@camstack/addon-admin-ui 0.1.35 → 0.1.37
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-Cjyt3AKP.js +1 -0
- package/dist/assets/{devices-D4k34mru.js → devices-GLp7me2a.js} +1 -1
- package/dist/assets/hostInit-Cx72YpvD.js +1 -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-G9qsQFtk.js +1150 -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-CbhqJYoN.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_-I5siGnQL.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-BhNfKRLZ.js +0 -1156
- 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-bBEaoekV.css +0 -1
- package/dist/assets/method-access-map-BFPyQ2-G.js +0 -1
|
@@ -1,1156 +0,0 @@
|
|
|
1
|
-
import"./virtualExposes-_ivNhQLP.js";import{d as _r}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DUkp33c_.js";import{c as o,a as Jh,d as f,e as me,g as s2}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-C_6K4VBY.js";import{b as ze,e as _,h as U,c as Y,f as H,d as ve,a as em,j as Ue,k as Ee,i as te,l as Jn,m as Aa,g as Pa,R as Ge,n as Sc,o as a2,p as i2,q as $r,r as He,s as l2,t as c2,u as d2,v as u2}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-Dl4u0xYE.js";import{a as tm,b as qo}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-CzO_Esxm.js";import{a as nm,b as rm}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-DNpf5SLz.js";import{_ as om,m as Ln,n as ke,o as sm,p as am,h as Kn,j as p2}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-CeLhKMin.js";import{_ as im,c as lm,s as cm,n as f2,B as h2,F as m2}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.mjs-DIkg6-MH.js";import{_ as dm,a as g2}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-OcRSBqRe.js";import{c as b2,D as um,E as x2,a as Wn,b as pt,M as y2,W as Nl,N as v2,d as pm,S as w2,e as zs}from"./index-BqMPfvQx.js";import{S as kl,c as fm}from"./devices-D4k34mru.js";import{a as N2}from"./schemas-BEt-CulV.js";import{E as Ne,A as k2,K as S2}from"./method-access-map-BFPyQ2-G.js";import{s as C2}from"./index-BGZqVJZt.js";import{a as Tu,C as hm,S as Lu,s as M2}from"./index-KlKJOjpC.js";import{r as mm}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-CSyOECfO.js";import{_ as E2}from"./preload-helper-BlTxHScW.js";import"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-xw6c6JeS.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"]'))r(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"&&r(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 r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();const gm={frigate:"#3b82f6",scrypted:"#a855f7",reolink:"#06b6d4",homeAssistant:"#22d3ee",rtsp:"#78716c"},bm={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:gm},xm={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:gm},Sl={colors:{dark:bm,light:xm},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 ym(e,t){const n={...e};for(const r in t){const s=t[r],a=e[r];s!==void 0&&typeof s=="object"&&s!==null&&!Array.isArray(s)&&typeof a=="object"&&a!==null?n[r]=ym(a,s):s!==void 0&&(n[r]=s)}return n}function I2(e){return e?ym(structuredClone(Sl),e):structuredClone(Sl)}function vm(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function A2(e){return`--color-${vm(e)}`}function Ru(e){const t=[];for(const[n,r]of Object.entries(e))n!=="provider"&&t.push(` ${A2(n)}: ${r};`);return t.join(`
|
|
2
|
-
`)}function P2(e){const t=[];for(const[n,r]of Object.entries(e))t.push(` --color-provider-${vm(n)}: ${r};`);return t.join(`
|
|
3
|
-
`)}function _2(e){const t=[];for(const[n,r]of Object.entries(e))t.push(` --spacing-${n}: ${r}px;`);return t.join(`
|
|
4
|
-
`)}function $2(e){const t=[];for(const[n,r]of Object.entries(e))t.push(` --radius-${n}: ${r}px;`);return t.join(`
|
|
5
|
-
`)}function D2(e){const t=Ru(e.colors.dark),n=Ru(e.colors.light),r=P2(e.colors.dark.provider),s=_2(e.spacing),a=$2(e.radius);return`@theme {
|
|
6
|
-
${r}
|
|
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 wm=ze(null),vi=["dark","light","system"];function Nm(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function T2(e,t){if(typeof window>"u")return t;const n=localStorage.getItem(e);return n==="dark"||n==="light"||n==="system"?n:t}function Ou(e){return e==="system"?Nm():e}function Zs({children:e,defaultMode:t="system",storageKey:n="camstack-theme-mode"}){const[r,s]=_(()=>T2(n,t)),[a,i]=_(()=>Ou(r)),l=U(u=>{s(u),i(Ou(u)),typeof window<"u"&&localStorage.setItem(n,u)},[n]),c=U(()=>{const p=(vi.indexOf(r)+1)%vi.length;l(vi[p]??"dark")},[r,l]);Y(()=>{if(typeof document>"u")return;const u=document.documentElement;u.classList.remove("dark","light"),u.classList.add(a)},[r,a]),Y(()=>{if(typeof window>"u"||r!=="system")return;const u=window.matchMedia("(prefers-color-scheme: dark)"),p=()=>{i(Nm())};return u.addEventListener("change",p),()=>u.removeEventListener("change",p)},[r]);const d=H(()=>({mode:r,resolvedMode:a,setMode:l,toggleMode:c}),[r,a,l,c]);return o(wm.Provider,{value:d,children:e})}function Hr(){const e=ve(wm);if(!e)throw new Error("useThemeMode must be used within a ThemeProvider");return e}function km(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=km(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Sm(){for(var e,t,n=0,r="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=km(e))&&(r&&(r+=" "),r+=t);return r}const L2=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},R2=(e,t)=>({classGroupId:e,validator:t}),Cm=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Xs="-",Bu=[],O2="arbitrary..",B2=e=>{const t=F2(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return z2(i);const l=i.split(Xs),c=l[0]===""&&l.length>1?1:0;return Mm(l,c,t)},getConflictingClassGroupIds:(i,l)=>{if(l){const c=r[i],d=n[i];return c?d?L2(d,c):c:d||Bu}return n[i]||Bu}}},Mm=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const s=e[t],a=n.nextPart.get(s);if(a){const d=Mm(e,t+1,a);if(d)return d}const i=n.validators;if(i===null)return;const l=t===0?e.join(Xs):e.slice(t).join(Xs),c=i.length;for(let d=0;d<c;d++){const u=i[d];if(u.validator(l))return u.classGroupId}},z2=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?O2+r:void 0})(),F2=e=>{const{theme:t,classGroups:n}=e;return j2(n,t)},j2=(e,t)=>{const n=Cm();for(const r in e){const s=e[r];Cc(s,n,r,t)}return n},Cc=(e,t,n,r)=>{const s=e.length;for(let a=0;a<s;a++){const i=e[a];V2(i,t,n,r)}},V2=(e,t,n,r)=>{if(typeof e=="string"){H2(e,t,n);return}if(typeof e=="function"){q2(e,t,n,r);return}U2(e,t,n,r)},H2=(e,t,n)=>{const r=e===""?t:Em(t,e);r.classGroupId=n},q2=(e,t,n,r)=>{if(Q2(e)){Cc(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(R2(n,e))},U2=(e,t,n,r)=>{const s=Object.entries(e),a=s.length;for(let i=0;i<a;i++){const[l,c]=s[i];Cc(c,Em(t,l),n,r)}},Em=(e,t)=>{let n=e;const r=t.split(Xs),s=r.length;for(let a=0;a<s;a++){const i=r[a];let l=n.nextPart.get(i);l||(l=Cm(),n.nextPart.set(i,l)),n=l}return n},Q2=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,G2=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const s=(a,i)=>{n[a]=i,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(a){let i=n[a];if(i!==void 0)return i;if((i=r[a])!==void 0)return s(a,i),i},set(a,i){a in n?n[a]=i:s(a,i)}}},Cl="!",zu=":",K2=[],Fu=(e,t,n,r,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:s}),W2=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=s=>{const a=[];let i=0,l=0,c=0,d;const u=s.length;for(let b=0;b<u;b++){const x=s[b];if(i===0&&l===0){if(x===zu){a.push(s.slice(c,b)),c=b+1;continue}if(x==="/"){d=b;continue}}x==="["?i++:x==="]"?i--:x==="("?l++:x===")"&&l--}const p=a.length===0?s:s.slice(c);let h=p,m=!1;p.endsWith(Cl)?(h=p.slice(0,-1),m=!0):p.startsWith(Cl)&&(h=p.slice(1),m=!0);const g=d&&d>c?d-c:void 0;return Fu(a,m,h,g)};if(t){const s=t+zu,a=r;r=i=>i.startsWith(s)?a(i.slice(s.length)):Fu(K2,!1,i,void 0,!0)}if(n){const s=r;r=a=>n({className:a,parseClassName:s})}return r},Y2=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];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(),r.push(...s),s=[]),r.push(i)):s.push(i)}return s.length>0&&(s.sort(),r.push(...s)),r}},Z2=e=>({cache:G2(e.cacheSize),parseClassName:W2(e),sortModifiers:Y2(e),...B2(e)}),X2=/\s+/,J2=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:a}=t,i=[],l=e.trim().split(X2);let c="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:p,modifiers:h,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:b}=n(u);if(p){c=u+(c.length>0?" "+c:c);continue}let x=!!b,y=r(x?g.substring(0,b):g);if(!y){if(!x){c=u+(c.length>0?" "+c:c);continue}if(y=r(g),!y){c=u+(c.length>0?" "+c:c);continue}x=!1}const w=h.length===0?"":h.length===1?h[0]:a(h).join(":"),v=m?w+Cl:w,N=v+y;if(i.indexOf(N)>-1)continue;i.push(N);const k=s(y,x);for(let C=0;C<k.length;++C){const E=k[C];i.push(v+E)}c=u+(c.length>0?" "+c:c)}return c},ek=(...e)=>{let t=0,n,r,s="";for(;t<e.length;)(n=e[t++])&&(r=Im(n))&&(s&&(s+=" "),s+=r);return s},Im=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Im(e[r]))&&(n&&(n+=" "),n+=t);return n},tk=(e,...t)=>{let n,r,s,a;const i=c=>{const d=t.reduce((u,p)=>p(u),e());return n=Z2(d),r=n.cache.get,s=n.cache.set,a=l,l(c)},l=c=>{const d=r(c);if(d)return d;const u=J2(c,n);return s(c,u),u};return a=i,(...c)=>a(ek(...c))},nk=[],Ye=e=>{const t=n=>n[e]||nk;return t.isThemeGetter=!0,t},Am=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Pm=/^\((?:(\w[\w-]*):)?(.+)\)$/i,rk=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ok=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,sk=/\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$/,ak=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ik=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,lk=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,kn=e=>rk.test(e),Ie=e=>!!e&&!Number.isNaN(Number(e)),Sn=e=>!!e&&Number.isInteger(Number(e)),wi=e=>e.endsWith("%")&&Ie(e.slice(0,-1)),on=e=>ok.test(e),_m=()=>!0,ck=e=>sk.test(e)&&!ak.test(e),Mc=()=>!1,dk=e=>ik.test(e),uk=e=>lk.test(e),pk=e=>!xe(e)&&!ye(e),fk=e=>Rn(e,Tm,Mc),xe=e=>Am.test(e),Vn=e=>Rn(e,Lm,ck),ju=e=>Rn(e,wk,Ie),hk=e=>Rn(e,Om,_m),mk=e=>Rn(e,Rm,Mc),Vu=e=>Rn(e,$m,Mc),gk=e=>Rn(e,Dm,uk),ds=e=>Rn(e,Bm,dk),ye=e=>Pm.test(e),oo=e=>dr(e,Lm),bk=e=>dr(e,Rm),Hu=e=>dr(e,$m),xk=e=>dr(e,Tm),yk=e=>dr(e,Dm),us=e=>dr(e,Bm,!0),vk=e=>dr(e,Om,!0),Rn=(e,t,n)=>{const r=Am.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},dr=(e,t,n=!1)=>{const r=Pm.exec(e);return r?r[1]?t(r[1]):n:!1},$m=e=>e==="position"||e==="percentage",Dm=e=>e==="image"||e==="url",Tm=e=>e==="length"||e==="size"||e==="bg-size",Lm=e=>e==="length",wk=e=>e==="number",Rm=e=>e==="family-name",Om=e=>e==="number"||e==="weight",Bm=e=>e==="shadow",Nk=()=>{const e=Ye("color"),t=Ye("font"),n=Ye("text"),r=Ye("font-weight"),s=Ye("tracking"),a=Ye("leading"),i=Ye("breakpoint"),l=Ye("container"),c=Ye("spacing"),d=Ye("radius"),u=Ye("shadow"),p=Ye("inset-shadow"),h=Ye("text-shadow"),m=Ye("drop-shadow"),g=Ye("blur"),b=Ye("perspective"),x=Ye("aspect"),y=Ye("ease"),w=Ye("animate"),v=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],k=()=>[...N(),ye,xe],C=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto","contain","none"],I=()=>[ye,xe,c],A=()=>[kn,"full","auto",...I()],z=()=>[Sn,"none","subgrid",ye,xe],P=()=>["auto",{span:["full",Sn,ye,xe]},Sn,ye,xe],B=()=>[Sn,"auto",ye,xe],R=()=>["auto","min","max","fr",ye,xe],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],D=()=>["start","end","center","stretch","center-safe","end-safe"],T=()=>["auto",...I()],L=()=>[kn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...I()],O=()=>[kn,"screen","full","dvw","lvw","svw","min","max","fit",...I()],F=()=>[kn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...I()],j=()=>[e,ye,xe],V=()=>[...N(),Hu,Vu,{position:[ye,xe]}],$=()=>["no-repeat",{repeat:["","x","y","space","round"]}],q=()=>["auto","cover","contain",xk,fk,{size:[ye,xe]}],G=()=>[wi,oo,Vn],Z=()=>["","none","full",d,ye,xe],oe=()=>["",Ie,oo,Vn],ne=()=>["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"],re=()=>[Ie,wi,Hu,Vu],be=()=>["","none",g,ye,xe],J=()=>["none",Ie,ye,xe],W=()=>["none",Ie,ye,xe],ee=()=>[Ie,ye,xe],ae=()=>[kn,"full",...I()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[on],breakpoint:[on],color:[_m],container:[on],"drop-shadow":[on],ease:["in","out","in-out"],font:[pk],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[on],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[on],shadow:[on],spacing:["px",Ie],text:[on],"text-shadow":[on],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",kn,xe,ye,x]}],container:["container"],columns:[{columns:[Ie,xe,ye,l]}],"break-after":[{"break-after":v()}],"break-before":[{"break-before":v()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:k()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{"inset-s":A(),start:A()}],end:[{"inset-e":A(),end:A()}],"inset-bs":[{"inset-bs":A()}],"inset-be":[{"inset-be":A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[Sn,"auto",ye,xe]}],basis:[{basis:[kn,"full","auto",l,...I()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ie,kn,"auto","initial","none",xe]}],grow:[{grow:["",Ie,ye,xe]}],shrink:[{shrink:["",Ie,ye,xe]}],order:[{order:[Sn,"first","last","none",ye,xe]}],"grid-cols":[{"grid-cols":z()}],"col-start-end":[{col:P()}],"col-start":[{"col-start":B()}],"col-end":[{"col-end":B()}],"grid-rows":[{"grid-rows":z()}],"row-start-end":[{row:P()}],"row-start":[{"row-start":B()}],"row-end":[{"row-end":B()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:I()}],"gap-x":[{"gap-x":I()}],"gap-y":[{"gap-y":I()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...D(),"normal"]}],"justify-self":[{"justify-self":["auto",...D()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...D(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...D(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...D(),"baseline"]}],"place-self":[{"place-self":["auto",...D()]}],p:[{p:I()}],px:[{px:I()}],py:[{py:I()}],ps:[{ps:I()}],pe:[{pe:I()}],pbs:[{pbs:I()}],pbe:[{pbe:I()}],pt:[{pt:I()}],pr:[{pr:I()}],pb:[{pb:I()}],pl:[{pl:I()}],m:[{m:T()}],mx:[{mx:T()}],my:[{my:T()}],ms:[{ms:T()}],me:[{me:T()}],mbs:[{mbs:T()}],mbe:[{mbe:T()}],mt:[{mt:T()}],mr:[{mr:T()}],mb:[{mb:T()}],ml:[{ml:T()}],"space-x":[{"space-x":I()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":I()}],"space-y-reverse":["space-y-reverse"],size:[{size:L()}],"inline-size":[{inline:["auto",...O()]}],"min-inline-size":[{"min-inline":["auto",...O()]}],"max-inline-size":[{"max-inline":["none",...O()]}],"block-size":[{block:["auto",...F()]}],"min-block-size":[{"min-block":["auto",...F()]}],"max-block-size":[{"max-block":["none",...F()]}],w:[{w:[l,"screen",...L()]}],"min-w":[{"min-w":[l,"screen","none",...L()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...L()]}],h:[{h:["screen","lh",...L()]}],"min-h":[{"min-h":["screen","lh","none",...L()]}],"max-h":[{"max-h":["screen","lh",...L()]}],"font-size":[{text:["base",n,oo,Vn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,vk,hk]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",wi,xe]}],"font-family":[{font:[bk,mk,t]}],"font-features":[{"font-features":[xe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,ye,xe]}],"line-clamp":[{"line-clamp":[Ie,"none",ye,ju]}],leading:[{leading:[a,...I()]}],"list-image":[{"list-image":["none",ye,xe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ye,xe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:j()}],"text-color":[{text:j()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ie,"from-font","auto",ye,Vn]}],"text-decoration-color":[{decoration:j()}],"underline-offset":[{"underline-offset":[Ie,"auto",ye,xe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ye,xe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ye,xe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:V()}],"bg-repeat":[{bg:$()}],"bg-size":[{bg:q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Sn,ye,xe],radial:["",ye,xe],conic:[Sn,ye,xe]},yk,gk]}],"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:Z()}],"rounded-s":[{"rounded-s":Z()}],"rounded-e":[{"rounded-e":Z()}],"rounded-t":[{"rounded-t":Z()}],"rounded-r":[{"rounded-r":Z()}],"rounded-b":[{"rounded-b":Z()}],"rounded-l":[{"rounded-l":Z()}],"rounded-ss":[{"rounded-ss":Z()}],"rounded-se":[{"rounded-se":Z()}],"rounded-ee":[{"rounded-ee":Z()}],"rounded-es":[{"rounded-es":Z()}],"rounded-tl":[{"rounded-tl":Z()}],"rounded-tr":[{"rounded-tr":Z()}],"rounded-br":[{"rounded-br":Z()}],"rounded-bl":[{"rounded-bl":Z()}],"border-w":[{border:oe()}],"border-w-x":[{"border-x":oe()}],"border-w-y":[{"border-y":oe()}],"border-w-s":[{"border-s":oe()}],"border-w-e":[{"border-e":oe()}],"border-w-bs":[{"border-bs":oe()}],"border-w-be":[{"border-be":oe()}],"border-w-t":[{"border-t":oe()}],"border-w-r":[{"border-r":oe()}],"border-w-b":[{"border-b":oe()}],"border-w-l":[{"border-l":oe()}],"divide-x":[{"divide-x":oe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":oe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ne(),"hidden","none"]}],"divide-style":[{divide:[...ne(),"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:[...ne(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ie,ye,xe]}],"outline-w":[{outline:["",Ie,oo,Vn]}],"outline-color":[{outline:j()}],shadow:[{shadow:["","none",u,us,ds]}],"shadow-color":[{shadow:j()}],"inset-shadow":[{"inset-shadow":["none",p,us,ds]}],"inset-shadow-color":[{"inset-shadow":j()}],"ring-w":[{ring:oe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:j()}],"ring-offset-w":[{"ring-offset":[Ie,Vn]}],"ring-offset-color":[{"ring-offset":j()}],"inset-ring-w":[{"inset-ring":oe()}],"inset-ring-color":[{"inset-ring":j()}],"text-shadow":[{"text-shadow":["none",h,us,ds]}],"text-shadow-color":[{"text-shadow":j()}],opacity:[{opacity:[Ie,ye,xe]}],"mix-blend":[{"mix-blend":[...X(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":X()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ie]}],"mask-image-linear-from-pos":[{"mask-linear-from":re()}],"mask-image-linear-to-pos":[{"mask-linear-to":re()}],"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":re()}],"mask-image-t-to-pos":[{"mask-t-to":re()}],"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":re()}],"mask-image-r-to-pos":[{"mask-r-to":re()}],"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":re()}],"mask-image-b-to-pos":[{"mask-b-to":re()}],"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":re()}],"mask-image-l-to-pos":[{"mask-l-to":re()}],"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":re()}],"mask-image-x-to-pos":[{"mask-x-to":re()}],"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":re()}],"mask-image-y-to-pos":[{"mask-y-to":re()}],"mask-image-y-from-color":[{"mask-y-from":j()}],"mask-image-y-to-color":[{"mask-y-to":j()}],"mask-image-radial":[{"mask-radial":[ye,xe]}],"mask-image-radial-from-pos":[{"mask-radial-from":re()}],"mask-image-radial-to-pos":[{"mask-radial-to":re()}],"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":[Ie]}],"mask-image-conic-from-pos":[{"mask-conic-from":re()}],"mask-image-conic-to-pos":[{"mask-conic-to":re()}],"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:V()}],"mask-repeat":[{mask:$()}],"mask-size":[{mask:q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ye,xe]}],filter:[{filter:["","none",ye,xe]}],blur:[{blur:be()}],brightness:[{brightness:[Ie,ye,xe]}],contrast:[{contrast:[Ie,ye,xe]}],"drop-shadow":[{"drop-shadow":["","none",m,us,ds]}],"drop-shadow-color":[{"drop-shadow":j()}],grayscale:[{grayscale:["",Ie,ye,xe]}],"hue-rotate":[{"hue-rotate":[Ie,ye,xe]}],invert:[{invert:["",Ie,ye,xe]}],saturate:[{saturate:[Ie,ye,xe]}],sepia:[{sepia:["",Ie,ye,xe]}],"backdrop-filter":[{"backdrop-filter":["","none",ye,xe]}],"backdrop-blur":[{"backdrop-blur":be()}],"backdrop-brightness":[{"backdrop-brightness":[Ie,ye,xe]}],"backdrop-contrast":[{"backdrop-contrast":[Ie,ye,xe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ie,ye,xe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ie,ye,xe]}],"backdrop-invert":[{"backdrop-invert":["",Ie,ye,xe]}],"backdrop-opacity":[{"backdrop-opacity":[Ie,ye,xe]}],"backdrop-saturate":[{"backdrop-saturate":[Ie,ye,xe]}],"backdrop-sepia":[{"backdrop-sepia":["",Ie,ye,xe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":I()}],"border-spacing-x":[{"border-spacing-x":I()}],"border-spacing-y":[{"border-spacing-y":I()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ye,xe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ie,"initial",ye,xe]}],ease:[{ease:["linear","initial",y,ye,xe]}],delay:[{delay:[Ie,ye,xe]}],animate:[{animate:["none",w,ye,xe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,ye,xe]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:J()}],"rotate-x":[{"rotate-x":J()}],"rotate-y":[{"rotate-y":J()}],"rotate-z":[{"rotate-z":J()}],scale:[{scale:W()}],"scale-x":[{"scale-x":W()}],"scale-y":[{"scale-y":W()}],"scale-z":[{"scale-z":W()}],"scale-3d":["scale-3d"],skew:[{skew:ee()}],"skew-x":[{"skew-x":ee()}],"skew-y":[{"skew-y":ee()}],transform:[{transform:[ye,xe,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ae()}],"translate-x":[{"translate-x":ae()}],"translate-y":[{"translate-y":ae()}],"translate-z":[{"translate-z":ae()}],"translate-none":["translate-none"],accent:[{accent:j()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:j()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ye,xe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mbs":[{"scroll-mbs":I()}],"scroll-mbe":[{"scroll-mbe":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pbs":[{"scroll-pbs":I()}],"scroll-pbe":[{"scroll-pbe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ye,xe]}],fill:[{fill:["none",...j()]}],"stroke-w":[{stroke:[Ie,oo,Vn,ju]}],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"]}},kk=tk(Nk);function K(...e){return kk(Sm(e))}const Sk="rounded-lg border border-border bg-surface overflow-hidden",Ck="border-b border-border px-3 sm:px-4 py-1.5 sm:py-2",Mk="p-2 sm:p-3 lg:p-4",zm="space-y-3 sm:space-y-4",Fm="gap-2 sm:gap-3",jm="px-3 sm:px-4 py-1.5 sm:py-2",Ek="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4",Ik="grid grid-cols-1 lg:grid-cols-2",Ak="flex flex-col-reverse md:flex-row",Pk="w-full md:w-44 lg:w-52 md:flex-shrink-0 border-b md:border-b-0 md:border-l border-border",_k="text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider",$k="text-[11px] sm:text-xs text-foreground",Js="text-[10px] text-foreground-subtle",Dk="text-[11px] sm:text-xs font-medium text-foreground",Ml="text-base sm:text-lg font-semibold leading-tight text-foreground",Tk="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",Lk="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",Rk="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",Ok="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",Bk="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",zk="inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors",Fk="border-primary/50 bg-primary/15 text-primary",jk="border-border bg-surface text-foreground-subtle hover:bg-surface-hover";function Vk(e,t){for(const n of e.slots)for(const r of n.addons)if(r.id===t)return r;return null}function Hk(e,t){return e.models.find(n=>n.id===t)??null}function qk(e,t){return e.models.find(n=>!!n.formats[t])??null}function Uk(e,t){const n=new Set((t.configSchema??[]).map(s=>s.key)),r={};for(const[s,a]of Object.entries(e))n.has(s)&&(r[s]=a);return r}function Vm(e){const{source:t,target:n,catalog:r,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=Vk(r,i);if(!c){a.push({addonId:i,outcome:"skip",modelId:null,reason:"addon not in target catalog",patch:null});continue}const d=Hk(c,l.modelId),u=d!==null&&!!d.formats[n.engine.format];let p,h;if(u)p=l.modelId,h="exact";else{const g=qk(c,n.engine.format);if(!g){a.push({addonId:i,outcome:"skip",modelId:null,reason:"no compatible model for target format",patch:null});continue}p=g.id,h="mapped"}const m={enabled:l.enabled,modelId:p,settings:Uk(l.settings,c)};a.push({addonId:i,outcome:h,modelId:p,patch:m})}return a}const El={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 ur(e){return El[e]??El.watching}function xn(e,t){if(typeof globalThis>"u")return ze(t);const n=globalThis.__camstackSharedContexts,r=n??new Map;n||(globalThis.__camstackSharedContexts=r);const s=r.get(e);if(s)return s;const a=ze(t);return r.set(e,a),a}function Er(e){const n=(typeof globalThis<"u"?globalThis:void 0)?.[e];return n&&typeof n=="object"?n:{}}const Qk={singleton:!0,requiredVersion:!1,eager:!0},qt=e=>({version:"0.0.0",scope:"default",lib:e,shareConfig:Qk}),qu="__mf_module_cache__";function Gk(){const e=globalThis,t=e[qu];if(t&&typeof t=="object"){const r=t;return r.share??={},r.remote??={},r}const n={share:{},remote:{}};return e[qu]=n,n}function Kk(){const e=Gk();e.share.react??=em,e.share["react-dom"]??=tm,e.share["react-dom/client"]??=nm,e.share["react/jsx-runtime"]??=Jh,e.share["@tanstack/react-query"]??=om,e.share["@trpc/client"]??=im,e.share["@trpc/react-query"]??=dm,e.share["@camstack/ui-library"]??=Er("__camstackUiLibrary"),e.share["@camstack/sdk"]??=Er("__camstackSdk"),e.share["@camstack/types"]??=Er("__camstackTypes")}function Ec(){Kk(),_r.getInstance()===null&&_r.init({name:"admin_ui_host",remotes:[],shared:{react:qt(()=>em),"react-dom":qt(()=>tm),"react-dom/client":qt(()=>nm),"react/jsx-runtime":qt(()=>Jh),"@tanstack/react-query":qt(()=>om),"@trpc/client":qt(()=>im),"@trpc/react-query":qt(()=>dm),"@camstack/ui-library":qt(()=>Er("__camstackUiLibrary")),"@camstack/sdk":qt(()=>Er("__camstackSdk")),"@camstack/types":qt(()=>Er("__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 Hm=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.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 Wk=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 Yk=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.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 Uu=e=>{const t=Yk(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 Zk={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 Xk=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 Jk=Ue(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:i,...l},c)=>Ee("svg",{ref:c,...Zk,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Hm("lucide",s),...!a&&!Xk(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,u])=>Ee(d,u)),...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 ie=(e,t)=>{const n=Ue(({className:r,...s},a)=>Ee(Jk,{ref:a,iconNode:t,className:Hm(`lucide-${Wk(Uu(e))}`,`lucide-${e}`,r),...s}));return n.displayName=Uu(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 e5=[["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"}]],In=ie("activity",e5);/**
|
|
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 t5=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],n5=ie("arrow-down",t5);/**
|
|
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 r5=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],o5=ie("arrow-left",r5);/**
|
|
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 s5=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],a5=ie("arrow-right",s5);/**
|
|
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 i5=[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]],Ic=ie("arrow-up-to-line",i5);/**
|
|
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 l5=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],c5=ie("arrow-up",l5);/**
|
|
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 d5=[["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"}]],u5=ie("battery-full",d5);/**
|
|
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 p5=[["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"}]],f5=ie("battery-low",p5);/**
|
|
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 h5=[["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"}]],m5=ie("battery-warning",h5);/**
|
|
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 g5=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],qm=ie("battery",g5);/**
|
|
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 b5=[["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"}]],x5=ie("bell-ring",b5);/**
|
|
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 y5=[["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"}]],_a=ie("bell",y5);/**
|
|
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 v5=[["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"}]],w5=ie("bug",v5);/**
|
|
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 N5=[["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=ie("camera",N5);/**
|
|
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 k5=[["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"}]],S5=ie("cast",k5);/**
|
|
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 C5=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],qr=ie("check",C5);/**
|
|
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 M5=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],pr=ie("chevron-down",M5);/**
|
|
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 E5=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],I5=ie("chevron-left",E5);/**
|
|
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 A5=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],On=ie("chevron-right",A5);/**
|
|
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 P5=[["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"}]],Uo=ie("circle-alert",P5);/**
|
|
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 _5=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],$5=ie("circle-check-big",_5);/**
|
|
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 D5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],T5=ie("circle-check",D5);/**
|
|
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 L5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],R5=ie("circle-dot",L5);/**
|
|
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 O5=[["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"}]],B5=ie("circle-pause",O5);/**
|
|
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 z5=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],F5=ie("circle-plus",z5);/**
|
|
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 j5=[["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"}]],Um=ie("circle-question-mark",j5);/**
|
|
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 V5=[["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"}]],H5=ie("circle-x",V5);/**
|
|
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 q5=[["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"}]],U5=ie("copy-plus",q5);/**
|
|
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 Q5=[["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"}]],yn=ie("copy",Q5);/**
|
|
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 G5=[["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"}]],K5=ie("cpu",G5);/**
|
|
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 W5=[["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"}]],Qm=ie("crosshair",W5);/**
|
|
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 Y5=[["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"}]],Z5=ie("database",Y5);/**
|
|
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 X5=[["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"}]],Gm=ie("door-open",X5);/**
|
|
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 J5=[["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"}]],Il=ie("download",J5);/**
|
|
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 eS=[["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"}]],Km=ie("ellipsis-vertical",eS);/**
|
|
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 tS=[["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"}]],Pc=ie("external-link",tS);/**
|
|
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 nS=[["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"}]],_c=ie("eye-off",nS);/**
|
|
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 rS=[["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"}]],Ur=ie("eye",rS);/**
|
|
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 oS=[["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"}]],Wm=ie("funnel",oS);/**
|
|
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 sS=[["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"}]],aS=ie("grip-horizontal",sS);/**
|
|
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 iS=[["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"}]],Ym=ie("house",iS);/**
|
|
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 lS=[["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"}]],cS=ie("image",lS);/**
|
|
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 dS=[["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"}]],uS=ie("inbox",dS);/**
|
|
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 pS=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],fS=ie("info",pS);/**
|
|
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 hS=[["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"}]],mS=ie("layout-grid",hS);/**
|
|
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 gS=[["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"}]],Zm=ie("lightbulb",gS);/**
|
|
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 bS=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ct=ie("loader-circle",bS);/**
|
|
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 xS=[["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"}]],yS=ie("locate-fixed",xS);/**
|
|
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 vS=[["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"}]],Qu=ie("maximize-2",vS);/**
|
|
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 wS=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],NS=ie("menu",wS);/**
|
|
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 kS=[["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"}]],Xm=ie("mic",kS);/**
|
|
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 SS=[["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=ie("minimize-2",SS);/**
|
|
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 CS=[["path",{d:"M5 12h14",key:"1ays0h"}]],Jm=ie("minus",CS);/**
|
|
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 MS=[["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"}]],$c=ie("moon",MS);/**
|
|
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 ES=[["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"}]],IS=ie("music",ES);/**
|
|
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 AS=[["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"}]],Al=ie("network",AS);/**
|
|
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 PS=[["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"}]],_S=ie("pencil",PS);/**
|
|
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 $S=[["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"}]],Pl=ie("play",$S);/**
|
|
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 DS=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Qo=ie("plus",DS);/**
|
|
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 TS=[["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"}]],LS=ie("plug",TS);/**
|
|
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 RS=[["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"}]],OS=ie("power-off",RS);/**
|
|
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 BS=[["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"}]],zS=ie("qr-code",BS);/**
|
|
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 FS=[["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"}]],eg=ie("radar",FS);/**
|
|
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 jS=[["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"}]],VS=ie("radio",jS);/**
|
|
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 HS=[["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"}]],$a=ie("refresh-cw",HS);/**
|
|
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 qS=[["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"}]],tg=ie("rotate-ccw",qS);/**
|
|
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 US=[["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"}]],ng=ie("rotate-cw",US);/**
|
|
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 QS=[["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"}]],GS=ie("save",QS);/**
|
|
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 KS=[["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"}]],WS=ie("scan",KS);/**
|
|
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 YS=[["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"}]],ZS=ie("scroll-text",YS);/**
|
|
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 XS=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Mo=ie("search",XS);/**
|
|
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 JS=[["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"}]],eC=ie("server",JS);/**
|
|
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 tC=[["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"}]],Ku=ie("share-2",tC);/**
|
|
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 nC=[["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"}]],rC=ie("shield",nC);/**
|
|
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 oC=[["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"}]],sC=ie("ship",oC);/**
|
|
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 aC=[["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"}]],iC=ie("sliders-horizontal",aC);/**
|
|
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 lC=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Wu=ie("square",lC);/**
|
|
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 cC=[["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"}]],dC=ie("star",cC);/**
|
|
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 uC=[["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"}]],rg=ie("sun",uC);/**
|
|
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 pC=[["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"}]],fC=ie("table-2",pC);/**
|
|
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 hC=[["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=ie("target",hC);/**
|
|
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 mC=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],gC=ie("thermometer",mC);/**
|
|
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 bC=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],xC=ie("toggle-left",bC);/**
|
|
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 yC=[["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"}]],Zt=ie("trash-2",yC);/**
|
|
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 vC=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],wC=ie("trending-up",vC);/**
|
|
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 NC=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],kC=ie("trending-down",NC);/**
|
|
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 SC=[["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"}]],Qr=ie("triangle-alert",SC);/**
|
|
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 CC=[["path",{d:"M15 7h2a5 5 0 0 1 0 10h-2m-6 0H7A5 5 0 0 1 7 7h2",key:"1re2ne"}]],MC=ie("unlink-2",CC);/**
|
|
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 EC=[["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"}]],og=ie("upload",EC);/**
|
|
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 IC=[["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"}]],AC=ie("wifi-off",IC);/**
|
|
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 PC=[["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"}]],sg=ie("wifi",PC);/**
|
|
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 _C=[["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"}]],Dc=ie("wrench",_C);/**
|
|
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 $C=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Je=ie("x",$C);/**
|
|
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 DC=[["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"}]],Zu=ie("zap",DC);/**
|
|
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 TC=[["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"}]],LC=ie("zoom-in",TC);/**
|
|
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 RC=[["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"}]],OC=ie("zoom-out",RC),BC={frigate:sC,scrypted:rC,reolink:VS,homeAssistant:Ym,rtsp:S5},zC={online:T5,offline:H5,degraded:Uo,unknown:Um},Xu=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ju=Sm,fr=(e,t)=>n=>{var r;if(t?.variants==null)return Ju(e,n?.class,n?.className);const{variants:s,defaultVariants:a}=t,i=Object.keys(s).map(d=>{const u=n?.[d],p=a?.[d];if(u===null)return null;const h=Xu(u)||Xu(p);return s[d][h]}),l=n&&Object.entries(n).reduce((d,u)=>{let[p,h]=u;return h===void 0||(d[p]=h),d},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,u)=>{let{class:p,className:h,...m}=u;return Object.entries(m).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...a,...l}[b]):{...a,...l}[b]===x})?[...d,p,h]:d},[]);return Ju(e,i,c,n?.class,n?.className)},FC=fr("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"}}),Be=Ue(({className:e,variant:t,size:n,...r},s)=>o("button",{ref:s,className:K(FC({variant:t,size:n}),e),...r}));Be.displayName="Button";const jC=fr("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"}}),Tc=Ue(({className:e,variant:t,size:n,icon:r,...s},a)=>o("button",{ref:a,className:K(jC({variant:t,size:n}),e),...s,children:o(r,{className:"h-4 w-4"})}));Tc.displayName="IconButton";const VC=fr("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"}}),zt=Ue(({className:e,variant:t,style:n,...r},s)=>o("span",{ref:s,className:K(VC({variant:t,styleVariant:n}),e),...r}));zt.displayName="Badge";const HC=fr("rounded-lg p-3",{variants:{variant:{flat:"bg-surface",bordered:"bg-surface border border-border"}},defaultVariants:{variant:"bordered"}}),un=Ue(({className:e,variant:t,...n},r)=>o("div",{ref:r,className:K(HC({variant:t}),e),...n}));un.displayName="Card";function ag({expanded:e,onExpandedChange:t,header:n,children:r,dimmed:s=!1,hideChevron:a=!1,className:i}){return f("div",{className:K("rounded-lg border border-border bg-surface overflow-hidden",s&&"opacity-[0.45]",i),children:[f("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&&o("span",{className:"text-foreground-subtle shrink-0",children:e?o(pr,{className:"h-4 w-4"}):o(On,{className:"h-4 w-4"})}),n]}),e&&r&&o("div",{className:"border-t border-border px-3 py-3",children:r})]})}const Lc=Ue(({className:e,...t},n)=>o("label",{ref:n,className:K("text-[10px] uppercase tracking-wider text-foreground-muted font-medium",e),...t}));Lc.displayName="Label";const qC=fr("",{variants:{orientation:{horizontal:"h-px w-full bg-border-subtle",vertical:"w-px h-full bg-border-subtle"}},defaultVariants:{orientation:"horizontal"}}),Rc=Ue(({className:e,orientation:t,...n},r)=>o("div",{ref:r,role:"separator",className:K(qC({orientation:t}),e),...n}));Rc.displayName="Separator";const ig=Ue(({className:e,...t},n)=>o("div",{ref:n,className:K("animate-pulse bg-surface-hover rounded-md h-4 w-full",e),...t}));ig.displayName="Skeleton";const ep=fr("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"}}),ea=Ue(({className:e,state:t,leftSlot:n,rightSlot:r,...s},a)=>n||r?f("div",{className:"relative flex items-center w-full",children:[n&&o("div",{className:"absolute left-2.5 flex items-center pointer-events-none",children:n}),o("input",{ref:a,className:K(ep({state:t}),n?"pl-7":"",r?"pr-7":"",e),...s}),r&&o("div",{className:"absolute right-2.5 flex items-center pointer-events-none",children:r})]}):o("input",{ref:a,className:K(ep({state:t}),e),...s}));ea.displayName="Input";const Eo=Ue(({className:e,options:t,...n},r)=>f("div",{className:"relative w-full",children:[o("select",{ref:r,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=>o("option",{value:s.value,children:s.label},s.value))}),o("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none text-foreground-muted",children:o(pr,{className:"h-3.5 w-3.5"})})]}));Eo.displayName="Select";const lg=Ue(({className:e,...t},n)=>o("input",{ref:n,type:"checkbox",className:K("w-3.5 h-3.5 rounded-sm border border-border accent-primary",e),...t}));lg.displayName="Checkbox";const Oc=Ue(({className:e,checked:t,onCheckedChange:n,label:r,...s},a)=>f("button",{ref:a,role:"switch","aria-checked":t,type:"button",onClick:()=>n(!t),className:K("inline-flex items-center gap-2",e),...s,children:[o("span",{className:K("w-8 h-4 rounded-full transition-colors",t?"bg-primary":"bg-surface-hover"),children:o("span",{className:K("block w-3.5 h-3.5 rounded-full bg-white transition-transform",t?"translate-x-4":"translate-x-0.5")})}),r&&o("span",{className:"text-xs text-foreground",children:r})]}));Oc.displayName="Switch";const cg=ze(null);function dg(){const e=ve(cg);if(!e)throw new Error("Dialog compound components must be used within <Dialog>");return e}function ug({children:e,open:t,onOpenChange:n}){const[r,s]=_(!1),a=t??r,i=Jn(),l=U(c=>{n?.(c),t===void 0&&s(c)},[t,n]);return o(cg.Provider,{value:{open:a,setOpen:l,contentId:i},children:e})}function UC({children:e,...t}){const{setOpen:n}=dg();return o("button",{type:"button",onClick:()=>n(!0),...t,children:e})}const QC=fr("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"}}),Bc=Ue(({className:e,width:t,children:n,...r},s)=>{const{open:a,setOpen:i,contentId:l}=dg(),c=te(null),d=s??c;Y(()=>{const p=d.current;p&&(a&&!p.open&&p.showModal(),!a&&p.open&&p.close())},[a,d]);const u=p=>{p.target===p.currentTarget&&i(!1)};return o("dialog",{ref:d,id:l,className:K(QC({width:t}),"w-full",e),onClick:u,onClose:()=>i(!1),...r,children:n})});Bc.displayName="DialogContent";function pg({className:e,...t}){return o("div",{className:K("flex flex-col gap-1 mb-3",e),...t})}function fg({className:e,...t}){return o("div",{className:K("flex justify-end gap-2 mt-4",e),...t})}function hg({className:e,...t}){return o("h2",{className:K("text-sm font-semibold text-foreground",e),...t})}function mg({className:e,...t}){return o("p",{className:K("text-xs text-foreground-muted",e),...t})}const gg=ze(null);function zc(){const e=ve(gg);if(!e)throw new Error("Dropdown compound components must be used within <Dropdown>");return e}function bg({children:e}){const[t,n]=_(!1),r=Jn(),s=Jn(),a=te(null);return o(gg.Provider,{value:{open:t,setOpen:n,triggerId:r,contentId:s,triggerRef:a},children:o("div",{className:"relative inline-block",children:e})})}function xg({children:e,...t}){const{open:n,setOpen:r,triggerId:s,contentId:a,triggerRef:i}=zc();return o("button",{type:"button",ref:i,id:s,"aria-haspopup":"menu","aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>r(!n),...t,children:e})}function yg({className:e,children:t,align:n="start",offset:r=4,...s}){const{open:a,setOpen:i,contentId:l,triggerId:c,triggerRef:d}=zc(),u=te(null),[p,h]=_(null);if(Aa(()=>{if(!a){h(null);return}const g=()=>{const b=d.current;if(!b)return;const x=b.getBoundingClientRect(),y=n==="end"?x.right:x.left;h({top:x.bottom+r,left:y,minWidth:x.width})};return g(),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0)}},[a,n,r,d]),Y(()=>{if(!a)return;const g=x=>{const y=u.current,w=d.current;y&&!y.contains(x.target)&&!w?.contains(x.target)&&i(!1)},b=x=>{x.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",b)}},[a,i,d]),!a||!p||typeof document>"u")return null;const m={position:"fixed",top:p.top,...n==="end"?{right:window.innerWidth-p.left}:{left:p.left},minWidth:p.minWidth};return qo(o("div",{ref:u,id:l,role:"menu","aria-labelledby":c,style:m,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 vg({className:e,icon:t,variant:n="default",children:r,onClick:s,...a}){const{setOpen:i}=zc(),l=U(c=>{s?.(c),i(!1)},[s,i]);return f("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&&o(t,{size:14}),r]})}const wg=ze(null);function Ng(){const e=ve(wg);if(!e)throw new Error("Tooltip compound components must be used within <Tooltip>");return e}function GC({children:e}){const[t,n]=_(!1),r=te(null),s=Jn(),a=()=>{r.current=setTimeout(()=>n(!0),300)},i=()=>{r.current&&clearTimeout(r.current),n(!1)};return o(wg.Provider,{value:{open:t,show:a,hide:i,tooltipId:s},children:o("div",{className:"relative inline-block",children:e})})}function KC({children:e,...t}){const{show:n,hide:r,tooltipId:s,open:a}=Ng();return o("div",{onMouseEnter:n,onMouseLeave:r,onFocus:n,onBlur:r,"aria-describedby":a?s:void 0,...t,children:e})}function WC({className:e,children:t,...n}){const{open:r,tooltipId:s}=Ng();return o("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",r?"opacity-100":"opacity-0",e),...n,children:t})}const tp="(max-width: 767px)",np="(min-width: 768px) and (max-width: 1023px)";function kg(e){return t=>{const n=window.matchMedia(e);return n.addEventListener("change",t),()=>n.removeEventListener("change",t)}}function Sg(e){return()=>window.matchMedia(e).matches}function Cg(){return!1}function hr(){return Pa(kg(tp),Sg(tp),Cg)}function Mg(){return Pa(kg(np),Sg(np),Cg)}function Fc({open:e,onClose:t,title:n,children:r,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]),f(me,{children:[o("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"}),f("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:[o("div",{className:"flex justify-center pt-2 pb-1",children:o("div",{className:"h-1 w-8 rounded-full bg-foreground-subtle/30"})}),n&&f("div",{className:"flex items-center justify-between px-4 pb-2",children:[o("span",{className:"text-sm font-medium text-foreground",children:n}),o("button",{onClick:t,className:"p-1 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors",children:o(Je,{className:"h-4 w-4"})})]}),o("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:r})]})]})}const Eg=ze(null);function Ig(){const e=ve(Eg);if(!e)throw new Error("Popover compound components must be used within <Popover>");return e}function Ag({children:e,open:t,onOpenChange:n}){const[r,s]=_(!1),a=t??r,i=Jn(),l=Jn(),c=U(d=>{n?.(d),t===void 0&&s(d)},[t,n]);return o(Eg.Provider,{value:{open:a,setOpen:c,triggerId:i,contentId:l},children:o("div",{className:"relative inline-block",children:e})})}function Pg({children:e,...t}){const{open:n,setOpen:r,triggerId:s,contentId:a}=Ig();return o("button",{type:"button",id:s,"aria-haspopup":"dialog","aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>r(!n),...t,children:e})}function _g({className:e,children:t,...n}){const{open:r,setOpen:s,contentId:a,triggerId:i}=Ig(),l=hr(),c=te(null);return Y(()=>{if(!r||l)return;const d=p=>{const h=c.current,m=document.getElementById(i);h&&!h.contains(p.target)&&!m?.contains(p.target)&&s(!1)},u=p=>{p.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",d),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",u)}},[r,s,i,l]),r?l?o(Fc,{open:r,onClose:()=>s(!1),children:t}):o("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 $g=ze(null);function Dg(){const e=ve($g);if(!e)throw new Error("Tabs compound components must be used within <Tabs>");return e}function YC({value:e,onValueChange:t,defaultValue:n="",className:r,...s}){const[a,i]=_(n),l=e??a,c=U(d=>{t?.(d),e===void 0&&i(d)},[e,t]);return o($g.Provider,{value:{value:l,setValue:c},children:o("div",{className:r,...s})})}function ZC({className:e,...t}){return o("div",{role:"tablist",className:K("flex flex-row border-b border-border-subtle",e),...t})}function XC({value:e,className:t,...n}){const{value:r,setValue:s}=Dg(),a=e===r,i=`tabpanel-${e}`;return o("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 JC({value:e,className:t,...n}){const{value:r}=Dg();return e!==r?null:o("div",{role:"tabpanel",id:`tabpanel-${e}`,className:K("pt-3",t),...n})}const jc=Ue(({className:e,...t},n)=>o("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}));jc.displayName="ScrollArea";function e3({title:e,onClose:t,children:n,defaultWidth:r=360,defaultHeight:s=280,minWidth:a=280,minHeight:i=160,offsetIndex:l=0,className:c}){const[d,u]=_({x:80+l*30,y:80+l*30}),[p,h]=_({w:r,h:s}),[m,g]=_(!1),b=te(!1),x=te(!1),y=te({x:0,y:0}),w=hr(),v=U(k=>{k.preventDefault(),b.current=!0,y.current={x:k.clientX-d.x,y:k.clientY-d.y}},[d]),N=U(k=>{k.preventDefault(),k.stopPropagation(),x.current=!0,y.current={x:k.clientX,y:k.clientY}},[]);return Y(()=>{const k=E=>{if(b.current&&u({x:E.clientX-y.current.x,y:E.clientY-y.current.y}),x.current){const I=E.clientX-y.current.x,A=E.clientY-y.current.y;y.current={x:E.clientX,y:E.clientY},h(z=>({w:Math.max(a,z.w+I),h:Math.max(i,z.h+A)}))}},C=()=>{b.current=!1,x.current=!1};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",C)}},[a,i]),w?f("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:[f("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border shrink-0 bg-surface",children:[o("span",{className:"text-[11px] font-medium truncate",children:e}),f("div",{className:"flex items-center gap-1 shrink-0",children:[o("button",{onClick:()=>g(!m),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",children:m?o(Qu,{size:12}):o(Gu,{size:12})}),o("button",{onClick:t,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",children:o(Je,{size:12})})]})]}),!m&&o("div",{className:"flex-1 min-h-0 overflow-y-auto",children:n})]}):f("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:m?280:p.w,height:m?"auto":p.h},children:[f("div",{onMouseDown:v,className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border cursor-move select-none shrink-0 bg-surface",children:[f("div",{className:"flex items-center gap-2 min-w-0",children:[o(aS,{size:12,className:"text-foreground-subtle shrink-0"}),o("span",{className:"text-[11px] font-medium truncate",children:e})]}),f("div",{className:"flex items-center gap-1 shrink-0",children:[o("button",{onClick:()=>g(!m),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",title:m?"Restore":"Minimize",children:m?o(Qu,{size:12}):o(Gu,{size:12})}),o("button",{onClick:t,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",title:"Close",children:o(Je,{size:12})})]})]}),!m&&f("div",{className:"flex-1 min-h-0 overflow-y-auto relative",children:[n,o("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:r,width:s="w-64"}){const a=te(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]),f(me,{children:[o("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"}),o("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",r),children:n})]})}function Hc({items:e,className:t}){return o("nav",{className:`flex items-center gap-1 text-[11px] text-foreground-subtle ${t??""}`,children:e.map((n,r)=>{const s=r===e.length-1,a=!s&&(n.onClick||n.href);return f(Ge.Fragment,{children:[r>0&&o(On,{className:"h-3 w-3 flex-shrink-0"}),a?n.onClick?o("button",{type:"button",onClick:n.onClick,className:"hover:text-foreground transition-colors",children:n.label}):o("a",{href:n.href,className:"hover:text-foreground transition-colors",children:n.label}):o("span",{className:s?"text-foreground font-medium":"",children:n.label})]},r)})})}const rp={left:"text-left",right:"text-right",center:"text-center"};function Da({columns:e,rows:t,rowKey:n,onRowClick:r,minWidthPx:s=480,emptyMessage:a,className:i,bordered:l=!0,rowClassName:c}){if(t.length===0&&a)return o("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 o("div",{className:d,children:f("table",{className:"w-full text-xs",style:{minWidth:`${s}px`},children:[o("thead",{className:"bg-surface",children:o("tr",{children:e.map(u=>{const p=u.align??"left",h=u.nowrap??!0;return o("th",{className:["px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border",rp[p],h?"whitespace-nowrap":"",u.width??""].filter(Boolean).join(" "),children:u.headerRender?u.headerRender():u.header},u.key)})})}),o("tbody",{children:t.map((u,p)=>{const h=n?n(u,p):p,m=c?.(u,p)??"",g=r!==void 0;return o("tr",{onClick:g?()=>r(u,p):void 0,className:[g?"cursor-pointer hover:bg-primary/5":"hover:bg-primary/5",m].filter(Boolean).join(" "),children:e.map(b=>{const x=b.align??"left",y=b.nowrap??!1;return o("td",{className:["px-3 py-2 text-foreground border-b border-border",rp[x],y?"whitespace-nowrap":""].filter(Boolean).join(" "),children:b.render(u,p)},b.key)})},h)})})]})})}function qc({open:e,onClose:t,title:n,subtitle:r,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?f("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:[f("header",{className:"flex items-start justify-between gap-2 px-4 py-3 border-b border-border",children:[f("div",{className:"min-w-0",children:[o("div",{className:"text-sm font-semibold text-foreground truncate",children:n}),r!==void 0&&o("div",{className:"text-[11px] text-foreground-subtle mt-0.5 truncate",children:r})]}),o("button",{type:"button",onClick:t,className:"p-1 rounded hover:bg-muted text-foreground-subtle hover:text-foreground","aria-label":"Close panel",children:o(Je,{className:"w-4 h-4"})})]}),o("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-3",children:a}),s!==void 0&&o("footer",{className:"flex items-center gap-2 justify-end px-4 py-3 border-t border-border",children:s})]}):null}const t3={inherit:"bg-muted",on:"bg-emerald-500",off:"bg-orange-500",na:"bg-gray-300 opacity-50"};function Tg({node:e,depth:t,selectedAddonId:n,onSelect:r,agentDots:s}){const a=e.addonId===n,i=s?.[e.addonId]??[];return f("div",{children:[f("button",{type:"button",onClick:()=>r(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:[o("span",{className:"truncate",children:e.addonName}),i.length>0&&o("span",{className:"flex items-center gap-1 shrink-0",children:i.map(l=>o("span",{title:`${l.agentNodeId}: ${l.state}`,className:K("w-2 h-2 rounded-full",t3[l.state])},l.agentNodeId))})]}),e.children.map(l=>o(Tg,{node:l,depth:t+1,selectedAddonId:n,onSelect:r,agentDots:s},l.addonId))]})}function Lg({tree:e,selectedAddonId:t,onSelect:n,agentDots:r,className:s}){return o("div",{className:K("flex flex-col py-2",s),children:e.map(a=>o(Tg,{node:a,depth:0,selectedAddonId:t,onSelect:n,agentDots:r},a.addonId))})}function Ta(e){const t=[],n=[],r=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),r.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 n3(e){return e?e.models.map(t=>({id:t.id,name:t.name})):[]}function Fs({step:e,schema:t,allSchemas:n,depth:r=0,onChange:s,onDelete:a,readOnly:i=!1,toggleMode:l="simple",overrideState:c=null,onOverrideChange:d,inheritedEnabled:u,hideModelAndSettings:p=!1}){const[h,m]=_(!1),g=n3(t);if(g.length>0&&!g.some(x=>x.id===e.modelId)&&!i){const y=(t?.defaultModelId?g.find(w=>w.id===t.defaultModelId):null)??g[0];y&&y.id!==e.modelId&&queueMicrotask(()=>s({...e,modelId:y.id}))}const b=f(me,{children:[f("div",{className:"flex-1 min-w-0",children:[o("span",{className:"text-[10px] uppercase tracking-wider font-medium text-foreground-subtle/60 block leading-none",children:e.slot}),o("span",{className:"text-sm font-semibold text-foreground truncate block leading-tight",children:e.addonName}),f("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(x=>o("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-blue-500/12 text-blue-400",children:x},x)),e.inputClasses.length>0&&e.outputClasses.length>0&&o("span",{className:"text-foreground-subtle/40 text-[10px]",children:"→"}),e.outputClasses.map(x=>o("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-green-500/12 text-green-400",children:x},x))]})]}),!i&&l==="simple"&&o("button",{onClick:x=>{x.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:o("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&&f("div",{className:"flex items-center gap-0.5 rounded-md border border-border p-0.5",onClick:x=>x.stopPropagation(),children:[o(Ni,{label:"Inherit",active:c===null,variant:"inherit",subtext:u===void 0?void 0:u?"on":"off",onClick:()=>d(null)}),o(Ni,{label:"On",active:c===!0,variant:"on",onClick:()=>d(!0)}),o(Ni,{label:"Off",active:c===!1,variant:"off",onClick:()=>d(!1)})]})]});return o(ag,{expanded:h,onExpandedChange:m,dimmed:!e.enabled,header:b,children:p?o("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."}):f("div",{className:"space-y-3",children:[o(_l,{label:"Model",value:e.modelId,disabled:i,options:g.map(x=>({value:x.id,label:x.name})),onChange:x=>s({...e,modelId:x})}),e.slot==="audio-classifier"&&e.engine&&o(_l,{label:"Runtime",value:`${e.engine.runtime}/${e.engine.backend}`,disabled:i,options:[{value:"node/cpu",label:"Node.js — ONNX CPU"},{value:"node/coreml",label:"Node.js — Apple SoundAnalysis (macOS)"},{value:"python/cpu",label:"Python — ONNX CPU"}],onChange:x=>{const[y,w]=x.split("/");s({...e,engine:{runtime:y,backend:w,format:w==="coreml"?"coreml":"onnx"}})}}),t?.configSchema?.map(x=>o(La,{field:x,allFields:t.configSchema??[],step:e,disabled:i,onChange:s},x.key))]})})}function _l({label:e,value:t,options:n,disabled:r,onChange:s}){return f("div",{children:[o("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e}),f("select",{value:t,onChange:a=>s(a.target.value),disabled:r,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&&o("option",{value:t,children:t||"default"}),n.map(a=>o("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]})]})}function r3({label:e,description:t,value:n,options:r,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 f("div",{children:[o("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1",children:e}),t&&o("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:t}),o("div",{className:"flex flex-wrap gap-1.5",children:r.map(l=>{const c=n.includes(l.value);return o("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 o3(e,t,n){const r=t.settings?.[e];if(r!==void 0)return r;const s=n.find(a=>"key"in a&&a.key===e);return s&&"default"in s?s.default:void 0}function La({field:e,allFields:t,step:n,disabled:r,onChange:s}){const a=e.type!=="separator"&&e.type!=="info"?e.showWhen:void 0;if(a){const{field:l,equals:c,notEquals:d,in:u,notIn:p}=a,h=o3(l,n,t);if(c!==void 0&&h!==c||d!==void 0&&h===d||u!==void 0&&!u.includes(h)||p!==void 0&&p.includes(h))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 o(_l,{label:e.label,value:c,disabled:r||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 o(r3,{label:e.label,description:e.description,value:c,options:e.options,disabled:r||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,u=e.min??0,p=e.max??1,h=e.step??.01,m=e.type==="slider"?e.showValue:!0,g="unit"in e?e.unit:void 0,b=e.type==="slider"?e.displayScale:void 0,x=b?d/b:d;return f("div",{children:[f("div",{className:"flex items-center justify-between mb-1",children:[o("span",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide",children:e.label}),m&&f("span",{className:"text-xs font-medium text-foreground tabular-nums",children:[typeof x=="number"?x.toFixed(2).replace(/\.?0+$/,""):x,g?` ${g}`:""]})]}),e.description&&o("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:e.description}),o("input",{type:"range",min:u,max:p,step:h,value:d,disabled:r||e.disabled,onChange:y=>i(Number(y.target.value)),className:"w-full accent-primary h-1.5"})]})}if(e.type==="boolean"){const l=n.settings?.[e.key],c=typeof l=="boolean"?l:e.default===!0;return f("label",{className:"flex items-center gap-2",children:[o("input",{type:"checkbox",checked:c,disabled:r||e.disabled,onChange:d=>i(d.target.checked),className:"h-3.5 w-3.5 accent-primary"}),o("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 f("div",{children:[o("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e.label}),e.type==="textarea"?o("textarea",{value:c,disabled:r||e.disabled,placeholder:e.placeholder,onChange:u=>i(u.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"}):o("input",{type:d,value:c,disabled:r||e.disabled,placeholder:e.placeholder,onChange:u=>i(u.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"?o("div",{className:"border-t border-border my-2"}):e.type==="info"?o("div",{className:"rounded-md border border-border bg-surface px-2 py-1.5 text-[10px] text-foreground-subtle",children:e.content}):null}function Ni({label:e,active:t,variant:n,subtext:r,onClick:s}){return f("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,r&&t&&f("span",{className:"ml-1 opacity-60",children:["(",r,")"]})]})}function Rg(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 s3(e,t,n){return n?{enabled:n.enabled??t.enabled,modelId:n.modelId??t.modelId,settings:n.settings??t.settings}:t}function a3({addon:e,agentDefault:t,modelsForFormat:n,onChangeAgentConfig:r}){const s=a=>{r?.({...t,...a})};return f("div",{className:"space-y-4 text-xs",children:[f("label",{className:"flex items-center gap-2",children:[o("input",{type:"checkbox",checked:t.enabled,onChange:a=>s({enabled:a.target.checked})}),f("span",{children:["Enabled on this agent (",e.name,")"]})]}),f("div",{children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle mb-1",children:"Model"}),o("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=>o("option",{value:a.id,children:a.name},a.id))})]}),(e.configSchema?.length??0)>0&&f("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),e.configSchema?.map(a=>o(La,{field:a,allFields:e.configSchema??[],step:Rg(e,t),disabled:!1,onChange:i=>s({settings:{...i.settings}})},a.key))]})]})}function i3({addon:e,agentDefault:t,agentNodeId:n,currentPatch:r,modelsForFormat:s,onChangePatch:a}){const i=s3("device",t,r),l=m=>{const g=m.enabled!==void 0||m.modelId!==void 0||m.settings!==void 0;a?.(g?m:null)},c=m=>{const{enabled:g,...b}=r??{},x=m==="inherit"?b:{...b,enabled:m==="on"};l(x)},d=m=>{const{modelId:g,...b}=r??{},x=m===void 0?b:{...b,modelId:m};l(x)},u=m=>{const{settings:g,...b}=r??{},x=m===void 0?b:{...b,settings:m};l(x)},p=r?.enabled===void 0?"inherit":r.enabled?"on":"off",h=r?.modelId!==void 0;return f("div",{className:"space-y-4 text-xs",children:[f("div",{className:"flex items-center gap-1",children:[["inherit","on","off"].map(m=>o("button",{type:"button",onClick:()=>c(m),className:K("px-3 py-1 border border-border rounded text-xs capitalize",p===m?"bg-primary text-primary-foreground border-primary":"bg-surface text-foreground hover:bg-muted"),children:m},m)),f("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["agent default: ",o("span",{className:"font-semibold",children:t.enabled?"on":"off"})]})]}),f("div",{children:[f("div",{className:"flex items-center justify-between mb-1",children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Model"}),h?o("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>d(void 0),children:"Clear"}):o("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>d(t.modelId),children:"Override"})]}),o("select",{disabled:!h,className:"w-full bg-surface border border-border rounded px-2 py-1 text-xs disabled:opacity-50",value:h?r?.modelId??t.modelId:t.modelId,onChange:m=>d(m.target.value),children:s.map(m=>o("option",{value:m.id,children:m.name},m.id))}),!h&&f("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["inherits from ",n]})]}),(e.configSchema?.length??0)>0&&(()=>{const m=r?.settings!==void 0;return f("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[f("div",{className:"flex items-center justify-between",children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),m?o("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>u(void 0),children:"Clear"}):o("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>u({...t.settings}),children:"Override"})]}),e.configSchema?.map(g=>o(La,{field:g,allFields:e.configSchema??[],step:Rg(e,i),disabled:!m,onChange:b=>u({...b.settings})},g.key)),!m&&f("div",{className:"text-[10px] text-foreground-subtle",children:["inherits from ",n]})]})})(),f("div",{className:"rounded bg-muted/40 px-3 py-2 text-[11px] text-foreground-subtle",children:[o("div",{className:"font-semibold text-foreground mb-0.5",children:"Effective config preview"}),f("div",{className:"font-mono truncate",children:[e.id," · model: ",i.modelId," · ",i.enabled?"on":"off"]})]})]})}function Ra(e){const{mode:t,addon:n,agentDefault:r,agentNodeId:s,currentPatch:a,onChangeAgentConfig:i,onChangePatch:l,engineFormat:c}=e,d=H(()=>n.models.filter(u=>!!u.formats[c]),[n.models,c]);return t==="agent"?o(a3,{addon:n,agentDefault:r,modelsForFormat:d,onChangeAgentConfig:i}):o(i3,{addon:n,agentDefault:r,agentNodeId:s,currentPatch:a,modelsForFormat:d,onChangePatch:l})}function l3(e){const t=[],n=(r,s)=>{for(const a of r)t.push({node:a,depth:s}),n(a.children,s+1)};return n(e,0),t}const op={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 c3({slot:e}){const t=op[e]??op.classifier;return o("span",{className:K("text-[9px] font-semibold uppercase tracking-widest leading-none",t.className),children:t.label})}const sp="inline-flex items-center rounded bg-muted px-1.5 py-px text-[9px] font-medium text-foreground-subtle";function d3({inputs:e,outputs:t}){return e.length===0&&t.length===0?null:f("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[e.map(n=>o("span",{className:K(sp,"bg-blue-500/10 text-blue-500"),children:n},`in-${n}`)),e.length>0&&t.length>0&&o("span",{className:"text-foreground-subtle/60 text-[9px]",children:"→"}),t.map(n=>o("span",{className:K(sp,"bg-emerald-500/10 text-emerald-500"),children:n},`out-${n}`))]})}function u3({enabled:e,onChange:t,disabled:n}){return o("button",{type:"button",role:"switch","aria-checked":e,disabled:n,onClick:r=>{r.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:o("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 p3(e){return e.kind==="enabled"?f("span",{className:"inline-flex items-center gap-1",children:[o("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 shrink-0"}),o("span",{className:"font-mono text-foreground",children:e.modelId})]}):e.kind==="disabled"?f("span",{className:"inline-flex items-center gap-1 text-foreground-subtle",children:[o("span",{className:"h-1.5 w-1.5 rounded-full border border-foreground-subtle/60 shrink-0"}),"off"]}):f("span",{className:"inline-flex items-center gap-1 text-foreground-subtle/70",children:[o("span",{className:"h-1.5 w-1.5 rounded-full bg-muted shrink-0"}),"n/a"]})}function f3({node:e,depth:t,agents:n,getCellState:r,onCellClick:s,selectedCell:a,toggleProps:i}){return f(me,{children:[f("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:[f("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:[o(c3,{slot:e.slot}),f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"font-semibold truncate",children:e.addonName}),o(d3,{inputs:e.inputClasses,outputs:e.outputClasses})]})]}),i&&o("span",{className:"pl-2 pt-0.5 shrink-0",children:o(u3,{enabled:i.enabled,onChange:i.onChange,disabled:i.disabled})})]}),n.map(l=>{const c=r(e.addonId,l.agentNodeId),d=a?.addonId===e.addonId&&a.agentNodeId===l.agentNodeId;return o("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:p3(c)},l.agentNodeId)})]})}function Uc({tree:e,agents:t,getCellState:n,onCellClick:r,selectedCell:s,onToggleEnabled:a}){const i=H(()=>l3(e),[e]),l=`minmax(320px, 1fr) repeat(${t.length}, minmax(160px, 220px))`,c=a!==void 0&&t.length===1,d=t[0]?.agentNodeId;return o("div",{className:"overflow-auto border border-border rounded",children:f("div",{className:"grid",style:{gridTemplateColumns:l},children:[o("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(u=>f("div",{className:"sticky top-0 z-10 bg-muted/60 px-3 py-2 border-b border-l border-border",children:[o("div",{className:"text-xs font-semibold text-foreground",children:u.agentNodeId}),o("div",{className:"text-[10px] text-foreground-subtle truncate",children:u.engineLabel})]},u.agentNodeId)),i.map(({node:u,depth:p})=>{const h=c&&d!==void 0?n(u.addonId,d):null,m=c&&h!==null?{enabled:h.kind==="enabled",onChange:g=>a?.(u.addonId,g),disabled:h.kind==="na"}:void 0;return o(f3,{node:u,depth:p,agents:t,getCellState:n,onCellClick:r,selectedCell:s,toggleProps:m},u.addonId)})]})})}const Og=typeof globalThis<"u"?globalThis.__camstackTrpcReact:void 0,S=Og??g2();typeof globalThis<"u"&&!Og&&(globalThis.__camstackTrpcReact=S);const Qc=xn("camstack:system",null);function Gc({system:e,children:t}){return o(Qc.Provider,{value:e,children:t})}function Te(){const e=ve(Qc);if(!e)throw new Error("useSystem(): no <SystemProvider> in tree");return e}function h3(){return ve(Qc)}function gt(e,t){const n=Te(),r=te(t);r.current=t;const[s,a]=_(n.connectionVersion);Y(()=>n.subscribeConnectionEvents((i,l)=>{i==="connected"&&a(l)}),[n]),Y(()=>n.subscribeEvent(e,l=>{r.current(l)}),[n,e,s])}function $l(e){const t=te(e);return t.current=e,t}function Gr(e,t){const[n,r]=_(null),s=$l(t);return gt(e,a=>{const i=a.data,l=s.current;l&&!l(i)||r(i)}),n}function Kc(e,t,n){const[r,s]=_(()=>new Map),a=$l(t),i=$l(n);gt(e,c=>{const d=c.data,u=i.current;if(u&&!u(d))return;const p=a.current(d);s(h=>{const m=new Map(h);return m.set(p,d),m})});const l=H(()=>Array.from(r.values()),[r]);return{map:r,values:l}}function Kr(){const{data:e,isLoading:t}=S.nodes.topology.useQuery(void 0,{staleTime:6e4}),r=Gr("cluster.topology-snapshot")?.nodes??e;return{nodes:H(()=>{const a=[];for(const i of r??[])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},[r]),isLoading:t}}function Bg({selectedNodeId:e,onSelect:t,label:n="Node",hideIcon:r=!1,alwaysShow:s=!1}){const{nodes:a}=Kr();return!s&&a.length<=1?null:f("div",{className:"flex items-center gap-1.5",children:[!r&&o(eC,{className:"h-3.5 w-3.5 text-foreground-subtle"}),n&&o("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:n}),o("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 o("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 m3={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 g3({status:e,showDot:t=!0,showLabel:n=!0,size:r="sm",className:s}){const a=m3[e];return f("span",{className:K("inline-flex items-center gap-1.5",r==="sm"?"text-xs":"text-sm",s),children:[t&&o("span",{className:K("h-1.5 w-1.5 shrink-0 rounded-full",a.colorClass),"aria-hidden":"true"}),n&&o("span",{className:"text-foreground",children:a.label})]})}const b3={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 x3({provider:e,showLabel:t=!0,className:n}){const r=b3[e];return f("span",{className:K("inline-flex items-center gap-1.5 text-xs",n),children:[o("span",{className:K("h-1.5 w-1.5 shrink-0 rounded-sm",r.colorClass),"aria-hidden":"true"}),t&&o("span",{className:"text-foreground",children:r.label})]})}const y3={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 zg({children:e,variant:t="neutral",mono:n,className:r}){return o("span",{className:K("inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-bold leading-tight",n&&"font-mono",y3[t],r),children:e})}function v3({version:e,preRelease:t,className:n}){const r=t??/-(alpha|beta|rc|dev|canary|next)/i.test(e);return o(zg,{variant:r?"warning":"success",mono:!0,className:n,children:e})}function w3({label:e,description:t,error:n,required:r,children:s,orientation:a="vertical",className:i}){const l=a==="horizontal";return f("div",{className:K("flex gap-2",l?"flex-row items-center justify-between":"flex-col",i),children:[f("div",{className:K(l?"flex-1":""),children:[f(Lc,{children:[e,r&&o("span",{className:"text-danger ml-0.5",children:"*"})]}),t&&o("p",{className:"text-foreground-subtle text-xs mt-0.5",children:t})]}),o("div",{className:K(l?"shrink-0":""),children:s}),n&&o("p",{className:"text-danger text-xs",children:n})]})}function N3({title:e,subtitle:t,actions:n,className:r}){return f("div",{className:K("flex flex-col gap-2 mb-3 sm:flex-row sm:items-center sm:justify-between",r),children:[f("div",{children:[o("h1",{className:"text-sm font-semibold text-foreground",children:e}),t&&o("p",{className:"text-foreground-subtle text-xs",children:t})]}),n&&o("div",{className:"flex items-center gap-2 flex-wrap",children:n})]})}function Wc({icon:e,title:t,description:n,action:r,className:s}){return f("div",{className:K("flex flex-col items-center justify-center gap-3 py-12",s),children:[e&&o(e,{className:"h-12 w-12 text-foreground-subtle","aria-hidden":"true"}),f("div",{className:"flex flex-col items-center gap-1 text-center",children:[o("p",{className:"text-foreground-muted text-sm font-medium",children:t}),n&&o("p",{className:"text-foreground-subtle text-xs max-w-xs",children:n})]}),r&&o("div",{className:"mt-1",children:r})]})}const k3={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 Oa({message:e,title:t,onRetry:n,action:r,variant:s="danger",className:a}){const i=k3[s],l=s==="warning"?Qr:Uo;return f("div",{role:"alert",className:K("flex items-start gap-2.5 rounded border px-3 py-2.5",i.box,a),children:[o(l,{className:K("h-4 w-4 mt-0.5 shrink-0",i.icon),"aria-hidden":"true"}),f("div",{className:"flex-1 min-w-0",children:[t&&o("p",{className:K("text-xs font-semibold",i.title),children:t}),o("div",{className:K("text-xs break-words",i.message,t?"mt-0.5":""),children:e})]}),r??(n&&f("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:[o($a,{className:"h-3 w-3","aria-hidden":"true"}),"Retry"]}))]})}const Fg=xn("camstack:confirm-dialog",null);function nt(){const e=ve(Fg);if(!e)throw new Error("useConfirm must be used within ConfirmDialogProvider");return e.confirm}function jg({children:e}){const[t,n]=_(null),r=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 f(Fg.Provider,{value:{confirm:r},children:[e,t&&f("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[o("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:a}),f("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:[f("div",{className:"px-5 pt-5 pb-4",children:[o("h3",{className:"text-sm font-semibold text-foreground",children:t.title}),o("p",{className:"mt-2 text-xs text-foreground-subtle leading-relaxed",children:t.message})]}),f("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border bg-surface-hover/30",children:[o("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"}),o("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 S3({value:e,label:t,trend:n,className:r}){return f(un,{className:K("flex flex-col gap-1",r),children:[f("div",{className:"flex items-baseline gap-2",children:[o("span",{className:"text-2xl font-semibold text-foreground",children:e}),n&&f("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"?o(wC,{className:"h-3 w-3"}):o(kC,{className:"h-3 w-3"}),n.value,"%"]})]}),o("span",{className:"text-xs text-foreground-muted",children:t})]})}function C3({items:e,className:t}){return o("dl",{className:K("flex flex-col",t),children:e.map(n=>f("div",{className:"flex items-center h-7",children:[o("dt",{className:"text-foreground-subtle text-xs w-1/3 shrink-0",children:n.key}),o("dd",{className:"text-foreground text-xs",children:n.value})]},n.key))})}function M3({children:e,maxHeight:t=300,className:n}){const[r,s]=_(!1),a=U(()=>{navigator.clipboard.writeText(e).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})},[e]);return f("div",{className:K("relative group",n),children:[o(jc,{style:{maxHeight:t},children:o("pre",{className:"font-mono text-xs bg-surface p-3 rounded-md border border-border-subtle",children:o("code",{children:e})})}),o("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:o(Tc,{icon:r?qr:yn,"aria-label":"Copy code",variant:"ghost",size:"sm",onClick:a})})]})}function E3({filters:e,values:t,onChange:n,className:r}){const s=hr(),[a,i]=_(!1),l=(d,u)=>{n({...t,[d]:u})},c=Object.values(t).filter(d=>d!==void 0&&d!=="").length;if(s){const d=e.find(p=>p.type==="search"),u=e.some(p=>p.type!=="search");return f("div",{className:K("flex items-center gap-2",r),children:[d&&o(ea,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:p=>l(d.key,p.target.value),leftSlot:o(Mo,{className:"h-3 w-3 text-foreground-subtle"}),className:"flex-1"}),u&&f(me,{children:[f("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:[o(iC,{className:"h-3.5 w-3.5"}),"Filters",c>0&&o(zt,{variant:"info",className:"ml-1 text-[10px] px-1 py-0",children:c})]}),o(Fc,{open:a,onClose:()=>i(!1),title:"Filters",children:o("div",{className:"flex flex-col gap-3",children:e.filter(p=>p.type!=="search").map(p=>{switch(p.type){case"select":return f("div",{children:[o("label",{className:"text-xs text-foreground-muted mb-1 block",children:p.label}),o(Eo,{options:p.options,value:t[p.key]??"",onChange:h=>l(p.key,h.target.value),className:"w-full"})]},p.key);case"badge-toggle":return o("div",{className:"flex items-center gap-1 flex-wrap",children:p.options.map(h=>{const g=t[p.key]===h.value;return o("button",{type:"button",onClick:()=>l(p.key,g?void 0:h.value),children:o(zt,{variant:g?"info":"default",className:"cursor-pointer",children:h.label})},h.value)})},p.key);default:return null}})})})]})]})}return o("div",{className:K("flex items-center gap-2 flex-wrap",r),children:e.map(d=>{switch(d.type){case"search":return o(ea,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:u=>l(d.key,u.target.value),leftSlot:o(Mo,{className:"h-3 w-3 text-foreground-subtle"}),className:"w-48"},d.key);case"select":return o(Eo,{options:d.options,value:t[d.key]??"",onChange:u=>l(d.key,u.target.value),className:"w-36"},d.key);case"badge-toggle":return o("div",{className:"flex items-center gap-1",children:d.options.map(u=>{const h=t[d.key]===u.value;return o("button",{type:"button",onClick:()=>l(d.key,h?void 0:u.value),children:o(zt,{variant:h?"info":"default",className:"cursor-pointer",children:u.label})},u.value)})},d.key);default:return null}})})}function Dl({label:e,icon:t,href:n,badge:r,active:s=!1,className:a}){return f("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:[o(t,{className:"h-3.5 w-3.5 shrink-0"}),o("span",{className:"truncate flex-1",children:e}),r!==void 0&&o(zt,{className:"ml-auto text-[10px] px-1.5 py-0",children:r})]})}function Tl({logo:e,sections:t,footer:n,onNavigate:r,className:s}){return f("nav",{className:K("bg-surface border-r border-border h-full flex flex-col",s),children:[e&&o("div",{className:"px-3 py-2 shrink-0",children:e}),o("div",{className:"flex-1 overflow-auto px-1 py-1",children:t.map((a,i)=>f("div",{className:K(i>0?"mt-3":""),children:[a.label&&o("span",{className:"text-[10px] text-foreground-disabled uppercase tracking-wider px-2 mb-1 block",children:a.label}),o("div",{className:"flex flex-col gap-0.5",onClick:r,children:a.items.map(l=>o(Dl,{...l},l.href))})]},i))}),n&&n.length>0&&f("div",{className:"shrink-0 px-1 pb-1",children:[o(Rc,{className:"mb-1"}),o("div",{className:"flex flex-col gap-0.5",onClick:r,children:n.map(a=>o(Dl,{...a},a.href))})]})]})}function I3({sidebar:e,header:t,mobileLogo:n,mobileActions:r,children:s,className:a}){const i=hr(),[l,c]=_(!1);return f("div",{className:K("flex h-screen",a),children:[!i&&o(Tl,{...e,className:K("w-44",e.className)}),i&&o(Vc,{open:l,onClose:()=>c(!1),width:"w-64",children:o(Tl,{...e,onNavigate:()=>c(!1),className:"w-full border-r-0"})}),f("div",{className:"flex flex-1 flex-col min-w-0",children:[i&&f("header",{className:"flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm",children:[o("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:o(NS,{className:"h-5 w-5"})}),n&&o("div",{className:"flex-1 flex justify-center",children:n}),r&&o("div",{className:"shrink-0",children:r})]}),!i&&t&&f("header",{className:"flex items-center h-10 border-b border-border px-4 shrink-0",children:[t.breadcrumbs&&t.breadcrumbs.length>0&&o("nav",{className:"flex items-center gap-1 text-xs flex-1 min-w-0",children:t.breadcrumbs.map((d,u)=>{const p=u===t.breadcrumbs.length-1;return f("span",{className:"flex items-center gap-1",children:[u>0&&o(On,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),d.href&&!p?o("a",{href:d.href,className:"text-foreground-subtle hover:text-foreground transition-colors truncate",children:d.label}):o("span",{className:"text-foreground truncate",children:d.label})]},u)})}),t.actions&&o("div",{className:"flex items-center gap-2 ml-auto shrink-0",children:t.actions})]}),o("main",{className:"flex-1 overflow-auto p-4",children:s})]})]})}const A3={online:"bg-success",offline:"bg-danger",warning:"bg-warning",unknown:"bg-foreground-subtle"};function P3({title:e,subtitle:t,status:n,selected:r,onClick:s,badges:a,actions:i,offlineAction:l,className:c}){const d=n==="offline";return f("div",{onClick:s,className:K("w-full rounded-lg border p-3 text-left transition-colors",s&&"cursor-pointer",r?"border-primary bg-primary/10":"border-border bg-surface hover:bg-surface-hover",d&&!r&&"opacity-50",c),children:[f("div",{className:"flex items-center justify-between mb-2",children:[o("span",{className:"text-sm font-medium truncate",children:e}),n&&o("span",{className:K("h-2 w-2 rounded-full shrink-0",A3[n])})]}),t&&o("div",{className:"text-[11px] text-foreground-muted",children:t}),a&&a.length>0&&o("div",{className:"flex flex-wrap gap-1 mt-2",children:a.map((u,p)=>{const h=K("rounded px-1.5 py-0.5 text-[10px] flex items-center gap-0.5",r?"bg-primary/20":"bg-surface-hover",u.onClick&&"hover:opacity-80 transition-opacity cursor-pointer");return u.onClick?f("button",{onClick:m=>{m.stopPropagation(),u.onClick()},className:h,children:[u.icon,u.label]},p):f("span",{className:h,children:[u.icon,u.label]},p)})}),!d&&i&&i.length>0&&o("div",{className:"flex items-center gap-0.5 mt-2 -mb-1",children:i.map((u,p)=>o("button",{onClick:h=>{h.stopPropagation(),u.onClick()},className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",title:u.label,"aria-label":u.label,children:u.icon},p))}),d&&l&&o("div",{className:"mt-2",onClick:u=>u.stopPropagation(),children:l})]})}function _3({children:e,minCardWidth:t=220,gap:n=3,className:r}){return o("div",{className:K("p-4 overflow-y-auto flex-1 content-start",r),style:{display:"grid",gridTemplateColumns:`repeat(auto-fill, minmax(${t}px, 1fr))`,gap:`${n*4}px`},children:e})}const $3="capability.binding-changed";function At(e,t){const[n,r]=_(null);return Y(()=>{if(t===null){r(null);return}let s=!1;const a=async()=>{try{const l=await e.deviceManager.getBindings.query({deviceId:t});s||r(l)}catch{s||r(l=>l)}};a();const i=e.live?.onEvent.subscribe({category:$3},{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]),H(()=>n?b2(e,n):null,[e,n])}function pn(e){const t=U(r=>e?e.subscribe(()=>r()):()=>{},[e]),n=U(()=>e?.value,[e]);return Pa(t,n,n)}function Vg(e,t,n){const r=At(e,t),s=r?n(r.state):void 0;return pn(s)}function Wr(e){const t=At(e.trpc,e.deviceId),n=t!==null?e.slice(t):void 0,r=pn(n),s=t!==null?e.cap(t):void 0,c=(e.requireFeature===void 0||(e.deviceFeatures??[]).includes(e.requireFeature))&&s!==void 0&&r!==void 0;return{dev:t,cap:s,slice:r,available:c}}function D3(e){return e.parentDeviceId===null?"top-level":e.role?"accessory":"adopted"}const T3={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 L3(e){const t=T3[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 R3={siren:_a,floodlight:Zm,spotlight:rg,"pir-sensor":eg,chime:IS,autotrack:Qm,nightvision:$c,"privacy-mask":_c,doorbell:Gm},O3={camera:Ac,hub:Al,nvr:Al,light:Zm,siren:_a,switch:xC,sensor:eg,thermostat:gC,button:R5,generic:Dc};function Hg(e){return e.role?R3[e.role]??Dc:O3[e.type.toLowerCase()]??Ac}const qg={"native-snapshot":cS,"two-way-audio":Xm,"pan-tilt-zoom":Qm,"ptz-autotrack":yS,"doorbell-button":Gm,"motion-trigger":In,"battery-operated":qm,rebootable:ng},Ug={"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"},B3={"native-snapshot":"snapshot",rebootable:"reboot","pan-tilt-zoom":"ptz","ptz-autotrack":"ptz-autotrack","two-way-audio":"intercom","motion-trigger":"motion-trigger"},Qg=new Set(["camera","hub","nvr"]);function Gg(e){return!Qg.has(e.type.toLowerCase())}function ap(e){return e.role?!0:!Qg.has(e.type.toLowerCase())}function Kg(e){return(e.features??[]).includes("motion-trigger")}function z3(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 r=n.slice(-2).join("-");if(r.length>=6)return r}return`…${e.slice(-18)}`}function F3({trpc:e,accessoryChildren:t,adoptedChildren:n,onNavigate:r}){return f("div",{className:"border-t border-border-subtle/50",children:[n.length>0&&o(ip,{trpc:e,label:"Adopted devices",rows:n,onNavigate:r}),t.length>0&&o(ip,{trpc:e,label:"Accessories",rows:t,onNavigate:r})]})}function ip({trpc:e,label:t,rows:n,onNavigate:r}){return f("div",{children:[o("div",{className:"px-3 pt-1.5 pb-1 text-[9px] font-semibold uppercase tracking-wide text-foreground-subtle",children:t}),o("ul",{children:n.map(s=>o(j3,{trpc:e,child:s,onNavigate:r},s.id))})]})}function j3({trpc:e,child:t,onNavigate:n}){const r=!t.disabled,s=r&&Gg(t),a=r&&Kg(t),i=Hg(t);return o("li",{children:f("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:[o(i,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),o("span",{className:"text-[10.5px] text-foreground flex-1 truncate",children:t.name}),a&&o(H3,{trpc:e,deviceId:t.id,features:t.features}),s&&o(V3,{trpc:e,deviceId:t.id}),o("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 V3({trpc:e,deviceId:t}){const{dev:n,cap:r,slice:s,available:a}=Wr({trpc:e,deviceId:t,cap:p=>p.switch,slice:p=>p.state.switch}),[i,l]=_(!1);if(n!==null&&!r)return null;const c=s?.on===!0,d={transform:c?"translateX(14px)":"translateX(2px)"},u=async p=>{if(p.stopPropagation(),!(i||!a||!r)){l(!0);try{await r.setState({on:!c})}finally{l(!1)}}};return o("button",{type:"button",onClick:p=>{u(p)},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:o("span",{className:K("absolute h-3 w-3 rounded-full transition-all",c?"bg-success":"bg-foreground-subtle"),style:d})})}function H3({trpc:e,deviceId:t,features:n}){const{dev:r,cap:s,slice:a,available:i}=Wr({trpc:e,deviceId:t,cap:p=>p.motionTrigger,slice:p=>p.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:n}),[l,c]=_(!1);if(r!==null&&!s)return null;const d=a?.enabled===!0,u=async p=>{if(p.stopPropagation(),!(l||!i||!s)){c(!0);try{await s.setMotionTrigger({enabled:!d})}finally{c(!1)}}};return o("button",{type:"button",onClick:p=>{u(p)},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:o(In,{className:"h-2.5 w-2.5"})})}function Wg({trpc:e,device:t,flags:n}){if(!!t.disabled)return null;const s=t.type.toLowerCase(),a=n.showSwitchToggle&&Gg(t),i=Kg(t),l=s==="hub"||s==="nvr",c=(t.features??[]).includes("rebootable"),d=l&&c;return f(me,{children:[i&&o(U3,{trpc:e,deviceId:t.id,features:t.features}),a&&o(q3,{trpc:e,deviceId:t.id}),d&&o(G3,{trpc:e,deviceId:t.id})]})}function q3({trpc:e,deviceId:t}){const{dev:n,cap:r,slice:s,available:a}=Wr({trpc:e,deviceId:t,cap:p=>p.switch,slice:p=>p.state.switch}),[i,l]=_(!1);if(n!==null&&!r)return null;const c=s?.on===!0,d={transform:c?"translateX(14px)":"translateX(2px)"},u=async p=>{if(p.stopPropagation(),!(i||!a||!r)){l(!0);try{await r.setState({on:!c})}finally{l(!1)}}};return o("button",{type:"button",onClick:p=>{u(p)},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:o("span",{className:K("absolute h-3 w-3 rounded-full transition-all",c?"bg-success":"bg-foreground-subtle"),style:d})})}function U3({trpc:e,deviceId:t,features:n}){const{dev:r,cap:s,slice:a,available:i}=Wr({trpc:e,deviceId:t,cap:p=>p.motionTrigger,slice:p=>p.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:n}),[l,c]=_(!1);if(r!==null&&!s)return null;const d=a?.enabled===!0,u=async p=>{if(p.stopPropagation(),!(l||!i||!s)){c(!0);try{await s.setMotionTrigger({enabled:!d})}finally{c(!1)}}};return o("button",{type:"button",onClick:p=>{u(p)},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:o(In,{className:"h-2.5 w-2.5"})})}const ki=168,Q3=4;function G3({trpc:e,deviceId:t}){const{dev:n,cap:r}=Wr({trpc:e,deviceId:t,cap:x=>x.reboot,slice:()=>{}}),s=te(null),a=te(null),[i,l]=_(null),[c,d]=_(!1),u=n!==null&&r!==void 0&&r!==null,p=i!==null,h=()=>l(null),m=()=>{const x=s.current;if(!x)return;const y=x.getBoundingClientRect(),w=y.right-ki,v=Math.max(8,Math.min(w,window.innerWidth-ki-8)),N=y.bottom+Q3;l({top:N,left:v})};if(Y(()=>{if(!p)return;const x=w=>{const v=s.current,N=a.current,k=w.target;k!==null&&(v&&v.contains(k)||N&&N.contains(k)||h())},y=w=>{w.key==="Escape"&&(w.stopPropagation(),h())};return document.addEventListener("mousedown",x),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",y)}},[p]),n!==null&&!r)return null;const g=x=>{x.stopPropagation(),p?h():m()},b=async()=>{if(!(c||!u||!r)){d(!0),h();try{await r.reboot({})}finally{d(!1)}}};return f(me,{children:[o("button",{ref:s,type:"button",onClick:g,disabled:c||!u,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||!u)&&"opacity-50",p&&"bg-surface-hover text-foreground"),title:"More actions","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":p,children:o(Km,{className:"h-3 w-3"})}),i&&qo(o("div",{ref:a,role:"menu",style:{position:"fixed",top:i.top,left:i.left,width:ki},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-1",onClick:x=>x.stopPropagation(),children:f("button",{type:"button",role:"menuitem",onClick:()=>{b()},disabled:c||!u,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:[o(ng,{className:"h-3 w-3 shrink-0 text-foreground-subtle"}),o("span",{children:"Reboot device"})]})}),document.body)]})}const K3=Object.freeze([]);function W3(e){return e==="native"?"native":"enhanced"}function Y3(e){return e.map(t=>({kind:"marker",feature:t}))}function Z3(e,t){const n=new Map,r=t.entries??[];for(const a of r)n.set(a.capName,a);const s=[];for(const a of e){const i=B3[a];if(i===void 0){s.push({kind:"marker",feature:a});continue}const l=n.get(i);l&&s.push({kind:W3(l.kind),feature:a,capName:i})}return s}function X3(e,t,n){const[r,s]=_(null),[a,i]=_(!1),[l,c]=_(!0);return Y(()=>{if(t===null){s(null),i(!1),c(!1);return}let d=!1;c(!0),i(!1);const u=async()=>{try{const h=await e.deviceManager.getBindings.query({deviceId:t});if(d)return;s(h),c(!1)}catch{if(d)return;i(!0),c(!1)}};u();const p=e.live?.onEvent.subscribe({category:"capability.binding-changed"},{onData:h=>{const m=h.data?.source;if(!m){u();return}m.type==="device"&&m.id===t&&u()}});return()=>{d=!0,p?.unsubscribe()}},[e,t]),n.length===0?{loading:l,resolved:K3}:l||a||!r?{loading:l,resolved:Y3(n)}:{loading:!1,resolved:Z3(n,r)}}const J3=[];function Yg({trpc:e,device:t,flags:n,accessoryCount:r,adoptedCount:s,showFeatureRow:a=!1}){const i=r+s,l=n.showChildrenAccordion&&i>0,c=t.features??J3,d=a&&c.length>0,{resolved:u}=X3(e,d?t.id:null,c),p=d&&u.length>0;return!l&&!p?null:f("div",{className:"flex items-center gap-1.5 flex-nowrap whitespace-nowrap min-w-0",children:[l&&o(eM,{accessoryCount:r,adoptedCount:s}),p&&o(tM,{resolved:u})]})}function eM({accessoryCount:e,adoptedCount:t}){const n=e+t;if(n===0)return null;const r=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 f("span",{className:"text-[9px] font-medium text-foreground-subtle bg-surface-elevated/60 rounded px-1.5 py-0.5 flex-shrink-0",title:r,children:["+",n]})}const Zg=240,lp=200;function tM({resolved:e}){const t=te(null),[n,r]=_(null);return f("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(),u=window.innerHeight-l.bottom>=lp?l.bottom+4:l.top-lp-4,p=Math.max(8,Math.min(l.left,window.innerWidth-Zg-8));r({top:u,left:p})},onMouseLeave:()=>r(null),children:[e.map(i=>{const l=qg[i.feature];return l?o("span",{className:"inline-flex items-center justify-center h-4 w-4 rounded bg-surface-elevated/60 text-foreground-subtle",title:Ug[i.feature]??i.feature,children:o(l,{className:"h-2.5 w-2.5"})},i.feature):null}),n&&qo(o(nM,{resolved:e,position:n}),document.body)]})}function nM({resolved:e,position:t}){return f("div",{style:{position:"fixed",top:t.top,left:t.left,width:Zg,pointerEvents:"none"},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-2",children:[o("h5",{className:"text-[9px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5",children:"Features"}),o("ul",{className:"space-y-0.5",children:e.map(n=>o(rM,{entry:n},n.feature))})]})}function rM({entry:e}){const t=qg[e.feature],n=Ug[e.feature]??e.feature;return f("li",{className:"flex items-center justify-between gap-2 text-[10px]",children:[f("span",{className:"flex items-center gap-1.5 text-foreground",children:[t&&o(t,{className:"h-3 w-3 text-foreground-subtle"}),o("span",{children:n})]}),o(oM,{kind:e.kind})]})}function oM({kind:e}){return e==="marker"?o("span",{className:"text-[8.5px] px-1 rounded text-foreground-subtle",title:"Informational marker (no cap registered)",children:"marker"}):o("span",{className:K("text-[8.5px] px-1 rounded",e==="native"?"bg-success/15 text-success":"bg-primary/15 text-primary"),children:e})}function Xg({device:e,variant:t,flags:n,parent:r,integrationIcon:s,hasChildren:a,expanded:i,onToggleExpand:l,onNavigateToParent:c}){const d=Hg(e);return f("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[n.showChildrenAccordion&&a?o("button",{type:"button",onClick:u=>{u.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?o(pr,{className:"h-3 w-3"}):o(On,{className:"h-3 w-3"})}):n.showChildrenAccordion?o("span",{className:"h-3.5 w-3.5 flex-shrink-0"}):null,o(d,{className:K("text-foreground-subtle flex-shrink-0",t==="minimal"?"h-3 w-3":"h-3.5 w-3.5")}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.showIntegrationIcon&&s&&o("span",{className:"flex-shrink-0",children:s}),o("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)&&f("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&&f("span",{className:"flex-shrink-0 tabular-nums",children:["#",String(e.id)]}),n.showId&&n.showStableId&&o("span",{className:"flex-shrink-0 opacity-50",children:"·"}),n.showStableId&&o("span",{className:"truncate",children:z3(e.stableId)})]}),n.showParentBadge&&r&&f("button",{type:"button",onClick:u=>{u.stopPropagation(),c(r.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: ${r.name} (#${String(r.id)})`,children:[o(Al,{className:"h-2.5 w-2.5 shrink-0"}),f("span",{className:"truncate",children:["Under: ",r.name]})]})]})]})}function Yc(e,t){return Vg(e,t,r=>r.battery)??null}function Zc(e,t){const n=At(e,t),r=te(!1),{data:s,isLoading:a,isFetching:i,refetch:l}=Ln({queryKey:["device",t,"snapshot"],queryFn:()=>{if(!n)throw new Error("useDeviceSnapshotImage: device proxy not ready");const u=r.current;return r.current=!1,n.snapshot?.getSnapshot({force:u})??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(){r.current=!0,l()}return{src:c,loading:a||i,refresh:d}}function sM(e){return e<=10?m5:e<=30?f5:e>=95?u5:qm}function aM(e,t){return t!=="none"?"text-emerald-400":e<=10?"text-rose-400":e<=30?"text-amber-400":"text-foreground-subtle"}function Xc({status:e,variant:t="compact",className:n}){if(!e)return null;const r=sM(e.percentage),s=aM(e.percentage,e.charging),a=e.charging==="solar"?rg:e.charging==="dc"?LS:null,i=e.sleeping;return f("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:[o(r,{className:"h-3.5 w-3.5"}),f("span",{children:[Math.round(e.percentage),"%"]}),a&&o(a,{className:"h-3 w-3"}),i&&o($c,{className:"h-3 w-3 text-blue-300"}),t==="full"&&e.charging!=="none"&&o("span",{className:"text-foreground-subtle",children:e.charging})]})}function Jg({trpc:e,device:t,status:n,enabled:r,showStatusPills:s=!1}){const a=r&&t.online,i=Zc(e,a?t.id:null),l=(t.features??[]).includes("battery-operated"),c=s&&l&&!t.disabled,d=Yc(e,c?t.id:null);return!r&&!c?null:f("span",{className:"inline-flex items-center gap-1.5 flex-nowrap whitespace-nowrap",children:[c&&d&&o(Xc,{status:d}),r&&o(iM,{deviceName:t.name,snapshotUrl:i.src,status:n})]})}const Si=288,cp=196,Ci=8;function iM({deviceName:e,snapshotUrl:t,status:n}){const r=te(null),[s,a]=_(null),i=n==="offline"||n==="disabled",l=()=>{const d=r.current;if(!d)return;const u=d.getBoundingClientRect(),p=u.top,h=window.innerHeight-u.bottom,m=p<cp+Ci&&h>p,g=m?u.bottom+Ci:u.top-cp-Ci,b=u.right-Si,x=Math.max(8,Math.min(b,window.innerWidth-Si-8));a({top:g,left:x,placeBelow:m})},c=()=>a(null);return f(me,{children:[o("button",{ref:r,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:o(Ur,{className:"h-3.5 w-3.5"})}),s&&qo(f("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:[o("div",{className:"h-40 bg-background flex items-center justify-center",children:t&&!i?o("img",{src:t,alt:e,className:"h-full w-full object-cover"}):o("span",{className:"text-xs text-foreground-subtle",children:n==="offline"?"Offline — no snapshot":n==="disabled"?"Disabled":"No snapshot yet"})}),o("div",{className:"px-3 py-2",children:o("p",{className:"text-xs font-semibold text-foreground truncate",children:e})})]}),document.body)]})}function eb({status:e}){const t=e==="disabled"?"bg-warning":e==="online"?"bg-success":"bg-danger",n=e==="disabled"?"Disabled":e==="online"?"Online":"Offline";return o("span",{className:K("h-1.5 w-1.5 rounded-full flex-shrink-0",t),title:n})}function Io(e){const{trpc:t,device:n,parent:r,integrationIcon:s,onNavigate:a,className:i}=e,l=L3(e),c=e.variant??"compact",d=e.view??"card",u=!n.disabled,p=n.isCamera??n.type.toLowerCase()==="camera",h=e.children??[],m=h.filter(ap),g=h.filter(E=>!ap(E)),b=h.length>0,[x,y]=_(!1),w=e.expanded??x,v=e.onToggleExpand??(()=>y(E=>!E)),N=E=>{a?.(E)},k=e.indentLevel??(e.isAccessoryRow?2:0),C=u?n.online?"online":"offline":"disabled";return d==="table"?o(cM,{trpc:t,device:n,variant:c,flags:l,parent:r??null,integrationIcon:s??null,accessoryCount:m.length,adoptedCount:g.length,hasChildren:b,expanded:w,onToggleExpand:v,onNavigate:N,displayStatus:C,isCamera:p,showSnapshot:l.showSnapshot&&p,isAccessoryRow:e.isAccessoryRow??!1,indentLevel:k,className:i}):f("div",{className:K("rounded-lg border border-border bg-surface transition-colors",!u&&"opacity-60",i),children:[f("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:[o(Xg,{device:n,variant:c,flags:l,parent:r??null,integrationIcon:s??null,hasChildren:b,expanded:w,onToggleExpand:v,onNavigateToParent:N}),o(Yg,{trpc:t,device:n,flags:l,accessoryCount:m.length,adoptedCount:g.length,showFeatureRow:!1}),o(Jg,{trpc:t,device:n,status:C,enabled:l.showSnapshot&&p,showStatusPills:!0}),o(Wg,{trpc:t,device:n,flags:l}),o(eb,{status:C})]}),w&&b&&o(F3,{trpc:t,accessoryChildren:m,adoptedChildren:g,onNavigate:N})]})}const lM={0:"pl-2",1:"pl-6",2:"pl-8"};function cM(e){const{trpc:t,device:n,variant:r,flags:s,parent:a,integrationIcon:i,accessoryCount:l,adoptedCount:c,hasChildren:d,expanded:u,onToggleExpand:p,onNavigate:h,displayStatus:m,isCamera:g,showSnapshot:b,isAccessoryRow:x,indentLevel:y,className:w}=e;return f("tr",{onClick:()=>h(n.id),className:K("cursor-pointer hover:bg-surface-hover transition-colors",!s.showChildrenAccordion&&"border-b border-border-subtle/40",x&&"bg-foreground-subtle/[0.03]",w),children:[o("td",{className:K("py-2 align-middle pr-2",lM[y]),children:o(Xg,{device:n,variant:r,flags:s,parent:a,integrationIcon:i,hasChildren:d,expanded:u,onToggleExpand:p,onNavigateToParent:h})}),o("td",{className:"px-2 py-2 align-middle text-[10px] text-foreground-subtle whitespace-nowrap",children:n.type}),o("td",{className:"px-2 py-2 align-middle",children:o(Yg,{trpc:t,device:n,flags:s,accessoryCount:l,adoptedCount:c,showFeatureRow:!0})}),o("td",{className:"px-2 py-2 align-middle",children:o(Jg,{trpc:t,device:n,status:m,enabled:b&&g,showStatusPills:!0})}),o("td",{className:"px-2 py-2 align-middle text-right whitespace-nowrap",children:f("span",{className:"inline-flex items-center gap-1.5",children:[o(Wg,{trpc:t,device:n,flags:s}),o(eb,{status:m})]})})]})}function tb(e,t){const[n,r]=_(e);return Y(()=>{const s=setTimeout(()=>r(e),t);return()=>clearTimeout(s)},[e,t]),n}const dM=new Set(["hub","nvr"]);function uM(e){const t=new Map;for(const s of e)t.set(s.id,s);const n=[],r=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(dM.has(i.type)&&!l){n.push(s);continue}const d=r.get(a);d?d.push(s):r.set(a,[s])}return{topLevel:n,accessoriesByParent:r}}const dp=2;function pM(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=[],r=Math.max(2,e-dp),s=Math.min(t-1,e+dp);n.push({kind:"page",n:1}),r>2&&n.push({kind:"ellipsis",side:"left"});for(let a=r;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 fM({currentPage:e,totalItems:t,pageSize:n,onPageChange:r,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=pM(e,a);return f("div",{className:"flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle",children:[f("span",{children:["Showing ",i,"–",l," of ",t," ",s]}),f("span",{className:"inline-flex items-center gap-1",children:[o("button",{type:"button","aria-label":"Previous page",disabled:e===1,onClick:()=>r(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:o(I5,{className:"h-3 w-3"})}),c.map((d,u)=>{if(d.kind==="ellipsis")return o("span",{className:"px-1 text-foreground-subtle/60 select-none",children:"…"},`e-${u}`);const p=d.n===e;return o("button",{type:"button",onClick:()=>r(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",p?"border-primary/40 bg-primary/10 text-primary":"border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),children:d.n},`p-${d.n}`)}),o("button",{type:"button","aria-label":"Next page",disabled:e===a,onClick:()=>r(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:o(On,{className:"h-3 w-3"})})]})]})}function hM({view:e,onViewChange:t,types:n,currentType:r,onTypeChange:s,addons:a,currentAddon:i,onAddonChange:l,hideAddons:c=!1}){return f("div",{className:"flex items-center gap-2 flex-wrap",children:[f("span",{className:"inline-flex border border-border rounded-md overflow-hidden",children:[o("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:o(mS,{className:"h-3.5 w-3.5"})}),o("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:o(fC,{className:"h-3.5 w-3.5"})})]}),n&&n.length>0&&f(me,{children:[o(up,{children:"Type"}),o(Mi,{active:r===null,onClick:()=>s(null),children:"All"}),n.map(d=>o(Mi,{active:r===d,onClick:()=>s(r===d?null:d),children:mM(d)},d))]}),!c&&a&&a.length>0&&f(me,{children:[o(up,{children:"Integration"}),a.map(d=>o(Mi,{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 up({children:e}){return o("span",{className:"text-[10px] font-medium uppercase tracking-wider text-foreground-subtle ml-1",children:e})}function Mi({active:e,icon:t,onClick:n,showClearIcon:r,children:s}){return f("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&&o("span",{className:"inline-flex items-center",children:t}),o("span",{children:s}),e&&r&&o(Je,{className:"h-2.5 w-2.5 opacity-70"})]})}function mM(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function gM({variant:e,onClearFilters:t}){return f("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[o(uS,{className:"h-8 w-8 text-foreground-subtle/40 mb-3"}),o("p",{className:"text-sm font-medium text-foreground-subtle",children:e==="filtered"?"No devices match the current filters":"No devices yet"}),e==="filtered"&&t&&o("button",{type:"button",onClick:t,className:"mt-2 text-[11px] text-primary hover:underline",children:"Clear filters"})]})}function Gt(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 pp(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 bM(e,t){try{localStorage.setItem(`camstack:${e}:lastFilters`,JSON.stringify(t))}catch{}}function fp(e,t,n){const r=new URLSearchParams(window.location.search),s=r.get(Gt(e,"view")),a=s==="cards"||s==="table"?s:n.view??t,i=r.get(Gt(e,"page")),l=i?parseInt(i,10):1,c=Number.isFinite(l)&&l>=1?l:1,d=r.get(Gt(e,"addon"))??n.addon??null,u=r.get(Gt(e,"type"))??n.type??null,p=r.get(Gt(e,"q"))??n.q??"";return{view:a,page:c,addon:d,type:u,q:p}}function xM(e,t,n){const r=new URLSearchParams(window.location.search),s=(l,c)=>{c===null||c===""?r.delete(l):r.set(l,c)};s(Gt(e,"view"),t.view===n?null:t.view),s(Gt(e,"page"),t.page===1?null:String(t.page)),s(Gt(e,"addon"),t.addon),s(Gt(e,"type"),t.type),s(Gt(e,"q"),t.q||null);const a=r.toString(),i=a?`${window.location.pathname}?${a}`:window.location.pathname;window.history.replaceState(null,"",i)}function yM(e){const{scope:t,defaultView:n,lsKey:r}=e,[s,a]=_(()=>{const g=pp(r);return fp(t,n,g)}),i=te(s);i.current=s,Y(()=>{const g=()=>{const b=pp(r),x=fp(t,n,b);i.current=x,a(x)};return window.addEventListener("popstate",g),()=>window.removeEventListener("popstate",g)},[t,n,r]);const l=U(g=>{const b=g(i.current);i.current=b,a(b),xM(t,b,n),bM(r,{view:b.view,addon:b.addon,type:b.type,q:b.q})},[t,n,r]),c=U(g=>l(b=>({...b,view:g})),[l]),d=U(g=>l(b=>({...b,page:g})),[l]),u=U(g=>l(b=>({...b,addon:g,page:1})),[l]),p=U(g=>l(b=>({...b,type:g,page:1})),[l]),h=U(g=>l(b=>({...b,q:g,page:1})),[l]),m=U(()=>l(g=>({...g,addon:null,type:null,q:"",page:1})),[l]);return{state:s,setView:c,setPage:d,setAddon:u,setType:p,setQ:h,clearFilters:m}}const vM={cards:24,table:50};function Ao(e){const{devices:t,trpc:n,defaultView:r="table",filters:s,forceAddon:a,resolveIntegrationIcon:i,resolveParent:l,onNavigate:c,pageSize:d=vM,urlScope:u="root",lsKey:p=u==="root"?"devices":"integrations:nested"}=e,h=yM({scope:u,defaultView:r,lsKey:p}),m=h.state.view,g=m==="cards"?d.cards:d.table,[b,x]=_(h.state.q),y=tb(b,300);Y(()=>{y!==h.state.q&&h.setQ(y)},[y]);const w=a??h.state.addon,v=H(()=>{const R=h.state.q.toLowerCase().trim();return t.filter(M=>!(w&&M.addonId!==w||h.state.type&&M.type!==h.state.type||R&&!M.name.toLowerCase().includes(R)&&!M.stableId.toLowerCase().includes(R)))},[t,w,h.state.type,h.state.q]),N=H(()=>uM(v),[v]),k=H(()=>{if(h.state.q.trim()==="")return new Set;const R=h.state.q.toLowerCase().trim(),M=new Set;for(const[D,T]of N.accessoriesByParent.entries())T.some(L=>L.name.toLowerCase().includes(R)||L.stableId.toLowerCase().includes(R))&&M.add(D);return M},[N.accessoriesByParent,h.state.q]),C=N.topLevel.length,E=Math.max(1,Math.ceil(C/g)),I=Math.min(h.state.page,E),A=(I-1)*g,z=N.topLevel.slice(A,A+g);Y(()=>{I!==h.state.page&&h.setPage(I)},[I]),MM();const P=w!=null||h.state.type!==null||h.state.q!=="",B=C===0;return f("div",{className:"flex flex-col gap-3",children:[f("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[o(hM,{view:m,onViewChange:h.setView,types:s?.types,currentType:h.state.type,onTypeChange:h.setType,addons:s?.addons,currentAddon:h.state.addon,onAddonChange:h.setAddon,hideAddons:a!==void 0}),f("div",{className:"relative",children:[o(Mo,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle pointer-events-none"}),o("input",{type:"text",value:b,onChange:R=>x(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"})]})]}),B?o(gM,{variant:P?"filtered":"nofilter",onClearFilters:P?h.clearFilters:void 0}):m==="cards"?o(wM,{rows:z,accessoriesByParent:N.accessoriesByParent,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}):o(SM,{rows:z,accessoriesByParent:N.accessoriesByParent,autoExpandedParents:k,devices:v,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}),o(fM,{currentPage:I,totalItems:C,pageSize:g,onPageChange:h.setPage}),a===void 0&&P&&C>0&&f("p",{className:"text-[11px] text-foreground-subtle",children:["Showing ",C," of ",t.length," devices",w&&f(me,{children:[" ","· filtered by"," ",o("strong",{className:"text-primary",children:s?.addons?.find(R=>R.id===w)?.name??w})]})]})]})}function wM({rows:e,accessoriesByParent:t,trpc:n,resolveIntegrationIcon:r,resolveParent:s,onNavigate:a}){return o("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 o(Io,{trpc:n,device:i,view:"card",integrationIcon:r?.(i.addonId)??null,parent:i.parentDeviceId!==null?s?.(i.parentDeviceId)??null:null,children:l,onNavigate:a??void 0},i.id)})})}const NM=new Set(["hub","nvr"]);function kM(e,t){return e.parentDeviceId===null||t===null?0:NM.has(t.toLowerCase())?1:0}function SM({rows:e,accessoriesByParent:t,autoExpandedParents:n,devices:r,trpc:s,resolveIntegrationIcon:a,resolveParent:i,onNavigate:l}){const c=H(()=>{const d=new Map;for(const u of r)d.set(u.id,u.type);return d},[r]);return o("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:f("table",{className:"w-full border-collapse",children:[o("thead",{children:f("tr",{className:"border-b border-border",children:[o("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle",children:"Name"}),o("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-24",children:"Type"}),o("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Features"}),o("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-20",children:"Preview"}),o("th",{className:"text-right px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Actions"})]})}),o("tbody",{children:e.map(d=>{const u=t.get(d.id)??[],p=u.length>0,h=n.has(d.id),m=d.parentDeviceId!==null?i?.(d.parentDeviceId)??null:null,g=d.parentDeviceId!==null?c.get(d.parentDeviceId)??null:null;return o(CM,{parent:d,accessories:u,hasAccessories:p,forceExpanded:h,trpc:s,integrationIcon:a?.(d.addonId)??null,parentRowParent:m,indentLevel:kM(d,g),onNavigate:l??null},d.id)})})]})})}function CM({parent:e,accessories:t,hasAccessories:n,forceExpanded:r,trpc:s,integrationIcon:a,parentRowParent:i,indentLevel:l,onNavigate:c}){const[d,u]=_(r),p=te(r);return Y(()=>{p.current!==r&&(u(r),p.current=r)},[r]),f(me,{children:[o(Io,{trpc:s,device:e,view:"table",integrationIcon:a,parent:i,children:t,onNavigate:c??void 0,showChildrenAccordion:n,expanded:d,onToggleExpand:()=>u(g=>!g),indentLevel:l}),n&&d&&t.map(g=>o(Io,{trpc:s,device:g,view:"table",integrationIcon:null,parent:null,isAccessoryRow:!0,showChildrenAccordion:!1,onNavigate:c??void 0},g.id))]})}function MM(){ke()}function EM({options:e,value:t,onChange:n}){return o("div",{className:"flex flex-wrap gap-2",children:e.map(r=>{const s=r.id===t;return f("button",{onClick:()=>r.available&&n(r.id),disabled:!r.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":r.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:[o(K5,{className:"h-3.5 w-3.5 shrink-0"}),r.label,r.isBest&&f("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:[o(dC,{className:"h-2.5 w-2.5"}),"Best"]}),r.platformScore!=null&&f("span",{className:"text-[10px] text-foreground-subtle/60",children:["(",r.platformScore,")"]}),o("span",{className:`h-1.5 w-1.5 rounded-full ${r.available?"bg-success":"bg-danger"}`})]},r.id)})})}function IM(e,t){const n=new Set(t.slots.flatMap(i=>i.addons.map(l=>l.id))),r=[];function s(i){if(!n.has(i.addonId))return r.push(`Addon "${i.addonId}" is no longer available — step removed`),null;const l=t.slots.flatMap(u=>u.addons).find(u=>u.id===i.addonId);let c=i.modelId;if(l&&!l.models.some(u=>u.id===c)){const u=l.defaultModelId;r.push(`Model "${c}" not available for ${i.addonId} — using "${u}"`),c=u}const d=i.children.map(u=>s(u)).filter(u=>u!==null);return{...i,modelId:c,children:d}}const a=e.map(i=>s(i)).filter(i=>i!==null);return{valid:r.length===0,steps:a,warnings:r}}function AM(e){const t=new Map;for(const n of e.slots)for(const r of n.addons)t.set(r.id,r);return t}function Ei(e){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:!0,modelId:e.defaultModelId,children:[]}}function Ii({addon:e,onClick:t}){return o("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:f("div",{className:"flex items-center gap-3",children:[o(F5,{className:"h-[18px] w-[18px] text-foreground-subtle/30 group-hover:text-primary/60 shrink-0"}),f("div",{className:"flex-1 min-w-0",children:[o("span",{className:"text-[13px] font-medium text-foreground-subtle/50 group-hover:text-foreground-subtle block truncate",children:e.name}),f("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(n=>o("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&&o("span",{className:"text-foreground-subtle/25 text-[10px]",children:"→"}),e.outputClasses.map(n=>o("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 Jc({schema:e,steps:t,onChange:n,templates:r,selectedTemplateId:s,onSelectTemplate:a,onSaveTemplate:i,onUpdateTemplate:l,onDeleteTemplate:c,readOnly:d=!1,excludeAddons:u=[],hideTemplates:p=!1,showOnlyEnabled:h=!1,showSlotLabels:m=!1,toggleMode:g="simple",overrides:b={},onOverrideChange:x,inheritedEnabledByAddon:y={},hideModelAndSettings:w=!1}){const v=V=>({toggleMode:g,hideModelAndSettings:w,...g==="threeState"?{overrideState:b[V]!==void 0?b[V]:null,onOverrideChange:x?$=>x(V,$):void 0,inheritedEnabled:y[V]}:{}}),N=H(()=>new Set(u),[u]),k=H(()=>AM(e),[e]),[C,E]=_([]),I=s?JSON.stringify(t)!==JSON.stringify(r.find(V=>V.id===s)?.steps):!1;function A(V){const $=V.target.value||null;if($){const q=r.find(G=>G.id===$);if(q){const G=IM(q.steps,e);E([...G.warnings])}}else E([]);a($)}function z(){s&&l(s,t)}function P(){const V=window.prompt("Template name:");V?.trim()&&i(V.trim(),t)}function B(){if(!s)return;const V=r.find($=>$.id===s);V&&window.confirm(`Delete template "${V.name}"?`)&&c(s)}function R(V){n(t.map($=>$.addonId!==V.addonId?$:M(V)))}function M(V){const $=V.children.some(q=>q.enabled||q.children.some(G=>G.enabled));return{...V,enabled:V.enabled||$,children:V.children.map(q=>{const G=q.children.some(Z=>Z.enabled);return{...q,enabled:q.enabled||G}})}}function D(V,$){const q=Ei($);n(t.map(G=>G.addonId!==V?G:{...G,children:[...G.children,q]}))}function T(V){const $=new Set;for(const q of V){$.add(q.addonId);for(const Z of q.children)$.add(Z.addonId);const G=T(q.children);for(const Z of G)$.add(Z)}return $}const L=T(t);function O(V){const $=k.get(V.addonId);if(!$)return[];const G=e.slots.find(X=>X.id===$.slot)?.parentSlot==null,Z=$.childSlots,oe=new Set(V.children.map(X=>X.addonId)),ne=[];for(const X of e.slots)if(Z.includes(X.id))for(const re of X.addons){if(oe.has(re.id)||N.has(re.id))continue;const be=re.inputClasses.length===0;if(be&&!G)continue;(be||re.inputClasses.some(W=>V.outputClasses.includes(W)))&&ne.push(re)}return ne}function F(V){const $=h?{...V,children:V.children.filter(G=>G.enabled).map(G=>({...G,children:G.children.filter(Z=>Z.enabled)}))}:V,q=h?[]:O($);return f("div",{className:"space-y-1.5",children:[o(Fs,{step:$,schema:k.get($.addonId)??null,allSchemas:k,onChange:R,onDelete:d?void 0:G=>n(t.filter(Z=>Z.addonId!==G)),readOnly:d,...v($.addonId)}),($.children.length>0||q.length>0)&&f("div",{className:"ml-4 pl-3 border-l border-border/60 space-y-1.5",children:[m&&o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/40",children:"Slot: Cropper / Classifier"}),$.children.map(G=>{const Z=O(G);return f("div",{className:"space-y-1.5",children:[o(Fs,{step:G,schema:k.get(G.addonId)??null,allSchemas:k,depth:1,onChange:oe=>{R({...$,children:$.children.map(ne=>ne.addonId===oe.addonId?oe:ne)})},onDelete:d?void 0:oe=>{R({...$,children:$.children.filter(ne=>ne.addonId!==oe)})},readOnly:d,...v(G.addonId)}),(G.children.length>0||Z.length>0)&&f("div",{className:"ml-4 pl-3 border-l border-border/40 space-y-1.5",children:[m&&o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/30",children:"Slot: Recognizer"}),G.children.map(oe=>o(Fs,{step:oe,schema:k.get(oe.addonId)??null,allSchemas:k,depth:2,onChange:ne=>{R({...$,children:$.children.map(X=>X.addonId===G.addonId?{...X,children:X.children.map(re=>re.addonId===ne.addonId?ne:re)}:X)})},onDelete:d?void 0:ne=>{R({...$,children:$.children.map(X=>X.addonId===G.addonId?{...X,children:X.children.filter(re=>re.addonId!==ne)}:X)})},readOnly:d,...v(oe.addonId)},oe.addonId)),!d&&Z.map(oe=>o(Ii,{addon:oe,onClick:()=>{const ne=Ei(oe);R({...$,children:$.children.map(X=>X.addonId===G.addonId?{...X,children:[...X.children,ne]}:X)})}},oe.id))]})]},G.addonId)}),!d&&q.map(G=>o(Ii,{addon:G,onClick:()=>D($.addonId,G)},G.id))]})]},$.addonId)}const j=e.slots.filter(V=>V.parentSlot===null).sort((V,$)=>V.priority-$.priority);return f("div",{className:"space-y-4",children:[!p&&o("div",{className:"rounded-lg border border-border bg-surface p-3",children:f("div",{className:"flex items-center gap-2",children:[o("div",{className:"relative flex-1 min-w-0",children:f("select",{value:s??"",onChange:A,className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:border-primary/50",children:[o("option",{value:"",children:"No template"}),r.map(V=>o("option",{value:V.id,children:V.name},V.id))]})}),I&&o("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500 shrink-0"}),o("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:o(GS,{className:"h-4 w-4"})}),o("button",{onClick:P,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:o(U5,{className:"h-4 w-4"})}),o("button",{onClick:B,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:o(Zt,{className:"h-4 w-4"})})]})}),C.length>0&&f("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 text-xs text-amber-400 space-y-1",children:[f("div",{className:"flex items-center justify-between",children:[o("span",{className:"font-medium",children:"Template loaded with warnings:"}),o("button",{onClick:()=>E([]),className:"text-amber-400/60 hover:text-amber-400",children:o(Je,{className:"h-3.5 w-3.5"})})]}),C.map((V,$)=>f("div",{children:["• ",V]},$))]}),j.map(V=>{const $=t.filter(ne=>ne.slot===V.id&&!N.has(ne.addonId)),q=h?$.filter(ne=>ne.enabled):$,G=h?[]:V.addons.filter(ne=>!L.has(ne.id)&&!N.has(ne.id)),Z=new Map,oe=[];for(const ne of q)ne.group?(Z.has(ne.group)||Z.set(ne.group,[]),Z.get(ne.group).push(ne)):oe.push(ne);return f("div",{className:"space-y-2",children:[m&&f("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50",children:["Slot: ",V.label]}),oe.map(ne=>F(ne)),[...Z.entries()].map(([ne,X])=>f("div",{className:"space-y-2 rounded-lg border border-border/40 p-2",children:[o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50 px-1",children:ne}),X.map(re=>F(re))]},ne)),!d&&G.map(ne=>o(Ii,{addon:ne,onClick:()=>{n([...t,Ei(ne)])}},ne.id))]},V.id)})]})}const po={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"},hp=["#ef4444","#8b5cf6","#06b6d4","#f97316","#10b981","#6366f1","#e11d48","#0891b2","#7c3aed","#059669"],nb="#f59e42";function mt(e,t){if(t?.[e])return t[e];if(t?.[e.toLowerCase()])return t[e.toLowerCase()];if(po[e])return po[e];if(po[e.toLowerCase()])return po[e.toLowerCase()];let n=0;for(let r=0;r<e.length;r++)n=n*31+(e.codePointAt(r)??0)>>>0;return hp[n%hp.length]??nb}function PM({src:e,imageWidth:t,imageHeight:n,detections:r=[],classColors:s,aspectRatio:a,className:i,placeholder:l,showConfidence:c=!0,minConfidence:d=0,borderWidth:u=2}){function p(y){return mt(y,s)}const h=a??(t&&n?`${t}/${n}`:"16/9"),m=r.filter(y=>y.score>=d),g=m.filter(y=>y.kind==="first-level"),b=m.filter(y=>y.kind==="detail"),x=DM(b,y=>y.parentId??"");return o("div",{className:K("rounded-lg border border-border bg-surface overflow-hidden relative",i),style:{aspectRatio:h},children:e?f(me,{children:[o("img",{src:e,className:"absolute inset-0 w-full h-full object-fill",alt:""}),m.map((y,w)=>y.debug?.mask&&y.debug.maskWidth&&y.debug.maskHeight?o(_M,{mask:y.debug.mask,maskWidth:y.debug.maskWidth,maskHeight:y.debug.maskHeight,bbox:y.bbox,imageWidth:t,imageHeight:n,color:p(y.macroClass)},`mask-${w}`):null),g.map(y=>{const w=x.get(y.id)??[];return o(mp,{detection:y,imageWidth:t,imageHeight:n,color:p(y.macroClass),showConfidence:c,borderWidth:y.debug?.mask?1:u,children:w.map(v=>o($M,{child:v,parentBbox:y.bbox,color:p(v.macroClass),showConfidence:c},`child-${v.id}`))},`det-${y.id}`)}),b.filter(y=>!y.parentId||!g.some(w=>w.id===y.parentId)).map(y=>o(mp,{detection:y,imageWidth:t,imageHeight:n,color:p(y.macroClass),showConfidence:c,borderWidth:u},`orphan-${y.id}`))]}):o("div",{className:"w-full h-full flex items-center justify-center text-foreground-subtle text-sm",children:l??"No image loaded"})})}function mp({detection:e,imageWidth:t,imageHeight:n,color:r,showConfidence:s,borderWidth:a,children:i}){const{x:l,y:c,width:d,height:u}=e.bbox,p=f("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"2px"},children:[f("span",{className:"text-[10px] px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:r},children:[e.macroClass,s&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((h,m)=>f("span",{className:"text-[9px] font-semibold px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:mt(h.label)},children:[h.label," ",(h.score*100).toFixed(0),"%"]},`${e.id}-lbl-${m}`))]});return f("div",{className:"absolute rounded-sm",style:{left:`${l/t*100}%`,top:`${c/n*100}%`,width:`${d/t*100}%`,height:`${u/n*100}%`,borderWidth:`${a}px`,borderStyle:"solid",borderColor:r},children:[p,i]})}function _M({mask:e,maskWidth:t,maskHeight:n,bbox:r,imageWidth:s,imageHeight:a,color:i}){const l=te(null);return Y(()=>{const c=l.current;if(!c)return;const d=c.getContext("2d");if(!d)return;const u=atob(e),p=new Uint8Array(u.length);for(let y=0;y<u.length;y++)p[y]=u.charCodeAt(y);const h=parseInt(i.slice(1,3),16),m=parseInt(i.slice(3,5),16),g=parseInt(i.slice(5,7),16);c.width=t,c.height=n;const b=d.createImageData(t,n),x=t*n;for(let y=0;y<x;y++){const w=y<p.length?p[y]:0,v=y*4;w>0&&(b.data[v]=h,b.data[v+1]=m,b.data[v+2]=g,b.data[v+3]=120)}d.putImageData(b,0,0)},[e,t,n,i]),o("canvas",{ref:l,className:"absolute pointer-events-none",style:{left:`${r.x/s*100}%`,top:`${r.y/a*100}%`,width:`${r.width/s*100}%`,height:`${r.height/a*100}%`,imageRendering:"pixelated"}})}function $M({child:e,parentBbox:t,color:n,showConfidence:r}){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 o("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:f("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"1px"},children:[f("span",{className:"text-[9px] px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:n},children:[e.macroClass,r&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((c,d)=>f("span",{className:"text-[8px] font-semibold px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:mt(c.label)},children:[c.label," ",(c.score*100).toFixed(0),"%"]},`${e.id}-lbl-${d}`))]})})}function DM(e,t){const n=new Map;for(const r of e){const s=t(r),a=n.get(s)??[];a.push(r),n.set(s,a)}return n}function TM({detections:e,classColors:t,className:n,hiddenKeys:r,onToggleVisibility:s}){const a=t;if(e.length===0)return o("div",{className:"text-sm text-foreground-subtle italic text-center py-4",children:"No detections"});const i=e.filter(u=>u.kind==="first-level"),l=e.filter(u=>u.kind==="detail"),c=new Map;for(const u of l){if(!u.parentId)continue;const p=c.get(u.parentId)??[];p.push(u),c.set(u.parentId,p)}const d=l.filter(u=>!u.parentId||!i.some(p=>p.id===u.parentId));return f("div",{className:n,children:[f("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Detections (",e.length,")"]}),f("div",{className:"space-y-2",children:[i.map(u=>o(gp,{detection:u,children_:c.get(u.id)??[],colors:a,hiddenKeys:r,onToggleVisibility:s},u.id)),d.map(u=>o(gp,{detection:u,children_:[],colors:a,hiddenKeys:r,onToggleVisibility:s},u.id))]})]})}function gp({detection:e,children_:t,colors:n,hiddenKeys:r,onToggleVisibility:s}){const a=mt(e.macroClass,n),i=!r?.has(e.id),l=e.debug?.mask,c=e.debug?.maskWidth,d=e.debug?.maskHeight,u=e.debug?.alternateLabels;return f("div",{className:`rounded-md border border-border bg-surface p-3 space-y-1 ${i?"":"opacity-40"}`,children:[f("div",{className:"flex justify-between items-center",children:[f("div",{className:"flex items-center gap-2",children:[s&&o("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"}),o("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:a}}),o("span",{className:"text-sm font-medium text-foreground",children:e.macroClass}),e.kind==="detail"&&o("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:"detail"}),l&&c&&d&&f("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",c,"x",d]})]}),o(OM,{confidence:e.score})]}),f("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&&o("div",{className:"flex flex-wrap gap-1 mt-1",children:e.labels.map((p,h)=>f("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{backgroundColor:mt(p.label,n)+"20",color:mt(p.label,n)},children:[p.label,f("span",{className:"opacity-60",children:[(p.score*100).toFixed(0),"%"]}),p.detectionId&&f("span",{className:"opacity-40 text-[8px]",children:["→ ",p.detectionId]})]},h))}),u&&Object.keys(u).length>0&&o(RM,{alternateLabels:u,colors:n}),t.length>0&&o(LM,{items:t,colors:n,hiddenKeys:r,onToggleVisibility:s})]})}function LM({items:e,colors:t,hiddenKeys:n,onToggleVisibility:r}){return o("div",{className:"ml-4 mt-1.5 space-y-1.5 border-l-2 border-border pl-3",children:e.map(s=>{const a=mt(s.macroClass,t),i=!n?.has(s.id),l=s.debug?.mask,c=s.debug?.maskWidth,d=s.debug?.maskHeight;return f("div",{className:`text-xs space-y-0.5 ${i?"":"opacity-40"}`,children:[f("div",{className:"flex items-center gap-1.5",children:[r&&o("input",{type:"checkbox",checked:i,onChange:()=>r(s.id,!i),className:"h-3 w-3 rounded border-border accent-primary cursor-pointer shrink-0"}),o("span",{className:"h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:a}}),o("span",{className:"font-medium",style:{color:a},children:s.macroClass}),f("span",{className:"text-foreground-subtle",children:[(s.score*100).toFixed(0),"%"]}),l&&c&&d&&f("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&&o("div",{className:"flex flex-wrap gap-1 ml-5 mt-0.5",children:s.labels.map((u,p)=>f("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-medium px-1 py-0.5 rounded-full",style:{backgroundColor:mt(u.label,t)+"20",color:mt(u.label,t)},children:[u.label," ",f("span",{className:"opacity-60",children:[(u.score*100).toFixed(0),"%"]})]},p))})]},s.id)})})}function RM({alternateLabels:e,colors:t}){const[n,r]=_(!1),s=Object.keys(e);return f("div",{className:"mt-1",children:[f("button",{onClick:()=>r(a=>!a),className:"text-[9px] text-foreground-subtle hover:text-foreground transition-colors flex items-center gap-1",children:[o("span",{className:`transition-transform ${n?"rotate-90":""}`,children:"▶"}),"Alternates (",s.length," source",s.length!==1?"s":"",")"]}),n&&o("div",{className:"mt-1 ml-3 space-y-1.5",children:s.map(a=>{const i=e[a];return!i||i.length===0?null:f("div",{children:[o("div",{className:"text-[9px] font-medium text-foreground-subtle mb-0.5",children:a}),o("div",{className:"flex flex-wrap gap-1",children:i.map((l,c)=>f("span",{className:"inline-flex items-center gap-0.5 text-[9px] px-1 py-0.5 rounded-full",style:{backgroundColor:mt(a,t)+"10",color:mt(a,t),opacity:Math.max(.4,l.score)},children:[l.label,f("span",{className:"opacity-60",children:[(l.score*100).toFixed(1),"%"]})]},c))})]},a)})})]})}function OM({confidence:e}){const t=e>=.8?"bg-success/10 text-success":e>=.5?"bg-warning/10 text-warning":"bg-danger/10 text-danger";return f("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${t}`,children:[(e*100).toFixed(1),"%"]})}function BM({timings:e,totalMs:t,className:n}){const r=Object.entries(e);return r.length===0&&t===void 0?null:f("div",{className:`rounded-lg border border-border bg-surface p-3 space-y-2 ${n??""}`,children:[o("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide",children:"Timings"}),f("div",{className:"space-y-1 text-xs",children:[r.map(([s,a])=>f("div",{className:"flex justify-between",children:[o("span",{className:"text-foreground-subtle",children:s}),f("span",{className:"font-mono text-foreground",children:[a.toFixed(1),"ms"]})]},s)),t!==void 0&&f("div",{className:"flex justify-between pt-1 border-t border-border font-medium text-foreground",children:[o("span",{children:"Total"}),f("span",{className:"font-mono",children:[t.toFixed(1),"ms"]})]})]})]})}function zM({images:e,selectedFilename:t,uploadedName:n,onSelect:r,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 u=d.files?.[0];if(!u)return;const p=new FileReader;p.onload=()=>{const h=p.result,m=h.split(",")[1];m&&s(m,u.name,h)},p.readAsDataURL(u)},d.click()};return f("div",{className:`flex flex-wrap items-center gap-2 ${a??""}`,children:[e.map(d=>o("button",{onClick:()=>r(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)),o("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&&o("span",{className:"text-xs text-foreground-subtle",children:n})]})}const ps="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 FM({runtime:e,backend:t,modelId:n,agentId:r="hub",runtimes:s,backends:a,models:i,agents:l=[],onRuntimeChange:c,onBackendChange:d,onModelChange:u,onAgentChange:p,layout:h="grid",className:m,showAgent:g=!1}){return f("div",{className:`${h==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4":h==="horizontal"?"flex flex-wrap items-end gap-4":"space-y-3"} ${m??""}`,children:[g&&l.length>0&&f("label",{className:"space-y-1",children:[o("span",{className:"text-xs font-medium text-foreground-subtle",children:"Agent"}),o("select",{value:r,onChange:x=>p?.(x.target.value),className:ps,children:l.map(x=>f("option",{value:x.id,children:[x.name," (",x.status,")"]},x.id))})]}),f("label",{className:"space-y-1",children:[o("span",{className:"text-xs font-medium text-foreground-subtle",children:"Runtime"}),o("select",{value:e,onChange:x=>c(x.target.value),className:ps,children:s.map(x=>f("option",{value:x.value,disabled:!x.available,children:[x.label,x.available?"":" (unavailable)"]},x.value))})]}),f("label",{className:"space-y-1",children:[o("span",{className:"text-xs font-medium text-foreground-subtle",children:"Backend"}),o("select",{value:t,onChange:x=>d(x.target.value),className:ps,children:a.map(x=>f("option",{value:x.id,disabled:!x.available,children:[x.label,x.available?"":" (unavailable)"]},x.id))})]}),f("label",{className:"space-y-1",children:[o("span",{className:"text-xs font-medium text-foreground-subtle",children:"Model"}),o("select",{value:n,onChange:x=>u(x.target.value),className:ps,children:i.length===0?o("option",{value:"",children:"No compatible models"}):i.map(x=>f("option",{value:x.id,children:[x.name,x.downloaded?" ✓":""]},x.id))})]})]})}function jM({className:e}){return f("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:[o("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"}),o("circle",{cx:"12",cy:"12",r:"3"})]})}function VM({className:e}){return f("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:[o("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"}),o("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),o("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"}),o("path",{d:"m2 2 20 20"})]})}function HM({className:e}){return o("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:o("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}function rb({onLogin:e,serverUrl:t,logoSrc:n,error:r,className:s}){const[a,i]=_(""),[l,c]=_(""),[d,u]=_(!1),[p,h]=_(!1),[m,g]=_(null),b=r??m,x=async y=>{if(y.preventDefault(),!p){g(null),h(!0);try{await e(a,l)}catch(w){const v=w instanceof Error?w.message:"Login failed. Please try again.";g(v)}finally{h(!1)}}};return o("div",{className:K("flex min-h-screen items-center justify-center bg-background p-4",s),children:f("div",{className:"w-full max-w-sm",children:[n&&o("div",{className:"flex justify-center mb-8",children:o("img",{src:n,alt:"Logo",className:"h-12"})}),t&&o("p",{className:"mb-4 text-center text-xs text-foreground-subtle truncate",children:t}),f("form",{onSubmit:x,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[b&&o("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:b}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Username"}),o("input",{type:"text",value:a,onChange:y=>i(y.target.value),autoComplete:"username",required:!0,className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary"})]}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Password"}),f("div",{className:"relative",children:[o("input",{type:d?"text":"password",value:l,onChange:y=>c(y.target.value),autoComplete:"current-password",required:!0,className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary"}),o("button",{type:"button",onClick:()=>u(y=>!y),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",tabIndex:-1,children:d?o(VM,{className:"h-4 w-4"}):o(jM,{className:"h-4 w-4"})})]})]}),f("button",{type:"submit",disabled:p,className:"w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2",children:[p&&o(HM,{className:"h-4 w-4 animate-spin"}),p?"Logging in...":"Log in"]})]})]})})}const Ll="camstack_dev_token",ob=ze(null);function qM(){const e=ve(ob);if(!e)throw new Error("useDevShell must be used within a DevShell");return e}function UM(){return typeof window>"u"?null:localStorage.getItem(Ll)}function QM({className:e}){return f("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:[o("circle",{cx:"12",cy:"12",r:"4"}),o("path",{d:"M12 2v2"}),o("path",{d:"M12 20v2"}),o("path",{d:"m4.93 4.93 1.41 1.41"}),o("path",{d:"m17.66 17.66 1.41 1.41"}),o("path",{d:"M2 12h2"}),o("path",{d:"M20 12h2"}),o("path",{d:"m6.34 17.66-1.41 1.41"}),o("path",{d:"m19.07 4.93-1.41 1.41"})]})}function GM({className:e}){return o("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:o("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function KM({children:e,serverUrl:t,title:n,token:r,onLogout:s}){const a=Hr(),i=H(()=>{const h=t.replace(/^http/,"ws")+"/trpc",m=f2({url:h,connectionParams:()=>({token:r})});return[h2({condition:g=>g.type==="subscription",true:m2({client:m,transformer:kl}),false:cm({url:`${t}/trpc`,transformer:kl,headers:()=>({authorization:`Bearer ${r}`})})})]},[t,r]),l=H(()=>lm({links:i}),[i]),c=H(()=>S.createClient({links:i}),[i]),d=H(()=>fm({serverUrl:t,token:r}),[t,r]);Y(()=>(d.init().catch(()=>{}),()=>{d.close()}),[d]);const u=H(()=>new sm,[]),p=H(()=>({trpc:l,token:r,logout:s}),[l,r,s]);return o(Gc,{system:d,children:o(S.Provider,{client:c,queryClient:u,children:o(am,{client:u,children:o(ob.Provider,{value:p,children:f("div",{className:"min-h-screen bg-background text-foreground",children:[f("div",{className:"flex items-center justify-between border-b border-border bg-surface px-4 py-2",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"rounded bg-warning/20 px-2 py-0.5 text-xs font-bold text-warning",children:"DEV MODE"}),n&&o("span",{className:"text-sm font-medium text-foreground",children:n}),o("span",{className:"text-xs text-foreground-subtle",children:t})]}),f("div",{className:"flex items-center gap-2",children:[f("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"?o(QM,{className:"h-3.5 w-3.5"}):o(GM,{className:"h-3.5 w-3.5"}),a.mode==="dark"?"Dark":a.mode==="light"?"Light":"System"]}),o("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"})]})]}),o("div",{className:"p-4",children:e({trpc:l,theme:a})})]})})})})})}function sb({children:e,serverUrl:t="https://localhost:4443",title:n}){const[r,s]=_(UM),a=U(async(l,c)=>{const p=await lm({links:[cm({url:`${t}/trpc`,transformer:kl})]}).auth.login.mutate({username:l,password:c});if(!p.token)throw new Error("No token returned");localStorage.setItem(Ll,p.token),s(p.token)},[t]),i=U(()=>{localStorage.removeItem(Ll),s(null)},[]);return r?o(Zs,{children:o(KM,{serverUrl:t,title:n,token:r,onLogout:i,children:e})}):o(Zs,{children:o(rb,{onLogin:a,serverUrl:t})})}function WM(e,t={}){const{serverUrl:n="https://localhost:4443",title:r,rootId:s="root"}=t,a=document.getElementById(s);if(!a){console.error(`[mountAddonPage] Element #${s} not found`);return}rm(a).render(Ee(sb,{serverUrl:n,title:r,children:({trpc:i,theme:l})=>Ee(e,{trpc:i,theme:{isDark:l.resolvedMode==="dark"},navigate:c=>{console.log("[dev] navigate:",c)}})}))}const ab=xn("camstack:custom-field-renderers",{});function ib({renderers:e,children:t}){return o(ab.Provider,{value:e,children:t})}function lb(e){return ve(ab)[e]??null}const ed=xn("camstack:device-context",null);function cb({deviceId:e,device:t,children:n}){const r={deviceId:e,device:t??null};return o(ed.Provider,{value:r,children:n})}function vn(){return ve(ed)?.deviceId??null}function td(){return ve(ed)?.device??null}const YM=S.accessories.getStatus.useQuery,nd=S.addonPages.listPages.useQuery,wn=S.addons.list.useQuery,ZM=S.addons.getLogs.useQuery,XM=S.addons.listPackages.useQuery,rd=S.addons.installPackage.useMutation,JM=S.addons.installFromWorkspace.useMutation,eE=S.addons.isWorkspaceAvailable.useQuery,tE=S.addons.listWorkspacePackages.useQuery,db=S.addons.uninstallPackage.useMutation,ub=S.addons.reloadPackages.useMutation,pb=S.addons.searchAvailable.useQuery,od=S.addons.listUpdates.useQuery,Rl=S.addons.updatePackage.useMutation,nE=S.addons.rollbackPackage.useMutation,fb=S.addons.forceRefresh.useMutation,hb=S.addons.restartServer.useMutation,mb=S.addons.getLastRestart.useQuery,gb=S.addons.listFrameworkPackages.useQuery,Go=S.addons.listCapabilityProviders.useQuery,bb=S.addons.setCapabilityProviderEnabled.useMutation,xb=S.addons.updateFrameworkPackage.useMutation,yb=S.addons.getVersions.useQuery,Ko=S.addons.restartAddon.useMutation,vb=S.addons.retryLoad.useMutation,wb=S.addons.getAutoUpdateSettings.useQuery,rE=S.addons.setAutoUpdateSettings.useMutation,Nb=S.addons.getAddonAutoUpdate.useQuery,kb=S.addons.setAddonAutoUpdate.useMutation,Sb=S.addons.applyAutoUpdateToAll.useMutation,oE=S.addons.custom.useMutation,sE=S.addons.onAddonLogs.useSubscription,sd=S.addonSettings.getGlobalSettings.useQuery,Cb=S.addonSettings.updateGlobalSettings.useMutation,aE=S.addonSettings.getDeviceSettings.useQuery,Mb=S.addonSettings.updateDeviceSettings.useMutation,Eb=S.addonWidgets.listWidgets.useQuery,iE=S.alerts.emit.useMutation,lE=S.alerts.update.useMutation,Ib=S.alerts.list.useQuery,Ab=S.alerts.getUnreadCount.useQuery,Pb=S.alerts.markRead.useMutation,_b=S.alerts.markAllRead.useMutation,$b=S.alerts.dismiss.useMutation,cE=S.audioAnalysis.resolveDeviceSettings.useQuery,dE=S.audioAnalysis.getDeviceSettingsContribution.useQuery,uE=S.audioAnalysis.getDeviceLiveContribution.useQuery,pE=S.audioAnalysis.applyDeviceSettingsPatch.useMutation,fE=S.audioAnalyzer.analyseChunk.useMutation,hE=S.audioAnalyzer.classify.useQuery,mE=S.audioAnalyzer.isReady.useQuery,gE=S.audioAnalyzer.dispose.useMutation,Db=S.audioAnalyzer.reprobeAudioEngine.useMutation,bE=S.audioCodec.listSupportedCodecs.useQuery,xE=S.audioCodec.canHandle.useQuery,yE=S.audioCodec.createDecodeSession.useMutation,vE=S.audioCodec.createEncodeSession.useMutation,wE=S.audioCodec.closeSession.useMutation,NE=S.audioCodec.pushEncodedFrame.useMutation,kE=S.audioCodec.pullPcm.useQuery,SE=S.audioCodec.pushPcm.useMutation,CE=S.audioCodec.pullEncoded.useQuery,ME=S.audioCodec.flushEncode.useMutation,EE=S.audioCodec.listActiveSessions.useQuery,IE=S.audioMetrics.getCurrentSnapshot.useQuery,AE=S.audioMetrics.getHistory.useQuery,ad=S.backup.listDestinations.useQuery,Tb=S.backup.trigger.useMutation,PE=S.backup.list.useQuery,Lb=S.backup.listLocations.useQuery,Rb=S.backup.getEntries.useQuery,Ob=S.backup.restore.useMutation,Bb=S.backup.delete.useMutation,id=S.backup.listArchives.useQuery,zb=S.backup.upsertDestinationPolicy.useMutation,Fb=S.backup.previewSchedule.useQuery,_E=S.battery.getStatus.useQuery,$E=S.brightness.setBrightness.useMutation,DE=S.brightness.getStatus.useQuery,TE=S.cameraCredentials.getCredentials.useQuery,LE=S.cameraCredentials.getStatus.useQuery,RE=S.cameraStreams.getCameraStreams.useQuery,OE=S.cameraStreams.getBrokerStreams.useQuery,jb=S.cameraStreams.getRtspEntries.useQuery,BE=S.decoder.supportsCodec.useQuery,zE=S.decoder.getInfo.useQuery,FE=S.decoder.createSession.useQuery,jE=S.decoder.destroySession.useQuery,VE=S.decoder.pushPacket.useQuery,HE=S.decoder.openStream.useQuery,qE=S.decoder.pullFrames.useQuery,UE=S.decoder.updateConfig.useQuery,QE=S.decoder.getStats.useQuery,GE=S.decoder.listActiveSessions.useQuery,Vb=S.decoder.reprobeHwaccel.useMutation,KE=S.detectionPipeline.getDeviceSettingsContribution.useQuery,WE=S.detectionPipeline.getDeviceLiveContribution.useQuery,YE=S.detectionPipeline.applyDeviceSettingsPatch.useMutation,Hb=S.deviceDiscovery.listDiscovered.useQuery,qb=S.deviceDiscovery.refreshDiscovery.useMutation,ZE=S.deviceDiscovery.adoptDevice.useMutation,XE=S.deviceDiscovery.releaseDevice.useMutation,JE=S.deviceDiscovery.getStatus.useQuery,ld=S.deviceExport.getStatus.useQuery,e4=S.deviceExport.listSupportedDeviceKinds.useQuery,Ub=S.deviceExport.listExposedDevices.useQuery,t4=S.deviceExport.exposeDevice.useMutation,Qb=S.deviceExport.unexposeDevice.useMutation,n4=S.deviceExport.getDeviceSettingsContribution.useQuery,r4=S.deviceExport.getDeviceLiveContribution.useQuery,o4=S.deviceExport.applyDeviceSettingsPatch.useMutation,s4=S.deviceManager.allocateDeviceId.useMutation,a4=S.deviceManager.registerDevice.useMutation,i4=S.deviceManager.removeDevice.useMutation,l4=S.deviceManager.persistConfig.useMutation,c4=S.deviceManager.loadConfig.useQuery,d4=S.deviceManager.loadRuntimeState.useQuery,u4=S.deviceManager.loadMeta.useQuery,Gb=S.deviceManager.setName.useMutation,Kb=S.deviceManager.setLocation.useMutation,p4=S.deviceManager.setMetadata.useMutation,Wb=S.deviceManager.listLocations.useQuery,f4=S.deviceManager.addLocation.useMutation,h4=S.deviceManager.removeLocation.useMutation,m4=S.deviceManager.setDisabled.useMutation,g4=S.deviceManager.listPersistedByAddon.useQuery,Bn=S.deviceManager.listAll.useQuery,er=S.deviceManager.getDevice.useQuery,Yb=S.deviceManager.getChildren.useQuery,b4=S.deviceManager.getStreamSources.useQuery,x4=S.deviceManager.getConfigSchema.useQuery,y4=S.deviceManager.getSettingsSchema.useQuery,v4=S.deviceManager.updateConfig.useMutation,Zb=S.deviceManager.enable.useMutation,Xb=S.deviceManager.disable.useMutation,Jb=S.deviceManager.remove.useMutation,w4=S.deviceManager.getStreamProfileMap.useQuery,N4=S.deviceManager.setStreamProfileMap.useMutation,k4=S.deviceManager.probeStreams.useMutation,ex=S.deviceManager.getBindings.useQuery,S4=S.deviceManager.getAllBindings.useQuery,tx=S.deviceManager.setWrapperActive.useMutation,C4=S.deviceManager.listWrappersForCap.useQuery,nx=S.deviceManager.listBindableCapsForDeviceType.useQuery,M4=S.deviceManager.getDeviceSettingsAggregate.useQuery,E4=S.deviceManager.getDeviceLiveInfoAggregate.useQuery,cd=S.deviceManager.getDeviceAggregate.useQuery,I4=S.deviceManager.updateDeviceField.useMutation,rx=S.deviceManager.updateDeviceFieldsBatch.useMutation,dd=S.deviceManager.discoverDevices.useMutation,ox=S.deviceManager.adoptDevice.useMutation,sx=S.deviceManager.getCreationSchema.useQuery,ax=S.deviceManager.createDevice.useMutation,ud=S.deviceManager.testCreationField.useMutation,A4=S.deviceManager.testField.useMutation,P4=S.deviceManager.getDeviceStatusAggregate.useQuery,_4=S.deviceOps.getStreamSources.useQuery,$4=S.deviceOps.getConfigEntries.useQuery,D4=S.deviceOps.setConfig.useMutation,T4=S.deviceOps.removeDevice.useMutation,L4=S.deviceOps.getSettingsSchema.useQuery,R4=S.deviceProvider.start.useMutation,O4=S.deviceProvider.stop.useMutation,B4=S.deviceProvider.getStatus.useQuery,z4=S.deviceProvider.getDevices.useQuery,F4=S.deviceProvider.supportsDiscovery.useQuery,j4=S.deviceProvider.discoverDevices.useMutation,V4=S.deviceProvider.adoptDiscoveredDevice.useMutation,H4=S.deviceProvider.supportsManualCreation.useQuery,q4=S.deviceProvider.getChildCreationSchema.useQuery,U4=S.deviceProvider.createDevice.useMutation,Q4=S.deviceProvider.testCreationField.useMutation,G4=S.deviceState.getSnapshot.useQuery,K4=S.deviceState.getCapSlice.useQuery,W4=S.deviceState.getAllSnapshots.useQuery,Y4=S.deviceState.setCapSlice.useMutation,Z4=S.deviceStatus.getStatus.useQuery,X4=S.doorbell.getStatus.useQuery,J4=S.events.getEvents.useQuery,eI=S.events.getEventThumbnail.useQuery,tI=S.events.getEventClipUrl.useQuery,nI=S.featureProbe.getStatus.useQuery,pd=S.integrations.list.useQuery,ix=S.integrations.get.useQuery,lx=S.integrations.getByAddonId.useQuery,cx=S.integrations.create.useMutation,dx=S.integrations.update.useMutation,ux=S.integrations.delete.useMutation,rI=S.integrations.getSettings.useQuery,oI=S.integrations.setSettings.useMutation,px=S.integrations.getAvailableTypes.useQuery,fx=S.integrations.testConnection.useMutation,hx=S.intercom.startSession.useMutation,mx=S.intercom.handleAnswer.useMutation,gx=S.intercom.stopSession.useMutation,sI=S.intercom.startTalkSession.useMutation,aI=S.intercom.pushTalkPcm.useMutation,iI=S.intercom.endTalkSession.useMutation,lI=S.intercom.getStatus.useQuery,bx=S.localNetwork.list.useQuery,cI=S.localNetwork.getPreferred.useQuery,xx=S.localNetwork.getConnectionEndpoints.useQuery,yx=S.localNetwork.getAllowedAddresses.useQuery,vx=S.localNetwork.setAllowedAddresses.useMutation,wx=S.localNetwork.resetAllowlistToBestMatch.useMutation,Nx=S.meshNetwork.getStatus.useQuery,dI=S.meshNetwork.join.useMutation,kx=S.meshNetwork.startLogin.useMutation,Sx=S.meshNetwork.leave.useMutation,Cx=S.meshNetwork.logout.useMutation,Mx=S.meshNetwork.listPeers.useQuery,uI=S.meshNetwork.testConnection.useMutation,pI=S.metricsProvider.collectSnapshot.useQuery,fI=S.metricsProvider.getCached.useQuery,hI=S.metricsProvider.getCurrent.useQuery,mI=S.metricsProvider.getDiskSpace.useQuery,gI=S.metricsProvider.getGpuInfo.useQuery,bI=S.metricsProvider.getCpuTemperature.useQuery,xI=S.metricsProvider.getProcessStats.useQuery,yI=S.metricsProvider.listAddonInstances.useQuery,vI=S.metricsProvider.getAddonStats.useQuery,Ex=S.metricsProvider.listNodeProcesses.useQuery,Ix=S.metricsProvider.killProcess.useMutation,wI=S.motion.isDetected.useQuery,NI=S.motion.getStatus.useQuery,kI=S.motionDetection.analyze.useMutation,SI=S.motionDetection.removeCamera.useMutation,CI=S.motionDetection.reset.useMutation,MI=S.motionDetection.getDeviceSettingsContribution.useQuery,EI=S.motionDetection.getDeviceLiveContribution.useQuery,II=S.motionDetection.applyDeviceSettingsPatch.useMutation,AI=S.motionTrigger.setMotionTrigger.useMutation,PI=S.motionTrigger.getStatus.useQuery,_I=S.mqttBroker.listBrokers.useQuery,$I=S.mqttBroker.getBrokerConfig.useQuery,DI=S.mqttBroker.addBroker.useMutation,TI=S.mqttBroker.removeBroker.useMutation,LI=S.mqttBroker.testConnection.useMutation,RI=S.mqttBroker.startEmbeddedBroker.useMutation,OI=S.mqttBroker.stopEmbeddedBroker.useMutation,Ax=S.mqttBroker.getStatus.useQuery,BI=S.nativeObjectDetection.getStatus.useQuery,Px=S.networkAccess.start.useMutation,_x=S.networkAccess.stop.useMutation,zI=S.networkAccess.getEndpoint.useQuery,$x=S.networkAccess.getStatus.useQuery,FI=S.networkAccess.listEndpoints.useQuery,fd=S.networkQuality.getDeviceStats.useQuery,jI=S.networkQuality.getAllStats.useQuery,VI=S.networkQuality.reportClientStats.useMutation,zn=S.nodes.topology.useQuery,HI=S.nodes.deployAddon.useMutation,Dx=S.nodes.undeployAddon.useMutation,Ba=S.nodes.restartAddon.useMutation,Tx=S.nodes.restartProcess.useMutation,Lx=S.nodes.restartNode.useMutation,qI=S.nodes.shutdownNode.useMutation,Rx=S.nodes.renameNode.useMutation,Ox=S.nodes.clusterAddonStatus.useQuery,Bx=S.nodes.getNodeAddons.useQuery,zx=S.nodes.setProcessLogLevel.useMutation,UI=S.nodes.executeQuery.useMutation,QI=S.notificationOutput.send.useMutation,GI=S.notificationOutput.sendTest.useMutation,KI=S.osd.setOverlay.useMutation,WI=S.osd.getStatus.useQuery,YI=S.pipelineAnalytics.getActiveTracks.useQuery,ZI=S.pipelineAnalytics.getTrack.useQuery,XI=S.pipelineAnalytics.listTracks.useQuery,JI=S.pipelineAnalytics.clearTracks.useMutation,eA=S.pipelineAnalytics.getMotionEvents.useQuery,tA=S.pipelineAnalytics.getObjectEvents.useQuery,nA=S.pipelineAnalytics.getAudioEvents.useQuery,rA=S.pipelineAnalytics.getEventMedia.useQuery,oA=S.pipelineAnalytics.getTrackMedia.useQuery,sA=S.pipelineAnalytics.getDeviceSettingsContribution.useQuery,aA=S.pipelineAnalytics.getDeviceLiveContribution.useQuery,iA=S.pipelineAnalytics.applyDeviceSettingsPatch.useMutation,Fx=S.pipelineExecutor.getAvailableEngines.useQuery,jx=S.pipelineExecutor.getSelectedEngine.useQuery,lA=S.pipelineExecutor.getDefaultSteps.useQuery,Vx=S.pipelineExecutor.reprobeEngine.useMutation,cA=S.pipelineExecutor.getVideoPipelineSteps.useQuery,dA=S.pipelineExecutor.setVideoPipelineSteps.useMutation,Wo=S.pipelineExecutor.getSchema.useQuery,uA=S.pipelineExecutor.getGlobalSteps.useQuery,pA=S.pipelineExecutor.getGlobalPipelineConfig.useQuery,fA=S.pipelineExecutor.getOrchestratorConfigSchema.useQuery,hA=S.pipelineExecutor.listTemplates.useQuery,mA=S.pipelineExecutor.saveTemplate.useMutation,gA=S.pipelineExecutor.updateTemplate.useMutation,bA=S.pipelineExecutor.deleteTemplate.useMutation,xA=S.pipelineExecutor.getCapabilities.useQuery,yA=S.pipelineExecutor.getAddonModels.useQuery,Hx=S.pipelineExecutor.downloadModel.useMutation,qx=S.pipelineExecutor.deleteModel.useMutation,vA=S.pipelineExecutor.detect.useQuery,wA=S.pipelineExecutor.runPipeline.useMutation,NA=S.pipelineExecutor.runPipelineBatch.useMutation,kA=S.pipelineExecutor.cacheFrameInPool.useMutation,SA=S.pipelineExecutor.inferCached.useMutation,CA=S.pipelineExecutor.uncacheFrame.useMutation,MA=S.pipelineExecutor.getEffectiveTuning.useQuery,Ux=S.pipelineExecutor.listLoadedEngines.useQuery,EA=S.pipelineExecutor.spinEngine.useMutation,Qx=S.pipelineExecutor.killEngine.useMutation,IA=S.pipelineExecutor.listReferenceImages.useQuery,AA=S.pipelineExecutor.getReferenceImage.useQuery,PA=S.pipelineExecutor.getReferenceAudioFiles.useQuery,_A=S.pipelineExecutor.getReferenceAudio.useQuery,$A=S.pipelineExecutor.getAudioCapabilities.useQuery,DA=S.pipelineExecutor.runAudioTest.useMutation,TA=S.pipelineExecutor.getDetectionConfigSchema.useQuery,Gx=S.pipelineOrchestrator.assignPipeline.useMutation,Kx=S.pipelineOrchestrator.unassignPipeline.useMutation,Wx=S.pipelineOrchestrator.rebalance.useMutation,za=S.pipelineOrchestrator.getPipelineAssignments.useQuery,Fa=S.pipelineOrchestrator.getPipelineAssignment.useQuery,Yx=S.pipelineOrchestrator.getAgentLoad.useQuery,LA=S.pipelineOrchestrator.getGlobalMetrics.useQuery,RA=S.pipelineOrchestrator.getCameraMetrics.useQuery,Zx=S.pipelineOrchestrator.getCapabilityBindings.useQuery,Xx=S.pipelineOrchestrator.setCapabilityBinding.useMutation,Jx=S.pipelineOrchestrator.assignDecoder.useMutation,ey=S.pipelineOrchestrator.unassignDecoder.useMutation,ty=S.pipelineOrchestrator.getDecoderAssignments.useQuery,ny=S.pipelineOrchestrator.assignAudio.useMutation,ry=S.pipelineOrchestrator.unassignAudio.useMutation,OA=S.pipelineOrchestrator.getAudioAssignment.useQuery,oy=S.pipelineOrchestrator.getAudioNodeLoad.useQuery,sy=S.pipelineOrchestrator.getAudioAssignments.useQuery,BA=S.pipelineOrchestrator.getDecoderAssignment.useQuery,hd=S.pipelineOrchestrator.getAgentSettings.useQuery,Yr=S.pipelineOrchestrator.listAgentSettings.useQuery,md=S.pipelineOrchestrator.setAgentAddonDefaults.useMutation,ay=S.pipelineOrchestrator.removeAgentSettings.useMutation,gd=S.pipelineOrchestrator.getCameraSettings.useQuery,iy=S.pipelineOrchestrator.setCameraStepToggle.useMutation,zA=S.pipelineOrchestrator.getCameraStepOverrides.useQuery,ly=S.pipelineOrchestrator.setCameraStepOverride.useMutation,cy=S.pipelineOrchestrator.setCameraPipelineForAgent.useMutation,dy=S.pipelineOrchestrator.resolvePipeline.useQuery,uy=S.pipelineOrchestrator.listTemplates.useQuery,FA=S.pipelineOrchestrator.saveTemplate.useMutation,py=S.pipelineOrchestrator.updateTemplate.useMutation,fy=S.pipelineOrchestrator.deleteTemplate.useMutation,jA=S.pipelineOrchestrator.getDeviceSettingsContribution.useQuery,VA=S.pipelineOrchestrator.getDeviceLiveContribution.useQuery,HA=S.pipelineOrchestrator.applyDeviceSettingsPatch.useMutation,qA=S.pipelineRunner.attachCamera.useMutation,UA=S.pipelineRunner.detachCamera.useMutation,QA=S.pipelineRunner.reportMotion.useMutation,GA=S.pipelineRunner.getLocalLoad.useQuery,KA=S.pipelineRunner.getLocalMetrics.useQuery,bd=S.pipelineRunner.getCameraMetrics.useQuery,WA=S.pipelineRunner.getAllCameraMetrics.useQuery,hy=S.pipelineRunner.getLocalCameras.useQuery,YA=S.platformProbe.getCapabilities.useQuery,ZA=S.platformProbe.getHardware.useQuery,XA=S.platformProbe.resolveInferenceConfig.useQuery,JA=S.platformProbe.resolveHwAccel.useQuery,eP=S.platformProbe.getHardwareEncoders.useQuery,tP=S.platformProbe.refreshHardwareEncoders.useMutation,nP=S.ptz.move.useMutation,rP=S.ptz.continuousMove.useMutation,oP=S.ptz.stop.useMutation,sP=S.ptz.getPresets.useQuery,aP=S.ptz.goToPreset.useMutation,iP=S.ptz.goHome.useMutation,lP=S.ptz.getPosition.useQuery,cP=S.ptz.getStatus.useQuery,my=S.ptzAutotrack.getStatus.useQuery,gy=S.ptzAutotrack.setEnabled.useMutation,dP=S.ptzAutotrack.getSettings.useQuery,by=S.ptzAutotrack.setSettings.useMutation,xy=S.reboot.reboot.useMutation,uP=S.recording.getSegments.useQuery,pP=S.recording.getPlaybackUrl.useQuery,fP=S.recording.getThumbnailAt.useQuery,hP=S.recordingEngine.getStatus.useQuery,yy=S.recordingEngine.enable.useMutation,vy=S.recordingEngine.disable.useMutation,wy=S.recordingEngine.getConfig.useQuery,mP=S.recordingEngine.updateConfig.useMutation,gP=S.recordingEngine.getPlaylist.useQuery,bP=S.recordingEngine.getThumbnail.useQuery,Ny=S.recordingEngine.getSegments.useQuery,xP=S.recordingEngine.getAvailability.useQuery,yP=S.recordingEngine.estimateStorage.useQuery,vP=S.recordingEngine.estimateGlobalStorage.useQuery,ky=S.recordingEngine.getStorageUsage.useQuery,wP=S.recordingEngine.setPolicy.useMutation,NP=S.recordingEngine.getPolicy.useQuery,Sy=S.recordingEngine.getPolicyStatus.useQuery,Cy=S.recordingEngine.getRetentionConfig.useQuery,kP=S.recordingEngine.updateRetentionConfig.useMutation,SP=S.recordingEngine.getMotionStats.useQuery,CP=S.settingsStore.get.useQuery,MP=S.settingsStore.set.useMutation,EP=S.settingsStore.query.useQuery,IP=S.settingsStore.insert.useMutation,AP=S.settingsStore.update.useMutation,PP=S.settingsStore.delete.useMutation,_P=S.settingsStore.count.useQuery,$P=S.settingsStore.isEmpty.useQuery,DP=S.settingsStore.declareCollection.useMutation,TP=S.snapshot.getSnapshot.useQuery,LP=S.snapshot.invalidateCache.useMutation,RP=S.snapshot.getStatus.useQuery,OP=S.snapshot.getDeviceSettingsContribution.useQuery,BP=S.snapshot.getDeviceLiveContribution.useQuery,zP=S.snapshot.applyDeviceSettingsPatch.useMutation,FP=S.snapshotProvider.supportsDevice.useQuery,jP=S.snapshotProvider.getSnapshot.useQuery,VP=S.storage.resolve.useQuery,HP=S.storage.write.useMutation,qP=S.storage.read.useQuery,UP=S.storage.exists.useQuery,QP=S.storage.list.useQuery,GP=S.storage.delete.useMutation,KP=S.storage.getAvailableSpace.useQuery,WP=S.storage.beginUpload.useMutation,YP=S.storage.writeChunk.useMutation,ZP=S.storage.finalizeUpload.useMutation,XP=S.storage.abortUpload.useMutation,JP=S.storage.beginDownload.useMutation,e_=S.storage.readChunk.useQuery,t_=S.storage.endDownload.useMutation,My=S.storage.listLocations.useQuery,n_=S.storage.getDefaultLocation.useQuery,ja=S.storage.upsertLocation.useMutation,Ey=S.storage.deleteLocation.useMutation,r_=S.storage.testLocation.useQuery,xd=S.storage.listProviders.useQuery,o_=S.storage.testConfig.useQuery,s_=S.streamBroker.publishCameraStream.useMutation,a_=S.streamBroker.retractCameraStream.useMutation,i_=S.streamBroker.assignProfile.useMutation,l_=S.streamBroker.unassignProfile.useMutation,c_=S.streamBroker.listAllCameraStreams.useQuery,d_=S.streamBroker.listAllProfileSlots.useQuery,u_=S.streamBroker.getBrokerStats.useQuery,p_=S.streamBroker.listClients.useQuery,f_=S.streamBroker.killClient.useMutation,h_=S.streamBroker.restartProfile.useMutation,m_=S.streamBroker.getStreamUrl.useQuery,g_=S.streamBroker.getStreamWithCodec.useMutation,b_=S.streamBroker.releaseStreamWithCodec.useMutation,x_=S.streamBroker.getBroker.useQuery,y_=S.streamBroker.setPreBufferDuration.useMutation,v_=S.streamBroker.getPreBufferInfo.useQuery,w_=S.streamBroker.getRtspPort.useQuery,N_=S.streamBroker.getAllRtspEntries.useQuery,k_=S.streamBroker.getRtspEntry.useQuery,Iy=S.streamBroker.regenerateRtspToken.useMutation,S_=S.streamBroker.setRtspEnabled.useMutation,C_=S.streamBroker.isRtspEnabled.useQuery,M_=S.streamBroker.getDeviceSettingsContribution.useQuery,E_=S.streamBroker.getDeviceLiveContribution.useQuery,I_=S.streamBroker.applyDeviceSettingsPatch.useMutation,A_=S.switch.setState.useMutation,P_=S.switch.getStatus.useQuery,__=S.system.info.useQuery,$_=S.system.health.useQuery,D_=S.system.featureFlags.useQuery,T_=S.system.networkAddresses.useQuery,L_=S.system.getRetentionConfig.useQuery,R_=S.system.setRetentionConfig.useMutation,O_=S.system.forceRetentionCleanup.useMutation,Ay=S.toast.onToast.useSubscription,yd=S.turnProvider.getTurnServers.useQuery,vd=S.userManagement.listUsers.useQuery,Py=S.userManagement.createUser.useMutation,_y=S.userManagement.updateUser.useMutation,$y=S.userManagement.deleteUser.useMutation,wd=S.userManagement.resetPassword.useMutation,Dy=S.userManagement.setUserScopes.useMutation,B_=S.userManagement.validateCredentials.useMutation,Ty=S.userManagement.listApiKeys.useQuery,z_=S.userManagement.createApiKey.useMutation,Ly=S.userManagement.revokeApiKey.useMutation,F_=S.userManagement.validateApiKey.useMutation,Ry=S.userManagement.createScopedToken.useMutation,Oy=S.userManagement.revokeScopedToken.useMutation,j_=S.userManagement.validateScopedToken.useQuery,By=S.userManagement.listScopedTokens.useQuery,V_=S.userManagement.setupTotp.useMutation,H_=S.userManagement.confirmTotp.useMutation,zy=S.userManagement.disableTotp.useMutation,Fy=S.userManagement.getTotpStatus.useQuery,q_=S.userManagement.verifyTotp.useMutation,U_=S.webrtcSession.listStreams.useQuery,Q_=S.webrtcSession.createSession.useMutation,G_=S.webrtcSession.handleOffer.useMutation,K_=S.webrtcSession.handleAnswer.useMutation,W_=S.webrtcSession.closeSession.useMutation,Y_=S.webrtcSession.hasAdaptiveBitrate.useQuery,Z_=S.zoneAnalytics.getCurrentSnapshot.useQuery,X_=S.zoneAnalytics.getZoneHistory.useQuery,J_=S.zoneAnalytics.getCameraHistory.useQuery,e$=S.zoneAnalytics.getUnzonedHistory.useQuery,t$=S.zoneRules.listRules.useQuery,n$=S.zoneRules.setRules.useMutation,r$=S.zones.listZones.useQuery,o$=S.zones.addZone.useMutation,s$=S.zones.removeZone.useMutation,a$=S.zones.updateZone.useMutation,jy=xn("camstack:widget-registry",null),ta=new Map,fs=new Map,bp=new Set;function i$(e){if(!e||typeof e!="object")return!1;const t=e.default;return t!==null&&typeof t=="object"}function l$(e){if(!e||typeof e!="object")return typeof e;const t=e,n=Object.getPrototypeOf(t),r=n&&typeof n=="object"?n.constructor?.name:void 0;return{ownKeys:Object.keys(t),allKeys:Object.getOwnPropertyNames(t),proto:typeof r=="string"?r:void 0}}async function c$(e,t){const n=ta.get(e);if(n)return n;const r=fs.get(e);if(r)return r;bp.has(e)||(Ec(),_r.registerRemotes([{name:e,entry:t,type:"module"}],{force:!1}),bp.add(e));const s=_r.loadRemote(`${e}/widgets`).then(a=>{if(!i$(a)){const l=l$(a);throw new Error(`Widget remote ${e} (${t}) does not expose a default record on './widgets'. Got: ${JSON.stringify(l)}`)}const i=a.default;return ta.set(e,i),fs.delete(e),i}).catch(a=>{throw fs.delete(e),a});return fs.set(e,s),s}const d$=3e4,u$=2e3;function Vy({children:e}){const t=ke(),n=te(Date.now()),{data:r}=Eb(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:l=>{const c=l.state.data;return c&&c.length>0||Date.now()-n.current>=d$?!1:u$}});gt("addon.widget-ready",()=>{t.invalidateQueries({queryKey:[["addonWidgets","listWidgets"]]})});const[s,a]=_(0);Y(()=>{if(!r)return;let l=!1;const c=new Set;for(const d of r){if(c.has(d.remoteName)||(c.add(d.remoteName),ta.has(d.remoteName)))continue;const u=d.bundleUrl;c$(d.remoteName,u).then(()=>{l||a(p=>p+1)}).catch(p=>{const h=p instanceof Error?p.message:String(p);(typeof globalThis<"u"?globalThis.console:void 0)?.error?.("[WidgetRegistry] Failed to load widget remote",{remoteName:d.remoteName,entryUrl:u,reason:h})})}return()=>{l=!0}},[r]);const i=H(()=>{const l=r??[],c=new Map;for(const u of l)c.set(`${u.addonId}/${u.stableId}`,u);const d=(u,p)=>({widgetId:u,addonId:p.addonId,stableId:p.stableId,label:p.label,description:p.description,icon:p.icon,remoteName:p.remoteName,bundleUrl:p.bundleUrl,hosts:p.hosts,requires:p.requires,defaultSize:p.defaultSize,allowedSizes:p.allowedSizes,defaultColumns:p.defaultColumns,defaultRows:p.defaultRows});return{resolve:u=>{const p=c.get(u);if(!p)return;const h=ta.get(p.remoteName);if(!h)return null;const m=h[p.stableId];if(m)return m},metadata:u=>{const p=c.get(u);if(p)return d(u,p)},listAll:()=>{const u=[];for(const[p,h]of c)u.push(d(p,h));return u}}},[r,s]);return o(jy.Provider,{value:i,children:e})}function Hy(e){return Va().resolve(e)}function qy(e){return Va().metadata(e)}function Uy(){return Va().listAll()}function Va(){const e=Qy();if(!e)throw new Error("useWidgetRegistry(): no <WidgetRegistryProvider> in tree");return e}function Qy(){return p$(jy)}function p$(e){return ve(e)}function ft(e){const{widgetId:t,host:n="device-tab",config:r,deviceId:s,integrationId:a,instanceId:i,size:l,columns:c,rows:d}=e,u=Hy(t),p=qy(t),h=H(()=>i??t,[i,t]);if(u===void 0&&p===void 0)return o(hs,{widgetId:t,reason:"unknown"});if(u===void 0)return o(hs,{widgetId:t,reason:"missing-export"});if(u===null)return o(f$,{});if(p){if(p.requires.deviceContext&&s===void 0)return o(hs,{widgetId:t,reason:"missing-device-context"});if(p.requires.integrationContext&&a===void 0)return o(hs,{widgetId:t,reason:"missing-integration-context"})}return o(u,{instanceId:h,host:n,config:r,deviceId:s,integrationId:a,size:l,columns:c,rows:d})}function f$(){return f("div",{className:"rounded-lg border border-border bg-surface/40 p-4 animate-pulse",children:[o("div",{className:"h-3 w-24 bg-foreground-subtle/20 rounded mb-2"}),o("div",{className:"h-2 w-full bg-foreground-subtle/10 rounded mb-1"}),o("div",{className:"h-2 w-3/4 bg-foreground-subtle/10 rounded"})]})}function hs({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 o("div",{className:"rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",children:n})}const mr="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",Ha="block text-[11px] font-medium text-foreground mb-1",h$="text-[10px] text-foreground-subtle mt-0.5";function Ke({label:e,description:t,required:n,span:r,children:s,translationFn:a}){const i=r===2?"col-span-2":r===3?"col-span-3":r===4?"col-span-4":"col-span-1",l=jt(e,a),c=jt(t,a);return f("div",{className:i,children:[l!==void 0&&l!==""&&f("label",{className:Ha,children:[l,n&&o("span",{className:"text-danger ml-0.5",children:"*"})]}),s,c&&o("p",{className:h$,children:c})]})}function m$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("input",{type:e.inputType??"text",className:mr,value:t==null?"":String(t),placeholder:e.placeholder,maxLength:e.maxLength,pattern:e.pattern,disabled:r||e.disabled,onChange:a=>n(a.target.value)})})}function g$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const[a,i]=_(t==null?"":String(t)),l=te(!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 u=Number(d);Number.isNaN(u)||n(u)};return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("div",{className:"flex items-center gap-1",children:[o("input",{type:"number",className:mr,value:a,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step,disabled:r||e.disabled,onFocus:()=>{l.current=!0},onBlur:()=>{l.current=!1},onChange:d=>c(d.target.value)}),e.unit&&o("span",{className:"text-xs text-foreground-subtle whitespace-nowrap",children:e.unit})]})})}function b$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const a=!!t,i=r||e.disabled;return e.style==="checkbox"?o(Ke,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[o("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)}),o("span",{className:"text-xs font-medium text-foreground",children:jt(e.label,s)}),e.required&&o("span",{className:"text-danger",children:"*"})]})}):o(Ke,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("div",{className:"flex items-center justify-between",children:[f("span",{className:Ha+" mb-0",children:[jt(e.label,s),e.required&&o("span",{className:"text-danger ml-0.5",children:"*"})]}),o("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:o("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 x$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const a=e.options.some(i=>i.value==="");return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("select",{className:mr,value:t==null?"":String(t),disabled:r||e.disabled,onChange:i=>n(i.target.value),children:[!e.required&&!a&&o("option",{value:"",children:"— Select —"}),e.options.map(i=>o("option",{value:i.value,children:i.label},i.value))]})})}function y$({field:e,value:t,onChange:n,disabled:r,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 o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("div",{className:"flex flex-wrap gap-2",children:e.options.map(l=>{const c=a.includes(l.value);return f("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",r||e.disabled?"opacity-50 cursor-not-allowed":""].join(" "),children:[o("input",{type:"checkbox",className:"sr-only",checked:c,disabled:r||e.disabled,onChange:()=>i(l.value)}),l.label]},l.value)})})})}function v$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const[a,i]=_(!1),l=e.showToggle!==!1;return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("div",{className:"relative",children:[o("input",{type:a?"text":"password",className:mr+(l?" pr-9":""),value:t==null?"":String(t),placeholder:e.placeholder,disabled:r||e.disabled,onChange:c=>n(c.target.value)}),l&&o("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?o(_c,{className:"h-3.5 w-3.5"}):o(Ur,{className:"h-3.5 w-3.5"})})]})})}function w$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("textarea",{className:mr+" resize-y min-h-[60px]",value:t==null?"":String(t),placeholder:e.placeholder,rows:e.rows??3,maxLength:e.maxLength,disabled:r||e.disabled,onChange:a=>n(a.target.value)})})}function N$({field:e,value:t,onChange:n,disabled:r,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",u=r||e.disabled,p=e.displayScale??1,h=e.min/p,m=e.max/p,g=l/p,b=(e.step??1)/p;if(i&&a)return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("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:u,onClick:()=>n(e.default??e.min),children:[d," — click to set manually"]})});const x=e.showStepper===!0&&c,y=v=>{const N=l+v*(e.step??1),k=Math.min(e.max,Math.max(e.min,N));k!==l&&n(k)},w="flex h-6 w-6 shrink-0 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:cursor-not-allowed disabled:opacity-40";return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[f("div",{className:"flex min-w-0 flex-1 basis-[160px] items-center gap-2",children:[o("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:h}),o("input",{type:"range",className:"min-w-0 flex-1 h-1 accent-primary cursor-pointer disabled:opacity-50",min:h,max:m,step:b,value:g,disabled:u,onChange:v=>n(Number(v.target.value)*p)}),o("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:m})]}),(c||i||e.unit)&&f("div",{className:"flex shrink-0 items-center gap-2",children:[x&&o("button",{type:"button",className:w,disabled:u||l<=e.min,onClick:()=>y(-1),title:`Decrease by ${e.step??1}`,"aria-label":"Decrement",children:o(Jm,{className:"h-3 w-3"})}),c&&o("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:h,max:m,step:b,value:g,disabled:u,onChange:v=>{if(v.target.value===""){n(i?null:e.min);return}const N=Number(v.target.value)*p,k=e.step??1,C=N-e.min,E=e.min+Math.round(C/k)*k;n(Math.min(e.max,Math.max(e.min,E)))}}),x&&o("button",{type:"button",className:w,disabled:u||l>=e.max,onClick:()=>y(1),title:`Increase by ${e.step??1}`,"aria-label":"Increment",children:o(Qo,{className:"h-3 w-3"})}),e.unit&&o("span",{className:"text-[10px] text-foreground-subtle",children:e.unit}),i&&o("button",{className:"text-[10px] text-foreground-subtle hover:text-primary transition-colors",title:`Reset to ${d}`,disabled:u,onClick:()=>n(null),children:d})]})]})})}function k$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const a=Array.isArray(t)?t:[],[i,l]=_(""),c=te(null),d=U(m=>{const g=m.trim();!g||a.includes(g)||e.maxTags!==void 0&&a.length>=e.maxTags||(n([...a,g]),l(""))},[a,e.maxTags,n]),u=m=>n(a.filter(g=>g!==m)),p=m=>{m.key==="Enter"||m.key===","?(m.preventDefault(),d(i)):m.key==="Backspace"&&i===""&&a.length>0&&u(a[a.length-1])},h=r||e.disabled;return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("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",h?"opacity-50 cursor-not-allowed":""].join(" "),onClick:()=>!h&&c.current?.focus(),children:[a.map(m=>f("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[m,!h&&o("button",{type:"button",onClick:()=>u(m),className:"hover:text-danger",children:o(Je,{className:"h-2.5 w-2.5"})})]},m)),o("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:h,list:`tags-suggestions-${e.key}`,onChange:m=>l(m.target.value),onKeyDown:p,onBlur:()=>{i.trim()&&d(i)}}),e.suggestions&&o("datalist",{id:`tags-suggestions-${e.key}`,children:e.suggestions.map(m=>o("option",{value:m},m))})]})})}function Gy({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const{nodes:a}=Kr(),i=typeof t=="string"?t:"",l=e.showOffline?a:a.filter(c=>c.isOnline);return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:f("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:r,children:[o("option",{value:"",children:"Select node…"}),l.map(c=>f("option",{value:c.id,disabled:!c.isOnline,children:[c.shortName,c.isOnline?"":" (offline)"]},c.id))]})})}function Ky({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const{nodes:a}=Kr(),i=new Set(Array.isArray(t)?t.map(String):[]),l=e.showOffline?a:a.filter(d=>d.isOnline),c=d=>{const u=new Set(i);u.has(d)?u.delete(d):u.add(d),n([...u])};return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("div",{className:"flex flex-wrap gap-1.5",children:l.map(d=>{const u=i.has(d.id);return o("button",{type:"button",onClick:()=>c(d.id),disabled:r||!d.isOnline,className:`px-2.5 py-1 text-xs font-medium rounded-md border transition-colors ${u?"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 S$({field:e,value:t,onChange:n,disabled:r,translationFn:s}){const a=t==null?"#000000":String(t);return f(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:[f("div",{className:"flex items-center gap-2",children:[o("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:r||e.disabled,onChange:i=>n(i.target.value)}),o("input",{type:"text",className:mr+" flex-1 font-mono",value:a,placeholder:"#000000",disabled:r||e.disabled,onChange:i=>n(i.target.value)})]}),e.presets&&e.presets.length>0&&o("div",{className:"flex gap-1.5 mt-1.5",children:e.presets.map(i=>o("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:r||e.disabled,title:i,onClick:()=>n(i)},i))})]})}function C$({field:e,value:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:i,externalProbe:l}){const[c,d]=_("idle"),[u,p]=_(null),h=l?.status??c,m=l?.result??u,g=!!a||!!i,b=U(async()=>{if(g){d("probing"),p(null);try{const w=a?await a(e.key,t):await i("test-probe",e.key,t),v=w&&typeof w=="object"?w:{status:"error",error:"Probe handler returned no result"};p(v),d(v.status==="ok"?"ok":"error")}catch(w){p({status:"error",error:w instanceof Error?w.message:String(w)}),d("error")}}},[a,i,e.key,t,g]),x=h==="probing"?"border-primary/40 bg-primary/10 text-primary":h==="ok"?"border-success/40 bg-success/10 text-success hover:bg-success/15":h==="error"?"border-danger/40 bg-danger/10 text-danger hover:bg-danger/15":"border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover",y=h==="probing"?o(Ct,{className:"h-3 w-3 animate-spin"}):h==="ok"?o($5,{className:"h-3 w-3"}):h==="error"?o(Uo,{className:"h-3 w-3"}):o(sg,{className:"h-3 w-3"});return f(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:[f("div",{className:"@container flex items-center gap-2",style:{containerType:"inline-size"},children:[f("button",{type:"button",onClick:b,title:"Test",disabled:e.disabled||h==="probing"||!g||!t,className:`flex-shrink-0 inline-flex items-center gap-1.5 rounded-md border px-2 py-2 text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed @[280px]:px-3 ${x}`,children:[y,o("span",{className:"hidden @[280px]:inline",children:"Test"})]}),o("input",{type:e.inputType??"url",className:mr+" flex-1 min-w-0",value:t==null?"":String(t),placeholder:e.placeholder,disabled:r||e.disabled,onChange:w=>{n(w.target.value),c!=="idle"&&(d("idle"),p(null))}})]}),h==="ok"&&m?.labels&&m.labels.length>0&&o("div",{className:"flex flex-wrap gap-1 mt-1.5",children:m.labels.map((w,v)=>o("span",{className:"text-xs bg-success/10 text-success rounded px-2 py-0.5 font-mono",children:w},v))}),h==="error"&&m?.error&&o("p",{className:"text-xs text-danger mt-1 truncate",title:m.error,children:m.error})]})}function M$({field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a}){const[i,l]=_(e.defaultCollapsed??!1),c=e.style==="accordion",d=e.span===2?"col-span-2":e.span===3?"col-span-3":e.span===4?"col-span-4":"col-span-1";return o("div",{className:d,children:f("div",{className:"rounded-lg border border-border bg-surface/50 overflow-hidden",children:[f("div",{className:["px-3 py-2 flex items-center justify-between",c?"cursor-pointer hover:bg-surface":""].join(" "),onClick:c?()=>l(u=>!u):void 0,children:[o("span",{className:"text-xs font-semibold text-foreground",children:jt(e.label,s)}),c&&o("span",{className:"text-foreground-subtle text-xs",children:i?"▸":"▾"})]}),!i&&o("div",{className:"px-3 pb-3 grid grid-cols-2 gap-x-4 gap-y-3",children:e.fields.map(u=>o(gr,{field:u,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a},u.key))})]})})}function E$({field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:i}){const l=e.tabs[0]?.id??"",[c,d]=_(l),u=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:f("div",{className:u,children:[e.label&&o("div",{className:Ha,children:jt(e.label,s)}),f("div",{className:"rounded-lg border border-border-subtle bg-surface-hover/40 overflow-hidden",children:[o("div",{className:"flex flex-wrap gap-1 p-1.5 border-b border-border-subtle bg-surface/40",role:"tablist",children:e.tabs.map(p=>{const h=p.id===c;return f("button",{type:"button",role:"tab","aria-selected":h,onClick:()=>d(p.id),className:`inline-flex items-center gap-1.5 whitespace-nowrap rounded-md px-2.5 py-1 text-[11px] transition-colors ${h?"bg-primary text-primary-foreground font-medium shadow-sm":"bg-transparent text-foreground-subtle hover:bg-surface hover:text-foreground"}`,children:[o("span",{children:jt(p.label,s)}),p.badge&&o("span",{className:`text-[9px] px-1 py-0.5 rounded-full font-medium ${h?"bg-primary-foreground/20 text-primary-foreground":"bg-primary/10 text-primary"}`,children:p.badge})]},p.id)})}),e.tabs.map(p=>p.id!==c?null:o("div",{role:"tabpanel",className:"px-3 pb-3 pt-2 grid grid-cols-2 gap-x-4 gap-y-3",children:p.fields.map((h,m)=>{const g="key"in h&&typeof h.key=="string"?h.key:`__${p.id}__${m}`;return o(gr,{field:h,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:i},g)})},p.id))]})]})}function I$({span:e}){return o("div",{className:e===2?"col-span-2":e===3?"col-span-3":e===4?"col-span-4":"col-span-full",children:o("hr",{className:"border-border"})})}const xp={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 A$(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"),r=n.body.firstElementChild;if(!r)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(r),r.innerHTML}function P$({field:e}){const t=e.variant??"info",n=xp[t]??xp.info,r=e.format==="html";return o("div",{className:"col-span-full",children:f("div",{className:`rounded-md border-l-4 px-3 py-2.5 ${n.border} ${n.bg}`,children:[e.label&&o("p",{className:`text-xs font-semibold mb-0.5 ${n.text}`,children:e.label}),r?o("div",{className:"text-xs text-foreground-subtle leading-relaxed info-html-content",dangerouslySetInnerHTML:{__html:A$(e.content)}}):o("p",{className:"text-xs text-foreground-subtle leading-relaxed whitespace-pre-line",children:e.content})]})})}const yp={ok:"bg-success",warn:"bg-amber-500",danger:"bg-danger",idle:"bg-foreground-subtle/40",unknown:"bg-foreground-subtle/40"};function _$(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),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function $$(e){return!Number.isFinite(e)||e<=0?"—":new Date(e).toLocaleTimeString()}function D$({kind:e,value:t}){if(t==null||t==="")return o("span",{className:"text-foreground-subtle/60",children:"—"});if(e==="monospace")return o("span",{className:"font-mono text-[11px]",children:String(t)});if(e==="status"){const n=String(t).toLowerCase(),r=yp[n]??yp.unknown;return f("span",{className:"inline-flex items-center gap-1.5",children:[o("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${r}`}),o("span",{children:String(t)})]})}return e==="duration"&&typeof t=="number"?o("span",{className:"font-mono text-[11px]",children:_$(t)}):e==="timestamp"&&typeof t=="number"?o("span",{className:"font-mono text-[11px]",children:$$(t)}):o("span",{children:String(t)})}function T$({field:e}){const t=e.value??[],n=e.description;return f("div",{className:"col-span-full",children:[e.label&&o("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1",children:e.label}),n&&o("p",{className:"text-xs text-foreground-subtle mb-2",children:n}),t.length===0?o("div",{className:"rounded-md border border-border bg-surface-subtle px-3 py-2 text-xs text-foreground-subtle",children:e.emptyMessage??"No entries"}):o("div",{className:"rounded-md border border-border overflow-hidden",children:f("table",{className:"w-full text-xs",children:[o("thead",{className:"bg-surface-subtle border-b border-border",children:o("tr",{children:e.columns.map(r=>o("th",{className:"px-3 py-1.5 text-left font-medium text-foreground-subtle",style:r.width?{width:r.width}:void 0,children:r.label},r.key))})}),o("tbody",{className:"divide-y divide-border",children:t.map((r,s)=>o("tr",{className:"hover:bg-surface-hover/40",children:e.columns.map(a=>o("td",{className:"px-3 py-1.5 align-top text-foreground",children:o(D$,{kind:a.kind,value:r[a.key]})},a.key))},s))})]})})]})}function L$({field:e,value:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:i}){const l=Array.isArray(t)?t:[],c=e.minRows??0,d=e.maxRows??Number.POSITIVE_INFINITY,u=(x,y,w)=>{const v=l.slice(),N=v[x]??{};v[x]={...N,[y]:w},n(v)},p=x=>{l.length<=c||n(l.filter((y,w)=>w!==x))},h=()=>{if(l.length>=d)return;const x=e.defaultItem??{};n([...l,{...x}])},m=(x,y)=>e.rowTitleTemplate?e.rowTitleTemplate.replace(/\{(\w+)\}/g,(w,v)=>{const N=x[v];return N==null||N===""?"—":String(N)}):`Row ${y+1}`,g=l.length>c,b=l.length<d;return f("div",{className:"col-span-full space-y-2",children:[f("div",{className:"space-y-0.5",children:[e.label&&o("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:jt(e.label,s)}),e.description&&o("p",{className:"text-[11px] text-foreground-subtle",children:jt(e.description,s)})]}),l.length===0?o("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"}):o("div",{className:"space-y-2",children:l.map((x,y)=>f("div",{className:"rounded-md border border-border bg-background",children:[f("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[o("span",{className:"text-xs font-medium text-foreground",children:m(x,y)}),f("button",{type:"button",onClick:()=>p(y),disabled:r||!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:[o(Jm,{className:"h-3 w-3"}),"Remove"]})]}),o("div",{className:"grid grid-cols-1 @[420px]:grid-cols-2 gap-x-3 gap-y-2 p-3",children:e.itemFields.map(w=>o(gr,{field:w,values:x,onChange:(v,N)=>u(y,v,N),disabled:r,translationFn:s,onTestField:a,allFields:e.itemFields,onAction:i},w.key))})]},y))}),f("div",{children:[f("button",{type:"button",onClick:h,disabled:r||!b,className:"inline-flex items-center gap-1 rounded border border-border bg-surface px-3 py-1 text-[11px] font-medium text-foreground hover:border-primary/40 hover:bg-primary/5 disabled:opacity-30 disabled:cursor-not-allowed",children:[o(Qo,{className:"h-3 w-3"}),e.addLabel??"Add"]}),!b&&Number.isFinite(d)&&f("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["(limit: ",d,")"]})]})]})}function R$({field:e,disabled:t,onAction:n}){const[r,s]=_(!1),a=nt(),i=async()=>{if(!(e.confirmMessage&&!await a({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant==="danger"?"danger":"default"}))&&n){s(!0);try{await n(e.action,e.key)}finally{s(!1)}}},l={default:"border border-border text-foreground hover:bg-surface-hover",primary:"bg-primary text-primary-foreground hover:bg-primary/90",danger:"bg-danger text-white hover:bg-danger/90"};return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,children:o("button",{onClick:i,disabled:t||r,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:r?"Processing...":e.buttonLabel})})}function Wy(e,t){const n={...e.paramsStatic??{}};if(e.paramsFromForm)for(const[r,s]of Object.entries(e.paramsFromForm)){const a=t[s];a!=null&&a!==""&&(n[r]=a)}return n}function O$({field:e,value:t,values:n,onChange:r,disabled:s,onAction:a}){const[i,l]=_(!1),[c,d]=_(null),[u,p]=_(null),h=Wy(e,n),m=Object.keys(e.paramsFromForm??{}).some(w=>h[w]===void 0),g=(e.refreshOn??Object.values(e.paramsFromForm??{})).map(w=>`${w}=${JSON.stringify(n[w])}`).join("|");Y(()=>{if(!a||m){p(null),d(null);return}let w=!1;return l(!0),d(null),a(e.action,e.key,h).then(v=>{if(w)return;const N=v;let k=[];if(Array.isArray(N))k=N;else if(N&&typeof N=="object")for(const C of Object.keys(N)){const E=N[C];if(Array.isArray(E)){k=E;break}}p(k)}).catch(v=>{w||(d(v instanceof Error?v.message:String(v)),p([]))}).finally(()=>{w||l(!1)}),()=>{w=!0}},[g,a,e.action,e.key]);const b=e.mapOption.value,x=e.mapOption.label,y=e.mapOption.description;return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,children:m?o("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyParamsMessage??"Fill the prerequisite fields above first."}):i?f("div",{className:"flex items-center gap-2 text-[11px] text-foreground-subtle",children:[o(Ct,{className:"h-3 w-3 animate-spin"})," Loading options…"]}):c?o("div",{className:"text-[11px] text-danger",children:c}):u&&u.length===0?o("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyResultsMessage??"No options returned."}):(()=>{const w=(u??[]).some(v=>{const N=v[b];return N===""||N===void 0});return f("select",{className:"w-full rounded-md border border-border bg-surface px-2 py-1.5 text-xs text-foreground",value:typeof t=="string"?t:"",disabled:s,onChange:v=>r(v.target.value),children:[!w&&o("option",{value:"",children:"— Select —"}),(u??[]).map((v,N)=>{const k=v[b],C=v[x],E=y?v[y]:void 0,I=typeof k=="string"&&k!==""?k:`row-${N}`;return f("option",{value:typeof k=="string"?k:String(k??""),children:[typeof C=="string"?C:String(C??I),E!==void 0?` (${String(E)})`:""]},I)})]})})()})}function B$({field:e,values:t,disabled:n,onAction:r}){const[s,a]=_(!1),[i,l]=_(null),c=nt(),d=async()=>{if(e.confirmMessage&&!await c({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant==="danger"?"danger":"default"})||!r)return;const p=Wy(e,t);a(!0),l(null);try{const h=await r(e.action,e.key,p),m=typeof h=="object"&&h!==null?h:null,g=e.successMessage?e.successMessage.replace(/\{(\w+)\}/g,(b,x)=>{const y=m?.[x];return y===void 0?"":String(y)}):"Done.";l({kind:"ok",text:g})}catch(h){l({kind:"error",text:h instanceof Error?h.message:String(h)})}finally{a(!1)}},u={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 o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,children:f("div",{className:"flex flex-col gap-1.5",children:[o("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 ${u[e.variant??"default"]??u.default}`,children:s?"Working…":e.buttonLabel}),i&&o("div",{className:`text-[11px] ${i.kind==="ok"?"text-emerald-700 dark:text-emerald-300":"text-danger"}`,children:i.text})]})})}function z$({field:e}){const t=vn();return o(Ke,{label:e.label,description:e.description,required:e.required,span:e.span,children:o(ft,{widgetId:e.widgetId,host:"device-tab",config:e.widgetConfig,deviceId:t??void 0,instanceId:e.key})})}function F$(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 j$({field:e,values:t,onAction:n,translationFn:r}){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=F$(i,l),d="label"in e?e.label:void 0,u="description"in e?e.description:void 0,p="span"in e?e.span:void 0,h="actions"in e?e.actions??[]:[];return o(Ke,{label:d,description:u,span:p,translationFn:r,children:f("div",{className:"flex items-stretch gap-1",children:[o("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}),h.length>0&&o("div",{className:"flex items-center gap-1",children:h.map(m=>o(H$,{action:m,fieldKey:s,value:i,onAction:n},m.action))})]})})}function V$({name:e}){const t="h-3.5 w-3.5";switch(e){case"copy":return o(yn,{className:t});case"refresh-cw":return o($a,{className:t});case"external-link":return o(Pc,{className:t});case"trash-2":return o(Zt,{className:t});case"download":return o(Il,{className:t});case"upload":return o(og,{className:t});default:return o(Dc,{className:t})}}function H$({action:e,fieldKey:t,value:n,onAction:r}){const s=nt(),[a,i]=_(!1),l=e.variant==="danger"?"text-danger hover:bg-danger/10 border-danger/30":e.variant==="primary"?"text-primary hover:bg-primary/10 border-primary/30":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover border-border";return o("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(r){i(!0);try{await r(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:o(V$,{name:e.icon})})}function q$(e){return"multiple"in e&&e.multiple!=null}function U$({field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c}){const d=e.multiple,u=d.min,p=d.max,h=t[e.key],g=[...Array.isArray(h)?h:h!=null?[h]:[]],b=d.itemDefault!==void 0?d.itemDefault:"default"in e&&e.default!==void 0?e.default:"";for(;g.length<u;)g.push(b);const x=k=>n(e.key,[...k]),y=(k,C)=>{const E=[...g];E[k]=C,x(E)},w=()=>{g.length>=p||x([...g,b])},v=k=>{g.length<=u||x(g.filter((C,E)=>E!==k))},N=()=>{const{multiple:k,...C}=e;return{...C,...{label:void 0,description:void 0,required:!1}}};return o(Ke,{label:e.label,description:e.description,required:u>0?e.required:!1,span:e.span,translationFn:s,children:f("div",{className:"space-y-2",children:[g.map((k,C)=>{const E=d.itemLabel?.replace("${n}",String(C+1));return f("div",{className:"space-y-1",children:[E&&o("div",{className:Ha,children:E}),f("div",{className:"flex items-center gap-2",children:[o("div",{className:"flex-1 min-w-0",children:o(gr,{field:N(),values:{...t,[e.key]:k},onChange:(I,A)=>y(C,A),disabled:r,translationFn:s,onTestField:a,onAction:c,allFields:l})}),g.length>u&&o("button",{type:"button",onClick:()=>v(C),disabled:r,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:o(Zt,{className:"h-3.5 w-3.5"})})]})]},C)}),f("div",{className:"flex items-center justify-between pt-1",children:[g.length<p?f("button",{type:"button",onClick:w,disabled:r,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:[o(Qo,{className:"h-3 w-3"}),d.addLabel??"Add"]}):o("span",{}),f("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[g.length,"/",p]})]})]})})}function Nd(e,t,n){if(!("showWhen"in e)||!e.showWhen)return!0;const r=e.showWhen,s=t[r.field],a=n?.find(c=>"key"in c&&c.key===r.field),i=a&&"default"in a?a.default:void 0,l=s!==void 0?s:i;return r.equals!==void 0?l===r.equals:r.notEquals!==void 0?l!==r.notEquals:r.in!==void 0?r.in.includes(l):r.notIn!==void 0?!r.notIn.includes(l):r.includes!==void 0?Array.isArray(l)&&l.includes(r.includes):r.notIncludes!==void 0?!Array.isArray(l)||!l.includes(r.notIncludes):!0}function gr({field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c}){if(q$(e))return o(U$,{field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c});if("readonlyField"in e&&e.readonlyField===!0)return o(j$,{field:e,values:t,onAction:c,translationFn:s});if(!Nd(e,t,l))return null;const d=t[e.key],u=d!==void 0?d:"default"in e?e.default:void 0,p=m=>n(e.key,m),h=lb(e.type);switch(e.type){case"text":return o(m$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"number":return o(g$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"boolean":return o(b$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"select":return o(x$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"multiselect":return o(y$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"password":return o(v$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"textarea":return o(w$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"slider":return o(N$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"tags":return o(k$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"color":return o(S$,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"node-select":return o(Gy,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"node-multiselect":return o(Ky,{field:e,value:u,onChange:p,disabled:r,translationFn:s});case"probe":return o(C$,{field:e,value:u,onChange:p,disabled:r,translationFn:s,onTestField:a,onAction:c,externalProbe:i});case"group":return o(M$,{field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a});case"sub-tabs":return o(E$,{field:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,onAction:c});case"separator":return o(I$,{});case"info":return o(P$,{field:e});case"object-array":return o(T$,{field:e});case"editable-array":return o(L$,{field:e,value:u,onChange:p,disabled:r,translationFn:s,onTestField:a,onAction:c});case"button":return o(R$,{field:e,disabled:r,onAction:c});case"addon-action-select":return o(O$,{field:e,value:u,values:t,onChange:p,disabled:r,onAction:c});case"addon-action-button":return o(B$,{field:e,values:t,disabled:r,onAction:c});case"widget":return o(z$,{field:e});default:return h?o(h,{field:e,value:u,onChange:p,disabled:r}):null}}function Q$(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function jt(e,t){if(e!==void 0)return t&&Q$(e)?t(e):e}function G$({section:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,probeResults:i}){const[l,c]=_(e.defaultCollapsed??!1),d=e.style==="accordion",u=e.columns??2,p=u===1?"grid-cols-1":u===3?"grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3":u===4?"grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4":"grid-cols-1 @[640px]:grid-cols-2";return f("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[f("div",{className:["flex items-center justify-between mb-2",d?"cursor-pointer":""].join(" "),onClick:d?()=>c(h=>!h):void 0,children:[f("div",{children:[o("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:jt(e.title,s)}),e.description&&o("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:jt(e.description,s)})]}),d&&o("span",{className:"text-foreground-subtle text-xs ml-2",children:l?"▸":"▾"})]}),!l&&o("div",{className:`grid ${p} gap-x-3 gap-y-2.5`,children:e.fields.map(h=>o(gr,{field:h,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i?.[h.key]},h.key))})]})}function Yy({schema:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,probeResults:i,onClearProbe:l}){const c=(d,u)=>{n({...t,[d]:u}),l?.(d)};return o("div",{className:"space-y-4",children:e.sections.map(d=>o(G$,{section:d,values:t,onChange:c,disabled:r,translationFn:s,onTestField:a,probeResults:i},d.id))})}const K$=({open:e})=>o("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:o("polyline",{points:"9 18 15 12 9 6"})});function vp(e){const t={};if(!e)return t;for(const n of e.sections)for(const r of n.fields){if(r.type==="separator"||r.type==="info"||r.type==="button"||r.type==="group")continue;const s=r.key;t[s]=r.value}return t}function W$(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:r,...s}=n;return s})}))}}function Y$({trpc:e,addonId:t,nodeId:n,title:r,disabled:s,onAfterChange:a,refreshToken:i,collapsible:l,defaultOpen:c,mode:d,onOverrideChange:u}){const p=d??"persist",[h,m]=_(null),[g,b]=_(!0),[x,y]=_(null),[w,v]=_(!1),[N,k]=_(c??!1),[C,E]=_({}),[I,A]=_(null);Y(()=>{A(null),E({})},[e,t,n,i,p]);const z=JSON.stringify(C);Y(()=>{let T=!1;b(!0),y(null);const L=p==="override"&&Object.keys(C).length>0?C:void 0;return e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n,...L?{overlay:L}:{}}).then(O=>{T||(m(O),L||A(vp(O)),b(!1))}).catch(O=>{T||(y(O instanceof Error?O.message:String(O)),b(!1))}),()=>{T=!0}},[e,t,n,i,p,z]);const P=H(()=>vp(h),[h]),B=H(()=>h?W$(h):null,[h]),R=async T=>{if(p==="override"){const O=I??P,F={};for(const V of Object.keys(T))T[V]!==O[V]&&(F[V]=T[V]);const j={...O,...F};E(F),u?.(F,j);return}const L={};for(const O of Object.keys(T))T[O]!==P[O]&&(L[O]=T[O]);if(Object.keys(L).length!==0){v(!0);try{await e.addonSettings.updateGlobalSettings.mutate({addonId:t,nodeId:n,patch:L});const O=await e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n});m(O),a?.()}catch(O){y(O instanceof Error?O.message:String(O))}finally{v(!1)}}};if(g)return f("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading ",r??t,"…"]});if(x)return f("div",{className:"text-xs text-red-400",children:[r??t,": ",x]});if(!h||!B)return f("div",{className:"text-xs text-foreground-subtle",children:[r??t," not available on ",n,"."]});const M=p==="override"?{...P,...C}:P,D=f(me,{children:[p==="override"?o("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,o(Yy,{schema:B,values:M,onChange:R,disabled:s===!0||w})]});return l===!0?f("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("button",{type:"button",onClick:()=>k(T=>!T),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover text-left","aria-expanded":N,children:[o(K$,{open:N}),o("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide flex-1",children:r??t}),o("span",{className:"text-[10px] text-foreground-subtle",children:N?"hide":"edit"})]}),N?o("div",{className:"border-t border-border px-4 py-3",children:D}):null]}):r?f("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o("div",{className:"border-b border-border px-4 py-2",children:o("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:r})}),o("div",{className:"px-4 py-3",children:D})]}):o("div",{children:D})}function Zy({detections:{motion:e,motionRaw:t,detection:n,phase:r},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,u=i&&n&&n.detections.length>0;return!c&&!d&&!u&&!l?null:f("div",{className:"absolute inset-0 pointer-events-none z-10",children:[l&&o(Z$,{phase:r}),d&&o(X$,{raw:t}),c&&o(J$,{motion:e}),u&&o(eD,{detections:n.detections,frameWidth:n.frameWidth,frameHeight:n.frameHeight})]})}function Z$({phase:e}){const t=ur(e);return f("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:[o("span",{className:`w-2 h-2 rounded-full ${t.dotClass}`}),o("span",{className:"text-[10px] font-semibold text-white uppercase tracking-wider",children:t.label})]})}function X$({raw:e}){return e.frameWidth===0||e.frameHeight===0?null:o(me,{children:e.boxes.map((t,n)=>{const[r,s,a,i]=t.bbox,l=r/e.frameWidth*100,c=s/e.frameHeight*100,d=(a-r)/e.frameWidth*100,u=(i-s)/e.frameHeight*100,p=Math.max(.05,Math.min(.25,t.changeScore*.3));return o("div",{className:"absolute rounded-sm",style:{left:`${l}%`,top:`${c}%`,width:`${d}%`,height:`${u}%`,backgroundColor:`rgba(239, 68, 68, ${p})`}},`mr-${n}`)})})}function J$({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 o(me,{children:t.map((n,r)=>{const s=Math.max(.15,Math.min(.5,n.intensity/255));return o("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-${r}`)})})}function eD({detections:e,frameWidth:t,frameHeight:n}){return t===0||n===0?null:o(me,{children:e.map(r=>{const{x:s,y:a,width:i,height:l}=r.bbox,c=s/t*100,d=a/n*100,u=i/t*100,p=l/n*100,h=mt(r.macroClass),m=[`${r.macroClass} ${(r.score*100).toFixed(0)}%`];for(const g of r.labels)m.push(g.label);return o("div",{className:"absolute border-2 rounded-sm",style:{left:`${c}%`,top:`${d}%`,width:`${u}%`,height:`${p}%`,borderColor:h},children:o("div",{className:"absolute -top-4 left-0 px-1 py-0.5 text-[9px] font-bold text-white rounded-sm whitespace-nowrap",style:{backgroundColor:h},children:m.join(" | ")})},`det-${r.id}`)})})}function tD(e){const t={};if(typeof window<"u"){if(e){const r=e.getBoundingClientRect();r.width>0&&r.height>0&&(t.viewportWidth=Math.round(r.width),t.viewportHeight=Math.round(r.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 nD=3e3,rD=5;function Xy({serverUrl:e,streamKey:t,label:n,autoPlay:r=!0,muted:s=!0,showControls:a=!0,className:i="",onStateChange:l,onError:c,overlay:d,createSession:u,sendAnswer:p,closeSession:h,hintsOverride:m}){const g=te(null),b=te(null),x=te(null),y=te(new Set),w=te(null),v=te(null),N=te(0),k=te(!0),[C,E]=_("idle"),[I,A]=_(""),[z,P]=_(s),[B,R]=_(!1),[M,D]=_(!1),T=te(null),L=te(!1);(p||u)&&(L.current=!0);const O=L.current,F=U(W=>{E(W),l?.(W)},[l]),j=U(()=>{if(w.current?.abort(),w.current=null,v.current&&(clearTimeout(v.current),v.current=null),x.current&&(x.current.close(),x.current=null),h&&y.current.size>0){for(const W of y.current)h(W).catch(()=>{});y.current.clear()}g.current&&(g.current.srcObject=null)},[h]),V=U(async()=>{if(!k.current||!u||!p)return;j(),F("connecting");const W=new AbortController;w.current=W;try{const ae={...tD(b.current),...m},{sessionId:fe,sdpOffer:ge}=await u(ae);if(y.current.add(fe),!k.current||W.signal.aborted){h?.(fe).catch(()=>{}),y.current.delete(fe);return}const Q=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=Q;const le=new MediaStream;Q.ontrack=pe=>{console.debug("[WebRTC] ontrack",pe.track.kind,pe.track.readyState),le.addTrack(pe.track),g.current&&(g.current.srcObject=le,g.current.play().catch(()=>{}))},Q.oniceconnectionstatechange=()=>{if(!k.current)return;const pe=Q.iceConnectionState;console.debug("[WebRTC] ICE state:",pe),pe==="connected"||pe==="completed"?(N.current=0,F("playing"),g.current?.paused&&(console.debug("[WebRTC] video was paused at ICE connected — calling play()"),g.current.play().catch(()=>{}))):(pe==="failed"||pe==="disconnected"||pe==="closed")&&(F("disconnected"),Z())},Q.onicecandidateerror=pe=>{console.debug("[WebRTC] ICE candidate error:",pe)},console.debug("[WebRTC] Setting remote description (server offer)..."),await Q.setRemoteDescription({type:"offer",sdp:ge});const ue=await Q.createAnswer();if(await Q.setLocalDescription(ue),console.debug("[WebRTC] Local description set, waiting for ICE gathering..."),await wp(Q),!k.current)return;const de=(Q.localDescription?.sdp??"").split(`
|
|
551
|
-
`).filter(pe=>pe.startsWith("a=candidate:")).length;console.debug("[WebRTC] Sending answer to server",{localCandidates:de,sessionId:fe.slice(0,8)}),await p(fe,Q.localDescription?.sdp??""),console.debug("[WebRTC] Answer sent successfully");const ce=Q,Ce=()=>{const pe=ce.connectionState;if(pe==="closed"||pe==="failed")return;const $e=g.current;$e&&$e.readyState===0&&console.log(`[WebRTC] no video data yet (ice=${ce.iceConnectionState})`)};setTimeout(Ce,3e3),setTimeout(Ce,8e3)}catch(ee){if(!k.current)return;const ae=ee instanceof Error?ee.message:String(ee);A(ae),F("error"),c?.(ae),Z()}},[e,t,u,p,j,F,c,m]),$=U(async()=>{if(k.current){j(),F("connecting");try{const W=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=W,W.addTransceiver("video",{direction:"recvonly"}),W.addTransceiver("audio",{direction:"recvonly"});const ee=new MediaStream;W.ontrack=le=>{ee.addTrack(le.track),g.current&&(g.current.srcObject=ee,g.current.play().catch(()=>{}))},W.oniceconnectionstatechange=()=>{if(!k.current)return;const le=W.iceConnectionState;le==="connected"||le==="completed"?(N.current=0,F("playing"),g.current?.paused&&g.current.play().catch(()=>{})):(le==="failed"||le==="disconnected"||le==="closed")&&(F("disconnected"),Z())};const ae=await W.createOffer();if(await W.setLocalDescription(ae),await wp(W),!k.current)return;const fe=`${e}/api/webrtc?src=${encodeURIComponent(t)}`,ge=await fetch(fe,{method:"POST",headers:{"Content-Type":"application/sdp"},body:W.localDescription?.sdp??""});if(!ge.ok)throw new Error(`WHEP ${ge.status}: ${ge.statusText}`);const Q=await ge.text();await W.setRemoteDescription({type:"answer",sdp:Q})}catch(W){if(!k.current)return;const ee=W instanceof Error?W.message:String(W);A(ee),F("error"),c?.(ee),Z()}}},[e,t,j,F,c]),q=O?V:$,G=te(()=>{});G.current=q;const Z=U(()=>{k.current&&(N.current>=rD||(N.current+=1,v.current=setTimeout(()=>{k.current&&G.current()},nD)))},[]);Y(()=>(k.current=!0,N.current=0,r&&q(),()=>{k.current=!1,j()}),[e,t]);const oe=te(!1);Y(()=>{!r||!O||!u||!p||oe.current||x.current||(oe.current=!0,q())},[r,O,u,p,q]);const ne=()=>{N.current=0,q()},X=()=>{g.current&&(g.current.muted=!g.current.muted,P(g.current.muted))},re=async()=>{if(b.current)try{document.fullscreenElement?await document.exitFullscreen():await b.current.requestFullscreen()}catch(W){console.warn(`Fullscreen toggle failed: ${W instanceof Error?W.message:W}`)}},be=()=>{if(!g.current)return;const W=document.createElement("canvas");W.width=g.current.videoWidth||1280,W.height=g.current.videoHeight||720;const ee=W.getContext("2d");if(!ee)return;ee.drawImage(g.current,0,0);const ae=document.createElement("a");ae.download=`${t.replace(/[/:]/g,"-")}-${Date.now()}.jpg`,ae.href=W.toDataURL("image/jpeg",.92),ae.click()};Y(()=>{const W=()=>R(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",W),()=>document.removeEventListener("fullscreenchange",W)},[]);const J=()=>{D(!0),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>D(!1),3e3)};return f("div",{ref:b,className:`relative bg-black overflow-hidden group ${i}`,onMouseMove:J,onMouseEnter:J,children:[o("video",{ref:g,autoPlay:r,muted:z,playsInline:!0,className:"w-full h-full object-contain"}),n&&C==="playing"&&o("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"&&f("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[o("svg",{className:"h-6 w-6 text-white/60 animate-spin",viewBox:"0 0 24 24",fill:"none",children:o("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]"})}),o("span",{className:"text-xs text-white/60",children:"Connecting…"})]}),(C==="error"||C==="disconnected")&&f("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[o("svg",{className:"h-6 w-6 text-red-400",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o("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"})}),o("span",{className:"text-xs text-red-400 text-center px-4",children:C==="error"?I||"Connection failed":"Disconnected"}),o("button",{onClick:ne,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"&&f("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:[o("div",{className:"flex items-center gap-1",children:o(Ai,{onClick:X,title:z?"Unmute":"Mute",children:z?f("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),o("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),o("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]}):f("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),o("path",{d:"M19.07 4.93a10 10 0 010 14.14M15.54 8.46a5 5 0 010 7.07"})]})})}),f("div",{className:"flex items-center gap-1",children:[o(Ai,{onClick:be,title:"Take snapshot",children:f("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o("path",{d:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z"}),o("circle",{cx:"12",cy:"13",r:"4"})]})}),o(Ai,{onClick:re,title:B?"Exit fullscreen":"Fullscreen",children:B?o("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:o("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"})}):o("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:o("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 Ai({onClick:e,title:t,children:n}){return o("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 wp(e){if(e.iceGatheringState!=="complete")return new Promise(t=>{const n=()=>{e.iceGatheringState==="complete"&&(e.removeEventListener("icegatheringstatechange",n),t())};e.addEventListener("icegatheringstatechange",n),setTimeout(t,5e3)})}const kd=xn("camstack:player-overlays-state",null),Sd=xn("camstack:player-overlays-actions",null);function Jy({children:e}){const[t,n]=_(()=>new Map),[r,s]=_(()=>new Map),a=U(p=>{n(h=>{const m=new Map(h);return m.set(p.id,p),m})},[]),i=U(p=>{n(h=>{if(!h.has(p))return h;const m=new Map(h);return m.delete(p),m})},[]),l=U(p=>{s(h=>{const m=new Map(h);return m.set(p.id,p),m})},[]),c=U(p=>{s(h=>{if(!h.has(p))return h;const m=new Map(h);return m.delete(p),m})},[]),d=H(()=>({layers:t,buttons:r}),[t,r]),u=H(()=>({setLayer:a,removeLayer:i,setButton:l,removeButton:c}),[a,i,l,c]);return o(kd.Provider,{value:d,children:o(Sd.Provider,{value:u,children:e})})}function e0(){const e=ve(kd);return H(()=>e?[...e.layers.values()].sort((t,n)=>t.order-n.order):[],[e])}function t0(){const e=ve(kd);return H(()=>e?[...e.buttons.values()].sort((t,n)=>t.order-n.order):[],[e])}function oD(e){const t=ve(Sd);Y(()=>{if(!(!t||!e))return t.setLayer(e),()=>t.removeLayer(e.id)},[t,e])}function sD(e){const t=ve(Sd);Y(()=>{if(!(!t||!e))return t.setButton(e),()=>t.removeButton(e.id)},[t,e])}function aD(e){return e==="streaming"?"bg-emerald-500":e==="connecting"?"bg-amber-500":e==="error"?"bg-rose-500":"bg-zinc-500"}function iD(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 Ol({className:e}){return o("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o("polygon",{points:"5 3 19 12 5 21 5 3"})})}function lD({className:e}){return o("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})})}function cD({className:e}){return f("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"}),o("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),o("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),o("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}function dD({className:e}){return f("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[o("circle",{cx:"5",cy:"12",r:"2"}),o("circle",{cx:"12",cy:"12",r:"2"}),o("circle",{cx:"19",cy:"12",r:"2"})]})}function Pi({label:e,active:t,onClick:n}){return f("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:[o("span",{children:e}),o("span",{className:`inline-block h-3 w-5 rounded-full transition-colors ${t?"bg-primary":"bg-foreground-subtle/30"} relative`,children:o("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-white transition-all ${t?"left-2.5":"left-0.5"}`})})]})}function n0({className:e}){return f("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o("polyline",{points:"23 4 23 10 17 10"}),o("polyline",{points:"1 20 1 14 7 14"}),o("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]})}function uD({className:e}){return f("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),o("path",{d:"M10.41 10.41a2 2 0 11-2.83-2.83"}),o("line",{x1:"13.5",y1:"13.5",x2:"6",y2:"21"}),o("path",{d:"M18 12l-1.5-1.5"}),o("path",{d:"M21 15V5a2 2 0 00-2-2H5"}),o("path",{d:"M21 21H5a2 2 0 01-2-2V11"})]})}function Cd({serverUrl:e,createSession:t,sendAnswer:n,closeSession:r,streams:s,activeStreamId:a,onStreamChange:i,deviceName:l,phase:c,pipelineMetrics:d,detections:u,defaultShowDetections:p=!0,defaultShowMotion:h=!1,streamStats:m,autoPlay:g=!1,showPlayStop:b=!1,snapshotSrc:x,snapshotLoading:y=!1,onRefreshSnapshot:w,showStreamStats:v=!1,children:N,extraOverlay:k,ptzAvailable:C=!1,ptzShown:E=!1,ptzOverlay:I,onPtzToggle:A,intercomAvailable:z=!1,intercomShown:P=!1,onIntercomToggle:B,chromeless:R=!1,className:M}){const D=t0(),[T,L]=_(g),[O,F]=_(p),[j,V]=_(h),[$,q]=_(null),[G,Z]=_(!1),oe=te(null);Y(()=>{if(!G)return;function ce(Ce){oe.current&&!oe.current.contains(Ce.target)&&Z(!1)}return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[G]);const ne=a??$??s?.[0]?.id??"",X=s?.find(ce=>ce.id===ne)??s?.[0],re=X?.inputFps!=null?{status:X.status??"unknown",inputFps:X.inputFps,bitrateKbps:X.bitrateKbps??0}:null,be=ce=>{q(ce),i?.(ce),T&&b&&(L(!1),setTimeout(()=>L(!0),50))},J=H(()=>{const ce=X?.target;if(ce)return Ce=>t(ce,Ce)},[t,X]),W=s,ee=()=>L(!0),ae=()=>L(!1),fe=d?.phase??c,ge=fe==="active",Q=!!u,le=Q&&(O||j),ue=C&&E&&!!I,de=b?T:!0;return f("div",{className:`overflow-hidden ${R?"":"rounded-xl border border-border bg-surface"} ${M??""}`,children:[f("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[f("div",{className:"flex items-center gap-2",children:[(m??re)&&o("span",{className:`w-2 h-2 rounded-full ${aD((m??re).status)}`}),l&&o("span",{className:"text-xs font-medium text-foreground",children:l}),W&&W.length>1&&f("div",{className:"relative",children:[o("select",{"data-testid":"stream-profile-select",value:ne,onChange:ce=>be(ce.target.value),className:"appearance-none cursor-pointer rounded-md border border-border bg-surface-hover hover:bg-surface text-foreground text-[11px] font-medium pl-2 pr-6 py-1 focus:outline-none focus:ring-1 focus:ring-primary transition-colors",children:W.map(ce=>o("option",{value:ce.id,children:ce.label},ce.id))}),o("span",{className:"pointer-events-none absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle",children:o("svg",{className:"h-2.5 w-2.5",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o("polyline",{points:"3 4.5 6 7.5 9 4.5"})})})]})]}),f("div",{className:"flex items-center gap-1.5",children:[z&&f("button",{"data-testid":"stream-intercom-toggle","data-intercom-shown":P?"true":"false",onClick:B,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${P?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:P?"Close intercom":"Open intercom",children:[o(cD,{className:"h-3 w-3"}),o("span",{className:"hidden xl:inline",children:"Intercom"})]}),D.map(ce=>{const pe=ce.tone==="primary"?"bg-primary text-primary-foreground":"bg-primary/15 text-primary";return f("button",{type:"button","data-toolbar-button-id":ce.id,"data-toolbar-button-active":ce.active?"true":"false",onClick:ce.onClick,disabled:ce.disabled,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors disabled:opacity-50 ${ce.active?pe:"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:ce.title??ce.label,children:[ce.icon,o("span",{className:"hidden xl:inline",children:ce.label})]},ce.id)}),b&&f("button",{"data-testid":"stream-play-toggle","data-stream-playing":de?"true":"false",onClick:de?ae:ee,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${de?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary/10 text-primary hover:bg-primary/20"}`,title:de?"Stop stream":"Start stream",children:[de?o(lD,{className:"h-3 w-3"}):o(Ol,{className:"h-3 w-3"}),o("span",{className:"hidden xl:inline",children:de?"Stop":"Play"})]}),w&&f("button",{"data-testid":"stream-snapshot-refresh",onClick:w,disabled:y,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",title:"Force snapshot refresh",children:[o(n0,{className:`h-3 w-3 ${y?"animate-spin":""}`}),o("span",{className:"hidden xl:inline",children:"Snapshot"})]}),(Q||C||d||fe||m||re&&re.inputFps>0)&&f("div",{ref:oe,className:"relative",children:[o("button",{onClick:()=>Z(ce=>!ce),title:"More controls",className:"inline-flex items-center justify-center rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:o(dD,{className:"h-3.5 w-3.5"})}),G&&f("div",{className:"absolute right-0 top-full mt-1 z-30 min-w-[200px] rounded-lg border border-border bg-surface shadow-xl py-1.5",children:[v&&m&&f("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[f("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Input"}),f("span",{className:"tabular-nums text-foreground",children:[m.inputFps.toFixed(1)," fps"]})]}),f("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Decode"}),f("span",{className:"tabular-nums text-foreground",children:[m.decodeFps.toFixed(1)," fps"]})]}),f("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Uptime"}),o("span",{className:"tabular-nums text-foreground",children:iD(m.uptimeMs)})]})]}),!v&&re&&re.inputFps>0&&f("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[f("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Input"}),f("span",{className:"tabular-nums text-foreground",children:[re.inputFps.toFixed(1)," fps"]})]}),re.bitrateKbps>0&&f("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Bitrate"}),f("span",{className:"tabular-nums text-foreground",children:[re.bitrateKbps," kbps"]})]})]}),(d||Q&&fe)&&f("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[f("div",{className:"flex justify-between gap-3 items-center",children:[o("span",{children:"Phase"}),f("span",{className:`flex items-center gap-1 font-semibold uppercase tracking-wider ${ge?"text-red-400":"text-emerald-400"}`,children:[o("span",{className:`w-1.5 h-1.5 rounded-full ${ge?"bg-red-500 animate-pulse":"bg-emerald-500"}`}),ge?"Active":"Watching"]})]}),d&&d.detectionFps>0&&f("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Detection"}),f("span",{className:"tabular-nums text-foreground",children:[d.detectionFps.toFixed(1)," det/s"]})]}),d&&d.avgInferenceMs>0&&f("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Inference"}),f("span",{className:"tabular-nums text-foreground",children:[d.avgInferenceMs.toFixed(0)," ms"]})]})]}),Q&&f(me,{children:[o(Pi,{label:"Show detections",active:O,onClick:()=>F(ce=>!ce)}),o(Pi,{label:"Show motion",active:j,onClick:()=>V(ce=>!ce)})]}),C&&o(Pi,{label:"PTZ controls",active:E,onClick:()=>{A?.(),Z(!1)}})]})]})]})]}),de?o("div",{className:"aspect-video relative",children:o(Xy,{serverUrl:e,streamKey:ne,autoPlay:!0,className:"w-full h-full",createSession:J,sendAnswer:n,closeSession:r,overlay:le||k||ue?f(me,{children:[le&&o(Zy,{detections:u,showPhaseIndicator:!1,showMotionZones:j,showMotionRaw:j,showDetections:O}),k,ue&&I]}):void 0},ne)}):o(pD,{src:x??null,isLoading:y,onPlay:ee,onRetry:w,extraOverlay:k||ue?f(me,{children:[k,ue&&I]}):null,suppressPlayHover:!!k||ue}),N]})}function pD({src:e,isLoading:t,onPlay:n,onRetry:r,extraOverlay:s,suppressPlayHover:a=!1}){return e?f("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:[o("img",{src:e,alt:"Camera snapshot",className:"w-full h-full object-contain"}),!a&&o("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:o("div",{className:"h-14 w-14 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center",children:o(Ol,{className:"h-7 w-7 text-white ml-0.5"})})}),s]}):t?o("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:o("div",{className:"h-8 w-8 border-2 border-white/20 border-t-white/60 rounded-full animate-spin"})}):o("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:f("div",{className:"flex flex-col items-center gap-2 text-white/40",children:[o(uD,{className:"h-8 w-8"}),o("span",{className:"text-xs",children:"No snapshot available"}),f("div",{className:"flex items-center gap-2 mt-1",children:[r&&f("button",{onClick:r,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:[o(n0,{className:"h-3 w-3"}),"Retry"]}),f("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:[o(Ol,{className:"h-3 w-3"}),"Play Live"]})]})]})})}const Np={value:"auto",label:"Auto (best available)"};function fD(e){return e.charAt(0).toUpperCase()+e.slice(1)}function hD({deviceId:e,value:t,onChange:n,disabled:r,label:s,className:a}){const i=Jn(),l=jb({deviceId:e},{refetchOnWindowFocus:!1}),[c,d]=_([Np]);Y(()=>{if(!l.data)return;const h=`${e}/`,m=[Np];for(const g of l.data){if(!g.enabled)continue;const b=g.brokerId.startsWith(h)?g.brokerId.slice(h.length):g.brokerId;m.push({value:b,label:fD(b)})}d(m)},[l.data,e]);const u=s??"Preferred stream",p=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 f("div",{className:a,children:[o("label",{id:i,className:"text-xs font-medium text-foreground-muted block mb-1",children:u}),o(Eo,{"aria-labelledby":i,options:c,value:t,disabled:r,onChange:h=>n(h.target.value)}),p!==null&&o("p",{className:"text-foreground-subtle text-[10px] mt-1",children:p})]})}var mD=Object.defineProperty,na=Object.getOwnPropertySymbols,r0=Object.prototype.hasOwnProperty,o0=Object.prototype.propertyIsEnumerable,kp=(e,t,n)=>t in e?mD(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bl=(e,t)=>{for(var n in t||(t={}))r0.call(t,n)&&kp(e,n,t[n]);if(na)for(var n of na(t))o0.call(t,n)&&kp(e,n,t[n]);return e},zl=(e,t)=>{var n={};for(var r in e)r0.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&na)for(var r of na(e))t.indexOf(r)<0&&o0.call(e,r)&&(n[r]=e[r]);return n};/**
|
|
552
|
-
* @license QR Code generator library (TypeScript)
|
|
553
|
-
* Copyright (c) Project Nayuki.
|
|
554
|
-
* SPDX-License-Identifier: MIT
|
|
555
|
-
*/var tr;(e=>{const t=class Pe{constructor(c,d,u,p){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(p<-1||p>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let h=[];for(let g=0;g<this.size;g++)h.push(!1);for(let g=0;g<this.size;g++)this.modules.push(h.slice()),this.isFunction.push(h.slice());this.drawFunctionPatterns();const m=this.addEccAndInterleave(u);if(this.drawCodewords(m),p==-1){let g=1e9;for(let b=0;b<8;b++){this.applyMask(b),this.drawFormatBits(b);const x=this.getPenaltyScore();x<g&&(p=b,g=x),this.applyMask(b)}}s(0<=p&&p<=7),this.mask=p,this.applyMask(p),this.drawFormatBits(p),this.isFunction=[]}static encodeText(c,d){const u=e.QrSegment.makeSegments(c);return Pe.encodeSegments(u,d)}static encodeBinary(c,d){const u=e.QrSegment.makeBytes(c);return Pe.encodeSegments([u],d)}static encodeSegments(c,d,u=1,p=40,h=-1,m=!0){if(!(Pe.MIN_VERSION<=u&&u<=p&&p<=Pe.MAX_VERSION)||h<-1||h>7)throw new RangeError("Invalid value");let g,b;for(g=u;;g++){const v=Pe.getNumDataCodewords(g,d)*8,N=i.getTotalBits(c,g);if(N<=v){b=N;break}if(g>=p)throw new RangeError("Data too long")}for(const v of[Pe.Ecc.MEDIUM,Pe.Ecc.QUARTILE,Pe.Ecc.HIGH])m&&b<=Pe.getNumDataCodewords(g,v)*8&&(d=v);let x=[];for(const v of c){n(v.mode.modeBits,4,x),n(v.numChars,v.mode.numCharCountBits(g),x);for(const N of v.getData())x.push(N)}s(x.length==b);const y=Pe.getNumDataCodewords(g,d)*8;s(x.length<=y),n(0,Math.min(4,y-x.length),x),n(0,(8-x.length%8)%8,x),s(x.length%8==0);for(let v=236;x.length<y;v^=253)n(v,8,x);let w=[];for(;w.length*8<x.length;)w.push(0);return x.forEach((v,N)=>w[N>>>3]|=v<<7-(N&7)),new Pe(g,d,w,h)}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 u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%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 u=0;u<d;u++)for(let p=0;p<d;p++)u==0&&p==0||u==0&&p==d-1||u==d-1&&p==0||this.drawAlignmentPattern(c[u],c[p]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const d=this.errorCorrectionLevel.formatBits<<3|c;let u=d;for(let h=0;h<10;h++)u=u<<1^(u>>>9)*1335;const p=(d<<10|u)^21522;s(p>>>15==0);for(let h=0;h<=5;h++)this.setFunctionModule(8,h,r(p,h));this.setFunctionModule(8,7,r(p,6)),this.setFunctionModule(8,8,r(p,7)),this.setFunctionModule(7,8,r(p,8));for(let h=9;h<15;h++)this.setFunctionModule(14-h,8,r(p,h));for(let h=0;h<8;h++)this.setFunctionModule(this.size-1-h,8,r(p,h));for(let h=8;h<15;h++)this.setFunctionModule(8,this.size-15+h,r(p,h));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let u=0;u<12;u++)c=c<<1^(c>>>11)*7973;const d=this.version<<12|c;s(d>>>18==0);for(let u=0;u<18;u++){const p=r(d,u),h=this.size-11+u%3,m=Math.floor(u/3);this.setFunctionModule(h,m,p),this.setFunctionModule(m,h,p)}}drawFinderPattern(c,d){for(let u=-4;u<=4;u++)for(let p=-4;p<=4;p++){const h=Math.max(Math.abs(p),Math.abs(u)),m=c+p,g=d+u;0<=m&&m<this.size&&0<=g&&g<this.size&&this.setFunctionModule(m,g,h!=2&&h!=4)}}drawAlignmentPattern(c,d){for(let u=-2;u<=2;u++)for(let p=-2;p<=2;p++)this.setFunctionModule(c+p,d+u,Math.max(Math.abs(p),Math.abs(u))!=1)}setFunctionModule(c,d,u){this.modules[d][c]=u,this.isFunction[d][c]=!0}addEccAndInterleave(c){const d=this.version,u=this.errorCorrectionLevel;if(c.length!=Pe.getNumDataCodewords(d,u))throw new RangeError("Invalid argument");const p=Pe.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][d],h=Pe.ECC_CODEWORDS_PER_BLOCK[u.ordinal][d],m=Math.floor(Pe.getNumRawDataModules(d)/8),g=p-m%p,b=Math.floor(m/p);let x=[];const y=Pe.reedSolomonComputeDivisor(h);for(let v=0,N=0;v<p;v++){let k=c.slice(N,N+b-h+(v<g?0:1));N+=k.length;const C=Pe.reedSolomonComputeRemainder(k,y);v<g&&k.push(0),x.push(k.concat(C))}let w=[];for(let v=0;v<x[0].length;v++)x.forEach((N,k)=>{(v!=b-h||k>=g)&&w.push(N[v])});return s(w.length==m),w}drawCodewords(c){if(c.length!=Math.floor(Pe.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let d=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let p=0;p<this.size;p++)for(let h=0;h<2;h++){const m=u-h,b=(u+1&2)==0?this.size-1-p:p;!this.isFunction[b][m]&&d<c.length*8&&(this.modules[b][m]=r(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 u=0;u<this.size;u++){let p;switch(c){case 0:p=(u+d)%2==0;break;case 1:p=d%2==0;break;case 2:p=u%3==0;break;case 3:p=(u+d)%3==0;break;case 4:p=(Math.floor(u/3)+Math.floor(d/2))%2==0;break;case 5:p=u*d%2+u*d%3==0;break;case 6:p=(u*d%2+u*d%3)%2==0;break;case 7:p=((u+d)%2+u*d%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[d][u]&&p&&(this.modules[d][u]=!this.modules[d][u])}}getPenaltyScore(){let c=0;for(let h=0;h<this.size;h++){let m=!1,g=0,b=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[h][x]==m?(g++,g==5?c+=Pe.PENALTY_N1:g>5&&c++):(this.finderPenaltyAddHistory(g,b),m||(c+=this.finderPenaltyCountPatterns(b)*Pe.PENALTY_N3),m=this.modules[h][x],g=1);c+=this.finderPenaltyTerminateAndCount(m,g,b)*Pe.PENALTY_N3}for(let h=0;h<this.size;h++){let m=!1,g=0,b=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[x][h]==m?(g++,g==5?c+=Pe.PENALTY_N1:g>5&&c++):(this.finderPenaltyAddHistory(g,b),m||(c+=this.finderPenaltyCountPatterns(b)*Pe.PENALTY_N3),m=this.modules[x][h],g=1);c+=this.finderPenaltyTerminateAndCount(m,g,b)*Pe.PENALTY_N3}for(let h=0;h<this.size-1;h++)for(let m=0;m<this.size-1;m++){const g=this.modules[h][m];g==this.modules[h][m+1]&&g==this.modules[h+1][m]&&g==this.modules[h+1][m+1]&&(c+=Pe.PENALTY_N2)}let d=0;for(const h of this.modules)d=h.reduce((m,g)=>m+(g?1:0),d);const u=this.size*this.size,p=Math.ceil(Math.abs(d*20-u*10)/u)-1;return s(0<=p&&p<=9),c+=p*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 u=[6];for(let p=this.size-7;u.length<c;p-=d)u.splice(1,0,p);return u}}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 u=Math.floor(c/7)+2;d-=(25*u-10)*u-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 p=0;p<c-1;p++)d.push(0);d.push(1);let u=1;for(let p=0;p<c;p++){for(let h=0;h<d.length;h++)d[h]=Pe.reedSolomonMultiply(d[h],u),h+1<d.length&&(d[h]^=d[h+1]);u=Pe.reedSolomonMultiply(u,2)}return d}static reedSolomonComputeRemainder(c,d){let u=d.map(p=>0);for(const p of c){const h=p^u.shift();u.push(0),d.forEach((m,g)=>u[g]^=Pe.reedSolomonMultiply(m,h))}return u}static reedSolomonMultiply(c,d){if(c>>>8||d>>>8)throw new RangeError("Byte out of range");let u=0;for(let p=7;p>=0;p--)u=u<<1^(u>>>7)*285,u^=(d>>>p&1)*c;return s(u>>>8==0),u}finderPenaltyCountPatterns(c){const d=c[1];s(d<=this.size*3);const u=d>0&&c[2]==d&&c[3]==d*3&&c[4]==d&&c[5]==d;return(u&&c[0]>=d*4&&c[6]>=d?1:0)+(u&&c[6]>=d*4&&c[0]>=d?1:0)}finderPenaltyTerminateAndCount(c,d,u){return c&&(this.finderPenaltyAddHistory(d,u),d=0),d+=this.size,this.finderPenaltyAddHistory(d,u),this.finderPenaltyCountPatterns(u)}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 u=c-1;u>=0;u--)d.push(l>>>u&1)}function r(l,c){return(l>>>c&1)!=0}function s(l){if(!l)throw new Error("Assertion error")}const a=class Qe{constructor(c,d,u){if(this.mode=c,this.numChars=d,this.bitData=u,d<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(c){let d=[];for(const u of c)n(u,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 u=0;u<c.length;){const p=Math.min(c.length-u,3);n(parseInt(c.substring(u,u+p),10),p*3+1,d),u+=p}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=[],u;for(u=0;u+2<=c.length;u+=2){let p=Qe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(u))*45;p+=Qe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(u+1)),n(p,11,d)}return u<c.length&&n(Qe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(u)),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 u=0;for(const p of c){const h=p.mode.numCharCountBits(d);if(p.numChars>=1<<h)return 1/0;u+=4+h+p.bitData.length}return u}static toUtf8ByteArray(c){c=encodeURI(c);let d=[];for(let u=0;u<c.length;u++)c.charAt(u)!="%"?d.push(c.charCodeAt(u)):(d.push(parseInt(c.substring(u+1,u+3),16)),u+=2);return d}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let i=a;e.QrSegment=a})(tr||(tr={}));(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={}))})(tr||(tr={}));(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={}))})(tr||(tr={}));var kr=tr;/**
|
|
556
|
-
* @license qrcode.react
|
|
557
|
-
* Copyright (c) Paul O'Shannessy
|
|
558
|
-
* SPDX-License-Identifier: ISC
|
|
559
|
-
*/var gD={L:kr.QrCode.Ecc.LOW,M:kr.QrCode.Ecc.MEDIUM,Q:kr.QrCode.Ecc.QUARTILE,H:kr.QrCode.Ecc.HIGH},s0=128,a0="L",i0="#FFFFFF",l0="#000000",c0=!1,d0=1,bD=4,xD=0,yD=.1;function u0(e,t=0){const n=[];return e.forEach(function(r,s){let a=null;r.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===r.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 p0(e,t){return e.slice().map((n,r)=>r<t.y||r>=t.y+t.h?n:n.map((s,a)=>a<t.x||a>=t.x+t.w?s:!1))}function vD(e,t,n,r){if(r==null)return null;const s=e.length+n*2,a=Math.floor(t*yD),i=s/t,l=(r.width||a)*i,c=(r.height||a)*i,d=r.x==null?e.length/2-l/2:r.x*i,u=r.y==null?e.length/2-c/2:r.y*i,p=r.opacity==null?1:r.opacity;let h=null;if(r.excavate){let g=Math.floor(d),b=Math.floor(u),x=Math.ceil(l+d-g),y=Math.ceil(c+u-b);h={x:g,y:b,w:x,h:y}}const m=r.crossOrigin;return{x:d,y:u,h:c,w:l,excavation:h,opacity:p,crossOrigin:m}}function wD(e,t){return t!=null?Math.max(Math.floor(t),0):e?bD:xD}function f0({value:e,level:t,minVersion:n,includeMargin:r,marginSize:s,imageSettings:a,size:i,boostLevel:l}){let c=Ge.useMemo(()=>{const g=(Array.isArray(e)?e:[e]).reduce((b,x)=>(b.push(...kr.QrSegment.makeSegments(x)),b),[]);return kr.QrCode.encodeSegments(g,gD[t],n,void 0,void 0,l)},[e,t,n,l]);const{cells:d,margin:u,numCells:p,calculatedImageSettings:h}=Ge.useMemo(()=>{let m=c.getModules();const g=wD(r,s),b=m.length+g*2,x=vD(m,i,g,a);return{cells:m,margin:g,numCells:b,calculatedImageSettings:x}},[c,i,a,r,s]);return{qrcode:c,margin:u,cells:d,numCells:p,calculatedImageSettings:h}}var ND=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),kD=Ge.forwardRef(function(t,n){const r=t,{value:s,size:a=s0,level:i=a0,bgColor:l=i0,fgColor:c=l0,includeMargin:d=c0,minVersion:u=d0,boostLevel:p,marginSize:h,imageSettings:m}=r,b=zl(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:x}=b,y=zl(b,["style"]),w=m?.src,v=Ge.useRef(null),N=Ge.useRef(null),k=Ge.useCallback(M=>{v.current=M,typeof n=="function"?n(M):n&&(n.current=M)},[n]),[C,E]=Ge.useState(!1),{margin:I,cells:A,numCells:z,calculatedImageSettings:P}=f0({value:s,level:i,minVersion:u,boostLevel:p,includeMargin:d,marginSize:h,imageSettings:m,size:a});Ge.useEffect(()=>{if(v.current!=null){const M=v.current,D=M.getContext("2d");if(!D)return;let T=A;const L=N.current,O=P!=null&&L!==null&&L.complete&&L.naturalHeight!==0&&L.naturalWidth!==0;O&&P.excavation!=null&&(T=p0(A,P.excavation));const F=window.devicePixelRatio||1;M.height=M.width=a*F;const j=a/z*F;D.scale(j,j),D.fillStyle=l,D.fillRect(0,0,z,z),D.fillStyle=c,ND?D.fill(new Path2D(u0(T,I))):A.forEach(function(V,$){V.forEach(function(q,G){q&&D.fillRect(G+I,$+I,1,1)})}),P&&(D.globalAlpha=P.opacity),O&&D.drawImage(L,P.x+I,P.y+I,P.w,P.h)}}),Ge.useEffect(()=>{E(!1)},[w]);const B=Bl({height:a,width:a},x);let R=null;return w!=null&&(R=Ge.createElement("img",{src:w,key:w,style:{display:"none"},onLoad:()=>{E(!0)},ref:N,crossOrigin:P?.crossOrigin})),Ge.createElement(Ge.Fragment,null,Ge.createElement("canvas",Bl({style:B,height:a,width:a,ref:k,role:"img"},y)),R)});kD.displayName="QRCodeCanvas";var h0=Ge.forwardRef(function(t,n){const r=t,{value:s,size:a=s0,level:i=a0,bgColor:l=i0,fgColor:c=l0,includeMargin:d=c0,minVersion:u=d0,boostLevel:p,title:h,marginSize:m,imageSettings:g}=r,b=zl(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:x,cells:y,numCells:w,calculatedImageSettings:v}=f0({value:s,level:i,minVersion:u,boostLevel:p,includeMargin:d,marginSize:m,imageSettings:g,size:a});let N=y,k=null;g!=null&&v!=null&&(v.excavation!=null&&(N=p0(y,v.excavation)),k=Ge.createElement("image",{href:g.src,height:v.h,width:v.w,x:v.x+x,y:v.y+x,preserveAspectRatio:"none",opacity:v.opacity,crossOrigin:v.crossOrigin}));const C=u0(N,x);return Ge.createElement("svg",Bl({height:a,width:a,viewBox:`0 0 ${w} ${w}`,ref:n,role:"img"},b),!!h&&Ge.createElement("title",null,h),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)});h0.displayName="QRCodeSVG";const SD=192;function m0({value:e,size:t=SD,className:n,alt:r}){const s=e.trim();return s.length===0?null:o("div",{className:K("inline-flex rounded-md bg-white p-2",n),children:o(h0,{value:s,size:t,marginSize:1,title:r??"QR code"})})}const CD=2e3;function g0({value:e,label:t,className:n,disabled:r}){const[s,a]=_(!1),i=U(()=>{e&&navigator.clipboard.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),CD)})},[e]);return f(Be,{size:"sm",variant:"ghost",type:"button",disabled:r||e.length===0,onClick:i,className:K(n),"aria-label":s?"Copied":`Copy ${t??"value"}`,children:[s?o(qr,{className:"h-3.5 w-3.5 text-success"}):o(yn,{className:"h-3.5 w-3.5"}),t?o("span",{className:"ml-1",children:s?"Copied":t}):null]})}const MD=N2(x2),Sp=1e4;function Cp(e){return e==="linked"?"success":e==="error"?"danger":"warning"}function Mp(e){return e==="linked"?"Linked":e==="unlinked"?"Unlinked":e==="error"?"Error":e}function ED({field:e}){const[t,n]=_(!1),r=e.secret===!0,a=r&&!t?"•".repeat(Math.min(e.value.length,24)):e.value;return f("div",{className:"flex items-center gap-2 py-1.5",children:[o("span",{className:"text-[11px] text-foreground-subtle w-32 shrink-0",children:e.label}),o("span",{className:"flex-1 min-w-0 truncate font-mono text-xs text-foreground",children:a||"—"}),r&&o(Be,{size:"sm",variant:"ghost",type:"button","aria-label":t?"Hide value":"Reveal value",onClick:()=>n(i=>!i),children:t?o(_c,{className:"h-3.5 w-3.5"}):o(Ur,{className:"h-3.5 w-3.5"})}),o(g0,{value:e.value,label:e.label})]})}function ID({setup:e}){const t=e.fields??[];return f("div",{className:"border-b border-border bg-surface-hover/10",children:[f("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border",children:[o(zS,{className:"h-3.5 w-3.5 text-foreground-subtle shrink-0"}),o("span",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Setup"})]}),f("div",{className:"flex flex-col gap-3 p-4 sm:flex-row sm:items-start",children:[e.qr&&o("div",{className:"shrink-0",children:o(m0,{value:e.qr,alt:"Pairing QR code"})}),f("div",{className:"flex-1 min-w-0",children:[e.note&&o("p",{className:"text-xs text-foreground-muted whitespace-pre-line mb-2",children:e.note}),t.length>0&&o("div",{className:"divide-y divide-border-subtle",children:t.map(n=>o(ED,{field:n},n.label))})]})]})]})}function Md({addonId:e,onOpenDevice:t}){const n=ke(),r=ld({nodeId:"hub",addonId:e},{refetchInterval:Sp,retry:!1}),s=Ub({nodeId:"hub",addonId:e},{refetchInterval:Sp,retry:!1}),a=Qb({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceExport"]]})}}),i=H(()=>{const m=um.safeParse(r.data);return m.success?m.data:null},[r.data]),l=H(()=>{const m=MD.safeParse(s.data);return m.success?m.data:[]},[s.data]),c=i?.linkState??"unlinked",d=H(()=>l.map(m=>({deviceId:m.deviceId,displayName:m.exposedAs??`Device ${m.deviceId}`,streamPreference:"auto",linkState:c})),[l,c]),u=r.isLoading||s.isLoading,p=i?.exposedDeviceCount??d.length,h=H(()=>[{key:"device",header:"Device",render:m=>f("div",{className:"flex flex-col",children:[o("span",{className:"text-foreground font-medium",children:m.displayName}),f("span",{className:"text-foreground-subtle text-xs font-mono",children:["#",m.deviceId]})]})},{key:"status",header:"Status",render:m=>o(zt,{variant:Cp(m.linkState),children:Mp(m.linkState)})},{key:"stream",header:"Stream",render:m=>o("span",{className:"text-xs text-foreground-subtle font-mono",children:m.streamPreference==="auto"?"Auto":m.streamPreference})},{key:"actions",header:"",align:"right",render:m=>f("div",{className:"flex items-center justify-end gap-2",children:[t&&f(Be,{size:"sm",variant:"ghost",onClick:()=>t(m.deviceId),children:[o(Pc,{className:"h-3.5 w-3.5 mr-1"}),"Open"]}),f(Be,{size:"sm",variant:"ghost",disabled:a.isPending,onClick:()=>a.mutate({deviceId:m.deviceId,nodeId:"hub",addonId:e}),children:[o(MC,{className:"h-3.5 w-3.5 mr-1"}),"Unexpose"]})]})}],[t,a,e]);return f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 border-b border-border bg-surface-hover/20",children:[f("div",{className:"flex items-center gap-2 min-w-0",children:[o(Ku,{className:"h-3.5 w-3.5 text-foreground-subtle shrink-0"}),o("span",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Exported devices"}),o(zt,{variant:Cp(c),children:Mp(c)}),f("span",{className:"text-[11px] text-foreground-subtle",children:[p," exposed"]})]}),u&&o(Ct,{className:"h-3.5 w-3.5 animate-spin text-foreground-subtle"})]}),i?.error&&o("div",{className:"px-4 py-3 border-b border-border",children:o(Oa,{message:i.error})}),i?.setup&&o(ID,{setup:i.setup}),d.length===0?o(Wc,{icon:Ku,title:"No devices exposed",description:`Expose a camera to "${e}" from its device-details page to surface it in the connected ecosystem.`}):o("div",{className:"p-3",children:o(Da,{columns:h,rows:d,rowKey:m=>m.deviceId})})]})}function AD({samples:e,sampleRate:t=16e3,height:n=96,className:r="",color:s="#3b82f6",bgColor:a="transparent"}){const i=te(null),l=te(null),c=U(()=>{const p=i.current,h=l.current;if(!p||!h||!e||e.length===0)return;const m=h.clientWidth;if(m===0)return;const g=window.devicePixelRatio||1;p.width=m*g,p.height=n*g,p.style.width=`${m}px`,p.style.height=`${n}px`;const b=p.getContext("2d");if(!b)return;b.scale(g,g),a!=="transparent"?(b.fillStyle=a,b.fillRect(0,0,m,n)):b.clearRect(0,0,m,n);const x=e.length/m,y=n/2;b.fillStyle=s,b.globalAlpha=.7;for(let w=0;w<m;w++){const v=Math.floor(w*x),N=Math.min(Math.floor((w+1)*x),e.length);let k=0,C=0;for(let z=v;z<N;z++){const P=e[z];P<k&&(k=P),P>C&&(C=P)}const E=y-C*y,I=y-k*y,A=Math.max(1,I-E);b.fillRect(w,E,1,A)}b.globalAlpha=1,b.strokeStyle=s,b.globalAlpha=.2,b.lineWidth=1,b.beginPath(),b.moveTo(0,y),b.lineTo(m,y),b.stroke(),b.globalAlpha=1},[e,n,s,a]);Y(()=>{c()},[c]),Y(()=>{const p=new ResizeObserver(()=>c()),h=l.current;return h&&p.observe(h),()=>p.disconnect()},[c]);const u=((e&&t?Math.round(e.length/t*1e3):0)/1e3).toFixed(1);return f("div",{ref:l,className:`relative ${r}`,children:[o("canvas",{ref:i,className:"w-full rounded-md"}),e&&e.length>0&&f("div",{className:"absolute bottom-1 right-2 text-[10px] text-foreground-subtle/60 font-mono",children:[u,"s · ",t/1e3,"kHz · ",e.length.toLocaleString()," samples"]})]})}function PD({currentDbfs:e,durationSec:t=30,maxSamples:n=120,height:r=64,className:s="",color:a="#10b981",clipColor:i="#ef4444",clipThreshold:l=-6,minDbfs:c=-96}){const d=te(null),u=te(null),[p,h]=_([]);Y(()=>{e!==null&&h(b=>{const x=[...b,{dbfs:e,timestamp:Date.now()}];return x.length>n?x.slice(-n):x})},[e,n]);const m=U(()=>{const b=d.current,x=u.current;if(!b||!x)return;const y=x.clientWidth;if(y===0)return;const w=window.devicePixelRatio||1;b.width=y*w,b.height=r*w,b.style.width=`${y}px`,b.style.height=`${r}px`;const v=b.getContext("2d");if(!v||(v.scale(w,w),v.clearRect(0,0,y,r),p.length===0))return;const N=p[p.length-1].timestamp,k=t*1e3,C=N-k,E=p.filter(P=>P.timestamp>=C);if(E.length===0)return;const I=Math.max(1,Math.floor(y/(t*2))),A=Math.abs(c);for(const P of E){const B=P.timestamp-C,R=Math.floor(B/k*y),D=(Math.max(c,Math.min(0,P.dbfs))-c)/A,T=Math.max(1,D*r),L=P.dbfs>=l;v.fillStyle=L?i:a,v.globalAlpha=.8,v.fillRect(R,r-T,I,T)}v.globalAlpha=1;const z=r-(l-c)/A*r;v.strokeStyle=i,v.globalAlpha=.25,v.lineWidth=1,v.setLineDash([4,4]),v.beginPath(),v.moveTo(0,z),v.lineTo(y,z),v.stroke(),v.setLineDash([]),v.globalAlpha=1},[p,t,r,a,i,l,c]);Y(()=>{m()},[m]),Y(()=>{const b=new ResizeObserver(()=>m()),x=u.current;return x&&b.observe(x),()=>b.disconnect()},[m]);const g=p.length>0?p[p.length-1].dbfs:null;return f("div",{ref:u,className:`relative ${s}`,children:[o("canvas",{ref:d,className:"w-full rounded-md"}),f("div",{className:"absolute top-1 left-2 text-[9px] text-foreground-subtle/50 font-mono",children:[t,"s"]}),g!==null&&f("div",{className:"absolute bottom-1 right-2 text-[9px] text-foreground-subtle/50 font-mono",children:[g.toFixed(1)," dBFS · ",p.length," samples"]})]})}function _D(e){return e>=.8?"bg-emerald-500":e>=.5?"bg-amber-500":e>=.3?"bg-orange-500":"bg-zinc-500"}function $D(e){return e>=.8?"text-emerald-400":e>=.5?"text-amber-400":e>=.3?"text-orange-400":"text-zinc-400"}function DD({classifications:e,processing:t=!1,inferenceMs:n,maxItems:r=10,className:s=""}){const a=e.slice(0,r),i=a.length>0?a[0].score:1;return t?o("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${s}`,children:o("div",{className:"text-sm text-foreground-subtle animate-pulse",children:"Classifying audio..."})}):a.length===0?o("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${s}`,children:o("div",{className:"text-xs text-foreground-subtle",children:"No classifications yet"})}):f("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${s}`,children:[f("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between",children:[o("h3",{className:"text-xs font-medium text-foreground",children:"Audio Classifications"}),f("div",{className:"flex items-center gap-3 text-[10px] text-foreground-subtle",children:[a.length<e.length&&f("span",{children:["showing ",a.length," of ",e.length]}),n!==void 0&&f("span",{className:"font-mono",children:[n.toFixed(1),"ms"]})]})]}),o("div",{className:"divide-y divide-border/50",children:a.map((l,c)=>{const d=i>0?l.score/i*100:0;return f("div",{className:"px-3 py-1.5 flex items-center gap-3 hover:bg-surface-hover/30",children:[o("span",{className:"text-[10px] text-foreground-subtle w-5 text-right font-mono",children:c+1}),o("span",{className:"text-xs font-medium text-foreground min-w-[120px]",children:l.className}),o("div",{className:"flex-1 h-2 rounded-full bg-zinc-800 overflow-hidden",children:o("div",{className:`h-full rounded-full transition-all duration-300 ${_D(l.score)}`,style:{width:`${d}%`}})}),f("span",{className:`text-xs font-mono font-semibold w-14 text-right ${$D(l.score)}`,children:[(l.score*100).toFixed(1),"%"]})]},`${l.className}-${c}`)})})]})}function TD({data:e,label:t="Response",className:n=""}){const[r,s]=_(!1);if(!e)return null;const a=JSON.stringify(e,null,2);return f("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${n}`,children:[f("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:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-[10px] text-foreground-subtle",children:r?"▼":"▶"}),o("h3",{className:"text-xs font-medium text-foreground",children:t})]}),o("span",{className:"text-[10px] text-foreground-subtle font-mono",children:a.length>1e3?`${(a.length/1024).toFixed(1)} KB`:`${a.length} bytes`})]}),r&&o("div",{className:"max-h-80 overflow-y-auto overflow-x-auto",children:o("pre",{className:"p-3 text-[10px] leading-4 font-mono text-foreground-subtle whitespace-pre",children:a})})]})}const LD={Activity:In,Eye:Ur,AlertTriangle:Qr,PauseCircle:B5,PowerOff:OS};function Ed({phase:e,...t}){const n=ur(e),r=LD[n.icon];return o(r,{...t})}function Yn(e){const[t,n]=_([]),r=U(a=>{n(i=>{const l=[...i,a];return l.length>e?l.slice(-e):l})},[e]),s=U(()=>{n([])},[]);return H(()=>({entries:t,append:r,reset:s}),[t,r,s])}function Ep(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 Ip={error:{icon:Uo,color:"text-red-400"},warn:{icon:Qr,color:"text-amber-400"},info:{icon:fS,color:"text-blue-400"},debug:{icon:w5,color:"text-gray-500"}},Ap={debug:0,info:1,warn:2,error:3},RD=["all","debug","info","warn","error"],OD=500;function BD(e,t){return t?(Ap[e]??0)>=(Ap[t]??0):!0}function tn({agentId:e,addonId:t,deviceId:n,integrationId:r,requestId:s,level:a,maxHeight:i="max-h-96",showScope:l=!1,showFilters:c=!0,limit:d=100,liveBuffer:u,onClose:p,className:h}){const[m,g]=_(""),[b,x]=_(""),[y,w]=_(a),v=e,N=t??(m||void 0),k=n??(b?Number(b):void 0),C=r,E=s,I=H(()=>{const Q={};return v&&(Q.agentId=v),N&&(Q.addonId=N),k!==void 0&&Number.isFinite(k)&&(Q.deviceId=k),C&&(Q.integrationId=C),E&&(Q.requestId=E),Object.keys(Q).length>0?Q:void 0},[v,N,k,C,E]),A=Yn(OD),z=u??A,P=z.entries,[B,R]=_(0),[M,D]=_(!1),[T,L]=_(!1),[O,F]=_(new Set),[j,V]=_(""),$=te(null),q=`${v??""}:${N??""}:${String(k??"")}:${C??""}:${E??""}`,G=te(q);Y(()=>{G.current!==q&&(G.current=q,z.reset(),R(0),F(new Set))},[q,z]);const{data:Z,isLoading:oe}=S.logs.query.useQuery({...I?{tags:I}:{},limit:d},{staleTime:3e4});S.logs.subscribe.useSubscription({...I?{tags:I}:{}},{onData:Q=>{z.append(Q)}});const ne=te(P.length);Y(()=>{const Q=$.current;if(!Q){ne.current=P.length;return}const le=ne.current;if(ne.current=P.length,!(P.length<=le)){if(M&&Q.scrollTop<=8)Q.scrollTo({top:0});else if(!M&&Q.scrollTop>0){const ue=Q.querySelector("tbody tr"),de=ue instanceof HTMLElement?ue.offsetHeight:24;Q.scrollTop+=de*(P.length-le)}}},[P.length,M]);const X=H(()=>{const Q=(Z??[]).map(pe=>({timestamp:pe.timestamp,level:pe.level,message:pe.message,scope:pe.scope,tags:pe.tags,meta:pe.meta})),le=new Set,ue=[];for(const pe of[...P].reverse()){const $e=`${pe.timestamp}|${pe.level}|${pe.scope??""}|${pe.message}`;le.has($e)||(le.add($e),ue.push(pe))}for(const pe of Q){const $e=`${pe.timestamp}|${pe.level}|${pe.scope??""}|${pe.message}`;le.has($e)||(le.add($e),ue.push(pe))}const ce=(B>0?ue.filter(pe=>new Date(pe.timestamp).getTime()>B):ue).filter(pe=>BD(pe.level,y)),Ce=j.trim().toLowerCase();return Ce?ce.filter(pe=>{if(pe.message.toLowerCase().includes(Ce)||pe.scope&&pe.scope.toLowerCase().includes(Ce))return!0;if(pe.tags){for(const $e of Object.values(pe.tags))if($e!==void 0&&String($e).toLowerCase().includes(Ce))return!0}if(pe.meta){for(const $e of Object.values(pe.meta))if($e!=null&&Ep($e).toLowerCase().includes(Ce))return!0}return!1}):ce},[Z,P,y,B,j]),re=U(()=>{const Q=X.map(le=>{const ue=new Date(le.timestamp).toLocaleTimeString(),de=le.tags?" "+Object.entries(le.tags).filter(([,ce])=>ce).map(([ce,Ce])=>`${ce}=${Ce}`).join(" "):"";return`${ue} [${le.level.toUpperCase()}]${le.scope?` [${le.scope}]`:""}${de} ${le.message}`});navigator.clipboard.writeText(Q.join(`
|
|
560
|
-
`)).then(()=>{L(!0),setTimeout(()=>L(!1),1500)})},[X]),be=S.logs.clear.useMutation(),J=U(()=>{R(Date.now()),z.reset(),be.mutate({...I?{tags:I}:{}})},[z,be,I]),W=U(Q=>{F(le=>{const ue=new Set(le);return ue.has(Q)?ue.delete(Q):ue.add(Q),ue})},[]),[ee,ae]=_(null),fe=U((Q,le)=>{const ue=new Date(Q.timestamp).toISOString(),de=Q.tags?" "+Object.entries(Q.tags).filter(([,pe])=>pe).map(([pe,$e])=>`${pe}=${$e}`).join(" "):"",ce=Q.meta&&Object.keys(Q.meta).length>0?` meta=${JSON.stringify(Q.meta)}`:"",Ce=`${ue} [${Q.level.toUpperCase()}]${Q.scope?` [${Q.scope}]`:""}${de} ${Q.message}${ce}`;navigator.clipboard.writeText(Ce).then(()=>{ae(le),setTimeout(()=>ae(pe=>pe===le?null:pe),1200)})},[]),ge=U(Q=>`${Q.timestamp}|${Q.level}|${Q.scope??""}|${Q.message}`,[]);return f("div",{className:K("h-full min-h-0 flex flex-col",h),onClick:Q=>Q.stopPropagation(),children:[f("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Logs"}),v&&o(_i,{label:"agent",value:v}),N&&o(_i,{label:"addon",value:N}),k!==void 0&&o(_i,{label:"device",value:`#${k}`}),o("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:RD.map(Q=>f("button",{type:"button",onClick:()=>w(Q==="all"?void 0:Q),className:K("px-1.5 py-0.5 capitalize transition-colors",Q==="all"&&!y||y===Q?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover",Q!=="all"&&"border-l border-border"),children:[Q,Q!=="all"?"+":""]},Q))}),o($i,{icon:Ic,label:M?"Auto":"Paused",active:!M,onClick:()=>{D(Q=>!Q),!M&&$.current&&$.current.scrollTo({top:0,behavior:"smooth"})}}),o($i,{icon:yn,label:T?"Copied!":"Copy",onClick:re,disabled:X.length===0}),o($i,{icon:Zt,label:"Clear",onClick:J}),f("div",{className:"relative",children:[o("input",{type:"text",value:j,onChange:Q=>V(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"}),j&&o("button",{type:"button",onClick:()=>V(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:o(Je,{className:"h-2.5 w-2.5"})})]}),P.length>0&&f("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",P.length," live"]})]}),p&&o("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:o(Je,{className:"h-3.5 w-3.5"})})]}),c&&(!t||!n)&&f("div",{className:"flex items-center gap-2 px-3 py-1 border-b border-border/50 bg-surface/50 text-[10px]",children:[!t&&f("label",{className:"flex items-center gap-1",children:[o("span",{className:"text-foreground-subtle",children:"Addon:"}),o("input",{type:"text",value:m,onChange:Q=>g(Q.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&&f("label",{className:"flex items-center gap-1",children:[o("span",{className:"text-foreground-subtle",children:"Device:"}),o("input",{type:"text",inputMode:"numeric",value:b,onChange:Q=>x(Q.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"})]})]}),f("div",{ref:$,className:K("flex-1 min-h-0 overflow-auto font-mono text-[10px]",i),children:[oe&&f("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[o(Ct,{className:"h-3.5 w-3.5 animate-spin"}),"Loading logs..."]}),!oe&&X.length===0&&o("div",{className:"py-4 text-center text-foreground-subtle",children:"No logs found"}),X.length>0&&o("table",{className:"w-full",children:o("tbody",{children:X.map(Q=>{const le=Ip[Q.level]??Ip.info,ue=le.icon,de=ge(Q),ce=O.has(de),Ce=Q.tags&&Object.keys(Q.tags).length>0,pe=Q.meta&&Object.keys(Q.meta).length>0,$e=Ce||pe;return f("tr",{className:K("hover:bg-surface-hover/30 border-b border-border/30",$e&&"cursor-pointer"),onClick:$e?()=>W(de):void 0,children:[o("td",{className:"px-2 py-1 text-foreground-subtle whitespace-nowrap align-top w-[70px]",children:new Date(Q.timestamp).toLocaleTimeString()}),o("td",{className:K("px-1 py-1 align-top w-5",le.color),children:o(ue,{className:"h-3 w-3"})}),l&&o("td",{className:"px-2 py-1 text-foreground-subtle align-top truncate max-w-[120px]",title:Q.scope,children:Q.scope?.replace(/^addon:/,"")??""}),o("td",{className:"px-2 py-1 text-foreground break-all",children:f("div",{className:"flex items-start gap-1",children:[$e&&(ce?o(pr,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"}):o(On,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"})),f("div",{className:"flex-1 min-w-0",children:[Q.message,ce&&$e&&f("div",{className:"mt-1 text-[9px] text-foreground-subtle bg-surface rounded px-2 py-1 space-y-0.5",children:[pe&&Object.entries(Q.meta).filter(([,Ae])=>Ae!==void 0&&Ae!=="").map(([Ae,Xe])=>f("div",{children:[o("span",{className:"text-amber-400/80 font-medium",children:Ae}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground break-all",children:Ep(Xe)})]},`m-${Ae}`)),Ce&&Object.entries(Q.tags).filter(([,Ae])=>Ae!==void 0).map(([Ae,Xe])=>f("div",{children:[o("span",{className:"text-primary/70 font-medium",children:Ae}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground",children:Xe})]},`t-${Ae}`))]})]})]})}),o("td",{className:"px-1 py-1 align-top w-5",children:o(zD,{copied:ee===de,onCopy:()=>fe(Q,de)})})]},de)})})})]})]})}function b0({position:e="bottom",className:t,...n}){return o("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:o(tn,{maxHeight:"max-h-48",...n})})}function _i({label:e,value:t}){return f("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function zD({copied:e,onCopy:t}){return o("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?o(qr,{className:"h-3 w-3"}):o(yn,{className:"h-3 w-3"})})}function $i({icon:e,label:t,onClick:n,disabled:r,active:s}){return f("button",{type:"button",onClick:n,disabled:r,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",r&&"opacity-40 cursor-not-allowed"),children:[o(e,{className:"h-2.5 w-2.5"}),t]})}function FD(e,t,n,r){if(r!==void 0&&(e.source.deviceId??(e.source.type==="device"&&typeof e.source.id=="number"?e.source.id:void 0))!==r||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 jD={[Ne.AddonStarted]:{icon:Pl,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Started"},[Ne.AddonInstalled]:{icon:Il,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Installed"},[Ne.AddonRestarted]:{icon:$a,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Restarted"},[Ne.AddonUpdated]:{icon:og,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Updated"},[Ne.AddonStopped]:{icon:Wu,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Stopped"},[Ne.AddonUninstalled]:{icon:Zt,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Uninstalled"},[Ne.AddonCrashed]:{icon:Uo,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Crashed"},[Ne.AddonError]:{icon:Qr,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Error"},[Ne.DetectionPhaseTransition]:{icon:In,color:"bg-violet-500/15 text-violet-400 border-violet-500/30",label:"Phase"},[Ne.DetectionResult]:{icon:WS,color:"bg-purple-500/15 text-purple-400 border-purple-500/30",label:"Detection"},[Ne.DetectionEvent]:{icon:Ur,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Event"},[Ne.DetectionCameraNative]:{icon:Yu,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Camera AI"},[Ne.ProviderMotion]:{icon:Zu,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Ne.MotionOnMotionChanged]:{icon:Zu,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Ne.MotionAnalysis]:{icon:In,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion analysis"},[Ne.MotionZonesRaw]:{icon:In,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion zones"},[Ne.ProviderDetection]:{icon:Yu,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Provider Det"},[Ne.PipelineAudioInferenceResult]:{icon:Xm,color:"bg-pink-500/15 text-pink-400 border-pink-500/30",label:"Audio"},[Ne.AgentOnline]:{icon:Pl,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Agent Online"},[Ne.AgentOffline]:{icon:Wu,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Agent Offline"},[Ne.DeviceRegistered]:{icon:Il,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Registered"},[Ne.DeviceUnregistered]:{icon:Zt,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Unregistered"},[Ne.DeviceStateChanged]:{icon:In,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"State"}};function Fl(e,t){const n=jD[e]??{icon:Pl,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:e.split(".").pop()??e};if(e===Ne.DeviceStateChanged&&t&&typeof t.capName=="string"){const r=t.capName;return{...n,label:r}}return n}const Nr=Object.freeze([...new Set(Object.values(Ne))].sort()),VD=Object.freeze([Ne.PipelineCameraMetricsSnapshot,Ne.PipelineRunnerLoadSnapshot,Ne.PipelineEngineMetricsSnapshot,Ne.PipelineInferenceResult,Ne.PipelineTrace,Ne.PipelineProgress,Ne.StreamBrokerMetricsSnapshot,Ne.MetricsNodeResourcesSnapshot,Ne.MetricsNodeProcessesSnapshot,Ne.ClusterTopologySnapshot,Ne.MotionAnalysis,Ne.MotionZonesRaw,Ne.DetectionResult,Ne.PipelineAudioInferenceResult,Ne.PlatformProbePhase,Ne.BenchmarkProgress,Ne.ModelDownloadProgress]),HD=new Set(VD),qD=Object.freeze(Nr.filter(e=>!HD.has(e)));function js(e,t){if(e===Ne.DetectionPhaseTransition){const s=t.to,a=t.from,i=typeof t.source=="string"?t.source:null,l=typeof t.cooldownMs=="number"?t.cooldownMs:null,c=i?` (${i}${l?`, ${Math.round(l/1e3)}s cooldown`:""})`:"";return s==="active"?`Motion detected — phase active${c}`:s==="watching"?`Cooldown expired — phase watching${c}`:`Phase: ${String(a)} → ${String(s)}${c}`}if(e===Ne.DetectionResult){const a=t.frame?.detections??[];if(a.length===0)return null;const i=new Map;for(const l of a){const c=l,d=c.class??c.macroClass,u=typeof d=="string"?d:"";u&&i.set(u,(i.get(u)??0)+1)}return[...i.entries()].map(([l,c])=>c>1?`${l} ×${c}`:l).join(", ")}if(e===Ne.PipelineAudioInferenceResult){const a=t.frame?.detections??[];return a.length===0?null:a.map(i=>{const l=i,c=l.macroClass??l.class??l.label,d=typeof c=="string"?c:"",u=l.score;return u?`${d} (${Math.round(u*100)}%)`:d}).filter(Boolean).join(", ")}if(e===Ne.DetectionEvent){const s=t.label??t.class,a=t.score??t.confidence,i=[];return typeof s=="string"&&i.push(s),typeof a=="number"&&i.push(`${Math.round(a*100)}%`),i.length>0?i.join(" — "):null}if(e===Ne.ProviderMotion)return t.active===!0?"motion start":"motion stop";if(e===Ne.DeviceStateChanged){const s=t.slice;if(s&&typeof s=="object"){const a=Object.keys(s).filter(i=>i!=="lastFetchedAt"&&i!=="ts");if(a.length>0)return a.slice(0,4).join(", ")+(a.length>4?"…":"")}return null}if(e===Ne.MotionOnMotionChanged){const s=t.detected,a=typeof t.source=="string"?t.source:null,i=s===!0?"motion start":s===!1?"motion stop":"motion";return a?`${i} (${a})`:i}if(e===Ne.ProviderDetection||e===Ne.DetectionCameraNative){const s=t.detections??[];if(!Array.isArray(s)||s.length===0)return(typeof t.class=="string"?t.class:null)??null;const a=new Map;for(const i of s){const l=i,c=l.class??l.macroClass,d=typeof c=="string"?c:"";d&&a.set(d,(a.get(d)??0)+1)}return[...a.entries()].map(([i,l])=>l>1?`${i} ×${l}`:i).join(", ")}const n=t.addonId,r=t.error;return r||(n?`addon: ${n}`:null)}function UD(e){const t=e.category;return t===Ne.DetectionResult||t===Ne.PipelineAudioInferenceResult?js(t,e.data)!==null:!0}const QD=300;function br({agentId:e,addonId:t,deviceId:n,defaultCategories:r,categories:s,category:a,maxHeight:i="max-h-96",limit:l=50,showCategoryFilter:c=!0,showFilters:d=!1,liveBuffer:u,onClose:p,className:h}){const m=H(()=>r??s??qD,[r,s]),g=H(()=>[...m].sort().join(","),[m]),[b,x]=_(()=>new Set(m)),y=te(g);Y(()=>{y.current!==g&&(y.current=g,x(new Set(m)))},[g,m]);const w=Yn(QD),v=u??w,N=v.entries,[k,C]=_(!0),[E,I]=_(new Set),[A,z]=_(""),[P,B]=_(!1),[R,M]=_(""),[D,T]=_(0),L=te(null),O=te(null),F=`${e??""}:${t??""}:${String(n??"")}:${a??""}`,j=te(F);Y(()=>{j.current!==F&&(j.current=F,v.reset(),I(new Set),T(0))},[F,v]),Y(()=>{if(!P)return;const he=_e=>{const Re=O.current;Re&&_e.target instanceof Node&&!Re.contains(_e.target)&&B(!1)};return document.addEventListener("mousedown",he),()=>{document.removeEventListener("mousedown",he)}},[P]);const V=H(()=>{const he={};return e&&(he.agentId=e),t&&(he.addonId=t),n!==void 0&&(he.deviceId=n),a&&(he.category=a),he},[e,t,n,a]),$=H(()=>[...b].sort(),[b]),q=H(()=>$.join(","),[$]),G=H(()=>{const he={...V,limit:l};return $.length>0&&$.length<Nr.length&&(he.category=$),he},[V,l,q,$]),{data:Z,isLoading:oe}=S.systemEvents.getRecent.useQuery(G,{staleTime:3e4}),ne=te(b);Y(()=>{ne.current=b},[b]);const X=V;S.systemEvents.subscribe.useSubscription(X,{onData:he=>{const _e=he;_e?.id&&FD(_e,e,t,n)&&ne.current.has(_e.category)&&v.append(_e)}});const re=te(N.length);Y(()=>{const he=L.current;if(!he){re.current=N.length;return}const _e=re.current;if(re.current=N.length,!(N.length<=_e)){if(k&&he.scrollTop<=8)he.scrollTo({top:0});else if(!k&&he.scrollTop>0){const Re=he.firstElementChild?.firstElementChild,Oe=Re instanceof HTMLElement?Re.offsetHeight:28;he.scrollTop+=Oe*(N.length-_e)}}},[N.length,k]);const be=H(()=>{const he=new Map;for(const Oe of Z??[])he.set(Oe.id,Oe);for(const Oe of N)he.set(Oe.id,Oe);let _e=[...he.values()].filter(Oe=>b.has(Oe.category)).filter(UD);D>0&&(_e=_e.filter(Oe=>new Date(Oe.timestamp).getTime()>D));const Re=A.trim().toLowerCase();return Re&&(_e=_e.filter(Oe=>{if(Oe.category.toLowerCase().includes(Re)||Fl(Oe.category,Oe.data).label.toLowerCase().includes(Re))return!0;const jn=js(Oe.category,Oe.data);if(jn&&jn.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,Fn)=>new Date(Fn.timestamp).getTime()-new Date(Oe.timestamp).getTime())},[Z,N,b,A,D]),J=U(he=>{I(_e=>{const Re=new Set(_e);return Re.has(he)?Re.delete(he):Re.add(he),Re})},[]),W=U(he=>{x(_e=>{const Re=new Set(_e);return Re.has(he)?Re.delete(he):Re.add(he),Re})},[]),ee=U(()=>{x(new Set(m)),z(""),T(0)},[m]),ae=U(()=>{T(Date.now()),v.reset()},[v]),[fe,ge]=_(!1),[Q,le]=_(null),ue=U(he=>{const _e=new Date(he.timestamp).toISOString(),Re=js(he.category,he.data)??"",Oe=Re?` ${Re}`:"";return`${_e} [${he.category}]${Oe} data=${JSON.stringify(he.data)}`},[]),de=U(()=>{const he=be.map(ue);navigator.clipboard.writeText(he.join(`
|
|
561
|
-
`)).then(()=>{ge(!0),setTimeout(()=>ge(!1),1500)})},[be,ue]),ce=U(he=>{navigator.clipboard.writeText(ue(he)).then(()=>{le(he.id),setTimeout(()=>le(_e=>_e===he.id?null:_e),1200)})},[ue]),Ce=U(()=>{x(new Set(Nr))},[]),pe=U(()=>{x(new Set)},[]),$e=H(()=>{const he=R.trim().toLowerCase();return he?Nr.filter(_e=>_e.toLowerCase().includes(he)):Nr},[R]),Ae=Nr.length,Xe=b.size,dt=Xe===Ae,yr=dt?"All":`${Xe}/${Ae}`;return f("div",{className:K("h-full min-h-0 flex flex-col",h),onClick:he=>he.stopPropagation(),children:[f("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Events"}),e&&o(ms,{label:"agent",value:e}),t&&o(ms,{label:"addon",value:t}),n!==void 0&&o(ms,{label:"device",value:`#${n}`}),a&&o(ms,{label:"category",value:a}),f("button",{type:"button",onClick:()=>{C(he=>!he),!k&&L.current&&L.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:[o(Ic,{className:"h-2.5 w-2.5"}),k?"Auto":"Paused"]}),c&&f("div",{className:"relative",ref:O,children:[f("button",{type:"button",onClick:()=>B(he=>!he),className:K("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",dt?"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:[o(Wm,{className:"h-2.5 w-2.5"}),"Filter (",yr,")"]}),P&&o(GD,{search:R,onSearchChange:M,categories:$e,active:b,onToggle:W,onSelectAll:Ce,onSelectNone:pe,onResetDefaults:ee})]}),f("button",{type:"button",onClick:ee,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Reset filters to defaults",children:[o(tg,{className:"h-2.5 w-2.5"}),"Reset"]}),f("button",{type:"button",onClick:ae,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Clear visible entries",children:[o(Zt,{className:"h-2.5 w-2.5"}),"Clear"]}),f("button",{type:"button",onClick:de,disabled:be.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",be.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible events",children:[o(yn,{className:"h-2.5 w-2.5"}),fe?"Copied!":"Copy"]}),f("div",{className:"relative",children:[o("input",{type:"text",value:A,onChange:he=>z(he.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),A&&o("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:o(Je,{className:"h-2.5 w-2.5"})})]}),N.length>0&&f("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",N.length," live"]})]}),p&&o("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:o(Je,{className:"h-3.5 w-3.5"})})]}),f("div",{ref:L,className:K("flex-1 min-h-0 overflow-auto text-[10px]",i),children:[oe&&f("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[o(Ct,{className:"h-3.5 w-3.5 animate-spin"}),"Loading events..."]}),!oe&&be.length===0&&o("div",{className:"py-4 text-center text-foreground-subtle",children:"No events found"}),be.length>0&&o("div",{className:"divide-y divide-border/30",children:be.map(he=>{const _e=Fl(he.category,he.data),Re=_e.icon,Oe=js(he.category,he.data),Fn=E.has(he.id);return f("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>J(he.id),children:[o("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(he.timestamp).toLocaleTimeString()}),o(WD,{copied:Q===he.id,onCopy:()=>ce(he)}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-1.5",children:[Fn?o(pr,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):o(On,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),f("span",{className:K("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[9px] font-medium",_e.color),children:[o(Re,{className:"h-2.5 w-2.5"}),_e.label]}),he.source.nodeId&&he.source.nodeId!=="hub"&&o("span",{className:"text-[9px] px-1 py-0.5 rounded bg-foreground-subtle/10 text-foreground-subtle font-mono",children:he.source.nodeId})]}),Oe&&o("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5",children:Oe}),Fn&&f("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:[f("div",{children:[o("span",{className:"text-primary/70",children:"source"}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground",children:JSON.stringify(he.source)})]}),f("div",{children:[o("span",{className:"text-primary/70",children:"category"}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground",children:he.category})]}),Object.entries(he.data).map(([jn,ro])=>f("div",{children:[o("span",{className:"text-primary/70",children:jn}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground break-all",children:typeof ro=="object"?JSON.stringify(ro):String(ro)})]},jn))]})]})]},he.id)})})]})]})}function GD({search:e,onSearchChange:t,categories:n,active:r,onToggle:s,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return f("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:[f("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[o(Mo,{className:"h-3 w-3 text-foreground-subtle"}),o("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&&o("button",{type:"button",onClick:()=>t(""),className:"text-foreground-subtle hover:text-foreground",children:o(Je,{className:"h-2.5 w-2.5"})})]}),f("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[o("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),o("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),o("button",{type:"button",onClick:l,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),f("div",{className:"overflow-y-auto flex-1",children:[n.length===0&&o("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),n.map(c=>{const d=r.has(c),u=Fl(c),p=u.icon;return f("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:[o("input",{type:"checkbox",readOnly:!0,checked:d,className:"accent-violet-500"}),f("span",{className:K("inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[9px] font-medium shrink-0",u.color),children:[o(p,{className:"h-2.5 w-2.5"}),u.label]}),o("span",{className:"text-foreground-subtle font-mono truncate",children:c})]},c)})]})]})}function KD({position:e="bottom",className:t,...n}){return o("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:o(br,{maxHeight:"max-h-48",...n})})}function ms({label:e,value:t}){return f("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 o("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?o(qr,{className:"h-3 w-3"}):o(yn,{className:"h-3 w-3"})})}function x0({deviceId:e,className:t="",onOpenChild:n}){const r=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:()=>{r.deviceDiscovery.listDiscovered.invalidate({deviceId:e}),r.deviceDiscovery.getStatus.invalidate({deviceId:e})}}),l=S.deviceDiscovery.adoptDevice.useMutation({onSuccess:()=>{r.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),c=S.deviceDiscovery.releaseDevice.useMutation({onSuccess:()=>{r.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),[d,u]=_(null),{available:p,adopted:h}=H(()=>{const v=s.data??[],N=C=>typeof C.metadata.rtspChannel=="number"?C.metadata.rtspChannel:Number.POSITIVE_INFINITY,k=(C,E)=>{const I=N(C),A=N(E);return I!==A?I-A:C.name.localeCompare(E.name)};return{available:v.filter(C=>!C.alreadyAdopted).sort(k),adopted:v.filter(C=>C.alreadyAdopted).sort(k)}},[s.data]),m=a.data,g=m?.lastError??null,b=m?.lastDiscoveryAt??null;async function x(){await i.mutateAsync({deviceId:e}).catch(()=>{})}async function y(v){u(v.childNativeId);try{await l.mutateAsync({deviceId:e,childNativeId:v.childNativeId})}finally{u(null)}}async function w(v){if(v.adoptedDeviceId!=null){u(v.childNativeId);try{await c.mutateAsync({deviceId:e,childDeviceId:v.adoptedDeviceId})}finally{u(null)}}}return f("div",{className:`rounded-xl border border-border bg-surface ${t}`,children:[f("div",{className:"flex items-start justify-between gap-2 border-b border-border px-3 py-2 sm:px-5 sm:py-3",children:[f("div",{className:"min-w-0",children:[o("h3",{className:"text-sm font-semibold text-foreground",children:"Discovered devices"}),f("p",{className:"text-[11px] text-foreground-subtle",children:["Channels behind this hub. Click ",o("span",{className:"font-medium",children:"Add"})," to promote a channel to a managed device, or ",o("span",{className:"font-medium",children:"Remove"})," to detach."]})]}),f("button",{type:"button",onClick:x,disabled:i.isPending,className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-2 py-1.5 sm:px-3 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 shrink-0",children:[i.isPending?o(Ct,{className:"h-3.5 w-3.5 animate-spin"}):o($a,{className:"h-3.5 w-3.5"}),o("span",{className:"hidden sm:inline",children:"Refresh"})]})]}),g?f("div",{className:"flex items-start gap-2 border-b border-border bg-destructive/10 px-5 py-2 text-[11px] text-destructive",children:[o(Qr,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),f("span",{children:["Last refresh failed: ",g]})]}):null,s.isLoading?o("div",{className:"flex items-center justify-center py-8 text-foreground-subtle",children:o(Ct,{className:"h-5 w-5 animate-spin"})}):p.length===0&&h.length===0?o("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."}):f(me,{children:[p.length>0?o(Pp,{title:"Available to add",count:p.length,tone:"primary",children:p.map(v=>o(_p,{child:v,busy:d===v.childNativeId,onAdopt:y,onRelease:w,onOpenChild:n},v.childNativeId))}):null,h.length>0?o(Pp,{title:"Already adopted",count:h.length,tone:"muted",children:h.map(v=>o(_p,{child:v,busy:d===v.childNativeId,onAdopt:y,onRelease:w,onOpenChild:n},v.childNativeId))}):null]}),b!=null?f("div",{className:"border-t border-border px-5 py-2 text-[10px] text-foreground-subtle",children:["Last refreshed ",new Date(b).toLocaleString()]}):null]})}function Pp({title:e,count:t,tone:n,children:r}){return f("div",{className:"border-t border-border",children:[f("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:[o("span",{className:"font-semibold",children:e}),o("span",{className:"font-mono",children:t})]}),o("div",{className:"divide-y divide-border",children:r})]})}function _p({child:e,busy:t,onAdopt:n,onRelease:r,onOpenChild:s}){return f("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:[f("div",{className:"min-w-0 flex-1",children:[f("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[o(YD,{status:e.status}),o("span",{className:"truncate text-sm font-medium text-foreground",children:e.name}),e.metadata.isDoorbell?o("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?o("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?o("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Multifocal"}):null]}),f("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"?f("span",{children:["ch ",o("span",{className:"font-mono",children:e.metadata.rtspChannel})]}):null,e.metadata.model?o("span",{className:"truncate max-w-[160px]",children:e.metadata.model}):null,e.metadata.uid?f("span",{className:"font-mono truncate max-w-[140px]",children:[e.metadata.uid.slice(0,12),"…"]}):null]})]}),e.alreadyAdopted?f("div",{className:"flex items-center gap-2",children:[s&&e.adoptedDeviceId!==null?f("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:[o(Pc,{className:"h-3.5 w-3.5"}),"Open"]}):null,f("button",{type:"button",onClick:()=>{r(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?o(Ct,{className:"h-3.5 w-3.5 animate-spin"}):o(Zt,{className:"h-3.5 w-3.5"}),"Remove"]})]}):f("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?o(Ct,{className:"h-3.5 w-3.5 animate-spin"}):o(Qo,{className:"h-3.5 w-3.5"}),"Add"]})]})}function YD({status:e}){switch(e){case"online":return f("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:[o(sg,{className:"h-2.5 w-2.5"})," online"]});case"sleeping":return f("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:[o($c,{className:"h-2.5 w-2.5"})," sleeping"]});case"offline":return f("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:[o(AC,{className:"h-2.5 w-2.5"})," offline"]});case"unknown":default:return f("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:[o(Um,{className:"h-2.5 w-2.5"})," unknown"]})}}function ZD(e,t){if(!e||typeof e!="object")return!1;const n=e;if(n.category!==Ne.DeviceStateChanged)return!1;const r=n.data;return!(!r||typeof r!="object"||r.deviceId!==t||typeof r.capName!="string"||!r.slice||typeof r.slice!="object")}function Di(e){if(!e||typeof e!="object")return null;const t=e,n=typeof t.id=="string"?t.id:null,r=typeof t.timestamp=="string"?t.timestamp:null,s=t.data;return!n||!r||!s||typeof s!="object"||typeof s.capName!="string"||!s.slice||typeof s.slice!="object"?null:{id:n,timestamp:r,capName:s.capName,slice:s.slice}}const XD=300,JD=Object.freeze([...new Set(k2.filter(e=>e.scope==="device").map(e=>e.name))].sort());function Id({deviceId:e,defaultCaps:t,maxHeight:n="max-h-96",limit:r=50,liveBuffer:s,onClose:a,className:i}){const l=H(()=>new Set(t??[]),[t]),[c,d]=_(l),[u,p]=_(""),[h,m]=_(!0),[g,b]=_(new Set),[x,y]=_(0),[w,v]=_(!1),[N,k]=_(""),C=te(null),E=Yn(XD),I=s??E,A=I.entries,z=te(null),P=te(e);Y(()=>{P.current!==e&&(P.current=e,I.reset(),b(new Set),y(0))},[e,I]);const B=H(()=>({deviceId:e,category:Ne.DeviceStateChanged,limit:r}),[e,r]),{data:R,isLoading:M}=S.systemEvents.getRecent.useQuery(B,{staleTime:3e4}),D=te(c);Y(()=>{D.current=c},[c]),S.systemEvents.subscribe.useSubscription({deviceId:e,category:Ne.DeviceStateChanged},{onData:Q=>{if(!ZD(Q,e))return;const le=Di(Q);if(!le)return;const ue=D.current;ue.size>0&&!ue.has(le.capName)||I.append(le)}});const T=te(A.length);Y(()=>{const Q=z.current;if(!Q){T.current=A.length;return}const le=T.current;if(T.current=A.length,!(A.length<=le)){if(h&&Q.scrollTop<=8)Q.scrollTo({top:0});else if(!h&&Q.scrollTop>0){const ue=Q.firstElementChild?.firstElementChild,de=ue instanceof HTMLElement?ue.offsetHeight:28,ce=A.length-le;Q.scrollTop+=de*ce}}},[A.length,h]);const L=H(()=>{const Q=new Map;for(const de of R??[]){const ce=Di(de);ce&&Q.set(ce.id,ce)}for(const de of A)Q.set(de.id,de);let le=[...Q.values()];x>0&&(le=le.filter(de=>new Date(de.timestamp).getTime()>x)),c.size>0&&(le=le.filter(de=>c.has(de.capName)));const ue=u.trim().toLowerCase();return ue&&(le=le.filter(de=>{if(de.capName.toLowerCase().includes(ue))return!0;try{if(new Date(de.timestamp).toLocaleTimeString().toLowerCase().includes(ue))return!0}catch{}try{if(Object.entries(de.slice).map(([Ce,pe])=>`${Ce}=${Ti(pe)}`).join(" · ").toLowerCase().includes(ue))return!0}catch{}try{if(JSON.stringify(de.slice).toLowerCase().includes(ue))return!0}catch{}return!1})),le.sort((de,ce)=>new Date(ce.timestamp).getTime()-new Date(de.timestamp).getTime())},[R,A,c,u,x]),O=H(()=>{const Q=new Set(JD);for(const le of R??[]){const ue=Di(le);ue&&Q.add(ue.capName)}for(const le of A)Q.add(le.capName);return[...Q].sort()},[R,A]),F=U(Q=>{b(le=>{const ue=new Set(le);return ue.has(Q)?ue.delete(Q):ue.add(Q),ue})},[]),j=U(Q=>{d(le=>{const ue=new Set(le);return ue.has(Q)?ue.delete(Q):ue.add(Q),ue})},[]),V=U(()=>{d(new Set(t??[])),p("")},[t]),$=U(()=>{y(Date.now()),I.reset()},[I]),[q,G]=_(!1),[Z,oe]=_(null),ne=U(Q=>`${new Date(Q.timestamp).toISOString()} [${Q.capName}] slice=${JSON.stringify(Q.slice)}`,[]),X=U(()=>{const Q=L.map(ne);navigator.clipboard.writeText(Q.join(`
|
|
562
|
-
`)).then(()=>{G(!0),setTimeout(()=>G(!1),1500)})},[L,ne]),re=U(Q=>{navigator.clipboard.writeText(ne(Q)).then(()=>{oe(Q.id),setTimeout(()=>oe(le=>le===Q.id?null:le),1200)})},[ne]),be=U(()=>{d(new Set(O))},[O]),J=U(()=>{d(new Set)},[]),W=H(()=>{const Q=N.trim().toLowerCase();return Q?O.filter(le=>le.toLowerCase().includes(Q)):O},[N,O]),ee=O.length,ae=c.size,fe=ae===0||ae===ee,ge=fe?"All":`${ae}/${ee}`;return Y(()=>{if(!w)return;const Q=le=>{const ue=C.current;ue&&!ue.contains(le.target)&&v(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[w]),f("div",{className:K("h-full min-h-0 flex flex-col",i),onClick:Q=>Q.stopPropagation(),children:[f("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"State"}),o(eT,{label:"device",value:`#${e}`}),f("button",{type:"button",onClick:()=>{m(Q=>!Q),!h&&z.current&&z.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",h?"border-border text-foreground-subtle hover:text-foreground":"border-amber-500/30 bg-amber-500/10 text-amber-400"),children:[o(Ic,{className:"h-2.5 w-2.5"}),h?"Auto":"Paused"]}),f("div",{className:"relative",ref:C,children:[f("button",{type:"button",onClick:()=>v(Q=>!Q),className:K("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",fe?"border-border text-foreground-subtle hover:text-foreground":"border-violet-500/30 bg-violet-500/10 text-violet-400"),title:"Pick caps to track",children:[o(Wm,{className:"h-2.5 w-2.5"}),"Filter (",ge,")"]}),w&&o(tT,{search:N,onSearchChange:k,caps:W,active:c,onToggle:j,onSelectAll:be,onSelectNone:J,onResetDefaults:V})]}),f("button",{type:"button",onClick:V,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:[o(tg,{className:"h-2.5 w-2.5"}),"Reset"]}),f("button",{type:"button",onClick:$,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:[o(Zt,{className:"h-2.5 w-2.5"}),"Clear"]}),f("button",{type:"button",onClick:X,disabled:L.length===0,className:K("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",q?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",L.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible state changes",children:[o(yn,{className:"h-2.5 w-2.5"}),q?"Copied!":"Copy"]}),f("div",{className:"relative",children:[o("input",{type:"text",value:u,onChange:Q=>p(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"}),u&&o("button",{type:"button",onClick:()=>p(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:o(Je,{className:"h-2.5 w-2.5"})})]}),A.length>0&&f("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",A.length," live"]})]}),a&&o("button",{type:"button",onClick:a,className:"text-foreground-subtle hover:text-foreground",children:o(Je,{className:"h-3.5 w-3.5"})})]}),f("div",{ref:z,className:K("flex-1 min-h-0 overflow-auto text-[10px]",n),children:[M&&f("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[o(Ct,{className:"h-3.5 w-3.5 animate-spin"}),"Loading state changes..."]}),!M&&L.length===0&&o("div",{className:"py-4 text-center text-foreground-subtle",children:"No state changes"}),L.length>0&&o("div",{className:"divide-y divide-border/30",children:L.map(Q=>{const le=g.has(Q.id),ue=Object.entries(Q.slice),de=ue.slice(0,3).map(([ce,Ce])=>`${ce}=${Ti(Ce)}`).join(" · ");return f("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>F(Q.id),children:[o("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(Q.timestamp).toLocaleTimeString()}),o(nT,{copied:Z===Q.id,onCopy:()=>re(Q)}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-1.5",children:[le?o(pr,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):o(On,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),o("span",{className:"inline-flex items-center gap-1 rounded-full border border-violet-500/30 bg-violet-500/15 text-violet-400 px-2 py-0.5 text-[9px] font-medium",children:Q.capName}),ue.length>3&&f("span",{className:"text-[9px] text-foreground-subtle",children:["+",ue.length-3," more"]})]}),de&&o("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5 truncate",children:de}),le&&o("div",{className:"mt-1 ml-5 text-[9px] bg-surface rounded px-2 py-1.5 space-y-0.5 font-mono overflow-x-auto",children:ue.length===0?o("div",{className:"text-foreground-subtle italic",children:"empty slice"}):ue.map(([ce,Ce])=>f("div",{children:[o("span",{className:"text-primary/70",children:ce}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground break-all",children:Ti(Ce)})]},ce))})]})]},Q.id)})})]})]})}function Ti(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 eT({label:e,value:t}){return f("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function tT({search:e,onSearchChange:t,caps:n,active:r,onToggle:s,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return f("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:[f("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[o(Mo,{className:"h-3 w-3 text-foreground-subtle"}),o("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&&o("button",{type:"button",onClick:()=>t(""),className:"text-foreground-subtle hover:text-foreground",children:o(Je,{className:"h-2.5 w-2.5"})})]}),f("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[o("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),o("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),o("button",{type:"button",onClick:l,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),f("div",{className:"overflow-y-auto flex-1",children:[n.length===0&&o("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),n.map(c=>{const d=r.has(c);return f("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:[o("input",{type:"checkbox",readOnly:!0,checked:d,className:"accent-violet-500"}),o("span",{className:"inline-flex items-center gap-1 rounded-full border border-violet-500/30 bg-violet-500/15 text-violet-400 px-1.5 py-0.5 text-[9px] font-medium shrink-0",children:c})]},c)})]})]})}function nT({copied:e,onCopy:t}){return o("button",{type:"button",title:"Copy this state change",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?o(qr,{className:"h-3 w-3"}):o(yn,{className:"h-3 w-3"})})}const Li=500,rT=[{id:"logs",label:"Logs",icon:ZS},{id:"events",label:"Events",icon:_a},{id:"state",label:"State",icon:Z5}];function oT({deviceId:e,defaultEventCategories:t,defaultStateCaps:n,initialTab:r="events",className:s,maxHeight:a="max-h-96"}){const[i,l]=_(r),c=Yn(Li),d=Yn(Li),u=Yn(Li),p=c.reset,h=d.reset,m=u.reset;return Y(()=>{p(),h(),m()},[e,p,h,m]),f("div",{className:K("flex flex-col h-full min-h-0",s),children:[o("div",{className:"flex items-center gap-1 mb-2 shrink-0",children:rT.map(({id:g,label:b,icon:x})=>f("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:[o(x,{className:"h-3.5 w-3.5"}),b]},g))}),f("div",{className:"flex-1 min-h-0 overflow-hidden",children:[i==="logs"&&o(tn,{deviceId:e,maxHeight:a,showFilters:!1,liveBuffer:c}),i==="events"&&o(br,{deviceId:e,defaultCategories:t,maxHeight:a,showCategoryFilter:!0,liveBuffer:d}),i==="state"&&o(Id,{deviceId:e,defaultCaps:n,maxHeight:a,liveBuffer:u})]})]})}function Ad({label:e,icon:t,title:n="Confirm action",description:r,confirmLabel:s,triggerVariant:a="outline",confirmVariant:i="danger",size:l="sm",disabled:c,className:d,action:u,onSuccess:p}){const[h,m]=_(!1),[g,b]=_(!1),[x,y]=_(null),w=async()=>{y(null),b(!0);try{const v=await u();p?.(v),m(!1)}catch(v){y(v instanceof Error?v.message:String(v))}finally{b(!1)}};return f(me,{children:[f(Be,{type:"button",variant:a,size:l,disabled:c,onClick:()=>{y(null),m(!0)},className:d,children:[t&&o(t,{className:"h-3.5 w-3.5"}),e]}),o(ug,{open:h,onOpenChange:v=>!g&&m(v),children:f(Bc,{children:[f(pg,{children:[f(hg,{className:"flex items-center gap-2",children:[o(Qr,{className:"h-4 w-4 text-amber-400"}),n]}),typeof r=="string"?o(mg,{children:r}):r]}),x&&o("div",{className:K("mt-2 px-3 py-2 rounded border border-danger/40 bg-danger/10","text-xs text-danger"),children:x}),f(fg,{children:[o(Be,{type:"button",variant:"ghost",size:l,disabled:g,onClick:()=>m(!1),children:"Cancel"}),f(Be,{type:"button",variant:i,size:l,disabled:g,onClick:()=>{w()},children:[g&&o(Ct,{className:"h-3.5 w-3.5 animate-spin"}),s??e]})]})]})})]})}function gs({direction:e,icon:t,disabled:n,className:r,variant:s,onMove:a,onStart:i,onStop:l}){const[c,d]=_(null),[u,p]=_(!1),h=U(w=>{if(n)return;w.currentTarget.setPointerCapture(w.pointerId),d(Date.now()),p(!1);const v=setTimeout(()=>{p(!0),i(e)},250);w.currentTarget.dataset.timer=String(v)},[e,n,i]),m=U(w=>{const v=Number(w.currentTarget.dataset.timer);v&&clearTimeout(v),w.currentTarget.dataset.timer="",u?l():c!==null&&a(e),d(null),p(!1)},[u,e,a,l,c]),g=U(w=>{const v=Number(w.currentTarget.dataset.timer);v&&clearTimeout(v),w.currentTarget.dataset.timer="",u&&l(),d(null),p(!1)},[u,l]),b=s==="panel"?"h-9 w-9":"h-7 w-7",x=s==="panel"?"h-4 w-4":"h-3.5 w-3.5";return o("button",{type:"button",disabled:n,onPointerDown:h,onPointerUp:m,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",b,r),title:e,children:o(t,{className:x})})}function Pd({controls:e,mode:t="overlay",showPresets:n,showZoom:r=!0,showHome:s=!0,className:a}){const{move:i,startContinuous:l,stopContinuous:c,zoom:d,goHome:u,goToPreset:p,presets:h,busy:m,error:g}=e,[b,x]=_(!1),y=(n??h.length>0)&&h.length>0,w=t==="panel",v=w?"flex flex-col items-stretch gap-2 w-full h-full p-3":"pointer-events-auto absolute top-3 right-3 z-10 flex flex-col items-end gap-2",N=K(w?"flex items-center gap-3 rounded-lg p-2":"flex items-center gap-2 rounded-lg border border-white/30 bg-zinc-900/90 backdrop-blur-md p-2 shadow-lg shadow-black/40",m&&"ring-1 ring-primary/40"),k=w?"h-9 w-9":"h-7 w-7",C=w?"h-4 w-4":"h-3.5 w-3.5",E=w?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15",I=w?"h-12 w-px bg-border mx-1":"h-12 w-px bg-white/15 mx-1";return f("div",{className:K(v,a),children:[g&&f("div",{className:"rounded bg-danger/90 px-2 py-1 text-[10px] font-medium text-white shadow-lg max-w-[200px] self-center",children:["PTZ: ",g]}),f("div",{className:K(N,w&&"justify-center"),children:[f("div",{className:"grid grid-cols-3 gap-0.5",children:[o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),o(gs,{direction:"up",icon:c5,variant:t,onMove:i,onStart:l,onStop:c}),o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),o(gs,{direction:"left",icon:o5,variant:t,onMove:i,onStart:l,onStop:c}),o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),o(gs,{direction:"right",icon:a5,variant:t,onMove:i,onStart:l,onStop:c}),o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),o(gs,{direction:"down",icon:n5,variant:t,onMove:i,onStart:l,onStop:c}),o("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"})]}),(r||s)&&o("div",{className:I}),f("div",{className:"flex flex-col gap-0.5",children:[r&&f(me,{children:[o("button",{type:"button",onClick:()=>d("in"),disabled:m,title:"Zoom in",className:K("flex items-center justify-center rounded disabled:opacity-40",k,E),children:o(LC,{className:C})}),o("button",{type:"button",onClick:()=>d("out"),disabled:m,title:"Zoom out",className:K("flex items-center justify-center rounded disabled:opacity-40",k,E),children:o(OC,{className:C})})]}),s&&o("button",{type:"button",onClick:()=>u(),disabled:m,title:"Go home",className:K("flex items-center justify-center rounded disabled:opacity-40",k,E),children:o(Ym,{className:C})})]}),y&&f("div",{className:"relative",children:[f("button",{type:"button",onClick:()=>x(A=>!A),disabled:m,className:K("flex items-center gap-1 rounded px-2 text-[10px] disabled:opacity-40",w?"h-9 text-foreground hover:bg-surface-hover":"h-7 text-white hover:bg-white/15"),title:"Presets",children:["Presets",o(pr,{className:K("h-3 w-3 transition-transform",b&&"rotate-180")})]}),b&&o("div",{className:K("absolute right-0 min-w-[140px] rounded-lg shadow-xl py-1 z-20",w?"bottom-full mb-1 bg-surface border border-border":"top-full mt-1 border border-white/30 bg-zinc-900/95 backdrop-blur-md"),children:h.map(A=>o("button",{type:"button",onClick:()=>{p(A.id),x(!1)},disabled:m,className:K("block w-full px-3 py-1.5 text-left text-[10px] disabled:opacity-40",w?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15"),children:A.name||A.id},A.id))})]})]})]})}function sT(e,t){const n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function aT({trpc:e,deviceId:t,deviceName:n,size:r="sm",className:s}){const[a,i]=_(!1),[l,c]=_(!1),[d,u]=_(null),p=n.replace(/[^a-zA-Z0-9_.-]+/g,"_"),h=U(async k=>{i(!0),u(null),c(!1);try{const C=await e.snapshot.getSnapshot.query({deviceId:t,force:!0});if(!C)throw new Error("No snapshot available");const E=`data:${C.contentType};base64,${C.base64}`;if(k==="copy")try{await navigator.clipboard.writeText(E)}catch{throw new Error("Clipboard unavailable")}else{const I=C.contentType.includes("png")?"png":"jpg",A=new Date().toISOString().replace(/[:.]/g,"-");sT(`${p}-${A}.${I}`,E)}c(!0),setTimeout(()=>c(!1),1500)}catch(C){u(C instanceof Error?C.message:String(C))}finally{i(!1)}},[e,t,p]),m=r==="md"?"h-9 px-3 text-sm gap-2":"h-7 px-2.5 text-[11px] gap-1.5",[g,b]=_(null),[x,y]=_(!1),w=()=>{y(!1);const k=setTimeout(()=>{y(!0),h("copy")},600);b(k)},v=()=>{g&&(clearTimeout(g),b(null)),x||h("download")},N=()=>{g&&(clearTimeout(g),b(null))};return f("button",{type:"button",title:"Click to download · long-press to copy",disabled:a,onPointerDown:w,onPointerUp:v,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",m,d&&"border-danger/40 text-danger",s),children:[a?o(Ct,{className:"h-3.5 w-3.5 animate-spin"}):l?o(qr,{className:"h-3.5 w-3.5 text-success"}):o(Ac,{className:"h-3.5 w-3.5"}),"Snapshot"]})}function iT(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 _d({history:e,limit:t=5,latestIsFresh:n,className:r}){if(e.length===0)return null;const s=n?x5:_a,a=e.slice(0,t);return f("div",{className:K("rounded-lg border border-border bg-surface px-3 py-2",r),children:[f("div",{className:"flex items-center gap-2 mb-2",children:[o(s,{className:K("h-4 w-4 text-amber-400",n&&"animate-pulse")}),o("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:"Recent presses"}),o("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})]}),o("ul",{className:"space-y-1",children:a.map(i=>f("li",{className:"flex items-center justify-between text-[11px]",title:new Date(i.timestamp).toLocaleString(),children:[o("span",{className:"text-foreground",children:iT(i.timestamp)}),o("span",{className:"text-foreground-subtle font-mono text-[10px]",children:new Date(i.timestamp).toLocaleTimeString()})]},`${i.deviceId}-${i.timestamp}`))})]})}function y0({items:e,header:t,triggerClassName:n,title:r="More actions"}){const[s,a]=_(!1),i=e.filter(l=>!l.hidden);return i.length===0?null:f(Ag,{open:s,onOpenChange:a,children:[o(Pg,{title:r,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:o(Km,{className:"h-4 w-4"})}),f(_g,{className:"left-auto right-0 mt-1 min-w-[200px] p-1",children:[t&&o("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle",children:t}),o("ul",{className:"space-y-0.5",children:i.map((l,c)=>f("li",{children:[l.separatorBefore&&c>0&&o("div",{className:"my-1 h-px bg-border"}),f("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&&o(l.icon,{className:K("h-3.5 w-3.5 shrink-0 mt-0.5",l.danger&&"text-danger/80")}),f("span",{className:"flex-1 min-w-0",children:[o("span",{className:"block leading-tight",children:l.label}),l.description&&o("span",{className:"block mt-0.5 text-[10px] text-foreground-subtle leading-tight",children:l.description})]})]})]},l.id))})]})]})}const lT=[{value:"view",label:"View",icon:Ur,hint:"Read-only — queries + subscriptions"},{value:"create",label:"Create",icon:_S,hint:"Mutations that create or update"},{value:"delete",label:"Delete",icon:Zt,hint:"Destructive ops (delete/revoke/reset/…)"}],cT=["device","system"];function dT(){return{type:"capability",target:"",access:["view"]}}function uT(e){if(e==null)return[];const t=new Set;for(const n of e)if(n.type==="device")for(const r of n.targets)t.add(r);return[...t]}function pT(e,t,n,r){let s;switch(e){case"addon":s=n;break;case"capability":s=r;break;case"category":s=cT.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 fT(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 r=new Set;for(const s of n)for(const a of s.access)r.add(a);return[...r]}function $d({value:e,onChange:t,clampToParent:n,emptyHint:r}){const{data:s}=wn(),{data:a}=Bn({}),i=H(()=>(s??[]).map(g=>({value:g.manifest.id,label:g.manifest.id})).sort((g,b)=>g.label.localeCompare(b.label)),[s]),l=H(()=>[...S2].sort().map(g=>({value:g,label:g})),[]),c=H(()=>(a??[]).map(g=>({value:String(g.id),label:`${g.name} (#${g.id} · ${g.addonId})`})).sort((g,b)=>g.label.localeCompare(b.label)),[a]),d=H(()=>n==null?null:uT(n),[n]),u=(g,b)=>{const x=[...b];switch(g){case"category":return{type:"category",target:"device",access:x};case"capability":return{type:"capability",target:"",access:x};case"addon":return{type:"addon",target:"",access:x};case"device":return{type:"device",targets:[],access:x}}},p=(g,b)=>{t(e.map((x,y)=>{if(y!==g)return x;if(b.type!==void 0&&b.type!==x.type)return u(b.type,b.access??x.access);const w=[...b.access??x.access];return x.type==="device"?{type:"device",targets:[...b.targets??x.targets],access:w}:x.type==="category"?{type:"category",target:b.target??x.target,access:w}:x.type==="capability"?{type:"capability",target:b.target??x.target,access:w}:{type:"addon",target:b.target??x.target,access:w}}))},h=g=>{t(e.filter((b,x)=>x!==g))},m=()=>{t([...e,dT()])};return f("div",{className:"space-y-2",children:[e.length===0&&r&&o("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-2",children:r}),e.map((g,b)=>{const x=fT(g,n);return f("div",{className:"flex flex-wrap items-start gap-1.5 rounded border border-border bg-surface px-2 py-1.5",children:[f("select",{value:g.type,onChange:y=>p(b,{type:y.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:[o("option",{value:"category",children:"category"}),o("option",{value:"capability",children:"capability"}),o("option",{value:"addon",children:"addon"}),o("option",{value:"device",children:"device"})]}),g.type==="device"?o(hT,{value:g.targets,choices:c,clampToParent:d,onChange:y=>p(b,{targets:y})}):f("select",{value:g.target,onChange:y=>p(b,{target:y.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:[f("option",{value:"",children:["— pick ",g.type," —"]}),pT(g.type,n,i,l).map(y=>o("option",{value:y.value,children:y.label},y.value))]}),o("div",{className:"flex items-center gap-1",children:lT.map(({value:y,label:w,icon:v,hint:N})=>{const k=g.access.includes(y),C=n!=null&&!x.includes(y)&&!k;return f("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:[o("input",{type:"checkbox",checked:k,disabled:C,onChange:E=>{const I=new Set(g.access);E.target.checked?I.add(y):I.delete(y),p(b,{access:[...I]})},className:"sr-only"}),o(v,{className:"h-3 w-3"}),w]},y)})}),o("button",{type:"button",onClick:()=>h(b),className:"rounded p-1 text-foreground-subtle hover:bg-danger/10 hover:text-danger transition-colors",title:"Remove scope",children:o(Je,{className:"h-3 w-3"})})]},b)}),f("button",{type:"button",onClick:m,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:[o(Qo,{className:"h-3 w-3"}),"Add scope"]})]})}function hT({value:e,choices:t,clampToParent:n,onChange:r}){const[s,a]=_(""),i=H(()=>{const u=n==null?t:t.filter(h=>n.includes(h.value)),p=new Set(e);return u.filter(h=>!p.has(h.value))},[t,n,e]),l=u=>t.find(p=>p.value===u)?.label??`#${u}`,c=u=>{u&&(r([...e,u]),a(""))},d=u=>{r(e.filter(p=>p!==u))};return f("div",{className:"flex-1 min-w-[160px] flex flex-wrap items-center gap-1",children:[e.length===0&&o("span",{className:"text-[10px] text-foreground-subtle italic px-1",children:"no devices selected"}),e.map(u=>f("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(u),o("button",{type:"button",onClick:()=>d(u),className:"hover:text-danger transition-colors",title:"Remove device",children:o(Je,{className:"h-2.5 w-2.5"})})]},u)),i.length>0&&f("select",{value:s,onChange:u=>c(u.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:[o("option",{value:"",children:"+ add device…"}),i.map(u=>o("option",{value:u.value,children:u.label},u.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 v0=xn("camstack:zone-editing",null);function w0({children:e}){const[t,n]=_(!1),[r,s]=_(null),[a,i]=_(null),[l,c]=_(null),d=U(w=>{n(w),w||(s(null),i(null),c(null))},[]),u=U(w=>{s(w)},[]),p=U(w=>{i(w)},[]),h=U(w=>{n(!0),i(null),s(w),c(null)},[]),m=U(()=>{n(!1),s(null),i(null),c(null)},[]),g=U(w=>{i(w.id),c(w)},[]),b=U(w=>{c(v=>v===null?v:{...v,...w})},[]),x=U(()=>{c(null)},[]),y=H(()=>({editing:t,drawingKind:r,selectedZoneId:a,editingDraft:l,setEditing:d,setDrawingKind:u,setSelectedZoneId:p,startDrawing:h,exitEditing:m,enterDraft:g,updateDraft:b,discardDraft:x}),[t,r,a,l,d,u,p,h,m,g,b,x]);return o(v0.Provider,{value:y,children:e})}function mT(){return ve(v0)}const $p=500,gT=800;function bs(e,t,n){try{const r=e.live;if(!r)return null;const s=r.onEvent;return!s||typeof s.subscribe!="function"?null:s.subscribe({category:t},{onData:n})}catch{return null}}function xs(e,t){return e?.id===t}function N0(e,t){const[n,r]=_(null),[s,a]=_(null),[i,l]=_(null),[c,d]=_("watching"),u=te(void 0),p=te(void 0),h=te(void 0);return Y(()=>{if(t===null)return;const m=bs(e,"detection.motion-analysis",g=>{const b=g;if(!xs(b?.source,t))return;const x=b.data;!x?.regions||x.regions.length===0||(r({zones:x.regions.map(y=>({...y.bbox,intensity:y.intensity})),frameWidth:x.frameWidth,frameHeight:x.frameHeight}),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>r(null),$p))});return()=>{m?.unsubscribe(),u.current&&clearTimeout(u.current)}},[e,t]),Y(()=>{if(t===null)return;const m=bs(e,"detection.motion-zones-raw",g=>{const b=g;if(!xs(b?.source,t))return;const x=b.data;x?.zones&&(a({boxes:x.zones.map(y=>({bbox:y.bbox,changeScore:y.changeScore})),frameWidth:x.frameSize?.width??0,frameHeight:x.frameSize?.height??0,motionScore:x.zones.length>0?x.zones.reduce((y,w)=>y+w.changeScore,0)/x.zones.length:0}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>a(null),$p))});return()=>{m?.unsubscribe(),p.current&&clearTimeout(p.current)}},[e,t]),Y(()=>{if(t===null)return;const m=bs(e,"detection.result",g=>{const b=g;if(!xs(b?.source,t))return;const x=b.data?.frame;x?.detections?.length&&(l({detections:x.detections,frameWidth:x.width,frameHeight:x.height}),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>l(null),gT))});return()=>{m?.unsubscribe(),h.current&&clearTimeout(h.current)}},[e,t]),Y(()=>{if(t===null)return;const m=bs(e,"detection.phase-transition",g=>{const b=g;xs(b?.source,t)&&b.data?.to&&d(b.data.to)});return()=>{m?.unsubscribe()}},[e,t]),{motion:n,motionRaw:s,detection:i,phase:c}}function Td(e,t,n=5e3){const[r,s]=_([]);Y(()=>{if(t===null)return;let h=!1;const m=()=>{e.webrtcSession.listStreams.query({deviceId:t}).then(b=>{h||s(b)}).catch(()=>{})};m();const g=setInterval(m,n);return()=>{h=!0,clearInterval(g)}},[e,t,n]);const[a,i]=_(null);Y(()=>{if(t===null)return;let h=!1;return e.pipelineOrchestrator&&e.pipelineOrchestrator.getCameraMetrics.query({deviceId:t}).then(m=>{h||!m||i({phase:m.phase,detectionFps:m.actualFps,avgInferenceMs:m.avgInferenceTimeMs,droppedFrames:m.droppedFrames})}).catch(()=>{}),()=>{h=!0}},[e,t]),gt("pipeline.camera-metrics-snapshot",h=>{if(t===null)return;const m=h.data;m.deviceId!==t||!m.metrics||i({phase:m.metrics.phase,detectionFps:m.metrics.actualFps,avgInferenceMs:m.metrics.avgInferenceTimeMs,droppedFrames:m.metrics.droppedFrames})});const{streams:l,hasWebrtc:c}=H(()=>t===null||r.length===0?{streams:[],hasWebrtc:!1}:{streams:r.map(m=>({id:m.id,label:m.label,target:m.target,status:m.status,inputFps:m.inputFps,decodeFps:m.decodeFps,bitrateKbps:m.bitrateKbps})),hasWebrtc:!0},[t,r]),d=U(async(h,m)=>{if(t===null)throw new Error("No device selected");const g=await e.webrtcSession.createSession.mutate({deviceId:t,target:h,hints:m});return{sessionId:g.sessionId,sdpOffer:g.sdpOffer}},[e,t]),u=U(async(h,m)=>{if(t===null)throw new Error("No device selected");await e.webrtcSession.handleAnswer.mutate({deviceId:t,sessionId:h,sdpAnswer:m})},[e,t]),p=U(async h=>{t!==null&&await e.webrtcSession.closeSession.mutate({deviceId:t,sessionId:h}).catch(()=>{})},[e,t]);return{streams:l,hasWebrtc:c,pipelineMetrics:a,createSession:d,sendAnswer:u,closeSession:p}}const Dp={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 Ld(e,t,n){const r=n?.defaultSpeed??.5,s=n?.pulseMs??250,a=n?.enabled??!0,l=At(e,a?t:null)?.ptz,[c,d]=_([]),[u,p]=_(!1),[h,m]=_(null),g=U(async()=>{if(!(!a||!l))try{const C=await l.getPresets({});d(C)}catch(C){const E=C instanceof Error?C.message:String(C);if(E.includes("provider not available")||E.includes("no 'ptz' binding"))return;m(E)}},[l,a]);Y(()=>{g()},[g]);const b=U(async C=>{if(!(!a||!l)){m(null),p(!0);try{return await C()}catch(E){m(E instanceof Error?E.message:String(E));return}finally{p(!1)}}},[a,l]),x=U(async(C,E)=>{if(!l)return;const I=Dp[C],A=E??r;await b(async()=>{await l.move({pan:I.pan,tilt:I.tilt,speed:A}),await new Promise(z=>setTimeout(z,s)),await l.stop({})})},[l,r,s,b]),y=U(async(C,E)=>{if(!l)return;const I=Dp[C],A=E??r;await b(()=>l.continuousMove({pan:I.pan,tilt:I.tilt,speed:A}))},[l,r,b]),w=U(async()=>{l&&await b(()=>l.stop({}))},[l,b]),v=U(async(C,E)=>{if(!l)return;const I=C==="in"?1:-1,A=E??r;await b(async()=>{await l.move({zoom:I,speed:A}),await new Promise(z=>setTimeout(z,s)),await l.stop({})})},[l,r,s,b]),N=U(async()=>{l&&await b(()=>l.goHome({}))},[l,b]),k=U(async C=>{l&&await b(()=>l.goToPreset({presetId:C}))},[l,b]);return{move:x,startContinuous:y,stopContinuous:w,zoom:v,goHome:N,goToPreset:k,presets:c,refreshPresets:g,busy:u,error:h}}function Rd(e){const t=e?.deviceId??null,n=e?.historyLimit??20,r=Gr("doorbell.onPressed",t!==null?i=>i.deviceId===t:void 0),[s,a]=_([]);return Y(()=>{r&&a(i=>{if(i.length>0&&i[0].deviceId===r.deviceId&&i[0].timestamp===r.timestamp)return i;const l=[r,...i];return l.length>n?l.slice(0,n):l})},[r,n]),{latest:r??null,history:s}}function bT(e){const t=Te(),n=H(()=>e?JSON.stringify(e):"",[e]),[r,s]=_(()=>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]),r}function xT(e){const t=Te(),[n,r]=_(()=>e===null?null:t.getDevice(e));return Y(()=>{if(e===null){r(null);return}const s=()=>{r(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 yT(e,t,n){const r=Te();return Ln({queryKey:e,queryFn:()=>t(r)(),...n})}function vT(e,t){const n=Te();return Kn({mutationFn:r=>e(n)(r),...t})}function wT(e,t){const n=Te(),r=ke(),[s,a]=_(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 u=JSON.parse(l),h=u.length===1&&Array.isArray(u[0])?u:[u];r.invalidateQueries({queryKey:h})};d();for(const u of i.split("|"))if(u)try{c.push(n.subscribeEvent(u,d))}catch{}return()=>{for(const u of c)u()}},[n,r,i,l,s])}const NT=Object.freeze(Object.defineProperty({__proto__:null,AddonGlobalSettingsForm:Y$,AgentStepEditor:Ra,AppShell:I3,AudioClassificationList:DD,AudioLevelWaveform:PD,AudioWaveform:AD,BTN_COMPACT:Tk,BTN_COMPACT_DANGER:Rk,BTN_COMPACT_PRIMARY:Lk,BTN_COMPACT_WARNING:Ok,Badge:zt,BatteryBadge:Xc,BottomSheet:Fc,Breadcrumb:Hc,Button:Be,CHIP_ACTIVE:Fk,CHIP_BASE:zk,CHIP_INACTIVE:jk,CLASS_COLORS:po,CameraStreamPlayer:Xy,Card:un,Checkbox:lg,CodeBlock:M3,CollapsibleCard:ag,ConfigFormBuilder:Yy,ConfigFormField:gr,ConfigSchemaField:La,ConfirmActionButton:Ad,ConfirmDialogProvider:jg,CopyButton:g0,CustomFieldRenderersProvider:ib,DEFAULT_COLOR:nb,DataTable:Da,DetectionCanvas:PM,DetectionOverlay:Zy,DetectionResultTree:TM,DevShell:sb,DeviceActivityPanel:oT,DeviceCard:P3,DeviceContextProvider:cb,DeviceExportPanel:Md,DeviceGrid:_3,DeviceItem:Io,DeviceList:Ao,Dialog:ug,DialogContent:Bc,DialogDescription:mg,DialogFooter:fg,DialogHeader:pg,DialogTitle:hg,DialogTrigger:UC,DiscoveryPanel:x0,DoorbellRecentPanel:_d,Dropdown:bg,DropdownContent:yg,DropdownItem:vg,DropdownTrigger:xg,EmptyState:Wc,ErrorBox:Oa,EventStream:br,FilterBar:E3,FloatingEventStream:KD,FloatingLogStream:b0,FloatingPanel:e3,FormField:w3,GRID_GAP:Fm,GRID_PAIRED:Ik,GRID_QUICK_STATS:Ek,INPUT_COMPACT:Bk,IconButton:Tc,ImageSelector:zM,InferenceConfigSelector:FM,Input:ea,KebabMenu:y0,KeyValueList:C3,LIST_ROW:jm,Label:Lc,LogStream:tn,LoginForm:rb,MobileDrawer:Vc,NodeMultiSelectField:Ky,NodePicker:Bg,NodeSelectField:Gy,PHASE_CONFIG:El,PTZOverlay:Pd,PageHeader:N3,PhaseIcon:Ed,PipelineBuilder:Jc,PipelineRuntimeSelector:EM,PipelineStep:Fs,PipelineTreeMatrix:Uc,PlayerOverlaysProvider:Jy,Popover:Ag,PopoverContent:_g,PopoverTrigger:Pg,ProviderBadge:x3,QrCode:m0,ResponseLog:TD,SECTION_BODY:Mk,SECTION_CARD:Sk,SECTION_HEADER:Ck,SPLIT_PANEL_OUTER:Ak,SPLIT_PANEL_SIDE:Pk,STACK_GAP:zm,ScopePicker:$d,ScrollArea:jc,Select:Eo,SemanticBadge:zg,Separator:Rc,Sidebar:Tl,SidebarItem:Dl,Skeleton:ig,SlideOverPanel:qc,SnapshotButton:aT,StatCard:S3,StateValuesStream:Id,StatusBadge:g3,StepTimings:BM,StepTreeMaster:Lg,StreamBrokerSelector:hD,StreamPanel:Cd,Switch:Oc,SystemProvider:Gc,TEXT_FIELD_LABEL:$k,TEXT_HINT:Js,TEXT_METRIC:Ml,TEXT_SECTION_LABEL:_k,TEXT_VALUE:Dk,Tabs:YC,TabsContent:JC,TabsList:ZC,TabsTrigger:XC,ThemeProvider:Zs,Tooltip:GC,TooltipContent:WC,TooltipTrigger:KC,VersionBadge:v3,WidgetRegistryProvider:Vy,WidgetSlot:ft,ZoneEditingProvider:w0,buildStepTreeFromSchema:Ta,cn:K,createSharedContext:xn,createTheme:I2,darkColors:bm,defaultTheme:Sl,deriveDeviceKind:D3,ensureMfHostInit:Ec,getClassColor:mt,getPhaseVisual:ur,isFieldVisible:Nd,lightColors:xm,mirror:Vm,mountAddonPage:WM,providerIcons:BC,statusIcons:zC,themeToCss:D2,trpc:S,useAccessoriesGetStatus:YM,useAddonPagesListPages:nd,useAddonSettingsGetDeviceSettings:aE,useAddonSettingsGetGlobalSettings:sd,useAddonSettingsUpdateDeviceSettings:Mb,useAddonSettingsUpdateGlobalSettings:Cb,useAddonWidgetsListWidgets:Eb,useAddonsApplyAutoUpdateToAll:Sb,useAddonsCustom:oE,useAddonsForceRefresh:fb,useAddonsGetAddonAutoUpdate:Nb,useAddonsGetAutoUpdateSettings:wb,useAddonsGetLastRestart:mb,useAddonsGetLogs:ZM,useAddonsGetVersions:yb,useAddonsInstallFromWorkspace:JM,useAddonsInstallPackage:rd,useAddonsIsWorkspaceAvailable:eE,useAddonsList:wn,useAddonsListCapabilityProviders:Go,useAddonsListFrameworkPackages:gb,useAddonsListPackages:XM,useAddonsListUpdates:od,useAddonsListWorkspacePackages:tE,useAddonsOnAddonLogs:sE,useAddonsReloadPackages:ub,useAddonsRestartAddon:Ko,useAddonsRestartServer:hb,useAddonsRetryLoad:vb,useAddonsRollbackPackage:nE,useAddonsSearchAvailable:pb,useAddonsSetAddonAutoUpdate:kb,useAddonsSetAutoUpdateSettings:rE,useAddonsSetCapabilityProviderEnabled:bb,useAddonsUninstallPackage:db,useAddonsUpdateFrameworkPackage:xb,useAddonsUpdatePackage:Rl,useAlertsDismiss:$b,useAlertsEmit:iE,useAlertsGetUnreadCount:Ab,useAlertsList:Ib,useAlertsMarkAllRead:_b,useAlertsMarkRead:Pb,useAlertsUpdate:lE,useAllWidgets:Uy,useAudioAnalysisApplyDeviceSettingsPatch:pE,useAudioAnalysisGetDeviceLiveContribution:uE,useAudioAnalysisGetDeviceSettingsContribution:dE,useAudioAnalysisResolveDeviceSettings:cE,useAudioAnalyzerAnalyseChunk:fE,useAudioAnalyzerClassify:hE,useAudioAnalyzerDispose:gE,useAudioAnalyzerIsReady:mE,useAudioAnalyzerReprobeAudioEngine:Db,useAudioCodecCanHandle:xE,useAudioCodecCloseSession:wE,useAudioCodecCreateDecodeSession:yE,useAudioCodecCreateEncodeSession:vE,useAudioCodecFlushEncode:ME,useAudioCodecListActiveSessions:EE,useAudioCodecListSupportedCodecs:bE,useAudioCodecPullEncoded:CE,useAudioCodecPullPcm:kE,useAudioCodecPushEncodedFrame:NE,useAudioCodecPushPcm:SE,useAudioMetricsGetCurrentSnapshot:IE,useAudioMetricsGetHistory:AE,useBackupDelete:Bb,useBackupGetEntries:Rb,useBackupList:PE,useBackupListArchives:id,useBackupListDestinations:ad,useBackupListLocations:Lb,useBackupPreviewSchedule:Fb,useBackupRestore:Ob,useBackupTrigger:Tb,useBackupUpsertDestinationPolicy:zb,useBatteryGetStatus:_E,useBrightnessGetStatus:DE,useBrightnessSetBrightness:$E,useCameraCredentialsGetCredentials:TE,useCameraCredentialsGetStatus:LE,useCameraStreamsGetBrokerStreams:OE,useCameraStreamsGetCameraStreams:RE,useCameraStreamsGetRtspEntries:jb,useClusterNodes:Kr,useConfirm:nt,useCustomFieldRenderer:lb,useDebouncedString:tb,useDecoderCreateSession:FE,useDecoderDestroySession:jE,useDecoderGetInfo:zE,useDecoderGetStats:QE,useDecoderListActiveSessions:GE,useDecoderOpenStream:HE,useDecoderPullFrames:qE,useDecoderPushPacket:VE,useDecoderReprobeHwaccel:Vb,useDecoderSupportsCodec:BE,useDecoderUpdateConfig:UE,useDetectionPipelineApplyDeviceSettingsPatch:YE,useDetectionPipelineGetDeviceLiveContribution:WE,useDetectionPipelineGetDeviceSettingsContribution:KE,useDevShell:qM,useDevice:xT,useDeviceBattery:Yc,useDeviceCapability:Wr,useDeviceDetections:N0,useDeviceDiscoveryAdoptDevice:ZE,useDeviceDiscoveryGetStatus:JE,useDeviceDiscoveryListDiscovered:Hb,useDeviceDiscoveryRefreshDiscovery:qb,useDeviceDiscoveryReleaseDevice:XE,useDeviceExportApplyDeviceSettingsPatch:o4,useDeviceExportExposeDevice:t4,useDeviceExportGetDeviceLiveContribution:r4,useDeviceExportGetDeviceSettingsContribution:n4,useDeviceExportGetStatus:ld,useDeviceExportListExposedDevices:Ub,useDeviceExportListSupportedDeviceKinds:e4,useDeviceExportUnexposeDevice:Qb,useDeviceId:vn,useDeviceManagerAddLocation:f4,useDeviceManagerAdoptDevice:ox,useDeviceManagerAllocateDeviceId:s4,useDeviceManagerCreateDevice:ax,useDeviceManagerDisable:Xb,useDeviceManagerDiscoverDevices:dd,useDeviceManagerEnable:Zb,useDeviceManagerGetAllBindings:S4,useDeviceManagerGetBindings:ex,useDeviceManagerGetChildren:Yb,useDeviceManagerGetConfigSchema:x4,useDeviceManagerGetCreationSchema:sx,useDeviceManagerGetDevice:er,useDeviceManagerGetDeviceAggregate:cd,useDeviceManagerGetDeviceLiveInfoAggregate:E4,useDeviceManagerGetDeviceSettingsAggregate:M4,useDeviceManagerGetDeviceStatusAggregate:P4,useDeviceManagerGetSettingsSchema:y4,useDeviceManagerGetStreamProfileMap:w4,useDeviceManagerGetStreamSources:b4,useDeviceManagerListAll:Bn,useDeviceManagerListBindableCapsForDeviceType:nx,useDeviceManagerListLocations:Wb,useDeviceManagerListPersistedByAddon:g4,useDeviceManagerListWrappersForCap:C4,useDeviceManagerLoadConfig:c4,useDeviceManagerLoadMeta:u4,useDeviceManagerLoadRuntimeState:d4,useDeviceManagerPersistConfig:l4,useDeviceManagerProbeStreams:k4,useDeviceManagerRegisterDevice:a4,useDeviceManagerRemove:Jb,useDeviceManagerRemoveDevice:i4,useDeviceManagerRemoveLocation:h4,useDeviceManagerSetDisabled:m4,useDeviceManagerSetLocation:Kb,useDeviceManagerSetMetadata:p4,useDeviceManagerSetName:Gb,useDeviceManagerSetStreamProfileMap:N4,useDeviceManagerSetWrapperActive:tx,useDeviceManagerTestCreationField:ud,useDeviceManagerTestField:A4,useDeviceManagerUpdateConfig:v4,useDeviceManagerUpdateDeviceField:I4,useDeviceManagerUpdateDeviceFieldsBatch:rx,useDeviceOpsGetConfigEntries:$4,useDeviceOpsGetSettingsSchema:L4,useDeviceOpsGetStreamSources:_4,useDeviceOpsRemoveDevice:T4,useDeviceOpsSetConfig:D4,useDeviceProviderAdoptDiscoveredDevice:V4,useDeviceProviderCreateDevice:U4,useDeviceProviderDiscoverDevices:j4,useDeviceProviderGetChildCreationSchema:q4,useDeviceProviderGetDevices:z4,useDeviceProviderGetStatus:B4,useDeviceProviderStart:R4,useDeviceProviderStop:O4,useDeviceProviderSupportsDiscovery:F4,useDeviceProviderSupportsManualCreation:H4,useDeviceProviderTestCreationField:Q4,useDeviceProxy:At,useDeviceSnapshot:td,useDeviceSnapshotImage:Zc,useDeviceState:Vg,useDeviceStateGetAllSnapshots:W4,useDeviceStateGetCapSlice:K4,useDeviceStateGetSnapshot:G4,useDeviceStateSetCapSlice:Y4,useDeviceStateSlice:pn,useDeviceStatusGetStatus:Z4,useDeviceWebrtc:Td,useDevices:bT,useDoorbellEvents:Rd,useDoorbellGetStatus:X4,useEventInvalidation:wT,useEventStreamLatest:Gr,useEventStreamMap:Kc,useEventsGetEventClipUrl:tI,useEventsGetEventThumbnail:eI,useEventsGetEvents:J4,useFeatureProbeGetStatus:nI,useIntegrationsCreate:cx,useIntegrationsDelete:ux,useIntegrationsGet:ix,useIntegrationsGetAvailableTypes:px,useIntegrationsGetByAddonId:lx,useIntegrationsGetSettings:rI,useIntegrationsList:pd,useIntegrationsSetSettings:oI,useIntegrationsTestConnection:fx,useIntegrationsUpdate:dx,useIntercomEndTalkSession:iI,useIntercomGetStatus:lI,useIntercomHandleAnswer:mx,useIntercomPushTalkPcm:aI,useIntercomStartSession:hx,useIntercomStartTalkSession:sI,useIntercomStopSession:gx,useIsMidWidth:Mg,useIsMobile:hr,useLiveBuffer:Yn,useLiveEvent:gt,useLocalNetworkGetAllowedAddresses:yx,useLocalNetworkGetConnectionEndpoints:xx,useLocalNetworkGetPreferred:cI,useLocalNetworkList:bx,useLocalNetworkResetAllowlistToBestMatch:wx,useLocalNetworkSetAllowedAddresses:vx,useMeshNetworkGetStatus:Nx,useMeshNetworkJoin:dI,useMeshNetworkLeave:Sx,useMeshNetworkListPeers:Mx,useMeshNetworkLogout:Cx,useMeshNetworkStartLogin:kx,useMeshNetworkTestConnection:uI,useMetricsProviderCollectSnapshot:pI,useMetricsProviderGetAddonStats:vI,useMetricsProviderGetCached:fI,useMetricsProviderGetCpuTemperature:bI,useMetricsProviderGetCurrent:hI,useMetricsProviderGetDiskSpace:mI,useMetricsProviderGetGpuInfo:gI,useMetricsProviderGetProcessStats:xI,useMetricsProviderKillProcess:Ix,useMetricsProviderListAddonInstances:yI,useMetricsProviderListNodeProcesses:Ex,useMotionDetectionAnalyze:kI,useMotionDetectionApplyDeviceSettingsPatch:II,useMotionDetectionGetDeviceLiveContribution:EI,useMotionDetectionGetDeviceSettingsContribution:MI,useMotionDetectionRemoveCamera:SI,useMotionDetectionReset:CI,useMotionGetStatus:NI,useMotionIsDetected:wI,useMotionTriggerGetStatus:PI,useMotionTriggerSetMotionTrigger:AI,useMqttBrokerAddBroker:DI,useMqttBrokerGetBrokerConfig:$I,useMqttBrokerGetStatus:Ax,useMqttBrokerListBrokers:_I,useMqttBrokerRemoveBroker:TI,useMqttBrokerStartEmbeddedBroker:RI,useMqttBrokerStopEmbeddedBroker:OI,useMqttBrokerTestConnection:LI,useNativeObjectDetectionGetStatus:BI,useNetworkAccessGetEndpoint:zI,useNetworkAccessGetStatus:$x,useNetworkAccessListEndpoints:FI,useNetworkAccessStart:Px,useNetworkAccessStop:_x,useNetworkQualityGetAllStats:jI,useNetworkQualityGetDeviceStats:fd,useNetworkQualityReportClientStats:VI,useNodesClusterAddonStatus:Ox,useNodesDeployAddon:HI,useNodesExecuteQuery:UI,useNodesGetNodeAddons:Bx,useNodesRenameNode:Rx,useNodesRestartAddon:Ba,useNodesRestartNode:Lx,useNodesRestartProcess:Tx,useNodesSetProcessLogLevel:zx,useNodesShutdownNode:qI,useNodesTopology:zn,useNodesUndeployAddon:Dx,useNotificationOutputSend:QI,useNotificationOutputSendTest:GI,useOptionalSystem:h3,useOptionalWidgetRegistry:Qy,useOsdGetStatus:WI,useOsdSetOverlay:KI,usePTZ:Ld,usePipelineAnalyticsApplyDeviceSettingsPatch:iA,usePipelineAnalyticsClearTracks:JI,usePipelineAnalyticsGetActiveTracks:YI,usePipelineAnalyticsGetAudioEvents:nA,usePipelineAnalyticsGetDeviceLiveContribution:aA,usePipelineAnalyticsGetDeviceSettingsContribution:sA,usePipelineAnalyticsGetEventMedia:rA,usePipelineAnalyticsGetMotionEvents:eA,usePipelineAnalyticsGetObjectEvents:tA,usePipelineAnalyticsGetTrack:ZI,usePipelineAnalyticsGetTrackMedia:oA,usePipelineAnalyticsListTracks:XI,usePipelineExecutorCacheFrameInPool:kA,usePipelineExecutorDeleteModel:qx,usePipelineExecutorDeleteTemplate:bA,usePipelineExecutorDetect:vA,usePipelineExecutorDownloadModel:Hx,usePipelineExecutorGetAddonModels:yA,usePipelineExecutorGetAudioCapabilities:$A,usePipelineExecutorGetAvailableEngines:Fx,usePipelineExecutorGetCapabilities:xA,usePipelineExecutorGetDefaultSteps:lA,usePipelineExecutorGetDetectionConfigSchema:TA,usePipelineExecutorGetEffectiveTuning:MA,usePipelineExecutorGetGlobalPipelineConfig:pA,usePipelineExecutorGetGlobalSteps:uA,usePipelineExecutorGetOrchestratorConfigSchema:fA,usePipelineExecutorGetReferenceAudio:_A,usePipelineExecutorGetReferenceAudioFiles:PA,usePipelineExecutorGetReferenceImage:AA,usePipelineExecutorGetSchema:Wo,usePipelineExecutorGetSelectedEngine:jx,usePipelineExecutorGetVideoPipelineSteps:cA,usePipelineExecutorInferCached:SA,usePipelineExecutorKillEngine:Qx,usePipelineExecutorListLoadedEngines:Ux,usePipelineExecutorListReferenceImages:IA,usePipelineExecutorListTemplates:hA,usePipelineExecutorReprobeEngine:Vx,usePipelineExecutorRunAudioTest:DA,usePipelineExecutorRunPipeline:wA,usePipelineExecutorRunPipelineBatch:NA,usePipelineExecutorSaveTemplate:mA,usePipelineExecutorSetVideoPipelineSteps:dA,usePipelineExecutorSpinEngine:EA,usePipelineExecutorUncacheFrame:CA,usePipelineExecutorUpdateTemplate:gA,usePipelineOrchestratorApplyDeviceSettingsPatch:HA,usePipelineOrchestratorAssignAudio:ny,usePipelineOrchestratorAssignDecoder:Jx,usePipelineOrchestratorAssignPipeline:Gx,usePipelineOrchestratorDeleteTemplate:fy,usePipelineOrchestratorGetAgentLoad:Yx,usePipelineOrchestratorGetAgentSettings:hd,usePipelineOrchestratorGetAudioAssignment:OA,usePipelineOrchestratorGetAudioAssignments:sy,usePipelineOrchestratorGetAudioNodeLoad:oy,usePipelineOrchestratorGetCameraMetrics:RA,usePipelineOrchestratorGetCameraSettings:gd,usePipelineOrchestratorGetCameraStepOverrides:zA,usePipelineOrchestratorGetCapabilityBindings:Zx,usePipelineOrchestratorGetDecoderAssignment:BA,usePipelineOrchestratorGetDecoderAssignments:ty,usePipelineOrchestratorGetDeviceLiveContribution:VA,usePipelineOrchestratorGetDeviceSettingsContribution:jA,usePipelineOrchestratorGetGlobalMetrics:LA,usePipelineOrchestratorGetPipelineAssignment:Fa,usePipelineOrchestratorGetPipelineAssignments:za,usePipelineOrchestratorListAgentSettings:Yr,usePipelineOrchestratorListTemplates:uy,usePipelineOrchestratorRebalance:Wx,usePipelineOrchestratorRemoveAgentSettings:ay,usePipelineOrchestratorResolvePipeline:dy,usePipelineOrchestratorSaveTemplate:FA,usePipelineOrchestratorSetAgentAddonDefaults:md,usePipelineOrchestratorSetCameraPipelineForAgent:cy,usePipelineOrchestratorSetCameraStepOverride:ly,usePipelineOrchestratorSetCameraStepToggle:iy,usePipelineOrchestratorSetCapabilityBinding:Xx,usePipelineOrchestratorUnassignAudio:ry,usePipelineOrchestratorUnassignDecoder:ey,usePipelineOrchestratorUnassignPipeline:Kx,usePipelineOrchestratorUpdateTemplate:py,usePipelineRunnerAttachCamera:qA,usePipelineRunnerDetachCamera:UA,usePipelineRunnerGetAllCameraMetrics:WA,usePipelineRunnerGetCameraMetrics:bd,usePipelineRunnerGetLocalCameras:hy,usePipelineRunnerGetLocalLoad:GA,usePipelineRunnerGetLocalMetrics:KA,usePipelineRunnerReportMotion:QA,usePlatformProbeGetCapabilities:YA,usePlatformProbeGetHardware:ZA,usePlatformProbeGetHardwareEncoders:eP,usePlatformProbeRefreshHardwareEncoders:tP,usePlatformProbeResolveHwAccel:JA,usePlatformProbeResolveInferenceConfig:XA,usePlayerOverlayLayer:oD,usePlayerOverlayLayers:e0,usePlayerToolbarButton:sD,usePlayerToolbarButtons:t0,usePtzAutotrackGetSettings:dP,usePtzAutotrackGetStatus:my,usePtzAutotrackSetEnabled:gy,usePtzAutotrackSetSettings:by,usePtzContinuousMove:rP,usePtzGetPosition:lP,usePtzGetPresets:sP,usePtzGetStatus:cP,usePtzGoHome:iP,usePtzGoToPreset:aP,usePtzMove:nP,usePtzStop:oP,useRebootReboot:xy,useRecordingEngineDisable:vy,useRecordingEngineEnable:yy,useRecordingEngineEstimateGlobalStorage:vP,useRecordingEngineEstimateStorage:yP,useRecordingEngineGetAvailability:xP,useRecordingEngineGetConfig:wy,useRecordingEngineGetMotionStats:SP,useRecordingEngineGetPlaylist:gP,useRecordingEngineGetPolicy:NP,useRecordingEngineGetPolicyStatus:Sy,useRecordingEngineGetRetentionConfig:Cy,useRecordingEngineGetSegments:Ny,useRecordingEngineGetStatus:hP,useRecordingEngineGetStorageUsage:ky,useRecordingEngineGetThumbnail:bP,useRecordingEngineSetPolicy:wP,useRecordingEngineUpdateConfig:mP,useRecordingEngineUpdateRetentionConfig:kP,useRecordingGetPlaybackUrl:pP,useRecordingGetSegments:uP,useRecordingGetThumbnailAt:fP,useSettingsStoreCount:_P,useSettingsStoreDeclareCollection:DP,useSettingsStoreDelete:PP,useSettingsStoreGet:CP,useSettingsStoreInsert:IP,useSettingsStoreIsEmpty:$P,useSettingsStoreQuery:EP,useSettingsStoreSet:MP,useSettingsStoreUpdate:AP,useSnapshotApplyDeviceSettingsPatch:zP,useSnapshotGetDeviceLiveContribution:BP,useSnapshotGetDeviceSettingsContribution:OP,useSnapshotGetSnapshot:TP,useSnapshotGetStatus:RP,useSnapshotInvalidateCache:LP,useSnapshotProviderGetSnapshot:jP,useSnapshotProviderSupportsDevice:FP,useStorageAbortUpload:XP,useStorageBeginDownload:JP,useStorageBeginUpload:WP,useStorageDelete:GP,useStorageDeleteLocation:Ey,useStorageEndDownload:t_,useStorageExists:UP,useStorageFinalizeUpload:ZP,useStorageGetAvailableSpace:KP,useStorageGetDefaultLocation:n_,useStorageList:QP,useStorageListLocations:My,useStorageListProviders:xd,useStorageRead:qP,useStorageReadChunk:e_,useStorageResolve:VP,useStorageTestConfig:o_,useStorageTestLocation:r_,useStorageUpsertLocation:ja,useStorageWrite:HP,useStorageWriteChunk:YP,useStreamBrokerApplyDeviceSettingsPatch:I_,useStreamBrokerAssignProfile:i_,useStreamBrokerGetAllRtspEntries:N_,useStreamBrokerGetBroker:x_,useStreamBrokerGetBrokerStats:u_,useStreamBrokerGetDeviceLiveContribution:E_,useStreamBrokerGetDeviceSettingsContribution:M_,useStreamBrokerGetPreBufferInfo:v_,useStreamBrokerGetRtspEntry:k_,useStreamBrokerGetRtspPort:w_,useStreamBrokerGetStreamUrl:m_,useStreamBrokerGetStreamWithCodec:g_,useStreamBrokerIsRtspEnabled:C_,useStreamBrokerKillClient:f_,useStreamBrokerListAllCameraStreams:c_,useStreamBrokerListAllProfileSlots:d_,useStreamBrokerListClients:p_,useStreamBrokerPublishCameraStream:s_,useStreamBrokerRegenerateRtspToken:Iy,useStreamBrokerReleaseStreamWithCodec:b_,useStreamBrokerRestartProfile:h_,useStreamBrokerRetractCameraStream:a_,useStreamBrokerSetPreBufferDuration:y_,useStreamBrokerSetRtspEnabled:S_,useStreamBrokerUnassignProfile:l_,useSwitchGetStatus:P_,useSwitchSetState:A_,useSystem:Te,useSystemFeatureFlags:D_,useSystemForceRetentionCleanup:O_,useSystemGetRetentionConfig:L_,useSystemHealth:$_,useSystemInfo:__,useSystemMutation:vT,useSystemNetworkAddresses:T_,useSystemQuery:yT,useSystemSetRetentionConfig:R_,useThemeMode:Hr,useToastOnToast:Ay,useTurnProviderGetTurnServers:yd,useUserManagementConfirmTotp:H_,useUserManagementCreateApiKey:z_,useUserManagementCreateScopedToken:Ry,useUserManagementCreateUser:Py,useUserManagementDeleteUser:$y,useUserManagementDisableTotp:zy,useUserManagementGetTotpStatus:Fy,useUserManagementListApiKeys:Ty,useUserManagementListScopedTokens:By,useUserManagementListUsers:vd,useUserManagementResetPassword:wd,useUserManagementRevokeApiKey:Ly,useUserManagementRevokeScopedToken:Oy,useUserManagementSetUserScopes:Dy,useUserManagementSetupTotp:V_,useUserManagementUpdateUser:_y,useUserManagementValidateApiKey:F_,useUserManagementValidateCredentials:B_,useUserManagementValidateScopedToken:j_,useUserManagementVerifyTotp:q_,useWebrtcSessionCloseSession:W_,useWebrtcSessionCreateSession:Q_,useWebrtcSessionHandleAnswer:K_,useWebrtcSessionHandleOffer:G_,useWebrtcSessionHasAdaptiveBitrate:Y_,useWebrtcSessionListStreams:U_,useWidget:Hy,useWidgetMetadata:qy,useWidgetRegistry:Va,useZoneAnalyticsGetCameraHistory:J_,useZoneAnalyticsGetCurrentSnapshot:Z_,useZoneAnalyticsGetUnzonedHistory:e$,useZoneAnalyticsGetZoneHistory:X_,useZoneEditing:mT,useZoneRulesListRules:t$,useZoneRulesSetRules:n$,useZonesAddZone:o$,useZonesListZones:r$,useZonesRemoveZone:s$,useZonesUpdateZone:a$,validateScopes:Dd},Symbol.toStringTag,{value:"Module"}));/**
|
|
563
|
-
* react-router v7.15.0
|
|
564
|
-
*
|
|
565
|
-
* Copyright (c) Remix Software Inc.
|
|
566
|
-
*
|
|
567
|
-
* This source code is licensed under the MIT license found in the
|
|
568
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
569
|
-
*
|
|
570
|
-
* @license MIT
|
|
571
|
-
*/var Tp="popstate";function Lp(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function kT(e={}){function t(r,s){let a=s.state?.masked,{pathname:i,search:l,hash:c}=a||r.location;return jl("",{pathname:i,search:l,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default",a?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,s){return typeof s=="string"?s:Po(s)}return CT(t,n,null,e)}function je(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Mt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function ST(){return Math.random().toString(36).substring(2,10)}function Rp(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 jl(e,t,n=null,r,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Zr(t):t,state:n,key:t&&t.key||r||ST(),mask:s}}function Po({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 Zr(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function CT(e,t,n,r={}){let{window:s=document.defaultView,v5Compat:a=!1}=r,i=s.history,l="POP",c=null,d=u();d==null&&(d=0,i.replaceState({...i.state,idx:d},""));function u(){return(i.state||{idx:null}).idx}function p(){l="POP";let x=u(),y=x==null?null:x-d;d=x,c&&c({action:l,location:b.location,delta:y})}function h(x,y){l="PUSH";let w=Lp(x)?x:jl(b.location,x,y);d=u()+1;let v=Rp(w,d),N=b.createHref(w.mask||w);try{i.pushState(v,"",N)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;s.location.assign(N)}a&&c&&c({action:l,location:b.location,delta:1})}function m(x,y){l="REPLACE";let w=Lp(x)?x:jl(b.location,x,y);d=u();let v=Rp(w,d),N=b.createHref(w.mask||w);i.replaceState(v,"",N),a&&c&&c({action:l,location:b.location,delta:0})}function g(x){return MT(x)}let b={get action(){return l},get location(){return e(s,i)},listen(x){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(Tp,p),c=x,()=>{s.removeEventListener(Tp,p),c=null}},createHref(x){return t(s,x)},createURL:g,encodeLocation(x){let y=g(x);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:h,replace:m,go(x){return i.go(x)}};return b}function MT(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),je(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Po(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function k0(e,t,n="/"){return ET(e,t,n,!1)}function ET(e,t,n,r,s){let a=typeof t=="string"?Zr(t):t,i=fn(a.pathname||"/",n);if(i==null)return null;let l=IT(e),c=null,d=FT(i);for(let u=0;c==null&&u<l.length;++u)c=BT(l[u],d,r);return c}function IT(e){let t=S0(e);return AT(t),t}function S0(e,t=[],n=[],r="",s=!1){let a=(i,l,c=s,d)=>{let u={relativePath:d===void 0?i.path||"":d,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(r)&&c)return;je(u.relativePath.startsWith(r),`Absolute route path "${u.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(r.length)}let p=Ft([r,u.relativePath]),h=n.concat(u);i.children&&i.children.length>0&&(je(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${p}".`),S0(i.children,t,h,p,c)),!(i.path==null&&!i.index)&&t.push({path:p,score:RT(p,i.index),routesMeta:h})};return e.forEach((i,l)=>{if(i.path===""||!i.path?.includes("?"))a(i,l);else for(let c of C0(i.path))a(i,l,!0,c)}),t}function C0(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return s?[a,""]:[a];let i=C0(r.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 AT(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:OT(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var PT=/^:[\w-]+$/,_T=3,$T=2,DT=1,TT=10,LT=-2,Op=e=>e==="*";function RT(e,t){let n=e.split("/"),r=n.length;return n.some(Op)&&(r+=LT),t&&(r+=$T),n.filter(s=>!Op(s)).reduce((s,a)=>s+(PT.test(a)?_T:a===""?DT:TT),r)}function OT(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function BT(e,t,n=!1){let{routesMeta:r}=e,s={},a="/",i=[];for(let l=0;l<r.length;++l){let c=r[l],d=l===r.length-1,u=a==="/"?t:t.slice(a.length)||"/",p=ra({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},u),h=c.route;if(!p&&d&&n&&!r[r.length-1].route.index&&(p=ra({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},u)),!p)return null;Object.assign(s,p.params),i.push({params:s,pathname:Ft([a,p.pathname]),pathnameBase:qT(Ft([a,p.pathnameBase])),route:h}),p.pathnameBase!=="/"&&(a=Ft([a,p.pathnameBase]))}return i}function ra(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=zT(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:r.reduce((d,{paramName:u,isOptional:p},h)=>{if(u==="*"){let g=l[h]||"";i=a.slice(0,a.length-g.length).replace(/(.)\/+$/,"$1")}const m=l[h];return p&&!m?d[u]=void 0:d[u]=(m||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:i,pattern:e}}function zT(e,t=!1,n=!0){Mt(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 r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,c,d,u)=>{if(r.push({paramName:l,isOptional:c!=null}),c){let p=u.charAt(d+i.length);return p&&p!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function FT(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Mt(!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 fn(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var jT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function VT(e,t="/"){let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?Zr(e):e,a;return n?(n=M0(n),n.startsWith("/")?a=Bp(n.substring(1),"/"):a=Bp(n,t)):a=t,{pathname:a,search:UT(r),hash:QT(s)}}function Bp(e,t){let n=oa(t).split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function Ri(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. 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 HT(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Od(e){let t=HT(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function qa(e,t,n,r=!1){let s;typeof e=="string"?s=Zr(e):(s={...e},je(!s.pathname||!s.pathname.includes("?"),Ri("?","pathname","search",s)),je(!s.pathname||!s.pathname.includes("#"),Ri("#","pathname","hash",s)),je(!s.search||!s.search.includes("#"),Ri("#","search","hash",s)));let a=e===""||s.pathname==="",i=a?"/":s.pathname,l;if(i==null)l=n;else{let p=t.length-1;if(!r&&i.startsWith("..")){let h=i.split("/");for(;h[0]==="..";)h.shift(),p-=1;s.pathname=h.join("/")}l=p>=0?t[p]:"/"}let c=VT(s,l),d=i&&i!=="/"&&i.endsWith("/"),u=(a||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}var M0=e=>e.replace(/\/\/+/g,"/"),Ft=e=>M0(e.join("/")),oa=e=>e.replace(/\/+$/,""),qT=e=>oa(e).replace(/^\/*/,"/"),UT=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,QT=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,GT=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function KT(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function WT(e){let t=e.map(n=>n.route.path).filter(Boolean);return Ft(t)||"/"}var E0=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function I0(e,t){let n=e;if(typeof n!="string"||!jT.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,s=!1;if(E0)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=fn(i.pathname,t);i.origin===a.origin&&l!=null?n=l+i.search+i.hash:s=!0}catch{Mt(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:s,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var A0=["POST","PUT","PATCH","DELETE"];new Set(A0);var YT=["GET",...A0];new Set(YT);var Xr=ze(null);Xr.displayName="DataRouter";var Ua=ze(null);Ua.displayName="DataRouterState";var P0=ze(!1);function ZT(){return ve(P0)}var _0=ze({isTransitioning:!1});_0.displayName="ViewTransition";var XT=ze(new Map);XT.displayName="Fetchers";var JT=ze(null);JT.displayName="Await";var yt=ze(null);yt.displayName="Navigation";var Yo=ze(null);Yo.displayName="Location";var Pt=ze({outlet:null,matches:[],isDataRoute:!1});Pt.displayName="Route";var Bd=ze(null);Bd.displayName="RouteError";var $0="REACT_ROUTER_ERROR",eL="REDIRECT",tL="ROUTE_ERROR_RESPONSE";function nL(e){if(e.startsWith(`${$0}:${eL}:{`))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 rL(e){if(e.startsWith(`${$0}:${tL}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new GT(t.status,t.statusText,t.data)}catch{}}function oL(e,{relative:t}={}){je(Jr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=ve(yt),{hash:s,pathname:a,search:i}=Zo(e,{relative:t}),l=a;return n!=="/"&&(l=a==="/"?n:Ft([n,a])),r.createHref({pathname:l,search:i,hash:s})}function Jr(){return ve(Yo)!=null}function vt(){return je(Jr(),"useLocation() may be used only in the context of a <Router> component."),ve(Yo).location}var D0="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function T0(e){ve(yt).static||Aa(e)}function rt(){let{isDataRoute:e}=ve(Pt);return e?yL():sL()}function sL(){je(Jr(),"useNavigate() may be used only in the context of a <Router> component.");let e=ve(Xr),{basename:t,navigator:n}=ve(yt),{matches:r}=ve(Pt),{pathname:s}=vt(),a=JSON.stringify(Od(r)),i=te(!1);return T0(()=>{i.current=!0}),U((c,d={})=>{if(Mt(i.current,D0),!i.current)return;if(typeof c=="number"){n.go(c);return}let u=qa(c,JSON.parse(a),s,d.relative==="path");e==null&&t!=="/"&&(u.pathname=u.pathname==="/"?t:Ft([t,u.pathname])),(d.replace?n.replace:n.push)(u,d.state,d)},[t,n,a,s,e])}var aL=ze(null);function iL(e){let t=ve(Pt).outlet;return H(()=>t&&Ee(aL.Provider,{value:e},t),[t,e])}function zd(){let{matches:e}=ve(Pt);return e[e.length-1]?.params??{}}function Zo(e,{relative:t}={}){let{matches:n}=ve(Pt),{pathname:r}=vt(),s=JSON.stringify(Od(n));return H(()=>qa(e,JSON.parse(s),r,t==="path"),[e,s,r,t])}function lL(e,t){return L0(e,t)}function L0(e,t,n){je(Jr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=ve(yt),{matches:s}=ve(Pt),a=s[s.length-1],i=a?a.params:{},l=a?a.pathname:"/",c=a?a.pathnameBase:"/",d=a&&a.route;{let x=d&&d.path||"";O0(l,!d||x.endsWith("*")||x.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${x}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
572
|
-
|
|
573
|
-
Please change the parent <Route path="${x}"> to <Route path="${x==="/"?"*":`${x}/*`}">.`)}let u=vt(),p;if(t){let x=typeof t=="string"?Zr(t):t;je(c==="/"||x.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${x.pathname}" was given in the \`location\` prop.`),p=x}else p=u;let h=p.pathname||"/",m=h;if(c!=="/"){let x=c.replace(/^\//,"").split("/");m="/"+h.replace(/^\//,"").split("/").slice(x.length).join("/")}let g=n&&n.state.matches.length?n.state.matches.map(x=>Object.assign(x,{route:n.manifest[x.route.id]||x.route})):k0(e,{pathname:m});Mt(d||g!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Mt(g==null||g[g.length-1].route.element!==void 0||g[g.length-1].route.Component!==void 0||g[g.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let b=fL(g&&g.map(x=>Object.assign({},x,{params:Object.assign({},i,x.params),pathname:Ft([c,r.encodeLocation?r.encodeLocation(x.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?c:Ft([c,r.encodeLocation?r.encodeLocation(x.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathnameBase])})),s,n);return t&&b?Ee(Yo.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...p},navigationType:"POP"}},b):b}function cL(){let e=xL(),t=KT(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=Ee($r,null,Ee("p",null,"💿 Hey developer 👋"),Ee("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",Ee("code",{style:a},"ErrorBoundary")," or"," ",Ee("code",{style:a},"errorElement")," prop on your route.")),Ee($r,null,Ee("h2",null,"Unexpected Application Error!"),Ee("h3",{style:{fontStyle:"italic"}},t),n?Ee("pre",{style:s},n):null,i)}var dL=Ee(cL,null),R0=class extends l2{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=rL(e.digest);n&&(e=n)}let t=e!==void 0?Ee(Pt.Provider,{value:this.props.routeContext},Ee(Bd.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?Ee(uL,{error:e},t):t}};R0.contextType=P0;var Oi=new WeakMap;function uL({children:e,error:t}){let{basename:n}=ve(yt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=nL(t.digest);if(r){let s=Oi.get(t);if(s)throw s;let a=I0(r.location,n);if(E0&&!Oi.get(t))if(a.isExternal||r.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:r.replace}));throw Oi.set(t,i),i}return Ee("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function pL({routeContext:e,match:t,children:n}){let r=ve(Xr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),Ee(Pt.Provider,{value:e},n)}function fL(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let s=e,a=r?.errors;if(a!=null){let u=s.findIndex(p=>p.route.id&&a?.[p.route.id]!==void 0);je(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),s=s.slice(0,Math.min(s.length,u+1))}let i=!1,l=-1;if(n&&r){i=r.renderFallback;for(let u=0;u<s.length;u++){let p=s[u];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(l=u),p.route.id){let{loaderData:h,errors:m}=r,g=p.route.loader&&!h.hasOwnProperty(p.route.id)&&(!m||m[p.route.id]===void 0);if(p.route.lazy||g){n.isStatic&&(i=!0),l>=0?s=s.slice(0,l+1):s=[s[0]];break}}}}let c=n?.onError,d=r&&c?(u,p)=>{c(u,{location:r.location,params:r.matches?.[0]?.params??{},pattern:WT(r.matches),errorInfo:p})}:void 0;return s.reduceRight((u,p,h)=>{let m,g=!1,b=null,x=null;r&&(m=a&&p.route.id?a[p.route.id]:void 0,b=p.route.errorElement||dL,i&&(l<0&&h===0?(O0("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,x=null):l===h&&(g=!0,x=p.route.hydrateFallbackElement||null)));let y=t.concat(s.slice(0,h+1)),w=()=>{let v;return m?v=b:g?v=x:p.route.Component?v=Ee(p.route.Component,null):p.route.element?v=p.route.element:v=u,Ee(pL,{match:p,routeContext:{outlet:u,matches:y,isDataRoute:r!=null},children:v})};return r&&(p.route.ErrorBoundary||p.route.errorElement||h===0)?Ee(R0,{location:r.location,revalidation:r.revalidation,component:b,error:m,children:w(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:d}):w()},null)}function Fd(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function hL(e){let t=ve(Xr);return je(t,Fd(e)),t}function mL(e){let t=ve(Ua);return je(t,Fd(e)),t}function gL(e){let t=ve(Pt);return je(t,Fd(e)),t}function jd(e){let t=gL(e),n=t.matches[t.matches.length-1];return je(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function bL(){return jd("useRouteId")}function xL(){let e=ve(Bd),t=mL("useRouteError"),n=jd("useRouteError");return e!==void 0?e:t.errors?.[n]}function yL(){let{router:e}=hL("useNavigate"),t=jd("useNavigate"),n=te(!1);return T0(()=>{n.current=!0}),U(async(s,a={})=>{Mt(n.current,D0),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...a}))},[e,t])}var zp={};function O0(e,t,n){!t&&!zp[e]&&(zp[e]=!0,Mt(!1,n))}He(vL);function vL({routes:e,manifest:t,future:n,state:r,isStatic:s,onError:a}){return L0(e,void 0,{manifest:t,state:r,isStatic:s,onError:a})}function Nt({to:e,replace:t,state:n,relative:r}){je(Jr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:s}=ve(yt);Mt(!s,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:a}=ve(Pt),{pathname:i}=vt(),l=rt(),c=qa(e,Od(a),i,r==="path"),d=JSON.stringify(c);return Y(()=>{l(JSON.parse(d),{replace:t,state:n,relative:r})},[l,d,r,t,n]),null}function wL(e){return iL(e.context)}function Le(e){je(!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 NL({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:s,static:a=!1,useTransitions:i}){je(!Jr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=H(()=>({basename:l,navigator:s,static:a,useTransitions:i,future:{}}),[l,s,a,i]);typeof n=="string"&&(n=Zr(n));let{pathname:d="/",search:u="",hash:p="",state:h=null,key:m="default",mask:g}=n,b=H(()=>{let x=fn(d,l);return x==null?null:{location:{pathname:x,search:u,hash:p,state:h,key:m,mask:g},navigationType:r}},[l,d,u,p,h,m,r,g]);return Mt(b!=null,`<Router basename="${l}"> is not able to match the URL "${d}${u}${p}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:Ee(yt.Provider,{value:c},Ee(Yo.Provider,{children:t,value:b}))}function kL({children:e,location:t}){return lL(Vl(e),t)}function Vl(e,t=[]){let n=[];return a2.forEach(e,(r,s)=>{if(!i2(r))return;let a=[...t,s];if(r.type===$r){n.push.apply(n,Vl(r.props.children,a));return}je(r.type===Le,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),je(!r.props.index||!r.props.children,"An index route cannot have child routes.");let i={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(i.children=Vl(r.props.children,a)),n.push(i)}),n}var Vs="get",Hs="application/x-www-form-urlencoded";function Qa(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function SL(e){return Qa(e)&&e.tagName.toLowerCase()==="button"}function CL(e){return Qa(e)&&e.tagName.toLowerCase()==="form"}function ML(e){return Qa(e)&&e.tagName.toLowerCase()==="input"}function EL(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function IL(e,t){return e.button===0&&(!t||t==="_self")&&!EL(e)}function Hl(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(s=>[n,s]):[[n,r]])},[]))}function AL(e,t){let n=Hl(e);return t&&t.forEach((r,s)=>{n.has(s)||t.getAll(s).forEach(a=>{n.append(s,a)})}),n}var ys=null;function PL(){if(ys===null)try{new FormData(document.createElement("form"),0),ys=!1}catch{ys=!0}return ys}var _L=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Bi(e){return e!=null&&!_L.has(e)?(Mt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Hs}"`),null):e}function $L(e,t){let n,r,s,a,i;if(CL(e)){let l=e.getAttribute("action");r=l?fn(l,t):null,n=e.getAttribute("method")||Vs,s=Bi(e.getAttribute("enctype"))||Hs,a=new FormData(e)}else if(SL(e)||ML(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(r=c?fn(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Vs,s=Bi(e.getAttribute("formenctype"))||Bi(l.getAttribute("enctype"))||Hs,a=new FormData(l,e),!PL()){let{name:d,type:u,value:p}=e;if(u==="image"){let h=d?`${d}.`:"";a.append(`${h}x`,"0"),a.append(`${h}y`,"0")}else d&&a.append(d,p)}}else{if(Qa(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Vs,r=null,s=Hs,i=e}return a&&s==="text/plain"&&(i=a,a=void 0),{action:r,method:n.toLowerCase(),encType:s,formData:a,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Vd(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function B0(e,t,n,r){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}_.${r}`:s.pathname=`${s.pathname}.${r}`:s.pathname==="/"?s.pathname=`_root.${r}`:t&&fn(s.pathname,t)==="/"?s.pathname=`${oa(t)}/_root.${r}`:s.pathname=`${oa(s.pathname)}.${r}`,s}async function DL(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 TL(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 LL(e,t,n){let r=await Promise.all(e.map(async s=>{let a=t.routes[s.route.id];if(a){let i=await DL(a,n);return i.links?i.links():[]}return[]}));return zL(r.flat(1).filter(TL).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function Fp(e,t,n,r,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 u=r.routes[c.route.id];if(!u||!u.hasLoader)return!1;if(i(c,d)||l(c,d))return!0;if(c.route.shouldRevalidate){let p=c.route.shouldRevalidate({currentUrl:new URL(s.pathname+s.search+s.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof p=="boolean")return p}return!0}):[]}function RL(e,t,{includeHydrateFallback:n}={}){return OL(e.map(r=>{let s=t.routes[r.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 OL(e){return[...new Set(e)]}function BL(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function zL(e,t){let n=new Set;return new Set(t),e.reduce((r,s)=>{let a=JSON.stringify(BL(s));return n.has(a)||(n.add(a),r.push({key:a,link:s})),r},[])}function Hd(){let e=ve(Xr);return Vd(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function FL(){let e=ve(Ua);return Vd(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var qd=ze(void 0);qd.displayName="FrameworkContext";function Ud(){let e=ve(qd);return Vd(e,"You must render this element inside a <HydratedRouter> element"),e}function jL(e,t){let n=ve(qd),[r,s]=_(!1),[a,i]=_(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:u,onTouchStart:p}=t,h=te(null);Y(()=>{if(e==="render"&&i(!0),e==="viewport"){let b=y=>{y.forEach(w=>{i(w.isIntersecting)})},x=new IntersectionObserver(b,{threshold:.5});return h.current&&x.observe(h.current),()=>{x.disconnect()}}},[e]),Y(()=>{if(r){let b=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(b)}}},[r]);let m=()=>{s(!0)},g=()=>{s(!1),i(!1)};return n?e!=="intent"?[a,h,{}]:[a,h,{onFocus:so(l,m),onBlur:so(c,g),onMouseEnter:so(d,m),onMouseLeave:so(u,g),onTouchStart:so(p,m)}]:[!1,h,{}]}function so(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function VL({page:e,...t}){let n=ZT(),{router:r}=Hd(),s=H(()=>k0(r.routes,e,r.basename),[r.routes,e,r.basename]);return s?n?Ee(qL,{page:e,matches:s,...t}):Ee(UL,{page:e,matches:s,...t}):null}function HL(e){let{manifest:t,routeModules:n}=Ud(),[r,s]=_([]);return Y(()=>{let a=!1;return LL(e,t,n).then(i=>{a||s(i)}),()=>{a=!0}},[e,t,n]),r}function qL({page:e,matches:t,...n}){let r=vt(),{future:s}=Ud(),{basename:a}=Hd(),i=H(()=>{if(e===r.pathname+r.search+r.hash)return[];let l=B0(e,a,s.unstable_trailingSlashAwareDataRequests,"rsc"),c=!1,d=[];for(let u of t)typeof u.route.shouldRevalidate=="function"?c=!0:d.push(u.route.id);return c&&d.length>0&&l.searchParams.set("_routes",d.join(",")),[l.pathname+l.search]},[a,s.unstable_trailingSlashAwareDataRequests,e,r,t]);return Ee($r,null,i.map(l=>Ee("link",{key:l,rel:"prefetch",as:"fetch",href:l,...n})))}function UL({page:e,matches:t,...n}){let r=vt(),{future:s,manifest:a,routeModules:i}=Ud(),{basename:l}=Hd(),{loaderData:c,matches:d}=FL(),u=H(()=>Fp(e,t,d,a,r,"data"),[e,t,d,a,r]),p=H(()=>Fp(e,t,d,a,r,"assets"),[e,t,d,a,r]),h=H(()=>{if(e===r.pathname+r.search+r.hash)return[];let b=new Set,x=!1;if(t.forEach(w=>{let v=a.routes[w.route.id];!v||!v.hasLoader||(!u.some(N=>N.route.id===w.route.id)&&w.route.id in c&&i[w.route.id]?.shouldRevalidate||v.hasClientLoader?x=!0:b.add(w.route.id))}),b.size===0)return[];let y=B0(e,l,s.unstable_trailingSlashAwareDataRequests,"data");return x&&b.size>0&&y.searchParams.set("_routes",t.filter(w=>b.has(w.route.id)).map(w=>w.route.id).join(",")),[y.pathname+y.search]},[l,s.unstable_trailingSlashAwareDataRequests,c,r,a,u,t,e,i]),m=H(()=>RL(p,a),[p,a]),g=HL(p);return Ee($r,null,h.map(b=>Ee("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),m.map(b=>Ee("link",{key:b,rel:"modulepreload",href:b,...n})),g.map(({key:b,link:x})=>Ee("link",{key:b,nonce:n.nonce,...x,crossOrigin:x.crossOrigin??n.crossOrigin})))}function QL(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var GL=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{GL&&(window.__reactRouterVersion="7.15.0")}catch{}function KL({basename:e,children:t,useTransitions:n,window:r}){let s=te();s.current==null&&(s.current=kT({window:r,v5Compat:!0}));let a=s.current,[i,l]=_({action:a.action,location:a.location}),c=U(d=>{n===!1?l(d):Sc(()=>l(d))},[n]);return Aa(()=>a.listen(c),[a,c]),Ee(NL,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,useTransitions:n})}var z0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,sa=Ue(function({onClick:t,discover:n="render",prefetch:r="none",relative:s,reloadDocument:a,replace:i,mask:l,state:c,target:d,to:u,preventScrollReset:p,viewTransition:h,defaultShouldRevalidate:m,...g},b){let{basename:x,navigator:y,useTransitions:w}=ve(yt),v=typeof u=="string"&&z0.test(u),N=I0(u,x);u=N.to;let k=oL(u,{relative:s}),C=vt(),E=null;if(l){let D=qa(l,[],C.mask?C.mask.pathname:"/",!0);x!=="/"&&(D.pathname=D.pathname==="/"?x:Ft([x,D.pathname])),E=y.createHref(D)}let[I,A,z]=jL(r,g),P=XL(u,{replace:i,mask:l,state:c,target:d,preventScrollReset:p,relative:s,viewTransition:h,defaultShouldRevalidate:m,useTransitions:w});function B(D){t&&t(D),D.defaultPrevented||P(D)}let R=!(N.isExternal||a),M=Ee("a",{...g,...z,href:(R?E:void 0)||N.absoluteURL||k,onClick:R?B:t,ref:QL(b,A),target:d,"data-discover":!v&&n==="render"?"true":void 0});return I&&!v?Ee($r,null,M,Ee(VL,{page:k})):M});sa.displayName="Link";var WL=Ue(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:s=!1,style:a,to:i,viewTransition:l,children:c,...d},u){let p=Zo(i,{relative:d.relative}),h=vt(),m=ve(Ua),{navigator:g,basename:b}=ve(yt),x=m!=null&&rR(p)&&l===!0,y=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,w=h.pathname,v=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(w=w.toLowerCase(),v=v?v.toLowerCase():null,y=y.toLowerCase()),v&&b&&(v=fn(v,b)||v);const N=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let k=w===y||!s&&w.startsWith(y)&&w.charAt(N)==="/",C=v!=null&&(v===y||!s&&v.startsWith(y)&&v.charAt(y.length)==="/"),E={isActive:k,isPending:C,isTransitioning:x},I=k?t:void 0,A;typeof r=="function"?A=r(E):A=[r,k?"active":null,C?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let z=typeof a=="function"?a(E):a;return Ee(sa,{...d,"aria-current":I,className:A,ref:u,style:z,to:i,viewTransition:l},typeof c=="function"?c(E):c)});WL.displayName="NavLink";var YL=Ue(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:s,state:a,method:i=Vs,action:l,onSubmit:c,relative:d,preventScrollReset:u,viewTransition:p,defaultShouldRevalidate:h,...m},g)=>{let{useTransitions:b}=ve(yt),x=tR(),y=nR(l,{relative:d}),w=i.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&z0.test(l);return Ee("form",{ref:g,method:w,action:y,onSubmit:r?c:k=>{if(c&&c(k),k.defaultPrevented)return;k.preventDefault();let C=k.nativeEvent.submitter,E=C?.getAttribute("formmethod")||i,I=()=>x(C||k.currentTarget,{fetcherKey:t,method:E,navigate:n,replace:s,state:a,relative:d,preventScrollReset:u,viewTransition:p,defaultShouldRevalidate:h});b&&n!==!1?Sc(()=>I()):I()},...m,"data-discover":!v&&e==="render"?"true":void 0})});YL.displayName="Form";function ZL(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function F0(e){let t=ve(Xr);return je(t,ZL(e)),t}function XL(e,{target:t,replace:n,mask:r,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c,useTransitions:d}={}){let u=rt(),p=vt(),h=Zo(e,{relative:i});return U(m=>{if(IL(m,t)){m.preventDefault();let g=n!==void 0?n:Po(p)===Po(h),b=()=>u(e,{replace:g,mask:r,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c});d?Sc(()=>b()):b()}},[p,u,h,n,r,s,t,e,a,i,l,c,d])}function Ga(e){Mt(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=te(Hl(e)),n=te(!1),r=vt(),s=H(()=>AL(r.search,n.current?null:t.current),[r.search]),a=rt(),i=U((l,c)=>{const d=Hl(typeof l=="function"?l(new URLSearchParams(s)):l);n.current=!0,a("?"+d,c)},[a,s]);return[s,i]}var JL=0,eR=()=>`__${String(++JL)}__`;function tR(){let{router:e}=F0("useSubmit"),{basename:t}=ve(yt),n=bL(),r=e.fetch,s=e.navigate;return U(async(a,i={})=>{let{action:l,method:c,encType:d,formData:u,body:p}=$L(a,t);if(i.navigate===!1){let h=i.fetcherKey||eR();await r(h,n,i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:u,body:p,formMethod:i.method||c,formEncType:i.encType||d,flushSync:i.flushSync})}else await s(i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:u,body:p,formMethod:i.method||c,formEncType:i.encType||d,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[r,s,t,n])}function nR(e,{relative:t}={}){let{basename:n}=ve(yt),r=ve(Pt);je(r,"useFormAction must be used inside a RouteContext");let[s]=r.matches.slice(-1),a={...Zo(e||".",{relative:t})},i=vt();if(e==null){a.search=i.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(u=>u==="")){l.delete("index"),c.filter(p=>p).forEach(p=>l.append("index",p));let u=l.toString();a.search=u?`?${u}`:""}}return(!e||e===".")&&s.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Ft([n,a.pathname])),Po(a)}function rR(e,{relative:t}={}){let n=ve(_0);je(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=F0("useViewTransitionState"),s=Zo(e,{relative:t});if(!n.isTransitioning)return!1;let a=fn(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=fn(n.nextLocation.pathname,r)||n.nextLocation.pathname;return ra(s.pathname,i)!=null||ra(s.pathname,a)!=null}const oR=3e4;function sR(e){const t=te(e);t.current=e,Y(()=>{let n=null;const r=()=>{if(document.visibilityState==="hidden"){n=Date.now();return}if(document.visibilityState==="visible"&&n!==null){const i=Date.now()-n;n=null,i>=oR&&t.current()}},s=()=>{t.current()},a=i=>{i.persisted&&t.current()};return document.addEventListener("visibilitychange",r),window.addEventListener("online",s),window.addEventListener("pageshow",a),()=>{document.removeEventListener("visibilitychange",r),window.removeEventListener("online",s),window.removeEventListener("pageshow",a)}},[])}let ql="disconnected";const Ul=new Set;function aR(){for(const e of Ul)e()}function iR(e){ql!==e&&(ql=e,aR())}function lR(e){return Ul.add(e),()=>{Ul.delete(e)}}function jp(){return ql}function cR(){return Pa(lR,jp,jp)}let bo=null;function qs(){if(!bo){const e=window.location.origin,t=localStorage.getItem("camstack_admin_token")??void 0;bo=fm({serverUrl:e,token:t,onConnectionChange:n=>iR(n)})}return bo}function Sr(){bo?.close(),bo=null}/**
|
|
574
|
-
* @license lucide-react v0.511.0 - ISC
|
|
575
|
-
*
|
|
576
|
-
* This source code is licensed under the ISC license.
|
|
577
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
578
|
-
*/const dR=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),uR=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),Vp=e=>{const t=uR(e);return t.charAt(0).toUpperCase()+t.slice(1)},j0=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),pR=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/**
|
|
579
|
-
* @license lucide-react v0.511.0 - ISC
|
|
580
|
-
*
|
|
581
|
-
* This source code is licensed under the ISC license.
|
|
582
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
583
|
-
*/var fR={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"};/**
|
|
584
|
-
* @license lucide-react v0.511.0 - ISC
|
|
585
|
-
*
|
|
586
|
-
* This source code is licensed under the ISC license.
|
|
587
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
588
|
-
*/const hR=Ue(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:i,...l},c)=>Ee("svg",{ref:c,...fR,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:j0("lucide",s),...!a&&!pR(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,u])=>Ee(d,u)),...Array.isArray(a)?a:[a]]));/**
|
|
589
|
-
* @license lucide-react v0.511.0 - ISC
|
|
590
|
-
*
|
|
591
|
-
* This source code is licensed under the ISC license.
|
|
592
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
593
|
-
*/const se=(e,t)=>{const n=Ue(({className:r,...s},a)=>Ee(hR,{ref:a,iconNode:t,className:j0(`lucide-${dR(Vp(e))}`,`lucide-${e}`,r),...s}));return n.displayName=Vp(e),n};/**
|
|
594
|
-
* @license lucide-react v0.511.0 - ISC
|
|
595
|
-
*
|
|
596
|
-
* This source code is licensed under the ISC license.
|
|
597
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
598
|
-
*/const mR=[["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"}]],Xo=se("activity",mR);/**
|
|
599
|
-
* @license lucide-react v0.511.0 - ISC
|
|
600
|
-
*
|
|
601
|
-
* This source code is licensed under the ISC license.
|
|
602
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
603
|
-
*/const gR=[["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"}]],V0=se("archive",gR);/**
|
|
604
|
-
* @license lucide-react v0.511.0 - ISC
|
|
605
|
-
*
|
|
606
|
-
* This source code is licensed under the ISC license.
|
|
607
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
608
|
-
*/const bR=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Qd=se("arrow-left",bR);/**
|
|
609
|
-
* @license lucide-react v0.511.0 - ISC
|
|
610
|
-
*
|
|
611
|
-
* This source code is licensed under the ISC license.
|
|
612
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
613
|
-
*/const xR=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],yR=se("arrow-right",xR);/**
|
|
614
|
-
* @license lucide-react v0.511.0 - ISC
|
|
615
|
-
*
|
|
616
|
-
* This source code is licensed under the ISC license.
|
|
617
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
618
|
-
*/const vR=[["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"}]],wR=se("battery-full",vR);/**
|
|
619
|
-
* @license lucide-react v0.511.0 - ISC
|
|
620
|
-
*
|
|
621
|
-
* This source code is licensed under the ISC license.
|
|
622
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
623
|
-
*/const NR=[["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"}]],Jo=se("bell",NR);/**
|
|
624
|
-
* @license lucide-react v0.511.0 - ISC
|
|
625
|
-
*
|
|
626
|
-
* This source code is licensed under the ISC license.
|
|
627
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
628
|
-
*/const kR=[["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"}]],SR=se("book-open",kR);/**
|
|
629
|
-
* @license lucide-react v0.511.0 - ISC
|
|
630
|
-
*
|
|
631
|
-
* This source code is licensed under the ISC license.
|
|
632
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
633
|
-
*/const CR=[["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"}]],MR=se("bot",CR);/**
|
|
634
|
-
* @license lucide-react v0.511.0 - ISC
|
|
635
|
-
*
|
|
636
|
-
* This source code is licensed under the ISC license.
|
|
637
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
638
|
-
*/const ER=[["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"}]],Ka=se("box",ER);/**
|
|
639
|
-
* @license lucide-react v0.511.0 - ISC
|
|
640
|
-
*
|
|
641
|
-
* This source code is licensed under the ISC license.
|
|
642
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
643
|
-
*/const IR=[["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"}]],Wa=se("boxes",IR);/**
|
|
644
|
-
* @license lucide-react v0.511.0 - ISC
|
|
645
|
-
*
|
|
646
|
-
* This source code is licensed under the ISC license.
|
|
647
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
648
|
-
*/const AR=[["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"}]],PR=se("calendar-clock",AR);/**
|
|
649
|
-
* @license lucide-react v0.511.0 - ISC
|
|
650
|
-
*
|
|
651
|
-
* This source code is licensed under the ISC license.
|
|
652
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
653
|
-
*/const _R=[["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"}]],H0=se("calendar",_R);/**
|
|
654
|
-
* @license lucide-react v0.511.0 - ISC
|
|
655
|
-
*
|
|
656
|
-
* This source code is licensed under the ISC license.
|
|
657
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
658
|
-
*/const $R=[["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"}]],Dr=se("camera",$R);/**
|
|
659
|
-
* @license lucide-react v0.511.0 - ISC
|
|
660
|
-
*
|
|
661
|
-
* This source code is licensed under the ISC license.
|
|
662
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
663
|
-
*/const DR=[["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"}]],q0=se("cctv",DR);/**
|
|
664
|
-
* @license lucide-react v0.511.0 - ISC
|
|
665
|
-
*
|
|
666
|
-
* This source code is licensed under the ISC license.
|
|
667
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
668
|
-
*/const TR=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],LR=se("check-check",TR);/**
|
|
669
|
-
* @license lucide-react v0.511.0 - ISC
|
|
670
|
-
*
|
|
671
|
-
* This source code is licensed under the ISC license.
|
|
672
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
673
|
-
*/const RR=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],_t=se("check",RR);/**
|
|
674
|
-
* @license lucide-react v0.511.0 - ISC
|
|
675
|
-
*
|
|
676
|
-
* This source code is licensed under the ISC license.
|
|
677
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
678
|
-
*/const OR=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],lt=se("chevron-down",OR);/**
|
|
679
|
-
* @license lucide-react v0.511.0 - ISC
|
|
680
|
-
*
|
|
681
|
-
* This source code is licensed under the ISC license.
|
|
682
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
683
|
-
*/const BR=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Gd=se("chevron-left",BR);/**
|
|
684
|
-
* @license lucide-react v0.511.0 - ISC
|
|
685
|
-
*
|
|
686
|
-
* This source code is licensed under the ISC license.
|
|
687
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
688
|
-
*/const zR=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],wt=se("chevron-right",zR);/**
|
|
689
|
-
* @license lucide-react v0.511.0 - ISC
|
|
690
|
-
*
|
|
691
|
-
* This source code is licensed under the ISC license.
|
|
692
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
693
|
-
*/const FR=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],jR=se("chevron-up",FR);/**
|
|
694
|
-
* @license lucide-react v0.511.0 - ISC
|
|
695
|
-
*
|
|
696
|
-
* This source code is licensed under the ISC license.
|
|
697
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
698
|
-
*/const VR=[["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"}]],nr=se("circle-alert",VR);/**
|
|
699
|
-
* @license lucide-react v0.511.0 - ISC
|
|
700
|
-
*
|
|
701
|
-
* This source code is licensed under the ISC license.
|
|
702
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
703
|
-
*/const HR=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],xo=se("circle-check-big",HR);/**
|
|
704
|
-
* @license lucide-react v0.511.0 - ISC
|
|
705
|
-
*
|
|
706
|
-
* This source code is licensed under the ISC license.
|
|
707
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
708
|
-
*/const qR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Kd=se("circle-check",qR);/**
|
|
709
|
-
* @license lucide-react v0.511.0 - ISC
|
|
710
|
-
*
|
|
711
|
-
* This source code is licensed under the ISC license.
|
|
712
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
713
|
-
*/const UR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],U0=se("circle-dot",UR);/**
|
|
714
|
-
* @license lucide-react v0.511.0 - ISC
|
|
715
|
-
*
|
|
716
|
-
* This source code is licensed under the ISC license.
|
|
717
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
718
|
-
*/const QR=[["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"}]],GR=se("circle-help",QR);/**
|
|
719
|
-
* @license lucide-react v0.511.0 - ISC
|
|
720
|
-
*
|
|
721
|
-
* This source code is licensed under the ISC license.
|
|
722
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
723
|
-
*/const KR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],WR=se("clock",KR);/**
|
|
724
|
-
* @license lucide-react v0.511.0 - ISC
|
|
725
|
-
*
|
|
726
|
-
* This source code is licensed under the ISC license.
|
|
727
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
728
|
-
*/const YR=[["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"}]],aa=se("copy",YR);/**
|
|
729
|
-
* @license lucide-react v0.511.0 - ISC
|
|
730
|
-
*
|
|
731
|
-
* This source code is licensed under the ISC license.
|
|
732
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
733
|
-
*/const ZR=[["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"}]],bt=se("cpu",ZR);/**
|
|
734
|
-
* @license lucide-react v0.511.0 - ISC
|
|
735
|
-
*
|
|
736
|
-
* This source code is licensed under the ISC license.
|
|
737
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
738
|
-
*/const XR=[["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"}]],JR=se("crosshair",XR);/**
|
|
739
|
-
* @license lucide-react v0.511.0 - ISC
|
|
740
|
-
*
|
|
741
|
-
* This source code is licensed under the ISC license.
|
|
742
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
743
|
-
*/const e6=[["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"}]],Q0=se("database",e6);/**
|
|
744
|
-
* @license lucide-react v0.511.0 - ISC
|
|
745
|
-
*
|
|
746
|
-
* This source code is licensed under the ISC license.
|
|
747
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
748
|
-
*/const t6=[["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"}]],Xt=se("download",t6);/**
|
|
749
|
-
* @license lucide-react v0.511.0 - ISC
|
|
750
|
-
*
|
|
751
|
-
* This source code is licensed under the ISC license.
|
|
752
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
753
|
-
*/const n6=[["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"}]],r6=se("ellipsis-vertical",n6);/**
|
|
754
|
-
* @license lucide-react v0.511.0 - ISC
|
|
755
|
-
*
|
|
756
|
-
* This source code is licensed under the ISC license.
|
|
757
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
758
|
-
*/const o6=[["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"}]],Wd=se("external-link",o6);/**
|
|
759
|
-
* @license lucide-react v0.511.0 - ISC
|
|
760
|
-
*
|
|
761
|
-
* This source code is licensed under the ISC license.
|
|
762
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
763
|
-
*/const s6=[["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"}]],G0=se("eye-off",s6);/**
|
|
764
|
-
* @license lucide-react v0.511.0 - ISC
|
|
765
|
-
*
|
|
766
|
-
* This source code is licensed under the ISC license.
|
|
767
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
768
|
-
*/const a6=[["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"}]],es=se("eye",a6);/**
|
|
769
|
-
* @license lucide-react v0.511.0 - ISC
|
|
770
|
-
*
|
|
771
|
-
* This source code is licensed under the ISC license.
|
|
772
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
773
|
-
*/const i6=[["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"}]],yo=se("film",i6);/**
|
|
774
|
-
* @license lucide-react v0.511.0 - ISC
|
|
775
|
-
*
|
|
776
|
-
* This source code is licensed under the ISC license.
|
|
777
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
778
|
-
*/const l6=[["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"}]],c6=se("flame",l6);/**
|
|
779
|
-
* @license lucide-react v0.511.0 - ISC
|
|
780
|
-
*
|
|
781
|
-
* This source code is licensed under the ISC license.
|
|
782
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
783
|
-
*/const d6=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],K0=se("gauge",d6);/**
|
|
784
|
-
* @license lucide-react v0.511.0 - ISC
|
|
785
|
-
*
|
|
786
|
-
* This source code is licensed under the ISC license.
|
|
787
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
788
|
-
*/const u6=[["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"}]],Ql=se("ghost",u6);/**
|
|
789
|
-
* @license lucide-react v0.511.0 - ISC
|
|
790
|
-
*
|
|
791
|
-
* This source code is licensed under the ISC license.
|
|
792
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
793
|
-
*/const p6=[["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"}]],f6=se("git-branch",p6);/**
|
|
794
|
-
* @license lucide-react v0.511.0 - ISC
|
|
795
|
-
*
|
|
796
|
-
* This source code is licensed under the ISC license.
|
|
797
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
798
|
-
*/const h6=[["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"}]],_n=se("globe",h6);/**
|
|
799
|
-
* @license lucide-react v0.511.0 - ISC
|
|
800
|
-
*
|
|
801
|
-
* This source code is licensed under the ISC license.
|
|
802
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
803
|
-
*/const m6=[["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"}]],ia=se("hard-drive",m6);/**
|
|
804
|
-
* @license lucide-react v0.511.0 - ISC
|
|
805
|
-
*
|
|
806
|
-
* This source code is licensed under the ISC license.
|
|
807
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
808
|
-
*/const g6=[["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"}]],b6=se("house",g6);/**
|
|
809
|
-
* @license lucide-react v0.511.0 - ISC
|
|
810
|
-
*
|
|
811
|
-
* This source code is licensed under the ISC license.
|
|
812
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
813
|
-
*/const x6=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],rr=se("info",x6);/**
|
|
814
|
-
* @license lucide-react v0.511.0 - ISC
|
|
815
|
-
*
|
|
816
|
-
* This source code is licensed under the ISC license.
|
|
817
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
818
|
-
*/const y6=[["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"}]],W0=se("key-round",y6);/**
|
|
819
|
-
* @license lucide-react v0.511.0 - ISC
|
|
820
|
-
*
|
|
821
|
-
* This source code is licensed under the ISC license.
|
|
822
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
823
|
-
*/const v6=[["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"}]],w6=se("key-square",v6);/**
|
|
824
|
-
* @license lucide-react v0.511.0 - ISC
|
|
825
|
-
*
|
|
826
|
-
* This source code is licensed under the ISC license.
|
|
827
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
828
|
-
*/const N6=[["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"}]],k6=se("key",N6);/**
|
|
829
|
-
* @license lucide-react v0.511.0 - ISC
|
|
830
|
-
*
|
|
831
|
-
* This source code is licensed under the ISC license.
|
|
832
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
833
|
-
*/const S6=[["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"}]],C6=se("layers",S6);/**
|
|
834
|
-
* @license lucide-react v0.511.0 - ISC
|
|
835
|
-
*
|
|
836
|
-
* This source code is licensed under the ISC license.
|
|
837
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
838
|
-
*/const M6=[["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"}]],Y0=se("layout-dashboard",M6);/**
|
|
839
|
-
* @license lucide-react v0.511.0 - ISC
|
|
840
|
-
*
|
|
841
|
-
* This source code is licensed under the ISC license.
|
|
842
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
843
|
-
*/const E6=[["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"}]],I6=se("lightbulb",E6);/**
|
|
844
|
-
* @license lucide-react v0.511.0 - ISC
|
|
845
|
-
*
|
|
846
|
-
* This source code is licensed under the ISC license.
|
|
847
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
848
|
-
*/const A6=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Se=se("loader-circle",A6);/**
|
|
849
|
-
* @license lucide-react v0.511.0 - ISC
|
|
850
|
-
*
|
|
851
|
-
* This source code is licensed under the ISC license.
|
|
852
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
853
|
-
*/const P6=[["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"}]],Yd=se("lock",P6);/**
|
|
854
|
-
* @license lucide-react v0.511.0 - ISC
|
|
855
|
-
*
|
|
856
|
-
* This source code is licensed under the ISC license.
|
|
857
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
858
|
-
*/const _6=[["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"}]],$6=se("log-in",_6);/**
|
|
859
|
-
* @license lucide-react v0.511.0 - ISC
|
|
860
|
-
*
|
|
861
|
-
* This source code is licensed under the ISC license.
|
|
862
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
863
|
-
*/const D6=[["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"}]],Zd=se("log-out",D6);/**
|
|
864
|
-
* @license lucide-react v0.511.0 - ISC
|
|
865
|
-
*
|
|
866
|
-
* This source code is licensed under the ISC license.
|
|
867
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
868
|
-
*/const T6=[["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"}]],L6=se("mail",T6);/**
|
|
869
|
-
* @license lucide-react v0.511.0 - ISC
|
|
870
|
-
*
|
|
871
|
-
* This source code is licensed under the ISC license.
|
|
872
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
873
|
-
*/const R6=[["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"}]],O6=se("map-pin",R6);/**
|
|
874
|
-
* @license lucide-react v0.511.0 - ISC
|
|
875
|
-
*
|
|
876
|
-
* This source code is licensed under the ISC license.
|
|
877
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
878
|
-
*/const B6=[["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"}]],Xd=se("memory-stick",B6);/**
|
|
879
|
-
* @license lucide-react v0.511.0 - ISC
|
|
880
|
-
*
|
|
881
|
-
* This source code is licensed under the ISC license.
|
|
882
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
883
|
-
*/const z6=[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]],F6=se("menu",z6);/**
|
|
884
|
-
* @license lucide-react v0.511.0 - ISC
|
|
885
|
-
*
|
|
886
|
-
* This source code is licensed under the ISC license.
|
|
887
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
888
|
-
*/const j6=[["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"}]],Gl=se("mic",j6);/**
|
|
889
|
-
* @license lucide-react v0.511.0 - ISC
|
|
890
|
-
*
|
|
891
|
-
* This source code is licensed under the ISC license.
|
|
892
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
893
|
-
*/const V6=[["path",{d:"M5 12h14",key:"1ays0h"}]],H6=se("minus",V6);/**
|
|
894
|
-
* @license lucide-react v0.511.0 - ISC
|
|
895
|
-
*
|
|
896
|
-
* This source code is licensed under the ISC license.
|
|
897
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
898
|
-
*/const q6=[["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"}]],U6=se("monitor",q6);/**
|
|
899
|
-
* @license lucide-react v0.511.0 - ISC
|
|
900
|
-
*
|
|
901
|
-
* This source code is licensed under the ISC license.
|
|
902
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
903
|
-
*/const Q6=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],Z0=se("moon",Q6);/**
|
|
904
|
-
* @license lucide-react v0.511.0 - ISC
|
|
905
|
-
*
|
|
906
|
-
* This source code is licensed under the ISC license.
|
|
907
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
908
|
-
*/const G6=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],K6=se("move",G6);/**
|
|
909
|
-
* @license lucide-react v0.511.0 - ISC
|
|
910
|
-
*
|
|
911
|
-
* This source code is licensed under the ISC license.
|
|
912
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
913
|
-
*/const W6=[["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"}]],$n=se("network",W6);/**
|
|
914
|
-
* @license lucide-react v0.511.0 - ISC
|
|
915
|
-
*
|
|
916
|
-
* This source code is licensed under the ISC license.
|
|
917
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
918
|
-
*/const Y6=[["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"}]],Z6=se("octagon-alert",Y6);/**
|
|
919
|
-
* @license lucide-react v0.511.0 - ISC
|
|
920
|
-
*
|
|
921
|
-
* This source code is licensed under the ISC license.
|
|
922
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
923
|
-
*/const X6=[["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"}]],X0=se("package",X6);/**
|
|
924
|
-
* @license lucide-react v0.511.0 - ISC
|
|
925
|
-
*
|
|
926
|
-
* This source code is licensed under the ISC license.
|
|
927
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
928
|
-
*/const J6=[["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"}]],eo=se("pencil",J6);/**
|
|
929
|
-
* @license lucide-react v0.511.0 - ISC
|
|
930
|
-
*
|
|
931
|
-
* This source code is licensed under the ISC license.
|
|
932
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
933
|
-
*/const eO=[["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"}]],J0=se("pin",eO);/**
|
|
934
|
-
* @license lucide-react v0.511.0 - ISC
|
|
935
|
-
*
|
|
936
|
-
* This source code is licensed under the ISC license.
|
|
937
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
938
|
-
*/const tO=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],Ya=se("play",tO);/**
|
|
939
|
-
* @license lucide-react v0.511.0 - ISC
|
|
940
|
-
*
|
|
941
|
-
* This source code is licensed under the ISC license.
|
|
942
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
943
|
-
*/const nO=[["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"}]],_o=se("plug",nO);/**
|
|
944
|
-
* @license lucide-react v0.511.0 - ISC
|
|
945
|
-
*
|
|
946
|
-
* This source code is licensed under the ISC license.
|
|
947
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
948
|
-
*/const rO=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Et=se("plus",rO);/**
|
|
949
|
-
* @license lucide-react v0.511.0 - ISC
|
|
950
|
-
*
|
|
951
|
-
* This source code is licensed under the ISC license.
|
|
952
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
953
|
-
*/const oO=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],ev=se("power",oO);/**
|
|
954
|
-
* @license lucide-react v0.511.0 - ISC
|
|
955
|
-
*
|
|
956
|
-
* This source code is licensed under the ISC license.
|
|
957
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
958
|
-
*/const sO=[["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"}]],la=se("puzzle",sO);/**
|
|
959
|
-
* @license lucide-react v0.511.0 - ISC
|
|
960
|
-
*
|
|
961
|
-
* This source code is licensed under the ISC license.
|
|
962
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
963
|
-
*/const aO=[["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"}]],iO=se("radar",aO);/**
|
|
964
|
-
* @license lucide-react v0.511.0 - ISC
|
|
965
|
-
*
|
|
966
|
-
* This source code is licensed under the ISC license.
|
|
967
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
968
|
-
*/const lO=[["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"}]],Za=se("radio",lO);/**
|
|
969
|
-
* @license lucide-react v0.511.0 - ISC
|
|
970
|
-
*
|
|
971
|
-
* This source code is licensed under the ISC license.
|
|
972
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
973
|
-
*/const cO=[["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"}]],ct=se("refresh-cw",cO);/**
|
|
974
|
-
* @license lucide-react v0.511.0 - ISC
|
|
975
|
-
*
|
|
976
|
-
* This source code is licensed under the ISC license.
|
|
977
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
978
|
-
*/const dO=[["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"}]],tv=se("rotate-ccw",dO);/**
|
|
979
|
-
* @license lucide-react v0.511.0 - ISC
|
|
980
|
-
*
|
|
981
|
-
* This source code is licensed under the ISC license.
|
|
982
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
983
|
-
*/const uO=[["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"}]],kt=se("rotate-cw",uO);/**
|
|
984
|
-
* @license lucide-react v0.511.0 - ISC
|
|
985
|
-
*
|
|
986
|
-
* This source code is licensed under the ISC license.
|
|
987
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
988
|
-
*/const pO=[["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"}]],fO=se("save",pO);/**
|
|
989
|
-
* @license lucide-react v0.511.0 - ISC
|
|
990
|
-
*
|
|
991
|
-
* This source code is licensed under the ISC license.
|
|
992
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
993
|
-
*/const hO=[["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"}]],at=se("scroll-text",hO);/**
|
|
994
|
-
* @license lucide-react v0.511.0 - ISC
|
|
995
|
-
*
|
|
996
|
-
* This source code is licensed under the ISC license.
|
|
997
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
998
|
-
*/const mO=[["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"}]],gO=se("search-x",mO);/**
|
|
999
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1000
|
-
*
|
|
1001
|
-
* This source code is licensed under the ISC license.
|
|
1002
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1003
|
-
*/const bO=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],nv=se("search",bO);/**
|
|
1004
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1005
|
-
*
|
|
1006
|
-
* This source code is licensed under the ISC license.
|
|
1007
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1008
|
-
*/const xO=[["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"}]],hn=se("server",xO);/**
|
|
1009
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1010
|
-
*
|
|
1011
|
-
* This source code is licensed under the ISC license.
|
|
1012
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1013
|
-
*/const yO=[["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"}]],Jt=se("settings",yO);/**
|
|
1014
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1015
|
-
*
|
|
1016
|
-
* This source code is licensed under the ISC license.
|
|
1017
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1018
|
-
*/const vO=[["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"}]],wO=se("share-2",vO);/**
|
|
1019
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1020
|
-
*
|
|
1021
|
-
* This source code is licensed under the ISC license.
|
|
1022
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1023
|
-
*/const NO=[["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"}]],mn=se("shield-check",NO);/**
|
|
1024
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1025
|
-
*
|
|
1026
|
-
* This source code is licensed under the ISC license.
|
|
1027
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1028
|
-
*/const kO=[["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"}]],Hp=se("shield-off",kO);/**
|
|
1029
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1030
|
-
*
|
|
1031
|
-
* This source code is licensed under the ISC license.
|
|
1032
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1033
|
-
*/const SO=[["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",SO);/**
|
|
1034
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1035
|
-
*
|
|
1036
|
-
* This source code is licensed under the ISC license.
|
|
1037
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1038
|
-
*/const MO=[["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"}]],EO=se("shield",MO);/**
|
|
1039
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1040
|
-
*
|
|
1041
|
-
* This source code is licensed under the ISC license.
|
|
1042
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1043
|
-
*/const IO=[["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"}]],vs=se("skull",IO);/**
|
|
1044
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1045
|
-
*
|
|
1046
|
-
* This source code is licensed under the ISC license.
|
|
1047
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1048
|
-
*/const AO=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],An=se("smartphone",AO);/**
|
|
1049
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1050
|
-
*
|
|
1051
|
-
* This source code is licensed under the ISC license.
|
|
1052
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1053
|
-
*/const PO=[["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"}]],_O=se("sparkles",PO);/**
|
|
1054
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1055
|
-
*
|
|
1056
|
-
* This source code is licensed under the ISC license.
|
|
1057
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1058
|
-
*/const $O=[["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"}]],rv=se("square-check-big",$O);/**
|
|
1059
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1060
|
-
*
|
|
1061
|
-
* This source code is licensed under the ISC license.
|
|
1062
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1063
|
-
*/const DO=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ts=se("square",DO);/**
|
|
1064
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1065
|
-
*
|
|
1066
|
-
* This source code is licensed under the ISC license.
|
|
1067
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1068
|
-
*/const TO=[["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"}]],zi=se("star",TO);/**
|
|
1069
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1070
|
-
*
|
|
1071
|
-
* This source code is licensed under the ISC license.
|
|
1072
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1073
|
-
*/const LO=[["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"}]],RO=se("sun",LO);/**
|
|
1074
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1075
|
-
*
|
|
1076
|
-
* This source code is licensed under the ISC license.
|
|
1077
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1078
|
-
*/const OO=[["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"}]],BO=se("table-2",OO);/**
|
|
1079
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1080
|
-
*
|
|
1081
|
-
* This source code is licensed under the ISC license.
|
|
1082
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1083
|
-
*/const zO=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],ov=se("terminal",zO);/**
|
|
1084
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1085
|
-
*
|
|
1086
|
-
* This source code is licensed under the ISC license.
|
|
1087
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1088
|
-
*/const FO=[["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"}]],Ze=se("trash-2",FO);/**
|
|
1089
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1090
|
-
*
|
|
1091
|
-
* This source code is licensed under the ISC license.
|
|
1092
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1093
|
-
*/const jO=[["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"}]],it=se("triangle-alert",jO);/**
|
|
1094
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1095
|
-
*
|
|
1096
|
-
* This source code is licensed under the ISC license.
|
|
1097
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1098
|
-
*/const VO=[["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"}]],Xa=se("upload",VO);/**
|
|
1099
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1100
|
-
*
|
|
1101
|
-
* This source code is licensed under the ISC license.
|
|
1102
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1103
|
-
*/const HO=[["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"}]],qO=se("users",HO);/**
|
|
1104
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1105
|
-
*
|
|
1106
|
-
* This source code is licensed under the ISC license.
|
|
1107
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1108
|
-
*/const UO=[["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"}]],sv=se("video",UO);/**
|
|
1109
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1110
|
-
*
|
|
1111
|
-
* This source code is licensed under the ISC license.
|
|
1112
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1113
|
-
*/const QO=[["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"}]],av=se("wifi-off",QO);/**
|
|
1114
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1115
|
-
*
|
|
1116
|
-
* This source code is licensed under the ISC license.
|
|
1117
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1118
|
-
*/const GO=[["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"}]],or=se("wifi",GO);/**
|
|
1119
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1120
|
-
*
|
|
1121
|
-
* This source code is licensed under the ISC license.
|
|
1122
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1123
|
-
*/const KO=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Fe=se("x",KO);/**
|
|
1124
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1125
|
-
*
|
|
1126
|
-
* This source code is licensed under the ISC license.
|
|
1127
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1128
|
-
*/const WO=[["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"}]],YO=se("wrench",WO);/**
|
|
1129
|
-
* @license lucide-react v0.511.0 - ISC
|
|
1130
|
-
*
|
|
1131
|
-
* This source code is licensed under the ISC license.
|
|
1132
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
1133
|
-
*/const ZO=[["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"}]],Jd=se("zap",ZO);function XO(){const e=Te(),t=ke(),[n,r]=_(()=>e.isConnected()?"connected":"disconnected"),s=te(!1),[a,i]=_(0),[l,c]=_([]);Y(()=>e.subscribeConnectionEvents(h=>{r(m=>(m!=="connected"&&h==="connected"&&s.current&&i(g=>g+1),h!=="connected"&&(s.current=!0),h))}),[e]),Y(()=>{a!==0&&t.invalidateQueries({queryKey:[["addons","getLastRestart"]]})},[a,t]);const{data:d}=mb(void 0,{enabled:n==="connected"&&a>0,staleTime:0,refetchOnMount:!1,refetchOnWindowFocus:!1}),u=te(null);return Y(()=>{if(d==null||d.requestedAt===u.current)return;u.current=d.requestedAt;const p=t8(d);c(m=>[...m,p]);const h=window.setTimeout(()=>{c(m=>m.filter(g=>g.id!==p.id))},6e3);return()=>window.clearTimeout(h)},[d]),f(me,{children:[n!=="connected"&&o(JO,{state:n}),l.length>0&&o(e8,{toasts:l})]})}function JO({state:e}){return o("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/70 backdrop-blur-sm",children:f("div",{className:"flex flex-col items-center gap-3 text-foreground",children:[o(Se,{className:"w-10 h-10 animate-spin text-primary"}),o("div",{className:"text-sm font-medium",children:e==="connecting"?"Reconnecting…":"Server unreachable"}),o("div",{className:"text-[11px] text-foreground-subtle max-w-xs text-center",children:e==="connecting"?"Waiting for the hub to finish restarting. This usually takes 10–15 seconds.":"Lost connection to the hub. The reconnect will resume automatically once the server is back up."})]})})}function e8({toasts:e}){return o("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=>f("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:[o(Kd,{className:"w-4 h-4 shrink-0 mt-0.5 text-green-400"}),f("div",{children:[o("div",{className:"text-[11px] font-semibold text-foreground",children:t.title}),o("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:t.message})]})]},t.id))})}function t8(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 n8(e){const t=vn();return t===null?o("div",{className:"rounded-md border border-warning/40 bg-warning/10 p-3 text-xs text-warning",children:"zone-editor: no DeviceContext — declare this field inside a top-tab section rendered from a device-detail page."}):o(ft,{widgetId:"pipeline-orchestrator/zone-editor",host:"device-tab",deviceId:t})}function r8({deviceId:e}){return f("div",{className:zm,children:[f("div",{className:`grid ${Fm}`,style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 340px), 1fr))"},children:[o(ft,{widgetId:"pipeline-analytics/live-occupancy-panel",host:"device-tab",deviceId:e}),o(ft,{widgetId:"pipeline-analytics/audio-metrics-panel",host:"device-tab",deviceId:e})]}),o(ft,{widgetId:"pipeline-analytics/audio-history-chart",host:"device-tab",deviceId:e}),o(ft,{widgetId:"pipeline-analytics/occupancy-history-chart",host:"device-tab",deviceId:e}),o(ft,{widgetId:"pipeline-analytics/motion-history-chart",host:"device-tab",deviceId:e}),o(ft,{widgetId:"pipeline-analytics/detection-history-chart",host:"device-tab",deviceId:e})]})}function o8(e){const t=vn();return t===null?o("div",{className:"rounded-md border border-warning/40 bg-warning/10 p-3 text-xs text-warning",children:"live-stats: no DeviceContext — declare this field inside a top-tab section rendered from a device-detail page."}):o(r8,{deviceId:t})}function s8(e){const t=Te();return Ln({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"),r=Reflect.get(t.trpcClient,e.capName);if(!n(r))throw new Error(`useFieldResolver: no cap namespace '${e.capName}' on the tRPC client`);const s=Reflect.get(r,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 a8(e){return typeof e=="string"&&e.length>0&&e!=="undefined"&&e!=="null"}function i8(e={}){const t=ke(),n=Yr(void 0,{staleTime:1e4,enabled:e.enabled??!0}),r=H(()=>(n.data??[]).filter(i=>a8(i.nodeId)),[n.data]),s=U(()=>{t.invalidateQueries({queryKey:["pipelineOrchestrator","listAgentSettings"]})},[t]);return{agents:r,isLoading:n.isLoading,isError:n.isError,error:n.error,refetch:()=>{n.refetch()},invalidate:s}}function l8({field:e,disabled:t}){const n=ke(),r=e.deviceId,s=s8(e.catalogResolver),a=hd({agentNodeId:e.nodeId}),i=gd({deviceId:r}),c=iy({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),d=s.data,u=a.data??null,p=i.data??null,h=H(()=>d?d8(d,u,p):[],[d,u,p]),m=H(()=>{if(!u)return{};const g={};for(const[b,x]of Object.entries(u.addonDefaults))g[b]=x.enabled;return g},[u]);return s.error?f("div",{className:"text-xs text-red-400",children:["Failed to load pipeline catalog for ",o("code",{children:e.nodeId}),": ",String(s.error.message??s.error)]}):s.isLoading||!d||a.isLoading?f("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading pipeline for ",e.nodeId,"…"]}):f("div",{className:"col-span-full space-y-4",children:[f("div",{className:"flex items-center gap-2 text-[11px] text-foreground-subtle",children:["Agent: ",o("span",{className:"text-foreground",children:e.nodeId}),f("span",{className:"ml-2",children:["Engine: ",o("span",{className:"text-foreground font-mono",children:`${d.selectedEngine.runtime}/${d.selectedEngine.backend}`})]}),f("span",{className:"ml-auto text-[10px]",children:["Model + settings edited on Pipeline → ",e.nodeId,"."]})]}),o(Jc,{schema:d,steps:h,onChange:()=>{},templates:[],selectedTemplateId:null,onSelectTemplate:()=>{},onSaveTemplate:()=>{},onUpdateTemplate:()=>{},onDeleteTemplate:()=>{},readOnly:t===!0,hideTemplates:!0,toggleMode:"threeState",hideModelAndSettings:!0,overrides:p?.stepToggles??{},onOverrideChange:(g,b)=>c.mutate({deviceId:r,addonId:g,enabled:b}),inheritedEnabledByAddon:m}),o(c8,{deviceId:r,currentAgentNodeId:e.nodeId,catalog:d,pipelineByAgent:p?.pipelineByAgent??{},disabled:t===!0})]})}function c8({deviceId:e,currentAgentNodeId:t,catalog:n,pipelineByAgent:r,disabled:s}){const a=ke(),[i,l]=_(!1),[c,d]=_(t),{agents:u}=i8({enabled:i}),p=dy({deviceId:e,agentNodeId:c},{enabled:i}),m=cy({onSuccess:()=>{a.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),a.invalidateQueries({queryKey:[["pipelineOrchestrator","resolvePipeline"]]})}}),g=r[c]??null,b=u,x=H(()=>g?u8(g.steps,n):[],[g,n]),y=w=>{const v=g?.audio??null;m.mutate({deviceId:e,agentNodeId:c,pipeline:{steps:p8(w),audio:v?{modelId:v.modelId,enabled:v.enabled}:null}})};return f("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("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?o(lt,{className:"h-3 w-3"}):o(wt,{className:"h-3 w-3"}),o("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:"Advanced — custom pipeline per agent"}),o("span",{className:"ml-auto text-[10px] text-foreground-subtle",children:Object.keys(r).length>0?`${Object.keys(r).length} override(s) active`:"None configured"})]}),i&&f("div",{className:"border-t border-border px-4 py-3 space-y-3",children:[f("div",{className:"flex items-center gap-2 text-xs",children:[o("span",{className:"text-foreground-subtle",children:"Agent:"}),f("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"&&f("option",{value:t,children:[t," (current)"]}),b.filter(w=>w.nodeId!==t).map(w=>o("option",{value:w.nodeId,children:w.nodeId},w.nodeId))]}),r[c]&&f("button",{type:"button",onClick:()=>{window.confirm(`Remove custom pipeline override for ${c}? The camera will revert to the agent default + step toggles.`)&&m.mutate({deviceId:e,agentNodeId:c,pipeline:null})},disabled:s||m.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:[o(Ze,{className:"h-3 w-3"}),"Remove override"]})]}),g?o(Jc,{schema:n,steps:x,onChange:y,templates:[],selectedTemplateId:null,onSelectTemplate:()=>{},onSaveTemplate:()=>{},onUpdateTemplate:()=>{},onDeleteTemplate:()=>{},readOnly:s,hideTemplates:!0}):f("div",{className:"text-xs text-foreground-subtle space-y-2",children:[f("p",{children:["No custom pipeline for ",o("code",{children:c}),". The camera uses the agent's default + step toggles."]}),o("button",{type:"button",onClick:()=>{const w=p.data;w&&m.mutate({deviceId:e,agentNodeId:c,pipeline:{steps:w.steps,audio:w.audio?{modelId:w.audio.modelId,enabled:w.audio.enabled}:null}})},disabled:s||m.isPending||!p.data,className:"inline-flex items-center gap-1 px-3 py-1.5 text-xs font-medium rounded bg-primary/15 text-primary hover:bg-primary/25 disabled:opacity-50",children:"Create wholesale override from current default"})]})]})]})}function d8(e,t,n){const r=d=>{for(const u of e.slots)for(const p of u.addons)if(p.id===d)return p;return null},s=d=>{const u=t?.addonDefaults[d.id],p=u?.enabled??d.enabledByDefault??!0,h=n?.stepToggles?.[d.id],m=h!==void 0?h:p;return{addonId:d.id,addonName:d.name,slot:d.slot,inputClasses:[...d.inputClasses],outputClasses:[...d.outputClasses],enabled:m,modelId:u?.modelId??d.defaultModelId,children:[],...u?.settings&&Object.keys(u.settings).length>0?{settings:u.settings}:{}}},a=new Map;for(const d of e.slots)for(const u of d.addons)a.set(u.id,s(u));const i=[],l=new Set;for(const[d,u]of a){const p=r(d);p&&p.inputClasses.length===0&&(i.push(u),l.add(d))}let c=!0;for(;c;){c=!1;for(const[d,u]of a){if(l.has(d))continue;const p=r(d);if(p)for(const[h,m]of a){if(h===d)continue;const g=r(h);if(g&&l.has(h)&&g.outputClasses.some(b=>p.inputClasses.includes(b))){m.children.push(u),l.add(d),c=!0;break}}}}return i}function u8(e,t){const n=new Map;for(const s of t.slots)for(const a of s.addons)n.set(a.id,a);const r=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(r),...s.settings?{settings:{...s.settings}}:{}}};return[...e].map(r)}function p8(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 f8({tabs:e,active:t,onChange:n}){return o("div",{className:"flex rounded-lg border border-border bg-surface p-0.5 gap-0.5",children:e.map(r=>o("button",{type:"button",onClick:()=>n(r.id),className:["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",t===r.id?"bg-primary/12 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"].join(" "),children:r.label},r.id))})}function h8(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 r=Math.min(...n),s=Math.max(...n);return r===s?`${r} MB`:`${r}-${s} MB`}function m8(e){return`${e.inputSize.width}x${e.inputSize.height}`}function g8(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function b8({entry:e,selected:t,onSelect:n,disabled:r}){const s=h8(e),a=m8(e),i=g8(e);return f("button",{type:"button",onClick:n,disabled:r,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",r?"opacity-50 cursor-not-allowed":"cursor-pointer"].join(" "),children:[o("div",{className:"flex items-start justify-between gap-2",children:f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-xs font-semibold text-foreground truncate",children:e.name}),t&&o(_t,{className:"h-3.5 w-3.5 text-primary shrink-0"})]}),o("p",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-2",children:e.description})]})}),f("div",{className:"flex items-center gap-3 mt-2 flex-wrap",children:[f("span",{className:"inline-flex items-center gap-1 text-[10px] text-foreground-subtle",children:[o(bt,{className:"h-3 w-3"}),a]}),s&&o("span",{className:"text-[10px] text-foreground-subtle",children:s}),i.length>0&&o("div",{className:"flex gap-1",children:i.map(l=>o("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&&f("span",{className:"text-[10px] text-foreground-subtle",children:[e.labels.length," label",e.labels.length!==1?"s":""]})]})]})}function x8({field:e,value:t,onChange:n,disabled:r}){const s=e.catalog??[],a=s.length>0,i=e.allowCustomPath!==!1||e.allowCustom===!0,l=[...a?[{id:"catalog",label:`Models (${s.length})`}]:[],...i?[{id:"custom",label:"Custom Path"}]:[]],[c,d]=_(a?"catalog":"custom"),u=t==null?"":String(t);return f("div",{className:"space-y-3",children:[l.length>1&&o(f8,{tabs:l,active:c,onChange:d}),c==="catalog"&&a&&o("div",{className:"space-y-1.5 max-h-[320px] overflow-y-auto pr-1",children:s.map(p=>o(b8,{entry:p,selected:u===p.id,onSelect:()=>n(p.id),disabled:r||e.disabled},p.id))}),c==="catalog"&&!a&&f("div",{className:"rounded-md border border-info/30 bg-info/5 px-3 py-2 flex items-start gap-2",children:[o(rr,{className:"h-3.5 w-3.5 text-info shrink-0 mt-0.5"}),o("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&&f("div",{className:"space-y-2",children:[o("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:u,disabled:r||e.disabled,onChange:p=>n(p.target.value)}),e.acceptFormats&&e.acceptFormats.length>0&&f("p",{className:"text-[10px] text-foreground-subtle",children:["Accepted formats: ",e.acceptFormats.join(", ")]})]}),(e.compatibilityNote||e.conversionGuideUrl)&&f("div",{className:"flex items-start justify-between gap-3 pt-1",children:[e.compatibilityNote&&f("p",{className:"flex items-start gap-1 text-[10px] text-foreground-subtle",children:[o(rr,{className:"h-3 w-3 mt-0.5 shrink-0"}),e.compatibilityNote]}),e.conversionGuideUrl&&f("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",o(Wd,{className:"h-3 w-3"})]})]})]})}function iv(e){const t=Te();return N0(t.trpcClient,e)}function y8({deviceId:e,deviceName:t,hasPTZ:n=!1,className:r}){const s=Te(),a=typeof window<"u"?window.location.origin:"",i=Number.isFinite(e),[l,c]=_(!1),d=i&&n&&l,u=At(s.trpcClient,i?e:null),p=te(!1),{data:h,isLoading:m,isFetching:g,refetch:b}=Ln({queryKey:["device",e,"snapshot.getSnapshot"],queryFn:()=>{const A=p.current;return p.current=!1,u?.snapshot?.getSnapshot({force:A})??null},enabled:!!u&&i,staleTime:5e3,retry:!1}),x=()=>{p.current=!0,b()},{streams:y,pipelineMetrics:w,createSession:v,sendAnswer:N,closeSession:k}=Td(s.trpcClient,i?e:null),C=iv(i?e:null),E=Ld(s.trpcClient,i?e:0,{enabled:d}),I=h?`data:${h.contentType};base64,${h.base64}`:null;return o(Cd,{serverUrl:a,createSession:v,sendAnswer:N,closeSession:k,streams:y,pipelineMetrics:w,deviceName:t,phase:C.phase,detections:C,defaultShowDetections:!1,defaultShowMotion:!1,autoPlay:!1,showPlayStop:!0,snapshotSrc:I,snapshotLoading:m||g,onRefreshSnapshot:x,ptzAvailable:i&&n,ptzShown:d,onPtzToggle:()=>c(A=>!A),ptzOverlay:d?o(Pd,{controls:E}):void 0,className:r})}function v8(){const e=vn(),t=td();if(e===null)return null;const n=typeof t?.name=="string"?t.name:"",s=(t?.features??[]).includes(Wn.PanTiltZoom);return o(y8,{deviceId:e,deviceName:n,hasPTZ:s})}function St(e,t){const n=Te(),r=ke(),[s,a]=_(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 u=JSON.parse(l),h=u.length===1&&Array.isArray(u[0])?u:[u];r.invalidateQueries({queryKey:h})};d();for(const u of i.split("|"))if(u)try{c.push(n.subscribeEvent(u,d))}catch{}return()=>{for(const u of c)u()}},[n,r,i,l,s])}function ws({icon:e,label:t,value:n,subtext:r,color:s}){return f("div",{className:"rounded-lg border border-border bg-surface p-2 sm:p-2.5 min-w-0",children:[f("div",{className:"flex items-center gap-1.5 mb-0.5 min-w-0",children:[o(e,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),o("span",{className:`${Js} uppercase tracking-wider whitespace-nowrap overflow-hidden text-ellipsis min-w-0`,children:t})]}),o("p",{className:`${s?`${Ml.replace("text-foreground","")} ${s}`:Ml} whitespace-nowrap overflow-hidden text-ellipsis`,children:n}),r&&o("p",{className:`${Js} mt-0.5 truncate`,children:r})]})}function Ns({label:e,value:t,warning:n}){return f("div",{className:"min-w-0",children:[o("p",{className:`${Js} truncate`,children:e}),o("p",{className:`text-[11px] font-medium truncate ${n?"text-warning":"text-foreground"}`,children:t})]})}function cn({label:e,value:t}){return f("div",{className:`${jm} flex items-start gap-2 sm:gap-3`,children:[o("span",{className:"w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle",children:e}),o("div",{className:"flex-1 min-w-0 text-[11px] text-foreground",children:t})]})}function w8(){const e=vn();St(["pipelineOrchestrator","getPipelineAssignment"],["pipeline.camera-assigned","pipeline.camera-unassigned","pipeline.camera-updated"]),St(["pipelineRunner","getCameraMetrics"],["pipeline.camera-metrics-snapshot"]);const{data:t}=Fa({deviceId:e??0},{enabled:e!==null,staleTime:3e4}),n=t?.agentNodeId??null,s=typeof n=="string"&&n.length>0&&!n.startsWith("addon:")?n:void 0,{data:a}=bd({deviceId:e??0,...s?{nodeId:s}:{}},{enabled:e!==null,staleTime:2e3,retry:!1}),i=Te(),l=At(i.trpcClient,e),{data:c}=Ln({queryKey:["device",e,"pipelineAnalytics.getActiveTracks"],queryFn:()=>l?.pipelineAnalytics?.getActiveTracks({})??[],enabled:!!l&&e!==null,refetchInterval:5e3,retry:!1});if(e===null)return null;const d=a?.phase??null,u=a?.detectionMode??null,p=Number(a?.actualFps??0),h=Number(a?.configuredFps??0),m=Number(a?.avgInferenceTimeMs??0),g=Number(a?.queueDepth??0),b=Number(a?.droppedFrames??0),x=ur(d??"watching"),y=c?.length??0;return f("div",{className:"grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4 gap-2 sm:gap-3",children:[o(ws,{icon:Xo,label:"Phase",value:x.label,color:x.textColor,subtext:u??void 0}),o(ws,{icon:K0,label:"Detection FPS",value:`${p.toFixed(1)}`,subtext:h>0?`target: ${h}`:void 0}),o(ws,{icon:bt,label:"Inference",value:`${m.toFixed(1)} ms`,subtext:g>0?`queue: ${g}`:void 0}),o(ws,{icon:es,label:"Active Tracks",value:String(y),subtext:b>0?`dropped: ${b}`:void 0})]})}function Fi(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function N8(){const e=vn(),{data:t}=fd({deviceId:e??0},{enabled:e!==null,refetchInterval:5e3});if(e===null)return null;const n=t?.streams??{},r=Object.entries(n);return r.length===0?null:f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o("div",{className:"border-b border-border px-3 sm:px-4 py-2",children:o("h2",{className:"text-[11px] font-semibold text-foreground uppercase tracking-wider",children:"Stream Network"})}),o("div",{className:"divide-y divide-border",children:r.map(([s,a])=>f("div",{className:"px-3 sm:px-4 py-2",children:[f("div",{className:"flex items-center gap-1.5 mb-1.5",children:[o(or,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),o("span",{className:"text-[11px] font-medium text-foreground truncate",children:s})]}),f("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-2",children:[o(Ns,{label:"Nominal",value:Fi(a.nominalBitrateKbps??0)}),o(Ns,{label:"Observed",value:Fi(a.observedBitrateKbps??0)}),o(Ns,{label:"Peak",value:Fi(a.peakBitrateKbps??0)}),o(Ns,{label:"Packet Loss",value:`${(a.packetLossPercent??0).toFixed(2)}%`,warning:(a.packetLossPercent??0)>1})]})]},s))})]})}const k8=3e4;function S8({field:e}){const t=vn(),n=e.type==="doorbell-recent"&&typeof e.historyLimit=="number"?e.historyLimit:10,r=Rd({deviceId:t??void 0,historyLimit:n});if(t===null)return null;const s=r.latest?Date.now()-r.latest.timestamp<k8:!1;return o(_d,{history:r.history,latestIsFresh:s})}const C8={streaming:{icon:sv,label:"Streaming"},detection:{icon:es,label:"Detection"},recording:{icon:U0,label:"Recording"},audio:{icon:Gl,label:"Audio"},snapshot:{icon:Dr,label:"Snapshot"},motion:{icon:Jd,label:"Motion"},ptz:{icon:Jt,label:"PTZ"},webrtc:{icon:Za,label:"WebRTC"},onvif:{icon:EO,label:"ONVIF"},analytics:{icon:bt,label:"Analytics"},"battery-operated":{icon:wR,label:"Battery"},"native-snapshot":{icon:Dr,label:"Native Snapshot"},"pan-tilt-zoom":{icon:Jt,label:"PTZ"},"two-way-audio":{icon:Gl,label:"Two-way Audio"},"doorbell-button":{icon:Jo,label:"Doorbell"},rebootable:{icon:ct,label:"Rebootable"}},M8=Ka;function Ja({capabilities:e,showLabels:t=!1}){return o("div",{className:"flex items-center gap-1 flex-wrap",children:e.map(n=>{const r=C8[n],s=r?.icon??M8,a=r?.label??n;return f("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:[o(s,{className:"h-3 w-3"}),t&&o("span",{children:a})]},n)})})}const E8={frigate:{icon:q0,color:"#3b82f6",label:"Frigate"},scrypted:{icon:hn,color:"#a855f7",label:"Scrypted"},reolink:{icon:Za,color:"#06b6d4",label:"Reolink"},homeassistant:{icon:b6,color:"#22d3ee",label:"Home Assistant"},rtsp:{icon:or,color:"#78716c",label:"RTSP"},onvif:{icon:or,color:"#78716c",label:"ONVIF"}},qp={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"},I8={sm:"h-7 w-7",md:"h-8 w-8",lg:"h-10 w-10"};function lv(e){const t=e.toLowerCase();return t.startsWith("provider-")?t.slice(9):t}function A8(e){const t=lv(e);return E8[t]??{icon:q0,color:"#78716c",label:e}}function P8(e){const t=lv(e);return`/api/addon-assets/${e.toLowerCase().startsWith("provider-")?e:`provider-${t}`}/assets/icon.svg`}function gn({type:e,size:t="md",showLabel:n}){const r=A8(e),s=r.icon,[a,i]=_(!1),l=P8(e);return f("div",{className:"flex items-center gap-2",children:[o("div",{className:`flex items-center justify-center rounded-lg ${I8[t]}`,style:{backgroundColor:`${r.color}15`},children:a?o(s,{className:qp[t],style:{color:r.color}}):o("img",{src:l,alt:r.label,className:qp[t],onError:()=>i(!0)})}),n&&o("span",{className:"text-xs font-medium text-foreground-subtle",children:r.label})]})}function _8({deviceId:e,initialName:t}){const n=ke(),[r,s]=_(!1),[a,i]=_(t),[l,c]=_(!1),d=te(null);Y(()=>{r||i(t)},[t,r]),Y(()=>{r&&d.current?.focus()},[r]);const u=Gb({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDevice"]]}),n.invalidateQueries({queryKey:[["deviceManager","listAll"]]}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]})}}),p=async()=>{const m=a.trim();if(m.length===0||m===t){s(!1),i(t);return}c(!0);try{await u.mutateAsync({deviceId:e,name:m}),s(!1)}catch{}finally{c(!1)}},h=()=>{i(t),s(!1)};return r?o(cn,{label:"Name",value:f("div",{className:"flex items-center gap-1",children:[o("input",{ref:d,type:"text",value:a,onChange:m=>i(m.target.value),onKeyDown:m=>{m.key==="Enter"?p():m.key==="Escape"&&h()},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"}),o("button",{type:"button",onClick:()=>void p(),disabled:l,className:"p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50","aria-label":"Save",children:o(_t,{className:"h-3 w-3"})}),o("button",{type:"button",onClick:h,disabled:l,className:"p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50","aria-label":"Cancel",children:o(Fe,{className:"h-3 w-3"})})]})}):o(cn,{label:"Name",value:f("div",{className:"flex items-center gap-2 group",children:[o("span",{className:"truncate",children:t}),o("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:o(eo,{className:"h-3 w-3 text-foreground-subtle"})})]})})}function $8({deviceId:e,initialLocation:t}){const n=ke(),[r,s]=_(!1),[a,i]=_(t??""),[l,c]=_(!1),d=te(null),{data:u}=Wb(void 0,{staleTime:3e4,enabled:r}),p=u??[];Y(()=>{r||i(t??"")},[t,r]),Y(()=>{r&&d.current?.focus()},[r]);const h=Kb({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDevice"]]}),n.invalidateQueries({queryKey:[["deviceManager","listAll"]]}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]}),n.invalidateQueries({queryKey:[["deviceManager","listLocations"]]})}}),m=H(()=>{const y=a.trim().toLowerCase();return y.length===0?p:p.filter(w=>w.toLowerCase()!==y&&w.toLowerCase().includes(y))},[p,a]),g=a.trim().length>0&&!p.some(y=>y.toLowerCase()===a.trim().toLowerCase()),b=async y=>{const v=(y??a).trim(),N=v.length===0?null:v;if(N===(t??null)){s(!1);return}c(!0);try{await h.mutateAsync({deviceId:e,location:N}),s(!1)}catch{}finally{c(!1)}},x=()=>{i(t??""),s(!1)};return r?o(cn,{label:"Location",value:f("div",{className:"relative",children:[f("div",{className:"flex items-center gap-1",children:[o("input",{ref:d,type:"text",value:a,onChange:y=>i(y.target.value),onKeyDown:y=>{y.key==="Enter"?b():y.key==="Escape"&&x()},disabled:l,placeholder:"Room / area (or leave empty to clear)",className:"flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary"}),o("button",{type:"button",onClick:()=>void b(),disabled:l,className:"p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50","aria-label":"Save",children:o(_t,{className:"h-3 w-3"})}),o("button",{type:"button",onClick:x,disabled:l,className:"p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50","aria-label":"Cancel",children:o(Fe,{className:"h-3 w-3"})})]}),(m.length>0||g)&&f("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:[m.map(y=>f("button",{type:"button",onClick:()=>{i(y),b(y)},className:"w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover",children:[o(O6,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),o("span",{className:"truncate",children:y})]},y)),g&&f("button",{type:"button",onClick:()=>void b(),className:"w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover border-t border-border",children:[o("span",{className:"text-foreground-subtle",children:"Create"}),f("span",{className:"font-medium truncate",children:['"',a.trim(),'"']})]})]})]})}):o(cn,{label:"Location",value:f("div",{className:"flex items-center gap-2 group",children:[t?o("span",{className:"truncate",children:t}):o("span",{className:"italic text-foreground-subtle",children:"unset"}),o("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:o(eo,{className:"h-3 w-3 text-foreground-subtle"})})]})})}const Up=["manufacturer","model","hardware","firmware","serialNumber","uid","mac","itemNo"];function D8(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}function T8(e){return e==null?"—":typeof e=="string"||typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e)}function cv(){const e=vn(),t=td(),{data:n}=er({deviceId:e??0},{enabled:e!==null,staleTime:3e4}),r=n??t??null,[s,a]=_("identity");if(e===null||!r)return null;const i=String(r.stableId??""),l=String(r.name??""),c=String(r.type??""),d=String(r.addonId??""),u=r.features??[],p=r.location??null,h=r.metadata??null,m=h!==null&&Object.keys(h).length>0;return f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3",children:[o("h2",{className:"text-[11px] font-semibold text-foreground uppercase tracking-wider",children:"Device Info"}),m&&f("div",{className:"flex items-center gap-1 rounded-md bg-surface-hover p-0.5",children:[o(Qp,{active:s==="identity",onClick:()=>a("identity"),label:"Identity"}),o(Qp,{active:s==="hardware",onClick:()=>a("hardware"),label:"Hardware"})]})]}),(!m||s==="identity")&&f("div",{className:"divide-y divide-border",children:[o(cn,{label:"ID",value:f("span",{className:"font-mono text-[11px] text-foreground",children:[`#${e}`,f("span",{className:"ml-1.5 text-foreground-subtle",children:["(",i,")"]})]})}),o(_8,{deviceId:e,initialName:l}),o($8,{deviceId:e,initialLocation:p}),o(cn,{label:"Type",value:c}),o(cn,{label:"Provider",value:o(gn,{type:d,size:"sm",showLabel:!0})}),o(cn,{label:"Capabilities",value:u.length>0?o(Ja,{capabilities:u,showLabels:!0}):o("span",{className:"text-[11px] text-foreground-subtle",children:"None"})})]}),m&&s==="hardware"&&o(L8,{metadata:h})]})}function Qp({active:e,onClick:t,label:n}){return o("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 L8({metadata:e}){const t=Up.filter(s=>s in e),n=Object.keys(e).filter(s=>!Up.includes(s)).sort(),r=[...t,...n];return f("div",{children:[o("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."}),o("div",{className:"divide-y divide-border",children:r.map(s=>o(cn,{label:D8(s),value:o("span",{className:"font-mono text-[11px] text-foreground break-all",children:T8(e[s])})},s))})]})}function Us(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:B8(n.scopes)}}catch{return null}}const R8=new Set(["view","create","delete"]),O8=new Set(["category","capability","addon","device"]);function B8(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(typeof n!="object"||n===null)continue;const r=n,{type:s,access:a}=r;if(typeof s!="string"||!O8.has(s)||!Array.isArray(a))continue;const i=a.filter(c=>typeof c=="string"&&R8.has(c));if(i.length===0)continue;if(s==="device"){const c=r.targets;if(!Array.isArray(c))continue;const d=c.filter(u=>typeof u=="string"&&u.length>0);if(d.length===0)continue;t.push({type:"device",targets:d,access:i});continue}const l=r.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 z8(e){const t=Us(e);return t?t.exp*1e3<Date.now():!0}const F8="changeme",dv=ze(null);function j8({children:e}){const[t,n]=_(null),[r,s]=_(!0),[a,i]=_(!1);Y(()=>{if(typeof window<"u"&&window.location.hash.startsWith("#token=")){const x=new URLSearchParams(window.location.hash.slice(1)).get("token");x&&(localStorage.setItem("camstack_admin_token",x),window.history.replaceState({},"","/admin"))}const p=localStorage.getItem("camstack_admin_token");if(!p){s(!1);return}if(z8(p)){localStorage.removeItem("camstack_admin_token"),s(!1);return}const h=Us(p);if(!h){localStorage.removeItem("camstack_admin_token"),s(!1);return}qs().trpcClient.system.info.query().then(()=>n(h)).catch(b=>{const x=b?.data?.code;x==="UNAUTHORIZED"||x==="FORBIDDEN"?(localStorage.removeItem("camstack_admin_token"),Sr()):n(h)}).finally(()=>s(!1))},[]);const l=U(async(p,h)=>{const g=await qs().login(p,h);if(g.requiresTotp===!0)return{kind:"totp-required",challengeToken:g.token};const b=g.token;return localStorage.setItem("camstack_admin_token",b),Sr(),n(Us(b)),i(h===F8),{kind:"ok"}},[]),c=U(async(p,h)=>{const b=(await qs().loginVerifyTotp(p,h)).token;localStorage.setItem("camstack_admin_token",b),Sr(),n(Us(b)),i(!1)},[]),d=U(()=>{localStorage.removeItem("camstack_admin_token"),Sr(),n(null),i(!1)},[]),u=U(()=>{i(!1)},[]);return o(dv.Provider,{value:{user:t,loading:r,mustChangePassword:a,login:l,verifyTotp:c,logout:d,clearMustChangePassword:u},children:e})}function nn(){const e=ve(dv);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}function Dt({children:e,requireAdmin:t}){const{user:n,loading:r,mustChangePassword:s}=nn(),a=vt();return r?o("div",{className:"flex h-screen items-center justify-center bg-background text-foreground-subtle",children:"Loading..."}):n?s&&a.pathname!=="/change-password"?o(Nt,{to:"/change-password",replace:!0}):t&&!n.isAdmin?o(Nt,{to:"/access-denied",replace:!0}):o(me,{children:e}):o(Nt,{to:"/login",replace:!0})}var ji={};const Me=e=>typeof e=="string",ao=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},Gp=e=>e==null?"":""+e,V8=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},H8=/###/g,Kp=e=>e&&e.indexOf("###")>-1?e.replace(H8,"."):e,Wp=e=>!e||Me(e),vo=(e,t,n)=>{const r=Me(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(Wp(e))return{};const a=Kp(r[s]);!e[a]&&n&&(e[a]=new n),Object.prototype.hasOwnProperty.call(e,a)?e=e[a]:e={},++s}return Wp(e)?{}:{obj:e,k:Kp(r[s])}},Yp=(e,t,n)=>{const{obj:r,k:s}=vo(e,t,Object);if(r!==void 0||t.length===1){r[s]=n;return}let a=t[t.length-1],i=t.slice(0,t.length-1),l=vo(e,i,Object);for(;l.obj===void 0&&i.length;)a=`${i[i.length-1]}.${a}`,i=i.slice(0,i.length-1),l=vo(e,i,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},q8=(e,t,n,r)=>{const{obj:s,k:a}=vo(e,t,Object);s[a]=s[a]||[],s[a].push(n)},ca=(e,t)=>{const{obj:n,k:r}=vo(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},U8=(e,t,n)=>{const r=ca(e,n);return r!==void 0?r:ca(t,n)},uv=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?Me(e[r])||e[r]instanceof String||Me(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):uv(e[r],t[r],n):e[r]=t[r]);return e},Hn=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Q8={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const G8=e=>Me(e)?e.replace(/[&<>"'\/]/g,t=>Q8[t]):e;class K8{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 r=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,r),this.regExpQueue.push(t),r}}const W8=[" ",",","?","!",";"],Y8=new K8(20),Z8=(e,t,n)=>{t=t||"",n=n||"";const r=W8.filter(i=>t.indexOf(i)<0&&n.indexOf(i)<0);if(r.length===0)return!0;const s=Y8.getRegExp(`(${r.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},Kl=(e,t,n=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;const r=t.split(n);let s=e;for(let a=0;a<r.length;){if(!s||typeof s!="object")return;let i,l="";for(let c=a;c<r.length;++c)if(c!==a&&(l+=n),l+=r[c],i=s[l],i!==void 0){if(["string","number","boolean"].indexOf(typeof i)>-1&&c<r.length-1)continue;a+=c-a+1;break}s=i}return s},$o=e=>e?.replace(/_/g,"-"),X8={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 da{constructor(t,n={}){this.init(t,n)}init(t,n={}){this.prefix=n.prefix||"i18next:",this.logger=t||X8,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,r,s){return s&&!this.debug?null:(Me(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new da(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new da(this.logger,t)}}var Kt=new da;class ei{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const s=this.observers[r].get(n)||0;this.observers[r].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 Zp extends ei{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,r,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],r&&(Array.isArray(r)?l.push(...r):Me(r)&&a?l.push(...r.split(a)):l.push(r)));const c=ca(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!i||!Me(r)?c:Kl(this.data?.[t]?.[n],r,a)}addResource(t,n,r,s,a={silent:!1}){const i=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let l=[t,n];r&&(l=l.concat(i?r.split(i):r)),t.indexOf(".")>-1&&(l=t.split("."),s=n,n=l[1]),this.addNamespaces(n),Yp(this.data,l,s),a.silent||this.emit("added",t,n,r,s)}addResources(t,n,r,s={silent:!1}){for(const a in r)(Me(r[a])||Array.isArray(r[a]))&&this.addResource(t,n,a,r[a],{silent:!0});s.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,s,a,i={silent:!1,skipCopy:!1}){let l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),s=r,r=n,n=l[1]),this.addNamespaces(n);let c=ca(this.data,l)||{};i.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?uv(c,r,a):c={...c,...r},Yp(this.data,l,c),i.silent||this.emit("added",t,n,r)}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 pv={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,s){return e.forEach(a=>{t=this.processors[a]?.process(t,n,r,s)??t}),t}};const fv=Symbol("i18next/PATH_KEY");function J8(){const e=[],t=Object.create(null);let n;return t.get=(r,s)=>(n?.revoke?.(),s===fv?e:(e.push(s),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function Ir(e,t){const{[fv]:n}=e(J8()),r=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(r)}`}return n.join(r)}const Xp={},Vi=e=>!Me(e)&&typeof e!="boolean"&&typeof e!="number";class ua extends ei{constructor(t,n={}){super(),V8(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Kt.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t,n={interpolation:{}}){const r={...n};if(t==null)return!1;const s=this.resolve(t,r);if(s?.res===void 0)return!1;const a=Vi(s.res);return!(r.returnObjects===!1&&a)}extractFromKey(t,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const i=r&&t.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Z8(t,r,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(r);(r!==s||r===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,r){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=Ir(t,{...this.options,...s})),Array.isArray(t)||(t=[String(t)]),t=t.map(R=>typeof R=="function"?Ir(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 u=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;u===void 0&&(u=":");const p=s.lng||this.language,h=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p?.toLowerCase()==="cimode")return h?a?{res:`${d}${u}${l}`,usedKey:l,exactUsedKey:l,usedLng:p,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:`${d}${u}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:p,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:l;const m=this.resolve(t,s);let g=m?.res;const b=m?.usedKey||l,x=m?.exactUsedKey||l,y=["[object Number]","[object Function]","[object RegExp]"],w=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,v=!this.i18nFormat||this.i18nFormat.handleAsObject,N=s.count!==void 0&&!Me(s.count),k=ua.hasDefaultValue(s),C=N?this.pluralResolver.getSuffix(p,s.count,s):"",E=s.ordinal&&N?this.pluralResolver.getSuffix(p,s.count,{ordinal:!1}):"",I=N&&!s.ordinal&&s.count===0,A=I&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${C}`]||s[`defaultValue${E}`]||s.defaultValue;let z=g;v&&!g&&k&&(z=A);const P=Vi(z),B=Object.prototype.toString.apply(z);if(v&&z&&P&&y.indexOf(B)<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(b,z,{...s,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(m.res=R,m.usedParams=this.getUsedParamsDetails(s),m):R}if(i){const R=Array.isArray(z),M=R?[]:{},D=R?x:b;for(const T in z)if(Object.prototype.hasOwnProperty.call(z,T)){const L=`${D}${i}${T}`;k&&!g?M[T]=this.translate(L,{...s,defaultValue:Vi(A)?A[T]:void 0,joinArrays:!1,ns:c}):M[T]=this.translate(L,{...s,joinArrays:!1,ns:c}),M[T]===L&&(M[T]=z[T])}g=M}}else if(v&&Me(w)&&Array.isArray(g))g=g.join(w),g&&(g=this.extendTranslation(g,t,s,r));else{let R=!1,M=!1;!this.isValidLookup(g)&&k&&(R=!0,g=A),this.isValidLookup(g)||(M=!0,g=l);const T=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&M?void 0:g,L=k&&A!==g&&this.options.updateMissing;if(M||R||L){if(this.logger.log(L?"updateKey":"missingKey",p,d,l,L?A:g),i){const V=this.resolve(l,{...s,keySeparator:!1});V&&V.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 O=[];const F=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&F&&F[0])for(let V=0;V<F.length;V++)O.push(F[V]);else this.options.saveMissingTo==="all"?O=this.languageUtils.toResolveHierarchy(s.lng||this.language):O.push(s.lng||this.language);const j=(V,$,q)=>{const G=k&&q!==g?q:T;this.options.missingKeyHandler?this.options.missingKeyHandler(V,d,$,G,L,s):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(V,d,$,G,L,s),this.emit("missingKey",V,d,$,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?O.forEach(V=>{const $=this.pluralResolver.getSuffixes(V,s);I&&s[`defaultValue${this.options.pluralSeparator}zero`]&&$.indexOf(`${this.options.pluralSeparator}zero`)<0&&$.push(`${this.options.pluralSeparator}zero`),$.forEach(q=>{j([V],l+q,s[`defaultValue${q}`]||A)})}):j(O,l,A))}g=this.extendTranslation(g,t,s,m,r),M&&g===l&&this.options.appendNamespaceToMissingKey&&(g=`${d}${u}${l}`),(M||R)&&this.options.parseMissingKeyHandler&&(g=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${u}${l}`:l,R?g:void 0,s))}return a?(m.res=g,m.usedParams=this.getUsedParamsDetails(s),m):g}extendTranslation(t,n,r,s,a){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=Me(t)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(c){const p=t.match(this.interpolator.nestingRegexp);d=p&&p.length}let u=r.replace&&!Me(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),t=this.interpolator.interpolate(t,u,r.lng||this.language||s.usedLng,r),c){const p=t.match(this.interpolator.nestingRegexp),h=p&&p.length;d<h&&(r.nest=!1)}!r.lng&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,(...p)=>a?.[0]===p[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${p[0]} in key: ${n[0]}`),null):this.translate(...p,n),r)),r.interpolation&&this.interpolator.reset()}const i=r.postProcess||this.options.postProcess,l=Me(i)?[i]:i;return t!=null&&l?.length&&r.applyPostProcessor!==!1&&(t=pv.handle(l,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t,n={}){let r,s,a,i,l;return Me(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(c=>typeof c=="function"?Ir(c,{...this.options,...n}):c)),t.forEach(c=>{if(this.isValidLookup(r))return;const d=this.extractFromKey(c,n),u=d.key;s=u;let p=d.namespaces;this.options.fallbackNS&&(p=p.concat(this.options.fallbackNS));const h=n.count!==void 0&&!Me(n.count),m=h&&!n.ordinal&&n.count===0,g=n.context!==void 0&&(Me(n.context)||typeof n.context=="number")&&n.context!=="",b=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);p.forEach(x=>{this.isValidLookup(r)||(l=x,!Xp[`${b[0]}-${x}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(Xp[`${b[0]}-${x}`]=!0,this.logger.warn(`key "${s}" for languages "${b.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),b.forEach(y=>{if(this.isValidLookup(r))return;i=y;const w=[u];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(w,u,y,x,n);else{let N;h&&(N=this.pluralResolver.getSuffix(y,n.count,n));const k=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(h&&(n.ordinal&&N.indexOf(C)===0&&w.push(u+N.replace(C,this.options.pluralSeparator)),w.push(u+N),m&&w.push(u+k)),g){const E=`${u}${this.options.contextSeparator||"_"}${n.context}`;w.push(E),h&&(n.ordinal&&N.indexOf(C)===0&&w.push(E+N.replace(C,this.options.pluralSeparator)),w.push(E+N),m&&w.push(E+k))}}let v;for(;v=w.pop();)this.isValidLookup(r)||(a=v,r=this.getResource(y,x,v,n))}))})}),{res:r,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,r,s={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,n,r,s):this.resourceStore.getResource(t,n,r,s)}getUsedParamsDetails(t={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&!Me(t.replace);let s=r?t.replace:t;if(r&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!r){s={...s};for(const a of n)delete s[a]}return s}static hasDefaultValue(t){const n="defaultValue";for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&n===r.substring(0,n.length)&&t[r]!==void 0)return!0;return!1}}class Jp{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Kt.create("languageUtils")}getScriptPartFromCode(t){if(t=$o(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=$o(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(r=>{if(n)return;const s=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(s))&&(n=s)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const s=this.getScriptPartFromCode(r);if(this.isSupportedCode(s))return n=s;const a=this.getLanguagePartFromCode(r);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 r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=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)),r.forEach(i=>{s.indexOf(i)<0&&a(this.formatLanguageCode(i))}),s}}const ef={zero:0,one:1,two:2,few:3,many:4,other:5},tf={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class e9{constructor(t,n={}){this.languageUtils=t,this.options=n,this.logger=Kt.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,n={}){const r=$o(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:r,type:s});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let i;try{i=new Intl.PluralRules(r,{type:s})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),tf;if(!t.match(/-|_/))return tf;const c=this.languageUtils.getLanguagePartFromCode(t);i=this.getRule(c,n)}return this.pluralRulesCache[a]=i,i}needsPlural(t,n={}){let r=this.getRule(t,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,n,r={}){return this.getSuffixes(t,r).map(s=>`${n}${s}`)}getSuffixes(t,n={}){let r=this.getRule(t,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((s,a)=>ef[s]-ef[a]).map(s=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(t,n,r={}){const s=this.getRule(t,r);return s?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${s.select(n)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",n,r))}}const nf=(e,t,n,r=".",s=!0)=>{let a=U8(e,t,n);return!a&&s&&Me(n)&&(a=Kl(e,n,r),a===void 0&&(a=Kl(t,n,r))),a},Hi=e=>e.replace(/\$/g,"$$$$");class rf{constructor(t={}){this.logger=Kt.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:r,useRawValueToEscape:s,prefix:a,prefixEscaped:i,suffix:l,suffixEscaped:c,formatSeparator:d,unescapeSuffix:u,unescapePrefix:p,nestingPrefix:h,nestingPrefixEscaped:m,nestingSuffix:g,nestingSuffixEscaped:b,nestingOptionsSeparator:x,maxReplaces:y,alwaysFormat:w}=t.interpolation;this.escape=n!==void 0?n:G8,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=a?Hn(a):i||"{{",this.suffix=l?Hn(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=u?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=h?Hn(h):m||Hn("$t("),this.nestingSuffix=g?Hn(g):b||Hn(")"),this.nestingOptionsSeparator=x||",",this.maxReplaces=y||1e3,this.alwaysFormat=w!==void 0?w:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"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,r,s){let a,i,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=m=>{if(m.indexOf(this.formatSeparator)<0){const y=nf(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,r,{...s,...n,interpolationkey:m}):y}const g=m.split(this.formatSeparator),b=g.shift().trim(),x=g.join(this.formatSeparator).trim();return this.format(nf(n,c,b,this.options.keySeparator,this.options.ignoreJSONStructure),x,r,{...s,...n,interpolationkey:b})};this.resetRegExp();const u=s?.missingInterpolationHandler||this.options.missingInterpolationHandler,p=s?.interpolation?.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>Hi(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?Hi(this.escape(m)):Hi(m)}].forEach(m=>{for(l=0;a=m.regex.exec(t);){const g=a[1].trim();if(i=d(g),i===void 0)if(typeof u=="function"){const x=u(t,a,s);i=Me(x)?x:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))i="";else if(p){i=a[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),i="";else!Me(i)&&!this.useRawValueToEscape&&(i=Gp(i));const b=m.safeValue(i);if(t=t.replace(a[0],b),p?(m.regex.lastIndex+=i.length,m.regex.lastIndex-=a[0].length):m.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n,r={}){let s,a,i;const l=(c,d)=>{const u=this.nestingOptionsSeparator;if(c.indexOf(u)<0)return c;const p=c.split(new RegExp(`${Hn(u)}[ ]*{`));let h=`{${p[1]}`;c=p[0],h=this.interpolate(h,i);const m=h.match(/'/g),g=h.match(/"/g);((m?.length??0)%2===0&&!g||(g?.length??0)%2!==0)&&(h=h.replace(/'/g,'"'));try{i=JSON.parse(h),d&&(i={...d,...i})}catch(b){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,b),`${c}${u}${h}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];i={...r},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(u=>u.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=Gp(a)),a||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),a=""),c.length&&(a=c.reduce((u,p)=>this.format(u,p,r.lng,{...r,interpolationkey:s[1].trim()}),a.trim())),t=t.replace(s[0],a),this.regexp.lastIndex=0}return t}}const t9=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const s=r[1].substring(0,r[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,""),u=l.trim();n[u]||(n[u]=d),d==="false"&&(n[u]=!1),d==="true"&&(n[u]=!0),isNaN(d)||(n[u]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},of=e=>{const t={};return(n,r,s)=>{let a=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(a={...a,[s.interpolationkey]:void 0});const i=r+JSON.stringify(a);let l=t[i];return l||(l=e($o(r),s),t[i]=l),l(n)}},n9=e=>(t,n,r)=>e($o(n),r)(t);class r9{constructor(t={}){this.logger=Kt.create("formatter"),this.options=t,this.init(t)}init(t,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?of:n9;this.formats={number:r((s,a)=>{const i=new Intl.NumberFormat(s,{...a});return l=>i.format(l)}),currency:r((s,a)=>{const i=new Intl.NumberFormat(s,{...a,style:"currency"});return l=>i.format(l)}),datetime:r((s,a)=>{const i=new Intl.DateTimeFormat(s,{...a});return l=>i.format(l)}),relativetime:r((s,a)=>{const i=new Intl.RelativeTimeFormat(s,{...a});return l=>i.format(l,a.range||"day")}),list:r((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()]=of(n)}format(t,n,r,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:u}=t9(c);if(this.formats[d]){let p=l;try{const h=s?.formatParams?.[s.interpolationkey]||{},m=h.locale||h.lng||s.locale||s.lng||r;p=this.formats[d](l,m,{...u,...s,...h})}catch(h){this.logger.warn(h)}return p}else this.logger.warn(`there was no format function for ${d}`);return l},t)}}const o9=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class s9 extends ei{constructor(t,n,r,s={}){super(),this.backend=t,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=s,this.logger=Kt.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?.(r,s.backend,s)}queueLoad(t,n,r,s){const a={},i={},l={},c={};return t.forEach(d=>{let u=!0;n.forEach(p=>{const h=`${d}|${p}`;!r.reload&&this.store.hasResourceBundle(d,p)?this.state[h]=2:this.state[h]<0||(this.state[h]===1?i[h]===void 0&&(i[h]=!0):(this.state[h]=1,u=!1,i[h]===void 0&&(i[h]=!0),a[h]===void 0&&(a[h]=!0),c[p]===void 0&&(c[p]=!0)))}),u||(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,r){const s=t.split("|"),a=s[0],i=s[1];n&&this.emit("failedLoading",a,i,n),!n&&r&&this.store.addResourceBundle(a,i,r,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&r&&(this.state[t]=0);const l={};this.queue.forEach(c=>{q8(c.loaded,[a],i),o9(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(d=>{l[d]||(l[d]={});const u=c.loaded[d];u.length&&u.forEach(p=>{l[d][p]===void 0&&(l[d][p]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,r,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:r,tried:s,wait:a,callback:i});return}this.readingCalls++;const l=(d,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const p=this.waitingReads.shift();this.read(p.lng,p.ns,p.fcName,p.tried,p.wait,p.callback)}if(d&&u&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,a*2,i)},a);return}i(d,u)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const d=c(t,n);d&&typeof d.then=="function"?d.then(u=>l(null,u)).catch(l):l(null,d)}catch(d){l(d)}return}return c(t,n,l)}prepareLoading(t,n,r={},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,r,s);if(!a.toLoad.length)return a.pending.length||s(),null;a.toLoad.forEach(i=>{this.loadOne(i)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t,n=""){const r=t.split("|"),s=r[0],a=r[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,r,s,a,i={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" 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(!(r==null||r==="")){if(this.backend?.create){const c={...i,isUpdate:a},d=this.backend.create.bind(this.backend);if(d.length<6)try{let u;d.length===5?u=d(t,n,r,s,c):u=d(t,n,r,s),u&&typeof u.then=="function"?u.then(p=>l(null,p)).catch(l):l(null,u)}catch(u){l(u)}else d(t,n,r,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const qi=()=>({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(r=>{t[r]=n[r]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),sf=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),ks=()=>{},a9=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})},hv="__i18next_supportNoticeShown",i9=()=>!!(typeof globalThis<"u"&&globalThis[hv]||typeof process<"u"&&ji&&ji.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&ji),l9=()=>{typeof globalThis<"u"&&(globalThis[hv]=!0)},c9=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 wo extends ei{constructor(t={},n){if(super(),this.options=sf(t),this.services={},this.logger=Kt,this.modules={external:[]},a9(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 r=qi();this.options={...r,...this.options,...sf(t)},this.options.interpolation={...r.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=r.overloadTranslationOptionHandler),this.options.showSupportNotice!==!1&&!c9(this)&&!i9()&&(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 💙"),l9());const s=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Kt.init(s(this.modules.logger),this.options):Kt.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=r9;const u=new Jp(this.options);this.store=new Zp(this.options.resources,this.options);const p=this.services;p.logger=Kt,p.resourceStore=this.store,p.languageUtils=u,p.pluralResolver=new e9(u,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.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===r.interpolation.format)&&(p.formatter=s(d),p.formatter.init&&p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new rf(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new s9(s(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",(m,...g)=>{this.emit(m,...g)}),this.modules.languageDetector&&(p.languageDetector=s(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=s(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new ua(this.services,this.options),this.translator.on("*",(m,...g)=>{this.emit(m,...g)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,n||(n=ks),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]=(...u)=>this.store[d](...u)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=(...u)=>(this.store[d](...u),this)});const l=ao(),c=()=>{const d=(u,p)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(p),n(u,p)};if(this.languages&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(t,n=ks){let r=n;const s=Me(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(s?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();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),r(l)})}else r(null)}reloadResources(t,n,r){const s=ao();return typeof t=="function"&&(r=t,t=void 0),typeof n=="function"&&(r=n,n=void 0),t||(t=this.languages),n||(n=this.options.ns),r||(r=ks),this.services.backendConnector.reload(t,n,a=>{s.resolve(),r(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"&&pv.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 r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;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 r=ao();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,r.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,u=>{a(u,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),r}getFixedT(t,n,r){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||r||s.keyPrefix);const d={...this.options,...c};typeof c.keyPrefix=="function"&&(c.keyPrefix=Ir(c.keyPrefix,d));const u=this.options.keySeparator||".";let p;return c.keyPrefix&&Array.isArray(a)?p=a.map(h=>(typeof h=="function"&&(h=Ir(h,d)),`${c.keyPrefix}${u}${h}`)):(typeof a=="function"&&(a=Ir(a,d)),p=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(p,c)};return Me(t)?s.lng=t:s.lngs=t,s.ns=n,s.keyPrefix=r,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 r=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(r.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(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(r,t)&&(!s||i(a,t)))}loadNamespaces(t,n){const r=ao();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=>{r.resolve(),n&&n(s)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=ao();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=>{r.resolve(),n&&n(i)}),r):(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"],r=this.services?.languageUtils||new Jp(qi());return t.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(r.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},n){const r=new wo(t,n);return r.createInstance=wo.createInstance,r}cloneInstance(t={},n=ks){const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},a=new wo(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)},r){const l=Object.keys(this.store.data).reduce((c,d)=>(c[d]={...this.store.data[d]},c[d]=Object.keys(c[d]).reduce((u,p)=>(u[p]={...c[d][p]},u),c[d]),c),{});a.store=new Zp(l,s),a.services.resourceStore=a.store}if(t.interpolation){const c={...qi().interpolation,...this.options.interpolation,...t.interpolation},d={...s,interpolation:c};a.services.interpolator=new rf(d)}return a.translator=new ua(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 et=wo.createInstance();et.createInstance;et.dir;et.init;et.loadResources;et.reloadResources;et.use;et.changeLanguage;et.getFixedT;et.t;et.exists;et.setDefaultNamespace;et.hasLoadedNamespace;et.loadNamespaces;et.loadLanguages;const d9=(e,t,n,r)=>{const s=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(s,"warn","react-i18next::",!0);sr(s[0])&&(s[0]=`react-i18next:: ${s[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...s):console?.warn&&console.warn(...s)},af={},Wl=(e,t,n,r)=>{sr(n)&&af[n]||(sr(n)&&(af[n]=new Date),d9(e,t,n,r))},mv=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}},Yl=(e,t,n)=>{e.loadNamespaces(t,mv(e,n))},lf=(e,t,n,r)=>{if(sr(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return Yl(e,n,r);n.forEach(s=>{e.options.ns.indexOf(s)<0&&e.options.ns.push(s)}),e.loadLanguages(t,mv(e,r))},u9=(e,t,n={})=>!t.languages||!t.languages.length?(Wl(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(r,s)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&r.services.backendConnector.backend&&r.isLanguageChangingTo&&!s(r.isLanguageChangingTo,e))return!1}}),sr=e=>typeof e=="string",p9=e=>typeof e=="object"&&e!==null,f9=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,h9={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},m9=e=>h9[e],g9=e=>e.replace(f9,m9);let Zl={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:g9,transDefaultProps:void 0};const b9=(e={})=>{Zl={...Zl,...e}},x9=()=>Zl;let gv;const y9=e=>{gv=e},v9=()=>gv,w9={type:"3rdParty",init(e){b9(e.options.react),y9(e)}},N9=ze();class k9{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var bv={exports:{}},xv={};/**
|
|
1134
|
-
* @license React
|
|
1135
|
-
* use-sync-external-store-shim.production.js
|
|
1136
|
-
*
|
|
1137
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1138
|
-
*
|
|
1139
|
-
* This source code is licensed under the MIT license found in the
|
|
1140
|
-
* LICENSE file in the root directory of this source tree.
|
|
1141
|
-
*/var Tr=mm;function S9(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var C9=typeof Object.is=="function"?Object.is:S9,M9=Tr.useState,E9=Tr.useEffect,I9=Tr.useLayoutEffect,A9=Tr.useDebugValue;function P9(e,t){var n=t(),r=M9({inst:{value:n,getSnapshot:t}}),s=r[0].inst,a=r[1];return I9(function(){s.value=n,s.getSnapshot=t,Ui(s)&&a({inst:s})},[e,n,t]),E9(function(){return Ui(s)&&a({inst:s}),e(function(){Ui(s)&&a({inst:s})})},[e]),A9(n),n}function Ui(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!C9(e,n)}catch{return!0}}function _9(e,t){return t()}var $9=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?_9:P9;xv.useSyncExternalStore=Tr.useSyncExternalStore!==void 0?Tr.useSyncExternalStore:$9;bv.exports=xv;var yv=bv.exports;const D9=(e,t)=>{if(sr(t))return t;if(p9(t)&&sr(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},T9={t:D9,ready:!1},L9=()=>()=>{},Vt=(e,t={})=>{const{i18n:n}=t,{i18n:r,defaultNS:s}=ve(N9)||{},a=n||r||v9();a&&!a.reportNamespaces&&(a.reportNamespaces=new k9),a||Wl(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const i=H(()=>({...x9(),...a?.options?.react,...t}),[a,t]),{useSuspense:l,keyPrefix:c}=i,d=s||a?.options?.defaultNS,u=sr(d)?[d]:d||["translation"],p=H(()=>u,u);a?.reportNamespaces?.addUsedNamespaces?.(p);const h=te(0),m=U(A=>{if(!a)return L9;const{bindI18n:z,bindI18nStore:P}=i,B=()=>{h.current+=1,A()};return z&&a.on(z,B),P&&a.store.on(P,B),()=>{z&&z.split(" ").forEach(R=>a.off(R,B)),P&&P.split(" ").forEach(R=>a.store.off(R,B))}},[a,i]),g=te(),b=U(()=>{if(!a)return T9;const A=!!(a.isInitialized||a.initializedStoreOnce)&&p.every(D=>u9(D,a,i)),z=t.lng||a.language,P=h.current,B=g.current;if(B&&B.ready===A&&B.lng===z&&B.keyPrefix===c&&B.revision===P)return B;const M={t:a.getFixedT(z,i.nsMode==="fallback"?p:p[0],c),ready:A,lng:z,keyPrefix:c,revision:P};return g.current=M,M},[a,p,c,i,t.lng]),[x,y]=_(0),{t:w,ready:v}=yv.useSyncExternalStore(m,b,b);Y(()=>{if(a&&!v&&!l){const A=()=>y(z=>z+1);t.lng?lf(a,t.lng,p,A):Yl(a,p,A)}},[a,t.lng,p,v,l,x]);const N=a||{},k=te(null),C=te(),E=A=>{const z=Object.getOwnPropertyDescriptors(A);z.__original&&delete z.__original;const P=Object.create(Object.getPrototypeOf(A),z);if(!Object.prototype.hasOwnProperty.call(P,"__original"))try{Object.defineProperty(P,"__original",{value:A,writable:!1,enumerable:!1,configurable:!1})}catch{}return P},I=H(()=>{const A=N,z=A?.language;let P=A;A&&(k.current&&k.current.__original===A?C.current!==z?(P=E(A),k.current=P,C.current=z):P=k.current:(P=E(A),k.current=P,C.current=z));const B=!v&&!l?(...M)=>(Wl(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=[B,P,v];return R.t=B,R.i18n=P,R.ready=v,R},[w,N,v,N.resolvedLanguage,N.language,N.languages]);if(a&&l&&!v)throw new Promise(A=>{const z=()=>A();t.lng?lf(a,t.lng,p,z):Yl(a,p,z)});return I},cf={info:rr,success:Kd,warning:it,error:nr},R9={info:"text-blue-400",success:"text-green-400",warning:"text-amber-400",error:"text-red-400"},df={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 O9(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 r=Math.floor(n/60);if(r<24)return`${String(r)}h ago`;const s=Math.floor(r/24);return`${String(s)}d ago`}function uf({alert:e,onMarkRead:t,onDismiss:n}){const r=e.severity in cf?e.severity:"info",s=e.status in df?e.status:"active",a=cf[r],i=R9[r],l=df[s];return f("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:[o(a,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${i}`}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:`text-[11px] font-semibold ${e.read?"text-foreground-subtle":"text-foreground"}`,children:e.title}),!e.read&&o("span",{className:"h-1.5 w-1.5 rounded-full bg-primary shrink-0"})]}),o("div",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-2",children:e.message}),e.status==="in-progress"&&e.progress!==void 0&&f("div",{className:"mt-1.5 flex items-center gap-2",children:[o("div",{className:"flex-1 h-1 bg-surface-hover rounded-full overflow-hidden",children:o("div",{className:"h-full bg-primary rounded-full transition-all duration-300",style:{width:`${String(Math.min(100,Math.max(0,e.progress)))}%`}})}),f("span",{className:"text-[9px] text-foreground-subtle font-mono shrink-0",children:[String(Math.round(e.progress)),"%"]})]}),o("div",{className:"text-[9px] text-foreground-subtle/60 mt-1",children:O9(e.updatedAt)})]}),f("div",{className:"flex items-center gap-0.5 shrink-0",children:[!e.read&&o("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:o(_t,{className:"h-3 w-3 text-foreground-subtle"})}),e.status!=="in-progress"&&o("button",{type:"button",onClick:c=>{c.stopPropagation(),n(e.id)},className:"p-1 rounded hover:bg-surface-hover transition-colors",title:"Dismiss",children:o(Fe,{className:"h-3 w-3 text-foreground-subtle"})})]})]})}function pf({variant:e="icon",compact:t=!1}={}){const[n,r]=_(!1),[s,a]=_(!1),i=te(null),l=te(null),c=ke(),{data:d=0}=Ab(void 0,{staleTime:1e4,refetchInterval:3e4}),{data:u=[],isLoading:p}=Ib({limit:50},{enabled:n,staleTime:5e3}),h=s?u:u.filter(A=>!A.read),m=u.filter(A=>A.read).length,g=()=>{c.invalidateQueries({queryKey:[["alerts"]]})},b=Pb({onSuccess:g}),x=_b({onSuccess:g}),y=$b({onSuccess:g});gt("alert.created",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),gt("alert.updated",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),Y(()=>{if(!n)return;const A=z=>{const P=z.target;i.current&&!i.current.contains(P)&&l.current&&!l.current.contains(P)&&r(!1)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[n]);const w=U(A=>{b.mutate({alertId:A})},[b]),v=U(A=>{A&&y.mutate({alertId:A})},[y]),N=U(()=>{x.mutate(void 0),r(!1)},[x]),k=h.filter(A=>A.status==="in-progress"),C=h.filter(A=>A.status!=="in-progress"),[E,I]=_({});return Y(()=>{if(n&&l.current){const A=l.current.getBoundingClientRect();I({position:"fixed",left:A.left,bottom:window.innerHeight-A.top+4,zIndex:9999})}},[n]),f("div",{children:[e==="sidebar"?f("button",{ref:l,type:"button",onClick:()=>r(!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:[f("span",{className:"relative inline-flex shrink-0",children:[o(at,{className:"h-3.5 w-3.5"}),t&&d>0&&o("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary"})]}),!t&&o("span",{className:"flex-1 text-left",children:"Alerts"}),!t&&d>0&&o("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)})]}):f("button",{ref:l,type:"button",onClick:()=>r(!n),className:"relative p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors","aria-label":"Alerts",children:[o(at,{className:"h-4.5 w-4.5"}),d>0&&o("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&&qo(f("div",{ref:i,style:E,className:"w-80 max-h-[28rem] bg-surface border border-border rounded-lg shadow-xl flex flex-col overflow-hidden",children:[f("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border shrink-0",children:[o("span",{className:"text-[12px] font-semibold text-foreground",children:"Alerts"}),f("div",{className:"flex items-center gap-2",children:[m>0&&f("label",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle cursor-pointer select-none",children:[o("input",{type:"checkbox",checked:s,onChange:A=>a(A.target.checked),className:"h-3 w-3 rounded border-border accent-primary cursor-pointer"}),"Show read"]}),d>0&&f("button",{type:"button",onClick:N,className:"flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors",children:[o(LR,{className:"h-3 w-3"}),"Mark all read"]})]})]}),f("div",{className:"flex-1 overflow-y-auto",children:[p&&o("div",{className:"flex items-center justify-center py-8",children:o(Se,{className:"h-4 w-4 animate-spin text-foreground-subtle"})}),!p&&h.length===0&&f("div",{className:"flex flex-col items-center justify-center py-8 text-foreground-subtle",children:[o(at,{className:"h-6 w-6 mb-2 opacity-40"}),o("span",{className:"text-[11px]",children:u.length>0?"No unread alerts":"No alerts"}),u.length>0&&!s&&f("button",{type:"button",onClick:()=>a(!0),className:"text-[10px] text-primary mt-1 hover:underline",children:["Show ",m," read alert",m!==1?"s":""]})]}),k.length>0&&f("div",{className:"border-b border-border",children:[o("div",{className:"px-3 py-1.5 bg-surface-hover/50",children:o("span",{className:"text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:"In Progress"})}),k.map(A=>o(uf,{alert:A,onMarkRead:w,onDismiss:v},A.id))]}),C.map(A=>o(uf,{alert:A,onMarkRead:w,onDismiss:v},A.id))]})]}),document.body)]})}function vv(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 ff=new Map,Ss=new Map,hf=new Set;function B9(e){return!e||typeof e!="object"?!1:typeof e.default=="function"}async function z9(e,t){const n=ff.get(e);if(n)return n;const r=Ss.get(e);if(r)return r;hf.has(e)||(Ec(),_r.registerRemotes([{name:e,entry:t,type:"module"}],{force:!1}),hf.add(e));const s=_r.loadRemote(`${e}/page`).then(a=>{if(!B9(a))throw new Error(`Addon page remote ${e} (${t}) does not expose a default React component on './page'`);return ff.set(e,a.default),Ss.delete(e),a.default}).catch(a=>{throw Ss.delete(e),a});return Ss.set(e,s),s}function F9(){const{pagePath:e}=zd(),t=Te(),{data:n}=nd(void 0,{staleTime:6e4}),r=H(()=>n?vv(n):void 0,[n]),s=r?.find(d=>d.path===`/addon/${e}`),[a,i]=_(null),[l,c]=_(null);return Y(()=>{if(!s)return;c(null),i(null);let d=!1;return z9(s.remoteName,s.bundleUrl).then(u=>{d||i(()=>u)}).catch(u=>{if(d)return;const p=u instanceof Error?u.message:String(u);c(`Failed to load addon page: ${p}`)}),()=>{d=!0}},[s]),r?s?l?o("div",{className:"flex items-center justify-center h-full text-red-400 text-sm",children:l}):a?o(a,{trpc:t.trpcClient,theme:{isDark:document.documentElement.classList.contains("dark")},navigate:d=>{window.location.href=d}}):o("div",{className:"flex items-center justify-center h-full",children:o("div",{className:"animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full"})}):o("div",{className:"flex items-center justify-center h-full text-foreground-subtle",children:"Addon page not found"}):o("div",{className:"flex items-center justify-center h-full",children:o("div",{className:"animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full"})})}const j9={dark:Z0,light:RO,system:U6},V9={gauge:K0,puzzle:la,bot:MR,cpu:bt,terminal:ov,box:Ka,wrench:YO,activity:Xo,plug:_o};function H9(){const e=vt(),t=rt(),{user:n,logout:r}=nn(),s=Hr(),{t:a}=Vt(),i=hr(),l=Mg(),c=cR(),d=c!=="connected",u=c==="connecting",[p,h]=_(!1),[m,g]=_(()=>typeof window>"u"?!1:window.localStorage.getItem("camstack:sidebar-collapsed")==="1");Y(()=>{typeof window>"u"||window.localStorage.setItem("camstack:sidebar-collapsed",m?"1":"0")},[m]);const[b,x]=_(()=>{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([...b]))},[b]),Y(()=>{l&&window.localStorage.getItem("camstack:sidebar-collapsed")===null&&g(!0)},[l]);const{data:y=[]}=od({nodeId:"hub"},{staleTime:3e4,refetchInterval:3e4}),w=y.length,v=ke(),N=te(Date.now()),k=3e4,C=2e3,{data:E}=nd(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:$=>{const q=$.state.data;return q&&q.length>0||Date.now()-N.current>=k?!1:C}}),I=H(()=>E&&n?.isAdmin?vv(E):[],[E,n?.isAdmin]);gt("addon.page-ready",()=>{v.invalidateQueries({queryKey:[["addonPages","listPages"]]})});const A=()=>{r(),t("/login")},z=$=>!!(e.pathname===$||e.pathname.startsWith($+"/")),B=["/pipeline","/timeline"].some($=>e.pathname===$||e.pathname.startsWith($+"/")),R=n?.isAdmin===!0,M=[{label:a("nav.devices","Devices"),icon:Dr,path:"/devices"},{label:a("nav.integrations"),icon:_o,path:"/integrations"},{label:a("nav.timeline","Timeline"),icon:WR,path:"/timeline"},{label:a("nav.pipeline","Pipeline"),icon:f6,path:"/pipeline"}].filter(Boolean),T=[{label:a("system.identity","Identity & Access"),icon:Yd,path:"/system/identity",adminOnly:!0},{label:a("system.network","Network"),icon:_n,path:"/system/network",adminOnly:!0},{label:a("system.integrations","Integrations"),icon:_o,path:"/system/integrations",adminOnly:!0},{label:a("system.data","Data"),icon:Q0,path:"/system/data",adminOnly:!0},{label:a("system.cluster","Cluster"),icon:$n,path:"/system/cluster",adminOnly:!0},{label:a("system.addons"),icon:la,path:"/system/addons",adminOnly:!0},{label:a("system.addonSettings","Addon Settings"),icon:Jt,path:"/system/settings",adminOnly:!0},{label:a("system.logs","Logs"),icon:at,path:"/system/logs",adminOnly:!0}].filter($=>!$.adminOnly||R),L=s?.mode??"system",O={dark:a("theme.dark"),light:a("theme.light"),system:a("theme.system")},F=m&&!i,j=($,q="md")=>`flex w-full items-center gap-2.5 rounded-md ${F?"justify-center px-0 py-2":"px-2.5 py-1.5"} ${q==="lg"?"text-[13px] font-medium":"text-[12px]"} transition-all ${$?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"}`,V=f(me,{children:[f("div",{className:`flex h-14 items-center border-b border-border ${F?"justify-center px-1":"pl-3 pr-4 gap-2"}`,children:[!F&&o("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&&o("button",{onClick:()=>g($=>!$),className:`p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle transition-colors flex-shrink-0 ${F?"":"mr-2"}`,"aria-label":m?"Expand sidebar":"Collapse sidebar",title:m?"Expand sidebar":"Collapse sidebar",children:m?o(wt,{className:"h-4 w-4"}):o(Gd,{className:"h-4 w-4"})})]}),f("nav",{className:`flex-1 overflow-y-auto py-3 ${F?"px-1.5":"px-2"} space-y-0.5`,children:[(()=>{const $=z("/dashboard");return f("button",{"data-testid":"nav-dashboard",onClick:()=>{t("/dashboard"),h(!1)},className:j($,"lg"),title:F?a("nav.dashboard"):void 0,children:[o(Y0,{className:`h-4 w-4 shrink-0 ${$?"text-primary":""}`}),!F&&a("nav.dashboard")]})})(),!F&&o("div",{className:"pt-4 pb-1.5 px-2.5",children:o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("nav.camerasSection","Cameras")})}),F&&o("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),M.map($=>{const q=$.icon,G=z($.path),Z=`nav-${$.path.replace(/^\//,"").replace(/\//g,"-")}`;return f("button",{"data-testid":Z,onClick:()=>{t($.path),h(!1)},className:j(G),title:F?$.label:void 0,children:[o(q,{className:`h-3.5 w-3.5 shrink-0 ${G?"text-primary":""}`}),!F&&$.label]},$.path)}),!F&&o("div",{className:"pt-4 pb-1.5 px-2.5",children:o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("system.title")})}),F&&o("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),T.map($=>{const q=$.icon,G=z($.path),Z=$.path==="/system/addons",oe=`nav-${$.path.replace(/^\//,"").replace(/\//g,"-")}`;return f("button",{"data-testid":oe,onClick:()=>{t($.path),h(!1)},className:j(G),title:F?$.label:void 0,children:[o(q,{className:`h-3.5 w-3.5 shrink-0 ${G?"text-primary":""}`}),!F&&f(me,{children:[o("span",{className:"flex-1 text-left",children:$.label}),Z&&w>0&&o("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})]}),F&&Z&&w>0&&o("span",{className:"absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary"})]},$.path)}),I&&I.length>0&&!F&&o("div",{className:"pt-4 pb-1.5 px-2.5",children:o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("nav.addonPages","Addon Pages")})}),F&&I&&I.length>0&&o("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),I?.map($=>{const q=z($.path),G=V9[$.icon]??la;return f("button",{onClick:()=>{t($.path),h(!1)},className:j(q),title:F?$.label:void 0,children:[o(G,{className:`h-3.5 w-3.5 shrink-0 ${q?"text-primary":""}`}),!F&&$.label]},$.id)})]}),f("div",{className:`border-t border-border ${F?"p-1.5":"p-2"} space-y-0.5`,children:[f("button",{onClick:()=>s?.toggleMode(),className:j(!1),title:F?O[L]:void 0,children:[(()=>{const $=j9[L];return o($,{className:"h-3.5 w-3.5 shrink-0"})})(),!F&&o("span",{children:O[L]})]}),o(pf,{variant:"sidebar",compact:F}),f("button",{type:"button",onClick:()=>t("/system/my-access"),className:j(z("/system/my-access")),title:F?a("system.myAccess","My access"):void 0,children:[o(mn,{className:"h-3.5 w-3.5 shrink-0"}),!F&&o("span",{className:"truncate",children:a("system.myAccess","My access")})]}),f("button",{onClick:A,className:j(!1).replace("hover:text-foreground","hover:text-danger"),title:F?n?.username??"Logout":void 0,children:[o(Zd,{className:"h-3.5 w-3.5 shrink-0"}),!F&&o("span",{className:"truncate",children:n?.username??"User"})]})]})]});return f("div",{className:"flex h-screen bg-background text-foreground",children:[!i&&o("aside",{className:`flex flex-col border-r border-border bg-surface/80 backdrop-blur-sm shrink-0 transition-[width] duration-150 ease-out ${F?"w-12":"w-48"}`,children:V}),i&&o(Vc,{open:p,onClose:()=>h(!1),width:"w-64",children:V}),f("div",{className:"flex flex-1 flex-col min-w-0",children:[d&&f("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:[o(av,{className:"h-3.5 w-3.5"}),o("span",{children:u?a("connection.reconnecting","Reconnecting…"):a("connection.disconnected","Server unreachable — reconnecting…")}),o(Se,{className:"h-3.5 w-3.5 animate-spin"})]}),i&&f("header",{className:"flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm",children:[o("button",{onClick:()=>h(!0),className:"p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors","aria-label":"Open menu",children:o(F6,{className:"h-5 w-5"})}),o("div",{className:"flex-1 flex justify-center",children:o("img",{src:s?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack",className:"h-7"})}),o(pf,{})]}),f("main",{className:`relative flex-1 min-h-0 bg-background ${B?"overflow-hidden":"overflow-auto"}`,children:[d&&o("div",{className:"absolute inset-0 z-40 bg-background/60 backdrop-blur-[2px]"}),o(wL,{})]})]})]})}function q9(){const{login:e,verifyTotp:t}=nn(),n=Hr(),r=rt(),[s,a]=_(""),[i,l]=_(""),[c,d]=_(!1),[u,p]=_(""),[h,m]=_(!1),[g,b]=_("credentials"),[x,y]=_(""),[w,v]=_(""),N=async E=>{E.preventDefault(),p(""),m(!0);try{const I=await e(s,i);if(I.kind==="totp-required"){y(I.challengeToken),b("totp");return}r(i==="changeme"?"/change-password":"/dashboard",{replace:!0})}catch(I){p(I instanceof Error?I.message:"Login failed")}finally{m(!1)}},k=async E=>{E.preventDefault(),p(""),m(!0);try{await t(x,w.trim()),r("/dashboard",{replace:!0})}catch(I){p(I instanceof Error?I.message:"TOTP verification failed"),v("")}finally{m(!1)}},C=()=>{b("credentials"),y(""),v(""),p("")};return o("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:f("div",{className:"w-full max-w-sm",children:[o("div",{className:"flex justify-center mb-8",children:o("img",{src:n?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack Admin",className:"h-12"})}),g==="credentials"?f("form",{onSubmit:N,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[u&&o("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:u}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Username"}),o("input",{"data-testid":"login-username",type:"text",placeholder:"Username",value:s,onChange:E=>a(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})]}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Password"}),f("div",{className:"relative",children:[o("input",{"data-testid":"login-password",type:c?"text":"password",placeholder:"Password",value:i,onChange:E=>l(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"}),o("button",{type:"button",onClick:()=>d(!c),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors",tabIndex:-1,children:c?o(G0,{className:"h-4 w-4"}):o(es,{className:"h-4 w-4"})})]})]}),o("button",{"data-testid":"login-submit",type:"submit",disabled:h||!s||!i,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?f("span",{className:"flex items-center justify-center gap-2",children:[o("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground/30 border-t-primary-foreground"}),"Logging in..."]}):"Log in"})]}):f("form",{onSubmit:k,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[f("div",{className:"flex items-center gap-2 pb-1 border-b border-border",children:[o(An,{className:"h-4 w-4 text-primary"}),o("div",{className:"text-sm font-medium text-foreground",children:"Two-factor authentication"})]}),f("p",{className:"text-xs text-foreground-subtle",children:["Enter the 6-digit code from your authenticator app to finish signing in as"," ",o("span",{className:"font-mono text-foreground",children:s}),"."]}),u&&o("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:u}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Authentication code"}),o("input",{"data-testid":"login-totp",type:"text",inputMode:"numeric",autoComplete:"one-time-code",placeholder:"123456",value:w,onChange:E=>v(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})]}),o("button",{"data-testid":"login-totp-submit",type:"submit",disabled:h||w.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?f("span",{className:"flex items-center justify-center gap-2",children:[o("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"}),f("button",{type:"button",onClick:C,className:"w-full flex items-center justify-center gap-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors",children:[o(Qd,{className:"h-3 w-3"}),"Back to username + password"]})]}),g==="credentials"&&o(U9,{}),o("p",{className:"mt-6 text-center text-[10px] text-foreground-subtle/50",children:"CamStack v0.1.0"})]})})}function U9(){const t=(S.auth.listProviders.useQuery().data??[]).filter(n=>n.flowType==="redirect");return t.length===0?null:f("div",{className:"mt-6 space-y-3",children:[f("div",{className:"flex items-center gap-3",children:[o("div",{className:"h-px flex-1 bg-border"}),o("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Or continue with"}),o("div",{className:"h-px flex-1 bg-border"})]}),o("div",{className:"space-y-2",children:t.map(n=>f("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:[o(mn,{className:"h-4 w-4 text-primary"}),n.name]},n.id))})]})}const mf=8;function Q9(){const{user:e,mustChangePassword:t,clearMustChangePassword:n,logout:r}=nn(),s=Hr(),a=rt(),[i,l]=_(""),[c,d]=_(""),[u,p]=_(!1),[h,m]=_(""),g=wd({onSuccess:()=>{n(),a("/dashboard",{replace:!0})},onError:x=>{m(x instanceof Error?x.message:"Could not change password")}}),b=async x=>{if(x.preventDefault(),m(""),!e){m("Not signed in");return}if(i.length<mf){m(`Password must be at least ${mf} characters`);return}if(i!==c){m("The two passwords do not match");return}if(i==="changeme"){m("Choose a password different from the seed default");return}g.mutate({id:e.id,newPassword:i})};return o("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:f("div",{className:"w-full max-w-sm",children:[o("div",{className:"flex justify-center mb-8",children:o("img",{src:s?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack Admin",className:"h-12"})}),f("form",{onSubmit:b,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[f("div",{className:"space-y-1",children:[o("h1",{className:"text-sm font-semibold text-foreground",children:"Set a new password"}),o("p",{className:"text-xs text-foreground-subtle",children:t?"You must rotate the seed password before continuing.":"Choose a new password for your account."})]}),h&&o("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:h}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"New password"}),f("div",{className:"relative",children:[o("input",{"data-testid":"change-password-new",type:u?"text":"password",value:i,onChange:x=>l(x.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all",autoFocus:!0}),o("button",{type:"button",onClick:()=>p(!u),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors",tabIndex:-1,children:u?o(G0,{className:"h-4 w-4"}):o(es,{className:"h-4 w-4"})})]})]}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Confirm new password"}),o("input",{"data-testid":"change-password-confirm",type:u?"text":"password",value:c,onChange:x=>d(x.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all"})]}),o("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&&o("button",{type:"button",onClick:()=>{r(),a("/login",{replace:!0})},className:"w-full text-xs text-foreground-subtle hover:text-foreground transition-colors",children:"Sign out instead"})]})]})})}function G9(){const e=rt();return f("div",{className:"flex flex-col items-center justify-center text-foreground py-16 px-4",children:[o("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-danger/10 mb-4",children:o(CO,{className:"h-8 w-8 text-danger"})}),o("h1",{className:"text-xl font-bold",children:"Access Denied"}),o("p",{className:"mt-2 text-sm text-foreground-subtle",children:"You don't have permission to access this page."}),o("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 wv="camstack:dashboard-layout",Qi={version:1,widgets:[]};function K9(){try{const e=localStorage.getItem(wv);if(!e)return Qi;const t=JSON.parse(e);return t&&t.version===1&&Array.isArray(t.widgets)?{version:1,widgets:t.widgets}:Qi}catch{return Qi}}function W9(e){try{localStorage.setItem(wv,JSON.stringify(e))}catch{}}function Y9(){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 Z9(){const[e,t]=_(K9),[n,r]=_(!1),s=Uy(),a=H(()=>s.filter(d=>d.hosts.includes("dashboard")),[s]),i=U(d=>{t(d),W9(d)},[]),l=U(d=>{i({version:1,widgets:[...e.widgets,d]})},[e,i]),c=U(d=>{i({version:1,widgets:e.widgets.filter(u=>u.instanceId!==d)})},[e,i]);return f("div",{className:"p-4",children:[f("div",{className:"flex items-center justify-between mb-4",children:[o("h1",{className:"text-lg font-semibold text-foreground",children:"Dashboard"}),f("button",{onClick:()=>r(!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:[o(Et,{className:"h-3.5 w-3.5"}),"Add widget"]})]}),e.widgets.length===0?o(X9,{onAdd:()=>r(!0)}):o("div",{className:"grid grid-cols-12 gap-3 auto-rows-[minmax(80px,_auto)]",children:e.widgets.map(d=>o(J9,{entry:d,onRemove:()=>c(d.instanceId)},d.instanceId))}),n&&o(t7,{widgets:a,onClose:()=>r(!1),onAdd:d=>{l(d),r(!1)}})]})}function X9({onAdd:e}){return f("div",{className:"flex flex-col items-center justify-center py-24 text-foreground-subtle",children:[o("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-surface border border-border mb-4",children:o(Y0,{className:"h-8 w-8 text-foreground-subtle/40"})}),o("p",{className:"text-sm font-medium text-foreground/70",children:"Your dashboard is empty"}),o("p",{className:"text-xs text-foreground-subtle mt-1 mb-4",children:"Add widgets to monitor your cameras and system"}),f("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:[o(Et,{className:"h-3.5 w-3.5"}),"Add your first widget"]})]})}function J9({entry:e,onRemove:t}){const n=e7(e.columns),r=Math.max(1,Math.min(12,e.rows));return f("div",{className:"relative group rounded-lg border border-border bg-surface overflow-hidden flex flex-col",style:{gridColumn:`span ${n} / span ${n}`,gridRow:`span ${r} / span ${r}`},children:[o("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:o(Fe,{className:"h-3 w-3"})}),o("div",{className:"flex-1 min-h-0 overflow-auto p-2",children:o(ft,{widgetId:e.widgetId,host:"dashboard",instanceId:e.instanceId,config:e.config,deviceId:e.deviceId,size:e.size,columns:e.columns,rows:e.rows})})]})}function e7(e){return!Number.isFinite(e)||e<1?6:Math.min(12,Math.floor(e))}function t7({widgets:e,onClose:t,onAdd:n}){const[r,s]=_(null);return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:t,children:f("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:[f("div",{className:"flex items-center justify-between mb-4",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:r?`Configure: ${r.label}`:"Add widget"}),o("button",{onClick:t,className:"p-1 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",children:o(Fe,{className:"h-4 w-4"})})]}),r===null?o(n7,{widgets:e,onSelect:s}):o(r7,{widget:r,onCancel:()=>s(null),onAdd:n})]})})}function n7({widgets:e,onSelect:t}){return e.length===0?o("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."}):o("div",{className:"grid grid-cols-2 gap-2 max-h-96 overflow-auto",children:e.map(n=>f("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:[o("span",{className:"text-xs font-medium text-foreground block",children:n.label}),o("span",{className:"text-[10px] text-foreground-subtle truncate",title:n.widgetId,children:n.widgetId}),n.description&&o("span",{className:"text-[10px] text-foreground-subtle mt-1 line-clamp-2",children:n.description})]},n.widgetId))})}function r7({widget:e,onCancel:t,onAdd:n}){const[r,s]=_(e.defaultSize),[a,i]=_(e.defaultColumns),[l,c]=_(e.defaultRows),[d,u]=_(null),{data:p}=Bn({},{enabled:e.requires.deviceContext,staleTime:3e4}),h=!e.requires.deviceContext||d!==null&&d>0,m=()=>{if(!h)return;const g={instanceId:Y9(),widgetId:e.widgetId,size:r,columns:a,rows:l,...e.requires.deviceContext&&d!==null?{deviceId:d}:{}};n(g)};return f("div",{className:"space-y-3",children:[f("div",{children:[o("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:"Size"}),o("div",{className:"flex items-center gap-1",children:e.allowedSizes.map(g=>o("button",{onClick:()=>s(g),className:`px-3 py-1 rounded-md text-[11px] font-medium border transition-colors ${r===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))})]}),f("div",{className:"grid grid-cols-2 gap-3",children:[o(gf,{label:"Columns (1-12)",value:a,min:1,max:12,onChange:i}),o(gf,{label:"Rows (1-12)",value:l,min:1,max:12,onChange:c})]}),e.requires.deviceContext&&f("div",{children:[o("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:"Device"}),f("select",{value:d??"",onChange:g=>u(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:[o("option",{value:"",children:"— select a device —"}),(p??[]).map(g=>f("option",{value:g.id,children:[g.name??g.stableId," (#",g.id,")"]},g.id))]})]}),f("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-border",children:[o("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"}),o("button",{disabled:!h,onClick:m,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 gf({label:e,value:t,min:n,max:r,onChange:s}){return f("div",{children:[o("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:e}),o("input",{type:"number",min:n,max:r,value:t,onChange:a=>{const i=Number(a.target.value);Number.isFinite(i)&&s(Math.max(n,Math.min(r,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 o7(){return o(Z9,{})}function tt({icon:e,title:t,subtitle:n,actions:r,children:s}){const a=!!t||n!=null||r!=null;return f("div",{className:"p-4 space-y-4",children:[a&&f("div",{className:"flex items-center justify-between gap-4",children:[f("div",{className:"min-w-0",children:[t&&f("h1",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e&&o(e,{className:"h-4 w-4 text-foreground-subtle"}),t]}),n&&o("p",{className:"text-xs text-foreground-subtle mt-0.5",children:n})]}),r&&o("div",{className:"shrink-0 flex items-center gap-2",children:r})]}),s]})}const bf=["camera","hub","nvr","light","siren","switch","sensor","thermostat","button","generic"];function s7(){const{t:e}=Vt(),t=rt(),n=Te();St(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]),St(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped"]);const{data:r}=Bn({},{staleTime:3e4}),{data:s}=pd(void 0,{staleTime:3e4}),a=H(()=>r??[],[r]),{activeDevices:i,orphanDevices:l}=H(()=>{const m=new Set((s??[]).map(k=>k.addonId)),g=k=>typeof k.addonId=="string"&&k.addonId.length>0&&!m.has(k.addonId),b=new Set;for(const k of a)g(k)&&b.add(k.id);const x=new Set(b),y=new Map;for(const k of a)y.set(k.id,k);const w=(k,C=0)=>{if(C>32)return!1;if(b.has(k.id))return!0;if(k.parentDeviceId==null)return!1;const E=y.get(k.parentDeviceId);return E?w(E,C+1):!1};for(const k of a)w(k)&&x.add(k.id);const v=[],N=[];for(const k of a)x.has(k.id)?N.push(k):v.push(k);return{activeDevices:v,orphanDevices:N}},[a,s]),c=H(()=>{const m=new Map;for(const g of a)m.set(g.id,{id:g.id,name:g.name??g.stableId??`#${String(g.id)}`});return m},[a]),d=U(m=>c.get(m)??null,[c]),u=H(()=>(s??[]).map(m=>({id:m.addonId,name:m.name??m.addonId,icon:o(gn,{type:m.addonId,size:"sm"})})),[s]),p=U(m=>o(gn,{type:m,size:"sm"}),[]),h=U(m=>t(`/devices/${String(m)}`),[t]);return f(tt,{icon:Dr,title:e("nav.devices","Devices"),children:[o(Ao,{devices:i,trpc:n.trpcClient,filters:{types:bf,addons:u},resolveIntegrationIcon:p,resolveParent:d,onNavigate:h}),l.length>0&&f("div",{className:"mt-6 space-y-2",children:[f("div",{className:"flex items-baseline gap-2",children:[o(it,{className:"h-3.5 w-3.5 text-warning shrink-0"}),o("h2",{className:"text-sm font-semibold text-foreground",children:"Orphan devices"}),f("span",{className:"text-[10px] text-foreground-subtle",children:[l.length," device",l.length===1?"":"s"," pointing at integrations no longer registered"]})]}),f("div",{className:"rounded-lg border border-warning/30 bg-warning/5 p-2",children:[o("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."}),o(Ao,{devices:l,trpc:n.trpcClient,filters:{types:bf,addons:u},urlScope:"nested",lsKey:"devices:orphan",resolveIntegrationIcon:p,resolveParent:d,onNavigate:h})]})]})]})}function a7({onSelect:e,onClose:t,pendingAddonId:n=null}){const{t:r}=Vt(),s=rt(),{data:a,isLoading:i}=px();if(i)return o("div",{className:"space-y-2 p-2",children:[1,2,3].map(c=>o("div",{className:"h-14 rounded-lg bg-surface animate-pulse"},c))});const l=n!==null;return f("div",{className:"space-y-2",children:[(a??[]).map(c=>{const d=c.instanceMode==="unique"&&c.existingInstances.length>0,u=n===c.addonId,p=l;return f("button",{disabled:p,onClick:()=>{if(!p)if(d){const h=c.existingInstances[0].id;t(),s(`/integrations/${h}`)}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?o("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0",style:{backgroundColor:`${c.color}15`},children:o("img",{src:c.iconUrl,alt:"",className:"h-5 w-5"})}):o("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0",style:{backgroundColor:`${c.color}15`},children:o("span",{className:"text-sm",style:{color:c.color},children:"◉"})}),f("div",{className:"flex-1 min-w-0",children:[o("p",{className:"text-xs font-semibold text-foreground",children:c.name}),c.description&&o("p",{className:"text-[10px] text-foreground-subtle mt-0.5 truncate",children:c.description})]}),u?o(Se,{className:"h-4 w-4 animate-spin text-primary flex-shrink-0"}):d?f("span",{className:"flex items-center gap-1 text-[10px] font-medium text-foreground-subtle",children:[o(Jt,{className:"h-3 w-3"}),r("integrations.manage")]}):o(wt,{className:"h-4 w-4 text-foreground-subtle flex-shrink-0"})]},c.addonId)}),(a??[]).length===0&&o("div",{className:"py-8 text-center text-xs text-foreground-subtle",children:r("integrations.noProviders")})]})}function i7(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function xf(e,t){if(e!==void 0)return t&&i7(e)?t(e):e}function l7({section:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,probeResults:i,onAction:l}){const[c,d]=_(e.defaultCollapsed??!1),u=e.style==="accordion";if(e.fields.reduce((b,x)=>b+(Nd(x,t,e.fields)?1:0),0)===0)return null;const h=e.columns??2,m=h===1?"grid-cols-1":h===3?"grid-cols-1 @[420px]:grid-cols-2 @[680px]:grid-cols-3":h===4?"grid-cols-1 @[420px]:grid-cols-2 @[900px]:grid-cols-4":"grid-cols-1 @[480px]:grid-cols-2",g=!e.title&&!e.description;return f("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[!g&&f("div",{className:["flex items-center justify-between mb-2",u?"cursor-pointer":""].join(" "),onClick:u?()=>d(b=>!b):void 0,children:[f("div",{children:[e.title&&o("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:xf(e.title,s)}),e.description&&o("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:xf(e.description,s)})]}),u&&o("span",{className:"text-foreground-subtle text-xs ml-2",children:c?"▸":"▾"})]}),!c&&o("div",{className:`grid ${m} gap-x-3 gap-y-2.5`,children:e.fields.map(b=>o(gr,{field:b,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,externalProbe:i?.[b.key],allFields:e.fields,onAction:l},b.key))})]})}function Dn({schema:e,values:t,onChange:n,disabled:r,translationFn:s,onTestField:a,probeResults:i,onClearProbe:l,onAction:c}){const d=(u,p)=>{n({...t,[u]:p}),l?.(u)};return o("div",{className:"space-y-4",children:e.sections.map((u,p)=>o(l7,{section:u,values:t,onChange:d,disabled:r,translationFn:s,onTestField:a,probeResults:i,onAction:c},`${u.id}-${p}`))})}function c7({addonId:e,configSchema:t,onSave:n,onBack:r}){const{t:s}=Vt(),[a,i]=_(""),[l,c]=_({}),[d,u]=_(null),p=fx({onSuccess:h=>u(h),onError:h=>u({success:!1,error:String(h)})});return f("div",{className:"space-y-4",children:[f("div",{children:[o("label",{className:"block text-[11px] font-medium text-foreground mb-1",children:s("integrations.integrationName")}),o("input",{type:"text",value:a,onChange:h=>i(h.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&&o(Dn,{schema:t,values:l,onChange:c}),d&&o("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}`}),f("div",{className:"flex items-center justify-between pt-2",children:[o("button",{onClick:r,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")}),f("div",{className:"flex items-center gap-2",children:[o("button",{onClick:()=>p.mutate({addonId:e,settings:l}),disabled:p.isPending,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:p.isPending?s("integrations.testing"):s("integrations.testConnection")}),o("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 d7({providerId:e,onImport:t,onSkip:n}){const{t:r}=Vt(),[s,a]=_(new Set),i=dd(),l=i.data,c=i.isPending||!i.data&&!i.isError;Y(()=>{e&&(i.isPending||i.data||i.mutate({addonId:e}))},[e,i]);function d(p){a(h=>{const m=new Set(h);return m.has(p)?m.delete(p):m.add(p),m})}if(c)return f("div",{className:"flex flex-col items-center py-12",children:[o("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"}),o("p",{className:"mt-3 text-xs text-foreground-subtle",children:r("integrations.searchingDevices")})]});const u=l??[];return f("div",{className:"space-y-4",children:[o("p",{className:"text-xs text-foreground-subtle",children:u.length>0?r("integrations.foundDevices",{count:u.length}):r("integrations.noDevicesFound")}),u.length>0&&o("div",{className:"space-y-1.5 max-h-64 overflow-y-auto",children:u.map(p=>{const h=p.stableId,m=p.suggestedName??h,g=s.has(h);return f("button",{onClick:()=>d(h),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:[o("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&&o(_t,{className:"h-3 w-3 text-primary-foreground"})}),o(Dr,{className:"h-3.5 w-3.5 text-foreground-subtle flex-shrink-0"}),o("span",{className:"text-xs font-medium text-foreground truncate",children:m})]},h)})}),f("div",{className:"flex items-center justify-between pt-2",children:[o("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:r("integrations.skip")}),u.length>0&&f("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:[r("integrations.importSelected")," (",s.size,")"]})]})]})}function u7(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 r=n,{value:s,...a}=r;return a};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(n=>({...n,fields:n.fields.map(t)}))}}function p7({open:e,onClose:t}){const{t:n}=Vt(),r=rt(),s=ke(),[a,i]=_("picker"),[l,c]=_(null),[d,u]=_(null),[p,h]=_("manual"),{data:m}=sd({addonId:l??"",nodeId:"hub"},{enabled:l!=null}),g=H(()=>m?u7(m):null,[m]),b=cx({onSuccess:()=>s.invalidateQueries({queryKey:[["integrations"]]})}),x=dd(),y=x.data;Y(()=>{a!=="discovery"||!d||!l||x.isPending||x.data||x.mutate({addonId:l})},[a,d,l,x]);const w=ox({onSuccess:()=>s.invalidateQueries({queryKey:[["deviceManager"]]})});async function v(R,M,D,T){if(!b.isPending){if(c(R),h(D),M==="unique"){try{const L=await b.mutateAsync({addonId:R,name:T,settings:{}});t(),E(),r(`/integrations/${L.id}`)}catch{}return}i("config")}}async function N(R){if(l)try{const M=await b.mutateAsync({addonId:l,name:R.name,settings:R.config});u(M.id),p==="auto"||p==="both"?i("discovery"):C(M.id)}catch{}}async function k(R){if(l){for(const M of R){const D=y?.find(T=>T.stableId===M);D&&await w.mutateAsync({addonId:l,candidate:D})}C()}}function C(R){const M=R??d??l;t(),E(),M&&r(`/integrations/${M}`)}function E(){i("picker"),c(null),u(null),h("manual")}function I(){t(),E()}if(!e)return null;const A={picker:n("integrations.newIntegration"),config:n("integrations.configureIntegration"),discovery:n("integrations.importDevices")},z=b.isPending,P=z?l:null,B=b.error;return f("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[o("div",{className:"absolute inset-0 bg-black/60",onClick:z?void 0:I}),f("div",{className:"relative z-10 w-full max-w-lg rounded-xl border border-border bg-background shadow-2xl",children:[f("div",{className:"flex items-center justify-between border-b border-border px-5 py-4",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:A[a]}),o("button",{onClick:I,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:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"relative px-5 py-4",children:[B&&!z&&o("div",{className:"mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:B instanceof Error?B.message:String(B)}),a==="picker"&&o(a7,{onSelect:v,onClose:I,pendingAddonId:P}),a==="config"&&l&&o(c7,{addonId:l,configSchema:g??null,onSave:N,onBack:()=>i("picker")}),a==="discovery"&&d&&o(d7,{providerId:d,onImport:k,onSkip:C}),z&&f("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background/85 backdrop-blur-sm",children:[o(Se,{className:"h-6 w-6 animate-spin text-primary"}),o("p",{className:"text-xs font-medium text-foreground",children:n("integrations.creating",{defaultValue:"Creating integration…"})}),o("p",{className:"text-[10px] text-foreground-subtle",children:n("integrations.creatingHint",{defaultValue:"Waiting for the addon to restart and register"})})]})]})]})]})}const yf={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 ti({status:e}){const t=yf[e]??yf.stopped;return f("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:[o("span",{className:`h-1.5 w-1.5 rounded-full ${t.dot}`}),t.label]})}const Gi="px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle";function f7({integrations:e,expandedAddonId:t,onToggleExpand:n,onOpenSettings:r,renderExpanded:s}){const a=U(i=>n(i),[n]);return o("div",{className:"overflow-hidden rounded-lg border border-border bg-surface",children:f("table",{className:"w-full table-fixed text-xs",children:[o("thead",{className:"bg-surface-hover/40",children:f("tr",{children:[o("th",{className:K(Gi,"w-[60%]"),children:"Integration"}),o("th",{className:K(Gi,"w-[15%]"),children:"Devices"}),o("th",{className:K(Gi,"w-[25%]"),children:"Status"})]})}),o("tbody",{children:e.map(i=>{const l=t===i.addonId;return o(h7,{integration:i,isExpanded:l,onClick:a,onOpenSettings:r,renderExpanded:s},i.id)})})]})})}function h7({integration:e,isExpanded:t,onClick:n,onOpenSettings:r,renderExpanded:s}){const a=U(c=>{c.stopPropagation(),r(e.id)},[e.id,r]),i=U(()=>{n(e.addonId)},[e.addonId,n]),l=U(c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),i())},[i]);return f(me,{children:[f("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:[o("td",{className:"px-3 py-2.5",children:f("div",{className:"flex items-center gap-2.5",children:[t?o(lt,{className:"h-3.5 w-3.5 flex-shrink-0 text-foreground-subtle"}):o(wt,{className:"h-3.5 w-3.5 flex-shrink-0 text-foreground-subtle"}),o(gn,{type:e.addonId,size:"sm"}),f("div",{className:"flex min-w-0 flex-col",children:[o("span",{className:"truncate text-xs font-semibold text-foreground",children:e.name}),o("span",{className:"truncate text-[10px] text-foreground-subtle",children:e.addonId})]})]})}),f("td",{className:"px-3 py-2.5 text-[11px] text-foreground-subtle",children:[e.deviceCount," device",e.deviceCount!==1?"s":""]}),o("td",{className:"px-3 py-2.5",children:f("div",{className:"flex items-center justify-between gap-2",children:[o(ti,{status:e.status}),f("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:[o(Jt,{className:"h-3 w-3"}),"Settings"]})]})})]}),t&&o("tr",{className:"border-t border-border bg-surface",children:o("td",{colSpan:3,className:"px-3 py-3",children:s(e.addonId)})})]})}function m7(e){if(!e.enabled)return"disabled";switch(e.processState){case"running":return"running";case"stopped":case"crashed":case"unknown":default:return"stopped"}}const Cs="expand";function g7(){const{t:e}=Vt(),t=rt(),n=Te(),[r]=Ga(),[s,a]=_(!1),i=U(()=>a(!0),[]),l=U(()=>a(!1),[]);St(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped","addon.updated"]),St(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]);const{data:c,isLoading:d,refetch:u}=pd(void 0,{staleTime:3e4}),{data:p,isLoading:h,refetch:m}=Bn({},{staleTime:3e4}),g=H(()=>p??[],[p]),b=H(()=>c??[],[c]),x=H(()=>{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]),y=H(()=>{const R=new Map;for(const M of g){if(M.parentDeviceId!==null&&M.parentDeviceId!==void 0&&!!M.role)continue;const T=M.addonId??"";T&&R.set(T,(R.get(T)??0)+1)}return R},[g]),w=H(()=>b.map(R=>({id:R.id,addonId:R.addonId,name:R.name,enabled:R.enabled,status:m7(R),deviceCount:y.get(R.addonId)??0})),[b,y]),v=r.get(Cs),N=U(R=>{const M=new URLSearchParams(window.location.search);M.get(Cs)===R?M.delete(Cs):M.set(Cs,R);const T=M.toString(),L=`${window.location.pathname}${T?`?${T}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",L),window.dispatchEvent(new PopStateEvent("popstate"))},[]),k=U(R=>t(`/integrations/${R}`),[t]),C=U(R=>x.get(R)??null,[x]),E=U(R=>o(gn,{type:R,size:"sm"}),[]),I=U(R=>t(`/devices/${String(R)}`),[t]),A=U(R=>o(Ao,{devices:g,trpc:n.trpcClient,forceAddon:R,urlScope:"nested",lsKey:`integrations:nested:${R}`,resolveIntegrationIcon:E,resolveParent:C,onNavigate:I}),[g,n.trpcClient,E,C,I]),z=U(()=>{u(),m()},[u,m]),P=d||h,B=b.length>0;return f(tt,{icon:_o,title:e("nav.integrations","Integrations"),actions:f(me,{children:[o("button",{onClick:z,disabled:P,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:o(ct,{className:K("h-3.5 w-3.5",P&&"animate-spin")})}),f("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:[o(Et,{className:"h-3.5 w-3.5"}),"New Integration"]})]}),children:[P&&o("div",{className:"space-y-2",children:[1,2,3].map(R=>o("div",{className:"h-12 rounded-lg border border-border bg-surface animate-pulse"},R))}),!P&&!B&&f("div",{className:"flex flex-col items-center py-20 text-foreground-subtle",children:[o("p",{className:"text-sm",children:"No integrations configured."}),o("p",{className:"text-xs mt-1",children:'Click "New Integration" to connect cameras and devices.'})]}),!P&&B&&o(f7,{integrations:w,expandedAddonId:v,onToggleExpand:N,onOpenSettings:k,renderExpanded:A}),o(p7,{open:s,onClose:l})]})}function Nv(e){const t=[];for(const n of e)n.type==="probe"&&t.push(n.key),n.type==="group"&&"fields"in n&&t.push(...Nv(n.fields));return t}function b7(e,t,n){const[r,s]=_("idle"),[a,i]=_({}),l=H(()=>{const p=[];for(const h of e.sections)p.push(...Nv(h.fields));return p},[e]),c=l.length>0&&n!==void 0,d=U(p=>{i(h=>{if(!h[p])return h;const m={...h};return delete m[p],m})},[]),u=U(async()=>{if(!n)return;const p=l.filter(b=>{const x=t[b];return x!=null&&String(x).trim()!==""});if(p.length===0)return;s("testing");const h={};for(const b of p)h[b]={status:"probing"};i(h);const m=await Promise.allSettled(p.map(async b=>{try{const x=await n(b,t[b]);return{key:b,result:x}}catch(x){const w={status:"error",error:x instanceof Error?x.message:String(x)};return{key:b,result:w}}})),g={};for(const b of m)if(b.status==="fulfilled"){const{key:x,result:y}=b.value;g[x]={status:y.status==="ok"?"ok":"error",result:y}}i(g),s("idle")},[n,l,t]);return{testAllStatus:r,hasProbeFields:c,probeResults:a,handleTestAll:u,clearProbeResult:d}}function kv(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(...kv(n.fields));return t}function Ki(e){return e==null?!0:typeof e=="string"?e.trim()==="":!1}function Xl(e,t={}){for(const n of e){if(n.type==="group"&&"fields"in n){Xl(n.fields,t);continue}"key"in n&&n.key&&"default"in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function vf(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function x7({open:e,integrationId:t,addonId:n,onClose:r}){const{t:s}=Vt(),a=ke(),[i,l]=_({}),[c,d]=_(!1),[u,p]=_(null),[h,m]=_(vf),g=sx({addonId:n,type:pt.Camera},{enabled:e}),b=g.data??null;Y(()=>{if(e){const M=b?Xl(b.sections.flatMap(D=>D.fields)):{};l(M),m(vf()),d(!1),p(null)}},[e,t,b]);const x=H(()=>({...i,_probeRequestId:h}),[i,h]),y=ax({onSuccess:()=>{a.invalidateQueries({queryKey:[["deviceManager"]]})}}),w=ud(),v=U(async(M,D)=>{d(!0);const T=await w.mutateAsync({addonId:n,type:pt.Camera,key:M,value:D,formValues:x});return T.status==="ok"&&T.suggestedValues&&l(L=>{let O=!1;const F={...L};for(const[j,V]of Object.entries(T.suggestedValues??{}))Ki(L[j])&&!Ki(V)&&(F[j]=V,O=!0);return O?F:L}),T},[w,n,x]),{testAllStatus:N,hasProbeFields:k,probeResults:C,handleTestAll:E,clearProbeResult:I}=b7(b??{sections:[]},i,v);async function A(M){p(null);try{if(await y.mutateAsync({addonId:n,type:pt.Camera,config:i}),M){const D=b?Xl(b.sections.flatMap(T=>T.fields)):{};l(D)}else r()}catch(D){p(D instanceof Error?D.message:String(D))}}if(!e)return null;const P=kv((b?.sections??[]).flatMap(M=>M.fields)).filter(M=>Ki(i[M])),B=P.length===0,R=!g.isLoading&&(g.isError||b===null);return f("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[o("div",{className:"absolute inset-0 bg-black/60",onClick:r}),f("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:[f("div",{className:"flex items-center justify-between border-b border-border px-5 py-4 shrink-0",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:s("integrations.addDevice")}),o("button",{onClick:r,className:"rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:o(Fe,{className:"h-4 w-4"})})]}),o("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-3",children:g.isLoading?o("div",{className:"flex items-center justify-center py-8",children:o(Se,{className:"h-5 w-5 animate-spin text-primary"})}):R?f("div",{className:"flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3",children:[o(it,{className:"h-4 w-4 text-destructive mt-0.5 shrink-0"}),f("div",{className:"space-y-1",children:[o("p",{className:"text-xs font-medium text-destructive",children:"Provider unavailable"}),f("p",{className:"text-xs text-foreground-subtle",children:["The addon ",o("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."]})]})]}):o(Dn,{schema:b,values:i,onChange:l,onTestField:v,probeResults:C,onClearProbe:I})}),!R&&!g.isLoading&&f("div",{className:"border-t border-border bg-surface/50 shrink-0",children:[f("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:[f("span",{className:"flex items-center gap-2",children:[o(at,{className:"h-3.5 w-3.5"}),"Test logs",o("span",{className:"font-mono text-[9px] opacity-60",children:h.slice(0,14)})]}),o(lt,{className:`h-3.5 w-3.5 transition-transform ${c?"rotate-180":""}`})]}),c&&o("div",{className:"border-t border-border max-h-64 overflow-hidden",children:o(tn,{addonId:n,requestId:h,limit:50,maxHeight:"max-h-64",showFilters:!1,showScope:!1,className:"border-0 rounded-none"})})]}),!R&&!g.isLoading&&(u||P.length>0)&&o("div",{className:"border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0",children:f("div",{className:"flex items-start gap-2",children:[o(it,{className:"h-3.5 w-3.5 text-destructive mt-0.5 shrink-0"}),o("p",{className:"text-[11px] text-destructive",children:u||`Required: ${P.join(", ")}`})]})}),f("div",{className:"flex items-center justify-between border-t border-border px-5 py-3 shrink-0",children:[f("div",{className:"flex items-center gap-2",children:[o("button",{onClick:r,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&&f("button",{type:"button",onClick:E,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"?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(or,{className:"h-3.5 w-3.5"}),"Test All"]})]}),f("div",{className:"flex items-center gap-2",children:[o("button",{onClick:()=>A(!0),disabled:R||!B||y.isPending,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:s("integrations.saveAndNew")}),o("button",{onClick:()=>A(!1),disabled:R||!B||y.isPending,className:"rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:y.isPending?s("integrations.saving"):s("integrations.save")})]})]})]})]})}function y7(){const{t:e}=Vt(),{integrationId:t}=zd(),n=ke(),r=rt(),s=Te(),[a,i]=_(!1),[l,c]=_(!1),[d,u]=_(!1),[p,h]=_(!1),{data:m,isLoading:g}=ix({id:t??""},{enabled:!!t}),{data:b}=sd({addonId:m?.addonId??"",nodeId:"hub"},{enabled:!!m?.addonId}),x=b!=null&&Array.isArray(b.sections)&&b.sections.some(B=>B.fields.length>0),{data:y}=Bn({},{refetchInterval:5e3}),w=[["integrations","get"],{input:{id:t??""},type:"query"}],v=dx({onMutate:async B=>{await n.cancelQueries({queryKey:w});const R=n.getQueryData(w);return R!=null&&n.setQueryData(w,{...R,enabled:B.enabled}),{previous:R}},onError:(B,R,M)=>{const D=M;D?.previous!=null&&n.setQueryData(w,D.previous)},onSettled:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),N=ux({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]}),u(!1),r("/integrations")}}),k=Ko({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),C=H(()=>y??[],[y]),E=H(()=>{const B=new Map;for(const R of C)B.set(R.id,{id:R.id,name:R.name??R.stableId??`#${String(R.id)}`});return B},[C]),I=U(B=>E.get(B)??null,[E]),A=U(B=>o(gn,{type:B,size:"sm"}),[]),z=U(B=>r(`/devices/${String(B)}`),[r]),P=H(()=>{const B=m?.addonId;if(!B)return 0;let R=0;for(const M of C)M.addonId!==B||M.parentDeviceId!==null&&M.parentDeviceId!==void 0&&M.role||(R+=1);return R},[C,m?.addonId]);return g?f("div",{className:"p-4",children:[o("div",{className:"h-16 rounded-lg bg-surface animate-pulse mb-4"}),o("div",{className:"h-40 rounded-lg bg-surface animate-pulse"})]}):m?f("div",{className:"p-4 space-y-4",children:[o(Hc,{items:[{label:"Integrations",onClick:()=>r("/integrations")},{label:m.name}]}),f("div",{className:"flex items-center justify-between",children:[f("div",{className:"flex items-center gap-3",children:[o("img",{src:`/api/addon-assets/${m.addonId}/assets/icon.svg`,alt:"",className:"h-8 w-8 rounded-lg",onError:B=>{B.target.style.display="none"}}),f("div",{children:[o("h1",{className:"text-lg font-semibold text-foreground",children:m.name}),f("p",{className:"text-[11px] text-foreground-subtle mt-0.5",children:[m.addonId," · ",P," ",e("integrations.devices")]})]})]}),f("div",{className:"flex items-center gap-3",children:[f("div",{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${v.isPending?"opacity-60":""} ${m.enabled?"border-success/30 bg-success/5":"border-border bg-surface"}`,title:e("integrations.toggleHint",{defaultValue:"Click to toggle"}),children:[o(Oc,{checked:m.enabled,onCheckedChange:B=>v.mutate({id:t,enabled:B}),disabled:v.isPending,"aria-label":m.enabled?"Disable integration":"Enable integration"}),o("span",{className:`text-[11px] font-medium ${m.enabled?"text-success":"text-foreground-subtle"}`,children:m.enabled?"Enabled":"Disabled"}),v.isPending&&o(Se,{className:"h-3 w-3 animate-spin text-foreground-subtle"})]}),x&&f("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:[o(Jt,{className:"h-3 w-3"}),e("integrations.config")]}),f("button",{onClick:()=>h(!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:[o(at,{className:"h-3 w-3"}),e("integrations.logs",{defaultValue:"Logs"})]}),o(Ad,{label:"Restart",icon:ct,title:`Restart "${m.name}"?`,description:`Restarting the addon will briefly disconnect every device backed by it (${P} active). Streams will reconnect automatically.`,confirmLabel:"Restart",triggerVariant:"outline",confirmVariant:"danger",disabled:k.isPending,action:()=>k.mutateAsync({addonId:m.addonId})}),f("button",{onClick:()=>u(!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:[o(Ze,{className:"h-3 w-3"}),e("integrations.delete",{defaultValue:"Delete"})]})]})]}),o(Ao,{devices:C,trpc:s.trpcClient,defaultView:"cards",forceAddon:m.addonId,urlScope:"root",lsKey:`integration-detail:${m.addonId}`,resolveIntegrationIcon:A,resolveParent:I,onNavigate:z}),o("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:o(Et,{className:"h-5 w-5 text-primary-foreground"})}),a&&t&&o(x7,{open:a,integrationId:t,addonId:m.addonId,onClose:()=>i(!1)}),l&&o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>c(!1),children:f("div",{className:"rounded-xl border border-border bg-surface p-6 shadow-xl w-80",onClick:B=>B.stopPropagation(),children:[o("h2",{className:"text-sm font-semibold text-foreground mb-2",children:e("integrations.providerConfig")}),o("p",{className:"text-[11px] text-foreground-subtle",children:e("integrations.configComingSoon")}),o("button",{onClick:()=>c(!1),className:"mt-4 w-full rounded-lg bg-primary px-3 py-1.5 text-[11px] text-primary-foreground hover:bg-primary/90 transition-colors",children:"Close"})]})}),p&&o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onClick:()=>h(!1),children:f("div",{className:"flex flex-col rounded-xl border border-border bg-surface shadow-xl w-full max-w-5xl h-[80vh]",onClick:B=>B.stopPropagation(),children:[f("div",{className:"flex items-center justify-between border-b border-border px-4 py-2.5",children:[f("div",{className:"flex items-center gap-2 min-w-0",children:[o(at,{className:"h-4 w-4 text-primary shrink-0"}),o("h2",{className:"text-sm font-semibold text-foreground truncate",children:m.name}),f("span",{className:"text-[10px] text-foreground-subtle font-mono truncate",children:[m.addonId,t?` · ${t}`:""]})]}),o("button",{onClick:()=>h(!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:o(Fe,{className:"h-4 w-4"})})]}),o("div",{className:"flex-1 min-h-0 overflow-hidden",children:o(tn,{addonId:m.addonId,limit:200,maxHeight:"max-h-full",showScope:!1,className:"h-full border-0 rounded-none"})})]})}),d&&o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>!N.isPending&&u(!1),children:f("div",{className:"rounded-xl border border-border bg-background p-5 shadow-2xl w-96 space-y-3",onClick:B=>B.stopPropagation(),children:[f("div",{className:"flex items-start gap-3",children:[o("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-danger/10 shrink-0",children:o(it,{className:"h-4 w-4 text-danger"})}),f("div",{className:"min-w-0",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:e("integrations.deleteTitle",{defaultValue:"Delete integration?"})}),o("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:m.name,count:P})})]})]}),N.error&&o("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)}),f("div",{className:"flex items-center justify-end gap-2 pt-1",children:[o("button",{onClick:()=>u(!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"})}),o("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?f(me,{children:[o(Se,{className:"h-3 w-3 animate-spin"}),e("integrations.deleting",{defaultValue:"Deleting…"})]}):f(me,{children:[o(Ze,{className:"h-3 w-3"}),e("integrations.confirmDelete",{defaultValue:"Delete integration"})]})})]})]})})]}):f("div",{className:"flex flex-col items-center justify-center py-20 px-6 text-center gap-4",children:[o("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10",children:o(gO,{className:"h-6 w-6 text-foreground-subtle"})}),f("div",{className:"space-y-1 max-w-sm",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:e("integrations.integrationNotFound",{defaultValue:"Integration not found"})}),o("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??""})})]}),f("button",{onClick:()=>r("/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:[o(Qd,{className:"h-3 w-3"}),e("integrations.backToList",{defaultValue:"Back to integrations"})]})]})}function v7({label:e,color:t,title:n,style:r}){return f("div",{className:"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 z-10 group cursor-pointer",style:r,title:n,children:[o("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&&o("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:f("div",{className:"bg-surface border border-border rounded px-2 py-1 text-[10px] text-foreground whitespace-nowrap shadow-lg",children:[o("span",{className:"inline-block h-1.5 w-1.5 rounded-full mr-1 align-middle",style:{backgroundColor:t}}),e]})})]})}const Wi=36e5;function w7(e){return String(e).padStart(2,"0")}function N7(e){const t=new Date(e);return`${w7(t.getHours())}:00`}function k7({startMs:e,endMs:t,segments:n,events:r,playheadMs:s,onSeek:a}){const i=te(null),l=t-e,c=U(m=>Math.max(0,Math.min(100,(m-e)/l*100)),[e,l]);function d(m){if(!i.current)return;const g=i.current.getBoundingClientRect(),b=Math.max(0,Math.min(1,(m.clientX-g.left)/g.width));a(Math.round(e+b*l))}const u=[],p=Math.floor(e/Wi),h=Math.ceil(t/Wi);for(let m=p;m<=h;m++){const g=m*Wi;g<e||g>t||u.push({percent:c(g),label:N7(g)})}return f("div",{className:"select-none",children:[o("div",{className:"relative h-5 mb-1",children:u.map(({percent:m,label:g})=>o("span",{className:"absolute -translate-x-1/2 text-[10px] text-foreground-subtle",style:{left:`${m}%`},children:g},g))}),f("div",{ref:i,className:"relative h-8 rounded bg-surface-hover cursor-pointer overflow-hidden border border-border",onClick:d,onPointerMove:m=>{m.buttons===1&&d(m)},children:[n.map((m,g)=>{const b=c(m.startMs),x=c(m.endMs)-b;return o("div",{className:"absolute top-1 bottom-1 rounded-sm bg-success/60",style:{left:`${b}%`,width:`${Math.max(x,.1)}%`}},g)}),r.map(m=>o(v7,{label:m.label,color:m.color,title:`${m.label} — ${new Date(m.timestampMs).toLocaleTimeString()}`,style:{left:`${c(m.timestampMs)}%`}},m.id)),o("div",{className:"absolute top-0 bottom-0 w-0.5 bg-danger z-20 pointer-events-none",style:{left:`${c(s)}%`},children:o("div",{className:"absolute -top-0.5 left-1/2 -translate-x-1/2 w-2.5 h-2.5 bg-danger rotate-45"})})]})]})}const wf={person:"#f59e0b",vehicle:"#3b82f6",car:"#3b82f6",face:"#a855f7",plate:"#ec4899",animal:"#10b981",motion:"#ef4444",unknown:"#6b7280"};function Jl(e){return wf[e.toLowerCase()]??wf.unknown}function S7(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function C7(e){return new Date(e).toISOString().slice(0,10)}function M7(e){return new Date(e+"T00:00:00").getTime()}function E7(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 I7(e){const t=["person","vehicle","face","motion"];return Array.from({length:24},(n,r)=>({id:`placeholder-${r}`,timestampMs:e+Math.floor(Math.random()*24*36e5),label:t[r%t.length],color:Jl(t[r%t.length])})).sort((n,r)=>n.timestampMs-r.timestampMs)}function A7(){const{t:e}=Vt(),t=S7(new Date),[n,r]=_(t),[s,a]=_(null),[i,l]=_(t+12*36e5),c=n,d=n+24*36e5,{data:u,isLoading:p}=Bn({},{staleTime:3e4}),h=u??[],m=H(()=>h.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})),[h]),g=s??m[0]?.id??null,{data:b}=Ln({queryKey:["events",g,c],queryFn:()=>Promise.resolve(null),enabled:!!g,staleTime:6e4}),x=H(()=>{const v=Array.isArray(b)?b:(()=>{const k=Tu(b)?.events;return Array.isArray(k)?k:[]})();return v.length===0?g?I7(c):[]:v.flatMap((N,k)=>{const C=Tu(N);if(!C)return[];const E=String(C.class??C.type??C.label??"unknown").toLowerCase(),I=typeof C.timestamp=="number"?C.timestamp:c;return[{id:String(C.id??k),timestampMs:I,label:E,color:Jl(E)}]})},[b,g,c]),y=H(()=>g?E7(c):[],[g,c]);function w(v){r(N=>N+v*24*36e5),l(N=>N+v*24*36e5)}return f("div",{className:"flex flex-col h-full p-4 gap-4 overflow-hidden",children:[f("div",{className:"flex items-center justify-between gap-4 shrink-0",children:[o("h1",{className:"text-lg font-semibold text-foreground",children:e("nav.timeline","Timeline")}),f("div",{className:"flex items-center gap-2",children:[o("button",{onClick:()=>w(-1),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",children:o(Gd,{className:"h-4 w-4"})}),f("div",{className:"relative flex items-center",children:[o(H0,{className:"absolute left-2 h-3.5 w-3.5 text-foreground-subtle pointer-events-none"}),o("input",{type:"date",value:C7(n),onChange:v=>{if(v.target.value){const N=M7(v.target.value);r(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"})]}),o("button",{onClick:()=>w(1),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",disabled:n>=t,children:o(wt,{className:"h-4 w-4"})})]})]}),f("div",{className:"flex gap-1.5 shrink-0 overflow-x-auto pb-1",children:[p&&o("div",{className:"h-8 w-48 rounded-lg bg-surface animate-pulse"}),!p&&m.length===0&&o("span",{className:"text-xs text-foreground-subtle",children:"No cameras found"}),m.map(v=>{const N=v.id===g;return o("button",{onClick:()=>a(v.id),className:`shrink-0 rounded-lg px-3 py-1.5 text-[12px] font-medium transition-all border ${N?"bg-primary/12 text-primary border-primary/30":"bg-surface text-foreground-subtle border-border hover:bg-surface-hover hover:text-foreground"}`,children:v.name},v.id)})]}),f("div",{className:"relative w-full aspect-video rounded-xl border border-border bg-black shrink-0 overflow-hidden max-h-[45vh]",children:[f("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 text-foreground-subtle",children:[o(yo,{className:"h-12 w-12 opacity-20"}),o("p",{className:"text-sm opacity-50",children:g?`${m.find(v=>v.id===g)?.name??g} — seek to play`:"Select a camera"})]}),o("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()})]}),f("div",{className:"rounded-xl border border-border bg-surface px-4 pt-3 pb-4 shrink-0",children:[f("div",{className:"flex flex-wrap items-center gap-4 mb-3",children:[o("span",{className:"text-[10px] font-semibold text-foreground-subtle uppercase tracking-wider",children:"Timeline"}),f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"inline-block h-2 w-4 rounded-sm bg-success/60"}),o("span",{className:"text-[10px] text-foreground-subtle",children:"Recording"})]}),Array.from(new Set(x.map(v=>v.label))).slice(0,5).map(v=>f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{backgroundColor:Jl(v)}}),o("span",{className:"text-[10px] text-foreground-subtle capitalize",children:v})]},v))]}),g?o(k7,{startMs:c,endMs:d,segments:y,events:x,playheadMs:i,onSeek:l}):o("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 P7({selectedNodeId:e,onSelect:t,refreshToken:n}){const{data:r}=zn(void 0,{staleTime:3e4}),{data:s}=za(void 0,{staleTime:3e4}),a=new Map;for(const d of s??[])a.set(d.agentNodeId,(a.get(d.agentNodeId)??0)+1);const i=r??[],l=i.filter(d=>d.isOnline).length,c=i.filter(d=>!d.isOnline).length;return f("div",{className:"flex flex-col h-full",children:[f("button",{type:"button",onClick:()=>t(No),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===No?"bg-primary/10 text-primary":"text-foreground hover:bg-surface-hover"}`,children:[o(_n,{className:"h-4 w-4 flex-shrink-0"}),f("div",{className:"min-w-0 flex-1",children:[o("div",{className:"text-xs font-semibold truncate",children:"Cluster"}),o("div",{className:"text-[10px] text-foreground-subtle",children:"Balancer + failover + assignments"})]})]}),o("div",{className:"flex-1 overflow-y-auto",children:i.map(d=>{const u=e===d.id,p=a.get(d.id)??0,h=d.isHub?hn:bt;return f("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 ${u?"bg-primary/10 text-primary":"text-foreground hover:bg-surface-hover"}`,children:[o(h,{className:"h-4 w-4 flex-shrink-0"}),f("div",{className:"min-w-0 flex-1",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-xs font-semibold truncate",children:d.name}),d.isHub&&o("span",{className:"text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5",children:"hub"}),!d.isOnline&&o("span",{className:"h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0"}),d.isOnline&&o("span",{className:"h-1.5 w-1.5 rounded-full bg-success flex-shrink-0"})]}),f("div",{className:"text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5",children:[f("span",{children:[d.cpuCores," cores"]}),o("span",{children:"•"}),f("span",{children:[Math.round(d.memoryMB/1024)," GB"]}),p>0&&f(me,{children:[o("span",{children:"•"}),f("span",{className:"inline-flex items-center gap-0.5 text-foreground",children:[o(sv,{className:"h-2.5 w-2.5"}),p]})]})]})]})]},d.id)})}),f("div",{className:"px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between",children:[f("span",{children:[l," online"]}),c>0&&f("span",{className:"text-destructive",children:[c," offline"]})]})]})}function _7({nodeId:e,refreshToken:t}){const{data:n}=zn(void 0,{staleTime:3e4}),r=n?.find(i=>i.id===e),a=Gr("pipeline.runner-load-snapshot",i=>i.nodeId===e)?.load??null;return r?f("div",{className:"px-6 py-4 border-b border-border",children:[f("div",{className:"flex items-center gap-2 mb-1",children:[o("h2",{className:"text-base font-semibold text-foreground",children:r.name}),r.isOnline?o("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success",children:"online"}):o("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:"offline"}),r.isHub&&o("span",{className:"text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5",children:"hub"})]}),f("div",{className:"text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap",children:[o("span",{children:r.cpuModel??"CPU"}),o("span",{children:"•"}),f("span",{children:[r.cpuCores," cores"]}),o("span",{children:"•"}),f("span",{children:[Math.round(r.memoryMB/1024)," GB"]}),a&&f(me,{children:[o("span",{children:"•"}),f("span",{children:[a.attachedCameras," cameras (",a.activeCameras," active)"]}),o("span",{children:"•"}),f("span",{children:[a.avgInferenceTimeMs.toFixed(0),"ms avg inference"]}),o("span",{children:"•"}),f("span",{children:["queue ",a.queueDepthTotal]}),a.hardware.hasGpu&&f(me,{children:[o("span",{children:"•"}),o("span",{className:"text-success",children:"GPU"})]})]})]})]}):o("div",{className:"px-6 py-4 border-b border-border",children:f("div",{className:"text-xs text-foreground-subtle",children:["Node not found: ",e]})})}function Sv({refreshToken:e,nodeId:t}){const[n,r]=_(new Map),{nodes:s}=Kr();gt("pipeline.camera-metrics-snapshot",p=>{const h=p.data;typeof h?.deviceId=="number"&&r(m=>{const g=new Map(m);return g.set(h.deviceId,h),g})});const{data:a}=oy(void 0,{staleTime:5e3}),i=H(()=>{const p=new Map;for(const h of a??[])p.set(h.nodeId,h.deviceCount);return p},[a]),l=H(()=>{const p=new Map,h=Date.now()-3e4;for(const m of n.values()){if(m.timestamp<h)continue;const g=m.nodeId??"hub",b=p.get(g)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};b.attachedCameras++,m.metrics.phase==="active"&&b.activeCameras++,b.totalFps+=m.metrics.actualFps,b.totalInferenceWeighted+=m.metrics.avgInferenceTimeMs,b.queueDepth+=m.metrics.queueDepth,p.set(g,b)}return p},[n]),c=H(()=>{const p=new Map;for(const h of s)p.set(h.id,h.shortName);return p},[s]),d=H(()=>{let p=0,h=0,m=0,g=0,b=0;for(const y of l.values())p+=y.attachedCameras,h+=y.activeCameras,m+=y.totalFps,g+=y.totalInferenceWeighted,b+=y.queueDepth;const x=p>0?g/p:0;return{totalAgents:s.length,onlineAgents:s.filter(y=>y.isOnline).length,attachedCameras:p,activeCameras:h,avgInferenceTimeMs:x,queueDepth:b,totalFps:m}},[l,s]);if(t){const p=l.get(t);return f("div",{className:"@container/liveload",children:[o("h3",{className:"text-sm font-semibold text-foreground mb-2",children:"Live load"}),f("div",{className:"grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3",children:[o(Ut,{label:"FPS",value:p?p.totalFps.toFixed(1):"—"}),o(Ut,{label:"Cameras",value:p?`${p.activeCameras}/${p.attachedCameras}`:"—"}),o(Ut,{label:"Avg infer ms",value:p&&p.attachedCameras>0?(p.totalInferenceWeighted/p.attachedCameras).toFixed(0):"—"}),o(Ut,{label:"Queue",value:p?String(p.queueDepth):"—"}),o(Ut,{label:"Audio",value:String(i.get(t)??"—")})]})]})}const u=[...l.entries()].sort(([p],[h])=>p==="hub"?-1:h==="hub"?1:p.localeCompare(h));return f("div",{className:"@container/liveload",children:[o("h3",{className:"text-sm font-semibold text-foreground mb-2",children:"Live load"}),f("div",{className:"grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3",children:[o(Ut,{label:"Total agents",value:`${d.onlineAgents}/${d.totalAgents}`}),o(Ut,{label:"Cameras",value:`${d.activeCameras}/${d.attachedCameras}`}),o(Ut,{label:"Total FPS",value:d.totalFps.toFixed(1)}),o(Ut,{label:"Avg inference ms",value:d.avgInferenceTimeMs.toFixed(0)}),o(Ut,{label:"Queue depth",value:String(d.queueDepth)})]}),o("div",{className:"rounded-lg border border-border overflow-x-auto",children:f("table",{className:"w-full text-xs min-w-[480px]",children:[o("thead",{className:"bg-surface",children:f("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[o("th",{className:"text-left px-3 py-2",children:"Agent"}),o("th",{className:"text-right px-3 py-2",children:"FPS"}),o("th",{className:"text-right px-3 py-2",children:"Cameras"}),o("th",{className:"text-right px-3 py-2",children:"Inference ms"}),o("th",{className:"text-right px-3 py-2",children:"Queue"}),o("th",{className:"text-right px-3 py-2",children:"Audio"})]})}),f("tbody",{children:[u.map(([p,h])=>f("tr",{className:"border-t border-border",children:[o("td",{className:"px-3 py-2 text-foreground font-medium",children:c.get(p)??p}),o("td",{className:"px-3 py-2 text-right text-foreground",children:h.totalFps.toFixed(1)}),o("td",{className:"px-3 py-2 text-right text-foreground",children:h.attachedCameras}),o("td",{className:"px-3 py-2 text-right text-foreground",children:h.attachedCameras>0?(h.totalInferenceWeighted/h.attachedCameras).toFixed(0):"—"}),o("td",{className:"px-3 py-2 text-right text-foreground",children:h.queueDepth}),o("td",{className:"px-3 py-2 text-right text-foreground",children:i.get(p)??"—"})]},p)),u.length===0&&o("tr",{children:o("td",{colSpan:6,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:"No camera metrics received yet"})})]})]})})]})}function Ut({label:e,value:t}){return f("div",{className:"rounded-lg border border-border bg-surface/60 p-3",children:[o("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle mb-1",children:e}),o("div",{className:"text-lg font-semibold text-foreground",children:t})]})}function Cv(e){return Bn({addonId:e})}function $7(e){return er({deviceId:e},{enabled:Number.isFinite(e)})}const D7=3e4,T7=2e3;function Mv(e){const t=te(0);return t.current===0&&(t.current=Date.now()),Yb({parentDeviceId:e},{enabled:Number.isFinite(e),staleTime:0,refetchOnMount:"always",refetchInterval:n=>{const r=n.state.data;return r&&r.length>0||Date.now()-t.current>=D7?!1:T7}})}const Yi={active:!1,pinned:!1,nodeId:null,reason:""},Zi=["pipeline.camera-assigned","pipeline.camera-unassigned","pipeline.camera-updated","agent.online","agent.offline"],L7={pipeline:bt,decoder:yo,audio:Gl},Nf={pipeline:"Pipeline",decoder:"Decoder",audio:"Audio"};function Ev({mode:e,nodeId:t,compact:n=!1}){if(e==="agent"&&!t)throw new Error('CameraAssignmentsTable: nodeId is required when mode === "agent"');const r=ke(),[s,a]=_(null),[i,l]=_(null),[c,d]=_(new Map);St(["pipelineOrchestrator","getPipelineAssignments"],Zi),St(["pipelineOrchestrator","getDecoderAssignments"],Zi),St(["pipelineOrchestrator","getAudioAssignments"],Zi);const{data:u}=za(void 0,{staleTime:3e4}),{data:p}=ty(void 0,{staleTime:3e4}),{data:h}=sy(void 0,{staleTime:3e4}),{nodes:m}=Kr(),{data:g}=Cv();gt("pipeline.camera-metrics-snapshot",P=>{const B=P.data;typeof B.deviceId=="number"&&d(R=>{const M=new Map(R);return M.set(B.deviceId,B),M})}),Y(()=>{if(c.size===0)return;const P=setInterval(()=>{d(B=>{const R=Date.now()-1e4;let M=!1;const D=new Map(B);for(const[T,L]of B)L.timestamp<R&&(D.delete(T),M=!0);return M?D:B})},5e3);return()=>clearInterval(P)},[c.size]);const b=H(()=>{const P=new Map;for(const B of g??[])P.set(B.id,B.name);return P},[g]),x=H(()=>{const P=new Map,B=M=>{const D=P.get(M);if(D)return D;const T={deviceId:M,deviceName:b.get(M)??`Device ${M}`,pipeline:Yi,decoder:Yi,audio:Yi};return P.set(M,T),T};for(const M of u??[]){const D=B(M.deviceId);P.set(M.deviceId,{...D,pipeline:{active:e==="cluster"?!0:M.agentNodeId===t,pinned:M.pinned,nodeId:M.agentNodeId,reason:M.reason??""}})}for(const M of p??[]){const D=B(M.deviceId);P.set(M.deviceId,{...D,decoder:{active:e==="cluster"?!0:M.decoderNodeId===t,pinned:M.pinned,nodeId:M.decoderNodeId,reason:M.reason??""}})}for(const M of h??[]){const D=B(M.deviceId);P.set(M.deviceId,{...D,audio:{active:e==="cluster"?!0:M.nodeId===t,pinned:M.pinned,nodeId:M.nodeId,reason:"capacity"}})}let R=[...P.values()];return e==="agent"&&(R=R.filter(M=>M.pipeline.active||M.decoder.active||M.audio.active)),R.sort((M,D)=>M.deviceId-D.deviceId),R},[u,p,h,b,e,t]),y=H(()=>(m??[]).filter(P=>P.isOnline).map(P=>({id:P.id,name:P.name})),[m]),w=()=>{r.invalidateQueries({queryKey:[["pipelineOrchestrator","getPipelineAssignments"]]}),r.invalidateQueries({queryKey:[["pipelineOrchestrator","getDecoderAssignments"]]}),r.invalidateQueries({queryKey:[["pipelineOrchestrator","getAudioAssignments"]]})},v=Gx({onSuccess:w}),N=Kx({onSuccess:w}),k=Jx({onSuccess:w}),C=ey({onSuccess:w}),E=ny({onSuccess:w}),I=ry({onSuccess:w}),A=(P,B,R)=>{B==="pipeline"?v.mutate({deviceId:P,agentNodeId:R}):B==="decoder"?k.mutate({deviceId:P,nodeId:R}):E.mutate({deviceId:P,nodeId:R}),a(null)},z=(P,B)=>{B==="pipeline"?N.mutate({deviceId:P}):B==="decoder"?C.mutate({deviceId:P}):I.mutate({deviceId:P}),a(null)};return o("div",{className:"rounded-lg border border-border overflow-x-auto",children:f("table",{className:"w-full text-xs min-w-[640px]",children:[o("thead",{className:"bg-surface",children:f("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[!n&&o("th",{className:"w-6"}),o("th",{className:"text-left px-3 py-2 align-middle",children:"Camera"}),o("th",{className:"text-left px-3 py-2 align-middle",children:"Pipeline"}),o("th",{className:"text-left px-3 py-2 align-middle",children:"Decoder"}),o("th",{className:"text-left px-3 py-2 align-middle",children:"Audio"}),o("th",{className:"text-left px-3 py-2 align-middle",children:"Status"})]})}),f("tbody",{children:[x.map(P=>{const B=c.get(P.deviceId),R=i===P.deviceId;return f(Ge.Fragment,{children:[f("tr",{className:"border-t border-border align-middle relative",children:[!n&&o("td",{className:"px-2 py-2 align-middle",children:o("button",{type:"button",onClick:()=>l(R?null:P.deviceId),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle","aria-label":R?"Collapse broker details":"Expand broker details",children:R?o(lt,{className:"h-3.5 w-3.5"}):o(wt,{className:"h-3.5 w-3.5"})})}),f("td",{className:"px-3 py-2 align-middle",children:[o("div",{className:"text-foreground font-medium leading-tight",children:P.deviceName}),f("div",{className:"text-[10px] text-foreground-subtle leading-tight",children:["#",P.deviceId]})]}),o(Xi,{role:"pipeline",state:P.pipeline,mode:e,deviceId:P.deviceId,onlineNodes:y,isMenuOpen:s?.deviceId===P.deviceId&&s.role==="pipeline",onToggleMenu:()=>a(s?.deviceId===P.deviceId&&s.role==="pipeline"?null:{deviceId:P.deviceId,role:"pipeline"}),onCloseMenu:()=>a(null),onMove:M=>A(P.deviceId,"pipeline",M),onUnpin:()=>z(P.deviceId,"pipeline")}),o(Xi,{role:"decoder",state:P.decoder,mode:e,deviceId:P.deviceId,onlineNodes:y,isMenuOpen:s?.deviceId===P.deviceId&&s.role==="decoder",onToggleMenu:()=>a(s?.deviceId===P.deviceId&&s.role==="decoder"?null:{deviceId:P.deviceId,role:"decoder"}),onCloseMenu:()=>a(null),onMove:M=>A(P.deviceId,"decoder",M),onUnpin:()=>z(P.deviceId,"decoder")}),o(Xi,{role:"audio",state:P.audio,mode:e,deviceId:P.deviceId,onlineNodes:y,isMenuOpen:s?.deviceId===P.deviceId&&s.role==="audio",onToggleMenu:()=>a(s?.deviceId===P.deviceId&&s.role==="audio"?null:{deviceId:P.deviceId,role:"audio"}),onCloseMenu:()=>a(null),onMove:M=>A(P.deviceId,"audio",M),onUnpin:()=>z(P.deviceId,"audio")}),o("td",{className:"px-3 py-2 align-middle",children:o(B7,{snap:B})})]}),R&&!n&&f("tr",{className:"bg-surface/50",children:[o("td",{}),o("td",{colSpan:5,className:"px-3 py-2",children:o(ft,{widgetId:"stream-broker/stream-broker-panel",host:"device-tab",deviceId:P.deviceId,instanceId:`pipeline-row/${P.deviceId}`,config:{variant:"compact",title:"Stream brokers & clients"}})})]})]},P.deviceId)}),x.length===0&&o("tr",{children:o("td",{colSpan:n?5:6,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:e==="agent"?"No cameras assigned to this node":"No cameras currently assigned"})})]})]})})}function Xi({role:e,state:t,mode:n,onlineNodes:r,isMenuOpen:s,onToggleMenu:a,onCloseMenu:i,onMove:l,onUnpin:c}){const d=L7[e],u=r.filter(m=>m.id!==(t.nodeId??"")),h=(t.active||n==="cluster")&&(u.length>0||t.pinned);return f("td",{className:"px-3 py-2 align-middle relative",children:[f("div",{className:"flex items-center gap-2",children:[n==="agent"?o(R7,{state:t,Icon:d}):o(O7,{state:t,Icon:d}),o("div",{className:"ml-auto",children:h&&o("button",{type:"button",onClick:a,className:"p-1 rounded hover:bg-surface-hover","aria-label":`${Nf[e]} actions`,children:o(r6,{className:"h-3 w-3 text-foreground-subtle"})})})]}),s&&h&&o(z7,{title:Nf[e],targets:u,pinned:t.pinned,onMove:l,onUnpin:c,onClose:i})]})}function R7({state:e,Icon:t}){const n=e.active?rv:ts;return f("div",{className:"flex items-center gap-1.5",children:[o(n,{className:`h-3.5 w-3.5 ${e.active?"text-success":"text-foreground-subtle/50"}`}),o(t,{className:`h-3 w-3 ${e.active?"text-foreground-subtle":"text-foreground-subtle/40"}`}),e.pinned&&o(J0,{className:"h-2.5 w-2.5 text-amber-400"})]})}function O7({state:e,Icon:t}){return!e.active||!e.nodeId?f("div",{className:"flex items-center gap-1.5 text-foreground-subtle/60",children:[o(t,{className:"h-3 w-3"}),o("span",{className:"text-[10px] italic",children:"—"})]}):f("div",{className:"flex items-center gap-1.5 min-w-0",children:[o(t,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),f("div",{className:"flex flex-col leading-tight min-w-0",children:[o("span",{className:"font-mono text-[11px] text-foreground truncate",children:e.nodeId}),o("span",{className:"flex items-center gap-1 text-[10px]",children:e.pinned?f("span",{className:"inline-flex items-center gap-0.5 text-amber-400",children:[o(J0,{className:"h-2.5 w-2.5"})," manual"]}):f("span",{className:"text-foreground-subtle truncate",children:["auto · ",e.reason||"capacity"]})})]})]})}function B7({snap:e}){if(!e)return o("span",{className:"text-[10px] text-foreground-subtle italic",children:"—"});const{phase:t,actualFps:n,avgInferenceTimeMs:r,queueDepth:s,configuredFps:a}=e.metrics,i=ur(t);return f("div",{className:"flex flex-col gap-0.5 font-mono text-[10px] tabular-nums leading-tight",children:[f("span",{className:`inline-flex items-center gap-1 ${i.textColor}`,children:[o(Ed,{phase:t,className:"h-2.5 w-2.5"}),o("span",{className:"font-semibold uppercase tracking-wider",children:i.label})]}),f("span",{className:"text-foreground-subtle",children:[o("span",{className:"text-foreground",children:n.toFixed(1)}),f("span",{children:["/",a.toFixed(0)," fps"]})]}),f("span",{className:"text-foreground-subtle",children:[o("span",{className:"text-foreground",children:r.toFixed(0)}),o("span",{children:" ms"}),s>0&&f("span",{className:"text-warning ml-1",children:["q",s]})]})]})}function z7({title:e,targets:t,pinned:n,onMove:r,onUnpin:s,onClose:a}){const i=te(null);return Y(()=>{const l=c=>{i.current?.contains(c.target)||a()};return window.addEventListener("mousedown",l),()=>window.removeEventListener("mousedown",l)},[a]),f("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:[o("div",{className:"px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border",children:e}),t.length>0&&o("div",{className:"py-1",children:t.map(l=>f("button",{type:"button",onClick:()=>r(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&&f("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&&o("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle italic",children:"Already auto · no other nodes online"})]})}function F7({nodeId:e,refreshToken:t}){return f("div",{className:"space-y-6",children:[o(Sv,{refreshToken:t,nodeId:e}),f("div",{children:[o("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Cameras on this node"}),f("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."]})]}),o(Ev,{mode:"agent",nodeId:e,compact:!0})]})}function j7(e,t){const n=Math.max(0,t-e),r=Math.floor(e/1e3),s=Math.floor(n/1e3);return`${r}s idle · ${s}s left`}function V7({nodeId:e,refreshToken:t}){const n=ke(),r=Qx({onSettled:()=>{n.invalidateQueries({queryKey:["pipelineExecutor","listLoadedEngines"]})}}),{data:s}=Ux({nodeId:e},{staleTime:5e3}),i=Gr("pipeline.engine-metrics-snapshot",h=>h.nodeId===e)?.engines??s??null,l=i===null;St(["pipelineRunner","getLocalCameras"],["pipeline.camera-assigned","pipeline.camera-unassigned"]);const{data:c}=hy({nodeId:e},{staleTime:3e4}),{values:d}=Kc("pipeline.camera-metrics-snapshot",h=>h.deviceId,h=>h.nodeId===e),u=H(()=>d.filter(h=>h.metrics.phase==="active").length,[d]),p=h=>{const m=c??[];m.length>0&&!window.confirm(`${m.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||r.mutate({nodeId:e,engine:h,force:m.length>0})};return f("div",{className:"space-y-6",children:[f("div",{children:[o("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Inference engines on this node"}),f("p",{className:"text-[11px] text-foreground-subtle",children:[(i??[]).length," engine(s) resident in RAM. ",(c??[]).length," camera(s) attached, ",u," actively dispatching frames. Refreshes every 5s."]})]}),o("div",{className:"rounded-lg border border-border overflow-x-auto",children:f("table",{className:"w-full text-xs min-w-[640px]",children:[o("thead",{className:"bg-surface",children:f("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[o("th",{className:"text-left px-3 py-2 whitespace-nowrap",children:"Kind"}),o("th",{className:"text-left px-3 py-2 whitespace-nowrap",children:"Runtime / Backend / Device"}),o("th",{className:"text-left px-3 py-2",children:"Models"}),o("th",{className:"text-right px-3 py-2 whitespace-nowrap",children:"Pool PID"}),o("th",{className:"text-right px-3 py-2 whitespace-nowrap",children:"Auto-kill"}),o("th",{className:"text-right px-3 py-2 whitespace-nowrap",children:"In use"}),o("th",{className:"w-20"})]})}),f("tbody",{children:[l&&o("tr",{children:o("td",{colSpan:7,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:"Loading…"})}),!l&&(i??[]).map(h=>{const m=h.kind==="warm-override";return f("tr",{className:`border-t border-border ${m?"bg-amber-500/5":""}`,children:[o("td",{className:"px-3 py-2",children:f("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${m?"bg-amber-500/15 text-amber-400":"bg-success/15 text-success"}`,children:[m?o(c6,{className:"h-3 w-3"}):o(bt,{className:"h-3 w-3"}),m?"warm":"runtime"]})}),o("td",{className:"px-3 py-2",children:f("span",{className:"inline-flex items-center gap-1 text-[11px] text-sky-400",children:[o(Jd,{className:"h-3 w-3"}),h.engine.runtime,"/",h.engine.backend,h.engine.device?`/${h.engine.device}`:"",h.engine.format?` · ${h.engine.format}`:""]})}),o("td",{className:"px-3 py-2",children:h.modelsLoaded.length===0?o("span",{className:"text-foreground-subtle text-[11px]",children:"—"}):o("div",{className:"flex flex-wrap gap-1",children:h.modelsLoaded.map(g=>o("span",{className:"inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle",children:g},g))})}),o("td",{className:"px-3 py-2 text-right font-mono text-foreground",children:h.poolPid??"—"}),o("td",{className:"px-3 py-2 text-right text-[11px]",children:h.idleMs!==null&&h.idleTtlMs!==null?o("span",{className:"text-foreground-subtle",children:j7(h.idleMs,h.idleTtlMs)}):o("span",{className:"text-foreground-subtle/50",children:"never"})}),o("td",{className:"px-3 py-2 text-right text-foreground",children:m?"—":(c??[]).length}),o("td",{className:"px-3 py-2 text-right",children:f("button",{type:"button",disabled:r.isPending,onClick:()=>p(h.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:[o(Ze,{className:"h-3 w-3"}),"Kill"]})})]},h.engineKey)}),!l&&(i??[]).length===0&&o("tr",{children:o("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."})})]})]})}),f("div",{className:"text-[10px] text-foreground-subtle leading-relaxed",children:[o("strong",{className:"text-foreground",children:"runtime"}),": main camera-serving engine; never auto-killed while cameras attached. ",o("strong",{className:"text-foreground",children:"warm"}),": benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL."]}),r.isError&&f("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive",children:["Kill failed: ",r.error instanceof Error?r.error.message:"unknown"]})]})}function It(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,r="KB";for(const a of t){if(r=a,n<1024)break;n/=1024}return`${n>=100?Math.round(n).toString():n.toFixed(1)} ${r}`}function Iv(e){return It(e*1024*1024)}const H7=new Set(y2);function kf(e){return H7.has(e)}function Ji(e,t,n){return`${e}/${t}/${n}`}function ec(e){return{coreml:"CoreML",openvino:"OpenVINO",onnx:"ONNX"}[e.format]??e.format.toUpperCase()}function Sf(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 qn(e){return e.format}function q7(e,t){let n=0,r=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&&(r++,s+=c.sizeMB))}return{total:n,downloaded:r,downloadedSizeMB:s}}function U7({addonId:e,model:t,format:n,isActive:r,progress:s,errorMsg:a,onDownload:i,onDelete:l}){const c=t.formats[n];return c?f("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:[o("div",{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?"bg-success":"bg-foreground-subtle/30"}`}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-sm font-medium text-foreground",children:t.name}),f("span",{className:"text-[10px] text-foreground-subtle font-mono",children:["(",t.id,")"]})]}),s&&s.progress>=0&&s.progress<100&&f("div",{className:"mt-1.5 flex items-center gap-2 max-w-xs",children:[o("div",{className:"flex-1 h-1 bg-surface-hover rounded-full overflow-hidden",children:o("div",{className:"bg-primary h-full rounded-full transition-all duration-300",style:{width:`${s.progress}%`}})}),f("span",{className:"text-[9px] text-primary font-mono tabular-nums shrink-0",children:[Math.round(s.progress),"%"]})]})]}),o("span",{className:"text-xs text-foreground-subtle tabular-nums shrink-0",children:Iv(c.sizeMB)}),a&&f("span",{className:"flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0",title:a,children:[o(nr,{className:"h-3 w-3 shrink-0"}),a]}),c.downloaded?f("button",{onClick:l,disabled:r,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:[r?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ze,{className:"h-3 w-3"}),r?"Deleting...":"Delete"]}):f("button",{onClick:i,disabled:r,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:[r?o(Se,{className:"h-3 w-3 animate-spin"}):o(Xt,{className:"h-3 w-3"}),r?"Downloading...":"Download"]})]}):null}function Q7({engines:e,activeEngine:t,viewEngine:n,onSelect:r}){const[s,a]=_(!1);return f("div",{className:"relative",children:[f("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:[o(bt,{className:"h-4 w-4 text-primary shrink-0"}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-sm font-medium text-foreground",children:ec(n)}),qn(n)===qn(t)&&o("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium",children:"Active"})]}),o("div",{className:"text-[10px] text-foreground-subtle",children:Sf(n)})]}),o(lt,{className:`h-4 w-4 text-foreground-subtle transition-transform ${s?"rotate-180":""}`})]}),s&&o("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=qn(i)===qn(n),c=qn(i)===qn(t);return f("button",{type:"button",onClick:()=>{r(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:[o(bt,{className:`h-4 w-4 shrink-0 ${l?"text-primary":"text-foreground-subtle"}`}),f("div",{className:"flex-1",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:`text-sm font-medium ${l?"text-primary":"text-foreground"}`,children:ec(i)}),c&&o("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium",children:"Active"})]}),o("div",{className:"text-[10px] text-foreground-subtle",children:Sf(i)})]}),l&&o(Kd,{className:"h-4 w-4 text-primary shrink-0"})]},qn(i))})})]})}function G7({embedded:e=!1,nodeId:t}={}){const n=ke(),r=t??"hub",[s,a]=_(null),[i,l]=_(new Set),[c,d]=_(new Map),[u,p]=_(new Map),[h,m]=_(""),{data:g=[]}=Fx({nodeId:r},{staleTime:6e4}),x=g.filter((O,F,j)=>j.findIndex(V=>V.format===O.format)===F),{data:y}=jx({nodeId:r},{staleTime:3e4}),w=y,{data:v,isLoading:N}=Wo({nodeId:r},{staleTime:1e4}),k=Hx(),C=qx();gt("model.download.progress",O=>{const F=O.data,j=typeof F.modelId=="string"?F.modelId:void 0,V=typeof F.progress=="number"?F.progress:void 0,$=typeof F.totalMB=="number"?F.totalMB:0;j===void 0||V===void 0||(d(q=>{const G=new Map(q);return V===100||V===-1?G.delete(j):G.set(j,{modelId:j,progress:V,totalMB:$}),G}),V===100&&n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]}))});const E=w??{runtime:"node",backend:"cpu",format:"onnx"},I=x.find(O=>O.format===s)??E,A=I.format,z=v?.slots??[],P=z.map(O=>({...O,addons:O.addons.map(F=>({...F,models:F.models.filter(j=>j.formats[A]!==void 0)})).filter(F=>F.models.length>0)})).filter(O=>O.addons.length>0),B=q7(P,A),R=U(async(O,F,j)=>{if(!kf(j))return;const V=Ji(O,F,j);l($=>new Set([...$,V])),p($=>{const q=new Map($);return q.delete(V),q});try{await k.mutateAsync({addonId:O,modelId:F,format:j,nodeId:r}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch($){p(q=>new Map([...q,[V,$ instanceof Error?$.message:"Download failed"]]))}finally{l($=>{const q=new Set($);return q.delete(V),q})}},[k,n,r]),M=U(async(O,F,j)=>{if(!kf(j))return;const V=Ji(O,F,j);l($=>new Set([...$,V])),p($=>{const q=new Map($);return q.delete(V),q});try{await C.mutateAsync({addonId:O,modelId:F,format:j,nodeId:r}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch($){p(q=>new Map([...q,[V,$ instanceof Error?$.message:"Delete failed"]]))}finally{l($=>{const q=new Set($);return q.delete(V),q})}},[C,n,r]),D=U(O=>{a(O.format)},[]),T=h.trim()?P.map(O=>({...O,addons:O.addons.map(F=>({...F,models:F.models.filter(j=>j.name.toLowerCase().includes(h.toLowerCase())||j.id.toLowerCase().includes(h.toLowerCase())||F.name.toLowerCase().includes(h.toLowerCase()))})).filter(F=>F.models.length>0)})).filter(O=>O.addons.length>0):P,L=f(me,{children:[N&&o("div",{className:"flex items-center justify-center py-16",children:o(Se,{className:"h-5 w-5 animate-spin text-foreground-subtle"})}),!N&&z.length===0&&f("div",{className:"flex flex-col items-center justify-center py-16 text-foreground-subtle",children:[o(ia,{className:"h-8 w-8 mb-3 opacity-30"}),o("span",{className:"text-sm",children:"No pipeline steps available"}),o("span",{className:"text-xs mt-1",children:"Configure the detection pipeline to see available models."})]}),!N&&z.length>0&&f(me,{children:[o(Q7,{engines:x,activeEngine:E,viewEngine:I,onSelect:D}),f("div",{className:"flex items-center gap-4 text-xs text-foreground-subtle",children:[f("span",{children:[o("span",{className:"font-semibold text-foreground tabular-nums",children:B.total}),o("span",{className:"ml-1",children:"compatible models"})]}),o("span",{className:"text-border",children:"|"}),f("span",{children:[o("span",{className:"font-semibold text-success tabular-nums",children:B.downloaded}),o("span",{className:"ml-1",children:"downloaded"})]}),o("span",{className:"text-border",children:"|"}),f("span",{className:"tabular-nums",children:[Iv(B.downloadedSizeMB),o("span",{className:"ml-1",children:"on disk"})]})]}),B.total>5&&f("div",{className:"relative",children:[o(nv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle"}),o("input",{type:"text",value:h,onChange:O=>m(O.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"})]}),T.map(O=>{const F=O.addons.reduce((V,$)=>V+$.models.length,0),j=O.addons.reduce((V,$)=>V+$.models.filter(q=>q.formats[A]?.downloaded).length,0);return f("div",{children:[f("div",{className:"flex items-center gap-2 mb-2",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:O.label}),o("div",{className:"flex-1 h-px bg-border"}),f("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[j,"/",F]})]}),o("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:O.addons.map(V=>V.models.map($=>{const q=Ji(V.id,$.id,A);return o(U7,{addonId:V.id,model:$,format:A,isActive:i.has(q),progress:c.get($.id),errorMsg:u.get(q),onDownload:()=>R(V.id,$.id,A),onDelete:()=>M(V.id,$.id,A)},`${V.id}/${$.id}`)}))})]},O.id)}),T.length===0&&o("div",{className:"text-center py-8 text-sm text-foreground-subtle",children:h.trim()?f(me,{children:["No models matching “",h,"”"]}):f(me,{children:["No models available for ",ec(I)," format"]})})]})]});return e?o("div",{className:"space-y-4",children:L}):o(tt,{children:L})}function K7({nodeId:e,refreshToken:t}){return o(G7,{embedded:!0,nodeId:e})}function Av({nodeId:e,title:t}){const{data:n}=Cv(),{data:r}=za(void 0,{staleTime:3e4}),s=H(()=>{const d=new Map;for(const u of n??[])d.set(u.id,u.name);return d},[n]),a=H(()=>{if(!e)return null;const d=new Set;for(const u of r??[])u.agentNodeId===e&&d.add(u.deviceId);return d},[e,r]),[i,l]=_(new Map);gt("pipeline.camera-metrics-snapshot",d=>{const u=d.data;typeof u.deviceId=="number"&&(e&&u.nodeId!==e||l(p=>{const h=new Map(p);return h.set(u.deviceId,u),h}))}),Y(()=>{if(i.size===0)return;const d=setInterval(()=>{l(u=>{const p=Date.now()-1e4;let h=!1;const m=new Map(u);for(const[g,b]of u)b.timestamp<p&&(m.delete(g),h=!0);return h?m:u})},5e3);return()=>clearInterval(d)},[i.size]);const c=H(()=>{const d=[];for(const u of i.values())a&&!a.has(u.deviceId)||d.push(u);return d.sort((u,p)=>u.deviceId-p.deviceId),d},[i,a]);return c.length===0?f("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"]}):f("div",{className:"rounded-md border border-border bg-surface px-3 py-2",children:[f("div",{className:"flex items-center gap-2 mb-1.5",children:[o("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:t??"Cameras"}),o("span",{className:"text-[10px] text-foreground-subtle",children:c.length})]}),o("div",{className:"flex flex-wrap gap-1.5",children:c.map(d=>{const u=s.get(d.deviceId)??`#${d.deviceId}`,p=ur(d.metrics.phase);return f("div",{title:`${u} · ${p.label} · ${d.metrics.actualFps.toFixed(1)} fps · ${d.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${d.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${p.badgeClass}`,children:[o(Ed,{phase:d.metrics.phase,className:"h-2.5 w-2.5"}),o("span",{className:"font-medium text-foreground/90 max-w-[120px] truncate",children:u}),o("span",{className:"font-mono tabular-nums",children:d.metrics.actualFps.toFixed(1)}),o("span",{className:"opacity-60",children:"fps"})]},d.deviceId)})})]})}function el(e,t){if(!e)return null;for(const n of e.slots)for(const r of n.addons)if(r.id===t)return r;return null}function W7({nodeId:e,refreshToken:t}){const n=ke(),[r,s]=_(null),[a,i]=_(null),l=Wo({nodeId:e},{refetchOnMount:"always"}),c=hd({agentNodeId:e},{refetchOnMount:"always"}),d=md({onSuccess:()=>{n.invalidateQueries({queryKey:[["addonSettings"]]}),n.invalidateQueries({queryKey:[["pipelineOrchestrator"]]}),n.invalidateQueries({queryKey:[["pipelineExecutor"]]})}}),u=l.data??null,p=c.data,h=u?.selectedEngine.format??"coreml",m=H(()=>u?Ta(u):[],[u]),g=H(()=>[{agentNodeId:e,engineLabel:h}],[e,h]),b=(C,E)=>{const I=p?.addonDefaults[C];return el(u,C)?.models.some(P=>!!P.formats[h])?I?I.enabled?{kind:"enabled",modelId:I.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},x=r&&u?el(u,r.addonId):null,y=C=>{const E=p?.addonDefaults[C]??null;s({addonId:C,agentNodeId:e}),i(E)},w=(C,E)=>{if(!p)return;const I=p.addonDefaults[C],A=el(u,C);if(!I&&!A)return;const z={enabled:E,modelId:I?.modelId??A?.defaultModelId??"",settings:I?.settings??{}};d.mutate({agentNodeId:e,defaults:{...p.addonDefaults,[C]:z}})},v=()=>{s(null),i(null)},N=()=>{!a||!r||!p||d.mutate({agentNodeId:e,defaults:{...p.addonDefaults,[r.addonId]:a}},{onSuccess:v})};if(l.isLoading||c.isLoading)return o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading pipeline…"});if(l.error)return f("div",{className:"text-xs text-red-400",children:["Failed to load catalog: ",String(l.error)]});if(!u)return o("div",{className:"text-xs text-foreground-subtle",children:"Catalog unavailable for this node (runner offline?)."});const k=r!==null&&x!==null&&a!==null;return f("div",{className:"relative h-full w-full space-y-3",children:[o(Av,{nodeId:e}),o("div",{className:k?"pr-[360px]":"",children:m.length>0?o(Uc,{tree:m,agents:g,getCellState:b,onCellClick:y,selectedCell:r,onToggleEnabled:w}):o("div",{className:"text-xs text-foreground-subtle",children:"Catalog empty."})}),o(qc,{open:k,onClose:v,title:x?.name??"",subtitle:r?`${r.agentNodeId} · ${h}`:"",footer:f(me,{children:[o("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:v,children:"Cancel"}),o("button",{type:"button",disabled:!a||!r||d.isPending,className:"px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50",onClick:N,children:d.isPending?"Saving…":"Save"})]}),children:x&&a&&r&&o(Ra,{mode:"agent",addon:x,agentDefault:a,agentNodeId:r.agentNodeId,engineFormat:h,onChangeAgentConfig:C=>i(C)})})]})}function Pv({pendingCount:e,onSave:t,onDiscard:n,saving:r=!1,saveLabel:s="Save",discardLabel:a="Discard"}){return e<=0?null:f("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:[f("span",{className:"text-xs text-foreground",children:[e," unsaved change",e===1?"":"s"]}),f("div",{className:"flex items-center gap-2",children:[o("button",{type:"button",onClick:n,disabled:r,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}),o("button",{type:"button",onClick:t,disabled:r,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:r?"Saving…":s})]})]})}function _v({tabs:e,activeId:t,onChange:n,countByTab:r,pendingByTab:s}){return e.length===0?null:o("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=r?.get(a.id)??0,c=s?.get(a.id)??0;return f("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&&f("span",{className:"ml-1.5 text-[10px] opacity-60",children:["(",l,")"]}),c>0&&o("span",{className:"ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-primary"})]},a.id)})})}function Y7(e,t){for(const n of e)for(const r of n.fields){if(!("key"in r)||r.key!==t)continue;if(r.type==="button"||r.type==="separator"||r.type==="info")return!0;const s=r.immediate;return s===!0?!0:s===!1?!1:n.immediate===!0}return!1}function $v({schema:e,serverValues:t,onImmediateSave:n,onDeferredSave:r}){const[s,a]=_({}),[i,l]=_(!1),c=te(null),d=e?.sections??[],u=Object.keys(s).length>0,p=H(()=>({...t,...s}),[t,s]);Y(()=>{if(u){l(!0);return}c.current&&clearTimeout(c.current),c.current=setTimeout(()=>l(!1),500)},[u]);const h=U(()=>{l(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>l(!1),2e3)},[]),m=U(y=>{h();const w={},v={},N={...t,...s};for(const[k,C]of Object.entries(y))N[k]!==C&&(Y7(d,k)?w[k]=C:v[k]=C);Object.keys(w).length>0&&n(w),a(k=>{const C={...k};for(const E of Object.keys(w))delete C[E];for(const[E,I]of Object.entries(v))C[E]=I;return C})},[h,t,s,d,n]),g=U(y=>{const w={},v={};for(const[N,k]of Object.entries(s))y.includes(N)?w[N]=k:v[N]=k;a(v),Object.keys(w).length>0&&r(w)},[s,r]),b=U(y=>{a(w=>{const v={...w};for(const N of y)delete v[N];return v})},[]),x=U(()=>{a({})},[]);return{values:p,pendingKeys:Object.keys(s),hasPendingEdits:u,editingPaused:i,handleChange:m,handleSave:g,handleDiscard:b,resetAll:x}}const Z7=Ue(function({addonId:t,schema:n,serverValues:r,onImmediateSave:s,onStateChange:a,onAction:i,disabled:l},c){const d=$v({schema:n,serverValues:r,onImmediateSave:U(b=>s(t,b),[t,s]),onDeferredSave:U(()=>{},[])});c2(c,()=>({flush:()=>{const b={};for(const x of d.pendingKeys)b[x]=d.values[x];return d.handleDiscard(d.pendingKeys),b},discard:()=>d.resetAll()}),[d]);const u=d.pendingKeys,p=u.join("|"),h=H(()=>u.map(b=>`${b}=${JSON.stringify(d.values[b])}`).join(","),[u,d.values]),m=te(a);Y(()=>{m.current=a},[a]),Y(()=>{const b={};for(const x of u)b[x]=d.values[x];m.current({addonId:t,pendingKeys:u,pendingValues:b})},[t,p,h]);const g=H(()=>{if(i)return(b,x,y)=>i(t,b,x,y)},[t,i]);return o(Dn,{schema:n,values:d.values,onChange:d.handleChange,disabled:l,onAction:g})});function Dv(e,t){if(e.type==="separator"||e.type==="info"||e.type==="button")return e;if(e.type==="group"){const a=e.fields.map(i=>Dv(i,t));return{...e,fields:a}}const n=e;t[e.key]=n.value;const{value:r,...s}=n;return s}function X7(e,t){return{...e,fields:e.fields.map(n=>Dv(n,t))}}function J7(e){const t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(r=>X7(r,t))},values:t}}function to({nodeId:e,addonIds:t,level:n,deviceId:r,sectionIds:s,sectionTab:a,extraTabs:i,title:l,description:c}){const d=ke(),u=Te().trpcClient,p=Cb(),h=Mb(),m=Vx(),g=Vb(),b=Db(),x=!!(i&&i.length>0),[y,w]=_(null);if(n==="device"&&!r)throw new Error('NodeAddonsSettingsPanel: deviceId is required when level === "device"');const v=e??"hub",N=p2({queries:t.map(J=>({queryKey:[["addonSettings",n==="global"?"getGlobalSettings":"getDeviceSettings"],{addonId:J,nodeId:v,deviceId:r??null}],queryFn:async()=>{if(n==="global"){const ee=await u.addonSettings.getGlobalSettings.query({addonId:J,nodeId:v});return{addonId:J,result:ee}}const W=await u.addonSettings.getDeviceSettings.query({addonId:J,deviceId:r,nodeId:v});return{addonId:J,result:W}},staleTime:3e4}))}),k=N.some(J=>J.isLoading),C=N.map(J=>{if(!J.data)return"-";if(J.data.result===null)return`${J.data.addonId}:n`;const W=[];for(const ee of J.data.result.sections){W.push(`s:${ee.id}:${ee.tab??"general"}`);for(const ae of ee.fields){if(!("key"in ae))continue;const fe="options"in ae&&Array.isArray(ae.options)?ae.options.map(le=>le.value).join(","):"",ge=ae.value,Q=ge===void 0?"":typeof ge=="string"?ge:JSON.stringify(ge);W.push(`f:${ae.key}:${fe}:${Q}`)}}return`${J.data.addonId}:${W.join("|")}`}).join("||"),E=H(()=>{const J=new Set;for(const W of N){const ee=W.data?.result?.sections;if(ee)for(const ae of ee)J.add(ae.tab??"general")}return[...J]},[C+"::"+N.map(J=>(J.data?.result?.sections??[]).map(W=>W.tab??"general").join(",")).join("::")]),I=H(()=>new Map((i??[]).map(J=>[J.id,J])),[i]),A=H(()=>{if(!x)return[];const J=[...new Set([...E,...(i??[]).map(ee=>ee.id)])],W=ee=>{const ae=I.get(ee);if(ae?.order!==void 0)return ae.order;const fe=Nl[ee];return fe?fe.order:50};return J.sort((ee,ae)=>{const fe=W(ee),ge=W(ae);return fe!==ge?fe-ge:ee.localeCompare(ae)})},[x,E,i,I]),z=H(()=>{const J=new Map;for(const W of E){const ee=Nl[W];J.set(W,ee?.label??W.charAt(0).toUpperCase()+W.slice(1))}for(const W of i??[])J.set(W.id,W.label);return J},[E,i]),P=x?y&&A.includes(y)?y:A[0]??null:null,B=P!==null&&I.has(P),R=x?P&&!B?P:void 0:a,{data:M}=wn(void 0,{staleTime:6e4}),D=H(()=>{const J=new Map;for(const W of M??[]){const ee=W.manifest?.id;if(!ee)continue;const ae=W.manifest?.name??W.manifest?.packageDisplayName??ee;J.set(ee,ae)}return J},[M]),T=H(()=>{const J=s?new Set(s):null,W=[];for(const ee of N){if(!ee.data||ee.data.result===null)continue;const{schema:ae,values:fe}=J7(ee.data.result),ge=ae.sections.filter(ue=>J?J.has(ue.id):!0);if(ge.length===0)continue;const Q={...ee.data.result,sections:ee.data.result.sections.filter(ue=>J?J.has(ue.id):!0)},le={...ae,sections:ge};W.push({addonId:ee.data.addonId,schemaWithValues:Q,schema:le,serverValues:fe})}return W},[C,s]),[L,O]=_(new Map),F=U(J=>{O(W=>{const ee=new Map(W);return ee.set(J.addonId,J),ee})},[]),j=te(new Map),V=U(J=>W=>{W?j.current.set(J,W):j.current.delete(J)},[]),$=U(async(J,W)=>{n==="global"?await p.mutateAsync({addonId:J,nodeId:v,patch:W}):await h.mutateAsync({addonId:J,deviceId:r,nodeId:v,patch:W}),d.invalidateQueries({queryKey:[["addonSettings"]]})},[p,h,v,n,r,d]),q=U(async(J,W,ee,ae)=>{const fe=v;try{switch(W){case"reprobe-engine":await m.mutateAsync({nodeId:fe}),d.invalidateQueries({queryKey:[["addonSettings"]]});return;case"reprobe-hwaccel":await g.mutateAsync({nodeId:fe}),d.invalidateQueries({queryKey:[["addonSettings"]]});return;case"reprobe-audio-engine":await b.mutateAsync({nodeId:fe}),d.invalidateQueries({queryKey:[["addonSettings"]]});return;default:{const ge=await u.addons.custom.mutate({addonId:J,action:W,input:ae});return d.invalidateQueries({queryKey:[["addonSettings"]]}),ge}}}catch(ge){throw console.error("[NodeAddonsSettingsPanel] action failed",{addonId:J,action:W,err:ge}),ge}},[m,g,b,v,d,u]),G=U((J,W)=>{$(J,W)},[$]),Z=Kn({mutationFn:async()=>{const J=[];for(const ee of T){const ae=L.get(ee.addonId);!ae||ae.pendingKeys.length===0||J.push({addonId:ee.addonId,patch:ae.pendingValues})}return J.length===0?{saved:[]}:{saved:await Promise.all(J.map(async({addonId:ee,patch:ae})=>(n==="global"?await p.mutateAsync({addonId:ee,nodeId:v,patch:ae}):await h.mutateAsync({addonId:ee,deviceId:r,nodeId:v,patch:ae}),ee)))}},onSuccess:({saved:J})=>{for(const W of J)j.current.get(W)?.discard();d.invalidateQueries({queryKey:[["addonSettings"]]})}}),oe=U(()=>{for(const J of j.current.values())J.discard()},[]),ne=H(()=>{let J=0;for(const W of T){const ee=L.get(W.addonId);ee&&(J+=ee.pendingKeys.length)}return J},[T,L]),X=H(()=>{const J=new Map;for(const W of T){const ee=L.get(W.addonId);if(!ee||ee.pendingKeys.length===0)continue;const ae=new Set(ee.pendingKeys);for(const fe of W.schema.sections){const ge=fe.tab??"general";for(const Q of fe.fields)"key"in Q&&ae.has(Q.key)&&J.set(ge,(J.get(ge)??0)+1)}}return J},[T,L]);if(k)return o("div",{className:"h-24 rounded-lg border border-border bg-surface animate-pulse"});const re=P&&B?I.get(P):void 0;if(!x&&T.length===0)return f("div",{className:"text-[11px] text-foreground-subtle italic",children:["No addons in ",t.length>0?`[${t.join(", ")}]`:"the current selection"," ","expose ",n,"-level settings on this node."]});const be=Z.isPending;return f("div",{className:"space-y-4",children:[(l||c)&&f("div",{className:"border-b border-border pb-2",children:[l&&o("h2",{className:"text-sm font-semibold text-foreground",children:l}),c&&o("p",{className:"text-[11px] text-foreground-subtle mt-0.5",children:c})]}),x&&o(_v,{tabs:A.map(J=>({id:J,label:z.get(J)??J})),activeId:P,onChange:w,pendingByTab:X}),Z.isError&&f("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(Z.error?.message??Z.error)]}),re?re.content:(()=>{const J=R?T.reduce((ae,fe)=>ae+fe.schemaWithValues.sections.filter(ge=>(ge.tab??"general")===R).length,0):0,W=R!==null&&J<=1,ee=T.map(ae=>({...ae,renderedWithValues:{...ae.schemaWithValues,sections:ae.schemaWithValues.sections.filter(fe=>R?(fe.tab??"general")===R:!0).map(fe=>W?{...fe,title:"",description:void 0}:fe)}})).filter(ae=>ae.renderedWithValues.sections.length>0).sort((ae,fe)=>{const ge=ue=>{let de=Number.POSITIVE_INFINITY;for(const ce of ue)typeof ce.order=="number"&&ce.order<de&&(de=ce.order);return de},Q=ge(ae.renderedWithValues.sections),le=ge(fe.renderedWithValues.sections);return Q!==le?Q-le:0});return ee.length===0?o("div",{className:"text-[11px] text-foreground-subtle italic",children:"Nothing to configure here for this node."}):o(eB,{entries:ee,paneStates:L,displayNames:D,disabled:be,setPaneRef:V,onPaneStateChange:F,onImmediateSave:G,onAction:q,inline:x||!!a})})(),!k&&o(Pv,{pendingCount:ne,onSave:()=>Z.mutate(),onDiscard:oe,saving:be})]})}function eB({entries:e,paneStates:t,displayNames:n,disabled:r,setPaneRef:s,onPaneStateChange:a,onImmediateSave:i,onAction:l,inline:c}){const d=H(()=>[...e].sort((x,y)=>{if(x.addonId==="system-config")return-1;if(y.addonId==="system-config")return 1;const w=n.get(x.addonId)??x.addonId,v=n.get(y.addonId)??y.addonId;return w.localeCompare(v)}),[e,n]),u=d[0]?.addonId??"",[p,h]=_(u);Y(()=>{d.length!==0&&(d.find(x=>x.addonId===p)||h(d[0].addonId))},[d,p]);const m=d.find(x=>x.addonId===p)??d[0];if(!m)return null;const g=H(()=>l?(x,y,w,v)=>l(x,y,w,v):void 0,[l]),b=x=>o(Z7,{ref:s(x.addonId),addonId:x.addonId,schema:x.renderedWithValues,serverValues:x.serverValues,onImmediateSave:i,onStateChange:a,onAction:g,disabled:r},x.addonId);return d.length===1||c?o("div",{className:"flex flex-col gap-4",children:d.map(b)}):f("div",{className:"flex flex-col gap-3",children:[o("div",{className:"flex flex-wrap items-center gap-1 border-b border-border shrink-0",children:d.map(x=>{const y=n.get(x.addonId)??x.addonId,w=x.addonId===m.addonId,v=(t.get(x.addonId)?.pendingKeys.length??0)>0;return f("button",{type:"button",onClick:()=>h(x.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${w?"text-primary border-primary bg-primary/5":"text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover"}`,children:[y,v&&o("span",{className:"ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400"})]},x.addonId)})}),o("div",{className:"space-y-2",children:d.map(x=>o("div",{style:x.addonId===m.addonId?void 0:{display:"none"},children:b(x)},x.addonId))})]})}const tB=["detection-pipeline","decoder-nodeav","audio-analyzer","pipeline-runner"];function nB({nodeId:e,refreshToken:t}){return f("div",{className:"flex flex-col h-full",children:[o(_7,{nodeId:e,refreshToken:t}),o("div",{className:"flex-1 min-h-0 overflow-y-auto p-6",children:o(to,{nodeId:e,addonIds:tB,level:"global",extraTabs:[{id:"assignments",label:"Assignments",order:-10,content:o(F7,{nodeId:e,refreshToken:t})},{id:"tree",label:"Pipeline",order:39,content:o(W7,{nodeId:e,refreshToken:t})},{id:"engines",label:"Warm instances",order:180,content:o(V7,{nodeId:e,refreshToken:t})},{id:"models",label:"Models",order:200,content:o(K7,{nodeId:e,refreshToken:t})}]})})]})}function rB({refreshToken:e}){const t=ke(),n=Wx({onSuccess:()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","getPipelineAssignments"]]}),t.invalidateQueries({queryKey:[["pipelineOrchestrator","getDecoderAssignments"]]}),t.invalidateQueries({queryKey:[["pipelineOrchestrator","getAudioAssignments"]]})}});return f("div",{className:"space-y-6",children:[o(Sv,{refreshToken:e}),f("div",{className:"flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between",children:[f("div",{className:"min-w-0",children:[o("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Placement matrix"}),o("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."})]}),f("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:[o(Jd,{className:"h-3.5 w-3.5"}),n.isPending?"Rebalancing…":"Rebalance pipelines"]})]}),o(Ev,{mode:"cluster"})]})}const oB=["pipeline-orchestrator"];function sB({refreshToken:e}){return o("div",{className:"space-y-4 max-w-3xl",children:o(to,{nodeId:"hub",addonIds:oB,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 aB({refreshToken:e}){const t=ke(),{data:n,isLoading:r}=uy(),[s,a]=_(null),[i,l]=_(""),[c,d]=_(""),u=()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","listTemplates"]]})},p=py({onSuccess:()=>{a(null),u()}}),h=fy({onSuccess:u}),m=y=>{a(y.id),l(y.name),d(y.description??"")},g=()=>{a(null),l(""),d("")},b=()=>{if(!s)return;const y=c.trim();p.mutate({id:s,name:i.trim()||"Untitled",...y?{description:y}:{}})};if(r)return o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading templates…"});const x=[...n??[]].sort((y,w)=>y.name.localeCompare(w.name));return o("div",{className:"space-y-6 max-w-4xl",children:f("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"border-b border-border px-4 py-3 flex items-center justify-between",children:[f("div",{children:[o("h3",{className:"text-sm font-semibold text-foreground",children:"Templates"}),o("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."})]}),f("div",{className:"text-[11px] text-foreground-subtle",children:[x.length," template",x.length===1?"":"s"]})]}),x.length===0?f("div",{className:"px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2",children:[o(Et,{className:"h-6 w-6 opacity-40"}),o("div",{children:'No templates yet. Create one from a device Pipeline tab ("Save as template").'})]}):o("ul",{className:"divide-y divide-border",children:x.map(y=>{const w=s===y.id;return o("li",{className:"px-4 py-3 text-xs",children:f("div",{className:"flex items-start gap-3",children:[o("div",{className:"flex-1 min-w-0",children:w?f("div",{className:"space-y-2",children:[o("input",{className:"w-full rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary",value:i,onChange:v=>l(v.target.value),placeholder:"Template name",autoFocus:!0}),o("input",{className:"w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary",value:c,onChange:v=>d(v.target.value),placeholder:"Description (optional)"})]}):f(me,{children:[o("div",{className:"font-medium text-foreground",children:y.name}),y.description&&o("div",{className:"text-foreground-subtle mt-0.5",children:y.description}),f("div",{className:"mt-1 font-mono text-[10px] text-foreground-subtle",children:["engine ",y.config.engine.runtime,"/",y.config.engine.backend," · ",y.config.steps.length," step(s)",y.config.audio?.enabled?" · audio":"",f("span",{className:"ml-2",children:["updated ",new Date(y.updatedAt).toLocaleString()]})]})]})}),o("div",{className:"flex items-center gap-1 shrink-0",children:w?f(me,{children:[f("button",{type:"button",onClick:b,disabled:p.isPending,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-50",children:[o(_t,{className:"h-3 w-3"}),"Save"]}),f("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:[o(Fe,{className:"h-3 w-3"}),"Cancel"]})]}):f(me,{children:[o("button",{type:"button",onClick:()=>m(y),title:"Rename",className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover",children:o(eo,{className:"h-3 w-3"})}),o("button",{type:"button",onClick:()=>{confirm(`Delete template "${y.name}"?`)&&h.mutate({id:y.id})},disabled:h.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:o(Ze,{className:"h-3 w-3"})})]})})]})},y.id)})})]})})}function Cf(e,t){if(!e)return null;for(const n of e.slots)for(const r of n.addons)if(r.id===t)return r;return null}function iB({nodeId:e,refreshToken:t}){const n=ke(),r=Te().trpcClient,[s,a]=_(null),[i,l]=_(null),c=Yr(void 0,{refetchOnMount:"always"});St(["nodes","topology"],["agent.online","agent.offline","agent.unregistered","addon.installed","addon.uninstalled","addon.updated"]);const d=zn(void 0,{staleTime:3e4,refetchOnMount:"always"}),u=H(()=>{const A=new Set;for(const z of d.data??[])z.isOnline&&A.add(z.id);return A},[d.data]),p=Wo({nodeId:e},{refetchOnMount:"always"}),h=H(()=>(c.data??[]).filter(A=>u.has(A.nodeId)).map(A=>A.nodeId),[c.data,u]),m=Ln({enabled:h.length>0,queryKey:[["pipelineExecutor","getSchema"],"schema-by-agent",h.join(","),t],queryFn:async()=>{const A={};for(const z of h)try{const P=await r.pipelineExecutor.getSchema.query({nodeId:z});A[z]=P.selectedEngine.format}catch{A[z]="coreml"}return A}}),g=md({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator"]]}),n.invalidateQueries({queryKey:[["pipelineExecutor"]]}),n.invalidateQueries({queryKey:[["addonSettings"]]})}}),b=H(()=>p.data?Ta(p.data):[],[p.data]),x=H(()=>{const A=c.data??[],z=u;return(z.size===0?[]:A.filter(B=>z.has(B.nodeId))).map(B=>{const R=m.data?.[B.nodeId];return{agentNodeId:B.nodeId,engineLabel:R??"(engine unknown)"}})},[c.data,m.data,u]),y=(A,z)=>{const B=c.data?.find(T=>T.nodeId===z)?.settings.addonDefaults[A],R=m.data?.[z];return Cf(p.data??null,A)?.models.some(T=>R!==void 0&&!!T.formats[R])?B?B.enabled?{kind:"enabled",modelId:B.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},w=s?c.data?.find(A=>A.nodeId===s.agentNodeId)??null:null,v=s&&p.data?Cf(p.data,s.addonId):null,N=s?m.data?.[s.agentNodeId]??"coreml":"coreml",k=()=>{a(null),l(null)},C=(A,z)=>{const B=c.data?.find(R=>R.nodeId===z)?.settings.addonDefaults[A]??null;a({addonId:A,agentNodeId:z}),l(B)},E=()=>{!i||!s||!w||g.mutate({agentNodeId:s.agentNodeId,defaults:{...w.settings.addonDefaults,[s.addonId]:i}},{onSuccess:k})};if(c.isLoading||p.isLoading)return o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading agents…"});if(!p.data)return f("div",{className:"text-xs text-foreground-subtle",children:["Catalog unavailable for ",e,"."]});const I=s!==null&&v!==null&&i!==null;return f("div",{className:"relative h-full w-full space-y-3",children:[o(Av,{title:"Cluster cameras"}),o("div",{className:I?"pr-[360px]":"",children:b.length>0&&x.length>0?o(Uc,{tree:b,agents:x,getCellState:y,onCellClick:C,selectedCell:s}):o("div",{className:"text-xs text-foreground-subtle",children:"No agents or catalog empty."})}),o(qc,{open:I,onClose:k,title:v?.name??"",subtitle:s?`${s.agentNodeId} · ${N}`:"",footer:f(me,{children:[o("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:k,children:"Cancel"}),o("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:E,children:g.isPending?"Saving…":"Save"})]}),children:v&&i&&s&&o(Ra,{mode:"agent",addon:v,agentDefault:i,agentNodeId:s.agentNodeId,engineFormat:N,onChangeAgentConfig:A=>l(A)})})]})}const lB=[{id:"assignments",label:"Assignments"},{id:"pipeline",label:"Pipeline"},{id:"settings",label:"Settings"},{id:"templates",label:"Templates"}];function cB({refreshToken:e}){const[t,n]=_("assignments"),{data:r}=zn(void 0,{staleTime:3e4}),s=r?.find(a=>a.isHub&&a.isOnline)?.id??r?.find(a=>a.isOnline)?.id??null;return f("div",{className:"flex flex-col h-full",children:[f("div",{className:"px-6 py-4 border-b border-border",children:[o("h2",{className:"text-base font-semibold text-foreground",children:"Cluster Orchestration"}),o("div",{className:"text-[11px] text-foreground-subtle mt-1",children:"Assignments with live load, cluster-wide settings, pipeline template library, per-camera pipeline overrides."})]}),o("div",{className:"flex items-center gap-1 px-6 border-b border-border",children:lB.map(a=>o("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))}),f("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab",children:[t==="assignments"&&o(rB,{refreshToken:e}),t==="pipeline"&&(s?o(iB,{nodeId:s,refreshToken:e}):o("div",{className:"text-xs text-foreground-subtle",children:"No online node available — schema unreachable."})),t==="settings"&&o(sB,{refreshToken:e}),t==="templates"&&o(aB,{refreshToken:e})]})]})}const No="__cluster__";function dB(){const[e,t]=Ga(),n=e.get("node")??No,[r,s]=_(0);return Y(()=>{e.get("node")||t({node:No},{replace:!0})},[e,t]),f("div",{className:"flex flex-col h-full overflow-hidden",children:[o("div",{className:"flex items-center justify-end gap-4 px-4 py-3 border-b border-border shrink-0",children:f("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:[o(ct,{className:"h-3.5 w-3.5"}),"Refresh"]})}),f("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden min-h-0",children:[o("aside",{className:"w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border overflow-y-auto",children:o(P7,{selectedNodeId:n,onSelect:i=>{t({node:i},{replace:!0})},refreshToken:r})}),o("section",{className:"flex-1 min-h-0 overflow-hidden",children:n===No?o(cB,{refreshToken:r}):o(nB,{nodeId:n,refreshToken:r})})]})]})}const uB="device-export",tl="export",pB="Export";function tc(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(tc):e.type==="sub-tabs"?e.tabs.some(t=>t.fields.some(tc)):e.writerCapName===uB}function Do(e){return e.fields.some(tc)}function fB(e){const[t,n]=_("idle"),[r,s]=_(null),a=te(null),i=te(null),l=te(null),c=te(!0),d=hx(),u=mx(),p=gx(),h=U(()=>{if(a.current){try{a.current.close()}catch{}a.current=null}if(i.current){for(const b of i.current.getTracks())try{b.stop()}catch{}i.current=null}l.current=null},[]),m=U(async()=>{if(t==="idle")return;n("stopping");const b=l.current;if(b&&e!==null)try{await Promise.race([p.mutateAsync({deviceId:e,sessionId:b}),new Promise((y,w)=>setTimeout(()=>w(new Error("server stopSession timeout")),2e3))])}catch(y){console.warn("[intercom] server stopSession failed (continuing teardown)",y)}h(),c.current&&(n("idle"),s(null))},[t,e,p,h]),g=U(async()=>{if(e===null||t!=="idle"&&t!=="error")return;s(null);let b=null,x=null,y=null;try{n("requesting-mic"),b=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),i.current=b,n("starting");const w=await d.mutateAsync({deviceId:e});y=w.sessionId,l.current=y,n("connecting"),x=new RTCPeerConnection,a.current=x,x.oniceconnectionstatechange=()=>{if(!c.current)return;const k=x.iceConnectionState;k==="connected"||k==="completed"?n("talking"):(k==="failed"||k==="closed"||k==="disconnected")&&c.current&&(s(k==="failed"?"WebRTC connection failed":null),m())};for(const k of b.getAudioTracks())x.addTrack(k,b);await x.setRemoteDescription({type:"offer",sdp:w.sdpOffer});const v=await x.createAnswer();await x.setLocalDescription(v);const N=x.localDescription?.sdp??v.sdp??"";await u.mutateAsync({deviceId:e,sessionId:y,sdpAnswer:N})}catch(w){const v=w instanceof Error?w.message:String(w);if(console.warn("[intercom] start failed",w),x)try{x.close()}catch{}if(b)for(const N of b.getTracks())try{N.stop()}catch{}if(a.current=null,i.current=null,y!==null)try{await p.mutateAsync({deviceId:e,sessionId:y})}catch{}l.current=null,c.current&&(s(v),n("error"))}},[e,t,d,u,p,m]);return Y(()=>(c.current=!0,()=>{c.current=!1;const b=l.current;if(b!==null&&e!==null&&p.mutate({deviceId:e,sessionId:b}),a.current){try{a.current.close()}catch{}a.current=null}if(i.current){for(const x of i.current.getTracks())try{x.stop()}catch{}i.current=null}l.current=null}),[e]),{state:t,error:r,start:g,stop:m,isTalking:t==="talking"}}let hB=0;function ut(){return++hB}function nl(e){switch(e.type){case"system":return"system";case"device":return`#${e.deviceId}`;case"provider":return e.providerId;case"addon":return e.addonId}}function mB(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 gB(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 bB(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 xB({scope:e,greeting:t,className:n}){const r=Te(),[s,a]=_(()=>{const v=[];return t&&v.push({id:ut(),kind:"info",text:t}),v.push({id:ut(),kind:"info",text:`scope: ${nl(e)} — type help or context for available commands`}),v}),[i,l]=_(""),[c,d]=_([]),[u,p]=_(-1),h=te(null),m=te(null);Y(()=>{const v=m.current;v&&(v.scrollTop=v.scrollHeight)},[s]);const g=U(()=>{h.current?.focus()},[]),b=Kn({mutationFn:v=>r.trpcClient.repl.execute.mutate({code:v,scope:e}),onSuccess:v=>{const N=v??{},k=typeof N.output=="string"?N.output:v==null?"undefined":typeof v=="string"?v:JSON.stringify(v,null,2),C=N.type==="error";a(E=>[...E,{id:ut(),kind:C?"error":"result",text:k}])},onError:v=>{const N=v instanceof Error?v.message:String(v);a(k=>[...k,{id:ut(),kind:"error",text:N}])}});function x(v){const N=v.trim();if(N){if(N==="clear"){a([{id:ut(),kind:"info",text:`scope: ${nl(e)}`}]),l("");return}if(N==="help"){a(k=>[...k,{id:ut(),kind:"input",text:`> ${N}`},...mB(e).map(C=>({id:ut(),kind:"info",text:C}))]),l("");return}if(N==="context"){a(k=>[...k,{id:ut(),kind:"input",text:`> ${N}`},...bB(e).map(C=>({id:ut(),kind:"info",text:C}))]),l("");return}if(N==="examples"){a(k=>[...k,{id:ut(),kind:"input",text:`> ${N}`},...gB(e).map(C=>({id:ut(),kind:"info",text:C}))]),l("");return}d(k=>[...k,N]),p(-1),a(k=>[...k,{id:ut(),kind:"input",text:`> ${N}`}]),l(""),b.mutate(N)}}function y(v){if(v.key==="Enter"){v.preventDefault(),x(i);return}if(v.key==="ArrowUp"){if(v.preventDefault(),c.length===0)return;const N=u===-1?c.length-1:Math.max(0,u-1);p(N),l(c[N]??"");return}if(v.key==="ArrowDown"){if(v.preventDefault(),u===-1)return;const N=u+1;N>=c.length?(p(-1),l("")):(p(N),l(c[N]??""));return}v.ctrlKey&&v.key==="l"&&(v.preventDefault(),a([{id:ut(),kind:"info",text:`scope: ${nl(e)}`}]))}const w={input:"text-zinc-300",result:"text-emerald-300",error:"text-red-300",info:"text-zinc-400"};return f("div",{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${n??""}`,onClick:g,children:[f("div",{ref:m,className:"flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]",children:[s.map(v=>o("pre",{className:`whitespace-pre-wrap break-words leading-relaxed ${w[v.kind]}`,children:v.text},v.id)),b.isPending&&o("span",{className:"text-zinc-500 animate-pulse",children:"…thinking"})]}),f("div",{className:"flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]",children:[o("span",{className:"text-emerald-400 flex-shrink-0 select-none font-bold",children:">"}),o("input",{ref:h,value:i,onChange:v=>l(v.target.value),onKeyDown:y,disabled:b.isPending,placeholder:"device.state.battery.value",autoFocus:!0,className:"flex-1 bg-transparent text-zinc-100 placeholder:text-zinc-600 focus:outline-none caret-emerald-400 disabled:opacity-50",spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"})]})]})}function yB(e){const t=ke(),n=e!==null&&Number.isFinite(e),r=my({deviceId:e??0},{enabled:n,refetchInterval:5e3,retry:1}),s=gy({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),a=by({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=r.error?r.error.message:s.error?s.error.message:a.error?a.error.message:null;return{status:r.data??null,isLoading:r.isLoading,isPending:s.isPending||a.isPending,error:c,setEnabled:i,setSettings:l}}function vB({deviceId:e}){const{status:t,isLoading:n,isPending:r,error:s,setEnabled:a,setSettings:i}=yB(Number.isFinite(e)?e:null),[l,c]=_({targetType:"",stopDelaySeconds:30,disappearDelaySeconds:15}),[d,u]=_(!1);return Y(()=>{if(d)return;const p=t?.currentSettings;p&&c({targetType:p.targetType,stopDelaySeconds:p.stopDelaySeconds,disappearDelaySeconds:p.disappearDelaySeconds})},[t,d]),n&&!t?f("div",{className:"flex items-center gap-2 px-3 py-2 text-[10.5px] text-foreground-subtle",children:[o(Se,{className:"h-3 w-3 animate-spin"}),"Loading autotrack…"]}):f("div",{className:"border-t border-border/40 mt-2 pt-2 px-1 space-y-2",children:[f("div",{className:"flex items-center justify-between px-2",children:[f("div",{className:"flex items-center gap-1.5 text-[10.5px] font-semibold text-foreground",children:[o(JR,{className:"h-3 w-3 text-primary"}),"Autotracking"]}),f("button",{type:"button",onClick:()=>{a(!(t?.enabled??!1))},disabled:r,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:[o("span",{className:`h-1.5 w-1.5 rounded-full ${t?.enabled?"bg-success":"bg-foreground-subtle/40"}`}),t?.enabled?"Enabled":"Disabled"]})]}),s&&f("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:[o(nr,{className:"h-3 w-3 flex-shrink-0 mt-0.5"}),o("span",{className:"leading-snug break-words",children:s})]}),f("div",{className:"grid grid-cols-2 gap-2 px-2",children:[(t?.supportedTargetTypes?.length??0)>0&&f("label",{className:"col-span-2 flex flex-col gap-1",children:[o("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Target type"}),o("select",{value:l.targetType,onFocus:()=>u(!0),onChange:p=>c(h=>({...h,targetType:p.target.value})),onBlur:()=>{u(!1);const p=t?.currentSettings?.targetType??"";l.targetType!==p&&i({targetType:l.targetType})},disabled:r,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50",children:(t?.supportedTargetTypes??[]).map(p=>o("option",{value:p.value,children:p.label},p.value))})]}),f("label",{className:"flex flex-col gap-1",children:[o("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Stop delay (s)"}),o("input",{type:"number",min:0,max:300,value:l.stopDelaySeconds,onFocus:()=>u(!0),onChange:p=>c(h=>({...h,stopDelaySeconds:Number(p.target.value)||0})),onBlur:()=>{u(!1);const p=t?.currentSettings?.stopDelaySeconds??30;l.stopDelaySeconds!==p&&i({stopDelaySeconds:l.stopDelaySeconds})},disabled:r,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"})]}),f("label",{className:"flex flex-col gap-1",children:[o("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Disappear delay (s)"}),o("input",{type:"number",min:0,max:300,value:l.disappearDelaySeconds,onFocus:()=>u(!0),onChange:p=>c(h=>({...h,disappearDelaySeconds:Number(p.target.value)||0})),onBlur:()=>{u(!1);const p=t?.currentSettings?.disappearDelaySeconds??15;l.disappearDelaySeconds!==p&&i({disappearDelaySeconds:l.disappearDelaySeconds})},disabled:r,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"})]})]}),o("p",{className:"px-2 text-[9.5px] text-foreground-subtle leading-snug italic",children:"Settings save on blur. Vendor support varies — Reolink honours all three; Hikvision honours target type + stop delay only (disappear delay is accepted but ignored at firmware push)."})]})}function wB({deviceId:e,intercomAvailable:t=!1}){const n=Te(),r=typeof window<"u"?window.location.origin:"",s=Number.isFinite(e),a=iv(s?e:null),{streams:i,pipelineMetrics:l,createSession:c,sendAnswer:d,closeSession:u}=Td(n.trpcClient,s?e:null),p=Zc(n.trpcClient,s?e:null),h=fB(s&&t?e:null),m=h.state==="requesting-mic"||h.state==="starting"||h.state==="connecting"||h.state==="stopping",g=h.isTalking||m,b=()=>{h.state==="idle"||h.state==="error"?h.start():h.state!=="stopping"&&h.stop()},x=e0(),y=x.length>0?o(me,{children:x.map(w=>o("div",{className:"absolute inset-0",children:w.node},w.id))}):null;return o(Cd,{serverUrl:r,createSession:c,sendAnswer:d,closeSession:u,streams:i,pipelineMetrics:l,phase:a.phase,detections:a,defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:p.src,snapshotLoading:p.loading,onRefreshSnapshot:p.refresh,intercomAvailable:t,intercomShown:g,onIntercomToggle:b,extraOverlay:y,chromeless:!0,className:"h-full"})}function NB({deviceId:e}){return Number.isFinite(e)?o("div",{className:"flex flex-col h-full",children:o(tn,{deviceId:e,limit:50,maxHeight:"max-h-full",showScope:!1,showFilters:!1})}):f("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function kB({deviceId:e}){if(!Number.isFinite(e))return f("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(`
|
|
1142
|
-
`);return o(xB,{scope:{type:"device",deviceId:e},greeting:t,className:"h-full border-0 rounded-none"})}function SB({deviceId:e}){const t=Te(),n=Number.isFinite(e),r=Ld(t.trpcClient,n?e:0,{enabled:n}),{data:s}=$7(n?e:0);if(!n)return f("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]});const a=(s?.features??[]).includes(Wn.PtzAutotrack);return f("div",{className:"flex flex-col h-full overflow-y-auto",children:[o(Pd,{controls:r,mode:"panel"}),a&&o(vB,{deviceId:e})]})}function CB({deviceId:e}){return Number.isFinite(e)?o("div",{className:"flex flex-col h-full overflow-y-auto",children:o(br,{deviceId:e,limit:50,maxHeight:"max-h-full"})}):f("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function MB({deviceId:e}){return Number.isFinite(e)?o("div",{className:"flex flex-col h-full overflow-y-auto",children:o(Id,{deviceId:e,limit:50,maxHeight:"max-h-full"})}):f("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function EB({parentDeviceId:e}){const{t}=Vt(),n=rt(),r=Te(),{data:s,isLoading:a,isError:i}=Mv(e);if(a)return o("div",{className:"rounded-lg border border-border bg-surface p-3",children:o("p",{className:"text-[10px] text-foreground-subtle",children:t("common.loading",{defaultValue:"Loading…"})})});if(i)return o("div",{className:"rounded-lg border border-border bg-surface p-3",children:o("p",{className:"text-[10px] text-warning",children:t("integrations.childrenLoadError",{defaultValue:"Failed to load children"})})});const l=s??[];if(l.length===0)return null;const c=l.some(p=>!!p.role),d=l.some(p=>!p.role),u=c&&!d?t("device.accessories",{defaultValue:"Accessories"}):!c&&d?t("device.adoptedDevices",{defaultValue:"Adopted devices"}):t("device.children",{defaultValue:"Children"});return f("div",{className:"rounded-lg border border-border bg-surface p-3",children:[o("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5",children:u}),o("div",{className:"space-y-1",children:l.map(p=>o(Io,{trpc:r.trpcClient,device:p,variant:"minimal",onNavigate:h=>n(`/devices/${String(h)}`)},p.id))})]})}function rl(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function IB({device:e}){const t=rt(),n=typeof e.id=="number"?e.id:null,r=String(e.type??""),s=r===pt.Camera,a=r===pt.Hub,i=e.features??[],{data:l}=fd({deviceId:n??0},{enabled:n!==null&&s,refetchInterval:5e3}),c=l?.streams??{},d=Object.entries(c),u=i.includes(Wn.DoorbellButton),p=Rd(u?{deviceId:n??void 0,historyLimit:10}:void 0),h=p.latest?Date.now()-p.latest.timestamp<3e4:!1;return f("div",{className:"space-y-5",children:[a&&n!==null&&o(x0,{deviceId:n,onOpenChild:m=>t(`/devices/${m}`)}),s&&n!==null&&o(ft,{widgetId:"pipeline-orchestrator/pipeline-quick-stats",host:"device-tab",deviceId:n}),u&&o(_d,{history:p.history,latestIsFresh:h}),s&&n!==null&&o(ft,{widgetId:"stream-broker/stream-broker-panel",host:"device-tab",deviceId:n}),s&&d.length>0&&f("div",{className:"@container rounded-lg border border-border bg-surface overflow-hidden",style:{containerType:"inline-size"},children:[o("div",{className:"border-b border-border px-4 py-2",children:o("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"Stream Network"})}),o("div",{className:"divide-y divide-border",children:d.map(([m,g])=>f("div",{className:"px-4 py-2.5",children:[f("div",{className:"flex items-center gap-2 mb-2",children:[o(or,{className:"h-3 w-3 text-foreground-subtle"}),o("span",{className:"text-[11px] font-medium text-foreground",children:m})]}),f("div",{className:"grid grid-cols-2 @[640px]:grid-cols-4 gap-2",children:[o(Ms,{label:"Nominal",value:rl(g.nominalBitrateKbps??0)}),o(Ms,{label:"Observed",value:rl(g.observedBitrateKbps??0)}),o(Ms,{label:"Peak",value:rl(g.peakBitrateKbps??0)}),o(Ms,{label:"Packet Loss",value:`${(g.packetLossPercent??0).toFixed(2)}%`,warning:(g.packetLossPercent??0)>1})]})]},m))})]}),o(cv,{})]})}function Ms({label:e,value:t,warning:n}){return f("div",{children:[o("p",{className:"text-[10px] text-foreground-subtle",children:e}),o("p",{className:`text-xs font-medium ${n?"text-warning":"text-foreground"}`,children:t})]})}function AB({schema:e,values:t,pendingKeys:n,onChange:r,onAction:s,onSave:a,onDiscard:i,disabled:l}){const c=e.tabs??[],d=H(()=>{const k=new Map;for(const C of e.sections){const E=C.tab??"general",I=k.get(E)??[];I.push(C),k.set(E,I)}return k},[e.sections]),u=new Set(c.map(k=>k.id)),p=[...c,...[...d.keys()].filter(k=>!u.has(k)).map(k=>({id:k,label:k,icon:"wrench",order:100}))],h=p[0]?.id??"general",[m,g]=_(h),b=d.get(m)??[],y={sections:b.length<=1?b.length===1?[{...b[0],title:""}]:b:b.every(C=>!C.title)?[{...b[0],title:"",fields:b.flatMap(C=>C.fields)}]:b},w=o(Pv,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>i(n),saving:l});if(p.length<=1)return f("div",{className:"flex flex-col gap-3",children:[o(Dn,{schema:e,values:t,onChange:r,onAction:s,disabled:l}),w]});const v=new Map,N=new Map;for(const[k,C]of d){v.set(k,C.length);const E=new Set,I=z=>{for(const P of z)if("key"in P&&typeof P.key=="string"&&E.add(P.key),P.type==="group")I(P.fields);else if(P.type==="sub-tabs")for(const B of P.tabs)I(B.fields)};for(const z of C)I(z.fields);const A=n.filter(z=>E.has(z)).length;A>0&&N.set(k,A)}return f("div",{className:"flex flex-col gap-3",children:[o(_v,{tabs:p.map(k=>({id:k.id,label:k.label})),activeId:m,onChange:g,countByTab:v,pendingByTab:N}),o(Dn,{schema:y,values:t,onChange:r,onAction:s,disabled:l}),w]})}function PB(e,t){return t&&t==="admin"?e:!0}function _B(e){if(!e)return null;const n={sections:[...e.sections].sort((r,s)=>{const a=r.tab??"general",i=s.tab??"general";return a!==i?a.localeCompare(i):Do(r)&&Do(s)?r.id.localeCompare(s.id):(r.order??0)-(s.order??0)})};return e.tabs?{...n,tabs:e.tabs}:n}function Tv(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="widget"||e.type==="addon-action-button"}function Lv(e){return e.key}function $B(e){if(!Tv(e))return e.value}function Rv(e){return Tv(e)?null:e}function pa(e,t){for(const n of e)if(t(n),n.type==="group")pa(n.fields,t);else if(n.type==="sub-tabs")for(const r of n.tabs)pa(r.fields,t)}function DB(e){if(!e)return{};const t={};for(const n of e.sections)pa(n.fields,r=>{const s=Lv(r);s!==null&&(t[s]=$B(r))});return t}function Mf(e,t){if(!e)return null;let n=null;for(const r of e.sections)if(pa(r.fields,s=>{if(n!==null||Lv(s)!==t)return;const a=Rv(s);a&&a.writerCapName&&a.writerAddonId&&(n={capName:a.writerCapName,addonId:a.writerAddonId})}),n!==null)break;return n}function TB(e){return{...e,fields:e.fields.map(Ov)}}function Ov(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="object-array"?e:{...e,readonlyField:!0}}function LB(e,t){return e&&{...e,sections:e.sections.map(n=>({...n,fields:n.fields.map(r=>{const s=Rv(r);return s?PB(t,s.minRole)?r:Ov(r):r})}))}}function nc({deviceId:e,sectionFilter:t}){const n=ke(),{user:r}=nn(),s=r?.isAdmin===!0,a=te(!1),{data:i,isLoading:l}=cd({deviceId:e},{refetchInterval:()=>a.current?!1:2500,staleTime:6e4,enabled:Number.isFinite(e)}),{data:c}=er({deviceId:e},{staleTime:6e4,enabled:Number.isFinite(e)}),d=i?.settings??null,u=i?.live??null,p=H(()=>{if(!d&&!u)return null;const B=d?.sections??[],R=(u?.sections??[]).map(TB),M=[...B,...R],D=t?M.filter(t):M.filter(F=>F.location!=="top-tab"&&!Do(F));if(D.length===0)return null;const T=new Set;for(const F of D)T.add(F.tab??"general");const O=[...d?.tabs??[],...(u?.tabs??[]).filter(F=>!(d?.tabs??[]).some(j=>j.id===F.id))].filter(F=>T.has(F.id));return O.length>0?{tabs:O,sections:D}:{sections:D}},[d,u,t]),h=H(()=>_B(p),[p]),m=H(()=>LB(h,s),[h,s]),g=H(()=>DB(m),[m]),b=Iy(),x=ud(),y=rx({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]})}}),w={isPending:y.isPending,mutate:B=>{y.mutate({deviceId:e,changes:[...B]})}},v=U(B=>{const R=Object.entries(B).map(([M,D])=>{const T=Mf(m,M);return T?{writerCapName:T.capName,writerAddonId:T.addonId,key:M,value:D}:null}).filter(M=>M!==null);R.length>0&&w.mutate(R)},[m,w]),N=U(B=>{const R=Object.entries(B).map(([M,D])=>{const T=Mf(m,M);return T?{writerCapName:T.capName,writerAddonId:T.addonId,key:M,value:D}:null}).filter(M=>M!==null);R.length>0&&w.mutate(R)},[m,w]),k=$v({schema:m,serverValues:g,onImmediateSave:v,onDeferredSave:N}),{values:C,pendingKeys:E,handleChange:I,handleSave:A,handleDiscard:z}=k;if(a.current=k.editingPaused,l)return f("div",{className:"flex items-center justify-center py-12 text-foreground-subtle",children:[o(Se,{className:"h-4 w-4 animate-spin mr-2"}),o("span",{className:"text-xs",children:"Loading device aggregate…"})]});if(!m||m.sections.length===0)return o("div",{className:"text-xs text-foreground-subtle italic py-4 text-center",children:"No aggregate contributions for this device."});async function P(B,R,M){if(B==="regenerate-rtsp-token"){const D=["rtspUrl:","regenerateToken:"].find(O=>R.startsWith(O));if(!D)throw new Error(`regenerate-rtsp-token: unrecognised key "${R}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);const T=R.slice(D.length);if(!T)throw new Error(`regenerate-rtsp-token: key "${R}" has no streamId after prefix`);const L=`${e}/${T}`;await b.mutateAsync({brokerId:L}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]});return}if(B==="test-probe"){if(!c)return{status:"error",error:"Device metadata not loaded yet"};try{return await x.mutateAsync({addonId:c.addonId,type:c.type,key:R,value:M})}catch(D){return{status:"error",error:D instanceof Error?D.message:String(D)}}}if(B==="refresh-driver-data"){await y.mutateAsync({deviceId:e,changes:[{writerCapName:"device-manager",writerAddonId:"device-manager",key:R,value:Date.now()}]});return}throw new Error(`[device-aggregate] unknown action "${B}"`)}return o(AB,{schema:m,values:C,pendingKeys:E,onChange:I,onAction:P,onSave:A,onDiscard:z,disabled:w.isPending})}function RB({deviceId:e}){return o(nc,{deviceId:e})}const Bv=6e4,rc=60*Bv,Ef=24*rc;function ni(e){if(e==null||e<=0)return"—";const t=Date.now()-e;return t<0||t<3e4?"just now":t<rc?`${String(Math.floor(t/Bv))}m ago`:t<Ef?`${String(Math.floor(t/rc))}h ago`:`${String(Math.floor(t/Ef))}d ago`}function OB(e,t=new Date){const n=new Date(e);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()}function zv({dev:e,busy:t,setBusy:n}){const r=e?.motionTrigger,s=pn(e?.state.motionTrigger),[a,i]=_(!1);if(!r)return null;const l=s?.enabled===!0,c=s!==void 0,d=async()=>{if(t||!c)return;const p=!l;n(!0),i(!0);try{await r.setMotionTrigger({enabled:p})}finally{n(!1),i(!1)}};return f("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:[o(Xo,{className:"h-3 w-3"}),o("span",{children:a?l?"Disabling…":"Enabling…":c?l?"On motion: on":"On motion: off":"On motion: …"})]})}function Fv({deviceId:e,deviceName:t,useSiren:n=!1}){const r=Te(),s=At(r.trpcClient,e),a=pn(s?.state.switch),[i,l]=_(!1),c=a?.on??!1,d=a?.lastChangedAt??null,u=a!==void 0,p=n?Jo:ev,h=async()=>{if(!(i||!u||!s?.switch)){l(!0);try{await s.switch.setState({on:!c})}finally{l(!1)}}};return f("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[o("button",{type:"button",onClick:()=>{h()},disabled:i||!u||!s?.switch,title:u?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:o(p,{className:"h-10 w-10"})}),o(zv,{dev:s,busy:i,setBusy:l}),f("div",{className:"text-center",children:[o("div",{className:`text-sm font-semibold ${c?"text-success":"text-foreground-subtle"}`,children:u?c?"On":"Off":"Unknown"}),o("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:u?`Changed ${ni(d)}`:"Awaiting state…"})]})]})}function BB({deviceId:e,deviceName:t}){const n=Te(),r=At(n.trpcClient,e),s=pn(r?.state.switch),a=pn(r?.state.brightness),i=s?.on??!1,l=s?.lastChangedAt??null,c=s!==void 0,d=a!==void 0,u=r?.brightness!==void 0,[p,h]=_(!1),[m,g]=_(a?.percentage??0);Y(()=>{a?.percentage!==void 0&&g(a.percentage)},[a?.percentage]);const b=async()=>{if(!(p||!c||!r?.switch)){h(!0);try{await r.switch.setState({on:!i})}finally{h(!1)}}},x=async()=>{if(!(p||!d||!r?.brightness)){h(!0);try{await r.brightness.setBrightness({percentage:m})}finally{h(!1)}}};return f("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[o("button",{type:"button",onClick:()=>{b()},disabled:p||!c||!r?.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:o(I6,{className:"h-9 w-9"})}),u?f("div",{className:"flex w-full max-w-xs flex-col items-center gap-1",children:[o("input",{type:"range",min:0,max:100,step:1,value:m,disabled:p||!i||!d,onChange:y=>g(Number(y.currentTarget.value)),onPointerUp:()=>{x()},onKeyUp:y=>{y.key==="Enter"&&x()},"aria-label":"Brightness",className:"w-full accent-warning disabled:cursor-not-allowed disabled:opacity-50"}),o("div",{className:"text-[10px] text-foreground-subtle tabular-nums",children:d?`${String(m)}%`:"Brightness unavailable"})]}):null,o(zv,{dev:r,busy:p,setBusy:h}),f("div",{className:"text-center",children:[o("div",{className:`text-sm font-semibold ${i?"text-warning":"text-foreground-subtle"}`,children:c?i?"On":"Off":"Unknown"}),o("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:c?`Changed ${ni(l)}`:"Awaiting state…"})]})]})}function zB({deviceId:e}){const t=Te(),n=At(t.trpcClient,e),r=pn(n?.state.motion),s=r?.detected??!1,a=r?.lastDetectedAt??null,i=r!==void 0;return f("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[o("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?o(iO,{className:"h-10 w-10"}):o(Xo,{className:"h-10 w-10"})}),f("div",{className:"text-center",children:[o("div",{className:`text-sm font-semibold ${s?"text-danger":"text-foreground-subtle"}`,children:i?s?"Triggered":"Idle":"Unknown"}),o("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:i?`Last trip ${ni(a)}`:"Awaiting state…"})]})]})}function FB({deviceId:e}){const t=Te(),n=At(t.trpcClient,e),r=pn(n?.state.doorbell),s=r?.lastPressedAt??null,a=r!==void 0,i=s!==null&&Date.now()-s<6e4,[l,c]=_(0),[d,u]=_(null);return Y(()=>{s===null||s===d||(u(s),OB(s)&&c(p=>p+1))},[s,d]),f("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[o("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:o(Jo,{className:"h-10 w-10"})}),f("div",{className:"text-center",children:[o("div",{className:`text-sm font-semibold ${i?"text-primary":"text-foreground-subtle"}`,children:a?`Last press ${ni(s)}`:"Unknown"}),o("div",{className:"text-[10px] text-foreground-subtle mt-0.5 tabular-nums",children:a?`${String(l)} ring${l===1?"":"s"} today`:"Awaiting state…"})]})]})}function jB({deviceName:e,deviceType:t,provider:n,isOnline:r,features:s}){return f("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:[o(gn,{type:n,size:"lg"}),f("div",{children:[o("div",{className:"text-sm font-semibold text-foreground",children:e}),o("div",{className:"text-[10px] text-foreground-subtle uppercase tracking-wider mt-0.5",children:t})]}),f("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[o(ti,{status:r?"online":"offline"}),s.length>0&&o(Ja,{capabilities:s})]}),o("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 VB({deviceId:e}){const t=ke(),n=Hb({deviceId:e},{refetchInterval:1e4,retry:!1}),r=qb({onSuccess:()=>{t.invalidateQueries({queryKey:[["deviceDiscovery","listDiscovered"]]}),t.invalidateQueries({queryKey:[["deviceDiscovery","getStatus"]]})}}),s=H(()=>HB(n.data??[]),[n.data]);return f("div",{className:"flex h-full w-full flex-col gap-3 p-3 sm:p-4",children:[f("div",{className:"flex flex-wrap items-stretch gap-2 sm:gap-3",children:[o(ol,{label:"Discovered",value:s.total,icon:o($n,{className:"h-3.5 w-3.5"})}),o(ol,{label:"Adopted",value:s.adopted,accent:"success"}),o(ol,{label:"Available",value:s.available,accent:s.available>0?"primary":void 0}),f("button",{type:"button",onClick:()=>{r.mutateAsync({deviceId:e}).catch(()=>{})},disabled:r.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:[r.isPending?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(ct,{className:"h-3.5 w-3.5"}),o("span",{className:"hidden sm:inline",children:"Discover"})]})]}),f("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:[o(Es,{icon:o(or,{className:"h-3 w-3 text-emerald-500"}),label:`${s.online} online`}),o(Es,{icon:o(Z0,{className:"h-3 w-3 text-amber-500"}),label:`${s.sleeping} sleeping`}),o(Es,{icon:o(av,{className:"h-3 w-3 text-destructive"}),label:`${s.offline} offline`}),s.unknown>0?o(Es,{icon:o(GR,{className:"h-3 w-3 text-foreground-subtle"}),label:`${s.unknown} unknown`}):null]})]})}function HB(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 ol({label:e,value:t,icon:n,accent:r}){return f("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 ${r==="success"?"bg-emerald-500/10 border-emerald-500/30 text-emerald-500":r==="primary"?"bg-primary/10 border-primary/30 text-primary":"bg-surface-hover border-border text-foreground"}`,children:[f("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider opacity-70 truncate",children:[n,o("span",{className:"truncate",children:e})]}),o("div",{className:"text-xl sm:text-2xl font-semibold tabular-nums leading-none",children:t})]})}function Es({icon:e,label:t}){return f("span",{className:"inline-flex items-center gap-1",children:[e,o("span",{children:t})]})}const qB=e=>o(Fv,{...e,useSiren:!0}),UB={[pt.Switch]:Fv,[pt.Siren]:qB,[pt.Light]:BB,[pt.Sensor]:zB,[pt.Button]:FB,[pt.Hub]:VB};function QB(e){const t=UB[e.deviceType]??jB;return o(t,{...e})}function eu(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 r=Math.floor(t/60),s=t%60;return s>0?`${r}h ${s}m`:`${r}h`}function fa(e){return new Date(e).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ha(e){return e.toISOString().slice(0,10)}function GB(e,t){return ha(e)===ha(t)}function fo(e){const t=new Date(e);return t.setHours(0,0,0,0),t}function KB(e){const t=new Date(e);return t.setHours(23,59,59,999),t}function Tt({className:e=""}){return o("div",{className:`animate-pulse rounded bg-foreground-subtle/10 ${e}`})}function Un(){return f("div",{className:"flex items-center gap-3 px-4 py-3",children:[o(Tt,{className:"h-4 w-4"}),o(Tt,{className:"h-3 w-24"}),o(Tt,{className:"h-3 w-16 ml-auto"})]})}function io({children:e,actions:t}){return f("div",{className:"border-b border-border px-4 py-2.5 flex items-center justify-between",children:[o("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:e}),t]})}function If({icon:e,label:t,value:n}){return f("div",{className:"flex items-center gap-2",children:[o(e,{className:"h-3.5 w-3.5 text-foreground-subtle flex-shrink-0"}),f("div",{className:"min-w-0",children:[o("p",{className:"text-[10px] text-foreground-subtle leading-tight",children:t}),o("p",{className:"text-xs font-medium text-foreground leading-tight",children:n})]})]})}function WB({segments:e,selectedDate:t}){const n=fo(t).getTime(),r=1440*60*1e3,s=Array.from({length:25},(a,i)=>i);return f("div",{className:"space-y-1",children:[o("div",{className:"flex justify-between px-0.5",children:s.filter(a=>a%3===0).map(a=>o("span",{className:"text-[9px] text-foreground-subtle font-mono",children:String(a).padStart(2,"0")},a))}),f("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/r*100),d=Math.min(100-c,(l-i)/r*100);return d<=0?null:o("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:`${fa(a.startTime)} - ${fa(a.endTime)} (${eu(a.duration)})`},a.id)}),s.slice(1,-1).map(a=>o("div",{className:"absolute top-0 bottom-0 w-px bg-border/50",style:{left:`${a/24*100}%`}},a))]})]})}function YB({segment:e,selected:t,onToggle:n,onPlay:r,onDownload:s,onDelete:a}){return f("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:[o("button",{onClick:n,className:"flex-shrink-0 text-foreground-subtle hover:text-foreground",children:t?o(rv,{className:"h-4 w-4 text-primary"}):o(ts,{className:"h-4 w-4"})}),f("div",{className:"flex-1 min-w-0",children:[f("p",{className:"text-xs font-mono text-foreground",children:[fa(e.startTime)," - ",fa(e.endTime)]}),f("p",{className:"text-[10px] text-foreground-subtle",children:[eu(e.duration),e.sizeBytes!=null&&` · ${It(e.sizeBytes)}`]})]}),f("div",{className:"flex items-center gap-1 flex-shrink-0",children:[o("button",{onClick:r,title:"Play",className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:o(Ya,{className:"h-3.5 w-3.5"})}),o("button",{onClick:s,title:"Download",className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:o(Xt,{className:"h-3.5 w-3.5"})}),o("button",{onClick:a,title:"Delete",className:"p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger transition-colors",children:o(Ze,{className:"h-3.5 w-3.5"})})]})]})}function ZB({deviceId:e}){const t=ke(),[n,r]=_(()=>fo(new Date)),[s,a]=_(new Set),i=Sy({deviceId:e},{refetchInterval:5e3}),l=wy({deviceId:e}),c=l.data?.streams[0]?.streamId??"stream0",d=Ny({deviceId:e,streamId:c,startTime:fo(n).getTime(),endTime:KB(n).getTime()}),u=ky({deviceId:e,streamId:c},{refetchInterval:3e4}),p=Cy({deviceId:e,dataCategory:"recording:main"}),h=U(()=>{t.invalidateQueries({queryKey:["recordingEngine","getPolicyStatus"]}),t.invalidateQueries({queryKey:["recordingEngine","getSegments"]}),t.invalidateQueries({queryKey:["recordingEngine","getStorageUsage"]})},[t]),m=yy({onSuccess:h}),g={isPending:m.isPending,error:m.error,mutate:()=>{const T=l.data,L=T?{mode:T.mode,streams:T.streams,enabled:!0,preBufferSec:T.preBufferSec,postBufferSec:T.postBufferSec,scheduleRules:T.scheduleRules}:{mode:"continuous",streams:[{streamId:c,mode:"always"}],enabled:!0,preBufferSec:10,postBufferSec:5};m.mutate({deviceId:e,policy:L})}},b=vy({onSuccess:h}),x=i.data??void 0,y=l.data??void 0,w=d.data??[],v=u.data,N=p.data??void 0,k=(x?.enabled??!1)&&(x?.activeStreams??0)>0,C=g.isPending||b.isPending,E=GB(n,new Date),I=H(()=>[...w].sort((T,L)=>new Date(L.startTime).getTime()-new Date(T.startTime).getTime()),[w]),A=H(()=>w.reduce((T,L)=>T+(L.duration??0),0),[w]),z=H(()=>w.reduce((T,L)=>T+(L.sizeBytes??0),0),[w]);function P(){k?b.mutate({deviceId:e}):g.mutate()}function B(){r(T=>{const L=new Date(T);return L.setDate(L.getDate()-1),fo(L)}),a(new Set)}function R(){E||(r(T=>{const L=new Date(T);return L.setDate(L.getDate()+1),fo(L)}),a(new Set))}function M(T){a(L=>{const O=new Set(L);return O.has(T)?O.delete(T):O.add(T),O})}function D(){s.size===I.length?a(new Set):a(new Set(I.map(T=>T.id)))}return i.isLoading&&l.isLoading?f("div",{className:"space-y-4",children:[f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(io,{children:"Recording Status"}),f("div",{className:"px-4 py-4 space-y-3",children:[o(Tt,{className:"h-10 w-full"}),o(Tt,{className:"h-4 w-48"})]})]}),f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(io,{children:"Segments"}),f("div",{className:"divide-y divide-border",children:[o(Un,{}),o(Un,{}),o(Un,{})]})]})]}):f("div",{className:"space-y-4",children:[f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(io,{children:"Recording Status"}),f("div",{className:"px-4 py-4 flex items-center justify-between gap-4",children:[f("div",{className:"flex items-center gap-3 min-w-0",children:[o("div",{className:`flex items-center justify-center rounded-full p-2 flex-shrink-0 ${k?"bg-danger/10":"bg-foreground-subtle/10"}`,children:o(U0,{className:`h-5 w-5 ${k?"text-danger animate-pulse":"text-foreground-subtle"}`})}),f("div",{className:"min-w-0",children:[o("p",{className:`text-sm font-medium ${k?"text-danger":"text-foreground-subtle"}`,children:k?"Recording":"Not Recording"}),o("p",{className:"text-[11px] text-foreground-subtle mt-0.5 truncate",children:k&&x?`${x.mode} – ${x.activeStreams} stream(s)`:"No active recording session"})]})]}),o("button",{onClick:P,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?f(me,{children:[o(ts,{className:"h-3.5 w-3.5"}),C?"Stopping...":"Stop Recording"]}):f(me,{children:[o(Ya,{className:"h-3.5 w-3.5"}),C?"Starting...":"Start Recording"]})})]}),k&&x&&f("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-[11px] text-foreground-subtle",children:[o(yo,{className:"h-3.5 w-3.5 text-primary flex-shrink-0"}),f("span",{children:[x.activeStreams," active stream",x.activeStreams!==1?"s":""," · mode: ",x.mode]})]})]}),f("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(io,{children:f("span",{className:"flex items-center gap-1.5",children:[o(Jt,{className:"h-3.5 w-3.5"}),"Settings"]})}),l.isLoading?f("div",{className:"px-4 py-3 space-y-2",children:[o(Tt,{className:"h-3 w-32"}),o(Tt,{className:"h-3 w-40"}),o(Tt,{className:"h-3 w-28"})]}):f("div",{className:"divide-y divide-border",children:[o(lo,{label:"Stream",value:c}),o(lo,{label:"Pre-buffer",value:y?`${y.preBufferSec}s`:"N/A"}),o(lo,{label:"Mode",value:y?.mode??"continuous"}),o(lo,{label:"Retention",value:N?.retentionDays!=null?`${N.retentionDays} days`:"N/A"}),N?.retentionGb!=null&&o(lo,{label:"Max Storage",value:`${N.retentionGb} GB`})]})]}),f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o(io,{children:f("span",{className:"flex items-center gap-1.5",children:[o(ia,{className:"h-3.5 w-3.5"}),"Storage"]})}),u.isLoading?f("div",{className:"px-4 py-3 space-y-2",children:[o(Tt,{className:"h-3 w-28"}),o(Tt,{className:"h-3 w-36"}),o(Tt,{className:"h-3 w-24"})]}):u.error?f("div",{className:"px-4 py-4 flex items-center gap-2 text-xs text-danger",children:[o(it,{className:"h-4 w-4"}),"Failed to load storage info"]}):f("div",{className:"px-4 py-3 grid grid-cols-2 gap-3",children:[o(If,{icon:ia,label:"Total",value:v?.totalBytes!=null?It(v.totalBytes):"N/A"}),o(If,{icon:yo,label:"Segments",value:v?.segmentCount!=null?String(v.segmentCount):"N/A"})]})]})]}),f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"border-b border-border px-4 py-2.5 flex items-center justify-between",children:[o("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"Segment Browser"}),f("div",{className:"flex items-center gap-2",children:[o("button",{onClick:B,className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:o(Gd,{className:"h-4 w-4"})}),f("div",{className:"flex items-center gap-1.5 text-xs text-foreground font-medium",children:[o(H0,{className:"h-3.5 w-3.5 text-foreground-subtle"}),E?"Today":ha(n)]}),o("button",{onClick:R,disabled:E,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:o(wt,{className:"h-4 w-4"})})]})]}),f("div",{className:"px-4 py-3 border-b border-border",children:[o(WB,{segments:w,selectedDate:n}),f("div",{className:"flex items-center gap-4 mt-2 text-[10px] text-foreground-subtle",children:[f("span",{children:[w.length," segment",w.length!==1?"s":""]}),A>0&&f("span",{children:[eu(A)," recorded"]}),z>0&&o("span",{children:It(z)})]})]}),I.length>0&&f("div",{className:"border-b border-border px-4 py-2 flex items-center justify-between",children:[o("button",{onClick:D,className:"text-[11px] text-foreground-subtle hover:text-foreground transition-colors",children:s.size===I.length?"Deselect All":"Select All"}),s.size>0&&f("div",{className:"flex items-center gap-2",children:[f("span",{className:"text-[10px] text-foreground-subtle",children:[s.size," selected"]}),f("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:[o(Xt,{className:"h-3 w-3"}),"Download"]}),f("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:[o(Ze,{className:"h-3 w-3"}),"Delete"]})]})]}),d.isLoading?f("div",{className:"divide-y divide-border",children:[o(Un,{}),o(Un,{}),o(Un,{}),o(Un,{})]}):I.length===0?f("div",{className:"flex flex-col items-center justify-center py-12 text-foreground-subtle",children:[o(yo,{className:"h-8 w-8 mb-3 opacity-30"}),o("p",{className:"text-sm",children:"No recorded segments"}),o("p",{className:"text-xs mt-1 opacity-70",children:E?"Recorded clips will appear here as they are created":`No recordings found for ${ha(n)}`})]}):o("div",{className:"max-h-[400px] overflow-y-auto",children:I.map(T=>o(YB,{segment:T,selected:s.has(T.id),onToggle:()=>M(T.id),onPlay:()=>{},onDownload:()=>{},onDelete:()=>{}},T.id))})]}),i.error&&f("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:[o(it,{className:"h-4 w-4 flex-shrink-0"}),"Failed to load recording status. Will retry automatically."]}),(g.error||b.error)&&f("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:[o(it,{className:"h-4 w-4 flex-shrink-0"}),g.error?`Failed to start recording: ${g.error instanceof Error?g.error.message:"Unknown error"}`:`Failed to stop recording: ${b.error instanceof Error?b.error.message:"Unknown error"}`]})]})}function lo({label:e,value:t}){return f("div",{className:"flex items-center justify-between px-4 py-2.5",children:[o("span",{className:"text-xs text-foreground-subtle",children:e}),o("span",{className:"text-xs font-medium text-foreground",children:t})]})}function XB({deviceId:e}){const t=ke(),n=Number.isFinite(e),{data:r}=er({deviceId:e},{enabled:n}),s=typeof r?.type=="string"?r.type:"camera";St(["deviceManager","getBindings"],["capability.binding-changed"]);const{data:a,isLoading:i,isError:l,error:c}=ex({deviceId:e},{staleTime:3e4,enabled:n}),{data:d}=nx({deviceType:s},{staleTime:3e4,enabled:!!s}),u=tx({onSuccess:()=>{t.invalidateQueries({queryKey:[["deviceManager","getBindings"]]})}});if(i)return o("div",{className:"p-4",children:o("div",{className:"h-20 rounded-lg border border-border bg-surface animate-pulse"})});if(l)return f("div",{className:"p-4 text-xs text-red-400",children:["Failed to load bindings: ",c instanceof Error?c.message:String(c)]});const p=new Map,h={};for(const b of d??[])h[b.capName]=b.wrappers;for(const b of a?.entries??[])p.set(b.capName,{...b,wrappers:h[b.capName]??[]});for(const b of d??[])p.has(b.capName)||p.set(b.capName,{capName:b.capName,kind:"unbound",providerAddonId:"",providerNodeId:"",nativeAddonId:"",wrappers:b.wrappers});const m=[...p.values()].sort((b,x)=>b.capName.localeCompare(x.capName));if(m.length===0)return f("div",{className:"flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle",children:[o(Wa,{className:"h-8 w-8 opacity-40"}),o("p",{className:"text-xs",children:"No capability providers applicable to this device yet."}),o("p",{className:"text-[10px] opacity-60",children:"Native providers show up here as soon as the owning addon registers them."})]});const g=m.filter(b=>b.kind!=="unbound").length;return f("div",{className:"flex flex-col gap-3 p-1",children:[f("div",{className:"text-[11px] text-foreground-subtle",children:[o("span",{className:"font-medium text-foreground",children:g})," ","of ",m.length," capabilit",m.length===1?"y":"ies"," bound — rows marked ",o("em",{children:"unbound"})," have a wrapper available you can activate."]}),o("div",{className:"overflow-hidden rounded-lg border border-border bg-surface",children:f("table",{className:"w-full border-collapse text-[11px]",children:[o("thead",{children:f("tr",{className:"bg-surface-hover/50 text-left text-[10px] uppercase tracking-wide text-foreground-subtle",children:[o("th",{className:"px-3 py-2 font-medium",children:"Capability"}),o("th",{className:"px-3 py-2 font-medium",children:"Kind"}),o("th",{className:"px-3 py-2 font-medium",children:"Active Provider"}),o("th",{className:"px-3 py-2 font-medium",children:"Node"}),o("th",{className:"px-3 py-2 font-medium",children:"Native"}),o("th",{className:"px-3 py-2 font-medium",children:"Wrapper"})]})}),o("tbody",{children:m.map(b=>{const x=b.kind==="wrapped"?b.providerAddonId:null;return f("tr",{className:"border-t border-border align-middle",children:[o("td",{className:"px-3 py-2 font-mono text-foreground",children:b.capName}),o("td",{className:"px-3 py-2",children:o(JB,{kind:b.kind})}),o("td",{className:"px-3 py-2 font-mono text-foreground-subtle",children:b.providerAddonId||o("span",{className:"opacity-40",children:"—"})}),o("td",{className:"px-3 py-2",children:b.providerNodeId?o(ez,{nodeId:b.providerNodeId}):o("span",{className:"text-[10px] opacity-40",children:"—"})}),o("td",{className:"px-3 py-2 font-mono text-foreground-subtle",children:b.nativeAddonId||o("span",{className:"opacity-40",children:"—"})}),o("td",{className:"px-3 py-2",children:o(tz,{wrappers:b.wrappers,activeWrapperId:x,disabled:u.isPending,onPick:y=>{const w=x===y;u.mutate({deviceId:e,capName:b.capName,wrapperAddonId:y,active:!w})}})})]},b.capName)})})]})})]})}function JB({kind:e}){return e==="native"?f("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:[o(hn,{className:"h-3 w-3"}),"native"]}):e==="wrapped"?f("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:[o(C6,{className:"h-3 w-3"}),"wrapped"]}):f("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:[o(H6,{className:"h-3 w-3"}),"unbound"]})}function ez({nodeId:e}){return o("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 tz({wrappers:e,activeWrapperId:t,disabled:n,onPick:r}){return e.length===0?o("span",{className:"text-[10px] opacity-40",children:"none available"}):o("div",{className:"flex flex-wrap gap-1",children:e.map(s=>{const a=s===t;return f("button",{disabled:n,onClick:()=>r(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?o(_t,{className:"h-3 w-3"}):o(tv,{className:"h-3 w-3"}),s]},s)})})}function nz(e,t){if(!e)return null;for(const n of e.slots)for(const r of n.addons)if(r.id===t)return r;return null}function rz(e,t,n){const r=e?.stepOverridesByAgent?.[t]?.[n];if(r)return r.enabled===!1?"off":(r.enabled===!0,"on");const s=e?.stepToggles?.[n];return s===!1?"off":s===!0?"on":"inherit"}function oz({agents:e,currentAgent:t,onPick:n}){const[r,s]=_(!1);return f("div",{className:"relative",children:[o("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 ▾"}),r&&o("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=>o("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 sz({deviceId:e,refreshToken:t}){const n=ke(),[r,s]=_(null),[a,i]=_(null),[l,c]=_(null),[d,u]=_(null),p=gd({deviceId:e}),h=Yr(),m=Fa({deviceId:e}),g=Yx(),b=H(()=>{const D=m.data?.agentNodeId;if(D)return D;const T=g.data?.find(L=>L.online)?.nodeId;return T||"hub"},[m.data?.agentNodeId,g.data]),x=a??b,y=Wo({nodeId:x??""},{enabled:!!x}),w=ly({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),c(null)}}),v=H(()=>y.data?Ta(y.data):[],[y.data]),N=H(()=>{const D=p.data??null,T={};for(const L of h.data??[])for(const O of Object.keys(L.settings.addonDefaults)){const F=T[O]??[];F.push({agentNodeId:L.nodeId,state:rz(D,L.nodeId,O)}),T[O]=F}return T},[p.data,h.data]),k=r?nz(y.data??null,r):null,C=x?h.data?.find(D=>D.nodeId===x)??null:null,E=r&&C?C.settings.addonDefaults[r]??null:null,I=r&&x?p.data?.stepOverridesByAgent?.[x]?.[r]??null:null,A=y.data?.selectedEngine.format??"coreml",z=D=>{i(D),c(null),u(null)},P=D=>{s(D),c(null),u(null)},B=D=>{if(!x||!r||!y.data||!h.data)return;const T=h.data.find(F=>F.nodeId===D),L=h.data.find(F=>F.nodeId===x);if(!T||!L)return;const[O]=Vm({source:{nodeId:T.nodeId,engine:{format:A},defaults:T.settings.addonDefaults},target:{nodeId:L.nodeId,engine:{format:A},defaults:L.settings.addonDefaults},catalog:y.data,addonIds:[r]});if(!O){u("no mirror result");return}if(O.outcome==="skip"){u(`skipped: ${O.reason??"no candidate"}`);return}c(O.patch),u(`${O.outcome} from ${D}`)},R=()=>{!x||!r||w.mutate({deviceId:e,agentNodeId:x,addonId:r,patch:l})},M=()=>{!x||!r||w.mutate({deviceId:e,agentNodeId:x,addonId:r,patch:null})};return h.isLoading||y.isLoading?o("div",{className:"text-xs text-foreground-subtle animate-pulse p-4",children:"Loading pipeline…"}):y.data?o("div",{className:"@container h-full",style:{containerType:"inline-size"},children:f("div",{className:"flex flex-col @[720px]:flex-row h-full",children:[o("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:o(Lg,{tree:v,selectedAddonId:r,onSelect:P,agentDots:N})}),o("section",{className:"flex-1 min-w-0 p-4 overflow-y-auto",children:!r||!k?o("div",{className:"text-sm text-foreground-subtle",children:"Select a step on the left to configure it for this camera."}):f("div",{className:"space-y-4",children:[f("div",{children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Selected step"}),o("div",{className:"text-base font-semibold",children:k.name})]}),f("div",{className:"flex items-end gap-3 flex-wrap",children:[f("div",{children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle mb-1",children:"Agent"}),o("div",{className:"flex rounded border border-border overflow-hidden",children:(h.data??[]).map(D=>o("button",{type:"button",onClick:()=>z(D.nodeId),className:`px-3 py-1 text-xs ${x===D.nodeId?"bg-primary text-primary-foreground":"bg-surface hover:bg-muted"}`,children:D.nodeId},D.nodeId))})]}),o(oz,{agents:(h.data??[]).map(D=>D.nodeId),currentAgent:x,onPick:B}),d&&o("div",{className:"text-[10px] text-foreground-subtle",children:d})]}),E&&o(Ra,{mode:"device",addon:k,agentDefault:E,agentNodeId:x??"",currentPatch:l??I,engineFormat:A,onChangePatch:c}),f("div",{className:"flex items-center justify-between gap-2 pt-4 border-t border-border",children:[o("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted text-foreground-subtle",disabled:!I||w.isPending,onClick:M,children:"Clear override"}),f("div",{className:"flex items-center gap-2",children:[o("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"}),o("button",{type:"button",className:"px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50",disabled:!x||!r||w.isPending,onClick:R,children:w.isPending?"Saving…":"Save"})]})]})]})})]})}):o("div",{className:"text-xs text-foreground-subtle p-4",children:"Catalog unavailable."})}const az=[{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 iz(e){const t=e===pt.Camera;return az.filter(n=>t||!n.cameraOnly).map(({id:n,label:r})=>({id:n,label:r}))}const lz=[{id:"logs",icon:at,label:"Logs"},{id:"repl",icon:ov,label:"REPL"},{id:"events",icon:Jo,label:"Events"},{id:"state",icon:Q0,label:"State"},{id:"ptz",icon:K6,label:"PTZ",featureGate:Wn.PanTiltZoom}];function cz(){const e=zd(),t=Number(e.deviceId),n=Number.isFinite(t),r=rt(),s=ke(),a=nt(),i=Te(),[l,c]=_("overview"),[d,u]=_("logs"),p="device-detail.left-col-width-px",[h,m]=_(()=>{if(typeof window>"u")return null;const de=window.localStorage.getItem(p),ce=de?Number(de):NaN;return Number.isFinite(ce)&&ce>0?ce:null}),g=te(h);g.current=h;function b(de){de.preventDefault();const ce=de.clientX,Ce=de.currentTarget.previousElementSibling?.getBoundingClientRect().width??h??0,pe=280,$e=Math.max(pe+50,Math.floor(window.innerWidth*.7)),Ae=dt=>{const yr=Math.max(pe,Math.min($e,Ce+(dt.clientX-ce)));m(yr)},Xe=()=>{document.removeEventListener("mousemove",Ae),document.removeEventListener("mouseup",Xe);const dt=g.current;if(dt!==null)try{window.localStorage.setItem(p,String(Math.round(dt)))}catch{}document.body.style.userSelect="",document.body.style.cursor=""};document.body.style.userSelect="none",document.body.style.cursor="col-resize",document.addEventListener("mousemove",Ae),document.addEventListener("mouseup",Xe)}const{data:x,isLoading:y,isError:w}=er({deviceId:t},{enabled:n,refetchInterval:5e3,retry:1}),{data:v}=cd({deviceId:t},{enabled:n,staleTime:3e4}),N=H(()=>{const de=v?.settings?.sections??[],ce=v?.live?.sections??[],Ce=[...de,...ce],pe=new Set;for(const Ae of Ce)Ae.location==="top-tab"&&Ae.tab&&pe.add(Ae.tab);return Ce.some(Do)&&pe.add(tl),[...pe].map(Ae=>{if(Ae===tl)return{id:Ae,label:pB,isAddonContrib:!0};const Xe=Nl[Ae];return{id:Ae,label:Xe?.label??Ae,isAddonContrib:!0}})},[v]),k=x,C=String(k?.name??e.deviceId??"Device"),E=k?.online===!0,I=E?"online":"offline",A=String(k?.addonId??"rtsp"),z=k?.features??[],P=k?.type,B=P===pt.Camera,R=typeof k?.parentDeviceId=="number"?k.parentDeviceId:null,{data:M}=er({deviceId:R??0},{enabled:R!==null,staleTime:3e4}),D=hr(),T=H(()=>[...iz(P),...N],[P,N]),{data:L}=Mv(n?t:0),O=(L??[]).length>0,F=H(()=>lz.filter(({featureGate:de})=>!de||z.includes(de)),[z]),{data:j}=lx({addonId:A},{enabled:!!A&&A!=="rtsp"}),V=Jb({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]}),r(j?.id?`/integrations/${j.id}`:"/integrations")}}),$=Zb({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),q=Xb({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),G=xy(),Z=Ko({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),oe=z.includes(Wn.Rebootable),ne=z.includes(Wn.BatteryOperated),X=Yc(i.trpcClient,ne&&n?t:null),[re,be]=_(!1),J=At(i.trpcClient,n?t:null),W=async()=>{if(!(re||!J)){be(!0);try{await J.snapshot?.invalidateCache({});const de=await J.snapshot?.getSnapshot({});if(!de)return;const ce=`data:${de.contentType};base64,${de.base64}`,Ce=de.contentType.includes("png")?"png":"jpg",pe=C.replace(/[^a-zA-Z0-9_.-]+/g,"_"),$e=new Date().toISOString().replace(/[:.]/g,"-"),Ae=document.createElement("a");Ae.href=ce,Ae.download=`${pe}-${$e}.${Ce}`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae)}finally{be(!1)}}},ee=$.isPending||q.isPending,{data:ae}=Fa({deviceId:t},{enabled:n,refetchInterval:1e4}),fe=ae?.agentNodeId??null,Q=typeof fe=="string"&&fe.length>0&&!fe.startsWith("addon:")?fe:void 0,{data:le}=bd({deviceId:t,...Q?{nodeId:Q}:{}},{enabled:n,refetchInterval:3e3,retry:!1});function ue(){if(!n)return null;switch(l){case"overview":return o(IB,{device:k??{}});case"config":return o(RB,{deviceId:t});case"pipeline":return o(sz,{deviceId:t,refreshToken:0});case"bindings":return o(XB,{deviceId:t});case"recording":return o(ZB,{deviceId:t});default:{const de=l;return N.some(Ce=>Ce.id===de)?de===tl?o(nc,{deviceId:t,sectionFilter:Do}):o(nc,{deviceId:t,sectionFilter:Ce=>Ce.location==="top-tab"&&Ce.tab===de}):null}}}return n?y?f("div",{className:"flex flex-col h-full",children:[f("div",{className:"border-b border-border bg-surface px-6 py-4",children:[o("div",{className:"h-4 w-48 rounded bg-surface-hover animate-pulse mb-3"}),o("div",{className:"h-8 w-64 rounded bg-surface-hover animate-pulse"})]}),o("div",{className:"flex-1 p-6",children:o("div",{className:"h-40 rounded-lg border border-border bg-surface animate-pulse"})})]}):w||!x?f("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle",children:[o("p",{className:"text-lg font-semibold text-foreground",children:"Device not found"}),f("p",{className:"text-xs",children:["No device with ID ",f("code",{className:"font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]",children:["#",t]})]}),o("button",{onClick:()=>r("/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"})]}):f("div",{className:"absolute inset-0 flex flex-col overflow-hidden",children:[f("div",{className:"border-b border-border bg-surface px-6 py-3 flex-shrink-0",children:[o("div",{className:"mb-2",children:o(Hc,{items:[{label:"Integrations",onClick:()=>r("/integrations")},{label:j?.name??A,onClick:()=>j?.id&&r(`/integrations/${j.id}`)},{label:C}]})}),f("div",{className:"flex items-center gap-2 sm:gap-3",children:[o(gn,{type:A,size:"lg"}),f("div",{className:"min-w-0 flex-1",children:[f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("h1",{className:"text-sm sm:text-base font-semibold text-foreground truncate",children:C}),o(ti,{status:I}),ne&&o(Xc,{status:X,variant:"full"})]}),R!==null&&M&&f("button",{type:"button",onClick:()=>r(`/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:[o("span",{children:"↑"}),o("span",{className:"truncate",children:String(M.name??`Device #${R}`)})]}),o("div",{className:"hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle",children:z.length>0&&o(Ja,{capabilities:z})})]}),le&&o("div",{className:"hidden lg:flex",children:o(dz,{metrics:le})}),f("div",{className:"flex items-center gap-1 shrink-0",children:[f("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:ee,title:"Disable device",className:"inline-flex items-center gap-1.5 rounded-lg px-2 sm:px-2.5 py-1.5 text-[11px] font-medium border transition-colors disabled:opacity-50 border-success/30 text-success hover:bg-success/10",children:[o(ev,{className:"h-3.5 w-3.5"}),o("span",{className:"hidden sm:inline",children:ee?"Updating…":"Enabled"})]}),o("div",{className:"hidden sm:block h-5 w-px bg-border mx-1"}),o(y0,{triggerClassName:"ml-1",items:[{id:"snapshot",label:"Take snapshot",description:"Fetch a fresh frame and download it.",icon:Dr,disabled:re,onClick:()=>{W()}},{id:"reboot",label:"Reboot device",description:"Camera goes offline for ~30 seconds.",icon:kt,hidden:!oe,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??A}.`,icon:ct,disabled:Z.isPending,danger:!0,onClick:async()=>{await a({title:`Restart "${j?.name??A}"?`,message:`Restarting the addon will briefly disconnect every device served by it (not just "${C}"). Streams will reconnect automatically.`,confirmLabel:"Restart",variant:"danger"})&&Z.mutate({addonId:A})}},{id:"delete",label:"Delete device",description:"Remove the device and all its settings.",icon:Ze,separatorBefore:!0,disabled:V.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"})&&V.mutate({deviceId:t})}}]})]})]})]}),o(cb,{deviceId:t,device:k??void 0,children:o(Jy,{children:o(w0,{children:f("main",{className:D?"flex-1 overflow-y-auto flex flex-col":"flex-1 min-h-0 overflow-hidden flex flex-row",children:[f("div",{className:D?"flex flex-col bg-surface":`${h===null?"w-1/2 lg:w-1/3":""} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-hidden`,style:!D&&h!==null?{width:`${String(h)}px`}:void 0,children:[o("div",{className:`flex-shrink-0 border-b border-border-subtle ${B?"aspect-video bg-black":"bg-surface"}`,children:B?o(wB,{deviceId:t,intercomAvailable:z.includes(Wn.TwoWayAudio)}):o(QB,{deviceId:t,deviceName:C,deviceType:P??"unknown",provider:A,isOnline:E,features:z})}),f("div",{className:D?"flex flex-col border-b border-border":"flex-1 min-h-0 flex flex-col overflow-hidden",children:[o("div",{className:"flex-shrink-0 border-b border-border-subtle px-2 py-1.5",children:o("div",{className:"flex gap-1 overflow-x-auto -mx-1 px-1 pb-0.5",children:F.map(({id:de,label:ce,icon:Ce})=>f("button",{onClick:()=>u(de),title:ce,className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors flex-shrink-0 ${d===de?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,children:[o(Ce,{className:"h-3 w-3"}),ce]},de))})}),f("div",{className:D?"h-72 overflow-hidden":"flex-1 min-h-0 overflow-hidden",children:[d==="logs"&&o(NB,{deviceId:t}),d==="repl"&&o(kB,{deviceId:t}),d==="events"&&o(CB,{deviceId:t}),d==="state"&&o(MB,{deviceId:t}),d==="ptz"&&o(SB,{deviceId:t})]})]})]}),!D&&o("div",{role:"separator","aria-orientation":"vertical",title:"Drag to resize",onMouseDown:b,className:"flex-shrink-0 w-1 cursor-col-resize bg-border hover:bg-primary/40 transition-colors group relative z-10",children:o("span",{className:"absolute inset-y-0 -left-1 -right-1"})}),f("div",{className:D?"flex flex-col":"flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden",children:[o("div",{className:"flex-shrink-0 border-b border-border bg-surface px-4",children:o("div",{className:"flex flex-wrap items-center gap-0",children:T.map(de=>{const ce=l===de.id;return f("button",{onClick:()=>c(de.id),className:`relative flex-shrink-0 px-3 py-2 text-xs font-medium transition-colors ${ce?"text-primary":"text-foreground-subtle hover:text-foreground"}`,children:[de.label,ce&&o("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 rounded-full bg-primary"})]},de.id)})})}),f("div",{className:D?"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"&&O&&o(EB,{parentDeviceId:t}),ue()]})]})]})})})})]}):f("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle",children:[o("p",{className:"text-lg font-semibold text-foreground",children:"Invalid device id"}),f("p",{className:"text-xs",children:["The URL segment ",o("code",{className:"font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]",children:e.deviceId})," is not a number."]}),o("button",{onClick:()=>r("/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 dz({metrics:e}){const t=e.phase??"idle",n=ur(t);return f("div",{className:"flex items-center gap-3 flex-shrink-0",children:[f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:`h-1.5 w-1.5 rounded-full ${n.dotClass}`}),o("span",{className:`text-[10px] font-medium ${n.textColor}`,children:n.label})]}),o("div",{className:"h-3 w-px bg-border"}),f("div",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle",children:[o(Xo,{className:"h-3 w-3"}),o("span",{className:"text-foreground tabular-nums",children:(e.actualFps??0).toFixed(1)}),o("span",{children:"fps"})]}),f("div",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle",children:[o(bt,{className:"h-3 w-3"}),o("span",{className:"text-foreground tabular-nums",children:(e.avgInferenceTimeMs??0).toFixed(0)}),o("span",{children:"ms"})]}),(e.queueDepth??0)>0&&f("span",{className:"text-[10px] text-warning tabular-nums",children:["q:",e.queueDepth]})]})}function jv({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:s}){const a=n==="upload"||n==="local",{data:i,isLoading:l}=yb({name:e},{staleTime:5*6e4});return f("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 u=window.innerHeight-d.bottom,p=d.top;u<280&&p>u?(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:[f("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[o("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Versions"}),o("button",{type:"button",onClick:s,className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-3 w-3"})})]}),a&&f("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]",children:[o(Xa,{className:"h-3 w-3 mt-0.5 text-cyan-500 shrink-0"}),f("div",{className:"text-cyan-700 dark:text-cyan-200",children:[f("span",{className:"font-semibold",children:[n==="upload"?"Uploaded copy":"Local copy"," in place."]})," ","Re-install ",o("span",{className:"font-mono",children:t})," from npm to track upstream releases again."]})]}),l&&f("div",{className:"flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle",children:[o(Se,{className:"h-3.5 w-3.5 animate-spin"}),"Loading versions..."]}),i&&o("div",{className:"max-h-64 overflow-auto divide-y divide-border",children:i.map(c=>{const d=c.version===t,u=/-(alpha|beta|rc|dev|canary|next)/i.test(c.version);return f("div",{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${d?"bg-primary/5":"hover:bg-surface-hover"} transition-colors`,children:[o("span",{className:`font-mono flex-1 ${d?"text-primary font-semibold":u?"text-amber-400":"text-foreground"}`,children:c.version}),c.distTags.map(p=>o("span",{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${p==="latest"?"bg-emerald-500/15 text-emerald-400":p==="beta"?"bg-amber-500/15 text-amber-400":"bg-gray-500/15 text-gray-400"}`,children:p},p)),c.deprecated&&o("span",{className:"text-[9px] text-red-400 line-through",children:"deprecated"}),o("span",{className:"text-[9px] text-foreground-subtle shrink-0",children:new Date(c.publishedAt).toLocaleDateString()}),d&&!a?o(_t,{className:"h-3 w-3 text-primary shrink-0"}):o("button",{type:"button",onClick:()=>r(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:o(Xt,{className:"h-3 w-3"})})]},c.version)})}),i&&i.length===0&&o("div",{className:"py-4 text-center text-[10px] text-foreground-subtle",children:"No versions found"})]})}const uz="device-export";function pz(e){return e.capabilities.some(t=>(typeof t=="string"?t:t.name)===uz)}function fz({isBundle:e,installSource:t,addonId:n,iconPath:r,color:s}){const[a,i]=_(!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&&r?`/api/addon-assets/${n}/${r}`:null,u=!!d&&!a;return f("div",{className:"relative flex-shrink-0",children:[o("div",{className:`h-9 w-9 rounded-lg flex items-center justify-center ${l?"":c}`,style:l,children:u?o("img",{src:d,alt:n,className:"h-5 w-5",onError:()=>i(!0)}):e?o(X0,{className:"h-4 w-4"}):o(la,{className:"h-4 w-4"})}),t==="local"&&o("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"&&o("span",{className:"absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm",children:o("svg",{viewBox:"0 0 780 250",className:"w-[11px] h-[11px]",children:o("path",{fill:"#fff",d:"M240 250h100V50h100v200h340V0H0v250z"})})}),t==="upload"&&o("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:o(Xa,{className:"h-2.5 w-2.5 text-white"})})]})}function hz({addonId:e}){const t=ke(),{data:n="inherit"}=Nb({addonId:e},{staleTime:3e4}),r=kb({onSuccess:()=>{t.invalidateQueries({queryKey:[["addons","getAddonAutoUpdate"]]})}});return o("div",{className:"flex rounded-lg border border-border overflow-hidden text-[10px] font-medium",children:["inherit","off","latest","beta"].map(s=>o("button",{type:"button",onClick:a=>{a.stopPropagation(),r.mutate({addonId:e,channel:s})},disabled:r.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 oc({addon:e,agents:t=[],clusterStatus:n,hideVersion:r,availableUpdate:s,onUpdate:a,isUpdating:i,bundle:l}){const[c,d]=_(!1),[u,p]=_(!1),[h,m]=_(!1),[g,b]=_(!1),[x,y]=_(!1),[w,v]=_("logs"),N=ke(),k=nt(),{manifest:C}=e,E=e.installedOn??[],I=!l&&!C.protected&&C.removable!==!1,A=!!l,z=l?.displayName??C.name,P=l?.packageName??C.packageName,B=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 D=db({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]})}}),T=Ko({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]})}}),L=rd({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]}),N.invalidateQueries({queryKey:[["integrations"]]})}}),O=vb({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["alerts"]]})}}),F=e.health,j=F?.phase==="failed"&&!F.inGracePeriod,V=j&&F?.nextRetryAt&&!F.retrying;return f("div",{className:`rounded-lg border bg-surface overflow-hidden ${j?"border-red-500/50":"border-border"}`,children:[j&&F&&f("div",{className:"bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5",children:[o(Z6,{className:"h-4 w-4 text-danger shrink-0 mt-0.5"}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"text-xs font-semibold text-danger",children:["Failed to load (attempt #",F.retryCount,")"]}),o("div",{className:"text-[11px] text-foreground mt-0.5 break-words font-mono",children:F.lastError?.message??"Unknown error"}),V&&F.nextRetryAt&&f("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["Auto-retry at ",new Date(F.nextRetryAt).toLocaleTimeString()]})]}),f("button",{type:"button",disabled:O.isPending||F.retrying,onClick:$=>{$.stopPropagation(),O.mutate({packageName:P})},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:[o(ct,{className:`h-3 w-3 ${O.isPending||F.retrying?"animate-spin":""}`}),"Retry now"]})]}),f("div",{className:"flex items-start gap-3 px-4 py-3",children:[o(fz,{isBundle:A||!!C.components&&C.components.length>1,installSource:R,addonId:A?l.addons[0]?.manifest.id:C.id,iconPath:A?l.bundle?.icon??l.addons[0]?.manifest.icon:C.icon,color:A?l.addons[0]?.manifest.color:C.color}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-sm font-semibold text-foreground truncate",children:z}),f("span",{className:"text-[10px] text-foreground-subtle font-mono shrink-0",children:["(",P,")"]}),A&&f("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:[o(X0,{className:"h-3 w-3"}),l.addons.length]})]}),M&&o("p",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-1",children:M}),!A&&e.process&&f("div",{className:"flex items-center gap-1.5 mt-1",children:[o("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&&f("span",{className:"text-[9px] font-mono text-foreground-subtle",children:["PID ",e.process.pid]}),o("span",{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state==="running"?"bg-emerald-500/15 text-emerald-400":e.process.state==="crashed"?"bg-red-500/15 text-red-400":"bg-gray-500/15 text-gray-400"}`,children:e.process.state})]})]}),!r&&f("div",{className:"relative inline-flex items-center gap-1.5 shrink-0 pt-0.5",children:[i?f("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:[o(Se,{className:"h-3 w-3 animate-spin"}),"Updating to ",s,"…"]}):s&&a?f("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:[o(Xt,{className:"h-3 w-3"}),s]}):null,f("button",{type:"button",onClick:$=>{$.stopPropagation(),m(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 ${B} — newer ${s} available`:"View all versions",children:[B,o(lt,{className:"h-3 w-3 opacity-50"})]}),h&&o(jv,{packageName:P,currentVersion:B,...R?{installSource:R}:{},onInstall:$=>{m(!1),L.mutate({packageName:P,version:$})},onClose:()=>m(!1)})]})]}),!A&&f("div",{className:"flex items-center gap-1 px-4 py-1.5 border-t border-border/50 bg-surface-hover/20",children:[f("button",{type:"button",onClick:$=>{$.stopPropagation(),T.mutate({addonId:C.id})},disabled:T.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:[o(ct,{className:`h-3 w-3 ${T.isPending?"animate-spin":""}`}),"Restart"]}),f("button",{type:"button",onClick:$=>{$.stopPropagation(),b(q=>!q)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${g?"border-primary/30 bg-primary/10 text-primary":"border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10"}`,children:[o(at,{className:"h-3 w-3"}),"Logs"]}),!A&&f("button",{type:"button",onClick:$=>{$.stopPropagation(),y(!0)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${x?"border-primary/30 bg-primary/10 text-primary":"border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10"}`,children:[o(Jt,{className:"h-3 w-3"}),"Settings"]}),o("div",{className:"flex-1"}),I&&f("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"})&&D.mutate({packageName:C.packageName})},disabled:D.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:[o(Ze,{className:"h-3 w-3"}),D.isPending?"Removing...":"Uninstall"]})]}),n&&n.nodes.length>1&&!A&&f("div",{className:"border-t border-border px-4 py-2 bg-muted/10",children:[o("div",{className:"text-[10px] font-medium text-foreground-subtle mb-1.5",children:"Cluster Deployment"}),o("div",{className:"space-y-1",children:n.nodes.map($=>f("div",{className:"flex items-center gap-2 text-[10px]",children:[o("div",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${$.status==="offline"?"bg-muted-foreground/30":$.synced?"bg-success":"bg-amber-500"}`}),o("span",{className:"font-medium text-foreground min-w-[60px]",children:$.name}),o("span",{className:"font-mono text-foreground-subtle",children:$.version}),!$.synced&&$.status!=="offline"&&o("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"&&o("span",{className:"text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground",children:"offline"}),$.synced&&$.status!=="offline"&&o("span",{className:"text-[9px] text-success",children:"synced"})]},$.nodeId))})]}),g&&!A&&f("div",{className:"border-t border-border",children:[f("div",{className:"flex items-center px-4 py-1 bg-surface-hover/20 border-b border-border/50",children:[f("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:[o("button",{type:"button",onClick:()=>v("logs"),className:`px-2 py-0.5 transition-colors ${w==="logs"?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover"}`,children:"Logs"}),o("button",{type:"button",onClick:()=>v("events"),className:`px-2 py-0.5 border-l border-border transition-colors ${w==="events"?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover"}`,children:"Events"})]}),o("div",{className:"flex-1"}),o("button",{type:"button",onClick:$=>{$.stopPropagation(),b(!1)},className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-3.5 w-3.5"})})]}),w==="logs"&&o(tn,{addonId:C.id,maxHeight:"max-h-64",showFilters:!1}),w==="events"&&o(br,{addonId:C.id,category:"addon.*",maxHeight:"max-h-64"})]}),A&&f(me,{children:[o("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?o(jR,{className:"h-3.5 w-3.5 text-foreground-subtle"}):o(lt,{className:"h-3.5 w-3.5 text-foreground-subtle"})}),c&&o("div",{className:"border-t border-border px-3 py-2 space-y-2",children:l.addons.map($=>o(oc,{addon:$,agents:t,hideVersion:!0},$.manifest.id))})]}),x&&!A&&o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:()=>y(!1),children:f("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:[f("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border flex-shrink-0",children:[f("div",{className:"flex items-center gap-2",children:[o(Jt,{className:"h-4 w-4 text-primary"}),f("h2",{className:"text-sm font-semibold text-foreground",children:[z," Settings"]})]}),o("button",{onClick:()=>y(!1),className:"text-foreground-subtle hover:text-foreground transition-colors p-1 rounded",children:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[o(to,{nodeId:"hub",addonIds:[C.id],level:"global"}),pz(C)&&f("div",{children:[o("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Device export"}),o(Md,{addonId:C.id})]}),R==="npm"&&f("div",{children:[o("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Auto-Update"}),o(hz,{addonId:C.id})]}),C.components&&C.components.length>0&&f("div",{children:[f("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Components (",C.components.length,")"]}),o("div",{className:"flex flex-wrap gap-1",children:C.components.map($=>o("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&&f("div",{children:[o("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Installed on"}),f("div",{className:"flex items-center gap-1.5 flex-wrap",children:[E.length===0&&o("span",{className:"text-[10px] text-foreground-subtle",children:"Hub (local)"}),E.map($=>o("span",{className:"rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle",children:$},$)),f("div",{className:"relative",children:[f("button",{type:"button",onClick:$=>{$.stopPropagation(),p(q=>!q)},className:"inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:border-primary transition-colors",title:"Install on more agents",children:[o(Et,{className:"h-3 w-3"}),"Add agent"]}),u&&f("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&&!E.includes($.name)).map($=>o("button",{type:"button",onClick:q=>{q.stopPropagation(),p(!1)},className:"w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors",children:$.name},$.id)),t.filter($=>!$.isHub&&!E.includes($.name)).length===0&&o("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle",children:"No available agents"})]})]})]})]})]}),o("div",{className:"flex items-center justify-end px-5 py-3 border-t border-border flex-shrink-0",children:o("button",{type:"button",onClick:()=>y(!1),className:"rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:"Close"})})]})})]})}const mz=".tgz,.tar.gz,.zip";function gz({onUploadSuccess:e}){const[t,n]=_(!1),r=te(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 f(me,{children:[o("input",{ref:r,type:"file",accept:mz,onChange:a,className:"hidden"}),f("button",{type:"button",onClick:()=>r.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?o(Se,{className:"w-3.5 h-3.5 animate-spin"}):o(Xa,{className:"w-3.5 h-3.5"}),t?"Uploading...":"Upload"]})]})}function bz(){const{data:e,isLoading:t,isError:n}=gb(void 0,{staleTime:6e4}),[r,s]=_(null),[a,i]=_(null),l=xb({onError:d=>{i(d instanceof Error?d.message:String(d))},onSuccess:()=>{s(null)}});if(t)return o(sl,{children:o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading system packages…"})});if(n)return o(sl,{children:o("div",{className:"text-xs text-danger",children:"Failed to load system packages"})});const c=e??[];return c.length===0?o(me,{}):f(me,{children:[o(sl,{collapsible:!0,defaultCollapsed:!0,children:o("div",{className:"space-y-1.5",children:c.map(d=>o(xz,{row:d,onUpdate:u=>s({packageName:d.packageName,fromVersion:d.currentVersion,toVersion:u})},d.packageName))})}),r!==null&&o(yz,{pending:r,onCancel:()=>{s(null),i(null)},onConfirm:()=>{i(null),l.mutate({packageName:r.packageName,version:r.toVersion})},isPending:l.isPending,error:a})]})}function sl({children:e,collapsible:t=!1,defaultCollapsed:n=!1}){const[r,s]=_(n),a=!t||!r,i=f("div",{className:"flex items-center gap-2",children:[t&&(r?o(wt,{className:"w-3.5 h-3.5 text-amber-700 shrink-0"}):o(lt,{className:"w-3.5 h-3.5 text-amber-700 shrink-0"})),o(it,{className:"w-3.5 h-3.5 text-amber-700 shrink-0"}),o("span",{className:"text-[11px] font-medium text-amber-800",children:"System packages"}),o("span",{className:"text-[10px] text-foreground-subtle",children:"Updating these will restart the hub (~10s)."})]});return f("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/5 p-3 space-y-2",children:[t?o("button",{type:"button",onClick:()=>s(l=>!l),"aria-expanded":!r,className:"flex w-full items-center text-left",children:i}):i,a&&e]})}function xz({row:e,onUpdate:t}){const[n,r]=_(!1),s=e.hasUpdate&&e.latestVersion!==null;return f("div",{className:"flex items-center justify-between gap-3 px-2 py-1.5 rounded bg-surface/50 border border-border",children:[f("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o("span",{className:"font-mono text-[11px] text-foreground truncate",children:e.packageName}),e.description!==void 0&&o("span",{className:"text-[10px] text-foreground-subtle truncate",title:e.description,children:e.description})]}),f("div",{className:"flex items-center gap-2 shrink-0",children:[s&&f("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:[o(Xt,{className:"w-3 h-3"}),"v",e.latestVersion]}),f("button",{type:"button",onClick:()=>r(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,o(lt,{className:"w-3 h-3 opacity-50"})]}),n&&o(jv,{packageName:e.packageName,currentVersion:e.currentVersion,onInstall:a=>{r(!1),t(a)},onClose:()=>r(!1)})]})]})}function yz({pending:e,onCancel:t,onConfirm:n,isPending:r,error:s}){return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:f("div",{className:"bg-surface border border-border rounded-md shadow-xl p-5 max-w-md w-full mx-4 space-y-3",children:[f("div",{className:"flex items-center gap-2",children:[o(it,{className:"w-4 h-4 text-amber-700"}),o("h3",{className:"text-sm font-medium text-foreground",children:"Update system package?"})]}),f("div",{className:"space-y-2 text-[11px] text-foreground-subtle",children:[f("div",{children:[o("span",{className:"font-mono text-foreground",children:e.packageName}),o("span",{className:"mx-1",children:"·"}),f("span",{className:"font-mono",children:["v",e.fromVersion]}),o("span",{className:"mx-1",children:"→"}),f("span",{className:"font-mono text-amber-700",children:["v",e.toVersion]})]}),o("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&&o("div",{className:"rounded border border-danger/40 bg-danger/10 p-2 text-danger",children:s})]}),f("div",{className:"flex justify-end gap-2 pt-1",children:[o("button",{type:"button",onClick:t,disabled:r,className:"px-3 py-1.5 text-[11px] rounded bg-surface hover:bg-surface-hover border border-border disabled:opacity-50",children:"Cancel"}),f("button",{type:"button",onClick:n,disabled:r,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:[r?o(Se,{className:"w-3 h-3 animate-spin"}):o(Xt,{className:"w-3 h-3"}),"Update & restart"]})]})]})})}function vz(e,t){const n=e??"hub-only";return n==="any-node"?!0:n==="hub-only"?t:!t}function wz(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??[]},r=t.process,s=r?{pid:r.pid,mode:r.mode==="forked"?"forked":"in-process",state:r.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 Nz(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 r=[];for(const s of t.values())s.bundle!==void 0||s.addons.length>=2?r.push({bundle:s,representative:s.addons[0]}):r.push(s.addons[0]);return r.push(...n),r}function sn(e){return"bundle"in e}function kz({addons:e,clusterStatus:t,selectedNode:n,onRefresh:r,isRefreshing:s}){const a=ke(),[i,l]=_(""),c=d2(i),[d,u]=_(!1),p=te(null);Y(()=>{if(!d)return;const $=q=>{p.current&&!p.current.contains(q.target)&&u(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[d]);const{data:h}=od({nodeId:n.id},{staleTime:5*6e4}),m=H(()=>{const $=new Map;for(const q of h??[])$.set(q.name,q.latestVersion);return $},[h]),[g,b]=_(null),[x,y]=_(null),w=Rl({onMutate:$=>{b($.name),y(null)},onSuccess:($,q)=>{b(null);const G=$;if(G&&G.success===!1){y({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)=>{b(null),y({name:q.name,message:$ instanceof Error?$.message:String($)})}}),{data:v}=wb(void 0,{staleTime:3e4}),N=Sb({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons","getAutoUpdateSettings"]]})}}),{data:k,isFetching:C}=pb({query:c||void 0},{enabled:d,staleTime:6e4}),E=Rl(),I=async()=>{const $=h??[];for(const q of $)await E.mutateAsync({name:q.name,version:q.latestVersion,nodeId:n.id});a.invalidateQueries({queryKey:[["addons"]]})},A=rd({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),a.invalidateQueries({queryKey:[["addonPages"]]}),a.invalidateQueries({queryKey:[["capabilities"]]}),a.invalidateQueries({queryKey:[["integrations"]]})}}),[z,P]=_("type"),[B,R]=_(()=>typeof window>"u"?"grouped":window.localStorage.getItem("camstack.addons.viewMode")==="flat"?"flat":"grouped"),M=$=>{R($),typeof window<"u"&&window.localStorage.setItem("camstack.addons.viewMode",$)},[D,T]=Ga(),L=D.get("capability"),O=H(()=>{let $=n.isHub?e:e.filter(q=>vz(q.placement,n.isHub));return L&&($=$.filter(q=>(q.manifest.capabilities??[]).some(Z=>(typeof Z=="string"?Z:Z.name)===L))),$},[e,n.isHub,L]),F=()=>{const $=new URLSearchParams(D);$.delete("capability"),T($,{replace:!0})},j=B==="flat"?O:Nz(O),V=H(()=>{const $=[...j];switch(z){case"type":$.sort((q,G)=>{const Z=sn(q)?0:1,oe=sn(G)?0:1;if(Z!==oe)return Z-oe;const ne=sn(q)?q.bundle.displayName:q.manifest.name,X=sn(G)?G.bundle.displayName:G.manifest.name;return ne.localeCompare(X)});break;case"name":$.sort((q,G)=>{const Z=sn(q)?q.bundle.displayName:q.manifest.name,oe=sn(G)?G.bundle.displayName:G.manifest.name;return Z.localeCompare(oe)});break;case"source":$.sort((q,G)=>{const Z=sn(q)?q.bundle.installSource??"":q.installSource??"",oe=sn(G)?G.bundle.installSource??"":G.installSource??"";return Z.localeCompare(oe)});break}return $},[j,z]);return f("div",{className:"space-y-4",children:[x&&o("div",{className:"rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px]",children:f("div",{className:"flex items-start justify-between gap-3",children:[f("div",{className:"space-y-0.5",children:[f("div",{className:"font-medium text-danger",children:["Failed to update ",x.name]}),o("div",{className:"text-foreground-subtle font-mono",children:x.message})]}),o("button",{type:"button",onClick:()=>y(null),className:"text-foreground-subtle hover:text-foreground text-[10px]",children:"dismiss"})]})}),f("div",{className:"flex items-center gap-2 flex-wrap",children:[f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"text-[10px] text-foreground-subtle",children:"Sort:"}),f("select",{value:z,onChange:$=>P($.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:[o("option",{value:"type",children:"Bundles first"}),o("option",{value:"name",children:"Name"}),o("option",{value:"source",children:"Install source"})]})]}),f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"text-[10px] text-foreground-subtle",children:"View:"}),o("div",{className:"flex rounded-md border border-border overflow-hidden text-[10px] font-medium",children:["grouped","flat"].map($=>o("button",{type:"button",onClick:()=>M($),className:`px-2.5 py-1.5 transition-colors capitalize ${B===$?"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&&f("div",{className:"flex items-center gap-1.5",children:[o(ct,{className:"h-3 w-3 text-foreground-subtle"}),o("span",{className:"text-[10px] text-foreground-subtle",children:"Auto-Update:"}),o("div",{className:"flex rounded-md border border-border overflow-hidden text-[10px] font-medium",children:["off","latest","beta"].map($=>o("button",{type:"button",onClick:()=>N.mutate({channel:$}),disabled:N.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${v?.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:$},$))})]}),(h?.length??0)>0&&f("button",{type:"button",onClick:()=>void I(),disabled:E.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:[o(Xt,{className:`w-3 h-3 ${E.isPending?"animate-bounce":""}`}),"Update All (",h.length,")"]}),f("button",{type:"button",onClick:r,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:[o(ct,{className:`w-3 h-3 ${s?"animate-spin":""}`}),"Refresh"]})]}),f("div",{className:"flex items-center gap-3",children:[f("div",{className:"relative flex-1 min-w-[200px]",ref:p,children:[o(nv,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle"}),o("input",{type:"text",value:i,onChange:$=>{l($.target.value),u(!0)},onFocus:()=>u(!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&&o(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&&f("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&&f("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&&o("div",{className:"max-h-72 overflow-auto divide-y divide-border",children:k.map($=>f("div",{className:"flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors",children:[o("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()}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-[11px] font-semibold truncate",children:$.name}),f("span",{className:"text-[10px] text-foreground-subtle",children:["v",$.version]})]}),$.description&&o("div",{className:"text-[10px] text-foreground-subtle truncate",children:$.description})]}),$.installed?f("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:[o(_t,{className:"h-3 w-3"}),$.installedVersion??"Installed"]}):f("button",{type:"button",onClick:()=>A.mutate({packageName:$.name}),disabled:A.isPending,className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0",children:[A.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(Xt,{className:"h-3 w-3"}),"Install"]})]},$.name))})]})]}),o(gz,{onUploadSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),r()}})]}),L&&f("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/10 border border-primary/30 text-sm",children:[o("span",{className:"text-foreground-subtle",children:"Filtering by capability:"}),o("span",{className:"font-mono text-primary font-semibold",children:L}),o("button",{type:"button",onClick:F,className:"ml-auto text-xs text-foreground-subtle hover:text-foreground underline",children:"Clear"})]}),O.length===0&&o("div",{className:"text-xs text-foreground-subtle",children:e.length===0?"No addons installed":L?`No installed addons declare the "${L}" capability. Browse the npm catalog above to find a compatible addon.`:`No addons compatible with ${n.name} (placement filter active)`}),o("div",{className:"space-y-2",children:V.map($=>{if(sn($)){const Z=$.bundle.packageName,oe=m.get(Z);return o(oc,{addon:$.representative,clusterStatus:t?.[$.representative.manifest.id],bundle:$.bundle,availableUpdate:oe,isUpdating:g===Z,onUpdate:oe?()=>w.mutate({name:Z,version:oe,nodeId:n.id}):void 0},Z)}const q=$.manifest.packageName,G=m.get(q);return o(oc,{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 Sz(){const e=ke(),{data:t,isLoading:n,isError:r}=wn(),{data:s}=Ox(void 0,{staleTime:15e3}),{data:a}=zn(void 0,{staleTime:3e4,refetchInterval:1e4}),i=H(()=>{const x=new Map;x.set("hub",{id:"hub",name:"Hub",isHub:!0});for(const y of a??[]){const w=String(y.id??"");w&&x.set(w,{id:w,name:String(y.name??w),isHub:!!y.isHub})}return[...x.values()]},[a]),[l,c]=_("hub"),d=i.find(x=>x.id===l)??i[0],u=fb(),p=ub(),h=u.isPending||p.isPending,m=async()=>{await u.mutateAsync({nodeId:l}),await p.mutateAsync(),e.invalidateQueries({queryKey:[["addons"]]})},g=te(u);g.current=u,Y(()=>{g.current.mutate({nodeId:"hub"})},[]);const b=(t??[]).map(wz).filter(x=>x!==null);return f(tt,{children:[f("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[o(Bg,{selectedNodeId:l,onSelect:c}),f("div",{className:"flex items-center gap-3 flex-wrap",children:[!n&&!r&&f("span",{className:"text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium",children:[b.length," installed"]}),f("button",{type:"button",onClick:()=>void m(),disabled:h,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:[o(ct,{className:`w-3 h-3 ${h?"animate-spin":""}`}),"Check for updates"]})]})]}),!d.isHub&&f("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"," ",o("span",{className:"font-medium text-foreground",children:d.name})," ","— agents only run ",o("code",{className:"font-mono",children:"agent-only"})," and"," ",o("code",{className:"font-mono",children:"any-node"})," addons. Install / uninstall is hub-driven; agents auto-sync from the hub."]}),n&&o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading…"}),r&&o("div",{className:"text-xs text-danger",children:"Failed to load addons"}),d.isHub&&o(bz,{}),!n&&!r&&o(kz,{addons:b,clusterStatus:s,selectedNode:d,onRefresh:()=>void m(),isRefreshing:h})]})}function Cz({value:e,size:t=192}){const[n,r]=_(null),[s,a]=_(null);if(Y(()=>{let d=!1;return E2(()=>import("./browser-BXdiCFWD.js").then(u=>u.b),[]).then(async u=>{if(d)return;const p=u.create;if(typeof p!="function"){a("qrcode.create() unavailable in installed version");return}try{const h=p(e,{errorCorrectionLevel:"M"});d||r(h)}catch(h){d||a(h instanceof Error?h.message:"QR generation failed")}}).catch(()=>{d||a("qrcode library not installed")}),()=>{d=!0}},[e]),s)return o("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 o("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 u=0;u<i;u++)n.modules.data[d*i+u]&&c.push(o("rect",{x:u*l,y:d*l,width:l,height:l,fill:"currentColor"},`${u}-${d}`));return f("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:"text-black",children:[o("rect",{x:0,y:0,width:t,height:t,fill:"white"}),c]})}const Mz={view:{icon:es,cls:"bg-foreground-subtle/15 text-foreground-subtle"},create:{icon:eo,cls:"bg-primary/15 text-primary"},delete:{icon:Ze,cls:"bg-danger/15 text-danger"}};function Ez(){const{user:e,logout:t}=nn();if(!e)return o(tt,{children:o("div",{className:"text-xs text-foreground-subtle",children:"Not signed in."})});const n=e.isAdmin,r=e.scopes??[];return f(tt,{children:[f("div",{className:"rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3",children:[o("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()}),f("div",{className:"flex-1 min-w-0",children:[o("div",{className:"text-sm font-semibold text-foreground truncate",children:e.username}),f("div",{className:"text-[11px] text-foreground-subtle",children:[n?"Administrator":"User"," · session id ",f("span",{className:"font-mono",children:[e.id.slice(0,8),"…"]})]})]})]}),n&&f("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:[o(rr,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),f("div",{children:[o("div",{className:"font-semibold text-foreground",children:"Unrestricted access"}),o("p",{className:"text-foreground-subtle mt-0.5",children:"Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below."})]})]}),o(Iz,{}),o(Az,{username:e.username}),r.length>0&&f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"px-4 py-2 border-b border-border",children:[o("div",{className:"text-xs font-semibold text-foreground",children:"Granted scopes"}),o("div",{className:"text-[10px] text-foreground-subtle",children:"Baked into your session token at login; sign out + back in to refresh after changes."})]}),f("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:[o("div",{children:"Type"}),o("div",{children:"Target"}),o("div",{children:"Access"})]}),o("ul",{className:"divide-y divide-border",children:r.map((s,a)=>f("li",{className:"grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs",children:[o("span",{className:"font-mono text-foreground-subtle",children:s.type}),o("span",{className:"font-mono text-foreground",children:s.type==="device"?s.targets.join(", "):s.target}),o("div",{className:"flex items-center gap-1",children:["view","create","delete"].map(i=>{const l=s.access.includes(i),{icon:c,cls:d}=Mz[i];return f("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:[o(c,{className:"h-3 w-3"}),i]},i)})})]},a))})]}),o("div",{className:"flex justify-end",children:f("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:[o(Zd,{className:"h-3 w-3"}),"Sign out"]})})]})}function Iz(){const e=Te(),[t,n]=_(""),[r,s]=_(""),[a,i]=_(""),[l,c]=_(null),d=Kn({mutationFn:m=>e.changeOwnPassword(m),onSuccess:()=>{c({kind:"success",msg:"Password updated."}),n(""),s(""),i("")},onError:m=>{c({kind:"error",msg:m instanceof Error?m.message:"Update failed"})}}),u=r.length>0&&a.length>0&&r!==a,p=r.length>0&&r.length<8,h=t.length>=1&&r.length>=8&&r===a;return f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"px-4 py-2.5 border-b border-border flex items-center gap-2",children:[o(W0,{className:"h-3.5 w-3.5 text-foreground-subtle"}),o("div",{className:"text-xs font-semibold text-foreground",children:"Change password"})]}),f("div",{className:"p-4 space-y-3",children:[o(al,{label:"Current password",value:t,onChange:n,autoComplete:"current-password"}),o(al,{label:"New password",value:r,onChange:s,autoComplete:"new-password",hint:"At least 8 characters."}),o(al,{label:"Confirm new password",value:a,onChange:i,autoComplete:"new-password"}),(u||p)&&o("div",{className:"text-[11px] text-danger",children:u?"Passwords do not match.":"New password must be at least 8 characters."}),l&&f("div",{className:`text-[11px] flex items-center gap-1 ${l.kind==="success"?"text-emerald-500":"text-danger"}`,children:[l.kind==="success"?o(xo,{className:"h-3 w-3"}):o(nr,{className:"h-3 w-3"}),l.msg]}),o("div",{className:"flex justify-end",children:f("button",{onClick:()=>{c(null),d.mutate({currentPassword:t,newPassword:r})},disabled:!h||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?o(Se,{className:"h-3 w-3 animate-spin"}):o(Yd,{className:"h-3 w-3"}),"Update password"]})})]})]})}function al({label:e,value:t,onChange:n,autoComplete:r,hint:s}){return f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:e}),o("input",{type:"password",value:t,onChange:a=>n(a.target.value),autoComplete:r,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&&o("div",{className:"text-[10px] text-foreground-subtle",children:s})]})}function Az({username:e}){const t=Te(),n=Ln({queryKey:["auth","getOwnTotpStatus"],queryFn:()=>t.getOwnTotpStatus()}),r=n.data,[s,a]=_(null),[i,l]=_(""),[c,d]=_(null),[u,p]=_(!1),h=Kn({mutationFn:()=>t.setupOwnTotp(),onSuccess:y=>{a({secret:y.secret,otpauthUrl:y.otpauthUrl}),l(""),d(null)},onError:y=>d(y instanceof Error?y.message:"Setup failed")}),m=Kn({mutationFn:y=>t.confirmOwnTotp(y),onSuccess:()=>{a(null),l(""),d(null),n.refetch()},onError:y=>d(y instanceof Error?y.message:"Confirmation failed — code did not match")}),g=Kn({mutationFn:()=>t.disableOwnTotp(),onSuccess:()=>{d(null),n.refetch()},onError:y=>d(y instanceof Error?y.message:"Disable failed")});Y(()=>{if(!u)return;const y=setTimeout(()=>p(!1),1500);return()=>clearTimeout(y)},[u]);const b=H(()=>n.isLoading?"loading":s?"setup_in_progress":r?.enabled?"enrolled":"not_enrolled",[n.isLoading,r?.enabled,s]),x=()=>{s&&navigator.clipboard.writeText(s.secret).then(()=>p(!0))};return f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"px-4 py-2.5 border-b border-border flex items-center gap-2",children:[o(An,{className:"h-3.5 w-3.5 text-foreground-subtle"}),o("div",{className:"text-xs font-semibold text-foreground",children:"Two-factor authentication"})]}),f("div",{className:"p-4 space-y-3",children:[b==="loading"&&f("div",{className:"flex items-center gap-2 text-xs text-foreground-subtle",children:[o(Se,{className:"h-3.5 w-3.5 animate-spin"}),"Checking status…"]}),b==="not_enrolled"&&f(me,{children:[o("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."}),o("div",{className:"flex justify-end",children:f("button",{onClick:()=>{d(null),h.mutate()},disabled:h.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:[h.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(An,{className:"h-3 w-3"}),"Enable 2FA"]})})]}),b==="setup_in_progress"&&s&&f(me,{children:[f("div",{className:"text-[11px] text-foreground-subtle",children:["Scan the QR code (or enter the secret manually) into your authenticator app for ",o("span",{className:"font-mono",children:e}),", then enter the 6-digit code below to confirm."]}),f("div",{className:"flex flex-col items-center gap-3",children:[o("div",{className:"rounded-lg border border-border bg-white p-3",children:o(Cz,{value:s.otpauthUrl,size:180})}),f("div",{className:"w-full",children:[o("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle mb-1",children:"Secret (manual entry)"}),f("div",{className:"flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5",children:[o("code",{className:"text-[11px] font-mono text-foreground break-all flex-1",children:s.secret}),f("button",{onClick:x,className:"inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground",children:[u?o(xo,{className:"h-3 w-3 text-emerald-500"}):o(aa,{className:"h-3 w-3"}),u?"Copied":"Copy"]})]})]})]}),f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"6-digit code"}),o("input",{type:"text",inputMode:"numeric",autoComplete:"one-time-code",placeholder:"123456",value:i,onChange:y=>l(y.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&&f("div",{className:"text-[11px] text-danger flex items-center gap-1",children:[o(nr,{className:"h-3 w-3"}),c]}),f("div",{className:"flex justify-end gap-2",children:[o("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"}),f("button",{onClick:()=>{d(null),m.mutate({code:i})},disabled:m.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:[m.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(xo,{className:"h-3 w-3"}),"Confirm"]})]})]}),b==="enrolled"&&r&&f(me,{children:[f("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:[o(xo,{className:"h-4 w-4 mt-0.5 text-emerald-500 shrink-0"}),f("div",{className:"text-xs text-foreground space-y-0.5",children:[o("div",{className:"font-medium",children:"2FA is active"}),f("div",{className:"text-foreground-subtle",children:["Enrolled on ",r.confirmedAt?new Date(r.confirmedAt).toLocaleString():"—"]})]})]}),c&&f("div",{className:"text-[11px] text-danger flex items-center gap-1",children:[o(nr,{className:"h-3 w-3"}),c]}),o("div",{className:"flex justify-end",children:f("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?o(Se,{className:"h-3 w-3 animate-spin"}):o(An,{className:"h-3 w-3"}),"Disable 2FA"]})})]})]})]})}function Pz(){return o(tt,{children:o("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:o(tn,{limit:500,maxHeight:"max-h-[calc(100vh-250px)]",showScope:!0,showFilters:!0})})})}function ri({tabs:e,defaultTab:t}){const[n,r]=Ga(),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 u=new URLSearchParams(n);u.set("tab",d),r(u,{replace:!0})};return f("div",{className:"space-y-3",children:[o("div",{className:"flex border-b border-border",children:e.map(d=>{const u=d.icon,p=d.id===i;return f("button",{onClick:()=>c(d.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors ${p?"border-primary text-primary":"border-transparent text-foreground-subtle hover:text-foreground"}`,children:[u&&o(u,{className:"h-3.5 w-3.5"}),d.label]},d.id)})}),o("div",{children:l?.content})]})}function _z({userId:e,username:t,onClose:n}){const r=ke(),s=nt(),a=Fy({userId:e}),i=a.data,l=()=>r.invalidateQueries({queryKey:[["userManagement","getTotpStatus"]]}),c=zy({onSuccess:()=>{l(),n()}}),d=a.isLoading?"loading":i?.enabled?"enrolled":"not_enrolled",u=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 o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm p-4",children:f("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl overflow-hidden",children:[f("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[f("div",{className:"flex items-center gap-2",children:[o(An,{className:"h-4 w-4 text-primary"}),f("div",{children:[o("div",{className:"text-sm font-medium text-foreground",children:"Two-factor authentication"}),f("div",{className:"text-[11px] text-foreground-subtle",children:["User: ",o("span",{className:"font-mono",children:t})]})]})]}),o("button",{onClick:n,className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle",children:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"p-4 space-y-4",children:[d==="loading"&&f("div",{className:"flex items-center gap-2 text-xs text-foreground-subtle",children:[o(Se,{className:"h-3.5 w-3.5 animate-spin"}),"Checking status…"]}),d==="not_enrolled"&&f("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:[o(rr,{className:"h-4 w-4 mt-0.5 shrink-0"}),f("div",{children:[o("div",{className:"font-medium text-foreground",children:"2FA not enrolled"}),o("p",{className:"mt-0.5",children:"Only the user themselves can enable 2FA, from their own profile page."})]})]}),d==="enrolled"&&i&&f(me,{children:[f("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:[o(xo,{className:"h-4 w-4 mt-0.5 text-emerald-500 shrink-0"}),f("div",{className:"text-xs text-foreground space-y-0.5",children:[o("div",{className:"font-medium",children:"2FA is active"}),f("div",{className:"text-foreground-subtle",children:["Enrolled on ",i.confirmedAt?new Date(i.confirmedAt).toLocaleString():"—"]})]})]}),o("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."}),f("div",{className:"flex justify-end gap-2",children:[o(Be,{onClick:n,variant:"secondary",children:"Close"}),f("button",{onClick:u,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?o(Se,{className:"h-3 w-3 animate-spin"}):o(Fe,{className:"h-3 w-3"}),"Remove 2FA"]})]})]})]})]})})}function $z(){const e=ke(),{user:t}=nn(),[n,r]=_(!1),[s,a]=_(""),[i,l]=_(""),[c,d]=_(!1),[u,p]=_(null),{data:h,isLoading:m,isError:g}=vd(),b=nt(),x=()=>e.invalidateQueries({queryKey:[["userManagement","listUsers"]]}),y=Py({onSuccess:()=>{x(),r(!1),a(""),l(""),d(!1),p(null)},onError:D=>{p(D instanceof Error?D.message:"Failed to create user")}}),w=$y({onSuccess:x}),v=_y({onSuccess:x}),N=wd({onSuccess:x}),k=Dy({onSuccess:()=>{x(),E(null)}}),[C,E]=_(null),[I,A]=_(null),z=h??[];async function P(D){await b({title:"Delete user",message:`Permanently delete user "${D.username}"? This cannot be undone — any active sessions will be revoked on next request.`,confirmLabel:"Delete",variant:"danger"})&&w.mutate({id:D.id})}async function B(D){const T=window.prompt(`New password for "${D.username}":`);if(!T)return;if(T.length<8){window.alert("Password must be at least 8 characters.");return}await b({title:"Reset password",message:`Reset the password for "${D.username}"? They will need to use the new password on their next login.`,confirmLabel:"Reset"})&&N.mutate({id:D.id,newPassword:T})}function R(D,T){T!==D.isAdmin&&v.mutate({id:D.id,isAdmin:T})}function M(D){return D?new Date(typeof D=="number"?D:String(D)).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):"—"}return f(tt,{children:[o("div",{className:"flex items-center justify-end",children:f("button",{onClick:()=>r(!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:[o(Et,{className:"h-3.5 w-3.5"}),"Create User"]})}),n&&f("div",{className:"rounded-lg border border-border bg-surface p-4 space-y-3",children:[f("div",{className:"flex items-center justify-between",children:[o("span",{className:"text-xs font-medium text-foreground",children:"New User"}),o("button",{onClick:()=>r(!1),className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"grid grid-cols-3 gap-3",children:[f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Username"}),o("input",{type:"text",value:s,onChange:D=>a(D.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"})]}),f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Password"}),o("input",{type:"password",value:i,onChange:D=>l(D.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"})]}),f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Admin"}),f("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:[o("input",{type:"checkbox",checked:c,onChange:D=>d(D.target.checked),className:"rounded border-border focus:ring-primary"}),o("span",{className:"text-foreground-subtle",children:"Unrestricted access"})]})]})]}),u&&o("p",{className:"text-[10px] text-danger",children:u}),f("div",{className:"flex justify-end gap-2",children:[o("button",{onClick:()=>r(!1),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),o("button",{onClick:()=>y.mutate({username:s,password:i,isAdmin:c}),disabled:y.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:y.isPending?"Creating...":"Create"})]})]}),m&&o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading..."}),g&&o("div",{className:"text-xs text-danger",children:"Failed to load"}),!m&&!g&&z.length===0&&o("div",{className:"text-xs text-foreground-subtle",children:"No data"}),(()=>{const D=L=>w.isPending&&w.variables?.id===L.id||v.isPending&&v.variables?.id===L.id||N.isPending&&N.variables?.id===L.id;return o(Da,{columns:[{key:"username",header:"Username",render:L=>L.username},{key:"isAdmin",header:"Admin",render:L=>f("label",{className:"inline-flex items-center gap-1.5 text-xs cursor-pointer",children:[o("input",{type:"checkbox",checked:L.isAdmin,onChange:O=>R(L,O.target.checked),disabled:D(L),className:"rounded border-border focus:ring-primary disabled:opacity-50"}),o("span",{className:L.isAdmin?"text-primary font-medium":"text-foreground-subtle",children:L.isAdmin?"Admin":"Regular"})]})},{key:"scopes",header:"Scopes",render:L=>{if(L.isAdmin)return o("span",{className:"text-[10px] text-foreground-subtle italic",children:"unscoped"});const O=L.scopes??[];return f("button",{onClick:()=>E(L),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:[o(mn,{className:"h-3 w-3"}),O.length===0?"no access":`${O.length} grant${O.length===1?"":"s"}`]})}},{key:"createdAt",header:"Created",render:L=>o("span",{className:"text-foreground-subtle",children:M(L.createdAt)})},{key:"actions",header:"Actions",align:"right",render:L=>{const O=D(L),F=L.id!==t?.id&&L.totpEnabled;return f("div",{className:"flex items-center justify-end gap-1",children:[F&&f("button",{onClick:()=>A(L),disabled:O,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:[o(An,{className:"h-3 w-3"}),"Remove 2FA"]}),f("button",{onClick:()=>B(L),disabled:O,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:[o(k6,{className:"h-3 w-3"}),"Reset password"]}),f("button",{onClick:()=>P(L),disabled:O,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:[O?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ze,{className:"h-3 w-3"}),"Delete"]})]})}}],rows:z,rowKey:L=>L.id,minWidthPx:560})})(),I&&o(_z,{userId:I.id,username:I.username,onClose:()=>A(null)}),C&&o(Dz,{user:C,onClose:()=>E(null),onSubmit:D=>k.mutate({userId:C.id,scopes:D}),submitting:k.isPending})]})}function Dz(e){const{user:t}=nn(),n=t?.isAdmin===!0;return o(Tz,{...e,callerScopes:n?null:t?.scopes??[]})}function Tz({user:e,onClose:t,onSubmit:n,submitting:r,callerScopes:s}){const a=H(()=>(e.scopes??[]).map(d=>({...d,access:[...d.access]})),[e.scopes]),[i,l]=_(a),c=Dd(i);return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:f("div",{className:"w-full max-w-2xl rounded-lg border border-border bg-surface shadow-xl",children:[f("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[f("div",{children:[f("div",{className:"text-sm font-semibold text-foreground",children:["Edit scopes — ",e.username]}),o("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."})]}),o("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"px-4 py-4",children:[o($d,{value:i,onChange:l,clampToParent:s,emptyHint:f(me,{children:["No scopes granted. ",o("span",{className:"font-medium text-foreground",children:e.username})," cannot call any protected endpoint until a scope is added."]})}),c&&o("p",{className:"mt-2 text-[10px] text-danger",children:c})]}),f("div",{className:"flex items-center justify-end gap-2 border-t border-border px-4 py-3",children:[o("button",{onClick:t,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),o("button",{onClick:()=>n(i),disabled:r||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:r?o(Se,{className:"h-3 w-3 animate-spin"}):"Save scopes"})]})]})})}const Lz="bg-primary/10 text-primary",Rz="bg-foreground-subtle/10 text-foreground-subtle";function ko(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}function Oz(e){return e?e==="*"?"*":e.join(", "):""}function Bz(){const e=ke(),t=nt(),{data:n,isLoading:r}=Ty(),{data:s}=vd(),a=H(()=>n??[],[n]),i=H(()=>s??[],[s]),l=()=>e.invalidateQueries({queryKey:[["userManagement","listApiKeys"]]}),c=()=>e.invalidateQueries({queryKey:[["userManagement","listScopedTokens"]]}),[d,u]=_(!1),[p,h]=_(null),m=Ly({onSuccess:l}),g=Ry({onSuccess:({token:w,record:v})=>{c(),u(!1),h({token:w,label:v.name})}}),b=Oy({onSuccess:c}),x=async(w,v)=>{await t({title:`Revoke "${v}"?`,message:"Any client using this token will lose access immediately. This cannot be undone.",confirmLabel:"Revoke",variant:"danger"})&&m.mutate({id:w})},y=async(w,v)=>{await t({title:`Revoke "${v}"?`,message:"The scoped token will be invalid on its next use.",confirmLabel:"Revoke",variant:"danger"})&&b.mutate({id:w})};return f(tt,{children:[f("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[o("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."}),f("button",{onClick:()=>u(!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:[o(mn,{className:"h-3.5 w-3.5"}),"New token"]})]}),f(Af,{title:"Scoped tokens",subtitle:"Grouped per user",children:[i.length===0&&o(Fz,{text:"No users yet — scoped tokens are issued on behalf of an existing user."}),i.map(w=>o(jz,{userId:w.id,username:w.username,onRevoke:(v,N)=>{y(v,N)},revokePending:b.isPending,revokeId:b.variables?.id},w.id))]}),a.length>0&&o(Af,{title:"Legacy API keys",subtitle:`${a.length} pre-existing — revoke only`,children:o(Vv,{headers:["Label","Admin","Prefix","Allowed providers","Created","Last used",""],rows:a.map(w=>{const v=!!w.isAdmin,N=m.isPending&&m.variables?.id===w.id;return f("tr",{className:"hover:bg-primary/5",children:[o("td",{className:"px-3 py-2 text-foreground border-b border-border font-medium",children:w.label}),o("td",{className:"px-3 py-2 text-foreground border-b border-border",children:o("span",{className:`inline-block rounded px-2 py-0.5 text-[10px] uppercase tracking-wide ${v?Lz:Rz}`,children:v?"admin":"regular"})}),f("td",{className:"px-3 py-2 text-foreground border-b border-border font-mono text-[11px]",children:[w.tokenPrefix,"…"]}),o("td",{className:"px-3 py-2 text-foreground border-b border-border text-foreground-subtle",children:Oz(w.allowedProviders)||"all"}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:ko(w.createdAt)}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:ko(w.lastUsedAt)}),o("td",{className:"px-3 py-2 border-b border-border text-right",children:f("button",{onClick:()=>{x(w.id,w.label)},disabled:N,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50",title:"Revoke",children:[N?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ze,{className:"h-3 w-3"}),"Revoke"]})})]},w.id)})})}),r&&o(zz,{}),d&&o(Vz,{users:i.map(w=>({id:w.id,username:w.username})),onClose:()=>u(!1),onSubmit:w=>g.mutate({userId:w.userId,name:w.name,scopes:w.scopes,...w.expiresAt!==void 0?{expiresAt:w.expiresAt}:{}}),submitting:g.isPending}),p&&o(Hz,{token:p.token,label:p.label,onClose:()=>h(null)})]})}function Af({title:e,subtitle:t,children:n}){return f("div",{className:"space-y-2",children:[f("div",{className:"flex items-baseline justify-between",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:e}),t&&o("span",{className:"text-[10px] text-foreground-subtle",children:t})]}),n]})}function zz(){return o("div",{className:"space-y-2",children:[1,2].map(e=>o("div",{className:"h-10 rounded border border-border bg-surface animate-pulse"},e))})}function Fz({text:e}){return o("div",{className:"rounded border border-dashed border-border bg-surface px-3 py-4 text-xs text-foreground-subtle text-center",children:e})}function Vv({headers:e,rows:t}){return o("div",{className:"rounded-lg border border-border bg-surface overflow-x-auto",children:f("table",{className:"w-full text-xs min-w-[640px]",children:[o("thead",{children:o("tr",{children:e.map((n,r)=>o("th",{className:`px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border whitespace-nowrap ${r===e.length-1?"text-right":"text-left"}`,children:n},r))})}),o("tbody",{children:t})]})})}function jz({userId:e,username:t,onRevoke:n,revokePending:r,revokeId:s}){const{data:a,isLoading:i}=By({userId:e}),l=a??[];return i||l.length===0?null:f("div",{className:"space-y-1.5",children:[o("div",{className:"text-[11px] font-medium text-foreground",children:t}),o(Vv,{headers:["Name","Prefix","Scopes","Expires","Last used","Created",""],rows:l.map(c=>{const d=r&&s===c.id;return f("tr",{className:"hover:bg-primary/5",children:[o("td",{className:"px-3 py-2 text-foreground border-b border-border font-medium",children:c.name}),f("td",{className:"px-3 py-2 text-foreground border-b border-border font-mono text-[11px]",children:[c.tokenPrefix,"…"]}),o("td",{className:"px-3 py-2 text-foreground border-b border-border",children:o("div",{className:"flex flex-wrap gap-1",children:c.scopes.map((u,p)=>f("span",{className:"inline-block rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-mono",children:[u.type,":",u.type==="device"?`[${u.targets.join(",")}]`:u.target]},p))})}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:ko(c.expiresAt)}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:ko(c.lastUsedAt)}),o("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:ko(c.createdAt)}),o("td",{className:"px-3 py-2 border-b border-border text-right",children:f("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?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ze,{className:"h-3 w-3"}),"Revoke"]})})]},c.id)})})]})}function Vz({users:e,onClose:t,onSubmit:n,submitting:r}){const{user:s}=nn(),i=s?.isAdmin===!0?null:s?.scopes??[],[l,c]=_(e[0]?.id??""),[d,u]=_(""),[p,h]=_([{type:"capability",target:"",access:["view","create"]}]),[m,g]=_(""),b=Dd(p),x=l!==""&&d.trim().length>0&&p.length>0&&b===null&&!r,y=()=>{const w=parseInt(m,10),v=Number.isFinite(w)&&w>0?Date.now()+w*864e5:void 0;n({userId:l,name:d.trim(),scopes:p,expiresAt:v})};return f(Hv,{title:"Create scoped token",onClose:t,children:[f("div",{className:"space-y-3",children:[o(Is,{label:"On behalf of user",children:o("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=>o("option",{value:w.id,children:w.username},w.id))})}),o(Is,{label:"Name",children:o("input",{value:d,onChange:w=>u(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"})}),f(Is,{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:[o($d,{value:p,onChange:h,clampToParent:i}),b&&o("p",{className:"mt-1 text-[10px] text-danger",children:b})]}),o(Is,{label:"Expires in (days)",hint:"Leave blank for non-expiring.",children:o("input",{type:"number",min:1,value:m,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"})})]}),f(qv,{children:[o("button",{onClick:t,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),f("button",{onClick:y,disabled:!x,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[r?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(mn,{className:"h-3.5 w-3.5"}),"Issue token"]})]})]})}function Hz({token:e,label:t,onClose:n}){const[r,s]=_(!1),a=async()=>{try{await navigator.clipboard.writeText(e),s(!0)}catch{}};return f(Hv,{title:`Token: ${t}`,onClose:n,children:[f("div",{className:"space-y-3",children:[o("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."}),o("div",{className:"rounded border border-border bg-background p-2 font-mono text-[11px] break-all select-all",children:e})]}),f(qv,{children:[f("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:[r?o(_t,{className:"h-3.5 w-3.5 text-primary"}):o(aa,{className:"h-3.5 w-3.5"}),r?"Copied":"Copy"]}),o("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 Hv({title:e,onClose:t,children:n}){return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:t,children:f("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:r=>r.stopPropagation(),children:[f("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:e}),o("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-4 w-4"})})]}),o("div",{className:"p-4",children:n})]})})}function qv({children:e}){return o("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:e})}function Is({label:e,hint:t,children:n}){return f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:e}),n,t&&o("p",{className:"text-[10px] text-foreground-subtle",children:t})]})}function qz({addonId:e,fallback:t,tileClassName:n,iconPath:r="assets/icon.svg"}){const[s,a]=_(!1),i=`/api/addon-assets/${e}/${r}`;return o("div",{className:`h-10 w-10 rounded-lg flex items-center justify-center shrink-0 ${n}`,children:s?o(t,{className:"h-5 w-5"}):o("img",{src:i,alt:e,className:"h-6 w-6",onError:()=>a(!0)})})}function Uz({addonId:e,defaultActivity:t,showActivity:n=!0,maxHeight:r="max-h-64",defaultTab:s}){const a=t??(s==="events"?"events":"logs"),[i,l]=_(a);return f("div",{className:"flex flex-col gap-4",children:[o(to,{nodeId:"hub",addonIds:[e],level:"global"}),n&&f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[f("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-surface-hover/20",children:[o("span",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Activity"}),f("div",{className:"flex items-center gap-1",children:[o(Pf,{kind:"logs",active:i==="logs",onClick:()=>l("logs")}),o(Pf,{kind:"events",active:i==="events",onClick:()=>l("events")})]})]}),i==="logs"?o(tn,{addonId:e,maxHeight:r,showFilters:!1}):o(br,{addonId:e,category:"addon.*",maxHeight:r})]})]})}function Pf({kind:e,active:t,onClick:n}){return f("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:[o(e==="logs"?at:Jo,{className:"h-3 w-3"}),e==="logs"?"Logs":"Events"]})}function ns(e){const{title:t,subtitle:n,pageIcon:r,itemIcon:s,capability:a,installButtonLabel:i="Add addon",items:l,isLoading:c,emptyTitle:d="No addons installed for this capability",emptyDescription:u,itemIconColor:p,renderStatusBadges:h,renderPrimaryAction:m,itemError:g,renderExpandedPanel:b,workspaceMaxHeight:x="max-h-72",trailing:y,showChrome:w=!1}=e,v=l.length>1,[N,k]=_(()=>l[0]?.addonId??null);Y(()=>{N&&(l.some(I=>I.addonId===N)||k(l[0]?.addonId??null))},[l,N]);const C=I=>k(A=>A===I?null:I),E=`/system/addons?capability=${encodeURIComponent(a)}`;return o(tt,{icon:w?r:void 0,title:w?t:void 0,subtitle:w?n:void 0,actions:w?o(sa,{to:E,children:f(Be,{variant:"primary",size:"sm",children:[o(Et,{className:"h-3.5 w-3.5 mr-1"}),i]})}):void 0,children:c?o(un,{children:o("div",{className:"p-6 text-sm text-foreground-subtle",children:"Loading…"})}):l.length===0?o(un,{children:o(Wc,{title:d,description:u??`Install an addon that declares the "${a}" capability to get started.`,action:w?o(sa,{to:E,children:f(Be,{variant:"primary",size:"sm",children:[o(Et,{className:"h-3.5 w-3.5 mr-1"}),i]})}):void 0})}):f("div",{className:"flex flex-col gap-4",children:[l.map(I=>{const A=!v||N===I.addonId,z=p?.(I)??(I.isActive?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"),P=g?.(I)??null;return f(un,{children:[f("div",{className:`flex items-center gap-3 p-4 ${A?"border-b border-border":""}`,children:[v&&o("button",{type:"button",onClick:()=>C(I.addonId),"aria-label":A?"Collapse":"Expand",className:"shrink-0 p-1 rounded hover:bg-foreground-subtle/10 transition-colors",children:o(lt,{className:`h-4 w-4 text-foreground-subtle transition-transform ${A?"rotate-180":""}`})}),f("button",{type:"button",onClick:()=>v&&C(I.addonId),className:`flex items-center gap-4 flex-1 min-w-0 text-left ${v?"hover:opacity-80 transition-opacity":""}`,disabled:!v,children:[o(qz,{addonId:I.addonId,fallback:s,tileClassName:z}),f("div",{className:"flex-1 min-w-0",children:[f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"font-semibold text-foreground",children:I.displayName}),o(Qz,{isActive:I.isActive}),h?.(I)]}),f("div",{className:"text-xs text-foreground-subtle mt-1 font-mono",children:["@camstack/addon-",I.addonId]})]})]}),f("div",{className:"flex items-center gap-1 shrink-0",children:[m?.(I),o(Gz,{capName:a,addonId:I.addonId,isActive:I.isActive}),o(Kz,{addonId:I.addonId,displayName:I.displayName})]})]}),A&&f("div",{className:"p-4 flex flex-col gap-3",children:[P!==null&&o(Oa,{message:P}),b?.(I),o(Uz,{addonId:I.addonId,maxHeight:x})]})]},I.addonId)}),y]})})}function Qz({isActive:e}){return o("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 Gz({capName:e,addonId:t,isActive:n}){const r=ke(),s=bb({onSuccess:()=>{r.invalidateQueries({queryKey:[["addons","listCapabilityProviders"]]})}}),a=s.isPending;return f(Be,{size:"sm",variant:n?"secondary":"primary",disabled:a,onClick:()=>s.mutate({capName:e,addonId:t,enabled:!n}),children:[a?o(Se,{className:"h-3 w-3 animate-spin"}):n?o(ts,{className:"h-3 w-3"}):o(Ya,{className:"h-3 w-3"}),n?"Disable":"Enable"]})}function Kz({addonId:e,displayName:t}){const n=ke(),r=Ko({onSuccess:()=>{n.invalidateQueries({queryKey:[["addons","listCapabilityProviders"]]})}});return o(Ad,{label:"Restart",icon:ct,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:r.isPending,action:()=>r.mutateAsync({addonId:e})})}const _f=3e4;function Wz(e){const t=new Map;for(const n of e){const r=n?.manifest;r?.id&&t.set(r.id,r.packageDisplayName??r.name??r.id)}return t}function Yz(e){return e==="local-auth"?{headline:"Username + password (local).",icon:w6,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:_n,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:_n,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:An,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:An,bullets:["Codes / links delivered out-of-band (RFC 6238 for TOTP).","Compatible with Google Authenticator, Aegis, 1Password, Bitwarden, etc."]}:{headline:"Authentication provider.",icon:mn,bullets:["Generic authentication provider. No additional hints registered."]}}function Zz(){const e=Go({capName:"auth-provider"},{refetchInterval:_f}),t=wn(void 0,{refetchInterval:_f}),n=H(()=>Wz(t.data??[]),[t.data]),r=H(()=>(e.data??[]).map(s=>({addonId:s.addonId,displayName:n.get(s.addonId)??s.addonId,isActive:s.isActive})),[e.data,n]);return o(ns,{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:mn,itemIcon:mn,capability:"auth-provider",installButtonLabel:"Add provider",items:r,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=>o(Xz,{addonId:s.addonId})})}function Xz({addonId:e}){const t=Yz(e),n=t.icon;return f("div",{className:"rounded-lg border border-border bg-surface p-4 space-y-3",children:[f("div",{className:"flex items-start gap-2.5",children:[o(n,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),o("div",{className:"text-xs text-foreground font-medium",children:t.headline})]}),o("ul",{className:"text-xs text-foreground-subtle space-y-1.5 pl-6 list-disc",children:t.bullets.map((r,s)=>o("li",{children:r},s))}),t.setupSteps&&t.setupSteps.length>0&&f("div",{className:"rounded-md border border-border bg-surface-hover/40 px-3 py-2.5 space-y-1.5",children:[f("div",{className:"flex items-center gap-1.5 text-[10px] font-semibold text-foreground-subtle uppercase tracking-wide",children:[o(SR,{className:"h-3 w-3"}),"Setup steps"]}),o("ol",{className:"text-xs text-foreground space-y-0.5 pl-4 list-decimal",children:t.setupSteps.map((r,s)=>o("li",{children:r},s))})]}),e==="local-auth"&&f("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:[o(rr,{className:"h-3.5 w-3.5 mt-0.5 text-blue-500 shrink-0"}),f("span",{children:["TOTP / 2FA settings are exposed per-user from the"," ",o("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 Jz(){return o("div",{className:"flex flex-col p-4",children:o(ri,{tabs:[{id:"users",label:"Users",icon:qO,content:o($z,{})},{id:"api-keys",label:"Tokens",icon:W0,content:o(Bz,{})},{id:"authentication",label:"Authentication",icon:mn,content:o(Zz,{})}]})})}const sc=5e3,eF={connected:!1,endpoint:null};function tF(e){const t=new Map;for(const n of e){const r=n?.manifest;r?.id&&t.set(r.id,r.packageDisplayName??r.name??r.id)}return t}function nF(){const e=ke(),t=Go({capName:"network-access"},{refetchInterval:sc}),n=wn(void 0,{refetchInterval:sc}),r=H(()=>tF(n.data??[]),[n.data]),s=H(()=>(t.data??[]).map(m=>({addonId:m.addonId,displayName:r.get(m.addonId)??m.addonId,isActive:m.isActive})),[t.data,r]),[a,i]=_(null),[l,c]=_({}),d=(m,g)=>{e.invalidateQueries({queryKey:[["networkAccess"]]}),i(null),c(b=>{const x=g?.addonId;if(x===void 0||!(x in b))return b;const y={...b};return delete y[x],y})},u=(m,g)=>{i(null);const b=g?.addonId;if(b===void 0)return;const x=m instanceof Error?m.message:String(m);c(y=>({...y,[b]:x}))},p=Px({onSuccess:d,onError:u}),h=_x({onSuccess:d,onError:u});return o(ns,{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:_n,itemIcon:_n,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:m=>o(rF,{addonId:m.addonId}),itemError:m=>l[m.addonId]??null,renderPrimaryAction:m=>o(oF,{addonId:m.addonId,busyId:a,onStart:g=>{i(g),p.mutate({addonId:g})},onStop:g=>{i(g),h.mutate({addonId:g})}})})}function Uv(e){const{data:t}=$x({addonId:e},{refetchInterval:sc,retry:!1}),n=t?v2.safeParse(t):null;return n?.success?n.data:eF}function rF({addonId:e}){const t=Uv(e);return f(me,{children:[o("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&&f("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:[o(Wd,{className:"h-3 w-3"}),t.endpoint.url]})]})}function oF({addonId:e,busyId:t,onStart:n,onStop:r}){const s=Uv(e),a=t===e;return s.connected?f(Be,{size:"sm",variant:"secondary",disabled:a,onClick:()=>r(e),children:[a?o(Se,{className:"h-3 w-3 animate-spin"}):o(ts,{className:"h-3 w-3"}),"Stop"]}):f(Be,{size:"sm",variant:"primary",disabled:a,onClick:()=>n(e),children:[a?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ya,{className:"h-3 w-3"}),"Start"]})}const $f=3e4;function sF(e){const t=new Map;for(const n of e){const r=n?.manifest;r?.id&&t.set(r.id,r.packageDisplayName??r.name??r.id)}return t}function aF(e){const t=[];for(const n of e)typeof n.urls=="string"?t.push(n.urls):t.push(...n.urls);return t}function iF(){const e=Go({capName:"turn-provider"},{refetchInterval:$f}),t=wn(void 0,{refetchInterval:$f}),n=yd(),r=n.data??[],s=H(()=>sF(t.data??[]),[t.data]),a=H(()=>(e.data??[]).map(i=>({addonId:i.addonId,displayName:s.get(i.addonId)??i.addonId,isActive:i.isActive})),[e.data,s]);return o(ns,{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:$n,itemIcon:$n,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=>o(lF,{addonId:i.addonId,enabled:i.isActive}),trailing:f(un,{children:[f("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[f("div",{children:[o("div",{className:"text-sm font-semibold",children:"Combined ICE server list"}),o("div",{className:"text-xs text-foreground-subtle",children:"What the WebRTC layer fetches per-session."})]}),o(Be,{size:"sm",variant:"secondary",onClick:()=>n.refetch(),disabled:n.isFetching,children:"Refresh"})]}),o("div",{className:"p-4",children:r.length===0?o("div",{className:"text-xs text-foreground-subtle",children:"No servers from enabled providers."}):o("div",{className:"flex flex-col gap-3",children:r.map((i,l)=>{const c=Array.isArray(i.urls)?i.urls:[i.urls];return f("div",{className:"rounded border border-border bg-surface",children:[(i.username||i.credential)&&f("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&&f("span",{children:[o("span",{className:"text-foreground-subtle",children:"user:"})," ",o("span",{className:"text-foreground",children:i.username})]}),i.credential&&f("span",{title:i.credential,children:[o("span",{className:"text-foreground-subtle",children:"credential:"})," ",o("span",{className:"text-foreground",children:`${i.credential.slice(0,8)}…${i.credential.slice(-4)}`})]})]}),o("ul",{className:"divide-y divide-border",children:c.map(d=>o("li",{className:"px-3 py-1.5 font-mono text-xs text-foreground break-all",children:d},d))})]},l)})})})]})})}function lF({addonId:e,enabled:t}){const n=yd({addonId:e},{enabled:t,retry:!1}),r=H(()=>aF(n.data??[]),[n.data]);return!t||r.length===0?null:f("div",{className:"rounded-lg border border-border bg-surface p-3",children:[f("div",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide mb-2",children:["Discovered ICE servers (",r.length,")"]}),o("div",{className:"flex flex-wrap gap-1",children:r.map(s=>o("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 cF={lan:$n,wifi:or,docker:Wa,vpn:Yd,loopback:hn,other:hn},dF={lan:"LAN",wifi:"Wi-Fi",docker:"Docker",vpn:"VPN",loopback:"Loopback",other:"Other"},uF=["lan","wifi","vpn","docker","other","loopback"];function pF(e){const{interfaces:t,disabled:n,hideLoopback:r,ipv4Only:s,emptyMessage:a}=e,i=H(()=>t.filter(u=>!(r&&u.kind==="loopback"||s&&u.family!=="IPv4")),[t,r,s]),l=H(()=>{const u=new Map;for(const p of i){const h=u.get(p.kind)??[];h.push(p),u.set(p.kind,h)}return uF.filter(p=>u.has(p)).map(p=>({kind:p,items:u.get(p)}))},[i]),c=u=>e.mode==="single"?e.value===u:e.value.includes(u),d=u=>{if(n||u.kind==="loopback")return;if(e.mode==="single"){e.onChange(e.value===u.address?null:u.address);return}const p=new Set(e.value);p.has(u.address)?p.delete(u.address):p.add(u.address),e.onChange([...p])};return i.length===0?o("div",{className:"text-xs text-foreground-subtle italic",children:a??"No addresses available."}):o("div",{className:"flex flex-col gap-3",children:l.map(({kind:u,items:p})=>{const h=cF[u]??hn;return f("div",{className:"rounded-md border border-border overflow-hidden",children:[f("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border",children:[o(h,{className:"h-3.5 w-3.5 text-foreground-subtle"}),o("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle",children:dF[u]??u}),f("span",{className:"text-[10px] text-foreground-subtle",children:["· ",p.length]})]}),o("ul",{className:"divide-y divide-border",children:p.map(m=>{const g=c(m.address),b=m.kind==="loopback",x=!m.plausible&&!b;return f("li",{className:`flex items-center gap-3 px-3 py-2 ${b?"opacity-60 cursor-not-allowed":n?"opacity-60":x?"cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]":"cursor-pointer hover:bg-surface-hover/30"}`,onClick:()=>d(m),children:[o("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&&o(_t,{className:"h-3 w-3"})}),f("div",{className:`flex-1 min-w-0 ${x?"text-foreground-subtle":""}`,children:[f("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:`font-mono text-xs font-semibold ${x?"text-foreground-subtle":"text-foreground"}`,children:m.name}),o("span",{className:"text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono",children:m.family}),m.preferred&&o("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary",children:"Auto-preferred"}),b&&o("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle",children:"Always included"}),x&&f("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:m.plausibleReason||void 0,children:[o(it,{className:"h-2.5 w-2.5"}),"Unlikely usable"]})]}),f("div",{className:"text-xs text-foreground-subtle mt-0.5 font-mono break-all",children:[m.address,m.cidr&&m.cidr!==m.address?` (${m.cidr})`:""]})]})]},`${m.name}-${m.family}-${m.address}`)})})]},u)})})}const Df={"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 fF(){const e=ke(),t=Te(),n=bx(void 0,{refetchInterval:3e4}),r=yx(void 0),s=vx({onSuccess:()=>{e.invalidateQueries({queryKey:[["localNetwork"]]})}}),a=wx({onSuccess:C=>{p(C.addresses),e.invalidateQueries({queryKey:[["localNetwork"]]})}}),i=H(()=>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=xx({port:l,scheme:c},{refetchInterval:3e4}),[u,p]=_([]),[h,m]=_(!1);Y(()=>{!h&&r.data&&(p(r.data.addresses),m(!0))},[r.data,h]);const g=r.data?.addresses??[],b=H(()=>{if(u.length!==g.length)return!0;const C=[...u].sort(),E=[...g].sort();return C.some((I,A)=>I!==E[A])},[u,g]),x=()=>{s.mutate({addresses:[...u]})},y=()=>{p(g)},w=()=>{p([])},v=()=>{n.refetch(),d.refetch(),r.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 f(tt,{children:[f("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[o("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."}),f("div",{className:"flex items-center gap-2 shrink-0",children:[f(Be,{size:"sm",variant:"secondary",onClick:v,disabled:n.isLoading,children:[o(ct,{className:`h-3 w-3 ${n.isLoading?"animate-spin":""}`}),"Refresh"]}),o(Be,{size:"sm",variant:"secondary",onClick:N,children:"Probe race"})]})]}),f("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[f(un,{children:[f("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[f("div",{children:[o("div",{className:"text-sm font-semibold",children:"Allowed addresses"}),o("div",{className:"text-xs text-foreground-subtle",children:u.length===0?"Auto — every non-loopback / non-link-local interface participates.":`${u.length} pinned`})]}),f("div",{className:"flex items-center gap-1",children:[f(Be,{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:[o(_O,{className:"h-3 w-3"}),a.isPending?"Detecting…":"Best match"]}),f(Be,{size:"sm",variant:"secondary",onClick:w,disabled:u.length===0||s.isPending,children:[o(tv,{className:"h-3 w-3"}),"Clear"]}),b&&o(Be,{size:"sm",variant:"secondary",onClick:y,disabled:s.isPending,children:"Discard"}),f(Be,{size:"sm",variant:"primary",onClick:x,disabled:!b||s.isPending,children:[o(fO,{className:"h-3 w-3"}),s.isPending?"Saving…":"Save"]})]})]}),o("div",{className:"p-4",children:o(pF,{mode:"multiple",interfaces:i,value:u,onChange:p,disabled:s.isPending,emptyMessage:n.isLoading?"Loading interfaces…":"No interfaces detected."})})]}),f(un,{children:[f("div",{className:"px-4 py-3 border-b border-border",children:[o("div",{className:"text-sm font-semibold",children:"Connection endpoints — priority order"}),o("div",{className:"text-xs text-foreground-subtle",children:"Live preview of the ranked candidate list the SDK would race against. Updates with each Save."})]}),o("div",{className:"p-4",children:k.length===0?o("div",{className:"text-xs text-foreground-subtle italic",children:d.isLoading?"Loading…":"No endpoints available."}):o("ul",{className:"space-y-1 text-xs",children:k.map(C=>f("li",{className:`flex items-center gap-2 flex-wrap ${C.plausible?"":"opacity-80"}`,children:[o("span",{className:"font-mono text-[10px] w-10 text-foreground-subtle",children:String(C.priority).padStart(4,"0")}),o("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${Df[C.kind]??Df.loopback}`,children:C.kind}),C.interfaceKind!=="lan"&&C.interfaceKind!=="public"&&o("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"&&f("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:[o(it,{className:"h-2.5 w-2.5"}),"Unlikely usable"]}),o("span",{className:`font-mono break-all ${C.plausible?"text-foreground":"text-foreground-subtle"}`,children:C.baseUrl}),f("span",{className:"text-foreground-subtle",children:["— ",C.label]})]},`${C.priority}-${C.baseUrl}`))})})]})]})]})}const hF={mesh:"bg-violet-500/15 text-violet-700 dark:text-violet-300",public:"bg-blue-500/15 text-blue-700 dark:text-blue-300"},ac=5e3,mF=3e4,gF={joined:!1,meshIp:"",magicDnsHostname:"",peerCount:0,endpoints:[],tenantName:"",magicDnsSuffix:"",userLogin:null,controlPlaneUrl:"",keyExpiry:null};function bF(e){const t=new Map;for(const n of e){const r=n?.manifest;r?.id&&t.set(r.id,r.packageDisplayName??r.name??r.id)}return t}function xF(){const e=Go({capName:"mesh-network"},{refetchInterval:ac}),t=wn(void 0,{refetchInterval:ac}),n=H(()=>bF(t.data??[]),[t.data]),r=H(()=>(e.data??[]).map(s=>({addonId:s.addonId,displayName:n.get(s.addonId)??s.addonId,isActive:s.isActive})),[e.data,n]);return o(ns,{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:Wa,itemIcon:$n,capability:"mesh-network",installButtonLabel:"Add mesh",items:r,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=>o(yF,{addonId:s.addonId}),renderPrimaryAction:s=>o(vF,{addonId:s.addonId}),renderExpandedPanel:s=>o(wF,{addonId:s.addonId})})}function tu(e){const{data:t,isLoading:n}=Nx({addonId:e},{refetchInterval:ac,retry:!1}),r=t?pm.safeParse(t):null;return{status:r?.success?r.data:gF,isLoading:n}}function yF({addonId:e}){const{status:t}=tu(e);return f(me,{children:[o("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&&f("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 vF({addonId:e}){const t=ke(),[n,r]=_(!1),[s,a]=_(null),i=Te(),{status:l}=tu(e),c=U(()=>{t.invalidateQueries({queryKey:[["meshNetwork"]]})},[t]),d=kx(),u=Sx({onSuccess:c}),p=Cx({onSuccess:c}),h=U(async()=>{r(!0);const g={cancelled:!1};a(g);try{const b=await d.mutateAsync({addonId:e});if(g.cancelled)return;b.loginUrl&&window.open(b.loginUrl,"_blank","noopener,noreferrer");const x=Date.now(),y=10*6e4;for(;!g.cancelled&&(await MF(2e3),!g.cancelled);){const w=await i.trpcClient.meshNetwork.getStatus.query({addonId:e}).catch(()=>null),v=w?pm.safeParse(w):null;if(v?.success&&v.data.joined){c();break}if(Date.now()-x>y)break}}finally{r(!1),a(null)}},[e,c,d,i]),m=U(()=>{s&&(s.cancelled=!0),r(!1),a(null)},[s]);return o(me,{children:l.joined?f(me,{children:[f(Be,{size:"sm",variant:"secondary",disabled:u.isPending,onClick:()=>u.mutate({addonId:e}),children:[u.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(Zd,{className:"h-3 w-3"}),"Disconnect"]}),f(Be,{size:"sm",variant:"ghost",disabled:p.isPending,onClick:()=>p.mutate({addonId:e}),children:[p.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(Hp,{className:"h-3 w-3"}),"Log out"]})]}):n?f(Be,{size:"sm",variant:"ghost",onClick:m,children:[o(Fe,{className:"h-3 w-3 mr-1"})," Cancel"]}):f(me,{children:[f(Be,{size:"sm",variant:"primary",onClick:()=>void h(),children:[o($6,{className:"h-3 w-3"}),"Connect"]}),f(Be,{size:"sm",variant:"ghost",disabled:p.isPending,onClick:()=>p.mutate({addonId:e}),children:[p.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(Hp,{className:"h-3 w-3"}),"Log out"]})]})})}function wF({addonId:e}){const{status:t}=tu(e),n=Mx({addonId:e},{refetchInterval:mF,retry:!1});return f("div",{className:"rounded-lg border border-border bg-surface",children:[f("div",{className:"p-4 space-y-4",children:[t.error&&o(Oa,{message:t.error}),o(NF,{status:t}),t.endpoints.length>0&&f("div",{className:"space-y-1.5",children:[o("div",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Endpoints"}),t.endpoints.map(r=>f("div",{className:"flex items-center gap-2 text-xs flex-wrap",children:[f("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${hF[r.scope]??"bg-foreground-subtle/15 text-foreground-subtle"}`,children:[r.scope==="public"?o(_n,{className:"inline h-2.5 w-2.5 mr-0.5"}):null,r.label]}),f("a",{href:r.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:[o(Wd,{className:"h-3 w-3 shrink-0"}),r.url]})]},r.id))]})]}),o("div",{className:"border-t border-border",children:o(SF,{peers:n.data?.peers??[],loading:n.isLoading})})]})}function NF({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?kF(e.keyExpiry):"—"}];return o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5",children:t.map(n=>f("div",{className:"flex items-baseline justify-between gap-3 text-xs",children:[o("span",{className:"text-foreground-subtle shrink-0",children:n.label}),o("span",{className:`text-foreground truncate ${n.mono?"font-mono":""}`,children:n.value})]},n.label))})}function kF(e){const t=e-Date.now();if(t<0)return`Expired ${Qv(e)}`;const n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return`in ${n} days`;const r=Math.floor(t/36e5);return r>1?`in ${r}h`:`in ${Math.max(1,Math.floor(t/6e4))} min`}function SF({peers:e,loading:t}){const n=H(()=>e.map(a=>({...a,_id:a.id})),[e]),r=U(a=>{a&&navigator.clipboard?.writeText(a)},[]),s=H(()=>[{key:"hostname",header:"Hostname",render:a=>f("div",{className:"flex flex-col",children:[f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"font-medium text-foreground",children:a.hostname||"(unknown)"}),a.isSelf&&o(zt,{variant:"info",children:"self"}),a.exitNodeOption&&o(zt,{variant:"warning",children:"exit-node"})]}),a.userLogin&&o("div",{className:"text-[10px] text-foreground-subtle truncate",children:a.userLogin})]})},{key:"magicDns",header:"MagicDNS",render:a=>a.magicDns?f("div",{className:"flex items-center gap-1",children:[o("span",{className:"font-mono text-xs truncate",children:a.magicDns}),o("button",{onClick:()=>r(a.magicDns),className:"p-0.5 hover:bg-foreground-subtle/10 rounded","aria-label":"Copy MagicDNS",children:o(aa,{className:"h-3 w-3 text-foreground-subtle"})})]}):o("span",{className:"text-foreground-subtle",children:"—"})},{key:"addresses",header:"IP",render:a=>{const i=a.addresses[0]??"";return i?f("div",{className:"flex items-center gap-1",children:[o("span",{className:"font-mono text-xs",children:i}),o("button",{onClick:()=>r(i),className:"p-0.5 hover:bg-foreground-subtle/10 rounded","aria-label":"Copy IP",children:o(aa,{className:"h-3 w-3 text-foreground-subtle"})})]}):o("span",{className:"text-foreground-subtle",children:"—"})}},{key:"connection",header:"Connection",render:a=>f("div",{className:"flex items-center gap-1.5",children:[o(zt,{variant:CF(a.connection),children:a.connection}),a.relay&&o("span",{className:"text-[10px] text-foreground-subtle font-mono",children:a.relay})]})},{key:"routes",header:"Routes",render:a=>a.advertisedRoutes.length>0?o("span",{className:"text-[10px] font-mono text-foreground-subtle truncate",children:a.advertisedRoutes.join(", ")}):o("span",{className:"text-foreground-subtle",children:"—"})},{key:"tx",header:"TX / RX",render:a=>f("span",{className:"text-[10px] text-foreground-subtle font-mono",children:["↑ ",Tf(a.txBytes)," · ↓ ",Tf(a.rxBytes)]})},{key:"lastSeen",header:"Last seen",render:a=>o("span",{className:"text-[10px] text-foreground-subtle",children:a.lastSeenMs>0?Qv(a.lastSeenMs):"—"})}],[r]);return t&&e.length===0?f("div",{className:"p-4 text-xs text-foreground-subtle",children:[o(Se,{className:"h-3 w-3 animate-spin inline mr-1"})," Loading peers…"]}):e.length===0?o("div",{className:"p-4 text-xs text-foreground-subtle",children:"No peers visible — your tailnet may be empty or the host is not joined."}):o("div",{className:"p-4",children:o(Da,{columns:s,rows:n,rowKey:a=>a._id,minWidthPx:820})})}function CF(e){return e==="direct"?"success":e==="relay"?"warning":"info"}function Tf(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 Qv(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 MF(e){return new Promise(t=>setTimeout(t,e))}function EF(){return o("div",{className:"flex flex-col p-4",children:o(ri,{tabs:[{id:"addresses",label:"Network Addresses",icon:hn,content:o(fF,{})},{id:"remote-access",label:"Remote Access",icon:_n,content:o(nF,{})},{id:"mesh",label:"Mesh Networks",icon:Wa,content:o(xF,{})},{id:"turn",label:"TURN Servers",icon:$n,content:o(iF,{})}]})})}const IF=[{kind:"device-export",tabId:"device-export",title:"Device export",subtitle:"Outbound exporters that publish CamStack devices to other ecosystems (HomeAssistant, HomeKit, Alexa, …).",icon:wO,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:L6,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:Za,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 PF(e){const t=e,n=t?.manifest;if(!n?.id)return null;const r=[];for(const i of n.capabilities??[]){const l=AF(i);l!==null&&r.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:r,processState:a}}function _F(e,t){const n=new Set(t);return e.filter(r=>r.capNames.some(s=>n.has(s)))}function $F(e){for(const[t,n]of Object.entries(hm))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 nu({label:e,className:t}){return o("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t}`,children:e})}function TF({addonId:e}){const{data:t,isLoading:n}=Ax({addonId:e},{refetchInterval:1e4,retry:!1});if(n||!t)return null;const r=w2.safeParse(t);if(!r.success)return null;const s=r.data,a=`${s.brokerCount} broker${s.brokerCount===1?"":"s"}${s.embeddedRunning?" • embedded up":""}`;return o(nu,{label:a,className:"bg-primary/10 text-primary"})}function LF({addonId:e}){const{data:t,isLoading:n}=ld({addonId:e},{refetchInterval:1e4,retry:!1});if(n||!t)return null;const r=um.safeParse(t);if(!r.success)return null;const s=r.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 o(nu,{label:i,className:a})}function RF({kind:e,addonId:t}){return e==="broker"?o(TF,{addonId:t}):e==="device-export"?o(LF,{addonId:t}):null}function OF({descriptor:e,rows:t,isLoading:n}){const r=$F(e.kind),s=e.kind==="device-export";return o(ns,{title:e.title,subtitle:e.subtitle,pageIcon:e.icon,itemIcon:e.icon,capability:r??e.kind,installButtonLabel:e.addLabel,items:t,isLoading:n,emptyTitle:e.emptyTitle,emptyDescription:e.emptyDescription,renderStatusBadges:a=>{const i=DF(a.processState);return f(me,{children:[o(nu,{label:i.label,className:i.className}),o(RF,{kind:e.kind,addonId:a.addonId})]})},renderExpandedPanel:s?a=>o(Md,{addonId:a.addonId}):void 0,showChrome:!0})}function BF(){const e=wn(void 0,{refetchInterval:1e4}),t=(e.data??[]).map(PF).filter(r=>r!==null),n=IF.map(r=>{const s=Object.entries(hm).filter(([,a])=>a===r.kind).map(([a])=>a);return{id:r.tabId,label:r.title,icon:r.icon,content:o(OF,{descriptor:r,rows:_F(t,s),isLoading:e.isLoading})}});return o(tt,{icon:_o,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:o(ri,{tabs:n})})}function zF(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 FF({location:e,onEdit:t,onDelete:n,onSetDefault:r}){const s=zF(e.config);return f("div",{className:"flex items-center gap-3 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5",children:[f("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o("div",{className:"w-[88px] shrink-0",children:e.isDefault?f("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:[o(zi,{className:"h-2.5 w-2.5 fill-primary"}),"Default"]}):f("button",{onClick:()=>r(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:[o(zi,{className:"h-2.5 w-2.5"}),"Set default"]})}),o("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&&o("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"}),f("div",{className:"min-w-0",children:[o("div",{className:"text-xs font-medium text-foreground truncate",children:e.displayName}),s&&o("div",{className:"text-[10px] text-foreground-subtle truncate font-mono",children:s})]})]}),f("div",{className:"flex items-center gap-1 shrink-0",children:[!e.isDefault&&f("button",{onClick:()=>r(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:[o(zi,{className:"h-3 w-3"}),"Set default"]}),f("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:[o(eo,{className:"h-3 w-3"}),"Edit"]}),!e.isSystem&&zs[e.type]!=="singleton"&&o("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:o(Ze,{className:"h-3 w-3"})})]})]})}function jF({type:e,displayName:t,description:n,locations:r,onAdd:s,onEdit:a,onDelete:i,onSetDefault:l}){const c=H(()=>{const d=[...r];return d.sort((u,p)=>u.isDefault!==p.isDefault?u.isDefault?-1:1:u.displayName.localeCompare(p.displayName)),d},[r]);return f("div",{className:"rounded-lg border border-border bg-surface",children:[f("div",{className:"flex items-start justify-between border-b border-border px-3 py-2",children:[f("div",{className:"space-y-0.5",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-sm font-semibold text-foreground capitalize",children:t}),o("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&&o("p",{className:"text-[11px] text-foreground-subtle",children:n}),zs[e]==="singleton"&&o("p",{className:"text-[10px] text-foreground-subtle italic",children:"Singleton — one location per type. Edit the existing entry; it can't be split."})]}),zs[e]==="multi"&&f("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:[o(Et,{className:"h-3 w-3"}),"Add"]})]}),c.length===0?o("div",{className:"px-3 py-4 text-center text-[11px] text-foreground-subtle italic",children:zs[e]==="multi"?'No location registered. Click "Add" to register one.':"No location registered yet — should be auto-seeded at next boot."}):o("div",{children:c.map(d=>o(FF,{location:d,onEdit:a,onDelete:i,onSetDefault:l},d.id))})]})}function VF(e){const t=e.trim().toLowerCase();return t.length===0?"":t.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Lf(e,t){const n=VF(t),r=n.length>0?n:"default";return`${e}:${r}`}function Gv({initialType:e,onClose:t,onCreated:n}){const r=ke(),s=Te().trpcClient,[a,i]=_("picker"),[l,c]=_(e),[d,u]=_(null),[p,h]=_({}),[m,g]=_(""),[b,x]=_(null),[y,w]=_(!1),[v,N]=_(null),[k,C]=_(!1),E=xd(),I=H(()=>{const D=E.data;return Array.isArray(D)?D.filter(L=>L.supportedLocationTypes.includes(l)):[]},[E.data,l]),A=E.isLoading,z=ja({onSuccess:()=>{r.invalidateQueries({queryKey:[["storage","listLocations"]]}),n()}}),P=H(()=>b!==null&&b.length>0?b:Lf(l,m),[l,m,b]),B=async()=>{if(d){C(!0),N(null);try{const L=await(O=>s.storage.testConfig.query(O))({providerId:d.providerId,config:p});N(L)}catch(D){N({ok:!1,error:D instanceof Error?D.message:String(D)})}finally{C(!1)}}},R=()=>{d&&z.mutate({id:P,type:l,displayName:m.trim(),providerId:d.providerId,config:p,isDefault:y})},M={picker:"Add Location — Pick provider",config:`Add Location — ${d?.displayName??""}`,naming:"Add Location — Name & defaults"};return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:t,children:f("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:D=>D.stopPropagation(),children:[f("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[f("div",{className:"space-y-0.5",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:M[a]}),f("p",{className:"text-xs text-foreground-subtle",children:["Type: ",o("span",{className:"font-mono",children:l})]})]}),o("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-4 w-4"})})]}),a==="picker"&&f("div",{className:"p-4 space-y-2",children:[A&&o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading providers…"}),!A&&I.length===0&&f("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. ',o("code",{className:"font-mono",children:"remote-storage"}),") to enable it."]}),I.map(D=>f("button",{onClick:()=>{u(D),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:[f("div",{className:"flex-1 min-w-0",children:[o("p",{className:"text-xs font-semibold text-foreground",children:D.displayName}),o("p",{className:"text-[10px] text-foreground-subtle font-mono mt-0.5 truncate",children:D.providerId})]}),o(wt,{className:"h-4 w-4 text-foreground-subtle flex-shrink-0"})]},D.providerId))]}),a==="config"&&d&&f("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[o(Dn,{schema:d.configSchema,values:p,onChange:h}),v&&o("div",{className:`rounded border px-3 py-2 text-[11px] ${v.ok?"border-success/30 bg-success/5 text-success":"border-danger/30 bg-danger/5 text-danger"}`,children:v.ok?"Connection OK.":`Test failed: ${v.error??"unknown error"}`}),f("div",{className:"flex items-center justify-between pt-1",children:[o("button",{onClick:()=>i("picker"),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Back"}),f("div",{className:"flex items-center gap-2",children:[o("button",{onClick:()=>{B()},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"}),o("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&&f("div",{className:"p-4 space-y-3",children:[f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Display name"}),o("input",{type:"text",value:m,onChange:D=>g(D.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"})]}),f("div",{className:"space-y-1",children:[f("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:["Id ",o("span",{className:"lowercase tracking-normal text-foreground-subtle",children:"— auto-derived; override if needed"})]}),o("input",{type:"text",value:P,onChange:D=>x(D.target.value),placeholder:Lf(l,m),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"}),f("p",{className:"text-[10px] text-foreground-subtle",children:["Format: ",o("code",{className:"font-mono",children:"<type>:<slug>"}),". Lowercase letters, digits, and hyphens only."]})]}),f("label",{className:"flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5",children:[o("input",{type:"checkbox",checked:y,onChange:D=>w(D.target.checked),className:"accent-primary mt-0.5"}),f("div",{className:"space-y-0.5",children:[f("div",{className:"text-xs font-medium text-foreground",children:['Mark as default for type "',l,'"']}),f("div",{className:"text-[10px] text-foreground-subtle",children:["Setting this as default will demote the current default for this type. References like"," ",f("code",{className:"font-mono",children:['"',l,'"']})," resolve to whichever location is the default."]})]})]}),z.isError&&o("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)}),f("div",{className:"flex items-center justify-between pt-1",children:[o("button",{onClick:()=>i("config"),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Back"}),f("div",{className:"flex items-center gap-2",children:[o("button",{onClick:()=>{c(e),u(null),h({}),g(""),x(null),w(!1),N(null),i("picker")},className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Reset"}),f("button",{onClick:R,disabled:z.isPending||m.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?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):null,z.isPending?"Saving…":"Save"]})]})]})]})]})})}function HF({location:e,onClose:t,onSaved:n}){const r=ke(),s=Te().trpcClient,[a,i]=_({...e.config}),[l,c]=_(e.displayName),[d,u]=_(null),[p,h]=_(!1),m=xd(),g=H(()=>{const w=m.data;return Array.isArray(w)?w.find(N=>N.providerId===e.providerId)??null:null},[m.data,e.providerId]),b=ja({onSuccess:()=>{r.invalidateQueries({queryKey:[["storage","listLocations"]]}),n()}}),x=async()=>{h(!0),u(null);try{const v=await(N=>s.storage.testConfig.query(N))({providerId:e.providerId,config:a});u(v)}catch(w){u({ok:!1,error:w instanceof Error?w.message:String(w)})}finally{h(!1)}},y=()=>{b.mutate({id:e.id,type:e.type,providerId:e.providerId,isDefault:e.isDefault,displayName:l.trim(),config:a})};return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:t,children:f("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:w=>w.stopPropagation(),children:[f("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[f("div",{className:"space-y-0.5",children:[f("h2",{className:"text-sm font-semibold text-foreground",children:["Edit ",e.displayName]}),f("p",{className:"text-xs text-foreground-subtle",children:[o("span",{className:"font-mono",children:e.id})," · ",g?.displayName??e.providerId]})]}),o("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Display name"}),o("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&&o(Dn,{schema:g.configSchema,values:a,onChange:i}),!g&&!m.isLoading&&f("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 ",o("code",{className:"font-mono",children:e.providerId})," is no longer registered. Field schema unavailable; raw config is preserved on save."]}),d&&o("div",{className:`rounded border px-3 py-2 text-[11px] ${d.ok?"border-success/30 bg-success/5 text-success":"border-danger/30 bg-danger/5 text-danger"}`,children:d.ok?"Connection OK.":`Test failed: ${d.error??"unknown error"}`}),b.isError&&o("div",{className:"rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]",children:b.error instanceof Error?b.error.message:String(b.error)})]}),f("div",{className:"flex items-center justify-between gap-2 border-t border-border px-4 py-3",children:[o("button",{onClick:t,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),f("div",{className:"flex items-center gap-2",children:[o("button",{onClick:()=>{x()},disabled:p||!g,className:"rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50",children:p?"Testing…":"Test connection"}),f("button",{onClick:y,disabled:b.isPending||l.trim().length===0,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[b.isPending?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):null,b.isPending?"Saving…":"Save"]})]})]})]})})}const qF={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"},UF={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 QF(){const e=ke(),t=nt(),{data:n,isLoading:r,isError:s}=My({}),[a,i]=_(null),[l,c]=_(null),d=Ey({onSuccess:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]})}}),u=ja({onSuccess:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]})}}),p=g=>{g.isDefault||u.mutate({id:g.id,type:g.type,providerId:g.providerId,displayName:g.displayName,config:g.config,isDefault:!0})},h=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})},m=H(()=>{const g=new Map;for(const b of Lu)g.set(b,[]);for(const b of n??[]){const x=g.get(b.type);x?x.push(b):g.set(b.type,[b])}return g},[n]);return f(tt,{children:[r&&o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading locations…"}),s&&o("div",{className:"text-xs text-danger",children:"Failed to load storage locations."}),!r&&!s&&o("div",{className:"space-y-3",children:Lu.map(g=>o(jF,{type:g,displayName:qF[g],description:UF[g],locations:m.get(g)??[],onAdd:b=>i(b),onEdit:b=>c(b),onDelete:b=>{h(b)},onSetDefault:b=>p(b)},g))}),a!==null&&o(Gv,{initialType:a,onClose:()=>i(null),onCreated:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),i(null)}}),l!==null&&o(HF,{location:l,onClose:()=>c(null),onSaved:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),c(null)}})]})}const GF=[["backup","listDestinations"]],KF=["backup","listArchives"];function WF({destinationId:e,restoreSupported:t,onOpenRestoreWizard:n}){const r=ke(),s=nt(),{data:a,isLoading:i,isError:l}=id({destinationId:e}),c=a??[],d=Bb({onSuccess:()=>{r.invalidateQueries({queryKey:[[...KF]]}),r.invalidateQueries({queryKey:GF})}}),u=U(async b=>{await s({title:"Delete this archive?",message:`Permanently deletes "${b.label??b.id}" and frees ${It(b.sizeBytes)}.`,confirmLabel:"Delete",variant:"danger"})&&d.mutate({destinationId:e,backupId:b.id})},[s,e,d]),[p,h]=_(null),m=U(async b=>{h(b.id);try{const x=localStorage.getItem("camstack_admin_token"),y={};x&&(y.Authorization=`Bearer ${x}`);const w=await fetch(YF(e,b.id),{headers:y});if(!w.ok)throw new Error(`download failed: ${w.status} ${w.statusText}`);const v=await w.blob(),N=URL.createObjectURL(v),k=document.createElement("a");k.href=N,k.download=`${b.label??b.id}.tar.gz`,document.body.appendChild(k),k.click(),k.remove(),URL.revokeObjectURL(N)}finally{h(null)}},[e]),g=H(()=>[...c].sort((b,x)=>x.createdAt-b.createdAt),[c]);return i?o("div",{className:"text-xs text-foreground-subtle animate-pulse py-2",children:"Loading archives…"}):l?o("div",{className:"text-xs text-danger py-2",children:"Failed to read manifest for this destination"}):g.length===0?o("div",{className:"text-xs text-foreground-subtle italic py-2",children:"No archives at this destination yet."}):o("div",{className:"rounded border border-border bg-surface overflow-x-auto",children:f("table",{className:"w-full text-xs min-w-[640px]",children:[o("thead",{children:f("tr",{className:"text-foreground-subtle bg-background/30",children:[o("th",{className:"text-left px-3 py-1.5 font-medium",children:"When"}),o("th",{className:"text-left px-3 py-1.5 font-medium",children:"Label"}),o("th",{className:"text-left px-3 py-1.5 font-medium",children:"Includes"}),o("th",{className:"text-right px-3 py-1.5 font-medium",children:"Size"}),o("th",{className:"text-right px-3 py-1.5 font-medium w-52",children:"Actions"})]})}),o("tbody",{children:g.map(b=>f("tr",{className:"border-t border-border hover:bg-primary/5",children:[o("td",{className:"px-3 py-1.5 text-foreground tabular-nums",children:ZF(b.createdAt)}),o("td",{className:"px-3 py-1.5 text-foreground",children:b.label??o("span",{className:"text-foreground-subtle italic",children:"—"})}),o("td",{className:"px-3 py-1.5 text-foreground-subtle",children:b.locations.join(", ")}),o("td",{className:"px-3 py-1.5 text-foreground text-right tabular-nums",children:It(b.sizeBytes)}),o("td",{className:"px-3 py-1.5",children:f("div",{className:"flex items-center justify-end gap-1",children:[f("button",{onClick:()=>{m(b)},disabled:p===b.id,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 disabled:opacity-50",title:"Download archive",children:[p===b.id?o(Se,{className:"h-3 w-3 animate-spin"}):o(Xt,{className:"h-3 w-3"}),"Download"]}),t&&n&&f("button",{onClick:()=>n({destinationId:e,archiveId:b.id}),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-primary hover:bg-primary/10",title:"Restore from this archive",children:[o(kt,{className:"h-3 w-3"}),"Restore"]}),o("button",{onClick:()=>{u(b)},disabled:d.isPending,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50",title:"Delete archive",children:d.isPending?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ze,{className:"h-3 w-3"})})]})})]},b.id))})]})})}function YF(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function ZF(e){return new Date(e).toLocaleString(void 0,{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Kv=[{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 XF(e){const t=e.trim();for(const n of Kv)if(n.cron===t)return n.id;return"custom"}function JF({value:e,onChange:t,previewCount:n=5,disabled:r=!1}){const s=XF(e),[a,i]=_(s==="custom");Y(()=>{s!=="custom"&&i(!1)},[s]);const l=nj(e,250),c=Fb({cron:l,count:n},{enabled:l.trim().length>0}),d=c.data??null,u=h=>{i(!1),t(h.cron)},p=a||s==="custom";return f("div",{className:"space-y-3",children:[f("div",{className:"space-y-1",children:[o("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Schedule preset"}),f("div",{className:"flex flex-wrap gap-1.5",children:[Kv.map(h=>{const m=!a&&s===h.id;return o("button",{type:"button",onClick:()=>u(h),disabled:r,className:"rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 "+(m?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground"),title:h.description??h.label,children:h.label},h.id)}),o("button",{type:"button",onClick:()=>{i(!0),e.trim().length===0&&t("0 3 * * *")},disabled:r,className:"rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 "+(p?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground"),children:"Custom…"})]})]}),p&&f("div",{className:"space-y-1",children:[o("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Cron expression (5-field POSIX)"}),o("input",{type:"text",value:e,onChange:h=>t(h.target.value),disabled:r,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"}),f("p",{className:"text-[10px] text-foreground-subtle",children:["Format: ",o("span",{className:"font-mono",children:"minute hour day-of-month month day-of-week"})," · all times server-local"]})]}),o(ej,{cron:l,preview:d,loading:c.isFetching})]})}function ej({cron:e,preview:t,loading:n}){return n&&t===null?f("div",{className:"flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle",children:[o(Se,{className:"h-3 w-3 animate-spin"}),"Validating…"]}):t===null?null:t.ok?t.nextRuns.length===0?o("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."}):f("div",{className:"space-y-1",children:[o("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Next runs"}),o("ul",{className:"rounded border border-border bg-background/40 divide-y divide-border",children:t.nextRuns.map((r,s)=>f("li",{className:"flex items-center justify-between px-3 py-1.5 text-[11px]",children:[o("span",{className:"text-foreground tabular-nums",children:new Date(r).toLocaleString()}),o("span",{className:"text-foreground-subtle text-[10px] tabular-nums",children:tj(r)})]},`${r}-${s}`))})]}):o("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 tj(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 r=Math.floor(n/60);if(r<60)return`in ${r}m`;const s=Math.floor(r/60);return s<24?`in ${s}h`:`in ${Math.floor(s/24)}d`}function nj(e,t){const[n,r]=_(e),s=H(()=>e,[e]);return Y(()=>{const a=setTimeout(()=>r(s),t);return()=>clearTimeout(a)},[s,t]),n}const rj=[["backup","listDestinations"]];function oj({onCreateAt:e,onOpenRestoreWizard:t}){const{data:n,isLoading:r,isError:s}=ad(),a=n??[],[i,l]=_(null),c=u=>{l(p=>p===u?null:u)},d=cj();return r?o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading destinations…"}):s?o("div",{className:"text-xs text-danger",children:"Failed to load destinations"}):a.length===0?o("div",{className:"rounded-lg border border-border bg-surface px-4 py-8 text-center",children:o("p",{className:"text-xs text-foreground-subtle",children:"No `backups`-typed storage locations registered. Add one in Settings → Storage to begin."})}):o("div",{className:"rounded-lg border border-border bg-surface overflow-x-auto",children:f("table",{className:"w-full text-xs min-w-[720px]",children:[o("thead",{children:f("tr",{className:"text-foreground-subtle border-b border-border bg-background/40",children:[o("th",{className:"text-left px-3 py-2 font-medium w-6"}),o("th",{className:"text-left px-3 py-2 font-medium",children:"Destination"}),o("th",{className:"text-left px-3 py-2 font-medium w-20",children:"Enabled"}),o("th",{className:"text-left px-3 py-2 font-medium w-28",children:"Retention"}),o("th",{className:"text-left px-3 py-2 font-medium w-56",children:"Schedule"}),o("th",{className:"text-left px-3 py-2 font-medium w-44",children:"Last success"}),o("th",{className:"text-right px-3 py-2 font-medium w-44",children:"Actions"})]})}),o("tbody",{children:a.map(u=>{const p=d.get(u.id);return o(sj,{row:u,isOpen:i===u.id,onToggle:()=>c(u.id),onCreateAt:e,liveLastSuccessAt:p?.at,liveLastSuccessSizeBytes:p?.sizeBytes,...t?{onOpenRestoreWizard:t}:{}},u.id)})})]})})}function sj({row:e,isOpen:t,onToggle:n,onCreateAt:r,onOpenRestoreWizard:s,liveLastSuccessAt:a,liveLastSuccessSizeBytes:i}){const l=ke(),c=zb({onSuccess:()=>{l.invalidateQueries({queryKey:rj})}}),[d,u]=_(String(e.retentionCount));Y(()=>{u(String(e.retentionCount))},[e.retentionCount]);const[p,h]=_(!1),m=U(x=>{c.mutate({locationId:e.id,enabled:x,retentionCount:e.retentionCount,...e.label!==void 0?{label:e.label}:{},...e.cron!==void 0?{cron:e.cron}:{}})},[c,e.id,e.retentionCount,e.label,e.cron]),g=U(()=>{const x=Number.parseInt(d,10);if(Number.isNaN(x)||x<1){u(String(e.retentionCount));return}x!==e.retentionCount&&c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:x,...e.label!==void 0?{label:e.label}:{},...e.cron!==void 0?{cron:e.cron}:{}})},[c,d,e.id,e.enabled,e.retentionCount,e.label,e.cron]),b=U(x=>{c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:e.retentionCount,...e.label!==void 0?{label:e.label}:{},cron:x},{onSuccess:()=>{h(!1)}})},[c,e.id,e.enabled,e.retentionCount,e.label]);return f(me,{children:[f("tr",{className:"border-t border-border first:border-t-0 hover:bg-primary/5",children:[o("td",{className:"px-2 py-2",children:o("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?o(lt,{className:"h-3.5 w-3.5"}):o(wt,{className:"h-3.5 w-3.5"})})}),o("td",{className:"px-3 py-2",children:f("button",{onClick:n,className:"text-left hover:underline focus:outline-none",title:"View archives",children:[o("div",{className:"text-foreground font-medium",children:e.displayName}),f("div",{className:"flex items-center gap-1.5 mt-0.5",children:[o("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}),o("span",{className:"text-[10px] text-foreground-subtle font-mono",children:e.id})]})]})}),o("td",{className:"px-3 py-2",children:o("label",{className:"inline-flex items-center cursor-pointer",children:o("input",{type:"checkbox",className:"accent-primary",checked:e.enabled,disabled:c.isPending,onChange:x=>m(x.target.checked)})})}),o("td",{className:"px-3 py-2",children:o("input",{type:"number",min:1,max:1e3,value:d,disabled:c.isPending,onChange:x=>u(x.target.value),onBlur:g,onKeyDown:x=>{x.key==="Enter"&&x.target.blur(),x.key==="Escape"&&u(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"})}),o("td",{className:"px-3 py-2",children:o(aj,{cron:e.cron,nextRunAt:e.nextRunAt,onEdit:()=>h(!0),disabled:c.isPending})}),o("td",{className:"px-3 py-2 text-foreground-subtle",children:(()=>{const x=dj(a,e.lastSuccessAt),y=x===a?i:e.lastSuccessSizeBytes;return x!==void 0?o(uj,{at:x,sizeBytes:y}):o("span",{className:"italic",children:"Never"})})()}),o("td",{className:"px-3 py-2",children:o("div",{className:"flex items-center justify-end gap-1.5",children:e.triggerSupported&&f("button",{onClick:()=>r(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:[o(Et,{className:"h-3 w-3"}),"Create here"]})})})]}),t&&o("tr",{className:"border-t border-border bg-background/30",children:o("td",{colSpan:7,className:"px-4 py-3",children:o(WF,{destinationId:e.id,restoreSupported:e.restoreSupported,...s?{onOpenRestoreWizard:s}:{}})})}),p&&o(lj,{destinationName:e.displayName,currentCron:e.cron??"",onSave:b,onClose:()=>h(!1),saving:c.isPending,saveError:c.error instanceof Error?c.error.message:null})]})}function aj({cron:e,nextRunAt:t,onEdit:n,disabled:r}){const s=typeof e=="string"&&e.trim().length>0;return f("button",{type:"button",onClick:n,disabled:r,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:[f("div",{className:"flex items-center gap-1.5",children:[o(PR,{className:"h-3 w-3 text-foreground-subtle group-hover:text-foreground"}),o("span",{className:s?"font-mono text-foreground":"italic text-foreground-subtle",children:s?e:"Manual"})]}),s&&t!==void 0&&f("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:["next ",ij(t)]})]})}function ij(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 r=Math.floor(n/60);if(r<60)return`in ${r}m`;const s=Math.floor(r/60);return s<24?`in ${s}h`:`in ${Math.floor(s/24)}d`}function lj({destinationName:e,currentCron:t,onSave:n,onClose:r,saving:s,saveError:a}){const[i,l]=_(t);return o("tr",{children:o("td",{colSpan:7,className:"p-0",children:o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:r,children:f("div",{className:"w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl",onClick:c=>c.stopPropagation(),children:[f("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[f("div",{className:"space-y-0.5",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:"Schedule"}),f("p",{className:"text-xs text-foreground-subtle",children:["→ ",e]})]}),o("button",{onClick:r,className:"text-foreground-subtle hover:text-foreground",title:"Close",children:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"p-4",children:[o(JF,{value:i,onChange:l,disabled:s}),a!==null&&o("div",{className:"mt-3 rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger",children:a})]}),f("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:[o("button",{onClick:r,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"}),o("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 cj(){const{map:e}=Kc(Ne.BackupCompleted,t=>t.destinationId);return H(()=>{const t=new Map;for(const[n,r]of e)t.set(n,{at:Date.now(),sizeBytes:r.sizeMB*1024*1024});return t},[e])}function dj(e,t){return e===void 0?t:t===void 0||e>t?e:t}function uj({at:e,sizeBytes:t}){const n=pj(e),r=H(()=>new Date(e).toLocaleString(),[e]);return f("span",{title:r,className:"text-foreground tabular-nums",children:[n,t!==void 0&&f("span",{className:"ml-1 text-foreground-subtle",children:["· ",It(t)]})]})}function pj(e){const[,t]=_(0);return Y(()=>{const n=setInterval(()=>t(r=>r+1),3e4);return()=>clearInterval(n)},[]),fj(e)}function fj(e){const t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const s=Math.floor(r/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 hj=[["backup","list"]];function mj({initialDestinationId:e,initialArchiveId:t,onClose:n,onScheduled:r}){const s=ke(),[a,i]=_(e&&t?2:1),[l,c]=_(e),[d,u]=_(t),[p,h]=_(new Set),{data:m}=ad(),g=m??[],{data:b,isLoading:x}=id({destinationId:l??""},{enabled:!!l}),y=b??[];Y(()=>{if(l!==void 0)return;const z=g.filter(P=>P.restoreSupported);z.length===1&&c(z[0].id)},[l,g]);const{data:w}=Rb({destinationId:l??"",backupId:d??""},{enabled:!!l&&!!d}),v=H(()=>w?.locations??[],[w]);Y(()=>{v.length!==0&&h(z=>z.size===0?new Set(v):z)},[v]);const N=Ob({onSuccess:()=>{s.invalidateQueries({queryKey:hj}),r(),n()}}),k=z=>{h(P=>{const B=new Set(P);return B.has(z)?B.delete(z):B.add(z),B})},C=!!l&&!!d,E=p.size>0,I=C&&E&&!N.isPending,A=()=>{!l||!d||N.mutate({destinationId:l,backupId:d,locations:[...p]})};return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:n,children:f("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:z=>z.stopPropagation(),children:[f("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[f("div",{className:"space-y-0.5",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:"Restore Backup"}),f("p",{className:"text-xs text-foreground-subtle",children:["Step ",a," of 3 — ",a===1?"pick source":a===2?"pick locations":"confirm"]})]}),o("button",{onClick:n,className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-4 w-4"})})]}),a===1&&o(gj,{destinations:g,destinationId:l,onPickDestination:z=>{c(z),u(void 0),h(new Set)},archives:y,archivesLoading:x,archiveId:d,onPickArchive:u}),a===2&&o(bj,{locations:v,picked:p,onToggle:k}),a===3&&o(xj,{destinationName:g.find(z=>z.id===l)?.displayName??l??"",archive:y.find(z=>z.id===d),picked:[...p]}),f("div",{className:"flex justify-between gap-2 border-t border-border px-4 py-3",children:[o("div",{children:a>1&&f("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:[o(Qd,{className:"h-3 w-3"}),"Back"]})}),f("div",{className:"flex items-center gap-2",children:[o("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?f("button",{disabled:a===1&&!C||a===2&&!E,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",o(yR,{className:"h-3 w-3"})]}):f("button",{onClick:A,disabled:!I,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?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(kt,{className:"h-3.5 w-3.5"}),"Schedule Restore"]})]})]})]})})}function gj({destinations:e,destinationId:t,onPickDestination:n,archives:r,archivesLoading:s,archiveId:a,onPickArchive:i}){const l=e.filter(c=>c.restoreSupported);return f("div",{className:"p-4 space-y-3",children:[f("div",{className:"space-y-1.5",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Destination"}),f("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:[o("option",{value:"",disabled:!0,children:"Select destination…"}),l.map(c=>f("option",{value:c.id,children:[c.displayName," (",c.kind,")"]},c.id))]})]}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Archive"}),!t&&o("div",{className:"text-xs text-foreground-subtle italic",children:"Pick a destination first."}),t&&s&&o("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Reading archives…"}),t&&!s&&r.length===0&&o("div",{className:"text-xs text-foreground-subtle italic",children:"No archives available at this destination."}),t&&r.length>0&&o("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:r.map(c=>{const d=a===c.id;return f("label",{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${d?"bg-primary/10":"hover:bg-primary/5"}`,children:[f("div",{className:"flex items-center gap-2",children:[o("input",{type:"radio",name:"archive",checked:d,onChange:()=>i(c.id),className:"accent-primary"}),f("div",{children:[o("div",{className:"font-medium text-foreground",children:c.label??c.id}),o("div",{className:"text-[10px] text-foreground-subtle",children:new Date(c.createdAt).toLocaleString()})]})]}),o("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:It(c.sizeBytes)})]},c.id)})})]})]})}function bj({locations:e,picked:t,onToggle:n}){return e.length===0?o("div",{className:"p-4",children:o("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."})}):f("div",{className:"p-4 space-y-3",children:[o("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."}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Apply"}),o("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:e.map(r=>f("label",{className:"flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer",children:[o("input",{type:"checkbox",checked:t.has(r),onChange:()=>n(r),className:"accent-primary"}),o("span",{className:"font-mono text-foreground",children:r}),o("span",{className:"ml-auto text-[10px] text-foreground-subtle",children:vj(r)})]},r))})]})]})}function xj({destinationName:e,archive:t,picked:n}){return f("div",{className:"p-4 space-y-3 text-xs",children:[o("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."}),f("dl",{className:"space-y-1.5",children:[o(As,{term:"Destination",value:e}),o(As,{term:"Archive",value:t?.label??t?.id??"—"}),t&&o(As,{term:"Created",value:`${new Date(t.createdAt).toLocaleString()} · ${It(t.sizeBytes)}`}),o(As,{term:"Locations",value:n.length>0?n.join(", "):"— (full archive)"})]})]})}function As({term:e,value:t}){return f("div",{className:"flex justify-between gap-3",children:[o("dt",{className:"text-foreground-subtle",children:e}),o("dd",{className:"text-foreground font-mono text-right truncate",children:t})]})}const yj={db:"Database",addons:"Addon configs","addons-data":"Addon data",tls:"TLS certificates",cache:"Cache",data:"Top-level data"};function vj(e){return yj[e]??""}const wj=[["backup","list"]],Nj=[["backup","listLocations"]];function kj(){const e=ke(),t=nt(),{data:n}=Lb(),r=Tb({onSuccess:()=>{e.invalidateQueries({queryKey:wj}),e.invalidateQueries({queryKey:[["backup","listDestinations"]]}),e.invalidateQueries({queryKey:[["backup","listArchives"]]})}}),s=hb(),[a,i]=_(null),[l,c]=_(null),[d,u]=_(!1),[p,h]=_(!1),[m,g]=_(!1),b=async()=>{await t({title:"Restart server now?",message:"Active connections will drop and the apply-backup hook will run before boot.",confirmLabel:"Restart",variant:"warning"})&&s.mutate({confirm:!0})};return f(tt,{children:[f("div",{className:"flex items-center justify-end gap-2 flex-wrap",children:[f("button",{onClick:()=>u(!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:[o(kt,{className:"h-3.5 w-3.5"}),"Restore…"]}),f("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:[o(Et,{className:"h-3.5 w-3.5"}),"Add destination"]})]}),p&&o("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:f("div",{className:"flex items-center justify-between gap-3",children:[f("div",{className:"flex items-center gap-2",children:[o(kt,{className:"h-3.5 w-3.5"}),o("span",{children:"Restore scheduled. Restart the server to apply."})]}),f("button",{onClick:()=>{b()},disabled:s.isPending,className:"inline-flex items-center gap-1.5 rounded bg-amber-500/20 px-2 py-1 font-medium text-amber-800 dark:text-amber-200 hover:bg-amber-500/30 disabled:opacity-50",children:[s.isPending?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(kt,{className:"h-3.5 w-3.5"}),"Restart Now"]})]})}),o(oj,{onCreateAt:x=>i(x),onOpenRestoreWizard:x=>c(x)}),a&&o(Sj,{destination:a,locations:n??[],onClose:()=>i(null),onSubmit:(x,y)=>{r.mutate({destinations:[a.id],locations:x,label:y||void 0},{onSuccess:()=>{i(null),e.invalidateQueries({queryKey:Nj})}})},submitting:r.isPending}),(l||d)&&o(mj,{...l?{initialDestinationId:l.destinationId,initialArchiveId:l.archiveId}:{},onClose:()=>{c(null),u(!1)},onScheduled:()=>h(!0)}),m&&o(Gv,{initialType:"backups",onClose:()=>g(!1),onCreated:()=>{g(!1),e.invalidateQueries({queryKey:[["backup","listDestinations"]]})}})]})}function Sj({destination:e,locations:t,onClose:n,onSubmit:r,submitting:s}){const a=t.filter(p=>p.present),[i,l]=_(""),[c,d]=_(()=>new Set(a.map(p=>p.name))),u=p=>{d(h=>{const m=new Set(h);return m.has(p)?m.delete(p):m.add(p),m})};return o("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:n,children:f("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:p=>p.stopPropagation(),children:[f("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[f("div",{className:"space-y-0.5",children:[o("h2",{className:"text-sm font-semibold text-foreground",children:"Create Backup"}),f("p",{className:"text-xs text-foreground-subtle",children:["→ ",e.displayName]})]}),o("button",{onClick:n,className:"text-foreground-subtle hover:text-foreground",children:o(Fe,{className:"h-4 w-4"})})]}),f("div",{className:"p-4 space-y-3",children:[f("div",{className:"space-y-1",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Label (optional)"}),o("input",{type:"text",value:i,onChange:p=>l(p.target.value),placeholder:"pre-upgrade",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),f("div",{className:"space-y-1.5",children:[o("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Include"}),f("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:[a.length===0&&o("div",{className:"px-3 py-2 text-xs text-foreground-subtle italic",children:"Nothing to back up."}),a.map(p=>f("label",{className:"flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer",children:[f("div",{className:"flex items-center gap-2",children:[o("input",{type:"checkbox",checked:c.has(p.name),onChange:()=>u(p.name),className:"accent-primary"}),o("span",{className:"font-mono text-foreground",children:p.name})]}),f("div",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[It(p.sizeBytes)," · ",p.fileCount," files"]})]},p.name))]})]})]}),f("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:[o("button",{onClick:n,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),f("button",{onClick:()=>r(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?o(Se,{className:"h-3.5 w-3.5 animate-spin"}):o(V0,{className:"h-3.5 w-3.5"}),s?"Creating…":"Create"]})]})]})})}function Cj(){return o("div",{className:"flex flex-col p-4",children:o(ri,{tabs:[{id:"storage",label:"Storage",icon:ia,content:o(QF,{})},{id:"backup",label:"Backup",icon:V0,content:o(kj,{})}]})})}function Mj(){const{data:e,isLoading:t}=zn(void 0,{staleTime:3e4}),n=(e??[]).find(s=>s.isHub&&s.isOnline),r=n?.addons.map(s=>s.id)??[];return o(tt,{children:t?o("div",{className:"text-muted-foreground text-sm py-12 text-center",children:"Loading hub topology…"}):n?r.length===0?o("div",{className:"text-muted-foreground text-sm py-12 text-center",children:"No addons installed on the hub yet."}):o(to,{nodeId:n.id,addonIds:r,level:"global"}):f("div",{className:"flex flex-col items-center justify-center text-muted-foreground text-sm gap-2 py-12",children:[o(Jt,{className:"h-8 w-8 opacity-30"}),o("p",{children:"No online hub node found."}),o("p",{className:"text-xs",children:"Settings will appear once the hub is reachable."})]})})}function Ej(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,r)=>{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{r(new Error(`HTTP ${s.status}`));return}s.status>=200&&s.status<300?n(a):r(new Error(a.error??`HTTP ${s.status}`))}),s.addEventListener("error",()=>r(new Error("Network error during upload"))),s.addEventListener("abort",()=>r(new Error("Upload aborted"))),s.send(t)})}function Ij({nodeId:e,addons:t,isHub:n}){const r=ke(),s=nt(),[a,i]=_(null),[l,c]=_(null),[d,u]=_(!1),[p,h]=_(null),[m,g]=_(0),b=te(null),x=Ba(),y=Dx(),w=Bx({nodeId:e}),v=w.data??[],N=new Map(t.map(P=>[P.id,P.capabilities])),k=v.length>0?v.map(P=>({id:P.id,status:P.status,capabilities:N.get(P.id)??[],version:P.version,packageName:P.packageName})):t.map(P=>({id:P.id,status:P.status,capabilities:P.capabilities,version:void 0,packageName:void 0})),C=()=>{r.invalidateQueries({queryKey:[["nodes","topology"]]}),w.refetch()},E=async P=>{i(P);try{await x.mutateAsync({nodeId:e,addonId:P}),C()}catch(B){console.error("Failed to restart addon:",B)}finally{i(null)}},I=async P=>{if(await s({title:"Uninstall addon",message:`Remove "${P}" from ${e}? The addon directory will be deleted on disk.`,confirmLabel:"Uninstall",variant:"danger"})){c(P);try{await y.mutateAsync({nodeId:e,addonId:P}),C()}catch(R){console.error("Failed to uninstall addon:",R)}finally{c(null)}}},z=f("div",{className:"flex items-center gap-2 mb-2",children:[o("input",{ref:b,type:"file",accept:".tgz,.tar.gz",className:"hidden",onChange:async P=>{const B=P.target.files?.[0];if(B){P.target.value="",h(null),u(!0),g(0);try{const R=localStorage.getItem("camstack_admin_token");await Ej({file:B,nodeId:e,token:R,onProgress:g}),C()}catch(R){h(R instanceof Error?R.message:String(R))}finally{u(!1),g(0)}}}}),f("button",{onClick:()=>b.current?.click(),disabled:d,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:[d?o(Se,{className:"h-3 w-3 animate-spin"}):o(Xa,{className:"h-3 w-3"}),d?`Uploading… ${m}%`:"Upload addon (.tgz)"]}),d&&o("div",{className:"flex-1 h-1 rounded-full bg-muted overflow-hidden max-w-[140px]",children:o("div",{className:"h-full bg-primary transition-all",style:{width:`${m}%`}})}),p&&o("span",{className:"text-[10px] text-destructive",children:p})]});return k.length===0?f("div",{children:[z,o("div",{className:"py-4 text-xs text-muted-foreground text-center",children:w.isLoading?"Loading addons…":"No addons on this node"})]}):f("div",{children:[z,f("table",{className:"w-full text-xs",children:[o("thead",{children:f("tr",{className:"text-muted-foreground text-left",children:[o("th",{className:"py-2 font-medium",children:"Addon"}),o("th",{className:"py-2 font-medium",children:"Version"}),o("th",{className:"py-2 font-medium",children:"Capabilities"}),o("th",{className:"py-2 font-medium",children:"Status"}),o("th",{className:"py-2 font-medium w-16"})]})}),o("tbody",{children:k.map(P=>f("tr",{className:"border-t border-border/50",children:[f("td",{className:"py-2 font-medium",children:[o("div",{children:P.id}),P.packageName&&o("div",{className:"text-[9px] text-muted-foreground",children:P.packageName})]}),o("td",{className:"py-2 text-muted-foreground",children:P.version??"—"}),o("td",{className:"py-2",children:o("div",{className:"flex flex-wrap gap-1",children:P.capabilities.length>0?P.capabilities.map(B=>o("span",{className:"text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400",children:B},B)):o("span",{className:"text-muted-foreground",children:"—"})})}),o("td",{className:"py-2",children:o("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${P.status==="running"?"bg-success/10 text-success":P.status==="error"?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground"}`,children:P.status})}),o("td",{className:"py-2",children:f("div",{className:"flex items-center gap-1 justify-end",children:[o("button",{onClick:()=>E(P.id),disabled:a===P.id||l===P.id,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:`Restart ${P.id}`,children:o(kt,{className:`h-3 w-3 ${a===P.id?"animate-spin":""}`})}),o("button",{onClick:()=>I(P.id),disabled:a===P.id||l===P.id,className:"p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50",title:`Uninstall ${P.id}`,children:l===P.id?o(Se,{className:"h-3 w-3 animate-spin"}):o(Ze,{className:"h-3 w-3"})})]})})]},P.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 Pj({state:e}){return o("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e==="running"?"bg-success/10 text-success":e==="crashed"?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground"}`,children:e})}const _j=["trace","debug","info","warn","error"];function $j({proc:e,nodeId:t,defaultExpanded:n,activePanel:r,onTogglePanel:s}){const a=e.services??[],i=a.length===1,[l,c]=_(i||n),[d,u]=_(null),[p,h]=_("info"),m=e.name.includes("(core)"),g=Ba(),b=Tx(),x=zx(),y=async N=>{u(N);try{await g.mutateAsync({nodeId:t,addonId:N})}catch(k){console.error("Failed to restart addon:",k)}finally{u(null)}},w=async()=>{u(e.name);try{await b.mutateAsync({nodeId:t,processName:e.name})}catch(N){console.error("Failed to restart process:",N)}finally{u(null)}},v=async N=>{const k=`${t}/${e.name}`;try{await x.mutateAsync({nodeId:k,level:N}),h(N)}catch(C){console.error("Failed to set log level:",C)}};return f("div",{className:"border border-border/50 rounded-lg overflow-hidden",children:[f("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?o("span",{className:"h-3 w-3 shrink-0"}):l?o(lt,{className:"h-3 w-3 text-muted-foreground shrink-0"}):o(wt,{className:"h-3 w-3 text-muted-foreground shrink-0"}),m?o(hn,{className:"h-3.5 w-3.5 text-primary shrink-0"}):o(Ka,{className:"h-3.5 w-3.5 text-amber-500 shrink-0"}),o("span",{className:"text-xs font-semibold flex-1",children:e.name}),f("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:["PID ",e.pid]}),o(Pj,{state:e.state}),f("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[e.cpuPercent,"% CPU"]}),o("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:It(e.memoryRss)}),o("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:Aj(e.uptimeSeconds)}),!m&&f("div",{className:"flex items-center gap-1",onClick:N=>N.stopPropagation(),children:[f(bg,{children:[o(xg,{className:"text-[9px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors font-mono",title:"Set log level",children:p}),o(yg,{align:"end",className:"min-w-[70px] py-0.5",children:_j.map(N=>o(vg,{onClick:()=>v(N),className:`h-auto px-2 py-1 text-[10px] font-mono ${N===p?"text-primary font-semibold":""}`,children:N},N))})]}),o("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:o(kt,{className:`h-3 w-3 ${d===e.name?"animate-spin":""}`})})]})]}),l&&a.length>0&&o("div",{className:"divide-y divide-border/30",children:a.map(N=>f("div",{children:[f("div",{className:"flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors",children:[o("div",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${N.status==="running"?"bg-success":"bg-muted-foreground/30"}`}),o("span",{className:"text-xs font-medium flex-1 min-w-0 truncate",children:N.addonId}),N.capabilities.length>0&&f("div",{className:"flex gap-1 flex-shrink-0",children:[N.capabilities.slice(0,3).map(k=>o("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&&f("span",{className:"text-[9px] text-muted-foreground",children:["+",N.capabilities.length-3]})]}),f("div",{className:"flex items-center gap-1 shrink-0",children:[o("button",{onClick:()=>s(N.addonId,"logs"),className:`p-0.5 rounded transition-colors ${r?.addonId===N.addonId&&r.type==="logs"?"bg-primary/10 text-primary":"hover:bg-muted text-muted-foreground hover:text-foreground"}`,title:`Show logs for ${N.addonId}`,children:o(at,{className:"h-3 w-3"})}),o("button",{onClick:()=>s(N.addonId,"events"),className:`p-0.5 rounded transition-colors ${r?.addonId===N.addonId&&r.type==="events"?"bg-primary/10 text-primary":"hover:bg-muted text-muted-foreground hover:text-foreground"}`,title:`Show events for ${N.addonId}`,children:o(Za,{className:"h-3 w-3"})}),o("button",{onClick:()=>y(N.addonId),disabled:d===N.addonId,className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:`Restart ${N.addonId}`,children:o(kt,{className:`h-3 w-3 ${d===N.addonId?"animate-spin":""}`})})]})]}),r?.addonId===N.addonId&&r.type==="logs"&&o("div",{className:"border-t border-border/40 bg-muted/5",children:o(tn,{addonId:N.addonId,agentId:t,maxHeight:"max-h-48",showFilters:!1,onClose:()=>s(N.addonId,"logs")})}),r?.addonId===N.addonId&&r.type==="events"&&o("div",{className:"border-t border-border/40 bg-muted/5",children:o(br,{addonId:N.addonId,category:"addon.*",maxHeight:"max-h-48",onClose:()=>s(N.addonId,"events")})})]},N.addonId))}),l&&a.length===0&&o("div",{className:"px-3 py-2 pl-9 text-[10px] text-muted-foreground",children:"No services"})]})}function Dj({nodeId:e,processes:t}){const[n,r]=_(null),s=(a,i)=>{r(l=>l?.addonId===a&&l.type===i?null:{addonId:a,type:i})};return t.length===0?o("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No processes on this node"}):o("div",{className:"space-y-2 py-1",children:t.map((a,i)=>o($j,{proc:a,nodeId:e,defaultExpanded:i===0,activePanel:n,onTogglePanel:s},a.name))})}function Tj(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 Lj(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function Rj({nodeId:e}){const t=ke(),n=nt(),[r,s]=_("all"),a=Gr("metrics.node-processes-snapshot",k=>k.nodeId===e),{data:i}=Ex({nodeId:e},{staleTime:6e4}),l=a?.processes??i,c=H(()=>l?[...l]:[],[l]),d=H(()=>r==="ghost"?c.filter(k=>k.classification==="ghost"):c,[c,r]),u=H(()=>{const k=c.filter(E=>E.classification==="ghost"),C=new Map;for(const E of k)C.has(E.ppid)||C.set(E.ppid,[]),C.get(E.ppid).push(E);return[...C.entries()].filter(([,E])=>E.length>1).map(([E,I])=>({ppid:E,children:I})).sort((E,I)=>I.children.length-E.children.length)},[c]),p=Ix({onSettled:()=>{t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]})}}),h=H(()=>{const k=new Map;for(const C of c)k.set(C.pid,C.classification);return k},[c]),m=async(k,C)=>{if(k.classification==="root"||k.classification==="system")return;const E=k.classification==="ghost"?"ghost":k.addonId??"process",I=C?"SIGKILL":"SIGTERM";await n({title:`Send ${I}?`,message:`Target pid ${k.pid} (${E}) on node ${e}.`,confirmLabel:`Send ${I}`,variant:"danger"})&&p.mutate({nodeId:e,pid:k.pid,force:C})},g=async(k,C)=>{try{await p.mutateAsync({nodeId:e,pid:k,force:C})}catch{}},b=async k=>{const C=h.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(I=>g(I.pid,!1))]),t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}))},x=async()=>{const k=c.filter(E=>E.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(E=>g(E.pid,!0))),t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}))},y=c.filter(k=>k.classification==="ghost").length,w=c.filter(k=>k.classification==="managed").length,v=c.filter(k=>k.classification==="root").length,N=c.filter(k=>k.classification==="system").length;return f("div",{className:"space-y-4",children:[f("div",{className:"flex items-start justify-between gap-4",children:[f("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."]}),f("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:[o(ct,{className:"h-3 w-3"})," Refresh"]})]}),f("div",{className:"grid grid-cols-4 gap-3",children:[f("div",{className:"rounded-lg border border-border p-3",children:[o("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Root"}),o("div",{className:"text-xl font-semibold text-foreground",children:v})]}),f("div",{className:"rounded-lg border border-border p-3",children:[o("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Managed"}),o("div",{className:"text-xl font-semibold text-foreground",children:w})]}),f("div",{className:"rounded-lg border border-border p-3",children:[o("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"System"}),o("div",{className:"text-xl font-semibold text-foreground",children:N})]}),f("div",{className:`rounded-lg border p-3 ${y>0?"border-destructive/40 bg-destructive/5":"border-border"}`,children:[f("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle flex items-center gap-1",children:[y>0&&o(vs,{className:"h-3 w-3 text-destructive"})," Ghosts"]}),o("div",{className:`text-xl font-semibold ${y>0?"text-destructive":"text-foreground"}`,children:y})]})]}),u.length>0&&f("div",{className:"rounded-lg border border-amber-500/40 bg-amber-500/5 p-3",children:[f("div",{className:"flex items-center gap-1 text-[11px] font-semibold text-amber-400 mb-2",children:[o(it,{className:"h-3 w-3"})," Recurring ghost parents (",u.length,")"]}),o("div",{className:"space-y-1.5",children:u.map(k=>f("div",{className:"text-[11px] text-foreground flex items-center justify-between gap-2",children:[f("div",{className:"flex items-center gap-2",children:[f("span",{className:"font-mono text-foreground-subtle",children:["ppid ",k.ppid]}),f("span",{children:["→ ",k.children.length," ghost(s)"]})]}),f("button",{type:"button",disabled:p.isPending,onClick:()=>{b(k)},className:"inline-flex items-center gap-1 rounded border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] text-amber-400 hover:bg-amber-500/20 disabled:opacity-30",children:[o(vs,{className:"h-3 w-3"})," Kill parent + ",k.children.length]})]},k.ppid))})]}),f("div",{className:"flex items-center justify-between gap-2 text-[11px]",children:[f("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-foreground-subtle",children:"Filter:"}),f("button",{type:"button",className:`px-2 py-0.5 rounded ${r==="all"?"bg-primary text-primary-foreground":"border border-border text-foreground hover:bg-surface-hover"}`,onClick:()=>s("all"),children:["All (",c.length,")"]}),f("button",{type:"button",className:`px-2 py-0.5 rounded ${r==="ghost"?"bg-destructive text-destructive-foreground":"border border-border text-foreground hover:bg-surface-hover"}`,onClick:()=>s("ghost"),children:["Ghost only (",y,")"]})]}),y>0&&f("button",{type:"button",disabled:p.isPending,onClick:()=>{x()},className:"inline-flex items-center gap-1 rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive/20 disabled:opacity-30",children:[o(vs,{className:"h-3 w-3"})," Kill all ",y," ghost(s)"]})]}),o("div",{className:"rounded-lg border border-border overflow-hidden",children:f("table",{className:"w-full text-xs",children:[o("thead",{className:"bg-surface",children:f("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[o("th",{className:"text-left px-3 py-2",children:"Class"}),o("th",{className:"text-right px-3 py-2",children:"PID"}),o("th",{className:"text-right px-3 py-2",children:"PPID"}),o("th",{className:"text-left px-3 py-2",children:"Addon"}),o("th",{className:"text-left px-3 py-2",children:"Command"}),o("th",{className:"text-right px-3 py-2",children:"CPU%"}),o("th",{className:"text-right px-3 py-2",children:"RSS"}),o("th",{className:"text-right px-3 py-2",children:"Uptime"}),o("th",{className:"w-44"})]})}),f("tbody",{children:[d.length===0&&o("tr",{children:o("td",{colSpan:9,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:r==="ghost"?"No ghost processes detected.":"Scanning…"})}),d.map(k=>f("tr",{className:`border-t border-border ${k.classification==="ghost"?"bg-destructive/5":""}`,children:[o("td",{className:"px-3 py-2",children:o("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})}),o("td",{className:"px-3 py-2 text-right font-mono text-foreground",children:k.pid}),f("td",{className:"px-3 py-2 text-right font-mono text-foreground-subtle",children:[k.ppid,k.orphaned?" ⚠":""]}),o("td",{className:"px-3 py-2 text-foreground-subtle text-[11px]",children:k.addonId??"—"}),o("td",{className:"px-3 py-2 font-mono text-[10px] text-foreground-subtle break-all",children:Lj(k.command)}),o("td",{className:"px-3 py-2 text-right text-foreground",children:k.cpuPercent.toFixed(1)}),o("td",{className:"px-3 py-2 text-right text-foreground",children:It(k.memoryRssBytes)}),o("td",{className:"px-3 py-2 text-right text-foreground-subtle",children:Tj(k.uptimeSec)}),o("td",{className:"px-3 py-2 text-right",children:f("div",{className:"inline-flex gap-1",children:[f("button",{type:"button",disabled:p.isPending||k.classification==="root"||k.classification==="system",onClick:()=>{m(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:[o(Ze,{className:"h-3 w-3"})," Term"]}),f("button",{type:"button",disabled:p.isPending||k.classification==="root"||k.classification==="system",onClick:()=>{m(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:[o(vs,{className:"h-3 w-3"})," Kill"]})]})})]},k.pid))]})]})}),p.isError&&f("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive",children:["Kill failed: ",p.error instanceof Error?p.error.message:"unknown"]})]})}function Oj({nodeId:e,addonIds:t}){return t.length===0?o("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No addons on this node"}):o("div",{className:"w-full py-2",children:o(to,{nodeId:e,addonIds:t,level:"global"})})}function Bj({nodeId:e,addons:t}){const n=ke(),{data:r,isLoading:s}=Zx({nodeId:e}),a=H(()=>{const l=new Map;for(const c of t)for(const d of c.capabilities){const u=l.get(d)??[];u.push(c.id),l.set(d,u)}return[...l.entries()].sort(([c],[d])=>c.localeCompare(d)).map(([c,d])=>({capName:c,providers:d}))},[t]),i=Xx({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCapabilityBindings"]]})}});return a.length===0?o("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No capabilities on this node"}):f("table",{className:"w-full text-xs",children:[o("thead",{children:f("tr",{className:"text-muted-foreground text-left",children:[o("th",{className:"py-2 font-medium w-1/2",children:"Capability"}),o("th",{className:"py-2 font-medium",children:"Bound provider"})]})}),o("tbody",{children:a.map(({capName:l,providers:c})=>{const u=r?.[l]??c[0]??"",p=c.length===1;return f("tr",{className:"border-t border-border/50",children:[o("td",{className:"py-2 font-medium",children:l}),o("td",{className:"py-2",children:o("select",{value:u,onChange:h=>i.mutate({nodeId:e,capName:l,addonId:h.target.value}),disabled:p||i.isPending||s,className:"w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-60",title:p?"Only one provider installed — choice becomes available once a second addon registers this capability":void 0,children:c.map(h=>o("option",{value:h,children:h},h))})})]},l)})})]})}function zj(e){if(e==null)return"—";const t=Math.floor(e/1e3),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),s=Math.floor(t%3600/60);return n>0?`${n}d ${r}h ${s}m`:r>0?`${r}h ${s}m`:`${s}m`}function Fj(e){const[t,n]=_(!1),[r,s]=_(e.name),a=ke(),i=Rx({onSuccess:()=>{a.invalidateQueries({queryKey:[["nodes","topology"]]})}}),l=(e.localIps??[]).filter(p=>!p.includes(":")),c=(e.localIps??[]).filter(p=>p.includes(":")),d=async()=>{if(!r.trim()||r===e.name){n(!1);return}try{await i.mutateAsync({nodeId:e.nodeId,name:r.trim()}),n(!1)}catch(p){console.error("Rename failed:",p)}},u=[["Node ID",o("span",{className:"font-mono text-xs",children:e.nodeId})],["Display Name",t?f("div",{className:"flex items-center gap-1.5",children:[o("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:r,onChange:p=>s(p.target.value),onKeyDown:p=>{p.key==="Enter"&&d(),p.key==="Escape"&&n(!1)},disabled:i.isPending,autoFocus:!0}),o("button",{onClick:()=>void d(),disabled:i.isPending,className:"p-0.5 text-success hover:bg-success/10 rounded",title:"Save",children:o(_t,{className:"h-3.5 w-3.5"})}),o("button",{onClick:()=>n(!1),className:"p-0.5 text-muted-foreground hover:bg-muted rounded",title:"Cancel",children:o(Fe,{className:"h-3.5 w-3.5"})})]}):f("div",{className:"flex items-center gap-1.5",children:[o("span",{className:"text-xs",children:e.name}),!e.isHub&&o("button",{onClick:()=>{s(e.name),n(!0)},className:"p-0.5 text-muted-foreground hover:text-primary rounded",title:"Rename",children:o(eo,{className:"h-3 w-3"})})]})],["Hostname",o("span",{className:"text-xs",children:e.hostname})],["Role",e.isHub?o("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium",children:"Hub"}):o("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium",children:"Agent"})],["Platform",f("span",{className:"text-xs",children:[e.platform," / ",e.arch]})],["CPU",f("span",{className:"text-xs",children:[e.cpuModel??"—"," (",e.cpuCores," cores)"]})],["Memory",o("span",{className:"text-xs",children:e.memoryMB>0?`${(e.memoryMB/1024).toFixed(1)} GB`:"—"})],["Uptime",o("span",{className:"text-xs",children:zj(e.uptime)})],["Engines",e.engines.length>0?o("div",{className:"flex flex-wrap gap-1",children:e.engines.map(p=>o("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:p},p))}):o("span",{className:"text-xs text-muted-foreground",children:"—"})]];return l.length>0&&u.push(["IPv4",o("div",{className:"flex flex-wrap gap-1.5",children:l.map((p,h)=>o("span",{className:"font-mono text-xs px-1.5 py-0.5 rounded bg-muted",children:p},`${p}-${h}`))})]),c.length>0&&u.push(["IPv6",o("div",{className:"flex flex-wrap gap-1.5",children:c.map((p,h)=>o("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]",title:p,children:p},`${p}-${h}`))})]),o("div",{className:"py-2",children:o("table",{className:"w-full text-sm",children:o("tbody",{children:u.map(([p,h],m)=>f("tr",{className:m%2===0?"bg-muted/20":"",children:[o("td",{className:"py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap",children:p}),o("td",{className:"py-1.5 px-2",children:h})]},p))})})})}function jj({node:e}){const[t,n]=_("info"),r=e.processes??[],s=e.addons.map(a=>a.id);return e.isOnline?f("div",{className:"border border-border rounded-xl overflow-hidden",children:[f("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/30 border-b border-border",children:[o("div",{className:"w-2.5 h-2.5 rounded-full bg-success"}),o("span",{className:"text-sm font-semibold",children:e.name}),f("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=>o("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:a},a)),f("div",{className:"ml-auto flex gap-3 text-xs text-muted-foreground",children:[f("span",{className:"flex items-center gap-1",children:[o(bt,{className:"h-3 w-3"})," ",e.cpuPercent,"%"]}),f("span",{className:"flex items-center gap-1",children:[o(Xd,{className:"h-3 w-3"})," ",e.memoryPercent,"%"]})]})]}),o("div",{className:"flex border-b border-border px-4",children:["info","addons","forks","processes","settings","capabilities"].map(a=>o("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 (${r.length})`:a==="processes"?"Processes":a==="settings"?"Settings":"Capabilities"},a))}),f("div",{className:"px-4 py-2",children:[t==="info"&&o(Fj,{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"&&o(Ij,{nodeId:e.id,addons:e.addons,isHub:e.isHub}),t==="forks"&&o(Dj,{nodeId:e.id,processes:r}),t==="processes"&&o(Rj,{nodeId:e.id}),t==="settings"&&o(Oj,{nodeId:e.id,addonIds:s}),t==="capabilities"&&o(Bj,{nodeId:e.id,addons:e.addons})]})]}):f("div",{className:"border border-border rounded-xl overflow-hidden opacity-60",children:[f("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/30",children:[o("div",{className:"w-2.5 h-2.5 rounded-full bg-destructive"}),o("span",{className:"text-sm font-semibold",children:e.name}),f("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=>o("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:a},a)),o("span",{className:"ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:"offline"})]}),f("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 Vj({nodes:e}){const t=[...e].sort((n,r)=>n.isHub?-1:r.isHub?1:n.isOnline&&!r.isOnline?-1:!n.isOnline&&r.isOnline?1:n.name.localeCompare(r.name));return o("div",{className:"flex flex-col gap-4",children:t.map(n=>o(jj,{node:n},n.id))})}function We(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=We(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Hj={value:()=>{}};function oi(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Qs(n)}function Qs(e){this._=e}function qj(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Qs.prototype=oi.prototype={constructor:Qs,on:function(e,t){var n=this._,r=qj(e+"",n),s,a=-1,i=r.length;if(arguments.length<2){for(;++a<i;)if((s=(e=r[a]).type)&&(s=Uj(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=r[a]).type)n[s]=Rf(n[s],e.name,t);else if(t==null)for(s in n)n[s]=Rf(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 Qs(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,a;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],r=0,s=a.length;r<s;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,a=r.length;s<a;++s)r[s].value.apply(t,n)}};function Uj(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function Rf(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=Hj,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var ic="http://www.w3.org/1999/xhtml";const Of={svg:"http://www.w3.org/2000/svg",xhtml:ic,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function si(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Of.hasOwnProperty(t)?{space:Of[t],local:e}:e}function Qj(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ic&&t.documentElement.namespaceURI===ic?t.createElement(e):t.createElementNS(n,e)}}function Gj(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Wv(e){var t=si(e);return(t.local?Gj:Qj)(t)}function Kj(){}function ru(e){return e==null?Kj:function(){return this.querySelector(e)}}function Wj(e){typeof e!="function"&&(e=ru(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=r[s]=new Array(i),c,d,u=0;u<i;++u)(c=a[u])&&(d=e.call(c,c.__data__,u,a))&&("__data__"in c&&(d.__data__=c.__data__),l[u]=d);return new xt(r,this._parents)}function Yj(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Zj(){return[]}function Yv(e){return e==null?Zj:function(){return this.querySelectorAll(e)}}function Xj(e){return function(){return Yj(e.apply(this,arguments))}}function Jj(e){typeof e=="function"?e=Xj(e):e=Yv(e);for(var t=this._groups,n=t.length,r=[],s=[],a=0;a<n;++a)for(var i=t[a],l=i.length,c,d=0;d<l;++d)(c=i[d])&&(r.push(e.call(c,c.__data__,d,i)),s.push(c));return new xt(r,s)}function Zv(e){return function(){return this.matches(e)}}function Xv(e){return function(t){return t.matches(e)}}var eV=Array.prototype.find;function tV(e){return function(){return eV.call(this.children,e)}}function nV(){return this.firstElementChild}function rV(e){return this.select(e==null?nV:tV(typeof e=="function"?e:Xv(e)))}var oV=Array.prototype.filter;function sV(){return Array.from(this.children)}function aV(e){return function(){return oV.call(this.children,e)}}function iV(e){return this.selectAll(e==null?sV:aV(typeof e=="function"?e:Xv(e)))}function lV(e){typeof e!="function"&&(e=Zv(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=r[s]=[],c,d=0;d<i;++d)(c=a[d])&&e.call(c,c.__data__,d,a)&&l.push(c);return new xt(r,this._parents)}function Jv(e){return new Array(e.length)}function cV(){return new xt(this._enter||this._groups.map(Jv),this._parents)}function ma(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ma.prototype={constructor:ma,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 dV(e){return function(){return e}}function uV(e,t,n,r,s,a){for(var i=0,l,c=t.length,d=a.length;i<d;++i)(l=t[i])?(l.__data__=a[i],r[i]=l):n[i]=new ma(e,a[i]);for(;i<c;++i)(l=t[i])&&(s[i]=l)}function pV(e,t,n,r,s,a,i){var l,c,d=new Map,u=t.length,p=a.length,h=new Array(u),m;for(l=0;l<u;++l)(c=t[l])&&(h[l]=m=i.call(c,c.__data__,l,t)+"",d.has(m)?s[l]=c:d.set(m,c));for(l=0;l<p;++l)m=i.call(e,a[l],l,a)+"",(c=d.get(m))?(r[l]=c,c.__data__=a[l],d.delete(m)):n[l]=new ma(e,a[l]);for(l=0;l<u;++l)(c=t[l])&&d.get(h[l])===c&&(s[l]=c)}function fV(e){return e.__data__}function hV(e,t){if(!arguments.length)return Array.from(this,fV);var n=t?pV:uV,r=this._parents,s=this._groups;typeof e!="function"&&(e=dV(e));for(var a=s.length,i=new Array(a),l=new Array(a),c=new Array(a),d=0;d<a;++d){var u=r[d],p=s[d],h=p.length,m=mV(e.call(u,u&&u.__data__,d,r)),g=m.length,b=l[d]=new Array(g),x=i[d]=new Array(g),y=c[d]=new Array(h);n(u,p,b,x,y,m,t);for(var w=0,v=0,N,k;w<g;++w)if(N=b[w]){for(w>=v&&(v=w+1);!(k=x[v])&&++v<g;);N._next=k||null}}return i=new xt(i,r),i._enter=l,i._exit=c,i}function mV(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function gV(){return new xt(this._exit||this._groups.map(Jv),this._parents)}function bV(e,t,n){var r=this.enter(),s=this,a=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?a.remove():n(a),r&&s?r.merge(s).order():s}function xV(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,a=r.length,i=Math.min(s,a),l=new Array(s),c=0;c<i;++c)for(var d=n[c],u=r[c],p=d.length,h=l[c]=new Array(p),m,g=0;g<p;++g)(m=d[g]||u[g])&&(h[g]=m);for(;c<s;++c)l[c]=n[c];return new xt(l,this._parents)}function yV(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,a=r[s],i;--s>=0;)(i=r[s])&&(a&&i.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(i,a),a=i);return this}function vV(e){e||(e=wV);function t(p,h){return p&&h?e(p.__data__,h.__data__):!p-!h}for(var n=this._groups,r=n.length,s=new Array(r),a=0;a<r;++a){for(var i=n[a],l=i.length,c=s[a]=new Array(l),d,u=0;u<l;++u)(d=i[u])&&(c[u]=d);c.sort(t)}return new xt(s,this._parents).order()}function wV(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function NV(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function kV(){return Array.from(this)}function SV(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,a=r.length;s<a;++s){var i=r[s];if(i)return i}return null}function CV(){let e=0;for(const t of this)++e;return e}function MV(){return!this.node()}function EV(e){for(var t=this._groups,n=0,r=t.length;n<r;++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 IV(e){return function(){this.removeAttribute(e)}}function AV(e){return function(){this.removeAttributeNS(e.space,e.local)}}function PV(e,t){return function(){this.setAttribute(e,t)}}function _V(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function $V(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function DV(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 TV(e,t){var n=si(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?AV:IV:typeof t=="function"?n.local?DV:$V:n.local?_V:PV)(n,t))}function e1(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function LV(e){return function(){this.style.removeProperty(e)}}function RV(e,t,n){return function(){this.style.setProperty(e,t,n)}}function OV(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function BV(e,t,n){return arguments.length>1?this.each((t==null?LV:typeof t=="function"?OV:RV)(e,t,n??"")):Lr(this.node(),e)}function Lr(e,t){return e.style.getPropertyValue(t)||e1(e).getComputedStyle(e,null).getPropertyValue(t)}function zV(e){return function(){delete this[e]}}function FV(e,t){return function(){this[e]=t}}function jV(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function VV(e,t){return arguments.length>1?this.each((t==null?zV:typeof t=="function"?jV:FV)(e,t)):this.node()[e]}function t1(e){return e.trim().split(/^|\s+/)}function ou(e){return e.classList||new n1(e)}function n1(e){this._node=e,this._names=t1(e.getAttribute("class")||"")}n1.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 r1(e,t){for(var n=ou(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function o1(e,t){for(var n=ou(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function HV(e){return function(){r1(this,e)}}function qV(e){return function(){o1(this,e)}}function UV(e,t){return function(){(t.apply(this,arguments)?r1:o1)(this,e)}}function QV(e,t){var n=t1(e+"");if(arguments.length<2){for(var r=ou(this.node()),s=-1,a=n.length;++s<a;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?UV:t?HV:qV)(n,t))}function GV(){this.textContent=""}function KV(e){return function(){this.textContent=e}}function WV(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function YV(e){return arguments.length?this.each(e==null?GV:(typeof e=="function"?WV:KV)(e)):this.node().textContent}function ZV(){this.innerHTML=""}function XV(e){return function(){this.innerHTML=e}}function JV(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function eH(e){return arguments.length?this.each(e==null?ZV:(typeof e=="function"?JV:XV)(e)):this.node().innerHTML}function tH(){this.nextSibling&&this.parentNode.appendChild(this)}function nH(){return this.each(tH)}function rH(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function oH(){return this.each(rH)}function sH(e){var t=typeof e=="function"?e:Wv(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function aH(){return null}function iH(e,t){var n=typeof e=="function"?e:Wv(e),r=t==null?aH:typeof t=="function"?t:ru(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function lH(){var e=this.parentNode;e&&e.removeChild(this)}function cH(){return this.each(lH)}function dH(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function uH(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function pH(e){return this.select(e?uH:dH)}function fH(e){return arguments.length?this.property("__data__",e):this.node().__data__}function hH(e){return function(t){e.call(this,t,this.__data__)}}function mH(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function gH(e){return function(){var t=this.__on;if(t){for(var n=0,r=-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[++r]=a;++r?t.length=r:delete this.__on}}}function bH(e,t,n){return function(){var r=this.__on,s,a=hH(t);if(r){for(var i=0,l=r.length;i<l;++i)if((s=r[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},r?r.push(s):this.__on=[s]}}function xH(e,t,n){var r=mH(e+""),s,a=r.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,d=l.length,u;c<d;++c)for(s=0,u=l[c];s<a;++s)if((i=r[s]).type===u.type&&i.name===u.name)return u.value}return}for(l=t?bH:gH,s=0;s<a;++s)this.each(l(r[s],t,n));return this}function s1(e,t,n){var r=e1(e),s=r.CustomEvent;typeof s=="function"?s=new s(t,n):(s=r.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function yH(e,t){return function(){return s1(this,e,t)}}function vH(e,t){return function(){return s1(this,e,t.apply(this,arguments))}}function wH(e,t){return this.each((typeof t=="function"?vH:yH)(e,t))}function*NH(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,a=r.length,i;s<a;++s)(i=r[s])&&(yield i)}var a1=[null];function xt(e,t){this._groups=e,this._parents=t}function rs(){return new xt([[document.documentElement]],a1)}function kH(){return this}xt.prototype=rs.prototype={constructor:xt,select:Wj,selectAll:Jj,selectChild:rV,selectChildren:iV,filter:lV,data:hV,enter:cV,exit:gV,join:bV,merge:xV,selection:kH,order:yV,sort:vV,call:NV,nodes:kV,node:SV,size:CV,empty:MV,each:EV,attr:TV,style:BV,property:VV,classed:QV,text:YV,html:eH,raise:nH,lower:oH,append:sH,insert:iH,remove:cH,clone:pH,datum:fH,on:xH,dispatch:wH,[Symbol.iterator]:NH};function ht(e){return typeof e=="string"?new xt([[document.querySelector(e)]],[document.documentElement]):new xt([[e]],a1)}function SH(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Lt(e,t){if(e=SH(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.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 CH={passive:!1},To={capture:!0,passive:!1};function il(e){e.stopImmediatePropagation()}function Ar(e){e.preventDefault(),e.stopImmediatePropagation()}function i1(e){var t=e.document.documentElement,n=ht(e).on("dragstart.drag",Ar,To);"onselectstart"in t?n.on("selectstart.drag",Ar,To):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function l1(e,t){var n=e.document.documentElement,r=ht(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ar,To),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Ps=e=>()=>e;function lc(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:a,x:i,y:l,dx:c,dy:d,dispatch:u}){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:r,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:u}})}lc.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function MH(e){return!e.ctrlKey&&!e.button}function EH(){return this.parentNode}function IH(e,t){return t??{x:e.x,y:e.y}}function AH(){return navigator.maxTouchPoints||"ontouchstart"in this}function c1(){var e=MH,t=EH,n=IH,r=AH,s={},a=oi("start","drag","end"),i=0,l,c,d,u,p=0;function h(N){N.on("mousedown.drag",m).filter(r).on("touchstart.drag",x).on("touchmove.drag",y,CH).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(N,k){if(!(u||!e.call(this,N,k))){var C=v(this,t.call(this,N,k),N,k,"mouse");C&&(ht(N.view).on("mousemove.drag",g,To).on("mouseup.drag",b,To),i1(N.view),il(N),d=!1,l=N.clientX,c=N.clientY,C("start",N))}}function g(N){if(Ar(N),!d){var k=N.clientX-l,C=N.clientY-c;d=k*k+C*C>p}s.mouse("drag",N)}function b(N){ht(N.view).on("mousemove.drag mouseup.drag",null),l1(N.view,d),Ar(N),s.mouse("end",N)}function x(N,k){if(e.call(this,N,k)){var C=N.changedTouches,E=t.call(this,N,k),I=C.length,A,z;for(A=0;A<I;++A)(z=v(this,E,N,k,C[A].identifier,C[A]))&&(il(N),z("start",N,C[A]))}}function y(N){var k=N.changedTouches,C=k.length,E,I;for(E=0;E<C;++E)(I=s[k[E].identifier])&&(Ar(N),I("drag",N,k[E]))}function w(N){var k=N.changedTouches,C=k.length,E,I;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),E=0;E<C;++E)(I=s[k[E].identifier])&&(il(N),I("end",N,k[E]))}function v(N,k,C,E,I,A){var z=a.copy(),P=Lt(A||C,k),B,R,M;if((M=n.call(N,new lc("beforestart",{sourceEvent:C,target:h,identifier:I,active:i,x:P[0],y:P[1],dx:0,dy:0,dispatch:z}),E))!=null)return B=M.x-P[0]||0,R=M.y-P[1]||0,function D(T,L,O){var F=P,j;switch(T){case"start":s[I]=D,j=i++;break;case"end":delete s[I],--i;case"drag":P=Lt(O||L,k),j=i;break}z.call(T,N,new lc(T,{sourceEvent:L,subject:M,target:h,identifier:I,active:j,x:P[0]+B,y:P[1]+R,dx:P[0]-F[0],dy:P[1]-F[1],dispatch:z}),E)}}return h.filter=function(N){return arguments.length?(e=typeof N=="function"?N:Ps(!!N),h):e},h.container=function(N){return arguments.length?(t=typeof N=="function"?N:Ps(N),h):t},h.subject=function(N){return arguments.length?(n=typeof N=="function"?N:Ps(N),h):n},h.touchable=function(N){return arguments.length?(r=typeof N=="function"?N:Ps(!!N),h):r},h.on=function(){var N=a.on.apply(a,arguments);return N===a?h:N},h.clickDistance=function(N){return arguments.length?(p=(N=+N)*N,h):Math.sqrt(p)},h}function su(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function d1(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function os(){}var Lo=.7,ga=1/Lo,Pr="\\s*([+-]?\\d+)\\s*",Ro="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Yt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",PH=/^#([0-9a-f]{3,8})$/,_H=new RegExp(`^rgb\\(${Pr},${Pr},${Pr}\\)$`),$H=new RegExp(`^rgb\\(${Yt},${Yt},${Yt}\\)$`),DH=new RegExp(`^rgba\\(${Pr},${Pr},${Pr},${Ro}\\)$`),TH=new RegExp(`^rgba\\(${Yt},${Yt},${Yt},${Ro}\\)$`),LH=new RegExp(`^hsl\\(${Ro},${Yt},${Yt}\\)$`),RH=new RegExp(`^hsla\\(${Ro},${Yt},${Yt},${Ro}\\)$`),Bf={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};su(os,ar,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:zf,formatHex:zf,formatHex8:OH,formatHsl:BH,formatRgb:Ff,toString:Ff});function zf(){return this.rgb().formatHex()}function OH(){return this.rgb().formatHex8()}function BH(){return u1(this).formatHsl()}function Ff(){return this.rgb().formatRgb()}function ar(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=PH.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?jf(t):n===3?new st(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?_s(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?_s(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=_H.exec(e))?new st(t[1],t[2],t[3],1):(t=$H.exec(e))?new st(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=DH.exec(e))?_s(t[1],t[2],t[3],t[4]):(t=TH.exec(e))?_s(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=LH.exec(e))?qf(t[1],t[2]/100,t[3]/100,1):(t=RH.exec(e))?qf(t[1],t[2]/100,t[3]/100,t[4]):Bf.hasOwnProperty(e)?jf(Bf[e]):e==="transparent"?new st(NaN,NaN,NaN,0):null}function jf(e){return new st(e>>16&255,e>>8&255,e&255,1)}function _s(e,t,n,r){return r<=0&&(e=t=n=NaN),new st(e,t,n,r)}function zH(e){return e instanceof os||(e=ar(e)),e?(e=e.rgb(),new st(e.r,e.g,e.b,e.opacity)):new st}function cc(e,t,n,r){return arguments.length===1?zH(e):new st(e,t,n,r??1)}function st(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}su(st,cc,d1(os,{brighter(e){return e=e==null?ga:Math.pow(ga,e),new st(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Lo:Math.pow(Lo,e),new st(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new st(Zn(this.r),Zn(this.g),Zn(this.b),ba(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:Vf,formatHex:Vf,formatHex8:FH,formatRgb:Hf,toString:Hf}));function Vf(){return`#${Gn(this.r)}${Gn(this.g)}${Gn(this.b)}`}function FH(){return`#${Gn(this.r)}${Gn(this.g)}${Gn(this.b)}${Gn((isNaN(this.opacity)?1:this.opacity)*255)}`}function Hf(){const e=ba(this.opacity);return`${e===1?"rgb(":"rgba("}${Zn(this.r)}, ${Zn(this.g)}, ${Zn(this.b)}${e===1?")":`, ${e})`}`}function ba(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Zn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Gn(e){return e=Zn(e),(e<16?"0":"")+e.toString(16)}function qf(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Rt(e,t,n,r)}function u1(e){if(e instanceof Rt)return new Rt(e.h,e.s,e.l,e.opacity);if(e instanceof os||(e=ar(e)),!e)return new Rt;if(e instanceof Rt)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),a=Math.max(t,n,r),i=NaN,l=a-s,c=(a+s)/2;return l?(t===a?i=(n-r)/l+(n<r)*6:n===a?i=(r-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 Rt(i,l,c,e.opacity)}function jH(e,t,n,r){return arguments.length===1?u1(e):new Rt(e,t,n,r??1)}function Rt(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}su(Rt,jH,d1(os,{brighter(e){return e=e==null?ga:Math.pow(ga,e),new Rt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Lo:Math.pow(Lo,e),new Rt(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,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new st(ll(e>=240?e-240:e+120,s,r),ll(e,s,r),ll(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Rt(Uf(this.h),$s(this.s),$s(this.l),ba(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=ba(this.opacity);return`${e===1?"hsl(":"hsla("}${Uf(this.h)}, ${$s(this.s)*100}%, ${$s(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Uf(e){return e=(e||0)%360,e<0?e+360:e}function $s(e){return Math.max(0,Math.min(1,e||0))}function ll(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 au=e=>()=>e;function VH(e,t){return function(n){return e+n*t}}function HH(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function qH(e){return(e=+e)==1?p1:function(t,n){return n-t?HH(t,n,e):au(isNaN(t)?n:t)}}function p1(e,t){var n=t-e;return n?VH(e,n):au(isNaN(e)?t:e)}const xa=(function e(t){var n=qH(t);function r(s,a){var i=n((s=cc(s)).r,(a=cc(a)).r),l=n(s.g,a.g),c=n(s.b,a.b),d=p1(s.opacity,a.opacity);return function(u){return s.r=i(u),s.g=l(u),s.b=c(u),s.opacity=d(u),s+""}}return r.gamma=e,r})(1);function UH(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(a){for(s=0;s<n;++s)r[s]=e[s]*(1-a)+t[s]*a;return r}}function QH(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function GH(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,s=new Array(r),a=new Array(n),i;for(i=0;i<r;++i)s[i]=So(e[i],t[i]);for(;i<n;++i)a[i]=t[i];return function(l){for(i=0;i<r;++i)a[i]=s[i](l);return a}}function KH(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Qt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function WH(e,t){var n={},r={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=So(e[s],t[s]):r[s]=t[s];return function(a){for(s in n)r[s]=n[s](a);return r}}var dc=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,cl=new RegExp(dc.source,"g");function YH(e){return function(){return e}}function ZH(e){return function(t){return e(t)+""}}function f1(e,t){var n=dc.lastIndex=cl.lastIndex=0,r,s,a,i=-1,l=[],c=[];for(e=e+"",t=t+"";(r=dc.exec(e))&&(s=cl.exec(t));)(a=s.index)>n&&(a=t.slice(n,a),l[i]?l[i]+=a:l[++i]=a),(r=r[0])===(s=s[0])?l[i]?l[i]+=s:l[++i]=s:(l[++i]=null,c.push({i,x:Qt(r,s)})),n=cl.lastIndex;return n<t.length&&(a=t.slice(n),l[i]?l[i]+=a:l[++i]=a),l.length<2?c[0]?ZH(c[0].x):YH(t):(t=c.length,function(d){for(var u=0,p;u<t;++u)l[(p=c[u]).i]=p.x(d);return l.join("")})}function So(e,t){var n=typeof t,r;return t==null||n==="boolean"?au(t):(n==="number"?Qt:n==="string"?(r=ar(t))?(t=r,xa):f1:t instanceof ar?xa:t instanceof Date?KH:QH(t)?UH:Array.isArray(t)?GH:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?WH:Qt)(e,t)}var Qf=180/Math.PI,uc={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function h1(e,t,n,r,s,a){var i,l,c;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,c/=l),e*r<t*n&&(e=-e,t=-t,c=-c,i=-i),{translateX:s,translateY:a,rotate:Math.atan2(t,e)*Qf,skewX:Math.atan(c)*Qf,scaleX:i,scaleY:l}}var Ds;function XH(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?uc:h1(t.a,t.b,t.c,t.d,t.e,t.f)}function JH(e){return e==null||(Ds||(Ds=document.createElementNS("http://www.w3.org/2000/svg","g")),Ds.setAttribute("transform",e),!(e=Ds.transform.baseVal.consolidate()))?uc:(e=e.matrix,h1(e.a,e.b,e.c,e.d,e.e,e.f))}function m1(e,t,n,r){function s(d){return d.length?d.pop()+" ":""}function a(d,u,p,h,m,g){if(d!==p||u!==h){var b=m.push("translate(",null,t,null,n);g.push({i:b-4,x:Qt(d,p)},{i:b-2,x:Qt(u,h)})}else(p||h)&&m.push("translate("+p+t+h+n)}function i(d,u,p,h){d!==u?(d-u>180?u+=360:u-d>180&&(d+=360),h.push({i:p.push(s(p)+"rotate(",null,r)-2,x:Qt(d,u)})):u&&p.push(s(p)+"rotate("+u+r)}function l(d,u,p,h){d!==u?h.push({i:p.push(s(p)+"skewX(",null,r)-2,x:Qt(d,u)}):u&&p.push(s(p)+"skewX("+u+r)}function c(d,u,p,h,m,g){if(d!==p||u!==h){var b=m.push(s(m)+"scale(",null,",",null,")");g.push({i:b-4,x:Qt(d,p)},{i:b-2,x:Qt(u,h)})}else(p!==1||h!==1)&&m.push(s(m)+"scale("+p+","+h+")")}return function(d,u){var p=[],h=[];return d=e(d),u=e(u),a(d.translateX,d.translateY,u.translateX,u.translateY,p,h),i(d.rotate,u.rotate,p,h),l(d.skewX,u.skewX,p,h),c(d.scaleX,d.scaleY,u.scaleX,u.scaleY,p,h),d=u=null,function(m){for(var g=-1,b=h.length,x;++g<b;)p[(x=h[g]).i]=x.x(m);return p.join("")}}}var eq=m1(XH,"px, ","px)","deg)"),tq=m1(JH,", ",")",")"),nq=1e-12;function Gf(e){return((e=Math.exp(e))+1/e)/2}function rq(e){return((e=Math.exp(e))-1/e)/2}function oq(e){return((e=Math.exp(2*e))-1)/(e+1)}const Gs=(function e(t,n,r){function s(a,i){var l=a[0],c=a[1],d=a[2],u=i[0],p=i[1],h=i[2],m=u-l,g=p-c,b=m*m+g*g,x,y;if(b<nq)y=Math.log(h/d)/t,x=function(E){return[l+E*m,c+E*g,d*Math.exp(t*E*y)]};else{var w=Math.sqrt(b),v=(h*h-d*d+r*b)/(2*d*n*w),N=(h*h-d*d-r*b)/(2*h*n*w),k=Math.log(Math.sqrt(v*v+1)-v),C=Math.log(Math.sqrt(N*N+1)-N);y=(C-k)/t,x=function(E){var I=E*y,A=Gf(k),z=d/(n*w)*(A*oq(t*I+k)-rq(k));return[l+z*m,c+z*g,d*A/Gf(t*I+k)]}}return x.duration=y*1e3*t/Math.SQRT2,x}return s.rho=function(a){var i=Math.max(.001,+a),l=i*i,c=l*l;return e(i,l,c)},s})(Math.SQRT2,2,4);var Rr=0,ho=0,co=0,g1=1e3,ya,mo,va=0,ir=0,ai=0,Oo=typeof performance=="object"&&performance.now?performance:Date,b1=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function iu(){return ir||(b1(sq),ir=Oo.now()+ai)}function sq(){ir=0}function wa(){this._call=this._time=this._next=null}wa.prototype=x1.prototype={constructor:wa,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?iu():+n)+(t==null?0:+t),!this._next&&mo!==this&&(mo?mo._next=this:ya=this,mo=this),this._call=e,this._time=n,pc()},stop:function(){this._call&&(this._call=null,this._time=1/0,pc())}};function x1(e,t,n){var r=new wa;return r.restart(e,t,n),r}function aq(){iu(),++Rr;for(var e=ya,t;e;)(t=ir-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Rr}function Kf(){ir=(va=Oo.now())+ai,Rr=ho=0;try{aq()}finally{Rr=0,lq(),ir=0}}function iq(){var e=Oo.now(),t=e-va;t>g1&&(ai-=t,va=e)}function lq(){for(var e,t=ya,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:ya=n);mo=e,pc(r)}function pc(e){if(!Rr){ho&&(ho=clearTimeout(ho));var t=e-ir;t>24?(e<1/0&&(ho=setTimeout(Kf,e-Oo.now()-ai)),co&&(co=clearInterval(co))):(co||(va=Oo.now(),co=setInterval(iq,g1)),Rr=1,b1(Kf))}}function Wf(e,t,n){var r=new wa;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var cq=oi("start","end","cancel","interrupt"),dq=[],y1=0,Yf=1,fc=2,Ks=3,Zf=4,hc=5,Ws=6;function ii(e,t,n,r,s,a){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;uq(e,n,{name:t,index:r,group:s,on:cq,tween:dq,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:y1})}function lu(e,t){var n=Ht(e,t);if(n.state>y1)throw new Error("too late; already scheduled");return n}function rn(e,t){var n=Ht(e,t);if(n.state>Ks)throw new Error("too late; already running");return n}function Ht(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function uq(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=x1(a,0,n.time);function a(d){n.state=Yf,n.timer.restart(i,n.delay,n.time),n.delay<=d&&i(d-n.delay)}function i(d){var u,p,h,m;if(n.state!==Yf)return c();for(u in r)if(m=r[u],m.name===n.name){if(m.state===Ks)return Wf(i);m.state===Zf?(m.state=Ws,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[u]):+u<t&&(m.state=Ws,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[u])}if(Wf(function(){n.state===Ks&&(n.state=Zf,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=fc,n.on.call("start",e,e.__data__,n.index,n.group),n.state===fc){for(n.state=Ks,s=new Array(h=n.tween.length),u=0,p=-1;u<h;++u)(m=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(s[++p]=m);s.length=p+1}}function l(d){for(var u=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(c),n.state=hc,1),p=-1,h=s.length;++p<h;)s[p].call(e,u);n.state===hc&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Ws,n.timer.stop(),delete r[t];for(var d in r)return;delete e.__transition}}function Ys(e,t){var n=e.__transition,r,s,a=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((r=n[i]).name!==t){a=!1;continue}s=r.state>fc&&r.state<hc,r.state=Ws,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}a&&delete e.__transition}}function pq(e){return this.each(function(){Ys(this,e)})}function fq(e,t){var n,r;return function(){var s=rn(this,e),a=s.tween;if(a!==n){r=n=a;for(var i=0,l=r.length;i<l;++i)if(r[i].name===t){r=r.slice(),r.splice(i,1);break}}s.tween=r}}function hq(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var a=rn(this,e),i=a.tween;if(i!==r){s=(r=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 mq(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Ht(this.node(),n).tween,s=0,a=r.length,i;s<a;++s)if((i=r[s]).name===e)return i.value;return null}return this.each((t==null?fq:hq)(n,e,t))}function cu(e,t,n){var r=e._id;return e.each(function(){var s=rn(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Ht(s,r).value[t]}}function v1(e,t){var n;return(typeof t=="number"?Qt:t instanceof ar?xa:(n=ar(t))?(t=n,xa):f1)(e,t)}function gq(e){return function(){this.removeAttribute(e)}}function bq(e){return function(){this.removeAttributeNS(e.space,e.local)}}function xq(e,t,n){var r,s=n+"",a;return function(){var i=this.getAttribute(e);return i===s?null:i===r?a:a=t(r=i,n)}}function yq(e,t,n){var r,s=n+"",a;return function(){var i=this.getAttributeNS(e.space,e.local);return i===s?null:i===r?a:a=t(r=i,n)}}function vq(e,t,n){var r,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===r&&c===s?a:(s=c,a=t(r=i,l)))}}function wq(e,t,n){var r,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===r&&c===s?a:(s=c,a=t(r=i,l)))}}function Nq(e,t){var n=si(e),r=n==="transform"?tq:v1;return this.attrTween(e,typeof t=="function"?(n.local?wq:vq)(n,r,cu(this,"attr."+e,t)):t==null?(n.local?bq:gq)(n):(n.local?yq:xq)(n,r,t))}function kq(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Sq(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Cq(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Sq(e,a)),n}return s._value=t,s}function Mq(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&kq(e,a)),n}return s._value=t,s}function Eq(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 r=si(e);return this.tween(n,(r.local?Cq:Mq)(r,t))}function Iq(e,t){return function(){lu(this,e).delay=+t.apply(this,arguments)}}function Aq(e,t){return t=+t,function(){lu(this,e).delay=t}}function Pq(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Iq:Aq)(t,e)):Ht(this.node(),t).delay}function _q(e,t){return function(){rn(this,e).duration=+t.apply(this,arguments)}}function $q(e,t){return t=+t,function(){rn(this,e).duration=t}}function Dq(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?_q:$q)(t,e)):Ht(this.node(),t).duration}function Tq(e,t){if(typeof t!="function")throw new Error;return function(){rn(this,e).ease=t}}function Lq(e){var t=this._id;return arguments.length?this.each(Tq(t,e)):Ht(this.node(),t).ease}function Rq(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;rn(this,e).ease=n}}function Oq(e){if(typeof e!="function")throw new Error;return this.each(Rq(this._id,e))}function Bq(e){typeof e!="function"&&(e=Zv(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=r[s]=[],c,d=0;d<i;++d)(c=a[d])&&e.call(c,c.__data__,d,a)&&l.push(c);return new bn(r,this._parents,this._name,this._id)}function zq(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,a=Math.min(r,s),i=new Array(r),l=0;l<a;++l)for(var c=t[l],d=n[l],u=c.length,p=i[l]=new Array(u),h,m=0;m<u;++m)(h=c[m]||d[m])&&(p[m]=h);for(;l<r;++l)i[l]=t[l];return new bn(i,this._parents,this._name,this._id)}function Fq(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 jq(e,t,n){var r,s,a=Fq(t)?lu:rn;return function(){var i=a(this,e),l=i.on;l!==r&&(s=(r=l).copy()).on(t,n),i.on=s}}function Vq(e,t){var n=this._id;return arguments.length<2?Ht(this.node(),n).on.on(e):this.each(jq(n,e,t))}function Hq(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function qq(){return this.on("end.remove",Hq(this._id))}function Uq(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ru(e));for(var r=this._groups,s=r.length,a=new Array(s),i=0;i<s;++i)for(var l=r[i],c=l.length,d=a[i]=new Array(c),u,p,h=0;h<c;++h)(u=l[h])&&(p=e.call(u,u.__data__,h,l))&&("__data__"in u&&(p.__data__=u.__data__),d[h]=p,ii(d[h],t,n,h,d,Ht(u,n)));return new bn(a,this._parents,t,n)}function Qq(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Yv(e));for(var r=this._groups,s=r.length,a=[],i=[],l=0;l<s;++l)for(var c=r[l],d=c.length,u,p=0;p<d;++p)if(u=c[p]){for(var h=e.call(u,u.__data__,p,c),m,g=Ht(u,n),b=0,x=h.length;b<x;++b)(m=h[b])&&ii(m,t,n,b,h,g);a.push(h),i.push(u)}return new bn(a,i,t,n)}var Gq=rs.prototype.constructor;function Kq(){return new Gq(this._groups,this._parents)}function Wq(e,t){var n,r,s;return function(){var a=Lr(this,e),i=(this.style.removeProperty(e),Lr(this,e));return a===i?null:a===n&&i===r?s:s=t(n=a,r=i)}}function w1(e){return function(){this.style.removeProperty(e)}}function Yq(e,t,n){var r,s=n+"",a;return function(){var i=Lr(this,e);return i===s?null:i===r?a:a=t(r=i,n)}}function Zq(e,t,n){var r,s,a;return function(){var i=Lr(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),Lr(this,e))),i===c?null:i===r&&c===s?a:(s=c,a=t(r=i,l))}}function Xq(e,t){var n,r,s,a="style."+t,i="end."+a,l;return function(){var c=rn(this,e),d=c.on,u=c.value[a]==null?l||(l=w1(t)):void 0;(d!==n||s!==u)&&(r=(n=d).copy()).on(i,s=u),c.on=r}}function Jq(e,t,n){var r=(e+="")=="transform"?eq:v1;return t==null?this.styleTween(e,Wq(e,r)).on("end.style."+e,w1(e)):typeof t=="function"?this.styleTween(e,Zq(e,r,cu(this,"style."+e,t))).each(Xq(this._id,e)):this.styleTween(e,Yq(e,r,t),n).on("end.style."+e,null)}function eU(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function tU(e,t,n){var r,s;function a(){var i=t.apply(this,arguments);return i!==s&&(r=(s=i)&&eU(e,i,n)),r}return a._value=t,a}function nU(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,tU(e,t,n??""))}function rU(e){return function(){this.textContent=e}}function oU(e){return function(){var t=e(this);this.textContent=t??""}}function sU(e){return this.tween("text",typeof e=="function"?oU(cu(this,"text",e)):rU(e==null?"":e+""))}function aU(e){return function(t){this.textContent=e.call(this,t)}}function iU(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&aU(s)),t}return r._value=e,r}function lU(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,iU(e))}function cU(){for(var e=this._name,t=this._id,n=N1(),r=this._groups,s=r.length,a=0;a<s;++a)for(var i=r[a],l=i.length,c,d=0;d<l;++d)if(c=i[d]){var u=Ht(c,t);ii(c,e,n,d,i,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new bn(r,this._parents,e,n)}function dU(){var e,t,n=this,r=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=rn(this,r),u=d.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),d.on=t}),s===0&&a()})}var uU=0;function bn(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function N1(){return++uU}var an=rs.prototype;bn.prototype={constructor:bn,select:Uq,selectAll:Qq,selectChild:an.selectChild,selectChildren:an.selectChildren,filter:Bq,merge:zq,selection:Kq,transition:cU,call:an.call,nodes:an.nodes,node:an.node,size:an.size,empty:an.empty,each:an.each,on:Vq,attr:Nq,attrTween:Eq,style:Jq,styleTween:nU,text:sU,textTween:lU,remove:qq,tween:mq,delay:Pq,duration:Dq,ease:Lq,easeVarying:Oq,end:dU,[Symbol.iterator]:an[Symbol.iterator]};function pU(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var fU={time:null,delay:0,duration:250,ease:pU};function hU(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 mU(e){var t,n;e instanceof bn?(t=e._id,e=e._name):(t=N1(),(n=fU).time=iu(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,a=0;a<s;++a)for(var i=r[a],l=i.length,c,d=0;d<l;++d)(c=i[d])&&ii(c,e,t,d,i,n||hU(c,t));return new bn(r,this._parents,e,t)}rs.prototype.interrupt=pq;rs.prototype.transition=mU;const Ts=e=>()=>e;function gU(e,{sourceEvent:t,target:n,transform:r,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:r,enumerable:!0,configurable:!0},_:{value:s}})}function dn(e,t,n){this.k=e,this.x=t,this.y=n}dn.prototype={constructor:dn,scale:function(e){return e===1?this:new dn(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new dn(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 li=new dn(1,0,0);k1.prototype=dn.prototype;function k1(e){for(;!e.__zoom;)if(!(e=e.parentNode))return li;return e.__zoom}function dl(e){e.stopImmediatePropagation()}function uo(e){e.preventDefault(),e.stopImmediatePropagation()}function bU(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function xU(){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 Xf(){return this.__zoom||li}function yU(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function vU(){return navigator.maxTouchPoints||"ontouchstart"in this}function wU(e,t,n){var r=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>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),i>a?(a+i)/2:Math.min(0,a)||Math.max(0,i))}function S1(){var e=bU,t=xU,n=wU,r=yU,s=vU,a=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,c=Gs,d=oi("start","zoom","end"),u,p,h,m=500,g=150,b=0,x=10;function y(M){M.property("__zoom",Xf).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",z).filter(s).on("touchstart.zoom",P).on("touchmove.zoom",B).on("touchend.zoom touchcancel.zoom",R).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(M,D,T,L){var O=M.selection?M.selection():M;O.property("__zoom",Xf),M!==O?k(M,D,T,L):O.interrupt().each(function(){C(this,arguments).event(L).start().zoom(null,typeof D=="function"?D.apply(this,arguments):D).end()})},y.scaleBy=function(M,D,T,L){y.scaleTo(M,function(){var O=this.__zoom.k,F=typeof D=="function"?D.apply(this,arguments):D;return O*F},T,L)},y.scaleTo=function(M,D,T,L){y.transform(M,function(){var O=t.apply(this,arguments),F=this.__zoom,j=T==null?N(O):typeof T=="function"?T.apply(this,arguments):T,V=F.invert(j),$=typeof D=="function"?D.apply(this,arguments):D;return n(v(w(F,$),j,V),O,i)},T,L)},y.translateBy=function(M,D,T,L){y.transform(M,function(){return n(this.__zoom.translate(typeof D=="function"?D.apply(this,arguments):D,typeof T=="function"?T.apply(this,arguments):T),t.apply(this,arguments),i)},null,L)},y.translateTo=function(M,D,T,L,O){y.transform(M,function(){var F=t.apply(this,arguments),j=this.__zoom,V=L==null?N(F):typeof L=="function"?L.apply(this,arguments):L;return n(li.translate(V[0],V[1]).scale(j.k).translate(typeof D=="function"?-D.apply(this,arguments):-D,typeof T=="function"?-T.apply(this,arguments):-T),F,i)},L,O)};function w(M,D){return D=Math.max(a[0],Math.min(a[1],D)),D===M.k?M:new dn(D,M.x,M.y)}function v(M,D,T){var L=D[0]-T[0]*M.k,O=D[1]-T[1]*M.k;return L===M.x&&O===M.y?M:new dn(M.k,L,O)}function N(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function k(M,D,T,L){M.on("start.zoom",function(){C(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(L).end()}).tween("zoom",function(){var O=this,F=arguments,j=C(O,F).event(L),V=t.apply(O,F),$=T==null?N(V):typeof T=="function"?T.apply(O,F):T,q=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),G=O.__zoom,Z=typeof D=="function"?D.apply(O,F):D,oe=c(G.invert($).concat(q/G.k),Z.invert($).concat(q/Z.k));return function(ne){if(ne===1)ne=Z;else{var X=oe(ne),re=q/X[2];ne=new dn(re,$[0]-X[0]*re,$[1]-X[1]*re)}j.zoom(null,ne)}})}function C(M,D,T){return!T&&M.__zooming||new E(M,D)}function E(M,D){this.that=M,this.args=D,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,D),this.taps=0}E.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,D){return this.mouse&&M!=="mouse"&&(this.mouse[1]=D.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=D.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=D.invert(this.touch1[0])),this.that.__zoom=D,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var D=ht(this.that).datum();d.call(M,this.that,new gU(M,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:d}),D)}};function I(M,...D){if(!e.apply(this,arguments))return;var T=C(this,D).event(M),L=this.__zoom,O=Math.max(a[0],Math.min(a[1],L.k*Math.pow(2,r.apply(this,arguments)))),F=Lt(M);if(T.wheel)(T.mouse[0][0]!==F[0]||T.mouse[0][1]!==F[1])&&(T.mouse[1]=L.invert(T.mouse[0]=F)),clearTimeout(T.wheel);else{if(L.k===O)return;T.mouse=[F,L.invert(F)],Ys(this),T.start()}uo(M),T.wheel=setTimeout(j,g),T.zoom("mouse",n(v(w(L,O),T.mouse[0],T.mouse[1]),T.extent,i));function j(){T.wheel=null,T.end()}}function A(M,...D){if(h||!e.apply(this,arguments))return;var T=M.currentTarget,L=C(this,D,!0).event(M),O=ht(M.view).on("mousemove.zoom",$,!0).on("mouseup.zoom",q,!0),F=Lt(M,T),j=M.clientX,V=M.clientY;i1(M.view),dl(M),L.mouse=[F,this.__zoom.invert(F)],Ys(this),L.start();function $(G){if(uo(G),!L.moved){var Z=G.clientX-j,oe=G.clientY-V;L.moved=Z*Z+oe*oe>b}L.event(G).zoom("mouse",n(v(L.that.__zoom,L.mouse[0]=Lt(G,T),L.mouse[1]),L.extent,i))}function q(G){O.on("mousemove.zoom mouseup.zoom",null),l1(G.view,L.moved),uo(G),L.event(G).end()}}function z(M,...D){if(e.apply(this,arguments)){var T=this.__zoom,L=Lt(M.changedTouches?M.changedTouches[0]:M,this),O=T.invert(L),F=T.k*(M.shiftKey?.5:2),j=n(v(w(T,F),L,O),t.apply(this,D),i);uo(M),l>0?ht(this).transition().duration(l).call(k,j,L,M):ht(this).call(y.transform,j,L,M)}}function P(M,...D){if(e.apply(this,arguments)){var T=M.touches,L=T.length,O=C(this,D,M.changedTouches.length===L).event(M),F,j,V,$;for(dl(M),j=0;j<L;++j)V=T[j],$=Lt(V,this),$=[$,this.__zoom.invert($),V.identifier],O.touch0?!O.touch1&&O.touch0[2]!==$[2]&&(O.touch1=$,O.taps=0):(O.touch0=$,F=!0,O.taps=1+!!u);u&&(u=clearTimeout(u)),F&&(O.taps<2&&(p=$[0],u=setTimeout(function(){u=null},m)),Ys(this),O.start())}}function B(M,...D){if(this.__zooming){var T=C(this,D).event(M),L=M.changedTouches,O=L.length,F,j,V,$;for(uo(M),F=0;F<O;++F)j=L[F],V=Lt(j,this),T.touch0&&T.touch0[2]===j.identifier?T.touch0[0]=V:T.touch1&&T.touch1[2]===j.identifier&&(T.touch1[0]=V);if(j=T.that.__zoom,T.touch1){var q=T.touch0[0],G=T.touch0[1],Z=T.touch1[0],oe=T.touch1[1],ne=(ne=Z[0]-q[0])*ne+(ne=Z[1]-q[1])*ne,X=(X=oe[0]-G[0])*X+(X=oe[1]-G[1])*X;j=w(j,Math.sqrt(ne/X)),V=[(q[0]+Z[0])/2,(q[1]+Z[1])/2],$=[(G[0]+oe[0])/2,(G[1]+oe[1])/2]}else if(T.touch0)V=T.touch0[0],$=T.touch0[1];else return;T.zoom("touch",n(v(j,V,$),T.extent,i))}}function R(M,...D){if(this.__zooming){var T=C(this,D).event(M),L=M.changedTouches,O=L.length,F,j;for(dl(M),h&&clearTimeout(h),h=setTimeout(function(){h=null},m),F=0;F<O;++F)j=L[F],T.touch0&&T.touch0[2]===j.identifier?delete T.touch0:T.touch1&&T.touch1[2]===j.identifier&&delete T.touch1;if(T.touch1&&!T.touch0&&(T.touch0=T.touch1,delete T.touch1),T.touch0)T.touch0[1]=this.__zoom.invert(T.touch0[0]);else if(T.end(),T.taps===2&&(j=Lt(j,this),Math.hypot(p[0]-j[0],p[1]-j[1])<x)){var V=ht(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return y.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:Ts(+M),y):r},y.filter=function(M){return arguments.length?(e=typeof M=="function"?M:Ts(!!M),y):e},y.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:Ts(!!M),y):s},y.extent=function(M){return arguments.length?(t=typeof M=="function"?M:Ts([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),y):t},y.scaleExtent=function(M){return arguments.length?(a[0]=+M[0],a[1]=+M[1],y):[a[0],a[1]]},y.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],y):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},y.constrain=function(M){return arguments.length?(n=M,y):n},y.duration=function(M){return arguments.length?(l=+M,y):l},y.interpolate=function(M){return arguments.length?(c=M,y):c},y.on=function(){var M=d.on.apply(d,arguments);return M===d?y:M},y.clickDistance=function(M){return arguments.length?(b=(M=+M)*M,y):Math.sqrt(b)},y.tapDistance=function(M){return arguments.length?(x=+M,y):x},y}const en={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:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Bo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],C1=["Enter"," ","Escape"],M1={"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 Or;(function(e){e.Strict="strict",e.Loose="loose"})(Or||(Or={}));var Xn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Xn||(Xn={}));var zo;(function(e){e.Partial="partial",e.Full="full"})(zo||(zo={}));const E1={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var En;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(En||(En={}));var Na;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Na||(Na={}));var we;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(we||(we={}));const Jf={[we.Left]:we.Right,[we.Right]:we.Left,[we.Top]:we.Bottom,[we.Bottom]:we.Top};function I1(e){return e===null?null:e?"valid":"invalid"}const A1=e=>"id"in e&&"source"in e&&"target"in e,NU=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),du=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),ss=(e,t=[0,0])=>{const{width:n,height:r}=Nn(e),s=e.origin??t,a=n*s[0],i=r*s[1];return{x:e.position.x-a,y:e.position.y-i}},kU=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const a=typeof s=="string";let i=!t.nodeLookup&&!a?s:void 0;t.nodeLookup&&(i=a?t.nodeLookup.get(s):du(s)?s:t.nodeLookup.get(s.id));const l=i?ka(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return ci(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return di(n)},as=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=ci(n,ka(s)),r=!0)}),r?di(n):{x:0,y:0,width:0,height:0}},uu=(e,t,[n,r,s]=[0,0,1],a=!1,i=!1)=>{const l={...ls(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const d of e.values()){const{measured:u,selectable:p=!0,hidden:h=!1}=d;if(i&&!p||h)continue;const m=u.width??d.width??d.initialWidth??null,g=u.height??d.height??d.initialHeight??null,b=Fo(l,zr(d)),x=(m??0)*(g??0),y=a&&b>0;(!d.internals.handleBounds||y||b>=x||d.dragging)&&c.push(d)}return c},SU=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function CU(e,t){const n=new Map,r=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)&&(!r||r.has(s.id))&&n.set(s.id,s)}),n}async function MU({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:a},i){if(e.size===0)return Promise.resolve(!0);const l=CU(e,i),c=as(l),d=pu(c,t,n,i?.minZoom??s,i?.maxZoom??a,i?.padding??.1);return await r.setViewport(d,{duration:i?.duration,ease:i?.ease,interpolate:i?.interpolate}),Promise.resolve(!0)}function P1({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[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},u=i.origin??r;let p=i.extent||s;if(i.extent==="parent"&&!i.expandParent)if(!l)a?.("005",en.error005());else{const m=l.measured.width,g=l.measured.height;m&&g&&(p=[[c,d],[c+m,d+g]])}else l&&Fr(i.extent)&&(p=[[i.extent[0][0]+c,i.extent[0][1]+d],[i.extent[1][0]+c,i.extent[1][1]+d]]);const h=Fr(p)?lr(t,p,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&a?.("015",en.error015()),{position:{x:h.x-c+(i.measured.width??0)*u[0],y:h.y-d+(i.measured.height??0)*u[1]},positionAbsolute:h}}async function EU({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const a=new Set(e.map(h=>h.id)),i=[];for(const h of n){if(h.deletable===!1)continue;const m=a.has(h.id),g=!m&&h.parentId&&i.find(b=>b.id===h.parentId);(m||g)&&i.push(h)}const l=new Set(t.map(h=>h.id)),c=r.filter(h=>h.deletable!==!1),u=SU(i,c);for(const h of c)l.has(h.id)&&!u.find(g=>g.id===h.id)&&u.push(h);if(!s)return{edges:u,nodes:i};const p=await s({nodes:i,edges:u});return typeof p=="boolean"?p?{edges:u,nodes:i}:{edges:[],nodes:[]}:p}const Br=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),lr=(e={x:0,y:0},t,n)=>({x:Br(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Br(e.y,t[0][1],t[1][1]-(n?.height??0))});function _1(e,t,n){const{width:r,height:s}=Nn(n),{x:a,y:i}=n.internals.positionAbsolute;return lr(e,[[a,i],[a+r,i+s]],t)}const eh=(e,t,n)=>e<t?Br(Math.abs(e-t),1,t)/t:e>n?-Br(Math.abs(e-n),1,t)/t:0,$1=(e,t,n=15,r=40)=>{const s=eh(e.x,r,t.width-r)*n,a=eh(e.y,r,t.height-r)*n;return[s,a]},ci=(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)}),mc=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),di=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),zr=(e,t=[0,0])=>{const{x:n,y:r}=du(e)?e.internals.positionAbsolute:ss(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},ka=(e,t=[0,0])=>{const{x:n,y:r}=du(e)?e.internals.positionAbsolute:ss(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},D1=(e,t)=>di(ci(mc(e),mc(t))),Fo=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},th=e=>Ot(e.width)&&Ot(e.height)&&Ot(e.x)&&Ot(e.y),Ot=e=>!isNaN(e)&&isFinite(e),IU=(e,t)=>{},is=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),ls=({x:e,y:t},[n,r,s],a=!1,i=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return a?is(l,i):l},Sa=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function vr(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 AU(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=vr(e,n),s=vr(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=vr(e.top??e.y??0,n),s=vr(e.bottom??e.y??0,n),a=vr(e.left??e.x??0,t),i=vr(e.right??e.x??0,t);return{top:r,right:i,bottom:s,left:a,x:a+i,y:r+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function PU(e,t,n,r,s,a){const{x:i,y:l}=Sa(e,[t,n,r]),{x:c,y:d}=Sa({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=s-c,p=a-d;return{left:Math.floor(i),top:Math.floor(l),right:Math.floor(u),bottom:Math.floor(p)}}const pu=(e,t,n,r,s,a)=>{const i=AU(a,t,n),l=(t-i.x)/e.width,c=(n-i.y)/e.height,d=Math.min(l,c),u=Br(d,r,s),p=e.x+e.width/2,h=e.y+e.height/2,m=t/2-p*u,g=n/2-h*u,b=PU(e,m,g,u,t,n),x={left:Math.min(b.left-i.left,0),top:Math.min(b.top-i.top,0),right:Math.min(b.right-i.right,0),bottom:Math.min(b.bottom-i.bottom,0)};return{x:m-x.left+x.right,y:g-x.top+x.bottom,zoom:u}},jo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Fr(e){return e!=null&&e!=="parent"}function Nn(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function T1(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function L1(e,t={width:0,height:0},n,r,s){const a={...e},i=r.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 nh(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function _U(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function $U(e){return{...M1,...e||{}}}function Co(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:a,y:i}=Bt(e),l=ls({x:a-(s?.left??0),y:i-(s?.top??0)},r),{x:c,y:d}=n?is(l,t):l;return{xSnapped:c,ySnapped:d,...l}}const fu=e=>({width:e.offsetWidth,height:e.offsetHeight}),R1=e=>e?.getRootNode?.()||window?.document,DU=["INPUT","SELECT","TEXTAREA"];function O1(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:DU.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const B1=e=>"clientX"in e,Bt=(e,t)=>{const n=B1(e),r=n?e.clientX:e.touches?.[0].clientX,s=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:s-(t?.top??0)}},rh=(e,t,n,r,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)/r,y:(l.top-n.top)/r,...fu(i)}})};function z1({sourceX:e,sourceY:t,targetX:n,targetY:r,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+r*.125,u=Math.abs(c-e),p=Math.abs(d-t);return[c,d,u,p]}function Ls(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function oh({pos:e,x1:t,y1:n,x2:r,y2:s,c:a}){switch(e){case we.Left:return[t-Ls(t-r,a),n];case we.Right:return[t+Ls(r-t,a),n];case we.Top:return[t,n-Ls(n-s,a)];case we.Bottom:return[t,n+Ls(s-n,a)]}}function F1({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:r,targetY:s,targetPosition:a=we.Top,curvature:i=.25}){const[l,c]=oh({pos:n,x1:e,y1:t,x2:r,y2:s,c:i}),[d,u]=oh({pos:a,x1:r,y1:s,x2:e,y2:t,c:i}),[p,h,m,g]=z1({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:u});return[`M${e},${t} C${l},${c} ${d},${u} ${r},${s}`,p,h,m,g]}function j1({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,a=n<e?n+s:n-s,i=Math.abs(r-t)/2,l=r<t?r+i:r-i;return[a,l,s,i]}function TU({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:s=!1,zIndexMode:a="basic"}){if(a==="manual")return r;const i=s&&n?r+1e3:r,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 LU({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const a=ci(ka(e),ka(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:r/s[2]};return Fo(i,di(a))>0}const RU=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,OU=(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)),BU=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||RU;let s;return A1(e)?s={...e}:s={...e,id:r(e)},OU(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function V1({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,a,i,l]=j1({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,a,i,l]}const sh={[we.Left]:{x:-1,y:0},[we.Right]:{x:1,y:0},[we.Top]:{x:0,y:-1},[we.Bottom]:{x:0,y:1}},zU=({source:e,sourcePosition:t=we.Bottom,target:n})=>t===we.Left||t===we.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},ah=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function FU({source:e,sourcePosition:t=we.Bottom,target:n,targetPosition:r=we.Top,center:s,offset:a,stepPosition:i}){const l=sh[t],c=sh[r],d={x:e.x+l.x*a,y:e.y+l.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},p=zU({source:d,sourcePosition:t,target:u}),h=p.x!==0?"x":"y",m=p[h];let g=[],b,x;const y={x:0,y:0},w={x:0,y:0},[,,v,N]=j1({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[h]*c[h]===-1){h==="x"?(b=s.x??d.x+(u.x-d.x)*i,x=s.y??(d.y+u.y)/2):(b=s.x??(d.x+u.x)/2,x=s.y??d.y+(u.y-d.y)*i);const I=[{x:b,y:d.y},{x:b,y:u.y}],A=[{x:d.x,y:x},{x:u.x,y:x}];l[h]===m?g=h==="x"?I:A:g=h==="x"?A:I}else{const I=[{x:d.x,y:u.y}],A=[{x:u.x,y:d.y}];if(h==="x"?g=l.x===m?A:I:g=l.y===m?I:A,t===r){const M=Math.abs(e[h]-n[h]);if(M<=a){const D=Math.min(a-1,a-M);l[h]===m?y[h]=(d[h]>e[h]?-1:1)*D:w[h]=(u[h]>n[h]?-1:1)*D}}if(t!==r){const M=h==="x"?"y":"x",D=l[h]===c[M],T=d[M]>u[M],L=d[M]<u[M];(l[h]===1&&(!D&&T||D&&L)||l[h]!==1&&(!D&&L||D&&T))&&(g=h==="x"?I:A)}const z={x:d.x+y.x,y:d.y+y.y},P={x:u.x+w.x,y:u.y+w.y},B=Math.max(Math.abs(z.x-g[0].x),Math.abs(P.x-g[0].x)),R=Math.max(Math.abs(z.y-g[0].y),Math.abs(P.y-g[0].y));B>=R?(b=(z.x+P.x)/2,x=g[0].y):(b=g[0].x,x=(z.y+P.y)/2)}const k={x:d.x+y.x,y:d.y+y.y},C={x:u.x+w.x,y:u.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],b,x,v,N]}function jU(e,t,n,r){const s=Math.min(ah(e,t)/2,ah(t,n)/2,r),{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,u=e.y<n.y?1:-1;return`L ${a+s*d},${i}Q ${a},${i} ${a},${i+s*u}`}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 gc({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:r,targetY:s,targetPosition:a=we.Top,borderRadius:i=5,centerX:l,centerY:c,offset:d=20,stepPosition:u=.5}){const[p,h,m,g,b]=FU({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:a,center:{x:l,y:c},offset:d,stepPosition:u});let x=`M${p[0].x} ${p[0].y}`;for(let y=1;y<p.length-1;y++)x+=jU(p[y-1],p[y],p[y+1],i);return x+=`L${p[p.length-1].x} ${p[p.length-1].y}`,[x,h,m,g,b]}function ih(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function VU(e){const{sourceNode:t,targetNode:n}=e;if(!ih(t)||!ih(n))return null;const r=t.internals.handleBounds||lh(t.handles),s=n.internals.handleBounds||lh(n.handles),a=ch(r?.source??[],e.sourceHandle),i=ch(e.connectionMode===Or.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!a||!i)return e.onError?.("008",en.error008(a?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=a?.position||we.Bottom,c=i?.position||we.Top,d=cr(t,a,l),u=cr(n,i,c);return{sourceX:d.x,sourceY:d.y,targetX:u.x,targetY:u.y,sourcePosition:l,targetPosition:c}}function lh(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function cr(e,t,n=we.Left,r=!1){const s=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:i,height:l}=t??Nn(e);if(r)return{x:s+i/2,y:a+l/2};switch(t?.position??n){case we.Top:return{x:s+i/2,y:a};case we.Right:return{x:s+i,y:a+l/2};case we.Bottom:return{x:s+i/2,y:a+l};case we.Left:return{x:s,y:a+l/2}}}function ch(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function bc(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function HU(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const a=new Set;return e.reduce((i,l)=>([l.markerStart||r,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const d=bc(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 H1=1e3,qU=10,hu={nodeOrigin:[0,0],nodeExtent:Bo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},UU={...hu,checkEquality:!0};function mu(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function QU(e,t,n){const r=mu(hu,n);for(const s of e.values())if(s.parentId)bu(s,e,t,r);else{const a=ss(s,r.nodeOrigin),i=Fr(s.extent)?s.extent:r.nodeExtent,l=lr(a,i,Nn(s));s.internals.positionAbsolute=l}}function GU(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],r=[];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"&&r.push(a)}return{source:n,target:r}}function gu(e){return e==="manual"}function xc(e,t,n,r={}){const s=mu(UU,r),a={i:0},i=new Map(t),l=s?.elevateNodesOnSelect&&!gu(s.zIndexMode)?H1:0;let c=e.length>0,d=!1;t.clear(),n.clear();for(const u of e){let p=i.get(u.id);if(s.checkEquality&&u===p?.internals.userNode)t.set(u.id,p);else{const h=ss(u,s.nodeOrigin),m=Fr(u.extent)?u.extent:s.nodeExtent,g=lr(h,m,Nn(u));p={...s.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:g,handleBounds:GU(u,p),z:q1(u,l,s.zIndexMode),userNode:u}},t.set(u.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(c=!1),u.parentId&&bu(p,t,n,r,a),d||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:d}}function KU(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 bu(e,t,n,r,s){const{elevateNodesOnSelect:a,nodeOrigin:i,nodeExtent:l,zIndexMode:c}=mu(hu,r),d=e.parentId,u=t.get(d);if(!u){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}KU(e,n),s&&!u.parentId&&u.internals.rootParentIndex===void 0&&c==="auto"&&(u.internals.rootParentIndex=++s.i,u.internals.z=u.internals.z+s.i*qU),s&&u.internals.rootParentIndex!==void 0&&(s.i=u.internals.rootParentIndex);const p=a&&!gu(c)?H1:0,{x:h,y:m,z:g}=WU(e,u,i,l,p,c),{positionAbsolute:b}=e.internals,x=h!==b.x||m!==b.y;(x||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:h,y:m}:b,z:g}})}function q1(e,t,n){const r=Ot(e.zIndex)?e.zIndex:0;return gu(n)?r:r+(e.selected?t:0)}function WU(e,t,n,r,s,a){const{x:i,y:l}=t.internals.positionAbsolute,c=Nn(e),d=ss(e,n),u=Fr(e.extent)?lr(d,e.extent,c):d;let p=lr({x:i+u.x,y:l+u.y},r,c);e.extent==="parent"&&(p=_1(p,c,t));const h=q1(e,s,a),m=t.internals.z??0;return{x:p.x,y:p.y,z:m>=h?m+1:h}}function xu(e,t,n,r=[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??zr(l),d=D1(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,u=Nn(l),p=l.origin??r,h=i.x<d.x?Math.round(Math.abs(d.x-i.x)):0,m=i.y<d.y?Math.round(Math.abs(d.y-i.y)):0,g=Math.max(u.width,Math.round(i.width)),b=Math.max(u.height,Math.round(i.height)),x=(g-u.width)*p[0],y=(b-u.height)*p[1];(h>0||m>0||x||y)&&(s.push({id:c,type:"position",position:{x:l.position.x-h+x,y:l.position.y-m+y}}),n.get(c)?.forEach(w=>{e.some(v=>v.id===w.id)||s.push({id:w.id,type:"position",position:{x:w.position.x+h,y:w.position.y+m}})})),(u.width<i.width||u.height<i.height||h||m)&&s.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:g+(h?p[0]*h-x:0),height:b+(m?p[1]*m-y:0)}})}),s}function YU(e,t,n,r,s,a,i){const l=r?.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const d=[],u=window.getComputedStyle(l),{m22:p}=new window.DOMMatrixReadOnly(u.transform),h=[];for(const m of e.values()){const g=t.get(m.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const b=fu(m.nodeElement),x=g.measured.width!==b.width||g.measured.height!==b.height;if(!!(b.width&&b.height&&(x||!g.internals.handleBounds||m.force))){const w=m.nodeElement.getBoundingClientRect(),v=Fr(g.extent)?g.extent:a;let{positionAbsolute:N}=g.internals;g.parentId&&g.extent==="parent"?N=_1(N,b,t.get(g.parentId)):v&&(N=lr(N,v,b));const k={...g,measured:b,internals:{...g.internals,positionAbsolute:N,handleBounds:{source:rh("source",m.nodeElement,w,p,g.id),target:rh("target",m.nodeElement,w,p,g.id)}}};t.set(g.id,k),g.parentId&&bu(k,t,n,{nodeOrigin:s,zIndexMode:i}),c=!0,x&&(d.push({id:g.id,type:"dimensions",dimensions:b}),g.expandParent&&g.parentId&&h.push({id:g.id,parentId:g.parentId,rect:zr(k,s)}))}}if(h.length>0){const m=xu(h,t,n,s);d.push(...m)}return{changes:d,updatedInternals:c}}async function ZU({delta:e,panZoom:t,transform:n,translateExtent:r,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]],r),l=!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2]);return Promise.resolve(l)}function dh(e,t,n,r,s,a){let i=s;const l=r.get(i)||new Map;r.set(i,l.set(n,t)),i=`${s}-${e}`;const c=r.get(i)||new Map;if(r.set(i,c.set(n,t)),a){i=`${s}-${e}-${a}`;const d=r.get(i)||new Map;r.set(i,d.set(n,t))}}function U1(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:a,sourceHandle:i=null,targetHandle:l=null}=r,c={edgeId:r.id,source:s,target:a,sourceHandle:i,targetHandle:l},d=`${s}-${i}--${a}-${l}`,u=`${a}-${l}--${s}-${i}`;dh("source",c,u,e,s,i),dh("target",c,d,e,a,l),t.set(r.id,r)}}function Q1(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Q1(n,t):!1}function uh(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function XU(e,t,n,r){const s=new Map;for(const[a,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!Q1(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 ul({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){const s=[];for(const[i,l]of t){const c=n.get(i)?.internals.userNode;c&&s.push({...c,position:l.position,dragging:r})}if(!e)return[s[0],s];const a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:s[0],s]}function JU({dragItems:e,snapGrid:t,x:n,y:r}){const s=e.values().next().value;if(!s)return null;const a={x:n-s.distance.x,y:r-s.distance.y},i=is(a,t);return{x:i.x-a.x,y:i.y-a.y}}function eQ({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let a={x:null,y:null},i=0,l=new Map,c=!1,d={x:0,y:0},u=null,p=!1,h=null,m=!1,g=!1,b=null;function x({noDragClassName:w,handleSelector:v,domNode:N,isSelectable:k,nodeId:C,nodeClickDistance:E=0}){h=ht(N);function I({x:B,y:R}){const{nodeLookup:M,nodeExtent:D,snapGrid:T,snapToGrid:L,nodeOrigin:O,onNodeDrag:F,onSelectionDrag:j,onError:V,updateNodePositions:$}=t();a={x:B,y:R};let q=!1;const G=l.size>1,Z=G&&D?mc(as(l)):null,oe=G&&L?JU({dragItems:l,snapGrid:T,x:B,y:R}):null;for(const[ne,X]of l){if(!M.has(ne))continue;let re={x:B-X.distance.x,y:R-X.distance.y};L&&(re=oe?{x:Math.round(re.x+oe.x),y:Math.round(re.y+oe.y)}:is(re,T));let be=null;if(G&&D&&!X.extent&&Z){const{positionAbsolute:ee}=X.internals,ae=ee.x-Z.x+D[0][0],fe=ee.x+X.measured.width-Z.x2+D[1][0],ge=ee.y-Z.y+D[0][1],Q=ee.y+X.measured.height-Z.y2+D[1][1];be=[[ae,ge],[fe,Q]]}const{position:J,positionAbsolute:W}=P1({nodeId:ne,nextPosition:re,nodeLookup:M,nodeExtent:be||D,nodeOrigin:O,onError:V});q=q||X.position.x!==J.x||X.position.y!==J.y,X.position=J,X.internals.positionAbsolute=W}if(g=g||q,!!q&&($(l,!0),b&&(r||F||!C&&j))){const[ne,X]=ul({nodeId:C,dragItems:l,nodeLookup:M});r?.(b,l,ne,X),F?.(b,ne,X),C||j?.(b,X)}}async function A(){if(!u)return;const{transform:B,panBy:R,autoPanSpeed:M,autoPanOnNodeDrag:D}=t();if(!D){c=!1,cancelAnimationFrame(i);return}const[T,L]=$1(d,u,M);(T!==0||L!==0)&&(a.x=(a.x??0)-T/B[2],a.y=(a.y??0)-L/B[2],await R({x:T,y:L})&&I(a)),i=requestAnimationFrame(A)}function z(B){const{nodeLookup:R,multiSelectionActive:M,nodesDraggable:D,transform:T,snapGrid:L,snapToGrid:O,selectNodesOnDrag:F,onNodeDragStart:j,onSelectionDragStart:V,unselectNodesAndEdges:$}=t();p=!0,(!F||!k)&&!M&&C&&(R.get(C)?.selected||$()),k&&F&&C&&e?.(C);const q=Co(B.sourceEvent,{transform:T,snapGrid:L,snapToGrid:O,containerBounds:u});if(a=q,l=XU(R,D,q,C),l.size>0&&(n||j||!C&&V)){const[G,Z]=ul({nodeId:C,dragItems:l,nodeLookup:R});n?.(B.sourceEvent,l,G,Z),j?.(B.sourceEvent,G,Z),C||V?.(B.sourceEvent,Z)}}const P=c1().clickDistance(E).on("start",B=>{const{domNode:R,nodeDragThreshold:M,transform:D,snapGrid:T,snapToGrid:L}=t();u=R?.getBoundingClientRect()||null,m=!1,g=!1,b=B.sourceEvent,M===0&&z(B),a=Co(B.sourceEvent,{transform:D,snapGrid:T,snapToGrid:L,containerBounds:u}),d=Bt(B.sourceEvent,u)}).on("drag",B=>{const{autoPanOnNodeDrag:R,transform:M,snapGrid:D,snapToGrid:T,nodeDragThreshold:L,nodeLookup:O}=t(),F=Co(B.sourceEvent,{transform:M,snapGrid:D,snapToGrid:T,containerBounds:u});if(b=B.sourceEvent,(B.sourceEvent.type==="touchmove"&&B.sourceEvent.touches.length>1||C&&!O.has(C))&&(m=!0),!m){if(!c&&R&&p&&(c=!0,A()),!p){const j=Bt(B.sourceEvent,u),V=j.x-d.x,$=j.y-d.y;Math.sqrt(V*V+$*$)>L&&z(B)}(a.x!==F.xSnapped||a.y!==F.ySnapped)&&l&&p&&(d=Bt(B.sourceEvent,u),I(F))}}).on("end",B=>{if(!(!p||m)&&(c=!1,p=!1,cancelAnimationFrame(i),l.size>0)){const{nodeLookup:R,updateNodePositions:M,onNodeDragStop:D,onSelectionDragStop:T}=t();if(g&&(M(l,!1),g=!1),s||D||!C&&T){const[L,O]=ul({nodeId:C,dragItems:l,nodeLookup:R,dragging:!1});s?.(B.sourceEvent,l,L,O),D?.(B.sourceEvent,L,O),C||T?.(B.sourceEvent,O)}}}).filter(B=>{const R=B.target;return!B.button&&(!w||!uh(R,`.${w}`,N))&&(!v||uh(R,v,N))});h.call(P)}function y(){h?.on(".drag",null)}return{update:x,destroy:y}}function tQ(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const a of t.values())Fo(s,zr(a))>0&&r.push(a);return r}const nQ=250;function rQ(e,t,n,r){let s=[],a=1/0;const i=tQ(e,n,t+nQ);for(const l of i){const c=[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]];for(const d of c){if(r.nodeId===d.nodeId&&r.type===d.type&&r.id===d.id)continue;const{x:u,y:p}=cr(l,d,d.position,!0),h=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(p-e.y,2));h>t||(h<a?(s=[{...d,x:u,y:p}],a=h):h===a&&s.push({...d,x:u,y:p}))}}if(!s.length)return null;if(s.length>1){const l=r.type==="source"?"target":"source";return s.find(c=>c.type===l)??s[0]}return s[0]}function G1(e,t,n,r,s,a=!1){const i=r.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,...cr(i,c,c.position,!0)}:c}function K1(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function oQ(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const W1=()=>!0;function sQ(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:a,isTarget:i,domNode:l,nodeLookup:c,lib:d,autoPanOnConnect:u,flowId:p,panBy:h,cancelConnection:m,onConnectStart:g,onConnect:b,onConnectEnd:x,isValidConnection:y=W1,onReconnectEnd:w,updateConnection:v,getTransform:N,getFromHandle:k,autoPanSpeed:C,dragThreshold:E=1,handleDomNode:I}){const A=R1(e.target);let z=0,P;const{x:B,y:R}=Bt(e),M=K1(a,I),D=l?.getBoundingClientRect();let T=!1;if(!D||!M)return;const L=G1(s,M,r,c,t);if(!L)return;let O=Bt(e,D),F=!1,j=null,V=!1,$=null;function q(){if(!u||!D)return;const[J,W]=$1(O,D,C);h({x:J,y:W}),z=requestAnimationFrame(q)}const G={...L,nodeId:s,type:M,position:L.position},Z=c.get(s);let ne={inProgress:!0,isValid:null,from:cr(Z,G,we.Left,!0),fromHandle:G,fromPosition:G.position,fromNode:Z,to:O,toHandle:null,toPosition:Jf[G.position],toNode:null,pointer:O};function X(){T=!0,v(ne),g?.(e,{nodeId:s,handleId:r,handleType:M})}E===0&&X();function re(J){if(!T){const{x:Q,y:le}=Bt(J),ue=Q-B,de=le-R;if(!(ue*ue+de*de>E*E))return;X()}if(!k()||!G){be(J);return}const W=N();O=Bt(J,D),P=rQ(ls(O,W,!1,[1,1]),n,c,G),F||(q(),F=!0);const ee=Y1(J,{handle:P,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:i?"target":"source",isValidConnection:y,doc:A,lib:d,flowId:p,nodeLookup:c});$=ee.handleDomNode,j=ee.connection,V=oQ(!!P,ee.isValid);const ae=c.get(s),fe=ae?cr(ae,G,we.Left,!0):ne.from,ge={...ne,from:fe,isValid:V,to:ee.toHandle&&V?Sa({x:ee.toHandle.x,y:ee.toHandle.y},W):O,toHandle:ee.toHandle,toPosition:V&&ee.toHandle?ee.toHandle.position:Jf[G.position],toNode:ee.toHandle?c.get(ee.toHandle.nodeId):null,pointer:O};v(ge),ne=ge}function be(J){if(!("touches"in J&&J.touches.length>0)){if(T){(P||$)&&j&&V&&b?.(j);const{inProgress:W,...ee}=ne,ae={...ee,toPosition:ne.toHandle?ne.toPosition:null};x?.(J,ae),a&&w?.(J,ae)}m(),cancelAnimationFrame(z),F=!1,V=!1,j=null,$=null,A.removeEventListener("mousemove",re),A.removeEventListener("mouseup",be),A.removeEventListener("touchmove",re),A.removeEventListener("touchend",be)}}A.addEventListener("mousemove",re),A.addEventListener("mouseup",be),A.addEventListener("touchmove",re),A.addEventListener("touchend",be)}function Y1(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:a,doc:i,lib:l,flowId:c,isValidConnection:d=W1,nodeLookup:u}){const p=a==="target",h=t?i.querySelector(`.${l}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:m,y:g}=Bt(e),b=i.elementFromPoint(m,g),x=b?.classList.contains(`${l}-flow__handle`)?b:h,y={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const w=K1(void 0,x),v=x.getAttribute("data-nodeid"),N=x.getAttribute("data-handleid"),k=x.classList.contains("connectable"),C=x.classList.contains("connectableend");if(!v||!w)return y;const E={source:p?v:r,sourceHandle:p?N:s,target:p?r:v,targetHandle:p?s:N};y.connection=E;const A=k&&C&&(n===Or.Strict?p&&w==="source"||!p&&w==="target":v!==r||N!==s);y.isValid=A&&d(E),y.toHandle=G1(v,w,N,u,n,!0)}return y}const yc={onPointerDown:sQ,isValid:Y1};function aQ({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=ht(e);function a({translateExtent:l,width:c,height:d,zoomStep:u=1,pannable:p=!0,zoomable:h=!0,inversePan:m=!1}){const g=v=>{if(v.sourceEvent.type!=="wheel"||!t)return;const N=n(),k=v.sourceEvent.ctrlKey&&jo()?10:1,C=-v.sourceEvent.deltaY*(v.sourceEvent.deltaMode===1?.05:v.sourceEvent.deltaMode?1:.002)*u,E=N[2]*Math.pow(2,C*k);t.scaleTo(E)};let b=[0,0];const x=v=>{(v.sourceEvent.type==="mousedown"||v.sourceEvent.type==="touchstart")&&(b=[v.sourceEvent.clientX??v.sourceEvent.touches[0].clientX,v.sourceEvent.clientY??v.sourceEvent.touches[0].clientY])},y=v=>{const N=n();if(v.sourceEvent.type!=="mousemove"&&v.sourceEvent.type!=="touchmove"||!t)return;const k=[v.sourceEvent.clientX??v.sourceEvent.touches[0].clientX,v.sourceEvent.clientY??v.sourceEvent.touches[0].clientY],C=[k[0]-b[0],k[1]-b[1]];b=k;const E=r()*Math.max(N[2],Math.log(N[2]))*(m?-1:1),I={x:N[0]-C[0]*E,y:N[1]-C[1]*E},A=[[0,0],[c,d]];t.setViewportConstrained({x:I.x,y:I.y,zoom:N[2]},A,l)},w=S1().on("start",x).on("zoom",p?y:null).on("zoom.wheel",h?g:null);s.call(w,{})}function i(){s.on("zoom",null)}return{update:a,destroy:i,pointer:Lt}}const ui=e=>({x:e.x,y:e.y,zoom:e.k}),pl=({x:e,y:t,zoom:n})=>li.translate(e,t).scale(n),Cr=(e,t)=>e.target.closest(`.${t}`),Z1=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),iQ=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,fl=(e,t=0,n=iQ,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},X1=e=>{const t=e.ctrlKey&&jo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function lQ({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:i,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:d}){return u=>{if(Cr(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(u.ctrlKey&&i){const x=Lt(u),y=X1(u),w=p*Math.pow(2,y);r.scaleTo(n,w,x,u);return}const h=u.deltaMode===1?20:1;let m=s===Xn.Vertical?0:u.deltaX*h,g=s===Xn.Horizontal?0:u.deltaY*h;!jo()&&u.shiftKey&&s!==Xn.Vertical&&(m=u.deltaY*h,g=0),r.translateBy(n,-(m/p)*a,-(g/p)*a,{internal:!0});const b=ui(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,b),e.panScrollTimeout=setTimeout(()=>{d?.(u,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(u,b))}}function cQ({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const a=r.type==="wheel",i=!t&&a&&!r.ctrlKey,l=Cr(r,e);if(r.ctrlKey&&a&&l&&r.preventDefault(),i||l)return null;r.preventDefault(),n.call(this,r,s)}}function dQ({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;const s=ui(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=s,r.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(r.sourceEvent,s)}}function uQ({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return a=>{e.usedRightMouseButton=!!(n&&Z1(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),s&&!a.sourceEvent?.internal&&s?.(a.sourceEvent,ui(a.transform))}}function pQ({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:a}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&Z1(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&a(i.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const l=ui(i.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(i.sourceEvent,l)},n?150:0)}}}function fQ({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:a,userSelectionActive:i,noWheelClassName:l,noPanClassName:c,lib:d,connectionInProgress:u}){return p=>{const h=e||t,m=n&&p.ctrlKey,g=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(Cr(p,`${d}-flow__node`)||Cr(p,`${d}-flow__edge`)))return!0;if(!r&&!h&&!s&&!a&&!n||i||u&&!g||Cr(p,l)&&g||Cr(p,c)&&(!g||s&&g&&!e)||!n&&p.ctrlKey&&g)return!1;if(!n&&p.type==="touchstart"&&p.touches?.length>1)return p.preventDefault(),!1;if(!h&&!s&&!m&&g||!r&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(r)&&!r.includes(p.button)&&p.type==="mousedown")return!1;const b=Array.isArray(r)&&r.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||g)&&b}}function hQ({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,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},u=e.getBoundingClientRect(),p=S1().scaleExtent([t,n]).translateExtent(r),h=ht(e).call(p);w({x:s.x,y:s.y,zoom:Br(s.zoom,t,n)},[[0,0],[u.width,u.height]],r);const m=h.on("wheel.zoom"),g=h.on("dblclick.zoom");p.wheelDelta(X1);function b(P,B){return h?new Promise(R=>{p?.interpolate(B?.interpolate==="linear"?So:Gs).transform(fl(h,B?.duration,B?.ease,()=>R(!0)),P)}):Promise.resolve(!1)}function x({noWheelClassName:P,noPanClassName:B,onPaneContextMenu:R,userSelectionActive:M,panOnScroll:D,panOnDrag:T,panOnScrollMode:L,panOnScrollSpeed:O,preventScrolling:F,zoomOnPinch:j,zoomOnScroll:V,zoomOnDoubleClick:$,zoomActivationKeyPressed:q,lib:G,onTransformChange:Z,connectionInProgress:oe,paneClickDistance:ne,selectionOnDrag:X}){M&&!d.isZoomingOrPanning&&y();const re=D&&!q&&!M;p.clickDistance(X?1/0:!Ot(ne)||ne<0?0:ne);const be=re?lQ({zoomPanValues:d,noWheelClassName:P,d3Selection:h,d3Zoom:p,panOnScrollMode:L,panOnScrollSpeed:O,zoomOnPinch:j,onPanZoomStart:i,onPanZoom:a,onPanZoomEnd:l}):cQ({noWheelClassName:P,preventScrolling:F,d3ZoomHandler:m});if(h.on("wheel.zoom",be,{passive:!1}),!M){const W=dQ({zoomPanValues:d,onDraggingChange:c,onPanZoomStart:i});p.on("start",W);const ee=uQ({zoomPanValues:d,panOnDrag:T,onPaneContextMenu:!!R,onPanZoom:a,onTransformChange:Z});p.on("zoom",ee);const ae=pQ({zoomPanValues:d,panOnDrag:T,panOnScroll:D,onPaneContextMenu:R,onPanZoomEnd:l,onDraggingChange:c});p.on("end",ae)}const J=fQ({zoomActivationKeyPressed:q,panOnDrag:T,zoomOnScroll:V,panOnScroll:D,zoomOnDoubleClick:$,zoomOnPinch:j,userSelectionActive:M,noPanClassName:B,noWheelClassName:P,lib:G,connectionInProgress:oe});p.filter(J),$?h.on("dblclick.zoom",g):h.on("dblclick.zoom",null)}function y(){p.on("zoom",null)}async function w(P,B,R){const M=pl(P),D=p?.constrain()(M,B,R);return D&&await b(D),new Promise(T=>T(D))}async function v(P,B){const R=pl(P);return await b(R,B),new Promise(M=>M(R))}function N(P){if(h){const B=pl(P),R=h.property("__zoom");(R.k!==P.zoom||R.x!==P.x||R.y!==P.y)&&p?.transform(h,B,null,{sync:!0})}}function k(){const P=h?k1(h.node()):{x:0,y:0,k:1};return{x:P.x,y:P.y,zoom:P.k}}function C(P,B){return h?new Promise(R=>{p?.interpolate(B?.interpolate==="linear"?So:Gs).scaleTo(fl(h,B?.duration,B?.ease,()=>R(!0)),P)}):Promise.resolve(!1)}function E(P,B){return h?new Promise(R=>{p?.interpolate(B?.interpolate==="linear"?So:Gs).scaleBy(fl(h,B?.duration,B?.ease,()=>R(!0)),P)}):Promise.resolve(!1)}function I(P){p?.scaleExtent(P)}function A(P){p?.translateExtent(P)}function z(P){const B=!Ot(P)||P<0?0:P;p?.clickDistance(B)}return{update:x,destroy:y,setViewport:v,setViewportConstrained:w,getViewport:k,scaleTo:C,scaleBy:E,setScaleExtent:I,setTranslateExtent:A,syncViewport:N,setClickDistance:z}}var jr;(function(e){e.Line="line",e.Handle="handle"})(jr||(jr={}));function mQ({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:a}){const i=e-t,l=n-r,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 ph(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:s}}function Cn(e,t){return Math.max(0,t-e)}function Mn(e,t){return Math.max(0,e-t)}function Rs(e,t,n){return Math.max(0,t-e,e-n)}function fh(e,t){return e?!t:t}function gQ(e,t,n,r,s,a,i,l){let{affectsX:c,affectsY:d}=t;const{isHorizontal:u,isVertical:p}=t,h=u&&p,{xSnapped:m,ySnapped:g}=n,{minWidth:b,maxWidth:x,minHeight:y,maxHeight:w}=r,{x:v,y:N,width:k,height:C,aspectRatio:E}=e;let I=Math.floor(u?m-e.pointerX:0),A=Math.floor(p?g-e.pointerY:0);const z=k+(c?-I:I),P=C+(d?-A:A),B=-a[0]*k,R=-a[1]*C;let M=Rs(z,b,x),D=Rs(P,y,w);if(i){let O=0,F=0;c&&I<0?O=Cn(v+I+B,i[0][0]):!c&&I>0&&(O=Mn(v+z+B,i[1][0])),d&&A<0?F=Cn(N+A+R,i[0][1]):!d&&A>0&&(F=Mn(N+P+R,i[1][1])),M=Math.max(M,O),D=Math.max(D,F)}if(l){let O=0,F=0;c&&I>0?O=Mn(v+I,l[0][0]):!c&&I<0&&(O=Cn(v+z,l[1][0])),d&&A>0?F=Mn(N+A,l[0][1]):!d&&A<0&&(F=Cn(N+P,l[1][1])),M=Math.max(M,O),D=Math.max(D,F)}if(s){if(u){const O=Rs(z/E,y,w)*E;if(M=Math.max(M,O),i){let F=0;!c&&!d||c&&!d&&h?F=Mn(N+R+z/E,i[1][1])*E:F=Cn(N+R+(c?I:-I)/E,i[0][1])*E,M=Math.max(M,F)}if(l){let F=0;!c&&!d||c&&!d&&h?F=Cn(N+z/E,l[1][1])*E:F=Mn(N+(c?I:-I)/E,l[0][1])*E,M=Math.max(M,F)}}if(p){const O=Rs(P*E,b,x)/E;if(D=Math.max(D,O),i){let F=0;!c&&!d||d&&!c&&h?F=Mn(v+P*E+B,i[1][0])/E:F=Cn(v+(d?A:-A)*E+B,i[0][0])/E,D=Math.max(D,F)}if(l){let F=0;!c&&!d||d&&!c&&h?F=Cn(v+P*E,l[1][0])/E:F=Mn(v+(d?A:-A)*E,l[0][0])/E,D=Math.max(D,F)}}}A=A+(A<0?D:-D),I=I+(I<0?M:-M),s&&(h?z>P*E?A=(fh(c,d)?-I:I)/E:I=(fh(c,d)?-A:A)*E:u?(A=I/E,d=c):(I=A*E,c=d));const T=c?v+I:v,L=d?N+A:N;return{width:k+(c?-I:I),height:C+(d?-A:A),x:a[0]*I*(c?-1:1)+T,y:a[1]*A*(d?-1:1)+L}}const J1={width:0,height:0,x:0,y:0},bQ={...J1,pointerX:0,pointerY:0,aspectRatio:1};function xQ(e){return[[0,0],[e.measured.width,e.measured.height]]}function yQ(e,t,n){const r=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[[r-l,s-c],[r+a-l,s+i-c]]}function vQ({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const a=ht(e);let i={controlDirection:ph("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:u,keepAspectRatio:p,resizeDirection:h,onResizeStart:m,onResize:g,onResizeEnd:b,shouldResize:x}){let y={...J1},w={...bQ};i={boundaries:u,resizeDirection:h,keepAspectRatio:p,controlDirection:ph(d)};let v,N=null,k=[],C,E,I,A=!1;const z=c1().on("start",P=>{const{nodeLookup:B,transform:R,snapGrid:M,snapToGrid:D,nodeOrigin:T,paneDomNode:L}=n();if(v=B.get(t),!v)return;N=L?.getBoundingClientRect()??null;const{xSnapped:O,ySnapped:F}=Co(P.sourceEvent,{transform:R,snapGrid:M,snapToGrid:D,containerBounds:N});y={width:v.measured.width??0,height:v.measured.height??0,x:v.position.x??0,y:v.position.y??0},w={...y,pointerX:O,pointerY:F,aspectRatio:y.width/y.height},C=void 0,v.parentId&&(v.extent==="parent"||v.expandParent)&&(C=B.get(v.parentId),E=C&&v.extent==="parent"?xQ(C):void 0),k=[],I=void 0;for(const[j,V]of B)if(V.parentId===t&&(k.push({id:j,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const $=yQ(V,v,V.origin??T);I?I=[[Math.min($[0][0],I[0][0]),Math.min($[0][1],I[0][1])],[Math.max($[1][0],I[1][0]),Math.max($[1][1],I[1][1])]]:I=$}m?.(P,{...y})}).on("drag",P=>{const{transform:B,snapGrid:R,snapToGrid:M,nodeOrigin:D}=n(),T=Co(P.sourceEvent,{transform:B,snapGrid:R,snapToGrid:M,containerBounds:N}),L=[];if(!v)return;const{x:O,y:F,width:j,height:V}=y,$={},q=v.origin??D,{width:G,height:Z,x:oe,y:ne}=gQ(w,i.controlDirection,T,i.boundaries,i.keepAspectRatio,q,E,I),X=G!==j,re=Z!==V,be=oe!==O&&X,J=ne!==F&&re;if(!be&&!J&&!X&&!re)return;if((be||J||q[0]===1||q[1]===1)&&($.x=be?oe:y.x,$.y=J?ne:y.y,y.x=$.x,y.y=$.y,k.length>0)){const fe=oe-O,ge=ne-F;for(const Q of k)Q.position={x:Q.position.x-fe+q[0]*(G-j),y:Q.position.y-ge+q[1]*(Z-V)},L.push(Q)}if((X||re)&&($.width=X&&(!i.resizeDirection||i.resizeDirection==="horizontal")?G:y.width,$.height=re&&(!i.resizeDirection||i.resizeDirection==="vertical")?Z:y.height,y.width=$.width,y.height=$.height),C&&v.expandParent){const fe=q[0]*($.width??0);$.x&&$.x<fe&&(y.x=fe,w.x=w.x-($.x-fe));const ge=q[1]*($.height??0);$.y&&$.y<ge&&(y.y=ge,w.y=w.y-($.y-ge))}const W=mQ({width:y.width,prevWidth:j,height:y.height,prevHeight:V,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),ee={...y,direction:W};x?.(P,ee)!==!1&&(A=!0,g?.(P,ee),r($,L))}).on("end",P=>{A&&(b?.(P,{...y}),s?.({...y}),A=!1)});a.call(z)}function c(){a.on(".drag",null)}return{update:l,destroy:c}}var ew={exports:{}},tw={};/**
|
|
1143
|
-
* @license React
|
|
1144
|
-
* use-sync-external-store-shim/with-selector.production.js
|
|
1145
|
-
*
|
|
1146
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1147
|
-
*
|
|
1148
|
-
* This source code is licensed under the MIT license found in the
|
|
1149
|
-
* LICENSE file in the root directory of this source tree.
|
|
1150
|
-
*/var pi=mm,wQ=yv;function NQ(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var kQ=typeof Object.is=="function"?Object.is:NQ,SQ=wQ.useSyncExternalStore,CQ=pi.useRef,MQ=pi.useEffect,EQ=pi.useMemo,IQ=pi.useDebugValue;tw.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var a=CQ(null);if(a.current===null){var i={hasValue:!1,value:null};a.current=i}else i=a.current;a=EQ(function(){function c(m){if(!d){if(d=!0,u=m,m=r(m),s!==void 0&&i.hasValue){var g=i.value;if(s(g,m))return p=g}return p=m}if(g=p,kQ(u,m))return g;var b=r(m);return s!==void 0&&s(g,b)?(u=m,g):(u=m,p=b)}var d=!1,u,p,h=n===void 0?null:n;return[function(){return c(t())},h===null?void 0:function(){return c(h())}]},[t,n,r,s]);var l=SQ(e,a[0],a[1]);return MQ(function(){i.hasValue=!0,i.value=l},[l]),IQ(l),l};ew.exports=tw;var AQ=ew.exports;const PQ=s2(AQ),_Q={},hh=e=>{let t;const n=new Set,r=(u,p)=>{const h=typeof u=="function"?u(t):u;if(!Object.is(h,t)){const m=t;t=p??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(g=>g(t,m))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>d,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(_Q?"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(r,s,c);return c},$Q=e=>e?hh(e):hh,{useDebugValue:DQ}=Ge,{useSyncExternalStoreWithSelector:TQ}=PQ,LQ=e=>e;function nw(e,t=LQ,n){const r=TQ(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return DQ(r),r}const mh=(e,t)=>{const n=$Q(e),r=(s,a=t)=>nw(n,s,a);return Object.assign(r,n),r},RQ=(e,t)=>e?mh(e,t):mh;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[r,s]of e)if(!Object.is(s,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const fi=ze(null),OQ=fi.Provider,rw=en.error001();function De(e,t){const n=ve(fi);if(n===null)throw new Error(rw);return nw(n,e,t)}function qe(){const e=ve(fi);if(e===null)throw new Error(rw);return H(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const gh={display:"none"},BQ={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},ow="react-flow__node-desc",sw="react-flow__edge-desc",zQ="react-flow__aria-live",FQ=e=>e.ariaLiveMessage,jQ=e=>e.ariaLabelConfig;function VQ({rfId:e}){const t=De(FQ);return o("div",{id:`${zQ}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:BQ,children:t})}function HQ({rfId:e,disableKeyboardA11y:t}){const n=De(jQ);return f(me,{children:[o("div",{id:`${ow}-${e}`,style:gh,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o("div",{id:`${sw}-${e}`,style:gh,children:n["edge.a11yDescription.default"]}),!t&&o(VQ,{rfId:e})]})}const hi=Ue(({position:e="top-left",children:t,className:n,style:r,...s},a)=>{const i=`${e}`.split("-");return o("div",{className:We(["react-flow__panel",n,...i]),style:r,ref:a,...s,children:t})});hi.displayName="Panel";function qQ({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:o(hi,{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:o("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const UQ=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},Os=e=>e.id;function QQ(e,t){return Ve(e.selectedNodes.map(Os),t.selectedNodes.map(Os))&&Ve(e.selectedEdges.map(Os),t.selectedEdges.map(Os))}function GQ({onSelectionChange:e}){const t=qe(),{selectedNodes:n,selectedEdges:r}=De(UQ,QQ);return Y(()=>{const s={nodes:n,edges:r};e?.(s),t.getState().onSelectionChangeHandlers.forEach(a=>a(s))},[n,r,e]),null}const KQ=e=>!!e.onSelectionChangeHandlers;function WQ({onSelectionChange:e}){const t=De(KQ);return e||t?o(GQ,{onSelectionChange:e}):null}const vc=typeof window<"u"?Aa:Y,aw=[0,0],YQ={x:0,y:0,zoom:1},ZQ=["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"],bh=[...ZQ,"rfId"],XQ=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}),xh={translateExtent:Bo,nodeOrigin:aw,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function JQ(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:a,setNodeExtent:i,reset:l,setDefaultNodesAndEdges:c}=De(XQ,Ve),d=qe();vc(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=xh,l()}),[]);const u=te(xh);return vc(()=>{for(const p of bh){const h=e[p],m=u.current[p];h!==m&&(typeof e[p]>"u"||(p==="nodes"?t(h):p==="edges"?n(h):p==="minZoom"?r(h):p==="maxZoom"?s(h):p==="translateExtent"?a(h):p==="nodeExtent"?i(h):p==="ariaLabelConfig"?d.setState({ariaLabelConfig:$U(h)}):p==="fitView"?d.setState({fitViewQueued:h}):p==="fitViewOptions"?d.setState({fitViewOptions:h}):d.setState({[p]:h})))}u.current=e},bh.map(p=>e[p])),null}function yh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function eG(e){const[t,n]=_(e==="system"?null:e);return Y(()=>{if(e!=="system"){n(e);return}const r=yh(),s=()=>n(r?.matches?"dark":"light");return s(),r?.addEventListener("change",s),()=>{r?.removeEventListener("change",s)}},[e]),t!==null?t:yh()?.matches?"dark":"light"}const vh=typeof document<"u"?document:null;function Vo(e=null,t={target:vh,actInsideInputWithModifier:!0}){const[n,r]=_(!1),s=te(!1),a=te(new Set([])),[i,l]=H(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",`
|
|
1151
|
-
`).replace(`
|
|
1152
|
-
|
|
1153
|
-
`,`
|
|
1154
|
-
+`).split(`
|
|
1155
|
-
`)),u=d.reduce((p,h)=>p.concat(...h),[]);return[d,u]}return[[],[]]},[e]);return Y(()=>{const c=t?.target??vh,d=t?.actInsideInputWithModifier??!0;if(e!==null){const u=m=>{if(s.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!s.current||s.current&&!d)&&O1(m))return!1;const b=Nh(m.code,l);if(a.current.add(m[b]),wh(i,a.current,!1)){const x=m.composedPath?.()?.[0]||m.target,y=x?.nodeName==="BUTTON"||x?.nodeName==="A";t.preventDefault!==!1&&(s.current||!y)&&m.preventDefault(),r(!0)}},p=m=>{const g=Nh(m.code,l);wh(i,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(m[g]),m.key==="Meta"&&a.current.clear(),s.current=!1},h=()=>{a.current.clear(),r(!1)};return c?.addEventListener("keydown",u),c?.addEventListener("keyup",p),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{c?.removeEventListener("keydown",u),c?.removeEventListener("keyup",p),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[e,r]),n}function wh(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function Nh(e,t){return t.includes(e)?"code":"key"}const tG=()=>{const e=qe();return H(()=>({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:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,a],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:s,minZoom:a,maxZoom:i,panZoom:l}=e.getState(),c=pu(t,r,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:r,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},u=n.snapGrid??s,p=n.snapToGrid??a;return ls(d,r,p,u)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:a}=r.getBoundingClientRect(),i=Sa(t,n);return{x:i.x+s,y:i.y+a}}}),[])};function iw(e,t){const n=[],r=new Map,s=[];for(const a of e)if(a.type==="add"){s.push(a);continue}else if(a.type==="remove"||a.type==="replace")r.set(a.id,[a]);else{const i=r.get(a.id);i?i.push(a):r.set(a.id,[a])}for(const a of t){const i=r.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)nG(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 nG(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 rG(e,t){return iw(e,t)}function oG(e,t){return iw(e,t)}function Qn(e,t){return{id:e,type:"select",selected:t}}function Mr(e,t=new Set,n=!1){const r=[];for(const[s,a]of e){const i=t.has(s);!(a.selected===void 0&&!i)&&a.selected!==i&&(n&&(a.selected=i),r.push(Qn(a.id,i)))}return r}function kh({items:e=[],lookup:t}){const n=[],r=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)r.get(s)===void 0&&n.push({id:s,type:"remove"});return n}function Sh(e){return{id:e.id,type:"remove"}}const Ch=e=>NU(e),sG=e=>A1(e);function lw(e){return Ue(e)}function Mh(e){const[t,n]=_(BigInt(0)),[r]=_(()=>aG(()=>n(s=>s+BigInt(1))));return vc(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function aG(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const cw=ze(null);function iG({children:e}){const t=qe(),n=U(l=>{const{nodes:c=[],setNodes:d,hasDefaultNodes:u,onNodesChange:p,nodeLookup:h,fitViewQueued:m,onNodesChangeMiddlewareMap:g}=t.getState();let b=c;for(const y of l)b=typeof y=="function"?y(b):y;let x=kh({items:b,lookup:h});for(const y of g.values())x=y(x);u&&d(b),x.length>0?p?.(x):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:w,setNodes:v}=t.getState();y&&v(w)})},[]),r=Mh(n),s=U(l=>{const{edges:c=[],setEdges:d,hasDefaultEdges:u,onEdgesChange:p,edgeLookup:h}=t.getState();let m=c;for(const g of l)m=typeof g=="function"?g(m):g;u?d(m):p&&p(kh({items:m,lookup:h}))},[]),a=Mh(s),i=H(()=>({nodeQueue:r,edgeQueue:a}),[]);return o(cw.Provider,{value:i,children:e})}function lG(){const e=ve(cw);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const cG=e=>!!e.panZoom;function yu(){const e=tG(),t=qe(),n=lG(),r=De(cG),s=H(()=>{const a=p=>t.getState().nodeLookup.get(p),i=p=>{n.nodeQueue.push(p)},l=p=>{n.edgeQueue.push(p)},c=p=>{const{nodeLookup:h,nodeOrigin:m}=t.getState(),g=Ch(p)?p:h.get(p.id),b=g.parentId?L1(g.position,g.measured,g.parentId,h,m):g.position,x={...g,position:b,width:g.measured?.width??g.width,height:g.measured?.height??g.height};return zr(x)},d=(p,h,m={replace:!1})=>{i(g=>g.map(b=>{if(b.id===p){const x=typeof h=="function"?h(b):h;return m.replace&&Ch(x)?x:{...b,...x}}return b}))},u=(p,h,m={replace:!1})=>{l(g=>g.map(b=>{if(b.id===p){const x=typeof h=="function"?h(b):h;return m.replace&&sG(x)?x:{...b,...x}}return b}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>a(p)?.internals.userNode,getInternalNode:a,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(h=>({...h}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:i,setEdges:l,addNodes:p=>{const h=Array.isArray(p)?p:[p];n.nodeQueue.push(m=>[...m,...h])},addEdges:p=>{const h=Array.isArray(p)?p:[p];n.edgeQueue.push(m=>[...m,...h])},toObject:()=>{const{nodes:p=[],edges:h=[],transform:m}=t.getState(),[g,b,x]=m;return{nodes:p.map(y=>({...y})),edges:h.map(y=>({...y})),viewport:{x:g,y:b,zoom:x}}},deleteElements:async({nodes:p=[],edges:h=[]})=>{const{nodes:m,edges:g,onNodesDelete:b,onEdgesDelete:x,triggerNodeChanges:y,triggerEdgeChanges:w,onDelete:v,onBeforeDelete:N}=t.getState(),{nodes:k,edges:C}=await EU({nodesToRemove:p,edgesToRemove:h,nodes:m,edges:g,onBeforeDelete:N}),E=C.length>0,I=k.length>0;if(E){const A=C.map(Sh);x?.(C),w(A)}if(I){const A=k.map(Sh);b?.(k),y(A)}return(I||E)&&v?.({nodes:k,edges:C}),{deletedNodes:k,deletedEdges:C}},getIntersectingNodes:(p,h=!0,m)=>{const g=th(p),b=g?p:c(p),x=m!==void 0;return b?(m||t.getState().nodes).filter(y=>{const w=t.getState().nodeLookup.get(y.id);if(w&&!g&&(y.id===p.id||!w.internals.positionAbsolute))return!1;const v=zr(x?y:w),N=Fo(v,b);return h&&N>0||N>=v.width*v.height||N>=b.width*b.height}):[]},isNodeIntersecting:(p,h,m=!0)=>{const b=th(p)?p:c(p);if(!b)return!1;const x=Fo(b,h);return m&&x>0||x>=h.width*h.height||x>=b.width*b.height},updateNode:d,updateNodeData:(p,h,m={replace:!1})=>{d(p,g=>{const b=typeof h=="function"?h(g):h;return m.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},m)},updateEdge:u,updateEdgeData:(p,h,m={replace:!1})=>{u(p,g=>{const b=typeof h=="function"?h(g):h;return m.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},m)},getNodesBounds:p=>{const{nodeLookup:h,nodeOrigin:m}=t.getState();return kU(p,{nodeLookup:h,nodeOrigin:m})},getHandleConnections:({type:p,id:h,nodeId:m})=>Array.from(t.getState().connectionLookup.get(`${m}-${p}${h?`-${h}`:""}`)?.values()??[]),getNodeConnections:({type:p,handleId:h,nodeId:m})=>Array.from(t.getState().connectionLookup.get(`${m}${p?h?`-${p}-${h}`:`-${p}`:""}`)?.values()??[]),fitView:async p=>{const h=t.getState().fitViewResolver??_U();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:h}),n.nodeQueue.push(m=>[...m]),h.promise}}},[]);return H(()=>({...s,...e,viewportInitialized:r}),[r])}const Eh=e=>e.selected,dG=typeof window<"u"?window:void 0;function uG({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=qe(),{deleteElements:r}=yu(),s=Vo(e,{actInsideInputWithModifier:!1}),a=Vo(t,{target:dG});Y(()=>{if(s){const{edges:i,nodes:l}=n.getState();r({nodes:l.filter(Eh),edges:i.filter(Eh)}),n.setState({nodesSelectionActive:!1})}},[s]),Y(()=>{n.setState({multiSelectionActive:a})},[a])}function pG(e){const t=qe();Y(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const r=fu(e.current);(r.height===0||r.width===0)&&t.getState().onError?.("004",en.error004()),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const mi={position:"absolute",width:"100%",height:"100%",top:0,left:0},fG=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function hG({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:a=Xn.Free,zoomOnDoubleClick:i=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:d,minZoom:u,maxZoom:p,zoomActivationKeyCode:h,preventScrolling:m=!0,children:g,noWheelClassName:b,noPanClassName:x,onViewportChange:y,isControlledViewport:w,paneClickDistance:v,selectionOnDrag:N}){const k=qe(),C=te(null),{userSelectionActive:E,lib:I,connectionInProgress:A}=De(fG,Ve),z=Vo(h),P=te();pG(C);const B=U(R=>{y?.({x:R[0],y:R[1],zoom:R[2]}),w||k.setState({transform:R})},[y,w]);return Y(()=>{if(C.current){P.current=hQ({domNode:C.current,minZoom:u,maxZoom:p,translateExtent:d,viewport:c,onDraggingChange:T=>k.setState(L=>L.paneDragging===T?L:{paneDragging:T}),onPanZoomStart:(T,L)=>{const{onViewportChangeStart:O,onMoveStart:F}=k.getState();F?.(T,L),O?.(L)},onPanZoom:(T,L)=>{const{onViewportChange:O,onMove:F}=k.getState();F?.(T,L),O?.(L)},onPanZoomEnd:(T,L)=>{const{onViewportChangeEnd:O,onMoveEnd:F}=k.getState();F?.(T,L),O?.(L)}});const{x:R,y:M,zoom:D}=P.current.getViewport();return k.setState({panZoom:P.current,transform:[R,M,D],domNode:C.current.closest(".react-flow")}),()=>{P.current?.destroy()}}},[]),Y(()=>{P.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:a,zoomOnDoubleClick:i,panOnDrag:l,zoomActivationKeyPressed:z,preventScrolling:m,noPanClassName:x,userSelectionActive:E,noWheelClassName:b,lib:I,onTransformChange:B,connectionInProgress:A,selectionOnDrag:N,paneClickDistance:v})},[e,t,n,r,s,a,i,l,z,m,x,E,b,I,B,A,N,v]),o("div",{className:"react-flow__renderer",ref:C,style:mi,children:g})}const mG=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function gG(){const{userSelectionActive:e,userSelectionRect:t}=De(mG,Ve);return e&&t?o("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 hl=(e,t)=>n=>{n.target===t.current&&e?.(n)},bG=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function xG({isSelecting:e,selectionKeyPressed:t,selectionMode:n=zo.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:a,onSelectionStart:i,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:d,onPaneScroll:u,onPaneMouseEnter:p,onPaneMouseMove:h,onPaneMouseLeave:m,children:g}){const b=qe(),{userSelectionActive:x,elementsSelectable:y,dragging:w,connectionInProgress:v}=De(bG,Ve),N=y&&(e||x),k=te(null),C=te(),E=te(new Set),I=te(new Set),A=te(!1),z=O=>{if(A.current||v){A.current=!1;return}c?.(O),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},P=O=>{if(Array.isArray(r)&&r?.includes(2)){O.preventDefault();return}d?.(O)},B=u?O=>u(O):void 0,R=O=>{A.current&&(O.stopPropagation(),A.current=!1)},M=O=>{const{domNode:F}=b.getState();if(C.current=F?.getBoundingClientRect(),!C.current)return;const j=O.target===k.current;if(!j&&!!O.target.closest(".nokey")||!e||!(a&&j||t)||O.button!==0||!O.isPrimary)return;O.target?.setPointerCapture?.(O.pointerId),A.current=!1;const{x:q,y:G}=Bt(O.nativeEvent,C.current);b.setState({userSelectionRect:{width:0,height:0,startX:q,startY:G,x:q,y:G}}),j||(O.stopPropagation(),O.preventDefault())},D=O=>{const{userSelectionRect:F,transform:j,nodeLookup:V,edgeLookup:$,connectionLookup:q,triggerNodeChanges:G,triggerEdgeChanges:Z,defaultEdgeOptions:oe,resetSelectedElements:ne}=b.getState();if(!C.current||!F)return;const{x:X,y:re}=Bt(O.nativeEvent,C.current),{startX:be,startY:J}=F;if(!A.current){const ge=t?0:s;if(Math.hypot(X-be,re-J)<=ge)return;ne(),i?.(O)}A.current=!0;const W={startX:be,startY:J,x:X<be?X:be,y:re<J?re:J,width:Math.abs(X-be),height:Math.abs(re-J)},ee=E.current,ae=I.current;E.current=new Set(uu(V,W,j,n===zo.Partial,!0).map(ge=>ge.id)),I.current=new Set;const fe=oe?.selectable??!0;for(const ge of E.current){const Q=q.get(ge);if(Q)for(const{edgeId:le}of Q.values()){const ue=$.get(le);ue&&(ue.selectable??fe)&&I.current.add(le)}}if(!nh(ee,E.current)){const ge=Mr(V,E.current,!0);G(ge)}if(!nh(ae,I.current)){const ge=Mr($,I.current);Z(ge)}b.setState({userSelectionRect:W,userSelectionActive:!0,nodesSelectionActive:!1})},T=O=>{O.button===0&&(O.target?.releasePointerCapture?.(O.pointerId),!x&&O.target===k.current&&b.getState().userSelectionRect&&z?.(O),b.setState({userSelectionActive:!1,userSelectionRect:null}),A.current&&(l?.(O),b.setState({nodesSelectionActive:E.current.size>0})))},L=r===!0||Array.isArray(r)&&r.includes(0);return f("div",{className:We(["react-flow__pane",{draggable:L,dragging:w,selection:e}]),onClick:N?void 0:hl(z,k),onContextMenu:hl(P,k),onWheel:hl(B,k),onPointerEnter:N?void 0:p,onPointerMove:N?D:h,onPointerUp:N?T:void 0,onPointerDownCapture:N?M:void 0,onClickCapture:N?R:void 0,onPointerLeave:m,ref:k,style:mi,children:[g,o(gG,{})]})}function wc({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:a,multiSelectionActive:i,nodeLookup:l,onError:c}=t.getState(),d=l.get(e);if(!d){c?.("012",en.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&i)&&(a({nodes:[d],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):s([e])}function dw({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:a,nodeClickDistance:i}){const l=qe(),[c,d]=_(!1),u=te();return Y(()=>{u.current=eQ({getStoreItems:()=>l.getState(),onNodeMouseDown:p=>{wc({id:p,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),Y(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:s,nodeClickDistance:i}),()=>{u.current?.destroy()}},[n,r,t,a,e,s,i]),c}const yG=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function uw(){const e=qe();return U(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:a,nodesDraggable:i,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:u}=e.getState(),p=new Map,h=yG(i),m=s?a[0]:5,g=s?a[1]:5,b=n.direction.x*m*n.factor,x=n.direction.y*g*n.factor;for(const[,y]of d){if(!h(y))continue;let w={x:y.internals.positionAbsolute.x+b,y:y.internals.positionAbsolute.y+x};s&&(w=is(w,a));const{position:v,positionAbsolute:N}=P1({nodeId:y.id,nextPosition:w,nodeLookup:d,nodeExtent:r,nodeOrigin:u,onError:l});y.position=v,y.internals.positionAbsolute=N,p.set(y.id,y)}c(p)},[])}const vu=ze(null),vG=vu.Provider;vu.Consumer;const pw=()=>ve(vu),wG=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),NG=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:a,connection:i}=r,{fromHandle:l,toHandle:c,isValid:d}=i,u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:l?.nodeId===e&&l?.id===t&&l?.type===n,connectingTo:u,clickConnecting:s?.nodeId===e&&s?.id===t&&s?.type===n,isPossibleEndHandle:a===Or.Strict?l?.type!==n:e!==l?.nodeId||t!==l?.id,connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:u&&d}};function kG({type:e="source",position:t=we.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:a=!0,id:i,onConnect:l,children:c,className:d,onMouseDown:u,onTouchStart:p,...h},m){const g=i||null,b=e==="target",x=qe(),y=pw(),{connectOnClick:w,noPanClassName:v,rfId:N}=De(wG,Ve),{connectingFrom:k,connectingTo:C,clickConnecting:E,isPossibleEndHandle:I,connectionInProcess:A,clickConnectionInProcess:z,valid:P}=De(NG(y,g,e),Ve);y||x.getState().onError?.("010",en.error010());const B=D=>{const{defaultEdgeOptions:T,onConnect:L,hasDefaultEdges:O}=x.getState(),F={...T,...D};if(O){const{edges:j,setEdges:V}=x.getState();V(BU(F,j))}L?.(F),l?.(F)},R=D=>{if(!y)return;const T=B1(D.nativeEvent);if(s&&(T&&D.button===0||!T)){const L=x.getState();yc.onPointerDown(D.nativeEvent,{handleDomNode:D.currentTarget,autoPanOnConnect:L.autoPanOnConnect,connectionMode:L.connectionMode,connectionRadius:L.connectionRadius,domNode:L.domNode,nodeLookup:L.nodeLookup,lib:L.lib,isTarget:b,handleId:g,nodeId:y,flowId:L.rfId,panBy:L.panBy,cancelConnection:L.cancelConnection,onConnectStart:L.onConnectStart,onConnectEnd:(...O)=>x.getState().onConnectEnd?.(...O),updateConnection:L.updateConnection,onConnect:B,isValidConnection:n||((...O)=>x.getState().isValidConnection?.(...O)??!0),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:L.autoPanSpeed,dragThreshold:L.connectionDragThreshold})}T?u?.(D):p?.(D)},M=D=>{const{onClickConnectStart:T,onClickConnectEnd:L,connectionClickStartHandle:O,connectionMode:F,isValidConnection:j,lib:V,rfId:$,nodeLookup:q,connection:G}=x.getState();if(!y||!O&&!s)return;if(!O){T?.(D.nativeEvent,{nodeId:y,handleId:g,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const Z=R1(D.target),oe=n||j,{connection:ne,isValid:X}=yc.isValid(D.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:F,fromNodeId:O.nodeId,fromHandleId:O.id||null,fromType:O.type,isValidConnection:oe,flowId:$,doc:Z,lib:V,nodeLookup:q});X&&ne&&B(ne);const re=structuredClone(G);delete re.inProgress,re.toPosition=re.toHandle?re.toHandle.position:null,L?.(D,re),x.setState({connectionClickStartHandle:null})};return o("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${N}-${y}-${g}-${e}`,className:We(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",v,d,{source:!b,target:b,connectable:r,connectablestart:s,connectableend:a,clickconnecting:E,connectingfrom:k,connectingto:C,valid:P,connectionindicator:r&&(!A||I)&&(A||z?a:s)}]),onMouseDown:R,onTouchStart:R,onClick:w?M:void 0,ref:m,...h,children:c})}const Tn=He(lw(kG));function SG({data:e,isConnectable:t,sourcePosition:n=we.Bottom}){return f(me,{children:[e?.label,o(Tn,{type:"source",position:n,isConnectable:t})]})}function CG({data:e,isConnectable:t,targetPosition:n=we.Top,sourcePosition:r=we.Bottom}){return f(me,{children:[o(Tn,{type:"target",position:n,isConnectable:t}),e?.label,o(Tn,{type:"source",position:r,isConnectable:t})]})}function MG(){return null}function EG({data:e,isConnectable:t,targetPosition:n=we.Top}){return f(me,{children:[o(Tn,{type:"target",position:n,isConnectable:t}),e?.label]})}const Ca={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Ih={input:SG,default:CG,output:EG,group:MG};function IG(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 AG=e=>{const{width:t,height:n,x:r,y:s}=as(e.nodeLookup,{filter:a=>!!a.selected});return{width:Ot(t)?t:null,height:Ot(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${s}px)`}};function PG({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=qe(),{width:s,height:a,transformString:i,userSelectionActive:l}=De(AG,Ve),c=uw(),d=te(null);Y(()=>{n||d.current?.focus({preventScroll:!0})},[n]);const u=!l&&s!==null&&a!==null;if(dw({nodeRef:d,disabled:!u}),!u)return null;const p=e?m=>{const g=r.getState().nodes.filter(b=>b.selected);e(m,g)}:void 0,h=m=>{Object.prototype.hasOwnProperty.call(Ca,m.key)&&(m.preventDefault(),c({direction:Ca[m.key],factor:m.shiftKey?4:1}))};return o("div",{className:We(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:o("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:s,height:a}})})}const Ah=typeof window<"u"?window:void 0,_G=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function fw({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:i,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:d,selectionOnDrag:u,selectionMode:p,onSelectionStart:h,onSelectionEnd:m,multiSelectionKeyCode:g,panActivationKeyCode:b,zoomActivationKeyCode:x,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:v,panOnScroll:N,panOnScrollSpeed:k,panOnScrollMode:C,zoomOnDoubleClick:E,panOnDrag:I,defaultViewport:A,translateExtent:z,minZoom:P,maxZoom:B,preventScrolling:R,onSelectionContextMenu:M,noWheelClassName:D,noPanClassName:T,disableKeyboardA11y:L,onViewportChange:O,isControlledViewport:F}){const{nodesSelectionActive:j,userSelectionActive:V}=De(_G,Ve),$=Vo(d,{target:Ah}),q=Vo(b,{target:Ah}),G=q||I,Z=q||N,oe=u&&G!==!0,ne=$||V||oe;return uG({deleteKeyCode:c,multiSelectionKeyCode:g}),o(hG,{onPaneContextMenu:a,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:v,panOnScroll:Z,panOnScrollSpeed:k,panOnScrollMode:C,zoomOnDoubleClick:E,panOnDrag:!$&&G,defaultViewport:A,translateExtent:z,minZoom:P,maxZoom:B,zoomActivationKeyCode:x,preventScrolling:R,noWheelClassName:D,noPanClassName:T,onViewportChange:O,isControlledViewport:F,paneClickDistance:l,selectionOnDrag:oe,children:f(xG,{onSelectionStart:h,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:i,panOnDrag:G,isSelecting:!!ne,selectionMode:p,selectionKeyPressed:$,paneClickDistance:l,selectionOnDrag:oe,children:[e,j&&o(PG,{onSelectionContextMenu:M,noPanClassName:T,disableKeyboardA11y:L})]})})}fw.displayName="FlowRenderer";const $G=He(fw),DG=e=>t=>e?uu(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 TG(e){return De(U(DG(e),[e]),Ve)}const LG=e=>e.updateNodeInternals;function RG(){const e=De(LG),[t]=_(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const a=s.target.getAttribute("data-id");r.set(a,{id:a,nodeElement:s.target,force:!0})}),e(r)}));return Y(()=>()=>{t?.disconnect()},[t]),t}function OG({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=qe(),a=te(null),i=te(null),l=te(e.sourcePosition),c=te(e.targetPosition),d=te(t),u=n&&!!e.internals.handleBounds;return Y(()=>{a.current&&!e.hidden&&(!u||i.current!==a.current)&&(i.current&&r?.unobserve(i.current),r?.observe(a.current),i.current=a.current)},[u,e.hidden]),Y(()=>()=>{i.current&&(r?.unobserve(i.current),i.current=null)},[]),Y(()=>{if(a.current){const p=d.current!==t,h=l.current!==e.sourcePosition,m=c.current!==e.targetPosition;(p||h||m)&&(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 BG({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:a,onDoubleClick:i,nodesDraggable:l,elementsSelectable:c,nodesConnectable:d,nodesFocusable:u,resizeObserver:p,noDragClassName:h,noPanClassName:m,disableKeyboardA11y:g,rfId:b,nodeTypes:x,nodeClickDistance:y,onError:w}){const{node:v,internals:N,isParent:k}=De(X=>{const re=X.nodeLookup.get(e),be=X.parentLookup.has(e);return{node:re,internals:re.internals,isParent:be}},Ve);let C=v.type||"default",E=x?.[C]||Ih[C];E===void 0&&(w?.("003",en.error003(C)),C="default",E=x?.default||Ih.default);const I=!!(v.draggable||l&&typeof v.draggable>"u"),A=!!(v.selectable||c&&typeof v.selectable>"u"),z=!!(v.connectable||d&&typeof v.connectable>"u"),P=!!(v.focusable||u&&typeof v.focusable>"u"),B=qe(),R=T1(v),M=OG({node:v,nodeType:C,hasDimensions:R,resizeObserver:p}),D=dw({nodeRef:M,disabled:v.hidden||!I,noDragClassName:h,handleSelector:v.dragHandle,nodeId:e,isSelectable:A,nodeClickDistance:y}),T=uw();if(v.hidden)return null;const L=Nn(v),O=IG(v),F=A||I||t||n||r||s,j=n?X=>n(X,{...N.userNode}):void 0,V=r?X=>r(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,Z=X=>{const{selectNodesOnDrag:re,nodeDragThreshold:be}=B.getState();A&&(!re||!I||be>0)&&wc({id:e,store:B,nodeRef:M}),t&&t(X,{...N.userNode})},oe=X=>{if(!(O1(X.nativeEvent)||g)){if(C1.includes(X.key)&&A){const re=X.key==="Escape";wc({id:e,store:B,unselect:re,nodeRef:M})}else if(I&&v.selected&&Object.prototype.hasOwnProperty.call(Ca,X.key)){X.preventDefault();const{ariaLabelConfig:re}=B.getState();B.setState({ariaLiveMessage:re["node.a11yDescription.ariaLiveMessage"]({direction:X.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),T({direction:Ca[X.key],factor:X.shiftKey?4:1})}}},ne=()=>{if(g||!M.current?.matches(":focus-visible"))return;const{transform:X,width:re,height:be,autoPanOnNodeFocus:J,setCenter:W}=B.getState();if(!J)return;uu(new Map([[e,v]]),{x:0,y:0,width:re,height:be},X,!0).length>0||W(v.position.x+L.width/2,v.position.y+L.height/2,{zoom:X[2]})};return o("div",{className:We(["react-flow__node",`react-flow__node-${C}`,{[m]:I},v.className,{selected:v.selected,selectable:A,parent:k,draggable:I,dragging:D}]),ref:M,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:F?"all":"none",visibility:R?"visible":"hidden",...v.style,...O},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:j,onMouseMove:V,onMouseLeave:$,onContextMenu:q,onClick:Z,onDoubleClick:G,onKeyDown:P?oe:void 0,tabIndex:P?0:void 0,onFocus:P?ne:void 0,role:v.ariaRole??(P?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${ow}-${b}`,"aria-label":v.ariaLabel,...v.domAttributes,children:o(vG,{value:e,children:o(E,{id:e,data:v.data,type:C,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:v.selected??!1,selectable:A,draggable:I,deletable:v.deletable??!0,isConnectable:z,sourcePosition:v.sourcePosition,targetPosition:v.targetPosition,dragging:D,dragHandle:v.dragHandle,zIndex:N.z,parentId:v.parentId,...L})})})}var zG=He(BG);const FG=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function hw(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:a}=De(FG,Ve),i=TG(e.onlyRenderVisibleElements),l=RG();return o("div",{className:"react-flow__nodes",style:mi,children:i.map(c=>o(zG,{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:r,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:a},c))})}hw.displayName="NodeRenderer";const jG=He(hw);function VG(e){return De(U(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];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&&LU({sourceNode:a,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),Ve)}const HG=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return o("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},qG=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return o("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Ph={[Na.Arrow]:HG,[Na.ArrowClosed]:qG};function UG(e){const t=qe();return H(()=>Object.prototype.hasOwnProperty.call(Ph,e)?Ph[e]:(t.getState().onError?.("009",en.error009(e)),null),[e])}const QG=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:a="strokeWidth",strokeWidth:i,orient:l="auto-start-reverse"})=>{const c=UG(t);return c?o("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:l,refX:"0",refY:"0",children:o(c,{color:n,strokeWidth:i})}):null},mw=({defaultColor:e,rfId:t})=>{const n=De(a=>a.edges),r=De(a=>a.defaultEdgeOptions),s=H(()=>HU(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return s.length?o("svg",{className:"react-flow__marker","aria-hidden":"true",children:o("defs",{children:s.map(a=>o(QG,{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};mw.displayName="MarkerDefinitions";var GG=He(mw);function gw({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:a,labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...u}){const[p,h]=_({x:1,y:0,width:0,height:0}),m=We(["react-flow__edge-textwrapper",d]),g=te(null);return Y(()=>{if(g.current){const b=g.current.getBBox();h({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?f("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:m,visibility:p.width?"visible":"hidden",...u,children:[s&&o("rect",{width:p.width+2*i[0],x:-i[0],y:-i[1],height:p.height+2*i[1],className:"react-flow__edge-textbg",style:a,rx:l,ry:l}),o("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]}):null}gw.displayName="EdgeText";const KG=He(gw);function gi({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:d=20,...u}){return f(me,{children:[o("path",{...u,d:e,fill:"none",className:We(["react-flow__edge-path",u.className])}),d?o("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&Ot(t)&&Ot(n)?o(KG,{x:t,y:n,label:r,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function _h({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===we.Left||e===we.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function bw({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:r,targetY:s,targetPosition:a=we.Top}){const[i,l]=_h({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,d]=_h({pos:a,x1:r,y1:s,x2:e,y2:t}),[u,p,h,m]=z1({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:i,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${i},${l} ${c},${d} ${r},${s}`,u,p,h,m]}function xw(e){return He(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:a,sourcePosition:i,targetPosition:l,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:x,interactionWidth:y})=>{const[w,v,N]=bw({sourceX:n,sourceY:r,sourcePosition:i,targetX:s,targetY:a,targetPosition:l}),k=e.isInternal?void 0:t;return o(gi,{id:k,path:w,labelX:v,labelY:N,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:x,interactionWidth:y})})}const WG=xw({isInternal:!1}),yw=xw({isInternal:!0});WG.displayName="SimpleBezierEdge";yw.displayName="SimpleBezierEdgeInternal";function vw(e){return He(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:a,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:h,sourcePosition:m=we.Bottom,targetPosition:g=we.Top,markerEnd:b,markerStart:x,pathOptions:y,interactionWidth:w})=>{const[v,N,k]=gc({sourceX:n,sourceY:r,sourcePosition:m,targetX:s,targetY:a,targetPosition:g,borderRadius:y?.borderRadius,offset:y?.offset,stepPosition:y?.stepPosition}),C=e.isInternal?void 0:t;return o(gi,{id:C,path:v,labelX:N,labelY:k,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:h,markerEnd:b,markerStart:x,interactionWidth:w})})}const ww=vw({isInternal:!1}),Nw=vw({isInternal:!0});ww.displayName="SmoothStepEdge";Nw.displayName="SmoothStepEdgeInternal";function kw(e){return He(({id:t,...n})=>{const r=e.isInternal?void 0:t;return o(ww,{...n,id:r,pathOptions:H(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const YG=kw({isInternal:!1}),Sw=kw({isInternal:!0});YG.displayName="StepEdge";Sw.displayName="StepEdgeInternal";function Cw(e){return He(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:a,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:h,markerEnd:m,markerStart:g,interactionWidth:b})=>{const[x,y,w]=V1({sourceX:n,sourceY:r,targetX:s,targetY:a}),v=e.isInternal?void 0:t;return o(gi,{id:v,path:x,labelX:y,labelY:w,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:h,markerEnd:m,markerStart:g,interactionWidth:b})})}const ZG=Cw({isInternal:!1}),Mw=Cw({isInternal:!0});ZG.displayName="StraightEdge";Mw.displayName="StraightEdgeInternal";function Ew(e){return He(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:a,sourcePosition:i=we.Bottom,targetPosition:l=we.Top,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:x,pathOptions:y,interactionWidth:w})=>{const[v,N,k]=F1({sourceX:n,sourceY:r,sourcePosition:i,targetX:s,targetY:a,targetPosition:l,curvature:y?.curvature}),C=e.isInternal?void 0:t;return o(gi,{id:C,path:v,labelX:N,labelY:k,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:x,interactionWidth:w})})}const XG=Ew({isInternal:!1}),Iw=Ew({isInternal:!0});XG.displayName="BezierEdge";Iw.displayName="BezierEdgeInternal";const $h={default:Iw,straight:Mw,step:Sw,smoothstep:Nw,simplebezier:yw},Dh={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},JG=(e,t,n)=>n===we.Left?e-t:n===we.Right?e+t:e,eK=(e,t,n)=>n===we.Top?e-t:n===we.Bottom?e+t:e,Th="react-flow__edgeupdater";function Lh({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:a,onMouseOut:i,type:l}){return o("circle",{onMouseDown:s,onMouseEnter:a,onMouseOut:i,className:We([Th,`${Th}-${l}`]),cx:JG(t,r,e),cy:eK(n,r,e),r,stroke:"transparent",fill:"transparent"})}function tK({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:a,targetY:i,sourcePosition:l,targetPosition:c,onReconnect:d,onReconnectStart:u,onReconnectEnd:p,setReconnecting:h,setUpdateHover:m}){const g=qe(),b=(N,k)=>{if(N.button!==0)return;const{autoPanOnConnect:C,domNode:E,connectionMode:I,connectionRadius:A,lib:z,onConnectStart:P,cancelConnection:B,nodeLookup:R,rfId:M,panBy:D,updateConnection:T}=g.getState(),L=k.type==="target",O=(V,$)=>{h(!1),p?.(V,n,k.type,$)},F=V=>d?.(n,V),j=(V,$)=>{h(!0),u?.(N,n,k.type),P?.(V,$)};yc.onPointerDown(N.nativeEvent,{autoPanOnConnect:C,connectionMode:I,connectionRadius:A,domNode:E,handleId:k.id,nodeId:k.nodeId,nodeLookup:R,isTarget:L,edgeUpdaterType:k.type,lib:z,flowId:M,cancelConnection:B,panBy:D,isValidConnection:(...V)=>g.getState().isValidConnection?.(...V)??!0,onConnect:F,onConnectStart:j,onConnectEnd:(...V)=>g.getState().onConnectEnd?.(...V),onReconnectEnd:O,updateConnection:T,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},x=N=>b(N,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=N=>b(N,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),w=()=>m(!0),v=()=>m(!1);return f(me,{children:[(e===!0||e==="source")&&o(Lh,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:x,onMouseEnter:w,onMouseOut:v,type:"source"}),(e===!0||e==="target")&&o(Lh,{position:c,centerX:a,centerY:i,radius:t,onMouseDown:y,onMouseEnter:w,onMouseOut:v,type:"target"})]})}function nK({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:a,onContextMenu:i,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,reconnectRadius:u,onReconnect:p,onReconnectStart:h,onReconnectEnd:m,rfId:g,edgeTypes:b,noPanClassName:x,onError:y,disableKeyboardA11y:w}){let v=De(W=>W.edgeLookup.get(e));const N=De(W=>W.defaultEdgeOptions);v=N?{...N,...v}:v;let k=v.type||"default",C=b?.[k]||$h[k];C===void 0&&(y?.("011",en.error011(k)),k="default",C=b?.default||$h.default);const E=!!(v.focusable||t&&typeof v.focusable>"u"),I=typeof p<"u"&&(v.reconnectable||n&&typeof v.reconnectable>"u"),A=!!(v.selectable||r&&typeof v.selectable>"u"),z=te(null),[P,B]=_(!1),[R,M]=_(!1),D=qe(),{zIndex:T,sourceX:L,sourceY:O,targetX:F,targetY:j,sourcePosition:V,targetPosition:$}=De(U(W=>{const ee=W.nodeLookup.get(v.source),ae=W.nodeLookup.get(v.target);if(!ee||!ae)return{zIndex:v.zIndex,...Dh};const fe=VU({id:e,sourceNode:ee,targetNode:ae,sourceHandle:v.sourceHandle||null,targetHandle:v.targetHandle||null,connectionMode:W.connectionMode,onError:y});return{zIndex:TU({selected:v.selected,zIndex:v.zIndex,sourceNode:ee,targetNode:ae,elevateOnSelect:W.elevateEdgesOnSelect,zIndexMode:W.zIndexMode}),...fe||Dh}},[v.source,v.target,v.sourceHandle,v.targetHandle,v.selected,v.zIndex]),Ve),q=H(()=>v.markerStart?`url('#${bc(v.markerStart,g)}')`:void 0,[v.markerStart,g]),G=H(()=>v.markerEnd?`url('#${bc(v.markerEnd,g)}')`:void 0,[v.markerEnd,g]);if(v.hidden||L===null||O===null||F===null||j===null)return null;const Z=W=>{const{addSelectedEdges:ee,unselectNodesAndEdges:ae,multiSelectionActive:fe}=D.getState();A&&(D.setState({nodesSelectionActive:!1}),v.selected&&fe?(ae({nodes:[],edges:[v]}),z.current?.blur()):ee([e])),s&&s(W,v)},oe=a?W=>{a(W,{...v})}:void 0,ne=i?W=>{i(W,{...v})}:void 0,X=l?W=>{l(W,{...v})}:void 0,re=c?W=>{c(W,{...v})}:void 0,be=d?W=>{d(W,{...v})}:void 0,J=W=>{if(!w&&C1.includes(W.key)&&A){const{unselectNodesAndEdges:ee,addSelectedEdges:ae}=D.getState();W.key==="Escape"?(z.current?.blur(),ee({edges:[v]})):ae([e])}};return o("svg",{style:{zIndex:T},children:f("g",{className:We(["react-flow__edge",`react-flow__edge-${k}`,v.className,x,{selected:v.selected,animated:v.animated,inactive:!A&&!s,updating:P,selectable:A}]),onClick:Z,onDoubleClick:oe,onContextMenu:ne,onMouseEnter:X,onMouseMove:re,onMouseLeave:be,onKeyDown:E?J:void 0,tabIndex:E?0:void 0,role:v.ariaRole??(E?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":v.ariaLabel===null?void 0:v.ariaLabel||`Edge from ${v.source} to ${v.target}`,"aria-describedby":E?`${sw}-${g}`:void 0,ref:z,...v.domAttributes,children:[!R&&o(C,{id:e,source:v.source,target:v.target,type:v.type,selected:v.selected,animated:v.animated,selectable:A,deletable:v.deletable??!0,label:v.label,labelStyle:v.labelStyle,labelShowBg:v.labelShowBg,labelBgStyle:v.labelBgStyle,labelBgPadding:v.labelBgPadding,labelBgBorderRadius:v.labelBgBorderRadius,sourceX:L,sourceY:O,targetX:F,targetY:j,sourcePosition:V,targetPosition:$,data:v.data,style:v.style,sourceHandleId:v.sourceHandle,targetHandleId:v.targetHandle,markerStart:q,markerEnd:G,pathOptions:"pathOptions"in v?v.pathOptions:void 0,interactionWidth:v.interactionWidth}),I&&o(tK,{edge:v,isReconnectable:I,reconnectRadius:u,onReconnect:p,onReconnectStart:h,onReconnectEnd:m,sourceX:L,sourceY:O,targetX:F,targetY:j,sourcePosition:V,targetPosition:$,setUpdateHover:B,setReconnecting:M})]})})}var rK=He(nK);const oK=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Aw({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:a,onEdgeContextMenu:i,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeClick:u,reconnectRadius:p,onEdgeDoubleClick:h,onReconnectStart:m,onReconnectEnd:g,disableKeyboardA11y:b}){const{edgesFocusable:x,edgesReconnectable:y,elementsSelectable:w,onError:v}=De(oK,Ve),N=VG(t);return f("div",{className:"react-flow__edges",children:[o(GG,{defaultColor:e,rfId:n}),N.map(k=>o(rK,{id:k,edgesFocusable:x,edgesReconnectable:y,elementsSelectable:w,noPanClassName:s,onReconnect:a,onContextMenu:i,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onClick:u,reconnectRadius:p,onDoubleClick:h,onReconnectStart:m,onReconnectEnd:g,rfId:n,onError:v,edgeTypes:r,disableKeyboardA11y:b},k))]})}Aw.displayName="EdgeRenderer";const sK=He(Aw),aK=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function iK({children:e}){const t=De(aK);return o("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function lK(e){const t=yu(),n=te(!1);Y(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const cK=e=>e.panZoom?.syncViewport;function dK(e){const t=De(cK),n=qe();return Y(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function uK(e){return e.connection.inProgress?{...e.connection,to:ls(e.connection.to,e.transform)}:{...e.connection}}function pK(e){return uK}function fK(e){const t=pK();return De(t,Ve)}const hK=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function mK({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:a,height:i,isValid:l,inProgress:c}=De(hK,Ve);return!(a&&s&&c)?null:o("svg",{style:e,width:a,height:i,className:"react-flow__connectionline react-flow__container",children:o("g",{className:We(["react-flow__connection",I1(l)]),children:o(Pw,{style:t,type:n,CustomComponent:r,isValid:l})})})}const Pw=({style:e,type:t=En.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:a,fromNode:i,fromHandle:l,fromPosition:c,to:d,toNode:u,toHandle:p,toPosition:h,pointer:m}=fK();if(!s)return;if(n)return o(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:l,fromX:a.x,fromY:a.y,toX:d.x,toY:d.y,fromPosition:c,toPosition:h,connectionStatus:I1(r),toNode:u,toHandle:p,pointer:m});let g="";const b={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:d.x,targetY:d.y,targetPosition:h};switch(t){case En.Bezier:[g]=F1(b);break;case En.SimpleBezier:[g]=bw(b);break;case En.Step:[g]=gc({...b,borderRadius:0});break;case En.SmoothStep:[g]=gc(b);break;default:[g]=V1(b)}return o("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};Pw.displayName="ConnectionLine";const gK={};function Rh(e=gK){te(e),qe(),Y(()=>{},[e])}function bK(){qe(),te(!1),Y(()=>{},[])}function _w({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:a,onEdgeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:u,onSelectionContextMenu:p,onSelectionStart:h,onSelectionEnd:m,connectionLineType:g,connectionLineStyle:b,connectionLineComponent:x,connectionLineContainerStyle:y,selectionKeyCode:w,selectionOnDrag:v,selectionMode:N,multiSelectionKeyCode:k,panActivationKeyCode:C,zoomActivationKeyCode:E,deleteKeyCode:I,onlyRenderVisibleElements:A,elementsSelectable:z,defaultViewport:P,translateExtent:B,minZoom:R,maxZoom:M,preventScrolling:D,defaultMarkerColor:T,zoomOnScroll:L,zoomOnPinch:O,panOnScroll:F,panOnScrollSpeed:j,panOnScrollMode:V,zoomOnDoubleClick:$,panOnDrag:q,onPaneClick:G,onPaneMouseEnter:Z,onPaneMouseMove:oe,onPaneMouseLeave:ne,onPaneScroll:X,onPaneContextMenu:re,paneClickDistance:be,nodeClickDistance:J,onEdgeContextMenu:W,onEdgeMouseEnter:ee,onEdgeMouseMove:ae,onEdgeMouseLeave:fe,reconnectRadius:ge,onReconnect:Q,onReconnectStart:le,onReconnectEnd:ue,noDragClassName:de,noWheelClassName:ce,noPanClassName:Ce,disableKeyboardA11y:pe,nodeExtent:$e,rfId:Ae,viewport:Xe,onViewportChange:dt}){return Rh(e),Rh(t),bK(),lK(n),dK(Xe),o($G,{onPaneClick:G,onPaneMouseEnter:Z,onPaneMouseMove:oe,onPaneMouseLeave:ne,onPaneContextMenu:re,onPaneScroll:X,paneClickDistance:be,deleteKeyCode:I,selectionKeyCode:w,selectionOnDrag:v,selectionMode:N,onSelectionStart:h,onSelectionEnd:m,multiSelectionKeyCode:k,panActivationKeyCode:C,zoomActivationKeyCode:E,elementsSelectable:z,zoomOnScroll:L,zoomOnPinch:O,zoomOnDoubleClick:$,panOnScroll:F,panOnScrollSpeed:j,panOnScrollMode:V,panOnDrag:q,defaultViewport:P,translateExtent:B,minZoom:R,maxZoom:M,onSelectionContextMenu:p,preventScrolling:D,noDragClassName:de,noWheelClassName:ce,noPanClassName:Ce,disableKeyboardA11y:pe,onViewportChange:dt,isControlledViewport:!!Xe,children:f(iK,{children:[o(sK,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:i,onReconnect:Q,onReconnectStart:le,onReconnectEnd:ue,onlyRenderVisibleElements:A,onEdgeContextMenu:W,onEdgeMouseEnter:ee,onEdgeMouseMove:ae,onEdgeMouseLeave:fe,reconnectRadius:ge,defaultMarkerColor:T,noPanClassName:Ce,disableKeyboardA11y:pe,rfId:Ae}),o(mK,{style:b,type:g,component:x,containerStyle:y}),o("div",{className:"react-flow__edgelabel-renderer"}),o(jG,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:u,nodeClickDistance:J,onlyRenderVisibleElements:A,noPanClassName:Ce,noDragClassName:de,disableKeyboardA11y:pe,nodeExtent:$e,rfId:Ae}),o("div",{className:"react-flow__viewport-portal"})]})})}_w.displayName="GraphView";const xK=He(_w),Oh=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c=.5,maxZoom:d=2,nodeOrigin:u,nodeExtent:p,zIndexMode:h="basic"}={})=>{const m=new Map,g=new Map,b=new Map,x=new Map,y=r??t??[],w=n??e??[],v=u??[0,0],N=p??Bo;U1(b,x,y);const{nodesInitialized:k}=xc(w,m,g,{nodeOrigin:v,nodeExtent:N,zIndexMode:h});let C=[0,0,1];if(i&&s&&a){const E=as(m,{filter:P=>!!((P.width||P.initialWidth)&&(P.height||P.initialHeight))}),{x:I,y:A,zoom:z}=pu(E,s,a,c,d,l?.padding??.1);C=[I,A,z]}return{rfId:"1",width:s??0,height:a??0,transform:C,nodes:w,nodesInitialized:k,nodeLookup:m,parentLookup:g,edges:y,edgeLookup:x,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:d,translateExtent:Bo,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Or.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:v,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:i??!1,fitViewOptions:l,fitViewResolver:null,connection:{...E1},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:IU,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:M1,zIndexMode:h,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},yK=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:u,nodeExtent:p,zIndexMode:h})=>RQ((m,g)=>{async function b(){const{nodeLookup:x,panZoom:y,fitViewOptions:w,fitViewResolver:v,width:N,height:k,minZoom:C,maxZoom:E}=g();y&&(await MU({nodes:x,width:N,height:k,panZoom:y,minZoom:C,maxZoom:E},w),v?.resolve(!0),m({fitViewResolver:null}))}return{...Oh({nodes:e,edges:t,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:u,nodeExtent:p,defaultNodes:n,defaultEdges:r,zIndexMode:h}),setNodes:x=>{const{nodeLookup:y,parentLookup:w,nodeOrigin:v,elevateNodesOnSelect:N,fitViewQueued:k,zIndexMode:C,nodesSelectionActive:E}=g(),{nodesInitialized:I,hasSelectedNodes:A}=xc(x,y,w,{nodeOrigin:v,nodeExtent:p,elevateNodesOnSelect:N,checkEquality:!0,zIndexMode:C}),z=E&&A;k&&I?(b(),m({nodes:x,nodesInitialized:I,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:z})):m({nodes:x,nodesInitialized:I,nodesSelectionActive:z})},setEdges:x=>{const{connectionLookup:y,edgeLookup:w}=g();U1(y,w,x),m({edges:x})},setDefaultNodesAndEdges:(x,y)=>{if(x){const{setNodes:w}=g();w(x),m({hasDefaultNodes:!0})}if(y){const{setEdges:w}=g();w(y),m({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:y,nodeLookup:w,parentLookup:v,domNode:N,nodeOrigin:k,nodeExtent:C,debug:E,fitViewQueued:I,zIndexMode:A}=g(),{changes:z,updatedInternals:P}=YU(x,w,v,N,k,C,A);P&&(QU(w,v,{nodeOrigin:k,nodeExtent:C,zIndexMode:A}),I?(b(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),z?.length>0&&(E&&console.log("React Flow: trigger node changes",z),y?.(z)))},updateNodePositions:(x,y=!1)=>{const w=[];let v=[];const{nodeLookup:N,triggerNodeChanges:k,connection:C,updateConnection:E,onNodesChangeMiddlewareMap:I}=g();for(const[A,z]of x){const P=N.get(A),B=!!(P?.expandParent&&P?.parentId&&z?.position),R={id:A,type:"position",position:B?{x:Math.max(0,z.position.x),y:Math.max(0,z.position.y)}:z.position,dragging:y};if(P&&C.inProgress&&C.fromNode.id===P.id){const M=cr(P,C.fromHandle,we.Left,!0);E({...C,from:M})}B&&P.parentId&&w.push({id:A,parentId:P.parentId,rect:{...z.internals.positionAbsolute,width:z.measured.width??0,height:z.measured.height??0}}),v.push(R)}if(w.length>0){const{parentLookup:A,nodeOrigin:z}=g(),P=xu(w,N,A,z);v.push(...P)}for(const A of I.values())v=A(v);k(v)},triggerNodeChanges:x=>{const{onNodesChange:y,setNodes:w,nodes:v,hasDefaultNodes:N,debug:k}=g();if(x?.length){if(N){const C=rG(x,v);w(C)}k&&console.log("React Flow: trigger node changes",x),y?.(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:y,setEdges:w,edges:v,hasDefaultEdges:N,debug:k}=g();if(x?.length){if(N){const C=oG(x,v);w(C)}k&&console.log("React Flow: trigger edge changes",x),y?.(x)}},addSelectedNodes:x=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:v,triggerNodeChanges:N,triggerEdgeChanges:k}=g();if(y){const C=x.map(E=>Qn(E,!0));N(C);return}N(Mr(v,new Set([...x]),!0)),k(Mr(w))},addSelectedEdges:x=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:v,triggerNodeChanges:N,triggerEdgeChanges:k}=g();if(y){const C=x.map(E=>Qn(E,!0));k(C);return}k(Mr(w,new Set([...x]))),N(Mr(v,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:y}={})=>{const{edges:w,nodes:v,nodeLookup:N,triggerNodeChanges:k,triggerEdgeChanges:C}=g(),E=x||v,I=y||w,A=[];for(const P of E){if(!P.selected)continue;const B=N.get(P.id);B&&(B.selected=!1),A.push(Qn(P.id,!1))}const z=[];for(const P of I)P.selected&&z.push(Qn(P.id,!1));k(A),C(z)},setMinZoom:x=>{const{panZoom:y,maxZoom:w}=g();y?.setScaleExtent([x,w]),m({minZoom:x})},setMaxZoom:x=>{const{panZoom:y,minZoom:w}=g();y?.setScaleExtent([w,x]),m({maxZoom:x})},setTranslateExtent:x=>{g().panZoom?.setTranslateExtent(x),m({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:y,triggerNodeChanges:w,triggerEdgeChanges:v,elementsSelectable:N}=g();if(!N)return;const k=y.reduce((E,I)=>I.selected?[...E,Qn(I.id,!1)]:E,[]),C=x.reduce((E,I)=>I.selected?[...E,Qn(I.id,!1)]:E,[]);w(k),v(C)},setNodeExtent:x=>{const{nodes:y,nodeLookup:w,parentLookup:v,nodeOrigin:N,elevateNodesOnSelect:k,nodeExtent:C,zIndexMode:E}=g();x[0][0]===C[0][0]&&x[0][1]===C[0][1]&&x[1][0]===C[1][0]&&x[1][1]===C[1][1]||(xc(y,w,v,{nodeOrigin:N,nodeExtent:x,elevateNodesOnSelect:k,checkEquality:!1,zIndexMode:E}),m({nodeExtent:x}))},panBy:x=>{const{transform:y,width:w,height:v,panZoom:N,translateExtent:k}=g();return ZU({delta:x,panZoom:N,transform:y,translateExtent:k,width:w,height:v})},setCenter:async(x,y,w)=>{const{width:v,height:N,maxZoom:k,panZoom:C}=g();if(!C)return Promise.resolve(!1);const E=typeof w?.zoom<"u"?w.zoom:k;return await C.setViewport({x:v/2-x*E,y:N/2-y*E,zoom:E},{duration:w?.duration,ease:w?.ease,interpolate:w?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{m({connection:{...E1}})},updateConnection:x=>{m({connection:x})},reset:()=>m({...Oh()})}},Object.is);function vK({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:a,initialMinZoom:i,initialMaxZoom:l,initialFitViewOptions:c,fitView:d,nodeOrigin:u,nodeExtent:p,zIndexMode:h,children:m}){const[g]=_(()=>yK({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:a,fitView:d,minZoom:i,maxZoom:l,fitViewOptions:c,nodeOrigin:u,nodeExtent:p,zIndexMode:h}));return o(OQ,{value:g,children:o(iG,{children:m})})}function wK({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:a,height:i,fitView:l,fitViewOptions:c,minZoom:d,maxZoom:u,nodeOrigin:p,nodeExtent:h,zIndexMode:m}){return ve(fi)?o(me,{children:e}):o(vK,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:a,initialHeight:i,fitView:l,initialFitViewOptions:c,initialMinZoom:d,initialMaxZoom:u,nodeOrigin:p,nodeExtent:h,zIndexMode:m,children:e})}const NK={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function kK({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:a,edgeTypes:i,onNodeClick:l,onEdgeClick:c,onInit:d,onMove:u,onMoveStart:p,onMoveEnd:h,onConnect:m,onConnectStart:g,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:y,onNodeMouseEnter:w,onNodeMouseMove:v,onNodeMouseLeave:N,onNodeContextMenu:k,onNodeDoubleClick:C,onNodeDragStart:E,onNodeDrag:I,onNodeDragStop:A,onNodesDelete:z,onEdgesDelete:P,onDelete:B,onSelectionChange:R,onSelectionDragStart:M,onSelectionDrag:D,onSelectionDragStop:T,onSelectionContextMenu:L,onSelectionStart:O,onSelectionEnd:F,onBeforeDelete:j,connectionMode:V,connectionLineType:$=En.Bezier,connectionLineStyle:q,connectionLineComponent:G,connectionLineContainerStyle:Z,deleteKeyCode:oe="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:X=!1,selectionMode:re=zo.Full,panActivationKeyCode:be="Space",multiSelectionKeyCode:J=jo()?"Meta":"Control",zoomActivationKeyCode:W=jo()?"Meta":"Control",snapToGrid:ee,snapGrid:ae,onlyRenderVisibleElements:fe=!1,selectNodesOnDrag:ge,nodesDraggable:Q,autoPanOnNodeFocus:le,nodesConnectable:ue,nodesFocusable:de,nodeOrigin:ce=aw,edgesFocusable:Ce,edgesReconnectable:pe,elementsSelectable:$e=!0,defaultViewport:Ae=YQ,minZoom:Xe=.5,maxZoom:dt=2,translateExtent:yr=Bo,preventScrolling:he=!0,nodeExtent:_e,defaultMarkerColor:Re="#b1b1b7",zoomOnScroll:Oe=!0,zoomOnPinch:Fn=!0,panOnScroll:jn=!1,panOnScrollSpeed:ro=.5,panOnScrollMode:lN=Xn.Free,zoomOnDoubleClick:cN=!0,panOnDrag:dN=!0,onPaneClick:uN,onPaneMouseEnter:pN,onPaneMouseMove:fN,onPaneMouseLeave:hN,onPaneScroll:mN,onPaneContextMenu:gN,paneClickDistance:bN=1,nodeClickDistance:xN=0,children:yN,onReconnect:vN,onReconnectStart:wN,onReconnectEnd:NN,onEdgeContextMenu:kN,onEdgeDoubleClick:SN,onEdgeMouseEnter:CN,onEdgeMouseMove:MN,onEdgeMouseLeave:EN,reconnectRadius:IN=10,onNodesChange:AN,onEdgesChange:PN,noDragClassName:_N="nodrag",noWheelClassName:$N="nowheel",noPanClassName:Mu="nopan",fitView:Eu,fitViewOptions:Iu,connectOnClick:DN,attributionPosition:TN,proOptions:LN,defaultEdgeOptions:RN,elevateNodesOnSelect:ON=!0,elevateEdgesOnSelect:BN=!1,disableKeyboardA11y:Au=!1,autoPanOnConnect:zN,autoPanOnNodeDrag:FN,autoPanSpeed:jN,connectionRadius:VN,isValidConnection:HN,onError:qN,style:UN,id:Pu,nodeDragThreshold:QN,connectionDragThreshold:GN,viewport:KN,onViewportChange:WN,width:YN,height:ZN,colorMode:XN="light",debug:JN,onScroll:_u,ariaLabelConfig:e2,zIndexMode:$u="basic",...t2},n2){const yi=Pu||"1",r2=eG(XN),o2=U(Du=>{Du.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),_u?.(Du)},[_u]);return o("div",{"data-testid":"rf__wrapper",...t2,onScroll:o2,style:{...UN,...NK},ref:n2,className:We(["react-flow",s,r2]),id:Pu,role:"application",children:f(wK,{nodes:e,edges:t,width:YN,height:ZN,fitView:Eu,fitViewOptions:Iu,minZoom:Xe,maxZoom:dt,nodeOrigin:ce,nodeExtent:_e,zIndexMode:$u,children:[o(JQ,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:g,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:y,nodesDraggable:Q,autoPanOnNodeFocus:le,nodesConnectable:ue,nodesFocusable:de,edgesFocusable:Ce,edgesReconnectable:pe,elementsSelectable:$e,elevateNodesOnSelect:ON,elevateEdgesOnSelect:BN,minZoom:Xe,maxZoom:dt,nodeExtent:_e,onNodesChange:AN,onEdgesChange:PN,snapToGrid:ee,snapGrid:ae,connectionMode:V,translateExtent:yr,connectOnClick:DN,defaultEdgeOptions:RN,fitView:Eu,fitViewOptions:Iu,onNodesDelete:z,onEdgesDelete:P,onDelete:B,onNodeDragStart:E,onNodeDrag:I,onNodeDragStop:A,onSelectionDrag:D,onSelectionDragStart:M,onSelectionDragStop:T,onMove:u,onMoveStart:p,onMoveEnd:h,noPanClassName:Mu,nodeOrigin:ce,rfId:yi,autoPanOnConnect:zN,autoPanOnNodeDrag:FN,autoPanSpeed:jN,onError:qN,connectionRadius:VN,isValidConnection:HN,selectNodesOnDrag:ge,nodeDragThreshold:QN,connectionDragThreshold:GN,onBeforeDelete:j,debug:JN,ariaLabelConfig:e2,zIndexMode:$u}),o(xK,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:w,onNodeMouseMove:v,onNodeMouseLeave:N,onNodeContextMenu:k,onNodeDoubleClick:C,nodeTypes:a,edgeTypes:i,connectionLineType:$,connectionLineStyle:q,connectionLineComponent:G,connectionLineContainerStyle:Z,selectionKeyCode:ne,selectionOnDrag:X,selectionMode:re,deleteKeyCode:oe,multiSelectionKeyCode:J,panActivationKeyCode:be,zoomActivationKeyCode:W,onlyRenderVisibleElements:fe,defaultViewport:Ae,translateExtent:yr,minZoom:Xe,maxZoom:dt,preventScrolling:he,zoomOnScroll:Oe,zoomOnPinch:Fn,zoomOnDoubleClick:cN,panOnScroll:jn,panOnScrollSpeed:ro,panOnScrollMode:lN,panOnDrag:dN,onPaneClick:uN,onPaneMouseEnter:pN,onPaneMouseMove:fN,onPaneMouseLeave:hN,onPaneScroll:mN,onPaneContextMenu:gN,paneClickDistance:bN,nodeClickDistance:xN,onSelectionContextMenu:L,onSelectionStart:O,onSelectionEnd:F,onReconnect:vN,onReconnectStart:wN,onReconnectEnd:NN,onEdgeContextMenu:kN,onEdgeDoubleClick:SN,onEdgeMouseEnter:CN,onEdgeMouseMove:MN,onEdgeMouseLeave:EN,reconnectRadius:IN,defaultMarkerColor:Re,noDragClassName:_N,noWheelClassName:$N,noPanClassName:Mu,rfId:yi,disableKeyboardA11y:Au,nodeExtent:_e,viewport:KN,onViewportChange:WN}),o(WQ,{onSelectionChange:R}),yN,o(qQ,{proOptions:LN,position:TN}),o(HQ,{rfId:yi,disableKeyboardA11y:Au})]})})}var SK=lw(kK);function CK({dimensions:e,lineWidth:t,variant:n,className:r}){return o("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:We(["react-flow__background-pattern",n,r])})}function MK({radius:e,className:t}){return o("circle",{cx:e,cy:e,r:e,className:We(["react-flow__background-pattern","dots",t])})}var Pn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Pn||(Pn={}));const EK={[Pn.Dots]:1,[Pn.Lines]:1,[Pn.Cross]:6},IK=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function $w({id:e,variant:t=Pn.Dots,gap:n=20,size:r,lineWidth:s=1,offset:a=0,color:i,bgColor:l,style:c,className:d,patternClassName:u}){const p=te(null),{transform:h,patternId:m}=De(IK,Ve),g=r||EK[t],b=t===Pn.Dots,x=t===Pn.Cross,y=Array.isArray(n)?n:[n,n],w=[y[0]*h[2]||1,y[1]*h[2]||1],v=g*h[2],N=Array.isArray(a)?a:[a,a],k=x?[v,v]:w,C=[N[0]*h[2]||1+k[0]/2,N[1]*h[2]||1+k[1]/2],E=`${m}${e||""}`;return f("svg",{className:We(["react-flow__background",d]),style:{...c,...mi,"--xy-background-color-props":l,"--xy-background-pattern-color-props":i},ref:p,"data-testid":"rf__background",children:[o("pattern",{id:E,x:h[0]%w[0],y:h[1]%w[1],width:w[0],height:w[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`,children:b?o(MK,{radius:v/2,className:u}):o(CK,{dimensions:k,lineWidth:s,variant:t,className:u})}),o("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${E})`})]})}$w.displayName="Background";const AK=He($w);function PK(){return o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:o("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function _K(){return o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:o("path",{d:"M0 0h32v4.2H0z"})})}function $K(){return o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:o("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 DK(){return o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o("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 TK(){return o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o("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 Bs({children:e,className:t,...n}){return o("button",{type:"button",className:We(["react-flow__controls-button",t]),...n,children:e})}const LK=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Dw({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:a,onZoomOut:i,onFitView:l,onInteractiveChange:c,className:d,children:u,position:p="bottom-left",orientation:h="vertical","aria-label":m}){const g=qe(),{isInteractive:b,minZoomReached:x,maxZoomReached:y,ariaLabelConfig:w}=De(LK,Ve),{zoomIn:v,zoomOut:N,fitView:k}=yu(),C=()=>{v(),a?.()},E=()=>{N(),i?.()},I=()=>{k(s),l?.()},A=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),c?.(!b)};return f(hi,{className:We(["react-flow__controls",h==="horizontal"?"horizontal":"vertical",d]),position:p,style:e,"data-testid":"rf__controls","aria-label":m??w["controls.ariaLabel"],children:[t&&f(me,{children:[o(Bs,{onClick:C,className:"react-flow__controls-zoomin",title:w["controls.zoomIn.ariaLabel"],"aria-label":w["controls.zoomIn.ariaLabel"],disabled:y,children:o(PK,{})}),o(Bs,{onClick:E,className:"react-flow__controls-zoomout",title:w["controls.zoomOut.ariaLabel"],"aria-label":w["controls.zoomOut.ariaLabel"],disabled:x,children:o(_K,{})})]}),n&&o(Bs,{className:"react-flow__controls-fitview",onClick:I,title:w["controls.fitView.ariaLabel"],"aria-label":w["controls.fitView.ariaLabel"],children:o($K,{})}),r&&o(Bs,{className:"react-flow__controls-interactive",onClick:A,title:w["controls.interactive.ariaLabel"],"aria-label":w["controls.interactive.ariaLabel"],children:b?o(TK,{}):o(DK,{})}),u]})}Dw.displayName="Controls";const RK=He(Dw);function OK({id:e,x:t,y:n,width:r,height:s,style:a,color:i,strokeColor:l,strokeWidth:c,className:d,borderRadius:u,shapeRendering:p,selected:h,onClick:m}){const{background:g,backgroundColor:b}=a||{},x=i||g||b;return o("rect",{className:We(["react-flow__minimap-node",{selected:h},d]),x:t,y:n,rx:u,ry:u,width:r,height:s,style:{fill:x,stroke:l,strokeWidth:c},shapeRendering:p,onClick:m?y=>m(y,e):void 0})}const BK=He(OK),zK=e=>e.nodes.map(t=>t.id),ml=e=>e instanceof Function?e:()=>e;function FK({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:a=BK,onClick:i}){const l=De(zK,Ve),c=ml(t),d=ml(e),u=ml(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return o(me,{children:l.map(h=>o(VK,{id:h,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:a,onClick:i,shapeRendering:p},h))})}function jK({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:a,shapeRendering:i,NodeComponent:l,onClick:c}){const{node:d,x:u,y:p,width:h,height:m}=De(g=>{const b=g.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const x=b.internals.userNode,{x:y,y:w}=b.internals.positionAbsolute,{width:v,height:N}=Nn(x);return{node:x,x:y,y:w,width:v,height:N}},Ve);return!d||d.hidden||!T1(d)?null:o(l,{x:u,y:p,width:h,height:m,style:d.style,selected:!!d.selected,className:r(d),color:t(d),borderRadius:s,strokeColor:n(d),strokeWidth:a,shapeRendering:i,onClick:c,id:d.id})}const VK=He(jK);var HK=He(FK);const qK=200,UK=150,QK=e=>!e.hidden,GK=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?D1(as(e.nodeLookup,{filter:QK}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},KK="react-flow__minimap-desc";function Tw({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:a=5,nodeStrokeWidth:i,nodeComponent:l,bgColor:c,maskColor:d,maskStrokeColor:u,maskStrokeWidth:p,position:h="bottom-right",onClick:m,onNodeClick:g,pannable:b=!1,zoomable:x=!1,ariaLabel:y,inversePan:w,zoomStep:v=1,offsetScale:N=5}){const k=qe(),C=te(null),{boundingRect:E,viewBB:I,rfId:A,panZoom:z,translateExtent:P,flowWidth:B,flowHeight:R,ariaLabelConfig:M}=De(GK,Ve),D=e?.width??qK,T=e?.height??UK,L=E.width/D,O=E.height/T,F=Math.max(L,O),j=F*D,V=F*T,$=N*F,q=E.x-(j-E.width)/2-$,G=E.y-(V-E.height)/2-$,Z=j+$*2,oe=V+$*2,ne=`${KK}-${A}`,X=te(0),re=te();X.current=F,Y(()=>{if(C.current&&z)return re.current=aQ({domNode:C.current,panZoom:z,getTransform:()=>k.getState().transform,getViewScale:()=>X.current}),()=>{re.current?.destroy()}},[z]),Y(()=>{re.current?.update({translateExtent:P,width:B,height:R,inversePan:w,pannable:b,zoomStep:v,zoomable:x})},[b,x,w,v,P,B,R]);const be=m?ee=>{const[ae,fe]=re.current?.pointer(ee)||[0,0];m(ee,{x:ae,y:fe})}:void 0,J=g?U((ee,ae)=>{const fe=k.getState().nodeLookup.get(ae).internals.userNode;g(ee,fe)},[]):void 0,W=y??M["minimap.ariaLabel"];return o(hi,{position:h,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 u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*F:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r: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:We(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:f("svg",{width:D,height:T,viewBox:`${q} ${G} ${Z} ${oe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:C,onClick:be,children:[W&&o("title",{id:ne,children:W}),o(HK,{onClick:J,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:s,nodeStrokeWidth:i,nodeComponent:l}),o("path",{className:"react-flow__minimap-mask",d:`M${q-$},${G-$}h${Z+$*2}v${oe+$*2}h${-Z-$*2}z
|
|
1156
|
-
M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Tw.displayName="MiniMap";He(Tw);const WK=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,YK={[jr.Line]:"right",[jr.Handle]:"bottom-right"};function ZK({nodeId:e,position:t,variant:n=jr.Handle,className:r,style:s=void 0,children:a,color:i,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:h,autoScale:m=!0,shouldResize:g,onResizeStart:b,onResize:x,onResizeEnd:y}){const w=pw(),v=typeof e=="string"?e:w,N=qe(),k=te(null),C=n===jr.Handle,E=De(U(WK(C&&m),[C,m]),Ve),I=te(null),A=t??YK[n];Y(()=>{if(!(!k.current||!v))return I.current||(I.current=vQ({domNode:k.current,nodeId:v,getStoreItems:()=>{const{nodeLookup:P,transform:B,snapGrid:R,snapToGrid:M,nodeOrigin:D,domNode:T}=N.getState();return{nodeLookup:P,transform:B,snapGrid:R,snapToGrid:M,nodeOrigin:D,paneDomNode:T}},onChange:(P,B)=>{const{triggerNodeChanges:R,nodeLookup:M,parentLookup:D,nodeOrigin:T}=N.getState(),L=[],O={x:P.x,y:P.y},F=M.get(v);if(F&&F.expandParent&&F.parentId){const j=F.origin??T,V=P.width??F.measured.width??0,$=P.height??F.measured.height??0,q={id:F.id,parentId:F.parentId,rect:{width:V,height:$,...L1({x:P.x??F.position.x,y:P.y??F.position.y},{width:V,height:$},F.parentId,M,j)}},G=xu([q],M,D,T);L.push(...G),O.x=P.x?Math.max(j[0]*V,P.x):void 0,O.y=P.y?Math.max(j[1]*$,P.y):void 0}if(O.x!==void 0&&O.y!==void 0){const j={id:v,type:"position",position:{...O}};L.push(j)}if(P.width!==void 0&&P.height!==void 0){const V={id:v,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:P.width,height:P.height}};L.push(V)}for(const j of B){const V={...j,type:"position"};L.push(V)}R(L)},onEnd:({width:P,height:B})=>{const R={id:v,type:"dimensions",resizing:!1,dimensions:{width:P,height:B}};N.getState().triggerNodeChanges([R])}})),I.current.update({controlPosition:A,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:u},keepAspectRatio:p,resizeDirection:h,onResizeStart:b,onResize:x,onResizeEnd:y,shouldResize:g}),()=>{I.current?.destroy()}},[A,l,c,d,u,p,b,x,y,g]);const z=A.split("-");return o("div",{className:We(["react-flow__resize-control","nodrag",...z,n,r]),ref:k,style:{...s,scale:E,...i&&{[C?"backgroundColor":"borderColor"]:i}},children:a})}He(ZK);var Lw=Object.defineProperty,XK=(e,t,n)=>t in e?Lw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,JK=(e,t)=>{for(var n in t)Lw(e,n,{get:t[n],enumerable:!0})},eW=(e,t,n)=>XK(e,t+"",n),Rw={};JK(Rw,{Graph:()=>$t,alg:()=>wu,json:()=>Bw,version:()=>rW});var tW=Object.defineProperty,Ow=(e,t)=>{for(var n in t)tW(e,n,{get:t[n],enumerable:!0})},$t=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(n=>{t!==void 0?this.setNode(n,t):this.setNode(n)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=n=>this.removeEdge(this._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(n=>{this.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let r of this.successors(e))n.add(r);return Array.from(n.values())}}isLeaf(e){let t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([s,a])=>{e(s)&&t.setNode(s,a)}),Object.values(this._edgeObjs).forEach(s=>{t.hasNode(s.v)&&t.hasNode(s.w)&&t.setEdge(s,this.edge(s))});let n={},r=s=>{let a=this.parent(s);return!a||t.hasNode(a)?(n[s]=a??void 0,a??void 0):a in n?n[a]:r(a)};return this._isCompound&&t.nodes().forEach(s=>t.setParent(s,r(s))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((n,r)=>(t!==void 0?this.setEdge(n,r,t):this.setEdge(n,r),r)),this}setEdge(e,t,n,r){let s,a,i,l,c=!1;typeof e=="object"&&e!==null&&"v"in e?(s=e.v,a=e.w,i=e.name,arguments.length===2&&(l=t,c=!0)):(s=e,a=t,i=r,arguments.length>2&&(l=n,c=!0)),s=""+s,a=""+a,i!==void 0&&(i=""+i);let d=go(this._isDirected,s,a,i);if(d in this._edgeLabels)return c&&(this._edgeLabels[d]=l),this;if(i!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(s),this.setNode(a),this._edgeLabels[d]=c?l:this._defaultEdgeLabelFn(s,a,i);let u=nW(this._isDirected,s,a,i);return s=u.v,a=u.w,Object.freeze(u),this._edgeObjs[d]=u,Bh(this._preds[a],s),Bh(this._sucs[s],a),this._in[a][d]=u,this._out[s][d]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?gl(this._isDirected,e):go(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!="object"?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?gl(this._isDirected,e):go(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?gl(this._isDirected,e):go(this._isDirected,e,t,n),s=this._edgeObjs[r];if(s){let a=s.v,i=s.w;delete this._edgeLabels[r],delete this._edgeObjs[r],zh(this._preds[i],a),zh(this._sucs[a],i),delete this._in[i][r],delete this._out[a][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(s=>s.v===t&&s.w===n||s.v===n&&s.w===t):r}};function Bh(e,t){e[t]?e[t]++:e[t]=1}function zh(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function go(e,t,n,r){let s=""+t,a=""+n;if(!e&&s>a){let i=s;s=a,a=i}return s+""+a+""+(r===void 0?"\0":r)}function nW(e,t,n,r){let s=""+t,a=""+n;if(!e&&s>a){let l=s;s=a,a=l}let i={v:s,w:a};return r&&(i.name=r),i}function gl(e,t){return go(e,t.v,t.w,t.name)}var rW="4.0.1",Bw={};Ow(Bw,{read:()=>iW,write:()=>oW});function oW(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:sW(e),edges:aW(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function sW(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),s={v:t};return n!==void 0&&(s.value=n),r!==void 0&&(s.parent=r),s})}function aW(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function iW(e){let t=new $t(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var wu={};Ow(wu,{CycleException:()=>Ea,bellmanFord:()=>zw,components:()=>dW,dijkstra:()=>Ma,dijkstraAll:()=>fW,findCycles:()=>hW,floydWarshall:()=>gW,isAcyclic:()=>xW,postorder:()=>vW,preorder:()=>wW,prim:()=>NW,shortestPaths:()=>kW,tarjan:()=>jw,topsort:()=>Vw});var lW=()=>1;function zw(e,t,n,r){return cW(e,String(t),n||lW,r||function(s){return e.outEdges(s)})}function cW(e,t,n,r){let s={},a,i=0,l=e.nodes(),c=function(p){let h=n(p);s[p.v].distance+h<s[p.w].distance&&(s[p.w]={distance:s[p.v].distance+h,predecessor:p.v},a=!0)},d=function(){l.forEach(function(p){r(p).forEach(function(h){let m=h.v===p?h.v:h.w,g=m===h.v?h.w:h.v;c({v:m,w:g})})})};l.forEach(function(p){let h=p===t?0:Number.POSITIVE_INFINITY;s[p]={distance:h,predecessor:""}});let u=l.length;for(let p=1;p<u&&(a=!1,i++,d(),!!a);p++);if(i===u-1&&(a=!1,d(),a))throw new Error("The graph contains a negative weight cycle");return s}function dW(e){let t={},n=[],r;function s(a){a in t||(t[a]=!0,r.push(a),e.successors(a).forEach(s),e.predecessors(a).forEach(s))}return e.nodes().forEach(function(a){r=[],s(a),r.length&&n.push(r)}),n}var Fw=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let s=this._arr,a=s.length;return n[r]=a,s.push({key:r,priority:t}),this._decrease(a),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,s=e;n<t.length&&(s=t[n].priority<t[s].priority?n:s,r<t.length&&(s=t[r].priority<t[s].priority?r:s),s!==e&&(this._swap(e,s),this._heapify(s)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,s=n[e],a=n[t];n[e]=a,n[t]=s,r[a.key]=e,r[s.key]=t}},uW=()=>1;function Ma(e,t,n,r){let s=function(a){return e.outEdges(a)};return pW(e,String(t),n||uW,r||s)}function pW(e,t,n,r){let s={},a=new Fw,i,l,c=function(d){let u=d.v!==i?d.v:d.w,p=s[u],h=n(d),m=l.distance+h;if(h<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+d+" Weight: "+h);m<p.distance&&(p.distance=m,p.predecessor=i,a.decrease(u,m))};for(e.nodes().forEach(function(d){let u=d===t?0:Number.POSITIVE_INFINITY;s[d]={distance:u,predecessor:""},a.add(d,u)});a.size()>0&&(i=a.removeMin(),l=s[i],l.distance!==Number.POSITIVE_INFINITY);)r(i).forEach(c);return s}function fW(e,t,n){return e.nodes().reduce(function(r,s){return r[s]=Ma(e,s,t,n),r},{})}function jw(e){let t=0,n=[],r={},s=[];function a(i){let l=r[i]={onStack:!0,lowlink:t,index:t++};if(n.push(i),e.successors(i).forEach(function(c){c in r?r[c].onStack&&(l.lowlink=Math.min(l.lowlink,r[c].index)):(a(c),l.lowlink=Math.min(l.lowlink,r[c].lowlink))}),l.lowlink===l.index){let c=[],d;do d=n.pop(),r[d].onStack=!1,c.push(d);while(i!==d);s.push(c)}}return e.nodes().forEach(function(i){i in r||a(i)}),s}function hW(e){return jw(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var mW=()=>1;function gW(e,t,n){return bW(e,t||mW,n||function(r){return e.outEdges(r)})}function bW(e,t,n){let r={},s=e.nodes();return s.forEach(function(a){r[a]={},r[a][a]={distance:0,predecessor:""},s.forEach(function(i){a!==i&&(r[a][i]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(a).forEach(function(i){let l=i.v===a?i.w:i.v,c=t(i);r[a][l]={distance:c,predecessor:a}})}),s.forEach(function(a){let i=r[a];s.forEach(function(l){let c=r[l];s.forEach(function(d){let u=c[a],p=i[d],h=c[d],m=u.distance+p.distance;m<h.distance&&(h.distance=m,h.predecessor=p.predecessor)})})}),r}var Ea=class extends Error{constructor(...e){super(...e)}};function Vw(e){let t={},n={},r=[];function s(a){if(a in n)throw new Ea;a in t||(n[a]=!0,t[a]=!0,e.predecessors(a).forEach(s),delete n[a],r.push(a))}if(e.sinks().forEach(s),Object.keys(t).length!==e.nodeCount())throw new Ea;return r}function xW(e){try{Vw(e)}catch(t){if(t instanceof Ea)return!1;throw t}return!0}function yW(e,t,n,r,s){Array.isArray(t)||(t=[t]);let a=(l=>{var c;return(c=e.isDirected()?e.successors(l):e.neighbors(l))!=null?c:[]}),i={};return t.forEach(function(l){if(!e.hasNode(l))throw new Error("Graph does not have node: "+l);s=Hw(e,l,n==="post",i,a,r,s)}),s}function Hw(e,t,n,r,s,a,i){return t in r||(r[t]=!0,n||(i=a(i,t)),s(t).forEach(function(l){i=Hw(e,l,n,r,s,a,i)}),n&&(i=a(i,t))),i}function qw(e,t,n){return yW(e,t,n,function(r,s){return r.push(s),r},[])}function vW(e,t){return qw(e,t,"post")}function wW(e,t){return qw(e,t,"pre")}function NW(e,t){let n=new $t,r={},s=new Fw,a;function i(c){let d=c.v===a?c.w:c.v,u=s.priority(d);if(u!==void 0){let p=t(c);p<u&&(r[d]=a,s.decrease(d,p))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(c){s.add(c,Number.POSITIVE_INFINITY),n.setNode(c)}),s.decrease(e.nodes()[0],0);let l=!1;for(;s.size()>0;){if(a=s.removeMin(),a in r)n.setEdge(a,r[a]);else{if(l)throw new Error("Input graph is not connected: "+e);l=!0}e.nodeEdges(a).forEach(i)}return n}function kW(e,t,n,r){return SW(e,t,n,r??(s=>{let a=e.outEdges(s);return a??[]}))}function SW(e,t,n,r){if(n===void 0)return Ma(e,t,n,r);let s=!1,a=e.nodes();for(let i=0;i<a.length;i++){let l=r(a[i]);for(let c=0;c<l.length;c++){let d=l[c],u=d.v===a[i]?d.v:d.w,p=u===d.v?d.w:d.v;n({v:u,w:p})<0&&(s=!0)}if(s)return zw(e,t,n,r)}return Ma(e,t,n,r)}function no(e,t,n,r){let s=r;for(;e.hasNode(s);)s=Nu(r);return n.dummy=t,e.setNode(s,n),s}function CW(e){let t=new $t().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},s=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+s.weight,minlen:Math.max(r.minlen,s.minlen)})}),t}function Uw(e){let t=new $t({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function Fh(e,t){let n=e.x,r=e.y,s=t.x-n,a=t.y-r,i=e.width/2,l=e.height/2;if(!s&&!a)throw new Error("Not possible to find intersection inside of the rectangle");let c,d;return Math.abs(a)*i>Math.abs(s)*l?(a<0&&(l=-l),c=l*s/a,d=l):(s<0&&(i=-i),c=i,d=i*a/s),{x:n+c,y:r+d}}function cs(e){let t=Ho(Gw(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),s=r.rank;s!==void 0&&(t[s]||(t[s]=[]),t[s][r.order]=n)}),t}function MW(e){let t=e.nodes().map(r=>{let s=e.node(r).rank;return s===void 0?Number.MAX_VALUE:s}),n=Wt(Math.min,t);e.nodes().forEach(r=>{let s=e.node(r);Object.hasOwn(s,"rank")&&(s.rank-=n)})}function EW(e){let t=e.nodes().map(i=>e.node(i).rank).filter(i=>i!==void 0),n=Wt(Math.min,t),r=[];e.nodes().forEach(i=>{let l=e.node(i).rank-n;r[l]||(r[l]=[]),r[l].push(i)});let s=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((i,l)=>{i===void 0&&l%a!==0?--s:i!==void 0&&s&&i.forEach(c=>e.node(c).rank+=s)})}function jh(e,t,n,r){let s={width:0,height:0};return arguments.length>=4&&(s.rank=n,s.order=r),no(e,"border",s,t)}function IW(e,t=Qw){let n=[];for(let r=0;r<e.length;r+=t){let s=e.slice(r,r+t);n.push(s)}return n}var Qw=65535;function Wt(e,t){if(t.length>Qw){let n=IW(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function Gw(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return Wt(Math.max,t)}function AW(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function Kw(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function Ww(e,t){return t()}var PW=0;function Nu(e){let t=++PW;return e+(""+t)}function Ho(e,t,n=1){t==null&&(t=e,e=0);let r=a=>a<t;n<0&&(r=a=>t<a);let s=[];for(let a=e;r(a);a+=n)s.push(a);return s}function Ia(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function bi(e,t){let n;return typeof t=="string"?n=r=>r[t]:n=t,Object.entries(e).reduce((r,[s,a])=>(r[s]=n(a,s),r),{})}function _W(e,t){return e.reduce((n,r,s)=>(n[r]=t[s],n),{})}var xi="\0",$W="3.0.0",DW=class{constructor(){eW(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Vh(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Vh(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,TW)),n=n._prev;return"["+e.join(", ")+"]"}};function Vh(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function TW(e,t){if(e!=="_next"&&e!=="_prev")return t}var LW=DW,RW=()=>1;function OW(e,t){if(e.nodeCount()<=1)return[];let n=zW(e,t||RW);return BW(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function BW(e,t,n){var r;let s=[],a=t[t.length-1],i=t[0],l;for(;e.nodeCount();){for(;l=i.dequeue();)bl(e,t,n,l);for(;l=a.dequeue();)bl(e,t,n,l);if(e.nodeCount()){for(let c=t.length-2;c>0;--c)if(l=(r=t[c])==null?void 0:r.dequeue(),l){s=s.concat(bl(e,t,n,l,!0)||[]);break}}}return s}function bl(e,t,n,r,s){let a=[],i=s?a:void 0;return(e.inEdges(r.v)||[]).forEach(l=>{let c=e.edge(l),d=e.node(l.v);s&&a.push({v:l.v,w:l.w}),d.out-=c,Nc(t,n,d)}),(e.outEdges(r.v)||[]).forEach(l=>{let c=e.edge(l),d=l.w,u=e.node(d);u.in-=c,Nc(t,n,u)}),e.removeNode(r.v),i}function zW(e,t){let n=new $t,r=0,s=0;e.nodes().forEach(l=>{n.setNode(l,{v:l,in:0,out:0})}),e.edges().forEach(l=>{let c=n.edge(l.v,l.w)||0,d=t(l),u=c+d;n.setEdge(l.v,l.w,u);let p=n.node(l.v),h=n.node(l.w);s=Math.max(s,p.out+=d),r=Math.max(r,h.in+=d)});let a=FW(s+r+3).map(()=>new LW),i=r+1;return n.nodes().forEach(l=>{Nc(a,i,n.node(l))}),{graph:n,buckets:a,zeroIdx:i}}function Nc(e,t,n){var r,s,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(s=e[e.length-1])==null||s.enqueue(n):(r=e[0])==null||r.enqueue(n)}function FW(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function jW(e){(e.graph().acyclicer==="greedy"?OW(e,t(e)):VW(e)).forEach(n=>{let r=e.edge(n);e.removeEdge(n),r.forwardName=n.name,r.reversed=!0,e.setEdge(n.w,n.v,r,Nu("rev"))});function t(n){return r=>n.edge(r).weight}}function VW(e){let t=[],n={},r={};function s(a){Object.hasOwn(r,a)||(r[a]=!0,n[a]=!0,e.outEdges(a).forEach(i=>{Object.hasOwn(n,i.w)?t.push(i):s(i.w)}),delete n[a])}return e.nodes().forEach(s),t}function HW(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function qW(e){e.graph().dummyChains=[],e.edges().forEach(t=>UW(e,t))}function UW(e,t){let n=t.v,r=e.node(n).rank,s=t.w,a=e.node(s).rank,i=t.name,l=e.edge(t),c=l.labelRank;if(a===r+1)return;e.removeEdge(t);let d,u,p;for(p=0,++r;r<a;++p,++r)l.points=[],u={width:0,height:0,edgeLabel:l,edgeObj:t,rank:r},d=no(e,"edge",u,"_d"),r===c&&(u.width=l.width,u.height=l.height,u.dummy="edge-label",u.labelpos=l.labelpos),e.setEdge(n,d,{weight:l.weight},i),p===0&&e.graph().dummyChains.push(d),n=d;e.setEdge(n,s,{weight:l.weight},i)}function QW(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,s;for(e.setEdge(n.edgeObj,r);n.dummy;)s=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=s,n=e.node(t)})}function ku(e){let t={};function n(r){let s=e.node(r);if(Object.hasOwn(t,r))return s.rank;t[r]=!0;let a=e.outEdges(r),i=a?a.map(c=>c==null?Number.POSITIVE_INFINITY:n(c.w)-e.edge(c).minlen):[],l=Wt(Math.min,i);return l===Number.POSITIVE_INFINITY&&(l=0),s.rank=l}e.sources().forEach(n)}function Vr(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Yw=GW;function GW(e){let t=new $t({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let r=n[0],s=e.nodeCount();t.setNode(r,{});let a,i;for(;KW(t,e)<s&&(a=WW(t,e),!!a);)i=t.hasNode(a.v)?Vr(e,a):-Vr(e,a),YW(t,e,i);return t}function KW(e,t){function n(r){let s=t.nodeEdges(r);s&&s.forEach(a=>{let i=a.v,l=r===i?a.w:i;!e.hasNode(l)&&!Vr(t,a)&&(e.setNode(l,{}),e.setEdge(r,l,{}),n(l))})}return e.nodes().forEach(n),e.nodeCount()}function WW(e,t){return t.edges().reduce((n,r)=>{let s=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(s=Vr(t,r)),s<n[0]?[s,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function YW(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:ZW,postorder:XW}=wu,JW=xr;xr.initLowLimValues=Cu;xr.initCutValues=Su;xr.calcCutValue=Zw;xr.leaveEdge=Jw;xr.enterEdge=eN;xr.exchangeEdges=tN;function xr(e){e=CW(e),ku(e);let t=Yw(e);Cu(t),Su(t,e);let n,r;for(;n=Jw(t);)r=eN(t,e,n),tN(t,e,n,r)}function Su(e,t){let n=XW(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>eY(e,t,r))}function eY(e,t,n){let r=e.node(n).parent,s=e.edge(n,r);s.cutvalue=Zw(e,t,n)}function Zw(e,t,n){let r=e.node(n).parent,s=!0,a=t.edge(n,r),i=0;a||(s=!1,a=t.edge(r,n)),i=a.weight;let l=t.nodeEdges(n);return l&&l.forEach(c=>{let d=c.v===n,u=d?c.w:c.v;if(u!==r){let p=d===s,h=t.edge(c).weight;if(i+=p?h:-h,nY(e,n,u)){let m=e.edge(n,u).cutvalue;i+=p?-m:m}}}),i}function Cu(e,t){arguments.length<2&&(t=e.nodes()[0]),Xw(e,{},1,t)}function Xw(e,t,n,r,s){let a=n,i=e.node(r);t[r]=!0;let l=e.neighbors(r);return l&&l.forEach(c=>{Object.hasOwn(t,c)||(n=Xw(e,t,n,c,r))}),i.low=a,i.lim=n++,s?i.parent=s:delete i.parent,n}function Jw(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function eN(e,t,n){let r=n.v,s=n.w;t.hasEdge(r,s)||(r=n.w,s=n.v);let a=e.node(r),i=e.node(s),l=a,c=!1;return a.lim>i.lim&&(l=i,c=!0),t.edges().filter(d=>c===Hh(e,e.node(d.v),l)&&c!==Hh(e,e.node(d.w),l)).reduce((d,u)=>Vr(t,u)<Vr(t,d)?u:d)}function tN(e,t,n,r){let s=n.v,a=n.w;e.removeEdge(s,a),e.setEdge(r.v,r.w,{}),Cu(e),Su(e,t),tY(e,t)}function tY(e,t){let n=e.nodes().find(s=>!e.node(s).parent);if(!n)return;let r=ZW(e,[n]);r=r.slice(1),r.forEach(s=>{let a=e.node(s).parent,i=t.edge(s,a),l=!1;i||(i=t.edge(a,s),l=!0),t.node(s).rank=t.node(a).rank+(l?i.minlen:-i.minlen)})}function nY(e,t,n){return e.hasEdge(t,n)}function Hh(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var rY=oY;function oY(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":qh(e);break;case"tight-tree":aY(e);break;case"longest-path":sY(e);break;case"none":break;default:qh(e)}}var sY=ku;function aY(e){ku(e),Yw(e)}function qh(e){JW(e)}var iY=lY;function lY(e){let t=dY(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),s=r.edgeObj,a=cY(e,t,s.v,s.w),i=a.path,l=a.lca,c=0,d=i[c],u=!0;for(;n!==s.w;){if(r=e.node(n),u){for(;(d=i[c])!==l&&e.node(d).maxRank<r.rank;)c++;d===l&&(u=!1)}if(!u){for(;c<i.length-1&&e.node(i[c+1]).minRank<=r.rank;)c++;d=i[c]}d!==void 0&&e.setParent(n,d),n=e.successors(n)[0]}})}function cY(e,t,n,r){let s=[],a=[],i=Math.min(t[n].low,t[r].low),l=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),s.push(c);while(c&&(t[c].low>i||l>t[c].lim));let d=c,u=r;for(;(u=e.parent(u))!==d;)a.push(u);return{path:s.concat(a.reverse()),lca:d}}function dY(e){let t={},n=0;function r(s){let a=n;e.children(s).forEach(r),t[s]={low:a,lim:n++}}return e.children(xi).forEach(r),t}function uY(e){let t=no(e,"root",{},"_root"),n=pY(e),r=Object.values(n),s=Wt(Math.max,r)-1,a=2*s+1;e.graph().nestingRoot=t,e.edges().forEach(l=>e.edge(l).minlen*=a);let i=fY(e)+1;e.children(xi).forEach(l=>nN(e,t,a,i,s,n,l)),e.graph().nodeRankFactor=a}function nN(e,t,n,r,s,a,i){var l;let c=e.children(i);if(!c.length){i!==t&&e.setEdge(t,i,{weight:0,minlen:n});return}let d=jh(e,"_bt"),u=jh(e,"_bb"),p=e.node(i);e.setParent(d,i),p.borderTop=d,e.setParent(u,i),p.borderBottom=u,c.forEach(h=>{var m;nN(e,t,n,r,s,a,h);let g=e.node(h),b=g.borderTop?g.borderTop:h,x=g.borderBottom?g.borderBottom:h,y=g.borderTop?r:2*r,w=b!==x?1:s-((m=a[i])!=null?m:0)+1;e.setEdge(d,b,{weight:y,minlen:w,nestingEdge:!0}),e.setEdge(x,u,{weight:y,minlen:w,nestingEdge:!0})}),e.parent(i)||e.setEdge(t,d,{weight:0,minlen:s+((l=a[i])!=null?l:0)})}function pY(e){let t={};function n(r,s){let a=e.children(r);a&&a.length&&a.forEach(i=>n(i,s+1)),t[r]=s}return e.children(xi).forEach(r=>n(r,1)),t}function fY(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function hY(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var mY=gY;function gY(e){function t(n){let r=e.children(n),s=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(s,"minRank")){s.borderLeft=[],s.borderRight=[];for(let a=s.minRank,i=s.maxRank+1;a<i;++a)Uh(e,"borderLeft","_bl",n,s,a),Uh(e,"borderRight","_br",n,s,a)}}e.children(xi).forEach(t)}function Uh(e,t,n,r,s,a){let i={width:0,height:0,rank:a,borderType:t},l=s[t][a-1],c=no(e,"border",i,n);s[t][a]=c,e.setParent(c,r),l&&e.setEdge(l,c,{weight:1})}function bY(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&rN(e)}function xY(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&yY(e),(n==="lr"||n==="rl")&&(vY(e),rN(e))}function rN(e){e.nodes().forEach(t=>Qh(e.node(t))),e.edges().forEach(t=>Qh(e.edge(t)))}function Qh(e){let t=e.width;e.width=e.height,e.height=t}function yY(e){e.nodes().forEach(t=>xl(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(xl),Object.hasOwn(r,"y")&&xl(r)})}function xl(e){e.y=-e.y}function vY(e){e.nodes().forEach(t=>yl(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(yl),Object.hasOwn(r,"x")&&yl(r)})}function yl(e){let t=e.x;e.x=e.y,e.y=t}function wY(e){let t={},n=e.nodes().filter(l=>!e.children(l).length),r=n.map(l=>e.node(l).rank),s=Wt(Math.max,r),a=Ho(s+1).map(()=>[]);function i(l){if(t[l])return;t[l]=!0;let c=e.node(l);a[c.rank].push(l);let d=e.successors(l);d&&d.forEach(i)}return n.sort((l,c)=>e.node(l).rank-e.node(c).rank).forEach(i),a}function NY(e,t){let n=0;for(let r=1;r<t.length;++r)n+=kY(e,t[r-1],t[r]);return n}function kY(e,t,n){let r=_W(n,n.map((d,u)=>u)),s=t.flatMap(d=>{let u=e.outEdges(d);return u?u.map(p=>({pos:r[p.w],weight:e.edge(p).weight})).sort((p,h)=>p.pos-h.pos):[]}),a=1;for(;a<n.length;)a<<=1;let i=2*a-1;a-=1;let l=new Array(i).fill(0),c=0;return s.forEach(d=>{let u=d.pos+a;l[u]+=d.weight;let p=0;for(;u>0;)u%2&&(p+=l[u+1]),u=u-1>>1,l[u]+=d.weight;c+=d.weight*p}),c}function SY(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(!r||!r.length)return{v:n};{let s=r.reduce((a,i)=>{let l=e.edge(i),c=e.node(i.v);return{sum:a.sum+l.weight*c.order,weight:a.weight+l.weight}},{sum:0,weight:0});return{v:n,barycenter:s.sum/s.weight,weight:s.weight}}})}function CY(e,t){let n={};e.forEach((s,a)=>{let i={indegree:0,in:[],out:[],vs:[s.v],i:a};s.barycenter!==void 0&&(i.barycenter=s.barycenter,i.weight=s.weight),n[s.v]=i}),t.edges().forEach(s=>{let a=n[s.v],i=n[s.w];a!==void 0&&i!==void 0&&(i.indegree++,a.out.push(i))});let r=Object.values(n).filter(s=>!s.indegree);return MY(r)}function MY(e){let t=[];function n(s){return a=>{a.merged||(a.barycenter===void 0||s.barycenter===void 0||a.barycenter>=s.barycenter)&&EY(s,a)}}function r(s){return a=>{a.in.push(s),--a.indegree===0&&e.push(a)}}for(;e.length;){let s=e.pop();t.push(s),s.in.reverse().forEach(n(s)),s.out.forEach(r(s))}return t.filter(s=>!s.merged).map(s=>Ia(s,["vs","i","barycenter","weight"]))}function EY(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function IY(e,t){let n=AW(e,u=>Object.hasOwn(u,"barycenter")),r=n.lhs,s=n.rhs.sort((u,p)=>p.i-u.i),a=[],i=0,l=0,c=0;r.sort(AY(!!t)),c=Gh(a,s,c),r.forEach(u=>{c+=u.vs.length,a.push(u.vs),i+=u.barycenter*u.weight,l+=u.weight,c=Gh(a,s,c)});let d={vs:a.flat(1)};return l&&(d.barycenter=i/l,d.weight=l),d}function Gh(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function AY(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function oN(e,t,n,r){let s=e.children(t),a=e.node(t),i=a?a.borderLeft:void 0,l=a?a.borderRight:void 0,c={};i&&(s=s.filter(h=>h!==i&&h!==l));let d=SY(e,s);d.forEach(h=>{if(e.children(h.v).length){let m=oN(e,h.v,n,r);c[h.v]=m,Object.hasOwn(m,"barycenter")&&_Y(h,m)}});let u=CY(d,n);PY(u,c);let p=IY(u,r);if(i&&l){p.vs=[i,p.vs,l].flat(1);let h=e.predecessors(i);if(h&&h.length){let m=e.node(h[0]),g=e.predecessors(l),b=e.node(g[0]);Object.hasOwn(p,"barycenter")||(p.barycenter=0,p.weight=0),p.barycenter=(p.barycenter*p.weight+m.order+b.order)/(p.weight+2),p.weight+=2}}return p}function PY(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function _Y(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function $Y(e,t,n,r){r||(r=e.nodes());let s=DY(e),a=new $t({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(i=>e.node(i));return r.forEach(i=>{let l=e.node(i),c=e.parent(i);if(l.rank===t||l.minRank<=t&&t<=l.maxRank){a.setNode(i),a.setParent(i,c||s);let d=e[n](i);d&&d.forEach(u=>{let p=u.v===i?u.w:u.v,h=a.edge(p,i),m=h!==void 0?h.weight:0;a.setEdge(p,i,{weight:e.edge(u).weight+m})}),Object.hasOwn(l,"minRank")&&a.setNode(i,{borderLeft:l.borderLeft[t],borderRight:l.borderRight[t]})}}),a}function DY(e){let t;for(;e.hasNode(t=Nu("_root")););return t}function TY(e,t,n){let r={},s;n.forEach(a=>{let i=e.parent(a),l,c;for(;i;){if(l=e.parent(i),l?(c=r[l],r[l]=i):(c=s,s=i),c&&c!==i){t.setEdge(c,i);return}i=l}})}function sN(e,t={}){if(typeof t.customOrder=="function"){t.customOrder(e,sN);return}let n=Gw(e),r=Kh(e,Ho(1,n+1),"inEdges"),s=Kh(e,Ho(n-1,-1,-1),"outEdges"),a=wY(e);if(Wh(e,a),t.disableOptimalOrderHeuristic)return;let i=Number.POSITIVE_INFINITY,l,c=t.constraints||[];for(let d=0,u=0;u<4;++d,++u){LY(d%2?r:s,d%4>=2,c),a=cs(e);let p=NY(e,a);p<i?(u=0,l=Object.assign({},a),i=p):p===i&&(l=structuredClone(a))}Wh(e,l)}function Kh(e,t,n){let r=new Map,s=(a,i)=>{r.has(a)||r.set(a,[]),r.get(a).push(i)};for(let a of e.nodes()){let i=e.node(a);if(typeof i.rank=="number"&&s(i.rank,a),typeof i.minRank=="number"&&typeof i.maxRank=="number")for(let l=i.minRank;l<=i.maxRank;l++)l!==i.rank&&s(l,a)}return t.map(function(a){return $Y(e,a,n,r.get(a)||[])})}function LY(e,t,n){let r=new $t;e.forEach(function(s){n.forEach(l=>r.setEdge(l.left,l.right));let a=s.graph().root,i=oN(s,a,r,t);i.vs.forEach((l,c)=>s.node(l).order=c),TY(s,r,i.vs)})}function Wh(e,t){Object.values(t).forEach(n=>n.forEach((r,s)=>e.node(r).order=s))}function RY(e,t){let n={};function r(s,a){let i=0,l=0,c=s.length,d=a[a.length-1];return a.forEach((u,p)=>{let h=BY(e,u),m=h?e.node(h).order:c;(h||u===d)&&(a.slice(l,p+1).forEach(g=>{let b=e.predecessors(g);b&&b.forEach(x=>{let y=e.node(x),w=y.order;(w<i||m<w)&&!(y.dummy&&e.node(g).dummy)&&aN(n,x,g)})}),l=p+1,i=m)}),a}return t.length&&t.reduce(r),n}function OY(e,t){let n={};function r(a,i,l,c,d){Ho(i,l).forEach(u=>{let p=a[u];if(p!==void 0&&e.node(p).dummy){let h=e.predecessors(p);h&&h.forEach(m=>{if(m===void 0)return;let g=e.node(m);g.dummy&&(g.order<c||g.order>d)&&aN(n,m,p)})}})}function s(a,i){let l=-1,c=-1,d=0;return i.forEach((u,p)=>{if(e.node(u).dummy==="border"){let h=e.predecessors(u);if(h&&h.length){let m=h[0];if(m===void 0)return;c=e.node(m).order,r(i,d,p,l,c),d=p,l=c}}r(i,d,i.length,c,a.length)}),i}return t.length&&t.reduce(s),n}function BY(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function aN(e,t,n){if(t>n){let s=t;t=n,n=s}let r=e[t];r||(e[t]=r={}),r[n]=!0}function zY(e,t,n){if(t>n){let s=t;t=n,n=s}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function FY(e,t,n,r){let s={},a={},i={};return t.forEach(l=>{l.forEach((c,d)=>{s[c]=c,a[c]=c,i[c]=d})}),t.forEach(l=>{let c=-1;l.forEach(d=>{let u=r(d);if(u&&u.length){let p=u.sort((m,g)=>{let b=i[m],x=i[g];return(b!==void 0?b:0)-(x!==void 0?x:0)}),h=(p.length-1)/2;for(let m=Math.floor(h),g=Math.ceil(h);m<=g;++m){let b=p[m];if(b===void 0)continue;let x=i[b];if(x!==void 0&&a[d]===d&&c<x&&!zY(n,d,b)){let y=s[b];y!==void 0&&(a[b]=d,a[d]=s[d]=y,c=x)}}}})}),{root:s,align:a}}function jY(e,t,n,r,s=!1){let a={},i=VY(e,t,n,s),l=s?"borderLeft":"borderRight";function c(m,g){let b=i.nodes().slice(),x={},y=b.pop();for(;y;){if(x[y])m(y);else{x[y]=!0,b.push(y);for(let w of g(y))b.push(w)}y=b.pop()}}function d(m){let g=i.inEdges(m);g?a[m]=g.reduce((b,x)=>{var y;let w=(y=a[x.v])!=null?y:0,v=i.edge(x);return Math.max(b,w+(v!==void 0?v:0))},0):a[m]=0}function u(m){let g=i.outEdges(m),b=Number.POSITIVE_INFINITY;g&&(b=g.reduce((y,w)=>{let v=a[w.w],N=i.edge(w);return Math.min(y,(v!==void 0?v:0)-(N!==void 0?N:0))},Number.POSITIVE_INFINITY));let x=e.node(m);b!==Number.POSITIVE_INFINITY&&x.borderType!==l&&(a[m]=Math.max(a[m]!==void 0?a[m]:0,b))}function p(m){return i.predecessors(m)||[]}function h(m){return i.successors(m)||[]}return c(d,p),c(u,h),Object.keys(r).forEach(m=>{var g;let b=n[m];b!==void 0&&(a[m]=(g=a[b])!=null?g:0)}),a}function VY(e,t,n,r){let s=new $t,a=e.graph(),i=GY(a.nodesep,a.edgesep,r);return t.forEach(l=>{let c;l.forEach(d=>{let u=n[d];if(u!==void 0){if(s.setNode(u),c!==void 0){let p=n[c];if(p!==void 0){let h=s.edge(p,u);s.setEdge(p,u,Math.max(i(e,d,c),h||0))}}c=d}})}),s}function HY(e,t){return Object.values(t).reduce((n,r)=>{let s=Number.NEGATIVE_INFINITY,a=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([l,c])=>{let d=KY(e,l)/2;s=Math.max(c+d,s),a=Math.min(c-d,a)});let i=s-a;return i<n[0]&&(n=[i,r]),n},[Number.POSITIVE_INFINITY,null])[1]}function qY(e,t){let n=Object.values(t),r=Wt(Math.min,n),s=Wt(Math.max,n);["u","d"].forEach(a=>{["l","r"].forEach(i=>{let l=a+i,c=e[l];if(!c||c===t)return;let d=Object.values(c),u=r-Wt(Math.min,d);i!=="l"&&(u=s-Wt(Math.max,d)),u&&(e[l]=bi(c,p=>p+u))})})}function UY(e,t=void 0){let n=e.ul;return n?bi(n,(r,s)=>{var a,i;if(t){let c=t.toLowerCase(),d=e[c];if(d&&d[s]!==void 0)return d[s]}let l=Object.values(e).map(c=>{let d=c[s];return d!==void 0?d:0}).sort((c,d)=>c-d);return(((a=l[1])!=null?a:0)+((i=l[2])!=null?i:0))/2}):{}}function QY(e){let t=cs(e),n=Object.assign(RY(e,t),OY(e,t)),r={},s;["u","d"].forEach(i=>{s=i==="u"?t:Object.values(t).reverse(),["l","r"].forEach(l=>{l==="r"&&(s=s.map(u=>Object.values(u).reverse()));let c=FY(e,s,n,u=>(i==="u"?e.predecessors(u):e.successors(u))||[]),d=jY(e,s,c.root,c.align,l==="r");l==="r"&&(d=bi(d,u=>-u)),r[i+l]=d})});let a=HY(e,r);return qY(r,a),UY(r,e.graph().align)}function GY(e,t,n){return(r,s,a)=>{let i=r.node(s),l=r.node(a),c=0,d;if(c+=i.width/2,Object.hasOwn(i,"labelpos"))switch(i.labelpos.toLowerCase()){case"l":d=-i.width/2;break;case"r":d=i.width/2;break}if(d&&(c+=n?d:-d),d=void 0,c+=(i.dummy?t:e)/2,c+=(l.dummy?t:e)/2,c+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":d=l.width/2;break;case"r":d=-l.width/2;break}return d&&(c+=n?d:-d),c}}function KY(e,t){return e.node(t).width}function WY(e){e=Uw(e),YY(e),Object.entries(QY(e)).forEach(([t,n])=>e.node(t).x=n)}function YY(e){let t=cs(e),n=e.graph(),r=n.ranksep,s=n.rankalign,a=0;t.forEach(i=>{let l=i.reduce((c,d)=>{var u;let p=(u=e.node(d).height)!=null?u:0;return c>p?c:p},0);i.forEach(c=>{let d=e.node(c);s==="top"?d.y=a+d.height/2:s==="bottom"?d.y=a+l-d.height/2:d.y=a+l/2}),a+=l+r})}function ZY(e,t={}){let n=t.debugTiming?Kw:Ww;return n("layout",()=>{let r=n(" buildLayoutGraph",()=>iZ(e));return n(" runLayout",()=>XY(r,n,t)),n(" updateInputGraph",()=>JY(e,r)),r})}function XY(e,t,n){t(" makeSpaceForEdgeLabels",()=>lZ(e)),t(" removeSelfEdges",()=>bZ(e)),t(" acyclic",()=>jW(e)),t(" nestingGraph.run",()=>uY(e)),t(" rank",()=>rY(Uw(e))),t(" injectEdgeLabelProxies",()=>cZ(e)),t(" removeEmptyRanks",()=>EW(e)),t(" nestingGraph.cleanup",()=>hY(e)),t(" normalizeRanks",()=>MW(e)),t(" assignRankMinMax",()=>dZ(e)),t(" removeEdgeLabelProxies",()=>uZ(e)),t(" normalize.run",()=>qW(e)),t(" parentDummyChains",()=>iY(e)),t(" addBorderSegments",()=>mY(e)),t(" order",()=>sN(e,n)),t(" insertSelfEdges",()=>xZ(e)),t(" adjustCoordinateSystem",()=>bY(e)),t(" position",()=>WY(e)),t(" positionSelfEdges",()=>yZ(e)),t(" removeBorderNodes",()=>gZ(e)),t(" normalize.undo",()=>QW(e)),t(" fixupEdgeLabelCoords",()=>hZ(e)),t(" undoCoordinateSystem",()=>xY(e)),t(" translateGraph",()=>pZ(e)),t(" assignNodeIntersects",()=>fZ(e)),t(" reversePoints",()=>mZ(e)),t(" acyclic.undo",()=>HW(e))}function JY(e,t){e.nodes().forEach(n=>{let r=e.node(n),s=t.node(n);r&&(r.x=s.x,r.y=s.y,r.order=s.order,r.rank=s.rank,t.children(n).length&&(r.width=s.width,r.height=s.height))}),e.edges().forEach(n=>{let r=e.edge(n),s=t.edge(n);r.points=s.points,Object.hasOwn(s,"x")&&(r.x=s.x,r.y=s.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var eZ=["nodesep","edgesep","ranksep","marginx","marginy"],tZ={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},nZ=["acyclicer","ranker","rankdir","align","rankalign"],rZ=["width","height","rank"],Yh={width:0,height:0},oZ=["minlen","weight","width","height","labeloffset"],sZ={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},aZ=["labelpos"];function iZ(e){let t=new $t({multigraph:!0,compound:!0}),n=wl(e.graph());return t.setGraph(Object.assign({},tZ,vl(n,eZ),Ia(n,nZ))),e.nodes().forEach(r=>{let s=wl(e.node(r)),a=vl(s,rZ);Object.keys(Yh).forEach(l=>{a[l]===void 0&&(a[l]=Yh[l])}),t.setNode(r,a);let i=e.parent(r);i!==void 0&&t.setParent(r,i)}),e.edges().forEach(r=>{let s=wl(e.edge(r));t.setEdge(r,Object.assign({},sZ,vl(s,oZ),Ia(s,aZ)))}),t}function lZ(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function cZ(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),s={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};no(e,"edge-proxy",s,"_ep")}})}function dZ(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function uZ(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function pZ(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,s=0,a=e.graph(),i=a.marginx||0,l=a.marginy||0;function c(d){let u=d.x,p=d.y,h=d.width,m=d.height;t=Math.min(t,u-h/2),n=Math.max(n,u+h/2),r=Math.min(r,p-m/2),s=Math.max(s,p+m/2)}e.nodes().forEach(d=>c(e.node(d))),e.edges().forEach(d=>{let u=e.edge(d);Object.hasOwn(u,"x")&&c(u)}),t-=i,r-=l,e.nodes().forEach(d=>{let u=e.node(d);u.x-=t,u.y-=r}),e.edges().forEach(d=>{let u=e.edge(d);u.points.forEach(p=>{p.x-=t,p.y-=r}),Object.hasOwn(u,"x")&&(u.x-=t),Object.hasOwn(u,"y")&&(u.y-=r)}),a.width=n-t+i,a.height=s-r+l}function fZ(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),s=e.node(t.w),a,i;n.points?(a=n.points[0],i=n.points[n.points.length-1]):(n.points=[],a=s,i=r),n.points.unshift(Fh(r,a)),n.points.push(Fh(s,i))})}function hZ(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function mZ(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function gZ(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),s=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),i=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(i.x-a.x),n.height=Math.abs(s.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function bZ(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function xZ(e){cs(e).forEach(t=>{let n=0;t.forEach((r,s)=>{let a=e.node(r);a.order=s+n,(a.selfEdges||[]).forEach(i=>{no(e,"selfedge",{width:i.label.width,height:i.label.height,rank:a.rank,order:s+ ++n,e:i.e,label:i.label},"_se")}),delete a.selfEdges})})}function yZ(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="selfedge"){let r=n,s=e.node(r.e.v),a=s.x+s.width/2,i=s.y,l=n.x-a,c=s.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:a+2*l/3,y:i-c},{x:a+5*l/6,y:i-c},{x:a+l,y:i},{x:a+5*l/6,y:i+c},{x:a+2*l/3,y:i+c}],r.label.x=n.x,r.label.y=n.y}})}function vl(e,t){return bi(Ia(e,t),Number)}function wl(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function vZ(e){let t=cs(e),n=new $t({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>n.setEdge(r.v,r.w,{},r.name)),t.forEach((r,s)=>{let a="layer"+s;n.setNode(a,{rank:"same"}),r.reduce((i,l)=>(n.setEdge(i,l,{style:"invis"}),l))}),n}var wZ={graphlib:Rw,version:$W,layout:ZY,debug:vZ,util:{time:Kw,notime:Ww}},Zh=wZ;/*! For license information please see dagre.esm.js.LEGAL.txt */function NZ({data:e,selected:t}){const n=e.isOnline,r=e.isHub,s=e.engines??[],a=e.addons??[],i=e.processes??[],l=e.name,c=e.hostname,d=e.localIps??[],u=e.cpuPercent,p=e.memoryPercent,h=e.isExpanded,m=e.onToggleExpand,g=e.onShowNodeLogs,b=e.onRestartNode,x=e.id,y=i.length,w=U(E=>{E.stopPropagation(),m?.()},[m]),v=U(E=>{E.stopPropagation(),g?.()},[g]),N=U(E=>{E.stopPropagation(),b?.()},[b]);return f("div",{className:`rounded-xl bg-surface px-3 py-2.5 min-w-[180px] max-w-[260px] transition-all duration-200 ${n?r?"border-2 border-success":"border-2 border-dashed border-primary/60 bg-primary/5":"border-2 border-dashed border-muted-foreground/30 opacity-50"} ${t?"ring-2 ring-primary ring-offset-1":""}`,children:[o(Tn,{type:"target",position:we.Top,className:"!bg-border !w-2 !h-2"}),f("div",{className:"flex items-center gap-1.5 mb-1.5",children:[o("div",{className:`w-2 h-2 rounded-full ${n?"bg-success":"bg-destructive"}`}),o("span",{className:"text-xs font-semibold truncate flex-1",children:l}),r?o("span",{className:"text-[8px] px-1 py-0.5 rounded bg-primary/10 text-primary font-medium",children:"HUB"}):o("span",{className:"text-[8px] px-1 py-0.5 rounded bg-muted text-muted-foreground font-medium",children:"AGENT"})]}),(c||d.length>0)&&(()=>{const E=d.filter(I=>!I.includes(":"));return f("div",{className:"text-[9px] text-muted-foreground mb-1 space-y-0.5",title:[c,...d].filter(Boolean).join(", "),children:[c&&o("div",{className:"truncate",children:c}),E.length>0&&o("div",{className:"truncate font-mono opacity-70",children:E.join(", ")})]})})(),s.length>0&&o("div",{className:"flex flex-wrap gap-1 mb-1.5",children:s.map(E=>o("span",{className:"text-[8px] px-1 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:E},E))}),a.length>0&&f("div",{className:"text-[9px] text-muted-foreground mb-1",children:[a.length," addon",a.length!==1?"s":""," in-process"]}),n&&f("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground",children:[f("span",{className:"flex items-center gap-0.5",children:[o(bt,{className:"h-2.5 w-2.5"}),u,"%"]}),f("span",{className:"flex items-center gap-0.5",children:[o(Xd,{className:"h-2.5 w-2.5"}),p,"%"]}),f("div",{className:"flex items-center gap-1 ml-auto",children:[y>0&&f("button",{onClick:w,className:"flex items-center gap-0.5 px-1 py-0.5 rounded hover:bg-amber-500/10 text-amber-500 transition-colors",title:h?"Collapse processes":`Expand ${y} process${y!==1?"es":""}`,children:[h?o(lt,{className:"h-3 w-3"}):o(wt,{className:"h-3 w-3"}),o("span",{className:"text-[9px] font-medium",children:y})]}),o("button",{onClick:v,className:"p-0.5 rounded hover:bg-primary/10 text-muted-foreground hover:text-primary transition-colors",title:`Logs: ${x}`,children:o(at,{className:"h-3 w-3"})}),o("button",{onClick:N,className:"p-0.5 rounded hover:bg-primary/10 text-muted-foreground hover:text-primary transition-colors",title:"Restart all processes",children:o(kt,{className:"h-3 w-3"})})]})]}),!n&&o("div",{className:"text-[10px] text-muted-foreground",children:"offline"}),o(Tn,{type:"source",position:we.Bottom,className:"!bg-border !w-2 !h-2"})]})}const kZ=He(NZ);function SZ(e){return e===0?"0":e<1024*1024?`${Math.round(e/1024)}K`:e<1024*1024*1024?`${Math.round(e/(1024*1024))}M`:`${(e/(1024*1024*1024)).toFixed(1)}G`}function CZ({data:e}){const t=e.name,n=e.state,r=e.pid,s=e.cpuPercent,a=e.memoryRss,i=e.addonId,l=e.services??[],c=e.isExpanded,d=e.onToggleServices,u=e.parentNodeId,p=e.onShowLogs,h=e.onRestartAddon,m=n==="running",g=t.includes("(core)"),b=!g&&l.length===1,x=b?l[0]:null,y=u??"hub",w=`${y}/${t}`,v=U(E=>{E.stopPropagation(),d?.()},[d]),N=g?hn:Ka,k=g?"border-primary/50":m?"border-amber-500/50":"border-destructive/50",C=g?"text-primary":"text-amber-500";return f("div",{className:`rounded-lg bg-surface min-w-[150px] border ${k} ${c?"max-w-[240px]":"max-w-[210px]"}`,children:[o(Tn,{type:"target",position:we.Top,className:`!w-1.5 !h-1.5 ${g?"!bg-primary":"!bg-amber-500"}`}),f("div",{className:"px-2.5 pt-2 pb-1.5",children:[f("div",{className:"flex items-start gap-1.5 mb-1.5",children:[o(N,{className:`h-3 w-3 ${C} shrink-0 mt-0.5`}),o("span",{className:"text-[10px] font-semibold truncate flex-1",children:g?"core":i??t}),o("span",{className:"text-[8px] text-muted-foreground/60 tabular-nums shrink-0",children:r})]}),f("div",{className:"flex items-center gap-2 text-[9px] text-muted-foreground",children:[o("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${m?"bg-success":"bg-destructive"}`}),f("span",{className:"flex items-center gap-0.5",children:[o(bt,{className:"h-2 w-2"}),s,"%"]}),f("span",{className:"flex items-center gap-0.5",children:[o(Xd,{className:"h-2 w-2"}),SZ(a)]}),b&&x?f("div",{className:"flex items-center gap-0.5 ml-auto",children:[o("button",{onClick:E=>{E.stopPropagation(),p?.(x.addonId,y)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Logs: ${x.addonId}`,children:o(at,{className:"h-2.5 w-2.5"})}),o("button",{onClick:E=>{E.stopPropagation(),h?.(x.addonId,w)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Restart: ${x.addonId}`,children:o(kt,{className:"h-2.5 w-2.5"})})]}):l.length>0?f("button",{onClick:v,className:"flex items-center gap-0.5 ml-auto px-0.5 rounded hover:bg-blue-500/10 text-blue-400 transition-colors",title:c?"Hide addons":`Show ${l.length} addon${l.length!==1?"s":""}`,children:[c?o(lt,{className:"h-2.5 w-2.5"}):o(wt,{className:"h-2.5 w-2.5"}),o("span",{className:"text-[8px] font-medium",children:l.length})]}):null]})]}),c&&l.length>0&&!b&&o("div",{className:"border-t border-border/40 px-2 py-1 space-y-0.5 max-h-[200px] overflow-y-auto",children:l.map(E=>{const I=g?y:`${y}/${t}`;return f("div",{className:"flex items-center gap-1 py-0.5",children:[o("div",{className:`w-1 h-1 rounded-full shrink-0 ${E.status==="running"?"bg-success":"bg-muted-foreground/30"}`}),o("span",{className:"text-[9px] truncate flex-1",children:E.addonId}),o("button",{onClick:A=>{A.stopPropagation(),p?.(E.addonId,y)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Logs: ${E.addonId}`,children:o(at,{className:"h-2.5 w-2.5"})}),o("button",{onClick:A=>{A.stopPropagation(),h?.(E.addonId,I)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Restart: ${E.addonId}`,children:o(kt,{className:"h-2.5 w-2.5"})})]},E.addonId)})}),o(Tn,{type:"source",position:we.Bottom,className:`!w-1.5 !h-1.5 ${g?"!bg-primary":"!bg-amber-500"}`})]})}const MZ=He(CZ),EZ={clusterNode:kZ,processNode:MZ},wr={cluster:{width:320,height:170},process:{width:240,height:100},processExpanded:{width:240,height:240}};function IZ(e){return typeof e=="object"&&e!==null&&typeof e.x=="number"&&typeof e.y=="number"}function AZ(e,t){const n=new Zh.graphlib.Graph;n.setGraph({rankdir:"TB",nodesep:40,ranksep:80,marginx:30,marginy:30}),n.setDefaultEdgeLabel(()=>({}));for(const s of e){const a=s.type==="processNode"&&!!s.data?.isExpanded,i=s.type==="clusterNode"?wr.cluster:a?wr.processExpanded:wr.process;n.setNode(s.id,{width:i.width,height:i.height})}for(const s of t)n.setEdge(s.source,s.target);Zh.layout(n);const r=new Map;for(const s of e){const a=n.node(s.id);if(!IZ(a))continue;const i=s.type==="processNode"&&!!s.data?.isExpanded,l=s.type==="clusterNode"?wr.cluster:i?wr.processExpanded:wr.process;r.set(s.id,{x:a.x-l.width/2,y:a.y-l.height/2})}return r}function PZ({topology:e}){const{resolvedMode:t}=Hr(),n=Lx(),r=Ba(),[,s]=_(null),[a,i]=_(()=>e.length<=1?new Set(e.map(E=>E.id)):new Set),[l,c]=_(null),[d,u]=_(null),p=U((E,I)=>{u(A=>A?.addonId===E&&A?.agentId===I?null:{addonId:E,agentId:I})},[]),h=U(E=>{u(I=>I?.agentId===E&&!I?.addonId?null:{agentId:E})},[]),m=U(async E=>{try{await n.mutateAsync({nodeId:E})}catch(I){console.error("Failed to restart node:",I)}},[n]),g=U(async(E,I)=>{try{await r.mutateAsync({nodeId:I,addonId:E})}catch(A){console.error("Failed to restart addon:",A)}},[r]),b=U(E=>{i(I=>{const A=new Set(I);return A.has(E)?A.delete(E):A.add(E),A})},[]),x=U(E=>{c(I=>I===E?null:E)},[]),y=U(E=>{s(E)},[]),w=H(()=>{const E=e.filter(M=>M.isHub),I=e.filter(M=>!M.isHub),A=[],z=[],P=E[0]?.id;function B(M,D){const T=[...D];if(T.length!==0)for(const L of T){const O=`proc:${M}/${L.name}`,F=L.services??[],j=l===O;A.push({id:O,type:"processNode",position:{x:0,y:0},data:{...L,addonId:L.name.includes("(core)")?void 0:F.length>1?L.name:F[0]?.addonId??L.name,parentNodeId:M,services:F,isExpanded:j,onToggleServices:()=>x(O),onShowLogs:p,onRestartAddon:g}}),z.push({id:`edge:${M}-${O}`,source:M,target:O,animated:!0,style:{stroke:"var(--amber-500, #f59e0b)",strokeWidth:1,strokeDasharray:"4 4"}})}}for(const M of E)A.push({id:M.id,type:"clusterNode",position:{x:0,y:0},data:{...M,label:M.name,isExpanded:a.has(M.id),onToggleExpand:()=>b(M.id),onShowDetail:()=>y(M.id),onShowNodeLogs:()=>h(M.id),onRestartNode:()=>m(M.id)}}),a.has(M.id)&&B(M.id,M.processes??[]);for(const M of I)A.push({id:M.id,type:"clusterNode",position:{x:0,y:0},data:{...M,label:M.name,isExpanded:a.has(M.id),onToggleExpand:()=>b(M.id),onShowDetail:()=>y(M.id),onShowNodeLogs:()=>h(M.id),onRestartNode:()=>m(M.id)}}),P&&M.isOnline&&z.push({id:`${P}-${M.id}`,source:P,target:M.id,animated:!0,style:{stroke:"var(--border)",strokeWidth:1.5}}),a.has(M.id)&&B(M.id,M.processes??[]);const R=AZ(A,z);for(const M of A){const D=R.get(M.id);D&&(M.position=D)}return{nodes:A,edges:z}},[e,a,l,b,x,y,p,h,m,g]),v=te(new Map),N=H(()=>{const E=v.current;return w.nodes.map(A=>({...A,position:E.get(A.id)??A.position}))},[w.nodes]),k=U(E=>{for(const I of E)I.type==="position"&&I.position&&v.current.set(I.id,I.position)},[]),C=U(()=>s(null),[]);return o("div",{className:"flex flex-col gap-4 flex-1",children:f("div",{className:"relative flex-1 min-h-[350px] border border-border rounded-xl overflow-hidden",children:[f(SK,{nodes:N,edges:w.edges,onNodesChange:k,onPaneClick:C,nodeTypes:EZ,nodesConnectable:!1,fitView:!0,fitViewOptions:{padding:.2,maxZoom:1.2},proOptions:{hideAttribution:!0},className:"bg-background",colorMode:t,children:[o(AK,{gap:20,size:1}),o(RK,{showInteractive:!1})]}),d&&o(b0,{addonId:d.addonId,agentId:d.agentId,showScope:!0,onClose:()=>u(null)})]})})}function _Z({onlineNodeIds:e}){const t=ke(),n=nt(),{data:r,isLoading:s}=Yr(),a=ay({onSuccess:()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","listAgentSettings"]]})}}),i=H(()=>{if(!r)return[];const c=new Set(e);return c.add("hub"),r.filter(d=>!c.has(d.nodeId))},[r,e]);if(s)return o("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?o("section",{className:"rounded-lg border border-border bg-surface p-6",children:f("div",{className:"flex flex-col items-center gap-2 text-center text-muted-foreground",children:[o(Ql,{className:"h-6 w-6 opacity-40"}),o("p",{className:"text-xs",children:"No stale agent entries."}),o("p",{className:"text-[11px] opacity-60",children:"Every persisted nodeId matches a node currently online in the cluster."})]})}):f("section",{className:"rounded-lg border border-border bg-surface",children:[f("header",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[o(Ql,{className:"h-4 w-4 text-muted-foreground"}),o("h2",{className:"text-sm font-semibold",children:"Offline agents"}),f("span",{className:"ml-auto text-[11px] text-muted-foreground",children:[i.length," stale ",i.length===1?"entry":"entries"]})]}),o("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."}),o("ul",{className:"divide-y divide-border",children:i.map(c=>{const d=Object.keys(c.settings.addonDefaults??{}).length,u=Object.values(c.settings.addonDefaults??{}).filter(p=>p?.enabled).length;return f("li",{className:"flex items-center gap-3 px-4 py-2 text-xs",children:[o("span",{className:"font-mono text-foreground",children:c.nodeId}),f("span",{className:"text-muted-foreground",children:[d," addons configured",d>0&&f(me,{children:[" · ",u," enabled"]})]}),f("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:[o(Ze,{className:"h-3 w-3"}),"Remove"]})]},c.nodeId)})})]})}function $Z(e){const[t,n]=_(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return Y(()=>{const r=window.matchMedia(e),s=a=>n(a.matches);return r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[e]),t}function DZ(){const{data:e,isLoading:t}=zn(void 0,{staleTime:1/0}),[n,r]=_(null);return gt("cluster.topology-snapshot",a=>{const i=a.data?.nodes;Array.isArray(i)&&r(i)}),{nodes:H(()=>n??e??[],[n,e]),isLoading:t&&!n}}function TZ(){const[e,t]=_("diagram"),n=$Z("(max-width: 767px)"),r=n&&e==="diagram"?"table":e,{nodes:s,isLoading:a}=DZ(),i=s.filter(h=>h.isOnline).length,l=s.filter(h=>!h.isOnline).length,c=H(()=>s.map(h=>h.id??"").filter(Boolean),[s]),{data:d}=Yr(),u=H(()=>{if(!d)return 0;const h=new Set(c);return h.add("hub"),d.filter(m=>!h.has(m.nodeId)).length},[d,c]),p=(h,m,g,b)=>f("button",{onClick:()=>t(h),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${e===h?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:[o(g,{className:"h-3.5 w-3.5"}),m,b!==void 0&&b>0&&o("span",{className:`ml-1 inline-flex h-4 min-w-[1rem] items-center justify-center rounded-full px-1 text-[10px] font-semibold ${e===h?"bg-primary-foreground/20 text-primary-foreground":"bg-destructive/15 text-destructive"}`,children:b})]});return f("div",{className:"flex flex-col h-full gap-4 p-4",children:[f("div",{className:"flex items-center justify-between",children:[f("div",{className:"flex items-center gap-2",children:[i>0&&f("span",{className:"text-xs px-2 py-0.5 rounded-full bg-success/10 text-success",children:[i," online"]}),l>0&&f("span",{className:"text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:[l," offline"]})]}),f("div",{className:"flex gap-0.5 p-1 rounded-lg bg-muted",children:[!n&&p("diagram","Diagram",$n),p("table","Table",BO),p("offline-agents","Offline agents",Ql,u)]})]}),a?o("div",{className:"flex items-center justify-center flex-1 text-muted-foreground",children:"Loading cluster topology..."}):r==="diagram"?o(PZ,{topology:s}):r==="table"?o("div",{className:"flex-1 overflow-auto",children:o(Vj,{nodes:s})}):o("div",{className:"flex-1 overflow-auto",children:o(_Z,{onlineNodeIds:c})})]})}function ln({title:e,children:t}){return f("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o("div",{className:"border-b border-border px-4 py-2.5",children:o("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:e})}),o("div",{className:"p-4",children:t})]})}function ot({name:e,cssVar:t,hex:n}){const r=t?`var(${t})`:n;return f("div",{className:"flex flex-col items-center gap-1.5",children:[o("div",{className:"h-10 w-10 rounded-lg border border-border shadow-inner",style:{backgroundColor:r}}),o("span",{className:"text-[10px] text-foreground-subtle text-center leading-tight",children:e})]})}const LZ={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 RZ(){const[e,t]=_({name:"Example",count:10,enabled:!0,mode:"a",tags:["camera"],confidence:60});return f("div",{className:"p-6 space-y-6 max-w-5xl mx-auto",children:[f("div",{className:"mb-6",children:[o("h1",{className:"text-xl font-bold text-foreground",children:"Component Showroom"}),o("p",{className:"text-sm text-foreground-subtle mt-1",children:"All UI components at a glance"})]}),o(ln,{title:"Typography",children:f("div",{className:"space-y-3",children:[o("h1",{className:"text-2xl font-bold text-foreground",children:"Heading 1 — Display title"}),o("h2",{className:"text-xl font-semibold text-foreground",children:"Heading 2 — Section title"}),o("h3",{className:"text-base font-semibold text-foreground",children:"Heading 3 — Card title"}),o("h4",{className:"text-sm font-semibold text-foreground",children:"Heading 4 — Sub-section"}),o("p",{className:"text-sm text-foreground",children:"Body text — Regular paragraph content goes here. It uses the foreground color."}),o("p",{className:"text-sm text-foreground-subtle",children:"Subtle text — Secondary/descriptive text with reduced emphasis."}),o("p",{className:"text-xs text-foreground-subtle uppercase tracking-wider font-semibold",children:"Label / Caption"}),o("p",{className:"text-xs text-foreground-disabled",children:"Disabled / placeholder text"})]})}),o(ln,{title:"Colors",children:f("div",{className:"flex flex-wrap gap-4",children:[o(ot,{name:"primary",cssVar:"--color-primary"}),o(ot,{name:"background",cssVar:"--color-background"}),o(ot,{name:"surface",cssVar:"--color-surface"}),o(ot,{name:"foreground",cssVar:"--color-foreground"}),o(ot,{name:"success",cssVar:"--color-success"}),o(ot,{name:"warning",cssVar:"--color-warning"}),o(ot,{name:"danger",cssVar:"--color-danger"}),o(ot,{name:"info",cssVar:"--color-info"}),o(ot,{name:"border",cssVar:"--color-border"}),o("div",{className:"w-px"}),o(ot,{name:"frigate",hex:"#3b82f6"}),o(ot,{name:"scrypted",hex:"#a855f7"}),o(ot,{name:"reolink",hex:"#06b6d4"}),o(ot,{name:"ha",hex:"#22d3ee"}),o(ot,{name:"rtsp",hex:"#78716c"})]})}),o(ln,{title:"Buttons",children:f("div",{className:"flex flex-wrap gap-3",children:[o("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"}),o("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"}),o("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"}),o("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"}),o("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"}),o("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"})]})}),o(ln,{title:"Inputs",children:f("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[f("div",{children:[o("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Text input"}),o("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..."})]}),f("div",{children:[o("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Number input"}),o("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"})]}),f("div",{children:[o("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Password input"}),o("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:"••••••••"})]}),f("div",{children:[o("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Select"}),f("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:[o("option",{children:"Option A"}),o("option",{children:"Option B"}),o("option",{children:"Option C"})]})]}),f("div",{className:"md:col-span-2",children:[o("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Textarea"}),o("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})]}),o("div",{children:f("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[o("input",{type:"checkbox",className:"h-3.5 w-3.5 rounded border-border accent-primary",defaultChecked:!0}),o("span",{className:"text-xs font-medium text-foreground",children:"Checkbox (checked)"})]})}),o("div",{children:f("div",{className:"flex items-center justify-between",children:[o("span",{className:"text-xs font-medium text-foreground",children:"Toggle switch"}),o(OZ,{})]})}),f("div",{children:[o("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Slider"}),o("input",{type:"range",className:"w-full h-1 accent-primary cursor-pointer",min:0,max:100,defaultValue:60})]}),f("div",{children:[o("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Tags example"}),o("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=>o("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))})]})]})}),o(ln,{title:"Badges",children:f("div",{className:"space-y-3",children:[f("div",{children:[o("p",{className:"text-xs text-foreground-subtle mb-2",children:"StatusBadge"}),o("div",{className:"flex flex-wrap gap-2",children:["running","stopped","error","online","offline","idle"].map(n=>o(ti,{status:n},n))})]}),f("div",{children:[o("p",{className:"text-xs text-foreground-subtle mb-2",children:"CapabilityBadges"}),o(Ja,{capabilities:["streaming","detection","recording","audio"]})]})]})}),o(ln,{title:"Cards",children:f("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[f("div",{className:"rounded-lg bg-surface p-4",children:[o("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Surface card"}),o("p",{className:"text-xs text-foreground-subtle",children:"Uses `bg-surface`. Default card background."})]}),f("div",{className:"rounded-lg border border-border bg-surface p-4",children:[o("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Bordered card"}),o("p",{className:"text-xs text-foreground-subtle",children:"Uses `border border-border bg-surface`."})]}),f("div",{className:"rounded-lg border border-primary/30 bg-primary/5 p-4",children:[o("h3",{className:"text-sm font-semibold text-primary mb-1",children:"Accent card"}),o("p",{className:"text-xs text-foreground-subtle",children:"Highlighted with primary color."})]}),f("div",{className:"rounded-lg bg-background p-4",children:[o("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Background card"}),o("p",{className:"text-xs text-foreground-subtle",children:"Uses `bg-background`. Inset card."})]})]})}),o(ln,{title:"Provider Icons",children:o("div",{className:"flex flex-wrap gap-4",children:["frigate","scrypted","reolink","homeassistant","rtsp","onvif"].map(n=>o(gn,{type:n,size:"lg",showLabel:!0},n))})}),f(ln,{title:"Form Builder Demo",children:[o(Dn,{schema:LZ,values:e,onChange:t}),f("details",{className:"mt-3",children:[o("summary",{className:"text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground",children:"View current values"}),o("pre",{className:"mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto",children:JSON.stringify(e,null,2)})]})]}),o(ln,{title:"Info Boxes",children:o("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:r,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 f("div",{className:`rounded-md border-l-4 px-3 py-2.5 ${i.border} ${i.bg}`,children:[o("p",{className:`text-xs font-semibold mb-0.5 ${i.text}`,children:r}),o("p",{className:"text-xs text-foreground-subtle leading-relaxed",children:s})]},n)})})})]})}function OZ(){const[e,t]=_(!0);return o("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:o("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 Xh={info:{bg:"bg-blue-500/10",border:"border-blue-500/30",icon:rr},warning:{bg:"bg-orange-500/10",border:"border-orange-500/30",icon:it},critical:{bg:"bg-red-500/10",border:"border-red-500/30",icon:nr}};function BZ({toast:e,onDismiss:t}){const n=Xh[e.severity]??Xh.info,r=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]),f("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:[o(r,{className:"h-4 w-4 shrink-0 mt-0.5 text-foreground-subtle"}),f("div",{className:"flex-1 min-w-0",children:[o("div",{className:"text-xs font-semibold text-foreground",children:e.title}),o("div",{className:"text-[11px] text-foreground-subtle mt-0.5",children:e.message})]}),o("button",{type:"button",onClick:()=>t(e.id),className:"shrink-0 p-0.5 rounded hover:bg-surface-hover transition-colors",children:o(Fe,{className:"h-3.5 w-3.5 text-foreground-subtle"})})]})}function zZ(){const[e,t]=_([]),n=U(r=>{t(s=>s.filter(a=>a.id!==r))},[]);return Ay(void 0,{onData:r=>{const s=r,a=`toast-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;t(i=>[...i,{...s,id:a,timestamp:Date.now()}])}}),e.length===0?null:o("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(r=>o("div",{className:"pointer-events-auto",children:o(BZ,{toast:r,onDismiss:n})},r.id))})}const kc=new sm({defaultOptions:{queries:{staleTime:3e4,retry:!1,refetchOnWindowFocus:!1}}});function FZ({field:e,value:t,onChange:n,disabled:r}){return o(l8,{field:e,value:t,onChange:n,disabled:r})}function jZ({field:e,value:t,onChange:n,disabled:r}){return o(x8,{field:e,value:t,onChange:n,disabled:r})}const VZ={"zone-editor":n8,"live-stats":o8,"pipeline-editor":FZ,"model-selector":jZ,"live-stream-viewer":v8,"pipeline-stats":w8,"stream-network-stats":N8,"doorbell-recent":S8,"device-info":cv};function HZ({children:e}){const{user:t}=nn(),[n,r]=_(0),s=te(t?.username??null);Y(()=>{const p=t?.username??null;p!==s.current&&(s.current=p,Sr(),r(h=>h+1))},[t]);const a=H(()=>qs(),[n]),[i,l]=_(!1),[c,d]=_(null);Y(()=>{if(l(!1),d(null),!t){l(!0);return}let p=!1;return a.init().then(()=>{p||l(!0)},h=>{if(p)return;const m=h instanceof Error?h.message:String(h);d(m),l(!0)}),()=>{p=!0}},[a,t]);const u=U(()=>{Sr(),r(p=>p+1),kc.invalidateQueries()},[]);return sR(u),o(Gc,{system:a,children:o(S.Provider,{client:a.trpcClient,queryClient:kc,children:f(Vy,{children:[i?e:o(qZ,{}),i&&o(XO,{}),c!==null&&i&&f("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 qZ(){return o("div",{className:"flex min-h-screen items-center justify-center bg-background",children:f("div",{className:"flex items-center gap-3 text-sm text-foreground-subtle",children:[o("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary"}),"Connecting…"]})})}function UZ(){return o(Zs,{defaultMode:"dark",children:o(am,{client:kc,children:o(j8,{children:o(HZ,{children:o(jg,{children:f(ib,{renderers:VZ,children:[o(KL,{children:f(kL,{children:[o(Le,{path:"/login",element:o(q9,{})}),o(Le,{path:"/change-password",element:o(Dt,{children:o(Q9,{})})}),o(Le,{path:"/showroom",element:o(RZ,{})}),f(Le,{element:o(Dt,{children:o(H9,{})}),children:[o(Le,{index:!0,element:o(Nt,{to:"/dashboard",replace:!0})}),o(Le,{path:"/access-denied",element:o(G9,{})}),o(Le,{path:"/dashboard",element:o(o7,{})}),o(Le,{path:"/devices",element:o(s7,{})}),o(Le,{path:"/cameras",element:o(Nt,{to:"/devices",replace:!0})}),o(Le,{path:"/integrations",element:o(g7,{})}),o(Le,{path:"/integrations/:integrationId",element:o(y7,{})}),o(Le,{path:"/timeline",element:o(A7,{})}),o(Le,{path:"/pipeline",element:o(dB,{})}),o(Le,{path:"/devices/:deviceId",element:o(cz,{})}),o(Le,{path:"/system/logs",element:o(Dt,{requireAdmin:!0,children:o(Pz,{})})}),o(Le,{path:"/system/addons",element:o(Dt,{requireAdmin:!0,children:o(Sz,{})})}),o(Le,{path:"/system/settings",element:o(Dt,{requireAdmin:!0,children:o(Mj,{})})}),o(Le,{path:"/system/cluster",element:o(Dt,{requireAdmin:!0,children:o(TZ,{})})}),o(Le,{path:"/system/identity",element:o(Dt,{requireAdmin:!0,children:o(Jz,{})})}),o(Le,{path:"/system/my-access",element:o(Ez,{})}),o(Le,{path:"/system/network",element:o(Dt,{requireAdmin:!0,children:o(EF,{})})}),o(Le,{path:"/system/integrations",element:o(Dt,{requireAdmin:!0,children:o(BF,{})})}),o(Le,{path:"/system/data",element:o(Dt,{requireAdmin:!0,children:o(Cj,{})})}),o(Le,{path:"/system/users",element:o(Nt,{to:"/system/identity?tab=users",replace:!0})}),o(Le,{path:"/system/api-keys",element:o(Nt,{to:"/system/identity?tab=api-keys",replace:!0})}),o(Le,{path:"/system/authentication",element:o(Nt,{to:"/system/identity?tab=authentication",replace:!0})}),o(Le,{path:"/system/remote-access",element:o(Nt,{to:"/system/network?tab=remote-access",replace:!0})}),o(Le,{path:"/system/turn",element:o(Nt,{to:"/system/network?tab=turn",replace:!0})}),o(Le,{path:"/system/storage",element:o(Nt,{to:"/system/data?tab=storage",replace:!0})}),o(Le,{path:"/system/backup",element:o(Nt,{to:"/system/data?tab=backup",replace:!0})}),o(Le,{path:"/addon/:pagePath",element:o(Dt,{requireAdmin:!0,children:o(F9,{})})})]})]})}),o(zZ,{})]})})})})})})}const QZ={dashboard:"Dashboard",integrations:"Integrations",metrics:"Metrics"},GZ={title:"System",addons:"Addons",agents:"Agents",processes:"Processes",logs:"Logs",users:"Users",settings:"Settings",repl:"REPL",models:"Models",integrations:"Integrations"},KZ={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"},WZ={disconnected:"Server unreachable — reconnecting…",connected:"Connected"},YZ={online:"Online",offline:"Offline",connecting:"Connecting",error:"Error",disabled:"Disabled",enabled:"Enabled",active:"Active",inactive:"Inactive",running:"Running",stopped:"Stopped",pending:"Pending",unknown:"Unknown"},ZZ={login:"Login",logout:"Logout",username:"Username",password:"Password",signIn:"Sign In",invalidCredentials:"Invalid username or password"},XZ={dark:"Dark",light:"Light",system:"System"},JZ={select:"Language",en:"English",it:"Italian"},eX={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"}},tX={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"},nX={nav:QZ,system:GZ,common:KZ,connection:WZ,status:YZ,auth:ZZ,theme:XZ,language:JZ,pages:eX,integrations:tX},rX={dashboard:"Dashboard",integrations:"Integrazioni",metrics:"Metriche"},oX={title:"Sistema",addons:"Addon",agents:"Agenti",processes:"Processi",logs:"Log",users:"Utenti",settings:"Impostazioni",repl:"REPL",models:"Modelli",integrations:"Integrazioni"},sX={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"},aX={disconnected:"Server non raggiungibile — riconnessione in corso…",connected:"Connesso"},iX={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"},lX={login:"Accesso",logout:"Esci",username:"Nome utente",password:"Password",signIn:"Accedi",invalidCredentials:"Nome utente o password non validi"},cX={dark:"Scuro",light:"Chiaro",system:"Sistema"},dX={select:"Lingua",en:"Inglese",it:"Italiano"},uX={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"}},pX={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"},fX={nav:rX,system:oX,common:sX,connection:aX,status:iX,auth:lX,theme:cX,language:dX,pages:uX,integrations:pX},iN="camstack_language",hX=localStorage.getItem(iN)??"en";et.use(w9).init({resources:{en:{translation:nX},it:{translation:fX}},lng:hX,fallbackLng:"en",interpolation:{escapeValue:!1}});et.on("languageChanged",e=>{localStorage.setItem(iN,e)});window.__camstackUiLibrary=NT;window.__camstackSdk=C2;window.__camstackTypes=M2;rm(document.getElementById("root")).render(o(u2,{children:o(UZ,{})}));
|