@camstack/addon-admin-ui 0.1.36 → 0.1.38
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/{__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-CeLhKMin.js → __mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-Cv6qLu_-.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-DXPQtD9p.js → __mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-CChEG9e0.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-OcRSBqRe.js → __mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-C1BmHlGM.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-GvBGLFI2.js → __mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-Bxv_3KWz.js} +1 -1
- package/dist/assets/__mfe_internal__admin_ui_host__loadShare__konva__loadShare__.mjs-g85Oidc0.js +15 -0
- package/dist/assets/__mfe_internal__admin_ui_host__loadShare__konva__loadShare__.mjs_commonjs-proxy-Bqeq2Zwj.js +1 -0
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-Dl4u0xYE.js → __mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-DC63qZbr.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-CSyOECfO.js → __mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-D2C49VyZ.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-CzO_Esxm.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-D3WbXy3O.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-xw6c6JeS.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-Csg6EbPB.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-DNpf5SLz.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-CUc0oFNo.js} +2 -2
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs_commonjs-proxy-BEKtiDI3.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs_commonjs-proxy-vh0hhA5d.js} +1 -1
- package/dist/assets/__mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.mjs-CpGtTxci.js +35 -0
- package/dist/assets/__mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.mjs_commonjs-proxy-RUDPE9aM.js +1 -0
- package/dist/assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-W-FrsYv6.js +1 -0
- package/dist/assets/{devices-D4k34mru.js → devices-GLp7me2a.js} +1 -1
- package/dist/assets/hostInit-c5F5KLjV.js +1 -0
- package/dist/assets/index-2B5djHSh.js +1150 -0
- package/dist/assets/index-ByRJWRUP.js +1 -0
- package/dist/assets/index-COoei6lw.css +1 -0
- package/dist/assets/index-CtHpLu0L.js +1 -0
- package/dist/assets/{index-D92THlot.js → index-CwF7Dxf8.js} +1 -1
- package/dist/assets/{index-BI3Z7SSi.js → index-D6khiudP.js} +1 -1
- package/dist/assets/index-DNY_otk4.js +151 -0
- package/dist/assets/index-DQFO9ZU6.js +1 -0
- package/dist/assets/{index-BGZqVJZt.js → index-JJ5NLHxC.js} +1 -1
- package/dist/assets/{index-Bwcmc2hW.js → index-TiJwCuZx.js} +1 -1
- package/dist/assets/index-WrAHDGEr.js +87 -0
- package/dist/assets/index-b0D9qthW.js +1 -0
- package/dist/assets/method-access-map-DLEhlu0x.js +1 -0
- package/dist/assets/{remoteEntry-BRybuw2S.js → remoteEntry-BJZZ6pth.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DUkp33c_.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DWHckfBG.js} +6 -6
- package/dist/index.html +6 -6
- package/dist/mf-entry-bootstrap-0.js +2 -2
- package/dist/server/addon.js +528 -96
- package/dist/server/addon.js.map +1 -1
- package/dist/sw.js +1 -1
- package/package.json +10 -2
- package/dist/assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DYU-qDnu.js +0 -1
- package/dist/assets/hostInit-CBKchP1G.js +0 -1
- package/dist/assets/index-BEewR-UX.js +0 -1
- package/dist/assets/index-BRSAFSOw.css +0 -1
- package/dist/assets/index-BqMPfvQx.js +0 -1
- package/dist/assets/index-CP1R6E2R.js +0 -88
- package/dist/assets/index-CwjnPcOV.js +0 -152
- package/dist/assets/index-Dmon2mdO.js +0 -1
- package/dist/assets/index-KlKJOjpC.js +0 -1
- package/dist/assets/index-SyrojlmO.js +0 -1156
- package/dist/assets/method-access-map-BFPyQ2-G.js +0 -1
|
@@ -0,0 +1,1150 @@
|
|
|
1
|
+
import"./virtualExposes-_ivNhQLP.js";import{d as xr}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DWHckfBG.js";import{c as r,a as um,d as u,e as ue,g as cN}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-C_6K4VBY.js";import{b as je,e as P,h as U,c as Y,f as V,d as xe,a as pm,n as qe,k as Ae,i as re,m as qn,o as fa,g as ma,R as Ge,p as nc,q as dN,r as uN,s as yr,t as Fe,j as pN,u as fN,v as mN,w as hN}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-DC63qZbr.js";import{a as fm,b as To}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-D3WbXy3O.js";import{a as mm,b as hm}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-CUc0oFNo.js";import{_ as gm,m as Dr,n as we,o as bm,p as xm,h as Hn,j as gN}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-Cv6qLu_-.js";import{_ as ym,c as vm,s as wm,n as bN,B as xN,F as yN}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.mjs-DIkg6-MH.js";import{_ as Nm,a as vN}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-C1BmHlGM.js";import{_ as km}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.mjs-CpGtTxci.js";import{_ as Sm}from"./__mfe_internal__admin_ui_host__loadShare__konva__loadShare__.mjs-g85Oidc0.js";import{c as wN,D as Cm,E as NN,a as ut,M as kN,W as Xi,b as Cs,N as SN,d as Mm,S as CN,e as Ms}from"./index-DQFO9ZU6.js";import{S as Ji,c as Am}from"./devices-GLp7me2a.js";import{a as MN}from"./schemas-BEt-CulV.js";import{E as ve,A as AN,K as EN}from"./method-access-map-DLEhlu0x.js";import{s as IN}from"./index-JJ5NLHxC.js";import{a as ru,C as Em,S as ou,s as PN}from"./index-b0D9qthW.js";import{r as Im}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-D2C49VyZ.js";import{_ as _N}from"./preload-helper-BlTxHScW.js";import"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-Csg6EbPB.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 Pm={frigate:"#3b82f6",scrypted:"#a855f7",reolink:"#06b6d4",homeAssistant:"#22d3ee",rtsp:"#78716c"},_m={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:Pm},$m={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:Pm},el={colors:{dark:_m,light:$m},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 Dm(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]=Dm(a,s):s!==void 0&&(n[o]=s)}return n}function $N(e){return e?Dm(structuredClone(el),e):structuredClone(el)}function Lm(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function DN(e){return`--color-${Lm(e)}`}function su(e){const t=[];for(const[n,o]of Object.entries(e))n!=="provider"&&t.push(` ${DN(n)}: ${o};`);return t.join(`
|
|
2
|
+
`)}function LN(e){const t=[];for(const[n,o]of Object.entries(e))t.push(` --color-provider-${Lm(n)}: ${o};`);return t.join(`
|
|
3
|
+
`)}function TN(e){const t=[];for(const[n,o]of Object.entries(e))t.push(` --spacing-${n}: ${o}px;`);return t.join(`
|
|
4
|
+
`)}function RN(e){const t=[];for(const[n,o]of Object.entries(e))t.push(` --radius-${n}: ${o}px;`);return t.join(`
|
|
5
|
+
`)}function ON(e){const t=su(e.colors.dark),n=su(e.colors.light),o=LN(e.colors.dark.provider),s=TN(e.spacing),a=RN(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 Tm=je(null),ti=["dark","light","system"];function Rm(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function zN(e,t){if(typeof window>"u")return t;const n=localStorage.getItem(e);return n==="dark"||n==="light"||n==="system"?n:t}function au(e){return e==="system"?Rm():e}function zs({children:e,defaultMode:t="system",storageKey:n="camstack-theme-mode"}){const[o,s]=P(()=>zN(n,t)),[a,i]=P(()=>au(o)),l=U(p=>{s(p),i(au(p)),typeof window<"u"&&localStorage.setItem(n,p)},[n]),c=U(()=>{const f=(ti.indexOf(o)+1)%ti.length;l(ti[f]??"dark")},[o,l]);Y(()=>{if(typeof document>"u")return;const p=document.documentElement;p.classList.remove("dark","light"),p.classList.add(a)},[o,a]),Y(()=>{if(typeof window>"u"||o!=="system")return;const p=window.matchMedia("(prefers-color-scheme: dark)"),f=()=>{i(Rm())};return p.addEventListener("change",f),()=>p.removeEventListener("change",f)},[o]);const d=V(()=>({mode:o,resolvedMode:a,setMode:l,toggleMode:c}),[o,a,l,c]);return r(Tm.Provider,{value:d,children:e})}function Ro(){const e=xe(Tm);if(!e)throw new Error("useThemeMode must be used within a ThemeProvider");return e}function Om(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=Om(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function zm(){for(var e,t,n=0,o="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=Om(e))&&(o&&(o+=" "),o+=t);return o}const BN=(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},FN=(e,t)=>({classGroupId:e,validator:t}),Bm=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Bs="-",iu=[],jN="arbitrary..",HN=e=>{const t=UN(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return VN(i);const l=i.split(Bs),c=l[0]===""&&l.length>1?1:0;return Fm(l,c,t)},getConflictingClassGroupIds:(i,l)=>{if(l){const c=o[i],d=n[i];return c?d?BN(d,c):c:d||iu}return n[i]||iu}}},Fm=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const s=e[t],a=n.nextPart.get(s);if(a){const d=Fm(e,t+1,a);if(d)return d}const i=n.validators;if(i===null)return;const l=t===0?e.join(Bs):e.slice(t).join(Bs),c=i.length;for(let d=0;d<c;d++){const p=i[d];if(p.validator(l))return p.classGroupId}},VN=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?jN+o:void 0})(),UN=e=>{const{theme:t,classGroups:n}=e;return qN(n,t)},qN=(e,t)=>{const n=Bm();for(const o in e){const s=e[o];rc(s,n,o,t)}return n},rc=(e,t,n,o)=>{const s=e.length;for(let a=0;a<s;a++){const i=e[a];QN(i,t,n,o)}},QN=(e,t,n,o)=>{if(typeof e=="string"){GN(e,t,n);return}if(typeof e=="function"){KN(e,t,n,o);return}WN(e,t,n,o)},GN=(e,t,n)=>{const o=e===""?t:jm(t,e);o.classGroupId=n},KN=(e,t,n,o)=>{if(YN(e)){rc(e(o),t,n,o);return}t.validators===null&&(t.validators=[]),t.validators.push(FN(n,e))},WN=(e,t,n,o)=>{const s=Object.entries(e),a=s.length;for(let i=0;i<a;i++){const[l,c]=s[i];rc(c,jm(t,l),n,o)}},jm=(e,t)=>{let n=e;const o=t.split(Bs),s=o.length;for(let a=0;a<s;a++){const i=o[a];let l=n.nextPart.get(i);l||(l=Bm(),n.nextPart.set(i,l)),n=l}return n},YN=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,ZN=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)}}},tl="!",lu=":",XN=[],cu=(e,t,n,o,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:o,isExternal:s}),JN=e=>{const{prefix:t,experimentalParseClassName:n}=e;let o=s=>{const a=[];let i=0,l=0,c=0,d;const p=s.length;for(let x=0;x<p;x++){const b=s[x];if(i===0&&l===0){if(b===lu){a.push(s.slice(c,x)),c=x+1;continue}if(b==="/"){d=x;continue}}b==="["?i++:b==="]"?i--:b==="("?l++:b===")"&&l--}const f=a.length===0?s:s.slice(c);let m=f,h=!1;f.endsWith(tl)?(m=f.slice(0,-1),h=!0):f.startsWith(tl)&&(m=f.slice(1),h=!0);const g=d&&d>c?d-c:void 0;return cu(a,h,m,g)};if(t){const s=t+lu,a=o;o=i=>i.startsWith(s)?a(i.slice(s.length)):cu(XN,!1,i,void 0,!0)}if(n){const s=o;o=a=>n({className:a,parseClassName:s})}return o},e2=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}},t2=e=>({cache:ZN(e.cacheSize),parseClassName:JN(e),sortModifiers:e2(e),...HN(e)}),n2=/\s+/,r2=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:s,sortModifiers:a}=t,i=[],l=e.trim().split(n2);let c="";for(let d=l.length-1;d>=0;d-=1){const p=l[d],{isExternal:f,modifiers:m,hasImportantModifier:h,baseClassName:g,maybePostfixModifierPosition:x}=n(p);if(f){c=p+(c.length>0?" "+c:c);continue}let b=!!x,v=o(b?g.substring(0,x):g);if(!v){if(!b){c=p+(c.length>0?" "+c:c);continue}if(v=o(g),!v){c=p+(c.length>0?" "+c:c);continue}b=!1}const w=m.length===0?"":m.length===1?m[0]:a(m).join(":"),y=h?w+tl:w,N=y+v;if(i.indexOf(N)>-1)continue;i.push(N);const k=s(v,b);for(let C=0;C<k.length;++C){const D=k[C];i.push(y+D)}c=p+(c.length>0?" "+c:c)}return c},o2=(...e)=>{let t=0,n,o,s="";for(;t<e.length;)(n=e[t++])&&(o=Hm(n))&&(s&&(s+=" "),s+=o);return s},Hm=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=Hm(e[o]))&&(n&&(n+=" "),n+=t);return n},s2=(e,...t)=>{let n,o,s,a;const i=c=>{const d=t.reduce((p,f)=>f(p),e());return n=t2(d),o=n.cache.get,s=n.cache.set,a=l,l(c)},l=c=>{const d=o(c);if(d)return d;const p=r2(c,n);return s(c,p),p};return a=i,(...c)=>a(o2(...c))},a2=[],Ze=e=>{const t=n=>n[e]||a2;return t.isThemeGetter=!0,t},Vm=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Um=/^\((?:(\w[\w-]*):)?(.+)\)$/i,i2=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,l2=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,c2=/\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$/,d2=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,u2=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,p2=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,bn=e=>i2.test(e),Ee=e=>!!e&&!Number.isNaN(Number(e)),xn=e=>!!e&&Number.isInteger(Number(e)),ni=e=>e.endsWith("%")&&Ee(e.slice(0,-1)),en=e=>l2.test(e),qm=()=>!0,f2=e=>c2.test(e)&&!d2.test(e),oc=()=>!1,m2=e=>u2.test(e),h2=e=>p2.test(e),g2=e=>!ge(e)&&!be(e),b2=e=>In(e,Km,oc),ge=e=>Vm.test(e),Rn=e=>In(e,Wm,f2),du=e=>In(e,C2,Ee),x2=e=>In(e,Zm,qm),y2=e=>In(e,Ym,oc),uu=e=>In(e,Qm,oc),v2=e=>In(e,Gm,h2),Jo=e=>In(e,Xm,m2),be=e=>Um.test(e),Wr=e=>Jn(e,Wm),w2=e=>Jn(e,Ym),pu=e=>Jn(e,Qm),N2=e=>Jn(e,Km),k2=e=>Jn(e,Gm),es=e=>Jn(e,Xm,!0),S2=e=>Jn(e,Zm,!0),In=(e,t,n)=>{const o=Vm.exec(e);return o?o[1]?t(o[1]):n(o[2]):!1},Jn=(e,t,n=!1)=>{const o=Um.exec(e);return o?o[1]?t(o[1]):n:!1},Qm=e=>e==="position"||e==="percentage",Gm=e=>e==="image"||e==="url",Km=e=>e==="length"||e==="size"||e==="bg-size",Wm=e=>e==="length",C2=e=>e==="number",Ym=e=>e==="family-name",Zm=e=>e==="number"||e==="weight",Xm=e=>e==="shadow",M2=()=>{const e=Ze("color"),t=Ze("font"),n=Ze("text"),o=Ze("font-weight"),s=Ze("tracking"),a=Ze("leading"),i=Ze("breakpoint"),l=Ze("container"),c=Ze("spacing"),d=Ze("radius"),p=Ze("shadow"),f=Ze("inset-shadow"),m=Ze("text-shadow"),h=Ze("drop-shadow"),g=Ze("blur"),x=Ze("perspective"),b=Ze("aspect"),v=Ze("ease"),w=Ze("animate"),y=()=>["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(),be,ge],C=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto","contain","none"],E=()=>[be,ge,c],I=()=>[bn,"full","auto",...E()],z=()=>[xn,"none","subgrid",be,ge],A=()=>["auto",{span:["full",xn,be,ge]},xn,be,ge],T=()=>[xn,"auto",be,ge],R=()=>["auto","min","max","fr",be,ge],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],$=()=>["start","end","center","stretch","center-safe","end-safe"],L=()=>["auto",...E()],O=()=>[bn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...E()],F=()=>[bn,"screen","full","dvw","lvw","svw","min","max","fit",...E()],B=()=>[bn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...E()],j=()=>[e,be,ge],H=()=>[...N(),pu,uu,{position:[be,ge]}],_=()=>["no-repeat",{repeat:["","x","y","space","round"]}],q=()=>["auto","cover","contain",N2,b2,{size:[be,ge]}],G=()=>[ni,Wr,Rn],Q=()=>["","none","full",d,be,ge],J=()=>["",Ee,Wr,Rn],Z=()=>["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=()=>[Ee,ni,pu,uu],he=()=>["","none",g,be,ge],ee=()=>["none",Ee,be,ge],W=()=>["none",Ee,be,ge],ne=()=>[Ee,be,ge],ie=()=>[bn,"full",...E()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[en],breakpoint:[en],color:[qm],container:[en],"drop-shadow":[en],ease:["in","out","in-out"],font:[g2],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[en],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[en],shadow:[en],spacing:["px",Ee],text:[en],"text-shadow":[en],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",bn,ge,be,b]}],container:["container"],columns:[{columns:[Ee,ge,be,l]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:k()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:D()}],"overscroll-x":[{"overscroll-x":D()}],"overscroll-y":[{"overscroll-y":D()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{"inset-s":I(),start:I()}],end:[{"inset-e":I(),end:I()}],"inset-bs":[{"inset-bs":I()}],"inset-be":[{"inset-be":I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[xn,"auto",be,ge]}],basis:[{basis:[bn,"full","auto",l,...E()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ee,bn,"auto","initial","none",ge]}],grow:[{grow:["",Ee,be,ge]}],shrink:[{shrink:["",Ee,be,ge]}],order:[{order:[xn,"first","last","none",be,ge]}],"grid-cols":[{"grid-cols":z()}],"col-start-end":[{col:A()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":z()}],"row-start-end":[{row:A()}],"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":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:E()}],"gap-x":[{"gap-x":E()}],"gap-y":[{"gap-y":E()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...$(),"normal"]}],"justify-self":[{"justify-self":["auto",...$()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...$(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...$(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...$(),"baseline"]}],"place-self":[{"place-self":["auto",...$()]}],p:[{p:E()}],px:[{px:E()}],py:[{py:E()}],ps:[{ps:E()}],pe:[{pe:E()}],pbs:[{pbs:E()}],pbe:[{pbe:E()}],pt:[{pt:E()}],pr:[{pr:E()}],pb:[{pb:E()}],pl:[{pl:E()}],m:[{m:L()}],mx:[{mx:L()}],my:[{my:L()}],ms:[{ms:L()}],me:[{me:L()}],mbs:[{mbs:L()}],mbe:[{mbe:L()}],mt:[{mt:L()}],mr:[{mr:L()}],mb:[{mb:L()}],ml:[{ml:L()}],"space-x":[{"space-x":E()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":E()}],"space-y-reverse":["space-y-reverse"],size:[{size:O()}],"inline-size":[{inline:["auto",...F()]}],"min-inline-size":[{"min-inline":["auto",...F()]}],"max-inline-size":[{"max-inline":["none",...F()]}],"block-size":[{block:["auto",...B()]}],"min-block-size":[{"min-block":["auto",...B()]}],"max-block-size":[{"max-block":["none",...B()]}],w:[{w:[l,"screen",...O()]}],"min-w":[{"min-w":[l,"screen","none",...O()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...O()]}],h:[{h:["screen","lh",...O()]}],"min-h":[{"min-h":["screen","lh","none",...O()]}],"max-h":[{"max-h":["screen","lh",...O()]}],"font-size":[{text:["base",n,Wr,Rn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,S2,x2]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ni,ge]}],"font-family":[{font:[w2,y2,t]}],"font-features":[{"font-features":[ge]}],"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,be,ge]}],"line-clamp":[{"line-clamp":[Ee,"none",be,du]}],leading:[{leading:[a,...E()]}],"list-image":[{"list-image":["none",be,ge]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",be,ge]}],"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:[...Z(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ee,"from-font","auto",be,Rn]}],"text-decoration-color":[{decoration:j()}],"underline-offset":[{"underline-offset":[Ee,"auto",be,ge]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:E()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",be,ge]}],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",be,ge]}],"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:_()}],"bg-size":[{bg:q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},xn,be,ge],radial:["",be,ge],conic:[xn,be,ge]},k2,v2]}],"bg-color":[{bg:j()}],"gradient-from-pos":[{from:G()}],"gradient-via-pos":[{via:G()}],"gradient-to-pos":[{to:G()}],"gradient-from":[{from:j()}],"gradient-via":[{via:j()}],"gradient-to":[{to:j()}],rounded:[{rounded:Q()}],"rounded-s":[{"rounded-s":Q()}],"rounded-e":[{"rounded-e":Q()}],"rounded-t":[{"rounded-t":Q()}],"rounded-r":[{"rounded-r":Q()}],"rounded-b":[{"rounded-b":Q()}],"rounded-l":[{"rounded-l":Q()}],"rounded-ss":[{"rounded-ss":Q()}],"rounded-se":[{"rounded-se":Q()}],"rounded-ee":[{"rounded-ee":Q()}],"rounded-es":[{"rounded-es":Q()}],"rounded-tl":[{"rounded-tl":Q()}],"rounded-tr":[{"rounded-tr":Q()}],"rounded-br":[{"rounded-br":Q()}],"rounded-bl":[{"rounded-bl":Q()}],"border-w":[{border:J()}],"border-w-x":[{"border-x":J()}],"border-w-y":[{"border-y":J()}],"border-w-s":[{"border-s":J()}],"border-w-e":[{"border-e":J()}],"border-w-bs":[{"border-bs":J()}],"border-w-be":[{"border-be":J()}],"border-w-t":[{"border-t":J()}],"border-w-r":[{"border-r":J()}],"border-w-b":[{"border-b":J()}],"border-w-l":[{"border-l":J()}],"divide-x":[{"divide-x":J()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":J()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Z(),"hidden","none"]}],"divide-style":[{divide:[...Z(),"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:[...Z(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ee,be,ge]}],"outline-w":[{outline:["",Ee,Wr,Rn]}],"outline-color":[{outline:j()}],shadow:[{shadow:["","none",p,es,Jo]}],"shadow-color":[{shadow:j()}],"inset-shadow":[{"inset-shadow":["none",f,es,Jo]}],"inset-shadow-color":[{"inset-shadow":j()}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:j()}],"ring-offset-w":[{"ring-offset":[Ee,Rn]}],"ring-offset-color":[{"ring-offset":j()}],"inset-ring-w":[{"inset-ring":J()}],"inset-ring-color":[{"inset-ring":j()}],"text-shadow":[{"text-shadow":["none",m,es,Jo]}],"text-shadow-color":[{"text-shadow":j()}],opacity:[{opacity:[Ee,be,ge]}],"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":[Ee]}],"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":[be,ge]}],"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":[Ee]}],"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:_()}],"mask-size":[{mask:q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",be,ge]}],filter:[{filter:["","none",be,ge]}],blur:[{blur:he()}],brightness:[{brightness:[Ee,be,ge]}],contrast:[{contrast:[Ee,be,ge]}],"drop-shadow":[{"drop-shadow":["","none",h,es,Jo]}],"drop-shadow-color":[{"drop-shadow":j()}],grayscale:[{grayscale:["",Ee,be,ge]}],"hue-rotate":[{"hue-rotate":[Ee,be,ge]}],invert:[{invert:["",Ee,be,ge]}],saturate:[{saturate:[Ee,be,ge]}],sepia:[{sepia:["",Ee,be,ge]}],"backdrop-filter":[{"backdrop-filter":["","none",be,ge]}],"backdrop-blur":[{"backdrop-blur":he()}],"backdrop-brightness":[{"backdrop-brightness":[Ee,be,ge]}],"backdrop-contrast":[{"backdrop-contrast":[Ee,be,ge]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ee,be,ge]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ee,be,ge]}],"backdrop-invert":[{"backdrop-invert":["",Ee,be,ge]}],"backdrop-opacity":[{"backdrop-opacity":[Ee,be,ge]}],"backdrop-saturate":[{"backdrop-saturate":[Ee,be,ge]}],"backdrop-sepia":[{"backdrop-sepia":["",Ee,be,ge]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":E()}],"border-spacing-x":[{"border-spacing-x":E()}],"border-spacing-y":[{"border-spacing-y":E()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",be,ge]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ee,"initial",be,ge]}],ease:[{ease:["linear","initial",v,be,ge]}],delay:[{delay:[Ee,be,ge]}],animate:[{animate:["none",w,be,ge]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,be,ge]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:ee()}],"rotate-x":[{"rotate-x":ee()}],"rotate-y":[{"rotate-y":ee()}],"rotate-z":[{"rotate-z":ee()}],scale:[{scale:W()}],"scale-x":[{"scale-x":W()}],"scale-y":[{"scale-y":W()}],"scale-z":[{"scale-z":W()}],"scale-3d":["scale-3d"],skew:[{skew:ne()}],"skew-x":[{"skew-x":ne()}],"skew-y":[{"skew-y":ne()}],transform:[{transform:[be,ge,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ie()}],"translate-x":[{"translate-x":ie()}],"translate-y":[{"translate-y":ie()}],"translate-z":[{"translate-z":ie()}],"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",be,ge]}],"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":E()}],"scroll-mx":[{"scroll-mx":E()}],"scroll-my":[{"scroll-my":E()}],"scroll-ms":[{"scroll-ms":E()}],"scroll-me":[{"scroll-me":E()}],"scroll-mbs":[{"scroll-mbs":E()}],"scroll-mbe":[{"scroll-mbe":E()}],"scroll-mt":[{"scroll-mt":E()}],"scroll-mr":[{"scroll-mr":E()}],"scroll-mb":[{"scroll-mb":E()}],"scroll-ml":[{"scroll-ml":E()}],"scroll-p":[{"scroll-p":E()}],"scroll-px":[{"scroll-px":E()}],"scroll-py":[{"scroll-py":E()}],"scroll-ps":[{"scroll-ps":E()}],"scroll-pe":[{"scroll-pe":E()}],"scroll-pbs":[{"scroll-pbs":E()}],"scroll-pbe":[{"scroll-pbe":E()}],"scroll-pt":[{"scroll-pt":E()}],"scroll-pr":[{"scroll-pr":E()}],"scroll-pb":[{"scroll-pb":E()}],"scroll-pl":[{"scroll-pl":E()}],"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",be,ge]}],fill:[{fill:["none",...j()]}],"stroke-w":[{stroke:[Ee,Wr,Rn,du]}],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"]}},A2=s2(M2);function K(...e){return A2(zm(e))}const E2="rounded-lg border border-border bg-surface overflow-hidden",I2="border-b border-border px-3 sm:px-4 py-1.5 sm:py-2",P2="p-2 sm:p-3 lg:p-4",_2="space-y-3 sm:space-y-4",$2="gap-2 sm:gap-3",Jm="px-3 sm:px-4 py-1.5 sm:py-2",D2="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4",L2="grid grid-cols-1 lg:grid-cols-2",T2="flex flex-col-reverse md:flex-row",R2="w-full md:w-44 lg:w-52 md:flex-shrink-0 border-b md:border-b-0 md:border-l border-border",O2="text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider",z2="text-[11px] sm:text-xs text-foreground",no="text-[10px] text-foreground-subtle",B2="text-[11px] sm:text-xs font-medium text-foreground",F2="text-base sm:text-lg font-semibold leading-tight text-foreground",j2="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",H2="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",V2="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",U2="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",q2="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",Q2="inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors",G2="border-primary/50 bg-primary/15 text-primary",K2="border-border bg-surface text-foreground-subtle hover:bg-surface-hover";function W2(e,t){for(const n of e.slots)for(const o of n.addons)if(o.id===t)return o;return null}function Y2(e,t){return e.models.find(n=>n.id===t)??null}function Z2(e,t){return e.models.find(n=>!!n.formats[t])??null}function X2(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 eh(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=W2(o,i);if(!c){a.push({addonId:i,outcome:"skip",modelId:null,reason:"addon not in target catalog",patch:null});continue}const d=Y2(c,l.modelId),p=d!==null&&!!d.formats[n.engine.format];let f,m;if(p)f=l.modelId,m="exact";else{const g=Z2(c,n.engine.format);if(!g){a.push({addonId:i,outcome:"skip",modelId:null,reason:"no compatible model for target format",patch:null});continue}f=g.id,m="mapped"}const h={enabled:l.enabled,modelId:f,settings:X2(l.settings,c)};a.push({addonId:i,outcome:m,modelId:f,patch:h})}return a}const nl={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 Lr(e){return nl[e]??nl.watching}function mn(e,t){if(typeof globalThis>"u")return je(t);const n=globalThis.__camstackSharedContexts,o=n??new Map;n||(globalThis.__camstackSharedContexts=o);const s=o.get(e);if(s)return s;const a=je(t);return o.set(e,a),a}function fr(e){const n=(typeof globalThis<"u"?globalThis:void 0)?.[e];return n&&typeof n=="object"?n:{}}const J2={singleton:!0,requiredVersion:!1,eager:!0},yt=e=>({version:"0.0.0",scope:"default",lib:e,shareConfig:J2}),fu="__mf_module_cache__";function ek(){const e=globalThis,t=e[fu];if(t&&typeof t=="object"){const o=t;return o.share??={},o.remote??={},o}const n={share:{},remote:{}};return e[fu]=n,n}function tk(){const e=ek();e.share.react??=pm,e.share["react-dom"]??=fm,e.share["react-dom/client"]??=mm,e.share["react/jsx-runtime"]??=um,e.share["@tanstack/react-query"]??=gm,e.share["@trpc/client"]??=ym,e.share["@trpc/react-query"]??=Nm,e.share["react-konva"]??=km,e.share.konva??=Sm,e.share["@camstack/ui-library"]??=fr("__camstackUiLibrary"),e.share["@camstack/sdk"]??=fr("__camstackSdk"),e.share["@camstack/types"]??=fr("__camstackTypes")}function sc(){tk(),xr.getInstance()===null&&xr.init({name:"admin_ui_host",remotes:[],shared:{react:yt(()=>pm),"react-dom":yt(()=>fm),"react-dom/client":yt(()=>mm),"react/jsx-runtime":yt(()=>um),"@tanstack/react-query":yt(()=>gm),"@trpc/client":yt(()=>ym),"@trpc/react-query":yt(()=>Nm),"react-konva":yt(()=>km),konva:yt(()=>Sm),"@camstack/ui-library":yt(()=>fr("__camstackUiLibrary")),"@camstack/sdk":yt(()=>fr("__camstackSdk")),"@camstack/types":yt(()=>fr("__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 th=(...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 nk=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 rk=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 mu=e=>{const t=rk(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 ok={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 sk=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 ak=qe(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:s="",children:a,iconNode:i,...l},c)=>Ae("svg",{ref:c,...ok,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:th("lucide",s),...!a&&!sk(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,p])=>Ae(d,p)),...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 ae=(e,t)=>{const n=qe(({className:o,...s},a)=>Ae(ak,{ref:a,iconNode:t,className:th(`lucide-${nk(mu(e))}`,`lucide-${e}`,o),...s}));return n.displayName=mu(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 ik=[["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"}]],Nn=ae("activity",ik);/**
|
|
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 lk=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],ck=ae("arrow-down",lk);/**
|
|
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 dk=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],uk=ae("arrow-left",dk);/**
|
|
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 pk=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],fk=ae("arrow-right",pk);/**
|
|
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 mk=[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]],nh=ae("arrow-up-to-line",mk);/**
|
|
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 hk=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],gk=ae("arrow-up",hk);/**
|
|
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 bk=[["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"}]],xk=ae("battery-full",bk);/**
|
|
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 yk=[["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"}]],vk=ae("battery-low",yk);/**
|
|
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 wk=[["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"}]],Nk=ae("battery-warning",wk);/**
|
|
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 kk=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],rh=ae("battery",kk);/**
|
|
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 Sk=[["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"}]],Ck=ae("bell-ring",Sk);/**
|
|
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 Mk=[["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"}]],ha=ae("bell",Mk);/**
|
|
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 Ak=[["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"}]],Ek=ae("bug",Ak);/**
|
|
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 Ik=[["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"}]],ac=ae("camera",Ik);/**
|
|
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 Pk=[["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"}]],_k=ae("cast",Pk);/**
|
|
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 $k=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Oo=ae("check",$k);/**
|
|
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 Dk=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],er=ae("chevron-down",Dk);/**
|
|
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 Lk=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Tk=ae("chevron-left",Lk);/**
|
|
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 Rk=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Pn=ae("chevron-right",Rk);/**
|
|
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 Ok=[["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"}]],Tr=ae("circle-alert",Ok);/**
|
|
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 zk=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Bk=ae("circle-check-big",zk);/**
|
|
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 Fk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],jk=ae("circle-check",Fk);/**
|
|
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 Hk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Vk=ae("circle-dot",Hk);/**
|
|
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 Uk=[["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"}]],qk=ae("circle-pause",Uk);/**
|
|
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 Qk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],Gk=ae("circle-plus",Qk);/**
|
|
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 Kk=[["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"}]],oh=ae("circle-question-mark",Kk);/**
|
|
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 Wk=[["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"}]],Yk=ae("circle-x",Wk);/**
|
|
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 Zk=[["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"}]],Xk=ae("copy-plus",Zk);/**
|
|
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 Jk=[["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"}]],_n=ae("copy",Jk);/**
|
|
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 eS=[["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"}]],tS=ae("cpu",eS);/**
|
|
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 nS=[["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"}]],ic=ae("crosshair",nS);/**
|
|
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 rS=[["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"}]],oS=ae("database",rS);/**
|
|
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 sS=[["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"}]],sh=ae("door-open",sS);/**
|
|
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 aS=[["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"}]],rl=ae("download",aS);/**
|
|
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 iS=[["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"}]],ah=ae("ellipsis-vertical",iS);/**
|
|
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 lS=[["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"}]],lc=ae("external-link",lS);/**
|
|
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 cS=[["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"}]],cc=ae("eye-off",cS);/**
|
|
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 dS=[["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"}]],Rr=ae("eye",dS);/**
|
|
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 uS=[["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"}]],ih=ae("funnel",uS);/**
|
|
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 pS=[["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"}]],fS=ae("grip-horizontal",pS);/**
|
|
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 mS=[["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"}]],lh=ae("house",mS);/**
|
|
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 hS=[["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"}]],gS=ae("image",hS);/**
|
|
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 bS=[["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"}]],xS=ae("inbox",bS);/**
|
|
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 yS=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],vS=ae("info",yS);/**
|
|
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 wS=[["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"}]],NS=ae("layout-grid",wS);/**
|
|
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 kS=[["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"}]],ch=ae("lightbulb",kS);/**
|
|
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 SS=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],mt=ae("loader-circle",SS);/**
|
|
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 CS=[["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"}]],MS=ae("locate-fixed",CS);/**
|
|
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 AS=[["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"}]],hu=ae("maximize-2",AS);/**
|
|
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 ES=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],IS=ae("menu",ES);/**
|
|
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 PS=[["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"}]],dh=ae("mic",PS);/**
|
|
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 _S=[["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"}]],gu=ae("minimize-2",_S);/**
|
|
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 $S=[["path",{d:"M5 12h14",key:"1ays0h"}]],uh=ae("minus",$S);/**
|
|
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 DS=[["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"}]],dc=ae("moon",DS);/**
|
|
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 LS=[["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"}]],TS=ae("music",LS);/**
|
|
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 RS=[["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"}]],ol=ae("network",RS);/**
|
|
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 OS=[["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"}]],zS=ae("pencil",OS);/**
|
|
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 BS=[["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"}]],sl=ae("play",BS);/**
|
|
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 FS=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Or=ae("plus",FS);/**
|
|
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 jS=[["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"}]],HS=ae("plug",jS);/**
|
|
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 VS=[["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"}]],US=ae("power-off",VS);/**
|
|
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 qS=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],QS=ae("qr-code",qS);/**
|
|
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 GS=[["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"}]],ph=ae("radar",GS);/**
|
|
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 KS=[["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"}]],WS=ae("radio",KS);/**
|
|
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 YS=[["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"}]],ga=ae("refresh-cw",YS);/**
|
|
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 ZS=[["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"}]],fh=ae("rotate-ccw",ZS);/**
|
|
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 XS=[["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"}]],mh=ae("rotate-cw",XS);/**
|
|
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 JS=[["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"}]],e5=ae("save",JS);/**
|
|
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 t5=[["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"}]],n5=ae("scan",t5);/**
|
|
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 r5=[["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"}]],o5=ae("scroll-text",r5);/**
|
|
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 s5=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],xo=ae("search",s5);/**
|
|
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 a5=[["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"}]],i5=ae("server",a5);/**
|
|
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 l5=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],bu=ae("share-2",l5);/**
|
|
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 c5=[["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"}]],d5=ae("shield",c5);/**
|
|
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 u5=[["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"}]],p5=ae("ship",u5);/**
|
|
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 f5=[["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"}]],m5=ae("sliders-horizontal",f5);/**
|
|
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 h5=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],xu=ae("square",h5);/**
|
|
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 g5=[["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"}]],b5=ae("star",g5);/**
|
|
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 x5=[["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"}]],hh=ae("sun",x5);/**
|
|
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 y5=[["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"}]],v5=ae("table-2",y5);/**
|
|
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 w5=[["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"}]],yu=ae("target",w5);/**
|
|
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 N5=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],k5=ae("thermometer",N5);/**
|
|
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 S5=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],C5=ae("toggle-left",S5);/**
|
|
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 M5=[["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"}]],ln=ae("trash-2",M5);/**
|
|
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 A5=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],E5=ae("trending-up",A5);/**
|
|
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 I5=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],P5=ae("trending-down",I5);/**
|
|
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 _5=[["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"}]],zr=ae("triangle-alert",_5);/**
|
|
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 $5=[["path",{d:"M15 7h2a5 5 0 0 1 0 10h-2m-6 0H7A5 5 0 0 1 7 7h2",key:"1re2ne"}]],D5=ae("unlink-2",$5);/**
|
|
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 L5=[["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"}]],gh=ae("upload",L5);/**
|
|
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 T5=[["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"}]],R5=ae("wifi-off",T5);/**
|
|
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 O5=[["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"}]],bh=ae("wifi",O5);/**
|
|
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 z5=[["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"}]],uc=ae("wrench",z5);/**
|
|
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 B5=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Je=ae("x",B5);/**
|
|
536
|
+
* @license lucide-react v0.576.0 - ISC
|
|
537
|
+
*
|
|
538
|
+
* This source code is licensed under the ISC license.
|
|
539
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
540
|
+
*/const F5=[["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"}]],vu=ae("zap",F5);/**
|
|
541
|
+
* @license lucide-react v0.576.0 - ISC
|
|
542
|
+
*
|
|
543
|
+
* This source code is licensed under the ISC license.
|
|
544
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
545
|
+
*/const j5=[["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"}]],H5=ae("zoom-in",j5);/**
|
|
546
|
+
* @license lucide-react v0.576.0 - ISC
|
|
547
|
+
*
|
|
548
|
+
* This source code is licensed under the ISC license.
|
|
549
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
550
|
+
*/const V5=[["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"}]],U5=ae("zoom-out",V5),q5={frigate:p5,scrypted:d5,reolink:WS,homeAssistant:lh,rtsp:_k},Q5={online:jk,offline:Yk,degraded:Tr,unknown:oh},wu=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Nu=zm,tr=(e,t)=>n=>{var o;if(t?.variants==null)return Nu(e,n?.class,n?.className);const{variants:s,defaultVariants:a}=t,i=Object.keys(s).map(d=>{const p=n?.[d],f=a?.[d];if(p===null)return null;const m=wu(p)||wu(f);return s[d][m]}),l=n&&Object.entries(n).reduce((d,p)=>{let[f,m]=p;return m===void 0||(d[f]=m),d},{}),c=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((d,p)=>{let{class:f,className:m,...h}=p;return Object.entries(h).every(g=>{let[x,b]=g;return Array.isArray(b)?b.includes({...a,...l}[x]):{...a,...l}[x]===b})?[...d,f,m]:d},[]);return Nu(e,i,c,n?.class,n?.className)},G5=tr("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"}}),ze=qe(({className:e,variant:t,size:n,...o},s)=>r("button",{ref:s,className:K(G5({variant:t,size:n}),e),...o}));ze.displayName="Button";const K5=tr("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"}}),pc=qe(({className:e,variant:t,size:n,icon:o,...s},a)=>r("button",{ref:a,className:K(K5({variant:t,size:n}),e),...s,children:r(o,{className:"h-4 w-4"})}));pc.displayName="IconButton";const W5=tr("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"}}),Lt=qe(({className:e,variant:t,style:n,...o},s)=>r("span",{ref:s,className:K(W5({variant:t,styleVariant:n}),e),...o}));Lt.displayName="Badge";const Y5=tr("rounded-lg p-3",{variants:{variant:{flat:"bg-surface",bordered:"bg-surface border border-border"}},defaultVariants:{variant:"bordered"}}),an=qe(({className:e,variant:t,...n},o)=>r("div",{ref:o,className:K(Y5({variant:t}),e),...n}));an.displayName="Card";function xh({expanded:e,onExpandedChange:t,header:n,children:o,dimmed:s=!1,hideChevron:a=!1,className:i}){return u("div",{className:K("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(er,{className:"h-4 w-4"}):r(Pn,{className:"h-4 w-4"})}),n]}),e&&o&&r("div",{className:"border-t border-border px-3 py-3",children:o})]})}const fc=qe(({className:e,...t},n)=>r("label",{ref:n,className:K("text-[10px] uppercase tracking-wider text-foreground-muted font-medium",e),...t}));fc.displayName="Label";const Z5=tr("",{variants:{orientation:{horizontal:"h-px w-full bg-border-subtle",vertical:"w-px h-full bg-border-subtle"}},defaultVariants:{orientation:"horizontal"}}),mc=qe(({className:e,orientation:t,...n},o)=>r("div",{ref:o,role:"separator",className:K(Z5({orientation:t}),e),...n}));mc.displayName="Separator";const yh=qe(({className:e,...t},n)=>r("div",{ref:n,className:K("animate-pulse bg-surface-hover rounded-md h-4 w-full",e),...t}));yh.displayName="Skeleton";const ku=tr("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"}}),Fs=qe(({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:K(ku({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:K(ku({state:t}),e),...s}));Fs.displayName="Input";const yo=qe(({className:e,options:t,...n},o)=>u("div",{className:"relative w-full",children:[r("select",{ref:o,className:K("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(er,{className:"h-3.5 w-3.5"})})]}));yo.displayName="Select";const vh=qe(({className:e,...t},n)=>r("input",{ref:n,type:"checkbox",className:K("w-3.5 h-3.5 rounded-sm border border-border accent-primary",e),...t}));vh.displayName="Checkbox";const hc=qe(({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:K("inline-flex items-center gap-2",e),...s,children:[r("span",{className:K("w-8 h-4 rounded-full transition-colors",t?"bg-primary":"bg-surface-hover"),children:r("span",{className:K("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})]}));hc.displayName="Switch";const wh=je(null);function Nh(){const e=xe(wh);if(!e)throw new Error("Dialog compound components must be used within <Dialog>");return e}function kh({children:e,open:t,onOpenChange:n}){const[o,s]=P(!1),a=t??o,i=qn(),l=U(c=>{n?.(c),t===void 0&&s(c)},[t,n]);return r(wh.Provider,{value:{open:a,setOpen:l,contentId:i},children:e})}function X5({children:e,...t}){const{setOpen:n}=Nh();return r("button",{type:"button",onClick:()=>n(!0),...t,children:e})}const J5=tr("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"}}),gc=qe(({className:e,width:t,children:n,...o},s)=>{const{open:a,setOpen:i,contentId:l}=Nh(),c=re(null),d=s??c;Y(()=>{const f=d.current;f&&(a&&!f.open&&f.showModal(),!a&&f.open&&f.close())},[a,d]);const p=f=>{f.target===f.currentTarget&&i(!1)};return r("dialog",{ref:d,id:l,className:K(J5({width:t}),"w-full",e),onClick:p,onClose:()=>i(!1),...o,children:n})});gc.displayName="DialogContent";function Sh({className:e,...t}){return r("div",{className:K("flex flex-col gap-1 mb-3",e),...t})}function Ch({className:e,...t}){return r("div",{className:K("flex justify-end gap-2 mt-4",e),...t})}function Mh({className:e,...t}){return r("h2",{className:K("text-sm font-semibold text-foreground",e),...t})}function Ah({className:e,...t}){return r("p",{className:K("text-xs text-foreground-muted",e),...t})}const Eh=je(null);function bc(){const e=xe(Eh);if(!e)throw new Error("Dropdown compound components must be used within <Dropdown>");return e}function Ih({children:e}){const[t,n]=P(!1),o=qn(),s=qn(),a=re(null);return r(Eh.Provider,{value:{open:t,setOpen:n,triggerId:o,contentId:s,triggerRef:a},children:r("div",{className:"relative inline-block",children:e})})}function Ph({children:e,...t}){const{open:n,setOpen:o,triggerId:s,contentId:a,triggerRef:i}=bc();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 _h({className:e,children:t,align:n="start",offset:o=4,...s}){const{open:a,setOpen:i,contentId:l,triggerId:c,triggerRef:d}=bc(),p=re(null),[f,m]=P(null);if(fa(()=>{if(!a){m(null);return}const g=()=>{const x=d.current;if(!x)return;const b=x.getBoundingClientRect(),v=n==="end"?b.right:b.left;m({top:b.bottom+o,left:v,minWidth:b.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]),Y(()=>{if(!a)return;const g=b=>{const v=p.current,w=d.current;v&&!v.contains(b.target)&&!w?.contains(b.target)&&i(!1)},x=b=>{b.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",x)}},[a,i,d]),!a||!f||typeof document>"u")return null;const h={position:"fixed",top:f.top,...n==="end"?{right:window.innerWidth-f.left}:{left:f.left},minWidth:f.minWidth};return To(r("div",{ref:p,id:l,role:"menu","aria-labelledby":c,style:h,className:K("z-50 bg-background-elevated border border-border rounded-md shadow-lg py-1 min-w-[160px]",e),...s,children:t}),document.body)}function $h({className:e,icon:t,variant:n="default",children:o,onClick:s,...a}){const{setOpen:i}=bc(),l=U(c=>{s?.(c),i(!1)},[s,i]);return u("button",{type:"button",role:"menuitem",className:K("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 Dh=je(null);function Lh(){const e=xe(Dh);if(!e)throw new Error("Tooltip compound components must be used within <Tooltip>");return e}function eC({children:e}){const[t,n]=P(!1),o=re(null),s=qn(),a=()=>{o.current=setTimeout(()=>n(!0),300)},i=()=>{o.current&&clearTimeout(o.current),n(!1)};return r(Dh.Provider,{value:{open:t,show:a,hide:i,tooltipId:s},children:r("div",{className:"relative inline-block",children:e})})}function tC({children:e,...t}){const{show:n,hide:o,tooltipId:s,open:a}=Lh();return r("div",{onMouseEnter:n,onMouseLeave:o,onFocus:n,onBlur:o,"aria-describedby":a?s:void 0,...t,children:e})}function nC({className:e,children:t,...n}){const{open:o,tooltipId:s}=Lh();return r("div",{id:s,role:"tooltip",className:K("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 Su="(max-width: 767px)",Cu="(min-width: 768px) and (max-width: 1023px)";function Th(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 nr(){return ma(Th(Su),Rh(Su),Oh)}function zh(){return ma(Th(Cu),Rh(Cu),Oh)}function xc({open:e,onClose:t,title:n,children:o,className:s}){return Y(()=>{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(ue,{children:[r("div",{className:K("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:K("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(Je,{className:"h-4 w-4"})})]}),r("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:o})]})]})}const Bh=je(null);function Fh(){const e=xe(Bh);if(!e)throw new Error("Popover compound components must be used within <Popover>");return e}function jh({children:e,open:t,onOpenChange:n}){const[o,s]=P(!1),a=t??o,i=qn(),l=qn(),c=U(d=>{n?.(d),t===void 0&&s(d)},[t,n]);return r(Bh.Provider,{value:{open:a,setOpen:c,triggerId:i,contentId:l},children:r("div",{className:"relative inline-block",children:e})})}function Hh({children:e,...t}){const{open:n,setOpen:o,triggerId:s,contentId:a}=Fh();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 Vh({className:e,children:t,...n}){const{open:o,setOpen:s,contentId:a,triggerId:i}=Fh(),l=nr(),c=re(null);return Y(()=>{if(!o||l)return;const d=f=>{const m=c.current,h=document.getElementById(i);m&&!m.contains(f.target)&&!h?.contains(f.target)&&s(!1)},p=f=>{f.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",d),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",p)}},[o,s,i,l]),o?l?r(xc,{open:o,onClose:()=>s(!1),children:t}):r("div",{ref:c,id:a,role:"dialog","aria-labelledby":i,className:K("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=je(null);function qh(){const e=xe(Uh);if(!e)throw new Error("Tabs compound components must be used within <Tabs>");return e}function rC({value:e,onValueChange:t,defaultValue:n="",className:o,...s}){const[a,i]=P(n),l=e??a,c=U(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 oC({className:e,...t}){return r("div",{role:"tablist",className:K("flex flex-row border-b border-border-subtle",e),...t})}function sC({value:e,className:t,...n}){const{value:o,setValue:s}=qh(),a=e===o,i=`tabpanel-${e}`;return r("button",{type:"button",role:"tab","aria-selected":a,"aria-controls":i,tabIndex:a?0:-1,className:K("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 aC({value:e,className:t,...n}){const{value:o}=qh();return e!==o?null:r("div",{role:"tabpanel",id:`tabpanel-${e}`,className:K("pt-3",t),...n})}const yc=qe(({className:e,...t},n)=>r("div",{ref:n,className:K("overflow-auto [&::-webkit-scrollbar]:w-1 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-surface-hover [&::-webkit-scrollbar-thumb]:rounded-full",e),...t}));yc.displayName="ScrollArea";function iC({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,p]=P({x:80+l*30,y:80+l*30}),[f,m]=P({w:o,h:s}),[h,g]=P(!1),x=re(!1),b=re(!1),v=re({x:0,y:0}),w=nr(),y=U(k=>{k.preventDefault(),x.current=!0,v.current={x:k.clientX-d.x,y:k.clientY-d.y}},[d]),N=U(k=>{k.preventDefault(),k.stopPropagation(),b.current=!0,v.current={x:k.clientX,y:k.clientY}},[]);return Y(()=>{const k=D=>{if(x.current&&p({x:D.clientX-v.current.x,y:D.clientY-v.current.y}),b.current){const E=D.clientX-v.current.x,I=D.clientY-v.current.y;v.current={x:D.clientX,y:D.clientY},m(z=>({w:Math.max(a,z.w+E),h:Math.max(i,z.h+I)}))}},C=()=>{x.current=!1,b.current=!1};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",C)}},[a,i]),w?u("div",{className:K("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(hu,{size:12}):r(gu,{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(Je,{size:12})})]})]}),!h&&r("div",{className:"flex-1 min-h-0 overflow-y-auto",children:n})]}):u("div",{className:K("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:f.w,height:h?"auto":f.h},children:[u("div",{onMouseDown:y,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(fS,{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(hu,{size:12}):r(gu,{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(Je,{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 vc({open:e,onClose:t,children:n,className:o,width:s="w-64"}){const a=re(null);return Y(()=>{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(ue,{children:[r("div",{className:K("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:K("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 wc({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(Ge.Fragment,{children:[o>0&&r(Pn,{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 Mu={left:"text-left",right:"text-right",center:"text-center"};function zo({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(p=>{const f=p.align??"left",m=p.nowrap??!0;return r("th",{className:["px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border",Mu[f],m?"whitespace-nowrap":"",p.width??""].filter(Boolean).join(" "),children:p.headerRender?p.headerRender():p.header},p.key)})})}),r("tbody",{children:t.map((p,f)=>{const m=n?n(p,f):f,h=c?.(p,f)??"",g=o!==void 0;return r("tr",{onClick:g?()=>o(p,f):void 0,className:[g?"cursor-pointer hover:bg-primary/5":"hover:bg-primary/5",h].filter(Boolean).join(" "),children:e.map(x=>{const b=x.align??"left",v=x.nowrap??!1;return r("td",{className:["px-3 py-2 text-foreground border-b border-border",Mu[b],v?"whitespace-nowrap":""].filter(Boolean).join(" "),children:x.render(p,f)},x.key)})},m)})})]})})}function Nc({open:e,onClose:t,title:n,subtitle:o,footer:s,children:a,widthClass:i="w-[360px]"}){return Y(()=>{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:K("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(Je,{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 lC={inherit:"bg-muted",on:"bg-emerald-500",off:"bg-orange-500",na:"bg-gray-300 opacity-50"};function Qh({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:K("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:K("w-2 h-2 rounded-full",lC[l.state])},l.agentNodeId))})]}),e.children.map(l=>r(Qh,{node:l,depth:t+1,selectedAddonId:n,onSelect:o,agentDots:s},l.addonId))]})}function Gh({tree:e,selectedAddonId:t,onSelect:n,agentDots:o,className:s}){return r("div",{className:K("flex flex-col py-2",s),children:e.map(a=>r(Qh,{node:a,depth:0,selectedAddonId:t,onSelect:n,agentDots:o},a.addonId))})}function ba(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 cC(e){return e?e.models.map(t=>({id:t.id,name:t.name})):[]}function As({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:p,hideModelAndSettings:f=!1}){const[m,h]=P(!1),g=cC(t);if(g.length>0&&!g.some(b=>b.id===e.modelId)&&!i){const v=(t?.defaultModelId?g.find(w=>w.id===t.defaultModelId):null)??g[0];v&&v.id!==e.modelId&&queueMicrotask(()=>s({...e,modelId:v.id}))}const x=u(ue,{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(b=>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:b},b)),e.inputClasses.length>0&&e.outputClasses.length>0&&r("span",{className:"text-foreground-subtle/40 text-[10px]",children:"→"}),e.outputClasses.map(b=>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:b},b))]})]}),!i&&l==="simple"&&r("button",{onClick:b=>{b.stopPropagation(),s({...e,enabled:!e.enabled})},className:K("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:K("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:b=>b.stopPropagation(),children:[r(ri,{label:"Inherit",active:c===null,variant:"inherit",subtext:p===void 0?void 0:p?"on":"off",onClick:()=>d(null)}),r(ri,{label:"On",active:c===!0,variant:"on",onClick:()=>d(!0)}),r(ri,{label:"Off",active:c===!1,variant:"off",onClick:()=>d(!1)})]})]});return r(xh,{expanded:m,onExpandedChange:h,dimmed:!e.enabled,header:x,children:f?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(al,{label:"Model",value:e.modelId,disabled:i,options:g.map(b=>({value:b.id,label:b.name})),onChange:b=>s({...e,modelId:b})}),e.slot==="audio-classifier"&&e.engine&&r(al,{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:b=>{const[v,w]=b.split("/");s({...e,engine:{runtime:v,backend:w,format:w==="coreml"?"coreml":"onnx"}})}}),t?.configSchema?.map(b=>r(xa,{field:b,allFields:t.configSchema??[],step:e,disabled:i,onChange:s},b.key))]})})}function al({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 dC({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:K("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 uC(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 xa({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:p,notIn:f}=a,m=uC(l,n,t);if(c!==void 0&&m!==c||d!==void 0&&m===d||p!==void 0&&!p.includes(m)||f!==void 0&&f.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(al,{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(dC,{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,p=e.min??0,f=e.max??1,m=e.step??.01,h=e.type==="slider"?e.showValue:!0,g="unit"in e?e.unit:void 0,x=e.type==="slider"?e.displayScale:void 0,b=x?d/x: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 b=="number"?b.toFixed(2).replace(/\.?0+$/,""):b,g?` ${g}`:""]})]}),e.description&&r("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:e.description}),r("input",{type:"range",min:p,max:f,step:m,value:d,disabled:o||e.disabled,onChange:v=>i(Number(v.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:p=>i(p.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:p=>i(p.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 ri({label:e,active:t,variant:n,subtext:o,onClick:s}){return u("button",{type:"button",onClick:s,className:K("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 Kh(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 pC(e,t,n){return n?{enabled:n.enabled??t.enabled,modelId:n.modelId??t.modelId,settings:n.settings??t.settings}:t}function fC({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(xa,{field:a,allFields:e.configSchema??[],step:Kh(e,t),disabled:!1,onChange:i=>s({settings:{...i.settings}})},a.key))]})]})}function mC({addon:e,agentDefault:t,agentNodeId:n,currentPatch:o,modelsForFormat:s,onChangePatch:a}){const i=pC("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,...x}=o??{},b=h==="inherit"?x:{...x,enabled:h==="on"};l(b)},d=h=>{const{modelId:g,...x}=o??{},b=h===void 0?x:{...x,modelId:h};l(b)},p=h=>{const{settings:g,...x}=o??{},b=h===void 0?x:{...x,settings:h};l(b)},f=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:K("px-3 py-1 border border-border rounded text-xs capitalize",f===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:()=>p(void 0),children:"Clear"}):r("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>p({...t.settings}),children:"Override"})]}),e.configSchema?.map(g=>r(xa,{field:g,allFields:e.configSchema??[],step:Kh(e,i),disabled:!h,onChange:x=>p({...x.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 ya(e){const{mode:t,addon:n,agentDefault:o,agentNodeId:s,currentPatch:a,onChangeAgentConfig:i,onChangePatch:l,engineFormat:c}=e,d=V(()=>n.models.filter(p=>!!p.formats[c]),[n.models,c]);return t==="agent"?r(fC,{addon:n,agentDefault:o,modelsForFormat:d,onChangeAgentConfig:i}):r(mC,{addon:n,agentDefault:o,agentNodeId:s,currentPatch:a,modelsForFormat:d,onChangePatch:l})}function hC(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 Au={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 gC({slot:e}){const t=Au[e]??Au.classifier;return r("span",{className:K("text-[9px] font-semibold uppercase tracking-widest leading-none",t.className),children:t.label})}const Eu="inline-flex items-center rounded bg-muted px-1.5 py-px text-[9px] font-medium text-foreground-subtle";function bC({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:K(Eu,"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:K(Eu,"bg-emerald-500/10 text-emerald-500"),children:n},`out-${n}`))]})}function xC({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:K("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:K("inline-block h-3 w-3 rounded-full bg-white shadow transition-transform",e?"translate-x-3.5":"translate-x-0.5")})})}function yC(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 vC({node:e,depth:t,agents:n,getCellState:o,onCellClick:s,selectedCell:a,toggleProps:i}){return u(ue,{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(gC,{slot:e.slot}),u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"font-semibold truncate",children:e.addonName}),r(bC,{inputs:e.inputClasses,outputs:e.outputClasses})]})]}),i&&r("span",{className:"pl-2 pt-0.5 shrink-0",children:r(xC,{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:K("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:yC(c)},l.agentNodeId)})]})}function kc({tree:e,agents:t,getCellState:n,onCellClick:o,selectedCell:s,onToggleEnabled:a}){const i=V(()=>hC(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(p=>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:p.agentNodeId}),r("div",{className:"text-[10px] text-foreground-subtle truncate",children:p.engineLabel})]},p.agentNodeId)),i.map(({node:p,depth:f})=>{const m=c&&d!==void 0?n(p.addonId,d):null,h=c&&m!==null?{enabled:m.kind==="enabled",onChange:g=>a?.(p.addonId,g),disabled:m.kind==="na"}:void 0;return r(vC,{node:p,depth:f,agents:t,getCellState:n,onCellClick:o,selectedCell:s,toggleProps:h},p.addonId)})]})})}const Wh=typeof globalThis<"u"?globalThis.__camstackTrpcReact:void 0,S=Wh??vN();typeof globalThis<"u"&&!Wh&&(globalThis.__camstackTrpcReact=S);const Sc=mn("camstack:system",null);function Cc({system:e,children:t}){return r(Sc.Provider,{value:e,children:t})}function Le(){const e=xe(Sc);if(!e)throw new Error("useSystem(): no <SystemProvider> in tree");return e}function wC(){return xe(Sc)}function ht(e,t){const n=Le(),o=re(t);o.current=t;const[s,a]=P(n.connectionVersion);Y(()=>n.subscribeConnectionEvents((i,l)=>{i==="connected"&&a(l)}),[n]),Y(()=>n.subscribeEvent(e,l=>{o.current(l)}),[n,e,s])}function il(e){const t=re(e);return t.current=e,t}function Br(e,t){const[n,o]=P(null),s=il(t);return ht(e,a=>{const i=a.data,l=s.current;l&&!l(i)||o(i)}),n}function Mc(e,t,n){const[o,s]=P(()=>new Map),a=il(t),i=il(n);ht(e,c=>{const d=c.data,p=i.current;if(p&&!p(d))return;const f=a.current(d);s(m=>{const h=new Map(m);return h.set(f,d),h})});const l=V(()=>Array.from(o.values()),[o]);return{map:o,values:l}}function Fr(){const{data:e,isLoading:t}=S.nodes.topology.useQuery(void 0,{staleTime:6e4}),o=Br("cluster.topology-snapshot")?.nodes??e;return{nodes:V(()=>{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 Yh({selectedNodeId:e,onSelect:t,label:n="Node",hideIcon:o=!1,alwaysShow:s=!1}){const{nodes:a}=Fr();return!s&&a.length<=1?null:u("div",{className:"flex items-center gap-1.5",children:[!o&&r(i5,{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:K("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 NC={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 kC({status:e,showDot:t=!0,showLabel:n=!0,size:o="sm",className:s}){const a=NC[e];return u("span",{className:K("inline-flex items-center gap-1.5",o==="sm"?"text-xs":"text-sm",s),children:[t&&r("span",{className:K("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 SC={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 CC({provider:e,showLabel:t=!0,className:n}){const o=SC[e];return u("span",{className:K("inline-flex items-center gap-1.5 text-xs",n),children:[r("span",{className:K("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 MC={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 Zh({children:e,variant:t="neutral",mono:n,className:o}){return r("span",{className:K("inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-bold leading-tight",n&&"font-mono",MC[t],o),children:e})}function AC({version:e,preRelease:t,className:n}){const o=t??/-(alpha|beta|rc|dev|canary|next)/i.test(e);return r(Zh,{variant:o?"warning":"success",mono:!0,className:n,children:e})}function EC({label:e,description:t,error:n,required:o,children:s,orientation:a="vertical",className:i}){const l=a==="horizontal";return u("div",{className:K("flex gap-2",l?"flex-row items-center justify-between":"flex-col",i),children:[u("div",{className:K(l?"flex-1":""),children:[u(fc,{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:K(l?"shrink-0":""),children:s}),n&&r("p",{className:"text-danger text-xs",children:n})]})}function IC({title:e,subtitle:t,actions:n,className:o}){return u("div",{className:K("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 Ac({icon:e,title:t,description:n,action:o,className:s}){return u("div",{className:K("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 PC={danger:{box:"border-danger/40 bg-danger/10",icon:"text-danger",title:"text-danger",message:"text-danger"},warning:{box:"border-amber-500/40 bg-amber-500/10",icon:"text-amber-600 dark:text-amber-400",title:"text-amber-700 dark:text-amber-300",message:"text-amber-700 dark:text-amber-300"}};function va({message:e,title:t,onRetry:n,action:o,variant:s="danger",className:a}){const i=PC[s],l=s==="warning"?zr:Tr;return u("div",{role:"alert",className:K("flex items-start gap-2.5 rounded border px-3 py-2.5",i.box,a),children:[r(l,{className:K("h-4 w-4 mt-0.5 shrink-0",i.icon),"aria-hidden":"true"}),u("div",{className:"flex-1 min-w-0",children:[t&&r("p",{className:K("text-xs font-semibold",i.title),children:t}),r("div",{className:K("text-xs break-words",i.message,t?"mt-0.5":""),children:e})]}),o??(n&&u("button",{type:"button",onClick:n,className:K("shrink-0 inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium","border border-current/30 hover:bg-current/10 transition-colors",i.message),children:[r(ga,{className:"h-3 w-3","aria-hidden":"true"}),"Retry"]}))]})}const Xh=mn("camstack:confirm-dialog",null);function et(){const e=xe(Xh);if(!e)throw new Error("useConfirm must be used within ConfirmDialogProvider");return e.confirm}function Jh({children:e}){const[t,n]=P(null),o=U(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(Xh.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 _C({value:e,label:t,trend:n,className:o}){return u(an,{className:K("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:K("inline-flex items-center gap-0.5 text-xs font-medium",n.direction==="up"?"text-success":"text-danger"),children:[n.direction==="up"?r(E5,{className:"h-3 w-3"}):r(P5,{className:"h-3 w-3"}),n.value,"%"]})]}),r("span",{className:"text-xs text-foreground-muted",children:t})]})}function $C({items:e,className:t}){return r("dl",{className:K("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 DC({children:e,maxHeight:t=300,className:n}){const[o,s]=P(!1),a=U(()=>{navigator.clipboard.writeText(e).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})},[e]);return u("div",{className:K("relative group",n),children:[r(yc,{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(pc,{icon:o?Oo:_n,"aria-label":"Copy code",variant:"ghost",size:"sm",onClick:a})})]})}function LC({filters:e,values:t,onChange:n,className:o}){const s=nr(),[a,i]=P(!1),l=(d,p)=>{n({...t,[d]:p})},c=Object.values(t).filter(d=>d!==void 0&&d!=="").length;if(s){const d=e.find(f=>f.type==="search"),p=e.some(f=>f.type!=="search");return u("div",{className:K("flex items-center gap-2",o),children:[d&&r(Fs,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:f=>l(d.key,f.target.value),leftSlot:r(xo,{className:"h-3 w-3 text-foreground-subtle"}),className:"flex-1"}),p&&u(ue,{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(m5,{className:"h-3.5 w-3.5"}),"Filters",c>0&&r(Lt,{variant:"info",className:"ml-1 text-[10px] px-1 py-0",children:c})]}),r(xc,{open:a,onClose:()=>i(!1),title:"Filters",children:r("div",{className:"flex flex-col gap-3",children:e.filter(f=>f.type!=="search").map(f=>{switch(f.type){case"select":return u("div",{children:[r("label",{className:"text-xs text-foreground-muted mb-1 block",children:f.label}),r(yo,{options:f.options,value:t[f.key]??"",onChange:m=>l(f.key,m.target.value),className:"w-full"})]},f.key);case"badge-toggle":return r("div",{className:"flex items-center gap-1 flex-wrap",children:f.options.map(m=>{const g=t[f.key]===m.value;return r("button",{type:"button",onClick:()=>l(f.key,g?void 0:m.value),children:r(Lt,{variant:g?"info":"default",className:"cursor-pointer",children:m.label})},m.value)})},f.key);default:return null}})})})]})]})}return r("div",{className:K("flex items-center gap-2 flex-wrap",o),children:e.map(d=>{switch(d.type){case"search":return r(Fs,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:p=>l(d.key,p.target.value),leftSlot:r(xo,{className:"h-3 w-3 text-foreground-subtle"}),className:"w-48"},d.key);case"select":return r(yo,{options:d.options,value:t[d.key]??"",onChange:p=>l(d.key,p.target.value),className:"w-36"},d.key);case"badge-toggle":return r("div",{className:"flex items-center gap-1",children:d.options.map(p=>{const m=t[d.key]===p.value;return r("button",{type:"button",onClick:()=>l(d.key,m?void 0:p.value),children:r(Lt,{variant:m?"info":"default",className:"cursor-pointer",children:p.label})},p.value)})},d.key);default:return null}})})}function ll({label:e,icon:t,href:n,badge:o,active:s=!1,className:a}){return u("a",{href:n,className:K("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(Lt,{className:"ml-auto text-[10px] px-1.5 py-0",children:o})]})}function cl({logo:e,sections:t,footer:n,onNavigate:o,className:s}){return u("nav",{className:K("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:K(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(ll,{...l},l.href))})]},i))}),n&&n.length>0&&u("div",{className:"shrink-0 px-1 pb-1",children:[r(mc,{className:"mb-1"}),r("div",{className:"flex flex-col gap-0.5",onClick:o,children:n.map(a=>r(ll,{...a},a.href))})]})]})}function TC({sidebar:e,header:t,mobileLogo:n,mobileActions:o,children:s,className:a}){const i=nr(),[l,c]=P(!1);return u("div",{className:K("flex h-screen",a),children:[!i&&r(cl,{...e,className:K("w-44",e.className)}),i&&r(vc,{open:l,onClose:()=>c(!1),width:"w-64",children:r(cl,{...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(IS,{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,p)=>{const f=p===t.breadcrumbs.length-1;return u("span",{className:"flex items-center gap-1",children:[p>0&&r(Pn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),d.href&&!f?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})]},p)})}),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 RC={online:"bg-success",offline:"bg-danger",warning:"bg-warning",unknown:"bg-foreground-subtle"};function OC({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:K("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:K("h-2 w-2 rounded-full shrink-0",RC[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((p,f)=>{const m=K("rounded px-1.5 py-0.5 text-[10px] flex items-center gap-0.5",o?"bg-primary/20":"bg-surface-hover",p.onClick&&"hover:opacity-80 transition-opacity cursor-pointer");return p.onClick?u("button",{onClick:h=>{h.stopPropagation(),p.onClick()},className:m,children:[p.icon,p.label]},f):u("span",{className:m,children:[p.icon,p.label]},f)})}),!d&&i&&i.length>0&&r("div",{className:"flex items-center gap-0.5 mt-2 -mb-1",children:i.map((p,f)=>r("button",{onClick:m=>{m.stopPropagation(),p.onClick()},className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",title:p.label,"aria-label":p.label,children:p.icon},f))}),d&&l&&r("div",{className:"mt-2",onClick:p=>p.stopPropagation(),children:l})]})}function zC({children:e,minCardWidth:t=220,gap:n=3,className:o}){return r("div",{className:K("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 BC="capability.binding-changed";function Ct(e,t){const[n,o]=P(null);return Y(()=>{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:BC},{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]),V(()=>n?wN(e,n):null,[e,n])}function cn(e){const t=U(o=>e?e.subscribe(()=>o()):()=>{},[e]),n=U(()=>e?.value,[e]);return ma(t,n,n)}function eg(e,t,n){const o=Ct(e,t),s=o?n(o.state):void 0;return cn(s)}function jr(e){const t=Ct(e.trpc,e.deviceId),n=t!==null?e.slice(t):void 0,o=cn(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 FC(e){return e.parentDeviceId===null?"top-level":e.role?"accessory":"adopted"}const jC={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 HC(e){const t=jC[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 VC={siren:ha,floodlight:ch,spotlight:hh,"pir-sensor":ph,chime:TS,autotrack:ic,nightvision:dc,"privacy-mask":cc,doorbell:sh},UC={camera:ac,hub:ol,nvr:ol,light:ch,siren:ha,switch:C5,sensor:ph,thermostat:k5,button:Vk,generic:uc};function tg(e){return e.role?VC[e.role]??uc:UC[e.type.toLowerCase()]??ac}const ng={"native-snapshot":gS,"two-way-audio":dh,"pan-tilt-zoom":ic,"ptz-autotrack":MS,"doorbell-button":sh,"motion-trigger":Nn,"battery-operated":rh,rebootable:mh},rg={"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"},qC={"native-snapshot":"snapshot",rebootable:"reboot","pan-tilt-zoom":"ptz","ptz-autotrack":"ptz-autotrack","two-way-audio":"intercom","motion-trigger":"motion-trigger"},og=new Set(["camera","hub","nvr"]);function sg(e){return!og.has(e.type.toLowerCase())}function Iu(e){return e.role?!0:!og.has(e.type.toLowerCase())}function ag(e){return(e.features??[]).includes("motion-trigger")}function QC(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 GC({trpc:e,accessoryChildren:t,adoptedChildren:n,onNavigate:o}){return u("div",{className:"border-t border-border-subtle/50",children:[n.length>0&&r(Pu,{trpc:e,label:"Adopted devices",rows:n,onNavigate:o}),t.length>0&&r(Pu,{trpc:e,label:"Accessories",rows:t,onNavigate:o})]})}function Pu({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(KC,{trpc:e,child:s,onNavigate:o},s.id))})]})}function KC({trpc:e,child:t,onNavigate:n}){const o=!t.disabled,s=o&&sg(t),a=o&&ag(t),i=tg(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(YC,{trpc:e,deviceId:t.id,features:t.features}),s&&r(WC,{trpc:e,deviceId:t.id}),r("span",{className:K("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 WC({trpc:e,deviceId:t}){const{dev:n,cap:o,slice:s,available:a}=jr({trpc:e,deviceId:t,cap:f=>f.switch,slice:f=>f.state.switch}),[i,l]=P(!1);if(n!==null&&!o)return null;const c=s?.on===!0,d={transform:c?"translateX(14px)":"translateX(2px)"},p=async f=>{if(f.stopPropagation(),!(i||!a||!o)){l(!0);try{await o.setState({on:!c})}finally{l(!1)}}};return r("button",{type:"button",onClick:f=>{p(f)},disabled:i||!a,className:K("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:K("absolute h-3 w-3 rounded-full transition-all",c?"bg-success":"bg-foreground-subtle"),style:d})})}function YC({trpc:e,deviceId:t,features:n}){const{dev:o,cap:s,slice:a,available:i}=jr({trpc:e,deviceId:t,cap:f=>f.motionTrigger,slice:f=>f.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:n}),[l,c]=P(!1);if(o!==null&&!s)return null;const d=a?.enabled===!0,p=async f=>{if(f.stopPropagation(),!(l||!i||!s)){c(!0);try{await s.setMotionTrigger({enabled:!d})}finally{c(!1)}}};return r("button",{type:"button",onClick:f=>{p(f)},disabled:l||!i,className:K("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(Nn,{className:"h-2.5 w-2.5"})})}function ig({trpc:e,device:t,flags:n}){if(!!t.disabled)return null;const s=t.type.toLowerCase(),a=n.showSwitchToggle&&sg(t),i=ag(t),l=s==="hub"||s==="nvr",c=(t.features??[]).includes("rebootable"),d=l&&c;return u(ue,{children:[i&&r(XC,{trpc:e,deviceId:t.id,features:t.features}),a&&r(ZC,{trpc:e,deviceId:t.id}),d&&r(e3,{trpc:e,deviceId:t.id})]})}function ZC({trpc:e,deviceId:t}){const{dev:n,cap:o,slice:s,available:a}=jr({trpc:e,deviceId:t,cap:f=>f.switch,slice:f=>f.state.switch}),[i,l]=P(!1);if(n!==null&&!o)return null;const c=s?.on===!0,d={transform:c?"translateX(14px)":"translateX(2px)"},p=async f=>{if(f.stopPropagation(),!(i||!a||!o)){l(!0);try{await o.setState({on:!c})}finally{l(!1)}}};return r("button",{type:"button",onClick:f=>{p(f)},disabled:i||!a,className:K("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:K("absolute h-3 w-3 rounded-full transition-all",c?"bg-success":"bg-foreground-subtle"),style:d})})}function XC({trpc:e,deviceId:t,features:n}){const{dev:o,cap:s,slice:a,available:i}=jr({trpc:e,deviceId:t,cap:f=>f.motionTrigger,slice:f=>f.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:n}),[l,c]=P(!1);if(o!==null&&!s)return null;const d=a?.enabled===!0,p=async f=>{if(f.stopPropagation(),!(l||!i||!s)){c(!0);try{await s.setMotionTrigger({enabled:!d})}finally{c(!1)}}};return r("button",{type:"button",onClick:f=>{p(f)},disabled:l||!i,className:K("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(Nn,{className:"h-2.5 w-2.5"})})}const oi=168,JC=4;function e3({trpc:e,deviceId:t}){const{dev:n,cap:o}=jr({trpc:e,deviceId:t,cap:b=>b.reboot,slice:()=>{}}),s=re(null),a=re(null),[i,l]=P(null),[c,d]=P(!1),p=n!==null&&o!==void 0&&o!==null,f=i!==null,m=()=>l(null),h=()=>{const b=s.current;if(!b)return;const v=b.getBoundingClientRect(),w=v.right-oi,y=Math.max(8,Math.min(w,window.innerWidth-oi-8)),N=v.bottom+JC;l({top:N,left:y})};if(Y(()=>{if(!f)return;const b=w=>{const y=s.current,N=a.current,k=w.target;k!==null&&(y&&y.contains(k)||N&&N.contains(k)||m())},v=w=>{w.key==="Escape"&&(w.stopPropagation(),m())};return document.addEventListener("mousedown",b),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",v)}},[f]),n!==null&&!o)return null;const g=b=>{b.stopPropagation(),f?m():h()},x=async()=>{if(!(c||!p||!o)){d(!0),m();try{await o.reboot({})}finally{d(!1)}}};return u(ue,{children:[r("button",{ref:s,type:"button",onClick:g,disabled:c||!p,className:K("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||!p)&&"opacity-50",f&&"bg-surface-hover text-foreground"),title:"More actions","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":f,children:r(ah,{className:"h-3 w-3"})}),i&&To(r("div",{ref:a,role:"menu",style:{position:"fixed",top:i.top,left:i.left,width:oi},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-1",onClick:b=>b.stopPropagation(),children:u("button",{type:"button",role:"menuitem",onClick:()=>{x()},disabled:c||!p,className:K("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(mh,{className:"h-3 w-3 shrink-0 text-foreground-subtle"}),r("span",{children:"Reboot device"})]})}),document.body)]})}const t3=Object.freeze([]);function n3(e){return e==="native"?"native":"enhanced"}function r3(e){return e.map(t=>({kind:"marker",feature:t}))}function o3(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=qC[a];if(i===void 0){s.push({kind:"marker",feature:a});continue}const l=n.get(i);l&&s.push({kind:n3(l.kind),feature:a,capName:i})}return s}function s3(e,t,n){const[o,s]=P(null),[a,i]=P(!1),[l,c]=P(!0);return Y(()=>{if(t===null){s(null),i(!1),c(!1);return}let d=!1;c(!0),i(!1);const p=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)}};p();const f=e.live?.onEvent.subscribe({category:"capability.binding-changed"},{onData:m=>{const h=m.data?.source;if(!h){p();return}h.type==="device"&&h.id===t&&p()}});return()=>{d=!0,f?.unsubscribe()}},[e,t]),n.length===0?{loading:l,resolved:t3}:l||a||!o?{loading:l,resolved:r3(n)}:{loading:!1,resolved:o3(n,o)}}const a3=[];function lg({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??a3,d=a&&c.length>0,{resolved:p}=s3(e,d?t.id:null,c),f=d&&p.length>0;return!l&&!f?null:u("div",{className:"flex items-center gap-1.5 flex-nowrap whitespace-nowrap min-w-0",children:[l&&r(i3,{accessoryCount:o,adoptedCount:s}),f&&r(l3,{resolved:p})]})}function i3({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 cg=240,_u=200;function l3({resolved:e}){const t=re(null),[n,o]=P(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(),p=window.innerHeight-l.bottom>=_u?l.bottom+4:l.top-_u-4,f=Math.max(8,Math.min(l.left,window.innerWidth-cg-8));o({top:p,left:f})},onMouseLeave:()=>o(null),children:[e.map(i=>{const l=ng[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:rg[i.feature]??i.feature,children:r(l,{className:"h-2.5 w-2.5"})},i.feature):null}),n&&To(r(c3,{resolved:e,position:n}),document.body)]})}function c3({resolved:e,position:t}){return u("div",{style:{position:"fixed",top:t.top,left:t.left,width:cg,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(d3,{entry:n},n.feature))})]})}function d3({entry:e}){const t=ng[e.feature],n=rg[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(u3,{kind:e.kind})]})}function u3({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:K("text-[8.5px] px-1 rounded",e==="native"?"bg-success/15 text-success":"bg-primary/15 text-primary"),children:e})}function dg({device:e,variant:t,flags:n,parent:o,integrationIcon:s,hasChildren:a,expanded:i,onToggleExpand:l,onNavigateToParent:c}){const d=tg(e);return u("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[n.showChildrenAccordion&&a?r("button",{type:"button",onClick:p=>{p.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(er,{className:"h-3 w-3"}):r(Pn,{className:"h-3 w-3"})}):n.showChildrenAccordion?r("span",{className:"h-3.5 w-3.5 flex-shrink-0"}):null,r(d,{className:K("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:K("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:QC(e.stableId)})]}),n.showParentBadge&&o&&u("button",{type:"button",onClick:p=>{p.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(ol,{className:"h-2.5 w-2.5 shrink-0"}),u("span",{className:"truncate",children:["Under: ",o.name]})]})]})]})}function Ec(e,t){return eg(e,t,o=>o.battery)??null}function Ic(e,t){const n=Ct(e,t),o=re(!1),{data:s,isLoading:a,isFetching:i,refetch:l}=Dr({queryKey:["device",t,"snapshot"],queryFn:()=>{if(!n)throw new Error("useDeviceSnapshotImage: device proxy not ready");const p=o.current;return o.current=!1,n.snapshot?.getSnapshot({force:p})??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 p3(e){return e<=10?Nk:e<=30?vk:e>=95?xk:rh}function f3(e,t){return t!=="none"?"text-emerald-400":e<=10?"text-rose-400":e<=30?"text-amber-400":"text-foreground-subtle"}function Pc({status:e,variant:t="compact",className:n}){if(!e)return null;const o=p3(e.percentage),s=f3(e.percentage,e.charging),a=e.charging==="solar"?hh:e.charging==="dc"?HS:null,i=e.sleeping;return u("span",{className:K("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(dc,{className:"h-3 w-3 text-blue-300"}),t==="full"&&e.charging!=="none"&&r("span",{className:"text-foreground-subtle",children:e.charging})]})}function ug({trpc:e,device:t,status:n,enabled:o,showStatusPills:s=!1}){const a=o&&t.online,i=Ic(e,a?t.id:null),l=(t.features??[]).includes("battery-operated"),c=s&&l&&!t.disabled,d=Ec(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(Pc,{status:d}),o&&r(m3,{deviceName:t.name,snapshotUrl:i.src,status:n})]})}const si=288,$u=196,ai=8;function m3({deviceName:e,snapshotUrl:t,status:n}){const o=re(null),[s,a]=P(null),i=n==="offline"||n==="disabled",l=()=>{const d=o.current;if(!d)return;const p=d.getBoundingClientRect(),f=p.top,m=window.innerHeight-p.bottom,h=f<$u+ai&&m>f,g=h?p.bottom+ai:p.top-$u-ai,x=p.right-si,b=Math.max(8,Math.min(x,window.innerWidth-si-8));a({top:g,left:b,placeBelow:h})},c=()=>a(null);return u(ue,{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(Rr,{className:"h-3.5 w-3.5"})}),s&&To(u("div",{style:{position:"fixed",top:s.top,left:s.left,width:si,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 pg({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:K("h-1.5 w-1.5 rounded-full flex-shrink-0",t),title:n})}function vo(e){const{trpc:t,device:n,parent:o,integrationIcon:s,onNavigate:a,className:i}=e,l=HC(e),c=e.variant??"compact",d=e.view??"card",p=!n.disabled,f=n.isCamera??n.type.toLowerCase()==="camera",m=e.children??[],h=m.filter(Iu),g=m.filter(D=>!Iu(D)),x=m.length>0,[b,v]=P(!1),w=e.expanded??b,y=e.onToggleExpand??(()=>v(D=>!D)),N=D=>{a?.(D)},k=e.indentLevel??(e.isAccessoryRow?2:0),C=p?n.online?"online":"offline":"disabled";return d==="table"?r(g3,{trpc:t,device:n,variant:c,flags:l,parent:o??null,integrationIcon:s??null,accessoryCount:h.length,adoptedCount:g.length,hasChildren:x,expanded:w,onToggleExpand:y,onNavigate:N,displayStatus:C,isCamera:f,showSnapshot:l.showSnapshot&&f,isAccessoryRow:e.isAccessoryRow??!1,indentLevel:k,className:i}):u("div",{className:K("rounded-lg border border-border bg-surface transition-colors",!p&&"opacity-60",i),children:[u("div",{onClick:()=>N(n.id),className:K("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(dg,{device:n,variant:c,flags:l,parent:o??null,integrationIcon:s??null,hasChildren:x,expanded:w,onToggleExpand:y,onNavigateToParent:N}),r(lg,{trpc:t,device:n,flags:l,accessoryCount:h.length,adoptedCount:g.length,showFeatureRow:!1}),r(ug,{trpc:t,device:n,status:C,enabled:l.showSnapshot&&f,showStatusPills:!0}),r(ig,{trpc:t,device:n,flags:l}),r(pg,{status:C})]}),w&&x&&r(GC,{trpc:t,accessoryChildren:h,adoptedChildren:g,onNavigate:N})]})}const h3={0:"pl-2",1:"pl-6",2:"pl-8"};function g3(e){const{trpc:t,device:n,variant:o,flags:s,parent:a,integrationIcon:i,accessoryCount:l,adoptedCount:c,hasChildren:d,expanded:p,onToggleExpand:f,onNavigate:m,displayStatus:h,isCamera:g,showSnapshot:x,isAccessoryRow:b,indentLevel:v,className:w}=e;return u("tr",{onClick:()=>m(n.id),className:K("cursor-pointer hover:bg-surface-hover transition-colors",!s.showChildrenAccordion&&"border-b border-border-subtle/40",b&&"bg-foreground-subtle/[0.03]",w),children:[r("td",{className:K("py-2 align-middle pr-2",h3[v]),children:r(dg,{device:n,variant:o,flags:s,parent:a,integrationIcon:i,hasChildren:d,expanded:p,onToggleExpand:f,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(lg,{trpc:t,device:n,flags:s,accessoryCount:l,adoptedCount:c,showFeatureRow:!0})}),r("td",{className:"px-2 py-2 align-middle",children:r(ug,{trpc:t,device:n,status:h,enabled:x&&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(ig,{trpc:t,device:n,flags:s}),r(pg,{status:h})]})})]})}function fg(e,t){const[n,o]=P(e);return Y(()=>{const s=setTimeout(()=>o(e),t);return()=>clearTimeout(s)},[e,t]),n}const b3=new Set(["hub","nvr"]);function x3(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(b3.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 Du=2;function y3(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-Du),s=Math.min(t-1,e+Du);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 v3({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=y3(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:K("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(Tk,{className:"h-3 w-3"})}),c.map((d,p)=>{if(d.kind==="ellipsis")return r("span",{className:"px-1 text-foreground-subtle/60 select-none",children:"…"},`e-${p}`);const f=d.n===e;return r("button",{type:"button",onClick:()=>o(d.n),className:K("inline-flex items-center justify-center h-7 min-w-7 px-1.5 rounded border text-[10.5px] font-medium transition-colors",f?"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:K("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(Pn,{className:"h-3 w-3"})})]})]})}function w3({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:K("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(NS,{className:"h-3.5 w-3.5"})}),r("button",{type:"button",onClick:()=>t("table"),className:K("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(v5,{className:"h-3.5 w-3.5"})})]}),n&&n.length>0&&u(ue,{children:[r(Lu,{children:"Type"}),r(ii,{active:o===null,onClick:()=>s(null),children:"All"}),n.map(d=>r(ii,{active:o===d,onClick:()=>s(o===d?null:d),children:N3(d)},d))]}),!c&&a&&a.length>0&&u(ue,{children:[r(Lu,{children:"Integration"}),a.map(d=>r(ii,{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 ii({active:e,icon:t,onClick:n,showClearIcon:o,children:s}){return u("button",{type:"button",onClick:n,className:K("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(Je,{className:"h-2.5 w-2.5 opacity-70"})]})}function N3(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function k3({variant:e,onClearFilters:t}){return u("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r(xS,{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 Tu(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 S3(e,t){try{localStorage.setItem(`camstack:${e}:lastFilters`,JSON.stringify(t))}catch{}}function Ru(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,p=o.get(Vt(e,"type"))??n.type??null,f=o.get(Vt(e,"q"))??n.q??"";return{view:a,page:c,addon:d,type:p,q:f}}function C3(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 M3(e){const{scope:t,defaultView:n,lsKey:o}=e,[s,a]=P(()=>{const g=Tu(o);return Ru(t,n,g)}),i=re(s);i.current=s,Y(()=>{const g=()=>{const x=Tu(o),b=Ru(t,n,x);i.current=b,a(b)};return window.addEventListener("popstate",g),()=>window.removeEventListener("popstate",g)},[t,n,o]);const l=U(g=>{const x=g(i.current);i.current=x,a(x),C3(t,x,n),S3(o,{view:x.view,addon:x.addon,type:x.type,q:x.q})},[t,n,o]),c=U(g=>l(x=>({...x,view:g})),[l]),d=U(g=>l(x=>({...x,page:g})),[l]),p=U(g=>l(x=>({...x,addon:g,page:1})),[l]),f=U(g=>l(x=>({...x,type:g,page:1})),[l]),m=U(g=>l(x=>({...x,q:g,page:1})),[l]),h=U(()=>l(g=>({...g,addon:null,type:null,q:"",page:1})),[l]);return{state:s,setView:c,setPage:d,setAddon:p,setType:f,setQ:m,clearFilters:h}}const A3={cards:24,table:50};function wo(e){const{devices:t,trpc:n,defaultView:o="table",filters:s,forceAddon:a,resolveIntegrationIcon:i,resolveParent:l,onNavigate:c,pageSize:d=A3,urlScope:p="root",lsKey:f=p==="root"?"devices":"integrations:nested"}=e,m=M3({scope:p,defaultView:o,lsKey:f}),h=m.state.view,g=h==="cards"?d.cards:d.table,[x,b]=P(m.state.q),v=fg(x,300);Y(()=>{v!==m.state.q&&m.setQ(v)},[v]);const w=a??m.state.addon,y=V(()=>{const R=m.state.q.toLowerCase().trim();return t.filter(M=>!(w&&M.addonId!==w||m.state.type&&M.type!==m.state.type||R&&!M.name.toLowerCase().includes(R)&&!M.stableId.toLowerCase().includes(R)))},[t,w,m.state.type,m.state.q]),N=V(()=>x3(y),[y]),k=V(()=>{if(m.state.q.trim()==="")return new Set;const R=m.state.q.toLowerCase().trim(),M=new Set;for(const[$,L]of N.accessoriesByParent.entries())L.some(O=>O.name.toLowerCase().includes(R)||O.stableId.toLowerCase().includes(R))&&M.add($);return M},[N.accessoriesByParent,m.state.q]),C=N.topLevel.length,D=Math.max(1,Math.ceil(C/g)),E=Math.min(m.state.page,D),I=(E-1)*g,z=N.topLevel.slice(I,I+g);Y(()=>{E!==m.state.page&&m.setPage(E)},[E]),D3();const A=w!=null||m.state.type!==null||m.state.q!=="",T=C===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(w3,{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(xo,{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:x,onChange:R=>b(R.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(k3,{variant:A?"filtered":"nofilter",onClearFilters:A?m.clearFilters:void 0}):h==="cards"?r(E3,{rows:z,accessoriesByParent:N.accessoriesByParent,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}):r(_3,{rows:z,accessoriesByParent:N.accessoriesByParent,autoExpandedParents:k,devices:y,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}),r(v3,{currentPage:E,totalItems:C,pageSize:g,onPageChange:m.setPage}),a===void 0&&A&&C>0&&u("p",{className:"text-[11px] text-foreground-subtle",children:["Showing ",C," of ",t.length," devices",w&&u(ue,{children:[" ","· filtered by"," ",r("strong",{className:"text-primary",children:s?.addons?.find(R=>R.id===w)?.name??w})]})]})]})}function E3({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(vo,{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 I3=new Set(["hub","nvr"]);function P3(e,t){return e.parentDeviceId===null||t===null?0:I3.has(t.toLowerCase())?1:0}function _3({rows:e,accessoriesByParent:t,autoExpandedParents:n,devices:o,trpc:s,resolveIntegrationIcon:a,resolveParent:i,onNavigate:l}){const c=V(()=>{const d=new Map;for(const p of o)d.set(p.id,p.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 p=t.get(d.id)??[],f=p.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($3,{parent:d,accessories:p,hasAccessories:f,forceExpanded:m,trpc:s,integrationIcon:a?.(d.addonId)??null,parentRowParent:h,indentLevel:P3(d,g),onNavigate:l??null},d.id)})})]})})}function $3({parent:e,accessories:t,hasAccessories:n,forceExpanded:o,trpc:s,integrationIcon:a,parentRowParent:i,indentLevel:l,onNavigate:c}){const[d,p]=P(o),f=re(o);return Y(()=>{f.current!==o&&(p(o),f.current=o)},[o]),u(ue,{children:[r(vo,{trpc:s,device:e,view:"table",integrationIcon:a,parent:i,children:t,onNavigate:c??void 0,showChildrenAccordion:n,expanded:d,onToggleExpand:()=>p(g=>!g),indentLevel:l}),n&&d&&t.map(g=>r(vo,{trpc:s,device:g,view:"table",integrationIcon:null,parent:null,isAccessoryRow:!0,showChildrenAccordion:!1,onNavigate:c??void 0},g.id))]})}function D3(){we()}function L3({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(tS,{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(b5,{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 T3(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(p=>p.addons).find(p=>p.id===i.addonId);let c=i.modelId;if(l&&!l.models.some(p=>p.id===c)){const p=l.defaultModelId;o.push(`Model "${c}" not available for ${i.addonId} — using "${p}"`),c=p}const d=i.children.map(p=>s(p)).filter(p=>p!==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 R3(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 li(e){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:!0,modelId:e.defaultModelId,children:[]}}function ci({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(Gk,{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 _c({schema:e,steps:t,onChange:n,templates:o,selectedTemplateId:s,onSelectTemplate:a,onSaveTemplate:i,onUpdateTemplate:l,onDeleteTemplate:c,readOnly:d=!1,excludeAddons:p=[],hideTemplates:f=!1,showOnlyEnabled:m=!1,showSlotLabels:h=!1,toggleMode:g="simple",overrides:x={},onOverrideChange:b,inheritedEnabledByAddon:v={},hideModelAndSettings:w=!1}){const y=H=>({toggleMode:g,hideModelAndSettings:w,...g==="threeState"?{overrideState:x[H]!==void 0?x[H]:null,onOverrideChange:b?_=>b(H,_):void 0,inheritedEnabled:v[H]}:{}}),N=V(()=>new Set(p),[p]),k=V(()=>R3(e),[e]),[C,D]=P([]),E=s?JSON.stringify(t)!==JSON.stringify(o.find(H=>H.id===s)?.steps):!1;function I(H){const _=H.target.value||null;if(_){const q=o.find(G=>G.id===_);if(q){const G=T3(q.steps,e);D([...G.warnings])}}else D([]);a(_)}function z(){s&&l(s,t)}function A(){const H=window.prompt("Template name:");H?.trim()&&i(H.trim(),t)}function T(){if(!s)return;const H=o.find(_=>_.id===s);H&&window.confirm(`Delete template "${H.name}"?`)&&c(s)}function R(H){n(t.map(_=>_.addonId!==H.addonId?_:M(H)))}function M(H){const _=H.children.some(q=>q.enabled||q.children.some(G=>G.enabled));return{...H,enabled:H.enabled||_,children:H.children.map(q=>{const G=q.children.some(Q=>Q.enabled);return{...q,enabled:q.enabled||G}})}}function $(H,_){const q=li(_);n(t.map(G=>G.addonId!==H?G:{...G,children:[...G.children,q]}))}function L(H){const _=new Set;for(const q of H){_.add(q.addonId);for(const Q of q.children)_.add(Q.addonId);const G=L(q.children);for(const Q of G)_.add(Q)}return _}const O=L(t);function F(H){const _=k.get(H.addonId);if(!_)return[];const G=e.slots.find(X=>X.id===_.slot)?.parentSlot==null,Q=_.childSlots,J=new Set(H.children.map(X=>X.addonId)),Z=[];for(const X of e.slots)if(Q.includes(X.id))for(const oe of X.addons){if(J.has(oe.id)||N.has(oe.id))continue;const he=oe.inputClasses.length===0;if(he&&!G)continue;(he||oe.inputClasses.some(W=>H.outputClasses.includes(W)))&&Z.push(oe)}return Z}function B(H){const _=m?{...H,children:H.children.filter(G=>G.enabled).map(G=>({...G,children:G.children.filter(Q=>Q.enabled)}))}:H,q=m?[]:F(_);return u("div",{className:"space-y-1.5",children:[r(As,{step:_,schema:k.get(_.addonId)??null,allSchemas:k,onChange:R,onDelete:d?void 0:G=>n(t.filter(Q=>Q.addonId!==G)),readOnly:d,...y(_.addonId)}),(_.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"}),_.children.map(G=>{const Q=F(G);return u("div",{className:"space-y-1.5",children:[r(As,{step:G,schema:k.get(G.addonId)??null,allSchemas:k,depth:1,onChange:J=>{R({..._,children:_.children.map(Z=>Z.addonId===J.addonId?J:Z)})},onDelete:d?void 0:J=>{R({..._,children:_.children.filter(Z=>Z.addonId!==J)})},readOnly:d,...y(G.addonId)}),(G.children.length>0||Q.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"}),G.children.map(J=>r(As,{step:J,schema:k.get(J.addonId)??null,allSchemas:k,depth:2,onChange:Z=>{R({..._,children:_.children.map(X=>X.addonId===G.addonId?{...X,children:X.children.map(oe=>oe.addonId===Z.addonId?Z:oe)}:X)})},onDelete:d?void 0:Z=>{R({..._,children:_.children.map(X=>X.addonId===G.addonId?{...X,children:X.children.filter(oe=>oe.addonId!==Z)}:X)})},readOnly:d,...y(J.addonId)},J.addonId)),!d&&Q.map(J=>r(ci,{addon:J,onClick:()=>{const Z=li(J);R({..._,children:_.children.map(X=>X.addonId===G.addonId?{...X,children:[...X.children,Z]}:X)})}},J.id))]})]},G.addonId)}),!d&&q.map(G=>r(ci,{addon:G,onClick:()=>$(_.addonId,G)},G.id))]})]},_.addonId)}const j=e.slots.filter(H=>H.parentSlot===null).sort((H,_)=>H.priority-_.priority);return u("div",{className:"space-y-4",children:[!f&&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:I,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))]})}),E&&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:K("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(e5,{className:"h-4 w-4"})}),r("button",{onClick:A,disabled:d,title:"Save As",className:K("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(Xk,{className:"h-4 w-4"})}),r("button",{onClick:T,disabled:!s||d,title:"Delete",className:K("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(ln,{className:"h-4 w-4"})})]})}),C.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:()=>D([]),className:"text-amber-400/60 hover:text-amber-400",children:r(Je,{className:"h-3.5 w-3.5"})})]}),C.map((H,_)=>u("div",{children:["• ",H]},_))]}),j.map(H=>{const _=t.filter(Z=>Z.slot===H.id&&!N.has(Z.addonId)),q=m?_.filter(Z=>Z.enabled):_,G=m?[]:H.addons.filter(Z=>!O.has(Z.id)&&!N.has(Z.id)),Q=new Map,J=[];for(const Z of q)Z.group?(Q.has(Z.group)||Q.set(Z.group,[]),Q.get(Z.group).push(Z)):J.push(Z);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]}),J.map(Z=>B(Z)),[...Q.entries()].map(([Z,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:Z}),X.map(oe=>B(oe))]},Z)),!d&&G.map(Z=>r(ci,{addon:Z,onClick:()=>{n([...t,li(Z)])}},Z.id))]},H.id)})]})}const ro={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"},Ou=["#ef4444","#8b5cf6","#06b6d4","#f97316","#10b981","#6366f1","#e11d48","#0891b2","#7c3aed","#059669"],mg="#f59e42";function ft(e,t){if(t?.[e])return t[e];if(t?.[e.toLowerCase()])return t[e.toLowerCase()];if(ro[e])return ro[e];if(ro[e.toLowerCase()])return ro[e.toLowerCase()];let n=0;for(let o=0;o<e.length;o++)n=n*31+(e.codePointAt(o)??0)>>>0;return Ou[n%Ou.length]??mg}function O3({src:e,imageWidth:t,imageHeight:n,detections:o=[],classColors:s,aspectRatio:a,className:i,placeholder:l,showConfidence:c=!0,minConfidence:d=0,borderWidth:p=2}){function f(v){return ft(v,s)}const m=a??(t&&n?`${t}/${n}`:"16/9"),h=o.filter(v=>v.score>=d),g=h.filter(v=>v.kind==="first-level"),x=h.filter(v=>v.kind==="detail"),b=F3(x,v=>v.parentId??"");return r("div",{className:K("rounded-lg border border-border bg-surface overflow-hidden relative",i),style:{aspectRatio:m},children:e?u(ue,{children:[r("img",{src:e,className:"absolute inset-0 w-full h-full object-fill",alt:""}),h.map((v,w)=>v.debug?.mask&&v.debug.maskWidth&&v.debug.maskHeight?r(z3,{mask:v.debug.mask,maskWidth:v.debug.maskWidth,maskHeight:v.debug.maskHeight,bbox:v.bbox,imageWidth:t,imageHeight:n,color:f(v.macroClass)},`mask-${w}`):null),g.map(v=>{const w=b.get(v.id)??[];return r(zu,{detection:v,imageWidth:t,imageHeight:n,color:f(v.macroClass),showConfidence:c,borderWidth:v.debug?.mask?1:p,children:w.map(y=>r(B3,{child:y,parentBbox:v.bbox,color:f(y.macroClass),showConfidence:c},`child-${y.id}`))},`det-${v.id}`)}),x.filter(v=>!v.parentId||!g.some(w=>w.id===v.parentId)).map(v=>r(zu,{detection:v,imageWidth:t,imageHeight:n,color:f(v.macroClass),showConfidence:c,borderWidth:p},`orphan-${v.id}`))]}):r("div",{className:"w-full h-full flex items-center justify-center text-foreground-subtle text-sm",children:l??"No image loaded"})})}function zu({detection:e,imageWidth:t,imageHeight:n,color:o,showConfidence:s,borderWidth:a,children:i}){const{x:l,y:c,width:d,height:p}=e.bbox,f=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:ft(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:`${p/n*100}%`,borderWidth:`${a}px`,borderStyle:"solid",borderColor:o},children:[f,i]})}function z3({mask:e,maskWidth:t,maskHeight:n,bbox:o,imageWidth:s,imageHeight:a,color:i}){const l=re(null);return Y(()=>{const c=l.current;if(!c)return;const d=c.getContext("2d");if(!d)return;const p=atob(e),f=new Uint8Array(p.length);for(let v=0;v<p.length;v++)f[v]=p.charCodeAt(v);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 x=d.createImageData(t,n),b=t*n;for(let v=0;v<b;v++){const w=v<f.length?f[v]:0,y=v*4;w>0&&(x.data[y]=m,x.data[y+1]=h,x.data[y+2]=g,x.data[y+3]=120)}d.putImageData(x,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 B3({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:ft(c.label)},children:[c.label," ",(c.score*100).toFixed(0),"%"]},`${e.id}-lbl-${d}`))]})})}function F3(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 j3({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(p=>p.kind==="first-level"),l=e.filter(p=>p.kind==="detail"),c=new Map;for(const p of l){if(!p.parentId)continue;const f=c.get(p.parentId)??[];f.push(p),c.set(p.parentId,f)}const d=l.filter(p=>!p.parentId||!i.some(f=>f.id===p.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(p=>r(Bu,{detection:p,children_:c.get(p.id)??[],colors:a,hiddenKeys:o,onToggleVisibility:s},p.id)),d.map(p=>r(Bu,{detection:p,children_:[],colors:a,hiddenKeys:o,onToggleVisibility:s},p.id))]})]})}function Bu({detection:e,children_:t,colors:n,hiddenKeys:o,onToggleVisibility:s}){const a=ft(e.macroClass,n),i=!o?.has(e.id),l=e.debug?.mask,c=e.debug?.maskWidth,d=e.debug?.maskHeight,p=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(U3,{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((f,m)=>u("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{backgroundColor:ft(f.label,n)+"20",color:ft(f.label,n)},children:[f.label,u("span",{className:"opacity-60",children:[(f.score*100).toFixed(0),"%"]}),f.detectionId&&u("span",{className:"opacity-40 text-[8px]",children:["→ ",f.detectionId]})]},m))}),p&&Object.keys(p).length>0&&r(V3,{alternateLabels:p,colors:n}),t.length>0&&r(H3,{items:t,colors:n,hiddenKeys:o,onToggleVisibility:s})]})}function H3({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=ft(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((p,f)=>u("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-medium px-1 py-0.5 rounded-full",style:{backgroundColor:ft(p.label,t)+"20",color:ft(p.label,t)},children:[p.label," ",u("span",{className:"opacity-60",children:[(p.score*100).toFixed(0),"%"]})]},f))})]},s.id)})})}function V3({alternateLabels:e,colors:t}){const[n,o]=P(!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:ft(a,t)+"10",color:ft(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 U3({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 q3({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 Q3({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 p=d.files?.[0];if(!p)return;const f=new FileReader;f.onload=()=>{const m=f.result,h=m.split(",")[1];h&&s(h,p.name,m)},f.readAsDataURL(p)},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 ts="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 G3({runtime:e,backend:t,modelId:n,agentId:o="hub",runtimes:s,backends:a,models:i,agents:l=[],onRuntimeChange:c,onBackendChange:d,onModelChange:p,onAgentChange:f,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:b=>f?.(b.target.value),className:ts,children:l.map(b=>u("option",{value:b.id,children:[b.name," (",b.status,")"]},b.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:b=>c(b.target.value),className:ts,children:s.map(b=>u("option",{value:b.value,disabled:!b.available,children:[b.label,b.available?"":" (unavailable)"]},b.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:b=>d(b.target.value),className:ts,children:a.map(b=>u("option",{value:b.id,disabled:!b.available,children:[b.label,b.available?"":" (unavailable)"]},b.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:b=>p(b.target.value),className:ts,children:i.length===0?r("option",{value:"",children:"No compatible models"}):i.map(b=>u("option",{value:b.id,children:[b.name,b.downloaded?" ✓":""]},b.id))})]})]})}function K3({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 W3({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 Y3({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 hg({onLogin:e,serverUrl:t,logoSrc:n,error:o,className:s}){const[a,i]=P(""),[l,c]=P(""),[d,p]=P(!1),[f,m]=P(!1),[h,g]=P(null),x=o??h,b=async v=>{if(v.preventDefault(),!f){g(null),m(!0);try{await e(a,l)}catch(w){const y=w instanceof Error?w.message:"Login failed. Please try again.";g(y)}finally{m(!1)}}};return r("div",{className:K("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:b,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[x&&r("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:x}),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:v=>i(v.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:v=>c(v.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:()=>p(v=>!v),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",tabIndex:-1,children:d?r(W3,{className:"h-4 w-4"}):r(K3,{className:"h-4 w-4"})})]})]}),u("button",{type:"submit",disabled:f,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:[f&&r(Y3,{className:"h-4 w-4 animate-spin"}),f?"Logging in...":"Log in"]})]})]})})}const dl="camstack_dev_token",gg=je(null);function Z3(){const e=xe(gg);if(!e)throw new Error("useDevShell must be used within a DevShell");return e}function X3(){return typeof window>"u"?null:localStorage.getItem(dl)}function J3({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 eM({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 tM({children:e,serverUrl:t,title:n,token:o,onLogout:s}){const a=Ro(),i=V(()=>{const m=t.replace(/^http/,"ws")+"/trpc",h=bN({url:m,connectionParams:()=>({token:o})});return[xN({condition:g=>g.type==="subscription",true:yN({client:h,transformer:Ji}),false:wm({url:`${t}/trpc`,transformer:Ji,headers:()=>({authorization:`Bearer ${o}`})})})]},[t,o]),l=V(()=>vm({links:i}),[i]),c=V(()=>S.createClient({links:i}),[i]),d=V(()=>Am({serverUrl:t,token:o}),[t,o]);Y(()=>(d.init().catch(()=>{}),()=>{d.close()}),[d]);const p=V(()=>new bm,[]),f=V(()=>({trpc:l,token:o,logout:s}),[l,o,s]);return r(Cc,{system:d,children:r(S.Provider,{client:c,queryClient:p,children:r(xm,{client:p,children:r(gg.Provider,{value:f,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(J3,{className:"h-3.5 w-3.5"}):r(eM,{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 bg({children:e,serverUrl:t="https://localhost:4443",title:n}){const[o,s]=P(X3),a=U(async(l,c)=>{const f=await vm({links:[wm({url:`${t}/trpc`,transformer:Ji})]}).auth.login.mutate({username:l,password:c});if(!f.token)throw new Error("No token returned");localStorage.setItem(dl,f.token),s(f.token)},[t]),i=U(()=>{localStorage.removeItem(dl),s(null)},[]);return o?r(zs,{children:r(tM,{serverUrl:t,title:n,token:o,onLogout:i,children:e})}):r(zs,{children:r(hg,{onLogin:a,serverUrl:t})})}function nM(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}hm(a).render(Ae(bg,{serverUrl:n,title:o,children:({trpc:i,theme:l})=>Ae(e,{trpc:i,theme:{isDark:l.resolvedMode==="dark"},navigate:c=>{console.log("[dev] navigate:",c)}})}))}const xg=mn("camstack:custom-field-renderers",{});function yg({renderers:e,children:t}){return r(xg.Provider,{value:e,children:t})}function vg(e){return xe(xg)[e]??null}const $c=mn("camstack:device-context",null);function wg({deviceId:e,device:t,children:n}){const o={deviceId:e,device:t??null};return r($c.Provider,{value:o,children:n})}function Dc(){return xe($c)?.deviceId??null}function Ng(){return xe($c)?.device??null}const rM=S.accessories.getStatus.useQuery,Lc=S.addonPages.listPages.useQuery,hn=S.addons.list.useQuery,oM=S.addons.getLogs.useQuery,sM=S.addons.listPackages.useQuery,Tc=S.addons.installPackage.useMutation,aM=S.addons.installFromWorkspace.useMutation,iM=S.addons.isWorkspaceAvailable.useQuery,lM=S.addons.listWorkspacePackages.useQuery,kg=S.addons.uninstallPackage.useMutation,Sg=S.addons.reloadPackages.useMutation,Cg=S.addons.searchAvailable.useQuery,Rc=S.addons.listUpdates.useQuery,ul=S.addons.updatePackage.useMutation,cM=S.addons.rollbackPackage.useMutation,Mg=S.addons.forceRefresh.useMutation,Ag=S.addons.restartServer.useMutation,Eg=S.addons.getLastRestart.useQuery,Ig=S.addons.listFrameworkPackages.useQuery,Bo=S.addons.listCapabilityProviders.useQuery,Pg=S.addons.setCapabilityProviderEnabled.useMutation,_g=S.addons.updateFrameworkPackage.useMutation,$g=S.addons.getVersions.useQuery,Fo=S.addons.restartAddon.useMutation,Dg=S.addons.retryLoad.useMutation,Lg=S.addons.getAutoUpdateSettings.useQuery,dM=S.addons.setAutoUpdateSettings.useMutation,Tg=S.addons.getAddonAutoUpdate.useQuery,Rg=S.addons.setAddonAutoUpdate.useMutation,Og=S.addons.applyAutoUpdateToAll.useMutation,uM=S.addons.custom.useMutation,pM=S.addons.onAddonLogs.useSubscription,Oc=S.addonSettings.getGlobalSettings.useQuery,zg=S.addonSettings.updateGlobalSettings.useMutation,fM=S.addonSettings.getDeviceSettings.useQuery,Bg=S.addonSettings.updateDeviceSettings.useMutation,Fg=S.addonWidgets.listWidgets.useQuery,mM=S.alerts.emit.useMutation,hM=S.alerts.update.useMutation,jg=S.alerts.list.useQuery,Hg=S.alerts.getUnreadCount.useQuery,Vg=S.alerts.markRead.useMutation,Ug=S.alerts.markAllRead.useMutation,qg=S.alerts.dismiss.useMutation,gM=S.audioAnalysis.resolveDeviceSettings.useQuery,bM=S.audioAnalysis.getDeviceSettingsContribution.useQuery,xM=S.audioAnalysis.getDeviceLiveContribution.useQuery,yM=S.audioAnalysis.applyDeviceSettingsPatch.useMutation,vM=S.audioAnalyzer.analyseChunk.useMutation,wM=S.audioAnalyzer.classify.useQuery,NM=S.audioAnalyzer.isReady.useQuery,kM=S.audioAnalyzer.dispose.useMutation,Qg=S.audioAnalyzer.reprobeAudioEngine.useMutation,SM=S.audioCodec.listSupportedCodecs.useQuery,CM=S.audioCodec.canHandle.useQuery,MM=S.audioCodec.createDecodeSession.useMutation,AM=S.audioCodec.createEncodeSession.useMutation,EM=S.audioCodec.closeSession.useMutation,IM=S.audioCodec.pushEncodedFrame.useMutation,PM=S.audioCodec.pullPcm.useQuery,_M=S.audioCodec.pushPcm.useMutation,$M=S.audioCodec.pullEncoded.useQuery,DM=S.audioCodec.flushEncode.useMutation,LM=S.audioCodec.listActiveSessions.useQuery,TM=S.audioMetrics.getCurrentSnapshot.useQuery,RM=S.audioMetrics.getHistory.useQuery,zc=S.backup.listDestinations.useQuery,Gg=S.backup.trigger.useMutation,OM=S.backup.list.useQuery,Kg=S.backup.listLocations.useQuery,Wg=S.backup.getEntries.useQuery,Yg=S.backup.restore.useMutation,Zg=S.backup.delete.useMutation,Bc=S.backup.listArchives.useQuery,Xg=S.backup.upsertDestinationPolicy.useMutation,Jg=S.backup.previewSchedule.useQuery,zM=S.battery.getStatus.useQuery,BM=S.brightness.setBrightness.useMutation,FM=S.brightness.getStatus.useQuery,jM=S.cameraCredentials.getCredentials.useQuery,HM=S.cameraCredentials.getStatus.useQuery,VM=S.cameraStreams.getCameraStreams.useQuery,UM=S.cameraStreams.getBrokerStreams.useQuery,eb=S.cameraStreams.getRtspEntries.useQuery,qM=S.decoder.supportsCodec.useQuery,QM=S.decoder.getInfo.useQuery,GM=S.decoder.createSession.useQuery,KM=S.decoder.destroySession.useQuery,WM=S.decoder.pushPacket.useQuery,YM=S.decoder.openStream.useQuery,ZM=S.decoder.pullFrames.useQuery,XM=S.decoder.pullHandles.useQuery,JM=S.decoder.getFrame.useQuery,e4=S.decoder.getShmStats.useQuery,t4=S.decoder.updateConfig.useQuery,n4=S.decoder.getStats.useQuery,r4=S.decoder.listActiveSessions.useQuery,tb=S.decoder.reprobeHwaccel.useMutation,o4=S.detectionPipeline.getDeviceSettingsContribution.useQuery,s4=S.detectionPipeline.getDeviceLiveContribution.useQuery,a4=S.detectionPipeline.applyDeviceSettingsPatch.useMutation,nb=S.deviceDiscovery.listDiscovered.useQuery,rb=S.deviceDiscovery.refreshDiscovery.useMutation,i4=S.deviceDiscovery.adoptDevice.useMutation,l4=S.deviceDiscovery.releaseDevice.useMutation,c4=S.deviceDiscovery.getStatus.useQuery,Fc=S.deviceExport.getStatus.useQuery,d4=S.deviceExport.listSupportedDeviceKinds.useQuery,ob=S.deviceExport.listExposedDevices.useQuery,u4=S.deviceExport.exposeDevice.useMutation,sb=S.deviceExport.unexposeDevice.useMutation,p4=S.deviceExport.getDeviceSettingsContribution.useQuery,f4=S.deviceExport.getDeviceLiveContribution.useQuery,m4=S.deviceExport.applyDeviceSettingsPatch.useMutation,h4=S.deviceManager.allocateDeviceId.useMutation,g4=S.deviceManager.registerDevice.useMutation,b4=S.deviceManager.removeDevice.useMutation,x4=S.deviceManager.persistConfig.useMutation,y4=S.deviceManager.loadConfig.useQuery,v4=S.deviceManager.loadRuntimeState.useQuery,w4=S.deviceManager.loadMeta.useQuery,ab=S.deviceManager.setName.useMutation,ib=S.deviceManager.setLocation.useMutation,N4=S.deviceManager.setMetadata.useMutation,lb=S.deviceManager.listLocations.useQuery,k4=S.deviceManager.addLocation.useMutation,S4=S.deviceManager.removeLocation.useMutation,C4=S.deviceManager.setDisabled.useMutation,M4=S.deviceManager.listPersistedByAddon.useQuery,$n=S.deviceManager.listAll.useQuery,vr=S.deviceManager.getDevice.useQuery,cb=S.deviceManager.getChildren.useQuery,A4=S.deviceManager.getStreamSources.useQuery,E4=S.deviceManager.getConfigSchema.useQuery,I4=S.deviceManager.getSettingsSchema.useQuery,P4=S.deviceManager.updateConfig.useMutation,db=S.deviceManager.enable.useMutation,ub=S.deviceManager.disable.useMutation,pb=S.deviceManager.remove.useMutation,_4=S.deviceManager.getStreamProfileMap.useQuery,$4=S.deviceManager.setStreamProfileMap.useMutation,D4=S.deviceManager.probeStreams.useMutation,fb=S.deviceManager.getBindings.useQuery,L4=S.deviceManager.getAllBindings.useQuery,mb=S.deviceManager.setWrapperActive.useMutation,T4=S.deviceManager.listWrappersForCap.useQuery,hb=S.deviceManager.listBindableCapsForDeviceType.useQuery,R4=S.deviceManager.getDeviceSettingsAggregate.useQuery,O4=S.deviceManager.getDeviceLiveInfoAggregate.useQuery,jc=S.deviceManager.getDeviceAggregate.useQuery,z4=S.deviceManager.updateDeviceField.useMutation,gb=S.deviceManager.updateDeviceFieldsBatch.useMutation,Hc=S.deviceManager.discoverDevices.useMutation,bb=S.deviceManager.adoptDevice.useMutation,xb=S.deviceManager.getCreationSchema.useQuery,yb=S.deviceManager.createDevice.useMutation,Vc=S.deviceManager.testCreationField.useMutation,B4=S.deviceManager.testField.useMutation,F4=S.deviceManager.getDeviceStatusAggregate.useQuery,j4=S.deviceOps.getStreamSources.useQuery,H4=S.deviceOps.getConfigEntries.useQuery,V4=S.deviceOps.setConfig.useMutation,U4=S.deviceOps.removeDevice.useMutation,q4=S.deviceOps.getSettingsSchema.useQuery,Q4=S.deviceProvider.start.useMutation,G4=S.deviceProvider.stop.useMutation,K4=S.deviceProvider.getStatus.useQuery,W4=S.deviceProvider.getDevices.useQuery,Y4=S.deviceProvider.supportsDiscovery.useQuery,Z4=S.deviceProvider.discoverDevices.useMutation,X4=S.deviceProvider.adoptDiscoveredDevice.useMutation,J4=S.deviceProvider.supportsManualCreation.useQuery,eA=S.deviceProvider.getChildCreationSchema.useQuery,tA=S.deviceProvider.createDevice.useMutation,nA=S.deviceProvider.testCreationField.useMutation,rA=S.deviceState.getSnapshot.useQuery,oA=S.deviceState.getCapSlice.useQuery,sA=S.deviceState.getAllSnapshots.useQuery,aA=S.deviceState.setCapSlice.useMutation,iA=S.deviceStatus.getStatus.useQuery,lA=S.doorbell.getStatus.useQuery,cA=S.events.getEvents.useQuery,dA=S.events.getEventThumbnail.useQuery,uA=S.events.getEventClipUrl.useQuery,pA=S.featureProbe.getStatus.useQuery,Uc=S.integrations.list.useQuery,vb=S.integrations.get.useQuery,wb=S.integrations.getByAddonId.useQuery,Nb=S.integrations.create.useMutation,kb=S.integrations.update.useMutation,Sb=S.integrations.delete.useMutation,fA=S.integrations.getSettings.useQuery,mA=S.integrations.setSettings.useMutation,Cb=S.integrations.getAvailableTypes.useQuery,Mb=S.integrations.testConnection.useMutation,Ab=S.intercom.startSession.useMutation,Eb=S.intercom.handleAnswer.useMutation,Ib=S.intercom.stopSession.useMutation,hA=S.intercom.startTalkSession.useMutation,gA=S.intercom.pushTalkPcm.useMutation,bA=S.intercom.endTalkSession.useMutation,xA=S.intercom.getStatus.useQuery,Pb=S.localNetwork.list.useQuery,yA=S.localNetwork.getPreferred.useQuery,_b=S.localNetwork.getConnectionEndpoints.useQuery,$b=S.localNetwork.getAllowedAddresses.useQuery,Db=S.localNetwork.setAllowedAddresses.useMutation,Lb=S.localNetwork.resetAllowlistToBestMatch.useMutation,Tb=S.meshNetwork.getStatus.useQuery,vA=S.meshNetwork.join.useMutation,Rb=S.meshNetwork.startLogin.useMutation,Ob=S.meshNetwork.leave.useMutation,zb=S.meshNetwork.logout.useMutation,Bb=S.meshNetwork.listPeers.useQuery,wA=S.meshNetwork.testConnection.useMutation,NA=S.metricsProvider.collectSnapshot.useQuery,kA=S.metricsProvider.getCached.useQuery,SA=S.metricsProvider.getCurrent.useQuery,CA=S.metricsProvider.getDiskSpace.useQuery,MA=S.metricsProvider.getGpuInfo.useQuery,AA=S.metricsProvider.getCpuTemperature.useQuery,EA=S.metricsProvider.getProcessStats.useQuery,IA=S.metricsProvider.listAddonInstances.useQuery,PA=S.metricsProvider.getAddonStats.useQuery,Fb=S.metricsProvider.listNodeProcesses.useQuery,jb=S.metricsProvider.killProcess.useMutation,_A=S.motion.isDetected.useQuery,$A=S.motion.getStatus.useQuery,DA=S.motionDetection.analyze.useMutation,LA=S.motionDetection.removeCamera.useMutation,TA=S.motionDetection.reset.useMutation,RA=S.motionDetection.getDeviceSettingsContribution.useQuery,OA=S.motionDetection.getDeviceLiveContribution.useQuery,zA=S.motionDetection.applyDeviceSettingsPatch.useMutation,BA=S.motionTrigger.setMotionTrigger.useMutation,FA=S.motionTrigger.getStatus.useQuery,jA=S.motionZones.getOptions.useQuery,HA=S.motionZones.setZone.useMutation,VA=S.motionZones.getStatus.useQuery,UA=S.mqttBroker.listBrokers.useQuery,qA=S.mqttBroker.getBrokerConfig.useQuery,QA=S.mqttBroker.addBroker.useMutation,GA=S.mqttBroker.removeBroker.useMutation,KA=S.mqttBroker.testConnection.useMutation,WA=S.mqttBroker.startEmbeddedBroker.useMutation,YA=S.mqttBroker.stopEmbeddedBroker.useMutation,Hb=S.mqttBroker.getStatus.useQuery,ZA=S.nativeObjectDetection.getStatus.useQuery,Vb=S.networkAccess.start.useMutation,Ub=S.networkAccess.stop.useMutation,XA=S.networkAccess.getEndpoint.useQuery,qb=S.networkAccess.getStatus.useQuery,JA=S.networkAccess.listEndpoints.useQuery,Qb=S.networkQuality.getDeviceStats.useQuery,eE=S.networkQuality.getAllStats.useQuery,tE=S.networkQuality.reportClientStats.useMutation,Dn=S.nodes.topology.useQuery,nE=S.nodes.deployAddon.useMutation,Gb=S.nodes.undeployAddon.useMutation,wa=S.nodes.restartAddon.useMutation,Kb=S.nodes.restartProcess.useMutation,rE=S.nodes.restartNode.useMutation,oE=S.nodes.shutdownNode.useMutation,Wb=S.nodes.renameNode.useMutation,Yb=S.nodes.clusterAddonStatus.useQuery,Zb=S.nodes.getCapUsageGraph.useQuery,Xb=S.nodes.getNodeAddons.useQuery,Jb=S.nodes.setProcessLogLevel.useMutation,sE=S.nodes.executeQuery.useMutation,aE=S.notificationOutput.send.useMutation,iE=S.notificationOutput.sendTest.useMutation,lE=S.osd.setOverlay.useMutation,cE=S.osd.getStatus.useQuery,dE=S.pipelineAnalytics.getActiveTracks.useQuery,uE=S.pipelineAnalytics.getTrack.useQuery,pE=S.pipelineAnalytics.listTracks.useQuery,fE=S.pipelineAnalytics.clearTracks.useMutation,mE=S.pipelineAnalytics.getMotionEvents.useQuery,hE=S.pipelineAnalytics.getObjectEvents.useQuery,gE=S.pipelineAnalytics.getAudioEvents.useQuery,bE=S.pipelineAnalytics.getEventMedia.useQuery,xE=S.pipelineAnalytics.getTrackMedia.useQuery,yE=S.pipelineAnalytics.getDeviceSettingsContribution.useQuery,vE=S.pipelineAnalytics.getDeviceLiveContribution.useQuery,wE=S.pipelineAnalytics.applyDeviceSettingsPatch.useMutation,ex=S.pipelineExecutor.getAvailableEngines.useQuery,tx=S.pipelineExecutor.getSelectedEngine.useQuery,NE=S.pipelineExecutor.getDefaultSteps.useQuery,nx=S.pipelineExecutor.reprobeEngine.useMutation,kE=S.pipelineExecutor.getVideoPipelineSteps.useQuery,SE=S.pipelineExecutor.setVideoPipelineSteps.useMutation,jo=S.pipelineExecutor.getSchema.useQuery,CE=S.pipelineExecutor.getGlobalSteps.useQuery,ME=S.pipelineExecutor.getGlobalPipelineConfig.useQuery,AE=S.pipelineExecutor.getOrchestratorConfigSchema.useQuery,EE=S.pipelineExecutor.listTemplates.useQuery,IE=S.pipelineExecutor.saveTemplate.useMutation,PE=S.pipelineExecutor.updateTemplate.useMutation,_E=S.pipelineExecutor.deleteTemplate.useMutation,$E=S.pipelineExecutor.getCapabilities.useQuery,DE=S.pipelineExecutor.getAddonModels.useQuery,rx=S.pipelineExecutor.downloadModel.useMutation,ox=S.pipelineExecutor.deleteModel.useMutation,LE=S.pipelineExecutor.detect.useQuery,TE=S.pipelineExecutor.runPipeline.useMutation,RE=S.pipelineExecutor.runPipelineBatch.useMutation,OE=S.pipelineExecutor.cacheFrameInPool.useMutation,zE=S.pipelineExecutor.inferCached.useMutation,BE=S.pipelineExecutor.uncacheFrame.useMutation,FE=S.pipelineExecutor.getEffectiveTuning.useQuery,sx=S.pipelineExecutor.listLoadedEngines.useQuery,jE=S.pipelineExecutor.spinEngine.useMutation,ax=S.pipelineExecutor.killEngine.useMutation,HE=S.pipelineExecutor.listReferenceImages.useQuery,VE=S.pipelineExecutor.getReferenceImage.useQuery,UE=S.pipelineExecutor.getReferenceAudioFiles.useQuery,qE=S.pipelineExecutor.getReferenceAudio.useQuery,QE=S.pipelineExecutor.getAudioCapabilities.useQuery,GE=S.pipelineExecutor.runAudioTest.useMutation,KE=S.pipelineExecutor.getDetectionConfigSchema.useQuery,ix=S.pipelineOrchestrator.assignPipeline.useMutation,lx=S.pipelineOrchestrator.unassignPipeline.useMutation,cx=S.pipelineOrchestrator.rebalance.useMutation,Na=S.pipelineOrchestrator.getPipelineAssignments.useQuery,qc=S.pipelineOrchestrator.getPipelineAssignment.useQuery,dx=S.pipelineOrchestrator.getAgentLoad.useQuery,WE=S.pipelineOrchestrator.getGlobalMetrics.useQuery,YE=S.pipelineOrchestrator.getCameraMetrics.useQuery,ux=S.pipelineOrchestrator.getCapabilityBindings.useQuery,px=S.pipelineOrchestrator.setCapabilityBinding.useMutation,fx=S.pipelineOrchestrator.assignDecoder.useMutation,mx=S.pipelineOrchestrator.unassignDecoder.useMutation,hx=S.pipelineOrchestrator.getDecoderAssignments.useQuery,gx=S.pipelineOrchestrator.assignAudio.useMutation,bx=S.pipelineOrchestrator.unassignAudio.useMutation,ZE=S.pipelineOrchestrator.getAudioAssignment.useQuery,xx=S.pipelineOrchestrator.getAudioNodeLoad.useQuery,yx=S.pipelineOrchestrator.getAudioAssignments.useQuery,XE=S.pipelineOrchestrator.getDecoderAssignment.useQuery,Qc=S.pipelineOrchestrator.getAgentSettings.useQuery,Hr=S.pipelineOrchestrator.listAgentSettings.useQuery,Gc=S.pipelineOrchestrator.setAgentAddonDefaults.useMutation,vx=S.pipelineOrchestrator.removeAgentSettings.useMutation,Kc=S.pipelineOrchestrator.getCameraSettings.useQuery,wx=S.pipelineOrchestrator.setCameraStepToggle.useMutation,JE=S.pipelineOrchestrator.getCameraStepOverrides.useQuery,Nx=S.pipelineOrchestrator.setCameraStepOverride.useMutation,kx=S.pipelineOrchestrator.setCameraPipelineForAgent.useMutation,Sx=S.pipelineOrchestrator.resolvePipeline.useQuery,Cx=S.pipelineOrchestrator.listTemplates.useQuery,eI=S.pipelineOrchestrator.saveTemplate.useMutation,Mx=S.pipelineOrchestrator.updateTemplate.useMutation,Ax=S.pipelineOrchestrator.deleteTemplate.useMutation,tI=S.pipelineOrchestrator.getDeviceSettingsContribution.useQuery,nI=S.pipelineOrchestrator.getDeviceLiveContribution.useQuery,rI=S.pipelineOrchestrator.applyDeviceSettingsPatch.useMutation,oI=S.pipelineRunner.attachCamera.useMutation,sI=S.pipelineRunner.detachCamera.useMutation,aI=S.pipelineRunner.reportMotion.useMutation,iI=S.pipelineRunner.getLocalLoad.useQuery,lI=S.pipelineRunner.getLocalMetrics.useQuery,Ex=S.pipelineRunner.getCameraMetrics.useQuery,cI=S.pipelineRunner.getAllCameraMetrics.useQuery,Ix=S.pipelineRunner.getLocalCameras.useQuery,dI=S.platformProbe.getCapabilities.useQuery,uI=S.platformProbe.getHardware.useQuery,pI=S.platformProbe.resolveInferenceConfig.useQuery,fI=S.platformProbe.resolveHwAccel.useQuery,mI=S.platformProbe.getHardwareEncoders.useQuery,hI=S.platformProbe.refreshHardwareEncoders.useMutation,gI=S.ptz.move.useMutation,bI=S.ptz.continuousMove.useMutation,xI=S.ptz.stop.useMutation,yI=S.ptz.getPresets.useQuery,vI=S.ptz.goToPreset.useMutation,wI=S.ptz.savePreset.useMutation,NI=S.ptz.deletePreset.useMutation,kI=S.ptz.getOptions.useQuery,SI=S.ptz.goHome.useMutation,CI=S.ptz.getPosition.useQuery,MI=S.ptz.setAutofocus.useMutation,AI=S.ptz.getStatus.useQuery,Px=S.ptzAutotrack.getStatus.useQuery,_x=S.ptzAutotrack.setEnabled.useMutation,EI=S.ptzAutotrack.getSettings.useQuery,$x=S.ptzAutotrack.setSettings.useMutation,Dx=S.reboot.reboot.useMutation,II=S.recording.getSegments.useQuery,PI=S.recording.getPlaybackUrl.useQuery,_I=S.recording.getThumbnailAt.useQuery,$I=S.recordingEngine.getStatus.useQuery,Lx=S.recordingEngine.enable.useMutation,Tx=S.recordingEngine.disable.useMutation,Rx=S.recordingEngine.getConfig.useQuery,DI=S.recordingEngine.updateConfig.useMutation,LI=S.recordingEngine.getPlaylist.useQuery,TI=S.recordingEngine.getThumbnail.useQuery,Ox=S.recordingEngine.getSegments.useQuery,RI=S.recordingEngine.getAvailability.useQuery,OI=S.recordingEngine.estimateStorage.useQuery,zI=S.recordingEngine.estimateGlobalStorage.useQuery,zx=S.recordingEngine.getStorageUsage.useQuery,BI=S.recordingEngine.setPolicy.useMutation,FI=S.recordingEngine.getPolicy.useQuery,Bx=S.recordingEngine.getPolicyStatus.useQuery,Fx=S.recordingEngine.getRetentionConfig.useQuery,jI=S.recordingEngine.updateRetentionConfig.useMutation,HI=S.recordingEngine.getMotionStats.useQuery,VI=S.settingsStore.get.useQuery,UI=S.settingsStore.set.useMutation,qI=S.settingsStore.query.useQuery,QI=S.settingsStore.insert.useMutation,GI=S.settingsStore.update.useMutation,KI=S.settingsStore.delete.useMutation,WI=S.settingsStore.count.useQuery,YI=S.settingsStore.isEmpty.useQuery,ZI=S.settingsStore.declareCollection.useMutation,XI=S.snapshot.getSnapshot.useQuery,JI=S.snapshot.invalidateCache.useMutation,eP=S.snapshot.getStatus.useQuery,tP=S.snapshot.getDeviceSettingsContribution.useQuery,nP=S.snapshot.getDeviceLiveContribution.useQuery,rP=S.snapshot.applyDeviceSettingsPatch.useMutation,oP=S.snapshotProvider.supportsDevice.useQuery,sP=S.snapshotProvider.getSnapshot.useQuery,aP=S.storage.resolve.useQuery,iP=S.storage.write.useMutation,lP=S.storage.read.useQuery,cP=S.storage.exists.useQuery,dP=S.storage.list.useQuery,uP=S.storage.delete.useMutation,pP=S.storage.getAvailableSpace.useQuery,fP=S.storage.beginUpload.useMutation,mP=S.storage.writeChunk.useMutation,hP=S.storage.finalizeUpload.useMutation,gP=S.storage.abortUpload.useMutation,bP=S.storage.beginDownload.useMutation,xP=S.storage.readChunk.useQuery,yP=S.storage.endDownload.useMutation,jx=S.storage.listLocations.useQuery,vP=S.storage.getDefaultLocation.useQuery,ka=S.storage.upsertLocation.useMutation,Hx=S.storage.deleteLocation.useMutation,wP=S.storage.testLocation.useQuery,Wc=S.storage.listProviders.useQuery,NP=S.storage.testConfig.useQuery,kP=S.streamBroker.publishCameraStream.useMutation,SP=S.streamBroker.retractCameraStream.useMutation,CP=S.streamBroker.assignProfile.useMutation,MP=S.streamBroker.unassignProfile.useMutation,AP=S.streamBroker.listAllCameraStreams.useQuery,EP=S.streamBroker.listAllProfileSlots.useQuery,IP=S.streamBroker.getBrokerStats.useQuery,PP=S.streamBroker.listClients.useQuery,_P=S.streamBroker.killClient.useMutation,$P=S.streamBroker.restartProfile.useMutation,DP=S.streamBroker.getStreamUrl.useQuery,LP=S.streamBroker.getStreamWithCodec.useMutation,TP=S.streamBroker.releaseStreamWithCodec.useMutation,RP=S.streamBroker.subscribeAudioChunks.useMutation,OP=S.streamBroker.pullAudioChunks.useQuery,zP=S.streamBroker.unsubscribeAudioChunks.useMutation,BP=S.streamBroker.subscribeFrames.useMutation,FP=S.streamBroker.pullFrameHandles.useQuery,jP=S.streamBroker.unsubscribeFrames.useMutation,HP=S.streamBroker.setPreBufferDuration.useMutation,VP=S.streamBroker.getPreBufferInfo.useQuery,UP=S.streamBroker.getRtspPort.useQuery,qP=S.streamBroker.getAllRtspEntries.useQuery,QP=S.streamBroker.getRtspEntry.useQuery,Vx=S.streamBroker.regenerateRtspToken.useMutation,GP=S.streamBroker.setRtspEnabled.useMutation,KP=S.streamBroker.isRtspEnabled.useQuery,WP=S.streamBroker.getDeviceSettingsContribution.useQuery,YP=S.streamBroker.getDeviceLiveContribution.useQuery,ZP=S.streamBroker.applyDeviceSettingsPatch.useMutation,XP=S.streamParams.getOptions.useQuery,JP=S.streamParams.setProfile.useMutation,e_=S.streamParams.getConfigSchema.useQuery,t_=S.streamParams.getStatus.useQuery,n_=S.switch.setState.useMutation,r_=S.switch.getStatus.useQuery,o_=S.system.info.useQuery,s_=S.system.health.useQuery,a_=S.system.featureFlags.useQuery,i_=S.system.networkAddresses.useQuery,l_=S.system.getRetentionConfig.useQuery,c_=S.system.setRetentionConfig.useMutation,d_=S.system.forceRetentionCleanup.useMutation,Ux=S.toast.onToast.useSubscription,Yc=S.turnProvider.getTurnServers.useQuery,Zc=S.userManagement.listUsers.useQuery,qx=S.userManagement.createUser.useMutation,Qx=S.userManagement.updateUser.useMutation,Gx=S.userManagement.deleteUser.useMutation,Xc=S.userManagement.resetPassword.useMutation,Kx=S.userManagement.setUserScopes.useMutation,u_=S.userManagement.validateCredentials.useMutation,Wx=S.userManagement.listApiKeys.useQuery,p_=S.userManagement.createApiKey.useMutation,Yx=S.userManagement.revokeApiKey.useMutation,f_=S.userManagement.validateApiKey.useMutation,Zx=S.userManagement.createScopedToken.useMutation,Xx=S.userManagement.revokeScopedToken.useMutation,m_=S.userManagement.validateScopedToken.useQuery,Jx=S.userManagement.listScopedTokens.useQuery,h_=S.userManagement.setupTotp.useMutation,g_=S.userManagement.confirmTotp.useMutation,ey=S.userManagement.disableTotp.useMutation,ty=S.userManagement.getTotpStatus.useQuery,b_=S.userManagement.verifyTotp.useMutation,x_=S.userManagement.oauthIssueCode.useMutation,y_=S.userManagement.oauthExchangeCode.useMutation,v_=S.userManagement.oauthRefresh.useMutation,w_=S.userManagement.oauthVerifyAccessToken.useQuery,ny=S.userManagement.listOauthSessions.useQuery,ry=S.userManagement.revokeOauthSession.useMutation,N_=S.webrtcSession.listStreams.useQuery,k_=S.webrtcSession.createSession.useMutation,S_=S.webrtcSession.handleOffer.useMutation,C_=S.webrtcSession.handleAnswer.useMutation,M_=S.webrtcSession.closeSession.useMutation,A_=S.webrtcSession.hasAdaptiveBitrate.useQuery,E_=S.zoneAnalytics.getCurrentSnapshot.useQuery,I_=S.zoneAnalytics.getZoneHistory.useQuery,P_=S.zoneAnalytics.getCameraHistory.useQuery,__=S.zoneAnalytics.getUnzonedHistory.useQuery,$_=S.zoneRules.listRules.useQuery,D_=S.zoneRules.setRules.useMutation,L_=S.zones.listZones.useQuery,T_=S.zones.addZone.useMutation,R_=S.zones.removeZone.useMutation,O_=S.zones.updateZone.useMutation,oy=mn("camstack:widget-registry",null),js=new Map,ns=new Map,Fu=new Set;function Jc(e,t){return`${e}::${t}`}function z_(e){if(!e||typeof e!="object")return!1;const t=e.default;return t!==null&&typeof t=="object"}function B_(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 ed(e,t,n){const o=Jc(e,t),s=js.get(o);if(s)return s;const a=ns.get(o);if(a)return a;Fu.has(e)||(sc(),xr.registerRemotes([{name:e,entry:n,type:"module"}],{force:!1}),Fu.add(e));const i=t.startsWith("./")?t.slice(2):t,l=xr.loadRemote(`${e}/${i}`).then(c=>{if(!z_(c)){const p=B_(c);throw new Error(`Remote ${e} (${n}) does not expose a default record on '${t}'. Got: ${JSON.stringify(p)}`)}const d=c.default;return js.set(o,d),ns.delete(o),d}).catch(c=>{throw ns.delete(o),c});return ns.set(o,l),l}function pl(e,t){return js.get(Jc(e,t))}const F_=3e4,j_=2e3;function sy({children:e}){const t=we(),n=re(Date.now()),{data:o}=Fg(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:c=>{const d=c.state.data;return d&&d.length>0||Date.now()-n.current>=F_?!1:j_}});ht("addon.widget-ready",()=>{t.invalidateQueries({queryKey:[["addonWidgets","listWidgets"]]})});const[s,a]=P(0),i=V(()=>o??[],[o]);Y(()=>{if(i.length===0)return;let c=!1;const d=new Set;for(const p of i){const f=Jc(p.remote.remoteName,p.remote.exposedModule);if(d.has(f)||(d.add(f),js.has(f)))continue;const m=p.bundleUrl;ed(p.remote.remoteName,p.remote.exposedModule,m).then(()=>{c||a(h=>h+1)}).catch(h=>{const g=h instanceof Error?h.message:String(h);(typeof globalThis<"u"?globalThis.console:void 0)?.error?.("[WidgetRegistry] Failed to load widget remote",{remoteName:p.remote.remoteName,exposedModule:p.remote.exposedModule,entryUrl:m,reason:g})})}return()=>{c=!0}},[i]);const l=V(()=>{const c=new Map,d=new Map;for(const f of i)c.set(`${f.addonId}/${f.stableId}`,f),d.set(f.remote.remoteName,f.bundleUrl);const p=(f,m)=>({widgetId:f,addonId:m.addonId,stableId:m.stableId,tab:m.tab,subTab:m.subTab,label:m.label,order:m.order,kind:m.kind,remote:m.remote,description:m.description,icon:m.icon,bundleUrl:m.bundleUrl,hosts:m.hosts,requires:m.requires,defaultSize:m.defaultSize,allowedSizes:m.allowedSizes,defaultColumns:m.defaultColumns,defaultRows:m.defaultRows});return{resolve:f=>{const m=c.get(f);if(!m)return;const h=pl(m.remote.remoteName,m.remote.exposedModule);if(!h)return null;const g=m.remote.componentKey??m.stableId,x=h[g];if(x)return x},metadata:f=>{const m=c.get(f);if(m)return p(f,m)},listAll:()=>{const f=[];for(const[m,h]of c)f.push(p(m,h));return f},entryUrlFor:f=>d.get(f)}},[i,s]);return r(oy.Provider,{value:l,children:e})}function H_(e){return Sa().resolve(e)}function ay(e){return Sa().metadata(e)}function iy(){return Sa().listAll()}function ly(e,t){const n=td(),o=t??n?.entryUrlFor(e.remoteName),[s,a]=P(0),[i,l]=P(!1);return Y(()=>{if(!o||(l(!1),pl(e.remoteName,e.exposedModule)))return;let c=!1;return ed(e.remoteName,e.exposedModule,o).then(()=>{c||a(d=>d+1)}).catch(d=>{const p=d instanceof Error?d.message:String(d);(typeof globalThis<"u"?globalThis.console:void 0)?.error?.("[WidgetRegistry] Failed to load remote component",{remoteName:e.remoteName,exposedModule:e.exposedModule,entryUrl:o,reason:p}),c||l(!0)}),()=>{c=!0}},[e.remoteName,e.exposedModule,o]),V(()=>{if(!o||i)return;const c=pl(e.remoteName,e.exposedModule);if(!c)return null;const d=e.componentKey;return d===void 0?Object.values(c)[0]??void 0:c[d]??void 0},[e.remoteName,e.exposedModule,e.componentKey,o,s,i])}function Sa(){const e=td();if(!e)throw new Error("useWidgetRegistry(): no <WidgetRegistryProvider> in tree");return e}function td(){return V_(oy)}function V_(e){return xe(e)}const ju={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 cy(e,t,n){const o=n?.defaultSpeed??.5,s=n?.pulseMs??250,a=n?.enabled??!0,l=Ct(e,a?t:null)?.ptz,[c,d]=P([]),[p,f]=P(null),[m,h]=P(!1),[g,x]=P(null),b=T=>{const R=T instanceof Error?T.message:String(T);return R.includes("provider not available")||R.includes("no 'ptz' binding")},v=U(async()=>{if(!(!a||!l))try{const T=await l.getPresets({});d(T)}catch(T){if(b(T))return;x(T instanceof Error?T.message:String(T))}},[l,a]),w=U(async()=>{if(!(!a||!l))try{const T=await l.getOptions({});f(T)}catch(T){if(b(T))return;x(T instanceof Error?T.message:String(T))}},[l,a]);Y(()=>{v(),w()},[v,w]);const y=U(async T=>{if(!(!a||!l)){x(null),h(!0);try{return await T()}catch(R){x(R instanceof Error?R.message:String(R));return}finally{h(!1)}}},[a,l]),N=U(async(T,R)=>{if(!l)return;const M=ju[T],$=R??o;await y(async()=>{await l.move({pan:M.pan,tilt:M.tilt,speed:$}),await new Promise(L=>setTimeout(L,s)),await l.stop({})})},[l,o,s,y]),k=U(async(T,R)=>{if(!l)return;const M=ju[T],$=R??o;await y(()=>l.continuousMove({pan:M.pan,tilt:M.tilt,speed:$}))},[l,o,y]),C=U(async()=>{l&&await y(()=>l.stop({}))},[l,y]),D=U(async(T,R)=>{if(!l)return;const M=T==="in"?1:-1,$=R??o;await y(async()=>{await l.move({zoom:M,speed:$}),await new Promise(L=>setTimeout(L,s)),await l.stop({})})},[l,o,s,y]),E=U(async()=>{l&&await y(()=>l.goHome({}))},[l,y]),I=U(async T=>{l&&await y(()=>l.goToPreset({presetId:T}))},[l,y]),z=U(async T=>{if(l)return y(async()=>{const R=new Set(c.map(L=>Number(L.id)).filter(L=>Number.isInteger(L)&&L>=0));let M=0;for(;R.has(M);)M+=1;const $=String(M);return await l.savePreset({presetId:$,name:T}),await v(),$})},[l,c,v,y]),A=U(async T=>{l&&await y(async()=>{await l.deletePreset({presetId:T}),await v()})},[l,v,y]);return{move:N,startContinuous:k,stopContinuous:C,zoom:D,goHome:E,goToPreset:I,savePreset:z,deletePreset:A,presets:c,refreshPresets:v,options:p,busy:m,error:g}}function rs({direction:e,icon:t,disabled:n,className:o,variant:s,onMove:a,onStart:i,onStop:l}){const[c,d]=P(null),[p,f]=P(!1),m=U(w=>{if(n)return;w.currentTarget.setPointerCapture(w.pointerId),d(Date.now()),f(!1);const y=setTimeout(()=>{f(!0),i(e)},250);w.currentTarget.dataset.timer=String(y)},[e,n,i]),h=U(w=>{const y=Number(w.currentTarget.dataset.timer);y&&clearTimeout(y),w.currentTarget.dataset.timer="",p?l():c!==null&&a(e),d(null),f(!1)},[p,e,a,l,c]),g=U(w=>{const y=Number(w.currentTarget.dataset.timer);y&&clearTimeout(y),w.currentTarget.dataset.timer="",p&&l(),d(null),f(!1)},[p,l]),x=s==="panel"?"h-9 w-9":"h-7 w-7",b=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:K("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",x,o),title:e,children:r(t,{className:b})})}function dy({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:p,goToPreset:f,savePreset:m,deletePreset:h,presets:g,options:x,busy:b,error:v}=e,w=et(),[y,N]=P(!1),[k,C]=P(""),D=(n??g.length>0)&&g.length>0,E=t==="panel",I=E&&(x?.supportsPresets??!1),z=x?.maxPresets!==void 0&&g.length>=x.maxPresets,A=U(async()=>{const B=k.trim();if(!B||b||z)return;await m(B)!==void 0&&C("")},[k,b,z,m]),T=U(async(B,j)=>{await w({title:"Delete preset",message:`Delete PTZ preset "${j}"? This removes it from the camera.`,confirmLabel:"Delete",variant:"danger"})&&await h(B)},[w,h]),R=E?"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",M=K(E?"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",b&&"ring-1 ring-primary/40"),$=E?"h-9 w-9":"h-7 w-7",L=E?"h-4 w-4":"h-3.5 w-3.5",O=E?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15",F=E?"h-12 w-px bg-border mx-1":"h-12 w-px bg-white/15 mx-1";return u("div",{className:K(R,a),children:[v&&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: ",v]}),u("div",{className:K(M,E&&"justify-center"),children:[u("div",{className:"grid grid-cols-3 gap-0.5",children:[r("span",{"aria-hidden":!0,className:E?"h-9 w-9":"h-7 w-7"}),r(rs,{direction:"up",icon:gk,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:E?"h-9 w-9":"h-7 w-7"}),r(rs,{direction:"left",icon:uk,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:E?"h-9 w-9":"h-7 w-7"}),r(rs,{direction:"right",icon:fk,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:E?"h-9 w-9":"h-7 w-7"}),r(rs,{direction:"down",icon:ck,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:E?"h-9 w-9":"h-7 w-7"})]}),(o||s)&&r("div",{className:F}),u("div",{className:"flex flex-col gap-0.5",children:[o&&u(ue,{children:[r("button",{type:"button",onClick:()=>d("in"),disabled:b,title:"Zoom in",className:K("flex items-center justify-center rounded disabled:opacity-40",$,O),children:r(H5,{className:L})}),r("button",{type:"button",onClick:()=>d("out"),disabled:b,title:"Zoom out",className:K("flex items-center justify-center rounded disabled:opacity-40",$,O),children:r(U5,{className:L})})]}),s&&r("button",{type:"button",onClick:()=>p(),disabled:b,title:"Go home",className:K("flex items-center justify-center rounded disabled:opacity-40",$,O),children:r(lh,{className:L})})]}),D&&u("div",{className:"relative",children:[u("button",{type:"button",onClick:()=>N(B=>!B),disabled:b,className:K("flex items-center gap-1 rounded px-2 text-[10px] disabled:opacity-40",E?"h-9 text-foreground hover:bg-surface-hover":"h-7 text-white hover:bg-white/15"),title:"Presets",children:["Presets",r(er,{className:K("h-3 w-3 transition-transform",y&&"rotate-180")})]}),y&&r("div",{className:K("absolute right-0 top-full mt-1 min-w-[140px] rounded-lg shadow-xl py-1 z-20",E?"bg-surface border border-border":"border border-white/30 bg-zinc-900/95 backdrop-blur-md"),children:g.map(B=>u("div",{className:K("group flex items-center",E?"hover:bg-surface-hover":"hover:bg-white/15"),children:[r("button",{type:"button",onClick:()=>{f(B.id),N(!1)},disabled:b,className:K("flex-1 px-3 py-1.5 text-left text-[10px] disabled:opacity-40",E?"text-foreground":"text-white"),children:B.name||B.id}),I&&r("button",{type:"button",onClick:()=>void T(B.id,B.name||B.id),disabled:b,title:`Delete preset ${B.name||B.id}`,className:K("mr-1 flex h-5 w-5 shrink-0 items-center justify-center rounded","text-foreground-subtle hover:bg-danger/15 hover:text-danger disabled:opacity-40"),children:r(Je,{className:"h-3 w-3"})})]},B.id))})]})]}),I&&u("div",{className:"flex flex-col gap-1 rounded-lg border border-border p-2",children:[u("div",{className:"flex items-center gap-2",children:[r("input",{type:"text",value:k,onChange:B=>C(B.target.value),onKeyDown:B=>{B.key==="Enter"&&A()},disabled:b||z,placeholder:"New preset name",maxLength:64,className:K("min-w-0 flex-1 rounded border border-border bg-surface px-2 py-1 text-[11px] text-foreground","placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary/50","disabled:opacity-40")}),u("button",{type:"button",onClick:()=>void A(),disabled:b||z||k.trim().length===0,title:z?`Camera preset limit reached (${x?.maxPresets})`:"Save current position as a new preset",className:K("flex h-7 shrink-0 items-center gap-1 rounded px-2 text-[10px] font-medium","bg-primary/15 text-primary hover:bg-primary/25 disabled:opacity-40"),children:[r(Or,{className:"h-3 w-3"}),"Save current position"]})]}),z&&u("span",{className:"text-[10px] text-foreground-subtle",children:["Camera preset limit reached (",x?.maxPresets,"). Delete a preset to add a new one."]})]})]})}function U_({deviceId:e}){const t=Le(),n=Ct(t.trpcClient,e),[o,s]=P(null),[a,i]=P(!1);Y(()=>{if(!n)return;let c=!1;return(async()=>{try{const d=await n.ptz?.getStatus({});if(c||!d)return;s(d.autofocus)}catch{}})(),()=>{c=!0}},[n]);const l=U(async()=>{if(!(!n?.ptz||o===null)){i(!0);try{const c=!o;await n.ptz.setAutofocus({enabled:c}),s(c)}catch(c){console.error("ptz.setAutofocus failed",c)}finally{i(!1)}}},[n,o]);return o===null?null:u("div",{className:"flex items-center justify-between border-t border-border/40 mt-2 pt-2",children:[r("span",{className:"text-[10.5px] font-semibold text-foreground",children:"Autofocus"}),u("button",{type:"button",onClick:()=>void l(),disabled:a,"aria-pressed":o,className:`flex items-center gap-1.5 rounded-md px-2 py-1 text-[10px] font-medium transition-colors ${o?"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`,children:[r("span",{className:`h-1.5 w-1.5 rounded-full ${o?"bg-success":"bg-foreground-subtle/40"}`}),o?"On":"Off"]})]})}function uy({deviceId:e}){const t=Le(),n=Number.isFinite(e),o=cy(t.trpcClient,n?e:0,{enabled:n});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 s=o.options?.hasAutofocus===!0;return u("div",{className:"flex flex-col h-full overflow-y-auto",children:[r("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider mb-2",children:"PTZ"}),r(dy,{controls:o,mode:"panel"}),s&&r(U_,{deviceId:e})]})}function py(e){const t=we(),n=e!==null&&Number.isFinite(e),o=Px({deviceId:e??0},{enabled:n,refetchInterval:5e3,retry:1}),s=_x({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),a=$x({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),i=U(async d=>{e!==null&&await s.mutateAsync({deviceId:e,enabled:d})},[e,s]),l=U(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 fy({deviceId:e}){const{status:t,isLoading:n,isPending:o,error:s,setEnabled:a,setSettings:i}=py(Number.isFinite(e)?e:null),[l,c]=P({targetType:"",stopDelaySeconds:30,disappearDelaySeconds:15}),[d,p]=P(!1);return Y(()=>{if(d)return;const f=t?.currentSettings;f&&c({targetType:f.targetType,stopDelaySeconds:f.stopDelaySeconds,disappearDelaySeconds:f.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(mt,{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("h3",{className:"flex items-center gap-1.5 text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:[r(ic,{className:"h-3 w-3 text-primary"}),"Autotrack"]}),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(Tr,{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:()=>p(!0),onChange:f=>c(m=>({...m,targetType:f.target.value})),onBlur:()=>{p(!1);const f=t?.currentSettings?.targetType??"";l.targetType!==f&&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(f=>r("option",{value:f.value,children:f.label},f.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:()=>p(!0),onChange:f=>c(m=>({...m,stopDelaySeconds:Number(f.target.value)||0})),onBlur:()=>{p(!1);const f=t?.currentSettings?.stopDelaySeconds??30;l.stopDelaySeconds!==f&&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:()=>p(!0),onChange:f=>c(m=>({...m,disappearDelaySeconds:Number(f.target.value)||0})),onBlur:()=>{p(!1);const f=t?.currentSettings?.disappearDelaySeconds??15;l.disappearDelaySeconds!==f&&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)."})]})}const nd=mn("camstack:player-overlays-state",null),rd=mn("camstack:player-overlays-actions",null);function my({children:e}){const[t,n]=P(()=>new Map),[o,s]=P(()=>new Map),a=U(f=>{n(m=>{const h=new Map(m);return h.set(f.id,f),h})},[]),i=U(f=>{n(m=>{if(!m.has(f))return m;const h=new Map(m);return h.delete(f),h})},[]),l=U(f=>{s(m=>{const h=new Map(m);return h.set(f.id,f),h})},[]),c=U(f=>{s(m=>{if(!m.has(f))return m;const h=new Map(m);return h.delete(f),h})},[]),d=V(()=>({layers:t,buttons:o}),[t,o]),p=V(()=>({setLayer:a,removeLayer:i,setButton:l,removeButton:c}),[a,i,l,c]);return r(nd.Provider,{value:d,children:r(rd.Provider,{value:p,children:e})})}function hy(){const e=xe(nd);return V(()=>e?[...e.layers.values()].sort((t,n)=>t.order-n.order):[],[e])}function gy(){const e=xe(nd);return V(()=>e?[...e.buttons.values()].sort((t,n)=>t.order-n.order):[],[e])}function by(e){const t=xe(rd);Y(()=>{if(!(!t||!e))return t.setLayer(e),()=>t.removeLayer(e.id)},[t,e])}function q_(e){const t=xe(rd);Y(()=>{if(!(!t||!e))return t.setButton(e),()=>t.removeButton(e.id)},[t,e])}function Q_({options:e,cells:t,onCellsChange:n}){const{gridWidth:o,gridHeight:s}=e,a=o*s,i=re(!1),l=re(!0),c=re(new Set),[,d]=P(0),p=U((g,x)=>{if(g<0||g>=a||t[g]===x)return;const b=[...t];for(;b.length<a;)b.push(!1);b.length=a,b[g]=x,n(b)},[t,a,n]),f=U(g=>x=>{x.preventDefault();const b=!t[g];i.current=!0,l.current=b,c.current=new Set([g]),p(g,b),d(v=>v+1)},[t,p]),m=U(g=>()=>{i.current&&(c.current.has(g)||(c.current.add(g),p(g,l.current)))},[p]),h=U(()=>{i.current&&(i.current=!1,c.current=new Set)},[]);return r("div",{className:"absolute inset-0 select-none grid",style:{gridTemplateColumns:`repeat(${String(o)}, 1fr)`,gridTemplateRows:`repeat(${String(s)}, 1fr)`},onPointerUp:h,onPointerLeave:h,children:Array.from({length:a},(g,x)=>{const b=t[x]===!0;return r("button",{type:"button","aria-label":`motion cell ${String(x)}`,"aria-pressed":b,onPointerDown:f(x),onPointerEnter:m(x),className:b?"border border-primary/70 bg-primary/55 hover:bg-primary/65 transition-colors":"border border-white/25 bg-white/10 hover:bg-white/20 transition-colors"},x)})})}function G_(e){const t=e instanceof Error?e.message:String(e);return t.includes("provider not available")||t.includes("motion-zones")}function Hu(e,t){const n=t.gridWidth*t.gridHeight,o=new Array(n);for(let s=0;s<n;s+=1)o[s]=e[s]===!0;return o}function K_(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function xy({deviceId:e}){const t=Le(),n=Ct(t.trpcClient,e),[o,s]=P(null),[a,i]=P(!1),[l,c]=P(null),[d,p]=P(null),[f,m]=P(!1),[h,g]=P(!1),x=re(!1);Y(()=>{if(!n)return;let I=!1;return(async()=>{try{const z=await n.motionZones?.getOptions({});if(I||!z||(s(z),x.current))return;const A=await n.motionZones?.getStatus({});if(I||!A)return;x.current=!0;const T=Hu(A.cells,z);p(T),c(T)}catch(z){if(I)return;G_(z)?i(!0):console.error("motion-zones load failed",z)}})(),()=>{I=!0}},[n]);const b=V(()=>l!==null&&d!==null&&!K_(l,d),[l,d]),v=V(()=>l?l.reduce((I,z)=>z?I+1:I,0):0,[l]),w=o?o.gridWidth*o.gridHeight:0,y=U(I=>{w>0&&c(new Array(w).fill(I))},[w]),N=U(()=>{c(I=>I&&I.map(z=>!z))},[]),k=U(()=>{d&&c([...d])},[d]),C=U(async()=>{if(!(!l||!n?.motionZones||!o)){m(!0);try{await n.motionZones.setZone({patch:{cells:[...l]}});const I=await n.motionZones.getStatus({});if(I){const z=Hu(I.cells,o);p(z),c(z)}}catch(I){console.error("motion-zones.setZone failed",I)}finally{m(!1)}}},[l,n,o]),D=V(()=>h&&!a&&o&&l?{id:"motion-zones",order:110,node:r(Q_,{options:o,cells:l,onCellsChange:c})}:null,[h,a,o,l]);return by(D),u("div",{className:"flex flex-col gap-3",children:[r("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:"Motion Zones"}),a?r("p",{className:`${no} leading-relaxed`,children:"This camera doesn't expose an on-board motion-detection grid."}):!a&&o!==null&&l!==null?u(ue,{children:[u("p",{className:`${no} leading-relaxed`,children:["Toggle"," ",r("strong",{className:"text-foreground",children:"Edit grid"})," to paint the region the camera watches for motion directly on the live frame, then ",r("strong",{className:"text-foreground",children:"Save"})," to push the mask to the camera. Detection on/off and sensitivity are set in the"," ",r("strong",{className:"text-foreground",children:"On-camera motion"})," section."]}),u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("button",{type:"button",onClick:()=>g(I=>!I),disabled:f,"aria-pressed":h,className:h?"rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors":"rounded-md border border-border bg-surface px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors",children:h?"Done editing":"Edit grid"}),r("button",{type:"button",onClick:()=>y(!0),disabled:f,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors",children:"All on"}),r("button",{type:"button",onClick:()=>y(!1),disabled:f,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors",children:"All off"}),r("button",{type:"button",onClick:N,disabled:f,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors",children:"Invert"}),u("span",{className:`${no} ml-1 tabular-nums`,children:[v," / ",w," cells · ",o.gridWidth,"×",o.gridHeight]}),r("span",{className:"flex-1"}),r("button",{type:"button",onClick:k,disabled:f||!b,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors",children:"Revert"}),r("button",{type:"button",onClick:()=>void C(),disabled:f||!b,className:"rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors",children:f?"Saving…":"Save"})]})]}):r("p",{className:`${no} leading-relaxed`,children:"Loading the camera's motion grid…"})]})}const yy={"host/motion-zones-grid":xy,"host/ptz-panel":uy,"host/ptz-autotrack":fy};function wr(e){const{widgetId:t,deviceId:n}=e,o=yy[t];return o!==void 0?n===void 0?r(io,{widgetId:t,reason:"missing-device-context"}):r(o,{deviceId:n}):r(W_,{...e})}function W_(e){const{widgetId:t}=e,n=ay(t);return n===void 0?r(io,{widgetId:t,reason:"unknown"}):r(Y_,{...e,metadata:n})}function Y_(e){const{widgetId:t,host:n="device-tab",config:o,deviceId:s,integrationId:a,instanceId:i,size:l,columns:c,rows:d,metadata:p}=e,f=ly(p.remote,p.bundleUrl),m=V(()=>i??t,[i,t]);return f===null?r(Z_,{}):f===void 0?r(io,{widgetId:t,reason:"missing-export"}):p.requires.deviceContext&&s===void 0?r(io,{widgetId:t,reason:"missing-device-context"}):p.requires.integrationContext&&a===void 0?r(io,{widgetId:t,reason:"missing-integration-context"}):r(f,{instanceId:m,host:n,config:o,deviceId:s,integrationId:a,size:l,columns:c,rows:d})}function Z_(){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 io({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 rr="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",Ca="block text-[11px] font-medium text-foreground mb-1",X_="text-[10px] text-foreground-subtle mt-0.5";function Ke({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=Rt(e,a),c=Rt(t,a),d=l!==void 0&&l!=="";return u("div",{className:`${i} min-w-0`,children:[d&&u("label",{className:Ca,children:[l,n&&r("span",{className:"text-danger ml-0.5",children:"*"})]}),s,c&&r("p",{className:X_,children:c})]})}function J_({field:e,value:t,onChange:n,disabled:o,translationFn:s}){return r(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:r("input",{type:e.inputType??"text",className:rr,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 e$({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const[a,i]=P(t==null?"":String(t)),l=re(!1);Y(()=>{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 p=Number(d);Number.isNaN(p)||n(p)};return r(Ke,{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:rr,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 t$({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=!!t,i=o||e.disabled;return e.style==="checkbox"?r(Ke,{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:Rt(e.label,s)}),e.required&&r("span",{className:"text-danger",children:"*"})]})}):r(Ke,{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:Ca+" mb-0",children:[Rt(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 n$({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=e.options.some(i=>i.value==="");return r(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("select",{className:rr,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 r$({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(Ke,{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 o$({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const[a,i]=P(!1),l=e.showToggle!==!1;return r(Ke,{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:rr+(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(cc,{className:"h-3.5 w-3.5"}):r(Rr,{className:"h-3.5 w-3.5"})})]})})}function s$({field:e,value:t,onChange:n,disabled:o,translationFn:s}){return r(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:r("textarea",{className:rr+" 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 a$({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",p=o||e.disabled,f=e.displayScale??1,m=e.min/f,h=e.max/f,g=l/f,x=(e.step??1)/f;if(i&&a)return r(Ke,{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:p,onClick:()=>n(e.default??e.min),children:[d," — click to set manually"]})});const b=e.showStepper===!0&&c,v=y=>{const N=l+y*(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(Ke,{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:x,value:g,disabled:p,onChange:y=>n(Number(y.target.value)*f)}),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:[b&&r("button",{type:"button",className:w,disabled:p||l<=e.min,onClick:()=>v(-1),title:`Decrease by ${e.step??1}`,"aria-label":"Decrement",children:r(uh,{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:x,value:g,disabled:p,onChange:y=>{if(y.target.value===""){n(i?null:e.min);return}const N=Number(y.target.value)*f,k=e.step??1,C=N-e.min,D=e.min+Math.round(C/k)*k;n(Math.min(e.max,Math.max(e.min,D)))}}),b&&r("button",{type:"button",className:w,disabled:p||l>=e.max,onClick:()=>v(1),title:`Increase by ${e.step??1}`,"aria-label":"Increment",children:r(Or,{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:p,onClick:()=>n(null),children:d})]})]})})}function i$({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=Array.isArray(t)?t:[],[i,l]=P(""),c=re(null),d=U(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]),p=h=>n(a.filter(g=>g!==h)),f=h=>{h.key==="Enter"||h.key===","?(h.preventDefault(),d(i)):h.key==="Backspace"&&i===""&&a.length>0&&p(a[a.length-1])},m=o||e.disabled;return r(Ke,{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:()=>p(h),className:"hover:text-danger",children:r(Je,{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:f,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 vy({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const{nodes:a}=Fr(),i=typeof t=="string"?t:"",l=e.showOffline?a:a.filter(c=>c.isOnline);return r(Ke,{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 wy({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const{nodes:a}=Fr(),i=new Set(Array.isArray(t)?t.map(String):[]),l=e.showOffline?a:a.filter(d=>d.isOnline),c=d=>{const p=new Set(i);p.has(d)?p.delete(d):p.add(d),n([...p])};return r(Ke,{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 p=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 ${p?"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 l$({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=t==null?"#000000":String(t);return u(Ke,{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:rr+" 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 c$({field:e,value:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:i,externalProbe:l}){const[c,d]=P("idle"),[p,f]=P(null),m=l?.status??c,h=l?.result??p,g=!!a||!!i,x=U(async()=>{if(g){d("probing"),f(null);try{const w=a?await a(e.key,t):await i("test-probe",e.key,t),y=w&&typeof w=="object"?w:{status:"error",error:"Probe handler returned no result"};f(y),d(y.status==="ok"?"ok":"error")}catch(w){f({status:"error",error:w instanceof Error?w.message:String(w)}),d("error")}}},[a,i,e.key,t,g]),b=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",v=m==="probing"?r(mt,{className:"h-3 w-3 animate-spin"}):m==="ok"?r(Bk,{className:"h-3 w-3"}):m==="error"?r(Tr,{className:"h-3 w-3"}):r(bh,{className:"h-3 w-3"});return u(Ke,{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:x,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 ${b}`,children:[v,r("span",{className:"hidden @[280px]:inline",children:"Test"})]}),r("input",{type:e.inputType??"url",className:rr+" 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"),f(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,y)=>r("span",{className:"text-xs bg-success/10 text-success rounded px-2 py-0.5 font-mono",children:w},y))}),m==="error"&&h?.error&&r("p",{className:"text-xs text-danger mt-1 truncate",title:h.error,children:h.error})]})}function d$({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a}){const[i,l]=P(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(p=>!p):void 0,children:[r("span",{className:"text-xs font-semibold text-foreground",children:Rt(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(p=>r(or,{field:p,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a},p.key))})]})})}function u$({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:i}){const l=e.tabs[0]?.id??"",[c,d]=P(l),p=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:p,children:[e.label&&r("div",{className:Ca,children:Rt(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(f=>{const m=f.id===c;return u("button",{type:"button",role:"tab","aria-selected":m,onClick:()=>d(f.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:Rt(f.label,s)}),f.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:f.badge})]},f.id)})}),e.tabs.map(f=>f.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:f.fields.map((m,h)=>{const g="key"in m&&typeof m.key=="string"?m.key:`__${f.id}__${h}`;return r(or,{field:m,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:i},g)})},f.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 Vu={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 f$(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 m$({field:e}){const t=e.variant??"info",n=Vu[t]??Vu.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:f$(e.content)}}):r("p",{className:"text-xs text-foreground-subtle leading-relaxed whitespace-pre-line",children:e.content})]})})}const Uu={ok:"bg-success",warn:"bg-amber-500",danger:"bg-danger",idle:"bg-foreground-subtle/40",unknown:"bg-foreground-subtle/40"};function h$(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 g$(e){return!Number.isFinite(e)||e<=0?"—":new Date(e).toLocaleTimeString()}function b$({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=Uu[n]??Uu.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:h$(t)}):e==="timestamp"&&typeof t=="number"?r("span",{className:"font-mono text-[11px]",children:g$(t)}):r("span",{children:String(t)})}function x$({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(b$,{kind:a.kind,value:o[a.key]})},a.key))},s))})]})})]})}function y$({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,p=(b,v,w)=>{const y=l.slice(),N=y[b]??{};y[b]={...N,[v]:w},n(y)},f=b=>{l.length<=c||n(l.filter((v,w)=>w!==b))},m=()=>{if(l.length>=d)return;const b=e.defaultItem??{};n([...l,{...b}])},h=(b,v)=>e.rowTitleTemplate?e.rowTitleTemplate.replace(/\{(\w+)\}/g,(w,y)=>{const N=b[y];return N==null||N===""?"—":String(N)}):`Row ${v+1}`,g=l.length>c,x=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:Rt(e.label,s)}),e.description&&r("p",{className:"text-[11px] text-foreground-subtle",children:Rt(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((b,v)=>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(b,v)}),u("button",{type:"button",onClick:()=>f(v),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(uh,{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(or,{field:w,values:b,onChange:(y,N)=>p(v,y,N),disabled:o,translationFn:s,onTestField:a,allFields:e.itemFields,onAction:i},w.key))})]},v))}),u("div",{children:[u("button",{type:"button",onClick:m,disabled:o||!x,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(Or,{className:"h-3 w-3"}),e.addLabel??"Add"]}),!x&&Number.isFinite(d)&&u("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["(limit: ",d,")"]})]})]})}function v$({field:e,disabled:t,onAction:n}){const[o,s]=P(!1),a=et(),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(Ke,{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 Ny(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 w$({field:e,value:t,values:n,onChange:o,disabled:s,onAction:a}){const[i,l]=P(!1),[c,d]=P(null),[p,f]=P(null),m=Ny(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("|");Y(()=>{if(!a||h){f(null),d(null);return}let w=!1;return l(!0),d(null),a(e.action,e.key,m).then(y=>{if(w)return;const N=y;let k=[];if(Array.isArray(N))k=N;else if(N&&typeof N=="object")for(const C of Object.keys(N)){const D=N[C];if(Array.isArray(D)){k=D;break}}f(k)}).catch(y=>{w||(d(y instanceof Error?y.message:String(y)),f([]))}).finally(()=>{w||l(!1)}),()=>{w=!0}},[g,a,e.action,e.key]);const x=e.mapOption.value,b=e.mapOption.label,v=e.mapOption.description;return r(Ke,{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(mt,{className:"h-3 w-3 animate-spin"})," Loading options…"]}):c?r("div",{className:"text-[11px] text-danger",children:c}):p&&p.length===0?r("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyResultsMessage??"No options returned."}):(()=>{const w=(p??[]).some(y=>{const N=y[x];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:y=>o(y.target.value),children:[!w&&r("option",{value:"",children:"— Select —"}),(p??[]).map((y,N)=>{const k=y[x],C=y[b],D=v?y[v]:void 0,E=typeof k=="string"&&k!==""?k:`row-${N}`;return u("option",{value:typeof k=="string"?k:String(k??""),children:[typeof C=="string"?C:String(C??E),D!==void 0?` (${String(D)})`:""]},E)})]})})()})}function N$({field:e,values:t,disabled:n,onAction:o}){const[s,a]=P(!1),[i,l]=P(null),c=et(),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 f=Ny(e,t);a(!0),l(null);try{const m=await o(e.action,e.key,f),h=typeof m=="object"&&m!==null?m:null,g=e.successMessage?e.successMessage.replace(/\{(\w+)\}/g,(x,b)=>{const v=h?.[b];return v===void 0?"":String(v)}):"Done.";l({kind:"ok",text:g})}catch(m){l({kind:"error",text:m instanceof Error?m.message:String(m)})}finally{a(!1)}},p={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(Ke,{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 ${p[e.variant??"default"]??p.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 k$({field:e}){const t=Dc();return r(wr,{widgetId:e.widgetId,host:"device-tab",config:e.widgetConfig,deviceId:t??void 0,instanceId:e.key})}function S$(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 C$({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=S$(i,l),d="label"in e?e.label:void 0,p="description"in e?e.description:void 0,f="span"in e?e.span:void 0,m="actions"in e?e.actions??[]:[];return r(Ke,{label:d,description:p,span:f,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(A$,{action:h,fieldKey:s,value:i,onAction:n},h.action))})]})})}function M$({name:e}){const t="h-3.5 w-3.5";switch(e){case"copy":return r(_n,{className:t});case"refresh-cw":return r(ga,{className:t});case"external-link":return r(lc,{className:t});case"trash-2":return r(ln,{className:t});case"download":return r(rl,{className:t});case"upload":return r(gh,{className:t});default:return r(uc,{className:t})}}function A$({action:e,fieldKey:t,value:n,onAction:o}){const s=et(),[a,i]=P(!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(M$,{name:e.icon})})}function E$(e){return"multiple"in e&&e.multiple!=null}function I$({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c}){const d=e.multiple,p=d.min,f=d.max,m=t[e.key],g=[...Array.isArray(m)?m:m!=null?[m]:[]],x=d.itemDefault!==void 0?d.itemDefault:"default"in e&&e.default!==void 0?e.default:"";for(;g.length<p;)g.push(x);const b=k=>n(e.key,[...k]),v=(k,C)=>{const D=[...g];D[k]=C,b(D)},w=()=>{g.length>=f||b([...g,x])},y=k=>{g.length<=p||b(g.filter((C,D)=>D!==k))},N=()=>{const{multiple:k,...C}=e;return{...C,...{label:void 0,description:void 0,required:!1}}};return r(Ke,{label:e.label,description:e.description,required:p>0?e.required:!1,span:e.span,translationFn:s,children:u("div",{className:"space-y-2",children:[g.map((k,C)=>{const D=d.itemLabel?.replace("${n}",String(C+1));return u("div",{className:"space-y-1",children:[D&&r("div",{className:Ca,children:D}),u("div",{className:"flex items-center gap-2",children:[r("div",{className:"flex-1 min-w-0",children:r(or,{field:N(),values:{...t,[e.key]:k},onChange:(E,I)=>v(C,I),disabled:o,translationFn:s,onTestField:a,onAction:c,allFields:l})}),g.length>p&&r("button",{type:"button",onClick:()=>y(C),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(ln,{className:"h-3.5 w-3.5"})})]})]},C)}),u("div",{className:"flex items-center justify-between pt-1",children:[g.length<f?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(Or,{className:"h-3 w-3"}),d.addLabel??"Add"]}):r("span",{}),u("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[g.length,"/",f]})]})]})})}function od(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 or({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c}){if(E$(e))return r(I$,{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(C$,{field:e,values:t,onAction:c,translationFn:s});if(!od(e,t,l))return null;const d=t[e.key],p=d!==void 0?d:"default"in e?e.default:void 0,f=h=>n(e.key,h),m=vg(e.type);switch(e.type){case"text":return r(J_,{field:e,value:p,onChange:f,disabled:o,translationFn:s});case"number":return r(e$,{field:e,value:p,onChange:f,disabled:o,translationFn:s});case"boolean":return r(t$,{field:e,value:p,onChange:f,disabled:o,translationFn:s});case"select":return r(n$,{field:e,value:p,onChange:f,disabled:o,translationFn:s});case"multiselect":return r(r$,{field:e,value:p,onChange:f,disabled:o,translationFn:s});case"password":return r(o$,{field:e,value:p,onChange:f,disabled:o,translationFn:s});case"textarea":return r(s$,{field:e,value:p,onChange:f,disabled:o,translationFn:s});case"slider":return r(a$,{field:e,value:p,onChange:f,disabled:o,translationFn:s});case"tags":return r(i$,{field:e,value:p,onChange:f,disabled:o,translationFn:s});case"color":return r(l$,{field:e,value:p,onChange:f,disabled:o,translationFn:s});case"node-select":return r(vy,{field:e,value:p,onChange:f,disabled:o,translationFn:s});case"node-multiselect":return r(wy,{field:e,value:p,onChange:f,disabled:o,translationFn:s});case"probe":return r(c$,{field:e,value:p,onChange:f,disabled:o,translationFn:s,onTestField:a,onAction:c,externalProbe:i});case"group":return r(d$,{field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a});case"sub-tabs":return r(u$,{field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:c});case"separator":return r(p$,{});case"info":return r(m$,{field:e});case"object-array":return r(x$,{field:e});case"editable-array":return r(y$,{field:e,value:p,onChange:f,disabled:o,translationFn:s,onTestField:a,onAction:c});case"button":return r(v$,{field:e,disabled:o,onAction:c});case"addon-action-select":return r(w$,{field:e,value:p,values:t,onChange:f,disabled:o,onAction:c});case"addon-action-button":return r(N$,{field:e,values:t,disabled:o,onAction:c});case"widget":return r(k$,{field:e});default:return m?r(m,{field:e,value:p,onChange:f,disabled:o}):null}}function P$(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Rt(e,t){if(e!==void 0)return t&&P$(e)?t(e):e}function _$({section:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i}){const[l,c]=P(e.defaultCollapsed??!1),d=e.style==="accordion",p=e.columns??2,f=p===1?"grid-cols-1":p===3?"grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3":p===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:Rt(e.title,s)}),e.description&&r("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:Rt(e.description,s)})]}),d&&r("span",{className:"text-foreground-subtle text-xs ml-2",children:l?"▸":"▾"})]}),!l&&r("div",{className:`grid ${f} gap-x-3 gap-y-2.5`,children:e.fields.map(m=>r(or,{field:m,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i?.[m.key]},m.key))})]})}function ky({schema:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i,onClearProbe:l}){const c=(d,p)=>{n({...t,[d]:p}),l?.(d)};return r("div",{className:"space-y-4",children:e.sections.map(d=>r(_$,{section:d,values:t,onChange:c,disabled:o,translationFn:s,onTestField:a,probeResults:i},d.id))})}const $$=({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 qu(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 D$(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 L$({trpc:e,addonId:t,nodeId:n,title:o,disabled:s,onAfterChange:a,refreshToken:i,collapsible:l,defaultOpen:c,mode:d,onOverrideChange:p}){const f=d??"persist",[m,h]=P(null),[g,x]=P(!0),[b,v]=P(null),[w,y]=P(!1),[N,k]=P(c??!1),[C,D]=P({}),[E,I]=P(null);Y(()=>{I(null),D({})},[e,t,n,i,f]);const z=JSON.stringify(C);Y(()=>{let L=!1;x(!0),v(null);const O=f==="override"&&Object.keys(C).length>0?C:void 0;return e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n,...O?{overlay:O}:{}}).then(F=>{L||(h(F),O||I(qu(F)),x(!1))}).catch(F=>{L||(v(F instanceof Error?F.message:String(F)),x(!1))}),()=>{L=!0}},[e,t,n,i,f,z]);const A=V(()=>qu(m),[m]),T=V(()=>m?D$(m):null,[m]),R=async L=>{if(f==="override"){const F=E??A,B={};for(const H of Object.keys(L))L[H]!==F[H]&&(B[H]=L[H]);const j={...F,...B};D(B),p?.(B,j);return}const O={};for(const F of Object.keys(L))L[F]!==A[F]&&(O[F]=L[F]);if(Object.keys(O).length!==0){y(!0);try{await e.addonSettings.updateGlobalSettings.mutate({addonId:t,nodeId:n,patch:O});const F=await e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n});h(F),a?.()}catch(F){v(F instanceof Error?F.message:String(F))}finally{y(!1)}}};if(g)return u("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading ",o??t,"…"]});if(b)return u("div",{className:"text-xs text-red-400",children:[o??t,": ",b]});if(!m||!T)return u("div",{className:"text-xs text-foreground-subtle",children:[o??t," not available on ",n,"."]});const M=f==="override"?{...A,...C}:A,$=u(ue,{children:[f==="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(ky,{schema:T,values:M,onChange:R,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(L=>!L),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover text-left","aria-expanded":N,children:[r($$,{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:$}):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:$})]}):r("div",{children:$})}function Sy({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,p=i&&n&&n.detections.length>0;return!c&&!d&&!p&&!l?null:u("div",{className:"absolute inset-0 pointer-events-none z-10",children:[l&&r(T$,{phase:o}),d&&r(R$,{raw:t}),c&&r(O$,{motion:e}),p&&r(z$,{detections:n.detections,frameWidth:n.frameWidth,frameHeight:n.frameHeight})]})}function T$({phase:e}){const t=Lr(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 R$({raw:e}){return e.frameWidth===0||e.frameHeight===0?null:r(ue,{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,p=(i-s)/e.frameHeight*100,f=Math.max(.05,Math.min(.25,t.changeScore*.3));return r("div",{className:"absolute rounded-sm",style:{left:`${l}%`,top:`${c}%`,width:`${d}%`,height:`${p}%`,backgroundColor:`rgba(239, 68, 68, ${f})`}},`mr-${n}`)})})}function O$({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(ue,{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 z$({detections:e,frameWidth:t,frameHeight:n}){return t===0||n===0?null:r(ue,{children:e.map(o=>{const{x:s,y:a,width:i,height:l}=o.bbox,c=s/t*100,d=a/n*100,p=i/t*100,f=l/n*100,m=ft(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:`${p}%`,height:`${f}%`,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 B$(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 F$=3e3,j$=5;function Cy({serverUrl:e,streamKey:t,label:n,autoPlay:o=!0,muted:s=!0,showControls:a=!0,className:i="",onStateChange:l,onError:c,overlay:d,createSession:p,sendAnswer:f,closeSession:m,hintsOverride:h}){const g=re(null),x=re(null),b=re(null),v=re(new Set),w=re(null),y=re(null),N=re(0),k=re(!0),[C,D]=P("idle"),[E,I]=P(""),[z,A]=P(s),[T,R]=P(!1),[M,$]=P(!1),L=re(null),O=re(!1);(f||p)&&(O.current=!0);const F=O.current,B=U(W=>{D(W),l?.(W)},[l]),j=U(()=>{if(w.current?.abort(),w.current=null,y.current&&(clearTimeout(y.current),y.current=null),b.current&&(b.current.close(),b.current=null),m&&v.current.size>0){for(const W of v.current)m(W).catch(()=>{});v.current.clear()}g.current&&(g.current.srcObject=null)},[m]),H=U(async()=>{if(!k.current||!p||!f)return;j(),B("connecting");const W=new AbortController;w.current=W;try{const ie={...B$(x.current),...h},{sessionId:fe,sdpOffer:me}=await p(ie);if(v.current.add(fe),!k.current||W.signal.aborted){m?.(fe).catch(()=>{}),v.current.delete(fe);return}const te=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});b.current=te;const ye=new MediaStream;te.ontrack=ce=>{console.debug("[WebRTC] ontrack",ce.track.kind,ce.track.readyState),ye.addTrack(ce.track),g.current&&(g.current.srcObject=ye,g.current.play().catch(()=>{}))},te.oniceconnectionstatechange=()=>{if(!k.current)return;const ce=te.iceConnectionState;console.debug("[WebRTC] ICE state:",ce),ce==="connected"||ce==="completed"?(N.current=0,B("playing"),g.current?.paused&&(console.debug("[WebRTC] video was paused at ICE connected — calling play()"),g.current.play().catch(()=>{}))):(ce==="failed"||ce==="disconnected"||ce==="closed")&&(B("disconnected"),Q())},te.onicecandidateerror=ce=>{console.debug("[WebRTC] ICE candidate error:",ce)},console.debug("[WebRTC] Setting remote description (server offer)..."),await te.setRemoteDescription({type:"offer",sdp:me});const ke=await te.createAnswer();if(await te.setLocalDescription(ke),console.debug("[WebRTC] Local description set, waiting for ICE gathering..."),await Qu(te),!k.current)return;const pe=(te.localDescription?.sdp??"").split(`
|
|
551
|
+
`).filter(ce=>ce.startsWith("a=candidate:")).length;console.debug("[WebRTC] Sending answer to server",{localCandidates:pe,sessionId:fe.slice(0,8)}),await f(fe,te.localDescription?.sdp??""),console.debug("[WebRTC] Answer sent successfully");const le=te,Ce=()=>{const ce=le.connectionState;if(ce==="closed"||ce==="failed")return;const $e=g.current;$e&&$e.readyState===0&&console.log(`[WebRTC] no video data yet (ice=${le.iceConnectionState})`)};setTimeout(Ce,3e3),setTimeout(Ce,8e3)}catch(ne){if(!k.current)return;const ie=ne instanceof Error?ne.message:String(ne);I(ie),B("error"),c?.(ie),Q()}},[e,t,p,f,j,B,c,h]),_=U(async()=>{if(k.current){j(),B("connecting");try{const W=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});b.current=W,W.addTransceiver("video",{direction:"recvonly"}),W.addTransceiver("audio",{direction:"recvonly"});const ne=new MediaStream;W.ontrack=ye=>{ne.addTrack(ye.track),g.current&&(g.current.srcObject=ne,g.current.play().catch(()=>{}))},W.oniceconnectionstatechange=()=>{if(!k.current)return;const ye=W.iceConnectionState;ye==="connected"||ye==="completed"?(N.current=0,B("playing"),g.current?.paused&&g.current.play().catch(()=>{})):(ye==="failed"||ye==="disconnected"||ye==="closed")&&(B("disconnected"),Q())};const ie=await W.createOffer();if(await W.setLocalDescription(ie),await Qu(W),!k.current)return;const fe=`${e}/api/webrtc?src=${encodeURIComponent(t)}`,me=await fetch(fe,{method:"POST",headers:{"Content-Type":"application/sdp"},body:W.localDescription?.sdp??""});if(!me.ok)throw new Error(`WHEP ${me.status}: ${me.statusText}`);const te=await me.text();await W.setRemoteDescription({type:"answer",sdp:te})}catch(W){if(!k.current)return;const ne=W instanceof Error?W.message:String(W);I(ne),B("error"),c?.(ne),Q()}}},[e,t,j,B,c]),q=F?H:_,G=re(()=>{});G.current=q;const Q=U(()=>{k.current&&(N.current>=j$||(N.current+=1,y.current=setTimeout(()=>{k.current&&G.current()},F$)))},[]);Y(()=>(k.current=!0,N.current=0,o&&q(),()=>{k.current=!1,j()}),[e,t]);const J=re(!1);Y(()=>{!o||!F||!p||!f||J.current||b.current||(J.current=!0,q())},[o,F,p,f,q]);const Z=()=>{N.current=0,q()},X=()=>{g.current&&(g.current.muted=!g.current.muted,A(g.current.muted))},oe=async()=>{if(x.current)try{document.fullscreenElement?await document.exitFullscreen():await x.current.requestFullscreen()}catch(W){console.warn(`Fullscreen toggle failed: ${W instanceof Error?W.message:W}`)}},he=()=>{if(!g.current)return;const W=document.createElement("canvas");W.width=g.current.videoWidth||1280,W.height=g.current.videoHeight||720;const ne=W.getContext("2d");if(!ne)return;ne.drawImage(g.current,0,0);const ie=document.createElement("a");ie.download=`${t.replace(/[/:]/g,"-")}-${Date.now()}.jpg`,ie.href=W.toDataURL("image/jpeg",.92),ie.click()};Y(()=>{const W=()=>R(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",W),()=>document.removeEventListener("fullscreenchange",W)},[]);const ee=()=>{$(!0),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>$(!1),3e3)};return u("div",{ref:x,className:`relative bg-black overflow-hidden group ${i}`,onMouseMove:ee,onMouseEnter:ee,children:[r("video",{ref:g,autoPlay:o,muted:z,playsInline:!0,className:"w-full h-full object-contain"}),n&&C==="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,C==="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…"})]}),(C==="error"||C==="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:C==="error"?E||"Connection failed":"Disconnected"}),r("button",{onClick:Z,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&&C==="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 ${M?"opacity-100":"opacity-0"}`,children:[r("div",{className:"flex items-center gap-1",children:r(di,{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(di,{onClick:he,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(di,{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 di({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 Qu(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)})}function H$(e){return e==="streaming"?"bg-emerald-500":e==="connecting"?"bg-amber-500":e==="error"?"bg-rose-500":"bg-zinc-500"}function V$(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 fl({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 U$({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 q$({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 Q$({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 ui({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 My({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 G$({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 Ay({serverUrl:e,createSession:t,sendAnswer:n,closeSession:o,streams:s,activeStreamId:a,onStreamChange:i,deviceName:l,phase:c,pipelineMetrics:d,detections:p,defaultShowDetections:f=!0,defaultShowMotion:m=!1,streamStats:h,autoPlay:g=!1,showPlayStop:x=!1,snapshotSrc:b,snapshotLoading:v=!1,onRefreshSnapshot:w,showStreamStats:y=!1,children:N,extraOverlay:k,ptzAvailable:C=!1,ptzShown:D=!1,ptzOverlay:E,onPtzToggle:I,intercomAvailable:z=!1,intercomShown:A=!1,onIntercomToggle:T,chromeless:R=!1,className:M}){const $=gy(),[L,O]=P(g),[F,B]=P(f),[j,H]=P(m),[_,q]=P(null),[G,Q]=P(!1),J=re(null);Y(()=>{if(!G)return;function le(Ce){J.current&&!J.current.contains(Ce.target)&&Q(!1)}return document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[G]);const Z=a??_??s?.[0]?.id??"",X=s?.find(le=>le.id===Z)??s?.[0],oe=X?.inputFps!=null?{status:X.status??"unknown",inputFps:X.inputFps,bitrateKbps:X.bitrateKbps??0}:null,he=le=>{q(le),i?.(le),L&&x&&(O(!1),setTimeout(()=>O(!0),50))},ee=V(()=>{const le=X?.target;if(le)return Ce=>t(le,Ce)},[t,X]),W=s,ne=()=>O(!0),ie=()=>O(!1),fe=d?.phase??c,me=fe==="active",te=!!p,ye=te&&(F||j),ke=C&&D&&!!E,pe=x?L:!0;return u("div",{className:`overflow-hidden ${R?"":"rounded-xl border border-border bg-surface"} ${M??""}`,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 ${H$((h??oe).status)}`}),l&&r("span",{className:"text-xs font-medium text-foreground",children:l}),W&&W.length>1&&u("div",{className:"relative",children:[r("select",{"data-testid":"stream-profile-select",value:Z,onChange:le=>he(le.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:W.map(le=>r("option",{value:le.id,children:le.label},le.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":A?"true":"false",onClick:T,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${A?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:A?"Close intercom":"Open intercom",children:[r(q$,{className:"h-3 w-3"}),r("span",{className:"hidden xl:inline",children:"Intercom"})]}),$.map(le=>{const ce=le.tone==="primary"?"bg-primary text-primary-foreground":"bg-primary/15 text-primary";return u("button",{type:"button","data-toolbar-button-id":le.id,"data-toolbar-button-active":le.active?"true":"false",onClick:le.onClick,disabled:le.disabled,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors disabled:opacity-50 ${le.active?ce:"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:le.title??le.label,children:[le.icon,r("span",{className:"hidden xl:inline",children:le.label})]},le.id)}),x&&u("button",{"data-testid":"stream-play-toggle","data-stream-playing":pe?"true":"false",onClick:pe?ie:ne,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${pe?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary/10 text-primary hover:bg-primary/20"}`,title:pe?"Stop stream":"Start stream",children:[pe?r(U$,{className:"h-3 w-3"}):r(fl,{className:"h-3 w-3"}),r("span",{className:"hidden xl:inline",children:pe?"Stop":"Play"})]}),w&&u("button",{"data-testid":"stream-snapshot-refresh",onClick:w,disabled:v,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(My,{className:`h-3 w-3 ${v?"animate-spin":""}`}),r("span",{className:"hidden xl:inline",children:"Snapshot"})]}),(te||C||d||fe||h||oe&&oe.inputFps>0)&&u("div",{ref:J,className:"relative",children:[r("button",{onClick:()=>Q(le=>!le),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(Q$,{className:"h-3.5 w-3.5"})}),G&&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:[y&&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:V$(h.uptimeMs)})]})]}),!y&&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||te&&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 ${me?"text-red-400":"text-emerald-400"}`,children:[r("span",{className:`w-1.5 h-1.5 rounded-full ${me?"bg-red-500 animate-pulse":"bg-emerald-500"}`}),me?"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"]})]})]}),te&&u(ue,{children:[r(ui,{label:"Show detections",active:F,onClick:()=>B(le=>!le)}),r(ui,{label:"Show motion",active:j,onClick:()=>H(le=>!le)})]}),C&&r(ui,{label:"PTZ controls",active:D,onClick:()=>{I?.(),Q(!1)}})]})]})]})]}),pe?r("div",{className:"aspect-video relative",children:r(Cy,{serverUrl:e,streamKey:Z,autoPlay:!0,className:"w-full h-full",createSession:ee,sendAnswer:n,closeSession:o,overlay:ye||k||ke?u(ue,{children:[ye&&r(Sy,{detections:p,showPhaseIndicator:!1,showMotionZones:j,showMotionRaw:j,showDetections:F}),k,ke&&E]}):void 0},Z)}):r(K$,{src:b??null,isLoading:v,onPlay:ne,onRetry:w,extraOverlay:k||ke?u(ue,{children:[k,ke&&E]}):null,suppressPlayHover:!!k||ke}),N]})}function K$({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(fl,{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(G$,{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(My,{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(fl,{className:"h-3 w-3"}),"Play Live"]})]})]})})}const Gu={value:"auto",label:"Auto (best available)"};function W$(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Y$({deviceId:e,value:t,onChange:n,disabled:o,label:s,className:a}){const i=qn(),l=eb({deviceId:e},{refetchOnWindowFocus:!1}),[c,d]=P([Gu]);Y(()=>{if(!l.data)return;const m=`${e}/`,h=[Gu];for(const g of l.data){if(!g.enabled)continue;const x=g.brokerId.startsWith(m)?g.brokerId.slice(m.length):g.brokerId;h.push({value:x,label:W$(x)})}d(h)},[l.data,e]);const p=s??"Preferred stream",f=l.isLoading?"Loading available streams…":l.isError?"Could not load streams — only Auto available.":c.length===1?"No enabled streams found — only Auto available.":null;return u("div",{className:a,children:[r("label",{id:i,className:"text-xs font-medium text-foreground-muted block mb-1",children:p}),r(yo,{"aria-labelledby":i,options:c,value:t,disabled:o,onChange:m=>n(m.target.value)}),f!==null&&r("p",{className:"text-foreground-subtle text-[10px] mt-1",children:f})]})}var Z$=Object.defineProperty,Hs=Object.getOwnPropertySymbols,Ey=Object.prototype.hasOwnProperty,Iy=Object.prototype.propertyIsEnumerable,Ku=(e,t,n)=>t in e?Z$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ml=(e,t)=>{for(var n in t||(t={}))Ey.call(t,n)&&Ku(e,n,t[n]);if(Hs)for(var n of Hs(t))Iy.call(t,n)&&Ku(e,n,t[n]);return e},hl=(e,t)=>{var n={};for(var o in e)Ey.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&Hs)for(var o of Hs(e))t.indexOf(o)<0&&Iy.call(e,o)&&(n[o]=e[o]);return n};/**
|
|
552
|
+
* @license QR Code generator library (TypeScript)
|
|
553
|
+
* Copyright (c) Project Nayuki.
|
|
554
|
+
* SPDX-License-Identifier: MIT
|
|
555
|
+
*/var Qn;(e=>{const t=class Pe{constructor(c,d,p,f){if(this.version=c,this.errorCorrectionLevel=d,this.modules=[],this.isFunction=[],c<Pe.MIN_VERSION||c>Pe.MAX_VERSION)throw new RangeError("Version value out of range");if(f<-1||f>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let m=[];for(let g=0;g<this.size;g++)m.push(!1);for(let g=0;g<this.size;g++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const h=this.addEccAndInterleave(p);if(this.drawCodewords(h),f==-1){let g=1e9;for(let x=0;x<8;x++){this.applyMask(x),this.drawFormatBits(x);const b=this.getPenaltyScore();b<g&&(f=x,g=b),this.applyMask(x)}}s(0<=f&&f<=7),this.mask=f,this.applyMask(f),this.drawFormatBits(f),this.isFunction=[]}static encodeText(c,d){const p=e.QrSegment.makeSegments(c);return Pe.encodeSegments(p,d)}static encodeBinary(c,d){const p=e.QrSegment.makeBytes(c);return Pe.encodeSegments([p],d)}static encodeSegments(c,d,p=1,f=40,m=-1,h=!0){if(!(Pe.MIN_VERSION<=p&&p<=f&&f<=Pe.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let g,x;for(g=p;;g++){const y=Pe.getNumDataCodewords(g,d)*8,N=i.getTotalBits(c,g);if(N<=y){x=N;break}if(g>=f)throw new RangeError("Data too long")}for(const y of[Pe.Ecc.MEDIUM,Pe.Ecc.QUARTILE,Pe.Ecc.HIGH])h&&x<=Pe.getNumDataCodewords(g,y)*8&&(d=y);let b=[];for(const y of c){n(y.mode.modeBits,4,b),n(y.numChars,y.mode.numCharCountBits(g),b);for(const N of y.getData())b.push(N)}s(b.length==x);const v=Pe.getNumDataCodewords(g,d)*8;s(b.length<=v),n(0,Math.min(4,v-b.length),b),n(0,(8-b.length%8)%8,b),s(b.length%8==0);for(let y=236;b.length<v;y^=253)n(y,8,b);let w=[];for(;w.length*8<b.length;)w.push(0);return b.forEach((y,N)=>w[N>>>3]|=y<<7-(N&7)),new Pe(g,d,w,m)}getModule(c,d){return 0<=c&&c<this.size&&0<=d&&d<this.size&&this.modules[d][c]}getModules(){return this.modules}drawFunctionPatterns(){for(let p=0;p<this.size;p++)this.setFunctionModule(6,p,p%2==0),this.setFunctionModule(p,6,p%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const c=this.getAlignmentPatternPositions(),d=c.length;for(let p=0;p<d;p++)for(let f=0;f<d;f++)p==0&&f==0||p==0&&f==d-1||p==d-1&&f==0||this.drawAlignmentPattern(c[p],c[f]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const d=this.errorCorrectionLevel.formatBits<<3|c;let p=d;for(let m=0;m<10;m++)p=p<<1^(p>>>9)*1335;const f=(d<<10|p)^21522;s(f>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,o(f,m));this.setFunctionModule(8,7,o(f,6)),this.setFunctionModule(8,8,o(f,7)),this.setFunctionModule(7,8,o(f,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,o(f,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,o(f,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,o(f,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let p=0;p<12;p++)c=c<<1^(c>>>11)*7973;const d=this.version<<12|c;s(d>>>18==0);for(let p=0;p<18;p++){const f=o(d,p),m=this.size-11+p%3,h=Math.floor(p/3);this.setFunctionModule(m,h,f),this.setFunctionModule(h,m,f)}}drawFinderPattern(c,d){for(let p=-4;p<=4;p++)for(let f=-4;f<=4;f++){const m=Math.max(Math.abs(f),Math.abs(p)),h=c+f,g=d+p;0<=h&&h<this.size&&0<=g&&g<this.size&&this.setFunctionModule(h,g,m!=2&&m!=4)}}drawAlignmentPattern(c,d){for(let p=-2;p<=2;p++)for(let f=-2;f<=2;f++)this.setFunctionModule(c+f,d+p,Math.max(Math.abs(f),Math.abs(p))!=1)}setFunctionModule(c,d,p){this.modules[d][c]=p,this.isFunction[d][c]=!0}addEccAndInterleave(c){const d=this.version,p=this.errorCorrectionLevel;if(c.length!=Pe.getNumDataCodewords(d,p))throw new RangeError("Invalid argument");const f=Pe.NUM_ERROR_CORRECTION_BLOCKS[p.ordinal][d],m=Pe.ECC_CODEWORDS_PER_BLOCK[p.ordinal][d],h=Math.floor(Pe.getNumRawDataModules(d)/8),g=f-h%f,x=Math.floor(h/f);let b=[];const v=Pe.reedSolomonComputeDivisor(m);for(let y=0,N=0;y<f;y++){let k=c.slice(N,N+x-m+(y<g?0:1));N+=k.length;const C=Pe.reedSolomonComputeRemainder(k,v);y<g&&k.push(0),b.push(k.concat(C))}let w=[];for(let y=0;y<b[0].length;y++)b.forEach((N,k)=>{(y!=x-m||k>=g)&&w.push(N[y])});return s(w.length==h),w}drawCodewords(c){if(c.length!=Math.floor(Pe.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let d=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let f=0;f<this.size;f++)for(let m=0;m<2;m++){const h=p-m,x=(p+1&2)==0?this.size-1-f:f;!this.isFunction[x][h]&&d<c.length*8&&(this.modules[x][h]=o(c[d>>>3],7-(d&7)),d++)}}s(d==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let d=0;d<this.size;d++)for(let p=0;p<this.size;p++){let f;switch(c){case 0:f=(p+d)%2==0;break;case 1:f=d%2==0;break;case 2:f=p%3==0;break;case 3:f=(p+d)%3==0;break;case 4:f=(Math.floor(p/3)+Math.floor(d/2))%2==0;break;case 5:f=p*d%2+p*d%3==0;break;case 6:f=(p*d%2+p*d%3)%2==0;break;case 7:f=((p+d)%2+p*d%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[d][p]&&f&&(this.modules[d][p]=!this.modules[d][p])}}getPenaltyScore(){let c=0;for(let m=0;m<this.size;m++){let h=!1,g=0,x=[0,0,0,0,0,0,0];for(let b=0;b<this.size;b++)this.modules[m][b]==h?(g++,g==5?c+=Pe.PENALTY_N1:g>5&&c++):(this.finderPenaltyAddHistory(g,x),h||(c+=this.finderPenaltyCountPatterns(x)*Pe.PENALTY_N3),h=this.modules[m][b],g=1);c+=this.finderPenaltyTerminateAndCount(h,g,x)*Pe.PENALTY_N3}for(let m=0;m<this.size;m++){let h=!1,g=0,x=[0,0,0,0,0,0,0];for(let b=0;b<this.size;b++)this.modules[b][m]==h?(g++,g==5?c+=Pe.PENALTY_N1:g>5&&c++):(this.finderPenaltyAddHistory(g,x),h||(c+=this.finderPenaltyCountPatterns(x)*Pe.PENALTY_N3),h=this.modules[b][m],g=1);c+=this.finderPenaltyTerminateAndCount(h,g,x)*Pe.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let h=0;h<this.size-1;h++){const g=this.modules[m][h];g==this.modules[m][h+1]&&g==this.modules[m+1][h]&&g==this.modules[m+1][h+1]&&(c+=Pe.PENALTY_N2)}let d=0;for(const m of this.modules)d=m.reduce((h,g)=>h+(g?1:0),d);const p=this.size*this.size,f=Math.ceil(Math.abs(d*20-p*10)/p)-1;return s(0<=f&&f<=9),c+=f*Pe.PENALTY_N4,s(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,d=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let p=[6];for(let f=this.size-7;p.length<c;f-=d)p.splice(1,0,f);return p}}static getNumRawDataModules(c){if(c<Pe.MIN_VERSION||c>Pe.MAX_VERSION)throw new RangeError("Version number out of range");let d=(16*c+128)*c+64;if(c>=2){const p=Math.floor(c/7)+2;d-=(25*p-10)*p-55,c>=7&&(d-=36)}return s(208<=d&&d<=29648),d}static getNumDataCodewords(c,d){return Math.floor(Pe.getNumRawDataModules(c)/8)-Pe.ECC_CODEWORDS_PER_BLOCK[d.ordinal][c]*Pe.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let d=[];for(let f=0;f<c-1;f++)d.push(0);d.push(1);let p=1;for(let f=0;f<c;f++){for(let m=0;m<d.length;m++)d[m]=Pe.reedSolomonMultiply(d[m],p),m+1<d.length&&(d[m]^=d[m+1]);p=Pe.reedSolomonMultiply(p,2)}return d}static reedSolomonComputeRemainder(c,d){let p=d.map(f=>0);for(const f of c){const m=f^p.shift();p.push(0),d.forEach((h,g)=>p[g]^=Pe.reedSolomonMultiply(h,m))}return p}static reedSolomonMultiply(c,d){if(c>>>8||d>>>8)throw new RangeError("Byte out of range");let p=0;for(let f=7;f>=0;f--)p=p<<1^(p>>>7)*285,p^=(d>>>f&1)*c;return s(p>>>8==0),p}finderPenaltyCountPatterns(c){const d=c[1];s(d<=this.size*3);const p=d>0&&c[2]==d&&c[3]==d*3&&c[4]==d&&c[5]==d;return(p&&c[0]>=d*4&&c[6]>=d?1:0)+(p&&c[6]>=d*4&&c[0]>=d?1:0)}finderPenaltyTerminateAndCount(c,d,p){return c&&(this.finderPenaltyAddHistory(d,p),d=0),d+=this.size,this.finderPenaltyAddHistory(d,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(c,d){d[0]==0&&(c+=this.size),d.pop(),d.unshift(c)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(l,c,d){if(c<0||c>31||l>>>c)throw new RangeError("Value out of range");for(let p=c-1;p>=0;p--)d.push(l>>>p&1)}function o(l,c){return(l>>>c&1)!=0}function s(l){if(!l)throw new Error("Assertion error")}const a=class Qe{constructor(c,d,p){if(this.mode=c,this.numChars=d,this.bitData=p,d<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(c){let d=[];for(const p of c)n(p,8,d);return new Qe(Qe.Mode.BYTE,c.length,d)}static makeNumeric(c){if(!Qe.isNumeric(c))throw new RangeError("String contains non-numeric characters");let d=[];for(let p=0;p<c.length;){const f=Math.min(c.length-p,3);n(parseInt(c.substring(p,p+f),10),f*3+1,d),p+=f}return new Qe(Qe.Mode.NUMERIC,c.length,d)}static makeAlphanumeric(c){if(!Qe.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let d=[],p;for(p=0;p+2<=c.length;p+=2){let f=Qe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(p))*45;f+=Qe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(p+1)),n(f,11,d)}return p<c.length&&n(Qe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(p)),6,d),new Qe(Qe.Mode.ALPHANUMERIC,c.length,d)}static makeSegments(c){return c==""?[]:Qe.isNumeric(c)?[Qe.makeNumeric(c)]:Qe.isAlphanumeric(c)?[Qe.makeAlphanumeric(c)]:[Qe.makeBytes(Qe.toUtf8ByteArray(c))]}static makeEci(c){let d=[];if(c<0)throw new RangeError("ECI assignment value out of range");if(c<128)n(c,8,d);else if(c<16384)n(2,2,d),n(c,14,d);else if(c<1e6)n(6,3,d),n(c,21,d);else throw new RangeError("ECI assignment value out of range");return new Qe(Qe.Mode.ECI,0,d)}static isNumeric(c){return Qe.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return Qe.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,d){let p=0;for(const f of c){const m=f.mode.numCharCountBits(d);if(f.numChars>=1<<m)return 1/0;p+=4+m+f.bitData.length}return p}static toUtf8ByteArray(c){c=encodeURI(c);let d=[];for(let p=0;p<c.length;p++)c.charAt(p)!="%"?d.push(c.charCodeAt(p)):(d.push(parseInt(c.substring(p+1,p+3),16)),p+=2);return d}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let i=a;e.QrSegment=a})(Qn||(Qn={}));(e=>{(t=>{const n=class{constructor(s,a){this.ordinal=s,this.formatBits=a}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),t.Ecc=n})(e.QrCode||(e.QrCode={}))})(Qn||(Qn={}));(e=>{(t=>{const n=class{constructor(s,a){this.modeBits=s,this.numBitsCharCount=a}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),t.Mode=n})(e.QrSegment||(e.QrSegment={}))})(Qn||(Qn={}));var cr=Qn;/**
|
|
556
|
+
* @license qrcode.react
|
|
557
|
+
* Copyright (c) Paul O'Shannessy
|
|
558
|
+
* SPDX-License-Identifier: ISC
|
|
559
|
+
*/var X$={L:cr.QrCode.Ecc.LOW,M:cr.QrCode.Ecc.MEDIUM,Q:cr.QrCode.Ecc.QUARTILE,H:cr.QrCode.Ecc.HIGH},Py=128,_y="L",$y="#FFFFFF",Dy="#000000",Ly=!1,Ty=1,J$=4,eD=0,tD=.1;function Ry(e,t=0){const n=[];return e.forEach(function(o,s){let a=null;o.forEach(function(i,l){if(!i&&a!==null){n.push(`M${a+t} ${s+t}h${l-a}v1H${a+t}z`),a=null;return}if(l===o.length-1){if(!i)return;a===null?n.push(`M${l+t},${s+t} h1v1H${l+t}z`):n.push(`M${a+t},${s+t} h${l+1-a}v1H${a+t}z`);return}i&&a===null&&(a=l)})}),n.join("")}function Oy(e,t){return e.slice().map((n,o)=>o<t.y||o>=t.y+t.h?n:n.map((s,a)=>a<t.x||a>=t.x+t.w?s:!1))}function nD(e,t,n,o){if(o==null)return null;const s=e.length+n*2,a=Math.floor(t*tD),i=s/t,l=(o.width||a)*i,c=(o.height||a)*i,d=o.x==null?e.length/2-l/2:o.x*i,p=o.y==null?e.length/2-c/2:o.y*i,f=o.opacity==null?1:o.opacity;let m=null;if(o.excavate){let g=Math.floor(d),x=Math.floor(p),b=Math.ceil(l+d-g),v=Math.ceil(c+p-x);m={x:g,y:x,w:b,h:v}}const h=o.crossOrigin;return{x:d,y:p,h:c,w:l,excavation:m,opacity:f,crossOrigin:h}}function rD(e,t){return t!=null?Math.max(Math.floor(t),0):e?J$:eD}function zy({value:e,level:t,minVersion:n,includeMargin:o,marginSize:s,imageSettings:a,size:i,boostLevel:l}){let c=Ge.useMemo(()=>{const g=(Array.isArray(e)?e:[e]).reduce((x,b)=>(x.push(...cr.QrSegment.makeSegments(b)),x),[]);return cr.QrCode.encodeSegments(g,X$[t],n,void 0,void 0,l)},[e,t,n,l]);const{cells:d,margin:p,numCells:f,calculatedImageSettings:m}=Ge.useMemo(()=>{let h=c.getModules();const g=rD(o,s),x=h.length+g*2,b=nD(h,i,g,a);return{cells:h,margin:g,numCells:x,calculatedImageSettings:b}},[c,i,a,o,s]);return{qrcode:c,margin:p,cells:d,numCells:f,calculatedImageSettings:m}}var oD=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),sD=Ge.forwardRef(function(t,n){const o=t,{value:s,size:a=Py,level:i=_y,bgColor:l=$y,fgColor:c=Dy,includeMargin:d=Ly,minVersion:p=Ty,boostLevel:f,marginSize:m,imageSettings:h}=o,x=hl(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:b}=x,v=hl(x,["style"]),w=h?.src,y=Ge.useRef(null),N=Ge.useRef(null),k=Ge.useCallback(M=>{y.current=M,typeof n=="function"?n(M):n&&(n.current=M)},[n]),[C,D]=Ge.useState(!1),{margin:E,cells:I,numCells:z,calculatedImageSettings:A}=zy({value:s,level:i,minVersion:p,boostLevel:f,includeMargin:d,marginSize:m,imageSettings:h,size:a});Ge.useEffect(()=>{if(y.current!=null){const M=y.current,$=M.getContext("2d");if(!$)return;let L=I;const O=N.current,F=A!=null&&O!==null&&O.complete&&O.naturalHeight!==0&&O.naturalWidth!==0;F&&A.excavation!=null&&(L=Oy(I,A.excavation));const B=window.devicePixelRatio||1;M.height=M.width=a*B;const j=a/z*B;$.scale(j,j),$.fillStyle=l,$.fillRect(0,0,z,z),$.fillStyle=c,oD?$.fill(new Path2D(Ry(L,E))):I.forEach(function(H,_){H.forEach(function(q,G){q&&$.fillRect(G+E,_+E,1,1)})}),A&&($.globalAlpha=A.opacity),F&&$.drawImage(O,A.x+E,A.y+E,A.w,A.h)}}),Ge.useEffect(()=>{D(!1)},[w]);const T=ml({height:a,width:a},b);let R=null;return w!=null&&(R=Ge.createElement("img",{src:w,key:w,style:{display:"none"},onLoad:()=>{D(!0)},ref:N,crossOrigin:A?.crossOrigin})),Ge.createElement(Ge.Fragment,null,Ge.createElement("canvas",ml({style:T,height:a,width:a,ref:k,role:"img"},v)),R)});sD.displayName="QRCodeCanvas";var By=Ge.forwardRef(function(t,n){const o=t,{value:s,size:a=Py,level:i=_y,bgColor:l=$y,fgColor:c=Dy,includeMargin:d=Ly,minVersion:p=Ty,boostLevel:f,title:m,marginSize:h,imageSettings:g}=o,x=hl(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:b,cells:v,numCells:w,calculatedImageSettings:y}=zy({value:s,level:i,minVersion:p,boostLevel:f,includeMargin:d,marginSize:h,imageSettings:g,size:a});let N=v,k=null;g!=null&&y!=null&&(y.excavation!=null&&(N=Oy(v,y.excavation)),k=Ge.createElement("image",{href:g.src,height:y.h,width:y.w,x:y.x+b,y:y.y+b,preserveAspectRatio:"none",opacity:y.opacity,crossOrigin:y.crossOrigin}));const C=Ry(N,b);return Ge.createElement("svg",ml({height:a,width:a,viewBox:`0 0 ${w} ${w}`,ref:n,role:"img"},x),!!m&&Ge.createElement("title",null,m),Ge.createElement("path",{fill:l,d:`M0,0 h${w}v${w}H0z`,shapeRendering:"crispEdges"}),Ge.createElement("path",{fill:c,d:C,shapeRendering:"crispEdges"}),k)});By.displayName="QRCodeSVG";const aD=192;function Fy({value:e,size:t=aD,className:n,alt:o}){const s=e.trim();return s.length===0?null:r("div",{className:K("inline-flex rounded-md bg-white p-2",n),children:r(By,{value:s,size:t,marginSize:1,title:o??"QR code"})})}const iD=2e3;function jy({value:e,label:t,className:n,disabled:o}){const[s,a]=P(!1),i=U(()=>{e&&navigator.clipboard.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),iD)})},[e]);return u(ze,{size:"sm",variant:"ghost",type:"button",disabled:o||e.length===0,onClick:i,className:K(n),"aria-label":s?"Copied":`Copy ${t??"value"}`,children:[s?r(Oo,{className:"h-3.5 w-3.5 text-success"}):r(_n,{className:"h-3.5 w-3.5"}),t?r("span",{className:"ml-1",children:s?"Copied":t}):null]})}const lD=MN(NN),Wu=1e4;function Yu(e){return e==="linked"?"success":e==="error"?"danger":"warning"}function Zu(e){return e==="linked"?"Linked":e==="unlinked"?"Unlinked":e==="error"?"Error":e}function cD({field:e}){const[t,n]=P(!1),o=e.secret===!0,a=o&&!t?"•".repeat(Math.min(e.value.length,24)):e.value;return u("div",{className:"flex items-center gap-2 py-1.5",children:[r("span",{className:"text-[11px] text-foreground-subtle w-32 shrink-0",children:e.label}),r("span",{className:"flex-1 min-w-0 truncate font-mono text-xs text-foreground",children:a||"—"}),o&&r(ze,{size:"sm",variant:"ghost",type:"button","aria-label":t?"Hide value":"Reveal value",onClick:()=>n(i=>!i),children:t?r(cc,{className:"h-3.5 w-3.5"}):r(Rr,{className:"h-3.5 w-3.5"})}),r(jy,{value:e.value,label:e.label})]})}function dD({setup:e}){const t=e.fields??[];return u("div",{className:"border-b border-border bg-surface-hover/10",children:[u("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border",children:[r(QS,{className:"h-3.5 w-3.5 text-foreground-subtle shrink-0"}),r("span",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Setup"})]}),u("div",{className:"flex flex-col gap-3 p-4 sm:flex-row sm:items-start",children:[e.qr&&r("div",{className:"shrink-0",children:r(Fy,{value:e.qr,alt:"Pairing QR code"})}),u("div",{className:"flex-1 min-w-0",children:[e.note&&r("p",{className:"text-xs text-foreground-muted whitespace-pre-line mb-2",children:e.note}),t.length>0&&r("div",{className:"divide-y divide-border-subtle",children:t.map(n=>r(cD,{field:n},n.label))})]})]})]})}function sd({addonId:e,onOpenDevice:t}){const n=we(),o=Fc({nodeId:"hub",addonId:e},{refetchInterval:Wu,retry:!1}),s=ob({nodeId:"hub",addonId:e},{refetchInterval:Wu,retry:!1}),a=sb({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceExport"]]})}}),i=V(()=>{const h=Cm.safeParse(o.data);return h.success?h.data:null},[o.data]),l=V(()=>{const h=lD.safeParse(s.data);return h.success?h.data:[]},[s.data]),c=i?.linkState??"unlinked",d=V(()=>l.map(h=>({deviceId:h.deviceId,displayName:h.exposedAs??`Device ${h.deviceId}`,streamPreference:"auto",linkState:c})),[l,c]),p=o.isLoading||s.isLoading,f=i?.exposedDeviceCount??d.length,m=V(()=>[{key:"device",header:"Device",render:h=>u("div",{className:"flex flex-col",children:[r("span",{className:"text-foreground font-medium",children:h.displayName}),u("span",{className:"text-foreground-subtle text-xs font-mono",children:["#",h.deviceId]})]})},{key:"status",header:"Status",render:h=>r(Lt,{variant:Yu(h.linkState),children:Zu(h.linkState)})},{key:"stream",header:"Stream",render:h=>r("span",{className:"text-xs text-foreground-subtle font-mono",children:h.streamPreference==="auto"?"Auto":h.streamPreference})},{key:"actions",header:"",align:"right",render:h=>u("div",{className:"flex items-center justify-end gap-2",children:[t&&u(ze,{size:"sm",variant:"ghost",onClick:()=>t(h.deviceId),children:[r(lc,{className:"h-3.5 w-3.5 mr-1"}),"Open"]}),u(ze,{size:"sm",variant:"ghost",disabled:a.isPending,onClick:()=>a.mutate({deviceId:h.deviceId,nodeId:"hub",addonId:e}),children:[r(D5,{className:"h-3.5 w-3.5 mr-1"}),"Unexpose"]})]})}],[t,a,e]);return u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 border-b border-border bg-surface-hover/20",children:[u("div",{className:"flex items-center gap-2 min-w-0",children:[r(bu,{className:"h-3.5 w-3.5 text-foreground-subtle shrink-0"}),r("span",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Exported devices"}),r(Lt,{variant:Yu(c),children:Zu(c)}),u("span",{className:"text-[11px] text-foreground-subtle",children:[f," exposed"]})]}),p&&r(mt,{className:"h-3.5 w-3.5 animate-spin text-foreground-subtle"})]}),i?.error&&r("div",{className:"px-4 py-3 border-b border-border",children:r(va,{message:i.error})}),i?.setup&&r(dD,{setup:i.setup}),d.length===0?r(Ac,{icon:bu,title:"No devices exposed",description:`Expose a camera to "${e}" from its device-details page to surface it in the connected ecosystem.`}):r("div",{className:"p-3",children:r(zo,{columns:m,rows:d,rowKey:h=>h.deviceId})})]})}function uD({samples:e,sampleRate:t=16e3,height:n=96,className:o="",color:s="#3b82f6",bgColor:a="transparent"}){const i=re(null),l=re(null),c=U(()=>{const f=i.current,m=l.current;if(!f||!m||!e||e.length===0)return;const h=m.clientWidth;if(h===0)return;const g=window.devicePixelRatio||1;f.width=h*g,f.height=n*g,f.style.width=`${h}px`,f.style.height=`${n}px`;const x=f.getContext("2d");if(!x)return;x.scale(g,g),a!=="transparent"?(x.fillStyle=a,x.fillRect(0,0,h,n)):x.clearRect(0,0,h,n);const b=e.length/h,v=n/2;x.fillStyle=s,x.globalAlpha=.7;for(let w=0;w<h;w++){const y=Math.floor(w*b),N=Math.min(Math.floor((w+1)*b),e.length);let k=0,C=0;for(let z=y;z<N;z++){const A=e[z];A<k&&(k=A),A>C&&(C=A)}const D=v-C*v,E=v-k*v,I=Math.max(1,E-D);x.fillRect(w,D,1,I)}x.globalAlpha=1,x.strokeStyle=s,x.globalAlpha=.2,x.lineWidth=1,x.beginPath(),x.moveTo(0,v),x.lineTo(h,v),x.stroke(),x.globalAlpha=1},[e,n,s,a]);Y(()=>{c()},[c]),Y(()=>{const f=new ResizeObserver(()=>c()),m=l.current;return m&&f.observe(m),()=>f.disconnect()},[c]);const p=((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:[p,"s · ",t/1e3,"kHz · ",e.length.toLocaleString()," samples"]})]})}function pD({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=re(null),p=re(null),[f,m]=P([]);Y(()=>{e!==null&&m(x=>{const b=[...x,{dbfs:e,timestamp:Date.now()}];return b.length>n?b.slice(-n):b})},[e,n]);const h=U(()=>{const x=d.current,b=p.current;if(!x||!b)return;const v=b.clientWidth;if(v===0)return;const w=window.devicePixelRatio||1;x.width=v*w,x.height=o*w,x.style.width=`${v}px`,x.style.height=`${o}px`;const y=x.getContext("2d");if(!y||(y.scale(w,w),y.clearRect(0,0,v,o),f.length===0))return;const N=f[f.length-1].timestamp,k=t*1e3,C=N-k,D=f.filter(A=>A.timestamp>=C);if(D.length===0)return;const E=Math.max(1,Math.floor(v/(t*2))),I=Math.abs(c);for(const A of D){const T=A.timestamp-C,R=Math.floor(T/k*v),$=(Math.max(c,Math.min(0,A.dbfs))-c)/I,L=Math.max(1,$*o),O=A.dbfs>=l;y.fillStyle=O?i:a,y.globalAlpha=.8,y.fillRect(R,o-L,E,L)}y.globalAlpha=1;const z=o-(l-c)/I*o;y.strokeStyle=i,y.globalAlpha=.25,y.lineWidth=1,y.setLineDash([4,4]),y.beginPath(),y.moveTo(0,z),y.lineTo(v,z),y.stroke(),y.setLineDash([]),y.globalAlpha=1},[f,t,o,a,i,l,c]);Y(()=>{h()},[h]),Y(()=>{const x=new ResizeObserver(()=>h()),b=p.current;return b&&x.observe(b),()=>x.disconnect()},[h]);const g=f.length>0?f[f.length-1].dbfs:null;return u("div",{ref:p,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 · ",f.length," samples"]})]})}function fD(e){return e>=.8?"bg-emerald-500":e>=.5?"bg-amber-500":e>=.3?"bg-orange-500":"bg-zinc-500"}function mD(e){return e>=.8?"text-emerald-400":e>=.5?"text-amber-400":e>=.3?"text-orange-400":"text-zinc-400"}function hD({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 ${fD(l.score)}`,style:{width:`${d}%`}})}),u("span",{className:`text-xs font-mono font-semibold w-14 text-right ${mD(l.score)}`,children:[(l.score*100).toFixed(1),"%"]})]},`${l.className}-${c}`)})})]})}function gD({data:e,label:t="Response",className:n=""}){const[o,s]=P(!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 bD={Activity:Nn,Eye:Rr,AlertTriangle:zr,PauseCircle:qk,PowerOff:US};function ad({phase:e,...t}){const n=Lr(e),o=bD[n.icon];return r(o,{...t})}function mr(e){const[t,n]=P([]),o=U(a=>{n(i=>{const l=[...i,a];return l.length>e?l.slice(-e):l})},[e]),s=U(()=>{n([])},[]);return V(()=>({entries:t,append:o,reset:s}),[t,o,s])}function Xu(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 Ju={error:{icon:Tr,color:"text-red-400"},warn:{icon:zr,color:"text-amber-400"},info:{icon:vS,color:"text-blue-400"},debug:{icon:Ek,color:"text-gray-500"}},ep={debug:0,info:1,warn:2,error:3},xD=["all","debug","info","warn","error"],yD=500;function vD(e,t){return t?(ep[e]??0)>=(ep[t]??0):!0}function Zt({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:p,onClose:f,className:m}){const[h,g]=P(""),[x,b]=P(""),[v,w]=P(a),y=e,N=t??(h||void 0),k=n??(x?Number(x):void 0),C=o,D=s,E=V(()=>{const te={};return y&&(te.agentId=y),N&&(te.addonId=N),k!==void 0&&Number.isFinite(k)&&(te.deviceId=k),C&&(te.integrationId=C),D&&(te.requestId=D),Object.keys(te).length>0?te:void 0},[y,N,k,C,D]),I=mr(yD),z=p??I,A=z.entries,[T,R]=P(0),[M,$]=P(!1),[L,O]=P(!1),[F,B]=P(new Set),[j,H]=P(""),_=re(null),q=`${y??""}:${N??""}:${String(k??"")}:${C??""}:${D??""}`,G=re(q);Y(()=>{G.current!==q&&(G.current=q,z.reset(),R(0),B(new Set))},[q,z]);const{data:Q,isLoading:J}=S.logs.query.useQuery({...E?{tags:E}:{},limit:d},{staleTime:3e4});S.logs.subscribe.useSubscription({...E?{tags:E}:{}},{onData:te=>{z.append(te)}});const Z=re(A.length);Y(()=>{const te=_.current;if(!te){Z.current=A.length;return}const ye=Z.current;if(Z.current=A.length,!(A.length<=ye)){if(M&&te.scrollTop<=8)te.scrollTo({top:0});else if(!M&&te.scrollTop>0){const ke=te.querySelector("tbody tr"),pe=ke instanceof HTMLElement?ke.offsetHeight:24;te.scrollTop+=pe*(A.length-ye)}}},[A.length,M]);const X=V(()=>{const te=(Q??[]).map(ce=>({timestamp:ce.timestamp,level:ce.level,message:ce.message,scope:ce.scope,tags:ce.tags,meta:ce.meta})),ye=new Set,ke=[];for(const ce of[...A].reverse()){const $e=`${ce.timestamp}|${ce.level}|${ce.scope??""}|${ce.message}`;ye.has($e)||(ye.add($e),ke.push(ce))}for(const ce of te){const $e=`${ce.timestamp}|${ce.level}|${ce.scope??""}|${ce.message}`;ye.has($e)||(ye.add($e),ke.push(ce))}const le=(T>0?ke.filter(ce=>new Date(ce.timestamp).getTime()>T):ke).filter(ce=>vD(ce.level,v)),Ce=j.trim().toLowerCase();return Ce?le.filter(ce=>{if(ce.message.toLowerCase().includes(Ce)||ce.scope&&ce.scope.toLowerCase().includes(Ce))return!0;if(ce.tags){for(const $e of Object.values(ce.tags))if($e!==void 0&&String($e).toLowerCase().includes(Ce))return!0}if(ce.meta){for(const $e of Object.values(ce.meta))if($e!=null&&Xu($e).toLowerCase().includes(Ce))return!0}return!1}):le},[Q,A,v,T,j]),oe=U(()=>{const te=X.map(ye=>{const ke=new Date(ye.timestamp).toLocaleTimeString(),pe=ye.tags?" "+Object.entries(ye.tags).filter(([,le])=>le).map(([le,Ce])=>`${le}=${Ce}`).join(" "):"";return`${ke} [${ye.level.toUpperCase()}]${ye.scope?` [${ye.scope}]`:""}${pe} ${ye.message}`});navigator.clipboard.writeText(te.join(`
|
|
560
|
+
`)).then(()=>{O(!0),setTimeout(()=>O(!1),1500)})},[X]),he=S.logs.clear.useMutation(),ee=U(()=>{R(Date.now()),z.reset(),he.mutate({...E?{tags:E}:{}})},[z,he,E]),W=U(te=>{B(ye=>{const ke=new Set(ye);return ke.has(te)?ke.delete(te):ke.add(te),ke})},[]),[ne,ie]=P(null),fe=U((te,ye)=>{const ke=new Date(te.timestamp).toISOString(),pe=te.tags?" "+Object.entries(te.tags).filter(([,ce])=>ce).map(([ce,$e])=>`${ce}=${$e}`).join(" "):"",le=te.meta&&Object.keys(te.meta).length>0?` meta=${JSON.stringify(te.meta)}`:"",Ce=`${ke} [${te.level.toUpperCase()}]${te.scope?` [${te.scope}]`:""}${pe} ${te.message}${le}`;navigator.clipboard.writeText(Ce).then(()=>{ie(ye),setTimeout(()=>ie(ce=>ce===ye?null:ce),1200)})},[]),me=U(te=>`${te.timestamp}|${te.level}|${te.scope??""}|${te.message}`,[]);return u("div",{className:K("h-full min-h-0 flex flex-col",m),onClick:te=>te.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"}),y&&r(pi,{label:"agent",value:y}),N&&r(pi,{label:"addon",value:N}),k!==void 0&&r(pi,{label:"device",value:`#${k}`}),r("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:xD.map(te=>u("button",{type:"button",onClick:()=>w(te==="all"?void 0:te),className:K("px-1.5 py-0.5 capitalize transition-colors",te==="all"&&!v||v===te?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover",te!=="all"&&"border-l border-border"),children:[te,te!=="all"?"+":""]},te))}),r(fi,{icon:nh,label:M?"Auto":"Paused",active:!M,onClick:()=>{$(te=>!te),!M&&_.current&&_.current.scrollTo({top:0,behavior:"smooth"})}}),r(fi,{icon:_n,label:L?"Copied!":"Copy",onClick:oe,disabled:X.length===0}),r(fi,{icon:ln,label:"Clear",onClick:ee}),u("div",{className:"relative",children:[r("input",{type:"text",value:j,onChange:te=>H(te.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(Je,{className:"h-2.5 w-2.5"})})]}),A.length>0&&u("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",A.length," live"]})]}),f&&r("button",{type:"button",onClick:f,className:"text-foreground-subtle hover:text-foreground",children:r(Je,{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:te=>g(te.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:x,onChange:te=>b(te.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:_,className:K("flex-1 min-h-0 overflow-auto font-mono text-[10px]",i),children:[J&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[r(mt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading logs..."]}),!J&&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(te=>{const ye=Ju[te.level]??Ju.info,ke=ye.icon,pe=me(te),le=F.has(pe),Ce=te.tags&&Object.keys(te.tags).length>0,ce=te.meta&&Object.keys(te.meta).length>0,$e=Ce||ce;return u("tr",{className:K("hover:bg-surface-hover/30 border-b border-border/30",$e&&"cursor-pointer"),onClick:$e?()=>W(pe):void 0,children:[r("td",{className:"px-2 py-1 text-foreground-subtle whitespace-nowrap align-top w-[70px]",children:new Date(te.timestamp).toLocaleTimeString()}),r("td",{className:K("px-1 py-1 align-top w-5",ye.color),children:r(ke,{className:"h-3 w-3"})}),l&&r("td",{className:"px-2 py-1 text-foreground-subtle align-top truncate max-w-[120px]",title:te.scope,children:te.scope?.replace(/^addon:/,"")??""}),r("td",{className:"px-2 py-1 text-foreground break-all",children:u("div",{className:"flex items-start gap-1",children:[$e&&(le?r(er,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"}):r(Pn,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"})),u("div",{className:"flex-1 min-w-0",children:[te.message,le&&$e&&u("div",{className:"mt-1 text-[9px] text-foreground-subtle bg-surface rounded px-2 py-1 space-y-0.5",children:[ce&&Object.entries(te.meta).filter(([,Ie])=>Ie!==void 0&&Ie!=="").map(([Ie,Xe])=>u("div",{children:[r("span",{className:"text-amber-400/80 font-medium",children:Ie}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground break-all",children:Xu(Xe)})]},`m-${Ie}`)),Ce&&Object.entries(te.tags).filter(([,Ie])=>Ie!==void 0).map(([Ie,Xe])=>u("div",{children:[r("span",{className:"text-primary/70 font-medium",children:Ie}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground",children:Xe})]},`t-${Ie}`))]})]})]})}),r("td",{className:"px-1 py-1 align-top w-5",children:r(wD,{copied:ne===pe,onCopy:()=>fe(te,pe)})})]},pe)})})})]})]})}function Hy({position:e="bottom",className:t,...n}){return r("div",{className:K(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(Zt,{maxHeight:"max-h-48",...n})})}function pi({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 wD({copied:e,onCopy:t}){return r("button",{type:"button",title:"Copy this row",onClick:n=>{n.stopPropagation(),t()},className:K("rounded p-0.5 transition-colors",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?r(Oo,{className:"h-3 w-3"}):r(_n,{className:"h-3 w-3"})})}function fi({icon:e,label:t,onClick:n,disabled:o,active:s}){return u("button",{type:"button",onClick:n,disabled:o,className:K("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 ND(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 kD={[ve.AddonStarted]:{icon:sl,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Started"},[ve.AddonInstalled]:{icon:rl,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Installed"},[ve.AddonRestarted]:{icon:ga,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Restarted"},[ve.AddonUpdated]:{icon:gh,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Updated"},[ve.AddonStopped]:{icon:xu,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Stopped"},[ve.AddonUninstalled]:{icon:ln,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Uninstalled"},[ve.AddonCrashed]:{icon:Tr,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Crashed"},[ve.AddonError]:{icon:zr,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Error"},[ve.DetectionPhaseTransition]:{icon:Nn,color:"bg-violet-500/15 text-violet-400 border-violet-500/30",label:"Phase"},[ve.DetectionResult]:{icon:n5,color:"bg-purple-500/15 text-purple-400 border-purple-500/30",label:"Detection"},[ve.DetectionEvent]:{icon:Rr,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Event"},[ve.DetectionCameraNative]:{icon:yu,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Camera AI"},[ve.ProviderMotion]:{icon:vu,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[ve.MotionOnMotionChanged]:{icon:vu,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[ve.MotionAnalysis]:{icon:Nn,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion analysis"},[ve.MotionZonesRaw]:{icon:Nn,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion zones"},[ve.ProviderDetection]:{icon:yu,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Provider Det"},[ve.PipelineAudioInferenceResult]:{icon:dh,color:"bg-pink-500/15 text-pink-400 border-pink-500/30",label:"Audio"},[ve.AgentOnline]:{icon:sl,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Agent Online"},[ve.AgentOffline]:{icon:xu,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Agent Offline"},[ve.DeviceRegistered]:{icon:rl,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Registered"},[ve.DeviceUnregistered]:{icon:ln,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Unregistered"},[ve.DeviceStateChanged]:{icon:Nn,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"State"}};function gl(e,t){const n=kD[e]??{icon:sl,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:e.split(".").pop()??e};if(e===ve.DeviceStateChanged&&t&&typeof t.capName=="string"){const o=t.capName;return{...n,label:o}}return n}const lr=Object.freeze([...new Set(Object.values(ve))].sort()),SD=Object.freeze([ve.PipelineCameraMetricsSnapshot,ve.PipelineRunnerLoadSnapshot,ve.PipelineEngineMetricsSnapshot,ve.PipelineInferenceResult,ve.PipelineTrace,ve.PipelineProgress,ve.StreamBrokerMetricsSnapshot,ve.MetricsNodeResourcesSnapshot,ve.MetricsNodeProcessesSnapshot,ve.ClusterTopologySnapshot,ve.MotionAnalysis,ve.MotionZonesRaw,ve.DetectionResult,ve.PipelineAudioInferenceResult,ve.PlatformProbePhase,ve.BenchmarkProgress,ve.ModelDownloadProgress]),CD=new Set(SD),MD=Object.freeze(lr.filter(e=>!CD.has(e)));function Es(e,t){if(e===ve.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===ve.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,p=typeof d=="string"?d:"";p&&i.set(p,(i.get(p)??0)+1)}return[...i.entries()].map(([l,c])=>c>1?`${l} ×${c}`:l).join(", ")}if(e===ve.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:"",p=l.score;return p?`${d} (${Math.round(p*100)}%)`:d}).filter(Boolean).join(", ")}if(e===ve.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===ve.ProviderMotion)return t.active===!0?"motion start":"motion stop";if(e===ve.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===ve.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===ve.ProviderDetection||e===ve.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 AD(e){const t=e.category;return t===ve.DetectionResult||t===ve.PipelineAudioInferenceResult?Es(t,e.data)!==null:!0}const ED=300;function sr({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:p,onClose:f,className:m}){const h=V(()=>o??s??MD,[o,s]),g=V(()=>[...h].sort().join(","),[h]),[x,b]=P(()=>new Set(h)),v=re(g);Y(()=>{v.current!==g&&(v.current=g,b(new Set(h)))},[g,h]);const w=mr(ED),y=p??w,N=y.entries,[k,C]=P(!0),[D,E]=P(new Set),[I,z]=P(""),[A,T]=P(!1),[R,M]=P(""),[$,L]=P(0),O=re(null),F=re(null),B=`${e??""}:${t??""}:${String(n??"")}:${a??""}`,j=re(B);Y(()=>{j.current!==B&&(j.current=B,y.reset(),E(new Set),L(0))},[B,y]),Y(()=>{if(!A)return;const de=_e=>{const Re=F.current;Re&&_e.target instanceof Node&&!Re.contains(_e.target)&&T(!1)};return document.addEventListener("mousedown",de),()=>{document.removeEventListener("mousedown",de)}},[A]);const H=V(()=>{const de={};return e&&(de.agentId=e),t&&(de.addonId=t),n!==void 0&&(de.deviceId=n),a&&(de.category=a),de},[e,t,n,a]),_=V(()=>[...x].sort(),[x]),q=V(()=>_.join(","),[_]),G=V(()=>{const de={...H,limit:l};return _.length>0&&_.length<lr.length&&(de.category=_),de},[H,l,q,_]),{data:Q,isLoading:J}=S.systemEvents.getRecent.useQuery(G,{staleTime:3e4}),Z=re(x);Y(()=>{Z.current=x},[x]);const X=H;S.systemEvents.subscribe.useSubscription(X,{onData:de=>{const _e=de;_e?.id&&ND(_e,e,t,n)&&Z.current.has(_e.category)&&y.append(_e)}});const oe=re(N.length);Y(()=>{const de=O.current;if(!de){oe.current=N.length;return}const _e=oe.current;if(oe.current=N.length,!(N.length<=_e)){if(k&&de.scrollTop<=8)de.scrollTo({top:0});else if(!k&&de.scrollTop>0){const Re=de.firstElementChild?.firstElementChild,Oe=Re instanceof HTMLElement?Re.offsetHeight:28;de.scrollTop+=Oe*(N.length-_e)}}},[N.length,k]);const he=V(()=>{const de=new Map;for(const Oe of Q??[])de.set(Oe.id,Oe);for(const Oe of N)de.set(Oe.id,Oe);let _e=[...de.values()].filter(Oe=>x.has(Oe.category)).filter(AD);$>0&&(_e=_e.filter(Oe=>new Date(Oe.timestamp).getTime()>$));const Re=I.trim().toLowerCase();return Re&&(_e=_e.filter(Oe=>{if(Oe.category.toLowerCase().includes(Re)||gl(Oe.category,Oe.data).label.toLowerCase().includes(Re))return!0;const Tn=Es(Oe.category,Oe.data);if(Tn&&Tn.toLowerCase().includes(Re))return!0;try{if(new Date(Oe.timestamp).toLocaleTimeString().toLowerCase().includes(Re))return!0}catch{}try{if(JSON.stringify(Oe.data).toLowerCase().includes(Re)||JSON.stringify(Oe.source).toLowerCase().includes(Re))return!0}catch{}return!1})),_e.sort((Oe,Ln)=>new Date(Ln.timestamp).getTime()-new Date(Oe.timestamp).getTime())},[Q,N,x,I,$]),ee=U(de=>{E(_e=>{const Re=new Set(_e);return Re.has(de)?Re.delete(de):Re.add(de),Re})},[]),W=U(de=>{b(_e=>{const Re=new Set(_e);return Re.has(de)?Re.delete(de):Re.add(de),Re})},[]),ne=U(()=>{b(new Set(h)),z(""),L(0)},[h]),ie=U(()=>{L(Date.now()),y.reset()},[y]),[fe,me]=P(!1),[te,ye]=P(null),ke=U(de=>{const _e=new Date(de.timestamp).toISOString(),Re=Es(de.category,de.data)??"",Oe=Re?` ${Re}`:"";return`${_e} [${de.category}]${Oe} data=${JSON.stringify(de.data)}`},[]),pe=U(()=>{const de=he.map(ke);navigator.clipboard.writeText(de.join(`
|
|
561
|
+
`)).then(()=>{me(!0),setTimeout(()=>me(!1),1500)})},[he,ke]),le=U(de=>{navigator.clipboard.writeText(ke(de)).then(()=>{ye(de.id),setTimeout(()=>ye(_e=>_e===de.id?null:_e),1200)})},[ke]),Ce=U(()=>{b(new Set(lr))},[]),ce=U(()=>{b(new Set)},[]),$e=V(()=>{const de=R.trim().toLowerCase();return de?lr.filter(_e=>_e.toLowerCase().includes(de)):lr},[R]),Ie=lr.length,Xe=x.size,lt=Xe===Ie,ar=lt?"All":`${Xe}/${Ie}`;return u("div",{className:K("h-full min-h-0 flex flex-col",m),onClick:de=>de.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(os,{label:"agent",value:e}),t&&r(os,{label:"addon",value:t}),n!==void 0&&r(os,{label:"device",value:`#${n}`}),a&&r(os,{label:"category",value:a}),u("button",{type:"button",onClick:()=>{C(de=>!de),!k&&O.current&&O.current.scrollTo({top:0,behavior:"smooth"})},className:K("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(nh,{className:"h-2.5 w-2.5"}),k?"Auto":"Paused"]}),c&&u("div",{className:"relative",ref:F,children:[u("button",{type:"button",onClick:()=>T(de=>!de),className:K("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",lt?"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(ih,{className:"h-2.5 w-2.5"}),"Filter (",ar,")"]}),A&&r(ID,{search:R,onSearchChange:M,categories:$e,active:x,onToggle:W,onSelectAll:Ce,onSelectNone:ce,onResetDefaults:ne})]}),u("button",{type:"button",onClick:ne,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(fh,{className:"h-2.5 w-2.5"}),"Reset"]}),u("button",{type:"button",onClick:ie,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(ln,{className:"h-2.5 w-2.5"}),"Clear"]}),u("button",{type:"button",onClick:pe,disabled:he.length===0,className:K("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",he.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible events",children:[r(_n,{className:"h-2.5 w-2.5"}),fe?"Copied!":"Copy"]}),u("div",{className:"relative",children:[r("input",{type:"text",value:I,onChange:de=>z(de.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"}),I&&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(Je,{className:"h-2.5 w-2.5"})})]}),N.length>0&&u("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",N.length," live"]})]}),f&&r("button",{type:"button",onClick:f,className:"text-foreground-subtle hover:text-foreground",children:r(Je,{className:"h-3.5 w-3.5"})})]}),u("div",{ref:O,className:K("flex-1 min-h-0 overflow-auto text-[10px]",i),children:[J&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[r(mt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading events..."]}),!J&&he.length===0&&r("div",{className:"py-4 text-center text-foreground-subtle",children:"No events found"}),he.length>0&&r("div",{className:"divide-y divide-border/30",children:he.map(de=>{const _e=gl(de.category,de.data),Re=_e.icon,Oe=Es(de.category,de.data),Ln=D.has(de.id);return u("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>ee(de.id),children:[r("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(de.timestamp).toLocaleTimeString()}),r(_D,{copied:te===de.id,onCopy:()=>le(de)}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5",children:[Ln?r(er,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):r(Pn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),u("span",{className:K("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[9px] font-medium",_e.color),children:[r(Re,{className:"h-2.5 w-2.5"}),_e.label]}),de.source.nodeId&&de.source.nodeId!=="hub"&&r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-foreground-subtle/10 text-foreground-subtle font-mono",children:de.source.nodeId})]}),Oe&&r("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5",children:Oe}),Ln&&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(de.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:de.category})]}),Object.entries(de.data).map(([Tn,Kr])=>u("div",{children:[r("span",{className:"text-primary/70",children:Tn}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground break-all",children:typeof Kr=="object"?JSON.stringify(Kr):String(Kr)})]},Tn))]})]})]},de.id)})})]})]})}function ID({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(xo,{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(Je,{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),p=gl(c),f=p.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:K("inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[9px] font-medium shrink-0",p.color),children:[r(f,{className:"h-2.5 w-2.5"}),p.label]}),r("span",{className:"text-foreground-subtle font-mono truncate",children:c})]},c)})]})]})}function PD({position:e="bottom",className:t,...n}){return r("div",{className:K(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(sr,{maxHeight:"max-h-48",...n})})}function os({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 _D({copied:e,onCopy:t}){return r("button",{type:"button",title:"Copy this event",onClick:n=>{n.stopPropagation(),t()},className:K("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(Oo,{className:"h-3 w-3"}):r(_n,{className:"h-3 w-3"})})}function Vy({deviceId:e,className:t="",onOpenChild:n}){const o=S.useUtils(),s=S.deviceDiscovery.listDiscovered.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),a=S.deviceDiscovery.getStatus.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),i=S.deviceDiscovery.refreshDiscovery.useMutation({onSuccess:()=>{o.deviceDiscovery.listDiscovered.invalidate({deviceId:e}),o.deviceDiscovery.getStatus.invalidate({deviceId:e})}}),l=S.deviceDiscovery.adoptDevice.useMutation({onSuccess:()=>{o.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),c=S.deviceDiscovery.releaseDevice.useMutation({onSuccess:()=>{o.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),[d,p]=P(null),{available:f,adopted:m}=V(()=>{const y=s.data??[],N=C=>typeof C.metadata.rtspChannel=="number"?C.metadata.rtspChannel:Number.POSITIVE_INFINITY,k=(C,D)=>{const E=N(C),I=N(D);return E!==I?E-I:C.name.localeCompare(D.name)};return{available:y.filter(C=>!C.alreadyAdopted).sort(k),adopted:y.filter(C=>C.alreadyAdopted).sort(k)}},[s.data]),h=a.data,g=h?.lastError??null,x=h?.lastDiscoveryAt??null;async function b(){await i.mutateAsync({deviceId:e}).catch(()=>{})}async function v(y){p(y.childNativeId);try{await l.mutateAsync({deviceId:e,childNativeId:y.childNativeId})}finally{p(null)}}async function w(y){if(y.adoptedDeviceId!=null){p(y.childNativeId);try{await c.mutateAsync({deviceId:e,childDeviceId:y.adoptedDeviceId})}finally{p(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:b,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(mt,{className:"h-3.5 w-3.5 animate-spin"}):r(ga,{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(zr,{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(mt,{className:"h-5 w-5 animate-spin"})}):f.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(ue,{children:[f.length>0?r(tp,{title:"Available to add",count:f.length,tone:"primary",children:f.map(y=>r(np,{child:y,busy:d===y.childNativeId,onAdopt:v,onRelease:w,onOpenChild:n},y.childNativeId))}):null,m.length>0?r(tp,{title:"Already adopted",count:m.length,tone:"muted",children:m.map(y=>r(np,{child:y,busy:d===y.childNativeId,onAdopt:v,onRelease:w,onOpenChild:n},y.childNativeId))}):null]}),x!=null?u("div",{className:"border-t border-border px-5 py-2 text-[10px] text-foreground-subtle",children:["Last refreshed ",new Date(x).toLocaleString()]}):null]})}function tp({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 np({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($D,{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(lc,{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(mt,{className:"h-3.5 w-3.5 animate-spin"}):r(ln,{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(mt,{className:"h-3.5 w-3.5 animate-spin"}):r(Or,{className:"h-3.5 w-3.5"}),"Add"]})]})}function $D({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(bh,{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(dc,{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(R5,{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(oh,{className:"h-2.5 w-2.5"})," unknown"]})}}function DD(e,t){if(!e||typeof e!="object")return null;const n=e;if(n.category!==ve.DeviceStateChanged)return null;const o=n.data;return!o||typeof o!="object"||o.deviceId!==t||typeof o.capName!="string"||!o.slice||typeof o.slice!="object"?null:{capName:o.capName,slice:o.slice}}function LD(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}const TD=Object.freeze([...new Set(AN.filter(e=>e.scope==="device").map(e=>e.name))].sort()),RD=1;function id({deviceId:e,defaultCaps:t,maxHeight:n="max-h-96",onClose:o,className:s}){const a=V(()=>new Set(t??[]),[t]),[i,l]=P(a),[c,d]=P(""),[p,f]=P(!1),[m,h]=P(""),g=re(null),[x,b]=P(new Map),[v,w]=P(new Map),[,y]=P(0),N=re(e);Y(()=>{N.current!==e&&(N.current=e,b(new Map),w(new Map))},[e]);const{data:k,isLoading:C}=S.deviceState.getAllSnapshots.useQuery({},{staleTime:3e4}),D=re(!1);Y(()=>{if(D.current||!LD(k))return;const Q=k[String(e)];if(D.current=!0,!Q)return;const J=Date.now();b(Z=>{const X=new Map(Z);for(const[oe,he]of Object.entries(Q))X.has(oe)||X.set(oe,{slice:he,updatedAt:J});return X})},[k,e]),Y(()=>{D.current=!1},[e]),S.systemEvents.subscribe.useSubscription({deviceId:e,category:ve.DeviceStateChanged},{onData:Q=>{const J=DD(Q,e);J&&b(Z=>{const X=new Map(Z);return X.set(J.capName,{slice:J.slice,updatedAt:Date.now()}),X})}}),Y(()=>{const Q=setInterval(()=>y(J=>J+1),5e3);return()=>clearInterval(Q)},[]);const E=V(()=>{const Q=new Set(TD);for(const J of x.keys())Q.add(J);return[...Q].sort()},[x]),I=V(()=>{const Q=c.trim().toLowerCase();return[...x.keys()].sort().filter(Z=>i.size>0&&!i.has(Z)?!1:!Q||Z.toLowerCase().includes(Q)?!0:xl(x.get(Z)?.slice??{},Q))},[x,i,c]),z=U(Q=>{l(J=>{const Z=new Set(J);return Z.has(Q)?Z.delete(Q):Z.add(Q),Z})},[]),A=U(()=>{l(new Set(t??[])),d("")},[t]),T=U(()=>{l(new Set(E))},[E]),R=U(()=>{l(new Set)},[]),M=U((Q,J)=>{w(Z=>{const X=new Map(Z);return X.set(Q,!J),X})},[]),$=U((Q,J)=>{const Z=v.get(Q);return Z!==void 0?Z:J<RD},[v]),[L,O]=P(!1),F=U(()=>{const Q={};for(const J of I){const Z=x.get(J);Z&&(Q[J]=Z.slice)}navigator.clipboard.writeText(JSON.stringify(Q,null,2)).then(()=>{O(!0),setTimeout(()=>O(!1),1500)})},[I,x]),B=V(()=>{const Q=m.trim().toLowerCase();return Q?E.filter(J=>J.toLowerCase().includes(Q)):E},[m,E]),j=E.length,H=i.size,_=H===0||H===j,q=_?"All":`${H}/${j}`;Y(()=>{if(!p)return;const Q=J=>{const Z=g.current;Z&&!Z.contains(J.target)&&f(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[p]);const G=c.trim().toLowerCase();return u("div",{className:K("h-full min-h-0 flex flex-col",s),onClick:Q=>Q.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(jD,{label:"device",value:`#${e}`}),u("div",{className:"relative",ref:g,children:[u("button",{type:"button",onClick:()=>f(Q=>!Q),className:K("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",_?"border-border text-foreground-subtle hover:text-foreground":"border-violet-500/30 bg-violet-500/10 text-violet-400"),title:"Pick caps to show",children:[r(ih,{className:"h-2.5 w-2.5"}),"Filter (",q,")"]}),p&&r(HD,{search:m,onSearchChange:h,caps:B,active:i,onToggle:z,onSelectAll:T,onSelectNone:R,onResetDefaults:A})]}),u("button",{type:"button",onClick:A,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(fh,{className:"h-2.5 w-2.5"}),"Reset"]}),u("button",{type:"button",onClick:F,disabled:I.length===0,className:K("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",L?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",I.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy visible state as JSON",children:[r(_n,{className:"h-2.5 w-2.5"}),L?"Copied!":"Copy"]}),u("div",{className:"relative",children:[r("input",{type:"text",value:c,onChange:Q=>d(Q.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"}),c&&r("button",{type:"button",onClick:()=>d(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:r(Je,{className:"h-2.5 w-2.5"})})]}),u("span",{className:"text-[9px] text-emerald-400 font-medium inline-flex items-center gap-1",children:[r("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-400 animate-pulse"}),"live"]})]}),o&&r("button",{type:"button",onClick:o,className:"text-foreground-subtle hover:text-foreground",children:r(Je,{className:"h-3.5 w-3.5"})})]}),u("div",{className:K("flex-1 min-h-0 overflow-auto text-[10px] font-mono",n),children:[C&&x.size===0&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle font-sans",children:[r(mt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading device state..."]}),!C&&x.size===0&&r("div",{className:"py-4 text-center text-foreground-subtle font-sans",children:"No runtime state"}),!C&&x.size>0&&I.length===0&&r("div",{className:"py-4 text-center text-foreground-subtle font-sans",children:"No caps match the filter"}),I.length>0&&r("div",{className:"py-1",children:I.map(Q=>{const J=x.get(Q);return J?r(OD,{capName:Q,slice:J.slice,updatedAt:J.updatedAt,searchNeedle:G,isPathOpen:$,onToggle:M},Q):null})})]})]})}function OD({capName:e,slice:t,updatedAt:n,searchNeedle:o,isPathOpen:s,onToggle:a}){const i=e,l=s(i,0),c=Object.entries(t);return u("div",{children:[u("div",{className:"flex items-center gap-1.5 px-3 py-1 hover:bg-surface-hover/30 cursor-pointer select-none",onClick:()=>a(i,l),children:[r(Qy,{open:l,hasChildren:c.length>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 font-sans",children:e}),u("span",{className:"text-[9px] text-foreground-subtle font-sans",children:[c.length," ",c.length===1?"key":"keys"]}),u("span",{className:"ml-auto text-[9px] text-foreground-subtle/70 font-sans tabular-nums",children:["updated ",FD(n)]})]}),l&&r("div",{children:c.length===0?r(qy,{depth:1,label:"empty slice"}):c.map(([d,p])=>r(Uy,{path:`${i}.${d}`,nodeKey:d,value:p,depth:1,searchNeedle:o,isPathOpen:s,onToggle:a},d))})]})}function Uy({path:e,nodeKey:t,value:n,depth:o,searchNeedle:s,isPathOpen:a,onToggle:i}){const l=zD(n),c={paddingLeft:`${12+o*14}px`};if(!l)return u("div",{className:"flex items-start gap-1 px-3 py-0.5",style:c,children:[r("span",{className:K("shrink-0",mi(t,s,"text-primary/70")),children:t}),r("span",{className:"text-foreground-subtle",children:":"}),r("span",{className:K("break-all",mi(bl(n),s,BD(n))),children:bl(n)})]});const d=a(e,o);return u("div",{children:[u("div",{className:"flex items-center gap-1 px-3 py-0.5 hover:bg-surface-hover/30 cursor-pointer select-none",style:c,onClick:()=>i(e,d),children:[r(Qy,{open:d,hasChildren:l.entries.length>0}),r("span",{className:mi(t,s,"text-primary/70"),children:t}),r("span",{className:"text-foreground-subtle/70 text-[9px]",children:l.summary})]}),d&&(l.entries.length===0?r(qy,{depth:o+1,label:l.kind==="array"?"empty array":"empty object"}):l.entries.map(([p,f])=>r(Uy,{path:`${e}.${p}`,nodeKey:p,value:f,depth:o+1,searchNeedle:s,isPathOpen:a,onToggle:i},p)))]})}function qy({depth:e,label:t}){return r("div",{className:"px-3 py-0.5 text-foreground-subtle/60 italic",style:{paddingLeft:`${12+e*14}px`},children:t})}function Qy({open:e,hasChildren:t}){return t?e?r(er,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):r(Pn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):r("span",{className:"inline-block w-3 shrink-0"})}function zD(e){if(Array.isArray(e))return{kind:"array",entries:e.map((t,n)=>[String(n),t]),summary:`[${e.length}]`};if(e&&typeof e=="object"){const t=Object.entries(e);return{kind:"object",entries:t,summary:`{${t.length}}`}}return null}function bl(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 BD(e){return e==null?"text-foreground-subtle/60":typeof e=="number"?"text-amber-400":typeof e=="boolean"?e?"text-emerald-400":"text-rose-400":"text-foreground"}function mi(e,t,n){return t&&e.toLowerCase().includes(t)?K(n,"bg-violet-500/20 rounded px-0.5"):n}function xl(e,t){if(Array.isArray(e))return e.some(n=>xl(n,t));if(e&&typeof e=="object"){for(const[n,o]of Object.entries(e))if(n.toLowerCase().includes(t)||xl(o,t))return!0;return!1}return bl(e).toLowerCase().includes(t)}function FD(e){const t=Date.now()-e;if(t<5e3)return"just now";const n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const o=Math.floor(n/60);return o<60?`${o}m ago`:`${Math.floor(o/60)}h ago`}function jD({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 font-sans",children:[e,": ",t]})}function HD({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 font-sans",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(xo,{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(Je,{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)})]})]})}const hi=500,VD=[{id:"logs",label:"Logs",icon:o5},{id:"events",label:"Events",icon:ha},{id:"state",label:"State",icon:oS}];function UD({deviceId:e,defaultEventCategories:t,defaultStateCaps:n,initialTab:o="events",className:s,maxHeight:a="max-h-96"}){const[i,l]=P(o),c=mr(hi),d=mr(hi),p=mr(hi),f=c.reset,m=d.reset,h=p.reset;return Y(()=>{f(),m(),h()},[e,f,m,h]),u("div",{className:K("flex flex-col h-full min-h-0",s),children:[r("div",{className:"flex items-center gap-1 mb-2 shrink-0",children:VD.map(({id:g,label:x,icon:b})=>u("button",{type:"button",onClick:()=>l(g),className:K("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(b,{className:"h-3.5 w-3.5"}),x]},g))}),u("div",{className:"flex-1 min-h-0 overflow-hidden",children:[i==="logs"&&r(Zt,{deviceId:e,maxHeight:a,showFilters:!1,liveBuffer:c}),i==="events"&&r(sr,{deviceId:e,defaultCategories:t,maxHeight:a,showCategoryFilter:!0,liveBuffer:d}),i==="state"&&r(id,{deviceId:e,defaultCaps:n,maxHeight:a,liveBuffer:p})]})]})}function ld({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:p,onSuccess:f}){const[m,h]=P(!1),[g,x]=P(!1),[b,v]=P(null),w=async()=>{v(null),x(!0);try{const y=await p();f?.(y),h(!1)}catch(y){v(y instanceof Error?y.message:String(y))}finally{x(!1)}};return u(ue,{children:[u(ze,{type:"button",variant:a,size:l,disabled:c,onClick:()=>{v(null),h(!0)},className:d,children:[t&&r(t,{className:"h-3.5 w-3.5"}),e]}),r(kh,{open:m,onOpenChange:y=>!g&&h(y),children:u(gc,{children:[u(Sh,{children:[u(Mh,{className:"flex items-center gap-2",children:[r(zr,{className:"h-4 w-4 text-amber-400"}),n]}),typeof o=="string"?r(Ah,{children:o}):o]}),b&&r("div",{className:K("mt-2 px-3 py-2 rounded border border-danger/40 bg-danger/10","text-xs text-danger"),children:b}),u(Ch,{children:[r(ze,{type:"button",variant:"ghost",size:l,disabled:g,onClick:()=>h(!1),children:"Cancel"}),u(ze,{type:"button",variant:i,size:l,disabled:g,onClick:()=>{w()},children:[g&&r(mt,{className:"h-3.5 w-3.5 animate-spin"}),s??e]})]})]})})]})}function qD(e,t){const n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function QD({trpc:e,deviceId:t,deviceName:n,size:o="sm",className:s}){const[a,i]=P(!1),[l,c]=P(!1),[d,p]=P(null),f=n.replace(/[^a-zA-Z0-9_.-]+/g,"_"),m=U(async k=>{i(!0),p(null),c(!1);try{const C=await e.snapshot.getSnapshot.query({deviceId:t,force:!0});if(!C)throw new Error("No snapshot available");const D=`data:${C.contentType};base64,${C.base64}`;if(k==="copy")try{await navigator.clipboard.writeText(D)}catch{throw new Error("Clipboard unavailable")}else{const E=C.contentType.includes("png")?"png":"jpg",I=new Date().toISOString().replace(/[:.]/g,"-");qD(`${f}-${I}.${E}`,D)}c(!0),setTimeout(()=>c(!1),1500)}catch(C){p(C instanceof Error?C.message:String(C))}finally{i(!1)}},[e,t,f]),h=o==="md"?"h-9 px-3 text-sm gap-2":"h-7 px-2.5 text-[11px] gap-1.5",[g,x]=P(null),[b,v]=P(!1),w=()=>{v(!1);const k=setTimeout(()=>{v(!0),m("copy")},600);x(k)},y=()=>{g&&(clearTimeout(g),x(null)),b||m("download")},N=()=>{g&&(clearTimeout(g),x(null))};return u("button",{type:"button",title:"Click to download · long-press to copy",disabled:a,onPointerDown:w,onPointerUp:y,onPointerLeave:N,onPointerCancel:N,className:K("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(mt,{className:"h-3.5 w-3.5 animate-spin"}):l?r(Oo,{className:"h-3.5 w-3.5 text-success"}):r(ac,{className:"h-3.5 w-3.5"}),"Snapshot"]})}function GD(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 Gy({history:e,limit:t=5,latestIsFresh:n,className:o}){if(e.length===0)return null;const s=n?Ck:ha,a=e.slice(0,t);return u("div",{className:K("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:K("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:GD(i.timestamp)}),r("span",{className:"text-foreground-subtle font-mono text-[10px]",children:new Date(i.timestamp).toLocaleTimeString()})]},`${i.deviceId}-${i.timestamp}`))})]})}function Ky({items:e,header:t,triggerClassName:n,title:o="More actions"}){const[s,a]=P(!1),i=e.filter(l=>!l.hidden);return i.length===0?null:u(jh,{open:s,onOpenChange:a,children:[r(Hh,{title:o,className:K("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(ah,{className:"h-4 w-4"})}),u(Vh,{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:K("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:K("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 KD=[{value:"view",label:"View",icon:Rr,hint:"Read-only — queries + subscriptions"},{value:"create",label:"Create",icon:zS,hint:"Mutations that create or update"},{value:"delete",label:"Delete",icon:ln,hint:"Destructive ops (delete/revoke/reset/…)"}],WD=["device","system"];function YD(){return{type:"capability",target:"",access:["view"]}}function ZD(e){if(e==null)return[];const t=new Set;for(const n of e)if(n.type==="device")for(const o of n.targets)t.add(o);return[...t]}function XD(e,t,n,o){let s;switch(e){case"addon":s=n;break;case"capability":s=o;break;case"category":s=WD.map(i=>({value:i,label:i}));break}if(t==null)return s;const a=new Set(t.filter(i=>i.type!=="device"&&i.type===e).map(i=>i.target));return s.filter(i=>a.has(i.value))}function JD(e,t){if(t==null)return["view","create","delete"];const n=t.filter(s=>s.type!==e.type?!1:s.type==="device"&&e.type==="device"?s.targets.some(a=>e.targets.includes(a)):s.type!=="device"&&e.type!=="device"?s.target===e.target:!1);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 cd({value:e,onChange:t,clampToParent:n,emptyHint:o}){const{data:s}=hn(),{data:a}=$n({}),i=V(()=>(s??[]).map(g=>({value:g.manifest.id,label:g.manifest.id})).sort((g,x)=>g.label.localeCompare(x.label)),[s]),l=V(()=>[...EN].sort().map(g=>({value:g,label:g})),[]),c=V(()=>(a??[]).map(g=>({value:String(g.id),label:`${g.name} (#${g.id} · ${g.addonId})`})).sort((g,x)=>g.label.localeCompare(x.label)),[a]),d=V(()=>n==null?null:ZD(n),[n]),p=(g,x)=>{const b=[...x];switch(g){case"category":return{type:"category",target:"device",access:b};case"capability":return{type:"capability",target:"",access:b};case"addon":return{type:"addon",target:"",access:b};case"device":return{type:"device",targets:[],access:b}}},f=(g,x)=>{t(e.map((b,v)=>{if(v!==g)return b;if(x.type!==void 0&&x.type!==b.type)return p(x.type,x.access??b.access);const w=[...x.access??b.access];return b.type==="device"?{type:"device",targets:[...x.targets??b.targets],access:w}:b.type==="category"?{type:"category",target:x.target??b.target,access:w}:b.type==="capability"?{type:"capability",target:x.target??b.target,access:w}:{type:"addon",target:x.target??b.target,access:w}}))},m=g=>{t(e.filter((x,b)=>b!==g))},h=()=>{t([...e,YD()])};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((g,x)=>{const b=JD(g,n);return u("div",{className:"flex flex-wrap items-start gap-1.5 rounded border border-border bg-surface px-2 py-1.5",children:[u("select",{value:g.type,onChange:v=>f(x,{type:v.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:"category",children:"category"}),r("option",{value:"capability",children:"capability"}),r("option",{value:"addon",children:"addon"}),r("option",{value:"device",children:"device"})]}),g.type==="device"?r(eL,{value:g.targets,choices:c,clampToParent:d,onChange:v=>f(x,{targets:v})}):u("select",{value:g.target,onChange:v=>f(x,{target:v.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 ",g.type," —"]}),XD(g.type,n,i,l).map(v=>r("option",{value:v.value,children:v.label},v.value))]}),r("div",{className:"flex items-center gap-1",children:KD.map(({value:v,label:w,icon:y,hint:N})=>{const k=g.access.includes(v),C=n!=null&&!b.includes(v)&&!k;return u("label",{title:C?`${N} — not granted by your scope`:N,className:`inline-flex items-center gap-1 rounded px-1.5 py-1 text-[10px] cursor-pointer transition-colors ${k?"bg-primary/15 text-primary font-medium":"text-foreground-subtle hover:bg-foreground-subtle/10"} ${C?"opacity-40 cursor-not-allowed":""}`,children:[r("input",{type:"checkbox",checked:k,disabled:C,onChange:D=>{const E=new Set(g.access);D.target.checked?E.add(v):E.delete(v),f(x,{access:[...E]})},className:"sr-only"}),r(y,{className:"h-3 w-3"}),w]},v)})}),r("button",{type:"button",onClick:()=>m(x),className:"rounded p-1 text-foreground-subtle hover:bg-danger/10 hover:text-danger transition-colors",title:"Remove scope",children:r(Je,{className:"h-3 w-3"})})]},x)}),u("button",{type:"button",onClick:h,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(Or,{className:"h-3 w-3"}),"Add scope"]})]})}function eL({value:e,choices:t,clampToParent:n,onChange:o}){const[s,a]=P(""),i=V(()=>{const p=n==null?t:t.filter(m=>n.includes(m.value)),f=new Set(e);return p.filter(m=>!f.has(m.value))},[t,n,e]),l=p=>t.find(f=>f.value===p)?.label??`#${p}`,c=p=>{p&&(o([...e,p]),a(""))},d=p=>{o(e.filter(f=>f!==p))};return u("div",{className:"flex-1 min-w-[160px] flex flex-wrap items-center gap-1",children:[e.length===0&&r("span",{className:"text-[10px] text-foreground-subtle italic px-1",children:"no devices selected"}),e.map(p=>u("span",{className:"inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-mono text-primary",children:[l(p),r("button",{type:"button",onClick:()=>d(p),className:"hover:text-danger transition-colors",title:"Remove device",children:r(Je,{className:"h-2.5 w-2.5"})})]},p)),i.length>0&&u("select",{value:s,onChange:p=>c(p.target.value),className:"rounded border border-border bg-background px-1.5 py-0.5 text-[10px] focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"",children:"+ add device…"}),i.map(p=>r("option",{value:p.value,children:p.label},p.value))]})]})}function dd(e){for(const t of e){if(t.type==="device"){if(t.targets.length===0)return"Scope device: pick at least one device"}else if(t.target.trim().length===0)return`Scope ${t.type}: pick a target`;if(t.access.length===0){const n=t.type==="device"?`[${t.targets.join(",")}]`:t.target;return`Scope ${t.type}:${n}: pick at least one access`}}return null}const Wy=mn("camstack:zone-editing",null);function Yy({children:e}){const[t,n]=P(!1),[o,s]=P(null),[a,i]=P(null),[l,c]=P(null),d=U(w=>{n(w),w||(s(null),i(null),c(null))},[]),p=U(w=>{s(w)},[]),f=U(w=>{i(w)},[]),m=U(w=>{n(!0),i(null),s(w),c(null)},[]),h=U(()=>{n(!1),s(null),i(null),c(null)},[]),g=U(w=>{i(w.id),c(w)},[]),x=U(w=>{c(y=>y===null?y:{...y,...w})},[]),b=U(()=>{c(null)},[]),v=V(()=>({editing:t,drawingKind:o,selectedZoneId:a,editingDraft:l,setEditing:d,setDrawingKind:p,setSelectedZoneId:f,startDrawing:m,exitEditing:h,enterDraft:g,updateDraft:x,discardDraft:b}),[t,o,a,l,d,p,f,m,h,g,x,b]);return r(Wy.Provider,{value:v,children:e})}function tL(){return xe(Wy)}const rp=500,nL=800;function ss(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 as(e,t){return e?.id===t}function Zy(e,t){const[n,o]=P(null),[s,a]=P(null),[i,l]=P(null),[c,d]=P("watching"),p=re(void 0),f=re(void 0),m=re(void 0);return Y(()=>{if(t===null)return;const h=ss(e,"detection.motion-analysis",g=>{const x=g;if(!as(x?.source,t))return;const b=x.data;!b?.regions||b.regions.length===0||(o({zones:b.regions.map(v=>({...v.bbox,intensity:v.intensity})),frameWidth:b.frameWidth,frameHeight:b.frameHeight}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>o(null),rp))});return()=>{h?.unsubscribe(),p.current&&clearTimeout(p.current)}},[e,t]),Y(()=>{if(t===null)return;const h=ss(e,"detection.motion-zones-raw",g=>{const x=g;if(!as(x?.source,t))return;const b=x.data;b?.zones&&(a({boxes:b.zones.map(v=>({bbox:v.bbox,changeScore:v.changeScore})),frameWidth:b.frameSize?.width??0,frameHeight:b.frameSize?.height??0,motionScore:b.zones.length>0?b.zones.reduce((v,w)=>v+w.changeScore,0)/b.zones.length:0}),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>a(null),rp))});return()=>{h?.unsubscribe(),f.current&&clearTimeout(f.current)}},[e,t]),Y(()=>{if(t===null)return;const h=ss(e,"detection.result",g=>{const x=g;if(!as(x?.source,t))return;const b=x.data?.frame;b?.detections?.length&&(l({detections:b.detections,frameWidth:b.width,frameHeight:b.height}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>l(null),nL))});return()=>{h?.unsubscribe(),m.current&&clearTimeout(m.current)}},[e,t]),Y(()=>{if(t===null)return;const h=ss(e,"detection.phase-transition",g=>{const x=g;as(x?.source,t)&&x.data?.to&&d(x.data.to)});return()=>{h?.unsubscribe()}},[e,t]),{motion:n,motionRaw:s,detection:i,phase:c}}function Xy(e,t,n=5e3){const[o,s]=P([]);Y(()=>{if(t===null)return;let m=!1;const h=()=>{e.webrtcSession.listStreams.query({deviceId:t}).then(x=>{m||s(x)}).catch(()=>{})};h();const g=setInterval(h,n);return()=>{m=!0,clearInterval(g)}},[e,t,n]);const[a,i]=P(null);Y(()=>{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]),ht("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}=V(()=>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=U(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]),p=U(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]),f=U(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:p,closeSession:f}}function Jy(e){const t=e?.deviceId??null,n=e?.historyLimit??20,o=Br("doorbell.onPressed",t!==null?i=>i.deviceId===t:void 0),[s,a]=P([]);return Y(()=>{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 rL(e){const t=Le(),n=V(()=>e?JSON.stringify(e):"",[e]),[o,s]=P(()=>t.listDevices(e));return Y(()=>{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 oL(e){const t=Le(),[n,o]=P(()=>e===null?null:t.getDevice(e));return Y(()=>{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 sL(e,t,n){const o=Le();return Dr({queryKey:e,queryFn:()=>t(o)(),...n})}function aL(e,t){const n=Le();return Hn({mutationFn:o=>e(n)(o),...t})}function iL(e,t){const n=Le(),o=we(),[s,a]=P(n.connectionVersion);Y(()=>n.subscribeConnectionEvents((c,d)=>{c==="connected"&&a(d)}),[n]);const i=t.join("|"),l=JSON.stringify(e);Y(()=>{const c=[],d=()=>{const p=JSON.parse(l),m=p.length===1&&Array.isArray(p[0])?p:[p];o.invalidateQueries({queryKey:m})};d();for(const p of i.split("|"))if(p)try{c.push(n.subscribeEvent(p,d))}catch{}return()=>{for(const p of c)p()}},[n,o,i,l,s])}const lL=Object.freeze(Object.defineProperty({__proto__:null,AddonGlobalSettingsForm:L$,AgentStepEditor:ya,AppShell:TC,AudioClassificationList:hD,AudioLevelWaveform:pD,AudioWaveform:uD,AutotrackSection:fy,BTN_COMPACT:j2,BTN_COMPACT_DANGER:V2,BTN_COMPACT_PRIMARY:H2,BTN_COMPACT_WARNING:U2,Badge:Lt,BatteryBadge:Pc,BottomSheet:xc,Breadcrumb:wc,Button:ze,CHIP_ACTIVE:G2,CHIP_BASE:Q2,CHIP_INACTIVE:K2,CLASS_COLORS:ro,CameraStreamPlayer:Cy,Card:an,Checkbox:vh,CodeBlock:DC,CollapsibleCard:xh,ConfigFormBuilder:ky,ConfigFormField:or,ConfigSchemaField:xa,ConfirmActionButton:ld,ConfirmDialogProvider:Jh,CopyButton:jy,CustomFieldRenderersProvider:yg,DEFAULT_COLOR:mg,DataTable:zo,DetectionCanvas:O3,DetectionOverlay:Sy,DetectionResultTree:j3,DevShell:bg,DeviceActivityPanel:UD,DeviceCard:OC,DeviceContextProvider:wg,DeviceExportPanel:sd,DeviceGrid:zC,DeviceItem:vo,DeviceList:wo,Dialog:kh,DialogContent:gc,DialogDescription:Ah,DialogFooter:Ch,DialogHeader:Sh,DialogTitle:Mh,DialogTrigger:X5,DiscoveryPanel:Vy,DoorbellRecentPanel:Gy,Dropdown:Ih,DropdownContent:_h,DropdownItem:$h,DropdownTrigger:Ph,EmptyState:Ac,ErrorBox:va,EventStream:sr,FilterBar:LC,FloatingEventStream:PD,FloatingLogStream:Hy,FloatingPanel:iC,FormField:EC,GRID_GAP:$2,GRID_PAIRED:L2,GRID_QUICK_STATS:D2,HOST_WIDGETS:yy,INPUT_COMPACT:q2,IconButton:pc,ImageSelector:Q3,InferenceConfigSelector:G3,Input:Fs,KebabMenu:Ky,KeyValueList:$C,LIST_ROW:Jm,Label:fc,LogStream:Zt,LoginForm:hg,MobileDrawer:vc,MotionZonesSettings:xy,NodeMultiSelectField:wy,NodePicker:Yh,NodeSelectField:vy,PHASE_CONFIG:nl,PTZOverlay:dy,PageHeader:IC,PhaseIcon:ad,PipelineBuilder:_c,PipelineRuntimeSelector:L3,PipelineStep:As,PipelineTreeMatrix:kc,PlayerOverlaysProvider:my,Popover:jh,PopoverContent:Vh,PopoverTrigger:Hh,ProviderBadge:CC,PtzPanel:uy,QrCode:Fy,ResponseLog:gD,SECTION_BODY:P2,SECTION_CARD:E2,SECTION_HEADER:I2,SPLIT_PANEL_OUTER:T2,SPLIT_PANEL_SIDE:R2,STACK_GAP:_2,ScopePicker:cd,ScrollArea:yc,Select:yo,SemanticBadge:Zh,Separator:mc,Sidebar:cl,SidebarItem:ll,Skeleton:yh,SlideOverPanel:Nc,SnapshotButton:QD,StatCard:_C,StateValuesStream:id,StatusBadge:kC,StepTimings:q3,StepTreeMaster:Gh,StreamBrokerSelector:Y$,StreamPanel:Ay,Switch:hc,SystemProvider:Cc,TEXT_FIELD_LABEL:z2,TEXT_HINT:no,TEXT_METRIC:F2,TEXT_SECTION_LABEL:O2,TEXT_VALUE:B2,Tabs:rC,TabsContent:aC,TabsList:oC,TabsTrigger:sC,ThemeProvider:zs,Tooltip:eC,TooltipContent:nC,TooltipTrigger:tC,VersionBadge:AC,WidgetRegistryProvider:sy,WidgetSlot:wr,ZoneEditingProvider:Yy,buildStepTreeFromSchema:ba,cn:K,createSharedContext:mn,createTheme:$N,darkColors:_m,defaultTheme:el,deriveDeviceKind:FC,ensureMfHostInit:sc,getClassColor:ft,getPhaseVisual:Lr,isFieldVisible:od,lightColors:$m,loadRemoteBundle:ed,mirror:eh,mountAddonPage:nM,providerIcons:q5,statusIcons:Q5,themeToCss:ON,trpc:S,useAccessoriesGetStatus:rM,useAddonPagesListPages:Lc,useAddonSettingsGetDeviceSettings:fM,useAddonSettingsGetGlobalSettings:Oc,useAddonSettingsUpdateDeviceSettings:Bg,useAddonSettingsUpdateGlobalSettings:zg,useAddonWidgetsListWidgets:Fg,useAddonsApplyAutoUpdateToAll:Og,useAddonsCustom:uM,useAddonsForceRefresh:Mg,useAddonsGetAddonAutoUpdate:Tg,useAddonsGetAutoUpdateSettings:Lg,useAddonsGetLastRestart:Eg,useAddonsGetLogs:oM,useAddonsGetVersions:$g,useAddonsInstallFromWorkspace:aM,useAddonsInstallPackage:Tc,useAddonsIsWorkspaceAvailable:iM,useAddonsList:hn,useAddonsListCapabilityProviders:Bo,useAddonsListFrameworkPackages:Ig,useAddonsListPackages:sM,useAddonsListUpdates:Rc,useAddonsListWorkspacePackages:lM,useAddonsOnAddonLogs:pM,useAddonsReloadPackages:Sg,useAddonsRestartAddon:Fo,useAddonsRestartServer:Ag,useAddonsRetryLoad:Dg,useAddonsRollbackPackage:cM,useAddonsSearchAvailable:Cg,useAddonsSetAddonAutoUpdate:Rg,useAddonsSetAutoUpdateSettings:dM,useAddonsSetCapabilityProviderEnabled:Pg,useAddonsUninstallPackage:kg,useAddonsUpdateFrameworkPackage:_g,useAddonsUpdatePackage:ul,useAlertsDismiss:qg,useAlertsEmit:mM,useAlertsGetUnreadCount:Hg,useAlertsList:jg,useAlertsMarkAllRead:Ug,useAlertsMarkRead:Vg,useAlertsUpdate:hM,useAllWidgets:iy,useAudioAnalysisApplyDeviceSettingsPatch:yM,useAudioAnalysisGetDeviceLiveContribution:xM,useAudioAnalysisGetDeviceSettingsContribution:bM,useAudioAnalysisResolveDeviceSettings:gM,useAudioAnalyzerAnalyseChunk:vM,useAudioAnalyzerClassify:wM,useAudioAnalyzerDispose:kM,useAudioAnalyzerIsReady:NM,useAudioAnalyzerReprobeAudioEngine:Qg,useAudioCodecCanHandle:CM,useAudioCodecCloseSession:EM,useAudioCodecCreateDecodeSession:MM,useAudioCodecCreateEncodeSession:AM,useAudioCodecFlushEncode:DM,useAudioCodecListActiveSessions:LM,useAudioCodecListSupportedCodecs:SM,useAudioCodecPullEncoded:$M,useAudioCodecPullPcm:PM,useAudioCodecPushEncodedFrame:IM,useAudioCodecPushPcm:_M,useAudioMetricsGetCurrentSnapshot:TM,useAudioMetricsGetHistory:RM,useBackupDelete:Zg,useBackupGetEntries:Wg,useBackupList:OM,useBackupListArchives:Bc,useBackupListDestinations:zc,useBackupListLocations:Kg,useBackupPreviewSchedule:Jg,useBackupRestore:Yg,useBackupTrigger:Gg,useBackupUpsertDestinationPolicy:Xg,useBatteryGetStatus:zM,useBrightnessGetStatus:FM,useBrightnessSetBrightness:BM,useCameraCredentialsGetCredentials:jM,useCameraCredentialsGetStatus:HM,useCameraStreamsGetBrokerStreams:UM,useCameraStreamsGetCameraStreams:VM,useCameraStreamsGetRtspEntries:eb,useClusterNodes:Fr,useConfirm:et,useCustomFieldRenderer:vg,useDebouncedString:fg,useDecoderCreateSession:GM,useDecoderDestroySession:KM,useDecoderGetFrame:JM,useDecoderGetInfo:QM,useDecoderGetShmStats:e4,useDecoderGetStats:n4,useDecoderListActiveSessions:r4,useDecoderOpenStream:YM,useDecoderPullFrames:ZM,useDecoderPullHandles:XM,useDecoderPushPacket:WM,useDecoderReprobeHwaccel:tb,useDecoderSupportsCodec:qM,useDecoderUpdateConfig:t4,useDetectionPipelineApplyDeviceSettingsPatch:a4,useDetectionPipelineGetDeviceLiveContribution:s4,useDetectionPipelineGetDeviceSettingsContribution:o4,useDevShell:Z3,useDevice:oL,useDeviceAutotrack:py,useDeviceBattery:Ec,useDeviceCapability:jr,useDeviceDetections:Zy,useDeviceDiscoveryAdoptDevice:i4,useDeviceDiscoveryGetStatus:c4,useDeviceDiscoveryListDiscovered:nb,useDeviceDiscoveryRefreshDiscovery:rb,useDeviceDiscoveryReleaseDevice:l4,useDeviceExportApplyDeviceSettingsPatch:m4,useDeviceExportExposeDevice:u4,useDeviceExportGetDeviceLiveContribution:f4,useDeviceExportGetDeviceSettingsContribution:p4,useDeviceExportGetStatus:Fc,useDeviceExportListExposedDevices:ob,useDeviceExportListSupportedDeviceKinds:d4,useDeviceExportUnexposeDevice:sb,useDeviceId:Dc,useDeviceManagerAddLocation:k4,useDeviceManagerAdoptDevice:bb,useDeviceManagerAllocateDeviceId:h4,useDeviceManagerCreateDevice:yb,useDeviceManagerDisable:ub,useDeviceManagerDiscoverDevices:Hc,useDeviceManagerEnable:db,useDeviceManagerGetAllBindings:L4,useDeviceManagerGetBindings:fb,useDeviceManagerGetChildren:cb,useDeviceManagerGetConfigSchema:E4,useDeviceManagerGetCreationSchema:xb,useDeviceManagerGetDevice:vr,useDeviceManagerGetDeviceAggregate:jc,useDeviceManagerGetDeviceLiveInfoAggregate:O4,useDeviceManagerGetDeviceSettingsAggregate:R4,useDeviceManagerGetDeviceStatusAggregate:F4,useDeviceManagerGetSettingsSchema:I4,useDeviceManagerGetStreamProfileMap:_4,useDeviceManagerGetStreamSources:A4,useDeviceManagerListAll:$n,useDeviceManagerListBindableCapsForDeviceType:hb,useDeviceManagerListLocations:lb,useDeviceManagerListPersistedByAddon:M4,useDeviceManagerListWrappersForCap:T4,useDeviceManagerLoadConfig:y4,useDeviceManagerLoadMeta:w4,useDeviceManagerLoadRuntimeState:v4,useDeviceManagerPersistConfig:x4,useDeviceManagerProbeStreams:D4,useDeviceManagerRegisterDevice:g4,useDeviceManagerRemove:pb,useDeviceManagerRemoveDevice:b4,useDeviceManagerRemoveLocation:S4,useDeviceManagerSetDisabled:C4,useDeviceManagerSetLocation:ib,useDeviceManagerSetMetadata:N4,useDeviceManagerSetName:ab,useDeviceManagerSetStreamProfileMap:$4,useDeviceManagerSetWrapperActive:mb,useDeviceManagerTestCreationField:Vc,useDeviceManagerTestField:B4,useDeviceManagerUpdateConfig:P4,useDeviceManagerUpdateDeviceField:z4,useDeviceManagerUpdateDeviceFieldsBatch:gb,useDeviceOpsGetConfigEntries:H4,useDeviceOpsGetSettingsSchema:q4,useDeviceOpsGetStreamSources:j4,useDeviceOpsRemoveDevice:U4,useDeviceOpsSetConfig:V4,useDeviceProviderAdoptDiscoveredDevice:X4,useDeviceProviderCreateDevice:tA,useDeviceProviderDiscoverDevices:Z4,useDeviceProviderGetChildCreationSchema:eA,useDeviceProviderGetDevices:W4,useDeviceProviderGetStatus:K4,useDeviceProviderStart:Q4,useDeviceProviderStop:G4,useDeviceProviderSupportsDiscovery:Y4,useDeviceProviderSupportsManualCreation:J4,useDeviceProviderTestCreationField:nA,useDeviceProxy:Ct,useDeviceSnapshot:Ng,useDeviceSnapshotImage:Ic,useDeviceState:eg,useDeviceStateGetAllSnapshots:sA,useDeviceStateGetCapSlice:oA,useDeviceStateGetSnapshot:rA,useDeviceStateSetCapSlice:aA,useDeviceStateSlice:cn,useDeviceStatusGetStatus:iA,useDeviceWebrtc:Xy,useDevices:rL,useDoorbellEvents:Jy,useDoorbellGetStatus:lA,useEventInvalidation:iL,useEventStreamLatest:Br,useEventStreamMap:Mc,useEventsGetEventClipUrl:uA,useEventsGetEventThumbnail:dA,useEventsGetEvents:cA,useFeatureProbeGetStatus:pA,useIntegrationsCreate:Nb,useIntegrationsDelete:Sb,useIntegrationsGet:vb,useIntegrationsGetAvailableTypes:Cb,useIntegrationsGetByAddonId:wb,useIntegrationsGetSettings:fA,useIntegrationsList:Uc,useIntegrationsSetSettings:mA,useIntegrationsTestConnection:Mb,useIntegrationsUpdate:kb,useIntercomEndTalkSession:bA,useIntercomGetStatus:xA,useIntercomHandleAnswer:Eb,useIntercomPushTalkPcm:gA,useIntercomStartSession:Ab,useIntercomStartTalkSession:hA,useIntercomStopSession:Ib,useIsMidWidth:zh,useIsMobile:nr,useLiveBuffer:mr,useLiveEvent:ht,useLocalNetworkGetAllowedAddresses:$b,useLocalNetworkGetConnectionEndpoints:_b,useLocalNetworkGetPreferred:yA,useLocalNetworkList:Pb,useLocalNetworkResetAllowlistToBestMatch:Lb,useLocalNetworkSetAllowedAddresses:Db,useMeshNetworkGetStatus:Tb,useMeshNetworkJoin:vA,useMeshNetworkLeave:Ob,useMeshNetworkListPeers:Bb,useMeshNetworkLogout:zb,useMeshNetworkStartLogin:Rb,useMeshNetworkTestConnection:wA,useMetricsProviderCollectSnapshot:NA,useMetricsProviderGetAddonStats:PA,useMetricsProviderGetCached:kA,useMetricsProviderGetCpuTemperature:AA,useMetricsProviderGetCurrent:SA,useMetricsProviderGetDiskSpace:CA,useMetricsProviderGetGpuInfo:MA,useMetricsProviderGetProcessStats:EA,useMetricsProviderKillProcess:jb,useMetricsProviderListAddonInstances:IA,useMetricsProviderListNodeProcesses:Fb,useMotionDetectionAnalyze:DA,useMotionDetectionApplyDeviceSettingsPatch:zA,useMotionDetectionGetDeviceLiveContribution:OA,useMotionDetectionGetDeviceSettingsContribution:RA,useMotionDetectionRemoveCamera:LA,useMotionDetectionReset:TA,useMotionGetStatus:$A,useMotionIsDetected:_A,useMotionTriggerGetStatus:FA,useMotionTriggerSetMotionTrigger:BA,useMotionZonesGetOptions:jA,useMotionZonesGetStatus:VA,useMotionZonesSetZone:HA,useMqttBrokerAddBroker:QA,useMqttBrokerGetBrokerConfig:qA,useMqttBrokerGetStatus:Hb,useMqttBrokerListBrokers:UA,useMqttBrokerRemoveBroker:GA,useMqttBrokerStartEmbeddedBroker:WA,useMqttBrokerStopEmbeddedBroker:YA,useMqttBrokerTestConnection:KA,useNativeObjectDetectionGetStatus:ZA,useNetworkAccessGetEndpoint:XA,useNetworkAccessGetStatus:qb,useNetworkAccessListEndpoints:JA,useNetworkAccessStart:Vb,useNetworkAccessStop:Ub,useNetworkQualityGetAllStats:eE,useNetworkQualityGetDeviceStats:Qb,useNetworkQualityReportClientStats:tE,useNodesClusterAddonStatus:Yb,useNodesDeployAddon:nE,useNodesExecuteQuery:sE,useNodesGetCapUsageGraph:Zb,useNodesGetNodeAddons:Xb,useNodesRenameNode:Wb,useNodesRestartAddon:wa,useNodesRestartNode:rE,useNodesRestartProcess:Kb,useNodesSetProcessLogLevel:Jb,useNodesShutdownNode:oE,useNodesTopology:Dn,useNodesUndeployAddon:Gb,useNotificationOutputSend:aE,useNotificationOutputSendTest:iE,useOptionalSystem:wC,useOptionalWidgetRegistry:td,useOsdGetStatus:cE,useOsdSetOverlay:lE,usePTZ:cy,usePipelineAnalyticsApplyDeviceSettingsPatch:wE,usePipelineAnalyticsClearTracks:fE,usePipelineAnalyticsGetActiveTracks:dE,usePipelineAnalyticsGetAudioEvents:gE,usePipelineAnalyticsGetDeviceLiveContribution:vE,usePipelineAnalyticsGetDeviceSettingsContribution:yE,usePipelineAnalyticsGetEventMedia:bE,usePipelineAnalyticsGetMotionEvents:mE,usePipelineAnalyticsGetObjectEvents:hE,usePipelineAnalyticsGetTrack:uE,usePipelineAnalyticsGetTrackMedia:xE,usePipelineAnalyticsListTracks:pE,usePipelineExecutorCacheFrameInPool:OE,usePipelineExecutorDeleteModel:ox,usePipelineExecutorDeleteTemplate:_E,usePipelineExecutorDetect:LE,usePipelineExecutorDownloadModel:rx,usePipelineExecutorGetAddonModels:DE,usePipelineExecutorGetAudioCapabilities:QE,usePipelineExecutorGetAvailableEngines:ex,usePipelineExecutorGetCapabilities:$E,usePipelineExecutorGetDefaultSteps:NE,usePipelineExecutorGetDetectionConfigSchema:KE,usePipelineExecutorGetEffectiveTuning:FE,usePipelineExecutorGetGlobalPipelineConfig:ME,usePipelineExecutorGetGlobalSteps:CE,usePipelineExecutorGetOrchestratorConfigSchema:AE,usePipelineExecutorGetReferenceAudio:qE,usePipelineExecutorGetReferenceAudioFiles:UE,usePipelineExecutorGetReferenceImage:VE,usePipelineExecutorGetSchema:jo,usePipelineExecutorGetSelectedEngine:tx,usePipelineExecutorGetVideoPipelineSteps:kE,usePipelineExecutorInferCached:zE,usePipelineExecutorKillEngine:ax,usePipelineExecutorListLoadedEngines:sx,usePipelineExecutorListReferenceImages:HE,usePipelineExecutorListTemplates:EE,usePipelineExecutorReprobeEngine:nx,usePipelineExecutorRunAudioTest:GE,usePipelineExecutorRunPipeline:TE,usePipelineExecutorRunPipelineBatch:RE,usePipelineExecutorSaveTemplate:IE,usePipelineExecutorSetVideoPipelineSteps:SE,usePipelineExecutorSpinEngine:jE,usePipelineExecutorUncacheFrame:BE,usePipelineExecutorUpdateTemplate:PE,usePipelineOrchestratorApplyDeviceSettingsPatch:rI,usePipelineOrchestratorAssignAudio:gx,usePipelineOrchestratorAssignDecoder:fx,usePipelineOrchestratorAssignPipeline:ix,usePipelineOrchestratorDeleteTemplate:Ax,usePipelineOrchestratorGetAgentLoad:dx,usePipelineOrchestratorGetAgentSettings:Qc,usePipelineOrchestratorGetAudioAssignment:ZE,usePipelineOrchestratorGetAudioAssignments:yx,usePipelineOrchestratorGetAudioNodeLoad:xx,usePipelineOrchestratorGetCameraMetrics:YE,usePipelineOrchestratorGetCameraSettings:Kc,usePipelineOrchestratorGetCameraStepOverrides:JE,usePipelineOrchestratorGetCapabilityBindings:ux,usePipelineOrchestratorGetDecoderAssignment:XE,usePipelineOrchestratorGetDecoderAssignments:hx,usePipelineOrchestratorGetDeviceLiveContribution:nI,usePipelineOrchestratorGetDeviceSettingsContribution:tI,usePipelineOrchestratorGetGlobalMetrics:WE,usePipelineOrchestratorGetPipelineAssignment:qc,usePipelineOrchestratorGetPipelineAssignments:Na,usePipelineOrchestratorListAgentSettings:Hr,usePipelineOrchestratorListTemplates:Cx,usePipelineOrchestratorRebalance:cx,usePipelineOrchestratorRemoveAgentSettings:vx,usePipelineOrchestratorResolvePipeline:Sx,usePipelineOrchestratorSaveTemplate:eI,usePipelineOrchestratorSetAgentAddonDefaults:Gc,usePipelineOrchestratorSetCameraPipelineForAgent:kx,usePipelineOrchestratorSetCameraStepOverride:Nx,usePipelineOrchestratorSetCameraStepToggle:wx,usePipelineOrchestratorSetCapabilityBinding:px,usePipelineOrchestratorUnassignAudio:bx,usePipelineOrchestratorUnassignDecoder:mx,usePipelineOrchestratorUnassignPipeline:lx,usePipelineOrchestratorUpdateTemplate:Mx,usePipelineRunnerAttachCamera:oI,usePipelineRunnerDetachCamera:sI,usePipelineRunnerGetAllCameraMetrics:cI,usePipelineRunnerGetCameraMetrics:Ex,usePipelineRunnerGetLocalCameras:Ix,usePipelineRunnerGetLocalLoad:iI,usePipelineRunnerGetLocalMetrics:lI,usePipelineRunnerReportMotion:aI,usePlatformProbeGetCapabilities:dI,usePlatformProbeGetHardware:uI,usePlatformProbeGetHardwareEncoders:mI,usePlatformProbeRefreshHardwareEncoders:hI,usePlatformProbeResolveHwAccel:fI,usePlatformProbeResolveInferenceConfig:pI,usePlayerOverlayLayer:by,usePlayerOverlayLayers:hy,usePlayerToolbarButton:q_,usePlayerToolbarButtons:gy,usePtzAutotrackGetSettings:EI,usePtzAutotrackGetStatus:Px,usePtzAutotrackSetEnabled:_x,usePtzAutotrackSetSettings:$x,usePtzContinuousMove:bI,usePtzDeletePreset:NI,usePtzGetOptions:kI,usePtzGetPosition:CI,usePtzGetPresets:yI,usePtzGetStatus:AI,usePtzGoHome:SI,usePtzGoToPreset:vI,usePtzMove:gI,usePtzSavePreset:wI,usePtzSetAutofocus:MI,usePtzStop:xI,useRebootReboot:Dx,useRecordingEngineDisable:Tx,useRecordingEngineEnable:Lx,useRecordingEngineEstimateGlobalStorage:zI,useRecordingEngineEstimateStorage:OI,useRecordingEngineGetAvailability:RI,useRecordingEngineGetConfig:Rx,useRecordingEngineGetMotionStats:HI,useRecordingEngineGetPlaylist:LI,useRecordingEngineGetPolicy:FI,useRecordingEngineGetPolicyStatus:Bx,useRecordingEngineGetRetentionConfig:Fx,useRecordingEngineGetSegments:Ox,useRecordingEngineGetStatus:$I,useRecordingEngineGetStorageUsage:zx,useRecordingEngineGetThumbnail:TI,useRecordingEngineSetPolicy:BI,useRecordingEngineUpdateConfig:DI,useRecordingEngineUpdateRetentionConfig:jI,useRecordingGetPlaybackUrl:PI,useRecordingGetSegments:II,useRecordingGetThumbnailAt:_I,useRemoteComponent:ly,useSettingsStoreCount:WI,useSettingsStoreDeclareCollection:ZI,useSettingsStoreDelete:KI,useSettingsStoreGet:VI,useSettingsStoreInsert:QI,useSettingsStoreIsEmpty:YI,useSettingsStoreQuery:qI,useSettingsStoreSet:UI,useSettingsStoreUpdate:GI,useSnapshotApplyDeviceSettingsPatch:rP,useSnapshotGetDeviceLiveContribution:nP,useSnapshotGetDeviceSettingsContribution:tP,useSnapshotGetSnapshot:XI,useSnapshotGetStatus:eP,useSnapshotInvalidateCache:JI,useSnapshotProviderGetSnapshot:sP,useSnapshotProviderSupportsDevice:oP,useStorageAbortUpload:gP,useStorageBeginDownload:bP,useStorageBeginUpload:fP,useStorageDelete:uP,useStorageDeleteLocation:Hx,useStorageEndDownload:yP,useStorageExists:cP,useStorageFinalizeUpload:hP,useStorageGetAvailableSpace:pP,useStorageGetDefaultLocation:vP,useStorageList:dP,useStorageListLocations:jx,useStorageListProviders:Wc,useStorageRead:lP,useStorageReadChunk:xP,useStorageResolve:aP,useStorageTestConfig:NP,useStorageTestLocation:wP,useStorageUpsertLocation:ka,useStorageWrite:iP,useStorageWriteChunk:mP,useStreamBrokerApplyDeviceSettingsPatch:ZP,useStreamBrokerAssignProfile:CP,useStreamBrokerGetAllRtspEntries:qP,useStreamBrokerGetBrokerStats:IP,useStreamBrokerGetDeviceLiveContribution:YP,useStreamBrokerGetDeviceSettingsContribution:WP,useStreamBrokerGetPreBufferInfo:VP,useStreamBrokerGetRtspEntry:QP,useStreamBrokerGetRtspPort:UP,useStreamBrokerGetStreamUrl:DP,useStreamBrokerGetStreamWithCodec:LP,useStreamBrokerIsRtspEnabled:KP,useStreamBrokerKillClient:_P,useStreamBrokerListAllCameraStreams:AP,useStreamBrokerListAllProfileSlots:EP,useStreamBrokerListClients:PP,useStreamBrokerPublishCameraStream:kP,useStreamBrokerPullAudioChunks:OP,useStreamBrokerPullFrameHandles:FP,useStreamBrokerRegenerateRtspToken:Vx,useStreamBrokerReleaseStreamWithCodec:TP,useStreamBrokerRestartProfile:$P,useStreamBrokerRetractCameraStream:SP,useStreamBrokerSetPreBufferDuration:HP,useStreamBrokerSetRtspEnabled:GP,useStreamBrokerSubscribeAudioChunks:RP,useStreamBrokerSubscribeFrames:BP,useStreamBrokerUnassignProfile:MP,useStreamBrokerUnsubscribeAudioChunks:zP,useStreamBrokerUnsubscribeFrames:jP,useStreamParamsGetConfigSchema:e_,useStreamParamsGetOptions:XP,useStreamParamsGetStatus:t_,useStreamParamsSetProfile:JP,useSwitchGetStatus:r_,useSwitchSetState:n_,useSystem:Le,useSystemFeatureFlags:a_,useSystemForceRetentionCleanup:d_,useSystemGetRetentionConfig:l_,useSystemHealth:s_,useSystemInfo:o_,useSystemMutation:aL,useSystemNetworkAddresses:i_,useSystemQuery:sL,useSystemSetRetentionConfig:c_,useThemeMode:Ro,useToastOnToast:Ux,useTurnProviderGetTurnServers:Yc,useUserManagementConfirmTotp:g_,useUserManagementCreateApiKey:p_,useUserManagementCreateScopedToken:Zx,useUserManagementCreateUser:qx,useUserManagementDeleteUser:Gx,useUserManagementDisableTotp:ey,useUserManagementGetTotpStatus:ty,useUserManagementListApiKeys:Wx,useUserManagementListOauthSessions:ny,useUserManagementListScopedTokens:Jx,useUserManagementListUsers:Zc,useUserManagementOauthExchangeCode:y_,useUserManagementOauthIssueCode:x_,useUserManagementOauthRefresh:v_,useUserManagementOauthVerifyAccessToken:w_,useUserManagementResetPassword:Xc,useUserManagementRevokeApiKey:Yx,useUserManagementRevokeOauthSession:ry,useUserManagementRevokeScopedToken:Xx,useUserManagementSetUserScopes:Kx,useUserManagementSetupTotp:h_,useUserManagementUpdateUser:Qx,useUserManagementValidateApiKey:f_,useUserManagementValidateCredentials:u_,useUserManagementValidateScopedToken:m_,useUserManagementVerifyTotp:b_,useWebrtcSessionCloseSession:M_,useWebrtcSessionCreateSession:k_,useWebrtcSessionHandleAnswer:C_,useWebrtcSessionHandleOffer:S_,useWebrtcSessionHasAdaptiveBitrate:A_,useWebrtcSessionListStreams:N_,useWidget:H_,useWidgetMetadata:ay,useWidgetRegistry:Sa,useZoneAnalyticsGetCameraHistory:P_,useZoneAnalyticsGetCurrentSnapshot:E_,useZoneAnalyticsGetUnzonedHistory:__,useZoneAnalyticsGetZoneHistory:I_,useZoneEditing:tL,useZoneRulesListRules:$_,useZoneRulesSetRules:D_,useZonesAddZone:T_,useZonesListZones:L_,useZonesRemoveZone:R_,useZonesUpdateZone:O_,validateScopes:dd},Symbol.toStringTag,{value:"Module"}));/**
|
|
562
|
+
* react-router v7.15.0
|
|
563
|
+
*
|
|
564
|
+
* Copyright (c) Remix Software Inc.
|
|
565
|
+
*
|
|
566
|
+
* This source code is licensed under the MIT license found in the
|
|
567
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
568
|
+
*
|
|
569
|
+
* @license MIT
|
|
570
|
+
*/var op="popstate";function sp(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function cL(e={}){function t(o,s){let a=s.state?.masked,{pathname:i,search:l,hash:c}=a||o.location;return yl("",{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:No(s)}return uL(t,n,null,e)}function He(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function wt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function dL(){return Math.random().toString(36).substring(2,10)}function ap(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 yl(e,t,n=null,o,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Vr(t):t,state:n,key:t&&t.key||o||dL(),mask:s}}function No({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 Vr(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 uL(e,t,n,o={}){let{window:s=document.defaultView,v5Compat:a=!1}=o,i=s.history,l="POP",c=null,d=p();d==null&&(d=0,i.replaceState({...i.state,idx:d},""));function p(){return(i.state||{idx:null}).idx}function f(){l="POP";let b=p(),v=b==null?null:b-d;d=b,c&&c({action:l,location:x.location,delta:v})}function m(b,v){l="PUSH";let w=sp(b)?b:yl(x.location,b,v);d=p()+1;let y=ap(w,d),N=x.createHref(w.mask||w);try{i.pushState(y,"",N)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;s.location.assign(N)}a&&c&&c({action:l,location:x.location,delta:1})}function h(b,v){l="REPLACE";let w=sp(b)?b:yl(x.location,b,v);d=p();let y=ap(w,d),N=x.createHref(w.mask||w);i.replaceState(y,"",N),a&&c&&c({action:l,location:x.location,delta:0})}function g(b){return pL(b)}let x={get action(){return l},get location(){return e(s,i)},listen(b){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(op,f),c=b,()=>{s.removeEventListener(op,f),c=null}},createHref(b){return t(s,b)},createURL:g,encodeLocation(b){let v=g(b);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:m,replace:h,go(b){return i.go(b)}};return x}function pL(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),He(n,"No window.location.(origin|href) available to create URL");let o=typeof e=="string"?e:No(e);return o=o.replace(/ $/,"%20"),!t&&o.startsWith("//")&&(o=n+o),new URL(o,n)}function e0(e,t,n="/"){return fL(e,t,n,!1)}function fL(e,t,n,o,s){let a=typeof t=="string"?Vr(t):t,i=dn(a.pathname||"/",n);if(i==null)return null;let l=mL(e),c=null,d=ML(i);for(let p=0;c==null&&p<l.length;++p)c=SL(l[p],d,o);return c}function mL(e){let t=t0(e);return hL(t),t}function t0(e,t=[],n=[],o="",s=!1){let a=(i,l,c=s,d)=>{let p={relativePath:d===void 0?i.path||"":d,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(p.relativePath.startsWith("/")){if(!p.relativePath.startsWith(o)&&c)return;He(p.relativePath.startsWith(o),`Absolute route path "${p.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),p.relativePath=p.relativePath.slice(o.length)}let f=Tt([o,p.relativePath]),m=n.concat(p);i.children&&i.children.length>0&&(He(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),t0(i.children,t,m,f,c)),!(i.path==null&&!i.index)&&t.push({path:f,score:NL(f,i.index),routesMeta:m})};return e.forEach((i,l)=>{if(i.path===""||!i.path?.includes("?"))a(i,l);else for(let c of n0(i.path))a(i,l,!0,c)}),t}function n0(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=n0(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 hL(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:kL(t.routesMeta.map(o=>o.childrenIndex),n.routesMeta.map(o=>o.childrenIndex)))}var gL=/^:[\w-]+$/,bL=3,xL=2,yL=1,vL=10,wL=-2,ip=e=>e==="*";function NL(e,t){let n=e.split("/"),o=n.length;return n.some(ip)&&(o+=wL),t&&(o+=xL),n.filter(s=>!ip(s)).reduce((s,a)=>s+(gL.test(a)?bL:a===""?yL:vL),o)}function kL(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 SL(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,p=a==="/"?t:t.slice(a.length)||"/",f=Vs({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},p),m=c.route;if(!f&&d&&n&&!o[o.length-1].route.index&&(f=Vs({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},p)),!f)return null;Object.assign(s,f.params),i.push({params:s,pathname:Tt([a,f.pathname]),pathnameBase:PL(Tt([a,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(a=Tt([a,f.pathnameBase]))}return i}function Vs(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,o]=CL(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:p,isOptional:f},m)=>{if(p==="*"){let g=l[m]||"";i=a.slice(0,a.length-g.length).replace(/(.)\/+$/,"$1")}const h=l[m];return f&&!h?d[p]=void 0:d[p]=(h||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:i,pattern:e}}function CL(e,t=!1,n=!0){wt(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,p)=>{if(o.push({paramName:l,isOptional:c!=null}),c){let f=p.charAt(d+i.length);return f&&f!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}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 ML(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return wt(!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 dn(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 AL=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function EL(e,t="/"){let{pathname:n,search:o="",hash:s=""}=typeof e=="string"?Vr(e):e,a;return n?(n=r0(n),n.startsWith("/")?a=lp(n.substring(1),"/"):a=lp(n,t)):a=t,{pathname:a,search:_L(o),hash:$L(s)}}function lp(e,t){let n=Us(t).split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function gi(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 IL(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function ud(e){let t=IL(e);return t.map((n,o)=>o===t.length-1?n.pathname:n.pathnameBase)}function Ma(e,t,n,o=!1){let s;typeof e=="string"?s=Vr(e):(s={...e},He(!s.pathname||!s.pathname.includes("?"),gi("?","pathname","search",s)),He(!s.pathname||!s.pathname.includes("#"),gi("#","pathname","hash",s)),He(!s.search||!s.search.includes("#"),gi("#","search","hash",s)));let a=e===""||s.pathname==="",i=a?"/":s.pathname,l;if(i==null)l=n;else{let f=t.length-1;if(!o&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),f-=1;s.pathname=m.join("/")}l=f>=0?t[f]:"/"}let c=EL(s,l),d=i&&i!=="/"&&i.endsWith("/"),p=(a||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||p)&&(c.pathname+="/"),c}var r0=e=>e.replace(/\/\/+/g,"/"),Tt=e=>r0(e.join("/")),Us=e=>e.replace(/\/+$/,""),PL=e=>Us(e).replace(/^\/*/,"/"),_L=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,$L=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,DL=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 LL(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function TL(e){let t=e.map(n=>n.route.path).filter(Boolean);return Tt(t)||"/"}var o0=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function s0(e,t){let n=e;if(typeof n!="string"||!AL.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let o=n,s=!1;if(o0)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=dn(i.pathname,t);i.origin===a.origin&&l!=null?n=l+i.search+i.hash:s=!0}catch{wt(!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 a0=["POST","PUT","PATCH","DELETE"];new Set(a0);var RL=["GET",...a0];new Set(RL);var Ur=je(null);Ur.displayName="DataRouter";var Aa=je(null);Aa.displayName="DataRouterState";var i0=je(!1);function OL(){return xe(i0)}var l0=je({isTransitioning:!1});l0.displayName="ViewTransition";var zL=je(new Map);zL.displayName="Fetchers";var BL=je(null);BL.displayName="Await";var bt=je(null);bt.displayName="Navigation";var Ho=je(null);Ho.displayName="Location";var Mt=je({outlet:null,matches:[],isDataRoute:!1});Mt.displayName="Route";var pd=je(null);pd.displayName="RouteError";var c0="REACT_ROUTER_ERROR",FL="REDIRECT",jL="ROUTE_ERROR_RESPONSE";function HL(e){if(e.startsWith(`${c0}:${FL}:{`))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 VL(e){if(e.startsWith(`${c0}:${jL}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new DL(t.status,t.statusText,t.data)}catch{}}function UL(e,{relative:t}={}){He(qr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:o}=xe(bt),{hash:s,pathname:a,search:i}=Vo(e,{relative:t}),l=a;return n!=="/"&&(l=a==="/"?n:Tt([n,a])),o.createHref({pathname:l,search:i,hash:s})}function qr(){return xe(Ho)!=null}function xt(){return He(qr(),"useLocation() may be used only in the context of a <Router> component."),xe(Ho).location}var d0="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function u0(e){xe(bt).static||fa(e)}function rt(){let{isDataRoute:e}=xe(Mt);return e?sT():qL()}function qL(){He(qr(),"useNavigate() may be used only in the context of a <Router> component.");let e=xe(Ur),{basename:t,navigator:n}=xe(bt),{matches:o}=xe(Mt),{pathname:s}=xt(),a=JSON.stringify(ud(o)),i=re(!1);return u0(()=>{i.current=!0}),U((c,d={})=>{if(wt(i.current,d0),!i.current)return;if(typeof c=="number"){n.go(c);return}let p=Ma(c,JSON.parse(a),s,d.relative==="path");e==null&&t!=="/"&&(p.pathname=p.pathname==="/"?t:Tt([t,p.pathname])),(d.replace?n.replace:n.push)(p,d.state,d)},[t,n,a,s,e])}var QL=je(null);function GL(e){let t=xe(Mt).outlet;return V(()=>t&&Ae(QL.Provider,{value:e},t),[t,e])}function fd(){let{matches:e}=xe(Mt);return e[e.length-1]?.params??{}}function Vo(e,{relative:t}={}){let{matches:n}=xe(Mt),{pathname:o}=xt(),s=JSON.stringify(ud(n));return V(()=>Ma(e,JSON.parse(s),o,t==="path"),[e,s,o,t])}function KL(e,t){return p0(e,t)}function p0(e,t,n){He(qr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=xe(bt),{matches:s}=xe(Mt),a=s[s.length-1],i=a?a.params:{},l=a?a.pathname:"/",c=a?a.pathnameBase:"/",d=a&&a.route;{let b=d&&d.path||"";m0(l,!d||b.endsWith("*")||b.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${b}">) 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.
|
|
571
|
+
|
|
572
|
+
Please change the parent <Route path="${b}"> to <Route path="${b==="/"?"*":`${b}/*`}">.`)}let p=xt(),f;if(t){let b=typeof t=="string"?Vr(t):t;He(c==="/"||b.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 "${b.pathname}" was given in the \`location\` prop.`),f=b}else f=p;let m=f.pathname||"/",h=m;if(c!=="/"){let b=c.replace(/^\//,"").split("/");h="/"+m.replace(/^\//,"").split("/").slice(b.length).join("/")}let g=n&&n.state.matches.length?n.state.matches.map(b=>Object.assign(b,{route:n.manifest[b.route.id]||b.route})):e0(e,{pathname:h});wt(d||g!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),wt(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 "${f.pathname}${f.search}${f.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 x=JL(g&&g.map(b=>Object.assign({},b,{params:Object.assign({},i,b.params),pathname:Tt([c,o.encodeLocation?o.encodeLocation(b.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?c:Tt([c,o.encodeLocation?o.encodeLocation(b.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:b.pathnameBase])})),s,n);return t&&x?Ae(Ho.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...f},navigationType:"POP"}},x):x}function WL(){let e=oT(),t=LL(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=Ae(yr,null,Ae("p",null,"💿 Hey developer 👋"),Ae("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",Ae("code",{style:a},"ErrorBoundary")," or"," ",Ae("code",{style:a},"errorElement")," prop on your route.")),Ae(yr,null,Ae("h2",null,"Unexpected Application Error!"),Ae("h3",{style:{fontStyle:"italic"}},t),n?Ae("pre",{style:s},n):null,i)}var YL=Ae(WL,null),f0=class extends pN{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=VL(e.digest);n&&(e=n)}let t=e!==void 0?Ae(Mt.Provider,{value:this.props.routeContext},Ae(pd.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?Ae(ZL,{error:e},t):t}};f0.contextType=i0;var bi=new WeakMap;function ZL({children:e,error:t}){let{basename:n}=xe(bt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let o=HL(t.digest);if(o){let s=bi.get(t);if(s)throw s;let a=s0(o.location,n);if(o0&&!bi.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 bi.set(t,i),i}return Ae("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function XL({routeContext:e,match:t,children:n}){let o=xe(Ur);return o&&o.static&&o.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=t.route.id),Ae(Mt.Provider,{value:e},n)}function JL(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 p=s.findIndex(f=>f.route.id&&a?.[f.route.id]!==void 0);He(p>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),s=s.slice(0,Math.min(s.length,p+1))}let i=!1,l=-1;if(n&&o){i=o.renderFallback;for(let p=0;p<s.length;p++){let f=s[p];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(l=p),f.route.id){let{loaderData:m,errors:h}=o,g=f.route.loader&&!m.hasOwnProperty(f.route.id)&&(!h||h[f.route.id]===void 0);if(f.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?(p,f)=>{c(p,{location:o.location,params:o.matches?.[0]?.params??{},pattern:TL(o.matches),errorInfo:f})}:void 0;return s.reduceRight((p,f,m)=>{let h,g=!1,x=null,b=null;o&&(h=a&&f.route.id?a[f.route.id]:void 0,x=f.route.errorElement||YL,i&&(l<0&&m===0?(m0("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,b=null):l===m&&(g=!0,b=f.route.hydrateFallbackElement||null)));let v=t.concat(s.slice(0,m+1)),w=()=>{let y;return h?y=x:g?y=b:f.route.Component?y=Ae(f.route.Component,null):f.route.element?y=f.route.element:y=p,Ae(XL,{match:f,routeContext:{outlet:p,matches:v,isDataRoute:o!=null},children:y})};return o&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?Ae(f0,{location:o.location,revalidation:o.revalidation,component:x,error:h,children:w(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:d}):w()},null)}function md(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function eT(e){let t=xe(Ur);return He(t,md(e)),t}function tT(e){let t=xe(Aa);return He(t,md(e)),t}function nT(e){let t=xe(Mt);return He(t,md(e)),t}function hd(e){let t=nT(e),n=t.matches[t.matches.length-1];return He(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function rT(){return hd("useRouteId")}function oT(){let e=xe(pd),t=tT("useRouteError"),n=hd("useRouteError");return e!==void 0?e:t.errors?.[n]}function sT(){let{router:e}=eT("useNavigate"),t=hd("useNavigate"),n=re(!1);return u0(()=>{n.current=!0}),U(async(s,a={})=>{wt(n.current,d0),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...a}))},[e,t])}var cp={};function m0(e,t,n){!t&&!cp[e]&&(cp[e]=!0,wt(!1,n))}Fe(aT);function aT({routes:e,manifest:t,future:n,state:o,isStatic:s,onError:a}){return p0(e,void 0,{manifest:t,state:o,isStatic:s,onError:a})}function dt({to:e,replace:t,state:n,relative:o}){He(qr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:s}=xe(bt);wt(!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}=xe(Mt),{pathname:i}=xt(),l=rt(),c=Ma(e,ud(a),i,o==="path"),d=JSON.stringify(c);return Y(()=>{l(JSON.parse(d),{replace:t,state:n,relative:o})},[l,d,o,t,n]),null}function iT(e){return GL(e.context)}function Te(e){He(!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 lT({basename:e="/",children:t=null,location:n,navigationType:o="POP",navigator:s,static:a=!1,useTransitions:i}){He(!qr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=V(()=>({basename:l,navigator:s,static:a,useTransitions:i,future:{}}),[l,s,a,i]);typeof n=="string"&&(n=Vr(n));let{pathname:d="/",search:p="",hash:f="",state:m=null,key:h="default",mask:g}=n,x=V(()=>{let b=dn(d,l);return b==null?null:{location:{pathname:b,search:p,hash:f,state:m,key:h,mask:g},navigationType:o}},[l,d,p,f,m,h,o,g]);return wt(x!=null,`<Router basename="${l}"> is not able to match the URL "${d}${p}${f}" because it does not start with the basename, so the <Router> won't render anything.`),x==null?null:Ae(bt.Provider,{value:c},Ae(Ho.Provider,{children:t,value:x}))}function cT({children:e,location:t}){return KL(vl(e),t)}function vl(e,t=[]){let n=[];return dN.forEach(e,(o,s)=>{if(!uN(o))return;let a=[...t,s];if(o.type===yr){n.push.apply(n,vl(o.props.children,a));return}He(o.type===Te,`[${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>`),He(!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=vl(o.props.children,a)),n.push(i)}),n}var Is="get",Ps="application/x-www-form-urlencoded";function Ea(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function dT(e){return Ea(e)&&e.tagName.toLowerCase()==="button"}function uT(e){return Ea(e)&&e.tagName.toLowerCase()==="form"}function pT(e){return Ea(e)&&e.tagName.toLowerCase()==="input"}function fT(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function mT(e,t){return e.button===0&&(!t||t==="_self")&&!fT(e)}function wl(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 hT(e,t){let n=wl(e);return t&&t.forEach((o,s)=>{n.has(s)||t.getAll(s).forEach(a=>{n.append(s,a)})}),n}var is=null;function gT(){if(is===null)try{new FormData(document.createElement("form"),0),is=!1}catch{is=!0}return is}var bT=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function xi(e){return e!=null&&!bT.has(e)?(wt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ps}"`),null):e}function xT(e,t){let n,o,s,a,i;if(uT(e)){let l=e.getAttribute("action");o=l?dn(l,t):null,n=e.getAttribute("method")||Is,s=xi(e.getAttribute("enctype"))||Ps,a=new FormData(e)}else if(dT(e)||pT(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?dn(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Is,s=xi(e.getAttribute("formenctype"))||xi(l.getAttribute("enctype"))||Ps,a=new FormData(l,e),!gT()){let{name:d,type:p,value:f}=e;if(p==="image"){let m=d?`${d}.`:"";a.append(`${m}x`,"0"),a.append(`${m}y`,"0")}else d&&a.append(d,f)}}else{if(Ea(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Is,o=null,s=Ps,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 gd(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function h0(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&&dn(s.pathname,t)==="/"?s.pathname=`${Us(t)}/_root.${o}`:s.pathname=`${Us(s.pathname)}.${o}`,s}async function yT(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 vT(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 wT(e,t,n){let o=await Promise.all(e.map(async s=>{let a=t.routes[s.route.id];if(a){let i=await yT(a,n);return i.links?i.links():[]}return[]}));return CT(o.flat(1).filter(vT).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function dp(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 p=o.routes[c.route.id];if(!p||!p.hasLoader)return!1;if(i(c,d)||l(c,d))return!0;if(c.route.shouldRevalidate){let f=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 f=="boolean")return f}return!0}):[]}function NT(e,t,{includeHydrateFallback:n}={}){return kT(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 kT(e){return[...new Set(e)]}function ST(e){let t={},n=Object.keys(e).sort();for(let o of n)t[o]=e[o];return t}function CT(e,t){let n=new Set;return new Set(t),e.reduce((o,s)=>{let a=JSON.stringify(ST(s));return n.has(a)||(n.add(a),o.push({key:a,link:s})),o},[])}function bd(){let e=xe(Ur);return gd(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function MT(){let e=xe(Aa);return gd(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var xd=je(void 0);xd.displayName="FrameworkContext";function yd(){let e=xe(xd);return gd(e,"You must render this element inside a <HydratedRouter> element"),e}function AT(e,t){let n=xe(xd),[o,s]=P(!1),[a,i]=P(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:p,onTouchStart:f}=t,m=re(null);Y(()=>{if(e==="render"&&i(!0),e==="viewport"){let x=v=>{v.forEach(w=>{i(w.isIntersecting)})},b=new IntersectionObserver(x,{threshold:.5});return m.current&&b.observe(m.current),()=>{b.disconnect()}}},[e]),Y(()=>{if(o){let x=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(x)}}},[o]);let h=()=>{s(!0)},g=()=>{s(!1),i(!1)};return n?e!=="intent"?[a,m,{}]:[a,m,{onFocus:Yr(l,h),onBlur:Yr(c,g),onMouseEnter:Yr(d,h),onMouseLeave:Yr(p,g),onTouchStart:Yr(f,h)}]:[!1,m,{}]}function Yr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function ET({page:e,...t}){let n=OL(),{router:o}=bd(),s=V(()=>e0(o.routes,e,o.basename),[o.routes,e,o.basename]);return s?n?Ae(PT,{page:e,matches:s,...t}):Ae(_T,{page:e,matches:s,...t}):null}function IT(e){let{manifest:t,routeModules:n}=yd(),[o,s]=P([]);return Y(()=>{let a=!1;return wT(e,t,n).then(i=>{a||s(i)}),()=>{a=!0}},[e,t,n]),o}function PT({page:e,matches:t,...n}){let o=xt(),{future:s}=yd(),{basename:a}=bd(),i=V(()=>{if(e===o.pathname+o.search+o.hash)return[];let l=h0(e,a,s.unstable_trailingSlashAwareDataRequests,"rsc"),c=!1,d=[];for(let p of t)typeof p.route.shouldRevalidate=="function"?c=!0:d.push(p.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 Ae(yr,null,i.map(l=>Ae("link",{key:l,rel:"prefetch",as:"fetch",href:l,...n})))}function _T({page:e,matches:t,...n}){let o=xt(),{future:s,manifest:a,routeModules:i}=yd(),{basename:l}=bd(),{loaderData:c,matches:d}=MT(),p=V(()=>dp(e,t,d,a,o,"data"),[e,t,d,a,o]),f=V(()=>dp(e,t,d,a,o,"assets"),[e,t,d,a,o]),m=V(()=>{if(e===o.pathname+o.search+o.hash)return[];let x=new Set,b=!1;if(t.forEach(w=>{let y=a.routes[w.route.id];!y||!y.hasLoader||(!p.some(N=>N.route.id===w.route.id)&&w.route.id in c&&i[w.route.id]?.shouldRevalidate||y.hasClientLoader?b=!0:x.add(w.route.id))}),x.size===0)return[];let v=h0(e,l,s.unstable_trailingSlashAwareDataRequests,"data");return b&&x.size>0&&v.searchParams.set("_routes",t.filter(w=>x.has(w.route.id)).map(w=>w.route.id).join(",")),[v.pathname+v.search]},[l,s.unstable_trailingSlashAwareDataRequests,c,o,a,p,t,e,i]),h=V(()=>NT(f,a),[f,a]),g=IT(f);return Ae(yr,null,m.map(x=>Ae("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),h.map(x=>Ae("link",{key:x,rel:"modulepreload",href:x,...n})),g.map(({key:x,link:b})=>Ae("link",{key:x,nonce:n.nonce,...b,crossOrigin:b.crossOrigin??n.crossOrigin})))}function $T(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var DT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{DT&&(window.__reactRouterVersion="7.15.0")}catch{}function LT({basename:e,children:t,useTransitions:n,window:o}){let s=re();s.current==null&&(s.current=cL({window:o,v5Compat:!0}));let a=s.current,[i,l]=P({action:a.action,location:a.location}),c=U(d=>{n===!1?l(d):nc(()=>l(d))},[n]);return fa(()=>a.listen(c),[a,c]),Ae(lT,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,useTransitions:n})}var g0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,qs=qe(function({onClick:t,discover:n="render",prefetch:o="none",relative:s,reloadDocument:a,replace:i,mask:l,state:c,target:d,to:p,preventScrollReset:f,viewTransition:m,defaultShouldRevalidate:h,...g},x){let{basename:b,navigator:v,useTransitions:w}=xe(bt),y=typeof p=="string"&&g0.test(p),N=s0(p,b);p=N.to;let k=UL(p,{relative:s}),C=xt(),D=null;if(l){let $=Ma(l,[],C.mask?C.mask.pathname:"/",!0);b!=="/"&&($.pathname=$.pathname==="/"?b:Tt([b,$.pathname])),D=v.createHref($)}let[E,I,z]=AT(o,g),A=zT(p,{replace:i,mask:l,state:c,target:d,preventScrollReset:f,relative:s,viewTransition:m,defaultShouldRevalidate:h,useTransitions:w});function T($){t&&t($),$.defaultPrevented||A($)}let R=!(N.isExternal||a),M=Ae("a",{...g,...z,href:(R?D:void 0)||N.absoluteURL||k,onClick:R?T:t,ref:$T(x,I),target:d,"data-discover":!y&&n==="render"?"true":void 0});return E&&!y?Ae(yr,null,M,Ae(ET,{page:k})):M});qs.displayName="Link";var TT=qe(function({"aria-current":t="page",caseSensitive:n=!1,className:o="",end:s=!1,style:a,to:i,viewTransition:l,children:c,...d},p){let f=Vo(i,{relative:d.relative}),m=xt(),h=xe(Aa),{navigator:g,basename:x}=xe(bt),b=h!=null&&VT(f)&&l===!0,v=g.encodeLocation?g.encodeLocation(f).pathname:f.pathname,w=m.pathname,y=h&&h.navigation&&h.navigation.location?h.navigation.location.pathname:null;n||(w=w.toLowerCase(),y=y?y.toLowerCase():null,v=v.toLowerCase()),y&&x&&(y=dn(y,x)||y);const N=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let k=w===v||!s&&w.startsWith(v)&&w.charAt(N)==="/",C=y!=null&&(y===v||!s&&y.startsWith(v)&&y.charAt(v.length)==="/"),D={isActive:k,isPending:C,isTransitioning:b},E=k?t:void 0,I;typeof o=="function"?I=o(D):I=[o,k?"active":null,C?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let z=typeof a=="function"?a(D):a;return Ae(qs,{...d,"aria-current":E,className:I,ref:p,style:z,to:i,viewTransition:l},typeof c=="function"?c(D):c)});TT.displayName="NavLink";var RT=qe(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:o,replace:s,state:a,method:i=Is,action:l,onSubmit:c,relative:d,preventScrollReset:p,viewTransition:f,defaultShouldRevalidate:m,...h},g)=>{let{useTransitions:x}=xe(bt),b=jT(),v=HT(l,{relative:d}),w=i.toLowerCase()==="get"?"get":"post",y=typeof l=="string"&&g0.test(l);return Ae("form",{ref:g,method:w,action:v,onSubmit:o?c:k=>{if(c&&c(k),k.defaultPrevented)return;k.preventDefault();let C=k.nativeEvent.submitter,D=C?.getAttribute("formmethod")||i,E=()=>b(C||k.currentTarget,{fetcherKey:t,method:D,navigate:n,replace:s,state:a,relative:d,preventScrollReset:p,viewTransition:f,defaultShouldRevalidate:m});x&&n!==!1?nc(()=>E()):E()},...h,"data-discover":!y&&e==="render"?"true":void 0})});RT.displayName="Form";function OT(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function b0(e){let t=xe(Ur);return He(t,OT(e)),t}function zT(e,{target:t,replace:n,mask:o,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c,useTransitions:d}={}){let p=rt(),f=xt(),m=Vo(e,{relative:i});return U(h=>{if(mT(h,t)){h.preventDefault();let g=n!==void 0?n:No(f)===No(m),x=()=>p(e,{replace:g,mask:o,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c});d?nc(()=>x()):x()}},[f,p,m,n,o,s,t,e,a,i,l,c,d])}function Ia(e){wt(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=re(wl(e)),n=re(!1),o=xt(),s=V(()=>hT(o.search,n.current?null:t.current),[o.search]),a=rt(),i=U((l,c)=>{const d=wl(typeof l=="function"?l(new URLSearchParams(s)):l);n.current=!0,a("?"+d,c)},[a,s]);return[s,i]}var BT=0,FT=()=>`__${String(++BT)}__`;function jT(){let{router:e}=b0("useSubmit"),{basename:t}=xe(bt),n=rT(),o=e.fetch,s=e.navigate;return U(async(a,i={})=>{let{action:l,method:c,encType:d,formData:p,body:f}=xT(a,t);if(i.navigate===!1){let m=i.fetcherKey||FT();await o(m,n,i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:p,body:f,formMethod:i.method||c,formEncType:i.encType||d,flushSync:i.flushSync})}else await s(i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:p,body:f,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 HT(e,{relative:t}={}){let{basename:n}=xe(bt),o=xe(Mt);He(o,"useFormAction must be used inside a RouteContext");let[s]=o.matches.slice(-1),a={...Vo(e||".",{relative:t})},i=xt();if(e==null){a.search=i.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(p=>p==="")){l.delete("index"),c.filter(f=>f).forEach(f=>l.append("index",f));let p=l.toString();a.search=p?`?${p}`:""}}return(!e||e===".")&&s.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Tt([n,a.pathname])),No(a)}function VT(e,{relative:t}={}){let n=xe(l0);He(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=b0("useViewTransitionState"),s=Vo(e,{relative:t});if(!n.isTransitioning)return!1;let a=dn(n.currentLocation.pathname,o)||n.currentLocation.pathname,i=dn(n.nextLocation.pathname,o)||n.nextLocation.pathname;return Vs(s.pathname,i)!=null||Vs(s.pathname,a)!=null}const UT=3e4;function qT(e){const t=re(e);t.current=e,Y(()=>{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>=UT&&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 Nl="disconnected";const kl=new Set;function QT(){for(const e of kl)e()}function GT(e){Nl!==e&&(Nl=e,QT())}function KT(e){return kl.add(e),()=>{kl.delete(e)}}function up(){return Nl}function WT(){return ma(KT,up,up)}let lo=null;function _s(){if(!lo){const e=window.location.origin,t=localStorage.getItem("camstack_admin_token")??void 0;lo=Am({serverUrl:e,token:t,onConnectionChange:n=>GT(n)})}return lo}function dr(){lo?.close(),lo=null}/**
|
|
573
|
+
* @license lucide-react v0.511.0 - ISC
|
|
574
|
+
*
|
|
575
|
+
* This source code is licensed under the ISC license.
|
|
576
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
577
|
+
*/const YT=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ZT=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase()),pp=e=>{const t=ZT(e);return t.charAt(0).toUpperCase()+t.slice(1)},x0=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim(),XT=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/**
|
|
578
|
+
* @license lucide-react v0.511.0 - ISC
|
|
579
|
+
*
|
|
580
|
+
* This source code is licensed under the ISC license.
|
|
581
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
582
|
+
*/var JT={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"};/**
|
|
583
|
+
* @license lucide-react v0.511.0 - ISC
|
|
584
|
+
*
|
|
585
|
+
* This source code is licensed under the ISC license.
|
|
586
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
587
|
+
*/const eR=qe(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:s="",children:a,iconNode:i,...l},c)=>Ae("svg",{ref:c,...JT,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:x0("lucide",s),...!a&&!XT(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,p])=>Ae(d,p)),...Array.isArray(a)?a:[a]]));/**
|
|
588
|
+
* @license lucide-react v0.511.0 - ISC
|
|
589
|
+
*
|
|
590
|
+
* This source code is licensed under the ISC license.
|
|
591
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
592
|
+
*/const se=(e,t)=>{const n=qe(({className:o,...s},a)=>Ae(eR,{ref:a,iconNode:t,className:x0(`lucide-${YT(pp(e))}`,`lucide-${e}`,o),...s}));return n.displayName=pp(e),n};/**
|
|
593
|
+
* @license lucide-react v0.511.0 - ISC
|
|
594
|
+
*
|
|
595
|
+
* This source code is licensed under the ISC license.
|
|
596
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
597
|
+
*/const tR=[["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"}]],Pa=se("activity",tR);/**
|
|
598
|
+
* @license lucide-react v0.511.0 - ISC
|
|
599
|
+
*
|
|
600
|
+
* This source code is licensed under the ISC license.
|
|
601
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
602
|
+
*/const nR=[["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"}]],y0=se("archive",nR);/**
|
|
603
|
+
* @license lucide-react v0.511.0 - ISC
|
|
604
|
+
*
|
|
605
|
+
* This source code is licensed under the ISC license.
|
|
606
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
607
|
+
*/const rR=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],vd=se("arrow-left",rR);/**
|
|
608
|
+
* @license lucide-react v0.511.0 - ISC
|
|
609
|
+
*
|
|
610
|
+
* This source code is licensed under the ISC license.
|
|
611
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
612
|
+
*/const oR=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],sR=se("arrow-right",oR);/**
|
|
613
|
+
* @license lucide-react v0.511.0 - ISC
|
|
614
|
+
*
|
|
615
|
+
* This source code is licensed under the ISC license.
|
|
616
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
617
|
+
*/const aR=[["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"}]],iR=se("battery-full",aR);/**
|
|
618
|
+
* @license lucide-react v0.511.0 - ISC
|
|
619
|
+
*
|
|
620
|
+
* This source code is licensed under the ISC license.
|
|
621
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
622
|
+
*/const lR=[["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"}]],Uo=se("bell",lR);/**
|
|
623
|
+
* @license lucide-react v0.511.0 - ISC
|
|
624
|
+
*
|
|
625
|
+
* This source code is licensed under the ISC license.
|
|
626
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
627
|
+
*/const cR=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],dR=se("book-open",cR);/**
|
|
628
|
+
* @license lucide-react v0.511.0 - ISC
|
|
629
|
+
*
|
|
630
|
+
* This source code is licensed under the ISC license.
|
|
631
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
632
|
+
*/const uR=[["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"}]],pR=se("bot",uR);/**
|
|
633
|
+
* @license lucide-react v0.511.0 - ISC
|
|
634
|
+
*
|
|
635
|
+
* This source code is licensed under the ISC license.
|
|
636
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
637
|
+
*/const fR=[["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"}]],wd=se("box",fR);/**
|
|
638
|
+
* @license lucide-react v0.511.0 - ISC
|
|
639
|
+
*
|
|
640
|
+
* This source code is licensed under the ISC license.
|
|
641
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
642
|
+
*/const mR=[["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"}]],_a=se("boxes",mR);/**
|
|
643
|
+
* @license lucide-react v0.511.0 - ISC
|
|
644
|
+
*
|
|
645
|
+
* This source code is licensed under the ISC license.
|
|
646
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
647
|
+
*/const hR=[["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"}]],gR=se("calendar-clock",hR);/**
|
|
648
|
+
* @license lucide-react v0.511.0 - ISC
|
|
649
|
+
*
|
|
650
|
+
* This source code is licensed under the ISC license.
|
|
651
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
652
|
+
*/const bR=[["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"}]],v0=se("calendar",bR);/**
|
|
653
|
+
* @license lucide-react v0.511.0 - ISC
|
|
654
|
+
*
|
|
655
|
+
* This source code is licensed under the ISC license.
|
|
656
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
657
|
+
*/const xR=[["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"}]],Nr=se("camera",xR);/**
|
|
658
|
+
* @license lucide-react v0.511.0 - ISC
|
|
659
|
+
*
|
|
660
|
+
* This source code is licensed under the ISC license.
|
|
661
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
662
|
+
*/const yR=[["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"}]],w0=se("cctv",yR);/**
|
|
663
|
+
* @license lucide-react v0.511.0 - ISC
|
|
664
|
+
*
|
|
665
|
+
* This source code is licensed under the ISC license.
|
|
666
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
667
|
+
*/const vR=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],wR=se("check-check",vR);/**
|
|
668
|
+
* @license lucide-react v0.511.0 - ISC
|
|
669
|
+
*
|
|
670
|
+
* This source code is licensed under the ISC license.
|
|
671
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
672
|
+
*/const NR=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],At=se("check",NR);/**
|
|
673
|
+
* @license lucide-react v0.511.0 - ISC
|
|
674
|
+
*
|
|
675
|
+
* This source code is licensed under the ISC license.
|
|
676
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
677
|
+
*/const kR=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Nt=se("chevron-down",kR);/**
|
|
678
|
+
* @license lucide-react v0.511.0 - ISC
|
|
679
|
+
*
|
|
680
|
+
* This source code is licensed under the ISC license.
|
|
681
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
682
|
+
*/const SR=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Nd=se("chevron-left",SR);/**
|
|
683
|
+
* @license lucide-react v0.511.0 - ISC
|
|
684
|
+
*
|
|
685
|
+
* This source code is licensed under the ISC license.
|
|
686
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
687
|
+
*/const CR=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],zt=se("chevron-right",CR);/**
|
|
688
|
+
* @license lucide-react v0.511.0 - ISC
|
|
689
|
+
*
|
|
690
|
+
* This source code is licensed under the ISC license.
|
|
691
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
692
|
+
*/const MR=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],AR=se("chevron-up",MR);/**
|
|
693
|
+
* @license lucide-react v0.511.0 - ISC
|
|
694
|
+
*
|
|
695
|
+
* This source code is licensed under the ISC license.
|
|
696
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
697
|
+
*/const ER=[["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"}]],kr=se("circle-alert",ER);/**
|
|
698
|
+
* @license lucide-react v0.511.0 - ISC
|
|
699
|
+
*
|
|
700
|
+
* This source code is licensed under the ISC license.
|
|
701
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
702
|
+
*/const IR=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],co=se("circle-check-big",IR);/**
|
|
703
|
+
* @license lucide-react v0.511.0 - ISC
|
|
704
|
+
*
|
|
705
|
+
* This source code is licensed under the ISC license.
|
|
706
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
707
|
+
*/const PR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],kd=se("circle-check",PR);/**
|
|
708
|
+
* @license lucide-react v0.511.0 - ISC
|
|
709
|
+
*
|
|
710
|
+
* This source code is licensed under the ISC license.
|
|
711
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
712
|
+
*/const _R=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],N0=se("circle-dot",_R);/**
|
|
713
|
+
* @license lucide-react v0.511.0 - ISC
|
|
714
|
+
*
|
|
715
|
+
* This source code is licensed under the ISC license.
|
|
716
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
717
|
+
*/const $R=[["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"}]],DR=se("circle-help",$R);/**
|
|
718
|
+
* @license lucide-react v0.511.0 - ISC
|
|
719
|
+
*
|
|
720
|
+
* This source code is licensed under the ISC license.
|
|
721
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
722
|
+
*/const LR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],TR=se("clock",LR);/**
|
|
723
|
+
* @license lucide-react v0.511.0 - ISC
|
|
724
|
+
*
|
|
725
|
+
* This source code is licensed under the ISC license.
|
|
726
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
727
|
+
*/const RR=[["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"}]],Qs=se("copy",RR);/**
|
|
728
|
+
* @license lucide-react v0.511.0 - ISC
|
|
729
|
+
*
|
|
730
|
+
* This source code is licensed under the ISC license.
|
|
731
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
732
|
+
*/const OR=[["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"}]],Ot=se("cpu",OR);/**
|
|
733
|
+
* @license lucide-react v0.511.0 - ISC
|
|
734
|
+
*
|
|
735
|
+
* This source code is licensed under the ISC license.
|
|
736
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
737
|
+
*/const zR=[["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"}]],k0=se("database",zR);/**
|
|
738
|
+
* @license lucide-react v0.511.0 - ISC
|
|
739
|
+
*
|
|
740
|
+
* This source code is licensed under the ISC license.
|
|
741
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
742
|
+
*/const BR=[["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"}]],Kt=se("download",BR);/**
|
|
743
|
+
* @license lucide-react v0.511.0 - ISC
|
|
744
|
+
*
|
|
745
|
+
* This source code is licensed under the ISC license.
|
|
746
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
747
|
+
*/const FR=[["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"}]],jR=se("ellipsis-vertical",FR);/**
|
|
748
|
+
* @license lucide-react v0.511.0 - ISC
|
|
749
|
+
*
|
|
750
|
+
* This source code is licensed under the ISC license.
|
|
751
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
752
|
+
*/const HR=[["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"}]],Sd=se("external-link",HR);/**
|
|
753
|
+
* @license lucide-react v0.511.0 - ISC
|
|
754
|
+
*
|
|
755
|
+
* This source code is licensed under the ISC license.
|
|
756
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
757
|
+
*/const VR=[["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"}]],S0=se("eye-off",VR);/**
|
|
758
|
+
* @license lucide-react v0.511.0 - ISC
|
|
759
|
+
*
|
|
760
|
+
* This source code is licensed under the ISC license.
|
|
761
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
762
|
+
*/const UR=[["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"}]],$a=se("eye",UR);/**
|
|
763
|
+
* @license lucide-react v0.511.0 - ISC
|
|
764
|
+
*
|
|
765
|
+
* This source code is licensed under the ISC license.
|
|
766
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
767
|
+
*/const qR=[["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"}]],uo=se("film",qR);/**
|
|
768
|
+
* @license lucide-react v0.511.0 - ISC
|
|
769
|
+
*
|
|
770
|
+
* This source code is licensed under the ISC license.
|
|
771
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
772
|
+
*/const QR=[["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"}]],GR=se("flame",QR);/**
|
|
773
|
+
* @license lucide-react v0.511.0 - ISC
|
|
774
|
+
*
|
|
775
|
+
* This source code is licensed under the ISC license.
|
|
776
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
777
|
+
*/const KR=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],WR=se("gauge",KR);/**
|
|
778
|
+
* @license lucide-react v0.511.0 - ISC
|
|
779
|
+
*
|
|
780
|
+
* This source code is licensed under the ISC license.
|
|
781
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
782
|
+
*/const YR=[["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"}]],Sl=se("ghost",YR);/**
|
|
783
|
+
* @license lucide-react v0.511.0 - ISC
|
|
784
|
+
*
|
|
785
|
+
* This source code is licensed under the ISC license.
|
|
786
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
787
|
+
*/const ZR=[["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"}]],XR=se("git-branch",ZR);/**
|
|
788
|
+
* @license lucide-react v0.511.0 - ISC
|
|
789
|
+
*
|
|
790
|
+
* This source code is licensed under the ISC license.
|
|
791
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
792
|
+
*/const JR=[["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"}]],Cn=se("globe",JR);/**
|
|
793
|
+
* @license lucide-react v0.511.0 - ISC
|
|
794
|
+
*
|
|
795
|
+
* This source code is licensed under the ISC license.
|
|
796
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
797
|
+
*/const e6=[["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"}]],Gs=se("hard-drive",e6);/**
|
|
798
|
+
* @license lucide-react v0.511.0 - ISC
|
|
799
|
+
*
|
|
800
|
+
* This source code is licensed under the ISC license.
|
|
801
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
802
|
+
*/const t6=[["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"}]],n6=se("house",t6);/**
|
|
803
|
+
* @license lucide-react v0.511.0 - ISC
|
|
804
|
+
*
|
|
805
|
+
* This source code is licensed under the ISC license.
|
|
806
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
807
|
+
*/const r6=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Gn=se("info",r6);/**
|
|
808
|
+
* @license lucide-react v0.511.0 - ISC
|
|
809
|
+
*
|
|
810
|
+
* This source code is licensed under the ISC license.
|
|
811
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
812
|
+
*/const o6=[["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"}]],C0=se("key-round",o6);/**
|
|
813
|
+
* @license lucide-react v0.511.0 - ISC
|
|
814
|
+
*
|
|
815
|
+
* This source code is licensed under the ISC license.
|
|
816
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
817
|
+
*/const s6=[["path",{d:"M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z",key:"165ttr"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"m9.4 10.6-6.814 6.814A2 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-.814",key:"1ubxi2"}]],a6=se("key-square",s6);/**
|
|
818
|
+
* @license lucide-react v0.511.0 - ISC
|
|
819
|
+
*
|
|
820
|
+
* This source code is licensed under the ISC license.
|
|
821
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
822
|
+
*/const i6=[["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"}]],l6=se("key",i6);/**
|
|
823
|
+
* @license lucide-react v0.511.0 - ISC
|
|
824
|
+
*
|
|
825
|
+
* This source code is licensed under the ISC license.
|
|
826
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
827
|
+
*/const c6=[["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"}]],d6=se("layers",c6);/**
|
|
828
|
+
* @license lucide-react v0.511.0 - ISC
|
|
829
|
+
*
|
|
830
|
+
* This source code is licensed under the ISC license.
|
|
831
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
832
|
+
*/const u6=[["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"}]],M0=se("layout-dashboard",u6);/**
|
|
833
|
+
* @license lucide-react v0.511.0 - ISC
|
|
834
|
+
*
|
|
835
|
+
* This source code is licensed under the ISC license.
|
|
836
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
837
|
+
*/const p6=[["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"}]],f6=se("lightbulb",p6);/**
|
|
838
|
+
* @license lucide-react v0.511.0 - ISC
|
|
839
|
+
*
|
|
840
|
+
* This source code is licensed under the ISC license.
|
|
841
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
842
|
+
*/const m6=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],A0=se("link",m6);/**
|
|
843
|
+
* @license lucide-react v0.511.0 - ISC
|
|
844
|
+
*
|
|
845
|
+
* This source code is licensed under the ISC license.
|
|
846
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
847
|
+
*/const h6=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Se=se("loader-circle",h6);/**
|
|
848
|
+
* @license lucide-react v0.511.0 - ISC
|
|
849
|
+
*
|
|
850
|
+
* This source code is licensed under the ISC license.
|
|
851
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
852
|
+
*/const g6=[["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"}]],Cd=se("lock",g6);/**
|
|
853
|
+
* @license lucide-react v0.511.0 - ISC
|
|
854
|
+
*
|
|
855
|
+
* This source code is licensed under the ISC license.
|
|
856
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
857
|
+
*/const b6=[["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"}]],x6=se("log-in",b6);/**
|
|
858
|
+
* @license lucide-react v0.511.0 - ISC
|
|
859
|
+
*
|
|
860
|
+
* This source code is licensed under the ISC license.
|
|
861
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
862
|
+
*/const y6=[["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"}]],Md=se("log-out",y6);/**
|
|
863
|
+
* @license lucide-react v0.511.0 - ISC
|
|
864
|
+
*
|
|
865
|
+
* This source code is licensed under the ISC license.
|
|
866
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
867
|
+
*/const v6=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],w6=se("mail",v6);/**
|
|
868
|
+
* @license lucide-react v0.511.0 - ISC
|
|
869
|
+
*
|
|
870
|
+
* This source code is licensed under the ISC license.
|
|
871
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
872
|
+
*/const N6=[["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"}]],k6=se("map-pin",N6);/**
|
|
873
|
+
* @license lucide-react v0.511.0 - ISC
|
|
874
|
+
*
|
|
875
|
+
* This source code is licensed under the ISC license.
|
|
876
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
877
|
+
*/const S6=[["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"}]],E0=se("memory-stick",S6);/**
|
|
878
|
+
* @license lucide-react v0.511.0 - ISC
|
|
879
|
+
*
|
|
880
|
+
* This source code is licensed under the ISC license.
|
|
881
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
882
|
+
*/const C6=[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]],M6=se("menu",C6);/**
|
|
883
|
+
* @license lucide-react v0.511.0 - ISC
|
|
884
|
+
*
|
|
885
|
+
* This source code is licensed under the ISC license.
|
|
886
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
887
|
+
*/const A6=[["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"}]],Cl=se("mic",A6);/**
|
|
888
|
+
* @license lucide-react v0.511.0 - ISC
|
|
889
|
+
*
|
|
890
|
+
* This source code is licensed under the ISC license.
|
|
891
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
892
|
+
*/const E6=[["path",{d:"M5 12h14",key:"1ays0h"}]],I6=se("minus",E6);/**
|
|
893
|
+
* @license lucide-react v0.511.0 - ISC
|
|
894
|
+
*
|
|
895
|
+
* This source code is licensed under the ISC license.
|
|
896
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
897
|
+
*/const P6=[["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"}]],_6=se("monitor",P6);/**
|
|
898
|
+
* @license lucide-react v0.511.0 - ISC
|
|
899
|
+
*
|
|
900
|
+
* This source code is licensed under the ISC license.
|
|
901
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
902
|
+
*/const $6=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],I0=se("moon",$6);/**
|
|
903
|
+
* @license lucide-react v0.511.0 - ISC
|
|
904
|
+
*
|
|
905
|
+
* This source code is licensed under the ISC license.
|
|
906
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
907
|
+
*/const D6=[["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"}]],Mn=se("network",D6);/**
|
|
908
|
+
* @license lucide-react v0.511.0 - ISC
|
|
909
|
+
*
|
|
910
|
+
* This source code is licensed under the ISC license.
|
|
911
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
912
|
+
*/const L6=[["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"}]],T6=se("octagon-alert",L6);/**
|
|
913
|
+
* @license lucide-react v0.511.0 - ISC
|
|
914
|
+
*
|
|
915
|
+
* This source code is licensed under the ISC license.
|
|
916
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
917
|
+
*/const R6=[["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"}]],P0=se("package",R6);/**
|
|
918
|
+
* @license lucide-react v0.511.0 - ISC
|
|
919
|
+
*
|
|
920
|
+
* This source code is licensed under the ISC license.
|
|
921
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
922
|
+
*/const O6=[["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"}]],Qr=se("pencil",O6);/**
|
|
923
|
+
* @license lucide-react v0.511.0 - ISC
|
|
924
|
+
*
|
|
925
|
+
* This source code is licensed under the ISC license.
|
|
926
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
927
|
+
*/const z6=[["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"}]],_0=se("pin",z6);/**
|
|
928
|
+
* @license lucide-react v0.511.0 - ISC
|
|
929
|
+
*
|
|
930
|
+
* This source code is licensed under the ISC license.
|
|
931
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
932
|
+
*/const B6=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],Da=se("play",B6);/**
|
|
933
|
+
* @license lucide-react v0.511.0 - ISC
|
|
934
|
+
*
|
|
935
|
+
* This source code is licensed under the ISC license.
|
|
936
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
937
|
+
*/const F6=[["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"}]],ko=se("plug",F6);/**
|
|
938
|
+
* @license lucide-react v0.511.0 - ISC
|
|
939
|
+
*
|
|
940
|
+
* This source code is licensed under the ISC license.
|
|
941
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
942
|
+
*/const j6=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],kt=se("plus",j6);/**
|
|
943
|
+
* @license lucide-react v0.511.0 - ISC
|
|
944
|
+
*
|
|
945
|
+
* This source code is licensed under the ISC license.
|
|
946
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
947
|
+
*/const H6=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],$0=se("power",H6);/**
|
|
948
|
+
* @license lucide-react v0.511.0 - ISC
|
|
949
|
+
*
|
|
950
|
+
* This source code is licensed under the ISC license.
|
|
951
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
952
|
+
*/const V6=[["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"}]],Ks=se("puzzle",V6);/**
|
|
953
|
+
* @license lucide-react v0.511.0 - ISC
|
|
954
|
+
*
|
|
955
|
+
* This source code is licensed under the ISC license.
|
|
956
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
957
|
+
*/const U6=[["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"}]],q6=se("radar",U6);/**
|
|
958
|
+
* @license lucide-react v0.511.0 - ISC
|
|
959
|
+
*
|
|
960
|
+
* This source code is licensed under the ISC license.
|
|
961
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
962
|
+
*/const Q6=[["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"}]],La=se("radio",Q6);/**
|
|
963
|
+
* @license lucide-react v0.511.0 - ISC
|
|
964
|
+
*
|
|
965
|
+
* This source code is licensed under the ISC license.
|
|
966
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
967
|
+
*/const G6=[["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"}]],it=se("refresh-cw",G6);/**
|
|
968
|
+
* @license lucide-react v0.511.0 - ISC
|
|
969
|
+
*
|
|
970
|
+
* This source code is licensed under the ISC license.
|
|
971
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
972
|
+
*/const K6=[["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"}]],D0=se("rotate-ccw",K6);/**
|
|
973
|
+
* @license lucide-react v0.511.0 - ISC
|
|
974
|
+
*
|
|
975
|
+
* This source code is licensed under the ISC license.
|
|
976
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
977
|
+
*/const W6=[["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"}]],qt=se("rotate-cw",W6);/**
|
|
978
|
+
* @license lucide-react v0.511.0 - ISC
|
|
979
|
+
*
|
|
980
|
+
* This source code is licensed under the ISC license.
|
|
981
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
982
|
+
*/const Y6=[["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"}]],Z6=se("save",Y6);/**
|
|
983
|
+
* @license lucide-react v0.511.0 - ISC
|
|
984
|
+
*
|
|
985
|
+
* This source code is licensed under the ISC license.
|
|
986
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
987
|
+
*/const X6=[["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"}]],vt=se("scroll-text",X6);/**
|
|
988
|
+
* @license lucide-react v0.511.0 - ISC
|
|
989
|
+
*
|
|
990
|
+
* This source code is licensed under the ISC license.
|
|
991
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
992
|
+
*/const J6=[["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"}]],eO=se("search-x",J6);/**
|
|
993
|
+
* @license lucide-react v0.511.0 - ISC
|
|
994
|
+
*
|
|
995
|
+
* This source code is licensed under the ISC license.
|
|
996
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
997
|
+
*/const tO=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],L0=se("search",tO);/**
|
|
998
|
+
* @license lucide-react v0.511.0 - ISC
|
|
999
|
+
*
|
|
1000
|
+
* This source code is licensed under the ISC license.
|
|
1001
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1002
|
+
*/const nO=[["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"}]],An=se("server",nO);/**
|
|
1003
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1004
|
+
*
|
|
1005
|
+
* This source code is licensed under the ISC license.
|
|
1006
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1007
|
+
*/const rO=[["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"}]],Wt=se("settings",rO);/**
|
|
1008
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1009
|
+
*
|
|
1010
|
+
* This source code is licensed under the ISC license.
|
|
1011
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1012
|
+
*/const oO=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],sO=se("share-2",oO);/**
|
|
1013
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1014
|
+
*
|
|
1015
|
+
* This source code is licensed under the ISC license.
|
|
1016
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1017
|
+
*/const aO=[["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"}]],un=se("shield-check",aO);/**
|
|
1018
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1019
|
+
*
|
|
1020
|
+
* This source code is licensed under the ISC license.
|
|
1021
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1022
|
+
*/const iO=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]],fp=se("shield-off",iO);/**
|
|
1023
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1024
|
+
*
|
|
1025
|
+
* This source code is licensed under the ISC license.
|
|
1026
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1027
|
+
*/const lO=[["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"}]],cO=se("shield-x",lO);/**
|
|
1028
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1029
|
+
*
|
|
1030
|
+
* This source code is licensed under the ISC license.
|
|
1031
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1032
|
+
*/const dO=[["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"}]],uO=se("shield",dO);/**
|
|
1033
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1034
|
+
*
|
|
1035
|
+
* This source code is licensed under the ISC license.
|
|
1036
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1037
|
+
*/const pO=[["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"}]],ls=se("skull",pO);/**
|
|
1038
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1039
|
+
*
|
|
1040
|
+
* This source code is licensed under the ISC license.
|
|
1041
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1042
|
+
*/const fO=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],kn=se("smartphone",fO);/**
|
|
1043
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1044
|
+
*
|
|
1045
|
+
* This source code is licensed under the ISC license.
|
|
1046
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1047
|
+
*/const mO=[["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"}]],hO=se("sparkles",mO);/**
|
|
1048
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1049
|
+
*
|
|
1050
|
+
* This source code is licensed under the ISC license.
|
|
1051
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1052
|
+
*/const gO=[["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"}]],T0=se("square-check-big",gO);/**
|
|
1053
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1054
|
+
*
|
|
1055
|
+
* This source code is licensed under the ISC license.
|
|
1056
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1057
|
+
*/const bO=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],qo=se("square",bO);/**
|
|
1058
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1059
|
+
*
|
|
1060
|
+
* This source code is licensed under the ISC license.
|
|
1061
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1062
|
+
*/const xO=[["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"}]],yi=se("star",xO);/**
|
|
1063
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1064
|
+
*
|
|
1065
|
+
* This source code is licensed under the ISC license.
|
|
1066
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1067
|
+
*/const yO=[["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"}]],vO=se("sun",yO);/**
|
|
1068
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1069
|
+
*
|
|
1070
|
+
* This source code is licensed under the ISC license.
|
|
1071
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1072
|
+
*/const wO=[["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"}]],NO=se("table-2",wO);/**
|
|
1073
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1074
|
+
*
|
|
1075
|
+
* This source code is licensed under the ISC license.
|
|
1076
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1077
|
+
*/const kO=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],R0=se("terminal",kO);/**
|
|
1078
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1079
|
+
*
|
|
1080
|
+
* This source code is licensed under the ISC license.
|
|
1081
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1082
|
+
*/const SO=[["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"}]],We=se("trash-2",SO);/**
|
|
1083
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1084
|
+
*
|
|
1085
|
+
* This source code is licensed under the ISC license.
|
|
1086
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1087
|
+
*/const CO=[["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"}]],at=se("triangle-alert",CO);/**
|
|
1088
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1089
|
+
*
|
|
1090
|
+
* This source code is licensed under the ISC license.
|
|
1091
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1092
|
+
*/const MO=[["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"}]],Ta=se("upload",MO);/**
|
|
1093
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1094
|
+
*
|
|
1095
|
+
* This source code is licensed under the ISC license.
|
|
1096
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1097
|
+
*/const AO=[["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"}]],EO=se("users",AO);/**
|
|
1098
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1099
|
+
*
|
|
1100
|
+
* This source code is licensed under the ISC license.
|
|
1101
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1102
|
+
*/const IO=[["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"}]],O0=se("video",IO);/**
|
|
1103
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1104
|
+
*
|
|
1105
|
+
* This source code is licensed under the ISC license.
|
|
1106
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1107
|
+
*/const PO=[["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"}]],z0=se("wifi-off",PO);/**
|
|
1108
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1109
|
+
*
|
|
1110
|
+
* This source code is licensed under the ISC license.
|
|
1111
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1112
|
+
*/const _O=[["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"}]],Sr=se("wifi",_O);/**
|
|
1113
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1114
|
+
*
|
|
1115
|
+
* This source code is licensed under the ISC license.
|
|
1116
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1117
|
+
*/const $O=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Be=se("x",$O);/**
|
|
1118
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1119
|
+
*
|
|
1120
|
+
* This source code is licensed under the ISC license.
|
|
1121
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1122
|
+
*/const DO=[["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"}]],LO=se("wrench",DO);/**
|
|
1123
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1124
|
+
*
|
|
1125
|
+
* This source code is licensed under the ISC license.
|
|
1126
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1127
|
+
*/const TO=[["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"}]],Ad=se("zap",TO);function RO(){const e=Le(),t=we(),[n,o]=P(()=>e.isConnected()?"connected":"disconnected"),s=re(!1),[a,i]=P(0),[l,c]=P([]);Y(()=>e.subscribeConnectionEvents(m=>{o(h=>(h!=="connected"&&m==="connected"&&s.current&&i(g=>g+1),m!=="connected"&&(s.current=!0),m))}),[e]),Y(()=>{a!==0&&t.invalidateQueries({queryKey:[["addons","getLastRestart"]]})},[a,t]);const{data:d}=Eg(void 0,{enabled:n==="connected"&&a>0,staleTime:0,refetchOnMount:!1,refetchOnWindowFocus:!1}),p=re(null);return Y(()=>{if(d==null||d.requestedAt===p.current)return;p.current=d.requestedAt;const f=zO(d);c(h=>[...h,f]);const m=window.setTimeout(()=>{c(h=>h.filter(g=>g.id!==f.id))},6e3);return()=>window.clearTimeout(m)},[d]),r(ue,{children:l.length>0&&r(OO,{toasts:l})})}function OO({toasts:e}){return r("div",{className:"fixed top-4 right-4 z-50 flex flex-col gap-2 max-w-sm w-full pointer-events-none",children:e.map(t=>u("div",{className:"pointer-events-auto flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm",children:[r(kd,{className:"w-4 h-4 shrink-0 mt-0.5 text-green-400"}),u("div",{children:[r("div",{className:"text-[11px] font-semibold text-foreground",children:t.title}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:t.message})]})]},t.id))})}function zO(e){const t=`restart-${e.requestedAt}`;if(e.kind==="framework-update"&&e.packageName!==void 0&&e.toVersion!==void 0){const n=e.fromVersion!==void 0?`v${e.fromVersion} → v${e.toVersion}`:`v${e.toVersion}`;return{id:t,title:"Framework updated",message:`${e.packageName} is now ${n}.`}}return{id:t,title:"Server restarted",message:e.requestedBy!==void 0?`Manual restart by ${e.requestedBy} completed.`:"Manual restart completed."}}function BO(e){const t=Le();return Dr({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 FO(e){return typeof e=="string"&&e.length>0&&e!=="undefined"&&e!=="null"}function jO(e={}){const t=we(),n=Hr(void 0,{staleTime:1e4,enabled:e.enabled??!0}),o=V(()=>(n.data??[]).filter(i=>FO(i.nodeId)),[n.data]),s=U(()=>{t.invalidateQueries({queryKey:["pipelineOrchestrator","listAgentSettings"]})},[t]);return{agents:o,isLoading:n.isLoading,isError:n.isError,error:n.error,refetch:()=>{n.refetch()},invalidate:s}}function HO({field:e,disabled:t}){const n=we(),o=e.deviceId,s=BO(e.catalogResolver),a=Qc({agentNodeId:e.nodeId}),i=Kc({deviceId:o}),c=wx({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),d=s.data,p=a.data??null,f=i.data??null,m=V(()=>d?UO(d,p,f):[],[d,p,f]),h=V(()=>{if(!p)return{};const g={};for(const[x,b]of Object.entries(p.addonDefaults))g[x]=b.enabled;return g},[p]);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(_c,{schema:d,steps:m,onChange:()=>{},templates:[],selectedTemplateId:null,onSelectTemplate:()=>{},onSaveTemplate:()=>{},onUpdateTemplate:()=>{},onDeleteTemplate:()=>{},readOnly:t===!0,hideTemplates:!0,toggleMode:"threeState",hideModelAndSettings:!0,overrides:f?.stepToggles??{},onOverrideChange:(g,x)=>c.mutate({deviceId:o,addonId:g,enabled:x}),inheritedEnabledByAddon:h}),r(VO,{deviceId:o,currentAgentNodeId:e.nodeId,catalog:d,pipelineByAgent:f?.pipelineByAgent??{},disabled:t===!0})]})}function VO({deviceId:e,currentAgentNodeId:t,catalog:n,pipelineByAgent:o,disabled:s}){const a=we(),[i,l]=P(!1),[c,d]=P(t),{agents:p}=jO({enabled:i}),f=Sx({deviceId:e,agentNodeId:c},{enabled:i}),h=kx({onSuccess:()=>{a.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),a.invalidateQueries({queryKey:[["pipelineOrchestrator","resolvePipeline"]]})}}),g=o[c]??null,x=p,b=V(()=>g?qO(g.steps,n):[],[g,n]),v=w=>{const y=g?.audio??null;h.mutate({deviceId:e,agentNodeId:c,pipeline:{steps:QO(w),audio:y?{modelId:y.modelId,enabled:y.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(Nt,{className:"h-3 w-3"}):r(zt,{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)"]}),x.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(We,{className:"h-3 w-3"}),"Remove override"]})]}),g?r(_c,{schema:n,steps:b,onChange:v,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=f.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||!f.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 UO(e,t,n){const o=d=>{for(const p of e.slots)for(const f of p.addons)if(f.id===d)return f;return null},s=d=>{const p=t?.addonDefaults[d.id],f=p?.enabled??d.enabledByDefault??!0,m=n?.stepToggles?.[d.id],h=m!==void 0?m:f;return{addonId:d.id,addonName:d.name,slot:d.slot,inputClasses:[...d.inputClasses],outputClasses:[...d.outputClasses],enabled:h,modelId:p?.modelId??d.defaultModelId,children:[],...p?.settings&&Object.keys(p.settings).length>0?{settings:p.settings}:{}}},a=new Map;for(const d of e.slots)for(const p of d.addons)a.set(p.id,s(p));const i=[],l=new Set;for(const[d,p]of a){const f=o(d);f&&f.inputClasses.length===0&&(i.push(p),l.add(d))}let c=!0;for(;c;){c=!1;for(const[d,p]of a){if(l.has(d))continue;const f=o(d);if(f)for(const[m,h]of a){if(m===d)continue;const g=o(m);if(g&&l.has(m)&&g.outputClasses.some(x=>f.inputClasses.includes(x))){h.children.push(p),l.add(d),c=!0;break}}}}return i}function qO(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 QO(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 GO({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 KO(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 WO(e){return`${e.inputSize.width}x${e.inputSize.height}`}function YO(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function ZO({entry:e,selected:t,onSelect:n,disabled:o}){const s=KO(e),a=WO(e),i=YO(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(At,{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(Ot,{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 XO({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]=P(a?"catalog":"custom"),p=t==null?"":String(t);return u("div",{className:"space-y-3",children:[l.length>1&&r(GO,{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(f=>r(ZO,{entry:f,selected:p===f.id,onSelect:()=>n(f.id),disabled:o||e.disabled},f.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(Gn,{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:p,disabled:o||e.disabled,onChange:f=>n(f.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(Gn,{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(Sd,{className:"h-3 w-3"})]})]})]})}function $s(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"),isAdmin:!!n.isAdmin,exp:Number(n.exp??0),scopes:t8(n.scopes)}}catch{return null}}const JO=new Set(["view","create","delete"]),e8=new Set(["category","capability","addon","device"]);function t8(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,access:a}=o;if(typeof s!="string"||!e8.has(s)||!Array.isArray(a))continue;const i=a.filter(c=>typeof c=="string"&&JO.has(c));if(i.length===0)continue;if(s==="device"){const c=o.targets;if(!Array.isArray(c))continue;const d=c.filter(p=>typeof p=="string"&&p.length>0);if(d.length===0)continue;t.push({type:"device",targets:d,access:i});continue}const l=o.target;if(typeof l=="string")if(s==="category"){if(l!=="device"&&l!=="system")continue;t.push({type:s,target:l,access:i})}else s==="capability"?t.push({type:s,target:l,access:i}):t.push({type:"addon",target:l,access:i})}return t}function n8(e){const t=$s(e);return t?t.exp*1e3<Date.now():!0}const r8="changeme",B0=je(null);function o8({children:e}){const[t,n]=P(null),[o,s]=P(!0),[a,i]=P(!1);Y(()=>{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(n8(f)){localStorage.removeItem("camstack_admin_token"),s(!1);return}const m=$s(f);if(!m){localStorage.removeItem("camstack_admin_token"),s(!1);return}_s().trpcClient.system.info.query().then(()=>n(m)).catch(x=>{const b=x?.data?.code;b==="UNAUTHORIZED"||b==="FORBIDDEN"?(localStorage.removeItem("camstack_admin_token"),dr()):n(m)}).finally(()=>s(!1))},[]);const l=U(async(f,m)=>{const g=await _s().login(f,m);if(g.requiresTotp===!0)return{kind:"totp-required",challengeToken:g.token};const x=g.token;return localStorage.setItem("camstack_admin_token",x),await fetch("/api/auth/session",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({token:x})}).catch(()=>{}),dr(),n($s(x)),i(m===r8),{kind:"ok"}},[]),c=U(async(f,m)=>{const x=(await _s().loginVerifyTotp(f,m)).token;localStorage.setItem("camstack_admin_token",x),await fetch("/api/auth/session",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({token:x})}).catch(()=>{}),dr(),n($s(x)),i(!1)},[]),d=U(()=>{localStorage.removeItem("camstack_admin_token"),fetch("/api/auth/session",{method:"DELETE"}).catch(()=>{}),dr(),n(null),i(!1)},[]),p=U(()=>{i(!1)},[]);return r(B0.Provider,{value:{user:t,loading:o,mustChangePassword:a,login:l,verifyTotp:c,logout:d,clearMustChangePassword:p},children:e})}function Xt(){const e=xe(B0);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}function Et({children:e,requireAdmin:t}){const{user:n,loading:o,mustChangePassword:s}=Xt(),a=xt();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(dt,{to:"/change-password",replace:!0}):t&&!n.isAdmin?r(dt,{to:"/access-denied",replace:!0}):r(ue,{children:e}):r(dt,{to:"/login",replace:!0})}var vi={};const Me=e=>typeof e=="string",Zr=()=>{let e,t;const n=new Promise((o,s)=>{e=o,t=s});return n.resolve=e,n.reject=t,n},mp=e=>e==null?"":""+e,s8=(e,t,n)=>{e.forEach(o=>{t[o]&&(n[o]=t[o])})},a8=/###/g,hp=e=>e&&e.indexOf("###")>-1?e.replace(a8,"."):e,gp=e=>!e||Me(e),po=(e,t,n)=>{const o=Me(t)?t.split("."):t;let s=0;for(;s<o.length-1;){if(gp(e))return{};const a=hp(o[s]);!e[a]&&n&&(e[a]=new n),Object.prototype.hasOwnProperty.call(e,a)?e=e[a]:e={},++s}return gp(e)?{}:{obj:e,k:hp(o[s])}},bp=(e,t,n)=>{const{obj:o,k:s}=po(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=po(e,i,Object);for(;l.obj===void 0&&i.length;)a=`${i[i.length-1]}.${a}`,i=i.slice(0,i.length-1),l=po(e,i,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},i8=(e,t,n,o)=>{const{obj:s,k:a}=po(e,t,Object);s[a]=s[a]||[],s[a].push(n)},Ws=(e,t)=>{const{obj:n,k:o}=po(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,o))return n[o]},l8=(e,t,n)=>{const o=Ws(e,n);return o!==void 0?o:Ws(t,n)},F0=(e,t,n)=>{for(const o in t)o!=="__proto__"&&o!=="constructor"&&(o in e?Me(e[o])||e[o]instanceof String||Me(t[o])||t[o]instanceof String?n&&(e[o]=t[o]):F0(e[o],t[o],n):e[o]=t[o]);return e},On=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var c8={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const d8=e=>Me(e)?e.replace(/[&<>"'\/]/g,t=>c8[t]):e;class u8{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 p8=[" ",",","?","!",";"],f8=new u8(20),m8=(e,t,n)=>{t=t||"",n=n||"";const o=p8.filter(i=>t.indexOf(i)<0&&n.indexOf(i)<0);if(o.length===0)return!0;const s=f8.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},Ml=(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},So=e=>e?.replace(/_/g,"-"),h8={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 Ys{constructor(t,n={}){this.init(t,n)}init(t,n={}){this.prefix=n.prefix||"i18next:",this.logger=t||h8,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:(Me(t[0])&&(t[0]=`${o}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new Ys(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Ys(this.logger,t)}}var Ut=new Ys;class Ra{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 xp extends Ra{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):Me(o)&&a?l.push(...o.split(a)):l.push(o)));const c=Ws(this.data,l);return!c&&!n&&!o&&t.indexOf(".")>-1&&(t=l[0],n=l[1],o=l.slice(2).join(".")),c||!i||!Me(o)?c:Ml(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),bp(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)(Me(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=Ws(this.data,l)||{};i.skipCopy||(o=JSON.parse(JSON.stringify(o))),s?F0(c,o,a):c={...c,...o},bp(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 j0={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 H0=Symbol("i18next/PATH_KEY");function g8(){const e=[],t=Object.create(null);let n;return t.get=(o,s)=>(n?.revoke?.(),s===H0?e:(e.push(s),n=Proxy.revocable(o,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function hr(e,t){const{[H0]:n}=e(g8()),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 yp={},wi=e=>!Me(e)&&typeof e!="boolean"&&typeof e!="number";class Zs extends Ra{constructor(t,n={}){super(),s8(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Ut.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=wi(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&&!m8(t,o,s);if(i&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:Me(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:Me(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=hr(t,{...this.options,...s})),Array.isArray(t)||(t=[String(t)]),t=t.map(R=>typeof R=="function"?hr(R,{...this.options,...s}):String(R));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 p=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;p===void 0&&(p=":");const f=s.lng||this.language,m=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return m?a?{res:`${d}${p}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:`${d}${p}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:l;const h=this.resolve(t,s);let g=h?.res;const x=h?.usedKey||l,b=h?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],w=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,N=s.count!==void 0&&!Me(s.count),k=Zs.hasDefaultValue(s),C=N?this.pluralResolver.getSuffix(f,s.count,s):"",D=s.ordinal&&N?this.pluralResolver.getSuffix(f,s.count,{ordinal:!1}):"",E=N&&!s.ordinal&&s.count===0,I=E&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${C}`]||s[`defaultValue${D}`]||s.defaultValue;let z=g;y&&!g&&k&&(z=I);const A=wi(z),T=Object.prototype.toString.apply(z);if(y&&z&&A&&v.indexOf(T)<0&&!(Me(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 R=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,z,{...s,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(h.res=R,h.usedParams=this.getUsedParamsDetails(s),h):R}if(i){const R=Array.isArray(z),M=R?[]:{},$=R?b:x;for(const L in z)if(Object.prototype.hasOwnProperty.call(z,L)){const O=`${$}${i}${L}`;k&&!g?M[L]=this.translate(O,{...s,defaultValue:wi(I)?I[L]:void 0,joinArrays:!1,ns:c}):M[L]=this.translate(O,{...s,joinArrays:!1,ns:c}),M[L]===O&&(M[L]=z[L])}g=M}}else if(y&&Me(w)&&Array.isArray(g))g=g.join(w),g&&(g=this.extendTranslation(g,t,s,o));else{let R=!1,M=!1;!this.isValidLookup(g)&&k&&(R=!0,g=I),this.isValidLookup(g)||(M=!0,g=l);const L=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&M?void 0:g,O=k&&I!==g&&this.options.updateMissing;if(M||R||O){if(this.logger.log(O?"updateKey":"missingKey",f,d,l,O?I: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 F=[];const B=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&B&&B[0])for(let H=0;H<B.length;H++)F.push(B[H]);else this.options.saveMissingTo==="all"?F=this.languageUtils.toResolveHierarchy(s.lng||this.language):F.push(s.lng||this.language);const j=(H,_,q)=>{const G=k&&q!==g?q:L;this.options.missingKeyHandler?this.options.missingKeyHandler(H,d,_,G,O,s):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(H,d,_,G,O,s),this.emit("missingKey",H,d,_,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?F.forEach(H=>{const _=this.pluralResolver.getSuffixes(H,s);E&&s[`defaultValue${this.options.pluralSeparator}zero`]&&_.indexOf(`${this.options.pluralSeparator}zero`)<0&&_.push(`${this.options.pluralSeparator}zero`),_.forEach(q=>{j([H],l+q,s[`defaultValue${q}`]||I)})}):j(F,l,I))}g=this.extendTranslation(g,t,s,h,o),M&&g===l&&this.options.appendNamespaceToMissingKey&&(g=`${d}${p}${l}`),(M||R)&&this.options.parseMissingKeyHandler&&(g=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${p}${l}`:l,R?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=Me(t)&&(o?.interpolation?.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(c){const f=t.match(this.interpolator.nestingRegexp);d=f&&f.length}let p=o.replace&&!Me(o.replace)?o.replace:o;if(this.options.interpolation.defaultVariables&&(p={...this.options.interpolation.defaultVariables,...p}),t=this.interpolator.interpolate(t,p,o.lng||this.language||s.usedLng,o),c){const f=t.match(this.interpolator.nestingRegexp),m=f&&f.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,(...f)=>a?.[0]===f[0]&&!o.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),o)),o.interpolation&&this.interpolator.reset()}const i=o.postProcess||this.options.postProcess,l=Me(i)?[i]:i;return t!=null&&l?.length&&o.applyPostProcessor!==!1&&(t=j0.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 Me(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(c=>typeof c=="function"?hr(c,{...this.options,...n}):c)),t.forEach(c=>{if(this.isValidLookup(o))return;const d=this.extractFromKey(c,n),p=d.key;s=p;let f=d.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const m=n.count!==void 0&&!Me(n.count),h=m&&!n.ordinal&&n.count===0,g=n.context!==void 0&&(Me(n.context)||typeof n.context=="number")&&n.context!=="",x=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(b=>{this.isValidLookup(o)||(l=b,!yp[`${x[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(yp[`${x[0]}-${b}`]=!0,this.logger.warn(`key "${s}" for languages "${x.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!!!")),x.forEach(v=>{if(this.isValidLookup(o))return;i=v;const w=[p];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(w,p,v,b,n);else{let N;m&&(N=this.pluralResolver.getSuffix(v,n.count,n));const k=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&N.indexOf(C)===0&&w.push(p+N.replace(C,this.options.pluralSeparator)),w.push(p+N),h&&w.push(p+k)),g){const D=`${p}${this.options.contextSeparator||"_"}${n.context}`;w.push(D),m&&(n.ordinal&&N.indexOf(C)===0&&w.push(D+N.replace(C,this.options.pluralSeparator)),w.push(D+N),h&&w.push(D+k))}}let y;for(;y=w.pop();)this.isValidLookup(o)||(a=y,o=this.getResource(v,b,y,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&&!Me(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 vp{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ut.create("languageUtils")}getScriptPartFromCode(t){if(t=So(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=So(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(Me(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)),Me(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 Me(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))):Me(t)&&a(this.formatLanguageCode(t)),o.forEach(i=>{s.indexOf(i)<0&&a(this.formatLanguageCode(i))}),s}}const wp={zero:0,one:1,two:2,few:3,many:4,other:5},Np={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class b8{constructor(t,n={}){this.languageUtils=t,this.options=n,this.logger=Ut.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,n={}){const o=So(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!"),Np;if(!t.match(/-|_/))return Np;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)=>wp[s]-wp[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 kp=(e,t,n,o=".",s=!0)=>{let a=l8(e,t,n);return!a&&s&&Me(n)&&(a=Ml(e,n,o),a===void 0&&(a=Ml(t,n,o))),a},Ni=e=>e.replace(/\$/g,"$$$$");class Sp{constructor(t={}){this.logger=Ut.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:p,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:h,nestingSuffix:g,nestingSuffixEscaped:x,nestingOptionsSeparator:b,maxReplaces:v,alwaysFormat:w}=t.interpolation;this.escape=n!==void 0?n:d8,this.escapeValue=o!==void 0?o:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=a?On(a):i||"{{",this.suffix=l?On(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=p?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=m?On(m):h||On("$t("),this.nestingSuffix=g?On(g):x||On(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=v||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 v=kp(n,c,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,o,{...s,...n,interpolationkey:h}):v}const g=h.split(this.formatSeparator),x=g.shift().trim(),b=g.join(this.formatSeparator).trim();return this.format(kp(n,c,x,this.options.keySeparator,this.options.ignoreJSONStructure),b,o,{...s,...n,interpolationkey:x})};this.resetRegExp();const p=s?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=s?.interpolation?.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>Ni(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?Ni(this.escape(h)):Ni(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 p=="function"){const b=p(t,a,s);i=Me(b)?b:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))i="";else if(f){i=a[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),i="";else!Me(i)&&!this.useRawValueToEscape&&(i=mp(i));const x=h.safeValue(i);if(t=t.replace(a[0],x),f?(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 p=this.nestingOptionsSeparator;if(c.indexOf(p)<0)return c;const f=c.split(new RegExp(`${On(p)}[ ]*{`));let m=`{${f[1]}`;c=f[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(x){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,x),`${c}${p}${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&&!Me(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(p=>p.trim()).filter(Boolean),s[1]=s[1].slice(0,d)),a=n(l.call(this,s[1].trim(),i),i),a&&s[0]===t&&!Me(a))return a;Me(a)||(a=mp(a)),a||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),a=""),c.length&&(a=c.reduce((p,f)=>this.format(p,f,o.lng,{...o,interpolationkey:s[1].trim()}),a.trim())),t=t.replace(s[0],a),this.regexp.lastIndex=0}return t}}const x8=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,""),p=l.trim();n[p]||(n[p]=d),d==="false"&&(n[p]=!1),d==="true"&&(n[p]=!0),isNaN(d)||(n[p]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},Cp=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(So(o),s),t[i]=l),l(n)}},y8=e=>(t,n,o)=>e(So(n),o)(t);class v8{constructor(t={}){this.logger=Ut.create("formatter"),this.options=t,this.init(t)}init(t,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const o=n.cacheInBuiltFormats?Cp:y8;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()]=Cp(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:p}=x8(c);if(this.formats[d]){let f=l;try{const m=s?.formatParams?.[s.interpolationkey]||{},h=m.locale||m.lng||s.locale||s.lng||o;f=this.formats[d](l,h,{...p,...s,...m})}catch(m){this.logger.warn(m)}return f}else this.logger.warn(`there was no format function for ${d}`);return l},t)}}const w8=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class N8 extends Ra{constructor(t,n,o,s={}){super(),this.backend=t,this.store=n,this.services=o,this.languageUtils=o.languageUtils,this.options=s,this.logger=Ut.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 p=!0;n.forEach(f=>{const m=`${d}|${f}`;!o.reload&&this.store.hasResourceBundle(d,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?i[m]===void 0&&(i[m]=!0):(this.state[m]=1,p=!1,i[m]===void 0&&(i[m]=!0),a[m]===void 0&&(a[m]=!0),c[f]===void 0&&(c[f]=!0)))}),p||(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=>{i8(c.loaded,[a],i),w8(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(d=>{l[d]||(l[d]={});const p=c.loaded[d];p.length&&p.forEach(f=>{l[d][f]===void 0&&(l[d][f]=!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,p)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(d&&p&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,o,s+1,a*2,i)},a);return}i(d,p)},c=this.backend[o].bind(this.backend);if(c.length===2){try{const d=c(t,n);d&&typeof d.then=="function"?d.then(p=>l(null,p)).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();Me(t)&&(t=this.languageUtils.toResolveHierarchy(t)),Me(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 p;d.length===5?p=d(t,n,o,s,c):p=d(t,n,o,s),p&&typeof p.then=="function"?p.then(f=>l(null,f)).catch(l):l(null,p)}catch(p){l(p)}else d(t,n,o,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,o,s)}}}const ki=()=>({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]),Me(e[1])&&(t.defaultValue=e[1]),Me(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}),Mp=e=>(Me(e.ns)&&(e.ns=[e.ns]),Me(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),Me(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),cs=()=>{},k8=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})},V0="__i18next_supportNoticeShown",S8=()=>!!(typeof globalThis<"u"&&globalThis[V0]||typeof process<"u"&&vi&&vi.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&vi),C8=()=>{typeof globalThis<"u"&&(globalThis[V0]=!0)},M8=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 fo extends Ra{constructor(t={},n){if(super(),this.options=Mp(t),this.services={},this.logger=Ut,this.modules={external:[]},k8(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&&(Me(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const o=ki();this.options={...o,...this.options,...Mp(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&&!M8(this)&&!S8()&&(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 💙"),C8());const s=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Ut.init(s(this.modules.logger),this.options):Ut.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=v8;const p=new vp(this.options);this.store=new xp(this.options.resources,this.options);const f=this.services;f.logger=Ut,f.resourceStore=this.store,f.languageUtils=p,f.pluralResolver=new b8(p,{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)&&(f.formatter=s(d),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Sp(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new N8(s(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(h,...g)=>{this.emit(h,...g)}),this.modules.languageDetector&&(f.languageDetector=s(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=s(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new Zs(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=cs),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]=(...p)=>this.store[d](...p)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=(...p)=>(this.store[d](...p),this)});const l=Zr(),c=()=>{const d=(p,f)=>{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(f),n(p,f)};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=cs){let o=n;const s=Me(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=Zr();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=cs),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"&&j0.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=Zr();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=Me(l)?l:l&&l[0],d=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(Me(l)?[l]:l);d&&(this.language||s(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector?.cacheUserLanguage?.(d)),this.loadResources(d,p=>{a(p,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=hr(c.keyPrefix,d));const p=this.options.keySeparator||".";let f;return c.keyPrefix&&Array.isArray(a)?f=a.map(m=>(typeof m=="function"&&(m=hr(m,d)),`${c.keyPrefix}${p}${m}`)):(typeof a=="function"&&(a=hr(a,d)),f=c.keyPrefix?`${c.keyPrefix}${p}${a}`:a),this.t(f,c)};return Me(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=Zr();return this.options.ns?(Me(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=Zr();Me(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 vp(ki());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 fo(t,n);return o.createInstance=fo.createInstance,o}cloneInstance(t={},n=cs){const o=t.forkResourceStore;o&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},a=new fo(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((p,f)=>(p[f]={...c[d][f]},p),c[d]),c),{});a.store=new xp(l,s),a.services.resourceStore=a.store}if(t.interpolation){const c={...ki().interpolation,...this.options.interpolation,...t.interpolation},d={...s,interpolation:c};a.services.interpolator=new Sp(d)}return a.translator=new Zs(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 nt=fo.createInstance();nt.createInstance;nt.dir;nt.init;nt.loadResources;nt.reloadResources;nt.use;nt.changeLanguage;nt.getFixedT;nt.t;nt.exists;nt.setDefaultNamespace;nt.hasLoadedNamespace;nt.loadNamespaces;nt.loadLanguages;const A8=(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);Kn(s[0])&&(s[0]=`react-i18next:: ${s[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...s):console?.warn&&console.warn(...s)},Ap={},Al=(e,t,n,o)=>{Kn(n)&&Ap[n]||(Kn(n)&&(Ap[n]=new Date),A8(e,t,n,o))},U0=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}},El=(e,t,n)=>{e.loadNamespaces(t,U0(e,n))},Ep=(e,t,n,o)=>{if(Kn(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return El(e,n,o);n.forEach(s=>{e.options.ns.indexOf(s)<0&&e.options.ns.push(s)}),e.loadLanguages(t,U0(e,o))},E8=(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}}),Kn=e=>typeof e=="string",I8=e=>typeof e=="object"&&e!==null,P8=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,_8={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},$8=e=>_8[e],D8=e=>e.replace(P8,$8);let Il={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:D8,transDefaultProps:void 0};const L8=(e={})=>{Il={...Il,...e}},T8=()=>Il;let q0;const R8=e=>{q0=e},O8=()=>q0,z8={type:"3rdParty",init(e){L8(e.options.react),R8(e)}},B8=je();class F8{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var Q0={exports:{}},G0={};/**
|
|
1128
|
+
* @license React
|
|
1129
|
+
* use-sync-external-store-shim.production.js
|
|
1130
|
+
*
|
|
1131
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1132
|
+
*
|
|
1133
|
+
* This source code is licensed under the MIT license found in the
|
|
1134
|
+
* LICENSE file in the root directory of this source tree.
|
|
1135
|
+
*/var Cr=Im;function j8(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var H8=typeof Object.is=="function"?Object.is:j8,V8=Cr.useState,U8=Cr.useEffect,q8=Cr.useLayoutEffect,Q8=Cr.useDebugValue;function G8(e,t){var n=t(),o=V8({inst:{value:n,getSnapshot:t}}),s=o[0].inst,a=o[1];return q8(function(){s.value=n,s.getSnapshot=t,Si(s)&&a({inst:s})},[e,n,t]),U8(function(){return Si(s)&&a({inst:s}),e(function(){Si(s)&&a({inst:s})})},[e]),Q8(n),n}function Si(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!H8(e,n)}catch{return!0}}function K8(e,t){return t()}var W8=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?K8:G8;G0.useSyncExternalStore=Cr.useSyncExternalStore!==void 0?Cr.useSyncExternalStore:W8;Q0.exports=G0;var K0=Q0.exports;const Y8=(e,t)=>{if(Kn(t))return t;if(I8(t)&&Kn(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},Z8={t:Y8,ready:!1},X8=()=>()=>{},Bt=(e,t={})=>{const{i18n:n}=t,{i18n:o,defaultNS:s}=xe(B8)||{},a=n||o||O8();a&&!a.reportNamespaces&&(a.reportNamespaces=new F8),a||Al(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const i=V(()=>({...T8(),...a?.options?.react,...t}),[a,t]),{useSuspense:l,keyPrefix:c}=i,d=s||a?.options?.defaultNS,p=Kn(d)?[d]:d||["translation"],f=V(()=>p,p);a?.reportNamespaces?.addUsedNamespaces?.(f);const m=re(0),h=U(I=>{if(!a)return X8;const{bindI18n:z,bindI18nStore:A}=i,T=()=>{m.current+=1,I()};return z&&a.on(z,T),A&&a.store.on(A,T),()=>{z&&z.split(" ").forEach(R=>a.off(R,T)),A&&A.split(" ").forEach(R=>a.store.off(R,T))}},[a,i]),g=re(),x=U(()=>{if(!a)return Z8;const I=!!(a.isInitialized||a.initializedStoreOnce)&&f.every($=>E8($,a,i)),z=t.lng||a.language,A=m.current,T=g.current;if(T&&T.ready===I&&T.lng===z&&T.keyPrefix===c&&T.revision===A)return T;const M={t:a.getFixedT(z,i.nsMode==="fallback"?f:f[0],c),ready:I,lng:z,keyPrefix:c,revision:A};return g.current=M,M},[a,f,c,i,t.lng]),[b,v]=P(0),{t:w,ready:y}=K0.useSyncExternalStore(h,x,x);Y(()=>{if(a&&!y&&!l){const I=()=>v(z=>z+1);t.lng?Ep(a,t.lng,f,I):El(a,f,I)}},[a,t.lng,f,y,l,b]);const N=a||{},k=re(null),C=re(),D=I=>{const z=Object.getOwnPropertyDescriptors(I);z.__original&&delete z.__original;const A=Object.create(Object.getPrototypeOf(I),z);if(!Object.prototype.hasOwnProperty.call(A,"__original"))try{Object.defineProperty(A,"__original",{value:I,writable:!1,enumerable:!1,configurable:!1})}catch{}return A},E=V(()=>{const I=N,z=I?.language;let A=I;I&&(k.current&&k.current.__original===I?C.current!==z?(A=D(I),k.current=A,C.current=z):A=k.current:(A=D(I),k.current=A,C.current=z));const T=!y&&!l?(...M)=>(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(...M)):w,R=[T,A,y];return R.t=T,R.i18n=A,R.ready=y,R},[w,N,y,N.resolvedLanguage,N.language,N.languages]);if(a&&l&&!y)throw new Promise(I=>{const z=()=>I();t.lng?Ep(a,t.lng,f,z):El(a,f,z)});return E},Ip={info:Gn,success:kd,warning:at,error:kr},J8={info:"text-blue-400",success:"text-green-400",warning:"text-amber-400",error:"text-red-400"},Pp={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 e7(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 _p({alert:e,onMarkRead:t,onDismiss:n}){const o=e.severity in Ip?e.severity:"info",s=e.status in Pp?e.status:"active",a=Ip[o],i=J8[o],l=Pp[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:e7(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(At,{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(Be,{className:"h-3 w-3 text-foreground-subtle"})})]})]})}function $p({variant:e="icon",compact:t=!1}={}){const[n,o]=P(!1),[s,a]=P(!1),i=re(null),l=re(null),c=we(),{data:d=0}=Hg(void 0,{staleTime:1e4,refetchInterval:3e4}),{data:p=[],isLoading:f}=jg({limit:50},{enabled:n,staleTime:5e3}),m=s?p:p.filter(I=>!I.read),h=p.filter(I=>I.read).length,g=()=>{c.invalidateQueries({queryKey:[["alerts"]]})},x=Vg({onSuccess:g}),b=Ug({onSuccess:g}),v=qg({onSuccess:g});ht("alert.created",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),ht("alert.updated",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),Y(()=>{if(!n)return;const I=z=>{const A=z.target;i.current&&!i.current.contains(A)&&l.current&&!l.current.contains(A)&&o(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[n]);const w=U(I=>{x.mutate({alertId:I})},[x]),y=U(I=>{I&&v.mutate({alertId:I})},[v]),N=U(()=>{b.mutate(void 0),o(!1)},[b]),k=m.filter(I=>I.status==="in-progress"),C=m.filter(I=>I.status!=="in-progress"),[D,E]=P({});return Y(()=>{if(n&&l.current){const I=l.current.getBoundingClientRect();E({position:"fixed",left:I.left,bottom:window.innerHeight-I.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(vt,{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(vt,{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&&To(u("div",{ref:i,style:D,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:I=>a(I.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(wR,{className:"h-3 w-3"}),"Mark all read"]})]})]}),u("div",{className:"flex-1 overflow-y-auto",children:[f&&r("div",{className:"flex items-center justify-center py-8",children:r(Se,{className:"h-4 w-4 animate-spin text-foreground-subtle"})}),!f&&m.length===0&&u("div",{className:"flex flex-col items-center justify-center py-8 text-foreground-subtle",children:[r(vt,{className:"h-6 w-6 mb-2 opacity-40"}),r("span",{className:"text-[11px]",children:p.length>0?"No unread alerts":"No alerts"}),p.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(I=>r(_p,{alert:I,onMarkRead:w,onDismiss:y},I.id))]}),C.map(I=>r(_p,{alert:I,onMarkRead:w,onDismiss:y},I.id))]})]}),document.body)]})}function W0(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 Dp=new Map,ds=new Map,Lp=new Set;function t7(e){return!e||typeof e!="object"?!1:typeof e.default=="function"}async function n7(e,t){const n=Dp.get(e);if(n)return n;const o=ds.get(e);if(o)return o;Lp.has(e)||(sc(),xr.registerRemotes([{name:e,entry:t,type:"module"}],{force:!1}),Lp.add(e));const s=xr.loadRemote(`${e}/page`).then(a=>{if(!t7(a))throw new Error(`Addon page remote ${e} (${t}) does not expose a default React component on './page'`);return Dp.set(e,a.default),ds.delete(e),a.default}).catch(a=>{throw ds.delete(e),a});return ds.set(e,s),s}function r7(){const{pagePath:e}=fd(),t=Le(),{data:n}=Lc(void 0,{staleTime:6e4}),o=V(()=>n?W0(n):void 0,[n]),s=o?.find(d=>d.path===`/addon/${e}`),[a,i]=P(null),[l,c]=P(null);return Y(()=>{if(!s)return;c(null),i(null);let d=!1;return n7(s.remoteName,s.bundleUrl).then(p=>{d||i(()=>p)}).catch(p=>{if(d)return;const f=p instanceof Error?p.message:String(p);c(`Failed to load addon page: ${f}`)}),()=>{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 o7={dark:I0,light:vO,system:_6},s7={gauge:WR,puzzle:Ks,bot:pR,cpu:Ot,terminal:R0,box:wd,wrench:LO,activity:Pa,plug:ko};function a7(){const e=xt(),t=rt(),{user:n,logout:o}=Xt(),s=Ro(),{t:a}=Bt(),i=nr(),l=zh(),c=WT(),d=c!=="connected",p=c==="connecting",[f,m]=P(!1),[h,g]=P(()=>typeof window>"u"?!1:window.localStorage.getItem("camstack:sidebar-collapsed")==="1");Y(()=>{typeof window>"u"||window.localStorage.setItem("camstack:sidebar-collapsed",h?"1":"0")},[h]);const[x,b]=P(()=>{if(typeof window>"u")return new Set;try{const _=window.localStorage.getItem("camstack:sidebar-collapsed-groups");if(!_)return new Set;const q=JSON.parse(_);return Array.isArray(q)?new Set(q.filter(G=>typeof G=="string")):new Set}catch{return new Set}});Y(()=>{typeof window>"u"||window.localStorage.setItem("camstack:sidebar-collapsed-groups",JSON.stringify([...x]))},[x]),Y(()=>{l&&window.localStorage.getItem("camstack:sidebar-collapsed")===null&&g(!0)},[l]);const{data:v=[]}=Rc({nodeId:"hub"},{staleTime:3e4,refetchInterval:3e4}),w=v.length,y=we(),N=re(Date.now()),k=3e4,C=2e3,{data:D}=Lc(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:_=>{const q=_.state.data;return q&&q.length>0||Date.now()-N.current>=k?!1:C}}),E=V(()=>D&&n?.isAdmin?W0(D):[],[D,n?.isAdmin]);ht("addon.page-ready",()=>{y.invalidateQueries({queryKey:[["addonPages","listPages"]]})});const I=()=>{o(),t("/login")},z=_=>!!(e.pathname===_||e.pathname.startsWith(_+"/")),T=["/pipeline","/timeline"].some(_=>e.pathname===_||e.pathname.startsWith(_+"/")),R=n?.isAdmin===!0,M=[{label:a("nav.devices","Devices"),icon:Nr,path:"/devices"},{label:a("nav.integrations"),icon:ko,path:"/integrations"},{label:a("nav.timeline","Timeline"),icon:TR,path:"/timeline"},{label:a("nav.pipeline","Pipeline"),icon:XR,path:"/pipeline"}].filter(Boolean),L=[{label:a("system.identity","Identity & Access"),icon:Cd,path:"/system/identity",adminOnly:!0},{label:a("system.network","Network"),icon:Cn,path:"/system/network",adminOnly:!0},{label:a("system.integrations","Integrations"),icon:ko,path:"/system/integrations",adminOnly:!0},{label:a("system.data","Data"),icon:k0,path:"/system/data",adminOnly:!0},{label:a("system.cluster","Cluster"),icon:Mn,path:"/system/cluster",adminOnly:!0},{label:a("system.addons"),icon:Ks,path:"/system/addons",adminOnly:!0},{label:a("system.addonSettings","Addon Settings"),icon:Wt,path:"/system/settings",adminOnly:!0},{label:a("system.logs","Logs"),icon:vt,path:"/system/logs",adminOnly:!0}].filter(_=>!_.adminOnly||R),O=s?.mode??"system",F={dark:a("theme.dark"),light:a("theme.light"),system:a("theme.system")},B=h&&!i,j=(_,q="md")=>`flex w-full items-center gap-2.5 rounded-md ${B?"justify-center px-0 py-2":"px-2.5 py-1.5"} ${q==="lg"?"text-[13px] font-medium":"text-[12px]"} transition-all ${_?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(ue,{children:[u("div",{className:`flex h-14 items-center border-b border-border ${B?"justify-center px-1":"pl-3 pr-4 gap-2"}`,children:[!B&&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"}),!i&&r("button",{onClick:()=>g(_=>!_),className:`p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle transition-colors flex-shrink-0 ${B?"":"mr-2"}`,"aria-label":h?"Expand sidebar":"Collapse sidebar",title:h?"Expand sidebar":"Collapse sidebar",children:h?r(zt,{className:"h-4 w-4"}):r(Nd,{className:"h-4 w-4"})})]}),u("nav",{className:`flex-1 overflow-y-auto py-3 ${B?"px-1.5":"px-2"} space-y-0.5`,children:[(()=>{const _=z("/dashboard");return u("button",{"data-testid":"nav-dashboard",onClick:()=>{t("/dashboard"),m(!1)},className:j(_,"lg"),title:B?a("nav.dashboard"):void 0,children:[r(M0,{className:`h-4 w-4 shrink-0 ${_?"text-primary":""}`}),!B&&a("nav.dashboard")]})})(),!B&&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")})}),B&&r("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),M.map(_=>{const q=_.icon,G=z(_.path),Q=`nav-${_.path.replace(/^\//,"").replace(/\//g,"-")}`;return u("button",{"data-testid":Q,onClick:()=>{t(_.path),m(!1)},className:j(G),title:B?_.label:void 0,children:[r(q,{className:`h-3.5 w-3.5 shrink-0 ${G?"text-primary":""}`}),!B&&_.label]},_.path)}),!B&&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")})}),B&&r("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),L.map(_=>{const q=_.icon,G=z(_.path),Q=_.path==="/system/addons",J=`nav-${_.path.replace(/^\//,"").replace(/\//g,"-")}`;return u("button",{"data-testid":J,onClick:()=>{t(_.path),m(!1)},className:j(G),title:B?_.label:void 0,children:[r(q,{className:`h-3.5 w-3.5 shrink-0 ${G?"text-primary":""}`}),!B&&u(ue,{children:[r("span",{className:"flex-1 text-left",children:_.label}),Q&&w>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:w})]}),B&&Q&&w>0&&r("span",{className:"absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary"})]},_.path)}),E&&E.length>0&&!B&&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")})}),B&&E&&E.length>0&&r("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),E?.map(_=>{const q=z(_.path),G=s7[_.icon]??Ks;return u("button",{onClick:()=>{t(_.path),m(!1)},className:j(q),title:B?_.label:void 0,children:[r(G,{className:`h-3.5 w-3.5 shrink-0 ${q?"text-primary":""}`}),!B&&_.label]},_.id)})]}),u("div",{className:`border-t border-border ${B?"p-1.5":"p-2"} space-y-0.5`,children:[u("button",{onClick:()=>s?.toggleMode(),className:j(!1),title:B?F[O]:void 0,children:[(()=>{const _=o7[O];return r(_,{className:"h-3.5 w-3.5 shrink-0"})})(),!B&&r("span",{children:F[O]})]}),r($p,{variant:"sidebar",compact:B}),u("button",{type:"button",onClick:()=>t("/system/my-access"),className:j(z("/system/my-access")),title:B?a("system.myAccess","My access"):void 0,children:[r(un,{className:"h-3.5 w-3.5 shrink-0"}),!B&&r("span",{className:"truncate",children:a("system.myAccess","My access")})]}),u("button",{onClick:I,className:j(!1).replace("hover:text-foreground","hover:text-danger"),title:B?n?.username??"Logout":void 0,children:[r(Md,{className:"h-3.5 w-3.5 shrink-0"}),!B&&r("span",{className:"truncate",children:n?.username??"User"})]})]})]});return u("div",{className:"flex h-screen bg-background text-foreground",children:[!i&&r("aside",{className:`flex flex-col border-r border-border bg-surface/80 backdrop-blur-sm shrink-0 transition-[width] duration-150 ease-out ${B?"w-12":"w-48"}`,children:H}),i&&r(vc,{open:f,onClose:()=>m(!1),width:"w-64",children:H}),u("div",{className:"flex flex-1 flex-col min-w-0",children:[d&&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(z0,{className:"h-3.5 w-3.5"}),r("span",{children:p?a("connection.reconnecting","Reconnecting…"):a("connection.disconnected","Server unreachable — reconnecting…")}),r(Se,{className:"h-3.5 w-3.5 animate-spin"})]}),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:()=>m(!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(M6,{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($p,{})]}),r("main",{className:`relative flex-1 min-h-0 bg-background ${T?"overflow-hidden":"overflow-auto"}`,children:r(iT,{})})]})]})}function i7(){const{login:e,verifyTotp:t}=Xt(),n=Ro(),o=rt(),s=new URLSearchParams(window.location.search).get("next"),[a,i]=P(""),[l,c]=P(""),[d,p]=P(!1),[f,m]=P(""),[h,g]=P(!1),[x,b]=P("credentials"),[v,w]=P(""),[y,N]=P(""),k=async E=>{E.preventDefault(),m(""),g(!0);try{const I=await e(a,l);if(I.kind==="totp-required"){w(I.challengeToken),b("totp");return}l==="changeme"?o("/change-password",{replace:!0}):s?window.location.assign(s):o("/dashboard",{replace:!0})}catch(I){m(I instanceof Error?I.message:"Login failed")}finally{g(!1)}},C=async E=>{E.preventDefault(),m(""),g(!0);try{await t(v,y.trim()),s?window.location.assign(s):o("/dashboard",{replace:!0})}catch(I){m(I instanceof Error?I.message:"TOTP verification failed"),N("")}finally{g(!1)}},D=()=>{b("credentials"),w(""),N(""),m("")};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:n?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack Admin",className:"h-12"})}),x==="credentials"?u("form",{onSubmit:k,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[f&&r("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:f}),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:a,onChange:E=>i(E.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:d?"text":"password",placeholder:"Password",value:l,onChange:E=>c(E.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:()=>p(!d),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors",tabIndex:-1,children:d?r(S0,{className:"h-4 w-4"}):r($a,{className:"h-4 w-4"})})]})]}),r("button",{"data-testid":"login-submit",type:"submit",disabled:h||!a||!l,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:h?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"})]}):u("form",{onSubmit:C,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[u("div",{className:"flex items-center gap-2 pb-1 border-b border-border",children:[r(kn,{className:"h-4 w-4 text-primary"}),r("div",{className:"text-sm font-medium text-foreground",children:"Two-factor authentication"})]}),u("p",{className:"text-xs text-foreground-subtle",children:["Enter the 6-digit code from your authenticator app to finish signing in as"," ",r("span",{className:"font-mono text-foreground",children:a}),"."]}),f&&r("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:f}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Authentication code"}),r("input",{"data-testid":"login-totp",type:"text",inputMode:"numeric",autoComplete:"one-time-code",placeholder:"123456",value:y,onChange:E=>N(E.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full rounded-lg border border-border bg-background px-3 py-3 text-center text-2xl font-mono tracking-widest text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all",autoFocus:!0})]}),r("button",{"data-testid":"login-totp-submit",type:"submit",disabled:h||y.length!==6,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:h?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"}),"Verifying..."]}):"Verify and sign in"}),u("button",{type:"button",onClick:D,className:"w-full flex items-center justify-center gap-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors",children:[r(vd,{className:"h-3 w-3"}),"Back to username + password"]})]}),x==="credentials"&&r(l7,{}),r("p",{className:"mt-6 text-center text-[10px] text-foreground-subtle/50",children:"CamStack v0.1.0"})]})})}function l7(){const t=(S.auth.listProviders.useQuery().data??[]).filter(n=>n.flowType==="redirect");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.id)}/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(un,{className:"h-4 w-4 text-primary"}),n.name]},n.id))})]})}const Tp=8;function c7(){const{user:e,mustChangePassword:t,clearMustChangePassword:n,logout:o}=Xt(),s=Ro(),a=rt(),[i,l]=P(""),[c,d]=P(""),[p,f]=P(!1),[m,h]=P(""),g=Xc({onSuccess:()=>{n(),a("/dashboard",{replace:!0})},onError:b=>{h(b instanceof Error?b.message:"Could not change password")}}),x=async b=>{if(b.preventDefault(),h(""),!e){h("Not signed in");return}if(i.length<Tp){h(`Password must be at least ${Tp} 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:x,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:p?"text":"password",value:i,onChange:b=>l(b.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:()=>f(!p),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors",tabIndex:-1,children:p?r(S0,{className:"h-4 w-4"}):r($a,{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:p?"text":"password",value:c,onChange:b=>d(b.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 d7(){const e=rt();return u("div",{className:"flex flex-col items-center justify-center text-foreground py-16 px-4",children:[r("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-danger/10 mb-4",children:r(cO,{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 Y0="camstack:dashboard-layout",Ci={version:1,widgets:[]};function u7(){try{const e=localStorage.getItem(Y0);if(!e)return Ci;const t=JSON.parse(e);return t&&t.version===1&&Array.isArray(t.widgets)?{version:1,widgets:t.widgets}:Ci}catch{return Ci}}function p7(e){try{localStorage.setItem(Y0,JSON.stringify(e))}catch{}}function f7(){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 m7(){const[e,t]=P(u7),[n,o]=P(!1),s=iy(),a=V(()=>s.filter(d=>d.hosts.includes("dashboard")),[s]),i=U(d=>{t(d),p7(d)},[]),l=U(d=>{i({version:1,widgets:[...e.widgets,d]})},[e,i]),c=U(d=>{i({version:1,widgets:e.widgets.filter(p=>p.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(kt,{className:"h-3.5 w-3.5"}),"Add widget"]})]}),e.widgets.length===0?r(h7,{onAdd:()=>o(!0)}):r("div",{className:"grid grid-cols-12 gap-3 auto-rows-[minmax(80px,_auto)]",children:e.widgets.map(d=>r(g7,{entry:d,onRemove:()=>c(d.instanceId)},d.instanceId))}),n&&r(x7,{widgets:a,onClose:()=>o(!1),onAdd:d=>{l(d),o(!1)}})]})}function h7({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(M0,{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(kt,{className:"h-3.5 w-3.5"}),"Add your first widget"]})]})}function g7({entry:e,onRemove:t}){const n=b7(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(Be,{className:"h-3 w-3"})}),r("div",{className:"flex-1 min-h-0 overflow-auto p-2",children:r(wr,{widgetId:e.widgetId,host:"dashboard",instanceId:e.instanceId,config:e.config,deviceId:e.deviceId,size:e.size,columns:e.columns,rows:e.rows})})]})}function b7(e){return!Number.isFinite(e)||e<1?6:Math.min(12,Math.floor(e))}function x7({widgets:e,onClose:t,onAdd:n}){const[o,s]=P(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(Be,{className:"h-4 w-4"})})]}),o===null?r(y7,{widgets:e,onSelect:s}):r(v7,{widget:o,onCancel:()=>s(null),onAdd:n})]})})}function y7({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 v7({widget:e,onCancel:t,onAdd:n}){const[o,s]=P(e.defaultSize),[a,i]=P(e.defaultColumns),[l,c]=P(e.defaultRows),[d,p]=P(null),{data:f}=$n({},{enabled:e.requires.deviceContext,staleTime:3e4}),m=!e.requires.deviceContext||d!==null&&d>0,h=()=>{if(!m)return;const g={instanceId:f7(),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(Rp,{label:"Columns (1-12)",value:a,min:1,max:12,onChange:i}),r(Rp,{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=>p(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 —"}),(f??[]).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 Rp({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 w7(){return r(m7,{})}function Qt(e,t){const n=Le(),o=we(),[s,a]=P(n.connectionVersion);Y(()=>n.subscribeConnectionEvents((c,d)=>{c==="connected"&&a(d)}),[n]);const i=t.join("|"),l=JSON.stringify(e);Y(()=>{const c=[],d=()=>{const p=JSON.parse(l),m=p.length===1&&Array.isArray(p[0])?p:[p];o.invalidateQueries({queryKey:m})};d();for(const p of i.split("|"))if(p)try{c.push(n.subscribeEvent(p,d))}catch{}return()=>{for(const p of c)p()}},[n,o,i,l,s])}const N7={frigate:{icon:w0,color:"#3b82f6",label:"Frigate"},scrypted:{icon:An,color:"#a855f7",label:"Scrypted"},reolink:{icon:La,color:"#06b6d4",label:"Reolink"},homeassistant:{icon:n6,color:"#22d3ee",label:"Home Assistant"},rtsp:{icon:Sr,color:"#78716c",label:"RTSP"},onvif:{icon:Sr,color:"#78716c",label:"ONVIF"}},Op={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"},k7={sm:"h-7 w-7",md:"h-8 w-8",lg:"h-10 w-10"};function Z0(e){const t=e.toLowerCase();return t.startsWith("provider-")?t.slice(9):t}function S7(e){const t=Z0(e);return N7[t]??{icon:w0,color:"#78716c",label:e}}function C7(e){const t=Z0(e);return`/api/addon-assets/${e.toLowerCase().startsWith("provider-")?e:`provider-${t}`}/assets/icon.svg`}function pn({type:e,size:t="md",showLabel:n}){const o=S7(e),s=o.icon,[a,i]=P(!1),l=C7(e);return u("div",{className:"flex items-center gap-2",children:[r("div",{className:`flex items-center justify-center rounded-lg ${k7[t]}`,style:{backgroundColor:`${o.color}15`},children:a?r(s,{className:Op[t],style:{color:o.color}}):r("img",{src:l,alt:o.label,className:Op[t],onError:()=>i(!0)})}),n&&r("span",{className:"text-xs font-medium text-foreground-subtle",children:o.label})]})}function tt({icon:e,title:t,subtitle:n,actions:o,children:s}){const a=!!t||n!=null||o!=null;return u("div",{className:"p-4 space-y-4",children:[a&&u("div",{className:"flex items-center justify-between gap-4",children:[u("div",{className:"min-w-0",children:[t&&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 zp=["camera","hub","nvr","light","siren","switch","sensor","thermostat","button","generic"];function M7(){const{t:e}=Bt(),t=rt(),n=Le();Qt(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]),Qt(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped"]);const{data:o}=$n({},{staleTime:3e4}),{data:s}=Uc(void 0,{staleTime:3e4}),a=V(()=>o??[],[o]),{activeDevices:i,orphanDevices:l}=V(()=>{const h=new Set((s??[]).map(k=>k.addonId)),g=k=>typeof k.addonId=="string"&&k.addonId.length>0&&!h.has(k.addonId),x=new Set;for(const k of a)g(k)&&x.add(k.id);const b=new Set(x),v=new Map;for(const k of a)v.set(k.id,k);const w=(k,C=0)=>{if(C>32)return!1;if(x.has(k.id))return!0;if(k.parentDeviceId==null)return!1;const D=v.get(k.parentDeviceId);return D?w(D,C+1):!1};for(const k of a)w(k)&&b.add(k.id);const y=[],N=[];for(const k of a)b.has(k.id)?N.push(k):y.push(k);return{activeDevices:y,orphanDevices:N}},[a,s]),c=V(()=>{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=U(h=>c.get(h)??null,[c]),p=V(()=>(s??[]).map(h=>({id:h.addonId,name:h.name??h.addonId,icon:r(pn,{type:h.addonId,size:"sm"})})),[s]),f=U(h=>r(pn,{type:h,size:"sm"}),[]),m=U(h=>t(`/devices/${String(h)}`),[t]);return u(tt,{icon:Nr,title:e("nav.devices","Devices"),children:[r(wo,{devices:i,trpc:n.trpcClient,filters:{types:zp,addons:p},resolveIntegrationIcon:f,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(at,{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(wo,{devices:l,trpc:n.trpcClient,filters:{types:zp,addons:p},urlScope:"nested",lsKey:"devices:orphan",resolveIntegrationIcon:f,resolveParent:d,onNavigate:m})]})]})]})}function A7({onSelect:e,onClose:t,pendingAddonId:n=null}){const{t:o}=Bt(),s=rt(),{data:a,isLoading:i}=Cb();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,p=n===c.addonId,f=l;return u("button",{disabled:f,onClick:()=>{if(!f)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})]}),p?r(Se,{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(Wt,{className:"h-3 w-3"}),o("integrations.manage")]}):r(zt,{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 E7(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Bp(e,t){if(e!==void 0)return t&&E7(e)?t(e):e}function I7({section:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i,onAction:l}){const[c,d]=P(e.defaultCollapsed??!1),p=e.style==="accordion";if(e.fields.reduce((b,v)=>b+(od(v,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",x=e.fields.length===1&&e.fields[0]?.type==="widget"||!e.title&&!e.description;return u("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[!x&&u("div",{className:["flex items-center justify-between mb-2",p?"cursor-pointer":""].join(" "),onClick:p?()=>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:Bp(e.title,s)}),e.description&&r("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:Bp(e.description,s)})]}),p&&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(or,{field:b,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i?.[b.key],allFields:e.fields,onAction:l},b.key))})]})}function En({schema:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i,onClearProbe:l,onAction:c}){const d=(p,f)=>{n({...t,[p]:f}),l?.(p)};return r("div",{className:"space-y-4",children:e.sections.map((p,f)=>r(I7,{section:p,values:t,onChange:d,disabled:o,translationFn:s,onTestField:a,probeResults:i,onAction:c},`${p.id}-${f}`))})}function P7({addonId:e,configSchema:t,onSave:n,onBack:o}){const{t:s}=Bt(),[a,i]=P(""),[l,c]=P({}),[d,p]=P(null),f=Mb({onSuccess:m=>p(m),onError:m=>p({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(En,{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:()=>f.mutate({addonId:e,settings:l}),disabled:f.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:f.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 _7({providerId:e,onImport:t,onSkip:n}){const{t:o}=Bt(),[s,a]=P(new Set),i=Hc(),l=i.data,c=i.isPending||!i.data&&!i.isError;Y(()=>{e&&(i.isPending||i.data||i.mutate({addonId:e}))},[e,i]);function d(f){a(m=>{const h=new Set(m);return h.has(f)?h.delete(f):h.add(f),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 p=l??[];return u("div",{className:"space-y-4",children:[r("p",{className:"text-xs text-foreground-subtle",children:p.length>0?o("integrations.foundDevices",{count:p.length}):o("integrations.noDevicesFound")}),p.length>0&&r("div",{className:"space-y-1.5 max-h-64 overflow-y-auto",children:p.map(f=>{const m=f.stableId,h=f.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(At,{className:"h-3 w-3 text-primary-foreground"})}),r(Nr,{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")}),p.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 $7(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 D7({open:e,onClose:t}){const{t:n}=Bt(),o=rt(),s=we(),[a,i]=P("picker"),[l,c]=P(null),[d,p]=P(null),[f,m]=P("manual"),{data:h}=Oc({addonId:l??"",nodeId:"hub"},{enabled:l!=null}),g=V(()=>h?$7(h):null,[h]),x=Nb({onSuccess:()=>s.invalidateQueries({queryKey:[["integrations"]]})}),b=Hc(),v=b.data;Y(()=>{a!=="discovery"||!d||!l||b.isPending||b.data||b.mutate({addonId:l})},[a,d,l,b]);const w=bb({onSuccess:()=>s.invalidateQueries({queryKey:[["deviceManager"]]})});async function y(R,M,$,L){if(!x.isPending){if(c(R),m($),M==="unique"){try{const O=await x.mutateAsync({addonId:R,name:L,settings:{}});t(),D(),o(`/integrations/${O.id}`)}catch{}return}i("config")}}async function N(R){if(l)try{const M=await x.mutateAsync({addonId:l,name:R.name,settings:R.config});p(M.id),f==="auto"||f==="both"?i("discovery"):C(M.id)}catch{}}async function k(R){if(l){for(const M of R){const $=v?.find(L=>L.stableId===M);$&&await w.mutateAsync({addonId:l,candidate:$})}C()}}function C(R){const M=R??d??l;t(),D(),M&&o(`/integrations/${M}`)}function D(){i("picker"),c(null),p(null),m("manual")}function E(){t(),D()}if(!e)return null;const I={picker:n("integrations.newIntegration"),config:n("integrations.configureIntegration"),discovery:n("integrations.importDevices")},z=x.isPending,A=z?l:null,T=x.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:E}),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:I[a]}),r("button",{onClick:E,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(Be,{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(A7,{onSelect:y,onClose:E,pendingAddonId:A}),a==="config"&&l&&r(P7,{addonId:l,configSchema:g??null,onSave:N,onBack:()=>i("picker")}),a==="discovery"&&d&&r(_7,{providerId:d,onImport:k,onSkip:C}),z&&u("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background/85 backdrop-blur-sm",children:[r(Se,{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 Fp={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 Oa({status:e}){const t=Fp[e]??Fp.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 Mi="px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle";function L7({integrations:e,expandedAddonId:t,onToggleExpand:n,onOpenSettings:o,renderExpanded:s}){const a=U(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:K(Mi,"w-[60%]"),children:"Integration"}),r("th",{className:K(Mi,"w-[15%]"),children:"Devices"}),r("th",{className:K(Mi,"w-[25%]"),children:"Status"})]})}),r("tbody",{children:e.map(i=>{const l=t===i.addonId;return r(T7,{integration:i,isExpanded:l,onClick:a,onOpenSettings:o,renderExpanded:s},i.id)})})]})})}function T7({integration:e,isExpanded:t,onClick:n,onOpenSettings:o,renderExpanded:s}){const a=U(c=>{c.stopPropagation(),o(e.id)},[e.id,o]),i=U(()=>{n(e.addonId)},[e.addonId,n]),l=U(c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),i())},[i]);return u(ue,{children:[u("tr",{role:"button",tabIndex:0,"aria-expanded":t,className:K("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(Nt,{className:"h-3.5 w-3.5 flex-shrink-0 text-foreground-subtle"}):r(zt,{className:"h-3.5 w-3.5 flex-shrink-0 text-foreground-subtle"}),r(pn,{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(Oa,{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(Wt,{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 R7(e){if(!e.enabled)return"disabled";switch(e.processState){case"running":return"running";case"stopped":case"crashed":case"unknown":default:return"stopped"}}const us="expand";function O7(){const{t:e}=Bt(),t=rt(),n=Le(),[o]=Ia(),[s,a]=P(!1),i=U(()=>a(!0),[]),l=U(()=>a(!1),[]);Qt(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped","addon.updated"]),Qt(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]);const{data:c,isLoading:d,refetch:p}=Uc(void 0,{staleTime:3e4}),{data:f,isLoading:m,refetch:h}=$n({},{staleTime:3e4}),g=V(()=>f??[],[f]),x=V(()=>c??[],[c]),b=V(()=>{const R=new Map;for(const M of g)R.set(M.id,{id:M.id,name:M.name??M.stableId??`#${String(M.id)}`});return R},[g]),v=V(()=>{const R=new Map;for(const M of g){if(M.parentDeviceId!==null&&M.parentDeviceId!==void 0&&!!M.role)continue;const L=M.addonId??"";L&&R.set(L,(R.get(L)??0)+1)}return R},[g]),w=V(()=>x.map(R=>({id:R.id,addonId:R.addonId,name:R.name,enabled:R.enabled,status:R7(R),deviceCount:v.get(R.addonId)??0})),[x,v]),y=o.get(us),N=U(R=>{const M=new URLSearchParams(window.location.search);M.get(us)===R?M.delete(us):M.set(us,R);const L=M.toString(),O=`${window.location.pathname}${L?`?${L}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",O),window.dispatchEvent(new PopStateEvent("popstate"))},[]),k=U(R=>t(`/integrations/${R}`),[t]),C=U(R=>b.get(R)??null,[b]),D=U(R=>r(pn,{type:R,size:"sm"}),[]),E=U(R=>t(`/devices/${String(R)}`),[t]),I=U(R=>r(wo,{devices:g,trpc:n.trpcClient,forceAddon:R,urlScope:"nested",lsKey:`integrations:nested:${R}`,resolveIntegrationIcon:D,resolveParent:C,onNavigate:E}),[g,n.trpcClient,D,C,E]),z=U(()=>{p(),h()},[p,h]),A=d||m,T=x.length>0;return u(tt,{icon:ko,title:e("nav.integrations","Integrations"),actions:u(ue,{children:[r("button",{onClick:z,disabled:A,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(it,{className:K("h-3.5 w-3.5",A&&"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(kt,{className:"h-3.5 w-3.5"}),"New Integration"]})]}),children:[A&&r("div",{className:"space-y-2",children:[1,2,3].map(R=>r("div",{className:"h-12 rounded-lg border border-border bg-surface animate-pulse"},R))}),!A&&!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.'})]}),!A&&T&&r(L7,{integrations:w,expandedAddonId:y,onToggleExpand:N,onOpenSettings:k,renderExpanded:I}),r(D7,{open:s,onClose:l})]})}function X0(e){const t=[];for(const n of e)n.type==="probe"&&t.push(n.key),n.type==="group"&&"fields"in n&&t.push(...X0(n.fields));return t}function z7(e,t,n){const[o,s]=P("idle"),[a,i]=P({}),l=V(()=>{const f=[];for(const m of e.sections)f.push(...X0(m.fields));return f},[e]),c=l.length>0&&n!==void 0,d=U(f=>{i(m=>{if(!m[f])return m;const h={...m};return delete h[f],h})},[]),p=U(async()=>{if(!n)return;const f=l.filter(x=>{const b=t[x];return b!=null&&String(b).trim()!==""});if(f.length===0)return;s("testing");const m={};for(const x of f)m[x]={status:"probing"};i(m);const h=await Promise.allSettled(f.map(async x=>{try{const b=await n(x,t[x]);return{key:x,result:b}}catch(b){const w={status:"error",error:b instanceof Error?b.message:String(b)};return{key:x,result:w}}})),g={};for(const x of h)if(x.status==="fulfilled"){const{key:b,result:v}=x.value;g[b]={status:v.status==="ok"?"ok":"error",result:v}}i(g),s("idle")},[n,l,t]);return{testAllStatus:o,hasProbeFields:c,probeResults:a,handleTestAll:p,clearProbeResult:d}}function J0(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(...J0(n.fields));return t}function Ai(e){return e==null?!0:typeof e=="string"?e.trim()==="":!1}function Pl(e,t={}){for(const n of e){if(n.type==="group"&&"fields"in n){Pl(n.fields,t);continue}"key"in n&&n.key&&"default"in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function jp(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function B7({open:e,integrationId:t,addonId:n,onClose:o}){const{t:s}=Bt(),a=we(),[i,l]=P({}),[c,d]=P(!1),[p,f]=P(null),[m,h]=P(jp),g=xb({addonId:n,type:ut.Camera},{enabled:e}),x=g.data??null;Y(()=>{if(e){const M=x?Pl(x.sections.flatMap($=>$.fields)):{};l(M),h(jp()),d(!1),f(null)}},[e,t,x]);const b=V(()=>({...i,_probeRequestId:m}),[i,m]),v=yb({onSuccess:()=>{a.invalidateQueries({queryKey:[["deviceManager"]]})}}),w=Vc(),y=U(async(M,$)=>{d(!0);const L=await w.mutateAsync({addonId:n,type:ut.Camera,key:M,value:$,formValues:b});return L.status==="ok"&&L.suggestedValues&&l(O=>{let F=!1;const B={...O};for(const[j,H]of Object.entries(L.suggestedValues??{}))Ai(O[j])&&!Ai(H)&&(B[j]=H,F=!0);return F?B:O}),L},[w,n,b]),{testAllStatus:N,hasProbeFields:k,probeResults:C,handleTestAll:D,clearProbeResult:E}=z7(x??{sections:[]},i,y);async function I(M){f(null);try{if(await v.mutateAsync({addonId:n,type:ut.Camera,config:i}),M){const $=x?Pl(x.sections.flatMap(L=>L.fields)):{};l($)}else o()}catch($){f($ instanceof Error?$.message:String($))}}if(!e)return null;const A=J0((x?.sections??[]).flatMap(M=>M.fields)).filter(M=>Ai(i[M])),T=A.length===0,R=!g.isLoading&&(g.isError||x===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(Be,{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(Se,{className:"h-5 w-5 animate-spin text-primary"})}):R?u("div",{className:"flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3",children:[r(at,{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(En,{schema:x,values:i,onChange:l,onTestField:y,probeResults:C,onClearProbe:E})}),!R&&!g.isLoading&&u("div",{className:"border-t border-border bg-surface/50 shrink-0",children:[u("button",{type:"button",onClick:()=>d(M=>!M),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(vt,{className:"h-3.5 w-3.5"}),"Test logs",r("span",{className:"font-mono text-[9px] opacity-60",children:m.slice(0,14)})]}),r(Nt,{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(Zt,{addonId:n,requestId:m,limit:50,maxHeight:"max-h-64",showFilters:!1,showScope:!1,className:"border-0 rounded-none"})})]}),!R&&!g.isLoading&&(p||A.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(at,{className:"h-3.5 w-3.5 text-destructive mt-0.5 shrink-0"}),r("p",{className:"text-[11px] text-destructive",children:p||`Required: ${A.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")}),!R&&k&&u("button",{type:"button",onClick:D,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(Se,{className:"h-3.5 w-3.5 animate-spin"}):r(Sr,{className:"h-3.5 w-3.5"}),"Test All"]})]}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>I(!0),disabled:R||!T||v.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:()=>I(!1),disabled:R||!T||v.isPending,className:"rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:v.isPending?s("integrations.saving"):s("integrations.save")})]})]})]})]})}function F7(){const{t:e}=Bt(),{integrationId:t}=fd(),n=we(),o=rt(),s=Le(),[a,i]=P(!1),[l,c]=P(!1),[d,p]=P(!1),[f,m]=P(!1),{data:h,isLoading:g}=vb({id:t??""},{enabled:!!t}),{data:x}=Oc({addonId:h?.addonId??"",nodeId:"hub"},{enabled:!!h?.addonId}),b=x!=null&&Array.isArray(x.sections)&&x.sections.some(T=>T.fields.length>0),{data:v}=$n({},{refetchInterval:5e3}),w=[["integrations","get"],{input:{id:t??""},type:"query"}],y=kb({onMutate:async T=>{await n.cancelQueries({queryKey:w});const R=n.getQueryData(w);return R!=null&&n.setQueryData(w,{...R,enabled:T.enabled}),{previous:R}},onError:(T,R,M)=>{const $=M;$?.previous!=null&&n.setQueryData(w,$.previous)},onSettled:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),N=Sb({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]}),p(!1),o("/integrations")}}),k=Fo({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),C=V(()=>v??[],[v]),D=V(()=>{const T=new Map;for(const R of C)T.set(R.id,{id:R.id,name:R.name??R.stableId??`#${String(R.id)}`});return T},[C]),E=U(T=>D.get(T)??null,[D]),I=U(T=>r(pn,{type:T,size:"sm"}),[]),z=U(T=>o(`/devices/${String(T)}`),[o]),A=V(()=>{const T=h?.addonId;if(!T)return 0;let R=0;for(const M of C)M.addonId!==T||M.parentDeviceId!==null&&M.parentDeviceId!==void 0&&M.role||(R+=1);return R},[C,h?.addonId]);return g?u("div",{className:"p-4",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-4 space-y-4",children:[r(wc,{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," · ",A," ",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 ${y.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(hc,{checked:h.enabled,onCheckedChange:T=>y.mutate({id:t,enabled:T}),disabled:y.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"}),y.isPending&&r(Se,{className:"h-3 w-3 animate-spin text-foreground-subtle"})]}),b&&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(Wt,{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(vt,{className:"h-3 w-3"}),e("integrations.logs",{defaultValue:"Logs"})]}),r(ld,{label:"Restart",icon:it,title:`Restart "${h.name}"?`,description:`Restarting the addon will briefly disconnect every device backed by it (${A} active). Streams will reconnect automatically.`,confirmLabel:"Restart",triggerVariant:"outline",confirmVariant:"danger",disabled:k.isPending,action:()=>k.mutateAsync({addonId:h.addonId})}),u("button",{onClick:()=>p(!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(We,{className:"h-3 w-3"}),e("integrations.delete",{defaultValue:"Delete"})]})]})]}),r(wo,{devices:C,trpc:s.trpcClient,defaultView:"cards",forceAddon:h.addonId,urlScope:"root",lsKey:`integration-detail:${h.addonId}`,resolveIntegrationIcon:I,resolveParent:E,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(kt,{className:"h-5 w-5 text-primary-foreground"})}),a&&t&&r(B7,{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"})]})}),f&&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(vt,{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(Be,{className:"h-4 w-4"})})]}),r("div",{className:"flex-1 min-h-0 overflow-hidden",children:r(Zt,{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&&p(!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(at,{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:A})})]})]}),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:()=>p(!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(ue,{children:[r(Se,{className:"h-3 w-3 animate-spin"}),e("integrations.deleting",{defaultValue:"Deleting…"})]}):u(ue,{children:[r(We,{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(eO,{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(vd,{className:"h-3 w-3"}),e("integrations.backToList",{defaultValue:"Back to integrations"})]})]})}function j7({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 Ei=36e5;function H7(e){return String(e).padStart(2,"0")}function V7(e){const t=new Date(e);return`${H7(t.getHours())}:00`}function U7({startMs:e,endMs:t,segments:n,events:o,playheadMs:s,onSeek:a}){const i=re(null),l=t-e,c=U(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(),x=Math.max(0,Math.min(1,(h.clientX-g.left)/g.width));a(Math.round(e+x*l))}const p=[],f=Math.floor(e/Ei),m=Math.ceil(t/Ei);for(let h=f;h<=m;h++){const g=h*Ei;g<e||g>t||p.push({percent:c(g),label:V7(g)})}return u("div",{className:"select-none",children:[r("div",{className:"relative h-5 mb-1",children:p.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 x=c(h.startMs),b=c(h.endMs)-x;return r("div",{className:"absolute top-1 bottom-1 rounded-sm bg-success/60",style:{left:`${x}%`,width:`${Math.max(b,.1)}%`}},g)}),o.map(h=>r(j7,{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 Hp={person:"#f59e0b",vehicle:"#3b82f6",car:"#3b82f6",face:"#a855f7",plate:"#ec4899",animal:"#10b981",motion:"#ef4444",unknown:"#6b7280"};function _l(e){return Hp[e.toLowerCase()]??Hp.unknown}function q7(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function Q7(e){return new Date(e).toISOString().slice(0,10)}function G7(e){return new Date(e+"T00:00:00").getTime()}function K7(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 W7(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:_l(t[o%t.length])})).sort((n,o)=>n.timestampMs-o.timestampMs)}function Y7(){const{t:e}=Bt(),t=q7(new Date),[n,o]=P(t),[s,a]=P(null),[i,l]=P(t+12*36e5),c=n,d=n+24*36e5,{data:p,isLoading:f}=$n({},{staleTime:3e4}),m=p??[],h=V(()=>m.filter(N=>{const k=N.type.toLowerCase();return k==="camera"||k.includes("camera")||N.features.some(C=>C.toLowerCase().includes("video")||C.toLowerCase().includes("stream"))}).map(N=>({id:N.id,name:N.name??N.stableId})),[m]),g=s??h[0]?.id??null,{data:x}=Dr({queryKey:["events",g,c],queryFn:()=>Promise.resolve(null),enabled:!!g,staleTime:6e4}),b=V(()=>{const y=Array.isArray(x)?x:(()=>{const k=ru(x)?.events;return Array.isArray(k)?k:[]})();return y.length===0?g?W7(c):[]:y.flatMap((N,k)=>{const C=ru(N);if(!C)return[];const D=String(C.class??C.type??C.label??"unknown").toLowerCase(),E=typeof C.timestamp=="number"?C.timestamp:c;return[{id:String(C.id??k),timestampMs:E,label:D,color:_l(D)}]})},[x,g,c]),v=V(()=>g?K7(c):[],[g,c]);function w(y){o(N=>N+y*24*36e5),l(N=>N+y*24*36e5)}return u("div",{className:"flex flex-col h-full p-4 gap-4 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(Nd,{className:"h-4 w-4"})}),u("div",{className:"relative flex items-center",children:[r(v0,{className:"absolute left-2 h-3.5 w-3.5 text-foreground-subtle pointer-events-none"}),r("input",{type:"date",value:Q7(n),onChange:y=>{if(y.target.value){const N=G7(y.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(zt,{className:"h-4 w-4"})})]})]}),u("div",{className:"flex gap-1.5 shrink-0 overflow-x-auto pb-1",children:[f&&r("div",{className:"h-8 w-48 rounded-lg bg-surface animate-pulse"}),!f&&h.length===0&&r("span",{className:"text-xs text-foreground-subtle",children:"No cameras found"}),h.map(y=>{const N=y.id===g;return r("button",{onClick:()=>a(y.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:y.name},y.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(uo,{className:"h-12 w-12 opacity-20"}),r("p",{className:"text-sm opacity-50",children:g?`${h.find(y=>y.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(b.map(y=>y.label))).slice(0,5).map(y=>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:_l(y)}}),r("span",{className:"text-[10px] text-foreground-subtle capitalize",children:y})]},y))]}),g?r(U7,{startMs:c,endMs:d,segments:v,events:b,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 Z7({selectedNodeId:e,onSelect:t,refreshToken:n}){const{data:o}=Dn(void 0,{staleTime:3e4}),{data:s}=Na(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(mo),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===mo?"bg-primary/10 text-primary":"text-foreground hover:bg-surface-hover"}`,children:[r(Cn,{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 p=e===d.id,f=a.get(d.id)??0,m=d.isHub?An:Ot;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 ${p?"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"]}),f>0&&u(ue,{children:[r("span",{children:"•"}),u("span",{className:"inline-flex items-center gap-0.5 text-foreground",children:[r(O0,{className:"h-2.5 w-2.5"}),f]})]})]})]})]},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 X7({nodeId:e,refreshToken:t}){const{data:n}=Dn(void 0,{staleTime:3e4}),o=n?.find(i=>i.id===e),a=Br("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(ue,{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(ue,{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 ev({refreshToken:e,nodeId:t}){const[n,o]=P(new Map),{nodes:s}=Fr();ht("pipeline.camera-metrics-snapshot",f=>{const m=f.data;typeof m?.deviceId=="number"&&o(h=>{const g=new Map(h);return g.set(m.deviceId,m),g})});const{data:a}=xx(void 0,{staleTime:5e3}),i=V(()=>{const f=new Map;for(const m of a??[])f.set(m.nodeId,m.deviceCount);return f},[a]),l=V(()=>{const f=new Map,m=Date.now()-3e4;for(const h of n.values()){if(h.timestamp<m)continue;const g=h.nodeId??"hub",x=f.get(g)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};x.attachedCameras++,h.metrics.phase==="active"&&x.activeCameras++,x.totalFps+=h.metrics.actualFps,x.totalInferenceWeighted+=h.metrics.avgInferenceTimeMs,x.queueDepth+=h.metrics.queueDepth,f.set(g,x)}return f},[n]),c=V(()=>{const f=new Map;for(const m of s)f.set(m.id,m.shortName);return f},[s]),d=V(()=>{let f=0,m=0,h=0,g=0,x=0;for(const v of l.values())f+=v.attachedCameras,m+=v.activeCameras,h+=v.totalFps,g+=v.totalInferenceWeighted,x+=v.queueDepth;const b=f>0?g/f:0;return{totalAgents:s.length,onlineAgents:s.filter(v=>v.isOnline).length,attachedCameras:f,activeCameras:m,avgInferenceTimeMs:b,queueDepth:x,totalFps:h}},[l,s]);if(t){const f=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:f?f.totalFps.toFixed(1):"—"}),r(jt,{label:"Cameras",value:f?`${f.activeCameras}/${f.attachedCameras}`:"—"}),r(jt,{label:"Avg infer ms",value:f&&f.attachedCameras>0?(f.totalInferenceWeighted/f.attachedCameras).toFixed(0):"—"}),r(jt,{label:"Queue",value:f?String(f.queueDepth):"—"}),r(jt,{label:"Audio",value:String(i.get(t)??"—")})]})]})}const p=[...l.entries()].sort(([f],[m])=>f==="hub"?-1:m==="hub"?1:f.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:[p.map(([f,m])=>u("tr",{className:"border-t border-border",children:[r("td",{className:"px-3 py-2 text-foreground font-medium",children:c.get(f)??f}),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(f)??"—"})]},f)),p.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 tv(e){return $n({addonId:e})}const J7=3e4,e9=2e3;function nv(e){const t=re(0);return t.current===0&&(t.current=Date.now()),cb({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>=J7?!1:e9}})}const Ii={active:!1,pinned:!1,nodeId:null,reason:""},Pi=["pipeline.camera-assigned","pipeline.camera-unassigned","pipeline.camera-updated","agent.online","agent.offline"],t9={pipeline:Ot,decoder:uo,audio:Cl},Vp={pipeline:"Pipeline",decoder:"Decoder",audio:"Audio"};function rv({mode:e,nodeId:t,compact:n=!1}){if(e==="agent"&&!t)throw new Error('CameraAssignmentsTable: nodeId is required when mode === "agent"');const o=we(),[s,a]=P(null),[i,l]=P(null),[c,d]=P(new Map);Qt(["pipelineOrchestrator","getPipelineAssignments"],Pi),Qt(["pipelineOrchestrator","getDecoderAssignments"],Pi),Qt(["pipelineOrchestrator","getAudioAssignments"],Pi);const{data:p}=Na(void 0,{staleTime:3e4}),{data:f}=hx(void 0,{staleTime:3e4}),{data:m}=yx(void 0,{staleTime:3e4}),{nodes:h}=Fr(),{data:g}=tv();ht("pipeline.camera-metrics-snapshot",A=>{const T=A.data;typeof T.deviceId=="number"&&d(R=>{const M=new Map(R);return M.set(T.deviceId,T),M})}),Y(()=>{if(c.size===0)return;const A=setInterval(()=>{d(T=>{const R=Date.now()-1e4;let M=!1;const $=new Map(T);for(const[L,O]of T)O.timestamp<R&&($.delete(L),M=!0);return M?$:T})},5e3);return()=>clearInterval(A)},[c.size]);const x=V(()=>{const A=new Map;for(const T of g??[])A.set(T.id,T.name);return A},[g]),b=V(()=>{const A=new Map,T=M=>{const $=A.get(M);if($)return $;const L={deviceId:M,deviceName:x.get(M)??`Device ${M}`,pipeline:Ii,decoder:Ii,audio:Ii};return A.set(M,L),L};for(const M of p??[]){const $=T(M.deviceId);A.set(M.deviceId,{...$,pipeline:{active:e==="cluster"?!0:M.agentNodeId===t,pinned:M.pinned,nodeId:M.agentNodeId,reason:M.reason??""}})}for(const M of f??[]){const $=T(M.deviceId);A.set(M.deviceId,{...$,decoder:{active:e==="cluster"?!0:M.decoderNodeId===t,pinned:M.pinned,nodeId:M.decoderNodeId,reason:M.reason??""}})}for(const M of m??[]){const $=T(M.deviceId);A.set(M.deviceId,{...$,audio:{active:e==="cluster"?!0:M.nodeId===t,pinned:M.pinned,nodeId:M.nodeId,reason:"capacity"}})}let R=[...A.values()];return e==="agent"&&(R=R.filter(M=>M.pipeline.active||M.decoder.active||M.audio.active)),R.sort((M,$)=>M.deviceId-$.deviceId),R},[p,f,m,x,e,t]),v=V(()=>(h??[]).filter(A=>A.isOnline).map(A=>({id:A.id,name:A.name})),[h]),w=()=>{o.invalidateQueries({queryKey:[["pipelineOrchestrator","getPipelineAssignments"]]}),o.invalidateQueries({queryKey:[["pipelineOrchestrator","getDecoderAssignments"]]}),o.invalidateQueries({queryKey:[["pipelineOrchestrator","getAudioAssignments"]]})},y=ix({onSuccess:w}),N=lx({onSuccess:w}),k=fx({onSuccess:w}),C=mx({onSuccess:w}),D=gx({onSuccess:w}),E=bx({onSuccess:w}),I=(A,T,R)=>{T==="pipeline"?y.mutate({deviceId:A,agentNodeId:R}):T==="decoder"?k.mutate({deviceId:A,nodeId:R}):D.mutate({deviceId:A,nodeId:R}),a(null)},z=(A,T)=>{T==="pipeline"?N.mutate({deviceId:A}):T==="decoder"?C.mutate({deviceId:A}):E.mutate({deviceId:A}),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:[b.map(A=>{const T=c.get(A.deviceId),R=i===A.deviceId;return u(Ge.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(R?null:A.deviceId),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle","aria-label":R?"Collapse broker details":"Expand broker details",children:R?r(Nt,{className:"h-3.5 w-3.5"}):r(zt,{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:A.deviceName}),u("div",{className:"text-[10px] text-foreground-subtle leading-tight",children:["#",A.deviceId]})]}),r(_i,{role:"pipeline",state:A.pipeline,mode:e,deviceId:A.deviceId,onlineNodes:v,isMenuOpen:s?.deviceId===A.deviceId&&s.role==="pipeline",onToggleMenu:()=>a(s?.deviceId===A.deviceId&&s.role==="pipeline"?null:{deviceId:A.deviceId,role:"pipeline"}),onCloseMenu:()=>a(null),onMove:M=>I(A.deviceId,"pipeline",M),onUnpin:()=>z(A.deviceId,"pipeline")}),r(_i,{role:"decoder",state:A.decoder,mode:e,deviceId:A.deviceId,onlineNodes:v,isMenuOpen:s?.deviceId===A.deviceId&&s.role==="decoder",onToggleMenu:()=>a(s?.deviceId===A.deviceId&&s.role==="decoder"?null:{deviceId:A.deviceId,role:"decoder"}),onCloseMenu:()=>a(null),onMove:M=>I(A.deviceId,"decoder",M),onUnpin:()=>z(A.deviceId,"decoder")}),r(_i,{role:"audio",state:A.audio,mode:e,deviceId:A.deviceId,onlineNodes:v,isMenuOpen:s?.deviceId===A.deviceId&&s.role==="audio",onToggleMenu:()=>a(s?.deviceId===A.deviceId&&s.role==="audio"?null:{deviceId:A.deviceId,role:"audio"}),onCloseMenu:()=>a(null),onMove:M=>I(A.deviceId,"audio",M),onUnpin:()=>z(A.deviceId,"audio")}),r("td",{className:"px-3 py-2 align-middle",children:r(o9,{snap:T})})]}),R&&!n&&u("tr",{className:"bg-surface/50",children:[r("td",{}),r("td",{colSpan:5,className:"px-3 py-2",children:r(wr,{widgetId:"stream-broker/stream-broker-panel",host:"device-tab",deviceId:A.deviceId,instanceId:`pipeline-row/${A.deviceId}`,config:{variant:"compact",title:"Stream brokers & clients"}})})]})]},A.deviceId)}),b.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 _i({role:e,state:t,mode:n,onlineNodes:o,isMenuOpen:s,onToggleMenu:a,onCloseMenu:i,onMove:l,onUnpin:c}){const d=t9[e],p=o.filter(h=>h.id!==(t.nodeId??"")),m=(t.active||n==="cluster")&&(p.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(n9,{state:t,Icon:d}):r(r9,{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":`${Vp[e]} actions`,children:r(jR,{className:"h-3 w-3 text-foreground-subtle"})})})]}),s&&m&&r(s9,{title:Vp[e],targets:p,pinned:t.pinned,onMove:l,onUnpin:c,onClose:i})]})}function n9({state:e,Icon:t}){const n=e.active?T0:qo;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(_0,{className:"h-2.5 w-2.5 text-amber-400"})]})}function r9({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(_0,{className:"h-2.5 w-2.5"})," manual"]}):u("span",{className:"text-foreground-subtle truncate",children:["auto · ",e.reason||"capacity"]})})]})]})}function o9({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=Lr(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(ad,{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 s9({title:e,targets:t,pinned:n,onMove:o,onUnpin:s,onClose:a}){const i=re(null);return Y(()=>{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 a9({nodeId:e,refreshToken:t}){return u("div",{className:"space-y-6",children:[r(ev,{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(rv,{mode:"agent",nodeId:e,compact:!0})]})}function i9(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 l9({nodeId:e,refreshToken:t}){const n=we(),o=ax({onSettled:()=>{n.invalidateQueries({queryKey:["pipelineExecutor","listLoadedEngines"]})}}),{data:s}=sx({nodeId:e},{staleTime:5e3}),i=Br("pipeline.engine-metrics-snapshot",m=>m.nodeId===e)?.engines??s??null,l=i===null;Qt(["pipelineRunner","getLocalCameras"],["pipeline.camera-assigned","pipeline.camera-unassigned"]);const{data:c}=Ix({nodeId:e},{staleTime:3e4}),{values:d}=Mc("pipeline.camera-metrics-snapshot",m=>m.deviceId,m=>m.nodeId===e),p=V(()=>d.filter(m=>m.metrics.phase==="active").length,[d]),f=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, ",p," 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(GR,{className:"h-3 w-3"}):r(Ot,{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(Ad,{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:i9(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:()=>f(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(We,{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 St(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 ov(e){return St(e*1024*1024)}const c9=new Set(kN);function Up(e){return c9.has(e)}function $i(e,t,n){return`${e}/${t}/${n}`}function $l(e){return{coreml:"CoreML",openvino:"OpenVINO",onnx:"ONNX"}[e.format]??e.format.toUpperCase()}function qp(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 zn(e){return e.format}function d9(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 u9({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:ov(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(kr,{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(Se,{className:"h-3 w-3 animate-spin"}):r(We,{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(Se,{className:"h-3 w-3 animate-spin"}):r(Kt,{className:"h-3 w-3"}),o?"Downloading...":"Download"]})]}):null}function p9({engines:e,activeEngine:t,viewEngine:n,onSelect:o}){const[s,a]=P(!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(Ot,{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:$l(n)}),zn(n)===zn(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:qp(n)})]}),r(Nt,{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=zn(i)===zn(n),c=zn(i)===zn(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(Ot,{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:$l(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:qp(i)})]}),l&&r(kd,{className:"h-4 w-4 text-primary shrink-0"})]},zn(i))})})]})}function f9({embedded:e=!1,nodeId:t}={}){const n=we(),o=t??"hub",[s,a]=P(null),[i,l]=P(new Set),[c,d]=P(new Map),[p,f]=P(new Map),[m,h]=P(""),{data:g=[]}=ex({nodeId:o},{staleTime:6e4}),b=g.filter((F,B,j)=>j.findIndex(H=>H.format===F.format)===B),{data:v}=tx({nodeId:o},{staleTime:3e4}),w=v,{data:y,isLoading:N}=jo({nodeId:o},{staleTime:1e4}),k=rx(),C=ox();ht("model.download.progress",F=>{const B=F.data,j=typeof B.modelId=="string"?B.modelId:void 0,H=typeof B.progress=="number"?B.progress:void 0,_=typeof B.totalMB=="number"?B.totalMB:0;j===void 0||H===void 0||(d(q=>{const G=new Map(q);return H===100||H===-1?G.delete(j):G.set(j,{modelId:j,progress:H,totalMB:_}),G}),H===100&&n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]}))});const D=w??{runtime:"node",backend:"cpu",format:"onnx"},E=b.find(F=>F.format===s)??D,I=E.format,z=y?.slots??[],A=z.map(F=>({...F,addons:F.addons.map(B=>({...B,models:B.models.filter(j=>j.formats[I]!==void 0)})).filter(B=>B.models.length>0)})).filter(F=>F.addons.length>0),T=d9(A,I),R=U(async(F,B,j)=>{if(!Up(j))return;const H=$i(F,B,j);l(_=>new Set([..._,H])),f(_=>{const q=new Map(_);return q.delete(H),q});try{await k.mutateAsync({addonId:F,modelId:B,format:j,nodeId:o}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch(_){f(q=>new Map([...q,[H,_ instanceof Error?_.message:"Download failed"]]))}finally{l(_=>{const q=new Set(_);return q.delete(H),q})}},[k,n,o]),M=U(async(F,B,j)=>{if(!Up(j))return;const H=$i(F,B,j);l(_=>new Set([..._,H])),f(_=>{const q=new Map(_);return q.delete(H),q});try{await C.mutateAsync({addonId:F,modelId:B,format:j,nodeId:o}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch(_){f(q=>new Map([...q,[H,_ instanceof Error?_.message:"Delete failed"]]))}finally{l(_=>{const q=new Set(_);return q.delete(H),q})}},[C,n,o]),$=U(F=>{a(F.format)},[]),L=m.trim()?A.map(F=>({...F,addons:F.addons.map(B=>({...B,models:B.models.filter(j=>j.name.toLowerCase().includes(m.toLowerCase())||j.id.toLowerCase().includes(m.toLowerCase())||B.name.toLowerCase().includes(m.toLowerCase()))})).filter(B=>B.models.length>0)})).filter(F=>F.addons.length>0):A,O=u(ue,{children:[N&&r("div",{className:"flex items-center justify-center py-16",children:r(Se,{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(Gs,{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(ue,{children:[r(p9,{engines:b,activeEngine:D,viewEngine:E,onSelect:$}),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:[ov(T.downloadedSizeMB),r("span",{className:"ml-1",children:"on disk"})]})]}),T.total>5&&u("div",{className:"relative",children:[r(L0,{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:F=>h(F.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"})]}),L.map(F=>{const B=F.addons.reduce((H,_)=>H+_.models.length,0),j=F.addons.reduce((H,_)=>H+_.models.filter(q=>q.formats[I]?.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:F.label}),r("div",{className:"flex-1 h-px bg-border"}),u("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[j,"/",B]})]}),r("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:F.addons.map(H=>H.models.map(_=>{const q=$i(H.id,_.id,I);return r(u9,{addonId:H.id,model:_,format:I,isActive:i.has(q),progress:c.get(_.id),errorMsg:p.get(q),onDownload:()=>R(H.id,_.id,I),onDelete:()=>M(H.id,_.id,I)},`${H.id}/${_.id}`)}))})]},F.id)}),L.length===0&&r("div",{className:"text-center py-8 text-sm text-foreground-subtle",children:m.trim()?u(ue,{children:["No models matching “",m,"”"]}):u(ue,{children:["No models available for ",$l(E)," format"]})})]})]});return e?r("div",{className:"space-y-4",children:O}):r(tt,{children:O})}function m9({nodeId:e,refreshToken:t}){return r(f9,{embedded:!0,nodeId:e})}function sv({nodeId:e,title:t}){const{data:n}=tv(),{data:o}=Na(void 0,{staleTime:3e4}),s=V(()=>{const d=new Map;for(const p of n??[])d.set(p.id,p.name);return d},[n]),a=V(()=>{if(!e)return null;const d=new Set;for(const p of o??[])p.agentNodeId===e&&d.add(p.deviceId);return d},[e,o]),[i,l]=P(new Map);ht("pipeline.camera-metrics-snapshot",d=>{const p=d.data;typeof p.deviceId=="number"&&(e&&p.nodeId!==e||l(f=>{const m=new Map(f);return m.set(p.deviceId,p),m}))}),Y(()=>{if(i.size===0)return;const d=setInterval(()=>{l(p=>{const f=Date.now()-1e4;let m=!1;const h=new Map(p);for(const[g,x]of p)x.timestamp<f&&(h.delete(g),m=!0);return m?h:p})},5e3);return()=>clearInterval(d)},[i.size]);const c=V(()=>{const d=[];for(const p of i.values())a&&!a.has(p.deviceId)||d.push(p);return d.sort((p,f)=>p.deviceId-f.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 p=s.get(d.deviceId)??`#${d.deviceId}`,f=Lr(d.metrics.phase);return u("div",{title:`${p} · ${f.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] ${f.badgeClass}`,children:[r(ad,{phase:d.metrics.phase,className:"h-2.5 w-2.5"}),r("span",{className:"font-medium text-foreground/90 max-w-[120px] truncate",children:p}),r("span",{className:"font-mono tabular-nums",children:d.metrics.actualFps.toFixed(1)}),r("span",{className:"opacity-60",children:"fps"})]},d.deviceId)})})]})}function Di(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 h9({nodeId:e,refreshToken:t}){const n=we(),[o,s]=P(null),[a,i]=P(null),l=jo({nodeId:e},{refetchOnMount:"always"}),c=Qc({agentNodeId:e},{refetchOnMount:"always"}),d=Gc({onSuccess:()=>{n.invalidateQueries({queryKey:[["addonSettings"]]}),n.invalidateQueries({queryKey:[["pipelineOrchestrator"]]}),n.invalidateQueries({queryKey:[["pipelineExecutor"]]})}}),p=l.data??null,f=c.data,m=p?.selectedEngine.format??"coreml",h=V(()=>p?ba(p):[],[p]),g=V(()=>[{agentNodeId:e,engineLabel:m}],[e,m]),x=(C,D)=>{const E=f?.addonDefaults[C];return Di(p,C)?.models.some(A=>!!A.formats[m])?E?E.enabled?{kind:"enabled",modelId:E.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},b=o&&p?Di(p,o.addonId):null,v=C=>{const D=f?.addonDefaults[C]??null;s({addonId:C,agentNodeId:e}),i(D)},w=(C,D)=>{if(!f)return;const E=f.addonDefaults[C],I=Di(p,C);if(!E&&!I)return;const z={enabled:D,modelId:E?.modelId??I?.defaultModelId??"",settings:E?.settings??{}};d.mutate({agentNodeId:e,defaults:{...f.addonDefaults,[C]:z}})},y=()=>{s(null),i(null)},N=()=>{!a||!o||!f||d.mutate({agentNodeId:e,defaults:{...f.addonDefaults,[o.addonId]:a}},{onSuccess:y})};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(!p)return r("div",{className:"text-xs text-foreground-subtle",children:"Catalog unavailable for this node (runner offline?)."});const k=o!==null&&b!==null&&a!==null;return u("div",{className:"relative h-full w-full space-y-3",children:[r(sv,{nodeId:e}),r("div",{className:k?"pr-[360px]":"",children:h.length>0?r(kc,{tree:h,agents:g,getCellState:x,onCellClick:v,selectedCell:o,onToggleEnabled:w}):r("div",{className:"text-xs text-foreground-subtle",children:"Catalog empty."})}),r(Nc,{open:k,onClose:y,title:b?.name??"",subtitle:o?`${o.agentNodeId} · ${m}`:"",footer:u(ue,{children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:y,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:b&&a&&o&&r(ya,{mode:"agent",addon:b,agentDefault:a,agentNodeId:o.agentNodeId,engineFormat:m,onChangeAgentConfig:C=>i(C)})})]})}function av({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 iv({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 g9(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 lv({schema:e,serverValues:t,onImmediateSave:n,onDeferredSave:o}){const[s,a]=P({}),[i,l]=P(!1),c=re(null),d=e?.sections??[],p=Object.keys(s).length>0,f=V(()=>({...t,...s}),[t,s]);Y(()=>{if(p){l(!0);return}c.current&&clearTimeout(c.current),c.current=setTimeout(()=>l(!1),500)},[p]);const m=U(()=>{l(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>l(!1),2e3)},[]),h=U(v=>{m();const w={},y={},N={...t,...s};for(const[k,C]of Object.entries(v))N[k]!==C&&(g9(d,k)?w[k]=C:y[k]=C);Object.keys(w).length>0&&n(w),a(k=>{const C={...k};for(const D of Object.keys(w))delete C[D];for(const[D,E]of Object.entries(y))C[D]=E;return C})},[m,t,s,d,n]),g=U(v=>{const w={},y={};for(const[N,k]of Object.entries(s))v.includes(N)?w[N]=k:y[N]=k;a(y),Object.keys(w).length>0&&o(w)},[s,o]),x=U(v=>{a(w=>{const y={...w};for(const N of v)delete y[N];return y})},[]),b=U(()=>{a({})},[]);return{values:f,pendingKeys:Object.keys(s),hasPendingEdits:p,editingPaused:i,handleChange:h,handleSave:g,handleDiscard:x,resetAll:b}}const b9=qe(function({addonId:t,schema:n,serverValues:o,onImmediateSave:s,onStateChange:a,onAction:i,disabled:l},c){const d=lv({schema:n,serverValues:o,onImmediateSave:U(x=>s(t,x),[t,s]),onDeferredSave:U(()=>{},[])});fN(c,()=>({flush:()=>{const x={};for(const b of d.pendingKeys)x[b]=d.values[b];return d.handleDiscard(d.pendingKeys),x},discard:()=>d.resetAll()}),[d]);const p=d.pendingKeys,f=p.join("|"),m=V(()=>p.map(x=>`${x}=${JSON.stringify(d.values[x])}`).join(","),[p,d.values]),h=re(a);Y(()=>{h.current=a},[a]),Y(()=>{const x={};for(const b of p)x[b]=d.values[b];h.current({addonId:t,pendingKeys:p,pendingValues:x})},[t,f,m]);const g=V(()=>{if(i)return(x,b,v)=>i(t,x,b,v)},[t,i]);return r(En,{schema:n,values:d.values,onChange:d.handleChange,disabled:l,onAction:g})});function cv(e,t){if(e.type==="separator"||e.type==="info"||e.type==="button")return e;if(e.type==="group"){const a=e.fields.map(i=>cv(i,t));return{...e,fields:a}}const n=e;t[e.key]=n.value;const{value:o,...s}=n;return s}function x9(e,t){return{...e,fields:e.fields.map(n=>cv(n,t))}}function y9(e){const t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(o=>x9(o,t))},values:t}}function Gr({nodeId:e,addonIds:t,level:n,deviceId:o,sectionIds:s,sectionTab:a,extraTabs:i,title:l,description:c}){const d=we(),p=Le().trpcClient,f=zg(),m=Bg(),h=nx(),g=tb(),x=Qg(),b=!!(i&&i.length>0),[v,w]=P(null);if(n==="device"&&!o)throw new Error('NodeAddonsSettingsPanel: deviceId is required when level === "device"');const y=e??"hub",N=gN({queries:t.map(ee=>({queryKey:[["addonSettings",n==="global"?"getGlobalSettings":"getDeviceSettings"],{addonId:ee,nodeId:y,deviceId:o??null}],queryFn:async()=>{if(n==="global"){const ne=await p.addonSettings.getGlobalSettings.query({addonId:ee,nodeId:y});return{addonId:ee,result:ne}}const W=await p.addonSettings.getDeviceSettings.query({addonId:ee,deviceId:o,nodeId:y});return{addonId:ee,result:W}},staleTime:3e4}))}),k=N.some(ee=>ee.isLoading),C=N.map(ee=>{if(!ee.data)return"-";if(ee.data.result===null)return`${ee.data.addonId}:n`;const W=[];for(const ne of ee.data.result.sections){W.push(`s:${ne.id}:${ne.tab??"general"}`);for(const ie of ne.fields){if(!("key"in ie))continue;const fe="options"in ie&&Array.isArray(ie.options)?ie.options.map(ye=>ye.value).join(","):"",me=ie.value,te=me===void 0?"":typeof me=="string"?me:JSON.stringify(me);W.push(`f:${ie.key}:${fe}:${te}`)}}return`${ee.data.addonId}:${W.join("|")}`}).join("||"),D=V(()=>{const ee=new Set;for(const W of N){const ne=W.data?.result?.sections;if(ne)for(const ie of ne)ee.add(ie.tab??"general")}return[...ee]},[C+"::"+N.map(ee=>(ee.data?.result?.sections??[]).map(W=>W.tab??"general").join(",")).join("::")]),E=V(()=>new Map((i??[]).map(ee=>[ee.id,ee])),[i]),I=V(()=>{if(!b)return[];const ee=[...new Set([...D,...(i??[]).map(ne=>ne.id)])],W=ne=>{const ie=E.get(ne);if(ie?.order!==void 0)return ie.order;const fe=Xi[ne];return fe?fe.order:50};return ee.sort((ne,ie)=>{const fe=W(ne),me=W(ie);return fe!==me?fe-me:ne.localeCompare(ie)})},[b,D,i,E]),z=V(()=>{const ee=new Map;for(const W of D){const ne=Xi[W];ee.set(W,ne?.label??W.charAt(0).toUpperCase()+W.slice(1))}for(const W of i??[])ee.set(W.id,W.label);return ee},[D,i]),A=b?v&&I.includes(v)?v:I[0]??null:null,T=A!==null&&E.has(A),R=b?A&&!T?A:void 0:a,{data:M}=hn(void 0,{staleTime:6e4}),$=V(()=>{const ee=new Map;for(const W of M??[]){const ne=W.manifest?.id;if(!ne)continue;const ie=W.manifest?.name??W.manifest?.packageDisplayName??ne;ee.set(ne,ie)}return ee},[M]),L=V(()=>{const ee=s?new Set(s):null,W=[];for(const ne of N){if(!ne.data||ne.data.result===null)continue;const{schema:ie,values:fe}=y9(ne.data.result),me=ie.sections.filter(ke=>ee?ee.has(ke.id):!0);if(me.length===0)continue;const te={...ne.data.result,sections:ne.data.result.sections.filter(ke=>ee?ee.has(ke.id):!0)},ye={...ie,sections:me};W.push({addonId:ne.data.addonId,schemaWithValues:te,schema:ye,serverValues:fe})}return W},[C,s]),[O,F]=P(new Map),B=U(ee=>{F(W=>{const ne=new Map(W);return ne.set(ee.addonId,ee),ne})},[]),j=re(new Map),H=U(ee=>W=>{W?j.current.set(ee,W):j.current.delete(ee)},[]),_=U(async(ee,W)=>{n==="global"?await f.mutateAsync({addonId:ee,nodeId:y,patch:W}):await m.mutateAsync({addonId:ee,deviceId:o,nodeId:y,patch:W}),d.invalidateQueries({queryKey:[["addonSettings"]]})},[f,m,y,n,o,d]),q=U(async(ee,W,ne,ie)=>{const fe=y;try{switch(W){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 x.mutateAsync({nodeId:fe}),d.invalidateQueries({queryKey:[["addonSettings"]]});return;default:{const me=await p.addons.custom.mutate({addonId:ee,action:W,input:ie});return d.invalidateQueries({queryKey:[["addonSettings"]]}),me}}}catch(me){throw console.error("[NodeAddonsSettingsPanel] action failed",{addonId:ee,action:W,err:me}),me}},[h,g,x,y,d,p]),G=U((ee,W)=>{_(ee,W)},[_]),Q=Hn({mutationFn:async()=>{const ee=[];for(const ne of L){const ie=O.get(ne.addonId);!ie||ie.pendingKeys.length===0||ee.push({addonId:ne.addonId,patch:ie.pendingValues})}return ee.length===0?{saved:[]}:{saved:await Promise.all(ee.map(async({addonId:ne,patch:ie})=>(n==="global"?await f.mutateAsync({addonId:ne,nodeId:y,patch:ie}):await m.mutateAsync({addonId:ne,deviceId:o,nodeId:y,patch:ie}),ne)))}},onSuccess:({saved:ee})=>{for(const W of ee)j.current.get(W)?.discard();d.invalidateQueries({queryKey:[["addonSettings"]]})}}),J=U(()=>{for(const ee of j.current.values())ee.discard()},[]),Z=V(()=>{let ee=0;for(const W of L){const ne=O.get(W.addonId);ne&&(ee+=ne.pendingKeys.length)}return ee},[L,O]),X=V(()=>{const ee=new Map;for(const W of L){const ne=O.get(W.addonId);if(!ne||ne.pendingKeys.length===0)continue;const ie=new Set(ne.pendingKeys);for(const fe of W.schema.sections){const me=fe.tab??"general";for(const te of fe.fields)"key"in te&&ie.has(te.key)&&ee.set(me,(ee.get(me)??0)+1)}}return ee},[L,O]);if(k)return r("div",{className:"h-24 rounded-lg border border-border bg-surface animate-pulse"});const oe=A&&T?E.get(A):void 0;if(!b&&L.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 he=Q.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})]}),b&&r(iv,{tabs:I.map(ee=>({id:ee,label:z.get(ee)??ee})),activeId:A,onChange:w,pendingByTab:X}),Q.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(Q.error?.message??Q.error)]}),oe?oe.content:(()=>{const ee=R?L.reduce((ie,fe)=>ie+fe.schemaWithValues.sections.filter(me=>(me.tab??"general")===R).length,0):0,W=R!==null&&ee<=1,ne=L.map(ie=>({...ie,renderedWithValues:{...ie.schemaWithValues,sections:ie.schemaWithValues.sections.filter(fe=>R?(fe.tab??"general")===R:!0).map(fe=>W?{...fe,title:"",description:void 0}:fe)}})).filter(ie=>ie.renderedWithValues.sections.length>0).sort((ie,fe)=>{const me=ke=>{let pe=Number.POSITIVE_INFINITY;for(const le of ke)typeof le.order=="number"&&le.order<pe&&(pe=le.order);return pe},te=me(ie.renderedWithValues.sections),ye=me(fe.renderedWithValues.sections);return te!==ye?te-ye:0});return ne.length===0?r("div",{className:"text-[11px] text-foreground-subtle italic",children:"Nothing to configure here for this node."}):r(v9,{entries:ne,paneStates:O,displayNames:$,disabled:he,setPaneRef:H,onPaneStateChange:B,onImmediateSave:G,onAction:q,inline:b||!!a})})(),!k&&r(av,{pendingCount:Z,onSave:()=>Q.mutate(),onDiscard:J,saving:he})]})}function v9({entries:e,paneStates:t,displayNames:n,disabled:o,setPaneRef:s,onPaneStateChange:a,onImmediateSave:i,onAction:l,inline:c}){const d=V(()=>[...e].sort((b,v)=>{if(b.addonId==="system-config")return-1;if(v.addonId==="system-config")return 1;const w=n.get(b.addonId)??b.addonId,y=n.get(v.addonId)??v.addonId;return w.localeCompare(y)}),[e,n]),p=d[0]?.addonId??"",[f,m]=P(p);Y(()=>{d.length!==0&&(d.find(b=>b.addonId===f)||m(d[0].addonId))},[d,f]);const h=d.find(b=>b.addonId===f)??d[0];if(!h)return null;const g=V(()=>l?(b,v,w,y)=>l(b,v,w,y):void 0,[l]),x=b=>r(b9,{ref:s(b.addonId),addonId:b.addonId,schema:b.renderedWithValues,serverValues:b.serverValues,onImmediateSave:i,onStateChange:a,onAction:g,disabled:o},b.addonId);return d.length===1||c?r("div",{className:"flex flex-col gap-4",children:d.map(x)}):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(b=>{const v=n.get(b.addonId)??b.addonId,w=b.addonId===h.addonId,y=(t.get(b.addonId)?.pendingKeys.length??0)>0;return u("button",{type:"button",onClick:()=>m(b.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:[v,y&&r("span",{className:"ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400"})]},b.addonId)})}),r("div",{className:"space-y-2",children:d.map(b=>r("div",{style:b.addonId===h.addonId?void 0:{display:"none"},children:x(b)},b.addonId))})]})}const w9=["detection-pipeline","decoder-nodeav","audio-analyzer","pipeline-runner"];function N9({nodeId:e,refreshToken:t}){return u("div",{className:"flex flex-col h-full",children:[r(X7,{nodeId:e,refreshToken:t}),r("div",{className:"flex-1 min-h-0 overflow-y-auto p-6",children:r(Gr,{nodeId:e,addonIds:w9,level:"global",extraTabs:[{id:"assignments",label:"Assignments",order:-10,content:r(a9,{nodeId:e,refreshToken:t})},{id:"tree",label:"Pipeline",order:39,content:r(h9,{nodeId:e,refreshToken:t})},{id:"engines",label:"Warm instances",order:180,content:r(l9,{nodeId:e,refreshToken:t})},{id:"models",label:"Models",order:200,content:r(m9,{nodeId:e,refreshToken:t})}]})})]})}function k9({refreshToken:e}){const t=we(),n=cx({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(ev,{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(Ad,{className:"h-3.5 w-3.5"}),n.isPending?"Rebalancing…":"Rebalance pipelines"]})]}),r(rv,{mode:"cluster"})]})}const S9=["pipeline-orchestrator"];function C9({refreshToken:e}){return r("div",{className:"space-y-4 max-w-3xl",children:r(Gr,{nodeId:"hub",addonIds:S9,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 M9({refreshToken:e}){const t=we(),{data:n,isLoading:o}=Cx(),[s,a]=P(null),[i,l]=P(""),[c,d]=P(""),p=()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","listTemplates"]]})},f=Mx({onSuccess:()=>{a(null),p()}}),m=Ax({onSuccess:p}),h=v=>{a(v.id),l(v.name),d(v.description??"")},g=()=>{a(null),l(""),d("")},x=()=>{if(!s)return;const v=c.trim();f.mutate({id:s,name:i.trim()||"Untitled",...v?{description:v}:{}})};if(o)return r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading templates…"});const b=[...n??[]].sort((v,w)=>v.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:[b.length," template",b.length===1?"":"s"]})]}),b.length===0?u("div",{className:"px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2",children:[r(kt,{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:b.map(v=>{const w=s===v.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:y=>l(y.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:y=>d(y.target.value),placeholder:"Description (optional)"})]}):u(ue,{children:[r("div",{className:"font-medium text-foreground",children:v.name}),v.description&&r("div",{className:"text-foreground-subtle mt-0.5",children:v.description}),u("div",{className:"mt-1 font-mono text-[10px] text-foreground-subtle",children:["engine ",v.config.engine.runtime,"/",v.config.engine.backend," · ",v.config.steps.length," step(s)",v.config.audio?.enabled?" · audio":"",u("span",{className:"ml-2",children:["updated ",new Date(v.updatedAt).toLocaleString()]})]})]})}),r("div",{className:"flex items-center gap-1 shrink-0",children:w?u(ue,{children:[u("button",{type:"button",onClick:x,disabled:f.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(At,{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(Be,{className:"h-3 w-3"}),"Cancel"]})]}):u(ue,{children:[r("button",{type:"button",onClick:()=>h(v),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(Qr,{className:"h-3 w-3"})}),r("button",{type:"button",onClick:()=>{confirm(`Delete template "${v.name}"?`)&&m.mutate({id:v.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(We,{className:"h-3 w-3"})})]})})]})},v.id)})})]})})}function Qp(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 A9({nodeId:e,refreshToken:t}){const n=we(),o=Le().trpcClient,[s,a]=P(null),[i,l]=P(null),c=Hr(void 0,{refetchOnMount:"always"});Qt(["nodes","topology"],["agent.online","agent.offline","agent.unregistered","addon.installed","addon.uninstalled","addon.updated"]);const d=Dn(void 0,{staleTime:3e4,refetchOnMount:"always"}),p=V(()=>{const I=new Set;for(const z of d.data??[])z.isOnline&&I.add(z.id);return I},[d.data]),f=jo({nodeId:e},{refetchOnMount:"always"}),m=V(()=>(c.data??[]).filter(I=>p.has(I.nodeId)).map(I=>I.nodeId),[c.data,p]),h=Dr({enabled:m.length>0,queryKey:[["pipelineExecutor","getSchema"],"schema-by-agent",m.join(","),t],queryFn:async()=>{const I={};for(const z of m)try{const A=await o.pipelineExecutor.getSchema.query({nodeId:z});I[z]=A.selectedEngine.format}catch{I[z]="coreml"}return I}}),g=Gc({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator"]]}),n.invalidateQueries({queryKey:[["pipelineExecutor"]]}),n.invalidateQueries({queryKey:[["addonSettings"]]})}}),x=V(()=>f.data?ba(f.data):[],[f.data]),b=V(()=>{const I=c.data??[],z=p;return(z.size===0?[]:I.filter(T=>z.has(T.nodeId))).map(T=>{const R=h.data?.[T.nodeId];return{agentNodeId:T.nodeId,engineLabel:R??"(engine unknown)"}})},[c.data,h.data,p]),v=(I,z)=>{const T=c.data?.find(L=>L.nodeId===z)?.settings.addonDefaults[I],R=h.data?.[z];return Qp(f.data??null,I)?.models.some(L=>R!==void 0&&!!L.formats[R])?T?T.enabled?{kind:"enabled",modelId:T.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},w=s?c.data?.find(I=>I.nodeId===s.agentNodeId)??null:null,y=s&&f.data?Qp(f.data,s.addonId):null,N=s?h.data?.[s.agentNodeId]??"coreml":"coreml",k=()=>{a(null),l(null)},C=(I,z)=>{const T=c.data?.find(R=>R.nodeId===z)?.settings.addonDefaults[I]??null;a({addonId:I,agentNodeId:z}),l(T)},D=()=>{!i||!s||!w||g.mutate({agentNodeId:s.agentNodeId,defaults:{...w.settings.addonDefaults,[s.addonId]:i}},{onSuccess:k})};if(c.isLoading||f.isLoading)return r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading agents…"});if(!f.data)return u("div",{className:"text-xs text-foreground-subtle",children:["Catalog unavailable for ",e,"."]});const E=s!==null&&y!==null&&i!==null;return u("div",{className:"relative h-full w-full space-y-3",children:[r(sv,{title:"Cluster cameras"}),r("div",{className:E?"pr-[360px]":"",children:x.length>0&&b.length>0?r(kc,{tree:x,agents:b,getCellState:v,onCellClick:C,selectedCell:s}):r("div",{className:"text-xs text-foreground-subtle",children:"No agents or catalog empty."})}),r(Nc,{open:E,onClose:k,title:y?.name??"",subtitle:s?`${s.agentNodeId} · ${N}`:"",footer:u(ue,{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:D,children:g.isPending?"Saving…":"Save"})]}),children:y&&i&&s&&r(ya,{mode:"agent",addon:y,agentDefault:i,agentNodeId:s.agentNodeId,engineFormat:N,onChangeAgentConfig:I=>l(I)})})]})}const E9=[{id:"assignments",label:"Assignments"},{id:"pipeline",label:"Pipeline"},{id:"settings",label:"Settings"},{id:"templates",label:"Templates"}];function I9({refreshToken:e}){const[t,n]=P("assignments"),{data:o}=Dn(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:E9.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(k9,{refreshToken:e}),t==="pipeline"&&(s?r(A9,{nodeId:s,refreshToken:e}):r("div",{className:"text-xs text-foreground-subtle",children:"No online node available — schema unreachable."})),t==="settings"&&r(C9,{refreshToken:e}),t==="templates"&&r(M9,{refreshToken:e})]})]})}const mo="__cluster__";function P9(){const[e,t]=Ia(),n=e.get("node")??mo,[o,s]=P(0);return Y(()=>{e.get("node")||t({node:mo},{replace:!0})},[e,t]),u("div",{className:"flex flex-col h-full overflow-hidden",children:[r("div",{className:"flex items-center justify-end gap-4 px-4 py-3 border-b border-border shrink-0",children: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(it,{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(Z7,{selectedNodeId:n,onSelect:i=>{t({node:i},{replace:!0})},refreshToken:o})}),r("section",{className:"flex-1 min-h-0 overflow-hidden",children:n===mo?r(I9,{refreshToken:o}):r(N9,{nodeId:n,refreshToken:o})})]})]})}const _9="device-export",Li="export",$9="Export";function Dl(e){return e.type==="separator"||e.type==="info"||e.type==="object-array"||e.type==="widget"||e.type==="addon-action-button"?!1:e.type==="group"?e.fields.some(Dl):e.type==="sub-tabs"?e.tabs.some(t=>t.fields.some(Dl)):e.writerCapName===_9}function Co(e){return e.fields.some(Dl)}const D9={streaming:{icon:O0,label:"Streaming"},detection:{icon:$a,label:"Detection"},recording:{icon:N0,label:"Recording"},audio:{icon:Cl,label:"Audio"},snapshot:{icon:Nr,label:"Snapshot"},motion:{icon:Ad,label:"Motion"},ptz:{icon:Wt,label:"PTZ"},webrtc:{icon:La,label:"WebRTC"},onvif:{icon:uO,label:"ONVIF"},analytics:{icon:Ot,label:"Analytics"},"battery-operated":{icon:iR,label:"Battery"},"native-snapshot":{icon:Nr,label:"Native Snapshot"},"pan-tilt-zoom":{icon:Wt,label:"PTZ"},"two-way-audio":{icon:Cl,label:"Two-way Audio"},"doorbell-button":{icon:Uo,label:"Doorbell"},rebootable:{icon:it,label:"Rebootable"}},L9=wd;function za({capabilities:e,showLabels:t=!1}){return r("div",{className:"flex items-center gap-1 flex-wrap",children:e.map(n=>{const o=D9[n],s=o?.icon??L9,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)})})}function T9(e){const t=Le();return Zy(t.trpcClient,e)}function R9(e){const[t,n]=P("idle"),[o,s]=P(null),a=re(null),i=re(null),l=re(null),c=re(!0),d=Ab(),p=Eb(),f=Ib(),m=U(()=>{if(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},[]),h=U(async()=>{if(t==="idle")return;n("stopping");const x=l.current;if(x&&e!==null)try{await Promise.race([f.mutateAsync({deviceId:e,sessionId:x}),new Promise((v,w)=>setTimeout(()=>w(new Error("server stopSession timeout")),2e3))])}catch(v){console.warn("[intercom] server stopSession failed (continuing teardown)",v)}m(),c.current&&(n("idle"),s(null))},[t,e,f,m]),g=U(async()=>{if(e===null||t!=="idle"&&t!=="error")return;s(null);let x=null,b=null,v=null;try{n("requesting-mic"),x=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),i.current=x,n("starting");const w=await d.mutateAsync({deviceId:e});v=w.sessionId,l.current=v,n("connecting"),b=new RTCPeerConnection,a.current=b,b.oniceconnectionstatechange=()=>{if(!c.current)return;const k=b.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 x.getAudioTracks())b.addTrack(k,x);await b.setRemoteDescription({type:"offer",sdp:w.sdpOffer});const y=await b.createAnswer();await b.setLocalDescription(y);const N=b.localDescription?.sdp??y.sdp??"";await p.mutateAsync({deviceId:e,sessionId:v,sdpAnswer:N})}catch(w){const y=w instanceof Error?w.message:String(w);if(console.warn("[intercom] start failed",w),b)try{b.close()}catch{}if(x)for(const N of x.getTracks())try{N.stop()}catch{}if(a.current=null,i.current=null,v!==null)try{await f.mutateAsync({deviceId:e,sessionId:v})}catch{}l.current=null,c.current&&(s(y),n("error"))}},[e,t,d,p,f,h]);return Y(()=>(c.current=!0,()=>{c.current=!1;const x=l.current;if(x!==null&&e!==null&&f.mutate({deviceId:e,sessionId:x}),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}),[e]),{state:t,error:o,start:g,stop:h,isTalking:t==="talking"}}let O9=0;function ct(){return++O9}function Ti(e){switch(e.type){case"system":return"system";case"device":return`#${e.deviceId}`;case"provider":return e.providerId;case"addon":return e.addonId}}function z9(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 B9(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 F9(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 j9({scope:e,greeting:t,className:n}){const o=Le(),[s,a]=P(()=>{const y=[];return t&&y.push({id:ct(),kind:"info",text:t}),y.push({id:ct(),kind:"info",text:`scope: ${Ti(e)} — type help or context for available commands`}),y}),[i,l]=P(""),[c,d]=P([]),[p,f]=P(-1),m=re(null),h=re(null);Y(()=>{const y=h.current;y&&(y.scrollTop=y.scrollHeight)},[s]);const g=U(()=>{m.current?.focus()},[]),x=Hn({mutationFn:y=>o.trpcClient.repl.execute.mutate({code:y,scope:e}),onSuccess:y=>{const N=y??{},k=typeof N.output=="string"?N.output:y==null?"undefined":typeof y=="string"?y:JSON.stringify(y,null,2),C=N.type==="error";a(D=>[...D,{id:ct(),kind:C?"error":"result",text:k}])},onError:y=>{const N=y instanceof Error?y.message:String(y);a(k=>[...k,{id:ct(),kind:"error",text:N}])}});function b(y){const N=y.trim();if(N){if(N==="clear"){a([{id:ct(),kind:"info",text:`scope: ${Ti(e)}`}]),l("");return}if(N==="help"){a(k=>[...k,{id:ct(),kind:"input",text:`> ${N}`},...z9(e).map(C=>({id:ct(),kind:"info",text:C}))]),l("");return}if(N==="context"){a(k=>[...k,{id:ct(),kind:"input",text:`> ${N}`},...F9(e).map(C=>({id:ct(),kind:"info",text:C}))]),l("");return}if(N==="examples"){a(k=>[...k,{id:ct(),kind:"input",text:`> ${N}`},...B9(e).map(C=>({id:ct(),kind:"info",text:C}))]),l("");return}d(k=>[...k,N]),f(-1),a(k=>[...k,{id:ct(),kind:"input",text:`> ${N}`}]),l(""),x.mutate(N)}}function v(y){if(y.key==="Enter"){y.preventDefault(),b(i);return}if(y.key==="ArrowUp"){if(y.preventDefault(),c.length===0)return;const N=p===-1?c.length-1:Math.max(0,p-1);f(N),l(c[N]??"");return}if(y.key==="ArrowDown"){if(y.preventDefault(),p===-1)return;const N=p+1;N>=c.length?(f(-1),l("")):(f(N),l(c[N]??""));return}y.ctrlKey&&y.key==="l"&&(y.preventDefault(),a([{id:ct(),kind:"info",text:`scope: ${Ti(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(y=>r("pre",{className:`whitespace-pre-wrap break-words leading-relaxed ${w[y.kind]}`,children:y.text},y.id)),x.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:y=>l(y.target.value),onKeyDown:v,disabled:x.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 H9({deviceId:e,intercomAvailable:t=!1}){const n=Le(),o=typeof window<"u"?window.location.origin:"",s=Number.isFinite(e),a=T9(s?e:null),{streams:i,pipelineMetrics:l,createSession:c,sendAnswer:d,closeSession:p}=Xy(n.trpcClient,s?e:null),f=Ic(n.trpcClient,s?e:null),m=R9(s&&t?e:null),h=m.state==="requesting-mic"||m.state==="starting"||m.state==="connecting"||m.state==="stopping",g=m.isTalking||h,x=()=>{m.state==="idle"||m.state==="error"?m.start():m.state!=="stopping"&&m.stop()},b=hy(),v=b.length>0?r(ue,{children:b.map(w=>r("div",{className:"absolute inset-0",children:w.node},w.id))}):null;return r(Ay,{serverUrl:o,createSession:c,sendAnswer:d,closeSession:p,streams:i,pipelineMetrics:l,phase:a.phase,detections:a,defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:f.src,snapshotLoading:f.loading,onRefreshSnapshot:f.refresh,intercomAvailable:t,intercomShown:g,onIntercomToggle:x,extraOverlay:v,chromeless:!0,className:"h-full"})}function V9({deviceId:e}){return Number.isFinite(e)?r("div",{className:"flex flex-col h-full",children:r(Zt,{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 U9({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(`
|
|
1136
|
+
`);return r(j9,{scope:{type:"device",deviceId:e},greeting:t,className:"h-full border-0 rounded-none"})}function q9({deviceId:e}){return Number.isFinite(e)?r("div",{className:"flex flex-col h-full overflow-y-auto",children:r(sr,{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 Q9({deviceId:e}){return Number.isFinite(e)?r("div",{className:"flex flex-col h-full overflow-y-auto",children:r(id,{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 G9({parentDeviceId:e}){const{t}=Bt(),n=rt(),o=Le(),{data:s,isLoading:a,isError:i}=nv(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(f=>!!f.role),d=l.some(f=>!f.role),p=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:p}),r("div",{className:"space-y-1",children:l.map(f=>r(vo,{trpc:o.trpcClient,device:f,variant:"minimal",onNavigate:m=>n(`/devices/${String(m)}`)},f.id))})]})}function on({label:e,value:t}){return u("div",{className:`${Jm} 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 K9({deviceId:e,initialName:t}){const n=we(),[o,s]=P(!1),[a,i]=P(t),[l,c]=P(!1),d=re(null);Y(()=>{o||i(t)},[t,o]),Y(()=>{o&&d.current?.focus()},[o]);const p=ab({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDevice"]]}),n.invalidateQueries({queryKey:[["deviceManager","listAll"]]}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]})}}),f=async()=>{const h=a.trim();if(h.length===0||h===t){s(!1),i(t);return}c(!0);try{await p.mutateAsync({deviceId:e,name:h}),s(!1)}catch{}finally{c(!1)}},m=()=>{i(t),s(!1)};return o?r(on,{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"?f():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 f(),disabled:l,className:"p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50","aria-label":"Save",children:r(At,{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(Be,{className:"h-3 w-3"})})]})}):r(on,{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(Qr,{className:"h-3 w-3 text-foreground-subtle"})})]})})}function W9({deviceId:e,initialLocation:t}){const n=we(),[o,s]=P(!1),[a,i]=P(t??""),[l,c]=P(!1),d=re(null),{data:p}=lb(void 0,{staleTime:3e4,enabled:o}),f=p??[];Y(()=>{o||i(t??"")},[t,o]),Y(()=>{o&&d.current?.focus()},[o]);const m=ib({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDevice"]]}),n.invalidateQueries({queryKey:[["deviceManager","listAll"]]}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]}),n.invalidateQueries({queryKey:[["deviceManager","listLocations"]]})}}),h=V(()=>{const v=a.trim().toLowerCase();return v.length===0?f:f.filter(w=>w.toLowerCase()!==v&&w.toLowerCase().includes(v))},[f,a]),g=a.trim().length>0&&!f.some(v=>v.toLowerCase()===a.trim().toLowerCase()),x=async v=>{const y=(v??a).trim(),N=y.length===0?null:y;if(N===(t??null)){s(!1);return}c(!0);try{await m.mutateAsync({deviceId:e,location:N}),s(!1)}catch{}finally{c(!1)}},b=()=>{i(t??""),s(!1)};return o?r(on,{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:v=>i(v.target.value),onKeyDown:v=>{v.key==="Enter"?x():v.key==="Escape"&&b()},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 x(),disabled:l,className:"p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50","aria-label":"Save",children:r(At,{className:"h-3 w-3"})}),r("button",{type:"button",onClick:b,disabled:l,className:"p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50","aria-label":"Cancel",children:r(Be,{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(v=>u("button",{type:"button",onClick:()=>{i(v),x(v)},className:"w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover",children:[r(k6,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),r("span",{className:"truncate",children:v})]},v)),g&&u("button",{type:"button",onClick:()=>void x(),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(on,{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(Qr,{className:"h-3 w-3 text-foreground-subtle"})})]})})}const Gp=["manufacturer","model","hardware","firmware","serialNumber","uid","mac","itemNo"];function Y9(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}function Z9(e){return e==null?"—":typeof e=="string"||typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e)}function X9(){const e=Dc(),t=Ng(),{data:n}=vr({deviceId:e??0},{enabled:e!==null,staleTime:3e4}),o=n??t??null,[s,a]=P("identity");if(e===null||!o)return null;const i=String(o.stableId??""),l=String(o.name??""),c=String(o.type??""),d=String(o.addonId??""),p=o.features??[],f=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(Kp,{active:s==="identity",onClick:()=>a("identity"),label:"Identity"}),r(Kp,{active:s==="hardware",onClick:()=>a("hardware"),label:"Hardware"})]})]}),(!h||s==="identity")&&u("div",{className:"divide-y divide-border",children:[r(on,{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(K9,{deviceId:e,initialName:l}),r(W9,{deviceId:e,initialLocation:f}),r(on,{label:"Type",value:c}),r(on,{label:"Provider",value:r(pn,{type:d,size:"sm",showLabel:!0})}),r(on,{label:"Capabilities",value:p.length>0?r(za,{capabilities:p,showLabels:!0}):r("span",{className:"text-[11px] text-foreground-subtle",children:"None"})})]}),h&&s==="hardware"&&r(J9,{metadata:m})]})}function Kp({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 J9({metadata:e}){const t=Gp.filter(s=>s in e),n=Object.keys(e).filter(s=>!Gp.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(on,{label:Y9(s),value:r("span",{className:"font-mono text-[11px] text-foreground break-all",children:Z9(e[s])})},s))})]})}function Ri(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function ez({device:e}){const t=rt(),n=typeof e.id=="number"?e.id:null,o=String(e.type??""),s=o===ut.Camera,a=o===ut.Hub,i=e.features??[],{data:l}=Qb({deviceId:n??0},{enabled:n!==null&&s,refetchInterval:5e3}),c=l?.streams??{},d=Object.entries(c),p=i.includes(Cs.DoorbellButton),f=Jy(p?{deviceId:n??void 0,historyLimit:10}:void 0),m=f.latest?Date.now()-f.latest.timestamp<3e4:!1;return u("div",{className:"space-y-5",children:[a&&n!==null&&r(Vy,{deviceId:n,onOpenChild:h=>t(`/devices/${h}`)}),s&&n!==null&&r(wr,{widgetId:"pipeline-orchestrator/pipeline-quick-stats",host:"device-tab",deviceId:n}),p&&r(Gy,{history:f.history,latestIsFresh:m}),s&&n!==null&&r(wr,{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(Sr,{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(ps,{label:"Nominal",value:Ri(g.nominalBitrateKbps??0)}),r(ps,{label:"Observed",value:Ri(g.observedBitrateKbps??0)}),r(ps,{label:"Peak",value:Ri(g.peakBitrateKbps??0)}),r(ps,{label:"Packet Loss",value:`${(g.packetLossPercent??0).toFixed(2)}%`,warning:(g.packetLossPercent??0)>1})]})]},h))})]}),r(X9,{})]})}function ps({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 tz({schema:e,values:t,pendingKeys:n,onChange:o,onAction:s,onSave:a,onDiscard:i,disabled:l}){const c=e.tabs??[],d=V(()=>{const k=new Map;for(const C of e.sections){const D=C.tab??"general",E=k.get(D)??[];E.push(C),k.set(D,E)}return k},[e.sections]),p=new Set(c.map(k=>k.id)),f=[...c,...[...d.keys()].filter(k=>!p.has(k)).map(k=>({id:k,label:k,icon:"wrench",order:100}))],m=f[0]?.id??"general",[h,g]=P(m),x=d.get(h)??[],v={sections:x.length<=1?x.length===1?[{...x[0],title:""}]:x:x.every(C=>!C.title)?[{...x[0],title:"",fields:x.flatMap(C=>C.fields)}]:x},w=r(av,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>i(n),saving:l});if(f.length<=1)return u("div",{className:"flex flex-col gap-3",children:[r(En,{schema:e,values:t,onChange:o,onAction:s,disabled:l}),w]});const y=new Map,N=new Map;for(const[k,C]of d){y.set(k,C.length);const D=new Set,E=z=>{for(const A of z)if("key"in A&&typeof A.key=="string"&&D.add(A.key),A.type==="group")E(A.fields);else if(A.type==="sub-tabs")for(const T of A.tabs)E(T.fields)};for(const z of C)E(z.fields);const I=n.filter(z=>D.has(z)).length;I>0&&N.set(k,I)}return u("div",{className:"flex flex-col gap-3",children:[r(iv,{tabs:f.map(k=>({id:k.id,label:k.label})),activeId:h,onChange:g,countByTab:y,pendingByTab:N}),r(En,{schema:v,values:t,onChange:o,onAction:s,disabled:l}),w]})}function nz(e,t){return t&&t==="admin"?e:!0}function rz(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):Co(o)&&Co(s)?o.id.localeCompare(s.id):(o.order??0)-(s.order??0)})};return e.tabs?{...n,tabs:e.tabs}:n}function dv(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="widget"||e.type==="addon-action-button"}function uv(e){return e.key}function oz(e){if(!dv(e))return e.value}function pv(e){return dv(e)?null:e}function Xs(e,t){for(const n of e)if(t(n),n.type==="group")Xs(n.fields,t);else if(n.type==="sub-tabs")for(const o of n.tabs)Xs(o.fields,t)}function sz(e){if(!e)return{};const t={};for(const n of e.sections)Xs(n.fields,o=>{const s=uv(o);s!==null&&(t[s]=oz(o))});return t}function Wp(e,t){if(!e)return null;let n=null;for(const o of e.sections)if(Xs(o.fields,s=>{if(n!==null||uv(s)!==t)return;const a=pv(s);a&&a.writerCapName&&a.writerAddonId&&(n={capName:a.writerCapName,addonId:a.writerAddonId})}),n!==null)break;return n}function az(e){return{...e,fields:e.fields.map(fv)}}function fv(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="object-array"?e:{...e,readonlyField:!0}}function iz(e,t){return e&&{...e,sections:e.sections.map(n=>({...n,fields:n.fields.map(o=>{const s=pv(o);return s?nz(t,s.minRole)?o:fv(o):o})}))}}function Ll({deviceId:e,sectionFilter:t}){const n=we(),{user:o}=Xt(),s=o?.isAdmin===!0,a=re(!1),{data:i,isLoading:l}=jc({deviceId:e},{refetchInterval:()=>a.current?!1:2500,staleTime:6e4,enabled:Number.isFinite(e)}),{data:c}=vr({deviceId:e},{staleTime:6e4,enabled:Number.isFinite(e)}),d=i?.settings??null,p=i?.live??null,f=V(()=>{if(!d&&!p)return null;const T=d?.sections??[],R=(p?.sections??[]).map(az),M=[...T,...R],$=t?M.filter(t):M.filter(B=>B.location!=="top-tab"&&!Co(B));if($.length===0)return null;const L=new Set;for(const B of $)L.add(B.tab??"general");const F=[...d?.tabs??[],...(p?.tabs??[]).filter(B=>!(d?.tabs??[]).some(j=>j.id===B.id))].filter(B=>L.has(B.id));return F.length>0?{tabs:F,sections:$}:{sections:$}},[d,p,t]),m=V(()=>rz(f),[f]),h=V(()=>iz(m,s),[m,s]),g=V(()=>sz(h),[h]),x=Vx(),b=Vc(),v=gb({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]})}}),w={isPending:v.isPending,mutate:T=>{v.mutate({deviceId:e,changes:[...T]})}},y=U(T=>{const R=Object.entries(T).map(([M,$])=>{const L=Wp(h,M);return L?{writerCapName:L.capName,writerAddonId:L.addonId,key:M,value:$}:null}).filter(M=>M!==null);R.length>0&&w.mutate(R)},[h,w]),N=U(T=>{const R=Object.entries(T).map(([M,$])=>{const L=Wp(h,M);return L?{writerCapName:L.capName,writerAddonId:L.addonId,key:M,value:$}:null}).filter(M=>M!==null);R.length>0&&w.mutate(R)},[h,w]),k=lv({schema:h,serverValues:g,onImmediateSave:y,onDeferredSave:N}),{values:C,pendingKeys:D,handleChange:E,handleSave:I,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(Se,{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 A(T,R,M){if(T==="regenerate-rtsp-token"){const $=["rtspUrl:","regenerateToken:"].find(F=>R.startsWith(F));if(!$)throw new Error(`regenerate-rtsp-token: unrecognised key "${R}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);const L=R.slice($.length);if(!L)throw new Error(`regenerate-rtsp-token: key "${R}" has no streamId after prefix`);const O=`${e}/${L}`;await x.mutateAsync({brokerId:O}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]});return}if(T==="test-probe"){if(!c)return{status:"error",error:"Device metadata not loaded yet"};try{return await b.mutateAsync({addonId:c.addonId,type:c.type,key:R,value:M})}catch($){return{status:"error",error:$ instanceof Error?$.message:String($)}}}if(T==="refresh-driver-data"){await v.mutateAsync({deviceId:e,changes:[{writerCapName:"device-manager",writerAddonId:"device-manager",key:R,value:Date.now()}]});return}throw new Error(`[device-aggregate] unknown action "${T}"`)}return r(tz,{schema:h,values:C,pendingKeys:D,onChange:E,onAction:A,onSave:I,onDiscard:z,disabled:w.isPending})}function lz({deviceId:e}){return r("div",{className:"flex flex-col gap-3",children:r(Ll,{deviceId:e})})}const mv=6e4,Tl=60*mv,Yp=24*Tl;function Ba(e){if(e==null||e<=0)return"—";const t=Date.now()-e;return t<0||t<3e4?"just now":t<Tl?`${String(Math.floor(t/mv))}m ago`:t<Yp?`${String(Math.floor(t/Tl))}h ago`:`${String(Math.floor(t/Yp))}d ago`}function cz(e,t=new Date){const n=new Date(e);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()}function hv({dev:e,busy:t,setBusy:n}){const o=e?.motionTrigger,s=cn(e?.state.motionTrigger),[a,i]=P(!1);if(!o)return null;const l=s?.enabled===!0,c=s!==void 0,d=async()=>{if(t||!c)return;const f=!l;n(!0),i(!0);try{await o.setMotionTrigger({enabled:f})}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(Pa,{className:"h-3 w-3"}),r("span",{children:a?l?"Disabling…":"Enabling…":c?l?"On motion: on":"On motion: off":"On motion: …"})]})}function gv({deviceId:e,deviceName:t,useSiren:n=!1}){const o=Le(),s=Ct(o.trpcClient,e),a=cn(s?.state.switch),[i,l]=P(!1),c=a?.on??!1,d=a?.lastChangedAt??null,p=a!==void 0,f=n?Uo:$0,m=async()=>{if(!(i||!p||!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||!p||!s?.switch,title:p?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(f,{className:"h-10 w-10"})}),r(hv,{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:p?c?"On":"Off":"Unknown"}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:p?`Changed ${Ba(d)}`:"Awaiting state…"})]})]})}function dz({deviceId:e,deviceName:t}){const n=Le(),o=Ct(n.trpcClient,e),s=cn(o?.state.switch),a=cn(o?.state.brightness),i=s?.on??!1,l=s?.lastChangedAt??null,c=s!==void 0,d=a!==void 0,p=o?.brightness!==void 0,[f,m]=P(!1),[h,g]=P(a?.percentage??0);Y(()=>{a?.percentage!==void 0&&g(a.percentage)},[a?.percentage]);const x=async()=>{if(!(f||!c||!o?.switch)){m(!0);try{await o.switch.setState({on:!i})}finally{m(!1)}}},b=async()=>{if(!(f||!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:()=>{x()},disabled:f||!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(f6,{className:"h-9 w-9"})}),p?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:f||!i||!d,onChange:v=>g(Number(v.currentTarget.value)),onPointerUp:()=>{b()},onKeyUp:v=>{v.key==="Enter"&&b()},"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(hv,{dev:o,busy:f,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 ${Ba(l)}`:"Awaiting state…"})]})]})}function uz({deviceId:e}){const t=Le(),n=Ct(t.trpcClient,e),o=cn(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(q6,{className:"h-10 w-10"}):r(Pa,{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 ${Ba(a)}`:"Awaiting state…"})]})]})}function pz({deviceId:e}){const t=Le(),n=Ct(t.trpcClient,e),o=cn(n?.state.doorbell),s=o?.lastPressedAt??null,a=o!==void 0,i=s!==null&&Date.now()-s<6e4,[l,c]=P(0),[d,p]=P(null);return Y(()=>{s===null||s===d||(p(s),cz(s)&&c(f=>f+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(Uo,{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 ${Ba(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 fz({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(pn,{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(Oa,{status:o?"online":"offline"}),s.length>0&&r(za,{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 mz({deviceId:e}){const t=we(),n=nb({deviceId:e},{refetchInterval:1e4,retry:!1}),o=rb({onSuccess:()=>{t.invalidateQueries({queryKey:[["deviceDiscovery","listDiscovered"]]}),t.invalidateQueries({queryKey:[["deviceDiscovery","getStatus"]]})}}),s=V(()=>hz(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(Oi,{label:"Discovered",value:s.total,icon:r(Mn,{className:"h-3.5 w-3.5"})}),r(Oi,{label:"Adopted",value:s.adopted,accent:"success"}),r(Oi,{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(Se,{className:"h-3.5 w-3.5 animate-spin"}):r(it,{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(fs,{icon:r(Sr,{className:"h-3 w-3 text-emerald-500"}),label:`${s.online} online`}),r(fs,{icon:r(I0,{className:"h-3 w-3 text-amber-500"}),label:`${s.sleeping} sleeping`}),r(fs,{icon:r(z0,{className:"h-3 w-3 text-destructive"}),label:`${s.offline} offline`}),s.unknown>0?r(fs,{icon:r(DR,{className:"h-3 w-3 text-foreground-subtle"}),label:`${s.unknown} unknown`}):null]})]})}function hz(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 Oi({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 fs({icon:e,label:t}){return u("span",{className:"inline-flex items-center gap-1",children:[e,r("span",{children:t})]})}const gz=e=>r(gv,{...e,useSiren:!0}),bz={[ut.Switch]:gv,[ut.Siren]:gz,[ut.Light]:dz,[ut.Sensor]:uz,[ut.Button]:pz,[ut.Hub]:mz};function xz(e){const t=bz[e.deviceType]??fz;return r(t,{...e})}function Ed(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 Js(e){return new Date(e).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ea(e){return e.toISOString().slice(0,10)}function yz(e,t){return ea(e)===ea(t)}function oo(e){const t=new Date(e);return t.setHours(0,0,0,0),t}function vz(e){const t=new Date(e);return t.setHours(23,59,59,999),t}function It({className:e=""}){return r("div",{className:`animate-pulse rounded bg-foreground-subtle/10 ${e}`})}function Bn(){return u("div",{className:"flex items-center gap-3 px-4 py-3",children:[r(It,{className:"h-4 w-4"}),r(It,{className:"h-3 w-24"}),r(It,{className:"h-3 w-16 ml-auto"})]})}function Xr({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 Zp({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 wz({segments:e,selectedDate:t}){const n=oo(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:`${Js(a.startTime)} - ${Js(a.endTime)} (${Ed(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 Nz({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(T0,{className:"h-4 w-4 text-primary"}):r(qo,{className:"h-4 w-4"})}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-xs font-mono text-foreground",children:[Js(e.startTime)," - ",Js(e.endTime)]}),u("p",{className:"text-[10px] text-foreground-subtle",children:[Ed(e.duration),e.sizeBytes!=null&&` · ${St(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(Da,{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(Kt,{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(We,{className:"h-3.5 w-3.5"})})]})]})}function kz({deviceId:e}){const t=we(),[n,o]=P(()=>oo(new Date)),[s,a]=P(new Set),i=Bx({deviceId:e},{refetchInterval:5e3}),l=Rx({deviceId:e}),c=l.data?.streams[0]?.streamId??"stream0",d=Ox({deviceId:e,streamId:c,startTime:oo(n).getTime(),endTime:vz(n).getTime()}),p=zx({deviceId:e,streamId:c},{refetchInterval:3e4}),f=Fx({deviceId:e,dataCategory:"recording:main"}),m=U(()=>{t.invalidateQueries({queryKey:["recordingEngine","getPolicyStatus"]}),t.invalidateQueries({queryKey:["recordingEngine","getSegments"]}),t.invalidateQueries({queryKey:["recordingEngine","getStorageUsage"]})},[t]),h=Lx({onSuccess:m}),g={isPending:h.isPending,error:h.error,mutate:()=>{const L=l.data,O=L?{mode:L.mode,streams:L.streams,enabled:!0,preBufferSec:L.preBufferSec,postBufferSec:L.postBufferSec,scheduleRules:L.scheduleRules}:{mode:"continuous",streams:[{streamId:c,mode:"always"}],enabled:!0,preBufferSec:10,postBufferSec:5};h.mutate({deviceId:e,policy:O})}},x=Tx({onSuccess:m}),b=i.data??void 0,v=l.data??void 0,w=d.data??[],y=p.data,N=f.data??void 0,k=(b?.enabled??!1)&&(b?.activeStreams??0)>0,C=g.isPending||x.isPending,D=yz(n,new Date),E=V(()=>[...w].sort((L,O)=>new Date(O.startTime).getTime()-new Date(L.startTime).getTime()),[w]),I=V(()=>w.reduce((L,O)=>L+(O.duration??0),0),[w]),z=V(()=>w.reduce((L,O)=>L+(O.sizeBytes??0),0),[w]);function A(){k?x.mutate({deviceId:e}):g.mutate()}function T(){o(L=>{const O=new Date(L);return O.setDate(O.getDate()-1),oo(O)}),a(new Set)}function R(){D||(o(L=>{const O=new Date(L);return O.setDate(O.getDate()+1),oo(O)}),a(new Set))}function M(L){a(O=>{const F=new Set(O);return F.has(L)?F.delete(L):F.add(L),F})}function $(){s.size===E.length?a(new Set):a(new Set(E.map(L=>L.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(Xr,{children:"Recording Status"}),u("div",{className:"px-4 py-4 space-y-3",children:[r(It,{className:"h-10 w-full"}),r(It,{className:"h-4 w-48"})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(Xr,{children:"Segments"}),u("div",{className:"divide-y divide-border",children:[r(Bn,{}),r(Bn,{}),r(Bn,{})]})]})]}):u("div",{className:"space-y-4",children:[u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(Xr,{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(N0,{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&&b?`${b.mode} – ${b.activeStreams} stream(s)`:"No active recording session"})]})]}),r("button",{onClick:A,disabled:C,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(ue,{children:[r(qo,{className:"h-3.5 w-3.5"}),C?"Stopping...":"Stop Recording"]}):u(ue,{children:[r(Da,{className:"h-3.5 w-3.5"}),C?"Starting...":"Start Recording"]})})]}),k&&b&&u("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-[11px] text-foreground-subtle",children:[r(uo,{className:"h-3.5 w-3.5 text-primary flex-shrink-0"}),u("span",{children:[b.activeStreams," active stream",b.activeStreams!==1?"s":""," · mode: ",b.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(Xr,{children:u("span",{className:"flex items-center gap-1.5",children:[r(Wt,{className:"h-3.5 w-3.5"}),"Settings"]})}),l.isLoading?u("div",{className:"px-4 py-3 space-y-2",children:[r(It,{className:"h-3 w-32"}),r(It,{className:"h-3 w-40"}),r(It,{className:"h-3 w-28"})]}):u("div",{className:"divide-y divide-border",children:[r(Jr,{label:"Stream",value:c}),r(Jr,{label:"Pre-buffer",value:v?`${v.preBufferSec}s`:"N/A"}),r(Jr,{label:"Mode",value:v?.mode??"continuous"}),r(Jr,{label:"Retention",value:N?.retentionDays!=null?`${N.retentionDays} days`:"N/A"}),N?.retentionGb!=null&&r(Jr,{label:"Max Storage",value:`${N.retentionGb} GB`})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(Xr,{children:u("span",{className:"flex items-center gap-1.5",children:[r(Gs,{className:"h-3.5 w-3.5"}),"Storage"]})}),p.isLoading?u("div",{className:"px-4 py-3 space-y-2",children:[r(It,{className:"h-3 w-28"}),r(It,{className:"h-3 w-36"}),r(It,{className:"h-3 w-24"})]}):p.error?u("div",{className:"px-4 py-4 flex items-center gap-2 text-xs text-danger",children:[r(at,{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(Zp,{icon:Gs,label:"Total",value:y?.totalBytes!=null?St(y.totalBytes):"N/A"}),r(Zp,{icon:uo,label:"Segments",value:y?.segmentCount!=null?String(y.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(Nd,{className:"h-4 w-4"})}),u("div",{className:"flex items-center gap-1.5 text-xs text-foreground font-medium",children:[r(v0,{className:"h-3.5 w-3.5 text-foreground-subtle"}),D?"Today":ea(n)]}),r("button",{onClick:R,disabled:D,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(zt,{className:"h-4 w-4"})})]})]}),u("div",{className:"px-4 py-3 border-b border-border",children:[r(wz,{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":""]}),I>0&&u("span",{children:[Ed(I)," recorded"]}),z>0&&r("span",{children:St(z)})]})]}),E.length>0&&u("div",{className:"border-b border-border px-4 py-2 flex items-center justify-between",children:[r("button",{onClick:$,className:"text-[11px] text-foreground-subtle hover:text-foreground transition-colors",children:s.size===E.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(Kt,{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(We,{className:"h-3 w-3"}),"Delete"]})]})]}),d.isLoading?u("div",{className:"divide-y divide-border",children:[r(Bn,{}),r(Bn,{}),r(Bn,{}),r(Bn,{})]}):E.length===0?u("div",{className:"flex flex-col items-center justify-center py-12 text-foreground-subtle",children:[r(uo,{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:D?"Recorded clips will appear here as they are created":`No recordings found for ${ea(n)}`})]}):r("div",{className:"max-h-[400px] overflow-y-auto",children:E.map(L=>r(Nz,{segment:L,selected:s.has(L.id),onToggle:()=>M(L.id),onPlay:()=>{},onDownload:()=>{},onDelete:()=>{}},L.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(at,{className:"h-4 w-4 flex-shrink-0"}),"Failed to load recording status. Will retry automatically."]}),(g.error||x.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(at,{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: ${x.error instanceof Error?x.error.message:"Unknown error"}`]})]})}function Jr({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 Sz({deviceId:e}){const t=we(),n=Number.isFinite(e),{data:o}=vr({deviceId:e},{enabled:n}),s=typeof o?.type=="string"?o.type:"camera";Qt(["deviceManager","getBindings"],["capability.binding-changed"]);const{data:a,isLoading:i,isError:l,error:c}=fb({deviceId:e},{staleTime:3e4,enabled:n}),{data:d}=hb({deviceType:s},{staleTime:3e4,enabled:!!s}),p=mb({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 f=new Map,m={};for(const b of d??[])m[b.capName]=b.wrappers;for(const b of a?.entries??[])f.set(b.capName,{...b,wrappers:m[b.capName]??[]});for(const b of d??[])f.has(b.capName)||f.set(b.capName,{capName:b.capName,kind:"unbound",providerAddonId:"",providerNodeId:"",nativeAddonId:"",wrappers:b.wrappers});const h=[...f.values()].sort((b,v)=>b.capName.localeCompare(v.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(_a,{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,x=[{key:"capability",header:"Capability",render:b=>r("span",{className:"font-mono text-foreground",children:b.capName})},{key:"kind",header:"Kind",render:b=>r(Cz,{kind:b.kind})},{key:"provider",header:"Active Provider",render:b=>r("span",{className:"font-mono text-foreground-subtle",children:b.providerAddonId||r("span",{className:"opacity-40",children:"—"})})},{key:"node",header:"Node",render:b=>b.providerNodeId?r(Mz,{nodeId:b.providerNodeId}):r("span",{className:"text-[10px] opacity-40",children:"—"})},{key:"native",header:"Native",render:b=>r("span",{className:"font-mono text-foreground-subtle",children:b.nativeAddonId||r("span",{className:"opacity-40",children:"—"})})},{key:"wrapper",header:"Wrapper",render:b=>{const v=b.kind==="wrapped"?b.providerAddonId:null;return r(Az,{wrappers:b.wrappers,activeWrapperId:v,disabled:p.isPending,onPick:w=>{const y=v===w;p.mutate({deviceId:e,capName:b.capName,wrapperAddonId:w,active:!y})}})}}];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(zo,{columns:x,rows:h,rowKey:b=>b.capName,minWidthPx:720})]})}function Cz({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(An,{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(d6,{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(I6,{className:"h-3 w-3"}),"unbound"]})}function Mz({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 Az({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(At,{className:"h-3 w-3"}):r(D0,{className:"h-3 w-3"}),s]},s)})})}function Ez(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 Iz(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 Pz({agents:e,currentAgent:t,onPick:n}){const[o,s]=P(!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 _z({deviceId:e,refreshToken:t}){const n=we(),[o,s]=P(null),[a,i]=P(null),[l,c]=P(null),[d,p]=P(null),f=Kc({deviceId:e}),m=Hr(),h=qc({deviceId:e}),g=dx(),x=V(()=>{const $=h.data?.agentNodeId;if($)return $;const L=g.data?.find(O=>O.online)?.nodeId;return L||"hub"},[h.data?.agentNodeId,g.data]),b=a??x,v=jo({nodeId:b??""},{enabled:!!b}),w=Nx({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),c(null)}}),y=V(()=>v.data?ba(v.data):[],[v.data]),N=V(()=>{const $=f.data??null,L={};for(const O of m.data??[])for(const F of Object.keys(O.settings.addonDefaults)){const B=L[F]??[];B.push({agentNodeId:O.nodeId,state:Iz($,O.nodeId,F)}),L[F]=B}return L},[f.data,m.data]),k=o?Ez(v.data??null,o):null,C=b?m.data?.find($=>$.nodeId===b)??null:null,D=o&&C?C.settings.addonDefaults[o]??null:null,E=o&&b?f.data?.stepOverridesByAgent?.[b]?.[o]??null:null,I=v.data?.selectedEngine.format??"coreml",z=$=>{i($),c(null),p(null)},A=$=>{s($),c(null),p(null)},T=$=>{if(!b||!o||!v.data||!m.data)return;const L=m.data.find(B=>B.nodeId===$),O=m.data.find(B=>B.nodeId===b);if(!L||!O)return;const[F]=eh({source:{nodeId:L.nodeId,engine:{format:I},defaults:L.settings.addonDefaults},target:{nodeId:O.nodeId,engine:{format:I},defaults:O.settings.addonDefaults},catalog:v.data,addonIds:[o]});if(!F){p("no mirror result");return}if(F.outcome==="skip"){p(`skipped: ${F.reason??"no candidate"}`);return}c(F.patch),p(`${F.outcome} from ${$}`)},R=()=>{!b||!o||w.mutate({deviceId:e,agentNodeId:b,addonId:o,patch:l})},M=()=>{!b||!o||w.mutate({deviceId:e,agentNodeId:b,addonId:o,patch:null})};return m.isLoading||v.isLoading?r("div",{className:"text-xs text-foreground-subtle animate-pulse p-4",children:"Loading pipeline…"}):v.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(Gh,{tree:y,selectedAddonId:o,onSelect:A,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($=>r("button",{type:"button",onClick:()=>z($.nodeId),className:`px-3 py-1 text-xs ${b===$.nodeId?"bg-primary text-primary-foreground":"bg-surface hover:bg-muted"}`,children:$.nodeId},$.nodeId))})]}),r(Pz,{agents:(m.data??[]).map($=>$.nodeId),currentAgent:b,onPick:T}),d&&r("div",{className:"text-[10px] text-foreground-subtle",children:d})]}),D&&r(ya,{mode:"device",addon:k,agentDefault:D,agentNodeId:b??"",currentPatch:l??E,engineFormat:I,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:!E||w.isPending,onClick:M,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:!b||!o||w.isPending,onClick:R,children:w.isPending?"Saving…":"Save"})]})]})]})})]})}):r("div",{className:"text-xs text-foreground-subtle p-4",children:"Catalog unavailable."})}const $z=[{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 Dz(e){const t=e===ut.Camera;return $z.filter(n=>t||!n.cameraOnly).map(({id:n,label:o})=>({id:n,label:o}))}const Lz=[{id:"logs",icon:vt,label:"Logs"},{id:"repl",icon:R0,label:"REPL"},{id:"events",icon:Uo,label:"Events"},{id:"state",icon:k0,label:"State"}];function Tz(){const e=fd(),t=Number(e.deviceId),n=Number.isFinite(t),o=rt(),s=we(),a=et(),i=Le(),[l,c]=P("overview"),[d,p]=P("logs"),f="device-detail.left-col-width-px",[m,h]=P(()=>{if(typeof window>"u")return null;const pe=window.localStorage.getItem(f),le=pe?Number(pe):NaN;return Number.isFinite(le)&&le>0?le:null}),g=re(m);g.current=m;function x(pe){pe.preventDefault();const le=pe.clientX,Ce=pe.currentTarget.previousElementSibling?.getBoundingClientRect().width??m??0,ce=280,$e=Math.max(ce+50,Math.floor(window.innerWidth*.7)),Ie=lt=>{const ar=Math.max(ce,Math.min($e,Ce+(lt.clientX-le)));h(ar)},Xe=()=>{document.removeEventListener("mousemove",Ie),document.removeEventListener("mouseup",Xe);const lt=g.current;if(lt!==null)try{window.localStorage.setItem(f,String(Math.round(lt)))}catch{}document.body.style.userSelect="",document.body.style.cursor=""};document.body.style.userSelect="none",document.body.style.cursor="col-resize",document.addEventListener("mousemove",Ie),document.addEventListener("mouseup",Xe)}const{data:b,isLoading:v,isError:w}=vr({deviceId:t},{enabled:n,refetchInterval:5e3,retry:1}),{data:y}=jc({deviceId:t},{enabled:n,staleTime:3e4}),N=V(()=>{const pe=y?.settings?.sections??[],le=y?.live?.sections??[],Ce=[...pe,...le],ce=new Set;for(const Ie of Ce)Ie.location==="top-tab"&&Ie.tab&&ce.add(Ie.tab);return Ce.some(Co)&&ce.add(Li),[...ce].map(Ie=>{if(Ie===Li)return{id:Ie,label:$9,isAddonContrib:!0};const Xe=Xi[Ie];return{id:Ie,label:Xe?.label??Ie,isAddonContrib:!0}})},[y]),k=b,C=String(k?.name??e.deviceId??"Device"),D=k?.online===!0,E=D?"online":"offline",I=String(k?.addonId??"rtsp"),z=k?.features??[],A=k?.type,T=A===ut.Camera,R=typeof k?.parentDeviceId=="number"?k.parentDeviceId:null,{data:M}=vr({deviceId:R??0},{enabled:R!==null,staleTime:3e4}),$=nr(),L=V(()=>{const pe=new Set,le=[];for(const Ce of[...Dz(A),...N])pe.has(Ce.id)||(pe.add(Ce.id),le.push(Ce));return le},[A,N]),{data:O}=nv(n?t:0),F=(O??[]).length>0,B=V(()=>Lz.filter(({featureGate:pe})=>!pe||z.includes(pe)),[z]),{data:j}=wb({addonId:I},{enabled:!!I&&I!=="rtsp"}),H=pb({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]}),o(j?.id?`/integrations/${j.id}`:"/integrations")}}),_=db({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),q=ub({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),G=Dx(),Q=Fo({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),J=z.includes(Cs.Rebootable),Z=z.includes(Cs.BatteryOperated),X=Ec(i.trpcClient,Z&&n?t:null),[oe,he]=P(!1),ee=Ct(i.trpcClient,n?t:null),W=async()=>{if(!(oe||!ee)){he(!0);try{await ee.snapshot?.invalidateCache({});const pe=await ee.snapshot?.getSnapshot({});if(!pe)return;const le=`data:${pe.contentType};base64,${pe.base64}`,Ce=pe.contentType.includes("png")?"png":"jpg",ce=C.replace(/[^a-zA-Z0-9_.-]+/g,"_"),$e=new Date().toISOString().replace(/[:.]/g,"-"),Ie=document.createElement("a");Ie.href=le,Ie.download=`${ce}-${$e}.${Ce}`,document.body.appendChild(Ie),Ie.click(),document.body.removeChild(Ie)}finally{he(!1)}}},ne=_.isPending||q.isPending,{data:ie}=qc({deviceId:t},{enabled:n,refetchInterval:1e4}),fe=ie?.agentNodeId??null,te=typeof fe=="string"&&fe.length>0&&!fe.startsWith("addon:")?fe:void 0,{data:ye}=Ex({deviceId:t,...te?{nodeId:te}:{}},{enabled:n,refetchInterval:3e3,retry:!1});function ke(){if(!n)return null;switch(l){case"overview":return r(ez,{device:k??{}});case"config":return r(lz,{deviceId:t});case"pipeline":return r(_z,{deviceId:t,refreshToken:0});case"bindings":return r(Sz,{deviceId:t});case"recording":return r(kz,{deviceId:t});default:{const pe=l;return N.some(Ce=>Ce.id===pe)?pe===Li?r(Ll,{deviceId:t,sectionFilter:Co}):r(Ll,{deviceId:t,sectionFilter:Ce=>Ce.location==="top-tab"&&Ce.tab===pe}):null}}}return n?v?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||!b?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(wc,{items:[{label:"Integrations",onClick:()=>o("/integrations")},{label:j?.name??I,onClick:()=>j?.id&&o(`/integrations/${j.id}`)},{label:C}]})}),u("div",{className:"flex items-center gap-2 sm:gap-3",children:[r(pn,{type:I,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:C}),r(Oa,{status:E}),Z&&r(Pc,{status:X,variant:"full"})]}),R!==null&&M&&u("button",{type:"button",onClick:()=>o(`/devices/${R}`),className:"text-[10px] text-foreground-subtle hover:text-primary transition-colors mt-0.5 inline-flex items-center gap-1",title:`Open parent device ${M.name}`,children:[r("span",{children:"↑"}),r("span",{className:"truncate",children:String(M.name??`Device #${R}`)})]}),r("div",{className:"hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle",children:z.length>0&&r(za,{capabilities:z})})]}),ye&&r("div",{className:"hidden lg:flex",children:r(Rz,{metrics:ye})}),u("div",{className:"flex items-center gap-1 shrink-0",children:[u("button",{onClick:async()=>{await a({title:`Disable "${C}"?`,message:"The device will stop processing streams and events. You can re-enable it later.",confirmLabel:"Disable",variant:"danger"})&&q.mutate({deviceId:t})},disabled:ne,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($0,{className:"h-3.5 w-3.5"}),r("span",{className:"hidden sm:inline",children:ne?"Updating…":"Enabled"})]}),r("div",{className:"hidden sm:block h-5 w-px bg-border mx-1"}),r(Ky,{triggerClassName:"ml-1",items:[{id:"snapshot",label:"Take snapshot",description:"Fetch a fresh frame and download it.",icon:Nr,disabled:oe,onClick:()=>{W()}},{id:"reboot",label:"Reboot device",description:"Camera goes offline for ~30 seconds.",icon:qt,hidden:!J,disabled:G.isPending,danger:!0,onClick:async()=>{await a({title:`Reboot "${C}"?`,message:"The camera will go offline for around 30 seconds while the firmware reboots.",confirmLabel:"Reboot",variant:"danger"})&&G.mutate({deviceId:t})}},{id:"restart-addon",label:"Restart addon",description:`Bounces every device served by ${j?.name??I}.`,icon:it,disabled:Q.isPending,danger:!0,onClick:async()=>{await a({title:`Restart "${j?.name??I}"?`,message:`Restarting the addon will briefly disconnect every device served by it (not just "${C}"). Streams will reconnect automatically.`,confirmLabel:"Restart",variant:"danger"})&&Q.mutate({addonId:I})}},{id:"delete",label:"Delete device",description:"Remove the device and all its settings.",icon:We,separatorBefore:!0,disabled:H.isPending,danger:!0,onClick:async()=>{await a({title:`Delete "${C}"?`,message:"This will remove the device and all its settings. This action cannot be undone.",confirmLabel:"Delete",variant:"danger"})&&H.mutate({deviceId:t})}}]})]})]})]}),r(wg,{deviceId:t,device:k??void 0,children:r(my,{children:r(Yy,{children:u("main",{className:$?"flex-1 overflow-y-auto flex flex-col":"flex-1 min-h-0 overflow-hidden flex flex-row",children:[u("div",{className:$?"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:!$&&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(H9,{deviceId:t,intercomAvailable:z.includes(Cs.TwoWayAudio)}):r(xz,{deviceId:t,deviceName:C,deviceType:A??"unknown",provider:I,isOnline:D,features:z})}),u("div",{className:$?"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:B.map(({id:pe,label:le,icon:Ce})=>u("button",{onClick:()=>p(pe),title:le,className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors flex-shrink-0 ${d===pe?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,children:[r(Ce,{className:"h-3 w-3"}),le]},pe))})}),u("div",{className:$?"h-72 overflow-hidden":"flex-1 min-h-0 overflow-hidden",children:[d==="logs"&&r(V9,{deviceId:t}),d==="repl"&&r(U9,{deviceId:t}),d==="events"&&r(q9,{deviceId:t}),d==="state"&&r(Q9,{deviceId:t})]})]})]}),!$&&r("div",{role:"separator","aria-orientation":"vertical",title:"Drag to resize",onMouseDown:x,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:$?"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:L.map(pe=>{const le=l===pe.id;return u("button",{onClick:()=>c(pe.id),className:`relative flex-shrink-0 px-3 py-2 text-xs font-medium transition-colors ${le?"text-primary":"text-foreground-subtle hover:text-foreground"}`,children:[pe.label,le&&r("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 rounded-full bg-primary"})]},pe.id)})})}),u("div",{className:$?"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"&&F&&r(G9,{parentDeviceId:t}),ke()]})]})]})})})})]}):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 Rz({metrics:e}){const t=e.phase??"idle",n=Lr(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(Pa,{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(Ot,{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 bv({packageName:e,currentVersion:t,installSource:n,onInstall:o,onClose:s}){const a=n==="upload"||n==="local",{data:i,isLoading:l}=$g({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 p=window.innerHeight-d.bottom,f=d.top;p<280&&f>p?(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(Be,{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(Ta,{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(Se,{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,p=/-(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":p?"text-amber-400":"text-foreground"}`,children:c.version}),c.distTags.map(f=>r("span",{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${f==="latest"?"bg-emerald-500/15 text-emerald-400":f==="beta"?"bg-amber-500/15 text-amber-400":"bg-gray-500/15 text-gray-400"}`,children:f},f)),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(At,{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(Kt,{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"})]})}const Oz="device-export";function zz(e){return e.capabilities.some(t=>(typeof t=="string"?t:t.name)===Oz)}function Bz({isBundle:e,installSource:t,addonId:n,iconPath:o,color:s}){const[a,i]=P(!1),l=s?{backgroundColor:`${s.startsWith("#")?s:`#${s}`}26`}:void 0,c=e?"bg-indigo-500/20 text-indigo-700 dark:text-indigo-300":"bg-purple-500/20 text-purple-700 dark:text-purple-300",d=n&&o?`/api/addon-assets/${n}/${o}`:null,p=!!d&&!a;return u("div",{className:"relative flex-shrink-0",children:[r("div",{className:`h-9 w-9 rounded-lg flex items-center justify-center ${l?"":c}`,style:l,children:p?r("img",{src:d,alt:n,className:"h-5 w-5",onError:()=>i(!0)}):e?r(P0,{className:"h-4 w-4"}):r(Ks,{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(Ta,{className:"h-2.5 w-2.5 text-white"})})]})}function Fz({addonId:e}){const t=we(),{data:n="inherit"}=Tg({addonId:e},{staleTime:3e4}),o=Rg({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 Rl({addon:e,agents:t=[],clusterStatus:n,hideVersion:o,availableUpdate:s,onUpdate:a,isUpdating:i,bundle:l}){const[c,d]=P(!1),[p,f]=P(!1),[m,h]=P(!1),[g,x]=P(!1),[b,v]=P(!1),[w,y]=P("logs"),N=we(),k=et(),{manifest:C}=e,D=e.installedOn??[],E=!l&&!C.protected&&C.removable!==!1,I=!!l,z=l?.displayName??C.name,A=l?.packageName??C.packageName,T=l?.version??C.packageVersion??C.version,R=l?.installSource??e.installSource,M=l?l.bundle?.description??l.addons[0]?.manifest.description:C.description;!l&&(C.components&&C.components.length>0||t.length>=2);const $=kg({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]})}}),L=Fo({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]})}}),O=Tc({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]}),N.invalidateQueries({queryKey:[["integrations"]]})}}),F=Dg({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["alerts"]]})}}),B=e.health,j=B?.phase==="failed"&&!B.inGracePeriod,H=j&&B?.nextRetryAt&&!B.retrying;return u("div",{className:`rounded-lg border bg-surface overflow-hidden ${j?"border-red-500/50":"border-border"}`,children:[j&&B&&u("div",{className:"bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5",children:[r(T6,{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 #",B.retryCount,")"]}),r("div",{className:"text-[11px] text-foreground mt-0.5 break-words font-mono",children:B.lastError?.message??"Unknown error"}),H&&B.nextRetryAt&&u("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["Auto-retry at ",new Date(B.nextRetryAt).toLocaleTimeString()]})]}),u("button",{type:"button",disabled:F.isPending||B.retrying,onClick:_=>{_.stopPropagation(),F.mutate({packageName:A})},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(it,{className:`h-3 w-3 ${F.isPending||B.retrying?"animate-spin":""}`}),"Retry now"]})]}),u("div",{className:"flex items-start gap-3 px-4 py-3",children:[r(Bz,{isBundle:I||!!C.components&&C.components.length>1,installSource:R,addonId:I?l.addons[0]?.manifest.id:C.id,iconPath:I?l.bundle?.icon??l.addons[0]?.manifest.icon:C.icon,color:I?l.addons[0]?.manifest.color:C.color}),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:["(",A,")"]}),I&&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(P0,{className:"h-3 w-3"}),l.addons.length]})]}),M&&r("p",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-1",children:M}),!I&&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"||e.process.state==="failed"?"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(Se,{className:"h-3 w-3 animate-spin"}),"Updating to ",s,"…"]}):s&&a?u("button",{type:"button",onClick:_=>{_.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(Kt,{className:"h-3 w-3"}),s]}):null,u("button",{type:"button",onClick:_=>{_.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",R==="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(Nt,{className:"h-3 w-3 opacity-50"})]}),m&&r(bv,{packageName:A,currentVersion:T,...R?{installSource:R}:{},onInstall:_=>{h(!1),O.mutate({packageName:A,version:_})},onClose:()=>h(!1)})]})]}),!I&&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:_=>{_.stopPropagation(),L.mutate({addonId:C.id})},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-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors",children:[r(it,{className:`h-3 w-3 ${L.isPending?"animate-spin":""}`}),"Restart"]}),u("button",{type:"button",onClick:_=>{_.stopPropagation(),x(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(vt,{className:"h-3 w-3"}),"Logs"]}),!I&&u("button",{type:"button",onClick:_=>{_.stopPropagation(),v(!0)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${b?"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(Wt,{className:"h-3 w-3"}),"Settings"]}),r("div",{className:"flex-1"}),E&&u("button",{type:"button",onClick:async _=>{_.stopPropagation(),await k({title:`Uninstall ${C.name}?`,message:"This will remove the addon package and all its data. This action cannot be undone.",confirmLabel:"Uninstall",variant:"danger"})&&$.mutate({packageName:C.packageName})},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-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors",children:[r(We,{className:"h-3 w-3"}),$.isPending?"Removing...":"Uninstall"]})]}),n&&n.nodes.length>1&&!I&&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(_=>u("div",{className:"flex items-center gap-2 text-[10px]",children:[r("div",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${_.status==="offline"?"bg-muted-foreground/30":_.synced?"bg-success":"bg-amber-500"}`}),r("span",{className:"font-medium text-foreground min-w-[60px]",children:_.name}),r("span",{className:"font-mono text-foreground-subtle",children:_.version}),!_.synced&&_.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"}),_.status==="offline"&&r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground",children:"offline"}),_.synced&&_.status!=="offline"&&r("span",{className:"text-[9px] text-success",children:"synced"})]},_.nodeId))})]}),g&&!I&&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:()=>y("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:()=>y("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:_=>{_.stopPropagation(),x(!1)},className:"text-foreground-subtle hover:text-foreground",children:r(Be,{className:"h-3.5 w-3.5"})})]}),w==="logs"&&r(Zt,{addonId:C.id,maxHeight:"max-h-64",showFilters:!1}),w==="events"&&r(sr,{addonId:C.id,category:"addon.*",maxHeight:"max-h-64"})]}),I&&u(ue,{children:[r("button",{type:"button",onClick:()=>d(_=>!_),className:"w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors",children:c?r(AR,{className:"h-3.5 w-3.5 text-foreground-subtle"}):r(Nt,{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(_=>r(Rl,{addon:_,agents:t,hideVersion:!0},_.manifest.id))})]}),b&&!I&&r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:()=>v(!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:_=>_.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(Wt,{className:"h-4 w-4 text-primary"}),u("h2",{className:"text-sm font-semibold text-foreground",children:[z," Settings"]})]}),r("button",{onClick:()=>v(!1),className:"text-foreground-subtle hover:text-foreground transition-colors p-1 rounded",children:r(Be,{className:"h-4 w-4"})})]}),u("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[r(Gr,{nodeId:"hub",addonIds:[C.id],level:"global"}),zz(C)&&u("div",{children:[r("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Device export"}),r(sd,{addonId:C.id})]}),R==="npm"&&u("div",{children:[r("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Auto-Update"}),r(Fz,{addonId:C.id})]}),C.components&&C.components.length>0&&u("div",{children:[u("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Components (",C.components.length,")"]}),r("div",{className:"flex flex-wrap gap-1",children:C.components.map(_=>r("span",{className:"text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono",children:_},_))})]}),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:[D.length===0&&r("span",{className:"text-[10px] text-foreground-subtle",children:"Hub (local)"}),D.map(_=>r("span",{className:"rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle",children:_},_)),u("div",{className:"relative",children:[u("button",{type:"button",onClick:_=>{_.stopPropagation(),f(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(kt,{className:"h-3 w-3"}),"Add agent"]}),p&&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(_=>!_.isHub&&!D.includes(_.name)).map(_=>r("button",{type:"button",onClick:q=>{q.stopPropagation(),f(!1)},className:"w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors",children:_.name},_.id)),t.filter(_=>!_.isHub&&!D.includes(_.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:()=>v(!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 jz=".tgz,.tar.gz,.zip";function Hz({onUploadSuccess:e}){const[t,n]=P(!1),o=re(null),s=U(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=U(i=>{const l=i.target.files?.[0];l&&s(l),i.target.value=""},[s]);return u(ue,{children:[r("input",{ref:o,type:"file",accept:jz,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(Se,{className:"w-3.5 h-3.5 animate-spin"}):r(Ta,{className:"w-3.5 h-3.5"}),t?"Uploading...":"Upload"]})]})}function Vz(){const{data:e,isLoading:t,isError:n}=Ig(void 0,{staleTime:6e4}),[o,s]=P(null),[a,i]=P(null),l=_g({onError:d=>{i(d instanceof Error?d.message:String(d))},onSuccess:()=>{s(null)}});if(t)return r(zi,{children:r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading system packages…"})});if(n)return r(zi,{children:r("div",{className:"text-xs text-danger",children:"Failed to load system packages"})});const c=e??[];return c.length===0?r(ue,{}):u(ue,{children:[r(zi,{collapsible:!0,defaultCollapsed:!0,children:r("div",{className:"space-y-1.5",children:c.map(d=>r(Uz,{row:d,onUpdate:p=>s({packageName:d.packageName,fromVersion:d.currentVersion,toVersion:p})},d.packageName))})}),o!==null&&r(qz,{pending:o,onCancel:()=>{s(null),i(null)},onConfirm:()=>{i(null),l.mutate({packageName:o.packageName,version:o.toVersion})},isPending:l.isPending,error:a})]})}function zi({children:e,collapsible:t=!1,defaultCollapsed:n=!1}){const[o,s]=P(n),a=!t||!o,i=u("div",{className:"flex items-center gap-2",children:[t&&(o?r(zt,{className:"w-3.5 h-3.5 text-amber-700 shrink-0"}):r(Nt,{className:"w-3.5 h-3.5 text-amber-700 shrink-0"})),r(at,{className:"w-3.5 h-3.5 text-amber-700 shrink-0"}),r("span",{className:"text-[11px] font-medium text-amber-800",children:"System packages"}),r("span",{className:"text-[10px] text-foreground-subtle",children:"Updating these will restart the hub (~10s)."})]});return u("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/5 p-3 space-y-2",children:[t?r("button",{type:"button",onClick:()=>s(l=>!l),"aria-expanded":!o,className:"flex w-full items-center text-left",children:i}):i,a&&e]})}function Uz({row:e,onUpdate:t}){const[n,o]=P(!1),s=e.hasUpdate&&e.latestVersion!==null;return u("div",{className:"flex items-center justify-between gap-3 px-2 py-1.5 rounded bg-surface/50 border border-border",children:[u("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[r("span",{className:"font-mono text-[11px] text-foreground truncate",children:e.packageName}),e.description!==void 0&&r("span",{className:"text-[10px] text-foreground-subtle truncate",title:e.description,children:e.description})]}),u("div",{className:"flex items-center gap-2 shrink-0",children:[s&&u("button",{type:"button",onClick:()=>t(e.latestVersion),className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] rounded bg-amber-500/15 text-amber-800 hover:bg-amber-500/25 border border-amber-500/30 font-medium transition-colors",title:`Update to ${e.latestVersion}`,children:[r(Kt,{className:"w-3 h-3"}),"v",e.latestVersion]}),u("button",{type:"button",onClick:()=>o(a=>!a),className:["inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-mono font-medium border transition-colors",s?"border-amber-500/30 bg-amber-500/10 text-amber-800 hover:bg-amber-500/20":"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 hover:bg-emerald-500/20"].join(" "),title:"View all versions",children:["v",e.currentVersion,r(Nt,{className:"w-3 h-3 opacity-50"})]}),n&&r(bv,{packageName:e.packageName,currentVersion:e.currentVersion,onInstall:a=>{o(!1),t(a)},onClose:()=>o(!1)})]})]})}function qz({pending:e,onCancel:t,onConfirm:n,isPending:o,error:s}){return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:u("div",{className:"bg-surface border border-border rounded-md shadow-xl p-5 max-w-md w-full mx-4 space-y-3",children:[u("div",{className:"flex items-center gap-2",children:[r(at,{className:"w-4 h-4 text-amber-700"}),r("h3",{className:"text-sm font-medium text-foreground",children:"Update system package?"})]}),u("div",{className:"space-y-2 text-[11px] text-foreground-subtle",children:[u("div",{children:[r("span",{className:"font-mono text-foreground",children:e.packageName}),r("span",{className:"mx-1",children:"·"}),u("span",{className:"font-mono",children:["v",e.fromVersion]}),r("span",{className:"mx-1",children:"→"}),u("span",{className:"font-mono text-amber-700",children:["v",e.toVersion]})]}),r("div",{className:"rounded border border-amber-500/30 bg-amber-500/10 p-2 text-amber-800",children:"The hub will restart immediately after the install. Any in-flight requests will be dropped. The reconnect typically takes ~10 seconds."}),s!==null&&r("div",{className:"rounded border border-danger/40 bg-danger/10 p-2 text-danger",children:s})]}),u("div",{className:"flex justify-end gap-2 pt-1",children:[r("button",{type:"button",onClick:t,disabled:o,className:"px-3 py-1.5 text-[11px] rounded bg-surface hover:bg-surface-hover border border-border disabled:opacity-50",children:"Cancel"}),u("button",{type:"button",onClick:n,disabled:o,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] rounded bg-amber-500/20 text-amber-800 hover:bg-amber-500/30 border border-amber-500/40 font-medium disabled:opacity-50",children:[o?r(Se,{className:"w-3 h-3 animate-spin"}):r(Kt,{className:"w-3 h-3"}),"Update & restart"]})]})]})})}function Qz(e,t){const n=e??"hub-only";return n==="any-node"?!0:n==="hub-only"?t:!t}function Gz(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,i=t.declaration?.execution,l=t.manifest.execution,c=i?.placement??l?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...s?{process:s}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function Kz(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 tn(e){return"bundle"in e}function Wz({addons:e,clusterStatus:t,selectedNode:n,onRefresh:o,isRefreshing:s}){const a=we(),[i,l]=P(""),c=mN(i),[d,p]=P(!1),f=re(null);Y(()=>{if(!d)return;const _=q=>{f.current&&!f.current.contains(q.target)&&p(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[d]);const{data:m}=Rc({nodeId:n.id},{staleTime:5*6e4}),h=V(()=>{const _=new Map;for(const q of m??[])_.set(q.name,q.latestVersion);return _},[m]),[g,x]=P(null),[b,v]=P(null),w=ul({onMutate:_=>{x(_.name),v(null)},onSuccess:(_,q)=>{x(null);const G=_;if(G&&G.success===!1){v({name:q.name,message:G.error??"Update failed (no error message returned by server)"});return}a.invalidateQueries({queryKey:[["addons"]]}),a.invalidateQueries({queryKey:[["addons","listUpdates"]]})},onError:(_,q)=>{x(null),v({name:q.name,message:_ instanceof Error?_.message:String(_)})}}),{data:y}=Lg(void 0,{staleTime:3e4}),N=Og({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons","getAutoUpdateSettings"]]})}}),{data:k,isFetching:C}=Cg({query:c||void 0},{enabled:d,staleTime:6e4}),D=ul(),E=async()=>{const _=m??[];for(const q of _)await D.mutateAsync({name:q.name,version:q.latestVersion,nodeId:n.id});a.invalidateQueries({queryKey:[["addons"]]})},I=Tc({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),a.invalidateQueries({queryKey:[["addonPages"]]}),a.invalidateQueries({queryKey:[["capabilities"]]}),a.invalidateQueries({queryKey:[["integrations"]]})}}),[z,A]=P("type"),[T,R]=P(()=>typeof window>"u"?"grouped":window.localStorage.getItem("camstack.addons.viewMode")==="flat"?"flat":"grouped"),M=_=>{R(_),typeof window<"u"&&window.localStorage.setItem("camstack.addons.viewMode",_)},[$,L]=Ia(),O=$.get("capability"),F=V(()=>{let _=n.isHub?e:e.filter(q=>Qz(q.placement,n.isHub));return O&&(_=_.filter(q=>(q.manifest.capabilities??[]).some(Q=>(typeof Q=="string"?Q:Q.name)===O))),_},[e,n.isHub,O]),B=()=>{const _=new URLSearchParams($);_.delete("capability"),L(_,{replace:!0})},j=T==="flat"?F:Kz(F),H=V(()=>{const _=[...j];switch(z){case"type":_.sort((q,G)=>{const Q=tn(q)?0:1,J=tn(G)?0:1;if(Q!==J)return Q-J;const Z=tn(q)?q.bundle.displayName:q.manifest.name,X=tn(G)?G.bundle.displayName:G.manifest.name;return Z.localeCompare(X)});break;case"name":_.sort((q,G)=>{const Q=tn(q)?q.bundle.displayName:q.manifest.name,J=tn(G)?G.bundle.displayName:G.manifest.name;return Q.localeCompare(J)});break;case"source":_.sort((q,G)=>{const Q=tn(q)?q.bundle.installSource??"":q.installSource??"",J=tn(G)?G.bundle.installSource??"":G.installSource??"";return Q.localeCompare(J)});break}return _},[j,z]);return u("div",{className:"space-y-4",children:[b&&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 ",b.name]}),r("div",{className:"text-foreground-subtle font-mono",children:b.message})]}),r("button",{type:"button",onClick:()=>v(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:_=>A(_.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(_=>r("button",{type:"button",onClick:()=>M(_),className:`px-2.5 py-1.5 transition-colors capitalize ${T===_?"bg-primary/10 text-primary":"bg-transparent text-foreground-subtle hover:bg-surface-hover"}`,title:_==="grouped"?"Group multi-addon packages into a bundle card":"Show every addon as its own card",children:_},_))})]}),n.isHub&&u("div",{className:"flex items-center gap-1.5",children:[r(it,{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(_=>r("button",{type:"button",onClick:()=>N.mutate({channel:_}),disabled:N.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${y?.channel===_?_==="off"?"bg-gray-700 text-gray-200":_==="latest"?"bg-blue-500/20 text-blue-400":"bg-amber-500/20 text-amber-400":"bg-transparent text-foreground-subtle hover:bg-surface-hover"} ${_!=="off"?"border-l border-border":""}`,children:_},_))})]}),(m?.length??0)>0&&u("button",{type:"button",onClick:()=>void E(),disabled:D.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(Kt,{className:`w-3 h-3 ${D.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(it,{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:f,children:[r(L0,{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:_=>{l(_.target.value),p(!0)},onFocus:()=>p(!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"}),C&&r(Se,{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(_=>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:_.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:_.name}),u("span",{className:"text-[10px] text-foreground-subtle",children:["v",_.version]})]}),_.description&&r("div",{className:"text-[10px] text-foreground-subtle truncate",children:_.description})]}),_.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(At,{className:"h-3 w-3"}),_.installedVersion??"Installed"]}):u("button",{type:"button",onClick:()=>I.mutate({packageName:_.name}),disabled:I.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:[I.isPending?r(Se,{className:"h-3 w-3 animate-spin"}):r(Kt,{className:"h-3 w-3"}),"Install"]})]},_.name))})]})]}),r(Hz,{onUploadSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),o()}})]}),O&&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:O}),r("button",{type:"button",onClick:B,className:"ml-auto text-xs text-foreground-subtle hover:text-foreground underline",children:"Clear"})]}),F.length===0&&r("div",{className:"text-xs text-foreground-subtle",children:e.length===0?"No addons installed":O?`No installed addons declare the "${O}" 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(_=>{if(tn(_)){const Q=_.bundle.packageName,J=h.get(Q);return r(Rl,{addon:_.representative,clusterStatus:t?.[_.representative.manifest.id],bundle:_.bundle,availableUpdate:J,isUpdating:g===Q,onUpdate:J?()=>w.mutate({name:Q,version:J,nodeId:n.id}):void 0},Q)}const q=_.manifest.packageName,G=h.get(q);return r(Rl,{addon:_,clusterStatus:t?.[_.manifest.id],availableUpdate:G,isUpdating:g===q,onUpdate:G?()=>w.mutate({name:_.manifest.packageName,version:G,nodeId:n.id}):void 0},_.manifest.id)})})]})}function Yz(){const e=we(),{data:t,isLoading:n,isError:o}=hn(),{data:s}=Yb(void 0,{staleTime:15e3}),{data:a}=Dn(void 0,{staleTime:3e4,refetchInterval:1e4}),i=V(()=>{const b=new Map;b.set("hub",{id:"hub",name:"Hub",isHub:!0});for(const v of a??[]){const w=String(v.id??"");w&&b.set(w,{id:w,name:String(v.name??w),isHub:!!v.isHub})}return[...b.values()]},[a]),[l,c]=P("hub"),d=i.find(b=>b.id===l)??i[0],p=Mg(),f=Sg(),m=p.isPending||f.isPending,h=async()=>{await p.mutateAsync({nodeId:l}),await f.mutateAsync(),e.invalidateQueries({queryKey:[["addons"]]})},g=re(p);g.current=p,Y(()=>{g.current.mutate({nodeId:"hub"})},[]);const x=(t??[]).map(Gz).filter(b=>b!==null);return u(tt,{children:[u("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[r(Yh,{selectedNodeId:l,onSelect:c}),u("div",{className:"flex items-center gap-3 flex-wrap",children:[!n&&!o&&u("span",{className:"text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium",children:[x.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(it,{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"}),d.isHub&&r(Vz,{}),!n&&!o&&r(Wz,{addons:x,clusterStatus:s,selectedNode:d,onRefresh:()=>void h(),isRefreshing:m})]})}function Zz({value:e,size:t=192}){const[n,o]=P(null),[s,a]=P(null);if(Y(()=>{let d=!1;return _N(()=>import("./browser-BXdiCFWD.js").then(p=>p.b),[]).then(async p=>{if(d)return;const f=p.create;if(typeof f!="function"){a("qrcode.create() unavailable in installed version");return}try{const m=f(e,{errorCorrectionLevel:"M"});d||o(m)}catch(m){d||a(m instanceof Error?m.message:"QR generation failed")}}).catch(()=>{d||a("qrcode library not installed")}),()=>{d=!0}},[e]),s)return r("div",{className:"flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4",style:{width:t,height:t},children:"QR rendering unavailable — use the secret below."});if(!n)return r("div",{className:"flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse",style:{width:t,height:t},children:"Generating…"});const i=n.modules.size,l=t/i,c=[];for(let d=0;d<i;d++)for(let p=0;p<i;p++)n.modules.data[d*i+p]&&c.push(r("rect",{x:p*l,y:d*l,width:l,height:l,fill:"currentColor"},`${p}-${d}`));return u("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:"text-black",children:[r("rect",{x:0,y:0,width:t,height:t,fill:"white"}),c]})}const Xz={view:{icon:$a,cls:"bg-foreground-subtle/15 text-foreground-subtle"},create:{icon:Qr,cls:"bg-primary/15 text-primary"},delete:{icon:We,cls:"bg-danger/15 text-danger"}};function Jz(){const{user:e,logout:t}=Xt();if(!e)return r(tt,{children:r("div",{className:"text-xs text-foreground-subtle",children:"Not signed in."})});const n=e.isAdmin,o=e.scopes??[];return u(tt,{children:[u("div",{className:"rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3",children:[r("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base",children:e.username.slice(0,1).toUpperCase()}),u("div",{className:"flex-1 min-w-0",children:[r("div",{className:"text-sm font-semibold text-foreground truncate",children:e.username}),u("div",{className:"text-[11px] text-foreground-subtle",children:[n?"Administrator":"User"," · session id ",u("span",{className:"font-mono",children:[e.id.slice(0,8),"…"]})]})]})]}),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(Gn,{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."})]})]}),r(eB,{}),r(tB,{username:e.username}),o.length>0&&u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"px-4 py-2 border-b border-border",children:[r("div",{className:"text-xs font-semibold text-foreground",children:"Granted scopes"}),r("div",{className:"text-[10px] text-foreground-subtle",children:"Baked into your session token at login; sign out + back in to refresh after changes."})]}),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.type==="device"?s.targets.join(", "):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}=Xz[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))})]}),r("div",{className:"flex justify-end",children: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",children:[r(Md,{className:"h-3 w-3"}),"Sign out"]})})]})}function eB(){const e=Le(),[t,n]=P(""),[o,s]=P(""),[a,i]=P(""),[l,c]=P(null),d=Hn({mutationFn:h=>e.changeOwnPassword(h),onSuccess:()=>{c({kind:"success",msg:"Password updated."}),n(""),s(""),i("")},onError:h=>{c({kind:"error",msg:h instanceof Error?h.message:"Update failed"})}}),p=o.length>0&&a.length>0&&o!==a,f=o.length>0&&o.length<8,m=t.length>=1&&o.length>=8&&o===a;return u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"px-4 py-2.5 border-b border-border flex items-center gap-2",children:[r(C0,{className:"h-3.5 w-3.5 text-foreground-subtle"}),r("div",{className:"text-xs font-semibold text-foreground",children:"Change password"})]}),u("div",{className:"p-4 space-y-3",children:[r(Bi,{label:"Current password",value:t,onChange:n,autoComplete:"current-password"}),r(Bi,{label:"New password",value:o,onChange:s,autoComplete:"new-password",hint:"At least 8 characters."}),r(Bi,{label:"Confirm new password",value:a,onChange:i,autoComplete:"new-password"}),(p||f)&&r("div",{className:"text-[11px] text-danger",children:p?"Passwords do not match.":"New password must be at least 8 characters."}),l&&u("div",{className:`text-[11px] flex items-center gap-1 ${l.kind==="success"?"text-emerald-500":"text-danger"}`,children:[l.kind==="success"?r(co,{className:"h-3 w-3"}):r(kr,{className:"h-3 w-3"}),l.msg]}),r("div",{className:"flex justify-end",children:u("button",{onClick:()=>{c(null),d.mutate({currentPassword:t,newPassword:o})},disabled:!m||d.isPending,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:[d.isPending?r(Se,{className:"h-3 w-3 animate-spin"}):r(Cd,{className:"h-3 w-3"}),"Update password"]})})]})]})}function Bi({label:e,value:t,onChange:n,autoComplete:o,hint:s}){return u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:e}),r("input",{type:"password",value:t,onChange:a=>n(a.target.value),autoComplete:o,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"}),s&&r("div",{className:"text-[10px] text-foreground-subtle",children:s})]})}function tB({username:e}){const t=Le(),n=Dr({queryKey:["auth","getOwnTotpStatus"],queryFn:()=>t.getOwnTotpStatus()}),o=n.data,[s,a]=P(null),[i,l]=P(""),[c,d]=P(null),[p,f]=P(!1),m=Hn({mutationFn:()=>t.setupOwnTotp(),onSuccess:v=>{a({secret:v.secret,otpauthUrl:v.otpauthUrl}),l(""),d(null)},onError:v=>d(v instanceof Error?v.message:"Setup failed")}),h=Hn({mutationFn:v=>t.confirmOwnTotp(v),onSuccess:()=>{a(null),l(""),d(null),n.refetch()},onError:v=>d(v instanceof Error?v.message:"Confirmation failed — code did not match")}),g=Hn({mutationFn:()=>t.disableOwnTotp(),onSuccess:()=>{d(null),n.refetch()},onError:v=>d(v instanceof Error?v.message:"Disable failed")});Y(()=>{if(!p)return;const v=setTimeout(()=>f(!1),1500);return()=>clearTimeout(v)},[p]);const x=V(()=>n.isLoading?"loading":s?"setup_in_progress":o?.enabled?"enrolled":"not_enrolled",[n.isLoading,o?.enabled,s]),b=()=>{s&&navigator.clipboard.writeText(s.secret).then(()=>f(!0))};return u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"px-4 py-2.5 border-b border-border flex items-center gap-2",children:[r(kn,{className:"h-3.5 w-3.5 text-foreground-subtle"}),r("div",{className:"text-xs font-semibold text-foreground",children:"Two-factor authentication"})]}),u("div",{className:"p-4 space-y-3",children:[x==="loading"&&u("div",{className:"flex items-center gap-2 text-xs text-foreground-subtle",children:[r(Se,{className:"h-3.5 w-3.5 animate-spin"}),"Checking status…"]}),x==="not_enrolled"&&u(ue,{children:[r("div",{className:"text-xs text-foreground-subtle",children:"2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login."}),r("div",{className:"flex justify-end",children:u("button",{onClick:()=>{d(null),m.mutate()},disabled:m.isPending,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:[m.isPending?r(Se,{className:"h-3 w-3 animate-spin"}):r(kn,{className:"h-3 w-3"}),"Enable 2FA"]})})]}),x==="setup_in_progress"&&s&&u(ue,{children:[u("div",{className:"text-[11px] text-foreground-subtle",children:["Scan the QR code (or enter the secret manually) into your authenticator app for ",r("span",{className:"font-mono",children:e}),", then enter the 6-digit code below to confirm."]}),u("div",{className:"flex flex-col items-center gap-3",children:[r("div",{className:"rounded-lg border border-border bg-white p-3",children:r(Zz,{value:s.otpauthUrl,size:180})}),u("div",{className:"w-full",children:[r("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle mb-1",children:"Secret (manual entry)"}),u("div",{className:"flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5",children:[r("code",{className:"text-[11px] font-mono text-foreground break-all flex-1",children:s.secret}),u("button",{onClick:b,className:"inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground",children:[p?r(co,{className:"h-3 w-3 text-emerald-500"}):r(Qs,{className:"h-3 w-3"}),p?"Copied":"Copy"]})]})]})]}),u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"6-digit code"}),r("input",{type:"text",inputMode:"numeric",autoComplete:"one-time-code",placeholder:"123456",value:i,onChange:v=>l(v.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary"})]}),c&&u("div",{className:"text-[11px] text-danger flex items-center gap-1",children:[r(kr,{className:"h-3 w-3"}),c]}),u("div",{className:"flex justify-end gap-2",children:[r("button",{onClick:()=>{a(null),d(null),l("")},className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),u("button",{onClick:()=>{d(null),h.mutate({code:i})},disabled:h.isPending||i.length!==6,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:[h.isPending?r(Se,{className:"h-3 w-3 animate-spin"}):r(co,{className:"h-3 w-3"}),"Confirm"]})]})]}),x==="enrolled"&&o&&u(ue,{children:[u("div",{className:"rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5",children:[r(co,{className:"h-4 w-4 mt-0.5 text-emerald-500 shrink-0"}),u("div",{className:"text-xs text-foreground space-y-0.5",children:[r("div",{className:"font-medium",children:"2FA is active"}),u("div",{className:"text-foreground-subtle",children:["Enrolled on ",o.confirmedAt?new Date(o.confirmedAt).toLocaleString():"—"]})]})]}),c&&u("div",{className:"text-[11px] text-danger flex items-center gap-1",children:[r(kr,{className:"h-3 w-3"}),c]}),r("div",{className:"flex justify-end",children:u("button",{onClick:()=>{d(null),g.mutate()},disabled:g.isPending,className:"rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1",children:[g.isPending?r(Se,{className:"h-3 w-3 animate-spin"}):r(kn,{className:"h-3 w-3"}),"Disable 2FA"]})})]})]})]})}function nB(){return r(tt,{children:r("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:r(Zt,{limit:500,maxHeight:"max-h-[calc(100vh-250px)]",showScope:!0,showFilters:!0})})})}function Fa({tabs:e,defaultTab:t}){const[n,o]=Ia(),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 p=new URLSearchParams(n);p.set("tab",d),o(p,{replace:!0})};return u("div",{className:"space-y-3",children:[r("div",{className:"flex border-b border-border",children:e.map(d=>{const p=d.icon,f=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 ${f?"border-primary text-primary":"border-transparent text-foreground-subtle hover:text-foreground"}`,children:[p&&r(p,{className:"h-3.5 w-3.5"}),d.label]},d.id)})}),r("div",{children:l?.content})]})}function rB({userId:e,username:t,onClose:n}){const o=we(),s=et(),a=ty({userId:e}),i=a.data,l=()=>o.invalidateQueries({queryKey:[["userManagement","getTotpStatus"]]}),c=ey({onSuccess:()=>{l(),n()}}),d=a.isLoading?"loading":i?.enabled?"enrolled":"not_enrolled",p=async()=>{await s({title:"Remove 2FA",message:`Remove two-factor authentication for "${t}"? They'll be able to log in with just their password until they re-enroll from their own profile page.`,confirmLabel:"Remove",variant:"danger"})&&c.mutate({userId:e})};return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm p-4",children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl overflow-hidden",children:[u("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[u("div",{className:"flex items-center gap-2",children:[r(kn,{className:"h-4 w-4 text-primary"}),u("div",{children:[r("div",{className:"text-sm font-medium text-foreground",children:"Two-factor authentication"}),u("div",{className:"text-[11px] text-foreground-subtle",children:["User: ",r("span",{className:"font-mono",children:t})]})]})]}),r("button",{onClick:n,className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle",children:r(Be,{className:"h-4 w-4"})})]}),u("div",{className:"p-4 space-y-4",children:[d==="loading"&&u("div",{className:"flex items-center gap-2 text-xs text-foreground-subtle",children:[r(Se,{className:"h-3.5 w-3.5 animate-spin"}),"Checking status…"]}),d==="not_enrolled"&&u("div",{className:"rounded-md border border-border bg-surface-hover/30 px-3 py-2.5 flex items-start gap-2.5 text-xs text-foreground-subtle",children:[r(Gn,{className:"h-4 w-4 mt-0.5 shrink-0"}),u("div",{children:[r("div",{className:"font-medium text-foreground",children:"2FA not enrolled"}),r("p",{className:"mt-0.5",children:"Only the user themselves can enable 2FA, from their own profile page."})]})]}),d==="enrolled"&&i&&u(ue,{children:[u("div",{className:"rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5",children:[r(co,{className:"h-4 w-4 mt-0.5 text-emerald-500 shrink-0"}),u("div",{className:"text-xs text-foreground space-y-0.5",children:[r("div",{className:"font-medium",children:"2FA is active"}),u("div",{className:"text-foreground-subtle",children:["Enrolled on ",i.confirmedAt?new Date(i.confirmedAt).toLocaleString():"—"]})]})]}),r("div",{className:"text-[11px] text-foreground-subtle",children:"Removing here clears the server-side secret. Use this only when the user has lost access — they'll have to re-enroll from their profile page afterwards."}),u("div",{className:"flex justify-end gap-2",children:[r(ze,{onClick:n,variant:"secondary",children:"Close"}),u("button",{onClick:p,disabled:c.isPending,className:"rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1",children:[c.isPending?r(Se,{className:"h-3 w-3 animate-spin"}):r(Be,{className:"h-3 w-3"}),"Remove 2FA"]})]})]})]})]})})}function oB(){const e=we(),{user:t}=Xt(),[n,o]=P(!1),[s,a]=P(""),[i,l]=P(""),[c,d]=P(!1),[p,f]=P(null),{data:m,isLoading:h,isError:g}=Zc(),x=et(),b=()=>e.invalidateQueries({queryKey:[["userManagement","listUsers"]]}),v=qx({onSuccess:()=>{b(),o(!1),a(""),l(""),d(!1),f(null)},onError:$=>{f($ instanceof Error?$.message:"Failed to create user")}}),w=Gx({onSuccess:b}),y=Qx({onSuccess:b}),N=Xc({onSuccess:b}),k=Kx({onSuccess:()=>{b(),D(null)}}),[C,D]=P(null),[E,I]=P(null),z=m??[];async function A($){await x({title:"Delete user",message:`Permanently delete user "${$.username}"? This cannot be undone — any active sessions will be revoked on next request.`,confirmLabel:"Delete",variant:"danger"})&&w.mutate({id:$.id})}async function T($){const L=window.prompt(`New password for "${$.username}":`);if(!L)return;if(L.length<8){window.alert("Password must be at least 8 characters.");return}await x({title:"Reset password",message:`Reset the password for "${$.username}"? They will need to use the new password on their next login.`,confirmLabel:"Reset"})&&N.mutate({id:$.id,newPassword:L})}function R($,L){L!==$.isAdmin&&y.mutate({id:$.id,isAdmin:L})}function M($){return $?new Date(typeof $=="number"?$:String($)).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):"—"}return u(tt,{children:[r("div",{className:"flex items-center justify-end",children:u("button",{onClick:()=>o(!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(kt,{className:"h-3.5 w-3.5"}),"Create User"]})}),n&&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:()=>o(!1),className:"text-foreground-subtle hover:text-foreground",children:r(Be,{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:s,onChange:$=>a($.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:i,onChange:$=>l($.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:"Admin"}),u("label",{className:"flex items-center gap-2 rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground cursor-pointer",children:[r("input",{type:"checkbox",checked:c,onChange:$=>d($.target.checked),className:"rounded border-border focus:ring-primary"}),r("span",{className:"text-foreground-subtle",children:"Unrestricted access"})]})]})]}),p&&r("p",{className:"text-[10px] text-danger",children:p}),u("div",{className:"flex justify-end gap-2",children:[r("button",{onClick:()=>o(!1),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),r("button",{onClick:()=>v.mutate({username:s,password:i,isAdmin:c}),disabled:v.isPending||!s||!i,className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:v.isPending?"Creating...":"Create"})]})]}),h&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading..."}),g&&r("div",{className:"text-xs text-danger",children:"Failed to load"}),!h&&!g&&z.length===0&&r("div",{className:"text-xs text-foreground-subtle",children:"No data"}),(()=>{const $=O=>w.isPending&&w.variables?.id===O.id||y.isPending&&y.variables?.id===O.id||N.isPending&&N.variables?.id===O.id;return r(zo,{columns:[{key:"username",header:"Username",render:O=>O.username},{key:"isAdmin",header:"Admin",render:O=>u("label",{className:"inline-flex items-center gap-1.5 text-xs cursor-pointer",children:[r("input",{type:"checkbox",checked:O.isAdmin,onChange:F=>R(O,F.target.checked),disabled:$(O),className:"rounded border-border focus:ring-primary disabled:opacity-50"}),r("span",{className:O.isAdmin?"text-primary font-medium":"text-foreground-subtle",children:O.isAdmin?"Admin":"Regular"})]})},{key:"scopes",header:"Scopes",render:O=>{if(O.isAdmin)return r("span",{className:"text-[10px] text-foreground-subtle italic",children:"unscoped"});const F=O.scopes??[];return u("button",{onClick:()=>D(O),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(un,{className:"h-3 w-3"}),F.length===0?"no access":`${F.length} grant${F.length===1?"":"s"}`]})}},{key:"createdAt",header:"Created",render:O=>r("span",{className:"text-foreground-subtle",children:M(O.createdAt)})},{key:"actions",header:"Actions",align:"right",render:O=>{const F=$(O),B=O.id!==t?.id&&O.totpEnabled;return u("div",{className:"flex items-center justify-end gap-1",children:[B&&u("button",{onClick:()=>I(O),disabled:F,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:"Remove two-factor authentication",children:[r(kn,{className:"h-3 w-3"}),"Remove 2FA"]}),u("button",{onClick:()=>T(O),disabled:F,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(l6,{className:"h-3 w-3"}),"Reset password"]}),u("button",{onClick:()=>A(O),disabled:F,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:[F?r(Se,{className:"h-3 w-3 animate-spin"}):r(We,{className:"h-3 w-3"}),"Delete"]})]})}}],rows:z,rowKey:O=>O.id,minWidthPx:560})})(),E&&r(rB,{userId:E.id,username:E.username,onClose:()=>I(null)}),C&&r(sB,{user:C,onClose:()=>D(null),onSubmit:$=>k.mutate({userId:C.id,scopes:$}),submitting:k.isPending})]})}function sB(e){const{user:t}=Xt(),n=t?.isAdmin===!0;return r(aB,{...e,callerScopes:n?null:t?.scopes??[]})}function aB({user:e,onClose:t,onSubmit:n,submitting:o,callerScopes:s}){const a=V(()=>(e.scopes??[]).map(d=>({...d,access:[...d.access]})),[e.scopes]),[i,l]=P(a),c=dd(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.isAdmin?"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(Be,{className:"h-4 w-4"})})]}),u("div",{className:"px-4 py-4",children:[r(cd,{value:i,onChange:l,clampToParent:s,emptyHint:u(ue,{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(Se,{className:"h-3 w-3 animate-spin"}):"Save scopes"})]})]})})}const iB="bg-primary/10 text-primary",lB="bg-foreground-subtle/10 text-foreground-subtle";function ho(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}function cB(e){return e?e==="*"?"*":e.join(", "):""}function dB(){const e=we(),t=et(),{data:n,isLoading:o}=Wx(),{data:s}=Zc(),a=V(()=>n??[],[n]),i=V(()=>s??[],[s]),l=()=>e.invalidateQueries({queryKey:[["userManagement","listApiKeys"]]}),c=()=>e.invalidateQueries({queryKey:[["userManagement","listScopedTokens"]]}),[d,p]=P(!1),[f,m]=P(null),h=Yx({onSuccess:l}),g=Zx({onSuccess:({token:w,record:y})=>{c(),p(!1),m({token:w,label:y.name})}}),x=Xx({onSuccess:c}),b=async(w,y)=>{await t({title:`Revoke "${y}"?`,message:"Any client using this token will lose access immediately. This cannot be undone.",confirmLabel:"Revoke",variant:"danger"})&&h.mutate({id:w})},v=async(w,y)=>{await t({title:`Revoke "${y}"?`,message:"The scoped token will be invalid on its next use.",confirmLabel:"Revoke",variant:"danger"})&&x.mutate({id:w})};return u(tt,{children:[u("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[r("p",{className:"text-xs text-foreground-subtle max-w-2xl",children:"Issue scoped tokens to grant a user a narrow surface — a specific addon, integration, or capability. Every token MUST be scoped: revoking it has predictable blast radius."}),u("button",{onClick:()=>p(!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(un,{className:"h-3.5 w-3.5"}),"New token"]})]}),u(Xp,{title:"Scoped tokens",subtitle:"Grouped per user",children:[i.length===0&&r(pB,{text:"No users yet — scoped tokens are issued on behalf of an existing user."}),i.map(w=>r(fB,{userId:w.id,username:w.username,onRevoke:(y,N)=>{v(y,N)},revokePending:x.isPending,revokeId:x.variables?.id},w.id))]}),a.length>0&&r(Xp,{title:"Legacy API keys",subtitle:`${a.length} pre-existing — revoke only`,children:r(xv,{headers:["Label","Admin","Prefix","Allowed providers","Created","Last used",""],rows:a.map(w=>{const y=!!w.isAdmin,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 ${y?iB:lB}`,children:y?"admin":"regular"})}),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:cB(w.allowedProviders)||"all"}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:ho(w.createdAt)}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:ho(w.lastUsedAt)}),r("td",{className:"px-3 py-2 border-b border-border text-right",children:u("button",{onClick:()=>{b(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(Se,{className:"h-3 w-3 animate-spin"}):r(We,{className:"h-3 w-3"}),"Revoke"]})})]},w.id)})})}),o&&r(uB,{}),d&&r(mB,{users:i.map(w=>({id:w.id,username:w.username})),onClose:()=>p(!1),onSubmit:w=>g.mutate({userId:w.userId,name:w.name,scopes:w.scopes,...w.expiresAt!==void 0?{expiresAt:w.expiresAt}:{}}),submitting:g.isPending}),f&&r(hB,{token:f.token,label:f.label,onClose:()=>m(null)})]})}function Xp({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 uB(){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 pB({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 xv({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 fB({userId:e,username:t,onRevoke:n,revokePending:o,revokeId:s}){const{data:a,isLoading:i}=Jx({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(xv,{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((p,f)=>u("span",{className:"inline-block rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-mono",children:[p.type,":",p.type==="device"?`[${p.targets.join(",")}]`:p.target]},f))})}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:ho(c.expiresAt)}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:ho(c.lastUsedAt)}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:ho(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(Se,{className:"h-3 w-3 animate-spin"}):r(We,{className:"h-3 w-3"}),"Revoke"]})})]},c.id)})})]})}function mB({users:e,onClose:t,onSubmit:n,submitting:o}){const{user:s}=Xt(),i=s?.isAdmin===!0?null:s?.scopes??[],[l,c]=P(e[0]?.id??""),[d,p]=P(""),[f,m]=P([{type:"capability",target:"",access:["view","create"]}]),[h,g]=P(""),x=dd(f),b=l!==""&&d.trim().length>0&&f.length>0&&x===null&&!o,v=()=>{const w=parseInt(h,10),y=Number.isFinite(w)&&w>0?Date.now()+w*864e5:void 0;n({userId:l,name:d.trim(),scopes:f,expiresAt:y})};return u(yv,{title:"Create scoped token",onClose:t,children:[u("div",{className:"space-y-3",children:[r(ms,{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(ms,{label:"Name",children:r("input",{value:d,onChange:w=>p(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(ms,{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(cd,{value:f,onChange:m,clampToParent:i}),x&&r("p",{className:"mt-1 text-[10px] text-danger",children:x})]}),r(ms,{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(vv,{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:v,disabled:!b,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(Se,{className:"h-3.5 w-3.5 animate-spin"}):r(un,{className:"h-3.5 w-3.5"}),"Issue token"]})]})]})}function hB({token:e,label:t,onClose:n}){const[o,s]=P(!1),a=async()=>{try{await navigator.clipboard.writeText(e),s(!0)}catch{}};return u(yv,{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(vv,{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(At,{className:"h-3.5 w-3.5 text-primary"}):r(Qs,{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 yv({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(Be,{className:"h-4 w-4"})})]}),r("div",{className:"p-4",children:n})]})})}function vv({children:e}){return r("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:e})}function ms({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 Fi(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}function gB(e){if(e.type==="category"){const n=e.target??"";return n==="device"?"all devices":`all ${n}`}if(e.type==="device")return`device:[${(e.targets??[]).join(",")}]`;const t=e;return`${t.type}:${t.target??""}`}function bB(){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 xB({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 yB({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 vB(){const e=we(),t=et(),{data:n,isLoading:o}=ny(),s=V(()=>n??[],[n]),i=ry({onSuccess:()=>e.invalidateQueries({queryKey:[["userManagement","listOauthSessions"]]})}),l=async(c,d)=>{await t({title:`Revoke "${d}" session?`,message:"This integration will lose access immediately on its next API call. This cannot be undone.",confirmLabel:"Revoke",variant:"danger"})&&i.mutate({id:c})};return u(tt,{icon:A0,title:"Linked Sessions",subtitle:"External integrations (Alexa, …) linked to this hub via OAuth. Revoke a session to immediately invalidate that integration's access.",children:[o&&r(bB,{}),!o&&s.length===0&&r(xB,{text:"No linked sessions — once an external integration completes the OAuth flow its session will appear here."}),!o&&s.length>0&&r(yB,{headers:["Integration","User","Scopes","Created","Last used","Status",""],rows:s.map(c=>{const d=c.revokedAt!==null,f=(i.isPending?i.variables?.id:void 0)===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.integrationId}),r("td",{className:"px-3 py-2 text-foreground border-b border-border",children:c.username}),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((m,h)=>r("span",{className:"inline-block rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-mono",children:gB(m)},h))})}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:Fi(c.createdAt)}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:Fi(c.lastUsedAt)}),r("td",{className:"px-3 py-2 border-b border-border",children:d?u("span",{className:"inline-block rounded bg-foreground-subtle/10 px-2 py-0.5 text-[10px] text-foreground-subtle",children:["Revoked ",Fi(c.revokedAt)]}):r("span",{className:"inline-block rounded bg-emerald-500/15 px-2 py-0.5 text-[10px] text-emerald-700 dark:text-emerald-300",children:"Active"})}),r("td",{className:"px-3 py-2 border-b border-border text-right",children:!d&&u("button",{onClick:()=>{l(c.id,c.integrationId)},disabled:f,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:[f?r(Se,{className:"h-3 w-3 animate-spin"}):r(We,{className:"h-3 w-3"}),"Revoke"]})})]},c.id)})})]})}function wB({addonId:e,fallback:t,tileClassName:n,iconPath:o="assets/icon.svg"}){const[s,a]=P(!1),i=`/api/addon-assets/${e}/${o}`;return r("div",{className:`h-10 w-10 rounded-lg flex items-center justify-center shrink-0 ${n}`,children:s?r(t,{className:"h-5 w-5"}):r("img",{src:i,alt:e,className:"h-7 w-7 rounded-md bg-white p-1 ring-1 ring-black/5",onError:()=>a(!0)})})}function NB({addonId:e,defaultActivity:t,showActivity:n=!0,maxHeight:o="max-h-64",defaultTab:s}){const a=t??(s==="events"?"events":"logs"),[i,l]=P(a);return u("div",{className:"flex flex-col gap-4",children:[r(Gr,{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(Jp,{kind:"logs",active:i==="logs",onClick:()=>l("logs")}),r(Jp,{kind:"events",active:i==="events",onClick:()=>l("events")})]})]}),i==="logs"?r(Zt,{addonId:e,maxHeight:o,showFilters:!1}):r(sr,{addonId:e,category:"addon.*",maxHeight:o})]})]})}function Jp({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"?vt:Uo,{className:"h-3 w-3"}),e==="logs"?"Logs":"Events"]})}function Qo(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:p,itemIconColor:f,renderStatusBadges:m,renderPrimaryAction:h,itemError:g,renderExpandedPanel:x,workspaceMaxHeight:b="max-h-72",trailing:v,showChrome:w=!1}=e,y=l.length>1,[N,k]=P(()=>l[0]?.addonId??null);Y(()=>{N&&(l.some(E=>E.addonId===N)||k(l[0]?.addonId??null))},[l,N]);const C=E=>k(I=>I===E?null:E),D=`/system/addons?capability=${encodeURIComponent(a)}`;return r(tt,{icon:w?o:void 0,title:w?t:void 0,subtitle:w?n:void 0,actions:w?r(qs,{to:D,children:u(ze,{variant:"primary",size:"sm",children:[r(kt,{className:"h-3.5 w-3.5 mr-1"}),i]})}):void 0,children:c?r(an,{children:r("div",{className:"p-6 text-sm text-foreground-subtle",children:"Loading…"})}):l.length===0?r(an,{children:r(Ac,{title:d,description:p??`Install an addon that declares the "${a}" capability to get started.`,action:w?r(qs,{to:D,children:u(ze,{variant:"primary",size:"sm",children:[r(kt,{className:"h-3.5 w-3.5 mr-1"}),i]})}):void 0})}):u("div",{className:"flex flex-col gap-4",children:[l.map(E=>{const I=!y||N===E.addonId,z=f?.(E)??(E.isActive?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"),A=g?.(E)??null;return u(an,{children:[u("div",{className:`flex items-center gap-3 p-4 ${I?"border-b border-border":""}`,children:[y&&r("button",{type:"button",onClick:()=>C(E.addonId),"aria-label":I?"Collapse":"Expand",className:"shrink-0 p-1 rounded hover:bg-foreground-subtle/10 transition-colors",children:r(Nt,{className:`h-4 w-4 text-foreground-subtle transition-transform ${I?"rotate-180":""}`})}),u("button",{type:"button",onClick:()=>y&&C(E.addonId),className:`flex items-center gap-4 flex-1 min-w-0 text-left ${y?"hover:opacity-80 transition-opacity":""}`,disabled:!y,children:[r(wB,{addonId:E.addonId,fallback:s,tileClassName:z}),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:E.displayName}),r(kB,{isActive:E.isActive}),m?.(E)]}),u("div",{className:"text-xs text-foreground-subtle mt-1 font-mono",children:["@camstack/addon-",E.addonId]})]})]}),u("div",{className:"flex items-center gap-1 shrink-0",children:[h?.(E),r(SB,{capName:a,addonId:E.addonId,isActive:E.isActive}),r(CB,{addonId:E.addonId,displayName:E.displayName})]})]}),I&&u("div",{className:"p-4 flex flex-col gap-3",children:[A!==null&&r(va,{message:A}),x?.(E),r(NB,{addonId:E.addonId,maxHeight:b})]})]},E.addonId)}),v]})})}function kB({isActive:e}){return r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${e?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:e?"Enabled":"Disabled"})}function SB({capName:e,addonId:t,isActive:n}){const o=we(),s=Pg({onSuccess:()=>{o.invalidateQueries({queryKey:[["addons","listCapabilityProviders"]]})}}),a=s.isPending;return u(ze,{size:"sm",variant:n?"secondary":"primary",disabled:a,onClick:()=>s.mutate({capName:e,addonId:t,enabled:!n}),children:[a?r(Se,{className:"h-3 w-3 animate-spin"}):n?r(qo,{className:"h-3 w-3"}):r(Da,{className:"h-3 w-3"}),n?"Disable":"Enable"]})}function CB({addonId:e,displayName:t}){const n=we(),o=Fo({onSuccess:()=>{n.invalidateQueries({queryKey:[["addons","listCapabilityProviders"]]})}});return r(ld,{label:"Restart",icon:it,size:"sm",title:`Restart "${t}"?`,description:"Restarting the addon bounces its subprocess — the provider will briefly drop and reconnect automatically.",confirmLabel:"Restart",triggerVariant:"ghost",confirmVariant:"danger",disabled:o.isPending,action:()=>o.mutateAsync({addonId:e})})}const ef=3e4;function MB(e){const t=new Map;for(const n of e){const o=n?.manifest;o?.id&&t.set(o.id,o.packageDisplayName??o.name??o.id)}return t}function AB(e){return e==="local-auth"?{headline:"Username + password (local).",icon:a6,bullets:["Users live in the hub’s SQLite database — no IdP roundtrip.","TOTP / 2FA can be enrolled per-user from the Users page (added in v0.4).","API keys + scoped tokens are managed from the API Keys page."],setupSteps:["Add users from Users → New user (or seed via CAMSTACK_ADMIN_USER / CAMSTACK_ADMIN_PASS).","Hand out either passwords or scoped tokens — both validate through this provider."]}:e.startsWith("auth-oidc")?{headline:"OpenID Connect (Google, Microsoft, Okta, Keycloak, …).",icon:Cn,bullets:["Three-leg redirect flow with PKCE S256 + nonce.","id_token is signature-verified against the IdP’s JWKS — no implicit trust.","First-time sign-ins are auto-provisioned with the configured Default Role."],setupSteps:["Register a web app at your IdP and copy the client_id + client_secret.","Set the redirect URI to `https://<this-hub>/addon/<addon-id>/callback`.","Paste issuer + credentials in the Settings panel below — saves on every change."]}:e.startsWith("auth-saml")?{headline:"SAML 2.0 — enterprise SSO (Azure AD, Okta, OneLogin).",icon:Cn,bullets:["Heavier handshake than OIDC — exchange metadata XML with your IdP.","Group → role mapping via SAML assertions."]}:e.startsWith("auth-webauthn")||e.startsWith("auth-passkey")?{headline:"Passkeys / WebAuthn — passwordless second factor.",icon:kn,bullets:["Enroll a YubiKey, Touch ID, or platform passkey per user.","Resistant to phishing — the browser binds the credential to your hub origin."]}:e.startsWith("auth-totp")||e.startsWith("auth-magic-link")?{headline:"TOTP / magic-link — second factor or passwordless sign-in.",icon:kn,bullets:["Codes / links delivered out-of-band (RFC 6238 for TOTP).","Compatible with Google Authenticator, Aegis, 1Password, Bitwarden, etc."]}:{headline:"Authentication provider.",icon:un,bullets:["Generic authentication provider. No additional hints registered."]}}function EB(){const e=Bo({capName:"auth-provider"},{refetchInterval:ef}),t=hn(void 0,{refetchInterval:ef}),n=V(()=>MB(t.data??[]),[t.data]),o=V(()=>(e.data??[]).map(s=>({addonId:s.addonId,displayName:n.get(s.addonId)??s.addonId,isActive:s.isActive})),[e.data,n]);return r(Qo,{title:"Authentication",subtitle:"Identity providers exposed to the admin UI. Multiple providers can run in parallel — operators pick which to enable. Disabling a provider only removes that external login method; local password login is unaffected. Each provider’s settings + live logs are inline below.",pageIcon:un,itemIcon:un,capability:"auth-provider",installButtonLabel:"Add provider",items:o,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.",renderExpandedPanel:s=>r(IB,{addonId:s.addonId})})}function IB({addonId:e}){const t=AB(e),n=t.icon;return u("div",{className:"rounded-lg border border-border bg-surface p-4 space-y-3",children:[u("div",{className:"flex items-start gap-2.5",children:[r(n,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),r("div",{className:"text-xs text-foreground font-medium",children:t.headline})]}),r("ul",{className:"text-xs text-foreground-subtle space-y-1.5 pl-6 list-disc",children:t.bullets.map((o,s)=>r("li",{children:o},s))}),t.setupSteps&&t.setupSteps.length>0&&u("div",{className:"rounded-md border border-border bg-surface-hover/40 px-3 py-2.5 space-y-1.5",children:[u("div",{className:"flex items-center gap-1.5 text-[10px] font-semibold text-foreground-subtle uppercase tracking-wide",children:[r(dR,{className:"h-3 w-3"}),"Setup steps"]}),r("ol",{className:"text-xs text-foreground space-y-0.5 pl-4 list-decimal",children:t.setupSteps.map((o,s)=>r("li",{children:o},s))})]}),e==="local-auth"&&u("div",{className:"rounded-md border border-blue-500/30 bg-blue-500/5 px-3 py-2 flex items-start gap-2 text-[11px] text-foreground",children:[r(Gn,{className:"h-3.5 w-3.5 mt-0.5 text-blue-500 shrink-0"}),u("span",{children:["TOTP / 2FA settings are exposed per-user from the"," ",r("a",{href:"/system/users",className:"underline text-primary",children:"Users"})," page (added in v0.4). Enable for each user via the Actions column → “Enable TOTP”."]})]})]})}function PB(){return r("div",{className:"flex flex-col p-4",children:r(Fa,{tabs:[{id:"users",label:"Users",icon:EO,content:r(oB,{})},{id:"api-keys",label:"Tokens",icon:C0,content:r(dB,{})},{id:"linked-sessions",label:"Linked Sessions",icon:A0,content:r(vB,{})},{id:"authentication",label:"Authentication",icon:un,content:r(EB,{})}]})})}const Ol=5e3,_B={connected:!1,endpoint:null};function $B(e){const t=new Map;for(const n of e){const o=n?.manifest;o?.id&&t.set(o.id,o.packageDisplayName??o.name??o.id)}return t}function DB(){const e=we(),t=Bo({capName:"network-access"},{refetchInterval:Ol}),n=hn(void 0,{refetchInterval:Ol}),o=V(()=>$B(n.data??[]),[n.data]),s=V(()=>(t.data??[]).map(h=>({addonId:h.addonId,displayName:o.get(h.addonId)??h.addonId,isActive:h.isActive})),[t.data,o]),[a,i]=P(null),[l,c]=P({}),d=(h,g)=>{const x=g?.addonId;e.invalidateQueries({queryKey:[["networkAccess","getStatus"],{input:{addonId:x},type:"query"}]}),i(null),c(b=>{const v=g?.addonId;if(v===void 0||!(v in b))return b;const w={...b};return delete w[v],w})},p=(h,g)=>{i(null);const x=g?.addonId;if(x===void 0)return;const b=h instanceof Error?h.message:String(h);c(v=>({...v,[x]:b}))},f=Vb({onSuccess:d,onError:p}),m=Ub({onSuccess:d,onError:p});return r(Qo,{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:Cn,itemIcon:Cn,capability:"network-access",installButtonLabel:"Add tunnel",items:s,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.",renderStatusBadges:h=>r(LB,{addonId:h.addonId}),itemError:h=>l[h.addonId]??null,renderPrimaryAction:h=>r(TB,{addonId:h.addonId,busyId:a,onStart:g=>{i(g),f.mutate({addonId:g})},onStop:g=>{i(g),m.mutate({addonId:g})}})})}function wv(e){const{data:t}=qb({addonId:e},{refetchInterval:Ol,retry:!1}),n=t?SN.safeParse(t):null;return n?.success?n.data:_B}function LB({addonId:e}){const t=wv(e);return u(ue,{children:[r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.connected?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:t.connected?"Connected":"Disconnected"}),t.endpoint&&u("a",{href:t.endpoint.url,target:"_blank",rel:"noopener noreferrer",onClick:n=>n.stopPropagation(),className:"text-[10px] text-emerald-700 dark:text-emerald-300 hover:underline flex items-center gap-1",children:[r(Sd,{className:"h-3 w-3"}),t.endpoint.url]})]})}function TB({addonId:e,busyId:t,onStart:n,onStop:o}){const s=wv(e),a=t===e;return s.connected?u(ze,{size:"sm",variant:"secondary",disabled:a,onClick:()=>o(e),children:[a?r(Se,{className:"h-3 w-3 animate-spin"}):r(qo,{className:"h-3 w-3"}),"Stop"]}):u(ze,{size:"sm",variant:"primary",disabled:a,onClick:()=>n(e),children:[a?r(Se,{className:"h-3 w-3 animate-spin"}):r(Da,{className:"h-3 w-3"}),"Start"]})}const tf=3e4;function RB(e){const t=new Map;for(const n of e){const o=n?.manifest;o?.id&&t.set(o.id,o.packageDisplayName??o.name??o.id)}return t}function OB(e){const t=[];for(const n of e)typeof n.urls=="string"?t.push(n.urls):t.push(...n.urls);return t}function zB(){const e=Bo({capName:"turn-provider"},{refetchInterval:tf}),t=hn(void 0,{refetchInterval:tf}),n=Yc(),o=n.data??[],s=V(()=>RB(t.data??[]),[t.data]),a=V(()=>(e.data??[]).map(i=>({addonId:i.addonId,displayName:s.get(i.addonId)??i.addonId,isActive:i.isActive})),[e.data,s]);return r(Qo,{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:Mn,itemIcon:Mn,capability:"turn-provider",installButtonLabel:"Add provider",items:a,isLoading:e.isLoading,emptyTitle:"No TURN providers installed",emptyDescription:"Install a TURN addon (e.g. @camstack/addon-cloudflare-turn) to enable WebRTC behind restrictive NATs.",renderExpandedPanel:i=>r(BB,{addonId:i.addonId,enabled:i.isActive}),trailing:u(an,{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(ze,{size:"sm",variant:"secondary",onClick:()=>n.refetch(),disabled:n.isFetching,children:"Refresh"})]}),r("div",{className:"p-4",children:o.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:o.map((i,l)=>{const c=Array.isArray(i.urls)?i.urls:[i.urls];return u("div",{className:"rounded border border-border bg-surface",children:[(i.username||i.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:[i.username&&u("span",{children:[r("span",{className:"text-foreground-subtle",children:"user:"})," ",r("span",{className:"text-foreground",children:i.username})]}),i.credential&&u("span",{title:i.credential,children:[r("span",{className:"text-foreground-subtle",children:"credential:"})," ",r("span",{className:"text-foreground",children:`${i.credential.slice(0,8)}…${i.credential.slice(-4)}`})]})]}),r("ul",{className:"divide-y divide-border",children:c.map(d=>r("li",{className:"px-3 py-1.5 font-mono text-xs text-foreground break-all",children:d},d))})]},l)})})})]})})}function BB({addonId:e,enabled:t}){const n=Yc({addonId:e},{enabled:t,retry:!1}),o=V(()=>OB(n.data??[]),[n.data]);return!t||o.length===0?null:u("div",{className:"rounded-lg border border-border bg-surface p-3",children:[u("div",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide mb-2",children:["Discovered ICE servers (",o.length,")"]}),r("div",{className:"flex flex-wrap gap-1",children:o.map(s=>r("span",{className:"inline-block rounded px-1.5 py-0.5 text-[10px] font-mono bg-foreground-subtle/10 text-foreground",children:s},s))})]})}const FB={lan:Mn,wifi:Sr,docker:_a,vpn:Cd,loopback:An,other:An},jB={lan:"LAN",wifi:"Wi-Fi",docker:"Docker",vpn:"VPN",loopback:"Loopback",other:"Other"},HB=["lan","wifi","vpn","docker","other","loopback"];function VB(e){const{interfaces:t,disabled:n,hideLoopback:o,ipv4Only:s,emptyMessage:a}=e,i=V(()=>t.filter(p=>!(o&&p.kind==="loopback"||s&&p.family!=="IPv4")),[t,o,s]),l=V(()=>{const p=new Map;for(const f of i){const m=p.get(f.kind)??[];m.push(f),p.set(f.kind,m)}return HB.filter(f=>p.has(f)).map(f=>({kind:f,items:p.get(f)}))},[i]),c=p=>e.mode==="single"?e.value===p:e.value.includes(p),d=p=>{if(n||p.kind==="loopback")return;if(e.mode==="single"){e.onChange(e.value===p.address?null:p.address);return}const f=new Set(e.value);f.has(p.address)?f.delete(p.address):f.add(p.address),e.onChange([...f])};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:p,items:f})=>{const m=FB[p]??An;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:jB[p]??p}),u("span",{className:"text-[10px] text-foreground-subtle",children:["· ",f.length]})]}),r("ul",{className:"divide-y divide-border",children:f.map(h=>{const g=c(h.address),x=h.kind==="loopback",b=!h.plausible&&!x;return u("li",{className:`flex items-center gap-3 px-3 py-2 ${x?"opacity-60 cursor-not-allowed":n?"opacity-60":b?"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(At,{className:"h-3 w-3"})}),u("div",{className:`flex-1 min-w-0 ${b?"text-foreground-subtle":""}`,children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:`font-mono text-xs font-semibold ${b?"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"}),x&&r("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle",children:"Always included"}),b&&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(at,{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}`)})})]},p)})})}const nf={"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 UB(){const e=we(),t=Le(),n=Pb(void 0,{refetchInterval:3e4}),o=$b(void 0),s=Db({onSuccess:()=>{e.invalidateQueries({queryKey:[["localNetwork"]]})}}),a=Lb({onSuccess:C=>{f(C.addresses),e.invalidateQueries({queryKey:[["localNetwork"]]})}}),i=V(()=>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=_b({port:l,scheme:c},{refetchInterval:3e4}),[p,f]=P([]),[m,h]=P(!1);Y(()=>{!m&&o.data&&(f(o.data.addresses),h(!0))},[o.data,m]);const g=o.data?.addresses??[],x=V(()=>{if(p.length!==g.length)return!0;const C=[...p].sort(),D=[...g].sort();return C.some((E,I)=>E!==D[I])},[p,g]),b=()=>{s.mutate({addresses:[...p]})},v=()=>{f(g)},w=()=>{f([])},y=()=>{n.refetch(),d.refetch(),o.refetch()},N=async()=>{try{const C=await t.raceConnectionEndpoints({perCandidateTimeoutMs:1500});console.info("[network-addresses] race result",C)}catch(C){console.warn("[network-addresses] race failed",C)}},k=d.data?.endpoints??[];return u(tt,{children:[u("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[r("p",{className:"text-xs text-foreground-subtle max-w-2xl",children:"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."}),u("div",{className:"flex items-center gap-2 shrink-0",children:[u(ze,{size:"sm",variant:"secondary",onClick:y,disabled:n.isLoading,children:[r(it,{className:`h-3 w-3 ${n.isLoading?"animate-spin":""}`}),"Refresh"]}),r(ze,{size:"sm",variant:"secondary",onClick:N,children:"Probe race"})]})]}),u("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[u(an,{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:p.length===0?"Auto — every non-loopback / non-link-local interface participates.":`${p.length} pinned`})]}),u("div",{className:"flex items-center gap-1",children:[u(ze,{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(hO,{className:"h-3 w-3"}),a.isPending?"Detecting…":"Best match"]}),u(ze,{size:"sm",variant:"secondary",onClick:w,disabled:p.length===0||s.isPending,children:[r(D0,{className:"h-3 w-3"}),"Clear"]}),x&&r(ze,{size:"sm",variant:"secondary",onClick:v,disabled:s.isPending,children:"Discard"}),u(ze,{size:"sm",variant:"primary",onClick:b,disabled:!x||s.isPending,children:[r(Z6,{className:"h-3 w-3"}),s.isPending?"Saving…":"Save"]})]})]}),r("div",{className:"p-4",children:r(VB,{mode:"multiple",interfaces:i,value:p,onChange:f,disabled:s.isPending,emptyMessage:n.isLoading?"Loading interfaces…":"No interfaces detected."})})]}),u(an,{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(C=>u("li",{className:`flex items-center gap-2 flex-wrap ${C.plausible?"":"opacity-80"}`,children:[r("span",{className:"font-mono text-[10px] w-10 text-foreground-subtle",children:String(C.priority).padStart(4,"0")}),r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${nf[C.kind]??nf.loopback}`,children:C.kind}),C.interfaceKind!=="lan"&&C.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:C.interfaceKind}),!C.plausible&&C.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:C.plausibleReason||void 0,children:[r(at,{className:"h-2.5 w-2.5"}),"Unlikely usable"]}),r("span",{className:`font-mono break-all ${C.plausible?"text-foreground":"text-foreground-subtle"}`,children:C.baseUrl}),u("span",{className:"text-foreground-subtle",children:["— ",C.label]})]},`${C.priority}-${C.baseUrl}`))})})]})]})]})}const qB={mesh:"bg-violet-500/15 text-violet-700 dark:text-violet-300",public:"bg-blue-500/15 text-blue-700 dark:text-blue-300"},zl=5e3,QB=3e4,GB={joined:!1,meshIp:"",magicDnsHostname:"",peerCount:0,endpoints:[],tenantName:"",magicDnsSuffix:"",userLogin:null,controlPlaneUrl:"",keyExpiry:null};function KB(e){const t=new Map;for(const n of e){const o=n?.manifest;o?.id&&t.set(o.id,o.packageDisplayName??o.name??o.id)}return t}function WB(){const e=Bo({capName:"mesh-network"},{refetchInterval:zl}),t=hn(void 0,{refetchInterval:zl}),n=V(()=>KB(t.data??[]),[t.data]),o=V(()=>(e.data??[]).map(s=>({addonId:s.addonId,displayName:n.get(s.addonId)??s.addonId,isActive:s.isActive})),[e.data,n]);return r(Qo,{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:_a,itemIcon:Mn,capability:"mesh-network",installButtonLabel:"Add mesh",items:o,isLoading:e.isLoading,emptyTitle:"No mesh-network providers installed",emptyDescription:"Install a mesh addon (e.g. @camstack/addon-tailscale-client) to join this hub into a private VPN mesh.",renderStatusBadges:s=>r(YB,{addonId:s.addonId}),renderPrimaryAction:s=>r(ZB,{addonId:s.addonId}),renderExpandedPanel:s=>r(XB,{addonId:s.addonId})})}function Id(e){const{data:t,isLoading:n}=Tb({addonId:e},{refetchInterval:zl,retry:!1}),o=t?Mm.safeParse(t):null;return{status:o?.success?o.data:GB,isLoading:n}}function YB({addonId:e}){const{status:t}=Id(e);return u(ue,{children:[r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.joined?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:t.joined?"Joined":"Not joined"}),t.joined&&u("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle",children:[t.peerCount," peer",t.peerCount===1?"":"s"]})]})}function ZB({addonId:e}){const t=we(),[n,o]=P(!1),[s,a]=P(null),i=Le(),{status:l}=Id(e),c=U(()=>{t.invalidateQueries({queryKey:[["meshNetwork"]]})},[t]),d=Rb(),p=Ob({onSuccess:c}),f=zb({onSuccess:c}),m=U(async()=>{o(!0);const g={cancelled:!1};a(g);try{const x=await d.mutateAsync({addonId:e});if(g.cancelled)return;x.loginUrl&&window.open(x.loginUrl,"_blank","noopener,noreferrer");const b=Date.now(),v=10*6e4;for(;!g.cancelled&&(await rF(2e3),!g.cancelled);){const w=await i.trpcClient.meshNetwork.getStatus.query({addonId:e}).catch(()=>null),y=w?Mm.safeParse(w):null;if(y?.success&&y.data.joined){c();break}if(Date.now()-b>v)break}}finally{o(!1),a(null)}},[e,c,d,i]),h=U(()=>{s&&(s.cancelled=!0),o(!1),a(null)},[s]);return r(ue,{children:l.joined?u(ue,{children:[u(ze,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>p.mutate({addonId:e}),children:[p.isPending?r(Se,{className:"h-3 w-3 animate-spin"}):r(Md,{className:"h-3 w-3"}),"Disconnect"]}),u(ze,{size:"sm",variant:"ghost",disabled:f.isPending,onClick:()=>f.mutate({addonId:e}),children:[f.isPending?r(Se,{className:"h-3 w-3 animate-spin"}):r(fp,{className:"h-3 w-3"}),"Log out"]})]}):n?u(ze,{size:"sm",variant:"ghost",onClick:h,children:[r(Be,{className:"h-3 w-3 mr-1"})," Cancel"]}):u(ue,{children:[u(ze,{size:"sm",variant:"primary",onClick:()=>void m(),children:[r(x6,{className:"h-3 w-3"}),"Connect"]}),u(ze,{size:"sm",variant:"ghost",disabled:f.isPending,onClick:()=>f.mutate({addonId:e}),children:[f.isPending?r(Se,{className:"h-3 w-3 animate-spin"}):r(fp,{className:"h-3 w-3"}),"Log out"]})]})})}function XB({addonId:e}){const{status:t}=Id(e),n=Bb({addonId:e},{refetchInterval:QB,retry:!1});return u("div",{className:"rounded-lg border border-border bg-surface",children:[u("div",{className:"p-4 space-y-4",children:[t.error&&r(va,{message:t.error}),r(JB,{status:t}),t.endpoints.length>0&&u("div",{className:"space-y-1.5",children:[r("div",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Endpoints"}),t.endpoints.map(o=>u("div",{className:"flex items-center gap-2 text-xs flex-wrap",children:[u("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${qB[o.scope]??"bg-foreground-subtle/15 text-foreground-subtle"}`,children:[o.scope==="public"?r(Cn,{className:"inline h-2.5 w-2.5 mr-0.5"}):null,o.label]}),u("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",onClick:s=>s.stopPropagation(),className:"text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1",children:[r(Sd,{className:"h-3 w-3 shrink-0"}),o.url]})]},o.id))]})]}),r("div",{className:"border-t border-border",children:r(tF,{peers:n.data?.peers??[],loading:n.isLoading})})]})}function JB({status:e}){const t=[{label:"Tenant",value:e.tenantName||"—"},{label:"User",value:e.userLogin??"—"},{label:"Control plane",value:e.controlPlaneUrl||"—"},{label:"Mesh IP",value:e.meshIp||"—",mono:!0},{label:"MagicDNS",value:e.magicDnsHostname||"—",mono:!0},{label:"DNS suffix",value:e.magicDnsSuffix||"—",mono:!0},{label:"Peers",value:String(e.peerCount)},{label:"Key expiry",value:e.keyExpiry?eF(e.keyExpiry):"—"}];return r("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5",children:t.map(n=>u("div",{className:"flex items-baseline justify-between gap-3 text-xs",children:[r("span",{className:"text-foreground-subtle shrink-0",children:n.label}),r("span",{className:`text-foreground truncate ${n.mono?"font-mono":""}`,children:n.value})]},n.label))})}function eF(e){const t=e-Date.now();if(t<0)return`Expired ${Nv(e)}`;const n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return`in ${n} days`;const o=Math.floor(t/36e5);return o>1?`in ${o}h`:`in ${Math.max(1,Math.floor(t/6e4))} min`}function tF({peers:e,loading:t}){const n=V(()=>e.map(a=>({...a,_id:a.id})),[e]),o=U(a=>{a&&navigator.clipboard?.writeText(a)},[]),s=V(()=>[{key:"hostname",header:"Hostname",render:a=>u("div",{className:"flex flex-col",children:[u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"font-medium text-foreground",children:a.hostname||"(unknown)"}),a.isSelf&&r(Lt,{variant:"info",children:"self"}),a.exitNodeOption&&r(Lt,{variant:"warning",children:"exit-node"})]}),a.userLogin&&r("div",{className:"text-[10px] text-foreground-subtle truncate",children:a.userLogin})]})},{key:"magicDns",header:"MagicDNS",render:a=>a.magicDns?u("div",{className:"flex items-center gap-1",children:[r("span",{className:"font-mono text-xs truncate",children:a.magicDns}),r("button",{onClick:()=>o(a.magicDns),className:"p-0.5 hover:bg-foreground-subtle/10 rounded","aria-label":"Copy MagicDNS",children:r(Qs,{className:"h-3 w-3 text-foreground-subtle"})})]}):r("span",{className:"text-foreground-subtle",children:"—"})},{key:"addresses",header:"IP",render:a=>{const i=a.addresses[0]??"";return i?u("div",{className:"flex items-center gap-1",children:[r("span",{className:"font-mono text-xs",children:i}),r("button",{onClick:()=>o(i),className:"p-0.5 hover:bg-foreground-subtle/10 rounded","aria-label":"Copy IP",children:r(Qs,{className:"h-3 w-3 text-foreground-subtle"})})]}):r("span",{className:"text-foreground-subtle",children:"—"})}},{key:"connection",header:"Connection",render:a=>u("div",{className:"flex items-center gap-1.5",children:[r(Lt,{variant:nF(a.connection),children:a.connection}),a.relay&&r("span",{className:"text-[10px] text-foreground-subtle font-mono",children:a.relay})]})},{key:"routes",header:"Routes",render:a=>a.advertisedRoutes.length>0?r("span",{className:"text-[10px] font-mono text-foreground-subtle truncate",children:a.advertisedRoutes.join(", ")}):r("span",{className:"text-foreground-subtle",children:"—"})},{key:"tx",header:"TX / RX",render:a=>u("span",{className:"text-[10px] text-foreground-subtle font-mono",children:["↑ ",rf(a.txBytes)," · ↓ ",rf(a.rxBytes)]})},{key:"lastSeen",header:"Last seen",render:a=>r("span",{className:"text-[10px] text-foreground-subtle",children:a.lastSeenMs>0?Nv(a.lastSeenMs):"—"})}],[o]);return t&&e.length===0?u("div",{className:"p-4 text-xs text-foreground-subtle",children:[r(Se,{className:"h-3 w-3 animate-spin inline mr-1"})," Loading peers…"]}):e.length===0?r("div",{className:"p-4 text-xs text-foreground-subtle",children:"No peers visible — your tailnet may be empty or the host is not joined."}):r("div",{className:"p-4",children:r(zo,{columns:s,rows:n,rowKey:a=>a._id,minWidthPx:820})})}function nF(e){return e==="direct"?"success":e==="relay"?"warning":"info"}function rf(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(2)}GB`}function Nv(e){const t=Date.now()-e;return t<6e4?"just now":t<36e5?`${Math.round(t/6e4)}m ago`:t<864e5?`${Math.round(t/36e5)}h ago`:`${Math.round(t/864e5)}d ago`}function rF(e){return new Promise(t=>setTimeout(t,e))}function oF(){return r("div",{className:"flex flex-col p-4",children:r(Fa,{tabs:[{id:"addresses",label:"Network Addresses",icon:An,content:r(UB,{})},{id:"remote-access",label:"Remote Access",icon:Cn,content:r(DB,{})},{id:"mesh",label:"Mesh Networks",icon:_a,content:r(WB,{})},{id:"turn",label:"TURN Servers",icon:Mn,content:r(zB,{})}]})})}const sF=[{kind:"device-export",tabId:"device-export",title:"Device export",subtitle:"Outbound exporters that publish CamStack devices to other ecosystems (HomeAssistant, HomeKit, Alexa, …).",icon:sO,emptyTitle:"No device-export providers installed",emptyDescription:"Install an export addon (e.g. @camstack/addon-export-ha-mqtt) to surface your CamStack devices in HomeAssistant, HomeKit, …",addLabel:"Add export"},{kind:"email",tabId:"email",title:"Email providers",subtitle:"Outbound email relays used for magic-link login, notifications, and alerts (SMTP today, future SendGrid, …).",icon:w6,emptyTitle:"No email providers installed",emptyDescription:"Install an email-provider addon (e.g. @camstack/addon-smtp) so the hub can deliver magic-link logins and notifications.",addLabel:"Add email provider"},{kind:"broker",tabId:"broker",title:"Brokers",subtitle:"Message brokers consumed by exporters and downstream automations (MQTT today, future Kafka, …).",icon:La,emptyTitle:"No brokers installed",emptyDescription:"Install a broker addon (e.g. @camstack/addon-mqtt-broker) to publish device events for downstream automations.",addLabel:"Add broker"}];function aF(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e.name;if(typeof t=="string")return t}return null}function iF(e){const t=e,n=t?.manifest;if(!n?.id)return null;const o=[];for(const i of n.capabilities??[]){const l=aF(i);l!==null&&o.push(l)}const s=n.packageDisplayName??n.name??n.id,a=t?.process?.state??null;return{addonId:n.id,displayName:s,isActive:a==="running",packageName:n.packageName??`@camstack/addon-${n.id}`,capNames:o,processState:a}}function lF(e,t){const n=new Set(t);return e.filter(o=>o.capNames.some(s=>n.has(s)))}function cF(e){for(const[t,n]of Object.entries(Em))if(n===e)return t;return null}function dF(e){return e==="running"?{label:"Running",className:"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300"}:e==="crashed"||e==="failed"?{label:e==="failed"?"Failed":"Crashed",className:"bg-danger/15 text-danger"}:e==="stopped"||e==="disabled"?{label:"Stopped",className:"bg-foreground-subtle/15 text-foreground-subtle"}:{label:e??"Unknown",className:"bg-foreground-subtle/15 text-foreground-subtle"}}function Pd({label:e,className:t}){return r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t}`,children:e})}function uF({addonId:e}){const{data:t,isLoading:n}=Hb({addonId:e},{refetchInterval:1e4,retry:!1});if(n||!t)return null;const o=CN.safeParse(t);if(!o.success)return null;const s=o.data,a=`${s.brokerCount} broker${s.brokerCount===1?"":"s"}${s.embeddedRunning?" • embedded up":""}`;return r(Pd,{label:a,className:"bg-primary/10 text-primary"})}function pF({addonId:e}){const{data:t,isLoading:n}=Fc({addonId:e},{refetchInterval:1e4,retry:!1});if(n||!t)return null;const o=Cm.safeParse(t);if(!o.success)return null;const s=o.data,a=s.linkState==="linked"?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":s.linkState==="error"?"bg-danger/15 text-danger":"bg-foreground-subtle/15 text-foreground-subtle",i=`${s.linkState} • ${s.exposedDeviceCount} exposed`;return r(Pd,{label:i,className:a})}function fF({kind:e,addonId:t}){return e==="broker"?r(uF,{addonId:t}):e==="device-export"?r(pF,{addonId:t}):null}function mF({descriptor:e,rows:t,isLoading:n}){const o=cF(e.kind),s=e.kind==="device-export";return r(Qo,{title:e.title,subtitle:e.subtitle,pageIcon:e.icon,itemIcon:e.icon,capability:o??e.kind,installButtonLabel:e.addLabel,items:t,isLoading:n,emptyTitle:e.emptyTitle,emptyDescription:e.emptyDescription,renderStatusBadges:a=>{const i=dF(a.processState);return u(ue,{children:[r(Pd,{label:i.label,className:i.className}),r(fF,{kind:e.kind,addonId:a.addonId})]})},renderExpandedPanel:s?a=>r(sd,{addonId:a.addonId}):void 0,showChrome:!0})}function hF(){const e=hn(void 0,{refetchInterval:1e4}),t=(e.data??[]).map(iF).filter(o=>o!==null),n=sF.map(o=>{const s=Object.entries(Em).filter(([,a])=>a===o.kind).map(([a])=>a);return{id:o.tabId,label:o.title,icon:o.icon,content:r(mF,{descriptor:o,rows:lF(t,s),isLoading:e.isLoading})}});return r(tt,{icon:ko,title:"Integrations",subtitle:"External systems this hub talks to — device exporters, email relays, and message brokers. Settings, Logs and Events are docked under every provider.",children:r(Fa,{tabs:n})})}function gF(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 bF({location:e,onEdit:t,onDelete:n,onSetDefault:o}){const s=gF(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(yi,{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(yi,{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(yi,{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(Qr,{className:"h-3 w-3"}),"Edit"]}),!e.isSystem&&Ms[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(We,{className:"h-3 w-3"})})]})]})}function xF({type:e,displayName:t,description:n,locations:o,onAdd:s,onEdit:a,onDelete:i,onSetDefault:l}){const c=V(()=>{const d=[...o];return d.sort((p,f)=>p.isDefault!==f.isDefault?p.isDefault?-1:1:p.displayName.localeCompare(f.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}),Ms[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."})]}),Ms[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(kt,{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:Ms[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(bF,{location:d,onEdit:a,onDelete:i,onSetDefault:l},d.id))})]})}function yF(e){const t=e.trim().toLowerCase();return t.length===0?"":t.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function of(e,t){const n=yF(t),o=n.length>0?n:"default";return`${e}:${o}`}function kv({initialType:e,onClose:t,onCreated:n}){const o=we(),s=Le().trpcClient,[a,i]=P("picker"),[l,c]=P(e),[d,p]=P(null),[f,m]=P({}),[h,g]=P(""),[x,b]=P(null),[v,w]=P(!1),[y,N]=P(null),[k,C]=P(!1),D=Wc(),E=V(()=>{const $=D.data;return Array.isArray($)?$.filter(O=>O.supportedLocationTypes.includes(l)):[]},[D.data,l]),I=D.isLoading,z=ka({onSuccess:()=>{o.invalidateQueries({queryKey:[["storage","listLocations"]]}),n()}}),A=V(()=>x!==null&&x.length>0?x:of(l,h),[l,h,x]),T=async()=>{if(d){C(!0),N(null);try{const O=await(F=>s.storage.testConfig.query(F))({providerId:d.providerId,config:f});N(O)}catch($){N({ok:!1,error:$ instanceof Error?$.message:String($)})}finally{C(!1)}}},R=()=>{d&&z.mutate({id:A,type:l,displayName:h.trim(),providerId:d.providerId,config:f,isDefault:v})},M={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:$=>$.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:M[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(Be,{className:"h-4 w-4"})})]}),a==="picker"&&u("div",{className:"p-4 space-y-2",children:[I&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading providers…"}),!I&&E.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."]}),E.map($=>u("button",{onClick:()=>{p($),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:$.displayName}),r("p",{className:"text-[10px] text-foreground-subtle font-mono mt-0.5 truncate",children:$.providerId})]}),r(zt,{className:"h-4 w-4 text-foreground-subtle flex-shrink-0"})]},$.providerId))]}),a==="config"&&d&&u("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[r(En,{schema:d.configSchema,values:f,onChange:m}),y&&r("div",{className:`rounded border px-3 py-2 text-[11px] ${y.ok?"border-success/30 bg-success/5 text-success":"border-danger/30 bg-danger/5 text-danger"}`,children:y.ok?"Connection OK.":`Test failed: ${y.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:$=>g($.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:A,onChange:$=>b($.target.value),placeholder:of(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:v,onChange:$=>w($.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),p(null),m({}),g(""),b(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:R,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(Se,{className:"h-3.5 w-3.5 animate-spin"}):null,z.isPending?"Saving…":"Save"]})]})]})]})]})})}function vF({location:e,onClose:t,onSaved:n}){const o=we(),s=Le().trpcClient,[a,i]=P({...e.config}),[l,c]=P(e.displayName),[d,p]=P(null),[f,m]=P(!1),h=Wc(),g=V(()=>{const w=h.data;return Array.isArray(w)?w.find(N=>N.providerId===e.providerId)??null:null},[h.data,e.providerId]),x=ka({onSuccess:()=>{o.invalidateQueries({queryKey:[["storage","listLocations"]]}),n()}}),b=async()=>{m(!0),p(null);try{const y=await(N=>s.storage.testConfig.query(N))({providerId:e.providerId,config:a});p(y)}catch(w){p({ok:!1,error:w instanceof Error?w.message:String(w)})}finally{m(!1)}},v=()=>{x.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(Be,{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(En,{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"}`}),x.isError&&r("div",{className:"rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]",children:x.error instanceof Error?x.error.message:String(x.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:()=>{b()},disabled:f||!g,className:"rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50",children:f?"Testing…":"Test connection"}),u("button",{onClick:v,disabled:x.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:[x.isPending?r(Se,{className:"h-3.5 w-3.5 animate-spin"}):null,x.isPending?"Saving…":"Save"]})]})]})]})})}const wF={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"},NF={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 kF(){const e=we(),t=et(),{data:n,isLoading:o,isError:s}=jx({}),[a,i]=P(null),[l,c]=P(null),d=Hx({onSuccess:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]})}}),p=ka({onSuccess:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]})}}),f=g=>{g.isDefault||p.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=V(()=>{const g=new Map;for(const x of ou)g.set(x,[]);for(const x of n??[]){const b=g.get(x.type);b?b.push(x):g.set(x.type,[x])}return g},[n]);return u(tt,{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:ou.map(g=>r(xF,{type:g,displayName:wF[g],description:NF[g],locations:h.get(g)??[],onAdd:x=>i(x),onEdit:x=>c(x),onDelete:x=>{m(x)},onSetDefault:x=>f(x)},g))}),a!==null&&r(kv,{initialType:a,onClose:()=>i(null),onCreated:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),i(null)}}),l!==null&&r(vF,{location:l,onClose:()=>c(null),onSaved:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),c(null)}})]})}const SF=[["backup","listDestinations"]],CF=["backup","listArchives"];function MF({destinationId:e,restoreSupported:t,onOpenRestoreWizard:n}){const o=we(),s=et(),{data:a,isLoading:i,isError:l}=Bc({destinationId:e}),c=a??[],d=Zg({onSuccess:()=>{o.invalidateQueries({queryKey:[[...CF]]}),o.invalidateQueries({queryKey:SF})}}),p=U(async x=>{await s({title:"Delete this archive?",message:`Permanently deletes "${x.label??x.id}" and frees ${St(x.sizeBytes)}.`,confirmLabel:"Delete",variant:"danger"})&&d.mutate({destinationId:e,backupId:x.id})},[s,e,d]),[f,m]=P(null),h=U(async x=>{m(x.id);try{const b=localStorage.getItem("camstack_admin_token"),v={};b&&(v.Authorization=`Bearer ${b}`);const w=await fetch(AF(e,x.id),{headers:v});if(!w.ok)throw new Error(`download failed: ${w.status} ${w.statusText}`);const y=await w.blob(),N=URL.createObjectURL(y),k=document.createElement("a");k.href=N,k.download=`${x.label??x.id}.tar.gz`,document.body.appendChild(k),k.click(),k.remove(),URL.revokeObjectURL(N)}finally{m(null)}},[e]),g=V(()=>[...c].sort((x,b)=>b.createdAt-x.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(x=>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:EF(x.createdAt)}),r("td",{className:"px-3 py-1.5 text-foreground",children:x.label??r("span",{className:"text-foreground-subtle italic",children:"—"})}),r("td",{className:"px-3 py-1.5 text-foreground-subtle",children:x.locations.join(", ")}),r("td",{className:"px-3 py-1.5 text-foreground text-right tabular-nums",children:St(x.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(x)},disabled:f===x.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:[f===x.id?r(Se,{className:"h-3 w-3 animate-spin"}):r(Kt,{className:"h-3 w-3"}),"Download"]}),t&&n&&u("button",{onClick:()=>n({destinationId:e,archiveId:x.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(qt,{className:"h-3 w-3"}),"Restore"]}),r("button",{onClick:()=>{p(x)},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(Se,{className:"h-3 w-3 animate-spin"}):r(We,{className:"h-3 w-3"})})]})})]},x.id))})]})})}function AF(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function EF(e){return new Date(e).toLocaleString(void 0,{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Sv=[{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 IF(e){const t=e.trim();for(const n of Sv)if(n.cron===t)return n.id;return"custom"}function PF({value:e,onChange:t,previewCount:n=5,disabled:o=!1}){const s=IF(e),[a,i]=P(s==="custom");Y(()=>{s!=="custom"&&i(!1)},[s]);const l=DF(e,250),c=Jg({cron:l,count:n},{enabled:l.trim().length>0}),d=c.data??null,p=m=>{i(!1),t(m.cron)},f=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:[Sv.map(m=>{const h=!a&&s===m.id;return r("button",{type:"button",onClick:()=>p(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 "+(f?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground"),children:"Custom…"})]})]}),f&&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(_F,{cron:l,preview:d,loading:c.isFetching})]})}function _F({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(Se,{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:$F(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 $F(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 DF(e,t){const[n,o]=P(e),s=V(()=>e,[e]);return Y(()=>{const a=setTimeout(()=>o(s),t);return()=>clearTimeout(a)},[s,t]),n}const LF=[["backup","listDestinations"]];function TF({onCreateAt:e,onOpenRestoreWizard:t}){const{data:n,isLoading:o,isError:s}=zc(),a=n??[],[i,l]=P(null),c=p=>{l(f=>f===p?null:p)},d=FF();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(p=>{const f=d.get(p.id);return r(RF,{row:p,isOpen:i===p.id,onToggle:()=>c(p.id),onCreateAt:e,liveLastSuccessAt:f?.at,liveLastSuccessSizeBytes:f?.sizeBytes,...t?{onOpenRestoreWizard:t}:{}},p.id)})})]})})}function RF({row:e,isOpen:t,onToggle:n,onCreateAt:o,onOpenRestoreWizard:s,liveLastSuccessAt:a,liveLastSuccessSizeBytes:i}){const l=we(),c=Xg({onSuccess:()=>{l.invalidateQueries({queryKey:LF})}}),[d,p]=P(String(e.retentionCount));Y(()=>{p(String(e.retentionCount))},[e.retentionCount]);const[f,m]=P(!1),h=U(b=>{c.mutate({locationId:e.id,enabled:b,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=U(()=>{const b=Number.parseInt(d,10);if(Number.isNaN(b)||b<1){p(String(e.retentionCount));return}b!==e.retentionCount&&c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:b,...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]),x=U(b=>{c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:e.retentionCount,...e.label!==void 0?{label:e.label}:{},cron:b},{onSuccess:()=>{m(!1)}})},[c,e.id,e.enabled,e.retentionCount,e.label]);return u(ue,{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(Nt,{className:"h-3.5 w-3.5"}):r(zt,{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:b=>h(b.target.checked)})})}),r("td",{className:"px-3 py-2",children:r("input",{type:"number",min:1,max:1e3,value:d,disabled:c.isPending,onChange:b=>p(b.target.value),onBlur:g,onKeyDown:b=>{b.key==="Enter"&&b.target.blur(),b.key==="Escape"&&p(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(OF,{cron:e.cron,nextRunAt:e.nextRunAt,onEdit:()=>m(!0),disabled:c.isPending})}),r("td",{className:"px-3 py-2 text-foreground-subtle",children:(()=>{const b=jF(a,e.lastSuccessAt),v=b===a?i:e.lastSuccessSizeBytes;return b!==void 0?r(HF,{at:b,sizeBytes:v}):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(kt,{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(MF,{destinationId:e.id,restoreSupported:e.restoreSupported,...s?{onOpenRestoreWizard:s}:{}})})}),f&&r(BF,{destinationName:e.displayName,currentCron:e.cron??"",onSave:x,onClose:()=>m(!1),saving:c.isPending,saveError:c.error instanceof Error?c.error.message:null})]})}function OF({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(gR,{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 ",zF(t)]})]})}function zF(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 BF({destinationName:e,currentCron:t,onSave:n,onClose:o,saving:s,saveError:a}){const[i,l]=P(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(Be,{className:"h-4 w-4"})})]}),u("div",{className:"p-4",children:[r(PF,{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 FF(){const{map:e}=Mc(ve.BackupCompleted,t=>t.destinationId);return V(()=>{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 jF(e,t){return e===void 0?t:t===void 0||e>t?e:t}function HF({at:e,sizeBytes:t}){const n=VF(e),o=V(()=>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:["· ",St(t)]})]})}function VF(e){const[,t]=P(0);return Y(()=>{const n=setInterval(()=>t(o=>o+1),3e4);return()=>clearInterval(n)},[]),UF(e)}function UF(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 qF=[["backup","list"]];function QF({initialDestinationId:e,initialArchiveId:t,onClose:n,onScheduled:o}){const s=we(),[a,i]=P(e&&t?2:1),[l,c]=P(e),[d,p]=P(t),[f,m]=P(new Set),{data:h}=zc(),g=h??[],{data:x,isLoading:b}=Bc({destinationId:l??""},{enabled:!!l}),v=x??[];Y(()=>{if(l!==void 0)return;const z=g.filter(A=>A.restoreSupported);z.length===1&&c(z[0].id)},[l,g]);const{data:w}=Wg({destinationId:l??"",backupId:d??""},{enabled:!!l&&!!d}),y=V(()=>w?.locations??[],[w]);Y(()=>{y.length!==0&&m(z=>z.size===0?new Set(y):z)},[y]);const N=Yg({onSuccess:()=>{s.invalidateQueries({queryKey:qF}),o(),n()}}),k=z=>{m(A=>{const T=new Set(A);return T.has(z)?T.delete(z):T.add(z),T})},C=!!l&&!!d,D=f.size>0,E=C&&D&&!N.isPending,I=()=>{!l||!d||N.mutate({destinationId:l,backupId:d,locations:[...f]})};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(Be,{className:"h-4 w-4"})})]}),a===1&&r(GF,{destinations:g,destinationId:l,onPickDestination:z=>{c(z),p(void 0),m(new Set)},archives:v,archivesLoading:b,archiveId:d,onPickArchive:p}),a===2&&r(KF,{locations:y,picked:f,onToggle:k}),a===3&&r(WF,{destinationName:g.find(z=>z.id===l)?.displayName??l??"",archive:v.find(z=>z.id===d),picked:[...f]}),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(vd,{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&&!C||a===2&&!D,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(sR,{className:"h-3 w-3"})]}):u("button",{onClick:I,disabled:!E,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(Se,{className:"h-3.5 w-3.5 animate-spin"}):r(qt,{className:"h-3.5 w-3.5"}),"Schedule Restore"]})]})]})]})})}function GF({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:St(c.sizeBytes)})]},c.id)})})]})]})}function KF({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:ZF(o)})]},o))})]})]})}function WF({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(hs,{term:"Destination",value:e}),r(hs,{term:"Archive",value:t?.label??t?.id??"—"}),t&&r(hs,{term:"Created",value:`${new Date(t.createdAt).toLocaleString()} · ${St(t.sizeBytes)}`}),r(hs,{term:"Locations",value:n.length>0?n.join(", "):"— (full archive)"})]})]})}function hs({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 YF={db:"Database",addons:"Addon configs","addons-data":"Addon data",tls:"TLS certificates",cache:"Cache",data:"Top-level data"};function ZF(e){return YF[e]??""}const XF=[["backup","list"]],JF=[["backup","listLocations"]];function ej(){const e=we(),t=et(),{data:n}=Kg(),o=Gg({onSuccess:()=>{e.invalidateQueries({queryKey:XF}),e.invalidateQueries({queryKey:[["backup","listDestinations"]]}),e.invalidateQueries({queryKey:[["backup","listArchives"]]})}}),s=Ag(),[a,i]=P(null),[l,c]=P(null),[d,p]=P(!1),[f,m]=P(!1),[h,g]=P(!1),x=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(tt,{children:[u("div",{className:"flex items-center justify-end gap-2 flex-wrap",children:[u("button",{onClick:()=>p(!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(qt,{className:"h-3.5 w-3.5"}),"Restore…"]}),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(kt,{className:"h-3.5 w-3.5"}),"Add destination"]})]}),f&&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(qt,{className:"h-3.5 w-3.5"}),r("span",{children:"Restore scheduled. Restart the server to apply."})]}),u("button",{onClick:()=>{x()},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(Se,{className:"h-3.5 w-3.5 animate-spin"}):r(qt,{className:"h-3.5 w-3.5"}),"Restart Now"]})]})}),r(TF,{onCreateAt:b=>i(b),onOpenRestoreWizard:b=>c(b)}),a&&r(tj,{destination:a,locations:n??[],onClose:()=>i(null),onSubmit:(b,v)=>{o.mutate({destinations:[a.id],locations:b,label:v||void 0},{onSuccess:()=>{i(null),e.invalidateQueries({queryKey:JF})}})},submitting:o.isPending}),(l||d)&&r(QF,{...l?{initialDestinationId:l.destinationId,initialArchiveId:l.archiveId}:{},onClose:()=>{c(null),p(!1)},onScheduled:()=>m(!0)}),h&&r(kv,{initialType:"backups",onClose:()=>g(!1),onCreated:()=>{g(!1),e.invalidateQueries({queryKey:[["backup","listDestinations"]]})}})]})}function tj({destination:e,locations:t,onClose:n,onSubmit:o,submitting:s}){const a=t.filter(f=>f.present),[i,l]=P(""),[c,d]=P(()=>new Set(a.map(f=>f.name))),p=f=>{d(m=>{const h=new Set(m);return h.has(f)?h.delete(f):h.add(f),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:f=>f.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(Be,{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:f=>l(f.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(f=>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(f.name),onChange:()=>p(f.name),className:"accent-primary"}),r("span",{className:"font-mono text-foreground",children:f.name})]}),u("div",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[St(f.sizeBytes)," · ",f.fileCount," files"]})]},f.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(Se,{className:"h-3.5 w-3.5 animate-spin"}):r(y0,{className:"h-3.5 w-3.5"}),s?"Creating…":"Create"]})]})]})})}function nj(){return r("div",{className:"flex flex-col p-4",children:r(Fa,{tabs:[{id:"storage",label:"Storage",icon:Gs,content:r(kF,{})},{id:"backup",label:"Backup",icon:y0,content:r(ej,{})}]})})}function rj(){const{data:e,isLoading:t}=Dn(void 0,{staleTime:3e4}),n=(e??[]).find(s=>s.isHub&&s.isOnline),o=n?.addons.map(s=>s.id)??[];return r(tt,{children:t?r("div",{className:"text-muted-foreground text-sm py-12 text-center",children:"Loading hub topology…"}):n?o.length===0?r("div",{className:"text-muted-foreground text-sm py-12 text-center",children:"No addons installed on the hub yet."}):r(Gr,{nodeId:n.id,addonIds:o,level:"global"}):u("div",{className:"flex flex-col items-center justify-center text-muted-foreground text-sm gap-2 py-12",children:[r(Wt,{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 oj(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 sj({nodeId:e,addons:t,isHub:n}){const o=we(),s=et(),[a,i]=P(null),[l,c]=P(null),[d,p]=P(!1),[f,m]=P(null),[h,g]=P(0),x=re(null),b=wa(),v=Gb(),w=Xb({nodeId:e}),y=w.data??[],N=new Map(t.map(A=>[A.id,A.capabilities])),k=y.length>0?y.map(A=>({id:A.id,status:A.status,capabilities:N.get(A.id)??[],version:A.version,packageName:A.packageName})):t.map(A=>({id:A.id,status:A.status,capabilities:A.capabilities,version:void 0,packageName:void 0})),C=()=>{o.invalidateQueries({queryKey:[["nodes","topology"]]}),w.refetch()},D=async A=>{i(A);try{await b.mutateAsync({nodeId:e,addonId:A}),C()}catch(T){console.error("Failed to restart addon:",T)}finally{i(null)}},E=async A=>{if(await s({title:"Uninstall addon",message:`Remove "${A}" from ${e}? The addon directory will be deleted on disk.`,confirmLabel:"Uninstall",variant:"danger"})){c(A);try{await v.mutateAsync({nodeId:e,addonId:A}),C()}catch(R){console.error("Failed to uninstall addon:",R)}finally{c(null)}}},z=u("div",{className:"flex items-center gap-2 mb-2",children:[r("input",{ref:x,type:"file",accept:".tgz,.tar.gz",className:"hidden",onChange:async A=>{const T=A.target.files?.[0];if(T){A.target.value="",m(null),p(!0),g(0);try{const R=localStorage.getItem("camstack_admin_token");await oj({file:T,nodeId:e,token:R,onProgress:g}),C()}catch(R){m(R instanceof Error?R.message:String(R))}finally{p(!1),g(0)}}}}),u("button",{onClick:()=>x.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(Se,{className:"h-3 w-3 animate-spin"}):r(Ta,{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}%`}})}),f&&r("span",{className:"text-[10px] text-destructive",children:f})]});return k.length===0?u("div",{children:[z,r("div",{className:"py-4 text-xs text-muted-foreground text-center",children:w.isLoading?"Loading addons…":"No addons on this node"})]}):u("div",{children:[z,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:"Version"}),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:k.map(A=>u("tr",{className:"border-t border-border/50",children:[u("td",{className:"py-2 font-medium",children:[r("div",{children:A.id}),A.packageName&&r("div",{className:"text-[9px] text-muted-foreground",children:A.packageName})]}),r("td",{className:"py-2 text-muted-foreground",children:A.version??"—"}),r("td",{className:"py-2",children:r("div",{className:"flex flex-wrap gap-1",children:A.capabilities.length>0?A.capabilities.map(T=>r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400",children:T},T)):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 ${A.status==="running"?"bg-success/10 text-success":A.status==="error"?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground"}`,children:A.status})}),r("td",{className:"py-2",children:u("div",{className:"flex items-center gap-1 justify-end",children:[r("button",{onClick:()=>D(A.id),disabled:a===A.id||l===A.id,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:`Restart ${A.id}`,children:r(qt,{className:`h-3 w-3 ${a===A.id?"animate-spin":""}`})}),r("button",{onClick:()=>E(A.id),disabled:a===A.id||l===A.id,className:"p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50",title:`Uninstall ${A.id}`,children:l===A.id?r(Se,{className:"h-3 w-3 animate-spin"}):r(We,{className:"h-3 w-3"})})]})})]},A.id))})]})]})}function aj(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 ij({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"||e==="failed"?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground"}`,children:e})}const lj=["trace","debug","info","warn","error"];function cj({proc:e,nodeId:t,defaultExpanded:n,activePanel:o,onTogglePanel:s}){const a=e.services??[],i=a.length===1,[l,c]=P(i||n),[d,p]=P(null),[f,m]=P("info"),h=e.name.includes("(core)"),g=wa(),x=Kb(),b=Jb(),v=async N=>{p(N);try{await g.mutateAsync({nodeId:t,addonId:N})}catch(k){console.error("Failed to restart addon:",k)}finally{p(null)}},w=async()=>{p(e.name);try{await x.mutateAsync({nodeId:t,processName:e.name})}catch(N){console.error("Failed to restart process:",N)}finally{p(null)}},y=async N=>{const k=`${t}/${e.name}`;try{await b.mutateAsync({nodeId:k,level:N}),m(N)}catch(C){console.error("Failed to set log level:",C)}};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(Nt,{className:"h-3 w-3 text-muted-foreground shrink-0"}):r(zt,{className:"h-3 w-3 text-muted-foreground shrink-0"}),h?r(An,{className:"h-3.5 w-3.5 text-primary shrink-0"}):r(wd,{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(ij,{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:St(e.memoryRss)}),r("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:aj(e.uptimeSeconds)}),!h&&u("div",{className:"flex items-center gap-1",onClick:N=>N.stopPropagation(),children:[u(Ih,{children:[r(Ph,{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:f}),r(_h,{align:"end",className:"min-w-[70px] py-0.5",children:lj.map(N=>r($h,{onClick:()=>y(N),className:`h-auto px-2 py-1 text-[10px] font-mono ${N===f?"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(qt,{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(vt,{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(La,{className:"h-3 w-3"})}),r("button",{onClick:()=>v(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(qt,{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(Zt,{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(sr,{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 dj({nodeId:e,processes:t}){const[n,o]=P(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(cj,{proc:a,nodeId:e,defaultExpanded:i===0,activePanel:n,onTogglePanel:s},a.name))})}function uj(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 pj(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function fj({nodeId:e}){const t=we(),n=et(),[o,s]=P("all"),a=Br("metrics.node-processes-snapshot",k=>k.nodeId===e),{data:i}=Fb({nodeId:e},{staleTime:6e4}),l=a?.processes??i,c=V(()=>l?[...l]:[],[l]),d=V(()=>o==="ghost"?c.filter(k=>k.classification==="ghost"):c,[c,o]),p=V(()=>{const k=c.filter(D=>D.classification==="ghost"),C=new Map;for(const D of k)C.has(D.ppid)||C.set(D.ppid,[]),C.get(D.ppid).push(D);return[...C.entries()].filter(([,D])=>D.length>1).map(([D,E])=>({ppid:D,children:E})).sort((D,E)=>E.children.length-D.children.length)},[c]),f=jb({onSettled:()=>{t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]})}}),m=V(()=>{const k=new Map;for(const C of c)k.set(C.pid,C.classification);return k},[c]),h=async(k,C)=>{if(k.classification==="root"||k.classification==="system")return;const D=k.classification==="ghost"?"ghost":k.addonId??"process",E=C?"SIGKILL":"SIGTERM";await n({title:`Send ${E}?`,message:`Target pid ${k.pid} (${D}) on node ${e}.`,confirmLabel:`Send ${E}`,variant:"danger"})&&f.mutate({nodeId:e,pid:k.pid,force:C})},g=async(k,C)=>{try{await f.mutateAsync({nodeId:e,pid:k,force:C})}catch{}},x=async k=>{const C=m.get(k.ppid);if(C==="root"||C==="system"){await n({title:"Cannot kill protected ancestor",message:C==="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(E=>g(E.pid,!1))]),t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}))},b=async()=>{const k=c.filter(D=>D.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(D=>g(D.pid,!0))),t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}))},v=c.filter(k=>k.classification==="ghost").length,w=c.filter(k=>k.classification==="managed").length,y=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(it,{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:y})]}),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 ${v>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:[v>0&&r(ls,{className:"h-3 w-3 text-destructive"})," Ghosts"]}),r("div",{className:`text-xl font-semibold ${v>0?"text-destructive":"text-foreground"}`,children:v})]})]}),p.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(at,{className:"h-3 w-3"})," Recurring ghost parents (",p.length,")"]}),r("div",{className:"space-y-1.5",children:p.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:f.isPending,onClick:()=>{x(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(ls,{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 (",v,")"]})]}),v>0&&u("button",{type:"button",disabled:f.isPending,onClick:()=>{b()},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(ls,{className:"h-3 w-3"})," Kill all ",v," 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:pj(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:St(k.memoryRssBytes)}),r("td",{className:"px-3 py-2 text-right text-foreground-subtle",children:uj(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:f.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(We,{className:"h-3 w-3"})," Term"]}),u("button",{type:"button",disabled:f.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(ls,{className:"h-3 w-3"})," Kill"]})]})})]},k.pid))]})]})}),f.isError&&u("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive",children:["Kill failed: ",f.error instanceof Error?f.error.message:"unknown"]})]})}function mj({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(Gr,{nodeId:e,addonIds:t,level:"global"})})}function hj({nodeId:e,addons:t}){const n=we(),{data:o,isLoading:s}=ux({nodeId:e}),a=V(()=>{const l=new Map;for(const c of t)for(const d of c.capabilities){const p=l.get(d)??[];p.push(c.id),l.set(d,p)}return[...l.entries()].sort(([c],[d])=>c.localeCompare(d)).map(([c,d])=>({capName:c,providers:d}))},[t]),i=px({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 p=o?.[l]??c[0]??"",f=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:p,onChange:m=>i.mutate({nodeId:e,capName:l,addonId:m.target.value}),disabled:f||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:f?"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 gj(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 bj(e){const[t,n]=P(!1),[o,s]=P(e.name),a=we(),i=Wb({onSuccess:()=>{a.invalidateQueries({queryKey:[["nodes","topology"]]})}}),l=(e.localIps??[]).filter(f=>!f.includes(":")),c=(e.localIps??[]).filter(f=>f.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(f){console.error("Rename failed:",f)}},p=[["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:f=>s(f.target.value),onKeyDown:f=>{f.key==="Enter"&&d(),f.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(At,{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(Be,{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(Qr,{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:gj(e.uptime)})],["Engines",e.engines.length>0?r("div",{className:"flex flex-wrap gap-1",children:e.engines.map(f=>r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:f},f))}):r("span",{className:"text-xs text-muted-foreground",children:"—"})]];return l.length>0&&p.push(["IPv4",r("div",{className:"flex flex-wrap gap-1.5",children:l.map((f,m)=>r("span",{className:"font-mono text-xs px-1.5 py-0.5 rounded bg-muted",children:f},`${f}-${m}`))})]),c.length>0&&p.push(["IPv6",r("div",{className:"flex flex-wrap gap-1.5",children:c.map((f,m)=>r("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]",title:f,children:f},`${f}-${m}`))})]),r("div",{className:"py-2",children:r("table",{className:"w-full text-sm",children:r("tbody",{children:p.map(([f,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:f}),r("td",{className:"py-1.5 px-2",children:m})]},f))})})})}function xj({node:e}){const[t,n]=P("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(Ot,{className:"h-3 w-3"})," ",e.cpuPercent,"%"]}),u("span",{className:"flex items-center gap-1",children:[r(E0,{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(bj,{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(sj,{nodeId:e.id,addons:e.addons,isHub:e.isHub}),t==="forks"&&r(dj,{nodeId:e.id,processes:o}),t==="processes"&&r(fj,{nodeId:e.id}),t==="settings"&&r(mj,{nodeId:e.id,addonIds:s}),t==="capabilities"&&r(hj,{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 yj({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(xj,{node:n},n.id))})}const Bl=[{id:"providers",label:"Providers",color:"#3b82f6"},{id:"pipeline",label:"Pipeline",color:"#8b5cf6"},{id:"analytics",label:"Analytics",color:"#06b6d4"},{id:"exports",label:"Exports",color:"#10b981"},{id:"messaging",label:"Messaging",color:"#f59e0b"},{id:"networking",label:"Networking",color:"#ef4444"},{id:"system",label:"System",color:"#6b7280"}],sf=Bl[Bl.length-1];function vj(e){return e==null||e===""?sf:Bl.find(n=>n.id===e)??sf}function wj(e,t){return e===0?"healthy":t===0?"failed":t<e?"degraded":"healthy"}function Nj({category:e,total:t,healthy:n,onSelect:o}){const s=vj(e),a=wj(t,n),i=t>0,l=U(()=>{i&&o(e)},[i,o,e]),c=t===0?0:Math.round(n/t*100),d=u(ue,{children:[u("div",{className:"flex items-baseline justify-between",children:[r("span",{className:"text-[10px] font-medium",style:{color:s.color},children:s.label}),u("span",{className:"text-[10px] tabular-nums text-muted-foreground",children:[n,"/",t]})]}),r("div",{"data-testid":"health-bar","data-state":a,className:"mt-1 h-[3px] w-full rounded-full bg-muted overflow-hidden","aria-hidden":"true",children:r("div",{className:a==="healthy"?"h-full bg-success":a==="degraded"?"h-full bg-gradient-to-r from-success to-amber-500":"h-full bg-gradient-to-r from-success to-destructive",style:{width:`${c}%`}})})]});return i?r("button",{type:"button",onClick:l,className:"rounded-md px-2 py-1.5 cursor-pointer text-left hover:bg-muted/50 transition-colors","aria-label":`${s.label}: ${n}/${t}`,children:d}):r("div",{className:"rounded-md px-2 py-1.5 opacity-50 select-none",children:d})}const kj=Fe(Nj);function Sj({node:e,onSelectCategory:t}){const n=U(i=>{t(i)},[t]),o="border-2 border-dashed border-muted-foreground/30 opacity-50",s=e.isHub?"border-2 border-success":"border-2 border-dashed border-primary/60 bg-primary/5",a=(e.localIps??[]).filter(i=>!i.includes(":"));return u("div",{className:`rounded-xl bg-surface px-3 py-2.5 min-w-[260px] max-w-[320px] ${e.isOnline?s:o}`,"data-node-id":e.id,children:[u("div",{className:"flex items-center gap-1.5 mb-1.5",children:[r("div",{className:`w-2 h-2 rounded-full ${e.isOnline?"bg-success":"bg-destructive"}`}),r("span",{className:"text-xs font-semibold truncate flex-1",children:e.name}),e.isHub?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"})]}),(e.hostname||a.length>0)&&u("div",{className:"text-[9px] text-muted-foreground mb-1.5 space-y-0.5",children:[e.hostname&&r("div",{className:"truncate",children:e.hostname}),a.length>0&&r("div",{className:"truncate font-mono opacity-70",children:a.join(", ")})]}),e.isOnline&&u("div",{className:"flex items-center gap-3 text-[10px] text-muted-foreground mb-2",children:[u("span",{className:"flex items-center gap-0.5",children:[r(Ot,{className:"h-2.5 w-2.5"}),e.cpuPercent,"%"]}),u("span",{className:"flex items-center gap-0.5",children:[r(E0,{className:"h-2.5 w-2.5"}),e.memoryPercent,"%"]})]}),r("div",{className:"grid grid-cols-3 gap-1",children:e.categories.map(i=>r(kj,{category:i.category,total:i.total,healthy:i.healthy,onSelect:n},i.category))})]})}const Cj=Fe(Sj);function Mj({mode:e,onClose:t,onModeChange:n,renderCategoryDetail:o}){const s=(a,i)=>{n({kind:"log",agentId:a,addonId:i})};return u("div",{className:"fixed bottom-0 left-0 right-0 h-[180px] border-t border-border bg-background shadow-lg z-40 flex flex-col",children:[u("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border",children:[r("span",{className:"text-xs font-semibold text-muted-foreground",children:e.kind==="log"?`Logs · ${e.addonId??e.agentId}`:`${e.category} · ${e.nodeId}`}),r("button",{type:"button",onClick:t,className:"p-1 rounded hover:bg-muted text-muted-foreground","aria-label":"Close dock",children:r(Be,{className:"h-3 w-3"})})]}),r("div",{className:"flex-1 overflow-hidden",children:e.kind==="log"?r(Hy,{addonId:e.addonId,agentId:e.agentId,showScope:!0,onClose:t}):o({nodeId:e.nodeId,category:e.category,switchToLog:s})})]})}const Aj=Fe(Mj);function Ej(e){return`${Math.round(e/1024/1024)}MB`}function Ij({nodeId:e,category:t,addons:n,onShowLog:o,onRestartAddon:s}){const a=U(l=>o(e,l),[e,o]),i=U(l=>s(e,l),[e,s]);return r("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 p-3 overflow-auto","data-category":t,children:n.map(l=>{const c=l.status==="running";return u("div",{"data-testid":"addon-tile","data-addon-id":l.id,className:"rounded-md border border-border px-2 py-1.5 text-[10px] flex items-center gap-2",children:[r("div",{"data-status":l.status,className:`w-2 h-2 rounded-full ${c?"bg-success":"bg-destructive"}`}),u("div",{className:"flex-1 min-w-0",children:[r("div",{className:"font-medium truncate",children:l.id}),u("div",{className:"text-muted-foreground",children:[l.cpuPercent,"% · ",Ej(l.memoryRss)]})]}),r("button",{type:"button",onClick:()=>a(l.id),"aria-label":`Show logs for ${l.id}`,className:"p-1 rounded hover:bg-muted text-muted-foreground",children:r(vt,{className:"h-3 w-3"})}),r("button",{type:"button",onClick:()=>i(l.id),"aria-label":`Restart ${l.id}`,className:"p-1 rounded hover:bg-muted text-muted-foreground",children:r(qt,{className:"h-3 w-3"})})]},l.id)})})}const Pj=Fe(Ij);function _j({topology:e}){const[t,n]=P(null),o=wa(),s=e.filter(d=>d.isOnline),a=U((d,p)=>{n({kind:"category-detail",nodeId:d,category:p})},[]),i=U(()=>n(null),[]),l=U((d,p)=>e.find(h=>h.id===d)?.categories.find(h=>h.category===p)?.addons??[],[e]),c=U((d,p)=>{o.mutateAsync({nodeId:d,addonId:p})},[o]);return u("div",{className:"flex flex-col flex-1 min-h-0",children:[r("div",{className:"flex flex-wrap gap-4 p-4 overflow-auto flex-1",children:s.map(d=>r(Cj,{node:d,onSelectCategory:p=>a(d.id,p)},d.id))}),t&&r(Aj,{mode:t,onClose:i,onModeChange:n,renderCategoryDetail:({nodeId:d,category:p,switchToLog:f})=>r(Pj,{nodeId:d,category:p,addons:l(d,p),onShowLog:(m,h)=>f(m,h),onRestartAddon:c})})]})}function Ye(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=Ye(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var $j={value:()=>{}};function ja(){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 Ds(n)}function Ds(e){this._=e}function Dj(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}})}Ds.prototype=ja.prototype={constructor:Ds,on:function(e,t){var n=this._,o=Dj(e+"",n),s,a=-1,i=o.length;if(arguments.length<2){for(;++a<i;)if((s=(e=o[a]).type)&&(s=Lj(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]=af(n[s],e.name,t);else if(t==null)for(s in n)n[s]=af(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 Ds(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 Lj(e,t){for(var n=0,o=e.length,s;n<o;++n)if((s=e[n]).name===t)return s.value}function af(e,t,n){for(var o=0,s=e.length;o<s;++o)if(e[o].name===t){e[o]=$j,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var Fl="http://www.w3.org/1999/xhtml";const lf={svg:"http://www.w3.org/2000/svg",xhtml:Fl,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ha(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),lf.hasOwnProperty(t)?{space:lf[t],local:e}:e}function Tj(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Fl&&t.documentElement.namespaceURI===Fl?t.createElement(e):t.createElementNS(n,e)}}function Rj(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Cv(e){var t=Ha(e);return(t.local?Rj:Tj)(t)}function Oj(){}function _d(e){return e==null?Oj:function(){return this.querySelector(e)}}function zj(e){typeof e!="function"&&(e=_d(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,p=0;p<i;++p)(c=a[p])&&(d=e.call(c,c.__data__,p,a))&&("__data__"in c&&(d.__data__=c.__data__),l[p]=d);return new gt(o,this._parents)}function Bj(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Fj(){return[]}function Mv(e){return e==null?Fj:function(){return this.querySelectorAll(e)}}function jj(e){return function(){return Bj(e.apply(this,arguments))}}function Hj(e){typeof e=="function"?e=jj(e):e=Mv(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 gt(o,s)}function Av(e){return function(){return this.matches(e)}}function Ev(e){return function(t){return t.matches(e)}}var Vj=Array.prototype.find;function Uj(e){return function(){return Vj.call(this.children,e)}}function qj(){return this.firstElementChild}function Qj(e){return this.select(e==null?qj:Uj(typeof e=="function"?e:Ev(e)))}var Gj=Array.prototype.filter;function Kj(){return Array.from(this.children)}function Wj(e){return function(){return Gj.call(this.children,e)}}function Yj(e){return this.selectAll(e==null?Kj:Wj(typeof e=="function"?e:Ev(e)))}function Zj(e){typeof e!="function"&&(e=Av(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 gt(o,this._parents)}function Iv(e){return new Array(e.length)}function Xj(){return new gt(this._enter||this._groups.map(Iv),this._parents)}function ta(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ta.prototype={constructor:ta,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 Jj(e){return function(){return e}}function eH(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 ta(e,a[i]);for(;i<c;++i)(l=t[i])&&(s[i]=l)}function tH(e,t,n,o,s,a,i){var l,c,d=new Map,p=t.length,f=a.length,m=new Array(p),h;for(l=0;l<p;++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<f;++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 ta(e,a[l]);for(l=0;l<p;++l)(c=t[l])&&d.get(m[l])===c&&(s[l]=c)}function nH(e){return e.__data__}function rH(e,t){if(!arguments.length)return Array.from(this,nH);var n=t?tH:eH,o=this._parents,s=this._groups;typeof e!="function"&&(e=Jj(e));for(var a=s.length,i=new Array(a),l=new Array(a),c=new Array(a),d=0;d<a;++d){var p=o[d],f=s[d],m=f.length,h=oH(e.call(p,p&&p.__data__,d,o)),g=h.length,x=l[d]=new Array(g),b=i[d]=new Array(g),v=c[d]=new Array(m);n(p,f,x,b,v,h,t);for(var w=0,y=0,N,k;w<g;++w)if(N=x[w]){for(w>=y&&(y=w+1);!(k=b[y])&&++y<g;);N._next=k||null}}return i=new gt(i,o),i._enter=l,i._exit=c,i}function oH(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function sH(){return new gt(this._exit||this._groups.map(Iv),this._parents)}function aH(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 iH(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],p=o[c],f=d.length,m=l[c]=new Array(f),h,g=0;g<f;++g)(h=d[g]||p[g])&&(m[g]=h);for(;c<s;++c)l[c]=n[c];return new gt(l,this._parents)}function lH(){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 cH(e){e||(e=dH);function t(f,m){return f&&m?e(f.__data__,m.__data__):!f-!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,p=0;p<l;++p)(d=i[p])&&(c[p]=d);c.sort(t)}return new gt(s,this._parents).order()}function dH(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function uH(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function pH(){return Array.from(this)}function fH(){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 mH(){let e=0;for(const t of this)++e;return e}function hH(){return!this.node()}function gH(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 bH(e){return function(){this.removeAttribute(e)}}function xH(e){return function(){this.removeAttributeNS(e.space,e.local)}}function yH(e,t){return function(){this.setAttribute(e,t)}}function vH(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function wH(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function NH(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 kH(e,t){var n=Ha(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?xH:bH:typeof t=="function"?n.local?NH:wH:n.local?vH:yH)(n,t))}function Pv(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function SH(e){return function(){this.style.removeProperty(e)}}function CH(e,t,n){return function(){this.style.setProperty(e,t,n)}}function MH(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function AH(e,t,n){return arguments.length>1?this.each((t==null?SH:typeof t=="function"?MH:CH)(e,t,n??"")):Mr(this.node(),e)}function Mr(e,t){return e.style.getPropertyValue(t)||Pv(e).getComputedStyle(e,null).getPropertyValue(t)}function EH(e){return function(){delete this[e]}}function IH(e,t){return function(){this[e]=t}}function PH(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function _H(e,t){return arguments.length>1?this.each((t==null?EH:typeof t=="function"?PH:IH)(e,t)):this.node()[e]}function _v(e){return e.trim().split(/^|\s+/)}function $d(e){return e.classList||new $v(e)}function $v(e){this._node=e,this._names=_v(e.getAttribute("class")||"")}$v.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 Dv(e,t){for(var n=$d(e),o=-1,s=t.length;++o<s;)n.add(t[o])}function Lv(e,t){for(var n=$d(e),o=-1,s=t.length;++o<s;)n.remove(t[o])}function $H(e){return function(){Dv(this,e)}}function DH(e){return function(){Lv(this,e)}}function LH(e,t){return function(){(t.apply(this,arguments)?Dv:Lv)(this,e)}}function TH(e,t){var n=_v(e+"");if(arguments.length<2){for(var o=$d(this.node()),s=-1,a=n.length;++s<a;)if(!o.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?LH:t?$H:DH)(n,t))}function RH(){this.textContent=""}function OH(e){return function(){this.textContent=e}}function zH(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function BH(e){return arguments.length?this.each(e==null?RH:(typeof e=="function"?zH:OH)(e)):this.node().textContent}function FH(){this.innerHTML=""}function jH(e){return function(){this.innerHTML=e}}function HH(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function VH(e){return arguments.length?this.each(e==null?FH:(typeof e=="function"?HH:jH)(e)):this.node().innerHTML}function UH(){this.nextSibling&&this.parentNode.appendChild(this)}function qH(){return this.each(UH)}function QH(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function GH(){return this.each(QH)}function KH(e){var t=typeof e=="function"?e:Cv(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function WH(){return null}function YH(e,t){var n=typeof e=="function"?e:Cv(e),o=t==null?WH:typeof t=="function"?t:_d(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function ZH(){var e=this.parentNode;e&&e.removeChild(this)}function XH(){return this.each(ZH)}function JH(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function eV(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tV(e){return this.select(e?eV:JH)}function nV(e){return arguments.length?this.property("__data__",e):this.node().__data__}function rV(e){return function(t){e.call(this,t,this.__data__)}}function oV(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 sV(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 aV(e,t,n){return function(){var o=this.__on,s,a=rV(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 iV(e,t,n){var o=oV(e+""),s,a=o.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,d=l.length,p;c<d;++c)for(s=0,p=l[c];s<a;++s)if((i=o[s]).type===p.type&&i.name===p.name)return p.value}return}for(l=t?aV:sV,s=0;s<a;++s)this.each(l(o[s],t,n));return this}function Tv(e,t,n){var o=Pv(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 lV(e,t){return function(){return Tv(this,e,t)}}function cV(e,t){return function(){return Tv(this,e,t.apply(this,arguments))}}function dV(e,t){return this.each((typeof t=="function"?cV:lV)(e,t))}function*uV(){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 Rv=[null];function gt(e,t){this._groups=e,this._parents=t}function Go(){return new gt([[document.documentElement]],Rv)}function pV(){return this}gt.prototype=Go.prototype={constructor:gt,select:zj,selectAll:Hj,selectChild:Qj,selectChildren:Yj,filter:Zj,data:rH,enter:Xj,exit:sH,join:aH,merge:iH,selection:pV,order:lH,sort:cH,call:uH,nodes:pH,node:fH,size:mH,empty:hH,each:gH,attr:kH,style:AH,property:_H,classed:TH,text:BH,html:VH,raise:qH,lower:GH,append:KH,insert:YH,remove:XH,clone:tV,datum:nV,on:iV,dispatch:dV,[Symbol.iterator]:uV};function pt(e){return typeof e=="string"?new gt([[document.querySelector(e)]],[document.documentElement]):new gt([[e]],Rv)}function fV(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Pt(e,t){if(e=fV(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 mV={passive:!1},Mo={capture:!0,passive:!1};function ji(e){e.stopImmediatePropagation()}function gr(e){e.preventDefault(),e.stopImmediatePropagation()}function Ov(e){var t=e.document.documentElement,n=pt(e).on("dragstart.drag",gr,Mo);"onselectstart"in t?n.on("selectstart.drag",gr,Mo):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function zv(e,t){var n=e.document.documentElement,o=pt(e).on("dragstart.drag",null);t&&(o.on("click.drag",gr,Mo),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 gs=e=>()=>e;function jl(e,{sourceEvent:t,subject:n,target:o,identifier:s,active:a,x:i,y:l,dx:c,dy:d,dispatch:p}){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:p}})}jl.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function hV(e){return!e.ctrlKey&&!e.button}function gV(){return this.parentNode}function bV(e,t){return t??{x:e.x,y:e.y}}function xV(){return navigator.maxTouchPoints||"ontouchstart"in this}function Bv(){var e=hV,t=gV,n=bV,o=xV,s={},a=ja("start","drag","end"),i=0,l,c,d,p,f=0;function m(N){N.on("mousedown.drag",h).filter(o).on("touchstart.drag",b).on("touchmove.drag",v,mV).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(!(p||!e.call(this,N,k))){var C=y(this,t.call(this,N,k),N,k,"mouse");C&&(pt(N.view).on("mousemove.drag",g,Mo).on("mouseup.drag",x,Mo),Ov(N.view),ji(N),d=!1,l=N.clientX,c=N.clientY,C("start",N))}}function g(N){if(gr(N),!d){var k=N.clientX-l,C=N.clientY-c;d=k*k+C*C>f}s.mouse("drag",N)}function x(N){pt(N.view).on("mousemove.drag mouseup.drag",null),zv(N.view,d),gr(N),s.mouse("end",N)}function b(N,k){if(e.call(this,N,k)){var C=N.changedTouches,D=t.call(this,N,k),E=C.length,I,z;for(I=0;I<E;++I)(z=y(this,D,N,k,C[I].identifier,C[I]))&&(ji(N),z("start",N,C[I]))}}function v(N){var k=N.changedTouches,C=k.length,D,E;for(D=0;D<C;++D)(E=s[k[D].identifier])&&(gr(N),E("drag",N,k[D]))}function w(N){var k=N.changedTouches,C=k.length,D,E;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),D=0;D<C;++D)(E=s[k[D].identifier])&&(ji(N),E("end",N,k[D]))}function y(N,k,C,D,E,I){var z=a.copy(),A=Pt(I||C,k),T,R,M;if((M=n.call(N,new jl("beforestart",{sourceEvent:C,target:m,identifier:E,active:i,x:A[0],y:A[1],dx:0,dy:0,dispatch:z}),D))!=null)return T=M.x-A[0]||0,R=M.y-A[1]||0,function $(L,O,F){var B=A,j;switch(L){case"start":s[E]=$,j=i++;break;case"end":delete s[E],--i;case"drag":A=Pt(F||O,k),j=i;break}z.call(L,N,new jl(L,{sourceEvent:O,subject:M,target:m,identifier:E,active:j,x:A[0]+T,y:A[1]+R,dx:A[0]-B[0],dy:A[1]-B[1],dispatch:z}),D)}}return m.filter=function(N){return arguments.length?(e=typeof N=="function"?N:gs(!!N),m):e},m.container=function(N){return arguments.length?(t=typeof N=="function"?N:gs(N),m):t},m.subject=function(N){return arguments.length?(n=typeof N=="function"?N:gs(N),m):n},m.touchable=function(N){return arguments.length?(o=typeof N=="function"?N:gs(!!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?(f=(N=+N)*N,m):Math.sqrt(f)},m}function Dd(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Fv(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function Ko(){}var Ao=.7,na=1/Ao,br="\\s*([+-]?\\d+)\\s*",Eo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",yV=/^#([0-9a-f]{3,8})$/,vV=new RegExp(`^rgb\\(${br},${br},${br}\\)$`),wV=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),NV=new RegExp(`^rgba\\(${br},${br},${br},${Eo}\\)$`),kV=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${Eo}\\)$`),SV=new RegExp(`^hsl\\(${Eo},${Gt},${Gt}\\)$`),CV=new RegExp(`^hsla\\(${Eo},${Gt},${Gt},${Eo}\\)$`),cf={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};Dd(Ko,Wn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:df,formatHex:df,formatHex8:MV,formatHsl:AV,formatRgb:uf,toString:uf});function df(){return this.rgb().formatHex()}function MV(){return this.rgb().formatHex8()}function AV(){return jv(this).formatHsl()}function uf(){return this.rgb().formatRgb()}function Wn(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=yV.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?pf(t):n===3?new st(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?bs(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?bs(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=vV.exec(e))?new st(t[1],t[2],t[3],1):(t=wV.exec(e))?new st(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=NV.exec(e))?bs(t[1],t[2],t[3],t[4]):(t=kV.exec(e))?bs(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=SV.exec(e))?hf(t[1],t[2]/100,t[3]/100,1):(t=CV.exec(e))?hf(t[1],t[2]/100,t[3]/100,t[4]):cf.hasOwnProperty(e)?pf(cf[e]):e==="transparent"?new st(NaN,NaN,NaN,0):null}function pf(e){return new st(e>>16&255,e>>8&255,e&255,1)}function bs(e,t,n,o){return o<=0&&(e=t=n=NaN),new st(e,t,n,o)}function EV(e){return e instanceof Ko||(e=Wn(e)),e?(e=e.rgb(),new st(e.r,e.g,e.b,e.opacity)):new st}function Hl(e,t,n,o){return arguments.length===1?EV(e):new st(e,t,n,o??1)}function st(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}Dd(st,Hl,Fv(Ko,{brighter(e){return e=e==null?na:Math.pow(na,e),new st(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ao:Math.pow(Ao,e),new st(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new st(Vn(this.r),Vn(this.g),Vn(this.b),ra(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:ff,formatHex:ff,formatHex8:IV,formatRgb:mf,toString:mf}));function ff(){return`#${jn(this.r)}${jn(this.g)}${jn(this.b)}`}function IV(){return`#${jn(this.r)}${jn(this.g)}${jn(this.b)}${jn((isNaN(this.opacity)?1:this.opacity)*255)}`}function mf(){const e=ra(this.opacity);return`${e===1?"rgb(":"rgba("}${Vn(this.r)}, ${Vn(this.g)}, ${Vn(this.b)}${e===1?")":`, ${e})`}`}function ra(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Vn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function jn(e){return e=Vn(e),(e<16?"0":"")+e.toString(16)}function hf(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new _t(e,t,n,o)}function jv(e){if(e instanceof _t)return new _t(e.h,e.s,e.l,e.opacity);if(e instanceof Ko||(e=Wn(e)),!e)return new _t;if(e instanceof _t)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 _t(i,l,c,e.opacity)}function PV(e,t,n,o){return arguments.length===1?jv(e):new _t(e,t,n,o??1)}function _t(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}Dd(_t,PV,Fv(Ko,{brighter(e){return e=e==null?na:Math.pow(na,e),new _t(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ao:Math.pow(Ao,e),new _t(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 st(Hi(e>=240?e-240:e+120,s,o),Hi(e,s,o),Hi(e<120?e+240:e-120,s,o),this.opacity)},clamp(){return new _t(gf(this.h),xs(this.s),xs(this.l),ra(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=ra(this.opacity);return`${e===1?"hsl(":"hsla("}${gf(this.h)}, ${xs(this.s)*100}%, ${xs(this.l)*100}%${e===1?")":`, ${e})`}`}}));function gf(e){return e=(e||0)%360,e<0?e+360:e}function xs(e){return Math.max(0,Math.min(1,e||0))}function Hi(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 Ld=e=>()=>e;function _V(e,t){return function(n){return e+n*t}}function $V(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 DV(e){return(e=+e)==1?Hv:function(t,n){return n-t?$V(t,n,e):Ld(isNaN(t)?n:t)}}function Hv(e,t){var n=t-e;return n?_V(e,n):Ld(isNaN(e)?t:e)}const oa=(function e(t){var n=DV(t);function o(s,a){var i=n((s=Hl(s)).r,(a=Hl(a)).r),l=n(s.g,a.g),c=n(s.b,a.b),d=Hv(s.opacity,a.opacity);return function(p){return s.r=i(p),s.g=l(p),s.b=c(p),s.opacity=d(p),s+""}}return o.gamma=e,o})(1);function LV(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 TV(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function RV(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]=go(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 OV(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 zV(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]=go(e[s],t[s]):o[s]=t[s];return function(a){for(s in n)o[s]=n[s](a);return o}}var Vl=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Vi=new RegExp(Vl.source,"g");function BV(e){return function(){return e}}function FV(e){return function(t){return e(t)+""}}function Vv(e,t){var n=Vl.lastIndex=Vi.lastIndex=0,o,s,a,i=-1,l=[],c=[];for(e=e+"",t=t+"";(o=Vl.exec(e))&&(s=Vi.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=Vi.lastIndex;return n<t.length&&(a=t.slice(n),l[i]?l[i]+=a:l[++i]=a),l.length<2?c[0]?FV(c[0].x):BV(t):(t=c.length,function(d){for(var p=0,f;p<t;++p)l[(f=c[p]).i]=f.x(d);return l.join("")})}function go(e,t){var n=typeof t,o;return t==null||n==="boolean"?Ld(t):(n==="number"?Ht:n==="string"?(o=Wn(t))?(t=o,oa):Vv:t instanceof Wn?oa:t instanceof Date?OV:TV(t)?LV:Array.isArray(t)?RV:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?zV:Ht)(e,t)}var bf=180/Math.PI,Ul={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Uv(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)*bf,skewX:Math.atan(c)*bf,scaleX:i,scaleY:l}}var ys;function jV(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Ul:Uv(t.a,t.b,t.c,t.d,t.e,t.f)}function HV(e){return e==null||(ys||(ys=document.createElementNS("http://www.w3.org/2000/svg","g")),ys.setAttribute("transform",e),!(e=ys.transform.baseVal.consolidate()))?Ul:(e=e.matrix,Uv(e.a,e.b,e.c,e.d,e.e,e.f))}function qv(e,t,n,o){function s(d){return d.length?d.pop()+" ":""}function a(d,p,f,m,h,g){if(d!==f||p!==m){var x=h.push("translate(",null,t,null,n);g.push({i:x-4,x:Ht(d,f)},{i:x-2,x:Ht(p,m)})}else(f||m)&&h.push("translate("+f+t+m+n)}function i(d,p,f,m){d!==p?(d-p>180?p+=360:p-d>180&&(d+=360),m.push({i:f.push(s(f)+"rotate(",null,o)-2,x:Ht(d,p)})):p&&f.push(s(f)+"rotate("+p+o)}function l(d,p,f,m){d!==p?m.push({i:f.push(s(f)+"skewX(",null,o)-2,x:Ht(d,p)}):p&&f.push(s(f)+"skewX("+p+o)}function c(d,p,f,m,h,g){if(d!==f||p!==m){var x=h.push(s(h)+"scale(",null,",",null,")");g.push({i:x-4,x:Ht(d,f)},{i:x-2,x:Ht(p,m)})}else(f!==1||m!==1)&&h.push(s(h)+"scale("+f+","+m+")")}return function(d,p){var f=[],m=[];return d=e(d),p=e(p),a(d.translateX,d.translateY,p.translateX,p.translateY,f,m),i(d.rotate,p.rotate,f,m),l(d.skewX,p.skewX,f,m),c(d.scaleX,d.scaleY,p.scaleX,p.scaleY,f,m),d=p=null,function(h){for(var g=-1,x=m.length,b;++g<x;)f[(b=m[g]).i]=b.x(h);return f.join("")}}}var VV=qv(jV,"px, ","px)","deg)"),UV=qv(HV,", ",")",")"),qV=1e-12;function xf(e){return((e=Math.exp(e))+1/e)/2}function QV(e){return((e=Math.exp(e))-1/e)/2}function GV(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ls=(function e(t,n,o){function s(a,i){var l=a[0],c=a[1],d=a[2],p=i[0],f=i[1],m=i[2],h=p-l,g=f-c,x=h*h+g*g,b,v;if(x<qV)v=Math.log(m/d)/t,b=function(D){return[l+D*h,c+D*g,d*Math.exp(t*D*v)]};else{var w=Math.sqrt(x),y=(m*m-d*d+o*x)/(2*d*n*w),N=(m*m-d*d-o*x)/(2*m*n*w),k=Math.log(Math.sqrt(y*y+1)-y),C=Math.log(Math.sqrt(N*N+1)-N);v=(C-k)/t,b=function(D){var E=D*v,I=xf(k),z=d/(n*w)*(I*GV(t*E+k)-QV(k));return[l+z*h,c+z*g,d*I/xf(t*E+k)]}}return b.duration=v*1e3*t/Math.SQRT2,b}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 Ar=0,so=0,eo=0,Qv=1e3,sa,ao,aa=0,Yn=0,Va=0,Io=typeof performance=="object"&&performance.now?performance:Date,Gv=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Td(){return Yn||(Gv(KV),Yn=Io.now()+Va)}function KV(){Yn=0}function ia(){this._call=this._time=this._next=null}ia.prototype=Kv.prototype={constructor:ia,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Td():+n)+(t==null?0:+t),!this._next&&ao!==this&&(ao?ao._next=this:sa=this,ao=this),this._call=e,this._time=n,ql()},stop:function(){this._call&&(this._call=null,this._time=1/0,ql())}};function Kv(e,t,n){var o=new ia;return o.restart(e,t,n),o}function WV(){Td(),++Ar;for(var e=sa,t;e;)(t=Yn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ar}function yf(){Yn=(aa=Io.now())+Va,Ar=so=0;try{WV()}finally{Ar=0,ZV(),Yn=0}}function YV(){var e=Io.now(),t=e-aa;t>Qv&&(Va-=t,aa=e)}function ZV(){for(var e,t=sa,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:sa=n);ao=e,ql(o)}function ql(e){if(!Ar){so&&(so=clearTimeout(so));var t=e-Yn;t>24?(e<1/0&&(so=setTimeout(yf,e-Io.now()-Va)),eo&&(eo=clearInterval(eo))):(eo||(aa=Io.now(),eo=setInterval(YV,Qv)),Ar=1,Gv(yf))}}function vf(e,t,n){var o=new ia;return t=t==null?0:+t,o.restart(s=>{o.stop(),e(s+t)},t,n),o}var XV=ja("start","end","cancel","interrupt"),JV=[],Wv=0,wf=1,Ql=2,Ts=3,Nf=4,Gl=5,Rs=6;function Ua(e,t,n,o,s,a){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;eU(e,n,{name:t,index:o,group:s,on:XV,tween:JV,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:Wv})}function Rd(e,t){var n=Ft(e,t);if(n.state>Wv)throw new Error("too late; already scheduled");return n}function Jt(e,t){var n=Ft(e,t);if(n.state>Ts)throw new Error("too late; already running");return n}function Ft(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function eU(e,t,n){var o=e.__transition,s;o[t]=n,n.timer=Kv(a,0,n.time);function a(d){n.state=wf,n.timer.restart(i,n.delay,n.time),n.delay<=d&&i(d-n.delay)}function i(d){var p,f,m,h;if(n.state!==wf)return c();for(p in o)if(h=o[p],h.name===n.name){if(h.state===Ts)return vf(i);h.state===Nf?(h.state=Rs,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[p]):+p<t&&(h.state=Rs,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[p])}if(vf(function(){n.state===Ts&&(n.state=Nf,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=Ql,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Ql){for(n.state=Ts,s=new Array(m=n.tween.length),p=0,f=-1;p<m;++p)(h=n.tween[p].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=h);s.length=f+1}}function l(d){for(var p=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(c),n.state=Gl,1),f=-1,m=s.length;++f<m;)s[f].call(e,p);n.state===Gl&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Rs,n.timer.stop(),delete o[t];for(var d in o)return;delete e.__transition}}function Os(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>Ql&&o.state<Gl,o.state=Rs,o.timer.stop(),o.on.call(s?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[i]}a&&delete e.__transition}}function tU(e){return this.each(function(){Os(this,e)})}function nU(e,t){var n,o;return function(){var s=Jt(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 rU(e,t,n){var o,s;if(typeof n!="function")throw new Error;return function(){var a=Jt(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 oU(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=Ft(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?nU:rU)(n,e,t))}function Od(e,t,n){var o=e._id;return e.each(function(){var s=Jt(this,o);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Ft(s,o).value[t]}}function Yv(e,t){var n;return(typeof t=="number"?Ht:t instanceof Wn?oa:(n=Wn(t))?(t=n,oa):Vv)(e,t)}function sU(e){return function(){this.removeAttribute(e)}}function aU(e){return function(){this.removeAttributeNS(e.space,e.local)}}function iU(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 lU(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 cU(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 dU(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 uU(e,t){var n=Ha(e),o=n==="transform"?UV:Yv;return this.attrTween(e,typeof t=="function"?(n.local?dU:cU)(n,o,Od(this,"attr."+e,t)):t==null?(n.local?aU:sU)(n):(n.local?lU:iU)(n,o,t))}function pU(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function fU(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function mU(e,t){var n,o;function s(){var a=t.apply(this,arguments);return a!==o&&(n=(o=a)&&fU(e,a)),n}return s._value=t,s}function hU(e,t){var n,o;function s(){var a=t.apply(this,arguments);return a!==o&&(n=(o=a)&&pU(e,a)),n}return s._value=t,s}function gU(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=Ha(e);return this.tween(n,(o.local?mU:hU)(o,t))}function bU(e,t){return function(){Rd(this,e).delay=+t.apply(this,arguments)}}function xU(e,t){return t=+t,function(){Rd(this,e).delay=t}}function yU(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?bU:xU)(t,e)):Ft(this.node(),t).delay}function vU(e,t){return function(){Jt(this,e).duration=+t.apply(this,arguments)}}function wU(e,t){return t=+t,function(){Jt(this,e).duration=t}}function NU(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?vU:wU)(t,e)):Ft(this.node(),t).duration}function kU(e,t){if(typeof t!="function")throw new Error;return function(){Jt(this,e).ease=t}}function SU(e){var t=this._id;return arguments.length?this.each(kU(t,e)):Ft(this.node(),t).ease}function CU(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Jt(this,e).ease=n}}function MU(e){if(typeof e!="function")throw new Error;return this.each(CU(this._id,e))}function AU(e){typeof e!="function"&&(e=Av(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 fn(o,this._parents,this._name,this._id)}function EU(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],p=c.length,f=i[l]=new Array(p),m,h=0;h<p;++h)(m=c[h]||d[h])&&(f[h]=m);for(;l<o;++l)i[l]=t[l];return new fn(i,this._parents,this._name,this._id)}function IU(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 PU(e,t,n){var o,s,a=IU(t)?Rd:Jt;return function(){var i=a(this,e),l=i.on;l!==o&&(s=(o=l).copy()).on(t,n),i.on=s}}function _U(e,t){var n=this._id;return arguments.length<2?Ft(this.node(),n).on.on(e):this.each(PU(n,e,t))}function $U(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function DU(){return this.on("end.remove",$U(this._id))}function LU(e){var t=this._name,n=this._id;typeof e!="function"&&(e=_d(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),p,f,m=0;m<c;++m)(p=l[m])&&(f=e.call(p,p.__data__,m,l))&&("__data__"in p&&(f.__data__=p.__data__),d[m]=f,Ua(d[m],t,n,m,d,Ft(p,n)));return new fn(a,this._parents,t,n)}function TU(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Mv(e));for(var o=this._groups,s=o.length,a=[],i=[],l=0;l<s;++l)for(var c=o[l],d=c.length,p,f=0;f<d;++f)if(p=c[f]){for(var m=e.call(p,p.__data__,f,c),h,g=Ft(p,n),x=0,b=m.length;x<b;++x)(h=m[x])&&Ua(h,t,n,x,m,g);a.push(m),i.push(p)}return new fn(a,i,t,n)}var RU=Go.prototype.constructor;function OU(){return new RU(this._groups,this._parents)}function zU(e,t){var n,o,s;return function(){var a=Mr(this,e),i=(this.style.removeProperty(e),Mr(this,e));return a===i?null:a===n&&i===o?s:s=t(n=a,o=i)}}function Zv(e){return function(){this.style.removeProperty(e)}}function BU(e,t,n){var o,s=n+"",a;return function(){var i=Mr(this,e);return i===s?null:i===o?a:a=t(o=i,n)}}function FU(e,t,n){var o,s,a;return function(){var i=Mr(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),Mr(this,e))),i===c?null:i===o&&c===s?a:(s=c,a=t(o=i,l))}}function jU(e,t){var n,o,s,a="style."+t,i="end."+a,l;return function(){var c=Jt(this,e),d=c.on,p=c.value[a]==null?l||(l=Zv(t)):void 0;(d!==n||s!==p)&&(o=(n=d).copy()).on(i,s=p),c.on=o}}function HU(e,t,n){var o=(e+="")=="transform"?VV:Yv;return t==null?this.styleTween(e,zU(e,o)).on("end.style."+e,Zv(e)):typeof t=="function"?this.styleTween(e,FU(e,o,Od(this,"style."+e,t))).each(jU(this._id,e)):this.styleTween(e,BU(e,o,t),n).on("end.style."+e,null)}function VU(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function UU(e,t,n){var o,s;function a(){var i=t.apply(this,arguments);return i!==s&&(o=(s=i)&&VU(e,i,n)),o}return a._value=t,a}function qU(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,UU(e,t,n??""))}function QU(e){return function(){this.textContent=e}}function GU(e){return function(){var t=e(this);this.textContent=t??""}}function KU(e){return this.tween("text",typeof e=="function"?GU(Od(this,"text",e)):QU(e==null?"":e+""))}function WU(e){return function(t){this.textContent=e.call(this,t)}}function YU(e){var t,n;function o(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&WU(s)),t}return o._value=e,o}function ZU(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,YU(e))}function XU(){for(var e=this._name,t=this._id,n=Xv(),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 p=Ft(c,t);Ua(c,e,n,d,i,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new fn(o,this._parents,e,n)}function JU(){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=Jt(this,o),p=d.on;p!==e&&(t=(e=p).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),d.on=t}),s===0&&a()})}var eq=0;function fn(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Xv(){return++eq}var nn=Go.prototype;fn.prototype={constructor:fn,select:LU,selectAll:TU,selectChild:nn.selectChild,selectChildren:nn.selectChildren,filter:AU,merge:EU,selection:OU,transition:XU,call:nn.call,nodes:nn.nodes,node:nn.node,size:nn.size,empty:nn.empty,each:nn.each,on:_U,attr:uU,attrTween:gU,style:HU,styleTween:qU,text:KU,textTween:ZU,remove:DU,tween:oU,delay:yU,duration:NU,ease:SU,easeVarying:MU,end:JU,[Symbol.iterator]:nn[Symbol.iterator]};function tq(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var nq={time:null,delay:0,duration:250,ease:tq};function rq(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 oq(e){var t,n;e instanceof fn?(t=e._id,e=e._name):(t=Xv(),(n=nq).time=Td(),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])&&Ua(c,e,t,d,i,n||rq(c,t));return new fn(o,this._parents,e,t)}Go.prototype.interrupt=tU;Go.prototype.transition=oq;const vs=e=>()=>e;function sq(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 sn(e,t,n){this.k=e,this.x=t,this.y=n}sn.prototype={constructor:sn,scale:function(e){return e===1?this:new sn(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new sn(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 qa=new sn(1,0,0);Jv.prototype=sn.prototype;function Jv(e){for(;!e.__zoom;)if(!(e=e.parentNode))return qa;return e.__zoom}function Ui(e){e.stopImmediatePropagation()}function to(e){e.preventDefault(),e.stopImmediatePropagation()}function aq(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function iq(){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 kf(){return this.__zoom||qa}function lq(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function cq(){return navigator.maxTouchPoints||"ontouchstart"in this}function dq(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 e1(){var e=aq,t=iq,n=dq,o=lq,s=cq,a=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,c=Ls,d=ja("start","zoom","end"),p,f,m,h=500,g=150,x=0,b=10;function v(M){M.property("__zoom",kf).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",z).filter(s).on("touchstart.zoom",A).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",R).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(M,$,L,O){var F=M.selection?M.selection():M;F.property("__zoom",kf),M!==F?k(M,$,L,O):F.interrupt().each(function(){C(this,arguments).event(O).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},v.scaleBy=function(M,$,L,O){v.scaleTo(M,function(){var F=this.__zoom.k,B=typeof $=="function"?$.apply(this,arguments):$;return F*B},L,O)},v.scaleTo=function(M,$,L,O){v.transform(M,function(){var F=t.apply(this,arguments),B=this.__zoom,j=L==null?N(F):typeof L=="function"?L.apply(this,arguments):L,H=B.invert(j),_=typeof $=="function"?$.apply(this,arguments):$;return n(y(w(B,_),j,H),F,i)},L,O)},v.translateBy=function(M,$,L,O){v.transform(M,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof L=="function"?L.apply(this,arguments):L),t.apply(this,arguments),i)},null,O)},v.translateTo=function(M,$,L,O,F){v.transform(M,function(){var B=t.apply(this,arguments),j=this.__zoom,H=O==null?N(B):typeof O=="function"?O.apply(this,arguments):O;return n(qa.translate(H[0],H[1]).scale(j.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof L=="function"?-L.apply(this,arguments):-L),B,i)},O,F)};function w(M,$){return $=Math.max(a[0],Math.min(a[1],$)),$===M.k?M:new sn($,M.x,M.y)}function y(M,$,L){var O=$[0]-L[0]*M.k,F=$[1]-L[1]*M.k;return O===M.x&&F===M.y?M:new sn(M.k,O,F)}function N(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function k(M,$,L,O){M.on("start.zoom",function(){C(this,arguments).event(O).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(O).end()}).tween("zoom",function(){var F=this,B=arguments,j=C(F,B).event(O),H=t.apply(F,B),_=L==null?N(H):typeof L=="function"?L.apply(F,B):L,q=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),G=F.__zoom,Q=typeof $=="function"?$.apply(F,B):$,J=c(G.invert(_).concat(q/G.k),Q.invert(_).concat(q/Q.k));return function(Z){if(Z===1)Z=Q;else{var X=J(Z),oe=q/X[2];Z=new sn(oe,_[0]-X[0]*oe,_[1]-X[1]*oe)}j.zoom(null,Z)}})}function C(M,$,L){return!L&&M.__zooming||new D(M,$)}function D(M,$){this.that=M,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,$),this.taps=0}D.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,$){return this.mouse&&M!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var $=pt(this.that).datum();d.call(M,this.that,new sq(M,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:d}),$)}};function E(M,...$){if(!e.apply(this,arguments))return;var L=C(this,$).event(M),O=this.__zoom,F=Math.max(a[0],Math.min(a[1],O.k*Math.pow(2,o.apply(this,arguments)))),B=Pt(M);if(L.wheel)(L.mouse[0][0]!==B[0]||L.mouse[0][1]!==B[1])&&(L.mouse[1]=O.invert(L.mouse[0]=B)),clearTimeout(L.wheel);else{if(O.k===F)return;L.mouse=[B,O.invert(B)],Os(this),L.start()}to(M),L.wheel=setTimeout(j,g),L.zoom("mouse",n(y(w(O,F),L.mouse[0],L.mouse[1]),L.extent,i));function j(){L.wheel=null,L.end()}}function I(M,...$){if(m||!e.apply(this,arguments))return;var L=M.currentTarget,O=C(this,$,!0).event(M),F=pt(M.view).on("mousemove.zoom",_,!0).on("mouseup.zoom",q,!0),B=Pt(M,L),j=M.clientX,H=M.clientY;Ov(M.view),Ui(M),O.mouse=[B,this.__zoom.invert(B)],Os(this),O.start();function _(G){if(to(G),!O.moved){var Q=G.clientX-j,J=G.clientY-H;O.moved=Q*Q+J*J>x}O.event(G).zoom("mouse",n(y(O.that.__zoom,O.mouse[0]=Pt(G,L),O.mouse[1]),O.extent,i))}function q(G){F.on("mousemove.zoom mouseup.zoom",null),zv(G.view,O.moved),to(G),O.event(G).end()}}function z(M,...$){if(e.apply(this,arguments)){var L=this.__zoom,O=Pt(M.changedTouches?M.changedTouches[0]:M,this),F=L.invert(O),B=L.k*(M.shiftKey?.5:2),j=n(y(w(L,B),O,F),t.apply(this,$),i);to(M),l>0?pt(this).transition().duration(l).call(k,j,O,M):pt(this).call(v.transform,j,O,M)}}function A(M,...$){if(e.apply(this,arguments)){var L=M.touches,O=L.length,F=C(this,$,M.changedTouches.length===O).event(M),B,j,H,_;for(Ui(M),j=0;j<O;++j)H=L[j],_=Pt(H,this),_=[_,this.__zoom.invert(_),H.identifier],F.touch0?!F.touch1&&F.touch0[2]!==_[2]&&(F.touch1=_,F.taps=0):(F.touch0=_,B=!0,F.taps=1+!!p);p&&(p=clearTimeout(p)),B&&(F.taps<2&&(f=_[0],p=setTimeout(function(){p=null},h)),Os(this),F.start())}}function T(M,...$){if(this.__zooming){var L=C(this,$).event(M),O=M.changedTouches,F=O.length,B,j,H,_;for(to(M),B=0;B<F;++B)j=O[B],H=Pt(j,this),L.touch0&&L.touch0[2]===j.identifier?L.touch0[0]=H:L.touch1&&L.touch1[2]===j.identifier&&(L.touch1[0]=H);if(j=L.that.__zoom,L.touch1){var q=L.touch0[0],G=L.touch0[1],Q=L.touch1[0],J=L.touch1[1],Z=(Z=Q[0]-q[0])*Z+(Z=Q[1]-q[1])*Z,X=(X=J[0]-G[0])*X+(X=J[1]-G[1])*X;j=w(j,Math.sqrt(Z/X)),H=[(q[0]+Q[0])/2,(q[1]+Q[1])/2],_=[(G[0]+J[0])/2,(G[1]+J[1])/2]}else if(L.touch0)H=L.touch0[0],_=L.touch0[1];else return;L.zoom("touch",n(y(j,H,_),L.extent,i))}}function R(M,...$){if(this.__zooming){var L=C(this,$).event(M),O=M.changedTouches,F=O.length,B,j;for(Ui(M),m&&clearTimeout(m),m=setTimeout(function(){m=null},h),B=0;B<F;++B)j=O[B],L.touch0&&L.touch0[2]===j.identifier?delete L.touch0:L.touch1&&L.touch1[2]===j.identifier&&delete L.touch1;if(L.touch1&&!L.touch0&&(L.touch0=L.touch1,delete L.touch1),L.touch0)L.touch0[1]=this.__zoom.invert(L.touch0[0]);else if(L.end(),L.taps===2&&(j=Pt(j,this),Math.hypot(f[0]-j[0],f[1]-j[1])<b)){var H=pt(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return v.wheelDelta=function(M){return arguments.length?(o=typeof M=="function"?M:vs(+M),v):o},v.filter=function(M){return arguments.length?(e=typeof M=="function"?M:vs(!!M),v):e},v.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:vs(!!M),v):s},v.extent=function(M){return arguments.length?(t=typeof M=="function"?M:vs([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),v):t},v.scaleExtent=function(M){return arguments.length?(a[0]=+M[0],a[1]=+M[1],v):[a[0],a[1]]},v.translateExtent=function(M){return arguments.length?(i[0][0]=+M[0][0],i[1][0]=+M[1][0],i[0][1]=+M[0][1],i[1][1]=+M[1][1],v):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},v.constrain=function(M){return arguments.length?(n=M,v):n},v.duration=function(M){return arguments.length?(l=+M,v):l},v.interpolate=function(M){return arguments.length?(c=M,v):c},v.on=function(){var M=d.on.apply(d,arguments);return M===d?v:M},v.clickDistance=function(M){return arguments.length?(x=(M=+M)*M,v):Math.sqrt(x)},v.tapDistance=function(M){return arguments.length?(b=+M,v):b},v}const Yt={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."},Po=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],t1=["Enter"," ","Escape"],n1={"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 Er;(function(e){e.Strict="strict",e.Loose="loose"})(Er||(Er={}));var Un;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Un||(Un={}));var _o;(function(e){e.Partial="partial",e.Full="full"})(_o||(_o={}));const r1={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var wn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(wn||(wn={}));var la;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(la||(la={}));var Ne;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ne||(Ne={}));const Sf={[Ne.Left]:Ne.Right,[Ne.Right]:Ne.Left,[Ne.Top]:Ne.Bottom,[Ne.Bottom]:Ne.Top};function o1(e){return e===null?null:e?"valid":"invalid"}const s1=e=>"id"in e&&"source"in e&&"target"in e,uq=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),zd=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Wo=(e,t=[0,0])=>{const{width:n,height:o}=gn(e),s=e.origin??t,a=n*s[0],i=o*s[1];return{x:e.position.x-a,y:e.position.y-i}},pq=(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):zd(s)?s:t.nodeLookup.get(s.id));const l=i?ca(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Qa(o,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Ga(n)},Yo=(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=Qa(n,ca(s)),o=!0)}),o?Ga(n):{x:0,y:0,width:0,height:0}},Bd=(e,t,[n,o,s]=[0,0,1],a=!1,i=!1)=>{const l={...Xo(t,[n,o,s]),width:t.width/s,height:t.height/s},c=[];for(const d of e.values()){const{measured:p,selectable:f=!0,hidden:m=!1}=d;if(i&&!f||m)continue;const h=p.width??d.width??d.initialWidth??null,g=p.height??d.height??d.initialHeight??null,x=$o(l,Pr(d)),b=(h??0)*(g??0),v=a&&x>0;(!d.internals.handleBounds||v||x>=b||d.dragging)&&c.push(d)}return c},fq=(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 mq(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 hq({nodes:e,width:t,height:n,panZoom:o,minZoom:s,maxZoom:a},i){if(e.size===0)return Promise.resolve(!0);const l=mq(e,i),c=Yo(l),d=Fd(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 a1({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},p=i.origin??o;let f=i.extent||s;if(i.extent==="parent"&&!i.expandParent)if(!l)a?.("005",Yt.error005());else{const h=l.measured.width,g=l.measured.height;h&&g&&(f=[[c,d],[c+h,d+g]])}else l&&_r(i.extent)&&(f=[[i.extent[0][0]+c,i.extent[0][1]+d],[i.extent[1][0]+c,i.extent[1][1]+d]]);const m=_r(f)?Zn(t,f,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&a?.("015",Yt.error015()),{position:{x:m.x-c+(i.measured.width??0)*p[0],y:m.y-d+(i.measured.height??0)*p[1]},positionAbsolute:m}}async function gq({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(x=>x.id===m.parentId);(h||g)&&i.push(m)}const l=new Set(t.map(m=>m.id)),c=o.filter(m=>m.deletable!==!1),p=fq(i,c);for(const m of c)l.has(m.id)&&!p.find(g=>g.id===m.id)&&p.push(m);if(!s)return{edges:p,nodes:i};const f=await s({nodes:i,edges:p});return typeof f=="boolean"?f?{edges:p,nodes:i}:{edges:[],nodes:[]}:f}const Ir=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Zn=(e={x:0,y:0},t,n)=>({x:Ir(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Ir(e.y,t[0][1],t[1][1]-(n?.height??0))});function i1(e,t,n){const{width:o,height:s}=gn(n),{x:a,y:i}=n.internals.positionAbsolute;return Zn(e,[[a,i],[a+o,i+s]],t)}const Cf=(e,t,n)=>e<t?Ir(Math.abs(e-t),1,t)/t:e>n?-Ir(Math.abs(e-n),1,t)/t:0,l1=(e,t,n=15,o=40)=>{const s=Cf(e.x,o,t.width-o)*n,a=Cf(e.y,o,t.height-o)*n;return[s,a]},Qa=(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)}),Kl=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),Ga=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Pr=(e,t=[0,0])=>{const{x:n,y:o}=zd(e)?e.internals.positionAbsolute:Wo(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}},ca=(e,t=[0,0])=>{const{x:n,y:o}=zd(e)?e.internals.positionAbsolute:Wo(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)}},c1=(e,t)=>Ga(Qa(Kl(e),Kl(t))),$o=(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)},Mf=e=>$t(e.width)&&$t(e.height)&&$t(e.x)&&$t(e.y),$t=e=>!isNaN(e)&&isFinite(e),bq=(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])}),Xo=({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},da=({x:e,y:t},[n,o,s])=>({x:e*s+n,y:t*s+o});function ir(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 xq(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=ir(e,n),s=ir(e,t);return{top:o,right:s,bottom:o,left:s,x:s*2,y:o*2}}if(typeof e=="object"){const o=ir(e.top??e.y??0,n),s=ir(e.bottom??e.y??0,n),a=ir(e.left??e.x??0,t),i=ir(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 yq(e,t,n,o,s,a){const{x:i,y:l}=da(e,[t,n,o]),{x:c,y:d}=da({x:e.x+e.width,y:e.y+e.height},[t,n,o]),p=s-c,f=a-d;return{left:Math.floor(i),top:Math.floor(l),right:Math.floor(p),bottom:Math.floor(f)}}const Fd=(e,t,n,o,s,a)=>{const i=xq(a,t,n),l=(t-i.x)/e.width,c=(n-i.y)/e.height,d=Math.min(l,c),p=Ir(d,o,s),f=e.x+e.width/2,m=e.y+e.height/2,h=t/2-f*p,g=n/2-m*p,x=yq(e,h,g,p,t,n),b={left:Math.min(x.left-i.left,0),top:Math.min(x.top-i.top,0),right:Math.min(x.right-i.right,0),bottom:Math.min(x.bottom-i.bottom,0)};return{x:h-b.left+b.right,y:g-b.top+b.bottom,zoom:p}},Do=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function _r(e){return e!=null&&e!=="parent"}function gn(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function d1(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function u1(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 Af(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function vq(){let e,t;return{promise:new Promise((o,s)=>{e=o,t=s}),resolve:e,reject:t}}function wq(e){return{...n1,...e||{}}}function bo(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:s}){const{x:a,y:i}=Dt(e),l=Xo({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 jd=e=>({width:e.offsetWidth,height:e.offsetHeight}),p1=e=>e?.getRootNode?.()||window?.document,Nq=["INPUT","SELECT","TEXTAREA"];function f1(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:Nq.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const m1=e=>"clientX"in e,Dt=(e,t)=>{const n=m1(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)}},Ef=(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,...jd(i)}})};function h1({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,p=Math.abs(c-e),f=Math.abs(d-t);return[c,d,p,f]}function ws(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function If({pos:e,x1:t,y1:n,x2:o,y2:s,c:a}){switch(e){case Ne.Left:return[t-ws(t-o,a),n];case Ne.Right:return[t+ws(o-t,a),n];case Ne.Top:return[t,n-ws(n-s,a)];case Ne.Bottom:return[t,n+ws(s-n,a)]}}function g1({sourceX:e,sourceY:t,sourcePosition:n=Ne.Bottom,targetX:o,targetY:s,targetPosition:a=Ne.Top,curvature:i=.25}){const[l,c]=If({pos:n,x1:e,y1:t,x2:o,y2:s,c:i}),[d,p]=If({pos:a,x1:o,y1:s,x2:e,y2:t,c:i}),[f,m,h,g]=h1({sourceX:e,sourceY:t,targetX:o,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:p});return[`M${e},${t} C${l},${c} ${d},${p} ${o},${s}`,f,m,h,g]}function b1({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 kq({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 Sq({sourceNode:e,targetNode:t,width:n,height:o,transform:s}){const a=Qa(ca(e),ca(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 $o(i,Ga(a))>0}const Cq=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,Mq=(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)),Aq=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||Cq;let s;return s1(e)?s={...e}:s={...e,id:o(e)},Mq(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function x1({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[s,a,i,l]=b1({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,s,a,i,l]}const Pf={[Ne.Left]:{x:-1,y:0},[Ne.Right]:{x:1,y:0},[Ne.Top]:{x:0,y:-1},[Ne.Bottom]:{x:0,y:1}},Eq=({source:e,sourcePosition:t=Ne.Bottom,target:n})=>t===Ne.Left||t===Ne.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},_f=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Iq({source:e,sourcePosition:t=Ne.Bottom,target:n,targetPosition:o=Ne.Top,center:s,offset:a,stepPosition:i}){const l=Pf[t],c=Pf[o],d={x:e.x+l.x*a,y:e.y+l.y*a},p={x:n.x+c.x*a,y:n.y+c.y*a},f=Eq({source:d,sourcePosition:t,target:p}),m=f.x!==0?"x":"y",h=f[m];let g=[],x,b;const v={x:0,y:0},w={x:0,y:0},[,,y,N]=b1({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[m]*c[m]===-1){m==="x"?(x=s.x??d.x+(p.x-d.x)*i,b=s.y??(d.y+p.y)/2):(x=s.x??(d.x+p.x)/2,b=s.y??d.y+(p.y-d.y)*i);const E=[{x,y:d.y},{x,y:p.y}],I=[{x:d.x,y:b},{x:p.x,y:b}];l[m]===h?g=m==="x"?E:I:g=m==="x"?I:E}else{const E=[{x:d.x,y:p.y}],I=[{x:p.x,y:d.y}];if(m==="x"?g=l.x===h?I:E:g=l.y===h?E:I,t===o){const M=Math.abs(e[m]-n[m]);if(M<=a){const $=Math.min(a-1,a-M);l[m]===h?v[m]=(d[m]>e[m]?-1:1)*$:w[m]=(p[m]>n[m]?-1:1)*$}}if(t!==o){const M=m==="x"?"y":"x",$=l[m]===c[M],L=d[M]>p[M],O=d[M]<p[M];(l[m]===1&&(!$&&L||$&&O)||l[m]!==1&&(!$&&O||$&&L))&&(g=m==="x"?E:I)}const z={x:d.x+v.x,y:d.y+v.y},A={x:p.x+w.x,y:p.y+w.y},T=Math.max(Math.abs(z.x-g[0].x),Math.abs(A.x-g[0].x)),R=Math.max(Math.abs(z.y-g[0].y),Math.abs(A.y-g[0].y));T>=R?(x=(z.x+A.x)/2,b=g[0].y):(x=g[0].x,b=(z.y+A.y)/2)}const k={x:d.x+v.x,y:d.y+v.y},C={x:p.x+w.x,y:p.y+w.y};return[[e,...k.x!==g[0].x||k.y!==g[0].y?[k]:[],...g,...C.x!==g[g.length-1].x||C.y!==g[g.length-1].y?[C]:[],n],x,b,y,N]}function Pq(e,t,n,o){const s=Math.min(_f(e,t)/2,_f(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,p=e.y<n.y?1:-1;return`L ${a+s*d},${i}Q ${a},${i} ${a},${i+s*p}`}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 Wl({sourceX:e,sourceY:t,sourcePosition:n=Ne.Bottom,targetX:o,targetY:s,targetPosition:a=Ne.Top,borderRadius:i=5,centerX:l,centerY:c,offset:d=20,stepPosition:p=.5}){const[f,m,h,g,x]=Iq({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:s},targetPosition:a,center:{x:l,y:c},offset:d,stepPosition:p});let b=`M${f[0].x} ${f[0].y}`;for(let v=1;v<f.length-1;v++)b+=Pq(f[v-1],f[v],f[v+1],i);return b+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[b,m,h,g,x]}function $f(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function _q(e){const{sourceNode:t,targetNode:n}=e;if(!$f(t)||!$f(n))return null;const o=t.internals.handleBounds||Df(t.handles),s=n.internals.handleBounds||Df(n.handles),a=Lf(o?.source??[],e.sourceHandle),i=Lf(e.connectionMode===Er.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!a||!i)return e.onError?.("008",Yt.error008(a?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=a?.position||Ne.Bottom,c=i?.position||Ne.Top,d=Xn(t,a,l),p=Xn(n,i,c);return{sourceX:d.x,sourceY:d.y,targetX:p.x,targetY:p.y,sourcePosition:l,targetPosition:c}}function Df(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 Xn(e,t,n=Ne.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??gn(e);if(o)return{x:s+i/2,y:a+l/2};switch(t?.position??n){case Ne.Top:return{x:s+i/2,y:a};case Ne.Right:return{x:s+i,y:a+l/2};case Ne.Bottom:return{x:s+i/2,y:a+l};case Ne.Left:return{x:s,y:a+l/2}}}function Lf(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Yl(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function $q(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=Yl(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 y1=1e3,Dq=10,Hd={nodeOrigin:[0,0],nodeExtent:Po,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Lq={...Hd,checkEquality:!0};function Vd(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Tq(e,t,n){const o=Vd(Hd,n);for(const s of e.values())if(s.parentId)qd(s,e,t,o);else{const a=Wo(s,o.nodeOrigin),i=_r(s.extent)?s.extent:o.nodeExtent,l=Zn(a,i,gn(s));s.internals.positionAbsolute=l}}function Rq(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 Ud(e){return e==="manual"}function Zl(e,t,n,o={}){const s=Vd(Lq,o),a={i:0},i=new Map(t),l=s?.elevateNodesOnSelect&&!Ud(s.zIndexMode)?y1:0;let c=e.length>0,d=!1;t.clear(),n.clear();for(const p of e){let f=i.get(p.id);if(s.checkEquality&&p===f?.internals.userNode)t.set(p.id,f);else{const m=Wo(p,s.nodeOrigin),h=_r(p.extent)?p.extent:s.nodeExtent,g=Zn(m,h,gn(p));f={...s.defaults,...p,measured:{width:p.measured?.width,height:p.measured?.height},internals:{positionAbsolute:g,handleBounds:Rq(p,f),z:v1(p,l,s.zIndexMode),userNode:p}},t.set(p.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(c=!1),p.parentId&&qd(f,t,n,o,a),d||=p.selected??!1}return{nodesInitialized:c,hasSelectedNodes:d}}function Oq(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 qd(e,t,n,o,s){const{elevateNodesOnSelect:a,nodeOrigin:i,nodeExtent:l,zIndexMode:c}=Vd(Hd,o),d=e.parentId,p=t.get(d);if(!p){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}Oq(e,n),s&&!p.parentId&&p.internals.rootParentIndex===void 0&&c==="auto"&&(p.internals.rootParentIndex=++s.i,p.internals.z=p.internals.z+s.i*Dq),s&&p.internals.rootParentIndex!==void 0&&(s.i=p.internals.rootParentIndex);const f=a&&!Ud(c)?y1:0,{x:m,y:h,z:g}=zq(e,p,i,l,f,c),{positionAbsolute:x}=e.internals,b=m!==x.x||h!==x.y;(b||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:b?{x:m,y:h}:x,z:g}})}function v1(e,t,n){const o=$t(e.zIndex)?e.zIndex:0;return Ud(n)?o:o+(e.selected?t:0)}function zq(e,t,n,o,s,a){const{x:i,y:l}=t.internals.positionAbsolute,c=gn(e),d=Wo(e,n),p=_r(e.extent)?Zn(d,e.extent,c):d;let f=Zn({x:i+p.x,y:l+p.y},o,c);e.extent==="parent"&&(f=i1(f,c,t));const m=v1(e,s,a),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=m?h+1:m}}function Qd(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??Pr(l),d=c1(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,p=gn(l),f=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(p.width,Math.round(i.width)),x=Math.max(p.height,Math.round(i.height)),b=(g-p.width)*f[0],v=(x-p.height)*f[1];(m>0||h>0||b||v)&&(s.push({id:c,type:"position",position:{x:l.position.x-m+b,y:l.position.y-h+v}}),n.get(c)?.forEach(w=>{e.some(y=>y.id===w.id)||s.push({id:w.id,type:"position",position:{x:w.position.x+m,y:w.position.y+h}})})),(p.width<i.width||p.height<i.height||m||h)&&s.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:g+(m?f[0]*m-b:0),height:x+(h?f[1]*h-v:0)}})}),s}function Bq(e,t,n,o,s,a,i){const l=o?.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const d=[],p=window.getComputedStyle(l),{m22:f}=new window.DOMMatrixReadOnly(p.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 x=jd(h.nodeElement),b=g.measured.width!==x.width||g.measured.height!==x.height;if(!!(x.width&&x.height&&(b||!g.internals.handleBounds||h.force))){const w=h.nodeElement.getBoundingClientRect(),y=_r(g.extent)?g.extent:a;let{positionAbsolute:N}=g.internals;g.parentId&&g.extent==="parent"?N=i1(N,x,t.get(g.parentId)):y&&(N=Zn(N,y,x));const k={...g,measured:x,internals:{...g.internals,positionAbsolute:N,handleBounds:{source:Ef("source",h.nodeElement,w,f,g.id),target:Ef("target",h.nodeElement,w,f,g.id)}}};t.set(g.id,k),g.parentId&&qd(k,t,n,{nodeOrigin:s,zIndexMode:i}),c=!0,b&&(d.push({id:g.id,type:"dimensions",dimensions:x}),g.expandParent&&g.parentId&&m.push({id:g.id,parentId:g.parentId,rect:Pr(k,s)}))}}if(m.length>0){const h=Qd(m,t,n,s);d.push(...h)}return{changes:d,updatedInternals:c}}async function Fq({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 Tf(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 w1(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}`,p=`${a}-${l}--${s}-${i}`;Tf("source",c,p,e,s,i),Tf("target",c,d,e,a,l),t.set(o.id,o)}}function N1(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:N1(n,t):!1}function Rf(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 jq(e,t,n,o){const s=new Map;for(const[a,i]of e)if((i.selected||i.id===o)&&(!i.parentId||!N1(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 qi({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 Hq({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 Vq({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},p=null,f=!1,m=null,h=!1,g=!1,x=null;function b({noDragClassName:w,handleSelector:y,domNode:N,isSelectable:k,nodeId:C,nodeClickDistance:D=0}){m=pt(N);function E({x:T,y:R}){const{nodeLookup:M,nodeExtent:$,snapGrid:L,snapToGrid:O,nodeOrigin:F,onNodeDrag:B,onSelectionDrag:j,onError:H,updateNodePositions:_}=t();a={x:T,y:R};let q=!1;const G=l.size>1,Q=G&&$?Kl(Yo(l)):null,J=G&&O?Hq({dragItems:l,snapGrid:L,x:T,y:R}):null;for(const[Z,X]of l){if(!M.has(Z))continue;let oe={x:T-X.distance.x,y:R-X.distance.y};O&&(oe=J?{x:Math.round(oe.x+J.x),y:Math.round(oe.y+J.y)}:Zo(oe,L));let he=null;if(G&&$&&!X.extent&&Q){const{positionAbsolute:ne}=X.internals,ie=ne.x-Q.x+$[0][0],fe=ne.x+X.measured.width-Q.x2+$[1][0],me=ne.y-Q.y+$[0][1],te=ne.y+X.measured.height-Q.y2+$[1][1];he=[[ie,me],[fe,te]]}const{position:ee,positionAbsolute:W}=a1({nodeId:Z,nextPosition:oe,nodeLookup:M,nodeExtent:he||$,nodeOrigin:F,onError:H});q=q||X.position.x!==ee.x||X.position.y!==ee.y,X.position=ee,X.internals.positionAbsolute=W}if(g=g||q,!!q&&(_(l,!0),x&&(o||B||!C&&j))){const[Z,X]=qi({nodeId:C,dragItems:l,nodeLookup:M});o?.(x,l,Z,X),B?.(x,Z,X),C||j?.(x,X)}}async function I(){if(!p)return;const{transform:T,panBy:R,autoPanSpeed:M,autoPanOnNodeDrag:$}=t();if(!$){c=!1,cancelAnimationFrame(i);return}const[L,O]=l1(d,p,M);(L!==0||O!==0)&&(a.x=(a.x??0)-L/T[2],a.y=(a.y??0)-O/T[2],await R({x:L,y:O})&&E(a)),i=requestAnimationFrame(I)}function z(T){const{nodeLookup:R,multiSelectionActive:M,nodesDraggable:$,transform:L,snapGrid:O,snapToGrid:F,selectNodesOnDrag:B,onNodeDragStart:j,onSelectionDragStart:H,unselectNodesAndEdges:_}=t();f=!0,(!B||!k)&&!M&&C&&(R.get(C)?.selected||_()),k&&B&&C&&e?.(C);const q=bo(T.sourceEvent,{transform:L,snapGrid:O,snapToGrid:F,containerBounds:p});if(a=q,l=jq(R,$,q,C),l.size>0&&(n||j||!C&&H)){const[G,Q]=qi({nodeId:C,dragItems:l,nodeLookup:R});n?.(T.sourceEvent,l,G,Q),j?.(T.sourceEvent,G,Q),C||H?.(T.sourceEvent,Q)}}const A=Bv().clickDistance(D).on("start",T=>{const{domNode:R,nodeDragThreshold:M,transform:$,snapGrid:L,snapToGrid:O}=t();p=R?.getBoundingClientRect()||null,h=!1,g=!1,x=T.sourceEvent,M===0&&z(T),a=bo(T.sourceEvent,{transform:$,snapGrid:L,snapToGrid:O,containerBounds:p}),d=Dt(T.sourceEvent,p)}).on("drag",T=>{const{autoPanOnNodeDrag:R,transform:M,snapGrid:$,snapToGrid:L,nodeDragThreshold:O,nodeLookup:F}=t(),B=bo(T.sourceEvent,{transform:M,snapGrid:$,snapToGrid:L,containerBounds:p});if(x=T.sourceEvent,(T.sourceEvent.type==="touchmove"&&T.sourceEvent.touches.length>1||C&&!F.has(C))&&(h=!0),!h){if(!c&&R&&f&&(c=!0,I()),!f){const j=Dt(T.sourceEvent,p),H=j.x-d.x,_=j.y-d.y;Math.sqrt(H*H+_*_)>O&&z(T)}(a.x!==B.xSnapped||a.y!==B.ySnapped)&&l&&f&&(d=Dt(T.sourceEvent,p),E(B))}}).on("end",T=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(i),l.size>0)){const{nodeLookup:R,updateNodePositions:M,onNodeDragStop:$,onSelectionDragStop:L}=t();if(g&&(M(l,!1),g=!1),s||$||!C&&L){const[O,F]=qi({nodeId:C,dragItems:l,nodeLookup:R,dragging:!1});s?.(T.sourceEvent,l,O,F),$?.(T.sourceEvent,O,F),C||L?.(T.sourceEvent,F)}}}).filter(T=>{const R=T.target;return!T.button&&(!w||!Rf(R,`.${w}`,N))&&(!y||Rf(R,y,N))});m.call(A)}function v(){m?.on(".drag",null)}return{update:b,destroy:v}}function Uq(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())$o(s,Pr(a))>0&&o.push(a);return o}const qq=250;function Qq(e,t,n,o){let s=[],a=1/0;const i=Uq(e,n,t+qq);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:p,y:f}=Xn(l,d,d.position,!0),m=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(f-e.y,2));m>t||(m<a?(s=[{...d,x:p,y:f}],a=m):m===a&&s.push({...d,x:p,y:f}))}}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 k1(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,...Xn(i,c,c.position,!0)}:c}function S1(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Gq(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const C1=()=>!0;function Kq(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:s,edgeUpdaterType:a,isTarget:i,domNode:l,nodeLookup:c,lib:d,autoPanOnConnect:p,flowId:f,panBy:m,cancelConnection:h,onConnectStart:g,onConnect:x,onConnectEnd:b,isValidConnection:v=C1,onReconnectEnd:w,updateConnection:y,getTransform:N,getFromHandle:k,autoPanSpeed:C,dragThreshold:D=1,handleDomNode:E}){const I=p1(e.target);let z=0,A;const{x:T,y:R}=Dt(e),M=S1(a,E),$=l?.getBoundingClientRect();let L=!1;if(!$||!M)return;const O=k1(s,M,o,c,t);if(!O)return;let F=Dt(e,$),B=!1,j=null,H=!1,_=null;function q(){if(!p||!$)return;const[ee,W]=l1(F,$,C);m({x:ee,y:W}),z=requestAnimationFrame(q)}const G={...O,nodeId:s,type:M,position:O.position},Q=c.get(s);let Z={inProgress:!0,isValid:null,from:Xn(Q,G,Ne.Left,!0),fromHandle:G,fromPosition:G.position,fromNode:Q,to:F,toHandle:null,toPosition:Sf[G.position],toNode:null,pointer:F};function X(){L=!0,y(Z),g?.(e,{nodeId:s,handleId:o,handleType:M})}D===0&&X();function oe(ee){if(!L){const{x:te,y:ye}=Dt(ee),ke=te-T,pe=ye-R;if(!(ke*ke+pe*pe>D*D))return;X()}if(!k()||!G){he(ee);return}const W=N();F=Dt(ee,$),A=Qq(Xo(F,W,!1,[1,1]),n,c,G),B||(q(),B=!0);const ne=M1(ee,{handle:A,connectionMode:t,fromNodeId:s,fromHandleId:o,fromType:i?"target":"source",isValidConnection:v,doc:I,lib:d,flowId:f,nodeLookup:c});_=ne.handleDomNode,j=ne.connection,H=Gq(!!A,ne.isValid);const ie=c.get(s),fe=ie?Xn(ie,G,Ne.Left,!0):Z.from,me={...Z,from:fe,isValid:H,to:ne.toHandle&&H?da({x:ne.toHandle.x,y:ne.toHandle.y},W):F,toHandle:ne.toHandle,toPosition:H&&ne.toHandle?ne.toHandle.position:Sf[G.position],toNode:ne.toHandle?c.get(ne.toHandle.nodeId):null,pointer:F};y(me),Z=me}function he(ee){if(!("touches"in ee&&ee.touches.length>0)){if(L){(A||_)&&j&&H&&x?.(j);const{inProgress:W,...ne}=Z,ie={...ne,toPosition:Z.toHandle?Z.toPosition:null};b?.(ee,ie),a&&w?.(ee,ie)}h(),cancelAnimationFrame(z),B=!1,H=!1,j=null,_=null,I.removeEventListener("mousemove",oe),I.removeEventListener("mouseup",he),I.removeEventListener("touchmove",oe),I.removeEventListener("touchend",he)}}I.addEventListener("mousemove",oe),I.addEventListener("mouseup",he),I.addEventListener("touchmove",oe),I.addEventListener("touchend",he)}function M1(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:s,fromType:a,doc:i,lib:l,flowId:c,isValidConnection:d=C1,nodeLookup:p}){const f=a==="target",m=t?i.querySelector(`.${l}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:g}=Dt(e),x=i.elementFromPoint(h,g),b=x?.classList.contains(`${l}-flow__handle`)?x:m,v={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const w=S1(void 0,b),y=b.getAttribute("data-nodeid"),N=b.getAttribute("data-handleid"),k=b.classList.contains("connectable"),C=b.classList.contains("connectableend");if(!y||!w)return v;const D={source:f?y:o,sourceHandle:f?N:s,target:f?o:y,targetHandle:f?s:N};v.connection=D;const I=k&&C&&(n===Er.Strict?f&&w==="source"||!f&&w==="target":y!==o||N!==s);v.isValid=I&&d(D),v.toHandle=k1(y,w,N,p,n,!0)}return v}const Xl={onPointerDown:Kq,isValid:M1};function Wq({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const s=pt(e);function a({translateExtent:l,width:c,height:d,zoomStep:p=1,pannable:f=!0,zoomable:m=!0,inversePan:h=!1}){const g=y=>{if(y.sourceEvent.type!=="wheel"||!t)return;const N=n(),k=y.sourceEvent.ctrlKey&&Do()?10:1,C=-y.sourceEvent.deltaY*(y.sourceEvent.deltaMode===1?.05:y.sourceEvent.deltaMode?1:.002)*p,D=N[2]*Math.pow(2,C*k);t.scaleTo(D)};let x=[0,0];const b=y=>{(y.sourceEvent.type==="mousedown"||y.sourceEvent.type==="touchstart")&&(x=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY])},v=y=>{const N=n();if(y.sourceEvent.type!=="mousemove"&&y.sourceEvent.type!=="touchmove"||!t)return;const k=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY],C=[k[0]-x[0],k[1]-x[1]];x=k;const D=o()*Math.max(N[2],Math.log(N[2]))*(h?-1:1),E={x:N[0]-C[0]*D,y:N[1]-C[1]*D},I=[[0,0],[c,d]];t.setViewportConstrained({x:E.x,y:E.y,zoom:N[2]},I,l)},w=e1().on("start",b).on("zoom",f?v:null).on("zoom.wheel",m?g:null);s.call(w,{})}function i(){s.on("zoom",null)}return{update:a,destroy:i,pointer:Pt}}const Ka=e=>({x:e.x,y:e.y,zoom:e.k}),Qi=({x:e,y:t,zoom:n})=>qa.translate(e,t).scale(n),ur=(e,t)=>e.target.closest(`.${t}`),A1=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Yq=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Gi=(e,t=0,n=Yq,o=()=>{})=>{const s=typeof t=="number"&&t>0;return s||o(),s?e.transition().duration(t).ease(n).on("end",o):e},E1=e=>{const t=e.ctrlKey&&Do()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Zq({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:i,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:d}){return p=>{if(ur(p,t))return p.ctrlKey&&p.preventDefault(),!1;p.preventDefault(),p.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(p.ctrlKey&&i){const b=Pt(p),v=E1(p),w=f*Math.pow(2,v);o.scaleTo(n,w,b,p);return}const m=p.deltaMode===1?20:1;let h=s===Un.Vertical?0:p.deltaX*m,g=s===Un.Horizontal?0:p.deltaY*m;!Do()&&p.shiftKey&&s!==Un.Vertical&&(h=p.deltaY*m,g=0),o.translateBy(n,-(h/f)*a,-(g/f)*a,{internal:!0});const x=Ka(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(p,x),e.panScrollTimeout=setTimeout(()=>{d?.(p,x),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(p,x))}}function Xq({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,s){const a=o.type==="wheel",i=!t&&a&&!o.ctrlKey,l=ur(o,e);if(o.ctrlKey&&a&&l&&o.preventDefault(),i||l)return null;o.preventDefault(),n.call(this,o,s)}}function Jq({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const s=Ka(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 eQ({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:s}){return a=>{e.usedRightMouseButton=!!(n&&A1(t,e.mouseButton??0)),a.sourceEvent?.sync||o([a.transform.x,a.transform.y,a.transform.k]),s&&!a.sourceEvent?.internal&&s?.(a.sourceEvent,Ka(a.transform))}}function tQ({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:s,onPaneContextMenu:a}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&A1(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&a(i.sourceEvent),e.usedRightMouseButton=!1,o(!1),s)){const l=Ka(i.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(i.sourceEvent,l)},n?150:0)}}}function nQ({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:s,zoomOnDoubleClick:a,userSelectionActive:i,noWheelClassName:l,noPanClassName:c,lib:d,connectionInProgress:p}){return f=>{const m=e||t,h=n&&f.ctrlKey,g=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(ur(f,`${d}-flow__node`)||ur(f,`${d}-flow__edge`)))return!0;if(!o&&!m&&!s&&!a&&!n||i||p&&!g||ur(f,l)&&g||ur(f,c)&&(!g||s&&g&&!e)||!n&&f.ctrlKey&&g)return!1;if(!n&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!m&&!s&&!h&&g||!o&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(o)&&!o.includes(f.button)&&f.type==="mousedown")return!1;const x=Array.isArray(o)&&o.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||g)&&x}}function rQ({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},p=e.getBoundingClientRect(),f=e1().scaleExtent([t,n]).translateExtent(o),m=pt(e).call(f);w({x:s.x,y:s.y,zoom:Ir(s.zoom,t,n)},[[0,0],[p.width,p.height]],o);const h=m.on("wheel.zoom"),g=m.on("dblclick.zoom");f.wheelDelta(E1);function x(A,T){return m?new Promise(R=>{f?.interpolate(T?.interpolate==="linear"?go:Ls).transform(Gi(m,T?.duration,T?.ease,()=>R(!0)),A)}):Promise.resolve(!1)}function b({noWheelClassName:A,noPanClassName:T,onPaneContextMenu:R,userSelectionActive:M,panOnScroll:$,panOnDrag:L,panOnScrollMode:O,panOnScrollSpeed:F,preventScrolling:B,zoomOnPinch:j,zoomOnScroll:H,zoomOnDoubleClick:_,zoomActivationKeyPressed:q,lib:G,onTransformChange:Q,connectionInProgress:J,paneClickDistance:Z,selectionOnDrag:X}){M&&!d.isZoomingOrPanning&&v();const oe=$&&!q&&!M;f.clickDistance(X?1/0:!$t(Z)||Z<0?0:Z);const he=oe?Zq({zoomPanValues:d,noWheelClassName:A,d3Selection:m,d3Zoom:f,panOnScrollMode:O,panOnScrollSpeed:F,zoomOnPinch:j,onPanZoomStart:i,onPanZoom:a,onPanZoomEnd:l}):Xq({noWheelClassName:A,preventScrolling:B,d3ZoomHandler:h});if(m.on("wheel.zoom",he,{passive:!1}),!M){const W=Jq({zoomPanValues:d,onDraggingChange:c,onPanZoomStart:i});f.on("start",W);const ne=eQ({zoomPanValues:d,panOnDrag:L,onPaneContextMenu:!!R,onPanZoom:a,onTransformChange:Q});f.on("zoom",ne);const ie=tQ({zoomPanValues:d,panOnDrag:L,panOnScroll:$,onPaneContextMenu:R,onPanZoomEnd:l,onDraggingChange:c});f.on("end",ie)}const ee=nQ({zoomActivationKeyPressed:q,panOnDrag:L,zoomOnScroll:H,panOnScroll:$,zoomOnDoubleClick:_,zoomOnPinch:j,userSelectionActive:M,noPanClassName:T,noWheelClassName:A,lib:G,connectionInProgress:J});f.filter(ee),_?m.on("dblclick.zoom",g):m.on("dblclick.zoom",null)}function v(){f.on("zoom",null)}async function w(A,T,R){const M=Qi(A),$=f?.constrain()(M,T,R);return $&&await x($),new Promise(L=>L($))}async function y(A,T){const R=Qi(A);return await x(R,T),new Promise(M=>M(R))}function N(A){if(m){const T=Qi(A),R=m.property("__zoom");(R.k!==A.zoom||R.x!==A.x||R.y!==A.y)&&f?.transform(m,T,null,{sync:!0})}}function k(){const A=m?Jv(m.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}function C(A,T){return m?new Promise(R=>{f?.interpolate(T?.interpolate==="linear"?go:Ls).scaleTo(Gi(m,T?.duration,T?.ease,()=>R(!0)),A)}):Promise.resolve(!1)}function D(A,T){return m?new Promise(R=>{f?.interpolate(T?.interpolate==="linear"?go:Ls).scaleBy(Gi(m,T?.duration,T?.ease,()=>R(!0)),A)}):Promise.resolve(!1)}function E(A){f?.scaleExtent(A)}function I(A){f?.translateExtent(A)}function z(A){const T=!$t(A)||A<0?0:A;f?.clickDistance(T)}return{update:b,destroy:v,setViewport:y,setViewportConstrained:w,getViewport:k,scaleTo:C,scaleBy:D,setScaleExtent:E,setTranslateExtent:I,syncViewport:N,setClickDistance:z}}var $r;(function(e){e.Line="line",e.Handle="handle"})($r||($r={}));function oQ({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 Of(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 yn(e,t){return Math.max(0,t-e)}function vn(e,t){return Math.max(0,e-t)}function Ns(e,t,n){return Math.max(0,t-e,e-n)}function zf(e,t){return e?!t:t}function sQ(e,t,n,o,s,a,i,l){let{affectsX:c,affectsY:d}=t;const{isHorizontal:p,isVertical:f}=t,m=p&&f,{xSnapped:h,ySnapped:g}=n,{minWidth:x,maxWidth:b,minHeight:v,maxHeight:w}=o,{x:y,y:N,width:k,height:C,aspectRatio:D}=e;let E=Math.floor(p?h-e.pointerX:0),I=Math.floor(f?g-e.pointerY:0);const z=k+(c?-E:E),A=C+(d?-I:I),T=-a[0]*k,R=-a[1]*C;let M=Ns(z,x,b),$=Ns(A,v,w);if(i){let F=0,B=0;c&&E<0?F=yn(y+E+T,i[0][0]):!c&&E>0&&(F=vn(y+z+T,i[1][0])),d&&I<0?B=yn(N+I+R,i[0][1]):!d&&I>0&&(B=vn(N+A+R,i[1][1])),M=Math.max(M,F),$=Math.max($,B)}if(l){let F=0,B=0;c&&E>0?F=vn(y+E,l[0][0]):!c&&E<0&&(F=yn(y+z,l[1][0])),d&&I>0?B=vn(N+I,l[0][1]):!d&&I<0&&(B=yn(N+A,l[1][1])),M=Math.max(M,F),$=Math.max($,B)}if(s){if(p){const F=Ns(z/D,v,w)*D;if(M=Math.max(M,F),i){let B=0;!c&&!d||c&&!d&&m?B=vn(N+R+z/D,i[1][1])*D:B=yn(N+R+(c?E:-E)/D,i[0][1])*D,M=Math.max(M,B)}if(l){let B=0;!c&&!d||c&&!d&&m?B=yn(N+z/D,l[1][1])*D:B=vn(N+(c?E:-E)/D,l[0][1])*D,M=Math.max(M,B)}}if(f){const F=Ns(A*D,x,b)/D;if($=Math.max($,F),i){let B=0;!c&&!d||d&&!c&&m?B=vn(y+A*D+T,i[1][0])/D:B=yn(y+(d?I:-I)*D+T,i[0][0])/D,$=Math.max($,B)}if(l){let B=0;!c&&!d||d&&!c&&m?B=yn(y+A*D,l[1][0])/D:B=vn(y+(d?I:-I)*D,l[0][0])/D,$=Math.max($,B)}}}I=I+(I<0?$:-$),E=E+(E<0?M:-M),s&&(m?z>A*D?I=(zf(c,d)?-E:E)/D:E=(zf(c,d)?-I:I)*D:p?(I=E/D,d=c):(E=I*D,c=d));const L=c?y+E:y,O=d?N+I:N;return{width:k+(c?-E:E),height:C+(d?-I:I),x:a[0]*E*(c?-1:1)+L,y:a[1]*I*(d?-1:1)+O}}const I1={width:0,height:0,x:0,y:0},aQ={...I1,pointerX:0,pointerY:0,aspectRatio:1};function iQ(e){return[[0,0],[e.measured.width,e.measured.height]]}function lQ(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 cQ({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:s}){const a=pt(e);let i={controlDirection:Of("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:p,keepAspectRatio:f,resizeDirection:m,onResizeStart:h,onResize:g,onResizeEnd:x,shouldResize:b}){let v={...I1},w={...aQ};i={boundaries:p,resizeDirection:m,keepAspectRatio:f,controlDirection:Of(d)};let y,N=null,k=[],C,D,E,I=!1;const z=Bv().on("start",A=>{const{nodeLookup:T,transform:R,snapGrid:M,snapToGrid:$,nodeOrigin:L,paneDomNode:O}=n();if(y=T.get(t),!y)return;N=O?.getBoundingClientRect()??null;const{xSnapped:F,ySnapped:B}=bo(A.sourceEvent,{transform:R,snapGrid:M,snapToGrid:$,containerBounds:N});v={width:y.measured.width??0,height:y.measured.height??0,x:y.position.x??0,y:y.position.y??0},w={...v,pointerX:F,pointerY:B,aspectRatio:v.width/v.height},C=void 0,y.parentId&&(y.extent==="parent"||y.expandParent)&&(C=T.get(y.parentId),D=C&&y.extent==="parent"?iQ(C):void 0),k=[],E=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 _=lQ(H,y,H.origin??L);E?E=[[Math.min(_[0][0],E[0][0]),Math.min(_[0][1],E[0][1])],[Math.max(_[1][0],E[1][0]),Math.max(_[1][1],E[1][1])]]:E=_}h?.(A,{...v})}).on("drag",A=>{const{transform:T,snapGrid:R,snapToGrid:M,nodeOrigin:$}=n(),L=bo(A.sourceEvent,{transform:T,snapGrid:R,snapToGrid:M,containerBounds:N}),O=[];if(!y)return;const{x:F,y:B,width:j,height:H}=v,_={},q=y.origin??$,{width:G,height:Q,x:J,y:Z}=sQ(w,i.controlDirection,L,i.boundaries,i.keepAspectRatio,q,D,E),X=G!==j,oe=Q!==H,he=J!==F&&X,ee=Z!==B&&oe;if(!he&&!ee&&!X&&!oe)return;if((he||ee||q[0]===1||q[1]===1)&&(_.x=he?J:v.x,_.y=ee?Z:v.y,v.x=_.x,v.y=_.y,k.length>0)){const fe=J-F,me=Z-B;for(const te of k)te.position={x:te.position.x-fe+q[0]*(G-j),y:te.position.y-me+q[1]*(Q-H)},O.push(te)}if((X||oe)&&(_.width=X&&(!i.resizeDirection||i.resizeDirection==="horizontal")?G:v.width,_.height=oe&&(!i.resizeDirection||i.resizeDirection==="vertical")?Q:v.height,v.width=_.width,v.height=_.height),C&&y.expandParent){const fe=q[0]*(_.width??0);_.x&&_.x<fe&&(v.x=fe,w.x=w.x-(_.x-fe));const me=q[1]*(_.height??0);_.y&&_.y<me&&(v.y=me,w.y=w.y-(_.y-me))}const W=oQ({width:v.width,prevWidth:j,height:v.height,prevHeight:H,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),ne={...v,direction:W};b?.(A,ne)!==!1&&(I=!0,g?.(A,ne),o(_,O))}).on("end",A=>{I&&(x?.(A,{...v}),s?.({...v}),I=!1)});a.call(z)}function c(){a.on(".drag",null)}return{update:l,destroy:c}}var P1={exports:{}},_1={};/**
|
|
1137
|
+
* @license React
|
|
1138
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
1139
|
+
*
|
|
1140
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1141
|
+
*
|
|
1142
|
+
* This source code is licensed under the MIT license found in the
|
|
1143
|
+
* LICENSE file in the root directory of this source tree.
|
|
1144
|
+
*/var Wa=Im,dQ=K0;function uQ(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var pQ=typeof Object.is=="function"?Object.is:uQ,fQ=dQ.useSyncExternalStore,mQ=Wa.useRef,hQ=Wa.useEffect,gQ=Wa.useMemo,bQ=Wa.useDebugValue;_1.useSyncExternalStoreWithSelector=function(e,t,n,o,s){var a=mQ(null);if(a.current===null){var i={hasValue:!1,value:null};a.current=i}else i=a.current;a=gQ(function(){function c(h){if(!d){if(d=!0,p=h,h=o(h),s!==void 0&&i.hasValue){var g=i.value;if(s(g,h))return f=g}return f=h}if(g=f,pQ(p,h))return g;var x=o(h);return s!==void 0&&s(g,x)?(p=h,g):(p=h,f=x)}var d=!1,p,f,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=fQ(e,a[0],a[1]);return hQ(function(){i.hasValue=!0,i.value=l},[l]),bQ(l),l};P1.exports=_1;var xQ=P1.exports;const yQ=cN(xQ),vQ={},Bf=e=>{let t;const n=new Set,o=(p,f)=>{const m=typeof p=="function"?p(t):p;if(!Object.is(m,t)){const h=t;t=f??(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:p=>(n.add(p),()=>n.delete(p)),destroy:()=>{(vQ?"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},wQ=e=>e?Bf(e):Bf,{useDebugValue:NQ}=Ge,{useSyncExternalStoreWithSelector:kQ}=yQ,SQ=e=>e;function $1(e,t=SQ,n){const o=kQ(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return NQ(o),o}const Ff=(e,t)=>{const n=wQ(e),o=(s,a=t)=>$1(n,s,a);return Object.assign(o,n),o},CQ=(e,t)=>e?Ff(e,t):Ff;function Ve(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 Ya=je(null),MQ=Ya.Provider,D1=Yt.error001();function De(e,t){const n=xe(Ya);if(n===null)throw new Error(D1);return $1(n,e,t)}function Ue(){const e=xe(Ya);if(e===null)throw new Error(D1);return V(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const jf={display:"none"},AQ={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},L1="react-flow__node-desc",T1="react-flow__edge-desc",EQ="react-flow__aria-live",IQ=e=>e.ariaLiveMessage,PQ=e=>e.ariaLabelConfig;function _Q({rfId:e}){const t=De(IQ);return r("div",{id:`${EQ}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:AQ,children:t})}function $Q({rfId:e,disableKeyboardA11y:t}){const n=De(PQ);return u(ue,{children:[r("div",{id:`${L1}-${e}`,style:jf,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),r("div",{id:`${T1}-${e}`,style:jf,children:n["edge.a11yDescription.default"]}),!t&&r(_Q,{rfId:e})]})}const Za=qe(({position:e="top-left",children:t,className:n,style:o,...s},a)=>{const i=`${e}`.split("-");return r("div",{className:Ye(["react-flow__panel",n,...i]),style:o,ref:a,...s,children:t})});Za.displayName="Panel";function DQ({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:r(Za,{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 LQ=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}},ks=e=>e.id;function TQ(e,t){return Ve(e.selectedNodes.map(ks),t.selectedNodes.map(ks))&&Ve(e.selectedEdges.map(ks),t.selectedEdges.map(ks))}function RQ({onSelectionChange:e}){const t=Ue(),{selectedNodes:n,selectedEdges:o}=De(LQ,TQ);return Y(()=>{const s={nodes:n,edges:o};e?.(s),t.getState().onSelectionChangeHandlers.forEach(a=>a(s))},[n,o,e]),null}const OQ=e=>!!e.onSelectionChangeHandlers;function zQ({onSelectionChange:e}){const t=De(OQ);return e||t?r(RQ,{onSelectionChange:e}):null}const Jl=typeof window<"u"?fa:Y,R1=[0,0],BQ={x:0,y:0,zoom:1},FQ=["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"],Hf=[...FQ,"rfId"],jQ=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}),Vf={translateExtent:Po,nodeOrigin:R1,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function HQ(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:s,setTranslateExtent:a,setNodeExtent:i,reset:l,setDefaultNodesAndEdges:c}=De(jQ,Ve),d=Ue();Jl(()=>(c(e.defaultNodes,e.defaultEdges),()=>{p.current=Vf,l()}),[]);const p=re(Vf);return Jl(()=>{for(const f of Hf){const m=e[f],h=p.current[f];m!==h&&(typeof e[f]>"u"||(f==="nodes"?t(m):f==="edges"?n(m):f==="minZoom"?o(m):f==="maxZoom"?s(m):f==="translateExtent"?a(m):f==="nodeExtent"?i(m):f==="ariaLabelConfig"?d.setState({ariaLabelConfig:wq(m)}):f==="fitView"?d.setState({fitViewQueued:m}):f==="fitViewOptions"?d.setState({fitViewOptions:m}):d.setState({[f]:m})))}p.current=e},Hf.map(f=>e[f])),null}function Uf(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function VQ(e){const[t,n]=P(e==="system"?null:e);return Y(()=>{if(e!=="system"){n(e);return}const o=Uf(),s=()=>n(o?.matches?"dark":"light");return s(),o?.addEventListener("change",s),()=>{o?.removeEventListener("change",s)}},[e]),t!==null?t:Uf()?.matches?"dark":"light"}const qf=typeof document<"u"?document:null;function Lo(e=null,t={target:qf,actInsideInputWithModifier:!0}){const[n,o]=P(!1),s=re(!1),a=re(new Set([])),[i,l]=V(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
|
|
1145
|
+
`).replace(`
|
|
1146
|
+
|
|
1147
|
+
`,`
|
|
1148
|
+
+`).split(`
|
|
1149
|
+
`)),p=d.reduce((f,m)=>f.concat(...m),[]);return[d,p]}return[[],[]]},[e]);return Y(()=>{const c=t?.target??qf,d=t?.actInsideInputWithModifier??!0;if(e!==null){const p=h=>{if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!d)&&f1(h))return!1;const x=Gf(h.code,l);if(a.current.add(h[x]),Qf(i,a.current,!1)){const b=h.composedPath?.()?.[0]||h.target,v=b?.nodeName==="BUTTON"||b?.nodeName==="A";t.preventDefault!==!1&&(s.current||!v)&&h.preventDefault(),o(!0)}},f=h=>{const g=Gf(h.code,l);Qf(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",p),c?.addEventListener("keyup",f),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{c?.removeEventListener("keydown",p),c?.removeEventListener("keyup",f),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[e,o]),n}function Qf(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(s=>t.has(s)))}function Gf(e,t){return t.includes(e)?"code":"key"}const UQ=()=>{const e=Ue();return V(()=>({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=Fd(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},p=n.snapGrid??s,f=n.snapToGrid??a;return Xo(d,o,f,p)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:s,y:a}=o.getBoundingClientRect(),i=da(t,n);return{x:i.x+s,y:i.y+a}}}),[])};function O1(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)qQ(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 qQ(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 QQ(e,t){return O1(e,t)}function GQ(e,t){return O1(e,t)}function Fn(e,t){return{id:e,type:"select",selected:t}}function pr(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(Fn(a.id,i)))}return o}function Kf({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 Wf(e){return{id:e.id,type:"remove"}}const Yf=e=>uq(e),KQ=e=>s1(e);function z1(e){return qe(e)}function Zf(e){const[t,n]=P(BigInt(0)),[o]=P(()=>WQ(()=>n(s=>s+BigInt(1))));return Jl(()=>{const s=o.get();s.length&&(e(s),o.reset())},[t]),o}function WQ(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const B1=je(null);function YQ({children:e}){const t=Ue(),n=U(l=>{const{nodes:c=[],setNodes:d,hasDefaultNodes:p,onNodesChange:f,nodeLookup:m,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let x=c;for(const v of l)x=typeof v=="function"?v(x):v;let b=Kf({items:x,lookup:m});for(const v of g.values())b=v(b);p&&d(x),b.length>0?f?.(b):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:v,nodes:w,setNodes:y}=t.getState();v&&y(w)})},[]),o=Zf(n),s=U(l=>{const{edges:c=[],setEdges:d,hasDefaultEdges:p,onEdgesChange:f,edgeLookup:m}=t.getState();let h=c;for(const g of l)h=typeof g=="function"?g(h):g;p?d(h):f&&f(Kf({items:h,lookup:m}))},[]),a=Zf(s),i=V(()=>({nodeQueue:o,edgeQueue:a}),[]);return r(B1.Provider,{value:i,children:e})}function ZQ(){const e=xe(B1);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const XQ=e=>!!e.panZoom;function Gd(){const e=UQ(),t=Ue(),n=ZQ(),o=De(XQ),s=V(()=>{const a=f=>t.getState().nodeLookup.get(f),i=f=>{n.nodeQueue.push(f)},l=f=>{n.edgeQueue.push(f)},c=f=>{const{nodeLookup:m,nodeOrigin:h}=t.getState(),g=Yf(f)?f:m.get(f.id),x=g.parentId?u1(g.position,g.measured,g.parentId,m,h):g.position,b={...g,position:x,width:g.measured?.width??g.width,height:g.measured?.height??g.height};return Pr(b)},d=(f,m,h={replace:!1})=>{i(g=>g.map(x=>{if(x.id===f){const b=typeof m=="function"?m(x):m;return h.replace&&Yf(b)?b:{...x,...b}}return x}))},p=(f,m,h={replace:!1})=>{l(g=>g.map(x=>{if(x.id===f){const b=typeof m=="function"?m(x):m;return h.replace&&KQ(b)?b:{...x,...b}}return x}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>a(f)?.internals.userNode,getInternalNode:a,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(m=>({...m}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:i,setEdges:l,addNodes:f=>{const m=Array.isArray(f)?f:[f];n.nodeQueue.push(h=>[...h,...m])},addEdges:f=>{const m=Array.isArray(f)?f:[f];n.edgeQueue.push(h=>[...h,...m])},toObject:()=>{const{nodes:f=[],edges:m=[],transform:h}=t.getState(),[g,x,b]=h;return{nodes:f.map(v=>({...v})),edges:m.map(v=>({...v})),viewport:{x:g,y:x,zoom:b}}},deleteElements:async({nodes:f=[],edges:m=[]})=>{const{nodes:h,edges:g,onNodesDelete:x,onEdgesDelete:b,triggerNodeChanges:v,triggerEdgeChanges:w,onDelete:y,onBeforeDelete:N}=t.getState(),{nodes:k,edges:C}=await gq({nodesToRemove:f,edgesToRemove:m,nodes:h,edges:g,onBeforeDelete:N}),D=C.length>0,E=k.length>0;if(D){const I=C.map(Wf);b?.(C),w(I)}if(E){const I=k.map(Wf);x?.(k),v(I)}return(E||D)&&y?.({nodes:k,edges:C}),{deletedNodes:k,deletedEdges:C}},getIntersectingNodes:(f,m=!0,h)=>{const g=Mf(f),x=g?f:c(f),b=h!==void 0;return x?(h||t.getState().nodes).filter(v=>{const w=t.getState().nodeLookup.get(v.id);if(w&&!g&&(v.id===f.id||!w.internals.positionAbsolute))return!1;const y=Pr(b?v:w),N=$o(y,x);return m&&N>0||N>=y.width*y.height||N>=x.width*x.height}):[]},isNodeIntersecting:(f,m,h=!0)=>{const x=Mf(f)?f:c(f);if(!x)return!1;const b=$o(x,m);return h&&b>0||b>=m.width*m.height||b>=x.width*x.height},updateNode:d,updateNodeData:(f,m,h={replace:!1})=>{d(f,g=>{const x=typeof m=="function"?m(g):m;return h.replace?{...g,data:x}:{...g,data:{...g.data,...x}}},h)},updateEdge:p,updateEdgeData:(f,m,h={replace:!1})=>{p(f,g=>{const x=typeof m=="function"?m(g):m;return h.replace?{...g,data:x}:{...g,data:{...g.data,...x}}},h)},getNodesBounds:f=>{const{nodeLookup:m,nodeOrigin:h}=t.getState();return pq(f,{nodeLookup:m,nodeOrigin:h})},getHandleConnections:({type:f,id:m,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}-${f}${m?`-${m}`:""}`)?.values()??[]),getNodeConnections:({type:f,handleId:m,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}${f?m?`-${f}-${m}`:`-${f}`:""}`)?.values()??[]),fitView:async f=>{const m=t.getState().fitViewResolver??vq();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:m}),n.nodeQueue.push(h=>[...h]),m.promise}}},[]);return V(()=>({...s,...e,viewportInitialized:o}),[o])}const Xf=e=>e.selected,JQ=typeof window<"u"?window:void 0;function eG({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Ue(),{deleteElements:o}=Gd(),s=Lo(e,{actInsideInputWithModifier:!1}),a=Lo(t,{target:JQ});Y(()=>{if(s){const{edges:i,nodes:l}=n.getState();o({nodes:l.filter(Xf),edges:i.filter(Xf)}),n.setState({nodesSelectionActive:!1})}},[s]),Y(()=>{n.setState({multiSelectionActive:a})},[a])}function tG(e){const t=Ue();Y(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const o=jd(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",Yt.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 Xa={position:"absolute",width:"100%",height:"100%",top:0,left:0},nG=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function rG({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:s=.5,panOnScrollMode:a=Un.Free,zoomOnDoubleClick:i=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:d,minZoom:p,maxZoom:f,zoomActivationKeyCode:m,preventScrolling:h=!0,children:g,noWheelClassName:x,noPanClassName:b,onViewportChange:v,isControlledViewport:w,paneClickDistance:y,selectionOnDrag:N}){const k=Ue(),C=re(null),{userSelectionActive:D,lib:E,connectionInProgress:I}=De(nG,Ve),z=Lo(m),A=re();tG(C);const T=U(R=>{v?.({x:R[0],y:R[1],zoom:R[2]}),w||k.setState({transform:R})},[v,w]);return Y(()=>{if(C.current){A.current=rQ({domNode:C.current,minZoom:p,maxZoom:f,translateExtent:d,viewport:c,onDraggingChange:L=>k.setState(O=>O.paneDragging===L?O:{paneDragging:L}),onPanZoomStart:(L,O)=>{const{onViewportChangeStart:F,onMoveStart:B}=k.getState();B?.(L,O),F?.(O)},onPanZoom:(L,O)=>{const{onViewportChange:F,onMove:B}=k.getState();B?.(L,O),F?.(O)},onPanZoomEnd:(L,O)=>{const{onViewportChangeEnd:F,onMoveEnd:B}=k.getState();B?.(L,O),F?.(O)}});const{x:R,y:M,zoom:$}=A.current.getViewport();return k.setState({panZoom:A.current,transform:[R,M,$],domNode:C.current.closest(".react-flow")}),()=>{A.current?.destroy()}}},[]),Y(()=>{A.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:s,panOnScrollMode:a,zoomOnDoubleClick:i,panOnDrag:l,zoomActivationKeyPressed:z,preventScrolling:h,noPanClassName:b,userSelectionActive:D,noWheelClassName:x,lib:E,onTransformChange:T,connectionInProgress:I,selectionOnDrag:N,paneClickDistance:y})},[e,t,n,o,s,a,i,l,z,h,b,D,x,E,T,I,N,y]),r("div",{className:"react-flow__renderer",ref:C,style:Xa,children:g})}const oG=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function sG(){const{userSelectionActive:e,userSelectionRect:t}=De(oG,Ve);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 Ki=(e,t)=>n=>{n.target===t.current&&e?.(n)},aG=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function iG({isSelecting:e,selectionKeyPressed:t,selectionMode:n=_o.Full,panOnDrag:o,paneClickDistance:s,selectionOnDrag:a,onSelectionStart:i,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:d,onPaneScroll:p,onPaneMouseEnter:f,onPaneMouseMove:m,onPaneMouseLeave:h,children:g}){const x=Ue(),{userSelectionActive:b,elementsSelectable:v,dragging:w,connectionInProgress:y}=De(aG,Ve),N=v&&(e||b),k=re(null),C=re(),D=re(new Set),E=re(new Set),I=re(!1),z=F=>{if(I.current||y){I.current=!1;return}c?.(F),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},A=F=>{if(Array.isArray(o)&&o?.includes(2)){F.preventDefault();return}d?.(F)},T=p?F=>p(F):void 0,R=F=>{I.current&&(F.stopPropagation(),I.current=!1)},M=F=>{const{domNode:B}=x.getState();if(C.current=B?.getBoundingClientRect(),!C.current)return;const j=F.target===k.current;if(!j&&!!F.target.closest(".nokey")||!e||!(a&&j||t)||F.button!==0||!F.isPrimary)return;F.target?.setPointerCapture?.(F.pointerId),I.current=!1;const{x:q,y:G}=Dt(F.nativeEvent,C.current);x.setState({userSelectionRect:{width:0,height:0,startX:q,startY:G,x:q,y:G}}),j||(F.stopPropagation(),F.preventDefault())},$=F=>{const{userSelectionRect:B,transform:j,nodeLookup:H,edgeLookup:_,connectionLookup:q,triggerNodeChanges:G,triggerEdgeChanges:Q,defaultEdgeOptions:J,resetSelectedElements:Z}=x.getState();if(!C.current||!B)return;const{x:X,y:oe}=Dt(F.nativeEvent,C.current),{startX:he,startY:ee}=B;if(!I.current){const me=t?0:s;if(Math.hypot(X-he,oe-ee)<=me)return;Z(),i?.(F)}I.current=!0;const W={startX:he,startY:ee,x:X<he?X:he,y:oe<ee?oe:ee,width:Math.abs(X-he),height:Math.abs(oe-ee)},ne=D.current,ie=E.current;D.current=new Set(Bd(H,W,j,n===_o.Partial,!0).map(me=>me.id)),E.current=new Set;const fe=J?.selectable??!0;for(const me of D.current){const te=q.get(me);if(te)for(const{edgeId:ye}of te.values()){const ke=_.get(ye);ke&&(ke.selectable??fe)&&E.current.add(ye)}}if(!Af(ne,D.current)){const me=pr(H,D.current,!0);G(me)}if(!Af(ie,E.current)){const me=pr(_,E.current);Q(me)}x.setState({userSelectionRect:W,userSelectionActive:!0,nodesSelectionActive:!1})},L=F=>{F.button===0&&(F.target?.releasePointerCapture?.(F.pointerId),!b&&F.target===k.current&&x.getState().userSelectionRect&&z?.(F),x.setState({userSelectionActive:!1,userSelectionRect:null}),I.current&&(l?.(F),x.setState({nodesSelectionActive:D.current.size>0})))},O=o===!0||Array.isArray(o)&&o.includes(0);return u("div",{className:Ye(["react-flow__pane",{draggable:O,dragging:w,selection:e}]),onClick:N?void 0:Ki(z,k),onContextMenu:Ki(A,k),onWheel:Ki(T,k),onPointerEnter:N?void 0:f,onPointerMove:N?$:m,onPointerUp:N?L:void 0,onPointerDownCapture:N?M:void 0,onClickCapture:N?R:void 0,onPointerLeave:h,ref:k,style:Xa,children:[g,r(sG,{})]})}function ec({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",Yt.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&i)&&(a({nodes:[d],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):s([e])}function F1({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:s,isSelectable:a,nodeClickDistance:i}){const l=Ue(),[c,d]=P(!1),p=re();return Y(()=>{p.current=Vq({getStoreItems:()=>l.getState(),onNodeMouseDown:f=>{ec({id:f,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),Y(()=>{if(!(t||!e.current||!p.current))return p.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:a,nodeId:s,nodeClickDistance:i}),()=>{p.current?.destroy()}},[n,o,t,a,e,s,i]),c}const lG=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function j1(){const e=Ue();return U(n=>{const{nodeExtent:o,snapToGrid:s,snapGrid:a,nodesDraggable:i,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:p}=e.getState(),f=new Map,m=lG(i),h=s?a[0]:5,g=s?a[1]:5,x=n.direction.x*h*n.factor,b=n.direction.y*g*n.factor;for(const[,v]of d){if(!m(v))continue;let w={x:v.internals.positionAbsolute.x+x,y:v.internals.positionAbsolute.y+b};s&&(w=Zo(w,a));const{position:y,positionAbsolute:N}=a1({nodeId:v.id,nextPosition:w,nodeLookup:d,nodeExtent:o,nodeOrigin:p,onError:l});v.position=y,v.internals.positionAbsolute=N,f.set(v.id,v)}c(f)},[])}const Kd=je(null),cG=Kd.Provider;Kd.Consumer;const H1=()=>xe(Kd),dG=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),uG=(e,t,n)=>o=>{const{connectionClickStartHandle:s,connectionMode:a,connection:i}=o,{fromHandle:l,toHandle:c,isValid:d}=i,p=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:l?.nodeId===e&&l?.id===t&&l?.type===n,connectingTo:p,clickConnecting:s?.nodeId===e&&s?.id===t&&s?.type===n,isPossibleEndHandle:a===Er.Strict?l?.type!==n:e!==l?.nodeId||t!==l?.id,connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:p&&d}};function pG({type:e="source",position:t=Ne.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:s=!0,isConnectableEnd:a=!0,id:i,onConnect:l,children:c,className:d,onMouseDown:p,onTouchStart:f,...m},h){const g=i||null,x=e==="target",b=Ue(),v=H1(),{connectOnClick:w,noPanClassName:y,rfId:N}=De(dG,Ve),{connectingFrom:k,connectingTo:C,clickConnecting:D,isPossibleEndHandle:E,connectionInProcess:I,clickConnectionInProcess:z,valid:A}=De(uG(v,g,e),Ve);v||b.getState().onError?.("010",Yt.error010());const T=$=>{const{defaultEdgeOptions:L,onConnect:O,hasDefaultEdges:F}=b.getState(),B={...L,...$};if(F){const{edges:j,setEdges:H}=b.getState();H(Aq(B,j))}O?.(B),l?.(B)},R=$=>{if(!v)return;const L=m1($.nativeEvent);if(s&&(L&&$.button===0||!L)){const O=b.getState();Xl.onPointerDown($.nativeEvent,{handleDomNode:$.currentTarget,autoPanOnConnect:O.autoPanOnConnect,connectionMode:O.connectionMode,connectionRadius:O.connectionRadius,domNode:O.domNode,nodeLookup:O.nodeLookup,lib:O.lib,isTarget:x,handleId:g,nodeId:v,flowId:O.rfId,panBy:O.panBy,cancelConnection:O.cancelConnection,onConnectStart:O.onConnectStart,onConnectEnd:(...F)=>b.getState().onConnectEnd?.(...F),updateConnection:O.updateConnection,onConnect:T,isValidConnection:n||((...F)=>b.getState().isValidConnection?.(...F)??!0),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:O.autoPanSpeed,dragThreshold:O.connectionDragThreshold})}L?p?.($):f?.($)},M=$=>{const{onClickConnectStart:L,onClickConnectEnd:O,connectionClickStartHandle:F,connectionMode:B,isValidConnection:j,lib:H,rfId:_,nodeLookup:q,connection:G}=b.getState();if(!v||!F&&!s)return;if(!F){L?.($.nativeEvent,{nodeId:v,handleId:g,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:v,type:e,id:g}});return}const Q=p1($.target),J=n||j,{connection:Z,isValid:X}=Xl.isValid($.nativeEvent,{handle:{nodeId:v,id:g,type:e},connectionMode:B,fromNodeId:F.nodeId,fromHandleId:F.id||null,fromType:F.type,isValidConnection:J,flowId:_,doc:Q,lib:H,nodeLookup:q});X&&Z&&T(Z);const oe=structuredClone(G);delete oe.inProgress,oe.toPosition=oe.toHandle?oe.toHandle.position:null,O?.($,oe),b.setState({connectionClickStartHandle:null})};return r("div",{"data-handleid":g,"data-nodeid":v,"data-handlepos":t,"data-id":`${N}-${v}-${g}-${e}`,className:Ye(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",y,d,{source:!x,target:x,connectable:o,connectablestart:s,connectableend:a,clickconnecting:D,connectingfrom:k,connectingto:C,valid:A,connectionindicator:o&&(!I||E)&&(I||z?a:s)}]),onMouseDown:R,onTouchStart:R,onClick:w?M:void 0,ref:h,...m,children:c})}const ua=Fe(z1(pG));function fG({data:e,isConnectable:t,sourcePosition:n=Ne.Bottom}){return u(ue,{children:[e?.label,r(ua,{type:"source",position:n,isConnectable:t})]})}function mG({data:e,isConnectable:t,targetPosition:n=Ne.Top,sourcePosition:o=Ne.Bottom}){return u(ue,{children:[r(ua,{type:"target",position:n,isConnectable:t}),e?.label,r(ua,{type:"source",position:o,isConnectable:t})]})}function hG(){return null}function gG({data:e,isConnectable:t,targetPosition:n=Ne.Top}){return u(ue,{children:[r(ua,{type:"target",position:n,isConnectable:t}),e?.label]})}const pa={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Jf={input:fG,default:mG,output:gG,group:hG};function bG(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 xG=e=>{const{width:t,height:n,x:o,y:s}=Yo(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 yG({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=Ue(),{width:s,height:a,transformString:i,userSelectionActive:l}=De(xG,Ve),c=j1(),d=re(null);Y(()=>{n||d.current?.focus({preventScroll:!0})},[n]);const p=!l&&s!==null&&a!==null;if(F1({nodeRef:d,disabled:!p}),!p)return null;const f=e?h=>{const g=o.getState().nodes.filter(x=>x.selected);e(h,g)}:void 0,m=h=>{Object.prototype.hasOwnProperty.call(pa,h.key)&&(h.preventDefault(),c({direction:pa[h.key],factor:h.shiftKey?4:1}))};return r("div",{className:Ye(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:r("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:m,style:{width:s,height:a}})})}const em=typeof window<"u"?window:void 0,vG=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function V1({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:i,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:d,selectionOnDrag:p,selectionMode:f,onSelectionStart:m,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:x,zoomActivationKeyCode:b,elementsSelectable:v,zoomOnScroll:w,zoomOnPinch:y,panOnScroll:N,panOnScrollSpeed:k,panOnScrollMode:C,zoomOnDoubleClick:D,panOnDrag:E,defaultViewport:I,translateExtent:z,minZoom:A,maxZoom:T,preventScrolling:R,onSelectionContextMenu:M,noWheelClassName:$,noPanClassName:L,disableKeyboardA11y:O,onViewportChange:F,isControlledViewport:B}){const{nodesSelectionActive:j,userSelectionActive:H}=De(vG,Ve),_=Lo(d,{target:em}),q=Lo(x,{target:em}),G=q||E,Q=q||N,J=p&&G!==!0,Z=_||H||J;return eG({deleteKeyCode:c,multiSelectionKeyCode:g}),r(rG,{onPaneContextMenu:a,elementsSelectable:v,zoomOnScroll:w,zoomOnPinch:y,panOnScroll:Q,panOnScrollSpeed:k,panOnScrollMode:C,zoomOnDoubleClick:D,panOnDrag:!_&&G,defaultViewport:I,translateExtent:z,minZoom:A,maxZoom:T,zoomActivationKeyCode:b,preventScrolling:R,noWheelClassName:$,noPanClassName:L,onViewportChange:F,isControlledViewport:B,paneClickDistance:l,selectionOnDrag:J,children:u(iG,{onSelectionStart:m,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:i,panOnDrag:G,isSelecting:!!Z,selectionMode:f,selectionKeyPressed:_,paneClickDistance:l,selectionOnDrag:J,children:[e,j&&r(yG,{onSelectionContextMenu:M,noPanClassName:L,disableKeyboardA11y:O})]})})}V1.displayName="FlowRenderer";const wG=Fe(V1),NG=e=>t=>e?Bd(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 kG(e){return De(U(NG(e),[e]),Ve)}const SG=e=>e.updateNodeInternals;function CG(){const e=De(SG),[t]=P(()=>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 Y(()=>()=>{t?.disconnect()},[t]),t}function MG({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const s=Ue(),a=re(null),i=re(null),l=re(e.sourcePosition),c=re(e.targetPosition),d=re(t),p=n&&!!e.internals.handleBounds;return Y(()=>{a.current&&!e.hidden&&(!p||i.current!==a.current)&&(i.current&&o?.unobserve(i.current),o?.observe(a.current),i.current=a.current)},[p,e.hidden]),Y(()=>()=>{i.current&&(o?.unobserve(i.current),i.current=null)},[]),Y(()=>{if(a.current){const f=d.current!==t,m=l.current!==e.sourcePosition,h=c.current!==e.targetPosition;(f||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 AG({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:s,onContextMenu:a,onDoubleClick:i,nodesDraggable:l,elementsSelectable:c,nodesConnectable:d,nodesFocusable:p,resizeObserver:f,noDragClassName:m,noPanClassName:h,disableKeyboardA11y:g,rfId:x,nodeTypes:b,nodeClickDistance:v,onError:w}){const{node:y,internals:N,isParent:k}=De(X=>{const oe=X.nodeLookup.get(e),he=X.parentLookup.has(e);return{node:oe,internals:oe.internals,isParent:he}},Ve);let C=y.type||"default",D=b?.[C]||Jf[C];D===void 0&&(w?.("003",Yt.error003(C)),C="default",D=b?.default||Jf.default);const E=!!(y.draggable||l&&typeof y.draggable>"u"),I=!!(y.selectable||c&&typeof y.selectable>"u"),z=!!(y.connectable||d&&typeof y.connectable>"u"),A=!!(y.focusable||p&&typeof y.focusable>"u"),T=Ue(),R=d1(y),M=MG({node:y,nodeType:C,hasDimensions:R,resizeObserver:f}),$=F1({nodeRef:M,disabled:y.hidden||!E,noDragClassName:m,handleSelector:y.dragHandle,nodeId:e,isSelectable:I,nodeClickDistance:v}),L=j1();if(y.hidden)return null;const O=gn(y),F=bG(y),B=I||E||t||n||o||s,j=n?X=>n(X,{...N.userNode}):void 0,H=o?X=>o(X,{...N.userNode}):void 0,_=s?X=>s(X,{...N.userNode}):void 0,q=a?X=>a(X,{...N.userNode}):void 0,G=i?X=>i(X,{...N.userNode}):void 0,Q=X=>{const{selectNodesOnDrag:oe,nodeDragThreshold:he}=T.getState();I&&(!oe||!E||he>0)&&ec({id:e,store:T,nodeRef:M}),t&&t(X,{...N.userNode})},J=X=>{if(!(f1(X.nativeEvent)||g)){if(t1.includes(X.key)&&I){const oe=X.key==="Escape";ec({id:e,store:T,unselect:oe,nodeRef:M})}else if(E&&y.selected&&Object.prototype.hasOwnProperty.call(pa,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})}),L({direction:pa[X.key],factor:X.shiftKey?4:1})}}},Z=()=>{if(g||!M.current?.matches(":focus-visible"))return;const{transform:X,width:oe,height:he,autoPanOnNodeFocus:ee,setCenter:W}=T.getState();if(!ee)return;Bd(new Map([[e,y]]),{x:0,y:0,width:oe,height:he},X,!0).length>0||W(y.position.x+O.width/2,y.position.y+O.height/2,{zoom:X[2]})};return r("div",{className:Ye(["react-flow__node",`react-flow__node-${C}`,{[h]:E},y.className,{selected:y.selected,selectable:I,parent:k,draggable:E,dragging:$}]),ref:M,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:B?"all":"none",visibility:R?"visible":"hidden",...y.style,...F},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:j,onMouseMove:H,onMouseLeave:_,onContextMenu:q,onClick:Q,onDoubleClick:G,onKeyDown:A?J:void 0,tabIndex:A?0:void 0,onFocus:A?Z:void 0,role:y.ariaRole??(A?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${L1}-${x}`,"aria-label":y.ariaLabel,...y.domAttributes,children:r(cG,{value:e,children:r(D,{id:e,data:y.data,type:C,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:y.selected??!1,selectable:I,draggable:E,deletable:y.deletable??!0,isConnectable:z,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:$,dragHandle:y.dragHandle,zIndex:N.z,parentId:y.parentId,...O})})})}var EG=Fe(AG);const IG=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function U1(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:s,onError:a}=De(IG,Ve),i=kG(e.onlyRenderVisibleElements),l=CG();return r("div",{className:"react-flow__nodes",style:Xa,children:i.map(c=>r(EG,{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))})}U1.displayName="NodeRenderer";const PG=Fe(U1);function _G(e){return De(U(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&&Sq({sourceNode:a,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&o.push(s.id)}return o},[e]),Ve)}const $G=({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"})},DG=({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"})},tm={[la.Arrow]:$G,[la.ArrowClosed]:DG};function LG(e){const t=Ue();return V(()=>Object.prototype.hasOwnProperty.call(tm,e)?tm[e]:(t.getState().onError?.("009",Yt.error009(e)),null),[e])}const TG=({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=LG(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},q1=({defaultColor:e,rfId:t})=>{const n=De(a=>a.edges),o=De(a=>a.defaultEdgeOptions),s=V(()=>$q(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(TG,{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};q1.displayName="MarkerDefinitions";var RG=Fe(q1);function Q1({x:e,y:t,label:n,labelStyle:o,labelShowBg:s=!0,labelBgStyle:a,labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...p}){const[f,m]=P({x:1,y:0,width:0,height:0}),h=Ye(["react-flow__edge-textwrapper",d]),g=re(null);return Y(()=>{if(g.current){const x=g.current.getBBox();m({x:x.x,y:x.y,width:x.width,height:x.height})}},[n]),n?u("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:h,visibility:f.width?"visible":"hidden",...p,children:[s&&r("rect",{width:f.width+2*i[0],x:-i[0],y:-i[1],height:f.height+2*i[1],className:"react-flow__edge-textbg",style:a,rx:l,ry:l}),r("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:g,style:o,children:n}),c]}):null}Q1.displayName="EdgeText";const OG=Fe(Q1);function Ja({path:e,labelX:t,labelY:n,label:o,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:d=20,...p}){return u(ue,{children:[r("path",{...p,d:e,fill:"none",className:Ye(["react-flow__edge-path",p.className])}),d?r("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,o&&$t(t)&&$t(n)?r(OG,{x:t,y:n,label:o,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function nm({pos:e,x1:t,y1:n,x2:o,y2:s}){return e===Ne.Left||e===Ne.Right?[.5*(t+o),n]:[t,.5*(n+s)]}function G1({sourceX:e,sourceY:t,sourcePosition:n=Ne.Bottom,targetX:o,targetY:s,targetPosition:a=Ne.Top}){const[i,l]=nm({pos:n,x1:e,y1:t,x2:o,y2:s}),[c,d]=nm({pos:a,x1:o,y1:s,x2:e,y2:t}),[p,f,m,h]=h1({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}`,p,f,m,h]}function K1(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,sourcePosition:i,targetPosition:l,label:c,labelStyle:d,labelShowBg:p,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:x,markerStart:b,interactionWidth:v})=>{const[w,y,N]=G1({sourceX:n,sourceY:o,sourcePosition:i,targetX:s,targetY:a,targetPosition:l}),k=e.isInternal?void 0:t;return r(Ja,{id:k,path:w,labelX:y,labelY:N,label:c,labelStyle:d,labelShowBg:p,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:x,markerStart:b,interactionWidth:v})})}const zG=K1({isInternal:!1}),W1=K1({isInternal:!0});zG.displayName="SimpleBezierEdge";W1.displayName="SimpleBezierEdgeInternal";function Y1(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:f,style:m,sourcePosition:h=Ne.Bottom,targetPosition:g=Ne.Top,markerEnd:x,markerStart:b,pathOptions:v,interactionWidth:w})=>{const[y,N,k]=Wl({sourceX:n,sourceY:o,sourcePosition:h,targetX:s,targetY:a,targetPosition:g,borderRadius:v?.borderRadius,offset:v?.offset,stepPosition:v?.stepPosition}),C=e.isInternal?void 0:t;return r(Ja,{id:C,path:y,labelX:N,labelY:k,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:f,style:m,markerEnd:x,markerStart:b,interactionWidth:w})})}const Z1=Y1({isInternal:!1}),X1=Y1({isInternal:!0});Z1.displayName="SmoothStepEdge";X1.displayName="SmoothStepEdgeInternal";function J1(e){return Fe(({id:t,...n})=>{const o=e.isInternal?void 0:t;return r(Z1,{...n,id:o,pathOptions:V(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const BG=J1({isInternal:!1}),ew=J1({isInternal:!0});BG.displayName="StepEdge";ew.displayName="StepEdgeInternal";function tw(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:f,style:m,markerEnd:h,markerStart:g,interactionWidth:x})=>{const[b,v,w]=x1({sourceX:n,sourceY:o,targetX:s,targetY:a}),y=e.isInternal?void 0:t;return r(Ja,{id:y,path:b,labelX:v,labelY:w,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:f,style:m,markerEnd:h,markerStart:g,interactionWidth:x})})}const FG=tw({isInternal:!1}),nw=tw({isInternal:!0});FG.displayName="StraightEdge";nw.displayName="StraightEdgeInternal";function rw(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,sourcePosition:i=Ne.Bottom,targetPosition:l=Ne.Top,label:c,labelStyle:d,labelShowBg:p,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:x,markerStart:b,pathOptions:v,interactionWidth:w})=>{const[y,N,k]=g1({sourceX:n,sourceY:o,sourcePosition:i,targetX:s,targetY:a,targetPosition:l,curvature:v?.curvature}),C=e.isInternal?void 0:t;return r(Ja,{id:C,path:y,labelX:N,labelY:k,label:c,labelStyle:d,labelShowBg:p,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:x,markerStart:b,interactionWidth:w})})}const jG=rw({isInternal:!1}),ow=rw({isInternal:!0});jG.displayName="BezierEdge";ow.displayName="BezierEdgeInternal";const rm={default:ow,straight:nw,step:ew,smoothstep:X1,simplebezier:W1},om={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},HG=(e,t,n)=>n===Ne.Left?e-t:n===Ne.Right?e+t:e,VG=(e,t,n)=>n===Ne.Top?e-t:n===Ne.Bottom?e+t:e,sm="react-flow__edgeupdater";function am({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:Ye([sm,`${sm}-${l}`]),cx:HG(t,o,e),cy:VG(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function UG({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:s,targetX:a,targetY:i,sourcePosition:l,targetPosition:c,onReconnect:d,onReconnectStart:p,onReconnectEnd:f,setReconnecting:m,setUpdateHover:h}){const g=Ue(),x=(N,k)=>{if(N.button!==0)return;const{autoPanOnConnect:C,domNode:D,connectionMode:E,connectionRadius:I,lib:z,onConnectStart:A,cancelConnection:T,nodeLookup:R,rfId:M,panBy:$,updateConnection:L}=g.getState(),O=k.type==="target",F=(H,_)=>{m(!1),f?.(H,n,k.type,_)},B=H=>d?.(n,H),j=(H,_)=>{m(!0),p?.(N,n,k.type),A?.(H,_)};Xl.onPointerDown(N.nativeEvent,{autoPanOnConnect:C,connectionMode:E,connectionRadius:I,domNode:D,handleId:k.id,nodeId:k.nodeId,nodeLookup:R,isTarget:O,edgeUpdaterType:k.type,lib:z,flowId:M,cancelConnection:T,panBy:$,isValidConnection:(...H)=>g.getState().isValidConnection?.(...H)??!0,onConnect:B,onConnectStart:j,onConnectEnd:(...H)=>g.getState().onConnectEnd?.(...H),onReconnectEnd:F,updateConnection:L,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},b=N=>x(N,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),v=N=>x(N,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),w=()=>h(!0),y=()=>h(!1);return u(ue,{children:[(e===!0||e==="source")&&r(am,{position:l,centerX:o,centerY:s,radius:t,onMouseDown:b,onMouseEnter:w,onMouseOut:y,type:"source"}),(e===!0||e==="target")&&r(am,{position:c,centerX:a,centerY:i,radius:t,onMouseDown:v,onMouseEnter:w,onMouseOut:y,type:"target"})]})}function qG({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:s,onDoubleClick:a,onContextMenu:i,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,reconnectRadius:p,onReconnect:f,onReconnectStart:m,onReconnectEnd:h,rfId:g,edgeTypes:x,noPanClassName:b,onError:v,disableKeyboardA11y:w}){let y=De(W=>W.edgeLookup.get(e));const N=De(W=>W.defaultEdgeOptions);y=N?{...N,...y}:y;let k=y.type||"default",C=x?.[k]||rm[k];C===void 0&&(v?.("011",Yt.error011(k)),k="default",C=x?.default||rm.default);const D=!!(y.focusable||t&&typeof y.focusable>"u"),E=typeof f<"u"&&(y.reconnectable||n&&typeof y.reconnectable>"u"),I=!!(y.selectable||o&&typeof y.selectable>"u"),z=re(null),[A,T]=P(!1),[R,M]=P(!1),$=Ue(),{zIndex:L,sourceX:O,sourceY:F,targetX:B,targetY:j,sourcePosition:H,targetPosition:_}=De(U(W=>{const ne=W.nodeLookup.get(y.source),ie=W.nodeLookup.get(y.target);if(!ne||!ie)return{zIndex:y.zIndex,...om};const fe=_q({id:e,sourceNode:ne,targetNode:ie,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:W.connectionMode,onError:v});return{zIndex:kq({selected:y.selected,zIndex:y.zIndex,sourceNode:ne,targetNode:ie,elevateOnSelect:W.elevateEdgesOnSelect,zIndexMode:W.zIndexMode}),...fe||om}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),Ve),q=V(()=>y.markerStart?`url('#${Yl(y.markerStart,g)}')`:void 0,[y.markerStart,g]),G=V(()=>y.markerEnd?`url('#${Yl(y.markerEnd,g)}')`:void 0,[y.markerEnd,g]);if(y.hidden||O===null||F===null||B===null||j===null)return null;const Q=W=>{const{addSelectedEdges:ne,unselectNodesAndEdges:ie,multiSelectionActive:fe}=$.getState();I&&($.setState({nodesSelectionActive:!1}),y.selected&&fe?(ie({nodes:[],edges:[y]}),z.current?.blur()):ne([e])),s&&s(W,y)},J=a?W=>{a(W,{...y})}:void 0,Z=i?W=>{i(W,{...y})}:void 0,X=l?W=>{l(W,{...y})}:void 0,oe=c?W=>{c(W,{...y})}:void 0,he=d?W=>{d(W,{...y})}:void 0,ee=W=>{if(!w&&t1.includes(W.key)&&I){const{unselectNodesAndEdges:ne,addSelectedEdges:ie}=$.getState();W.key==="Escape"?(z.current?.blur(),ne({edges:[y]})):ie([e])}};return r("svg",{style:{zIndex:L},children:u("g",{className:Ye(["react-flow__edge",`react-flow__edge-${k}`,y.className,b,{selected:y.selected,animated:y.animated,inactive:!I&&!s,updating:A,selectable:I}]),onClick:Q,onDoubleClick:J,onContextMenu:Z,onMouseEnter:X,onMouseMove:oe,onMouseLeave:he,onKeyDown:D?ee:void 0,tabIndex:D?0:void 0,role:y.ariaRole??(D?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":D?`${T1}-${g}`:void 0,ref:z,...y.domAttributes,children:[!R&&r(C,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:I,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:O,sourceY:F,targetX:B,targetY:j,sourcePosition:H,targetPosition:_,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:q,markerEnd:G,pathOptions:"pathOptions"in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),E&&r(UG,{edge:y,isReconnectable:E,reconnectRadius:p,onReconnect:f,onReconnectStart:m,onReconnectEnd:h,sourceX:O,sourceY:F,targetX:B,targetY:j,sourcePosition:H,targetPosition:_,setUpdateHover:T,setReconnecting:M})]})})}var QG=Fe(qG);const GG=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function sw({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:s,onReconnect:a,onEdgeContextMenu:i,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeClick:p,reconnectRadius:f,onEdgeDoubleClick:m,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:x}){const{edgesFocusable:b,edgesReconnectable:v,elementsSelectable:w,onError:y}=De(GG,Ve),N=_G(t);return u("div",{className:"react-flow__edges",children:[r(RG,{defaultColor:e,rfId:n}),N.map(k=>r(QG,{id:k,edgesFocusable:b,edgesReconnectable:v,elementsSelectable:w,noPanClassName:s,onReconnect:a,onContextMenu:i,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onClick:p,reconnectRadius:f,onDoubleClick:m,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:y,edgeTypes:o,disableKeyboardA11y:x},k))]})}sw.displayName="EdgeRenderer";const KG=Fe(sw),WG=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function YG({children:e}){const t=De(WG);return r("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function ZG(e){const t=Gd(),n=re(!1);Y(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const XG=e=>e.panZoom?.syncViewport;function JG(e){const t=De(XG),n=Ue();return Y(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function eK(e){return e.connection.inProgress?{...e.connection,to:Xo(e.connection.to,e.transform)}:{...e.connection}}function tK(e){return eK}function nK(e){const t=tK();return De(t,Ve)}const rK=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function oK({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:s,width:a,height:i,isValid:l,inProgress:c}=De(rK,Ve);return!(a&&s&&c)?null:r("svg",{style:e,width:a,height:i,className:"react-flow__connectionline react-flow__container",children:r("g",{className:Ye(["react-flow__connection",o1(l)]),children:r(aw,{style:t,type:n,CustomComponent:o,isValid:l})})})}const aw=({style:e,type:t=wn.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:s,from:a,fromNode:i,fromHandle:l,fromPosition:c,to:d,toNode:p,toHandle:f,toPosition:m,pointer:h}=nK();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:o1(o),toNode:p,toHandle:f,pointer:h});let g="";const x={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:d.x,targetY:d.y,targetPosition:m};switch(t){case wn.Bezier:[g]=g1(x);break;case wn.SimpleBezier:[g]=G1(x);break;case wn.Step:[g]=Wl({...x,borderRadius:0});break;case wn.SmoothStep:[g]=Wl(x);break;default:[g]=x1(x)}return r("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};aw.displayName="ConnectionLine";const sK={};function im(e=sK){re(e),Ue(),Y(()=>{},[e])}function aK(){Ue(),re(!1),Y(()=>{},[])}function iw({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:s,onNodeDoubleClick:a,onEdgeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:p,onSelectionContextMenu:f,onSelectionStart:m,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:x,connectionLineComponent:b,connectionLineContainerStyle:v,selectionKeyCode:w,selectionOnDrag:y,selectionMode:N,multiSelectionKeyCode:k,panActivationKeyCode:C,zoomActivationKeyCode:D,deleteKeyCode:E,onlyRenderVisibleElements:I,elementsSelectable:z,defaultViewport:A,translateExtent:T,minZoom:R,maxZoom:M,preventScrolling:$,defaultMarkerColor:L,zoomOnScroll:O,zoomOnPinch:F,panOnScroll:B,panOnScrollSpeed:j,panOnScrollMode:H,zoomOnDoubleClick:_,panOnDrag:q,onPaneClick:G,onPaneMouseEnter:Q,onPaneMouseMove:J,onPaneMouseLeave:Z,onPaneScroll:X,onPaneContextMenu:oe,paneClickDistance:he,nodeClickDistance:ee,onEdgeContextMenu:W,onEdgeMouseEnter:ne,onEdgeMouseMove:ie,onEdgeMouseLeave:fe,reconnectRadius:me,onReconnect:te,onReconnectStart:ye,onReconnectEnd:ke,noDragClassName:pe,noWheelClassName:le,noPanClassName:Ce,disableKeyboardA11y:ce,nodeExtent:$e,rfId:Ie,viewport:Xe,onViewportChange:lt}){return im(e),im(t),aK(),ZG(n),JG(Xe),r(wG,{onPaneClick:G,onPaneMouseEnter:Q,onPaneMouseMove:J,onPaneMouseLeave:Z,onPaneContextMenu:oe,onPaneScroll:X,paneClickDistance:he,deleteKeyCode:E,selectionKeyCode:w,selectionOnDrag:y,selectionMode:N,onSelectionStart:m,onSelectionEnd:h,multiSelectionKeyCode:k,panActivationKeyCode:C,zoomActivationKeyCode:D,elementsSelectable:z,zoomOnScroll:O,zoomOnPinch:F,zoomOnDoubleClick:_,panOnScroll:B,panOnScrollSpeed:j,panOnScrollMode:H,panOnDrag:q,defaultViewport:A,translateExtent:T,minZoom:R,maxZoom:M,onSelectionContextMenu:f,preventScrolling:$,noDragClassName:pe,noWheelClassName:le,noPanClassName:Ce,disableKeyboardA11y:ce,onViewportChange:lt,isControlledViewport:!!Xe,children:u(YG,{children:[r(KG,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:i,onReconnect:te,onReconnectStart:ye,onReconnectEnd:ke,onlyRenderVisibleElements:I,onEdgeContextMenu:W,onEdgeMouseEnter:ne,onEdgeMouseMove:ie,onEdgeMouseLeave:fe,reconnectRadius:me,defaultMarkerColor:L,noPanClassName:Ce,disableKeyboardA11y:ce,rfId:Ie}),r(oK,{style:x,type:g,component:b,containerStyle:v}),r("div",{className:"react-flow__edgelabel-renderer"}),r(PG,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:p,nodeClickDistance:ee,onlyRenderVisibleElements:I,noPanClassName:Ce,noDragClassName:pe,disableKeyboardA11y:ce,nodeExtent:$e,rfId:Ie}),r("div",{className:"react-flow__viewport-portal"})]})})}iw.displayName="GraphView";const iK=Fe(iw),lm=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c=.5,maxZoom:d=2,nodeOrigin:p,nodeExtent:f,zIndexMode:m="basic"}={})=>{const h=new Map,g=new Map,x=new Map,b=new Map,v=o??t??[],w=n??e??[],y=p??[0,0],N=f??Po;w1(x,b,v);const{nodesInitialized:k}=Zl(w,h,g,{nodeOrigin:y,nodeExtent:N,zIndexMode:m});let C=[0,0,1];if(i&&s&&a){const D=Yo(h,{filter:A=>!!((A.width||A.initialWidth)&&(A.height||A.initialHeight))}),{x:E,y:I,zoom:z}=Fd(D,s,a,c,d,l?.padding??.1);C=[E,I,z]}return{rfId:"1",width:s??0,height:a??0,transform:C,nodes:w,nodesInitialized:k,nodeLookup:h,parentLookup:g,edges:v,edgeLookup:b,connectionLookup:x,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:c,maxZoom:d,translateExtent:Po,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Er.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:y,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:{...r1},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:bq,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:n1,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},lK=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:p,nodeExtent:f,zIndexMode:m})=>CQ((h,g)=>{async function x(){const{nodeLookup:b,panZoom:v,fitViewOptions:w,fitViewResolver:y,width:N,height:k,minZoom:C,maxZoom:D}=g();v&&(await hq({nodes:b,width:N,height:k,panZoom:v,minZoom:C,maxZoom:D},w),y?.resolve(!0),h({fitViewResolver:null}))}return{...lm({nodes:e,edges:t,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:p,nodeExtent:f,defaultNodes:n,defaultEdges:o,zIndexMode:m}),setNodes:b=>{const{nodeLookup:v,parentLookup:w,nodeOrigin:y,elevateNodesOnSelect:N,fitViewQueued:k,zIndexMode:C,nodesSelectionActive:D}=g(),{nodesInitialized:E,hasSelectedNodes:I}=Zl(b,v,w,{nodeOrigin:y,nodeExtent:f,elevateNodesOnSelect:N,checkEquality:!0,zIndexMode:C}),z=D&&I;k&&E?(x(),h({nodes:b,nodesInitialized:E,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:z})):h({nodes:b,nodesInitialized:E,nodesSelectionActive:z})},setEdges:b=>{const{connectionLookup:v,edgeLookup:w}=g();w1(v,w,b),h({edges:b})},setDefaultNodesAndEdges:(b,v)=>{if(b){const{setNodes:w}=g();w(b),h({hasDefaultNodes:!0})}if(v){const{setEdges:w}=g();w(v),h({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:v,nodeLookup:w,parentLookup:y,domNode:N,nodeOrigin:k,nodeExtent:C,debug:D,fitViewQueued:E,zIndexMode:I}=g(),{changes:z,updatedInternals:A}=Bq(b,w,y,N,k,C,I);A&&(Tq(w,y,{nodeOrigin:k,nodeExtent:C,zIndexMode:I}),E?(x(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),z?.length>0&&(D&&console.log("React Flow: trigger node changes",z),v?.(z)))},updateNodePositions:(b,v=!1)=>{const w=[];let y=[];const{nodeLookup:N,triggerNodeChanges:k,connection:C,updateConnection:D,onNodesChangeMiddlewareMap:E}=g();for(const[I,z]of b){const A=N.get(I),T=!!(A?.expandParent&&A?.parentId&&z?.position),R={id:I,type:"position",position:T?{x:Math.max(0,z.position.x),y:Math.max(0,z.position.y)}:z.position,dragging:v};if(A&&C.inProgress&&C.fromNode.id===A.id){const M=Xn(A,C.fromHandle,Ne.Left,!0);D({...C,from:M})}T&&A.parentId&&w.push({id:I,parentId:A.parentId,rect:{...z.internals.positionAbsolute,width:z.measured.width??0,height:z.measured.height??0}}),y.push(R)}if(w.length>0){const{parentLookup:I,nodeOrigin:z}=g(),A=Qd(w,N,I,z);y.push(...A)}for(const I of E.values())y=I(y);k(y)},triggerNodeChanges:b=>{const{onNodesChange:v,setNodes:w,nodes:y,hasDefaultNodes:N,debug:k}=g();if(b?.length){if(N){const C=QQ(b,y);w(C)}k&&console.log("React Flow: trigger node changes",b),v?.(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:v,setEdges:w,edges:y,hasDefaultEdges:N,debug:k}=g();if(b?.length){if(N){const C=GQ(b,y);w(C)}k&&console.log("React Flow: trigger edge changes",b),v?.(b)}},addSelectedNodes:b=>{const{multiSelectionActive:v,edgeLookup:w,nodeLookup:y,triggerNodeChanges:N,triggerEdgeChanges:k}=g();if(v){const C=b.map(D=>Fn(D,!0));N(C);return}N(pr(y,new Set([...b]),!0)),k(pr(w))},addSelectedEdges:b=>{const{multiSelectionActive:v,edgeLookup:w,nodeLookup:y,triggerNodeChanges:N,triggerEdgeChanges:k}=g();if(v){const C=b.map(D=>Fn(D,!0));k(C);return}k(pr(w,new Set([...b]))),N(pr(y,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:v}={})=>{const{edges:w,nodes:y,nodeLookup:N,triggerNodeChanges:k,triggerEdgeChanges:C}=g(),D=b||y,E=v||w,I=[];for(const A of D){if(!A.selected)continue;const T=N.get(A.id);T&&(T.selected=!1),I.push(Fn(A.id,!1))}const z=[];for(const A of E)A.selected&&z.push(Fn(A.id,!1));k(I),C(z)},setMinZoom:b=>{const{panZoom:v,maxZoom:w}=g();v?.setScaleExtent([b,w]),h({minZoom:b})},setMaxZoom:b=>{const{panZoom:v,minZoom:w}=g();v?.setScaleExtent([w,b]),h({maxZoom:b})},setTranslateExtent:b=>{g().panZoom?.setTranslateExtent(b),h({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:v,triggerNodeChanges:w,triggerEdgeChanges:y,elementsSelectable:N}=g();if(!N)return;const k=v.reduce((D,E)=>E.selected?[...D,Fn(E.id,!1)]:D,[]),C=b.reduce((D,E)=>E.selected?[...D,Fn(E.id,!1)]:D,[]);w(k),y(C)},setNodeExtent:b=>{const{nodes:v,nodeLookup:w,parentLookup:y,nodeOrigin:N,elevateNodesOnSelect:k,nodeExtent:C,zIndexMode:D}=g();b[0][0]===C[0][0]&&b[0][1]===C[0][1]&&b[1][0]===C[1][0]&&b[1][1]===C[1][1]||(Zl(v,w,y,{nodeOrigin:N,nodeExtent:b,elevateNodesOnSelect:k,checkEquality:!1,zIndexMode:D}),h({nodeExtent:b}))},panBy:b=>{const{transform:v,width:w,height:y,panZoom:N,translateExtent:k}=g();return Fq({delta:b,panZoom:N,transform:v,translateExtent:k,width:w,height:y})},setCenter:async(b,v,w)=>{const{width:y,height:N,maxZoom:k,panZoom:C}=g();if(!C)return Promise.resolve(!1);const D=typeof w?.zoom<"u"?w.zoom:k;return await C.setViewport({x:y/2-b*D,y:N/2-v*D,zoom:D},{duration:w?.duration,ease:w?.ease,interpolate:w?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...r1}})},updateConnection:b=>{h({connection:b})},reset:()=>h({...lm()})}},Object.is);function cK({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:s,initialHeight:a,initialMinZoom:i,initialMaxZoom:l,initialFitViewOptions:c,fitView:d,nodeOrigin:p,nodeExtent:f,zIndexMode:m,children:h}){const[g]=P(()=>lK({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:s,height:a,fitView:d,minZoom:i,maxZoom:l,fitViewOptions:c,nodeOrigin:p,nodeExtent:f,zIndexMode:m}));return r(MQ,{value:g,children:r(YQ,{children:h})})}function dK({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:s,width:a,height:i,fitView:l,fitViewOptions:c,minZoom:d,maxZoom:p,nodeOrigin:f,nodeExtent:m,zIndexMode:h}){return xe(Ya)?r(ue,{children:e}):r(cK,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:i,fitView:l,initialFitViewOptions:c,initialMinZoom:d,initialMaxZoom:p,nodeOrigin:f,nodeExtent:m,zIndexMode:h,children:e})}const uK={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function pK({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:s,nodeTypes:a,edgeTypes:i,onNodeClick:l,onEdgeClick:c,onInit:d,onMove:p,onMoveStart:f,onMoveEnd:m,onConnect:h,onConnectStart:g,onConnectEnd:x,onClickConnectStart:b,onClickConnectEnd:v,onNodeMouseEnter:w,onNodeMouseMove:y,onNodeMouseLeave:N,onNodeContextMenu:k,onNodeDoubleClick:C,onNodeDragStart:D,onNodeDrag:E,onNodeDragStop:I,onNodesDelete:z,onEdgesDelete:A,onDelete:T,onSelectionChange:R,onSelectionDragStart:M,onSelectionDrag:$,onSelectionDragStop:L,onSelectionContextMenu:O,onSelectionStart:F,onSelectionEnd:B,onBeforeDelete:j,connectionMode:H,connectionLineType:_=wn.Bezier,connectionLineStyle:q,connectionLineComponent:G,connectionLineContainerStyle:Q,deleteKeyCode:J="Backspace",selectionKeyCode:Z="Shift",selectionOnDrag:X=!1,selectionMode:oe=_o.Full,panActivationKeyCode:he="Space",multiSelectionKeyCode:ee=Do()?"Meta":"Control",zoomActivationKeyCode:W=Do()?"Meta":"Control",snapToGrid:ne,snapGrid:ie,onlyRenderVisibleElements:fe=!1,selectNodesOnDrag:me,nodesDraggable:te,autoPanOnNodeFocus:ye,nodesConnectable:ke,nodesFocusable:pe,nodeOrigin:le=R1,edgesFocusable:Ce,edgesReconnectable:ce,elementsSelectable:$e=!0,defaultViewport:Ie=BQ,minZoom:Xe=.5,maxZoom:lt=2,translateExtent:ar=Po,preventScrolling:de=!0,nodeExtent:_e,defaultMarkerColor:Re="#b1b1b7",zoomOnScroll:Oe=!0,zoomOnPinch:Ln=!0,panOnScroll:Tn=!1,panOnScrollSpeed:Kr=.5,panOnScrollMode:pw=Un.Free,zoomOnDoubleClick:fw=!0,panOnDrag:mw=!0,onPaneClick:hw,onPaneMouseEnter:gw,onPaneMouseMove:bw,onPaneMouseLeave:xw,onPaneScroll:yw,onPaneContextMenu:vw,paneClickDistance:ww=1,nodeClickDistance:Nw=0,children:kw,onReconnect:Sw,onReconnectStart:Cw,onReconnectEnd:Mw,onEdgeContextMenu:Aw,onEdgeDoubleClick:Ew,onEdgeMouseEnter:Iw,onEdgeMouseMove:Pw,onEdgeMouseLeave:_w,reconnectRadius:$w=10,onNodesChange:Dw,onEdgesChange:Lw,noDragClassName:Tw="nodrag",noWheelClassName:Rw="nowheel",noPanClassName:Wd="nopan",fitView:Yd,fitViewOptions:Zd,connectOnClick:Ow,attributionPosition:zw,proOptions:Bw,defaultEdgeOptions:Fw,elevateNodesOnSelect:jw=!0,elevateEdgesOnSelect:Hw=!1,disableKeyboardA11y:Xd=!1,autoPanOnConnect:Vw,autoPanOnNodeDrag:Uw,autoPanSpeed:qw,connectionRadius:Qw,isValidConnection:Gw,onError:Kw,style:Ww,id:Jd,nodeDragThreshold:Yw,connectionDragThreshold:Zw,viewport:Xw,onViewportChange:Jw,width:eN,height:tN,colorMode:nN="light",debug:rN,onScroll:eu,ariaLabelConfig:oN,zIndexMode:tu="basic",...sN},aN){const ei=Jd||"1",iN=VQ(nN),lN=U(nu=>{nu.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),eu?.(nu)},[eu]);return r("div",{"data-testid":"rf__wrapper",...sN,onScroll:lN,style:{...Ww,...uK},ref:aN,className:Ye(["react-flow",s,iN]),id:Jd,role:"application",children:u(dK,{nodes:e,edges:t,width:eN,height:tN,fitView:Yd,fitViewOptions:Zd,minZoom:Xe,maxZoom:lt,nodeOrigin:le,nodeExtent:_e,zIndexMode:tu,children:[r(HQ,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:h,onConnectStart:g,onConnectEnd:x,onClickConnectStart:b,onClickConnectEnd:v,nodesDraggable:te,autoPanOnNodeFocus:ye,nodesConnectable:ke,nodesFocusable:pe,edgesFocusable:Ce,edgesReconnectable:ce,elementsSelectable:$e,elevateNodesOnSelect:jw,elevateEdgesOnSelect:Hw,minZoom:Xe,maxZoom:lt,nodeExtent:_e,onNodesChange:Dw,onEdgesChange:Lw,snapToGrid:ne,snapGrid:ie,connectionMode:H,translateExtent:ar,connectOnClick:Ow,defaultEdgeOptions:Fw,fitView:Yd,fitViewOptions:Zd,onNodesDelete:z,onEdgesDelete:A,onDelete:T,onNodeDragStart:D,onNodeDrag:E,onNodeDragStop:I,onSelectionDrag:$,onSelectionDragStart:M,onSelectionDragStop:L,onMove:p,onMoveStart:f,onMoveEnd:m,noPanClassName:Wd,nodeOrigin:le,rfId:ei,autoPanOnConnect:Vw,autoPanOnNodeDrag:Uw,autoPanSpeed:qw,onError:Kw,connectionRadius:Qw,isValidConnection:Gw,selectNodesOnDrag:me,nodeDragThreshold:Yw,connectionDragThreshold:Zw,onBeforeDelete:j,debug:rN,ariaLabelConfig:oN,zIndexMode:tu}),r(iK,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:w,onNodeMouseMove:y,onNodeMouseLeave:N,onNodeContextMenu:k,onNodeDoubleClick:C,nodeTypes:a,edgeTypes:i,connectionLineType:_,connectionLineStyle:q,connectionLineComponent:G,connectionLineContainerStyle:Q,selectionKeyCode:Z,selectionOnDrag:X,selectionMode:oe,deleteKeyCode:J,multiSelectionKeyCode:ee,panActivationKeyCode:he,zoomActivationKeyCode:W,onlyRenderVisibleElements:fe,defaultViewport:Ie,translateExtent:ar,minZoom:Xe,maxZoom:lt,preventScrolling:de,zoomOnScroll:Oe,zoomOnPinch:Ln,zoomOnDoubleClick:fw,panOnScroll:Tn,panOnScrollSpeed:Kr,panOnScrollMode:pw,panOnDrag:mw,onPaneClick:hw,onPaneMouseEnter:gw,onPaneMouseMove:bw,onPaneMouseLeave:xw,onPaneScroll:yw,onPaneContextMenu:vw,paneClickDistance:ww,nodeClickDistance:Nw,onSelectionContextMenu:O,onSelectionStart:F,onSelectionEnd:B,onReconnect:Sw,onReconnectStart:Cw,onReconnectEnd:Mw,onEdgeContextMenu:Aw,onEdgeDoubleClick:Ew,onEdgeMouseEnter:Iw,onEdgeMouseMove:Pw,onEdgeMouseLeave:_w,reconnectRadius:$w,defaultMarkerColor:Re,noDragClassName:Tw,noWheelClassName:Rw,noPanClassName:Wd,rfId:ei,disableKeyboardA11y:Xd,nodeExtent:_e,viewport:Xw,onViewportChange:Jw}),r(zQ,{onSelectionChange:R}),kw,r(DQ,{proOptions:Bw,position:zw}),r($Q,{rfId:ei,disableKeyboardA11y:Xd})]})})}var fK=z1(pK);function mK({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:Ye(["react-flow__background-pattern",n,o])})}function hK({radius:e,className:t}){return r("circle",{cx:e,cy:e,r:e,className:Ye(["react-flow__background-pattern","dots",t])})}var Sn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Sn||(Sn={}));const gK={[Sn.Dots]:1,[Sn.Lines]:1,[Sn.Cross]:6},bK=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function lw({id:e,variant:t=Sn.Dots,gap:n=20,size:o,lineWidth:s=1,offset:a=0,color:i,bgColor:l,style:c,className:d,patternClassName:p}){const f=re(null),{transform:m,patternId:h}=De(bK,Ve),g=o||gK[t],x=t===Sn.Dots,b=t===Sn.Cross,v=Array.isArray(n)?n:[n,n],w=[v[0]*m[2]||1,v[1]*m[2]||1],y=g*m[2],N=Array.isArray(a)?a:[a,a],k=b?[y,y]:w,C=[N[0]*m[2]||1+k[0]/2,N[1]*m[2]||1+k[1]/2],D=`${h}${e||""}`;return u("svg",{className:Ye(["react-flow__background",d]),style:{...c,...Xa,"--xy-background-color-props":l,"--xy-background-pattern-color-props":i},ref:f,"data-testid":"rf__background",children:[r("pattern",{id:D,x:m[0]%w[0],y:m[1]%w[1],width:w[0],height:w[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`,children:x?r(hK,{radius:y/2,className:p}):r(mK,{dimensions:k,lineWidth:s,variant:t,className:p})}),r("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${D})`})]})}lw.displayName="Background";const xK=Fe(lw);function yK(){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 vK(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:r("path",{d:"M0 0h32v4.2H0z"})})}function wK(){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 NK(){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 kK(){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 Ss({children:e,className:t,...n}){return r("button",{type:"button",className:Ye(["react-flow__controls-button",t]),...n,children:e})}const SK=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function cw({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:s,onZoomIn:a,onZoomOut:i,onFitView:l,onInteractiveChange:c,className:d,children:p,position:f="bottom-left",orientation:m="vertical","aria-label":h}){const g=Ue(),{isInteractive:x,minZoomReached:b,maxZoomReached:v,ariaLabelConfig:w}=De(SK,Ve),{zoomIn:y,zoomOut:N,fitView:k}=Gd(),C=()=>{y(),a?.()},D=()=>{N(),i?.()},E=()=>{k(s),l?.()},I=()=>{g.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),c?.(!x)};return u(Za,{className:Ye(["react-flow__controls",m==="horizontal"?"horizontal":"vertical",d]),position:f,style:e,"data-testid":"rf__controls","aria-label":h??w["controls.ariaLabel"],children:[t&&u(ue,{children:[r(Ss,{onClick:C,className:"react-flow__controls-zoomin",title:w["controls.zoomIn.ariaLabel"],"aria-label":w["controls.zoomIn.ariaLabel"],disabled:v,children:r(yK,{})}),r(Ss,{onClick:D,className:"react-flow__controls-zoomout",title:w["controls.zoomOut.ariaLabel"],"aria-label":w["controls.zoomOut.ariaLabel"],disabled:b,children:r(vK,{})})]}),n&&r(Ss,{className:"react-flow__controls-fitview",onClick:E,title:w["controls.fitView.ariaLabel"],"aria-label":w["controls.fitView.ariaLabel"],children:r(wK,{})}),o&&r(Ss,{className:"react-flow__controls-interactive",onClick:I,title:w["controls.interactive.ariaLabel"],"aria-label":w["controls.interactive.ariaLabel"],children:x?r(kK,{}):r(NK,{})}),p]})}cw.displayName="Controls";const CK=Fe(cw);function MK({id:e,x:t,y:n,width:o,height:s,style:a,color:i,strokeColor:l,strokeWidth:c,className:d,borderRadius:p,shapeRendering:f,selected:m,onClick:h}){const{background:g,backgroundColor:x}=a||{},b=i||g||x;return r("rect",{className:Ye(["react-flow__minimap-node",{selected:m},d]),x:t,y:n,rx:p,ry:p,width:o,height:s,style:{fill:b,stroke:l,strokeWidth:c},shapeRendering:f,onClick:h?v=>h(v,e):void 0})}const AK=Fe(MK),EK=e=>e.nodes.map(t=>t.id),Wi=e=>e instanceof Function?e:()=>e;function IK({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:s,nodeComponent:a=AK,onClick:i}){const l=De(EK,Ve),c=Wi(t),d=Wi(e),p=Wi(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return r(ue,{children:l.map(m=>r(_K,{id:m,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:p,nodeBorderRadius:o,nodeStrokeWidth:s,NodeComponent:a,onClick:i,shapeRendering:f},m))})}function PK({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:s,nodeStrokeWidth:a,shapeRendering:i,NodeComponent:l,onClick:c}){const{node:d,x:p,y:f,width:m,height:h}=De(g=>{const x=g.nodeLookup.get(e);if(!x)return{node:void 0,x:0,y:0,width:0,height:0};const b=x.internals.userNode,{x:v,y:w}=x.internals.positionAbsolute,{width:y,height:N}=gn(b);return{node:b,x:v,y:w,width:y,height:N}},Ve);return!d||d.hidden||!d1(d)?null:r(l,{x:p,y:f,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 _K=Fe(PK);var $K=Fe(IK);const DK=200,LK=150,TK=e=>!e.hidden,RK=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?c1(Yo(e.nodeLookup,{filter:TK}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},OK="react-flow__minimap-desc";function dw({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:s="",nodeBorderRadius:a=5,nodeStrokeWidth:i,nodeComponent:l,bgColor:c,maskColor:d,maskStrokeColor:p,maskStrokeWidth:f,position:m="bottom-right",onClick:h,onNodeClick:g,pannable:x=!1,zoomable:b=!1,ariaLabel:v,inversePan:w,zoomStep:y=1,offsetScale:N=5}){const k=Ue(),C=re(null),{boundingRect:D,viewBB:E,rfId:I,panZoom:z,translateExtent:A,flowWidth:T,flowHeight:R,ariaLabelConfig:M}=De(RK,Ve),$=e?.width??DK,L=e?.height??LK,O=D.width/$,F=D.height/L,B=Math.max(O,F),j=B*$,H=B*L,_=N*B,q=D.x-(j-D.width)/2-_,G=D.y-(H-D.height)/2-_,Q=j+_*2,J=H+_*2,Z=`${OK}-${I}`,X=re(0),oe=re();X.current=B,Y(()=>{if(C.current&&z)return oe.current=Wq({domNode:C.current,panZoom:z,getTransform:()=>k.getState().transform,getViewScale:()=>X.current}),()=>{oe.current?.destroy()}},[z]),Y(()=>{oe.current?.update({translateExtent:A,width:T,height:R,inversePan:w,pannable:x,zoomStep:y,zoomable:b})},[x,b,w,y,A,T,R]);const he=h?ne=>{const[ie,fe]=oe.current?.pointer(ne)||[0,0];h(ne,{x:ie,y:fe})}:void 0,ee=g?U((ne,ie)=>{const fe=k.getState().nodeLookup.get(ie).internals.userNode;g(ne,fe)},[]):void 0,W=v??M["minimap.ariaLabel"];return r(Za,{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 p=="string"?p:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*B: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:Ye(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:u("svg",{width:$,height:L,viewBox:`${q} ${G} ${Q} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Z,ref:C,onClick:he,children:[W&&r("title",{id:Z,children:W}),r($K,{onClick:ee,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:s,nodeStrokeWidth:i,nodeComponent:l}),r("path",{className:"react-flow__minimap-mask",d:`M${q-_},${G-_}h${Q+_*2}v${J+_*2}h${-Q-_*2}z
|
|
1150
|
+
M${E.x},${E.y}h${E.width}v${E.height}h${-E.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}dw.displayName="MiniMap";Fe(dw);const zK=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,BK={[$r.Line]:"right",[$r.Handle]:"bottom-right"};function FK({nodeId:e,position:t,variant:n=$r.Handle,className:o,style:s=void 0,children:a,color:i,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:m,autoScale:h=!0,shouldResize:g,onResizeStart:x,onResize:b,onResizeEnd:v}){const w=H1(),y=typeof e=="string"?e:w,N=Ue(),k=re(null),C=n===$r.Handle,D=De(U(zK(C&&h),[C,h]),Ve),E=re(null),I=t??BK[n];Y(()=>{if(!(!k.current||!y))return E.current||(E.current=cQ({domNode:k.current,nodeId:y,getStoreItems:()=>{const{nodeLookup:A,transform:T,snapGrid:R,snapToGrid:M,nodeOrigin:$,domNode:L}=N.getState();return{nodeLookup:A,transform:T,snapGrid:R,snapToGrid:M,nodeOrigin:$,paneDomNode:L}},onChange:(A,T)=>{const{triggerNodeChanges:R,nodeLookup:M,parentLookup:$,nodeOrigin:L}=N.getState(),O=[],F={x:A.x,y:A.y},B=M.get(y);if(B&&B.expandParent&&B.parentId){const j=B.origin??L,H=A.width??B.measured.width??0,_=A.height??B.measured.height??0,q={id:B.id,parentId:B.parentId,rect:{width:H,height:_,...u1({x:A.x??B.position.x,y:A.y??B.position.y},{width:H,height:_},B.parentId,M,j)}},G=Qd([q],M,$,L);O.push(...G),F.x=A.x?Math.max(j[0]*H,A.x):void 0,F.y=A.y?Math.max(j[1]*_,A.y):void 0}if(F.x!==void 0&&F.y!==void 0){const j={id:y,type:"position",position:{...F}};O.push(j)}if(A.width!==void 0&&A.height!==void 0){const H={id:y,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:A.width,height:A.height}};O.push(H)}for(const j of T){const H={...j,type:"position"};O.push(H)}R(O)},onEnd:({width:A,height:T})=>{const R={id:y,type:"dimensions",resizing:!1,dimensions:{width:A,height:T}};N.getState().triggerNodeChanges([R])}})),E.current.update({controlPosition:I,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:p},keepAspectRatio:f,resizeDirection:m,onResizeStart:x,onResize:b,onResizeEnd:v,shouldResize:g}),()=>{E.current?.destroy()}},[I,l,c,d,p,f,x,b,v,g]);const z=I.split("-");return r("div",{className:Ye(["react-flow__resize-control","nodrag",...z,n,o]),ref:k,style:{...s,scale:D,...i&&{[C?"backgroundColor":"borderColor"]:i}},children:a})}Fe(FK);function jK({availableCaps:e,selectedCaps:t,onChange:n}){const[o,s]=P(""),a=V(()=>{const c=new Set(t),d=o.trim().toLowerCase();return e.filter(p=>!c.has(p)&&(d===""||p.toLowerCase().includes(d)))},[e,t,o]),i=U(c=>{n([...t,c]),s("")},[t,n]),l=U(c=>{n(t.filter(d=>d!==c))},[t,n]);return u("div",{className:"flex flex-wrap items-center gap-1 border border-border rounded-md px-2 py-1",children:[t.map(c=>u("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-primary/10 text-primary text-[10px]",children:[c,r("button",{type:"button","aria-label":`Remove ${c}`,onClick:()=>l(c),className:"rounded hover:bg-primary/20",children:r(Be,{className:"h-2.5 w-2.5"})})]},c)),u("div",{className:"relative flex-1 min-w-[160px]",children:[r("input",{type:"text",placeholder:"Filter caps…",value:o,onChange:c=>s(c.target.value),className:"w-full bg-transparent text-xs outline-none"}),o.length>0&&a.length>0&&r("ul",{role:"listbox",className:"absolute z-10 left-0 right-0 mt-1 max-h-48 overflow-auto rounded-md border border-border bg-surface",children:a.map(c=>r("li",{children:r("button",{type:"button",role:"option","aria-selected":!1,onClick:()=>i(c),className:"w-full text-left px-2 py-1 text-xs hover:bg-muted",children:c})},c))})]})]})}const HK=Fe(jK),VK=5e3,Yi={consumer:0,cap:400,provider:800},Zi=80,cm=4;function UK({initialSelectedCaps:e=[],windowSeconds:t=60}){const[n,o]=P(e),{data:s,isLoading:a}=Zb({windowSeconds:t},{refetchInterval:VK}),i=V(()=>{const c=s??[];return Array.from(new Set(c.map(d=>d.capName))).sort()},[s]),l=V(()=>{if(n.length===0)return{nodes:[],edges:[]};const c=new Set(n),p=(s??[]).filter(b=>c.has(b.capName)),f=Array.from(new Set(p.map(b=>b.callerAddonId))).sort(),m=Array.from(new Set(p.map(b=>b.providerAddonId))).sort(),h=[];f.forEach((b,v)=>h.push({id:`consumer:${b}`,position:{x:Yi.consumer,y:v*Zi},data:{label:b}})),n.forEach((b,v)=>h.push({id:`cap:${b}`,position:{x:Yi.cap,y:v*Zi},data:{label:b},style:{background:"#3b82f6",color:"white"}})),m.forEach((b,v)=>h.push({id:`provider:${b}`,position:{x:Yi.provider,y:v*Zi},data:{label:b}}));const g=Math.max(1,...p.map(b=>b.callsPerMin)),x=[];for(const b of p){const v=Math.max(1,Math.min(cm,b.callsPerMin/g*cm));x.push({id:`${b.callerAddonId}→${b.capName}`,source:`consumer:${b.callerAddonId}`,target:`cap:${b.capName}`,style:{strokeWidth:v}}),x.push({id:`${b.capName}→${b.providerAddonId}`,source:`cap:${b.capName}`,target:`provider:${b.providerAddonId}`,style:{strokeWidth:v}})}return{nodes:h,edges:x}},[s,n]);return u("div",{className:"flex flex-col flex-1 min-h-0 gap-2 p-3",children:[r(HK,{availableCaps:i,selectedCaps:n,onChange:o}),n.length===0?r("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-xs",children:"Select 1+ capability to see who uses it."}):a?r("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-xs",children:"Loading…"}):r("div",{className:"flex-1 min-h-0 border border-border rounded-md overflow-hidden",children:u(fK,{nodes:[...l.nodes],edges:[...l.edges],fitView:!0,proOptions:{hideAttribution:!0},children:[r(xK,{gap:20,size:1}),r(CK,{showInteractive:!1})]})})]})}function qK({onlineNodeIds:e}){const t=we(),n=et(),{data:o,isLoading:s}=Hr(),a=vx({onSuccess:()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","listAgentSettings"]]})}}),i=V(()=>{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(Sl,{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(Sl,{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,p=Object.values(c.settings.addonDefaults??{}).filter(f=>f?.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(ue,{children:[" · ",p," 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(We,{className:"h-3 w-3"}),"Remove"]})]},c.nodeId)})})]})}function QK(e){const[t,n]=P(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return Y(()=>{const o=window.matchMedia(e),s=a=>n(a.matches);return o.addEventListener("change",s),()=>o.removeEventListener("change",s)},[e]),t}function GK(){const{data:e,isLoading:t}=Dn(void 0,{staleTime:1/0}),[n,o]=P(null);return ht("cluster.topology-snapshot",a=>{const i=a.data?.nodes;Array.isArray(i)&&o(i)}),{nodes:V(()=>n??e??[],[n,e]),isLoading:t&&!n}}function KK(){const[e,t]=P("diagram"),[n,o]=P("topology"),s=QK("(max-width: 767px)"),a=s&&e==="diagram"?"table":e,{nodes:i,isLoading:l}=GK(),c=i.filter(g=>g.isOnline).length,d=i.filter(g=>!g.isOnline).length,p=V(()=>i.map(g=>g.id??"").filter(Boolean),[i]),{data:f}=Hr(),m=V(()=>{if(!f)return 0;const g=new Set(p);return g.add("hub"),f.filter(x=>!g.has(x.nodeId)).length},[f,p]),h=(g,x,b,v)=>u("button",{onClick:()=>t(g),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${e===g?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:[r(b,{className:"h-3.5 w-3.5"}),x,v!==void 0&&v>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===g?"bg-primary-foreground/20 text-primary-foreground":"bg-destructive/15 text-destructive"}`,children:v})]});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-2",children:[c>0&&u("span",{className:"text-xs px-2 py-0.5 rounded-full bg-success/10 text-success",children:[c," online"]}),d>0&&u("span",{className:"text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:[d," offline"]})]}),u("div",{className:"flex gap-0.5 p-1 rounded-lg bg-muted",children:[!s&&h("diagram","Diagram",Mn),h("table","Table",NO),h("offline-agents","Offline agents",Sl,m)]})]}),a==="diagram"&&u("div",{className:"flex gap-1 p-1 rounded-lg bg-muted self-start",children:[r("button",{type:"button",onClick:()=>o("topology"),className:`px-2 py-1 rounded text-xs ${n==="topology"?"bg-primary text-primary-foreground":"text-muted-foreground"}`,children:"Topology"}),r("button",{type:"button",onClick:()=>o("capability-flow"),className:`px-2 py-1 rounded text-xs ${n==="capability-flow"?"bg-primary text-primary-foreground":"text-muted-foreground"}`,children:"Capability Flow"})]}),l?r("div",{className:"flex items-center justify-center flex-1 text-muted-foreground",children:"Loading cluster topology..."}):a==="diagram"?n==="topology"?r(_j,{topology:i}):r(UK,{}):a==="table"?r("div",{className:"flex-1 overflow-auto",children:r(yj,{nodes:i})}):r("div",{className:"flex-1 overflow-auto",children:r(qK,{onlineNodeIds:p})})]})}function rn({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 ot({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 WK={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 YK(){const[e,t]=P({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(rn,{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(rn,{title:"Colors",children:u("div",{className:"flex flex-wrap gap-4",children:[r(ot,{name:"primary",cssVar:"--color-primary"}),r(ot,{name:"background",cssVar:"--color-background"}),r(ot,{name:"surface",cssVar:"--color-surface"}),r(ot,{name:"foreground",cssVar:"--color-foreground"}),r(ot,{name:"success",cssVar:"--color-success"}),r(ot,{name:"warning",cssVar:"--color-warning"}),r(ot,{name:"danger",cssVar:"--color-danger"}),r(ot,{name:"info",cssVar:"--color-info"}),r(ot,{name:"border",cssVar:"--color-border"}),r("div",{className:"w-px"}),r(ot,{name:"frigate",hex:"#3b82f6"}),r(ot,{name:"scrypted",hex:"#a855f7"}),r(ot,{name:"reolink",hex:"#06b6d4"}),r(ot,{name:"ha",hex:"#22d3ee"}),r(ot,{name:"rtsp",hex:"#78716c"})]})}),r(rn,{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(rn,{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(ZK,{})]})}),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(rn,{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(Oa,{status:n},n))})]}),u("div",{children:[r("p",{className:"text-xs text-foreground-subtle mb-2",children:"CapabilityBadges"}),r(za,{capabilities:["streaming","detection","recording","audio"]})]})]})}),r(rn,{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(rn,{title:"Provider Icons",children:r("div",{className:"flex flex-wrap gap-4",children:["frigate","scrypted","reolink","homeassistant","rtsp","onvif"].map(n=>r(pn,{type:n,size:"lg",showLabel:!0},n))})}),u(rn,{title:"Form Builder Demo",children:[r(En,{schema:WK,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(rn,{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 ZK(){const[e,t]=P(!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 dm={info:{bg:"bg-blue-500/10",border:"border-blue-500/30",icon:Gn},warning:{bg:"bg-orange-500/10",border:"border-orange-500/30",icon:at},critical:{bg:"bg-red-500/10",border:"border-red-500/30",icon:kr}};function XK({toast:e,onDismiss:t}){const n=dm[e.severity]??dm.info,o=n.icon;return Y(()=>{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(Be,{className:"h-3.5 w-3.5 text-foreground-subtle"})})]})}function JK(){const[e,t]=P([]),n=U(o=>{t(s=>s.filter(a=>a.id!==o))},[]);return Ux(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(XK,{toast:o,onDismiss:n})},o.id))})}const tc=new bm({defaultOptions:{queries:{staleTime:3e4,retry:!1,refetchOnWindowFocus:!1}}});function eW({field:e,value:t,onChange:n,disabled:o}){return r(HO,{field:e,value:t,onChange:n,disabled:o})}function tW({field:e,value:t,onChange:n,disabled:o}){return r(XO,{field:e,value:t,onChange:n,disabled:o})}const nW={"pipeline-editor":eW,"model-selector":tW};function rW({children:e}){const{user:t}=Xt(),[n,o]=P(0),s=re(t?.username??null);Y(()=>{const f=t?.username??null;f!==s.current&&(s.current=f,dr(),o(m=>m+1))},[t]);const a=V(()=>_s(),[n]),[i,l]=P(!1),[c,d]=P(null);Y(()=>{if(l(!1),d(null),!t){l(!0);return}let f=!1;return a.init().then(()=>{f||l(!0)},m=>{if(f)return;const h=m instanceof Error?m.message:String(m);d(h),l(!0)}),()=>{f=!0}},[a,t]);const p=U(()=>{dr(),o(f=>f+1),tc.invalidateQueries()},[]);return qT(p),r(Cc,{system:a,children:r(S.Provider,{client:a.trpcClient,queryClient:tc,children:u(sy,{children:[i?e:r(oW,{}),i&&r(RO,{}),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 oW(){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 sW(){return r(zs,{defaultMode:"dark",children:r(xm,{client:tc,children:r(o8,{children:r(rW,{children:r(Jh,{children:u(yg,{renderers:nW,children:[r(LT,{children:u(cT,{children:[r(Te,{path:"/login",element:r(i7,{})}),r(Te,{path:"/change-password",element:r(Et,{children:r(c7,{})})}),r(Te,{path:"/showroom",element:r(YK,{})}),u(Te,{element:r(Et,{children:r(a7,{})}),children:[r(Te,{index:!0,element:r(dt,{to:"/dashboard",replace:!0})}),r(Te,{path:"/access-denied",element:r(d7,{})}),r(Te,{path:"/dashboard",element:r(w7,{})}),r(Te,{path:"/devices",element:r(M7,{})}),r(Te,{path:"/cameras",element:r(dt,{to:"/devices",replace:!0})}),r(Te,{path:"/integrations",element:r(O7,{})}),r(Te,{path:"/integrations/:integrationId",element:r(F7,{})}),r(Te,{path:"/timeline",element:r(Y7,{})}),r(Te,{path:"/pipeline",element:r(P9,{})}),r(Te,{path:"/devices/:deviceId",element:r(Tz,{})}),r(Te,{path:"/system/logs",element:r(Et,{requireAdmin:!0,children:r(nB,{})})}),r(Te,{path:"/system/addons",element:r(Et,{requireAdmin:!0,children:r(Yz,{})})}),r(Te,{path:"/system/settings",element:r(Et,{requireAdmin:!0,children:r(rj,{})})}),r(Te,{path:"/system/cluster",element:r(Et,{requireAdmin:!0,children:r(KK,{})})}),r(Te,{path:"/system/identity",element:r(Et,{requireAdmin:!0,children:r(PB,{})})}),r(Te,{path:"/system/my-access",element:r(Jz,{})}),r(Te,{path:"/system/network",element:r(Et,{requireAdmin:!0,children:r(oF,{})})}),r(Te,{path:"/system/integrations",element:r(Et,{requireAdmin:!0,children:r(hF,{})})}),r(Te,{path:"/system/data",element:r(Et,{requireAdmin:!0,children:r(nj,{})})}),r(Te,{path:"/system/users",element:r(dt,{to:"/system/identity?tab=users",replace:!0})}),r(Te,{path:"/system/api-keys",element:r(dt,{to:"/system/identity?tab=api-keys",replace:!0})}),r(Te,{path:"/system/authentication",element:r(dt,{to:"/system/identity?tab=authentication",replace:!0})}),r(Te,{path:"/system/linked-sessions",element:r(dt,{to:"/system/identity?tab=linked-sessions",replace:!0})}),r(Te,{path:"/system/remote-access",element:r(dt,{to:"/system/network?tab=remote-access",replace:!0})}),r(Te,{path:"/system/turn",element:r(dt,{to:"/system/network?tab=turn",replace:!0})}),r(Te,{path:"/system/storage",element:r(dt,{to:"/system/data?tab=storage",replace:!0})}),r(Te,{path:"/system/backup",element:r(dt,{to:"/system/data?tab=backup",replace:!0})}),r(Te,{path:"/addon/:pagePath",element:r(Et,{requireAdmin:!0,children:r(r7,{})})})]})]})}),r(JK,{})]})})})})})})}const aW={dashboard:"Dashboard",integrations:"Integrations",metrics:"Metrics"},iW={title:"System",addons:"Addons",agents:"Agents",processes:"Processes",logs:"Logs",users:"Users",settings:"Settings",repl:"REPL",models:"Models",integrations:"Integrations"},lW={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"},cW={disconnected:"Server unreachable — reconnecting…",connected:"Connected"},dW={online:"Online",offline:"Offline",connecting:"Connecting",error:"Error",disabled:"Disabled",enabled:"Enabled",active:"Active",inactive:"Inactive",running:"Running",stopped:"Stopped",pending:"Pending",unknown:"Unknown"},uW={login:"Login",logout:"Logout",username:"Username",password:"Password",signIn:"Sign In",invalidCredentials:"Invalid username or password"},pW={dark:"Dark",light:"Light",system:"System"},fW={select:"Language",en:"English",it:"Italian"},mW={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"}},hW={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"},gW={nav:aW,system:iW,common:lW,connection:cW,status:dW,auth:uW,theme:pW,language:fW,pages:mW,integrations:hW},bW={dashboard:"Dashboard",integrations:"Integrazioni",metrics:"Metriche"},xW={title:"Sistema",addons:"Addon",agents:"Agenti",processes:"Processi",logs:"Log",users:"Utenti",settings:"Impostazioni",repl:"REPL",models:"Modelli",integrations:"Integrazioni"},yW={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"},vW={disconnected:"Server non raggiungibile — riconnessione in corso…",connected:"Connesso"},wW={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"},NW={login:"Accesso",logout:"Esci",username:"Nome utente",password:"Password",signIn:"Accedi",invalidCredentials:"Nome utente o password non validi"},kW={dark:"Scuro",light:"Chiaro",system:"Sistema"},SW={select:"Lingua",en:"Inglese",it:"Italiano"},CW={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"}},MW={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"},AW={nav:bW,system:xW,common:yW,connection:vW,status:wW,auth:NW,theme:kW,language:SW,pages:CW,integrations:MW},uw="camstack_language",EW=localStorage.getItem(uw)??"en";nt.use(z8).init({resources:{en:{translation:gW},it:{translation:AW}},lng:EW,fallbackLng:"en",interpolation:{escapeValue:!1}});nt.on("languageChanged",e=>{localStorage.setItem(uw,e)});window.__camstackUiLibrary=lL;window.__camstackSdk=IN;window.__camstackTypes=PN;hm(document.getElementById("root")).render(r(hN,{children:r(sW,{})}));
|