@camstack/addon-admin-ui 0.1.28 → 0.1.31
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.
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-B73X4nGn.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BMrP2H8p.js} +1 -1
- package/dist/assets/browser-BXdiCFWD.js +8 -0
- package/dist/assets/{devices-Ccad-MYH.js → devices-CZsVkxKZ.js} +1 -1
- package/dist/assets/{hostInit-BHdA3fjn.js → hostInit-DIOhqSQ8.js} +1 -1
- package/dist/assets/index-4wFotr3p.js +1 -0
- package/dist/assets/{index-DDPTeM3J.js → index-B3ayOsQz.js} +24 -24
- package/dist/assets/{index-DV9irWJe.js → index-B4mdRb1N.js} +1 -1
- package/dist/assets/{index-D9kg0e9y.js → index-B7F0mwMZ.js} +1 -1
- package/dist/assets/index-CMnchRgf.css +1 -0
- package/dist/assets/index-DJIpFuqj.js +1 -0
- package/dist/assets/index-DSFtUS7Z.js +1 -0
- package/dist/assets/index-DUfO0e8s.js +80 -0
- package/dist/assets/index-Dc2Moq2w.js +1 -0
- package/dist/assets/index-FDG6Ru4K.js +1 -0
- package/dist/assets/index-Z_9-zlb_.js +1 -0
- package/dist/assets/index-lh_RKGLY.js +1118 -0
- package/dist/assets/method-access-map-D3ooxuVS.js +1 -0
- package/dist/assets/{remoteEntry-DNXn0OoH.js → remoteEntry-6Pin_7dI.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-PsaMcIkN.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-8g-kqXK4.js} +2 -2
- package/dist/index.html +6 -6
- package/dist/mf-entry-bootstrap-0.js +2 -2
- package/dist/sw.js +1 -1
- package/package.json +4 -1
- package/dist/assets/index-B21eY24R.css +0 -1
- package/dist/assets/index-CaiMG86U.js +0 -80
- package/dist/assets/index-D8EZjlIx.js +0 -1103
- package/dist/assets/index-DMrjJViX.js +0 -1
- package/dist/assets/index-DOXiszQ-.js +0 -1
- package/dist/assets/index-bCeHA7pg.js +0 -1
- package/dist/assets/index-ihiza8WC.js +0 -1
- package/dist/assets/index-vWF3glDx.js +0 -1
- package/dist/assets/index-zk-hwOKE.js +0 -1
- package/dist/assets/method-access-map-DAzkqn3U.js +0 -1
|
@@ -1,1103 +0,0 @@
|
|
|
1
|
-
import"./virtualExposes-_ivNhQLP.js";import{d as hr}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-PsaMcIkN.js";import{c as r,a as Df,d as u,e as ge,g as G1}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-C_6K4VBY.js";import{b as Oe,e as $,h as q,c as Z,f as U,d as ve,a as Lf,j as He,k as Me,i as ne,l as gr,m as Zs,g as Xs,R as El,n as $l,o as W1,p as Y1,q as br,r as Fe,s as Z1,t as X1,u as J1,v as ew}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-Dl4u0xYE.js";import{a as Tf,b as No}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-CzO_Esxm.js";import{a as Rf,b as Of}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-DNpf5SLz.js";import{_ as zf,m as Wn,n as ke,o as Bf,p as Ff,h as _l,j as tw}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-CeLhKMin.js";import{_ as jf,c as Hf,s as Vf,n as nw,B as rw,F as ow}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.mjs-DIkg6-MH.js";import{_ as qf,a as sw}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-OcRSBqRe.js";import{c as aw,D as On,a as st,M as iw,W as Di,S as hs}from"./index-DMrjJViX.js";import{S as Li,c as Uf}from"./devices-Ccad-MYH.js";import{E as Ne,A as lw,K as cw}from"./method-access-map-DAzkqn3U.js";import{s as dw}from"./index-D9kg0e9y.js";import{a as _d,S as Dd,s as uw}from"./index-zk-hwOKE.js";import{r as Qf}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-CSyOECfO.js";import"./preload-helper-BlTxHScW.js";import"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-xw6c6JeS.js";import"./schemas-XgIEoUz3.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function o(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();const Kf={frigate:"#3b82f6",scrypted:"#a855f7",reolink:"#06b6d4",homeAssistant:"#22d3ee",rtsp:"#78716c"},Gf={primary:"#f59e42",primaryForeground:"#0c0a09",background:"#0c0a09",backgroundElevated:"#1c1917",surface:"#1c1917",surfaceHover:"#292524",border:"#292524",borderSubtle:"#1c1917",foreground:"#fafaf9",foregroundMuted:"#a8a29e",foregroundSubtle:"#78716c",foregroundDisabled:"#57534e",success:"#4ade80",warning:"#fbbf24",danger:"#f87171",info:"#60a5fa",provider:Kf},Wf={primary:"#e67e22",primaryForeground:"#ffffff",background:"#fafaf9",backgroundElevated:"#ffffff",surface:"#f5f5f4",surfaceHover:"#e7e5e4",border:"#d6d3d1",borderSubtle:"#e7e5e4",foreground:"#1c1917",foregroundMuted:"#57534e",foregroundSubtle:"#78716c",foregroundDisabled:"#a8a29e",success:"#16a34a",warning:"#d97706",danger:"#dc2626",info:"#2563eb",provider:Kf},Ti={colors:{dark:Gf,light:Wf},spacing:{xs:2,sm:4,md:8,lg:12,xl:16,"2xl":24,"3xl":32},radius:{sm:4,md:6,lg:8,xl:12},typography:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',sizes:{xs:{fontSize:10,lineHeight:14},sm:{fontSize:11,lineHeight:16},base:{fontSize:12,lineHeight:18},lg:{fontSize:13,lineHeight:18},xl:{fontSize:14,lineHeight:20},"2xl":{fontSize:16,lineHeight:22},"3xl":{fontSize:20,lineHeight:28}},weights:{regular:400,medium:500,semibold:600,bold:700}},table:{rowHeight:28,headerHeight:24,cellPaddingX:8,cellPaddingY:6},sidebar:{width:176,itemHeight:28,iconSize:14}};function Yf(e,t){const n={...e};for(const o in t){const s=t[o],a=e[o];s!==void 0&&typeof s=="object"&&s!==null&&!Array.isArray(s)&&typeof a=="object"&&a!==null?n[o]=Yf(a,s):s!==void 0&&(n[o]=s)}return n}function pw(e){return e?Yf(structuredClone(Ti),e):structuredClone(Ti)}function Zf(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function fw(e){return`--color-${Zf(e)}`}function Ld(e){const t=[];for(const[n,o]of Object.entries(e))n!=="provider"&&t.push(` ${fw(n)}: ${o};`);return t.join(`
|
|
2
|
-
`)}function mw(e){const t=[];for(const[n,o]of Object.entries(e))t.push(` --color-provider-${Zf(n)}: ${o};`);return t.join(`
|
|
3
|
-
`)}function hw(e){const t=[];for(const[n,o]of Object.entries(e))t.push(` --spacing-${n}: ${o}px;`);return t.join(`
|
|
4
|
-
`)}function gw(e){const t=[];for(const[n,o]of Object.entries(e))t.push(` --radius-${n}: ${o}px;`);return t.join(`
|
|
5
|
-
`)}function bw(e){const t=Ld(e.colors.dark),n=Ld(e.colors.light),o=mw(e.colors.dark.provider),s=hw(e.spacing),a=gw(e.radius);return`@theme {
|
|
6
|
-
${o}
|
|
7
|
-
${s}
|
|
8
|
-
${a}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.dark {
|
|
12
|
-
${t}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.light {
|
|
16
|
-
${n}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@media (prefers-color-scheme: dark) {
|
|
20
|
-
:root {
|
|
21
|
-
${t.replace(/^ {2}/gm," ")}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@media (prefers-color-scheme: light) {
|
|
26
|
-
:root {
|
|
27
|
-
${n.replace(/^ {2}/gm," ")}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
`}const Xf=Oe(null),Fa=["dark","light","system"];function Jf(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function xw(e,t){if(typeof window>"u")return t;const n=localStorage.getItem(e);return n==="dark"||n==="light"||n==="system"?n:t}function Td(e){return e==="system"?Jf():e}function Cs({children:e,defaultMode:t="system",storageKey:n="camstack-theme-mode"}){const[o,s]=$(()=>xw(n,t)),[a,i]=$(()=>Td(o)),l=q(f=>{s(f),i(Td(f)),typeof window<"u"&&localStorage.setItem(n,f)},[n]),c=q(()=>{const p=(Fa.indexOf(o)+1)%Fa.length;l(Fa[p]??"dark")},[o,l]);Z(()=>{if(typeof document>"u")return;const f=document.documentElement;f.classList.remove("dark","light"),f.classList.add(a)},[o,a]),Z(()=>{if(typeof window>"u"||o!=="system")return;const f=window.matchMedia("(prefers-color-scheme: dark)"),p=()=>{i(Jf())};return f.addEventListener("change",p),()=>f.removeEventListener("change",p)},[o]);const d=U(()=>({mode:o,resolvedMode:a,setMode:l,toggleMode:c}),[o,a,l,c]);return r(Xf.Provider,{value:d,children:e})}function Ar(){const e=ve(Xf);if(!e)throw new Error("useThemeMode must be used within a ThemeProvider");return e}function em(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=em(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function tm(){for(var e,t,n=0,o="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=em(e))&&(o&&(o+=" "),o+=t);return o}const yw=(e,t)=>{const n=new Array(e.length+t.length);for(let o=0;o<e.length;o++)n[o]=e[o];for(let o=0;o<t.length;o++)n[e.length+o]=t[o];return n},vw=(e,t)=>({classGroupId:e,validator:t}),nm=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Ms="-",Rd=[],ww="arbitrary..",Nw=e=>{const t=Sw(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return kw(i);const l=i.split(Ms),c=l[0]===""&&l.length>1?1:0;return rm(l,c,t)},getConflictingClassGroupIds:(i,l)=>{if(l){const c=o[i],d=n[i];return c?d?yw(d,c):c:d||Rd}return n[i]||Rd}}},rm=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const s=e[t],a=n.nextPart.get(s);if(a){const d=rm(e,t+1,a);if(d)return d}const i=n.validators;if(i===null)return;const l=t===0?e.join(Ms):e.slice(t).join(Ms),c=i.length;for(let d=0;d<c;d++){const f=i[d];if(f.validator(l))return f.classGroupId}},kw=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),o=t.slice(0,n);return o?ww+o:void 0})(),Sw=e=>{const{theme:t,classGroups:n}=e;return Cw(n,t)},Cw=(e,t)=>{const n=nm();for(const o in e){const s=e[o];Dl(s,n,o,t)}return n},Dl=(e,t,n,o)=>{const s=e.length;for(let a=0;a<s;a++){const i=e[a];Mw(i,t,n,o)}},Mw=(e,t,n,o)=>{if(typeof e=="string"){Iw(e,t,n);return}if(typeof e=="function"){Aw(e,t,n,o);return}Pw(e,t,n,o)},Iw=(e,t,n)=>{const o=e===""?t:om(t,e);o.classGroupId=n},Aw=(e,t,n,o)=>{if(Ew(e)){Dl(e(o),t,n,o);return}t.validators===null&&(t.validators=[]),t.validators.push(vw(n,e))},Pw=(e,t,n,o)=>{const s=Object.entries(e),a=s.length;for(let i=0;i<a;i++){const[l,c]=s[i];Dl(c,om(t,l),n,o)}},om=(e,t)=>{let n=e;const o=t.split(Ms),s=o.length;for(let a=0;a<s;a++){const i=o[a];let l=n.nextPart.get(i);l||(l=nm(),n.nextPart.set(i,l)),n=l}return n},Ew=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,$w=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),o=Object.create(null);const s=(a,i)=>{n[a]=i,t++,t>e&&(t=0,o=n,n=Object.create(null))};return{get(a){let i=n[a];if(i!==void 0)return i;if((i=o[a])!==void 0)return s(a,i),i},set(a,i){a in n?n[a]=i:s(a,i)}}},Ri="!",Od=":",_w=[],zd=(e,t,n,o,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:o,isExternal:s}),Dw=e=>{const{prefix:t,experimentalParseClassName:n}=e;let o=s=>{const a=[];let i=0,l=0,c=0,d;const f=s.length;for(let b=0;b<f;b++){const x=s[b];if(i===0&&l===0){if(x===Od){a.push(s.slice(c,b)),c=b+1;continue}if(x==="/"){d=b;continue}}x==="["?i++:x==="]"?i--:x==="("?l++:x===")"&&l--}const p=a.length===0?s:s.slice(c);let m=p,h=!1;p.endsWith(Ri)?(m=p.slice(0,-1),h=!0):p.startsWith(Ri)&&(m=p.slice(1),h=!0);const g=d&&d>c?d-c:void 0;return zd(a,h,m,g)};if(t){const s=t+Od,a=o;o=i=>i.startsWith(s)?a(i.slice(s.length)):zd(_w,!1,i,void 0,!0)}if(n){const s=o;o=a=>n({className:a,parseClassName:s})}return o},Lw=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,o)=>{t.set(n,1e6+o)}),n=>{const o=[];let s=[];for(let a=0;a<n.length;a++){const i=n[a],l=i[0]==="[",c=t.has(i);l||c?(s.length>0&&(s.sort(),o.push(...s),s=[]),o.push(i)):s.push(i)}return s.length>0&&(s.sort(),o.push(...s)),o}},Tw=e=>({cache:$w(e.cacheSize),parseClassName:Dw(e),sortModifiers:Lw(e),...Nw(e)}),Rw=/\s+/,Ow=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:s,sortModifiers:a}=t,i=[],l=e.trim().split(Rw);let c="";for(let d=l.length-1;d>=0;d-=1){const f=l[d],{isExternal:p,modifiers:m,hasImportantModifier:h,baseClassName:g,maybePostfixModifierPosition:b}=n(f);if(p){c=f+(c.length>0?" "+c:c);continue}let x=!!b,y=o(x?g.substring(0,b):g);if(!y){if(!x){c=f+(c.length>0?" "+c:c);continue}if(y=o(g),!y){c=f+(c.length>0?" "+c:c);continue}x=!1}const w=m.length===0?"":m.length===1?m[0]:a(m).join(":"),v=h?w+Ri:w,N=v+y;if(i.indexOf(N)>-1)continue;i.push(N);const k=s(y,x);for(let S=0;S<k.length;++S){const M=k[S];i.push(v+M)}c=f+(c.length>0?" "+c:c)}return c},zw=(...e)=>{let t=0,n,o,s="";for(;t<e.length;)(n=e[t++])&&(o=sm(n))&&(s&&(s+=" "),s+=o);return s},sm=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=sm(e[o]))&&(n&&(n+=" "),n+=t);return n},Bw=(e,...t)=>{let n,o,s,a;const i=c=>{const d=t.reduce((f,p)=>p(f),e());return n=Tw(d),o=n.cache.get,s=n.cache.set,a=l,l(c)},l=c=>{const d=o(c);if(d)return d;const f=Ow(c,n);return s(c,f),f};return a=i,(...c)=>a(zw(...c))},Fw=[],Ke=e=>{const t=n=>n[e]||Fw;return t.isThemeGetter=!0,t},am=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,im=/^\((?:(\w[\w-]*):)?(.+)\)$/i,jw=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Hw=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Vw=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,qw=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Uw=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Qw=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,hn=e=>jw.test(e),Pe=e=>!!e&&!Number.isNaN(Number(e)),gn=e=>!!e&&Number.isInteger(Number(e)),ja=e=>e.endsWith("%")&&Pe(e.slice(0,-1)),Zt=e=>Hw.test(e),lm=()=>!0,Kw=e=>Vw.test(e)&&!qw.test(e),Ll=()=>!1,Gw=e=>Uw.test(e),Ww=e=>Qw.test(e),Yw=e=>!xe(e)&&!ye(e),Zw=e=>Cn(e,um,Ll),xe=e=>am.test(e),$n=e=>Cn(e,pm,Kw),Bd=e=>Cn(e,sN,Pe),Xw=e=>Cn(e,mm,lm),Jw=e=>Cn(e,fm,Ll),Fd=e=>Cn(e,cm,Ll),eN=e=>Cn(e,dm,Ww),Fo=e=>Cn(e,hm,Gw),ye=e=>im.test(e),Br=e=>Yn(e,pm),tN=e=>Yn(e,fm),jd=e=>Yn(e,cm),nN=e=>Yn(e,um),rN=e=>Yn(e,dm),jo=e=>Yn(e,hm,!0),oN=e=>Yn(e,mm,!0),Cn=(e,t,n)=>{const o=am.exec(e);return o?o[1]?t(o[1]):n(o[2]):!1},Yn=(e,t,n=!1)=>{const o=im.exec(e);return o?o[1]?t(o[1]):n:!1},cm=e=>e==="position"||e==="percentage",dm=e=>e==="image"||e==="url",um=e=>e==="length"||e==="size"||e==="bg-size",pm=e=>e==="length",sN=e=>e==="number",fm=e=>e==="family-name",mm=e=>e==="number"||e==="weight",hm=e=>e==="shadow",aN=()=>{const e=Ke("color"),t=Ke("font"),n=Ke("text"),o=Ke("font-weight"),s=Ke("tracking"),a=Ke("leading"),i=Ke("breakpoint"),l=Ke("container"),c=Ke("spacing"),d=Ke("radius"),f=Ke("shadow"),p=Ke("inset-shadow"),m=Ke("text-shadow"),h=Ke("drop-shadow"),g=Ke("blur"),b=Ke("perspective"),x=Ke("aspect"),y=Ke("ease"),w=Ke("animate"),v=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],k=()=>[...N(),ye,xe],S=()=>["auto","hidden","clip","visible","scroll"],M=()=>["auto","contain","none"],P=()=>[ye,xe,c],A=()=>[hn,"full","auto",...P()],z=()=>[gn,"none","subgrid",ye,xe],D=()=>["auto",{span:["full",gn,ye,xe]},gn,ye,xe],T=()=>[gn,"auto",ye,xe],O=()=>["auto","min","max","fr",ye,xe],I=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],L=()=>["start","end","center","stretch","center-safe","end-safe"],_=()=>["auto",...P()],R=()=>[hn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...P()],B=()=>[hn,"screen","full","dvw","lvw","svw","min","max","fit",...P()],F=()=>[hn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...P()],j=()=>[e,ye,xe],H=()=>[...N(),jd,Fd,{position:[ye,xe]}],E=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Q=()=>["auto","cover","contain",nN,Zw,{size:[ye,xe]}],K=()=>[ja,Br,$n],Y=()=>["","none","full",d,ye,xe],re=()=>["",Pe,Br,$n],te=()=>["solid","dashed","dotted","double"],X=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],oe=()=>[Pe,ja,jd,Fd],be=()=>["","none",g,ye,xe],J=()=>["none",Pe,ye,xe],G=()=>["none",Pe,ye,xe],ee=()=>[Pe,ye,xe],ae=()=>[hn,"full",...P()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Zt],breakpoint:[Zt],color:[lm],container:[Zt],"drop-shadow":[Zt],ease:["in","out","in-out"],font:[Yw],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Zt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Zt],shadow:[Zt],spacing:["px",Pe],text:[Zt],"text-shadow":[Zt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",hn,xe,ye,x]}],container:["container"],columns:[{columns:[Pe,xe,ye,l]}],"break-after":[{"break-after":v()}],"break-before":[{"break-before":v()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:k()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{"inset-s":A(),start:A()}],end:[{"inset-e":A(),end:A()}],"inset-bs":[{"inset-bs":A()}],"inset-be":[{"inset-be":A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[gn,"auto",ye,xe]}],basis:[{basis:[hn,"full","auto",l,...P()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Pe,hn,"auto","initial","none",xe]}],grow:[{grow:["",Pe,ye,xe]}],shrink:[{shrink:["",Pe,ye,xe]}],order:[{order:[gn,"first","last","none",ye,xe]}],"grid-cols":[{"grid-cols":z()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":z()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":T()}],"row-end":[{"row-end":T()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":O()}],"auto-rows":[{"auto-rows":O()}],gap:[{gap:P()}],"gap-x":[{"gap-x":P()}],"gap-y":[{"gap-y":P()}],"justify-content":[{justify:[...I(),"normal"]}],"justify-items":[{"justify-items":[...L(),"normal"]}],"justify-self":[{"justify-self":["auto",...L()]}],"align-content":[{content:["normal",...I()]}],"align-items":[{items:[...L(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...L(),{baseline:["","last"]}]}],"place-content":[{"place-content":I()}],"place-items":[{"place-items":[...L(),"baseline"]}],"place-self":[{"place-self":["auto",...L()]}],p:[{p:P()}],px:[{px:P()}],py:[{py:P()}],ps:[{ps:P()}],pe:[{pe:P()}],pbs:[{pbs:P()}],pbe:[{pbe:P()}],pt:[{pt:P()}],pr:[{pr:P()}],pb:[{pb:P()}],pl:[{pl:P()}],m:[{m:_()}],mx:[{mx:_()}],my:[{my:_()}],ms:[{ms:_()}],me:[{me:_()}],mbs:[{mbs:_()}],mbe:[{mbe:_()}],mt:[{mt:_()}],mr:[{mr:_()}],mb:[{mb:_()}],ml:[{ml:_()}],"space-x":[{"space-x":P()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":P()}],"space-y-reverse":["space-y-reverse"],size:[{size:R()}],"inline-size":[{inline:["auto",...B()]}],"min-inline-size":[{"min-inline":["auto",...B()]}],"max-inline-size":[{"max-inline":["none",...B()]}],"block-size":[{block:["auto",...F()]}],"min-block-size":[{"min-block":["auto",...F()]}],"max-block-size":[{"max-block":["none",...F()]}],w:[{w:[l,"screen",...R()]}],"min-w":[{"min-w":[l,"screen","none",...R()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...R()]}],h:[{h:["screen","lh",...R()]}],"min-h":[{"min-h":["screen","lh","none",...R()]}],"max-h":[{"max-h":["screen","lh",...R()]}],"font-size":[{text:["base",n,Br,$n]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,oN,Xw]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ja,xe]}],"font-family":[{font:[tN,Jw,t]}],"font-features":[{"font-features":[xe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,ye,xe]}],"line-clamp":[{"line-clamp":[Pe,"none",ye,Bd]}],leading:[{leading:[a,...P()]}],"list-image":[{"list-image":["none",ye,xe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ye,xe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:j()}],"text-color":[{text:j()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...te(),"wavy"]}],"text-decoration-thickness":[{decoration:[Pe,"from-font","auto",ye,$n]}],"text-decoration-color":[{decoration:j()}],"underline-offset":[{"underline-offset":[Pe,"auto",ye,xe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ye,xe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ye,xe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:E()}],"bg-size":[{bg:Q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},gn,ye,xe],radial:["",ye,xe],conic:[gn,ye,xe]},rN,eN]}],"bg-color":[{bg:j()}],"gradient-from-pos":[{from:K()}],"gradient-via-pos":[{via:K()}],"gradient-to-pos":[{to:K()}],"gradient-from":[{from:j()}],"gradient-via":[{via:j()}],"gradient-to":[{to:j()}],rounded:[{rounded:Y()}],"rounded-s":[{"rounded-s":Y()}],"rounded-e":[{"rounded-e":Y()}],"rounded-t":[{"rounded-t":Y()}],"rounded-r":[{"rounded-r":Y()}],"rounded-b":[{"rounded-b":Y()}],"rounded-l":[{"rounded-l":Y()}],"rounded-ss":[{"rounded-ss":Y()}],"rounded-se":[{"rounded-se":Y()}],"rounded-ee":[{"rounded-ee":Y()}],"rounded-es":[{"rounded-es":Y()}],"rounded-tl":[{"rounded-tl":Y()}],"rounded-tr":[{"rounded-tr":Y()}],"rounded-br":[{"rounded-br":Y()}],"rounded-bl":[{"rounded-bl":Y()}],"border-w":[{border:re()}],"border-w-x":[{"border-x":re()}],"border-w-y":[{"border-y":re()}],"border-w-s":[{"border-s":re()}],"border-w-e":[{"border-e":re()}],"border-w-bs":[{"border-bs":re()}],"border-w-be":[{"border-be":re()}],"border-w-t":[{"border-t":re()}],"border-w-r":[{"border-r":re()}],"border-w-b":[{"border-b":re()}],"border-w-l":[{"border-l":re()}],"divide-x":[{"divide-x":re()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":re()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...te(),"hidden","none"]}],"divide-style":[{divide:[...te(),"hidden","none"]}],"border-color":[{border:j()}],"border-color-x":[{"border-x":j()}],"border-color-y":[{"border-y":j()}],"border-color-s":[{"border-s":j()}],"border-color-e":[{"border-e":j()}],"border-color-bs":[{"border-bs":j()}],"border-color-be":[{"border-be":j()}],"border-color-t":[{"border-t":j()}],"border-color-r":[{"border-r":j()}],"border-color-b":[{"border-b":j()}],"border-color-l":[{"border-l":j()}],"divide-color":[{divide:j()}],"outline-style":[{outline:[...te(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Pe,ye,xe]}],"outline-w":[{outline:["",Pe,Br,$n]}],"outline-color":[{outline:j()}],shadow:[{shadow:["","none",f,jo,Fo]}],"shadow-color":[{shadow:j()}],"inset-shadow":[{"inset-shadow":["none",p,jo,Fo]}],"inset-shadow-color":[{"inset-shadow":j()}],"ring-w":[{ring:re()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:j()}],"ring-offset-w":[{"ring-offset":[Pe,$n]}],"ring-offset-color":[{"ring-offset":j()}],"inset-ring-w":[{"inset-ring":re()}],"inset-ring-color":[{"inset-ring":j()}],"text-shadow":[{"text-shadow":["none",m,jo,Fo]}],"text-shadow-color":[{"text-shadow":j()}],opacity:[{opacity:[Pe,ye,xe]}],"mix-blend":[{"mix-blend":[...X(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":X()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Pe]}],"mask-image-linear-from-pos":[{"mask-linear-from":oe()}],"mask-image-linear-to-pos":[{"mask-linear-to":oe()}],"mask-image-linear-from-color":[{"mask-linear-from":j()}],"mask-image-linear-to-color":[{"mask-linear-to":j()}],"mask-image-t-from-pos":[{"mask-t-from":oe()}],"mask-image-t-to-pos":[{"mask-t-to":oe()}],"mask-image-t-from-color":[{"mask-t-from":j()}],"mask-image-t-to-color":[{"mask-t-to":j()}],"mask-image-r-from-pos":[{"mask-r-from":oe()}],"mask-image-r-to-pos":[{"mask-r-to":oe()}],"mask-image-r-from-color":[{"mask-r-from":j()}],"mask-image-r-to-color":[{"mask-r-to":j()}],"mask-image-b-from-pos":[{"mask-b-from":oe()}],"mask-image-b-to-pos":[{"mask-b-to":oe()}],"mask-image-b-from-color":[{"mask-b-from":j()}],"mask-image-b-to-color":[{"mask-b-to":j()}],"mask-image-l-from-pos":[{"mask-l-from":oe()}],"mask-image-l-to-pos":[{"mask-l-to":oe()}],"mask-image-l-from-color":[{"mask-l-from":j()}],"mask-image-l-to-color":[{"mask-l-to":j()}],"mask-image-x-from-pos":[{"mask-x-from":oe()}],"mask-image-x-to-pos":[{"mask-x-to":oe()}],"mask-image-x-from-color":[{"mask-x-from":j()}],"mask-image-x-to-color":[{"mask-x-to":j()}],"mask-image-y-from-pos":[{"mask-y-from":oe()}],"mask-image-y-to-pos":[{"mask-y-to":oe()}],"mask-image-y-from-color":[{"mask-y-from":j()}],"mask-image-y-to-color":[{"mask-y-to":j()}],"mask-image-radial":[{"mask-radial":[ye,xe]}],"mask-image-radial-from-pos":[{"mask-radial-from":oe()}],"mask-image-radial-to-pos":[{"mask-radial-to":oe()}],"mask-image-radial-from-color":[{"mask-radial-from":j()}],"mask-image-radial-to-color":[{"mask-radial-to":j()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":N()}],"mask-image-conic-pos":[{"mask-conic":[Pe]}],"mask-image-conic-from-pos":[{"mask-conic-from":oe()}],"mask-image-conic-to-pos":[{"mask-conic-to":oe()}],"mask-image-conic-from-color":[{"mask-conic-from":j()}],"mask-image-conic-to-color":[{"mask-conic-to":j()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:E()}],"mask-size":[{mask:Q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ye,xe]}],filter:[{filter:["","none",ye,xe]}],blur:[{blur:be()}],brightness:[{brightness:[Pe,ye,xe]}],contrast:[{contrast:[Pe,ye,xe]}],"drop-shadow":[{"drop-shadow":["","none",h,jo,Fo]}],"drop-shadow-color":[{"drop-shadow":j()}],grayscale:[{grayscale:["",Pe,ye,xe]}],"hue-rotate":[{"hue-rotate":[Pe,ye,xe]}],invert:[{invert:["",Pe,ye,xe]}],saturate:[{saturate:[Pe,ye,xe]}],sepia:[{sepia:["",Pe,ye,xe]}],"backdrop-filter":[{"backdrop-filter":["","none",ye,xe]}],"backdrop-blur":[{"backdrop-blur":be()}],"backdrop-brightness":[{"backdrop-brightness":[Pe,ye,xe]}],"backdrop-contrast":[{"backdrop-contrast":[Pe,ye,xe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Pe,ye,xe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Pe,ye,xe]}],"backdrop-invert":[{"backdrop-invert":["",Pe,ye,xe]}],"backdrop-opacity":[{"backdrop-opacity":[Pe,ye,xe]}],"backdrop-saturate":[{"backdrop-saturate":[Pe,ye,xe]}],"backdrop-sepia":[{"backdrop-sepia":["",Pe,ye,xe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":P()}],"border-spacing-x":[{"border-spacing-x":P()}],"border-spacing-y":[{"border-spacing-y":P()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ye,xe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Pe,"initial",ye,xe]}],ease:[{ease:["linear","initial",y,ye,xe]}],delay:[{delay:[Pe,ye,xe]}],animate:[{animate:["none",w,ye,xe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,ye,xe]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:J()}],"rotate-x":[{"rotate-x":J()}],"rotate-y":[{"rotate-y":J()}],"rotate-z":[{"rotate-z":J()}],scale:[{scale:G()}],"scale-x":[{"scale-x":G()}],"scale-y":[{"scale-y":G()}],"scale-z":[{"scale-z":G()}],"scale-3d":["scale-3d"],skew:[{skew:ee()}],"skew-x":[{"skew-x":ee()}],"skew-y":[{"skew-y":ee()}],transform:[{transform:[ye,xe,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ae()}],"translate-x":[{"translate-x":ae()}],"translate-y":[{"translate-y":ae()}],"translate-z":[{"translate-z":ae()}],"translate-none":["translate-none"],accent:[{accent:j()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:j()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ye,xe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mbs":[{"scroll-mbs":P()}],"scroll-mbe":[{"scroll-mbe":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pbs":[{"scroll-pbs":P()}],"scroll-pbe":[{"scroll-pbe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ye,xe]}],fill:[{fill:["none",...j()]}],"stroke-w":[{stroke:[Pe,Br,$n,Bd]}],stroke:[{stroke:["none",...j()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},iN=Bw(aN);function W(...e){return iN(tm(e))}const lN="rounded-lg border border-border bg-surface overflow-hidden",cN="border-b border-border px-3 sm:px-4 py-1.5 sm:py-2",dN="p-2 sm:p-3 lg:p-4",gm="space-y-3 sm:space-y-4",bm="gap-2 sm:gap-3",xm="px-3 sm:px-4 py-1.5 sm:py-2",uN="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4",pN="grid grid-cols-1 lg:grid-cols-2",fN="flex flex-col-reverse md:flex-row",mN="w-full md:w-44 lg:w-52 md:flex-shrink-0 border-b md:border-b-0 md:border-l border-border",hN="text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider",gN="text-[11px] sm:text-xs text-foreground",Is="text-[10px] text-foreground-subtle",bN="text-[11px] sm:text-xs font-medium text-foreground",Oi="text-base sm:text-lg font-semibold leading-tight text-foreground",xN="inline-flex items-center justify-center gap-1 rounded border border-border bg-surface px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40",yN="inline-flex items-center justify-center gap-1 rounded border border-primary/40 bg-primary/15 px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-primary hover:bg-primary/25 transition-colors disabled:opacity-40",vN="inline-flex items-center justify-center gap-1 rounded border border-danger/40 bg-danger/10 px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-danger hover:bg-danger/20 transition-colors disabled:opacity-40",wN="inline-flex items-center justify-center gap-1 rounded border border-warning/40 bg-warning/10 px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-warning hover:bg-warning/20 transition-colors disabled:opacity-40",NN="w-full rounded border border-border bg-background px-1.5 py-0.5 sm:px-2 sm:py-1 text-[11px] sm:text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none",kN="inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors",SN="border-primary/50 bg-primary/15 text-primary",CN="border-border bg-surface text-foreground-subtle hover:bg-surface-hover";function MN(e,t){for(const n of e.slots)for(const o of n.addons)if(o.id===t)return o;return null}function IN(e,t){return e.models.find(n=>n.id===t)??null}function AN(e,t){return e.models.find(n=>!!n.formats[t])??null}function PN(e,t){const n=new Set((t.configSchema??[]).map(s=>s.key)),o={};for(const[s,a]of Object.entries(e))n.has(s)&&(o[s]=a);return o}function ym(e){const{source:t,target:n,catalog:o,addonIds:s}=e,a=[];for(const i of s){const l=t.defaults[i];if(!l){a.push({addonId:i,outcome:"skip",modelId:null,reason:"no source entry",patch:null});continue}const c=MN(o,i);if(!c){a.push({addonId:i,outcome:"skip",modelId:null,reason:"addon not in target catalog",patch:null});continue}const d=IN(c,l.modelId),f=d!==null&&!!d.formats[n.engine.format];let p,m;if(f)p=l.modelId,m="exact";else{const g=AN(c,n.engine.format);if(!g){a.push({addonId:i,outcome:"skip",modelId:null,reason:"no compatible model for target format",patch:null});continue}p=g.id,m="mapped"}const h={enabled:l.enabled,modelId:p,settings:PN(l.settings,c)};a.push({addonId:i,outcome:m,modelId:p,patch:h})}return a}const zi={idle:{label:"Idle",textColor:"text-foreground-subtle",badgeClass:"border-border bg-surface-hover text-foreground-subtle",dotClass:"bg-gray-400",icon:"PowerOff"},active:{label:"Active",textColor:"text-success",badgeClass:"border-success/40 bg-success/10 text-success",dotClass:"bg-red-500 animate-pulse",icon:"Activity"},watching:{label:"Watching",textColor:"text-foreground-subtle",badgeClass:"border-border bg-surface-hover text-foreground-subtle",dotClass:"bg-emerald-500",icon:"Eye"},"load-shed":{label:"Load-Shed",textColor:"text-amber-500",badgeClass:"border-amber-500/40 bg-amber-500/10 text-amber-500",dotClass:"bg-amber-500",icon:"AlertTriangle"},paused:{label:"Paused",textColor:"text-gray-400",badgeClass:"border-gray-500/40 bg-gray-500/10 text-gray-400",dotClass:"bg-gray-400",icon:"PauseCircle"}};function Zn(e){return zi[e]??zi.watching}function un(e,t){if(typeof globalThis>"u")return Oe(t);const n=globalThis.__camstackSharedContexts,o=n??new Map;n||(globalThis.__camstackSharedContexts=o);const s=o.get(e);if(s)return s;const a=Oe(t);return o.set(e,a),a}function dr(e){const n=(typeof globalThis<"u"?globalThis:void 0)?.[e];return n&&typeof n=="object"?n:{}}const EN={singleton:!0,requiredVersion:!1,eager:!0},Bt=e=>({version:"0.0.0",scope:"default",lib:e,shareConfig:EN}),Hd="__mf_module_cache__";function $N(){const e=globalThis,t=e[Hd];if(t&&typeof t=="object"){const o=t;return o.share??={},o.remote??={},o}const n={share:{},remote:{}};return e[Hd]=n,n}function _N(){const e=$N();e.share.react??=Lf,e.share["react-dom"]??=Tf,e.share["react-dom/client"]??=Rf,e.share["react/jsx-runtime"]??=Df,e.share["@tanstack/react-query"]??=zf,e.share["@trpc/client"]??=jf,e.share["@trpc/react-query"]??=qf,e.share["@camstack/ui-library"]??=dr("__camstackUiLibrary"),e.share["@camstack/sdk"]??=dr("__camstackSdk"),e.share["@camstack/types"]??=dr("__camstackTypes")}function Tl(){_N(),hr.getInstance()===null&&hr.init({name:"admin_ui_host",remotes:[],shared:{react:Bt(()=>Lf),"react-dom":Bt(()=>Tf),"react-dom/client":Bt(()=>Rf),"react/jsx-runtime":Bt(()=>Df),"@tanstack/react-query":Bt(()=>zf),"@trpc/client":Bt(()=>jf),"@trpc/react-query":Bt(()=>qf),"@camstack/ui-library":Bt(()=>dr("__camstackUiLibrary")),"@camstack/sdk":Bt(()=>dr("__camstackSdk")),"@camstack/types":Bt(()=>dr("__camstackTypes"))}})}/**
|
|
31
|
-
* @license lucide-react v0.576.0 - ISC
|
|
32
|
-
*
|
|
33
|
-
* This source code is licensed under the ISC license.
|
|
34
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
35
|
-
*/const vm=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim();/**
|
|
36
|
-
* @license lucide-react v0.576.0 - ISC
|
|
37
|
-
*
|
|
38
|
-
* This source code is licensed under the ISC license.
|
|
39
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
40
|
-
*/const DN=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
41
|
-
* @license lucide-react v0.576.0 - ISC
|
|
42
|
-
*
|
|
43
|
-
* This source code is licensed under the ISC license.
|
|
44
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
45
|
-
*/const LN=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase());/**
|
|
46
|
-
* @license lucide-react v0.576.0 - ISC
|
|
47
|
-
*
|
|
48
|
-
* This source code is licensed under the ISC license.
|
|
49
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
50
|
-
*/const Vd=e=>{const t=LN(e);return t.charAt(0).toUpperCase()+t.slice(1)};/**
|
|
51
|
-
* @license lucide-react v0.576.0 - ISC
|
|
52
|
-
*
|
|
53
|
-
* This source code is licensed under the ISC license.
|
|
54
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
55
|
-
*/var TN={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
56
|
-
* @license lucide-react v0.576.0 - ISC
|
|
57
|
-
*
|
|
58
|
-
* This source code is licensed under the ISC license.
|
|
59
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
60
|
-
*/const RN=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/**
|
|
61
|
-
* @license lucide-react v0.576.0 - ISC
|
|
62
|
-
*
|
|
63
|
-
* This source code is licensed under the ISC license.
|
|
64
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
65
|
-
*/const ON=He(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:s="",children:a,iconNode:i,...l},c)=>Me("svg",{ref:c,...TN,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:vm("lucide",s),...!a&&!RN(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,f])=>Me(d,f)),...Array.isArray(a)?a:[a]]));/**
|
|
66
|
-
* @license lucide-react v0.576.0 - ISC
|
|
67
|
-
*
|
|
68
|
-
* This source code is licensed under the ISC license.
|
|
69
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
70
|
-
*/const le=(e,t)=>{const n=He(({className:o,...s},a)=>Me(ON,{ref:a,iconNode:t,className:vm(`lucide-${DN(Vd(e))}`,`lucide-${e}`,o),...s}));return n.displayName=Vd(e),n};/**
|
|
71
|
-
* @license lucide-react v0.576.0 - ISC
|
|
72
|
-
*
|
|
73
|
-
* This source code is licensed under the ISC license.
|
|
74
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
75
|
-
*/const zN=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],vn=le("activity",zN);/**
|
|
76
|
-
* @license lucide-react v0.576.0 - ISC
|
|
77
|
-
*
|
|
78
|
-
* This source code is licensed under the ISC license.
|
|
79
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
80
|
-
*/const BN=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],FN=le("arrow-down",BN);/**
|
|
81
|
-
* @license lucide-react v0.576.0 - ISC
|
|
82
|
-
*
|
|
83
|
-
* This source code is licensed under the ISC license.
|
|
84
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
85
|
-
*/const jN=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],HN=le("arrow-left",jN);/**
|
|
86
|
-
* @license lucide-react v0.576.0 - ISC
|
|
87
|
-
*
|
|
88
|
-
* This source code is licensed under the ISC license.
|
|
89
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
90
|
-
*/const VN=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],qN=le("arrow-right",VN);/**
|
|
91
|
-
* @license lucide-react v0.576.0 - ISC
|
|
92
|
-
*
|
|
93
|
-
* This source code is licensed under the ISC license.
|
|
94
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
95
|
-
*/const UN=[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]],Rl=le("arrow-up-to-line",UN);/**
|
|
96
|
-
* @license lucide-react v0.576.0 - ISC
|
|
97
|
-
*
|
|
98
|
-
* This source code is licensed under the ISC license.
|
|
99
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
100
|
-
*/const QN=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],KN=le("arrow-up",QN);/**
|
|
101
|
-
* @license lucide-react v0.576.0 - ISC
|
|
102
|
-
*
|
|
103
|
-
* This source code is licensed under the ISC license.
|
|
104
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
105
|
-
*/const GN=[["path",{d:"M10 10v4",key:"1mb2ec"}],["path",{d:"M14 10v4",key:"1nt88p"}],["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 10v4",key:"1n77qd"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],WN=le("battery-full",GN);/**
|
|
106
|
-
* @license lucide-react v0.576.0 - ISC
|
|
107
|
-
*
|
|
108
|
-
* This source code is licensed under the ISC license.
|
|
109
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
110
|
-
*/const YN=[["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 14v-4",key:"14a6bd"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],ZN=le("battery-low",YN);/**
|
|
111
|
-
* @license lucide-react v0.576.0 - ISC
|
|
112
|
-
*
|
|
113
|
-
* This source code is licensed under the ISC license.
|
|
114
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
115
|
-
*/const XN=[["path",{d:"M10 17h.01",key:"nbq80n"}],["path",{d:"M10 7v6",key:"nne03l"}],["path",{d:"M14 6h2a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2",key:"1m83kb"}],["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 18H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"h8lgfh"}]],JN=le("battery-warning",XN);/**
|
|
116
|
-
* @license lucide-react v0.576.0 - ISC
|
|
117
|
-
*
|
|
118
|
-
* This source code is licensed under the ISC license.
|
|
119
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
120
|
-
*/const e2=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],wm=le("battery",e2);/**
|
|
121
|
-
* @license lucide-react v0.576.0 - ISC
|
|
122
|
-
*
|
|
123
|
-
* This source code is licensed under the ISC license.
|
|
124
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
125
|
-
*/const t2=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]],n2=le("bell-ring",t2);/**
|
|
126
|
-
* @license lucide-react v0.576.0 - ISC
|
|
127
|
-
*
|
|
128
|
-
* This source code is licensed under the ISC license.
|
|
129
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
130
|
-
*/const r2=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Js=le("bell",r2);/**
|
|
131
|
-
* @license lucide-react v0.576.0 - ISC
|
|
132
|
-
*
|
|
133
|
-
* This source code is licensed under the ISC license.
|
|
134
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
135
|
-
*/const o2=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],s2=le("bug",o2);/**
|
|
136
|
-
* @license lucide-react v0.576.0 - ISC
|
|
137
|
-
*
|
|
138
|
-
* This source code is licensed under the ISC license.
|
|
139
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
140
|
-
*/const a2=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Ol=le("camera",a2);/**
|
|
141
|
-
* @license lucide-react v0.576.0 - ISC
|
|
142
|
-
*
|
|
143
|
-
* This source code is licensed under the ISC license.
|
|
144
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
145
|
-
*/const i2=[["path",{d:"M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6",key:"3zrzxg"}],["path",{d:"M2 12a9 9 0 0 1 8 8",key:"g6cvee"}],["path",{d:"M2 16a5 5 0 0 1 4 4",key:"1y1dii"}],["line",{x1:"2",x2:"2.01",y1:"20",y2:"20",key:"xu2jvo"}]],l2=le("cast",i2);/**
|
|
146
|
-
* @license lucide-react v0.576.0 - ISC
|
|
147
|
-
*
|
|
148
|
-
* This source code is licensed under the ISC license.
|
|
149
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
150
|
-
*/const c2=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ko=le("check",c2);/**
|
|
151
|
-
* @license lucide-react v0.576.0 - ISC
|
|
152
|
-
*
|
|
153
|
-
* This source code is licensed under the ISC license.
|
|
154
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
155
|
-
*/const d2=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Xn=le("chevron-down",d2);/**
|
|
156
|
-
* @license lucide-react v0.576.0 - ISC
|
|
157
|
-
*
|
|
158
|
-
* This source code is licensed under the ISC license.
|
|
159
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
160
|
-
*/const u2=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],p2=le("chevron-left",u2);/**
|
|
161
|
-
* @license lucide-react v0.576.0 - ISC
|
|
162
|
-
*
|
|
163
|
-
* This source code is licensed under the ISC license.
|
|
164
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
165
|
-
*/const f2=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Mn=le("chevron-right",f2);/**
|
|
166
|
-
* @license lucide-react v0.576.0 - ISC
|
|
167
|
-
*
|
|
168
|
-
* This source code is licensed under the ISC license.
|
|
169
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
170
|
-
*/const m2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],ea=le("circle-alert",m2);/**
|
|
171
|
-
* @license lucide-react v0.576.0 - ISC
|
|
172
|
-
*
|
|
173
|
-
* This source code is licensed under the ISC license.
|
|
174
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
175
|
-
*/const h2=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],g2=le("circle-check-big",h2);/**
|
|
176
|
-
* @license lucide-react v0.576.0 - ISC
|
|
177
|
-
*
|
|
178
|
-
* This source code is licensed under the ISC license.
|
|
179
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
180
|
-
*/const b2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],x2=le("circle-check",b2);/**
|
|
181
|
-
* @license lucide-react v0.576.0 - ISC
|
|
182
|
-
*
|
|
183
|
-
* This source code is licensed under the ISC license.
|
|
184
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
185
|
-
*/const y2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],v2=le("circle-dot",y2);/**
|
|
186
|
-
* @license lucide-react v0.576.0 - ISC
|
|
187
|
-
*
|
|
188
|
-
* This source code is licensed under the ISC license.
|
|
189
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
190
|
-
*/const w2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]],N2=le("circle-pause",w2);/**
|
|
191
|
-
* @license lucide-react v0.576.0 - ISC
|
|
192
|
-
*
|
|
193
|
-
* This source code is licensed under the ISC license.
|
|
194
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
195
|
-
*/const k2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],S2=le("circle-plus",k2);/**
|
|
196
|
-
* @license lucide-react v0.576.0 - ISC
|
|
197
|
-
*
|
|
198
|
-
* This source code is licensed under the ISC license.
|
|
199
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
200
|
-
*/const C2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Nm=le("circle-question-mark",C2);/**
|
|
201
|
-
* @license lucide-react v0.576.0 - ISC
|
|
202
|
-
*
|
|
203
|
-
* This source code is licensed under the ISC license.
|
|
204
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
205
|
-
*/const M2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],I2=le("circle-x",M2);/**
|
|
206
|
-
* @license lucide-react v0.576.0 - ISC
|
|
207
|
-
*
|
|
208
|
-
* This source code is licensed under the ISC license.
|
|
209
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
210
|
-
*/const A2=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],P2=le("copy-plus",A2);/**
|
|
211
|
-
* @license lucide-react v0.576.0 - ISC
|
|
212
|
-
*
|
|
213
|
-
* This source code is licensed under the ISC license.
|
|
214
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
215
|
-
*/const E2=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],In=le("copy",E2);/**
|
|
216
|
-
* @license lucide-react v0.576.0 - ISC
|
|
217
|
-
*
|
|
218
|
-
* This source code is licensed under the ISC license.
|
|
219
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
220
|
-
*/const $2=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],_2=le("cpu",$2);/**
|
|
221
|
-
* @license lucide-react v0.576.0 - ISC
|
|
222
|
-
*
|
|
223
|
-
* This source code is licensed under the ISC license.
|
|
224
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
225
|
-
*/const D2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],km=le("crosshair",D2);/**
|
|
226
|
-
* @license lucide-react v0.576.0 - ISC
|
|
227
|
-
*
|
|
228
|
-
* This source code is licensed under the ISC license.
|
|
229
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
230
|
-
*/const L2=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],T2=le("database",L2);/**
|
|
231
|
-
* @license lucide-react v0.576.0 - ISC
|
|
232
|
-
*
|
|
233
|
-
* This source code is licensed under the ISC license.
|
|
234
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
235
|
-
*/const R2=[["path",{d:"M11 20H2",key:"nlcfvz"}],["path",{d:"M11 4.562v16.157a1 1 0 0 0 1.242.97L19 20V5.562a2 2 0 0 0-1.515-1.94l-4-1A2 2 0 0 0 11 4.561z",key:"au4z13"}],["path",{d:"M11 4H8a2 2 0 0 0-2 2v14",key:"74r1mk"}],["path",{d:"M14 12h.01",key:"1jfl7z"}],["path",{d:"M22 20h-3",key:"vhrsz"}]],Sm=le("door-open",R2);/**
|
|
236
|
-
* @license lucide-react v0.576.0 - ISC
|
|
237
|
-
*
|
|
238
|
-
* This source code is licensed under the ISC license.
|
|
239
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
240
|
-
*/const O2=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Bi=le("download",O2);/**
|
|
241
|
-
* @license lucide-react v0.576.0 - ISC
|
|
242
|
-
*
|
|
243
|
-
* This source code is licensed under the ISC license.
|
|
244
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
245
|
-
*/const z2=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Cm=le("ellipsis-vertical",z2);/**
|
|
246
|
-
* @license lucide-react v0.576.0 - ISC
|
|
247
|
-
*
|
|
248
|
-
* This source code is licensed under the ISC license.
|
|
249
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
250
|
-
*/const B2=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Mm=le("external-link",B2);/**
|
|
251
|
-
* @license lucide-react v0.576.0 - ISC
|
|
252
|
-
*
|
|
253
|
-
* This source code is licensed under the ISC license.
|
|
254
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
255
|
-
*/const F2=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Im=le("eye-off",F2);/**
|
|
256
|
-
* @license lucide-react v0.576.0 - ISC
|
|
257
|
-
*
|
|
258
|
-
* This source code is licensed under the ISC license.
|
|
259
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
260
|
-
*/const j2=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],So=le("eye",j2);/**
|
|
261
|
-
* @license lucide-react v0.576.0 - ISC
|
|
262
|
-
*
|
|
263
|
-
* This source code is licensed under the ISC license.
|
|
264
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
265
|
-
*/const H2=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Am=le("funnel",H2);/**
|
|
266
|
-
* @license lucide-react v0.576.0 - ISC
|
|
267
|
-
*
|
|
268
|
-
* This source code is licensed under the ISC license.
|
|
269
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
270
|
-
*/const V2=[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]],q2=le("grip-horizontal",V2);/**
|
|
271
|
-
* @license lucide-react v0.576.0 - ISC
|
|
272
|
-
*
|
|
273
|
-
* This source code is licensed under the ISC license.
|
|
274
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
275
|
-
*/const U2=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Pm=le("house",U2);/**
|
|
276
|
-
* @license lucide-react v0.576.0 - ISC
|
|
277
|
-
*
|
|
278
|
-
* This source code is licensed under the ISC license.
|
|
279
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
280
|
-
*/const Q2=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],K2=le("image",Q2);/**
|
|
281
|
-
* @license lucide-react v0.576.0 - ISC
|
|
282
|
-
*
|
|
283
|
-
* This source code is licensed under the ISC license.
|
|
284
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
285
|
-
*/const G2=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],W2=le("inbox",G2);/**
|
|
286
|
-
* @license lucide-react v0.576.0 - ISC
|
|
287
|
-
*
|
|
288
|
-
* This source code is licensed under the ISC license.
|
|
289
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
290
|
-
*/const Y2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Z2=le("info",Y2);/**
|
|
291
|
-
* @license lucide-react v0.576.0 - ISC
|
|
292
|
-
*
|
|
293
|
-
* This source code is licensed under the ISC license.
|
|
294
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
295
|
-
*/const X2=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],J2=le("layout-grid",X2);/**
|
|
296
|
-
* @license lucide-react v0.576.0 - ISC
|
|
297
|
-
*
|
|
298
|
-
* This source code is licensed under the ISC license.
|
|
299
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
300
|
-
*/const ek=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],Em=le("lightbulb",ek);/**
|
|
301
|
-
* @license lucide-react v0.576.0 - ISC
|
|
302
|
-
*
|
|
303
|
-
* This source code is licensed under the ISC license.
|
|
304
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
305
|
-
*/const tk=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Lt=le("loader-circle",tk);/**
|
|
306
|
-
* @license lucide-react v0.576.0 - ISC
|
|
307
|
-
*
|
|
308
|
-
* This source code is licensed under the ISC license.
|
|
309
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
310
|
-
*/const nk=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],rk=le("locate-fixed",nk);/**
|
|
311
|
-
* @license lucide-react v0.576.0 - ISC
|
|
312
|
-
*
|
|
313
|
-
* This source code is licensed under the ISC license.
|
|
314
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
315
|
-
*/const ok=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],qd=le("maximize-2",ok);/**
|
|
316
|
-
* @license lucide-react v0.576.0 - ISC
|
|
317
|
-
*
|
|
318
|
-
* This source code is licensed under the ISC license.
|
|
319
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
320
|
-
*/const sk=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],ak=le("menu",sk);/**
|
|
321
|
-
* @license lucide-react v0.576.0 - ISC
|
|
322
|
-
*
|
|
323
|
-
* This source code is licensed under the ISC license.
|
|
324
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
325
|
-
*/const ik=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],$m=le("mic",ik);/**
|
|
326
|
-
* @license lucide-react v0.576.0 - ISC
|
|
327
|
-
*
|
|
328
|
-
* This source code is licensed under the ISC license.
|
|
329
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
330
|
-
*/const lk=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Ud=le("minimize-2",lk);/**
|
|
331
|
-
* @license lucide-react v0.576.0 - ISC
|
|
332
|
-
*
|
|
333
|
-
* This source code is licensed under the ISC license.
|
|
334
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
335
|
-
*/const ck=[["path",{d:"M5 12h14",key:"1ays0h"}]],_m=le("minus",ck);/**
|
|
336
|
-
* @license lucide-react v0.576.0 - ISC
|
|
337
|
-
*
|
|
338
|
-
* This source code is licensed under the ISC license.
|
|
339
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
340
|
-
*/const dk=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],zl=le("moon",dk);/**
|
|
341
|
-
* @license lucide-react v0.576.0 - ISC
|
|
342
|
-
*
|
|
343
|
-
* This source code is licensed under the ISC license.
|
|
344
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
345
|
-
*/const uk=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],pk=le("music",uk);/**
|
|
346
|
-
* @license lucide-react v0.576.0 - ISC
|
|
347
|
-
*
|
|
348
|
-
* This source code is licensed under the ISC license.
|
|
349
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
350
|
-
*/const fk=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Fi=le("network",fk);/**
|
|
351
|
-
* @license lucide-react v0.576.0 - ISC
|
|
352
|
-
*
|
|
353
|
-
* This source code is licensed under the ISC license.
|
|
354
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
355
|
-
*/const mk=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],hk=le("pencil",mk);/**
|
|
356
|
-
* @license lucide-react v0.576.0 - ISC
|
|
357
|
-
*
|
|
358
|
-
* This source code is licensed under the ISC license.
|
|
359
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
360
|
-
*/const gk=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],ji=le("play",gk);/**
|
|
361
|
-
* @license lucide-react v0.576.0 - ISC
|
|
362
|
-
*
|
|
363
|
-
* This source code is licensed under the ISC license.
|
|
364
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
365
|
-
*/const bk=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Co=le("plus",bk);/**
|
|
366
|
-
* @license lucide-react v0.576.0 - ISC
|
|
367
|
-
*
|
|
368
|
-
* This source code is licensed under the ISC license.
|
|
369
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
370
|
-
*/const xk=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],yk=le("plug",xk);/**
|
|
371
|
-
* @license lucide-react v0.576.0 - ISC
|
|
372
|
-
*
|
|
373
|
-
* This source code is licensed under the ISC license.
|
|
374
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
375
|
-
*/const vk=[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],wk=le("power-off",vk);/**
|
|
376
|
-
* @license lucide-react v0.576.0 - ISC
|
|
377
|
-
*
|
|
378
|
-
* This source code is licensed under the ISC license.
|
|
379
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
380
|
-
*/const Nk=[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]],Dm=le("radar",Nk);/**
|
|
381
|
-
* @license lucide-react v0.576.0 - ISC
|
|
382
|
-
*
|
|
383
|
-
* This source code is licensed under the ISC license.
|
|
384
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
385
|
-
*/const kk=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Sk=le("radio",kk);/**
|
|
386
|
-
* @license lucide-react v0.576.0 - ISC
|
|
387
|
-
*
|
|
388
|
-
* This source code is licensed under the ISC license.
|
|
389
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
390
|
-
*/const Ck=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Bl=le("refresh-cw",Ck);/**
|
|
391
|
-
* @license lucide-react v0.576.0 - ISC
|
|
392
|
-
*
|
|
393
|
-
* This source code is licensed under the ISC license.
|
|
394
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
395
|
-
*/const Mk=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Lm=le("rotate-ccw",Mk);/**
|
|
396
|
-
* @license lucide-react v0.576.0 - ISC
|
|
397
|
-
*
|
|
398
|
-
* This source code is licensed under the ISC license.
|
|
399
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
400
|
-
*/const Ik=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Tm=le("rotate-cw",Ik);/**
|
|
401
|
-
* @license lucide-react v0.576.0 - ISC
|
|
402
|
-
*
|
|
403
|
-
* This source code is licensed under the ISC license.
|
|
404
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
405
|
-
*/const Ak=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Pk=le("save",Ak);/**
|
|
406
|
-
* @license lucide-react v0.576.0 - ISC
|
|
407
|
-
*
|
|
408
|
-
* This source code is licensed under the ISC license.
|
|
409
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
410
|
-
*/const Ek=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],$k=le("scan",Ek);/**
|
|
411
|
-
* @license lucide-react v0.576.0 - ISC
|
|
412
|
-
*
|
|
413
|
-
* This source code is licensed under the ISC license.
|
|
414
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
415
|
-
*/const _k=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],Dk=le("scroll-text",_k);/**
|
|
416
|
-
* @license lucide-react v0.576.0 - ISC
|
|
417
|
-
*
|
|
418
|
-
* This source code is licensed under the ISC license.
|
|
419
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
420
|
-
*/const Lk=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],so=le("search",Lk);/**
|
|
421
|
-
* @license lucide-react v0.576.0 - ISC
|
|
422
|
-
*
|
|
423
|
-
* This source code is licensed under the ISC license.
|
|
424
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
425
|
-
*/const Tk=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Rk=le("server",Tk);/**
|
|
426
|
-
* @license lucide-react v0.576.0 - ISC
|
|
427
|
-
*
|
|
428
|
-
* This source code is licensed under the ISC license.
|
|
429
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
430
|
-
*/const Ok=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],zk=le("shield",Ok);/**
|
|
431
|
-
* @license lucide-react v0.576.0 - ISC
|
|
432
|
-
*
|
|
433
|
-
* This source code is licensed under the ISC license.
|
|
434
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
435
|
-
*/const Bk=[["path",{d:"M12 10.189V14",key:"1p8cqu"}],["path",{d:"M12 2v3",key:"qbqxhf"}],["path",{d:"M19 13V7a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v6",key:"qpkstq"}],["path",{d:"M19.38 20A11.6 11.6 0 0 0 21 14l-8.188-3.639a2 2 0 0 0-1.624 0L3 14a11.6 11.6 0 0 0 2.81 7.76",key:"7tigtc"}],["path",{d:"M2 21c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1s1.2 1 2.5 1c2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"1924j5"}]],Fk=le("ship",Bk);/**
|
|
436
|
-
* @license lucide-react v0.576.0 - ISC
|
|
437
|
-
*
|
|
438
|
-
* This source code is licensed under the ISC license.
|
|
439
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
440
|
-
*/const jk=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],Hk=le("sliders-horizontal",jk);/**
|
|
441
|
-
* @license lucide-react v0.576.0 - ISC
|
|
442
|
-
*
|
|
443
|
-
* This source code is licensed under the ISC license.
|
|
444
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
445
|
-
*/const Vk=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Qd=le("square",Vk);/**
|
|
446
|
-
* @license lucide-react v0.576.0 - ISC
|
|
447
|
-
*
|
|
448
|
-
* This source code is licensed under the ISC license.
|
|
449
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
450
|
-
*/const qk=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],Uk=le("star",qk);/**
|
|
451
|
-
* @license lucide-react v0.576.0 - ISC
|
|
452
|
-
*
|
|
453
|
-
* This source code is licensed under the ISC license.
|
|
454
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
455
|
-
*/const Qk=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Rm=le("sun",Qk);/**
|
|
456
|
-
* @license lucide-react v0.576.0 - ISC
|
|
457
|
-
*
|
|
458
|
-
* This source code is licensed under the ISC license.
|
|
459
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
460
|
-
*/const Kk=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],Gk=le("table-2",Kk);/**
|
|
461
|
-
* @license lucide-react v0.576.0 - ISC
|
|
462
|
-
*
|
|
463
|
-
* This source code is licensed under the ISC license.
|
|
464
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
465
|
-
*/const Wk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Kd=le("target",Wk);/**
|
|
466
|
-
* @license lucide-react v0.576.0 - ISC
|
|
467
|
-
*
|
|
468
|
-
* This source code is licensed under the ISC license.
|
|
469
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
470
|
-
*/const Yk=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Zk=le("thermometer",Yk);/**
|
|
471
|
-
* @license lucide-react v0.576.0 - ISC
|
|
472
|
-
*
|
|
473
|
-
* This source code is licensed under the ISC license.
|
|
474
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
475
|
-
*/const Xk=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],Jk=le("toggle-left",Xk);/**
|
|
476
|
-
* @license lucide-react v0.576.0 - ISC
|
|
477
|
-
*
|
|
478
|
-
* This source code is licensed under the ISC license.
|
|
479
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
480
|
-
*/const e5=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Qt=le("trash-2",e5);/**
|
|
481
|
-
* @license lucide-react v0.576.0 - ISC
|
|
482
|
-
*
|
|
483
|
-
* This source code is licensed under the ISC license.
|
|
484
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
485
|
-
*/const t5=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],n5=le("trending-up",t5);/**
|
|
486
|
-
* @license lucide-react v0.576.0 - ISC
|
|
487
|
-
*
|
|
488
|
-
* This source code is licensed under the ISC license.
|
|
489
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
490
|
-
*/const r5=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],o5=le("trending-down",r5);/**
|
|
491
|
-
* @license lucide-react v0.576.0 - ISC
|
|
492
|
-
*
|
|
493
|
-
* This source code is licensed under the ISC license.
|
|
494
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
495
|
-
*/const s5=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Mo=le("triangle-alert",s5);/**
|
|
496
|
-
* @license lucide-react v0.576.0 - ISC
|
|
497
|
-
*
|
|
498
|
-
* This source code is licensed under the ISC license.
|
|
499
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
500
|
-
*/const a5=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Om=le("upload",a5);/**
|
|
501
|
-
* @license lucide-react v0.576.0 - ISC
|
|
502
|
-
*
|
|
503
|
-
* This source code is licensed under the ISC license.
|
|
504
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
505
|
-
*/const i5=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],l5=le("wifi-off",i5);/**
|
|
506
|
-
* @license lucide-react v0.576.0 - ISC
|
|
507
|
-
*
|
|
508
|
-
* This source code is licensed under the ISC license.
|
|
509
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
510
|
-
*/const c5=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],zm=le("wifi",c5);/**
|
|
511
|
-
* @license lucide-react v0.576.0 - ISC
|
|
512
|
-
*
|
|
513
|
-
* This source code is licensed under the ISC license.
|
|
514
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
515
|
-
*/const d5=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Fl=le("wrench",d5);/**
|
|
516
|
-
* @license lucide-react v0.576.0 - ISC
|
|
517
|
-
*
|
|
518
|
-
* This source code is licensed under the ISC license.
|
|
519
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
520
|
-
*/const u5=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ye=le("x",u5);/**
|
|
521
|
-
* @license lucide-react v0.576.0 - ISC
|
|
522
|
-
*
|
|
523
|
-
* This source code is licensed under the ISC license.
|
|
524
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
525
|
-
*/const p5=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Gd=le("zap",p5);/**
|
|
526
|
-
* @license lucide-react v0.576.0 - ISC
|
|
527
|
-
*
|
|
528
|
-
* This source code is licensed under the ISC license.
|
|
529
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
530
|
-
*/const f5=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],m5=le("zoom-in",f5);/**
|
|
531
|
-
* @license lucide-react v0.576.0 - ISC
|
|
532
|
-
*
|
|
533
|
-
* This source code is licensed under the ISC license.
|
|
534
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
535
|
-
*/const h5=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],g5=le("zoom-out",h5),b5={frigate:Fk,scrypted:zk,reolink:Sk,homeAssistant:Pm,rtsp:l2},x5={online:x2,offline:I2,degraded:ea,unknown:Nm},Wd=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Yd=tm,Jn=(e,t)=>n=>{var o;if(t?.variants==null)return Yd(e,n?.class,n?.className);const{variants:s,defaultVariants:a}=t,i=Object.keys(s).map(d=>{const f=n?.[d],p=a?.[d];if(f===null)return null;const m=Wd(f)||Wd(p);return s[d][m]}),l=n&&Object.entries(n).reduce((d,f)=>{let[p,m]=f;return m===void 0||(d[p]=m),d},{}),c=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((d,f)=>{let{class:p,className:m,...h}=f;return Object.entries(h).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...a,...l}[b]):{...a,...l}[b]===x})?[...d,p,m]:d},[]);return Yd(e,i,c,n?.class,n?.className)},y5=Jn("inline-flex items-center justify-center rounded-md font-medium transition-colors cursor-pointer disabled:opacity-50 disabled:pointer-events-none",{variants:{variant:{primary:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-surface text-foreground hover:bg-surface-hover",ghost:"hover:bg-surface-hover text-foreground-muted",danger:"bg-danger text-white hover:bg-danger/90",outline:"border border-border bg-transparent hover:bg-surface-hover"},size:{sm:"h-7 px-2.5 text-xs gap-1.5",md:"h-8 px-3 text-sm gap-2",lg:"h-9 px-4 text-sm gap-2"}},defaultVariants:{variant:"primary",size:"sm"}}),Ue=He(({className:e,variant:t,size:n,...o},s)=>r("button",{ref:s,className:W(y5({variant:t,size:n}),e),...o}));Ue.displayName="Button";const v5=Jn("inline-flex items-center justify-center rounded-md font-medium transition-colors cursor-pointer disabled:opacity-50 disabled:pointer-events-none",{variants:{variant:{primary:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-surface text-foreground hover:bg-surface-hover",ghost:"hover:bg-surface-hover text-foreground-muted",danger:"bg-danger text-white hover:bg-danger/90",outline:"border border-border bg-transparent hover:bg-surface-hover"},size:{sm:"h-7 w-7",md:"h-8 w-8",lg:"h-9 w-9"}},defaultVariants:{variant:"primary",size:"sm"}}),jl=He(({className:e,variant:t,size:n,icon:o,...s},a)=>r("button",{ref:a,className:W(v5({variant:t,size:n}),e),...s,children:r(o,{className:"h-4 w-4"})}));jl.displayName="IconButton";const w5=Jn("inline-flex items-center rounded-full text-xs font-medium px-2 py-0.5",{variants:{variant:{default:"bg-surface-hover text-foreground",success:"bg-success/15 text-success",warning:"bg-warning/15 text-warning",danger:"bg-danger/15 text-danger",info:"bg-info/15 text-info"},styleVariant:{solid:"",outline:"border bg-transparent"}},defaultVariants:{variant:"default",styleVariant:"solid"}}),ur=He(({className:e,variant:t,style:n,...o},s)=>r("span",{ref:s,className:W(w5({variant:t,styleVariant:n}),e),...o}));ur.displayName="Badge";const N5=Jn("rounded-lg p-3",{variants:{variant:{flat:"bg-surface",bordered:"bg-surface border border-border"}},defaultVariants:{variant:"bordered"}}),rn=He(({className:e,variant:t,...n},o)=>r("div",{ref:o,className:W(N5({variant:t}),e),...n}));rn.displayName="Card";function Bm({expanded:e,onExpandedChange:t,header:n,children:o,dimmed:s=!1,hideChevron:a=!1,className:i}){return u("div",{className:W("rounded-lg border border-border bg-surface overflow-hidden",s&&"opacity-[0.45]",i),children:[u("div",{role:"button",tabIndex:0,className:"flex items-center gap-2.5 px-3 py-2.5 cursor-pointer select-none",onClick:()=>t(!e),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),t(!e))},children:[!a&&r("span",{className:"text-foreground-subtle shrink-0",children:e?r(Xn,{className:"h-4 w-4"}):r(Mn,{className:"h-4 w-4"})}),n]}),e&&o&&r("div",{className:"border-t border-border px-3 py-3",children:o})]})}const Hl=He(({className:e,...t},n)=>r("label",{ref:n,className:W("text-[10px] uppercase tracking-wider text-foreground-muted font-medium",e),...t}));Hl.displayName="Label";const k5=Jn("",{variants:{orientation:{horizontal:"h-px w-full bg-border-subtle",vertical:"w-px h-full bg-border-subtle"}},defaultVariants:{orientation:"horizontal"}}),Vl=He(({className:e,orientation:t,...n},o)=>r("div",{ref:o,role:"separator",className:W(k5({orientation:t}),e),...n}));Vl.displayName="Separator";const Fm=He(({className:e,...t},n)=>r("div",{ref:n,className:W("animate-pulse bg-surface-hover rounded-md h-4 w-full",e),...t}));Fm.displayName="Skeleton";const Zd=Jn("h-7 w-full px-2.5 text-xs bg-surface border rounded-md text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary transition-colors",{variants:{state:{default:"border-border",error:"border-danger"}},defaultVariants:{state:"default"}}),As=He(({className:e,state:t,leftSlot:n,rightSlot:o,...s},a)=>n||o?u("div",{className:"relative flex items-center w-full",children:[n&&r("div",{className:"absolute left-2.5 flex items-center pointer-events-none",children:n}),r("input",{ref:a,className:W(Zd({state:t}),n?"pl-7":"",o?"pr-7":"",e),...s}),o&&r("div",{className:"absolute right-2.5 flex items-center pointer-events-none",children:o})]}):r("input",{ref:a,className:W(Zd({state:t}),e),...s}));As.displayName="Input";const Ps=He(({className:e,options:t,...n},o)=>u("div",{className:"relative w-full",children:[r("select",{ref:o,className:W("h-7 w-full px-2.5 text-xs bg-surface border border-border rounded-md text-foreground appearance-none pr-7 focus:outline-none focus:ring-1 focus:ring-primary",e),...n,children:t.map(s=>r("option",{value:s.value,children:s.label},s.value))}),r("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none text-foreground-muted",children:r(Xn,{className:"h-3.5 w-3.5"})})]}));Ps.displayName="Select";const jm=He(({className:e,...t},n)=>r("input",{ref:n,type:"checkbox",className:W("w-3.5 h-3.5 rounded-sm border border-border accent-primary",e),...t}));jm.displayName="Checkbox";const ql=He(({className:e,checked:t,onCheckedChange:n,label:o,...s},a)=>u("button",{ref:a,role:"switch","aria-checked":t,type:"button",onClick:()=>n(!t),className:W("inline-flex items-center gap-2",e),...s,children:[r("span",{className:W("w-8 h-4 rounded-full transition-colors",t?"bg-primary":"bg-surface-hover"),children:r("span",{className:W("block w-3.5 h-3.5 rounded-full bg-white transition-transform",t?"translate-x-4":"translate-x-0.5")})}),o&&r("span",{className:"text-xs text-foreground",children:o})]}));ql.displayName="Switch";const Hm=Oe(null);function Vm(){const e=ve(Hm);if(!e)throw new Error("Dialog compound components must be used within <Dialog>");return e}function qm({children:e,open:t,onOpenChange:n}){const[o,s]=$(!1),a=t??o,i=gr(),l=q(c=>{n?.(c),t===void 0&&s(c)},[t,n]);return r(Hm.Provider,{value:{open:a,setOpen:l,contentId:i},children:e})}function S5({children:e,...t}){const{setOpen:n}=Vm();return r("button",{type:"button",onClick:()=>n(!0),...t,children:e})}const C5=Jn("bg-background-elevated border border-border rounded-lg p-4 backdrop:bg-black/50 backdrop:backdrop-blur-sm max-w-[calc(100vw-2rem)] max-h-[calc(100dvh-2rem)] overflow-y-auto",{variants:{width:{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"}},defaultVariants:{width:"md"}}),Ul=He(({className:e,width:t,children:n,...o},s)=>{const{open:a,setOpen:i,contentId:l}=Vm(),c=ne(null),d=s??c;Z(()=>{const p=d.current;p&&(a&&!p.open&&p.showModal(),!a&&p.open&&p.close())},[a,d]);const f=p=>{p.target===p.currentTarget&&i(!1)};return r("dialog",{ref:d,id:l,className:W(C5({width:t}),"w-full",e),onClick:f,onClose:()=>i(!1),...o,children:n})});Ul.displayName="DialogContent";function Um({className:e,...t}){return r("div",{className:W("flex flex-col gap-1 mb-3",e),...t})}function Qm({className:e,...t}){return r("div",{className:W("flex justify-end gap-2 mt-4",e),...t})}function Km({className:e,...t}){return r("h2",{className:W("text-sm font-semibold text-foreground",e),...t})}function Gm({className:e,...t}){return r("p",{className:W("text-xs text-foreground-muted",e),...t})}const Wm=Oe(null);function Ql(){const e=ve(Wm);if(!e)throw new Error("Dropdown compound components must be used within <Dropdown>");return e}function Ym({children:e}){const[t,n]=$(!1),o=gr(),s=gr(),a=ne(null);return r(Wm.Provider,{value:{open:t,setOpen:n,triggerId:o,contentId:s,triggerRef:a},children:r("div",{className:"relative inline-block",children:e})})}function Zm({children:e,...t}){const{open:n,setOpen:o,triggerId:s,contentId:a,triggerRef:i}=Ql();return r("button",{type:"button",ref:i,id:s,"aria-haspopup":"menu","aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>o(!n),...t,children:e})}function Xm({className:e,children:t,align:n="start",offset:o=4,...s}){const{open:a,setOpen:i,contentId:l,triggerId:c,triggerRef:d}=Ql(),f=ne(null),[p,m]=$(null);if(Zs(()=>{if(!a){m(null);return}const g=()=>{const b=d.current;if(!b)return;const x=b.getBoundingClientRect(),y=n==="end"?x.right:x.left;m({top:x.bottom+o,left:y,minWidth:x.width})};return g(),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0)}},[a,n,o,d]),Z(()=>{if(!a)return;const g=x=>{const y=f.current,w=d.current;y&&!y.contains(x.target)&&!w?.contains(x.target)&&i(!1)},b=x=>{x.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",b)}},[a,i,d]),!a||!p||typeof document>"u")return null;const h={position:"fixed",top:p.top,...n==="end"?{right:window.innerWidth-p.left}:{left:p.left},minWidth:p.minWidth};return No(r("div",{ref:f,id:l,role:"menu","aria-labelledby":c,style:h,className:W("z-50 bg-background-elevated border border-border rounded-md shadow-lg py-1 min-w-[160px]",e),...s,children:t}),document.body)}function Jm({className:e,icon:t,variant:n="default",children:o,onClick:s,...a}){const{setOpen:i}=Ql(),l=q(c=>{s?.(c),i(!1)},[s,i]);return u("button",{type:"button",role:"menuitem",className:W("h-7 text-xs px-2 w-full text-left flex items-center gap-2",n==="danger"?"text-danger hover:bg-danger/10":"text-foreground hover:bg-surface-hover",e),onClick:l,...a,children:[t&&r(t,{size:14}),o]})}const eh=Oe(null);function th(){const e=ve(eh);if(!e)throw new Error("Tooltip compound components must be used within <Tooltip>");return e}function M5({children:e}){const[t,n]=$(!1),o=ne(null),s=gr(),a=()=>{o.current=setTimeout(()=>n(!0),300)},i=()=>{o.current&&clearTimeout(o.current),n(!1)};return r(eh.Provider,{value:{open:t,show:a,hide:i,tooltipId:s},children:r("div",{className:"relative inline-block",children:e})})}function I5({children:e,...t}){const{show:n,hide:o,tooltipId:s,open:a}=th();return r("div",{onMouseEnter:n,onMouseLeave:o,onFocus:n,onBlur:o,"aria-describedby":a?s:void 0,...t,children:e})}function A5({className:e,children:t,...n}){const{open:o,tooltipId:s}=th();return r("div",{id:s,role:"tooltip",className:W("absolute bottom-full left-1/2 -translate-x-1/2 mb-2 bg-foreground text-background text-xs px-2 py-1 rounded-md shadow-md whitespace-nowrap pointer-events-none transition-opacity duration-150",o?"opacity-100":"opacity-0",e),...n,children:t})}const Xd="(max-width: 767px)",Jd="(min-width: 768px) and (max-width: 1023px)";function nh(e){return t=>{const n=window.matchMedia(e);return n.addEventListener("change",t),()=>n.removeEventListener("change",t)}}function rh(e){return()=>window.matchMedia(e).matches}function oh(){return!1}function er(){return Xs(nh(Xd),rh(Xd),oh)}function sh(){return Xs(nh(Jd),rh(Jd),oh)}function Kl({open:e,onClose:t,title:n,children:o,className:s}){return Z(()=>{if(!e)return;const a=i=>{i.key==="Escape"&&t()};return document.addEventListener("keydown",a),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",a),document.body.style.overflow=""}},[e,t]),u(ge,{children:[r("div",{className:W("fixed inset-0 z-40 bg-black/50 transition-opacity duration-200",e?"opacity-100":"pointer-events-none opacity-0"),onClick:t,"aria-hidden":"true"}),u("div",{role:"dialog","aria-modal":"true",className:W("fixed inset-x-0 bottom-0 z-50 flex flex-col bg-background-elevated border-t border-border rounded-t-xl shadow-2xl transition-transform duration-200 ease-out","max-h-[80dvh]",e?"translate-y-0":"translate-y-full",s),children:[r("div",{className:"flex justify-center pt-2 pb-1",children:r("div",{className:"h-1 w-8 rounded-full bg-foreground-subtle/30"})}),n&&u("div",{className:"flex items-center justify-between px-4 pb-2",children:[r("span",{className:"text-sm font-medium text-foreground",children:n}),r("button",{onClick:t,className:"p-1 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors",children:r(Ye,{className:"h-4 w-4"})})]}),r("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:o})]})]})}const ah=Oe(null);function ih(){const e=ve(ah);if(!e)throw new Error("Popover compound components must be used within <Popover>");return e}function lh({children:e,open:t,onOpenChange:n}){const[o,s]=$(!1),a=t??o,i=gr(),l=gr(),c=q(d=>{n?.(d),t===void 0&&s(d)},[t,n]);return r(ah.Provider,{value:{open:a,setOpen:c,triggerId:i,contentId:l},children:r("div",{className:"relative inline-block",children:e})})}function ch({children:e,...t}){const{open:n,setOpen:o,triggerId:s,contentId:a}=ih();return r("button",{type:"button",id:s,"aria-haspopup":"dialog","aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>o(!n),...t,children:e})}function dh({className:e,children:t,...n}){const{open:o,setOpen:s,contentId:a,triggerId:i}=ih(),l=er(),c=ne(null);return Z(()=>{if(!o||l)return;const d=p=>{const m=c.current,h=document.getElementById(i);m&&!m.contains(p.target)&&!h?.contains(p.target)&&s(!1)},f=p=>{p.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",d),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",f)}},[o,s,i,l]),o?l?r(Kl,{open:o,onClose:()=>s(!1),children:t}):r("div",{ref:c,id:a,role:"dialog","aria-labelledby":i,className:W("absolute left-0 top-full z-50 mt-1 bg-background-elevated border border-border rounded-lg shadow-lg p-3",e),...n,children:t}):null}const uh=Oe(null);function ph(){const e=ve(uh);if(!e)throw new Error("Tabs compound components must be used within <Tabs>");return e}function P5({value:e,onValueChange:t,defaultValue:n="",className:o,...s}){const[a,i]=$(n),l=e??a,c=q(d=>{t?.(d),e===void 0&&i(d)},[e,t]);return r(uh.Provider,{value:{value:l,setValue:c},children:r("div",{className:o,...s})})}function E5({className:e,...t}){return r("div",{role:"tablist",className:W("flex flex-row border-b border-border-subtle",e),...t})}function $5({value:e,className:t,...n}){const{value:o,setValue:s}=ph(),a=e===o,i=`tabpanel-${e}`;return r("button",{type:"button",role:"tab","aria-selected":a,"aria-controls":i,tabIndex:a?0:-1,className:W("h-7 text-xs px-3 transition-colors",a?"border-b-2 border-primary text-foreground font-medium":"text-foreground-muted hover:text-foreground",t),onClick:()=>s(e),...n})}function _5({value:e,className:t,...n}){const{value:o}=ph();return e!==o?null:r("div",{role:"tabpanel",id:`tabpanel-${e}`,className:W("pt-3",t),...n})}const Gl=He(({className:e,...t},n)=>r("div",{ref:n,className:W("overflow-auto [&::-webkit-scrollbar]:w-1 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-surface-hover [&::-webkit-scrollbar-thumb]:rounded-full",e),...t}));Gl.displayName="ScrollArea";function D5({title:e,onClose:t,children:n,defaultWidth:o=360,defaultHeight:s=280,minWidth:a=280,minHeight:i=160,offsetIndex:l=0,className:c}){const[d,f]=$({x:80+l*30,y:80+l*30}),[p,m]=$({w:o,h:s}),[h,g]=$(!1),b=ne(!1),x=ne(!1),y=ne({x:0,y:0}),w=er(),v=q(k=>{k.preventDefault(),b.current=!0,y.current={x:k.clientX-d.x,y:k.clientY-d.y}},[d]),N=q(k=>{k.preventDefault(),k.stopPropagation(),x.current=!0,y.current={x:k.clientX,y:k.clientY}},[]);return Z(()=>{const k=M=>{if(b.current&&f({x:M.clientX-y.current.x,y:M.clientY-y.current.y}),x.current){const P=M.clientX-y.current.x,A=M.clientY-y.current.y;y.current={x:M.clientX,y:M.clientY},m(z=>({w:Math.max(a,z.w+P),h:Math.max(i,z.h+A)}))}},S=()=>{b.current=!1,x.current=!1};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",S)}},[a,i]),w?u("div",{className:W("fixed inset-x-0 bottom-0 z-50 rounded-t-xl border-t border-border bg-background-elevated shadow-2xl flex flex-col overflow-hidden",c),style:{maxHeight:"60dvh"},children:[u("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border shrink-0 bg-surface",children:[r("span",{className:"text-[11px] font-medium truncate",children:e}),u("div",{className:"flex items-center gap-1 shrink-0",children:[r("button",{onClick:()=>g(!h),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",children:h?r(qd,{size:12}):r(Ud,{size:12})}),r("button",{onClick:t,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",children:r(Ye,{size:12})})]})]}),!h&&r("div",{className:"flex-1 min-h-0 overflow-y-auto",children:n})]}):u("div",{className:W("fixed z-50 rounded-lg border border-border bg-background-elevated shadow-2xl flex flex-col overflow-hidden",c),style:{left:d.x,top:d.y,width:h?280:p.w,height:h?"auto":p.h},children:[u("div",{onMouseDown:v,className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border cursor-move select-none shrink-0 bg-surface",children:[u("div",{className:"flex items-center gap-2 min-w-0",children:[r(q2,{size:12,className:"text-foreground-subtle shrink-0"}),r("span",{className:"text-[11px] font-medium truncate",children:e})]}),u("div",{className:"flex items-center gap-1 shrink-0",children:[r("button",{onClick:()=>g(!h),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",title:h?"Restore":"Minimize",children:h?r(qd,{size:12}):r(Ud,{size:12})}),r("button",{onClick:t,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",title:"Close",children:r(Ye,{size:12})})]})]}),!h&&u("div",{className:"flex-1 min-h-0 overflow-y-auto relative",children:[n,r("div",{onMouseDown:N,className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",style:{background:"linear-gradient(135deg, transparent 50%, var(--color-foreground-subtle) 50%)",opacity:.4}})]})]})}function Wl({open:e,onClose:t,children:n,className:o,width:s="w-64"}){const a=ne(null);return Z(()=>{if(!e)return;const i=l=>{l.key==="Escape"&&t()};return document.addEventListener("keydown",i),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",i),document.body.style.overflow=""}},[e,t]),u(ge,{children:[r("div",{className:W("fixed inset-0 z-40 bg-black/50 backdrop-blur-sm transition-opacity duration-200",e?"opacity-100":"pointer-events-none opacity-0"),onClick:t,"aria-hidden":"true"}),r("div",{ref:a,role:"dialog","aria-modal":"true",className:W("fixed inset-y-0 left-0 z-50 flex flex-col bg-surface border-r border-border shadow-2xl transition-transform duration-200 ease-out",s,e?"translate-x-0":"-translate-x-full",o),children:n})]})}function Yl({items:e,className:t}){return r("nav",{className:`flex items-center gap-1 text-[11px] text-foreground-subtle ${t??""}`,children:e.map((n,o)=>{const s=o===e.length-1,a=!s&&(n.onClick||n.href);return u(El.Fragment,{children:[o>0&&r(Mn,{className:"h-3 w-3 flex-shrink-0"}),a?n.onClick?r("button",{type:"button",onClick:n.onClick,className:"hover:text-foreground transition-colors",children:n.label}):r("a",{href:n.href,className:"hover:text-foreground transition-colors",children:n.label}):r("span",{className:s?"text-foreground font-medium":"",children:n.label})]},o)})})}const eu={left:"text-left",right:"text-right",center:"text-center"};function fh({columns:e,rows:t,rowKey:n,onRowClick:o,minWidthPx:s=480,emptyMessage:a,className:i,bordered:l=!0,rowClassName:c}){if(t.length===0&&a)return r("div",{className:`rounded-lg ${l?"border border-border":""} bg-surface px-3 py-4 text-xs text-foreground-subtle text-center ${i??""}`,children:a});if(t.length===0)return null;const d=`rounded-lg ${l?"border border-border":""} bg-surface overflow-x-auto ${i??""}`;return r("div",{className:d,children:u("table",{className:"w-full text-xs",style:{minWidth:`${s}px`},children:[r("thead",{className:"bg-surface",children:r("tr",{children:e.map(f=>{const p=f.align??"left",m=f.nowrap??!0;return r("th",{className:["px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border",eu[p],m?"whitespace-nowrap":"",f.width??""].filter(Boolean).join(" "),children:f.headerRender?f.headerRender():f.header},f.key)})})}),r("tbody",{children:t.map((f,p)=>{const m=n?n(f,p):p,h=c?.(f,p)??"",g=o!==void 0;return r("tr",{onClick:g?()=>o(f,p):void 0,className:[g?"cursor-pointer hover:bg-primary/5":"hover:bg-primary/5",h].filter(Boolean).join(" "),children:e.map(b=>{const x=b.align??"left",y=b.nowrap??!1;return r("td",{className:["px-3 py-2 text-foreground border-b border-border",eu[x],y?"whitespace-nowrap":""].filter(Boolean).join(" "),children:b.render(f,p)},b.key)})},m)})})]})})}function Zl({open:e,onClose:t,title:n,subtitle:o,footer:s,children:a,widthClass:i="w-[360px]"}){return Z(()=>{if(!e)return;const l=c=>{c.key==="Escape"&&t()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e,t]),e?u("aside",{className:W("absolute top-0 right-0 bottom-0 z-20 flex flex-col","bg-surface border-l border-border shadow-xl",i),role:"dialog","aria-modal":"false",children:[u("header",{className:"flex items-start justify-between gap-2 px-4 py-3 border-b border-border",children:[u("div",{className:"min-w-0",children:[r("div",{className:"text-sm font-semibold text-foreground truncate",children:n}),o!==void 0&&r("div",{className:"text-[11px] text-foreground-subtle mt-0.5 truncate",children:o})]}),r("button",{type:"button",onClick:t,className:"p-1 rounded hover:bg-muted text-foreground-subtle hover:text-foreground","aria-label":"Close panel",children:r(Ye,{className:"w-4 h-4"})})]}),r("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-3",children:a}),s!==void 0&&r("footer",{className:"flex items-center gap-2 justify-end px-4 py-3 border-t border-border",children:s})]}):null}const L5={inherit:"bg-muted",on:"bg-emerald-500",off:"bg-orange-500",na:"bg-gray-300 opacity-50"};function mh({node:e,depth:t,selectedAddonId:n,onSelect:o,agentDots:s}){const a=e.addonId===n,i=s?.[e.addonId]??[];return u("div",{children:[u("button",{type:"button",onClick:()=>o(e.addonId),className:W("w-full flex items-center justify-between gap-2 text-left px-3 py-1.5 text-xs","border-l-2",a?"bg-accent border-primary text-foreground font-medium":"border-transparent hover:bg-muted/40 text-foreground"),style:{paddingLeft:`${12+t*14}px`},children:[r("span",{className:"truncate",children:e.addonName}),i.length>0&&r("span",{className:"flex items-center gap-1 shrink-0",children:i.map(l=>r("span",{title:`${l.agentNodeId}: ${l.state}`,className:W("w-2 h-2 rounded-full",L5[l.state])},l.agentNodeId))})]}),e.children.map(l=>r(mh,{node:l,depth:t+1,selectedAddonId:n,onSelect:o,agentDots:s},l.addonId))]})}function hh({tree:e,selectedAddonId:t,onSelect:n,agentDots:o,className:s}){return r("div",{className:W("flex flex-col py-2",s),children:e.map(a=>r(mh,{node:a,depth:0,selectedAddonId:t,onSelect:n,agentDots:o},a.addonId))})}function ta(e){const t=[],n=[],o=new Map;for(const a of e.slots)for(const i of a.addons){const l={addonId:i.id,addonName:i.name,slot:i.slot,inputClasses:i.inputClasses,outputClasses:i.outputClasses,children:[]};i.slot==="audio-classifier"?t.push(l):(n.push(l),o.set(i.id,l))}const s=[];for(const a of n){if(a.inputClasses.length===0){s.push(a);continue}const i=n.find(l=>l.addonId!==a.addonId&&l.outputClasses.some(c=>a.inputClasses.includes(c)));i&&i.children.push(a)}return[...s,...t]}function T5(e){return e?e.models.map(t=>({id:t.id,name:t.name})):[]}function gs({step:e,schema:t,allSchemas:n,depth:o=0,onChange:s,onDelete:a,readOnly:i=!1,toggleMode:l="simple",overrideState:c=null,onOverrideChange:d,inheritedEnabled:f,hideModelAndSettings:p=!1}){const[m,h]=$(!1),g=T5(t);if(g.length>0&&!g.some(x=>x.id===e.modelId)&&!i){const y=(t?.defaultModelId?g.find(w=>w.id===t.defaultModelId):null)??g[0];y&&y.id!==e.modelId&&queueMicrotask(()=>s({...e,modelId:y.id}))}const b=u(ge,{children:[u("div",{className:"flex-1 min-w-0",children:[r("span",{className:"text-[10px] uppercase tracking-wider font-medium text-foreground-subtle/60 block leading-none",children:e.slot}),r("span",{className:"text-sm font-semibold text-foreground truncate block leading-tight",children:e.addonName}),u("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(x=>r("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-blue-500/12 text-blue-400",children:x},x)),e.inputClasses.length>0&&e.outputClasses.length>0&&r("span",{className:"text-foreground-subtle/40 text-[10px]",children:"→"}),e.outputClasses.map(x=>r("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-green-500/12 text-green-400",children:x},x))]})]}),!i&&l==="simple"&&r("button",{onClick:x=>{x.stopPropagation(),s({...e,enabled:!e.enabled})},className:W("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors",e.enabled?"bg-success":"bg-foreground-subtle/30"),children:r("span",{className:W("inline-block h-4 w-4 rounded-full bg-white shadow transition-transform",e.enabled?"translate-x-6":"translate-x-1")})}),!i&&l==="threeState"&&d&&u("div",{className:"flex items-center gap-0.5 rounded-md border border-border p-0.5",onClick:x=>x.stopPropagation(),children:[r(Ha,{label:"Inherit",active:c===null,variant:"inherit",subtext:f===void 0?void 0:f?"on":"off",onClick:()=>d(null)}),r(Ha,{label:"On",active:c===!0,variant:"on",onClick:()=>d(!0)}),r(Ha,{label:"Off",active:c===!1,variant:"off",onClick:()=>d(!1)})]})]});return r(Bm,{expanded:m,onExpandedChange:h,dimmed:!e.enabled,header:b,children:p?r("p",{className:"text-[11px] text-foreground-subtle",children:"Model and detection settings are managed per agent — open the Pipeline page for this camera's agent to edit them."}):u("div",{className:"space-y-3",children:[r(Hi,{label:"Model",value:e.modelId,disabled:i,options:g.map(x=>({value:x.id,label:x.name})),onChange:x=>s({...e,modelId:x})}),e.slot==="audio-classifier"&&e.engine&&r(Hi,{label:"Runtime",value:`${e.engine.runtime}/${e.engine.backend}`,disabled:i,options:[{value:"node/cpu",label:"Node.js — ONNX CPU"},{value:"node/coreml",label:"Node.js — Apple SoundAnalysis (macOS)"},{value:"python/cpu",label:"Python — ONNX CPU"}],onChange:x=>{const[y,w]=x.split("/");s({...e,engine:{runtime:y,backend:w,format:w==="coreml"?"coreml":"onnx"}})}}),t?.configSchema?.map(x=>r(na,{field:x,allFields:t.configSchema??[],step:e,disabled:i,onChange:s},x.key))]})})}function Hi({label:e,value:t,options:n,disabled:o,onChange:s}){return u("div",{children:[r("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e}),u("select",{value:t,onChange:a=>s(a.target.value),disabled:o,className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground focus:outline-none focus:border-primary/50",children:[n.length===0&&r("option",{value:t,children:t||"default"}),n.map(a=>r("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]})]})}function R5({label:e,description:t,value:n,options:o,disabled:s,onChange:a}){function i(l){if(s)return;const c=n.includes(l)?n.filter(d=>d!==l):[...n,l];a(c)}return u("div",{children:[r("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1",children:e}),t&&r("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:t}),r("div",{className:"flex flex-wrap gap-1.5",children:o.map(l=>{const c=n.includes(l.value);return r("button",{type:"button",disabled:s,onClick:()=>i(l.value),className:W("text-[10px] font-medium px-2 py-1 rounded-md border transition-colors",c?"bg-primary/20 text-primary border-primary/40":"bg-surface text-foreground-subtle border-border hover:border-primary/30",s&&"opacity-50 cursor-not-allowed"),children:l.label},l.value)})})]})}function O5(e,t,n){const o=t.settings?.[e];if(o!==void 0)return o;const s=n.find(a=>"key"in a&&a.key===e);return s&&"default"in s?s.default:void 0}function na({field:e,allFields:t,step:n,disabled:o,onChange:s}){const a=e.type!=="separator"&&e.type!=="info"?e.showWhen:void 0;if(a){const{field:l,equals:c,notEquals:d,in:f,notIn:p}=a,m=O5(l,n,t);if(c!==void 0&&m!==c||d!==void 0&&m===d||f!==void 0&&!f.includes(m)||p!==void 0&&p.includes(m))return null}function i(l){s({...n,settings:{...n.settings,[e.key]:l}})}if(e.type==="select"){const l=n.settings?.[e.key],c=typeof l=="string"?l:e.default??"";return r(Hi,{label:e.label,value:c,disabled:o||e.disabled,options:e.options,onChange:i})}if(e.type==="multiselect"){const l=n.settings?.[e.key],c=Array.isArray(l)?l:Array.isArray(e.default)?e.default:[];return r(R5,{label:e.label,description:e.description,value:c,options:e.options,disabled:o||e.disabled,onChange:i})}if(e.type==="slider"||e.type==="number"){const l=n.settings?.[e.key],c=typeof e.default=="number"?e.default:e.min??0,d=typeof l=="number"?l:c,f=e.min??0,p=e.max??1,m=e.step??.01,h=e.type==="slider"?e.showValue:!0,g="unit"in e?e.unit:void 0,b=e.type==="slider"?e.displayScale:void 0,x=b?d/b:d;return u("div",{children:[u("div",{className:"flex items-center justify-between mb-1",children:[r("span",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide",children:e.label}),h&&u("span",{className:"text-xs font-medium text-foreground tabular-nums",children:[typeof x=="number"?x.toFixed(2).replace(/\.?0+$/,""):x,g?` ${g}`:""]})]}),e.description&&r("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:e.description}),r("input",{type:"range",min:f,max:p,step:m,value:d,disabled:o||e.disabled,onChange:y=>i(Number(y.target.value)),className:"w-full accent-primary h-1.5"})]})}if(e.type==="boolean"){const l=n.settings?.[e.key],c=typeof l=="boolean"?l:e.default===!0;return u("label",{className:"flex items-center gap-2",children:[r("input",{type:"checkbox",checked:c,disabled:o||e.disabled,onChange:d=>i(d.target.checked),className:"h-3.5 w-3.5 accent-primary"}),r("span",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide",children:e.label})]})}if(e.type==="text"||e.type==="password"||e.type==="textarea"){const l=n.settings?.[e.key],c=typeof l=="string"?l:e.default??"",d=e.type==="password"?"password":"text";return u("div",{children:[r("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e.label}),e.type==="textarea"?r("textarea",{value:c,disabled:o||e.disabled,placeholder:e.placeholder,onChange:f=>i(f.target.value),rows:3,className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground focus:outline-none focus:border-primary/50 resize-y"}):r("input",{type:d,value:c,disabled:o||e.disabled,placeholder:e.placeholder,onChange:f=>i(f.target.value),className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground focus:outline-none focus:border-primary/50"})]})}return e.type==="separator"?r("div",{className:"border-t border-border my-2"}):e.type==="info"?r("div",{className:"rounded-md border border-border bg-surface px-2 py-1.5 text-[10px] text-foreground-subtle",children:e.content}):null}function Ha({label:e,active:t,variant:n,subtext:o,onClick:s}){return u("button",{type:"button",onClick:s,className:W("px-2 py-1 text-[10px] font-medium rounded transition-colors",t?n==="on"?"bg-green-500/20 text-green-400":n==="off"?"bg-red-500/20 text-red-400":"bg-primary/20 text-primary":"text-foreground-subtle hover:bg-surface-hover"),children:[e,o&&t&&u("span",{className:"ml-1 opacity-60",children:["(",o,")"]})]})}function gh(e,t){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:t.enabled,modelId:t.modelId,children:[],settings:{...t.settings}}}function z5(e,t,n){return n?{enabled:n.enabled??t.enabled,modelId:n.modelId??t.modelId,settings:n.settings??t.settings}:t}function B5({addon:e,agentDefault:t,modelsForFormat:n,onChangeAgentConfig:o}){const s=a=>{o?.({...t,...a})};return u("div",{className:"space-y-4 text-xs",children:[u("label",{className:"flex items-center gap-2",children:[r("input",{type:"checkbox",checked:t.enabled,onChange:a=>s({enabled:a.target.checked})}),u("span",{children:["Enabled on this agent (",e.name,")"]})]}),u("div",{children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle mb-1",children:"Model"}),r("select",{className:"w-full bg-surface border border-border rounded px-2 py-1 text-xs",value:t.modelId,onChange:a=>s({modelId:a.target.value}),children:n.map(a=>r("option",{value:a.id,children:a.name},a.id))})]}),(e.configSchema?.length??0)>0&&u("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),e.configSchema?.map(a=>r(na,{field:a,allFields:e.configSchema??[],step:gh(e,t),disabled:!1,onChange:i=>s({settings:{...i.settings}})},a.key))]})]})}function F5({addon:e,agentDefault:t,agentNodeId:n,currentPatch:o,modelsForFormat:s,onChangePatch:a}){const i=z5("device",t,o),l=h=>{const g=h.enabled!==void 0||h.modelId!==void 0||h.settings!==void 0;a?.(g?h:null)},c=h=>{const{enabled:g,...b}=o??{},x=h==="inherit"?b:{...b,enabled:h==="on"};l(x)},d=h=>{const{modelId:g,...b}=o??{},x=h===void 0?b:{...b,modelId:h};l(x)},f=h=>{const{settings:g,...b}=o??{},x=h===void 0?b:{...b,settings:h};l(x)},p=o?.enabled===void 0?"inherit":o.enabled?"on":"off",m=o?.modelId!==void 0;return u("div",{className:"space-y-4 text-xs",children:[u("div",{className:"flex items-center gap-1",children:[["inherit","on","off"].map(h=>r("button",{type:"button",onClick:()=>c(h),className:W("px-3 py-1 border border-border rounded text-xs capitalize",p===h?"bg-primary text-primary-foreground border-primary":"bg-surface text-foreground hover:bg-muted"),children:h},h)),u("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["agent default: ",r("span",{className:"font-semibold",children:t.enabled?"on":"off"})]})]}),u("div",{children:[u("div",{className:"flex items-center justify-between mb-1",children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Model"}),m?r("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>d(void 0),children:"Clear"}):r("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>d(t.modelId),children:"Override"})]}),r("select",{disabled:!m,className:"w-full bg-surface border border-border rounded px-2 py-1 text-xs disabled:opacity-50",value:m?o?.modelId??t.modelId:t.modelId,onChange:h=>d(h.target.value),children:s.map(h=>r("option",{value:h.id,children:h.name},h.id))}),!m&&u("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["inherits from ",n]})]}),(e.configSchema?.length??0)>0&&(()=>{const h=o?.settings!==void 0;return u("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[u("div",{className:"flex items-center justify-between",children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),h?r("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>f(void 0),children:"Clear"}):r("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>f({...t.settings}),children:"Override"})]}),e.configSchema?.map(g=>r(na,{field:g,allFields:e.configSchema??[],step:gh(e,i),disabled:!h,onChange:b=>f({...b.settings})},g.key)),!h&&u("div",{className:"text-[10px] text-foreground-subtle",children:["inherits from ",n]})]})})(),u("div",{className:"rounded bg-muted/40 px-3 py-2 text-[11px] text-foreground-subtle",children:[r("div",{className:"font-semibold text-foreground mb-0.5",children:"Effective config preview"}),u("div",{className:"font-mono truncate",children:[e.id," · model: ",i.modelId," · ",i.enabled?"on":"off"]})]})]})}function ra(e){const{mode:t,addon:n,agentDefault:o,agentNodeId:s,currentPatch:a,onChangeAgentConfig:i,onChangePatch:l,engineFormat:c}=e,d=U(()=>n.models.filter(f=>!!f.formats[c]),[n.models,c]);return t==="agent"?r(B5,{addon:n,agentDefault:o,modelsForFormat:d,onChangeAgentConfig:i}):r(F5,{addon:n,agentDefault:o,agentNodeId:s,currentPatch:a,modelsForFormat:d,onChangePatch:l})}function j5(e){const t=[],n=(o,s)=>{for(const a of o)t.push({node:a,depth:s}),n(a.children,s+1)};return n(e,0),t}const tu={detector:{label:"detector",className:"text-emerald-500"},cropper:{label:"cropper",className:"text-blue-500"},classifier:{label:"classifier",className:"text-violet-500"},refiner:{label:"refiner",className:"text-amber-500"},"audio-classifier":{label:"audio classifier",className:"text-pink-500"}};function H5({slot:e}){const t=tu[e]??tu.classifier;return r("span",{className:W("text-[9px] font-semibold uppercase tracking-widest leading-none",t.className),children:t.label})}const nu="inline-flex items-center rounded bg-muted px-1.5 py-px text-[9px] font-medium text-foreground-subtle";function V5({inputs:e,outputs:t}){return e.length===0&&t.length===0?null:u("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[e.map(n=>r("span",{className:W(nu,"bg-blue-500/10 text-blue-500"),children:n},`in-${n}`)),e.length>0&&t.length>0&&r("span",{className:"text-foreground-subtle/60 text-[9px]",children:"→"}),t.map(n=>r("span",{className:W(nu,"bg-emerald-500/10 text-emerald-500"),children:n},`out-${n}`))]})}function q5({enabled:e,onChange:t,disabled:n}){return r("button",{type:"button",role:"switch","aria-checked":e,disabled:n,onClick:o=>{o.stopPropagation(),t(!e)},className:W("relative inline-flex h-3.5 w-7 shrink-0 items-center rounded-full transition-colors",e?"bg-emerald-500":"bg-foreground-subtle/30",n?"opacity-50 cursor-not-allowed":"cursor-pointer"),title:e?"Click to disable":"Click to enable",children:r("span",{className:W("inline-block h-3 w-3 rounded-full bg-white shadow transition-transform",e?"translate-x-3.5":"translate-x-0.5")})})}function U5(e){return e.kind==="enabled"?u("span",{className:"inline-flex items-center gap-1",children:[r("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 shrink-0"}),r("span",{className:"font-mono text-foreground",children:e.modelId})]}):e.kind==="disabled"?u("span",{className:"inline-flex items-center gap-1 text-foreground-subtle",children:[r("span",{className:"h-1.5 w-1.5 rounded-full border border-foreground-subtle/60 shrink-0"}),"off"]}):u("span",{className:"inline-flex items-center gap-1 text-foreground-subtle/70",children:[r("span",{className:"h-1.5 w-1.5 rounded-full bg-muted shrink-0"}),"n/a"]})}function Q5({node:e,depth:t,agents:n,getCellState:o,onCellClick:s,selectedCell:a,toggleProps:i}){return u(ge,{children:[u("div",{className:"sticky left-0 z-10 bg-surface px-3 py-2 border-b border-border text-xs flex items-start gap-2",style:{paddingLeft:`${12+t*14}px`},children:[u("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:[r(H5,{slot:e.slot}),u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"font-semibold truncate",children:e.addonName}),r(V5,{inputs:e.inputClasses,outputs:e.outputClasses})]})]}),i&&r("span",{className:"pl-2 pt-0.5 shrink-0",children:r(q5,{enabled:i.enabled,onChange:i.onChange,disabled:i.disabled})})]}),n.map(l=>{const c=o(e.addonId,l.agentNodeId),d=a?.addonId===e.addonId&&a.agentNodeId===l.agentNodeId;return r("button",{type:"button",onClick:()=>s(e.addonId,l.agentNodeId),className:W("text-left px-3 py-1.5 border-b border-l border-border text-xs hover:bg-muted/40",c.kind==="enabled"&&"bg-emerald-500/5",c.kind==="na"&&"bg-muted/30",d&&"ring-2 ring-primary ring-inset"),children:U5(c)},l.agentNodeId)})]})}function Xl({tree:e,agents:t,getCellState:n,onCellClick:o,selectedCell:s,onToggleEnabled:a}){const i=U(()=>j5(e),[e]),l=`minmax(320px, 1fr) repeat(${t.length}, minmax(160px, 220px))`,c=a!==void 0&&t.length===1,d=t[0]?.agentNodeId;return r("div",{className:"overflow-auto border border-border rounded",children:u("div",{className:"grid",style:{gridTemplateColumns:l},children:[r("div",{className:"sticky top-0 left-0 z-20 bg-muted/60 px-3 py-2 text-[10px] uppercase tracking-widest text-foreground-subtle border-b border-border",children:"Step"}),t.map(f=>u("div",{className:"sticky top-0 z-10 bg-muted/60 px-3 py-2 border-b border-l border-border",children:[r("div",{className:"text-xs font-semibold text-foreground",children:f.agentNodeId}),r("div",{className:"text-[10px] text-foreground-subtle truncate",children:f.engineLabel})]},f.agentNodeId)),i.map(({node:f,depth:p})=>{const m=c&&d!==void 0?n(f.addonId,d):null,h=c&&m!==null?{enabled:m.kind==="enabled",onChange:g=>a?.(f.addonId,g),disabled:m.kind==="na"}:void 0;return r(Q5,{node:f,depth:p,agents:t,getCellState:n,onCellClick:o,selectedCell:s,toggleProps:h},f.addonId)})]})})}const bh=typeof globalThis<"u"?globalThis.__camstackTrpcReact:void 0,C=bh??sw();typeof globalThis<"u"&&!bh&&(globalThis.__camstackTrpcReact=C);const Jl=un("camstack:system",null);function ec({system:e,children:t}){return r(Jl.Provider,{value:e,children:t})}function Le(){const e=ve(Jl);if(!e)throw new Error("useSystem(): no <SystemProvider> in tree");return e}function K5(){return ve(Jl)}function ct(e,t){const n=Le(),o=ne(t);o.current=t;const[s,a]=$(n.connectionVersion);Z(()=>n.subscribeConnectionEvents((i,l)=>{i==="connected"&&a(l)}),[n]),Z(()=>n.subscribeEvent(e,l=>{o.current(l)}),[n,e,s])}function Vi(e){const t=ne(e);return t.current=e,t}function Pr(e,t){const[n,o]=$(null),s=Vi(t);return ct(e,a=>{const i=a.data,l=s.current;l&&!l(i)||o(i)}),n}function tc(e,t,n){const[o,s]=$(()=>new Map),a=Vi(t),i=Vi(n);ct(e,c=>{const d=c.data,f=i.current;if(f&&!f(d))return;const p=a.current(d);s(m=>{const h=new Map(m);return h.set(p,d),h})});const l=U(()=>Array.from(o.values()),[o]);return{map:o,values:l}}function Er(){const{data:e,isLoading:t}=C.nodes.topology.useQuery(void 0,{staleTime:6e4}),o=Pr("cluster.topology-snapshot")?.nodes??e;return{nodes:U(()=>{const a=[];for(const i of o??[])a.push({id:String(i.id??""),name:String(i.name??i.id??""),shortName:i.isHub?"HUB":String(i.name??i.id??""),isHub:!!i.isHub,isOnline:!!i.isOnline,localIps:i.localIps??[],addons:(i.addons??[]).map(l=>({addonId:l.id,capabilities:l.capabilities}))});return a.sort((i,l)=>i.isHub!==l.isHub?i.isHub?-1:1:i.name.localeCompare(l.name)),a},[o]),isLoading:t}}function xh({selectedNodeId:e,onSelect:t,label:n="Node",hideIcon:o=!1,alwaysShow:s=!1}){const{nodes:a}=Er();return!s&&a.length<=1?null:u("div",{className:"flex items-center gap-1.5",children:[!o&&r(Rk,{className:"h-3.5 w-3.5 text-foreground-subtle"}),n&&r("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:n}),r("div",{className:"flex rounded-md border border-border overflow-hidden text-[11px] font-medium",children:a.map((i,l)=>{const c=e===i.id;return r("button",{type:"button",onClick:()=>t(i.id),disabled:!i.isOnline,title:i.isOnline?i.name:`${i.name} (offline)`,className:W("px-2.5 py-1 transition-colors",c?"bg-primary/15 text-primary":"bg-transparent text-foreground-subtle hover:bg-surface-hover hover:text-foreground",l>0&&"border-l border-border",!i.isOnline&&"opacity-50 cursor-not-allowed"),children:i.shortName},i.id)})})]})}const G5={online:{colorClass:"bg-success",label:"Online"},offline:{colorClass:"bg-danger",label:"Offline"},degraded:{colorClass:"bg-warning",label:"Degraded"},unknown:{colorClass:"bg-foreground-subtle",label:"Unknown"}};function W5({status:e,showDot:t=!0,showLabel:n=!0,size:o="sm",className:s}){const a=G5[e];return u("span",{className:W("inline-flex items-center gap-1.5",o==="sm"?"text-xs":"text-sm",s),children:[t&&r("span",{className:W("h-1.5 w-1.5 shrink-0 rounded-full",a.colorClass),"aria-hidden":"true"}),n&&r("span",{className:"text-foreground",children:a.label})]})}const Y5={frigate:{colorClass:"bg-provider-frigate",label:"Frigate"},scrypted:{colorClass:"bg-provider-scrypted",label:"Scrypted"},reolink:{colorClass:"bg-provider-reolink",label:"Reolink"},homeAssistant:{colorClass:"bg-provider-homeAssistant",label:"Home Assistant"},rtsp:{colorClass:"bg-provider-rtsp",label:"RTSP"}};function Z5({provider:e,showLabel:t=!0,className:n}){const o=Y5[e];return u("span",{className:W("inline-flex items-center gap-1.5 text-xs",n),children:[r("span",{className:W("h-1.5 w-1.5 shrink-0 rounded-sm",o.colorClass),"aria-hidden":"true"}),t&&r("span",{className:"text-foreground",children:o.label})]})}const X5={success:"bg-emerald-400 text-emerald-950",warning:"bg-amber-400 text-amber-950",danger:"bg-red-400 text-red-950",info:"bg-blue-400 text-blue-950",neutral:"bg-foreground-subtle/20 text-foreground"};function yh({children:e,variant:t="neutral",mono:n,className:o}){return r("span",{className:W("inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-bold leading-tight",n&&"font-mono",X5[t],o),children:e})}function J5({version:e,preRelease:t,className:n}){const o=t??/-(alpha|beta|rc|dev|canary|next)/i.test(e);return r(yh,{variant:o?"warning":"success",mono:!0,className:n,children:e})}function eS({label:e,description:t,error:n,required:o,children:s,orientation:a="vertical",className:i}){const l=a==="horizontal";return u("div",{className:W("flex gap-2",l?"flex-row items-center justify-between":"flex-col",i),children:[u("div",{className:W(l?"flex-1":""),children:[u(Hl,{children:[e,o&&r("span",{className:"text-danger ml-0.5",children:"*"})]}),t&&r("p",{className:"text-foreground-subtle text-xs mt-0.5",children:t})]}),r("div",{className:W(l?"shrink-0":""),children:s}),n&&r("p",{className:"text-danger text-xs",children:n})]})}function tS({title:e,subtitle:t,actions:n,className:o}){return u("div",{className:W("flex flex-col gap-2 mb-3 sm:flex-row sm:items-center sm:justify-between",o),children:[u("div",{children:[r("h1",{className:"text-sm font-semibold text-foreground",children:e}),t&&r("p",{className:"text-foreground-subtle text-xs",children:t})]}),n&&r("div",{className:"flex items-center gap-2 flex-wrap",children:n})]})}function vh({icon:e,title:t,description:n,action:o,className:s}){return u("div",{className:W("flex flex-col items-center justify-center gap-3 py-12",s),children:[e&&r(e,{className:"h-12 w-12 text-foreground-subtle","aria-hidden":"true"}),u("div",{className:"flex flex-col items-center gap-1 text-center",children:[r("p",{className:"text-foreground-muted text-sm font-medium",children:t}),n&&r("p",{className:"text-foreground-subtle text-xs max-w-xs",children:n})]}),o&&r("div",{className:"mt-1",children:o})]})}const wh=un("camstack:confirm-dialog",null);function nt(){const e=ve(wh);if(!e)throw new Error("useConfirm must be used within ConfirmDialogProvider");return e.confirm}function Nh({children:e}){const[t,n]=$(null),o=q(c=>new Promise(d=>{n({...c,resolve:d})}),[]),s=()=>{t?.resolve(!0),n(null)},a=()=>{t?.resolve(!1),n(null)},i={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600 text-white"},warning:{icon:"text-orange-400",button:"bg-orange-500 hover:bg-orange-600 text-white"},default:{icon:"text-primary",button:"bg-primary hover:bg-primary/90 text-white"}},l=t?i[t.variant??"default"]:i.default;return u(wh.Provider,{value:{confirm:o},children:[e,t&&u("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[r("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:a}),u("div",{className:"relative z-10 w-full max-w-sm mx-4 rounded-xl border border-border bg-surface shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-150",onClick:c=>c.stopPropagation(),children:[u("div",{className:"px-5 pt-5 pb-4",children:[r("h3",{className:"text-sm font-semibold text-foreground",children:t.title}),r("p",{className:"mt-2 text-xs text-foreground-subtle leading-relaxed",children:t.message})]}),u("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border bg-surface-hover/30",children:[r("button",{type:"button",onClick:a,className:"px-3 py-1.5 text-xs font-medium rounded-md border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:t.cancelLabel??"Cancel"}),r("button",{type:"button",onClick:s,className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${l.button}`,children:t.confirmLabel??"Confirm"})]})]})]})]})}function nS({value:e,label:t,trend:n,className:o}){return u(rn,{className:W("flex flex-col gap-1",o),children:[u("div",{className:"flex items-baseline gap-2",children:[r("span",{className:"text-2xl font-semibold text-foreground",children:e}),n&&u("span",{className:W("inline-flex items-center gap-0.5 text-xs font-medium",n.direction==="up"?"text-success":"text-danger"),children:[n.direction==="up"?r(n5,{className:"h-3 w-3"}):r(o5,{className:"h-3 w-3"}),n.value,"%"]})]}),r("span",{className:"text-xs text-foreground-muted",children:t})]})}function rS({items:e,className:t}){return r("dl",{className:W("flex flex-col",t),children:e.map(n=>u("div",{className:"flex items-center h-7",children:[r("dt",{className:"text-foreground-subtle text-xs w-1/3 shrink-0",children:n.key}),r("dd",{className:"text-foreground text-xs",children:n.value})]},n.key))})}function oS({children:e,maxHeight:t=300,className:n}){const[o,s]=$(!1),a=q(()=>{navigator.clipboard.writeText(e).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})},[e]);return u("div",{className:W("relative group",n),children:[r(Gl,{style:{maxHeight:t},children:r("pre",{className:"font-mono text-xs bg-surface p-3 rounded-md border border-border-subtle",children:r("code",{children:e})})}),r("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:r(jl,{icon:o?ko:In,"aria-label":"Copy code",variant:"ghost",size:"sm",onClick:a})})]})}function sS({filters:e,values:t,onChange:n,className:o}){const s=er(),[a,i]=$(!1),l=(d,f)=>{n({...t,[d]:f})},c=Object.values(t).filter(d=>d!==void 0&&d!=="").length;if(s){const d=e.find(p=>p.type==="search"),f=e.some(p=>p.type!=="search");return u("div",{className:W("flex items-center gap-2",o),children:[d&&r(As,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:p=>l(d.key,p.target.value),leftSlot:r(so,{className:"h-3 w-3 text-foreground-subtle"}),className:"flex-1"}),f&&u(ge,{children:[u("button",{onClick:()=>i(!0),className:"flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-foreground-muted hover:bg-surface-hover transition-colors shrink-0",children:[r(Hk,{className:"h-3.5 w-3.5"}),"Filters",c>0&&r(ur,{variant:"info",className:"ml-1 text-[10px] px-1 py-0",children:c})]}),r(Kl,{open:a,onClose:()=>i(!1),title:"Filters",children:r("div",{className:"flex flex-col gap-3",children:e.filter(p=>p.type!=="search").map(p=>{switch(p.type){case"select":return u("div",{children:[r("label",{className:"text-xs text-foreground-muted mb-1 block",children:p.label}),r(Ps,{options:p.options,value:t[p.key]??"",onChange:m=>l(p.key,m.target.value),className:"w-full"})]},p.key);case"badge-toggle":return r("div",{className:"flex items-center gap-1 flex-wrap",children:p.options.map(m=>{const g=t[p.key]===m.value;return r("button",{type:"button",onClick:()=>l(p.key,g?void 0:m.value),children:r(ur,{variant:g?"info":"default",className:"cursor-pointer",children:m.label})},m.value)})},p.key);default:return null}})})})]})]})}return r("div",{className:W("flex items-center gap-2 flex-wrap",o),children:e.map(d=>{switch(d.type){case"search":return r(As,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:f=>l(d.key,f.target.value),leftSlot:r(so,{className:"h-3 w-3 text-foreground-subtle"}),className:"w-48"},d.key);case"select":return r(Ps,{options:d.options,value:t[d.key]??"",onChange:f=>l(d.key,f.target.value),className:"w-36"},d.key);case"badge-toggle":return r("div",{className:"flex items-center gap-1",children:d.options.map(f=>{const m=t[d.key]===f.value;return r("button",{type:"button",onClick:()=>l(d.key,m?void 0:f.value),children:r(ur,{variant:m?"info":"default",className:"cursor-pointer",children:f.label})},f.value)})},d.key);default:return null}})})}function qi({label:e,icon:t,href:n,badge:o,active:s=!1,className:a}){return u("a",{href:n,className:W("flex items-center gap-2 h-7 px-2 text-[11px] transition-colors",s?"border-l-2 border-primary bg-primary/[0.08] text-foreground rounded-r-md":"text-foreground-subtle hover:bg-surface-hover rounded-md",a),children:[r(t,{className:"h-3.5 w-3.5 shrink-0"}),r("span",{className:"truncate flex-1",children:e}),o!==void 0&&r(ur,{className:"ml-auto text-[10px] px-1.5 py-0",children:o})]})}function Ui({logo:e,sections:t,footer:n,onNavigate:o,className:s}){return u("nav",{className:W("bg-surface border-r border-border h-full flex flex-col",s),children:[e&&r("div",{className:"px-3 py-2 shrink-0",children:e}),r("div",{className:"flex-1 overflow-auto px-1 py-1",children:t.map((a,i)=>u("div",{className:W(i>0?"mt-3":""),children:[a.label&&r("span",{className:"text-[10px] text-foreground-disabled uppercase tracking-wider px-2 mb-1 block",children:a.label}),r("div",{className:"flex flex-col gap-0.5",onClick:o,children:a.items.map(l=>r(qi,{...l},l.href))})]},i))}),n&&n.length>0&&u("div",{className:"shrink-0 px-1 pb-1",children:[r(Vl,{className:"mb-1"}),r("div",{className:"flex flex-col gap-0.5",onClick:o,children:n.map(a=>r(qi,{...a},a.href))})]})]})}function aS({sidebar:e,header:t,mobileLogo:n,mobileActions:o,children:s,className:a}){const i=er(),[l,c]=$(!1);return u("div",{className:W("flex h-screen",a),children:[!i&&r(Ui,{...e,className:W("w-44",e.className)}),i&&r(Wl,{open:l,onClose:()=>c(!1),width:"w-64",children:r(Ui,{...e,onNavigate:()=>c(!1),className:"w-full border-r-0"})}),u("div",{className:"flex flex-1 flex-col min-w-0",children:[i&&u("header",{className:"flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm",children:[r("button",{onClick:()=>c(!0),className:"p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors","aria-label":"Open menu",children:r(ak,{className:"h-5 w-5"})}),n&&r("div",{className:"flex-1 flex justify-center",children:n}),o&&r("div",{className:"shrink-0",children:o})]}),!i&&t&&u("header",{className:"flex items-center h-10 border-b border-border px-4 shrink-0",children:[t.breadcrumbs&&t.breadcrumbs.length>0&&r("nav",{className:"flex items-center gap-1 text-xs flex-1 min-w-0",children:t.breadcrumbs.map((d,f)=>{const p=f===t.breadcrumbs.length-1;return u("span",{className:"flex items-center gap-1",children:[f>0&&r(Mn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),d.href&&!p?r("a",{href:d.href,className:"text-foreground-subtle hover:text-foreground transition-colors truncate",children:d.label}):r("span",{className:"text-foreground truncate",children:d.label})]},f)})}),t.actions&&r("div",{className:"flex items-center gap-2 ml-auto shrink-0",children:t.actions})]}),r("main",{className:"flex-1 overflow-auto p-4",children:s})]})]})}const iS={online:"bg-success",offline:"bg-danger",warning:"bg-warning",unknown:"bg-foreground-subtle"};function lS({title:e,subtitle:t,status:n,selected:o,onClick:s,badges:a,actions:i,offlineAction:l,className:c}){const d=n==="offline";return u("div",{onClick:s,className:W("w-full rounded-lg border p-3 text-left transition-colors",s&&"cursor-pointer",o?"border-primary bg-primary/10":"border-border bg-surface hover:bg-surface-hover",d&&!o&&"opacity-50",c),children:[u("div",{className:"flex items-center justify-between mb-2",children:[r("span",{className:"text-sm font-medium truncate",children:e}),n&&r("span",{className:W("h-2 w-2 rounded-full shrink-0",iS[n])})]}),t&&r("div",{className:"text-[11px] text-foreground-muted",children:t}),a&&a.length>0&&r("div",{className:"flex flex-wrap gap-1 mt-2",children:a.map((f,p)=>{const m=W("rounded px-1.5 py-0.5 text-[10px] flex items-center gap-0.5",o?"bg-primary/20":"bg-surface-hover",f.onClick&&"hover:opacity-80 transition-opacity cursor-pointer");return f.onClick?u("button",{onClick:h=>{h.stopPropagation(),f.onClick()},className:m,children:[f.icon,f.label]},p):u("span",{className:m,children:[f.icon,f.label]},p)})}),!d&&i&&i.length>0&&r("div",{className:"flex items-center gap-0.5 mt-2 -mb-1",children:i.map((f,p)=>r("button",{onClick:m=>{m.stopPropagation(),f.onClick()},className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",title:f.label,"aria-label":f.label,children:f.icon},p))}),d&&l&&r("div",{className:"mt-2",onClick:f=>f.stopPropagation(),children:l})]})}function cS({children:e,minCardWidth:t=220,gap:n=3,className:o}){return r("div",{className:W("p-4 overflow-y-auto flex-1 content-start",o),style:{display:"grid",gridTemplateColumns:`repeat(auto-fill, minmax(${t}px, 1fr))`,gap:`${n*4}px`},children:e})}const dS="capability.binding-changed";function St(e,t){const[n,o]=$(null);return Z(()=>{if(t===null){o(null);return}let s=!1;const a=async()=>{try{const l=await e.deviceManager.getBindings.query({deviceId:t});s||o(l)}catch{s||o(l=>l)}};a();const i=e.live?.onEvent.subscribe({category:dS},{onData:l=>{const c=l.data?.source;if(!c){a();return}c.type==="device"&&c.id===t&&a()}});return()=>{s=!0,i?.unsubscribe()}},[e,t]),U(()=>n?aw(e,n):null,[e,n])}function on(e){const t=q(o=>e?e.subscribe(()=>o()):()=>{},[e]),n=q(()=>e?.value,[e]);return Xs(t,n,n)}function kh(e,t,n){const o=St(e,t),s=o?n(o.state):void 0;return on(s)}function $r(e){const t=St(e.trpc,e.deviceId),n=t!==null?e.slice(t):void 0,o=on(n),s=t!==null?e.cap(t):void 0,c=(e.requireFeature===void 0||(e.deviceFeatures??[]).includes(e.requireFeature))&&s!==void 0&&o!==void 0;return{dev:t,cap:s,slice:o,available:c}}function uS(e){return e.parentDeviceId===null?"top-level":e.role?"accessory":"adopted"}const pS={minimal:{showIntegrationIcon:!1,showParentBadge:!1,showSnapshot:!1,showBattery:!1,showStableId:!1,showId:!1,showSwitchToggle:!0,showChildrenAccordion:!1},compact:{showIntegrationIcon:!0,showParentBadge:!0,showSnapshot:!0,showBattery:!0,showStableId:!1,showId:!1,showSwitchToggle:!0,showChildrenAccordion:!0},expanded:{showIntegrationIcon:!1,showParentBadge:!0,showSnapshot:!0,showBattery:!0,showStableId:!0,showId:!0,showSwitchToggle:!0,showChildrenAccordion:!0}};function fS(e){const t=pS[e.variant??"compact"];return{showIntegrationIcon:e.showIntegrationIcon??t.showIntegrationIcon,showParentBadge:e.showParentBadge??t.showParentBadge,showSnapshot:e.showSnapshot??t.showSnapshot,showBattery:e.showBattery??t.showBattery,showStableId:e.showStableId??t.showStableId,showId:e.showId??t.showId,showSwitchToggle:e.showSwitchToggle??t.showSwitchToggle,showChildrenAccordion:e.showChildrenAccordion??t.showChildrenAccordion}}const mS={siren:Js,floodlight:Em,spotlight:Rm,"pir-sensor":Dm,chime:pk,autotrack:km,nightvision:zl,"privacy-mask":Im,doorbell:Sm},hS={camera:Ol,hub:Fi,nvr:Fi,light:Em,siren:Js,switch:Jk,sensor:Dm,thermostat:Zk,button:v2,generic:Fl};function Sh(e){return e.role?mS[e.role]??Fl:hS[e.type.toLowerCase()]??Ol}const Ch={"native-snapshot":K2,"two-way-audio":$m,"pan-tilt-zoom":km,"ptz-autotrack":rk,"doorbell-button":Sm,"motion-trigger":vn,"battery-operated":wm,rebootable:Tm},Mh={"native-snapshot":"Native snapshot","two-way-audio":"Two-way audio","pan-tilt-zoom":"Pan-Tilt-Zoom","ptz-autotrack":"PTZ autotrack","doorbell-button":"Doorbell button","motion-trigger":"Motion trigger","battery-operated":"Battery operated",rebootable:"Rebootable"},gS={"native-snapshot":"snapshot",rebootable:"reboot","pan-tilt-zoom":"ptz","ptz-autotrack":"ptz-autotrack","two-way-audio":"intercom","motion-trigger":"motion-trigger"},Ih=new Set(["camera","hub","nvr"]);function Ah(e){return!Ih.has(e.type.toLowerCase())}function ru(e){return e.role?!0:!Ih.has(e.type.toLowerCase())}function Ph(e){return(e.features??[]).includes("motion-trigger")}function bS(e){if(e.length<=24)return e;const t=e.lastIndexOf(":");if(t>=0&&t<e.length-4)return e.slice(t+1);const n=e.split("-");if(n.length>2){const o=n.slice(-2).join("-");if(o.length>=6)return o}return`…${e.slice(-18)}`}function xS({trpc:e,accessoryChildren:t,adoptedChildren:n,onNavigate:o}){return u("div",{className:"border-t border-border-subtle/50",children:[n.length>0&&r(ou,{trpc:e,label:"Adopted devices",rows:n,onNavigate:o}),t.length>0&&r(ou,{trpc:e,label:"Accessories",rows:t,onNavigate:o})]})}function ou({trpc:e,label:t,rows:n,onNavigate:o}){return u("div",{children:[r("div",{className:"px-3 pt-1.5 pb-1 text-[9px] font-semibold uppercase tracking-wide text-foreground-subtle",children:t}),r("ul",{children:n.map(s=>r(yS,{trpc:e,child:s,onNavigate:o},s.id))})]})}function yS({trpc:e,child:t,onNavigate:n}){const o=!t.disabled,s=o&&Ah(t),a=o&&Ph(t),i=Sh(t);return r("li",{children:u("div",{onClick:l=>{l.stopPropagation(),n(t.id)},className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-surface-hover transition-colors cursor-pointer",children:[r(i,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),r("span",{className:"text-[10.5px] text-foreground flex-1 truncate",children:t.name}),a&&r(wS,{trpc:e,deviceId:t.id,features:t.features}),s&&r(vS,{trpc:e,deviceId:t.id}),r("span",{className:W("h-1.5 w-1.5 rounded-full flex-shrink-0",t.online?"bg-success":"bg-foreground-subtle/40"),title:t.online?"Online":"Offline"})]})})}function vS({trpc:e,deviceId:t}){const{dev:n,cap:o,slice:s,available:a}=$r({trpc:e,deviceId:t,cap:p=>p.switch,slice:p=>p.state.switch}),[i,l]=$(!1);if(n!==null&&!o)return null;const c=s?.on===!0,d={transform:c?"translateX(14px)":"translateX(2px)"},f=async p=>{if(p.stopPropagation(),!(i||!a||!o)){l(!0);try{await o.setState({on:!c})}finally{l(!1)}}};return r("button",{type:"button",onClick:p=>{f(p)},disabled:i||!a,className:W("relative inline-flex h-4 w-7 items-center rounded-full border transition-colors flex-shrink-0",c?"bg-success/30 border-success/50":"bg-surface-hover border-border",i&&"opacity-60",!a&&"opacity-40 cursor-not-allowed"),title:a?c?"Turn off":"Turn on":"Awaiting state…","aria-pressed":c,children:r("span",{className:W("absolute h-3 w-3 rounded-full transition-all",c?"bg-success":"bg-foreground-subtle"),style:d})})}function wS({trpc:e,deviceId:t,features:n}){const{dev:o,cap:s,slice:a,available:i}=$r({trpc:e,deviceId:t,cap:p=>p.motionTrigger,slice:p=>p.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:n}),[l,c]=$(!1);if(o!==null&&!s)return null;const d=a?.enabled===!0,f=async p=>{if(p.stopPropagation(),!(l||!i||!s)){c(!0);try{await s.setMotionTrigger({enabled:!d})}finally{c(!1)}}};return r("button",{type:"button",onClick:p=>{f(p)},disabled:l||!i,className:W("inline-flex h-4 w-4 items-center justify-center rounded transition-colors flex-shrink-0",d?"text-primary bg-primary/10":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover",(l||!i)&&"opacity-50"),title:i?d?"Motion-trigger: on (click to disable)":"Motion-trigger: off (click to enable)":"Awaiting state…","aria-pressed":d,children:r(vn,{className:"h-2.5 w-2.5"})})}function Eh({trpc:e,device:t,flags:n}){if(!!t.disabled)return null;const s=t.type.toLowerCase(),a=n.showSwitchToggle&&Ah(t),i=Ph(t),l=s==="hub"||s==="nvr",c=(t.features??[]).includes("rebootable"),d=l&&c;return u(ge,{children:[i&&r(kS,{trpc:e,deviceId:t.id,features:t.features}),a&&r(NS,{trpc:e,deviceId:t.id}),d&&r(CS,{trpc:e,deviceId:t.id})]})}function NS({trpc:e,deviceId:t}){const{dev:n,cap:o,slice:s,available:a}=$r({trpc:e,deviceId:t,cap:p=>p.switch,slice:p=>p.state.switch}),[i,l]=$(!1);if(n!==null&&!o)return null;const c=s?.on===!0,d={transform:c?"translateX(14px)":"translateX(2px)"},f=async p=>{if(p.stopPropagation(),!(i||!a||!o)){l(!0);try{await o.setState({on:!c})}finally{l(!1)}}};return r("button",{type:"button",onClick:p=>{f(p)},disabled:i||!a,className:W("relative inline-flex h-4 w-7 items-center rounded-full border transition-colors flex-shrink-0",c?"bg-success/30 border-success/50":"bg-surface-hover border-border",i&&"opacity-60",!a&&"opacity-40 cursor-not-allowed"),title:a?c?"Turn off":"Turn on":"Awaiting state…","aria-pressed":c,children:r("span",{className:W("absolute h-3 w-3 rounded-full transition-all",c?"bg-success":"bg-foreground-subtle"),style:d})})}function kS({trpc:e,deviceId:t,features:n}){const{dev:o,cap:s,slice:a,available:i}=$r({trpc:e,deviceId:t,cap:p=>p.motionTrigger,slice:p=>p.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:n}),[l,c]=$(!1);if(o!==null&&!s)return null;const d=a?.enabled===!0,f=async p=>{if(p.stopPropagation(),!(l||!i||!s)){c(!0);try{await s.setMotionTrigger({enabled:!d})}finally{c(!1)}}};return r("button",{type:"button",onClick:p=>{f(p)},disabled:l||!i,className:W("inline-flex h-4 w-4 items-center justify-center rounded transition-colors flex-shrink-0",d?"text-primary bg-primary/10":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover",(l||!i)&&"opacity-50"),title:i?d?"Motion-trigger: on (click to disable)":"Motion-trigger: off (click to enable)":"Awaiting state…","aria-pressed":d,children:r(vn,{className:"h-2.5 w-2.5"})})}const Va=168,SS=4;function CS({trpc:e,deviceId:t}){const{dev:n,cap:o}=$r({trpc:e,deviceId:t,cap:x=>x.reboot,slice:()=>{}}),s=ne(null),a=ne(null),[i,l]=$(null),[c,d]=$(!1),f=n!==null&&o!==void 0&&o!==null,p=i!==null,m=()=>l(null),h=()=>{const x=s.current;if(!x)return;const y=x.getBoundingClientRect(),w=y.right-Va,v=Math.max(8,Math.min(w,window.innerWidth-Va-8)),N=y.bottom+SS;l({top:N,left:v})};if(Z(()=>{if(!p)return;const x=w=>{const v=s.current,N=a.current,k=w.target;k!==null&&(v&&v.contains(k)||N&&N.contains(k)||m())},y=w=>{w.key==="Escape"&&(w.stopPropagation(),m())};return document.addEventListener("mousedown",x),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",y)}},[p]),n!==null&&!o)return null;const g=x=>{x.stopPropagation(),p?m():h()},b=async()=>{if(!(c||!f||!o)){d(!0),m();try{await o.reboot({})}finally{d(!1)}}};return u(ge,{children:[r("button",{ref:s,type:"button",onClick:g,disabled:c||!f,className:W("inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors flex-shrink-0",(c||!f)&&"opacity-50",p&&"bg-surface-hover text-foreground"),title:"More actions","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":p,children:r(Cm,{className:"h-3 w-3"})}),i&&No(r("div",{ref:a,role:"menu",style:{position:"fixed",top:i.top,left:i.left,width:Va},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-1",onClick:x=>x.stopPropagation(),children:u("button",{type:"button",role:"menuitem",onClick:()=>{b()},disabled:c||!f,className:W("flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-[11px] text-foreground","hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed"),children:[r(Tm,{className:"h-3 w-3 shrink-0 text-foreground-subtle"}),r("span",{children:"Reboot device"})]})}),document.body)]})}const MS=Object.freeze([]);function IS(e){return e==="native"?"native":"enhanced"}function AS(e){return e.map(t=>({kind:"marker",feature:t}))}function PS(e,t){const n=new Map,o=t.entries??[];for(const a of o)n.set(a.capName,a);const s=[];for(const a of e){const i=gS[a];if(i===void 0){s.push({kind:"marker",feature:a});continue}const l=n.get(i);l&&s.push({kind:IS(l.kind),feature:a,capName:i})}return s}function ES(e,t,n){const[o,s]=$(null),[a,i]=$(!1),[l,c]=$(!0);return Z(()=>{if(t===null){s(null),i(!1),c(!1);return}let d=!1;c(!0),i(!1);const f=async()=>{try{const m=await e.deviceManager.getBindings.query({deviceId:t});if(d)return;s(m),c(!1)}catch{if(d)return;i(!0),c(!1)}};f();const p=e.live?.onEvent.subscribe({category:"capability.binding-changed"},{onData:m=>{const h=m.data?.source;if(!h){f();return}h.type==="device"&&h.id===t&&f()}});return()=>{d=!0,p?.unsubscribe()}},[e,t]),n.length===0?{loading:l,resolved:MS}:l||a||!o?{loading:l,resolved:AS(n)}:{loading:!1,resolved:PS(n,o)}}const $S=[];function $h({trpc:e,device:t,flags:n,accessoryCount:o,adoptedCount:s,showFeatureRow:a=!1}){const i=o+s,l=n.showChildrenAccordion&&i>0,c=t.features??$S,d=a&&c.length>0,{resolved:f}=ES(e,d?t.id:null,c),p=d&&f.length>0;return!l&&!p?null:u("div",{className:"flex items-center gap-1.5 flex-nowrap whitespace-nowrap min-w-0",children:[l&&r(_S,{accessoryCount:o,adoptedCount:s}),p&&r(DS,{resolved:f})]})}function _S({accessoryCount:e,adoptedCount:t}){const n=e+t;if(n===0)return null;const o=t>0&&e>0?`${String(t)} adopted · ${String(e)} accessor${e===1?"y":"ies"}`:t>0?`${String(t)} adopted`:`${String(e)} accessor${e===1?"y":"ies"}`;return u("span",{className:"text-[9px] font-medium text-foreground-subtle bg-surface-elevated/60 rounded px-1.5 py-0.5 flex-shrink-0",title:o,children:["+",n]})}const _h=240,su=200;function DS({resolved:e}){const t=ne(null),[n,o]=$(null);return u("span",{ref:t,className:"relative inline-flex items-center gap-1 cursor-help",onMouseEnter:()=>{const i=t.current;if(!i)return;const l=i.getBoundingClientRect(),f=window.innerHeight-l.bottom>=su?l.bottom+4:l.top-su-4,p=Math.max(8,Math.min(l.left,window.innerWidth-_h-8));o({top:f,left:p})},onMouseLeave:()=>o(null),children:[e.map(i=>{const l=Ch[i.feature];return l?r("span",{className:"inline-flex items-center justify-center h-4 w-4 rounded bg-surface-elevated/60 text-foreground-subtle",title:Mh[i.feature]??i.feature,children:r(l,{className:"h-2.5 w-2.5"})},i.feature):null}),n&&No(r(LS,{resolved:e,position:n}),document.body)]})}function LS({resolved:e,position:t}){return u("div",{style:{position:"fixed",top:t.top,left:t.left,width:_h,pointerEvents:"none"},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-2",children:[r("h5",{className:"text-[9px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5",children:"Features"}),r("ul",{className:"space-y-0.5",children:e.map(n=>r(TS,{entry:n},n.feature))})]})}function TS({entry:e}){const t=Ch[e.feature],n=Mh[e.feature]??e.feature;return u("li",{className:"flex items-center justify-between gap-2 text-[10px]",children:[u("span",{className:"flex items-center gap-1.5 text-foreground",children:[t&&r(t,{className:"h-3 w-3 text-foreground-subtle"}),r("span",{children:n})]}),r(RS,{kind:e.kind})]})}function RS({kind:e}){return e==="marker"?r("span",{className:"text-[8.5px] px-1 rounded text-foreground-subtle",title:"Informational marker (no cap registered)",children:"marker"}):r("span",{className:W("text-[8.5px] px-1 rounded",e==="native"?"bg-success/15 text-success":"bg-primary/15 text-primary"),children:e})}function Dh({device:e,variant:t,flags:n,parent:o,integrationIcon:s,hasChildren:a,expanded:i,onToggleExpand:l,onNavigateToParent:c}){const d=Sh(e);return u("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[n.showChildrenAccordion&&a?r("button",{type:"button",onClick:f=>{f.stopPropagation(),l()},className:"flex h-3.5 w-3.5 items-center justify-center text-foreground-subtle hover:text-foreground transition-colors flex-shrink-0","aria-label":i?"Collapse children":"Expand children","aria-expanded":i,children:i?r(Xn,{className:"h-3 w-3"}):r(Mn,{className:"h-3 w-3"})}):n.showChildrenAccordion?r("span",{className:"h-3.5 w-3.5 flex-shrink-0"}):null,r(d,{className:W("text-foreground-subtle flex-shrink-0",t==="minimal"?"h-3 w-3":"h-3.5 w-3.5")}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.showIntegrationIcon&&s&&r("span",{className:"flex-shrink-0",children:s}),r("span",{className:W("font-semibold text-foreground truncate",t==="minimal"?"text-[10.5px]":"text-[11px]"),title:e.name,children:e.name})]}),(n.showId||n.showStableId)&&u("div",{className:"mt-0.5 flex items-center gap-1 text-[9px] text-foreground-subtle font-mono truncate",title:n.showStableId?`stableId: ${e.stableId}`:void 0,children:[n.showId&&u("span",{className:"flex-shrink-0 tabular-nums",children:["#",String(e.id)]}),n.showId&&n.showStableId&&r("span",{className:"flex-shrink-0 opacity-50",children:"·"}),n.showStableId&&r("span",{className:"truncate",children:bS(e.stableId)})]}),n.showParentBadge&&o&&u("button",{type:"button",onClick:f=>{f.stopPropagation(),c(o.id)},className:"mt-0.5 inline-flex max-w-full items-center gap-1 text-[9px] text-foreground-subtle hover:text-primary transition-colors",title:`Open parent: ${o.name} (#${String(o.id)})`,children:[r(Fi,{className:"h-2.5 w-2.5 shrink-0"}),u("span",{className:"truncate",children:["Under: ",o.name]})]})]})]})}function nc(e,t){return kh(e,t,o=>o.battery)??null}function rc(e,t){const n=St(e,t),o=ne(!1),{data:s,isLoading:a,isFetching:i,refetch:l}=Wn({queryKey:["device",t,"snapshot"],queryFn:()=>{if(!n)throw new Error("useDeviceSnapshotImage: device proxy not ready");const f=o.current;return o.current=!1,n.snapshot?.getSnapshot({force:f})??null},enabled:n!==null&&t!==null,staleTime:1e4,gcTime:1440*60*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:!1}),c=s?`data:${s.contentType};base64,${s.base64}`:null;function d(){o.current=!0,l()}return{src:c,loading:a||i,refresh:d}}function OS(e){return e<=10?JN:e<=30?ZN:e>=95?WN:wm}function zS(e,t){return t!=="none"?"text-emerald-400":e<=10?"text-rose-400":e<=30?"text-amber-400":"text-foreground-subtle"}function oc({status:e,variant:t="compact",className:n}){if(!e)return null;const o=OS(e.percentage),s=zS(e.percentage,e.charging),a=e.charging==="solar"?Rm:e.charging==="dc"?yk:null,i=e.sleeping;return u("span",{className:W("inline-flex items-center gap-1 text-[10px] font-medium",s,n),title:`Battery: ${Math.round(e.percentage)}%`+(e.charging!=="none"?` · charging (${e.charging})`:"")+(e.sleeping?" · sleeping":""),children:[r(o,{className:"h-3.5 w-3.5"}),u("span",{children:[Math.round(e.percentage),"%"]}),a&&r(a,{className:"h-3 w-3"}),i&&r(zl,{className:"h-3 w-3 text-blue-300"}),t==="full"&&e.charging!=="none"&&r("span",{className:"text-foreground-subtle",children:e.charging})]})}function Lh({trpc:e,device:t,status:n,enabled:o,showStatusPills:s=!1}){const a=o&&t.online,i=rc(e,a?t.id:null),l=(t.features??[]).includes("battery-operated"),c=s&&l&&!t.disabled,d=nc(e,c?t.id:null);return!o&&!c?null:u("span",{className:"inline-flex items-center gap-1.5 flex-nowrap whitespace-nowrap",children:[c&&d&&r(oc,{status:d}),o&&r(BS,{deviceName:t.name,snapshotUrl:i.src,status:n})]})}const qa=288,au=196,Ua=8;function BS({deviceName:e,snapshotUrl:t,status:n}){const o=ne(null),[s,a]=$(null),i=n==="offline"||n==="disabled",l=()=>{const d=o.current;if(!d)return;const f=d.getBoundingClientRect(),p=f.top,m=window.innerHeight-f.bottom,h=p<au+Ua&&m>p,g=h?f.bottom+Ua:f.top-au-Ua,b=f.right-qa,x=Math.max(8,Math.min(b,window.innerWidth-qa-8));a({top:g,left:x,placeBelow:h})},c=()=>a(null);return u(ge,{children:[r("button",{ref:o,type:"button",onClick:d=>d.stopPropagation(),onMouseEnter:l,onMouseLeave:c,onFocus:l,onBlur:c,className:"flex h-6 w-6 items-center justify-center rounded text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors flex-shrink-0",title:"Preview","aria-label":"Preview snapshot",children:r(So,{className:"h-3.5 w-3.5"})}),s&&No(u("div",{style:{position:"fixed",top:s.top,left:s.left,width:qa,pointerEvents:"none"},className:"rounded-lg border border-border bg-surface shadow-lg shadow-black/30 z-[9999] overflow-hidden",children:[r("div",{className:"h-40 bg-background flex items-center justify-center",children:t&&!i?r("img",{src:t,alt:e,className:"h-full w-full object-cover"}):r("span",{className:"text-xs text-foreground-subtle",children:n==="offline"?"Offline — no snapshot":n==="disabled"?"Disabled":"No snapshot yet"})}),r("div",{className:"px-3 py-2",children:r("p",{className:"text-xs font-semibold text-foreground truncate",children:e})})]}),document.body)]})}function Th({status:e}){const t=e==="disabled"?"bg-warning":e==="online"?"bg-success":"bg-danger",n=e==="disabled"?"Disabled":e==="online"?"Online":"Offline";return r("span",{className:W("h-1.5 w-1.5 rounded-full flex-shrink-0",t),title:n})}function ao(e){const{trpc:t,device:n,parent:o,integrationIcon:s,onNavigate:a,className:i}=e,l=fS(e),c=e.variant??"compact",d=e.view??"card",f=!n.disabled,p=n.isCamera??n.type.toLowerCase()==="camera",m=e.children??[],h=m.filter(ru),g=m.filter(M=>!ru(M)),b=m.length>0,[x,y]=$(!1),w=e.expanded??x,v=e.onToggleExpand??(()=>y(M=>!M)),N=M=>{a?.(M)},k=e.indentLevel??(e.isAccessoryRow?2:0),S=f?n.online?"online":"offline":"disabled";return d==="table"?r(jS,{trpc:t,device:n,variant:c,flags:l,parent:o??null,integrationIcon:s??null,accessoryCount:h.length,adoptedCount:g.length,hasChildren:b,expanded:w,onToggleExpand:v,onNavigate:N,displayStatus:S,isCamera:p,showSnapshot:l.showSnapshot&&p,isAccessoryRow:e.isAccessoryRow??!1,indentLevel:k,className:i}):u("div",{className:W("rounded-lg border border-border bg-surface transition-colors",!f&&"opacity-60",i),children:[u("div",{onClick:()=>N(n.id),className:W("flex items-center gap-2 cursor-pointer hover:border-foreground-subtle/30 w-full",c==="minimal"?"px-2.5 py-1.5":"px-3 py-2.5"),children:[r(Dh,{device:n,variant:c,flags:l,parent:o??null,integrationIcon:s??null,hasChildren:b,expanded:w,onToggleExpand:v,onNavigateToParent:N}),r($h,{trpc:t,device:n,flags:l,accessoryCount:h.length,adoptedCount:g.length,showFeatureRow:!1}),r(Lh,{trpc:t,device:n,status:S,enabled:l.showSnapshot&&p,showStatusPills:!0}),r(Eh,{trpc:t,device:n,flags:l}),r(Th,{status:S})]}),w&&b&&r(xS,{trpc:t,accessoryChildren:h,adoptedChildren:g,onNavigate:N})]})}const FS={0:"pl-2",1:"pl-6",2:"pl-8"};function jS(e){const{trpc:t,device:n,variant:o,flags:s,parent:a,integrationIcon:i,accessoryCount:l,adoptedCount:c,hasChildren:d,expanded:f,onToggleExpand:p,onNavigate:m,displayStatus:h,isCamera:g,showSnapshot:b,isAccessoryRow:x,indentLevel:y,className:w}=e;return u("tr",{onClick:()=>m(n.id),className:W("cursor-pointer hover:bg-surface-hover transition-colors",!s.showChildrenAccordion&&"border-b border-border-subtle/40",x&&"bg-foreground-subtle/[0.03]",w),children:[r("td",{className:W("py-2 align-middle pr-2",FS[y]),children:r(Dh,{device:n,variant:o,flags:s,parent:a,integrationIcon:i,hasChildren:d,expanded:f,onToggleExpand:p,onNavigateToParent:m})}),r("td",{className:"px-2 py-2 align-middle text-[10px] text-foreground-subtle whitespace-nowrap",children:n.type}),r("td",{className:"px-2 py-2 align-middle",children:r($h,{trpc:t,device:n,flags:s,accessoryCount:l,adoptedCount:c,showFeatureRow:!0})}),r("td",{className:"px-2 py-2 align-middle",children:r(Lh,{trpc:t,device:n,status:h,enabled:b&&g,showStatusPills:!0})}),r("td",{className:"px-2 py-2 align-middle text-right whitespace-nowrap",children:u("span",{className:"inline-flex items-center gap-1.5",children:[r(Eh,{trpc:t,device:n,flags:s}),r(Th,{status:h})]})})]})}function Rh(e,t){const[n,o]=$(e);return Z(()=>{const s=setTimeout(()=>o(e),t);return()=>clearTimeout(s)},[e,t]),n}const HS=new Set(["hub","nvr"]);function VS(e){const t=new Map;for(const s of e)t.set(s.id,s);const n=[],o=new Map;for(const s of e){const a=s.parentDeviceId;if(a==null){n.push(s);continue}const i=t.get(a);if(!i){n.push(s);continue}const l=s.role!==null&&s.role!==void 0;if(HS.has(i.type)&&!l){n.push(s);continue}const d=o.get(a);d?d.push(s):o.set(a,[s])}return{topLevel:n,accessoriesByParent:o}}const iu=2;function qS(e,t){if(t<=1)return[{kind:"page",n:1}];if(t<=7){const a=[];for(let i=1;i<=t;i++)a.push({kind:"page",n:i});return a}const n=[],o=Math.max(2,e-iu),s=Math.min(t-1,e+iu);n.push({kind:"page",n:1}),o>2&&n.push({kind:"ellipsis",side:"left"});for(let a=o;a<=s;a++)n.push({kind:"page",n:a});return s<t-1&&n.push({kind:"ellipsis",side:"right"}),n.push({kind:"page",n:t}),n}function US({currentPage:e,totalItems:t,pageSize:n,onPageChange:o,itemNoun:s="devices"}){if(t<=n)return null;const a=Math.ceil(t/n),i=(e-1)*n+1,l=Math.min(e*n,t),c=qS(e,a);return u("div",{className:"flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle",children:[u("span",{children:["Showing ",i,"–",l," of ",t," ",s]}),u("span",{className:"inline-flex items-center gap-1",children:[r("button",{type:"button","aria-label":"Previous page",disabled:e===1,onClick:()=>o(e-1),className:W("inline-flex items-center justify-center h-7 w-7 rounded border border-border bg-surface text-foreground-subtle","hover:text-foreground hover:bg-surface-hover transition-colors","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-surface"),children:r(p2,{className:"h-3 w-3"})}),c.map((d,f)=>{if(d.kind==="ellipsis")return r("span",{className:"px-1 text-foreground-subtle/60 select-none",children:"…"},`e-${f}`);const p=d.n===e;return r("button",{type:"button",onClick:()=>o(d.n),className:W("inline-flex items-center justify-center h-7 min-w-7 px-1.5 rounded border text-[10.5px] font-medium transition-colors",p?"border-primary/40 bg-primary/10 text-primary":"border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),children:d.n},`p-${d.n}`)}),r("button",{type:"button","aria-label":"Next page",disabled:e===a,onClick:()=>o(e+1),className:W("inline-flex items-center justify-center h-7 w-7 rounded border border-border bg-surface text-foreground-subtle","hover:text-foreground hover:bg-surface-hover transition-colors","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-surface"),children:r(Mn,{className:"h-3 w-3"})})]})]})}function QS({view:e,onViewChange:t,types:n,currentType:o,onTypeChange:s,addons:a,currentAddon:i,onAddonChange:l,hideAddons:c=!1}){return u("div",{className:"flex items-center gap-2 flex-wrap",children:[u("span",{className:"inline-flex border border-border rounded-md overflow-hidden",children:[r("button",{type:"button",onClick:()=>t("cards"),className:W("inline-flex items-center justify-center h-7 w-8 transition-colors",e==="cards"?"bg-primary/10 text-primary":"bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),"aria-label":"Cards view",children:r(J2,{className:"h-3.5 w-3.5"})}),r("button",{type:"button",onClick:()=>t("table"),className:W("inline-flex items-center justify-center h-7 w-8 border-l border-border transition-colors",e==="table"?"bg-primary/10 text-primary":"bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),"aria-label":"Table view",children:r(Gk,{className:"h-3.5 w-3.5"})})]}),n&&n.length>0&&u(ge,{children:[r(lu,{children:"Type"}),r(Qa,{active:o===null,onClick:()=>s(null),children:"All"}),n.map(d=>r(Qa,{active:o===d,onClick:()=>s(o===d?null:d),children:KS(d)},d))]}),!c&&a&&a.length>0&&u(ge,{children:[r(lu,{children:"Integration"}),a.map(d=>r(Qa,{active:i===d.id,icon:d.icon,onClick:()=>l(i===d.id?null:d.id),showClearIcon:i===d.id,children:d.name},d.id))]})]})}function lu({children:e}){return r("span",{className:"text-[10px] font-medium uppercase tracking-wider text-foreground-subtle ml-1",children:e})}function Qa({active:e,icon:t,onClick:n,showClearIcon:o,children:s}){return u("button",{type:"button",onClick:n,className:W("inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full border text-[10.5px] font-medium transition-colors",e?"border-primary/40 bg-primary/15 text-primary":"border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),children:[t&&r("span",{className:"inline-flex items-center",children:t}),r("span",{children:s}),e&&o&&r(Ye,{className:"h-2.5 w-2.5 opacity-70"})]})}function KS(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function GS({variant:e,onClearFilters:t}){return u("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r(W2,{className:"h-8 w-8 text-foreground-subtle/40 mb-3"}),r("p",{className:"text-sm font-medium text-foreground-subtle",children:e==="filtered"?"No devices match the current filters":"No devices yet"}),e==="filtered"&&t&&r("button",{type:"button",onClick:t,className:"mt-2 text-[11px] text-primary hover:underline",children:"Clear filters"})]})}function Vt(e,t){if(e==="root")return t;switch(t){case"view":return"deviceView";case"page":return"devicePage";case"type":return"deviceType";case"q":return"deviceQ";case"addon":return"deviceAddon"}}function cu(e){try{const t=localStorage.getItem(`camstack:${e}:lastFilters`);if(!t)return{};const n=JSON.parse(t);return typeof n!="object"||n===null?{}:n}catch{return{}}}function WS(e,t){try{localStorage.setItem(`camstack:${e}:lastFilters`,JSON.stringify(t))}catch{}}function du(e,t,n){const o=new URLSearchParams(window.location.search),s=o.get(Vt(e,"view")),a=s==="cards"||s==="table"?s:n.view??t,i=o.get(Vt(e,"page")),l=i?parseInt(i,10):1,c=Number.isFinite(l)&&l>=1?l:1,d=o.get(Vt(e,"addon"))??n.addon??null,f=o.get(Vt(e,"type"))??n.type??null,p=o.get(Vt(e,"q"))??n.q??"";return{view:a,page:c,addon:d,type:f,q:p}}function YS(e,t,n){const o=new URLSearchParams(window.location.search),s=(l,c)=>{c===null||c===""?o.delete(l):o.set(l,c)};s(Vt(e,"view"),t.view===n?null:t.view),s(Vt(e,"page"),t.page===1?null:String(t.page)),s(Vt(e,"addon"),t.addon),s(Vt(e,"type"),t.type),s(Vt(e,"q"),t.q||null);const a=o.toString(),i=a?`${window.location.pathname}?${a}`:window.location.pathname;window.history.replaceState(null,"",i)}function ZS(e){const{scope:t,defaultView:n,lsKey:o}=e,[s,a]=$(()=>{const g=cu(o);return du(t,n,g)}),i=ne(s);i.current=s,Z(()=>{const g=()=>{const b=cu(o),x=du(t,n,b);i.current=x,a(x)};return window.addEventListener("popstate",g),()=>window.removeEventListener("popstate",g)},[t,n,o]);const l=q(g=>{const b=g(i.current);i.current=b,a(b),YS(t,b,n),WS(o,{view:b.view,addon:b.addon,type:b.type,q:b.q})},[t,n,o]),c=q(g=>l(b=>({...b,view:g})),[l]),d=q(g=>l(b=>({...b,page:g})),[l]),f=q(g=>l(b=>({...b,addon:g,page:1})),[l]),p=q(g=>l(b=>({...b,type:g,page:1})),[l]),m=q(g=>l(b=>({...b,q:g,page:1})),[l]),h=q(()=>l(g=>({...g,addon:null,type:null,q:"",page:1})),[l]);return{state:s,setView:c,setPage:d,setAddon:f,setType:p,setQ:m,clearFilters:h}}const XS={cards:24,table:50};function io(e){const{devices:t,trpc:n,defaultView:o="table",filters:s,forceAddon:a,resolveIntegrationIcon:i,resolveParent:l,onNavigate:c,pageSize:d=XS,urlScope:f="root",lsKey:p=f==="root"?"devices":"integrations:nested"}=e,m=ZS({scope:f,defaultView:o,lsKey:p}),h=m.state.view,g=h==="cards"?d.cards:d.table,[b,x]=$(m.state.q),y=Rh(b,300);Z(()=>{y!==m.state.q&&m.setQ(y)},[y]);const w=a??m.state.addon,v=U(()=>{const O=m.state.q.toLowerCase().trim();return t.filter(I=>!(w&&I.addonId!==w||m.state.type&&I.type!==m.state.type||O&&!I.name.toLowerCase().includes(O)&&!I.stableId.toLowerCase().includes(O)))},[t,w,m.state.type,m.state.q]),N=U(()=>VS(v),[v]),k=U(()=>{if(m.state.q.trim()==="")return new Set;const O=m.state.q.toLowerCase().trim(),I=new Set;for(const[L,_]of N.accessoriesByParent.entries())_.some(R=>R.name.toLowerCase().includes(O)||R.stableId.toLowerCase().includes(O))&&I.add(L);return I},[N.accessoriesByParent,m.state.q]),S=N.topLevel.length,M=Math.max(1,Math.ceil(S/g)),P=Math.min(m.state.page,M),A=(P-1)*g,z=N.topLevel.slice(A,A+g);Z(()=>{P!==m.state.page&&m.setPage(P)},[P]),oC();const D=w!=null||m.state.type!==null||m.state.q!=="",T=S===0;return u("div",{className:"flex flex-col gap-3",children:[u("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[r(QS,{view:h,onViewChange:m.setView,types:s?.types,currentType:m.state.type,onTypeChange:m.setType,addons:s?.addons,currentAddon:m.state.addon,onAddonChange:m.setAddon,hideAddons:a!==void 0}),u("div",{className:"relative",children:[r(so,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle pointer-events-none"}),r("input",{type:"text",value:b,onChange:O=>x(O.target.value),placeholder:"Search by name or stableId","aria-label":"Search devices by name or stableId",className:"h-7 pl-7 pr-2.5 rounded-md border border-border bg-surface text-[11px] text-foreground placeholder:text-foreground-subtle/60 focus:outline-none focus:ring-1 focus:ring-primary/40 w-56"})]})]}),T?r(GS,{variant:D?"filtered":"nofilter",onClearFilters:D?m.clearFilters:void 0}):h==="cards"?r(JS,{rows:z,accessoriesByParent:N.accessoriesByParent,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}):r(nC,{rows:z,accessoriesByParent:N.accessoriesByParent,autoExpandedParents:k,devices:v,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}),r(US,{currentPage:P,totalItems:S,pageSize:g,onPageChange:m.setPage}),a===void 0&&D&&S>0&&u("p",{className:"text-[11px] text-foreground-subtle",children:["Showing ",S," of ",t.length," devices",w&&u(ge,{children:[" ","· filtered by"," ",r("strong",{className:"text-primary",children:s?.addons?.find(O=>O.id===w)?.name??w})]})]})]})}function JS({rows:e,accessoriesByParent:t,trpc:n,resolveIntegrationIcon:o,resolveParent:s,onNavigate:a}){return r("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.map(i=>{const l=t.get(i.id)??[];return r(ao,{trpc:n,device:i,view:"card",integrationIcon:o?.(i.addonId)??null,parent:i.parentDeviceId!==null?s?.(i.parentDeviceId)??null:null,children:l,onNavigate:a??void 0},i.id)})})}const eC=new Set(["hub","nvr"]);function tC(e,t){return e.parentDeviceId===null||t===null?0:eC.has(t.toLowerCase())?1:0}function nC({rows:e,accessoriesByParent:t,autoExpandedParents:n,devices:o,trpc:s,resolveIntegrationIcon:a,resolveParent:i,onNavigate:l}){const c=U(()=>{const d=new Map;for(const f of o)d.set(f.id,f.type);return d},[o]);return r("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:u("table",{className:"w-full border-collapse",children:[r("thead",{children:u("tr",{className:"border-b border-border",children:[r("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle",children:"Name"}),r("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-24",children:"Type"}),r("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Features"}),r("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-20",children:"Preview"}),r("th",{className:"text-right px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Actions"})]})}),r("tbody",{children:e.map(d=>{const f=t.get(d.id)??[],p=f.length>0,m=n.has(d.id),h=d.parentDeviceId!==null?i?.(d.parentDeviceId)??null:null,g=d.parentDeviceId!==null?c.get(d.parentDeviceId)??null:null;return r(rC,{parent:d,accessories:f,hasAccessories:p,forceExpanded:m,trpc:s,integrationIcon:a?.(d.addonId)??null,parentRowParent:h,indentLevel:tC(d,g),onNavigate:l??null},d.id)})})]})})}function rC({parent:e,accessories:t,hasAccessories:n,forceExpanded:o,trpc:s,integrationIcon:a,parentRowParent:i,indentLevel:l,onNavigate:c}){const[d,f]=$(o),p=ne(o);return Z(()=>{p.current!==o&&(f(o),p.current=o)},[o]),u(ge,{children:[r(ao,{trpc:s,device:e,view:"table",integrationIcon:a,parent:i,children:t,onNavigate:c??void 0,showChildrenAccordion:n,expanded:d,onToggleExpand:()=>f(g=>!g),indentLevel:l}),n&&d&&t.map(g=>r(ao,{trpc:s,device:g,view:"table",integrationIcon:null,parent:null,isAccessoryRow:!0,showChildrenAccordion:!1,onNavigate:c??void 0},g.id))]})}function oC(){ke()}function sC({options:e,value:t,onChange:n}){return r("div",{className:"flex flex-wrap gap-2",children:e.map(o=>{const s=o.id===t;return u("button",{onClick:()=>o.available&&n(o.id),disabled:!o.available,className:`flex items-center gap-2 rounded-lg border px-3 py-2 text-xs font-medium transition-all ${s?"border-primary/40 bg-primary/10 text-primary":o.available?"border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground":"border-border/40 bg-surface/40 text-foreground-subtle/40 cursor-not-allowed"}`,children:[r(_2,{className:"h-3.5 w-3.5 shrink-0"}),o.label,o.isBest&&u("span",{className:"inline-flex items-center gap-0.5 rounded-full bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-amber-400",children:[r(Uk,{className:"h-2.5 w-2.5"}),"Best"]}),o.platformScore!=null&&u("span",{className:"text-[10px] text-foreground-subtle/60",children:["(",o.platformScore,")"]}),r("span",{className:`h-1.5 w-1.5 rounded-full ${o.available?"bg-success":"bg-danger"}`})]},o.id)})})}function aC(e,t){const n=new Set(t.slots.flatMap(i=>i.addons.map(l=>l.id))),o=[];function s(i){if(!n.has(i.addonId))return o.push(`Addon "${i.addonId}" is no longer available — step removed`),null;const l=t.slots.flatMap(f=>f.addons).find(f=>f.id===i.addonId);let c=i.modelId;if(l&&!l.models.some(f=>f.id===c)){const f=l.defaultModelId;o.push(`Model "${c}" not available for ${i.addonId} — using "${f}"`),c=f}const d=i.children.map(f=>s(f)).filter(f=>f!==null);return{...i,modelId:c,children:d}}const a=e.map(i=>s(i)).filter(i=>i!==null);return{valid:o.length===0,steps:a,warnings:o}}function iC(e){const t=new Map;for(const n of e.slots)for(const o of n.addons)t.set(o.id,o);return t}function Ka(e){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:!0,modelId:e.defaultModelId,children:[]}}function Ga({addon:e,onClick:t}){return r("button",{type:"button",onClick:t,className:"w-full rounded-lg border border-dashed border-border/60 px-3 py-2.5 text-left transition-all hover:border-primary/30 hover:bg-surface/60 group",children:u("div",{className:"flex items-center gap-3",children:[r(S2,{className:"h-[18px] w-[18px] text-foreground-subtle/30 group-hover:text-primary/60 shrink-0"}),u("div",{className:"flex-1 min-w-0",children:[r("span",{className:"text-[13px] font-medium text-foreground-subtle/50 group-hover:text-foreground-subtle block truncate",children:e.name}),u("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(n=>r("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-blue-500/8 text-blue-400/50",children:n},n)),e.inputClasses.length>0&&e.outputClasses.length>0&&r("span",{className:"text-foreground-subtle/25 text-[10px]",children:"→"}),e.outputClasses.map(n=>r("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-green-500/8 text-green-400/50",children:n},n))]})]})]})})}function sc({schema:e,steps:t,onChange:n,templates:o,selectedTemplateId:s,onSelectTemplate:a,onSaveTemplate:i,onUpdateTemplate:l,onDeleteTemplate:c,readOnly:d=!1,excludeAddons:f=[],hideTemplates:p=!1,showOnlyEnabled:m=!1,showSlotLabels:h=!1,toggleMode:g="simple",overrides:b={},onOverrideChange:x,inheritedEnabledByAddon:y={},hideModelAndSettings:w=!1}){const v=H=>({toggleMode:g,hideModelAndSettings:w,...g==="threeState"?{overrideState:b[H]!==void 0?b[H]:null,onOverrideChange:x?E=>x(H,E):void 0,inheritedEnabled:y[H]}:{}}),N=U(()=>new Set(f),[f]),k=U(()=>iC(e),[e]),[S,M]=$([]),P=s?JSON.stringify(t)!==JSON.stringify(o.find(H=>H.id===s)?.steps):!1;function A(H){const E=H.target.value||null;if(E){const Q=o.find(K=>K.id===E);if(Q){const K=aC(Q.steps,e);M([...K.warnings])}}else M([]);a(E)}function z(){s&&l(s,t)}function D(){const H=window.prompt("Template name:");H?.trim()&&i(H.trim(),t)}function T(){if(!s)return;const H=o.find(E=>E.id===s);H&&window.confirm(`Delete template "${H.name}"?`)&&c(s)}function O(H){n(t.map(E=>E.addonId!==H.addonId?E:I(H)))}function I(H){const E=H.children.some(Q=>Q.enabled||Q.children.some(K=>K.enabled));return{...H,enabled:H.enabled||E,children:H.children.map(Q=>{const K=Q.children.some(Y=>Y.enabled);return{...Q,enabled:Q.enabled||K}})}}function L(H,E){const Q=Ka(E);n(t.map(K=>K.addonId!==H?K:{...K,children:[...K.children,Q]}))}function _(H){const E=new Set;for(const Q of H){E.add(Q.addonId);for(const Y of Q.children)E.add(Y.addonId);const K=_(Q.children);for(const Y of K)E.add(Y)}return E}const R=_(t);function B(H){const E=k.get(H.addonId);if(!E)return[];const K=e.slots.find(X=>X.id===E.slot)?.parentSlot==null,Y=E.childSlots,re=new Set(H.children.map(X=>X.addonId)),te=[];for(const X of e.slots)if(Y.includes(X.id))for(const oe of X.addons){if(re.has(oe.id)||N.has(oe.id))continue;const be=oe.inputClasses.length===0;if(be&&!K)continue;(be||oe.inputClasses.some(G=>H.outputClasses.includes(G)))&&te.push(oe)}return te}function F(H){const E=m?{...H,children:H.children.filter(K=>K.enabled).map(K=>({...K,children:K.children.filter(Y=>Y.enabled)}))}:H,Q=m?[]:B(E);return u("div",{className:"space-y-1.5",children:[r(gs,{step:E,schema:k.get(E.addonId)??null,allSchemas:k,onChange:O,onDelete:d?void 0:K=>n(t.filter(Y=>Y.addonId!==K)),readOnly:d,...v(E.addonId)}),(E.children.length>0||Q.length>0)&&u("div",{className:"ml-4 pl-3 border-l border-border/60 space-y-1.5",children:[h&&r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/40",children:"Slot: Cropper / Classifier"}),E.children.map(K=>{const Y=B(K);return u("div",{className:"space-y-1.5",children:[r(gs,{step:K,schema:k.get(K.addonId)??null,allSchemas:k,depth:1,onChange:re=>{O({...E,children:E.children.map(te=>te.addonId===re.addonId?re:te)})},onDelete:d?void 0:re=>{O({...E,children:E.children.filter(te=>te.addonId!==re)})},readOnly:d,...v(K.addonId)}),(K.children.length>0||Y.length>0)&&u("div",{className:"ml-4 pl-3 border-l border-border/40 space-y-1.5",children:[h&&r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/30",children:"Slot: Recognizer"}),K.children.map(re=>r(gs,{step:re,schema:k.get(re.addonId)??null,allSchemas:k,depth:2,onChange:te=>{O({...E,children:E.children.map(X=>X.addonId===K.addonId?{...X,children:X.children.map(oe=>oe.addonId===te.addonId?te:oe)}:X)})},onDelete:d?void 0:te=>{O({...E,children:E.children.map(X=>X.addonId===K.addonId?{...X,children:X.children.filter(oe=>oe.addonId!==te)}:X)})},readOnly:d,...v(re.addonId)},re.addonId)),!d&&Y.map(re=>r(Ga,{addon:re,onClick:()=>{const te=Ka(re);O({...E,children:E.children.map(X=>X.addonId===K.addonId?{...X,children:[...X.children,te]}:X)})}},re.id))]})]},K.addonId)}),!d&&Q.map(K=>r(Ga,{addon:K,onClick:()=>L(E.addonId,K)},K.id))]})]},E.addonId)}const j=e.slots.filter(H=>H.parentSlot===null).sort((H,E)=>H.priority-E.priority);return u("div",{className:"space-y-4",children:[!p&&r("div",{className:"rounded-lg border border-border bg-surface p-3",children:u("div",{className:"flex items-center gap-2",children:[r("div",{className:"relative flex-1 min-w-0",children:u("select",{value:s??"",onChange:A,className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:border-primary/50",children:[r("option",{value:"",children:"No template"}),o.map(H=>r("option",{value:H.id,children:H.name},H.id))]})}),P&&r("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500 shrink-0"}),r("button",{onClick:z,disabled:!s||d,title:"Save",className:W("p-2 rounded-lg border border-border transition-colors",s&&!d?"text-foreground-subtle hover:bg-surface-hover":"text-foreground-subtle/30 cursor-not-allowed"),children:r(Pk,{className:"h-4 w-4"})}),r("button",{onClick:D,disabled:d,title:"Save As",className:W("p-2 rounded-lg border border-border transition-colors",d?"text-foreground-subtle/30 cursor-not-allowed":"text-foreground-subtle hover:bg-surface-hover"),children:r(P2,{className:"h-4 w-4"})}),r("button",{onClick:T,disabled:!s||d,title:"Delete",className:W("p-2 rounded-lg border border-border transition-colors",s&&!d?"text-foreground-subtle hover:text-danger":"text-foreground-subtle/30 cursor-not-allowed"),children:r(Qt,{className:"h-4 w-4"})})]})}),S.length>0&&u("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 text-xs text-amber-400 space-y-1",children:[u("div",{className:"flex items-center justify-between",children:[r("span",{className:"font-medium",children:"Template loaded with warnings:"}),r("button",{onClick:()=>M([]),className:"text-amber-400/60 hover:text-amber-400",children:r(Ye,{className:"h-3.5 w-3.5"})})]}),S.map((H,E)=>u("div",{children:["• ",H]},E))]}),j.map(H=>{const E=t.filter(te=>te.slot===H.id&&!N.has(te.addonId)),Q=m?E.filter(te=>te.enabled):E,K=m?[]:H.addons.filter(te=>!R.has(te.id)&&!N.has(te.id)),Y=new Map,re=[];for(const te of Q)te.group?(Y.has(te.group)||Y.set(te.group,[]),Y.get(te.group).push(te)):re.push(te);return u("div",{className:"space-y-2",children:[h&&u("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50",children:["Slot: ",H.label]}),re.map(te=>F(te)),[...Y.entries()].map(([te,X])=>u("div",{className:"space-y-2 rounded-lg border border-border/40 p-2",children:[r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50 px-1",children:te}),X.map(oe=>F(oe))]},te)),!d&&K.map(te=>r(Ga,{addon:te,onClick:()=>{n([...t,Ka(te)])}},te.id))]},H.id)})]})}const Qr={person:"#3b82f6",vehicle:"#f59e0b",animal:"#22c55e",face:"#a855f7",plate:"#ec4899",bird:"#14b8a6",dog:"#84cc16",cat:"#f97316",car:"#f59e0b",truck:"#d97706",bus:"#b45309",motorcycle:"#eab308",bicycle:"#ca8a04",motion:"#facc15"},uu=["#ef4444","#8b5cf6","#06b6d4","#f97316","#10b981","#6366f1","#e11d48","#0891b2","#7c3aed","#059669"],Oh="#f59e42";function lt(e,t){if(t?.[e])return t[e];if(t?.[e.toLowerCase()])return t[e.toLowerCase()];if(Qr[e])return Qr[e];if(Qr[e.toLowerCase()])return Qr[e.toLowerCase()];let n=0;for(let o=0;o<e.length;o++)n=n*31+(e.codePointAt(o)??0)>>>0;return uu[n%uu.length]??Oh}function lC({src:e,imageWidth:t,imageHeight:n,detections:o=[],classColors:s,aspectRatio:a,className:i,placeholder:l,showConfidence:c=!0,minConfidence:d=0,borderWidth:f=2}){function p(y){return lt(y,s)}const m=a??(t&&n?`${t}/${n}`:"16/9"),h=o.filter(y=>y.score>=d),g=h.filter(y=>y.kind==="first-level"),b=h.filter(y=>y.kind==="detail"),x=uC(b,y=>y.parentId??"");return r("div",{className:W("rounded-lg border border-border bg-surface overflow-hidden relative",i),style:{aspectRatio:m},children:e?u(ge,{children:[r("img",{src:e,className:"absolute inset-0 w-full h-full object-fill",alt:""}),h.map((y,w)=>y.debug?.mask&&y.debug.maskWidth&&y.debug.maskHeight?r(cC,{mask:y.debug.mask,maskWidth:y.debug.maskWidth,maskHeight:y.debug.maskHeight,bbox:y.bbox,imageWidth:t,imageHeight:n,color:p(y.macroClass)},`mask-${w}`):null),g.map(y=>{const w=x.get(y.id)??[];return r(pu,{detection:y,imageWidth:t,imageHeight:n,color:p(y.macroClass),showConfidence:c,borderWidth:y.debug?.mask?1:f,children:w.map(v=>r(dC,{child:v,parentBbox:y.bbox,color:p(v.macroClass),showConfidence:c},`child-${v.id}`))},`det-${y.id}`)}),b.filter(y=>!y.parentId||!g.some(w=>w.id===y.parentId)).map(y=>r(pu,{detection:y,imageWidth:t,imageHeight:n,color:p(y.macroClass),showConfidence:c,borderWidth:f},`orphan-${y.id}`))]}):r("div",{className:"w-full h-full flex items-center justify-center text-foreground-subtle text-sm",children:l??"No image loaded"})})}function pu({detection:e,imageWidth:t,imageHeight:n,color:o,showConfidence:s,borderWidth:a,children:i}){const{x:l,y:c,width:d,height:f}=e.bbox,p=u("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"2px"},children:[u("span",{className:"text-[10px] px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:o},children:[e.macroClass,s&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((m,h)=>u("span",{className:"text-[9px] font-semibold px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:lt(m.label)},children:[m.label," ",(m.score*100).toFixed(0),"%"]},`${e.id}-lbl-${h}`))]});return u("div",{className:"absolute rounded-sm",style:{left:`${l/t*100}%`,top:`${c/n*100}%`,width:`${d/t*100}%`,height:`${f/n*100}%`,borderWidth:`${a}px`,borderStyle:"solid",borderColor:o},children:[p,i]})}function cC({mask:e,maskWidth:t,maskHeight:n,bbox:o,imageWidth:s,imageHeight:a,color:i}){const l=ne(null);return Z(()=>{const c=l.current;if(!c)return;const d=c.getContext("2d");if(!d)return;const f=atob(e),p=new Uint8Array(f.length);for(let y=0;y<f.length;y++)p[y]=f.charCodeAt(y);const m=parseInt(i.slice(1,3),16),h=parseInt(i.slice(3,5),16),g=parseInt(i.slice(5,7),16);c.width=t,c.height=n;const b=d.createImageData(t,n),x=t*n;for(let y=0;y<x;y++){const w=y<p.length?p[y]:0,v=y*4;w>0&&(b.data[v]=m,b.data[v+1]=h,b.data[v+2]=g,b.data[v+3]=120)}d.putImageData(b,0,0)},[e,t,n,i]),r("canvas",{ref:l,className:"absolute pointer-events-none",style:{left:`${o.x/s*100}%`,top:`${o.y/a*100}%`,width:`${o.width/s*100}%`,height:`${o.height/a*100}%`,imageRendering:"pixelated"}})}function dC({child:e,parentBbox:t,color:n,showConfidence:o}){if(t.width<=0||t.height<=0)return null;const s=(e.bbox.x-t.x)/t.width*100,a=(e.bbox.y-t.y)/t.height*100,i=e.bbox.width/t.width*100,l=e.bbox.height/t.height*100;return r("div",{className:"absolute rounded-sm",style:{left:`${Math.max(0,s)}%`,top:`${Math.max(0,a)}%`,width:`${Math.min(100,i)}%`,height:`${Math.min(100,l)}%`,borderWidth:"1px",borderStyle:"solid",borderColor:n},children:u("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"1px"},children:[u("span",{className:"text-[9px] px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:n},children:[e.macroClass,o&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((c,d)=>u("span",{className:"text-[8px] font-semibold px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:lt(c.label)},children:[c.label," ",(c.score*100).toFixed(0),"%"]},`${e.id}-lbl-${d}`))]})})}function uC(e,t){const n=new Map;for(const o of e){const s=t(o),a=n.get(s)??[];a.push(o),n.set(s,a)}return n}function pC({detections:e,classColors:t,className:n,hiddenKeys:o,onToggleVisibility:s}){const a=t;if(e.length===0)return r("div",{className:"text-sm text-foreground-subtle italic text-center py-4",children:"No detections"});const i=e.filter(f=>f.kind==="first-level"),l=e.filter(f=>f.kind==="detail"),c=new Map;for(const f of l){if(!f.parentId)continue;const p=c.get(f.parentId)??[];p.push(f),c.set(f.parentId,p)}const d=l.filter(f=>!f.parentId||!i.some(p=>p.id===f.parentId));return u("div",{className:n,children:[u("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Detections (",e.length,")"]}),u("div",{className:"space-y-2",children:[i.map(f=>r(fu,{detection:f,children_:c.get(f.id)??[],colors:a,hiddenKeys:o,onToggleVisibility:s},f.id)),d.map(f=>r(fu,{detection:f,children_:[],colors:a,hiddenKeys:o,onToggleVisibility:s},f.id))]})]})}function fu({detection:e,children_:t,colors:n,hiddenKeys:o,onToggleVisibility:s}){const a=lt(e.macroClass,n),i=!o?.has(e.id),l=e.debug?.mask,c=e.debug?.maskWidth,d=e.debug?.maskHeight,f=e.debug?.alternateLabels;return u("div",{className:`rounded-md border border-border bg-surface p-3 space-y-1 ${i?"":"opacity-40"}`,children:[u("div",{className:"flex justify-between items-center",children:[u("div",{className:"flex items-center gap-2",children:[s&&r("input",{type:"checkbox",checked:i,onChange:()=>s(e.id,!i),className:"h-3.5 w-3.5 rounded border-border accent-primary cursor-pointer shrink-0"}),r("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:a}}),r("span",{className:"text-sm font-medium text-foreground",children:e.macroClass}),e.kind==="detail"&&r("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:"detail"}),l&&c&&d&&u("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",c,"x",d]})]}),r(hC,{confidence:e.score})]}),u("div",{className:"text-[10px] text-foreground-subtle font-mono",children:["bbox: [",Math.round(e.bbox.x),", ",Math.round(e.bbox.y),","," ",Math.round(e.bbox.x+e.bbox.width),","," ",Math.round(e.bbox.y+e.bbox.height),"]"]}),e.labels.length>0&&r("div",{className:"flex flex-wrap gap-1 mt-1",children:e.labels.map((p,m)=>u("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{backgroundColor:lt(p.label,n)+"20",color:lt(p.label,n)},children:[p.label,u("span",{className:"opacity-60",children:[(p.score*100).toFixed(0),"%"]}),p.detectionId&&u("span",{className:"opacity-40 text-[8px]",children:["→ ",p.detectionId]})]},m))}),f&&Object.keys(f).length>0&&r(mC,{alternateLabels:f,colors:n}),t.length>0&&r(fC,{items:t,colors:n,hiddenKeys:o,onToggleVisibility:s})]})}function fC({items:e,colors:t,hiddenKeys:n,onToggleVisibility:o}){return r("div",{className:"ml-4 mt-1.5 space-y-1.5 border-l-2 border-border pl-3",children:e.map(s=>{const a=lt(s.macroClass,t),i=!n?.has(s.id),l=s.debug?.mask,c=s.debug?.maskWidth,d=s.debug?.maskHeight;return u("div",{className:`text-xs space-y-0.5 ${i?"":"opacity-40"}`,children:[u("div",{className:"flex items-center gap-1.5",children:[o&&r("input",{type:"checkbox",checked:i,onChange:()=>o(s.id,!i),className:"h-3 w-3 rounded border-border accent-primary cursor-pointer shrink-0"}),r("span",{className:"h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:a}}),r("span",{className:"font-medium",style:{color:a},children:s.macroClass}),u("span",{className:"text-foreground-subtle",children:[(s.score*100).toFixed(0),"%"]}),l&&c&&d&&u("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",c,"x",d]})]}),s.labels.length>0&&r("div",{className:"flex flex-wrap gap-1 ml-5 mt-0.5",children:s.labels.map((f,p)=>u("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-medium px-1 py-0.5 rounded-full",style:{backgroundColor:lt(f.label,t)+"20",color:lt(f.label,t)},children:[f.label," ",u("span",{className:"opacity-60",children:[(f.score*100).toFixed(0),"%"]})]},p))})]},s.id)})})}function mC({alternateLabels:e,colors:t}){const[n,o]=$(!1),s=Object.keys(e);return u("div",{className:"mt-1",children:[u("button",{onClick:()=>o(a=>!a),className:"text-[9px] text-foreground-subtle hover:text-foreground transition-colors flex items-center gap-1",children:[r("span",{className:`transition-transform ${n?"rotate-90":""}`,children:"▶"}),"Alternates (",s.length," source",s.length!==1?"s":"",")"]}),n&&r("div",{className:"mt-1 ml-3 space-y-1.5",children:s.map(a=>{const i=e[a];return!i||i.length===0?null:u("div",{children:[r("div",{className:"text-[9px] font-medium text-foreground-subtle mb-0.5",children:a}),r("div",{className:"flex flex-wrap gap-1",children:i.map((l,c)=>u("span",{className:"inline-flex items-center gap-0.5 text-[9px] px-1 py-0.5 rounded-full",style:{backgroundColor:lt(a,t)+"10",color:lt(a,t),opacity:Math.max(.4,l.score)},children:[l.label,u("span",{className:"opacity-60",children:[(l.score*100).toFixed(1),"%"]})]},c))})]},a)})})]})}function hC({confidence:e}){const t=e>=.8?"bg-success/10 text-success":e>=.5?"bg-warning/10 text-warning":"bg-danger/10 text-danger";return u("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${t}`,children:[(e*100).toFixed(1),"%"]})}function gC({timings:e,totalMs:t,className:n}){const o=Object.entries(e);return o.length===0&&t===void 0?null:u("div",{className:`rounded-lg border border-border bg-surface p-3 space-y-2 ${n??""}`,children:[r("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide",children:"Timings"}),u("div",{className:"space-y-1 text-xs",children:[o.map(([s,a])=>u("div",{className:"flex justify-between",children:[r("span",{className:"text-foreground-subtle",children:s}),u("span",{className:"font-mono text-foreground",children:[a.toFixed(1),"ms"]})]},s)),t!==void 0&&u("div",{className:"flex justify-between pt-1 border-t border-border font-medium text-foreground",children:[r("span",{children:"Total"}),u("span",{className:"font-mono",children:[t.toFixed(1),"ms"]})]})]})]})}function bC({images:e,selectedFilename:t,uploadedName:n,onSelect:o,onUpload:s,className:a,accept:i="image/*",uploadLabel:l="Upload..."}){const c=()=>{const d=document.createElement("input");d.type="file",d.accept=i,d.onchange=()=>{const f=d.files?.[0];if(!f)return;const p=new FileReader;p.onload=()=>{const m=p.result,h=m.split(",")[1];h&&s(h,f.name,m)},p.readAsDataURL(f)},d.click()};return u("div",{className:`flex flex-wrap items-center gap-2 ${a??""}`,children:[e.map(d=>r("button",{onClick:()=>o(d.filename),className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${t===d.filename?"bg-primary text-primary-foreground border-primary":"bg-surface border-border text-foreground hover:border-primary/50"}`,children:d.id??d.filename.replace(/\.[^.]+$/,"")},d.filename)),r("button",{onClick:c,className:"px-3 py-1.5 text-xs rounded-md border border-border bg-surface text-foreground hover:bg-surface-hover transition-colors",children:l}),n&&r("span",{className:"text-xs text-foreground-subtle",children:n})]})}const Ho="w-full px-3 py-2 text-sm rounded-md border border-border bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-primary/50";function xC({runtime:e,backend:t,modelId:n,agentId:o="hub",runtimes:s,backends:a,models:i,agents:l=[],onRuntimeChange:c,onBackendChange:d,onModelChange:f,onAgentChange:p,layout:m="grid",className:h,showAgent:g=!1}){return u("div",{className:`${m==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4":m==="horizontal"?"flex flex-wrap items-end gap-4":"space-y-3"} ${h??""}`,children:[g&&l.length>0&&u("label",{className:"space-y-1",children:[r("span",{className:"text-xs font-medium text-foreground-subtle",children:"Agent"}),r("select",{value:o,onChange:x=>p?.(x.target.value),className:Ho,children:l.map(x=>u("option",{value:x.id,children:[x.name," (",x.status,")"]},x.id))})]}),u("label",{className:"space-y-1",children:[r("span",{className:"text-xs font-medium text-foreground-subtle",children:"Runtime"}),r("select",{value:e,onChange:x=>c(x.target.value),className:Ho,children:s.map(x=>u("option",{value:x.value,disabled:!x.available,children:[x.label,x.available?"":" (unavailable)"]},x.value))})]}),u("label",{className:"space-y-1",children:[r("span",{className:"text-xs font-medium text-foreground-subtle",children:"Backend"}),r("select",{value:t,onChange:x=>d(x.target.value),className:Ho,children:a.map(x=>u("option",{value:x.id,disabled:!x.available,children:[x.label,x.available?"":" (unavailable)"]},x.id))})]}),u("label",{className:"space-y-1",children:[r("span",{className:"text-xs font-medium text-foreground-subtle",children:"Model"}),r("select",{value:n,onChange:x=>f(x.target.value),className:Ho,children:i.length===0?r("option",{value:"",children:"No compatible models"}):i.map(x=>u("option",{value:x.id,children:[x.name,x.downloaded?" ✓":""]},x.id))})]})]})}function yC({className:e}){return u("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[r("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),r("circle",{cx:"12",cy:"12",r:"3"})]})}function vC({className:e}){return u("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[r("path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}),r("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),r("path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}),r("path",{d:"m2 2 20 20"})]})}function wC({className:e}){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:r("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}function zh({onLogin:e,serverUrl:t,logoSrc:n,error:o,className:s}){const[a,i]=$(""),[l,c]=$(""),[d,f]=$(!1),[p,m]=$(!1),[h,g]=$(null),b=o??h,x=async y=>{if(y.preventDefault(),!p){g(null),m(!0);try{await e(a,l)}catch(w){const v=w instanceof Error?w.message:"Login failed. Please try again.";g(v)}finally{m(!1)}}};return r("div",{className:W("flex min-h-screen items-center justify-center bg-background p-4",s),children:u("div",{className:"w-full max-w-sm",children:[n&&r("div",{className:"flex justify-center mb-8",children:r("img",{src:n,alt:"Logo",className:"h-12"})}),t&&r("p",{className:"mb-4 text-center text-xs text-foreground-subtle truncate",children:t}),u("form",{onSubmit:x,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[b&&r("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:b}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Username"}),r("input",{type:"text",value:a,onChange:y=>i(y.target.value),autoComplete:"username",required:!0,className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary"})]}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Password"}),u("div",{className:"relative",children:[r("input",{type:d?"text":"password",value:l,onChange:y=>c(y.target.value),autoComplete:"current-password",required:!0,className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary"}),r("button",{type:"button",onClick:()=>f(y=>!y),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",tabIndex:-1,children:d?r(vC,{className:"h-4 w-4"}):r(yC,{className:"h-4 w-4"})})]})]}),u("button",{type:"submit",disabled:p,className:"w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2",children:[p&&r(wC,{className:"h-4 w-4 animate-spin"}),p?"Logging in...":"Log in"]})]})]})})}const Qi="camstack_dev_token",Bh=Oe(null);function NC(){const e=ve(Bh);if(!e)throw new Error("useDevShell must be used within a DevShell");return e}function kC(){return typeof window>"u"?null:localStorage.getItem(Qi)}function SC({className:e}){return u("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[r("circle",{cx:"12",cy:"12",r:"4"}),r("path",{d:"M12 2v2"}),r("path",{d:"M12 20v2"}),r("path",{d:"m4.93 4.93 1.41 1.41"}),r("path",{d:"m17.66 17.66 1.41 1.41"}),r("path",{d:"M2 12h2"}),r("path",{d:"M20 12h2"}),r("path",{d:"m6.34 17.66-1.41 1.41"}),r("path",{d:"m19.07 4.93-1.41 1.41"})]})}function CC({className:e}){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:r("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function MC({children:e,serverUrl:t,title:n,token:o,onLogout:s}){const a=Ar(),i=U(()=>{const m=t.replace(/^http/,"ws")+"/trpc",h=nw({url:m,connectionParams:()=>({token:o})});return[rw({condition:g=>g.type==="subscription",true:ow({client:h,transformer:Li}),false:Vf({url:`${t}/trpc`,transformer:Li,headers:()=>({authorization:`Bearer ${o}`})})})]},[t,o]),l=U(()=>Hf({links:i}),[i]),c=U(()=>C.createClient({links:i}),[i]),d=U(()=>Uf({serverUrl:t,token:o}),[t,o]);Z(()=>(d.init().catch(()=>{}),()=>{d.close()}),[d]);const f=U(()=>new Bf,[]),p=U(()=>({trpc:l,token:o,logout:s}),[l,o,s]);return r(ec,{system:d,children:r(C.Provider,{client:c,queryClient:f,children:r(Ff,{client:f,children:r(Bh.Provider,{value:p,children:u("div",{className:"min-h-screen bg-background text-foreground",children:[u("div",{className:"flex items-center justify-between border-b border-border bg-surface px-4 py-2",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"rounded bg-warning/20 px-2 py-0.5 text-xs font-bold text-warning",children:"DEV MODE"}),n&&r("span",{className:"text-sm font-medium text-foreground",children:n}),r("span",{className:"text-xs text-foreground-subtle",children:t})]}),u("div",{className:"flex items-center gap-2",children:[u("button",{type:"button",onClick:a.toggleMode,className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",title:`Theme: ${a.mode}`,children:[a.resolvedMode==="dark"?r(SC,{className:"h-3.5 w-3.5"}):r(CC,{className:"h-3.5 w-3.5"}),a.mode==="dark"?"Dark":a.mode==="light"?"Light":"System"]}),r("button",{type:"button",onClick:s,className:"rounded-md px-2.5 py-1 text-xs font-medium text-danger hover:bg-danger/10 transition-colors",children:"Logout"})]})]}),r("div",{className:"p-4",children:e({trpc:l,theme:a})})]})})})})})}function Fh({children:e,serverUrl:t="https://localhost:4443",title:n}){const[o,s]=$(kC),a=q(async(l,c)=>{const p=await Hf({links:[Vf({url:`${t}/trpc`,transformer:Li})]}).auth.login.mutate({username:l,password:c});if(!p.token)throw new Error("No token returned");localStorage.setItem(Qi,p.token),s(p.token)},[t]),i=q(()=>{localStorage.removeItem(Qi),s(null)},[]);return o?r(Cs,{children:r(MC,{serverUrl:t,title:n,token:o,onLogout:i,children:e})}):r(Cs,{children:r(zh,{onLogin:a,serverUrl:t})})}function IC(e,t={}){const{serverUrl:n="https://localhost:4443",title:o,rootId:s="root"}=t,a=document.getElementById(s);if(!a){console.error(`[mountAddonPage] Element #${s} not found`);return}Of(a).render(Me(Fh,{serverUrl:n,title:o,children:({trpc:i,theme:l})=>Me(e,{trpc:i,theme:{isDark:l.resolvedMode==="dark"},navigate:c=>{console.log("[dev] navigate:",c)}})}))}const jh=un("camstack:custom-field-renderers",{});function Hh({renderers:e,children:t}){return r(jh.Provider,{value:e,children:t})}function Vh(e){return ve(jh)[e]??null}const ac=un("camstack:device-context",null);function qh({deviceId:e,device:t,children:n}){const o={deviceId:e,device:t??null};return r(ac.Provider,{value:o,children:n})}function pn(){return ve(ac)?.deviceId??null}function ic(){return ve(ac)?.device??null}const AC=C.accessories.getStatus.useQuery,lc=C.addonPages.listPages.useQuery,oa=C.addons.list.useQuery,PC=C.addons.getLogs.useQuery,EC=C.addons.listPackages.useQuery,cc=C.addons.installPackage.useMutation,$C=C.addons.installFromWorkspace.useMutation,_C=C.addons.isWorkspaceAvailable.useQuery,DC=C.addons.listWorkspacePackages.useQuery,Uh=C.addons.uninstallPackage.useMutation,Qh=C.addons.reloadPackages.useMutation,Kh=C.addons.searchAvailable.useQuery,dc=C.addons.listUpdates.useQuery,Ki=C.addons.updatePackage.useMutation,LC=C.addons.rollbackPackage.useMutation,Gh=C.addons.forceRefresh.useMutation,Wh=C.addons.restartServer.useMutation,Yh=C.addons.getVersions.useQuery,sa=C.addons.restartAddon.useMutation,Zh=C.addons.retryLoad.useMutation,Xh=C.addons.getAutoUpdateSettings.useQuery,TC=C.addons.setAutoUpdateSettings.useMutation,Jh=C.addons.getAddonAutoUpdate.useQuery,eg=C.addons.setAddonAutoUpdate.useMutation,tg=C.addons.applyAutoUpdateToAll.useMutation,RC=C.addons.custom.useMutation,OC=C.addons.onAddonLogs.useSubscription,uc=C.addonSettings.getGlobalSettings.useQuery,ng=C.addonSettings.updateGlobalSettings.useMutation,zC=C.addonSettings.getDeviceSettings.useQuery,rg=C.addonSettings.updateDeviceSettings.useMutation,og=C.addonWidgets.listWidgets.useQuery,BC=C.alerts.emit.useMutation,FC=C.alerts.update.useMutation,sg=C.alerts.list.useQuery,ag=C.alerts.getUnreadCount.useQuery,ig=C.alerts.markRead.useMutation,lg=C.alerts.markAllRead.useMutation,cg=C.alerts.dismiss.useMutation,jC=C.audioAnalysis.resolveDeviceSettings.useQuery,HC=C.audioAnalysis.getDeviceSettingsContribution.useQuery,VC=C.audioAnalysis.getDeviceLiveContribution.useQuery,qC=C.audioAnalysis.applyDeviceSettingsPatch.useMutation,UC=C.audioAnalyzer.analyseChunk.useMutation,QC=C.audioAnalyzer.classify.useQuery,KC=C.audioAnalyzer.isReady.useQuery,GC=C.audioAnalyzer.dispose.useMutation,dg=C.audioAnalyzer.reprobeAudioEngine.useMutation,WC=C.audioCodec.listSupportedCodecs.useQuery,YC=C.audioCodec.canHandle.useQuery,ZC=C.audioCodec.createDecodeSession.useMutation,XC=C.audioCodec.createEncodeSession.useMutation,JC=C.audioCodec.closeSession.useMutation,e3=C.audioCodec.pushEncodedFrame.useMutation,t3=C.audioCodec.pullPcm.useQuery,n3=C.audioCodec.pushPcm.useMutation,r3=C.audioCodec.pullEncoded.useQuery,o3=C.audioCodec.flushEncode.useMutation,s3=C.audioCodec.listActiveSessions.useQuery,a3=C.audioMetrics.getCurrentSnapshot.useQuery,i3=C.audioMetrics.getHistory.useQuery,pc=C.authentication.listProviders.useQuery,l3=C.authentication.setProviderEnabled.useMutation,fc=C.backup.listDestinations.useQuery,ug=C.backup.trigger.useMutation,c3=C.backup.list.useQuery,pg=C.backup.listLocations.useQuery,fg=C.backup.getEntries.useQuery,mg=C.backup.restore.useMutation,hg=C.backup.delete.useMutation,mc=C.backup.listArchives.useQuery,gg=C.backup.upsertDestinationPolicy.useMutation,bg=C.backup.previewSchedule.useQuery,d3=C.battery.getStatus.useQuery,u3=C.brightness.setBrightness.useMutation,p3=C.brightness.getStatus.useQuery,f3=C.cameraStreams.getCameraStreams.useQuery,m3=C.cameraStreams.getBrokerStreams.useQuery,h3=C.cameraStreams.getRtspEntries.useQuery,g3=C.decoder.supportsCodec.useQuery,b3=C.decoder.getInfo.useQuery,x3=C.decoder.createSession.useQuery,y3=C.decoder.destroySession.useQuery,v3=C.decoder.pushPacket.useQuery,w3=C.decoder.openStream.useQuery,N3=C.decoder.pullFrames.useQuery,k3=C.decoder.updateConfig.useQuery,S3=C.decoder.getStats.useQuery,C3=C.decoder.listActiveSessions.useQuery,xg=C.decoder.reprobeHwaccel.useMutation,M3=C.detectionPipeline.getDeviceSettingsContribution.useQuery,I3=C.detectionPipeline.getDeviceLiveContribution.useQuery,A3=C.detectionPipeline.applyDeviceSettingsPatch.useMutation,yg=C.deviceDiscovery.listDiscovered.useQuery,vg=C.deviceDiscovery.refreshDiscovery.useMutation,P3=C.deviceDiscovery.adoptDevice.useMutation,E3=C.deviceDiscovery.releaseDevice.useMutation,$3=C.deviceDiscovery.getStatus.useQuery,_3=C.deviceManager.allocateDeviceId.useMutation,D3=C.deviceManager.registerDevice.useMutation,L3=C.deviceManager.removeDevice.useMutation,T3=C.deviceManager.persistConfig.useMutation,R3=C.deviceManager.loadConfig.useQuery,O3=C.deviceManager.loadRuntimeState.useQuery,z3=C.deviceManager.loadMeta.useQuery,wg=C.deviceManager.setName.useMutation,Ng=C.deviceManager.setLocation.useMutation,B3=C.deviceManager.setMetadata.useMutation,kg=C.deviceManager.listLocations.useQuery,F3=C.deviceManager.addLocation.useMutation,j3=C.deviceManager.removeLocation.useMutation,H3=C.deviceManager.setDisabled.useMutation,V3=C.deviceManager.listPersistedByAddon.useQuery,tr=C.deviceManager.listAll.useQuery,Hn=C.deviceManager.getDevice.useQuery,Sg=C.deviceManager.getChildren.useQuery,q3=C.deviceManager.getStreamSources.useQuery,U3=C.deviceManager.getConfigSchema.useQuery,Q3=C.deviceManager.getSettingsSchema.useQuery,K3=C.deviceManager.updateConfig.useMutation,Cg=C.deviceManager.enable.useMutation,Mg=C.deviceManager.disable.useMutation,Ig=C.deviceManager.remove.useMutation,G3=C.deviceManager.getStreamProfileMap.useQuery,W3=C.deviceManager.setStreamProfileMap.useMutation,Y3=C.deviceManager.probeStreams.useMutation,Ag=C.deviceManager.getBindings.useQuery,Z3=C.deviceManager.getAllBindings.useQuery,Pg=C.deviceManager.setWrapperActive.useMutation,X3=C.deviceManager.listWrappersForCap.useQuery,Eg=C.deviceManager.listBindableCapsForDeviceType.useQuery,J3=C.deviceManager.getDeviceSettingsAggregate.useQuery,eM=C.deviceManager.getDeviceLiveInfoAggregate.useQuery,hc=C.deviceManager.getDeviceAggregate.useQuery,tM=C.deviceManager.updateDeviceField.useMutation,$g=C.deviceManager.updateDeviceFieldsBatch.useMutation,gc=C.deviceManager.discoverDevices.useMutation,_g=C.deviceManager.adoptDevice.useMutation,Dg=C.deviceManager.getCreationSchema.useQuery,Lg=C.deviceManager.createDevice.useMutation,bc=C.deviceManager.testCreationField.useMutation,nM=C.deviceManager.testField.useMutation,rM=C.deviceManager.getDeviceStatusAggregate.useQuery,oM=C.deviceOps.getStreamSources.useQuery,sM=C.deviceOps.getConfigEntries.useQuery,aM=C.deviceOps.setConfig.useMutation,iM=C.deviceOps.removeDevice.useMutation,lM=C.deviceOps.getSettingsSchema.useQuery,cM=C.deviceProvider.start.useMutation,dM=C.deviceProvider.stop.useMutation,uM=C.deviceProvider.getStatus.useQuery,pM=C.deviceProvider.getDevices.useQuery,fM=C.deviceProvider.supportsDiscovery.useQuery,mM=C.deviceProvider.discoverDevices.useMutation,hM=C.deviceProvider.adoptDiscoveredDevice.useMutation,gM=C.deviceProvider.supportsManualCreation.useQuery,bM=C.deviceProvider.getChildCreationSchema.useQuery,xM=C.deviceProvider.createDevice.useMutation,yM=C.deviceProvider.testCreationField.useMutation,vM=C.deviceState.getSnapshot.useQuery,wM=C.deviceState.getCapSlice.useQuery,NM=C.deviceState.getAllSnapshots.useQuery,kM=C.deviceState.setCapSlice.useMutation,SM=C.doorbell.getStatus.useQuery,CM=C.events.getEvents.useQuery,MM=C.events.getEventThumbnail.useQuery,IM=C.events.getEventClipUrl.useQuery,xc=C.integrations.list.useQuery,Tg=C.integrations.get.useQuery,Rg=C.integrations.getByAddonId.useQuery,Og=C.integrations.create.useMutation,zg=C.integrations.update.useMutation,Bg=C.integrations.delete.useMutation,AM=C.integrations.getSettings.useQuery,PM=C.integrations.setSettings.useMutation,Fg=C.integrations.getAvailableTypes.useQuery,jg=C.integrations.testConnection.useMutation,Hg=C.intercom.startSession.useMutation,Vg=C.intercom.handleAnswer.useMutation,qg=C.intercom.stopSession.useMutation,EM=C.intercom.getStatus.useQuery,Ug=C.localNetwork.list.useQuery,$M=C.localNetwork.getPreferred.useQuery,Qg=C.localNetwork.getConnectionEndpoints.useQuery,Kg=C.localNetwork.getAllowedAddresses.useQuery,Gg=C.localNetwork.setAllowedAddresses.useMutation,Wg=C.localNetwork.resetAllowlistToBestMatch.useMutation,Yg=C.meshOrchestrator.listProviders.useQuery,Zg=C.meshOrchestrator.joinProvider.useMutation,Xg=C.meshOrchestrator.leaveProvider.useMutation,_M=C.metricsProvider.collectSnapshot.useQuery,DM=C.metricsProvider.getCached.useQuery,LM=C.metricsProvider.getCurrent.useQuery,TM=C.metricsProvider.getDiskSpace.useQuery,RM=C.metricsProvider.getGpuInfo.useQuery,OM=C.metricsProvider.getCpuTemperature.useQuery,zM=C.metricsProvider.getProcessStats.useQuery,BM=C.metricsProvider.listAddonInstances.useQuery,FM=C.metricsProvider.getAddonStats.useQuery,Jg=C.metricsProvider.listNodeProcesses.useQuery,eb=C.metricsProvider.killProcess.useMutation,jM=C.motion.isDetected.useQuery,HM=C.motion.getStatus.useQuery,VM=C.motionDetection.analyze.useMutation,qM=C.motionDetection.removeCamera.useMutation,UM=C.motionDetection.reset.useMutation,QM=C.motionDetection.getDeviceSettingsContribution.useQuery,KM=C.motionDetection.getDeviceLiveContribution.useQuery,GM=C.motionDetection.applyDeviceSettingsPatch.useMutation,WM=C.motionTrigger.setMotionTrigger.useMutation,YM=C.motionTrigger.getStatus.useQuery,ZM=C.nativeObjectDetection.getStatus.useQuery,yc=C.networkQuality.getDeviceStats.useQuery,XM=C.networkQuality.getAllStats.useQuery,JM=C.networkQuality.reportClientStats.useMutation,An=C.nodes.topology.useQuery,e4=C.nodes.deployAddon.useMutation,tb=C.nodes.undeployAddon.useMutation,aa=C.nodes.restartAddon.useMutation,nb=C.nodes.restartProcess.useMutation,rb=C.nodes.restartNode.useMutation,t4=C.nodes.shutdownNode.useMutation,ob=C.nodes.renameNode.useMutation,sb=C.nodes.clusterAddonStatus.useQuery,ab=C.nodes.setProcessLogLevel.useMutation,n4=C.nodes.executeQuery.useMutation,r4=C.notificationOutput.send.useMutation,o4=C.notificationOutput.sendTest.useMutation,s4=C.osd.setOverlay.useMutation,a4=C.osd.getStatus.useQuery,i4=C.pipelineAnalytics.getActiveTracks.useQuery,l4=C.pipelineAnalytics.getTrack.useQuery,c4=C.pipelineAnalytics.listTracks.useQuery,d4=C.pipelineAnalytics.clearTracks.useMutation,u4=C.pipelineAnalytics.getMotionEvents.useQuery,p4=C.pipelineAnalytics.getObjectEvents.useQuery,f4=C.pipelineAnalytics.getAudioEvents.useQuery,m4=C.pipelineAnalytics.getEventMedia.useQuery,h4=C.pipelineAnalytics.getTrackMedia.useQuery,g4=C.pipelineAnalytics.getDeviceSettingsContribution.useQuery,b4=C.pipelineAnalytics.getDeviceLiveContribution.useQuery,x4=C.pipelineAnalytics.applyDeviceSettingsPatch.useMutation,ib=C.pipelineExecutor.getAvailableEngines.useQuery,lb=C.pipelineExecutor.getSelectedEngine.useQuery,y4=C.pipelineExecutor.getDefaultSteps.useQuery,cb=C.pipelineExecutor.reprobeEngine.useMutation,v4=C.pipelineExecutor.getVideoPipelineSteps.useQuery,w4=C.pipelineExecutor.setVideoPipelineSteps.useMutation,Io=C.pipelineExecutor.getSchema.useQuery,N4=C.pipelineExecutor.getGlobalSteps.useQuery,k4=C.pipelineExecutor.getGlobalPipelineConfig.useQuery,S4=C.pipelineExecutor.getOrchestratorConfigSchema.useQuery,C4=C.pipelineExecutor.listTemplates.useQuery,M4=C.pipelineExecutor.saveTemplate.useMutation,I4=C.pipelineExecutor.updateTemplate.useMutation,A4=C.pipelineExecutor.deleteTemplate.useMutation,P4=C.pipelineExecutor.getCapabilities.useQuery,E4=C.pipelineExecutor.getAddonModels.useQuery,db=C.pipelineExecutor.downloadModel.useMutation,ub=C.pipelineExecutor.deleteModel.useMutation,$4=C.pipelineExecutor.detect.useQuery,_4=C.pipelineExecutor.runPipeline.useMutation,D4=C.pipelineExecutor.runPipelineBatch.useMutation,L4=C.pipelineExecutor.cacheFrameInPool.useMutation,T4=C.pipelineExecutor.inferCached.useMutation,R4=C.pipelineExecutor.uncacheFrame.useMutation,O4=C.pipelineExecutor.getEffectiveTuning.useQuery,pb=C.pipelineExecutor.listLoadedEngines.useQuery,z4=C.pipelineExecutor.spinEngine.useMutation,fb=C.pipelineExecutor.killEngine.useMutation,B4=C.pipelineExecutor.listReferenceImages.useQuery,F4=C.pipelineExecutor.getReferenceImage.useQuery,j4=C.pipelineExecutor.getReferenceAudioFiles.useQuery,H4=C.pipelineExecutor.getReferenceAudio.useQuery,V4=C.pipelineExecutor.getAudioCapabilities.useQuery,q4=C.pipelineExecutor.runAudioTest.useMutation,U4=C.pipelineExecutor.getDetectionConfigSchema.useQuery,mb=C.pipelineOrchestrator.assignPipeline.useMutation,hb=C.pipelineOrchestrator.unassignPipeline.useMutation,gb=C.pipelineOrchestrator.rebalance.useMutation,ia=C.pipelineOrchestrator.getPipelineAssignments.useQuery,la=C.pipelineOrchestrator.getPipelineAssignment.useQuery,bb=C.pipelineOrchestrator.getAgentLoad.useQuery,Q4=C.pipelineOrchestrator.getGlobalMetrics.useQuery,K4=C.pipelineOrchestrator.getCameraMetrics.useQuery,xb=C.pipelineOrchestrator.getCapabilityBindings.useQuery,yb=C.pipelineOrchestrator.setCapabilityBinding.useMutation,vb=C.pipelineOrchestrator.assignDecoder.useMutation,wb=C.pipelineOrchestrator.unassignDecoder.useMutation,Nb=C.pipelineOrchestrator.getDecoderAssignments.useQuery,kb=C.pipelineOrchestrator.assignAudio.useMutation,Sb=C.pipelineOrchestrator.unassignAudio.useMutation,G4=C.pipelineOrchestrator.getAudioAssignment.useQuery,Cb=C.pipelineOrchestrator.getAudioNodeLoad.useQuery,Mb=C.pipelineOrchestrator.getAudioAssignments.useQuery,W4=C.pipelineOrchestrator.getDecoderAssignment.useQuery,vc=C.pipelineOrchestrator.getAgentSettings.useQuery,_r=C.pipelineOrchestrator.listAgentSettings.useQuery,wc=C.pipelineOrchestrator.setAgentAddonDefaults.useMutation,Ib=C.pipelineOrchestrator.removeAgentSettings.useMutation,Nc=C.pipelineOrchestrator.getCameraSettings.useQuery,Ab=C.pipelineOrchestrator.setCameraStepToggle.useMutation,Y4=C.pipelineOrchestrator.getCameraStepOverrides.useQuery,Pb=C.pipelineOrchestrator.setCameraStepOverride.useMutation,Eb=C.pipelineOrchestrator.setCameraPipelineForAgent.useMutation,$b=C.pipelineOrchestrator.resolvePipeline.useQuery,_b=C.pipelineOrchestrator.listTemplates.useQuery,Z4=C.pipelineOrchestrator.saveTemplate.useMutation,Db=C.pipelineOrchestrator.updateTemplate.useMutation,Lb=C.pipelineOrchestrator.deleteTemplate.useMutation,X4=C.pipelineOrchestrator.getDeviceSettingsContribution.useQuery,J4=C.pipelineOrchestrator.getDeviceLiveContribution.useQuery,eI=C.pipelineOrchestrator.applyDeviceSettingsPatch.useMutation,tI=C.pipelineRunner.attachCamera.useMutation,nI=C.pipelineRunner.detachCamera.useMutation,rI=C.pipelineRunner.reportMotion.useMutation,oI=C.pipelineRunner.getLocalLoad.useQuery,sI=C.pipelineRunner.getLocalMetrics.useQuery,kc=C.pipelineRunner.getCameraMetrics.useQuery,aI=C.pipelineRunner.getAllCameraMetrics.useQuery,Tb=C.pipelineRunner.getLocalCameras.useQuery,iI=C.platformProbe.getCapabilities.useQuery,lI=C.platformProbe.getHardware.useQuery,cI=C.platformProbe.resolveInferenceConfig.useQuery,dI=C.platformProbe.resolveHwAccel.useQuery,uI=C.ptz.move.useMutation,pI=C.ptz.continuousMove.useMutation,fI=C.ptz.stop.useMutation,mI=C.ptz.getPresets.useQuery,hI=C.ptz.goToPreset.useMutation,gI=C.ptz.goHome.useMutation,bI=C.ptz.getPosition.useQuery,xI=C.ptz.getStatus.useQuery,Rb=C.ptzAutotrack.getStatus.useQuery,Ob=C.ptzAutotrack.setEnabled.useMutation,yI=C.ptzAutotrack.getSettings.useQuery,zb=C.ptzAutotrack.setSettings.useMutation,Bb=C.reboot.reboot.useMutation,vI=C.recording.getSegments.useQuery,wI=C.recording.getPlaybackUrl.useQuery,NI=C.recording.getThumbnailAt.useQuery,kI=C.recordingEngine.getStatus.useQuery,Fb=C.recordingEngine.enable.useMutation,jb=C.recordingEngine.disable.useMutation,Hb=C.recordingEngine.getConfig.useQuery,SI=C.recordingEngine.updateConfig.useMutation,CI=C.recordingEngine.getPlaylist.useQuery,MI=C.recordingEngine.getThumbnail.useQuery,Vb=C.recordingEngine.getSegments.useQuery,II=C.recordingEngine.getAvailability.useQuery,AI=C.recordingEngine.estimateStorage.useQuery,PI=C.recordingEngine.estimateGlobalStorage.useQuery,qb=C.recordingEngine.getStorageUsage.useQuery,EI=C.recordingEngine.setPolicy.useMutation,$I=C.recordingEngine.getPolicy.useQuery,Ub=C.recordingEngine.getPolicyStatus.useQuery,Qb=C.recordingEngine.getRetentionConfig.useQuery,_I=C.recordingEngine.updateRetentionConfig.useMutation,DI=C.recordingEngine.getMotionStats.useQuery,Kb=C.remoteAccess.listProviders.useQuery,Gb=C.remoteAccess.startProvider.useMutation,Wb=C.remoteAccess.stopProvider.useMutation,LI=C.settingsStore.get.useQuery,TI=C.settingsStore.set.useMutation,RI=C.settingsStore.query.useQuery,OI=C.settingsStore.insert.useMutation,zI=C.settingsStore.update.useMutation,BI=C.settingsStore.delete.useMutation,FI=C.settingsStore.count.useQuery,jI=C.settingsStore.isEmpty.useQuery,HI=C.settingsStore.declareCollection.useMutation,VI=C.snapshot.getSnapshot.useQuery,qI=C.snapshot.invalidateCache.useMutation,UI=C.snapshot.getStatus.useQuery,QI=C.snapshot.getDeviceSettingsContribution.useQuery,KI=C.snapshot.getDeviceLiveContribution.useQuery,GI=C.snapshot.applyDeviceSettingsPatch.useMutation,WI=C.snapshotProvider.supportsDevice.useQuery,YI=C.snapshotProvider.getSnapshot.useQuery,ZI=C.storage.resolve.useQuery,XI=C.storage.write.useMutation,JI=C.storage.read.useQuery,eA=C.storage.exists.useQuery,tA=C.storage.list.useQuery,nA=C.storage.delete.useMutation,rA=C.storage.getAvailableSpace.useQuery,oA=C.storage.beginUpload.useMutation,sA=C.storage.writeChunk.useMutation,aA=C.storage.finalizeUpload.useMutation,iA=C.storage.abortUpload.useMutation,lA=C.storage.beginDownload.useMutation,cA=C.storage.readChunk.useQuery,dA=C.storage.endDownload.useMutation,Yb=C.storage.listLocations.useQuery,uA=C.storage.getDefaultLocation.useQuery,ca=C.storage.upsertLocation.useMutation,Zb=C.storage.deleteLocation.useMutation,pA=C.storage.testLocation.useQuery,Sc=C.storage.listProviders.useQuery,fA=C.storage.testConfig.useQuery,mA=C.streamBroker.publishCameraStream.useMutation,hA=C.streamBroker.retractCameraStream.useMutation,gA=C.streamBroker.assignProfile.useMutation,bA=C.streamBroker.unassignProfile.useMutation,xA=C.streamBroker.listAllCameraStreams.useQuery,yA=C.streamBroker.listAllProfileSlots.useQuery,vA=C.streamBroker.getBrokerStats.useQuery,wA=C.streamBroker.listClients.useQuery,NA=C.streamBroker.killClient.useMutation,kA=C.streamBroker.restartProfile.useMutation,SA=C.streamBroker.getStreamUrl.useQuery,CA=C.streamBroker.getBroker.useQuery,MA=C.streamBroker.setPreBufferDuration.useMutation,IA=C.streamBroker.getPreBufferInfo.useQuery,AA=C.streamBroker.getRtspPort.useQuery,PA=C.streamBroker.getAllRtspEntries.useQuery,EA=C.streamBroker.getRtspEntry.useQuery,Xb=C.streamBroker.regenerateRtspToken.useMutation,$A=C.streamBroker.setRtspEnabled.useMutation,_A=C.streamBroker.isRtspEnabled.useQuery,DA=C.streamBroker.getDeviceSettingsContribution.useQuery,LA=C.streamBroker.getDeviceLiveContribution.useQuery,TA=C.streamBroker.applyDeviceSettingsPatch.useMutation,RA=C.switch.setState.useMutation,OA=C.switch.getStatus.useQuery,zA=C.system.info.useQuery,BA=C.system.health.useQuery,FA=C.system.featureFlags.useQuery,jA=C.system.networkAddresses.useQuery,HA=C.system.getRetentionConfig.useQuery,VA=C.system.setRetentionConfig.useMutation,qA=C.system.forceRetentionCleanup.useMutation,Jb=C.toast.onToast.useSubscription,ex=C.turnOrchestrator.listProviders.useQuery,tx=C.turnOrchestrator.getAllServers.useQuery,nx=C.turnOrchestrator.setProviderEnabled.useMutation,UA=C.turnProvider.getTurnServers.useQuery,Cc=C.userManagement.listUsers.useQuery,rx=C.userManagement.createUser.useMutation,ox=C.userManagement.updateUser.useMutation,sx=C.userManagement.deleteUser.useMutation,Mc=C.userManagement.resetPassword.useMutation,ax=C.userManagement.setUserScopes.useMutation,QA=C.userManagement.validateCredentials.useMutation,ix=C.userManagement.listApiKeys.useQuery,KA=C.userManagement.createApiKey.useMutation,lx=C.userManagement.revokeApiKey.useMutation,GA=C.userManagement.validateApiKey.useMutation,cx=C.userManagement.createScopedToken.useMutation,dx=C.userManagement.revokeScopedToken.useMutation,WA=C.userManagement.validateScopedToken.useQuery,ux=C.userManagement.listScopedTokens.useQuery,YA=C.webrtcSession.listStreams.useQuery,ZA=C.webrtcSession.createSession.useMutation,XA=C.webrtcSession.handleAnswer.useMutation,JA=C.webrtcSession.closeSession.useMutation,eP=C.webrtcSession.hasAdaptiveBitrate.useQuery,tP=C.zoneAnalytics.getCurrentSnapshot.useQuery,nP=C.zoneAnalytics.getZoneHistory.useQuery,rP=C.zoneAnalytics.getCameraHistory.useQuery,oP=C.zoneAnalytics.getUnzonedHistory.useQuery,sP=C.zoneRules.listRules.useQuery,aP=C.zoneRules.setRules.useMutation,iP=C.zones.listZones.useQuery,lP=C.zones.addZone.useMutation,cP=C.zones.removeZone.useMutation,dP=C.zones.updateZone.useMutation,px=un("camstack:widget-registry",null),Es=new Map,Vo=new Map,mu=new Set;function uP(e){if(!e||typeof e!="object")return!1;const t=e.default;return t!==null&&typeof t=="object"}function pP(e){if(!e||typeof e!="object")return typeof e;const t=e,n=Object.getPrototypeOf(t),o=n&&typeof n=="object"?n.constructor?.name:void 0;return{ownKeys:Object.keys(t),allKeys:Object.getOwnPropertyNames(t),proto:typeof o=="string"?o:void 0}}async function fP(e,t){const n=Es.get(e);if(n)return n;const o=Vo.get(e);if(o)return o;mu.has(e)||(Tl(),hr.registerRemotes([{name:e,entry:t,type:"module"}],{force:!1}),mu.add(e));const s=hr.loadRemote(`${e}/widgets`).then(a=>{if(!uP(a)){const l=pP(a);throw new Error(`Widget remote ${e} (${t}) does not expose a default record on './widgets'. Got: ${JSON.stringify(l)}`)}const i=a.default;return Es.set(e,i),Vo.delete(e),i}).catch(a=>{throw Vo.delete(e),a});return Vo.set(e,s),s}const mP=3e4,hP=2e3;function fx({children:e}){const t=ke(),n=ne(Date.now()),{data:o}=og(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:l=>{const c=l.state.data;return c&&c.length>0||Date.now()-n.current>=mP?!1:hP}});ct("addon.widget-ready",()=>{t.invalidateQueries({queryKey:[["addonWidgets","listWidgets"]]})});const[s,a]=$(0);Z(()=>{if(!o)return;let l=!1;const c=new Set;for(const d of o){if(c.has(d.remoteName)||(c.add(d.remoteName),Es.has(d.remoteName)))continue;const f=d.bundleUrl;fP(d.remoteName,f).then(()=>{l||a(p=>p+1)}).catch(p=>{const m=p instanceof Error?p.message:String(p);(typeof globalThis<"u"?globalThis.console:void 0)?.error?.("[WidgetRegistry] Failed to load widget remote",{remoteName:d.remoteName,entryUrl:f,reason:m})})}return()=>{l=!0}},[o]);const i=U(()=>{const l=o??[],c=new Map;for(const f of l)c.set(`${f.addonId}/${f.stableId}`,f);const d=(f,p)=>({widgetId:f,addonId:p.addonId,stableId:p.stableId,label:p.label,description:p.description,icon:p.icon,remoteName:p.remoteName,bundleUrl:p.bundleUrl,hosts:p.hosts,requires:p.requires,defaultSize:p.defaultSize,allowedSizes:p.allowedSizes,defaultColumns:p.defaultColumns,defaultRows:p.defaultRows});return{resolve:f=>{const p=c.get(f);if(!p)return;const m=Es.get(p.remoteName);if(!m)return null;const h=m[p.stableId];if(h)return h},metadata:f=>{const p=c.get(f);if(p)return d(f,p)},listAll:()=>{const f=[];for(const[p,m]of c)f.push(d(p,m));return f}}},[o,s]);return r(px.Provider,{value:i,children:e})}function mx(e){return da().resolve(e)}function hx(e){return da().metadata(e)}function gx(){return da().listAll()}function da(){const e=bx();if(!e)throw new Error("useWidgetRegistry(): no <WidgetRegistryProvider> in tree");return e}function bx(){return gP(px)}function gP(e){return ve(e)}function at(e){const{widgetId:t,host:n="device-tab",config:o,deviceId:s,integrationId:a,instanceId:i,size:l,columns:c,rows:d}=e,f=mx(t),p=hx(t),m=U(()=>i??t,[i,t]);if(f===void 0&&p===void 0)return r(qo,{widgetId:t,reason:"unknown"});if(f===void 0)return r(qo,{widgetId:t,reason:"missing-export"});if(f===null)return r(bP,{});if(p){if(p.requires.deviceContext&&s===void 0)return r(qo,{widgetId:t,reason:"missing-device-context"});if(p.requires.integrationContext&&a===void 0)return r(qo,{widgetId:t,reason:"missing-integration-context"})}return r(f,{instanceId:m,host:n,config:o,deviceId:s,integrationId:a,size:l,columns:c,rows:d})}function bP(){return u("div",{className:"rounded-lg border border-border bg-surface/40 p-4 animate-pulse",children:[r("div",{className:"h-3 w-24 bg-foreground-subtle/20 rounded mb-2"}),r("div",{className:"h-2 w-full bg-foreground-subtle/10 rounded mb-1"}),r("div",{className:"h-2 w-3/4 bg-foreground-subtle/10 rounded"})]})}function qo({widgetId:e,reason:t}){const n=t==="unknown"?`Widget "${e}" not registered`:t==="missing-export"?`Widget "${e}" bundle does not export this stableId`:t==="missing-device-context"?`Widget "${e}" requires a deviceId`:`Widget "${e}" requires an integrationId`;return r("div",{className:"rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",children:n})}const nr="w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none disabled:opacity-50 disabled:cursor-not-allowed",ua="block text-[11px] font-medium text-foreground mb-1",xP="text-[10px] text-foreground-subtle mt-0.5";function qe({label:e,description:t,required:n,span:o,children:s,translationFn:a}){const i=o===2?"col-span-2":o===3?"col-span-3":o===4?"col-span-4":"col-span-1",l=Tt(e,a),c=Tt(t,a);return u("div",{className:i,children:[l!==void 0&&l!==""&&u("label",{className:ua,children:[l,n&&r("span",{className:"text-danger ml-0.5",children:"*"})]}),s,c&&r("p",{className:xP,children:c})]})}function yP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:r("input",{type:e.inputType??"text",className:nr,value:t==null?"":String(t),placeholder:e.placeholder,maxLength:e.maxLength,pattern:e.pattern,disabled:o||e.disabled,onChange:a=>n(a.target.value)})})}function vP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const[a,i]=$(t==null?"":String(t)),l=ne(!1);Z(()=>{if(l.current)return;const d=t==null?"":String(t);i(d)},[t]);const c=d=>{if(i(d),d===""||d==="-"){n(void 0);return}const f=Number(d);Number.isNaN(f)||n(f)};return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"flex items-center gap-1",children:[r("input",{type:"number",className:nr,value:a,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step,disabled:o||e.disabled,onFocus:()=>{l.current=!0},onBlur:()=>{l.current=!1},onChange:d=>c(d.target.value)}),e.unit&&r("span",{className:"text-xs text-foreground-subtle whitespace-nowrap",children:e.unit})]})})}function wP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=!!t,i=o||e.disabled;return e.style==="checkbox"?r(qe,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[r("input",{type:"checkbox",className:"h-3.5 w-3.5 rounded border-border accent-primary",checked:a,disabled:i,onChange:l=>n(l.target.checked)}),r("span",{className:"text-xs font-medium text-foreground",children:Tt(e.label,s)}),e.required&&r("span",{className:"text-danger",children:"*"})]})}):r(qe,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"flex items-center justify-between",children:[u("span",{className:ua+" mb-0",children:[Tt(e.label,s),e.required&&r("span",{className:"text-danger ml-0.5",children:"*"})]}),r("button",{type:"button",role:"switch","aria-checked":a,disabled:i,onClick:()=>!i&&n(!a),className:["relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150",a?"bg-primary":"bg-foreground-subtle/30",i?"opacity-50 cursor-not-allowed":"cursor-pointer"].join(" "),children:r("span",{className:["inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150",a?"translate-x-4":"translate-x-0.5"].join(" ")})})]})})}function NP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=e.options.some(i=>i.value==="");return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("select",{className:nr,value:t==null?"":String(t),disabled:o||e.disabled,onChange:i=>n(i.target.value),children:[!e.required&&!a&&r("option",{value:"",children:"— Select —"}),e.options.map(i=>r("option",{value:i.value,children:i.label},i.value))]})})}function kP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=Array.isArray(t)?t:[],i=l=>{if(a.includes(l))n(a.filter(c=>c!==l));else{if(e.maxItems!==void 0&&a.length>=e.maxItems)return;n([...a,l])}};return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:r("div",{className:"flex flex-wrap gap-2",children:e.options.map(l=>{const c=a.includes(l.value);return u("label",{className:["flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs cursor-pointer select-none transition-colors",c?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground hover:bg-surface",o||e.disabled?"opacity-50 cursor-not-allowed":""].join(" "),children:[r("input",{type:"checkbox",className:"sr-only",checked:c,disabled:o||e.disabled,onChange:()=>i(l.value)}),l.label]},l.value)})})})}function SP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const[a,i]=$(!1),l=e.showToggle!==!1;return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"relative",children:[r("input",{type:a?"text":"password",className:nr+(l?" pr-9":""),value:t==null?"":String(t),placeholder:e.placeholder,disabled:o||e.disabled,onChange:c=>n(c.target.value)}),l&&r("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",tabIndex:-1,onClick:()=>i(c=>!c),children:a?r(Im,{className:"h-3.5 w-3.5"}):r(So,{className:"h-3.5 w-3.5"})})]})})}function CP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:r("textarea",{className:nr+" resize-y min-h-[60px]",value:t==null?"":String(t),placeholder:e.placeholder,rows:e.rows??3,maxLength:e.maxLength,disabled:o||e.disabled,onChange:a=>n(a.target.value)})})}function MP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=t==null,i=e.nullable===!0,l=a?e.default??e.min:Number(t),c=e.showValue!==!1,d=e.nullLabel??"Auto",f=o||e.disabled,p=e.displayScale??1,m=e.min/p,h=e.max/p,g=l/p,b=(e.step??1)/p;if(i&&a)return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("button",{className:"w-full rounded-lg border border-dashed border-border px-3 py-2 text-xs text-foreground-subtle hover:border-primary/40 hover:text-primary transition-colors text-left",disabled:f,onClick:()=>n(e.default??e.min),children:[d," — click to set manually"]})});const x=e.showStepper===!0&&c,y=v=>{const N=l+v*(e.step??1),k=Math.min(e.max,Math.max(e.min,N));k!==l&&n(k)},w="flex h-6 w-6 shrink-0 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:cursor-not-allowed disabled:opacity-40";return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[u("div",{className:"flex min-w-0 flex-1 basis-[160px] items-center gap-2",children:[r("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:m}),r("input",{type:"range",className:"min-w-0 flex-1 h-1 accent-primary cursor-pointer disabled:opacity-50",min:m,max:h,step:b,value:g,disabled:f,onChange:v=>n(Number(v.target.value)*p)}),r("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:h})]}),(c||i||e.unit)&&u("div",{className:"flex shrink-0 items-center gap-2",children:[x&&r("button",{type:"button",className:w,disabled:f||l<=e.min,onClick:()=>y(-1),title:`Decrease by ${e.step??1}`,"aria-label":"Decrement",children:r(_m,{className:"h-3 w-3"})}),c&&r("input",{type:"number",className:"w-16 rounded border border-border bg-surface px-1.5 py-0.5 text-xs text-center text-foreground tabular-nums focus:outline-none focus:ring-1 focus:ring-primary",min:m,max:h,step:b,value:g,disabled:f,onChange:v=>{if(v.target.value===""){n(i?null:e.min);return}const N=Number(v.target.value)*p,k=e.step??1,S=N-e.min,M=e.min+Math.round(S/k)*k;n(Math.min(e.max,Math.max(e.min,M)))}}),x&&r("button",{type:"button",className:w,disabled:f||l>=e.max,onClick:()=>y(1),title:`Increase by ${e.step??1}`,"aria-label":"Increment",children:r(Co,{className:"h-3 w-3"})}),e.unit&&r("span",{className:"text-[10px] text-foreground-subtle",children:e.unit}),i&&r("button",{className:"text-[10px] text-foreground-subtle hover:text-primary transition-colors",title:`Reset to ${d}`,disabled:f,onClick:()=>n(null),children:d})]})]})})}function IP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=Array.isArray(t)?t:[],[i,l]=$(""),c=ne(null),d=q(h=>{const g=h.trim();!g||a.includes(g)||e.maxTags!==void 0&&a.length>=e.maxTags||(n([...a,g]),l(""))},[a,e.maxTags,n]),f=h=>n(a.filter(g=>g!==h)),p=h=>{h.key==="Enter"||h.key===","?(h.preventDefault(),d(i)):h.key==="Backspace"&&i===""&&a.length>0&&f(a[a.length-1])},m=o||e.disabled;return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:["flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px] cursor-text","focus-within:border-primary focus-within:ring-1 focus-within:ring-primary/30",m?"opacity-50 cursor-not-allowed":""].join(" "),onClick:()=>!m&&c.current?.focus(),children:[a.map(h=>u("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[h,!m&&r("button",{type:"button",onClick:()=>f(h),className:"hover:text-danger",children:r(Ye,{className:"h-2.5 w-2.5"})})]},h)),r("input",{ref:c,type:"text",className:"flex-1 min-w-[80px] bg-transparent text-sm text-foreground outline-none placeholder:text-foreground-disabled",value:i,placeholder:a.length===0?e.placeholder??"Add tags…":"",disabled:m,list:`tags-suggestions-${e.key}`,onChange:h=>l(h.target.value),onKeyDown:p,onBlur:()=>{i.trim()&&d(i)}}),e.suggestions&&r("datalist",{id:`tags-suggestions-${e.key}`,children:e.suggestions.map(h=>r("option",{value:h},h))})]})})}function xx({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const{nodes:a}=Er(),i=typeof t=="string"?t:"",l=e.showOffline?a:a.filter(c=>c.isOnline);return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("select",{className:"w-full px-3 py-2 text-sm bg-background border border-border rounded-lg text-foreground focus:outline-none focus:border-primary/50 disabled:opacity-50",value:i,onChange:c=>n(c.target.value),disabled:o,children:[r("option",{value:"",children:"Select node…"}),l.map(c=>u("option",{value:c.id,disabled:!c.isOnline,children:[c.shortName,c.isOnline?"":" (offline)"]},c.id))]})})}function yx({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const{nodes:a}=Er(),i=new Set(Array.isArray(t)?t.map(String):[]),l=e.showOffline?a:a.filter(d=>d.isOnline),c=d=>{const f=new Set(i);f.has(d)?f.delete(d):f.add(d),n([...f])};return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:r("div",{className:"flex flex-wrap gap-1.5",children:l.map(d=>{const f=i.has(d.id);return r("button",{type:"button",onClick:()=>c(d.id),disabled:o||!d.isOnline,className:`px-2.5 py-1 text-xs font-medium rounded-md border transition-colors ${f?"border-primary bg-primary/10 text-primary":"border-border bg-surface text-foreground-subtle hover:bg-surface-hover"} ${d.isOnline?"":"opacity-50 cursor-not-allowed"}`,children:d.shortName},d.id)})})})}function AP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=t==null?"#000000":String(t);return u(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:[u("div",{className:"flex items-center gap-2",children:[r("input",{type:"color",className:"h-9 w-9 rounded-md border border-border bg-background cursor-pointer p-0.5 disabled:opacity-50",value:a,disabled:o||e.disabled,onChange:i=>n(i.target.value)}),r("input",{type:"text",className:nr+" flex-1 font-mono",value:a,placeholder:"#000000",disabled:o||e.disabled,onChange:i=>n(i.target.value)})]}),e.presets&&e.presets.length>0&&r("div",{className:"flex gap-1.5 mt-1.5",children:e.presets.map(i=>r("button",{type:"button",className:"h-5 w-5 rounded-md border border-border hover:scale-110 transition-transform disabled:opacity-50",style:{backgroundColor:i},disabled:o||e.disabled,title:i,onClick:()=>n(i)},i))})]})}function PP({field:e,value:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:i,externalProbe:l}){const[c,d]=$("idle"),[f,p]=$(null),m=l?.status??c,h=l?.result??f,g=!!a||!!i,b=q(async()=>{if(g){d("probing"),p(null);try{const w=a?await a(e.key,t):await i("test-probe",e.key,t),v=w&&typeof w=="object"?w:{status:"error",error:"Probe handler returned no result"};p(v),d(v.status==="ok"?"ok":"error")}catch(w){p({status:"error",error:w instanceof Error?w.message:String(w)}),d("error")}}},[a,i,e.key,t,g]),x=m==="probing"?"border-primary/40 bg-primary/10 text-primary":m==="ok"?"border-success/40 bg-success/10 text-success hover:bg-success/15":m==="error"?"border-danger/40 bg-danger/10 text-danger hover:bg-danger/15":"border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover",y=m==="probing"?r(Lt,{className:"h-3 w-3 animate-spin"}):m==="ok"?r(g2,{className:"h-3 w-3"}):m==="error"?r(ea,{className:"h-3 w-3"}):r(zm,{className:"h-3 w-3"});return u(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:[u("div",{className:"@container flex items-center gap-2",style:{containerType:"inline-size"},children:[u("button",{type:"button",onClick:b,title:"Test",disabled:e.disabled||m==="probing"||!g||!t,className:`flex-shrink-0 inline-flex items-center gap-1.5 rounded-md border px-2 py-2 text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed @[280px]:px-3 ${x}`,children:[y,r("span",{className:"hidden @[280px]:inline",children:"Test"})]}),r("input",{type:e.inputType??"url",className:nr+" flex-1 min-w-0",value:t==null?"":String(t),placeholder:e.placeholder,disabled:o||e.disabled,onChange:w=>{n(w.target.value),c!=="idle"&&(d("idle"),p(null))}})]}),m==="ok"&&h?.labels&&h.labels.length>0&&r("div",{className:"flex flex-wrap gap-1 mt-1.5",children:h.labels.map((w,v)=>r("span",{className:"text-xs bg-success/10 text-success rounded px-2 py-0.5 font-mono",children:w},v))}),m==="error"&&h?.error&&r("p",{className:"text-xs text-danger mt-1 truncate",title:h.error,children:h.error})]})}function EP({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a}){const[i,l]=$(e.defaultCollapsed??!1),c=e.style==="accordion",d=e.span===2?"col-span-2":e.span===3?"col-span-3":e.span===4?"col-span-4":"col-span-1";return r("div",{className:d,children:u("div",{className:"rounded-lg border border-border bg-surface/50 overflow-hidden",children:[u("div",{className:["px-3 py-2 flex items-center justify-between",c?"cursor-pointer hover:bg-surface":""].join(" "),onClick:c?()=>l(f=>!f):void 0,children:[r("span",{className:"text-xs font-semibold text-foreground",children:Tt(e.label,s)}),c&&r("span",{className:"text-foreground-subtle text-xs",children:i?"▸":"▾"})]}),!i&&r("div",{className:"px-3 pb-3 grid grid-cols-2 gap-x-4 gap-y-3",children:e.fields.map(f=>r(rr,{field:f,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a},f.key))})]})})}function $P({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:i}){const l=e.tabs[0]?.id??"",[c,d]=$(l),f=e.span===2?"col-span-2":e.span===3?"col-span-3":e.span===4?"col-span-4":"col-span-1";return e.tabs.length===0?null:u("div",{className:f,children:[e.label&&r("div",{className:ua,children:Tt(e.label,s)}),u("div",{className:"rounded-lg border border-border-subtle bg-surface-hover/40 overflow-hidden",children:[r("div",{className:"flex flex-wrap gap-1 p-1.5 border-b border-border-subtle bg-surface/40",role:"tablist",children:e.tabs.map(p=>{const m=p.id===c;return u("button",{type:"button",role:"tab","aria-selected":m,onClick:()=>d(p.id),className:`inline-flex items-center gap-1.5 whitespace-nowrap rounded-md px-2.5 py-1 text-[11px] transition-colors ${m?"bg-primary text-primary-foreground font-medium shadow-sm":"bg-transparent text-foreground-subtle hover:bg-surface hover:text-foreground"}`,children:[r("span",{children:Tt(p.label,s)}),p.badge&&r("span",{className:`text-[9px] px-1 py-0.5 rounded-full font-medium ${m?"bg-primary-foreground/20 text-primary-foreground":"bg-primary/10 text-primary"}`,children:p.badge})]},p.id)})}),e.tabs.map(p=>p.id!==c?null:r("div",{role:"tabpanel",className:"px-3 pb-3 pt-2 grid grid-cols-2 gap-x-4 gap-y-3",children:p.fields.map((m,h)=>{const g="key"in m&&typeof m.key=="string"?m.key:`__${p.id}__${h}`;return r(rr,{field:m,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:i},g)})},p.id))]})]})}function _P({span:e}){return r("div",{className:e===2?"col-span-2":e===3?"col-span-3":e===4?"col-span-4":"col-span-full",children:r("hr",{className:"border-border"})})}const hu={info:{border:"border-info",bg:"bg-info/5",text:"text-info"},warning:{border:"border-warning",bg:"bg-warning/5",text:"text-warning"},success:{border:"border-success",bg:"bg-success/5",text:"text-success"},danger:{border:"border-danger",bg:"bg-danger/5",text:"text-danger"}};function DP(e){if(typeof window>"u"||typeof DOMParser>"u")return"";const t=new Set(["A","UL","OL","LI","STRONG","EM","CODE","BR","P","SPAN"]),n=new DOMParser().parseFromString(`<div>${e}</div>`,"text/html"),o=n.body.firstElementChild;if(!o)return"";const s=a=>{const i=Array.from(a.children);for(const l of i){if(!t.has(l.tagName)){const d=n.createTextNode(l.textContent??"");l.replaceWith(d);continue}const c=l.tagName==="A"?new Set(["href"]):new Set;for(const d of Array.from(l.attributes))c.has(d.name)||l.removeAttribute(d.name);if(l.tagName==="A"){const d=l.getAttribute("href")??"";!/^https?:\/\//i.test(d)&&!d.startsWith("mailto:")?l.removeAttribute("href"):(l.setAttribute("target","_blank"),l.setAttribute("rel","noopener noreferrer"))}s(l)}};return s(o),o.innerHTML}function LP({field:e}){const t=e.variant??"info",n=hu[t]??hu.info,o=e.format==="html";return r("div",{className:"col-span-full",children:u("div",{className:`rounded-md border-l-4 px-3 py-2.5 ${n.border} ${n.bg}`,children:[e.label&&r("p",{className:`text-xs font-semibold mb-0.5 ${n.text}`,children:e.label}),o?r("div",{className:"text-xs text-foreground-subtle leading-relaxed info-html-content",dangerouslySetInnerHTML:{__html:DP(e.content)}}):r("p",{className:"text-xs text-foreground-subtle leading-relaxed whitespace-pre-line",children:e.content})]})})}const gu={ok:"bg-success",warn:"bg-amber-500",danger:"bg-danger",idle:"bg-foreground-subtle/40",unknown:"bg-foreground-subtle/40"};function TP(e){if(!Number.isFinite(e)||e<0)return"—";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),o=t%60;return o===0?`${n}m`:`${n}m ${o}s`}function RP(e){return!Number.isFinite(e)||e<=0?"—":new Date(e).toLocaleTimeString()}function OP({kind:e,value:t}){if(t==null||t==="")return r("span",{className:"text-foreground-subtle/60",children:"—"});if(e==="monospace")return r("span",{className:"font-mono text-[11px]",children:String(t)});if(e==="status"){const n=String(t).toLowerCase(),o=gu[n]??gu.unknown;return u("span",{className:"inline-flex items-center gap-1.5",children:[r("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${o}`}),r("span",{children:String(t)})]})}return e==="duration"&&typeof t=="number"?r("span",{className:"font-mono text-[11px]",children:TP(t)}):e==="timestamp"&&typeof t=="number"?r("span",{className:"font-mono text-[11px]",children:RP(t)}):r("span",{children:String(t)})}function zP({field:e}){const t=e.value??[],n=e.description;return u("div",{className:"col-span-full",children:[e.label&&r("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1",children:e.label}),n&&r("p",{className:"text-xs text-foreground-subtle mb-2",children:n}),t.length===0?r("div",{className:"rounded-md border border-border bg-surface-subtle px-3 py-2 text-xs text-foreground-subtle",children:e.emptyMessage??"No entries"}):r("div",{className:"rounded-md border border-border overflow-hidden",children:u("table",{className:"w-full text-xs",children:[r("thead",{className:"bg-surface-subtle border-b border-border",children:r("tr",{children:e.columns.map(o=>r("th",{className:"px-3 py-1.5 text-left font-medium text-foreground-subtle",style:o.width?{width:o.width}:void 0,children:o.label},o.key))})}),r("tbody",{className:"divide-y divide-border",children:t.map((o,s)=>r("tr",{className:"hover:bg-surface-hover/40",children:e.columns.map(a=>r("td",{className:"px-3 py-1.5 align-top text-foreground",children:r(OP,{kind:a.kind,value:o[a.key]})},a.key))},s))})]})})]})}function BP({field:e,value:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:i}){const l=Array.isArray(t)?t:[],c=e.minRows??0,d=e.maxRows??Number.POSITIVE_INFINITY,f=(x,y,w)=>{const v=l.slice(),N=v[x]??{};v[x]={...N,[y]:w},n(v)},p=x=>{l.length<=c||n(l.filter((y,w)=>w!==x))},m=()=>{if(l.length>=d)return;const x=e.defaultItem??{};n([...l,{...x}])},h=(x,y)=>e.rowTitleTemplate?e.rowTitleTemplate.replace(/\{(\w+)\}/g,(w,v)=>{const N=x[v];return N==null||N===""?"—":String(N)}):`Row ${y+1}`,g=l.length>c,b=l.length<d;return u("div",{className:"col-span-full space-y-2",children:[u("div",{className:"space-y-0.5",children:[e.label&&r("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:Tt(e.label,s)}),e.description&&r("p",{className:"text-[11px] text-foreground-subtle",children:Tt(e.description,s)})]}),l.length===0?r("div",{className:"rounded-md border border-dashed border-border bg-background px-3 py-3 text-center text-[11px] text-foreground-subtle",children:e.emptyMessage??"No entries"}):r("div",{className:"space-y-2",children:l.map((x,y)=>u("div",{className:"rounded-md border border-border bg-background",children:[u("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[r("span",{className:"text-xs font-medium text-foreground",children:h(x,y)}),u("button",{type:"button",onClick:()=>p(y),disabled:o||!g,className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-30 disabled:cursor-not-allowed",title:g?"Remove this row":`At least ${c} row(s) required`,children:[r(_m,{className:"h-3 w-3"}),"Remove"]})]}),r("div",{className:"grid grid-cols-1 @[420px]:grid-cols-2 gap-x-3 gap-y-2 p-3",children:e.itemFields.map(w=>r(rr,{field:w,values:x,onChange:(v,N)=>f(y,v,N),disabled:o,translationFn:s,onTestField:a,allFields:e.itemFields,onAction:i},w.key))})]},y))}),u("div",{children:[u("button",{type:"button",onClick:m,disabled:o||!b,className:"inline-flex items-center gap-1 rounded border border-border bg-surface px-3 py-1 text-[11px] font-medium text-foreground hover:border-primary/40 hover:bg-primary/5 disabled:opacity-30 disabled:cursor-not-allowed",children:[r(Co,{className:"h-3 w-3"}),e.addLabel??"Add"]}),!b&&Number.isFinite(d)&&u("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["(limit: ",d,")"]})]})]})}function FP({field:e,disabled:t,onAction:n}){const[o,s]=$(!1),a=nt(),i=async()=>{if(!(e.confirmMessage&&!await a({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant==="danger"?"danger":"default"}))&&n){s(!0);try{await n(e.action,e.key)}finally{s(!1)}}},l={default:"border border-border text-foreground hover:bg-surface-hover",primary:"bg-primary text-primary-foreground hover:bg-primary/90",danger:"bg-danger text-white hover:bg-danger/90"};return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,children:r("button",{onClick:i,disabled:t||o,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors disabled:opacity-50 ${l[e.variant??"default"]??l.default}`,children:o?"Processing...":e.buttonLabel})})}function vx(e,t){const n={...e.paramsStatic??{}};if(e.paramsFromForm)for(const[o,s]of Object.entries(e.paramsFromForm)){const a=t[s];a!=null&&a!==""&&(n[o]=a)}return n}function jP({field:e,value:t,values:n,onChange:o,disabled:s,onAction:a}){const[i,l]=$(!1),[c,d]=$(null),[f,p]=$(null),m=vx(e,n),h=Object.keys(e.paramsFromForm??{}).some(w=>m[w]===void 0),g=(e.refreshOn??Object.values(e.paramsFromForm??{})).map(w=>`${w}=${JSON.stringify(n[w])}`).join("|");Z(()=>{if(!a||h){p(null),d(null);return}let w=!1;return l(!0),d(null),a(e.action,e.key,m).then(v=>{if(w)return;const N=v;let k=[];if(Array.isArray(N))k=N;else if(N&&typeof N=="object")for(const S of Object.keys(N)){const M=N[S];if(Array.isArray(M)){k=M;break}}p(k)}).catch(v=>{w||(d(v instanceof Error?v.message:String(v)),p([]))}).finally(()=>{w||l(!1)}),()=>{w=!0}},[g,a,e.action,e.key]);const b=e.mapOption.value,x=e.mapOption.label,y=e.mapOption.description;return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,children:h?r("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyParamsMessage??"Fill the prerequisite fields above first."}):i?u("div",{className:"flex items-center gap-2 text-[11px] text-foreground-subtle",children:[r(Lt,{className:"h-3 w-3 animate-spin"})," Loading options…"]}):c?r("div",{className:"text-[11px] text-danger",children:c}):f&&f.length===0?r("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyResultsMessage??"No options returned."}):(()=>{const w=(f??[]).some(v=>{const N=v[b];return N===""||N===void 0});return u("select",{className:"w-full rounded-md border border-border bg-surface px-2 py-1.5 text-xs text-foreground",value:typeof t=="string"?t:"",disabled:s,onChange:v=>o(v.target.value),children:[!w&&r("option",{value:"",children:"— Select —"}),(f??[]).map((v,N)=>{const k=v[b],S=v[x],M=y?v[y]:void 0,P=typeof k=="string"&&k!==""?k:`row-${N}`;return u("option",{value:typeof k=="string"?k:String(k??""),children:[typeof S=="string"?S:String(S??P),M!==void 0?` (${String(M)})`:""]},P)})]})})()})}function HP({field:e,values:t,disabled:n,onAction:o}){const[s,a]=$(!1),[i,l]=$(null),c=nt(),d=async()=>{if(e.confirmMessage&&!await c({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant==="danger"?"danger":"default"})||!o)return;const p=vx(e,t);a(!0),l(null);try{const m=await o(e.action,e.key,p),h=typeof m=="object"&&m!==null?m:null,g=e.successMessage?e.successMessage.replace(/\{(\w+)\}/g,(b,x)=>{const y=h?.[x];return y===void 0?"":String(y)}):"Done.";l({kind:"ok",text:g})}catch(m){l({kind:"error",text:m instanceof Error?m.message:String(m)})}finally{a(!1)}},f={default:"border border-border text-foreground hover:bg-surface-hover",primary:"bg-primary text-primary-foreground hover:bg-primary/90",danger:"bg-danger text-white hover:bg-danger/90"};return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,children:u("div",{className:"flex flex-col gap-1.5",children:[r("button",{onClick:d,disabled:n||s,className:`inline-flex w-fit items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors disabled:opacity-50 ${f[e.variant??"default"]??f.default}`,children:s?"Working…":e.buttonLabel}),i&&r("div",{className:`text-[11px] ${i.kind==="ok"?"text-emerald-700 dark:text-emerald-300":"text-danger"}`,children:i.text})]})})}function VP({field:e}){const t=pn();return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,children:r(at,{widgetId:e.widgetId,host:"device-tab",config:e.widgetConfig,deviceId:t??void 0,instanceId:e.key})})}function qP(e,t){if(e==null)return"—";if(typeof e=="boolean")return e?"yes":"no";if(typeof e=="number"){const n=Number.isInteger(e)?String(e):e.toFixed(2);return t?`${n} ${t}`:n}return typeof e=="string"?e:JSON.stringify(e)}function UP({field:e,values:t,onAction:n,translationFn:o}){const s="key"in e?e.key:void 0;if(!s)return null;const a=t[s],i=a!==void 0?a:"default"in e?e.default:void 0,l="unit"in e?e.unit:void 0,c=qP(i,l),d="label"in e?e.label:void 0,f="description"in e?e.description:void 0,p="span"in e?e.span:void 0,m="actions"in e?e.actions??[]:[];return r(qe,{label:d,description:f,span:p,translationFn:o,children:u("div",{className:"flex items-stretch gap-1",children:[r("div",{className:"flex-1 rounded-md border border-border bg-surface-alt px-2.5 py-1.5 text-xs text-foreground font-mono break-all",children:c}),m.length>0&&r("div",{className:"flex items-center gap-1",children:m.map(h=>r(KP,{action:h,fieldKey:s,value:i,onAction:n},h.action))})]})})}function QP({name:e}){const t="h-3.5 w-3.5";switch(e){case"copy":return r(In,{className:t});case"refresh-cw":return r(Bl,{className:t});case"external-link":return r(Mm,{className:t});case"trash-2":return r(Qt,{className:t});case"download":return r(Bi,{className:t});case"upload":return r(Om,{className:t});default:return r(Fl,{className:t})}}function KP({action:e,fieldKey:t,value:n,onAction:o}){const s=nt(),[a,i]=$(!1),l=e.variant==="danger"?"text-danger hover:bg-danger/10 border-danger/30":e.variant==="primary"?"text-primary hover:bg-primary/10 border-primary/30":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover border-border";return r("button",{type:"button",onClick:async()=>{if(!(e.confirmMessage&&!await s({title:e.tooltip,message:e.confirmMessage,variant:e.variant==="danger"?"danger":"default"}))){if(e.action==="copy-value"){try{await navigator.clipboard.writeText(typeof n=="string"?n:String(n))}catch{}return}if(o){i(!0);try{await o(e.action,t)}finally{i(!1)}}}},disabled:a,title:e.tooltip,className:`inline-flex items-center justify-center rounded-md border px-2 py-1.5 transition-colors disabled:opacity-50 ${l}`,children:r(QP,{name:e.icon})})}function GP(e){return"multiple"in e&&e.multiple!=null}function WP({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c}){const d=e.multiple,f=d.min,p=d.max,m=t[e.key],g=[...Array.isArray(m)?m:m!=null?[m]:[]],b=d.itemDefault!==void 0?d.itemDefault:"default"in e&&e.default!==void 0?e.default:"";for(;g.length<f;)g.push(b);const x=k=>n(e.key,[...k]),y=(k,S)=>{const M=[...g];M[k]=S,x(M)},w=()=>{g.length>=p||x([...g,b])},v=k=>{g.length<=f||x(g.filter((S,M)=>M!==k))},N=()=>{const{multiple:k,...S}=e;return{...S,...{label:void 0,description:void 0,required:!1}}};return r(qe,{label:e.label,description:e.description,required:f>0?e.required:!1,span:e.span,translationFn:s,children:u("div",{className:"space-y-2",children:[g.map((k,S)=>{const M=d.itemLabel?.replace("${n}",String(S+1));return u("div",{className:"space-y-1",children:[M&&r("div",{className:ua,children:M}),u("div",{className:"flex items-center gap-2",children:[r("div",{className:"flex-1 min-w-0",children:r(rr,{field:N(),values:{...t,[e.key]:k},onChange:(P,A)=>y(S,A),disabled:o,translationFn:s,onTestField:a,onAction:c,allFields:l})}),g.length>f&&r("button",{type:"button",onClick:()=>v(S),disabled:o,title:"Remove",className:"flex-shrink-0 inline-flex items-center justify-center rounded-md border border-border p-1.5 text-foreground-subtle hover:text-danger hover:border-danger/50 transition-colors disabled:opacity-40",children:r(Qt,{className:"h-3.5 w-3.5"})})]})]},S)}),u("div",{className:"flex items-center justify-between pt-1",children:[g.length<p?u("button",{type:"button",onClick:w,disabled:o,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40",children:[r(Co,{className:"h-3 w-3"}),d.addLabel??"Add"]}):r("span",{}),u("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[g.length,"/",p]})]})]})})}function Ic(e,t,n){if(!("showWhen"in e)||!e.showWhen)return!0;const o=e.showWhen,s=t[o.field],a=n?.find(c=>"key"in c&&c.key===o.field),i=a&&"default"in a?a.default:void 0,l=s!==void 0?s:i;return o.equals!==void 0?l===o.equals:o.notEquals!==void 0?l!==o.notEquals:o.in!==void 0?o.in.includes(l):o.notIn!==void 0?!o.notIn.includes(l):o.includes!==void 0?Array.isArray(l)&&l.includes(o.includes):o.notIncludes!==void 0?!Array.isArray(l)||!l.includes(o.notIncludes):!0}function rr({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c}){if(GP(e))return r(WP,{field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c});if("readonlyField"in e&&e.readonlyField===!0)return r(UP,{field:e,values:t,onAction:c,translationFn:s});if(!Ic(e,t,l))return null;const d=t[e.key],f=d!==void 0?d:"default"in e?e.default:void 0,p=h=>n(e.key,h),m=Vh(e.type);switch(e.type){case"text":return r(yP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"number":return r(vP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"boolean":return r(wP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"select":return r(NP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"multiselect":return r(kP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"password":return r(SP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"textarea":return r(CP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"slider":return r(MP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"tags":return r(IP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"color":return r(AP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"node-select":return r(xx,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"node-multiselect":return r(yx,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"probe":return r(PP,{field:e,value:f,onChange:p,disabled:o,translationFn:s,onTestField:a,onAction:c,externalProbe:i});case"group":return r(EP,{field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a});case"sub-tabs":return r($P,{field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:c});case"separator":return r(_P,{});case"info":return r(LP,{field:e});case"object-array":return r(zP,{field:e});case"editable-array":return r(BP,{field:e,value:f,onChange:p,disabled:o,translationFn:s,onTestField:a,onAction:c});case"button":return r(FP,{field:e,disabled:o,onAction:c});case"addon-action-select":return r(jP,{field:e,value:f,values:t,onChange:p,disabled:o,onAction:c});case"addon-action-button":return r(HP,{field:e,values:t,disabled:o,onAction:c});case"widget":return r(VP,{field:e});default:return m?r(m,{field:e,value:f,onChange:p,disabled:o}):null}}function YP(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Tt(e,t){if(e!==void 0)return t&&YP(e)?t(e):e}function ZP({section:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i}){const[l,c]=$(e.defaultCollapsed??!1),d=e.style==="accordion",f=e.columns??2,p=f===1?"grid-cols-1":f===3?"grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3":f===4?"grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4":"grid-cols-1 @[640px]:grid-cols-2";return u("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[u("div",{className:["flex items-center justify-between mb-2",d?"cursor-pointer":""].join(" "),onClick:d?()=>c(m=>!m):void 0,children:[u("div",{children:[r("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:Tt(e.title,s)}),e.description&&r("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:Tt(e.description,s)})]}),d&&r("span",{className:"text-foreground-subtle text-xs ml-2",children:l?"▸":"▾"})]}),!l&&r("div",{className:`grid ${p} gap-x-3 gap-y-2.5`,children:e.fields.map(m=>r(rr,{field:m,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i?.[m.key]},m.key))})]})}function wx({schema:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i,onClearProbe:l}){const c=(d,f)=>{n({...t,[d]:f}),l?.(d)};return r("div",{className:"space-y-4",children:e.sections.map(d=>r(ZP,{section:d,values:t,onChange:c,disabled:o,translationFn:s,onTestField:a,probeResults:i},d.id))})}const XP=({open:e})=>r("svg",{className:`h-3 w-3 transition-transform ${e?"rotate-90":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:r("polyline",{points:"9 18 15 12 9 6"})});function bu(e){const t={};if(!e)return t;for(const n of e.sections)for(const o of n.fields){if(o.type==="separator"||o.type==="info"||o.type==="button"||o.type==="group")continue;const s=o.key;t[s]=o.value}return t}function JP(e){return{...e,sections:e.sections.map(t=>({...t,fields:t.fields.map(n=>{if(n.type==="separator"||n.type==="info"||n.type==="button"||n.type==="group")return n;const{value:o,...s}=n;return s})}))}}function eE({trpc:e,addonId:t,nodeId:n,title:o,disabled:s,onAfterChange:a,refreshToken:i,collapsible:l,defaultOpen:c,mode:d,onOverrideChange:f}){const p=d??"persist",[m,h]=$(null),[g,b]=$(!0),[x,y]=$(null),[w,v]=$(!1),[N,k]=$(c??!1),[S,M]=$({}),[P,A]=$(null);Z(()=>{A(null),M({})},[e,t,n,i,p]);const z=JSON.stringify(S);Z(()=>{let _=!1;b(!0),y(null);const R=p==="override"&&Object.keys(S).length>0?S:void 0;return e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n,...R?{overlay:R}:{}}).then(B=>{_||(h(B),R||A(bu(B)),b(!1))}).catch(B=>{_||(y(B instanceof Error?B.message:String(B)),b(!1))}),()=>{_=!0}},[e,t,n,i,p,z]);const D=U(()=>bu(m),[m]),T=U(()=>m?JP(m):null,[m]),O=async _=>{if(p==="override"){const B=P??D,F={};for(const H of Object.keys(_))_[H]!==B[H]&&(F[H]=_[H]);const j={...B,...F};M(F),f?.(F,j);return}const R={};for(const B of Object.keys(_))_[B]!==D[B]&&(R[B]=_[B]);if(Object.keys(R).length!==0){v(!0);try{await e.addonSettings.updateGlobalSettings.mutate({addonId:t,nodeId:n,patch:R});const B=await e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n});h(B),a?.()}catch(B){y(B instanceof Error?B.message:String(B))}finally{v(!1)}}};if(g)return u("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading ",o??t,"…"]});if(x)return u("div",{className:"text-xs text-red-400",children:[o??t,": ",x]});if(!m||!T)return u("div",{className:"text-xs text-foreground-subtle",children:[o??t," not available on ",n,"."]});const I=p==="override"?{...D,...S}:D,L=u(ge,{children:[p==="override"?r("div",{className:"mb-2 text-[11px] text-foreground-subtle",children:"Benchmark override — applies to this run only. The addon's saved settings are not changed."}):null,r(wx,{schema:T,values:I,onChange:O,disabled:s===!0||w})]});return l===!0?u("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("button",{type:"button",onClick:()=>k(_=>!_),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover text-left","aria-expanded":N,children:[r(XP,{open:N}),r("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide flex-1",children:o??t}),r("span",{className:"text-[10px] text-foreground-subtle",children:N?"hide":"edit"})]}),N?r("div",{className:"border-t border-border px-4 py-3",children:L}):null]}):o?u("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r("div",{className:"border-b border-border px-4 py-2",children:r("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:o})}),r("div",{className:"px-4 py-3",children:L})]}):r("div",{children:L})}function Nx({detections:{motion:e,motionRaw:t,detection:n,phase:o},showMotionZones:s=!0,showMotionRaw:a=!0,showDetections:i=!0,showPhaseIndicator:l=!0}){const c=s&&e&&e.zones.length>0,d=a&&t&&t.boxes.length>0,f=i&&n&&n.detections.length>0;return!c&&!d&&!f&&!l?null:u("div",{className:"absolute inset-0 pointer-events-none z-10",children:[l&&r(tE,{phase:o}),d&&r(nE,{raw:t}),c&&r(rE,{motion:e}),f&&r(oE,{detections:n.detections,frameWidth:n.frameWidth,frameHeight:n.frameHeight})]})}function tE({phase:e}){const t=Zn(e);return u("div",{className:"absolute top-2 left-2 flex items-center gap-1.5 px-2 py-1 rounded-md bg-black/60 backdrop-blur-sm",children:[r("span",{className:`w-2 h-2 rounded-full ${t.dotClass}`}),r("span",{className:"text-[10px] font-semibold text-white uppercase tracking-wider",children:t.label})]})}function nE({raw:e}){return e.frameWidth===0||e.frameHeight===0?null:r(ge,{children:e.boxes.map((t,n)=>{const[o,s,a,i]=t.bbox,l=o/e.frameWidth*100,c=s/e.frameHeight*100,d=(a-o)/e.frameWidth*100,f=(i-s)/e.frameHeight*100,p=Math.max(.05,Math.min(.25,t.changeScore*.3));return r("div",{className:"absolute rounded-sm",style:{left:`${l}%`,top:`${c}%`,width:`${d}%`,height:`${f}%`,backgroundColor:`rgba(239, 68, 68, ${p})`}},`mr-${n}`)})})}function rE({motion:e}){if(e.frameWidth===0||e.frameHeight===0)return null;const t=e.zones.filter(n=>n.w*n.h/(e.frameWidth*e.frameHeight)<.9);return r(ge,{children:t.map((n,o)=>{const s=Math.max(.15,Math.min(.5,n.intensity/255));return r("div",{className:"absolute rounded-sm",style:{left:`${n.x/e.frameWidth*100}%`,top:`${n.y/e.frameHeight*100}%`,width:`${n.w/e.frameWidth*100}%`,height:`${n.h/e.frameHeight*100}%`,border:`1px solid rgba(250, 204, 21, ${s})`,backgroundColor:`rgba(250, 204, 21, ${s*.15})`}},`mz-${o}`)})})}function oE({detections:e,frameWidth:t,frameHeight:n}){return t===0||n===0?null:r(ge,{children:e.map(o=>{const{x:s,y:a,width:i,height:l}=o.bbox,c=s/t*100,d=a/n*100,f=i/t*100,p=l/n*100,m=lt(o.macroClass),h=[`${o.macroClass} ${(o.score*100).toFixed(0)}%`];for(const g of o.labels)h.push(g.label);return r("div",{className:"absolute border-2 rounded-sm",style:{left:`${c}%`,top:`${d}%`,width:`${f}%`,height:`${p}%`,borderColor:m},children:r("div",{className:"absolute -top-4 left-0 px-1 py-0.5 text-[9px] font-bold text-white rounded-sm whitespace-nowrap",style:{backgroundColor:m},children:h.join(" | ")})},`det-${o.id}`)})})}function sE(e){const t={};if(typeof window<"u"){if(e){const o=e.getBoundingClientRect();o.width>0&&o.height>0&&(t.viewportWidth=Math.round(o.width),t.viewportHeight=Math.round(o.height))}t.viewportWidth===void 0&&(t.viewportWidth=window.innerWidth,t.viewportHeight=window.innerHeight),t.devicePixelRatio=window.devicePixelRatio||1;const n=navigator.connection;n?.downlink&&n.downlink>0&&(t.downlinkMbps=n.downlink)}return t}const aE=3e3,iE=5;function kx({serverUrl:e,streamKey:t,label:n,autoPlay:o=!0,muted:s=!0,showControls:a=!0,className:i="",onStateChange:l,onError:c,overlay:d,createSession:f,sendAnswer:p,closeSession:m,hintsOverride:h}){const g=ne(null),b=ne(null),x=ne(null),y=ne(new Set),w=ne(null),v=ne(null),N=ne(0),k=ne(!0),[S,M]=$("idle"),[P,A]=$(""),[z,D]=$(s),[T,O]=$(!1),[I,L]=$(!1),_=ne(null),R=ne(!1);(p||f)&&(R.current=!0);const B=R.current,F=q(G=>{M(G),l?.(G)},[l]),j=q(()=>{if(w.current?.abort(),w.current=null,v.current&&(clearTimeout(v.current),v.current=null),x.current&&(x.current.close(),x.current=null),m&&y.current.size>0){for(const G of y.current)m(G).catch(()=>{});y.current.clear()}g.current&&(g.current.srcObject=null)},[m]),H=q(async()=>{if(!k.current||!f||!p)return;j(),F("connecting");const G=new AbortController;w.current=G;try{const ae={...sE(b.current),...h},{sessionId:fe,sdpOffer:he}=await f(ae);if(y.current.add(fe),!k.current||G.signal.aborted){m?.(fe).catch(()=>{}),y.current.delete(fe);return}const V=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=V;const ie=new MediaStream;V.ontrack=pe=>{console.debug("[WebRTC] ontrack",pe.track.kind,pe.track.readyState),ie.addTrack(pe.track),g.current&&(g.current.srcObject=ie,g.current.play().catch(()=>{}))},V.oniceconnectionstatechange=()=>{if(!k.current)return;const pe=V.iceConnectionState;console.debug("[WebRTC] ICE state:",pe),pe==="connected"||pe==="completed"?(N.current=0,F("playing"),g.current?.paused&&(console.debug("[WebRTC] video was paused at ICE connected — calling play()"),g.current.play().catch(()=>{}))):(pe==="failed"||pe==="disconnected"||pe==="closed")&&(F("disconnected"),Y())},V.onicecandidateerror=pe=>{console.debug("[WebRTC] ICE candidate error:",pe)},console.debug("[WebRTC] Setting remote description (server offer)..."),await V.setRemoteDescription({type:"offer",sdp:he});const ue=await V.createAnswer();if(await V.setLocalDescription(ue),console.debug("[WebRTC] Local description set, waiting for ICE gathering..."),await xu(V),!k.current)return;const de=(V.localDescription?.sdp??"").split(`
|
|
536
|
-
`).filter(pe=>pe.startsWith("a=candidate:")).length;console.debug("[WebRTC] Sending answer to server",{localCandidates:de,sessionId:fe.slice(0,8)}),await p(fe,V.localDescription?.sdp??""),console.debug("[WebRTC] Answer sent successfully");const ce=V,Se=()=>{const pe=ce.connectionState;if(pe==="closed"||pe==="failed")return;const Ie=g.current;Ie&&Ie.readyState===0&&console.log(`[WebRTC] no video data yet (ice=${ce.iceConnectionState})`)};setTimeout(Se,3e3),setTimeout(Se,8e3)}catch(ee){if(!k.current)return;const ae=ee instanceof Error?ee.message:String(ee);A(ae),F("error"),c?.(ae),Y()}},[e,t,f,p,j,F,c,h]),E=q(async()=>{if(k.current){j(),F("connecting");try{const G=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=G,G.addTransceiver("video",{direction:"recvonly"}),G.addTransceiver("audio",{direction:"recvonly"});const ee=new MediaStream;G.ontrack=ie=>{ee.addTrack(ie.track),g.current&&(g.current.srcObject=ee,g.current.play().catch(()=>{}))},G.oniceconnectionstatechange=()=>{if(!k.current)return;const ie=G.iceConnectionState;ie==="connected"||ie==="completed"?(N.current=0,F("playing"),g.current?.paused&&g.current.play().catch(()=>{})):(ie==="failed"||ie==="disconnected"||ie==="closed")&&(F("disconnected"),Y())};const ae=await G.createOffer();if(await G.setLocalDescription(ae),await xu(G),!k.current)return;const fe=`${e}/api/webrtc?src=${encodeURIComponent(t)}`,he=await fetch(fe,{method:"POST",headers:{"Content-Type":"application/sdp"},body:G.localDescription?.sdp??""});if(!he.ok)throw new Error(`WHEP ${he.status}: ${he.statusText}`);const V=await he.text();await G.setRemoteDescription({type:"answer",sdp:V})}catch(G){if(!k.current)return;const ee=G instanceof Error?G.message:String(G);A(ee),F("error"),c?.(ee),Y()}}},[e,t,j,F,c]),Q=B?H:E,K=ne(()=>{});K.current=Q;const Y=q(()=>{k.current&&(N.current>=iE||(N.current+=1,v.current=setTimeout(()=>{k.current&&K.current()},aE)))},[]);Z(()=>(k.current=!0,N.current=0,o&&Q(),()=>{k.current=!1,j()}),[e,t]);const re=ne(!1);Z(()=>{!o||!B||!f||!p||re.current||x.current||(re.current=!0,Q())},[o,B,f,p,Q]);const te=()=>{N.current=0,Q()},X=()=>{g.current&&(g.current.muted=!g.current.muted,D(g.current.muted))},oe=async()=>{if(b.current)try{document.fullscreenElement?await document.exitFullscreen():await b.current.requestFullscreen()}catch(G){console.warn(`Fullscreen toggle failed: ${G instanceof Error?G.message:G}`)}},be=()=>{if(!g.current)return;const G=document.createElement("canvas");G.width=g.current.videoWidth||1280,G.height=g.current.videoHeight||720;const ee=G.getContext("2d");if(!ee)return;ee.drawImage(g.current,0,0);const ae=document.createElement("a");ae.download=`${t.replace(/[/:]/g,"-")}-${Date.now()}.jpg`,ae.href=G.toDataURL("image/jpeg",.92),ae.click()};Z(()=>{const G=()=>O(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",G),()=>document.removeEventListener("fullscreenchange",G)},[]);const J=()=>{L(!0),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>L(!1),3e3)};return u("div",{ref:b,className:`relative bg-black overflow-hidden group ${i}`,onMouseMove:J,onMouseEnter:J,children:[r("video",{ref:g,autoPlay:o,muted:z,playsInline:!0,className:"w-full h-full object-contain"}),n&&S==="playing"&&r("div",{className:"absolute top-2 left-2 px-2 py-0.5 rounded bg-black/60 text-[10px] text-white font-medium",children:n}),d,S==="connecting"&&u("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[r("svg",{className:"h-6 w-6 text-white/60 animate-spin",viewBox:"0 0 24 24",fill:"none",children:r("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"32",strokeDashoffset:"32",className:"animate-[dash_1.5s_ease-in-out_infinite]"})}),r("span",{className:"text-xs text-white/60",children:"Connecting…"})]}),(S==="error"||S==="disconnected")&&u("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[r("svg",{className:"h-6 w-6 text-red-400",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:r("path",{d:"M1 1l5.5 5.5M23 23l-5.5-5.5M8.11 15.89a8 8 0 0110.78-10.78M3.64 3.64A12 12 0 0020.36 20.36",strokeLinecap:"round"})}),r("span",{className:"text-xs text-red-400 text-center px-4",children:S==="error"?P||"Connection failed":"Disconnected"}),r("button",{onClick:te,className:"mt-1 inline-flex items-center gap-1.5 rounded px-3 py-1 text-xs bg-white/10 text-white hover:bg-white/20 transition-colors",children:"Reconnect"})]}),a&&S==="playing"&&u("div",{className:`absolute bottom-0 inset-x-0 flex items-center justify-between px-3 py-1.5 bg-gradient-to-t from-black/80 to-transparent transition-opacity duration-200 ${I?"opacity-100":"opacity-0"}`,children:[r("div",{className:"flex items-center gap-1",children:r(Wa,{onClick:X,title:z?"Unmute":"Mute",children:z?u("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[r("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),r("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),r("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]}):u("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[r("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),r("path",{d:"M19.07 4.93a10 10 0 010 14.14M15.54 8.46a5 5 0 010 7.07"})]})})}),u("div",{className:"flex items-center gap-1",children:[r(Wa,{onClick:be,title:"Take snapshot",children:u("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[r("path",{d:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z"}),r("circle",{cx:"12",cy:"13",r:"4"})]})}),r(Wa,{onClick:oe,title:T?"Exit fullscreen":"Fullscreen",children:T?r("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:r("path",{d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):r("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:r("path",{d:"M8 3H5a2 2 0 00-2 2v3m18 0V5a2 2 0 00-2-2h-3m0 18h3a2 2 0 002-2v-3M3 16v3a2 2 0 002 2h3"})})})]})]})]})}function Wa({onClick:e,title:t,children:n}){return r("button",{onClick:e,title:t,className:"rounded-full p-1.5 text-white/80 hover:text-white hover:bg-white/20 transition-colors",children:n})}async function xu(e){if(e.iceGatheringState!=="complete")return new Promise(t=>{const n=()=>{e.iceGatheringState==="complete"&&(e.removeEventListener("icegatheringstatechange",n),t())};e.addEventListener("icegatheringstatechange",n),setTimeout(t,5e3)})}const Ac=un("camstack:player-overlays-state",null),Pc=un("camstack:player-overlays-actions",null);function Sx({children:e}){const[t,n]=$(()=>new Map),[o,s]=$(()=>new Map),a=q(p=>{n(m=>{const h=new Map(m);return h.set(p.id,p),h})},[]),i=q(p=>{n(m=>{if(!m.has(p))return m;const h=new Map(m);return h.delete(p),h})},[]),l=q(p=>{s(m=>{const h=new Map(m);return h.set(p.id,p),h})},[]),c=q(p=>{s(m=>{if(!m.has(p))return m;const h=new Map(m);return h.delete(p),h})},[]),d=U(()=>({layers:t,buttons:o}),[t,o]),f=U(()=>({setLayer:a,removeLayer:i,setButton:l,removeButton:c}),[a,i,l,c]);return r(Ac.Provider,{value:d,children:r(Pc.Provider,{value:f,children:e})})}function Cx(){const e=ve(Ac);return U(()=>e?[...e.layers.values()].sort((t,n)=>t.order-n.order):[],[e])}function Mx(){const e=ve(Ac);return U(()=>e?[...e.buttons.values()].sort((t,n)=>t.order-n.order):[],[e])}function lE(e){const t=ve(Pc);Z(()=>{if(!(!t||!e))return t.setLayer(e),()=>t.removeLayer(e.id)},[t,e])}function cE(e){const t=ve(Pc);Z(()=>{if(!(!t||!e))return t.setButton(e),()=>t.removeButton(e.id)},[t,e])}function dE(e){return e==="streaming"?"bg-emerald-500":e==="connecting"?"bg-amber-500":e==="error"?"bg-rose-500":"bg-zinc-500"}function uE(e){const t=Math.floor(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h${Math.floor(t%3600/60)}m`}function Gi({className:e}){return r("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r("polygon",{points:"5 3 19 12 5 21 5 3"})})}function pE({className:e}){return r("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})})}function fE({className:e}){return u("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"}),r("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),r("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),r("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}function mE({className:e}){return u("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[r("circle",{cx:"5",cy:"12",r:"2"}),r("circle",{cx:"12",cy:"12",r:"2"}),r("circle",{cx:"19",cy:"12",r:"2"})]})}function Ya({label:e,active:t,onClick:n}){return u("button",{type:"button",onClick:n,className:"w-full flex items-center justify-between gap-3 px-3 py-1.5 text-[11px] text-foreground hover:bg-surface-hover transition-colors",children:[r("span",{children:e}),r("span",{className:`inline-block h-3 w-5 rounded-full transition-colors ${t?"bg-primary":"bg-foreground-subtle/30"} relative`,children:r("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-white transition-all ${t?"left-2.5":"left-0.5"}`})})]})}function Ix({className:e}){return u("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("polyline",{points:"23 4 23 10 17 10"}),r("polyline",{points:"1 20 1 14 7 14"}),r("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]})}function hE({className:e}){return u("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),r("path",{d:"M10.41 10.41a2 2 0 11-2.83-2.83"}),r("line",{x1:"13.5",y1:"13.5",x2:"6",y2:"21"}),r("path",{d:"M18 12l-1.5-1.5"}),r("path",{d:"M21 15V5a2 2 0 00-2-2H5"}),r("path",{d:"M21 21H5a2 2 0 01-2-2V11"})]})}function Ec({serverUrl:e,createSession:t,sendAnswer:n,closeSession:o,streams:s,activeStreamId:a,onStreamChange:i,deviceName:l,phase:c,pipelineMetrics:d,detections:f,defaultShowDetections:p=!0,defaultShowMotion:m=!1,streamStats:h,autoPlay:g=!1,showPlayStop:b=!1,snapshotSrc:x,snapshotLoading:y=!1,onRefreshSnapshot:w,showStreamStats:v=!1,children:N,extraOverlay:k,ptzAvailable:S=!1,ptzShown:M=!1,ptzOverlay:P,onPtzToggle:A,intercomAvailable:z=!1,intercomShown:D=!1,onIntercomToggle:T,chromeless:O=!1,className:I}){const L=Mx(),[_,R]=$(g),[B,F]=$(p),[j,H]=$(m),[E,Q]=$(null),[K,Y]=$(!1),re=ne(null);Z(()=>{if(!K)return;function ce(Se){re.current&&!re.current.contains(Se.target)&&Y(!1)}return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[K]);const te=a??E??s?.[0]?.id??"",X=s?.find(ce=>ce.id===te)??s?.[0],oe=X?.inputFps!=null?{status:X.status??"unknown",inputFps:X.inputFps,bitrateKbps:X.bitrateKbps??0}:null,be=ce=>{Q(ce),i?.(ce),_&&b&&(R(!1),setTimeout(()=>R(!0),50))},J=U(()=>{const ce=X?.target;if(ce)return Se=>t(ce,Se)},[t,X]),G=s,ee=()=>R(!0),ae=()=>R(!1),fe=d?.phase??c,he=fe==="active",V=!!f,ie=V&&(B||j),ue=S&&M&&!!P,de=b?_:!0;return u("div",{className:`overflow-hidden ${O?"":"rounded-xl border border-border bg-surface"} ${I??""}`,children:[u("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[u("div",{className:"flex items-center gap-2",children:[(h??oe)&&r("span",{className:`w-2 h-2 rounded-full ${dE((h??oe).status)}`}),l&&r("span",{className:"text-xs font-medium text-foreground",children:l}),G&&G.length>1&&u("div",{className:"relative",children:[r("select",{"data-testid":"stream-profile-select",value:te,onChange:ce=>be(ce.target.value),className:"appearance-none cursor-pointer rounded-md border border-border bg-surface-hover hover:bg-surface text-foreground text-[11px] font-medium pl-2 pr-6 py-1 focus:outline-none focus:ring-1 focus:ring-primary transition-colors",children:G.map(ce=>r("option",{value:ce.id,children:ce.label},ce.id))}),r("span",{className:"pointer-events-none absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle",children:r("svg",{className:"h-2.5 w-2.5",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r("polyline",{points:"3 4.5 6 7.5 9 4.5"})})})]})]}),u("div",{className:"flex items-center gap-1.5",children:[z&&u("button",{"data-testid":"stream-intercom-toggle","data-intercom-shown":D?"true":"false",onClick:T,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${D?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:D?"Close intercom":"Open intercom",children:[r(fE,{className:"h-3 w-3"}),r("span",{className:"hidden xl:inline",children:"Intercom"})]}),L.map(ce=>{const pe=ce.tone==="primary"?"bg-primary text-primary-foreground":"bg-primary/15 text-primary";return u("button",{type:"button","data-toolbar-button-id":ce.id,"data-toolbar-button-active":ce.active?"true":"false",onClick:ce.onClick,disabled:ce.disabled,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors disabled:opacity-50 ${ce.active?pe:"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:ce.title??ce.label,children:[ce.icon,r("span",{className:"hidden xl:inline",children:ce.label})]},ce.id)}),b&&u("button",{"data-testid":"stream-play-toggle","data-stream-playing":de?"true":"false",onClick:de?ae:ee,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${de?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary/10 text-primary hover:bg-primary/20"}`,title:de?"Stop stream":"Start stream",children:[de?r(pE,{className:"h-3 w-3"}):r(Gi,{className:"h-3 w-3"}),r("span",{className:"hidden xl:inline",children:de?"Stop":"Play"})]}),w&&u("button",{"data-testid":"stream-snapshot-refresh",onClick:w,disabled:y,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",title:"Force snapshot refresh",children:[r(Ix,{className:`h-3 w-3 ${y?"animate-spin":""}`}),r("span",{className:"hidden xl:inline",children:"Snapshot"})]}),(V||S||d||fe||h||oe&&oe.inputFps>0)&&u("div",{ref:re,className:"relative",children:[r("button",{onClick:()=>Y(ce=>!ce),title:"More controls",className:"inline-flex items-center justify-center rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:r(mE,{className:"h-3.5 w-3.5"})}),K&&u("div",{className:"absolute right-0 top-full mt-1 z-30 min-w-[200px] rounded-lg border border-border bg-surface shadow-xl py-1.5",children:[v&&h&&u("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Input"}),u("span",{className:"tabular-nums text-foreground",children:[h.inputFps.toFixed(1)," fps"]})]}),u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Decode"}),u("span",{className:"tabular-nums text-foreground",children:[h.decodeFps.toFixed(1)," fps"]})]}),u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Uptime"}),r("span",{className:"tabular-nums text-foreground",children:uE(h.uptimeMs)})]})]}),!v&&oe&&oe.inputFps>0&&u("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Input"}),u("span",{className:"tabular-nums text-foreground",children:[oe.inputFps.toFixed(1)," fps"]})]}),oe.bitrateKbps>0&&u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Bitrate"}),u("span",{className:"tabular-nums text-foreground",children:[oe.bitrateKbps," kbps"]})]})]}),(d||V&&fe)&&u("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[u("div",{className:"flex justify-between gap-3 items-center",children:[r("span",{children:"Phase"}),u("span",{className:`flex items-center gap-1 font-semibold uppercase tracking-wider ${he?"text-red-400":"text-emerald-400"}`,children:[r("span",{className:`w-1.5 h-1.5 rounded-full ${he?"bg-red-500 animate-pulse":"bg-emerald-500"}`}),he?"Active":"Watching"]})]}),d&&d.detectionFps>0&&u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Detection"}),u("span",{className:"tabular-nums text-foreground",children:[d.detectionFps.toFixed(1)," det/s"]})]}),d&&d.avgInferenceMs>0&&u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Inference"}),u("span",{className:"tabular-nums text-foreground",children:[d.avgInferenceMs.toFixed(0)," ms"]})]})]}),V&&u(ge,{children:[r(Ya,{label:"Show detections",active:B,onClick:()=>F(ce=>!ce)}),r(Ya,{label:"Show motion",active:j,onClick:()=>H(ce=>!ce)})]}),S&&r(Ya,{label:"PTZ controls",active:M,onClick:()=>{A?.(),Y(!1)}})]})]})]})]}),de?r("div",{className:"aspect-video relative",children:r(kx,{serverUrl:e,streamKey:te,autoPlay:!0,className:"w-full h-full",createSession:J,sendAnswer:n,closeSession:o,overlay:ie||k||ue?u(ge,{children:[ie&&r(Nx,{detections:f,showPhaseIndicator:!1,showMotionZones:j,showMotionRaw:j,showDetections:B}),k,ue&&P]}):void 0},te)}):r(gE,{src:x??null,isLoading:y,onPlay:ee,onRetry:w,extraOverlay:k||ue?u(ge,{children:[k,ue&&P]}):null,suppressPlayHover:!!k||ue}),N]})}function gE({src:e,isLoading:t,onPlay:n,onRetry:o,extraOverlay:s,suppressPlayHover:a=!1}){return e?u("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:[r("img",{src:e,alt:"Camera snapshot",className:"w-full h-full object-contain"}),!a&&r("button",{onClick:n,className:"absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 hover:opacity-100 transition-opacity cursor-pointer",children:r("div",{className:"h-14 w-14 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center",children:r(Gi,{className:"h-7 w-7 text-white ml-0.5"})})}),s]}):t?r("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:r("div",{className:"h-8 w-8 border-2 border-white/20 border-t-white/60 rounded-full animate-spin"})}):r("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:u("div",{className:"flex flex-col items-center gap-2 text-white/40",children:[r(hE,{className:"h-8 w-8"}),r("span",{className:"text-xs",children:"No snapshot available"}),u("div",{className:"flex items-center gap-2 mt-1",children:[o&&u("button",{onClick:o,className:"inline-flex items-center gap-1.5 rounded-md border border-white/20 px-3 py-1.5 text-xs font-medium text-white/60 hover:text-white hover:border-white/40 transition-colors",children:[r(Ix,{className:"h-3 w-3"}),"Retry"]}),u("button",{onClick:n,className:"inline-flex items-center gap-1.5 rounded-md bg-primary/80 px-3 py-1.5 text-xs font-medium text-white hover:bg-primary transition-colors",children:[r(Gi,{className:"h-3 w-3"}),"Play Live"]})]})]})})}function bE({samples:e,sampleRate:t=16e3,height:n=96,className:o="",color:s="#3b82f6",bgColor:a="transparent"}){const i=ne(null),l=ne(null),c=q(()=>{const p=i.current,m=l.current;if(!p||!m||!e||e.length===0)return;const h=m.clientWidth;if(h===0)return;const g=window.devicePixelRatio||1;p.width=h*g,p.height=n*g,p.style.width=`${h}px`,p.style.height=`${n}px`;const b=p.getContext("2d");if(!b)return;b.scale(g,g),a!=="transparent"?(b.fillStyle=a,b.fillRect(0,0,h,n)):b.clearRect(0,0,h,n);const x=e.length/h,y=n/2;b.fillStyle=s,b.globalAlpha=.7;for(let w=0;w<h;w++){const v=Math.floor(w*x),N=Math.min(Math.floor((w+1)*x),e.length);let k=0,S=0;for(let z=v;z<N;z++){const D=e[z];D<k&&(k=D),D>S&&(S=D)}const M=y-S*y,P=y-k*y,A=Math.max(1,P-M);b.fillRect(w,M,1,A)}b.globalAlpha=1,b.strokeStyle=s,b.globalAlpha=.2,b.lineWidth=1,b.beginPath(),b.moveTo(0,y),b.lineTo(h,y),b.stroke(),b.globalAlpha=1},[e,n,s,a]);Z(()=>{c()},[c]),Z(()=>{const p=new ResizeObserver(()=>c()),m=l.current;return m&&p.observe(m),()=>p.disconnect()},[c]);const f=((e&&t?Math.round(e.length/t*1e3):0)/1e3).toFixed(1);return u("div",{ref:l,className:`relative ${o}`,children:[r("canvas",{ref:i,className:"w-full rounded-md"}),e&&e.length>0&&u("div",{className:"absolute bottom-1 right-2 text-[10px] text-foreground-subtle/60 font-mono",children:[f,"s · ",t/1e3,"kHz · ",e.length.toLocaleString()," samples"]})]})}function xE({currentDbfs:e,durationSec:t=30,maxSamples:n=120,height:o=64,className:s="",color:a="#10b981",clipColor:i="#ef4444",clipThreshold:l=-6,minDbfs:c=-96}){const d=ne(null),f=ne(null),[p,m]=$([]);Z(()=>{e!==null&&m(b=>{const x=[...b,{dbfs:e,timestamp:Date.now()}];return x.length>n?x.slice(-n):x})},[e,n]);const h=q(()=>{const b=d.current,x=f.current;if(!b||!x)return;const y=x.clientWidth;if(y===0)return;const w=window.devicePixelRatio||1;b.width=y*w,b.height=o*w,b.style.width=`${y}px`,b.style.height=`${o}px`;const v=b.getContext("2d");if(!v||(v.scale(w,w),v.clearRect(0,0,y,o),p.length===0))return;const N=p[p.length-1].timestamp,k=t*1e3,S=N-k,M=p.filter(D=>D.timestamp>=S);if(M.length===0)return;const P=Math.max(1,Math.floor(y/(t*2))),A=Math.abs(c);for(const D of M){const T=D.timestamp-S,O=Math.floor(T/k*y),L=(Math.max(c,Math.min(0,D.dbfs))-c)/A,_=Math.max(1,L*o),R=D.dbfs>=l;v.fillStyle=R?i:a,v.globalAlpha=.8,v.fillRect(O,o-_,P,_)}v.globalAlpha=1;const z=o-(l-c)/A*o;v.strokeStyle=i,v.globalAlpha=.25,v.lineWidth=1,v.setLineDash([4,4]),v.beginPath(),v.moveTo(0,z),v.lineTo(y,z),v.stroke(),v.setLineDash([]),v.globalAlpha=1},[p,t,o,a,i,l,c]);Z(()=>{h()},[h]),Z(()=>{const b=new ResizeObserver(()=>h()),x=f.current;return x&&b.observe(x),()=>b.disconnect()},[h]);const g=p.length>0?p[p.length-1].dbfs:null;return u("div",{ref:f,className:`relative ${s}`,children:[r("canvas",{ref:d,className:"w-full rounded-md"}),u("div",{className:"absolute top-1 left-2 text-[9px] text-foreground-subtle/50 font-mono",children:[t,"s"]}),g!==null&&u("div",{className:"absolute bottom-1 right-2 text-[9px] text-foreground-subtle/50 font-mono",children:[g.toFixed(1)," dBFS · ",p.length," samples"]})]})}function yE(e){return e>=.8?"bg-emerald-500":e>=.5?"bg-amber-500":e>=.3?"bg-orange-500":"bg-zinc-500"}function vE(e){return e>=.8?"text-emerald-400":e>=.5?"text-amber-400":e>=.3?"text-orange-400":"text-zinc-400"}function wE({classifications:e,processing:t=!1,inferenceMs:n,maxItems:o=10,className:s=""}){const a=e.slice(0,o),i=a.length>0?a[0].score:1;return t?r("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${s}`,children:r("div",{className:"text-sm text-foreground-subtle animate-pulse",children:"Classifying audio..."})}):a.length===0?r("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${s}`,children:r("div",{className:"text-xs text-foreground-subtle",children:"No classifications yet"})}):u("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${s}`,children:[u("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between",children:[r("h3",{className:"text-xs font-medium text-foreground",children:"Audio Classifications"}),u("div",{className:"flex items-center gap-3 text-[10px] text-foreground-subtle",children:[a.length<e.length&&u("span",{children:["showing ",a.length," of ",e.length]}),n!==void 0&&u("span",{className:"font-mono",children:[n.toFixed(1),"ms"]})]})]}),r("div",{className:"divide-y divide-border/50",children:a.map((l,c)=>{const d=i>0?l.score/i*100:0;return u("div",{className:"px-3 py-1.5 flex items-center gap-3 hover:bg-surface-hover/30",children:[r("span",{className:"text-[10px] text-foreground-subtle w-5 text-right font-mono",children:c+1}),r("span",{className:"text-xs font-medium text-foreground min-w-[120px]",children:l.className}),r("div",{className:"flex-1 h-2 rounded-full bg-zinc-800 overflow-hidden",children:r("div",{className:`h-full rounded-full transition-all duration-300 ${yE(l.score)}`,style:{width:`${d}%`}})}),u("span",{className:`text-xs font-mono font-semibold w-14 text-right ${vE(l.score)}`,children:[(l.score*100).toFixed(1),"%"]})]},`${l.className}-${c}`)})})]})}function NE({data:e,label:t="Response",className:n=""}){const[o,s]=$(!1);if(!e)return null;const a=JSON.stringify(e,null,2);return u("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${n}`,children:[u("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between cursor-pointer select-none hover:bg-surface-hover/30",onClick:()=>s(i=>!i),children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-[10px] text-foreground-subtle",children:o?"▼":"▶"}),r("h3",{className:"text-xs font-medium text-foreground",children:t})]}),r("span",{className:"text-[10px] text-foreground-subtle font-mono",children:a.length>1e3?`${(a.length/1024).toFixed(1)} KB`:`${a.length} bytes`})]}),o&&r("div",{className:"max-h-80 overflow-y-auto overflow-x-auto",children:r("pre",{className:"p-3 text-[10px] leading-4 font-mono text-foreground-subtle whitespace-pre",children:a})})]})}const kE={Activity:vn,Eye:So,AlertTriangle:Mo,PauseCircle:N2,PowerOff:wk};function $c({phase:e,...t}){const n=Zn(e),o=kE[n.icon];return r(o,{...t})}function zn(e){const[t,n]=$([]),o=q(a=>{n(i=>{const l=[...i,a];return l.length>e?l.slice(-e):l})},[e]),s=q(()=>{n([])},[]);return U(()=>({entries:t,append:o,reset:s}),[t,o,s])}function yu(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}const vu={error:{icon:ea,color:"text-red-400"},warn:{icon:Mo,color:"text-amber-400"},info:{icon:Z2,color:"text-blue-400"},debug:{icon:s2,color:"text-gray-500"}},wu={debug:0,info:1,warn:2,error:3},SE=["all","debug","info","warn","error"],CE=500;function ME(e,t){return t?(wu[e]??0)>=(wu[t]??0):!0}function Wt({agentId:e,addonId:t,deviceId:n,integrationId:o,requestId:s,level:a,maxHeight:i="max-h-96",showScope:l=!1,showFilters:c=!0,limit:d=100,liveBuffer:f,onClose:p,className:m}){const[h,g]=$(""),[b,x]=$(""),[y,w]=$(a),v=e,N=t??(h||void 0),k=n??(b?Number(b):void 0),S=o,M=s,P=U(()=>{const V={};return v&&(V.agentId=v),N&&(V.addonId=N),k!==void 0&&Number.isFinite(k)&&(V.deviceId=k),S&&(V.integrationId=S),M&&(V.requestId=M),Object.keys(V).length>0?V:void 0},[v,N,k,S,M]),A=zn(CE),z=f??A,D=z.entries,[T,O]=$(0),[I,L]=$(!1),[_,R]=$(!1),[B,F]=$(new Set),[j,H]=$(""),E=ne(null),Q=`${v??""}:${N??""}:${String(k??"")}:${S??""}:${M??""}`,K=ne(Q);Z(()=>{K.current!==Q&&(K.current=Q,z.reset(),O(0),F(new Set))},[Q,z]);const{data:Y,isLoading:re}=C.logs.query.useQuery({...P?{tags:P}:{},limit:d},{staleTime:3e4});C.logs.subscribe.useSubscription({...P?{tags:P}:{}},{onData:V=>{z.append(V)}});const te=ne(D.length);Z(()=>{const V=E.current;if(!V){te.current=D.length;return}const ie=te.current;if(te.current=D.length,!(D.length<=ie)){if(I&&V.scrollTop<=8)V.scrollTo({top:0});else if(!I&&V.scrollTop>0){const ue=V.querySelector("tbody tr"),de=ue instanceof HTMLElement?ue.offsetHeight:24;V.scrollTop+=de*(D.length-ie)}}},[D.length,I]);const X=U(()=>{const V=(Y??[]).map(pe=>({timestamp:pe.timestamp,level:pe.level,message:pe.message,scope:pe.scope,tags:pe.tags,meta:pe.meta})),ie=new Set,ue=[];for(const pe of[...D].reverse()){const Ie=`${pe.timestamp}|${pe.level}|${pe.scope??""}|${pe.message}`;ie.has(Ie)||(ie.add(Ie),ue.push(pe))}for(const pe of V){const Ie=`${pe.timestamp}|${pe.level}|${pe.scope??""}|${pe.message}`;ie.has(Ie)||(ie.add(Ie),ue.push(pe))}const ce=(T>0?ue.filter(pe=>new Date(pe.timestamp).getTime()>T):ue).filter(pe=>ME(pe.level,y)),Se=j.trim().toLowerCase();return Se?ce.filter(pe=>{if(pe.message.toLowerCase().includes(Se)||pe.scope&&pe.scope.toLowerCase().includes(Se))return!0;if(pe.tags){for(const Ie of Object.values(pe.tags))if(Ie!==void 0&&String(Ie).toLowerCase().includes(Se))return!0}if(pe.meta){for(const Ie of Object.values(pe.meta))if(Ie!=null&&yu(Ie).toLowerCase().includes(Se))return!0}return!1}):ce},[Y,D,y,T,j]),oe=q(()=>{const V=X.map(ie=>{const ue=new Date(ie.timestamp).toLocaleTimeString(),de=ie.tags?" "+Object.entries(ie.tags).filter(([,ce])=>ce).map(([ce,Se])=>`${ce}=${Se}`).join(" "):"";return`${ue} [${ie.level.toUpperCase()}]${ie.scope?` [${ie.scope}]`:""}${de} ${ie.message}`});navigator.clipboard.writeText(V.join(`
|
|
537
|
-
`)).then(()=>{R(!0),setTimeout(()=>R(!1),1500)})},[X]),be=C.logs.clear.useMutation(),J=q(()=>{O(Date.now()),z.reset(),be.mutate({...P?{tags:P}:{}})},[z,be,P]),G=q(V=>{F(ie=>{const ue=new Set(ie);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),[ee,ae]=$(null),fe=q((V,ie)=>{const ue=new Date(V.timestamp).toISOString(),de=V.tags?" "+Object.entries(V.tags).filter(([,pe])=>pe).map(([pe,Ie])=>`${pe}=${Ie}`).join(" "):"",ce=V.meta&&Object.keys(V.meta).length>0?` meta=${JSON.stringify(V.meta)}`:"",Se=`${ue} [${V.level.toUpperCase()}]${V.scope?` [${V.scope}]`:""}${de} ${V.message}${ce}`;navigator.clipboard.writeText(Se).then(()=>{ae(ie),setTimeout(()=>ae(pe=>pe===ie?null:pe),1200)})},[]),he=q(V=>`${V.timestamp}|${V.level}|${V.scope??""}|${V.message}`,[]);return u("div",{className:W("h-full min-h-0 flex flex-col",m),onClick:V=>V.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Logs"}),v&&r(Za,{label:"agent",value:v}),N&&r(Za,{label:"addon",value:N}),k!==void 0&&r(Za,{label:"device",value:`#${k}`}),r("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:SE.map(V=>u("button",{type:"button",onClick:()=>w(V==="all"?void 0:V),className:W("px-1.5 py-0.5 capitalize transition-colors",V==="all"&&!y||y===V?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover",V!=="all"&&"border-l border-border"),children:[V,V!=="all"?"+":""]},V))}),r(Xa,{icon:Rl,label:I?"Auto":"Paused",active:!I,onClick:()=>{L(V=>!V),!I&&E.current&&E.current.scrollTo({top:0,behavior:"smooth"})}}),r(Xa,{icon:In,label:_?"Copied!":"Copy",onClick:oe,disabled:X.length===0}),r(Xa,{icon:Qt,label:"Clear",onClick:J}),u("div",{className:"relative",children:[r("input",{type:"text",value:j,onChange:V=>H(V.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),j&&r("button",{type:"button",onClick:()=>H(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:r(Ye,{className:"h-2.5 w-2.5"})})]}),D.length>0&&u("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",D.length," live"]})]}),p&&r("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:r(Ye,{className:"h-3.5 w-3.5"})})]}),c&&(!t||!n)&&u("div",{className:"flex items-center gap-2 px-3 py-1 border-b border-border/50 bg-surface/50 text-[10px]",children:[!t&&u("label",{className:"flex items-center gap-1",children:[r("span",{className:"text-foreground-subtle",children:"Addon:"}),r("input",{type:"text",value:h,onChange:V=>g(V.target.value),placeholder:"all",className:"w-28 px-1.5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"})]}),!n&&u("label",{className:"flex items-center gap-1",children:[r("span",{className:"text-foreground-subtle",children:"Device:"}),r("input",{type:"text",inputMode:"numeric",value:b,onChange:V=>x(V.target.value),placeholder:"all",className:"w-16 px-1.5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"})]})]}),u("div",{ref:E,className:W("flex-1 min-h-0 overflow-auto font-mono text-[10px]",i),children:[re&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[r(Lt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading logs..."]}),!re&&X.length===0&&r("div",{className:"py-4 text-center text-foreground-subtle",children:"No logs found"}),X.length>0&&r("table",{className:"w-full",children:r("tbody",{children:X.map(V=>{const ie=vu[V.level]??vu.info,ue=ie.icon,de=he(V),ce=B.has(de),Se=V.tags&&Object.keys(V.tags).length>0,pe=V.meta&&Object.keys(V.meta).length>0,Ie=Se||pe;return u("tr",{className:W("hover:bg-surface-hover/30 border-b border-border/30",Ie&&"cursor-pointer"),onClick:Ie?()=>G(de):void 0,children:[r("td",{className:"px-2 py-1 text-foreground-subtle whitespace-nowrap align-top w-[70px]",children:new Date(V.timestamp).toLocaleTimeString()}),r("td",{className:W("px-1 py-1 align-top w-5",ie.color),children:r(ue,{className:"h-3 w-3"})}),l&&r("td",{className:"px-2 py-1 text-foreground-subtle align-top truncate max-w-[120px]",title:V.scope,children:V.scope?.replace(/^addon:/,"")??""}),r("td",{className:"px-2 py-1 text-foreground break-all",children:u("div",{className:"flex items-start gap-1",children:[Ie&&(ce?r(Xn,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"}):r(Mn,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"})),u("div",{className:"flex-1 min-w-0",children:[V.message,ce&&Ie&&u("div",{className:"mt-1 text-[9px] text-foreground-subtle bg-surface rounded px-2 py-1 space-y-0.5",children:[pe&&Object.entries(V.meta).filter(([,Te])=>Te!==void 0&&Te!=="").map(([Te,We])=>u("div",{children:[r("span",{className:"text-amber-400/80 font-medium",children:Te}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground break-all",children:yu(We)})]},`m-${Te}`)),Se&&Object.entries(V.tags).filter(([,Te])=>Te!==void 0).map(([Te,We])=>u("div",{children:[r("span",{className:"text-primary/70 font-medium",children:Te}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground",children:We})]},`t-${Te}`))]})]})]})}),r("td",{className:"px-1 py-1 align-top w-5",children:r(IE,{copied:ee===de,onCopy:()=>fe(V,de)})})]},de)})})})]})]})}function Ax({position:e="bottom",className:t,...n}){return r("div",{className:W(e==="bottom"?"absolute bottom-0 left-0 right-0 z-10 border-t border-border bg-surface/95 backdrop-blur-sm":"absolute inset-x-2 bottom-2 z-10 rounded-lg border border-border bg-surface/95 backdrop-blur-sm shadow-xl",t),children:r(Wt,{maxHeight:"max-h-48",...n})})}function Za({label:e,value:t}){return u("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function IE({copied:e,onCopy:t}){return r("button",{type:"button",title:"Copy this row",onClick:n=>{n.stopPropagation(),t()},className:W("rounded p-0.5 transition-colors",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?r(ko,{className:"h-3 w-3"}):r(In,{className:"h-3 w-3"})})}function Xa({icon:e,label:t,onClick:n,disabled:o,active:s}){return u("button",{type:"button",onClick:n,disabled:o,className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",s?"border-amber-500/30 bg-amber-500/10 text-amber-400":"border-border text-foreground-subtle hover:text-foreground",o&&"opacity-40 cursor-not-allowed"),children:[r(e,{className:"h-2.5 w-2.5"}),t]})}function AE(e,t,n,o){if(o!==void 0&&(e.source.deviceId??(e.source.type==="device"&&typeof e.source.id=="number"?e.source.id:void 0))!==o||n!==void 0&&(e.source.addonId??(e.source.type==="addon"&&typeof e.source.id=="string"?e.source.id:void 0))!==n)return!1;if(t!==void 0){const s=e.source.nodeId;if(!s||s!==t&&!s.startsWith(`${t}/`))return!1}return!0}const PE={[Ne.AddonStarted]:{icon:ji,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Started"},[Ne.AddonInstalled]:{icon:Bi,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Installed"},[Ne.AddonRestarted]:{icon:Bl,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Restarted"},[Ne.AddonUpdated]:{icon:Om,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Updated"},[Ne.AddonStopped]:{icon:Qd,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Stopped"},[Ne.AddonUninstalled]:{icon:Qt,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Uninstalled"},[Ne.AddonCrashed]:{icon:ea,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Crashed"},[Ne.AddonError]:{icon:Mo,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Error"},[Ne.DetectionPhaseTransition]:{icon:vn,color:"bg-violet-500/15 text-violet-400 border-violet-500/30",label:"Phase"},[Ne.DetectionResult]:{icon:$k,color:"bg-purple-500/15 text-purple-400 border-purple-500/30",label:"Detection"},[Ne.DetectionEvent]:{icon:So,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Event"},[Ne.DetectionCameraNative]:{icon:Kd,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Camera AI"},[Ne.ProviderMotion]:{icon:Gd,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Ne.MotionOnMotionChanged]:{icon:Gd,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Ne.MotionAnalysis]:{icon:vn,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion analysis"},[Ne.MotionZonesRaw]:{icon:vn,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion zones"},[Ne.ProviderDetection]:{icon:Kd,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Provider Det"},[Ne.PipelineAudioInferenceResult]:{icon:$m,color:"bg-pink-500/15 text-pink-400 border-pink-500/30",label:"Audio"},[Ne.AgentOnline]:{icon:ji,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Agent Online"},[Ne.AgentOffline]:{icon:Qd,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Agent Offline"},[Ne.DeviceRegistered]:{icon:Bi,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Registered"},[Ne.DeviceUnregistered]:{icon:Qt,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Unregistered"},[Ne.DeviceStateChanged]:{icon:vn,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"State"}};function Wi(e,t){const n=PE[e]??{icon:ji,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:e.split(".").pop()??e};if(e===Ne.DeviceStateChanged&&t&&typeof t.capName=="string"){const o=t.capName;return{...n,label:o}}return n}const ir=Object.freeze([...new Set(Object.values(Ne))].sort()),EE=Object.freeze([Ne.PipelineCameraMetricsSnapshot,Ne.PipelineRunnerLoadSnapshot,Ne.PipelineEngineMetricsSnapshot,Ne.PipelineInferenceResult,Ne.PipelineTrace,Ne.PipelineProgress,Ne.StreamBrokerMetricsSnapshot,Ne.MetricsNodeResourcesSnapshot,Ne.MetricsNodeProcessesSnapshot,Ne.ClusterTopologySnapshot,Ne.MotionAnalysis,Ne.MotionZonesRaw,Ne.DetectionResult,Ne.PipelineAudioInferenceResult,Ne.PlatformProbePhase,Ne.BenchmarkProgress,Ne.ModelDownloadProgress]),$E=new Set(EE),_E=Object.freeze(ir.filter(e=>!$E.has(e)));function bs(e,t){if(e===Ne.DetectionPhaseTransition){const s=t.to,a=t.from,i=typeof t.source=="string"?t.source:null,l=typeof t.cooldownMs=="number"?t.cooldownMs:null,c=i?` (${i}${l?`, ${Math.round(l/1e3)}s cooldown`:""})`:"";return s==="active"?`Motion detected — phase active${c}`:s==="watching"?`Cooldown expired — phase watching${c}`:`Phase: ${String(a)} → ${String(s)}${c}`}if(e===Ne.DetectionResult){const a=t.frame?.detections??[];if(a.length===0)return null;const i=new Map;for(const l of a){const c=l,d=c.class??c.macroClass,f=typeof d=="string"?d:"";f&&i.set(f,(i.get(f)??0)+1)}return[...i.entries()].map(([l,c])=>c>1?`${l} ×${c}`:l).join(", ")}if(e===Ne.PipelineAudioInferenceResult){const a=t.frame?.detections??[];return a.length===0?null:a.map(i=>{const l=i,c=l.macroClass??l.class??l.label,d=typeof c=="string"?c:"",f=l.score;return f?`${d} (${Math.round(f*100)}%)`:d}).filter(Boolean).join(", ")}if(e===Ne.DetectionEvent){const s=t.label??t.class,a=t.score??t.confidence,i=[];return typeof s=="string"&&i.push(s),typeof a=="number"&&i.push(`${Math.round(a*100)}%`),i.length>0?i.join(" — "):null}if(e===Ne.ProviderMotion)return t.active===!0?"motion start":"motion stop";if(e===Ne.DeviceStateChanged){const s=t.slice;if(s&&typeof s=="object"){const a=Object.keys(s).filter(i=>i!=="lastFetchedAt"&&i!=="ts");if(a.length>0)return a.slice(0,4).join(", ")+(a.length>4?"…":"")}return null}if(e===Ne.MotionOnMotionChanged){const s=t.detected,a=typeof t.source=="string"?t.source:null,i=s===!0?"motion start":s===!1?"motion stop":"motion";return a?`${i} (${a})`:i}if(e===Ne.ProviderDetection||e===Ne.DetectionCameraNative){const s=t.detections??[];if(!Array.isArray(s)||s.length===0)return(typeof t.class=="string"?t.class:null)??null;const a=new Map;for(const i of s){const l=i,c=l.class??l.macroClass,d=typeof c=="string"?c:"";d&&a.set(d,(a.get(d)??0)+1)}return[...a.entries()].map(([i,l])=>l>1?`${i} ×${l}`:i).join(", ")}const n=t.addonId,o=t.error;return o||(n?`addon: ${n}`:null)}function DE(e){const t=e.category;return t===Ne.DetectionResult||t===Ne.PipelineAudioInferenceResult?bs(t,e.data)!==null:!0}const LE=300;function or({agentId:e,addonId:t,deviceId:n,defaultCategories:o,categories:s,category:a,maxHeight:i="max-h-96",limit:l=50,showCategoryFilter:c=!0,showFilters:d=!1,liveBuffer:f,onClose:p,className:m}){const h=U(()=>o??s??_E,[o,s]),g=U(()=>[...h].sort().join(","),[h]),[b,x]=$(()=>new Set(h)),y=ne(g);Z(()=>{y.current!==g&&(y.current=g,x(new Set(h)))},[g,h]);const w=zn(LE),v=f??w,N=v.entries,[k,S]=$(!0),[M,P]=$(new Set),[A,z]=$(""),[D,T]=$(!1),[O,I]=$(""),[L,_]=$(0),R=ne(null),B=ne(null),F=`${e??""}:${t??""}:${String(n??"")}:${a??""}`,j=ne(F);Z(()=>{j.current!==F&&(j.current=F,v.reset(),P(new Set),_(0))},[F,v]),Z(()=>{if(!D)return;const me=Ee=>{const De=B.current;De&&Ee.target instanceof Node&&!De.contains(Ee.target)&&T(!1)};return document.addEventListener("mousedown",me),()=>{document.removeEventListener("mousedown",me)}},[D]);const H=U(()=>{const me={};return e&&(me.agentId=e),t&&(me.addonId=t),n!==void 0&&(me.deviceId=n),a&&(me.category=a),me},[e,t,n,a]),E=U(()=>[...b].sort(),[b]),Q=U(()=>E.join(","),[E]),K=U(()=>{const me={...H,limit:l};return E.length>0&&E.length<ir.length&&(me.category=E),me},[H,l,Q,E]),{data:Y,isLoading:re}=C.systemEvents.getRecent.useQuery(K,{staleTime:3e4}),te=ne(b);Z(()=>{te.current=b},[b]);const X=H;C.systemEvents.subscribe.useSubscription(X,{onData:me=>{const Ee=me;Ee?.id&&AE(Ee,e,t,n)&&te.current.has(Ee.category)&&v.append(Ee)}});const oe=ne(N.length);Z(()=>{const me=R.current;if(!me){oe.current=N.length;return}const Ee=oe.current;if(oe.current=N.length,!(N.length<=Ee)){if(k&&me.scrollTop<=8)me.scrollTo({top:0});else if(!k&&me.scrollTop>0){const De=me.firstElementChild?.firstElementChild,Re=De instanceof HTMLElement?De.offsetHeight:28;me.scrollTop+=Re*(N.length-Ee)}}},[N.length,k]);const be=U(()=>{const me=new Map;for(const Re of Y??[])me.set(Re.id,Re);for(const Re of N)me.set(Re.id,Re);let Ee=[...me.values()].filter(Re=>b.has(Re.category)).filter(DE);L>0&&(Ee=Ee.filter(Re=>new Date(Re.timestamp).getTime()>L));const De=A.trim().toLowerCase();return De&&(Ee=Ee.filter(Re=>{if(Re.category.toLowerCase().includes(De)||Wi(Re.category,Re.data).label.toLowerCase().includes(De))return!0;const En=bs(Re.category,Re.data);if(En&&En.toLowerCase().includes(De))return!0;try{if(new Date(Re.timestamp).toLocaleTimeString().toLowerCase().includes(De))return!0}catch{}try{if(JSON.stringify(Re.data).toLowerCase().includes(De)||JSON.stringify(Re.source).toLowerCase().includes(De))return!0}catch{}return!1})),Ee.sort((Re,Pn)=>new Date(Pn.timestamp).getTime()-new Date(Re.timestamp).getTime())},[Y,N,b,A,L]),J=q(me=>{P(Ee=>{const De=new Set(Ee);return De.has(me)?De.delete(me):De.add(me),De})},[]),G=q(me=>{x(Ee=>{const De=new Set(Ee);return De.has(me)?De.delete(me):De.add(me),De})},[]),ee=q(()=>{x(new Set(h)),z(""),_(0)},[h]),ae=q(()=>{_(Date.now()),v.reset()},[v]),[fe,he]=$(!1),[V,ie]=$(null),ue=q(me=>{const Ee=new Date(me.timestamp).toISOString(),De=bs(me.category,me.data)??"",Re=De?` ${De}`:"";return`${Ee} [${me.category}]${Re} data=${JSON.stringify(me.data)}`},[]),de=q(()=>{const me=be.map(ue);navigator.clipboard.writeText(me.join(`
|
|
538
|
-
`)).then(()=>{he(!0),setTimeout(()=>he(!1),1500)})},[be,ue]),ce=q(me=>{navigator.clipboard.writeText(ue(me)).then(()=>{ie(me.id),setTimeout(()=>ie(Ee=>Ee===me.id?null:Ee),1200)})},[ue]),Se=q(()=>{x(new Set(ir))},[]),pe=q(()=>{x(new Set)},[]),Ie=U(()=>{const me=O.trim().toLowerCase();return me?ir.filter(Ee=>Ee.toLowerCase().includes(me)):ir},[O]),Te=ir.length,We=b.size,rt=We===Te,sr=rt?"All":`${We}/${Te}`;return u("div",{className:W("h-full min-h-0 flex flex-col",m),onClick:me=>me.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Events"}),e&&r(Uo,{label:"agent",value:e}),t&&r(Uo,{label:"addon",value:t}),n!==void 0&&r(Uo,{label:"device",value:`#${n}`}),a&&r(Uo,{label:"category",value:a}),u("button",{type:"button",onClick:()=>{S(me=>!me),!k&&R.current&&R.current.scrollTo({top:0,behavior:"smooth"})},className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",k?"border-border text-foreground-subtle hover:text-foreground":"border-amber-500/30 bg-amber-500/10 text-amber-400"),children:[r(Rl,{className:"h-2.5 w-2.5"}),k?"Auto":"Paused"]}),c&&u("div",{className:"relative",ref:B,children:[u("button",{type:"button",onClick:()=>T(me=>!me),className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",rt?"border-border text-foreground-subtle hover:text-foreground":"border-violet-500/30 bg-violet-500/10 text-violet-400"),title:"Pick events to track",children:[r(Am,{className:"h-2.5 w-2.5"}),"Filter (",sr,")"]}),D&&r(TE,{search:O,onSearchChange:I,categories:Ie,active:b,onToggle:G,onSelectAll:Se,onSelectNone:pe,onResetDefaults:ee})]}),u("button",{type:"button",onClick:ee,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Reset filters to defaults",children:[r(Lm,{className:"h-2.5 w-2.5"}),"Reset"]}),u("button",{type:"button",onClick:ae,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Clear visible entries",children:[r(Qt,{className:"h-2.5 w-2.5"}),"Clear"]}),u("button",{type:"button",onClick:de,disabled:be.length===0,className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",fe?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",be.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible events",children:[r(In,{className:"h-2.5 w-2.5"}),fe?"Copied!":"Copy"]}),u("div",{className:"relative",children:[r("input",{type:"text",value:A,onChange:me=>z(me.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),A&&r("button",{type:"button",onClick:()=>z(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:r(Ye,{className:"h-2.5 w-2.5"})})]}),N.length>0&&u("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",N.length," live"]})]}),p&&r("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:r(Ye,{className:"h-3.5 w-3.5"})})]}),u("div",{ref:R,className:W("flex-1 min-h-0 overflow-auto text-[10px]",i),children:[re&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[r(Lt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading events..."]}),!re&&be.length===0&&r("div",{className:"py-4 text-center text-foreground-subtle",children:"No events found"}),be.length>0&&r("div",{className:"divide-y divide-border/30",children:be.map(me=>{const Ee=Wi(me.category,me.data),De=Ee.icon,Re=bs(me.category,me.data),Pn=M.has(me.id);return u("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>J(me.id),children:[r("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(me.timestamp).toLocaleTimeString()}),r(OE,{copied:V===me.id,onCopy:()=>ce(me)}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5",children:[Pn?r(Xn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):r(Mn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),u("span",{className:W("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[9px] font-medium",Ee.color),children:[r(De,{className:"h-2.5 w-2.5"}),Ee.label]}),me.source.nodeId&&me.source.nodeId!=="hub"&&r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-foreground-subtle/10 text-foreground-subtle font-mono",children:me.source.nodeId})]}),Re&&r("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5",children:Re}),Pn&&u("div",{className:"mt-1 ml-5 text-[9px] bg-surface rounded px-2 py-1.5 space-y-0.5 font-mono overflow-x-auto",children:[u("div",{children:[r("span",{className:"text-primary/70",children:"source"}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground",children:JSON.stringify(me.source)})]}),u("div",{children:[r("span",{className:"text-primary/70",children:"category"}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground",children:me.category})]}),Object.entries(me.data).map(([En,zr])=>u("div",{children:[r("span",{className:"text-primary/70",children:En}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground break-all",children:typeof zr=="object"?JSON.stringify(zr):String(zr)})]},En))]})]})]},me.id)})})]})]})}function TE({search:e,onSearchChange:t,categories:n,active:o,onToggle:s,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return u("div",{className:"absolute z-20 top-full mt-1 left-0 w-72 max-h-80 rounded-md border border-border bg-surface shadow-lg flex flex-col",onClick:c=>c.stopPropagation(),children:[u("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[r(so,{className:"h-3 w-3 text-foreground-subtle"}),r("input",{type:"text",value:e,onChange:c=>t(c.target.value),placeholder:"Filter categories…",className:"flex-1 bg-transparent text-[10px] focus:outline-none text-foreground placeholder:text-foreground-subtle",autoFocus:!0}),e&&r("button",{type:"button",onClick:()=>t(""),className:"text-foreground-subtle hover:text-foreground",children:r(Ye,{className:"h-2.5 w-2.5"})})]}),u("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[r("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),r("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),r("button",{type:"button",onClick:l,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),u("div",{className:"overflow-y-auto flex-1",children:[n.length===0&&r("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),n.map(c=>{const d=o.has(c),f=Wi(c),p=f.icon;return u("button",{type:"button",onClick:()=>s(c),className:"w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]",children:[r("input",{type:"checkbox",readOnly:!0,checked:d,className:"accent-violet-500"}),u("span",{className:W("inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[9px] font-medium shrink-0",f.color),children:[r(p,{className:"h-2.5 w-2.5"}),f.label]}),r("span",{className:"text-foreground-subtle font-mono truncate",children:c})]},c)})]})]})}function RE({position:e="bottom",className:t,...n}){return r("div",{className:W(e==="bottom"?"absolute bottom-0 left-0 right-0 z-10 border-t border-border bg-surface/95 backdrop-blur-sm":"absolute inset-x-2 bottom-2 z-10 rounded-lg border border-border bg-surface/95 backdrop-blur-sm shadow-xl",t),children:r(or,{maxHeight:"max-h-48",...n})})}function Uo({label:e,value:t}){return u("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function OE({copied:e,onCopy:t}){return r("button",{type:"button",title:"Copy this event",onClick:n=>{n.stopPropagation(),t()},className:W("rounded p-0.5 transition-colors mt-0.5",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?r(ko,{className:"h-3 w-3"}):r(In,{className:"h-3 w-3"})})}function Px({deviceId:e,className:t="",onOpenChild:n}){const o=C.useUtils(),s=C.deviceDiscovery.listDiscovered.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),a=C.deviceDiscovery.getStatus.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),i=C.deviceDiscovery.refreshDiscovery.useMutation({onSuccess:()=>{o.deviceDiscovery.listDiscovered.invalidate({deviceId:e}),o.deviceDiscovery.getStatus.invalidate({deviceId:e})}}),l=C.deviceDiscovery.adoptDevice.useMutation({onSuccess:()=>{o.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),c=C.deviceDiscovery.releaseDevice.useMutation({onSuccess:()=>{o.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),[d,f]=$(null),{available:p,adopted:m}=U(()=>{const v=s.data??[],N=S=>typeof S.metadata.rtspChannel=="number"?S.metadata.rtspChannel:Number.POSITIVE_INFINITY,k=(S,M)=>{const P=N(S),A=N(M);return P!==A?P-A:S.name.localeCompare(M.name)};return{available:v.filter(S=>!S.alreadyAdopted).sort(k),adopted:v.filter(S=>S.alreadyAdopted).sort(k)}},[s.data]),h=a.data,g=h?.lastError??null,b=h?.lastDiscoveryAt??null;async function x(){await i.mutateAsync({deviceId:e}).catch(()=>{})}async function y(v){f(v.childNativeId);try{await l.mutateAsync({deviceId:e,childNativeId:v.childNativeId})}finally{f(null)}}async function w(v){if(v.adoptedDeviceId!=null){f(v.childNativeId);try{await c.mutateAsync({deviceId:e,childDeviceId:v.adoptedDeviceId})}finally{f(null)}}}return u("div",{className:`rounded-xl border border-border bg-surface ${t}`,children:[u("div",{className:"flex items-start justify-between gap-2 border-b border-border px-3 py-2 sm:px-5 sm:py-3",children:[u("div",{className:"min-w-0",children:[r("h3",{className:"text-sm font-semibold text-foreground",children:"Discovered devices"}),u("p",{className:"text-[11px] text-foreground-subtle",children:["Channels behind this hub. Click ",r("span",{className:"font-medium",children:"Add"})," to promote a channel to a managed device, or ",r("span",{className:"font-medium",children:"Remove"})," to detach."]})]}),u("button",{type:"button",onClick:x,disabled:i.isPending,className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-2 py-1.5 sm:px-3 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 shrink-0",children:[i.isPending?r(Lt,{className:"h-3.5 w-3.5 animate-spin"}):r(Bl,{className:"h-3.5 w-3.5"}),r("span",{className:"hidden sm:inline",children:"Refresh"})]})]}),g?u("div",{className:"flex items-start gap-2 border-b border-border bg-destructive/10 px-5 py-2 text-[11px] text-destructive",children:[r(Mo,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),u("span",{children:["Last refresh failed: ",g]})]}):null,s.isLoading?r("div",{className:"flex items-center justify-center py-8 text-foreground-subtle",children:r(Lt,{className:"h-5 w-5 animate-spin"})}):p.length===0&&m.length===0?r("div",{className:"px-5 py-8 text-center text-xs text-foreground-subtle",children:"No channels reported by the hub yet. Click Refresh to enumerate."}):u(ge,{children:[p.length>0?r(Nu,{title:"Available to add",count:p.length,tone:"primary",children:p.map(v=>r(ku,{child:v,busy:d===v.childNativeId,onAdopt:y,onRelease:w,onOpenChild:n},v.childNativeId))}):null,m.length>0?r(Nu,{title:"Already adopted",count:m.length,tone:"muted",children:m.map(v=>r(ku,{child:v,busy:d===v.childNativeId,onAdopt:y,onRelease:w,onOpenChild:n},v.childNativeId))}):null]}),b!=null?u("div",{className:"border-t border-border px-5 py-2 text-[10px] text-foreground-subtle",children:["Last refreshed ",new Date(b).toLocaleString()]}):null]})}function Nu({title:e,count:t,tone:n,children:o}){return u("div",{className:"border-t border-border",children:[u("div",{className:`flex items-center justify-between border-b px-3 sm:px-5 py-1.5 text-[10px] uppercase tracking-wider ${n==="primary"?"bg-primary/5 text-primary border-primary/30":"bg-surface text-foreground-subtle border-border"}`,children:[r("span",{className:"font-semibold",children:e}),r("span",{className:"font-mono",children:t})]}),r("div",{className:"divide-y divide-border",children:o})]})}function ku({child:e,busy:t,onAdopt:n,onRelease:o,onOpenChild:s}){return u("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2 sm:px-5 sm:py-3 sm:flex-nowrap sm:gap-3",children:[u("div",{className:"min-w-0 flex-1",children:[u("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[r(zE,{status:e.status}),r("span",{className:"truncate text-sm font-medium text-foreground",children:e.name}),e.metadata.isDoorbell?r("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Doorbell"}):null,e.metadata.isBattery?r("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Battery"}):null,e.metadata.isMultifocal?r("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Multifocal"}):null]}),u("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-foreground-subtle",children:[typeof e.metadata.rtspChannel=="number"?u("span",{children:["ch ",r("span",{className:"font-mono",children:e.metadata.rtspChannel})]}):null,e.metadata.model?r("span",{className:"truncate max-w-[160px]",children:e.metadata.model}):null,e.metadata.uid?u("span",{className:"font-mono truncate max-w-[140px]",children:[e.metadata.uid.slice(0,12),"…"]}):null]})]}),e.alreadyAdopted?u("div",{className:"flex items-center gap-2",children:[s&&e.adoptedDeviceId!==null?u("button",{type:"button",onClick:()=>s(e.adoptedDeviceId),className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",title:"Open device detail",children:[r(Mm,{className:"h-3.5 w-3.5"}),"Open"]}):null,u("button",{type:"button",onClick:()=>{o(e)},disabled:t,className:"inline-flex items-center gap-1.5 rounded-lg border border-destructive/30 px-3 py-1.5 text-xs text-destructive hover:bg-destructive/10 transition-colors disabled:opacity-50",children:[t?r(Lt,{className:"h-3.5 w-3.5 animate-spin"}):r(Qt,{className:"h-3.5 w-3.5"}),"Remove"]})]}):u("button",{type:"button",onClick:()=>{n(e)},disabled:t,className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:[t?r(Lt,{className:"h-3.5 w-3.5 animate-spin"}):r(Co,{className:"h-3.5 w-3.5"}),"Add"]})]})}function zE({status:e}){switch(e){case"online":return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-emerald-500/40 bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-500",children:[r(zm,{className:"h-2.5 w-2.5"})," online"]});case"sleeping":return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-500",children:[r(zl,{className:"h-2.5 w-2.5"})," sleeping"]});case"offline":return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-destructive/40 bg-destructive/10 px-2 py-0.5 text-[10px] font-medium text-destructive",children:[r(l5,{className:"h-2.5 w-2.5"})," offline"]});case"unknown":default:return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-border bg-surface px-2 py-0.5 text-[10px] font-medium text-foreground-subtle",children:[r(Nm,{className:"h-2.5 w-2.5"})," unknown"]})}}function BE(e,t){if(!e||typeof e!="object")return!1;const n=e;if(n.category!==Ne.DeviceStateChanged)return!1;const o=n.data;return!(!o||typeof o!="object"||o.deviceId!==t||typeof o.capName!="string"||!o.slice||typeof o.slice!="object")}function Ja(e){if(!e||typeof e!="object")return null;const t=e,n=typeof t.id=="string"?t.id:null,o=typeof t.timestamp=="string"?t.timestamp:null,s=t.data;return!n||!o||!s||typeof s!="object"||typeof s.capName!="string"||!s.slice||typeof s.slice!="object"?null:{id:n,timestamp:o,capName:s.capName,slice:s.slice}}const FE=300,jE=Object.freeze([...new Set(lw.filter(e=>e.scope==="device").map(e=>e.name))].sort());function _c({deviceId:e,defaultCaps:t,maxHeight:n="max-h-96",limit:o=50,liveBuffer:s,onClose:a,className:i}){const l=U(()=>new Set(t??[]),[t]),[c,d]=$(l),[f,p]=$(""),[m,h]=$(!0),[g,b]=$(new Set),[x,y]=$(0),[w,v]=$(!1),[N,k]=$(""),S=ne(null),M=zn(FE),P=s??M,A=P.entries,z=ne(null),D=ne(e);Z(()=>{D.current!==e&&(D.current=e,P.reset(),b(new Set),y(0))},[e,P]);const T=U(()=>({deviceId:e,category:Ne.DeviceStateChanged,limit:o}),[e,o]),{data:O,isLoading:I}=C.systemEvents.getRecent.useQuery(T,{staleTime:3e4}),L=ne(c);Z(()=>{L.current=c},[c]),C.systemEvents.subscribe.useSubscription({deviceId:e,category:Ne.DeviceStateChanged},{onData:V=>{if(!BE(V,e))return;const ie=Ja(V);if(!ie)return;const ue=L.current;ue.size>0&&!ue.has(ie.capName)||P.append(ie)}});const _=ne(A.length);Z(()=>{const V=z.current;if(!V){_.current=A.length;return}const ie=_.current;if(_.current=A.length,!(A.length<=ie)){if(m&&V.scrollTop<=8)V.scrollTo({top:0});else if(!m&&V.scrollTop>0){const ue=V.firstElementChild?.firstElementChild,de=ue instanceof HTMLElement?ue.offsetHeight:28,ce=A.length-ie;V.scrollTop+=de*ce}}},[A.length,m]);const R=U(()=>{const V=new Map;for(const de of O??[]){const ce=Ja(de);ce&&V.set(ce.id,ce)}for(const de of A)V.set(de.id,de);let ie=[...V.values()];x>0&&(ie=ie.filter(de=>new Date(de.timestamp).getTime()>x)),c.size>0&&(ie=ie.filter(de=>c.has(de.capName)));const ue=f.trim().toLowerCase();return ue&&(ie=ie.filter(de=>{if(de.capName.toLowerCase().includes(ue))return!0;try{if(new Date(de.timestamp).toLocaleTimeString().toLowerCase().includes(ue))return!0}catch{}try{if(Object.entries(de.slice).map(([Se,pe])=>`${Se}=${ei(pe)}`).join(" · ").toLowerCase().includes(ue))return!0}catch{}try{if(JSON.stringify(de.slice).toLowerCase().includes(ue))return!0}catch{}return!1})),ie.sort((de,ce)=>new Date(ce.timestamp).getTime()-new Date(de.timestamp).getTime())},[O,A,c,f,x]),B=U(()=>{const V=new Set(jE);for(const ie of O??[]){const ue=Ja(ie);ue&&V.add(ue.capName)}for(const ie of A)V.add(ie.capName);return[...V].sort()},[O,A]),F=q(V=>{b(ie=>{const ue=new Set(ie);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),j=q(V=>{d(ie=>{const ue=new Set(ie);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),H=q(()=>{d(new Set(t??[])),p("")},[t]),E=q(()=>{y(Date.now()),P.reset()},[P]),[Q,K]=$(!1),[Y,re]=$(null),te=q(V=>`${new Date(V.timestamp).toISOString()} [${V.capName}] slice=${JSON.stringify(V.slice)}`,[]),X=q(()=>{const V=R.map(te);navigator.clipboard.writeText(V.join(`
|
|
539
|
-
`)).then(()=>{K(!0),setTimeout(()=>K(!1),1500)})},[R,te]),oe=q(V=>{navigator.clipboard.writeText(te(V)).then(()=>{re(V.id),setTimeout(()=>re(ie=>ie===V.id?null:ie),1200)})},[te]),be=q(()=>{d(new Set(B))},[B]),J=q(()=>{d(new Set)},[]),G=U(()=>{const V=N.trim().toLowerCase();return V?B.filter(ie=>ie.toLowerCase().includes(V)):B},[N,B]),ee=B.length,ae=c.size,fe=ae===0||ae===ee,he=fe?"All":`${ae}/${ee}`;return Z(()=>{if(!w)return;const V=ie=>{const ue=S.current;ue&&!ue.contains(ie.target)&&v(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[w]),u("div",{className:W("h-full min-h-0 flex flex-col",i),onClick:V=>V.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"State"}),r(HE,{label:"device",value:`#${e}`}),u("button",{type:"button",onClick:()=>{h(V=>!V),!m&&z.current&&z.current.scrollTo({top:0,behavior:"smooth"})},className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",m?"border-border text-foreground-subtle hover:text-foreground":"border-amber-500/30 bg-amber-500/10 text-amber-400"),children:[r(Rl,{className:"h-2.5 w-2.5"}),m?"Auto":"Paused"]}),u("div",{className:"relative",ref:S,children:[u("button",{type:"button",onClick:()=>v(V=>!V),className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",fe?"border-border text-foreground-subtle hover:text-foreground":"border-violet-500/30 bg-violet-500/10 text-violet-400"),title:"Pick caps to track",children:[r(Am,{className:"h-2.5 w-2.5"}),"Filter (",he,")"]}),w&&r(VE,{search:N,onSearchChange:k,caps:G,active:c,onToggle:j,onSelectAll:be,onSelectNone:J,onResetDefaults:H})]}),u("button",{type:"button",onClick:H,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Reset filters",children:[r(Lm,{className:"h-2.5 w-2.5"}),"Reset"]}),u("button",{type:"button",onClick:E,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Clear visible entries",children:[r(Qt,{className:"h-2.5 w-2.5"}),"Clear"]}),u("button",{type:"button",onClick:X,disabled:R.length===0,className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",Q?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",R.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible state changes",children:[r(In,{className:"h-2.5 w-2.5"}),Q?"Copied!":"Copy"]}),u("div",{className:"relative",children:[r("input",{type:"text",value:f,onChange:V=>p(V.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),f&&r("button",{type:"button",onClick:()=>p(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:r(Ye,{className:"h-2.5 w-2.5"})})]}),A.length>0&&u("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",A.length," live"]})]}),a&&r("button",{type:"button",onClick:a,className:"text-foreground-subtle hover:text-foreground",children:r(Ye,{className:"h-3.5 w-3.5"})})]}),u("div",{ref:z,className:W("flex-1 min-h-0 overflow-auto text-[10px]",n),children:[I&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[r(Lt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading state changes..."]}),!I&&R.length===0&&r("div",{className:"py-4 text-center text-foreground-subtle",children:"No state changes"}),R.length>0&&r("div",{className:"divide-y divide-border/30",children:R.map(V=>{const ie=g.has(V.id),ue=Object.entries(V.slice),de=ue.slice(0,3).map(([ce,Se])=>`${ce}=${ei(Se)}`).join(" · ");return u("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>F(V.id),children:[r("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(V.timestamp).toLocaleTimeString()}),r(qE,{copied:Y===V.id,onCopy:()=>oe(V)}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5",children:[ie?r(Xn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):r(Mn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),r("span",{className:"inline-flex items-center gap-1 rounded-full border border-violet-500/30 bg-violet-500/15 text-violet-400 px-2 py-0.5 text-[9px] font-medium",children:V.capName}),ue.length>3&&u("span",{className:"text-[9px] text-foreground-subtle",children:["+",ue.length-3," more"]})]}),de&&r("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5 truncate",children:de}),ie&&r("div",{className:"mt-1 ml-5 text-[9px] bg-surface rounded px-2 py-1.5 space-y-0.5 font-mono overflow-x-auto",children:ue.length===0?r("div",{className:"text-foreground-subtle italic",children:"empty slice"}):ue.map(([ce,Se])=>u("div",{children:[r("span",{className:"text-primary/70",children:ce}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground break-all",children:ei(Se)})]},ce))})]})]},V.id)})})]})]})}function ei(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function HE({label:e,value:t}){return u("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function VE({search:e,onSearchChange:t,caps:n,active:o,onToggle:s,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return u("div",{className:"absolute z-20 top-full mt-1 left-0 w-72 max-h-80 rounded-md border border-border bg-surface shadow-lg flex flex-col",onClick:c=>c.stopPropagation(),children:[u("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[r(so,{className:"h-3 w-3 text-foreground-subtle"}),r("input",{type:"text",value:e,onChange:c=>t(c.target.value),placeholder:"Filter caps…",className:"flex-1 bg-transparent text-[10px] focus:outline-none text-foreground placeholder:text-foreground-subtle",autoFocus:!0}),e&&r("button",{type:"button",onClick:()=>t(""),className:"text-foreground-subtle hover:text-foreground",children:r(Ye,{className:"h-2.5 w-2.5"})})]}),u("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[r("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),r("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),r("button",{type:"button",onClick:l,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),u("div",{className:"overflow-y-auto flex-1",children:[n.length===0&&r("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),n.map(c=>{const d=o.has(c);return u("button",{type:"button",onClick:()=>s(c),className:"w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]",children:[r("input",{type:"checkbox",readOnly:!0,checked:d,className:"accent-violet-500"}),r("span",{className:"inline-flex items-center gap-1 rounded-full border border-violet-500/30 bg-violet-500/15 text-violet-400 px-1.5 py-0.5 text-[9px] font-medium shrink-0",children:c})]},c)})]})]})}function qE({copied:e,onCopy:t}){return r("button",{type:"button",title:"Copy this state change",onClick:n=>{n.stopPropagation(),t()},className:W("rounded p-0.5 transition-colors mt-0.5",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?r(ko,{className:"h-3 w-3"}):r(In,{className:"h-3 w-3"})})}const ti=500,UE=[{id:"logs",label:"Logs",icon:Dk},{id:"events",label:"Events",icon:Js},{id:"state",label:"State",icon:T2}];function QE({deviceId:e,defaultEventCategories:t,defaultStateCaps:n,initialTab:o="events",className:s,maxHeight:a="max-h-96"}){const[i,l]=$(o),c=zn(ti),d=zn(ti),f=zn(ti),p=c.reset,m=d.reset,h=f.reset;return Z(()=>{p(),m(),h()},[e,p,m,h]),u("div",{className:W("flex flex-col h-full min-h-0",s),children:[r("div",{className:"flex items-center gap-1 mb-2 shrink-0",children:UE.map(({id:g,label:b,icon:x})=>u("button",{type:"button",onClick:()=>l(g),className:W("inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[11px] font-medium transition-colors",i===g?"bg-primary/15 text-primary border border-primary/30":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover border border-transparent"),children:[r(x,{className:"h-3.5 w-3.5"}),b]},g))}),u("div",{className:"flex-1 min-h-0 overflow-hidden",children:[i==="logs"&&r(Wt,{deviceId:e,maxHeight:a,showFilters:!1,liveBuffer:c}),i==="events"&&r(or,{deviceId:e,defaultCategories:t,maxHeight:a,showCategoryFilter:!0,liveBuffer:d}),i==="state"&&r(_c,{deviceId:e,defaultCaps:n,maxHeight:a,liveBuffer:f})]})]})}function Ex({label:e,icon:t,title:n="Confirm action",description:o,confirmLabel:s,triggerVariant:a="outline",confirmVariant:i="danger",size:l="sm",disabled:c,className:d,action:f,onSuccess:p}){const[m,h]=$(!1),[g,b]=$(!1),[x,y]=$(null),w=async()=>{y(null),b(!0);try{const v=await f();p?.(v),h(!1)}catch(v){y(v instanceof Error?v.message:String(v))}finally{b(!1)}};return u(ge,{children:[u(Ue,{type:"button",variant:a,size:l,disabled:c,onClick:()=>{y(null),h(!0)},className:d,children:[t&&r(t,{className:"h-3.5 w-3.5"}),e]}),r(qm,{open:m,onOpenChange:v=>!g&&h(v),children:u(Ul,{children:[u(Um,{children:[u(Km,{className:"flex items-center gap-2",children:[r(Mo,{className:"h-4 w-4 text-amber-400"}),n]}),typeof o=="string"?r(Gm,{children:o}):o]}),x&&r("div",{className:W("mt-2 px-3 py-2 rounded border border-danger/40 bg-danger/10","text-xs text-danger"),children:x}),u(Qm,{children:[r(Ue,{type:"button",variant:"ghost",size:l,disabled:g,onClick:()=>h(!1),children:"Cancel"}),u(Ue,{type:"button",variant:i,size:l,disabled:g,onClick:()=>{w()},children:[g&&r(Lt,{className:"h-3.5 w-3.5 animate-spin"}),s??e]})]})]})})]})}function Qo({direction:e,icon:t,disabled:n,className:o,variant:s,onMove:a,onStart:i,onStop:l}){const[c,d]=$(null),[f,p]=$(!1),m=q(w=>{if(n)return;w.currentTarget.setPointerCapture(w.pointerId),d(Date.now()),p(!1);const v=setTimeout(()=>{p(!0),i(e)},250);w.currentTarget.dataset.timer=String(v)},[e,n,i]),h=q(w=>{const v=Number(w.currentTarget.dataset.timer);v&&clearTimeout(v),w.currentTarget.dataset.timer="",f?l():c!==null&&a(e),d(null),p(!1)},[f,e,a,l,c]),g=q(w=>{const v=Number(w.currentTarget.dataset.timer);v&&clearTimeout(v),w.currentTarget.dataset.timer="",f&&l(),d(null),p(!1)},[f,l]),b=s==="panel"?"h-9 w-9":"h-7 w-7",x=s==="panel"?"h-4 w-4":"h-3.5 w-3.5";return r("button",{type:"button",disabled:n,onPointerDown:m,onPointerUp:h,onPointerCancel:g,className:W("flex items-center justify-center rounded transition-colors disabled:opacity-40",s==="panel"?"text-foreground hover:bg-surface-hover active:bg-surface-hover/80":"text-white hover:bg-white/15 active:bg-white/25",b,o),title:e,children:r(t,{className:x})})}function Dc({controls:e,mode:t="overlay",showPresets:n,showZoom:o=!0,showHome:s=!0,className:a}){const{move:i,startContinuous:l,stopContinuous:c,zoom:d,goHome:f,goToPreset:p,presets:m,busy:h,error:g}=e,[b,x]=$(!1),y=(n??m.length>0)&&m.length>0,w=t==="panel",v=w?"flex flex-col items-stretch gap-2 w-full h-full p-3":"pointer-events-auto absolute top-3 right-3 z-10 flex flex-col items-end gap-2",N=W(w?"flex items-center gap-3 rounded-lg p-2":"flex items-center gap-2 rounded-lg border border-white/30 bg-zinc-900/90 backdrop-blur-md p-2 shadow-lg shadow-black/40",h&&"ring-1 ring-primary/40"),k=w?"h-9 w-9":"h-7 w-7",S=w?"h-4 w-4":"h-3.5 w-3.5",M=w?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15",P=w?"h-12 w-px bg-border mx-1":"h-12 w-px bg-white/15 mx-1";return u("div",{className:W(v,a),children:[g&&u("div",{className:"rounded bg-danger/90 px-2 py-1 text-[10px] font-medium text-white shadow-lg max-w-[200px] self-center",children:["PTZ: ",g]}),u("div",{className:W(N,w&&"justify-center"),children:[u("div",{className:"grid grid-cols-3 gap-0.5",children:[r("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),r(Qo,{direction:"up",icon:KN,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),r(Qo,{direction:"left",icon:HN,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),r(Qo,{direction:"right",icon:qN,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),r(Qo,{direction:"down",icon:FN,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"})]}),(o||s)&&r("div",{className:P}),u("div",{className:"flex flex-col gap-0.5",children:[o&&u(ge,{children:[r("button",{type:"button",onClick:()=>d("in"),disabled:h,title:"Zoom in",className:W("flex items-center justify-center rounded disabled:opacity-40",k,M),children:r(m5,{className:S})}),r("button",{type:"button",onClick:()=>d("out"),disabled:h,title:"Zoom out",className:W("flex items-center justify-center rounded disabled:opacity-40",k,M),children:r(g5,{className:S})})]}),s&&r("button",{type:"button",onClick:()=>f(),disabled:h,title:"Go home",className:W("flex items-center justify-center rounded disabled:opacity-40",k,M),children:r(Pm,{className:S})})]}),y&&u("div",{className:"relative",children:[u("button",{type:"button",onClick:()=>x(A=>!A),disabled:h,className:W("flex items-center gap-1 rounded px-2 text-[10px] disabled:opacity-40",w?"h-9 text-foreground hover:bg-surface-hover":"h-7 text-white hover:bg-white/15"),title:"Presets",children:["Presets",r(Xn,{className:W("h-3 w-3 transition-transform",b&&"rotate-180")})]}),b&&r("div",{className:W("absolute right-0 min-w-[140px] rounded-lg shadow-xl py-1 z-20",w?"bottom-full mb-1 bg-surface border border-border":"top-full mt-1 border border-white/30 bg-zinc-900/95 backdrop-blur-md"),children:m.map(A=>r("button",{type:"button",onClick:()=>{p(A.id),x(!1)},disabled:h,className:W("block w-full px-3 py-1.5 text-left text-[10px] disabled:opacity-40",w?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15"),children:A.name||A.id},A.id))})]})]})]})}function KE(e,t){const n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function GE({trpc:e,deviceId:t,deviceName:n,size:o="sm",className:s}){const[a,i]=$(!1),[l,c]=$(!1),[d,f]=$(null),p=n.replace(/[^a-zA-Z0-9_.-]+/g,"_"),m=q(async k=>{i(!0),f(null),c(!1);try{const S=await e.snapshot.getSnapshot.query({deviceId:t,force:!0});if(!S)throw new Error("No snapshot available");const M=`data:${S.contentType};base64,${S.base64}`;if(k==="copy")try{await navigator.clipboard.writeText(M)}catch{throw new Error("Clipboard unavailable")}else{const P=S.contentType.includes("png")?"png":"jpg",A=new Date().toISOString().replace(/[:.]/g,"-");KE(`${p}-${A}.${P}`,M)}c(!0),setTimeout(()=>c(!1),1500)}catch(S){f(S instanceof Error?S.message:String(S))}finally{i(!1)}},[e,t,p]),h=o==="md"?"h-9 px-3 text-sm gap-2":"h-7 px-2.5 text-[11px] gap-1.5",[g,b]=$(null),[x,y]=$(!1),w=()=>{y(!1);const k=setTimeout(()=>{y(!0),m("copy")},600);b(k)},v=()=>{g&&(clearTimeout(g),b(null)),x||m("download")},N=()=>{g&&(clearTimeout(g),b(null))};return u("button",{type:"button",title:"Click to download · long-press to copy",disabled:a,onPointerDown:w,onPointerUp:v,onPointerLeave:N,onPointerCancel:N,className:W("inline-flex items-center justify-center rounded-lg font-medium border border-border","text-foreground-subtle hover:text-foreground hover:bg-surface-hover","disabled:opacity-50 transition-colors",h,d&&"border-danger/40 text-danger",s),children:[a?r(Lt,{className:"h-3.5 w-3.5 animate-spin"}):l?r(ko,{className:"h-3.5 w-3.5 text-success"}):r(Ol,{className:"h-3.5 w-3.5"}),"Snapshot"]})}function WE(e){const 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 Lc({history:e,limit:t=5,latestIsFresh:n,className:o}){if(e.length===0)return null;const s=n?n2:Js,a=e.slice(0,t);return u("div",{className:W("rounded-lg border border-border bg-surface px-3 py-2",o),children:[u("div",{className:"flex items-center gap-2 mb-2",children:[r(s,{className:W("h-4 w-4 text-amber-400",n&&"animate-pulse")}),r("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:"Recent presses"}),r("span",{className:"ml-auto rounded-full bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle border border-border",children:e.length})]}),r("ul",{className:"space-y-1",children:a.map(i=>u("li",{className:"flex items-center justify-between text-[11px]",title:new Date(i.timestamp).toLocaleString(),children:[r("span",{className:"text-foreground",children:WE(i.timestamp)}),r("span",{className:"text-foreground-subtle font-mono text-[10px]",children:new Date(i.timestamp).toLocaleTimeString()})]},`${i.deviceId}-${i.timestamp}`))})]})}function $x({items:e,header:t,triggerClassName:n,title:o="More actions"}){const[s,a]=$(!1),i=e.filter(l=>!l.hidden);return i.length===0?null:u(lh,{open:s,onOpenChange:a,children:[r(ch,{title:o,className:W("inline-flex items-center justify-center rounded-lg p-2","text-foreground-subtle hover:text-foreground hover:bg-surface-hover","border border-transparent transition-colors",n),children:r(Cm,{className:"h-4 w-4"})}),u(dh,{className:"left-auto right-0 mt-1 min-w-[200px] p-1",children:[t&&r("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle",children:t}),r("ul",{className:"space-y-0.5",children:i.map((l,c)=>u("li",{children:[l.separatorBefore&&c>0&&r("div",{className:"my-1 h-px bg-border"}),u("button",{type:"button",disabled:l.disabled,onClick:()=>{l.disabled||(l.onClick(),a(!1))},className:W("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left text-[12px]","transition-colors disabled:opacity-40 disabled:cursor-not-allowed",l.danger?"text-foreground hover:bg-danger/10 hover:text-danger":"text-foreground hover:bg-surface-hover"),children:[l.icon&&r(l.icon,{className:W("h-3.5 w-3.5 shrink-0 mt-0.5",l.danger&&"text-danger/80")}),u("span",{className:"flex-1 min-w-0",children:[r("span",{className:"block leading-tight",children:l.label}),l.description&&r("span",{className:"block mt-0.5 text-[10px] text-foreground-subtle leading-tight",children:l.description})]})]})]},l.id))})]})]})}const YE=[{value:"view",label:"View",icon:So,hint:"Read-only — queries + subscriptions"},{value:"create",label:"Create",icon:hk,hint:"Mutations that create or update"},{value:"delete",label:"Delete",icon:Qt,hint:"Destructive ops (delete/revoke/reset/…)"}];function ZE(){return{type:"capability",target:"",access:["view"]}}function XE(e,t,n,o){const s=e==="addon"?n:o;if(t==null)return s;const a=new Set(t.filter(i=>i.type===e).map(i=>i.target));return s.filter(i=>a.has(i))}function JE(e,t){if(t==null)return["view","create","delete"];const n=t.filter(s=>s.type===e.type&&s.target===e.target);if(n.length===0)return[];const o=new Set;for(const s of n)for(const a of s.access)o.add(a);return[...o]}function Tc({value:e,onChange:t,clampToParent:n,emptyHint:o}){const{data:s}=oa(),a=U(()=>(s??[]).map(f=>f.manifest.id).sort(),[s]),i=U(()=>[...cw].sort(),[]),l=(f,p)=>{t(e.map((m,h)=>{if(h!==f)return m;const g={...m,...p};return p.type!==void 0&&p.type!==m.type&&(g.target=""),g}))},c=f=>{t(e.filter((p,m)=>m!==f))},d=()=>{t([...e,ZE()])};return u("div",{className:"space-y-2",children:[e.length===0&&o&&r("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-2",children:o}),e.map((f,p)=>{const m=XE(f.type,n,a,i),h=JE(f,n);return u("div",{className:"flex flex-wrap items-center gap-1.5 rounded border border-border bg-surface px-2 py-1.5",children:[u("select",{value:f.type,onChange:g=>l(p,{type:g.target.value}),className:"rounded border border-border bg-background px-2 py-1 text-[11px] focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"capability",children:"capability"}),r("option",{value:"addon",children:"addon"})]}),u("select",{value:f.target,onChange:g=>l(p,{target:g.target.value}),className:"flex-1 min-w-[160px] rounded border border-border bg-background px-2 py-1 text-[11px] font-mono focus:outline-none focus:ring-1 focus:ring-primary",children:[u("option",{value:"",children:["— pick ",f.type," —"]}),m.map(g=>r("option",{value:g,children:g},g))]}),r("div",{className:"flex items-center gap-1",children:YE.map(({value:g,label:b,icon:x,hint:y})=>{const w=f.access.includes(g),v=n!=null&&!h.includes(g)&&!w;return u("label",{title:v?`${y} — not granted by your scope`:y,className:`inline-flex items-center gap-1 rounded px-1.5 py-1 text-[10px] cursor-pointer transition-colors ${w?"bg-primary/15 text-primary font-medium":"text-foreground-subtle hover:bg-foreground-subtle/10"} ${v?"opacity-40 cursor-not-allowed":""}`,children:[r("input",{type:"checkbox",checked:w,disabled:v,onChange:N=>{const k=new Set(f.access);N.target.checked?k.add(g):k.delete(g),l(p,{access:[...k]})},className:"sr-only"}),r(x,{className:"h-3 w-3"}),b]},g)})}),r("button",{type:"button",onClick:()=>c(p),className:"rounded p-1 text-foreground-subtle hover:bg-danger/10 hover:text-danger transition-colors",title:"Remove scope",children:r(Ye,{className:"h-3 w-3"})})]},p)}),u("button",{type:"button",onClick:d,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-foreground-subtle hover:text-foreground hover:bg-foreground-subtle/10 transition-colors",children:[r(Co,{className:"h-3 w-3"}),"Add scope"]})]})}function Rc(e){for(const t of e){if(t.target.trim().length===0)return`Scope ${t.type}: pick a target`;if(t.access.length===0)return`Scope ${t.type}:${t.target}: pick at least one access`}return null}const _x=un("camstack:zone-editing",null);function Dx({children:e}){const[t,n]=$(!1),[o,s]=$(null),[a,i]=$(null),[l,c]=$(null),d=q(w=>{n(w),w||(s(null),i(null),c(null))},[]),f=q(w=>{s(w)},[]),p=q(w=>{i(w)},[]),m=q(w=>{n(!0),i(null),s(w),c(null)},[]),h=q(()=>{n(!1),s(null),i(null),c(null)},[]),g=q(w=>{i(w.id),c(w)},[]),b=q(w=>{c(v=>v===null?v:{...v,...w})},[]),x=q(()=>{c(null)},[]),y=U(()=>({editing:t,drawingKind:o,selectedZoneId:a,editingDraft:l,setEditing:d,setDrawingKind:f,setSelectedZoneId:p,startDrawing:m,exitEditing:h,enterDraft:g,updateDraft:b,discardDraft:x}),[t,o,a,l,d,f,p,m,h,g,b,x]);return r(_x.Provider,{value:y,children:e})}function e$(){return ve(_x)}const Su=500,t$=800;function Ko(e,t,n){try{const o=e.live;if(!o)return null;const s=o.onEvent;return!s||typeof s.subscribe!="function"?null:s.subscribe({category:t},{onData:n})}catch{return null}}function Go(e,t){return e?.id===t}function Lx(e,t){const[n,o]=$(null),[s,a]=$(null),[i,l]=$(null),[c,d]=$("watching"),f=ne(void 0),p=ne(void 0),m=ne(void 0);return Z(()=>{if(t===null)return;const h=Ko(e,"detection.motion-analysis",g=>{const b=g;if(!Go(b?.source,t))return;const x=b.data;!x?.regions||x.regions.length===0||(o({zones:x.regions.map(y=>({...y.bbox,intensity:y.intensity})),frameWidth:x.frameWidth,frameHeight:x.frameHeight}),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>o(null),Su))});return()=>{h?.unsubscribe(),f.current&&clearTimeout(f.current)}},[e,t]),Z(()=>{if(t===null)return;const h=Ko(e,"detection.motion-zones-raw",g=>{const b=g;if(!Go(b?.source,t))return;const x=b.data;x?.zones&&(a({boxes:x.zones.map(y=>({bbox:y.bbox,changeScore:y.changeScore})),frameWidth:x.frameSize?.width??0,frameHeight:x.frameSize?.height??0,motionScore:x.zones.length>0?x.zones.reduce((y,w)=>y+w.changeScore,0)/x.zones.length:0}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>a(null),Su))});return()=>{h?.unsubscribe(),p.current&&clearTimeout(p.current)}},[e,t]),Z(()=>{if(t===null)return;const h=Ko(e,"detection.result",g=>{const b=g;if(!Go(b?.source,t))return;const x=b.data?.frame;x?.detections?.length&&(l({detections:x.detections,frameWidth:x.width,frameHeight:x.height}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>l(null),t$))});return()=>{h?.unsubscribe(),m.current&&clearTimeout(m.current)}},[e,t]),Z(()=>{if(t===null)return;const h=Ko(e,"detection.phase-transition",g=>{const b=g;Go(b?.source,t)&&b.data?.to&&d(b.data.to)});return()=>{h?.unsubscribe()}},[e,t]),{motion:n,motionRaw:s,detection:i,phase:c}}function Oc(e,t,n=5e3){const[o,s]=$([]);Z(()=>{if(t===null)return;let m=!1;const h=()=>{e.webrtcSession.listStreams.query({deviceId:t}).then(b=>{m||s(b)}).catch(()=>{})};h();const g=setInterval(h,n);return()=>{m=!0,clearInterval(g)}},[e,t,n]);const[a,i]=$(null);Z(()=>{if(t===null)return;let m=!1;return e.pipelineOrchestrator&&e.pipelineOrchestrator.getCameraMetrics.query({deviceId:t}).then(h=>{m||!h||i({phase:h.phase,detectionFps:h.actualFps,avgInferenceMs:h.avgInferenceTimeMs,droppedFrames:h.droppedFrames})}).catch(()=>{}),()=>{m=!0}},[e,t]),ct("pipeline.camera-metrics-snapshot",m=>{if(t===null)return;const h=m.data;h.deviceId!==t||!h.metrics||i({phase:h.metrics.phase,detectionFps:h.metrics.actualFps,avgInferenceMs:h.metrics.avgInferenceTimeMs,droppedFrames:h.metrics.droppedFrames})});const{streams:l,hasWebrtc:c}=U(()=>t===null||o.length===0?{streams:[],hasWebrtc:!1}:{streams:o.map(h=>({id:h.id,label:h.label,target:h.target,status:h.status,inputFps:h.inputFps,decodeFps:h.decodeFps,bitrateKbps:h.bitrateKbps})),hasWebrtc:!0},[t,o]),d=q(async(m,h)=>{if(t===null)throw new Error("No device selected");const g=await e.webrtcSession.createSession.mutate({deviceId:t,target:m,hints:h});return{sessionId:g.sessionId,sdpOffer:g.sdpOffer}},[e,t]),f=q(async(m,h)=>{if(t===null)throw new Error("No device selected");await e.webrtcSession.handleAnswer.mutate({deviceId:t,sessionId:m,sdpAnswer:h})},[e,t]),p=q(async m=>{t!==null&&await e.webrtcSession.closeSession.mutate({deviceId:t,sessionId:m}).catch(()=>{})},[e,t]);return{streams:l,hasWebrtc:c,pipelineMetrics:a,createSession:d,sendAnswer:f,closeSession:p}}const Cu={up:{pan:0,tilt:1},down:{pan:0,tilt:-1},left:{pan:-1,tilt:0},right:{pan:1,tilt:0},"up-left":{pan:-1,tilt:1},"up-right":{pan:1,tilt:1},"down-left":{pan:-1,tilt:-1},"down-right":{pan:1,tilt:-1}};function zc(e,t,n){const o=n?.defaultSpeed??.5,s=n?.pulseMs??250,a=n?.enabled??!0,l=St(e,a?t:null)?.ptz,[c,d]=$([]),[f,p]=$(!1),[m,h]=$(null),g=q(async()=>{if(!(!a||!l))try{const S=await l.getPresets({});d(S)}catch(S){const M=S instanceof Error?S.message:String(S);if(M.includes("provider not available")||M.includes("no 'ptz' binding"))return;h(M)}},[l,a]);Z(()=>{g()},[g]);const b=q(async S=>{if(!(!a||!l)){h(null),p(!0);try{return await S()}catch(M){h(M instanceof Error?M.message:String(M));return}finally{p(!1)}}},[a,l]),x=q(async(S,M)=>{if(!l)return;const P=Cu[S],A=M??o;await b(async()=>{await l.move({pan:P.pan,tilt:P.tilt,speed:A}),await new Promise(z=>setTimeout(z,s)),await l.stop({})})},[l,o,s,b]),y=q(async(S,M)=>{if(!l)return;const P=Cu[S],A=M??o;await b(()=>l.continuousMove({pan:P.pan,tilt:P.tilt,speed:A}))},[l,o,b]),w=q(async()=>{l&&await b(()=>l.stop({}))},[l,b]),v=q(async(S,M)=>{if(!l)return;const P=S==="in"?1:-1,A=M??o;await b(async()=>{await l.move({zoom:P,speed:A}),await new Promise(z=>setTimeout(z,s)),await l.stop({})})},[l,o,s,b]),N=q(async()=>{l&&await b(()=>l.goHome({}))},[l,b]),k=q(async S=>{l&&await b(()=>l.goToPreset({presetId:S}))},[l,b]);return{move:x,startContinuous:y,stopContinuous:w,zoom:v,goHome:N,goToPreset:k,presets:c,refreshPresets:g,busy:f,error:m}}function Bc(e){const t=e?.deviceId??null,n=e?.historyLimit??20,o=Pr("doorbell.onPressed",t!==null?i=>i.deviceId===t:void 0),[s,a]=$([]);return Z(()=>{o&&a(i=>{if(i.length>0&&i[0].deviceId===o.deviceId&&i[0].timestamp===o.timestamp)return i;const l=[o,...i];return l.length>n?l.slice(0,n):l})},[o,n]),{latest:o??null,history:s}}function n$(e){const t=Le(),n=U(()=>e?JSON.stringify(e):"",[e]),[o,s]=$(()=>t.listDevices(e));return Z(()=>{const a=()=>{s(t.listDevices(e))};a();let i=null,l=null;try{i=t.onDeviceAdded(a),l=t.onDeviceRemoved(a)}catch{}const c=t.subscribeConnectionEvents(d=>{d==="connected"&&a()});return()=>{i?.(),l?.(),c()}},[t,e,n]),o}function r$(e){const t=Le(),[n,o]=$(()=>e===null?null:t.getDevice(e));return Z(()=>{if(e===null){o(null);return}const s=()=>{o(t.getDevice(e))};s();let a=null,i=null;try{a=t.onDeviceAdded(s),i=t.onDeviceRemoved(s)}catch{}const l=t.subscribeConnectionEvents(c=>{c==="connected"&&s()});return()=>{a?.(),i?.(),l()}},[t,e]),n}function o$(e,t,n){const o=Le();return Wn({queryKey:e,queryFn:()=>t(o)(),...n})}function s$(e,t){const n=Le();return _l({mutationFn:o=>e(n)(o),...t})}function a$(e,t){const n=Le(),o=ke(),[s,a]=$(n.connectionVersion);Z(()=>n.subscribeConnectionEvents((c,d)=>{c==="connected"&&a(d)}),[n]);const i=t.join("|"),l=JSON.stringify(e);Z(()=>{const c=[],d=()=>{const f=JSON.parse(l),m=f.length===1&&Array.isArray(f[0])?f:[f];o.invalidateQueries({queryKey:m})};d();for(const f of i.split("|"))if(f)try{c.push(n.subscribeEvent(f,d))}catch{}return()=>{for(const f of c)f()}},[n,o,i,l,s])}const i$=Object.freeze(Object.defineProperty({__proto__:null,AddonGlobalSettingsForm:eE,AgentStepEditor:ra,AppShell:aS,AudioClassificationList:wE,AudioLevelWaveform:xE,AudioWaveform:bE,BTN_COMPACT:xN,BTN_COMPACT_DANGER:vN,BTN_COMPACT_PRIMARY:yN,BTN_COMPACT_WARNING:wN,Badge:ur,BatteryBadge:oc,BottomSheet:Kl,Breadcrumb:Yl,Button:Ue,CHIP_ACTIVE:SN,CHIP_BASE:kN,CHIP_INACTIVE:CN,CLASS_COLORS:Qr,CameraStreamPlayer:kx,Card:rn,Checkbox:jm,CodeBlock:oS,CollapsibleCard:Bm,ConfigFormBuilder:wx,ConfigFormField:rr,ConfigSchemaField:na,ConfirmActionButton:Ex,ConfirmDialogProvider:Nh,CustomFieldRenderersProvider:Hh,DEFAULT_COLOR:Oh,DataTable:fh,DetectionCanvas:lC,DetectionOverlay:Nx,DetectionResultTree:pC,DevShell:Fh,DeviceActivityPanel:QE,DeviceCard:lS,DeviceContextProvider:qh,DeviceGrid:cS,DeviceItem:ao,DeviceList:io,Dialog:qm,DialogContent:Ul,DialogDescription:Gm,DialogFooter:Qm,DialogHeader:Um,DialogTitle:Km,DialogTrigger:S5,DiscoveryPanel:Px,DoorbellRecentPanel:Lc,Dropdown:Ym,DropdownContent:Xm,DropdownItem:Jm,DropdownTrigger:Zm,EmptyState:vh,EventStream:or,FilterBar:sS,FloatingEventStream:RE,FloatingLogStream:Ax,FloatingPanel:D5,FormField:eS,GRID_GAP:bm,GRID_PAIRED:pN,GRID_QUICK_STATS:uN,INPUT_COMPACT:NN,IconButton:jl,ImageSelector:bC,InferenceConfigSelector:xC,Input:As,KebabMenu:$x,KeyValueList:rS,LIST_ROW:xm,Label:Hl,LogStream:Wt,LoginForm:zh,MobileDrawer:Wl,NodeMultiSelectField:yx,NodePicker:xh,NodeSelectField:xx,PHASE_CONFIG:zi,PTZOverlay:Dc,PageHeader:tS,PhaseIcon:$c,PipelineBuilder:sc,PipelineRuntimeSelector:sC,PipelineStep:gs,PipelineTreeMatrix:Xl,PlayerOverlaysProvider:Sx,Popover:lh,PopoverContent:dh,PopoverTrigger:ch,ProviderBadge:Z5,ResponseLog:NE,SECTION_BODY:dN,SECTION_CARD:lN,SECTION_HEADER:cN,SPLIT_PANEL_OUTER:fN,SPLIT_PANEL_SIDE:mN,STACK_GAP:gm,ScopePicker:Tc,ScrollArea:Gl,Select:Ps,SemanticBadge:yh,Separator:Vl,Sidebar:Ui,SidebarItem:qi,Skeleton:Fm,SlideOverPanel:Zl,SnapshotButton:GE,StatCard:nS,StateValuesStream:_c,StatusBadge:W5,StepTimings:gC,StepTreeMaster:hh,StreamPanel:Ec,Switch:ql,SystemProvider:ec,TEXT_FIELD_LABEL:gN,TEXT_HINT:Is,TEXT_METRIC:Oi,TEXT_SECTION_LABEL:hN,TEXT_VALUE:bN,Tabs:P5,TabsContent:_5,TabsList:E5,TabsTrigger:$5,ThemeProvider:Cs,Tooltip:M5,TooltipContent:A5,TooltipTrigger:I5,VersionBadge:J5,WidgetRegistryProvider:fx,WidgetSlot:at,ZoneEditingProvider:Dx,buildStepTreeFromSchema:ta,cn:W,createSharedContext:un,createTheme:pw,darkColors:Gf,defaultTheme:Ti,deriveDeviceKind:uS,ensureMfHostInit:Tl,getClassColor:lt,getPhaseVisual:Zn,isFieldVisible:Ic,lightColors:Wf,mirror:ym,mountAddonPage:IC,providerIcons:b5,statusIcons:x5,themeToCss:bw,trpc:C,useAccessoriesGetStatus:AC,useAddonPagesListPages:lc,useAddonSettingsGetDeviceSettings:zC,useAddonSettingsGetGlobalSettings:uc,useAddonSettingsUpdateDeviceSettings:rg,useAddonSettingsUpdateGlobalSettings:ng,useAddonWidgetsListWidgets:og,useAddonsApplyAutoUpdateToAll:tg,useAddonsCustom:RC,useAddonsForceRefresh:Gh,useAddonsGetAddonAutoUpdate:Jh,useAddonsGetAutoUpdateSettings:Xh,useAddonsGetLogs:PC,useAddonsGetVersions:Yh,useAddonsInstallFromWorkspace:$C,useAddonsInstallPackage:cc,useAddonsIsWorkspaceAvailable:_C,useAddonsList:oa,useAddonsListPackages:EC,useAddonsListUpdates:dc,useAddonsListWorkspacePackages:DC,useAddonsOnAddonLogs:OC,useAddonsReloadPackages:Qh,useAddonsRestartAddon:sa,useAddonsRestartServer:Wh,useAddonsRetryLoad:Zh,useAddonsRollbackPackage:LC,useAddonsSearchAvailable:Kh,useAddonsSetAddonAutoUpdate:eg,useAddonsSetAutoUpdateSettings:TC,useAddonsUninstallPackage:Uh,useAddonsUpdatePackage:Ki,useAlertsDismiss:cg,useAlertsEmit:BC,useAlertsGetUnreadCount:ag,useAlertsList:sg,useAlertsMarkAllRead:lg,useAlertsMarkRead:ig,useAlertsUpdate:FC,useAllWidgets:gx,useAudioAnalysisApplyDeviceSettingsPatch:qC,useAudioAnalysisGetDeviceLiveContribution:VC,useAudioAnalysisGetDeviceSettingsContribution:HC,useAudioAnalysisResolveDeviceSettings:jC,useAudioAnalyzerAnalyseChunk:UC,useAudioAnalyzerClassify:QC,useAudioAnalyzerDispose:GC,useAudioAnalyzerIsReady:KC,useAudioAnalyzerReprobeAudioEngine:dg,useAudioCodecCanHandle:YC,useAudioCodecCloseSession:JC,useAudioCodecCreateDecodeSession:ZC,useAudioCodecCreateEncodeSession:XC,useAudioCodecFlushEncode:o3,useAudioCodecListActiveSessions:s3,useAudioCodecListSupportedCodecs:WC,useAudioCodecPullEncoded:r3,useAudioCodecPullPcm:t3,useAudioCodecPushEncodedFrame:e3,useAudioCodecPushPcm:n3,useAudioMetricsGetCurrentSnapshot:a3,useAudioMetricsGetHistory:i3,useAuthenticationListProviders:pc,useAuthenticationSetProviderEnabled:l3,useBackupDelete:hg,useBackupGetEntries:fg,useBackupList:c3,useBackupListArchives:mc,useBackupListDestinations:fc,useBackupListLocations:pg,useBackupPreviewSchedule:bg,useBackupRestore:mg,useBackupTrigger:ug,useBackupUpsertDestinationPolicy:gg,useBatteryGetStatus:d3,useBrightnessGetStatus:p3,useBrightnessSetBrightness:u3,useCameraStreamsGetBrokerStreams:m3,useCameraStreamsGetCameraStreams:f3,useCameraStreamsGetRtspEntries:h3,useClusterNodes:Er,useConfirm:nt,useCustomFieldRenderer:Vh,useDebouncedString:Rh,useDecoderCreateSession:x3,useDecoderDestroySession:y3,useDecoderGetInfo:b3,useDecoderGetStats:S3,useDecoderListActiveSessions:C3,useDecoderOpenStream:w3,useDecoderPullFrames:N3,useDecoderPushPacket:v3,useDecoderReprobeHwaccel:xg,useDecoderSupportsCodec:g3,useDecoderUpdateConfig:k3,useDetectionPipelineApplyDeviceSettingsPatch:A3,useDetectionPipelineGetDeviceLiveContribution:I3,useDetectionPipelineGetDeviceSettingsContribution:M3,useDevShell:NC,useDevice:r$,useDeviceBattery:nc,useDeviceCapability:$r,useDeviceDetections:Lx,useDeviceDiscoveryAdoptDevice:P3,useDeviceDiscoveryGetStatus:$3,useDeviceDiscoveryListDiscovered:yg,useDeviceDiscoveryRefreshDiscovery:vg,useDeviceDiscoveryReleaseDevice:E3,useDeviceId:pn,useDeviceManagerAddLocation:F3,useDeviceManagerAdoptDevice:_g,useDeviceManagerAllocateDeviceId:_3,useDeviceManagerCreateDevice:Lg,useDeviceManagerDisable:Mg,useDeviceManagerDiscoverDevices:gc,useDeviceManagerEnable:Cg,useDeviceManagerGetAllBindings:Z3,useDeviceManagerGetBindings:Ag,useDeviceManagerGetChildren:Sg,useDeviceManagerGetConfigSchema:U3,useDeviceManagerGetCreationSchema:Dg,useDeviceManagerGetDevice:Hn,useDeviceManagerGetDeviceAggregate:hc,useDeviceManagerGetDeviceLiveInfoAggregate:eM,useDeviceManagerGetDeviceSettingsAggregate:J3,useDeviceManagerGetDeviceStatusAggregate:rM,useDeviceManagerGetSettingsSchema:Q3,useDeviceManagerGetStreamProfileMap:G3,useDeviceManagerGetStreamSources:q3,useDeviceManagerListAll:tr,useDeviceManagerListBindableCapsForDeviceType:Eg,useDeviceManagerListLocations:kg,useDeviceManagerListPersistedByAddon:V3,useDeviceManagerListWrappersForCap:X3,useDeviceManagerLoadConfig:R3,useDeviceManagerLoadMeta:z3,useDeviceManagerLoadRuntimeState:O3,useDeviceManagerPersistConfig:T3,useDeviceManagerProbeStreams:Y3,useDeviceManagerRegisterDevice:D3,useDeviceManagerRemove:Ig,useDeviceManagerRemoveDevice:L3,useDeviceManagerRemoveLocation:j3,useDeviceManagerSetDisabled:H3,useDeviceManagerSetLocation:Ng,useDeviceManagerSetMetadata:B3,useDeviceManagerSetName:wg,useDeviceManagerSetStreamProfileMap:W3,useDeviceManagerSetWrapperActive:Pg,useDeviceManagerTestCreationField:bc,useDeviceManagerTestField:nM,useDeviceManagerUpdateConfig:K3,useDeviceManagerUpdateDeviceField:tM,useDeviceManagerUpdateDeviceFieldsBatch:$g,useDeviceOpsGetConfigEntries:sM,useDeviceOpsGetSettingsSchema:lM,useDeviceOpsGetStreamSources:oM,useDeviceOpsRemoveDevice:iM,useDeviceOpsSetConfig:aM,useDeviceProviderAdoptDiscoveredDevice:hM,useDeviceProviderCreateDevice:xM,useDeviceProviderDiscoverDevices:mM,useDeviceProviderGetChildCreationSchema:bM,useDeviceProviderGetDevices:pM,useDeviceProviderGetStatus:uM,useDeviceProviderStart:cM,useDeviceProviderStop:dM,useDeviceProviderSupportsDiscovery:fM,useDeviceProviderSupportsManualCreation:gM,useDeviceProviderTestCreationField:yM,useDeviceProxy:St,useDeviceSnapshot:ic,useDeviceSnapshotImage:rc,useDeviceState:kh,useDeviceStateGetAllSnapshots:NM,useDeviceStateGetCapSlice:wM,useDeviceStateGetSnapshot:vM,useDeviceStateSetCapSlice:kM,useDeviceStateSlice:on,useDeviceWebrtc:Oc,useDevices:n$,useDoorbellEvents:Bc,useDoorbellGetStatus:SM,useEventInvalidation:a$,useEventStreamLatest:Pr,useEventStreamMap:tc,useEventsGetEventClipUrl:IM,useEventsGetEventThumbnail:MM,useEventsGetEvents:CM,useIntegrationsCreate:Og,useIntegrationsDelete:Bg,useIntegrationsGet:Tg,useIntegrationsGetAvailableTypes:Fg,useIntegrationsGetByAddonId:Rg,useIntegrationsGetSettings:AM,useIntegrationsList:xc,useIntegrationsSetSettings:PM,useIntegrationsTestConnection:jg,useIntegrationsUpdate:zg,useIntercomGetStatus:EM,useIntercomHandleAnswer:Vg,useIntercomStartSession:Hg,useIntercomStopSession:qg,useIsMidWidth:sh,useIsMobile:er,useLiveBuffer:zn,useLiveEvent:ct,useLocalNetworkGetAllowedAddresses:Kg,useLocalNetworkGetConnectionEndpoints:Qg,useLocalNetworkGetPreferred:$M,useLocalNetworkList:Ug,useLocalNetworkResetAllowlistToBestMatch:Wg,useLocalNetworkSetAllowedAddresses:Gg,useMeshOrchestratorJoinProvider:Zg,useMeshOrchestratorLeaveProvider:Xg,useMeshOrchestratorListProviders:Yg,useMetricsProviderCollectSnapshot:_M,useMetricsProviderGetAddonStats:FM,useMetricsProviderGetCached:DM,useMetricsProviderGetCpuTemperature:OM,useMetricsProviderGetCurrent:LM,useMetricsProviderGetDiskSpace:TM,useMetricsProviderGetGpuInfo:RM,useMetricsProviderGetProcessStats:zM,useMetricsProviderKillProcess:eb,useMetricsProviderListAddonInstances:BM,useMetricsProviderListNodeProcesses:Jg,useMotionDetectionAnalyze:VM,useMotionDetectionApplyDeviceSettingsPatch:GM,useMotionDetectionGetDeviceLiveContribution:KM,useMotionDetectionGetDeviceSettingsContribution:QM,useMotionDetectionRemoveCamera:qM,useMotionDetectionReset:UM,useMotionGetStatus:HM,useMotionIsDetected:jM,useMotionTriggerGetStatus:YM,useMotionTriggerSetMotionTrigger:WM,useNativeObjectDetectionGetStatus:ZM,useNetworkQualityGetAllStats:XM,useNetworkQualityGetDeviceStats:yc,useNetworkQualityReportClientStats:JM,useNodesClusterAddonStatus:sb,useNodesDeployAddon:e4,useNodesExecuteQuery:n4,useNodesRenameNode:ob,useNodesRestartAddon:aa,useNodesRestartNode:rb,useNodesRestartProcess:nb,useNodesSetProcessLogLevel:ab,useNodesShutdownNode:t4,useNodesTopology:An,useNodesUndeployAddon:tb,useNotificationOutputSend:r4,useNotificationOutputSendTest:o4,useOptionalSystem:K5,useOptionalWidgetRegistry:bx,useOsdGetStatus:a4,useOsdSetOverlay:s4,usePTZ:zc,usePipelineAnalyticsApplyDeviceSettingsPatch:x4,usePipelineAnalyticsClearTracks:d4,usePipelineAnalyticsGetActiveTracks:i4,usePipelineAnalyticsGetAudioEvents:f4,usePipelineAnalyticsGetDeviceLiveContribution:b4,usePipelineAnalyticsGetDeviceSettingsContribution:g4,usePipelineAnalyticsGetEventMedia:m4,usePipelineAnalyticsGetMotionEvents:u4,usePipelineAnalyticsGetObjectEvents:p4,usePipelineAnalyticsGetTrack:l4,usePipelineAnalyticsGetTrackMedia:h4,usePipelineAnalyticsListTracks:c4,usePipelineExecutorCacheFrameInPool:L4,usePipelineExecutorDeleteModel:ub,usePipelineExecutorDeleteTemplate:A4,usePipelineExecutorDetect:$4,usePipelineExecutorDownloadModel:db,usePipelineExecutorGetAddonModels:E4,usePipelineExecutorGetAudioCapabilities:V4,usePipelineExecutorGetAvailableEngines:ib,usePipelineExecutorGetCapabilities:P4,usePipelineExecutorGetDefaultSteps:y4,usePipelineExecutorGetDetectionConfigSchema:U4,usePipelineExecutorGetEffectiveTuning:O4,usePipelineExecutorGetGlobalPipelineConfig:k4,usePipelineExecutorGetGlobalSteps:N4,usePipelineExecutorGetOrchestratorConfigSchema:S4,usePipelineExecutorGetReferenceAudio:H4,usePipelineExecutorGetReferenceAudioFiles:j4,usePipelineExecutorGetReferenceImage:F4,usePipelineExecutorGetSchema:Io,usePipelineExecutorGetSelectedEngine:lb,usePipelineExecutorGetVideoPipelineSteps:v4,usePipelineExecutorInferCached:T4,usePipelineExecutorKillEngine:fb,usePipelineExecutorListLoadedEngines:pb,usePipelineExecutorListReferenceImages:B4,usePipelineExecutorListTemplates:C4,usePipelineExecutorReprobeEngine:cb,usePipelineExecutorRunAudioTest:q4,usePipelineExecutorRunPipeline:_4,usePipelineExecutorRunPipelineBatch:D4,usePipelineExecutorSaveTemplate:M4,usePipelineExecutorSetVideoPipelineSteps:w4,usePipelineExecutorSpinEngine:z4,usePipelineExecutorUncacheFrame:R4,usePipelineExecutorUpdateTemplate:I4,usePipelineOrchestratorApplyDeviceSettingsPatch:eI,usePipelineOrchestratorAssignAudio:kb,usePipelineOrchestratorAssignDecoder:vb,usePipelineOrchestratorAssignPipeline:mb,usePipelineOrchestratorDeleteTemplate:Lb,usePipelineOrchestratorGetAgentLoad:bb,usePipelineOrchestratorGetAgentSettings:vc,usePipelineOrchestratorGetAudioAssignment:G4,usePipelineOrchestratorGetAudioAssignments:Mb,usePipelineOrchestratorGetAudioNodeLoad:Cb,usePipelineOrchestratorGetCameraMetrics:K4,usePipelineOrchestratorGetCameraSettings:Nc,usePipelineOrchestratorGetCameraStepOverrides:Y4,usePipelineOrchestratorGetCapabilityBindings:xb,usePipelineOrchestratorGetDecoderAssignment:W4,usePipelineOrchestratorGetDecoderAssignments:Nb,usePipelineOrchestratorGetDeviceLiveContribution:J4,usePipelineOrchestratorGetDeviceSettingsContribution:X4,usePipelineOrchestratorGetGlobalMetrics:Q4,usePipelineOrchestratorGetPipelineAssignment:la,usePipelineOrchestratorGetPipelineAssignments:ia,usePipelineOrchestratorListAgentSettings:_r,usePipelineOrchestratorListTemplates:_b,usePipelineOrchestratorRebalance:gb,usePipelineOrchestratorRemoveAgentSettings:Ib,usePipelineOrchestratorResolvePipeline:$b,usePipelineOrchestratorSaveTemplate:Z4,usePipelineOrchestratorSetAgentAddonDefaults:wc,usePipelineOrchestratorSetCameraPipelineForAgent:Eb,usePipelineOrchestratorSetCameraStepOverride:Pb,usePipelineOrchestratorSetCameraStepToggle:Ab,usePipelineOrchestratorSetCapabilityBinding:yb,usePipelineOrchestratorUnassignAudio:Sb,usePipelineOrchestratorUnassignDecoder:wb,usePipelineOrchestratorUnassignPipeline:hb,usePipelineOrchestratorUpdateTemplate:Db,usePipelineRunnerAttachCamera:tI,usePipelineRunnerDetachCamera:nI,usePipelineRunnerGetAllCameraMetrics:aI,usePipelineRunnerGetCameraMetrics:kc,usePipelineRunnerGetLocalCameras:Tb,usePipelineRunnerGetLocalLoad:oI,usePipelineRunnerGetLocalMetrics:sI,usePipelineRunnerReportMotion:rI,usePlatformProbeGetCapabilities:iI,usePlatformProbeGetHardware:lI,usePlatformProbeResolveHwAccel:dI,usePlatformProbeResolveInferenceConfig:cI,usePlayerOverlayLayer:lE,usePlayerOverlayLayers:Cx,usePlayerToolbarButton:cE,usePlayerToolbarButtons:Mx,usePtzAutotrackGetSettings:yI,usePtzAutotrackGetStatus:Rb,usePtzAutotrackSetEnabled:Ob,usePtzAutotrackSetSettings:zb,usePtzContinuousMove:pI,usePtzGetPosition:bI,usePtzGetPresets:mI,usePtzGetStatus:xI,usePtzGoHome:gI,usePtzGoToPreset:hI,usePtzMove:uI,usePtzStop:fI,useRebootReboot:Bb,useRecordingEngineDisable:jb,useRecordingEngineEnable:Fb,useRecordingEngineEstimateGlobalStorage:PI,useRecordingEngineEstimateStorage:AI,useRecordingEngineGetAvailability:II,useRecordingEngineGetConfig:Hb,useRecordingEngineGetMotionStats:DI,useRecordingEngineGetPlaylist:CI,useRecordingEngineGetPolicy:$I,useRecordingEngineGetPolicyStatus:Ub,useRecordingEngineGetRetentionConfig:Qb,useRecordingEngineGetSegments:Vb,useRecordingEngineGetStatus:kI,useRecordingEngineGetStorageUsage:qb,useRecordingEngineGetThumbnail:MI,useRecordingEngineSetPolicy:EI,useRecordingEngineUpdateConfig:SI,useRecordingEngineUpdateRetentionConfig:_I,useRecordingGetPlaybackUrl:wI,useRecordingGetSegments:vI,useRecordingGetThumbnailAt:NI,useRemoteAccessListProviders:Kb,useRemoteAccessStartProvider:Gb,useRemoteAccessStopProvider:Wb,useSettingsStoreCount:FI,useSettingsStoreDeclareCollection:HI,useSettingsStoreDelete:BI,useSettingsStoreGet:LI,useSettingsStoreInsert:OI,useSettingsStoreIsEmpty:jI,useSettingsStoreQuery:RI,useSettingsStoreSet:TI,useSettingsStoreUpdate:zI,useSnapshotApplyDeviceSettingsPatch:GI,useSnapshotGetDeviceLiveContribution:KI,useSnapshotGetDeviceSettingsContribution:QI,useSnapshotGetSnapshot:VI,useSnapshotGetStatus:UI,useSnapshotInvalidateCache:qI,useSnapshotProviderGetSnapshot:YI,useSnapshotProviderSupportsDevice:WI,useStorageAbortUpload:iA,useStorageBeginDownload:lA,useStorageBeginUpload:oA,useStorageDelete:nA,useStorageDeleteLocation:Zb,useStorageEndDownload:dA,useStorageExists:eA,useStorageFinalizeUpload:aA,useStorageGetAvailableSpace:rA,useStorageGetDefaultLocation:uA,useStorageList:tA,useStorageListLocations:Yb,useStorageListProviders:Sc,useStorageRead:JI,useStorageReadChunk:cA,useStorageResolve:ZI,useStorageTestConfig:fA,useStorageTestLocation:pA,useStorageUpsertLocation:ca,useStorageWrite:XI,useStorageWriteChunk:sA,useStreamBrokerApplyDeviceSettingsPatch:TA,useStreamBrokerAssignProfile:gA,useStreamBrokerGetAllRtspEntries:PA,useStreamBrokerGetBroker:CA,useStreamBrokerGetBrokerStats:vA,useStreamBrokerGetDeviceLiveContribution:LA,useStreamBrokerGetDeviceSettingsContribution:DA,useStreamBrokerGetPreBufferInfo:IA,useStreamBrokerGetRtspEntry:EA,useStreamBrokerGetRtspPort:AA,useStreamBrokerGetStreamUrl:SA,useStreamBrokerIsRtspEnabled:_A,useStreamBrokerKillClient:NA,useStreamBrokerListAllCameraStreams:xA,useStreamBrokerListAllProfileSlots:yA,useStreamBrokerListClients:wA,useStreamBrokerPublishCameraStream:mA,useStreamBrokerRegenerateRtspToken:Xb,useStreamBrokerRestartProfile:kA,useStreamBrokerRetractCameraStream:hA,useStreamBrokerSetPreBufferDuration:MA,useStreamBrokerSetRtspEnabled:$A,useStreamBrokerUnassignProfile:bA,useSwitchGetStatus:OA,useSwitchSetState:RA,useSystem:Le,useSystemFeatureFlags:FA,useSystemForceRetentionCleanup:qA,useSystemGetRetentionConfig:HA,useSystemHealth:BA,useSystemInfo:zA,useSystemMutation:s$,useSystemNetworkAddresses:jA,useSystemQuery:o$,useSystemSetRetentionConfig:VA,useThemeMode:Ar,useToastOnToast:Jb,useTurnOrchestratorGetAllServers:tx,useTurnOrchestratorListProviders:ex,useTurnOrchestratorSetProviderEnabled:nx,useTurnProviderGetTurnServers:UA,useUserManagementCreateApiKey:KA,useUserManagementCreateScopedToken:cx,useUserManagementCreateUser:rx,useUserManagementDeleteUser:sx,useUserManagementListApiKeys:ix,useUserManagementListScopedTokens:ux,useUserManagementListUsers:Cc,useUserManagementResetPassword:Mc,useUserManagementRevokeApiKey:lx,useUserManagementRevokeScopedToken:dx,useUserManagementSetUserScopes:ax,useUserManagementUpdateUser:ox,useUserManagementValidateApiKey:GA,useUserManagementValidateCredentials:QA,useUserManagementValidateScopedToken:WA,useWebrtcSessionCloseSession:JA,useWebrtcSessionCreateSession:ZA,useWebrtcSessionHandleAnswer:XA,useWebrtcSessionHasAdaptiveBitrate:eP,useWebrtcSessionListStreams:YA,useWidget:mx,useWidgetMetadata:hx,useWidgetRegistry:da,useZoneAnalyticsGetCameraHistory:rP,useZoneAnalyticsGetCurrentSnapshot:tP,useZoneAnalyticsGetUnzonedHistory:oP,useZoneAnalyticsGetZoneHistory:nP,useZoneEditing:e$,useZoneRulesListRules:sP,useZoneRulesSetRules:aP,useZonesAddZone:lP,useZonesListZones:iP,useZonesRemoveZone:cP,useZonesUpdateZone:dP,validateScopes:Rc},Symbol.toStringTag,{value:"Module"}));/**
|
|
540
|
-
* react-router v7.15.0
|
|
541
|
-
*
|
|
542
|
-
* Copyright (c) Remix Software Inc.
|
|
543
|
-
*
|
|
544
|
-
* This source code is licensed under the MIT license found in the
|
|
545
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
546
|
-
*
|
|
547
|
-
* @license MIT
|
|
548
|
-
*/var Mu="popstate";function Iu(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function l$(e={}){function t(o,s){let a=s.state?.masked,{pathname:i,search:l,hash:c}=a||o.location;return Yi("",{pathname:i,search:l,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default",a?{pathname:o.location.pathname,search:o.location.search,hash:o.location.hash}:void 0)}function n(o,s){return typeof s=="string"?s:lo(s)}return d$(t,n,null,e)}function ze(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function yt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function c$(){return Math.random().toString(36).substring(2,10)}function Au(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Yi(e,t,n=null,o,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Dr(t):t,state:n,key:t&&t.key||o||c$(),mask:s}}function lo({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Dr(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let o=e.indexOf("?");o>=0&&(t.search=e.substring(o),e=e.substring(0,o)),e&&(t.pathname=e)}return t}function d$(e,t,n,o={}){let{window:s=document.defaultView,v5Compat:a=!1}=o,i=s.history,l="POP",c=null,d=f();d==null&&(d=0,i.replaceState({...i.state,idx:d},""));function f(){return(i.state||{idx:null}).idx}function p(){l="POP";let x=f(),y=x==null?null:x-d;d=x,c&&c({action:l,location:b.location,delta:y})}function m(x,y){l="PUSH";let w=Iu(x)?x:Yi(b.location,x,y);d=f()+1;let v=Au(w,d),N=b.createHref(w.mask||w);try{i.pushState(v,"",N)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;s.location.assign(N)}a&&c&&c({action:l,location:b.location,delta:1})}function h(x,y){l="REPLACE";let w=Iu(x)?x:Yi(b.location,x,y);d=f();let v=Au(w,d),N=b.createHref(w.mask||w);i.replaceState(v,"",N),a&&c&&c({action:l,location:b.location,delta:0})}function g(x){return u$(x)}let b={get action(){return l},get location(){return e(s,i)},listen(x){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(Mu,p),c=x,()=>{s.removeEventListener(Mu,p),c=null}},createHref(x){return t(s,x)},createURL:g,encodeLocation(x){let y=g(x);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:m,replace:h,go(x){return i.go(x)}};return b}function u$(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ze(n,"No window.location.(origin|href) available to create URL");let o=typeof e=="string"?e:lo(e);return o=o.replace(/ $/,"%20"),!t&&o.startsWith("//")&&(o=n+o),new URL(o,n)}function Tx(e,t,n="/"){return p$(e,t,n,!1)}function p$(e,t,n,o,s){let a=typeof t=="string"?Dr(t):t,i=sn(a.pathname||"/",n);if(i==null)return null;let l=f$(e),c=null,d=C$(i);for(let f=0;c==null&&f<l.length;++f)c=k$(l[f],d,o);return c}function f$(e){let t=Rx(e);return m$(t),t}function Rx(e,t=[],n=[],o="",s=!1){let a=(i,l,c=s,d)=>{let f={relativePath:d===void 0?i.path||"":d,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(o)&&c)return;ze(f.relativePath.startsWith(o),`Absolute route path "${f.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),f.relativePath=f.relativePath.slice(o.length)}let p=Dt([o,f.relativePath]),m=n.concat(f);i.children&&i.children.length>0&&(ze(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${p}".`),Rx(i.children,t,m,p,c)),!(i.path==null&&!i.index)&&t.push({path:p,score:w$(p,i.index),routesMeta:m})};return e.forEach((i,l)=>{if(i.path===""||!i.path?.includes("?"))a(i,l);else for(let c of Ox(i.path))a(i,l,!0,c)}),t}function Ox(e){let t=e.split("/");if(t.length===0)return[];let[n,...o]=t,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(o.length===0)return s?[a,""]:[a];let i=Ox(o.join("/")),l=[];return l.push(...i.map(c=>c===""?a:[a,c].join("/"))),s&&l.push(...i),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function m$(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:N$(t.routesMeta.map(o=>o.childrenIndex),n.routesMeta.map(o=>o.childrenIndex)))}var h$=/^:[\w-]+$/,g$=3,b$=2,x$=1,y$=10,v$=-2,Pu=e=>e==="*";function w$(e,t){let n=e.split("/"),o=n.length;return n.some(Pu)&&(o+=v$),t&&(o+=b$),n.filter(s=>!Pu(s)).reduce((s,a)=>s+(h$.test(a)?g$:a===""?x$:y$),o)}function N$(e,t){return e.length===t.length&&e.slice(0,-1).every((o,s)=>o===t[s])?e[e.length-1]-t[t.length-1]:0}function k$(e,t,n=!1){let{routesMeta:o}=e,s={},a="/",i=[];for(let l=0;l<o.length;++l){let c=o[l],d=l===o.length-1,f=a==="/"?t:t.slice(a.length)||"/",p=$s({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},f),m=c.route;if(!p&&d&&n&&!o[o.length-1].route.index&&(p=$s({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!p)return null;Object.assign(s,p.params),i.push({params:s,pathname:Dt([a,p.pathname]),pathnameBase:P$(Dt([a,p.pathnameBase])),route:m}),p.pathnameBase!=="/"&&(a=Dt([a,p.pathnameBase]))}return i}function $s(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,o]=S$(e.path,e.caseSensitive,e.end),s=t.match(n);if(!s)return null;let a=s[0],i=a.replace(/(.)\/+$/,"$1"),l=s.slice(1);return{params:o.reduce((d,{paramName:f,isOptional:p},m)=>{if(f==="*"){let g=l[m]||"";i=a.slice(0,a.length-g.length).replace(/(.)\/+$/,"$1")}const h=l[m];return p&&!h?d[f]=void 0:d[f]=(h||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:i,pattern:e}}function S$(e,t=!1,n=!0){yt(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let o=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,c,d,f)=>{if(o.push({paramName:l,isOptional:c!=null}),c){let p=f.charAt(d+i.length);return p&&p!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(o.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),o]}function C$(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return yt(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function sn(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,o=e.charAt(n);return o&&o!=="/"?null:e.slice(n)||"/"}var M$=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function I$(e,t="/"){let{pathname:n,search:o="",hash:s=""}=typeof e=="string"?Dr(e):e,a;return n?(n=zx(n),n.startsWith("/")?a=Eu(n.substring(1),"/"):a=Eu(n,t)):a=t,{pathname:a,search:E$(o),hash:$$(s)}}function Eu(e,t){let n=_s(t).split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function ni(e,t,n,o){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function A$(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Fc(e){let t=A$(e);return t.map((n,o)=>o===t.length-1?n.pathname:n.pathnameBase)}function pa(e,t,n,o=!1){let s;typeof e=="string"?s=Dr(e):(s={...e},ze(!s.pathname||!s.pathname.includes("?"),ni("?","pathname","search",s)),ze(!s.pathname||!s.pathname.includes("#"),ni("#","pathname","hash",s)),ze(!s.search||!s.search.includes("#"),ni("#","search","hash",s)));let a=e===""||s.pathname==="",i=a?"/":s.pathname,l;if(i==null)l=n;else{let p=t.length-1;if(!o&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),p-=1;s.pathname=m.join("/")}l=p>=0?t[p]:"/"}let c=I$(s,l),d=i&&i!=="/"&&i.endsWith("/"),f=(a||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var zx=e=>e.replace(/\/\/+/g,"/"),Dt=e=>zx(e.join("/")),_s=e=>e.replace(/\/+$/,""),P$=e=>_s(e).replace(/^\/*/,"/"),E$=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,$$=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,_$=class{constructor(e,t,n,o=!1){this.status=e,this.statusText=t||"",this.internal=o,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function D$(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function L$(e){let t=e.map(n=>n.route.path).filter(Boolean);return Dt(t)||"/"}var Bx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Fx(e,t){let n=e;if(typeof n!="string"||!M$.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let o=n,s=!1;if(Bx)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=sn(i.pathname,t);i.origin===a.origin&&l!=null?n=l+i.search+i.hash:s=!0}catch{yt(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:s,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var jx=["POST","PUT","PATCH","DELETE"];new Set(jx);var T$=["GET",...jx];new Set(T$);var Lr=Oe(null);Lr.displayName="DataRouter";var fa=Oe(null);fa.displayName="DataRouterState";var Hx=Oe(!1);function R$(){return ve(Hx)}var Vx=Oe({isTransitioning:!1});Vx.displayName="ViewTransition";var O$=Oe(new Map);O$.displayName="Fetchers";var z$=Oe(null);z$.displayName="Await";var ft=Oe(null);ft.displayName="Navigation";var Ao=Oe(null);Ao.displayName="Location";var Ct=Oe({outlet:null,matches:[],isDataRoute:!1});Ct.displayName="Route";var jc=Oe(null);jc.displayName="RouteError";var qx="REACT_ROUTER_ERROR",B$="REDIRECT",F$="ROUTE_ERROR_RESPONSE";function j$(e){if(e.startsWith(`${qx}:${B$}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function H$(e){if(e.startsWith(`${qx}:${F$}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new _$(t.status,t.statusText,t.data)}catch{}}function V$(e,{relative:t}={}){ze(Tr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:o}=ve(ft),{hash:s,pathname:a,search:i}=Po(e,{relative:t}),l=a;return n!=="/"&&(l=a==="/"?n:Dt([n,a])),o.createHref({pathname:l,search:i,hash:s})}function Tr(){return ve(Ao)!=null}function mt(){return ze(Tr(),"useLocation() may be used only in the context of a <Router> component."),ve(Ao).location}var Ux="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Qx(e){ve(ft).static||Zs(e)}function Je(){let{isDataRoute:e}=ve(Ct);return e?o_():q$()}function q$(){ze(Tr(),"useNavigate() may be used only in the context of a <Router> component.");let e=ve(Lr),{basename:t,navigator:n}=ve(ft),{matches:o}=ve(Ct),{pathname:s}=mt(),a=JSON.stringify(Fc(o)),i=ne(!1);return Qx(()=>{i.current=!0}),q((c,d={})=>{if(yt(i.current,Ux),!i.current)return;if(typeof c=="number"){n.go(c);return}let f=pa(c,JSON.parse(a),s,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Dt([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,a,s,e])}var U$=Oe(null);function Q$(e){let t=ve(Ct).outlet;return U(()=>t&&Me(U$.Provider,{value:e},t),[t,e])}function Hc(){let{matches:e}=ve(Ct);return e[e.length-1]?.params??{}}function Po(e,{relative:t}={}){let{matches:n}=ve(Ct),{pathname:o}=mt(),s=JSON.stringify(Fc(n));return U(()=>pa(e,JSON.parse(s),o,t==="path"),[e,s,o,t])}function K$(e,t){return Kx(e,t)}function Kx(e,t,n){ze(Tr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=ve(ft),{matches:s}=ve(Ct),a=s[s.length-1],i=a?a.params:{},l=a?a.pathname:"/",c=a?a.pathnameBase:"/",d=a&&a.route;{let x=d&&d.path||"";Wx(l,!d||x.endsWith("*")||x.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${x}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
549
|
-
|
|
550
|
-
Please change the parent <Route path="${x}"> to <Route path="${x==="/"?"*":`${x}/*`}">.`)}let f=mt(),p;if(t){let x=typeof t=="string"?Dr(t):t;ze(c==="/"||x.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${x.pathname}" was given in the \`location\` prop.`),p=x}else p=f;let m=p.pathname||"/",h=m;if(c!=="/"){let x=c.replace(/^\//,"").split("/");h="/"+m.replace(/^\//,"").split("/").slice(x.length).join("/")}let g=n&&n.state.matches.length?n.state.matches.map(x=>Object.assign(x,{route:n.manifest[x.route.id]||x.route})):Tx(e,{pathname:h});yt(d||g!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),yt(g==null||g[g.length-1].route.element!==void 0||g[g.length-1].route.Component!==void 0||g[g.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let b=X$(g&&g.map(x=>Object.assign({},x,{params:Object.assign({},i,x.params),pathname:Dt([c,o.encodeLocation?o.encodeLocation(x.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?c:Dt([c,o.encodeLocation?o.encodeLocation(x.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathnameBase])})),s,n);return t&&b?Me(Ao.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...p},navigationType:"POP"}},b):b}function G$(){let e=r_(),t=D$(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,o="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:o},a={padding:"2px 4px",backgroundColor:o},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=Me(br,null,Me("p",null,"💿 Hey developer 👋"),Me("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",Me("code",{style:a},"ErrorBoundary")," or"," ",Me("code",{style:a},"errorElement")," prop on your route.")),Me(br,null,Me("h2",null,"Unexpected Application Error!"),Me("h3",{style:{fontStyle:"italic"}},t),n?Me("pre",{style:s},n):null,i)}var W$=Me(G$,null),Gx=class extends Z1{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=H$(e.digest);n&&(e=n)}let t=e!==void 0?Me(Ct.Provider,{value:this.props.routeContext},Me(jc.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?Me(Y$,{error:e},t):t}};Gx.contextType=Hx;var ri=new WeakMap;function Y$({children:e,error:t}){let{basename:n}=ve(ft);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let o=j$(t.digest);if(o){let s=ri.get(t);if(s)throw s;let a=Fx(o.location,n);if(Bx&&!ri.get(t))if(a.isExternal||o.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:o.replace}));throw ri.set(t,i),i}return Me("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function Z$({routeContext:e,match:t,children:n}){let o=ve(Lr);return o&&o.static&&o.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=t.route.id),Me(Ct.Provider,{value:e},n)}function X$(e,t=[],n){let o=n?.state;if(e==null){if(!o)return null;if(o.errors)e=o.matches;else if(t.length===0&&!o.initialized&&o.matches.length>0)e=o.matches;else return null}let s=e,a=o?.errors;if(a!=null){let f=s.findIndex(p=>p.route.id&&a?.[p.route.id]!==void 0);ze(f>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),s=s.slice(0,Math.min(s.length,f+1))}let i=!1,l=-1;if(n&&o){i=o.renderFallback;for(let f=0;f<s.length;f++){let p=s[f];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(l=f),p.route.id){let{loaderData:m,errors:h}=o,g=p.route.loader&&!m.hasOwnProperty(p.route.id)&&(!h||h[p.route.id]===void 0);if(p.route.lazy||g){n.isStatic&&(i=!0),l>=0?s=s.slice(0,l+1):s=[s[0]];break}}}}let c=n?.onError,d=o&&c?(f,p)=>{c(f,{location:o.location,params:o.matches?.[0]?.params??{},pattern:L$(o.matches),errorInfo:p})}:void 0;return s.reduceRight((f,p,m)=>{let h,g=!1,b=null,x=null;o&&(h=a&&p.route.id?a[p.route.id]:void 0,b=p.route.errorElement||W$,i&&(l<0&&m===0?(Wx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,x=null):l===m&&(g=!0,x=p.route.hydrateFallbackElement||null)));let y=t.concat(s.slice(0,m+1)),w=()=>{let v;return h?v=b:g?v=x:p.route.Component?v=Me(p.route.Component,null):p.route.element?v=p.route.element:v=f,Me(Z$,{match:p,routeContext:{outlet:f,matches:y,isDataRoute:o!=null},children:v})};return o&&(p.route.ErrorBoundary||p.route.errorElement||m===0)?Me(Gx,{location:o.location,revalidation:o.revalidation,component:b,error:h,children:w(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:d}):w()},null)}function Vc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function J$(e){let t=ve(Lr);return ze(t,Vc(e)),t}function e_(e){let t=ve(fa);return ze(t,Vc(e)),t}function t_(e){let t=ve(Ct);return ze(t,Vc(e)),t}function qc(e){let t=t_(e),n=t.matches[t.matches.length-1];return ze(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function n_(){return qc("useRouteId")}function r_(){let e=ve(jc),t=e_("useRouteError"),n=qc("useRouteError");return e!==void 0?e:t.errors?.[n]}function o_(){let{router:e}=J$("useNavigate"),t=qc("useNavigate"),n=ne(!1);return Qx(()=>{n.current=!0}),q(async(s,a={})=>{yt(n.current,Ux),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...a}))},[e,t])}var $u={};function Wx(e,t,n){!t&&!$u[e]&&($u[e]=!0,yt(!1,n))}Fe(s_);function s_({routes:e,manifest:t,future:n,state:o,isStatic:s,onError:a}){return Kx(e,void 0,{manifest:t,state:o,isStatic:s,onError:a})}function ht({to:e,replace:t,state:n,relative:o}){ze(Tr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:s}=ve(ft);yt(!s,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:a}=ve(Ct),{pathname:i}=mt(),l=Je(),c=pa(e,Fc(a),i,o==="path"),d=JSON.stringify(c);return Z(()=>{l(JSON.parse(d),{replace:t,state:n,relative:o})},[l,d,o,t,n]),null}function a_(e){return Q$(e.context)}function _e(e){ze(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function i_({basename:e="/",children:t=null,location:n,navigationType:o="POP",navigator:s,static:a=!1,useTransitions:i}){ze(!Tr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=U(()=>({basename:l,navigator:s,static:a,useTransitions:i,future:{}}),[l,s,a,i]);typeof n=="string"&&(n=Dr(n));let{pathname:d="/",search:f="",hash:p="",state:m=null,key:h="default",mask:g}=n,b=U(()=>{let x=sn(d,l);return x==null?null:{location:{pathname:x,search:f,hash:p,state:m,key:h,mask:g},navigationType:o}},[l,d,f,p,m,h,o,g]);return yt(b!=null,`<Router basename="${l}"> is not able to match the URL "${d}${f}${p}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:Me(ft.Provider,{value:c},Me(Ao.Provider,{children:t,value:b}))}function l_({children:e,location:t}){return K$(Zi(e),t)}function Zi(e,t=[]){let n=[];return W1.forEach(e,(o,s)=>{if(!Y1(o))return;let a=[...t,s];if(o.type===br){n.push.apply(n,Zi(o.props.children,a));return}ze(o.type===_e,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ze(!o.props.index||!o.props.children,"An index route cannot have child routes.");let i={id:o.props.id||a.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(i.children=Zi(o.props.children,a)),n.push(i)}),n}var xs="get",ys="application/x-www-form-urlencoded";function ma(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function c_(e){return ma(e)&&e.tagName.toLowerCase()==="button"}function d_(e){return ma(e)&&e.tagName.toLowerCase()==="form"}function u_(e){return ma(e)&&e.tagName.toLowerCase()==="input"}function p_(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function f_(e,t){return e.button===0&&(!t||t==="_self")&&!p_(e)}function Xi(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let o=e[n];return t.concat(Array.isArray(o)?o.map(s=>[n,s]):[[n,o]])},[]))}function m_(e,t){let n=Xi(e);return t&&t.forEach((o,s)=>{n.has(s)||t.getAll(s).forEach(a=>{n.append(s,a)})}),n}var Wo=null;function h_(){if(Wo===null)try{new FormData(document.createElement("form"),0),Wo=!1}catch{Wo=!0}return Wo}var g_=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function oi(e){return e!=null&&!g_.has(e)?(yt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ys}"`),null):e}function b_(e,t){let n,o,s,a,i;if(d_(e)){let l=e.getAttribute("action");o=l?sn(l,t):null,n=e.getAttribute("method")||xs,s=oi(e.getAttribute("enctype"))||ys,a=new FormData(e)}else if(c_(e)||u_(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(o=c?sn(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||xs,s=oi(e.getAttribute("formenctype"))||oi(l.getAttribute("enctype"))||ys,a=new FormData(l,e),!h_()){let{name:d,type:f,value:p}=e;if(f==="image"){let m=d?`${d}.`:"";a.append(`${m}x`,"0"),a.append(`${m}y`,"0")}else d&&a.append(d,p)}}else{if(ma(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=xs,o=null,s=ys,i=e}return a&&s==="text/plain"&&(i=a,a=void 0),{action:o,method:n.toLowerCase(),encType:s,formData:a,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Uc(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Yx(e,t,n,o){let s=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?s.pathname.endsWith("/")?s.pathname=`${s.pathname}_.${o}`:s.pathname=`${s.pathname}.${o}`:s.pathname==="/"?s.pathname=`_root.${o}`:t&&sn(s.pathname,t)==="/"?s.pathname=`${_s(t)}/_root.${o}`:s.pathname=`${_s(s.pathname)}.${o}`,s}async function x_(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function y_(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function v_(e,t,n){let o=await Promise.all(e.map(async s=>{let a=t.routes[s.route.id];if(a){let i=await x_(a,n);return i.links?i.links():[]}return[]}));return S_(o.flat(1).filter(y_).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function _u(e,t,n,o,s,a){let i=(c,d)=>n[d]?c.route.id!==n[d].route.id:!0,l=(c,d)=>n[d].pathname!==c.pathname||n[d].route.path?.endsWith("*")&&n[d].params["*"]!==c.params["*"];return a==="assets"?t.filter((c,d)=>i(c,d)||l(c,d)):a==="data"?t.filter((c,d)=>{let f=o.routes[c.route.id];if(!f||!f.hasLoader)return!1;if(i(c,d)||l(c,d))return!0;if(c.route.shouldRevalidate){let p=c.route.shouldRevalidate({currentUrl:new URL(s.pathname+s.search+s.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof p=="boolean")return p}return!0}):[]}function w_(e,t,{includeHydrateFallback:n}={}){return N_(e.map(o=>{let s=t.routes[o.route.id];if(!s)return[];let a=[s.module];return s.clientActionModule&&(a=a.concat(s.clientActionModule)),s.clientLoaderModule&&(a=a.concat(s.clientLoaderModule)),n&&s.hydrateFallbackModule&&(a=a.concat(s.hydrateFallbackModule)),s.imports&&(a=a.concat(s.imports)),a}).flat(1))}function N_(e){return[...new Set(e)]}function k_(e){let t={},n=Object.keys(e).sort();for(let o of n)t[o]=e[o];return t}function S_(e,t){let n=new Set;return new Set(t),e.reduce((o,s)=>{let a=JSON.stringify(k_(s));return n.has(a)||(n.add(a),o.push({key:a,link:s})),o},[])}function Qc(){let e=ve(Lr);return Uc(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function C_(){let e=ve(fa);return Uc(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Kc=Oe(void 0);Kc.displayName="FrameworkContext";function Gc(){let e=ve(Kc);return Uc(e,"You must render this element inside a <HydratedRouter> element"),e}function M_(e,t){let n=ve(Kc),[o,s]=$(!1),[a,i]=$(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:f,onTouchStart:p}=t,m=ne(null);Z(()=>{if(e==="render"&&i(!0),e==="viewport"){let b=y=>{y.forEach(w=>{i(w.isIntersecting)})},x=new IntersectionObserver(b,{threshold:.5});return m.current&&x.observe(m.current),()=>{x.disconnect()}}},[e]),Z(()=>{if(o){let b=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(b)}}},[o]);let h=()=>{s(!0)},g=()=>{s(!1),i(!1)};return n?e!=="intent"?[a,m,{}]:[a,m,{onFocus:Fr(l,h),onBlur:Fr(c,g),onMouseEnter:Fr(d,h),onMouseLeave:Fr(f,g),onTouchStart:Fr(p,h)}]:[!1,m,{}]}function Fr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function I_({page:e,...t}){let n=R$(),{router:o}=Qc(),s=U(()=>Tx(o.routes,e,o.basename),[o.routes,e,o.basename]);return s?n?Me(P_,{page:e,matches:s,...t}):Me(E_,{page:e,matches:s,...t}):null}function A_(e){let{manifest:t,routeModules:n}=Gc(),[o,s]=$([]);return Z(()=>{let a=!1;return v_(e,t,n).then(i=>{a||s(i)}),()=>{a=!0}},[e,t,n]),o}function P_({page:e,matches:t,...n}){let o=mt(),{future:s}=Gc(),{basename:a}=Qc(),i=U(()=>{if(e===o.pathname+o.search+o.hash)return[];let l=Yx(e,a,s.unstable_trailingSlashAwareDataRequests,"rsc"),c=!1,d=[];for(let f of t)typeof f.route.shouldRevalidate=="function"?c=!0:d.push(f.route.id);return c&&d.length>0&&l.searchParams.set("_routes",d.join(",")),[l.pathname+l.search]},[a,s.unstable_trailingSlashAwareDataRequests,e,o,t]);return Me(br,null,i.map(l=>Me("link",{key:l,rel:"prefetch",as:"fetch",href:l,...n})))}function E_({page:e,matches:t,...n}){let o=mt(),{future:s,manifest:a,routeModules:i}=Gc(),{basename:l}=Qc(),{loaderData:c,matches:d}=C_(),f=U(()=>_u(e,t,d,a,o,"data"),[e,t,d,a,o]),p=U(()=>_u(e,t,d,a,o,"assets"),[e,t,d,a,o]),m=U(()=>{if(e===o.pathname+o.search+o.hash)return[];let b=new Set,x=!1;if(t.forEach(w=>{let v=a.routes[w.route.id];!v||!v.hasLoader||(!f.some(N=>N.route.id===w.route.id)&&w.route.id in c&&i[w.route.id]?.shouldRevalidate||v.hasClientLoader?x=!0:b.add(w.route.id))}),b.size===0)return[];let y=Yx(e,l,s.unstable_trailingSlashAwareDataRequests,"data");return x&&b.size>0&&y.searchParams.set("_routes",t.filter(w=>b.has(w.route.id)).map(w=>w.route.id).join(",")),[y.pathname+y.search]},[l,s.unstable_trailingSlashAwareDataRequests,c,o,a,f,t,e,i]),h=U(()=>w_(p,a),[p,a]),g=A_(p);return Me(br,null,m.map(b=>Me("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),h.map(b=>Me("link",{key:b,rel:"modulepreload",href:b,...n})),g.map(({key:b,link:x})=>Me("link",{key:b,nonce:n.nonce,...x,crossOrigin:x.crossOrigin??n.crossOrigin})))}function $_(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var __=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{__&&(window.__reactRouterVersion="7.15.0")}catch{}function D_({basename:e,children:t,useTransitions:n,window:o}){let s=ne();s.current==null&&(s.current=l$({window:o,v5Compat:!0}));let a=s.current,[i,l]=$({action:a.action,location:a.location}),c=q(d=>{n===!1?l(d):$l(()=>l(d))},[n]);return Zs(()=>a.listen(c),[a,c]),Me(i_,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,useTransitions:n})}var Zx=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,co=He(function({onClick:t,discover:n="render",prefetch:o="none",relative:s,reloadDocument:a,replace:i,mask:l,state:c,target:d,to:f,preventScrollReset:p,viewTransition:m,defaultShouldRevalidate:h,...g},b){let{basename:x,navigator:y,useTransitions:w}=ve(ft),v=typeof f=="string"&&Zx.test(f),N=Fx(f,x);f=N.to;let k=V$(f,{relative:s}),S=mt(),M=null;if(l){let L=pa(l,[],S.mask?S.mask.pathname:"/",!0);x!=="/"&&(L.pathname=L.pathname==="/"?x:Dt([x,L.pathname])),M=y.createHref(L)}let[P,A,z]=M_(o,g),D=O_(f,{replace:i,mask:l,state:c,target:d,preventScrollReset:p,relative:s,viewTransition:m,defaultShouldRevalidate:h,useTransitions:w});function T(L){t&&t(L),L.defaultPrevented||D(L)}let O=!(N.isExternal||a),I=Me("a",{...g,...z,href:(O?M:void 0)||N.absoluteURL||k,onClick:O?T:t,ref:$_(b,A),target:d,"data-discover":!v&&n==="render"?"true":void 0});return P&&!v?Me(br,null,I,Me(I_,{page:k})):I});co.displayName="Link";var L_=He(function({"aria-current":t="page",caseSensitive:n=!1,className:o="",end:s=!1,style:a,to:i,viewTransition:l,children:c,...d},f){let p=Po(i,{relative:d.relative}),m=mt(),h=ve(fa),{navigator:g,basename:b}=ve(ft),x=h!=null&&H_(p)&&l===!0,y=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,w=m.pathname,v=h&&h.navigation&&h.navigation.location?h.navigation.location.pathname:null;n||(w=w.toLowerCase(),v=v?v.toLowerCase():null,y=y.toLowerCase()),v&&b&&(v=sn(v,b)||v);const N=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let k=w===y||!s&&w.startsWith(y)&&w.charAt(N)==="/",S=v!=null&&(v===y||!s&&v.startsWith(y)&&v.charAt(y.length)==="/"),M={isActive:k,isPending:S,isTransitioning:x},P=k?t:void 0,A;typeof o=="function"?A=o(M):A=[o,k?"active":null,S?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let z=typeof a=="function"?a(M):a;return Me(co,{...d,"aria-current":P,className:A,ref:f,style:z,to:i,viewTransition:l},typeof c=="function"?c(M):c)});L_.displayName="NavLink";var T_=He(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:o,replace:s,state:a,method:i=xs,action:l,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m,...h},g)=>{let{useTransitions:b}=ve(ft),x=F_(),y=j_(l,{relative:d}),w=i.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&Zx.test(l);return Me("form",{ref:g,method:w,action:y,onSubmit:o?c:k=>{if(c&&c(k),k.defaultPrevented)return;k.preventDefault();let S=k.nativeEvent.submitter,M=S?.getAttribute("formmethod")||i,P=()=>x(S||k.currentTarget,{fetcherKey:t,method:M,navigate:n,replace:s,state:a,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m});b&&n!==!1?$l(()=>P()):P()},...h,"data-discover":!v&&e==="render"?"true":void 0})});T_.displayName="Form";function R_(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Xx(e){let t=ve(Lr);return ze(t,R_(e)),t}function O_(e,{target:t,replace:n,mask:o,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c,useTransitions:d}={}){let f=Je(),p=mt(),m=Po(e,{relative:i});return q(h=>{if(f_(h,t)){h.preventDefault();let g=n!==void 0?n:lo(p)===lo(m),b=()=>f(e,{replace:g,mask:o,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c});d?$l(()=>b()):b()}},[p,f,m,n,o,s,t,e,a,i,l,c,d])}function ha(e){yt(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=ne(Xi(e)),n=ne(!1),o=mt(),s=U(()=>m_(o.search,n.current?null:t.current),[o.search]),a=Je(),i=q((l,c)=>{const d=Xi(typeof l=="function"?l(new URLSearchParams(s)):l);n.current=!0,a("?"+d,c)},[a,s]);return[s,i]}var z_=0,B_=()=>`__${String(++z_)}__`;function F_(){let{router:e}=Xx("useSubmit"),{basename:t}=ve(ft),n=n_(),o=e.fetch,s=e.navigate;return q(async(a,i={})=>{let{action:l,method:c,encType:d,formData:f,body:p}=b_(a,t);if(i.navigate===!1){let m=i.fetcherKey||B_();await o(m,n,i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:p,formMethod:i.method||c,formEncType:i.encType||d,flushSync:i.flushSync})}else await s(i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:p,formMethod:i.method||c,formEncType:i.encType||d,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[o,s,t,n])}function j_(e,{relative:t}={}){let{basename:n}=ve(ft),o=ve(Ct);ze(o,"useFormAction must be used inside a RouteContext");let[s]=o.matches.slice(-1),a={...Po(e||".",{relative:t})},i=mt();if(e==null){a.search=i.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(f=>f==="")){l.delete("index"),c.filter(p=>p).forEach(p=>l.append("index",p));let f=l.toString();a.search=f?`?${f}`:""}}return(!e||e===".")&&s.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Dt([n,a.pathname])),lo(a)}function H_(e,{relative:t}={}){let n=ve(Vx);ze(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Xx("useViewTransitionState"),s=Po(e,{relative:t});if(!n.isTransitioning)return!1;let a=sn(n.currentLocation.pathname,o)||n.currentLocation.pathname,i=sn(n.nextLocation.pathname,o)||n.nextLocation.pathname;return $s(s.pathname,i)!=null||$s(s.pathname,a)!=null}const V_=3e4;function q_(e){const t=ne(e);t.current=e,Z(()=>{let n=null;const o=()=>{if(document.visibilityState==="hidden"){n=Date.now();return}if(document.visibilityState==="visible"&&n!==null){const i=Date.now()-n;n=null,i>=V_&&t.current()}},s=()=>{t.current()},a=i=>{i.persisted&&t.current()};return document.addEventListener("visibilitychange",o),window.addEventListener("online",s),window.addEventListener("pageshow",a),()=>{document.removeEventListener("visibilitychange",o),window.removeEventListener("online",s),window.removeEventListener("pageshow",a)}},[])}let Ji="disconnected";const el=new Set;function U_(){for(const e of el)e()}function Q_(e){Ji!==e&&(Ji=e,U_())}function K_(e){return el.add(e),()=>{el.delete(e)}}function Du(){return Ji}function G_(){return Xs(K_,Du,Du)}let Yr=null;function tl(){if(!Yr){const e=window.location.origin,t=localStorage.getItem("camstack_admin_token")??void 0;Yr=Uf({serverUrl:e,token:t,onConnectionChange:n=>Q_(n)})}return Yr}function Zr(){Yr?.close(),Yr=null}function W_(e){const t=pn();return t===null?r("div",{className:"rounded-md border border-warning/40 bg-warning/10 p-3 text-xs text-warning",children:"zone-editor: no DeviceContext — declare this field inside a top-tab section rendered from a device-detail page."}):r(at,{widgetId:"pipeline-orchestrator/zone-editor",host:"device-tab",deviceId:t})}function Y_({deviceId:e}){return u("div",{className:gm,children:[u("div",{className:`grid ${bm}`,style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 340px), 1fr))"},children:[r(at,{widgetId:"pipeline-analytics/live-occupancy-panel",host:"device-tab",deviceId:e}),r(at,{widgetId:"pipeline-analytics/audio-metrics-panel",host:"device-tab",deviceId:e})]}),r(at,{widgetId:"pipeline-analytics/audio-history-chart",host:"device-tab",deviceId:e}),r(at,{widgetId:"pipeline-analytics/occupancy-history-chart",host:"device-tab",deviceId:e}),r(at,{widgetId:"pipeline-analytics/motion-history-chart",host:"device-tab",deviceId:e}),r(at,{widgetId:"pipeline-analytics/detection-history-chart",host:"device-tab",deviceId:e})]})}function Z_(e){const t=pn();return t===null?r("div",{className:"rounded-md border border-warning/40 bg-warning/10 p-3 text-xs text-warning",children:"live-stats: no DeviceContext — declare this field inside a top-tab section rendered from a device-detail page."}):r(Y_,{deviceId:t})}/**
|
|
551
|
-
* @license lucide-react v0.511.0 - ISC
|
|
552
|
-
*
|
|
553
|
-
* This source code is licensed under the ISC license.
|
|
554
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
555
|
-
*/const X_=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),J_=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase()),Lu=e=>{const t=J_(e);return t.charAt(0).toUpperCase()+t.slice(1)},Jx=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim(),eD=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/**
|
|
556
|
-
* @license lucide-react v0.511.0 - ISC
|
|
557
|
-
*
|
|
558
|
-
* This source code is licensed under the ISC license.
|
|
559
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
560
|
-
*/var tD={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
561
|
-
* @license lucide-react v0.511.0 - ISC
|
|
562
|
-
*
|
|
563
|
-
* This source code is licensed under the ISC license.
|
|
564
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
565
|
-
*/const nD=He(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:s="",children:a,iconNode:i,...l},c)=>Me("svg",{ref:c,...tD,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:Jx("lucide",s),...!a&&!eD(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,f])=>Me(d,f)),...Array.isArray(a)?a:[a]]));/**
|
|
566
|
-
* @license lucide-react v0.511.0 - ISC
|
|
567
|
-
*
|
|
568
|
-
* This source code is licensed under the ISC license.
|
|
569
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
570
|
-
*/const se=(e,t)=>{const n=He(({className:o,...s},a)=>Me(nD,{ref:a,iconNode:t,className:Jx(`lucide-${X_(Lu(e))}`,`lucide-${e}`,o),...s}));return n.displayName=Lu(e),n};/**
|
|
571
|
-
* @license lucide-react v0.511.0 - ISC
|
|
572
|
-
*
|
|
573
|
-
* This source code is licensed under the ISC license.
|
|
574
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
575
|
-
*/const rD=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Eo=se("activity",rD);/**
|
|
576
|
-
* @license lucide-react v0.511.0 - ISC
|
|
577
|
-
*
|
|
578
|
-
* This source code is licensed under the ISC license.
|
|
579
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
580
|
-
*/const oD=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],Wc=se("archive",oD);/**
|
|
581
|
-
* @license lucide-react v0.511.0 - ISC
|
|
582
|
-
*
|
|
583
|
-
* This source code is licensed under the ISC license.
|
|
584
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
585
|
-
*/const sD=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],ey=se("arrow-left",sD);/**
|
|
586
|
-
* @license lucide-react v0.511.0 - ISC
|
|
587
|
-
*
|
|
588
|
-
* This source code is licensed under the ISC license.
|
|
589
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
590
|
-
*/const aD=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],ty=se("arrow-right",aD);/**
|
|
591
|
-
* @license lucide-react v0.511.0 - ISC
|
|
592
|
-
*
|
|
593
|
-
* This source code is licensed under the ISC license.
|
|
594
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
595
|
-
*/const iD=[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}],["line",{x1:"10",x2:"10",y1:"11",y2:"13",key:"haxvl5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"13",key:"c6fn6x"}]],lD=se("battery-full",iD);/**
|
|
596
|
-
* @license lucide-react v0.511.0 - ISC
|
|
597
|
-
*
|
|
598
|
-
* This source code is licensed under the ISC license.
|
|
599
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
600
|
-
*/const cD=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],$o=se("bell",cD);/**
|
|
601
|
-
* @license lucide-react v0.511.0 - ISC
|
|
602
|
-
*
|
|
603
|
-
* This source code is licensed under the ISC license.
|
|
604
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
605
|
-
*/const dD=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],uD=se("bot",dD);/**
|
|
606
|
-
* @license lucide-react v0.511.0 - ISC
|
|
607
|
-
*
|
|
608
|
-
* This source code is licensed under the ISC license.
|
|
609
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
610
|
-
*/const pD=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],ga=se("box",pD);/**
|
|
611
|
-
* @license lucide-react v0.511.0 - ISC
|
|
612
|
-
*
|
|
613
|
-
* This source code is licensed under the ISC license.
|
|
614
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
615
|
-
*/const fD=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],ba=se("boxes",fD);/**
|
|
616
|
-
* @license lucide-react v0.511.0 - ISC
|
|
617
|
-
*
|
|
618
|
-
* This source code is licensed under the ISC license.
|
|
619
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
620
|
-
*/const mD=[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],hD=se("calendar-clock",mD);/**
|
|
621
|
-
* @license lucide-react v0.511.0 - ISC
|
|
622
|
-
*
|
|
623
|
-
* This source code is licensed under the ISC license.
|
|
624
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
625
|
-
*/const gD=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],ny=se("calendar",gD);/**
|
|
626
|
-
* @license lucide-react v0.511.0 - ISC
|
|
627
|
-
*
|
|
628
|
-
* This source code is licensed under the ISC license.
|
|
629
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
630
|
-
*/const bD=[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],xr=se("camera",bD);/**
|
|
631
|
-
* @license lucide-react v0.511.0 - ISC
|
|
632
|
-
*
|
|
633
|
-
* This source code is licensed under the ISC license.
|
|
634
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
635
|
-
*/const xD=[["path",{d:"M16.75 12h3.632a1 1 0 0 1 .894 1.447l-2.034 4.069a1 1 0 0 1-1.708.134l-2.124-2.97",key:"ir91b5"}],["path",{d:"M17.106 9.053a1 1 0 0 1 .447 1.341l-3.106 6.211a1 1 0 0 1-1.342.447L3.61 12.3a2.92 2.92 0 0 1-1.3-3.91L3.69 5.6a2.92 2.92 0 0 1 3.92-1.3z",key:"jlp8i1"}],["path",{d:"M2 19h3.76a2 2 0 0 0 1.8-1.1L9 15",key:"19bib8"}],["path",{d:"M2 21v-4",key:"l40lih"}],["path",{d:"M7 9h.01",key:"19b3jx"}]],ry=se("cctv",xD);/**
|
|
636
|
-
* @license lucide-react v0.511.0 - ISC
|
|
637
|
-
*
|
|
638
|
-
* This source code is licensed under the ISC license.
|
|
639
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
640
|
-
*/const yD=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],vD=se("check-check",yD);/**
|
|
641
|
-
* @license lucide-react v0.511.0 - ISC
|
|
642
|
-
*
|
|
643
|
-
* This source code is licensed under the ISC license.
|
|
644
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
645
|
-
*/const wD=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Mt=se("check",wD);/**
|
|
646
|
-
* @license lucide-react v0.511.0 - ISC
|
|
647
|
-
*
|
|
648
|
-
* This source code is licensed under the ISC license.
|
|
649
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
650
|
-
*/const ND=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],vt=se("chevron-down",ND);/**
|
|
651
|
-
* @license lucide-react v0.511.0 - ISC
|
|
652
|
-
*
|
|
653
|
-
* This source code is licensed under the ISC license.
|
|
654
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
655
|
-
*/const kD=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Yc=se("chevron-left",kD);/**
|
|
656
|
-
* @license lucide-react v0.511.0 - ISC
|
|
657
|
-
*
|
|
658
|
-
* This source code is licensed under the ISC license.
|
|
659
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
660
|
-
*/const SD=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],It=se("chevron-right",SD);/**
|
|
661
|
-
* @license lucide-react v0.511.0 - ISC
|
|
662
|
-
*
|
|
663
|
-
* This source code is licensed under the ISC license.
|
|
664
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
665
|
-
*/const CD=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],MD=se("chevron-up",CD);/**
|
|
666
|
-
* @license lucide-react v0.511.0 - ISC
|
|
667
|
-
*
|
|
668
|
-
* This source code is licensed under the ISC license.
|
|
669
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
670
|
-
*/const ID=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],xa=se("circle-alert",ID);/**
|
|
671
|
-
* @license lucide-react v0.511.0 - ISC
|
|
672
|
-
*
|
|
673
|
-
* This source code is licensed under the ISC license.
|
|
674
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
675
|
-
*/const AD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],oy=se("circle-check",AD);/**
|
|
676
|
-
* @license lucide-react v0.511.0 - ISC
|
|
677
|
-
*
|
|
678
|
-
* This source code is licensed under the ISC license.
|
|
679
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
680
|
-
*/const PD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],sy=se("circle-dot",PD);/**
|
|
681
|
-
* @license lucide-react v0.511.0 - ISC
|
|
682
|
-
*
|
|
683
|
-
* This source code is licensed under the ISC license.
|
|
684
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
685
|
-
*/const ED=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],$D=se("circle-help",ED);/**
|
|
686
|
-
* @license lucide-react v0.511.0 - ISC
|
|
687
|
-
*
|
|
688
|
-
* This source code is licensed under the ISC license.
|
|
689
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
690
|
-
*/const _D=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],DD=se("clock",_D);/**
|
|
691
|
-
* @license lucide-react v0.511.0 - ISC
|
|
692
|
-
*
|
|
693
|
-
* This source code is licensed under the ISC license.
|
|
694
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
695
|
-
*/const LD=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],TD=se("copy",LD);/**
|
|
696
|
-
* @license lucide-react v0.511.0 - ISC
|
|
697
|
-
*
|
|
698
|
-
* This source code is licensed under the ISC license.
|
|
699
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
700
|
-
*/const RD=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],dt=se("cpu",RD);/**
|
|
701
|
-
* @license lucide-react v0.511.0 - ISC
|
|
702
|
-
*
|
|
703
|
-
* This source code is licensed under the ISC license.
|
|
704
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
705
|
-
*/const OD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],zD=se("crosshair",OD);/**
|
|
706
|
-
* @license lucide-react v0.511.0 - ISC
|
|
707
|
-
*
|
|
708
|
-
* This source code is licensed under the ISC license.
|
|
709
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
710
|
-
*/const BD=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],ay=se("database",BD);/**
|
|
711
|
-
* @license lucide-react v0.511.0 - ISC
|
|
712
|
-
*
|
|
713
|
-
* This source code is licensed under the ISC license.
|
|
714
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
715
|
-
*/const FD=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Nn=se("download",FD);/**
|
|
716
|
-
* @license lucide-react v0.511.0 - ISC
|
|
717
|
-
*
|
|
718
|
-
* This source code is licensed under the ISC license.
|
|
719
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
720
|
-
*/const jD=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],HD=se("ellipsis-vertical",jD);/**
|
|
721
|
-
* @license lucide-react v0.511.0 - ISC
|
|
722
|
-
*
|
|
723
|
-
* This source code is licensed under the ISC license.
|
|
724
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
725
|
-
*/const VD=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Zc=se("external-link",VD);/**
|
|
726
|
-
* @license lucide-react v0.511.0 - ISC
|
|
727
|
-
*
|
|
728
|
-
* This source code is licensed under the ISC license.
|
|
729
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
730
|
-
*/const qD=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],iy=se("eye-off",qD);/**
|
|
731
|
-
* @license lucide-react v0.511.0 - ISC
|
|
732
|
-
*
|
|
733
|
-
* This source code is licensed under the ISC license.
|
|
734
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
735
|
-
*/const UD=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],_o=se("eye",UD);/**
|
|
736
|
-
* @license lucide-react v0.511.0 - ISC
|
|
737
|
-
*
|
|
738
|
-
* This source code is licensed under the ISC license.
|
|
739
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
740
|
-
*/const QD=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],Xr=se("film",QD);/**
|
|
741
|
-
* @license lucide-react v0.511.0 - ISC
|
|
742
|
-
*
|
|
743
|
-
* This source code is licensed under the ISC license.
|
|
744
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
745
|
-
*/const KD=[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]],GD=se("flame",KD);/**
|
|
746
|
-
* @license lucide-react v0.511.0 - ISC
|
|
747
|
-
*
|
|
748
|
-
* This source code is licensed under the ISC license.
|
|
749
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
750
|
-
*/const WD=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],ly=se("gauge",WD);/**
|
|
751
|
-
* @license lucide-react v0.511.0 - ISC
|
|
752
|
-
*
|
|
753
|
-
* This source code is licensed under the ISC license.
|
|
754
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
755
|
-
*/const YD=[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]],nl=se("ghost",YD);/**
|
|
756
|
-
* @license lucide-react v0.511.0 - ISC
|
|
757
|
-
*
|
|
758
|
-
* This source code is licensed under the ISC license.
|
|
759
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
760
|
-
*/const ZD=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],cy=se("git-branch",ZD);/**
|
|
761
|
-
* @license lucide-react v0.511.0 - ISC
|
|
762
|
-
*
|
|
763
|
-
* This source code is licensed under the ISC license.
|
|
764
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
765
|
-
*/const XD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],yr=se("globe",XD);/**
|
|
766
|
-
* @license lucide-react v0.511.0 - ISC
|
|
767
|
-
*
|
|
768
|
-
* This source code is licensed under the ISC license.
|
|
769
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
770
|
-
*/const JD=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],uo=se("hard-drive",JD);/**
|
|
771
|
-
* @license lucide-react v0.511.0 - ISC
|
|
772
|
-
*
|
|
773
|
-
* This source code is licensed under the ISC license.
|
|
774
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
775
|
-
*/const eL=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]],tL=se("house",eL);/**
|
|
776
|
-
* @license lucide-react v0.511.0 - ISC
|
|
777
|
-
*
|
|
778
|
-
* This source code is licensed under the ISC license.
|
|
779
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
780
|
-
*/const nL=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Bn=se("info",nL);/**
|
|
781
|
-
* @license lucide-react v0.511.0 - ISC
|
|
782
|
-
*
|
|
783
|
-
* This source code is licensed under the ISC license.
|
|
784
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
785
|
-
*/const rL=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],dy=se("key-round",rL);/**
|
|
786
|
-
* @license lucide-react v0.511.0 - ISC
|
|
787
|
-
*
|
|
788
|
-
* This source code is licensed under the ISC license.
|
|
789
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
790
|
-
*/const oL=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],sL=se("key",oL);/**
|
|
791
|
-
* @license lucide-react v0.511.0 - ISC
|
|
792
|
-
*
|
|
793
|
-
* This source code is licensed under the ISC license.
|
|
794
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
795
|
-
*/const aL=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],iL=se("languages",aL);/**
|
|
796
|
-
* @license lucide-react v0.511.0 - ISC
|
|
797
|
-
*
|
|
798
|
-
* This source code is licensed under the ISC license.
|
|
799
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
800
|
-
*/const lL=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],cL=se("layers",lL);/**
|
|
801
|
-
* @license lucide-react v0.511.0 - ISC
|
|
802
|
-
*
|
|
803
|
-
* This source code is licensed under the ISC license.
|
|
804
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
805
|
-
*/const dL=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],uy=se("layout-dashboard",dL);/**
|
|
806
|
-
* @license lucide-react v0.511.0 - ISC
|
|
807
|
-
*
|
|
808
|
-
* This source code is licensed under the ISC license.
|
|
809
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
810
|
-
*/const uL=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],pL=se("lightbulb",uL);/**
|
|
811
|
-
* @license lucide-react v0.511.0 - ISC
|
|
812
|
-
*
|
|
813
|
-
* This source code is licensed under the ISC license.
|
|
814
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
815
|
-
*/const fL=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ae=se("loader-circle",fL);/**
|
|
816
|
-
* @license lucide-react v0.511.0 - ISC
|
|
817
|
-
*
|
|
818
|
-
* This source code is licensed under the ISC license.
|
|
819
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
820
|
-
*/const mL=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],py=se("lock",mL);/**
|
|
821
|
-
* @license lucide-react v0.511.0 - ISC
|
|
822
|
-
*
|
|
823
|
-
* This source code is licensed under the ISC license.
|
|
824
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
825
|
-
*/const hL=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],gL=se("log-in",hL);/**
|
|
826
|
-
* @license lucide-react v0.511.0 - ISC
|
|
827
|
-
*
|
|
828
|
-
* This source code is licensed under the ISC license.
|
|
829
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
830
|
-
*/const bL=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Xc=se("log-out",bL);/**
|
|
831
|
-
* @license lucide-react v0.511.0 - ISC
|
|
832
|
-
*
|
|
833
|
-
* This source code is licensed under the ISC license.
|
|
834
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
835
|
-
*/const xL=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],yL=se("map-pin",xL);/**
|
|
836
|
-
* @license lucide-react v0.511.0 - ISC
|
|
837
|
-
*
|
|
838
|
-
* This source code is licensed under the ISC license.
|
|
839
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
840
|
-
*/const vL=[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]],Jc=se("memory-stick",vL);/**
|
|
841
|
-
* @license lucide-react v0.511.0 - ISC
|
|
842
|
-
*
|
|
843
|
-
* This source code is licensed under the ISC license.
|
|
844
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
845
|
-
*/const wL=[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]],NL=se("menu",wL);/**
|
|
846
|
-
* @license lucide-react v0.511.0 - ISC
|
|
847
|
-
*
|
|
848
|
-
* This source code is licensed under the ISC license.
|
|
849
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
850
|
-
*/const kL=[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]],rl=se("mic",kL);/**
|
|
851
|
-
* @license lucide-react v0.511.0 - ISC
|
|
852
|
-
*
|
|
853
|
-
* This source code is licensed under the ISC license.
|
|
854
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
855
|
-
*/const SL=[["path",{d:"M5 12h14",key:"1ays0h"}]],CL=se("minus",SL);/**
|
|
856
|
-
* @license lucide-react v0.511.0 - ISC
|
|
857
|
-
*
|
|
858
|
-
* This source code is licensed under the ISC license.
|
|
859
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
860
|
-
*/const ML=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],IL=se("monitor",ML);/**
|
|
861
|
-
* @license lucide-react v0.511.0 - ISC
|
|
862
|
-
*
|
|
863
|
-
* This source code is licensed under the ISC license.
|
|
864
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
865
|
-
*/const AL=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],fy=se("moon",AL);/**
|
|
866
|
-
* @license lucide-react v0.511.0 - ISC
|
|
867
|
-
*
|
|
868
|
-
* This source code is licensed under the ISC license.
|
|
869
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
870
|
-
*/const PL=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],EL=se("move",PL);/**
|
|
871
|
-
* @license lucide-react v0.511.0 - ISC
|
|
872
|
-
*
|
|
873
|
-
* This source code is licensed under the ISC license.
|
|
874
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
875
|
-
*/const $L=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],an=se("network",$L);/**
|
|
876
|
-
* @license lucide-react v0.511.0 - ISC
|
|
877
|
-
*
|
|
878
|
-
* This source code is licensed under the ISC license.
|
|
879
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
880
|
-
*/const _L=[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],DL=se("octagon-alert",_L);/**
|
|
881
|
-
* @license lucide-react v0.511.0 - ISC
|
|
882
|
-
*
|
|
883
|
-
* This source code is licensed under the ISC license.
|
|
884
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
885
|
-
*/const LL=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],my=se("package",LL);/**
|
|
886
|
-
* @license lucide-react v0.511.0 - ISC
|
|
887
|
-
*
|
|
888
|
-
* This source code is licensed under the ISC license.
|
|
889
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
890
|
-
*/const TL=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Rr=se("pencil",TL);/**
|
|
891
|
-
* @license lucide-react v0.511.0 - ISC
|
|
892
|
-
*
|
|
893
|
-
* This source code is licensed under the ISC license.
|
|
894
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
895
|
-
*/const RL=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],hy=se("pin",RL);/**
|
|
896
|
-
* @license lucide-react v0.511.0 - ISC
|
|
897
|
-
*
|
|
898
|
-
* This source code is licensed under the ISC license.
|
|
899
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
900
|
-
*/const OL=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],ya=se("play",OL);/**
|
|
901
|
-
* @license lucide-react v0.511.0 - ISC
|
|
902
|
-
*
|
|
903
|
-
* This source code is licensed under the ISC license.
|
|
904
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
905
|
-
*/const zL=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],ed=se("plug",zL);/**
|
|
906
|
-
* @license lucide-react v0.511.0 - ISC
|
|
907
|
-
*
|
|
908
|
-
* This source code is licensed under the ISC license.
|
|
909
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
910
|
-
*/const BL=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],wt=se("plus",BL);/**
|
|
911
|
-
* @license lucide-react v0.511.0 - ISC
|
|
912
|
-
*
|
|
913
|
-
* This source code is licensed under the ISC license.
|
|
914
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
915
|
-
*/const FL=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],gy=se("power",FL);/**
|
|
916
|
-
* @license lucide-react v0.511.0 - ISC
|
|
917
|
-
*
|
|
918
|
-
* This source code is licensed under the ISC license.
|
|
919
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
920
|
-
*/const jL=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],Ds=se("puzzle",jL);/**
|
|
921
|
-
* @license lucide-react v0.511.0 - ISC
|
|
922
|
-
*
|
|
923
|
-
* This source code is licensed under the ISC license.
|
|
924
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
925
|
-
*/const HL=[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]],VL=se("radar",HL);/**
|
|
926
|
-
* @license lucide-react v0.511.0 - ISC
|
|
927
|
-
*
|
|
928
|
-
* This source code is licensed under the ISC license.
|
|
929
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
930
|
-
*/const qL=[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]],td=se("radio",qL);/**
|
|
931
|
-
* @license lucide-react v0.511.0 - ISC
|
|
932
|
-
*
|
|
933
|
-
* This source code is licensed under the ISC license.
|
|
934
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
935
|
-
*/const UL=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],ut=se("refresh-cw",UL);/**
|
|
936
|
-
* @license lucide-react v0.511.0 - ISC
|
|
937
|
-
*
|
|
938
|
-
* This source code is licensed under the ISC license.
|
|
939
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
940
|
-
*/const QL=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],by=se("rotate-ccw",QL);/**
|
|
941
|
-
* @license lucide-react v0.511.0 - ISC
|
|
942
|
-
*
|
|
943
|
-
* This source code is licensed under the ISC license.
|
|
944
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
945
|
-
*/const KL=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],gt=se("rotate-cw",KL);/**
|
|
946
|
-
* @license lucide-react v0.511.0 - ISC
|
|
947
|
-
*
|
|
948
|
-
* This source code is licensed under the ISC license.
|
|
949
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
950
|
-
*/const GL=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],WL=se("save",GL);/**
|
|
951
|
-
* @license lucide-react v0.511.0 - ISC
|
|
952
|
-
*
|
|
953
|
-
* This source code is licensed under the ISC license.
|
|
954
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
955
|
-
*/const YL=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],Xe=se("scroll-text",YL);/**
|
|
956
|
-
* @license lucide-react v0.511.0 - ISC
|
|
957
|
-
*
|
|
958
|
-
* This source code is licensed under the ISC license.
|
|
959
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
960
|
-
*/const ZL=[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],XL=se("search-x",ZL);/**
|
|
961
|
-
* @license lucide-react v0.511.0 - ISC
|
|
962
|
-
*
|
|
963
|
-
* This source code is licensed under the ISC license.
|
|
964
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
965
|
-
*/const JL=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],xy=se("search",JL);/**
|
|
966
|
-
* @license lucide-react v0.511.0 - ISC
|
|
967
|
-
*
|
|
968
|
-
* This source code is licensed under the ISC license.
|
|
969
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
970
|
-
*/const eT=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],ln=se("server",eT);/**
|
|
971
|
-
* @license lucide-react v0.511.0 - ISC
|
|
972
|
-
*
|
|
973
|
-
* This source code is licensed under the ISC license.
|
|
974
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
975
|
-
*/const tT=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Nt=se("settings",tT);/**
|
|
976
|
-
* @license lucide-react v0.511.0 - ISC
|
|
977
|
-
*
|
|
978
|
-
* This source code is licensed under the ISC license.
|
|
979
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
980
|
-
*/const nT=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Kt=se("shield-check",nT);/**
|
|
981
|
-
* @license lucide-react v0.511.0 - ISC
|
|
982
|
-
*
|
|
983
|
-
* This source code is licensed under the ISC license.
|
|
984
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
985
|
-
*/const rT=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]],oT=se("shield-x",rT);/**
|
|
986
|
-
* @license lucide-react v0.511.0 - ISC
|
|
987
|
-
*
|
|
988
|
-
* This source code is licensed under the ISC license.
|
|
989
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
990
|
-
*/const sT=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],aT=se("shield",sT);/**
|
|
991
|
-
* @license lucide-react v0.511.0 - ISC
|
|
992
|
-
*
|
|
993
|
-
* This source code is licensed under the ISC license.
|
|
994
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
995
|
-
*/const iT=[["path",{d:"m12.5 17-.5-1-.5 1h1z",key:"3me087"}],["path",{d:"M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z",key:"1o5pge"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]],Yo=se("skull",iT);/**
|
|
996
|
-
* @license lucide-react v0.511.0 - ISC
|
|
997
|
-
*
|
|
998
|
-
* This source code is licensed under the ISC license.
|
|
999
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1000
|
-
*/const lT=[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]],cT=se("sparkles",lT);/**
|
|
1001
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1002
|
-
*
|
|
1003
|
-
* This source code is licensed under the ISC license.
|
|
1004
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1005
|
-
*/const dT=[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],yy=se("square-check-big",dT);/**
|
|
1006
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1007
|
-
*
|
|
1008
|
-
* This source code is licensed under the ISC license.
|
|
1009
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1010
|
-
*/const uT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Do=se("square",uT);/**
|
|
1011
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1012
|
-
*
|
|
1013
|
-
* This source code is licensed under the ISC license.
|
|
1014
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1015
|
-
*/const pT=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],si=se("star",pT);/**
|
|
1016
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1017
|
-
*
|
|
1018
|
-
* This source code is licensed under the ISC license.
|
|
1019
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1020
|
-
*/const fT=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],mT=se("sun",fT);/**
|
|
1021
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1022
|
-
*
|
|
1023
|
-
* This source code is licensed under the ISC license.
|
|
1024
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1025
|
-
*/const hT=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],gT=se("table-2",hT);/**
|
|
1026
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1027
|
-
*
|
|
1028
|
-
* This source code is licensed under the ISC license.
|
|
1029
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1030
|
-
*/const bT=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],vy=se("terminal",bT);/**
|
|
1031
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1032
|
-
*
|
|
1033
|
-
* This source code is licensed under the ISC license.
|
|
1034
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1035
|
-
*/const xT=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],Ge=se("trash-2",xT);/**
|
|
1036
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1037
|
-
*
|
|
1038
|
-
* This source code is licensed under the ISC license.
|
|
1039
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1040
|
-
*/const yT=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],bt=se("triangle-alert",yT);/**
|
|
1041
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1042
|
-
*
|
|
1043
|
-
* This source code is licensed under the ISC license.
|
|
1044
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1045
|
-
*/const vT=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],va=se("upload",vT);/**
|
|
1046
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1047
|
-
*
|
|
1048
|
-
* This source code is licensed under the ISC license.
|
|
1049
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1050
|
-
*/const wT=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],wy=se("users",wT);/**
|
|
1051
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1052
|
-
*
|
|
1053
|
-
* This source code is licensed under the ISC license.
|
|
1054
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1055
|
-
*/const NT=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Ny=se("video",NT);/**
|
|
1056
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1057
|
-
*
|
|
1058
|
-
* This source code is licensed under the ISC license.
|
|
1059
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1060
|
-
*/const kT=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],ky=se("wifi-off",kT);/**
|
|
1061
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1062
|
-
*
|
|
1063
|
-
* This source code is licensed under the ISC license.
|
|
1064
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1065
|
-
*/const ST=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Vn=se("wifi",ST);/**
|
|
1066
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1067
|
-
*
|
|
1068
|
-
* This source code is licensed under the ISC license.
|
|
1069
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1070
|
-
*/const CT=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ve=se("x",CT);/**
|
|
1071
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1072
|
-
*
|
|
1073
|
-
* This source code is licensed under the ISC license.
|
|
1074
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1075
|
-
*/const MT=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]],IT=se("wrench",MT);/**
|
|
1076
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1077
|
-
*
|
|
1078
|
-
* This source code is licensed under the ISC license.
|
|
1079
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1080
|
-
*/const AT=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],nd=se("zap",AT);function PT(e){const t=Le();return Wn({queryKey:["field-resolver",e?.capName??"<none>",e?.methodName??"<none>",e?.input??{}],enabled:!!e,queryFn:async()=>{if(!e)throw new Error("useFieldResolver: resolver is null (enabled guard should have prevented this)");const n=i=>i!==null&&(typeof i=="object"||typeof i=="function"),o=Reflect.get(t.trpcClient,e.capName);if(!n(o))throw new Error(`useFieldResolver: no cap namespace '${e.capName}' on the tRPC client`);const s=Reflect.get(o,e.methodName);if(!n(s))throw new Error(`useFieldResolver: no method '${e.methodName}' on cap '${e.capName}'`);const a=Reflect.get(s,"query");if(typeof a!="function")throw new Error(`useFieldResolver: '${e.capName}.${e.methodName}' has no .query() (resolvers must be query methods, not mutations)`);return await a(e.input??{})}})}function ET(e){return typeof e=="string"&&e.length>0&&e!=="undefined"&&e!=="null"}function $T(e={}){const t=ke(),n=_r(void 0,{staleTime:1e4,enabled:e.enabled??!0}),o=U(()=>(n.data??[]).filter(i=>ET(i.nodeId)),[n.data]),s=q(()=>{t.invalidateQueries({queryKey:["pipelineOrchestrator","listAgentSettings"]})},[t]);return{agents:o,isLoading:n.isLoading,isError:n.isError,error:n.error,refetch:()=>{n.refetch()},invalidate:s}}function _T({field:e,disabled:t}){const n=ke(),o=e.deviceId,s=PT(e.catalogResolver),a=vc({agentNodeId:e.nodeId}),i=Nc({deviceId:o}),c=Ab({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),d=s.data,f=a.data??null,p=i.data??null,m=U(()=>d?LT(d,f,p):[],[d,f,p]),h=U(()=>{if(!f)return{};const g={};for(const[b,x]of Object.entries(f.addonDefaults))g[b]=x.enabled;return g},[f]);return s.error?u("div",{className:"text-xs text-red-400",children:["Failed to load pipeline catalog for ",r("code",{children:e.nodeId}),": ",String(s.error.message??s.error)]}):s.isLoading||!d||a.isLoading?u("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading pipeline for ",e.nodeId,"…"]}):u("div",{className:"col-span-full space-y-4",children:[u("div",{className:"flex items-center gap-2 text-[11px] text-foreground-subtle",children:["Agent: ",r("span",{className:"text-foreground",children:e.nodeId}),u("span",{className:"ml-2",children:["Engine: ",r("span",{className:"text-foreground font-mono",children:`${d.selectedEngine.runtime}/${d.selectedEngine.backend}`})]}),u("span",{className:"ml-auto text-[10px]",children:["Model + settings edited on Pipeline → ",e.nodeId,"."]})]}),r(sc,{schema:d,steps:m,onChange:()=>{},templates:[],selectedTemplateId:null,onSelectTemplate:()=>{},onSaveTemplate:()=>{},onUpdateTemplate:()=>{},onDeleteTemplate:()=>{},readOnly:t===!0,hideTemplates:!0,toggleMode:"threeState",hideModelAndSettings:!0,overrides:p?.stepToggles??{},onOverrideChange:(g,b)=>c.mutate({deviceId:o,addonId:g,enabled:b}),inheritedEnabledByAddon:h}),r(DT,{deviceId:o,currentAgentNodeId:e.nodeId,catalog:d,pipelineByAgent:p?.pipelineByAgent??{},disabled:t===!0})]})}function DT({deviceId:e,currentAgentNodeId:t,catalog:n,pipelineByAgent:o,disabled:s}){const a=ke(),[i,l]=$(!1),[c,d]=$(t),{agents:f}=$T({enabled:i}),p=$b({deviceId:e,agentNodeId:c},{enabled:i}),h=Eb({onSuccess:()=>{a.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),a.invalidateQueries({queryKey:[["pipelineOrchestrator","resolvePipeline"]]})}}),g=o[c]??null,b=f,x=U(()=>g?TT(g.steps,n):[],[g,n]),y=w=>{const v=g?.audio??null;h.mutate({deviceId:e,agentNodeId:c,pipeline:{steps:RT(w),audio:v?{modelId:v.modelId,enabled:v.enabled}:null}})};return u("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("button",{type:"button",onClick:()=>l(w=>!w),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover",children:[i?r(vt,{className:"h-3 w-3"}):r(It,{className:"h-3 w-3"}),r("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:"Advanced — custom pipeline per agent"}),r("span",{className:"ml-auto text-[10px] text-foreground-subtle",children:Object.keys(o).length>0?`${Object.keys(o).length} override(s) active`:"None configured"})]}),i&&u("div",{className:"border-t border-border px-4 py-3 space-y-3",children:[u("div",{className:"flex items-center gap-2 text-xs",children:[r("span",{className:"text-foreground-subtle",children:"Agent:"}),u("select",{value:c,disabled:s,onChange:w=>d(w.target.value),className:"rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary",children:[typeof t=="string"&&t.length>0&&t!=="undefined"&&u("option",{value:t,children:[t," (current)"]}),b.filter(w=>w.nodeId!==t).map(w=>r("option",{value:w.nodeId,children:w.nodeId},w.nodeId))]}),o[c]&&u("button",{type:"button",onClick:()=>{window.confirm(`Remove custom pipeline override for ${c}? The camera will revert to the agent default + step toggles.`)&&h.mutate({deviceId:e,agentNodeId:c,pipeline:null})},disabled:s||h.isPending,className:"ml-auto inline-flex items-center gap-1 px-2 py-1 text-[11px] text-red-400 hover:bg-red-500/10 rounded disabled:opacity-50",children:[r(Ge,{className:"h-3 w-3"}),"Remove override"]})]}),g?r(sc,{schema:n,steps:x,onChange:y,templates:[],selectedTemplateId:null,onSelectTemplate:()=>{},onSaveTemplate:()=>{},onUpdateTemplate:()=>{},onDeleteTemplate:()=>{},readOnly:s,hideTemplates:!0}):u("div",{className:"text-xs text-foreground-subtle space-y-2",children:[u("p",{children:["No custom pipeline for ",r("code",{children:c}),". The camera uses the agent's default + step toggles."]}),r("button",{type:"button",onClick:()=>{const w=p.data;w&&h.mutate({deviceId:e,agentNodeId:c,pipeline:{steps:w.steps,audio:w.audio?{modelId:w.audio.modelId,enabled:w.audio.enabled}:null}})},disabled:s||h.isPending||!p.data,className:"inline-flex items-center gap-1 px-3 py-1.5 text-xs font-medium rounded bg-primary/15 text-primary hover:bg-primary/25 disabled:opacity-50",children:"Create wholesale override from current default"})]})]})]})}function LT(e,t,n){const o=d=>{for(const f of e.slots)for(const p of f.addons)if(p.id===d)return p;return null},s=d=>{const f=t?.addonDefaults[d.id],p=f?.enabled??d.enabledByDefault??!0,m=n?.stepToggles?.[d.id],h=m!==void 0?m:p;return{addonId:d.id,addonName:d.name,slot:d.slot,inputClasses:[...d.inputClasses],outputClasses:[...d.outputClasses],enabled:h,modelId:f?.modelId??d.defaultModelId,children:[],...f?.settings&&Object.keys(f.settings).length>0?{settings:f.settings}:{}}},a=new Map;for(const d of e.slots)for(const f of d.addons)a.set(f.id,s(f));const i=[],l=new Set;for(const[d,f]of a){const p=o(d);p&&p.inputClasses.length===0&&(i.push(f),l.add(d))}let c=!0;for(;c;){c=!1;for(const[d,f]of a){if(l.has(d))continue;const p=o(d);if(p)for(const[m,h]of a){if(m===d)continue;const g=o(m);if(g&&l.has(m)&&g.outputClasses.some(b=>p.inputClasses.includes(b))){h.children.push(f),l.add(d),c=!0;break}}}}return i}function TT(e,t){const n=new Map;for(const s of t.slots)for(const a of s.addons)n.set(a.id,a);const o=s=>{const a=n.get(s.addonId);return{addonId:s.addonId,addonName:a?.name??s.addonId,slot:a?.slot??"detector",inputClasses:a?.inputClasses?[...a.inputClasses]:[],outputClasses:a?.outputClasses?[...a.outputClasses]:[],enabled:s.enabled,modelId:s.modelId,children:(s.children??[]).map(o),...s.settings?{settings:{...s.settings}}:{}}};return[...e].map(o)}function RT(e){const t=n=>({addonId:n.addonId,modelId:n.modelId,enabled:n.enabled,children:n.children.map(t),...n.settings?{settings:{...n.settings}}:{}});return e.map(t)}function OT({tabs:e,active:t,onChange:n}){return r("div",{className:"flex rounded-lg border border-border bg-surface p-0.5 gap-0.5",children:e.map(o=>r("button",{type:"button",onClick:()=>n(o.id),className:["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",t===o.id?"bg-primary/12 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"].join(" "),children:o.label},o.id))})}function zT(e){const t=e.formats;if(!t)return"";const n=Object.values(t).filter(a=>a!==void 0&&a.sizeMB>0).map(a=>a.sizeMB);if(n.length===0)return"";const o=Math.min(...n),s=Math.max(...n);return o===s?`${o} MB`:`${o}-${s} MB`}function BT(e){return`${e.inputSize.width}x${e.inputSize.height}`}function FT(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function jT({entry:e,selected:t,onSelect:n,disabled:o}){const s=zT(e),a=BT(e),i=FT(e);return u("button",{type:"button",onClick:n,disabled:o,className:["w-full text-left rounded-lg border p-3 transition-all",t?"border-primary bg-primary/5 ring-1 ring-primary/30":"border-border bg-background hover:border-foreground-subtle/40 hover:bg-surface-hover/50",o?"opacity-50 cursor-not-allowed":"cursor-pointer"].join(" "),children:[r("div",{className:"flex items-start justify-between gap-2",children:u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-xs font-semibold text-foreground truncate",children:e.name}),t&&r(Mt,{className:"h-3.5 w-3.5 text-primary shrink-0"})]}),r("p",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-2",children:e.description})]})}),u("div",{className:"flex items-center gap-3 mt-2 flex-wrap",children:[u("span",{className:"inline-flex items-center gap-1 text-[10px] text-foreground-subtle",children:[r(dt,{className:"h-3 w-3"}),a]}),s&&r("span",{className:"text-[10px] text-foreground-subtle",children:s}),i.length>0&&r("div",{className:"flex gap-1",children:i.map(l=>r("span",{className:"text-[9px] uppercase rounded bg-surface border border-border px-1 py-0.5 text-foreground-subtle font-mono",children:l},l))}),e.labels.length>0&&u("span",{className:"text-[10px] text-foreground-subtle",children:[e.labels.length," label",e.labels.length!==1?"s":""]})]})]})}function HT({field:e,value:t,onChange:n,disabled:o}){const s=e.catalog??[],a=s.length>0,i=e.allowCustomPath!==!1||e.allowCustom===!0,l=[...a?[{id:"catalog",label:`Models (${s.length})`}]:[],...i?[{id:"custom",label:"Custom Path"}]:[]],[c,d]=$(a?"catalog":"custom"),f=t==null?"":String(t);return u("div",{className:"space-y-3",children:[l.length>1&&r(OT,{tabs:l,active:c,onChange:d}),c==="catalog"&&a&&r("div",{className:"space-y-1.5 max-h-[320px] overflow-y-auto pr-1",children:s.map(p=>r(jT,{entry:p,selected:f===p.id,onSelect:()=>n(p.id),disabled:o||e.disabled},p.id))}),c==="catalog"&&!a&&u("div",{className:"rounded-md border border-info/30 bg-info/5 px-3 py-2 flex items-start gap-2",children:[r(Bn,{className:"h-3.5 w-3.5 text-info shrink-0 mt-0.5"}),r("p",{className:"text-[11px] text-foreground-subtle leading-relaxed",children:"No predefined models available. Use the Custom Path tab to specify a model file path or URL."})]}),c==="custom"&&i&&u("div",{className:"space-y-2",children:[r("input",{type:"text",className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none disabled:opacity-50",placeholder:"Enter path like /data/models/custom.onnx or https://...",value:f,disabled:o||e.disabled,onChange:p=>n(p.target.value)}),e.acceptFormats&&e.acceptFormats.length>0&&u("p",{className:"text-[10px] text-foreground-subtle",children:["Accepted formats: ",e.acceptFormats.join(", ")]})]}),(e.compatibilityNote||e.conversionGuideUrl)&&u("div",{className:"flex items-start justify-between gap-3 pt-1",children:[e.compatibilityNote&&u("p",{className:"flex items-start gap-1 text-[10px] text-foreground-subtle",children:[r(Bn,{className:"h-3 w-3 mt-0.5 shrink-0"}),e.compatibilityNote]}),e.conversionGuideUrl&&u("a",{href:e.conversionGuideUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-[11px] text-primary hover:underline shrink-0",children:["How to convert your model",r(Zc,{className:"h-3 w-3"})]})]})]})}function Sy(e){const t=Le();return Lx(t.trpcClient,e)}function VT({deviceId:e,deviceName:t,hasPTZ:n=!1,className:o}){const s=Le(),a=typeof window<"u"?window.location.origin:"",i=Number.isFinite(e),[l,c]=$(!1),d=i&&n&&l,f=St(s.trpcClient,i?e:null),p=ne(!1),{data:m,isLoading:h,isFetching:g,refetch:b}=Wn({queryKey:["device",e,"snapshot.getSnapshot"],queryFn:()=>{const A=p.current;return p.current=!1,f?.snapshot?.getSnapshot({force:A})??null},enabled:!!f&&i,staleTime:5e3,retry:!1}),x=()=>{p.current=!0,b()},{streams:y,pipelineMetrics:w,createSession:v,sendAnswer:N,closeSession:k}=Oc(s.trpcClient,i?e:null),S=Sy(i?e:null),M=zc(s.trpcClient,i?e:0,{enabled:d}),P=m?`data:${m.contentType};base64,${m.base64}`:null;return r(Ec,{serverUrl:a,createSession:v,sendAnswer:N,closeSession:k,streams:y,pipelineMetrics:w,deviceName:t,phase:S.phase,detections:S,defaultShowDetections:!1,defaultShowMotion:!1,autoPlay:!1,showPlayStop:!0,snapshotSrc:P,snapshotLoading:h||g,onRefreshSnapshot:x,ptzAvailable:i&&n,ptzShown:d,onPtzToggle:()=>c(A=>!A),ptzOverlay:d?r(Dc,{controls:M}):void 0,className:o})}function qT(){const e=pn(),t=ic();if(e===null)return null;const n=typeof t?.name=="string"?t.name:"",s=(t?.features??[]).includes(On.PanTiltZoom);return r(VT,{deviceId:e,deviceName:n,hasPTZ:s})}function xt(e,t){const n=Le(),o=ke(),[s,a]=$(n.connectionVersion);Z(()=>n.subscribeConnectionEvents((c,d)=>{c==="connected"&&a(d)}),[n]);const i=t.join("|"),l=JSON.stringify(e);Z(()=>{const c=[],d=()=>{const f=JSON.parse(l),m=f.length===1&&Array.isArray(f[0])?f:[f];o.invalidateQueries({queryKey:m})};d();for(const f of i.split("|"))if(f)try{c.push(n.subscribeEvent(f,d))}catch{}return()=>{for(const f of c)f()}},[n,o,i,l,s])}function Zo({icon:e,label:t,value:n,subtext:o,color:s}){return u("div",{className:"rounded-lg border border-border bg-surface p-2 sm:p-2.5 min-w-0",children:[u("div",{className:"flex items-center gap-1.5 mb-0.5 min-w-0",children:[r(e,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),r("span",{className:`${Is} uppercase tracking-wider whitespace-nowrap overflow-hidden text-ellipsis min-w-0`,children:t})]}),r("p",{className:`${s?`${Oi.replace("text-foreground","")} ${s}`:Oi} whitespace-nowrap overflow-hidden text-ellipsis`,children:n}),o&&r("p",{className:`${Is} mt-0.5 truncate`,children:o})]})}function Xo({label:e,value:t,warning:n}){return u("div",{className:"min-w-0",children:[r("p",{className:`${Is} truncate`,children:e}),r("p",{className:`text-[11px] font-medium truncate ${n?"text-warning":"text-foreground"}`,children:t})]})}function tn({label:e,value:t}){return u("div",{className:`${xm} flex items-start gap-2 sm:gap-3`,children:[r("span",{className:"w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle",children:e}),r("div",{className:"flex-1 min-w-0 text-[11px] text-foreground",children:t})]})}function UT(){const e=pn();xt(["pipelineOrchestrator","getPipelineAssignment"],["pipeline.camera-assigned","pipeline.camera-unassigned","pipeline.camera-updated"]),xt(["pipelineRunner","getCameraMetrics"],["pipeline.camera-metrics-snapshot"]);const{data:t}=la({deviceId:e??0},{enabled:e!==null,staleTime:3e4}),n=t?.agentNodeId??null,s=typeof n=="string"&&n.length>0&&!n.startsWith("addon:")?n:void 0,{data:a}=kc({deviceId:e??0,...s?{nodeId:s}:{}},{enabled:e!==null,staleTime:2e3,retry:!1}),i=Le(),l=St(i.trpcClient,e),{data:c}=Wn({queryKey:["device",e,"pipelineAnalytics.getActiveTracks"],queryFn:()=>l?.pipelineAnalytics?.getActiveTracks({})??[],enabled:!!l&&e!==null,refetchInterval:5e3,retry:!1});if(e===null)return null;const d=a?.phase??null,f=a?.detectionMode??null,p=Number(a?.actualFps??0),m=Number(a?.configuredFps??0),h=Number(a?.avgInferenceTimeMs??0),g=Number(a?.queueDepth??0),b=Number(a?.droppedFrames??0),x=Zn(d??"watching"),y=c?.length??0;return u("div",{className:"grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4 gap-2 sm:gap-3",children:[r(Zo,{icon:Eo,label:"Phase",value:x.label,color:x.textColor,subtext:f??void 0}),r(Zo,{icon:ly,label:"Detection FPS",value:`${p.toFixed(1)}`,subtext:m>0?`target: ${m}`:void 0}),r(Zo,{icon:dt,label:"Inference",value:`${h.toFixed(1)} ms`,subtext:g>0?`queue: ${g}`:void 0}),r(Zo,{icon:_o,label:"Active Tracks",value:String(y),subtext:b>0?`dropped: ${b}`:void 0})]})}function ai(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function QT(){const e=pn(),{data:t}=yc({deviceId:e??0},{enabled:e!==null,refetchInterval:5e3});if(e===null)return null;const n=t?.streams??{},o=Object.entries(n);return o.length===0?null:u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r("div",{className:"border-b border-border px-3 sm:px-4 py-2",children:r("h2",{className:"text-[11px] font-semibold text-foreground uppercase tracking-wider",children:"Stream Network"})}),r("div",{className:"divide-y divide-border",children:o.map(([s,a])=>u("div",{className:"px-3 sm:px-4 py-2",children:[u("div",{className:"flex items-center gap-1.5 mb-1.5",children:[r(Vn,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),r("span",{className:"text-[11px] font-medium text-foreground truncate",children:s})]}),u("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-2",children:[r(Xo,{label:"Nominal",value:ai(a.nominalBitrateKbps??0)}),r(Xo,{label:"Observed",value:ai(a.observedBitrateKbps??0)}),r(Xo,{label:"Peak",value:ai(a.peakBitrateKbps??0)}),r(Xo,{label:"Packet Loss",value:`${(a.packetLossPercent??0).toFixed(2)}%`,warning:(a.packetLossPercent??0)>1})]})]},s))})]})}const KT=3e4;function GT({field:e}){const t=pn(),n=e.type==="doorbell-recent"&&typeof e.historyLimit=="number"?e.historyLimit:10,o=Bc({deviceId:t??void 0,historyLimit:n});if(t===null)return null;const s=o.latest?Date.now()-o.latest.timestamp<KT:!1;return r(Lc,{history:o.history,latestIsFresh:s})}const WT={streaming:{icon:Ny,label:"Streaming"},detection:{icon:_o,label:"Detection"},recording:{icon:sy,label:"Recording"},audio:{icon:rl,label:"Audio"},snapshot:{icon:xr,label:"Snapshot"},motion:{icon:nd,label:"Motion"},ptz:{icon:Nt,label:"PTZ"},webrtc:{icon:td,label:"WebRTC"},onvif:{icon:aT,label:"ONVIF"},analytics:{icon:dt,label:"Analytics"},"battery-operated":{icon:lD,label:"Battery"},"native-snapshot":{icon:xr,label:"Native Snapshot"},"pan-tilt-zoom":{icon:Nt,label:"PTZ"},"two-way-audio":{icon:rl,label:"Two-way Audio"},"doorbell-button":{icon:$o,label:"Doorbell"},rebootable:{icon:ut,label:"Rebootable"}},YT=ga;function wa({capabilities:e,showLabels:t=!1}){return r("div",{className:"flex items-center gap-1 flex-wrap",children:e.map(n=>{const o=WT[n],s=o?.icon??YT,a=o?.label??n;return u("span",{className:"inline-flex items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] text-foreground-subtle",title:a,children:[r(s,{className:"h-3 w-3"}),t&&r("span",{children:a})]},n)})})}const ZT={frigate:{icon:ry,color:"#3b82f6",label:"Frigate"},scrypted:{icon:ln,color:"#a855f7",label:"Scrypted"},reolink:{icon:td,color:"#06b6d4",label:"Reolink"},homeassistant:{icon:tL,color:"#22d3ee",label:"Home Assistant"},rtsp:{icon:Vn,color:"#78716c",label:"RTSP"},onvif:{icon:Vn,color:"#78716c",label:"ONVIF"}},Tu={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"},XT={sm:"h-7 w-7",md:"h-8 w-8",lg:"h-10 w-10"};function Cy(e){const t=e.toLowerCase();return t.startsWith("provider-")?t.slice(9):t}function JT(e){const t=Cy(e);return ZT[t]??{icon:ry,color:"#78716c",label:e}}function eR(e){const t=Cy(e);return`/api/addon-assets/${e.toLowerCase().startsWith("provider-")?e:`provider-${t}`}/assets/icon.svg`}function cn({type:e,size:t="md",showLabel:n}){const o=JT(e),s=o.icon,[a,i]=$(!1),l=eR(e);return u("div",{className:"flex items-center gap-2",children:[r("div",{className:`flex items-center justify-center rounded-lg ${XT[t]}`,style:{backgroundColor:`${o.color}15`},children:a?r(s,{className:Tu[t],style:{color:o.color}}):r("img",{src:l,alt:o.label,className:Tu[t],onError:()=>i(!0)})}),n&&r("span",{className:"text-xs font-medium text-foreground-subtle",children:o.label})]})}function tR({deviceId:e,initialName:t}){const n=ke(),[o,s]=$(!1),[a,i]=$(t),[l,c]=$(!1),d=ne(null);Z(()=>{o||i(t)},[t,o]),Z(()=>{o&&d.current?.focus()},[o]);const f=wg({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDevice"]]}),n.invalidateQueries({queryKey:[["deviceManager","listAll"]]}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]})}}),p=async()=>{const h=a.trim();if(h.length===0||h===t){s(!1),i(t);return}c(!0);try{await f.mutateAsync({deviceId:e,name:h}),s(!1)}catch{}finally{c(!1)}},m=()=>{i(t),s(!1)};return o?r(tn,{label:"Name",value:u("div",{className:"flex items-center gap-1",children:[r("input",{ref:d,type:"text",value:a,onChange:h=>i(h.target.value),onKeyDown:h=>{h.key==="Enter"?p():h.key==="Escape"&&m()},disabled:l,className:"flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary"}),r("button",{type:"button",onClick:()=>void p(),disabled:l,className:"p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50","aria-label":"Save",children:r(Mt,{className:"h-3 w-3"})}),r("button",{type:"button",onClick:m,disabled:l,className:"p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50","aria-label":"Cancel",children:r(Ve,{className:"h-3 w-3"})})]})}):r(tn,{label:"Name",value:u("div",{className:"flex items-center gap-2 group",children:[r("span",{className:"truncate",children:t}),r("button",{type:"button",onClick:()=>s(!0),className:"opacity-0 group-hover:opacity-100 transition-opacity p-0.5 rounded hover:bg-surface-hover","aria-label":"Edit name",children:r(Rr,{className:"h-3 w-3 text-foreground-subtle"})})]})})}function nR({deviceId:e,initialLocation:t}){const n=ke(),[o,s]=$(!1),[a,i]=$(t??""),[l,c]=$(!1),d=ne(null),{data:f}=kg(void 0,{staleTime:3e4,enabled:o}),p=f??[];Z(()=>{o||i(t??"")},[t,o]),Z(()=>{o&&d.current?.focus()},[o]);const m=Ng({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDevice"]]}),n.invalidateQueries({queryKey:[["deviceManager","listAll"]]}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]}),n.invalidateQueries({queryKey:[["deviceManager","listLocations"]]})}}),h=U(()=>{const y=a.trim().toLowerCase();return y.length===0?p:p.filter(w=>w.toLowerCase()!==y&&w.toLowerCase().includes(y))},[p,a]),g=a.trim().length>0&&!p.some(y=>y.toLowerCase()===a.trim().toLowerCase()),b=async y=>{const v=(y??a).trim(),N=v.length===0?null:v;if(N===(t??null)){s(!1);return}c(!0);try{await m.mutateAsync({deviceId:e,location:N}),s(!1)}catch{}finally{c(!1)}},x=()=>{i(t??""),s(!1)};return o?r(tn,{label:"Location",value:u("div",{className:"relative",children:[u("div",{className:"flex items-center gap-1",children:[r("input",{ref:d,type:"text",value:a,onChange:y=>i(y.target.value),onKeyDown:y=>{y.key==="Enter"?b():y.key==="Escape"&&x()},disabled:l,placeholder:"Room / area (or leave empty to clear)",className:"flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary"}),r("button",{type:"button",onClick:()=>void b(),disabled:l,className:"p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50","aria-label":"Save",children:r(Mt,{className:"h-3 w-3"})}),r("button",{type:"button",onClick:x,disabled:l,className:"p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50","aria-label":"Cancel",children:r(Ve,{className:"h-3 w-3"})})]}),(h.length>0||g)&&u("div",{className:"absolute z-10 left-0 right-0 mt-0.5 max-h-40 overflow-y-auto rounded-md border border-border bg-surface shadow-md",children:[h.map(y=>u("button",{type:"button",onClick:()=>{i(y),b(y)},className:"w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover",children:[r(yL,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),r("span",{className:"truncate",children:y})]},y)),g&&u("button",{type:"button",onClick:()=>void b(),className:"w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover border-t border-border",children:[r("span",{className:"text-foreground-subtle",children:"Create"}),u("span",{className:"font-medium truncate",children:['"',a.trim(),'"']})]})]})]})}):r(tn,{label:"Location",value:u("div",{className:"flex items-center gap-2 group",children:[t?r("span",{className:"truncate",children:t}):r("span",{className:"italic text-foreground-subtle",children:"unset"}),r("button",{type:"button",onClick:()=>s(!0),className:"opacity-0 group-hover:opacity-100 transition-opacity p-0.5 rounded hover:bg-surface-hover","aria-label":"Edit location",children:r(Rr,{className:"h-3 w-3 text-foreground-subtle"})})]})})}const Ru=["manufacturer","model","hardware","firmware","serialNumber","uid","mac","itemNo"];function rR(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}function oR(e){return e==null?"—":typeof e=="string"||typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e)}function My(){const e=pn(),t=ic(),{data:n}=Hn({deviceId:e??0},{enabled:e!==null,staleTime:3e4}),o=n??t??null,[s,a]=$("identity");if(e===null||!o)return null;const i=String(o.stableId??""),l=String(o.name??""),c=String(o.type??""),d=String(o.addonId??""),f=o.features??[],p=o.location??null,m=o.metadata??null,h=m!==null&&Object.keys(m).length>0;return u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3",children:[r("h2",{className:"text-[11px] font-semibold text-foreground uppercase tracking-wider",children:"Device Info"}),h&&u("div",{className:"flex items-center gap-1 rounded-md bg-surface-hover p-0.5",children:[r(Ou,{active:s==="identity",onClick:()=>a("identity"),label:"Identity"}),r(Ou,{active:s==="hardware",onClick:()=>a("hardware"),label:"Hardware"})]})]}),(!h||s==="identity")&&u("div",{className:"divide-y divide-border",children:[r(tn,{label:"ID",value:u("span",{className:"font-mono text-[11px] text-foreground",children:[`#${e}`,u("span",{className:"ml-1.5 text-foreground-subtle",children:["(",i,")"]})]})}),r(tR,{deviceId:e,initialName:l}),r(nR,{deviceId:e,initialLocation:p}),r(tn,{label:"Type",value:c}),r(tn,{label:"Provider",value:r(cn,{type:d,size:"sm",showLabel:!0})}),r(tn,{label:"Capabilities",value:f.length>0?r(wa,{capabilities:f,showLabels:!0}):r("span",{className:"text-[11px] text-foreground-subtle",children:"None"})})]}),h&&s==="hardware"&&r(sR,{metadata:m})]})}function Ou({active:e,onClick:t,label:n}){return r("button",{type:"button",onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${e?"bg-surface text-foreground shadow-sm":"text-foreground-subtle hover:text-foreground"}`,children:n})}function sR({metadata:e}){const t=Ru.filter(s=>s in e),n=Object.keys(e).filter(s=>!Ru.includes(s)).sort(),o=[...t,...n];return u("div",{children:[r("div",{className:"px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border bg-surface-subtle/40",children:"Auto-populated by the driver on every connect. Read-only."}),r("div",{className:"divide-y divide-border",children:o.map(s=>r(tn,{label:rR(s),value:r("span",{className:"font-mono text-[11px] text-foreground break-all",children:oR(e[s])})},s))})]})}function ol(e){try{const t=e.split(".");if(t.length<2||!t[1])return null;const n=JSON.parse(atob(t[1]));return{id:String(n.userId??""),username:String(n.username??"unknown"),role:String(n.role??"viewer"),exp:Number(n.exp??0),scopes:iR(n.scopes)}}catch{return null}}const aR=new Set(["view","create","delete"]);function iR(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(typeof n!="object"||n===null)continue;const o=n,{type:s,target:a,access:i}=o;if(s!=="addon"&&s!=="capability"||typeof a!="string"||!Array.isArray(i))continue;const l=i.filter(c=>typeof c=="string"&&aR.has(c));l.length!==0&&t.push({type:s,target:a,access:l})}return t}function lR(e){const t=ol(e);return t?t.exp*1e3<Date.now():!0}const cR="changeme",Iy=Oe(null);function dR({children:e}){const[t,n]=$(null),[o,s]=$(!0),[a,i]=$(!1);Z(()=>{if(typeof window<"u"&&window.location.hash.startsWith("#token=")){const b=new URLSearchParams(window.location.hash.slice(1)).get("token");b&&(localStorage.setItem("camstack_admin_token",b),window.history.replaceState({},"","/admin"))}const f=localStorage.getItem("camstack_admin_token");if(!f){s(!1);return}if(lR(f)){localStorage.removeItem("camstack_admin_token"),s(!1);return}const p=ol(f);if(!p){localStorage.removeItem("camstack_admin_token"),s(!1);return}tl().trpcClient.system.info.query().then(()=>n(p)).catch(g=>{const b=g?.data?.code;b==="UNAUTHORIZED"||b==="FORBIDDEN"?(localStorage.removeItem("camstack_admin_token"),Zr()):n(p)}).finally(()=>s(!1))},[]);const l=q(async(f,p)=>{const g=(await tl().login(f,p)).token;localStorage.setItem("camstack_admin_token",g),Zr(),n(ol(g)),i(p===cR)},[]),c=q(()=>{localStorage.removeItem("camstack_admin_token"),Zr(),n(null),i(!1)},[]),d=q(()=>{i(!1)},[]);return r(Iy.Provider,{value:{user:t,loading:o,mustChangePassword:a,login:l,logout:c,clearMustChangePassword:d},children:e})}function fn(){const e=ve(Iy);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}function Ft({children:e,requiredRole:t}){const{user:n,loading:o,mustChangePassword:s}=fn(),a=mt();return o?r("div",{className:"flex h-screen items-center justify-center bg-background text-foreground-subtle",children:"Loading..."}):n?s&&a.pathname!=="/change-password"?r(ht,{to:"/change-password",replace:!0}):t==="admin"&&n.role!=="admin"?r(ht,{to:"/access-denied",replace:!0}):r(ge,{children:e}):r(ht,{to:"/login",replace:!0})}var ii={};const Ce=e=>typeof e=="string",jr=()=>{let e,t;const n=new Promise((o,s)=>{e=o,t=s});return n.resolve=e,n.reject=t,n},zu=e=>e==null?"":""+e,uR=(e,t,n)=>{e.forEach(o=>{t[o]&&(n[o]=t[o])})},pR=/###/g,Bu=e=>e&&e.indexOf("###")>-1?e.replace(pR,"."):e,Fu=e=>!e||Ce(e),Jr=(e,t,n)=>{const o=Ce(t)?t.split("."):t;let s=0;for(;s<o.length-1;){if(Fu(e))return{};const a=Bu(o[s]);!e[a]&&n&&(e[a]=new n),Object.prototype.hasOwnProperty.call(e,a)?e=e[a]:e={},++s}return Fu(e)?{}:{obj:e,k:Bu(o[s])}},ju=(e,t,n)=>{const{obj:o,k:s}=Jr(e,t,Object);if(o!==void 0||t.length===1){o[s]=n;return}let a=t[t.length-1],i=t.slice(0,t.length-1),l=Jr(e,i,Object);for(;l.obj===void 0&&i.length;)a=`${i[i.length-1]}.${a}`,i=i.slice(0,i.length-1),l=Jr(e,i,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},fR=(e,t,n,o)=>{const{obj:s,k:a}=Jr(e,t,Object);s[a]=s[a]||[],s[a].push(n)},Ls=(e,t)=>{const{obj:n,k:o}=Jr(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,o))return n[o]},mR=(e,t,n)=>{const o=Ls(e,n);return o!==void 0?o:Ls(t,n)},Ay=(e,t,n)=>{for(const o in t)o!=="__proto__"&&o!=="constructor"&&(o in e?Ce(e[o])||e[o]instanceof String||Ce(t[o])||t[o]instanceof String?n&&(e[o]=t[o]):Ay(e[o],t[o],n):e[o]=t[o]);return e},_n=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var hR={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const gR=e=>Ce(e)?e.replace(/[&<>"'\/]/g,t=>hR[t]):e;class bR{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const n=this.regExpMap.get(t);if(n!==void 0)return n;const o=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,o),this.regExpQueue.push(t),o}}const xR=[" ",",","?","!",";"],yR=new bR(20),vR=(e,t,n)=>{t=t||"",n=n||"";const o=xR.filter(i=>t.indexOf(i)<0&&n.indexOf(i)<0);if(o.length===0)return!0;const s=yR.getRegExp(`(${o.map(i=>i==="?"?"\\?":i).join("|")})`);let a=!s.test(e);if(!a){const i=e.indexOf(n);i>0&&!s.test(e.substring(0,i))&&(a=!0)}return a},sl=(e,t,n=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;const o=t.split(n);let s=e;for(let a=0;a<o.length;){if(!s||typeof s!="object")return;let i,l="";for(let c=a;c<o.length;++c)if(c!==a&&(l+=n),l+=o[c],i=s[l],i!==void 0){if(["string","number","boolean"].indexOf(typeof i)>-1&&c<o.length-1)continue;a+=c-a+1;break}s=i}return s},po=e=>e?.replace(/_/g,"-"),wR={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class Ts{constructor(t,n={}){this.init(t,n)}init(t,n={}){this.prefix=n.prefix||"i18next:",this.logger=t||wR,this.options=n,this.debug=n.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,o,s){return s&&!this.debug?null:(Ce(t[0])&&(t[0]=`${o}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new Ts(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Ts(this.logger,t)}}var qt=new Ts;class Na{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(o=>{this.observers[o]||(this.observers[o]=new Map);const s=this.observers[o].get(n)||0;this.observers[o].set(n,s+1)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t].delete(n)}}emit(t,...n){this.observers[t]&&Array.from(this.observers[t].entries()).forEach(([s,a])=>{for(let i=0;i<a;i++)s(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,a])=>{for(let i=0;i<a;i++)s.apply(s,[t,...n])})}}class Hu extends Na{constructor(t,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,o,s={}){const a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,i=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.indexOf(".")>-1?l=t.split("."):(l=[t,n],o&&(Array.isArray(o)?l.push(...o):Ce(o)&&a?l.push(...o.split(a)):l.push(o)));const c=Ls(this.data,l);return!c&&!n&&!o&&t.indexOf(".")>-1&&(t=l[0],n=l[1],o=l.slice(2).join(".")),c||!i||!Ce(o)?c:sl(this.data?.[t]?.[n],o,a)}addResource(t,n,o,s,a={silent:!1}){const i=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let l=[t,n];o&&(l=l.concat(i?o.split(i):o)),t.indexOf(".")>-1&&(l=t.split("."),s=n,n=l[1]),this.addNamespaces(n),ju(this.data,l,s),a.silent||this.emit("added",t,n,o,s)}addResources(t,n,o,s={silent:!1}){for(const a in o)(Ce(o[a])||Array.isArray(o[a]))&&this.addResource(t,n,a,o[a],{silent:!0});s.silent||this.emit("added",t,n,o)}addResourceBundle(t,n,o,s,a,i={silent:!1,skipCopy:!1}){let l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),s=o,o=n,n=l[1]),this.addNamespaces(n);let c=Ls(this.data,l)||{};i.skipCopy||(o=JSON.parse(JSON.stringify(o))),s?Ay(c,o,a):c={...c,...o},ju(this.data,l,c),i.silent||this.emit("added",t,n,o)}removeResourceBundle(t,n){this.hasResourceBundle(t,n)&&delete this.data[t][n],this.removeNamespaces(n),this.emit("removed",t,n)}hasResourceBundle(t,n){return this.getResource(t,n)!==void 0}getResourceBundle(t,n){return n||(n=this.options.defaultNS),this.getResource(t,n)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const n=this.getDataByLanguage(t);return!!(n&&Object.keys(n)||[]).find(s=>n[s]&&Object.keys(n[s]).length>0)}toJSON(){return this.data}}var Py={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,o,s){return e.forEach(a=>{t=this.processors[a]?.process(t,n,o,s)??t}),t}};const Ey=Symbol("i18next/PATH_KEY");function NR(){const e=[],t=Object.create(null);let n;return t.get=(o,s)=>(n?.revoke?.(),s===Ey?e:(e.push(s),n=Proxy.revocable(o,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function pr(e,t){const{[Ey]:n}=e(NR()),o=t?.keySeparator??".",s=t?.nsSeparator??":";if(n.length>1&&s){const a=t?.ns,i=Array.isArray(a)?a:null;if(i&&i.length>1&&i.slice(1).includes(n[0]))return`${n[0]}${s}${n.slice(1).join(o)}`}return n.join(o)}const Vu={},li=e=>!Ce(e)&&typeof e!="boolean"&&typeof e!="number";class Rs extends Na{constructor(t,n={}){super(),uR(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=qt.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t,n={interpolation:{}}){const o={...n};if(t==null)return!1;const s=this.resolve(t,o);if(s?.res===void 0)return!1;const a=li(s.res);return!(o.returnObjects===!1&&a)}extractFromKey(t,n){let o=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");const s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const i=o&&t.indexOf(o)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!vR(t,o,s);if(i&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:Ce(a)?[a]:a};const d=t.split(o);(o!==s||o===s&&this.options.ns.indexOf(d[0])>-1)&&(a=d.shift()),t=d.join(s)}return{key:t,namespaces:Ce(a)?[a]:a}}translate(t,n,o){let s=typeof n=="object"?{...n}:n;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof s=="object"&&(s={...s}),s||(s={}),t==null)return"";typeof t=="function"&&(t=pr(t,{...this.options,...s})),Array.isArray(t)||(t=[String(t)]),t=t.map(O=>typeof O=="function"?pr(O,{...this.options,...s}):String(O));const a=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,i=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(t[t.length-1],s),d=c[c.length-1];let f=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;f===void 0&&(f=":");const p=s.lng||this.language,m=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p?.toLowerCase()==="cimode")return m?a?{res:`${d}${f}${l}`,usedKey:l,exactUsedKey:l,usedLng:p,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:`${d}${f}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:p,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:l;const h=this.resolve(t,s);let g=h?.res;const b=h?.usedKey||l,x=h?.exactUsedKey||l,y=["[object Number]","[object Function]","[object RegExp]"],w=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,v=!this.i18nFormat||this.i18nFormat.handleAsObject,N=s.count!==void 0&&!Ce(s.count),k=Rs.hasDefaultValue(s),S=N?this.pluralResolver.getSuffix(p,s.count,s):"",M=s.ordinal&&N?this.pluralResolver.getSuffix(p,s.count,{ordinal:!1}):"",P=N&&!s.ordinal&&s.count===0,A=P&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${S}`]||s[`defaultValue${M}`]||s.defaultValue;let z=g;v&&!g&&k&&(z=A);const D=li(z),T=Object.prototype.toString.apply(z);if(v&&z&&D&&y.indexOf(T)<0&&!(Ce(w)&&Array.isArray(z))){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const O=this.options.returnedObjectHandler?this.options.returnedObjectHandler(b,z,{...s,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(h.res=O,h.usedParams=this.getUsedParamsDetails(s),h):O}if(i){const O=Array.isArray(z),I=O?[]:{},L=O?x:b;for(const _ in z)if(Object.prototype.hasOwnProperty.call(z,_)){const R=`${L}${i}${_}`;k&&!g?I[_]=this.translate(R,{...s,defaultValue:li(A)?A[_]:void 0,joinArrays:!1,ns:c}):I[_]=this.translate(R,{...s,joinArrays:!1,ns:c}),I[_]===R&&(I[_]=z[_])}g=I}}else if(v&&Ce(w)&&Array.isArray(g))g=g.join(w),g&&(g=this.extendTranslation(g,t,s,o));else{let O=!1,I=!1;!this.isValidLookup(g)&&k&&(O=!0,g=A),this.isValidLookup(g)||(I=!0,g=l);const _=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&I?void 0:g,R=k&&A!==g&&this.options.updateMissing;if(I||O||R){if(this.logger.log(R?"updateKey":"missingKey",p,d,l,R?A:g),i){const H=this.resolve(l,{...s,keySeparator:!1});H&&H.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let B=[];const F=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&F&&F[0])for(let H=0;H<F.length;H++)B.push(F[H]);else this.options.saveMissingTo==="all"?B=this.languageUtils.toResolveHierarchy(s.lng||this.language):B.push(s.lng||this.language);const j=(H,E,Q)=>{const K=k&&Q!==g?Q:_;this.options.missingKeyHandler?this.options.missingKeyHandler(H,d,E,K,R,s):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(H,d,E,K,R,s),this.emit("missingKey",H,d,E,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?B.forEach(H=>{const E=this.pluralResolver.getSuffixes(H,s);P&&s[`defaultValue${this.options.pluralSeparator}zero`]&&E.indexOf(`${this.options.pluralSeparator}zero`)<0&&E.push(`${this.options.pluralSeparator}zero`),E.forEach(Q=>{j([H],l+Q,s[`defaultValue${Q}`]||A)})}):j(B,l,A))}g=this.extendTranslation(g,t,s,h,o),I&&g===l&&this.options.appendNamespaceToMissingKey&&(g=`${d}${f}${l}`),(I||O)&&this.options.parseMissingKeyHandler&&(g=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${f}${l}`:l,O?g:void 0,s))}return a?(h.res=g,h.usedParams=this.getUsedParamsDetails(s),h):g}extendTranslation(t,n,o,s,a){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...o},o.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!o.skipInterpolation){o.interpolation&&this.interpolator.init({...o,interpolation:{...this.options.interpolation,...o.interpolation}});const c=Ce(t)&&(o?.interpolation?.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(c){const p=t.match(this.interpolator.nestingRegexp);d=p&&p.length}let f=o.replace&&!Ce(o.replace)?o.replace:o;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),t=this.interpolator.interpolate(t,f,o.lng||this.language||s.usedLng,o),c){const p=t.match(this.interpolator.nestingRegexp),m=p&&p.length;d<m&&(o.nest=!1)}!o.lng&&s&&s.res&&(o.lng=this.language||s.usedLng),o.nest!==!1&&(t=this.interpolator.nest(t,(...p)=>a?.[0]===p[0]&&!o.context?(this.logger.warn(`It seems you are nesting recursively key: ${p[0]} in key: ${n[0]}`),null):this.translate(...p,n),o)),o.interpolation&&this.interpolator.reset()}const i=o.postProcess||this.options.postProcess,l=Ce(i)?[i]:i;return t!=null&&l?.length&&o.applyPostProcessor!==!1&&(t=Py.handle(l,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(o)},...o}:o,this)),t}resolve(t,n={}){let o,s,a,i,l;return Ce(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(c=>typeof c=="function"?pr(c,{...this.options,...n}):c)),t.forEach(c=>{if(this.isValidLookup(o))return;const d=this.extractFromKey(c,n),f=d.key;s=f;let p=d.namespaces;this.options.fallbackNS&&(p=p.concat(this.options.fallbackNS));const m=n.count!==void 0&&!Ce(n.count),h=m&&!n.ordinal&&n.count===0,g=n.context!==void 0&&(Ce(n.context)||typeof n.context=="number")&&n.context!=="",b=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);p.forEach(x=>{this.isValidLookup(o)||(l=x,!Vu[`${b[0]}-${x}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(Vu[`${b[0]}-${x}`]=!0,this.logger.warn(`key "${s}" for languages "${b.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),b.forEach(y=>{if(this.isValidLookup(o))return;i=y;const w=[f];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(w,f,y,x,n);else{let N;m&&(N=this.pluralResolver.getSuffix(y,n.count,n));const k=`${this.options.pluralSeparator}zero`,S=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&N.indexOf(S)===0&&w.push(f+N.replace(S,this.options.pluralSeparator)),w.push(f+N),h&&w.push(f+k)),g){const M=`${f}${this.options.contextSeparator||"_"}${n.context}`;w.push(M),m&&(n.ordinal&&N.indexOf(S)===0&&w.push(M+N.replace(S,this.options.pluralSeparator)),w.push(M+N),h&&w.push(M+k))}}let v;for(;v=w.pop();)this.isValidLookup(o)||(a=v,o=this.getResource(y,x,v,n))}))})}),{res:o,usedKey:s,exactUsedKey:a,usedLng:i,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,o,s={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,n,o,s):this.resourceStore.getResource(t,n,o,s)}getUsedParamsDetails(t={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],o=t.replace&&!Ce(t.replace);let s=o?t.replace:t;if(o&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!o){s={...s};for(const a of n)delete s[a]}return s}static hasDefaultValue(t){const n="defaultValue";for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&n===o.substring(0,n.length)&&t[o]!==void 0)return!0;return!1}}class qu{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=qt.create("languageUtils")}getScriptPartFromCode(t){if(t=po(t),!t||t.indexOf("-")<0)return null;const n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(t){if(t=po(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(Ce(t)&&t.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(t)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(o=>{if(n)return;const s=this.formatLanguageCode(o);(!this.options.supportedLngs||this.isSupportedCode(s))&&(n=s)}),!n&&this.options.supportedLngs&&t.forEach(o=>{if(n)return;const s=this.getScriptPartFromCode(o);if(this.isSupportedCode(s))return n=s;const a=this.getLanguagePartFromCode(o);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(i=>{if(i===a)return i;if(!(i.indexOf("-")<0&&a.indexOf("-")<0)&&(i.indexOf("-")>0&&a.indexOf("-")<0&&i.substring(0,i.indexOf("-"))===a||i.indexOf(a)===0&&a.length>1))return i})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),Ce(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let o=t[n];return o||(o=t[this.getScriptPartFromCode(n)]),o||(o=t[this.formatLanguageCode(n)]),o||(o=t[this.getLanguagePartFromCode(n)]),o||(o=t.default),o||[]}toResolveHierarchy(t,n){const o=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],t),s=[],a=i=>{i&&(this.isSupportedCode(i)?s.push(i):this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`))};return Ce(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(t))):Ce(t)&&a(this.formatLanguageCode(t)),o.forEach(i=>{s.indexOf(i)<0&&a(this.formatLanguageCode(i))}),s}}const Uu={zero:0,one:1,two:2,few:3,many:4,other:5},Qu={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class kR{constructor(t,n={}){this.languageUtils=t,this.options=n,this.logger=qt.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,n={}){const o=po(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:o,type:s});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let i;try{i=new Intl.PluralRules(o,{type:s})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),Qu;if(!t.match(/-|_/))return Qu;const c=this.languageUtils.getLanguagePartFromCode(t);i=this.getRule(c,n)}return this.pluralRulesCache[a]=i,i}needsPlural(t,n={}){let o=this.getRule(t,n);return o||(o=this.getRule("dev",n)),o?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,n,o={}){return this.getSuffixes(t,o).map(s=>`${n}${s}`)}getSuffixes(t,n={}){let o=this.getRule(t,n);return o||(o=this.getRule("dev",n)),o?o.resolvedOptions().pluralCategories.sort((s,a)=>Uu[s]-Uu[a]).map(s=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(t,n,o={}){const s=this.getRule(t,o);return s?`${this.options.prepend}${o.ordinal?`ordinal${this.options.prepend}`:""}${s.select(n)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",n,o))}}const Ku=(e,t,n,o=".",s=!0)=>{let a=mR(e,t,n);return!a&&s&&Ce(n)&&(a=sl(e,n,o),a===void 0&&(a=sl(t,n,o))),a},ci=e=>e.replace(/\$/g,"$$$$");class Gu{constructor(t={}){this.logger=qt.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(n=>n),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});const{escape:n,escapeValue:o,useRawValueToEscape:s,prefix:a,prefixEscaped:i,suffix:l,suffixEscaped:c,formatSeparator:d,unescapeSuffix:f,unescapePrefix:p,nestingPrefix:m,nestingPrefixEscaped:h,nestingSuffix:g,nestingSuffixEscaped:b,nestingOptionsSeparator:x,maxReplaces:y,alwaysFormat:w}=t.interpolation;this.escape=n!==void 0?n:gR,this.escapeValue=o!==void 0?o:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=a?_n(a):i||"{{",this.suffix=l?_n(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=f?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=m?_n(m):h||_n("$t("),this.nestingSuffix=g?_n(g):b||_n(")"),this.nestingOptionsSeparator=x||",",this.maxReplaces=y||1e3,this.alwaysFormat=w!==void 0?w:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,o)=>n?.source===o?(n.lastIndex=0,n):new RegExp(o,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,n,o,s){let a,i,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=h=>{if(h.indexOf(this.formatSeparator)<0){const y=Ku(n,c,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,o,{...s,...n,interpolationkey:h}):y}const g=h.split(this.formatSeparator),b=g.shift().trim(),x=g.join(this.formatSeparator).trim();return this.format(Ku(n,c,b,this.options.keySeparator,this.options.ignoreJSONStructure),x,o,{...s,...n,interpolationkey:b})};this.resetRegExp();const f=s?.missingInterpolationHandler||this.options.missingInterpolationHandler,p=s?.interpolation?.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>ci(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?ci(this.escape(h)):ci(h)}].forEach(h=>{for(l=0;a=h.regex.exec(t);){const g=a[1].trim();if(i=d(g),i===void 0)if(typeof f=="function"){const x=f(t,a,s);i=Ce(x)?x:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))i="";else if(p){i=a[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),i="";else!Ce(i)&&!this.useRawValueToEscape&&(i=zu(i));const b=h.safeValue(i);if(t=t.replace(a[0],b),p?(h.regex.lastIndex+=i.length,h.regex.lastIndex-=a[0].length):h.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n,o={}){let s,a,i;const l=(c,d)=>{const f=this.nestingOptionsSeparator;if(c.indexOf(f)<0)return c;const p=c.split(new RegExp(`${_n(f)}[ ]*{`));let m=`{${p[1]}`;c=p[0],m=this.interpolate(m,i);const h=m.match(/'/g),g=m.match(/"/g);((h?.length??0)%2===0&&!g||(g?.length??0)%2!==0)&&(m=m.replace(/'/g,'"'));try{i=JSON.parse(m),d&&(i={...d,...i})}catch(b){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,b),`${c}${f}${m}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];i={...o},i=i.replace&&!Ce(i.replace)?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;const d=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(d!==-1&&(c=s[1].slice(d).split(this.formatSeparator).map(f=>f.trim()).filter(Boolean),s[1]=s[1].slice(0,d)),a=n(l.call(this,s[1].trim(),i),i),a&&s[0]===t&&!Ce(a))return a;Ce(a)||(a=zu(a)),a||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),a=""),c.length&&(a=c.reduce((f,p)=>this.format(f,p,o.lng,{...o,interpolationkey:s[1].trim()}),a.trim())),t=t.replace(s[0],a),this.regexp.lastIndex=0}return t}}const SR=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const o=e.split("(");t=o[0].toLowerCase().trim();const s=o[1].substring(0,o[1].length-1);t==="currency"&&s.indexOf(":")<0?n.currency||(n.currency=s.trim()):t==="relativetime"&&s.indexOf(":")<0?n.range||(n.range=s.trim()):s.split(";").forEach(i=>{if(i){const[l,...c]=i.split(":"),d=c.join(":").trim().replace(/^'+|'+$/g,""),f=l.trim();n[f]||(n[f]=d),d==="false"&&(n[f]=!1),d==="true"&&(n[f]=!0),isNaN(d)||(n[f]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},Wu=e=>{const t={};return(n,o,s)=>{let a=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(a={...a,[s.interpolationkey]:void 0});const i=o+JSON.stringify(a);let l=t[i];return l||(l=e(po(o),s),t[i]=l),l(n)}},CR=e=>(t,n,o)=>e(po(n),o)(t);class MR{constructor(t={}){this.logger=qt.create("formatter"),this.options=t,this.init(t)}init(t,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const o=n.cacheInBuiltFormats?Wu:CR;this.formats={number:o((s,a)=>{const i=new Intl.NumberFormat(s,{...a});return l=>i.format(l)}),currency:o((s,a)=>{const i=new Intl.NumberFormat(s,{...a,style:"currency"});return l=>i.format(l)}),datetime:o((s,a)=>{const i=new Intl.DateTimeFormat(s,{...a});return l=>i.format(l)}),relativetime:o((s,a)=>{const i=new Intl.RelativeTimeFormat(s,{...a});return l=>i.format(l,a.range||"day")}),list:o((s,a)=>{const i=new Intl.ListFormat(s,{...a});return l=>i.format(l)})}}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=Wu(n)}format(t,n,o,s={}){const a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(l=>l.indexOf(")")>-1)){const l=a.findIndex(c=>c.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,l)].join(this.formatSeparator)}return a.reduce((l,c)=>{const{formatName:d,formatOptions:f}=SR(c);if(this.formats[d]){let p=l;try{const m=s?.formatParams?.[s.interpolationkey]||{},h=m.locale||m.lng||s.locale||s.lng||o;p=this.formats[d](l,h,{...f,...s,...m})}catch(m){this.logger.warn(m)}return p}else this.logger.warn(`there was no format function for ${d}`);return l},t)}}const IR=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class AR extends Na{constructor(t,n,o,s={}){super(),this.backend=t,this.store=n,this.services=o,this.languageUtils=o.languageUtils,this.options=s,this.logger=qt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(o,s.backend,s)}queueLoad(t,n,o,s){const a={},i={},l={},c={};return t.forEach(d=>{let f=!0;n.forEach(p=>{const m=`${d}|${p}`;!o.reload&&this.store.hasResourceBundle(d,p)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?i[m]===void 0&&(i[m]=!0):(this.state[m]=1,f=!1,i[m]===void 0&&(i[m]=!0),a[m]===void 0&&(a[m]=!0),c[p]===void 0&&(c[p]=!0)))}),f||(l[d]=!0)}),(Object.keys(a).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(a),pending:Object.keys(i),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(t,n,o){const s=t.split("|"),a=s[0],i=s[1];n&&this.emit("failedLoading",a,i,n),!n&&o&&this.store.addResourceBundle(a,i,o,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&o&&(this.state[t]=0);const l={};this.queue.forEach(c=>{fR(c.loaded,[a],i),IR(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(d=>{l[d]||(l[d]={});const f=c.loaded[d];f.length&&f.forEach(p=>{l[d][p]===void 0&&(l[d][p]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,o,s=0,a=this.retryTimeout,i){if(!t.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:o,tried:s,wait:a,callback:i});return}this.readingCalls++;const l=(d,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const p=this.waitingReads.shift();this.read(p.lng,p.ns,p.fcName,p.tried,p.wait,p.callback)}if(d&&f&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,o,s+1,a*2,i)},a);return}i(d,f)},c=this.backend[o].bind(this.backend);if(c.length===2){try{const d=c(t,n);d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}return}return c(t,n,l)}prepareLoading(t,n,o={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();Ce(t)&&(t=this.languageUtils.toResolveHierarchy(t)),Ce(n)&&(n=[n]);const a=this.queueLoad(t,n,o,s);if(!a.toLoad.length)return a.pending.length||s(),null;a.toLoad.forEach(i=>{this.loadOne(i)})}load(t,n,o){this.prepareLoading(t,n,{},o)}reload(t,n,o){this.prepareLoading(t,n,{reload:!0},o)}loadOne(t,n=""){const o=t.split("|"),s=o[0],a=o[1];this.read(s,a,"read",void 0,void 0,(i,l)=>{i&&this.logger.warn(`${n}loading namespace ${a} for language ${s} failed`,i),!i&&l&&this.logger.log(`${n}loaded namespace ${a} for language ${s}`,l),this.loaded(t,i,l)})}saveMissing(t,n,o,s,a,i={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${o}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(o==null||o==="")){if(this.backend?.create){const c={...i,isUpdate:a},d=this.backend.create.bind(this.backend);if(d.length<6)try{let f;d.length===5?f=d(t,n,o,s,c):f=d(t,n,o,s),f&&typeof f.then=="function"?f.then(p=>l(null,p)).catch(l):l(null,f)}catch(f){l(f)}else d(t,n,o,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,o,s)}}}const di=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),Ce(e[1])&&(t.defaultValue=e[1]),Ce(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(o=>{t[o]=n[o]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Yu=e=>(Ce(e.ns)&&(e.ns=[e.ns]),Ce(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),Ce(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),typeof e.initImmediate=="boolean"&&(e.initAsync=e.initImmediate),e),Jo=()=>{},PR=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})},$y="__i18next_supportNoticeShown",ER=()=>!!(typeof globalThis<"u"&&globalThis[$y]||typeof process<"u"&&ii&&ii.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&ii),$R=()=>{typeof globalThis<"u"&&(globalThis[$y]=!0)},_R=e=>!!(e?.modules?.backend?.name?.indexOf("Locize")>0||e?.modules?.backend?.constructor?.name?.indexOf("Locize")>0||e?.options?.backend?.backends&&e.options.backend.backends.some(t=>t?.name?.indexOf("Locize")>0||t?.constructor?.name?.indexOf("Locize")>0)||e?.options?.backend?.projectId||e?.options?.backend?.backendOptions&&e.options.backend.backendOptions.some(t=>t?.projectId));class eo extends Na{constructor(t={},n){if(super(),this.options=Yu(t),this.services={},this.logger=qt,this.modules={external:[]},PR(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(t={},n){this.isInitializing=!0,typeof t=="function"&&(n=t,t={}),t.defaultNS==null&&t.ns&&(Ce(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const o=di();this.options={...o,...this.options,...Yu(t)},this.options.interpolation={...o.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=o.overloadTranslationOptionHandler),this.options.showSupportNotice!==!1&&!_R(this)&&!ER()&&(typeof console<"u"&&typeof console.info<"u"&&console.info("🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙"),$R());const s=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?qt.init(s(this.modules.logger),this.options):qt.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=MR;const f=new qu(this.options);this.store=new Hu(this.options.resources,this.options);const p=this.services;p.logger=qt,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new kR(f,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==o.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),d&&(!this.options.interpolation.format||this.options.interpolation.format===o.interpolation.format)&&(p.formatter=s(d),p.formatter.init&&p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new Gu(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new AR(s(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",(h,...g)=>{this.emit(h,...g)}),this.modules.languageDetector&&(p.languageDetector=s(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=s(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new Rs(this.services,this.options),this.translator.on("*",(h,...g)=>{this.emit(h,...g)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Jo),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(d=>{this[d]=(...f)=>this.store[d](...f)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=(...f)=>(this.store[d](...f),this)});const l=jr(),c=()=>{const d=(f,p)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(p),n(f,p)};if(this.languages&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(t,n=Jo){let o=n;const s=Ce(t)?t:this.language;if(typeof t=="function"&&(o=t),!this.options.resources||this.options.partialBundledLanguages){if(s?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return o();const a=[],i=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(d=>{d!=="cimode"&&a.indexOf(d)<0&&a.push(d)})};s?i(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>i(c)),this.options.preload?.forEach?.(l=>i(l)),this.services.backendConnector.load(a,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),o(l)})}else o(null)}reloadResources(t,n,o){const s=jr();return typeof t=="function"&&(o=t,t=void 0),typeof n=="function"&&(o=n,n=void 0),t||(t=this.languages),n||(n=this.options.ns),o||(o=Jo),this.services.backendConnector.reload(t,n,a=>{s.resolve(),o(a)}),s}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&Py.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!(["cimode","dev"].indexOf(t)>-1)){for(let n=0;n<this.languages.length;n++){const o=this.languages[n];if(!(["cimode","dev"].indexOf(o)>-1)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}!this.resolvedLanguage&&this.languages.indexOf(t)<0&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,n){this.isLanguageChangingTo=t;const o=jr();this.emit("languageChanging",t);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(l,c)=>{c?this.isLanguageChangingTo===t&&(s(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,o.resolve((...d)=>this.t(...d)),n&&n(l,(...d)=>this.t(...d))},i=l=>{!t&&!l&&this.services.languageDetector&&(l=[]);const c=Ce(l)?l:l&&l[0],d=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(Ce(l)?[l]:l);d&&(this.language||s(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector?.cacheUserLanguage?.(d)),this.loadResources(d,f=>{a(f,d)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?i(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(i):this.services.languageDetector.detect(i):i(t),o}getFixedT(t,n,o){const s=(a,i,...l)=>{let c;typeof i!="object"?c=this.options.overloadTranslationOptionHandler([a,i].concat(l)):c={...i},c.lng=c.lng||s.lng,c.lngs=c.lngs||s.lngs,c.ns=c.ns||s.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||o||s.keyPrefix);const d={...this.options,...c};typeof c.keyPrefix=="function"&&(c.keyPrefix=pr(c.keyPrefix,d));const f=this.options.keySeparator||".";let p;return c.keyPrefix&&Array.isArray(a)?p=a.map(m=>(typeof m=="function"&&(m=pr(m,d)),`${c.keyPrefix}${f}${m}`)):(typeof a=="function"&&(a=pr(a,d)),p=c.keyPrefix?`${c.keyPrefix}${f}${a}`:a),this.t(p,c)};return Ce(t)?s.lng=t:s.lngs=t,s.ns=n,s.keyPrefix=o,s}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const o=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(o.toLowerCase()==="cimode")return!0;const i=(l,c)=>{const d=this.services.backendConnector.state[`${l}|${c}`];return d===-1||d===0||d===2};if(n.precheck){const l=n.precheck(this,i);if(l!==void 0)return l}return!!(this.hasResourceBundle(o,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(o,t)&&(!s||i(a,t)))}loadNamespaces(t,n){const o=jr();return this.options.ns?(Ce(t)&&(t=[t]),t.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{o.resolve(),n&&n(s)}),o):(n&&n(),Promise.resolve())}loadLanguages(t,n){const o=jr();Ce(t)&&(t=[t]);const s=this.options.preload||[],a=t.filter(i=>s.indexOf(i)<0&&this.services.languageUtils.isSupportedCode(i));return a.length?(this.options.preload=s.concat(a),this.loadResources(i=>{o.resolve(),n&&n(i)}),o):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return"rtl";try{const s=new Intl.Locale(t);if(s&&s.getTextInfo){const a=s.getTextInfo();if(a&&a.direction)return a.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],o=this.services?.languageUtils||new qu(di());return t.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(o.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},n){const o=new eo(t,n);return o.createInstance=eo.createInstance,o}cloneInstance(t={},n=Jo){const o=t.forkResourceStore;o&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},a=new eo(s);if((t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),["store","services","language"].forEach(l=>{a[l]=this[l]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},o){const l=Object.keys(this.store.data).reduce((c,d)=>(c[d]={...this.store.data[d]},c[d]=Object.keys(c[d]).reduce((f,p)=>(f[p]={...c[d][p]},f),c[d]),c),{});a.store=new Hu(l,s),a.services.resourceStore=a.store}if(t.interpolation){const c={...di().interpolation,...this.options.interpolation,...t.interpolation},d={...s,interpolation:c};a.services.interpolator=new Gu(d)}return a.translator=new Rs(a.services,s),a.translator.on("*",(l,...c)=>{a.emit(l,...c)}),a.init(s,n),a.translator.options=s,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Ze=eo.createInstance();Ze.createInstance;Ze.dir;Ze.init;Ze.loadResources;Ze.reloadResources;Ze.use;Ze.changeLanguage;Ze.getFixedT;Ze.t;Ze.exists;Ze.setDefaultNamespace;Ze.hasLoadedNamespace;Ze.loadNamespaces;Ze.loadLanguages;const DR=(e,t,n,o)=>{const s=[n,{code:t,...o||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(s,"warn","react-i18next::",!0);qn(s[0])&&(s[0]=`react-i18next:: ${s[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...s):console?.warn&&console.warn(...s)},Zu={},al=(e,t,n,o)=>{qn(n)&&Zu[n]||(qn(n)&&(Zu[n]=new Date),DR(e,t,n,o))},_y=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}},il=(e,t,n)=>{e.loadNamespaces(t,_y(e,n))},Xu=(e,t,n,o)=>{if(qn(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return il(e,n,o);n.forEach(s=>{e.options.ns.indexOf(s)<0&&e.options.ns.push(s)}),e.loadLanguages(t,_y(e,o))},LR=(e,t,n={})=>!t.languages||!t.languages.length?(al(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(o,s)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&o.services.backendConnector.backend&&o.isLanguageChangingTo&&!s(o.isLanguageChangingTo,e))return!1}}),qn=e=>typeof e=="string",TR=e=>typeof e=="object"&&e!==null,RR=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,OR={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},zR=e=>OR[e],BR=e=>e.replace(RR,zR);let ll={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:BR,transDefaultProps:void 0};const FR=(e={})=>{ll={...ll,...e}},jR=()=>ll;let Dy;const HR=e=>{Dy=e},VR=()=>Dy,qR={type:"3rdParty",init(e){FR(e.options.react),HR(e)}},UR=Oe();class QR{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var Ly={exports:{}},Ty={};/**
|
|
1081
|
-
* @license React
|
|
1082
|
-
* use-sync-external-store-shim.production.js
|
|
1083
|
-
*
|
|
1084
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1085
|
-
*
|
|
1086
|
-
* This source code is licensed under the MIT license found in the
|
|
1087
|
-
* LICENSE file in the root directory of this source tree.
|
|
1088
|
-
*/var vr=Qf;function KR(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var GR=typeof Object.is=="function"?Object.is:KR,WR=vr.useState,YR=vr.useEffect,ZR=vr.useLayoutEffect,XR=vr.useDebugValue;function JR(e,t){var n=t(),o=WR({inst:{value:n,getSnapshot:t}}),s=o[0].inst,a=o[1];return ZR(function(){s.value=n,s.getSnapshot=t,ui(s)&&a({inst:s})},[e,n,t]),YR(function(){return ui(s)&&a({inst:s}),e(function(){ui(s)&&a({inst:s})})},[e]),XR(n),n}function ui(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!GR(e,n)}catch{return!0}}function e6(e,t){return t()}var t6=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?e6:JR;Ty.useSyncExternalStore=vr.useSyncExternalStore!==void 0?vr.useSyncExternalStore:t6;Ly.exports=Ty;var Ry=Ly.exports;const n6=(e,t)=>{if(qn(t))return t;if(TR(t)&&qn(t.defaultValue))return t.defaultValue;if(typeof e=="function")return"";if(Array.isArray(e)){const n=e[e.length-1];return typeof n=="function"?"":n}return e},r6={t:n6,ready:!1},o6=()=>()=>{},Ot=(e,t={})=>{const{i18n:n}=t,{i18n:o,defaultNS:s}=ve(UR)||{},a=n||o||VR();a&&!a.reportNamespaces&&(a.reportNamespaces=new QR),a||al(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const i=U(()=>({...jR(),...a?.options?.react,...t}),[a,t]),{useSuspense:l,keyPrefix:c}=i,d=s||a?.options?.defaultNS,f=qn(d)?[d]:d||["translation"],p=U(()=>f,f);a?.reportNamespaces?.addUsedNamespaces?.(p);const m=ne(0),h=q(A=>{if(!a)return o6;const{bindI18n:z,bindI18nStore:D}=i,T=()=>{m.current+=1,A()};return z&&a.on(z,T),D&&a.store.on(D,T),()=>{z&&z.split(" ").forEach(O=>a.off(O,T)),D&&D.split(" ").forEach(O=>a.store.off(O,T))}},[a,i]),g=ne(),b=q(()=>{if(!a)return r6;const A=!!(a.isInitialized||a.initializedStoreOnce)&&p.every(L=>LR(L,a,i)),z=t.lng||a.language,D=m.current,T=g.current;if(T&&T.ready===A&&T.lng===z&&T.keyPrefix===c&&T.revision===D)return T;const I={t:a.getFixedT(z,i.nsMode==="fallback"?p:p[0],c),ready:A,lng:z,keyPrefix:c,revision:D};return g.current=I,I},[a,p,c,i,t.lng]),[x,y]=$(0),{t:w,ready:v}=Ry.useSyncExternalStore(h,b,b);Z(()=>{if(a&&!v&&!l){const A=()=>y(z=>z+1);t.lng?Xu(a,t.lng,p,A):il(a,p,A)}},[a,t.lng,p,v,l,x]);const N=a||{},k=ne(null),S=ne(),M=A=>{const z=Object.getOwnPropertyDescriptors(A);z.__original&&delete z.__original;const D=Object.create(Object.getPrototypeOf(A),z);if(!Object.prototype.hasOwnProperty.call(D,"__original"))try{Object.defineProperty(D,"__original",{value:A,writable:!1,enumerable:!1,configurable:!1})}catch{}return D},P=U(()=>{const A=N,z=A?.language;let D=A;A&&(k.current&&k.current.__original===A?S.current!==z?(D=M(A),k.current=D,S.current=z):D=k.current:(D=M(A),k.current=D,S.current=z));const T=!v&&!l?(...I)=>(al(a,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),w(...I)):w,O=[T,D,v];return O.t=T,O.i18n=D,O.ready=v,O},[w,N,v,N.resolvedLanguage,N.language,N.languages]);if(a&&l&&!v)throw new Promise(A=>{const z=()=>A();t.lng?Xu(a,t.lng,p,z):il(a,p,z)});return P},Ju={info:Bn,success:oy,warning:bt,error:xa},s6={info:"text-blue-400",success:"text-green-400",warning:"text-amber-400",error:"text-red-400"},ep={active:"border-l-blue-400","in-progress":"border-l-amber-400",completed:"border-l-green-400",failed:"border-l-red-400",dismissed:"border-l-foreground-subtle/30"};function a6(e){const t=Math.floor((Date.now()-e)/1e3);if(t<60)return"just now";const n=Math.floor(t/60);if(n<60)return`${String(n)}m ago`;const o=Math.floor(n/60);if(o<24)return`${String(o)}h ago`;const s=Math.floor(o/24);return`${String(s)}d ago`}function tp({alert:e,onMarkRead:t,onDismiss:n}){const o=e.severity in Ju?e.severity:"info",s=e.status in ep?e.status:"active",a=Ju[o],i=s6[o],l=ep[s];return u("div",{className:`flex items-start gap-2.5 px-3 py-2.5 border-l-2 ${l} ${e.read?"opacity-60":""} hover:bg-surface-hover transition-colors`,children:[r(a,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${i}`}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:`text-[11px] font-semibold ${e.read?"text-foreground-subtle":"text-foreground"}`,children:e.title}),!e.read&&r("span",{className:"h-1.5 w-1.5 rounded-full bg-primary shrink-0"})]}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-2",children:e.message}),e.status==="in-progress"&&e.progress!==void 0&&u("div",{className:"mt-1.5 flex items-center gap-2",children:[r("div",{className:"flex-1 h-1 bg-surface-hover rounded-full overflow-hidden",children:r("div",{className:"h-full bg-primary rounded-full transition-all duration-300",style:{width:`${String(Math.min(100,Math.max(0,e.progress)))}%`}})}),u("span",{className:"text-[9px] text-foreground-subtle font-mono shrink-0",children:[String(Math.round(e.progress)),"%"]})]}),r("div",{className:"text-[9px] text-foreground-subtle/60 mt-1",children:a6(e.updatedAt)})]}),u("div",{className:"flex items-center gap-0.5 shrink-0",children:[!e.read&&r("button",{type:"button",onClick:c=>{c.stopPropagation(),t(e.id)},className:"p-1 rounded hover:bg-surface-hover transition-colors",title:"Mark as read",children:r(Mt,{className:"h-3 w-3 text-foreground-subtle"})}),e.status!=="in-progress"&&r("button",{type:"button",onClick:c=>{c.stopPropagation(),n(e.id)},className:"p-1 rounded hover:bg-surface-hover transition-colors",title:"Dismiss",children:r(Ve,{className:"h-3 w-3 text-foreground-subtle"})})]})]})}function np({variant:e="icon",compact:t=!1}={}){const[n,o]=$(!1),[s,a]=$(!1),i=ne(null),l=ne(null),c=ke(),{data:d=0}=ag(void 0,{staleTime:1e4,refetchInterval:3e4}),{data:f=[],isLoading:p}=sg({limit:50},{enabled:n,staleTime:5e3}),m=s?f:f.filter(A=>!A.read),h=f.filter(A=>A.read).length,g=()=>{c.invalidateQueries({queryKey:[["alerts"]]})},b=ig({onSuccess:g}),x=lg({onSuccess:g}),y=cg({onSuccess:g});ct("alert.created",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),ct("alert.updated",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),Z(()=>{if(!n)return;const A=z=>{const D=z.target;i.current&&!i.current.contains(D)&&l.current&&!l.current.contains(D)&&o(!1)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[n]);const w=q(A=>{b.mutate({alertId:A})},[b]),v=q(A=>{A&&y.mutate({alertId:A})},[y]),N=q(()=>{x.mutate(void 0),o(!1)},[x]),k=m.filter(A=>A.status==="in-progress"),S=m.filter(A=>A.status!=="in-progress"),[M,P]=$({});return Z(()=>{if(n&&l.current){const A=l.current.getBoundingClientRect();P({position:"fixed",left:A.left,bottom:window.innerHeight-A.top+4,zIndex:9999})}},[n]),u("div",{children:[e==="sidebar"?u("button",{ref:l,type:"button",onClick:()=>o(!n),className:`flex w-full items-center gap-2.5 rounded-md ${t?"justify-center px-0 py-2":"px-2.5 py-1.5"} text-[12px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,title:t?`Alerts${d>0?` (${d})`:""}`:void 0,children:[u("span",{className:"relative inline-flex shrink-0",children:[r(Xe,{className:"h-3.5 w-3.5"}),t&&d>0&&r("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary"})]}),!t&&r("span",{className:"flex-1 text-left",children:"Alerts"}),!t&&d>0&&r("span",{className:"flex items-center justify-center h-4 min-w-4 px-1 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none",children:d>99?"99+":String(d)})]}):u("button",{ref:l,type:"button",onClick:()=>o(!n),className:"relative p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors","aria-label":"Alerts",children:[r(Xe,{className:"h-4.5 w-4.5"}),d>0&&r("span",{className:"absolute -top-0.5 -right-0.5 flex items-center justify-center h-4 min-w-4 px-0.5 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none",children:d>99?"99+":String(d)})]}),n&&No(u("div",{ref:i,style:M,className:"w-80 max-h-[28rem] bg-surface border border-border rounded-lg shadow-xl flex flex-col overflow-hidden",children:[u("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border shrink-0",children:[r("span",{className:"text-[12px] font-semibold text-foreground",children:"Alerts"}),u("div",{className:"flex items-center gap-2",children:[h>0&&u("label",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle cursor-pointer select-none",children:[r("input",{type:"checkbox",checked:s,onChange:A=>a(A.target.checked),className:"h-3 w-3 rounded border-border accent-primary cursor-pointer"}),"Show read"]}),d>0&&u("button",{type:"button",onClick:N,className:"flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors",children:[r(vD,{className:"h-3 w-3"}),"Mark all read"]})]})]}),u("div",{className:"flex-1 overflow-y-auto",children:[p&&r("div",{className:"flex items-center justify-center py-8",children:r(Ae,{className:"h-4 w-4 animate-spin text-foreground-subtle"})}),!p&&m.length===0&&u("div",{className:"flex flex-col items-center justify-center py-8 text-foreground-subtle",children:[r(Xe,{className:"h-6 w-6 mb-2 opacity-40"}),r("span",{className:"text-[11px]",children:f.length>0?"No unread alerts":"No alerts"}),f.length>0&&!s&&u("button",{type:"button",onClick:()=>a(!0),className:"text-[10px] text-primary mt-1 hover:underline",children:["Show ",h," read alert",h!==1?"s":""]})]}),k.length>0&&u("div",{className:"border-b border-border",children:[r("div",{className:"px-3 py-1.5 bg-surface-hover/50",children:r("span",{className:"text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:"In Progress"})}),k.map(A=>r(tp,{alert:A,onMarkRead:w,onDismiss:v},A.id))]}),S.map(A=>r(tp,{alert:A,onMarkRead:w,onDismiss:v},A.id))]})]}),document.body)]})}function Oy(e){return e.map(t=>({id:t.page.id,addonId:t.addonId,label:t.page.label,icon:t.page.icon,path:t.page.path,remoteName:t.page.remoteName,bundle:t.page.bundle,bundleUrl:t.bundleUrl}))}const rp=new Map,es=new Map,op=new Set;function i6(e){return!e||typeof e!="object"?!1:typeof e.default=="function"}async function l6(e,t){const n=rp.get(e);if(n)return n;const o=es.get(e);if(o)return o;op.has(e)||(Tl(),hr.registerRemotes([{name:e,entry:t,type:"module"}],{force:!1}),op.add(e));const s=hr.loadRemote(`${e}/page`).then(a=>{if(!i6(a))throw new Error(`Addon page remote ${e} (${t}) does not expose a default React component on './page'`);return rp.set(e,a.default),es.delete(e),a.default}).catch(a=>{throw es.delete(e),a});return es.set(e,s),s}function c6(){const{pagePath:e}=Hc(),t=Le(),{data:n}=lc(void 0,{staleTime:6e4}),o=U(()=>n?Oy(n):void 0,[n]),s=o?.find(d=>d.path===`/addon/${e}`),[a,i]=$(null),[l,c]=$(null);return Z(()=>{if(!s)return;c(null),i(null);let d=!1;return l6(s.remoteName,s.bundleUrl).then(f=>{d||i(()=>f)}).catch(f=>{if(d)return;const p=f instanceof Error?f.message:String(f);c(`Failed to load addon page: ${p}`)}),()=>{d=!0}},[s]),o?s?l?r("div",{className:"flex items-center justify-center h-full text-red-400 text-sm",children:l}):a?r(a,{trpc:t.trpcClient,theme:{isDark:document.documentElement.classList.contains("dark")},navigate:d=>{window.location.href=d}}):r("div",{className:"flex items-center justify-center h-full",children:r("div",{className:"animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full"})}):r("div",{className:"flex items-center justify-center h-full text-foreground-subtle",children:"Addon page not found"}):r("div",{className:"flex items-center justify-center h-full",children:r("div",{className:"animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full"})})}const d6={dark:fy,light:mT,system:IL},u6={gauge:ly,puzzle:Ds,bot:uD,cpu:dt,terminal:vy,box:ga,wrench:IT,activity:Eo,plug:ed};function p6(){const e=mt(),t=Je(),{user:n,logout:o}=fn(),s=Ar(),{t:a,i18n:i}=Ot(),l=er(),c=sh(),d=G_(),f=d!=="connected",p=d==="connecting",[m,h]=$(!1),[g,b]=$(()=>typeof window>"u"?!1:window.localStorage.getItem("camstack:sidebar-collapsed")==="1");Z(()=>{typeof window>"u"||window.localStorage.setItem("camstack:sidebar-collapsed",g?"1":"0")},[g]);const[x,y]=$(()=>{if(typeof window>"u")return new Set;try{const E=window.localStorage.getItem("camstack:sidebar-collapsed-groups");if(!E)return new Set;const Q=JSON.parse(E);return Array.isArray(Q)?new Set(Q.filter(K=>typeof K=="string")):new Set}catch{return new Set}});Z(()=>{typeof window>"u"||window.localStorage.setItem("camstack:sidebar-collapsed-groups",JSON.stringify([...x]))},[x]),Z(()=>{c&&window.localStorage.getItem("camstack:sidebar-collapsed")===null&&b(!0)},[c]);const{data:w=[]}=dc(void 0,{staleTime:3e4,refetchInterval:3e4}),v=w.length,N=ke(),k=ne(Date.now()),S=3e4,M=2e3,{data:P}=lc(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:E=>{const Q=E.state.data;return Q&&Q.length>0||Date.now()-k.current>=S?!1:M}}),A=U(()=>P?Oy(P):[],[P]);ct("addon.page-ready",()=>{N.invalidateQueries({queryKey:[["addonPages","listPages"]]})});const z=()=>{o(),t("/login")},D=E=>!!(e.pathname===E||e.pathname.startsWith(E+"/")),O=["/pipeline","/timeline"].some(E=>e.pathname===E||e.pathname.startsWith(E+"/")),I=()=>{const E=i.language==="en"?"it":"en";i.changeLanguage(E)},L=[{label:a("nav.devices","Devices"),icon:xr,path:"/devices"},{label:a("nav.integrations"),icon:ed,path:"/integrations"},{label:a("nav.timeline","Timeline"),icon:DD,path:"/timeline"},{label:a("nav.pipeline","Pipeline"),icon:cy,path:"/pipeline"}],_=[{label:a("system.identity","Identity & Access"),icon:py,path:"/system/identity"},{label:a("system.network","Network"),icon:yr,path:"/system/network"},{label:a("system.data","Data"),icon:ay,path:"/system/data"},{label:a("system.cluster","Cluster"),icon:an,path:"/system/cluster"},{label:a("system.addons"),icon:Ds,path:"/system/addons"},{label:a("system.addonSettings","Addon Settings"),icon:Nt,path:"/system/settings"},{label:a("system.logs","Logs"),icon:Xe,path:"/system/logs"}],R=s?.mode??"system",B={dark:a("theme.dark"),light:a("theme.light"),system:a("theme.system")},F=g&&!l,j=(E,Q="md")=>`flex w-full items-center gap-2.5 rounded-md ${F?"justify-center px-0 py-2":"px-2.5 py-1.5"} ${Q==="lg"?"text-[13px] font-medium":"text-[12px]"} transition-all ${E?Q==="lg"?"bg-primary/12 text-primary shadow-sm shadow-primary/5":"bg-primary/12 text-primary":"text-foreground-subtle hover:bg-surface-hover hover:text-foreground"}`,H=u(ge,{children:[u("div",{className:`flex h-14 items-center border-b border-border ${F?"justify-center px-1":"pl-3 pr-4 gap-2"}`,children:[!F&&r("img",{src:s?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack Admin",className:"h-9 flex-1 min-w-0"}),!l&&r("button",{onClick:()=>b(E=>!E),className:`p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle transition-colors flex-shrink-0 ${F?"":"mr-2"}`,"aria-label":g?"Expand sidebar":"Collapse sidebar",title:g?"Expand sidebar":"Collapse sidebar",children:g?r(It,{className:"h-4 w-4"}):r(Yc,{className:"h-4 w-4"})})]}),u("nav",{className:`flex-1 overflow-y-auto py-3 ${F?"px-1.5":"px-2"} space-y-0.5`,children:[(()=>{const E=D("/dashboard");return u("button",{"data-testid":"nav-dashboard",onClick:()=>{t("/dashboard"),h(!1)},className:j(E,"lg"),title:F?a("nav.dashboard"):void 0,children:[r(uy,{className:`h-4 w-4 shrink-0 ${E?"text-primary":""}`}),!F&&a("nav.dashboard")]})})(),!F&&r("div",{className:"pt-4 pb-1.5 px-2.5",children:r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("nav.camerasSection","Cameras")})}),F&&r("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),L.map(E=>{const Q=E.icon,K=D(E.path),Y=`nav-${E.path.replace(/^\//,"").replace(/\//g,"-")}`;return u("button",{"data-testid":Y,onClick:()=>{t(E.path),h(!1)},className:j(K),title:F?E.label:void 0,children:[r(Q,{className:`h-3.5 w-3.5 shrink-0 ${K?"text-primary":""}`}),!F&&E.label]},E.path)}),!F&&r("div",{className:"pt-4 pb-1.5 px-2.5",children:r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("system.title")})}),F&&r("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),_.map(E=>{const Q=E.icon,K=D(E.path),Y=E.path==="/system/addons",re=`nav-${E.path.replace(/^\//,"").replace(/\//g,"-")}`;return u("button",{"data-testid":re,onClick:()=>{t(E.path),h(!1)},className:j(K),title:F?E.label:void 0,children:[r(Q,{className:`h-3.5 w-3.5 shrink-0 ${K?"text-primary":""}`}),!F&&u(ge,{children:[r("span",{className:"flex-1 text-left",children:E.label}),Y&&v>0&&r("span",{className:"ml-auto rounded-full bg-primary px-1.5 py-0.5 text-[9px] font-bold text-primary-foreground leading-none",children:v})]}),F&&Y&&v>0&&r("span",{className:"absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary"})]},E.path)}),A&&A.length>0&&!F&&r("div",{className:"pt-4 pb-1.5 px-2.5",children:r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("nav.addonPages","Addon Pages")})}),F&&A&&A.length>0&&r("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),A?.map(E=>{const Q=D(E.path),K=u6[E.icon]??Ds;return u("button",{onClick:()=>{t(E.path),h(!1)},className:j(Q),title:F?E.label:void 0,children:[r(K,{className:`h-3.5 w-3.5 shrink-0 ${Q?"text-primary":""}`}),!F&&E.label]},E.id)})]}),u("div",{className:`border-t border-border ${F?"p-1.5":"p-2"} space-y-0.5`,children:[u("button",{onClick:I,title:a("language.select"),className:j(!1),children:[r(iL,{className:"h-3.5 w-3.5 shrink-0"}),!F&&r("span",{children:i.language==="en"?a("language.en"):a("language.it")})]}),u("button",{onClick:()=>s?.toggleMode(),className:j(!1),title:F?B[R]:void 0,children:[(()=>{const E=d6[R];return r(E,{className:"h-3.5 w-3.5 shrink-0"})})(),!F&&r("span",{children:B[R]})]}),r(np,{variant:"sidebar",compact:F}),u("button",{type:"button",onClick:()=>t("/system/my-access"),className:j(D("/system/my-access")),title:F?a("system.myAccess","My access"):void 0,children:[r(Kt,{className:"h-3.5 w-3.5 shrink-0"}),!F&&r("span",{className:"truncate",children:a("system.myAccess","My access")})]}),u("button",{onClick:z,className:j(!1).replace("hover:text-foreground","hover:text-danger"),title:F?n?.username??"Logout":void 0,children:[r(Xc,{className:"h-3.5 w-3.5 shrink-0"}),!F&&r("span",{className:"truncate",children:n?.username??"User"})]})]})]});return u("div",{className:"flex h-screen bg-background text-foreground",children:[!l&&r("aside",{className:`flex flex-col border-r border-border bg-surface/80 backdrop-blur-sm shrink-0 transition-[width] duration-150 ease-out ${F?"w-12":"w-48"}`,children:H}),l&&r(Wl,{open:m,onClose:()=>h(!1),width:"w-64",children:H}),u("div",{className:"flex flex-1 flex-col min-w-0",children:[f&&u("div",{className:"flex items-center justify-center gap-2 bg-danger/90 px-3 py-2 text-[12px] font-medium text-white shrink-0",children:[r(ky,{className:"h-3.5 w-3.5"}),r("span",{children:p?a("connection.reconnecting","Reconnecting…"):a("connection.disconnected","Server unreachable — reconnecting…")}),r(Ae,{className:"h-3.5 w-3.5 animate-spin"})]}),l&&u("header",{className:"flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm",children:[r("button",{onClick:()=>h(!0),className:"p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors","aria-label":"Open menu",children:r(NL,{className:"h-5 w-5"})}),r("div",{className:"flex-1 flex justify-center",children:r("img",{src:s?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack",className:"h-7"})}),r(np,{})]}),u("main",{className:`relative flex-1 min-h-0 bg-background ${O?"overflow-hidden":"overflow-auto"}`,children:[f&&r("div",{className:"absolute inset-0 z-40 bg-background/60 backdrop-blur-[2px]"}),r(a_,{})]})]})]})}function f6(){const{login:e}=fn(),t=Ar(),n=Je(),[o,s]=$(""),[a,i]=$(""),[l,c]=$(!1),[d,f]=$(""),[p,m]=$(!1),h=async g=>{g.preventDefault(),f(""),m(!0);try{await e(o,a),n(a==="changeme"?"/change-password":"/dashboard",{replace:!0})}catch(b){f(b instanceof Error?b.message:"Login failed")}finally{m(!1)}};return r("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:u("div",{className:"w-full max-w-sm",children:[r("div",{className:"flex justify-center mb-8",children:r("img",{src:t?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack Admin",className:"h-12"})}),u("form",{onSubmit:h,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[d&&r("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:d}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Username"}),r("input",{"data-testid":"login-username",type:"text",placeholder:"Username",value:o,onChange:g=>s(g.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all",autoFocus:!0})]}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Password"}),u("div",{className:"relative",children:[r("input",{"data-testid":"login-password",type:l?"text":"password",placeholder:"Password",value:a,onChange:g=>i(g.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all"}),r("button",{type:"button",onClick:()=>c(!l),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors",tabIndex:-1,children:l?r(iy,{className:"h-4 w-4"}):r(_o,{className:"h-4 w-4"})})]})]}),r("button",{"data-testid":"login-submit",type:"submit",disabled:p||!o||!a,className:"w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all",children:p?u("span",{className:"flex items-center justify-center gap-2",children:[r("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground/30 border-t-primary-foreground"}),"Logging in..."]}):"Log in"})]}),r(m6,{}),r("p",{className:"mt-6 text-center text-[10px] text-foreground-subtle/50",children:"CamStack v0.1.0"})]})})}function m6(){const t=(pc().data??[]).filter(n=>n.enabled&&n.hasRedirectFlow);return t.length===0?null:u("div",{className:"mt-6 space-y-3",children:[u("div",{className:"flex items-center gap-3",children:[r("div",{className:"h-px flex-1 bg-border"}),r("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Or continue with"}),r("div",{className:"h-px flex-1 bg-border"})]}),r("div",{className:"space-y-2",children:t.map(n=>u("a",{href:`/addon/${encodeURIComponent(n.addonId)}/start`,className:"flex items-center justify-center gap-2 w-full rounded-lg border border-border bg-surface px-4 py-2.5 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors",children:[r(Kt,{className:"h-4 w-4 text-primary"}),n.displayName]},n.addonId))})]})}const sp=8;function h6(){const{user:e,mustChangePassword:t,clearMustChangePassword:n,logout:o}=fn(),s=Ar(),a=Je(),[i,l]=$(""),[c,d]=$(""),[f,p]=$(!1),[m,h]=$(""),g=Mc({onSuccess:()=>{n(),a("/dashboard",{replace:!0})},onError:x=>{h(x instanceof Error?x.message:"Could not change password")}}),b=async x=>{if(x.preventDefault(),h(""),!e){h("Not signed in");return}if(i.length<sp){h(`Password must be at least ${sp} characters`);return}if(i!==c){h("The two passwords do not match");return}if(i==="changeme"){h("Choose a password different from the seed default");return}g.mutate({id:e.id,newPassword:i})};return r("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:u("div",{className:"w-full max-w-sm",children:[r("div",{className:"flex justify-center mb-8",children:r("img",{src:s?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack Admin",className:"h-12"})}),u("form",{onSubmit:b,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[u("div",{className:"space-y-1",children:[r("h1",{className:"text-sm font-semibold text-foreground",children:"Set a new password"}),r("p",{className:"text-xs text-foreground-subtle",children:t?"You must rotate the seed password before continuing.":"Choose a new password for your account."})]}),m&&r("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:m}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"New password"}),u("div",{className:"relative",children:[r("input",{"data-testid":"change-password-new",type:f?"text":"password",value:i,onChange:x=>l(x.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all",autoFocus:!0}),r("button",{type:"button",onClick:()=>p(!f),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors",tabIndex:-1,children:f?r(iy,{className:"h-4 w-4"}):r(_o,{className:"h-4 w-4"})})]})]}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Confirm new password"}),r("input",{"data-testid":"change-password-confirm",type:f?"text":"password",value:c,onChange:x=>d(x.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all"})]}),r("button",{"data-testid":"change-password-submit",type:"submit",disabled:g.isPending||!i||!c,className:"w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all",children:g.isPending?"Saving…":"Save and continue"}),t&&r("button",{type:"button",onClick:()=>{o(),a("/login",{replace:!0})},className:"w-full text-xs text-foreground-subtle hover:text-foreground transition-colors",children:"Sign out instead"})]})]})})}function g6(){const e=Je();return u("div",{className:"flex min-h-screen flex-col items-center justify-center bg-background text-foreground p-4",children:[r("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-danger/10 mb-4",children:r(oT,{className:"h-8 w-8 text-danger"})}),r("h1",{className:"text-xl font-bold",children:"Access Denied"}),r("p",{className:"mt-2 text-sm text-foreground-subtle",children:"You don't have permission to access this page."}),r("button",{onClick:()=>e("/dashboard"),className:"mt-6 rounded-lg bg-primary px-5 py-2.5 text-sm font-medium text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all",children:"Go to Dashboard"})]})}const zy="camstack:dashboard-layout",pi={version:1,widgets:[]};function b6(){try{const e=localStorage.getItem(zy);if(!e)return pi;const t=JSON.parse(e);return t&&t.version===1&&Array.isArray(t.widgets)?{version:1,widgets:t.widgets}:pi}catch{return pi}}function x6(e){try{localStorage.setItem(zy,JSON.stringify(e))}catch{}}function y6(){const e=typeof crypto<"u"?crypto:void 0;return e?.randomUUID?e.randomUUID():`widget-${Date.now().toString(36)}-${Math.floor(Math.random()*1e6).toString(36)}`}function v6(){const[e,t]=$(b6),[n,o]=$(!1),s=gx(),a=U(()=>s.filter(d=>d.hosts.includes("dashboard")),[s]),i=q(d=>{t(d),x6(d)},[]),l=q(d=>{i({version:1,widgets:[...e.widgets,d]})},[e,i]),c=q(d=>{i({version:1,widgets:e.widgets.filter(f=>f.instanceId!==d)})},[e,i]);return u("div",{className:"p-4",children:[u("div",{className:"flex items-center justify-between mb-4",children:[r("h1",{className:"text-lg font-semibold text-foreground",children:"Dashboard"}),u("button",{onClick:()=>o(!0),className:"flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors",children:[r(wt,{className:"h-3.5 w-3.5"}),"Add widget"]})]}),e.widgets.length===0?r(w6,{onAdd:()=>o(!0)}):r("div",{className:"grid grid-cols-12 gap-3 auto-rows-[minmax(80px,_auto)]",children:e.widgets.map(d=>r(N6,{entry:d,onRemove:()=>c(d.instanceId)},d.instanceId))}),n&&r(S6,{widgets:a,onClose:()=>o(!1),onAdd:d=>{l(d),o(!1)}})]})}function w6({onAdd:e}){return u("div",{className:"flex flex-col items-center justify-center py-24 text-foreground-subtle",children:[r("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-surface border border-border mb-4",children:r(uy,{className:"h-8 w-8 text-foreground-subtle/40"})}),r("p",{className:"text-sm font-medium text-foreground/70",children:"Your dashboard is empty"}),r("p",{className:"text-xs text-foreground-subtle mt-1 mb-4",children:"Add widgets to monitor your cameras and system"}),u("button",{onClick:e,className:"flex items-center gap-1.5 rounded-lg bg-primary px-4 py-2 text-xs font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all",children:[r(wt,{className:"h-3.5 w-3.5"}),"Add your first widget"]})]})}function N6({entry:e,onRemove:t}){const n=k6(e.columns),o=Math.max(1,Math.min(12,e.rows));return u("div",{className:"relative group rounded-lg border border-border bg-surface overflow-hidden flex flex-col",style:{gridColumn:`span ${n} / span ${n}`,gridRow:`span ${o} / span ${o}`},children:[r("button",{type:"button",onClick:t,title:"Remove widget",className:"absolute right-1.5 top-1.5 z-10 inline-flex h-5 w-5 items-center justify-center rounded-md border border-border/60 bg-surface/80 text-foreground-subtle opacity-0 group-hover:opacity-100 hover:bg-danger/10 hover:text-danger hover:border-danger/40 transition-all",children:r(Ve,{className:"h-3 w-3"})}),r("div",{className:"flex-1 min-h-0 overflow-auto p-2",children:r(at,{widgetId:e.widgetId,host:"dashboard",instanceId:e.instanceId,config:e.config,deviceId:e.deviceId,size:e.size,columns:e.columns,rows:e.rows})})]})}function k6(e){return!Number.isFinite(e)||e<1?6:Math.min(12,Math.floor(e))}function S6({widgets:e,onClose:t,onAdd:n}){const[o,s]=$(null);return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:t,children:u("div",{className:"w-full max-w-2xl rounded-xl border border-border bg-surface p-5 shadow-2xl shadow-black/20",onClick:a=>a.stopPropagation(),children:[u("div",{className:"flex items-center justify-between mb-4",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:o?`Configure: ${o.label}`:"Add widget"}),r("button",{onClick:t,className:"p-1 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",children:r(Ve,{className:"h-4 w-4"})})]}),o===null?r(C6,{widgets:e,onSelect:s}):r(M6,{widget:o,onCancel:()=>s(null),onAdd:n})]})})}function C6({widgets:e,onSelect:t}){return e.length===0?r("div",{className:"text-center py-8 text-xs text-foreground-subtle italic",children:"No dashboard-host widgets registered. Make sure the contributing addons are enabled and have rebuilt their widget bundles."}):r("div",{className:"grid grid-cols-2 gap-2 max-h-96 overflow-auto",children:e.map(n=>u("button",{onClick:()=>t(n),className:"flex flex-col rounded-lg border border-border p-3 text-left hover:bg-surface-hover hover:border-primary/30 transition-all group",children:[r("span",{className:"text-xs font-medium text-foreground block",children:n.label}),r("span",{className:"text-[10px] text-foreground-subtle truncate",title:n.widgetId,children:n.widgetId}),n.description&&r("span",{className:"text-[10px] text-foreground-subtle mt-1 line-clamp-2",children:n.description})]},n.widgetId))})}function M6({widget:e,onCancel:t,onAdd:n}){const[o,s]=$(e.defaultSize),[a,i]=$(e.defaultColumns),[l,c]=$(e.defaultRows),[d,f]=$(null),{data:p}=tr({},{enabled:e.requires.deviceContext,staleTime:3e4}),m=!e.requires.deviceContext||d!==null&&d>0,h=()=>{if(!m)return;const g={instanceId:y6(),widgetId:e.widgetId,size:o,columns:a,rows:l,...e.requires.deviceContext&&d!==null?{deviceId:d}:{}};n(g)};return u("div",{className:"space-y-3",children:[u("div",{children:[r("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:"Size"}),r("div",{className:"flex items-center gap-1",children:e.allowedSizes.map(g=>r("button",{onClick:()=>s(g),className:`px-3 py-1 rounded-md text-[11px] font-medium border transition-colors ${o===g?"bg-primary/10 text-primary border-primary/30":"border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground"}`,children:g.toUpperCase()},g))})]}),u("div",{className:"grid grid-cols-2 gap-3",children:[r(ap,{label:"Columns (1-12)",value:a,min:1,max:12,onChange:i}),r(ap,{label:"Rows (1-12)",value:l,min:1,max:12,onChange:c})]}),e.requires.deviceContext&&u("div",{children:[r("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:"Device"}),u("select",{value:d??"",onChange:g=>f(g.target.value===""?null:Number(g.target.value)),className:"w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none",children:[r("option",{value:"",children:"— select a device —"}),(p??[]).map(g=>u("option",{value:g.id,children:[g.name??g.stableId," (#",g.id,")"]},g.id))]})]}),u("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-border",children:[r("button",{onClick:t,className:"px-3 py-1.5 rounded-md text-xs font-medium border border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors",children:"Back"}),r("button",{disabled:!m,onClick:h,className:"px-3 py-1.5 rounded-md text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Add to dashboard"})]})]})}function ap({label:e,value:t,min:n,max:o,onChange:s}){return u("div",{children:[r("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:e}),r("input",{type:"number",min:n,max:o,value:t,onChange:a=>{const i=Number(a.target.value);Number.isFinite(i)&&s(Math.max(n,Math.min(o,Math.floor(i))))},className:"w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none"})]})}function I6(){return r(v6,{})}function Rt({icon:e,title:t,subtitle:n,actions:o,children:s}){return u("div",{className:"p-6 space-y-4",children:[u("div",{className:"flex items-center justify-between gap-4",children:[u("div",{className:"min-w-0",children:[u("h1",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e&&r(e,{className:"h-4 w-4 text-foreground-subtle"}),t]}),n&&r("p",{className:"text-xs text-foreground-subtle mt-0.5",children:n})]}),o&&r("div",{className:"shrink-0 flex items-center gap-2",children:o})]}),s]})}const ip=["camera","hub","nvr","light","siren","switch","sensor","thermostat","button","generic"];function A6(){const{t:e}=Ot(),t=Je(),n=Le();xt(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]),xt(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped"]);const{data:o}=tr({},{staleTime:3e4}),{data:s}=xc(void 0,{staleTime:3e4}),a=U(()=>o??[],[o]),{activeDevices:i,orphanDevices:l}=U(()=>{const h=new Set((s??[]).map(k=>k.addonId)),g=k=>typeof k.addonId=="string"&&k.addonId.length>0&&!h.has(k.addonId),b=new Set;for(const k of a)g(k)&&b.add(k.id);const x=new Set(b),y=new Map;for(const k of a)y.set(k.id,k);const w=(k,S=0)=>{if(S>32)return!1;if(b.has(k.id))return!0;if(k.parentDeviceId==null)return!1;const M=y.get(k.parentDeviceId);return M?w(M,S+1):!1};for(const k of a)w(k)&&x.add(k.id);const v=[],N=[];for(const k of a)x.has(k.id)?N.push(k):v.push(k);return{activeDevices:v,orphanDevices:N}},[a,s]),c=U(()=>{const h=new Map;for(const g of a)h.set(g.id,{id:g.id,name:g.name??g.stableId??`#${String(g.id)}`});return h},[a]),d=q(h=>c.get(h)??null,[c]),f=U(()=>(s??[]).map(h=>({id:h.addonId,name:h.name??h.addonId,icon:r(cn,{type:h.addonId,size:"sm"})})),[s]),p=q(h=>r(cn,{type:h,size:"sm"}),[]),m=q(h=>t(`/devices/${String(h)}`),[t]);return u(Rt,{icon:xr,title:e("nav.devices","Devices"),children:[r(io,{devices:i,trpc:n.trpcClient,filters:{types:ip,addons:f},resolveIntegrationIcon:p,resolveParent:d,onNavigate:m}),l.length>0&&u("div",{className:"mt-6 space-y-2",children:[u("div",{className:"flex items-baseline gap-2",children:[r(bt,{className:"h-3.5 w-3.5 text-warning shrink-0"}),r("h2",{className:"text-sm font-semibold text-foreground",children:"Orphan devices"}),u("span",{className:"text-[10px] text-foreground-subtle",children:[l.length," device",l.length===1?"":"s"," pointing at integrations no longer registered"]})]}),u("div",{className:"rounded-lg border border-warning/30 bg-warning/5 p-2",children:[r("p",{className:"text-[11px] text-foreground-subtle px-2 pb-2",children:"These devices reference an addonId that has no matching integration. Delete them, or re-install the missing integration to bring them back online. The provider scope (`addonId`) shown beside each row is what's failing to resolve."}),r(io,{devices:l,trpc:n.trpcClient,filters:{types:ip,addons:f},urlScope:"nested",lsKey:"devices:orphan",resolveIntegrationIcon:p,resolveParent:d,onNavigate:m})]})]})]})}function P6({onSelect:e,onClose:t,pendingAddonId:n=null}){const{t:o}=Ot(),s=Je(),{data:a,isLoading:i}=Fg();if(i)return r("div",{className:"space-y-2 p-2",children:[1,2,3].map(c=>r("div",{className:"h-14 rounded-lg bg-surface animate-pulse"},c))});const l=n!==null;return u("div",{className:"space-y-2",children:[(a??[]).map(c=>{const d=c.instanceMode==="unique"&&c.existingInstances.length>0,f=n===c.addonId,p=l;return u("button",{disabled:p,onClick:()=>{if(!p)if(d){const m=c.existingInstances[0].id;t(),s(`/integrations/${m}`)}else e(c.addonId,c.instanceMode,c.discoveryMode,c.name)},className:"flex w-full items-center gap-3 rounded-lg border border-border bg-surface p-3 text-left hover:border-foreground-subtle/30 transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border",children:[c.iconUrl?r("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0",style:{backgroundColor:`${c.color}15`},children:r("img",{src:c.iconUrl,alt:"",className:"h-5 w-5"})}):r("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0",style:{backgroundColor:`${c.color}15`},children:r("span",{className:"text-sm",style:{color:c.color},children:"◉"})}),u("div",{className:"flex-1 min-w-0",children:[r("p",{className:"text-xs font-semibold text-foreground",children:c.name}),c.description&&r("p",{className:"text-[10px] text-foreground-subtle mt-0.5 truncate",children:c.description})]}),f?r(Ae,{className:"h-4 w-4 animate-spin text-primary flex-shrink-0"}):d?u("span",{className:"flex items-center gap-1 text-[10px] font-medium text-foreground-subtle",children:[r(Nt,{className:"h-3 w-3"}),o("integrations.manage")]}):r(It,{className:"h-4 w-4 text-foreground-subtle flex-shrink-0"})]},c.addonId)}),(a??[]).length===0&&r("div",{className:"py-8 text-center text-xs text-foreground-subtle",children:o("integrations.noProviders")})]})}function E6(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function lp(e,t){if(e!==void 0)return t&&E6(e)?t(e):e}function $6({section:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i,onAction:l}){const[c,d]=$(e.defaultCollapsed??!1),f=e.style==="accordion";if(e.fields.reduce((b,x)=>b+(Ic(x,t,e.fields)?1:0),0)===0)return null;const m=e.columns??2,h=m===1?"grid-cols-1":m===3?"grid-cols-1 @[420px]:grid-cols-2 @[680px]:grid-cols-3":m===4?"grid-cols-1 @[420px]:grid-cols-2 @[900px]:grid-cols-4":"grid-cols-1 @[480px]:grid-cols-2",g=!e.title&&!e.description;return u("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[!g&&u("div",{className:["flex items-center justify-between mb-2",f?"cursor-pointer":""].join(" "),onClick:f?()=>d(b=>!b):void 0,children:[u("div",{children:[e.title&&r("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:lp(e.title,s)}),e.description&&r("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:lp(e.description,s)})]}),f&&r("span",{className:"text-foreground-subtle text-xs ml-2",children:c?"▸":"▾"})]}),!c&&r("div",{className:`grid ${h} gap-x-3 gap-y-2.5`,children:e.fields.map(b=>r(rr,{field:b,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i?.[b.key],allFields:e.fields,onAction:l},b.key))})]})}function kn({schema:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i,onClearProbe:l,onAction:c}){const d=(f,p)=>{n({...t,[f]:p}),l?.(f)};return r("div",{className:"space-y-4",children:e.sections.map((f,p)=>r($6,{section:f,values:t,onChange:d,disabled:o,translationFn:s,onTestField:a,probeResults:i,onAction:c},`${f.id}-${p}`))})}function _6({addonId:e,configSchema:t,onSave:n,onBack:o}){const{t:s}=Ot(),[a,i]=$(""),[l,c]=$({}),[d,f]=$(null),p=jg({onSuccess:m=>f(m),onError:m=>f({success:!1,error:String(m)})});return u("div",{className:"space-y-4",children:[u("div",{children:[r("label",{className:"block text-[11px] font-medium text-foreground mb-1",children:s("integrations.integrationName")}),r("input",{type:"text",value:a,onChange:m=>i(m.target.value),placeholder:s("integrations.integrationNamePlaceholder"),className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:border-primary/50"})]}),t&&r(kn,{schema:t,values:l,onChange:c}),d&&r("div",{className:`rounded-lg border px-3 py-2 text-xs ${d.success?"border-success/30 bg-success/5 text-success":"border-danger/30 bg-danger/5 text-danger"}`,children:d.success?s("integrations.connectionSuccess"):`${s("integrations.errorPrefix")} ${d.error}`}),u("div",{className:"flex items-center justify-between pt-2",children:[r("button",{onClick:o,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors",children:s("integrations.back")}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>p.mutate({addonId:e,settings:l}),disabled:p.isPending,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:p.isPending?s("integrations.testing"):s("integrations.testConnection")}),r("button",{onClick:()=>n({name:a,config:l}),disabled:!a.trim(),className:"rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:s("integrations.forward")})]})]})]})}function D6({providerId:e,onImport:t,onSkip:n}){const{t:o}=Ot(),[s,a]=$(new Set),i=gc(),l=i.data,c=i.isPending||!i.data&&!i.isError;Z(()=>{e&&(i.isPending||i.data||i.mutate({addonId:e}))},[e,i]);function d(p){a(m=>{const h=new Set(m);return h.has(p)?h.delete(p):h.add(p),h})}if(c)return u("div",{className:"flex flex-col items-center py-12",children:[r("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"}),r("p",{className:"mt-3 text-xs text-foreground-subtle",children:o("integrations.searchingDevices")})]});const f=l??[];return u("div",{className:"space-y-4",children:[r("p",{className:"text-xs text-foreground-subtle",children:f.length>0?o("integrations.foundDevices",{count:f.length}):o("integrations.noDevicesFound")}),f.length>0&&r("div",{className:"space-y-1.5 max-h-64 overflow-y-auto",children:f.map(p=>{const m=p.stableId,h=p.suggestedName??m,g=s.has(m);return u("button",{onClick:()=>d(m),className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${g?"border-primary/40 bg-primary/5":"border-border bg-surface hover:border-foreground-subtle/30"}`,children:[r("div",{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${g?"border-primary bg-primary":"border-border"}`,children:g&&r(Mt,{className:"h-3 w-3 text-primary-foreground"})}),r(xr,{className:"h-3.5 w-3.5 text-foreground-subtle flex-shrink-0"}),r("span",{className:"text-xs font-medium text-foreground truncate",children:h})]},m)})}),u("div",{className:"flex items-center justify-between pt-2",children:[r("button",{onClick:n,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors",children:o("integrations.skip")}),f.length>0&&u("button",{onClick:()=>t(Array.from(s)),disabled:s.size===0,className:"rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:[o("integrations.importSelected")," (",s.size,")"]})]})]})}function L6(e){const t=n=>{if(n.type==="separator"||n.type==="info"||n.type==="button")return n;if(n.type==="group")return{...n,fields:n.fields.map(i=>t(i))};const o=n,{value:s,...a}=o;return a};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(n=>({...n,fields:n.fields.map(t)}))}}function T6({open:e,onClose:t}){const{t:n}=Ot(),o=Je(),s=ke(),[a,i]=$("picker"),[l,c]=$(null),[d,f]=$(null),[p,m]=$("manual"),{data:h}=uc({addonId:l??"",nodeId:"hub"},{enabled:l!=null}),g=U(()=>h?L6(h):null,[h]),b=Og({onSuccess:()=>s.invalidateQueries({queryKey:[["integrations"]]})}),x=gc(),y=x.data;Z(()=>{a!=="discovery"||!d||!l||x.isPending||x.data||x.mutate({addonId:l})},[a,d,l,x]);const w=_g({onSuccess:()=>s.invalidateQueries({queryKey:[["deviceManager"]]})});async function v(O,I,L,_){if(!b.isPending){if(c(O),m(L),I==="unique"){try{const R=await b.mutateAsync({addonId:O,name:_,settings:{}});t(),M(),o(`/integrations/${R.id}`)}catch{}return}i("config")}}async function N(O){if(l)try{const I=await b.mutateAsync({addonId:l,name:O.name,settings:O.config});f(I.id),p==="auto"||p==="both"?i("discovery"):S(I.id)}catch{}}async function k(O){if(l){for(const I of O){const L=y?.find(_=>_.stableId===I);L&&await w.mutateAsync({addonId:l,candidate:L})}S()}}function S(O){const I=O??d??l;t(),M(),I&&o(`/integrations/${I}`)}function M(){i("picker"),c(null),f(null),m("manual")}function P(){t(),M()}if(!e)return null;const A={picker:n("integrations.newIntegration"),config:n("integrations.configureIntegration"),discovery:n("integrations.importDevices")},z=b.isPending,D=z?l:null,T=b.error;return u("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[r("div",{className:"absolute inset-0 bg-black/60",onClick:z?void 0:P}),u("div",{className:"relative z-10 w-full max-w-lg rounded-xl border border-border bg-background shadow-2xl",children:[u("div",{className:"flex items-center justify-between border-b border-border px-5 py-4",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:A[a]}),r("button",{onClick:P,disabled:z,className:"rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:r(Ve,{className:"h-4 w-4"})})]}),u("div",{className:"relative px-5 py-4",children:[T&&!z&&r("div",{className:"mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:T instanceof Error?T.message:String(T)}),a==="picker"&&r(P6,{onSelect:v,onClose:P,pendingAddonId:D}),a==="config"&&l&&r(_6,{addonId:l,configSchema:g??null,onSave:N,onBack:()=>i("picker")}),a==="discovery"&&d&&r(D6,{providerId:d,onImport:k,onSkip:S}),z&&u("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background/85 backdrop-blur-sm",children:[r(Ae,{className:"h-6 w-6 animate-spin text-primary"}),r("p",{className:"text-xs font-medium text-foreground",children:n("integrations.creating",{defaultValue:"Creating integration…"})}),r("p",{className:"text-[10px] text-foreground-subtle",children:n("integrations.creatingHint",{defaultValue:"Waiting for the addon to restart and register"})})]})]})]})]})}const cp={running:{bg:"bg-success/10",text:"text-success",dot:"bg-success",label:"Running"},stopped:{bg:"bg-foreground-subtle/10",text:"text-foreground-subtle",dot:"bg-foreground-subtle",label:"Stopped"},error:{bg:"bg-danger/10",text:"text-danger",dot:"bg-danger",label:"Error"},online:{bg:"bg-success/10",text:"text-success",dot:"bg-success",label:"Online"},offline:{bg:"bg-foreground-subtle/10",text:"text-foreground-subtle",dot:"bg-foreground-subtle",label:"Offline"},idle:{bg:"bg-info/10",text:"text-info",dot:"bg-info",label:"Idle"},disabled:{bg:"bg-warning/10",text:"text-warning",dot:"bg-warning",label:"Disabled"},enabled:{bg:"bg-success/10",text:"text-success",dot:"bg-success",label:"Enabled"}};function ka({status:e}){const t=cp[e]??cp.stopped;return u("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-medium ${t.bg} ${t.text}`,children:[r("span",{className:`h-1.5 w-1.5 rounded-full ${t.dot}`}),t.label]})}const fi="px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle";function R6({integrations:e,expandedAddonId:t,onToggleExpand:n,onOpenSettings:o,renderExpanded:s}){const a=q(i=>n(i),[n]);return r("div",{className:"overflow-hidden rounded-lg border border-border bg-surface",children:u("table",{className:"w-full table-fixed text-xs",children:[r("thead",{className:"bg-surface-hover/40",children:u("tr",{children:[r("th",{className:W(fi,"w-[60%]"),children:"Integration"}),r("th",{className:W(fi,"w-[15%]"),children:"Devices"}),r("th",{className:W(fi,"w-[25%]"),children:"Status"})]})}),r("tbody",{children:e.map(i=>{const l=t===i.addonId;return r(O6,{integration:i,isExpanded:l,onClick:a,onOpenSettings:o,renderExpanded:s},i.id)})})]})})}function O6({integration:e,isExpanded:t,onClick:n,onOpenSettings:o,renderExpanded:s}){const a=q(c=>{c.stopPropagation(),o(e.id)},[e.id,o]),i=q(()=>{n(e.addonId)},[e.addonId,n]),l=q(c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),i())},[i]);return u(ge,{children:[u("tr",{role:"button",tabIndex:0,"aria-expanded":t,className:W("cursor-pointer border-t border-border transition-colors hover:bg-surface-hover","focus:outline-none focus-visible:ring-1 focus-visible:ring-primary/40",t&&"bg-surface-hover/60"),onClick:i,onKeyDown:l,children:[r("td",{className:"px-3 py-2.5",children:u("div",{className:"flex items-center gap-2.5",children:[t?r(vt,{className:"h-3.5 w-3.5 flex-shrink-0 text-foreground-subtle"}):r(It,{className:"h-3.5 w-3.5 flex-shrink-0 text-foreground-subtle"}),r(cn,{type:e.addonId,size:"sm"}),u("div",{className:"flex min-w-0 flex-col",children:[r("span",{className:"truncate text-xs font-semibold text-foreground",children:e.name}),r("span",{className:"truncate text-[10px] text-foreground-subtle",children:e.addonId})]})]})}),u("td",{className:"px-3 py-2.5 text-[11px] text-foreground-subtle",children:[e.deviceCount," device",e.deviceCount!==1?"s":""]}),r("td",{className:"px-3 py-2.5",children:u("div",{className:"flex items-center justify-between gap-2",children:[r(ka,{status:e.status}),u("button",{type:"button",onClick:a,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary",title:"Open integration settings",children:[r(Nt,{className:"h-3 w-3"}),"Settings"]})]})})]}),t&&r("tr",{className:"border-t border-border bg-surface",children:r("td",{colSpan:3,className:"px-3 py-3",children:s(e.addonId)})})]})}function z6(e){if(!e.enabled)return"disabled";switch(e.processState){case"running":return"running";case"stopped":case"crashed":case"unknown":default:return"stopped"}}const ts="expand";function B6(){const{t:e}=Ot(),t=Je(),n=Le(),[o]=ha(),[s,a]=$(!1),i=q(()=>a(!0),[]),l=q(()=>a(!1),[]);xt(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped","addon.updated"]),xt(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]);const{data:c,isLoading:d,refetch:f}=xc(void 0,{staleTime:3e4}),{data:p,isLoading:m,refetch:h}=tr({},{staleTime:3e4}),g=U(()=>p??[],[p]),b=U(()=>c??[],[c]),x=U(()=>{const O=new Map;for(const I of g)O.set(I.id,{id:I.id,name:I.name??I.stableId??`#${String(I.id)}`});return O},[g]),y=U(()=>{const O=new Map;for(const I of g){if(I.parentDeviceId!==null&&I.parentDeviceId!==void 0&&!!I.role)continue;const _=I.addonId??"";_&&O.set(_,(O.get(_)??0)+1)}return O},[g]),w=U(()=>b.map(O=>({id:O.id,addonId:O.addonId,name:O.name,enabled:O.enabled,status:z6(O),deviceCount:y.get(O.addonId)??0})),[b,y]),v=o.get(ts),N=q(O=>{const I=new URLSearchParams(window.location.search);I.get(ts)===O?I.delete(ts):I.set(ts,O);const _=I.toString(),R=`${window.location.pathname}${_?`?${_}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",R),window.dispatchEvent(new PopStateEvent("popstate"))},[]),k=q(O=>t(`/integrations/${O}`),[t]),S=q(O=>x.get(O)??null,[x]),M=q(O=>r(cn,{type:O,size:"sm"}),[]),P=q(O=>t(`/devices/${String(O)}`),[t]),A=q(O=>r(io,{devices:g,trpc:n.trpcClient,forceAddon:O,urlScope:"nested",lsKey:`integrations:nested:${O}`,resolveIntegrationIcon:M,resolveParent:S,onNavigate:P}),[g,n.trpcClient,M,S,P]),z=q(()=>{f(),h()},[f,h]),D=d||m,T=b.length>0;return u(Rt,{icon:ed,title:e("nav.integrations","Integrations"),actions:u(ge,{children:[r("button",{onClick:z,disabled:D,className:"flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",title:"Refresh",children:r(ut,{className:W("h-3.5 w-3.5",D&&"animate-spin")})}),u("button",{onClick:i,className:"flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm",children:[r(wt,{className:"h-3.5 w-3.5"}),"New Integration"]})]}),children:[D&&r("div",{className:"space-y-2",children:[1,2,3].map(O=>r("div",{className:"h-12 rounded-lg border border-border bg-surface animate-pulse"},O))}),!D&&!T&&u("div",{className:"flex flex-col items-center py-20 text-foreground-subtle",children:[r("p",{className:"text-sm",children:"No integrations configured."}),r("p",{className:"text-xs mt-1",children:'Click "New Integration" to connect cameras and devices.'})]}),!D&&T&&r(R6,{integrations:w,expandedAddonId:v,onToggleExpand:N,onOpenSettings:k,renderExpanded:A}),r(T6,{open:s,onClose:l})]})}function By(e){const t=[];for(const n of e)n.type==="probe"&&t.push(n.key),n.type==="group"&&"fields"in n&&t.push(...By(n.fields));return t}function F6(e,t,n){const[o,s]=$("idle"),[a,i]=$({}),l=U(()=>{const p=[];for(const m of e.sections)p.push(...By(m.fields));return p},[e]),c=l.length>0&&n!==void 0,d=q(p=>{i(m=>{if(!m[p])return m;const h={...m};return delete h[p],h})},[]),f=q(async()=>{if(!n)return;const p=l.filter(b=>{const x=t[b];return x!=null&&String(x).trim()!==""});if(p.length===0)return;s("testing");const m={};for(const b of p)m[b]={status:"probing"};i(m);const h=await Promise.allSettled(p.map(async b=>{try{const x=await n(b,t[b]);return{key:b,result:x}}catch(x){const w={status:"error",error:x instanceof Error?x.message:String(x)};return{key:b,result:w}}})),g={};for(const b of h)if(b.status==="fulfilled"){const{key:x,result:y}=b.value;g[x]={status:y.status==="ok"?"ok":"error",result:y}}i(g),s("idle")},[n,l,t]);return{testAllStatus:o,hasProbeFields:c,probeResults:a,handleTestAll:f,clearProbeResult:d}}function Fy(e){const t=[];for(const n of e)"required"in n&&n.required===!0&&"key"in n&&n.key&&t.push(n.key),n.type==="group"&&"fields"in n&&t.push(...Fy(n.fields));return t}function mi(e){return e==null?!0:typeof e=="string"?e.trim()==="":!1}function cl(e,t={}){for(const n of e){if(n.type==="group"&&"fields"in n){cl(n.fields,t);continue}"key"in n&&n.key&&"default"in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function dp(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function j6({open:e,integrationId:t,addonId:n,onClose:o}){const{t:s}=Ot(),a=ke(),[i,l]=$({}),[c,d]=$(!1),[f,p]=$(null),[m,h]=$(dp),g=Dg({addonId:n,type:st.Camera},{enabled:e}),b=g.data??null;Z(()=>{if(e){const I=b?cl(b.sections.flatMap(L=>L.fields)):{};l(I),h(dp()),d(!1),p(null)}},[e,t,b]);const x=U(()=>({...i,_probeRequestId:m}),[i,m]),y=Lg({onSuccess:()=>{a.invalidateQueries({queryKey:[["deviceManager"]]})}}),w=bc(),v=q(async(I,L)=>{d(!0);const _=await w.mutateAsync({addonId:n,type:st.Camera,key:I,value:L,formValues:x});return _.status==="ok"&&_.suggestedValues&&l(R=>{let B=!1;const F={...R};for(const[j,H]of Object.entries(_.suggestedValues??{}))mi(R[j])&&!mi(H)&&(F[j]=H,B=!0);return B?F:R}),_},[w,n,x]),{testAllStatus:N,hasProbeFields:k,probeResults:S,handleTestAll:M,clearProbeResult:P}=F6(b??{sections:[]},i,v);async function A(I){p(null);try{if(await y.mutateAsync({addonId:n,type:st.Camera,config:i}),I){const L=b?cl(b.sections.flatMap(_=>_.fields)):{};l(L)}else o()}catch(L){p(L instanceof Error?L.message:String(L))}}if(!e)return null;const D=Fy((b?.sections??[]).flatMap(I=>I.fields)).filter(I=>mi(i[I])),T=D.length===0,O=!g.isLoading&&(g.isError||b===null);return u("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[r("div",{className:"absolute inset-0 bg-black/60",onClick:o}),u("div",{className:"relative z-10 flex w-full max-w-2xl flex-col max-h-[90vh] rounded-xl border border-border bg-background shadow-2xl",children:[u("div",{className:"flex items-center justify-between border-b border-border px-5 py-4 shrink-0",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:s("integrations.addDevice")}),r("button",{onClick:o,className:"rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:r(Ve,{className:"h-4 w-4"})})]}),r("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-3",children:g.isLoading?r("div",{className:"flex items-center justify-center py-8",children:r(Ae,{className:"h-5 w-5 animate-spin text-primary"})}):O?u("div",{className:"flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3",children:[r(bt,{className:"h-4 w-4 text-destructive mt-0.5 shrink-0"}),u("div",{className:"space-y-1",children:[r("p",{className:"text-xs font-medium text-destructive",children:"Provider unavailable"}),u("p",{className:"text-xs text-foreground-subtle",children:["The addon ",r("span",{className:"font-mono",children:n})," is not ready or does not support manual device creation. Check that the integration is online and try again."]})]})]}):r(kn,{schema:b,values:i,onChange:l,onTestField:v,probeResults:S,onClearProbe:P})}),!O&&!g.isLoading&&u("div",{className:"border-t border-border bg-surface/50 shrink-0",children:[u("button",{type:"button",onClick:()=>d(I=>!I),className:"flex w-full items-center justify-between px-5 py-2 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:[u("span",{className:"flex items-center gap-2",children:[r(Xe,{className:"h-3.5 w-3.5"}),"Test logs",r("span",{className:"font-mono text-[9px] opacity-60",children:m.slice(0,14)})]}),r(vt,{className:`h-3.5 w-3.5 transition-transform ${c?"rotate-180":""}`})]}),c&&r("div",{className:"border-t border-border max-h-64 overflow-hidden",children:r(Wt,{addonId:n,requestId:m,limit:50,maxHeight:"max-h-64",showFilters:!1,showScope:!1,className:"border-0 rounded-none"})})]}),!O&&!g.isLoading&&(f||D.length>0)&&r("div",{className:"border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0",children:u("div",{className:"flex items-start gap-2",children:[r(bt,{className:"h-3.5 w-3.5 text-destructive mt-0.5 shrink-0"}),r("p",{className:"text-[11px] text-destructive",children:f||`Required: ${D.join(", ")}`})]})}),u("div",{className:"flex items-center justify-between border-t border-border px-5 py-3 shrink-0",children:[u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:o,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors",children:s("integrations.cancel")}),!O&&k&&u("button",{type:"button",onClick:M,disabled:N==="testing",className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:[N==="testing"?r(Ae,{className:"h-3.5 w-3.5 animate-spin"}):r(Vn,{className:"h-3.5 w-3.5"}),"Test All"]})]}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>A(!0),disabled:O||!T||y.isPending,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:s("integrations.saveAndNew")}),r("button",{onClick:()=>A(!1),disabled:O||!T||y.isPending,className:"rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:y.isPending?s("integrations.saving"):s("integrations.save")})]})]})]})]})}function H6(){const{t:e}=Ot(),{integrationId:t}=Hc(),n=ke(),o=Je(),s=Le(),[a,i]=$(!1),[l,c]=$(!1),[d,f]=$(!1),[p,m]=$(!1),{data:h,isLoading:g}=Tg({id:t??""},{enabled:!!t}),{data:b}=uc({addonId:h?.addonId??"",nodeId:"hub"},{enabled:!!h?.addonId}),x=b!=null&&Array.isArray(b.sections)&&b.sections.some(T=>T.fields.length>0),{data:y}=tr({},{refetchInterval:5e3}),w=[["integrations","get"],{input:{id:t??""},type:"query"}],v=zg({onMutate:async T=>{await n.cancelQueries({queryKey:w});const O=n.getQueryData(w);return O!=null&&n.setQueryData(w,{...O,enabled:T.enabled}),{previous:O}},onError:(T,O,I)=>{const L=I;L?.previous!=null&&n.setQueryData(w,L.previous)},onSettled:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),N=Bg({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]}),f(!1),o("/integrations")}}),k=sa({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),S=U(()=>y??[],[y]),M=U(()=>{const T=new Map;for(const O of S)T.set(O.id,{id:O.id,name:O.name??O.stableId??`#${String(O.id)}`});return T},[S]),P=q(T=>M.get(T)??null,[M]),A=q(T=>r(cn,{type:T,size:"sm"}),[]),z=q(T=>o(`/devices/${String(T)}`),[o]),D=U(()=>{const T=h?.addonId;if(!T)return 0;let O=0;for(const I of S)I.addonId!==T||I.parentDeviceId!==null&&I.parentDeviceId!==void 0&&I.role||(O+=1);return O},[S,h?.addonId]);return g?u("div",{className:"p-6",children:[r("div",{className:"h-16 rounded-lg bg-surface animate-pulse mb-4"}),r("div",{className:"h-40 rounded-lg bg-surface animate-pulse"})]}):h?u("div",{className:"p-6 space-y-5",children:[r(Yl,{items:[{label:"Integrations",onClick:()=>o("/integrations")},{label:h.name}]}),u("div",{className:"flex items-center justify-between",children:[u("div",{className:"flex items-center gap-3",children:[r("img",{src:`/api/addon-assets/${h.addonId}/assets/icon.svg`,alt:"",className:"h-8 w-8 rounded-lg",onError:T=>{T.target.style.display="none"}}),u("div",{children:[r("h1",{className:"text-lg font-semibold text-foreground",children:h.name}),u("p",{className:"text-[11px] text-foreground-subtle mt-0.5",children:[h.addonId," · ",D," ",e("integrations.devices")]})]})]}),u("div",{className:"flex items-center gap-3",children:[u("div",{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${v.isPending?"opacity-60":""} ${h.enabled?"border-success/30 bg-success/5":"border-border bg-surface"}`,title:e("integrations.toggleHint",{defaultValue:"Click to toggle"}),children:[r(ql,{checked:h.enabled,onCheckedChange:T=>v.mutate({id:t,enabled:T}),disabled:v.isPending,"aria-label":h.enabled?"Disable integration":"Enable integration"}),r("span",{className:`text-[11px] font-medium ${h.enabled?"text-success":"text-foreground-subtle"}`,children:h.enabled?"Enabled":"Disabled"}),v.isPending&&r(Ae,{className:"h-3 w-3 animate-spin text-foreground-subtle"})]}),x&&u("button",{onClick:()=>c(!0),className:"flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:[r(Nt,{className:"h-3 w-3"}),e("integrations.config")]}),u("button",{onClick:()=>m(!0),className:"flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",title:e("integrations.logs",{defaultValue:"View logs"}),children:[r(Xe,{className:"h-3 w-3"}),e("integrations.logs",{defaultValue:"Logs"})]}),r(Ex,{label:"Restart",icon:ut,title:`Restart "${h.name}"?`,description:`Restarting the addon will briefly disconnect every device backed by it (${D} active). Streams will reconnect automatically.`,confirmLabel:"Restart",triggerVariant:"outline",confirmVariant:"danger",disabled:k.isPending,action:()=>k.mutateAsync({addonId:h.addonId})}),u("button",{onClick:()=>f(!0),className:"flex items-center gap-1.5 rounded-lg border border-danger bg-danger/10 px-3 py-1.5 text-[11px] font-medium text-danger hover:bg-danger hover:text-background transition-colors",title:e("integrations.delete",{defaultValue:"Delete integration"}),children:[r(Ge,{className:"h-3 w-3"}),e("integrations.delete",{defaultValue:"Delete"})]})]})]}),r(io,{devices:S,trpc:s.trpcClient,defaultView:"cards",forceAddon:h.addonId,urlScope:"root",lsKey:`integration-detail:${h.addonId}`,resolveIntegrationIcon:A,resolveParent:P,onNavigate:z}),r("button",{onClick:()=>i(!0),className:"fixed bottom-6 right-6 flex h-12 w-12 items-center justify-center rounded-full bg-primary shadow-lg shadow-primary/30 hover:shadow-primary/40 transition-shadow",title:e("integrations.addDevice"),children:r(wt,{className:"h-5 w-5 text-primary-foreground"})}),a&&t&&r(j6,{open:a,integrationId:t,addonId:h.addonId,onClose:()=>i(!1)}),l&&r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>c(!1),children:u("div",{className:"rounded-xl border border-border bg-surface p-6 shadow-xl w-80",onClick:T=>T.stopPropagation(),children:[r("h2",{className:"text-sm font-semibold text-foreground mb-2",children:e("integrations.providerConfig")}),r("p",{className:"text-[11px] text-foreground-subtle",children:e("integrations.configComingSoon")}),r("button",{onClick:()=>c(!1),className:"mt-4 w-full rounded-lg bg-primary px-3 py-1.5 text-[11px] text-primary-foreground hover:bg-primary/90 transition-colors",children:"Close"})]})}),p&&r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onClick:()=>m(!1),children:u("div",{className:"flex flex-col rounded-xl border border-border bg-surface shadow-xl w-full max-w-5xl h-[80vh]",onClick:T=>T.stopPropagation(),children:[u("div",{className:"flex items-center justify-between border-b border-border px-4 py-2.5",children:[u("div",{className:"flex items-center gap-2 min-w-0",children:[r(Xe,{className:"h-4 w-4 text-primary shrink-0"}),r("h2",{className:"text-sm font-semibold text-foreground truncate",children:h.name}),u("span",{className:"text-[10px] text-foreground-subtle font-mono truncate",children:[h.addonId,t?` · ${t}`:""]})]}),r("button",{onClick:()=>m(!1),className:"flex h-7 w-7 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors","aria-label":"Close logs",children:r(Ve,{className:"h-4 w-4"})})]}),r("div",{className:"flex-1 min-h-0 overflow-hidden",children:r(Wt,{addonId:h.addonId,limit:200,maxHeight:"max-h-full",showScope:!1,className:"h-full border-0 rounded-none"})})]})}),d&&r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>!N.isPending&&f(!1),children:u("div",{className:"rounded-xl border border-border bg-background p-5 shadow-2xl w-96 space-y-3",onClick:T=>T.stopPropagation(),children:[u("div",{className:"flex items-start gap-3",children:[r("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-danger/10 shrink-0",children:r(bt,{className:"h-4 w-4 text-danger"})}),u("div",{className:"min-w-0",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:e("integrations.deleteTitle",{defaultValue:"Delete integration?"})}),r("p",{className:"mt-1 text-[11px] text-foreground-subtle",children:e("integrations.deleteWarning",{defaultValue:'This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.',name:h.name,count:D})})]})]}),N.error&&r("div",{className:"rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger",children:N.error instanceof Error?N.error.message:String(N.error)}),u("div",{className:"flex items-center justify-end gap-2 pt-1",children:[r("button",{onClick:()=>f(!1),disabled:N.isPending,className:"rounded-lg border border-border px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:e("integrations.cancel",{defaultValue:"Cancel"})}),r("button",{onClick:()=>N.mutate({id:t}),disabled:N.isPending,className:"inline-flex items-center gap-1.5 rounded-lg bg-danger px-3 py-1.5 text-[11px] font-medium text-background hover:bg-danger/90 transition-colors disabled:opacity-60 disabled:cursor-not-allowed",children:N.isPending?u(ge,{children:[r(Ae,{className:"h-3 w-3 animate-spin"}),e("integrations.deleting",{defaultValue:"Deleting…"})]}):u(ge,{children:[r(Ge,{className:"h-3 w-3"}),e("integrations.confirmDelete",{defaultValue:"Delete integration"})]})})]})]})})]}):u("div",{className:"flex flex-col items-center justify-center py-20 px-6 text-center gap-4",children:[r("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10",children:r(XL,{className:"h-6 w-6 text-foreground-subtle"})}),u("div",{className:"space-y-1 max-w-sm",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:e("integrations.integrationNotFound",{defaultValue:"Integration not found"})}),r("p",{className:"text-[11px] text-foreground-subtle",children:e("integrations.integrationNotFoundHint",{defaultValue:'The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.',id:t??""})})]}),u("button",{onClick:()=>o("/integrations"),className:"inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors",children:[r(ey,{className:"h-3 w-3"}),e("integrations.backToList",{defaultValue:"Back to integrations"})]})]})}function V6({label:e,color:t,title:n,style:o}){return u("div",{className:"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 z-10 group cursor-pointer",style:o,title:n,children:[r("div",{className:"h-2.5 w-2.5 rounded-full border-2 border-background shadow-sm transition-transform group-hover:scale-150",style:{backgroundColor:t}}),n&&r("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-1.5 hidden group-hover:block z-20 pointer-events-none",children:u("div",{className:"bg-surface border border-border rounded px-2 py-1 text-[10px] text-foreground whitespace-nowrap shadow-lg",children:[r("span",{className:"inline-block h-1.5 w-1.5 rounded-full mr-1 align-middle",style:{backgroundColor:t}}),e]})})]})}const hi=36e5;function q6(e){return String(e).padStart(2,"0")}function U6(e){const t=new Date(e);return`${q6(t.getHours())}:00`}function Q6({startMs:e,endMs:t,segments:n,events:o,playheadMs:s,onSeek:a}){const i=ne(null),l=t-e,c=q(h=>Math.max(0,Math.min(100,(h-e)/l*100)),[e,l]);function d(h){if(!i.current)return;const g=i.current.getBoundingClientRect(),b=Math.max(0,Math.min(1,(h.clientX-g.left)/g.width));a(Math.round(e+b*l))}const f=[],p=Math.floor(e/hi),m=Math.ceil(t/hi);for(let h=p;h<=m;h++){const g=h*hi;g<e||g>t||f.push({percent:c(g),label:U6(g)})}return u("div",{className:"select-none",children:[r("div",{className:"relative h-5 mb-1",children:f.map(({percent:h,label:g})=>r("span",{className:"absolute -translate-x-1/2 text-[10px] text-foreground-subtle",style:{left:`${h}%`},children:g},g))}),u("div",{ref:i,className:"relative h-8 rounded bg-surface-hover cursor-pointer overflow-hidden border border-border",onClick:d,onPointerMove:h=>{h.buttons===1&&d(h)},children:[n.map((h,g)=>{const b=c(h.startMs),x=c(h.endMs)-b;return r("div",{className:"absolute top-1 bottom-1 rounded-sm bg-success/60",style:{left:`${b}%`,width:`${Math.max(x,.1)}%`}},g)}),o.map(h=>r(V6,{label:h.label,color:h.color,title:`${h.label} — ${new Date(h.timestampMs).toLocaleTimeString()}`,style:{left:`${c(h.timestampMs)}%`}},h.id)),r("div",{className:"absolute top-0 bottom-0 w-0.5 bg-danger z-20 pointer-events-none",style:{left:`${c(s)}%`},children:r("div",{className:"absolute -top-0.5 left-1/2 -translate-x-1/2 w-2.5 h-2.5 bg-danger rotate-45"})})]})]})}const up={person:"#f59e0b",vehicle:"#3b82f6",car:"#3b82f6",face:"#a855f7",plate:"#ec4899",animal:"#10b981",motion:"#ef4444",unknown:"#6b7280"};function dl(e){return up[e.toLowerCase()]??up.unknown}function K6(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function G6(e){return new Date(e).toISOString().slice(0,10)}function W6(e){return new Date(e+"T00:00:00").getTime()}function Y6(e){return[{startMs:e+0*36e5,endMs:e+4*36e5},{startMs:e+6*36e5,endMs:e+10*36e5},{startMs:e+12*36e5,endMs:e+16*36e5},{startMs:e+18*36e5,endMs:e+23*36e5}]}function Z6(e){const t=["person","vehicle","face","motion"];return Array.from({length:24},(n,o)=>({id:`placeholder-${o}`,timestampMs:e+Math.floor(Math.random()*24*36e5),label:t[o%t.length],color:dl(t[o%t.length])})).sort((n,o)=>n.timestampMs-o.timestampMs)}function X6(){const{t:e}=Ot(),t=K6(new Date),[n,o]=$(t),[s,a]=$(null),[i,l]=$(t+12*36e5),c=n,d=n+24*36e5,{data:f,isLoading:p}=tr({},{staleTime:3e4}),m=f??[],h=U(()=>m.filter(N=>{const k=N.type.toLowerCase();return k==="camera"||k.includes("camera")||N.features.some(S=>S.toLowerCase().includes("video")||S.toLowerCase().includes("stream"))}).map(N=>({id:N.id,name:N.name??N.stableId})),[m]),g=s??h[0]?.id??null,{data:b}=Wn({queryKey:["events",g,c],queryFn:()=>Promise.resolve(null),enabled:!!g,staleTime:6e4}),x=U(()=>{const v=Array.isArray(b)?b:(()=>{const k=_d(b)?.events;return Array.isArray(k)?k:[]})();return v.length===0?g?Z6(c):[]:v.flatMap((N,k)=>{const S=_d(N);if(!S)return[];const M=String(S.class??S.type??S.label??"unknown").toLowerCase(),P=typeof S.timestamp=="number"?S.timestamp:c;return[{id:String(S.id??k),timestampMs:P,label:M,color:dl(M)}]})},[b,g,c]),y=U(()=>g?Y6(c):[],[g,c]);function w(v){o(N=>N+v*24*36e5),l(N=>N+v*24*36e5)}return u("div",{className:"flex flex-col h-full p-6 gap-5 overflow-hidden",children:[u("div",{className:"flex items-center justify-between gap-4 shrink-0",children:[r("h1",{className:"text-lg font-semibold text-foreground",children:e("nav.timeline","Timeline")}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>w(-1),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",children:r(Yc,{className:"h-4 w-4"})}),u("div",{className:"relative flex items-center",children:[r(ny,{className:"absolute left-2 h-3.5 w-3.5 text-foreground-subtle pointer-events-none"}),r("input",{type:"date",value:G6(n),onChange:v=>{if(v.target.value){const N=W6(v.target.value);o(N),l(N+12*36e5)}},className:"rounded-lg border border-border bg-surface pl-7 pr-3 py-1.5 text-xs text-foreground focus:outline-none focus:border-primary/50"})]}),r("button",{onClick:()=>w(1),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",disabled:n>=t,children:r(It,{className:"h-4 w-4"})})]})]}),u("div",{className:"flex gap-1.5 shrink-0 overflow-x-auto pb-1",children:[p&&r("div",{className:"h-8 w-48 rounded-lg bg-surface animate-pulse"}),!p&&h.length===0&&r("span",{className:"text-xs text-foreground-subtle",children:"No cameras found"}),h.map(v=>{const N=v.id===g;return r("button",{onClick:()=>a(v.id),className:`shrink-0 rounded-lg px-3 py-1.5 text-[12px] font-medium transition-all border ${N?"bg-primary/12 text-primary border-primary/30":"bg-surface text-foreground-subtle border-border hover:bg-surface-hover hover:text-foreground"}`,children:v.name},v.id)})]}),u("div",{className:"relative w-full aspect-video rounded-xl border border-border bg-black shrink-0 overflow-hidden max-h-[45vh]",children:[u("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 text-foreground-subtle",children:[r(Xr,{className:"h-12 w-12 opacity-20"}),r("p",{className:"text-sm opacity-50",children:g?`${h.find(v=>v.id===g)?.name??g} — seek to play`:"Select a camera"})]}),r("div",{className:"absolute top-3 left-3 rounded bg-black/60 px-2 py-1 text-[11px] text-white font-mono",children:new Date(i).toLocaleTimeString()})]}),u("div",{className:"rounded-xl border border-border bg-surface px-4 pt-3 pb-4 shrink-0",children:[u("div",{className:"flex flex-wrap items-center gap-4 mb-3",children:[r("span",{className:"text-[10px] font-semibold text-foreground-subtle uppercase tracking-wider",children:"Timeline"}),u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"inline-block h-2 w-4 rounded-sm bg-success/60"}),r("span",{className:"text-[10px] text-foreground-subtle",children:"Recording"})]}),Array.from(new Set(x.map(v=>v.label))).slice(0,5).map(v=>u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{backgroundColor:dl(v)}}),r("span",{className:"text-[10px] text-foreground-subtle capitalize",children:v})]},v))]}),g?r(Q6,{startMs:c,endMs:d,segments:y,events:x,playheadMs:i,onSeek:l}):r("div",{className:"h-8 rounded bg-surface-hover flex items-center justify-center text-xs text-foreground-subtle",children:"Select a camera to view timeline"})]})]})}function J6({selectedNodeId:e,onSelect:t,refreshToken:n}){const{data:o}=An(void 0,{staleTime:3e4}),{data:s}=ia(void 0,{staleTime:3e4}),a=new Map;for(const d of s??[])a.set(d.agentNodeId,(a.get(d.agentNodeId)??0)+1);const i=o??[],l=i.filter(d=>d.isOnline).length,c=i.filter(d=>!d.isOnline).length;return u("div",{className:"flex flex-col h-full",children:[u("button",{type:"button",onClick:()=>t(to),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===to?"bg-primary/10 text-primary":"text-foreground hover:bg-surface-hover"}`,children:[r(yr,{className:"h-4 w-4 flex-shrink-0"}),u("div",{className:"min-w-0 flex-1",children:[r("div",{className:"text-xs font-semibold truncate",children:"Cluster"}),r("div",{className:"text-[10px] text-foreground-subtle",children:"Balancer + failover + assignments"})]})]}),r("div",{className:"flex-1 overflow-y-auto",children:i.map(d=>{const f=e===d.id,p=a.get(d.id)??0,m=d.isHub?ln:dt;return u("button",{type:"button",onClick:()=>t(d.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${f?"bg-primary/10 text-primary":"text-foreground hover:bg-surface-hover"}`,children:[r(m,{className:"h-4 w-4 flex-shrink-0"}),u("div",{className:"min-w-0 flex-1",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-xs font-semibold truncate",children:d.name}),d.isHub&&r("span",{className:"text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5",children:"hub"}),!d.isOnline&&r("span",{className:"h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0"}),d.isOnline&&r("span",{className:"h-1.5 w-1.5 rounded-full bg-success flex-shrink-0"})]}),u("div",{className:"text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5",children:[u("span",{children:[d.cpuCores," cores"]}),r("span",{children:"•"}),u("span",{children:[Math.round(d.memoryMB/1024)," GB"]}),p>0&&u(ge,{children:[r("span",{children:"•"}),u("span",{className:"inline-flex items-center gap-0.5 text-foreground",children:[r(Ny,{className:"h-2.5 w-2.5"}),p]})]})]})]})]},d.id)})}),u("div",{className:"px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between",children:[u("span",{children:[l," online"]}),c>0&&u("span",{className:"text-destructive",children:[c," offline"]})]})]})}function eO({nodeId:e,refreshToken:t}){const{data:n}=An(void 0,{staleTime:3e4}),o=n?.find(i=>i.id===e),a=Pr("pipeline.runner-load-snapshot",i=>i.nodeId===e)?.load??null;return o?u("div",{className:"px-6 py-4 border-b border-border",children:[u("div",{className:"flex items-center gap-2 mb-1",children:[r("h2",{className:"text-base font-semibold text-foreground",children:o.name}),o.isOnline?r("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success",children:"online"}):r("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:"offline"}),o.isHub&&r("span",{className:"text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5",children:"hub"})]}),u("div",{className:"text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap",children:[r("span",{children:o.cpuModel??"CPU"}),r("span",{children:"•"}),u("span",{children:[o.cpuCores," cores"]}),r("span",{children:"•"}),u("span",{children:[Math.round(o.memoryMB/1024)," GB"]}),a&&u(ge,{children:[r("span",{children:"•"}),u("span",{children:[a.attachedCameras," cameras (",a.activeCameras," active)"]}),r("span",{children:"•"}),u("span",{children:[a.avgInferenceTimeMs.toFixed(0),"ms avg inference"]}),r("span",{children:"•"}),u("span",{children:["queue ",a.queueDepthTotal]}),a.hardware.hasGpu&&u(ge,{children:[r("span",{children:"•"}),r("span",{className:"text-success",children:"GPU"})]})]})]})]}):r("div",{className:"px-6 py-4 border-b border-border",children:u("div",{className:"text-xs text-foreground-subtle",children:["Node not found: ",e]})})}function jy({refreshToken:e,nodeId:t}){const[n,o]=$(new Map),{nodes:s}=Er();ct("pipeline.camera-metrics-snapshot",p=>{const m=p.data;typeof m?.deviceId=="number"&&o(h=>{const g=new Map(h);return g.set(m.deviceId,m),g})});const{data:a}=Cb(void 0,{staleTime:5e3}),i=U(()=>{const p=new Map;for(const m of a??[])p.set(m.nodeId,m.deviceCount);return p},[a]),l=U(()=>{const p=new Map,m=Date.now()-3e4;for(const h of n.values()){if(h.timestamp<m)continue;const g=h.nodeId??"hub",b=p.get(g)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};b.attachedCameras++,h.metrics.phase==="active"&&b.activeCameras++,b.totalFps+=h.metrics.actualFps,b.totalInferenceWeighted+=h.metrics.avgInferenceTimeMs,b.queueDepth+=h.metrics.queueDepth,p.set(g,b)}return p},[n]),c=U(()=>{const p=new Map;for(const m of s)p.set(m.id,m.shortName);return p},[s]),d=U(()=>{let p=0,m=0,h=0,g=0,b=0;for(const y of l.values())p+=y.attachedCameras,m+=y.activeCameras,h+=y.totalFps,g+=y.totalInferenceWeighted,b+=y.queueDepth;const x=p>0?g/p:0;return{totalAgents:s.length,onlineAgents:s.filter(y=>y.isOnline).length,attachedCameras:p,activeCameras:m,avgInferenceTimeMs:x,queueDepth:b,totalFps:h}},[l,s]);if(t){const p=l.get(t);return u("div",{className:"@container/liveload",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-2",children:"Live load"}),u("div",{className:"grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3",children:[r(jt,{label:"FPS",value:p?p.totalFps.toFixed(1):"—"}),r(jt,{label:"Cameras",value:p?`${p.activeCameras}/${p.attachedCameras}`:"—"}),r(jt,{label:"Avg infer ms",value:p&&p.attachedCameras>0?(p.totalInferenceWeighted/p.attachedCameras).toFixed(0):"—"}),r(jt,{label:"Queue",value:p?String(p.queueDepth):"—"}),r(jt,{label:"Audio",value:String(i.get(t)??"—")})]})]})}const f=[...l.entries()].sort(([p],[m])=>p==="hub"?-1:m==="hub"?1:p.localeCompare(m));return u("div",{className:"@container/liveload",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-2",children:"Live load"}),u("div",{className:"grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3",children:[r(jt,{label:"Total agents",value:`${d.onlineAgents}/${d.totalAgents}`}),r(jt,{label:"Cameras",value:`${d.activeCameras}/${d.attachedCameras}`}),r(jt,{label:"Total FPS",value:d.totalFps.toFixed(1)}),r(jt,{label:"Avg inference ms",value:d.avgInferenceTimeMs.toFixed(0)}),r(jt,{label:"Queue depth",value:String(d.queueDepth)})]}),r("div",{className:"rounded-lg border border-border overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[480px]",children:[r("thead",{className:"bg-surface",children:u("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[r("th",{className:"text-left px-3 py-2",children:"Agent"}),r("th",{className:"text-right px-3 py-2",children:"FPS"}),r("th",{className:"text-right px-3 py-2",children:"Cameras"}),r("th",{className:"text-right px-3 py-2",children:"Inference ms"}),r("th",{className:"text-right px-3 py-2",children:"Queue"}),r("th",{className:"text-right px-3 py-2",children:"Audio"})]})}),u("tbody",{children:[f.map(([p,m])=>u("tr",{className:"border-t border-border",children:[r("td",{className:"px-3 py-2 text-foreground font-medium",children:c.get(p)??p}),r("td",{className:"px-3 py-2 text-right text-foreground",children:m.totalFps.toFixed(1)}),r("td",{className:"px-3 py-2 text-right text-foreground",children:m.attachedCameras}),r("td",{className:"px-3 py-2 text-right text-foreground",children:m.attachedCameras>0?(m.totalInferenceWeighted/m.attachedCameras).toFixed(0):"—"}),r("td",{className:"px-3 py-2 text-right text-foreground",children:m.queueDepth}),r("td",{className:"px-3 py-2 text-right text-foreground",children:i.get(p)??"—"})]},p)),f.length===0&&r("tr",{children:r("td",{colSpan:6,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:"No camera metrics received yet"})})]})]})})]})}function jt({label:e,value:t}){return u("div",{className:"rounded-lg border border-border bg-surface/60 p-3",children:[r("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle mb-1",children:e}),r("div",{className:"text-lg font-semibold text-foreground",children:t})]})}function Hy(e){return tr({addonId:e})}function tO(e){return Hn({deviceId:e},{enabled:Number.isFinite(e)})}const nO=3e4,rO=2e3;function Vy(e){const t=ne(0);return t.current===0&&(t.current=Date.now()),Sg({parentDeviceId:e},{enabled:Number.isFinite(e),staleTime:0,refetchOnMount:"always",refetchInterval:n=>{const o=n.state.data;return o&&o.length>0||Date.now()-t.current>=nO?!1:rO}})}const gi={active:!1,pinned:!1,nodeId:null,reason:""},bi=["pipeline.camera-assigned","pipeline.camera-unassigned","pipeline.camera-updated","agent.online","agent.offline"],oO={pipeline:dt,decoder:Xr,audio:rl},pp={pipeline:"Pipeline",decoder:"Decoder",audio:"Audio"};function qy({mode:e,nodeId:t,compact:n=!1}){if(e==="agent"&&!t)throw new Error('CameraAssignmentsTable: nodeId is required when mode === "agent"');const o=ke(),[s,a]=$(null),[i,l]=$(null),[c,d]=$(new Map);xt(["pipelineOrchestrator","getPipelineAssignments"],bi),xt(["pipelineOrchestrator","getDecoderAssignments"],bi),xt(["pipelineOrchestrator","getAudioAssignments"],bi);const{data:f}=ia(void 0,{staleTime:3e4}),{data:p}=Nb(void 0,{staleTime:3e4}),{data:m}=Mb(void 0,{staleTime:3e4}),{nodes:h}=Er(),{data:g}=Hy();ct("pipeline.camera-metrics-snapshot",D=>{const T=D.data;typeof T.deviceId=="number"&&d(O=>{const I=new Map(O);return I.set(T.deviceId,T),I})}),Z(()=>{if(c.size===0)return;const D=setInterval(()=>{d(T=>{const O=Date.now()-1e4;let I=!1;const L=new Map(T);for(const[_,R]of T)R.timestamp<O&&(L.delete(_),I=!0);return I?L:T})},5e3);return()=>clearInterval(D)},[c.size]);const b=U(()=>{const D=new Map;for(const T of g??[])D.set(T.id,T.name);return D},[g]),x=U(()=>{const D=new Map,T=I=>{const L=D.get(I);if(L)return L;const _={deviceId:I,deviceName:b.get(I)??`Device ${I}`,pipeline:gi,decoder:gi,audio:gi};return D.set(I,_),_};for(const I of f??[]){const L=T(I.deviceId);D.set(I.deviceId,{...L,pipeline:{active:e==="cluster"?!0:I.agentNodeId===t,pinned:I.pinned,nodeId:I.agentNodeId,reason:I.reason??""}})}for(const I of p??[]){const L=T(I.deviceId);D.set(I.deviceId,{...L,decoder:{active:e==="cluster"?!0:I.decoderNodeId===t,pinned:I.pinned,nodeId:I.decoderNodeId,reason:I.reason??""}})}for(const I of m??[]){const L=T(I.deviceId);D.set(I.deviceId,{...L,audio:{active:e==="cluster"?!0:I.nodeId===t,pinned:I.pinned,nodeId:I.nodeId,reason:"capacity"}})}let O=[...D.values()];return e==="agent"&&(O=O.filter(I=>I.pipeline.active||I.decoder.active||I.audio.active)),O.sort((I,L)=>I.deviceId-L.deviceId),O},[f,p,m,b,e,t]),y=U(()=>(h??[]).filter(D=>D.isOnline).map(D=>({id:D.id,name:D.name})),[h]),w=()=>{o.invalidateQueries({queryKey:[["pipelineOrchestrator","getPipelineAssignments"]]}),o.invalidateQueries({queryKey:[["pipelineOrchestrator","getDecoderAssignments"]]}),o.invalidateQueries({queryKey:[["pipelineOrchestrator","getAudioAssignments"]]})},v=mb({onSuccess:w}),N=hb({onSuccess:w}),k=vb({onSuccess:w}),S=wb({onSuccess:w}),M=kb({onSuccess:w}),P=Sb({onSuccess:w}),A=(D,T,O)=>{T==="pipeline"?v.mutate({deviceId:D,agentNodeId:O}):T==="decoder"?k.mutate({deviceId:D,nodeId:O}):M.mutate({deviceId:D,nodeId:O}),a(null)},z=(D,T)=>{T==="pipeline"?N.mutate({deviceId:D}):T==="decoder"?S.mutate({deviceId:D}):P.mutate({deviceId:D}),a(null)};return r("div",{className:"rounded-lg border border-border overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[640px]",children:[r("thead",{className:"bg-surface",children:u("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[!n&&r("th",{className:"w-6"}),r("th",{className:"text-left px-3 py-2 align-middle",children:"Camera"}),r("th",{className:"text-left px-3 py-2 align-middle",children:"Pipeline"}),r("th",{className:"text-left px-3 py-2 align-middle",children:"Decoder"}),r("th",{className:"text-left px-3 py-2 align-middle",children:"Audio"}),r("th",{className:"text-left px-3 py-2 align-middle",children:"Status"})]})}),u("tbody",{children:[x.map(D=>{const T=c.get(D.deviceId),O=i===D.deviceId;return u(El.Fragment,{children:[u("tr",{className:"border-t border-border align-middle relative",children:[!n&&r("td",{className:"px-2 py-2 align-middle",children:r("button",{type:"button",onClick:()=>l(O?null:D.deviceId),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle","aria-label":O?"Collapse broker details":"Expand broker details",children:O?r(vt,{className:"h-3.5 w-3.5"}):r(It,{className:"h-3.5 w-3.5"})})}),u("td",{className:"px-3 py-2 align-middle",children:[r("div",{className:"text-foreground font-medium leading-tight",children:D.deviceName}),u("div",{className:"text-[10px] text-foreground-subtle leading-tight",children:["#",D.deviceId]})]}),r(xi,{role:"pipeline",state:D.pipeline,mode:e,deviceId:D.deviceId,onlineNodes:y,isMenuOpen:s?.deviceId===D.deviceId&&s.role==="pipeline",onToggleMenu:()=>a(s?.deviceId===D.deviceId&&s.role==="pipeline"?null:{deviceId:D.deviceId,role:"pipeline"}),onCloseMenu:()=>a(null),onMove:I=>A(D.deviceId,"pipeline",I),onUnpin:()=>z(D.deviceId,"pipeline")}),r(xi,{role:"decoder",state:D.decoder,mode:e,deviceId:D.deviceId,onlineNodes:y,isMenuOpen:s?.deviceId===D.deviceId&&s.role==="decoder",onToggleMenu:()=>a(s?.deviceId===D.deviceId&&s.role==="decoder"?null:{deviceId:D.deviceId,role:"decoder"}),onCloseMenu:()=>a(null),onMove:I=>A(D.deviceId,"decoder",I),onUnpin:()=>z(D.deviceId,"decoder")}),r(xi,{role:"audio",state:D.audio,mode:e,deviceId:D.deviceId,onlineNodes:y,isMenuOpen:s?.deviceId===D.deviceId&&s.role==="audio",onToggleMenu:()=>a(s?.deviceId===D.deviceId&&s.role==="audio"?null:{deviceId:D.deviceId,role:"audio"}),onCloseMenu:()=>a(null),onMove:I=>A(D.deviceId,"audio",I),onUnpin:()=>z(D.deviceId,"audio")}),r("td",{className:"px-3 py-2 align-middle",children:r(iO,{snap:T})})]}),O&&!n&&u("tr",{className:"bg-surface/50",children:[r("td",{}),r("td",{colSpan:5,className:"px-3 py-2",children:r(at,{widgetId:"stream-broker/stream-broker-panel",host:"device-tab",deviceId:D.deviceId,instanceId:`pipeline-row/${D.deviceId}`,config:{variant:"compact",title:"Stream brokers & clients"}})})]})]},D.deviceId)}),x.length===0&&r("tr",{children:r("td",{colSpan:n?5:6,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:e==="agent"?"No cameras assigned to this node":"No cameras currently assigned"})})]})]})})}function xi({role:e,state:t,mode:n,onlineNodes:o,isMenuOpen:s,onToggleMenu:a,onCloseMenu:i,onMove:l,onUnpin:c}){const d=oO[e],f=o.filter(h=>h.id!==(t.nodeId??"")),m=(t.active||n==="cluster")&&(f.length>0||t.pinned);return u("td",{className:"px-3 py-2 align-middle relative",children:[u("div",{className:"flex items-center gap-2",children:[n==="agent"?r(sO,{state:t,Icon:d}):r(aO,{state:t,Icon:d}),r("div",{className:"ml-auto",children:m&&r("button",{type:"button",onClick:a,className:"p-1 rounded hover:bg-surface-hover","aria-label":`${pp[e]} actions`,children:r(HD,{className:"h-3 w-3 text-foreground-subtle"})})})]}),s&&m&&r(lO,{title:pp[e],targets:f,pinned:t.pinned,onMove:l,onUnpin:c,onClose:i})]})}function sO({state:e,Icon:t}){const n=e.active?yy:Do;return u("div",{className:"flex items-center gap-1.5",children:[r(n,{className:`h-3.5 w-3.5 ${e.active?"text-success":"text-foreground-subtle/50"}`}),r(t,{className:`h-3 w-3 ${e.active?"text-foreground-subtle":"text-foreground-subtle/40"}`}),e.pinned&&r(hy,{className:"h-2.5 w-2.5 text-amber-400"})]})}function aO({state:e,Icon:t}){return!e.active||!e.nodeId?u("div",{className:"flex items-center gap-1.5 text-foreground-subtle/60",children:[r(t,{className:"h-3 w-3"}),r("span",{className:"text-[10px] italic",children:"—"})]}):u("div",{className:"flex items-center gap-1.5 min-w-0",children:[r(t,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),u("div",{className:"flex flex-col leading-tight min-w-0",children:[r("span",{className:"font-mono text-[11px] text-foreground truncate",children:e.nodeId}),r("span",{className:"flex items-center gap-1 text-[10px]",children:e.pinned?u("span",{className:"inline-flex items-center gap-0.5 text-amber-400",children:[r(hy,{className:"h-2.5 w-2.5"})," manual"]}):u("span",{className:"text-foreground-subtle truncate",children:["auto · ",e.reason||"capacity"]})})]})]})}function iO({snap:e}){if(!e)return r("span",{className:"text-[10px] text-foreground-subtle italic",children:"—"});const{phase:t,actualFps:n,avgInferenceTimeMs:o,queueDepth:s,configuredFps:a}=e.metrics,i=Zn(t);return u("div",{className:"flex flex-col gap-0.5 font-mono text-[10px] tabular-nums leading-tight",children:[u("span",{className:`inline-flex items-center gap-1 ${i.textColor}`,children:[r($c,{phase:t,className:"h-2.5 w-2.5"}),r("span",{className:"font-semibold uppercase tracking-wider",children:i.label})]}),u("span",{className:"text-foreground-subtle",children:[r("span",{className:"text-foreground",children:n.toFixed(1)}),u("span",{children:["/",a.toFixed(0)," fps"]})]}),u("span",{className:"text-foreground-subtle",children:[r("span",{className:"text-foreground",children:o.toFixed(0)}),r("span",{children:" ms"}),s>0&&u("span",{className:"text-warning ml-1",children:["q",s]})]})]})}function lO({title:e,targets:t,pinned:n,onMove:o,onUnpin:s,onClose:a}){const i=ne(null);return Z(()=>{const l=c=>{i.current?.contains(c.target)||a()};return window.addEventListener("mousedown",l),()=>window.removeEventListener("mousedown",l)},[a]),u("div",{ref:i,className:"absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left",children:[r("div",{className:"px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border",children:e}),t.length>0&&r("div",{className:"py-1",children:t.map(l=>u("button",{type:"button",onClick:()=>o(l.id),className:"block w-full text-left px-3 py-1 text-[11px] text-foreground hover:bg-surface-hover",children:["Move to ",l.name]},l.id))}),n&&u("button",{type:"button",onClick:s,className:"block w-full text-left px-3 py-1.5 text-[11px] text-destructive hover:bg-destructive/10 border-t border-border",children:["Unpin ",e.toLowerCase()]}),t.length===0&&!n&&r("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle italic",children:"Already auto · no other nodes online"})]})}function cO({nodeId:e,refreshToken:t}){return u("div",{className:"space-y-6",children:[r(jy,{refreshToken:t,nodeId:e}),u("div",{children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Cameras on this node"}),u("p",{className:"text-[11px] text-foreground-subtle",children:["Checkboxes mark the roles currently running on ",e,". Use the kebab to move a role to another node or unpin it; live KPIs come from the runner snapshot stream."]})]}),r(qy,{mode:"agent",nodeId:e,compact:!0})]})}function dO(e,t){const n=Math.max(0,t-e),o=Math.floor(e/1e3),s=Math.floor(n/1e3);return`${o}s idle · ${s}s left`}function uO({nodeId:e,refreshToken:t}){const n=ke(),o=fb({onSettled:()=>{n.invalidateQueries({queryKey:["pipelineExecutor","listLoadedEngines"]})}}),{data:s}=pb({nodeId:e},{staleTime:5e3}),i=Pr("pipeline.engine-metrics-snapshot",m=>m.nodeId===e)?.engines??s??null,l=i===null;xt(["pipelineRunner","getLocalCameras"],["pipeline.camera-assigned","pipeline.camera-unassigned"]);const{data:c}=Tb({nodeId:e},{staleTime:3e4}),{values:d}=tc("pipeline.camera-metrics-snapshot",m=>m.deviceId,m=>m.nodeId===e),f=U(()=>d.filter(m=>m.metrics.phase==="active").length,[d]),p=m=>{const h=c??[];h.length>0&&!window.confirm(`${h.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||o.mutate({nodeId:e,engine:m,force:h.length>0})};return u("div",{className:"space-y-6",children:[u("div",{children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Inference engines on this node"}),u("p",{className:"text-[11px] text-foreground-subtle",children:[(i??[]).length," engine(s) resident in RAM. ",(c??[]).length," camera(s) attached, ",f," actively dispatching frames. Refreshes every 5s."]})]}),r("div",{className:"rounded-lg border border-border overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[640px]",children:[r("thead",{className:"bg-surface",children:u("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[r("th",{className:"text-left px-3 py-2 whitespace-nowrap",children:"Kind"}),r("th",{className:"text-left px-3 py-2 whitespace-nowrap",children:"Runtime / Backend / Device"}),r("th",{className:"text-left px-3 py-2",children:"Models"}),r("th",{className:"text-right px-3 py-2 whitespace-nowrap",children:"Pool PID"}),r("th",{className:"text-right px-3 py-2 whitespace-nowrap",children:"Auto-kill"}),r("th",{className:"text-right px-3 py-2 whitespace-nowrap",children:"In use"}),r("th",{className:"w-20"})]})}),u("tbody",{children:[l&&r("tr",{children:r("td",{colSpan:7,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:"Loading…"})}),!l&&(i??[]).map(m=>{const h=m.kind==="warm-override";return u("tr",{className:`border-t border-border ${h?"bg-amber-500/5":""}`,children:[r("td",{className:"px-3 py-2",children:u("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${h?"bg-amber-500/15 text-amber-400":"bg-success/15 text-success"}`,children:[h?r(GD,{className:"h-3 w-3"}):r(dt,{className:"h-3 w-3"}),h?"warm":"runtime"]})}),r("td",{className:"px-3 py-2",children:u("span",{className:"inline-flex items-center gap-1 text-[11px] text-sky-400",children:[r(nd,{className:"h-3 w-3"}),m.engine.runtime,"/",m.engine.backend,m.engine.device?`/${m.engine.device}`:"",m.engine.format?` · ${m.engine.format}`:""]})}),r("td",{className:"px-3 py-2",children:m.modelsLoaded.length===0?r("span",{className:"text-foreground-subtle text-[11px]",children:"—"}):r("div",{className:"flex flex-wrap gap-1",children:m.modelsLoaded.map(g=>r("span",{className:"inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle",children:g},g))})}),r("td",{className:"px-3 py-2 text-right font-mono text-foreground",children:m.poolPid??"—"}),r("td",{className:"px-3 py-2 text-right text-[11px]",children:m.idleMs!==null&&m.idleTtlMs!==null?r("span",{className:"text-foreground-subtle",children:dO(m.idleMs,m.idleTtlMs)}):r("span",{className:"text-foreground-subtle/50",children:"never"})}),r("td",{className:"px-3 py-2 text-right text-foreground",children:h?"—":(c??[]).length}),r("td",{className:"px-3 py-2 text-right",children:u("button",{type:"button",disabled:o.isPending,onClick:()=>p(m.engine),className:"inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50",children:[r(Ge,{className:"h-3 w-3"}),"Kill"]})})]},m.engineKey)}),!l&&(i??[]).length===0&&r("tr",{children:r("td",{colSpan:7,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:"No engines resident — the factory spins up on the first pipeline run."})})]})]})}),u("div",{className:"text-[10px] text-foreground-subtle leading-relaxed",children:[r("strong",{className:"text-foreground",children:"runtime"}),": main camera-serving engine; never auto-killed while cameras attached. ",r("strong",{className:"text-foreground",children:"warm"}),": benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL."]}),o.isError&&u("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive",children:["Kill failed: ",o.error instanceof Error?o.error.message:"unknown"]})]})}function kt(e){if(!Number.isFinite(e)||e<0)return"—";if(e<1024)return`${Math.round(e)} B`;const t=["KB","MB","GB","TB","PB"];let n=e/1024,o="KB";for(const a of t){if(o=a,n<1024)break;n/=1024}return`${n>=100?Math.round(n).toString():n.toFixed(1)} ${o}`}function Uy(e){return kt(e*1024*1024)}const pO=new Set(iw);function fp(e){return pO.has(e)}function yi(e,t,n){return`${e}/${t}/${n}`}function ul(e){return{coreml:"CoreML",openvino:"OpenVINO",onnx:"ONNX"}[e.format]??e.format.toUpperCase()}function mp(e){return{coreml:"Apple Neural Engine / GPU — .mlpackage",openvino:"Intel CPU / GPU / NPU — .xml",onnx:"CPU, CUDA, Node.js — .onnx"}[e.format]??`.${e.format}`}function Dn(e){return e.format}function fO(e,t){let n=0,o=0,s=0;for(const a of e)for(const i of a.addons)for(const l of i.models){const c=l.formats[t];c&&(n++,c.downloaded&&(o++,s+=c.sizeMB))}return{total:n,downloaded:o,downloadedSizeMB:s}}function mO({addonId:e,model:t,format:n,isActive:o,progress:s,errorMsg:a,onDownload:i,onDelete:l}){const c=t.formats[n];return c?u("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/50 last:border-b-0 hover:bg-surface-hover/30 transition-colors",children:[r("div",{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?"bg-success":"bg-foreground-subtle/30"}`}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-sm font-medium text-foreground",children:t.name}),u("span",{className:"text-[10px] text-foreground-subtle font-mono",children:["(",t.id,")"]})]}),s&&s.progress>=0&&s.progress<100&&u("div",{className:"mt-1.5 flex items-center gap-2 max-w-xs",children:[r("div",{className:"flex-1 h-1 bg-surface-hover rounded-full overflow-hidden",children:r("div",{className:"bg-primary h-full rounded-full transition-all duration-300",style:{width:`${s.progress}%`}})}),u("span",{className:"text-[9px] text-primary font-mono tabular-nums shrink-0",children:[Math.round(s.progress),"%"]})]})]}),r("span",{className:"text-xs text-foreground-subtle tabular-nums shrink-0",children:Uy(c.sizeMB)}),a&&u("span",{className:"flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0",title:a,children:[r(xa,{className:"h-3 w-3 shrink-0"}),a]}),c.downloaded?u("button",{onClick:l,disabled:o,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md border border-danger/30 text-danger hover:bg-danger/10 disabled:opacity-50 transition-colors shrink-0",children:[o?r(Ae,{className:"h-3 w-3 animate-spin"}):r(Ge,{className:"h-3 w-3"}),o?"Deleting...":"Delete"]}):u("button",{onClick:i,disabled:o,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0",children:[o?r(Ae,{className:"h-3 w-3 animate-spin"}):r(Nn,{className:"h-3 w-3"}),o?"Downloading...":"Download"]})]}):null}function hO({engines:e,activeEngine:t,viewEngine:n,onSelect:o}){const[s,a]=$(!1);return u("div",{className:"relative",children:[u("button",{type:"button",onClick:()=>a(!s),className:"flex items-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 w-full text-left hover:bg-surface-hover transition-colors",children:[r(dt,{className:"h-4 w-4 text-primary shrink-0"}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-sm font-medium text-foreground",children:ul(n)}),Dn(n)===Dn(t)&&r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium",children:"Active"})]}),r("div",{className:"text-[10px] text-foreground-subtle",children:mp(n)})]}),r(vt,{className:`h-4 w-4 text-foreground-subtle transition-transform ${s?"rotate-180":""}`})]}),s&&r("div",{className:"absolute top-full left-0 right-0 mt-1 rounded-lg border border-border bg-surface shadow-lg z-50 overflow-hidden",children:e.map(i=>{const l=Dn(i)===Dn(n),c=Dn(i)===Dn(t);return u("button",{type:"button",onClick:()=>{o(i),a(!1)},className:`flex items-center gap-3 px-4 py-2.5 w-full text-left transition-colors ${l?"bg-primary/5":"hover:bg-surface-hover"}`,children:[r(dt,{className:`h-4 w-4 shrink-0 ${l?"text-primary":"text-foreground-subtle"}`}),u("div",{className:"flex-1",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:`text-sm font-medium ${l?"text-primary":"text-foreground"}`,children:ul(i)}),c&&r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium",children:"Active"})]}),r("div",{className:"text-[10px] text-foreground-subtle",children:mp(i)})]}),l&&r(oy,{className:"h-4 w-4 text-primary shrink-0"})]},Dn(i))})})]})}function gO({embedded:e=!1,nodeId:t}={}){const n=ke(),o=t??"hub",[s,a]=$(null),[i,l]=$(new Set),[c,d]=$(new Map),[f,p]=$(new Map),[m,h]=$(""),{data:g=[]}=ib({nodeId:o},{staleTime:6e4}),x=g.filter((R,B,F)=>F.findIndex(j=>j.format===R.format)===B),{data:y}=lb({nodeId:o},{staleTime:3e4}),w=y,{data:v,isLoading:N}=Io({nodeId:o},{staleTime:1e4}),k=db(),S=ub();ct("model.download.progress",R=>{const B=R.data,F=typeof B.modelId=="string"?B.modelId:void 0,j=typeof B.progress=="number"?B.progress:void 0,H=typeof B.totalMB=="number"?B.totalMB:0;F===void 0||j===void 0||(d(E=>{const Q=new Map(E);return j===100||j===-1?Q.delete(F):Q.set(F,{modelId:F,progress:j,totalMB:H}),Q}),j===100&&n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]}))});const M=w??{runtime:"node",backend:"cpu",format:"onnx"},P=x.find(R=>R.format===s)??M,A=P.format,z=v?.slots??[],D=z.map(R=>({...R,addons:R.addons.map(B=>({...B,models:B.models.filter(F=>F.formats[A]!==void 0)})).filter(B=>B.models.length>0)})).filter(R=>R.addons.length>0),T=fO(D,A),O=q(async(R,B,F)=>{if(!fp(F))return;const j=yi(R,B,F);l(H=>new Set([...H,j])),p(H=>{const E=new Map(H);return E.delete(j),E});try{await k.mutateAsync({addonId:R,modelId:B,format:F,nodeId:o}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch(H){p(E=>new Map([...E,[j,H instanceof Error?H.message:"Download failed"]]))}finally{l(H=>{const E=new Set(H);return E.delete(j),E})}},[k,n,o]),I=q(async(R,B,F)=>{if(!fp(F))return;const j=yi(R,B,F);l(H=>new Set([...H,j])),p(H=>{const E=new Map(H);return E.delete(j),E});try{await S.mutateAsync({addonId:R,modelId:B,format:F,nodeId:o}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch(H){p(E=>new Map([...E,[j,H instanceof Error?H.message:"Delete failed"]]))}finally{l(H=>{const E=new Set(H);return E.delete(j),E})}},[S,n,o]),L=q(R=>{a(R.format)},[]),_=m.trim()?D.map(R=>({...R,addons:R.addons.map(B=>({...B,models:B.models.filter(F=>F.name.toLowerCase().includes(m.toLowerCase())||F.id.toLowerCase().includes(m.toLowerCase())||B.name.toLowerCase().includes(m.toLowerCase()))})).filter(B=>B.models.length>0)})).filter(R=>R.addons.length>0):D;return u("div",{className:e?"space-y-4":"p-6 space-y-6 max-w-5xl mx-auto",children:[!e&&u("div",{children:[r("h1",{className:"text-lg font-bold text-foreground",children:"Models"}),r("p",{className:"text-xs text-foreground-subtle mt-0.5",children:"Manage ML models for the detection pipeline. Select an engine to see its compatible models."})]}),N&&r("div",{className:"flex items-center justify-center py-16",children:r(Ae,{className:"h-5 w-5 animate-spin text-foreground-subtle"})}),!N&&z.length===0&&u("div",{className:"flex flex-col items-center justify-center py-16 text-foreground-subtle",children:[r(uo,{className:"h-8 w-8 mb-3 opacity-30"}),r("span",{className:"text-sm",children:"No pipeline steps available"}),r("span",{className:"text-xs mt-1",children:"Configure the detection pipeline to see available models."})]}),!N&&z.length>0&&u(ge,{children:[r(hO,{engines:x,activeEngine:M,viewEngine:P,onSelect:L}),u("div",{className:"flex items-center gap-4 text-xs text-foreground-subtle",children:[u("span",{children:[r("span",{className:"font-semibold text-foreground tabular-nums",children:T.total}),r("span",{className:"ml-1",children:"compatible models"})]}),r("span",{className:"text-border",children:"|"}),u("span",{children:[r("span",{className:"font-semibold text-success tabular-nums",children:T.downloaded}),r("span",{className:"ml-1",children:"downloaded"})]}),r("span",{className:"text-border",children:"|"}),u("span",{className:"tabular-nums",children:[Uy(T.downloadedSizeMB),r("span",{className:"ml-1",children:"on disk"})]})]}),T.total>5&&u("div",{className:"relative",children:[r(xy,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle"}),r("input",{type:"text",value:m,onChange:R=>h(R.target.value),placeholder:"Search models...",className:"w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-border bg-surface text-foreground placeholder:text-foreground-subtle/50 focus:outline-none focus:ring-1 focus:ring-primary"})]}),_.map(R=>{const B=R.addons.reduce((j,H)=>j+H.models.length,0),F=R.addons.reduce((j,H)=>j+H.models.filter(E=>E.formats[A]?.downloaded).length,0);return u("div",{children:[u("div",{className:"flex items-center gap-2 mb-2",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:R.label}),r("div",{className:"flex-1 h-px bg-border"}),u("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[F,"/",B]})]}),r("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:R.addons.map(j=>j.models.map(H=>{const E=yi(j.id,H.id,A);return r(mO,{addonId:j.id,model:H,format:A,isActive:i.has(E),progress:c.get(H.id),errorMsg:f.get(E),onDownload:()=>O(j.id,H.id,A),onDelete:()=>I(j.id,H.id,A)},`${j.id}/${H.id}`)}))})]},R.id)}),_.length===0&&r("div",{className:"text-center py-8 text-sm text-foreground-subtle",children:m.trim()?u(ge,{children:["No models matching “",m,"”"]}):u(ge,{children:["No models available for ",ul(P)," format"]})})]})]})}function bO({nodeId:e,refreshToken:t}){return r(gO,{embedded:!0,nodeId:e})}function Qy({nodeId:e,title:t}){const{data:n}=Hy(),{data:o}=ia(void 0,{staleTime:3e4}),s=U(()=>{const d=new Map;for(const f of n??[])d.set(f.id,f.name);return d},[n]),a=U(()=>{if(!e)return null;const d=new Set;for(const f of o??[])f.agentNodeId===e&&d.add(f.deviceId);return d},[e,o]),[i,l]=$(new Map);ct("pipeline.camera-metrics-snapshot",d=>{const f=d.data;typeof f.deviceId=="number"&&(e&&f.nodeId!==e||l(p=>{const m=new Map(p);return m.set(f.deviceId,f),m}))}),Z(()=>{if(i.size===0)return;const d=setInterval(()=>{l(f=>{const p=Date.now()-1e4;let m=!1;const h=new Map(f);for(const[g,b]of f)b.timestamp<p&&(h.delete(g),m=!0);return m?h:f})},5e3);return()=>clearInterval(d)},[i.size]);const c=U(()=>{const d=[];for(const f of i.values())a&&!a.has(f.deviceId)||d.push(f);return d.sort((f,p)=>f.deviceId-p.deviceId),d},[i,a]);return c.length===0?u("div",{className:"rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic",children:[t??"Cameras",": no live snapshots yet"]}):u("div",{className:"rounded-md border border-border bg-surface px-3 py-2",children:[u("div",{className:"flex items-center gap-2 mb-1.5",children:[r("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:t??"Cameras"}),r("span",{className:"text-[10px] text-foreground-subtle",children:c.length})]}),r("div",{className:"flex flex-wrap gap-1.5",children:c.map(d=>{const f=s.get(d.deviceId)??`#${d.deviceId}`,p=Zn(d.metrics.phase);return u("div",{title:`${f} · ${p.label} · ${d.metrics.actualFps.toFixed(1)} fps · ${d.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${d.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${p.badgeClass}`,children:[r($c,{phase:d.metrics.phase,className:"h-2.5 w-2.5"}),r("span",{className:"font-medium text-foreground/90 max-w-[120px] truncate",children:f}),r("span",{className:"font-mono tabular-nums",children:d.metrics.actualFps.toFixed(1)}),r("span",{className:"opacity-60",children:"fps"})]},d.deviceId)})})]})}function vi(e,t){if(!e)return null;for(const n of e.slots)for(const o of n.addons)if(o.id===t)return o;return null}function xO({nodeId:e,refreshToken:t}){const n=ke(),[o,s]=$(null),[a,i]=$(null),l=Io({nodeId:e},{refetchOnMount:"always"}),c=vc({agentNodeId:e},{refetchOnMount:"always"}),d=wc({onSuccess:()=>{n.invalidateQueries({queryKey:[["addonSettings"]]}),n.invalidateQueries({queryKey:[["pipelineOrchestrator"]]}),n.invalidateQueries({queryKey:[["pipelineExecutor"]]})}}),f=l.data??null,p=c.data,m=f?.selectedEngine.format??"coreml",h=U(()=>f?ta(f):[],[f]),g=U(()=>[{agentNodeId:e,engineLabel:m}],[e,m]),b=(S,M)=>{const P=p?.addonDefaults[S];return vi(f,S)?.models.some(D=>!!D.formats[m])?P?P.enabled?{kind:"enabled",modelId:P.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},x=o&&f?vi(f,o.addonId):null,y=S=>{const M=p?.addonDefaults[S]??null;s({addonId:S,agentNodeId:e}),i(M)},w=(S,M)=>{if(!p)return;const P=p.addonDefaults[S],A=vi(f,S);if(!P&&!A)return;const z={enabled:M,modelId:P?.modelId??A?.defaultModelId??"",settings:P?.settings??{}};d.mutate({agentNodeId:e,defaults:{...p.addonDefaults,[S]:z}})},v=()=>{s(null),i(null)},N=()=>{!a||!o||!p||d.mutate({agentNodeId:e,defaults:{...p.addonDefaults,[o.addonId]:a}},{onSuccess:v})};if(l.isLoading||c.isLoading)return r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading pipeline…"});if(l.error)return u("div",{className:"text-xs text-red-400",children:["Failed to load catalog: ",String(l.error)]});if(!f)return r("div",{className:"text-xs text-foreground-subtle",children:"Catalog unavailable for this node (runner offline?)."});const k=o!==null&&x!==null&&a!==null;return u("div",{className:"relative h-full w-full space-y-3",children:[r(Qy,{nodeId:e}),r("div",{className:k?"pr-[360px]":"",children:h.length>0?r(Xl,{tree:h,agents:g,getCellState:b,onCellClick:y,selectedCell:o,onToggleEnabled:w}):r("div",{className:"text-xs text-foreground-subtle",children:"Catalog empty."})}),r(Zl,{open:k,onClose:v,title:x?.name??"",subtitle:o?`${o.agentNodeId} · ${m}`:"",footer:u(ge,{children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:v,children:"Cancel"}),r("button",{type:"button",disabled:!a||!o||d.isPending,className:"px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50",onClick:N,children:d.isPending?"Saving…":"Save"})]}),children:x&&a&&o&&r(ra,{mode:"agent",addon:x,agentDefault:a,agentNodeId:o.agentNodeId,engineFormat:m,onChangeAgentConfig:S=>i(S)})})]})}function Ky({pendingCount:e,onSave:t,onDiscard:n,saving:o=!1,saveLabel:s="Save",discardLabel:a="Discard"}){return e<=0?null:u("div",{className:"sticky bottom-0 -mb-3 flex items-center justify-between gap-3 rounded-lg border border-primary/40 bg-primary/5 px-3 py-2 shadow-sm z-10",children:[u("span",{className:"text-xs text-foreground",children:[e," unsaved change",e===1?"":"s"]}),u("div",{className:"flex items-center gap-2",children:[r("button",{type:"button",onClick:n,disabled:o,className:"inline-flex items-center rounded-md border border-border px-2.5 py-1 text-xs text-foreground-subtle hover:bg-surface-hover disabled:opacity-50",children:a}),r("button",{type:"button",onClick:t,disabled:o,className:"inline-flex items-center rounded-md bg-primary px-3 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:o?"Saving…":s})]})]})}function Gy({tabs:e,activeId:t,onChange:n,countByTab:o,pendingByTab:s}){return e.length===0?null:r("div",{className:"flex flex-wrap items-center gap-1 border-b border-border shrink-0",children:e.map(a=>{const i=a.id===t,l=o?.get(a.id)??0,c=s?.get(a.id)??0;return u("button",{type:"button",onClick:()=>n(a.id),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${i?"text-primary border-primary bg-primary/5":"text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover"}`,children:[a.label,l>0&&u("span",{className:"ml-1.5 text-[10px] opacity-60",children:["(",l,")"]}),c>0&&r("span",{className:"ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-primary"})]},a.id)})})}function yO(e,t){for(const n of e)for(const o of n.fields){if(!("key"in o)||o.key!==t)continue;if(o.type==="button"||o.type==="separator"||o.type==="info")return!0;const s=o.immediate;return s===!0?!0:s===!1?!1:n.immediate===!0}return!1}function Wy({schema:e,serverValues:t,onImmediateSave:n,onDeferredSave:o}){const[s,a]=$({}),[i,l]=$(!1),c=ne(null),d=e?.sections??[],f=Object.keys(s).length>0,p=U(()=>({...t,...s}),[t,s]);Z(()=>{if(f){l(!0);return}c.current&&clearTimeout(c.current),c.current=setTimeout(()=>l(!1),500)},[f]);const m=q(()=>{l(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>l(!1),2e3)},[]),h=q(y=>{m();const w={},v={},N={...t,...s};for(const[k,S]of Object.entries(y))N[k]!==S&&(yO(d,k)?w[k]=S:v[k]=S);Object.keys(w).length>0&&n(w),a(k=>{const S={...k};for(const M of Object.keys(w))delete S[M];for(const[M,P]of Object.entries(v))S[M]=P;return S})},[m,t,s,d,n]),g=q(y=>{const w={},v={};for(const[N,k]of Object.entries(s))y.includes(N)?w[N]=k:v[N]=k;a(v),Object.keys(w).length>0&&o(w)},[s,o]),b=q(y=>{a(w=>{const v={...w};for(const N of y)delete v[N];return v})},[]),x=q(()=>{a({})},[]);return{values:p,pendingKeys:Object.keys(s),hasPendingEdits:f,editingPaused:i,handleChange:h,handleSave:g,handleDiscard:b,resetAll:x}}const vO=He(function({addonId:t,schema:n,serverValues:o,onImmediateSave:s,onStateChange:a,onAction:i,disabled:l},c){const d=Wy({schema:n,serverValues:o,onImmediateSave:q(b=>s(t,b),[t,s]),onDeferredSave:q(()=>{},[])});X1(c,()=>({flush:()=>{const b={};for(const x of d.pendingKeys)b[x]=d.values[x];return d.handleDiscard(d.pendingKeys),b},discard:()=>d.resetAll()}),[d]);const f=d.pendingKeys,p=f.join("|"),m=U(()=>f.map(b=>`${b}=${JSON.stringify(d.values[b])}`).join(","),[f,d.values]),h=ne(a);Z(()=>{h.current=a},[a]),Z(()=>{const b={};for(const x of f)b[x]=d.values[x];h.current({addonId:t,pendingKeys:f,pendingValues:b})},[t,p,m]);const g=U(()=>{if(i)return(b,x,y)=>i(t,b,x,y)},[t,i]);return r(kn,{schema:n,values:d.values,onChange:d.handleChange,disabled:l,onAction:g})});function Yy(e,t){if(e.type==="separator"||e.type==="info"||e.type==="button")return e;if(e.type==="group"){const a=e.fields.map(i=>Yy(i,t));return{...e,fields:a}}const n=e;t[e.key]=n.value;const{value:o,...s}=n;return s}function wO(e,t){return{...e,fields:e.fields.map(n=>Yy(n,t))}}function NO(e){const t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(o=>wO(o,t))},values:t}}function Or({nodeId:e,addonIds:t,level:n,deviceId:o,sectionIds:s,sectionTab:a,extraTabs:i,title:l,description:c}){const d=ke(),f=Le().trpcClient,p=ng(),m=rg(),h=cb(),g=xg(),b=dg(),x=!!(i&&i.length>0),[y,w]=$(null);if(n==="device"&&!o)throw new Error('NodeAddonsSettingsPanel: deviceId is required when level === "device"');const v=e??"hub",N=tw({queries:t.map(J=>({queryKey:[["addonSettings",n==="global"?"getGlobalSettings":"getDeviceSettings"],{addonId:J,nodeId:v,deviceId:o??null}],queryFn:async()=>{if(n==="global"){const ee=await f.addonSettings.getGlobalSettings.query({addonId:J,nodeId:v});return{addonId:J,result:ee}}const G=await f.addonSettings.getDeviceSettings.query({addonId:J,deviceId:o,nodeId:v});return{addonId:J,result:G}},staleTime:3e4}))}),k=N.some(J=>J.isLoading),S=N.map(J=>{if(!J.data)return"-";if(J.data.result===null)return`${J.data.addonId}:n`;const G=[];for(const ee of J.data.result.sections){G.push(`s:${ee.id}:${ee.tab??"general"}`);for(const ae of ee.fields){if(!("key"in ae))continue;const fe="options"in ae&&Array.isArray(ae.options)?ae.options.map(ie=>ie.value).join(","):"",he=ae.value,V=he===void 0?"":typeof he=="string"?he:JSON.stringify(he);G.push(`f:${ae.key}:${fe}:${V}`)}}return`${J.data.addonId}:${G.join("|")}`}).join("||"),M=U(()=>{const J=new Set;for(const G of N){const ee=G.data?.result?.sections;if(ee)for(const ae of ee)J.add(ae.tab??"general")}return[...J]},[S+"::"+N.map(J=>(J.data?.result?.sections??[]).map(G=>G.tab??"general").join(",")).join("::")]),P=U(()=>new Map((i??[]).map(J=>[J.id,J])),[i]),A=U(()=>{if(!x)return[];const J=[...new Set([...M,...(i??[]).map(ee=>ee.id)])],G=ee=>{const ae=P.get(ee);if(ae?.order!==void 0)return ae.order;const fe=Di[ee];return fe?fe.order:50};return J.sort((ee,ae)=>{const fe=G(ee),he=G(ae);return fe!==he?fe-he:ee.localeCompare(ae)})},[x,M,i,P]),z=U(()=>{const J=new Map;for(const G of M){const ee=Di[G];J.set(G,ee?.label??G.charAt(0).toUpperCase()+G.slice(1))}for(const G of i??[])J.set(G.id,G.label);return J},[M,i]),D=x?y&&A.includes(y)?y:A[0]??null:null,T=D!==null&&P.has(D),O=x?D&&!T?D:void 0:a,{data:I}=oa(void 0,{staleTime:6e4}),L=U(()=>{const J=new Map;for(const G of I??[]){const ee=G.manifest?.id;if(!ee)continue;const ae=G.manifest?.name??G.manifest?.packageDisplayName??ee;J.set(ee,ae)}return J},[I]),_=U(()=>{const J=s?new Set(s):null,G=[];for(const ee of N){if(!ee.data||ee.data.result===null)continue;const{schema:ae,values:fe}=NO(ee.data.result),he=ae.sections.filter(ue=>J?J.has(ue.id):!0);if(he.length===0)continue;const V={...ee.data.result,sections:ee.data.result.sections.filter(ue=>J?J.has(ue.id):!0)},ie={...ae,sections:he};G.push({addonId:ee.data.addonId,schemaWithValues:V,schema:ie,serverValues:fe})}return G},[S,s]),[R,B]=$(new Map),F=q(J=>{B(G=>{const ee=new Map(G);return ee.set(J.addonId,J),ee})},[]),j=ne(new Map),H=q(J=>G=>{G?j.current.set(J,G):j.current.delete(J)},[]),E=q(async(J,G)=>{n==="global"?await p.mutateAsync({addonId:J,nodeId:v,patch:G}):await m.mutateAsync({addonId:J,deviceId:o,nodeId:v,patch:G}),d.invalidateQueries({queryKey:[["addonSettings"]]})},[p,m,v,n,o,d]),Q=q(async(J,G,ee,ae)=>{const fe=v;try{switch(G){case"reprobe-engine":await h.mutateAsync({nodeId:fe}),d.invalidateQueries({queryKey:[["addonSettings"]]});return;case"reprobe-hwaccel":await g.mutateAsync({nodeId:fe}),d.invalidateQueries({queryKey:[["addonSettings"]]});return;case"reprobe-audio-engine":await b.mutateAsync({nodeId:fe}),d.invalidateQueries({queryKey:[["addonSettings"]]});return;default:{const he=await f.addons.custom.mutate({addonId:J,action:G,input:ae});return d.invalidateQueries({queryKey:[["addonSettings"]]}),he}}}catch(he){throw console.error("[NodeAddonsSettingsPanel] action failed",{addonId:J,action:G,err:he}),he}},[h,g,b,v,d,f]),K=q((J,G)=>{E(J,G)},[E]),Y=_l({mutationFn:async()=>{const J=[];for(const ee of _){const ae=R.get(ee.addonId);!ae||ae.pendingKeys.length===0||J.push({addonId:ee.addonId,patch:ae.pendingValues})}return J.length===0?{saved:[]}:{saved:await Promise.all(J.map(async({addonId:ee,patch:ae})=>(n==="global"?await p.mutateAsync({addonId:ee,nodeId:v,patch:ae}):await m.mutateAsync({addonId:ee,deviceId:o,nodeId:v,patch:ae}),ee)))}},onSuccess:({saved:J})=>{for(const G of J)j.current.get(G)?.discard();d.invalidateQueries({queryKey:[["addonSettings"]]})}}),re=q(()=>{for(const J of j.current.values())J.discard()},[]),te=U(()=>{let J=0;for(const G of _){const ee=R.get(G.addonId);ee&&(J+=ee.pendingKeys.length)}return J},[_,R]),X=U(()=>{const J=new Map;for(const G of _){const ee=R.get(G.addonId);if(!ee||ee.pendingKeys.length===0)continue;const ae=new Set(ee.pendingKeys);for(const fe of G.schema.sections){const he=fe.tab??"general";for(const V of fe.fields)"key"in V&&ae.has(V.key)&&J.set(he,(J.get(he)??0)+1)}}return J},[_,R]);if(k)return r("div",{className:"h-24 rounded-lg border border-border bg-surface animate-pulse"});const oe=D&&T?P.get(D):void 0;if(!x&&_.length===0)return u("div",{className:"text-[11px] text-foreground-subtle italic",children:["No addons in ",t.length>0?`[${t.join(", ")}]`:"the current selection"," ","expose ",n,"-level settings on this node."]});const be=Y.isPending;return u("div",{className:"space-y-4",children:[(l||c)&&u("div",{className:"border-b border-border pb-2",children:[l&&r("h2",{className:"text-sm font-semibold text-foreground",children:l}),c&&r("p",{className:"text-[11px] text-foreground-subtle mt-0.5",children:c})]}),x&&r(Gy,{tabs:A.map(J=>({id:J,label:z.get(J)??J})),activeId:D,onChange:w,pendingByTab:X}),Y.isError&&u("div",{className:"rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400",children:["Save failed: ",String(Y.error?.message??Y.error)]}),oe?oe.content:(()=>{const J=O?_.reduce((ae,fe)=>ae+fe.schemaWithValues.sections.filter(he=>(he.tab??"general")===O).length,0):0,G=O!==null&&J<=1,ee=_.map(ae=>({...ae,renderedWithValues:{...ae.schemaWithValues,sections:ae.schemaWithValues.sections.filter(fe=>O?(fe.tab??"general")===O:!0).map(fe=>G?{...fe,title:"",description:void 0}:fe)}})).filter(ae=>ae.renderedWithValues.sections.length>0).sort((ae,fe)=>{const he=ue=>{let de=Number.POSITIVE_INFINITY;for(const ce of ue)typeof ce.order=="number"&&ce.order<de&&(de=ce.order);return de},V=he(ae.renderedWithValues.sections),ie=he(fe.renderedWithValues.sections);return V!==ie?V-ie:0});return ee.length===0?r("div",{className:"text-[11px] text-foreground-subtle italic",children:"Nothing to configure here for this node."}):r(kO,{entries:ee,paneStates:R,displayNames:L,disabled:be,setPaneRef:H,onPaneStateChange:F,onImmediateSave:K,onAction:Q,inline:x||!!a})})(),!k&&r(Ky,{pendingCount:te,onSave:()=>Y.mutate(),onDiscard:re,saving:be})]})}function kO({entries:e,paneStates:t,displayNames:n,disabled:o,setPaneRef:s,onPaneStateChange:a,onImmediateSave:i,onAction:l,inline:c}){const d=U(()=>[...e].sort((x,y)=>{if(x.addonId==="system-config")return-1;if(y.addonId==="system-config")return 1;const w=n.get(x.addonId)??x.addonId,v=n.get(y.addonId)??y.addonId;return w.localeCompare(v)}),[e,n]),f=d[0]?.addonId??"",[p,m]=$(f);Z(()=>{d.length!==0&&(d.find(x=>x.addonId===p)||m(d[0].addonId))},[d,p]);const h=d.find(x=>x.addonId===p)??d[0];if(!h)return null;const g=U(()=>l?(x,y,w,v)=>l(x,y,w,v):void 0,[l]),b=x=>r(vO,{ref:s(x.addonId),addonId:x.addonId,schema:x.renderedWithValues,serverValues:x.serverValues,onImmediateSave:i,onStateChange:a,onAction:g,disabled:o},x.addonId);return d.length===1||c?r("div",{className:"flex flex-col gap-4",children:d.map(b)}):u("div",{className:"flex flex-col gap-3",children:[r("div",{className:"flex flex-wrap items-center gap-1 border-b border-border shrink-0",children:d.map(x=>{const y=n.get(x.addonId)??x.addonId,w=x.addonId===h.addonId,v=(t.get(x.addonId)?.pendingKeys.length??0)>0;return u("button",{type:"button",onClick:()=>m(x.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${w?"text-primary border-primary bg-primary/5":"text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover"}`,children:[y,v&&r("span",{className:"ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400"})]},x.addonId)})}),r("div",{className:"space-y-2",children:d.map(x=>r("div",{style:x.addonId===h.addonId?void 0:{display:"none"},children:b(x)},x.addonId))})]})}const SO=["detection-pipeline","decoder-nodeav","audio-analyzer","pipeline-runner"];function CO({nodeId:e,refreshToken:t}){return u("div",{className:"flex flex-col h-full",children:[r(eO,{nodeId:e,refreshToken:t}),r("div",{className:"flex-1 min-h-0 overflow-y-auto p-6",children:r(Or,{nodeId:e,addonIds:SO,level:"global",extraTabs:[{id:"assignments",label:"Assignments",order:-10,content:r(cO,{nodeId:e,refreshToken:t})},{id:"tree",label:"Pipeline",order:39,content:r(xO,{nodeId:e,refreshToken:t})},{id:"engines",label:"Warm instances",order:180,content:r(uO,{nodeId:e,refreshToken:t})},{id:"models",label:"Models",order:200,content:r(bO,{nodeId:e,refreshToken:t})}]})})]})}function MO({refreshToken:e}){const t=ke(),n=gb({onSuccess:()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","getPipelineAssignments"]]}),t.invalidateQueries({queryKey:[["pipelineOrchestrator","getDecoderAssignments"]]}),t.invalidateQueries({queryKey:[["pipelineOrchestrator","getAudioAssignments"]]})}});return u("div",{className:"space-y-6",children:[r(jy,{refreshToken:e}),u("div",{className:"flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between",children:[u("div",{className:"min-w-0",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Placement matrix"}),r("p",{className:"text-[11px] text-foreground-subtle",children:"Pipeline · decoder · audio assignments per camera. Click the kebab to pin / unpin / move any role; expand the chevron for the per-camera broker drill-down."})]}),u("button",{type:"button",onClick:()=>n.mutate(void 0),disabled:n.isPending,className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-white hover:bg-primary/90 disabled:opacity-50 shrink-0 self-start @md/clustertab:self-auto whitespace-nowrap",children:[r(nd,{className:"h-3.5 w-3.5"}),n.isPending?"Rebalancing…":"Rebalance pipelines"]})]}),r(qy,{mode:"cluster"})]})}const IO=["pipeline-orchestrator"];function AO({refreshToken:e}){return r("div",{className:"space-y-4 max-w-3xl",children:r(Or,{nodeId:"hub",addonIds:IO,level:"global",title:"Cluster settings",description:"Cluster-wide orchestration knobs: enabled nodes, load balancer thresholds, and failover policy. Per-camera pipelines live in Device Overrides; live cluster load is on the Assignments tab."})})}function PO({refreshToken:e}){const t=ke(),{data:n,isLoading:o}=_b(),[s,a]=$(null),[i,l]=$(""),[c,d]=$(""),f=()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","listTemplates"]]})},p=Db({onSuccess:()=>{a(null),f()}}),m=Lb({onSuccess:f}),h=y=>{a(y.id),l(y.name),d(y.description??"")},g=()=>{a(null),l(""),d("")},b=()=>{if(!s)return;const y=c.trim();p.mutate({id:s,name:i.trim()||"Untitled",...y?{description:y}:{}})};if(o)return r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading templates…"});const x=[...n??[]].sort((y,w)=>y.name.localeCompare(w.name));return r("div",{className:"space-y-6 max-w-4xl",children:u("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"border-b border-border px-4 py-3 flex items-center justify-between",children:[u("div",{children:[r("h3",{className:"text-sm font-semibold text-foreground",children:"Templates"}),r("p",{className:"text-[11px] text-foreground-subtle mt-0.5",children:"Curated pipeline presets operators can apply to any camera. Apply-time is a copy — future edits to a template don't retroactively change cameras that were seeded from it. Save a template from the device Pipeline tab."})]}),u("div",{className:"text-[11px] text-foreground-subtle",children:[x.length," template",x.length===1?"":"s"]})]}),x.length===0?u("div",{className:"px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2",children:[r(wt,{className:"h-6 w-6 opacity-40"}),r("div",{children:'No templates yet. Create one from a device Pipeline tab ("Save as template").'})]}):r("ul",{className:"divide-y divide-border",children:x.map(y=>{const w=s===y.id;return r("li",{className:"px-4 py-3 text-xs",children:u("div",{className:"flex items-start gap-3",children:[r("div",{className:"flex-1 min-w-0",children:w?u("div",{className:"space-y-2",children:[r("input",{className:"w-full rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary",value:i,onChange:v=>l(v.target.value),placeholder:"Template name",autoFocus:!0}),r("input",{className:"w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary",value:c,onChange:v=>d(v.target.value),placeholder:"Description (optional)"})]}):u(ge,{children:[r("div",{className:"font-medium text-foreground",children:y.name}),y.description&&r("div",{className:"text-foreground-subtle mt-0.5",children:y.description}),u("div",{className:"mt-1 font-mono text-[10px] text-foreground-subtle",children:["engine ",y.config.engine.runtime,"/",y.config.engine.backend," · ",y.config.steps.length," step(s)",y.config.audio?.enabled?" · audio":"",u("span",{className:"ml-2",children:["updated ",new Date(y.updatedAt).toLocaleString()]})]})]})}),r("div",{className:"flex items-center gap-1 shrink-0",children:w?u(ge,{children:[u("button",{type:"button",onClick:b,disabled:p.isPending,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-50",children:[r(Mt,{className:"h-3 w-3"}),"Save"]}),u("button",{type:"button",onClick:g,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover",children:[r(Ve,{className:"h-3 w-3"}),"Cancel"]})]}):u(ge,{children:[r("button",{type:"button",onClick:()=>h(y),title:"Rename",className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover",children:r(Rr,{className:"h-3 w-3"})}),r("button",{type:"button",onClick:()=>{confirm(`Delete template "${y.name}"?`)&&m.mutate({id:y.id})},disabled:m.isPending,title:"Delete",className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-red-400 hover:bg-surface-hover disabled:opacity-50",children:r(Ge,{className:"h-3 w-3"})})]})})]})},y.id)})})]})})}function hp(e,t){if(!e)return null;for(const n of e.slots)for(const o of n.addons)if(o.id===t)return o;return null}function EO({nodeId:e,refreshToken:t}){const n=ke(),o=Le().trpcClient,[s,a]=$(null),[i,l]=$(null),c=_r(void 0,{refetchOnMount:"always"});xt(["nodes","topology"],["agent.online","agent.offline","agent.unregistered","addon.installed","addon.uninstalled","addon.updated"]);const d=An(void 0,{staleTime:3e4,refetchOnMount:"always"}),f=U(()=>{const A=new Set;for(const z of d.data??[])z.isOnline&&A.add(z.id);return A},[d.data]),p=Io({nodeId:e},{refetchOnMount:"always"}),m=U(()=>(c.data??[]).filter(A=>f.has(A.nodeId)).map(A=>A.nodeId),[c.data,f]),h=Wn({enabled:m.length>0,queryKey:[["pipelineExecutor","getSchema"],"schema-by-agent",m.join(","),t],queryFn:async()=>{const A={};for(const z of m)try{const D=await o.pipelineExecutor.getSchema.query({nodeId:z});A[z]=D.selectedEngine.format}catch{A[z]="coreml"}return A}}),g=wc({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator"]]}),n.invalidateQueries({queryKey:[["pipelineExecutor"]]}),n.invalidateQueries({queryKey:[["addonSettings"]]})}}),b=U(()=>p.data?ta(p.data):[],[p.data]),x=U(()=>{const A=c.data??[],z=f;return(z.size===0?[]:A.filter(T=>z.has(T.nodeId))).map(T=>{const O=h.data?.[T.nodeId];return{agentNodeId:T.nodeId,engineLabel:O??"(engine unknown)"}})},[c.data,h.data,f]),y=(A,z)=>{const T=c.data?.find(_=>_.nodeId===z)?.settings.addonDefaults[A],O=h.data?.[z];return hp(p.data??null,A)?.models.some(_=>O!==void 0&&!!_.formats[O])?T?T.enabled?{kind:"enabled",modelId:T.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},w=s?c.data?.find(A=>A.nodeId===s.agentNodeId)??null:null,v=s&&p.data?hp(p.data,s.addonId):null,N=s?h.data?.[s.agentNodeId]??"coreml":"coreml",k=()=>{a(null),l(null)},S=(A,z)=>{const T=c.data?.find(O=>O.nodeId===z)?.settings.addonDefaults[A]??null;a({addonId:A,agentNodeId:z}),l(T)},M=()=>{!i||!s||!w||g.mutate({agentNodeId:s.agentNodeId,defaults:{...w.settings.addonDefaults,[s.addonId]:i}},{onSuccess:k})};if(c.isLoading||p.isLoading)return r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading agents…"});if(!p.data)return u("div",{className:"text-xs text-foreground-subtle",children:["Catalog unavailable for ",e,"."]});const P=s!==null&&v!==null&&i!==null;return u("div",{className:"relative h-full w-full space-y-3",children:[r(Qy,{title:"Cluster cameras"}),r("div",{className:P?"pr-[360px]":"",children:b.length>0&&x.length>0?r(Xl,{tree:b,agents:x,getCellState:y,onCellClick:S,selectedCell:s}):r("div",{className:"text-xs text-foreground-subtle",children:"No agents or catalog empty."})}),r(Zl,{open:P,onClose:k,title:v?.name??"",subtitle:s?`${s.agentNodeId} · ${N}`:"",footer:u(ge,{children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:k,children:"Cancel"}),r("button",{type:"button",disabled:!i||!s||g.isPending,className:"px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50",onClick:M,children:g.isPending?"Saving…":"Save"})]}),children:v&&i&&s&&r(ra,{mode:"agent",addon:v,agentDefault:i,agentNodeId:s.agentNodeId,engineFormat:N,onChangeAgentConfig:A=>l(A)})})]})}const $O=[{id:"assignments",label:"Assignments"},{id:"pipeline",label:"Pipeline"},{id:"settings",label:"Settings"},{id:"templates",label:"Templates"}];function _O({refreshToken:e}){const[t,n]=$("assignments"),{data:o}=An(void 0,{staleTime:3e4}),s=o?.find(a=>a.isHub&&a.isOnline)?.id??o?.find(a=>a.isOnline)?.id??null;return u("div",{className:"flex flex-col h-full",children:[u("div",{className:"px-6 py-4 border-b border-border",children:[r("h2",{className:"text-base font-semibold text-foreground",children:"Cluster Orchestration"}),r("div",{className:"text-[11px] text-foreground-subtle mt-1",children:"Assignments with live load, cluster-wide settings, pipeline template library, per-camera pipeline overrides."})]}),r("div",{className:"flex items-center gap-1 px-6 border-b border-border",children:$O.map(a=>r("button",{type:"button",onClick:()=>n(a.id),className:`px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===a.id?"border-primary text-primary":"border-transparent text-foreground-subtle hover:text-foreground"}`,children:a.label},a.id))}),u("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab",children:[t==="assignments"&&r(MO,{refreshToken:e}),t==="pipeline"&&(s?r(EO,{nodeId:s,refreshToken:e}):r("div",{className:"text-xs text-foreground-subtle",children:"No online node available — schema unreachable."})),t==="settings"&&r(AO,{refreshToken:e}),t==="templates"&&r(PO,{refreshToken:e})]})]})}const to="__cluster__";function DO(){const[e,t]=ha(),n=e.get("node")??to,[o,s]=$(0);return Z(()=>{e.get("node")||t({node:to},{replace:!0})},[e,t]),u("div",{className:"flex flex-col h-full overflow-hidden",children:[u("div",{className:"flex items-center justify-between gap-4 px-6 py-4 border-b border-border shrink-0",children:[u("div",{className:"flex items-center gap-2",children:[r(cy,{className:"h-4 w-4 text-foreground-subtle"}),r("h1",{className:"text-lg font-semibold text-foreground",children:"Pipeline"})]}),u("button",{type:"button",onClick:()=>s(i=>i+1),title:"Refresh",className:"inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:[r(ut,{className:"h-3.5 w-3.5"}),"Refresh"]})]}),u("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden min-h-0",children:[r("aside",{className:"w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border overflow-y-auto",children:r(J6,{selectedNodeId:n,onSelect:i=>{t({node:i},{replace:!0})},refreshToken:o})}),r("section",{className:"flex-1 min-h-0 overflow-hidden",children:n===to?r(_O,{refreshToken:o}):r(CO,{nodeId:n,refreshToken:o})})]})]})}function LO(e){const[t,n]=$("idle"),[o,s]=$(null),a=ne(null),i=ne(null),l=ne(null),c=ne(!0),d=Hg(),f=Vg(),p=qg(),m=q(()=>{if(a.current){try{a.current.close()}catch{}a.current=null}if(i.current){for(const b of i.current.getTracks())try{b.stop()}catch{}i.current=null}l.current=null},[]),h=q(async()=>{if(t==="idle")return;n("stopping");const b=l.current;if(b&&e!==null)try{await Promise.race([p.mutateAsync({deviceId:e,sessionId:b}),new Promise((y,w)=>setTimeout(()=>w(new Error("server stopSession timeout")),2e3))])}catch(y){console.warn("[intercom] server stopSession failed (continuing teardown)",y)}m(),c.current&&(n("idle"),s(null))},[t,e,p,m]),g=q(async()=>{if(e===null||t!=="idle"&&t!=="error")return;s(null);let b=null,x=null,y=null;try{n("requesting-mic"),b=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),i.current=b,n("starting");const w=await d.mutateAsync({deviceId:e});y=w.sessionId,l.current=y,n("connecting"),x=new RTCPeerConnection,a.current=x,x.oniceconnectionstatechange=()=>{if(!c.current)return;const k=x.iceConnectionState;k==="connected"||k==="completed"?n("talking"):(k==="failed"||k==="closed"||k==="disconnected")&&c.current&&(s(k==="failed"?"WebRTC connection failed":null),h())};for(const k of b.getAudioTracks())x.addTrack(k,b);await x.setRemoteDescription({type:"offer",sdp:w.sdpOffer});const v=await x.createAnswer();await x.setLocalDescription(v);const N=x.localDescription?.sdp??v.sdp??"";await f.mutateAsync({deviceId:e,sessionId:y,sdpAnswer:N})}catch(w){const v=w instanceof Error?w.message:String(w);if(console.warn("[intercom] start failed",w),x)try{x.close()}catch{}if(b)for(const N of b.getTracks())try{N.stop()}catch{}if(a.current=null,i.current=null,y!==null)try{await p.mutateAsync({deviceId:e,sessionId:y})}catch{}l.current=null,c.current&&(s(v),n("error"))}},[e,t,d,f,p,h]);return Z(()=>(c.current=!0,()=>{c.current=!1;const b=l.current;if(b!==null&&e!==null&&p.mutate({deviceId:e,sessionId:b}),a.current){try{a.current.close()}catch{}a.current=null}if(i.current){for(const x of i.current.getTracks())try{x.stop()}catch{}i.current=null}l.current=null}),[e]),{state:t,error:o,start:g,stop:h,isTalking:t==="talking"}}let TO=0;function ot(){return++TO}function wi(e){switch(e.type){case"system":return"system";case"device":return`#${e.deviceId}`;case"provider":return e.providerId;case"addon":return e.addonId}}function RO(e){return["","Commands"," help Show this help"," examples Show usage examples for the current scope"," context Show every available variable + full API surface"," clear Clear terminal (also Ctrl+L)","","Shortcuts"," Enter Execute expression"," Arrow Up/Down Navigate command history"," Ctrl+L Clear terminal","",`Try: ${{system:" sm.summary() // fleet overview",device:" device.state.battery.value?.sleeping // sync read",provider:" devices.map(d => d.name)",addon:" manifest.version"}[e.type]}`,"","Top-level objects: sm (SystemMirror), DeviceType, Math, JSON, Date, …"]}function OO(e){switch(e.type){case"device":return["","── State (sync, zero round-trip) ─────────────────────────"," device.state.battery.value"," device.state.battery.value?.percentage"," device.state.motion.value?.detected","","── Actions (async, through wrapper chain) ────────────────"," await device.snapshot.getSnapshot({})"," await device.ptz.move({ direction: 'left', steps: 1 })"," await device.switch.setState({ on: true })","","── Wait for condition ───────────────────────────────────"," await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)","","── Subscribe to changes ─────────────────────────────────"," const off = device.state.battery.subscribe(s => console.log(s))","","── Quick info ───────────────────────────────────────────"," info.name device name"," info.addonId owning addon"," sm.dump(deviceId) full debug dump"];case"system":return["","── Lookups ──────────────────────────────────────────────"," sm.getDeviceById(8)"," sm.getDeviceByName('Sala da pranzo')"," sm.getDevicesByAddon('reolink')"," sm.getDevicesByType(DeviceType.Camera)","","── Filters (typed query) ────────────────────────────────"," sm.query({ addonId: 'reolink', online: true })"," sm.query({ caps: ['battery', 'snapshot'] })"," sm.query({ name: /^Cam-/ })","","── Cross-device ─────────────────────────────────────────"," sm.whereState('battery', s => s.percentage < 20).length"," sm.mapState('battery', s => s.percentage)"," sm.countByCap('snapshot')","","── Batch action ─────────────────────────────────────────"," await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })","","── Listen ───────────────────────────────────────────────"," sm.listenCap('motion', (id, s) => console.log(id, s))"," sm.onDeviceAdded((id, info) => console.log('+', info.name))","","── Diagnostics ──────────────────────────────────────────"," sm.summary()"," sm.dump(8)"];case"provider":return[""," devices.map(d => d.name)"," await getIntegration()"," sm.getDevicesByAddon('<this-addon-id>').length"];case"addon":return[""," manifest.name"," manifest.version"," declaration"]}}function zO(e){const t=["",`Scope: ${e.type}`,""];switch(e.type){case"system":return[...t,"Primary API — sm (SystemMirror):"," sm.getDeviceById(id) DeviceProxy | null (sync)"," sm.getDeviceByName(name) DeviceProxy | null"," sm.getDeviceByStableId(sid) DeviceProxy | null"," sm.getAllDevices() readonly DeviceProxy[]"," sm.getDeviceInfo(id) DeviceInfo | null"," sm.summary() fleet stats","","Filters — sm.query({...}):"," sm.query({ addonId: 'reolink', online: true })"," sm.query({ caps: ['battery', 'snapshot'] }) // ALL caps required"," sm.query({ anyCap: ['ptz', 'motion'] }) // ANY cap"," sm.query({ name: { contains: 'sala' } }) // case-insensitive"," sm.query({ name: /^Cam-\\d+$/ })"," sm.query({ type: DeviceType.Camera })"," sm.query({ parentDeviceId: 8 }) // accessories of cam 8"," sm.query({ where: (info, dev) => dev.state.battery.value?.sleeping })","","State queries:"," sm.whereState('battery', s => s.percentage < 20)"," sm.mapState('battery', s => s.percentage)"," sm.findState('motion', s => s.detected)"," sm.countByCap('snapshot')","","Listeners (return unsubscribe fn):"," sm.listen((id, cap, slice) => …) // every state change"," sm.listenCap('motion', (id, slice) => …)"," sm.listenDevice(8, (id, cap, slice) => …)"," sm.onDeviceAdded((id, info) => …)"," sm.onDeviceRemoved((id, info) => …)","","Wait primitives:"," await sm.waitForState(8, 'battery', s => !s.sleeping, 30_000)"," await sm.waitForDevice(99, 30_000)","","Batch:"," await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })"," await sm.forEachCap('reboot', d => d.reboot.reboot({}))","","Diagnostics:"," sm.dump(8) debug dump (one device)"," sm.dump() full fleet dump"," sm.summary() breakdown by cap/addon/type","","Legacy: deviceRegistry, addonRegistry, eventBus, devices(), addons()"];case"device":return[...t,"Pre-bound variables:"," device DeviceProxy for this device (sync state + async methods)"," deviceId number"," info DeviceInfo metadata (name, addonId, type, online, …)"," sm SystemMirror (full cluster view)"," rawDevice legacy IDevice instance (escape hatch)","","Reactive state (sync, zero round-trip):"," device.state.battery.value BatteryStatus | undefined"," device.state.battery.value?.sleeping"," device.state.battery.value?.percentage"," device.state.motion.value?.detected"," device.state.switch.value?.on"," device.state.brightness.value?.percentage"," device.state.doorbell.value?.lastPressedAt","","Cap actions (async, through wrapper chain):"," await device.snapshot.getSnapshot({})"," await device.snapshot.getSnapshot({ streamId: 'high' })"," await device.ptz.move({ direction: 'left', steps: 1 })"," await device.ptz.goToPreset({ presetId: 'home' })"," await device.switch.setState({ on: true })"," await device.brightness.setBrightness({ percentage: 60 })"," await device.reboot.reboot({})","","Subscribe to slice changes:"," const off = device.state.battery.subscribe(s => console.log(s))"," // off() to unsubscribe","","Wait for a state condition:"," await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)","","Diagnostics:"," info.name device name"," info.addonId which addon owns it"," info.online transport health"," sm.dump(deviceId) full debug dump (binding + state + info)"];case"provider":return[...t,"Pre-bound variables:"," devices Devices belonging to this provider (raw IDevice[])"," getIntegration() Integration metadata","","For typed device access use the SystemMirror:"," await getSystemMirror()"," sm.getDevicesByAddon('this-addon-id')"];case"addon":return[...t,"Pre-bound variables:"," manifest { name, version, ... }"," declaration addon declaration"," source addon source location","","Examples:"," manifest.name"," manifest.version"]}}function BO({scope:e,greeting:t,className:n}){const o=Le(),[s,a]=$(()=>{const v=[];return t&&v.push({id:ot(),kind:"info",text:t}),v.push({id:ot(),kind:"info",text:`scope: ${wi(e)} — type help or context for available commands`}),v}),[i,l]=$(""),[c,d]=$([]),[f,p]=$(-1),m=ne(null),h=ne(null);Z(()=>{const v=h.current;v&&(v.scrollTop=v.scrollHeight)},[s]);const g=q(()=>{m.current?.focus()},[]),b=_l({mutationFn:v=>o.trpcClient.repl.execute.mutate({code:v,scope:e}),onSuccess:v=>{const N=v??{},k=typeof N.output=="string"?N.output:v==null?"undefined":typeof v=="string"?v:JSON.stringify(v,null,2),S=N.type==="error";a(M=>[...M,{id:ot(),kind:S?"error":"result",text:k}])},onError:v=>{const N=v instanceof Error?v.message:String(v);a(k=>[...k,{id:ot(),kind:"error",text:N}])}});function x(v){const N=v.trim();if(N){if(N==="clear"){a([{id:ot(),kind:"info",text:`scope: ${wi(e)}`}]),l("");return}if(N==="help"){a(k=>[...k,{id:ot(),kind:"input",text:`> ${N}`},...RO(e).map(S=>({id:ot(),kind:"info",text:S}))]),l("");return}if(N==="context"){a(k=>[...k,{id:ot(),kind:"input",text:`> ${N}`},...zO(e).map(S=>({id:ot(),kind:"info",text:S}))]),l("");return}if(N==="examples"){a(k=>[...k,{id:ot(),kind:"input",text:`> ${N}`},...OO(e).map(S=>({id:ot(),kind:"info",text:S}))]),l("");return}d(k=>[...k,N]),p(-1),a(k=>[...k,{id:ot(),kind:"input",text:`> ${N}`}]),l(""),b.mutate(N)}}function y(v){if(v.key==="Enter"){v.preventDefault(),x(i);return}if(v.key==="ArrowUp"){if(v.preventDefault(),c.length===0)return;const N=f===-1?c.length-1:Math.max(0,f-1);p(N),l(c[N]??"");return}if(v.key==="ArrowDown"){if(v.preventDefault(),f===-1)return;const N=f+1;N>=c.length?(p(-1),l("")):(p(N),l(c[N]??""));return}v.ctrlKey&&v.key==="l"&&(v.preventDefault(),a([{id:ot(),kind:"info",text:`scope: ${wi(e)}`}]))}const w={input:"text-zinc-300",result:"text-emerald-300",error:"text-red-300",info:"text-zinc-400"};return u("div",{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${n??""}`,onClick:g,children:[u("div",{ref:h,className:"flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]",children:[s.map(v=>r("pre",{className:`whitespace-pre-wrap break-words leading-relaxed ${w[v.kind]}`,children:v.text},v.id)),b.isPending&&r("span",{className:"text-zinc-500 animate-pulse",children:"…thinking"})]}),u("div",{className:"flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]",children:[r("span",{className:"text-emerald-400 flex-shrink-0 select-none font-bold",children:">"}),r("input",{ref:m,value:i,onChange:v=>l(v.target.value),onKeyDown:y,disabled:b.isPending,placeholder:"device.state.battery.value",autoFocus:!0,className:"flex-1 bg-transparent text-zinc-100 placeholder:text-zinc-600 focus:outline-none caret-emerald-400 disabled:opacity-50",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"})]})]})}function FO(e){const t=ke(),n=e!==null&&Number.isFinite(e),o=Rb({deviceId:e??0},{enabled:n,refetchInterval:5e3,retry:1}),s=Ob({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),a=zb({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),i=q(async d=>{e!==null&&await s.mutateAsync({deviceId:e,enabled:d})},[e,s]),l=q(async d=>{e!==null&&await a.mutateAsync({deviceId:e,settings:d})},[e,a]),c=o.error?o.error.message:s.error?s.error.message:a.error?a.error.message:null;return{status:o.data??null,isLoading:o.isLoading,isPending:s.isPending||a.isPending,error:c,setEnabled:i,setSettings:l}}function jO({deviceId:e}){const{status:t,isLoading:n,isPending:o,error:s,setEnabled:a,setSettings:i}=FO(Number.isFinite(e)?e:null),[l,c]=$({targetType:"",stopDelaySeconds:30,disappearDelaySeconds:15}),[d,f]=$(!1);return Z(()=>{if(d)return;const p=t?.currentSettings;p&&c({targetType:p.targetType,stopDelaySeconds:p.stopDelaySeconds,disappearDelaySeconds:p.disappearDelaySeconds})},[t,d]),n&&!t?u("div",{className:"flex items-center gap-2 px-3 py-2 text-[10.5px] text-foreground-subtle",children:[r(Ae,{className:"h-3 w-3 animate-spin"}),"Loading autotrack…"]}):u("div",{className:"border-t border-border/40 mt-2 pt-2 px-1 space-y-2",children:[u("div",{className:"flex items-center justify-between px-2",children:[u("div",{className:"flex items-center gap-1.5 text-[10.5px] font-semibold text-foreground",children:[r(zD,{className:"h-3 w-3 text-primary"}),"Autotracking"]}),u("button",{type:"button",onClick:()=>{a(!(t?.enabled??!1))},disabled:o,className:`flex items-center gap-1.5 rounded-md px-2 py-1 text-[10px] font-medium transition-colors ${t?.enabled?"bg-success/15 text-success hover:bg-success/25":"bg-surface-elevated/40 text-foreground-subtle hover:bg-surface-hover hover:text-foreground"} disabled:opacity-50`,"aria-pressed":t?.enabled??!1,children:[r("span",{className:`h-1.5 w-1.5 rounded-full ${t?.enabled?"bg-success":"bg-foreground-subtle/40"}`}),t?.enabled?"Enabled":"Disabled"]})]}),s&&u("div",{className:"flex items-start gap-1.5 rounded-md border border-danger/30 bg-danger/5 px-2 py-1.5 text-[10px] text-danger",children:[r(xa,{className:"h-3 w-3 flex-shrink-0 mt-0.5"}),r("span",{className:"leading-snug break-words",children:s})]}),u("div",{className:"grid grid-cols-2 gap-2 px-2",children:[(t?.supportedTargetTypes?.length??0)>0&&u("label",{className:"col-span-2 flex flex-col gap-1",children:[r("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Target type"}),r("select",{value:l.targetType,onFocus:()=>f(!0),onChange:p=>c(m=>({...m,targetType:p.target.value})),onBlur:()=>{f(!1);const p=t?.currentSettings?.targetType??"";l.targetType!==p&&i({targetType:l.targetType})},disabled:o,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50",children:(t?.supportedTargetTypes??[]).map(p=>r("option",{value:p.value,children:p.label},p.value))})]}),u("label",{className:"flex flex-col gap-1",children:[r("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Stop delay (s)"}),r("input",{type:"number",min:0,max:300,value:l.stopDelaySeconds,onFocus:()=>f(!0),onChange:p=>c(m=>({...m,stopDelaySeconds:Number(p.target.value)||0})),onBlur:()=>{f(!1);const p=t?.currentSettings?.stopDelaySeconds??30;l.stopDelaySeconds!==p&&i({stopDelaySeconds:l.stopDelaySeconds})},disabled:o,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50"})]}),u("label",{className:"flex flex-col gap-1",children:[r("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Disappear delay (s)"}),r("input",{type:"number",min:0,max:300,value:l.disappearDelaySeconds,onFocus:()=>f(!0),onChange:p=>c(m=>({...m,disappearDelaySeconds:Number(p.target.value)||0})),onBlur:()=>{f(!1);const p=t?.currentSettings?.disappearDelaySeconds??15;l.disappearDelaySeconds!==p&&i({disappearDelaySeconds:l.disappearDelaySeconds})},disabled:o,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50"})]})]}),r("p",{className:"px-2 text-[9.5px] text-foreground-subtle leading-snug italic",children:"Settings save on blur. Vendor support varies — Reolink honours all three; Hikvision honours target type + stop delay only (disappear delay is accepted but ignored at firmware push)."})]})}function HO({deviceId:e,intercomAvailable:t=!1}){const n=Le(),o=typeof window<"u"?window.location.origin:"",s=Number.isFinite(e),a=Sy(s?e:null),{streams:i,pipelineMetrics:l,createSession:c,sendAnswer:d,closeSession:f}=Oc(n.trpcClient,s?e:null),p=rc(n.trpcClient,s?e:null),m=LO(s&&t?e:null),h=m.state==="requesting-mic"||m.state==="starting"||m.state==="connecting"||m.state==="stopping",g=m.isTalking||h,b=()=>{m.state==="idle"||m.state==="error"?m.start():m.state!=="stopping"&&m.stop()},x=Cx(),y=x.length>0?r(ge,{children:x.map(w=>r("div",{className:"absolute inset-0",children:w.node},w.id))}):null;return r(Ec,{serverUrl:o,createSession:c,sendAnswer:d,closeSession:f,streams:i,pipelineMetrics:l,phase:a.phase,detections:a,defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:p.src,snapshotLoading:p.loading,onRefreshSnapshot:p.refresh,intercomAvailable:t,intercomShown:g,onIntercomToggle:b,extraOverlay:y,chromeless:!0,className:"h-full"})}function VO({deviceId:e}){return Number.isFinite(e)?r("div",{className:"flex flex-col h-full",children:r(Wt,{deviceId:e,limit:50,maxHeight:"max-h-full",showScope:!1,showFilters:!1})}):u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function qO({deviceId:e}){if(!Number.isFinite(e))return u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]});const t=[`CamStack REPL — device #${e}`,""," device.state.battery.value sync state read"," await device.snapshot.getSnapshot({}) cap action",""," type 'examples' for more, 'context' for the full API"].join(`
|
|
1089
|
-
`);return r(BO,{scope:{type:"device",deviceId:e},greeting:t,className:"h-full border-0 rounded-none"})}function UO({deviceId:e}){const t=Le(),n=Number.isFinite(e),o=zc(t.trpcClient,n?e:0,{enabled:n}),{data:s}=tO(n?e:0);if(!n)return u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]});const a=(s?.features??[]).includes(On.PtzAutotrack);return u("div",{className:"flex flex-col h-full overflow-y-auto",children:[r(Dc,{controls:o,mode:"panel"}),a&&r(jO,{deviceId:e})]})}function QO({deviceId:e}){return Number.isFinite(e)?r("div",{className:"flex flex-col h-full overflow-y-auto",children:r(or,{deviceId:e,limit:50,maxHeight:"max-h-full"})}):u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function KO({deviceId:e}){return Number.isFinite(e)?r("div",{className:"flex flex-col h-full overflow-y-auto",children:r(_c,{deviceId:e,limit:50,maxHeight:"max-h-full"})}):u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function GO({parentDeviceId:e}){const{t}=Ot(),n=Je(),o=Le(),{data:s,isLoading:a,isError:i}=Vy(e);if(a)return r("div",{className:"rounded-lg border border-border bg-surface p-3",children:r("p",{className:"text-[10px] text-foreground-subtle",children:t("common.loading",{defaultValue:"Loading…"})})});if(i)return r("div",{className:"rounded-lg border border-border bg-surface p-3",children:r("p",{className:"text-[10px] text-warning",children:t("integrations.childrenLoadError",{defaultValue:"Failed to load children"})})});const l=s??[];if(l.length===0)return null;const c=l.some(p=>!!p.role),d=l.some(p=>!p.role),f=c&&!d?t("device.accessories",{defaultValue:"Accessories"}):!c&&d?t("device.adoptedDevices",{defaultValue:"Adopted devices"}):t("device.children",{defaultValue:"Children"});return u("div",{className:"rounded-lg border border-border bg-surface p-3",children:[r("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5",children:f}),r("div",{className:"space-y-1",children:l.map(p=>r(ao,{trpc:o.trpcClient,device:p,variant:"minimal",onNavigate:m=>n(`/devices/${String(m)}`)},p.id))})]})}function Ni(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function WO({device:e}){const t=Je(),n=typeof e.id=="number"?e.id:null,o=String(e.type??""),s=o===st.Camera,a=o===st.Hub,i=e.features??[],{data:l}=yc({deviceId:n??0},{enabled:n!==null&&s,refetchInterval:5e3}),c=l?.streams??{},d=Object.entries(c),f=i.includes(On.DoorbellButton),p=Bc(f?{deviceId:n??void 0,historyLimit:10}:void 0),m=p.latest?Date.now()-p.latest.timestamp<3e4:!1;return u("div",{className:"space-y-5",children:[a&&n!==null&&r(Px,{deviceId:n,onOpenChild:h=>t(`/devices/${h}`)}),s&&n!==null&&r(at,{widgetId:"pipeline-orchestrator/pipeline-quick-stats",host:"device-tab",deviceId:n}),f&&r(Lc,{history:p.history,latestIsFresh:m}),s&&n!==null&&r(at,{widgetId:"stream-broker/stream-broker-panel",host:"device-tab",deviceId:n}),s&&d.length>0&&u("div",{className:"@container rounded-lg border border-border bg-surface overflow-hidden",style:{containerType:"inline-size"},children:[r("div",{className:"border-b border-border px-4 py-2",children:r("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"Stream Network"})}),r("div",{className:"divide-y divide-border",children:d.map(([h,g])=>u("div",{className:"px-4 py-2.5",children:[u("div",{className:"flex items-center gap-2 mb-2",children:[r(Vn,{className:"h-3 w-3 text-foreground-subtle"}),r("span",{className:"text-[11px] font-medium text-foreground",children:h})]}),u("div",{className:"grid grid-cols-2 @[640px]:grid-cols-4 gap-2",children:[r(ns,{label:"Nominal",value:Ni(g.nominalBitrateKbps??0)}),r(ns,{label:"Observed",value:Ni(g.observedBitrateKbps??0)}),r(ns,{label:"Peak",value:Ni(g.peakBitrateKbps??0)}),r(ns,{label:"Packet Loss",value:`${(g.packetLossPercent??0).toFixed(2)}%`,warning:(g.packetLossPercent??0)>1})]})]},h))})]}),r(My,{})]})}function ns({label:e,value:t,warning:n}){return u("div",{children:[r("p",{className:"text-[10px] text-foreground-subtle",children:e}),r("p",{className:`text-xs font-medium ${n?"text-warning":"text-foreground"}`,children:t})]})}function YO({schema:e,values:t,pendingKeys:n,onChange:o,onAction:s,onSave:a,onDiscard:i,disabled:l}){const c=e.tabs??[],d=U(()=>{const k=new Map;for(const S of e.sections){const M=S.tab??"general",P=k.get(M)??[];P.push(S),k.set(M,P)}return k},[e.sections]),f=new Set(c.map(k=>k.id)),p=[...c,...[...d.keys()].filter(k=>!f.has(k)).map(k=>({id:k,label:k,icon:"wrench",order:100}))],m=p[0]?.id??"general",[h,g]=$(m),b=d.get(h)??[],y={sections:b.length<=1?b.length===1?[{...b[0],title:""}]:b:b.every(S=>!S.title)?[{...b[0],title:"",fields:b.flatMap(S=>S.fields)}]:b},w=r(Ky,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>i(n),saving:l});if(p.length<=1)return u("div",{className:"flex flex-col gap-3",children:[r(kn,{schema:e,values:t,onChange:o,onAction:s,disabled:l}),w]});const v=new Map,N=new Map;for(const[k,S]of d){v.set(k,S.length);const M=new Set,P=z=>{for(const D of z)if("key"in D&&typeof D.key=="string"&&M.add(D.key),D.type==="group")P(D.fields);else if(D.type==="sub-tabs")for(const T of D.tabs)P(T.fields)};for(const z of S)P(z.fields);const A=n.filter(z=>M.has(z)).length;A>0&&N.set(k,A)}return u("div",{className:"flex flex-col gap-3",children:[r(Gy,{tabs:p.map(k=>({id:k.id,label:k.label})),activeId:h,onChange:g,countByTab:v,pendingByTab:N}),r(kn,{schema:y,values:t,onChange:o,onAction:s,disabled:l}),w]})}const gp={viewer:10,admin:20};function ZO(e,t){if(!t)return!0;const n=gp[t];return n===void 0?!0:(e?gp[e]??0:0)>=n}function XO(e){if(!e)return null;const n={sections:[...e.sections].sort((o,s)=>{const a=o.tab??"general",i=s.tab??"general";return a!==i?a.localeCompare(i):(o.order??0)-(s.order??0)})};return e.tabs?{...n,tabs:e.tabs}:n}function Zy(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="widget"||e.type==="addon-action-button"}function Xy(e){return e.key}function JO(e){if(!Zy(e))return e.value}function Jy(e){return Zy(e)?null:e}function Os(e,t){for(const n of e)if(t(n),n.type==="group")Os(n.fields,t);else if(n.type==="sub-tabs")for(const o of n.tabs)Os(o.fields,t)}function e8(e){if(!e)return{};const t={};for(const n of e.sections)Os(n.fields,o=>{const s=Xy(o);s!==null&&(t[s]=JO(o))});return t}function bp(e,t){if(!e)return null;let n=null;for(const o of e.sections)if(Os(o.fields,s=>{if(n!==null||Xy(s)!==t)return;const a=Jy(s);a&&a.writerCapName&&a.writerAddonId&&(n={capName:a.writerCapName,addonId:a.writerAddonId})}),n!==null)break;return n}function t8(e){return{...e,fields:e.fields.map(e0)}}function e0(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="object-array"?e:{...e,readonlyField:!0}}function n8(e,t){return e&&{...e,sections:e.sections.map(n=>({...n,fields:n.fields.map(o=>{const s=Jy(o);return s?ZO(t,s.minRole)?o:e0(o):o})}))}}function t0({deviceId:e,sectionFilter:t}){const n=ke(),{user:o}=fn(),s=o?.role,a=ne(!1),{data:i,isLoading:l}=hc({deviceId:e},{refetchInterval:()=>a.current?!1:2500,staleTime:6e4,enabled:Number.isFinite(e)}),{data:c}=Hn({deviceId:e},{staleTime:6e4,enabled:Number.isFinite(e)}),d=i?.settings??null,f=i?.live??null,p=U(()=>{if(!d&&!f)return null;const T=d?.sections??[],O=(f?.sections??[]).map(t8),I=[...T,...O],L=t?I.filter(t):I.filter(F=>F.location!=="top-tab");if(L.length===0)return null;const _=new Set;for(const F of L)_.add(F.tab??"general");const B=[...d?.tabs??[],...(f?.tabs??[]).filter(F=>!(d?.tabs??[]).some(j=>j.id===F.id))].filter(F=>_.has(F.id));return B.length>0?{tabs:B,sections:L}:{sections:L}},[d,f,t]),m=U(()=>XO(p),[p]),h=U(()=>n8(m,s),[m,s]),g=U(()=>e8(h),[h]),b=Xb(),x=bc(),y=$g({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]})}}),w={isPending:y.isPending,mutate:T=>{y.mutate({deviceId:e,changes:[...T]})}},v=q(T=>{const O=Object.entries(T).map(([I,L])=>{const _=bp(h,I);return _?{writerCapName:_.capName,writerAddonId:_.addonId,key:I,value:L}:null}).filter(I=>I!==null);O.length>0&&w.mutate(O)},[h,w]),N=q(T=>{const O=Object.entries(T).map(([I,L])=>{const _=bp(h,I);return _?{writerCapName:_.capName,writerAddonId:_.addonId,key:I,value:L}:null}).filter(I=>I!==null);O.length>0&&w.mutate(O)},[h,w]),k=Wy({schema:h,serverValues:g,onImmediateSave:v,onDeferredSave:N}),{values:S,pendingKeys:M,handleChange:P,handleSave:A,handleDiscard:z}=k;if(a.current=k.editingPaused,l)return u("div",{className:"flex items-center justify-center py-12 text-foreground-subtle",children:[r(Ae,{className:"h-4 w-4 animate-spin mr-2"}),r("span",{className:"text-xs",children:"Loading device aggregate…"})]});if(!h||h.sections.length===0)return r("div",{className:"text-xs text-foreground-subtle italic py-4 text-center",children:"No aggregate contributions for this device."});async function D(T,O,I){if(T==="regenerate-rtsp-token"){const L=["rtspUrl:","regenerateToken:"].find(B=>O.startsWith(B));if(!L)throw new Error(`regenerate-rtsp-token: unrecognised key "${O}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);const _=O.slice(L.length);if(!_)throw new Error(`regenerate-rtsp-token: key "${O}" has no streamId after prefix`);const R=`${e}/${_}`;await b.mutateAsync({brokerId:R}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]});return}if(T==="test-probe"){if(!c)return{status:"error",error:"Device metadata not loaded yet"};try{return await x.mutateAsync({addonId:c.addonId,type:c.type,key:O,value:I})}catch(L){return{status:"error",error:L instanceof Error?L.message:String(L)}}}if(T==="refresh-driver-data"){await y.mutateAsync({deviceId:e,changes:[{writerCapName:"device-manager",writerAddonId:"device-manager",key:O,value:Date.now()}]});return}throw new Error(`[device-aggregate] unknown action "${T}"`)}return r(YO,{schema:h,values:S,pendingKeys:M,onChange:P,onAction:D,onSave:A,onDiscard:z,disabled:w.isPending})}function r8({deviceId:e}){return r(t0,{deviceId:e})}const n0=6e4,pl=60*n0,xp=24*pl;function Sa(e){if(e==null||e<=0)return"—";const t=Date.now()-e;return t<0||t<3e4?"just now":t<pl?`${String(Math.floor(t/n0))}m ago`:t<xp?`${String(Math.floor(t/pl))}h ago`:`${String(Math.floor(t/xp))}d ago`}function o8(e,t=new Date){const n=new Date(e);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()}function r0({dev:e,busy:t,setBusy:n}){const o=e?.motionTrigger,s=on(e?.state.motionTrigger),[a,i]=$(!1);if(!o)return null;const l=s?.enabled===!0,c=s!==void 0,d=async()=>{if(t||!c)return;const p=!l;n(!0),i(!0);try{await o.setMotionTrigger({enabled:p})}finally{n(!1),i(!1)}};return u("button",{type:"button",onClick:()=>{d()},disabled:t||!c,title:c?l?"Disable trigger on motion":"Enable trigger on motion":"Awaiting state…","aria-pressed":l,className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${l?"border-primary/50 bg-primary/15 text-primary":"border-border bg-surface text-foreground-subtle hover:text-foreground"}`,children:[r(Eo,{className:"h-3 w-3"}),r("span",{children:a?l?"Disabling…":"Enabling…":c?l?"On motion: on":"On motion: off":"On motion: …"})]})}function o0({deviceId:e,deviceName:t,useSiren:n=!1}){const o=Le(),s=St(o.trpcClient,e),a=on(s?.state.switch),[i,l]=$(!1),c=a?.on??!1,d=a?.lastChangedAt??null,f=a!==void 0,p=n?$o:gy,m=async()=>{if(!(i||!f||!s?.switch)){l(!0);try{await s.switch.setState({on:!c})}finally{l(!1)}}};return u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[r("button",{type:"button",onClick:()=>{m()},disabled:i||!f||!s?.switch,title:f?c?`Turn off ${t}`:`Turn on ${t}`:"Awaiting state…","aria-pressed":c,className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all disabled:cursor-not-allowed disabled:opacity-50 ${c?"border-success bg-success/20 text-success shadow-lg shadow-success/20":"border-border bg-surface text-foreground-subtle hover:border-foreground-subtle hover:text-foreground"}`,children:r(p,{className:"h-10 w-10"})}),r(r0,{dev:s,busy:i,setBusy:l}),u("div",{className:"text-center",children:[r("div",{className:`text-sm font-semibold ${c?"text-success":"text-foreground-subtle"}`,children:f?c?"On":"Off":"Unknown"}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:f?`Changed ${Sa(d)}`:"Awaiting state…"})]})]})}function s8({deviceId:e,deviceName:t}){const n=Le(),o=St(n.trpcClient,e),s=on(o?.state.switch),a=on(o?.state.brightness),i=s?.on??!1,l=s?.lastChangedAt??null,c=s!==void 0,d=a!==void 0,f=o?.brightness!==void 0,[p,m]=$(!1),[h,g]=$(a?.percentage??0);Z(()=>{a?.percentage!==void 0&&g(a.percentage)},[a?.percentage]);const b=async()=>{if(!(p||!c||!o?.switch)){m(!0);try{await o.switch.setState({on:!i})}finally{m(!1)}}},x=async()=>{if(!(p||!d||!o?.brightness)){m(!0);try{await o.brightness.setBrightness({percentage:h})}finally{m(!1)}}};return u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[r("button",{type:"button",onClick:()=>{b()},disabled:p||!c||!o?.switch,title:c?i?`Turn off ${t}`:`Turn on ${t}`:"Awaiting state…","aria-pressed":i,className:`flex h-20 w-20 items-center justify-center rounded-full border-2 transition-all disabled:cursor-not-allowed disabled:opacity-50 ${i?"border-warning bg-warning/20 text-warning shadow-lg shadow-warning/30":"border-border bg-surface text-foreground-subtle hover:border-foreground-subtle hover:text-foreground"}`,children:r(pL,{className:"h-9 w-9"})}),f?u("div",{className:"flex w-full max-w-xs flex-col items-center gap-1",children:[r("input",{type:"range",min:0,max:100,step:1,value:h,disabled:p||!i||!d,onChange:y=>g(Number(y.currentTarget.value)),onPointerUp:()=>{x()},onKeyUp:y=>{y.key==="Enter"&&x()},"aria-label":"Brightness",className:"w-full accent-warning disabled:cursor-not-allowed disabled:opacity-50"}),r("div",{className:"text-[10px] text-foreground-subtle tabular-nums",children:d?`${String(h)}%`:"Brightness unavailable"})]}):null,r(r0,{dev:o,busy:p,setBusy:m}),u("div",{className:"text-center",children:[r("div",{className:`text-sm font-semibold ${i?"text-warning":"text-foreground-subtle"}`,children:c?i?"On":"Off":"Unknown"}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:c?`Changed ${Sa(l)}`:"Awaiting state…"})]})]})}function a8({deviceId:e}){const t=Le(),n=St(t.trpcClient,e),o=on(n?.state.motion),s=o?.detected??!1,a=o?.lastDetectedAt??null,i=o!==void 0;return u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[r("div",{className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all ${s?"border-danger bg-danger/20 text-danger shadow-lg shadow-danger/30 animate-pulse":"border-border bg-surface text-foreground-subtle"}`,"aria-live":"polite",title:s?"Motion detected":"Idle",children:s?r(VL,{className:"h-10 w-10"}):r(Eo,{className:"h-10 w-10"})}),u("div",{className:"text-center",children:[r("div",{className:`text-sm font-semibold ${s?"text-danger":"text-foreground-subtle"}`,children:i?s?"Triggered":"Idle":"Unknown"}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:i?`Last trip ${Sa(a)}`:"Awaiting state…"})]})]})}function i8({deviceId:e}){const t=Le(),n=St(t.trpcClient,e),o=on(n?.state.doorbell),s=o?.lastPressedAt??null,a=o!==void 0,i=s!==null&&Date.now()-s<6e4,[l,c]=$(0),[d,f]=$(null);return Z(()=>{s===null||s===d||(f(s),o8(s)&&c(p=>p+1))},[s,d]),u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[r("div",{className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all ${i?"border-primary bg-primary/20 text-primary shadow-lg shadow-primary/30 animate-pulse":"border-border bg-surface text-foreground-subtle"}`,"aria-live":"polite",title:i?"Just pressed":"Idle",children:r($o,{className:"h-10 w-10"})}),u("div",{className:"text-center",children:[r("div",{className:`text-sm font-semibold ${i?"text-primary":"text-foreground-subtle"}`,children:a?`Last press ${Sa(s)}`:"Unknown"}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5 tabular-nums",children:a?`${String(l)} ring${l===1?"":"s"} today`:"Awaiting state…"})]})]})}function l8({deviceName:e,deviceType:t,provider:n,isOnline:o,features:s}){return u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border bg-surface p-6 text-center",children:[r(cn,{type:n,size:"lg"}),u("div",{children:[r("div",{className:"text-sm font-semibold text-foreground",children:e}),r("div",{className:"text-[10px] text-foreground-subtle uppercase tracking-wider mt-0.5",children:t})]}),u("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[r(ka,{status:o?"online":"offline"}),s.length>0&&r(wa,{capabilities:s})]}),r("div",{className:"text-[10px] text-foreground-subtle italic max-w-xs mt-1",children:"No live view for this device type. Use the Config tab or the shortcut row to interact."})]})}function c8({deviceId:e}){const t=ke(),n=yg({deviceId:e},{refetchInterval:1e4,retry:!1}),o=vg({onSuccess:()=>{t.invalidateQueries({queryKey:[["deviceDiscovery","listDiscovered"]]}),t.invalidateQueries({queryKey:[["deviceDiscovery","getStatus"]]})}}),s=U(()=>d8(n.data??[]),[n.data]);return u("div",{className:"flex h-full w-full flex-col gap-3 p-3 sm:p-4",children:[u("div",{className:"flex flex-wrap items-stretch gap-2 sm:gap-3",children:[r(ki,{label:"Discovered",value:s.total,icon:r(an,{className:"h-3.5 w-3.5"})}),r(ki,{label:"Adopted",value:s.adopted,accent:"success"}),r(ki,{label:"Available",value:s.available,accent:s.available>0?"primary":void 0}),u("button",{type:"button",onClick:()=>{o.mutateAsync({deviceId:e}).catch(()=>{})},disabled:o.isPending,className:"inline-flex items-center justify-center gap-1.5 rounded-lg border border-border px-3 py-2 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 self-stretch shrink-0",children:[o.isPending?r(Ae,{className:"h-3.5 w-3.5 animate-spin"}):r(ut,{className:"h-3.5 w-3.5"}),r("span",{className:"hidden sm:inline",children:"Discover"})]})]}),u("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-foreground-subtle border-t border-border-subtle pt-2",children:[r(rs,{icon:r(Vn,{className:"h-3 w-3 text-emerald-500"}),label:`${s.online} online`}),r(rs,{icon:r(fy,{className:"h-3 w-3 text-amber-500"}),label:`${s.sleeping} sleeping`}),r(rs,{icon:r(ky,{className:"h-3 w-3 text-destructive"}),label:`${s.offline} offline`}),s.unknown>0?r(rs,{icon:r($D,{className:"h-3 w-3 text-foreground-subtle"}),label:`${s.unknown} unknown`}):null]})]})}function d8(e){const t={total:e.length,adopted:0,available:0,online:0,sleeping:0,offline:0,unknown:0};for(const n of e)n.alreadyAdopted?t.adopted+=1:t.available+=1,t[n.status]+=1;return t}function ki({label:e,value:t,icon:n,accent:o}){return u("div",{className:`flex flex-1 basis-[140px] min-w-0 flex-col gap-1 rounded-lg border px-2 py-1.5 sm:px-3 sm:py-2 ${o==="success"?"bg-emerald-500/10 border-emerald-500/30 text-emerald-500":o==="primary"?"bg-primary/10 border-primary/30 text-primary":"bg-surface-hover border-border text-foreground"}`,children:[u("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider opacity-70 truncate",children:[n,r("span",{className:"truncate",children:e})]}),r("div",{className:"text-xl sm:text-2xl font-semibold tabular-nums leading-none",children:t})]})}function rs({icon:e,label:t}){return u("span",{className:"inline-flex items-center gap-1",children:[e,r("span",{children:t})]})}const u8=e=>r(o0,{...e,useSiren:!0}),p8={[st.Switch]:o0,[st.Siren]:u8,[st.Light]:s8,[st.Sensor]:a8,[st.Button]:i8,[st.Hub]:c8};function f8(e){const t=p8[e.deviceType]??l8;return r(t,{...e})}function rd(e){if(e<60)return`${Math.round(e)}s`;const t=Math.floor(e/60),n=Math.round(e%60);if(t<60)return n>0?`${t}m ${n}s`:`${t}m`;const o=Math.floor(t/60),s=t%60;return s>0?`${o}h ${s}m`:`${o}h`}function zs(e){return new Date(e).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Bs(e){return e.toISOString().slice(0,10)}function m8(e,t){return Bs(e)===Bs(t)}function Kr(e){const t=new Date(e);return t.setHours(0,0,0,0),t}function h8(e){const t=new Date(e);return t.setHours(23,59,59,999),t}function At({className:e=""}){return r("div",{className:`animate-pulse rounded bg-foreground-subtle/10 ${e}`})}function Ln(){return u("div",{className:"flex items-center gap-3 px-4 py-3",children:[r(At,{className:"h-4 w-4"}),r(At,{className:"h-3 w-24"}),r(At,{className:"h-3 w-16 ml-auto"})]})}function Hr({children:e,actions:t}){return u("div",{className:"border-b border-border px-4 py-2.5 flex items-center justify-between",children:[r("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:e}),t]})}function yp({icon:e,label:t,value:n}){return u("div",{className:"flex items-center gap-2",children:[r(e,{className:"h-3.5 w-3.5 text-foreground-subtle flex-shrink-0"}),u("div",{className:"min-w-0",children:[r("p",{className:"text-[10px] text-foreground-subtle leading-tight",children:t}),r("p",{className:"text-xs font-medium text-foreground leading-tight",children:n})]})]})}function g8({segments:e,selectedDate:t}){const n=Kr(t).getTime(),o=1440*60*1e3,s=Array.from({length:25},(a,i)=>i);return u("div",{className:"space-y-1",children:[r("div",{className:"flex justify-between px-0.5",children:s.filter(a=>a%3===0).map(a=>r("span",{className:"text-[9px] text-foreground-subtle font-mono",children:String(a).padStart(2,"0")},a))}),u("div",{className:"relative h-6 rounded bg-background border border-border overflow-hidden",children:[e.map(a=>{const i=new Date(a.startTime).getTime()-n,l=new Date(a.endTime).getTime()-n,c=Math.max(0,i/o*100),d=Math.min(100-c,(l-i)/o*100);return d<=0?null:r("div",{className:"absolute top-0 bottom-0 bg-primary/60 hover:bg-primary/80 transition-colors",style:{left:`${c}%`,width:`${Math.max(d,.3)}%`},title:`${zs(a.startTime)} - ${zs(a.endTime)} (${rd(a.duration)})`},a.id)}),s.slice(1,-1).map(a=>r("div",{className:"absolute top-0 bottom-0 w-px bg-border/50",style:{left:`${a/24*100}%`}},a))]})]})}function b8({segment:e,selected:t,onToggle:n,onPlay:o,onDownload:s,onDelete:a}){return u("div",{className:`flex items-center gap-3 px-4 py-2 border-b border-border last:border-b-0 hover:bg-background/50 transition-colors ${t?"bg-primary/5":""}`,children:[r("button",{onClick:n,className:"flex-shrink-0 text-foreground-subtle hover:text-foreground",children:t?r(yy,{className:"h-4 w-4 text-primary"}):r(Do,{className:"h-4 w-4"})}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-xs font-mono text-foreground",children:[zs(e.startTime)," - ",zs(e.endTime)]}),u("p",{className:"text-[10px] text-foreground-subtle",children:[rd(e.duration),e.sizeBytes!=null&&` · ${kt(e.sizeBytes)}`]})]}),u("div",{className:"flex items-center gap-1 flex-shrink-0",children:[r("button",{onClick:o,title:"Play",className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:r(ya,{className:"h-3.5 w-3.5"})}),r("button",{onClick:s,title:"Download",className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:r(Nn,{className:"h-3.5 w-3.5"})}),r("button",{onClick:a,title:"Delete",className:"p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger transition-colors",children:r(Ge,{className:"h-3.5 w-3.5"})})]})]})}function x8({deviceId:e}){const t=ke(),[n,o]=$(()=>Kr(new Date)),[s,a]=$(new Set),i=Ub({deviceId:e},{refetchInterval:5e3}),l=Hb({deviceId:e}),c=l.data?.streams[0]?.streamId??"stream0",d=Vb({deviceId:e,streamId:c,startTime:Kr(n).getTime(),endTime:h8(n).getTime()}),f=qb({deviceId:e,streamId:c},{refetchInterval:3e4}),p=Qb({deviceId:e,dataCategory:"recording:main"}),m=q(()=>{t.invalidateQueries({queryKey:["recordingEngine","getPolicyStatus"]}),t.invalidateQueries({queryKey:["recordingEngine","getSegments"]}),t.invalidateQueries({queryKey:["recordingEngine","getStorageUsage"]})},[t]),h=Fb({onSuccess:m}),g={isPending:h.isPending,error:h.error,mutate:()=>{const _=l.data,R=_?{mode:_.mode,streams:_.streams,enabled:!0,preBufferSec:_.preBufferSec,postBufferSec:_.postBufferSec,scheduleRules:_.scheduleRules}:{mode:"continuous",streams:[{streamId:c,mode:"always"}],enabled:!0,preBufferSec:10,postBufferSec:5};h.mutate({deviceId:e,policy:R})}},b=jb({onSuccess:m}),x=i.data??void 0,y=l.data??void 0,w=d.data??[],v=f.data,N=p.data??void 0,k=(x?.enabled??!1)&&(x?.activeStreams??0)>0,S=g.isPending||b.isPending,M=m8(n,new Date),P=U(()=>[...w].sort((_,R)=>new Date(R.startTime).getTime()-new Date(_.startTime).getTime()),[w]),A=U(()=>w.reduce((_,R)=>_+(R.duration??0),0),[w]),z=U(()=>w.reduce((_,R)=>_+(R.sizeBytes??0),0),[w]);function D(){k?b.mutate({deviceId:e}):g.mutate()}function T(){o(_=>{const R=new Date(_);return R.setDate(R.getDate()-1),Kr(R)}),a(new Set)}function O(){M||(o(_=>{const R=new Date(_);return R.setDate(R.getDate()+1),Kr(R)}),a(new Set))}function I(_){a(R=>{const B=new Set(R);return B.has(_)?B.delete(_):B.add(_),B})}function L(){s.size===P.length?a(new Set):a(new Set(P.map(_=>_.id)))}return i.isLoading&&l.isLoading?u("div",{className:"space-y-4",children:[u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(Hr,{children:"Recording Status"}),u("div",{className:"px-4 py-4 space-y-3",children:[r(At,{className:"h-10 w-full"}),r(At,{className:"h-4 w-48"})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(Hr,{children:"Segments"}),u("div",{className:"divide-y divide-border",children:[r(Ln,{}),r(Ln,{}),r(Ln,{})]})]})]}):u("div",{className:"space-y-4",children:[u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(Hr,{children:"Recording Status"}),u("div",{className:"px-4 py-4 flex items-center justify-between gap-4",children:[u("div",{className:"flex items-center gap-3 min-w-0",children:[r("div",{className:`flex items-center justify-center rounded-full p-2 flex-shrink-0 ${k?"bg-danger/10":"bg-foreground-subtle/10"}`,children:r(sy,{className:`h-5 w-5 ${k?"text-danger animate-pulse":"text-foreground-subtle"}`})}),u("div",{className:"min-w-0",children:[r("p",{className:`text-sm font-medium ${k?"text-danger":"text-foreground-subtle"}`,children:k?"Recording":"Not Recording"}),r("p",{className:"text-[11px] text-foreground-subtle mt-0.5 truncate",children:k&&x?`${x.mode} – ${x.activeStreams} stream(s)`:"No active recording session"})]})]}),r("button",{onClick:D,disabled:S,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors flex-shrink-0 disabled:opacity-50 ${k?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:k?u(ge,{children:[r(Do,{className:"h-3.5 w-3.5"}),S?"Stopping...":"Stop Recording"]}):u(ge,{children:[r(ya,{className:"h-3.5 w-3.5"}),S?"Starting...":"Start Recording"]})})]}),k&&x&&u("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-[11px] text-foreground-subtle",children:[r(Xr,{className:"h-3.5 w-3.5 text-primary flex-shrink-0"}),u("span",{children:[x.activeStreams," active stream",x.activeStreams!==1?"s":""," · mode: ",x.mode]})]})]}),u("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(Hr,{children:u("span",{className:"flex items-center gap-1.5",children:[r(Nt,{className:"h-3.5 w-3.5"}),"Settings"]})}),l.isLoading?u("div",{className:"px-4 py-3 space-y-2",children:[r(At,{className:"h-3 w-32"}),r(At,{className:"h-3 w-40"}),r(At,{className:"h-3 w-28"})]}):u("div",{className:"divide-y divide-border",children:[r(Vr,{label:"Stream",value:c}),r(Vr,{label:"Pre-buffer",value:y?`${y.preBufferSec}s`:"N/A"}),r(Vr,{label:"Mode",value:y?.mode??"continuous"}),r(Vr,{label:"Retention",value:N?.retentionDays!=null?`${N.retentionDays} days`:"N/A"}),N?.retentionGb!=null&&r(Vr,{label:"Max Storage",value:`${N.retentionGb} GB`})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(Hr,{children:u("span",{className:"flex items-center gap-1.5",children:[r(uo,{className:"h-3.5 w-3.5"}),"Storage"]})}),f.isLoading?u("div",{className:"px-4 py-3 space-y-2",children:[r(At,{className:"h-3 w-28"}),r(At,{className:"h-3 w-36"}),r(At,{className:"h-3 w-24"})]}):f.error?u("div",{className:"px-4 py-4 flex items-center gap-2 text-xs text-danger",children:[r(bt,{className:"h-4 w-4"}),"Failed to load storage info"]}):u("div",{className:"px-4 py-3 grid grid-cols-2 gap-3",children:[r(yp,{icon:uo,label:"Total",value:v?.totalBytes!=null?kt(v.totalBytes):"N/A"}),r(yp,{icon:Xr,label:"Segments",value:v?.segmentCount!=null?String(v.segmentCount):"N/A"})]})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"border-b border-border px-4 py-2.5 flex items-center justify-between",children:[r("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"Segment Browser"}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:T,className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:r(Yc,{className:"h-4 w-4"})}),u("div",{className:"flex items-center gap-1.5 text-xs text-foreground font-medium",children:[r(ny,{className:"h-3.5 w-3.5 text-foreground-subtle"}),M?"Today":Bs(n)]}),r("button",{onClick:O,disabled:M,className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:r(It,{className:"h-4 w-4"})})]})]}),u("div",{className:"px-4 py-3 border-b border-border",children:[r(g8,{segments:w,selectedDate:n}),u("div",{className:"flex items-center gap-4 mt-2 text-[10px] text-foreground-subtle",children:[u("span",{children:[w.length," segment",w.length!==1?"s":""]}),A>0&&u("span",{children:[rd(A)," recorded"]}),z>0&&r("span",{children:kt(z)})]})]}),P.length>0&&u("div",{className:"border-b border-border px-4 py-2 flex items-center justify-between",children:[r("button",{onClick:L,className:"text-[11px] text-foreground-subtle hover:text-foreground transition-colors",children:s.size===P.length?"Deselect All":"Select All"}),s.size>0&&u("div",{className:"flex items-center gap-2",children:[u("span",{className:"text-[10px] text-foreground-subtle",children:[s.size," selected"]}),u("button",{className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-medium bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",title:"Download selected",children:[r(Nn,{className:"h-3 w-3"}),"Download"]}),u("button",{className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-medium bg-danger/10 text-danger hover:bg-danger/20 transition-colors",title:"Delete selected",children:[r(Ge,{className:"h-3 w-3"}),"Delete"]})]})]}),d.isLoading?u("div",{className:"divide-y divide-border",children:[r(Ln,{}),r(Ln,{}),r(Ln,{}),r(Ln,{})]}):P.length===0?u("div",{className:"flex flex-col items-center justify-center py-12 text-foreground-subtle",children:[r(Xr,{className:"h-8 w-8 mb-3 opacity-30"}),r("p",{className:"text-sm",children:"No recorded segments"}),r("p",{className:"text-xs mt-1 opacity-70",children:M?"Recorded clips will appear here as they are created":`No recordings found for ${Bs(n)}`})]}):r("div",{className:"max-h-[400px] overflow-y-auto",children:P.map(_=>r(b8,{segment:_,selected:s.has(_.id),onToggle:()=>I(_.id),onPlay:()=>{},onDownload:()=>{},onDelete:()=>{}},_.id))})]}),i.error&&u("div",{className:"rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 flex items-center gap-2 text-xs text-danger",children:[r(bt,{className:"h-4 w-4 flex-shrink-0"}),"Failed to load recording status. Will retry automatically."]}),(g.error||b.error)&&u("div",{className:"rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 flex items-center gap-2 text-xs text-danger",children:[r(bt,{className:"h-4 w-4 flex-shrink-0"}),g.error?`Failed to start recording: ${g.error instanceof Error?g.error.message:"Unknown error"}`:`Failed to stop recording: ${b.error instanceof Error?b.error.message:"Unknown error"}`]})]})}function Vr({label:e,value:t}){return u("div",{className:"flex items-center justify-between px-4 py-2.5",children:[r("span",{className:"text-xs text-foreground-subtle",children:e}),r("span",{className:"text-xs font-medium text-foreground",children:t})]})}function y8({deviceId:e}){const t=ke(),n=Number.isFinite(e),{data:o}=Hn({deviceId:e},{enabled:n}),s=typeof o?.type=="string"?o.type:"camera";xt(["deviceManager","getBindings"],["capability.binding-changed"]);const{data:a,isLoading:i,isError:l,error:c}=Ag({deviceId:e},{staleTime:3e4,enabled:n}),{data:d}=Eg({deviceType:s},{staleTime:3e4,enabled:!!s}),f=Pg({onSuccess:()=>{t.invalidateQueries({queryKey:[["deviceManager","getBindings"]]})}});if(i)return r("div",{className:"p-4",children:r("div",{className:"h-20 rounded-lg border border-border bg-surface animate-pulse"})});if(l)return u("div",{className:"p-4 text-xs text-red-400",children:["Failed to load bindings: ",c instanceof Error?c.message:String(c)]});const p=new Map,m={};for(const b of d??[])m[b.capName]=b.wrappers;for(const b of a?.entries??[])p.set(b.capName,{...b,wrappers:m[b.capName]??[]});for(const b of d??[])p.has(b.capName)||p.set(b.capName,{capName:b.capName,kind:"unbound",providerAddonId:"",providerNodeId:"",nativeAddonId:"",wrappers:b.wrappers});const h=[...p.values()].sort((b,x)=>b.capName.localeCompare(x.capName));if(h.length===0)return u("div",{className:"flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle",children:[r(ba,{className:"h-8 w-8 opacity-40"}),r("p",{className:"text-xs",children:"No capability providers applicable to this device yet."}),r("p",{className:"text-[10px] opacity-60",children:"Native providers show up here as soon as the owning addon registers them."})]});const g=h.filter(b=>b.kind!=="unbound").length;return u("div",{className:"flex flex-col gap-3 p-1",children:[u("div",{className:"text-[11px] text-foreground-subtle",children:[r("span",{className:"font-medium text-foreground",children:g})," ","of ",h.length," capabilit",h.length===1?"y":"ies"," bound — rows marked ",r("em",{children:"unbound"})," have a wrapper available you can activate."]}),r("div",{className:"overflow-hidden rounded-lg border border-border bg-surface",children:u("table",{className:"w-full border-collapse text-[11px]",children:[r("thead",{children:u("tr",{className:"bg-surface-hover/50 text-left text-[10px] uppercase tracking-wide text-foreground-subtle",children:[r("th",{className:"px-3 py-2 font-medium",children:"Capability"}),r("th",{className:"px-3 py-2 font-medium",children:"Kind"}),r("th",{className:"px-3 py-2 font-medium",children:"Active Provider"}),r("th",{className:"px-3 py-2 font-medium",children:"Node"}),r("th",{className:"px-3 py-2 font-medium",children:"Native"}),r("th",{className:"px-3 py-2 font-medium",children:"Wrapper"})]})}),r("tbody",{children:h.map(b=>{const x=b.kind==="wrapped"?b.providerAddonId:null;return u("tr",{className:"border-t border-border align-middle",children:[r("td",{className:"px-3 py-2 font-mono text-foreground",children:b.capName}),r("td",{className:"px-3 py-2",children:r(v8,{kind:b.kind})}),r("td",{className:"px-3 py-2 font-mono text-foreground-subtle",children:b.providerAddonId||r("span",{className:"opacity-40",children:"—"})}),r("td",{className:"px-3 py-2",children:b.providerNodeId?r(w8,{nodeId:b.providerNodeId}):r("span",{className:"text-[10px] opacity-40",children:"—"})}),r("td",{className:"px-3 py-2 font-mono text-foreground-subtle",children:b.nativeAddonId||r("span",{className:"opacity-40",children:"—"})}),r("td",{className:"px-3 py-2",children:r(N8,{wrappers:b.wrappers,activeWrapperId:x,disabled:f.isPending,onPick:y=>{const w=x===y;f.mutate({deviceId:e,capName:b.capName,wrapperAddonId:y,active:!w})}})})]},b.capName)})})]})})]})}function v8({kind:e}){return e==="native"?u("span",{className:"inline-flex items-center gap-1 rounded-md border border-success/30 text-success bg-success/5 px-1.5 py-0.5 text-[10px] font-medium",children:[r(ln,{className:"h-3 w-3"}),"native"]}):e==="wrapped"?u("span",{className:"inline-flex items-center gap-1 rounded-md border border-primary/30 text-primary bg-primary/5 px-1.5 py-0.5 text-[10px] font-medium",children:[r(cL,{className:"h-3 w-3"}),"wrapped"]}):u("span",{className:"inline-flex items-center gap-1 rounded-md border border-border text-foreground-subtle/70 px-1.5 py-0.5 text-[10px] font-medium",children:[r(CL,{className:"h-3 w-3"}),"unbound"]})}function w8({nodeId:e}){return r("span",{className:`inline-flex items-center rounded-md border border-border px-1.5 py-0.5 font-mono text-[10px] ${e==="hub"?"text-foreground-subtle":"text-foreground"}`,children:e})}function N8({wrappers:e,activeWrapperId:t,disabled:n,onPick:o}){return e.length===0?r("span",{className:"text-[10px] opacity-40",children:"none available"}):r("div",{className:"flex flex-wrap gap-1",children:e.map(s=>{const a=s===t;return u("button",{disabled:n,onClick:()=>o(s),title:a?"Click to deactivate (revert to native)":`Activate wrapper ${s}`,className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[10px] transition-colors disabled:opacity-50 ${a?"border-primary/40 bg-primary/10 text-primary":"border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,children:[a?r(Mt,{className:"h-3 w-3"}):r(by,{className:"h-3 w-3"}),s]},s)})})}function k8(e,t){if(!e)return null;for(const n of e.slots)for(const o of n.addons)if(o.id===t)return o;return null}function S8(e,t,n){const o=e?.stepOverridesByAgent?.[t]?.[n];if(o)return o.enabled===!1?"off":(o.enabled===!0,"on");const s=e?.stepToggles?.[n];return s===!1?"off":s===!0?"on":"inherit"}function C8({agents:e,currentAgent:t,onPick:n}){const[o,s]=$(!1);return u("div",{className:"relative",children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:()=>s(a=>!a),children:"Mirror from ▾"}),o&&r("div",{className:"absolute top-full left-0 mt-1 min-w-[140px] bg-surface border border-border rounded shadow-lg z-10",children:e.filter(a=>a!==t).map(a=>r("button",{type:"button",className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted",onClick:()=>{s(!1),n(a)},children:a},a))})]})}function M8({deviceId:e,refreshToken:t}){const n=ke(),[o,s]=$(null),[a,i]=$(null),[l,c]=$(null),[d,f]=$(null),p=Nc({deviceId:e}),m=_r(),h=la({deviceId:e}),g=bb(),b=U(()=>{const L=h.data?.agentNodeId;if(L)return L;const _=g.data?.find(R=>R.online)?.nodeId;return _||"hub"},[h.data?.agentNodeId,g.data]),x=a??b,y=Io({nodeId:x??""},{enabled:!!x}),w=Pb({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),c(null)}}),v=U(()=>y.data?ta(y.data):[],[y.data]),N=U(()=>{const L=p.data??null,_={};for(const R of m.data??[])for(const B of Object.keys(R.settings.addonDefaults)){const F=_[B]??[];F.push({agentNodeId:R.nodeId,state:S8(L,R.nodeId,B)}),_[B]=F}return _},[p.data,m.data]),k=o?k8(y.data??null,o):null,S=x?m.data?.find(L=>L.nodeId===x)??null:null,M=o&&S?S.settings.addonDefaults[o]??null:null,P=o&&x?p.data?.stepOverridesByAgent?.[x]?.[o]??null:null,A=y.data?.selectedEngine.format??"coreml",z=L=>{i(L),c(null),f(null)},D=L=>{s(L),c(null),f(null)},T=L=>{if(!x||!o||!y.data||!m.data)return;const _=m.data.find(F=>F.nodeId===L),R=m.data.find(F=>F.nodeId===x);if(!_||!R)return;const[B]=ym({source:{nodeId:_.nodeId,engine:{format:A},defaults:_.settings.addonDefaults},target:{nodeId:R.nodeId,engine:{format:A},defaults:R.settings.addonDefaults},catalog:y.data,addonIds:[o]});if(!B){f("no mirror result");return}if(B.outcome==="skip"){f(`skipped: ${B.reason??"no candidate"}`);return}c(B.patch),f(`${B.outcome} from ${L}`)},O=()=>{!x||!o||w.mutate({deviceId:e,agentNodeId:x,addonId:o,patch:l})},I=()=>{!x||!o||w.mutate({deviceId:e,agentNodeId:x,addonId:o,patch:null})};return m.isLoading||y.isLoading?r("div",{className:"text-xs text-foreground-subtle animate-pulse p-4",children:"Loading pipeline…"}):y.data?r("div",{className:"@container h-full",style:{containerType:"inline-size"},children:u("div",{className:"flex flex-col @[720px]:flex-row h-full",children:[r("aside",{className:"w-full @[720px]:w-[300px] @[720px]:flex-shrink-0 border-b @[720px]:border-b-0 @[720px]:border-r border-border overflow-y-auto max-h-[40vh] @[720px]:max-h-none",children:r(hh,{tree:v,selectedAddonId:o,onSelect:D,agentDots:N})}),r("section",{className:"flex-1 min-w-0 p-4 overflow-y-auto",children:!o||!k?r("div",{className:"text-sm text-foreground-subtle",children:"Select a step on the left to configure it for this camera."}):u("div",{className:"space-y-4",children:[u("div",{children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Selected step"}),r("div",{className:"text-base font-semibold",children:k.name})]}),u("div",{className:"flex items-end gap-3 flex-wrap",children:[u("div",{children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle mb-1",children:"Agent"}),r("div",{className:"flex rounded border border-border overflow-hidden",children:(m.data??[]).map(L=>r("button",{type:"button",onClick:()=>z(L.nodeId),className:`px-3 py-1 text-xs ${x===L.nodeId?"bg-primary text-primary-foreground":"bg-surface hover:bg-muted"}`,children:L.nodeId},L.nodeId))})]}),r(C8,{agents:(m.data??[]).map(L=>L.nodeId),currentAgent:x,onPick:T}),d&&r("div",{className:"text-[10px] text-foreground-subtle",children:d})]}),M&&r(ra,{mode:"device",addon:k,agentDefault:M,agentNodeId:x??"",currentPatch:l??P,engineFormat:A,onChangePatch:c}),u("div",{className:"flex items-center justify-between gap-2 pt-4 border-t border-border",children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted text-foreground-subtle",disabled:!P||w.isPending,onClick:I,children:"Clear override"}),u("div",{className:"flex items-center gap-2",children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:()=>c(null),children:"Reset draft"}),r("button",{type:"button",className:"px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50",disabled:!x||!o||w.isPending,onClick:O,children:w.isPending?"Saving…":"Save"})]})]})]})})]})}):r("div",{className:"text-xs text-foreground-subtle p-4",children:"Catalog unavailable."})}const I8=[{id:"overview",label:"Overview",cameraOnly:!1},{id:"config",label:"Config",cameraOnly:!1},{id:"pipeline",label:"Pipeline",cameraOnly:!0},{id:"bindings",label:"Bindings",cameraOnly:!0},{id:"recording",label:"Recording",cameraOnly:!0}];function A8(e){const t=e===st.Camera;return I8.filter(n=>t||!n.cameraOnly).map(({id:n,label:o})=>({id:n,label:o}))}const P8=[{id:"logs",icon:Xe,label:"Logs"},{id:"repl",icon:vy,label:"REPL"},{id:"events",icon:$o,label:"Events"},{id:"state",icon:ay,label:"State"},{id:"ptz",icon:EL,label:"PTZ",featureGate:On.PanTiltZoom}];function E8(){const e=Hc(),t=Number(e.deviceId),n=Number.isFinite(t),o=Je(),s=ke(),a=nt(),i=Le(),[l,c]=$("overview"),[d,f]=$("logs"),p="device-detail.left-col-width-px",[m,h]=$(()=>{if(typeof window>"u")return null;const de=window.localStorage.getItem(p),ce=de?Number(de):NaN;return Number.isFinite(ce)&&ce>0?ce:null}),g=ne(m);g.current=m;function b(de){de.preventDefault();const ce=de.clientX,Se=de.currentTarget.previousElementSibling?.getBoundingClientRect().width??m??0,pe=280,Ie=Math.max(pe+50,Math.floor(window.innerWidth*.7)),Te=rt=>{const sr=Math.max(pe,Math.min(Ie,Se+(rt.clientX-ce)));h(sr)},We=()=>{document.removeEventListener("mousemove",Te),document.removeEventListener("mouseup",We);const rt=g.current;if(rt!==null)try{window.localStorage.setItem(p,String(Math.round(rt)))}catch{}document.body.style.userSelect="",document.body.style.cursor=""};document.body.style.userSelect="none",document.body.style.cursor="col-resize",document.addEventListener("mousemove",Te),document.addEventListener("mouseup",We)}const{data:x,isLoading:y,isError:w}=Hn({deviceId:t},{enabled:n,refetchInterval:5e3,retry:1}),{data:v}=hc({deviceId:t},{enabled:n,staleTime:3e4}),N=U(()=>{const de=v?.settings?.sections??[],ce=v?.live?.sections??[],Se=[...de,...ce],pe=new Set;for(const Ie of Se)Ie.location==="top-tab"&&Ie.tab&&pe.add(Ie.tab);return[...pe].map(Ie=>{const Te=Di[Ie];return{id:Ie,label:Te?.label??Ie,isAddonContrib:!0}})},[v]),k=x,S=String(k?.name??e.deviceId??"Device"),M=k?.online===!0,P=M?"online":"offline",A=String(k?.addonId??"rtsp"),z=k?.features??[],D=k?.type,T=D===st.Camera,O=typeof k?.parentDeviceId=="number"?k.parentDeviceId:null,{data:I}=Hn({deviceId:O??0},{enabled:O!==null,staleTime:3e4}),L=er(),_=U(()=>[...A8(D),...N],[D,N]),{data:R}=Vy(n?t:0),B=(R??[]).length>0,F=U(()=>P8.filter(({featureGate:de})=>!de||z.includes(de)),[z]),{data:j}=Rg({addonId:A},{enabled:!!A&&A!=="rtsp"}),H=Ig({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]}),o(j?.id?`/integrations/${j.id}`:"/integrations")}}),E=Cg({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),Q=Mg({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),K=Bb(),Y=sa({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),re=z.includes(On.Rebootable),te=z.includes(On.BatteryOperated),X=nc(i.trpcClient,te&&n?t:null),[oe,be]=$(!1),J=St(i.trpcClient,n?t:null),G=async()=>{if(!(oe||!J)){be(!0);try{await J.snapshot?.invalidateCache({});const de=await J.snapshot?.getSnapshot({});if(!de)return;const ce=`data:${de.contentType};base64,${de.base64}`,Se=de.contentType.includes("png")?"png":"jpg",pe=S.replace(/[^a-zA-Z0-9_.-]+/g,"_"),Ie=new Date().toISOString().replace(/[:.]/g,"-"),Te=document.createElement("a");Te.href=ce,Te.download=`${pe}-${Ie}.${Se}`,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te)}finally{be(!1)}}},ee=E.isPending||Q.isPending,{data:ae}=la({deviceId:t},{enabled:n,refetchInterval:1e4}),fe=ae?.agentNodeId??null,V=typeof fe=="string"&&fe.length>0&&!fe.startsWith("addon:")?fe:void 0,{data:ie}=kc({deviceId:t,...V?{nodeId:V}:{}},{enabled:n,refetchInterval:3e3,retry:!1});function ue(){if(!n)return null;switch(l){case"overview":return r(WO,{device:k??{}});case"config":return r(r8,{deviceId:t});case"pipeline":return r(M8,{deviceId:t,refreshToken:0});case"bindings":return r(y8,{deviceId:t});case"recording":return r(x8,{deviceId:t});default:{const de=l;return N.some(Se=>Se.id===de)?r(t0,{deviceId:t,sectionFilter:Se=>Se.location==="top-tab"&&Se.tab===de}):null}}}return n?y?u("div",{className:"flex flex-col h-full",children:[u("div",{className:"border-b border-border bg-surface px-6 py-4",children:[r("div",{className:"h-4 w-48 rounded bg-surface-hover animate-pulse mb-3"}),r("div",{className:"h-8 w-64 rounded bg-surface-hover animate-pulse"})]}),r("div",{className:"flex-1 p-6",children:r("div",{className:"h-40 rounded-lg border border-border bg-surface animate-pulse"})})]}):w||!x?u("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle",children:[r("p",{className:"text-lg font-semibold text-foreground",children:"Device not found"}),u("p",{className:"text-xs",children:["No device with ID ",u("code",{className:"font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]",children:["#",t]})]}),r("button",{onClick:()=>o("/integrations"),className:"mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors",children:"Back to Integrations"})]}):u("div",{className:"absolute inset-0 flex flex-col overflow-hidden",children:[u("div",{className:"border-b border-border bg-surface px-6 py-3 flex-shrink-0",children:[r("div",{className:"mb-2",children:r(Yl,{items:[{label:"Integrations",onClick:()=>o("/integrations")},{label:j?.name??A,onClick:()=>j?.id&&o(`/integrations/${j.id}`)},{label:S}]})}),u("div",{className:"flex items-center gap-2 sm:gap-3",children:[r(cn,{type:A,size:"lg"}),u("div",{className:"min-w-0 flex-1",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("h1",{className:"text-sm sm:text-base font-semibold text-foreground truncate",children:S}),r(ka,{status:P}),te&&r(oc,{status:X,variant:"full"})]}),O!==null&&I&&u("button",{type:"button",onClick:()=>o(`/devices/${O}`),className:"text-[10px] text-foreground-subtle hover:text-primary transition-colors mt-0.5 inline-flex items-center gap-1",title:`Open parent device ${I.name}`,children:[r("span",{children:"↑"}),r("span",{className:"truncate",children:String(I.name??`Device #${O}`)})]}),r("div",{className:"hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle",children:z.length>0&&r(wa,{capabilities:z})})]}),ie&&r("div",{className:"hidden lg:flex",children:r($8,{metrics:ie})}),u("div",{className:"flex items-center gap-1 shrink-0",children:[u("button",{onClick:async()=>{await a({title:`Disable "${S}"?`,message:"The device will stop processing streams and events. You can re-enable it later.",confirmLabel:"Disable",variant:"danger"})&&Q.mutate({deviceId:t})},disabled:ee,title:"Disable device",className:"inline-flex items-center gap-1.5 rounded-lg px-2 sm:px-2.5 py-1.5 text-[11px] font-medium border transition-colors disabled:opacity-50 border-success/30 text-success hover:bg-success/10",children:[r(gy,{className:"h-3.5 w-3.5"}),r("span",{className:"hidden sm:inline",children:ee?"Updating…":"Enabled"})]}),r("div",{className:"hidden sm:block h-5 w-px bg-border mx-1"}),r($x,{triggerClassName:"ml-1",items:[{id:"snapshot",label:"Take snapshot",description:"Fetch a fresh frame and download it.",icon:xr,disabled:oe,onClick:()=>{G()}},{id:"reboot",label:"Reboot device",description:"Camera goes offline for ~30 seconds.",icon:gt,hidden:!re,disabled:K.isPending,danger:!0,onClick:async()=>{await a({title:`Reboot "${S}"?`,message:"The camera will go offline for around 30 seconds while the firmware reboots.",confirmLabel:"Reboot",variant:"danger"})&&K.mutate({deviceId:t})}},{id:"restart-addon",label:"Restart addon",description:`Bounces every device served by ${j?.name??A}.`,icon:ut,disabled:Y.isPending,danger:!0,onClick:async()=>{await a({title:`Restart "${j?.name??A}"?`,message:`Restarting the addon will briefly disconnect every device served by it (not just "${S}"). Streams will reconnect automatically.`,confirmLabel:"Restart",variant:"danger"})&&Y.mutate({addonId:A})}},{id:"delete",label:"Delete device",description:"Remove the device and all its settings.",icon:Ge,separatorBefore:!0,disabled:H.isPending,danger:!0,onClick:async()=>{await a({title:`Delete "${S}"?`,message:"This will remove the device and all its settings. This action cannot be undone.",confirmLabel:"Delete",variant:"danger"})&&H.mutate({deviceId:t})}}]})]})]})]}),r(qh,{deviceId:t,device:k??void 0,children:r(Sx,{children:r(Dx,{children:u("main",{className:L?"flex-1 overflow-y-auto flex flex-col":"flex-1 min-h-0 overflow-hidden flex flex-row",children:[u("div",{className:L?"flex flex-col bg-surface":`${m===null?"w-1/2 lg:w-1/3":""} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-hidden`,style:!L&&m!==null?{width:`${String(m)}px`}:void 0,children:[r("div",{className:`flex-shrink-0 border-b border-border-subtle ${T?"aspect-video bg-black":"bg-surface"}`,children:T?r(HO,{deviceId:t,intercomAvailable:z.includes(On.TwoWayAudio)}):r(f8,{deviceId:t,deviceName:S,deviceType:D??"unknown",provider:A,isOnline:M,features:z})}),u("div",{className:L?"flex flex-col border-b border-border":"flex-1 min-h-0 flex flex-col overflow-hidden",children:[r("div",{className:"flex-shrink-0 border-b border-border-subtle px-2 py-1.5",children:r("div",{className:"flex gap-1 overflow-x-auto -mx-1 px-1 pb-0.5",children:F.map(({id:de,label:ce,icon:Se})=>u("button",{onClick:()=>f(de),title:ce,className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors flex-shrink-0 ${d===de?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,children:[r(Se,{className:"h-3 w-3"}),ce]},de))})}),u("div",{className:L?"h-72 overflow-hidden":"flex-1 min-h-0 overflow-hidden",children:[d==="logs"&&r(VO,{deviceId:t}),d==="repl"&&r(qO,{deviceId:t}),d==="events"&&r(QO,{deviceId:t}),d==="state"&&r(KO,{deviceId:t}),d==="ptz"&&r(UO,{deviceId:t})]})]})]}),!L&&r("div",{role:"separator","aria-orientation":"vertical",title:"Drag to resize",onMouseDown:b,className:"flex-shrink-0 w-1 cursor-col-resize bg-border hover:bg-primary/40 transition-colors group relative z-10",children:r("span",{className:"absolute inset-y-0 -left-1 -right-1"})}),u("div",{className:L?"flex flex-col":"flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden",children:[r("div",{className:"flex-shrink-0 border-b border-border bg-surface px-4",children:r("div",{className:"flex flex-wrap items-center gap-0",children:_.map(de=>{const ce=l===de.id;return u("button",{onClick:()=>c(de.id),className:`relative flex-shrink-0 px-3 py-2 text-xs font-medium transition-colors ${ce?"text-primary":"text-foreground-subtle hover:text-foreground"}`,children:[de.label,ce&&r("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 rounded-full bg-primary"})]},de.id)})})}),u("div",{className:L?"p-3 flex flex-col gap-3":"flex-1 min-h-0 overflow-y-auto p-4 flex flex-col gap-3",children:[l==="overview"&&B&&r(GO,{parentDeviceId:t}),ue()]})]})]})})})})]}):u("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle",children:[r("p",{className:"text-lg font-semibold text-foreground",children:"Invalid device id"}),u("p",{className:"text-xs",children:["The URL segment ",r("code",{className:"font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]",children:e.deviceId})," is not a number."]}),r("button",{onClick:()=>o("/integrations"),className:"mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors",children:"Back to Integrations"})]})}function $8({metrics:e}){const t=e.phase??"idle",n=Zn(t);return u("div",{className:"flex items-center gap-3 flex-shrink-0",children:[u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:`h-1.5 w-1.5 rounded-full ${n.dotClass}`}),r("span",{className:`text-[10px] font-medium ${n.textColor}`,children:n.label})]}),r("div",{className:"h-3 w-px bg-border"}),u("div",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle",children:[r(Eo,{className:"h-3 w-3"}),r("span",{className:"text-foreground tabular-nums",children:(e.actualFps??0).toFixed(1)}),r("span",{children:"fps"})]}),u("div",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle",children:[r(dt,{className:"h-3 w-3"}),r("span",{className:"text-foreground tabular-nums",children:(e.avgInferenceTimeMs??0).toFixed(0)}),r("span",{children:"ms"})]}),(e.queueDepth??0)>0&&u("span",{className:"text-[10px] text-warning tabular-nums",children:["q:",e.queueDepth]})]})}function _8({packageName:e,currentVersion:t,installSource:n,onInstall:o,onClose:s}){const a=n==="upload"||n==="local",{data:i,isLoading:l}=Yh({name:e},{staleTime:5*6e4});return u("div",{className:"fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden",style:{top:"auto",bottom:"auto"},ref:c=>{if(!c)return;const d=c.parentElement?.getBoundingClientRect();if(!d)return;const f=window.innerHeight-d.bottom,p=d.top;f<280&&p>f?(c.style.bottom=`${window.innerHeight-d.top+4}px`,c.style.top="auto"):(c.style.top=`${d.bottom+4}px`,c.style.bottom="auto"),c.style.right=`${window.innerWidth-d.right}px`},onClick:c=>c.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Versions"}),r("button",{type:"button",onClick:s,className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-3 w-3"})})]}),a&&u("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]",children:[r(va,{className:"h-3 w-3 mt-0.5 text-cyan-500 shrink-0"}),u("div",{className:"text-cyan-700 dark:text-cyan-200",children:[u("span",{className:"font-semibold",children:[n==="upload"?"Uploaded copy":"Local copy"," in place."]})," ","Re-install ",r("span",{className:"font-mono",children:t})," from npm to track upstream releases again."]})]}),l&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle",children:[r(Ae,{className:"h-3.5 w-3.5 animate-spin"}),"Loading versions..."]}),i&&r("div",{className:"max-h-64 overflow-auto divide-y divide-border",children:i.map(c=>{const d=c.version===t,f=/-(alpha|beta|rc|dev|canary|next)/i.test(c.version);return u("div",{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${d?"bg-primary/5":"hover:bg-surface-hover"} transition-colors`,children:[r("span",{className:`font-mono flex-1 ${d?"text-primary font-semibold":f?"text-amber-400":"text-foreground"}`,children:c.version}),c.distTags.map(p=>r("span",{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${p==="latest"?"bg-emerald-500/15 text-emerald-400":p==="beta"?"bg-amber-500/15 text-amber-400":"bg-gray-500/15 text-gray-400"}`,children:p},p)),c.deprecated&&r("span",{className:"text-[9px] text-red-400 line-through",children:"deprecated"}),r("span",{className:"text-[9px] text-foreground-subtle shrink-0",children:new Date(c.publishedAt).toLocaleDateString()}),d&&!a?r(Mt,{className:"h-3 w-3 text-primary shrink-0"}):r("button",{type:"button",onClick:()=>o(c.version),className:"shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors",title:d?`Re-install ${c.version} from npm`:`Install ${c.version}`,children:r(Nn,{className:"h-3 w-3"})})]},c.version)})}),i&&i.length===0&&r("div",{className:"py-4 text-center text-[10px] text-foreground-subtle",children:"No versions found"})]})}function D8({isBundle:e,installSource:t}){return u("div",{className:"relative flex-shrink-0",children:[r("div",{className:`h-9 w-9 rounded-lg flex items-center justify-center ${e?"bg-indigo-500/20 text-indigo-700 dark:text-indigo-300":"bg-purple-500/20 text-purple-700 dark:text-purple-300"}`,children:e?r(my,{className:"h-4 w-4"}):r(Ds,{className:"h-4 w-4"})}),t==="local"&&r("span",{className:"absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm",children:"DEV"}),t==="npm"&&r("span",{className:"absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm",children:r("svg",{viewBox:"0 0 780 250",className:"w-[11px] h-[11px]",children:r("path",{fill:"#fff",d:"M240 250h100V50h100v200h340V0H0v250z"})})}),t==="upload"&&r("span",{className:"absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm",children:r(va,{className:"h-2.5 w-2.5 text-white"})})]})}function L8({addonId:e}){const t=ke(),{data:n="inherit"}=Jh({addonId:e},{staleTime:3e4}),o=eg({onSuccess:()=>{t.invalidateQueries({queryKey:[["addons","getAddonAutoUpdate"]]})}});return r("div",{className:"flex rounded-lg border border-border overflow-hidden text-[10px] font-medium",children:["inherit","off","latest","beta"].map(s=>r("button",{type:"button",onClick:a=>{a.stopPropagation(),o.mutate({addonId:e,channel:s})},disabled:o.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===s?s==="inherit"?"bg-gray-700/50 text-gray-700 dark:text-gray-300":s==="off"?"bg-gray-700 text-gray-700 dark:text-gray-300":s==="latest"?"bg-blue-500/20 text-blue-400":"bg-amber-500/20 text-amber-400":"bg-transparent text-foreground-subtle hover:bg-surface-hover"} ${s!=="inherit"?"border-l border-border":""}`,children:s},s))})}function fl({addon:e,agents:t=[],clusterStatus:n,hideVersion:o,availableUpdate:s,onUpdate:a,isUpdating:i,bundle:l}){const[c,d]=$(!1),[f,p]=$(!1),[m,h]=$(!1),[g,b]=$(!1),[x,y]=$(!1),[w,v]=$("logs"),N=ke(),k=nt(),{manifest:S}=e,M=e.installedOn??[],P=!l&&!S.protected&&S.removable!==!1,A=!!l,z=l?.displayName??S.name,D=l?.packageName??S.packageName,T=l?.version??S.packageVersion??S.version,O=l?.installSource??e.installSource,I=l?l.bundle?.description??l.addons[0]?.manifest.description:S.description;!l&&(S.components&&S.components.length>0||t.length>=2);const L=Uh({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]})}}),_=sa({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]})}}),R=cc({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]}),N.invalidateQueries({queryKey:[["integrations"]]})}}),B=Zh({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["alerts"]]})}}),F=e.health,j=F?.phase==="failed"&&!F.inGracePeriod,H=j&&F?.nextRetryAt&&!F.retrying;return u("div",{className:`rounded-lg border bg-surface overflow-hidden ${j?"border-red-500/50":"border-border"}`,children:[j&&F&&u("div",{className:"bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5",children:[r(DL,{className:"h-4 w-4 text-danger shrink-0 mt-0.5"}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"text-xs font-semibold text-danger",children:["Failed to load (attempt #",F.retryCount,")"]}),r("div",{className:"text-[11px] text-foreground mt-0.5 break-words font-mono",children:F.lastError?.message??"Unknown error"}),H&&F.nextRetryAt&&u("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["Auto-retry at ",new Date(F.nextRetryAt).toLocaleTimeString()]})]}),u("button",{type:"button",disabled:B.isPending||F.retrying,onClick:E=>{E.stopPropagation(),B.mutate({packageName:D})},className:"inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0",title:"Reset retry counter and force immediate reload",children:[r(ut,{className:`h-3 w-3 ${B.isPending||F.retrying?"animate-spin":""}`}),"Retry now"]})]}),u("div",{className:"flex items-start gap-3 px-4 py-3",children:[r(D8,{isBundle:A||!!S.components&&S.components.length>1,installSource:O}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-sm font-semibold text-foreground truncate",children:z}),u("span",{className:"text-[10px] text-foreground-subtle font-mono shrink-0",children:["(",D,")"]}),A&&u("span",{className:"text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1",children:[r(my,{className:"h-3 w-3"}),l.addons.length]})]}),I&&r("p",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-1",children:I}),!A&&e.process&&u("div",{className:"flex items-center gap-1.5 mt-1",children:[r("span",{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode==="forked"?"bg-blue-500/15 text-blue-400":"bg-gray-500/15 text-gray-400"}`,children:e.process.mode==="forked"?"forked":"in-process"}),e.process.pid!=null&&u("span",{className:"text-[9px] font-mono text-foreground-subtle",children:["PID ",e.process.pid]}),r("span",{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state==="running"?"bg-emerald-500/15 text-emerald-400":e.process.state==="crashed"?"bg-red-500/15 text-red-400":"bg-gray-500/15 text-gray-400"}`,children:e.process.state})]})]}),!o&&u("div",{className:"relative inline-flex items-center gap-1.5 shrink-0 pt-0.5",children:[i?u("span",{className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400",children:[r(Ae,{className:"h-3 w-3 animate-spin"}),"Updating to ",s,"…"]}):s&&a?u("button",{type:"button",onClick:E=>{E.stopPropagation(),a()},className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-semibold border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors animate-pulse",title:`Update to ${s}`,children:[r(Nn,{className:"h-3 w-3"}),s]}):null,u("button",{type:"button",onClick:E=>{E.stopPropagation(),h(Q=>!Q)},className:["inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-bold font-mono border transition-colors",O==="local"?"border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20":s?"border-amber-500/30 bg-amber-500/10 text-amber-400 hover:bg-amber-500/20":"border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20"].join(" "),title:s?`Current ${T} — newer ${s} available`:"View all versions",children:[T,r(vt,{className:"h-3 w-3 opacity-50"})]}),m&&r(_8,{packageName:D,currentVersion:T,...O?{installSource:O}:{},onInstall:E=>{h(!1),R.mutate({packageName:D,version:E})},onClose:()=>h(!1)})]})]}),!A&&u("div",{className:"flex items-center gap-1 px-4 py-1.5 border-t border-border/50 bg-surface-hover/20",children:[u("button",{type:"button",onClick:E=>{E.stopPropagation(),_.mutate({addonId:S.id})},disabled:_.isPending,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors",children:[r(ut,{className:`h-3 w-3 ${_.isPending?"animate-spin":""}`}),"Restart"]}),u("button",{type:"button",onClick:E=>{E.stopPropagation(),b(Q=>!Q)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${g?"border-primary/30 bg-primary/10 text-primary":"border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10"}`,children:[r(Xe,{className:"h-3 w-3"}),"Logs"]}),!A&&u("button",{type:"button",onClick:E=>{E.stopPropagation(),y(!0)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${x?"border-primary/30 bg-primary/10 text-primary":"border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10"}`,children:[r(Nt,{className:"h-3 w-3"}),"Settings"]}),r("div",{className:"flex-1"}),P&&u("button",{type:"button",onClick:async E=>{E.stopPropagation(),await k({title:`Uninstall ${S.name}?`,message:"This will remove the addon package and all its data. This action cannot be undone.",confirmLabel:"Uninstall",variant:"danger"})&&L.mutate({packageName:S.packageName})},disabled:L.isPending,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors",children:[r(Ge,{className:"h-3 w-3"}),L.isPending?"Removing...":"Uninstall"]})]}),n&&n.nodes.length>1&&!A&&u("div",{className:"border-t border-border px-4 py-2 bg-muted/10",children:[r("div",{className:"text-[10px] font-medium text-foreground-subtle mb-1.5",children:"Cluster Deployment"}),r("div",{className:"space-y-1",children:n.nodes.map(E=>u("div",{className:"flex items-center gap-2 text-[10px]",children:[r("div",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${E.status==="offline"?"bg-muted-foreground/30":E.synced?"bg-success":"bg-amber-500"}`}),r("span",{className:"font-medium text-foreground min-w-[60px]",children:E.name}),r("span",{className:"font-mono text-foreground-subtle",children:E.version}),!E.synced&&E.status!=="offline"&&r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"outdated"}),E.status==="offline"&&r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground",children:"offline"}),E.synced&&E.status!=="offline"&&r("span",{className:"text-[9px] text-success",children:"synced"})]},E.nodeId))})]}),g&&!A&&u("div",{className:"border-t border-border",children:[u("div",{className:"flex items-center px-4 py-1 bg-surface-hover/20 border-b border-border/50",children:[u("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:[r("button",{type:"button",onClick:()=>v("logs"),className:`px-2 py-0.5 transition-colors ${w==="logs"?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover"}`,children:"Logs"}),r("button",{type:"button",onClick:()=>v("events"),className:`px-2 py-0.5 border-l border-border transition-colors ${w==="events"?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover"}`,children:"Events"})]}),r("div",{className:"flex-1"}),r("button",{type:"button",onClick:E=>{E.stopPropagation(),b(!1)},className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-3.5 w-3.5"})})]}),w==="logs"&&r(Wt,{addonId:S.id,maxHeight:"max-h-64",showFilters:!1}),w==="events"&&r(or,{addonId:S.id,category:"addon.*",maxHeight:"max-h-64"})]}),A&&u(ge,{children:[r("button",{type:"button",onClick:()=>d(E=>!E),className:"w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors",children:c?r(MD,{className:"h-3.5 w-3.5 text-foreground-subtle"}):r(vt,{className:"h-3.5 w-3.5 text-foreground-subtle"})}),c&&r("div",{className:"border-t border-border px-3 py-2 space-y-2",children:l.addons.map(E=>r(fl,{addon:E,agents:t,hideVersion:!0},E.manifest.id))})]}),x&&!A&&r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:()=>y(!1),children:u("div",{className:"w-full max-w-lg max-h-[80vh] rounded-xl border border-border bg-surface shadow-2xl flex flex-col overflow-hidden",onClick:E=>E.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border flex-shrink-0",children:[u("div",{className:"flex items-center gap-2",children:[r(Nt,{className:"h-4 w-4 text-primary"}),u("h2",{className:"text-sm font-semibold text-foreground",children:[z," Settings"]})]}),r("button",{onClick:()=>y(!1),className:"text-foreground-subtle hover:text-foreground transition-colors p-1 rounded",children:r(Ve,{className:"h-4 w-4"})})]}),u("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[r(Or,{nodeId:"hub",addonIds:[S.id],level:"global"}),O==="npm"&&u("div",{children:[r("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Auto-Update"}),r(L8,{addonId:S.id})]}),S.components&&S.components.length>0&&u("div",{children:[u("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Components (",S.components.length,")"]}),r("div",{className:"flex flex-wrap gap-1",children:S.components.map(E=>r("span",{className:"text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono",children:E},E))})]}),t.length>=2&&u("div",{children:[r("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Installed on"}),u("div",{className:"flex items-center gap-1.5 flex-wrap",children:[M.length===0&&r("span",{className:"text-[10px] text-foreground-subtle",children:"Hub (local)"}),M.map(E=>r("span",{className:"rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle",children:E},E)),u("div",{className:"relative",children:[u("button",{type:"button",onClick:E=>{E.stopPropagation(),p(Q=>!Q)},className:"inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:border-primary transition-colors",title:"Install on more agents",children:[r(wt,{className:"h-3 w-3"}),"Add agent"]}),f&&u("div",{className:"absolute left-0 top-full mt-1 z-10 min-w-[160px] rounded-md border border-border bg-surface shadow-lg overflow-hidden",children:[t.filter(E=>!E.isHub&&!M.includes(E.name)).map(E=>r("button",{type:"button",onClick:Q=>{Q.stopPropagation(),p(!1)},className:"w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors",children:E.name},E.id)),t.filter(E=>!E.isHub&&!M.includes(E.name)).length===0&&r("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle",children:"No available agents"})]})]})]})]})]}),r("div",{className:"flex items-center justify-end px-5 py-3 border-t border-border flex-shrink-0",children:r("button",{type:"button",onClick:()=>y(!1),className:"rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:"Close"})})]})})]})}const T8=".tgz,.tar.gz,.zip";function R8({onUploadSuccess:e}){const[t,n]=$(!1),o=ne(null),s=q(async i=>{n(!0);const l=new FormData;l.append("file",i);const c=localStorage.getItem("camstack_admin_token")??"";try{(await(await fetch("/api/addons/upload",{method:"POST",headers:{Authorization:`Bearer ${c}`},body:l})).json()).success&&e()}finally{n(!1)}},[e]),a=q(i=>{const l=i.target.files?.[0];l&&s(l),i.target.value=""},[s]);return u(ge,{children:[r("input",{ref:o,type:"file",accept:T8,onChange:a,className:"hidden"}),u("button",{type:"button",onClick:()=>o.current?.click(),disabled:t,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors",children:[t?r(Ae,{className:"w-3.5 h-3.5 animate-spin"}):r(va,{className:"w-3.5 h-3.5"}),t?"Uploading...":"Upload"]})]})}function O8(e,t){const n=e??"hub-only";return n==="any-node"?!0:n==="hub-only"?t:!t}function z8(e){const t=e;if(!t?.manifest)return null;const n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??"0.0.0",capabilities:t.manifest.capabilities??[]},o=t.process,s=o?{pid:o.pid,mode:o.mode==="forked"?"forked":"in-process",state:o.state??"unknown"}:void 0,a=t.health;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...s?{process:s}:{},hasBackup:t.hasBackup,...a?{health:a}:{}}}function B8(e){const t=new Map,n=[];for(const s of e){const a=s.manifest.packageName;if(!a){n.push(s);continue}const i=t.get(a);if(i)i.addons.push(s);else{const l=s.manifest.bundle,c={packageName:a,displayName:l?.displayName??s.manifest.packageDisplayName??s.manifest.name,version:s.manifest.packageVersion,addons:[s],...s.installSource!==void 0?{installSource:s.installSource}:{},...l!==void 0?{bundle:l}:{}};t.set(a,c)}}const o=[];for(const s of t.values())s.bundle!==void 0||s.addons.length>=2?o.push({bundle:s,representative:s.addons[0]}):o.push(s.addons[0]);return o.push(...n),o}function Xt(e){return"bundle"in e}function F8({addons:e,clusterStatus:t,selectedNode:n,onRefresh:o,isRefreshing:s}){const a=ke(),[i,l]=$(""),c=J1(i),[d,f]=$(!1),p=ne(null);Z(()=>{if(!d)return;const E=Q=>{p.current&&!p.current.contains(Q.target)&&f(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[d]);const{data:m}=dc(void 0,{staleTime:5*6e4}),h=U(()=>{const E=new Map;for(const Q of m??[])E.set(Q.name,Q.latestVersion);return E},[m]),[g,b]=$(null),[x,y]=$(null),w=Ki({onMutate:E=>{b(E.name),y(null)},onSuccess:(E,Q)=>{b(null);const K=E;if(K&&K.success===!1){y({name:Q.name,message:K.error??"Update failed (no error message returned by server)"});return}a.invalidateQueries({queryKey:[["addons"]]}),a.invalidateQueries({queryKey:[["addons","listUpdates"]]})},onError:(E,Q)=>{b(null),y({name:Q.name,message:E instanceof Error?E.message:String(E)})}}),{data:v}=Xh(void 0,{staleTime:3e4}),N=tg({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons","getAutoUpdateSettings"]]})}}),{data:k,isFetching:S}=Kh({query:c||void 0},{enabled:d,staleTime:6e4}),M=Ki(),P=async()=>{const E=m??[];for(const Q of E)await M.mutateAsync({name:Q.name,version:Q.latestVersion});a.invalidateQueries({queryKey:[["addons"]]})},A=cc({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),a.invalidateQueries({queryKey:[["addonPages"]]}),a.invalidateQueries({queryKey:[["capabilities"]]}),a.invalidateQueries({queryKey:[["integrations"]]})}}),[z,D]=$("type"),[T,O]=$(()=>typeof window>"u"?"grouped":window.localStorage.getItem("camstack.addons.viewMode")==="flat"?"flat":"grouped"),I=E=>{O(E),typeof window<"u"&&window.localStorage.setItem("camstack.addons.viewMode",E)},[L,_]=ha(),R=L.get("capability"),B=U(()=>{let E=n.isHub?e:e.filter(Q=>{const K=Q.manifest.execution;return O8(K?.placement,n.isHub)});return R&&(E=E.filter(Q=>(Q.manifest.capabilities??[]).some(Y=>(typeof Y=="string"?Y:Y.name)===R))),E},[e,n.isHub,R]),F=()=>{const E=new URLSearchParams(L);E.delete("capability"),_(E,{replace:!0})},j=T==="flat"?B:B8(B),H=U(()=>{const E=[...j];switch(z){case"type":E.sort((Q,K)=>{const Y=Xt(Q)?0:1,re=Xt(K)?0:1;if(Y!==re)return Y-re;const te=Xt(Q)?Q.bundle.displayName:Q.manifest.name,X=Xt(K)?K.bundle.displayName:K.manifest.name;return te.localeCompare(X)});break;case"name":E.sort((Q,K)=>{const Y=Xt(Q)?Q.bundle.displayName:Q.manifest.name,re=Xt(K)?K.bundle.displayName:K.manifest.name;return Y.localeCompare(re)});break;case"source":E.sort((Q,K)=>{const Y=Xt(Q)?Q.bundle.installSource??"":Q.installSource??"",re=Xt(K)?K.bundle.installSource??"":K.installSource??"";return Y.localeCompare(re)});break}return E},[j,z]);return u("div",{className:"space-y-4",children:[x&&r("div",{className:"rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px]",children:u("div",{className:"flex items-start justify-between gap-3",children:[u("div",{className:"space-y-0.5",children:[u("div",{className:"font-medium text-danger",children:["Failed to update ",x.name]}),r("div",{className:"text-foreground-subtle font-mono",children:x.message})]}),r("button",{type:"button",onClick:()=>y(null),className:"text-foreground-subtle hover:text-foreground text-[10px]",children:"dismiss"})]})}),u("div",{className:"flex items-center gap-2 flex-wrap",children:[u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"text-[10px] text-foreground-subtle",children:"Sort:"}),u("select",{value:z,onChange:E=>D(E.target.value),className:"rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground focus:outline-none focus:border-primary/50",children:[r("option",{value:"type",children:"Bundles first"}),r("option",{value:"name",children:"Name"}),r("option",{value:"source",children:"Install source"})]})]}),u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"text-[10px] text-foreground-subtle",children:"View:"}),r("div",{className:"flex rounded-md border border-border overflow-hidden text-[10px] font-medium",children:["grouped","flat"].map(E=>r("button",{type:"button",onClick:()=>I(E),className:`px-2.5 py-1.5 transition-colors capitalize ${T===E?"bg-primary/10 text-primary":"bg-transparent text-foreground-subtle hover:bg-surface-hover"}`,title:E==="grouped"?"Group multi-addon packages into a bundle card":"Show every addon as its own card",children:E},E))})]}),u("div",{className:"flex items-center gap-1.5",children:[r(ut,{className:"h-3 w-3 text-foreground-subtle"}),r("span",{className:"text-[10px] text-foreground-subtle",children:"Auto-Update:"}),r("div",{className:"flex rounded-md border border-border overflow-hidden text-[10px] font-medium",children:["off","latest","beta"].map(E=>r("button",{type:"button",onClick:()=>N.mutate({channel:E}),disabled:N.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${v?.channel===E?E==="off"?"bg-gray-700 text-gray-200":E==="latest"?"bg-blue-500/20 text-blue-400":"bg-amber-500/20 text-amber-400":"bg-transparent text-foreground-subtle hover:bg-surface-hover"} ${E!=="off"?"border-l border-border":""}`,children:E},E))})]}),(m?.length??0)>0&&u("button",{type:"button",onClick:()=>void P(),disabled:M.isPending,className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/30 disabled:opacity-50 transition-colors font-medium",children:[r(Nn,{className:`w-3 h-3 ${M.isPending?"animate-bounce":""}`}),"Update All (",m.length,")"]}),u("button",{type:"button",onClick:o,disabled:s,className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors",children:[r(ut,{className:`w-3 h-3 ${s?"animate-spin":""}`}),"Refresh"]})]}),u("div",{className:"flex items-center gap-3",children:[u("div",{className:"relative flex-1 min-w-[200px]",ref:p,children:[r(xy,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle"}),r("input",{type:"text",value:i,onChange:E=>{l(E.target.value),f(!0)},onFocus:()=>f(!0),placeholder:"Search addons on npm...",className:"w-full rounded-lg border border-border bg-background pl-9 pr-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"}),S&&r(Ae,{className:"absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin"}),d&&k&&k.length>0&&u("div",{className:"absolute left-0 right-0 top-full mt-1 z-40 rounded-lg border border-border bg-surface shadow-xl overflow-hidden",children:[k.length>0&&u("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border",children:["npm results (",k.length,")"]}),k&&k.length>0&&r("div",{className:"max-h-72 overflow-auto divide-y divide-border",children:k.map(E=>u("div",{className:"flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors",children:[r("div",{className:"w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0",children:E.name.replace("@camstack/addon-","").charAt(0).toUpperCase()}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-[11px] font-semibold truncate",children:E.name}),u("span",{className:"text-[10px] text-foreground-subtle",children:["v",E.version]})]}),E.description&&r("div",{className:"text-[10px] text-foreground-subtle truncate",children:E.description})]}),E.installed?u("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md border border-emerald-500/30 bg-emerald-500/10 text-emerald-400 shrink-0",children:[r(Mt,{className:"h-3 w-3"}),E.installedVersion??"Installed"]}):u("button",{type:"button",onClick:()=>A.mutate({packageName:E.name}),disabled:A.isPending,className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0",children:[A.isPending?r(Ae,{className:"h-3 w-3 animate-spin"}):r(Nn,{className:"h-3 w-3"}),"Install"]})]},E.name))})]})]}),r(R8,{onUploadSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),o()}})]}),R&&u("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/10 border border-primary/30 text-sm",children:[r("span",{className:"text-foreground-subtle",children:"Filtering by capability:"}),r("span",{className:"font-mono text-primary font-semibold",children:R}),r("button",{type:"button",onClick:F,className:"ml-auto text-xs text-foreground-subtle hover:text-foreground underline",children:"Clear"})]}),B.length===0&&r("div",{className:"text-xs text-foreground-subtle",children:e.length===0?"No addons installed":R?`No installed addons declare the "${R}" capability. Browse the npm catalog above to find a compatible addon.`:`No addons compatible with ${n.name} (placement filter active)`}),r("div",{className:"space-y-2",children:H.map(E=>{if(Xt(E)){const Y=E.bundle.packageName,re=h.get(Y);return r(fl,{addon:E.representative,clusterStatus:t?.[E.representative.manifest.id],bundle:E.bundle,availableUpdate:re,isUpdating:g===Y,onUpdate:re?()=>w.mutate({name:Y,version:re}):void 0},Y)}const Q=E.manifest.packageName,K=h.get(Q);return r(fl,{addon:E,clusterStatus:t?.[E.manifest.id],availableUpdate:K,isUpdating:g===Q,onUpdate:K?()=>w.mutate({name:E.manifest.packageName,version:K}):void 0},E.manifest.id)})})]})}function j8(){const e=ke(),{data:t,isLoading:n,isError:o}=oa(),{data:s}=sb(void 0,{staleTime:15e3}),{data:a}=An(void 0,{staleTime:3e4,refetchInterval:1e4}),i=U(()=>{const x=new Map;x.set("hub",{id:"hub",name:"Hub",isHub:!0});for(const y of a??[]){const w=String(y.id??"");w&&x.set(w,{id:w,name:String(y.name??w),isHub:!!y.isHub})}return[...x.values()]},[a]),[l,c]=$("hub"),d=i.find(x=>x.id===l)??i[0],f=Gh(),p=Qh(),m=f.isPending||p.isPending,h=async()=>{await f.mutateAsync(),await p.mutateAsync(),e.invalidateQueries({queryKey:[["addons"]]})},g=ne(f);g.current=f,Z(()=>{g.current.mutate()},[]);const b=(t??[]).map(z8).filter(x=>x!==null);return u("div",{className:"p-6 space-y-5",children:[u("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[u("div",{children:[r("h1",{className:"text-lg font-semibold text-foreground",children:"Addons"}),r("p",{className:"text-xs text-foreground-subtle mt-0.5",children:"Manage installed addons and explore capability providers."})]}),u("div",{className:"flex items-center gap-3 flex-wrap",children:[r(xh,{selectedNodeId:l,onSelect:c}),!n&&!o&&u("span",{className:"text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium",children:[b.length," installed"]}),u("button",{type:"button",onClick:()=>void h(),disabled:m,className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors",title:"Re-fetch addons + check npm for new versions",children:[r(ut,{className:`w-3 h-3 ${m?"animate-spin":""}`}),"Check for updates"]})]})]}),!d.isHub&&u("div",{className:"rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle",children:["Showing only addons compatible with"," ",r("span",{className:"font-medium text-foreground",children:d.name})," ","— agents only run ",r("code",{className:"font-mono",children:"agent-only"})," and"," ",r("code",{className:"font-mono",children:"any-node"})," addons. Install / uninstall is hub-driven; agents auto-sync from the hub."]}),n&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading…"}),o&&r("div",{className:"text-xs text-danger",children:"Failed to load addons"}),!n&&!o&&r(F8,{addons:b,clusterStatus:s,selectedNode:d,onRefresh:()=>void h(),isRefreshing:m})]})}const H8={view:{icon:_o,cls:"bg-foreground-subtle/15 text-foreground-subtle"},create:{icon:Rr,cls:"bg-primary/15 text-primary"},delete:{icon:Ge,cls:"bg-danger/15 text-danger"}};function V8(){const{user:e,logout:t}=fn();if(!e)return r(Rt,{icon:Kt,title:"My access",children:r("div",{className:"text-xs text-foreground-subtle",children:"Not signed in."})});const n=e.role==="admin",o=e.scopes??[];return u(Rt,{icon:Kt,title:"My access",subtitle:`Signed in as ${e.username} (${e.role})`,children:[n&&u("div",{className:"rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5",children:[r(Bn,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),u("div",{children:[r("div",{className:"font-semibold text-foreground",children:"Unrestricted access"}),r("p",{className:"text-foreground-subtle mt-0.5",children:"Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below."})]})]}),o.length===0&&!n&&u("div",{className:"rounded-lg border border-warning/30 bg-warning/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5",children:[r(Bn,{className:"h-4 w-4 text-warning mt-0.5 shrink-0"}),u("div",{children:[r("div",{className:"font-semibold text-foreground",children:"No scopes granted"}),u("p",{className:"text-foreground-subtle mt-0.5",children:["Your account doesn't have any capability or addon grants yet. Every protected endpoint will return 403 until an admin assigns you scopes from ",r("span",{className:"font-mono",children:"/system/users"}),"."]})]})]}),o.length>0&&u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border",children:[r("div",{children:"Type"}),r("div",{children:"Target"}),r("div",{children:"Access"})]}),r("ul",{className:"divide-y divide-border",children:o.map((s,a)=>u("li",{className:"grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs",children:[r("span",{className:"font-mono text-foreground-subtle",children:s.type}),r("span",{className:"font-mono text-foreground",children:s.target}),r("div",{className:"flex items-center gap-1",children:["view","create","delete"].map(i=>{const l=s.access.includes(i),{icon:c,cls:d}=H8[i];return u("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${l?d:"bg-transparent text-foreground-subtle/40 line-through"}`,title:l?`Can ${i}`:`Cannot ${i}`,children:[r(c,{className:"h-3 w-3"}),i]},i)})})]},a))})]}),u("div",{className:"rounded-lg border border-border bg-surface px-4 py-3 text-xs text-foreground-subtle flex items-start gap-2.5",children:[r(Bn,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),u("div",{className:"flex-1",children:[r("div",{className:"font-semibold text-foreground",children:"Updating access"}),u("p",{className:"mt-0.5",children:["Scopes are baked into your session token at login. Changes an admin makes via ",r("span",{className:"font-mono",children:"setUserScopes"})," take effect on your"," ",r("span",{className:"font-medium text-foreground",children:"next login"}),". Sign out and back in to refresh."]})]}),u("button",{onClick:t,className:"inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground transition-colors shrink-0",children:[r(Xc,{className:"h-3 w-3"}),"Sign out"]})]})]})}function q8(){return r(Rt,{icon:Xe,title:"Logs",children:r("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:r(Wt,{limit:500,maxHeight:"max-h-[calc(100vh-250px)]",showScope:!0,showFilters:!0})})})}function od({tabs:e,defaultTab:t}){const[n,o]=ha(),s=n.get("tab"),a=t??e[0]?.id??"",i=e.some(d=>d.id===s)?s:a,l=e.find(d=>d.id===i)??e[0],c=d=>{const f=new URLSearchParams(n);f.set("tab",d),o(f,{replace:!0})};return u("div",{className:"space-y-3",children:[r("div",{className:"flex border-b border-border",children:e.map(d=>{const f=d.icon,p=d.id===i;return u("button",{onClick:()=>c(d.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors ${p?"border-primary text-primary":"border-transparent text-foreground-subtle hover:text-foreground"}`,children:[f&&r(f,{className:"h-3.5 w-3.5"}),d.label]},d.id)})}),r("div",{children:l?.content})]})}const vp={admin:"bg-primary/10 text-primary",viewer:"bg-foreground-subtle/10 text-foreground-subtle"};function U8(){const e=ke(),[t,n]=$(!1),[o,s]=$(""),[a,i]=$(""),[l,c]=$("viewer"),[d,f]=$(null),{data:p,isLoading:m,isError:h}=Cc(),g=nt(),b=()=>e.invalidateQueries({queryKey:[["userManagement","listUsers"]]}),x=rx({onSuccess:()=>{b(),n(!1),s(""),i(""),c("viewer"),f(null)},onError:T=>{f(T instanceof Error?T.message:"Failed to create user")}}),y=sx({onSuccess:b}),w=ox({onSuccess:b}),v=Mc({onSuccess:b}),N=ax({onSuccess:()=>{b(),S(null)}}),[k,S]=$(null),M=p??[];async function P(T){await g({title:"Delete user",message:`Permanently delete user "${T.username}"? This cannot be undone — any active sessions will be revoked on next request.`,confirmLabel:"Delete",variant:"danger"})&&y.mutate({id:T.id})}async function A(T){const O=window.prompt(`New password for "${T.username}":`);if(!O)return;if(O.length<8){window.alert("Password must be at least 8 characters.");return}await g({title:"Reset password",message:`Reset the password for "${T.username}"? They will need to use the new password on their next login.`,confirmLabel:"Reset"})&&v.mutate({id:T.id,newPassword:O})}function z(T,O){O!==T.role&&w.mutate({id:T.id,role:O})}function D(T){return T?new Date(typeof T=="number"?T:String(T)).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):"—"}return u(Rt,{icon:wy,title:"Users",actions:u("button",{onClick:()=>n(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm hover:bg-primary/90",children:[r(wt,{className:"h-3.5 w-3.5"}),"Create User"]}),children:[t&&u("div",{className:"rounded-lg border border-border bg-surface p-4 space-y-3",children:[u("div",{className:"flex items-center justify-between",children:[r("span",{className:"text-xs font-medium text-foreground",children:"New User"}),r("button",{onClick:()=>n(!1),className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-4 w-4"})})]}),u("div",{className:"grid grid-cols-3 gap-3",children:[u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Username"}),r("input",{type:"text",value:o,onChange:T=>s(T.target.value),placeholder:"john",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Password"}),r("input",{type:"password",value:a,onChange:T=>i(T.target.value),placeholder:"••••••••",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Role"}),u("select",{value:l,onChange:T=>c(T.target.value),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"viewer",children:"Viewer"}),r("option",{value:"admin",children:"Admin"})]})]})]}),d&&r("p",{className:"text-[10px] text-danger",children:d}),u("div",{className:"flex justify-end gap-2",children:[r("button",{onClick:()=>n(!1),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),r("button",{onClick:()=>x.mutate({username:o,password:a,role:l}),disabled:x.isPending||!o||!a,className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:x.isPending?"Creating...":"Create"})]})]}),m&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading..."}),h&&r("div",{className:"text-xs text-danger",children:"Failed to load"}),!m&&!h&&M.length===0&&r("div",{className:"text-xs text-foreground-subtle",children:"No data"}),(()=>{const T=I=>y.isPending&&y.variables?.id===I.id||w.isPending&&w.variables?.id===I.id||v.isPending&&v.variables?.id===I.id;return r(fh,{columns:[{key:"username",header:"Username",render:I=>I.username},{key:"role",header:"Role",render:I=>{const L=I.role??"viewer",_=vp[L]??vp.viewer;return u("select",{value:L,onChange:R=>z(I,R.target.value),disabled:T(I),className:`rounded border border-border bg-background px-2 py-0.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 ${_}`,title:"Change role",children:[r("option",{value:"viewer",children:"Viewer"}),r("option",{value:"admin",children:"Admin"})]})}},{key:"scopes",header:"Scopes",render:I=>{if((I.role??"viewer")==="admin")return r("span",{className:"text-[10px] text-foreground-subtle italic",children:"unscoped"});const _=I.scopes??[];return u("button",{onClick:()=>S(I),className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground",title:"Edit scope grants",children:[r(Kt,{className:"h-3 w-3"}),_.length===0?"no access":`${_.length} grant${_.length===1?"":"s"}`]})}},{key:"createdAt",header:"Created",render:I=>r("span",{className:"text-foreground-subtle",children:D(I.createdAt)})},{key:"actions",header:"Actions",align:"right",render:I=>{const L=T(I);return u("div",{className:"flex items-center justify-end gap-1",children:[u("button",{onClick:()=>A(I),disabled:L,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground disabled:opacity-50",title:"Reset password",children:[r(sL,{className:"h-3 w-3"}),"Reset password"]}),u("button",{onClick:()=>P(I),disabled:L,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50",title:"Delete user",children:[L?r(Ae,{className:"h-3 w-3 animate-spin"}):r(Ge,{className:"h-3 w-3"}),"Delete"]})]})}}],rows:M,rowKey:I=>I.id,minWidthPx:560})})(),k&&r(Q8,{user:k,onClose:()=>S(null),onSubmit:T=>N.mutate({userId:k.id,scopes:T}),submitting:N.isPending})]})}function Q8(e){const{user:t}=fn(),n=t?.role==="admin";return r(K8,{...e,callerScopes:n?null:t?.scopes??[]})}function K8({user:e,onClose:t,onSubmit:n,submitting:o,callerScopes:s}){const a=U(()=>(e.scopes??[]).map(d=>({...d,access:[...d.access]})),[e.scopes]),[i,l]=$(a),c=Rc(i);return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:u("div",{className:"w-full max-w-2xl rounded-lg border border-border bg-surface shadow-xl",children:[u("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[u("div",{children:[u("div",{className:"text-sm font-semibold text-foreground",children:["Edit scopes — ",e.username]}),r("div",{className:"text-[10px] text-foreground-subtle",children:e.role==="admin"?"Admin users bypass the scope check; this list is ignored.":"Pick which capabilities this user can call, and which access flavours within each."})]}),r("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-4 w-4"})})]}),u("div",{className:"px-4 py-4",children:[r(Tc,{value:i,onChange:l,clampToParent:s,emptyHint:u(ge,{children:["No scopes granted. ",r("span",{className:"font-medium text-foreground",children:e.username})," cannot call any protected endpoint until a scope is added."]})}),c&&r("p",{className:"mt-2 text-[10px] text-danger",children:c})]}),u("div",{className:"flex items-center justify-end gap-2 border-t border-border px-4 py-3",children:[r("button",{onClick:t,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),r("button",{onClick:()=>n(i),disabled:o||c!==null,className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:o?r(Ae,{className:"h-3 w-3 animate-spin"}):"Save scopes"})]})]})})}const G8={admin:"bg-primary/10 text-primary",viewer:"bg-foreground-subtle/10 text-foreground-subtle",agent:"bg-warning/10 text-warning"};function no(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}function W8(e){return e?e==="*"?"*":e.join(", "):""}function Y8(){const e=ke(),t=nt(),{data:n,isLoading:o}=ix(),{data:s}=Cc(),a=U(()=>n??[],[n]),i=U(()=>s??[],[s]),l=()=>e.invalidateQueries({queryKey:[["userManagement","listApiKeys"]]}),c=()=>e.invalidateQueries({queryKey:[["userManagement","listScopedTokens"]]}),[d,f]=$(!1),[p,m]=$(null),h=lx({onSuccess:l}),g=cx({onSuccess:({token:w,record:v})=>{c(),f(!1),m({token:w,label:v.name})}}),b=dx({onSuccess:c}),x=async(w,v)=>{await t({title:`Revoke "${v}"?`,message:"Any client using this token will lose access immediately. This cannot be undone.",confirmLabel:"Revoke",variant:"danger"})&&h.mutate({id:w})},y=async(w,v)=>{await t({title:`Revoke "${v}"?`,message:"The scoped token will be invalid on its next use.",confirmLabel:"Revoke",variant:"danger"})&&b.mutate({id:w})};return u(Rt,{icon:dy,title:"Tokens",subtitle:"Issue scoped tokens to grant a user a narrow surface — a specific addon, integration, route prefix, or capability. Every token MUST be scoped: revoking it has predictable blast radius.",actions:u("button",{onClick:()=>f(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",disabled:i.length===0,title:i.length===0?"Create a user first":"Issue a scoped token",children:[r(Kt,{className:"h-3.5 w-3.5"}),"New token"]}),children:[u(wp,{title:"Scoped tokens",subtitle:"Grouped per user",children:[i.length===0&&r(X8,{text:"No users yet — scoped tokens are issued on behalf of an existing user."}),i.map(w=>r(J8,{userId:w.id,username:w.username,onRevoke:(v,N)=>{y(v,N)},revokePending:b.isPending,revokeId:b.variables?.id},w.id))]}),a.length>0&&r(wp,{title:"Legacy API keys",subtitle:`${a.length} pre-existing — revoke only`,children:r(s0,{headers:["Label","Role","Prefix","Allowed providers","Created","Last used",""],rows:a.map(w=>{const v=w.role??"viewer",N=h.isPending&&h.variables?.id===w.id;return u("tr",{className:"hover:bg-primary/5",children:[r("td",{className:"px-3 py-2 text-foreground border-b border-border font-medium",children:w.label}),r("td",{className:"px-3 py-2 text-foreground border-b border-border",children:r("span",{className:`inline-block rounded px-2 py-0.5 text-[10px] uppercase tracking-wide ${G8[v]}`,children:v})}),u("td",{className:"px-3 py-2 text-foreground border-b border-border font-mono text-[11px]",children:[w.tokenPrefix,"…"]}),r("td",{className:"px-3 py-2 text-foreground border-b border-border text-foreground-subtle",children:W8(w.allowedProviders)||"all"}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:no(w.createdAt)}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:no(w.lastUsedAt)}),r("td",{className:"px-3 py-2 border-b border-border text-right",children:u("button",{onClick:()=>{x(w.id,w.label)},disabled:N,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50",title:"Revoke",children:[N?r(Ae,{className:"h-3 w-3 animate-spin"}):r(Ge,{className:"h-3 w-3"}),"Revoke"]})})]},w.id)})})}),o&&r(Z8,{}),d&&r(e9,{users:i.map(w=>({id:w.id,username:w.username})),onClose:()=>f(!1),onSubmit:w=>g.mutate({userId:w.userId,name:w.name,scopes:w.scopes,...w.expiresAt!==void 0?{expiresAt:w.expiresAt}:{}}),submitting:g.isPending}),p&&r(t9,{token:p.token,label:p.label,onClose:()=>m(null)})]})}function wp({title:e,subtitle:t,children:n}){return u("div",{className:"space-y-2",children:[u("div",{className:"flex items-baseline justify-between",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:e}),t&&r("span",{className:"text-[10px] text-foreground-subtle",children:t})]}),n]})}function Z8(){return r("div",{className:"space-y-2",children:[1,2].map(e=>r("div",{className:"h-10 rounded border border-border bg-surface animate-pulse"},e))})}function X8({text:e}){return r("div",{className:"rounded border border-dashed border-border bg-surface px-3 py-4 text-xs text-foreground-subtle text-center",children:e})}function s0({headers:e,rows:t}){return r("div",{className:"rounded-lg border border-border bg-surface overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[640px]",children:[r("thead",{children:r("tr",{children:e.map((n,o)=>r("th",{className:`px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border whitespace-nowrap ${o===e.length-1?"text-right":"text-left"}`,children:n},o))})}),r("tbody",{children:t})]})})}function J8({userId:e,username:t,onRevoke:n,revokePending:o,revokeId:s}){const{data:a,isLoading:i}=ux({userId:e}),l=a??[];return i||l.length===0?null:u("div",{className:"space-y-1.5",children:[r("div",{className:"text-[11px] font-medium text-foreground",children:t}),r(s0,{headers:["Name","Prefix","Scopes","Expires","Last used","Created",""],rows:l.map(c=>{const d=o&&s===c.id;return u("tr",{className:"hover:bg-primary/5",children:[r("td",{className:"px-3 py-2 text-foreground border-b border-border font-medium",children:c.name}),u("td",{className:"px-3 py-2 text-foreground border-b border-border font-mono text-[11px]",children:[c.tokenPrefix,"…"]}),r("td",{className:"px-3 py-2 text-foreground border-b border-border",children:r("div",{className:"flex flex-wrap gap-1",children:c.scopes.map((f,p)=>u("span",{className:"inline-block rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-mono",children:[f.type,":",f.target]},p))})}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:no(c.expiresAt)}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:no(c.lastUsedAt)}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:no(c.createdAt)}),r("td",{className:"px-3 py-2 border-b border-border text-right",children:u("button",{onClick:()=>n(c.id,c.name),disabled:d,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50",children:[d?r(Ae,{className:"h-3 w-3 animate-spin"}):r(Ge,{className:"h-3 w-3"}),"Revoke"]})})]},c.id)})})]})}function e9({users:e,onClose:t,onSubmit:n,submitting:o}){const{user:s}=fn(),i=s?.role==="admin"?null:s?.scopes??[],[l,c]=$(e[0]?.id??""),[d,f]=$(""),[p,m]=$([{type:"capability",target:"",access:["view","create"]}]),[h,g]=$(""),b=Rc(p),x=l!==""&&d.trim().length>0&&p.length>0&&b===null&&!o,y=()=>{const w=parseInt(h,10),v=Number.isFinite(w)&&w>0?Date.now()+w*864e5:void 0;n({userId:l,name:d.trim(),scopes:p,expiresAt:v})};return u(a0,{title:"Create scoped token",onClose:t,children:[u("div",{className:"space-y-3",children:[r(os,{label:"On behalf of user",children:r("select",{value:l,onChange:w=>c(w.target.value),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary",children:e.map(w=>r("option",{value:w.id,children:w.username},w.id))})}),r(os,{label:"Name",children:r("input",{value:d,onChange:w=>f(w.target.value),placeholder:"cloudflare-tunnel-route",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary"})}),u(os,{label:"Scopes",hint:"Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.",children:[r(Tc,{value:p,onChange:m,clampToParent:i}),b&&r("p",{className:"mt-1 text-[10px] text-danger",children:b})]}),r(os,{label:"Expires in (days)",hint:"Leave blank for non-expiring.",children:r("input",{type:"number",min:1,value:h,onChange:w=>g(w.target.value),placeholder:"30",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary"})})]}),u(i0,{children:[r("button",{onClick:t,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),u("button",{onClick:y,disabled:!x,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[o?r(Ae,{className:"h-3.5 w-3.5 animate-spin"}):r(Kt,{className:"h-3.5 w-3.5"}),"Issue token"]})]})]})}function t9({token:e,label:t,onClose:n}){const[o,s]=$(!1),a=async()=>{try{await navigator.clipboard.writeText(e),s(!0)}catch{}};return u(a0,{title:`Token: ${t}`,onClose:n,children:[u("div",{className:"space-y-3",children:[r("div",{className:"rounded border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",children:"Copy this token now. Once you close this dialog the secret cannot be displayed again."}),r("div",{className:"rounded border border-border bg-background p-2 font-mono text-[11px] break-all select-all",children:e})]}),u(i0,{children:[u("button",{onClick:()=>{a()},className:"inline-flex items-center gap-1.5 rounded bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30",children:[o?r(Mt,{className:"h-3.5 w-3.5 text-primary"}):r(TD,{className:"h-3.5 w-3.5"}),o?"Copied":"Copy"]}),r("button",{onClick:n,className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:"Done"})]})]})}function a0({title:e,onClose:t,children:n}){return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:t,children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:o=>o.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:e}),r("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-4 w-4"})})]}),r("div",{className:"p-4",children:n})]})})}function i0({children:e}){return r("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:e})}function os({label:e,hint:t,children:n}){return u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:e}),n,t&&r("p",{className:"text-[10px] text-foreground-subtle",children:t})]})}function Ca(e){const{title:t,subtitle:n,pageIcon:o,itemIcon:s,capability:a,installButtonLabel:i="Add addon",items:l,isLoading:c,emptyTitle:d="No addons installed for this capability",emptyDescription:f,itemIconColor:p,renderStatusBadges:m,renderActionButtons:h,renderExpandedBody:g,trailing:b}=e,x=l.length>1,[y,w]=$(()=>l[0]?.addonId??null);Z(()=>{y&&(l.some(k=>k.addonId===y)||w(l[0]?.addonId??null))},[l,y]);const v=k=>w(S=>S===k?null:k),N=a?`/system/addons?capability=${encodeURIComponent(a)}`:null;return r(Rt,{icon:o,title:t,subtitle:n,actions:N?r(co,{to:N,children:u(Ue,{variant:"primary",size:"sm",children:[r(wt,{className:"h-3.5 w-3.5 mr-1"}),i]})}):void 0,children:c?r(rn,{children:r("div",{className:"p-6 text-sm text-foreground-subtle",children:"Loading…"})}):l.length===0?r(rn,{children:r(vh,{title:d,description:f??(N?`Install an addon that declares the "${a}" capability to get started.`:void 0),action:N?r(co,{to:N,children:u(Ue,{variant:"primary",size:"sm",children:[r(wt,{className:"h-3.5 w-3.5 mr-1"}),i]})}):void 0})}):u("div",{className:"flex flex-col gap-4",children:[l.map(k=>{const S=!x||y===k.addonId,M=p?.(k)??"bg-primary/15 text-primary";return u(rn,{children:[u("div",{className:`flex items-center gap-4 p-4 ${S?"border-b border-border":""}`,children:[u("button",{type:"button",onClick:()=>x&&v(k.addonId),className:`flex items-center gap-4 flex-1 min-w-0 text-left ${x?"hover:opacity-80 transition-opacity":""}`,disabled:!x,children:[r("div",{className:`h-10 w-10 rounded-lg flex items-center justify-center shrink-0 ${M}`,children:r(s,{className:"h-5 w-5"})}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"font-semibold text-foreground",children:k.displayName}),m?.(k)]}),u("div",{className:"text-xs text-foreground-subtle mt-1 font-mono",children:["@camstack/addon-",k.addonId]})]}),x&&r(vt,{className:`h-4 w-4 text-foreground-subtle shrink-0 transition-transform ${S?"rotate-180":""}`})]}),h&&r("div",{className:"flex items-center gap-1 shrink-0",children:h(k)})]}),S&&g?.(k)]},k.addonId)}),b]})})}function n9(){const e=pc(),t=e.data??[];return r(Ca,{title:"Authentication",subtitle:"Login providers exposed to the admin UI. Local username + password is always available; OIDC / SAML / LDAP can be added by installing a provider addon.",pageIcon:Kt,itemIcon:Kt,capability:"auth-provider",installButtonLabel:"Add provider",items:t,isLoading:e.isLoading,emptyTitle:"No authentication providers registered",emptyDescription:"Local auth should always be available — if this list is empty, the local-auth builtin failed to register. Check the Addons page for load errors.",renderStatusBadges:n=>n.enabled?null:r("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-red-500/15 text-red-700 dark:text-red-300",children:"Disabled"}),renderExpandedBody:n=>u("div",{className:"p-4 space-y-3",children:[u("div",{className:"text-xs text-foreground-subtle flex flex-wrap items-center gap-3",children:[n.hasCredentialFlow&&r("span",{children:"· username + password"}),n.hasRedirectFlow&&r("span",{children:"· redirect (SSO)"}),!n.hasCredentialFlow&&!n.hasRedirectFlow&&r("span",{children:"· no active flow"})]}),n.status&&r("div",{className:"text-xs text-foreground-subtle",children:n.status}),r("div",{className:"flex justify-end pt-2",children:u(co,{to:`/system/addons?addon=${encodeURIComponent(n.addonId)}`,className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[r(Nt,{className:"h-3.5 w-3.5"}),"Configure",r(ty,{className:"h-3.5 w-3.5"})]})})]})})}function r9(){return r("div",{className:"flex flex-col",children:r("div",{className:"px-6 pt-6",children:r(od,{tabs:[{id:"users",label:"Users",icon:wy,content:r(U8,{})},{id:"api-keys",label:"Tokens",icon:dy,content:r(Y8,{})},{id:"authentication",label:"Authentication",icon:Kt,content:r(n9,{})}]})})})}function sd({addonId:e,defaultActivity:t,showActivity:n=!0,maxHeight:o="max-h-64",defaultTab:s}){const a=t??(s==="events"?"events":"logs"),[i,l]=$(a);return u("div",{className:"flex flex-col gap-4",children:[r(Or,{nodeId:"hub",addonIds:[e],level:"global"}),n&&u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-surface-hover/20",children:[r("span",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Activity"}),u("div",{className:"flex items-center gap-1",children:[r(Np,{kind:"logs",active:i==="logs",onClick:()=>l("logs")}),r(Np,{kind:"events",active:i==="events",onClick:()=>l("events")})]})]}),i==="logs"?r(Wt,{addonId:e,maxHeight:o,showFilters:!1}):r(or,{addonId:e,category:"addon.*",maxHeight:o})]})]})}function Np({kind:e,active:t,onClick:n}){return u("button",{onClick:n,className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${t?"bg-primary/10 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,children:[r(e==="logs"?Xe:$o,{className:"h-3 w-3"}),e==="logs"?"Logs":"Events"]})}function o9(){const e=ke(),t=Kb(void 0,{refetchInterval:5e3}),n=t.data??[],[o,s]=$(null),a=()=>{e.invalidateQueries({queryKey:[["remoteAccess"]]}),s(null)},i=Gb({onSuccess:a,onError:()=>s(null)}),l=Wb({onSuccess:a,onError:()=>s(null)});return r(Ca,{title:"Remote Access",subtitle:"Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …). Settings, Logs and Events are docked under every provider.",pageIcon:yr,itemIcon:yr,capability:"network-access",installButtonLabel:"Add tunnel",items:n,isLoading:t.isLoading,emptyTitle:"No remote-access providers installed",emptyDescription:"Install a tunnel addon (e.g. @camstack/addon-cloudflare-tunnel) to expose this hub publicly.",itemIconColor:c=>c.connected?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle",renderStatusBadges:c=>u(ge,{children:[r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${c.connected?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:c.connected?"Connected":"Disconnected"}),c.endpoint&&u("a",{href:c.endpoint.url,target:"_blank",rel:"noopener noreferrer",onClick:d=>d.stopPropagation(),className:"text-[10px] text-emerald-700 dark:text-emerald-300 hover:underline flex items-center gap-1",children:[r(Zc,{className:"h-3 w-3"}),c.endpoint.url]}),c.error&&r("span",{className:"text-[10px] text-danger",children:c.error})]}),renderActionButtons:c=>{const d=o===c.addonId;return c.connected?u(Ue,{size:"sm",variant:"secondary",disabled:d,onClick:()=>{s(c.addonId),l.mutate({addonId:c.addonId})},children:[d?r(Ae,{className:"h-3 w-3 animate-spin"}):r(Do,{className:"h-3 w-3"}),"Stop"]}):u(Ue,{size:"sm",variant:"primary",disabled:d,onClick:()=>{s(c.addonId),i.mutate({addonId:c.addonId})},children:[d?r(Ae,{className:"h-3 w-3 animate-spin"}):r(ya,{className:"h-3 w-3"}),"Start"]})},renderExpandedBody:c=>r("div",{className:"p-4",children:r(sd,{addonId:c.addonId,maxHeight:"max-h-72"})})})}function s9(){const e=ke(),t=ex(void 0,{refetchInterval:3e4}),n=tx(),o=t.data??[],s=n.data??[],[a,i]=$(null),l=nx({onSuccess:()=>{e.invalidateQueries({queryKey:[["turnOrchestrator"]]}),i(null)},onError:()=>i(null)});return r(Ca,{title:"TURN Servers",subtitle:"ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.",pageIcon:an,itemIcon:an,capability:"turn-provider",installButtonLabel:"Add provider",items:o,isLoading:t.isLoading,emptyTitle:"No TURN providers installed",emptyDescription:"Install a TURN addon (e.g. @camstack/addon-cloudflare-turn) to enable WebRTC behind restrictive NATs.",itemIconColor:c=>c.error?"bg-danger/15 text-danger":c.enabled?"bg-violet-500/15 text-violet-700 dark:text-violet-300":"bg-foreground-subtle/15 text-foreground-subtle",renderStatusBadges:c=>u(ge,{children:[r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${c.enabled?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:c.enabled?"Enabled":"Disabled"}),u("span",{className:"text-[10px] text-foreground-subtle",children:["· ",c.serverCount," server",c.serverCount===1?"":"s"]}),c.error&&r("span",{className:"text-[10px] text-danger",children:c.error})]}),renderActionButtons:c=>{const d=a===c.addonId;return c.enabled?u(Ue,{size:"sm",variant:"secondary",disabled:d,onClick:()=>{i(c.addonId),l.mutate({addonId:c.addonId,enabled:!1})},children:[d?r(Ae,{className:"h-3 w-3 animate-spin"}):r(Do,{className:"h-3 w-3"}),"Disable"]}):u(Ue,{size:"sm",variant:"primary",disabled:d,onClick:()=>{i(c.addonId),l.mutate({addonId:c.addonId,enabled:!0})},children:[d?r(Ae,{className:"h-3 w-3 animate-spin"}):r(ya,{className:"h-3 w-3"}),"Enable"]})},renderExpandedBody:c=>u(ge,{children:[c.urls.length>0&&u("div",{className:"px-4 py-3 border-b border-border",children:[u("div",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide mb-2",children:["Discovered ICE servers (",c.urls.length,")"]}),r("div",{className:"flex flex-wrap gap-1",children:c.urls.map(d=>r("span",{className:"inline-block rounded px-1.5 py-0.5 text-[10px] font-mono bg-foreground-subtle/10 text-foreground",children:d},d))})]}),r("div",{className:"p-4",children:r(sd,{addonId:c.addonId,maxHeight:"max-h-72"})})]}),trailing:u(rn,{children:[u("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[u("div",{children:[r("div",{className:"text-sm font-semibold",children:"Combined ICE server list"}),r("div",{className:"text-xs text-foreground-subtle",children:"What the WebRTC layer fetches per-session."})]}),r(Ue,{size:"sm",variant:"secondary",onClick:()=>n.refetch(),disabled:n.isFetching,children:"Refresh"})]}),r("div",{className:"p-4",children:s.length===0?r("div",{className:"text-xs text-foreground-subtle",children:"No servers from enabled providers."}):r("div",{className:"flex flex-col gap-3",children:s.map((c,d)=>{const f=Array.isArray(c.urls)?c.urls:[c.urls];return u("div",{className:"rounded border border-border bg-surface",children:[(c.username||c.credential)&&u("div",{className:"px-3 py-1.5 border-b border-border text-[10px] font-mono text-foreground-subtle flex items-center gap-3",children:[c.username&&u("span",{children:[r("span",{className:"text-foreground-subtle",children:"user:"})," ",r("span",{className:"text-foreground",children:c.username})]}),c.credential&&u("span",{title:c.credential,children:[r("span",{className:"text-foreground-subtle",children:"credential:"})," ",r("span",{className:"text-foreground",children:`${c.credential.slice(0,8)}…${c.credential.slice(-4)}`})]})]}),r("ul",{className:"divide-y divide-border",children:f.map(p=>r("li",{className:"px-3 py-1.5 font-mono text-xs text-foreground break-all",children:p},p))})]},d)})})})]})})}const a9={lan:an,wifi:Vn,docker:ba,vpn:py,loopback:ln,other:ln},i9={lan:"LAN",wifi:"Wi-Fi",docker:"Docker",vpn:"VPN",loopback:"Loopback",other:"Other"},l9=["lan","wifi","vpn","docker","other","loopback"];function c9(e){const{interfaces:t,disabled:n,hideLoopback:o,ipv4Only:s,emptyMessage:a}=e,i=U(()=>t.filter(f=>!(o&&f.kind==="loopback"||s&&f.family!=="IPv4")),[t,o,s]),l=U(()=>{const f=new Map;for(const p of i){const m=f.get(p.kind)??[];m.push(p),f.set(p.kind,m)}return l9.filter(p=>f.has(p)).map(p=>({kind:p,items:f.get(p)}))},[i]),c=f=>e.mode==="single"?e.value===f:e.value.includes(f),d=f=>{if(n||f.kind==="loopback")return;if(e.mode==="single"){e.onChange(e.value===f.address?null:f.address);return}const p=new Set(e.value);p.has(f.address)?p.delete(f.address):p.add(f.address),e.onChange([...p])};return i.length===0?r("div",{className:"text-xs text-foreground-subtle italic",children:a??"No addresses available."}):r("div",{className:"flex flex-col gap-3",children:l.map(({kind:f,items:p})=>{const m=a9[f]??ln;return u("div",{className:"rounded-md border border-border overflow-hidden",children:[u("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border",children:[r(m,{className:"h-3.5 w-3.5 text-foreground-subtle"}),r("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle",children:i9[f]??f}),u("span",{className:"text-[10px] text-foreground-subtle",children:["· ",p.length]})]}),r("ul",{className:"divide-y divide-border",children:p.map(h=>{const g=c(h.address),b=h.kind==="loopback",x=!h.plausible&&!b;return u("li",{className:`flex items-center gap-3 px-3 py-2 ${b?"opacity-60 cursor-not-allowed":n?"opacity-60":x?"cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]":"cursor-pointer hover:bg-surface-hover/30"}`,onClick:()=>d(h),children:[r("span",{className:`flex items-center justify-center h-4 w-4 rounded ${e.mode==="single"?"rounded-full":"rounded"} border ${g?"border-primary bg-primary text-primary-foreground":"border-border bg-surface"}`,children:g&&r(Mt,{className:"h-3 w-3"})}),u("div",{className:`flex-1 min-w-0 ${x?"text-foreground-subtle":""}`,children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:`font-mono text-xs font-semibold ${x?"text-foreground-subtle":"text-foreground"}`,children:h.name}),r("span",{className:"text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono",children:h.family}),h.preferred&&r("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary",children:"Auto-preferred"}),b&&r("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle",children:"Always included"}),x&&u("span",{className:"inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300",title:h.plausibleReason||void 0,children:[r(bt,{className:"h-2.5 w-2.5"}),"Unlikely usable"]})]}),u("div",{className:"text-xs text-foreground-subtle mt-0.5 font-mono break-all",children:[h.address,h.cidr&&h.cidr!==h.address?` (${h.cidr})`:""]})]})]},`${h.name}-${h.family}-${h.address}`)})})]},f)})})}const kp={"lan-ipv4":"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300","lan-ipv6":"bg-violet-500/15 text-violet-700 dark:text-violet-300",public:"bg-blue-500/15 text-blue-700 dark:text-blue-300",loopback:"bg-foreground-subtle/15 text-foreground-subtle"};function d9(){const e=ke(),t=Le(),n=Ug(void 0,{refetchInterval:3e4}),o=Kg(void 0),s=Gg({onSuccess:()=>{e.invalidateQueries({queryKey:[["localNetwork"]]})}}),a=Wg({onSuccess:S=>{p(S.addresses),e.invalidateQueries({queryKey:[["localNetwork"]]})}}),i=U(()=>n.data?.interfaces??[],[n.data]),l=typeof window<"u"?Number(window.location.port)||(window.location.protocol==="https:"?443:80):4e3,c=typeof window<"u"&&window.location.protocol==="https:"?"https":"http",d=Qg({port:l,scheme:c},{refetchInterval:3e4}),[f,p]=$([]),[m,h]=$(!1);Z(()=>{!m&&o.data&&(p(o.data.addresses),h(!0))},[o.data,m]);const g=o.data?.addresses??[],b=U(()=>{if(f.length!==g.length)return!0;const S=[...f].sort(),M=[...g].sort();return S.some((P,A)=>P!==M[A])},[f,g]),x=()=>{s.mutate({addresses:[...f]})},y=()=>{p(g)},w=()=>{p([])},v=()=>{n.refetch(),d.refetch(),o.refetch()},N=async()=>{try{const S=await t.raceConnectionEndpoints({perCandidateTimeoutMs:1500});console.info("[network-addresses] race result",S)}catch(S){console.warn("[network-addresses] race failed",S)}},k=d.data?.endpoints??[];return r(Rt,{icon:an,title:"Network Addresses",subtitle:"Pick the local addresses SDK clients should race for the fastest path to this hub. Empty selection (auto) lets every non-loopback / non-link-local interface participate.",actions:u("div",{className:"flex items-center gap-2",children:[u(Ue,{size:"sm",variant:"secondary",onClick:v,disabled:n.isLoading,children:[r(ut,{className:`h-3 w-3 ${n.isLoading?"animate-spin":""}`}),"Refresh"]}),r(Ue,{size:"sm",variant:"secondary",onClick:N,children:"Probe race"})]}),children:u("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[u(rn,{children:[u("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[u("div",{children:[r("div",{className:"text-sm font-semibold",children:"Allowed addresses"}),r("div",{className:"text-xs text-foreground-subtle",children:f.length===0?"Auto — every non-loopback / non-link-local interface participates.":`${f.length} pinned`})]}),u("div",{className:"flex items-center gap-1",children:[u(Ue,{size:"sm",variant:"secondary",onClick:()=>a.mutate(void 0),disabled:a.isPending||s.isPending,title:"Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.",children:[r(cT,{className:"h-3 w-3"}),a.isPending?"Detecting…":"Best match"]}),u(Ue,{size:"sm",variant:"secondary",onClick:w,disabled:f.length===0||s.isPending,children:[r(by,{className:"h-3 w-3"}),"Clear"]}),b&&r(Ue,{size:"sm",variant:"secondary",onClick:y,disabled:s.isPending,children:"Discard"}),u(Ue,{size:"sm",variant:"primary",onClick:x,disabled:!b||s.isPending,children:[r(WL,{className:"h-3 w-3"}),s.isPending?"Saving…":"Save"]})]})]}),r("div",{className:"p-4",children:r(c9,{mode:"multiple",interfaces:i,value:f,onChange:p,disabled:s.isPending,emptyMessage:n.isLoading?"Loading interfaces…":"No interfaces detected."})})]}),u(rn,{children:[u("div",{className:"px-4 py-3 border-b border-border",children:[r("div",{className:"text-sm font-semibold",children:"Connection endpoints — priority order"}),r("div",{className:"text-xs text-foreground-subtle",children:"Live preview of the ranked candidate list the SDK would race against. Updates with each Save."})]}),r("div",{className:"p-4",children:k.length===0?r("div",{className:"text-xs text-foreground-subtle italic",children:d.isLoading?"Loading…":"No endpoints available."}):r("ul",{className:"space-y-1 text-xs",children:k.map(S=>u("li",{className:`flex items-center gap-2 flex-wrap ${S.plausible?"":"opacity-80"}`,children:[r("span",{className:"font-mono text-[10px] w-10 text-foreground-subtle",children:String(S.priority).padStart(4,"0")}),r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${kp[S.kind]??kp.loopback}`,children:S.kind}),S.interfaceKind!=="lan"&&S.interfaceKind!=="public"&&r("span",{className:"text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-medium uppercase",children:S.interfaceKind}),!S.plausible&&S.interfaceKind!=="loopback"&&u("span",{className:"inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300",title:S.plausibleReason||void 0,children:[r(bt,{className:"h-2.5 w-2.5"}),"Unlikely usable"]}),r("span",{className:`font-mono break-all ${S.plausible?"text-foreground":"text-foreground-subtle"}`,children:S.baseUrl}),u("span",{className:"text-foreground-subtle",children:["— ",S.label]})]},`${S.priority}-${S.baseUrl}`))})})]})]})})}const u9={mesh:"bg-violet-500/15 text-violet-700 dark:text-violet-300",public:"bg-blue-500/15 text-blue-700 dark:text-blue-300"};function p9(){const e=ke(),t=Yg(void 0,{refetchInterval:5e3}),n=t.data??[],[o,s]=$(null),[a,i]=$({}),[l,c]=$({}),d=()=>{e.invalidateQueries({queryKey:[["meshOrchestrator"]]}),s(null)},f=Zg({onSuccess:d,onError:()=>s(null)}),p=Xg({onSuccess:d,onError:()=>s(null)});return r(Ca,{title:"Mesh Networks",subtitle:"Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).",pageIcon:ba,itemIcon:an,capability:"mesh-network",installButtonLabel:"Add mesh",items:n,isLoading:t.isLoading,emptyTitle:"No mesh-network providers installed",emptyDescription:"Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.",itemIconColor:m=>m.joined?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle",renderStatusBadges:m=>u(ge,{children:[r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${m.joined?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:m.joined?"Joined":"Not joined"}),m.joined&&u("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle",children:[m.peerCount," peer",m.peerCount===1?"":"s"]})]}),renderActionButtons:m=>{const h=o===m.addonId;return m.joined?u(Ue,{size:"sm",variant:"secondary",disabled:h,onClick:()=>{s(m.addonId),p.mutate({addonId:m.addonId})},children:[h?r(Ae,{className:"h-3 w-3 animate-spin"}):r(Xc,{className:"h-3 w-3"}),"Leave"]}):null},renderExpandedBody:m=>{const h=o===m.addonId,g=a[m.addonId]??"",b=l[m.addonId]??"",x=g.trim().length>=8;return u(ge,{children:[m.joined?u("div",{className:"p-4 space-y-3",children:[u("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[m.meshIp&&u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"text-foreground-subtle",children:"Mesh IP:"}),r("span",{className:"font-mono text-foreground",children:m.meshIp})]}),m.magicDnsHostname&&u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"text-foreground-subtle",children:"MagicDNS:"}),r("span",{className:"font-mono text-foreground break-all",children:m.magicDnsHostname})]})]}),m.endpoints.length>0&&u("div",{className:"flex flex-col gap-1",children:[r("div",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Endpoints"}),m.endpoints.map(y=>u("div",{className:"flex items-center gap-2 text-xs",children:[u("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${u9[y.scope]??"bg-foreground-subtle/15 text-foreground-subtle"}`,children:[y.scope==="public"?r(yr,{className:"inline h-2.5 w-2.5 mr-0.5"}):null,y.label]}),u("a",{href:y.url,target:"_blank",rel:"noopener noreferrer",onClick:w=>w.stopPropagation(),className:"text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1",children:[r(Zc,{className:"h-3 w-3 shrink-0"}),y.url]})]},y.id))]}),m.error&&r("div",{className:"text-xs text-danger",children:m.error})]}):u("div",{className:"p-4 space-y-3",children:[r("div",{className:"text-xs text-foreground-subtle",children:"Provide an auth key to join this hub into the mesh. The key is forwarded to the daemon and never persisted in clear."}),u("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[r("input",{type:"password",autoComplete:"off",placeholder:"Auth key (tskey-auth-…)",value:g,onChange:y=>i(w=>({...w,[m.addonId]:y.target.value})),className:"rounded-md border border-border bg-surface px-2 py-1 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"}),r("input",{type:"text",placeholder:"Hostname (optional)",value:b,onChange:y=>c(w=>({...w,[m.addonId]:y.target.value})),className:"rounded-md border border-border bg-surface px-2 py-1 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),r("div",{className:"flex justify-end",children:u(Ue,{size:"sm",variant:"primary",disabled:h||!x,onClick:()=>{s(m.addonId),f.mutate({addonId:m.addonId,authKey:g.trim(),hostname:b.trim()?b.trim():void 0})},children:[h?r(Ae,{className:"h-3 w-3 animate-spin"}):r(gL,{className:"h-3 w-3"}),"Join"]})}),m.error&&r("div",{className:"text-xs text-danger",children:m.error})]}),r("div",{className:"p-4 border-t border-border",children:r(sd,{addonId:m.addonId,maxHeight:"max-h-72"})})]})}})}function f9(){return r("div",{className:"flex flex-col",children:r("div",{className:"px-6 pt-6",children:r(od,{tabs:[{id:"addresses",label:"Network Addresses",icon:ln,content:r(d9,{})},{id:"remote-access",label:"Remote Access",icon:yr,content:r(o9,{})},{id:"mesh",label:"Mesh Networks",icon:ba,content:r(p9,{})},{id:"turn",label:"TURN Servers",icon:an,content:r(s9,{})}]})})})}function m9(e){const t=e.basePath;if(typeof t=="string"&&t.length>0)return t;const n=Object.keys(e);return n.length===0?"":n.join(", ")}function h9({location:e,onEdit:t,onDelete:n,onSetDefault:o}){const s=m9(e.config);return u("div",{className:"flex items-center gap-3 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5",children:[u("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[r("div",{className:"w-[88px] shrink-0",children:e.isDefault?u("span",{className:"inline-flex items-center gap-0.5 rounded bg-primary/10 border border-primary/20 px-1.5 py-0.5 text-[10px] font-semibold text-primary uppercase tracking-wide",title:"Default location for this type",children:[r(si,{className:"h-2.5 w-2.5 fill-primary"}),"Default"]}):u("button",{onClick:()=>o(e),className:"inline-flex items-center gap-0.5 rounded border border-border px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 hover:border-primary/30 uppercase tracking-wide",title:"Promote to default for this type",children:[r(si,{className:"h-2.5 w-2.5"}),"Set default"]})}),r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono",children:e.providerId}),e.isSystem&&r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5",title:"System-managed location — cannot be deleted; edit config to relocate",children:"system"}),u("div",{className:"min-w-0",children:[r("div",{className:"text-xs font-medium text-foreground truncate",children:e.displayName}),s&&r("div",{className:"text-[10px] text-foreground-subtle truncate font-mono",children:s})]})]}),u("div",{className:"flex items-center gap-1 shrink-0",children:[!e.isDefault&&u("button",{onClick:()=>o(e),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10",title:"Set as default for this type",children:[r(si,{className:"h-3 w-3"}),"Set default"]}),u("button",{onClick:()=>t(e),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10",children:[r(Rr,{className:"h-3 w-3"}),"Edit"]}),!e.isSystem&&hs[e.type]!=="singleton"&&r("button",{onClick:()=>n(e),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10",title:"Delete location",children:r(Ge,{className:"h-3 w-3"})})]})]})}function g9({type:e,displayName:t,description:n,locations:o,onAdd:s,onEdit:a,onDelete:i,onSetDefault:l}){const c=U(()=>{const d=[...o];return d.sort((f,p)=>f.isDefault!==p.isDefault?f.isDefault?-1:1:f.displayName.localeCompare(p.displayName)),d},[o]);return u("div",{className:"rounded-lg border border-border bg-surface",children:[u("div",{className:"flex items-start justify-between border-b border-border px-3 py-2",children:[u("div",{className:"space-y-0.5",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-sm font-semibold text-foreground capitalize",children:t}),r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono",children:e})]}),n&&r("p",{className:"text-[11px] text-foreground-subtle",children:n}),hs[e]==="singleton"&&r("p",{className:"text-[10px] text-foreground-subtle italic",children:"Singleton — one location per type. Edit the existing entry; it can't be split."})]}),hs[e]==="multi"&&u("button",{onClick:()=>s(e),className:"inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90",children:[r(wt,{className:"h-3 w-3"}),"Add"]})]}),c.length===0?r("div",{className:"px-3 py-4 text-center text-[11px] text-foreground-subtle italic",children:hs[e]==="multi"?'No location registered. Click "Add" to register one.':"No location registered yet — should be auto-seeded at next boot."}):r("div",{children:c.map(d=>r(h9,{location:d,onEdit:a,onDelete:i,onSetDefault:l},d.id))})]})}function b9(e){const t=e.trim().toLowerCase();return t.length===0?"":t.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Sp(e,t){const n=b9(t),o=n.length>0?n:"default";return`${e}:${o}`}function l0({initialType:e,onClose:t,onCreated:n}){const o=ke(),s=Le().trpcClient,[a,i]=$("picker"),[l,c]=$(e),[d,f]=$(null),[p,m]=$({}),[h,g]=$(""),[b,x]=$(null),[y,w]=$(!1),[v,N]=$(null),[k,S]=$(!1),M=Sc(),P=U(()=>{const L=M.data;return Array.isArray(L)?L.filter(R=>R.supportedLocationTypes.includes(l)):[]},[M.data,l]),A=M.isLoading,z=ca({onSuccess:()=>{o.invalidateQueries({queryKey:[["storage","listLocations"]]}),n()}}),D=U(()=>b!==null&&b.length>0?b:Sp(l,h),[l,h,b]),T=async()=>{if(d){S(!0),N(null);try{const R=await(B=>s.storage.testConfig.query(B))({providerId:d.providerId,config:p});N(R)}catch(L){N({ok:!1,error:L instanceof Error?L.message:String(L)})}finally{S(!1)}}},O=()=>{d&&z.mutate({id:D,type:l,displayName:h.trim(),providerId:d.providerId,config:p,isDefault:y})},I={picker:"Add Location — Pick provider",config:`Add Location — ${d?.displayName??""}`,naming:"Add Location — Name & defaults"};return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:t,children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:L=>L.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:I[a]}),u("p",{className:"text-xs text-foreground-subtle",children:["Type: ",r("span",{className:"font-mono",children:l})]})]}),r("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-4 w-4"})})]}),a==="picker"&&u("div",{className:"p-4 space-y-2",children:[A&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading providers…"}),!A&&P.length===0&&u("div",{className:"rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle",children:['No storage-provider supports type "',l,'". Install a compatible addon (e.g. ',r("code",{className:"font-mono",children:"remote-storage"}),") to enable it."]}),P.map(L=>u("button",{onClick:()=>{f(L),i("config")},className:"flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors",children:[u("div",{className:"flex-1 min-w-0",children:[r("p",{className:"text-xs font-semibold text-foreground",children:L.displayName}),r("p",{className:"text-[10px] text-foreground-subtle font-mono mt-0.5 truncate",children:L.providerId})]}),r(It,{className:"h-4 w-4 text-foreground-subtle flex-shrink-0"})]},L.providerId))]}),a==="config"&&d&&u("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[r(kn,{schema:d.configSchema,values:p,onChange:m}),v&&r("div",{className:`rounded border px-3 py-2 text-[11px] ${v.ok?"border-success/30 bg-success/5 text-success":"border-danger/30 bg-danger/5 text-danger"}`,children:v.ok?"Connection OK.":`Test failed: ${v.error??"unknown error"}`}),u("div",{className:"flex items-center justify-between pt-1",children:[r("button",{onClick:()=>i("picker"),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Back"}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>{T()},disabled:k,className:"rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50",children:k?"Testing…":"Test connection"}),r("button",{onClick:()=>i("naming"),className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:"Next"})]})]})]}),a==="naming"&&d&&u("div",{className:"p-4 space-y-3",children:[u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Display name"}),r("input",{type:"text",value:h,onChange:L=>g(L.target.value),placeholder:`${l} on ${d.displayName}`,className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1",children:[u("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:["Id ",r("span",{className:"lowercase tracking-normal text-foreground-subtle",children:"— auto-derived; override if needed"})]}),r("input",{type:"text",value:D,onChange:L=>x(L.target.value),placeholder:Sp(l,h),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-1 focus:ring-primary"}),u("p",{className:"text-[10px] text-foreground-subtle",children:["Format: ",r("code",{className:"font-mono",children:"<type>:<slug>"}),". Lowercase letters, digits, and hyphens only."]})]}),u("label",{className:"flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5",children:[r("input",{type:"checkbox",checked:y,onChange:L=>w(L.target.checked),className:"accent-primary mt-0.5"}),u("div",{className:"space-y-0.5",children:[u("div",{className:"text-xs font-medium text-foreground",children:['Mark as default for type "',l,'"']}),u("div",{className:"text-[10px] text-foreground-subtle",children:["Setting this as default will demote the current default for this type. References like"," ",u("code",{className:"font-mono",children:['"',l,'"']})," resolve to whichever location is the default."]})]})]}),z.isError&&r("div",{className:"rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]",children:z.error instanceof Error?z.error.message:String(z.error)}),u("div",{className:"flex items-center justify-between pt-1",children:[r("button",{onClick:()=>i("config"),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Back"}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>{c(e),f(null),m({}),g(""),x(null),w(!1),N(null),i("picker")},className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Reset"}),u("button",{onClick:O,disabled:z.isPending||h.trim().length===0,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[z.isPending?r(Ae,{className:"h-3.5 w-3.5 animate-spin"}):null,z.isPending?"Saving…":"Save"]})]})]})]})]})})}function x9({location:e,onClose:t,onSaved:n}){const o=ke(),s=Le().trpcClient,[a,i]=$({...e.config}),[l,c]=$(e.displayName),[d,f]=$(null),[p,m]=$(!1),h=Sc(),g=U(()=>{const w=h.data;return Array.isArray(w)?w.find(N=>N.providerId===e.providerId)??null:null},[h.data,e.providerId]),b=ca({onSuccess:()=>{o.invalidateQueries({queryKey:[["storage","listLocations"]]}),n()}}),x=async()=>{m(!0),f(null);try{const v=await(N=>s.storage.testConfig.query(N))({providerId:e.providerId,config:a});f(v)}catch(w){f({ok:!1,error:w instanceof Error?w.message:String(w)})}finally{m(!1)}},y=()=>{b.mutate({id:e.id,type:e.type,providerId:e.providerId,isDefault:e.isDefault,displayName:l.trim(),config:a})};return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:t,children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:w=>w.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[u("h2",{className:"text-sm font-semibold text-foreground",children:["Edit ",e.displayName]}),u("p",{className:"text-xs text-foreground-subtle",children:[r("span",{className:"font-mono",children:e.id})," · ",g?.displayName??e.providerId]})]}),r("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-4 w-4"})})]}),u("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Display name"}),r("input",{type:"text",value:l,onChange:w=>c(w.target.value),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary"})]}),g&&r(kn,{schema:g.configSchema,values:a,onChange:i}),!g&&!h.isLoading&&u("div",{className:"rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300",children:["Provider ",r("code",{className:"font-mono",children:e.providerId})," is no longer registered. Field schema unavailable; raw config is preserved on save."]}),d&&r("div",{className:`rounded border px-3 py-2 text-[11px] ${d.ok?"border-success/30 bg-success/5 text-success":"border-danger/30 bg-danger/5 text-danger"}`,children:d.ok?"Connection OK.":`Test failed: ${d.error??"unknown error"}`}),b.isError&&r("div",{className:"rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]",children:b.error instanceof Error?b.error.message:String(b.error)})]}),u("div",{className:"flex items-center justify-between gap-2 border-t border-border px-4 py-3",children:[r("button",{onClick:t,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>{x()},disabled:p||!g,className:"rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50",children:p?"Testing…":"Test connection"}),u("button",{onClick:y,disabled:b.isPending||l.trim().length===0,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[b.isPending?r(Ae,{className:"h-3.5 w-3.5 animate-spin"}):null,b.isPending?"Saving…":"Save"]})]})]})]})})}const y9={data:"Data",media:"Media",recordings:"Recordings","recordings-high":"Recordings (High)","recordings-low":"Recordings (Low)","recordings-clips":"Recordings (Clips)","event-images":"Event Images",models:"Models","addons-data":"Addons Data",cache:"Cache",logs:"Logs",backups:"Backups"},v9={backups:"Snapshot archives. Default landing for `backup-orchestrator`.",recordings:"Continuous recordings (combined high + low + clips when no slot is specified).","recordings-high":"High-quality continuous recordings.","recordings-low":"Low-quality continuous recordings.","recordings-clips":"Event clips (motion / detection triggers).","event-images":"Detection snapshots, thumbnails, and crops.",models:"ML model files. Read by inference-engine addons.",logs:"Long-term log archives."};function w9(){const e=ke(),t=nt(),{data:n,isLoading:o,isError:s}=Yb({}),[a,i]=$(null),[l,c]=$(null),d=Zb({onSuccess:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]})}}),f=ca({onSuccess:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]})}}),p=g=>{g.isDefault||f.mutate({id:g.id,type:g.type,providerId:g.providerId,displayName:g.displayName,config:g.config,isDefault:!0})},m=async g=>{if(g.isDefault){await t({title:"Cannot delete default location",message:`"${g.displayName}" is the default for type "${g.type}". Mark another location as default first, then delete this one.`,confirmLabel:"OK",variant:"warning"});return}await t({title:`Delete location "${g.displayName}"?`,message:"This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.",confirmLabel:"Delete",variant:"danger"})&&d.mutate({id:g.id})},h=U(()=>{const g=new Map;for(const b of Dd)g.set(b,[]);for(const b of n??[]){const x=g.get(b.type);x?x.push(b):g.set(b.type,[b])}return g},[n]);return u(Rt,{icon:uo,title:"Storage Locations",subtitle:u(ge,{children:["Register where each kind of data lives. Each type can have multiple locations — one is the default, the rest are addressable by their fully-qualified id (",r("code",{className:"font-mono",children:"<type>:<slug>"}),")."]}),children:[o&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading locations…"}),s&&r("div",{className:"text-xs text-danger",children:"Failed to load storage locations."}),!o&&!s&&r("div",{className:"space-y-3",children:Dd.map(g=>r(g9,{type:g,displayName:y9[g],description:v9[g],locations:h.get(g)??[],onAdd:b=>i(b),onEdit:b=>c(b),onDelete:b=>{m(b)},onSetDefault:b=>p(b)},g))}),a!==null&&r(l0,{initialType:a,onClose:()=>i(null),onCreated:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),i(null)}}),l!==null&&r(x9,{location:l,onClose:()=>c(null),onSaved:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),c(null)}})]})}const N9=[["backup","listDestinations"]],k9=["backup","listArchives"];function S9({destinationId:e,restoreSupported:t,onOpenRestoreWizard:n}){const o=ke(),s=nt(),{data:a,isLoading:i,isError:l}=mc({destinationId:e}),c=a??[],d=hg({onSuccess:()=>{o.invalidateQueries({queryKey:[[...k9]]}),o.invalidateQueries({queryKey:N9})}}),f=q(async b=>{await s({title:"Delete this archive?",message:`Permanently deletes "${b.label??b.id}" and frees ${kt(b.sizeBytes)}.`,confirmLabel:"Delete",variant:"danger"})&&d.mutate({destinationId:e,backupId:b.id})},[s,e,d]),[p,m]=$(null),h=q(async b=>{m(b.id);try{const x=localStorage.getItem("camstack_admin_token"),y={};x&&(y.Authorization=`Bearer ${x}`);const w=await fetch(C9(e,b.id),{headers:y});if(!w.ok)throw new Error(`download failed: ${w.status} ${w.statusText}`);const v=await w.blob(),N=URL.createObjectURL(v),k=document.createElement("a");k.href=N,k.download=`${b.label??b.id}.tar.gz`,document.body.appendChild(k),k.click(),k.remove(),URL.revokeObjectURL(N)}finally{m(null)}},[e]),g=U(()=>[...c].sort((b,x)=>x.createdAt-b.createdAt),[c]);return i?r("div",{className:"text-xs text-foreground-subtle animate-pulse py-2",children:"Loading archives…"}):l?r("div",{className:"text-xs text-danger py-2",children:"Failed to read manifest for this destination"}):g.length===0?r("div",{className:"text-xs text-foreground-subtle italic py-2",children:"No archives at this destination yet."}):r("div",{className:"rounded border border-border bg-surface overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[640px]",children:[r("thead",{children:u("tr",{className:"text-foreground-subtle bg-background/30",children:[r("th",{className:"text-left px-3 py-1.5 font-medium",children:"When"}),r("th",{className:"text-left px-3 py-1.5 font-medium",children:"Label"}),r("th",{className:"text-left px-3 py-1.5 font-medium",children:"Includes"}),r("th",{className:"text-right px-3 py-1.5 font-medium",children:"Size"}),r("th",{className:"text-right px-3 py-1.5 font-medium w-52",children:"Actions"})]})}),r("tbody",{children:g.map(b=>u("tr",{className:"border-t border-border hover:bg-primary/5",children:[r("td",{className:"px-3 py-1.5 text-foreground tabular-nums",children:M9(b.createdAt)}),r("td",{className:"px-3 py-1.5 text-foreground",children:b.label??r("span",{className:"text-foreground-subtle italic",children:"—"})}),r("td",{className:"px-3 py-1.5 text-foreground-subtle",children:b.locations.join(", ")}),r("td",{className:"px-3 py-1.5 text-foreground text-right tabular-nums",children:kt(b.sizeBytes)}),r("td",{className:"px-3 py-1.5",children:u("div",{className:"flex items-center justify-end gap-1",children:[u("button",{onClick:()=>{h(b)},disabled:p===b.id,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 disabled:opacity-50",title:"Download archive",children:[p===b.id?r(Ae,{className:"h-3 w-3 animate-spin"}):r(Nn,{className:"h-3 w-3"}),"Download"]}),t&&n&&u("button",{onClick:()=>n({destinationId:e,archiveId:b.id}),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-primary hover:bg-primary/10",title:"Restore from this archive",children:[r(gt,{className:"h-3 w-3"}),"Restore"]}),r("button",{onClick:()=>{f(b)},disabled:d.isPending,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50",title:"Delete archive",children:d.isPending?r(Ae,{className:"h-3 w-3 animate-spin"}):r(Ge,{className:"h-3 w-3"})})]})})]},b.id))})]})})}function C9(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function M9(e){return new Date(e).toLocaleString(void 0,{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}const c0=[{id:"manual",label:"Manual only",cron:""},{id:"hourly",label:"Every hour",cron:"0 * * * *",description:"On the hour"},{id:"every-3h",label:"Every 3 hours",cron:"0 */3 * * *",description:"00:00, 03:00, 06:00, 09:00 …"},{id:"every-6h",label:"Every 6 hours",cron:"0 */6 * * *",description:"00:00, 06:00, 12:00, 18:00"},{id:"daily-3am",label:"Daily at 03:00",cron:"0 3 * * *",description:"Every night at 3 AM"},{id:"weekly-sun",label:"Weekly Sunday 03:00",cron:"0 3 * * 0",description:"Sunday morning at 3 AM"}];function I9(e){const t=e.trim();for(const n of c0)if(n.cron===t)return n.id;return"custom"}function A9({value:e,onChange:t,previewCount:n=5,disabled:o=!1}){const s=I9(e),[a,i]=$(s==="custom");Z(()=>{s!=="custom"&&i(!1)},[s]);const l=$9(e,250),c=bg({cron:l,count:n},{enabled:l.trim().length>0}),d=c.data??null,f=m=>{i(!1),t(m.cron)},p=a||s==="custom";return u("div",{className:"space-y-3",children:[u("div",{className:"space-y-1",children:[r("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Schedule preset"}),u("div",{className:"flex flex-wrap gap-1.5",children:[c0.map(m=>{const h=!a&&s===m.id;return r("button",{type:"button",onClick:()=>f(m),disabled:o,className:"rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 "+(h?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground"),title:m.description??m.label,children:m.label},m.id)}),r("button",{type:"button",onClick:()=>{i(!0),e.trim().length===0&&t("0 3 * * *")},disabled:o,className:"rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 "+(p?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground"),children:"Custom…"})]})]}),p&&u("div",{className:"space-y-1",children:[r("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Cron expression (5-field POSIX)"}),r("input",{type:"text",value:e,onChange:m=>t(m.target.value),disabled:o,placeholder:"0 3 * * *",spellCheck:!1,className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"}),u("p",{className:"text-[10px] text-foreground-subtle",children:["Format: ",r("span",{className:"font-mono",children:"minute hour day-of-month month day-of-week"})," · all times server-local"]})]}),r(P9,{cron:l,preview:d,loading:c.isFetching})]})}function P9({cron:e,preview:t,loading:n}){return n&&t===null?u("div",{className:"flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle",children:[r(Ae,{className:"h-3 w-3 animate-spin"}),"Validating…"]}):t===null?null:t.ok?t.nextRuns.length===0?r("div",{className:"rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle",children:"No future runs match this expression."}):u("div",{className:"space-y-1",children:[r("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Next runs"}),r("ul",{className:"rounded border border-border bg-background/40 divide-y divide-border",children:t.nextRuns.map((o,s)=>u("li",{className:"flex items-center justify-between px-3 py-1.5 text-[11px]",children:[r("span",{className:"text-foreground tabular-nums",children:new Date(o).toLocaleString()}),r("span",{className:"text-foreground-subtle text-[10px] tabular-nums",children:E9(o)})]},`${o}-${s}`))})]}):r("div",{className:"rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger",children:t.error??"Invalid cron expression"})}function E9(e){const t=e-Date.now();if(t<=0)return"now";const n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;const o=Math.floor(n/60);if(o<60)return`in ${o}m`;const s=Math.floor(o/60);return s<24?`in ${s}h`:`in ${Math.floor(s/24)}d`}function $9(e,t){const[n,o]=$(e),s=U(()=>e,[e]);return Z(()=>{const a=setTimeout(()=>o(s),t);return()=>clearTimeout(a)},[s,t]),n}const _9=[["backup","listDestinations"]];function D9({onCreateAt:e,onOpenRestoreWizard:t}){const{data:n,isLoading:o,isError:s}=fc(),a=n??[],[i,l]=$(null),c=f=>{l(p=>p===f?null:f)},d=z9();return o?r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading destinations…"}):s?r("div",{className:"text-xs text-danger",children:"Failed to load destinations"}):a.length===0?r("div",{className:"rounded-lg border border-border bg-surface px-4 py-8 text-center",children:r("p",{className:"text-xs text-foreground-subtle",children:"No `backups`-typed storage locations registered. Add one in Settings → Storage to begin."})}):r("div",{className:"rounded-lg border border-border bg-surface overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[720px]",children:[r("thead",{children:u("tr",{className:"text-foreground-subtle border-b border-border bg-background/40",children:[r("th",{className:"text-left px-3 py-2 font-medium w-6"}),r("th",{className:"text-left px-3 py-2 font-medium",children:"Destination"}),r("th",{className:"text-left px-3 py-2 font-medium w-20",children:"Enabled"}),r("th",{className:"text-left px-3 py-2 font-medium w-28",children:"Retention"}),r("th",{className:"text-left px-3 py-2 font-medium w-56",children:"Schedule"}),r("th",{className:"text-left px-3 py-2 font-medium w-44",children:"Last success"}),r("th",{className:"text-right px-3 py-2 font-medium w-44",children:"Actions"})]})}),r("tbody",{children:a.map(f=>{const p=d.get(f.id);return r(L9,{row:f,isOpen:i===f.id,onToggle:()=>c(f.id),onCreateAt:e,liveLastSuccessAt:p?.at,liveLastSuccessSizeBytes:p?.sizeBytes,...t?{onOpenRestoreWizard:t}:{}},f.id)})})]})})}function L9({row:e,isOpen:t,onToggle:n,onCreateAt:o,onOpenRestoreWizard:s,liveLastSuccessAt:a,liveLastSuccessSizeBytes:i}){const l=ke(),c=gg({onSuccess:()=>{l.invalidateQueries({queryKey:_9})}}),[d,f]=$(String(e.retentionCount));Z(()=>{f(String(e.retentionCount))},[e.retentionCount]);const[p,m]=$(!1),h=q(x=>{c.mutate({locationId:e.id,enabled:x,retentionCount:e.retentionCount,...e.label!==void 0?{label:e.label}:{},...e.cron!==void 0?{cron:e.cron}:{}})},[c,e.id,e.retentionCount,e.label,e.cron]),g=q(()=>{const x=Number.parseInt(d,10);if(Number.isNaN(x)||x<1){f(String(e.retentionCount));return}x!==e.retentionCount&&c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:x,...e.label!==void 0?{label:e.label}:{},...e.cron!==void 0?{cron:e.cron}:{}})},[c,d,e.id,e.enabled,e.retentionCount,e.label,e.cron]),b=q(x=>{c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:e.retentionCount,...e.label!==void 0?{label:e.label}:{},cron:x},{onSuccess:()=>{m(!1)}})},[c,e.id,e.enabled,e.retentionCount,e.label]);return u(ge,{children:[u("tr",{className:"border-t border-border first:border-t-0 hover:bg-primary/5",children:[r("td",{className:"px-2 py-2",children:r("button",{onClick:n,className:"inline-flex items-center justify-center rounded p-1 text-foreground-subtle hover:bg-primary/10 hover:text-foreground",title:t?"Hide archives":"Show archives",children:t?r(vt,{className:"h-3.5 w-3.5"}):r(It,{className:"h-3.5 w-3.5"})})}),r("td",{className:"px-3 py-2",children:u("button",{onClick:n,className:"text-left hover:underline focus:outline-none",title:"View archives",children:[r("div",{className:"text-foreground font-medium",children:e.displayName}),u("div",{className:"flex items-center gap-1.5 mt-0.5",children:[r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5",children:e.kind}),r("span",{className:"text-[10px] text-foreground-subtle font-mono",children:e.id})]})]})}),r("td",{className:"px-3 py-2",children:r("label",{className:"inline-flex items-center cursor-pointer",children:r("input",{type:"checkbox",className:"accent-primary",checked:e.enabled,disabled:c.isPending,onChange:x=>h(x.target.checked)})})}),r("td",{className:"px-3 py-2",children:r("input",{type:"number",min:1,max:1e3,value:d,disabled:c.isPending,onChange:x=>f(x.target.value),onBlur:g,onKeyDown:x=>{x.key==="Enter"&&x.target.blur(),x.key==="Escape"&&f(String(e.retentionCount))},className:"w-16 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary"})}),r("td",{className:"px-3 py-2",children:r(T9,{cron:e.cron,nextRunAt:e.nextRunAt,onEdit:()=>m(!0),disabled:c.isPending})}),r("td",{className:"px-3 py-2 text-foreground-subtle",children:(()=>{const x=B9(a,e.lastSuccessAt),y=x===a?i:e.lastSuccessSizeBytes;return x!==void 0?r(F9,{at:x,sizeBytes:y}):r("span",{className:"italic",children:"Never"})})()}),r("td",{className:"px-3 py-2",children:r("div",{className:"flex items-center justify-end gap-1.5",children:e.triggerSupported&&u("button",{onClick:()=>o(e),className:"inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90",children:[r(wt,{className:"h-3 w-3"}),"Create here"]})})})]}),t&&r("tr",{className:"border-t border-border bg-background/30",children:r("td",{colSpan:7,className:"px-4 py-3",children:r(S9,{destinationId:e.id,restoreSupported:e.restoreSupported,...s?{onOpenRestoreWizard:s}:{}})})}),p&&r(O9,{destinationName:e.displayName,currentCron:e.cron??"",onSave:b,onClose:()=>m(!1),saving:c.isPending,saveError:c.error instanceof Error?c.error.message:null})]})}function T9({cron:e,nextRunAt:t,onEdit:n,disabled:o}){const s=typeof e=="string"&&e.trim().length>0;return u("button",{type:"button",onClick:n,disabled:o,className:"group flex flex-col items-start gap-0.5 text-left rounded px-1.5 py-1 -mx-1.5 hover:bg-primary/5 disabled:opacity-50",title:"Edit schedule",children:[u("div",{className:"flex items-center gap-1.5",children:[r(hD,{className:"h-3 w-3 text-foreground-subtle group-hover:text-foreground"}),r("span",{className:s?"font-mono text-foreground":"italic text-foreground-subtle",children:s?e:"Manual"})]}),s&&t!==void 0&&u("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:["next ",R9(t)]})]})}function R9(e){const t=e-Date.now();if(t<=0)return"imminent";const n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;const o=Math.floor(n/60);if(o<60)return`in ${o}m`;const s=Math.floor(o/60);return s<24?`in ${s}h`:`in ${Math.floor(s/24)}d`}function O9({destinationName:e,currentCron:t,onSave:n,onClose:o,saving:s,saveError:a}){const[i,l]=$(t);return r("tr",{children:r("td",{colSpan:7,className:"p-0",children:r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:o,children:u("div",{className:"w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl",onClick:c=>c.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:"Schedule"}),u("p",{className:"text-xs text-foreground-subtle",children:["→ ",e]})]}),r("button",{onClick:o,className:"text-foreground-subtle hover:text-foreground",title:"Close",children:r(Ve,{className:"h-4 w-4"})})]}),u("div",{className:"p-4",children:[r(A9,{value:i,onChange:l,disabled:s}),a!==null&&r("div",{className:"mt-3 rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger",children:a})]}),u("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:[r("button",{onClick:o,disabled:s,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground disabled:opacity-50",children:"Cancel"}),r("button",{onClick:()=>n(i.trim()),disabled:s||i.trim()===t.trim(),className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:s?"Saving…":"Save"})]})]})})})})}function z9(){const{map:e}=tc(Ne.BackupCompleted,t=>t.destinationId);return U(()=>{const t=new Map;for(const[n,o]of e)t.set(n,{at:Date.now(),sizeBytes:o.sizeMB*1024*1024});return t},[e])}function B9(e,t){return e===void 0?t:t===void 0||e>t?e:t}function F9({at:e,sizeBytes:t}){const n=j9(e),o=U(()=>new Date(e).toLocaleString(),[e]);return u("span",{title:o,className:"text-foreground tabular-nums",children:[n,t!==void 0&&u("span",{className:"ml-1 text-foreground-subtle",children:["· ",kt(t)]})]})}function j9(e){const[,t]=$(0);return Z(()=>{const n=setInterval(()=>t(o=>o+1),3e4);return()=>clearInterval(n)},[]),H9(e)}function H9(e){const t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const o=Math.floor(n/60);if(o<60)return`${o}m ago`;const s=Math.floor(o/60);if(s<24)return`${s}h ago`;const a=Math.floor(s/24);if(a<30)return`${a}d ago`;const i=Math.floor(a/30);return i<12?`${i}mo ago`:`${Math.floor(a/365)}y ago`}const V9=[["backup","list"]];function q9({initialDestinationId:e,initialArchiveId:t,onClose:n,onScheduled:o}){const s=ke(),[a,i]=$(e&&t?2:1),[l,c]=$(e),[d,f]=$(t),[p,m]=$(new Set),{data:h}=fc(),g=h??[],{data:b,isLoading:x}=mc({destinationId:l??""},{enabled:!!l}),y=b??[];Z(()=>{if(l!==void 0)return;const z=g.filter(D=>D.restoreSupported);z.length===1&&c(z[0].id)},[l,g]);const{data:w}=fg({destinationId:l??"",backupId:d??""},{enabled:!!l&&!!d}),v=U(()=>w?.locations??[],[w]);Z(()=>{v.length!==0&&m(z=>z.size===0?new Set(v):z)},[v]);const N=mg({onSuccess:()=>{s.invalidateQueries({queryKey:V9}),o(),n()}}),k=z=>{m(D=>{const T=new Set(D);return T.has(z)?T.delete(z):T.add(z),T})},S=!!l&&!!d,M=p.size>0,P=S&&M&&!N.isPending,A=()=>{!l||!d||N.mutate({destinationId:l,backupId:d,locations:[...p]})};return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:n,children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:z=>z.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:"Restore Backup"}),u("p",{className:"text-xs text-foreground-subtle",children:["Step ",a," of 3 — ",a===1?"pick source":a===2?"pick locations":"confirm"]})]}),r("button",{onClick:n,className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-4 w-4"})})]}),a===1&&r(U9,{destinations:g,destinationId:l,onPickDestination:z=>{c(z),f(void 0),m(new Set)},archives:y,archivesLoading:x,archiveId:d,onPickArchive:f}),a===2&&r(Q9,{locations:v,picked:p,onToggle:k}),a===3&&r(K9,{destinationName:g.find(z=>z.id===l)?.displayName??l??"",archive:y.find(z=>z.id===d),picked:[...p]}),u("div",{className:"flex justify-between gap-2 border-t border-border px-4 py-3",children:[r("div",{children:a>1&&u("button",{onClick:()=>i(z=>z===3?2:1),className:"inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:[r(ey,{className:"h-3 w-3"}),"Back"]})}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:n,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),a<3?u("button",{disabled:a===1&&!S||a===2&&!M,onClick:()=>i(z=>z===1?2:3),className:"inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:["Next",r(ty,{className:"h-3 w-3"})]}):u("button",{onClick:A,disabled:!P,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[N.isPending?r(Ae,{className:"h-3.5 w-3.5 animate-spin"}):r(gt,{className:"h-3.5 w-3.5"}),"Schedule Restore"]})]})]})]})})}function U9({destinations:e,destinationId:t,onPickDestination:n,archives:o,archivesLoading:s,archiveId:a,onPickArchive:i}){const l=e.filter(c=>c.restoreSupported);return u("div",{className:"p-4 space-y-3",children:[u("div",{className:"space-y-1.5",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Destination"}),u("select",{value:t??"",onChange:c=>n(c.target.value),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"",disabled:!0,children:"Select destination…"}),l.map(c=>u("option",{value:c.id,children:[c.displayName," (",c.kind,")"]},c.id))]})]}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Archive"}),!t&&r("div",{className:"text-xs text-foreground-subtle italic",children:"Pick a destination first."}),t&&s&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Reading archives…"}),t&&!s&&o.length===0&&r("div",{className:"text-xs text-foreground-subtle italic",children:"No archives available at this destination."}),t&&o.length>0&&r("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:o.map(c=>{const d=a===c.id;return u("label",{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${d?"bg-primary/10":"hover:bg-primary/5"}`,children:[u("div",{className:"flex items-center gap-2",children:[r("input",{type:"radio",name:"archive",checked:d,onChange:()=>i(c.id),className:"accent-primary"}),u("div",{children:[r("div",{className:"font-medium text-foreground",children:c.label??c.id}),r("div",{className:"text-[10px] text-foreground-subtle",children:new Date(c.createdAt).toLocaleString()})]})]}),r("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:kt(c.sizeBytes)})]},c.id)})})]})]})}function Q9({locations:e,picked:t,onToggle:n}){return e.length===0?r("div",{className:"p-4",children:r("div",{className:"text-xs text-foreground-subtle",children:"Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball."})}):u("div",{className:"p-4 space-y-3",children:[r("div",{className:"rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300",children:"Selected entries will overwrite live data on the next server restart. Unchecked entries stay current."}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Apply"}),r("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:e.map(o=>u("label",{className:"flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer",children:[r("input",{type:"checkbox",checked:t.has(o),onChange:()=>n(o),className:"accent-primary"}),r("span",{className:"font-mono text-foreground",children:o}),r("span",{className:"ml-auto text-[10px] text-foreground-subtle",children:W9(o)})]},o))})]})]})}function K9({destinationName:e,archive:t,picked:n}){return u("div",{className:"p-4 space-y-3 text-xs",children:[r("div",{className:"rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-300",children:"Restore is applied at next server boot. Active connections will drop when you restart."}),u("dl",{className:"space-y-1.5",children:[r(ss,{term:"Destination",value:e}),r(ss,{term:"Archive",value:t?.label??t?.id??"—"}),t&&r(ss,{term:"Created",value:`${new Date(t.createdAt).toLocaleString()} · ${kt(t.sizeBytes)}`}),r(ss,{term:"Locations",value:n.length>0?n.join(", "):"— (full archive)"})]})]})}function ss({term:e,value:t}){return u("div",{className:"flex justify-between gap-3",children:[r("dt",{className:"text-foreground-subtle",children:e}),r("dd",{className:"text-foreground font-mono text-right truncate",children:t})]})}const G9={db:"Database",addons:"Addon configs","addons-data":"Addon data",tls:"TLS certificates",cache:"Cache",data:"Top-level data"};function W9(e){return G9[e]??""}const Y9=[["backup","list"]],Z9=[["backup","listLocations"]];function X9(){const e=ke(),t=nt(),{data:n}=pg(),o=ug({onSuccess:()=>{e.invalidateQueries({queryKey:Y9}),e.invalidateQueries({queryKey:[["backup","listDestinations"]]}),e.invalidateQueries({queryKey:[["backup","listArchives"]]})}}),s=Wh(),[a,i]=$(null),[l,c]=$(null),[d,f]=$(!1),[p,m]=$(!1),[h,g]=$(!1),b=async()=>{await t({title:"Restart server now?",message:"Active connections will drop and the apply-backup hook will run before boot.",confirmLabel:"Restart",variant:"warning"})&&s.mutate({confirm:!0})};return u(Rt,{icon:Wc,title:"Backup & Restore",subtitle:"Schedule + per-destination retention live in the orchestrator. Each `backups` storage location is a destination.",actions:u(ge,{children:[u("button",{onClick:()=>g(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:[r(wt,{className:"h-3.5 w-3.5"}),"Add destination"]}),u("button",{onClick:()=>f(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30",children:[r(gt,{className:"h-3.5 w-3.5"}),"Restore…"]})]}),children:[p&&r("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs text-amber-700 dark:text-amber-300",children:u("div",{className:"flex items-center justify-between gap-3",children:[u("div",{className:"flex items-center gap-2",children:[r(gt,{className:"h-3.5 w-3.5"}),r("span",{children:"Restore scheduled. Restart the server to apply."})]}),u("button",{onClick:()=>{b()},disabled:s.isPending,className:"inline-flex items-center gap-1.5 rounded bg-amber-500/20 px-2 py-1 font-medium text-amber-800 dark:text-amber-200 hover:bg-amber-500/30 disabled:opacity-50",children:[s.isPending?r(Ae,{className:"h-3.5 w-3.5 animate-spin"}):r(gt,{className:"h-3.5 w-3.5"}),"Restart Now"]})]})}),r(D9,{onCreateAt:x=>i(x),onOpenRestoreWizard:x=>c(x)}),a&&r(J9,{destination:a,locations:n??[],onClose:()=>i(null),onSubmit:(x,y)=>{o.mutate({destinations:[a.id],locations:x,label:y||void 0},{onSuccess:()=>{i(null),e.invalidateQueries({queryKey:Z9})}})},submitting:o.isPending}),(l||d)&&r(q9,{...l?{initialDestinationId:l.destinationId,initialArchiveId:l.archiveId}:{},onClose:()=>{c(null),f(!1)},onScheduled:()=>m(!0)}),h&&r(l0,{initialType:"backups",onClose:()=>g(!1),onCreated:()=>{g(!1),e.invalidateQueries({queryKey:[["backup","listDestinations"]]})}})]})}function J9({destination:e,locations:t,onClose:n,onSubmit:o,submitting:s}){const a=t.filter(p=>p.present),[i,l]=$(""),[c,d]=$(()=>new Set(a.map(p=>p.name))),f=p=>{d(m=>{const h=new Set(m);return h.has(p)?h.delete(p):h.add(p),h})};return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:n,children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:p=>p.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:"Create Backup"}),u("p",{className:"text-xs text-foreground-subtle",children:["→ ",e.displayName]})]}),r("button",{onClick:n,className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-4 w-4"})})]}),u("div",{className:"p-4 space-y-3",children:[u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Label (optional)"}),r("input",{type:"text",value:i,onChange:p=>l(p.target.value),placeholder:"pre-upgrade",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Include"}),u("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:[a.length===0&&r("div",{className:"px-3 py-2 text-xs text-foreground-subtle italic",children:"Nothing to back up."}),a.map(p=>u("label",{className:"flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer",children:[u("div",{className:"flex items-center gap-2",children:[r("input",{type:"checkbox",checked:c.has(p.name),onChange:()=>f(p.name),className:"accent-primary"}),r("span",{className:"font-mono text-foreground",children:p.name})]}),u("div",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[kt(p.sizeBytes)," · ",p.fileCount," files"]})]},p.name))]})]})]}),u("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:[r("button",{onClick:n,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),u("button",{onClick:()=>o(Array.from(c),i.trim()),disabled:s||c.size===0,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[s?r(Ae,{className:"h-3.5 w-3.5 animate-spin"}):r(Wc,{className:"h-3.5 w-3.5"}),s?"Creating…":"Create"]})]})]})})}function e7(){return r("div",{className:"flex flex-col",children:r("div",{className:"px-6 pt-6",children:r(od,{tabs:[{id:"storage",label:"Storage",icon:uo,content:r(w9,{})},{id:"backup",label:"Backup",icon:Wc,content:r(X9,{})}]})})})}function t7(){const{data:e,isLoading:t}=An(void 0,{staleTime:3e4}),n=(e??[]).find(s=>s.isHub&&s.isOnline),o=n?.addons.map(s=>s.id)??[];return u("div",{className:"flex flex-col h-full gap-4 p-4",children:[u("div",{className:"flex items-center gap-3",children:[r(Nt,{className:"h-5 w-5 text-muted-foreground"}),r("h1",{className:"text-xl font-semibold",children:"Settings"}),n&&u("span",{className:"text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground",children:["hub: ",n.name]})]}),t?r("div",{className:"flex items-center justify-center flex-1 text-muted-foreground text-sm",children:"Loading hub topology…"}):n?o.length===0?r("div",{className:"flex items-center justify-center flex-1 text-muted-foreground text-sm",children:"No addons installed on the hub yet."}):r("div",{className:"w-full",children:r(Or,{nodeId:n.id,addonIds:o,level:"global"})}):u("div",{className:"flex flex-col items-center justify-center flex-1 text-muted-foreground text-sm gap-2",children:[r(Nt,{className:"h-8 w-8 opacity-30"}),r("p",{children:"No online hub node found."}),r("p",{className:"text-xs",children:"Settings will appear once the hub is reachable."})]})]})}function n7(e){const t=new FormData;return t.append("file",e.file,e.file.name),t.append("nodeId",e.nodeId),e.addonId&&t.append("addonId",e.addonId),new Promise((n,o)=>{const s=new XMLHttpRequest;s.open("POST","/api/addons/upload"),e.token&&s.setRequestHeader("Authorization",`Bearer ${e.token}`),s.upload.addEventListener("progress",a=>{a.lengthComputable&&e.onProgress(Math.round(a.loaded/a.total*100))}),s.addEventListener("load",()=>{let a;try{a=JSON.parse(s.responseText)}catch{o(new Error(`HTTP ${s.status}`));return}s.status>=200&&s.status<300?n(a):o(new Error(a.error??`HTTP ${s.status}`))}),s.addEventListener("error",()=>o(new Error("Network error during upload"))),s.addEventListener("abort",()=>o(new Error("Upload aborted"))),s.send(t)})}function r7({nodeId:e,addons:t,isHub:n}){const o=ke(),s=nt(),[a,i]=$(null),[l,c]=$(null),[d,f]=$(!1),[p,m]=$(null),[h,g]=$(0),b=ne(null),x=aa(),y=tb(),w=()=>{o.invalidateQueries({queryKey:[["nodes","topology"]]})},v=async M=>{i(M);try{await x.mutateAsync({nodeId:e,addonId:M}),w()}catch(P){console.error("Failed to restart addon:",P)}finally{i(null)}},N=async M=>{if(await s({title:"Uninstall addon",message:`Remove "${M}" from ${e}? The addon directory will be deleted on disk.`,confirmLabel:"Uninstall",variant:"danger"})){c(M);try{await y.mutateAsync({nodeId:e,addonId:M}),w()}catch(A){console.error("Failed to uninstall addon:",A)}finally{c(null)}}},S=u("div",{className:"flex items-center gap-2 mb-2",children:[r("input",{ref:b,type:"file",accept:".tgz,.tar.gz",className:"hidden",onChange:async M=>{const P=M.target.files?.[0];if(P){M.target.value="",m(null),f(!0),g(0);try{const A=localStorage.getItem("camstack_admin_token");await n7({file:P,nodeId:e,token:A,onProgress:g}),w()}catch(A){m(A instanceof Error?A.message:String(A))}finally{f(!1),g(0)}}}}),u("button",{onClick:()=>b.current?.click(),disabled:d,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:[d?r(Ae,{className:"h-3 w-3 animate-spin"}):r(va,{className:"h-3 w-3"}),d?`Uploading… ${h}%`:"Upload addon (.tgz)"]}),d&&r("div",{className:"flex-1 h-1 rounded-full bg-muted overflow-hidden max-w-[140px]",children:r("div",{className:"h-full bg-primary transition-all",style:{width:`${h}%`}})}),p&&r("span",{className:"text-[10px] text-destructive",children:p})]});return t.length===0?u("div",{children:[S,r("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No addons on this node"})]}):u("div",{children:[S,u("table",{className:"w-full text-xs",children:[r("thead",{children:u("tr",{className:"text-muted-foreground text-left",children:[r("th",{className:"py-2 font-medium",children:"Addon"}),r("th",{className:"py-2 font-medium",children:"Capabilities"}),r("th",{className:"py-2 font-medium",children:"Status"}),r("th",{className:"py-2 font-medium w-16"})]})}),r("tbody",{children:t.map(M=>u("tr",{className:"border-t border-border/50",children:[r("td",{className:"py-2 font-medium",children:M.id}),r("td",{className:"py-2",children:r("div",{className:"flex flex-wrap gap-1",children:M.capabilities.length>0?M.capabilities.map(P=>r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400",children:P},P)):r("span",{className:"text-muted-foreground",children:"—"})})}),r("td",{className:"py-2",children:r("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${M.status==="running"?"bg-success/10 text-success":M.status==="error"?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground"}`,children:M.status})}),r("td",{className:"py-2",children:u("div",{className:"flex items-center gap-1 justify-end",children:[r("button",{onClick:()=>v(M.id),disabled:a===M.id||l===M.id,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:`Restart ${M.id}`,children:r(gt,{className:`h-3 w-3 ${a===M.id?"animate-spin":""}`})}),r("button",{onClick:()=>N(M.id),disabled:a===M.id||l===M.id,className:"p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50",title:`Uninstall ${M.id}`,children:l===M.id?r(Ae,{className:"h-3 w-3 animate-spin"}):r(Ge,{className:"h-3 w-3"})})]})})]},M.id))})]})]})}function o7(e){if(e<60)return`${e}s`;const t=Math.floor(e/60);if(t<60)return`${t}m`;const n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function s7({state:e}){return r("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e==="running"?"bg-success/10 text-success":e==="crashed"?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground"}`,children:e})}const a7=["trace","debug","info","warn","error"];function i7({proc:e,nodeId:t,defaultExpanded:n,activePanel:o,onTogglePanel:s}){const a=e.services??[],i=a.length===1,[l,c]=$(i||n),[d,f]=$(null),[p,m]=$("info"),h=e.name.includes("(core)"),g=aa(),b=nb(),x=ab(),y=async N=>{f(N);try{await g.mutateAsync({nodeId:t,addonId:N})}catch(k){console.error("Failed to restart addon:",k)}finally{f(null)}},w=async()=>{f(e.name);try{await b.mutateAsync({nodeId:t,processName:e.name})}catch(N){console.error("Failed to restart process:",N)}finally{f(null)}},v=async N=>{const k=`${t}/${e.name}`;try{await x.mutateAsync({nodeId:k,level:N}),m(N)}catch(S){console.error("Failed to set log level:",S)}};return u("div",{className:"border border-border/50 rounded-lg overflow-hidden",children:[u("div",{role:i?void 0:"button",tabIndex:i?void 0:0,onClick:i?void 0:()=>c(!l),onKeyDown:i?void 0:N=>{(N.key==="Enter"||N.key===" ")&&c(!l)},className:`flex items-center gap-2 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${i?"":"hover:bg-muted/40 cursor-pointer"}`,children:[i?r("span",{className:"h-3 w-3 shrink-0"}):l?r(vt,{className:"h-3 w-3 text-muted-foreground shrink-0"}):r(It,{className:"h-3 w-3 text-muted-foreground shrink-0"}),h?r(ln,{className:"h-3.5 w-3.5 text-primary shrink-0"}):r(ga,{className:"h-3.5 w-3.5 text-amber-500 shrink-0"}),r("span",{className:"text-xs font-semibold flex-1",children:e.name}),u("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:["PID ",e.pid]}),r(s7,{state:e.state}),u("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[e.cpuPercent,"% CPU"]}),r("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:kt(e.memoryRss)}),r("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:o7(e.uptimeSeconds)}),!h&&u("div",{className:"flex items-center gap-1",onClick:N=>N.stopPropagation(),children:[u(Ym,{children:[r(Zm,{className:"text-[9px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors font-mono",title:"Set log level",children:p}),r(Xm,{align:"end",className:"min-w-[70px] py-0.5",children:a7.map(N=>r(Jm,{onClick:()=>v(N),className:`h-auto px-2 py-1 text-[10px] font-mono ${N===p?"text-primary font-semibold":""}`,children:N},N))})]}),r("button",{onClick:w,disabled:d===e.name,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:"Restart process",children:r(gt,{className:`h-3 w-3 ${d===e.name?"animate-spin":""}`})})]})]}),l&&a.length>0&&r("div",{className:"divide-y divide-border/30",children:a.map(N=>u("div",{children:[u("div",{className:"flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors",children:[r("div",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${N.status==="running"?"bg-success":"bg-muted-foreground/30"}`}),r("span",{className:"text-xs font-medium flex-1 min-w-0 truncate",children:N.addonId}),N.capabilities.length>0&&u("div",{className:"flex gap-1 flex-shrink-0",children:[N.capabilities.slice(0,3).map(k=>r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400 truncate max-w-[80px]",children:k},k)),N.capabilities.length>3&&u("span",{className:"text-[9px] text-muted-foreground",children:["+",N.capabilities.length-3]})]}),u("div",{className:"flex items-center gap-1 shrink-0",children:[r("button",{onClick:()=>s(N.addonId,"logs"),className:`p-0.5 rounded transition-colors ${o?.addonId===N.addonId&&o.type==="logs"?"bg-primary/10 text-primary":"hover:bg-muted text-muted-foreground hover:text-foreground"}`,title:`Show logs for ${N.addonId}`,children:r(Xe,{className:"h-3 w-3"})}),r("button",{onClick:()=>s(N.addonId,"events"),className:`p-0.5 rounded transition-colors ${o?.addonId===N.addonId&&o.type==="events"?"bg-primary/10 text-primary":"hover:bg-muted text-muted-foreground hover:text-foreground"}`,title:`Show events for ${N.addonId}`,children:r(td,{className:"h-3 w-3"})}),r("button",{onClick:()=>y(N.addonId),disabled:d===N.addonId,className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:`Restart ${N.addonId}`,children:r(gt,{className:`h-3 w-3 ${d===N.addonId?"animate-spin":""}`})})]})]}),o?.addonId===N.addonId&&o.type==="logs"&&r("div",{className:"border-t border-border/40 bg-muted/5",children:r(Wt,{addonId:N.addonId,agentId:t,maxHeight:"max-h-48",showFilters:!1,onClose:()=>s(N.addonId,"logs")})}),o?.addonId===N.addonId&&o.type==="events"&&r("div",{className:"border-t border-border/40 bg-muted/5",children:r(or,{addonId:N.addonId,category:"addon.*",maxHeight:"max-h-48",onClose:()=>s(N.addonId,"events")})})]},N.addonId))}),l&&a.length===0&&r("div",{className:"px-3 py-2 pl-9 text-[10px] text-muted-foreground",children:"No services"})]})}function l7({nodeId:e,processes:t}){const[n,o]=$(null),s=(a,i)=>{o(l=>l?.addonId===a&&l.type===i?null:{addonId:a,type:i})};return t.length===0?r("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No processes on this node"}):r("div",{className:"space-y-2 py-1",children:t.map((a,i)=>r(i7,{proc:a,nodeId:e,defaultExpanded:i===0,activePanel:n,onTogglePanel:s},a.name))})}function c7(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`}function d7(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function u7({nodeId:e}){const t=ke(),n=nt(),[o,s]=$("all"),a=Pr("metrics.node-processes-snapshot",k=>k.nodeId===e),{data:i}=Jg({nodeId:e},{staleTime:6e4}),l=a?.processes??i,c=U(()=>l?[...l]:[],[l]),d=U(()=>o==="ghost"?c.filter(k=>k.classification==="ghost"):c,[c,o]),f=U(()=>{const k=c.filter(M=>M.classification==="ghost"),S=new Map;for(const M of k)S.has(M.ppid)||S.set(M.ppid,[]),S.get(M.ppid).push(M);return[...S.entries()].filter(([,M])=>M.length>1).map(([M,P])=>({ppid:M,children:P})).sort((M,P)=>P.children.length-M.children.length)},[c]),p=eb({onSettled:()=>{t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]})}}),m=U(()=>{const k=new Map;for(const S of c)k.set(S.pid,S.classification);return k},[c]),h=async(k,S)=>{if(k.classification==="root"||k.classification==="system")return;const M=k.classification==="ghost"?"ghost":k.addonId??"process",P=S?"SIGKILL":"SIGTERM";await n({title:`Send ${P}?`,message:`Target pid ${k.pid} (${M}) on node ${e}.`,confirmLabel:`Send ${P}`,variant:"danger"})&&p.mutate({nodeId:e,pid:k.pid,force:S})},g=async(k,S)=>{try{await p.mutateAsync({nodeId:e,pid:k,force:S})}catch{}},b=async k=>{const S=m.get(k.ppid);if(S==="root"||S==="system"){await n({title:"Cannot kill protected ancestor",message:S==="root"?`pid ${k.ppid} is the current node supervisor. Restart the node via the cluster page instead.`:`pid ${k.ppid} is a system ancestor (concurrently / vite / npm wrapper). Killing it would tear down the dev tree.`,confirmLabel:"OK",cancelLabel:"Close",variant:"warning"});return}await n({title:`Kill ghost parent + ${k.children.length} child(ren)?`,message:`SIGKILL parent pid ${k.ppid} and SIGTERM ${k.children.length} ghost child(ren) on node ${e}.`,confirmLabel:"Kill all",variant:"danger"})&&(await Promise.all([g(k.ppid,!0),...k.children.map(P=>g(P.pid,!1))]),t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}))},x=async()=>{const k=c.filter(M=>M.classification==="ghost");k.length===0||!await n({title:`Kill all ${k.length} ghost process(es)?`,message:`SIGKILL ${k.length} ghost process(es) on node ${e}. This is irreversible.`,confirmLabel:"Kill all",variant:"danger"})||(await Promise.all(k.map(M=>g(M.pid,!0))),t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}))},y=c.filter(k=>k.classification==="ghost").length,w=c.filter(k=>k.classification==="managed").length,v=c.filter(k=>k.classification==="root").length,N=c.filter(k=>k.classification==="system").length;return u("div",{className:"space-y-4",children:[u("div",{className:"flex items-start justify-between gap-4",children:[u("p",{className:"text-[11px] text-foreground-subtle",children:["ps"," scan + kernel `$process.list` cross-reference. Ghosts = camstack-shaped commands with no managed binding (usually orphaned to ppid=1). Refreshes every 10s."]}),u("button",{type:"button",onClick:()=>t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}),className:"inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover",children:[r(ut,{className:"h-3 w-3"})," Refresh"]})]}),u("div",{className:"grid grid-cols-4 gap-3",children:[u("div",{className:"rounded-lg border border-border p-3",children:[r("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Root"}),r("div",{className:"text-xl font-semibold text-foreground",children:v})]}),u("div",{className:"rounded-lg border border-border p-3",children:[r("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Managed"}),r("div",{className:"text-xl font-semibold text-foreground",children:w})]}),u("div",{className:"rounded-lg border border-border p-3",children:[r("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"System"}),r("div",{className:"text-xl font-semibold text-foreground",children:N})]}),u("div",{className:`rounded-lg border p-3 ${y>0?"border-destructive/40 bg-destructive/5":"border-border"}`,children:[u("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle flex items-center gap-1",children:[y>0&&r(Yo,{className:"h-3 w-3 text-destructive"})," Ghosts"]}),r("div",{className:`text-xl font-semibold ${y>0?"text-destructive":"text-foreground"}`,children:y})]})]}),f.length>0&&u("div",{className:"rounded-lg border border-amber-500/40 bg-amber-500/5 p-3",children:[u("div",{className:"flex items-center gap-1 text-[11px] font-semibold text-amber-400 mb-2",children:[r(bt,{className:"h-3 w-3"})," Recurring ghost parents (",f.length,")"]}),r("div",{className:"space-y-1.5",children:f.map(k=>u("div",{className:"text-[11px] text-foreground flex items-center justify-between gap-2",children:[u("div",{className:"flex items-center gap-2",children:[u("span",{className:"font-mono text-foreground-subtle",children:["ppid ",k.ppid]}),u("span",{children:["→ ",k.children.length," ghost(s)"]})]}),u("button",{type:"button",disabled:p.isPending,onClick:()=>{b(k)},className:"inline-flex items-center gap-1 rounded border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] text-amber-400 hover:bg-amber-500/20 disabled:opacity-30",children:[r(Yo,{className:"h-3 w-3"})," Kill parent + ",k.children.length]})]},k.ppid))})]}),u("div",{className:"flex items-center justify-between gap-2 text-[11px]",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-foreground-subtle",children:"Filter:"}),u("button",{type:"button",className:`px-2 py-0.5 rounded ${o==="all"?"bg-primary text-primary-foreground":"border border-border text-foreground hover:bg-surface-hover"}`,onClick:()=>s("all"),children:["All (",c.length,")"]}),u("button",{type:"button",className:`px-2 py-0.5 rounded ${o==="ghost"?"bg-destructive text-destructive-foreground":"border border-border text-foreground hover:bg-surface-hover"}`,onClick:()=>s("ghost"),children:["Ghost only (",y,")"]})]}),y>0&&u("button",{type:"button",disabled:p.isPending,onClick:()=>{x()},className:"inline-flex items-center gap-1 rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive/20 disabled:opacity-30",children:[r(Yo,{className:"h-3 w-3"})," Kill all ",y," ghost(s)"]})]}),r("div",{className:"rounded-lg border border-border overflow-hidden",children:u("table",{className:"w-full text-xs",children:[r("thead",{className:"bg-surface",children:u("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[r("th",{className:"text-left px-3 py-2",children:"Class"}),r("th",{className:"text-right px-3 py-2",children:"PID"}),r("th",{className:"text-right px-3 py-2",children:"PPID"}),r("th",{className:"text-left px-3 py-2",children:"Addon"}),r("th",{className:"text-left px-3 py-2",children:"Command"}),r("th",{className:"text-right px-3 py-2",children:"CPU%"}),r("th",{className:"text-right px-3 py-2",children:"RSS"}),r("th",{className:"text-right px-3 py-2",children:"Uptime"}),r("th",{className:"w-44"})]})}),u("tbody",{children:[d.length===0&&r("tr",{children:r("td",{colSpan:9,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:o==="ghost"?"No ghost processes detected.":"Scanning…"})}),d.map(k=>u("tr",{className:`border-t border-border ${k.classification==="ghost"?"bg-destructive/5":""}`,children:[r("td",{className:"px-3 py-2",children:r("span",{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${k.classification==="ghost"?"bg-destructive/20 text-destructive":k.classification==="root"?"bg-sky-500/20 text-sky-400":k.classification==="system"?"bg-foreground-subtle/20 text-foreground-subtle":"bg-success/20 text-success"}`,children:k.classification})}),r("td",{className:"px-3 py-2 text-right font-mono text-foreground",children:k.pid}),u("td",{className:"px-3 py-2 text-right font-mono text-foreground-subtle",children:[k.ppid,k.orphaned?" ⚠":""]}),r("td",{className:"px-3 py-2 text-foreground-subtle text-[11px]",children:k.addonId??"—"}),r("td",{className:"px-3 py-2 font-mono text-[10px] text-foreground-subtle break-all",children:d7(k.command)}),r("td",{className:"px-3 py-2 text-right text-foreground",children:k.cpuPercent.toFixed(1)}),r("td",{className:"px-3 py-2 text-right text-foreground",children:kt(k.memoryRssBytes)}),r("td",{className:"px-3 py-2 text-right text-foreground-subtle",children:c7(k.uptimeSec)}),r("td",{className:"px-3 py-2 text-right",children:u("div",{className:"inline-flex gap-1",children:[u("button",{type:"button",disabled:p.isPending||k.classification==="root"||k.classification==="system",onClick:()=>{h(k,!1)},title:"SIGTERM",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-border text-[10px] text-foreground hover:bg-surface-hover disabled:opacity-30",children:[r(Ge,{className:"h-3 w-3"})," Term"]}),u("button",{type:"button",disabled:p.isPending||k.classification==="root"||k.classification==="system",onClick:()=>{h(k,!0)},title:"SIGKILL",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-destructive/30 text-[10px] text-destructive hover:bg-destructive/10 disabled:opacity-30",children:[r(Yo,{className:"h-3 w-3"})," Kill"]})]})})]},k.pid))]})]})}),p.isError&&u("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive",children:["Kill failed: ",p.error instanceof Error?p.error.message:"unknown"]})]})}function p7({nodeId:e,addonIds:t}){return t.length===0?r("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No addons on this node"}):r("div",{className:"w-full py-2",children:r(Or,{nodeId:e,addonIds:t,level:"global"})})}function f7({nodeId:e,addons:t}){const n=ke(),{data:o,isLoading:s}=xb({nodeId:e}),a=U(()=>{const l=new Map;for(const c of t)for(const d of c.capabilities){const f=l.get(d)??[];f.push(c.id),l.set(d,f)}return[...l.entries()].sort(([c],[d])=>c.localeCompare(d)).map(([c,d])=>({capName:c,providers:d}))},[t]),i=yb({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCapabilityBindings"]]})}});return a.length===0?r("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No capabilities on this node"}):u("table",{className:"w-full text-xs",children:[r("thead",{children:u("tr",{className:"text-muted-foreground text-left",children:[r("th",{className:"py-2 font-medium w-1/2",children:"Capability"}),r("th",{className:"py-2 font-medium",children:"Bound provider"})]})}),r("tbody",{children:a.map(({capName:l,providers:c})=>{const f=o?.[l]??c[0]??"",p=c.length===1;return u("tr",{className:"border-t border-border/50",children:[r("td",{className:"py-2 font-medium",children:l}),r("td",{className:"py-2",children:r("select",{value:f,onChange:m=>i.mutate({nodeId:e,capName:l,addonId:m.target.value}),disabled:p||i.isPending||s,className:"w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-60",title:p?"Only one provider installed — choice becomes available once a second addon registers this capability":void 0,children:c.map(m=>r("option",{value:m,children:m},m))})})]},l)})})]})}function m7(e){if(e==null)return"—";const t=Math.floor(e/1e3),n=Math.floor(t/86400),o=Math.floor(t%86400/3600),s=Math.floor(t%3600/60);return n>0?`${n}d ${o}h ${s}m`:o>0?`${o}h ${s}m`:`${s}m`}function h7(e){const[t,n]=$(!1),[o,s]=$(e.name),a=ke(),i=ob({onSuccess:()=>{a.invalidateQueries({queryKey:[["nodes","topology"]]})}}),l=(e.localIps??[]).filter(p=>!p.includes(":")),c=(e.localIps??[]).filter(p=>p.includes(":")),d=async()=>{if(!o.trim()||o===e.name){n(!1);return}try{await i.mutateAsync({nodeId:e.nodeId,name:o.trim()}),n(!1)}catch(p){console.error("Rename failed:",p)}},f=[["Node ID",r("span",{className:"font-mono text-xs",children:e.nodeId})],["Display Name",t?u("div",{className:"flex items-center gap-1.5",children:[r("input",{type:"text",className:"flex-1 px-2 py-0.5 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary",value:o,onChange:p=>s(p.target.value),onKeyDown:p=>{p.key==="Enter"&&d(),p.key==="Escape"&&n(!1)},disabled:i.isPending,autoFocus:!0}),r("button",{onClick:()=>void d(),disabled:i.isPending,className:"p-0.5 text-success hover:bg-success/10 rounded",title:"Save",children:r(Mt,{className:"h-3.5 w-3.5"})}),r("button",{onClick:()=>n(!1),className:"p-0.5 text-muted-foreground hover:bg-muted rounded",title:"Cancel",children:r(Ve,{className:"h-3.5 w-3.5"})})]}):u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"text-xs",children:e.name}),!e.isHub&&r("button",{onClick:()=>{s(e.name),n(!0)},className:"p-0.5 text-muted-foreground hover:text-primary rounded",title:"Rename",children:r(Rr,{className:"h-3 w-3"})})]})],["Hostname",r("span",{className:"text-xs",children:e.hostname})],["Role",e.isHub?r("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium",children:"Hub"}):r("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium",children:"Agent"})],["Platform",u("span",{className:"text-xs",children:[e.platform," / ",e.arch]})],["CPU",u("span",{className:"text-xs",children:[e.cpuModel??"—"," (",e.cpuCores," cores)"]})],["Memory",r("span",{className:"text-xs",children:e.memoryMB>0?`${(e.memoryMB/1024).toFixed(1)} GB`:"—"})],["Uptime",r("span",{className:"text-xs",children:m7(e.uptime)})],["Engines",e.engines.length>0?r("div",{className:"flex flex-wrap gap-1",children:e.engines.map(p=>r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:p},p))}):r("span",{className:"text-xs text-muted-foreground",children:"—"})]];return l.length>0&&f.push(["IPv4",r("div",{className:"flex flex-wrap gap-1.5",children:l.map((p,m)=>r("span",{className:"font-mono text-xs px-1.5 py-0.5 rounded bg-muted",children:p},`${p}-${m}`))})]),c.length>0&&f.push(["IPv6",r("div",{className:"flex flex-wrap gap-1.5",children:c.map((p,m)=>r("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]",title:p,children:p},`${p}-${m}`))})]),r("div",{className:"py-2",children:r("table",{className:"w-full text-sm",children:r("tbody",{children:f.map(([p,m],h)=>u("tr",{className:h%2===0?"bg-muted/20":"",children:[r("td",{className:"py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap",children:p}),r("td",{className:"py-1.5 px-2",children:m})]},p))})})})}function g7({node:e}){const[t,n]=$("info"),o=e.processes??[],s=e.addons.map(a=>a.id);return e.isOnline?u("div",{className:"border border-border rounded-xl overflow-hidden",children:[u("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/30 border-b border-border",children:[r("div",{className:"w-2.5 h-2.5 rounded-full bg-success"}),r("span",{className:"text-sm font-semibold",children:e.name}),u("span",{className:"text-xs text-muted-foreground",children:[e.cpuModel??e.platform," · ",e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:""," · ",e.arch]}),e.engines.map(a=>r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:a},a)),u("div",{className:"ml-auto flex gap-3 text-xs text-muted-foreground",children:[u("span",{className:"flex items-center gap-1",children:[r(dt,{className:"h-3 w-3"})," ",e.cpuPercent,"%"]}),u("span",{className:"flex items-center gap-1",children:[r(Jc,{className:"h-3 w-3"})," ",e.memoryPercent,"%"]})]})]}),r("div",{className:"flex border-b border-border px-4",children:["info","addons","forks","processes","settings","capabilities"].map(a=>r("button",{onClick:()=>n(a),className:`px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===a?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:a==="info"?"Info":a==="addons"?`Addons (${e.addons.length})`:a==="forks"?`Forks (${o.length})`:a==="processes"?"Processes":a==="settings"?"Settings":"Capabilities"},a))}),u("div",{className:"px-4 py-2",children:[t==="info"&&r(h7,{nodeId:e.id,name:e.name,hostname:e.hostname,platform:e.platform,arch:e.arch,cpuModel:e.cpuModel,cpuCores:e.cpuCores,memoryMB:e.memoryMB,engines:e.engines,isHub:e.isHub,uptime:e.uptime,localIps:e.localIps}),t==="addons"&&r(r7,{nodeId:e.id,addons:e.addons,isHub:e.isHub}),t==="forks"&&r(l7,{nodeId:e.id,processes:o}),t==="processes"&&r(u7,{nodeId:e.id}),t==="settings"&&r(p7,{nodeId:e.id,addonIds:s}),t==="capabilities"&&r(f7,{nodeId:e.id,addons:e.addons})]})]}):u("div",{className:"border border-border rounded-xl overflow-hidden opacity-60",children:[u("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/30",children:[r("div",{className:"w-2.5 h-2.5 rounded-full bg-destructive"}),r("span",{className:"text-sm font-semibold",children:e.name}),u("span",{className:"text-xs text-muted-foreground",children:[e.cpuModel??e.platform," · ",e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:""," · ",e.arch]}),e.engines.map(a=>r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:a},a)),r("span",{className:"ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:"offline"})]}),u("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:[e.addons.length," addon",e.addons.length!==1?"s":""," assigned — will resume when node reconnects"]})]})}function b7({nodes:e}){const t=[...e].sort((n,o)=>n.isHub?-1:o.isHub?1:n.isOnline&&!o.isOnline?-1:!n.isOnline&&o.isOnline?1:n.name.localeCompare(o.name));return r("div",{className:"flex flex-col gap-4",children:t.map(n=>r(g7,{node:n},n.id))})}function Qe(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=Qe(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var x7={value:()=>{}};function Ma(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new vs(n)}function vs(e){this._=e}function y7(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",s=n.indexOf(".");if(s>=0&&(o=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}vs.prototype=Ma.prototype={constructor:vs,on:function(e,t){var n=this._,o=y7(e+"",n),s,a=-1,i=o.length;if(arguments.length<2){for(;++a<i;)if((s=(e=o[a]).type)&&(s=v7(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<i;)if(s=(e=o[a]).type)n[s]=Cp(n[s],e.name,t);else if(t==null)for(s in n)n[s]=Cp(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new vs(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),o=0,s,a;o<s;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],o=0,s=a.length;o<s;++o)a[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],s=0,a=o.length;s<a;++s)o[s].value.apply(t,n)}};function v7(e,t){for(var n=0,o=e.length,s;n<o;++n)if((s=e[n]).name===t)return s.value}function Cp(e,t,n){for(var o=0,s=e.length;o<s;++o)if(e[o].name===t){e[o]=x7,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var ml="http://www.w3.org/1999/xhtml";const Mp={svg:"http://www.w3.org/2000/svg",xhtml:ml,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ia(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Mp.hasOwnProperty(t)?{space:Mp[t],local:e}:e}function w7(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ml&&t.documentElement.namespaceURI===ml?t.createElement(e):t.createElementNS(n,e)}}function N7(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function d0(e){var t=Ia(e);return(t.local?N7:w7)(t)}function k7(){}function ad(e){return e==null?k7:function(){return this.querySelector(e)}}function S7(e){typeof e!="function"&&(e=ad(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=o[s]=new Array(i),c,d,f=0;f<i;++f)(c=a[f])&&(d=e.call(c,c.__data__,f,a))&&("__data__"in c&&(d.__data__=c.__data__),l[f]=d);return new pt(o,this._parents)}function C7(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function M7(){return[]}function u0(e){return e==null?M7:function(){return this.querySelectorAll(e)}}function I7(e){return function(){return C7(e.apply(this,arguments))}}function A7(e){typeof e=="function"?e=I7(e):e=u0(e);for(var t=this._groups,n=t.length,o=[],s=[],a=0;a<n;++a)for(var i=t[a],l=i.length,c,d=0;d<l;++d)(c=i[d])&&(o.push(e.call(c,c.__data__,d,i)),s.push(c));return new pt(o,s)}function p0(e){return function(){return this.matches(e)}}function f0(e){return function(t){return t.matches(e)}}var P7=Array.prototype.find;function E7(e){return function(){return P7.call(this.children,e)}}function $7(){return this.firstElementChild}function _7(e){return this.select(e==null?$7:E7(typeof e=="function"?e:f0(e)))}var D7=Array.prototype.filter;function L7(){return Array.from(this.children)}function T7(e){return function(){return D7.call(this.children,e)}}function R7(e){return this.selectAll(e==null?L7:T7(typeof e=="function"?e:f0(e)))}function O7(e){typeof e!="function"&&(e=p0(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=o[s]=[],c,d=0;d<i;++d)(c=a[d])&&e.call(c,c.__data__,d,a)&&l.push(c);return new pt(o,this._parents)}function m0(e){return new Array(e.length)}function z7(){return new pt(this._enter||this._groups.map(m0),this._parents)}function Fs(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Fs.prototype={constructor:Fs,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function B7(e){return function(){return e}}function F7(e,t,n,o,s,a){for(var i=0,l,c=t.length,d=a.length;i<d;++i)(l=t[i])?(l.__data__=a[i],o[i]=l):n[i]=new Fs(e,a[i]);for(;i<c;++i)(l=t[i])&&(s[i]=l)}function j7(e,t,n,o,s,a,i){var l,c,d=new Map,f=t.length,p=a.length,m=new Array(f),h;for(l=0;l<f;++l)(c=t[l])&&(m[l]=h=i.call(c,c.__data__,l,t)+"",d.has(h)?s[l]=c:d.set(h,c));for(l=0;l<p;++l)h=i.call(e,a[l],l,a)+"",(c=d.get(h))?(o[l]=c,c.__data__=a[l],d.delete(h)):n[l]=new Fs(e,a[l]);for(l=0;l<f;++l)(c=t[l])&&d.get(m[l])===c&&(s[l]=c)}function H7(e){return e.__data__}function V7(e,t){if(!arguments.length)return Array.from(this,H7);var n=t?j7:F7,o=this._parents,s=this._groups;typeof e!="function"&&(e=B7(e));for(var a=s.length,i=new Array(a),l=new Array(a),c=new Array(a),d=0;d<a;++d){var f=o[d],p=s[d],m=p.length,h=q7(e.call(f,f&&f.__data__,d,o)),g=h.length,b=l[d]=new Array(g),x=i[d]=new Array(g),y=c[d]=new Array(m);n(f,p,b,x,y,h,t);for(var w=0,v=0,N,k;w<g;++w)if(N=b[w]){for(w>=v&&(v=w+1);!(k=x[v])&&++v<g;);N._next=k||null}}return i=new pt(i,o),i._enter=l,i._exit=c,i}function q7(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function U7(){return new pt(this._exit||this._groups.map(m0),this._parents)}function Q7(e,t,n){var o=this.enter(),s=this,a=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?a.remove():n(a),o&&s?o.merge(s).order():s}function K7(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,s=n.length,a=o.length,i=Math.min(s,a),l=new Array(s),c=0;c<i;++c)for(var d=n[c],f=o[c],p=d.length,m=l[c]=new Array(p),h,g=0;g<p;++g)(h=d[g]||f[g])&&(m[g]=h);for(;c<s;++c)l[c]=n[c];return new pt(l,this._parents)}function G7(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],s=o.length-1,a=o[s],i;--s>=0;)(i=o[s])&&(a&&i.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(i,a),a=i);return this}function W7(e){e||(e=Y7);function t(p,m){return p&&m?e(p.__data__,m.__data__):!p-!m}for(var n=this._groups,o=n.length,s=new Array(o),a=0;a<o;++a){for(var i=n[a],l=i.length,c=s[a]=new Array(l),d,f=0;f<l;++f)(d=i[f])&&(c[f]=d);c.sort(t)}return new pt(s,this._parents).order()}function Y7(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Z7(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function X7(){return Array.from(this)}function J7(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],s=0,a=o.length;s<a;++s){var i=o[s];if(i)return i}return null}function ez(){let e=0;for(const t of this)++e;return e}function tz(){return!this.node()}function nz(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var s=t[n],a=0,i=s.length,l;a<i;++a)(l=s[a])&&e.call(l,l.__data__,a,s);return this}function rz(e){return function(){this.removeAttribute(e)}}function oz(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sz(e,t){return function(){this.setAttribute(e,t)}}function az(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function iz(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function lz(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function cz(e,t){var n=Ia(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?oz:rz:typeof t=="function"?n.local?lz:iz:n.local?az:sz)(n,t))}function h0(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function dz(e){return function(){this.style.removeProperty(e)}}function uz(e,t,n){return function(){this.style.setProperty(e,t,n)}}function pz(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function fz(e,t,n){return arguments.length>1?this.each((t==null?dz:typeof t=="function"?pz:uz)(e,t,n??"")):wr(this.node(),e)}function wr(e,t){return e.style.getPropertyValue(t)||h0(e).getComputedStyle(e,null).getPropertyValue(t)}function mz(e){return function(){delete this[e]}}function hz(e,t){return function(){this[e]=t}}function gz(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function bz(e,t){return arguments.length>1?this.each((t==null?mz:typeof t=="function"?gz:hz)(e,t)):this.node()[e]}function g0(e){return e.trim().split(/^|\s+/)}function id(e){return e.classList||new b0(e)}function b0(e){this._node=e,this._names=g0(e.getAttribute("class")||"")}b0.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function x0(e,t){for(var n=id(e),o=-1,s=t.length;++o<s;)n.add(t[o])}function y0(e,t){for(var n=id(e),o=-1,s=t.length;++o<s;)n.remove(t[o])}function xz(e){return function(){x0(this,e)}}function yz(e){return function(){y0(this,e)}}function vz(e,t){return function(){(t.apply(this,arguments)?x0:y0)(this,e)}}function wz(e,t){var n=g0(e+"");if(arguments.length<2){for(var o=id(this.node()),s=-1,a=n.length;++s<a;)if(!o.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?vz:t?xz:yz)(n,t))}function Nz(){this.textContent=""}function kz(e){return function(){this.textContent=e}}function Sz(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Cz(e){return arguments.length?this.each(e==null?Nz:(typeof e=="function"?Sz:kz)(e)):this.node().textContent}function Mz(){this.innerHTML=""}function Iz(e){return function(){this.innerHTML=e}}function Az(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Pz(e){return arguments.length?this.each(e==null?Mz:(typeof e=="function"?Az:Iz)(e)):this.node().innerHTML}function Ez(){this.nextSibling&&this.parentNode.appendChild(this)}function $z(){return this.each(Ez)}function _z(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Dz(){return this.each(_z)}function Lz(e){var t=typeof e=="function"?e:d0(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Tz(){return null}function Rz(e,t){var n=typeof e=="function"?e:d0(e),o=t==null?Tz:typeof t=="function"?t:ad(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Oz(){var e=this.parentNode;e&&e.removeChild(this)}function zz(){return this.each(Oz)}function Bz(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Fz(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function jz(e){return this.select(e?Fz:Bz)}function Hz(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Vz(e){return function(t){e.call(this,t,this.__data__)}}function qz(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Uz(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,s=t.length,a;n<s;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++o]=a;++o?t.length=o:delete this.__on}}}function Qz(e,t,n){return function(){var o=this.__on,s,a=Vz(t);if(o){for(var i=0,l=o.length;i<l;++i)if((s=o[i]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=a,s.options=n),s.value=t;return}}this.addEventListener(e.type,a,n),s={type:e.type,name:e.name,value:t,listener:a,options:n},o?o.push(s):this.__on=[s]}}function Kz(e,t,n){var o=qz(e+""),s,a=o.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,d=l.length,f;c<d;++c)for(s=0,f=l[c];s<a;++s)if((i=o[s]).type===f.type&&i.name===f.name)return f.value}return}for(l=t?Qz:Uz,s=0;s<a;++s)this.each(l(o[s],t,n));return this}function v0(e,t,n){var o=h0(e),s=o.CustomEvent;typeof s=="function"?s=new s(t,n):(s=o.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function Gz(e,t){return function(){return v0(this,e,t)}}function Wz(e,t){return function(){return v0(this,e,t.apply(this,arguments))}}function Yz(e,t){return this.each((typeof t=="function"?Wz:Gz)(e,t))}function*Zz(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],s=0,a=o.length,i;s<a;++s)(i=o[s])&&(yield i)}var w0=[null];function pt(e,t){this._groups=e,this._parents=t}function Lo(){return new pt([[document.documentElement]],w0)}function Xz(){return this}pt.prototype=Lo.prototype={constructor:pt,select:S7,selectAll:A7,selectChild:_7,selectChildren:R7,filter:O7,data:V7,enter:z7,exit:U7,join:Q7,merge:K7,selection:Xz,order:G7,sort:W7,call:Z7,nodes:X7,node:J7,size:ez,empty:tz,each:nz,attr:cz,style:fz,property:bz,classed:wz,text:Cz,html:Pz,raise:$z,lower:Dz,append:Lz,insert:Rz,remove:zz,clone:jz,datum:Hz,on:Kz,dispatch:Yz,[Symbol.iterator]:Zz};function it(e){return typeof e=="string"?new pt([[document.querySelector(e)]],[document.documentElement]):new pt([[e]],w0)}function Jz(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Pt(e,t){if(e=Jz(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const eB={passive:!1},fo={capture:!0,passive:!1};function Si(e){e.stopImmediatePropagation()}function fr(e){e.preventDefault(),e.stopImmediatePropagation()}function N0(e){var t=e.document.documentElement,n=it(e).on("dragstart.drag",fr,fo);"onselectstart"in t?n.on("selectstart.drag",fr,fo):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function k0(e,t){var n=e.document.documentElement,o=it(e).on("dragstart.drag",null);t&&(o.on("click.drag",fr,fo),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const as=e=>()=>e;function hl(e,{sourceEvent:t,subject:n,target:o,identifier:s,active:a,x:i,y:l,dx:c,dy:d,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:f}})}hl.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function tB(e){return!e.ctrlKey&&!e.button}function nB(){return this.parentNode}function rB(e,t){return t??{x:e.x,y:e.y}}function oB(){return navigator.maxTouchPoints||"ontouchstart"in this}function S0(){var e=tB,t=nB,n=rB,o=oB,s={},a=Ma("start","drag","end"),i=0,l,c,d,f,p=0;function m(N){N.on("mousedown.drag",h).filter(o).on("touchstart.drag",x).on("touchmove.drag",y,eB).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(N,k){if(!(f||!e.call(this,N,k))){var S=v(this,t.call(this,N,k),N,k,"mouse");S&&(it(N.view).on("mousemove.drag",g,fo).on("mouseup.drag",b,fo),N0(N.view),Si(N),d=!1,l=N.clientX,c=N.clientY,S("start",N))}}function g(N){if(fr(N),!d){var k=N.clientX-l,S=N.clientY-c;d=k*k+S*S>p}s.mouse("drag",N)}function b(N){it(N.view).on("mousemove.drag mouseup.drag",null),k0(N.view,d),fr(N),s.mouse("end",N)}function x(N,k){if(e.call(this,N,k)){var S=N.changedTouches,M=t.call(this,N,k),P=S.length,A,z;for(A=0;A<P;++A)(z=v(this,M,N,k,S[A].identifier,S[A]))&&(Si(N),z("start",N,S[A]))}}function y(N){var k=N.changedTouches,S=k.length,M,P;for(M=0;M<S;++M)(P=s[k[M].identifier])&&(fr(N),P("drag",N,k[M]))}function w(N){var k=N.changedTouches,S=k.length,M,P;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),M=0;M<S;++M)(P=s[k[M].identifier])&&(Si(N),P("end",N,k[M]))}function v(N,k,S,M,P,A){var z=a.copy(),D=Pt(A||S,k),T,O,I;if((I=n.call(N,new hl("beforestart",{sourceEvent:S,target:m,identifier:P,active:i,x:D[0],y:D[1],dx:0,dy:0,dispatch:z}),M))!=null)return T=I.x-D[0]||0,O=I.y-D[1]||0,function L(_,R,B){var F=D,j;switch(_){case"start":s[P]=L,j=i++;break;case"end":delete s[P],--i;case"drag":D=Pt(B||R,k),j=i;break}z.call(_,N,new hl(_,{sourceEvent:R,subject:I,target:m,identifier:P,active:j,x:D[0]+T,y:D[1]+O,dx:D[0]-F[0],dy:D[1]-F[1],dispatch:z}),M)}}return m.filter=function(N){return arguments.length?(e=typeof N=="function"?N:as(!!N),m):e},m.container=function(N){return arguments.length?(t=typeof N=="function"?N:as(N),m):t},m.subject=function(N){return arguments.length?(n=typeof N=="function"?N:as(N),m):n},m.touchable=function(N){return arguments.length?(o=typeof N=="function"?N:as(!!N),m):o},m.on=function(){var N=a.on.apply(a,arguments);return N===a?m:N},m.clickDistance=function(N){return arguments.length?(p=(N=+N)*N,m):Math.sqrt(p)},m}function ld(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function C0(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function To(){}var mo=.7,js=1/mo,mr="\\s*([+-]?\\d+)\\s*",ho="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ut="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",sB=/^#([0-9a-f]{3,8})$/,aB=new RegExp(`^rgb\\(${mr},${mr},${mr}\\)$`),iB=new RegExp(`^rgb\\(${Ut},${Ut},${Ut}\\)$`),lB=new RegExp(`^rgba\\(${mr},${mr},${mr},${ho}\\)$`),cB=new RegExp(`^rgba\\(${Ut},${Ut},${Ut},${ho}\\)$`),dB=new RegExp(`^hsl\\(${ho},${Ut},${Ut}\\)$`),uB=new RegExp(`^hsla\\(${ho},${Ut},${Ut},${ho}\\)$`),Ip={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ld(To,Un,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ap,formatHex:Ap,formatHex8:pB,formatHsl:fB,formatRgb:Pp,toString:Pp});function Ap(){return this.rgb().formatHex()}function pB(){return this.rgb().formatHex8()}function fB(){return M0(this).formatHsl()}function Pp(){return this.rgb().formatRgb()}function Un(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=sB.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Ep(t):n===3?new tt(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?is(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?is(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=aB.exec(e))?new tt(t[1],t[2],t[3],1):(t=iB.exec(e))?new tt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=lB.exec(e))?is(t[1],t[2],t[3],t[4]):(t=cB.exec(e))?is(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=dB.exec(e))?Dp(t[1],t[2]/100,t[3]/100,1):(t=uB.exec(e))?Dp(t[1],t[2]/100,t[3]/100,t[4]):Ip.hasOwnProperty(e)?Ep(Ip[e]):e==="transparent"?new tt(NaN,NaN,NaN,0):null}function Ep(e){return new tt(e>>16&255,e>>8&255,e&255,1)}function is(e,t,n,o){return o<=0&&(e=t=n=NaN),new tt(e,t,n,o)}function mB(e){return e instanceof To||(e=Un(e)),e?(e=e.rgb(),new tt(e.r,e.g,e.b,e.opacity)):new tt}function gl(e,t,n,o){return arguments.length===1?mB(e):new tt(e,t,n,o??1)}function tt(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}ld(tt,gl,C0(To,{brighter(e){return e=e==null?js:Math.pow(js,e),new tt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?mo:Math.pow(mo,e),new tt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new tt(Fn(this.r),Fn(this.g),Fn(this.b),Hs(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:$p,formatHex:$p,formatHex8:hB,formatRgb:_p,toString:_p}));function $p(){return`#${Rn(this.r)}${Rn(this.g)}${Rn(this.b)}`}function hB(){return`#${Rn(this.r)}${Rn(this.g)}${Rn(this.b)}${Rn((isNaN(this.opacity)?1:this.opacity)*255)}`}function _p(){const e=Hs(this.opacity);return`${e===1?"rgb(":"rgba("}${Fn(this.r)}, ${Fn(this.g)}, ${Fn(this.b)}${e===1?")":`, ${e})`}`}function Hs(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Fn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Rn(e){return e=Fn(e),(e<16?"0":"")+e.toString(16)}function Dp(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Et(e,t,n,o)}function M0(e){if(e instanceof Et)return new Et(e.h,e.s,e.l,e.opacity);if(e instanceof To||(e=Un(e)),!e)return new Et;if(e instanceof Et)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,s=Math.min(t,n,o),a=Math.max(t,n,o),i=NaN,l=a-s,c=(a+s)/2;return l?(t===a?i=(n-o)/l+(n<o)*6:n===a?i=(o-t)/l+2:i=(t-n)/l+4,l/=c<.5?a+s:2-a-s,i*=60):l=c>0&&c<1?0:i,new Et(i,l,c,e.opacity)}function gB(e,t,n,o){return arguments.length===1?M0(e):new Et(e,t,n,o??1)}function Et(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}ld(Et,gB,C0(To,{brighter(e){return e=e==null?js:Math.pow(js,e),new Et(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?mo:Math.pow(mo,e),new Et(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,s=2*n-o;return new tt(Ci(e>=240?e-240:e+120,s,o),Ci(e,s,o),Ci(e<120?e+240:e-120,s,o),this.opacity)},clamp(){return new Et(Lp(this.h),ls(this.s),ls(this.l),Hs(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Hs(this.opacity);return`${e===1?"hsl(":"hsla("}${Lp(this.h)}, ${ls(this.s)*100}%, ${ls(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Lp(e){return e=(e||0)%360,e<0?e+360:e}function ls(e){return Math.max(0,Math.min(1,e||0))}function Ci(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const cd=e=>()=>e;function bB(e,t){return function(n){return e+n*t}}function xB(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function yB(e){return(e=+e)==1?I0:function(t,n){return n-t?xB(t,n,e):cd(isNaN(t)?n:t)}}function I0(e,t){var n=t-e;return n?bB(e,n):cd(isNaN(e)?t:e)}const Vs=(function e(t){var n=yB(t);function o(s,a){var i=n((s=gl(s)).r,(a=gl(a)).r),l=n(s.g,a.g),c=n(s.b,a.b),d=I0(s.opacity,a.opacity);return function(f){return s.r=i(f),s.g=l(f),s.b=c(f),s.opacity=d(f),s+""}}return o.gamma=e,o})(1);function vB(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),s;return function(a){for(s=0;s<n;++s)o[s]=e[s]*(1-a)+t[s]*a;return o}}function wB(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function NB(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,s=new Array(o),a=new Array(n),i;for(i=0;i<o;++i)s[i]=ro(e[i],t[i]);for(;i<n;++i)a[i]=t[i];return function(l){for(i=0;i<o;++i)a[i]=s[i](l);return a}}function kB(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function Ht(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function SB(e,t){var n={},o={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=ro(e[s],t[s]):o[s]=t[s];return function(a){for(s in n)o[s]=n[s](a);return o}}var bl=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Mi=new RegExp(bl.source,"g");function CB(e){return function(){return e}}function MB(e){return function(t){return e(t)+""}}function A0(e,t){var n=bl.lastIndex=Mi.lastIndex=0,o,s,a,i=-1,l=[],c=[];for(e=e+"",t=t+"";(o=bl.exec(e))&&(s=Mi.exec(t));)(a=s.index)>n&&(a=t.slice(n,a),l[i]?l[i]+=a:l[++i]=a),(o=o[0])===(s=s[0])?l[i]?l[i]+=s:l[++i]=s:(l[++i]=null,c.push({i,x:Ht(o,s)})),n=Mi.lastIndex;return n<t.length&&(a=t.slice(n),l[i]?l[i]+=a:l[++i]=a),l.length<2?c[0]?MB(c[0].x):CB(t):(t=c.length,function(d){for(var f=0,p;f<t;++f)l[(p=c[f]).i]=p.x(d);return l.join("")})}function ro(e,t){var n=typeof t,o;return t==null||n==="boolean"?cd(t):(n==="number"?Ht:n==="string"?(o=Un(t))?(t=o,Vs):A0:t instanceof Un?Vs:t instanceof Date?kB:wB(t)?vB:Array.isArray(t)?NB:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?SB:Ht)(e,t)}var Tp=180/Math.PI,xl={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function P0(e,t,n,o,s,a){var i,l,c;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(l=Math.sqrt(n*n+o*o))&&(n/=l,o/=l,c/=l),e*o<t*n&&(e=-e,t=-t,c=-c,i=-i),{translateX:s,translateY:a,rotate:Math.atan2(t,e)*Tp,skewX:Math.atan(c)*Tp,scaleX:i,scaleY:l}}var cs;function IB(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?xl:P0(t.a,t.b,t.c,t.d,t.e,t.f)}function AB(e){return e==null||(cs||(cs=document.createElementNS("http://www.w3.org/2000/svg","g")),cs.setAttribute("transform",e),!(e=cs.transform.baseVal.consolidate()))?xl:(e=e.matrix,P0(e.a,e.b,e.c,e.d,e.e,e.f))}function E0(e,t,n,o){function s(d){return d.length?d.pop()+" ":""}function a(d,f,p,m,h,g){if(d!==p||f!==m){var b=h.push("translate(",null,t,null,n);g.push({i:b-4,x:Ht(d,p)},{i:b-2,x:Ht(f,m)})}else(p||m)&&h.push("translate("+p+t+m+n)}function i(d,f,p,m){d!==f?(d-f>180?f+=360:f-d>180&&(d+=360),m.push({i:p.push(s(p)+"rotate(",null,o)-2,x:Ht(d,f)})):f&&p.push(s(p)+"rotate("+f+o)}function l(d,f,p,m){d!==f?m.push({i:p.push(s(p)+"skewX(",null,o)-2,x:Ht(d,f)}):f&&p.push(s(p)+"skewX("+f+o)}function c(d,f,p,m,h,g){if(d!==p||f!==m){var b=h.push(s(h)+"scale(",null,",",null,")");g.push({i:b-4,x:Ht(d,p)},{i:b-2,x:Ht(f,m)})}else(p!==1||m!==1)&&h.push(s(h)+"scale("+p+","+m+")")}return function(d,f){var p=[],m=[];return d=e(d),f=e(f),a(d.translateX,d.translateY,f.translateX,f.translateY,p,m),i(d.rotate,f.rotate,p,m),l(d.skewX,f.skewX,p,m),c(d.scaleX,d.scaleY,f.scaleX,f.scaleY,p,m),d=f=null,function(h){for(var g=-1,b=m.length,x;++g<b;)p[(x=m[g]).i]=x.x(h);return p.join("")}}}var PB=E0(IB,"px, ","px)","deg)"),EB=E0(AB,", ",")",")"),$B=1e-12;function Rp(e){return((e=Math.exp(e))+1/e)/2}function _B(e){return((e=Math.exp(e))-1/e)/2}function DB(e){return((e=Math.exp(2*e))-1)/(e+1)}const ws=(function e(t,n,o){function s(a,i){var l=a[0],c=a[1],d=a[2],f=i[0],p=i[1],m=i[2],h=f-l,g=p-c,b=h*h+g*g,x,y;if(b<$B)y=Math.log(m/d)/t,x=function(M){return[l+M*h,c+M*g,d*Math.exp(t*M*y)]};else{var w=Math.sqrt(b),v=(m*m-d*d+o*b)/(2*d*n*w),N=(m*m-d*d-o*b)/(2*m*n*w),k=Math.log(Math.sqrt(v*v+1)-v),S=Math.log(Math.sqrt(N*N+1)-N);y=(S-k)/t,x=function(M){var P=M*y,A=Rp(k),z=d/(n*w)*(A*DB(t*P+k)-_B(k));return[l+z*h,c+z*g,d*A/Rp(t*P+k)]}}return x.duration=y*1e3*t/Math.SQRT2,x}return s.rho=function(a){var i=Math.max(.001,+a),l=i*i,c=l*l;return e(i,l,c)},s})(Math.SQRT2,2,4);var Nr=0,Gr=0,qr=0,$0=1e3,qs,Wr,Us=0,Qn=0,Aa=0,go=typeof performance=="object"&&performance.now?performance:Date,_0=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function dd(){return Qn||(_0(LB),Qn=go.now()+Aa)}function LB(){Qn=0}function Qs(){this._call=this._time=this._next=null}Qs.prototype=D0.prototype={constructor:Qs,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?dd():+n)+(t==null?0:+t),!this._next&&Wr!==this&&(Wr?Wr._next=this:qs=this,Wr=this),this._call=e,this._time=n,yl()},stop:function(){this._call&&(this._call=null,this._time=1/0,yl())}};function D0(e,t,n){var o=new Qs;return o.restart(e,t,n),o}function TB(){dd(),++Nr;for(var e=qs,t;e;)(t=Qn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Nr}function Op(){Qn=(Us=go.now())+Aa,Nr=Gr=0;try{TB()}finally{Nr=0,OB(),Qn=0}}function RB(){var e=go.now(),t=e-Us;t>$0&&(Aa-=t,Us=e)}function OB(){for(var e,t=qs,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:qs=n);Wr=e,yl(o)}function yl(e){if(!Nr){Gr&&(Gr=clearTimeout(Gr));var t=e-Qn;t>24?(e<1/0&&(Gr=setTimeout(Op,e-go.now()-Aa)),qr&&(qr=clearInterval(qr))):(qr||(Us=go.now(),qr=setInterval(RB,$0)),Nr=1,_0(Op))}}function zp(e,t,n){var o=new Qs;return t=t==null?0:+t,o.restart(s=>{o.stop(),e(s+t)},t,n),o}var zB=Ma("start","end","cancel","interrupt"),BB=[],L0=0,Bp=1,vl=2,Ns=3,Fp=4,wl=5,ks=6;function Pa(e,t,n,o,s,a){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;FB(e,n,{name:t,index:o,group:s,on:zB,tween:BB,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:L0})}function ud(e,t){var n=zt(e,t);if(n.state>L0)throw new Error("too late; already scheduled");return n}function Yt(e,t){var n=zt(e,t);if(n.state>Ns)throw new Error("too late; already running");return n}function zt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function FB(e,t,n){var o=e.__transition,s;o[t]=n,n.timer=D0(a,0,n.time);function a(d){n.state=Bp,n.timer.restart(i,n.delay,n.time),n.delay<=d&&i(d-n.delay)}function i(d){var f,p,m,h;if(n.state!==Bp)return c();for(f in o)if(h=o[f],h.name===n.name){if(h.state===Ns)return zp(i);h.state===Fp?(h.state=ks,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[f]):+f<t&&(h.state=ks,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[f])}if(zp(function(){n.state===Ns&&(n.state=Fp,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=vl,n.on.call("start",e,e.__data__,n.index,n.group),n.state===vl){for(n.state=Ns,s=new Array(m=n.tween.length),f=0,p=-1;f<m;++f)(h=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(s[++p]=h);s.length=p+1}}function l(d){for(var f=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(c),n.state=wl,1),p=-1,m=s.length;++p<m;)s[p].call(e,f);n.state===wl&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=ks,n.timer.stop(),delete o[t];for(var d in o)return;delete e.__transition}}function Ss(e,t){var n=e.__transition,o,s,a=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((o=n[i]).name!==t){a=!1;continue}s=o.state>vl&&o.state<wl,o.state=ks,o.timer.stop(),o.on.call(s?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[i]}a&&delete e.__transition}}function jB(e){return this.each(function(){Ss(this,e)})}function HB(e,t){var n,o;return function(){var s=Yt(this,e),a=s.tween;if(a!==n){o=n=a;for(var i=0,l=o.length;i<l;++i)if(o[i].name===t){o=o.slice(),o.splice(i,1);break}}s.tween=o}}function VB(e,t,n){var o,s;if(typeof n!="function")throw new Error;return function(){var a=Yt(this,e),i=a.tween;if(i!==o){s=(o=i).slice();for(var l={name:t,value:n},c=0,d=s.length;c<d;++c)if(s[c].name===t){s[c]=l;break}c===d&&s.push(l)}a.tween=s}}function qB(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=zt(this.node(),n).tween,s=0,a=o.length,i;s<a;++s)if((i=o[s]).name===e)return i.value;return null}return this.each((t==null?HB:VB)(n,e,t))}function pd(e,t,n){var o=e._id;return e.each(function(){var s=Yt(this,o);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return zt(s,o).value[t]}}function T0(e,t){var n;return(typeof t=="number"?Ht:t instanceof Un?Vs:(n=Un(t))?(t=n,Vs):A0)(e,t)}function UB(e){return function(){this.removeAttribute(e)}}function QB(e){return function(){this.removeAttributeNS(e.space,e.local)}}function KB(e,t,n){var o,s=n+"",a;return function(){var i=this.getAttribute(e);return i===s?null:i===o?a:a=t(o=i,n)}}function GB(e,t,n){var o,s=n+"",a;return function(){var i=this.getAttributeNS(e.space,e.local);return i===s?null:i===o?a:a=t(o=i,n)}}function WB(e,t,n){var o,s,a;return function(){var i,l=n(this),c;return l==null?void this.removeAttribute(e):(i=this.getAttribute(e),c=l+"",i===c?null:i===o&&c===s?a:(s=c,a=t(o=i,l)))}}function YB(e,t,n){var o,s,a;return function(){var i,l=n(this),c;return l==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),c=l+"",i===c?null:i===o&&c===s?a:(s=c,a=t(o=i,l)))}}function ZB(e,t){var n=Ia(e),o=n==="transform"?EB:T0;return this.attrTween(e,typeof t=="function"?(n.local?YB:WB)(n,o,pd(this,"attr."+e,t)):t==null?(n.local?QB:UB)(n):(n.local?GB:KB)(n,o,t))}function XB(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function JB(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function eF(e,t){var n,o;function s(){var a=t.apply(this,arguments);return a!==o&&(n=(o=a)&&JB(e,a)),n}return s._value=t,s}function tF(e,t){var n,o;function s(){var a=t.apply(this,arguments);return a!==o&&(n=(o=a)&&XB(e,a)),n}return s._value=t,s}function nF(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=Ia(e);return this.tween(n,(o.local?eF:tF)(o,t))}function rF(e,t){return function(){ud(this,e).delay=+t.apply(this,arguments)}}function oF(e,t){return t=+t,function(){ud(this,e).delay=t}}function sF(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?rF:oF)(t,e)):zt(this.node(),t).delay}function aF(e,t){return function(){Yt(this,e).duration=+t.apply(this,arguments)}}function iF(e,t){return t=+t,function(){Yt(this,e).duration=t}}function lF(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?aF:iF)(t,e)):zt(this.node(),t).duration}function cF(e,t){if(typeof t!="function")throw new Error;return function(){Yt(this,e).ease=t}}function dF(e){var t=this._id;return arguments.length?this.each(cF(t,e)):zt(this.node(),t).ease}function uF(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Yt(this,e).ease=n}}function pF(e){if(typeof e!="function")throw new Error;return this.each(uF(this._id,e))}function fF(e){typeof e!="function"&&(e=p0(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=o[s]=[],c,d=0;d<i;++d)(c=a[d])&&e.call(c,c.__data__,d,a)&&l.push(c);return new dn(o,this._parents,this._name,this._id)}function mF(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,s=n.length,a=Math.min(o,s),i=new Array(o),l=0;l<a;++l)for(var c=t[l],d=n[l],f=c.length,p=i[l]=new Array(f),m,h=0;h<f;++h)(m=c[h]||d[h])&&(p[h]=m);for(;l<o;++l)i[l]=t[l];return new dn(i,this._parents,this._name,this._id)}function hF(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function gF(e,t,n){var o,s,a=hF(t)?ud:Yt;return function(){var i=a(this,e),l=i.on;l!==o&&(s=(o=l).copy()).on(t,n),i.on=s}}function bF(e,t){var n=this._id;return arguments.length<2?zt(this.node(),n).on.on(e):this.each(gF(n,e,t))}function xF(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function yF(){return this.on("end.remove",xF(this._id))}function vF(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ad(e));for(var o=this._groups,s=o.length,a=new Array(s),i=0;i<s;++i)for(var l=o[i],c=l.length,d=a[i]=new Array(c),f,p,m=0;m<c;++m)(f=l[m])&&(p=e.call(f,f.__data__,m,l))&&("__data__"in f&&(p.__data__=f.__data__),d[m]=p,Pa(d[m],t,n,m,d,zt(f,n)));return new dn(a,this._parents,t,n)}function wF(e){var t=this._name,n=this._id;typeof e!="function"&&(e=u0(e));for(var o=this._groups,s=o.length,a=[],i=[],l=0;l<s;++l)for(var c=o[l],d=c.length,f,p=0;p<d;++p)if(f=c[p]){for(var m=e.call(f,f.__data__,p,c),h,g=zt(f,n),b=0,x=m.length;b<x;++b)(h=m[b])&&Pa(h,t,n,b,m,g);a.push(m),i.push(f)}return new dn(a,i,t,n)}var NF=Lo.prototype.constructor;function kF(){return new NF(this._groups,this._parents)}function SF(e,t){var n,o,s;return function(){var a=wr(this,e),i=(this.style.removeProperty(e),wr(this,e));return a===i?null:a===n&&i===o?s:s=t(n=a,o=i)}}function R0(e){return function(){this.style.removeProperty(e)}}function CF(e,t,n){var o,s=n+"",a;return function(){var i=wr(this,e);return i===s?null:i===o?a:a=t(o=i,n)}}function MF(e,t,n){var o,s,a;return function(){var i=wr(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),wr(this,e))),i===c?null:i===o&&c===s?a:(s=c,a=t(o=i,l))}}function IF(e,t){var n,o,s,a="style."+t,i="end."+a,l;return function(){var c=Yt(this,e),d=c.on,f=c.value[a]==null?l||(l=R0(t)):void 0;(d!==n||s!==f)&&(o=(n=d).copy()).on(i,s=f),c.on=o}}function AF(e,t,n){var o=(e+="")=="transform"?PB:T0;return t==null?this.styleTween(e,SF(e,o)).on("end.style."+e,R0(e)):typeof t=="function"?this.styleTween(e,MF(e,o,pd(this,"style."+e,t))).each(IF(this._id,e)):this.styleTween(e,CF(e,o,t),n).on("end.style."+e,null)}function PF(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function EF(e,t,n){var o,s;function a(){var i=t.apply(this,arguments);return i!==s&&(o=(s=i)&&PF(e,i,n)),o}return a._value=t,a}function $F(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,EF(e,t,n??""))}function _F(e){return function(){this.textContent=e}}function DF(e){return function(){var t=e(this);this.textContent=t??""}}function LF(e){return this.tween("text",typeof e=="function"?DF(pd(this,"text",e)):_F(e==null?"":e+""))}function TF(e){return function(t){this.textContent=e.call(this,t)}}function RF(e){var t,n;function o(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&TF(s)),t}return o._value=e,o}function OF(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,RF(e))}function zF(){for(var e=this._name,t=this._id,n=O0(),o=this._groups,s=o.length,a=0;a<s;++a)for(var i=o[a],l=i.length,c,d=0;d<l;++d)if(c=i[d]){var f=zt(c,t);Pa(c,e,n,d,i,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new dn(o,this._parents,e,n)}function BF(){var e,t,n=this,o=n._id,s=n.size();return new Promise(function(a,i){var l={value:i},c={value:function(){--s===0&&a()}};n.each(function(){var d=Yt(this,o),f=d.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),d.on=t}),s===0&&a()})}var FF=0;function dn(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function O0(){return++FF}var Jt=Lo.prototype;dn.prototype={constructor:dn,select:vF,selectAll:wF,selectChild:Jt.selectChild,selectChildren:Jt.selectChildren,filter:fF,merge:mF,selection:kF,transition:zF,call:Jt.call,nodes:Jt.nodes,node:Jt.node,size:Jt.size,empty:Jt.empty,each:Jt.each,on:bF,attr:ZB,attrTween:nF,style:AF,styleTween:$F,text:LF,textTween:OF,remove:yF,tween:qB,delay:sF,duration:lF,ease:dF,easeVarying:pF,end:BF,[Symbol.iterator]:Jt[Symbol.iterator]};function jF(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var HF={time:null,delay:0,duration:250,ease:jF};function VF(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function qF(e){var t,n;e instanceof dn?(t=e._id,e=e._name):(t=O0(),(n=HF).time=dd(),e=e==null?null:e+"");for(var o=this._groups,s=o.length,a=0;a<s;++a)for(var i=o[a],l=i.length,c,d=0;d<l;++d)(c=i[d])&&Pa(c,e,t,d,i,n||VF(c,t));return new dn(o,this._parents,e,t)}Lo.prototype.interrupt=jB;Lo.prototype.transition=qF;const ds=e=>()=>e;function UF(e,{sourceEvent:t,target:n,transform:o,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:s}})}function nn(e,t,n){this.k=e,this.x=t,this.y=n}nn.prototype={constructor:nn,scale:function(e){return e===1?this:new nn(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new nn(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Ea=new nn(1,0,0);z0.prototype=nn.prototype;function z0(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ea;return e.__zoom}function Ii(e){e.stopImmediatePropagation()}function Ur(e){e.preventDefault(),e.stopImmediatePropagation()}function QF(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function KF(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function jp(){return this.__zoom||Ea}function GF(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function WF(){return navigator.maxTouchPoints||"ontouchstart"in this}function YF(e,t,n){var o=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s),i>a?(a+i)/2:Math.min(0,a)||Math.max(0,i))}function B0(){var e=QF,t=KF,n=YF,o=GF,s=WF,a=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,c=ws,d=Ma("start","zoom","end"),f,p,m,h=500,g=150,b=0,x=10;function y(I){I.property("__zoom",jp).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",z).filter(s).on("touchstart.zoom",D).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",O).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(I,L,_,R){var B=I.selection?I.selection():I;B.property("__zoom",jp),I!==B?k(I,L,_,R):B.interrupt().each(function(){S(this,arguments).event(R).start().zoom(null,typeof L=="function"?L.apply(this,arguments):L).end()})},y.scaleBy=function(I,L,_,R){y.scaleTo(I,function(){var B=this.__zoom.k,F=typeof L=="function"?L.apply(this,arguments):L;return B*F},_,R)},y.scaleTo=function(I,L,_,R){y.transform(I,function(){var B=t.apply(this,arguments),F=this.__zoom,j=_==null?N(B):typeof _=="function"?_.apply(this,arguments):_,H=F.invert(j),E=typeof L=="function"?L.apply(this,arguments):L;return n(v(w(F,E),j,H),B,i)},_,R)},y.translateBy=function(I,L,_,R){y.transform(I,function(){return n(this.__zoom.translate(typeof L=="function"?L.apply(this,arguments):L,typeof _=="function"?_.apply(this,arguments):_),t.apply(this,arguments),i)},null,R)},y.translateTo=function(I,L,_,R,B){y.transform(I,function(){var F=t.apply(this,arguments),j=this.__zoom,H=R==null?N(F):typeof R=="function"?R.apply(this,arguments):R;return n(Ea.translate(H[0],H[1]).scale(j.k).translate(typeof L=="function"?-L.apply(this,arguments):-L,typeof _=="function"?-_.apply(this,arguments):-_),F,i)},R,B)};function w(I,L){return L=Math.max(a[0],Math.min(a[1],L)),L===I.k?I:new nn(L,I.x,I.y)}function v(I,L,_){var R=L[0]-_[0]*I.k,B=L[1]-_[1]*I.k;return R===I.x&&B===I.y?I:new nn(I.k,R,B)}function N(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function k(I,L,_,R){I.on("start.zoom",function(){S(this,arguments).event(R).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(R).end()}).tween("zoom",function(){var B=this,F=arguments,j=S(B,F).event(R),H=t.apply(B,F),E=_==null?N(H):typeof _=="function"?_.apply(B,F):_,Q=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),K=B.__zoom,Y=typeof L=="function"?L.apply(B,F):L,re=c(K.invert(E).concat(Q/K.k),Y.invert(E).concat(Q/Y.k));return function(te){if(te===1)te=Y;else{var X=re(te),oe=Q/X[2];te=new nn(oe,E[0]-X[0]*oe,E[1]-X[1]*oe)}j.zoom(null,te)}})}function S(I,L,_){return!_&&I.__zooming||new M(I,L)}function M(I,L){this.that=I,this.args=L,this.active=0,this.sourceEvent=null,this.extent=t.apply(I,L),this.taps=0}M.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,L){return this.mouse&&I!=="mouse"&&(this.mouse[1]=L.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=L.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=L.invert(this.touch1[0])),this.that.__zoom=L,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var L=it(this.that).datum();d.call(I,this.that,new UF(I,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:d}),L)}};function P(I,...L){if(!e.apply(this,arguments))return;var _=S(this,L).event(I),R=this.__zoom,B=Math.max(a[0],Math.min(a[1],R.k*Math.pow(2,o.apply(this,arguments)))),F=Pt(I);if(_.wheel)(_.mouse[0][0]!==F[0]||_.mouse[0][1]!==F[1])&&(_.mouse[1]=R.invert(_.mouse[0]=F)),clearTimeout(_.wheel);else{if(R.k===B)return;_.mouse=[F,R.invert(F)],Ss(this),_.start()}Ur(I),_.wheel=setTimeout(j,g),_.zoom("mouse",n(v(w(R,B),_.mouse[0],_.mouse[1]),_.extent,i));function j(){_.wheel=null,_.end()}}function A(I,...L){if(m||!e.apply(this,arguments))return;var _=I.currentTarget,R=S(this,L,!0).event(I),B=it(I.view).on("mousemove.zoom",E,!0).on("mouseup.zoom",Q,!0),F=Pt(I,_),j=I.clientX,H=I.clientY;N0(I.view),Ii(I),R.mouse=[F,this.__zoom.invert(F)],Ss(this),R.start();function E(K){if(Ur(K),!R.moved){var Y=K.clientX-j,re=K.clientY-H;R.moved=Y*Y+re*re>b}R.event(K).zoom("mouse",n(v(R.that.__zoom,R.mouse[0]=Pt(K,_),R.mouse[1]),R.extent,i))}function Q(K){B.on("mousemove.zoom mouseup.zoom",null),k0(K.view,R.moved),Ur(K),R.event(K).end()}}function z(I,...L){if(e.apply(this,arguments)){var _=this.__zoom,R=Pt(I.changedTouches?I.changedTouches[0]:I,this),B=_.invert(R),F=_.k*(I.shiftKey?.5:2),j=n(v(w(_,F),R,B),t.apply(this,L),i);Ur(I),l>0?it(this).transition().duration(l).call(k,j,R,I):it(this).call(y.transform,j,R,I)}}function D(I,...L){if(e.apply(this,arguments)){var _=I.touches,R=_.length,B=S(this,L,I.changedTouches.length===R).event(I),F,j,H,E;for(Ii(I),j=0;j<R;++j)H=_[j],E=Pt(H,this),E=[E,this.__zoom.invert(E),H.identifier],B.touch0?!B.touch1&&B.touch0[2]!==E[2]&&(B.touch1=E,B.taps=0):(B.touch0=E,F=!0,B.taps=1+!!f);f&&(f=clearTimeout(f)),F&&(B.taps<2&&(p=E[0],f=setTimeout(function(){f=null},h)),Ss(this),B.start())}}function T(I,...L){if(this.__zooming){var _=S(this,L).event(I),R=I.changedTouches,B=R.length,F,j,H,E;for(Ur(I),F=0;F<B;++F)j=R[F],H=Pt(j,this),_.touch0&&_.touch0[2]===j.identifier?_.touch0[0]=H:_.touch1&&_.touch1[2]===j.identifier&&(_.touch1[0]=H);if(j=_.that.__zoom,_.touch1){var Q=_.touch0[0],K=_.touch0[1],Y=_.touch1[0],re=_.touch1[1],te=(te=Y[0]-Q[0])*te+(te=Y[1]-Q[1])*te,X=(X=re[0]-K[0])*X+(X=re[1]-K[1])*X;j=w(j,Math.sqrt(te/X)),H=[(Q[0]+Y[0])/2,(Q[1]+Y[1])/2],E=[(K[0]+re[0])/2,(K[1]+re[1])/2]}else if(_.touch0)H=_.touch0[0],E=_.touch0[1];else return;_.zoom("touch",n(v(j,H,E),_.extent,i))}}function O(I,...L){if(this.__zooming){var _=S(this,L).event(I),R=I.changedTouches,B=R.length,F,j;for(Ii(I),m&&clearTimeout(m),m=setTimeout(function(){m=null},h),F=0;F<B;++F)j=R[F],_.touch0&&_.touch0[2]===j.identifier?delete _.touch0:_.touch1&&_.touch1[2]===j.identifier&&delete _.touch1;if(_.touch1&&!_.touch0&&(_.touch0=_.touch1,delete _.touch1),_.touch0)_.touch0[1]=this.__zoom.invert(_.touch0[0]);else if(_.end(),_.taps===2&&(j=Pt(j,this),Math.hypot(p[0]-j[0],p[1]-j[1])<x)){var H=it(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return y.wheelDelta=function(I){return arguments.length?(o=typeof I=="function"?I:ds(+I),y):o},y.filter=function(I){return arguments.length?(e=typeof I=="function"?I:ds(!!I),y):e},y.touchable=function(I){return arguments.length?(s=typeof I=="function"?I:ds(!!I),y):s},y.extent=function(I){return arguments.length?(t=typeof I=="function"?I:ds([[+I[0][0],+I[0][1]],[+I[1][0],+I[1][1]]]),y):t},y.scaleExtent=function(I){return arguments.length?(a[0]=+I[0],a[1]=+I[1],y):[a[0],a[1]]},y.translateExtent=function(I){return arguments.length?(i[0][0]=+I[0][0],i[1][0]=+I[1][0],i[0][1]=+I[0][1],i[1][1]=+I[1][1],y):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},y.constrain=function(I){return arguments.length?(n=I,y):n},y.duration=function(I){return arguments.length?(l=+I,y):l},y.interpolate=function(I){return arguments.length?(c=I,y):c},y.on=function(){var I=d.on.apply(d,arguments);return I===d?y:I},y.clickDistance=function(I){return arguments.length?(b=(I=+I)*I,y):Math.sqrt(b)},y.tapDistance=function(I){return arguments.length?(x=+I,y):x},y}const Gt={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},bo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],F0=["Enter"," ","Escape"],j0={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var kr;(function(e){e.Strict="strict",e.Loose="loose"})(kr||(kr={}));var jn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(jn||(jn={}));var xo;(function(e){e.Partial="partial",e.Full="full"})(xo||(xo={}));const H0={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var yn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(yn||(yn={}));var Ks;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ks||(Ks={}));var we;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(we||(we={}));const Hp={[we.Left]:we.Right,[we.Right]:we.Left,[we.Top]:we.Bottom,[we.Bottom]:we.Top};function V0(e){return e===null?null:e?"valid":"invalid"}const q0=e=>"id"in e&&"source"in e&&"target"in e,ZF=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),fd=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Ro=(e,t=[0,0])=>{const{width:n,height:o}=mn(e),s=e.origin??t,a=n*s[0],i=o*s[1];return{x:e.position.x-a,y:e.position.y-i}},XF=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,s)=>{const a=typeof s=="string";let i=!t.nodeLookup&&!a?s:void 0;t.nodeLookup&&(i=a?t.nodeLookup.get(s):fd(s)?s:t.nodeLookup.get(s.id));const l=i?Gs(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return $a(o,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return _a(n)},Oo=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=$a(n,Gs(s)),o=!0)}),o?_a(n):{x:0,y:0,width:0,height:0}},md=(e,t,[n,o,s]=[0,0,1],a=!1,i=!1)=>{const l={...Bo(t,[n,o,s]),width:t.width/s,height:t.height/s},c=[];for(const d of e.values()){const{measured:f,selectable:p=!0,hidden:m=!1}=d;if(i&&!p||m)continue;const h=f.width??d.width??d.initialWidth??null,g=f.height??d.height??d.initialHeight??null,b=yo(l,Cr(d)),x=(h??0)*(g??0),y=a&&b>0;(!d.internals.handleBounds||y||b>=x||d.dragging)&&c.push(d)}return c},JF=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function ej(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&(t?.includeHiddenNodes||!s.hidden)&&(!o||o.has(s.id))&&n.set(s.id,s)}),n}async function tj({nodes:e,width:t,height:n,panZoom:o,minZoom:s,maxZoom:a},i){if(e.size===0)return Promise.resolve(!0);const l=ej(e,i),c=Oo(l),d=hd(c,t,n,i?.minZoom??s,i?.maxZoom??a,i?.padding??.1);return await o.setViewport(d,{duration:i?.duration,ease:i?.ease,interpolate:i?.interpolate}),Promise.resolve(!0)}function U0({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:s,onError:a}){const i=n.get(e),l=i.parentId?n.get(i.parentId):void 0,{x:c,y:d}=l?l.internals.positionAbsolute:{x:0,y:0},f=i.origin??o;let p=i.extent||s;if(i.extent==="parent"&&!i.expandParent)if(!l)a?.("005",Gt.error005());else{const h=l.measured.width,g=l.measured.height;h&&g&&(p=[[c,d],[c+h,d+g]])}else l&&Mr(i.extent)&&(p=[[i.extent[0][0]+c,i.extent[0][1]+d],[i.extent[1][0]+c,i.extent[1][1]+d]]);const m=Mr(p)?Kn(t,p,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&a?.("015",Gt.error015()),{position:{x:m.x-c+(i.measured.width??0)*f[0],y:m.y-d+(i.measured.height??0)*f[1]},positionAbsolute:m}}async function nj({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:s}){const a=new Set(e.map(m=>m.id)),i=[];for(const m of n){if(m.deletable===!1)continue;const h=a.has(m.id),g=!h&&m.parentId&&i.find(b=>b.id===m.parentId);(h||g)&&i.push(m)}const l=new Set(t.map(m=>m.id)),c=o.filter(m=>m.deletable!==!1),f=JF(i,c);for(const m of c)l.has(m.id)&&!f.find(g=>g.id===m.id)&&f.push(m);if(!s)return{edges:f,nodes:i};const p=await s({nodes:i,edges:f});return typeof p=="boolean"?p?{edges:f,nodes:i}:{edges:[],nodes:[]}:p}const Sr=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Kn=(e={x:0,y:0},t,n)=>({x:Sr(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Sr(e.y,t[0][1],t[1][1]-(n?.height??0))});function Q0(e,t,n){const{width:o,height:s}=mn(n),{x:a,y:i}=n.internals.positionAbsolute;return Kn(e,[[a,i],[a+o,i+s]],t)}const Vp=(e,t,n)=>e<t?Sr(Math.abs(e-t),1,t)/t:e>n?-Sr(Math.abs(e-n),1,t)/t:0,K0=(e,t,n=15,o=40)=>{const s=Vp(e.x,o,t.width-o)*n,a=Vp(e.y,o,t.height-o)*n;return[s,a]},$a=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Nl=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),_a=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Cr=(e,t=[0,0])=>{const{x:n,y:o}=fd(e)?e.internals.positionAbsolute:Ro(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Gs=(e,t=[0,0])=>{const{x:n,y:o}=fd(e)?e.internals.positionAbsolute:Ro(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},G0=(e,t)=>_a($a(Nl(e),Nl(t))),yo=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},qp=e=>$t(e.width)&&$t(e.height)&&$t(e.x)&&$t(e.y),$t=e=>!isNaN(e)&&isFinite(e),rj=(e,t)=>{},zo=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Bo=({x:e,y:t},[n,o,s],a=!1,i=[1,1])=>{const l={x:(e-n)/s,y:(t-o)/s};return a?zo(l,i):l},Ws=({x:e,y:t},[n,o,s])=>({x:e*s+n,y:t*s+o});function ar(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function oj(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=ar(e,n),s=ar(e,t);return{top:o,right:s,bottom:o,left:s,x:s*2,y:o*2}}if(typeof e=="object"){const o=ar(e.top??e.y??0,n),s=ar(e.bottom??e.y??0,n),a=ar(e.left??e.x??0,t),i=ar(e.right??e.x??0,t);return{top:o,right:i,bottom:s,left:a,x:a+i,y:o+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function sj(e,t,n,o,s,a){const{x:i,y:l}=Ws(e,[t,n,o]),{x:c,y:d}=Ws({x:e.x+e.width,y:e.y+e.height},[t,n,o]),f=s-c,p=a-d;return{left:Math.floor(i),top:Math.floor(l),right:Math.floor(f),bottom:Math.floor(p)}}const hd=(e,t,n,o,s,a)=>{const i=oj(a,t,n),l=(t-i.x)/e.width,c=(n-i.y)/e.height,d=Math.min(l,c),f=Sr(d,o,s),p=e.x+e.width/2,m=e.y+e.height/2,h=t/2-p*f,g=n/2-m*f,b=sj(e,h,g,f,t,n),x={left:Math.min(b.left-i.left,0),top:Math.min(b.top-i.top,0),right:Math.min(b.right-i.right,0),bottom:Math.min(b.bottom-i.bottom,0)};return{x:h-x.left+x.right,y:g-x.top+x.bottom,zoom:f}},vo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Mr(e){return e!=null&&e!=="parent"}function mn(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function W0(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Y0(e,t={width:0,height:0},n,o,s){const a={...e},i=o.get(n);if(i){const l=i.origin||s;a.x+=i.internals.positionAbsolute.x-(t.width??0)*l[0],a.y+=i.internals.positionAbsolute.y-(t.height??0)*l[1]}return a}function Up(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function aj(){let e,t;return{promise:new Promise((o,s)=>{e=o,t=s}),resolve:e,reject:t}}function ij(e){return{...j0,...e||{}}}function oo(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:s}){const{x:a,y:i}=_t(e),l=Bo({x:a-(s?.left??0),y:i-(s?.top??0)},o),{x:c,y:d}=n?zo(l,t):l;return{xSnapped:c,ySnapped:d,...l}}const gd=e=>({width:e.offsetWidth,height:e.offsetHeight}),Z0=e=>e?.getRootNode?.()||window?.document,lj=["INPUT","SELECT","TEXTAREA"];function X0(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:lj.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const J0=e=>"clientX"in e,_t=(e,t)=>{const n=J0(e),o=n?e.clientX:e.touches?.[0].clientX,s=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:s-(t?.top??0)}},Qp=(e,t,n,o,s)=>{const a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(i=>{const l=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:s,position:i.getAttribute("data-handlepos"),x:(l.left-n.left)/o,y:(l.top-n.top)/o,...gd(i)}})};function ev({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:s,sourceControlY:a,targetControlX:i,targetControlY:l}){const c=e*.125+s*.375+i*.375+n*.125,d=t*.125+a*.375+l*.375+o*.125,f=Math.abs(c-e),p=Math.abs(d-t);return[c,d,f,p]}function us(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Kp({pos:e,x1:t,y1:n,x2:o,y2:s,c:a}){switch(e){case we.Left:return[t-us(t-o,a),n];case we.Right:return[t+us(o-t,a),n];case we.Top:return[t,n-us(n-s,a)];case we.Bottom:return[t,n+us(s-n,a)]}}function tv({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:o,targetY:s,targetPosition:a=we.Top,curvature:i=.25}){const[l,c]=Kp({pos:n,x1:e,y1:t,x2:o,y2:s,c:i}),[d,f]=Kp({pos:a,x1:o,y1:s,x2:e,y2:t,c:i}),[p,m,h,g]=ev({sourceX:e,sourceY:t,targetX:o,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:f});return[`M${e},${t} C${l},${c} ${d},${f} ${o},${s}`,p,m,h,g]}function nv({sourceX:e,sourceY:t,targetX:n,targetY:o}){const s=Math.abs(n-e)/2,a=n<e?n+s:n-s,i=Math.abs(o-t)/2,l=o<t?o+i:o-i;return[a,l,s,i]}function cj({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:s=!1,zIndexMode:a="basic"}){if(a==="manual")return o;const i=s&&n?o+1e3:o,l=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return i+l}function dj({sourceNode:e,targetNode:t,width:n,height:o,transform:s}){const a=$a(Gs(e),Gs(t));a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1);const i={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:o/s[2]};return yo(i,_a(a))>0}const uj=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,pj=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),fj=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||uj;let s;return q0(e)?s={...e}:s={...e,id:o(e)},pj(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function rv({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[s,a,i,l]=nv({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,s,a,i,l]}const Gp={[we.Left]:{x:-1,y:0},[we.Right]:{x:1,y:0},[we.Top]:{x:0,y:-1},[we.Bottom]:{x:0,y:1}},mj=({source:e,sourcePosition:t=we.Bottom,target:n})=>t===we.Left||t===we.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Wp=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function hj({source:e,sourcePosition:t=we.Bottom,target:n,targetPosition:o=we.Top,center:s,offset:a,stepPosition:i}){const l=Gp[t],c=Gp[o],d={x:e.x+l.x*a,y:e.y+l.y*a},f={x:n.x+c.x*a,y:n.y+c.y*a},p=mj({source:d,sourcePosition:t,target:f}),m=p.x!==0?"x":"y",h=p[m];let g=[],b,x;const y={x:0,y:0},w={x:0,y:0},[,,v,N]=nv({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[m]*c[m]===-1){m==="x"?(b=s.x??d.x+(f.x-d.x)*i,x=s.y??(d.y+f.y)/2):(b=s.x??(d.x+f.x)/2,x=s.y??d.y+(f.y-d.y)*i);const P=[{x:b,y:d.y},{x:b,y:f.y}],A=[{x:d.x,y:x},{x:f.x,y:x}];l[m]===h?g=m==="x"?P:A:g=m==="x"?A:P}else{const P=[{x:d.x,y:f.y}],A=[{x:f.x,y:d.y}];if(m==="x"?g=l.x===h?A:P:g=l.y===h?P:A,t===o){const I=Math.abs(e[m]-n[m]);if(I<=a){const L=Math.min(a-1,a-I);l[m]===h?y[m]=(d[m]>e[m]?-1:1)*L:w[m]=(f[m]>n[m]?-1:1)*L}}if(t!==o){const I=m==="x"?"y":"x",L=l[m]===c[I],_=d[I]>f[I],R=d[I]<f[I];(l[m]===1&&(!L&&_||L&&R)||l[m]!==1&&(!L&&R||L&&_))&&(g=m==="x"?P:A)}const z={x:d.x+y.x,y:d.y+y.y},D={x:f.x+w.x,y:f.y+w.y},T=Math.max(Math.abs(z.x-g[0].x),Math.abs(D.x-g[0].x)),O=Math.max(Math.abs(z.y-g[0].y),Math.abs(D.y-g[0].y));T>=O?(b=(z.x+D.x)/2,x=g[0].y):(b=g[0].x,x=(z.y+D.y)/2)}const k={x:d.x+y.x,y:d.y+y.y},S={x:f.x+w.x,y:f.y+w.y};return[[e,...k.x!==g[0].x||k.y!==g[0].y?[k]:[],...g,...S.x!==g[g.length-1].x||S.y!==g[g.length-1].y?[S]:[],n],b,x,v,N]}function gj(e,t,n,o){const s=Math.min(Wp(e,t)/2,Wp(t,n)/2,o),{x:a,y:i}=t;if(e.x===a&&a===n.x||e.y===i&&i===n.y)return`L${a} ${i}`;if(e.y===i){const d=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${a+s*d},${i}Q ${a},${i} ${a},${i+s*f}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${a},${i+s*c}Q ${a},${i} ${a+s*l},${i}`}function kl({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:o,targetY:s,targetPosition:a=we.Top,borderRadius:i=5,centerX:l,centerY:c,offset:d=20,stepPosition:f=.5}){const[p,m,h,g,b]=hj({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:s},targetPosition:a,center:{x:l,y:c},offset:d,stepPosition:f});let x=`M${p[0].x} ${p[0].y}`;for(let y=1;y<p.length-1;y++)x+=gj(p[y-1],p[y],p[y+1],i);return x+=`L${p[p.length-1].x} ${p[p.length-1].y}`,[x,m,h,g,b]}function Yp(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function bj(e){const{sourceNode:t,targetNode:n}=e;if(!Yp(t)||!Yp(n))return null;const o=t.internals.handleBounds||Zp(t.handles),s=n.internals.handleBounds||Zp(n.handles),a=Xp(o?.source??[],e.sourceHandle),i=Xp(e.connectionMode===kr.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!a||!i)return e.onError?.("008",Gt.error008(a?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=a?.position||we.Bottom,c=i?.position||we.Top,d=Gn(t,a,l),f=Gn(n,i,c);return{sourceX:d.x,sourceY:d.y,targetX:f.x,targetY:f.y,sourcePosition:l,targetPosition:c}}function Zp(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function Gn(e,t,n=we.Left,o=!1){const s=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:i,height:l}=t??mn(e);if(o)return{x:s+i/2,y:a+l/2};switch(t?.position??n){case we.Top:return{x:s+i/2,y:a};case we.Right:return{x:s+i,y:a+l/2};case we.Bottom:return{x:s+i/2,y:a+l};case we.Left:return{x:s,y:a+l/2}}}function Xp(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Sl(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function xj(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:s}){const a=new Set;return e.reduce((i,l)=>([l.markerStart||o,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const d=Sl(c,t);a.has(d)||(i.push({id:d,color:c.color||n,...c}),a.add(d))}}),i),[]).sort((i,l)=>i.id.localeCompare(l.id))}const ov=1e3,yj=10,bd={nodeOrigin:[0,0],nodeExtent:bo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},vj={...bd,checkEquality:!0};function xd(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function wj(e,t,n){const o=xd(bd,n);for(const s of e.values())if(s.parentId)vd(s,e,t,o);else{const a=Ro(s,o.nodeOrigin),i=Mr(s.extent)?s.extent:o.nodeExtent,l=Kn(a,i,mn(s));s.internals.positionAbsolute=l}}function Nj(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const s of e.handles){const a={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(a):s.type==="target"&&o.push(a)}return{source:n,target:o}}function yd(e){return e==="manual"}function Cl(e,t,n,o={}){const s=xd(vj,o),a={i:0},i=new Map(t),l=s?.elevateNodesOnSelect&&!yd(s.zIndexMode)?ov:0;let c=e.length>0,d=!1;t.clear(),n.clear();for(const f of e){let p=i.get(f.id);if(s.checkEquality&&f===p?.internals.userNode)t.set(f.id,p);else{const m=Ro(f,s.nodeOrigin),h=Mr(f.extent)?f.extent:s.nodeExtent,g=Kn(m,h,mn(f));p={...s.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:g,handleBounds:Nj(f,p),z:sv(f,l,s.zIndexMode),userNode:f}},t.set(f.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(c=!1),f.parentId&&vd(p,t,n,o,a),d||=f.selected??!1}return{nodesInitialized:c,hasSelectedNodes:d}}function kj(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function vd(e,t,n,o,s){const{elevateNodesOnSelect:a,nodeOrigin:i,nodeExtent:l,zIndexMode:c}=xd(bd,o),d=e.parentId,f=t.get(d);if(!f){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}kj(e,n),s&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++s.i,f.internals.z=f.internals.z+s.i*yj),s&&f.internals.rootParentIndex!==void 0&&(s.i=f.internals.rootParentIndex);const p=a&&!yd(c)?ov:0,{x:m,y:h,z:g}=Sj(e,f,i,l,p,c),{positionAbsolute:b}=e.internals,x=m!==b.x||h!==b.y;(x||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:m,y:h}:b,z:g}})}function sv(e,t,n){const o=$t(e.zIndex)?e.zIndex:0;return yd(n)?o:o+(e.selected?t:0)}function Sj(e,t,n,o,s,a){const{x:i,y:l}=t.internals.positionAbsolute,c=mn(e),d=Ro(e,n),f=Mr(e.extent)?Kn(d,e.extent,c):d;let p=Kn({x:i+f.x,y:l+f.y},o,c);e.extent==="parent"&&(p=Q0(p,c,t));const m=sv(e,s,a),h=t.internals.z??0;return{x:p.x,y:p.y,z:h>=m?h+1:m}}function wd(e,t,n,o=[0,0]){const s=[],a=new Map;for(const i of e){const l=t.get(i.parentId);if(!l)continue;const c=a.get(i.parentId)?.expandedRect??Cr(l),d=G0(c,i.rect);a.set(i.parentId,{expandedRect:d,parent:l})}return a.size>0&&a.forEach(({expandedRect:i,parent:l},c)=>{const d=l.internals.positionAbsolute,f=mn(l),p=l.origin??o,m=i.x<d.x?Math.round(Math.abs(d.x-i.x)):0,h=i.y<d.y?Math.round(Math.abs(d.y-i.y)):0,g=Math.max(f.width,Math.round(i.width)),b=Math.max(f.height,Math.round(i.height)),x=(g-f.width)*p[0],y=(b-f.height)*p[1];(m>0||h>0||x||y)&&(s.push({id:c,type:"position",position:{x:l.position.x-m+x,y:l.position.y-h+y}}),n.get(c)?.forEach(w=>{e.some(v=>v.id===w.id)||s.push({id:w.id,type:"position",position:{x:w.position.x+m,y:w.position.y+h}})})),(f.width<i.width||f.height<i.height||m||h)&&s.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:g+(m?p[0]*m-x:0),height:b+(h?p[1]*h-y:0)}})}),s}function Cj(e,t,n,o,s,a,i){const l=o?.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const d=[],f=window.getComputedStyle(l),{m22:p}=new window.DOMMatrixReadOnly(f.transform),m=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const b=gd(h.nodeElement),x=g.measured.width!==b.width||g.measured.height!==b.height;if(!!(b.width&&b.height&&(x||!g.internals.handleBounds||h.force))){const w=h.nodeElement.getBoundingClientRect(),v=Mr(g.extent)?g.extent:a;let{positionAbsolute:N}=g.internals;g.parentId&&g.extent==="parent"?N=Q0(N,b,t.get(g.parentId)):v&&(N=Kn(N,v,b));const k={...g,measured:b,internals:{...g.internals,positionAbsolute:N,handleBounds:{source:Qp("source",h.nodeElement,w,p,g.id),target:Qp("target",h.nodeElement,w,p,g.id)}}};t.set(g.id,k),g.parentId&&vd(k,t,n,{nodeOrigin:s,zIndexMode:i}),c=!0,x&&(d.push({id:g.id,type:"dimensions",dimensions:b}),g.expandParent&&g.parentId&&m.push({id:g.id,parentId:g.parentId,rect:Cr(k,s)}))}}if(m.length>0){const h=wd(m,t,n,s);d.push(...h)}return{changes:d,updatedInternals:c}}async function Mj({delta:e,panZoom:t,transform:n,translateExtent:o,width:s,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,a]],o),l=!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2]);return Promise.resolve(l)}function Jp(e,t,n,o,s,a){let i=s;const l=o.get(i)||new Map;o.set(i,l.set(n,t)),i=`${s}-${e}`;const c=o.get(i)||new Map;if(o.set(i,c.set(n,t)),a){i=`${s}-${e}-${a}`;const d=o.get(i)||new Map;o.set(i,d.set(n,t))}}function av(e,t,n){e.clear(),t.clear();for(const o of n){const{source:s,target:a,sourceHandle:i=null,targetHandle:l=null}=o,c={edgeId:o.id,source:s,target:a,sourceHandle:i,targetHandle:l},d=`${s}-${i}--${a}-${l}`,f=`${a}-${l}--${s}-${i}`;Jp("source",c,f,e,s,i),Jp("target",c,d,e,a,l),t.set(o.id,o)}}function iv(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:iv(n,t):!1}function ef(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function Ij(e,t,n,o){const s=new Map;for(const[a,i]of e)if((i.selected||i.id===o)&&(!i.parentId||!iv(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){const l=e.get(a);l&&s.set(a,{id:a,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return s}function Ai({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const s=[];for(const[i,l]of t){const c=n.get(i)?.internals.userNode;c&&s.push({...c,position:l.position,dragging:o})}if(!e)return[s[0],s];const a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:o}:s[0],s]}function Aj({dragItems:e,snapGrid:t,x:n,y:o}){const s=e.values().next().value;if(!s)return null;const a={x:n-s.distance.x,y:o-s.distance.y},i=zo(a,t);return{x:i.x-a.x,y:i.y-a.y}}function Pj({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:s}){let a={x:null,y:null},i=0,l=new Map,c=!1,d={x:0,y:0},f=null,p=!1,m=null,h=!1,g=!1,b=null;function x({noDragClassName:w,handleSelector:v,domNode:N,isSelectable:k,nodeId:S,nodeClickDistance:M=0}){m=it(N);function P({x:T,y:O}){const{nodeLookup:I,nodeExtent:L,snapGrid:_,snapToGrid:R,nodeOrigin:B,onNodeDrag:F,onSelectionDrag:j,onError:H,updateNodePositions:E}=t();a={x:T,y:O};let Q=!1;const K=l.size>1,Y=K&&L?Nl(Oo(l)):null,re=K&&R?Aj({dragItems:l,snapGrid:_,x:T,y:O}):null;for(const[te,X]of l){if(!I.has(te))continue;let oe={x:T-X.distance.x,y:O-X.distance.y};R&&(oe=re?{x:Math.round(oe.x+re.x),y:Math.round(oe.y+re.y)}:zo(oe,_));let be=null;if(K&&L&&!X.extent&&Y){const{positionAbsolute:ee}=X.internals,ae=ee.x-Y.x+L[0][0],fe=ee.x+X.measured.width-Y.x2+L[1][0],he=ee.y-Y.y+L[0][1],V=ee.y+X.measured.height-Y.y2+L[1][1];be=[[ae,he],[fe,V]]}const{position:J,positionAbsolute:G}=U0({nodeId:te,nextPosition:oe,nodeLookup:I,nodeExtent:be||L,nodeOrigin:B,onError:H});Q=Q||X.position.x!==J.x||X.position.y!==J.y,X.position=J,X.internals.positionAbsolute=G}if(g=g||Q,!!Q&&(E(l,!0),b&&(o||F||!S&&j))){const[te,X]=Ai({nodeId:S,dragItems:l,nodeLookup:I});o?.(b,l,te,X),F?.(b,te,X),S||j?.(b,X)}}async function A(){if(!f)return;const{transform:T,panBy:O,autoPanSpeed:I,autoPanOnNodeDrag:L}=t();if(!L){c=!1,cancelAnimationFrame(i);return}const[_,R]=K0(d,f,I);(_!==0||R!==0)&&(a.x=(a.x??0)-_/T[2],a.y=(a.y??0)-R/T[2],await O({x:_,y:R})&&P(a)),i=requestAnimationFrame(A)}function z(T){const{nodeLookup:O,multiSelectionActive:I,nodesDraggable:L,transform:_,snapGrid:R,snapToGrid:B,selectNodesOnDrag:F,onNodeDragStart:j,onSelectionDragStart:H,unselectNodesAndEdges:E}=t();p=!0,(!F||!k)&&!I&&S&&(O.get(S)?.selected||E()),k&&F&&S&&e?.(S);const Q=oo(T.sourceEvent,{transform:_,snapGrid:R,snapToGrid:B,containerBounds:f});if(a=Q,l=Ij(O,L,Q,S),l.size>0&&(n||j||!S&&H)){const[K,Y]=Ai({nodeId:S,dragItems:l,nodeLookup:O});n?.(T.sourceEvent,l,K,Y),j?.(T.sourceEvent,K,Y),S||H?.(T.sourceEvent,Y)}}const D=S0().clickDistance(M).on("start",T=>{const{domNode:O,nodeDragThreshold:I,transform:L,snapGrid:_,snapToGrid:R}=t();f=O?.getBoundingClientRect()||null,h=!1,g=!1,b=T.sourceEvent,I===0&&z(T),a=oo(T.sourceEvent,{transform:L,snapGrid:_,snapToGrid:R,containerBounds:f}),d=_t(T.sourceEvent,f)}).on("drag",T=>{const{autoPanOnNodeDrag:O,transform:I,snapGrid:L,snapToGrid:_,nodeDragThreshold:R,nodeLookup:B}=t(),F=oo(T.sourceEvent,{transform:I,snapGrid:L,snapToGrid:_,containerBounds:f});if(b=T.sourceEvent,(T.sourceEvent.type==="touchmove"&&T.sourceEvent.touches.length>1||S&&!B.has(S))&&(h=!0),!h){if(!c&&O&&p&&(c=!0,A()),!p){const j=_t(T.sourceEvent,f),H=j.x-d.x,E=j.y-d.y;Math.sqrt(H*H+E*E)>R&&z(T)}(a.x!==F.xSnapped||a.y!==F.ySnapped)&&l&&p&&(d=_t(T.sourceEvent,f),P(F))}}).on("end",T=>{if(!(!p||h)&&(c=!1,p=!1,cancelAnimationFrame(i),l.size>0)){const{nodeLookup:O,updateNodePositions:I,onNodeDragStop:L,onSelectionDragStop:_}=t();if(g&&(I(l,!1),g=!1),s||L||!S&&_){const[R,B]=Ai({nodeId:S,dragItems:l,nodeLookup:O,dragging:!1});s?.(T.sourceEvent,l,R,B),L?.(T.sourceEvent,R,B),S||_?.(T.sourceEvent,B)}}}).filter(T=>{const O=T.target;return!T.button&&(!w||!ef(O,`.${w}`,N))&&(!v||ef(O,v,N))});m.call(D)}function y(){m?.on(".drag",null)}return{update:x,destroy:y}}function Ej(e,t,n){const o=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const a of t.values())yo(s,Cr(a))>0&&o.push(a);return o}const $j=250;function _j(e,t,n,o){let s=[],a=1/0;const i=Ej(e,n,t+$j);for(const l of i){const c=[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]];for(const d of c){if(o.nodeId===d.nodeId&&o.type===d.type&&o.id===d.id)continue;const{x:f,y:p}=Gn(l,d,d.position,!0),m=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(p-e.y,2));m>t||(m<a?(s=[{...d,x:f,y:p}],a=m):m===a&&s.push({...d,x:f,y:p}))}}if(!s.length)return null;if(s.length>1){const l=o.type==="source"?"target":"source";return s.find(c=>c.type===l)??s[0]}return s[0]}function lv(e,t,n,o,s,a=!1){const i=o.get(e);if(!i)return null;const l=s==="strict"?i.internals.handleBounds?.[t]:[...i.internals.handleBounds?.source??[],...i.internals.handleBounds?.target??[]],c=(n?l?.find(d=>d.id===n):l?.[0])??null;return c&&a?{...c,...Gn(i,c,c.position,!0)}:c}function cv(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Dj(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const dv=()=>!0;function Lj(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:s,edgeUpdaterType:a,isTarget:i,domNode:l,nodeLookup:c,lib:d,autoPanOnConnect:f,flowId:p,panBy:m,cancelConnection:h,onConnectStart:g,onConnect:b,onConnectEnd:x,isValidConnection:y=dv,onReconnectEnd:w,updateConnection:v,getTransform:N,getFromHandle:k,autoPanSpeed:S,dragThreshold:M=1,handleDomNode:P}){const A=Z0(e.target);let z=0,D;const{x:T,y:O}=_t(e),I=cv(a,P),L=l?.getBoundingClientRect();let _=!1;if(!L||!I)return;const R=lv(s,I,o,c,t);if(!R)return;let B=_t(e,L),F=!1,j=null,H=!1,E=null;function Q(){if(!f||!L)return;const[J,G]=K0(B,L,S);m({x:J,y:G}),z=requestAnimationFrame(Q)}const K={...R,nodeId:s,type:I,position:R.position},Y=c.get(s);let te={inProgress:!0,isValid:null,from:Gn(Y,K,we.Left,!0),fromHandle:K,fromPosition:K.position,fromNode:Y,to:B,toHandle:null,toPosition:Hp[K.position],toNode:null,pointer:B};function X(){_=!0,v(te),g?.(e,{nodeId:s,handleId:o,handleType:I})}M===0&&X();function oe(J){if(!_){const{x:V,y:ie}=_t(J),ue=V-T,de=ie-O;if(!(ue*ue+de*de>M*M))return;X()}if(!k()||!K){be(J);return}const G=N();B=_t(J,L),D=_j(Bo(B,G,!1,[1,1]),n,c,K),F||(Q(),F=!0);const ee=uv(J,{handle:D,connectionMode:t,fromNodeId:s,fromHandleId:o,fromType:i?"target":"source",isValidConnection:y,doc:A,lib:d,flowId:p,nodeLookup:c});E=ee.handleDomNode,j=ee.connection,H=Dj(!!D,ee.isValid);const ae=c.get(s),fe=ae?Gn(ae,K,we.Left,!0):te.from,he={...te,from:fe,isValid:H,to:ee.toHandle&&H?Ws({x:ee.toHandle.x,y:ee.toHandle.y},G):B,toHandle:ee.toHandle,toPosition:H&&ee.toHandle?ee.toHandle.position:Hp[K.position],toNode:ee.toHandle?c.get(ee.toHandle.nodeId):null,pointer:B};v(he),te=he}function be(J){if(!("touches"in J&&J.touches.length>0)){if(_){(D||E)&&j&&H&&b?.(j);const{inProgress:G,...ee}=te,ae={...ee,toPosition:te.toHandle?te.toPosition:null};x?.(J,ae),a&&w?.(J,ae)}h(),cancelAnimationFrame(z),F=!1,H=!1,j=null,E=null,A.removeEventListener("mousemove",oe),A.removeEventListener("mouseup",be),A.removeEventListener("touchmove",oe),A.removeEventListener("touchend",be)}}A.addEventListener("mousemove",oe),A.addEventListener("mouseup",be),A.addEventListener("touchmove",oe),A.addEventListener("touchend",be)}function uv(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:s,fromType:a,doc:i,lib:l,flowId:c,isValidConnection:d=dv,nodeLookup:f}){const p=a==="target",m=t?i.querySelector(`.${l}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:g}=_t(e),b=i.elementFromPoint(h,g),x=b?.classList.contains(`${l}-flow__handle`)?b:m,y={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const w=cv(void 0,x),v=x.getAttribute("data-nodeid"),N=x.getAttribute("data-handleid"),k=x.classList.contains("connectable"),S=x.classList.contains("connectableend");if(!v||!w)return y;const M={source:p?v:o,sourceHandle:p?N:s,target:p?o:v,targetHandle:p?s:N};y.connection=M;const A=k&&S&&(n===kr.Strict?p&&w==="source"||!p&&w==="target":v!==o||N!==s);y.isValid=A&&d(M),y.toHandle=lv(v,w,N,f,n,!0)}return y}const Ml={onPointerDown:Lj,isValid:uv};function Tj({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const s=it(e);function a({translateExtent:l,width:c,height:d,zoomStep:f=1,pannable:p=!0,zoomable:m=!0,inversePan:h=!1}){const g=v=>{if(v.sourceEvent.type!=="wheel"||!t)return;const N=n(),k=v.sourceEvent.ctrlKey&&vo()?10:1,S=-v.sourceEvent.deltaY*(v.sourceEvent.deltaMode===1?.05:v.sourceEvent.deltaMode?1:.002)*f,M=N[2]*Math.pow(2,S*k);t.scaleTo(M)};let b=[0,0];const x=v=>{(v.sourceEvent.type==="mousedown"||v.sourceEvent.type==="touchstart")&&(b=[v.sourceEvent.clientX??v.sourceEvent.touches[0].clientX,v.sourceEvent.clientY??v.sourceEvent.touches[0].clientY])},y=v=>{const N=n();if(v.sourceEvent.type!=="mousemove"&&v.sourceEvent.type!=="touchmove"||!t)return;const k=[v.sourceEvent.clientX??v.sourceEvent.touches[0].clientX,v.sourceEvent.clientY??v.sourceEvent.touches[0].clientY],S=[k[0]-b[0],k[1]-b[1]];b=k;const M=o()*Math.max(N[2],Math.log(N[2]))*(h?-1:1),P={x:N[0]-S[0]*M,y:N[1]-S[1]*M},A=[[0,0],[c,d]];t.setViewportConstrained({x:P.x,y:P.y,zoom:N[2]},A,l)},w=B0().on("start",x).on("zoom",p?y:null).on("zoom.wheel",m?g:null);s.call(w,{})}function i(){s.on("zoom",null)}return{update:a,destroy:i,pointer:Pt}}const Da=e=>({x:e.x,y:e.y,zoom:e.k}),Pi=({x:e,y:t,zoom:n})=>Ea.translate(e,t).scale(n),lr=(e,t)=>e.target.closest(`.${t}`),pv=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Rj=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ei=(e,t=0,n=Rj,o=()=>{})=>{const s=typeof t=="number"&&t>0;return s||o(),s?e.transition().duration(t).ease(n).on("end",o):e},fv=e=>{const t=e.ctrlKey&&vo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Oj({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:i,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:d}){return f=>{if(lr(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(f.ctrlKey&&i){const x=Pt(f),y=fv(f),w=p*Math.pow(2,y);o.scaleTo(n,w,x,f);return}const m=f.deltaMode===1?20:1;let h=s===jn.Vertical?0:f.deltaX*m,g=s===jn.Horizontal?0:f.deltaY*m;!vo()&&f.shiftKey&&s!==jn.Vertical&&(h=f.deltaY*m,g=0),o.translateBy(n,-(h/p)*a,-(g/p)*a,{internal:!0});const b=Da(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(f,b),e.panScrollTimeout=setTimeout(()=>{d?.(f,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(f,b))}}function zj({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,s){const a=o.type==="wheel",i=!t&&a&&!o.ctrlKey,l=lr(o,e);if(o.ctrlKey&&a&&l&&o.preventDefault(),i||l)return null;o.preventDefault(),n.call(this,o,s)}}function Bj({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const s=Da(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=s,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,s)}}function Fj({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:s}){return a=>{e.usedRightMouseButton=!!(n&&pv(t,e.mouseButton??0)),a.sourceEvent?.sync||o([a.transform.x,a.transform.y,a.transform.k]),s&&!a.sourceEvent?.internal&&s?.(a.sourceEvent,Da(a.transform))}}function jj({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:s,onPaneContextMenu:a}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&pv(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&a(i.sourceEvent),e.usedRightMouseButton=!1,o(!1),s)){const l=Da(i.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(i.sourceEvent,l)},n?150:0)}}}function Hj({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:s,zoomOnDoubleClick:a,userSelectionActive:i,noWheelClassName:l,noPanClassName:c,lib:d,connectionInProgress:f}){return p=>{const m=e||t,h=n&&p.ctrlKey,g=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(lr(p,`${d}-flow__node`)||lr(p,`${d}-flow__edge`)))return!0;if(!o&&!m&&!s&&!a&&!n||i||f&&!g||lr(p,l)&&g||lr(p,c)&&(!g||s&&g&&!e)||!n&&p.ctrlKey&&g)return!1;if(!n&&p.type==="touchstart"&&p.touches?.length>1)return p.preventDefault(),!1;if(!m&&!s&&!h&&g||!o&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(o)&&!o.includes(p.button)&&p.type==="mousedown")return!1;const b=Array.isArray(o)&&o.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||g)&&b}}function Vj({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:s,onPanZoom:a,onPanZoomStart:i,onPanZoomEnd:l,onDraggingChange:c}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),p=B0().scaleExtent([t,n]).translateExtent(o),m=it(e).call(p);w({x:s.x,y:s.y,zoom:Sr(s.zoom,t,n)},[[0,0],[f.width,f.height]],o);const h=m.on("wheel.zoom"),g=m.on("dblclick.zoom");p.wheelDelta(fv);function b(D,T){return m?new Promise(O=>{p?.interpolate(T?.interpolate==="linear"?ro:ws).transform(Ei(m,T?.duration,T?.ease,()=>O(!0)),D)}):Promise.resolve(!1)}function x({noWheelClassName:D,noPanClassName:T,onPaneContextMenu:O,userSelectionActive:I,panOnScroll:L,panOnDrag:_,panOnScrollMode:R,panOnScrollSpeed:B,preventScrolling:F,zoomOnPinch:j,zoomOnScroll:H,zoomOnDoubleClick:E,zoomActivationKeyPressed:Q,lib:K,onTransformChange:Y,connectionInProgress:re,paneClickDistance:te,selectionOnDrag:X}){I&&!d.isZoomingOrPanning&&y();const oe=L&&!Q&&!I;p.clickDistance(X?1/0:!$t(te)||te<0?0:te);const be=oe?Oj({zoomPanValues:d,noWheelClassName:D,d3Selection:m,d3Zoom:p,panOnScrollMode:R,panOnScrollSpeed:B,zoomOnPinch:j,onPanZoomStart:i,onPanZoom:a,onPanZoomEnd:l}):zj({noWheelClassName:D,preventScrolling:F,d3ZoomHandler:h});if(m.on("wheel.zoom",be,{passive:!1}),!I){const G=Bj({zoomPanValues:d,onDraggingChange:c,onPanZoomStart:i});p.on("start",G);const ee=Fj({zoomPanValues:d,panOnDrag:_,onPaneContextMenu:!!O,onPanZoom:a,onTransformChange:Y});p.on("zoom",ee);const ae=jj({zoomPanValues:d,panOnDrag:_,panOnScroll:L,onPaneContextMenu:O,onPanZoomEnd:l,onDraggingChange:c});p.on("end",ae)}const J=Hj({zoomActivationKeyPressed:Q,panOnDrag:_,zoomOnScroll:H,panOnScroll:L,zoomOnDoubleClick:E,zoomOnPinch:j,userSelectionActive:I,noPanClassName:T,noWheelClassName:D,lib:K,connectionInProgress:re});p.filter(J),E?m.on("dblclick.zoom",g):m.on("dblclick.zoom",null)}function y(){p.on("zoom",null)}async function w(D,T,O){const I=Pi(D),L=p?.constrain()(I,T,O);return L&&await b(L),new Promise(_=>_(L))}async function v(D,T){const O=Pi(D);return await b(O,T),new Promise(I=>I(O))}function N(D){if(m){const T=Pi(D),O=m.property("__zoom");(O.k!==D.zoom||O.x!==D.x||O.y!==D.y)&&p?.transform(m,T,null,{sync:!0})}}function k(){const D=m?z0(m.node()):{x:0,y:0,k:1};return{x:D.x,y:D.y,zoom:D.k}}function S(D,T){return m?new Promise(O=>{p?.interpolate(T?.interpolate==="linear"?ro:ws).scaleTo(Ei(m,T?.duration,T?.ease,()=>O(!0)),D)}):Promise.resolve(!1)}function M(D,T){return m?new Promise(O=>{p?.interpolate(T?.interpolate==="linear"?ro:ws).scaleBy(Ei(m,T?.duration,T?.ease,()=>O(!0)),D)}):Promise.resolve(!1)}function P(D){p?.scaleExtent(D)}function A(D){p?.translateExtent(D)}function z(D){const T=!$t(D)||D<0?0:D;p?.clickDistance(T)}return{update:x,destroy:y,setViewport:v,setViewportConstrained:w,getViewport:k,scaleTo:S,scaleBy:M,setScaleExtent:P,setTranslateExtent:A,syncViewport:N,setClickDistance:z}}var Ir;(function(e){e.Line="line",e.Handle="handle"})(Ir||(Ir={}));function qj({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:s,affectsY:a}){const i=e-t,l=n-o,c=[i>0?1:i<0?-1:0,l>0?1:l<0?-1:0];return i&&s&&(c[0]=c[0]*-1),l&&a&&(c[1]=c[1]*-1),c}function tf(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:s}}function bn(e,t){return Math.max(0,t-e)}function xn(e,t){return Math.max(0,e-t)}function ps(e,t,n){return Math.max(0,t-e,e-n)}function nf(e,t){return e?!t:t}function Uj(e,t,n,o,s,a,i,l){let{affectsX:c,affectsY:d}=t;const{isHorizontal:f,isVertical:p}=t,m=f&&p,{xSnapped:h,ySnapped:g}=n,{minWidth:b,maxWidth:x,minHeight:y,maxHeight:w}=o,{x:v,y:N,width:k,height:S,aspectRatio:M}=e;let P=Math.floor(f?h-e.pointerX:0),A=Math.floor(p?g-e.pointerY:0);const z=k+(c?-P:P),D=S+(d?-A:A),T=-a[0]*k,O=-a[1]*S;let I=ps(z,b,x),L=ps(D,y,w);if(i){let B=0,F=0;c&&P<0?B=bn(v+P+T,i[0][0]):!c&&P>0&&(B=xn(v+z+T,i[1][0])),d&&A<0?F=bn(N+A+O,i[0][1]):!d&&A>0&&(F=xn(N+D+O,i[1][1])),I=Math.max(I,B),L=Math.max(L,F)}if(l){let B=0,F=0;c&&P>0?B=xn(v+P,l[0][0]):!c&&P<0&&(B=bn(v+z,l[1][0])),d&&A>0?F=xn(N+A,l[0][1]):!d&&A<0&&(F=bn(N+D,l[1][1])),I=Math.max(I,B),L=Math.max(L,F)}if(s){if(f){const B=ps(z/M,y,w)*M;if(I=Math.max(I,B),i){let F=0;!c&&!d||c&&!d&&m?F=xn(N+O+z/M,i[1][1])*M:F=bn(N+O+(c?P:-P)/M,i[0][1])*M,I=Math.max(I,F)}if(l){let F=0;!c&&!d||c&&!d&&m?F=bn(N+z/M,l[1][1])*M:F=xn(N+(c?P:-P)/M,l[0][1])*M,I=Math.max(I,F)}}if(p){const B=ps(D*M,b,x)/M;if(L=Math.max(L,B),i){let F=0;!c&&!d||d&&!c&&m?F=xn(v+D*M+T,i[1][0])/M:F=bn(v+(d?A:-A)*M+T,i[0][0])/M,L=Math.max(L,F)}if(l){let F=0;!c&&!d||d&&!c&&m?F=bn(v+D*M,l[1][0])/M:F=xn(v+(d?A:-A)*M,l[0][0])/M,L=Math.max(L,F)}}}A=A+(A<0?L:-L),P=P+(P<0?I:-I),s&&(m?z>D*M?A=(nf(c,d)?-P:P)/M:P=(nf(c,d)?-A:A)*M:f?(A=P/M,d=c):(P=A*M,c=d));const _=c?v+P:v,R=d?N+A:N;return{width:k+(c?-P:P),height:S+(d?-A:A),x:a[0]*P*(c?-1:1)+_,y:a[1]*A*(d?-1:1)+R}}const mv={width:0,height:0,x:0,y:0},Qj={...mv,pointerX:0,pointerY:0,aspectRatio:1};function Kj(e){return[[0,0],[e.measured.width,e.measured.height]]}function Gj(e,t,n){const o=t.position.x+e.position.x,s=t.position.y+e.position.y,a=e.measured.width??0,i=e.measured.height??0,l=n[0]*a,c=n[1]*i;return[[o-l,s-c],[o+a-l,s+i-c]]}function Wj({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:s}){const a=it(e);let i={controlDirection:tf("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:d,boundaries:f,keepAspectRatio:p,resizeDirection:m,onResizeStart:h,onResize:g,onResizeEnd:b,shouldResize:x}){let y={...mv},w={...Qj};i={boundaries:f,resizeDirection:m,keepAspectRatio:p,controlDirection:tf(d)};let v,N=null,k=[],S,M,P,A=!1;const z=S0().on("start",D=>{const{nodeLookup:T,transform:O,snapGrid:I,snapToGrid:L,nodeOrigin:_,paneDomNode:R}=n();if(v=T.get(t),!v)return;N=R?.getBoundingClientRect()??null;const{xSnapped:B,ySnapped:F}=oo(D.sourceEvent,{transform:O,snapGrid:I,snapToGrid:L,containerBounds:N});y={width:v.measured.width??0,height:v.measured.height??0,x:v.position.x??0,y:v.position.y??0},w={...y,pointerX:B,pointerY:F,aspectRatio:y.width/y.height},S=void 0,v.parentId&&(v.extent==="parent"||v.expandParent)&&(S=T.get(v.parentId),M=S&&v.extent==="parent"?Kj(S):void 0),k=[],P=void 0;for(const[j,H]of T)if(H.parentId===t&&(k.push({id:j,position:{...H.position},extent:H.extent}),H.extent==="parent"||H.expandParent)){const E=Gj(H,v,H.origin??_);P?P=[[Math.min(E[0][0],P[0][0]),Math.min(E[0][1],P[0][1])],[Math.max(E[1][0],P[1][0]),Math.max(E[1][1],P[1][1])]]:P=E}h?.(D,{...y})}).on("drag",D=>{const{transform:T,snapGrid:O,snapToGrid:I,nodeOrigin:L}=n(),_=oo(D.sourceEvent,{transform:T,snapGrid:O,snapToGrid:I,containerBounds:N}),R=[];if(!v)return;const{x:B,y:F,width:j,height:H}=y,E={},Q=v.origin??L,{width:K,height:Y,x:re,y:te}=Uj(w,i.controlDirection,_,i.boundaries,i.keepAspectRatio,Q,M,P),X=K!==j,oe=Y!==H,be=re!==B&&X,J=te!==F&&oe;if(!be&&!J&&!X&&!oe)return;if((be||J||Q[0]===1||Q[1]===1)&&(E.x=be?re:y.x,E.y=J?te:y.y,y.x=E.x,y.y=E.y,k.length>0)){const fe=re-B,he=te-F;for(const V of k)V.position={x:V.position.x-fe+Q[0]*(K-j),y:V.position.y-he+Q[1]*(Y-H)},R.push(V)}if((X||oe)&&(E.width=X&&(!i.resizeDirection||i.resizeDirection==="horizontal")?K:y.width,E.height=oe&&(!i.resizeDirection||i.resizeDirection==="vertical")?Y:y.height,y.width=E.width,y.height=E.height),S&&v.expandParent){const fe=Q[0]*(E.width??0);E.x&&E.x<fe&&(y.x=fe,w.x=w.x-(E.x-fe));const he=Q[1]*(E.height??0);E.y&&E.y<he&&(y.y=he,w.y=w.y-(E.y-he))}const G=qj({width:y.width,prevWidth:j,height:y.height,prevHeight:H,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),ee={...y,direction:G};x?.(D,ee)!==!1&&(A=!0,g?.(D,ee),o(E,R))}).on("end",D=>{A&&(b?.(D,{...y}),s?.({...y}),A=!1)});a.call(z)}function c(){a.on(".drag",null)}return{update:l,destroy:c}}var hv={exports:{}},gv={};/**
|
|
1090
|
-
* @license React
|
|
1091
|
-
* use-sync-external-store-shim/with-selector.production.js
|
|
1092
|
-
*
|
|
1093
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1094
|
-
*
|
|
1095
|
-
* This source code is licensed under the MIT license found in the
|
|
1096
|
-
* LICENSE file in the root directory of this source tree.
|
|
1097
|
-
*/var La=Qf,Yj=Ry;function Zj(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Xj=typeof Object.is=="function"?Object.is:Zj,Jj=Yj.useSyncExternalStore,eH=La.useRef,tH=La.useEffect,nH=La.useMemo,rH=La.useDebugValue;gv.useSyncExternalStoreWithSelector=function(e,t,n,o,s){var a=eH(null);if(a.current===null){var i={hasValue:!1,value:null};a.current=i}else i=a.current;a=nH(function(){function c(h){if(!d){if(d=!0,f=h,h=o(h),s!==void 0&&i.hasValue){var g=i.value;if(s(g,h))return p=g}return p=h}if(g=p,Xj(f,h))return g;var b=o(h);return s!==void 0&&s(g,b)?(f=h,g):(f=h,p=b)}var d=!1,f,p,m=n===void 0?null:n;return[function(){return c(t())},m===null?void 0:function(){return c(m())}]},[t,n,o,s]);var l=Jj(e,a[0],a[1]);return tH(function(){i.hasValue=!0,i.value=l},[l]),rH(l),l};hv.exports=gv;var oH=hv.exports;const sH=G1(oH),aH={},rf=e=>{let t;const n=new Set,o=(f,p)=>{const m=typeof f=="function"?f(t):f;if(!Object.is(m,t)){const h=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(g=>g(t,h))}},s=()=>t,c={setState:o,getState:s,getInitialState:()=>d,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(aH?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(o,s,c);return c},iH=e=>e?rf(e):rf,{useDebugValue:lH}=El,{useSyncExternalStoreWithSelector:cH}=sH,dH=e=>e;function bv(e,t=dH,n){const o=cH(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return lH(o),o}const of=(e,t)=>{const n=iH(e),o=(s,a=t)=>bv(n,s,a);return Object.assign(o,n),o},uH=(e,t)=>e?of(e,t):of;function Be(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,s]of e)if(!Object.is(s,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const Ta=Oe(null),pH=Ta.Provider,xv=Gt.error001();function $e(e,t){const n=ve(Ta);if(n===null)throw new Error(xv);return bv(n,e,t)}function je(){const e=ve(Ta);if(e===null)throw new Error(xv);return U(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const sf={display:"none"},fH={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},yv="react-flow__node-desc",vv="react-flow__edge-desc",mH="react-flow__aria-live",hH=e=>e.ariaLiveMessage,gH=e=>e.ariaLabelConfig;function bH({rfId:e}){const t=$e(hH);return r("div",{id:`${mH}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:fH,children:t})}function xH({rfId:e,disableKeyboardA11y:t}){const n=$e(gH);return u(ge,{children:[r("div",{id:`${yv}-${e}`,style:sf,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),r("div",{id:`${vv}-${e}`,style:sf,children:n["edge.a11yDescription.default"]}),!t&&r(bH,{rfId:e})]})}const Ra=He(({position:e="top-left",children:t,className:n,style:o,...s},a)=>{const i=`${e}`.split("-");return r("div",{className:Qe(["react-flow__panel",n,...i]),style:o,ref:a,...s,children:t})});Ra.displayName="Panel";function yH({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:r(Ra,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:r("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const vH=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},fs=e=>e.id;function wH(e,t){return Be(e.selectedNodes.map(fs),t.selectedNodes.map(fs))&&Be(e.selectedEdges.map(fs),t.selectedEdges.map(fs))}function NH({onSelectionChange:e}){const t=je(),{selectedNodes:n,selectedEdges:o}=$e(vH,wH);return Z(()=>{const s={nodes:n,edges:o};e?.(s),t.getState().onSelectionChangeHandlers.forEach(a=>a(s))},[n,o,e]),null}const kH=e=>!!e.onSelectionChangeHandlers;function SH({onSelectionChange:e}){const t=$e(kH);return e||t?r(NH,{onSelectionChange:e}):null}const Il=typeof window<"u"?Zs:Z,wv=[0,0],CH={x:0,y:0,zoom:1},MH=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],af=[...MH,"rfId"],IH=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),lf={translateExtent:bo,nodeOrigin:wv,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function AH(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:s,setTranslateExtent:a,setNodeExtent:i,reset:l,setDefaultNodesAndEdges:c}=$e(IH,Be),d=je();Il(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=lf,l()}),[]);const f=ne(lf);return Il(()=>{for(const p of af){const m=e[p],h=f.current[p];m!==h&&(typeof e[p]>"u"||(p==="nodes"?t(m):p==="edges"?n(m):p==="minZoom"?o(m):p==="maxZoom"?s(m):p==="translateExtent"?a(m):p==="nodeExtent"?i(m):p==="ariaLabelConfig"?d.setState({ariaLabelConfig:ij(m)}):p==="fitView"?d.setState({fitViewQueued:m}):p==="fitViewOptions"?d.setState({fitViewOptions:m}):d.setState({[p]:m})))}f.current=e},af.map(p=>e[p])),null}function cf(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function PH(e){const[t,n]=$(e==="system"?null:e);return Z(()=>{if(e!=="system"){n(e);return}const o=cf(),s=()=>n(o?.matches?"dark":"light");return s(),o?.addEventListener("change",s),()=>{o?.removeEventListener("change",s)}},[e]),t!==null?t:cf()?.matches?"dark":"light"}const df=typeof document<"u"?document:null;function wo(e=null,t={target:df,actInsideInputWithModifier:!0}){const[n,o]=$(!1),s=ne(!1),a=ne(new Set([])),[i,l]=U(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",`
|
|
1098
|
-
`).replace(`
|
|
1099
|
-
|
|
1100
|
-
`,`
|
|
1101
|
-
+`).split(`
|
|
1102
|
-
`)),f=d.reduce((p,m)=>p.concat(...m),[]);return[d,f]}return[[],[]]},[e]);return Z(()=>{const c=t?.target??df,d=t?.actInsideInputWithModifier??!0;if(e!==null){const f=h=>{if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!d)&&X0(h))return!1;const b=pf(h.code,l);if(a.current.add(h[b]),uf(i,a.current,!1)){const x=h.composedPath?.()?.[0]||h.target,y=x?.nodeName==="BUTTON"||x?.nodeName==="A";t.preventDefault!==!1&&(s.current||!y)&&h.preventDefault(),o(!0)}},p=h=>{const g=pf(h.code,l);uf(i,a.current,!0)?(o(!1),a.current.clear()):a.current.delete(h[g]),h.key==="Meta"&&a.current.clear(),s.current=!1},m=()=>{a.current.clear(),o(!1)};return c?.addEventListener("keydown",f),c?.addEventListener("keyup",p),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{c?.removeEventListener("keydown",f),c?.removeEventListener("keyup",p),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[e,o]),n}function uf(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(s=>t.has(s)))}function pf(e,t){return t.includes(e)?"code":"key"}const EH=()=>{const e=je();return U(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[o,s,a],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??o,y:t.y??s,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{const{width:o,height:s,minZoom:a,maxZoom:i,panZoom:l}=e.getState(),c=hd(t,o,s,a,i,n?.padding??.1);return l?(await l.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:s,snapToGrid:a,domNode:i}=e.getState();if(!i)return t;const{x:l,y:c}=i.getBoundingClientRect(),d={x:t.x-l,y:t.y-c},f=n.snapGrid??s,p=n.snapToGrid??a;return Bo(d,o,p,f)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:s,y:a}=o.getBoundingClientRect(),i=Ws(t,n);return{x:i.x+s,y:i.y+a}}}),[])};function Nv(e,t){const n=[],o=new Map,s=[];for(const a of e)if(a.type==="add"){s.push(a);continue}else if(a.type==="remove"||a.type==="replace")o.set(a.id,[a]);else{const i=o.get(a.id);i?i.push(a):o.set(a.id,[a])}for(const a of t){const i=o.get(a.id);if(!i){n.push(a);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){n.push({...i[0].item});continue}const l={...a};for(const c of i)$H(c,l);n.push(l)}return s.length&&s.forEach(a=>{a.index!==void 0?n.splice(a.index,0,{...a.item}):n.push({...a.item})}),n}function $H(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function _H(e,t){return Nv(e,t)}function DH(e,t){return Nv(e,t)}function Tn(e,t){return{id:e,type:"select",selected:t}}function cr(e,t=new Set,n=!1){const o=[];for(const[s,a]of e){const i=t.has(s);!(a.selected===void 0&&!i)&&a.selected!==i&&(n&&(a.selected=i),o.push(Tn(a.id,i)))}return o}function ff({items:e=[],lookup:t}){const n=[],o=new Map(e.map(s=>[s.id,s]));for(const[s,a]of e.entries()){const i=t.get(a.id),l=i?.internals?.userNode??i;l!==void 0&&l!==a&&n.push({id:a.id,item:a,type:"replace"}),l===void 0&&n.push({item:a,type:"add",index:s})}for(const[s]of t)o.get(s)===void 0&&n.push({id:s,type:"remove"});return n}function mf(e){return{id:e.id,type:"remove"}}const hf=e=>ZF(e),LH=e=>q0(e);function kv(e){return He(e)}function gf(e){const[t,n]=$(BigInt(0)),[o]=$(()=>TH(()=>n(s=>s+BigInt(1))));return Il(()=>{const s=o.get();s.length&&(e(s),o.reset())},[t]),o}function TH(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Sv=Oe(null);function RH({children:e}){const t=je(),n=q(l=>{const{nodes:c=[],setNodes:d,hasDefaultNodes:f,onNodesChange:p,nodeLookup:m,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let b=c;for(const y of l)b=typeof y=="function"?y(b):y;let x=ff({items:b,lookup:m});for(const y of g.values())x=y(x);f&&d(b),x.length>0?p?.(x):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:w,setNodes:v}=t.getState();y&&v(w)})},[]),o=gf(n),s=q(l=>{const{edges:c=[],setEdges:d,hasDefaultEdges:f,onEdgesChange:p,edgeLookup:m}=t.getState();let h=c;for(const g of l)h=typeof g=="function"?g(h):g;f?d(h):p&&p(ff({items:h,lookup:m}))},[]),a=gf(s),i=U(()=>({nodeQueue:o,edgeQueue:a}),[]);return r(Sv.Provider,{value:i,children:e})}function OH(){const e=ve(Sv);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const zH=e=>!!e.panZoom;function Nd(){const e=EH(),t=je(),n=OH(),o=$e(zH),s=U(()=>{const a=p=>t.getState().nodeLookup.get(p),i=p=>{n.nodeQueue.push(p)},l=p=>{n.edgeQueue.push(p)},c=p=>{const{nodeLookup:m,nodeOrigin:h}=t.getState(),g=hf(p)?p:m.get(p.id),b=g.parentId?Y0(g.position,g.measured,g.parentId,m,h):g.position,x={...g,position:b,width:g.measured?.width??g.width,height:g.measured?.height??g.height};return Cr(x)},d=(p,m,h={replace:!1})=>{i(g=>g.map(b=>{if(b.id===p){const x=typeof m=="function"?m(b):m;return h.replace&&hf(x)?x:{...b,...x}}return b}))},f=(p,m,h={replace:!1})=>{l(g=>g.map(b=>{if(b.id===p){const x=typeof m=="function"?m(b):m;return h.replace&&LH(x)?x:{...b,...x}}return b}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>a(p)?.internals.userNode,getInternalNode:a,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(m=>({...m}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:i,setEdges:l,addNodes:p=>{const m=Array.isArray(p)?p:[p];n.nodeQueue.push(h=>[...h,...m])},addEdges:p=>{const m=Array.isArray(p)?p:[p];n.edgeQueue.push(h=>[...h,...m])},toObject:()=>{const{nodes:p=[],edges:m=[],transform:h}=t.getState(),[g,b,x]=h;return{nodes:p.map(y=>({...y})),edges:m.map(y=>({...y})),viewport:{x:g,y:b,zoom:x}}},deleteElements:async({nodes:p=[],edges:m=[]})=>{const{nodes:h,edges:g,onNodesDelete:b,onEdgesDelete:x,triggerNodeChanges:y,triggerEdgeChanges:w,onDelete:v,onBeforeDelete:N}=t.getState(),{nodes:k,edges:S}=await nj({nodesToRemove:p,edgesToRemove:m,nodes:h,edges:g,onBeforeDelete:N}),M=S.length>0,P=k.length>0;if(M){const A=S.map(mf);x?.(S),w(A)}if(P){const A=k.map(mf);b?.(k),y(A)}return(P||M)&&v?.({nodes:k,edges:S}),{deletedNodes:k,deletedEdges:S}},getIntersectingNodes:(p,m=!0,h)=>{const g=qp(p),b=g?p:c(p),x=h!==void 0;return b?(h||t.getState().nodes).filter(y=>{const w=t.getState().nodeLookup.get(y.id);if(w&&!g&&(y.id===p.id||!w.internals.positionAbsolute))return!1;const v=Cr(x?y:w),N=yo(v,b);return m&&N>0||N>=v.width*v.height||N>=b.width*b.height}):[]},isNodeIntersecting:(p,m,h=!0)=>{const b=qp(p)?p:c(p);if(!b)return!1;const x=yo(b,m);return h&&x>0||x>=m.width*m.height||x>=b.width*b.height},updateNode:d,updateNodeData:(p,m,h={replace:!1})=>{d(p,g=>{const b=typeof m=="function"?m(g):m;return h.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},h)},updateEdge:f,updateEdgeData:(p,m,h={replace:!1})=>{f(p,g=>{const b=typeof m=="function"?m(g):m;return h.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},h)},getNodesBounds:p=>{const{nodeLookup:m,nodeOrigin:h}=t.getState();return XF(p,{nodeLookup:m,nodeOrigin:h})},getHandleConnections:({type:p,id:m,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}-${p}${m?`-${m}`:""}`)?.values()??[]),getNodeConnections:({type:p,handleId:m,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}${p?m?`-${p}-${m}`:`-${p}`:""}`)?.values()??[]),fitView:async p=>{const m=t.getState().fitViewResolver??aj();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:m}),n.nodeQueue.push(h=>[...h]),m.promise}}},[]);return U(()=>({...s,...e,viewportInitialized:o}),[o])}const bf=e=>e.selected,BH=typeof window<"u"?window:void 0;function FH({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=je(),{deleteElements:o}=Nd(),s=wo(e,{actInsideInputWithModifier:!1}),a=wo(t,{target:BH});Z(()=>{if(s){const{edges:i,nodes:l}=n.getState();o({nodes:l.filter(bf),edges:i.filter(bf)}),n.setState({nodesSelectionActive:!1})}},[s]),Z(()=>{n.setState({multiSelectionActive:a})},[a])}function jH(e){const t=je();Z(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const o=gd(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",Gt.error004()),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);const o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}const Oa={position:"absolute",width:"100%",height:"100%",top:0,left:0},HH=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function VH({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:s=.5,panOnScrollMode:a=jn.Free,zoomOnDoubleClick:i=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:d,minZoom:f,maxZoom:p,zoomActivationKeyCode:m,preventScrolling:h=!0,children:g,noWheelClassName:b,noPanClassName:x,onViewportChange:y,isControlledViewport:w,paneClickDistance:v,selectionOnDrag:N}){const k=je(),S=ne(null),{userSelectionActive:M,lib:P,connectionInProgress:A}=$e(HH,Be),z=wo(m),D=ne();jH(S);const T=q(O=>{y?.({x:O[0],y:O[1],zoom:O[2]}),w||k.setState({transform:O})},[y,w]);return Z(()=>{if(S.current){D.current=Vj({domNode:S.current,minZoom:f,maxZoom:p,translateExtent:d,viewport:c,onDraggingChange:_=>k.setState(R=>R.paneDragging===_?R:{paneDragging:_}),onPanZoomStart:(_,R)=>{const{onViewportChangeStart:B,onMoveStart:F}=k.getState();F?.(_,R),B?.(R)},onPanZoom:(_,R)=>{const{onViewportChange:B,onMove:F}=k.getState();F?.(_,R),B?.(R)},onPanZoomEnd:(_,R)=>{const{onViewportChangeEnd:B,onMoveEnd:F}=k.getState();F?.(_,R),B?.(R)}});const{x:O,y:I,zoom:L}=D.current.getViewport();return k.setState({panZoom:D.current,transform:[O,I,L],domNode:S.current.closest(".react-flow")}),()=>{D.current?.destroy()}}},[]),Z(()=>{D.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:s,panOnScrollMode:a,zoomOnDoubleClick:i,panOnDrag:l,zoomActivationKeyPressed:z,preventScrolling:h,noPanClassName:x,userSelectionActive:M,noWheelClassName:b,lib:P,onTransformChange:T,connectionInProgress:A,selectionOnDrag:N,paneClickDistance:v})},[e,t,n,o,s,a,i,l,z,h,x,M,b,P,T,A,N,v]),r("div",{className:"react-flow__renderer",ref:S,style:Oa,children:g})}const qH=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function UH(){const{userSelectionActive:e,userSelectionRect:t}=$e(qH,Be);return e&&t?r("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const $i=(e,t)=>n=>{n.target===t.current&&e?.(n)},QH=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function KH({isSelecting:e,selectionKeyPressed:t,selectionMode:n=xo.Full,panOnDrag:o,paneClickDistance:s,selectionOnDrag:a,onSelectionStart:i,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:d,onPaneScroll:f,onPaneMouseEnter:p,onPaneMouseMove:m,onPaneMouseLeave:h,children:g}){const b=je(),{userSelectionActive:x,elementsSelectable:y,dragging:w,connectionInProgress:v}=$e(QH,Be),N=y&&(e||x),k=ne(null),S=ne(),M=ne(new Set),P=ne(new Set),A=ne(!1),z=B=>{if(A.current||v){A.current=!1;return}c?.(B),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},D=B=>{if(Array.isArray(o)&&o?.includes(2)){B.preventDefault();return}d?.(B)},T=f?B=>f(B):void 0,O=B=>{A.current&&(B.stopPropagation(),A.current=!1)},I=B=>{const{domNode:F}=b.getState();if(S.current=F?.getBoundingClientRect(),!S.current)return;const j=B.target===k.current;if(!j&&!!B.target.closest(".nokey")||!e||!(a&&j||t)||B.button!==0||!B.isPrimary)return;B.target?.setPointerCapture?.(B.pointerId),A.current=!1;const{x:Q,y:K}=_t(B.nativeEvent,S.current);b.setState({userSelectionRect:{width:0,height:0,startX:Q,startY:K,x:Q,y:K}}),j||(B.stopPropagation(),B.preventDefault())},L=B=>{const{userSelectionRect:F,transform:j,nodeLookup:H,edgeLookup:E,connectionLookup:Q,triggerNodeChanges:K,triggerEdgeChanges:Y,defaultEdgeOptions:re,resetSelectedElements:te}=b.getState();if(!S.current||!F)return;const{x:X,y:oe}=_t(B.nativeEvent,S.current),{startX:be,startY:J}=F;if(!A.current){const he=t?0:s;if(Math.hypot(X-be,oe-J)<=he)return;te(),i?.(B)}A.current=!0;const G={startX:be,startY:J,x:X<be?X:be,y:oe<J?oe:J,width:Math.abs(X-be),height:Math.abs(oe-J)},ee=M.current,ae=P.current;M.current=new Set(md(H,G,j,n===xo.Partial,!0).map(he=>he.id)),P.current=new Set;const fe=re?.selectable??!0;for(const he of M.current){const V=Q.get(he);if(V)for(const{edgeId:ie}of V.values()){const ue=E.get(ie);ue&&(ue.selectable??fe)&&P.current.add(ie)}}if(!Up(ee,M.current)){const he=cr(H,M.current,!0);K(he)}if(!Up(ae,P.current)){const he=cr(E,P.current);Y(he)}b.setState({userSelectionRect:G,userSelectionActive:!0,nodesSelectionActive:!1})},_=B=>{B.button===0&&(B.target?.releasePointerCapture?.(B.pointerId),!x&&B.target===k.current&&b.getState().userSelectionRect&&z?.(B),b.setState({userSelectionActive:!1,userSelectionRect:null}),A.current&&(l?.(B),b.setState({nodesSelectionActive:M.current.size>0})))},R=o===!0||Array.isArray(o)&&o.includes(0);return u("div",{className:Qe(["react-flow__pane",{draggable:R,dragging:w,selection:e}]),onClick:N?void 0:$i(z,k),onContextMenu:$i(D,k),onWheel:$i(T,k),onPointerEnter:N?void 0:p,onPointerMove:N?L:m,onPointerUp:N?_:void 0,onPointerDownCapture:N?I:void 0,onClickCapture:N?O:void 0,onPointerLeave:h,ref:k,style:Oa,children:[g,r(UH,{})]})}function Al({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:s,unselectNodesAndEdges:a,multiSelectionActive:i,nodeLookup:l,onError:c}=t.getState(),d=l.get(e);if(!d){c?.("012",Gt.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&i)&&(a({nodes:[d],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):s([e])}function Cv({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:s,isSelectable:a,nodeClickDistance:i}){const l=je(),[c,d]=$(!1),f=ne();return Z(()=>{f.current=Pj({getStoreItems:()=>l.getState(),onNodeMouseDown:p=>{Al({id:p,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),Z(()=>{if(!(t||!e.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:a,nodeId:s,nodeClickDistance:i}),()=>{f.current?.destroy()}},[n,o,t,a,e,s,i]),c}const GH=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Mv(){const e=je();return q(n=>{const{nodeExtent:o,snapToGrid:s,snapGrid:a,nodesDraggable:i,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:f}=e.getState(),p=new Map,m=GH(i),h=s?a[0]:5,g=s?a[1]:5,b=n.direction.x*h*n.factor,x=n.direction.y*g*n.factor;for(const[,y]of d){if(!m(y))continue;let w={x:y.internals.positionAbsolute.x+b,y:y.internals.positionAbsolute.y+x};s&&(w=zo(w,a));const{position:v,positionAbsolute:N}=U0({nodeId:y.id,nextPosition:w,nodeLookup:d,nodeExtent:o,nodeOrigin:f,onError:l});y.position=v,y.internals.positionAbsolute=N,p.set(y.id,y)}c(p)},[])}const kd=Oe(null),WH=kd.Provider;kd.Consumer;const Iv=()=>ve(kd),YH=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),ZH=(e,t,n)=>o=>{const{connectionClickStartHandle:s,connectionMode:a,connection:i}=o,{fromHandle:l,toHandle:c,isValid:d}=i,f=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:l?.nodeId===e&&l?.id===t&&l?.type===n,connectingTo:f,clickConnecting:s?.nodeId===e&&s?.id===t&&s?.type===n,isPossibleEndHandle:a===kr.Strict?l?.type!==n:e!==l?.nodeId||t!==l?.id,connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:f&&d}};function XH({type:e="source",position:t=we.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:s=!0,isConnectableEnd:a=!0,id:i,onConnect:l,children:c,className:d,onMouseDown:f,onTouchStart:p,...m},h){const g=i||null,b=e==="target",x=je(),y=Iv(),{connectOnClick:w,noPanClassName:v,rfId:N}=$e(YH,Be),{connectingFrom:k,connectingTo:S,clickConnecting:M,isPossibleEndHandle:P,connectionInProcess:A,clickConnectionInProcess:z,valid:D}=$e(ZH(y,g,e),Be);y||x.getState().onError?.("010",Gt.error010());const T=L=>{const{defaultEdgeOptions:_,onConnect:R,hasDefaultEdges:B}=x.getState(),F={..._,...L};if(B){const{edges:j,setEdges:H}=x.getState();H(fj(F,j))}R?.(F),l?.(F)},O=L=>{if(!y)return;const _=J0(L.nativeEvent);if(s&&(_&&L.button===0||!_)){const R=x.getState();Ml.onPointerDown(L.nativeEvent,{handleDomNode:L.currentTarget,autoPanOnConnect:R.autoPanOnConnect,connectionMode:R.connectionMode,connectionRadius:R.connectionRadius,domNode:R.domNode,nodeLookup:R.nodeLookup,lib:R.lib,isTarget:b,handleId:g,nodeId:y,flowId:R.rfId,panBy:R.panBy,cancelConnection:R.cancelConnection,onConnectStart:R.onConnectStart,onConnectEnd:(...B)=>x.getState().onConnectEnd?.(...B),updateConnection:R.updateConnection,onConnect:T,isValidConnection:n||((...B)=>x.getState().isValidConnection?.(...B)??!0),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:R.autoPanSpeed,dragThreshold:R.connectionDragThreshold})}_?f?.(L):p?.(L)},I=L=>{const{onClickConnectStart:_,onClickConnectEnd:R,connectionClickStartHandle:B,connectionMode:F,isValidConnection:j,lib:H,rfId:E,nodeLookup:Q,connection:K}=x.getState();if(!y||!B&&!s)return;if(!B){_?.(L.nativeEvent,{nodeId:y,handleId:g,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const Y=Z0(L.target),re=n||j,{connection:te,isValid:X}=Ml.isValid(L.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:F,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:re,flowId:E,doc:Y,lib:H,nodeLookup:Q});X&&te&&T(te);const oe=structuredClone(K);delete oe.inProgress,oe.toPosition=oe.toHandle?oe.toHandle.position:null,R?.(L,oe),x.setState({connectionClickStartHandle:null})};return r("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${N}-${y}-${g}-${e}`,className:Qe(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",v,d,{source:!b,target:b,connectable:o,connectablestart:s,connectableend:a,clickconnecting:M,connectingfrom:k,connectingto:S,valid:D,connectionindicator:o&&(!A||P)&&(A||z?a:s)}]),onMouseDown:O,onTouchStart:O,onClick:w?I:void 0,ref:h,...m,children:c})}const Sn=Fe(kv(XH));function JH({data:e,isConnectable:t,sourcePosition:n=we.Bottom}){return u(ge,{children:[e?.label,r(Sn,{type:"source",position:n,isConnectable:t})]})}function eV({data:e,isConnectable:t,targetPosition:n=we.Top,sourcePosition:o=we.Bottom}){return u(ge,{children:[r(Sn,{type:"target",position:n,isConnectable:t}),e?.label,r(Sn,{type:"source",position:o,isConnectable:t})]})}function tV(){return null}function nV({data:e,isConnectable:t,targetPosition:n=we.Top}){return u(ge,{children:[r(Sn,{type:"target",position:n,isConnectable:t}),e?.label]})}const Ys={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},xf={input:JH,default:eV,output:nV,group:tV};function rV(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const oV=e=>{const{width:t,height:n,x:o,y:s}=Oo(e.nodeLookup,{filter:a=>!!a.selected});return{width:$t(t)?t:null,height:$t(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${s}px)`}};function sV({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=je(),{width:s,height:a,transformString:i,userSelectionActive:l}=$e(oV,Be),c=Mv(),d=ne(null);Z(()=>{n||d.current?.focus({preventScroll:!0})},[n]);const f=!l&&s!==null&&a!==null;if(Cv({nodeRef:d,disabled:!f}),!f)return null;const p=e?h=>{const g=o.getState().nodes.filter(b=>b.selected);e(h,g)}:void 0,m=h=>{Object.prototype.hasOwnProperty.call(Ys,h.key)&&(h.preventDefault(),c({direction:Ys[h.key],factor:h.shiftKey?4:1}))};return r("div",{className:Qe(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:r("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:m,style:{width:s,height:a}})})}const yf=typeof window<"u"?window:void 0,aV=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Av({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:i,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:d,selectionOnDrag:f,selectionMode:p,onSelectionStart:m,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:b,zoomActivationKeyCode:x,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:v,panOnScroll:N,panOnScrollSpeed:k,panOnScrollMode:S,zoomOnDoubleClick:M,panOnDrag:P,defaultViewport:A,translateExtent:z,minZoom:D,maxZoom:T,preventScrolling:O,onSelectionContextMenu:I,noWheelClassName:L,noPanClassName:_,disableKeyboardA11y:R,onViewportChange:B,isControlledViewport:F}){const{nodesSelectionActive:j,userSelectionActive:H}=$e(aV,Be),E=wo(d,{target:yf}),Q=wo(b,{target:yf}),K=Q||P,Y=Q||N,re=f&&K!==!0,te=E||H||re;return FH({deleteKeyCode:c,multiSelectionKeyCode:g}),r(VH,{onPaneContextMenu:a,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:v,panOnScroll:Y,panOnScrollSpeed:k,panOnScrollMode:S,zoomOnDoubleClick:M,panOnDrag:!E&&K,defaultViewport:A,translateExtent:z,minZoom:D,maxZoom:T,zoomActivationKeyCode:x,preventScrolling:O,noWheelClassName:L,noPanClassName:_,onViewportChange:B,isControlledViewport:F,paneClickDistance:l,selectionOnDrag:re,children:u(KH,{onSelectionStart:m,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:i,panOnDrag:K,isSelecting:!!te,selectionMode:p,selectionKeyPressed:E,paneClickDistance:l,selectionOnDrag:re,children:[e,j&&r(sV,{onSelectionContextMenu:I,noPanClassName:_,disableKeyboardA11y:R})]})})}Av.displayName="FlowRenderer";const iV=Fe(Av),lV=e=>t=>e?md(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function cV(e){return $e(q(lV(e),[e]),Be)}const dV=e=>e.updateNodeInternals;function uV(){const e=$e(dV),[t]=$(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;n.forEach(s=>{const a=s.target.getAttribute("data-id");o.set(a,{id:a,nodeElement:s.target,force:!0})}),e(o)}));return Z(()=>()=>{t?.disconnect()},[t]),t}function pV({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const s=je(),a=ne(null),i=ne(null),l=ne(e.sourcePosition),c=ne(e.targetPosition),d=ne(t),f=n&&!!e.internals.handleBounds;return Z(()=>{a.current&&!e.hidden&&(!f||i.current!==a.current)&&(i.current&&o?.unobserve(i.current),o?.observe(a.current),i.current=a.current)},[f,e.hidden]),Z(()=>()=>{i.current&&(o?.unobserve(i.current),i.current=null)},[]),Z(()=>{if(a.current){const p=d.current!==t,m=l.current!==e.sourcePosition,h=c.current!==e.targetPosition;(p||m||h)&&(d.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function fV({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:s,onContextMenu:a,onDoubleClick:i,nodesDraggable:l,elementsSelectable:c,nodesConnectable:d,nodesFocusable:f,resizeObserver:p,noDragClassName:m,noPanClassName:h,disableKeyboardA11y:g,rfId:b,nodeTypes:x,nodeClickDistance:y,onError:w}){const{node:v,internals:N,isParent:k}=$e(X=>{const oe=X.nodeLookup.get(e),be=X.parentLookup.has(e);return{node:oe,internals:oe.internals,isParent:be}},Be);let S=v.type||"default",M=x?.[S]||xf[S];M===void 0&&(w?.("003",Gt.error003(S)),S="default",M=x?.default||xf.default);const P=!!(v.draggable||l&&typeof v.draggable>"u"),A=!!(v.selectable||c&&typeof v.selectable>"u"),z=!!(v.connectable||d&&typeof v.connectable>"u"),D=!!(v.focusable||f&&typeof v.focusable>"u"),T=je(),O=W0(v),I=pV({node:v,nodeType:S,hasDimensions:O,resizeObserver:p}),L=Cv({nodeRef:I,disabled:v.hidden||!P,noDragClassName:m,handleSelector:v.dragHandle,nodeId:e,isSelectable:A,nodeClickDistance:y}),_=Mv();if(v.hidden)return null;const R=mn(v),B=rV(v),F=A||P||t||n||o||s,j=n?X=>n(X,{...N.userNode}):void 0,H=o?X=>o(X,{...N.userNode}):void 0,E=s?X=>s(X,{...N.userNode}):void 0,Q=a?X=>a(X,{...N.userNode}):void 0,K=i?X=>i(X,{...N.userNode}):void 0,Y=X=>{const{selectNodesOnDrag:oe,nodeDragThreshold:be}=T.getState();A&&(!oe||!P||be>0)&&Al({id:e,store:T,nodeRef:I}),t&&t(X,{...N.userNode})},re=X=>{if(!(X0(X.nativeEvent)||g)){if(F0.includes(X.key)&&A){const oe=X.key==="Escape";Al({id:e,store:T,unselect:oe,nodeRef:I})}else if(P&&v.selected&&Object.prototype.hasOwnProperty.call(Ys,X.key)){X.preventDefault();const{ariaLabelConfig:oe}=T.getState();T.setState({ariaLiveMessage:oe["node.a11yDescription.ariaLiveMessage"]({direction:X.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),_({direction:Ys[X.key],factor:X.shiftKey?4:1})}}},te=()=>{if(g||!I.current?.matches(":focus-visible"))return;const{transform:X,width:oe,height:be,autoPanOnNodeFocus:J,setCenter:G}=T.getState();if(!J)return;md(new Map([[e,v]]),{x:0,y:0,width:oe,height:be},X,!0).length>0||G(v.position.x+R.width/2,v.position.y+R.height/2,{zoom:X[2]})};return r("div",{className:Qe(["react-flow__node",`react-flow__node-${S}`,{[h]:P},v.className,{selected:v.selected,selectable:A,parent:k,draggable:P,dragging:L}]),ref:I,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:F?"all":"none",visibility:O?"visible":"hidden",...v.style,...B},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:j,onMouseMove:H,onMouseLeave:E,onContextMenu:Q,onClick:Y,onDoubleClick:K,onKeyDown:D?re:void 0,tabIndex:D?0:void 0,onFocus:D?te:void 0,role:v.ariaRole??(D?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${yv}-${b}`,"aria-label":v.ariaLabel,...v.domAttributes,children:r(WH,{value:e,children:r(M,{id:e,data:v.data,type:S,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:v.selected??!1,selectable:A,draggable:P,deletable:v.deletable??!0,isConnectable:z,sourcePosition:v.sourcePosition,targetPosition:v.targetPosition,dragging:L,dragHandle:v.dragHandle,zIndex:N.z,parentId:v.parentId,...R})})})}var mV=Fe(fV);const hV=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Pv(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:s,onError:a}=$e(hV,Be),i=cV(e.onlyRenderVisibleElements),l=uV();return r("div",{className:"react-flow__nodes",style:Oa,children:i.map(c=>r(mV,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:a},c))})}Pv.displayName="NodeRenderer";const gV=Fe(Pv);function bV(e){return $e(q(n=>{if(!e)return n.edges.map(s=>s.id);const o=[];if(n.width&&n.height)for(const s of n.edges){const a=n.nodeLookup.get(s.source),i=n.nodeLookup.get(s.target);a&&i&&dj({sourceNode:a,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&o.push(s.id)}return o},[e]),Be)}const xV=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return r("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},yV=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return r("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},vf={[Ks.Arrow]:xV,[Ks.ArrowClosed]:yV};function vV(e){const t=je();return U(()=>Object.prototype.hasOwnProperty.call(vf,e)?vf[e]:(t.getState().onError?.("009",Gt.error009(e)),null),[e])}const wV=({id:e,type:t,color:n,width:o=12.5,height:s=12.5,markerUnits:a="strokeWidth",strokeWidth:i,orient:l="auto-start-reverse"})=>{const c=vV(t);return c?r("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:l,refX:"0",refY:"0",children:r(c,{color:n,strokeWidth:i})}):null},Ev=({defaultColor:e,rfId:t})=>{const n=$e(a=>a.edges),o=$e(a=>a.defaultEdgeOptions),s=U(()=>xj(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return s.length?r("svg",{className:"react-flow__marker","aria-hidden":"true",children:r("defs",{children:s.map(a=>r(wV,{id:a.id,type:a.type,color:a.color,width:a.width,height:a.height,markerUnits:a.markerUnits,strokeWidth:a.strokeWidth,orient:a.orient},a.id))})}):null};Ev.displayName="MarkerDefinitions";var NV=Fe(Ev);function $v({x:e,y:t,label:n,labelStyle:o,labelShowBg:s=!0,labelBgStyle:a,labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...f}){const[p,m]=$({x:1,y:0,width:0,height:0}),h=Qe(["react-flow__edge-textwrapper",d]),g=ne(null);return Z(()=>{if(g.current){const b=g.current.getBBox();m({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?u("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:h,visibility:p.width?"visible":"hidden",...f,children:[s&&r("rect",{width:p.width+2*i[0],x:-i[0],y:-i[1],height:p.height+2*i[1],className:"react-flow__edge-textbg",style:a,rx:l,ry:l}),r("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:g,style:o,children:n}),c]}):null}$v.displayName="EdgeText";const kV=Fe($v);function za({path:e,labelX:t,labelY:n,label:o,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:d=20,...f}){return u(ge,{children:[r("path",{...f,d:e,fill:"none",className:Qe(["react-flow__edge-path",f.className])}),d?r("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,o&&$t(t)&&$t(n)?r(kV,{x:t,y:n,label:o,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function wf({pos:e,x1:t,y1:n,x2:o,y2:s}){return e===we.Left||e===we.Right?[.5*(t+o),n]:[t,.5*(n+s)]}function _v({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:o,targetY:s,targetPosition:a=we.Top}){const[i,l]=wf({pos:n,x1:e,y1:t,x2:o,y2:s}),[c,d]=wf({pos:a,x1:o,y1:s,x2:e,y2:t}),[f,p,m,h]=ev({sourceX:e,sourceY:t,targetX:o,targetY:s,sourceControlX:i,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${i},${l} ${c},${d} ${o},${s}`,f,p,m,h]}function Dv(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,sourcePosition:i,targetPosition:l,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:x,interactionWidth:y})=>{const[w,v,N]=_v({sourceX:n,sourceY:o,sourcePosition:i,targetX:s,targetY:a,targetPosition:l}),k=e.isInternal?void 0:t;return r(za,{id:k,path:w,labelX:v,labelY:N,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:x,interactionWidth:y})})}const SV=Dv({isInternal:!1}),Lv=Dv({isInternal:!0});SV.displayName="SimpleBezierEdge";Lv.displayName="SimpleBezierEdgeInternal";function Tv(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,sourcePosition:h=we.Bottom,targetPosition:g=we.Top,markerEnd:b,markerStart:x,pathOptions:y,interactionWidth:w})=>{const[v,N,k]=kl({sourceX:n,sourceY:o,sourcePosition:h,targetX:s,targetY:a,targetPosition:g,borderRadius:y?.borderRadius,offset:y?.offset,stepPosition:y?.stepPosition}),S=e.isInternal?void 0:t;return r(za,{id:S,path:v,labelX:N,labelY:k,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:b,markerStart:x,interactionWidth:w})})}const Rv=Tv({isInternal:!1}),Ov=Tv({isInternal:!0});Rv.displayName="SmoothStepEdge";Ov.displayName="SmoothStepEdgeInternal";function zv(e){return Fe(({id:t,...n})=>{const o=e.isInternal?void 0:t;return r(Rv,{...n,id:o,pathOptions:U(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const CV=zv({isInternal:!1}),Bv=zv({isInternal:!0});CV.displayName="StepEdge";Bv.displayName="StepEdgeInternal";function Fv(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:b})=>{const[x,y,w]=rv({sourceX:n,sourceY:o,targetX:s,targetY:a}),v=e.isInternal?void 0:t;return r(za,{id:v,path:x,labelX:y,labelY:w,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:b})})}const MV=Fv({isInternal:!1}),jv=Fv({isInternal:!0});MV.displayName="StraightEdge";jv.displayName="StraightEdgeInternal";function Hv(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,sourcePosition:i=we.Bottom,targetPosition:l=we.Top,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:x,pathOptions:y,interactionWidth:w})=>{const[v,N,k]=tv({sourceX:n,sourceY:o,sourcePosition:i,targetX:s,targetY:a,targetPosition:l,curvature:y?.curvature}),S=e.isInternal?void 0:t;return r(za,{id:S,path:v,labelX:N,labelY:k,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:x,interactionWidth:w})})}const IV=Hv({isInternal:!1}),Vv=Hv({isInternal:!0});IV.displayName="BezierEdge";Vv.displayName="BezierEdgeInternal";const Nf={default:Vv,straight:jv,step:Bv,smoothstep:Ov,simplebezier:Lv},kf={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},AV=(e,t,n)=>n===we.Left?e-t:n===we.Right?e+t:e,PV=(e,t,n)=>n===we.Top?e-t:n===we.Bottom?e+t:e,Sf="react-flow__edgeupdater";function Cf({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:s,onMouseEnter:a,onMouseOut:i,type:l}){return r("circle",{onMouseDown:s,onMouseEnter:a,onMouseOut:i,className:Qe([Sf,`${Sf}-${l}`]),cx:AV(t,o,e),cy:PV(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function EV({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:s,targetX:a,targetY:i,sourcePosition:l,targetPosition:c,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,setReconnecting:m,setUpdateHover:h}){const g=je(),b=(N,k)=>{if(N.button!==0)return;const{autoPanOnConnect:S,domNode:M,connectionMode:P,connectionRadius:A,lib:z,onConnectStart:D,cancelConnection:T,nodeLookup:O,rfId:I,panBy:L,updateConnection:_}=g.getState(),R=k.type==="target",B=(H,E)=>{m(!1),p?.(H,n,k.type,E)},F=H=>d?.(n,H),j=(H,E)=>{m(!0),f?.(N,n,k.type),D?.(H,E)};Ml.onPointerDown(N.nativeEvent,{autoPanOnConnect:S,connectionMode:P,connectionRadius:A,domNode:M,handleId:k.id,nodeId:k.nodeId,nodeLookup:O,isTarget:R,edgeUpdaterType:k.type,lib:z,flowId:I,cancelConnection:T,panBy:L,isValidConnection:(...H)=>g.getState().isValidConnection?.(...H)??!0,onConnect:F,onConnectStart:j,onConnectEnd:(...H)=>g.getState().onConnectEnd?.(...H),onReconnectEnd:B,updateConnection:_,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},x=N=>b(N,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=N=>b(N,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),w=()=>h(!0),v=()=>h(!1);return u(ge,{children:[(e===!0||e==="source")&&r(Cf,{position:l,centerX:o,centerY:s,radius:t,onMouseDown:x,onMouseEnter:w,onMouseOut:v,type:"source"}),(e===!0||e==="target")&&r(Cf,{position:c,centerX:a,centerY:i,radius:t,onMouseDown:y,onMouseEnter:w,onMouseOut:v,type:"target"})]})}function $V({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:s,onDoubleClick:a,onContextMenu:i,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,reconnectRadius:f,onReconnect:p,onReconnectStart:m,onReconnectEnd:h,rfId:g,edgeTypes:b,noPanClassName:x,onError:y,disableKeyboardA11y:w}){let v=$e(G=>G.edgeLookup.get(e));const N=$e(G=>G.defaultEdgeOptions);v=N?{...N,...v}:v;let k=v.type||"default",S=b?.[k]||Nf[k];S===void 0&&(y?.("011",Gt.error011(k)),k="default",S=b?.default||Nf.default);const M=!!(v.focusable||t&&typeof v.focusable>"u"),P=typeof p<"u"&&(v.reconnectable||n&&typeof v.reconnectable>"u"),A=!!(v.selectable||o&&typeof v.selectable>"u"),z=ne(null),[D,T]=$(!1),[O,I]=$(!1),L=je(),{zIndex:_,sourceX:R,sourceY:B,targetX:F,targetY:j,sourcePosition:H,targetPosition:E}=$e(q(G=>{const ee=G.nodeLookup.get(v.source),ae=G.nodeLookup.get(v.target);if(!ee||!ae)return{zIndex:v.zIndex,...kf};const fe=bj({id:e,sourceNode:ee,targetNode:ae,sourceHandle:v.sourceHandle||null,targetHandle:v.targetHandle||null,connectionMode:G.connectionMode,onError:y});return{zIndex:cj({selected:v.selected,zIndex:v.zIndex,sourceNode:ee,targetNode:ae,elevateOnSelect:G.elevateEdgesOnSelect,zIndexMode:G.zIndexMode}),...fe||kf}},[v.source,v.target,v.sourceHandle,v.targetHandle,v.selected,v.zIndex]),Be),Q=U(()=>v.markerStart?`url('#${Sl(v.markerStart,g)}')`:void 0,[v.markerStart,g]),K=U(()=>v.markerEnd?`url('#${Sl(v.markerEnd,g)}')`:void 0,[v.markerEnd,g]);if(v.hidden||R===null||B===null||F===null||j===null)return null;const Y=G=>{const{addSelectedEdges:ee,unselectNodesAndEdges:ae,multiSelectionActive:fe}=L.getState();A&&(L.setState({nodesSelectionActive:!1}),v.selected&&fe?(ae({nodes:[],edges:[v]}),z.current?.blur()):ee([e])),s&&s(G,v)},re=a?G=>{a(G,{...v})}:void 0,te=i?G=>{i(G,{...v})}:void 0,X=l?G=>{l(G,{...v})}:void 0,oe=c?G=>{c(G,{...v})}:void 0,be=d?G=>{d(G,{...v})}:void 0,J=G=>{if(!w&&F0.includes(G.key)&&A){const{unselectNodesAndEdges:ee,addSelectedEdges:ae}=L.getState();G.key==="Escape"?(z.current?.blur(),ee({edges:[v]})):ae([e])}};return r("svg",{style:{zIndex:_},children:u("g",{className:Qe(["react-flow__edge",`react-flow__edge-${k}`,v.className,x,{selected:v.selected,animated:v.animated,inactive:!A&&!s,updating:D,selectable:A}]),onClick:Y,onDoubleClick:re,onContextMenu:te,onMouseEnter:X,onMouseMove:oe,onMouseLeave:be,onKeyDown:M?J:void 0,tabIndex:M?0:void 0,role:v.ariaRole??(M?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":v.ariaLabel===null?void 0:v.ariaLabel||`Edge from ${v.source} to ${v.target}`,"aria-describedby":M?`${vv}-${g}`:void 0,ref:z,...v.domAttributes,children:[!O&&r(S,{id:e,source:v.source,target:v.target,type:v.type,selected:v.selected,animated:v.animated,selectable:A,deletable:v.deletable??!0,label:v.label,labelStyle:v.labelStyle,labelShowBg:v.labelShowBg,labelBgStyle:v.labelBgStyle,labelBgPadding:v.labelBgPadding,labelBgBorderRadius:v.labelBgBorderRadius,sourceX:R,sourceY:B,targetX:F,targetY:j,sourcePosition:H,targetPosition:E,data:v.data,style:v.style,sourceHandleId:v.sourceHandle,targetHandleId:v.targetHandle,markerStart:Q,markerEnd:K,pathOptions:"pathOptions"in v?v.pathOptions:void 0,interactionWidth:v.interactionWidth}),P&&r(EV,{edge:v,isReconnectable:P,reconnectRadius:f,onReconnect:p,onReconnectStart:m,onReconnectEnd:h,sourceX:R,sourceY:B,targetX:F,targetY:j,sourcePosition:H,targetPosition:E,setUpdateHover:T,setReconnecting:I})]})})}var _V=Fe($V);const DV=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function qv({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:s,onReconnect:a,onEdgeContextMenu:i,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeClick:f,reconnectRadius:p,onEdgeDoubleClick:m,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:b}){const{edgesFocusable:x,edgesReconnectable:y,elementsSelectable:w,onError:v}=$e(DV,Be),N=bV(t);return u("div",{className:"react-flow__edges",children:[r(NV,{defaultColor:e,rfId:n}),N.map(k=>r(_V,{id:k,edgesFocusable:x,edgesReconnectable:y,elementsSelectable:w,noPanClassName:s,onReconnect:a,onContextMenu:i,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onClick:f,reconnectRadius:p,onDoubleClick:m,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:v,edgeTypes:o,disableKeyboardA11y:b},k))]})}qv.displayName="EdgeRenderer";const LV=Fe(qv),TV=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function RV({children:e}){const t=$e(TV);return r("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function OV(e){const t=Nd(),n=ne(!1);Z(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const zV=e=>e.panZoom?.syncViewport;function BV(e){const t=$e(zV),n=je();return Z(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function FV(e){return e.connection.inProgress?{...e.connection,to:Bo(e.connection.to,e.transform)}:{...e.connection}}function jV(e){return FV}function HV(e){const t=jV();return $e(t,Be)}const VV=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function qV({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:s,width:a,height:i,isValid:l,inProgress:c}=$e(VV,Be);return!(a&&s&&c)?null:r("svg",{style:e,width:a,height:i,className:"react-flow__connectionline react-flow__container",children:r("g",{className:Qe(["react-flow__connection",V0(l)]),children:r(Uv,{style:t,type:n,CustomComponent:o,isValid:l})})})}const Uv=({style:e,type:t=yn.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:s,from:a,fromNode:i,fromHandle:l,fromPosition:c,to:d,toNode:f,toHandle:p,toPosition:m,pointer:h}=HV();if(!s)return;if(n)return r(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:l,fromX:a.x,fromY:a.y,toX:d.x,toY:d.y,fromPosition:c,toPosition:m,connectionStatus:V0(o),toNode:f,toHandle:p,pointer:h});let g="";const b={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:d.x,targetY:d.y,targetPosition:m};switch(t){case yn.Bezier:[g]=tv(b);break;case yn.SimpleBezier:[g]=_v(b);break;case yn.Step:[g]=kl({...b,borderRadius:0});break;case yn.SmoothStep:[g]=kl(b);break;default:[g]=rv(b)}return r("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};Uv.displayName="ConnectionLine";const UV={};function Mf(e=UV){ne(e),je(),Z(()=>{},[e])}function QV(){je(),ne(!1),Z(()=>{},[])}function Qv({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:s,onNodeDoubleClick:a,onEdgeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,onSelectionContextMenu:p,onSelectionStart:m,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:b,connectionLineComponent:x,connectionLineContainerStyle:y,selectionKeyCode:w,selectionOnDrag:v,selectionMode:N,multiSelectionKeyCode:k,panActivationKeyCode:S,zoomActivationKeyCode:M,deleteKeyCode:P,onlyRenderVisibleElements:A,elementsSelectable:z,defaultViewport:D,translateExtent:T,minZoom:O,maxZoom:I,preventScrolling:L,defaultMarkerColor:_,zoomOnScroll:R,zoomOnPinch:B,panOnScroll:F,panOnScrollSpeed:j,panOnScrollMode:H,zoomOnDoubleClick:E,panOnDrag:Q,onPaneClick:K,onPaneMouseEnter:Y,onPaneMouseMove:re,onPaneMouseLeave:te,onPaneScroll:X,onPaneContextMenu:oe,paneClickDistance:be,nodeClickDistance:J,onEdgeContextMenu:G,onEdgeMouseEnter:ee,onEdgeMouseMove:ae,onEdgeMouseLeave:fe,reconnectRadius:he,onReconnect:V,onReconnectStart:ie,onReconnectEnd:ue,noDragClassName:de,noWheelClassName:ce,noPanClassName:Se,disableKeyboardA11y:pe,nodeExtent:Ie,rfId:Te,viewport:We,onViewportChange:rt}){return Mf(e),Mf(t),QV(),OV(n),BV(We),r(iV,{onPaneClick:K,onPaneMouseEnter:Y,onPaneMouseMove:re,onPaneMouseLeave:te,onPaneContextMenu:oe,onPaneScroll:X,paneClickDistance:be,deleteKeyCode:P,selectionKeyCode:w,selectionOnDrag:v,selectionMode:N,onSelectionStart:m,onSelectionEnd:h,multiSelectionKeyCode:k,panActivationKeyCode:S,zoomActivationKeyCode:M,elementsSelectable:z,zoomOnScroll:R,zoomOnPinch:B,zoomOnDoubleClick:E,panOnScroll:F,panOnScrollSpeed:j,panOnScrollMode:H,panOnDrag:Q,defaultViewport:D,translateExtent:T,minZoom:O,maxZoom:I,onSelectionContextMenu:p,preventScrolling:L,noDragClassName:de,noWheelClassName:ce,noPanClassName:Se,disableKeyboardA11y:pe,onViewportChange:rt,isControlledViewport:!!We,children:u(RV,{children:[r(LV,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:i,onReconnect:V,onReconnectStart:ie,onReconnectEnd:ue,onlyRenderVisibleElements:A,onEdgeContextMenu:G,onEdgeMouseEnter:ee,onEdgeMouseMove:ae,onEdgeMouseLeave:fe,reconnectRadius:he,defaultMarkerColor:_,noPanClassName:Se,disableKeyboardA11y:pe,rfId:Te}),r(qV,{style:b,type:g,component:x,containerStyle:y}),r("div",{className:"react-flow__edgelabel-renderer"}),r(gV,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,nodeClickDistance:J,onlyRenderVisibleElements:A,noPanClassName:Se,noDragClassName:de,disableKeyboardA11y:pe,nodeExtent:Ie,rfId:Te}),r("div",{className:"react-flow__viewport-portal"})]})})}Qv.displayName="GraphView";const KV=Fe(Qv),If=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c=.5,maxZoom:d=2,nodeOrigin:f,nodeExtent:p,zIndexMode:m="basic"}={})=>{const h=new Map,g=new Map,b=new Map,x=new Map,y=o??t??[],w=n??e??[],v=f??[0,0],N=p??bo;av(b,x,y);const{nodesInitialized:k}=Cl(w,h,g,{nodeOrigin:v,nodeExtent:N,zIndexMode:m});let S=[0,0,1];if(i&&s&&a){const M=Oo(h,{filter:D=>!!((D.width||D.initialWidth)&&(D.height||D.initialHeight))}),{x:P,y:A,zoom:z}=hd(M,s,a,c,d,l?.padding??.1);S=[P,A,z]}return{rfId:"1",width:s??0,height:a??0,transform:S,nodes:w,nodesInitialized:k,nodeLookup:h,parentLookup:g,edges:y,edgeLookup:x,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:c,maxZoom:d,translateExtent:bo,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:kr.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:v,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:i??!1,fitViewOptions:l,fitViewResolver:null,connection:{...H0},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:rj,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:j0,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},GV=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:p,zIndexMode:m})=>uH((h,g)=>{async function b(){const{nodeLookup:x,panZoom:y,fitViewOptions:w,fitViewResolver:v,width:N,height:k,minZoom:S,maxZoom:M}=g();y&&(await tj({nodes:x,width:N,height:k,panZoom:y,minZoom:S,maxZoom:M},w),v?.resolve(!0),h({fitViewResolver:null}))}return{...If({nodes:e,edges:t,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:p,defaultNodes:n,defaultEdges:o,zIndexMode:m}),setNodes:x=>{const{nodeLookup:y,parentLookup:w,nodeOrigin:v,elevateNodesOnSelect:N,fitViewQueued:k,zIndexMode:S,nodesSelectionActive:M}=g(),{nodesInitialized:P,hasSelectedNodes:A}=Cl(x,y,w,{nodeOrigin:v,nodeExtent:p,elevateNodesOnSelect:N,checkEquality:!0,zIndexMode:S}),z=M&&A;k&&P?(b(),h({nodes:x,nodesInitialized:P,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:z})):h({nodes:x,nodesInitialized:P,nodesSelectionActive:z})},setEdges:x=>{const{connectionLookup:y,edgeLookup:w}=g();av(y,w,x),h({edges:x})},setDefaultNodesAndEdges:(x,y)=>{if(x){const{setNodes:w}=g();w(x),h({hasDefaultNodes:!0})}if(y){const{setEdges:w}=g();w(y),h({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:y,nodeLookup:w,parentLookup:v,domNode:N,nodeOrigin:k,nodeExtent:S,debug:M,fitViewQueued:P,zIndexMode:A}=g(),{changes:z,updatedInternals:D}=Cj(x,w,v,N,k,S,A);D&&(wj(w,v,{nodeOrigin:k,nodeExtent:S,zIndexMode:A}),P?(b(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),z?.length>0&&(M&&console.log("React Flow: trigger node changes",z),y?.(z)))},updateNodePositions:(x,y=!1)=>{const w=[];let v=[];const{nodeLookup:N,triggerNodeChanges:k,connection:S,updateConnection:M,onNodesChangeMiddlewareMap:P}=g();for(const[A,z]of x){const D=N.get(A),T=!!(D?.expandParent&&D?.parentId&&z?.position),O={id:A,type:"position",position:T?{x:Math.max(0,z.position.x),y:Math.max(0,z.position.y)}:z.position,dragging:y};if(D&&S.inProgress&&S.fromNode.id===D.id){const I=Gn(D,S.fromHandle,we.Left,!0);M({...S,from:I})}T&&D.parentId&&w.push({id:A,parentId:D.parentId,rect:{...z.internals.positionAbsolute,width:z.measured.width??0,height:z.measured.height??0}}),v.push(O)}if(w.length>0){const{parentLookup:A,nodeOrigin:z}=g(),D=wd(w,N,A,z);v.push(...D)}for(const A of P.values())v=A(v);k(v)},triggerNodeChanges:x=>{const{onNodesChange:y,setNodes:w,nodes:v,hasDefaultNodes:N,debug:k}=g();if(x?.length){if(N){const S=_H(x,v);w(S)}k&&console.log("React Flow: trigger node changes",x),y?.(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:y,setEdges:w,edges:v,hasDefaultEdges:N,debug:k}=g();if(x?.length){if(N){const S=DH(x,v);w(S)}k&&console.log("React Flow: trigger edge changes",x),y?.(x)}},addSelectedNodes:x=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:v,triggerNodeChanges:N,triggerEdgeChanges:k}=g();if(y){const S=x.map(M=>Tn(M,!0));N(S);return}N(cr(v,new Set([...x]),!0)),k(cr(w))},addSelectedEdges:x=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:v,triggerNodeChanges:N,triggerEdgeChanges:k}=g();if(y){const S=x.map(M=>Tn(M,!0));k(S);return}k(cr(w,new Set([...x]))),N(cr(v,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:y}={})=>{const{edges:w,nodes:v,nodeLookup:N,triggerNodeChanges:k,triggerEdgeChanges:S}=g(),M=x||v,P=y||w,A=[];for(const D of M){if(!D.selected)continue;const T=N.get(D.id);T&&(T.selected=!1),A.push(Tn(D.id,!1))}const z=[];for(const D of P)D.selected&&z.push(Tn(D.id,!1));k(A),S(z)},setMinZoom:x=>{const{panZoom:y,maxZoom:w}=g();y?.setScaleExtent([x,w]),h({minZoom:x})},setMaxZoom:x=>{const{panZoom:y,minZoom:w}=g();y?.setScaleExtent([w,x]),h({maxZoom:x})},setTranslateExtent:x=>{g().panZoom?.setTranslateExtent(x),h({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:y,triggerNodeChanges:w,triggerEdgeChanges:v,elementsSelectable:N}=g();if(!N)return;const k=y.reduce((M,P)=>P.selected?[...M,Tn(P.id,!1)]:M,[]),S=x.reduce((M,P)=>P.selected?[...M,Tn(P.id,!1)]:M,[]);w(k),v(S)},setNodeExtent:x=>{const{nodes:y,nodeLookup:w,parentLookup:v,nodeOrigin:N,elevateNodesOnSelect:k,nodeExtent:S,zIndexMode:M}=g();x[0][0]===S[0][0]&&x[0][1]===S[0][1]&&x[1][0]===S[1][0]&&x[1][1]===S[1][1]||(Cl(y,w,v,{nodeOrigin:N,nodeExtent:x,elevateNodesOnSelect:k,checkEquality:!1,zIndexMode:M}),h({nodeExtent:x}))},panBy:x=>{const{transform:y,width:w,height:v,panZoom:N,translateExtent:k}=g();return Mj({delta:x,panZoom:N,transform:y,translateExtent:k,width:w,height:v})},setCenter:async(x,y,w)=>{const{width:v,height:N,maxZoom:k,panZoom:S}=g();if(!S)return Promise.resolve(!1);const M=typeof w?.zoom<"u"?w.zoom:k;return await S.setViewport({x:v/2-x*M,y:N/2-y*M,zoom:M},{duration:w?.duration,ease:w?.ease,interpolate:w?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...H0}})},updateConnection:x=>{h({connection:x})},reset:()=>h({...If()})}},Object.is);function WV({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:s,initialHeight:a,initialMinZoom:i,initialMaxZoom:l,initialFitViewOptions:c,fitView:d,nodeOrigin:f,nodeExtent:p,zIndexMode:m,children:h}){const[g]=$(()=>GV({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:s,height:a,fitView:d,minZoom:i,maxZoom:l,fitViewOptions:c,nodeOrigin:f,nodeExtent:p,zIndexMode:m}));return r(pH,{value:g,children:r(RH,{children:h})})}function YV({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:s,width:a,height:i,fitView:l,fitViewOptions:c,minZoom:d,maxZoom:f,nodeOrigin:p,nodeExtent:m,zIndexMode:h}){return ve(Ta)?r(ge,{children:e}):r(WV,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:i,fitView:l,initialFitViewOptions:c,initialMinZoom:d,initialMaxZoom:f,nodeOrigin:p,nodeExtent:m,zIndexMode:h,children:e})}const ZV={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function XV({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:s,nodeTypes:a,edgeTypes:i,onNodeClick:l,onEdgeClick:c,onInit:d,onMove:f,onMoveStart:p,onMoveEnd:m,onConnect:h,onConnectStart:g,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:y,onNodeMouseEnter:w,onNodeMouseMove:v,onNodeMouseLeave:N,onNodeContextMenu:k,onNodeDoubleClick:S,onNodeDragStart:M,onNodeDrag:P,onNodeDragStop:A,onNodesDelete:z,onEdgesDelete:D,onDelete:T,onSelectionChange:O,onSelectionDragStart:I,onSelectionDrag:L,onSelectionDragStop:_,onSelectionContextMenu:R,onSelectionStart:B,onSelectionEnd:F,onBeforeDelete:j,connectionMode:H,connectionLineType:E=yn.Bezier,connectionLineStyle:Q,connectionLineComponent:K,connectionLineContainerStyle:Y,deleteKeyCode:re="Backspace",selectionKeyCode:te="Shift",selectionOnDrag:X=!1,selectionMode:oe=xo.Full,panActivationKeyCode:be="Space",multiSelectionKeyCode:J=vo()?"Meta":"Control",zoomActivationKeyCode:G=vo()?"Meta":"Control",snapToGrid:ee,snapGrid:ae,onlyRenderVisibleElements:fe=!1,selectNodesOnDrag:he,nodesDraggable:V,autoPanOnNodeFocus:ie,nodesConnectable:ue,nodesFocusable:de,nodeOrigin:ce=wv,edgesFocusable:Se,edgesReconnectable:pe,elementsSelectable:Ie=!0,defaultViewport:Te=CH,minZoom:We=.5,maxZoom:rt=2,translateExtent:sr=bo,preventScrolling:me=!0,nodeExtent:Ee,defaultMarkerColor:De="#b1b1b7",zoomOnScroll:Re=!0,zoomOnPinch:Pn=!0,panOnScroll:En=!1,panOnScrollSpeed:zr=.5,panOnScrollMode:Zv=jn.Free,zoomOnDoubleClick:Xv=!0,panOnDrag:Jv=!0,onPaneClick:e1,onPaneMouseEnter:t1,onPaneMouseMove:n1,onPaneMouseLeave:r1,onPaneScroll:o1,onPaneContextMenu:s1,paneClickDistance:a1=1,nodeClickDistance:i1=0,children:l1,onReconnect:c1,onReconnectStart:d1,onReconnectEnd:u1,onEdgeContextMenu:p1,onEdgeDoubleClick:f1,onEdgeMouseEnter:m1,onEdgeMouseMove:h1,onEdgeMouseLeave:g1,reconnectRadius:b1=10,onNodesChange:x1,onEdgesChange:y1,noDragClassName:v1="nodrag",noWheelClassName:w1="nowheel",noPanClassName:Sd="nopan",fitView:Cd,fitViewOptions:Md,connectOnClick:N1,attributionPosition:k1,proOptions:S1,defaultEdgeOptions:C1,elevateNodesOnSelect:M1=!0,elevateEdgesOnSelect:I1=!1,disableKeyboardA11y:Id=!1,autoPanOnConnect:A1,autoPanOnNodeDrag:P1,autoPanSpeed:E1,connectionRadius:$1,isValidConnection:_1,onError:D1,style:L1,id:Ad,nodeDragThreshold:T1,connectionDragThreshold:R1,viewport:O1,onViewportChange:z1,width:B1,height:F1,colorMode:j1="light",debug:H1,onScroll:Pd,ariaLabelConfig:V1,zIndexMode:Ed="basic",...q1},U1){const Ba=Ad||"1",Q1=PH(j1),K1=q($d=>{$d.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Pd?.($d)},[Pd]);return r("div",{"data-testid":"rf__wrapper",...q1,onScroll:K1,style:{...L1,...ZV},ref:U1,className:Qe(["react-flow",s,Q1]),id:Ad,role:"application",children:u(YV,{nodes:e,edges:t,width:B1,height:F1,fitView:Cd,fitViewOptions:Md,minZoom:We,maxZoom:rt,nodeOrigin:ce,nodeExtent:Ee,zIndexMode:Ed,children:[r(AH,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:h,onConnectStart:g,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:y,nodesDraggable:V,autoPanOnNodeFocus:ie,nodesConnectable:ue,nodesFocusable:de,edgesFocusable:Se,edgesReconnectable:pe,elementsSelectable:Ie,elevateNodesOnSelect:M1,elevateEdgesOnSelect:I1,minZoom:We,maxZoom:rt,nodeExtent:Ee,onNodesChange:x1,onEdgesChange:y1,snapToGrid:ee,snapGrid:ae,connectionMode:H,translateExtent:sr,connectOnClick:N1,defaultEdgeOptions:C1,fitView:Cd,fitViewOptions:Md,onNodesDelete:z,onEdgesDelete:D,onDelete:T,onNodeDragStart:M,onNodeDrag:P,onNodeDragStop:A,onSelectionDrag:L,onSelectionDragStart:I,onSelectionDragStop:_,onMove:f,onMoveStart:p,onMoveEnd:m,noPanClassName:Sd,nodeOrigin:ce,rfId:Ba,autoPanOnConnect:A1,autoPanOnNodeDrag:P1,autoPanSpeed:E1,onError:D1,connectionRadius:$1,isValidConnection:_1,selectNodesOnDrag:he,nodeDragThreshold:T1,connectionDragThreshold:R1,onBeforeDelete:j,debug:H1,ariaLabelConfig:V1,zIndexMode:Ed}),r(KV,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:w,onNodeMouseMove:v,onNodeMouseLeave:N,onNodeContextMenu:k,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:i,connectionLineType:E,connectionLineStyle:Q,connectionLineComponent:K,connectionLineContainerStyle:Y,selectionKeyCode:te,selectionOnDrag:X,selectionMode:oe,deleteKeyCode:re,multiSelectionKeyCode:J,panActivationKeyCode:be,zoomActivationKeyCode:G,onlyRenderVisibleElements:fe,defaultViewport:Te,translateExtent:sr,minZoom:We,maxZoom:rt,preventScrolling:me,zoomOnScroll:Re,zoomOnPinch:Pn,zoomOnDoubleClick:Xv,panOnScroll:En,panOnScrollSpeed:zr,panOnScrollMode:Zv,panOnDrag:Jv,onPaneClick:e1,onPaneMouseEnter:t1,onPaneMouseMove:n1,onPaneMouseLeave:r1,onPaneScroll:o1,onPaneContextMenu:s1,paneClickDistance:a1,nodeClickDistance:i1,onSelectionContextMenu:R,onSelectionStart:B,onSelectionEnd:F,onReconnect:c1,onReconnectStart:d1,onReconnectEnd:u1,onEdgeContextMenu:p1,onEdgeDoubleClick:f1,onEdgeMouseEnter:m1,onEdgeMouseMove:h1,onEdgeMouseLeave:g1,reconnectRadius:b1,defaultMarkerColor:De,noDragClassName:v1,noWheelClassName:w1,noPanClassName:Sd,rfId:Ba,disableKeyboardA11y:Id,nodeExtent:Ee,viewport:O1,onViewportChange:z1}),r(SH,{onSelectionChange:O}),l1,r(yH,{proOptions:S1,position:k1}),r(xH,{rfId:Ba,disableKeyboardA11y:Id})]})})}var JV=kv(XV);function eq({dimensions:e,lineWidth:t,variant:n,className:o}){return r("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Qe(["react-flow__background-pattern",n,o])})}function tq({radius:e,className:t}){return r("circle",{cx:e,cy:e,r:e,className:Qe(["react-flow__background-pattern","dots",t])})}var wn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(wn||(wn={}));const nq={[wn.Dots]:1,[wn.Lines]:1,[wn.Cross]:6},rq=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Kv({id:e,variant:t=wn.Dots,gap:n=20,size:o,lineWidth:s=1,offset:a=0,color:i,bgColor:l,style:c,className:d,patternClassName:f}){const p=ne(null),{transform:m,patternId:h}=$e(rq,Be),g=o||nq[t],b=t===wn.Dots,x=t===wn.Cross,y=Array.isArray(n)?n:[n,n],w=[y[0]*m[2]||1,y[1]*m[2]||1],v=g*m[2],N=Array.isArray(a)?a:[a,a],k=x?[v,v]:w,S=[N[0]*m[2]||1+k[0]/2,N[1]*m[2]||1+k[1]/2],M=`${h}${e||""}`;return u("svg",{className:Qe(["react-flow__background",d]),style:{...c,...Oa,"--xy-background-color-props":l,"--xy-background-pattern-color-props":i},ref:p,"data-testid":"rf__background",children:[r("pattern",{id:M,x:m[0]%w[0],y:m[1]%w[1],width:w[0],height:w[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${S[0]},-${S[1]})`,children:b?r(tq,{radius:v/2,className:f}):r(eq,{dimensions:k,lineWidth:s,variant:t,className:f})}),r("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}Kv.displayName="Background";const oq=Fe(Kv);function sq(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:r("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function aq(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:r("path",{d:"M0 0h32v4.2H0z"})})}function iq(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:r("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function lq(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function cq(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function ms({children:e,className:t,...n}){return r("button",{type:"button",className:Qe(["react-flow__controls-button",t]),...n,children:e})}const dq=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Gv({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:s,onZoomIn:a,onZoomOut:i,onFitView:l,onInteractiveChange:c,className:d,children:f,position:p="bottom-left",orientation:m="vertical","aria-label":h}){const g=je(),{isInteractive:b,minZoomReached:x,maxZoomReached:y,ariaLabelConfig:w}=$e(dq,Be),{zoomIn:v,zoomOut:N,fitView:k}=Nd(),S=()=>{v(),a?.()},M=()=>{N(),i?.()},P=()=>{k(s),l?.()},A=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),c?.(!b)};return u(Ra,{className:Qe(["react-flow__controls",m==="horizontal"?"horizontal":"vertical",d]),position:p,style:e,"data-testid":"rf__controls","aria-label":h??w["controls.ariaLabel"],children:[t&&u(ge,{children:[r(ms,{onClick:S,className:"react-flow__controls-zoomin",title:w["controls.zoomIn.ariaLabel"],"aria-label":w["controls.zoomIn.ariaLabel"],disabled:y,children:r(sq,{})}),r(ms,{onClick:M,className:"react-flow__controls-zoomout",title:w["controls.zoomOut.ariaLabel"],"aria-label":w["controls.zoomOut.ariaLabel"],disabled:x,children:r(aq,{})})]}),n&&r(ms,{className:"react-flow__controls-fitview",onClick:P,title:w["controls.fitView.ariaLabel"],"aria-label":w["controls.fitView.ariaLabel"],children:r(iq,{})}),o&&r(ms,{className:"react-flow__controls-interactive",onClick:A,title:w["controls.interactive.ariaLabel"],"aria-label":w["controls.interactive.ariaLabel"],children:b?r(cq,{}):r(lq,{})}),f]})}Gv.displayName="Controls";const uq=Fe(Gv);function pq({id:e,x:t,y:n,width:o,height:s,style:a,color:i,strokeColor:l,strokeWidth:c,className:d,borderRadius:f,shapeRendering:p,selected:m,onClick:h}){const{background:g,backgroundColor:b}=a||{},x=i||g||b;return r("rect",{className:Qe(["react-flow__minimap-node",{selected:m},d]),x:t,y:n,rx:f,ry:f,width:o,height:s,style:{fill:x,stroke:l,strokeWidth:c},shapeRendering:p,onClick:h?y=>h(y,e):void 0})}const fq=Fe(pq),mq=e=>e.nodes.map(t=>t.id),_i=e=>e instanceof Function?e:()=>e;function hq({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:s,nodeComponent:a=fq,onClick:i}){const l=$e(mq,Be),c=_i(t),d=_i(e),f=_i(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return r(ge,{children:l.map(m=>r(bq,{id:m,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:f,nodeBorderRadius:o,nodeStrokeWidth:s,NodeComponent:a,onClick:i,shapeRendering:p},m))})}function gq({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:s,nodeStrokeWidth:a,shapeRendering:i,NodeComponent:l,onClick:c}){const{node:d,x:f,y:p,width:m,height:h}=$e(g=>{const b=g.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const x=b.internals.userNode,{x:y,y:w}=b.internals.positionAbsolute,{width:v,height:N}=mn(x);return{node:x,x:y,y:w,width:v,height:N}},Be);return!d||d.hidden||!W0(d)?null:r(l,{x:f,y:p,width:m,height:h,style:d.style,selected:!!d.selected,className:o(d),color:t(d),borderRadius:s,strokeColor:n(d),strokeWidth:a,shapeRendering:i,onClick:c,id:d.id})}const bq=Fe(gq);var xq=Fe(hq);const yq=200,vq=150,wq=e=>!e.hidden,Nq=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?G0(Oo(e.nodeLookup,{filter:wq}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},kq="react-flow__minimap-desc";function Wv({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:s="",nodeBorderRadius:a=5,nodeStrokeWidth:i,nodeComponent:l,bgColor:c,maskColor:d,maskStrokeColor:f,maskStrokeWidth:p,position:m="bottom-right",onClick:h,onNodeClick:g,pannable:b=!1,zoomable:x=!1,ariaLabel:y,inversePan:w,zoomStep:v=1,offsetScale:N=5}){const k=je(),S=ne(null),{boundingRect:M,viewBB:P,rfId:A,panZoom:z,translateExtent:D,flowWidth:T,flowHeight:O,ariaLabelConfig:I}=$e(Nq,Be),L=e?.width??yq,_=e?.height??vq,R=M.width/L,B=M.height/_,F=Math.max(R,B),j=F*L,H=F*_,E=N*F,Q=M.x-(j-M.width)/2-E,K=M.y-(H-M.height)/2-E,Y=j+E*2,re=H+E*2,te=`${kq}-${A}`,X=ne(0),oe=ne();X.current=F,Z(()=>{if(S.current&&z)return oe.current=Tj({domNode:S.current,panZoom:z,getTransform:()=>k.getState().transform,getViewScale:()=>X.current}),()=>{oe.current?.destroy()}},[z]),Z(()=>{oe.current?.update({translateExtent:D,width:T,height:O,inversePan:w,pannable:b,zoomStep:v,zoomable:x})},[b,x,w,v,D,T,O]);const be=h?ee=>{const[ae,fe]=oe.current?.pointer(ee)||[0,0];h(ee,{x:ae,y:fe})}:void 0,J=g?q((ee,ae)=>{const fe=k.getState().nodeLookup.get(ae).internals.userNode;g(ee,fe)},[]):void 0,G=y??I["minimap.ariaLabel"];return r(Ra,{position:m,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*F:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof i=="number"?i:void 0},className:Qe(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:u("svg",{width:L,height:_,viewBox:`${Q} ${K} ${Y} ${re}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":te,ref:S,onClick:be,children:[G&&r("title",{id:te,children:G}),r(xq,{onClick:J,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:s,nodeStrokeWidth:i,nodeComponent:l}),r("path",{className:"react-flow__minimap-mask",d:`M${Q-E},${K-E}h${Y+E*2}v${re+E*2}h${-Y-E*2}z
|
|
1103
|
-
M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Wv.displayName="MiniMap";Fe(Wv);const Sq=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Cq={[Ir.Line]:"right",[Ir.Handle]:"bottom-right"};function Mq({nodeId:e,position:t,variant:n=Ir.Handle,className:o,style:s=void 0,children:a,color:i,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:m,autoScale:h=!0,shouldResize:g,onResizeStart:b,onResize:x,onResizeEnd:y}){const w=Iv(),v=typeof e=="string"?e:w,N=je(),k=ne(null),S=n===Ir.Handle,M=$e(q(Sq(S&&h),[S,h]),Be),P=ne(null),A=t??Cq[n];Z(()=>{if(!(!k.current||!v))return P.current||(P.current=Wj({domNode:k.current,nodeId:v,getStoreItems:()=>{const{nodeLookup:D,transform:T,snapGrid:O,snapToGrid:I,nodeOrigin:L,domNode:_}=N.getState();return{nodeLookup:D,transform:T,snapGrid:O,snapToGrid:I,nodeOrigin:L,paneDomNode:_}},onChange:(D,T)=>{const{triggerNodeChanges:O,nodeLookup:I,parentLookup:L,nodeOrigin:_}=N.getState(),R=[],B={x:D.x,y:D.y},F=I.get(v);if(F&&F.expandParent&&F.parentId){const j=F.origin??_,H=D.width??F.measured.width??0,E=D.height??F.measured.height??0,Q={id:F.id,parentId:F.parentId,rect:{width:H,height:E,...Y0({x:D.x??F.position.x,y:D.y??F.position.y},{width:H,height:E},F.parentId,I,j)}},K=wd([Q],I,L,_);R.push(...K),B.x=D.x?Math.max(j[0]*H,D.x):void 0,B.y=D.y?Math.max(j[1]*E,D.y):void 0}if(B.x!==void 0&&B.y!==void 0){const j={id:v,type:"position",position:{...B}};R.push(j)}if(D.width!==void 0&&D.height!==void 0){const H={id:v,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:D.width,height:D.height}};R.push(H)}for(const j of T){const H={...j,type:"position"};R.push(H)}O(R)},onEnd:({width:D,height:T})=>{const O={id:v,type:"dimensions",resizing:!1,dimensions:{width:D,height:T}};N.getState().triggerNodeChanges([O])}})),P.current.update({controlPosition:A,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:f},keepAspectRatio:p,resizeDirection:m,onResizeStart:b,onResize:x,onResizeEnd:y,shouldResize:g}),()=>{P.current?.destroy()}},[A,l,c,d,f,p,b,x,y,g]);const z=A.split("-");return r("div",{className:Qe(["react-flow__resize-control","nodrag",...z,n,o]),ref:k,style:{...s,scale:M,...i&&{[S?"backgroundColor":"borderColor"]:i}},children:a})}Fe(Mq);function Iq({data:e,selected:t}){const n=e.isOnline,o=e.isHub,s=e.engines??[],a=e.addons??[],i=e.processes??[],l=e.name,c=e.hostname,d=e.localIps??[],f=e.cpuPercent,p=e.memoryPercent,m=e.isExpanded,h=e.onToggleExpand,g=e.onShowNodeLogs,b=e.onRestartNode,x=e.id,y=i.length,w=q(M=>{M.stopPropagation(),h?.()},[h]),v=q(M=>{M.stopPropagation(),g?.()},[g]),N=q(M=>{M.stopPropagation(),b?.()},[b]);return u("div",{className:`rounded-xl bg-surface px-3 py-2.5 min-w-[180px] max-w-[260px] transition-all duration-200 ${n?o?"border-2 border-success":"border-2 border-dashed border-primary/60 bg-primary/5":"border-2 border-dashed border-muted-foreground/30 opacity-50"} ${t?"ring-2 ring-primary ring-offset-1":""}`,children:[r(Sn,{type:"target",position:we.Top,className:"!bg-border !w-2 !h-2"}),u("div",{className:"flex items-center gap-1.5 mb-1.5",children:[r("div",{className:`w-2 h-2 rounded-full ${n?"bg-success":"bg-destructive"}`}),r("span",{className:"text-xs font-semibold truncate flex-1",children:l}),o?r("span",{className:"text-[8px] px-1 py-0.5 rounded bg-primary/10 text-primary font-medium",children:"HUB"}):r("span",{className:"text-[8px] px-1 py-0.5 rounded bg-muted text-muted-foreground font-medium",children:"AGENT"})]}),(c||d.length>0)&&(()=>{const M=d.filter(P=>!P.includes(":"));return u("div",{className:"text-[9px] text-muted-foreground mb-1 space-y-0.5",title:[c,...d].filter(Boolean).join(", "),children:[c&&r("div",{className:"truncate",children:c}),M.length>0&&r("div",{className:"truncate font-mono opacity-70",children:M.join(", ")})]})})(),s.length>0&&r("div",{className:"flex flex-wrap gap-1 mb-1.5",children:s.map(M=>r("span",{className:"text-[8px] px-1 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:M},M))}),a.length>0&&u("div",{className:"text-[9px] text-muted-foreground mb-1",children:[a.length," addon",a.length!==1?"s":""," in-process"]}),n&&u("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground",children:[u("span",{className:"flex items-center gap-0.5",children:[r(dt,{className:"h-2.5 w-2.5"}),f,"%"]}),u("span",{className:"flex items-center gap-0.5",children:[r(Jc,{className:"h-2.5 w-2.5"}),p,"%"]}),u("div",{className:"flex items-center gap-1 ml-auto",children:[y>0&&u("button",{onClick:w,className:"flex items-center gap-0.5 px-1 py-0.5 rounded hover:bg-amber-500/10 text-amber-500 transition-colors",title:m?"Collapse processes":`Expand ${y} process${y!==1?"es":""}`,children:[m?r(vt,{className:"h-3 w-3"}):r(It,{className:"h-3 w-3"}),r("span",{className:"text-[9px] font-medium",children:y})]}),r("button",{onClick:v,className:"p-0.5 rounded hover:bg-primary/10 text-muted-foreground hover:text-primary transition-colors",title:`Logs: ${x}`,children:r(Xe,{className:"h-3 w-3"})}),r("button",{onClick:N,className:"p-0.5 rounded hover:bg-primary/10 text-muted-foreground hover:text-primary transition-colors",title:"Restart all processes",children:r(gt,{className:"h-3 w-3"})})]})]}),!n&&r("div",{className:"text-[10px] text-muted-foreground",children:"offline"}),r(Sn,{type:"source",position:we.Bottom,className:"!bg-border !w-2 !h-2"})]})}const Aq=Fe(Iq);function Pq(e){return e===0?"0":e<1024*1024?`${Math.round(e/1024)}K`:e<1024*1024*1024?`${Math.round(e/(1024*1024))}M`:`${(e/(1024*1024*1024)).toFixed(1)}G`}function Eq({data:e}){const t=e.name,n=e.state,o=e.pid,s=e.cpuPercent,a=e.memoryRss,i=e.addonId,l=e.services??[],c=e.isExpanded,d=e.onToggleServices,f=e.parentNodeId,p=e.onShowLogs,m=e.onRestartAddon,h=n==="running",g=t.includes("(core)"),b=!g&&l.length===1,x=b?l[0]:null,y=f??"hub",w=`${y}/${t}`,v=q(M=>{M.stopPropagation(),d?.()},[d]),N=g?ln:ga,k=g?"border-primary/50":h?"border-amber-500/50":"border-destructive/50",S=g?"text-primary":"text-amber-500";return u("div",{className:`rounded-lg bg-surface min-w-[150px] border ${k} ${c?"max-w-[240px]":"max-w-[210px]"}`,children:[r(Sn,{type:"target",position:we.Top,className:`!w-1.5 !h-1.5 ${g?"!bg-primary":"!bg-amber-500"}`}),u("div",{className:"px-2.5 pt-2 pb-1.5",children:[u("div",{className:"flex items-start gap-1.5 mb-1.5",children:[r(N,{className:`h-3 w-3 ${S} shrink-0 mt-0.5`}),r("span",{className:"text-[10px] font-semibold truncate flex-1",children:g?"core":i??t}),r("span",{className:"text-[8px] text-muted-foreground/60 tabular-nums shrink-0",children:o})]}),u("div",{className:"flex items-center gap-2 text-[9px] text-muted-foreground",children:[r("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${h?"bg-success":"bg-destructive"}`}),u("span",{className:"flex items-center gap-0.5",children:[r(dt,{className:"h-2 w-2"}),s,"%"]}),u("span",{className:"flex items-center gap-0.5",children:[r(Jc,{className:"h-2 w-2"}),Pq(a)]}),b&&x?u("div",{className:"flex items-center gap-0.5 ml-auto",children:[r("button",{onClick:M=>{M.stopPropagation(),p?.(x.addonId,y)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Logs: ${x.addonId}`,children:r(Xe,{className:"h-2.5 w-2.5"})}),r("button",{onClick:M=>{M.stopPropagation(),m?.(x.addonId,w)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Restart: ${x.addonId}`,children:r(gt,{className:"h-2.5 w-2.5"})})]}):l.length>0?u("button",{onClick:v,className:"flex items-center gap-0.5 ml-auto px-0.5 rounded hover:bg-blue-500/10 text-blue-400 transition-colors",title:c?"Hide addons":`Show ${l.length} addon${l.length!==1?"s":""}`,children:[c?r(vt,{className:"h-2.5 w-2.5"}):r(It,{className:"h-2.5 w-2.5"}),r("span",{className:"text-[8px] font-medium",children:l.length})]}):null]})]}),c&&l.length>0&&!b&&r("div",{className:"border-t border-border/40 px-2 py-1 space-y-0.5 max-h-[200px] overflow-y-auto",children:l.map(M=>{const P=g?y:`${y}/${t}`;return u("div",{className:"flex items-center gap-1 py-0.5",children:[r("div",{className:`w-1 h-1 rounded-full shrink-0 ${M.status==="running"?"bg-success":"bg-muted-foreground/30"}`}),r("span",{className:"text-[9px] truncate flex-1",children:M.addonId}),r("button",{onClick:A=>{A.stopPropagation(),p?.(M.addonId,y)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Logs: ${M.addonId}`,children:r(Xe,{className:"h-2.5 w-2.5"})}),r("button",{onClick:A=>{A.stopPropagation(),m?.(M.addonId,P)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Restart: ${M.addonId}`,children:r(gt,{className:"h-2.5 w-2.5"})})]},M.addonId)})}),r(Sn,{type:"source",position:we.Bottom,className:`!w-1.5 !h-1.5 ${g?"!bg-primary":"!bg-amber-500"}`})]})}const $q=Fe(Eq),_q={clusterNode:Aq,processNode:$q},Af=280,Pf=40,Ef=280,$f=200,Dq=150;function Lq({topology:e}){const{resolvedMode:t}=Ar(),n=rb(),o=aa(),[,s]=$(null),[a,i]=$(()=>e.length<=1?new Set(e.map(M=>M.id)):new Set),[l,c]=$(null),[d,f]=$(null),p=q((M,P)=>{f(A=>A?.addonId===M&&A?.agentId===P?null:{addonId:M,agentId:P})},[]),m=q(M=>{f(P=>P?.agentId===M&&!P?.addonId?null:{agentId:M})},[]),h=q(async M=>{try{await n.mutateAsync({nodeId:M})}catch(P){console.error("Failed to restart node:",P)}},[n]),g=q(async(M,P)=>{try{await o.mutateAsync({nodeId:P,addonId:M})}catch(A){console.error("Failed to restart addon:",A)}},[o]),b=q(M=>{i(P=>{const A=new Set(P);return A.has(M)?A.delete(M):A.add(M),A})},[]),x=q(M=>{c(P=>P===M?null:M)},[]),y=q(M=>{s(M)},[]),w=U(()=>{const M=e.filter(L=>L.isHub),P=e.filter(L=>!L.isHub),A=[],z=[],D=M[0]?.id,T=D?a.has(D):!1;function O(L,_,R,B){const F=[...B];if(F.length===0)return;const j=(F.length-1)*$f,H=_-j/2,E=R+Dq;for(let Q=0;Q<F.length;Q++){const K=F[Q],Y=`proc:${L}/${K.name}`,re=K.services??[],te=l===Y;A.push({id:Y,type:"processNode",position:{x:H+Q*$f,y:E},data:{...K,addonId:K.name.includes("(core)")?void 0:re.length>1?K.name:re[0]?.addonId??K.name,parentNodeId:L,services:re,isExpanded:te,onToggleServices:()=>x(Y),onShowLogs:p,onRestartAddon:g}}),z.push({id:`edge:${L}-${Y}`,source:L,target:Y,animated:!0,style:{stroke:"var(--amber-500, #f59e0b)",strokeWidth:1,strokeDasharray:"4 4"}})}}for(const L of M){const _=Math.max(0,(P.length-1)*Af)/2;A.push({id:L.id,type:"clusterNode",position:{x:_,y:Pf},data:{...L,label:L.name,isExpanded:a.has(L.id),onToggleExpand:()=>b(L.id),onShowDetail:()=>y(L.id),onShowNodeLogs:()=>m(L.id),onRestartNode:()=>h(L.id)}}),a.has(L.id)&&O(L.id,_,Pf,L.processes??[])}const I=T?Ef+120:Ef;for(let L=0;L<P.length;L++){const _=P[L],R=L*Af;A.push({id:_.id,type:"clusterNode",position:{x:R,y:I},data:{..._,label:_.name,isExpanded:a.has(_.id),onToggleExpand:()=>b(_.id),onShowDetail:()=>y(_.id),onShowNodeLogs:()=>m(_.id),onRestartNode:()=>h(_.id)}}),D&&_.isOnline&&z.push({id:`${D}-${_.id}`,source:D,target:_.id,animated:!0,style:{stroke:"var(--border)",strokeWidth:1.5}}),a.has(_.id)&&O(_.id,R,I,_.processes??[])}return{nodes:A,edges:z}},[e,a,l,b,x,y,p,m,h,g]),v=ne(new Map),N=U(()=>{const M=v.current;return w.nodes.map(A=>({...A,position:M.get(A.id)??A.position}))},[w.nodes]),k=q(M=>{for(const P of M)P.type==="position"&&P.position&&v.current.set(P.id,P.position)},[]),S=q(()=>s(null),[]);return r("div",{className:"flex flex-col gap-4 flex-1",children:u("div",{className:"relative flex-1 min-h-[350px] border border-border rounded-xl overflow-hidden",children:[u(JV,{nodes:N,edges:w.edges,onNodesChange:k,onPaneClick:S,nodeTypes:_q,nodesConnectable:!1,fitView:!0,fitViewOptions:{padding:.2,maxZoom:1.2},proOptions:{hideAttribution:!0},className:"bg-background",colorMode:t,children:[r(oq,{gap:20,size:1}),r(uq,{showInteractive:!1})]}),d&&r(Ax,{addonId:d.addonId,agentId:d.agentId,showScope:!0,onClose:()=>f(null)})]})})}function Tq({onlineNodeIds:e}){const t=ke(),n=nt(),{data:o,isLoading:s}=_r(),a=Ib({onSuccess:()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","listAgentSettings"]]})}}),i=U(()=>{if(!o)return[];const c=new Set(e);return c.add("hub"),o.filter(d=>!c.has(d.nodeId))},[o,e]);if(s)return r("section",{className:"rounded-lg border border-border bg-surface p-6 text-xs text-muted-foreground animate-pulse",children:"Loading persisted agent settings…"});const l=async c=>{await n({title:"Remove offline agent?",message:`Drop the persisted orchestrator settings for "${c}". This won't affect a node that comes back online — it just clears stale addonDefaults so it stops cluttering the cluster view.`,confirmLabel:"Remove",cancelLabel:"Keep",variant:"danger"})&&a.mutate({agentNodeId:c})};return i.length===0?r("section",{className:"rounded-lg border border-border bg-surface p-6",children:u("div",{className:"flex flex-col items-center gap-2 text-center text-muted-foreground",children:[r(nl,{className:"h-6 w-6 opacity-40"}),r("p",{className:"text-xs",children:"No stale agent entries."}),r("p",{className:"text-[11px] opacity-60",children:"Every persisted nodeId matches a node currently online in the cluster."})]})}):u("section",{className:"rounded-lg border border-border bg-surface",children:[u("header",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[r(nl,{className:"h-4 w-4 text-muted-foreground"}),r("h2",{className:"text-sm font-semibold",children:"Offline agents"}),u("span",{className:"ml-auto text-[11px] text-muted-foreground",children:[i.length," stale ",i.length===1?"entry":"entries"]})]}),r("p",{className:"px-4 pt-3 text-[11px] text-muted-foreground",children:"Persisted orchestrator settings for nodes not currently in the live topology. Remove entries you don't expect to come back — leftover from data-dir resets, env-driven nodeId changes, or decommissioned hosts."}),r("ul",{className:"divide-y divide-border",children:i.map(c=>{const d=Object.keys(c.settings.addonDefaults??{}).length,f=Object.values(c.settings.addonDefaults??{}).filter(p=>p?.enabled).length;return u("li",{className:"flex items-center gap-3 px-4 py-2 text-xs",children:[r("span",{className:"font-mono text-foreground",children:c.nodeId}),u("span",{className:"text-muted-foreground",children:[d," addons configured",d>0&&u(ge,{children:[" · ",f," enabled"]})]}),u("button",{type:"button",onClick:()=>{l(c.nodeId)},disabled:a.isPending,className:"ml-auto flex items-center gap-1 px-2 py-1 rounded text-destructive hover:bg-destructive/10 disabled:opacity-50",children:[r(Ge,{className:"h-3 w-3"}),"Remove"]})]},c.nodeId)})})]})}function Rq(e){const[t,n]=$(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return Z(()=>{const o=window.matchMedia(e),s=a=>n(a.matches);return o.addEventListener("change",s),()=>o.removeEventListener("change",s)},[e]),t}function Oq(){const{data:e,isLoading:t}=An(void 0,{staleTime:1/0}),[n,o]=$(null);return ct("cluster.topology-snapshot",a=>{const i=a.data?.nodes;Array.isArray(i)&&o(i)}),{nodes:U(()=>n??e??[],[n,e]),isLoading:t&&!n}}function zq(){const[e,t]=$("diagram"),n=Rq("(max-width: 767px)"),o=n&&e==="diagram"?"table":e,{nodes:s,isLoading:a}=Oq(),i=s.filter(m=>m.isOnline).length,l=s.filter(m=>!m.isOnline).length,c=U(()=>s.map(m=>m.id??"").filter(Boolean),[s]),{data:d}=_r(),f=U(()=>{if(!d)return 0;const m=new Set(c);return m.add("hub"),d.filter(h=>!m.has(h.nodeId)).length},[d,c]),p=(m,h,g,b)=>u("button",{onClick:()=>t(m),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${e===m?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:[r(g,{className:"h-3.5 w-3.5"}),h,b!==void 0&&b>0&&r("span",{className:`ml-1 inline-flex h-4 min-w-[1rem] items-center justify-center rounded-full px-1 text-[10px] font-semibold ${e===m?"bg-primary-foreground/20 text-primary-foreground":"bg-destructive/15 text-destructive"}`,children:b})]});return u("div",{className:"flex flex-col h-full gap-4 p-4",children:[u("div",{className:"flex items-center justify-between",children:[u("div",{className:"flex items-center gap-3",children:[r("h1",{className:"text-xl font-semibold",children:"Cluster"}),i>0&&u("span",{className:"text-xs px-2 py-0.5 rounded-full bg-success/10 text-success",children:[i," online"]}),l>0&&u("span",{className:"text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:[l," offline"]})]}),u("div",{className:"flex gap-0.5 p-1 rounded-lg bg-muted",children:[!n&&p("diagram","Diagram",an),p("table","Table",gT),p("offline-agents","Offline agents",nl,f)]})]}),a?r("div",{className:"flex items-center justify-center flex-1 text-muted-foreground",children:"Loading cluster topology..."}):o==="diagram"?r(Lq,{topology:s}):o==="table"?r("div",{className:"flex-1 overflow-auto",children:r(b7,{nodes:s})}):r("div",{className:"flex-1 overflow-auto",children:r(Tq,{onlineNodeIds:c})})]})}function en({title:e,children:t}){return u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r("div",{className:"border-b border-border px-4 py-2.5",children:r("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:e})}),r("div",{className:"p-4",children:t})]})}function et({name:e,cssVar:t,hex:n}){const o=t?`var(${t})`:n;return u("div",{className:"flex flex-col items-center gap-1.5",children:[r("div",{className:"h-10 w-10 rounded-lg border border-border shadow-inner",style:{backgroundColor:o}}),r("span",{className:"text-[10px] text-foreground-subtle text-center leading-tight",children:e})]})}const Bq={sections:[{id:"demo",title:"Demo Fields",columns:2,fields:[{key:"name",type:"text",label:"Name",placeholder:"Enter name"},{key:"count",type:"number",label:"Count",min:0,max:100,unit:"items"},{key:"enabled",type:"boolean",label:"Enabled"},{key:"mode",type:"select",label:"Mode",options:[{value:"a",label:"Alpha"},{value:"b",label:"Beta"}]},{key:"tags",type:"tags",label:"Tags",span:2,suggestions:["camera","zone","alert"]},{key:"confidence",type:"slider",label:"Confidence",min:0,max:100,step:5,unit:"%",span:2},{key:"info",type:"info",label:"Note",content:"This is an informational message for the user.",variant:"info"}]}]};function Fq(){const[e,t]=$({name:"Example",count:10,enabled:!0,mode:"a",tags:["camera"],confidence:60});return u("div",{className:"p-6 space-y-6 max-w-5xl mx-auto",children:[u("div",{className:"mb-6",children:[r("h1",{className:"text-xl font-bold text-foreground",children:"Component Showroom"}),r("p",{className:"text-sm text-foreground-subtle mt-1",children:"All UI components at a glance"})]}),r(en,{title:"Typography",children:u("div",{className:"space-y-3",children:[r("h1",{className:"text-2xl font-bold text-foreground",children:"Heading 1 — Display title"}),r("h2",{className:"text-xl font-semibold text-foreground",children:"Heading 2 — Section title"}),r("h3",{className:"text-base font-semibold text-foreground",children:"Heading 3 — Card title"}),r("h4",{className:"text-sm font-semibold text-foreground",children:"Heading 4 — Sub-section"}),r("p",{className:"text-sm text-foreground",children:"Body text — Regular paragraph content goes here. It uses the foreground color."}),r("p",{className:"text-sm text-foreground-subtle",children:"Subtle text — Secondary/descriptive text with reduced emphasis."}),r("p",{className:"text-xs text-foreground-subtle uppercase tracking-wider font-semibold",children:"Label / Caption"}),r("p",{className:"text-xs text-foreground-disabled",children:"Disabled / placeholder text"})]})}),r(en,{title:"Colors",children:u("div",{className:"flex flex-wrap gap-4",children:[r(et,{name:"primary",cssVar:"--color-primary"}),r(et,{name:"background",cssVar:"--color-background"}),r(et,{name:"surface",cssVar:"--color-surface"}),r(et,{name:"foreground",cssVar:"--color-foreground"}),r(et,{name:"success",cssVar:"--color-success"}),r(et,{name:"warning",cssVar:"--color-warning"}),r(et,{name:"danger",cssVar:"--color-danger"}),r(et,{name:"info",cssVar:"--color-info"}),r(et,{name:"border",cssVar:"--color-border"}),r("div",{className:"w-px"}),r(et,{name:"frigate",hex:"#3b82f6"}),r(et,{name:"scrypted",hex:"#a855f7"}),r(et,{name:"reolink",hex:"#06b6d4"}),r(et,{name:"ha",hex:"#22d3ee"}),r(et,{name:"rtsp",hex:"#78716c"})]})}),r(en,{title:"Buttons",children:u("div",{className:"flex flex-wrap gap-3",children:[r("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity",children:"Primary"}),r("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-4 py-2 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors",children:"Secondary"}),r("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-danger/40 bg-danger/10 px-4 py-2 text-sm font-medium text-danger hover:bg-danger/20 transition-colors",children:"Danger"}),r("button",{disabled:!0,className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white opacity-40 cursor-not-allowed",children:"Disabled"}),r("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-4 py-2 text-sm font-medium text-warning hover:bg-warning/20 transition-colors",children:"Warning"}),r("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-success/40 bg-success/10 px-4 py-2 text-sm font-medium text-success hover:bg-success/20 transition-colors",children:"Success"})]})}),r(en,{title:"Inputs",children:u("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Text input"}),r("input",{type:"text",className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30",placeholder:"Type something..."})]}),u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Number input"}),r("input",{type:"number",className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30",placeholder:"0"})]}),u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Password input"}),r("input",{type:"password",className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30",placeholder:"••••••••"})]}),u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Select"}),u("select",{className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30",children:[r("option",{children:"Option A"}),r("option",{children:"Option B"}),r("option",{children:"Option C"})]})]}),u("div",{className:"md:col-span-2",children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Textarea"}),r("textarea",{className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 resize-y min-h-[60px]",placeholder:"Enter multi-line text...",rows:3})]}),r("div",{children:u("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[r("input",{type:"checkbox",className:"h-3.5 w-3.5 rounded border-border accent-primary",defaultChecked:!0}),r("span",{className:"text-xs font-medium text-foreground",children:"Checkbox (checked)"})]})}),r("div",{children:u("div",{className:"flex items-center justify-between",children:[r("span",{className:"text-xs font-medium text-foreground",children:"Toggle switch"}),r(jq,{})]})}),u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Slider"}),r("input",{type:"range",className:"w-full h-1 accent-primary cursor-pointer",min:0,max:100,defaultValue:60})]}),u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Tags example"}),r("div",{className:"flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px]",children:["camera","zone","alert"].map(n=>r("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:n},n))})]})]})}),r(en,{title:"Badges",children:u("div",{className:"space-y-3",children:[u("div",{children:[r("p",{className:"text-xs text-foreground-subtle mb-2",children:"StatusBadge"}),r("div",{className:"flex flex-wrap gap-2",children:["running","stopped","error","online","offline","idle"].map(n=>r(ka,{status:n},n))})]}),u("div",{children:[r("p",{className:"text-xs text-foreground-subtle mb-2",children:"CapabilityBadges"}),r(wa,{capabilities:["streaming","detection","recording","audio"]})]})]})}),r(en,{title:"Cards",children:u("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[u("div",{className:"rounded-lg bg-surface p-4",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Surface card"}),r("p",{className:"text-xs text-foreground-subtle",children:"Uses `bg-surface`. Default card background."})]}),u("div",{className:"rounded-lg border border-border bg-surface p-4",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Bordered card"}),r("p",{className:"text-xs text-foreground-subtle",children:"Uses `border border-border bg-surface`."})]}),u("div",{className:"rounded-lg border border-primary/30 bg-primary/5 p-4",children:[r("h3",{className:"text-sm font-semibold text-primary mb-1",children:"Accent card"}),r("p",{className:"text-xs text-foreground-subtle",children:"Highlighted with primary color."})]}),u("div",{className:"rounded-lg bg-background p-4",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Background card"}),r("p",{className:"text-xs text-foreground-subtle",children:"Uses `bg-background`. Inset card."})]})]})}),r(en,{title:"Provider Icons",children:r("div",{className:"flex flex-wrap gap-4",children:["frigate","scrypted","reolink","homeassistant","rtsp","onvif"].map(n=>r(cn,{type:n,size:"lg",showLabel:!0},n))})}),u(en,{title:"Form Builder Demo",children:[r(kn,{schema:Bq,values:e,onChange:t}),u("details",{className:"mt-3",children:[r("summary",{className:"text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground",children:"View current values"}),r("pre",{className:"mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto",children:JSON.stringify(e,null,2)})]})]}),r(en,{title:"Info Boxes",children:r("div",{className:"space-y-2",children:[{variant:"info",label:"Info",content:"This is an informational message. Use it for tips and hints."},{variant:"warning",label:"Warning",content:"This action may have side effects. Proceed with caution."},{variant:"success",label:"Success",content:"Operation completed successfully. All systems are green."},{variant:"danger",label:"Danger",content:"This operation is irreversible. Data will be permanently deleted."}].map(({variant:n,label:o,content:s})=>{const i={info:{border:"border-info",bg:"bg-info/5",text:"text-info"},warning:{border:"border-warning",bg:"bg-warning/5",text:"text-warning"},success:{border:"border-success",bg:"bg-success/5",text:"text-success"},danger:{border:"border-danger",bg:"bg-danger/5",text:"text-danger"}}[n];return u("div",{className:`rounded-md border-l-4 px-3 py-2.5 ${i.border} ${i.bg}`,children:[r("p",{className:`text-xs font-semibold mb-0.5 ${i.text}`,children:o}),r("p",{className:"text-xs text-foreground-subtle leading-relaxed",children:s})]},n)})})})]})}function jq(){const[e,t]=$(!0);return r("button",{type:"button",role:"switch","aria-checked":e,onClick:()=>t(n=>!n),className:["relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150 cursor-pointer",e?"bg-primary":"bg-foreground-subtle/30"].join(" "),children:r("span",{className:["inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150",e?"translate-x-4":"translate-x-0.5"].join(" ")})})}const _f={info:{bg:"bg-blue-500/10",border:"border-blue-500/30",icon:Bn},warning:{bg:"bg-orange-500/10",border:"border-orange-500/30",icon:bt},critical:{bg:"bg-red-500/10",border:"border-red-500/30",icon:xa}};function Hq({toast:e,onDismiss:t}){const n=_f[e.severity]??_f.info,o=n.icon;return Z(()=>{const s=e.duration??5e3;if(s<=0)return;const a=setTimeout(()=>t(e.id),s);return()=>clearTimeout(a)},[e.id,e.duration,t]),u("div",{className:`flex items-start gap-3 px-4 py-3 rounded-lg border ${n.border} ${n.bg} shadow-lg backdrop-blur-sm animate-in slide-in-from-right-5 fade-in duration-200`,children:[r(o,{className:"h-4 w-4 shrink-0 mt-0.5 text-foreground-subtle"}),u("div",{className:"flex-1 min-w-0",children:[r("div",{className:"text-xs font-semibold text-foreground",children:e.title}),r("div",{className:"text-[11px] text-foreground-subtle mt-0.5",children:e.message})]}),r("button",{type:"button",onClick:()=>t(e.id),className:"shrink-0 p-0.5 rounded hover:bg-surface-hover transition-colors",children:r(Ve,{className:"h-3.5 w-3.5 text-foreground-subtle"})})]})}function Vq(){const[e,t]=$([]),n=q(o=>{t(s=>s.filter(a=>a.id!==o))},[]);return Jb(void 0,{onData:o=>{const s=o,a=`toast-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;t(i=>[...i,{...s,id:a,timestamp:Date.now()}])}}),e.length===0?null:r("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2 max-w-sm w-full pointer-events-none",children:e.map(o=>r("div",{className:"pointer-events-auto",children:r(Hq,{toast:o,onDismiss:n})},o.id))})}const Pl=new Bf({defaultOptions:{queries:{staleTime:3e4,retry:!1,refetchOnWindowFocus:!1}}});function qq({field:e,value:t,onChange:n,disabled:o}){return r(_T,{field:e,value:t,onChange:n,disabled:o})}function Uq({field:e,value:t,onChange:n,disabled:o}){return r(HT,{field:e,value:t,onChange:n,disabled:o})}const Qq={"zone-editor":W_,"live-stats":Z_,"pipeline-editor":qq,"model-selector":Uq,"live-stream-viewer":qT,"pipeline-stats":UT,"stream-network-stats":QT,"doorbell-recent":GT,"device-info":My};function Kq({children:e}){const{user:t}=fn(),[n,o]=$(0),s=ne(t?.username??null);Z(()=>{const p=t?.username??null;p!==s.current&&(s.current=p,Zr(),o(m=>m+1))},[t]);const a=U(()=>tl(),[n]),[i,l]=$(!1),[c,d]=$(null);Z(()=>{if(l(!1),d(null),!t){l(!0);return}let p=!1;return a.init().then(()=>{p||l(!0)},m=>{if(p)return;const h=m instanceof Error?m.message:String(m);d(h),l(!0)}),()=>{p=!0}},[a,t]);const f=q(()=>{Zr(),o(p=>p+1),Pl.invalidateQueries()},[]);return q_(f),r(ec,{system:a,children:r(C.Provider,{client:a.trpcClient,queryClient:Pl,children:u(fx,{children:[i?e:r(Gq,{}),c!==null&&i&&u("div",{className:"fixed bottom-4 right-4 z-50 max-w-sm rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning shadow-lg",children:["Boot probe failed: ",c,". Retrying in background."]})]})})})}function Gq(){return r("div",{className:"flex min-h-screen items-center justify-center bg-background",children:u("div",{className:"flex items-center gap-3 text-sm text-foreground-subtle",children:[r("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary"}),"Connecting…"]})})}function Wq(){return r(Cs,{defaultMode:"dark",children:r(Ff,{client:Pl,children:r(dR,{children:r(Kq,{children:r(Nh,{children:u(Hh,{renderers:Qq,children:[r(D_,{children:u(l_,{children:[r(_e,{path:"/login",element:r(f6,{})}),r(_e,{path:"/change-password",element:r(Ft,{children:r(h6,{})})}),r(_e,{path:"/access-denied",element:r(g6,{})}),r(_e,{path:"/showroom",element:r(Fq,{})}),u(_e,{element:r(Ft,{children:r(p6,{})}),children:[r(_e,{index:!0,element:r(ht,{to:"/dashboard",replace:!0})}),r(_e,{path:"/dashboard",element:r(I6,{})}),r(_e,{path:"/devices",element:r(A6,{})}),r(_e,{path:"/cameras",element:r(ht,{to:"/devices",replace:!0})}),r(_e,{path:"/integrations",element:r(B6,{})}),r(_e,{path:"/integrations/:integrationId",element:r(H6,{})}),r(_e,{path:"/timeline",element:r(X6,{})}),r(_e,{path:"/pipeline",element:r(DO,{})}),r(_e,{path:"/devices/:deviceId",element:r(E8,{})}),r(_e,{path:"/system/logs",element:r(Ft,{requiredRole:"admin",children:r(q8,{})})}),r(_e,{path:"/system/addons",element:r(Ft,{requiredRole:"admin",children:r(j8,{})})}),r(_e,{path:"/system/settings",element:r(Ft,{requiredRole:"admin",children:r(t7,{})})}),r(_e,{path:"/system/cluster",element:r(Ft,{requiredRole:"admin",children:r(zq,{})})}),r(_e,{path:"/system/identity",element:r(Ft,{requiredRole:"admin",children:r(r9,{})})}),r(_e,{path:"/system/my-access",element:r(V8,{})}),r(_e,{path:"/system/network",element:r(Ft,{requiredRole:"admin",children:r(f9,{})})}),r(_e,{path:"/system/data",element:r(Ft,{requiredRole:"admin",children:r(e7,{})})}),r(_e,{path:"/system/users",element:r(ht,{to:"/system/identity?tab=users",replace:!0})}),r(_e,{path:"/system/api-keys",element:r(ht,{to:"/system/identity?tab=api-keys",replace:!0})}),r(_e,{path:"/system/authentication",element:r(ht,{to:"/system/identity?tab=authentication",replace:!0})}),r(_e,{path:"/system/remote-access",element:r(ht,{to:"/system/network?tab=remote-access",replace:!0})}),r(_e,{path:"/system/turn",element:r(ht,{to:"/system/network?tab=turn",replace:!0})}),r(_e,{path:"/system/storage",element:r(ht,{to:"/system/data?tab=storage",replace:!0})}),r(_e,{path:"/system/backup",element:r(ht,{to:"/system/data?tab=backup",replace:!0})}),r(_e,{path:"/addon/:pagePath",element:r(Ft,{requiredRole:"admin",children:r(c6,{})})})]})]})}),r(Vq,{})]})})})})})})}const Yq={dashboard:"Dashboard",integrations:"Integrations",metrics:"Metrics"},Zq={title:"System",addons:"Addons",agents:"Agents",processes:"Processes",logs:"Logs",users:"Users",settings:"Settings",repl:"REPL",models:"Models"},Xq={save:"Save",cancel:"Cancel",delete:"Delete",enable:"Enable",disable:"Disable",edit:"Edit",add:"Add",remove:"Remove",confirm:"Confirm",close:"Close",back:"Back",next:"Next",search:"Search",filter:"Filter",reset:"Reset",apply:"Apply",submit:"Submit",loading:"Loading…",error:"Error",success:"Success",warning:"Warning",info:"Info",noData:"No data available",noResults:"No results found",retry:"Retry",refresh:"Refresh",copy:"Copy",copied:"Copied!",yes:"Yes",no:"No"},Jq={disconnected:"Server unreachable — reconnecting…",connected:"Connected"},eU={online:"Online",offline:"Offline",connecting:"Connecting",error:"Error",disabled:"Disabled",enabled:"Enabled",active:"Active",inactive:"Inactive",running:"Running",stopped:"Stopped",pending:"Pending",unknown:"Unknown"},tU={login:"Login",logout:"Logout",username:"Username",password:"Password",signIn:"Sign In",invalidCredentials:"Invalid username or password"},nU={dark:"Dark",light:"Light",system:"System"},rU={select:"Language",en:"English",it:"Italian"},oU={dashboard:{title:"Dashboard",subtitle:"Overview of all devices and their status"},integrations:{title:"Integrations",subtitle:"Manage camera sources and provider connections"},metrics:{title:"Metrics",subtitle:"System performance and usage statistics"},agents:{title:"Agents",subtitle:"Manage distributed processing agents"},addons:{title:"Addons",subtitle:"Extend functionality with addon modules"},settings:{title:"Settings",subtitle:"Configure system-wide preferences"},users:{title:"Users",subtitle:"Manage user accounts and permissions"},logs:{title:"Logs",subtitle:"View system and device logs"}},sU={preview:"Preview",snapshotUnavailable:"Snapshot unavailable",noSnapshot:"No snapshot",lastSnapshot:"Last snapshot:",offline:"Offline",active:"Active",available:"Available",noDevices:"No devices.",addFirstDevice:"Add your first device to get started.",import:"+ Import",noProviders:"No providers available. Install a provider addon.",manage:"Manage",integrationName:"Integration name",integrationNamePlaceholder:"e.g. Garage Server",connectionSuccess:"Connection successful!",errorPrefix:"Error:",back:"Back",testing:"Testing...",testConnection:"Test connection",forward:"Next",searchingDevices:"Searching for devices...",foundDevices:"Found {{count}} devices. Select the ones to import.",noDevicesFound:"No devices found.",skip:"Skip",importSelected:"Import selected",newIntegration:"New Integration",configureIntegration:"Configure Integration",importDevices:"Import Devices",addDevice:"Add device",name:"Name",namePlaceholder:"e.g. Entrance Camera",snapshotUrlOptional:"Snapshot URL (optional)",streamUrls:"Stream URLs",addStream:"Add stream",cancel:"Cancel",saving:"Saving...",save:"Save",saveAndNew:"Save and new",test:"Test",stream:"Stream {{number}}:",devices:"devices",rediscover:"Rediscover",config:"Config",integrationNotFound:"Integration not found.",configComingSoon:"Config coming soon.",providerConfig:"Provider Config"},aU={nav:Yq,system:Zq,common:Xq,connection:Jq,status:eU,auth:tU,theme:nU,language:rU,pages:oU,integrations:sU},iU={dashboard:"Dashboard",integrations:"Integrazioni",metrics:"Metriche"},lU={title:"Sistema",addons:"Addon",agents:"Agenti",processes:"Processi",logs:"Log",users:"Utenti",settings:"Impostazioni",repl:"REPL",models:"Modelli"},cU={save:"Salva",cancel:"Annulla",delete:"Elimina",enable:"Abilita",disable:"Disabilita",edit:"Modifica",add:"Aggiungi",remove:"Rimuovi",confirm:"Conferma",close:"Chiudi",back:"Indietro",next:"Avanti",search:"Cerca",filter:"Filtra",reset:"Reimposta",apply:"Applica",submit:"Invia",loading:"Caricamento…",error:"Errore",success:"Successo",warning:"Avviso",info:"Info",noData:"Nessun dato disponibile",noResults:"Nessun risultato trovato",retry:"Riprova",refresh:"Aggiorna",copy:"Copia",copied:"Copiato!",yes:"Sì",no:"No"},dU={disconnected:"Server non raggiungibile — riconnessione in corso…",connected:"Connesso"},uU={online:"Online",offline:"Offline",connecting:"Connessione in corso",error:"Errore",disabled:"Disabilitato",enabled:"Abilitato",active:"Attivo",inactive:"Inattivo",running:"In esecuzione",stopped:"Fermato",pending:"In attesa",unknown:"Sconosciuto"},pU={login:"Accesso",logout:"Esci",username:"Nome utente",password:"Password",signIn:"Accedi",invalidCredentials:"Nome utente o password non validi"},fU={dark:"Scuro",light:"Chiaro",system:"Sistema"},mU={select:"Lingua",en:"Inglese",it:"Italiano"},hU={dashboard:{title:"Dashboard",subtitle:"Panoramica di tutti i dispositivi e il loro stato"},integrations:{title:"Integrazioni",subtitle:"Gestisci le sorgenti video e le connessioni ai provider"},metrics:{title:"Metriche",subtitle:"Statistiche di prestazioni e utilizzo del sistema"},agents:{title:"Agenti",subtitle:"Gestisci gli agenti di elaborazione distribuita"},addons:{title:"Addon",subtitle:"Estendi le funzionalità con moduli addon"},settings:{title:"Impostazioni",subtitle:"Configura le preferenze di sistema"},users:{title:"Utenti",subtitle:"Gestisci gli account utente e i permessi"},logs:{title:"Log",subtitle:"Visualizza i log di sistema e dei dispositivi"}},gU={preview:"Anteprima",snapshotUnavailable:"Snapshot non disponibile",noSnapshot:"Nessuno snapshot",lastSnapshot:"Ultimo snapshot:",offline:"Offline",active:"Attivi",available:"Disponibili",noDevices:"Nessun dispositivo.",addFirstDevice:"Aggiungi il primo dispositivo per iniziare.",import:"+ Importa",noProviders:"Nessun provider disponibile. Installa un addon provider.",manage:"Gestisci",integrationName:"Nome integrazione",integrationNamePlaceholder:"es. Server Garage",connectionSuccess:"Connessione riuscita!",errorPrefix:"Errore:",back:"Indietro",testing:"Test...",testConnection:"Test connessione",forward:"Avanti",searchingDevices:"Ricerca dispositivi in corso...",foundDevices:"Trovati {{count}} dispositivi. Seleziona quelli da importare.",noDevicesFound:"Nessun dispositivo trovato.",skip:"Salta",importSelected:"Importa selezionati",newIntegration:"Nuova Integrazione",configureIntegration:"Configura Integrazione",importDevices:"Importa Dispositivi",addDevice:"Aggiungi dispositivo",name:"Nome",namePlaceholder:"es. Camera Ingresso",snapshotUrlOptional:"Snapshot URL (opzionale)",streamUrls:"Stream URLs",addStream:"Aggiungi stream",cancel:"Annulla",saving:"Salvataggio...",save:"Salva",saveAndNew:"Salva e nuova",test:"Test",stream:"Stream {{number}}:",devices:"dispositivi",rediscover:"Riscopri",config:"Config",integrationNotFound:"Integrazione non trovata.",configComingSoon:"Config coming soon.",providerConfig:"Provider Config"},bU={nav:iU,system:lU,common:cU,connection:dU,status:uU,auth:pU,theme:fU,language:mU,pages:hU,integrations:gU},Yv="camstack_language",xU=localStorage.getItem(Yv)??"en";Ze.use(qR).init({resources:{en:{translation:aU},it:{translation:bU}},lng:xU,fallbackLng:"en",interpolation:{escapeValue:!1}});Ze.on("languageChanged",e=>{localStorage.setItem(Yv,e)});window.__camstackUiLibrary=i$;window.__camstackSdk=dw;window.__camstackTypes=uw;Of(document.getElementById("root")).render(r(ew,{children:r(Wq,{})}));
|