@camstack/addon-admin-ui 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-EvvqBXwc.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-VlbukyAL.js} +1 -1
- package/dist/assets/{auth-records-BITWn7el.js → auth-records-DLqosdE2.js} +1 -1
- package/dist/assets/{capability-router-map-CaOEdRrL.js → capability-router-map-UNVkwZU9.js} +1 -1
- package/dist/assets/{devices-CHs8FtcP.js → devices-BUM64diU.js} +1 -1
- package/dist/assets/{hostInit-DvbtbwZk.js → hostInit-CNn7IXEh.js} +1 -1
- package/dist/assets/index-97OSqF1Q.js +1098 -0
- package/dist/assets/{index-DP47gBw3.js → index-B95gHp6V.js} +1 -1
- package/dist/assets/{index-kTWUqL5t.js → index-CvVlJEP5.js} +1 -1
- package/dist/assets/index-DVf1U7c4.js +1 -0
- package/dist/assets/{index-SQG_en0B.js → index-De6hr8eY.js} +1 -1
- package/dist/assets/{index-CQSGgFP_.js → index-Dq_5fsAQ.js} +1 -1
- package/dist/assets/{index-CXdbb2jB.js → index-DvrBfik_.js} +1 -1
- package/dist/assets/{index-Bgm2_LRj.js → index-F3MAsf-9.js} +1 -1
- package/dist/assets/{index-CmKCfHjL.js → index-agmLjvC2.js} +1 -1
- package/dist/assets/{index-4W5J6Mqf.js → index-bZcruxoE.js} +1 -1
- package/dist/assets/{remoteEntry-Cj_-4_C2.js → remoteEntry-Bdr9eSPp.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BZcqvZPM.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CexafoGf.js} +2 -2
- package/dist/index.html +5 -5
- package/dist/mf-entry-bootstrap-0.js +2 -2
- package/dist/sw.js +1 -1
- package/package.json +1 -1
- package/dist/assets/index--T2hMjuJ.js +0 -1098
- package/dist/assets/index-BARkrGFD.js +0 -1
|
@@ -0,0 +1,1098 @@
|
|
|
1
|
+
import"./virtualExposes-_ivNhQLP.js";import{d as pr}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CexafoGf.js";import{c as r,a as Ef,d as u,e as xe,g as Q1}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-C_6K4VBY.js";import{b as Oe,e as _,h as q,c as Z,f as U,d as ve,a as $f,j as He,k as Me,i as ne,l as fr,m as Gs,g as Ws,R as El,n as $l,o as U1,p as K1,q as mr,r as Fe,s as G1,t as W1,u as Y1,v as Z1}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-Dl4u0xYE.js";import{a as _f,b as vo}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-CzO_Esxm.js";import{a as Df,b as Lf}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-DNpf5SLz.js";import{_ as Tf,m as Un,n as ke,o as Rf,p as Of,h as _l,j as X1}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-CeLhKMin.js";import{_ as zf,c as Bf,s as Ff,n as J1,B as ew,F as tw}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.mjs-DIkg6-MH.js";import{_ as jf,a as nw}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-OcRSBqRe.js";import{c as rw,D as Tn,a as st,M as ow,W as Di,S as us}from"./auth-records-DLqosdE2.js";import{S as Li,c as Hf}from"./devices-BUM64diU.js";import{E as Ne,A as sw,C as aw}from"./capability-router-map-UNVkwZU9.js";import{s as iw}from"./index-F3MAsf-9.js";import{a as Pd,S as Ed,s as lw}from"./index-De6hr8eY.js";import{r as Vf}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-CSyOECfO.js";import"./preload-helper-BlTxHScW.js";import"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-xw6c6JeS.js";import"./schemas-XgIEoUz3.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function o(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();const qf={frigate:"#3b82f6",scrypted:"#a855f7",reolink:"#06b6d4",homeAssistant:"#22d3ee",rtsp:"#78716c"},Qf={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:qf},Uf={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:qf},Ti={colors:{dark:Qf,light:Uf},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 Kf(e,t){const n={...e};for(const o in t){const s=t[o],a=e[o];s!==void 0&&typeof s=="object"&&s!==null&&!Array.isArray(s)&&typeof a=="object"&&a!==null?n[o]=Kf(a,s):s!==void 0&&(n[o]=s)}return n}function cw(e){return e?Kf(structuredClone(Ti),e):structuredClone(Ti)}function Gf(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function dw(e){return`--color-${Gf(e)}`}function $d(e){const t=[];for(const[n,o]of Object.entries(e))n!=="provider"&&t.push(` ${dw(n)}: ${o};`);return t.join(`
|
|
2
|
+
`)}function uw(e){const t=[];for(const[n,o]of Object.entries(e))t.push(` --color-provider-${Gf(n)}: ${o};`);return t.join(`
|
|
3
|
+
`)}function pw(e){const t=[];for(const[n,o]of Object.entries(e))t.push(` --spacing-${n}: ${o}px;`);return t.join(`
|
|
4
|
+
`)}function fw(e){const t=[];for(const[n,o]of Object.entries(e))t.push(` --radius-${n}: ${o}px;`);return t.join(`
|
|
5
|
+
`)}function mw(e){const t=$d(e.colors.dark),n=$d(e.colors.light),o=uw(e.colors.dark.provider),s=pw(e.spacing),a=fw(e.radius);return`@theme {
|
|
6
|
+
${o}
|
|
7
|
+
${s}
|
|
8
|
+
${a}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.dark {
|
|
12
|
+
${t}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.light {
|
|
16
|
+
${n}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@media (prefers-color-scheme: dark) {
|
|
20
|
+
:root {
|
|
21
|
+
${t.replace(/^ {2}/gm," ")}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@media (prefers-color-scheme: light) {
|
|
26
|
+
:root {
|
|
27
|
+
${n.replace(/^ {2}/gm," ")}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`}const Wf=Oe(null),Fa=["dark","light","system"];function Yf(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function hw(e,t){if(typeof window>"u")return t;const n=localStorage.getItem(e);return n==="dark"||n==="light"||n==="system"?n:t}function _d(e){return e==="system"?Yf():e}function ws({children:e,defaultMode:t="system",storageKey:n="camstack-theme-mode"}){const[o,s]=_(()=>hw(n,t)),[a,i]=_(()=>_d(o)),l=q(f=>{s(f),i(_d(f)),typeof window<"u"&&localStorage.setItem(n,f)},[n]),c=q(()=>{const p=(Fa.indexOf(o)+1)%Fa.length;l(Fa[p]??"dark")},[o,l]);Z(()=>{if(typeof document>"u")return;const f=document.documentElement;f.classList.remove("dark","light"),f.classList.add(a)},[o,a]),Z(()=>{if(typeof window>"u"||o!=="system")return;const f=window.matchMedia("(prefers-color-scheme: dark)"),p=()=>{i(Yf())};return f.addEventListener("change",p),()=>f.removeEventListener("change",p)},[o]);const d=U(()=>({mode:o,resolvedMode:a,setMode:l,toggleMode:c}),[o,a,l,c]);return r(Wf.Provider,{value:d,children:e})}function Mr(){const e=ve(Wf);if(!e)throw new Error("useThemeMode must be used within a ThemeProvider");return e}function Zf(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=Zf(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Xf(){for(var e,t,n=0,o="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=Zf(e))&&(o&&(o+=" "),o+=t);return o}const gw=(e,t)=>{const n=new Array(e.length+t.length);for(let o=0;o<e.length;o++)n[o]=e[o];for(let o=0;o<t.length;o++)n[e.length+o]=t[o];return n},bw=(e,t)=>({classGroupId:e,validator:t}),Jf=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Ns="-",Dd=[],xw="arbitrary..",yw=e=>{const t=ww(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return vw(i);const l=i.split(Ns),c=l[0]===""&&l.length>1?1:0;return em(l,c,t)},getConflictingClassGroupIds:(i,l)=>{if(l){const c=o[i],d=n[i];return c?d?gw(d,c):c:d||Dd}return n[i]||Dd}}},em=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const s=e[t],a=n.nextPart.get(s);if(a){const d=em(e,t+1,a);if(d)return d}const i=n.validators;if(i===null)return;const l=t===0?e.join(Ns):e.slice(t).join(Ns),c=i.length;for(let d=0;d<c;d++){const f=i[d];if(f.validator(l))return f.classGroupId}},vw=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),o=t.slice(0,n);return o?xw+o:void 0})(),ww=e=>{const{theme:t,classGroups:n}=e;return Nw(n,t)},Nw=(e,t)=>{const n=Jf();for(const o in e){const s=e[o];Dl(s,n,o,t)}return n},Dl=(e,t,n,o)=>{const s=e.length;for(let a=0;a<s;a++){const i=e[a];kw(i,t,n,o)}},kw=(e,t,n,o)=>{if(typeof e=="string"){Sw(e,t,n);return}if(typeof e=="function"){Cw(e,t,n,o);return}Mw(e,t,n,o)},Sw=(e,t,n)=>{const o=e===""?t:tm(t,e);o.classGroupId=n},Cw=(e,t,n,o)=>{if(Iw(e)){Dl(e(o),t,n,o);return}t.validators===null&&(t.validators=[]),t.validators.push(bw(n,e))},Mw=(e,t,n,o)=>{const s=Object.entries(e),a=s.length;for(let i=0;i<a;i++){const[l,c]=s[i];Dl(c,tm(t,l),n,o)}},tm=(e,t)=>{let n=e;const o=t.split(Ns),s=o.length;for(let a=0;a<s;a++){const i=o[a];let l=n.nextPart.get(i);l||(l=Jf(),n.nextPart.set(i,l)),n=l}return n},Iw=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Aw=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),o=Object.create(null);const s=(a,i)=>{n[a]=i,t++,t>e&&(t=0,o=n,n=Object.create(null))};return{get(a){let i=n[a];if(i!==void 0)return i;if((i=o[a])!==void 0)return s(a,i),i},set(a,i){a in n?n[a]=i:s(a,i)}}},Ri="!",Ld=":",Pw=[],Td=(e,t,n,o,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:o,isExternal:s}),Ew=e=>{const{prefix:t,experimentalParseClassName:n}=e;let o=s=>{const a=[];let i=0,l=0,c=0,d;const f=s.length;for(let b=0;b<f;b++){const x=s[b];if(i===0&&l===0){if(x===Ld){a.push(s.slice(c,b)),c=b+1;continue}if(x==="/"){d=b;continue}}x==="["?i++:x==="]"?i--:x==="("?l++:x===")"&&l--}const p=a.length===0?s:s.slice(c);let m=p,h=!1;p.endsWith(Ri)?(m=p.slice(0,-1),h=!0):p.startsWith(Ri)&&(m=p.slice(1),h=!0);const g=d&&d>c?d-c:void 0;return Td(a,h,m,g)};if(t){const s=t+Ld,a=o;o=i=>i.startsWith(s)?a(i.slice(s.length)):Td(Pw,!1,i,void 0,!0)}if(n){const s=o;o=a=>n({className:a,parseClassName:s})}return o},$w=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,o)=>{t.set(n,1e6+o)}),n=>{const o=[];let s=[];for(let a=0;a<n.length;a++){const i=n[a],l=i[0]==="[",c=t.has(i);l||c?(s.length>0&&(s.sort(),o.push(...s),s=[]),o.push(i)):s.push(i)}return s.length>0&&(s.sort(),o.push(...s)),o}},_w=e=>({cache:Aw(e.cacheSize),parseClassName:Ew(e),sortModifiers:$w(e),...yw(e)}),Dw=/\s+/,Lw=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:s,sortModifiers:a}=t,i=[],l=e.trim().split(Dw);let c="";for(let d=l.length-1;d>=0;d-=1){const f=l[d],{isExternal:p,modifiers:m,hasImportantModifier:h,baseClassName:g,maybePostfixModifierPosition:b}=n(f);if(p){c=f+(c.length>0?" "+c:c);continue}let x=!!b,v=o(x?g.substring(0,b):g);if(!v){if(!x){c=f+(c.length>0?" "+c:c);continue}if(v=o(g),!v){c=f+(c.length>0?" "+c:c);continue}x=!1}const w=m.length===0?"":m.length===1?m[0]:a(m).join(":"),y=h?w+Ri:w,N=y+v;if(i.indexOf(N)>-1)continue;i.push(N);const k=s(v,x);for(let S=0;S<k.length;++S){const M=k[S];i.push(y+M)}c=f+(c.length>0?" "+c:c)}return c},Tw=(...e)=>{let t=0,n,o,s="";for(;t<e.length;)(n=e[t++])&&(o=nm(n))&&(s&&(s+=" "),s+=o);return s},nm=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=nm(e[o]))&&(n&&(n+=" "),n+=t);return n},Rw=(e,...t)=>{let n,o,s,a;const i=c=>{const d=t.reduce((f,p)=>p(f),e());return n=_w(d),o=n.cache.get,s=n.cache.set,a=l,l(c)},l=c=>{const d=o(c);if(d)return d;const f=Lw(c,n);return s(c,f),f};return a=i,(...c)=>a(Tw(...c))},Ow=[],Ke=e=>{const t=n=>n[e]||Ow;return t.isThemeGetter=!0,t},rm=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,om=/^\((?:(\w[\w-]*):)?(.+)\)$/i,zw=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Bw=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Fw=/\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$/,jw=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Hw=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Vw=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,fn=e=>zw.test(e),Ae=e=>!!e&&!Number.isNaN(Number(e)),mn=e=>!!e&&Number.isInteger(Number(e)),ja=e=>e.endsWith("%")&&Ae(e.slice(0,-1)),Gt=e=>Bw.test(e),sm=()=>!0,qw=e=>Fw.test(e)&&!jw.test(e),Ll=()=>!1,Qw=e=>Hw.test(e),Uw=e=>Vw.test(e),Kw=e=>!be(e)&&!ye(e),Gw=e=>kn(e,lm,Ll),be=e=>rm.test(e),Pn=e=>kn(e,cm,qw),Rd=e=>kn(e,nN,Ae),Ww=e=>kn(e,um,sm),Yw=e=>kn(e,dm,Ll),Od=e=>kn(e,am,Ll),Zw=e=>kn(e,im,Uw),Ro=e=>kn(e,pm,Qw),ye=e=>om.test(e),Or=e=>Kn(e,cm),Xw=e=>Kn(e,dm),zd=e=>Kn(e,am),Jw=e=>Kn(e,lm),eN=e=>Kn(e,im),Oo=e=>Kn(e,pm,!0),tN=e=>Kn(e,um,!0),kn=(e,t,n)=>{const o=rm.exec(e);return o?o[1]?t(o[1]):n(o[2]):!1},Kn=(e,t,n=!1)=>{const o=om.exec(e);return o?o[1]?t(o[1]):n:!1},am=e=>e==="position"||e==="percentage",im=e=>e==="image"||e==="url",lm=e=>e==="length"||e==="size"||e==="bg-size",cm=e=>e==="length",nN=e=>e==="number",dm=e=>e==="family-name",um=e=>e==="number"||e==="weight",pm=e=>e==="shadow",rN=()=>{const e=Ke("color"),t=Ke("font"),n=Ke("text"),o=Ke("font-weight"),s=Ke("tracking"),a=Ke("leading"),i=Ke("breakpoint"),l=Ke("container"),c=Ke("spacing"),d=Ke("radius"),f=Ke("shadow"),p=Ke("inset-shadow"),m=Ke("text-shadow"),h=Ke("drop-shadow"),g=Ke("blur"),b=Ke("perspective"),x=Ke("aspect"),v=Ke("ease"),w=Ke("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],k=()=>[...N(),ye,be],S=()=>["auto","hidden","clip","visible","scroll"],M=()=>["auto","contain","none"],P=()=>[ye,be,c],I=()=>[fn,"full","auto",...P()],z=()=>[mn,"none","subgrid",ye,be],$=()=>["auto",{span:["full",mn,ye,be]},mn,ye,be],O=()=>[mn,"auto",ye,be],R=()=>["auto","min","max","fr",ye,be],A=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],L=()=>["start","end","center","stretch","center-safe","end-safe"],D=()=>["auto",...P()],T=()=>[fn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...P()],B=()=>[fn,"screen","full","dvw","lvw","svw","min","max","fit",...P()],F=()=>[fn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...P()],j=()=>[e,ye,be],H=()=>[...N(),zd,Od,{position:[ye,be]}],E=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Q=()=>["auto","cover","contain",Jw,Gw,{size:[ye,be]}],K=()=>[ja,Or,Pn],Y=()=>["","none","full",d,ye,be],re=()=>["",Ae,Or,Pn],te=()=>["solid","dashed","dotted","double"],X=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],oe=()=>[Ae,ja,zd,Od],ge=()=>["","none",g,ye,be],J=()=>["none",Ae,ye,be],G=()=>["none",Ae,ye,be],ee=()=>[Ae,ye,be],ae=()=>[fn,"full",...P()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Gt],breakpoint:[Gt],color:[sm],container:[Gt],"drop-shadow":[Gt],ease:["in","out","in-out"],font:[Kw],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Gt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Gt],shadow:[Gt],spacing:["px",Ae],text:[Gt],"text-shadow":[Gt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",fn,be,ye,x]}],container:["container"],columns:[{columns:[Ae,be,ye,l]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:k()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{"inset-s":I(),start:I()}],end:[{"inset-e":I(),end:I()}],"inset-bs":[{"inset-bs":I()}],"inset-be":[{"inset-be":I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[mn,"auto",ye,be]}],basis:[{basis:[fn,"full","auto",l,...P()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ae,fn,"auto","initial","none",be]}],grow:[{grow:["",Ae,ye,be]}],shrink:[{shrink:["",Ae,ye,be]}],order:[{order:[mn,"first","last","none",ye,be]}],"grid-cols":[{"grid-cols":z()}],"col-start-end":[{col:$()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":z()}],"row-start-end":[{row:$()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":R()}],"auto-rows":[{"auto-rows":R()}],gap:[{gap:P()}],"gap-x":[{"gap-x":P()}],"gap-y":[{"gap-y":P()}],"justify-content":[{justify:[...A(),"normal"]}],"justify-items":[{"justify-items":[...L(),"normal"]}],"justify-self":[{"justify-self":["auto",...L()]}],"align-content":[{content:["normal",...A()]}],"align-items":[{items:[...L(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...L(),{baseline:["","last"]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...L(),"baseline"]}],"place-self":[{"place-self":["auto",...L()]}],p:[{p:P()}],px:[{px:P()}],py:[{py:P()}],ps:[{ps:P()}],pe:[{pe:P()}],pbs:[{pbs:P()}],pbe:[{pbe:P()}],pt:[{pt:P()}],pr:[{pr:P()}],pb:[{pb:P()}],pl:[{pl:P()}],m:[{m:D()}],mx:[{mx:D()}],my:[{my:D()}],ms:[{ms:D()}],me:[{me:D()}],mbs:[{mbs:D()}],mbe:[{mbe:D()}],mt:[{mt:D()}],mr:[{mr:D()}],mb:[{mb:D()}],ml:[{ml:D()}],"space-x":[{"space-x":P()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":P()}],"space-y-reverse":["space-y-reverse"],size:[{size:T()}],"inline-size":[{inline:["auto",...B()]}],"min-inline-size":[{"min-inline":["auto",...B()]}],"max-inline-size":[{"max-inline":["none",...B()]}],"block-size":[{block:["auto",...F()]}],"min-block-size":[{"min-block":["auto",...F()]}],"max-block-size":[{"max-block":["none",...F()]}],w:[{w:[l,"screen",...T()]}],"min-w":[{"min-w":[l,"screen","none",...T()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...T()]}],h:[{h:["screen","lh",...T()]}],"min-h":[{"min-h":["screen","lh","none",...T()]}],"max-h":[{"max-h":["screen","lh",...T()]}],"font-size":[{text:["base",n,Or,Pn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,tN,Ww]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ja,be]}],"font-family":[{font:[Xw,Yw,t]}],"font-features":[{"font-features":[be]}],"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,be]}],"line-clamp":[{"line-clamp":[Ae,"none",ye,Rd]}],leading:[{leading:[a,...P()]}],"list-image":[{"list-image":["none",ye,be]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ye,be]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:j()}],"text-color":[{text:j()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...te(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ae,"from-font","auto",ye,Pn]}],"text-decoration-color":[{decoration:j()}],"underline-offset":[{"underline-offset":[Ae,"auto",ye,be]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ye,be]}],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,be]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:E()}],"bg-size":[{bg:Q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},mn,ye,be],radial:["",ye,be],conic:[mn,ye,be]},eN,Zw]}],"bg-color":[{bg:j()}],"gradient-from-pos":[{from:K()}],"gradient-via-pos":[{via:K()}],"gradient-to-pos":[{to:K()}],"gradient-from":[{from:j()}],"gradient-via":[{via:j()}],"gradient-to":[{to:j()}],rounded:[{rounded:Y()}],"rounded-s":[{"rounded-s":Y()}],"rounded-e":[{"rounded-e":Y()}],"rounded-t":[{"rounded-t":Y()}],"rounded-r":[{"rounded-r":Y()}],"rounded-b":[{"rounded-b":Y()}],"rounded-l":[{"rounded-l":Y()}],"rounded-ss":[{"rounded-ss":Y()}],"rounded-se":[{"rounded-se":Y()}],"rounded-ee":[{"rounded-ee":Y()}],"rounded-es":[{"rounded-es":Y()}],"rounded-tl":[{"rounded-tl":Y()}],"rounded-tr":[{"rounded-tr":Y()}],"rounded-br":[{"rounded-br":Y()}],"rounded-bl":[{"rounded-bl":Y()}],"border-w":[{border:re()}],"border-w-x":[{"border-x":re()}],"border-w-y":[{"border-y":re()}],"border-w-s":[{"border-s":re()}],"border-w-e":[{"border-e":re()}],"border-w-bs":[{"border-bs":re()}],"border-w-be":[{"border-be":re()}],"border-w-t":[{"border-t":re()}],"border-w-r":[{"border-r":re()}],"border-w-b":[{"border-b":re()}],"border-w-l":[{"border-l":re()}],"divide-x":[{"divide-x":re()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":re()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...te(),"hidden","none"]}],"divide-style":[{divide:[...te(),"hidden","none"]}],"border-color":[{border:j()}],"border-color-x":[{"border-x":j()}],"border-color-y":[{"border-y":j()}],"border-color-s":[{"border-s":j()}],"border-color-e":[{"border-e":j()}],"border-color-bs":[{"border-bs":j()}],"border-color-be":[{"border-be":j()}],"border-color-t":[{"border-t":j()}],"border-color-r":[{"border-r":j()}],"border-color-b":[{"border-b":j()}],"border-color-l":[{"border-l":j()}],"divide-color":[{divide:j()}],"outline-style":[{outline:[...te(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ae,ye,be]}],"outline-w":[{outline:["",Ae,Or,Pn]}],"outline-color":[{outline:j()}],shadow:[{shadow:["","none",f,Oo,Ro]}],"shadow-color":[{shadow:j()}],"inset-shadow":[{"inset-shadow":["none",p,Oo,Ro]}],"inset-shadow-color":[{"inset-shadow":j()}],"ring-w":[{ring:re()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:j()}],"ring-offset-w":[{"ring-offset":[Ae,Pn]}],"ring-offset-color":[{"ring-offset":j()}],"inset-ring-w":[{"inset-ring":re()}],"inset-ring-color":[{"inset-ring":j()}],"text-shadow":[{"text-shadow":["none",m,Oo,Ro]}],"text-shadow-color":[{"text-shadow":j()}],opacity:[{opacity:[Ae,ye,be]}],"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":[Ae]}],"mask-image-linear-from-pos":[{"mask-linear-from":oe()}],"mask-image-linear-to-pos":[{"mask-linear-to":oe()}],"mask-image-linear-from-color":[{"mask-linear-from":j()}],"mask-image-linear-to-color":[{"mask-linear-to":j()}],"mask-image-t-from-pos":[{"mask-t-from":oe()}],"mask-image-t-to-pos":[{"mask-t-to":oe()}],"mask-image-t-from-color":[{"mask-t-from":j()}],"mask-image-t-to-color":[{"mask-t-to":j()}],"mask-image-r-from-pos":[{"mask-r-from":oe()}],"mask-image-r-to-pos":[{"mask-r-to":oe()}],"mask-image-r-from-color":[{"mask-r-from":j()}],"mask-image-r-to-color":[{"mask-r-to":j()}],"mask-image-b-from-pos":[{"mask-b-from":oe()}],"mask-image-b-to-pos":[{"mask-b-to":oe()}],"mask-image-b-from-color":[{"mask-b-from":j()}],"mask-image-b-to-color":[{"mask-b-to":j()}],"mask-image-l-from-pos":[{"mask-l-from":oe()}],"mask-image-l-to-pos":[{"mask-l-to":oe()}],"mask-image-l-from-color":[{"mask-l-from":j()}],"mask-image-l-to-color":[{"mask-l-to":j()}],"mask-image-x-from-pos":[{"mask-x-from":oe()}],"mask-image-x-to-pos":[{"mask-x-to":oe()}],"mask-image-x-from-color":[{"mask-x-from":j()}],"mask-image-x-to-color":[{"mask-x-to":j()}],"mask-image-y-from-pos":[{"mask-y-from":oe()}],"mask-image-y-to-pos":[{"mask-y-to":oe()}],"mask-image-y-from-color":[{"mask-y-from":j()}],"mask-image-y-to-color":[{"mask-y-to":j()}],"mask-image-radial":[{"mask-radial":[ye,be]}],"mask-image-radial-from-pos":[{"mask-radial-from":oe()}],"mask-image-radial-to-pos":[{"mask-radial-to":oe()}],"mask-image-radial-from-color":[{"mask-radial-from":j()}],"mask-image-radial-to-color":[{"mask-radial-to":j()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":N()}],"mask-image-conic-pos":[{"mask-conic":[Ae]}],"mask-image-conic-from-pos":[{"mask-conic-from":oe()}],"mask-image-conic-to-pos":[{"mask-conic-to":oe()}],"mask-image-conic-from-color":[{"mask-conic-from":j()}],"mask-image-conic-to-color":[{"mask-conic-to":j()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:E()}],"mask-size":[{mask:Q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ye,be]}],filter:[{filter:["","none",ye,be]}],blur:[{blur:ge()}],brightness:[{brightness:[Ae,ye,be]}],contrast:[{contrast:[Ae,ye,be]}],"drop-shadow":[{"drop-shadow":["","none",h,Oo,Ro]}],"drop-shadow-color":[{"drop-shadow":j()}],grayscale:[{grayscale:["",Ae,ye,be]}],"hue-rotate":[{"hue-rotate":[Ae,ye,be]}],invert:[{invert:["",Ae,ye,be]}],saturate:[{saturate:[Ae,ye,be]}],sepia:[{sepia:["",Ae,ye,be]}],"backdrop-filter":[{"backdrop-filter":["","none",ye,be]}],"backdrop-blur":[{"backdrop-blur":ge()}],"backdrop-brightness":[{"backdrop-brightness":[Ae,ye,be]}],"backdrop-contrast":[{"backdrop-contrast":[Ae,ye,be]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ae,ye,be]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ae,ye,be]}],"backdrop-invert":[{"backdrop-invert":["",Ae,ye,be]}],"backdrop-opacity":[{"backdrop-opacity":[Ae,ye,be]}],"backdrop-saturate":[{"backdrop-saturate":[Ae,ye,be]}],"backdrop-sepia":[{"backdrop-sepia":["",Ae,ye,be]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":P()}],"border-spacing-x":[{"border-spacing-x":P()}],"border-spacing-y":[{"border-spacing-y":P()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ye,be]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ae,"initial",ye,be]}],ease:[{ease:["linear","initial",v,ye,be]}],delay:[{delay:[Ae,ye,be]}],animate:[{animate:["none",w,ye,be]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,ye,be]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:J()}],"rotate-x":[{"rotate-x":J()}],"rotate-y":[{"rotate-y":J()}],"rotate-z":[{"rotate-z":J()}],scale:[{scale:G()}],"scale-x":[{"scale-x":G()}],"scale-y":[{"scale-y":G()}],"scale-z":[{"scale-z":G()}],"scale-3d":["scale-3d"],skew:[{skew:ee()}],"skew-x":[{"skew-x":ee()}],"skew-y":[{"skew-y":ee()}],transform:[{transform:[ye,be,"","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,be]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mbs":[{"scroll-mbs":P()}],"scroll-mbe":[{"scroll-mbe":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pbs":[{"scroll-pbs":P()}],"scroll-pbe":[{"scroll-pbe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ye,be]}],fill:[{fill:["none",...j()]}],"stroke-w":[{stroke:[Ae,Or,Pn,Rd]}],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"]}},oN=Rw(rN);function W(...e){return oN(Xf(e))}const sN="rounded-lg border border-border bg-surface overflow-hidden",aN="border-b border-border px-3 sm:px-4 py-1.5 sm:py-2",iN="p-2 sm:p-3 lg:p-4",fm="space-y-3 sm:space-y-4",mm="gap-2 sm:gap-3",hm="px-3 sm:px-4 py-1.5 sm:py-2",lN="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4",cN="grid grid-cols-1 lg:grid-cols-2",dN="flex flex-col-reverse md:flex-row",uN="w-full md:w-44 lg:w-52 md:flex-shrink-0 border-b md:border-b-0 md:border-l border-border",pN="text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider",fN="text-[11px] sm:text-xs text-foreground",ks="text-[10px] text-foreground-subtle",mN="text-[11px] sm:text-xs font-medium text-foreground",Oi="text-base sm:text-lg font-semibold leading-tight text-foreground",hN="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",gN="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",bN="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",xN="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",yN="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",vN="inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors",wN="border-primary/50 bg-primary/15 text-primary",NN="border-border bg-surface text-foreground-subtle hover:bg-surface-hover";function kN(e,t){for(const n of e.slots)for(const o of n.addons)if(o.id===t)return o;return null}function SN(e,t){return e.models.find(n=>n.id===t)??null}function CN(e,t){return e.models.find(n=>!!n.formats[t])??null}function MN(e,t){const n=new Set((t.configSchema??[]).map(s=>s.key)),o={};for(const[s,a]of Object.entries(e))n.has(s)&&(o[s]=a);return o}function gm(e){const{source:t,target:n,catalog:o,addonIds:s}=e,a=[];for(const i of s){const l=t.defaults[i];if(!l){a.push({addonId:i,outcome:"skip",modelId:null,reason:"no source entry",patch:null});continue}const c=kN(o,i);if(!c){a.push({addonId:i,outcome:"skip",modelId:null,reason:"addon not in target catalog",patch:null});continue}const d=SN(c,l.modelId),f=d!==null&&!!d.formats[n.engine.format];let p,m;if(f)p=l.modelId,m="exact";else{const g=CN(c,n.engine.format);if(!g){a.push({addonId:i,outcome:"skip",modelId:null,reason:"no compatible model for target format",patch:null});continue}p=g.id,m="mapped"}const h={enabled:l.enabled,modelId:p,settings:MN(l.settings,c)};a.push({addonId:i,outcome:m,modelId:p,patch:h})}return a}const zi={idle:{label:"Idle",textColor:"text-foreground-subtle",badgeClass:"border-border bg-surface-hover text-foreground-subtle",dotClass:"bg-gray-400",icon:"PowerOff"},active:{label:"Active",textColor:"text-success",badgeClass:"border-success/40 bg-success/10 text-success",dotClass:"bg-red-500 animate-pulse",icon:"Activity"},watching:{label:"Watching",textColor:"text-foreground-subtle",badgeClass:"border-border bg-surface-hover text-foreground-subtle",dotClass:"bg-emerald-500",icon:"Eye"},"load-shed":{label:"Load-Shed",textColor:"text-amber-500",badgeClass:"border-amber-500/40 bg-amber-500/10 text-amber-500",dotClass:"bg-amber-500",icon:"AlertTriangle"},paused:{label:"Paused",textColor:"text-gray-400",badgeClass:"border-gray-500/40 bg-gray-500/10 text-gray-400",dotClass:"bg-gray-400",icon:"PauseCircle"}};function Gn(e){return zi[e]??zi.watching}function cn(e,t){if(typeof globalThis>"u")return Oe(t);const n=globalThis.__camstackSharedContexts,o=n??new Map;n||(globalThis.__camstackSharedContexts=o);const s=o.get(e);if(s)return s;const a=Oe(t);return o.set(e,a),a}function ir(e){const n=(typeof globalThis<"u"?globalThis:void 0)?.[e];return n&&typeof n=="object"?n:{}}const IN={singleton:!0,requiredVersion:!1,eager:!0},zt=e=>({version:"0.0.0",scope:"default",lib:e,shareConfig:IN}),Bd="__mf_module_cache__";function AN(){const e=globalThis,t=e[Bd];if(t&&typeof t=="object"){const o=t;return o.share??={},o.remote??={},o}const n={share:{},remote:{}};return e[Bd]=n,n}function PN(){const e=AN();e.share.react??=$f,e.share["react-dom"]??=_f,e.share["react-dom/client"]??=Df,e.share["react/jsx-runtime"]??=Ef,e.share["@tanstack/react-query"]??=Tf,e.share["@trpc/client"]??=zf,e.share["@trpc/react-query"]??=jf,e.share["@camstack/ui-library"]??=ir("__camstackUiLibrary"),e.share["@camstack/sdk"]??=ir("__camstackSdk"),e.share["@camstack/types"]??=ir("__camstackTypes")}function Tl(){PN(),pr.getInstance()===null&&pr.init({name:"admin_ui_host",remotes:[],shared:{react:zt(()=>$f),"react-dom":zt(()=>_f),"react-dom/client":zt(()=>Df),"react/jsx-runtime":zt(()=>Ef),"@tanstack/react-query":zt(()=>Tf),"@trpc/client":zt(()=>zf),"@trpc/react-query":zt(()=>jf),"@camstack/ui-library":zt(()=>ir("__camstackUiLibrary")),"@camstack/sdk":zt(()=>ir("__camstackSdk")),"@camstack/types":zt(()=>ir("__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 bm=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim();/**
|
|
36
|
+
* @license lucide-react v0.576.0 - ISC
|
|
37
|
+
*
|
|
38
|
+
* This source code is licensed under the ISC license.
|
|
39
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
40
|
+
*/const EN=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 $N=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase());/**
|
|
46
|
+
* @license lucide-react v0.576.0 - ISC
|
|
47
|
+
*
|
|
48
|
+
* This source code is licensed under the ISC license.
|
|
49
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
50
|
+
*/const Fd=e=>{const t=$N(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 _N={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 DN=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 LN=He(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:s="",children:a,iconNode:i,...l},c)=>Me("svg",{ref:c,..._N,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:bm("lucide",s),...!a&&!DN(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,f])=>Me(d,f)),...Array.isArray(a)?a:[a]]));/**
|
|
66
|
+
* @license lucide-react v0.576.0 - ISC
|
|
67
|
+
*
|
|
68
|
+
* This source code is licensed under the ISC license.
|
|
69
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
70
|
+
*/const ce=(e,t)=>{const n=He(({className:o,...s},a)=>Me(LN,{ref:a,iconNode:t,className:bm(`lucide-${EN(Fd(e))}`,`lucide-${e}`,o),...s}));return n.displayName=Fd(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 TN=[["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"}]],xn=ce("activity",TN);/**
|
|
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 RN=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],ON=ce("arrow-down",RN);/**
|
|
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 zN=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],BN=ce("arrow-left",zN);/**
|
|
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 FN=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],jN=ce("arrow-right",FN);/**
|
|
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 HN=[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]],Rl=ce("arrow-up-to-line",HN);/**
|
|
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 VN=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],qN=ce("arrow-up",VN);/**
|
|
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 QN=[["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"}]],UN=ce("battery-full",QN);/**
|
|
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 KN=[["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"}]],GN=ce("battery-low",KN);/**
|
|
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 WN=[["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"}]],YN=ce("battery-warning",WN);/**
|
|
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 ZN=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],xm=ce("battery",ZN);/**
|
|
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 XN=[["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"}]],JN=ce("bell-ring",XN);/**
|
|
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 e2=[["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"}]],Ys=ce("bell",e2);/**
|
|
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 t2=[["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"}]],n2=ce("bug",t2);/**
|
|
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 r2=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Ol=ce("camera",r2);/**
|
|
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 o2=[["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"}]],s2=ce("cast",o2);/**
|
|
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 a2=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],wo=ce("check",a2);/**
|
|
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 i2=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Wn=ce("chevron-down",i2);/**
|
|
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 l2=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],c2=ce("chevron-left",l2);/**
|
|
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 d2=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Sn=ce("chevron-right",d2);/**
|
|
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 u2=[["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"}]],Zs=ce("circle-alert",u2);/**
|
|
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 p2=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],f2=ce("circle-check-big",p2);/**
|
|
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 m2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],h2=ce("circle-check",m2);/**
|
|
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 g2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],b2=ce("circle-dot",g2);/**
|
|
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 x2=[["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"}]],y2=ce("circle-pause",x2);/**
|
|
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 v2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],w2=ce("circle-plus",v2);/**
|
|
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 N2=[["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"}]],ym=ce("circle-question-mark",N2);/**
|
|
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 k2=[["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"}]],S2=ce("circle-x",k2);/**
|
|
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 C2=[["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"}]],M2=ce("copy-plus",C2);/**
|
|
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 I2=[["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"}]],Cn=ce("copy",I2);/**
|
|
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 A2=[["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"}]],P2=ce("cpu",A2);/**
|
|
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 E2=[["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"}]],vm=ce("crosshair",E2);/**
|
|
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 $2=[["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"}]],_2=ce("database",$2);/**
|
|
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 D2=[["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"}]],wm=ce("door-open",D2);/**
|
|
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 L2=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Bi=ce("download",L2);/**
|
|
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 T2=[["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"}]],Nm=ce("ellipsis-vertical",T2);/**
|
|
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 R2=[["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"}]],km=ce("external-link",R2);/**
|
|
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 O2=[["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"}]],Sm=ce("eye-off",O2);/**
|
|
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 z2=[["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"}]],Xs=ce("eye",z2);/**
|
|
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 B2=[["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"}]],Cm=ce("funnel",B2);/**
|
|
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 F2=[["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"}]],j2=ce("grip-horizontal",F2);/**
|
|
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 H2=[["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"}]],Mm=ce("house",H2);/**
|
|
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 V2=[["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"}]],q2=ce("image",V2);/**
|
|
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 Q2=[["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"}]],U2=ce("inbox",Q2);/**
|
|
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 K2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],G2=ce("info",K2);/**
|
|
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 W2=[["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"}]],Y2=ce("layout-grid",W2);/**
|
|
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 Z2=[["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"}]],Im=ce("lightbulb",Z2);/**
|
|
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 X2=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Lt=ce("loader-circle",X2);/**
|
|
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 J2=[["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"}]],ek=ce("locate-fixed",J2);/**
|
|
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 tk=[["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"}]],jd=ce("maximize-2",tk);/**
|
|
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 nk=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],rk=ce("menu",nk);/**
|
|
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 ok=[["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"}]],Am=ce("mic",ok);/**
|
|
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 sk=[["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"}]],Hd=ce("minimize-2",sk);/**
|
|
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 ak=[["path",{d:"M5 12h14",key:"1ays0h"}]],Pm=ce("minus",ak);/**
|
|
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 ik=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],zl=ce("moon",ik);/**
|
|
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 lk=[["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"}]],ck=ce("music",lk);/**
|
|
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 dk=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Fi=ce("network",dk);/**
|
|
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 uk=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],ji=ce("play",uk);/**
|
|
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 pk=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Js=ce("plus",pk);/**
|
|
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 fk=[["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"}]],mk=ce("plug",fk);/**
|
|
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 hk=[["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"}]],gk=ce("power-off",hk);/**
|
|
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 bk=[["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"}]],Em=ce("radar",bk);/**
|
|
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 xk=[["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"}]],yk=ce("radio",xk);/**
|
|
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 vk=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Bl=ce("refresh-cw",vk);/**
|
|
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 wk=[["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"}]],$m=ce("rotate-ccw",wk);/**
|
|
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 Nk=[["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"}]],_m=ce("rotate-cw",Nk);/**
|
|
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 kk=[["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"}]],Sk=ce("save",kk);/**
|
|
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 Ck=[["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"}]],Mk=ce("scan",Ck);/**
|
|
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 Ik=[["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"}]],Ak=ce("scroll-text",Ik);/**
|
|
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 Pk=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],ro=ce("search",Pk);/**
|
|
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 Ek=[["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"}]],$k=ce("server",Ek);/**
|
|
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 _k=[["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"}]],Dk=ce("shield",_k);/**
|
|
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 Lk=[["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"}]],Tk=ce("ship",Lk);/**
|
|
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 Rk=[["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"}]],Ok=ce("sliders-horizontal",Rk);/**
|
|
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 zk=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Vd=ce("square",zk);/**
|
|
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 Bk=[["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"}]],Fk=ce("star",Bk);/**
|
|
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 jk=[["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"}]],Dm=ce("sun",jk);/**
|
|
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 Hk=[["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"}]],Vk=ce("table-2",Hk);/**
|
|
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 qk=[["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"}]],qd=ce("target",qk);/**
|
|
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 Qk=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Uk=ce("thermometer",Qk);/**
|
|
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 Kk=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],Gk=ce("toggle-left",Kk);/**
|
|
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 Wk=[["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"}]],tn=ce("trash-2",Wk);/**
|
|
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 Yk=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Zk=ce("trending-up",Yk);/**
|
|
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 Xk=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],Jk=ce("trending-down",Xk);/**
|
|
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 e5=[["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"}]],No=ce("triangle-alert",e5);/**
|
|
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 t5=[["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"}]],Lm=ce("upload",t5);/**
|
|
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 n5=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],r5=ce("wifi-off",n5);/**
|
|
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 o5=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Tm=ce("wifi",o5);/**
|
|
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 s5=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Fl=ce("wrench",s5);/**
|
|
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 a5=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Xe=ce("x",a5);/**
|
|
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 i5=[["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"}]],Qd=ce("zap",i5);/**
|
|
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 l5=[["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"}]],c5=ce("zoom-in",l5);/**
|
|
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 d5=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],u5=ce("zoom-out",d5),p5={frigate:Tk,scrypted:Dk,reolink:yk,homeAssistant:Mm,rtsp:s2},f5={online:h2,offline:S2,degraded:Zs,unknown:ym},Ud=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Kd=Xf,Yn=(e,t)=>n=>{var o;if(t?.variants==null)return Kd(e,n?.class,n?.className);const{variants:s,defaultVariants:a}=t,i=Object.keys(s).map(d=>{const f=n?.[d],p=a?.[d];if(f===null)return null;const m=Ud(f)||Ud(p);return s[d][m]}),l=n&&Object.entries(n).reduce((d,f)=>{let[p,m]=f;return m===void 0||(d[p]=m),d},{}),c=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((d,f)=>{let{class:p,className:m,...h}=f;return Object.entries(h).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...a,...l}[b]):{...a,...l}[b]===x})?[...d,p,m]:d},[]);return Kd(e,i,c,n?.class,n?.className)},m5=Yn("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"}}),Qe=He(({className:e,variant:t,size:n,...o},s)=>r("button",{ref:s,className:W(m5({variant:t,size:n}),e),...o}));Qe.displayName="Button";const h5=Yn("inline-flex items-center justify-center rounded-md font-medium transition-colors cursor-pointer disabled:opacity-50 disabled:pointer-events-none",{variants:{variant:{primary:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-surface text-foreground hover:bg-surface-hover",ghost:"hover:bg-surface-hover text-foreground-muted",danger:"bg-danger text-white hover:bg-danger/90",outline:"border border-border bg-transparent hover:bg-surface-hover"},size:{sm:"h-7 w-7",md:"h-8 w-8",lg:"h-9 w-9"}},defaultVariants:{variant:"primary",size:"sm"}}),jl=He(({className:e,variant:t,size:n,icon:o,...s},a)=>r("button",{ref:a,className:W(h5({variant:t,size:n}),e),...s,children:r(o,{className:"h-4 w-4"})}));jl.displayName="IconButton";const g5=Yn("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"}}),lr=He(({className:e,variant:t,style:n,...o},s)=>r("span",{ref:s,className:W(g5({variant:t,styleVariant:n}),e),...o}));lr.displayName="Badge";const b5=Yn("rounded-lg p-3",{variants:{variant:{flat:"bg-surface",bordered:"bg-surface border border-border"}},defaultVariants:{variant:"bordered"}}),en=He(({className:e,variant:t,...n},o)=>r("div",{ref:o,className:W(b5({variant:t}),e),...n}));en.displayName="Card";function Rm({expanded:e,onExpandedChange:t,header:n,children:o,dimmed:s=!1,hideChevron:a=!1,className:i}){return u("div",{className:W("rounded-lg border border-border bg-surface overflow-hidden",s&&"opacity-[0.45]",i),children:[u("div",{role:"button",tabIndex:0,className:"flex items-center gap-2.5 px-3 py-2.5 cursor-pointer select-none",onClick:()=>t(!e),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),t(!e))},children:[!a&&r("span",{className:"text-foreground-subtle shrink-0",children:e?r(Wn,{className:"h-4 w-4"}):r(Sn,{className:"h-4 w-4"})}),n]}),e&&o&&r("div",{className:"border-t border-border px-3 py-3",children:o})]})}const Hl=He(({className:e,...t},n)=>r("label",{ref:n,className:W("text-[10px] uppercase tracking-wider text-foreground-muted font-medium",e),...t}));Hl.displayName="Label";const x5=Yn("",{variants:{orientation:{horizontal:"h-px w-full bg-border-subtle",vertical:"w-px h-full bg-border-subtle"}},defaultVariants:{orientation:"horizontal"}}),Vl=He(({className:e,orientation:t,...n},o)=>r("div",{ref:o,role:"separator",className:W(x5({orientation:t}),e),...n}));Vl.displayName="Separator";const Om=He(({className:e,...t},n)=>r("div",{ref:n,className:W("animate-pulse bg-surface-hover rounded-md h-4 w-full",e),...t}));Om.displayName="Skeleton";const Gd=Yn("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"}}),Ss=He(({className:e,state:t,leftSlot:n,rightSlot:o,...s},a)=>n||o?u("div",{className:"relative flex items-center w-full",children:[n&&r("div",{className:"absolute left-2.5 flex items-center pointer-events-none",children:n}),r("input",{ref:a,className:W(Gd({state:t}),n?"pl-7":"",o?"pr-7":"",e),...s}),o&&r("div",{className:"absolute right-2.5 flex items-center pointer-events-none",children:o})]}):r("input",{ref:a,className:W(Gd({state:t}),e),...s}));Ss.displayName="Input";const Cs=He(({className:e,options:t,...n},o)=>u("div",{className:"relative w-full",children:[r("select",{ref:o,className:W("h-7 w-full px-2.5 text-xs bg-surface border border-border rounded-md text-foreground appearance-none pr-7 focus:outline-none focus:ring-1 focus:ring-primary",e),...n,children:t.map(s=>r("option",{value:s.value,children:s.label},s.value))}),r("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none text-foreground-muted",children:r(Wn,{className:"h-3.5 w-3.5"})})]}));Cs.displayName="Select";const zm=He(({className:e,...t},n)=>r("input",{ref:n,type:"checkbox",className:W("w-3.5 h-3.5 rounded-sm border border-border accent-primary",e),...t}));zm.displayName="Checkbox";const ql=He(({className:e,checked:t,onCheckedChange:n,label:o,...s},a)=>u("button",{ref:a,role:"switch","aria-checked":t,type:"button",onClick:()=>n(!t),className:W("inline-flex items-center gap-2",e),...s,children:[r("span",{className:W("w-8 h-4 rounded-full transition-colors",t?"bg-primary":"bg-surface-hover"),children:r("span",{className:W("block w-3.5 h-3.5 rounded-full bg-white transition-transform",t?"translate-x-4":"translate-x-0.5")})}),o&&r("span",{className:"text-xs text-foreground",children:o})]}));ql.displayName="Switch";const Bm=Oe(null);function Fm(){const e=ve(Bm);if(!e)throw new Error("Dialog compound components must be used within <Dialog>");return e}function jm({children:e,open:t,onOpenChange:n}){const[o,s]=_(!1),a=t??o,i=fr(),l=q(c=>{n?.(c),t===void 0&&s(c)},[t,n]);return r(Bm.Provider,{value:{open:a,setOpen:l,contentId:i},children:e})}function y5({children:e,...t}){const{setOpen:n}=Fm();return r("button",{type:"button",onClick:()=>n(!0),...t,children:e})}const v5=Yn("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"}}),Ql=He(({className:e,width:t,children:n,...o},s)=>{const{open:a,setOpen:i,contentId:l}=Fm(),c=ne(null),d=s??c;Z(()=>{const p=d.current;p&&(a&&!p.open&&p.showModal(),!a&&p.open&&p.close())},[a,d]);const f=p=>{p.target===p.currentTarget&&i(!1)};return r("dialog",{ref:d,id:l,className:W(v5({width:t}),"w-full",e),onClick:f,onClose:()=>i(!1),...o,children:n})});Ql.displayName="DialogContent";function Hm({className:e,...t}){return r("div",{className:W("flex flex-col gap-1 mb-3",e),...t})}function Vm({className:e,...t}){return r("div",{className:W("flex justify-end gap-2 mt-4",e),...t})}function qm({className:e,...t}){return r("h2",{className:W("text-sm font-semibold text-foreground",e),...t})}function Qm({className:e,...t}){return r("p",{className:W("text-xs text-foreground-muted",e),...t})}const Um=Oe(null);function Ul(){const e=ve(Um);if(!e)throw new Error("Dropdown compound components must be used within <Dropdown>");return e}function Km({children:e}){const[t,n]=_(!1),o=fr(),s=fr(),a=ne(null);return r(Um.Provider,{value:{open:t,setOpen:n,triggerId:o,contentId:s,triggerRef:a},children:r("div",{className:"relative inline-block",children:e})})}function Gm({children:e,...t}){const{open:n,setOpen:o,triggerId:s,contentId:a,triggerRef:i}=Ul();return r("button",{type:"button",ref:i,id:s,"aria-haspopup":"menu","aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>o(!n),...t,children:e})}function Wm({className:e,children:t,align:n="start",offset:o=4,...s}){const{open:a,setOpen:i,contentId:l,triggerId:c,triggerRef:d}=Ul(),f=ne(null),[p,m]=_(null);if(Gs(()=>{if(!a){m(null);return}const g=()=>{const b=d.current;if(!b)return;const x=b.getBoundingClientRect(),v=n==="end"?x.right:x.left;m({top:x.bottom+o,left:v,minWidth:x.width})};return g(),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0)}},[a,n,o,d]),Z(()=>{if(!a)return;const g=x=>{const v=f.current,w=d.current;v&&!v.contains(x.target)&&!w?.contains(x.target)&&i(!1)},b=x=>{x.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",b)}},[a,i,d]),!a||!p||typeof document>"u")return null;const h={position:"fixed",top:p.top,...n==="end"?{right:window.innerWidth-p.left}:{left:p.left},minWidth:p.minWidth};return vo(r("div",{ref:f,id:l,role:"menu","aria-labelledby":c,style:h,className:W("z-50 bg-background-elevated border border-border rounded-md shadow-lg py-1 min-w-[160px]",e),...s,children:t}),document.body)}function Ym({className:e,icon:t,variant:n="default",children:o,onClick:s,...a}){const{setOpen:i}=Ul(),l=q(c=>{s?.(c),i(!1)},[s,i]);return u("button",{type:"button",role:"menuitem",className:W("h-7 text-xs px-2 w-full text-left flex items-center gap-2",n==="danger"?"text-danger hover:bg-danger/10":"text-foreground hover:bg-surface-hover",e),onClick:l,...a,children:[t&&r(t,{size:14}),o]})}const Zm=Oe(null);function Xm(){const e=ve(Zm);if(!e)throw new Error("Tooltip compound components must be used within <Tooltip>");return e}function w5({children:e}){const[t,n]=_(!1),o=ne(null),s=fr(),a=()=>{o.current=setTimeout(()=>n(!0),300)},i=()=>{o.current&&clearTimeout(o.current),n(!1)};return r(Zm.Provider,{value:{open:t,show:a,hide:i,tooltipId:s},children:r("div",{className:"relative inline-block",children:e})})}function N5({children:e,...t}){const{show:n,hide:o,tooltipId:s,open:a}=Xm();return r("div",{onMouseEnter:n,onMouseLeave:o,onFocus:n,onBlur:o,"aria-describedby":a?s:void 0,...t,children:e})}function k5({className:e,children:t,...n}){const{open:o,tooltipId:s}=Xm();return r("div",{id:s,role:"tooltip",className:W("absolute bottom-full left-1/2 -translate-x-1/2 mb-2 bg-foreground text-background text-xs px-2 py-1 rounded-md shadow-md whitespace-nowrap pointer-events-none transition-opacity duration-150",o?"opacity-100":"opacity-0",e),...n,children:t})}const Wd="(max-width: 767px)",Yd="(min-width: 768px) and (max-width: 1023px)";function Jm(e){return t=>{const n=window.matchMedia(e);return n.addEventListener("change",t),()=>n.removeEventListener("change",t)}}function eh(e){return()=>window.matchMedia(e).matches}function th(){return!1}function Zn(){return Ws(Jm(Wd),eh(Wd),th)}function nh(){return Ws(Jm(Yd),eh(Yd),th)}function Kl({open:e,onClose:t,title:n,children:o,className:s}){return Z(()=>{if(!e)return;const a=i=>{i.key==="Escape"&&t()};return document.addEventListener("keydown",a),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",a),document.body.style.overflow=""}},[e,t]),u(xe,{children:[r("div",{className:W("fixed inset-0 z-40 bg-black/50 transition-opacity duration-200",e?"opacity-100":"pointer-events-none opacity-0"),onClick:t,"aria-hidden":"true"}),u("div",{role:"dialog","aria-modal":"true",className:W("fixed inset-x-0 bottom-0 z-50 flex flex-col bg-background-elevated border-t border-border rounded-t-xl shadow-2xl transition-transform duration-200 ease-out","max-h-[80dvh]",e?"translate-y-0":"translate-y-full",s),children:[r("div",{className:"flex justify-center pt-2 pb-1",children:r("div",{className:"h-1 w-8 rounded-full bg-foreground-subtle/30"})}),n&&u("div",{className:"flex items-center justify-between px-4 pb-2",children:[r("span",{className:"text-sm font-medium text-foreground",children:n}),r("button",{onClick:t,className:"p-1 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors",children:r(Xe,{className:"h-4 w-4"})})]}),r("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:o})]})]})}const rh=Oe(null);function oh(){const e=ve(rh);if(!e)throw new Error("Popover compound components must be used within <Popover>");return e}function sh({children:e,open:t,onOpenChange:n}){const[o,s]=_(!1),a=t??o,i=fr(),l=fr(),c=q(d=>{n?.(d),t===void 0&&s(d)},[t,n]);return r(rh.Provider,{value:{open:a,setOpen:c,triggerId:i,contentId:l},children:r("div",{className:"relative inline-block",children:e})})}function ah({children:e,...t}){const{open:n,setOpen:o,triggerId:s,contentId:a}=oh();return r("button",{type:"button",id:s,"aria-haspopup":"dialog","aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>o(!n),...t,children:e})}function ih({className:e,children:t,...n}){const{open:o,setOpen:s,contentId:a,triggerId:i}=oh(),l=Zn(),c=ne(null);return Z(()=>{if(!o||l)return;const d=p=>{const m=c.current,h=document.getElementById(i);m&&!m.contains(p.target)&&!h?.contains(p.target)&&s(!1)},f=p=>{p.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",d),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",f)}},[o,s,i,l]),o?l?r(Kl,{open:o,onClose:()=>s(!1),children:t}):r("div",{ref:c,id:a,role:"dialog","aria-labelledby":i,className:W("absolute left-0 top-full z-50 mt-1 bg-background-elevated border border-border rounded-lg shadow-lg p-3",e),...n,children:t}):null}const lh=Oe(null);function ch(){const e=ve(lh);if(!e)throw new Error("Tabs compound components must be used within <Tabs>");return e}function S5({value:e,onValueChange:t,defaultValue:n="",className:o,...s}){const[a,i]=_(n),l=e??a,c=q(d=>{t?.(d),e===void 0&&i(d)},[e,t]);return r(lh.Provider,{value:{value:l,setValue:c},children:r("div",{className:o,...s})})}function C5({className:e,...t}){return r("div",{role:"tablist",className:W("flex flex-row border-b border-border-subtle",e),...t})}function M5({value:e,className:t,...n}){const{value:o,setValue:s}=ch(),a=e===o,i=`tabpanel-${e}`;return r("button",{type:"button",role:"tab","aria-selected":a,"aria-controls":i,tabIndex:a?0:-1,className:W("h-7 text-xs px-3 transition-colors",a?"border-b-2 border-primary text-foreground font-medium":"text-foreground-muted hover:text-foreground",t),onClick:()=>s(e),...n})}function I5({value:e,className:t,...n}){const{value:o}=ch();return e!==o?null:r("div",{role:"tabpanel",id:`tabpanel-${e}`,className:W("pt-3",t),...n})}const Gl=He(({className:e,...t},n)=>r("div",{ref:n,className:W("overflow-auto [&::-webkit-scrollbar]:w-1 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-surface-hover [&::-webkit-scrollbar-thumb]:rounded-full",e),...t}));Gl.displayName="ScrollArea";function A5({title:e,onClose:t,children:n,defaultWidth:o=360,defaultHeight:s=280,minWidth:a=280,minHeight:i=160,offsetIndex:l=0,className:c}){const[d,f]=_({x:80+l*30,y:80+l*30}),[p,m]=_({w:o,h:s}),[h,g]=_(!1),b=ne(!1),x=ne(!1),v=ne({x:0,y:0}),w=Zn(),y=q(k=>{k.preventDefault(),b.current=!0,v.current={x:k.clientX-d.x,y:k.clientY-d.y}},[d]),N=q(k=>{k.preventDefault(),k.stopPropagation(),x.current=!0,v.current={x:k.clientX,y:k.clientY}},[]);return Z(()=>{const k=M=>{if(b.current&&f({x:M.clientX-v.current.x,y:M.clientY-v.current.y}),x.current){const P=M.clientX-v.current.x,I=M.clientY-v.current.y;v.current={x:M.clientX,y:M.clientY},m(z=>({w:Math.max(a,z.w+P),h:Math.max(i,z.h+I)}))}},S=()=>{b.current=!1,x.current=!1};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",S)}},[a,i]),w?u("div",{className:W("fixed inset-x-0 bottom-0 z-50 rounded-t-xl border-t border-border bg-background-elevated shadow-2xl flex flex-col overflow-hidden",c),style:{maxHeight:"60dvh"},children:[u("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border shrink-0 bg-surface",children:[r("span",{className:"text-[11px] font-medium truncate",children:e}),u("div",{className:"flex items-center gap-1 shrink-0",children:[r("button",{onClick:()=>g(!h),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",children:h?r(jd,{size:12}):r(Hd,{size:12})}),r("button",{onClick:t,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",children:r(Xe,{size:12})})]})]}),!h&&r("div",{className:"flex-1 min-h-0 overflow-y-auto",children:n})]}):u("div",{className:W("fixed z-50 rounded-lg border border-border bg-background-elevated shadow-2xl flex flex-col overflow-hidden",c),style:{left:d.x,top:d.y,width:h?280:p.w,height:h?"auto":p.h},children:[u("div",{onMouseDown:y,className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border cursor-move select-none shrink-0 bg-surface",children:[u("div",{className:"flex items-center gap-2 min-w-0",children:[r(j2,{size:12,className:"text-foreground-subtle shrink-0"}),r("span",{className:"text-[11px] font-medium truncate",children:e})]}),u("div",{className:"flex items-center gap-1 shrink-0",children:[r("button",{onClick:()=>g(!h),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",title:h?"Restore":"Minimize",children:h?r(jd,{size:12}):r(Hd,{size:12})}),r("button",{onClick:t,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",title:"Close",children:r(Xe,{size:12})})]})]}),!h&&u("div",{className:"flex-1 min-h-0 overflow-y-auto relative",children:[n,r("div",{onMouseDown:N,className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",style:{background:"linear-gradient(135deg, transparent 50%, var(--color-foreground-subtle) 50%)",opacity:.4}})]})]})}function Wl({open:e,onClose:t,children:n,className:o,width:s="w-64"}){const a=ne(null);return Z(()=>{if(!e)return;const i=l=>{l.key==="Escape"&&t()};return document.addEventListener("keydown",i),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",i),document.body.style.overflow=""}},[e,t]),u(xe,{children:[r("div",{className:W("fixed inset-0 z-40 bg-black/50 backdrop-blur-sm transition-opacity duration-200",e?"opacity-100":"pointer-events-none opacity-0"),onClick:t,"aria-hidden":"true"}),r("div",{ref:a,role:"dialog","aria-modal":"true",className:W("fixed inset-y-0 left-0 z-50 flex flex-col bg-surface border-r border-border shadow-2xl transition-transform duration-200 ease-out",s,e?"translate-x-0":"-translate-x-full",o),children:n})]})}function Yl({items:e,className:t}){return r("nav",{className:`flex items-center gap-1 text-[11px] text-foreground-subtle ${t??""}`,children:e.map((n,o)=>{const s=o===e.length-1,a=!s&&(n.onClick||n.href);return u(El.Fragment,{children:[o>0&&r(Sn,{className:"h-3 w-3 flex-shrink-0"}),a?n.onClick?r("button",{type:"button",onClick:n.onClick,className:"hover:text-foreground transition-colors",children:n.label}):r("a",{href:n.href,className:"hover:text-foreground transition-colors",children:n.label}):r("span",{className:s?"text-foreground font-medium":"",children:n.label})]},o)})})}const Zd={left:"text-left",right:"text-right",center:"text-center"};function dh({columns:e,rows:t,rowKey:n,onRowClick:o,minWidthPx:s=480,emptyMessage:a,className:i,bordered:l=!0,rowClassName:c}){if(t.length===0&&a)return r("div",{className:`rounded-lg ${l?"border border-border":""} bg-surface px-3 py-4 text-xs text-foreground-subtle text-center ${i??""}`,children:a});if(t.length===0)return null;const d=`rounded-lg ${l?"border border-border":""} bg-surface overflow-x-auto ${i??""}`;return r("div",{className:d,children:u("table",{className:"w-full text-xs",style:{minWidth:`${s}px`},children:[r("thead",{className:"bg-surface",children:r("tr",{children:e.map(f=>{const p=f.align??"left",m=f.nowrap??!0;return r("th",{className:["px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border",Zd[p],m?"whitespace-nowrap":"",f.width??""].filter(Boolean).join(" "),children:f.headerRender?f.headerRender():f.header},f.key)})})}),r("tbody",{children:t.map((f,p)=>{const m=n?n(f,p):p,h=c?.(f,p)??"",g=o!==void 0;return r("tr",{onClick:g?()=>o(f,p):void 0,className:[g?"cursor-pointer hover:bg-primary/5":"hover:bg-primary/5",h].filter(Boolean).join(" "),children:e.map(b=>{const x=b.align??"left",v=b.nowrap??!1;return r("td",{className:["px-3 py-2 text-foreground border-b border-border",Zd[x],v?"whitespace-nowrap":""].filter(Boolean).join(" "),children:b.render(f,p)},b.key)})},m)})})]})})}function Zl({open:e,onClose:t,title:n,subtitle:o,footer:s,children:a,widthClass:i="w-[360px]"}){return Z(()=>{if(!e)return;const l=c=>{c.key==="Escape"&&t()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e,t]),e?u("aside",{className:W("absolute top-0 right-0 bottom-0 z-20 flex flex-col","bg-surface border-l border-border shadow-xl",i),role:"dialog","aria-modal":"false",children:[u("header",{className:"flex items-start justify-between gap-2 px-4 py-3 border-b border-border",children:[u("div",{className:"min-w-0",children:[r("div",{className:"text-sm font-semibold text-foreground truncate",children:n}),o!==void 0&&r("div",{className:"text-[11px] text-foreground-subtle mt-0.5 truncate",children:o})]}),r("button",{type:"button",onClick:t,className:"p-1 rounded hover:bg-muted text-foreground-subtle hover:text-foreground","aria-label":"Close panel",children:r(Xe,{className:"w-4 h-4"})})]}),r("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-3",children:a}),s!==void 0&&r("footer",{className:"flex items-center gap-2 justify-end px-4 py-3 border-t border-border",children:s})]}):null}const P5={inherit:"bg-muted",on:"bg-emerald-500",off:"bg-orange-500",na:"bg-gray-300 opacity-50"};function uh({node:e,depth:t,selectedAddonId:n,onSelect:o,agentDots:s}){const a=e.addonId===n,i=s?.[e.addonId]??[];return u("div",{children:[u("button",{type:"button",onClick:()=>o(e.addonId),className:W("w-full flex items-center justify-between gap-2 text-left px-3 py-1.5 text-xs","border-l-2",a?"bg-accent border-primary text-foreground font-medium":"border-transparent hover:bg-muted/40 text-foreground"),style:{paddingLeft:`${12+t*14}px`},children:[r("span",{className:"truncate",children:e.addonName}),i.length>0&&r("span",{className:"flex items-center gap-1 shrink-0",children:i.map(l=>r("span",{title:`${l.agentNodeId}: ${l.state}`,className:W("w-2 h-2 rounded-full",P5[l.state])},l.agentNodeId))})]}),e.children.map(l=>r(uh,{node:l,depth:t+1,selectedAddonId:n,onSelect:o,agentDots:s},l.addonId))]})}function ph({tree:e,selectedAddonId:t,onSelect:n,agentDots:o,className:s}){return r("div",{className:W("flex flex-col py-2",s),children:e.map(a=>r(uh,{node:a,depth:0,selectedAddonId:t,onSelect:n,agentDots:o},a.addonId))})}function ea(e){const t=[],n=[],o=new Map;for(const a of e.slots)for(const i of a.addons){const l={addonId:i.id,addonName:i.name,slot:i.slot,inputClasses:i.inputClasses,outputClasses:i.outputClasses,children:[]};i.slot==="audio-classifier"?t.push(l):(n.push(l),o.set(i.id,l))}const s=[];for(const a of n){if(a.inputClasses.length===0){s.push(a);continue}const i=n.find(l=>l.addonId!==a.addonId&&l.outputClasses.some(c=>a.inputClasses.includes(c)));i&&i.children.push(a)}return[...s,...t]}function E5(e){return e?e.models.map(t=>({id:t.id,name:t.name})):[]}function ps({step:e,schema:t,allSchemas:n,depth:o=0,onChange:s,onDelete:a,readOnly:i=!1,toggleMode:l="simple",overrideState:c=null,onOverrideChange:d,inheritedEnabled:f,hideModelAndSettings:p=!1}){const[m,h]=_(!1),g=E5(t);if(g.length>0&&!g.some(x=>x.id===e.modelId)&&!i){const v=(t?.defaultModelId?g.find(w=>w.id===t.defaultModelId):null)??g[0];v&&v.id!==e.modelId&&queueMicrotask(()=>s({...e,modelId:v.id}))}const b=u(xe,{children:[u("div",{className:"flex-1 min-w-0",children:[r("span",{className:"text-[10px] uppercase tracking-wider font-medium text-foreground-subtle/60 block leading-none",children:e.slot}),r("span",{className:"text-sm font-semibold text-foreground truncate block leading-tight",children:e.addonName}),u("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(x=>r("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-blue-500/12 text-blue-400",children:x},x)),e.inputClasses.length>0&&e.outputClasses.length>0&&r("span",{className:"text-foreground-subtle/40 text-[10px]",children:"→"}),e.outputClasses.map(x=>r("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-green-500/12 text-green-400",children:x},x))]})]}),!i&&l==="simple"&&r("button",{onClick:x=>{x.stopPropagation(),s({...e,enabled:!e.enabled})},className:W("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors",e.enabled?"bg-success":"bg-foreground-subtle/30"),children:r("span",{className:W("inline-block h-4 w-4 rounded-full bg-white shadow transition-transform",e.enabled?"translate-x-6":"translate-x-1")})}),!i&&l==="threeState"&&d&&u("div",{className:"flex items-center gap-0.5 rounded-md border border-border p-0.5",onClick:x=>x.stopPropagation(),children:[r(Ha,{label:"Inherit",active:c===null,variant:"inherit",subtext:f===void 0?void 0:f?"on":"off",onClick:()=>d(null)}),r(Ha,{label:"On",active:c===!0,variant:"on",onClick:()=>d(!0)}),r(Ha,{label:"Off",active:c===!1,variant:"off",onClick:()=>d(!1)})]})]});return r(Rm,{expanded:m,onExpandedChange:h,dimmed:!e.enabled,header:b,children:p?r("p",{className:"text-[11px] text-foreground-subtle",children:"Model and detection settings are managed per agent — open the Pipeline page for this camera's agent to edit them."}):u("div",{className:"space-y-3",children:[r(Hi,{label:"Model",value:e.modelId,disabled:i,options:g.map(x=>({value:x.id,label:x.name})),onChange:x=>s({...e,modelId:x})}),e.slot==="audio-classifier"&&e.engine&&r(Hi,{label:"Runtime",value:`${e.engine.runtime}/${e.engine.backend}`,disabled:i,options:[{value:"node/cpu",label:"Node.js — ONNX CPU"},{value:"node/coreml",label:"Node.js — Apple SoundAnalysis (macOS)"},{value:"python/cpu",label:"Python — ONNX CPU"}],onChange:x=>{const[v,w]=x.split("/");s({...e,engine:{runtime:v,backend:w,format:w==="coreml"?"coreml":"onnx"}})}}),t?.configSchema?.map(x=>r(ta,{field:x,allFields:t.configSchema??[],step:e,disabled:i,onChange:s},x.key))]})})}function Hi({label:e,value:t,options:n,disabled:o,onChange:s}){return u("div",{children:[r("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e}),u("select",{value:t,onChange:a=>s(a.target.value),disabled:o,className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground focus:outline-none focus:border-primary/50",children:[n.length===0&&r("option",{value:t,children:t||"default"}),n.map(a=>r("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]})]})}function $5({label:e,description:t,value:n,options:o,disabled:s,onChange:a}){function i(l){if(s)return;const c=n.includes(l)?n.filter(d=>d!==l):[...n,l];a(c)}return u("div",{children:[r("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1",children:e}),t&&r("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:t}),r("div",{className:"flex flex-wrap gap-1.5",children:o.map(l=>{const c=n.includes(l.value);return r("button",{type:"button",disabled:s,onClick:()=>i(l.value),className:W("text-[10px] font-medium px-2 py-1 rounded-md border transition-colors",c?"bg-primary/20 text-primary border-primary/40":"bg-surface text-foreground-subtle border-border hover:border-primary/30",s&&"opacity-50 cursor-not-allowed"),children:l.label},l.value)})})]})}function _5(e,t,n){const o=t.settings?.[e];if(o!==void 0)return o;const s=n.find(a=>"key"in a&&a.key===e);return s&&"default"in s?s.default:void 0}function ta({field:e,allFields:t,step:n,disabled:o,onChange:s}){const a=e.type!=="separator"&&e.type!=="info"?e.showWhen:void 0;if(a){const{field:l,equals:c,notEquals:d,in:f,notIn:p}=a,m=_5(l,n,t);if(c!==void 0&&m!==c||d!==void 0&&m===d||f!==void 0&&!f.includes(m)||p!==void 0&&p.includes(m))return null}function i(l){s({...n,settings:{...n.settings,[e.key]:l}})}if(e.type==="select"){const l=n.settings?.[e.key],c=typeof l=="string"?l:e.default??"";return r(Hi,{label:e.label,value:c,disabled:o||e.disabled,options:e.options,onChange:i})}if(e.type==="multiselect"){const l=n.settings?.[e.key],c=Array.isArray(l)?l:Array.isArray(e.default)?e.default:[];return r($5,{label:e.label,description:e.description,value:c,options:e.options,disabled:o||e.disabled,onChange:i})}if(e.type==="slider"||e.type==="number"){const l=n.settings?.[e.key],c=typeof e.default=="number"?e.default:e.min??0,d=typeof l=="number"?l:c,f=e.min??0,p=e.max??1,m=e.step??.01,h=e.type==="slider"?e.showValue:!0,g="unit"in e?e.unit:void 0,b=e.type==="slider"?e.displayScale:void 0,x=b?d/b:d;return u("div",{children:[u("div",{className:"flex items-center justify-between mb-1",children:[r("span",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide",children:e.label}),h&&u("span",{className:"text-xs font-medium text-foreground tabular-nums",children:[typeof x=="number"?x.toFixed(2).replace(/\.?0+$/,""):x,g?` ${g}`:""]})]}),e.description&&r("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:e.description}),r("input",{type:"range",min:f,max:p,step:m,value:d,disabled:o||e.disabled,onChange:v=>i(Number(v.target.value)),className:"w-full accent-primary h-1.5"})]})}if(e.type==="boolean"){const l=n.settings?.[e.key],c=typeof l=="boolean"?l:e.default===!0;return u("label",{className:"flex items-center gap-2",children:[r("input",{type:"checkbox",checked:c,disabled:o||e.disabled,onChange:d=>i(d.target.checked),className:"h-3.5 w-3.5 accent-primary"}),r("span",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide",children:e.label})]})}if(e.type==="text"||e.type==="password"||e.type==="textarea"){const l=n.settings?.[e.key],c=typeof l=="string"?l:e.default??"",d=e.type==="password"?"password":"text";return u("div",{children:[r("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e.label}),e.type==="textarea"?r("textarea",{value:c,disabled:o||e.disabled,placeholder:e.placeholder,onChange:f=>i(f.target.value),rows:3,className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground focus:outline-none focus:border-primary/50 resize-y"}):r("input",{type:d,value:c,disabled:o||e.disabled,placeholder:e.placeholder,onChange:f=>i(f.target.value),className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground focus:outline-none focus:border-primary/50"})]})}return e.type==="separator"?r("div",{className:"border-t border-border my-2"}):e.type==="info"?r("div",{className:"rounded-md border border-border bg-surface px-2 py-1.5 text-[10px] text-foreground-subtle",children:e.content}):null}function Ha({label:e,active:t,variant:n,subtext:o,onClick:s}){return u("button",{type:"button",onClick:s,className:W("px-2 py-1 text-[10px] font-medium rounded transition-colors",t?n==="on"?"bg-green-500/20 text-green-400":n==="off"?"bg-red-500/20 text-red-400":"bg-primary/20 text-primary":"text-foreground-subtle hover:bg-surface-hover"),children:[e,o&&t&&u("span",{className:"ml-1 opacity-60",children:["(",o,")"]})]})}function fh(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 D5(e,t,n){return n?{enabled:n.enabled??t.enabled,modelId:n.modelId??t.modelId,settings:n.settings??t.settings}:t}function L5({addon:e,agentDefault:t,modelsForFormat:n,onChangeAgentConfig:o}){const s=a=>{o?.({...t,...a})};return u("div",{className:"space-y-4 text-xs",children:[u("label",{className:"flex items-center gap-2",children:[r("input",{type:"checkbox",checked:t.enabled,onChange:a=>s({enabled:a.target.checked})}),u("span",{children:["Enabled on this agent (",e.name,")"]})]}),u("div",{children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle mb-1",children:"Model"}),r("select",{className:"w-full bg-surface border border-border rounded px-2 py-1 text-xs",value:t.modelId,onChange:a=>s({modelId:a.target.value}),children:n.map(a=>r("option",{value:a.id,children:a.name},a.id))})]}),(e.configSchema?.length??0)>0&&u("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),e.configSchema?.map(a=>r(ta,{field:a,allFields:e.configSchema??[],step:fh(e,t),disabled:!1,onChange:i=>s({settings:{...i.settings}})},a.key))]})]})}function T5({addon:e,agentDefault:t,agentNodeId:n,currentPatch:o,modelsForFormat:s,onChangePatch:a}){const i=D5("device",t,o),l=h=>{const g=h.enabled!==void 0||h.modelId!==void 0||h.settings!==void 0;a?.(g?h:null)},c=h=>{const{enabled:g,...b}=o??{},x=h==="inherit"?b:{...b,enabled:h==="on"};l(x)},d=h=>{const{modelId:g,...b}=o??{},x=h===void 0?b:{...b,modelId:h};l(x)},f=h=>{const{settings:g,...b}=o??{},x=h===void 0?b:{...b,settings:h};l(x)},p=o?.enabled===void 0?"inherit":o.enabled?"on":"off",m=o?.modelId!==void 0;return u("div",{className:"space-y-4 text-xs",children:[u("div",{className:"flex items-center gap-1",children:[["inherit","on","off"].map(h=>r("button",{type:"button",onClick:()=>c(h),className:W("px-3 py-1 border border-border rounded text-xs capitalize",p===h?"bg-primary text-primary-foreground border-primary":"bg-surface text-foreground hover:bg-muted"),children:h},h)),u("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["agent default: ",r("span",{className:"font-semibold",children:t.enabled?"on":"off"})]})]}),u("div",{children:[u("div",{className:"flex items-center justify-between mb-1",children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Model"}),m?r("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>d(void 0),children:"Clear"}):r("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>d(t.modelId),children:"Override"})]}),r("select",{disabled:!m,className:"w-full bg-surface border border-border rounded px-2 py-1 text-xs disabled:opacity-50",value:m?o?.modelId??t.modelId:t.modelId,onChange:h=>d(h.target.value),children:s.map(h=>r("option",{value:h.id,children:h.name},h.id))}),!m&&u("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["inherits from ",n]})]}),(e.configSchema?.length??0)>0&&(()=>{const h=o?.settings!==void 0;return u("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[u("div",{className:"flex items-center justify-between",children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),h?r("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>f(void 0),children:"Clear"}):r("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>f({...t.settings}),children:"Override"})]}),e.configSchema?.map(g=>r(ta,{field:g,allFields:e.configSchema??[],step:fh(e,i),disabled:!h,onChange:b=>f({...b.settings})},g.key)),!h&&u("div",{className:"text-[10px] text-foreground-subtle",children:["inherits from ",n]})]})})(),u("div",{className:"rounded bg-muted/40 px-3 py-2 text-[11px] text-foreground-subtle",children:[r("div",{className:"font-semibold text-foreground mb-0.5",children:"Effective config preview"}),u("div",{className:"font-mono truncate",children:[e.id," · model: ",i.modelId," · ",i.enabled?"on":"off"]})]})]})}function na(e){const{mode:t,addon:n,agentDefault:o,agentNodeId:s,currentPatch:a,onChangeAgentConfig:i,onChangePatch:l,engineFormat:c}=e,d=U(()=>n.models.filter(f=>!!f.formats[c]),[n.models,c]);return t==="agent"?r(L5,{addon:n,agentDefault:o,modelsForFormat:d,onChangeAgentConfig:i}):r(T5,{addon:n,agentDefault:o,agentNodeId:s,currentPatch:a,modelsForFormat:d,onChangePatch:l})}function R5(e){const t=[],n=(o,s)=>{for(const a of o)t.push({node:a,depth:s}),n(a.children,s+1)};return n(e,0),t}const Xd={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 O5({slot:e}){const t=Xd[e]??Xd.classifier;return r("span",{className:W("text-[9px] font-semibold uppercase tracking-widest leading-none",t.className),children:t.label})}const Jd="inline-flex items-center rounded bg-muted px-1.5 py-px text-[9px] font-medium text-foreground-subtle";function z5({inputs:e,outputs:t}){return e.length===0&&t.length===0?null:u("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[e.map(n=>r("span",{className:W(Jd,"bg-blue-500/10 text-blue-500"),children:n},`in-${n}`)),e.length>0&&t.length>0&&r("span",{className:"text-foreground-subtle/60 text-[9px]",children:"→"}),t.map(n=>r("span",{className:W(Jd,"bg-emerald-500/10 text-emerald-500"),children:n},`out-${n}`))]})}function B5({enabled:e,onChange:t,disabled:n}){return r("button",{type:"button",role:"switch","aria-checked":e,disabled:n,onClick:o=>{o.stopPropagation(),t(!e)},className:W("relative inline-flex h-3.5 w-7 shrink-0 items-center rounded-full transition-colors",e?"bg-emerald-500":"bg-foreground-subtle/30",n?"opacity-50 cursor-not-allowed":"cursor-pointer"),title:e?"Click to disable":"Click to enable",children:r("span",{className:W("inline-block h-3 w-3 rounded-full bg-white shadow transition-transform",e?"translate-x-3.5":"translate-x-0.5")})})}function F5(e){return e.kind==="enabled"?u("span",{className:"inline-flex items-center gap-1",children:[r("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 shrink-0"}),r("span",{className:"font-mono text-foreground",children:e.modelId})]}):e.kind==="disabled"?u("span",{className:"inline-flex items-center gap-1 text-foreground-subtle",children:[r("span",{className:"h-1.5 w-1.5 rounded-full border border-foreground-subtle/60 shrink-0"}),"off"]}):u("span",{className:"inline-flex items-center gap-1 text-foreground-subtle/70",children:[r("span",{className:"h-1.5 w-1.5 rounded-full bg-muted shrink-0"}),"n/a"]})}function j5({node:e,depth:t,agents:n,getCellState:o,onCellClick:s,selectedCell:a,toggleProps:i}){return u(xe,{children:[u("div",{className:"sticky left-0 z-10 bg-surface px-3 py-2 border-b border-border text-xs flex items-start gap-2",style:{paddingLeft:`${12+t*14}px`},children:[u("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:[r(O5,{slot:e.slot}),u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"font-semibold truncate",children:e.addonName}),r(z5,{inputs:e.inputClasses,outputs:e.outputClasses})]})]}),i&&r("span",{className:"pl-2 pt-0.5 shrink-0",children:r(B5,{enabled:i.enabled,onChange:i.onChange,disabled:i.disabled})})]}),n.map(l=>{const c=o(e.addonId,l.agentNodeId),d=a?.addonId===e.addonId&&a.agentNodeId===l.agentNodeId;return r("button",{type:"button",onClick:()=>s(e.addonId,l.agentNodeId),className:W("text-left px-3 py-1.5 border-b border-l border-border text-xs hover:bg-muted/40",c.kind==="enabled"&&"bg-emerald-500/5",c.kind==="na"&&"bg-muted/30",d&&"ring-2 ring-primary ring-inset"),children:F5(c)},l.agentNodeId)})]})}function Xl({tree:e,agents:t,getCellState:n,onCellClick:o,selectedCell:s,onToggleEnabled:a}){const i=U(()=>R5(e),[e]),l=`minmax(320px, 1fr) repeat(${t.length}, minmax(160px, 220px))`,c=a!==void 0&&t.length===1,d=t[0]?.agentNodeId;return r("div",{className:"overflow-auto border border-border rounded",children:u("div",{className:"grid",style:{gridTemplateColumns:l},children:[r("div",{className:"sticky top-0 left-0 z-20 bg-muted/60 px-3 py-2 text-[10px] uppercase tracking-widest text-foreground-subtle border-b border-border",children:"Step"}),t.map(f=>u("div",{className:"sticky top-0 z-10 bg-muted/60 px-3 py-2 border-b border-l border-border",children:[r("div",{className:"text-xs font-semibold text-foreground",children:f.agentNodeId}),r("div",{className:"text-[10px] text-foreground-subtle truncate",children:f.engineLabel})]},f.agentNodeId)),i.map(({node:f,depth:p})=>{const m=c&&d!==void 0?n(f.addonId,d):null,h=c&&m!==null?{enabled:m.kind==="enabled",onChange:g=>a?.(f.addonId,g),disabled:m.kind==="na"}:void 0;return r(j5,{node:f,depth:p,agents:t,getCellState:n,onCellClick:o,selectedCell:s,toggleProps:h},f.addonId)})]})})}const mh=typeof globalThis<"u"?globalThis.__camstackTrpcReact:void 0,C=mh??nw();typeof globalThis<"u"&&!mh&&(globalThis.__camstackTrpcReact=C);const Jl=cn("camstack:system",null);function ec({system:e,children:t}){return r(Jl.Provider,{value:e,children:t})}function Le(){const e=ve(Jl);if(!e)throw new Error("useSystem(): no <SystemProvider> in tree");return e}function H5(){return ve(Jl)}function ct(e,t){const n=Le(),o=ne(t);o.current=t;const[s,a]=_(n.connectionVersion);Z(()=>n.subscribeConnectionEvents((i,l)=>{i==="connected"&&a(l)}),[n]),Z(()=>n.subscribeEvent(e,l=>{o.current(l)}),[n,e,s])}function Vi(e){const t=ne(e);return t.current=e,t}function Ir(e,t){const[n,o]=_(null),s=Vi(t);return ct(e,a=>{const i=a.data,l=s.current;l&&!l(i)||o(i)}),n}function tc(e,t,n){const[o,s]=_(()=>new Map),a=Vi(t),i=Vi(n);ct(e,c=>{const d=c.data,f=i.current;if(f&&!f(d))return;const p=a.current(d);s(m=>{const h=new Map(m);return h.set(p,d),h})});const l=U(()=>Array.from(o.values()),[o]);return{map:o,values:l}}function Ar(){const{data:e,isLoading:t}=C.nodes.topology.useQuery(void 0,{staleTime:6e4}),o=Ir("cluster.topology-snapshot")?.nodes??e;return{nodes:U(()=>{const a=[];for(const i of o??[])a.push({id:String(i.id??""),name:String(i.name??i.id??""),shortName:i.isHub?"HUB":String(i.name??i.id??""),isHub:!!i.isHub,isOnline:!!i.isOnline,localIps:i.localIps??[],addons:(i.addons??[]).map(l=>({addonId:l.id,capabilities:l.capabilities}))});return a.sort((i,l)=>i.isHub!==l.isHub?i.isHub?-1:1:i.name.localeCompare(l.name)),a},[o]),isLoading:t}}function hh({selectedNodeId:e,onSelect:t,label:n="Node",hideIcon:o=!1,alwaysShow:s=!1}){const{nodes:a}=Ar();return!s&&a.length<=1?null:u("div",{className:"flex items-center gap-1.5",children:[!o&&r($k,{className:"h-3.5 w-3.5 text-foreground-subtle"}),n&&r("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:n}),r("div",{className:"flex rounded-md border border-border overflow-hidden text-[11px] font-medium",children:a.map((i,l)=>{const c=e===i.id;return r("button",{type:"button",onClick:()=>t(i.id),disabled:!i.isOnline,title:i.isOnline?i.name:`${i.name} (offline)`,className:W("px-2.5 py-1 transition-colors",c?"bg-primary/15 text-primary":"bg-transparent text-foreground-subtle hover:bg-surface-hover hover:text-foreground",l>0&&"border-l border-border",!i.isOnline&&"opacity-50 cursor-not-allowed"),children:i.shortName},i.id)})})]})}const V5={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 q5({status:e,showDot:t=!0,showLabel:n=!0,size:o="sm",className:s}){const a=V5[e];return u("span",{className:W("inline-flex items-center gap-1.5",o==="sm"?"text-xs":"text-sm",s),children:[t&&r("span",{className:W("h-1.5 w-1.5 shrink-0 rounded-full",a.colorClass),"aria-hidden":"true"}),n&&r("span",{className:"text-foreground",children:a.label})]})}const Q5={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 U5({provider:e,showLabel:t=!0,className:n}){const o=Q5[e];return u("span",{className:W("inline-flex items-center gap-1.5 text-xs",n),children:[r("span",{className:W("h-1.5 w-1.5 shrink-0 rounded-sm",o.colorClass),"aria-hidden":"true"}),t&&r("span",{className:"text-foreground",children:o.label})]})}const K5={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 gh({children:e,variant:t="neutral",mono:n,className:o}){return r("span",{className:W("inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-bold leading-tight",n&&"font-mono",K5[t],o),children:e})}function G5({version:e,preRelease:t,className:n}){const o=t??/-(alpha|beta|rc|dev|canary|next)/i.test(e);return r(gh,{variant:o?"warning":"success",mono:!0,className:n,children:e})}function W5({label:e,description:t,error:n,required:o,children:s,orientation:a="vertical",className:i}){const l=a==="horizontal";return u("div",{className:W("flex gap-2",l?"flex-row items-center justify-between":"flex-col",i),children:[u("div",{className:W(l?"flex-1":""),children:[u(Hl,{children:[e,o&&r("span",{className:"text-danger ml-0.5",children:"*"})]}),t&&r("p",{className:"text-foreground-subtle text-xs mt-0.5",children:t})]}),r("div",{className:W(l?"shrink-0":""),children:s}),n&&r("p",{className:"text-danger text-xs",children:n})]})}function Y5({title:e,subtitle:t,actions:n,className:o}){return u("div",{className:W("flex flex-col gap-2 mb-3 sm:flex-row sm:items-center sm:justify-between",o),children:[u("div",{children:[r("h1",{className:"text-sm font-semibold text-foreground",children:e}),t&&r("p",{className:"text-foreground-subtle text-xs",children:t})]}),n&&r("div",{className:"flex items-center gap-2 flex-wrap",children:n})]})}function bh({icon:e,title:t,description:n,action:o,className:s}){return u("div",{className:W("flex flex-col items-center justify-center gap-3 py-12",s),children:[e&&r(e,{className:"h-12 w-12 text-foreground-subtle","aria-hidden":"true"}),u("div",{className:"flex flex-col items-center gap-1 text-center",children:[r("p",{className:"text-foreground-muted text-sm font-medium",children:t}),n&&r("p",{className:"text-foreground-subtle text-xs max-w-xs",children:n})]}),o&&r("div",{className:"mt-1",children:o})]})}const xh=cn("camstack:confirm-dialog",null);function nt(){const e=ve(xh);if(!e)throw new Error("useConfirm must be used within ConfirmDialogProvider");return e.confirm}function yh({children:e}){const[t,n]=_(null),o=q(c=>new Promise(d=>{n({...c,resolve:d})}),[]),s=()=>{t?.resolve(!0),n(null)},a=()=>{t?.resolve(!1),n(null)},i={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600 text-white"},warning:{icon:"text-orange-400",button:"bg-orange-500 hover:bg-orange-600 text-white"},default:{icon:"text-primary",button:"bg-primary hover:bg-primary/90 text-white"}},l=t?i[t.variant??"default"]:i.default;return u(xh.Provider,{value:{confirm:o},children:[e,t&&u("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[r("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:a}),u("div",{className:"relative z-10 w-full max-w-sm mx-4 rounded-xl border border-border bg-surface shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-150",onClick:c=>c.stopPropagation(),children:[u("div",{className:"px-5 pt-5 pb-4",children:[r("h3",{className:"text-sm font-semibold text-foreground",children:t.title}),r("p",{className:"mt-2 text-xs text-foreground-subtle leading-relaxed",children:t.message})]}),u("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border bg-surface-hover/30",children:[r("button",{type:"button",onClick:a,className:"px-3 py-1.5 text-xs font-medium rounded-md border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:t.cancelLabel??"Cancel"}),r("button",{type:"button",onClick:s,className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${l.button}`,children:t.confirmLabel??"Confirm"})]})]})]})]})}function Z5({value:e,label:t,trend:n,className:o}){return u(en,{className:W("flex flex-col gap-1",o),children:[u("div",{className:"flex items-baseline gap-2",children:[r("span",{className:"text-2xl font-semibold text-foreground",children:e}),n&&u("span",{className:W("inline-flex items-center gap-0.5 text-xs font-medium",n.direction==="up"?"text-success":"text-danger"),children:[n.direction==="up"?r(Zk,{className:"h-3 w-3"}):r(Jk,{className:"h-3 w-3"}),n.value,"%"]})]}),r("span",{className:"text-xs text-foreground-muted",children:t})]})}function X5({items:e,className:t}){return r("dl",{className:W("flex flex-col",t),children:e.map(n=>u("div",{className:"flex items-center h-7",children:[r("dt",{className:"text-foreground-subtle text-xs w-1/3 shrink-0",children:n.key}),r("dd",{className:"text-foreground text-xs",children:n.value})]},n.key))})}function J5({children:e,maxHeight:t=300,className:n}){const[o,s]=_(!1),a=q(()=>{navigator.clipboard.writeText(e).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})},[e]);return u("div",{className:W("relative group",n),children:[r(Gl,{style:{maxHeight:t},children:r("pre",{className:"font-mono text-xs bg-surface p-3 rounded-md border border-border-subtle",children:r("code",{children:e})})}),r("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:r(jl,{icon:o?wo:Cn,"aria-label":"Copy code",variant:"ghost",size:"sm",onClick:a})})]})}function eS({filters:e,values:t,onChange:n,className:o}){const s=Zn(),[a,i]=_(!1),l=(d,f)=>{n({...t,[d]:f})},c=Object.values(t).filter(d=>d!==void 0&&d!=="").length;if(s){const d=e.find(p=>p.type==="search"),f=e.some(p=>p.type!=="search");return u("div",{className:W("flex items-center gap-2",o),children:[d&&r(Ss,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:p=>l(d.key,p.target.value),leftSlot:r(ro,{className:"h-3 w-3 text-foreground-subtle"}),className:"flex-1"}),f&&u(xe,{children:[u("button",{onClick:()=>i(!0),className:"flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-foreground-muted hover:bg-surface-hover transition-colors shrink-0",children:[r(Ok,{className:"h-3.5 w-3.5"}),"Filters",c>0&&r(lr,{variant:"info",className:"ml-1 text-[10px] px-1 py-0",children:c})]}),r(Kl,{open:a,onClose:()=>i(!1),title:"Filters",children:r("div",{className:"flex flex-col gap-3",children:e.filter(p=>p.type!=="search").map(p=>{switch(p.type){case"select":return u("div",{children:[r("label",{className:"text-xs text-foreground-muted mb-1 block",children:p.label}),r(Cs,{options:p.options,value:t[p.key]??"",onChange:m=>l(p.key,m.target.value),className:"w-full"})]},p.key);case"badge-toggle":return r("div",{className:"flex items-center gap-1 flex-wrap",children:p.options.map(m=>{const g=t[p.key]===m.value;return r("button",{type:"button",onClick:()=>l(p.key,g?void 0:m.value),children:r(lr,{variant:g?"info":"default",className:"cursor-pointer",children:m.label})},m.value)})},p.key);default:return null}})})})]})]})}return r("div",{className:W("flex items-center gap-2 flex-wrap",o),children:e.map(d=>{switch(d.type){case"search":return r(Ss,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:f=>l(d.key,f.target.value),leftSlot:r(ro,{className:"h-3 w-3 text-foreground-subtle"}),className:"w-48"},d.key);case"select":return r(Cs,{options:d.options,value:t[d.key]??"",onChange:f=>l(d.key,f.target.value),className:"w-36"},d.key);case"badge-toggle":return r("div",{className:"flex items-center gap-1",children:d.options.map(f=>{const m=t[d.key]===f.value;return r("button",{type:"button",onClick:()=>l(d.key,m?void 0:f.value),children:r(lr,{variant:m?"info":"default",className:"cursor-pointer",children:f.label})},f.value)})},d.key);default:return null}})})}function qi({label:e,icon:t,href:n,badge:o,active:s=!1,className:a}){return u("a",{href:n,className:W("flex items-center gap-2 h-7 px-2 text-[11px] transition-colors",s?"border-l-2 border-primary bg-primary/[0.08] text-foreground rounded-r-md":"text-foreground-subtle hover:bg-surface-hover rounded-md",a),children:[r(t,{className:"h-3.5 w-3.5 shrink-0"}),r("span",{className:"truncate flex-1",children:e}),o!==void 0&&r(lr,{className:"ml-auto text-[10px] px-1.5 py-0",children:o})]})}function Qi({logo:e,sections:t,footer:n,onNavigate:o,className:s}){return u("nav",{className:W("bg-surface border-r border-border h-full flex flex-col",s),children:[e&&r("div",{className:"px-3 py-2 shrink-0",children:e}),r("div",{className:"flex-1 overflow-auto px-1 py-1",children:t.map((a,i)=>u("div",{className:W(i>0?"mt-3":""),children:[a.label&&r("span",{className:"text-[10px] text-foreground-disabled uppercase tracking-wider px-2 mb-1 block",children:a.label}),r("div",{className:"flex flex-col gap-0.5",onClick:o,children:a.items.map(l=>r(qi,{...l},l.href))})]},i))}),n&&n.length>0&&u("div",{className:"shrink-0 px-1 pb-1",children:[r(Vl,{className:"mb-1"}),r("div",{className:"flex flex-col gap-0.5",onClick:o,children:n.map(a=>r(qi,{...a},a.href))})]})]})}function tS({sidebar:e,header:t,mobileLogo:n,mobileActions:o,children:s,className:a}){const i=Zn(),[l,c]=_(!1);return u("div",{className:W("flex h-screen",a),children:[!i&&r(Qi,{...e,className:W("w-44",e.className)}),i&&r(Wl,{open:l,onClose:()=>c(!1),width:"w-64",children:r(Qi,{...e,onNavigate:()=>c(!1),className:"w-full border-r-0"})}),u("div",{className:"flex flex-1 flex-col min-w-0",children:[i&&u("header",{className:"flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm",children:[r("button",{onClick:()=>c(!0),className:"p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors","aria-label":"Open menu",children:r(rk,{className:"h-5 w-5"})}),n&&r("div",{className:"flex-1 flex justify-center",children:n}),o&&r("div",{className:"shrink-0",children:o})]}),!i&&t&&u("header",{className:"flex items-center h-10 border-b border-border px-4 shrink-0",children:[t.breadcrumbs&&t.breadcrumbs.length>0&&r("nav",{className:"flex items-center gap-1 text-xs flex-1 min-w-0",children:t.breadcrumbs.map((d,f)=>{const p=f===t.breadcrumbs.length-1;return u("span",{className:"flex items-center gap-1",children:[f>0&&r(Sn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),d.href&&!p?r("a",{href:d.href,className:"text-foreground-subtle hover:text-foreground transition-colors truncate",children:d.label}):r("span",{className:"text-foreground truncate",children:d.label})]},f)})}),t.actions&&r("div",{className:"flex items-center gap-2 ml-auto shrink-0",children:t.actions})]}),r("main",{className:"flex-1 overflow-auto p-4",children:s})]})]})}const nS={online:"bg-success",offline:"bg-danger",warning:"bg-warning",unknown:"bg-foreground-subtle"};function rS({title:e,subtitle:t,status:n,selected:o,onClick:s,badges:a,actions:i,offlineAction:l,className:c}){const d=n==="offline";return u("div",{onClick:s,className:W("w-full rounded-lg border p-3 text-left transition-colors",s&&"cursor-pointer",o?"border-primary bg-primary/10":"border-border bg-surface hover:bg-surface-hover",d&&!o&&"opacity-50",c),children:[u("div",{className:"flex items-center justify-between mb-2",children:[r("span",{className:"text-sm font-medium truncate",children:e}),n&&r("span",{className:W("h-2 w-2 rounded-full shrink-0",nS[n])})]}),t&&r("div",{className:"text-[11px] text-foreground-muted",children:t}),a&&a.length>0&&r("div",{className:"flex flex-wrap gap-1 mt-2",children:a.map((f,p)=>{const m=W("rounded px-1.5 py-0.5 text-[10px] flex items-center gap-0.5",o?"bg-primary/20":"bg-surface-hover",f.onClick&&"hover:opacity-80 transition-opacity cursor-pointer");return f.onClick?u("button",{onClick:h=>{h.stopPropagation(),f.onClick()},className:m,children:[f.icon,f.label]},p):u("span",{className:m,children:[f.icon,f.label]},p)})}),!d&&i&&i.length>0&&r("div",{className:"flex items-center gap-0.5 mt-2 -mb-1",children:i.map((f,p)=>r("button",{onClick:m=>{m.stopPropagation(),f.onClick()},className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",title:f.label,"aria-label":f.label,children:f.icon},p))}),d&&l&&r("div",{className:"mt-2",onClick:f=>f.stopPropagation(),children:l})]})}function oS({children:e,minCardWidth:t=220,gap:n=3,className:o}){return r("div",{className:W("p-4 overflow-y-auto flex-1 content-start",o),style:{display:"grid",gridTemplateColumns:`repeat(auto-fill, minmax(${t}px, 1fr))`,gap:`${n*4}px`},children:e})}const sS="capability.binding-changed";function St(e,t){const[n,o]=_(null);return Z(()=>{if(t===null){o(null);return}let s=!1;const a=async()=>{try{const l=await e.deviceManager.getBindings.query({deviceId:t});s||o(l)}catch{s||o(l=>l)}};a();const i=e.live?.onEvent.subscribe({category:sS},{onData:l=>{const c=l.data?.source;if(!c){a();return}c.type==="device"&&c.id===t&&a()}});return()=>{s=!0,i?.unsubscribe()}},[e,t]),U(()=>n?rw(e,n):null,[e,n])}function nn(e){const t=q(o=>e?e.subscribe(()=>o()):()=>{},[e]),n=q(()=>e?.value,[e]);return Ws(t,n,n)}function vh(e,t,n){const o=St(e,t),s=o?n(o.state):void 0;return nn(s)}function Pr(e){const t=St(e.trpc,e.deviceId),n=t!==null?e.slice(t):void 0,o=nn(n),s=t!==null?e.cap(t):void 0,c=(e.requireFeature===void 0||(e.deviceFeatures??[]).includes(e.requireFeature))&&s!==void 0&&o!==void 0;return{dev:t,cap:s,slice:o,available:c}}function aS(e){return e.parentDeviceId===null?"top-level":e.role?"accessory":"adopted"}const iS={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 lS(e){const t=iS[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 cS={siren:Ys,floodlight:Im,spotlight:Dm,"pir-sensor":Em,chime:ck,autotrack:vm,nightvision:zl,"privacy-mask":Sm,doorbell:wm},dS={camera:Ol,hub:Fi,nvr:Fi,light:Im,siren:Ys,switch:Gk,sensor:Em,thermostat:Uk,button:b2,generic:Fl};function wh(e){return e.role?cS[e.role]??Fl:dS[e.type.toLowerCase()]??Ol}const Nh={"native-snapshot":q2,"two-way-audio":Am,"pan-tilt-zoom":vm,"ptz-autotrack":ek,"doorbell-button":wm,"motion-trigger":xn,"battery-operated":xm,rebootable:_m},kh={"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"},uS={"native-snapshot":"snapshot",rebootable:"reboot","pan-tilt-zoom":"ptz","ptz-autotrack":"ptz-autotrack","two-way-audio":"intercom","motion-trigger":"motion-trigger"},Sh=new Set(["camera","hub","nvr"]);function Ch(e){return!Sh.has(e.type.toLowerCase())}function eu(e){return e.role?!0:!Sh.has(e.type.toLowerCase())}function Mh(e){return(e.features??[]).includes("motion-trigger")}function pS(e){if(e.length<=24)return e;const t=e.lastIndexOf(":");if(t>=0&&t<e.length-4)return e.slice(t+1);const n=e.split("-");if(n.length>2){const o=n.slice(-2).join("-");if(o.length>=6)return o}return`…${e.slice(-18)}`}function fS({trpc:e,accessoryChildren:t,adoptedChildren:n,onNavigate:o}){return u("div",{className:"border-t border-border-subtle/50",children:[n.length>0&&r(tu,{trpc:e,label:"Adopted devices",rows:n,onNavigate:o}),t.length>0&&r(tu,{trpc:e,label:"Accessories",rows:t,onNavigate:o})]})}function tu({trpc:e,label:t,rows:n,onNavigate:o}){return u("div",{children:[r("div",{className:"px-3 pt-1.5 pb-1 text-[9px] font-semibold uppercase tracking-wide text-foreground-subtle",children:t}),r("ul",{children:n.map(s=>r(mS,{trpc:e,child:s,onNavigate:o},s.id))})]})}function mS({trpc:e,child:t,onNavigate:n}){const o=!t.disabled,s=o&&Ch(t),a=o&&Mh(t),i=wh(t);return r("li",{children:u("div",{onClick:l=>{l.stopPropagation(),n(t.id)},className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-surface-hover transition-colors cursor-pointer",children:[r(i,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),r("span",{className:"text-[10.5px] text-foreground flex-1 truncate",children:t.name}),a&&r(gS,{trpc:e,deviceId:t.id,features:t.features}),s&&r(hS,{trpc:e,deviceId:t.id}),r("span",{className:W("h-1.5 w-1.5 rounded-full flex-shrink-0",t.online?"bg-success":"bg-foreground-subtle/40"),title:t.online?"Online":"Offline"})]})})}function hS({trpc:e,deviceId:t}){const{dev:n,cap:o,slice:s,available:a}=Pr({trpc:e,deviceId:t,cap:p=>p.switch,slice:p=>p.state.switch}),[i,l]=_(!1);if(n!==null&&!o)return null;const c=s?.on===!0,d={transform:c?"translateX(14px)":"translateX(2px)"},f=async p=>{if(p.stopPropagation(),!(i||!a||!o)){l(!0);try{await o.setState({on:!c})}finally{l(!1)}}};return r("button",{type:"button",onClick:p=>{f(p)},disabled:i||!a,className:W("relative inline-flex h-4 w-7 items-center rounded-full border transition-colors flex-shrink-0",c?"bg-success/30 border-success/50":"bg-surface-hover border-border",i&&"opacity-60",!a&&"opacity-40 cursor-not-allowed"),title:a?c?"Turn off":"Turn on":"Awaiting state…","aria-pressed":c,children:r("span",{className:W("absolute h-3 w-3 rounded-full transition-all",c?"bg-success":"bg-foreground-subtle"),style:d})})}function gS({trpc:e,deviceId:t,features:n}){const{dev:o,cap:s,slice:a,available:i}=Pr({trpc:e,deviceId:t,cap:p=>p.motionTrigger,slice:p=>p.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:n}),[l,c]=_(!1);if(o!==null&&!s)return null;const d=a?.enabled===!0,f=async p=>{if(p.stopPropagation(),!(l||!i||!s)){c(!0);try{await s.setMotionTrigger({enabled:!d})}finally{c(!1)}}};return r("button",{type:"button",onClick:p=>{f(p)},disabled:l||!i,className:W("inline-flex h-4 w-4 items-center justify-center rounded transition-colors flex-shrink-0",d?"text-primary bg-primary/10":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover",(l||!i)&&"opacity-50"),title:i?d?"Motion-trigger: on (click to disable)":"Motion-trigger: off (click to enable)":"Awaiting state…","aria-pressed":d,children:r(xn,{className:"h-2.5 w-2.5"})})}function Ih({trpc:e,device:t,flags:n}){if(!!t.disabled)return null;const s=t.type.toLowerCase(),a=n.showSwitchToggle&&Ch(t),i=Mh(t),l=s==="hub"||s==="nvr",c=(t.features??[]).includes("rebootable"),d=l&&c;return u(xe,{children:[i&&r(xS,{trpc:e,deviceId:t.id,features:t.features}),a&&r(bS,{trpc:e,deviceId:t.id}),d&&r(vS,{trpc:e,deviceId:t.id})]})}function bS({trpc:e,deviceId:t}){const{dev:n,cap:o,slice:s,available:a}=Pr({trpc:e,deviceId:t,cap:p=>p.switch,slice:p=>p.state.switch}),[i,l]=_(!1);if(n!==null&&!o)return null;const c=s?.on===!0,d={transform:c?"translateX(14px)":"translateX(2px)"},f=async p=>{if(p.stopPropagation(),!(i||!a||!o)){l(!0);try{await o.setState({on:!c})}finally{l(!1)}}};return r("button",{type:"button",onClick:p=>{f(p)},disabled:i||!a,className:W("relative inline-flex h-4 w-7 items-center rounded-full border transition-colors flex-shrink-0",c?"bg-success/30 border-success/50":"bg-surface-hover border-border",i&&"opacity-60",!a&&"opacity-40 cursor-not-allowed"),title:a?c?"Turn off":"Turn on":"Awaiting state…","aria-pressed":c,children:r("span",{className:W("absolute h-3 w-3 rounded-full transition-all",c?"bg-success":"bg-foreground-subtle"),style:d})})}function xS({trpc:e,deviceId:t,features:n}){const{dev:o,cap:s,slice:a,available:i}=Pr({trpc:e,deviceId:t,cap:p=>p.motionTrigger,slice:p=>p.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:n}),[l,c]=_(!1);if(o!==null&&!s)return null;const d=a?.enabled===!0,f=async p=>{if(p.stopPropagation(),!(l||!i||!s)){c(!0);try{await s.setMotionTrigger({enabled:!d})}finally{c(!1)}}};return r("button",{type:"button",onClick:p=>{f(p)},disabled:l||!i,className:W("inline-flex h-4 w-4 items-center justify-center rounded transition-colors flex-shrink-0",d?"text-primary bg-primary/10":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover",(l||!i)&&"opacity-50"),title:i?d?"Motion-trigger: on (click to disable)":"Motion-trigger: off (click to enable)":"Awaiting state…","aria-pressed":d,children:r(xn,{className:"h-2.5 w-2.5"})})}const Va=168,yS=4;function vS({trpc:e,deviceId:t}){const{dev:n,cap:o}=Pr({trpc:e,deviceId:t,cap:x=>x.reboot,slice:()=>{}}),s=ne(null),a=ne(null),[i,l]=_(null),[c,d]=_(!1),f=n!==null&&o!==void 0&&o!==null,p=i!==null,m=()=>l(null),h=()=>{const x=s.current;if(!x)return;const v=x.getBoundingClientRect(),w=v.right-Va,y=Math.max(8,Math.min(w,window.innerWidth-Va-8)),N=v.bottom+yS;l({top:N,left:y})};if(Z(()=>{if(!p)return;const x=w=>{const y=s.current,N=a.current,k=w.target;k!==null&&(y&&y.contains(k)||N&&N.contains(k)||m())},v=w=>{w.key==="Escape"&&(w.stopPropagation(),m())};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v)}},[p]),n!==null&&!o)return null;const g=x=>{x.stopPropagation(),p?m():h()},b=async()=>{if(!(c||!f||!o)){d(!0),m();try{await o.reboot({})}finally{d(!1)}}};return u(xe,{children:[r("button",{ref:s,type:"button",onClick:g,disabled:c||!f,className:W("inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors flex-shrink-0",(c||!f)&&"opacity-50",p&&"bg-surface-hover text-foreground"),title:"More actions","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":p,children:r(Nm,{className:"h-3 w-3"})}),i&&vo(r("div",{ref:a,role:"menu",style:{position:"fixed",top:i.top,left:i.left,width:Va},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-1",onClick:x=>x.stopPropagation(),children:u("button",{type:"button",role:"menuitem",onClick:()=>{b()},disabled:c||!f,className:W("flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-[11px] text-foreground","hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed"),children:[r(_m,{className:"h-3 w-3 shrink-0 text-foreground-subtle"}),r("span",{children:"Reboot device"})]})}),document.body)]})}const wS=Object.freeze([]);function NS(e){return e==="native"?"native":"enhanced"}function kS(e){return e.map(t=>({kind:"marker",feature:t}))}function SS(e,t){const n=new Map,o=t.entries??[];for(const a of o)n.set(a.capName,a);const s=[];for(const a of e){const i=uS[a];if(i===void 0){s.push({kind:"marker",feature:a});continue}const l=n.get(i);l&&s.push({kind:NS(l.kind),feature:a,capName:i})}return s}function CS(e,t,n){const[o,s]=_(null),[a,i]=_(!1),[l,c]=_(!0);return Z(()=>{if(t===null){s(null),i(!1),c(!1);return}let d=!1;c(!0),i(!1);const f=async()=>{try{const m=await e.deviceManager.getBindings.query({deviceId:t});if(d)return;s(m),c(!1)}catch{if(d)return;i(!0),c(!1)}};f();const p=e.live?.onEvent.subscribe({category:"capability.binding-changed"},{onData:m=>{const h=m.data?.source;if(!h){f();return}h.type==="device"&&h.id===t&&f()}});return()=>{d=!0,p?.unsubscribe()}},[e,t]),n.length===0?{loading:l,resolved:wS}:l||a||!o?{loading:l,resolved:kS(n)}:{loading:!1,resolved:SS(n,o)}}const MS=[];function Ah({trpc:e,device:t,flags:n,accessoryCount:o,adoptedCount:s,showFeatureRow:a=!1}){const i=o+s,l=n.showChildrenAccordion&&i>0,c=t.features??MS,d=a&&c.length>0,{resolved:f}=CS(e,d?t.id:null,c),p=d&&f.length>0;return!l&&!p?null:u("div",{className:"flex items-center gap-1.5 flex-nowrap whitespace-nowrap min-w-0",children:[l&&r(IS,{accessoryCount:o,adoptedCount:s}),p&&r(AS,{resolved:f})]})}function IS({accessoryCount:e,adoptedCount:t}){const n=e+t;if(n===0)return null;const o=t>0&&e>0?`${String(t)} adopted · ${String(e)} accessor${e===1?"y":"ies"}`:t>0?`${String(t)} adopted`:`${String(e)} accessor${e===1?"y":"ies"}`;return u("span",{className:"text-[9px] font-medium text-foreground-subtle bg-surface-elevated/60 rounded px-1.5 py-0.5 flex-shrink-0",title:o,children:["+",n]})}const Ph=240,nu=200;function AS({resolved:e}){const t=ne(null),[n,o]=_(null);return u("span",{ref:t,className:"relative inline-flex items-center gap-1 cursor-help",onMouseEnter:()=>{const i=t.current;if(!i)return;const l=i.getBoundingClientRect(),f=window.innerHeight-l.bottom>=nu?l.bottom+4:l.top-nu-4,p=Math.max(8,Math.min(l.left,window.innerWidth-Ph-8));o({top:f,left:p})},onMouseLeave:()=>o(null),children:[e.map(i=>{const l=Nh[i.feature];return l?r("span",{className:"inline-flex items-center justify-center h-4 w-4 rounded bg-surface-elevated/60 text-foreground-subtle",title:kh[i.feature]??i.feature,children:r(l,{className:"h-2.5 w-2.5"})},i.feature):null}),n&&vo(r(PS,{resolved:e,position:n}),document.body)]})}function PS({resolved:e,position:t}){return u("div",{style:{position:"fixed",top:t.top,left:t.left,width:Ph,pointerEvents:"none"},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-2",children:[r("h5",{className:"text-[9px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5",children:"Features"}),r("ul",{className:"space-y-0.5",children:e.map(n=>r(ES,{entry:n},n.feature))})]})}function ES({entry:e}){const t=Nh[e.feature],n=kh[e.feature]??e.feature;return u("li",{className:"flex items-center justify-between gap-2 text-[10px]",children:[u("span",{className:"flex items-center gap-1.5 text-foreground",children:[t&&r(t,{className:"h-3 w-3 text-foreground-subtle"}),r("span",{children:n})]}),r($S,{kind:e.kind})]})}function $S({kind:e}){return e==="marker"?r("span",{className:"text-[8.5px] px-1 rounded text-foreground-subtle",title:"Informational marker (no cap registered)",children:"marker"}):r("span",{className:W("text-[8.5px] px-1 rounded",e==="native"?"bg-success/15 text-success":"bg-primary/15 text-primary"),children:e})}function Eh({device:e,variant:t,flags:n,parent:o,integrationIcon:s,hasChildren:a,expanded:i,onToggleExpand:l,onNavigateToParent:c}){const d=wh(e);return u("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[n.showChildrenAccordion&&a?r("button",{type:"button",onClick:f=>{f.stopPropagation(),l()},className:"flex h-3.5 w-3.5 items-center justify-center text-foreground-subtle hover:text-foreground transition-colors flex-shrink-0","aria-label":i?"Collapse children":"Expand children","aria-expanded":i,children:i?r(Wn,{className:"h-3 w-3"}):r(Sn,{className:"h-3 w-3"})}):n.showChildrenAccordion?r("span",{className:"h-3.5 w-3.5 flex-shrink-0"}):null,r(d,{className:W("text-foreground-subtle flex-shrink-0",t==="minimal"?"h-3 w-3":"h-3.5 w-3.5")}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.showIntegrationIcon&&s&&r("span",{className:"flex-shrink-0",children:s}),r("span",{className:W("font-semibold text-foreground truncate",t==="minimal"?"text-[10.5px]":"text-[11px]"),title:e.name,children:e.name})]}),(n.showId||n.showStableId)&&u("div",{className:"mt-0.5 flex items-center gap-1 text-[9px] text-foreground-subtle font-mono truncate",title:n.showStableId?`stableId: ${e.stableId}`:void 0,children:[n.showId&&u("span",{className:"flex-shrink-0 tabular-nums",children:["#",String(e.id)]}),n.showId&&n.showStableId&&r("span",{className:"flex-shrink-0 opacity-50",children:"·"}),n.showStableId&&r("span",{className:"truncate",children:pS(e.stableId)})]}),n.showParentBadge&&o&&u("button",{type:"button",onClick:f=>{f.stopPropagation(),c(o.id)},className:"mt-0.5 inline-flex max-w-full items-center gap-1 text-[9px] text-foreground-subtle hover:text-primary transition-colors",title:`Open parent: ${o.name} (#${String(o.id)})`,children:[r(Fi,{className:"h-2.5 w-2.5 shrink-0"}),u("span",{className:"truncate",children:["Under: ",o.name]})]})]})]})}function nc(e,t){return vh(e,t,o=>o.battery)??null}function rc(e,t){const n=St(e,t),o=ne(!1),{data:s,isLoading:a,isFetching:i,refetch:l}=Un({queryKey:["device",t,"snapshot"],queryFn:()=>{if(!n)throw new Error("useDeviceSnapshotImage: device proxy not ready");const f=o.current;return o.current=!1,n.snapshot?.getSnapshot({force:f})??null},enabled:n!==null&&t!==null,staleTime:1e4,gcTime:1440*60*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:!1}),c=s?`data:${s.contentType};base64,${s.base64}`:null;function d(){o.current=!0,l()}return{src:c,loading:a||i,refresh:d}}function _S(e){return e<=10?YN:e<=30?GN:e>=95?UN:xm}function DS(e,t){return t!=="none"?"text-emerald-400":e<=10?"text-rose-400":e<=30?"text-amber-400":"text-foreground-subtle"}function oc({status:e,variant:t="compact",className:n}){if(!e)return null;const o=_S(e.percentage),s=DS(e.percentage,e.charging),a=e.charging==="solar"?Dm:e.charging==="dc"?mk:null,i=e.sleeping;return u("span",{className:W("inline-flex items-center gap-1 text-[10px] font-medium",s,n),title:`Battery: ${Math.round(e.percentage)}%`+(e.charging!=="none"?` · charging (${e.charging})`:"")+(e.sleeping?" · sleeping":""),children:[r(o,{className:"h-3.5 w-3.5"}),u("span",{children:[Math.round(e.percentage),"%"]}),a&&r(a,{className:"h-3 w-3"}),i&&r(zl,{className:"h-3 w-3 text-blue-300"}),t==="full"&&e.charging!=="none"&&r("span",{className:"text-foreground-subtle",children:e.charging})]})}function $h({trpc:e,device:t,status:n,enabled:o,showStatusPills:s=!1}){const a=o&&t.online,i=rc(e,a?t.id:null),l=(t.features??[]).includes("battery-operated"),c=s&&l&&!t.disabled,d=nc(e,c?t.id:null);return!o&&!c?null:u("span",{className:"inline-flex items-center gap-1.5 flex-nowrap whitespace-nowrap",children:[c&&d&&r(oc,{status:d}),o&&r(LS,{deviceName:t.name,snapshotUrl:i.src,status:n})]})}const qa=288,ru=196,Qa=8;function LS({deviceName:e,snapshotUrl:t,status:n}){const o=ne(null),[s,a]=_(null),i=n==="offline"||n==="disabled",l=()=>{const d=o.current;if(!d)return;const f=d.getBoundingClientRect(),p=f.top,m=window.innerHeight-f.bottom,h=p<ru+Qa&&m>p,g=h?f.bottom+Qa:f.top-ru-Qa,b=f.right-qa,x=Math.max(8,Math.min(b,window.innerWidth-qa-8));a({top:g,left:x,placeBelow:h})},c=()=>a(null);return u(xe,{children:[r("button",{ref:o,type:"button",onClick:d=>d.stopPropagation(),onMouseEnter:l,onMouseLeave:c,onFocus:l,onBlur:c,className:"flex h-6 w-6 items-center justify-center rounded text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors flex-shrink-0",title:"Preview","aria-label":"Preview snapshot",children:r(Xs,{className:"h-3.5 w-3.5"})}),s&&vo(u("div",{style:{position:"fixed",top:s.top,left:s.left,width:qa,pointerEvents:"none"},className:"rounded-lg border border-border bg-surface shadow-lg shadow-black/30 z-[9999] overflow-hidden",children:[r("div",{className:"h-40 bg-background flex items-center justify-center",children:t&&!i?r("img",{src:t,alt:e,className:"h-full w-full object-cover"}):r("span",{className:"text-xs text-foreground-subtle",children:n==="offline"?"Offline — no snapshot":n==="disabled"?"Disabled":"No snapshot yet"})}),r("div",{className:"px-3 py-2",children:r("p",{className:"text-xs font-semibold text-foreground truncate",children:e})})]}),document.body)]})}function _h({status:e}){const t=e==="disabled"?"bg-warning":e==="online"?"bg-success":"bg-danger",n=e==="disabled"?"Disabled":e==="online"?"Online":"Offline";return r("span",{className:W("h-1.5 w-1.5 rounded-full flex-shrink-0",t),title:n})}function oo(e){const{trpc:t,device:n,parent:o,integrationIcon:s,onNavigate:a,className:i}=e,l=lS(e),c=e.variant??"compact",d=e.view??"card",f=!n.disabled,p=n.isCamera??n.type.toLowerCase()==="camera",m=e.children??[],h=m.filter(eu),g=m.filter(M=>!eu(M)),b=m.length>0,[x,v]=_(!1),w=e.expanded??x,y=e.onToggleExpand??(()=>v(M=>!M)),N=M=>{a?.(M)},k=e.indentLevel??(e.isAccessoryRow?2:0),S=f?n.online?"online":"offline":"disabled";return d==="table"?r(RS,{trpc:t,device:n,variant:c,flags:l,parent:o??null,integrationIcon:s??null,accessoryCount:h.length,adoptedCount:g.length,hasChildren:b,expanded:w,onToggleExpand:y,onNavigate:N,displayStatus:S,isCamera:p,showSnapshot:l.showSnapshot&&p,isAccessoryRow:e.isAccessoryRow??!1,indentLevel:k,className:i}):u("div",{className:W("rounded-lg border border-border bg-surface transition-colors",!f&&"opacity-60",i),children:[u("div",{onClick:()=>N(n.id),className:W("flex items-center gap-2 cursor-pointer hover:border-foreground-subtle/30 w-full",c==="minimal"?"px-2.5 py-1.5":"px-3 py-2.5"),children:[r(Eh,{device:n,variant:c,flags:l,parent:o??null,integrationIcon:s??null,hasChildren:b,expanded:w,onToggleExpand:y,onNavigateToParent:N}),r(Ah,{trpc:t,device:n,flags:l,accessoryCount:h.length,adoptedCount:g.length,showFeatureRow:!1}),r($h,{trpc:t,device:n,status:S,enabled:l.showSnapshot&&p,showStatusPills:!0}),r(Ih,{trpc:t,device:n,flags:l}),r(_h,{status:S})]}),w&&b&&r(fS,{trpc:t,accessoryChildren:h,adoptedChildren:g,onNavigate:N})]})}const TS={0:"pl-2",1:"pl-6",2:"pl-8"};function RS(e){const{trpc:t,device:n,variant:o,flags:s,parent:a,integrationIcon:i,accessoryCount:l,adoptedCount:c,hasChildren:d,expanded:f,onToggleExpand:p,onNavigate:m,displayStatus:h,isCamera:g,showSnapshot:b,isAccessoryRow:x,indentLevel:v,className:w}=e;return u("tr",{onClick:()=>m(n.id),className:W("cursor-pointer hover:bg-surface-hover transition-colors",!s.showChildrenAccordion&&"border-b border-border-subtle/40",x&&"bg-foreground-subtle/[0.03]",w),children:[r("td",{className:W("py-2 align-middle pr-2",TS[v]),children:r(Eh,{device:n,variant:o,flags:s,parent:a,integrationIcon:i,hasChildren:d,expanded:f,onToggleExpand:p,onNavigateToParent:m})}),r("td",{className:"px-2 py-2 align-middle text-[10px] text-foreground-subtle whitespace-nowrap",children:n.type}),r("td",{className:"px-2 py-2 align-middle",children:r(Ah,{trpc:t,device:n,flags:s,accessoryCount:l,adoptedCount:c,showFeatureRow:!0})}),r("td",{className:"px-2 py-2 align-middle",children:r($h,{trpc:t,device:n,status:h,enabled:b&&g,showStatusPills:!0})}),r("td",{className:"px-2 py-2 align-middle text-right whitespace-nowrap",children:u("span",{className:"inline-flex items-center gap-1.5",children:[r(Ih,{trpc:t,device:n,flags:s}),r(_h,{status:h})]})})]})}function Dh(e,t){const[n,o]=_(e);return Z(()=>{const s=setTimeout(()=>o(e),t);return()=>clearTimeout(s)},[e,t]),n}const OS=new Set(["hub","nvr"]);function zS(e){const t=new Map;for(const s of e)t.set(s.id,s);const n=[],o=new Map;for(const s of e){const a=s.parentDeviceId;if(a==null){n.push(s);continue}const i=t.get(a);if(!i){n.push(s);continue}const l=s.role!==null&&s.role!==void 0;if(OS.has(i.type)&&!l){n.push(s);continue}const d=o.get(a);d?d.push(s):o.set(a,[s])}return{topLevel:n,accessoriesByParent:o}}const ou=2;function BS(e,t){if(t<=1)return[{kind:"page",n:1}];if(t<=7){const a=[];for(let i=1;i<=t;i++)a.push({kind:"page",n:i});return a}const n=[],o=Math.max(2,e-ou),s=Math.min(t-1,e+ou);n.push({kind:"page",n:1}),o>2&&n.push({kind:"ellipsis",side:"left"});for(let a=o;a<=s;a++)n.push({kind:"page",n:a});return s<t-1&&n.push({kind:"ellipsis",side:"right"}),n.push({kind:"page",n:t}),n}function FS({currentPage:e,totalItems:t,pageSize:n,onPageChange:o,itemNoun:s="devices"}){if(t<=n)return null;const a=Math.ceil(t/n),i=(e-1)*n+1,l=Math.min(e*n,t),c=BS(e,a);return u("div",{className:"flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle",children:[u("span",{children:["Showing ",i,"–",l," of ",t," ",s]}),u("span",{className:"inline-flex items-center gap-1",children:[r("button",{type:"button","aria-label":"Previous page",disabled:e===1,onClick:()=>o(e-1),className:W("inline-flex items-center justify-center h-7 w-7 rounded border border-border bg-surface text-foreground-subtle","hover:text-foreground hover:bg-surface-hover transition-colors","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-surface"),children:r(c2,{className:"h-3 w-3"})}),c.map((d,f)=>{if(d.kind==="ellipsis")return r("span",{className:"px-1 text-foreground-subtle/60 select-none",children:"…"},`e-${f}`);const p=d.n===e;return r("button",{type:"button",onClick:()=>o(d.n),className:W("inline-flex items-center justify-center h-7 min-w-7 px-1.5 rounded border text-[10.5px] font-medium transition-colors",p?"border-primary/40 bg-primary/10 text-primary":"border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),children:d.n},`p-${d.n}`)}),r("button",{type:"button","aria-label":"Next page",disabled:e===a,onClick:()=>o(e+1),className:W("inline-flex items-center justify-center h-7 w-7 rounded border border-border bg-surface text-foreground-subtle","hover:text-foreground hover:bg-surface-hover transition-colors","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-surface"),children:r(Sn,{className:"h-3 w-3"})})]})]})}function jS({view:e,onViewChange:t,types:n,currentType:o,onTypeChange:s,addons:a,currentAddon:i,onAddonChange:l,hideAddons:c=!1}){return u("div",{className:"flex items-center gap-2 flex-wrap",children:[u("span",{className:"inline-flex border border-border rounded-md overflow-hidden",children:[r("button",{type:"button",onClick:()=>t("cards"),className:W("inline-flex items-center justify-center h-7 w-8 transition-colors",e==="cards"?"bg-primary/10 text-primary":"bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),"aria-label":"Cards view",children:r(Y2,{className:"h-3.5 w-3.5"})}),r("button",{type:"button",onClick:()=>t("table"),className:W("inline-flex items-center justify-center h-7 w-8 border-l border-border transition-colors",e==="table"?"bg-primary/10 text-primary":"bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),"aria-label":"Table view",children:r(Vk,{className:"h-3.5 w-3.5"})})]}),n&&n.length>0&&u(xe,{children:[r(su,{children:"Type"}),r(Ua,{active:o===null,onClick:()=>s(null),children:"All"}),n.map(d=>r(Ua,{active:o===d,onClick:()=>s(o===d?null:d),children:HS(d)},d))]}),!c&&a&&a.length>0&&u(xe,{children:[r(su,{children:"Integration"}),a.map(d=>r(Ua,{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 su({children:e}){return r("span",{className:"text-[10px] font-medium uppercase tracking-wider text-foreground-subtle ml-1",children:e})}function Ua({active:e,icon:t,onClick:n,showClearIcon:o,children:s}){return u("button",{type:"button",onClick:n,className:W("inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full border text-[10.5px] font-medium transition-colors",e?"border-primary/40 bg-primary/15 text-primary":"border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),children:[t&&r("span",{className:"inline-flex items-center",children:t}),r("span",{children:s}),e&&o&&r(Xe,{className:"h-2.5 w-2.5 opacity-70"})]})}function HS(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function VS({variant:e,onClearFilters:t}){return u("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r(U2,{className:"h-8 w-8 text-foreground-subtle/40 mb-3"}),r("p",{className:"text-sm font-medium text-foreground-subtle",children:e==="filtered"?"No devices match the current filters":"No devices yet"}),e==="filtered"&&t&&r("button",{type:"button",onClick:t,className:"mt-2 text-[11px] text-primary hover:underline",children:"Clear filters"})]})}function Ht(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 au(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 qS(e,t){try{localStorage.setItem(`camstack:${e}:lastFilters`,JSON.stringify(t))}catch{}}function iu(e,t,n){const o=new URLSearchParams(window.location.search),s=o.get(Ht(e,"view")),a=s==="cards"||s==="table"?s:n.view??t,i=o.get(Ht(e,"page")),l=i?parseInt(i,10):1,c=Number.isFinite(l)&&l>=1?l:1,d=o.get(Ht(e,"addon"))??n.addon??null,f=o.get(Ht(e,"type"))??n.type??null,p=o.get(Ht(e,"q"))??n.q??"";return{view:a,page:c,addon:d,type:f,q:p}}function QS(e,t,n){const o=new URLSearchParams(window.location.search),s=(l,c)=>{c===null||c===""?o.delete(l):o.set(l,c)};s(Ht(e,"view"),t.view===n?null:t.view),s(Ht(e,"page"),t.page===1?null:String(t.page)),s(Ht(e,"addon"),t.addon),s(Ht(e,"type"),t.type),s(Ht(e,"q"),t.q||null);const a=o.toString(),i=a?`${window.location.pathname}?${a}`:window.location.pathname;window.history.replaceState(null,"",i)}function US(e){const{scope:t,defaultView:n,lsKey:o}=e,[s,a]=_(()=>{const g=au(o);return iu(t,n,g)}),i=ne(s);i.current=s,Z(()=>{const g=()=>{const b=au(o),x=iu(t,n,b);i.current=x,a(x)};return window.addEventListener("popstate",g),()=>window.removeEventListener("popstate",g)},[t,n,o]);const l=q(g=>{const b=g(i.current);i.current=b,a(b),QS(t,b,n),qS(o,{view:b.view,addon:b.addon,type:b.type,q:b.q})},[t,n,o]),c=q(g=>l(b=>({...b,view:g})),[l]),d=q(g=>l(b=>({...b,page:g})),[l]),f=q(g=>l(b=>({...b,addon:g,page:1})),[l]),p=q(g=>l(b=>({...b,type:g,page:1})),[l]),m=q(g=>l(b=>({...b,q:g,page:1})),[l]),h=q(()=>l(g=>({...g,addon:null,type:null,q:"",page:1})),[l]);return{state:s,setView:c,setPage:d,setAddon:f,setType:p,setQ:m,clearFilters:h}}const KS={cards:24,table:50};function so(e){const{devices:t,trpc:n,defaultView:o="table",filters:s,forceAddon:a,resolveIntegrationIcon:i,resolveParent:l,onNavigate:c,pageSize:d=KS,urlScope:f="root",lsKey:p=f==="root"?"devices":"integrations:nested"}=e,m=US({scope:f,defaultView:o,lsKey:p}),h=m.state.view,g=h==="cards"?d.cards:d.table,[b,x]=_(m.state.q),v=Dh(b,300);Z(()=>{v!==m.state.q&&m.setQ(v)},[v]);const w=a??m.state.addon,y=U(()=>{const R=m.state.q.toLowerCase().trim();return t.filter(A=>!(w&&A.addonId!==w||m.state.type&&A.type!==m.state.type||R&&!A.name.toLowerCase().includes(R)&&!A.stableId.toLowerCase().includes(R)))},[t,w,m.state.type,m.state.q]),N=U(()=>zS(y),[y]),k=U(()=>{if(m.state.q.trim()==="")return new Set;const R=m.state.q.toLowerCase().trim(),A=new Set;for(const[L,D]of N.accessoriesByParent.entries())D.some(T=>T.name.toLowerCase().includes(R)||T.stableId.toLowerCase().includes(R))&&A.add(L);return A},[N.accessoriesByParent,m.state.q]),S=N.topLevel.length,M=Math.max(1,Math.ceil(S/g)),P=Math.min(m.state.page,M),I=(P-1)*g,z=N.topLevel.slice(I,I+g);Z(()=>{P!==m.state.page&&m.setPage(P)},[P]),JS();const $=w!=null||m.state.type!==null||m.state.q!=="",O=S===0;return u("div",{className:"flex flex-col gap-3",children:[u("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[r(jS,{view:h,onViewChange:m.setView,types:s?.types,currentType:m.state.type,onTypeChange:m.setType,addons:s?.addons,currentAddon:m.state.addon,onAddonChange:m.setAddon,hideAddons:a!==void 0}),u("div",{className:"relative",children:[r(ro,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle pointer-events-none"}),r("input",{type:"text",value:b,onChange: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"})]})]}),O?r(VS,{variant:$?"filtered":"nofilter",onClearFilters:$?m.clearFilters:void 0}):h==="cards"?r(GS,{rows:z,accessoriesByParent:N.accessoriesByParent,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}):r(ZS,{rows:z,accessoriesByParent:N.accessoriesByParent,autoExpandedParents:k,devices:y,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:c??null}),r(FS,{currentPage:P,totalItems:S,pageSize:g,onPageChange:m.setPage}),a===void 0&&$&&S>0&&u("p",{className:"text-[11px] text-foreground-subtle",children:["Showing ",S," of ",t.length," devices",w&&u(xe,{children:[" ","· filtered by"," ",r("strong",{className:"text-primary",children:s?.addons?.find(R=>R.id===w)?.name??w})]})]})]})}function GS({rows:e,accessoriesByParent:t,trpc:n,resolveIntegrationIcon:o,resolveParent:s,onNavigate:a}){return r("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.map(i=>{const l=t.get(i.id)??[];return r(oo,{trpc:n,device:i,view:"card",integrationIcon:o?.(i.addonId)??null,parent:i.parentDeviceId!==null?s?.(i.parentDeviceId)??null:null,children:l,onNavigate:a??void 0},i.id)})})}const WS=new Set(["hub","nvr"]);function YS(e,t){return e.parentDeviceId===null||t===null?0:WS.has(t.toLowerCase())?1:0}function ZS({rows:e,accessoriesByParent:t,autoExpandedParents:n,devices:o,trpc:s,resolveIntegrationIcon:a,resolveParent:i,onNavigate:l}){const c=U(()=>{const d=new Map;for(const f of o)d.set(f.id,f.type);return d},[o]);return r("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:u("table",{className:"w-full border-collapse",children:[r("thead",{children:u("tr",{className:"border-b border-border",children:[r("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle",children:"Name"}),r("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-24",children:"Type"}),r("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Features"}),r("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-20",children:"Preview"}),r("th",{className:"text-right px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Actions"})]})}),r("tbody",{children:e.map(d=>{const f=t.get(d.id)??[],p=f.length>0,m=n.has(d.id),h=d.parentDeviceId!==null?i?.(d.parentDeviceId)??null:null,g=d.parentDeviceId!==null?c.get(d.parentDeviceId)??null:null;return r(XS,{parent:d,accessories:f,hasAccessories:p,forceExpanded:m,trpc:s,integrationIcon:a?.(d.addonId)??null,parentRowParent:h,indentLevel:YS(d,g),onNavigate:l??null},d.id)})})]})})}function XS({parent:e,accessories:t,hasAccessories:n,forceExpanded:o,trpc:s,integrationIcon:a,parentRowParent:i,indentLevel:l,onNavigate:c}){const[d,f]=_(o),p=ne(o);return Z(()=>{p.current!==o&&(f(o),p.current=o)},[o]),u(xe,{children:[r(oo,{trpc:s,device:e,view:"table",integrationIcon:a,parent:i,children:t,onNavigate:c??void 0,showChildrenAccordion:n,expanded:d,onToggleExpand:()=>f(g=>!g),indentLevel:l}),n&&d&&t.map(g=>r(oo,{trpc:s,device:g,view:"table",integrationIcon:null,parent:null,isAccessoryRow:!0,showChildrenAccordion:!1,onNavigate:c??void 0},g.id))]})}function JS(){ke()}function eC({options:e,value:t,onChange:n}){return r("div",{className:"flex flex-wrap gap-2",children:e.map(o=>{const s=o.id===t;return u("button",{onClick:()=>o.available&&n(o.id),disabled:!o.available,className:`flex items-center gap-2 rounded-lg border px-3 py-2 text-xs font-medium transition-all ${s?"border-primary/40 bg-primary/10 text-primary":o.available?"border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground":"border-border/40 bg-surface/40 text-foreground-subtle/40 cursor-not-allowed"}`,children:[r(P2,{className:"h-3.5 w-3.5 shrink-0"}),o.label,o.isBest&&u("span",{className:"inline-flex items-center gap-0.5 rounded-full bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-amber-400",children:[r(Fk,{className:"h-2.5 w-2.5"}),"Best"]}),o.platformScore!=null&&u("span",{className:"text-[10px] text-foreground-subtle/60",children:["(",o.platformScore,")"]}),r("span",{className:`h-1.5 w-1.5 rounded-full ${o.available?"bg-success":"bg-danger"}`})]},o.id)})})}function tC(e,t){const n=new Set(t.slots.flatMap(i=>i.addons.map(l=>l.id))),o=[];function s(i){if(!n.has(i.addonId))return o.push(`Addon "${i.addonId}" is no longer available — step removed`),null;const l=t.slots.flatMap(f=>f.addons).find(f=>f.id===i.addonId);let c=i.modelId;if(l&&!l.models.some(f=>f.id===c)){const f=l.defaultModelId;o.push(`Model "${c}" not available for ${i.addonId} — using "${f}"`),c=f}const d=i.children.map(f=>s(f)).filter(f=>f!==null);return{...i,modelId:c,children:d}}const a=e.map(i=>s(i)).filter(i=>i!==null);return{valid:o.length===0,steps:a,warnings:o}}function nC(e){const t=new Map;for(const n of e.slots)for(const o of n.addons)t.set(o.id,o);return t}function Ka(e){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:!0,modelId:e.defaultModelId,children:[]}}function Ga({addon:e,onClick:t}){return r("button",{type:"button",onClick:t,className:"w-full rounded-lg border border-dashed border-border/60 px-3 py-2.5 text-left transition-all hover:border-primary/30 hover:bg-surface/60 group",children:u("div",{className:"flex items-center gap-3",children:[r(w2,{className:"h-[18px] w-[18px] text-foreground-subtle/30 group-hover:text-primary/60 shrink-0"}),u("div",{className:"flex-1 min-w-0",children:[r("span",{className:"text-[13px] font-medium text-foreground-subtle/50 group-hover:text-foreground-subtle block truncate",children:e.name}),u("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(n=>r("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-blue-500/8 text-blue-400/50",children:n},n)),e.inputClasses.length>0&&e.outputClasses.length>0&&r("span",{className:"text-foreground-subtle/25 text-[10px]",children:"→"}),e.outputClasses.map(n=>r("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-green-500/8 text-green-400/50",children:n},n))]})]})]})})}function sc({schema:e,steps:t,onChange:n,templates:o,selectedTemplateId:s,onSelectTemplate:a,onSaveTemplate:i,onUpdateTemplate:l,onDeleteTemplate:c,readOnly:d=!1,excludeAddons:f=[],hideTemplates:p=!1,showOnlyEnabled:m=!1,showSlotLabels:h=!1,toggleMode:g="simple",overrides:b={},onOverrideChange:x,inheritedEnabledByAddon:v={},hideModelAndSettings:w=!1}){const y=H=>({toggleMode:g,hideModelAndSettings:w,...g==="threeState"?{overrideState:b[H]!==void 0?b[H]:null,onOverrideChange:x?E=>x(H,E):void 0,inheritedEnabled:v[H]}:{}}),N=U(()=>new Set(f),[f]),k=U(()=>nC(e),[e]),[S,M]=_([]),P=s?JSON.stringify(t)!==JSON.stringify(o.find(H=>H.id===s)?.steps):!1;function I(H){const E=H.target.value||null;if(E){const Q=o.find(K=>K.id===E);if(Q){const K=tC(Q.steps,e);M([...K.warnings])}}else M([]);a(E)}function z(){s&&l(s,t)}function $(){const H=window.prompt("Template name:");H?.trim()&&i(H.trim(),t)}function O(){if(!s)return;const H=o.find(E=>E.id===s);H&&window.confirm(`Delete template "${H.name}"?`)&&c(s)}function R(H){n(t.map(E=>E.addonId!==H.addonId?E:A(H)))}function A(H){const E=H.children.some(Q=>Q.enabled||Q.children.some(K=>K.enabled));return{...H,enabled:H.enabled||E,children:H.children.map(Q=>{const K=Q.children.some(Y=>Y.enabled);return{...Q,enabled:Q.enabled||K}})}}function L(H,E){const Q=Ka(E);n(t.map(K=>K.addonId!==H?K:{...K,children:[...K.children,Q]}))}function D(H){const E=new Set;for(const Q of H){E.add(Q.addonId);for(const Y of Q.children)E.add(Y.addonId);const K=D(Q.children);for(const Y of K)E.add(Y)}return E}const T=D(t);function B(H){const E=k.get(H.addonId);if(!E)return[];const K=e.slots.find(X=>X.id===E.slot)?.parentSlot==null,Y=E.childSlots,re=new Set(H.children.map(X=>X.addonId)),te=[];for(const X of e.slots)if(Y.includes(X.id))for(const oe of X.addons){if(re.has(oe.id)||N.has(oe.id))continue;const ge=oe.inputClasses.length===0;if(ge&&!K)continue;(ge||oe.inputClasses.some(G=>H.outputClasses.includes(G)))&&te.push(oe)}return te}function F(H){const E=m?{...H,children:H.children.filter(K=>K.enabled).map(K=>({...K,children:K.children.filter(Y=>Y.enabled)}))}:H,Q=m?[]:B(E);return u("div",{className:"space-y-1.5",children:[r(ps,{step:E,schema:k.get(E.addonId)??null,allSchemas:k,onChange:R,onDelete:d?void 0:K=>n(t.filter(Y=>Y.addonId!==K)),readOnly:d,...y(E.addonId)}),(E.children.length>0||Q.length>0)&&u("div",{className:"ml-4 pl-3 border-l border-border/60 space-y-1.5",children:[h&&r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/40",children:"Slot: Cropper / Classifier"}),E.children.map(K=>{const Y=B(K);return u("div",{className:"space-y-1.5",children:[r(ps,{step:K,schema:k.get(K.addonId)??null,allSchemas:k,depth:1,onChange:re=>{R({...E,children:E.children.map(te=>te.addonId===re.addonId?re:te)})},onDelete:d?void 0:re=>{R({...E,children:E.children.filter(te=>te.addonId!==re)})},readOnly:d,...y(K.addonId)}),(K.children.length>0||Y.length>0)&&u("div",{className:"ml-4 pl-3 border-l border-border/40 space-y-1.5",children:[h&&r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/30",children:"Slot: Recognizer"}),K.children.map(re=>r(ps,{step:re,schema:k.get(re.addonId)??null,allSchemas:k,depth:2,onChange:te=>{R({...E,children:E.children.map(X=>X.addonId===K.addonId?{...X,children:X.children.map(oe=>oe.addonId===te.addonId?te:oe)}:X)})},onDelete:d?void 0:te=>{R({...E,children:E.children.map(X=>X.addonId===K.addonId?{...X,children:X.children.filter(oe=>oe.addonId!==te)}:X)})},readOnly:d,...y(re.addonId)},re.addonId)),!d&&Y.map(re=>r(Ga,{addon:re,onClick:()=>{const te=Ka(re);R({...E,children:E.children.map(X=>X.addonId===K.addonId?{...X,children:[...X.children,te]}:X)})}},re.id))]})]},K.addonId)}),!d&&Q.map(K=>r(Ga,{addon:K,onClick:()=>L(E.addonId,K)},K.id))]})]},E.addonId)}const j=e.slots.filter(H=>H.parentSlot===null).sort((H,E)=>H.priority-E.priority);return u("div",{className:"space-y-4",children:[!p&&r("div",{className:"rounded-lg border border-border bg-surface p-3",children:u("div",{className:"flex items-center gap-2",children:[r("div",{className:"relative flex-1 min-w-0",children:u("select",{value:s??"",onChange:I,className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:border-primary/50",children:[r("option",{value:"",children:"No template"}),o.map(H=>r("option",{value:H.id,children:H.name},H.id))]})}),P&&r("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500 shrink-0"}),r("button",{onClick:z,disabled:!s||d,title:"Save",className:W("p-2 rounded-lg border border-border transition-colors",s&&!d?"text-foreground-subtle hover:bg-surface-hover":"text-foreground-subtle/30 cursor-not-allowed"),children:r(Sk,{className:"h-4 w-4"})}),r("button",{onClick:$,disabled:d,title:"Save As",className:W("p-2 rounded-lg border border-border transition-colors",d?"text-foreground-subtle/30 cursor-not-allowed":"text-foreground-subtle hover:bg-surface-hover"),children:r(M2,{className:"h-4 w-4"})}),r("button",{onClick:O,disabled:!s||d,title:"Delete",className:W("p-2 rounded-lg border border-border transition-colors",s&&!d?"text-foreground-subtle hover:text-danger":"text-foreground-subtle/30 cursor-not-allowed"),children:r(tn,{className:"h-4 w-4"})})]})}),S.length>0&&u("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 text-xs text-amber-400 space-y-1",children:[u("div",{className:"flex items-center justify-between",children:[r("span",{className:"font-medium",children:"Template loaded with warnings:"}),r("button",{onClick:()=>M([]),className:"text-amber-400/60 hover:text-amber-400",children:r(Xe,{className:"h-3.5 w-3.5"})})]}),S.map((H,E)=>u("div",{children:["• ",H]},E))]}),j.map(H=>{const E=t.filter(te=>te.slot===H.id&&!N.has(te.addonId)),Q=m?E.filter(te=>te.enabled):E,K=m?[]:H.addons.filter(te=>!T.has(te.id)&&!N.has(te.id)),Y=new Map,re=[];for(const te of Q)te.group?(Y.has(te.group)||Y.set(te.group,[]),Y.get(te.group).push(te)):re.push(te);return u("div",{className:"space-y-2",children:[h&&u("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50",children:["Slot: ",H.label]}),re.map(te=>F(te)),[...Y.entries()].map(([te,X])=>u("div",{className:"space-y-2 rounded-lg border border-border/40 p-2",children:[r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50 px-1",children:te}),X.map(oe=>F(oe))]},te)),!d&&K.map(te=>r(Ga,{addon:te,onClick:()=>{n([...t,Ka(te)])}},te.id))]},H.id)})]})}const qr={person:"#3b82f6",vehicle:"#f59e0b",animal:"#22c55e",face:"#a855f7",plate:"#ec4899",bird:"#14b8a6",dog:"#84cc16",cat:"#f97316",car:"#f59e0b",truck:"#d97706",bus:"#b45309",motorcycle:"#eab308",bicycle:"#ca8a04",motion:"#facc15"},lu=["#ef4444","#8b5cf6","#06b6d4","#f97316","#10b981","#6366f1","#e11d48","#0891b2","#7c3aed","#059669"],Lh="#f59e42";function lt(e,t){if(t?.[e])return t[e];if(t?.[e.toLowerCase()])return t[e.toLowerCase()];if(qr[e])return qr[e];if(qr[e.toLowerCase()])return qr[e.toLowerCase()];let n=0;for(let o=0;o<e.length;o++)n=n*31+(e.codePointAt(o)??0)>>>0;return lu[n%lu.length]??Lh}function rC({src:e,imageWidth:t,imageHeight:n,detections:o=[],classColors:s,aspectRatio:a,className:i,placeholder:l,showConfidence:c=!0,minConfidence:d=0,borderWidth:f=2}){function p(v){return lt(v,s)}const m=a??(t&&n?`${t}/${n}`:"16/9"),h=o.filter(v=>v.score>=d),g=h.filter(v=>v.kind==="first-level"),b=h.filter(v=>v.kind==="detail"),x=aC(b,v=>v.parentId??"");return r("div",{className:W("rounded-lg border border-border bg-surface overflow-hidden relative",i),style:{aspectRatio:m},children:e?u(xe,{children:[r("img",{src:e,className:"absolute inset-0 w-full h-full object-fill",alt:""}),h.map((v,w)=>v.debug?.mask&&v.debug.maskWidth&&v.debug.maskHeight?r(oC,{mask:v.debug.mask,maskWidth:v.debug.maskWidth,maskHeight:v.debug.maskHeight,bbox:v.bbox,imageWidth:t,imageHeight:n,color:p(v.macroClass)},`mask-${w}`):null),g.map(v=>{const w=x.get(v.id)??[];return r(cu,{detection:v,imageWidth:t,imageHeight:n,color:p(v.macroClass),showConfidence:c,borderWidth:v.debug?.mask?1:f,children:w.map(y=>r(sC,{child:y,parentBbox:v.bbox,color:p(y.macroClass),showConfidence:c},`child-${y.id}`))},`det-${v.id}`)}),b.filter(v=>!v.parentId||!g.some(w=>w.id===v.parentId)).map(v=>r(cu,{detection:v,imageWidth:t,imageHeight:n,color:p(v.macroClass),showConfidence:c,borderWidth:f},`orphan-${v.id}`))]}):r("div",{className:"w-full h-full flex items-center justify-center text-foreground-subtle text-sm",children:l??"No image loaded"})})}function cu({detection:e,imageWidth:t,imageHeight:n,color:o,showConfidence:s,borderWidth:a,children:i}){const{x:l,y:c,width:d,height:f}=e.bbox,p=u("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"2px"},children:[u("span",{className:"text-[10px] px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:o},children:[e.macroClass,s&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((m,h)=>u("span",{className:"text-[9px] font-semibold px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:lt(m.label)},children:[m.label," ",(m.score*100).toFixed(0),"%"]},`${e.id}-lbl-${h}`))]});return u("div",{className:"absolute rounded-sm",style:{left:`${l/t*100}%`,top:`${c/n*100}%`,width:`${d/t*100}%`,height:`${f/n*100}%`,borderWidth:`${a}px`,borderStyle:"solid",borderColor:o},children:[p,i]})}function oC({mask:e,maskWidth:t,maskHeight:n,bbox:o,imageWidth:s,imageHeight:a,color:i}){const l=ne(null);return Z(()=>{const c=l.current;if(!c)return;const d=c.getContext("2d");if(!d)return;const f=atob(e),p=new Uint8Array(f.length);for(let v=0;v<f.length;v++)p[v]=f.charCodeAt(v);const m=parseInt(i.slice(1,3),16),h=parseInt(i.slice(3,5),16),g=parseInt(i.slice(5,7),16);c.width=t,c.height=n;const b=d.createImageData(t,n),x=t*n;for(let v=0;v<x;v++){const w=v<p.length?p[v]:0,y=v*4;w>0&&(b.data[y]=m,b.data[y+1]=h,b.data[y+2]=g,b.data[y+3]=120)}d.putImageData(b,0,0)},[e,t,n,i]),r("canvas",{ref:l,className:"absolute pointer-events-none",style:{left:`${o.x/s*100}%`,top:`${o.y/a*100}%`,width:`${o.width/s*100}%`,height:`${o.height/a*100}%`,imageRendering:"pixelated"}})}function sC({child:e,parentBbox:t,color:n,showConfidence:o}){if(t.width<=0||t.height<=0)return null;const s=(e.bbox.x-t.x)/t.width*100,a=(e.bbox.y-t.y)/t.height*100,i=e.bbox.width/t.width*100,l=e.bbox.height/t.height*100;return r("div",{className:"absolute rounded-sm",style:{left:`${Math.max(0,s)}%`,top:`${Math.max(0,a)}%`,width:`${Math.min(100,i)}%`,height:`${Math.min(100,l)}%`,borderWidth:"1px",borderStyle:"solid",borderColor:n},children:u("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"1px"},children:[u("span",{className:"text-[9px] px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:n},children:[e.macroClass,o&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((c,d)=>u("span",{className:"text-[8px] font-semibold px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:lt(c.label)},children:[c.label," ",(c.score*100).toFixed(0),"%"]},`${e.id}-lbl-${d}`))]})})}function aC(e,t){const n=new Map;for(const o of e){const s=t(o),a=n.get(s)??[];a.push(o),n.set(s,a)}return n}function iC({detections:e,classColors:t,className:n,hiddenKeys:o,onToggleVisibility:s}){const a=t;if(e.length===0)return r("div",{className:"text-sm text-foreground-subtle italic text-center py-4",children:"No detections"});const i=e.filter(f=>f.kind==="first-level"),l=e.filter(f=>f.kind==="detail"),c=new Map;for(const f of l){if(!f.parentId)continue;const p=c.get(f.parentId)??[];p.push(f),c.set(f.parentId,p)}const d=l.filter(f=>!f.parentId||!i.some(p=>p.id===f.parentId));return u("div",{className:n,children:[u("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Detections (",e.length,")"]}),u("div",{className:"space-y-2",children:[i.map(f=>r(du,{detection:f,children_:c.get(f.id)??[],colors:a,hiddenKeys:o,onToggleVisibility:s},f.id)),d.map(f=>r(du,{detection:f,children_:[],colors:a,hiddenKeys:o,onToggleVisibility:s},f.id))]})]})}function du({detection:e,children_:t,colors:n,hiddenKeys:o,onToggleVisibility:s}){const a=lt(e.macroClass,n),i=!o?.has(e.id),l=e.debug?.mask,c=e.debug?.maskWidth,d=e.debug?.maskHeight,f=e.debug?.alternateLabels;return u("div",{className:`rounded-md border border-border bg-surface p-3 space-y-1 ${i?"":"opacity-40"}`,children:[u("div",{className:"flex justify-between items-center",children:[u("div",{className:"flex items-center gap-2",children:[s&&r("input",{type:"checkbox",checked:i,onChange:()=>s(e.id,!i),className:"h-3.5 w-3.5 rounded border-border accent-primary cursor-pointer shrink-0"}),r("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:a}}),r("span",{className:"text-sm font-medium text-foreground",children:e.macroClass}),e.kind==="detail"&&r("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:"detail"}),l&&c&&d&&u("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",c,"x",d]})]}),r(dC,{confidence:e.score})]}),u("div",{className:"text-[10px] text-foreground-subtle font-mono",children:["bbox: [",Math.round(e.bbox.x),", ",Math.round(e.bbox.y),","," ",Math.round(e.bbox.x+e.bbox.width),","," ",Math.round(e.bbox.y+e.bbox.height),"]"]}),e.labels.length>0&&r("div",{className:"flex flex-wrap gap-1 mt-1",children:e.labels.map((p,m)=>u("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{backgroundColor:lt(p.label,n)+"20",color:lt(p.label,n)},children:[p.label,u("span",{className:"opacity-60",children:[(p.score*100).toFixed(0),"%"]}),p.detectionId&&u("span",{className:"opacity-40 text-[8px]",children:["→ ",p.detectionId]})]},m))}),f&&Object.keys(f).length>0&&r(cC,{alternateLabels:f,colors:n}),t.length>0&&r(lC,{items:t,colors:n,hiddenKeys:o,onToggleVisibility:s})]})}function lC({items:e,colors:t,hiddenKeys:n,onToggleVisibility:o}){return r("div",{className:"ml-4 mt-1.5 space-y-1.5 border-l-2 border-border pl-3",children:e.map(s=>{const a=lt(s.macroClass,t),i=!n?.has(s.id),l=s.debug?.mask,c=s.debug?.maskWidth,d=s.debug?.maskHeight;return u("div",{className:`text-xs space-y-0.5 ${i?"":"opacity-40"}`,children:[u("div",{className:"flex items-center gap-1.5",children:[o&&r("input",{type:"checkbox",checked:i,onChange:()=>o(s.id,!i),className:"h-3 w-3 rounded border-border accent-primary cursor-pointer shrink-0"}),r("span",{className:"h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:a}}),r("span",{className:"font-medium",style:{color:a},children:s.macroClass}),u("span",{className:"text-foreground-subtle",children:[(s.score*100).toFixed(0),"%"]}),l&&c&&d&&u("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",c,"x",d]})]}),s.labels.length>0&&r("div",{className:"flex flex-wrap gap-1 ml-5 mt-0.5",children:s.labels.map((f,p)=>u("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-medium px-1 py-0.5 rounded-full",style:{backgroundColor:lt(f.label,t)+"20",color:lt(f.label,t)},children:[f.label," ",u("span",{className:"opacity-60",children:[(f.score*100).toFixed(0),"%"]})]},p))})]},s.id)})})}function cC({alternateLabels:e,colors:t}){const[n,o]=_(!1),s=Object.keys(e);return u("div",{className:"mt-1",children:[u("button",{onClick:()=>o(a=>!a),className:"text-[9px] text-foreground-subtle hover:text-foreground transition-colors flex items-center gap-1",children:[r("span",{className:`transition-transform ${n?"rotate-90":""}`,children:"▶"}),"Alternates (",s.length," source",s.length!==1?"s":"",")"]}),n&&r("div",{className:"mt-1 ml-3 space-y-1.5",children:s.map(a=>{const i=e[a];return!i||i.length===0?null:u("div",{children:[r("div",{className:"text-[9px] font-medium text-foreground-subtle mb-0.5",children:a}),r("div",{className:"flex flex-wrap gap-1",children:i.map((l,c)=>u("span",{className:"inline-flex items-center gap-0.5 text-[9px] px-1 py-0.5 rounded-full",style:{backgroundColor:lt(a,t)+"10",color:lt(a,t),opacity:Math.max(.4,l.score)},children:[l.label,u("span",{className:"opacity-60",children:[(l.score*100).toFixed(1),"%"]})]},c))})]},a)})})]})}function dC({confidence:e}){const t=e>=.8?"bg-success/10 text-success":e>=.5?"bg-warning/10 text-warning":"bg-danger/10 text-danger";return u("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${t}`,children:[(e*100).toFixed(1),"%"]})}function uC({timings:e,totalMs:t,className:n}){const o=Object.entries(e);return o.length===0&&t===void 0?null:u("div",{className:`rounded-lg border border-border bg-surface p-3 space-y-2 ${n??""}`,children:[r("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide",children:"Timings"}),u("div",{className:"space-y-1 text-xs",children:[o.map(([s,a])=>u("div",{className:"flex justify-between",children:[r("span",{className:"text-foreground-subtle",children:s}),u("span",{className:"font-mono text-foreground",children:[a.toFixed(1),"ms"]})]},s)),t!==void 0&&u("div",{className:"flex justify-between pt-1 border-t border-border font-medium text-foreground",children:[r("span",{children:"Total"}),u("span",{className:"font-mono",children:[t.toFixed(1),"ms"]})]})]})]})}function pC({images:e,selectedFilename:t,uploadedName:n,onSelect:o,onUpload:s,className:a,accept:i="image/*",uploadLabel:l="Upload..."}){const c=()=>{const d=document.createElement("input");d.type="file",d.accept=i,d.onchange=()=>{const f=d.files?.[0];if(!f)return;const p=new FileReader;p.onload=()=>{const m=p.result,h=m.split(",")[1];h&&s(h,f.name,m)},p.readAsDataURL(f)},d.click()};return u("div",{className:`flex flex-wrap items-center gap-2 ${a??""}`,children:[e.map(d=>r("button",{onClick:()=>o(d.filename),className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${t===d.filename?"bg-primary text-primary-foreground border-primary":"bg-surface border-border text-foreground hover:border-primary/50"}`,children:d.id??d.filename.replace(/\.[^.]+$/,"")},d.filename)),r("button",{onClick:c,className:"px-3 py-1.5 text-xs rounded-md border border-border bg-surface text-foreground hover:bg-surface-hover transition-colors",children:l}),n&&r("span",{className:"text-xs text-foreground-subtle",children:n})]})}const zo="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 fC({runtime:e,backend:t,modelId:n,agentId:o="hub",runtimes:s,backends:a,models:i,agents:l=[],onRuntimeChange:c,onBackendChange:d,onModelChange:f,onAgentChange:p,layout:m="grid",className:h,showAgent:g=!1}){return u("div",{className:`${m==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4":m==="horizontal"?"flex flex-wrap items-end gap-4":"space-y-3"} ${h??""}`,children:[g&&l.length>0&&u("label",{className:"space-y-1",children:[r("span",{className:"text-xs font-medium text-foreground-subtle",children:"Agent"}),r("select",{value:o,onChange:x=>p?.(x.target.value),className:zo,children:l.map(x=>u("option",{value:x.id,children:[x.name," (",x.status,")"]},x.id))})]}),u("label",{className:"space-y-1",children:[r("span",{className:"text-xs font-medium text-foreground-subtle",children:"Runtime"}),r("select",{value:e,onChange:x=>c(x.target.value),className:zo,children:s.map(x=>u("option",{value:x.value,disabled:!x.available,children:[x.label,x.available?"":" (unavailable)"]},x.value))})]}),u("label",{className:"space-y-1",children:[r("span",{className:"text-xs font-medium text-foreground-subtle",children:"Backend"}),r("select",{value:t,onChange:x=>d(x.target.value),className:zo,children:a.map(x=>u("option",{value:x.id,disabled:!x.available,children:[x.label,x.available?"":" (unavailable)"]},x.id))})]}),u("label",{className:"space-y-1",children:[r("span",{className:"text-xs font-medium text-foreground-subtle",children:"Model"}),r("select",{value:n,onChange:x=>f(x.target.value),className:zo,children:i.length===0?r("option",{value:"",children:"No compatible models"}):i.map(x=>u("option",{value:x.id,children:[x.name,x.downloaded?" ✓":""]},x.id))})]})]})}function mC({className:e}){return u("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[r("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),r("circle",{cx:"12",cy:"12",r:"3"})]})}function hC({className:e}){return u("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[r("path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}),r("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),r("path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}),r("path",{d:"m2 2 20 20"})]})}function gC({className:e}){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:r("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}function Th({onLogin:e,serverUrl:t,logoSrc:n,error:o,className:s}){const[a,i]=_(""),[l,c]=_(""),[d,f]=_(!1),[p,m]=_(!1),[h,g]=_(null),b=o??h,x=async v=>{if(v.preventDefault(),!p){g(null),m(!0);try{await e(a,l)}catch(w){const y=w instanceof Error?w.message:"Login failed. Please try again.";g(y)}finally{m(!1)}}};return r("div",{className:W("flex min-h-screen items-center justify-center bg-background p-4",s),children:u("div",{className:"w-full max-w-sm",children:[n&&r("div",{className:"flex justify-center mb-8",children:r("img",{src:n,alt:"Logo",className:"h-12"})}),t&&r("p",{className:"mb-4 text-center text-xs text-foreground-subtle truncate",children:t}),u("form",{onSubmit:x,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[b&&r("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:b}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Username"}),r("input",{type:"text",value:a,onChange:v=>i(v.target.value),autoComplete:"username",required:!0,className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary"})]}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Password"}),u("div",{className:"relative",children:[r("input",{type:d?"text":"password",value:l,onChange:v=>c(v.target.value),autoComplete:"current-password",required:!0,className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary"}),r("button",{type:"button",onClick:()=>f(v=>!v),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",tabIndex:-1,children:d?r(hC,{className:"h-4 w-4"}):r(mC,{className:"h-4 w-4"})})]})]}),u("button",{type:"submit",disabled:p,className:"w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2",children:[p&&r(gC,{className:"h-4 w-4 animate-spin"}),p?"Logging in...":"Log in"]})]})]})})}const Ui="camstack_dev_token",Rh=Oe(null);function bC(){const e=ve(Rh);if(!e)throw new Error("useDevShell must be used within a DevShell");return e}function xC(){return typeof window>"u"?null:localStorage.getItem(Ui)}function yC({className:e}){return u("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[r("circle",{cx:"12",cy:"12",r:"4"}),r("path",{d:"M12 2v2"}),r("path",{d:"M12 20v2"}),r("path",{d:"m4.93 4.93 1.41 1.41"}),r("path",{d:"m17.66 17.66 1.41 1.41"}),r("path",{d:"M2 12h2"}),r("path",{d:"M20 12h2"}),r("path",{d:"m6.34 17.66-1.41 1.41"}),r("path",{d:"m19.07 4.93-1.41 1.41"})]})}function vC({className:e}){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:r("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function wC({children:e,serverUrl:t,title:n,token:o,onLogout:s}){const a=Mr(),i=U(()=>{const m=t.replace(/^http/,"ws")+"/trpc",h=J1({url:m,connectionParams:()=>({token:o})});return[ew({condition:g=>g.type==="subscription",true:tw({client:h,transformer:Li}),false:Ff({url:`${t}/trpc`,transformer:Li,headers:()=>({authorization:`Bearer ${o}`})})})]},[t,o]),l=U(()=>Bf({links:i}),[i]),c=U(()=>C.createClient({links:i}),[i]),d=U(()=>Hf({serverUrl:t,token:o}),[t,o]);Z(()=>(d.init().catch(()=>{}),()=>{d.close()}),[d]);const f=U(()=>new Rf,[]),p=U(()=>({trpc:l,token:o,logout:s}),[l,o,s]);return r(ec,{system:d,children:r(C.Provider,{client:c,queryClient:f,children:r(Of,{client:f,children:r(Rh.Provider,{value:p,children:u("div",{className:"min-h-screen bg-background text-foreground",children:[u("div",{className:"flex items-center justify-between border-b border-border bg-surface px-4 py-2",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"rounded bg-warning/20 px-2 py-0.5 text-xs font-bold text-warning",children:"DEV MODE"}),n&&r("span",{className:"text-sm font-medium text-foreground",children:n}),r("span",{className:"text-xs text-foreground-subtle",children:t})]}),u("div",{className:"flex items-center gap-2",children:[u("button",{type:"button",onClick:a.toggleMode,className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",title:`Theme: ${a.mode}`,children:[a.resolvedMode==="dark"?r(yC,{className:"h-3.5 w-3.5"}):r(vC,{className:"h-3.5 w-3.5"}),a.mode==="dark"?"Dark":a.mode==="light"?"Light":"System"]}),r("button",{type:"button",onClick:s,className:"rounded-md px-2.5 py-1 text-xs font-medium text-danger hover:bg-danger/10 transition-colors",children:"Logout"})]})]}),r("div",{className:"p-4",children:e({trpc:l,theme:a})})]})})})})})}function Oh({children:e,serverUrl:t="https://localhost:4443",title:n}){const[o,s]=_(xC),a=q(async(l,c)=>{const p=await Bf({links:[Ff({url:`${t}/trpc`,transformer:Li})]}).auth.login.mutate({username:l,password:c});if(!p.token)throw new Error("No token returned");localStorage.setItem(Ui,p.token),s(p.token)},[t]),i=q(()=>{localStorage.removeItem(Ui),s(null)},[]);return o?r(ws,{children:r(wC,{serverUrl:t,title:n,token:o,onLogout:i,children:e})}):r(ws,{children:r(Th,{onLogin:a,serverUrl:t})})}function NC(e,t={}){const{serverUrl:n="https://localhost:4443",title:o,rootId:s="root"}=t,a=document.getElementById(s);if(!a){console.error(`[mountAddonPage] Element #${s} not found`);return}Lf(a).render(Me(Oh,{serverUrl:n,title:o,children:({trpc:i,theme:l})=>Me(e,{trpc:i,theme:{isDark:l.resolvedMode==="dark"},navigate:c=>{console.log("[dev] navigate:",c)}})}))}const zh=cn("camstack:custom-field-renderers",{});function Bh({renderers:e,children:t}){return r(zh.Provider,{value:e,children:t})}function Fh(e){return ve(zh)[e]??null}const ac=cn("camstack:device-context",null);function jh({deviceId:e,device:t,children:n}){const o={deviceId:e,device:t??null};return r(ac.Provider,{value:o,children:n})}function dn(){return ve(ac)?.deviceId??null}function ic(){return ve(ac)?.device??null}const kC=C.accessories.getStatus.useQuery,lc=C.addonPages.listPages.useQuery,ra=C.addons.list.useQuery,SC=C.addons.getLogs.useQuery,CC=C.addons.listPackages.useQuery,cc=C.addons.installPackage.useMutation,MC=C.addons.installFromWorkspace.useMutation,IC=C.addons.isWorkspaceAvailable.useQuery,AC=C.addons.listWorkspacePackages.useQuery,Hh=C.addons.uninstallPackage.useMutation,Vh=C.addons.reloadPackages.useMutation,qh=C.addons.searchAvailable.useQuery,dc=C.addons.listUpdates.useQuery,Ki=C.addons.updatePackage.useMutation,PC=C.addons.rollbackPackage.useMutation,Qh=C.addons.forceRefresh.useMutation,Uh=C.addons.restartServer.useMutation,Kh=C.addons.getVersions.useQuery,oa=C.addons.restartAddon.useMutation,Gh=C.addons.retryLoad.useMutation,Wh=C.addons.getAutoUpdateSettings.useQuery,EC=C.addons.setAutoUpdateSettings.useMutation,Yh=C.addons.getAddonAutoUpdate.useQuery,Zh=C.addons.setAddonAutoUpdate.useMutation,Xh=C.addons.applyAutoUpdateToAll.useMutation,$C=C.addons.custom.useMutation,_C=C.addons.onAddonLogs.useSubscription,uc=C.addonSettings.getGlobalSettings.useQuery,Jh=C.addonSettings.updateGlobalSettings.useMutation,DC=C.addonSettings.getDeviceSettings.useQuery,eg=C.addonSettings.updateDeviceSettings.useMutation,tg=C.addonWidgets.listWidgets.useQuery,LC=C.alerts.emit.useMutation,TC=C.alerts.update.useMutation,ng=C.alerts.list.useQuery,rg=C.alerts.getUnreadCount.useQuery,og=C.alerts.markRead.useMutation,sg=C.alerts.markAllRead.useMutation,ag=C.alerts.dismiss.useMutation,RC=C.audioAnalysis.resolveDeviceSettings.useQuery,OC=C.audioAnalysis.getDeviceSettingsContribution.useQuery,zC=C.audioAnalysis.getDeviceLiveContribution.useQuery,BC=C.audioAnalysis.applyDeviceSettingsPatch.useMutation,FC=C.audioAnalyzer.analyseChunk.useMutation,jC=C.audioAnalyzer.classify.useQuery,HC=C.audioAnalyzer.isReady.useQuery,VC=C.audioAnalyzer.dispose.useMutation,ig=C.audioAnalyzer.reprobeAudioEngine.useMutation,qC=C.audioCodec.listSupportedCodecs.useQuery,QC=C.audioCodec.canHandle.useQuery,UC=C.audioCodec.createDecodeSession.useMutation,KC=C.audioCodec.createEncodeSession.useMutation,GC=C.audioCodec.closeSession.useMutation,WC=C.audioCodec.pushEncodedFrame.useMutation,YC=C.audioCodec.pullPcm.useQuery,ZC=C.audioCodec.pushPcm.useMutation,XC=C.audioCodec.pullEncoded.useQuery,JC=C.audioCodec.flushEncode.useMutation,e3=C.audioCodec.listActiveSessions.useQuery,t3=C.audioMetrics.getCurrentSnapshot.useQuery,n3=C.audioMetrics.getHistory.useQuery,pc=C.authentication.listProviders.useQuery,r3=C.authentication.setProviderEnabled.useMutation,fc=C.backup.listDestinations.useQuery,lg=C.backup.trigger.useMutation,o3=C.backup.list.useQuery,cg=C.backup.listLocations.useQuery,dg=C.backup.getEntries.useQuery,ug=C.backup.restore.useMutation,pg=C.backup.delete.useMutation,mc=C.backup.listArchives.useQuery,fg=C.backup.upsertDestinationPolicy.useMutation,mg=C.backup.previewSchedule.useQuery,s3=C.battery.getStatus.useQuery,a3=C.brightness.setBrightness.useMutation,i3=C.brightness.getStatus.useQuery,l3=C.cameraStreams.getCameraStreams.useQuery,c3=C.cameraStreams.getBrokerStreams.useQuery,d3=C.cameraStreams.getRtspEntries.useQuery,u3=C.decoder.supportsCodec.useQuery,p3=C.decoder.getInfo.useQuery,f3=C.decoder.createSession.useQuery,m3=C.decoder.destroySession.useQuery,h3=C.decoder.pushPacket.useQuery,g3=C.decoder.openStream.useQuery,b3=C.decoder.pullFrames.useQuery,x3=C.decoder.updateConfig.useQuery,y3=C.decoder.getStats.useQuery,v3=C.decoder.listActiveSessions.useQuery,hg=C.decoder.reprobeHwaccel.useMutation,w3=C.detectionPipeline.getDeviceSettingsContribution.useQuery,N3=C.detectionPipeline.getDeviceLiveContribution.useQuery,k3=C.detectionPipeline.applyDeviceSettingsPatch.useMutation,gg=C.deviceDiscovery.listDiscovered.useQuery,bg=C.deviceDiscovery.refreshDiscovery.useMutation,S3=C.deviceDiscovery.adoptDevice.useMutation,C3=C.deviceDiscovery.releaseDevice.useMutation,M3=C.deviceDiscovery.getStatus.useQuery,I3=C.deviceManager.allocateDeviceId.useMutation,A3=C.deviceManager.registerDevice.useMutation,P3=C.deviceManager.removeDevice.useMutation,E3=C.deviceManager.persistConfig.useMutation,$3=C.deviceManager.loadConfig.useQuery,_3=C.deviceManager.loadRuntimeState.useQuery,D3=C.deviceManager.loadMeta.useQuery,xg=C.deviceManager.setName.useMutation,yg=C.deviceManager.setLocation.useMutation,L3=C.deviceManager.setMetadata.useMutation,vg=C.deviceManager.listLocations.useQuery,T3=C.deviceManager.addLocation.useMutation,R3=C.deviceManager.removeLocation.useMutation,O3=C.deviceManager.setDisabled.useMutation,z3=C.deviceManager.listPersistedByAddon.useQuery,Xn=C.deviceManager.listAll.useQuery,Bn=C.deviceManager.getDevice.useQuery,wg=C.deviceManager.getChildren.useQuery,B3=C.deviceManager.getStreamSources.useQuery,F3=C.deviceManager.getConfigSchema.useQuery,j3=C.deviceManager.getSettingsSchema.useQuery,H3=C.deviceManager.updateConfig.useMutation,Ng=C.deviceManager.enable.useMutation,kg=C.deviceManager.disable.useMutation,Sg=C.deviceManager.remove.useMutation,V3=C.deviceManager.getStreamProfileMap.useQuery,q3=C.deviceManager.setStreamProfileMap.useMutation,Q3=C.deviceManager.probeStreams.useMutation,Cg=C.deviceManager.getBindings.useQuery,U3=C.deviceManager.getAllBindings.useQuery,Mg=C.deviceManager.setWrapperActive.useMutation,K3=C.deviceManager.listWrappersForCap.useQuery,Ig=C.deviceManager.listBindableCapsForDeviceType.useQuery,G3=C.deviceManager.getDeviceSettingsAggregate.useQuery,W3=C.deviceManager.getDeviceLiveInfoAggregate.useQuery,hc=C.deviceManager.getDeviceAggregate.useQuery,Y3=C.deviceManager.updateDeviceField.useMutation,Ag=C.deviceManager.updateDeviceFieldsBatch.useMutation,gc=C.deviceManager.discoverDevices.useMutation,Pg=C.deviceManager.adoptDevice.useMutation,Eg=C.deviceManager.getCreationSchema.useQuery,$g=C.deviceManager.createDevice.useMutation,bc=C.deviceManager.testCreationField.useMutation,Z3=C.deviceManager.testField.useMutation,X3=C.deviceManager.getDeviceStatusAggregate.useQuery,J3=C.deviceOps.getStreamSources.useQuery,eM=C.deviceOps.getConfigEntries.useQuery,tM=C.deviceOps.setConfig.useMutation,nM=C.deviceOps.removeDevice.useMutation,rM=C.deviceOps.getSettingsSchema.useQuery,oM=C.deviceProvider.start.useMutation,sM=C.deviceProvider.stop.useMutation,aM=C.deviceProvider.getStatus.useQuery,iM=C.deviceProvider.getDevices.useQuery,lM=C.deviceProvider.supportsDiscovery.useQuery,cM=C.deviceProvider.discoverDevices.useMutation,dM=C.deviceProvider.adoptDiscoveredDevice.useMutation,uM=C.deviceProvider.supportsManualCreation.useQuery,pM=C.deviceProvider.getChildCreationSchema.useQuery,fM=C.deviceProvider.createDevice.useMutation,mM=C.deviceProvider.testCreationField.useMutation,hM=C.deviceState.getSnapshot.useQuery,gM=C.deviceState.getCapSlice.useQuery,bM=C.deviceState.getAllSnapshots.useQuery,xM=C.deviceState.setCapSlice.useMutation,yM=C.doorbell.getStatus.useQuery,vM=C.events.getEvents.useQuery,wM=C.events.getEventThumbnail.useQuery,NM=C.events.getEventClipUrl.useQuery,sa=C.integrations.list.useQuery,_g=C.integrations.get.useQuery,Dg=C.integrations.getByAddonId.useQuery,Lg=C.integrations.create.useMutation,Tg=C.integrations.update.useMutation,Rg=C.integrations.delete.useMutation,kM=C.integrations.getSettings.useQuery,SM=C.integrations.setSettings.useMutation,Og=C.integrations.getAvailableTypes.useQuery,zg=C.integrations.testConnection.useMutation,Bg=C.intercom.startSession.useMutation,Fg=C.intercom.handleAnswer.useMutation,jg=C.intercom.stopSession.useMutation,CM=C.intercom.getStatus.useQuery,Hg=C.localNetwork.list.useQuery,MM=C.localNetwork.getPreferred.useQuery,Vg=C.localNetwork.getConnectionEndpoints.useQuery,qg=C.localNetwork.getAllowedAddresses.useQuery,Qg=C.localNetwork.setAllowedAddresses.useMutation,Ug=C.localNetwork.resetAllowlistToBestMatch.useMutation,Kg=C.meshOrchestrator.listProviders.useQuery,Gg=C.meshOrchestrator.joinProvider.useMutation,Wg=C.meshOrchestrator.leaveProvider.useMutation,IM=C.metricsProvider.collectSnapshot.useQuery,AM=C.metricsProvider.getCached.useQuery,PM=C.metricsProvider.getCurrent.useQuery,EM=C.metricsProvider.getDiskSpace.useQuery,$M=C.metricsProvider.getGpuInfo.useQuery,_M=C.metricsProvider.getCpuTemperature.useQuery,DM=C.metricsProvider.getProcessStats.useQuery,LM=C.metricsProvider.listAddonInstances.useQuery,TM=C.metricsProvider.getAddonStats.useQuery,Yg=C.metricsProvider.listNodeProcesses.useQuery,Zg=C.metricsProvider.killProcess.useMutation,RM=C.motion.isDetected.useQuery,OM=C.motion.getStatus.useQuery,zM=C.motionDetection.analyze.useMutation,BM=C.motionDetection.removeCamera.useMutation,FM=C.motionDetection.reset.useMutation,jM=C.motionDetection.getDeviceSettingsContribution.useQuery,HM=C.motionDetection.getDeviceLiveContribution.useQuery,VM=C.motionDetection.applyDeviceSettingsPatch.useMutation,qM=C.motionTrigger.setMotionTrigger.useMutation,QM=C.motionTrigger.getStatus.useQuery,UM=C.nativeObjectDetection.getStatus.useQuery,xc=C.networkQuality.getDeviceStats.useQuery,KM=C.networkQuality.getAllStats.useQuery,GM=C.networkQuality.reportClientStats.useMutation,Mn=C.nodes.topology.useQuery,WM=C.nodes.deployAddon.useMutation,Xg=C.nodes.undeployAddon.useMutation,aa=C.nodes.restartAddon.useMutation,Jg=C.nodes.restartProcess.useMutation,eb=C.nodes.restartNode.useMutation,YM=C.nodes.shutdownNode.useMutation,tb=C.nodes.renameNode.useMutation,nb=C.nodes.clusterAddonStatus.useQuery,rb=C.nodes.setProcessLogLevel.useMutation,ZM=C.nodes.executeQuery.useMutation,XM=C.notificationOutput.send.useMutation,JM=C.notificationOutput.sendTest.useMutation,e4=C.osd.setOverlay.useMutation,t4=C.osd.getStatus.useQuery,n4=C.pipelineAnalytics.getActiveTracks.useQuery,r4=C.pipelineAnalytics.getTrack.useQuery,o4=C.pipelineAnalytics.listTracks.useQuery,s4=C.pipelineAnalytics.clearTracks.useMutation,a4=C.pipelineAnalytics.getMotionEvents.useQuery,i4=C.pipelineAnalytics.getObjectEvents.useQuery,l4=C.pipelineAnalytics.getAudioEvents.useQuery,c4=C.pipelineAnalytics.getEventMedia.useQuery,d4=C.pipelineAnalytics.getTrackMedia.useQuery,u4=C.pipelineAnalytics.getDeviceSettingsContribution.useQuery,p4=C.pipelineAnalytics.getDeviceLiveContribution.useQuery,f4=C.pipelineAnalytics.applyDeviceSettingsPatch.useMutation,ob=C.pipelineExecutor.getAvailableEngines.useQuery,sb=C.pipelineExecutor.getSelectedEngine.useQuery,m4=C.pipelineExecutor.getDefaultSteps.useQuery,ab=C.pipelineExecutor.reprobeEngine.useMutation,h4=C.pipelineExecutor.getVideoPipelineSteps.useQuery,g4=C.pipelineExecutor.setVideoPipelineSteps.useMutation,ko=C.pipelineExecutor.getSchema.useQuery,b4=C.pipelineExecutor.getGlobalSteps.useQuery,x4=C.pipelineExecutor.getGlobalPipelineConfig.useQuery,y4=C.pipelineExecutor.getOrchestratorConfigSchema.useQuery,v4=C.pipelineExecutor.listTemplates.useQuery,w4=C.pipelineExecutor.saveTemplate.useMutation,N4=C.pipelineExecutor.updateTemplate.useMutation,k4=C.pipelineExecutor.deleteTemplate.useMutation,S4=C.pipelineExecutor.getCapabilities.useQuery,C4=C.pipelineExecutor.getAddonModels.useQuery,ib=C.pipelineExecutor.downloadModel.useMutation,lb=C.pipelineExecutor.deleteModel.useMutation,M4=C.pipelineExecutor.detect.useQuery,I4=C.pipelineExecutor.runPipeline.useMutation,A4=C.pipelineExecutor.runPipelineBatch.useMutation,P4=C.pipelineExecutor.cacheFrameInPool.useMutation,E4=C.pipelineExecutor.inferCached.useMutation,$4=C.pipelineExecutor.uncacheFrame.useMutation,_4=C.pipelineExecutor.getEffectiveTuning.useQuery,cb=C.pipelineExecutor.listLoadedEngines.useQuery,D4=C.pipelineExecutor.spinEngine.useMutation,db=C.pipelineExecutor.killEngine.useMutation,L4=C.pipelineExecutor.listReferenceImages.useQuery,T4=C.pipelineExecutor.getReferenceImage.useQuery,R4=C.pipelineExecutor.getReferenceAudioFiles.useQuery,O4=C.pipelineExecutor.getReferenceAudio.useQuery,z4=C.pipelineExecutor.getAudioCapabilities.useQuery,B4=C.pipelineExecutor.runAudioTest.useMutation,F4=C.pipelineExecutor.getDetectionConfigSchema.useQuery,ub=C.pipelineOrchestrator.assignPipeline.useMutation,pb=C.pipelineOrchestrator.unassignPipeline.useMutation,fb=C.pipelineOrchestrator.rebalance.useMutation,ia=C.pipelineOrchestrator.getPipelineAssignments.useQuery,la=C.pipelineOrchestrator.getPipelineAssignment.useQuery,mb=C.pipelineOrchestrator.getAgentLoad.useQuery,j4=C.pipelineOrchestrator.getGlobalMetrics.useQuery,H4=C.pipelineOrchestrator.getCameraMetrics.useQuery,hb=C.pipelineOrchestrator.getCapabilityBindings.useQuery,gb=C.pipelineOrchestrator.setCapabilityBinding.useMutation,bb=C.pipelineOrchestrator.assignDecoder.useMutation,xb=C.pipelineOrchestrator.unassignDecoder.useMutation,yb=C.pipelineOrchestrator.getDecoderAssignments.useQuery,vb=C.pipelineOrchestrator.assignAudio.useMutation,wb=C.pipelineOrchestrator.unassignAudio.useMutation,V4=C.pipelineOrchestrator.getAudioAssignment.useQuery,Nb=C.pipelineOrchestrator.getAudioNodeLoad.useQuery,kb=C.pipelineOrchestrator.getAudioAssignments.useQuery,q4=C.pipelineOrchestrator.getDecoderAssignment.useQuery,yc=C.pipelineOrchestrator.getAgentSettings.useQuery,Er=C.pipelineOrchestrator.listAgentSettings.useQuery,vc=C.pipelineOrchestrator.setAgentAddonDefaults.useMutation,Sb=C.pipelineOrchestrator.removeAgentSettings.useMutation,wc=C.pipelineOrchestrator.getCameraSettings.useQuery,Cb=C.pipelineOrchestrator.setCameraStepToggle.useMutation,Q4=C.pipelineOrchestrator.getCameraStepOverrides.useQuery,Mb=C.pipelineOrchestrator.setCameraStepOverride.useMutation,Ib=C.pipelineOrchestrator.setCameraPipelineForAgent.useMutation,Ab=C.pipelineOrchestrator.resolvePipeline.useQuery,Pb=C.pipelineOrchestrator.listTemplates.useQuery,U4=C.pipelineOrchestrator.saveTemplate.useMutation,Eb=C.pipelineOrchestrator.updateTemplate.useMutation,$b=C.pipelineOrchestrator.deleteTemplate.useMutation,K4=C.pipelineOrchestrator.getDeviceSettingsContribution.useQuery,G4=C.pipelineOrchestrator.getDeviceLiveContribution.useQuery,W4=C.pipelineOrchestrator.applyDeviceSettingsPatch.useMutation,Y4=C.pipelineRunner.attachCamera.useMutation,Z4=C.pipelineRunner.detachCamera.useMutation,X4=C.pipelineRunner.reportMotion.useMutation,J4=C.pipelineRunner.getLocalLoad.useQuery,eI=C.pipelineRunner.getLocalMetrics.useQuery,Nc=C.pipelineRunner.getCameraMetrics.useQuery,tI=C.pipelineRunner.getAllCameraMetrics.useQuery,_b=C.pipelineRunner.getLocalCameras.useQuery,nI=C.platformProbe.getCapabilities.useQuery,rI=C.platformProbe.getHardware.useQuery,oI=C.platformProbe.resolveInferenceConfig.useQuery,sI=C.platformProbe.resolveHwAccel.useQuery,aI=C.ptz.move.useMutation,iI=C.ptz.continuousMove.useMutation,lI=C.ptz.stop.useMutation,cI=C.ptz.getPresets.useQuery,dI=C.ptz.goToPreset.useMutation,uI=C.ptz.goHome.useMutation,pI=C.ptz.getPosition.useQuery,fI=C.ptz.getStatus.useQuery,Db=C.ptzAutotrack.getStatus.useQuery,Lb=C.ptzAutotrack.setEnabled.useMutation,mI=C.ptzAutotrack.getSettings.useQuery,Tb=C.ptzAutotrack.setSettings.useMutation,Rb=C.reboot.reboot.useMutation,hI=C.recording.getSegments.useQuery,gI=C.recording.getPlaybackUrl.useQuery,bI=C.recording.getThumbnailAt.useQuery,xI=C.recordingEngine.getStatus.useQuery,Ob=C.recordingEngine.enable.useMutation,zb=C.recordingEngine.disable.useMutation,Bb=C.recordingEngine.getConfig.useQuery,yI=C.recordingEngine.updateConfig.useMutation,vI=C.recordingEngine.getPlaylist.useQuery,wI=C.recordingEngine.getThumbnail.useQuery,Fb=C.recordingEngine.getSegments.useQuery,NI=C.recordingEngine.getAvailability.useQuery,kI=C.recordingEngine.estimateStorage.useQuery,SI=C.recordingEngine.estimateGlobalStorage.useQuery,jb=C.recordingEngine.getStorageUsage.useQuery,CI=C.recordingEngine.setPolicy.useMutation,MI=C.recordingEngine.getPolicy.useQuery,Hb=C.recordingEngine.getPolicyStatus.useQuery,Vb=C.recordingEngine.getRetentionConfig.useQuery,II=C.recordingEngine.updateRetentionConfig.useMutation,AI=C.recordingEngine.getMotionStats.useQuery,qb=C.remoteAccess.listProviders.useQuery,Qb=C.remoteAccess.startProvider.useMutation,Ub=C.remoteAccess.stopProvider.useMutation,PI=C.settingsStore.get.useQuery,EI=C.settingsStore.set.useMutation,$I=C.settingsStore.query.useQuery,_I=C.settingsStore.insert.useMutation,DI=C.settingsStore.update.useMutation,LI=C.settingsStore.delete.useMutation,TI=C.settingsStore.count.useQuery,RI=C.settingsStore.isEmpty.useQuery,OI=C.settingsStore.declareCollection.useMutation,zI=C.snapshot.getSnapshot.useQuery,BI=C.snapshot.invalidateCache.useMutation,FI=C.snapshot.getStatus.useQuery,jI=C.snapshot.getDeviceSettingsContribution.useQuery,HI=C.snapshot.getDeviceLiveContribution.useQuery,VI=C.snapshot.applyDeviceSettingsPatch.useMutation,qI=C.snapshotProvider.supportsDevice.useQuery,QI=C.snapshotProvider.getSnapshot.useQuery,UI=C.storage.resolve.useQuery,KI=C.storage.write.useMutation,GI=C.storage.read.useQuery,WI=C.storage.exists.useQuery,YI=C.storage.list.useQuery,ZI=C.storage.delete.useMutation,XI=C.storage.getAvailableSpace.useQuery,JI=C.storage.beginUpload.useMutation,eA=C.storage.writeChunk.useMutation,tA=C.storage.finalizeUpload.useMutation,nA=C.storage.abortUpload.useMutation,rA=C.storage.beginDownload.useMutation,oA=C.storage.readChunk.useQuery,sA=C.storage.endDownload.useMutation,Kb=C.storage.listLocations.useQuery,aA=C.storage.getDefaultLocation.useQuery,ca=C.storage.upsertLocation.useMutation,Gb=C.storage.deleteLocation.useMutation,iA=C.storage.testLocation.useQuery,kc=C.storage.listProviders.useQuery,lA=C.storage.testConfig.useQuery,cA=C.streamBroker.publishCameraStream.useMutation,dA=C.streamBroker.retractCameraStream.useMutation,uA=C.streamBroker.assignProfile.useMutation,pA=C.streamBroker.unassignProfile.useMutation,fA=C.streamBroker.listAllCameraStreams.useQuery,mA=C.streamBroker.listAllProfileSlots.useQuery,hA=C.streamBroker.getBrokerStats.useQuery,gA=C.streamBroker.listClients.useQuery,bA=C.streamBroker.killClient.useMutation,xA=C.streamBroker.restartProfile.useMutation,yA=C.streamBroker.getStreamUrl.useQuery,vA=C.streamBroker.getBroker.useQuery,wA=C.streamBroker.setPreBufferDuration.useMutation,NA=C.streamBroker.getPreBufferInfo.useQuery,kA=C.streamBroker.getRtspPort.useQuery,SA=C.streamBroker.getAllRtspEntries.useQuery,CA=C.streamBroker.getRtspEntry.useQuery,Wb=C.streamBroker.regenerateRtspToken.useMutation,MA=C.streamBroker.setRtspEnabled.useMutation,IA=C.streamBroker.isRtspEnabled.useQuery,AA=C.streamBroker.getDeviceSettingsContribution.useQuery,PA=C.streamBroker.getDeviceLiveContribution.useQuery,EA=C.streamBroker.applyDeviceSettingsPatch.useMutation,$A=C.switch.setState.useMutation,_A=C.switch.getStatus.useQuery,DA=C.system.info.useQuery,LA=C.system.health.useQuery,TA=C.system.featureFlags.useQuery,RA=C.system.networkAddresses.useQuery,OA=C.system.getRetentionConfig.useQuery,zA=C.system.setRetentionConfig.useMutation,BA=C.system.forceRetentionCleanup.useMutation,Yb=C.toast.onToast.useSubscription,Zb=C.turnOrchestrator.listProviders.useQuery,Xb=C.turnOrchestrator.getAllServers.useQuery,Jb=C.turnOrchestrator.setProviderEnabled.useMutation,FA=C.turnProvider.getTurnServers.useQuery,Sc=C.userManagement.listUsers.useQuery,ex=C.userManagement.createUser.useMutation,tx=C.userManagement.updateUser.useMutation,nx=C.userManagement.deleteUser.useMutation,Cc=C.userManagement.resetPassword.useMutation,jA=C.userManagement.validateCredentials.useMutation,rx=C.userManagement.listApiKeys.useQuery,HA=C.userManagement.createApiKey.useMutation,ox=C.userManagement.revokeApiKey.useMutation,VA=C.userManagement.validateApiKey.useMutation,sx=C.userManagement.createScopedToken.useMutation,ax=C.userManagement.revokeScopedToken.useMutation,qA=C.userManagement.validateScopedToken.useQuery,ix=C.userManagement.listScopedTokens.useQuery,QA=C.webrtcSession.listStreams.useQuery,UA=C.webrtcSession.createSession.useMutation,KA=C.webrtcSession.handleAnswer.useMutation,GA=C.webrtcSession.closeSession.useMutation,WA=C.webrtcSession.hasAdaptiveBitrate.useQuery,YA=C.zoneAnalytics.getCurrentSnapshot.useQuery,ZA=C.zoneAnalytics.getZoneHistory.useQuery,XA=C.zoneAnalytics.getCameraHistory.useQuery,JA=C.zoneAnalytics.getUnzonedHistory.useQuery,eP=C.zoneRules.listRules.useQuery,tP=C.zoneRules.setRules.useMutation,nP=C.zones.listZones.useQuery,rP=C.zones.addZone.useMutation,oP=C.zones.removeZone.useMutation,sP=C.zones.updateZone.useMutation,lx=cn("camstack:widget-registry",null),Ms=new Map,Bo=new Map,uu=new Set;function aP(e){if(!e||typeof e!="object")return!1;const t=e.default;return t!==null&&typeof t=="object"}function iP(e){if(!e||typeof e!="object")return typeof e;const t=e,n=Object.getPrototypeOf(t),o=n&&typeof n=="object"?n.constructor?.name:void 0;return{ownKeys:Object.keys(t),allKeys:Object.getOwnPropertyNames(t),proto:typeof o=="string"?o:void 0}}async function lP(e,t){const n=Ms.get(e);if(n)return n;const o=Bo.get(e);if(o)return o;uu.has(e)||(Tl(),pr.registerRemotes([{name:e,entry:t,type:"module"}],{force:!1}),uu.add(e));const s=pr.loadRemote(`${e}/widgets`).then(a=>{if(!aP(a)){const l=iP(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 Ms.set(e,i),Bo.delete(e),i}).catch(a=>{throw Bo.delete(e),a});return Bo.set(e,s),s}const cP=3e4,dP=2e3;function cx({children:e}){const t=ke(),n=ne(Date.now()),{data:o}=tg(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:l=>{const c=l.state.data;return c&&c.length>0||Date.now()-n.current>=cP?!1:dP}});ct("addon.widget-ready",()=>{t.invalidateQueries({queryKey:[["addonWidgets","listWidgets"]]})});const[s,a]=_(0);Z(()=>{if(!o)return;let l=!1;const c=new Set;for(const d of o){if(c.has(d.remoteName)||(c.add(d.remoteName),Ms.has(d.remoteName)))continue;const f=d.bundleUrl;lP(d.remoteName,f).then(()=>{l||a(p=>p+1)}).catch(p=>{const m=p instanceof Error?p.message:String(p);(typeof globalThis<"u"?globalThis.console:void 0)?.error?.("[WidgetRegistry] Failed to load widget remote",{remoteName:d.remoteName,entryUrl:f,reason:m})})}return()=>{l=!0}},[o]);const i=U(()=>{const l=o??[],c=new Map;for(const f of l)c.set(`${f.addonId}/${f.stableId}`,f);const d=(f,p)=>({widgetId:f,addonId:p.addonId,stableId:p.stableId,label:p.label,description:p.description,icon:p.icon,remoteName:p.remoteName,bundleUrl:p.bundleUrl,hosts:p.hosts,requires:p.requires,defaultSize:p.defaultSize,allowedSizes:p.allowedSizes,defaultColumns:p.defaultColumns,defaultRows:p.defaultRows});return{resolve:f=>{const p=c.get(f);if(!p)return;const m=Ms.get(p.remoteName);if(!m)return null;const h=m[p.stableId];if(h)return h},metadata:f=>{const p=c.get(f);if(p)return d(f,p)},listAll:()=>{const f=[];for(const[p,m]of c)f.push(d(p,m));return f}}},[o,s]);return r(lx.Provider,{value:i,children:e})}function dx(e){return da().resolve(e)}function ux(e){return da().metadata(e)}function px(){return da().listAll()}function da(){const e=fx();if(!e)throw new Error("useWidgetRegistry(): no <WidgetRegistryProvider> in tree");return e}function fx(){return uP(lx)}function uP(e){return ve(e)}function at(e){const{widgetId:t,host:n="device-tab",config:o,deviceId:s,integrationId:a,instanceId:i,size:l,columns:c,rows:d}=e,f=dx(t),p=ux(t),m=U(()=>i??t,[i,t]);if(f===void 0&&p===void 0)return r(Fo,{widgetId:t,reason:"unknown"});if(f===void 0)return r(Fo,{widgetId:t,reason:"missing-export"});if(f===null)return r(pP,{});if(p){if(p.requires.deviceContext&&s===void 0)return r(Fo,{widgetId:t,reason:"missing-device-context"});if(p.requires.integrationContext&&a===void 0)return r(Fo,{widgetId:t,reason:"missing-integration-context"})}return r(f,{instanceId:m,host:n,config:o,deviceId:s,integrationId:a,size:l,columns:c,rows:d})}function pP(){return u("div",{className:"rounded-lg border border-border bg-surface/40 p-4 animate-pulse",children:[r("div",{className:"h-3 w-24 bg-foreground-subtle/20 rounded mb-2"}),r("div",{className:"h-2 w-full bg-foreground-subtle/10 rounded mb-1"}),r("div",{className:"h-2 w-3/4 bg-foreground-subtle/10 rounded"})]})}function Fo({widgetId:e,reason:t}){const n=t==="unknown"?`Widget "${e}" not registered`:t==="missing-export"?`Widget "${e}" bundle does not export this stableId`:t==="missing-device-context"?`Widget "${e}" requires a deviceId`:`Widget "${e}" requires an integrationId`;return r("div",{className:"rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",children:n})}const Jn="w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none disabled:opacity-50 disabled:cursor-not-allowed",ua="block text-[11px] font-medium text-foreground mb-1",fP="text-[10px] text-foreground-subtle mt-0.5";function qe({label:e,description:t,required:n,span:o,children:s,translationFn:a}){const i=o===2?"col-span-2":o===3?"col-span-3":o===4?"col-span-4":"col-span-1",l=Tt(e,a),c=Tt(t,a);return u("div",{className:i,children:[l!==void 0&&l!==""&&u("label",{className:ua,children:[l,n&&r("span",{className:"text-danger ml-0.5",children:"*"})]}),s,c&&r("p",{className:fP,children:c})]})}function mP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:r("input",{type:e.inputType??"text",className:Jn,value:t==null?"":String(t),placeholder:e.placeholder,maxLength:e.maxLength,pattern:e.pattern,disabled:o||e.disabled,onChange:a=>n(a.target.value)})})}function hP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const[a,i]=_(t==null?"":String(t)),l=ne(!1);Z(()=>{if(l.current)return;const d=t==null?"":String(t);i(d)},[t]);const c=d=>{if(i(d),d===""||d==="-"){n(void 0);return}const f=Number(d);Number.isNaN(f)||n(f)};return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"flex items-center gap-1",children:[r("input",{type:"number",className:Jn,value:a,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step,disabled:o||e.disabled,onFocus:()=>{l.current=!0},onBlur:()=>{l.current=!1},onChange:d=>c(d.target.value)}),e.unit&&r("span",{className:"text-xs text-foreground-subtle whitespace-nowrap",children:e.unit})]})})}function gP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=!!t,i=o||e.disabled;return e.style==="checkbox"?r(qe,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[r("input",{type:"checkbox",className:"h-3.5 w-3.5 rounded border-border accent-primary",checked:a,disabled:i,onChange:l=>n(l.target.checked)}),r("span",{className:"text-xs font-medium text-foreground",children:Tt(e.label,s)}),e.required&&r("span",{className:"text-danger",children:"*"})]})}):r(qe,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"flex items-center justify-between",children:[u("span",{className:ua+" mb-0",children:[Tt(e.label,s),e.required&&r("span",{className:"text-danger ml-0.5",children:"*"})]}),r("button",{type:"button",role:"switch","aria-checked":a,disabled:i,onClick:()=>!i&&n(!a),className:["relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150",a?"bg-primary":"bg-foreground-subtle/30",i?"opacity-50 cursor-not-allowed":"cursor-pointer"].join(" "),children:r("span",{className:["inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150",a?"translate-x-4":"translate-x-0.5"].join(" ")})})]})})}function bP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=e.options.some(i=>i.value==="");return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("select",{className:Jn,value:t==null?"":String(t),disabled:o||e.disabled,onChange:i=>n(i.target.value),children:[!e.required&&!a&&r("option",{value:"",children:"— Select —"}),e.options.map(i=>r("option",{value:i.value,children:i.label},i.value))]})})}function xP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=Array.isArray(t)?t:[],i=l=>{if(a.includes(l))n(a.filter(c=>c!==l));else{if(e.maxItems!==void 0&&a.length>=e.maxItems)return;n([...a,l])}};return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:r("div",{className:"flex flex-wrap gap-2",children:e.options.map(l=>{const c=a.includes(l.value);return u("label",{className:["flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs cursor-pointer select-none transition-colors",c?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground hover:bg-surface",o||e.disabled?"opacity-50 cursor-not-allowed":""].join(" "),children:[r("input",{type:"checkbox",className:"sr-only",checked:c,disabled:o||e.disabled,onChange:()=>i(l.value)}),l.label]},l.value)})})})}function yP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const[a,i]=_(!1),l=e.showToggle!==!1;return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"relative",children:[r("input",{type:a?"text":"password",className:Jn+(l?" pr-9":""),value:t==null?"":String(t),placeholder:e.placeholder,disabled:o||e.disabled,onChange:c=>n(c.target.value)}),l&&r("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",tabIndex:-1,onClick:()=>i(c=>!c),children:a?r(Sm,{className:"h-3.5 w-3.5"}):r(Xs,{className:"h-3.5 w-3.5"})})]})})}function vP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:r("textarea",{className:Jn+" resize-y min-h-[60px]",value:t==null?"":String(t),placeholder:e.placeholder,rows:e.rows??3,maxLength:e.maxLength,disabled:o||e.disabled,onChange:a=>n(a.target.value)})})}function wP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=t==null,i=e.nullable===!0,l=a?e.default??e.min:Number(t),c=e.showValue!==!1,d=e.nullLabel??"Auto",f=o||e.disabled,p=e.displayScale??1,m=e.min/p,h=e.max/p,g=l/p,b=(e.step??1)/p;if(i&&a)return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("button",{className:"w-full rounded-lg border border-dashed border-border px-3 py-2 text-xs text-foreground-subtle hover:border-primary/40 hover:text-primary transition-colors text-left",disabled:f,onClick:()=>n(e.default??e.min),children:[d," — click to set manually"]})});const x=e.showStepper===!0&&c,v=y=>{const N=l+y*(e.step??1),k=Math.min(e.max,Math.max(e.min,N));k!==l&&n(k)},w="flex h-6 w-6 shrink-0 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:cursor-not-allowed disabled:opacity-40";return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[u("div",{className:"flex min-w-0 flex-1 basis-[160px] items-center gap-2",children:[r("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:m}),r("input",{type:"range",className:"min-w-0 flex-1 h-1 accent-primary cursor-pointer disabled:opacity-50",min:m,max:h,step:b,value:g,disabled:f,onChange:y=>n(Number(y.target.value)*p)}),r("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:h})]}),(c||i||e.unit)&&u("div",{className:"flex shrink-0 items-center gap-2",children:[x&&r("button",{type:"button",className:w,disabled:f||l<=e.min,onClick:()=>v(-1),title:`Decrease by ${e.step??1}`,"aria-label":"Decrement",children:r(Pm,{className:"h-3 w-3"})}),c&&r("input",{type:"number",className:"w-16 rounded border border-border bg-surface px-1.5 py-0.5 text-xs text-center text-foreground tabular-nums focus:outline-none focus:ring-1 focus:ring-primary",min:m,max:h,step:b,value:g,disabled:f,onChange:y=>{if(y.target.value===""){n(i?null:e.min);return}const N=Number(y.target.value)*p,k=e.step??1,S=N-e.min,M=e.min+Math.round(S/k)*k;n(Math.min(e.max,Math.max(e.min,M)))}}),x&&r("button",{type:"button",className:w,disabled:f||l>=e.max,onClick:()=>v(1),title:`Increase by ${e.step??1}`,"aria-label":"Increment",children:r(Js,{className:"h-3 w-3"})}),e.unit&&r("span",{className:"text-[10px] text-foreground-subtle",children:e.unit}),i&&r("button",{className:"text-[10px] text-foreground-subtle hover:text-primary transition-colors",title:`Reset to ${d}`,disabled:f,onClick:()=>n(null),children:d})]})]})})}function NP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=Array.isArray(t)?t:[],[i,l]=_(""),c=ne(null),d=q(h=>{const g=h.trim();!g||a.includes(g)||e.maxTags!==void 0&&a.length>=e.maxTags||(n([...a,g]),l(""))},[a,e.maxTags,n]),f=h=>n(a.filter(g=>g!==h)),p=h=>{h.key==="Enter"||h.key===","?(h.preventDefault(),d(i)):h.key==="Backspace"&&i===""&&a.length>0&&f(a[a.length-1])},m=o||e.disabled;return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("div",{className:["flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px] cursor-text","focus-within:border-primary focus-within:ring-1 focus-within:ring-primary/30",m?"opacity-50 cursor-not-allowed":""].join(" "),onClick:()=>!m&&c.current?.focus(),children:[a.map(h=>u("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[h,!m&&r("button",{type:"button",onClick:()=>f(h),className:"hover:text-danger",children:r(Xe,{className:"h-2.5 w-2.5"})})]},h)),r("input",{ref:c,type:"text",className:"flex-1 min-w-[80px] bg-transparent text-sm text-foreground outline-none placeholder:text-foreground-disabled",value:i,placeholder:a.length===0?e.placeholder??"Add tags…":"",disabled:m,list:`tags-suggestions-${e.key}`,onChange:h=>l(h.target.value),onKeyDown:p,onBlur:()=>{i.trim()&&d(i)}}),e.suggestions&&r("datalist",{id:`tags-suggestions-${e.key}`,children:e.suggestions.map(h=>r("option",{value:h},h))})]})})}function mx({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const{nodes:a}=Ar(),i=typeof t=="string"?t:"",l=e.showOffline?a:a.filter(c=>c.isOnline);return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:u("select",{className:"w-full px-3 py-2 text-sm bg-background border border-border rounded-lg text-foreground focus:outline-none focus:border-primary/50 disabled:opacity-50",value:i,onChange:c=>n(c.target.value),disabled:o,children:[r("option",{value:"",children:"Select node…"}),l.map(c=>u("option",{value:c.id,disabled:!c.isOnline,children:[c.shortName,c.isOnline?"":" (offline)"]},c.id))]})})}function hx({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const{nodes:a}=Ar(),i=new Set(Array.isArray(t)?t.map(String):[]),l=e.showOffline?a:a.filter(d=>d.isOnline),c=d=>{const f=new Set(i);f.has(d)?f.delete(d):f.add(d),n([...f])};return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:r("div",{className:"flex flex-wrap gap-1.5",children:l.map(d=>{const f=i.has(d.id);return r("button",{type:"button",onClick:()=>c(d.id),disabled:o||!d.isOnline,className:`px-2.5 py-1 text-xs font-medium rounded-md border transition-colors ${f?"border-primary bg-primary/10 text-primary":"border-border bg-surface text-foreground-subtle hover:bg-surface-hover"} ${d.isOnline?"":"opacity-50 cursor-not-allowed"}`,children:d.shortName},d.id)})})})}function kP({field:e,value:t,onChange:n,disabled:o,translationFn:s}){const a=t==null?"#000000":String(t);return u(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:[u("div",{className:"flex items-center gap-2",children:[r("input",{type:"color",className:"h-9 w-9 rounded-md border border-border bg-background cursor-pointer p-0.5 disabled:opacity-50",value:a,disabled:o||e.disabled,onChange:i=>n(i.target.value)}),r("input",{type:"text",className:Jn+" flex-1 font-mono",value:a,placeholder:"#000000",disabled:o||e.disabled,onChange:i=>n(i.target.value)})]}),e.presets&&e.presets.length>0&&r("div",{className:"flex gap-1.5 mt-1.5",children:e.presets.map(i=>r("button",{type:"button",className:"h-5 w-5 rounded-md border border-border hover:scale-110 transition-transform disabled:opacity-50",style:{backgroundColor:i},disabled:o||e.disabled,title:i,onClick:()=>n(i)},i))})]})}function SP({field:e,value:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:i,externalProbe:l}){const[c,d]=_("idle"),[f,p]=_(null),m=l?.status??c,h=l?.result??f,g=!!a||!!i,b=q(async()=>{if(g){d("probing"),p(null);try{const w=a?await a(e.key,t):await i("test-probe",e.key,t),y=w&&typeof w=="object"?w:{status:"error",error:"Probe handler returned no result"};p(y),d(y.status==="ok"?"ok":"error")}catch(w){p({status:"error",error:w instanceof Error?w.message:String(w)}),d("error")}}},[a,i,e.key,t,g]),x=m==="probing"?"border-primary/40 bg-primary/10 text-primary":m==="ok"?"border-success/40 bg-success/10 text-success hover:bg-success/15":m==="error"?"border-danger/40 bg-danger/10 text-danger hover:bg-danger/15":"border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover",v=m==="probing"?r(Lt,{className:"h-3 w-3 animate-spin"}):m==="ok"?r(f2,{className:"h-3 w-3"}):m==="error"?r(Zs,{className:"h-3 w-3"}):r(Tm,{className:"h-3 w-3"});return u(qe,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:[u("div",{className:"@container flex items-center gap-2",style:{containerType:"inline-size"},children:[u("button",{type:"button",onClick:b,title:"Test",disabled:e.disabled||m==="probing"||!g||!t,className:`flex-shrink-0 inline-flex items-center gap-1.5 rounded-md border px-2 py-2 text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed @[280px]:px-3 ${x}`,children:[v,r("span",{className:"hidden @[280px]:inline",children:"Test"})]}),r("input",{type:e.inputType??"url",className:Jn+" flex-1 min-w-0",value:t==null?"":String(t),placeholder:e.placeholder,disabled:o||e.disabled,onChange:w=>{n(w.target.value),c!=="idle"&&(d("idle"),p(null))}})]}),m==="ok"&&h?.labels&&h.labels.length>0&&r("div",{className:"flex flex-wrap gap-1 mt-1.5",children:h.labels.map((w,y)=>r("span",{className:"text-xs bg-success/10 text-success rounded px-2 py-0.5 font-mono",children:w},y))}),m==="error"&&h?.error&&r("p",{className:"text-xs text-danger mt-1 truncate",title:h.error,children:h.error})]})}function CP({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a}){const[i,l]=_(e.defaultCollapsed??!1),c=e.style==="accordion",d=e.span===2?"col-span-2":e.span===3?"col-span-3":e.span===4?"col-span-4":"col-span-1";return r("div",{className:d,children:u("div",{className:"rounded-lg border border-border bg-surface/50 overflow-hidden",children:[u("div",{className:["px-3 py-2 flex items-center justify-between",c?"cursor-pointer hover:bg-surface":""].join(" "),onClick:c?()=>l(f=>!f):void 0,children:[r("span",{className:"text-xs font-semibold text-foreground",children:Tt(e.label,s)}),c&&r("span",{className:"text-foreground-subtle text-xs",children:i?"▸":"▾"})]}),!i&&r("div",{className:"px-3 pb-3 grid grid-cols-2 gap-x-4 gap-y-3",children:e.fields.map(f=>r(er,{field:f,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a},f.key))})]})})}function MP({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:i}){const l=e.tabs[0]?.id??"",[c,d]=_(l),f=e.span===2?"col-span-2":e.span===3?"col-span-3":e.span===4?"col-span-4":"col-span-1";return e.tabs.length===0?null:u("div",{className:f,children:[e.label&&r("div",{className:ua,children:Tt(e.label,s)}),u("div",{className:"rounded-lg border border-border-subtle bg-surface-hover/40 overflow-hidden",children:[r("div",{className:"flex flex-wrap gap-1 p-1.5 border-b border-border-subtle bg-surface/40",role:"tablist",children:e.tabs.map(p=>{const m=p.id===c;return u("button",{type:"button",role:"tab","aria-selected":m,onClick:()=>d(p.id),className:`inline-flex items-center gap-1.5 whitespace-nowrap rounded-md px-2.5 py-1 text-[11px] transition-colors ${m?"bg-primary text-primary-foreground font-medium shadow-sm":"bg-transparent text-foreground-subtle hover:bg-surface hover:text-foreground"}`,children:[r("span",{children:Tt(p.label,s)}),p.badge&&r("span",{className:`text-[9px] px-1 py-0.5 rounded-full font-medium ${m?"bg-primary-foreground/20 text-primary-foreground":"bg-primary/10 text-primary"}`,children:p.badge})]},p.id)})}),e.tabs.map(p=>p.id!==c?null:r("div",{role:"tabpanel",className:"px-3 pb-3 pt-2 grid grid-cols-2 gap-x-4 gap-y-3",children:p.fields.map((m,h)=>{const g="key"in m&&typeof m.key=="string"?m.key:`__${p.id}__${h}`;return r(er,{field:m,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:i},g)})},p.id))]})]})}function IP({span:e}){return r("div",{className:e===2?"col-span-2":e===3?"col-span-3":e===4?"col-span-4":"col-span-full",children:r("hr",{className:"border-border"})})}const pu={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 AP(e){if(typeof window>"u"||typeof DOMParser>"u")return"";const t=new Set(["A","UL","OL","LI","STRONG","EM","CODE","BR","P","SPAN"]),n=new DOMParser().parseFromString(`<div>${e}</div>`,"text/html"),o=n.body.firstElementChild;if(!o)return"";const s=a=>{const i=Array.from(a.children);for(const l of i){if(!t.has(l.tagName)){const d=n.createTextNode(l.textContent??"");l.replaceWith(d);continue}const c=l.tagName==="A"?new Set(["href"]):new Set;for(const d of Array.from(l.attributes))c.has(d.name)||l.removeAttribute(d.name);if(l.tagName==="A"){const d=l.getAttribute("href")??"";!/^https?:\/\//i.test(d)&&!d.startsWith("mailto:")?l.removeAttribute("href"):(l.setAttribute("target","_blank"),l.setAttribute("rel","noopener noreferrer"))}s(l)}};return s(o),o.innerHTML}function PP({field:e}){const t=e.variant??"info",n=pu[t]??pu.info,o=e.format==="html";return r("div",{className:"col-span-full",children:u("div",{className:`rounded-md border-l-4 px-3 py-2.5 ${n.border} ${n.bg}`,children:[e.label&&r("p",{className:`text-xs font-semibold mb-0.5 ${n.text}`,children:e.label}),o?r("div",{className:"text-xs text-foreground-subtle leading-relaxed info-html-content",dangerouslySetInnerHTML:{__html:AP(e.content)}}):r("p",{className:"text-xs text-foreground-subtle leading-relaxed whitespace-pre-line",children:e.content})]})})}const fu={ok:"bg-success",warn:"bg-amber-500",danger:"bg-danger",idle:"bg-foreground-subtle/40",unknown:"bg-foreground-subtle/40"};function EP(e){if(!Number.isFinite(e)||e<0)return"—";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),o=t%60;return o===0?`${n}m`:`${n}m ${o}s`}function $P(e){return!Number.isFinite(e)||e<=0?"—":new Date(e).toLocaleTimeString()}function _P({kind:e,value:t}){if(t==null||t==="")return r("span",{className:"text-foreground-subtle/60",children:"—"});if(e==="monospace")return r("span",{className:"font-mono text-[11px]",children:String(t)});if(e==="status"){const n=String(t).toLowerCase(),o=fu[n]??fu.unknown;return u("span",{className:"inline-flex items-center gap-1.5",children:[r("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${o}`}),r("span",{children:String(t)})]})}return e==="duration"&&typeof t=="number"?r("span",{className:"font-mono text-[11px]",children:EP(t)}):e==="timestamp"&&typeof t=="number"?r("span",{className:"font-mono text-[11px]",children:$P(t)}):r("span",{children:String(t)})}function DP({field:e}){const t=e.value??[],n=e.description;return u("div",{className:"col-span-full",children:[e.label&&r("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1",children:e.label}),n&&r("p",{className:"text-xs text-foreground-subtle mb-2",children:n}),t.length===0?r("div",{className:"rounded-md border border-border bg-surface-subtle px-3 py-2 text-xs text-foreground-subtle",children:e.emptyMessage??"No entries"}):r("div",{className:"rounded-md border border-border overflow-hidden",children:u("table",{className:"w-full text-xs",children:[r("thead",{className:"bg-surface-subtle border-b border-border",children:r("tr",{children:e.columns.map(o=>r("th",{className:"px-3 py-1.5 text-left font-medium text-foreground-subtle",style:o.width?{width:o.width}:void 0,children:o.label},o.key))})}),r("tbody",{className:"divide-y divide-border",children:t.map((o,s)=>r("tr",{className:"hover:bg-surface-hover/40",children:e.columns.map(a=>r("td",{className:"px-3 py-1.5 align-top text-foreground",children:r(_P,{kind:a.kind,value:o[a.key]})},a.key))},s))})]})})]})}function LP({field:e,value:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:i}){const l=Array.isArray(t)?t:[],c=e.minRows??0,d=e.maxRows??Number.POSITIVE_INFINITY,f=(x,v,w)=>{const y=l.slice(),N=y[x]??{};y[x]={...N,[v]:w},n(y)},p=x=>{l.length<=c||n(l.filter((v,w)=>w!==x))},m=()=>{if(l.length>=d)return;const x=e.defaultItem??{};n([...l,{...x}])},h=(x,v)=>e.rowTitleTemplate?e.rowTitleTemplate.replace(/\{(\w+)\}/g,(w,y)=>{const N=x[y];return N==null||N===""?"—":String(N)}):`Row ${v+1}`,g=l.length>c,b=l.length<d;return u("div",{className:"col-span-full space-y-2",children:[u("div",{className:"space-y-0.5",children:[e.label&&r("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:Tt(e.label,s)}),e.description&&r("p",{className:"text-[11px] text-foreground-subtle",children:Tt(e.description,s)})]}),l.length===0?r("div",{className:"rounded-md border border-dashed border-border bg-background px-3 py-3 text-center text-[11px] text-foreground-subtle",children:e.emptyMessage??"No entries"}):r("div",{className:"space-y-2",children:l.map((x,v)=>u("div",{className:"rounded-md border border-border bg-background",children:[u("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[r("span",{className:"text-xs font-medium text-foreground",children:h(x,v)}),u("button",{type:"button",onClick:()=>p(v),disabled:o||!g,className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-30 disabled:cursor-not-allowed",title:g?"Remove this row":`At least ${c} row(s) required`,children:[r(Pm,{className:"h-3 w-3"}),"Remove"]})]}),r("div",{className:"grid grid-cols-1 @[420px]:grid-cols-2 gap-x-3 gap-y-2 p-3",children:e.itemFields.map(w=>r(er,{field:w,values:x,onChange:(y,N)=>f(v,y,N),disabled:o,translationFn:s,onTestField:a,allFields:e.itemFields,onAction:i},w.key))})]},v))}),u("div",{children:[u("button",{type:"button",onClick:m,disabled:o||!b,className:"inline-flex items-center gap-1 rounded border border-border bg-surface px-3 py-1 text-[11px] font-medium text-foreground hover:border-primary/40 hover:bg-primary/5 disabled:opacity-30 disabled:cursor-not-allowed",children:[r(Js,{className:"h-3 w-3"}),e.addLabel??"Add"]}),!b&&Number.isFinite(d)&&u("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["(limit: ",d,")"]})]})]})}function TP({field:e,disabled:t,onAction:n}){const[o,s]=_(!1),a=nt(),i=async()=>{if(!(e.confirmMessage&&!await a({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant==="danger"?"danger":"default"}))&&n){s(!0);try{await n(e.action,e.key)}finally{s(!1)}}},l={default:"border border-border text-foreground hover:bg-surface-hover",primary:"bg-primary text-primary-foreground hover:bg-primary/90",danger:"bg-danger text-white hover:bg-danger/90"};return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,children:r("button",{onClick:i,disabled:t||o,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors disabled:opacity-50 ${l[e.variant??"default"]??l.default}`,children:o?"Processing...":e.buttonLabel})})}function gx(e,t){const n={...e.paramsStatic??{}};if(e.paramsFromForm)for(const[o,s]of Object.entries(e.paramsFromForm)){const a=t[s];a!=null&&a!==""&&(n[o]=a)}return n}function RP({field:e,value:t,values:n,onChange:o,disabled:s,onAction:a}){const[i,l]=_(!1),[c,d]=_(null),[f,p]=_(null),m=gx(e,n),h=Object.keys(e.paramsFromForm??{}).some(w=>m[w]===void 0),g=(e.refreshOn??Object.values(e.paramsFromForm??{})).map(w=>`${w}=${JSON.stringify(n[w])}`).join("|");Z(()=>{if(!a||h){p(null),d(null);return}let w=!1;return l(!0),d(null),a(e.action,e.key,m).then(y=>{if(w)return;const N=y;let k=[];if(Array.isArray(N))k=N;else if(N&&typeof N=="object")for(const S of Object.keys(N)){const M=N[S];if(Array.isArray(M)){k=M;break}}p(k)}).catch(y=>{w||(d(y instanceof Error?y.message:String(y)),p([]))}).finally(()=>{w||l(!1)}),()=>{w=!0}},[g,a,e.action,e.key]);const b=e.mapOption.value,x=e.mapOption.label,v=e.mapOption.description;return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,children:h?r("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyParamsMessage??"Fill the prerequisite fields above first."}):i?u("div",{className:"flex items-center gap-2 text-[11px] text-foreground-subtle",children:[r(Lt,{className:"h-3 w-3 animate-spin"})," Loading options…"]}):c?r("div",{className:"text-[11px] text-danger",children:c}):f&&f.length===0?r("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyResultsMessage??"No options returned."}):(()=>{const w=(f??[]).some(y=>{const N=y[b];return N===""||N===void 0});return u("select",{className:"w-full rounded-md border border-border bg-surface px-2 py-1.5 text-xs text-foreground",value:typeof t=="string"?t:"",disabled:s,onChange:y=>o(y.target.value),children:[!w&&r("option",{value:"",children:"— Select —"}),(f??[]).map((y,N)=>{const k=y[b],S=y[x],M=v?y[v]:void 0,P=typeof k=="string"&&k!==""?k:`row-${N}`;return u("option",{value:typeof k=="string"?k:String(k??""),children:[typeof S=="string"?S:String(S??P),M!==void 0?` (${String(M)})`:""]},P)})]})})()})}function OP({field:e,values:t,disabled:n,onAction:o}){const[s,a]=_(!1),[i,l]=_(null),c=nt(),d=async()=>{if(e.confirmMessage&&!await c({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant==="danger"?"danger":"default"})||!o)return;const p=gx(e,t);a(!0),l(null);try{const m=await o(e.action,e.key,p),h=typeof m=="object"&&m!==null?m:null,g=e.successMessage?e.successMessage.replace(/\{(\w+)\}/g,(b,x)=>{const v=h?.[x];return v===void 0?"":String(v)}):"Done.";l({kind:"ok",text:g})}catch(m){l({kind:"error",text:m instanceof Error?m.message:String(m)})}finally{a(!1)}},f={default:"border border-border text-foreground hover:bg-surface-hover",primary:"bg-primary text-primary-foreground hover:bg-primary/90",danger:"bg-danger text-white hover:bg-danger/90"};return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,children:u("div",{className:"flex flex-col gap-1.5",children:[r("button",{onClick:d,disabled:n||s,className:`inline-flex w-fit items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors disabled:opacity-50 ${f[e.variant??"default"]??f.default}`,children:s?"Working…":e.buttonLabel}),i&&r("div",{className:`text-[11px] ${i.kind==="ok"?"text-emerald-700 dark:text-emerald-300":"text-danger"}`,children:i.text})]})})}function zP({field:e}){const t=dn();return r(qe,{label:e.label,description:e.description,required:e.required,span:e.span,children:r(at,{widgetId:e.widgetId,host:"device-tab",config:e.widgetConfig,deviceId:t??void 0,instanceId:e.key})})}function BP(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 FP({field:e,values:t,onAction:n,translationFn:o}){const s="key"in e?e.key:void 0;if(!s)return null;const a=t[s],i=a!==void 0?a:"default"in e?e.default:void 0,l="unit"in e?e.unit:void 0,c=BP(i,l),d="label"in e?e.label:void 0,f="description"in e?e.description:void 0,p="span"in e?e.span:void 0,m="actions"in e?e.actions??[]:[];return r(qe,{label:d,description:f,span:p,translationFn:o,children:u("div",{className:"flex items-stretch gap-1",children:[r("div",{className:"flex-1 rounded-md border border-border bg-surface-alt px-2.5 py-1.5 text-xs text-foreground font-mono break-all",children:c}),m.length>0&&r("div",{className:"flex items-center gap-1",children:m.map(h=>r(HP,{action:h,fieldKey:s,value:i,onAction:n},h.action))})]})})}function jP({name:e}){const t="h-3.5 w-3.5";switch(e){case"copy":return r(Cn,{className:t});case"refresh-cw":return r(Bl,{className:t});case"external-link":return r(km,{className:t});case"trash-2":return r(tn,{className:t});case"download":return r(Bi,{className:t});case"upload":return r(Lm,{className:t});default:return r(Fl,{className:t})}}function HP({action:e,fieldKey:t,value:n,onAction:o}){const s=nt(),[a,i]=_(!1),l=e.variant==="danger"?"text-danger hover:bg-danger/10 border-danger/30":e.variant==="primary"?"text-primary hover:bg-primary/10 border-primary/30":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover border-border";return r("button",{type:"button",onClick:async()=>{if(!(e.confirmMessage&&!await s({title:e.tooltip,message:e.confirmMessage,variant:e.variant==="danger"?"danger":"default"}))){if(e.action==="copy-value"){try{await navigator.clipboard.writeText(typeof n=="string"?n:String(n))}catch{}return}if(o){i(!0);try{await o(e.action,t)}finally{i(!1)}}}},disabled:a,title:e.tooltip,className:`inline-flex items-center justify-center rounded-md border px-2 py-1.5 transition-colors disabled:opacity-50 ${l}`,children:r(jP,{name:e.icon})})}function VP(e){return"multiple"in e&&e.multiple!=null}function qP({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c}){const d=e.multiple,f=d.min,p=d.max,m=t[e.key],g=[...Array.isArray(m)?m:m!=null?[m]:[]],b=d.itemDefault!==void 0?d.itemDefault:"default"in e&&e.default!==void 0?e.default:"";for(;g.length<f;)g.push(b);const x=k=>n(e.key,[...k]),v=(k,S)=>{const M=[...g];M[k]=S,x(M)},w=()=>{g.length>=p||x([...g,b])},y=k=>{g.length<=f||x(g.filter((S,M)=>M!==k))},N=()=>{const{multiple:k,...S}=e;return{...S,...{label:void 0,description:void 0,required:!1}}};return r(qe,{label:e.label,description:e.description,required:f>0?e.required:!1,span:e.span,translationFn:s,children:u("div",{className:"space-y-2",children:[g.map((k,S)=>{const M=d.itemLabel?.replace("${n}",String(S+1));return u("div",{className:"space-y-1",children:[M&&r("div",{className:ua,children:M}),u("div",{className:"flex items-center gap-2",children:[r("div",{className:"flex-1 min-w-0",children:r(er,{field:N(),values:{...t,[e.key]:k},onChange:(P,I)=>v(S,I),disabled:o,translationFn:s,onTestField:a,onAction:c,allFields:l})}),g.length>f&&r("button",{type:"button",onClick:()=>y(S),disabled:o,title:"Remove",className:"flex-shrink-0 inline-flex items-center justify-center rounded-md border border-border p-1.5 text-foreground-subtle hover:text-danger hover:border-danger/50 transition-colors disabled:opacity-40",children:r(tn,{className:"h-3.5 w-3.5"})})]})]},S)}),u("div",{className:"flex items-center justify-between pt-1",children:[g.length<p?u("button",{type:"button",onClick:w,disabled:o,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40",children:[r(Js,{className:"h-3 w-3"}),d.addLabel??"Add"]}):r("span",{}),u("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[g.length,"/",p]})]})]})})}function Mc(e,t,n){if(!("showWhen"in e)||!e.showWhen)return!0;const o=e.showWhen,s=t[o.field],a=n?.find(c=>"key"in c&&c.key===o.field),i=a&&"default"in a?a.default:void 0,l=s!==void 0?s:i;return o.equals!==void 0?l===o.equals:o.notEquals!==void 0?l!==o.notEquals:o.in!==void 0?o.in.includes(l):o.notIn!==void 0?!o.notIn.includes(l):o.includes!==void 0?Array.isArray(l)&&l.includes(o.includes):o.notIncludes!==void 0?!Array.isArray(l)||!l.includes(o.notIncludes):!0}function er({field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c}){if(VP(e))return r(qP,{field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i,allFields:l,onAction:c});if("readonlyField"in e&&e.readonlyField===!0)return r(FP,{field:e,values:t,onAction:c,translationFn:s});if(!Mc(e,t,l))return null;const d=t[e.key],f=d!==void 0?d:"default"in e?e.default:void 0,p=h=>n(e.key,h),m=Fh(e.type);switch(e.type){case"text":return r(mP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"number":return r(hP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"boolean":return r(gP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"select":return r(bP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"multiselect":return r(xP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"password":return r(yP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"textarea":return r(vP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"slider":return r(wP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"tags":return r(NP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"color":return r(kP,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"node-select":return r(mx,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"node-multiselect":return r(hx,{field:e,value:f,onChange:p,disabled:o,translationFn:s});case"probe":return r(SP,{field:e,value:f,onChange:p,disabled:o,translationFn:s,onTestField:a,onAction:c,externalProbe:i});case"group":return r(CP,{field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a});case"sub-tabs":return r(MP,{field:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,onAction:c});case"separator":return r(IP,{});case"info":return r(PP,{field:e});case"object-array":return r(DP,{field:e});case"editable-array":return r(LP,{field:e,value:f,onChange:p,disabled:o,translationFn:s,onTestField:a,onAction:c});case"button":return r(TP,{field:e,disabled:o,onAction:c});case"addon-action-select":return r(RP,{field:e,value:f,values:t,onChange:p,disabled:o,onAction:c});case"addon-action-button":return r(OP,{field:e,values:t,disabled:o,onAction:c});case"widget":return r(zP,{field:e});default:return m?r(m,{field:e,value:f,onChange:p,disabled:o}):null}}function QP(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Tt(e,t){if(e!==void 0)return t&&QP(e)?t(e):e}function UP({section:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i}){const[l,c]=_(e.defaultCollapsed??!1),d=e.style==="accordion",f=e.columns??2,p=f===1?"grid-cols-1":f===3?"grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3":f===4?"grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4":"grid-cols-1 @[640px]:grid-cols-2";return u("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[u("div",{className:["flex items-center justify-between mb-2",d?"cursor-pointer":""].join(" "),onClick:d?()=>c(m=>!m):void 0,children:[u("div",{children:[r("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:Tt(e.title,s)}),e.description&&r("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:Tt(e.description,s)})]}),d&&r("span",{className:"text-foreground-subtle text-xs ml-2",children:l?"▸":"▾"})]}),!l&&r("div",{className:`grid ${p} gap-x-3 gap-y-2.5`,children:e.fields.map(m=>r(er,{field:m,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i?.[m.key]},m.key))})]})}function bx({schema:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i,onClearProbe:l}){const c=(d,f)=>{n({...t,[d]:f}),l?.(d)};return r("div",{className:"space-y-4",children:e.sections.map(d=>r(UP,{section:d,values:t,onChange:c,disabled:o,translationFn:s,onTestField:a,probeResults:i},d.id))})}const KP=({open:e})=>r("svg",{className:`h-3 w-3 transition-transform ${e?"rotate-90":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:r("polyline",{points:"9 18 15 12 9 6"})});function mu(e){const t={};if(!e)return t;for(const n of e.sections)for(const o of n.fields){if(o.type==="separator"||o.type==="info"||o.type==="button"||o.type==="group")continue;const s=o.key;t[s]=o.value}return t}function GP(e){return{...e,sections:e.sections.map(t=>({...t,fields:t.fields.map(n=>{if(n.type==="separator"||n.type==="info"||n.type==="button"||n.type==="group")return n;const{value:o,...s}=n;return s})}))}}function WP({trpc:e,addonId:t,nodeId:n,title:o,disabled:s,onAfterChange:a,refreshToken:i,collapsible:l,defaultOpen:c,mode:d,onOverrideChange:f}){const p=d??"persist",[m,h]=_(null),[g,b]=_(!0),[x,v]=_(null),[w,y]=_(!1),[N,k]=_(c??!1),[S,M]=_({}),[P,I]=_(null);Z(()=>{I(null),M({})},[e,t,n,i,p]);const z=JSON.stringify(S);Z(()=>{let D=!1;b(!0),v(null);const T=p==="override"&&Object.keys(S).length>0?S:void 0;return e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n,...T?{overlay:T}:{}}).then(B=>{D||(h(B),T||I(mu(B)),b(!1))}).catch(B=>{D||(v(B instanceof Error?B.message:String(B)),b(!1))}),()=>{D=!0}},[e,t,n,i,p,z]);const $=U(()=>mu(m),[m]),O=U(()=>m?GP(m):null,[m]),R=async D=>{if(p==="override"){const B=P??$,F={};for(const H of Object.keys(D))D[H]!==B[H]&&(F[H]=D[H]);const j={...B,...F};M(F),f?.(F,j);return}const T={};for(const B of Object.keys(D))D[B]!==$[B]&&(T[B]=D[B]);if(Object.keys(T).length!==0){y(!0);try{await e.addonSettings.updateGlobalSettings.mutate({addonId:t,nodeId:n,patch:T});const B=await e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n});h(B),a?.()}catch(B){v(B instanceof Error?B.message:String(B))}finally{y(!1)}}};if(g)return u("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading ",o??t,"…"]});if(x)return u("div",{className:"text-xs text-red-400",children:[o??t,": ",x]});if(!m||!O)return u("div",{className:"text-xs text-foreground-subtle",children:[o??t," not available on ",n,"."]});const A=p==="override"?{...$,...S}:$,L=u(xe,{children:[p==="override"?r("div",{className:"mb-2 text-[11px] text-foreground-subtle",children:"Benchmark override — applies to this run only. The addon's saved settings are not changed."}):null,r(bx,{schema:O,values:A,onChange:R,disabled:s===!0||w})]});return l===!0?u("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("button",{type:"button",onClick:()=>k(D=>!D),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover text-left","aria-expanded":N,children:[r(KP,{open:N}),r("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide flex-1",children:o??t}),r("span",{className:"text-[10px] text-foreground-subtle",children:N?"hide":"edit"})]}),N?r("div",{className:"border-t border-border px-4 py-3",children:L}):null]}):o?u("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r("div",{className:"border-b border-border px-4 py-2",children:r("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:o})}),r("div",{className:"px-4 py-3",children:L})]}):r("div",{children:L})}function xx({detections:{motion:e,motionRaw:t,detection:n,phase:o},showMotionZones:s=!0,showMotionRaw:a=!0,showDetections:i=!0,showPhaseIndicator:l=!0}){const c=s&&e&&e.zones.length>0,d=a&&t&&t.boxes.length>0,f=i&&n&&n.detections.length>0;return!c&&!d&&!f&&!l?null:u("div",{className:"absolute inset-0 pointer-events-none z-10",children:[l&&r(YP,{phase:o}),d&&r(ZP,{raw:t}),c&&r(XP,{motion:e}),f&&r(JP,{detections:n.detections,frameWidth:n.frameWidth,frameHeight:n.frameHeight})]})}function YP({phase:e}){const t=Gn(e);return u("div",{className:"absolute top-2 left-2 flex items-center gap-1.5 px-2 py-1 rounded-md bg-black/60 backdrop-blur-sm",children:[r("span",{className:`w-2 h-2 rounded-full ${t.dotClass}`}),r("span",{className:"text-[10px] font-semibold text-white uppercase tracking-wider",children:t.label})]})}function ZP({raw:e}){return e.frameWidth===0||e.frameHeight===0?null:r(xe,{children:e.boxes.map((t,n)=>{const[o,s,a,i]=t.bbox,l=o/e.frameWidth*100,c=s/e.frameHeight*100,d=(a-o)/e.frameWidth*100,f=(i-s)/e.frameHeight*100,p=Math.max(.05,Math.min(.25,t.changeScore*.3));return r("div",{className:"absolute rounded-sm",style:{left:`${l}%`,top:`${c}%`,width:`${d}%`,height:`${f}%`,backgroundColor:`rgba(239, 68, 68, ${p})`}},`mr-${n}`)})})}function XP({motion:e}){if(e.frameWidth===0||e.frameHeight===0)return null;const t=e.zones.filter(n=>n.w*n.h/(e.frameWidth*e.frameHeight)<.9);return r(xe,{children:t.map((n,o)=>{const s=Math.max(.15,Math.min(.5,n.intensity/255));return r("div",{className:"absolute rounded-sm",style:{left:`${n.x/e.frameWidth*100}%`,top:`${n.y/e.frameHeight*100}%`,width:`${n.w/e.frameWidth*100}%`,height:`${n.h/e.frameHeight*100}%`,border:`1px solid rgba(250, 204, 21, ${s})`,backgroundColor:`rgba(250, 204, 21, ${s*.15})`}},`mz-${o}`)})})}function JP({detections:e,frameWidth:t,frameHeight:n}){return t===0||n===0?null:r(xe,{children:e.map(o=>{const{x:s,y:a,width:i,height:l}=o.bbox,c=s/t*100,d=a/n*100,f=i/t*100,p=l/n*100,m=lt(o.macroClass),h=[`${o.macroClass} ${(o.score*100).toFixed(0)}%`];for(const g of o.labels)h.push(g.label);return r("div",{className:"absolute border-2 rounded-sm",style:{left:`${c}%`,top:`${d}%`,width:`${f}%`,height:`${p}%`,borderColor:m},children:r("div",{className:"absolute -top-4 left-0 px-1 py-0.5 text-[9px] font-bold text-white rounded-sm whitespace-nowrap",style:{backgroundColor:m},children:h.join(" | ")})},`det-${o.id}`)})})}function eE(e){const t={};if(typeof window<"u"){if(e){const o=e.getBoundingClientRect();o.width>0&&o.height>0&&(t.viewportWidth=Math.round(o.width),t.viewportHeight=Math.round(o.height))}t.viewportWidth===void 0&&(t.viewportWidth=window.innerWidth,t.viewportHeight=window.innerHeight),t.devicePixelRatio=window.devicePixelRatio||1;const n=navigator.connection;n?.downlink&&n.downlink>0&&(t.downlinkMbps=n.downlink)}return t}const tE=3e3,nE=5;function yx({serverUrl:e,streamKey:t,label:n,autoPlay:o=!0,muted:s=!0,showControls:a=!0,className:i="",onStateChange:l,onError:c,overlay:d,createSession:f,sendAnswer:p,closeSession:m,hintsOverride:h}){const g=ne(null),b=ne(null),x=ne(null),v=ne(new Set),w=ne(null),y=ne(null),N=ne(0),k=ne(!0),[S,M]=_("idle"),[P,I]=_(""),[z,$]=_(s),[O,R]=_(!1),[A,L]=_(!1),D=ne(null),T=ne(!1);(p||f)&&(T.current=!0);const B=T.current,F=q(G=>{M(G),l?.(G)},[l]),j=q(()=>{if(w.current?.abort(),w.current=null,y.current&&(clearTimeout(y.current),y.current=null),x.current&&(x.current.close(),x.current=null),m&&v.current.size>0){for(const G of v.current)m(G).catch(()=>{});v.current.clear()}g.current&&(g.current.srcObject=null)},[m]),H=q(async()=>{if(!k.current||!f||!p)return;j(),F("connecting");const G=new AbortController;w.current=G;try{const ae={...eE(b.current),...h},{sessionId:fe,sdpOffer:he}=await f(ae);if(v.current.add(fe),!k.current||G.signal.aborted){m?.(fe).catch(()=>{}),v.current.delete(fe);return}const V=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=V;const ie=new MediaStream;V.ontrack=pe=>{console.debug("[WebRTC] ontrack",pe.track.kind,pe.track.readyState),ie.addTrack(pe.track),g.current&&(g.current.srcObject=ie,g.current.play().catch(()=>{}))},V.oniceconnectionstatechange=()=>{if(!k.current)return;const pe=V.iceConnectionState;console.debug("[WebRTC] ICE state:",pe),pe==="connected"||pe==="completed"?(N.current=0,F("playing"),g.current?.paused&&(console.debug("[WebRTC] video was paused at ICE connected — calling play()"),g.current.play().catch(()=>{}))):(pe==="failed"||pe==="disconnected"||pe==="closed")&&(F("disconnected"),Y())},V.onicecandidateerror=pe=>{console.debug("[WebRTC] ICE candidate error:",pe)},console.debug("[WebRTC] Setting remote description (server offer)..."),await V.setRemoteDescription({type:"offer",sdp:he});const ue=await V.createAnswer();if(await V.setLocalDescription(ue),console.debug("[WebRTC] Local description set, waiting for ICE gathering..."),await hu(V),!k.current)return;const de=(V.localDescription?.sdp??"").split(`
|
|
531
|
+
`).filter(pe=>pe.startsWith("a=candidate:")).length;console.debug("[WebRTC] Sending answer to server",{localCandidates:de,sessionId:fe.slice(0,8)}),await p(fe,V.localDescription?.sdp??""),console.debug("[WebRTC] Answer sent successfully");const le=V,Se=()=>{const pe=le.connectionState;if(pe==="closed"||pe==="failed")return;const Ie=g.current;Ie&&Ie.readyState===0&&console.log(`[WebRTC] no video data yet (ice=${le.iceConnectionState})`)};setTimeout(Se,3e3),setTimeout(Se,8e3)}catch(ee){if(!k.current)return;const ae=ee instanceof Error?ee.message:String(ee);I(ae),F("error"),c?.(ae),Y()}},[e,t,f,p,j,F,c,h]),E=q(async()=>{if(k.current){j(),F("connecting");try{const G=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=G,G.addTransceiver("video",{direction:"recvonly"}),G.addTransceiver("audio",{direction:"recvonly"});const ee=new MediaStream;G.ontrack=ie=>{ee.addTrack(ie.track),g.current&&(g.current.srcObject=ee,g.current.play().catch(()=>{}))},G.oniceconnectionstatechange=()=>{if(!k.current)return;const ie=G.iceConnectionState;ie==="connected"||ie==="completed"?(N.current=0,F("playing"),g.current?.paused&&g.current.play().catch(()=>{})):(ie==="failed"||ie==="disconnected"||ie==="closed")&&(F("disconnected"),Y())};const ae=await G.createOffer();if(await G.setLocalDescription(ae),await hu(G),!k.current)return;const fe=`${e}/api/webrtc?src=${encodeURIComponent(t)}`,he=await fetch(fe,{method:"POST",headers:{"Content-Type":"application/sdp"},body:G.localDescription?.sdp??""});if(!he.ok)throw new Error(`WHEP ${he.status}: ${he.statusText}`);const V=await he.text();await G.setRemoteDescription({type:"answer",sdp:V})}catch(G){if(!k.current)return;const ee=G instanceof Error?G.message:String(G);I(ee),F("error"),c?.(ee),Y()}}},[e,t,j,F,c]),Q=B?H:E,K=ne(()=>{});K.current=Q;const Y=q(()=>{k.current&&(N.current>=nE||(N.current+=1,y.current=setTimeout(()=>{k.current&&K.current()},tE)))},[]);Z(()=>(k.current=!0,N.current=0,o&&Q(),()=>{k.current=!1,j()}),[e,t]);const re=ne(!1);Z(()=>{!o||!B||!f||!p||re.current||x.current||(re.current=!0,Q())},[o,B,f,p,Q]);const te=()=>{N.current=0,Q()},X=()=>{g.current&&(g.current.muted=!g.current.muted,$(g.current.muted))},oe=async()=>{if(b.current)try{document.fullscreenElement?await document.exitFullscreen():await b.current.requestFullscreen()}catch(G){console.warn(`Fullscreen toggle failed: ${G instanceof Error?G.message:G}`)}},ge=()=>{if(!g.current)return;const G=document.createElement("canvas");G.width=g.current.videoWidth||1280,G.height=g.current.videoHeight||720;const ee=G.getContext("2d");if(!ee)return;ee.drawImage(g.current,0,0);const ae=document.createElement("a");ae.download=`${t.replace(/[/:]/g,"-")}-${Date.now()}.jpg`,ae.href=G.toDataURL("image/jpeg",.92),ae.click()};Z(()=>{const G=()=>R(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",G),()=>document.removeEventListener("fullscreenchange",G)},[]);const J=()=>{L(!0),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>L(!1),3e3)};return u("div",{ref:b,className:`relative bg-black overflow-hidden group ${i}`,onMouseMove:J,onMouseEnter:J,children:[r("video",{ref:g,autoPlay:o,muted:z,playsInline:!0,className:"w-full h-full object-contain"}),n&&S==="playing"&&r("div",{className:"absolute top-2 left-2 px-2 py-0.5 rounded bg-black/60 text-[10px] text-white font-medium",children:n}),d,S==="connecting"&&u("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[r("svg",{className:"h-6 w-6 text-white/60 animate-spin",viewBox:"0 0 24 24",fill:"none",children:r("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"32",strokeDashoffset:"32",className:"animate-[dash_1.5s_ease-in-out_infinite]"})}),r("span",{className:"text-xs text-white/60",children:"Connecting…"})]}),(S==="error"||S==="disconnected")&&u("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[r("svg",{className:"h-6 w-6 text-red-400",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:r("path",{d:"M1 1l5.5 5.5M23 23l-5.5-5.5M8.11 15.89a8 8 0 0110.78-10.78M3.64 3.64A12 12 0 0020.36 20.36",strokeLinecap:"round"})}),r("span",{className:"text-xs text-red-400 text-center px-4",children:S==="error"?P||"Connection failed":"Disconnected"}),r("button",{onClick:te,className:"mt-1 inline-flex items-center gap-1.5 rounded px-3 py-1 text-xs bg-white/10 text-white hover:bg-white/20 transition-colors",children:"Reconnect"})]}),a&&S==="playing"&&u("div",{className:`absolute bottom-0 inset-x-0 flex items-center justify-between px-3 py-1.5 bg-gradient-to-t from-black/80 to-transparent transition-opacity duration-200 ${A?"opacity-100":"opacity-0"}`,children:[r("div",{className:"flex items-center gap-1",children:r(Wa,{onClick:X,title:z?"Unmute":"Mute",children:z?u("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[r("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),r("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),r("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]}):u("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[r("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),r("path",{d:"M19.07 4.93a10 10 0 010 14.14M15.54 8.46a5 5 0 010 7.07"})]})})}),u("div",{className:"flex items-center gap-1",children:[r(Wa,{onClick:ge,title:"Take snapshot",children:u("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[r("path",{d:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z"}),r("circle",{cx:"12",cy:"13",r:"4"})]})}),r(Wa,{onClick:oe,title:O?"Exit fullscreen":"Fullscreen",children:O?r("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:r("path",{d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):r("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:r("path",{d:"M8 3H5a2 2 0 00-2 2v3m18 0V5a2 2 0 00-2-2h-3m0 18h3a2 2 0 002-2v-3M3 16v3a2 2 0 002 2h3"})})})]})]})]})}function Wa({onClick:e,title:t,children:n}){return r("button",{onClick:e,title:t,className:"rounded-full p-1.5 text-white/80 hover:text-white hover:bg-white/20 transition-colors",children:n})}async function hu(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 Ic=cn("camstack:player-overlays-state",null),Ac=cn("camstack:player-overlays-actions",null);function vx({children:e}){const[t,n]=_(()=>new Map),[o,s]=_(()=>new Map),a=q(p=>{n(m=>{const h=new Map(m);return h.set(p.id,p),h})},[]),i=q(p=>{n(m=>{if(!m.has(p))return m;const h=new Map(m);return h.delete(p),h})},[]),l=q(p=>{s(m=>{const h=new Map(m);return h.set(p.id,p),h})},[]),c=q(p=>{s(m=>{if(!m.has(p))return m;const h=new Map(m);return h.delete(p),h})},[]),d=U(()=>({layers:t,buttons:o}),[t,o]),f=U(()=>({setLayer:a,removeLayer:i,setButton:l,removeButton:c}),[a,i,l,c]);return r(Ic.Provider,{value:d,children:r(Ac.Provider,{value:f,children:e})})}function wx(){const e=ve(Ic);return U(()=>e?[...e.layers.values()].sort((t,n)=>t.order-n.order):[],[e])}function Nx(){const e=ve(Ic);return U(()=>e?[...e.buttons.values()].sort((t,n)=>t.order-n.order):[],[e])}function rE(e){const t=ve(Ac);Z(()=>{if(!(!t||!e))return t.setLayer(e),()=>t.removeLayer(e.id)},[t,e])}function oE(e){const t=ve(Ac);Z(()=>{if(!(!t||!e))return t.setButton(e),()=>t.removeButton(e.id)},[t,e])}function sE(e){return e==="streaming"?"bg-emerald-500":e==="connecting"?"bg-amber-500":e==="error"?"bg-rose-500":"bg-zinc-500"}function aE(e){const t=Math.floor(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h${Math.floor(t%3600/60)}m`}function Gi({className:e}){return r("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r("polygon",{points:"5 3 19 12 5 21 5 3"})})}function iE({className:e}){return r("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})})}function lE({className:e}){return u("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"}),r("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),r("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),r("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}function cE({className:e}){return u("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[r("circle",{cx:"5",cy:"12",r:"2"}),r("circle",{cx:"12",cy:"12",r:"2"}),r("circle",{cx:"19",cy:"12",r:"2"})]})}function Ya({label:e,active:t,onClick:n}){return u("button",{type:"button",onClick:n,className:"w-full flex items-center justify-between gap-3 px-3 py-1.5 text-[11px] text-foreground hover:bg-surface-hover transition-colors",children:[r("span",{children:e}),r("span",{className:`inline-block h-3 w-5 rounded-full transition-colors ${t?"bg-primary":"bg-foreground-subtle/30"} relative`,children:r("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-white transition-all ${t?"left-2.5":"left-0.5"}`})})]})}function kx({className:e}){return u("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("polyline",{points:"23 4 23 10 17 10"}),r("polyline",{points:"1 20 1 14 7 14"}),r("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]})}function dE({className:e}){return u("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),r("path",{d:"M10.41 10.41a2 2 0 11-2.83-2.83"}),r("line",{x1:"13.5",y1:"13.5",x2:"6",y2:"21"}),r("path",{d:"M18 12l-1.5-1.5"}),r("path",{d:"M21 15V5a2 2 0 00-2-2H5"}),r("path",{d:"M21 21H5a2 2 0 01-2-2V11"})]})}function Pc({serverUrl:e,createSession:t,sendAnswer:n,closeSession:o,streams:s,activeStreamId:a,onStreamChange:i,deviceName:l,phase:c,pipelineMetrics:d,detections:f,defaultShowDetections:p=!0,defaultShowMotion:m=!1,streamStats:h,autoPlay:g=!1,showPlayStop:b=!1,snapshotSrc:x,snapshotLoading:v=!1,onRefreshSnapshot:w,showStreamStats:y=!1,children:N,extraOverlay:k,ptzAvailable:S=!1,ptzShown:M=!1,ptzOverlay:P,onPtzToggle:I,intercomAvailable:z=!1,intercomShown:$=!1,onIntercomToggle:O,chromeless:R=!1,className:A}){const L=Nx(),[D,T]=_(g),[B,F]=_(p),[j,H]=_(m),[E,Q]=_(null),[K,Y]=_(!1),re=ne(null);Z(()=>{if(!K)return;function le(Se){re.current&&!re.current.contains(Se.target)&&Y(!1)}return document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[K]);const te=a??E??s?.[0]?.id??"",X=s?.find(le=>le.id===te)??s?.[0],oe=X?.inputFps!=null?{status:X.status??"unknown",inputFps:X.inputFps,bitrateKbps:X.bitrateKbps??0}:null,ge=le=>{Q(le),i?.(le),D&&b&&(T(!1),setTimeout(()=>T(!0),50))},J=U(()=>{const le=X?.target;if(le)return Se=>t(le,Se)},[t,X]),G=s,ee=()=>T(!0),ae=()=>T(!1),fe=d?.phase??c,he=fe==="active",V=!!f,ie=V&&(B||j),ue=S&&M&&!!P,de=b?D:!0;return u("div",{className:`overflow-hidden ${R?"":"rounded-xl border border-border bg-surface"} ${A??""}`,children:[u("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[u("div",{className:"flex items-center gap-2",children:[(h??oe)&&r("span",{className:`w-2 h-2 rounded-full ${sE((h??oe).status)}`}),l&&r("span",{className:"text-xs font-medium text-foreground",children:l}),G&&G.length>1&&u("div",{className:"relative",children:[r("select",{"data-testid":"stream-profile-select",value:te,onChange:le=>ge(le.target.value),className:"appearance-none cursor-pointer rounded-md border border-border bg-surface-hover hover:bg-surface text-foreground text-[11px] font-medium pl-2 pr-6 py-1 focus:outline-none focus:ring-1 focus:ring-primary transition-colors",children:G.map(le=>r("option",{value:le.id,children:le.label},le.id))}),r("span",{className:"pointer-events-none absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle",children:r("svg",{className:"h-2.5 w-2.5",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r("polyline",{points:"3 4.5 6 7.5 9 4.5"})})})]})]}),u("div",{className:"flex items-center gap-1.5",children:[z&&u("button",{"data-testid":"stream-intercom-toggle","data-intercom-shown":$?"true":"false",onClick:O,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${$?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:$?"Close intercom":"Open intercom",children:[r(lE,{className:"h-3 w-3"}),r("span",{className:"hidden xl:inline",children:"Intercom"})]}),L.map(le=>{const pe=le.tone==="primary"?"bg-primary text-primary-foreground":"bg-primary/15 text-primary";return u("button",{type:"button","data-toolbar-button-id":le.id,"data-toolbar-button-active":le.active?"true":"false",onClick:le.onClick,disabled:le.disabled,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors disabled:opacity-50 ${le.active?pe:"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:le.title??le.label,children:[le.icon,r("span",{className:"hidden xl:inline",children:le.label})]},le.id)}),b&&u("button",{"data-testid":"stream-play-toggle","data-stream-playing":de?"true":"false",onClick:de?ae:ee,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${de?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary/10 text-primary hover:bg-primary/20"}`,title:de?"Stop stream":"Start stream",children:[de?r(iE,{className:"h-3 w-3"}):r(Gi,{className:"h-3 w-3"}),r("span",{className:"hidden xl:inline",children:de?"Stop":"Play"})]}),w&&u("button",{"data-testid":"stream-snapshot-refresh",onClick:w,disabled:v,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",title:"Force snapshot refresh",children:[r(kx,{className:`h-3 w-3 ${v?"animate-spin":""}`}),r("span",{className:"hidden xl:inline",children:"Snapshot"})]}),(V||S||d||fe||h||oe&&oe.inputFps>0)&&u("div",{ref:re,className:"relative",children:[r("button",{onClick:()=>Y(le=>!le),title:"More controls",className:"inline-flex items-center justify-center rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:r(cE,{className:"h-3.5 w-3.5"})}),K&&u("div",{className:"absolute right-0 top-full mt-1 z-30 min-w-[200px] rounded-lg border border-border bg-surface shadow-xl py-1.5",children:[y&&h&&u("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Input"}),u("span",{className:"tabular-nums text-foreground",children:[h.inputFps.toFixed(1)," fps"]})]}),u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Decode"}),u("span",{className:"tabular-nums text-foreground",children:[h.decodeFps.toFixed(1)," fps"]})]}),u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Uptime"}),r("span",{className:"tabular-nums text-foreground",children:aE(h.uptimeMs)})]})]}),!y&&oe&&oe.inputFps>0&&u("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Input"}),u("span",{className:"tabular-nums text-foreground",children:[oe.inputFps.toFixed(1)," fps"]})]}),oe.bitrateKbps>0&&u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Bitrate"}),u("span",{className:"tabular-nums text-foreground",children:[oe.bitrateKbps," kbps"]})]})]}),(d||V&&fe)&&u("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[u("div",{className:"flex justify-between gap-3 items-center",children:[r("span",{children:"Phase"}),u("span",{className:`flex items-center gap-1 font-semibold uppercase tracking-wider ${he?"text-red-400":"text-emerald-400"}`,children:[r("span",{className:`w-1.5 h-1.5 rounded-full ${he?"bg-red-500 animate-pulse":"bg-emerald-500"}`}),he?"Active":"Watching"]})]}),d&&d.detectionFps>0&&u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Detection"}),u("span",{className:"tabular-nums text-foreground",children:[d.detectionFps.toFixed(1)," det/s"]})]}),d&&d.avgInferenceMs>0&&u("div",{className:"flex justify-between gap-3",children:[r("span",{children:"Inference"}),u("span",{className:"tabular-nums text-foreground",children:[d.avgInferenceMs.toFixed(0)," ms"]})]})]}),V&&u(xe,{children:[r(Ya,{label:"Show detections",active:B,onClick:()=>F(le=>!le)}),r(Ya,{label:"Show motion",active:j,onClick:()=>H(le=>!le)})]}),S&&r(Ya,{label:"PTZ controls",active:M,onClick:()=>{I?.(),Y(!1)}})]})]})]})]}),de?r("div",{className:"aspect-video relative",children:r(yx,{serverUrl:e,streamKey:te,autoPlay:!0,className:"w-full h-full",createSession:J,sendAnswer:n,closeSession:o,overlay:ie||k||ue?u(xe,{children:[ie&&r(xx,{detections:f,showPhaseIndicator:!1,showMotionZones:j,showMotionRaw:j,showDetections:B}),k,ue&&P]}):void 0},te)}):r(uE,{src:x??null,isLoading:v,onPlay:ee,onRetry:w,extraOverlay:k||ue?u(xe,{children:[k,ue&&P]}):null,suppressPlayHover:!!k||ue}),N]})}function uE({src:e,isLoading:t,onPlay:n,onRetry:o,extraOverlay:s,suppressPlayHover:a=!1}){return e?u("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:[r("img",{src:e,alt:"Camera snapshot",className:"w-full h-full object-contain"}),!a&&r("button",{onClick:n,className:"absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 hover:opacity-100 transition-opacity cursor-pointer",children:r("div",{className:"h-14 w-14 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center",children:r(Gi,{className:"h-7 w-7 text-white ml-0.5"})})}),s]}):t?r("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:r("div",{className:"h-8 w-8 border-2 border-white/20 border-t-white/60 rounded-full animate-spin"})}):r("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:u("div",{className:"flex flex-col items-center gap-2 text-white/40",children:[r(dE,{className:"h-8 w-8"}),r("span",{className:"text-xs",children:"No snapshot available"}),u("div",{className:"flex items-center gap-2 mt-1",children:[o&&u("button",{onClick:o,className:"inline-flex items-center gap-1.5 rounded-md border border-white/20 px-3 py-1.5 text-xs font-medium text-white/60 hover:text-white hover:border-white/40 transition-colors",children:[r(kx,{className:"h-3 w-3"}),"Retry"]}),u("button",{onClick:n,className:"inline-flex items-center gap-1.5 rounded-md bg-primary/80 px-3 py-1.5 text-xs font-medium text-white hover:bg-primary transition-colors",children:[r(Gi,{className:"h-3 w-3"}),"Play Live"]})]})]})})}function pE({samples:e,sampleRate:t=16e3,height:n=96,className:o="",color:s="#3b82f6",bgColor:a="transparent"}){const i=ne(null),l=ne(null),c=q(()=>{const p=i.current,m=l.current;if(!p||!m||!e||e.length===0)return;const h=m.clientWidth;if(h===0)return;const g=window.devicePixelRatio||1;p.width=h*g,p.height=n*g,p.style.width=`${h}px`,p.style.height=`${n}px`;const b=p.getContext("2d");if(!b)return;b.scale(g,g),a!=="transparent"?(b.fillStyle=a,b.fillRect(0,0,h,n)):b.clearRect(0,0,h,n);const x=e.length/h,v=n/2;b.fillStyle=s,b.globalAlpha=.7;for(let w=0;w<h;w++){const y=Math.floor(w*x),N=Math.min(Math.floor((w+1)*x),e.length);let k=0,S=0;for(let z=y;z<N;z++){const $=e[z];$<k&&(k=$),$>S&&(S=$)}const M=v-S*v,P=v-k*v,I=Math.max(1,P-M);b.fillRect(w,M,1,I)}b.globalAlpha=1,b.strokeStyle=s,b.globalAlpha=.2,b.lineWidth=1,b.beginPath(),b.moveTo(0,v),b.lineTo(h,v),b.stroke(),b.globalAlpha=1},[e,n,s,a]);Z(()=>{c()},[c]),Z(()=>{const p=new ResizeObserver(()=>c()),m=l.current;return m&&p.observe(m),()=>p.disconnect()},[c]);const f=((e&&t?Math.round(e.length/t*1e3):0)/1e3).toFixed(1);return u("div",{ref:l,className:`relative ${o}`,children:[r("canvas",{ref:i,className:"w-full rounded-md"}),e&&e.length>0&&u("div",{className:"absolute bottom-1 right-2 text-[10px] text-foreground-subtle/60 font-mono",children:[f,"s · ",t/1e3,"kHz · ",e.length.toLocaleString()," samples"]})]})}function fE({currentDbfs:e,durationSec:t=30,maxSamples:n=120,height:o=64,className:s="",color:a="#10b981",clipColor:i="#ef4444",clipThreshold:l=-6,minDbfs:c=-96}){const d=ne(null),f=ne(null),[p,m]=_([]);Z(()=>{e!==null&&m(b=>{const x=[...b,{dbfs:e,timestamp:Date.now()}];return x.length>n?x.slice(-n):x})},[e,n]);const h=q(()=>{const b=d.current,x=f.current;if(!b||!x)return;const v=x.clientWidth;if(v===0)return;const w=window.devicePixelRatio||1;b.width=v*w,b.height=o*w,b.style.width=`${v}px`,b.style.height=`${o}px`;const y=b.getContext("2d");if(!y||(y.scale(w,w),y.clearRect(0,0,v,o),p.length===0))return;const N=p[p.length-1].timestamp,k=t*1e3,S=N-k,M=p.filter($=>$.timestamp>=S);if(M.length===0)return;const P=Math.max(1,Math.floor(v/(t*2))),I=Math.abs(c);for(const $ of M){const O=$.timestamp-S,R=Math.floor(O/k*v),L=(Math.max(c,Math.min(0,$.dbfs))-c)/I,D=Math.max(1,L*o),T=$.dbfs>=l;y.fillStyle=T?i:a,y.globalAlpha=.8,y.fillRect(R,o-D,P,D)}y.globalAlpha=1;const z=o-(l-c)/I*o;y.strokeStyle=i,y.globalAlpha=.25,y.lineWidth=1,y.setLineDash([4,4]),y.beginPath(),y.moveTo(0,z),y.lineTo(v,z),y.stroke(),y.setLineDash([]),y.globalAlpha=1},[p,t,o,a,i,l,c]);Z(()=>{h()},[h]),Z(()=>{const b=new ResizeObserver(()=>h()),x=f.current;return x&&b.observe(x),()=>b.disconnect()},[h]);const g=p.length>0?p[p.length-1].dbfs:null;return u("div",{ref:f,className:`relative ${s}`,children:[r("canvas",{ref:d,className:"w-full rounded-md"}),u("div",{className:"absolute top-1 left-2 text-[9px] text-foreground-subtle/50 font-mono",children:[t,"s"]}),g!==null&&u("div",{className:"absolute bottom-1 right-2 text-[9px] text-foreground-subtle/50 font-mono",children:[g.toFixed(1)," dBFS · ",p.length," samples"]})]})}function mE(e){return e>=.8?"bg-emerald-500":e>=.5?"bg-amber-500":e>=.3?"bg-orange-500":"bg-zinc-500"}function hE(e){return e>=.8?"text-emerald-400":e>=.5?"text-amber-400":e>=.3?"text-orange-400":"text-zinc-400"}function gE({classifications:e,processing:t=!1,inferenceMs:n,maxItems:o=10,className:s=""}){const a=e.slice(0,o),i=a.length>0?a[0].score:1;return t?r("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${s}`,children:r("div",{className:"text-sm text-foreground-subtle animate-pulse",children:"Classifying audio..."})}):a.length===0?r("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${s}`,children:r("div",{className:"text-xs text-foreground-subtle",children:"No classifications yet"})}):u("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${s}`,children:[u("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between",children:[r("h3",{className:"text-xs font-medium text-foreground",children:"Audio Classifications"}),u("div",{className:"flex items-center gap-3 text-[10px] text-foreground-subtle",children:[a.length<e.length&&u("span",{children:["showing ",a.length," of ",e.length]}),n!==void 0&&u("span",{className:"font-mono",children:[n.toFixed(1),"ms"]})]})]}),r("div",{className:"divide-y divide-border/50",children:a.map((l,c)=>{const d=i>0?l.score/i*100:0;return u("div",{className:"px-3 py-1.5 flex items-center gap-3 hover:bg-surface-hover/30",children:[r("span",{className:"text-[10px] text-foreground-subtle w-5 text-right font-mono",children:c+1}),r("span",{className:"text-xs font-medium text-foreground min-w-[120px]",children:l.className}),r("div",{className:"flex-1 h-2 rounded-full bg-zinc-800 overflow-hidden",children:r("div",{className:`h-full rounded-full transition-all duration-300 ${mE(l.score)}`,style:{width:`${d}%`}})}),u("span",{className:`text-xs font-mono font-semibold w-14 text-right ${hE(l.score)}`,children:[(l.score*100).toFixed(1),"%"]})]},`${l.className}-${c}`)})})]})}function bE({data:e,label:t="Response",className:n=""}){const[o,s]=_(!1);if(!e)return null;const a=JSON.stringify(e,null,2);return u("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${n}`,children:[u("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between cursor-pointer select-none hover:bg-surface-hover/30",onClick:()=>s(i=>!i),children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-[10px] text-foreground-subtle",children:o?"▼":"▶"}),r("h3",{className:"text-xs font-medium text-foreground",children:t})]}),r("span",{className:"text-[10px] text-foreground-subtle font-mono",children:a.length>1e3?`${(a.length/1024).toFixed(1)} KB`:`${a.length} bytes`})]}),o&&r("div",{className:"max-h-80 overflow-y-auto overflow-x-auto",children:r("pre",{className:"p-3 text-[10px] leading-4 font-mono text-foreground-subtle whitespace-pre",children:a})})]})}const xE={Activity:xn,Eye:Xs,AlertTriangle:No,PauseCircle:y2,PowerOff:gk};function Ec({phase:e,...t}){const n=Gn(e),o=xE[n.icon];return r(o,{...t})}function Rn(e){const[t,n]=_([]),o=q(a=>{n(i=>{const l=[...i,a];return l.length>e?l.slice(-e):l})},[e]),s=q(()=>{n([])},[]);return U(()=>({entries:t,append:o,reset:s}),[t,o,s])}function gu(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 bu={error:{icon:Zs,color:"text-red-400"},warn:{icon:No,color:"text-amber-400"},info:{icon:G2,color:"text-blue-400"},debug:{icon:n2,color:"text-gray-500"}},xu={debug:0,info:1,warn:2,error:3},yE=["all","debug","info","warn","error"],vE=500;function wE(e,t){return t?(xu[e]??0)>=(xu[t]??0):!0}function Ut({agentId:e,addonId:t,deviceId:n,integrationId:o,requestId:s,level:a,maxHeight:i="max-h-96",showScope:l=!1,showFilters:c=!0,limit:d=100,liveBuffer:f,onClose:p,className:m}){const[h,g]=_(""),[b,x]=_(""),[v,w]=_(a),y=e,N=t??(h||void 0),k=n??(b?Number(b):void 0),S=o,M=s,P=U(()=>{const V={};return y&&(V.agentId=y),N&&(V.addonId=N),k!==void 0&&Number.isFinite(k)&&(V.deviceId=k),S&&(V.integrationId=S),M&&(V.requestId=M),Object.keys(V).length>0?V:void 0},[y,N,k,S,M]),I=Rn(vE),z=f??I,$=z.entries,[O,R]=_(0),[A,L]=_(!1),[D,T]=_(!1),[B,F]=_(new Set),[j,H]=_(""),E=ne(null),Q=`${y??""}:${N??""}:${String(k??"")}:${S??""}:${M??""}`,K=ne(Q);Z(()=>{K.current!==Q&&(K.current=Q,z.reset(),R(0),F(new Set))},[Q,z]);const{data:Y,isLoading:re}=C.logs.query.useQuery({...P?{tags:P}:{},limit:d},{staleTime:3e4});C.logs.subscribe.useSubscription({...P?{tags:P}:{}},{onData:V=>{z.append(V)}});const te=ne($.length);Z(()=>{const V=E.current;if(!V){te.current=$.length;return}const ie=te.current;if(te.current=$.length,!($.length<=ie)){if(A&&V.scrollTop<=8)V.scrollTo({top:0});else if(!A&&V.scrollTop>0){const ue=V.querySelector("tbody tr"),de=ue instanceof HTMLElement?ue.offsetHeight:24;V.scrollTop+=de*($.length-ie)}}},[$.length,A]);const X=U(()=>{const V=(Y??[]).map(pe=>({timestamp:pe.timestamp,level:pe.level,message:pe.message,scope:pe.scope,tags:pe.tags,meta:pe.meta})),ie=new Set,ue=[];for(const pe of[...$].reverse()){const Ie=`${pe.timestamp}|${pe.level}|${pe.scope??""}|${pe.message}`;ie.has(Ie)||(ie.add(Ie),ue.push(pe))}for(const pe of V){const Ie=`${pe.timestamp}|${pe.level}|${pe.scope??""}|${pe.message}`;ie.has(Ie)||(ie.add(Ie),ue.push(pe))}const le=(O>0?ue.filter(pe=>new Date(pe.timestamp).getTime()>O):ue).filter(pe=>wE(pe.level,v)),Se=j.trim().toLowerCase();return Se?le.filter(pe=>{if(pe.message.toLowerCase().includes(Se)||pe.scope&&pe.scope.toLowerCase().includes(Se))return!0;if(pe.tags){for(const Ie of Object.values(pe.tags))if(Ie!==void 0&&String(Ie).toLowerCase().includes(Se))return!0}if(pe.meta){for(const Ie of Object.values(pe.meta))if(Ie!=null&&gu(Ie).toLowerCase().includes(Se))return!0}return!1}):le},[Y,$,v,O,j]),oe=q(()=>{const V=X.map(ie=>{const ue=new Date(ie.timestamp).toLocaleTimeString(),de=ie.tags?" "+Object.entries(ie.tags).filter(([,le])=>le).map(([le,Se])=>`${le}=${Se}`).join(" "):"";return`${ue} [${ie.level.toUpperCase()}]${ie.scope?` [${ie.scope}]`:""}${de} ${ie.message}`});navigator.clipboard.writeText(V.join(`
|
|
532
|
+
`)).then(()=>{T(!0),setTimeout(()=>T(!1),1500)})},[X]),ge=C.logs.clear.useMutation(),J=q(()=>{R(Date.now()),z.reset(),ge.mutate({...P?{tags:P}:{}})},[z,ge,P]),G=q(V=>{F(ie=>{const ue=new Set(ie);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),[ee,ae]=_(null),fe=q((V,ie)=>{const ue=new Date(V.timestamp).toISOString(),de=V.tags?" "+Object.entries(V.tags).filter(([,pe])=>pe).map(([pe,Ie])=>`${pe}=${Ie}`).join(" "):"",le=V.meta&&Object.keys(V.meta).length>0?` meta=${JSON.stringify(V.meta)}`:"",Se=`${ue} [${V.level.toUpperCase()}]${V.scope?` [${V.scope}]`:""}${de} ${V.message}${le}`;navigator.clipboard.writeText(Se).then(()=>{ae(ie),setTimeout(()=>ae(pe=>pe===ie?null:pe),1200)})},[]),he=q(V=>`${V.timestamp}|${V.level}|${V.scope??""}|${V.message}`,[]);return u("div",{className:W("h-full min-h-0 flex flex-col",m),onClick:V=>V.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Logs"}),y&&r(Za,{label:"agent",value:y}),N&&r(Za,{label:"addon",value:N}),k!==void 0&&r(Za,{label:"device",value:`#${k}`}),r("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:yE.map(V=>u("button",{type:"button",onClick:()=>w(V==="all"?void 0:V),className:W("px-1.5 py-0.5 capitalize transition-colors",V==="all"&&!v||v===V?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover",V!=="all"&&"border-l border-border"),children:[V,V!=="all"?"+":""]},V))}),r(Xa,{icon:Rl,label:A?"Auto":"Paused",active:!A,onClick:()=>{L(V=>!V),!A&&E.current&&E.current.scrollTo({top:0,behavior:"smooth"})}}),r(Xa,{icon:Cn,label:D?"Copied!":"Copy",onClick:oe,disabled:X.length===0}),r(Xa,{icon:tn,label:"Clear",onClick:J}),u("div",{className:"relative",children:[r("input",{type:"text",value:j,onChange:V=>H(V.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),j&&r("button",{type:"button",onClick:()=>H(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:r(Xe,{className:"h-2.5 w-2.5"})})]}),$.length>0&&u("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",$.length," live"]})]}),p&&r("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:r(Xe,{className:"h-3.5 w-3.5"})})]}),c&&(!t||!n)&&u("div",{className:"flex items-center gap-2 px-3 py-1 border-b border-border/50 bg-surface/50 text-[10px]",children:[!t&&u("label",{className:"flex items-center gap-1",children:[r("span",{className:"text-foreground-subtle",children:"Addon:"}),r("input",{type:"text",value:h,onChange:V=>g(V.target.value),placeholder:"all",className:"w-28 px-1.5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"})]}),!n&&u("label",{className:"flex items-center gap-1",children:[r("span",{className:"text-foreground-subtle",children:"Device:"}),r("input",{type:"text",inputMode:"numeric",value:b,onChange:V=>x(V.target.value),placeholder:"all",className:"w-16 px-1.5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"})]})]}),u("div",{ref:E,className:W("flex-1 min-h-0 overflow-auto font-mono text-[10px]",i),children:[re&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[r(Lt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading logs..."]}),!re&&X.length===0&&r("div",{className:"py-4 text-center text-foreground-subtle",children:"No logs found"}),X.length>0&&r("table",{className:"w-full",children:r("tbody",{children:X.map(V=>{const ie=bu[V.level]??bu.info,ue=ie.icon,de=he(V),le=B.has(de),Se=V.tags&&Object.keys(V.tags).length>0,pe=V.meta&&Object.keys(V.meta).length>0,Ie=Se||pe;return u("tr",{className:W("hover:bg-surface-hover/30 border-b border-border/30",Ie&&"cursor-pointer"),onClick:Ie?()=>G(de):void 0,children:[r("td",{className:"px-2 py-1 text-foreground-subtle whitespace-nowrap align-top w-[70px]",children:new Date(V.timestamp).toLocaleTimeString()}),r("td",{className:W("px-1 py-1 align-top w-5",ie.color),children:r(ue,{className:"h-3 w-3"})}),l&&r("td",{className:"px-2 py-1 text-foreground-subtle align-top truncate max-w-[120px]",title:V.scope,children:V.scope?.replace(/^addon:/,"")??""}),r("td",{className:"px-2 py-1 text-foreground break-all",children:u("div",{className:"flex items-start gap-1",children:[Ie&&(le?r(Wn,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"}):r(Sn,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"})),u("div",{className:"flex-1 min-w-0",children:[V.message,le&&Ie&&u("div",{className:"mt-1 text-[9px] text-foreground-subtle bg-surface rounded px-2 py-1 space-y-0.5",children:[pe&&Object.entries(V.meta).filter(([,Te])=>Te!==void 0&&Te!=="").map(([Te,We])=>u("div",{children:[r("span",{className:"text-amber-400/80 font-medium",children:Te}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground break-all",children:gu(We)})]},`m-${Te}`)),Se&&Object.entries(V.tags).filter(([,Te])=>Te!==void 0).map(([Te,We])=>u("div",{children:[r("span",{className:"text-primary/70 font-medium",children:Te}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground",children:We})]},`t-${Te}`))]})]})]})}),r("td",{className:"px-1 py-1 align-top w-5",children:r(NE,{copied:ee===de,onCopy:()=>fe(V,de)})})]},de)})})})]})]})}function Sx({position:e="bottom",className:t,...n}){return r("div",{className:W(e==="bottom"?"absolute bottom-0 left-0 right-0 z-10 border-t border-border bg-surface/95 backdrop-blur-sm":"absolute inset-x-2 bottom-2 z-10 rounded-lg border border-border bg-surface/95 backdrop-blur-sm shadow-xl",t),children:r(Ut,{maxHeight:"max-h-48",...n})})}function Za({label:e,value:t}){return u("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function NE({copied:e,onCopy:t}){return r("button",{type:"button",title:"Copy this row",onClick:n=>{n.stopPropagation(),t()},className:W("rounded p-0.5 transition-colors",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?r(wo,{className:"h-3 w-3"}):r(Cn,{className:"h-3 w-3"})})}function Xa({icon:e,label:t,onClick:n,disabled:o,active:s}){return u("button",{type:"button",onClick:n,disabled:o,className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",s?"border-amber-500/30 bg-amber-500/10 text-amber-400":"border-border text-foreground-subtle hover:text-foreground",o&&"opacity-40 cursor-not-allowed"),children:[r(e,{className:"h-2.5 w-2.5"}),t]})}function kE(e,t,n,o){if(o!==void 0&&(e.source.deviceId??(e.source.type==="device"&&typeof e.source.id=="number"?e.source.id:void 0))!==o||n!==void 0&&(e.source.addonId??(e.source.type==="addon"&&typeof e.source.id=="string"?e.source.id:void 0))!==n)return!1;if(t!==void 0){const s=e.source.nodeId;if(!s||s!==t&&!s.startsWith(`${t}/`))return!1}return!0}const SE={[Ne.AddonStarted]:{icon:ji,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Started"},[Ne.AddonInstalled]:{icon:Bi,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Installed"},[Ne.AddonRestarted]:{icon:Bl,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Restarted"},[Ne.AddonUpdated]:{icon:Lm,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Updated"},[Ne.AddonStopped]:{icon:Vd,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Stopped"},[Ne.AddonUninstalled]:{icon:tn,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Uninstalled"},[Ne.AddonCrashed]:{icon:Zs,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Crashed"},[Ne.AddonError]:{icon:No,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Error"},[Ne.DetectionPhaseTransition]:{icon:xn,color:"bg-violet-500/15 text-violet-400 border-violet-500/30",label:"Phase"},[Ne.DetectionResult]:{icon:Mk,color:"bg-purple-500/15 text-purple-400 border-purple-500/30",label:"Detection"},[Ne.DetectionEvent]:{icon:Xs,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Event"},[Ne.DetectionCameraNative]:{icon:qd,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Camera AI"},[Ne.ProviderMotion]:{icon:Qd,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Ne.MotionOnMotionChanged]:{icon:Qd,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Ne.MotionAnalysis]:{icon:xn,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion analysis"},[Ne.MotionZonesRaw]:{icon:xn,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion zones"},[Ne.ProviderDetection]:{icon:qd,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Provider Det"},[Ne.PipelineAudioInferenceResult]:{icon:Am,color:"bg-pink-500/15 text-pink-400 border-pink-500/30",label:"Audio"},[Ne.AgentOnline]:{icon:ji,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Agent Online"},[Ne.AgentOffline]:{icon:Vd,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Agent Offline"},[Ne.DeviceRegistered]:{icon:Bi,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Registered"},[Ne.DeviceUnregistered]:{icon:tn,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Unregistered"},[Ne.DeviceStateChanged]:{icon:xn,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"State"}};function Wi(e,t){const n=SE[e]??{icon:ji,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:e.split(".").pop()??e};if(e===Ne.DeviceStateChanged&&t&&typeof t.capName=="string"){const o=t.capName;return{...n,label:o}}return n}const or=Object.freeze([...new Set(Object.values(Ne))].sort()),CE=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]),ME=new Set(CE),IE=Object.freeze(or.filter(e=>!ME.has(e)));function fs(e,t){if(e===Ne.DetectionPhaseTransition){const s=t.to,a=t.from,i=typeof t.source=="string"?t.source:null,l=typeof t.cooldownMs=="number"?t.cooldownMs:null,c=i?` (${i}${l?`, ${Math.round(l/1e3)}s cooldown`:""})`:"";return s==="active"?`Motion detected — phase active${c}`:s==="watching"?`Cooldown expired — phase watching${c}`:`Phase: ${String(a)} → ${String(s)}${c}`}if(e===Ne.DetectionResult){const a=t.frame?.detections??[];if(a.length===0)return null;const i=new Map;for(const l of a){const c=l,d=c.class??c.macroClass,f=typeof d=="string"?d:"";f&&i.set(f,(i.get(f)??0)+1)}return[...i.entries()].map(([l,c])=>c>1?`${l} ×${c}`:l).join(", ")}if(e===Ne.PipelineAudioInferenceResult){const a=t.frame?.detections??[];return a.length===0?null:a.map(i=>{const l=i,c=l.macroClass??l.class??l.label,d=typeof c=="string"?c:"",f=l.score;return f?`${d} (${Math.round(f*100)}%)`:d}).filter(Boolean).join(", ")}if(e===Ne.DetectionEvent){const s=t.label??t.class,a=t.score??t.confidence,i=[];return typeof s=="string"&&i.push(s),typeof a=="number"&&i.push(`${Math.round(a*100)}%`),i.length>0?i.join(" — "):null}if(e===Ne.ProviderMotion)return t.active===!0?"motion start":"motion stop";if(e===Ne.DeviceStateChanged){const s=t.slice;if(s&&typeof s=="object"){const a=Object.keys(s).filter(i=>i!=="lastFetchedAt"&&i!=="ts");if(a.length>0)return a.slice(0,4).join(", ")+(a.length>4?"…":"")}return null}if(e===Ne.MotionOnMotionChanged){const s=t.detected,a=typeof t.source=="string"?t.source:null,i=s===!0?"motion start":s===!1?"motion stop":"motion";return a?`${i} (${a})`:i}if(e===Ne.ProviderDetection||e===Ne.DetectionCameraNative){const s=t.detections??[];if(!Array.isArray(s)||s.length===0)return(typeof t.class=="string"?t.class:null)??null;const a=new Map;for(const i of s){const l=i,c=l.class??l.macroClass,d=typeof c=="string"?c:"";d&&a.set(d,(a.get(d)??0)+1)}return[...a.entries()].map(([i,l])=>l>1?`${i} ×${l}`:i).join(", ")}const n=t.addonId,o=t.error;return o||(n?`addon: ${n}`:null)}function AE(e){const t=e.category;return t===Ne.DetectionResult||t===Ne.PipelineAudioInferenceResult?fs(t,e.data)!==null:!0}const PE=300;function tr({agentId:e,addonId:t,deviceId:n,defaultCategories:o,categories:s,category:a,maxHeight:i="max-h-96",limit:l=50,showCategoryFilter:c=!0,showFilters:d=!1,liveBuffer:f,onClose:p,className:m}){const h=U(()=>o??s??IE,[o,s]),g=U(()=>[...h].sort().join(","),[h]),[b,x]=_(()=>new Set(h)),v=ne(g);Z(()=>{v.current!==g&&(v.current=g,x(new Set(h)))},[g,h]);const w=Rn(PE),y=f??w,N=y.entries,[k,S]=_(!0),[M,P]=_(new Set),[I,z]=_(""),[$,O]=_(!1),[R,A]=_(""),[L,D]=_(0),T=ne(null),B=ne(null),F=`${e??""}:${t??""}:${String(n??"")}:${a??""}`,j=ne(F);Z(()=>{j.current!==F&&(j.current=F,y.reset(),P(new Set),D(0))},[F,y]),Z(()=>{if(!$)return;const me=Ee=>{const _e=B.current;_e&&Ee.target instanceof Node&&!_e.contains(Ee.target)&&O(!1)};return document.addEventListener("mousedown",me),()=>{document.removeEventListener("mousedown",me)}},[$]);const H=U(()=>{const me={};return e&&(me.agentId=e),t&&(me.addonId=t),n!==void 0&&(me.deviceId=n),a&&(me.category=a),me},[e,t,n,a]),E=U(()=>[...b].sort(),[b]),Q=U(()=>E.join(","),[E]),K=U(()=>{const me={...H,limit:l};return E.length>0&&E.length<or.length&&(me.category=E),me},[H,l,Q,E]),{data:Y,isLoading:re}=C.systemEvents.getRecent.useQuery(K,{staleTime:3e4}),te=ne(b);Z(()=>{te.current=b},[b]);const X=H;C.systemEvents.subscribe.useSubscription(X,{onData:me=>{const Ee=me;Ee?.id&&kE(Ee,e,t,n)&&te.current.has(Ee.category)&&y.append(Ee)}});const oe=ne(N.length);Z(()=>{const me=T.current;if(!me){oe.current=N.length;return}const Ee=oe.current;if(oe.current=N.length,!(N.length<=Ee)){if(k&&me.scrollTop<=8)me.scrollTo({top:0});else if(!k&&me.scrollTop>0){const _e=me.firstElementChild?.firstElementChild,Re=_e instanceof HTMLElement?_e.offsetHeight:28;me.scrollTop+=Re*(N.length-Ee)}}},[N.length,k]);const ge=U(()=>{const me=new Map;for(const Re of Y??[])me.set(Re.id,Re);for(const Re of N)me.set(Re.id,Re);let Ee=[...me.values()].filter(Re=>b.has(Re.category)).filter(AE);L>0&&(Ee=Ee.filter(Re=>new Date(Re.timestamp).getTime()>L));const _e=I.trim().toLowerCase();return _e&&(Ee=Ee.filter(Re=>{if(Re.category.toLowerCase().includes(_e)||Wi(Re.category,Re.data).label.toLowerCase().includes(_e))return!0;const An=fs(Re.category,Re.data);if(An&&An.toLowerCase().includes(_e))return!0;try{if(new Date(Re.timestamp).toLocaleTimeString().toLowerCase().includes(_e))return!0}catch{}try{if(JSON.stringify(Re.data).toLowerCase().includes(_e)||JSON.stringify(Re.source).toLowerCase().includes(_e))return!0}catch{}return!1})),Ee.sort((Re,In)=>new Date(In.timestamp).getTime()-new Date(Re.timestamp).getTime())},[Y,N,b,I,L]),J=q(me=>{P(Ee=>{const _e=new Set(Ee);return _e.has(me)?_e.delete(me):_e.add(me),_e})},[]),G=q(me=>{x(Ee=>{const _e=new Set(Ee);return _e.has(me)?_e.delete(me):_e.add(me),_e})},[]),ee=q(()=>{x(new Set(h)),z(""),D(0)},[h]),ae=q(()=>{D(Date.now()),y.reset()},[y]),[fe,he]=_(!1),[V,ie]=_(null),ue=q(me=>{const Ee=new Date(me.timestamp).toISOString(),_e=fs(me.category,me.data)??"",Re=_e?` ${_e}`:"";return`${Ee} [${me.category}]${Re} data=${JSON.stringify(me.data)}`},[]),de=q(()=>{const me=ge.map(ue);navigator.clipboard.writeText(me.join(`
|
|
533
|
+
`)).then(()=>{he(!0),setTimeout(()=>he(!1),1500)})},[ge,ue]),le=q(me=>{navigator.clipboard.writeText(ue(me)).then(()=>{ie(me.id),setTimeout(()=>ie(Ee=>Ee===me.id?null:Ee),1200)})},[ue]),Se=q(()=>{x(new Set(or))},[]),pe=q(()=>{x(new Set)},[]),Ie=U(()=>{const me=R.trim().toLowerCase();return me?or.filter(Ee=>Ee.toLowerCase().includes(me)):or},[R]),Te=or.length,We=b.size,rt=We===Te,nr=rt?"All":`${We}/${Te}`;return u("div",{className:W("h-full min-h-0 flex flex-col",m),onClick:me=>me.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Events"}),e&&r(jo,{label:"agent",value:e}),t&&r(jo,{label:"addon",value:t}),n!==void 0&&r(jo,{label:"device",value:`#${n}`}),a&&r(jo,{label:"category",value:a}),u("button",{type:"button",onClick:()=>{S(me=>!me),!k&&T.current&&T.current.scrollTo({top:0,behavior:"smooth"})},className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",k?"border-border text-foreground-subtle hover:text-foreground":"border-amber-500/30 bg-amber-500/10 text-amber-400"),children:[r(Rl,{className:"h-2.5 w-2.5"}),k?"Auto":"Paused"]}),c&&u("div",{className:"relative",ref:B,children:[u("button",{type:"button",onClick:()=>O(me=>!me),className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",rt?"border-border text-foreground-subtle hover:text-foreground":"border-violet-500/30 bg-violet-500/10 text-violet-400"),title:"Pick events to track",children:[r(Cm,{className:"h-2.5 w-2.5"}),"Filter (",nr,")"]}),$&&r(EE,{search:R,onSearchChange:A,categories:Ie,active:b,onToggle:G,onSelectAll:Se,onSelectNone:pe,onResetDefaults:ee})]}),u("button",{type:"button",onClick:ee,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Reset filters to defaults",children:[r($m,{className:"h-2.5 w-2.5"}),"Reset"]}),u("button",{type:"button",onClick:ae,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Clear visible entries",children:[r(tn,{className:"h-2.5 w-2.5"}),"Clear"]}),u("button",{type:"button",onClick:de,disabled:ge.length===0,className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",fe?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",ge.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible events",children:[r(Cn,{className:"h-2.5 w-2.5"}),fe?"Copied!":"Copy"]}),u("div",{className:"relative",children:[r("input",{type:"text",value:I,onChange:me=>z(me.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),I&&r("button",{type:"button",onClick:()=>z(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:r(Xe,{className:"h-2.5 w-2.5"})})]}),N.length>0&&u("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",N.length," live"]})]}),p&&r("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:r(Xe,{className:"h-3.5 w-3.5"})})]}),u("div",{ref:T,className:W("flex-1 min-h-0 overflow-auto text-[10px]",i),children:[re&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[r(Lt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading events..."]}),!re&&ge.length===0&&r("div",{className:"py-4 text-center text-foreground-subtle",children:"No events found"}),ge.length>0&&r("div",{className:"divide-y divide-border/30",children:ge.map(me=>{const Ee=Wi(me.category,me.data),_e=Ee.icon,Re=fs(me.category,me.data),In=M.has(me.id);return u("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>J(me.id),children:[r("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(me.timestamp).toLocaleTimeString()}),r(_E,{copied:V===me.id,onCopy:()=>le(me)}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5",children:[In?r(Wn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):r(Sn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),u("span",{className:W("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[9px] font-medium",Ee.color),children:[r(_e,{className:"h-2.5 w-2.5"}),Ee.label]}),me.source.nodeId&&me.source.nodeId!=="hub"&&r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-foreground-subtle/10 text-foreground-subtle font-mono",children:me.source.nodeId})]}),Re&&r("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5",children:Re}),In&&u("div",{className:"mt-1 ml-5 text-[9px] bg-surface rounded px-2 py-1.5 space-y-0.5 font-mono overflow-x-auto",children:[u("div",{children:[r("span",{className:"text-primary/70",children:"source"}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground",children:JSON.stringify(me.source)})]}),u("div",{children:[r("span",{className:"text-primary/70",children:"category"}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground",children:me.category})]}),Object.entries(me.data).map(([An,Rr])=>u("div",{children:[r("span",{className:"text-primary/70",children:An}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground break-all",children:typeof Rr=="object"?JSON.stringify(Rr):String(Rr)})]},An))]})]})]},me.id)})})]})]})}function EE({search:e,onSearchChange:t,categories:n,active:o,onToggle:s,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return u("div",{className:"absolute z-20 top-full mt-1 left-0 w-72 max-h-80 rounded-md border border-border bg-surface shadow-lg flex flex-col",onClick:c=>c.stopPropagation(),children:[u("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[r(ro,{className:"h-3 w-3 text-foreground-subtle"}),r("input",{type:"text",value:e,onChange:c=>t(c.target.value),placeholder:"Filter categories…",className:"flex-1 bg-transparent text-[10px] focus:outline-none text-foreground placeholder:text-foreground-subtle",autoFocus:!0}),e&&r("button",{type:"button",onClick:()=>t(""),className:"text-foreground-subtle hover:text-foreground",children:r(Xe,{className:"h-2.5 w-2.5"})})]}),u("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[r("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),r("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),r("button",{type:"button",onClick:l,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),u("div",{className:"overflow-y-auto flex-1",children:[n.length===0&&r("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),n.map(c=>{const d=o.has(c),f=Wi(c),p=f.icon;return u("button",{type:"button",onClick:()=>s(c),className:"w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]",children:[r("input",{type:"checkbox",readOnly:!0,checked:d,className:"accent-violet-500"}),u("span",{className:W("inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[9px] font-medium shrink-0",f.color),children:[r(p,{className:"h-2.5 w-2.5"}),f.label]}),r("span",{className:"text-foreground-subtle font-mono truncate",children:c})]},c)})]})]})}function $E({position:e="bottom",className:t,...n}){return r("div",{className:W(e==="bottom"?"absolute bottom-0 left-0 right-0 z-10 border-t border-border bg-surface/95 backdrop-blur-sm":"absolute inset-x-2 bottom-2 z-10 rounded-lg border border-border bg-surface/95 backdrop-blur-sm shadow-xl",t),children:r(tr,{maxHeight:"max-h-48",...n})})}function jo({label:e,value:t}){return u("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function _E({copied:e,onCopy:t}){return r("button",{type:"button",title:"Copy this event",onClick:n=>{n.stopPropagation(),t()},className:W("rounded p-0.5 transition-colors mt-0.5",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?r(wo,{className:"h-3 w-3"}):r(Cn,{className:"h-3 w-3"})})}function Cx({deviceId:e,className:t="",onOpenChild:n}){const o=C.useUtils(),s=C.deviceDiscovery.listDiscovered.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),a=C.deviceDiscovery.getStatus.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),i=C.deviceDiscovery.refreshDiscovery.useMutation({onSuccess:()=>{o.deviceDiscovery.listDiscovered.invalidate({deviceId:e}),o.deviceDiscovery.getStatus.invalidate({deviceId:e})}}),l=C.deviceDiscovery.adoptDevice.useMutation({onSuccess:()=>{o.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),c=C.deviceDiscovery.releaseDevice.useMutation({onSuccess:()=>{o.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),[d,f]=_(null),{available:p,adopted:m}=U(()=>{const y=s.data??[],N=S=>typeof S.metadata.rtspChannel=="number"?S.metadata.rtspChannel:Number.POSITIVE_INFINITY,k=(S,M)=>{const P=N(S),I=N(M);return P!==I?P-I:S.name.localeCompare(M.name)};return{available:y.filter(S=>!S.alreadyAdopted).sort(k),adopted:y.filter(S=>S.alreadyAdopted).sort(k)}},[s.data]),h=a.data,g=h?.lastError??null,b=h?.lastDiscoveryAt??null;async function x(){await i.mutateAsync({deviceId:e}).catch(()=>{})}async function v(y){f(y.childNativeId);try{await l.mutateAsync({deviceId:e,childNativeId:y.childNativeId})}finally{f(null)}}async function w(y){if(y.adoptedDeviceId!=null){f(y.childNativeId);try{await c.mutateAsync({deviceId:e,childDeviceId:y.adoptedDeviceId})}finally{f(null)}}}return u("div",{className:`rounded-xl border border-border bg-surface ${t}`,children:[u("div",{className:"flex items-start justify-between gap-2 border-b border-border px-3 py-2 sm:px-5 sm:py-3",children:[u("div",{className:"min-w-0",children:[r("h3",{className:"text-sm font-semibold text-foreground",children:"Discovered devices"}),u("p",{className:"text-[11px] text-foreground-subtle",children:["Channels behind this hub. Click ",r("span",{className:"font-medium",children:"Add"})," to promote a channel to a managed device, or ",r("span",{className:"font-medium",children:"Remove"})," to detach."]})]}),u("button",{type:"button",onClick:x,disabled:i.isPending,className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-2 py-1.5 sm:px-3 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 shrink-0",children:[i.isPending?r(Lt,{className:"h-3.5 w-3.5 animate-spin"}):r(Bl,{className:"h-3.5 w-3.5"}),r("span",{className:"hidden sm:inline",children:"Refresh"})]})]}),g?u("div",{className:"flex items-start gap-2 border-b border-border bg-destructive/10 px-5 py-2 text-[11px] text-destructive",children:[r(No,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),u("span",{children:["Last refresh failed: ",g]})]}):null,s.isLoading?r("div",{className:"flex items-center justify-center py-8 text-foreground-subtle",children:r(Lt,{className:"h-5 w-5 animate-spin"})}):p.length===0&&m.length===0?r("div",{className:"px-5 py-8 text-center text-xs text-foreground-subtle",children:"No channels reported by the hub yet. Click Refresh to enumerate."}):u(xe,{children:[p.length>0?r(yu,{title:"Available to add",count:p.length,tone:"primary",children:p.map(y=>r(vu,{child:y,busy:d===y.childNativeId,onAdopt:v,onRelease:w,onOpenChild:n},y.childNativeId))}):null,m.length>0?r(yu,{title:"Already adopted",count:m.length,tone:"muted",children:m.map(y=>r(vu,{child:y,busy:d===y.childNativeId,onAdopt:v,onRelease:w,onOpenChild:n},y.childNativeId))}):null]}),b!=null?u("div",{className:"border-t border-border px-5 py-2 text-[10px] text-foreground-subtle",children:["Last refreshed ",new Date(b).toLocaleString()]}):null]})}function yu({title:e,count:t,tone:n,children:o}){return u("div",{className:"border-t border-border",children:[u("div",{className:`flex items-center justify-between border-b px-3 sm:px-5 py-1.5 text-[10px] uppercase tracking-wider ${n==="primary"?"bg-primary/5 text-primary border-primary/30":"bg-surface text-foreground-subtle border-border"}`,children:[r("span",{className:"font-semibold",children:e}),r("span",{className:"font-mono",children:t})]}),r("div",{className:"divide-y divide-border",children:o})]})}function vu({child:e,busy:t,onAdopt:n,onRelease:o,onOpenChild:s}){return u("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2 sm:px-5 sm:py-3 sm:flex-nowrap sm:gap-3",children:[u("div",{className:"min-w-0 flex-1",children:[u("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[r(DE,{status:e.status}),r("span",{className:"truncate text-sm font-medium text-foreground",children:e.name}),e.metadata.isDoorbell?r("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Doorbell"}):null,e.metadata.isBattery?r("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Battery"}):null,e.metadata.isMultifocal?r("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Multifocal"}):null]}),u("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-foreground-subtle",children:[typeof e.metadata.rtspChannel=="number"?u("span",{children:["ch ",r("span",{className:"font-mono",children:e.metadata.rtspChannel})]}):null,e.metadata.model?r("span",{className:"truncate max-w-[160px]",children:e.metadata.model}):null,e.metadata.uid?u("span",{className:"font-mono truncate max-w-[140px]",children:[e.metadata.uid.slice(0,12),"…"]}):null]})]}),e.alreadyAdopted?u("div",{className:"flex items-center gap-2",children:[s&&e.adoptedDeviceId!==null?u("button",{type:"button",onClick:()=>s(e.adoptedDeviceId),className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",title:"Open device detail",children:[r(km,{className:"h-3.5 w-3.5"}),"Open"]}):null,u("button",{type:"button",onClick:()=>{o(e)},disabled:t,className:"inline-flex items-center gap-1.5 rounded-lg border border-destructive/30 px-3 py-1.5 text-xs text-destructive hover:bg-destructive/10 transition-colors disabled:opacity-50",children:[t?r(Lt,{className:"h-3.5 w-3.5 animate-spin"}):r(tn,{className:"h-3.5 w-3.5"}),"Remove"]})]}):u("button",{type:"button",onClick:()=>{n(e)},disabled:t,className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:[t?r(Lt,{className:"h-3.5 w-3.5 animate-spin"}):r(Js,{className:"h-3.5 w-3.5"}),"Add"]})]})}function DE({status:e}){switch(e){case"online":return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-emerald-500/40 bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-500",children:[r(Tm,{className:"h-2.5 w-2.5"})," online"]});case"sleeping":return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-500",children:[r(zl,{className:"h-2.5 w-2.5"})," sleeping"]});case"offline":return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-destructive/40 bg-destructive/10 px-2 py-0.5 text-[10px] font-medium text-destructive",children:[r(r5,{className:"h-2.5 w-2.5"})," offline"]});case"unknown":default:return u("span",{className:"inline-flex items-center gap-1 rounded-full border border-border bg-surface px-2 py-0.5 text-[10px] font-medium text-foreground-subtle",children:[r(ym,{className:"h-2.5 w-2.5"})," unknown"]})}}function LE(e,t){if(!e||typeof e!="object")return!1;const n=e;if(n.category!==Ne.DeviceStateChanged)return!1;const o=n.data;return!(!o||typeof o!="object"||o.deviceId!==t||typeof o.capName!="string"||!o.slice||typeof o.slice!="object")}function Ja(e){if(!e||typeof e!="object")return null;const t=e,n=typeof t.id=="string"?t.id:null,o=typeof t.timestamp=="string"?t.timestamp:null,s=t.data;return!n||!o||!s||typeof s!="object"||typeof s.capName!="string"||!s.slice||typeof s.slice!="object"?null:{id:n,timestamp:o,capName:s.capName,slice:s.slice}}const TE=300,RE=Object.freeze([...new Set(sw.filter(e=>e.scope==="device").map(e=>e.name))].sort());function $c({deviceId:e,defaultCaps:t,maxHeight:n="max-h-96",limit:o=50,liveBuffer:s,onClose:a,className:i}){const l=U(()=>new Set(t??[]),[t]),[c,d]=_(l),[f,p]=_(""),[m,h]=_(!0),[g,b]=_(new Set),[x,v]=_(0),[w,y]=_(!1),[N,k]=_(""),S=ne(null),M=Rn(TE),P=s??M,I=P.entries,z=ne(null),$=ne(e);Z(()=>{$.current!==e&&($.current=e,P.reset(),b(new Set),v(0))},[e,P]);const O=U(()=>({deviceId:e,category:Ne.DeviceStateChanged,limit:o}),[e,o]),{data:R,isLoading:A}=C.systemEvents.getRecent.useQuery(O,{staleTime:3e4}),L=ne(c);Z(()=>{L.current=c},[c]),C.systemEvents.subscribe.useSubscription({deviceId:e,category:Ne.DeviceStateChanged},{onData:V=>{if(!LE(V,e))return;const ie=Ja(V);if(!ie)return;const ue=L.current;ue.size>0&&!ue.has(ie.capName)||P.append(ie)}});const D=ne(I.length);Z(()=>{const V=z.current;if(!V){D.current=I.length;return}const ie=D.current;if(D.current=I.length,!(I.length<=ie)){if(m&&V.scrollTop<=8)V.scrollTo({top:0});else if(!m&&V.scrollTop>0){const ue=V.firstElementChild?.firstElementChild,de=ue instanceof HTMLElement?ue.offsetHeight:28,le=I.length-ie;V.scrollTop+=de*le}}},[I.length,m]);const T=U(()=>{const V=new Map;for(const de of R??[]){const le=Ja(de);le&&V.set(le.id,le)}for(const de of I)V.set(de.id,de);let ie=[...V.values()];x>0&&(ie=ie.filter(de=>new Date(de.timestamp).getTime()>x)),c.size>0&&(ie=ie.filter(de=>c.has(de.capName)));const ue=f.trim().toLowerCase();return ue&&(ie=ie.filter(de=>{if(de.capName.toLowerCase().includes(ue))return!0;try{if(new Date(de.timestamp).toLocaleTimeString().toLowerCase().includes(ue))return!0}catch{}try{if(Object.entries(de.slice).map(([Se,pe])=>`${Se}=${ei(pe)}`).join(" · ").toLowerCase().includes(ue))return!0}catch{}try{if(JSON.stringify(de.slice).toLowerCase().includes(ue))return!0}catch{}return!1})),ie.sort((de,le)=>new Date(le.timestamp).getTime()-new Date(de.timestamp).getTime())},[R,I,c,f,x]),B=U(()=>{const V=new Set(RE);for(const ie of R??[]){const ue=Ja(ie);ue&&V.add(ue.capName)}for(const ie of I)V.add(ie.capName);return[...V].sort()},[R,I]),F=q(V=>{b(ie=>{const ue=new Set(ie);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),j=q(V=>{d(ie=>{const ue=new Set(ie);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),H=q(()=>{d(new Set(t??[])),p("")},[t]),E=q(()=>{v(Date.now()),P.reset()},[P]),[Q,K]=_(!1),[Y,re]=_(null),te=q(V=>`${new Date(V.timestamp).toISOString()} [${V.capName}] slice=${JSON.stringify(V.slice)}`,[]),X=q(()=>{const V=T.map(te);navigator.clipboard.writeText(V.join(`
|
|
534
|
+
`)).then(()=>{K(!0),setTimeout(()=>K(!1),1500)})},[T,te]),oe=q(V=>{navigator.clipboard.writeText(te(V)).then(()=>{re(V.id),setTimeout(()=>re(ie=>ie===V.id?null:ie),1200)})},[te]),ge=q(()=>{d(new Set(B))},[B]),J=q(()=>{d(new Set)},[]),G=U(()=>{const V=N.trim().toLowerCase();return V?B.filter(ie=>ie.toLowerCase().includes(V)):B},[N,B]),ee=B.length,ae=c.size,fe=ae===0||ae===ee,he=fe?"All":`${ae}/${ee}`;return Z(()=>{if(!w)return;const V=ie=>{const ue=S.current;ue&&!ue.contains(ie.target)&&y(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[w]),u("div",{className:W("h-full min-h-0 flex flex-col",i),onClick:V=>V.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"State"}),r(OE,{label:"device",value:`#${e}`}),u("button",{type:"button",onClick:()=>{h(V=>!V),!m&&z.current&&z.current.scrollTo({top:0,behavior:"smooth"})},className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",m?"border-border text-foreground-subtle hover:text-foreground":"border-amber-500/30 bg-amber-500/10 text-amber-400"),children:[r(Rl,{className:"h-2.5 w-2.5"}),m?"Auto":"Paused"]}),u("div",{className:"relative",ref:S,children:[u("button",{type:"button",onClick:()=>y(V=>!V),className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",fe?"border-border text-foreground-subtle hover:text-foreground":"border-violet-500/30 bg-violet-500/10 text-violet-400"),title:"Pick caps to track",children:[r(Cm,{className:"h-2.5 w-2.5"}),"Filter (",he,")"]}),w&&r(zE,{search:N,onSearchChange:k,caps:G,active:c,onToggle:j,onSelectAll:ge,onSelectNone:J,onResetDefaults:H})]}),u("button",{type:"button",onClick:H,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Reset filters",children:[r($m,{className:"h-2.5 w-2.5"}),"Reset"]}),u("button",{type:"button",onClick:E,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Clear visible entries",children:[r(tn,{className:"h-2.5 w-2.5"}),"Clear"]}),u("button",{type:"button",onClick:X,disabled:T.length===0,className:W("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",Q?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",T.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible state changes",children:[r(Cn,{className:"h-2.5 w-2.5"}),Q?"Copied!":"Copy"]}),u("div",{className:"relative",children:[r("input",{type:"text",value:f,onChange:V=>p(V.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),f&&r("button",{type:"button",onClick:()=>p(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:r(Xe,{className:"h-2.5 w-2.5"})})]}),I.length>0&&u("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",I.length," live"]})]}),a&&r("button",{type:"button",onClick:a,className:"text-foreground-subtle hover:text-foreground",children:r(Xe,{className:"h-3.5 w-3.5"})})]}),u("div",{ref:z,className:W("flex-1 min-h-0 overflow-auto text-[10px]",n),children:[A&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[r(Lt,{className:"h-3.5 w-3.5 animate-spin"}),"Loading state changes..."]}),!A&&T.length===0&&r("div",{className:"py-4 text-center text-foreground-subtle",children:"No state changes"}),T.length>0&&r("div",{className:"divide-y divide-border/30",children:T.map(V=>{const ie=g.has(V.id),ue=Object.entries(V.slice),de=ue.slice(0,3).map(([le,Se])=>`${le}=${ei(Se)}`).join(" · ");return u("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>F(V.id),children:[r("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(V.timestamp).toLocaleTimeString()}),r(BE,{copied:Y===V.id,onCopy:()=>oe(V)}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5",children:[ie?r(Wn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):r(Sn,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),r("span",{className:"inline-flex items-center gap-1 rounded-full border border-violet-500/30 bg-violet-500/15 text-violet-400 px-2 py-0.5 text-[9px] font-medium",children:V.capName}),ue.length>3&&u("span",{className:"text-[9px] text-foreground-subtle",children:["+",ue.length-3," more"]})]}),de&&r("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5 truncate",children:de}),ie&&r("div",{className:"mt-1 ml-5 text-[9px] bg-surface rounded px-2 py-1.5 space-y-0.5 font-mono overflow-x-auto",children:ue.length===0?r("div",{className:"text-foreground-subtle italic",children:"empty slice"}):ue.map(([le,Se])=>u("div",{children:[r("span",{className:"text-primary/70",children:le}),r("span",{className:"text-foreground-subtle",children:": "}),r("span",{className:"text-foreground break-all",children:ei(Se)})]},le))})]})]},V.id)})})]})]})}function ei(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function OE({label:e,value:t}){return u("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function zE({search:e,onSearchChange:t,caps:n,active:o,onToggle:s,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return u("div",{className:"absolute z-20 top-full mt-1 left-0 w-72 max-h-80 rounded-md border border-border bg-surface shadow-lg flex flex-col",onClick:c=>c.stopPropagation(),children:[u("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[r(ro,{className:"h-3 w-3 text-foreground-subtle"}),r("input",{type:"text",value:e,onChange:c=>t(c.target.value),placeholder:"Filter caps…",className:"flex-1 bg-transparent text-[10px] focus:outline-none text-foreground placeholder:text-foreground-subtle",autoFocus:!0}),e&&r("button",{type:"button",onClick:()=>t(""),className:"text-foreground-subtle hover:text-foreground",children:r(Xe,{className:"h-2.5 w-2.5"})})]}),u("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[r("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),r("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),r("button",{type:"button",onClick:l,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),u("div",{className:"overflow-y-auto flex-1",children:[n.length===0&&r("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),n.map(c=>{const d=o.has(c);return u("button",{type:"button",onClick:()=>s(c),className:"w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]",children:[r("input",{type:"checkbox",readOnly:!0,checked:d,className:"accent-violet-500"}),r("span",{className:"inline-flex items-center gap-1 rounded-full border border-violet-500/30 bg-violet-500/15 text-violet-400 px-1.5 py-0.5 text-[9px] font-medium shrink-0",children:c})]},c)})]})]})}function BE({copied:e,onCopy:t}){return r("button",{type:"button",title:"Copy this state change",onClick:n=>{n.stopPropagation(),t()},className:W("rounded p-0.5 transition-colors mt-0.5",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?r(wo,{className:"h-3 w-3"}):r(Cn,{className:"h-3 w-3"})})}const ti=500,FE=[{id:"logs",label:"Logs",icon:Ak},{id:"events",label:"Events",icon:Ys},{id:"state",label:"State",icon:_2}];function jE({deviceId:e,defaultEventCategories:t,defaultStateCaps:n,initialTab:o="events",className:s,maxHeight:a="max-h-96"}){const[i,l]=_(o),c=Rn(ti),d=Rn(ti),f=Rn(ti),p=c.reset,m=d.reset,h=f.reset;return Z(()=>{p(),m(),h()},[e,p,m,h]),u("div",{className:W("flex flex-col h-full min-h-0",s),children:[r("div",{className:"flex items-center gap-1 mb-2 shrink-0",children:FE.map(({id:g,label:b,icon:x})=>u("button",{type:"button",onClick:()=>l(g),className:W("inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[11px] font-medium transition-colors",i===g?"bg-primary/15 text-primary border border-primary/30":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover border border-transparent"),children:[r(x,{className:"h-3.5 w-3.5"}),b]},g))}),u("div",{className:"flex-1 min-h-0 overflow-hidden",children:[i==="logs"&&r(Ut,{deviceId:e,maxHeight:a,showFilters:!1,liveBuffer:c}),i==="events"&&r(tr,{deviceId:e,defaultCategories:t,maxHeight:a,showCategoryFilter:!0,liveBuffer:d}),i==="state"&&r($c,{deviceId:e,defaultCaps:n,maxHeight:a,liveBuffer:f})]})]})}function Mx({label:e,icon:t,title:n="Confirm action",description:o,confirmLabel:s,triggerVariant:a="outline",confirmVariant:i="danger",size:l="sm",disabled:c,className:d,action:f,onSuccess:p}){const[m,h]=_(!1),[g,b]=_(!1),[x,v]=_(null),w=async()=>{v(null),b(!0);try{const y=await f();p?.(y),h(!1)}catch(y){v(y instanceof Error?y.message:String(y))}finally{b(!1)}};return u(xe,{children:[u(Qe,{type:"button",variant:a,size:l,disabled:c,onClick:()=>{v(null),h(!0)},className:d,children:[t&&r(t,{className:"h-3.5 w-3.5"}),e]}),r(jm,{open:m,onOpenChange:y=>!g&&h(y),children:u(Ql,{children:[u(Hm,{children:[u(qm,{className:"flex items-center gap-2",children:[r(No,{className:"h-4 w-4 text-amber-400"}),n]}),typeof o=="string"?r(Qm,{children:o}):o]}),x&&r("div",{className:W("mt-2 px-3 py-2 rounded border border-danger/40 bg-danger/10","text-xs text-danger"),children:x}),u(Vm,{children:[r(Qe,{type:"button",variant:"ghost",size:l,disabled:g,onClick:()=>h(!1),children:"Cancel"}),u(Qe,{type:"button",variant:i,size:l,disabled:g,onClick:()=>{w()},children:[g&&r(Lt,{className:"h-3.5 w-3.5 animate-spin"}),s??e]})]})]})})]})}function Ho({direction:e,icon:t,disabled:n,className:o,variant:s,onMove:a,onStart:i,onStop:l}){const[c,d]=_(null),[f,p]=_(!1),m=q(w=>{if(n)return;w.currentTarget.setPointerCapture(w.pointerId),d(Date.now()),p(!1);const y=setTimeout(()=>{p(!0),i(e)},250);w.currentTarget.dataset.timer=String(y)},[e,n,i]),h=q(w=>{const y=Number(w.currentTarget.dataset.timer);y&&clearTimeout(y),w.currentTarget.dataset.timer="",f?l():c!==null&&a(e),d(null),p(!1)},[f,e,a,l,c]),g=q(w=>{const y=Number(w.currentTarget.dataset.timer);y&&clearTimeout(y),w.currentTarget.dataset.timer="",f&&l(),d(null),p(!1)},[f,l]),b=s==="panel"?"h-9 w-9":"h-7 w-7",x=s==="panel"?"h-4 w-4":"h-3.5 w-3.5";return r("button",{type:"button",disabled:n,onPointerDown:m,onPointerUp:h,onPointerCancel:g,className:W("flex items-center justify-center rounded transition-colors disabled:opacity-40",s==="panel"?"text-foreground hover:bg-surface-hover active:bg-surface-hover/80":"text-white hover:bg-white/15 active:bg-white/25",b,o),title:e,children:r(t,{className:x})})}function _c({controls:e,mode:t="overlay",showPresets:n,showZoom:o=!0,showHome:s=!0,className:a}){const{move:i,startContinuous:l,stopContinuous:c,zoom:d,goHome:f,goToPreset:p,presets:m,busy:h,error:g}=e,[b,x]=_(!1),v=(n??m.length>0)&&m.length>0,w=t==="panel",y=w?"flex flex-col items-stretch gap-2 w-full h-full p-3":"pointer-events-auto absolute top-3 right-3 z-10 flex flex-col items-end gap-2",N=W(w?"flex items-center gap-3 rounded-lg p-2":"flex items-center gap-2 rounded-lg border border-white/30 bg-zinc-900/90 backdrop-blur-md p-2 shadow-lg shadow-black/40",h&&"ring-1 ring-primary/40"),k=w?"h-9 w-9":"h-7 w-7",S=w?"h-4 w-4":"h-3.5 w-3.5",M=w?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15",P=w?"h-12 w-px bg-border mx-1":"h-12 w-px bg-white/15 mx-1";return u("div",{className:W(y,a),children:[g&&u("div",{className:"rounded bg-danger/90 px-2 py-1 text-[10px] font-medium text-white shadow-lg max-w-[200px] self-center",children:["PTZ: ",g]}),u("div",{className:W(N,w&&"justify-center"),children:[u("div",{className:"grid grid-cols-3 gap-0.5",children:[r("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),r(Ho,{direction:"up",icon:qN,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),r(Ho,{direction:"left",icon:BN,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),r(Ho,{direction:"right",icon:jN,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"}),r(Ho,{direction:"down",icon:ON,variant:t,onMove:i,onStart:l,onStop:c}),r("span",{"aria-hidden":!0,className:w?"h-9 w-9":"h-7 w-7"})]}),(o||s)&&r("div",{className:P}),u("div",{className:"flex flex-col gap-0.5",children:[o&&u(xe,{children:[r("button",{type:"button",onClick:()=>d("in"),disabled:h,title:"Zoom in",className:W("flex items-center justify-center rounded disabled:opacity-40",k,M),children:r(c5,{className:S})}),r("button",{type:"button",onClick:()=>d("out"),disabled:h,title:"Zoom out",className:W("flex items-center justify-center rounded disabled:opacity-40",k,M),children:r(u5,{className:S})})]}),s&&r("button",{type:"button",onClick:()=>f(),disabled:h,title:"Go home",className:W("flex items-center justify-center rounded disabled:opacity-40",k,M),children:r(Mm,{className:S})})]}),v&&u("div",{className:"relative",children:[u("button",{type:"button",onClick:()=>x(I=>!I),disabled:h,className:W("flex items-center gap-1 rounded px-2 text-[10px] disabled:opacity-40",w?"h-9 text-foreground hover:bg-surface-hover":"h-7 text-white hover:bg-white/15"),title:"Presets",children:["Presets",r(Wn,{className:W("h-3 w-3 transition-transform",b&&"rotate-180")})]}),b&&r("div",{className:W("absolute right-0 min-w-[140px] rounded-lg shadow-xl py-1 z-20",w?"bottom-full mb-1 bg-surface border border-border":"top-full mt-1 border border-white/30 bg-zinc-900/95 backdrop-blur-md"),children:m.map(I=>r("button",{type:"button",onClick:()=>{p(I.id),x(!1)},disabled:h,className:W("block w-full px-3 py-1.5 text-left text-[10px] disabled:opacity-40",w?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15"),children:I.name||I.id},I.id))})]})]})]})}function HE(e,t){const n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function VE({trpc:e,deviceId:t,deviceName:n,size:o="sm",className:s}){const[a,i]=_(!1),[l,c]=_(!1),[d,f]=_(null),p=n.replace(/[^a-zA-Z0-9_.-]+/g,"_"),m=q(async k=>{i(!0),f(null),c(!1);try{const S=await e.snapshot.getSnapshot.query({deviceId:t,force:!0});if(!S)throw new Error("No snapshot available");const M=`data:${S.contentType};base64,${S.base64}`;if(k==="copy")try{await navigator.clipboard.writeText(M)}catch{throw new Error("Clipboard unavailable")}else{const P=S.contentType.includes("png")?"png":"jpg",I=new Date().toISOString().replace(/[:.]/g,"-");HE(`${p}-${I}.${P}`,M)}c(!0),setTimeout(()=>c(!1),1500)}catch(S){f(S instanceof Error?S.message:String(S))}finally{i(!1)}},[e,t,p]),h=o==="md"?"h-9 px-3 text-sm gap-2":"h-7 px-2.5 text-[11px] gap-1.5",[g,b]=_(null),[x,v]=_(!1),w=()=>{v(!1);const k=setTimeout(()=>{v(!0),m("copy")},600);b(k)},y=()=>{g&&(clearTimeout(g),b(null)),x||m("download")},N=()=>{g&&(clearTimeout(g),b(null))};return u("button",{type:"button",title:"Click to download · long-press to copy",disabled:a,onPointerDown:w,onPointerUp:y,onPointerLeave:N,onPointerCancel:N,className:W("inline-flex items-center justify-center rounded-lg font-medium border border-border","text-foreground-subtle hover:text-foreground hover:bg-surface-hover","disabled:opacity-50 transition-colors",h,d&&"border-danger/40 text-danger",s),children:[a?r(Lt,{className:"h-3.5 w-3.5 animate-spin"}):l?r(wo,{className:"h-3.5 w-3.5 text-success"}):r(Ol,{className:"h-3.5 w-3.5"}),"Snapshot"]})}function qE(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 Dc({history:e,limit:t=5,latestIsFresh:n,className:o}){if(e.length===0)return null;const s=n?JN:Ys,a=e.slice(0,t);return u("div",{className:W("rounded-lg border border-border bg-surface px-3 py-2",o),children:[u("div",{className:"flex items-center gap-2 mb-2",children:[r(s,{className:W("h-4 w-4 text-amber-400",n&&"animate-pulse")}),r("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:"Recent presses"}),r("span",{className:"ml-auto rounded-full bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle border border-border",children:e.length})]}),r("ul",{className:"space-y-1",children:a.map(i=>u("li",{className:"flex items-center justify-between text-[11px]",title:new Date(i.timestamp).toLocaleString(),children:[r("span",{className:"text-foreground",children:qE(i.timestamp)}),r("span",{className:"text-foreground-subtle font-mono text-[10px]",children:new Date(i.timestamp).toLocaleTimeString()})]},`${i.deviceId}-${i.timestamp}`))})]})}function Ix({items:e,header:t,triggerClassName:n,title:o="More actions"}){const[s,a]=_(!1),i=e.filter(l=>!l.hidden);return i.length===0?null:u(sh,{open:s,onOpenChange:a,children:[r(ah,{title:o,className:W("inline-flex items-center justify-center rounded-lg p-2","text-foreground-subtle hover:text-foreground hover:bg-surface-hover","border border-transparent transition-colors",n),children:r(Nm,{className:"h-4 w-4"})}),u(ih,{className:"left-auto right-0 mt-1 min-w-[200px] p-1",children:[t&&r("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle",children:t}),r("ul",{className:"space-y-0.5",children:i.map((l,c)=>u("li",{children:[l.separatorBefore&&c>0&&r("div",{className:"my-1 h-px bg-border"}),u("button",{type:"button",disabled:l.disabled,onClick:()=>{l.disabled||(l.onClick(),a(!1))},className:W("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left text-[12px]","transition-colors disabled:opacity-40 disabled:cursor-not-allowed",l.danger?"text-foreground hover:bg-danger/10 hover:text-danger":"text-foreground hover:bg-surface-hover"),children:[l.icon&&r(l.icon,{className:W("h-3.5 w-3.5 shrink-0 mt-0.5",l.danger&&"text-danger/80")}),u("span",{className:"flex-1 min-w-0",children:[r("span",{className:"block leading-tight",children:l.label}),l.description&&r("span",{className:"block mt-0.5 text-[10px] text-foreground-subtle leading-tight",children:l.description})]})]})]},l.id))})]})]})}const Ax=cn("camstack:zone-editing",null);function Px({children:e}){const[t,n]=_(!1),[o,s]=_(null),[a,i]=_(null),[l,c]=_(null),d=q(w=>{n(w),w||(s(null),i(null),c(null))},[]),f=q(w=>{s(w)},[]),p=q(w=>{i(w)},[]),m=q(w=>{n(!0),i(null),s(w),c(null)},[]),h=q(()=>{n(!1),s(null),i(null),c(null)},[]),g=q(w=>{i(w.id),c(w)},[]),b=q(w=>{c(y=>y===null?y:{...y,...w})},[]),x=q(()=>{c(null)},[]),v=U(()=>({editing:t,drawingKind:o,selectedZoneId:a,editingDraft:l,setEditing:d,setDrawingKind:f,setSelectedZoneId:p,startDrawing:m,exitEditing:h,enterDraft:g,updateDraft:b,discardDraft:x}),[t,o,a,l,d,f,p,m,h,g,b,x]);return r(Ax.Provider,{value:v,children:e})}function QE(){return ve(Ax)}const wu=500,UE=800;function Vo(e,t,n){try{const o=e.live;if(!o)return null;const s=o.onEvent;return!s||typeof s.subscribe!="function"?null:s.subscribe({category:t},{onData:n})}catch{return null}}function qo(e,t){return e?.id===t}function Ex(e,t){const[n,o]=_(null),[s,a]=_(null),[i,l]=_(null),[c,d]=_("watching"),f=ne(void 0),p=ne(void 0),m=ne(void 0);return Z(()=>{if(t===null)return;const h=Vo(e,"detection.motion-analysis",g=>{const b=g;if(!qo(b?.source,t))return;const x=b.data;!x?.regions||x.regions.length===0||(o({zones:x.regions.map(v=>({...v.bbox,intensity:v.intensity})),frameWidth:x.frameWidth,frameHeight:x.frameHeight}),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>o(null),wu))});return()=>{h?.unsubscribe(),f.current&&clearTimeout(f.current)}},[e,t]),Z(()=>{if(t===null)return;const h=Vo(e,"detection.motion-zones-raw",g=>{const b=g;if(!qo(b?.source,t))return;const x=b.data;x?.zones&&(a({boxes:x.zones.map(v=>({bbox:v.bbox,changeScore:v.changeScore})),frameWidth:x.frameSize?.width??0,frameHeight:x.frameSize?.height??0,motionScore:x.zones.length>0?x.zones.reduce((v,w)=>v+w.changeScore,0)/x.zones.length:0}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>a(null),wu))});return()=>{h?.unsubscribe(),p.current&&clearTimeout(p.current)}},[e,t]),Z(()=>{if(t===null)return;const h=Vo(e,"detection.result",g=>{const b=g;if(!qo(b?.source,t))return;const x=b.data?.frame;x?.detections?.length&&(l({detections:x.detections,frameWidth:x.width,frameHeight:x.height}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>l(null),UE))});return()=>{h?.unsubscribe(),m.current&&clearTimeout(m.current)}},[e,t]),Z(()=>{if(t===null)return;const h=Vo(e,"detection.phase-transition",g=>{const b=g;qo(b?.source,t)&&b.data?.to&&d(b.data.to)});return()=>{h?.unsubscribe()}},[e,t]),{motion:n,motionRaw:s,detection:i,phase:c}}function Lc(e,t,n=5e3){const[o,s]=_([]);Z(()=>{if(t===null)return;let m=!1;const h=()=>{e.webrtcSession.listStreams.query({deviceId:t}).then(b=>{m||s(b)}).catch(()=>{})};h();const g=setInterval(h,n);return()=>{m=!0,clearInterval(g)}},[e,t,n]);const[a,i]=_(null);Z(()=>{if(t===null)return;let m=!1;return e.pipelineOrchestrator&&e.pipelineOrchestrator.getCameraMetrics.query({deviceId:t}).then(h=>{m||!h||i({phase:h.phase,detectionFps:h.actualFps,avgInferenceMs:h.avgInferenceTimeMs,droppedFrames:h.droppedFrames})}).catch(()=>{}),()=>{m=!0}},[e,t]),ct("pipeline.camera-metrics-snapshot",m=>{if(t===null)return;const h=m.data;h.deviceId!==t||!h.metrics||i({phase:h.metrics.phase,detectionFps:h.metrics.actualFps,avgInferenceMs:h.metrics.avgInferenceTimeMs,droppedFrames:h.metrics.droppedFrames})});const{streams:l,hasWebrtc:c}=U(()=>t===null||o.length===0?{streams:[],hasWebrtc:!1}:{streams:o.map(h=>({id:h.id,label:h.label,target:h.target,status:h.status,inputFps:h.inputFps,decodeFps:h.decodeFps,bitrateKbps:h.bitrateKbps})),hasWebrtc:!0},[t,o]),d=q(async(m,h)=>{if(t===null)throw new Error("No device selected");const g=await e.webrtcSession.createSession.mutate({deviceId:t,target:m,hints:h});return{sessionId:g.sessionId,sdpOffer:g.sdpOffer}},[e,t]),f=q(async(m,h)=>{if(t===null)throw new Error("No device selected");await e.webrtcSession.handleAnswer.mutate({deviceId:t,sessionId:m,sdpAnswer:h})},[e,t]),p=q(async m=>{t!==null&&await e.webrtcSession.closeSession.mutate({deviceId:t,sessionId:m}).catch(()=>{})},[e,t]);return{streams:l,hasWebrtc:c,pipelineMetrics:a,createSession:d,sendAnswer:f,closeSession:p}}const Nu={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 Tc(e,t,n){const o=n?.defaultSpeed??.5,s=n?.pulseMs??250,a=n?.enabled??!0,l=St(e,a?t:null)?.ptz,[c,d]=_([]),[f,p]=_(!1),[m,h]=_(null),g=q(async()=>{if(!(!a||!l))try{const S=await l.getPresets({});d(S)}catch(S){const M=S instanceof Error?S.message:String(S);if(M.includes("provider not available")||M.includes("no 'ptz' binding"))return;h(M)}},[l,a]);Z(()=>{g()},[g]);const b=q(async S=>{if(!(!a||!l)){h(null),p(!0);try{return await S()}catch(M){h(M instanceof Error?M.message:String(M));return}finally{p(!1)}}},[a,l]),x=q(async(S,M)=>{if(!l)return;const P=Nu[S],I=M??o;await b(async()=>{await l.move({pan:P.pan,tilt:P.tilt,speed:I}),await new Promise(z=>setTimeout(z,s)),await l.stop({})})},[l,o,s,b]),v=q(async(S,M)=>{if(!l)return;const P=Nu[S],I=M??o;await b(()=>l.continuousMove({pan:P.pan,tilt:P.tilt,speed:I}))},[l,o,b]),w=q(async()=>{l&&await b(()=>l.stop({}))},[l,b]),y=q(async(S,M)=>{if(!l)return;const P=S==="in"?1:-1,I=M??o;await b(async()=>{await l.move({zoom:P,speed:I}),await new Promise(z=>setTimeout(z,s)),await l.stop({})})},[l,o,s,b]),N=q(async()=>{l&&await b(()=>l.goHome({}))},[l,b]),k=q(async S=>{l&&await b(()=>l.goToPreset({presetId:S}))},[l,b]);return{move:x,startContinuous:v,stopContinuous:w,zoom:y,goHome:N,goToPreset:k,presets:c,refreshPresets:g,busy:f,error:m}}function Rc(e){const t=e?.deviceId??null,n=e?.historyLimit??20,o=Ir("doorbell.onPressed",t!==null?i=>i.deviceId===t:void 0),[s,a]=_([]);return Z(()=>{o&&a(i=>{if(i.length>0&&i[0].deviceId===o.deviceId&&i[0].timestamp===o.timestamp)return i;const l=[o,...i];return l.length>n?l.slice(0,n):l})},[o,n]),{latest:o??null,history:s}}function KE(e){const t=Le(),n=U(()=>e?JSON.stringify(e):"",[e]),[o,s]=_(()=>t.listDevices(e));return Z(()=>{const a=()=>{s(t.listDevices(e))};a();let i=null,l=null;try{i=t.onDeviceAdded(a),l=t.onDeviceRemoved(a)}catch{}const c=t.subscribeConnectionEvents(d=>{d==="connected"&&a()});return()=>{i?.(),l?.(),c()}},[t,e,n]),o}function GE(e){const t=Le(),[n,o]=_(()=>e===null?null:t.getDevice(e));return Z(()=>{if(e===null){o(null);return}const s=()=>{o(t.getDevice(e))};s();let a=null,i=null;try{a=t.onDeviceAdded(s),i=t.onDeviceRemoved(s)}catch{}const l=t.subscribeConnectionEvents(c=>{c==="connected"&&s()});return()=>{a?.(),i?.(),l()}},[t,e]),n}function WE(e,t,n){const o=Le();return Un({queryKey:e,queryFn:()=>t(o)(),...n})}function YE(e,t){const n=Le();return _l({mutationFn:o=>e(n)(o),...t})}function ZE(e,t){const n=Le(),o=ke(),[s,a]=_(n.connectionVersion);Z(()=>n.subscribeConnectionEvents((c,d)=>{c==="connected"&&a(d)}),[n]);const i=t.join("|"),l=JSON.stringify(e);Z(()=>{const c=[],d=()=>{const f=JSON.parse(l),m=f.length===1&&Array.isArray(f[0])?f:[f];o.invalidateQueries({queryKey:m})};d();for(const f of i.split("|"))if(f)try{c.push(n.subscribeEvent(f,d))}catch{}return()=>{for(const f of c)f()}},[n,o,i,l,s])}const XE=Object.freeze(Object.defineProperty({__proto__:null,AddonGlobalSettingsForm:WP,AgentStepEditor:na,AppShell:tS,AudioClassificationList:gE,AudioLevelWaveform:fE,AudioWaveform:pE,BTN_COMPACT:hN,BTN_COMPACT_DANGER:bN,BTN_COMPACT_PRIMARY:gN,BTN_COMPACT_WARNING:xN,Badge:lr,BatteryBadge:oc,BottomSheet:Kl,Breadcrumb:Yl,Button:Qe,CHIP_ACTIVE:wN,CHIP_BASE:vN,CHIP_INACTIVE:NN,CLASS_COLORS:qr,CameraStreamPlayer:yx,Card:en,Checkbox:zm,CodeBlock:J5,CollapsibleCard:Rm,ConfigFormBuilder:bx,ConfigFormField:er,ConfigSchemaField:ta,ConfirmActionButton:Mx,ConfirmDialogProvider:yh,CustomFieldRenderersProvider:Bh,DEFAULT_COLOR:Lh,DataTable:dh,DetectionCanvas:rC,DetectionOverlay:xx,DetectionResultTree:iC,DevShell:Oh,DeviceActivityPanel:jE,DeviceCard:rS,DeviceContextProvider:jh,DeviceGrid:oS,DeviceItem:oo,DeviceList:so,Dialog:jm,DialogContent:Ql,DialogDescription:Qm,DialogFooter:Vm,DialogHeader:Hm,DialogTitle:qm,DialogTrigger:y5,DiscoveryPanel:Cx,DoorbellRecentPanel:Dc,Dropdown:Km,DropdownContent:Wm,DropdownItem:Ym,DropdownTrigger:Gm,EmptyState:bh,EventStream:tr,FilterBar:eS,FloatingEventStream:$E,FloatingLogStream:Sx,FloatingPanel:A5,FormField:W5,GRID_GAP:mm,GRID_PAIRED:cN,GRID_QUICK_STATS:lN,INPUT_COMPACT:yN,IconButton:jl,ImageSelector:pC,InferenceConfigSelector:fC,Input:Ss,KebabMenu:Ix,KeyValueList:X5,LIST_ROW:hm,Label:Hl,LogStream:Ut,LoginForm:Th,MobileDrawer:Wl,NodeMultiSelectField:hx,NodePicker:hh,NodeSelectField:mx,PHASE_CONFIG:zi,PTZOverlay:_c,PageHeader:Y5,PhaseIcon:Ec,PipelineBuilder:sc,PipelineRuntimeSelector:eC,PipelineStep:ps,PipelineTreeMatrix:Xl,PlayerOverlaysProvider:vx,Popover:sh,PopoverContent:ih,PopoverTrigger:ah,ProviderBadge:U5,ResponseLog:bE,SECTION_BODY:iN,SECTION_CARD:sN,SECTION_HEADER:aN,SPLIT_PANEL_OUTER:dN,SPLIT_PANEL_SIDE:uN,STACK_GAP:fm,ScrollArea:Gl,Select:Cs,SemanticBadge:gh,Separator:Vl,Sidebar:Qi,SidebarItem:qi,Skeleton:Om,SlideOverPanel:Zl,SnapshotButton:VE,StatCard:Z5,StateValuesStream:$c,StatusBadge:q5,StepTimings:uC,StepTreeMaster:ph,StreamPanel:Pc,Switch:ql,SystemProvider:ec,TEXT_FIELD_LABEL:fN,TEXT_HINT:ks,TEXT_METRIC:Oi,TEXT_SECTION_LABEL:pN,TEXT_VALUE:mN,Tabs:S5,TabsContent:I5,TabsList:C5,TabsTrigger:M5,ThemeProvider:ws,Tooltip:w5,TooltipContent:k5,TooltipTrigger:N5,VersionBadge:G5,WidgetRegistryProvider:cx,WidgetSlot:at,ZoneEditingProvider:Px,buildStepTreeFromSchema:ea,cn:W,createSharedContext:cn,createTheme:cw,darkColors:Qf,defaultTheme:Ti,deriveDeviceKind:aS,ensureMfHostInit:Tl,getClassColor:lt,getPhaseVisual:Gn,isFieldVisible:Mc,lightColors:Uf,mirror:gm,mountAddonPage:NC,providerIcons:p5,statusIcons:f5,themeToCss:mw,trpc:C,useAccessoriesGetStatus:kC,useAddonPagesListPages:lc,useAddonSettingsGetDeviceSettings:DC,useAddonSettingsGetGlobalSettings:uc,useAddonSettingsUpdateDeviceSettings:eg,useAddonSettingsUpdateGlobalSettings:Jh,useAddonWidgetsListWidgets:tg,useAddonsApplyAutoUpdateToAll:Xh,useAddonsCustom:$C,useAddonsForceRefresh:Qh,useAddonsGetAddonAutoUpdate:Yh,useAddonsGetAutoUpdateSettings:Wh,useAddonsGetLogs:SC,useAddonsGetVersions:Kh,useAddonsInstallFromWorkspace:MC,useAddonsInstallPackage:cc,useAddonsIsWorkspaceAvailable:IC,useAddonsList:ra,useAddonsListPackages:CC,useAddonsListUpdates:dc,useAddonsListWorkspacePackages:AC,useAddonsOnAddonLogs:_C,useAddonsReloadPackages:Vh,useAddonsRestartAddon:oa,useAddonsRestartServer:Uh,useAddonsRetryLoad:Gh,useAddonsRollbackPackage:PC,useAddonsSearchAvailable:qh,useAddonsSetAddonAutoUpdate:Zh,useAddonsSetAutoUpdateSettings:EC,useAddonsUninstallPackage:Hh,useAddonsUpdatePackage:Ki,useAlertsDismiss:ag,useAlertsEmit:LC,useAlertsGetUnreadCount:rg,useAlertsList:ng,useAlertsMarkAllRead:sg,useAlertsMarkRead:og,useAlertsUpdate:TC,useAllWidgets:px,useAudioAnalysisApplyDeviceSettingsPatch:BC,useAudioAnalysisGetDeviceLiveContribution:zC,useAudioAnalysisGetDeviceSettingsContribution:OC,useAudioAnalysisResolveDeviceSettings:RC,useAudioAnalyzerAnalyseChunk:FC,useAudioAnalyzerClassify:jC,useAudioAnalyzerDispose:VC,useAudioAnalyzerIsReady:HC,useAudioAnalyzerReprobeAudioEngine:ig,useAudioCodecCanHandle:QC,useAudioCodecCloseSession:GC,useAudioCodecCreateDecodeSession:UC,useAudioCodecCreateEncodeSession:KC,useAudioCodecFlushEncode:JC,useAudioCodecListActiveSessions:e3,useAudioCodecListSupportedCodecs:qC,useAudioCodecPullEncoded:XC,useAudioCodecPullPcm:YC,useAudioCodecPushEncodedFrame:WC,useAudioCodecPushPcm:ZC,useAudioMetricsGetCurrentSnapshot:t3,useAudioMetricsGetHistory:n3,useAuthenticationListProviders:pc,useAuthenticationSetProviderEnabled:r3,useBackupDelete:pg,useBackupGetEntries:dg,useBackupList:o3,useBackupListArchives:mc,useBackupListDestinations:fc,useBackupListLocations:cg,useBackupPreviewSchedule:mg,useBackupRestore:ug,useBackupTrigger:lg,useBackupUpsertDestinationPolicy:fg,useBatteryGetStatus:s3,useBrightnessGetStatus:i3,useBrightnessSetBrightness:a3,useCameraStreamsGetBrokerStreams:c3,useCameraStreamsGetCameraStreams:l3,useCameraStreamsGetRtspEntries:d3,useClusterNodes:Ar,useConfirm:nt,useCustomFieldRenderer:Fh,useDebouncedString:Dh,useDecoderCreateSession:f3,useDecoderDestroySession:m3,useDecoderGetInfo:p3,useDecoderGetStats:y3,useDecoderListActiveSessions:v3,useDecoderOpenStream:g3,useDecoderPullFrames:b3,useDecoderPushPacket:h3,useDecoderReprobeHwaccel:hg,useDecoderSupportsCodec:u3,useDecoderUpdateConfig:x3,useDetectionPipelineApplyDeviceSettingsPatch:k3,useDetectionPipelineGetDeviceLiveContribution:N3,useDetectionPipelineGetDeviceSettingsContribution:w3,useDevShell:bC,useDevice:GE,useDeviceBattery:nc,useDeviceCapability:Pr,useDeviceDetections:Ex,useDeviceDiscoveryAdoptDevice:S3,useDeviceDiscoveryGetStatus:M3,useDeviceDiscoveryListDiscovered:gg,useDeviceDiscoveryRefreshDiscovery:bg,useDeviceDiscoveryReleaseDevice:C3,useDeviceId:dn,useDeviceManagerAddLocation:T3,useDeviceManagerAdoptDevice:Pg,useDeviceManagerAllocateDeviceId:I3,useDeviceManagerCreateDevice:$g,useDeviceManagerDisable:kg,useDeviceManagerDiscoverDevices:gc,useDeviceManagerEnable:Ng,useDeviceManagerGetAllBindings:U3,useDeviceManagerGetBindings:Cg,useDeviceManagerGetChildren:wg,useDeviceManagerGetConfigSchema:F3,useDeviceManagerGetCreationSchema:Eg,useDeviceManagerGetDevice:Bn,useDeviceManagerGetDeviceAggregate:hc,useDeviceManagerGetDeviceLiveInfoAggregate:W3,useDeviceManagerGetDeviceSettingsAggregate:G3,useDeviceManagerGetDeviceStatusAggregate:X3,useDeviceManagerGetSettingsSchema:j3,useDeviceManagerGetStreamProfileMap:V3,useDeviceManagerGetStreamSources:B3,useDeviceManagerListAll:Xn,useDeviceManagerListBindableCapsForDeviceType:Ig,useDeviceManagerListLocations:vg,useDeviceManagerListPersistedByAddon:z3,useDeviceManagerListWrappersForCap:K3,useDeviceManagerLoadConfig:$3,useDeviceManagerLoadMeta:D3,useDeviceManagerLoadRuntimeState:_3,useDeviceManagerPersistConfig:E3,useDeviceManagerProbeStreams:Q3,useDeviceManagerRegisterDevice:A3,useDeviceManagerRemove:Sg,useDeviceManagerRemoveDevice:P3,useDeviceManagerRemoveLocation:R3,useDeviceManagerSetDisabled:O3,useDeviceManagerSetLocation:yg,useDeviceManagerSetMetadata:L3,useDeviceManagerSetName:xg,useDeviceManagerSetStreamProfileMap:q3,useDeviceManagerSetWrapperActive:Mg,useDeviceManagerTestCreationField:bc,useDeviceManagerTestField:Z3,useDeviceManagerUpdateConfig:H3,useDeviceManagerUpdateDeviceField:Y3,useDeviceManagerUpdateDeviceFieldsBatch:Ag,useDeviceOpsGetConfigEntries:eM,useDeviceOpsGetSettingsSchema:rM,useDeviceOpsGetStreamSources:J3,useDeviceOpsRemoveDevice:nM,useDeviceOpsSetConfig:tM,useDeviceProviderAdoptDiscoveredDevice:dM,useDeviceProviderCreateDevice:fM,useDeviceProviderDiscoverDevices:cM,useDeviceProviderGetChildCreationSchema:pM,useDeviceProviderGetDevices:iM,useDeviceProviderGetStatus:aM,useDeviceProviderStart:oM,useDeviceProviderStop:sM,useDeviceProviderSupportsDiscovery:lM,useDeviceProviderSupportsManualCreation:uM,useDeviceProviderTestCreationField:mM,useDeviceProxy:St,useDeviceSnapshot:ic,useDeviceSnapshotImage:rc,useDeviceState:vh,useDeviceStateGetAllSnapshots:bM,useDeviceStateGetCapSlice:gM,useDeviceStateGetSnapshot:hM,useDeviceStateSetCapSlice:xM,useDeviceStateSlice:nn,useDeviceWebrtc:Lc,useDevices:KE,useDoorbellEvents:Rc,useDoorbellGetStatus:yM,useEventInvalidation:ZE,useEventStreamLatest:Ir,useEventStreamMap:tc,useEventsGetEventClipUrl:NM,useEventsGetEventThumbnail:wM,useEventsGetEvents:vM,useIntegrationsCreate:Lg,useIntegrationsDelete:Rg,useIntegrationsGet:_g,useIntegrationsGetAvailableTypes:Og,useIntegrationsGetByAddonId:Dg,useIntegrationsGetSettings:kM,useIntegrationsList:sa,useIntegrationsSetSettings:SM,useIntegrationsTestConnection:zg,useIntegrationsUpdate:Tg,useIntercomGetStatus:CM,useIntercomHandleAnswer:Fg,useIntercomStartSession:Bg,useIntercomStopSession:jg,useIsMidWidth:nh,useIsMobile:Zn,useLiveBuffer:Rn,useLiveEvent:ct,useLocalNetworkGetAllowedAddresses:qg,useLocalNetworkGetConnectionEndpoints:Vg,useLocalNetworkGetPreferred:MM,useLocalNetworkList:Hg,useLocalNetworkResetAllowlistToBestMatch:Ug,useLocalNetworkSetAllowedAddresses:Qg,useMeshOrchestratorJoinProvider:Gg,useMeshOrchestratorLeaveProvider:Wg,useMeshOrchestratorListProviders:Kg,useMetricsProviderCollectSnapshot:IM,useMetricsProviderGetAddonStats:TM,useMetricsProviderGetCached:AM,useMetricsProviderGetCpuTemperature:_M,useMetricsProviderGetCurrent:PM,useMetricsProviderGetDiskSpace:EM,useMetricsProviderGetGpuInfo:$M,useMetricsProviderGetProcessStats:DM,useMetricsProviderKillProcess:Zg,useMetricsProviderListAddonInstances:LM,useMetricsProviderListNodeProcesses:Yg,useMotionDetectionAnalyze:zM,useMotionDetectionApplyDeviceSettingsPatch:VM,useMotionDetectionGetDeviceLiveContribution:HM,useMotionDetectionGetDeviceSettingsContribution:jM,useMotionDetectionRemoveCamera:BM,useMotionDetectionReset:FM,useMotionGetStatus:OM,useMotionIsDetected:RM,useMotionTriggerGetStatus:QM,useMotionTriggerSetMotionTrigger:qM,useNativeObjectDetectionGetStatus:UM,useNetworkQualityGetAllStats:KM,useNetworkQualityGetDeviceStats:xc,useNetworkQualityReportClientStats:GM,useNodesClusterAddonStatus:nb,useNodesDeployAddon:WM,useNodesExecuteQuery:ZM,useNodesRenameNode:tb,useNodesRestartAddon:aa,useNodesRestartNode:eb,useNodesRestartProcess:Jg,useNodesSetProcessLogLevel:rb,useNodesShutdownNode:YM,useNodesTopology:Mn,useNodesUndeployAddon:Xg,useNotificationOutputSend:XM,useNotificationOutputSendTest:JM,useOptionalSystem:H5,useOptionalWidgetRegistry:fx,useOsdGetStatus:t4,useOsdSetOverlay:e4,usePTZ:Tc,usePipelineAnalyticsApplyDeviceSettingsPatch:f4,usePipelineAnalyticsClearTracks:s4,usePipelineAnalyticsGetActiveTracks:n4,usePipelineAnalyticsGetAudioEvents:l4,usePipelineAnalyticsGetDeviceLiveContribution:p4,usePipelineAnalyticsGetDeviceSettingsContribution:u4,usePipelineAnalyticsGetEventMedia:c4,usePipelineAnalyticsGetMotionEvents:a4,usePipelineAnalyticsGetObjectEvents:i4,usePipelineAnalyticsGetTrack:r4,usePipelineAnalyticsGetTrackMedia:d4,usePipelineAnalyticsListTracks:o4,usePipelineExecutorCacheFrameInPool:P4,usePipelineExecutorDeleteModel:lb,usePipelineExecutorDeleteTemplate:k4,usePipelineExecutorDetect:M4,usePipelineExecutorDownloadModel:ib,usePipelineExecutorGetAddonModels:C4,usePipelineExecutorGetAudioCapabilities:z4,usePipelineExecutorGetAvailableEngines:ob,usePipelineExecutorGetCapabilities:S4,usePipelineExecutorGetDefaultSteps:m4,usePipelineExecutorGetDetectionConfigSchema:F4,usePipelineExecutorGetEffectiveTuning:_4,usePipelineExecutorGetGlobalPipelineConfig:x4,usePipelineExecutorGetGlobalSteps:b4,usePipelineExecutorGetOrchestratorConfigSchema:y4,usePipelineExecutorGetReferenceAudio:O4,usePipelineExecutorGetReferenceAudioFiles:R4,usePipelineExecutorGetReferenceImage:T4,usePipelineExecutorGetSchema:ko,usePipelineExecutorGetSelectedEngine:sb,usePipelineExecutorGetVideoPipelineSteps:h4,usePipelineExecutorInferCached:E4,usePipelineExecutorKillEngine:db,usePipelineExecutorListLoadedEngines:cb,usePipelineExecutorListReferenceImages:L4,usePipelineExecutorListTemplates:v4,usePipelineExecutorReprobeEngine:ab,usePipelineExecutorRunAudioTest:B4,usePipelineExecutorRunPipeline:I4,usePipelineExecutorRunPipelineBatch:A4,usePipelineExecutorSaveTemplate:w4,usePipelineExecutorSetVideoPipelineSteps:g4,usePipelineExecutorSpinEngine:D4,usePipelineExecutorUncacheFrame:$4,usePipelineExecutorUpdateTemplate:N4,usePipelineOrchestratorApplyDeviceSettingsPatch:W4,usePipelineOrchestratorAssignAudio:vb,usePipelineOrchestratorAssignDecoder:bb,usePipelineOrchestratorAssignPipeline:ub,usePipelineOrchestratorDeleteTemplate:$b,usePipelineOrchestratorGetAgentLoad:mb,usePipelineOrchestratorGetAgentSettings:yc,usePipelineOrchestratorGetAudioAssignment:V4,usePipelineOrchestratorGetAudioAssignments:kb,usePipelineOrchestratorGetAudioNodeLoad:Nb,usePipelineOrchestratorGetCameraMetrics:H4,usePipelineOrchestratorGetCameraSettings:wc,usePipelineOrchestratorGetCameraStepOverrides:Q4,usePipelineOrchestratorGetCapabilityBindings:hb,usePipelineOrchestratorGetDecoderAssignment:q4,usePipelineOrchestratorGetDecoderAssignments:yb,usePipelineOrchestratorGetDeviceLiveContribution:G4,usePipelineOrchestratorGetDeviceSettingsContribution:K4,usePipelineOrchestratorGetGlobalMetrics:j4,usePipelineOrchestratorGetPipelineAssignment:la,usePipelineOrchestratorGetPipelineAssignments:ia,usePipelineOrchestratorListAgentSettings:Er,usePipelineOrchestratorListTemplates:Pb,usePipelineOrchestratorRebalance:fb,usePipelineOrchestratorRemoveAgentSettings:Sb,usePipelineOrchestratorResolvePipeline:Ab,usePipelineOrchestratorSaveTemplate:U4,usePipelineOrchestratorSetAgentAddonDefaults:vc,usePipelineOrchestratorSetCameraPipelineForAgent:Ib,usePipelineOrchestratorSetCameraStepOverride:Mb,usePipelineOrchestratorSetCameraStepToggle:Cb,usePipelineOrchestratorSetCapabilityBinding:gb,usePipelineOrchestratorUnassignAudio:wb,usePipelineOrchestratorUnassignDecoder:xb,usePipelineOrchestratorUnassignPipeline:pb,usePipelineOrchestratorUpdateTemplate:Eb,usePipelineRunnerAttachCamera:Y4,usePipelineRunnerDetachCamera:Z4,usePipelineRunnerGetAllCameraMetrics:tI,usePipelineRunnerGetCameraMetrics:Nc,usePipelineRunnerGetLocalCameras:_b,usePipelineRunnerGetLocalLoad:J4,usePipelineRunnerGetLocalMetrics:eI,usePipelineRunnerReportMotion:X4,usePlatformProbeGetCapabilities:nI,usePlatformProbeGetHardware:rI,usePlatformProbeResolveHwAccel:sI,usePlatformProbeResolveInferenceConfig:oI,usePlayerOverlayLayer:rE,usePlayerOverlayLayers:wx,usePlayerToolbarButton:oE,usePlayerToolbarButtons:Nx,usePtzAutotrackGetSettings:mI,usePtzAutotrackGetStatus:Db,usePtzAutotrackSetEnabled:Lb,usePtzAutotrackSetSettings:Tb,usePtzContinuousMove:iI,usePtzGetPosition:pI,usePtzGetPresets:cI,usePtzGetStatus:fI,usePtzGoHome:uI,usePtzGoToPreset:dI,usePtzMove:aI,usePtzStop:lI,useRebootReboot:Rb,useRecordingEngineDisable:zb,useRecordingEngineEnable:Ob,useRecordingEngineEstimateGlobalStorage:SI,useRecordingEngineEstimateStorage:kI,useRecordingEngineGetAvailability:NI,useRecordingEngineGetConfig:Bb,useRecordingEngineGetMotionStats:AI,useRecordingEngineGetPlaylist:vI,useRecordingEngineGetPolicy:MI,useRecordingEngineGetPolicyStatus:Hb,useRecordingEngineGetRetentionConfig:Vb,useRecordingEngineGetSegments:Fb,useRecordingEngineGetStatus:xI,useRecordingEngineGetStorageUsage:jb,useRecordingEngineGetThumbnail:wI,useRecordingEngineSetPolicy:CI,useRecordingEngineUpdateConfig:yI,useRecordingEngineUpdateRetentionConfig:II,useRecordingGetPlaybackUrl:gI,useRecordingGetSegments:hI,useRecordingGetThumbnailAt:bI,useRemoteAccessListProviders:qb,useRemoteAccessStartProvider:Qb,useRemoteAccessStopProvider:Ub,useSettingsStoreCount:TI,useSettingsStoreDeclareCollection:OI,useSettingsStoreDelete:LI,useSettingsStoreGet:PI,useSettingsStoreInsert:_I,useSettingsStoreIsEmpty:RI,useSettingsStoreQuery:$I,useSettingsStoreSet:EI,useSettingsStoreUpdate:DI,useSnapshotApplyDeviceSettingsPatch:VI,useSnapshotGetDeviceLiveContribution:HI,useSnapshotGetDeviceSettingsContribution:jI,useSnapshotGetSnapshot:zI,useSnapshotGetStatus:FI,useSnapshotInvalidateCache:BI,useSnapshotProviderGetSnapshot:QI,useSnapshotProviderSupportsDevice:qI,useStorageAbortUpload:nA,useStorageBeginDownload:rA,useStorageBeginUpload:JI,useStorageDelete:ZI,useStorageDeleteLocation:Gb,useStorageEndDownload:sA,useStorageExists:WI,useStorageFinalizeUpload:tA,useStorageGetAvailableSpace:XI,useStorageGetDefaultLocation:aA,useStorageList:YI,useStorageListLocations:Kb,useStorageListProviders:kc,useStorageRead:GI,useStorageReadChunk:oA,useStorageResolve:UI,useStorageTestConfig:lA,useStorageTestLocation:iA,useStorageUpsertLocation:ca,useStorageWrite:KI,useStorageWriteChunk:eA,useStreamBrokerApplyDeviceSettingsPatch:EA,useStreamBrokerAssignProfile:uA,useStreamBrokerGetAllRtspEntries:SA,useStreamBrokerGetBroker:vA,useStreamBrokerGetBrokerStats:hA,useStreamBrokerGetDeviceLiveContribution:PA,useStreamBrokerGetDeviceSettingsContribution:AA,useStreamBrokerGetPreBufferInfo:NA,useStreamBrokerGetRtspEntry:CA,useStreamBrokerGetRtspPort:kA,useStreamBrokerGetStreamUrl:yA,useStreamBrokerIsRtspEnabled:IA,useStreamBrokerKillClient:bA,useStreamBrokerListAllCameraStreams:fA,useStreamBrokerListAllProfileSlots:mA,useStreamBrokerListClients:gA,useStreamBrokerPublishCameraStream:cA,useStreamBrokerRegenerateRtspToken:Wb,useStreamBrokerRestartProfile:xA,useStreamBrokerRetractCameraStream:dA,useStreamBrokerSetPreBufferDuration:wA,useStreamBrokerSetRtspEnabled:MA,useStreamBrokerUnassignProfile:pA,useSwitchGetStatus:_A,useSwitchSetState:$A,useSystem:Le,useSystemFeatureFlags:TA,useSystemForceRetentionCleanup:BA,useSystemGetRetentionConfig:OA,useSystemHealth:LA,useSystemInfo:DA,useSystemMutation:YE,useSystemNetworkAddresses:RA,useSystemQuery:WE,useSystemSetRetentionConfig:zA,useThemeMode:Mr,useToastOnToast:Yb,useTurnOrchestratorGetAllServers:Xb,useTurnOrchestratorListProviders:Zb,useTurnOrchestratorSetProviderEnabled:Jb,useTurnProviderGetTurnServers:FA,useUserManagementCreateApiKey:HA,useUserManagementCreateScopedToken:sx,useUserManagementCreateUser:ex,useUserManagementDeleteUser:nx,useUserManagementListApiKeys:rx,useUserManagementListScopedTokens:ix,useUserManagementListUsers:Sc,useUserManagementResetPassword:Cc,useUserManagementRevokeApiKey:ox,useUserManagementRevokeScopedToken:ax,useUserManagementUpdateUser:tx,useUserManagementValidateApiKey:VA,useUserManagementValidateCredentials:jA,useUserManagementValidateScopedToken:qA,useWebrtcSessionCloseSession:GA,useWebrtcSessionCreateSession:UA,useWebrtcSessionHandleAnswer:KA,useWebrtcSessionHasAdaptiveBitrate:WA,useWebrtcSessionListStreams:QA,useWidget:dx,useWidgetMetadata:ux,useWidgetRegistry:da,useZoneAnalyticsGetCameraHistory:XA,useZoneAnalyticsGetCurrentSnapshot:YA,useZoneAnalyticsGetUnzonedHistory:JA,useZoneAnalyticsGetZoneHistory:ZA,useZoneEditing:QE,useZoneRulesListRules:eP,useZoneRulesSetRules:tP,useZonesAddZone:rP,useZonesListZones:nP,useZonesRemoveZone:oP,useZonesUpdateZone:sP},Symbol.toStringTag,{value:"Module"}));/**
|
|
535
|
+
* react-router v7.15.0
|
|
536
|
+
*
|
|
537
|
+
* Copyright (c) Remix Software Inc.
|
|
538
|
+
*
|
|
539
|
+
* This source code is licensed under the MIT license found in the
|
|
540
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
541
|
+
*
|
|
542
|
+
* @license MIT
|
|
543
|
+
*/var ku="popstate";function Su(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function JE(e={}){function t(o,s){let a=s.state?.masked,{pathname:i,search:l,hash:c}=a||o.location;return Yi("",{pathname:i,search:l,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default",a?{pathname:o.location.pathname,search:o.location.search,hash:o.location.hash}:void 0)}function n(o,s){return typeof s=="string"?s:ao(s)}return t$(t,n,null,e)}function ze(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function vt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function e$(){return Math.random().toString(36).substring(2,10)}function Cu(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Yi(e,t,n=null,o,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?$r(t):t,state:n,key:t&&t.key||o||e$(),mask:s}}function ao({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 $r(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let o=e.indexOf("?");o>=0&&(t.search=e.substring(o),e=e.substring(0,o)),e&&(t.pathname=e)}return t}function t$(e,t,n,o={}){let{window:s=document.defaultView,v5Compat:a=!1}=o,i=s.history,l="POP",c=null,d=f();d==null&&(d=0,i.replaceState({...i.state,idx:d},""));function f(){return(i.state||{idx:null}).idx}function p(){l="POP";let x=f(),v=x==null?null:x-d;d=x,c&&c({action:l,location:b.location,delta:v})}function m(x,v){l="PUSH";let w=Su(x)?x:Yi(b.location,x,v);d=f()+1;let y=Cu(w,d),N=b.createHref(w.mask||w);try{i.pushState(y,"",N)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;s.location.assign(N)}a&&c&&c({action:l,location:b.location,delta:1})}function h(x,v){l="REPLACE";let w=Su(x)?x:Yi(b.location,x,v);d=f();let y=Cu(w,d),N=b.createHref(w.mask||w);i.replaceState(y,"",N),a&&c&&c({action:l,location:b.location,delta:0})}function g(x){return n$(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(ku,p),c=x,()=>{s.removeEventListener(ku,p),c=null}},createHref(x){return t(s,x)},createURL:g,encodeLocation(x){let v=g(x);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:m,replace:h,go(x){return i.go(x)}};return b}function n$(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ze(n,"No window.location.(origin|href) available to create URL");let o=typeof e=="string"?e:ao(e);return o=o.replace(/ $/,"%20"),!t&&o.startsWith("//")&&(o=n+o),new URL(o,n)}function $x(e,t,n="/"){return r$(e,t,n,!1)}function r$(e,t,n,o,s){let a=typeof t=="string"?$r(t):t,i=rn(a.pathname||"/",n);if(i==null)return null;let l=o$(e),c=null,d=g$(i);for(let f=0;c==null&&f<l.length;++f)c=m$(l[f],d,o);return c}function o$(e){let t=_x(e);return s$(t),t}function _x(e,t=[],n=[],o="",s=!1){let a=(i,l,c=s,d)=>{let f={relativePath:d===void 0?i.path||"":d,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(o)&&c)return;ze(f.relativePath.startsWith(o),`Absolute route path "${f.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),f.relativePath=f.relativePath.slice(o.length)}let p=Dt([o,f.relativePath]),m=n.concat(f);i.children&&i.children.length>0&&(ze(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${p}".`),_x(i.children,t,m,p,c)),!(i.path==null&&!i.index)&&t.push({path:p,score:p$(p,i.index),routesMeta:m})};return e.forEach((i,l)=>{if(i.path===""||!i.path?.includes("?"))a(i,l);else for(let c of Dx(i.path))a(i,l,!0,c)}),t}function Dx(e){let t=e.split("/");if(t.length===0)return[];let[n,...o]=t,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(o.length===0)return s?[a,""]:[a];let i=Dx(o.join("/")),l=[];return l.push(...i.map(c=>c===""?a:[a,c].join("/"))),s&&l.push(...i),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function s$(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:f$(t.routesMeta.map(o=>o.childrenIndex),n.routesMeta.map(o=>o.childrenIndex)))}var a$=/^:[\w-]+$/,i$=3,l$=2,c$=1,d$=10,u$=-2,Mu=e=>e==="*";function p$(e,t){let n=e.split("/"),o=n.length;return n.some(Mu)&&(o+=u$),t&&(o+=l$),n.filter(s=>!Mu(s)).reduce((s,a)=>s+(a$.test(a)?i$:a===""?c$:d$),o)}function f$(e,t){return e.length===t.length&&e.slice(0,-1).every((o,s)=>o===t[s])?e[e.length-1]-t[t.length-1]:0}function m$(e,t,n=!1){let{routesMeta:o}=e,s={},a="/",i=[];for(let l=0;l<o.length;++l){let c=o[l],d=l===o.length-1,f=a==="/"?t:t.slice(a.length)||"/",p=Is({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},f),m=c.route;if(!p&&d&&n&&!o[o.length-1].route.index&&(p=Is({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!p)return null;Object.assign(s,p.params),i.push({params:s,pathname:Dt([a,p.pathname]),pathnameBase:v$(Dt([a,p.pathnameBase])),route:m}),p.pathnameBase!=="/"&&(a=Dt([a,p.pathnameBase]))}return i}function Is(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,o]=h$(e.path,e.caseSensitive,e.end),s=t.match(n);if(!s)return null;let a=s[0],i=a.replace(/(.)\/+$/,"$1"),l=s.slice(1);return{params:o.reduce((d,{paramName:f,isOptional:p},m)=>{if(f==="*"){let g=l[m]||"";i=a.slice(0,a.length-g.length).replace(/(.)\/+$/,"$1")}const h=l[m];return p&&!h?d[f]=void 0:d[f]=(h||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:i,pattern:e}}function h$(e,t=!1,n=!0){vt(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let o=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,c,d,f)=>{if(o.push({paramName:l,isOptional:c!=null}),c){let p=f.charAt(d+i.length);return p&&p!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(o.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),o]}function g$(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return vt(!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 rn(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,o=e.charAt(n);return o&&o!=="/"?null:e.slice(n)||"/"}var b$=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function x$(e,t="/"){let{pathname:n,search:o="",hash:s=""}=typeof e=="string"?$r(e):e,a;return n?(n=Lx(n),n.startsWith("/")?a=Iu(n.substring(1),"/"):a=Iu(n,t)):a=t,{pathname:a,search:w$(o),hash:N$(s)}}function Iu(e,t){let n=As(t).split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function ni(e,t,n,o){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function y$(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Oc(e){let t=y$(e);return t.map((n,o)=>o===t.length-1?n.pathname:n.pathnameBase)}function pa(e,t,n,o=!1){let s;typeof e=="string"?s=$r(e):(s={...e},ze(!s.pathname||!s.pathname.includes("?"),ni("?","pathname","search",s)),ze(!s.pathname||!s.pathname.includes("#"),ni("#","pathname","hash",s)),ze(!s.search||!s.search.includes("#"),ni("#","search","hash",s)));let a=e===""||s.pathname==="",i=a?"/":s.pathname,l;if(i==null)l=n;else{let p=t.length-1;if(!o&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),p-=1;s.pathname=m.join("/")}l=p>=0?t[p]:"/"}let c=x$(s,l),d=i&&i!=="/"&&i.endsWith("/"),f=(a||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var Lx=e=>e.replace(/\/\/+/g,"/"),Dt=e=>Lx(e.join("/")),As=e=>e.replace(/\/+$/,""),v$=e=>As(e).replace(/^\/*/,"/"),w$=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,N$=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,k$=class{constructor(e,t,n,o=!1){this.status=e,this.statusText=t||"",this.internal=o,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function S$(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function C$(e){let t=e.map(n=>n.route.path).filter(Boolean);return Dt(t)||"/"}var Tx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Rx(e,t){let n=e;if(typeof n!="string"||!b$.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let o=n,s=!1;if(Tx)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=rn(i.pathname,t);i.origin===a.origin&&l!=null?n=l+i.search+i.hash:s=!0}catch{vt(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:s,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Ox=["POST","PUT","PATCH","DELETE"];new Set(Ox);var M$=["GET",...Ox];new Set(M$);var _r=Oe(null);_r.displayName="DataRouter";var fa=Oe(null);fa.displayName="DataRouterState";var zx=Oe(!1);function I$(){return ve(zx)}var Bx=Oe({isTransitioning:!1});Bx.displayName="ViewTransition";var A$=Oe(new Map);A$.displayName="Fetchers";var P$=Oe(null);P$.displayName="Await";var mt=Oe(null);mt.displayName="Navigation";var So=Oe(null);So.displayName="Location";var Ct=Oe({outlet:null,matches:[],isDataRoute:!1});Ct.displayName="Route";var zc=Oe(null);zc.displayName="RouteError";var Fx="REACT_ROUTER_ERROR",E$="REDIRECT",$$="ROUTE_ERROR_RESPONSE";function _$(e){if(e.startsWith(`${Fx}:${E$}:{`))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 D$(e){if(e.startsWith(`${Fx}:${$$}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new k$(t.status,t.statusText,t.data)}catch{}}function L$(e,{relative:t}={}){ze(Dr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:o}=ve(mt),{hash:s,pathname:a,search:i}=Co(e,{relative:t}),l=a;return n!=="/"&&(l=a==="/"?n:Dt([n,a])),o.createHref({pathname:l,search:i,hash:s})}function Dr(){return ve(So)!=null}function ht(){return ze(Dr(),"useLocation() may be used only in the context of a <Router> component."),ve(So).location}var jx="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Hx(e){ve(mt).static||Gs(e)}function Je(){let{isDataRoute:e}=ve(Ct);return e?W$():T$()}function T$(){ze(Dr(),"useNavigate() may be used only in the context of a <Router> component.");let e=ve(_r),{basename:t,navigator:n}=ve(mt),{matches:o}=ve(Ct),{pathname:s}=ht(),a=JSON.stringify(Oc(o)),i=ne(!1);return Hx(()=>{i.current=!0}),q((c,d={})=>{if(vt(i.current,jx),!i.current)return;if(typeof c=="number"){n.go(c);return}let f=pa(c,JSON.parse(a),s,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Dt([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,a,s,e])}var R$=Oe(null);function O$(e){let t=ve(Ct).outlet;return U(()=>t&&Me(R$.Provider,{value:e},t),[t,e])}function Bc(){let{matches:e}=ve(Ct);return e[e.length-1]?.params??{}}function Co(e,{relative:t}={}){let{matches:n}=ve(Ct),{pathname:o}=ht(),s=JSON.stringify(Oc(n));return U(()=>pa(e,JSON.parse(s),o,t==="path"),[e,s,o,t])}function z$(e,t){return Vx(e,t)}function Vx(e,t,n){ze(Dr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=ve(mt),{matches:s}=ve(Ct),a=s[s.length-1],i=a?a.params:{},l=a?a.pathname:"/",c=a?a.pathnameBase:"/",d=a&&a.route;{let x=d&&d.path||"";Qx(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.
|
|
544
|
+
|
|
545
|
+
Please change the parent <Route path="${x}"> to <Route path="${x==="/"?"*":`${x}/*`}">.`)}let f=ht(),p;if(t){let x=typeof t=="string"?$r(t):t;ze(c==="/"||x.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${x.pathname}" was given in the \`location\` prop.`),p=x}else p=f;let m=p.pathname||"/",h=m;if(c!=="/"){let x=c.replace(/^\//,"").split("/");h="/"+m.replace(/^\//,"").split("/").slice(x.length).join("/")}let g=n&&n.state.matches.length?n.state.matches.map(x=>Object.assign(x,{route:n.manifest[x.route.id]||x.route})):$x(e,{pathname:h});vt(d||g!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),vt(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=V$(g&&g.map(x=>Object.assign({},x,{params:Object.assign({},i,x.params),pathname:Dt([c,o.encodeLocation?o.encodeLocation(x.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?c:Dt([c,o.encodeLocation?o.encodeLocation(x.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathnameBase])})),s,n);return t&&b?Me(So.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...p},navigationType:"POP"}},b):b}function B$(){let e=G$(),t=S$(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,o="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:o},a={padding:"2px 4px",backgroundColor:o},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=Me(mr,null,Me("p",null,"💿 Hey developer 👋"),Me("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",Me("code",{style:a},"ErrorBoundary")," or"," ",Me("code",{style:a},"errorElement")," prop on your route.")),Me(mr,null,Me("h2",null,"Unexpected Application Error!"),Me("h3",{style:{fontStyle:"italic"}},t),n?Me("pre",{style:s},n):null,i)}var F$=Me(B$,null),qx=class extends G1{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=D$(e.digest);n&&(e=n)}let t=e!==void 0?Me(Ct.Provider,{value:this.props.routeContext},Me(zc.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?Me(j$,{error:e},t):t}};qx.contextType=zx;var ri=new WeakMap;function j$({children:e,error:t}){let{basename:n}=ve(mt);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let o=_$(t.digest);if(o){let s=ri.get(t);if(s)throw s;let a=Rx(o.location,n);if(Tx&&!ri.get(t))if(a.isExternal||o.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:o.replace}));throw ri.set(t,i),i}return Me("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function H$({routeContext:e,match:t,children:n}){let o=ve(_r);return o&&o.static&&o.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=t.route.id),Me(Ct.Provider,{value:e},n)}function V$(e,t=[],n){let o=n?.state;if(e==null){if(!o)return null;if(o.errors)e=o.matches;else if(t.length===0&&!o.initialized&&o.matches.length>0)e=o.matches;else return null}let s=e,a=o?.errors;if(a!=null){let f=s.findIndex(p=>p.route.id&&a?.[p.route.id]!==void 0);ze(f>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),s=s.slice(0,Math.min(s.length,f+1))}let i=!1,l=-1;if(n&&o){i=o.renderFallback;for(let f=0;f<s.length;f++){let p=s[f];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(l=f),p.route.id){let{loaderData:m,errors:h}=o,g=p.route.loader&&!m.hasOwnProperty(p.route.id)&&(!h||h[p.route.id]===void 0);if(p.route.lazy||g){n.isStatic&&(i=!0),l>=0?s=s.slice(0,l+1):s=[s[0]];break}}}}let c=n?.onError,d=o&&c?(f,p)=>{c(f,{location:o.location,params:o.matches?.[0]?.params??{},pattern:C$(o.matches),errorInfo:p})}:void 0;return s.reduceRight((f,p,m)=>{let h,g=!1,b=null,x=null;o&&(h=a&&p.route.id?a[p.route.id]:void 0,b=p.route.errorElement||F$,i&&(l<0&&m===0?(Qx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,x=null):l===m&&(g=!0,x=p.route.hydrateFallbackElement||null)));let v=t.concat(s.slice(0,m+1)),w=()=>{let y;return h?y=b:g?y=x:p.route.Component?y=Me(p.route.Component,null):p.route.element?y=p.route.element:y=f,Me(H$,{match:p,routeContext:{outlet:f,matches:v,isDataRoute:o!=null},children:y})};return o&&(p.route.ErrorBoundary||p.route.errorElement||m===0)?Me(qx,{location:o.location,revalidation:o.revalidation,component:b,error:h,children:w(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:d}):w()},null)}function Fc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function q$(e){let t=ve(_r);return ze(t,Fc(e)),t}function Q$(e){let t=ve(fa);return ze(t,Fc(e)),t}function U$(e){let t=ve(Ct);return ze(t,Fc(e)),t}function jc(e){let t=U$(e),n=t.matches[t.matches.length-1];return ze(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function K$(){return jc("useRouteId")}function G$(){let e=ve(zc),t=Q$("useRouteError"),n=jc("useRouteError");return e!==void 0?e:t.errors?.[n]}function W$(){let{router:e}=q$("useNavigate"),t=jc("useNavigate"),n=ne(!1);return Hx(()=>{n.current=!0}),q(async(s,a={})=>{vt(n.current,jx),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...a}))},[e,t])}var Au={};function Qx(e,t,n){!t&&!Au[e]&&(Au[e]=!0,vt(!1,n))}Fe(Y$);function Y$({routes:e,manifest:t,future:n,state:o,isStatic:s,onError:a}){return Vx(e,void 0,{manifest:t,state:o,isStatic:s,onError:a})}function gt({to:e,replace:t,state:n,relative:o}){ze(Dr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:s}=ve(mt);vt(!s,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:a}=ve(Ct),{pathname:i}=ht(),l=Je(),c=pa(e,Oc(a),i,o==="path"),d=JSON.stringify(c);return Z(()=>{l(JSON.parse(d),{replace:t,state:n,relative:o})},[l,d,o,t,n]),null}function Z$(e){return O$(e.context)}function De(e){ze(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function X$({basename:e="/",children:t=null,location:n,navigationType:o="POP",navigator:s,static:a=!1,useTransitions:i}){ze(!Dr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=U(()=>({basename:l,navigator:s,static:a,useTransitions:i,future:{}}),[l,s,a,i]);typeof n=="string"&&(n=$r(n));let{pathname:d="/",search:f="",hash:p="",state:m=null,key:h="default",mask:g}=n,b=U(()=>{let x=rn(d,l);return x==null?null:{location:{pathname:x,search:f,hash:p,state:m,key:h,mask:g},navigationType:o}},[l,d,f,p,m,h,o,g]);return vt(b!=null,`<Router basename="${l}"> is not able to match the URL "${d}${f}${p}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:Me(mt.Provider,{value:c},Me(So.Provider,{children:t,value:b}))}function J$({children:e,location:t}){return z$(Zi(e),t)}function Zi(e,t=[]){let n=[];return U1.forEach(e,(o,s)=>{if(!K1(o))return;let a=[...t,s];if(o.type===mr){n.push.apply(n,Zi(o.props.children,a));return}ze(o.type===De,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ze(!o.props.index||!o.props.children,"An index route cannot have child routes.");let i={id:o.props.id||a.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(i.children=Zi(o.props.children,a)),n.push(i)}),n}var ms="get",hs="application/x-www-form-urlencoded";function ma(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function e_(e){return ma(e)&&e.tagName.toLowerCase()==="button"}function t_(e){return ma(e)&&e.tagName.toLowerCase()==="form"}function n_(e){return ma(e)&&e.tagName.toLowerCase()==="input"}function r_(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function o_(e,t){return e.button===0&&(!t||t==="_self")&&!r_(e)}function Xi(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let o=e[n];return t.concat(Array.isArray(o)?o.map(s=>[n,s]):[[n,o]])},[]))}function s_(e,t){let n=Xi(e);return t&&t.forEach((o,s)=>{n.has(s)||t.getAll(s).forEach(a=>{n.append(s,a)})}),n}var Qo=null;function a_(){if(Qo===null)try{new FormData(document.createElement("form"),0),Qo=!1}catch{Qo=!0}return Qo}var i_=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function oi(e){return e!=null&&!i_.has(e)?(vt(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${hs}"`),null):e}function l_(e,t){let n,o,s,a,i;if(t_(e)){let l=e.getAttribute("action");o=l?rn(l,t):null,n=e.getAttribute("method")||ms,s=oi(e.getAttribute("enctype"))||hs,a=new FormData(e)}else if(e_(e)||n_(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(o=c?rn(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||ms,s=oi(e.getAttribute("formenctype"))||oi(l.getAttribute("enctype"))||hs,a=new FormData(l,e),!a_()){let{name:d,type:f,value:p}=e;if(f==="image"){let m=d?`${d}.`:"";a.append(`${m}x`,"0"),a.append(`${m}y`,"0")}else d&&a.append(d,p)}}else{if(ma(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=ms,o=null,s=hs,i=e}return a&&s==="text/plain"&&(i=a,a=void 0),{action:o,method:n.toLowerCase(),encType:s,formData:a,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Hc(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ux(e,t,n,o){let s=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?s.pathname.endsWith("/")?s.pathname=`${s.pathname}_.${o}`:s.pathname=`${s.pathname}.${o}`:s.pathname==="/"?s.pathname=`_root.${o}`:t&&rn(s.pathname,t)==="/"?s.pathname=`${As(t)}/_root.${o}`:s.pathname=`${As(s.pathname)}.${o}`,s}async function c_(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 d_(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 u_(e,t,n){let o=await Promise.all(e.map(async s=>{let a=t.routes[s.route.id];if(a){let i=await c_(a,n);return i.links?i.links():[]}return[]}));return h_(o.flat(1).filter(d_).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function Pu(e,t,n,o,s,a){let i=(c,d)=>n[d]?c.route.id!==n[d].route.id:!0,l=(c,d)=>n[d].pathname!==c.pathname||n[d].route.path?.endsWith("*")&&n[d].params["*"]!==c.params["*"];return a==="assets"?t.filter((c,d)=>i(c,d)||l(c,d)):a==="data"?t.filter((c,d)=>{let f=o.routes[c.route.id];if(!f||!f.hasLoader)return!1;if(i(c,d)||l(c,d))return!0;if(c.route.shouldRevalidate){let p=c.route.shouldRevalidate({currentUrl:new URL(s.pathname+s.search+s.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof p=="boolean")return p}return!0}):[]}function p_(e,t,{includeHydrateFallback:n}={}){return f_(e.map(o=>{let s=t.routes[o.route.id];if(!s)return[];let a=[s.module];return s.clientActionModule&&(a=a.concat(s.clientActionModule)),s.clientLoaderModule&&(a=a.concat(s.clientLoaderModule)),n&&s.hydrateFallbackModule&&(a=a.concat(s.hydrateFallbackModule)),s.imports&&(a=a.concat(s.imports)),a}).flat(1))}function f_(e){return[...new Set(e)]}function m_(e){let t={},n=Object.keys(e).sort();for(let o of n)t[o]=e[o];return t}function h_(e,t){let n=new Set;return new Set(t),e.reduce((o,s)=>{let a=JSON.stringify(m_(s));return n.has(a)||(n.add(a),o.push({key:a,link:s})),o},[])}function Vc(){let e=ve(_r);return Hc(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function g_(){let e=ve(fa);return Hc(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var qc=Oe(void 0);qc.displayName="FrameworkContext";function Qc(){let e=ve(qc);return Hc(e,"You must render this element inside a <HydratedRouter> element"),e}function b_(e,t){let n=ve(qc),[o,s]=_(!1),[a,i]=_(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:f,onTouchStart:p}=t,m=ne(null);Z(()=>{if(e==="render"&&i(!0),e==="viewport"){let b=v=>{v.forEach(w=>{i(w.isIntersecting)})},x=new IntersectionObserver(b,{threshold:.5});return m.current&&x.observe(m.current),()=>{x.disconnect()}}},[e]),Z(()=>{if(o){let b=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(b)}}},[o]);let h=()=>{s(!0)},g=()=>{s(!1),i(!1)};return n?e!=="intent"?[a,m,{}]:[a,m,{onFocus:zr(l,h),onBlur:zr(c,g),onMouseEnter:zr(d,h),onMouseLeave:zr(f,g),onTouchStart:zr(p,h)}]:[!1,m,{}]}function zr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function x_({page:e,...t}){let n=I$(),{router:o}=Vc(),s=U(()=>$x(o.routes,e,o.basename),[o.routes,e,o.basename]);return s?n?Me(v_,{page:e,matches:s,...t}):Me(w_,{page:e,matches:s,...t}):null}function y_(e){let{manifest:t,routeModules:n}=Qc(),[o,s]=_([]);return Z(()=>{let a=!1;return u_(e,t,n).then(i=>{a||s(i)}),()=>{a=!0}},[e,t,n]),o}function v_({page:e,matches:t,...n}){let o=ht(),{future:s}=Qc(),{basename:a}=Vc(),i=U(()=>{if(e===o.pathname+o.search+o.hash)return[];let l=Ux(e,a,s.unstable_trailingSlashAwareDataRequests,"rsc"),c=!1,d=[];for(let f of t)typeof f.route.shouldRevalidate=="function"?c=!0:d.push(f.route.id);return c&&d.length>0&&l.searchParams.set("_routes",d.join(",")),[l.pathname+l.search]},[a,s.unstable_trailingSlashAwareDataRequests,e,o,t]);return Me(mr,null,i.map(l=>Me("link",{key:l,rel:"prefetch",as:"fetch",href:l,...n})))}function w_({page:e,matches:t,...n}){let o=ht(),{future:s,manifest:a,routeModules:i}=Qc(),{basename:l}=Vc(),{loaderData:c,matches:d}=g_(),f=U(()=>Pu(e,t,d,a,o,"data"),[e,t,d,a,o]),p=U(()=>Pu(e,t,d,a,o,"assets"),[e,t,d,a,o]),m=U(()=>{if(e===o.pathname+o.search+o.hash)return[];let b=new Set,x=!1;if(t.forEach(w=>{let y=a.routes[w.route.id];!y||!y.hasLoader||(!f.some(N=>N.route.id===w.route.id)&&w.route.id in c&&i[w.route.id]?.shouldRevalidate||y.hasClientLoader?x=!0:b.add(w.route.id))}),b.size===0)return[];let v=Ux(e,l,s.unstable_trailingSlashAwareDataRequests,"data");return x&&b.size>0&&v.searchParams.set("_routes",t.filter(w=>b.has(w.route.id)).map(w=>w.route.id).join(",")),[v.pathname+v.search]},[l,s.unstable_trailingSlashAwareDataRequests,c,o,a,f,t,e,i]),h=U(()=>p_(p,a),[p,a]),g=y_(p);return Me(mr,null,m.map(b=>Me("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),h.map(b=>Me("link",{key:b,rel:"modulepreload",href:b,...n})),g.map(({key:b,link:x})=>Me("link",{key:b,nonce:n.nonce,...x,crossOrigin:x.crossOrigin??n.crossOrigin})))}function N_(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var k_=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{k_&&(window.__reactRouterVersion="7.15.0")}catch{}function S_({basename:e,children:t,useTransitions:n,window:o}){let s=ne();s.current==null&&(s.current=JE({window:o,v5Compat:!0}));let a=s.current,[i,l]=_({action:a.action,location:a.location}),c=q(d=>{n===!1?l(d):$l(()=>l(d))},[n]);return Gs(()=>a.listen(c),[a,c]),Me(X$,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,useTransitions:n})}var Kx=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,io=He(function({onClick:t,discover:n="render",prefetch:o="none",relative:s,reloadDocument:a,replace:i,mask:l,state:c,target:d,to:f,preventScrollReset:p,viewTransition:m,defaultShouldRevalidate:h,...g},b){let{basename:x,navigator:v,useTransitions:w}=ve(mt),y=typeof f=="string"&&Kx.test(f),N=Rx(f,x);f=N.to;let k=L$(f,{relative:s}),S=ht(),M=null;if(l){let L=pa(l,[],S.mask?S.mask.pathname:"/",!0);x!=="/"&&(L.pathname=L.pathname==="/"?x:Dt([x,L.pathname])),M=v.createHref(L)}let[P,I,z]=b_(o,g),$=A_(f,{replace:i,mask:l,state:c,target:d,preventScrollReset:p,relative:s,viewTransition:m,defaultShouldRevalidate:h,useTransitions:w});function O(L){t&&t(L),L.defaultPrevented||$(L)}let R=!(N.isExternal||a),A=Me("a",{...g,...z,href:(R?M:void 0)||N.absoluteURL||k,onClick:R?O:t,ref:N_(b,I),target:d,"data-discover":!y&&n==="render"?"true":void 0});return P&&!y?Me(mr,null,A,Me(x_,{page:k})):A});io.displayName="Link";var C_=He(function({"aria-current":t="page",caseSensitive:n=!1,className:o="",end:s=!1,style:a,to:i,viewTransition:l,children:c,...d},f){let p=Co(i,{relative:d.relative}),m=ht(),h=ve(fa),{navigator:g,basename:b}=ve(mt),x=h!=null&&D_(p)&&l===!0,v=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,w=m.pathname,y=h&&h.navigation&&h.navigation.location?h.navigation.location.pathname:null;n||(w=w.toLowerCase(),y=y?y.toLowerCase():null,v=v.toLowerCase()),y&&b&&(y=rn(y,b)||y);const N=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let k=w===v||!s&&w.startsWith(v)&&w.charAt(N)==="/",S=y!=null&&(y===v||!s&&y.startsWith(v)&&y.charAt(v.length)==="/"),M={isActive:k,isPending:S,isTransitioning:x},P=k?t:void 0,I;typeof o=="function"?I=o(M):I=[o,k?"active":null,S?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let z=typeof a=="function"?a(M):a;return Me(io,{...d,"aria-current":P,className:I,ref:f,style:z,to:i,viewTransition:l},typeof c=="function"?c(M):c)});C_.displayName="NavLink";var M_=He(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:o,replace:s,state:a,method:i=ms,action:l,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m,...h},g)=>{let{useTransitions:b}=ve(mt),x=$_(),v=__(l,{relative:d}),w=i.toLowerCase()==="get"?"get":"post",y=typeof l=="string"&&Kx.test(l);return Me("form",{ref:g,method:w,action:v,onSubmit:o?c:k=>{if(c&&c(k),k.defaultPrevented)return;k.preventDefault();let S=k.nativeEvent.submitter,M=S?.getAttribute("formmethod")||i,P=()=>x(S||k.currentTarget,{fetcherKey:t,method:M,navigate:n,replace:s,state:a,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m});b&&n!==!1?$l(()=>P()):P()},...h,"data-discover":!y&&e==="render"?"true":void 0})});M_.displayName="Form";function I_(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Gx(e){let t=ve(_r);return ze(t,I_(e)),t}function A_(e,{target:t,replace:n,mask:o,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c,useTransitions:d}={}){let f=Je(),p=ht(),m=Co(e,{relative:i});return q(h=>{if(o_(h,t)){h.preventDefault();let g=n!==void 0?n:ao(p)===ao(m),b=()=>f(e,{replace:g,mask:o,state:s,preventScrollReset:a,relative:i,viewTransition:l,defaultShouldRevalidate:c});d?$l(()=>b()):b()}},[p,f,m,n,o,s,t,e,a,i,l,c,d])}function ha(e){vt(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=ne(Xi(e)),n=ne(!1),o=ht(),s=U(()=>s_(o.search,n.current?null:t.current),[o.search]),a=Je(),i=q((l,c)=>{const d=Xi(typeof l=="function"?l(new URLSearchParams(s)):l);n.current=!0,a("?"+d,c)},[a,s]);return[s,i]}var P_=0,E_=()=>`__${String(++P_)}__`;function $_(){let{router:e}=Gx("useSubmit"),{basename:t}=ve(mt),n=K$(),o=e.fetch,s=e.navigate;return q(async(a,i={})=>{let{action:l,method:c,encType:d,formData:f,body:p}=l_(a,t);if(i.navigate===!1){let m=i.fetcherKey||E_();await o(m,n,i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:p,formMethod:i.method||c,formEncType:i.encType||d,flushSync:i.flushSync})}else await s(i.action||l,{defaultShouldRevalidate:i.defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:f,body:p,formMethod:i.method||c,formEncType:i.encType||d,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[o,s,t,n])}function __(e,{relative:t}={}){let{basename:n}=ve(mt),o=ve(Ct);ze(o,"useFormAction must be used inside a RouteContext");let[s]=o.matches.slice(-1),a={...Co(e||".",{relative:t})},i=ht();if(e==null){a.search=i.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(f=>f==="")){l.delete("index"),c.filter(p=>p).forEach(p=>l.append("index",p));let f=l.toString();a.search=f?`?${f}`:""}}return(!e||e===".")&&s.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Dt([n,a.pathname])),ao(a)}function D_(e,{relative:t}={}){let n=ve(Bx);ze(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Gx("useViewTransitionState"),s=Co(e,{relative:t});if(!n.isTransitioning)return!1;let a=rn(n.currentLocation.pathname,o)||n.currentLocation.pathname,i=rn(n.nextLocation.pathname,o)||n.nextLocation.pathname;return Is(s.pathname,i)!=null||Is(s.pathname,a)!=null}const L_=3e4;function T_(e){const t=ne(e);t.current=e,Z(()=>{let n=null;const o=()=>{if(document.visibilityState==="hidden"){n=Date.now();return}if(document.visibilityState==="visible"&&n!==null){const i=Date.now()-n;n=null,i>=L_&&t.current()}},s=()=>{t.current()},a=i=>{i.persisted&&t.current()};return document.addEventListener("visibilitychange",o),window.addEventListener("online",s),window.addEventListener("pageshow",a),()=>{document.removeEventListener("visibilitychange",o),window.removeEventListener("online",s),window.removeEventListener("pageshow",a)}},[])}let Ji="disconnected";const el=new Set;function R_(){for(const e of el)e()}function O_(e){Ji!==e&&(Ji=e,R_())}function z_(e){return el.add(e),()=>{el.delete(e)}}function Eu(){return Ji}function B_(){return Ws(z_,Eu,Eu)}let Gr=null;function tl(){if(!Gr){const e=window.location.origin,t=localStorage.getItem("camstack_admin_token")??void 0;Gr=Hf({serverUrl:e,token:t,onConnectionChange:n=>O_(n)})}return Gr}function Wr(){Gr?.close(),Gr=null}function F_(e){const t=dn();return t===null?r("div",{className:"rounded-md border border-warning/40 bg-warning/10 p-3 text-xs text-warning",children:"zone-editor: no DeviceContext — declare this field inside a top-tab section rendered from a device-detail page."}):r(at,{widgetId:"pipeline-orchestrator/zone-editor",host:"device-tab",deviceId:t})}function j_({deviceId:e}){return u("div",{className:fm,children:[u("div",{className:`grid ${mm}`,style:{gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 340px), 1fr))"},children:[r(at,{widgetId:"pipeline-analytics/live-occupancy-panel",host:"device-tab",deviceId:e}),r(at,{widgetId:"pipeline-analytics/audio-metrics-panel",host:"device-tab",deviceId:e})]}),r(at,{widgetId:"pipeline-analytics/audio-history-chart",host:"device-tab",deviceId:e}),r(at,{widgetId:"pipeline-analytics/occupancy-history-chart",host:"device-tab",deviceId:e}),r(at,{widgetId:"pipeline-analytics/motion-history-chart",host:"device-tab",deviceId:e}),r(at,{widgetId:"pipeline-analytics/detection-history-chart",host:"device-tab",deviceId:e})]})}function H_(e){const t=dn();return t===null?r("div",{className:"rounded-md border border-warning/40 bg-warning/10 p-3 text-xs text-warning",children:"live-stats: no DeviceContext — declare this field inside a top-tab section rendered from a device-detail page."}):r(j_,{deviceId:t})}/**
|
|
546
|
+
* @license lucide-react v0.511.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 V_=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),q_=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase()),$u=e=>{const t=q_(e);return t.charAt(0).toUpperCase()+t.slice(1)},Wx=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim(),Q_=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/**
|
|
551
|
+
* @license lucide-react v0.511.0 - ISC
|
|
552
|
+
*
|
|
553
|
+
* This source code is licensed under the ISC license.
|
|
554
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
555
|
+
*/var U_={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"};/**
|
|
556
|
+
* @license lucide-react v0.511.0 - ISC
|
|
557
|
+
*
|
|
558
|
+
* This source code is licensed under the ISC license.
|
|
559
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
560
|
+
*/const K_=He(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:s="",children:a,iconNode:i,...l},c)=>Me("svg",{ref:c,...U_,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:Wx("lucide",s),...!a&&!Q_(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,f])=>Me(d,f)),...Array.isArray(a)?a:[a]]));/**
|
|
561
|
+
* @license lucide-react v0.511.0 - ISC
|
|
562
|
+
*
|
|
563
|
+
* This source code is licensed under the ISC license.
|
|
564
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
565
|
+
*/const se=(e,t)=>{const n=He(({className:o,...s},a)=>Me(K_,{ref:a,iconNode:t,className:Wx(`lucide-${V_($u(e))}`,`lucide-${e}`,o),...s}));return n.displayName=$u(e),n};/**
|
|
566
|
+
* @license lucide-react v0.511.0 - ISC
|
|
567
|
+
*
|
|
568
|
+
* This source code is licensed under the ISC license.
|
|
569
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
570
|
+
*/const G_=[["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"}]],Mo=se("activity",G_);/**
|
|
571
|
+
* @license lucide-react v0.511.0 - ISC
|
|
572
|
+
*
|
|
573
|
+
* This source code is licensed under the ISC license.
|
|
574
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
575
|
+
*/const W_=[["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"}]],Uc=se("archive",W_);/**
|
|
576
|
+
* @license lucide-react v0.511.0 - ISC
|
|
577
|
+
*
|
|
578
|
+
* This source code is licensed under the ISC license.
|
|
579
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
580
|
+
*/const Y_=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Yx=se("arrow-left",Y_);/**
|
|
581
|
+
* @license lucide-react v0.511.0 - ISC
|
|
582
|
+
*
|
|
583
|
+
* This source code is licensed under the ISC license.
|
|
584
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
585
|
+
*/const Z_=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Zx=se("arrow-right",Z_);/**
|
|
586
|
+
* @license lucide-react v0.511.0 - ISC
|
|
587
|
+
*
|
|
588
|
+
* This source code is licensed under the ISC license.
|
|
589
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
590
|
+
*/const X_=[["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"}]],J_=se("battery-full",X_);/**
|
|
591
|
+
* @license lucide-react v0.511.0 - ISC
|
|
592
|
+
*
|
|
593
|
+
* This source code is licensed under the ISC license.
|
|
594
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
595
|
+
*/const eD=[["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"}]],Io=se("bell",eD);/**
|
|
596
|
+
* @license lucide-react v0.511.0 - ISC
|
|
597
|
+
*
|
|
598
|
+
* This source code is licensed under the ISC license.
|
|
599
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
600
|
+
*/const tD=[["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"}]],nD=se("bot",tD);/**
|
|
601
|
+
* @license lucide-react v0.511.0 - ISC
|
|
602
|
+
*
|
|
603
|
+
* This source code is licensed under the ISC license.
|
|
604
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
605
|
+
*/const rD=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],ga=se("box",rD);/**
|
|
606
|
+
* @license lucide-react v0.511.0 - ISC
|
|
607
|
+
*
|
|
608
|
+
* This source code is licensed under the ISC license.
|
|
609
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
610
|
+
*/const oD=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],ba=se("boxes",oD);/**
|
|
611
|
+
* @license lucide-react v0.511.0 - ISC
|
|
612
|
+
*
|
|
613
|
+
* This source code is licensed under the ISC license.
|
|
614
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
615
|
+
*/const sD=[["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"}]],aD=se("calendar-clock",sD);/**
|
|
616
|
+
* @license lucide-react v0.511.0 - ISC
|
|
617
|
+
*
|
|
618
|
+
* This source code is licensed under the ISC license.
|
|
619
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
620
|
+
*/const iD=[["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"}]],Xx=se("calendar",iD);/**
|
|
621
|
+
* @license lucide-react v0.511.0 - ISC
|
|
622
|
+
*
|
|
623
|
+
* This source code is licensed under the ISC license.
|
|
624
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
625
|
+
*/const lD=[["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"}]],hr=se("camera",lD);/**
|
|
626
|
+
* @license lucide-react v0.511.0 - ISC
|
|
627
|
+
*
|
|
628
|
+
* This source code is licensed under the ISC license.
|
|
629
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
630
|
+
*/const cD=[["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"}]],Jx=se("cctv",cD);/**
|
|
631
|
+
* @license lucide-react v0.511.0 - ISC
|
|
632
|
+
*
|
|
633
|
+
* This source code is licensed under the ISC license.
|
|
634
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
635
|
+
*/const dD=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],uD=se("check-check",dD);/**
|
|
636
|
+
* @license lucide-react v0.511.0 - ISC
|
|
637
|
+
*
|
|
638
|
+
* This source code is licensed under the ISC license.
|
|
639
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
640
|
+
*/const pD=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Mt=se("check",pD);/**
|
|
641
|
+
* @license lucide-react v0.511.0 - ISC
|
|
642
|
+
*
|
|
643
|
+
* This source code is licensed under the ISC license.
|
|
644
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
645
|
+
*/const fD=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],wt=se("chevron-down",fD);/**
|
|
646
|
+
* @license lucide-react v0.511.0 - ISC
|
|
647
|
+
*
|
|
648
|
+
* This source code is licensed under the ISC license.
|
|
649
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
650
|
+
*/const mD=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Kc=se("chevron-left",mD);/**
|
|
651
|
+
* @license lucide-react v0.511.0 - ISC
|
|
652
|
+
*
|
|
653
|
+
* This source code is licensed under the ISC license.
|
|
654
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
655
|
+
*/const hD=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],It=se("chevron-right",hD);/**
|
|
656
|
+
* @license lucide-react v0.511.0 - ISC
|
|
657
|
+
*
|
|
658
|
+
* This source code is licensed under the ISC license.
|
|
659
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
660
|
+
*/const gD=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],bD=se("chevron-up",gD);/**
|
|
661
|
+
* @license lucide-react v0.511.0 - ISC
|
|
662
|
+
*
|
|
663
|
+
* This source code is licensed under the ISC license.
|
|
664
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
665
|
+
*/const xD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],xa=se("circle-alert",xD);/**
|
|
666
|
+
* @license lucide-react v0.511.0 - ISC
|
|
667
|
+
*
|
|
668
|
+
* This source code is licensed under the ISC license.
|
|
669
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
670
|
+
*/const yD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ey=se("circle-check",yD);/**
|
|
671
|
+
* @license lucide-react v0.511.0 - ISC
|
|
672
|
+
*
|
|
673
|
+
* This source code is licensed under the ISC license.
|
|
674
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
675
|
+
*/const vD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],ty=se("circle-dot",vD);/**
|
|
676
|
+
* @license lucide-react v0.511.0 - ISC
|
|
677
|
+
*
|
|
678
|
+
* This source code is licensed under the ISC license.
|
|
679
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
680
|
+
*/const wD=[["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"}]],ND=se("circle-help",wD);/**
|
|
681
|
+
* @license lucide-react v0.511.0 - ISC
|
|
682
|
+
*
|
|
683
|
+
* This source code is licensed under the ISC license.
|
|
684
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
685
|
+
*/const kD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],SD=se("clock",kD);/**
|
|
686
|
+
* @license lucide-react v0.511.0 - ISC
|
|
687
|
+
*
|
|
688
|
+
* This source code is licensed under the ISC license.
|
|
689
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
690
|
+
*/const CD=[["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"}]],MD=se("copy",CD);/**
|
|
691
|
+
* @license lucide-react v0.511.0 - ISC
|
|
692
|
+
*
|
|
693
|
+
* This source code is licensed under the ISC license.
|
|
694
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
695
|
+
*/const ID=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],dt=se("cpu",ID);/**
|
|
696
|
+
* @license lucide-react v0.511.0 - ISC
|
|
697
|
+
*
|
|
698
|
+
* This source code is licensed under the ISC license.
|
|
699
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
700
|
+
*/const AD=[["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"}]],PD=se("crosshair",AD);/**
|
|
701
|
+
* @license lucide-react v0.511.0 - ISC
|
|
702
|
+
*
|
|
703
|
+
* This source code is licensed under the ISC license.
|
|
704
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
705
|
+
*/const ED=[["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"}]],ny=se("database",ED);/**
|
|
706
|
+
* @license lucide-react v0.511.0 - ISC
|
|
707
|
+
*
|
|
708
|
+
* This source code is licensed under the ISC license.
|
|
709
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
710
|
+
*/const $D=[["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"}]],vn=se("download",$D);/**
|
|
711
|
+
* @license lucide-react v0.511.0 - ISC
|
|
712
|
+
*
|
|
713
|
+
* This source code is licensed under the ISC license.
|
|
714
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
715
|
+
*/const _D=[["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"}]],DD=se("ellipsis-vertical",_D);/**
|
|
716
|
+
* @license lucide-react v0.511.0 - ISC
|
|
717
|
+
*
|
|
718
|
+
* This source code is licensed under the ISC license.
|
|
719
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
720
|
+
*/const LD=[["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"}]],Gc=se("external-link",LD);/**
|
|
721
|
+
* @license lucide-react v0.511.0 - ISC
|
|
722
|
+
*
|
|
723
|
+
* This source code is licensed under the ISC license.
|
|
724
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
725
|
+
*/const TD=[["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"}]],ry=se("eye-off",TD);/**
|
|
726
|
+
* @license lucide-react v0.511.0 - ISC
|
|
727
|
+
*
|
|
728
|
+
* This source code is licensed under the ISC license.
|
|
729
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
730
|
+
*/const RD=[["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"}]],ya=se("eye",RD);/**
|
|
731
|
+
* @license lucide-react v0.511.0 - ISC
|
|
732
|
+
*
|
|
733
|
+
* This source code is licensed under the ISC license.
|
|
734
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
735
|
+
*/const OD=[["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"}]],Yr=se("film",OD);/**
|
|
736
|
+
* @license lucide-react v0.511.0 - ISC
|
|
737
|
+
*
|
|
738
|
+
* This source code is licensed under the ISC license.
|
|
739
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
740
|
+
*/const zD=[["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"}]],BD=se("flame",zD);/**
|
|
741
|
+
* @license lucide-react v0.511.0 - ISC
|
|
742
|
+
*
|
|
743
|
+
* This source code is licensed under the ISC license.
|
|
744
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
745
|
+
*/const FD=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],oy=se("gauge",FD);/**
|
|
746
|
+
* @license lucide-react v0.511.0 - ISC
|
|
747
|
+
*
|
|
748
|
+
* This source code is licensed under the ISC license.
|
|
749
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
750
|
+
*/const jD=[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]],nl=se("ghost",jD);/**
|
|
751
|
+
* @license lucide-react v0.511.0 - ISC
|
|
752
|
+
*
|
|
753
|
+
* This source code is licensed under the ISC license.
|
|
754
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
755
|
+
*/const HD=[["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"}]],sy=se("git-branch",HD);/**
|
|
756
|
+
* @license lucide-react v0.511.0 - ISC
|
|
757
|
+
*
|
|
758
|
+
* This source code is licensed under the ISC license.
|
|
759
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
760
|
+
*/const VD=[["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"}]],gr=se("globe",VD);/**
|
|
761
|
+
* @license lucide-react v0.511.0 - ISC
|
|
762
|
+
*
|
|
763
|
+
* This source code is licensed under the ISC license.
|
|
764
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
765
|
+
*/const qD=[["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"}]],lo=se("hard-drive",qD);/**
|
|
766
|
+
* @license lucide-react v0.511.0 - ISC
|
|
767
|
+
*
|
|
768
|
+
* This source code is licensed under the ISC license.
|
|
769
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
770
|
+
*/const QD=[["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"}]],UD=se("house",QD);/**
|
|
771
|
+
* @license lucide-react v0.511.0 - ISC
|
|
772
|
+
*
|
|
773
|
+
* This source code is licensed under the ISC license.
|
|
774
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
775
|
+
*/const KD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ps=se("info",KD);/**
|
|
776
|
+
* @license lucide-react v0.511.0 - ISC
|
|
777
|
+
*
|
|
778
|
+
* This source code is licensed under the ISC license.
|
|
779
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
780
|
+
*/const GD=[["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"}]],ay=se("key-round",GD);/**
|
|
781
|
+
* @license lucide-react v0.511.0 - ISC
|
|
782
|
+
*
|
|
783
|
+
* This source code is licensed under the ISC license.
|
|
784
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
785
|
+
*/const WD=[["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"}]],YD=se("key",WD);/**
|
|
786
|
+
* @license lucide-react v0.511.0 - ISC
|
|
787
|
+
*
|
|
788
|
+
* This source code is licensed under the ISC license.
|
|
789
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
790
|
+
*/const ZD=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],XD=se("languages",ZD);/**
|
|
791
|
+
* @license lucide-react v0.511.0 - ISC
|
|
792
|
+
*
|
|
793
|
+
* This source code is licensed under the ISC license.
|
|
794
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
795
|
+
*/const JD=[["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"}]],eL=se("layers",JD);/**
|
|
796
|
+
* @license lucide-react v0.511.0 - ISC
|
|
797
|
+
*
|
|
798
|
+
* This source code is licensed under the ISC license.
|
|
799
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
800
|
+
*/const tL=[["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"}]],iy=se("layout-dashboard",tL);/**
|
|
801
|
+
* @license lucide-react v0.511.0 - ISC
|
|
802
|
+
*
|
|
803
|
+
* This source code is licensed under the ISC license.
|
|
804
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
805
|
+
*/const nL=[["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"}]],rL=se("lightbulb",nL);/**
|
|
806
|
+
* @license lucide-react v0.511.0 - ISC
|
|
807
|
+
*
|
|
808
|
+
* This source code is licensed under the ISC license.
|
|
809
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
810
|
+
*/const oL=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Pe=se("loader-circle",oL);/**
|
|
811
|
+
* @license lucide-react v0.511.0 - ISC
|
|
812
|
+
*
|
|
813
|
+
* This source code is licensed under the ISC license.
|
|
814
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
815
|
+
*/const sL=[["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"}]],ly=se("lock",sL);/**
|
|
816
|
+
* @license lucide-react v0.511.0 - ISC
|
|
817
|
+
*
|
|
818
|
+
* This source code is licensed under the ISC license.
|
|
819
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
820
|
+
*/const aL=[["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"}]],iL=se("log-in",aL);/**
|
|
821
|
+
* @license lucide-react v0.511.0 - ISC
|
|
822
|
+
*
|
|
823
|
+
* This source code is licensed under the ISC license.
|
|
824
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
825
|
+
*/const lL=[["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"}]],cy=se("log-out",lL);/**
|
|
826
|
+
* @license lucide-react v0.511.0 - ISC
|
|
827
|
+
*
|
|
828
|
+
* This source code is licensed under the ISC license.
|
|
829
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
830
|
+
*/const cL=[["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"}]],dL=se("map-pin",cL);/**
|
|
831
|
+
* @license lucide-react v0.511.0 - ISC
|
|
832
|
+
*
|
|
833
|
+
* This source code is licensed under the ISC license.
|
|
834
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
835
|
+
*/const uL=[["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"}]],Wc=se("memory-stick",uL);/**
|
|
836
|
+
* @license lucide-react v0.511.0 - ISC
|
|
837
|
+
*
|
|
838
|
+
* This source code is licensed under the ISC license.
|
|
839
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
840
|
+
*/const pL=[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]],fL=se("menu",pL);/**
|
|
841
|
+
* @license lucide-react v0.511.0 - ISC
|
|
842
|
+
*
|
|
843
|
+
* This source code is licensed under the ISC license.
|
|
844
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
845
|
+
*/const mL=[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]],rl=se("mic",mL);/**
|
|
846
|
+
* @license lucide-react v0.511.0 - ISC
|
|
847
|
+
*
|
|
848
|
+
* This source code is licensed under the ISC license.
|
|
849
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
850
|
+
*/const hL=[["path",{d:"M5 12h14",key:"1ays0h"}]],gL=se("minus",hL);/**
|
|
851
|
+
* @license lucide-react v0.511.0 - ISC
|
|
852
|
+
*
|
|
853
|
+
* This source code is licensed under the ISC license.
|
|
854
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
855
|
+
*/const bL=[["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"}]],xL=se("monitor",bL);/**
|
|
856
|
+
* @license lucide-react v0.511.0 - ISC
|
|
857
|
+
*
|
|
858
|
+
* This source code is licensed under the ISC license.
|
|
859
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
860
|
+
*/const yL=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],dy=se("moon",yL);/**
|
|
861
|
+
* @license lucide-react v0.511.0 - ISC
|
|
862
|
+
*
|
|
863
|
+
* This source code is licensed under the ISC license.
|
|
864
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
865
|
+
*/const vL=[["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"}]],wL=se("move",vL);/**
|
|
866
|
+
* @license lucide-react v0.511.0 - ISC
|
|
867
|
+
*
|
|
868
|
+
* This source code is licensed under the ISC license.
|
|
869
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
870
|
+
*/const NL=[["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"}]],on=se("network",NL);/**
|
|
871
|
+
* @license lucide-react v0.511.0 - ISC
|
|
872
|
+
*
|
|
873
|
+
* This source code is licensed under the ISC license.
|
|
874
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
875
|
+
*/const kL=[["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"}]],SL=se("octagon-alert",kL);/**
|
|
876
|
+
* @license lucide-react v0.511.0 - ISC
|
|
877
|
+
*
|
|
878
|
+
* This source code is licensed under the ISC license.
|
|
879
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
880
|
+
*/const CL=[["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"}]],uy=se("package",CL);/**
|
|
881
|
+
* @license lucide-react v0.511.0 - ISC
|
|
882
|
+
*
|
|
883
|
+
* This source code is licensed under the ISC license.
|
|
884
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
885
|
+
*/const ML=[["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"}]],Ao=se("pencil",ML);/**
|
|
886
|
+
* @license lucide-react v0.511.0 - ISC
|
|
887
|
+
*
|
|
888
|
+
* This source code is licensed under the ISC license.
|
|
889
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
890
|
+
*/const IL=[["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"}]],py=se("pin",IL);/**
|
|
891
|
+
* @license lucide-react v0.511.0 - ISC
|
|
892
|
+
*
|
|
893
|
+
* This source code is licensed under the ISC license.
|
|
894
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
895
|
+
*/const AL=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],va=se("play",AL);/**
|
|
896
|
+
* @license lucide-react v0.511.0 - ISC
|
|
897
|
+
*
|
|
898
|
+
* This source code is licensed under the ISC license.
|
|
899
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
900
|
+
*/const PL=[["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"}]],Yc=se("plug",PL);/**
|
|
901
|
+
* @license lucide-react v0.511.0 - ISC
|
|
902
|
+
*
|
|
903
|
+
* This source code is licensed under the ISC license.
|
|
904
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
905
|
+
*/const EL=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ut=se("plus",EL);/**
|
|
906
|
+
* @license lucide-react v0.511.0 - ISC
|
|
907
|
+
*
|
|
908
|
+
* This source code is licensed under the ISC license.
|
|
909
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
910
|
+
*/const $L=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],fy=se("power",$L);/**
|
|
911
|
+
* @license lucide-react v0.511.0 - ISC
|
|
912
|
+
*
|
|
913
|
+
* This source code is licensed under the ISC license.
|
|
914
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
915
|
+
*/const _L=[["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"}]],Es=se("puzzle",_L);/**
|
|
916
|
+
* @license lucide-react v0.511.0 - ISC
|
|
917
|
+
*
|
|
918
|
+
* This source code is licensed under the ISC license.
|
|
919
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
920
|
+
*/const DL=[["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"}]],LL=se("radar",DL);/**
|
|
921
|
+
* @license lucide-react v0.511.0 - ISC
|
|
922
|
+
*
|
|
923
|
+
* This source code is licensed under the ISC license.
|
|
924
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
925
|
+
*/const TL=[["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"}]],Zc=se("radio",TL);/**
|
|
926
|
+
* @license lucide-react v0.511.0 - ISC
|
|
927
|
+
*
|
|
928
|
+
* This source code is licensed under the ISC license.
|
|
929
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
930
|
+
*/const RL=[["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"}]],pt=se("refresh-cw",RL);/**
|
|
931
|
+
* @license lucide-react v0.511.0 - ISC
|
|
932
|
+
*
|
|
933
|
+
* This source code is licensed under the ISC license.
|
|
934
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
935
|
+
*/const OL=[["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"}]],my=se("rotate-ccw",OL);/**
|
|
936
|
+
* @license lucide-react v0.511.0 - ISC
|
|
937
|
+
*
|
|
938
|
+
* This source code is licensed under the ISC license.
|
|
939
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
940
|
+
*/const zL=[["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"}]],bt=se("rotate-cw",zL);/**
|
|
941
|
+
* @license lucide-react v0.511.0 - ISC
|
|
942
|
+
*
|
|
943
|
+
* This source code is licensed under the ISC license.
|
|
944
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
945
|
+
*/const BL=[["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"}]],FL=se("save",BL);/**
|
|
946
|
+
* @license lucide-react v0.511.0 - ISC
|
|
947
|
+
*
|
|
948
|
+
* This source code is licensed under the ISC license.
|
|
949
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
950
|
+
*/const jL=[["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"}]],Ze=se("scroll-text",jL);/**
|
|
951
|
+
* @license lucide-react v0.511.0 - ISC
|
|
952
|
+
*
|
|
953
|
+
* This source code is licensed under the ISC license.
|
|
954
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
955
|
+
*/const HL=[["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"}]],VL=se("search-x",HL);/**
|
|
956
|
+
* @license lucide-react v0.511.0 - ISC
|
|
957
|
+
*
|
|
958
|
+
* This source code is licensed under the ISC license.
|
|
959
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
960
|
+
*/const qL=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],hy=se("search",qL);/**
|
|
961
|
+
* @license lucide-react v0.511.0 - ISC
|
|
962
|
+
*
|
|
963
|
+
* This source code is licensed under the ISC license.
|
|
964
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
965
|
+
*/const QL=[["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"}]],sn=se("server",QL);/**
|
|
966
|
+
* @license lucide-react v0.511.0 - ISC
|
|
967
|
+
*
|
|
968
|
+
* This source code is licensed under the ISC license.
|
|
969
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
970
|
+
*/const UL=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Nt=se("settings",UL);/**
|
|
971
|
+
* @license lucide-react v0.511.0 - ISC
|
|
972
|
+
*
|
|
973
|
+
* This source code is licensed under the ISC license.
|
|
974
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
975
|
+
*/const KL=[["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"}]],br=se("shield-check",KL);/**
|
|
976
|
+
* @license lucide-react v0.511.0 - ISC
|
|
977
|
+
*
|
|
978
|
+
* This source code is licensed under the ISC license.
|
|
979
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
980
|
+
*/const GL=[["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"}]],WL=se("shield-x",GL);/**
|
|
981
|
+
* @license lucide-react v0.511.0 - ISC
|
|
982
|
+
*
|
|
983
|
+
* This source code is licensed under the ISC license.
|
|
984
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
985
|
+
*/const YL=[["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"}]],ZL=se("shield",YL);/**
|
|
986
|
+
* @license lucide-react v0.511.0 - ISC
|
|
987
|
+
*
|
|
988
|
+
* This source code is licensed under the ISC license.
|
|
989
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
990
|
+
*/const XL=[["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"}]],Uo=se("skull",XL);/**
|
|
991
|
+
* @license lucide-react v0.511.0 - ISC
|
|
992
|
+
*
|
|
993
|
+
* This source code is licensed under the ISC license.
|
|
994
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
995
|
+
*/const JL=[["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"}]],eT=se("sparkles",JL);/**
|
|
996
|
+
* @license lucide-react v0.511.0 - ISC
|
|
997
|
+
*
|
|
998
|
+
* This source code is licensed under the ISC license.
|
|
999
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1000
|
+
*/const tT=[["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"}]],gy=se("square-check-big",tT);/**
|
|
1001
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1002
|
+
*
|
|
1003
|
+
* This source code is licensed under the ISC license.
|
|
1004
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1005
|
+
*/const nT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Po=se("square",nT);/**
|
|
1006
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1007
|
+
*
|
|
1008
|
+
* This source code is licensed under the ISC license.
|
|
1009
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1010
|
+
*/const rT=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],si=se("star",rT);/**
|
|
1011
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1012
|
+
*
|
|
1013
|
+
* This source code is licensed under the ISC license.
|
|
1014
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1015
|
+
*/const oT=[["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"}]],sT=se("sun",oT);/**
|
|
1016
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1017
|
+
*
|
|
1018
|
+
* This source code is licensed under the ISC license.
|
|
1019
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1020
|
+
*/const aT=[["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"}]],iT=se("table-2",aT);/**
|
|
1021
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1022
|
+
*
|
|
1023
|
+
* This source code is licensed under the ISC license.
|
|
1024
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1025
|
+
*/const lT=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],by=se("terminal",lT);/**
|
|
1026
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1027
|
+
*
|
|
1028
|
+
* This source code is licensed under the ISC license.
|
|
1029
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1030
|
+
*/const cT=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],Ge=se("trash-2",cT);/**
|
|
1031
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1032
|
+
*
|
|
1033
|
+
* This source code is licensed under the ISC license.
|
|
1034
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1035
|
+
*/const dT=[["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"}]],xt=se("triangle-alert",dT);/**
|
|
1036
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1037
|
+
*
|
|
1038
|
+
* This source code is licensed under the ISC license.
|
|
1039
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1040
|
+
*/const uT=[["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"}]],Xc=se("upload",uT);/**
|
|
1041
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1042
|
+
*
|
|
1043
|
+
* This source code is licensed under the ISC license.
|
|
1044
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1045
|
+
*/const pT=[["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"}]],xy=se("users",pT);/**
|
|
1046
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1047
|
+
*
|
|
1048
|
+
* This source code is licensed under the ISC license.
|
|
1049
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1050
|
+
*/const fT=[["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"}]],yy=se("video",fT);/**
|
|
1051
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1052
|
+
*
|
|
1053
|
+
* This source code is licensed under the ISC license.
|
|
1054
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1055
|
+
*/const mT=[["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"}]],vy=se("wifi-off",mT);/**
|
|
1056
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1057
|
+
*
|
|
1058
|
+
* This source code is licensed under the ISC license.
|
|
1059
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1060
|
+
*/const hT=[["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"}]],Fn=se("wifi",hT);/**
|
|
1061
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1062
|
+
*
|
|
1063
|
+
* This source code is licensed under the ISC license.
|
|
1064
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1065
|
+
*/const gT=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ve=se("x",gT);/**
|
|
1066
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1067
|
+
*
|
|
1068
|
+
* This source code is licensed under the ISC license.
|
|
1069
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1070
|
+
*/const bT=[["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"}]],xT=se("wrench",bT);/**
|
|
1071
|
+
* @license lucide-react v0.511.0 - ISC
|
|
1072
|
+
*
|
|
1073
|
+
* This source code is licensed under the ISC license.
|
|
1074
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1075
|
+
*/const yT=[["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"}]],Jc=se("zap",yT);function vT(e){const t=Le();return Un({queryKey:["field-resolver",e?.capName??"<none>",e?.methodName??"<none>",e?.input??{}],enabled:!!e,queryFn:async()=>{if(!e)throw new Error("useFieldResolver: resolver is null (enabled guard should have prevented this)");const n=i=>i!==null&&(typeof i=="object"||typeof i=="function"),o=Reflect.get(t.trpcClient,e.capName);if(!n(o))throw new Error(`useFieldResolver: no cap namespace '${e.capName}' on the tRPC client`);const s=Reflect.get(o,e.methodName);if(!n(s))throw new Error(`useFieldResolver: no method '${e.methodName}' on cap '${e.capName}'`);const a=Reflect.get(s,"query");if(typeof a!="function")throw new Error(`useFieldResolver: '${e.capName}.${e.methodName}' has no .query() (resolvers must be query methods, not mutations)`);return await a(e.input??{})}})}function wT(e){return typeof e=="string"&&e.length>0&&e!=="undefined"&&e!=="null"}function NT(e={}){const t=ke(),n=Er(void 0,{staleTime:1e4,enabled:e.enabled??!0}),o=U(()=>(n.data??[]).filter(i=>wT(i.nodeId)),[n.data]),s=q(()=>{t.invalidateQueries({queryKey:["pipelineOrchestrator","listAgentSettings"]})},[t]);return{agents:o,isLoading:n.isLoading,isError:n.isError,error:n.error,refetch:()=>{n.refetch()},invalidate:s}}function kT({field:e,disabled:t}){const n=ke(),o=e.deviceId,s=vT(e.catalogResolver),a=yc({agentNodeId:e.nodeId}),i=wc({deviceId:o}),c=Cb({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),d=s.data,f=a.data??null,p=i.data??null,m=U(()=>d?CT(d,f,p):[],[d,f,p]),h=U(()=>{if(!f)return{};const g={};for(const[b,x]of Object.entries(f.addonDefaults))g[b]=x.enabled;return g},[f]);return s.error?u("div",{className:"text-xs text-red-400",children:["Failed to load pipeline catalog for ",r("code",{children:e.nodeId}),": ",String(s.error.message??s.error)]}):s.isLoading||!d||a.isLoading?u("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading pipeline for ",e.nodeId,"…"]}):u("div",{className:"col-span-full space-y-4",children:[u("div",{className:"flex items-center gap-2 text-[11px] text-foreground-subtle",children:["Agent: ",r("span",{className:"text-foreground",children:e.nodeId}),u("span",{className:"ml-2",children:["Engine: ",r("span",{className:"text-foreground font-mono",children:`${d.selectedEngine.runtime}/${d.selectedEngine.backend}`})]}),u("span",{className:"ml-auto text-[10px]",children:["Model + settings edited on Pipeline → ",e.nodeId,"."]})]}),r(sc,{schema:d,steps:m,onChange:()=>{},templates:[],selectedTemplateId:null,onSelectTemplate:()=>{},onSaveTemplate:()=>{},onUpdateTemplate:()=>{},onDeleteTemplate:()=>{},readOnly:t===!0,hideTemplates:!0,toggleMode:"threeState",hideModelAndSettings:!0,overrides:p?.stepToggles??{},onOverrideChange:(g,b)=>c.mutate({deviceId:o,addonId:g,enabled:b}),inheritedEnabledByAddon:h}),r(ST,{deviceId:o,currentAgentNodeId:e.nodeId,catalog:d,pipelineByAgent:p?.pipelineByAgent??{},disabled:t===!0})]})}function ST({deviceId:e,currentAgentNodeId:t,catalog:n,pipelineByAgent:o,disabled:s}){const a=ke(),[i,l]=_(!1),[c,d]=_(t),{agents:f}=NT({enabled:i}),p=Ab({deviceId:e,agentNodeId:c},{enabled:i}),h=Ib({onSuccess:()=>{a.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),a.invalidateQueries({queryKey:[["pipelineOrchestrator","resolvePipeline"]]})}}),g=o[c]??null,b=f,x=U(()=>g?MT(g.steps,n):[],[g,n]),v=w=>{const y=g?.audio??null;h.mutate({deviceId:e,agentNodeId:c,pipeline:{steps:IT(w),audio:y?{modelId:y.modelId,enabled:y.enabled}:null}})};return u("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("button",{type:"button",onClick:()=>l(w=>!w),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover",children:[i?r(wt,{className:"h-3 w-3"}):r(It,{className:"h-3 w-3"}),r("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:"Advanced — custom pipeline per agent"}),r("span",{className:"ml-auto text-[10px] text-foreground-subtle",children:Object.keys(o).length>0?`${Object.keys(o).length} override(s) active`:"None configured"})]}),i&&u("div",{className:"border-t border-border px-4 py-3 space-y-3",children:[u("div",{className:"flex items-center gap-2 text-xs",children:[r("span",{className:"text-foreground-subtle",children:"Agent:"}),u("select",{value:c,disabled:s,onChange:w=>d(w.target.value),className:"rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary",children:[typeof t=="string"&&t.length>0&&t!=="undefined"&&u("option",{value:t,children:[t," (current)"]}),b.filter(w=>w.nodeId!==t).map(w=>r("option",{value:w.nodeId,children:w.nodeId},w.nodeId))]}),o[c]&&u("button",{type:"button",onClick:()=>{window.confirm(`Remove custom pipeline override for ${c}? The camera will revert to the agent default + step toggles.`)&&h.mutate({deviceId:e,agentNodeId:c,pipeline:null})},disabled:s||h.isPending,className:"ml-auto inline-flex items-center gap-1 px-2 py-1 text-[11px] text-red-400 hover:bg-red-500/10 rounded disabled:opacity-50",children:[r(Ge,{className:"h-3 w-3"}),"Remove override"]})]}),g?r(sc,{schema:n,steps:x,onChange:v,templates:[],selectedTemplateId:null,onSelectTemplate:()=>{},onSaveTemplate:()=>{},onUpdateTemplate:()=>{},onDeleteTemplate:()=>{},readOnly:s,hideTemplates:!0}):u("div",{className:"text-xs text-foreground-subtle space-y-2",children:[u("p",{children:["No custom pipeline for ",r("code",{children:c}),". The camera uses the agent's default + step toggles."]}),r("button",{type:"button",onClick:()=>{const w=p.data;w&&h.mutate({deviceId:e,agentNodeId:c,pipeline:{steps:w.steps,audio:w.audio?{modelId:w.audio.modelId,enabled:w.audio.enabled}:null}})},disabled:s||h.isPending||!p.data,className:"inline-flex items-center gap-1 px-3 py-1.5 text-xs font-medium rounded bg-primary/15 text-primary hover:bg-primary/25 disabled:opacity-50",children:"Create wholesale override from current default"})]})]})]})}function CT(e,t,n){const o=d=>{for(const f of e.slots)for(const p of f.addons)if(p.id===d)return p;return null},s=d=>{const f=t?.addonDefaults[d.id],p=f?.enabled??d.enabledByDefault??!0,m=n?.stepToggles?.[d.id],h=m!==void 0?m:p;return{addonId:d.id,addonName:d.name,slot:d.slot,inputClasses:[...d.inputClasses],outputClasses:[...d.outputClasses],enabled:h,modelId:f?.modelId??d.defaultModelId,children:[],...f?.settings&&Object.keys(f.settings).length>0?{settings:f.settings}:{}}},a=new Map;for(const d of e.slots)for(const f of d.addons)a.set(f.id,s(f));const i=[],l=new Set;for(const[d,f]of a){const p=o(d);p&&p.inputClasses.length===0&&(i.push(f),l.add(d))}let c=!0;for(;c;){c=!1;for(const[d,f]of a){if(l.has(d))continue;const p=o(d);if(p)for(const[m,h]of a){if(m===d)continue;const g=o(m);if(g&&l.has(m)&&g.outputClasses.some(b=>p.inputClasses.includes(b))){h.children.push(f),l.add(d),c=!0;break}}}}return i}function MT(e,t){const n=new Map;for(const s of t.slots)for(const a of s.addons)n.set(a.id,a);const o=s=>{const a=n.get(s.addonId);return{addonId:s.addonId,addonName:a?.name??s.addonId,slot:a?.slot??"detector",inputClasses:a?.inputClasses?[...a.inputClasses]:[],outputClasses:a?.outputClasses?[...a.outputClasses]:[],enabled:s.enabled,modelId:s.modelId,children:(s.children??[]).map(o),...s.settings?{settings:{...s.settings}}:{}}};return[...e].map(o)}function IT(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 AT({tabs:e,active:t,onChange:n}){return r("div",{className:"flex rounded-lg border border-border bg-surface p-0.5 gap-0.5",children:e.map(o=>r("button",{type:"button",onClick:()=>n(o.id),className:["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",t===o.id?"bg-primary/12 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"].join(" "),children:o.label},o.id))})}function PT(e){const t=e.formats;if(!t)return"";const n=Object.values(t).filter(a=>a!==void 0&&a.sizeMB>0).map(a=>a.sizeMB);if(n.length===0)return"";const o=Math.min(...n),s=Math.max(...n);return o===s?`${o} MB`:`${o}-${s} MB`}function ET(e){return`${e.inputSize.width}x${e.inputSize.height}`}function $T(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function _T({entry:e,selected:t,onSelect:n,disabled:o}){const s=PT(e),a=ET(e),i=$T(e);return u("button",{type:"button",onClick:n,disabled:o,className:["w-full text-left rounded-lg border p-3 transition-all",t?"border-primary bg-primary/5 ring-1 ring-primary/30":"border-border bg-background hover:border-foreground-subtle/40 hover:bg-surface-hover/50",o?"opacity-50 cursor-not-allowed":"cursor-pointer"].join(" "),children:[r("div",{className:"flex items-start justify-between gap-2",children:u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-xs font-semibold text-foreground truncate",children:e.name}),t&&r(Mt,{className:"h-3.5 w-3.5 text-primary shrink-0"})]}),r("p",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-2",children:e.description})]})}),u("div",{className:"flex items-center gap-3 mt-2 flex-wrap",children:[u("span",{className:"inline-flex items-center gap-1 text-[10px] text-foreground-subtle",children:[r(dt,{className:"h-3 w-3"}),a]}),s&&r("span",{className:"text-[10px] text-foreground-subtle",children:s}),i.length>0&&r("div",{className:"flex gap-1",children:i.map(l=>r("span",{className:"text-[9px] uppercase rounded bg-surface border border-border px-1 py-0.5 text-foreground-subtle font-mono",children:l},l))}),e.labels.length>0&&u("span",{className:"text-[10px] text-foreground-subtle",children:[e.labels.length," label",e.labels.length!==1?"s":""]})]})]})}function DT({field:e,value:t,onChange:n,disabled:o}){const s=e.catalog??[],a=s.length>0,i=e.allowCustomPath!==!1||e.allowCustom===!0,l=[...a?[{id:"catalog",label:`Models (${s.length})`}]:[],...i?[{id:"custom",label:"Custom Path"}]:[]],[c,d]=_(a?"catalog":"custom"),f=t==null?"":String(t);return u("div",{className:"space-y-3",children:[l.length>1&&r(AT,{tabs:l,active:c,onChange:d}),c==="catalog"&&a&&r("div",{className:"space-y-1.5 max-h-[320px] overflow-y-auto pr-1",children:s.map(p=>r(_T,{entry:p,selected:f===p.id,onSelect:()=>n(p.id),disabled:o||e.disabled},p.id))}),c==="catalog"&&!a&&u("div",{className:"rounded-md border border-info/30 bg-info/5 px-3 py-2 flex items-start gap-2",children:[r(Ps,{className:"h-3.5 w-3.5 text-info shrink-0 mt-0.5"}),r("p",{className:"text-[11px] text-foreground-subtle leading-relaxed",children:"No predefined models available. Use the Custom Path tab to specify a model file path or URL."})]}),c==="custom"&&i&&u("div",{className:"space-y-2",children:[r("input",{type:"text",className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none disabled:opacity-50",placeholder:"Enter path like /data/models/custom.onnx or https://...",value:f,disabled:o||e.disabled,onChange:p=>n(p.target.value)}),e.acceptFormats&&e.acceptFormats.length>0&&u("p",{className:"text-[10px] text-foreground-subtle",children:["Accepted formats: ",e.acceptFormats.join(", ")]})]}),(e.compatibilityNote||e.conversionGuideUrl)&&u("div",{className:"flex items-start justify-between gap-3 pt-1",children:[e.compatibilityNote&&u("p",{className:"flex items-start gap-1 text-[10px] text-foreground-subtle",children:[r(Ps,{className:"h-3 w-3 mt-0.5 shrink-0"}),e.compatibilityNote]}),e.conversionGuideUrl&&u("a",{href:e.conversionGuideUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-[11px] text-primary hover:underline shrink-0",children:["How to convert your model",r(Gc,{className:"h-3 w-3"})]})]})]})}function wy(e){const t=Le();return Ex(t.trpcClient,e)}function LT({deviceId:e,deviceName:t,hasPTZ:n=!1,className:o}){const s=Le(),a=typeof window<"u"?window.location.origin:"",i=Number.isFinite(e),[l,c]=_(!1),d=i&&n&&l,f=St(s.trpcClient,i?e:null),p=ne(!1),{data:m,isLoading:h,isFetching:g,refetch:b}=Un({queryKey:["device",e,"snapshot.getSnapshot"],queryFn:()=>{const I=p.current;return p.current=!1,f?.snapshot?.getSnapshot({force:I})??null},enabled:!!f&&i,staleTime:5e3,retry:!1}),x=()=>{p.current=!0,b()},{streams:v,pipelineMetrics:w,createSession:y,sendAnswer:N,closeSession:k}=Lc(s.trpcClient,i?e:null),S=wy(i?e:null),M=Tc(s.trpcClient,i?e:0,{enabled:d}),P=m?`data:${m.contentType};base64,${m.base64}`:null;return r(Pc,{serverUrl:a,createSession:y,sendAnswer:N,closeSession:k,streams:v,pipelineMetrics:w,deviceName:t,phase:S.phase,detections:S,defaultShowDetections:!1,defaultShowMotion:!1,autoPlay:!1,showPlayStop:!0,snapshotSrc:P,snapshotLoading:h||g,onRefreshSnapshot:x,ptzAvailable:i&&n,ptzShown:d,onPtzToggle:()=>c(I=>!I),ptzOverlay:d?r(_c,{controls:M}):void 0,className:o})}function TT(){const e=dn(),t=ic();if(e===null)return null;const n=typeof t?.name=="string"?t.name:"",s=(t?.features??[]).includes(Tn.PanTiltZoom);return r(LT,{deviceId:e,deviceName:n,hasPTZ:s})}function yt(e,t){const n=Le(),o=ke(),[s,a]=_(n.connectionVersion);Z(()=>n.subscribeConnectionEvents((c,d)=>{c==="connected"&&a(d)}),[n]);const i=t.join("|"),l=JSON.stringify(e);Z(()=>{const c=[],d=()=>{const f=JSON.parse(l),m=f.length===1&&Array.isArray(f[0])?f:[f];o.invalidateQueries({queryKey:m})};d();for(const f of i.split("|"))if(f)try{c.push(n.subscribeEvent(f,d))}catch{}return()=>{for(const f of c)f()}},[n,o,i,l,s])}function Ko({icon:e,label:t,value:n,subtext:o,color:s}){return u("div",{className:"rounded-lg border border-border bg-surface p-2 sm:p-2.5 min-w-0",children:[u("div",{className:"flex items-center gap-1.5 mb-0.5 min-w-0",children:[r(e,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),r("span",{className:`${ks} uppercase tracking-wider whitespace-nowrap overflow-hidden text-ellipsis min-w-0`,children:t})]}),r("p",{className:`${s?`${Oi.replace("text-foreground","")} ${s}`:Oi} whitespace-nowrap overflow-hidden text-ellipsis`,children:n}),o&&r("p",{className:`${ks} mt-0.5 truncate`,children:o})]})}function Go({label:e,value:t,warning:n}){return u("div",{className:"min-w-0",children:[r("p",{className:`${ks} truncate`,children:e}),r("p",{className:`text-[11px] font-medium truncate ${n?"text-warning":"text-foreground"}`,children:t})]})}function Xt({label:e,value:t}){return u("div",{className:`${hm} flex items-start gap-2 sm:gap-3`,children:[r("span",{className:"w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle",children:e}),r("div",{className:"flex-1 min-w-0 text-[11px] text-foreground",children:t})]})}function RT(){const e=dn();yt(["pipelineOrchestrator","getPipelineAssignment"],["pipeline.camera-assigned","pipeline.camera-unassigned","pipeline.camera-updated"]),yt(["pipelineRunner","getCameraMetrics"],["pipeline.camera-metrics-snapshot"]);const{data:t}=la({deviceId:e??0},{enabled:e!==null,staleTime:3e4}),n=t?.agentNodeId??null,s=typeof n=="string"&&n.length>0&&!n.startsWith("addon:")?n:void 0,{data:a}=Nc({deviceId:e??0,...s?{nodeId:s}:{}},{enabled:e!==null,staleTime:2e3,retry:!1}),i=Le(),l=St(i.trpcClient,e),{data:c}=Un({queryKey:["device",e,"pipelineAnalytics.getActiveTracks"],queryFn:()=>l?.pipelineAnalytics?.getActiveTracks({})??[],enabled:!!l&&e!==null,refetchInterval:5e3,retry:!1});if(e===null)return null;const d=a?.phase??null,f=a?.detectionMode??null,p=Number(a?.actualFps??0),m=Number(a?.configuredFps??0),h=Number(a?.avgInferenceTimeMs??0),g=Number(a?.queueDepth??0),b=Number(a?.droppedFrames??0),x=Gn(d??"watching"),v=c?.length??0;return u("div",{className:"grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4 gap-2 sm:gap-3",children:[r(Ko,{icon:Mo,label:"Phase",value:x.label,color:x.textColor,subtext:f??void 0}),r(Ko,{icon:oy,label:"Detection FPS",value:`${p.toFixed(1)}`,subtext:m>0?`target: ${m}`:void 0}),r(Ko,{icon:dt,label:"Inference",value:`${h.toFixed(1)} ms`,subtext:g>0?`queue: ${g}`:void 0}),r(Ko,{icon:ya,label:"Active Tracks",value:String(v),subtext:b>0?`dropped: ${b}`:void 0})]})}function ai(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function OT(){const e=dn(),{data:t}=xc({deviceId:e??0},{enabled:e!==null,refetchInterval:5e3});if(e===null)return null;const n=t?.streams??{},o=Object.entries(n);return o.length===0?null:u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r("div",{className:"border-b border-border px-3 sm:px-4 py-2",children:r("h2",{className:"text-[11px] font-semibold text-foreground uppercase tracking-wider",children:"Stream Network"})}),r("div",{className:"divide-y divide-border",children:o.map(([s,a])=>u("div",{className:"px-3 sm:px-4 py-2",children:[u("div",{className:"flex items-center gap-1.5 mb-1.5",children:[r(Fn,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),r("span",{className:"text-[11px] font-medium text-foreground truncate",children:s})]}),u("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-2",children:[r(Go,{label:"Nominal",value:ai(a.nominalBitrateKbps??0)}),r(Go,{label:"Observed",value:ai(a.observedBitrateKbps??0)}),r(Go,{label:"Peak",value:ai(a.peakBitrateKbps??0)}),r(Go,{label:"Packet Loss",value:`${(a.packetLossPercent??0).toFixed(2)}%`,warning:(a.packetLossPercent??0)>1})]})]},s))})]})}const zT=3e4;function BT({field:e}){const t=dn(),n=e.type==="doorbell-recent"&&typeof e.historyLimit=="number"?e.historyLimit:10,o=Rc({deviceId:t??void 0,historyLimit:n});if(t===null)return null;const s=o.latest?Date.now()-o.latest.timestamp<zT:!1;return r(Dc,{history:o.history,latestIsFresh:s})}const FT={streaming:{icon:yy,label:"Streaming"},detection:{icon:ya,label:"Detection"},recording:{icon:ty,label:"Recording"},audio:{icon:rl,label:"Audio"},snapshot:{icon:hr,label:"Snapshot"},motion:{icon:Jc,label:"Motion"},ptz:{icon:Nt,label:"PTZ"},webrtc:{icon:Zc,label:"WebRTC"},onvif:{icon:ZL,label:"ONVIF"},analytics:{icon:dt,label:"Analytics"},"battery-operated":{icon:J_,label:"Battery"},"native-snapshot":{icon:hr,label:"Native Snapshot"},"pan-tilt-zoom":{icon:Nt,label:"PTZ"},"two-way-audio":{icon:rl,label:"Two-way Audio"},"doorbell-button":{icon:Io,label:"Doorbell"},rebootable:{icon:pt,label:"Rebootable"}},jT=ga;function wa({capabilities:e,showLabels:t=!1}){return r("div",{className:"flex items-center gap-1 flex-wrap",children:e.map(n=>{const o=FT[n],s=o?.icon??jT,a=o?.label??n;return u("span",{className:"inline-flex items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] text-foreground-subtle",title:a,children:[r(s,{className:"h-3 w-3"}),t&&r("span",{children:a})]},n)})})}const HT={frigate:{icon:Jx,color:"#3b82f6",label:"Frigate"},scrypted:{icon:sn,color:"#a855f7",label:"Scrypted"},reolink:{icon:Zc,color:"#06b6d4",label:"Reolink"},homeassistant:{icon:UD,color:"#22d3ee",label:"Home Assistant"},rtsp:{icon:Fn,color:"#78716c",label:"RTSP"},onvif:{icon:Fn,color:"#78716c",label:"ONVIF"}},_u={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"},VT={sm:"h-7 w-7",md:"h-8 w-8",lg:"h-10 w-10"};function Ny(e){const t=e.toLowerCase();return t.startsWith("provider-")?t.slice(9):t}function qT(e){const t=Ny(e);return HT[t]??{icon:Jx,color:"#78716c",label:e}}function QT(e){const t=Ny(e);return`/api/addon-assets/${e.toLowerCase().startsWith("provider-")?e:`provider-${t}`}/assets/icon.svg`}function an({type:e,size:t="md",showLabel:n}){const o=qT(e),s=o.icon,[a,i]=_(!1),l=QT(e);return u("div",{className:"flex items-center gap-2",children:[r("div",{className:`flex items-center justify-center rounded-lg ${VT[t]}`,style:{backgroundColor:`${o.color}15`},children:a?r(s,{className:_u[t],style:{color:o.color}}):r("img",{src:l,alt:o.label,className:_u[t],onError:()=>i(!0)})}),n&&r("span",{className:"text-xs font-medium text-foreground-subtle",children:o.label})]})}function UT({deviceId:e,initialName:t}){const n=ke(),[o,s]=_(!1),[a,i]=_(t),[l,c]=_(!1),d=ne(null);Z(()=>{o||i(t)},[t,o]),Z(()=>{o&&d.current?.focus()},[o]);const f=xg({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDevice"]]}),n.invalidateQueries({queryKey:[["deviceManager","listAll"]]}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]})}}),p=async()=>{const h=a.trim();if(h.length===0||h===t){s(!1),i(t);return}c(!0);try{await f.mutateAsync({deviceId:e,name:h}),s(!1)}catch{}finally{c(!1)}},m=()=>{i(t),s(!1)};return o?r(Xt,{label:"Name",value:u("div",{className:"flex items-center gap-1",children:[r("input",{ref:d,type:"text",value:a,onChange:h=>i(h.target.value),onKeyDown:h=>{h.key==="Enter"?p():h.key==="Escape"&&m()},disabled:l,className:"flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary"}),r("button",{type:"button",onClick:()=>void p(),disabled:l,className:"p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50","aria-label":"Save",children:r(Mt,{className:"h-3 w-3"})}),r("button",{type:"button",onClick:m,disabled:l,className:"p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50","aria-label":"Cancel",children:r(Ve,{className:"h-3 w-3"})})]})}):r(Xt,{label:"Name",value:u("div",{className:"flex items-center gap-2 group",children:[r("span",{className:"truncate",children:t}),r("button",{type:"button",onClick:()=>s(!0),className:"opacity-0 group-hover:opacity-100 transition-opacity p-0.5 rounded hover:bg-surface-hover","aria-label":"Edit name",children:r(Ao,{className:"h-3 w-3 text-foreground-subtle"})})]})})}function KT({deviceId:e,initialLocation:t}){const n=ke(),[o,s]=_(!1),[a,i]=_(t??""),[l,c]=_(!1),d=ne(null),{data:f}=vg(void 0,{staleTime:3e4,enabled:o}),p=f??[];Z(()=>{o||i(t??"")},[t,o]),Z(()=>{o&&d.current?.focus()},[o]);const m=yg({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDevice"]]}),n.invalidateQueries({queryKey:[["deviceManager","listAll"]]}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]}),n.invalidateQueries({queryKey:[["deviceManager","listLocations"]]})}}),h=U(()=>{const v=a.trim().toLowerCase();return v.length===0?p:p.filter(w=>w.toLowerCase()!==v&&w.toLowerCase().includes(v))},[p,a]),g=a.trim().length>0&&!p.some(v=>v.toLowerCase()===a.trim().toLowerCase()),b=async v=>{const y=(v??a).trim(),N=y.length===0?null:y;if(N===(t??null)){s(!1);return}c(!0);try{await m.mutateAsync({deviceId:e,location:N}),s(!1)}catch{}finally{c(!1)}},x=()=>{i(t??""),s(!1)};return o?r(Xt,{label:"Location",value:u("div",{className:"relative",children:[u("div",{className:"flex items-center gap-1",children:[r("input",{ref:d,type:"text",value:a,onChange:v=>i(v.target.value),onKeyDown:v=>{v.key==="Enter"?b():v.key==="Escape"&&x()},disabled:l,placeholder:"Room / area (or leave empty to clear)",className:"flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary"}),r("button",{type:"button",onClick:()=>void b(),disabled:l,className:"p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50","aria-label":"Save",children:r(Mt,{className:"h-3 w-3"})}),r("button",{type:"button",onClick:x,disabled:l,className:"p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50","aria-label":"Cancel",children:r(Ve,{className:"h-3 w-3"})})]}),(h.length>0||g)&&u("div",{className:"absolute z-10 left-0 right-0 mt-0.5 max-h-40 overflow-y-auto rounded-md border border-border bg-surface shadow-md",children:[h.map(v=>u("button",{type:"button",onClick:()=>{i(v),b(v)},className:"w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover",children:[r(dL,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),r("span",{className:"truncate",children:v})]},v)),g&&u("button",{type:"button",onClick:()=>void b(),className:"w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover border-t border-border",children:[r("span",{className:"text-foreground-subtle",children:"Create"}),u("span",{className:"font-medium truncate",children:['"',a.trim(),'"']})]})]})]})}):r(Xt,{label:"Location",value:u("div",{className:"flex items-center gap-2 group",children:[t?r("span",{className:"truncate",children:t}):r("span",{className:"italic text-foreground-subtle",children:"unset"}),r("button",{type:"button",onClick:()=>s(!0),className:"opacity-0 group-hover:opacity-100 transition-opacity p-0.5 rounded hover:bg-surface-hover","aria-label":"Edit location",children:r(Ao,{className:"h-3 w-3 text-foreground-subtle"})})]})})}const Du=["manufacturer","model","hardware","firmware","serialNumber","uid","mac","itemNo"];function GT(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}function WT(e){return e==null?"—":typeof e=="string"||typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e)}function ky(){const e=dn(),t=ic(),{data:n}=Bn({deviceId:e??0},{enabled:e!==null,staleTime:3e4}),o=n??t??null,[s,a]=_("identity");if(e===null||!o)return null;const i=String(o.stableId??""),l=String(o.name??""),c=String(o.type??""),d=String(o.addonId??""),f=o.features??[],p=o.location??null,m=o.metadata??null,h=m!==null&&Object.keys(m).length>0;return u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3",children:[r("h2",{className:"text-[11px] font-semibold text-foreground uppercase tracking-wider",children:"Device Info"}),h&&u("div",{className:"flex items-center gap-1 rounded-md bg-surface-hover p-0.5",children:[r(Lu,{active:s==="identity",onClick:()=>a("identity"),label:"Identity"}),r(Lu,{active:s==="hardware",onClick:()=>a("hardware"),label:"Hardware"})]})]}),(!h||s==="identity")&&u("div",{className:"divide-y divide-border",children:[r(Xt,{label:"ID",value:u("span",{className:"font-mono text-[11px] text-foreground",children:[`#${e}`,u("span",{className:"ml-1.5 text-foreground-subtle",children:["(",i,")"]})]})}),r(UT,{deviceId:e,initialName:l}),r(KT,{deviceId:e,initialLocation:p}),r(Xt,{label:"Type",value:c}),r(Xt,{label:"Provider",value:r(an,{type:d,size:"sm",showLabel:!0})}),r(Xt,{label:"Capabilities",value:f.length>0?r(wa,{capabilities:f,showLabels:!0}):r("span",{className:"text-[11px] text-foreground-subtle",children:"None"})})]}),h&&s==="hardware"&&r(YT,{metadata:m})]})}function Lu({active:e,onClick:t,label:n}){return r("button",{type:"button",onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${e?"bg-surface text-foreground shadow-sm":"text-foreground-subtle hover:text-foreground"}`,children:n})}function YT({metadata:e}){const t=Du.filter(s=>s in e),n=Object.keys(e).filter(s=>!Du.includes(s)).sort(),o=[...t,...n];return u("div",{children:[r("div",{className:"px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border bg-surface-subtle/40",children:"Auto-populated by the driver on every connect. Read-only."}),r("div",{className:"divide-y divide-border",children:o.map(s=>r(Xt,{label:GT(s),value:r("span",{className:"font-mono text-[11px] text-foreground break-all",children:WT(e[s])})},s))})]})}function ol(e){try{const t=e.split(".");if(t.length<2||!t[1])return null;const n=JSON.parse(atob(t[1]));return{id:String(n.userId??""),username:String(n.username??"unknown"),role:String(n.role??"viewer"),exp:Number(n.exp??0)}}catch{return null}}function ZT(e){const t=ol(e);return t?t.exp*1e3<Date.now():!0}const XT="changeme",Sy=Oe(null);function JT({children:e}){const[t,n]=_(null),[o,s]=_(!0),[a,i]=_(!1);Z(()=>{if(typeof window<"u"&&window.location.hash.startsWith("#token=")){const b=new URLSearchParams(window.location.hash.slice(1)).get("token");b&&(localStorage.setItem("camstack_admin_token",b),window.history.replaceState({},"","/admin"))}const f=localStorage.getItem("camstack_admin_token");if(!f){s(!1);return}if(ZT(f)){localStorage.removeItem("camstack_admin_token"),s(!1);return}const p=ol(f);if(!p){localStorage.removeItem("camstack_admin_token"),s(!1);return}tl().trpcClient.system.info.query().then(()=>n(p)).catch(g=>{const b=g?.data?.code;b==="UNAUTHORIZED"||b==="FORBIDDEN"?(localStorage.removeItem("camstack_admin_token"),Wr()):n(p)}).finally(()=>s(!1))},[]);const l=q(async(f,p)=>{const g=(await tl().login(f,p)).token;localStorage.setItem("camstack_admin_token",g),Wr(),n(ol(g)),i(p===XT)},[]),c=q(()=>{localStorage.removeItem("camstack_admin_token"),Wr(),n(null),i(!1)},[]),d=q(()=>{i(!1)},[]);return r(Sy.Provider,{value:{user:t,loading:o,mustChangePassword:a,login:l,logout:c,clearMustChangePassword:d},children:e})}function Lr(){const e=ve(Sy);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}function Bt({children:e,requiredRole:t}){const{user:n,loading:o,mustChangePassword:s}=Lr(),a=ht();return o?r("div",{className:"flex h-screen items-center justify-center bg-background text-foreground-subtle",children:"Loading..."}):n?s&&a.pathname!=="/change-password"?r(gt,{to:"/change-password",replace:!0}):t==="admin"&&n.role!=="admin"&&n.role!=="super_admin"?r(gt,{to:"/access-denied",replace:!0}):r(xe,{children:e}):r(gt,{to:"/login",replace:!0})}var ii={};const Ce=e=>typeof e=="string",Br=()=>{let e,t;const n=new Promise((o,s)=>{e=o,t=s});return n.resolve=e,n.reject=t,n},Tu=e=>e==null?"":""+e,eR=(e,t,n)=>{e.forEach(o=>{t[o]&&(n[o]=t[o])})},tR=/###/g,Ru=e=>e&&e.indexOf("###")>-1?e.replace(tR,"."):e,Ou=e=>!e||Ce(e),Zr=(e,t,n)=>{const o=Ce(t)?t.split("."):t;let s=0;for(;s<o.length-1;){if(Ou(e))return{};const a=Ru(o[s]);!e[a]&&n&&(e[a]=new n),Object.prototype.hasOwnProperty.call(e,a)?e=e[a]:e={},++s}return Ou(e)?{}:{obj:e,k:Ru(o[s])}},zu=(e,t,n)=>{const{obj:o,k:s}=Zr(e,t,Object);if(o!==void 0||t.length===1){o[s]=n;return}let a=t[t.length-1],i=t.slice(0,t.length-1),l=Zr(e,i,Object);for(;l.obj===void 0&&i.length;)a=`${i[i.length-1]}.${a}`,i=i.slice(0,i.length-1),l=Zr(e,i,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},nR=(e,t,n,o)=>{const{obj:s,k:a}=Zr(e,t,Object);s[a]=s[a]||[],s[a].push(n)},$s=(e,t)=>{const{obj:n,k:o}=Zr(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,o))return n[o]},rR=(e,t,n)=>{const o=$s(e,n);return o!==void 0?o:$s(t,n)},Cy=(e,t,n)=>{for(const o in t)o!=="__proto__"&&o!=="constructor"&&(o in e?Ce(e[o])||e[o]instanceof String||Ce(t[o])||t[o]instanceof String?n&&(e[o]=t[o]):Cy(e[o],t[o],n):e[o]=t[o]);return e},En=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var oR={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const sR=e=>Ce(e)?e.replace(/[&<>"'\/]/g,t=>oR[t]):e;class aR{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const n=this.regExpMap.get(t);if(n!==void 0)return n;const o=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,o),this.regExpQueue.push(t),o}}const iR=[" ",",","?","!",";"],lR=new aR(20),cR=(e,t,n)=>{t=t||"",n=n||"";const o=iR.filter(i=>t.indexOf(i)<0&&n.indexOf(i)<0);if(o.length===0)return!0;const s=lR.getRegExp(`(${o.map(i=>i==="?"?"\\?":i).join("|")})`);let a=!s.test(e);if(!a){const i=e.indexOf(n);i>0&&!s.test(e.substring(0,i))&&(a=!0)}return a},sl=(e,t,n=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;const o=t.split(n);let s=e;for(let a=0;a<o.length;){if(!s||typeof s!="object")return;let i,l="";for(let c=a;c<o.length;++c)if(c!==a&&(l+=n),l+=o[c],i=s[l],i!==void 0){if(["string","number","boolean"].indexOf(typeof i)>-1&&c<o.length-1)continue;a+=c-a+1;break}s=i}return s},co=e=>e?.replace(/_/g,"-"),dR={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 _s{constructor(t,n={}){this.init(t,n)}init(t,n={}){this.prefix=n.prefix||"i18next:",this.logger=t||dR,this.options=n,this.debug=n.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,o,s){return s&&!this.debug?null:(Ce(t[0])&&(t[0]=`${o}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new _s(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new _s(this.logger,t)}}var Vt=new _s;class Na{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(o=>{this.observers[o]||(this.observers[o]=new Map);const s=this.observers[o].get(n)||0;this.observers[o].set(n,s+1)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t].delete(n)}}emit(t,...n){this.observers[t]&&Array.from(this.observers[t].entries()).forEach(([s,a])=>{for(let i=0;i<a;i++)s(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,a])=>{for(let i=0;i<a;i++)s.apply(s,[t,...n])})}}class Bu extends Na{constructor(t,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,o,s={}){const a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,i=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.indexOf(".")>-1?l=t.split("."):(l=[t,n],o&&(Array.isArray(o)?l.push(...o):Ce(o)&&a?l.push(...o.split(a)):l.push(o)));const c=$s(this.data,l);return!c&&!n&&!o&&t.indexOf(".")>-1&&(t=l[0],n=l[1],o=l.slice(2).join(".")),c||!i||!Ce(o)?c:sl(this.data?.[t]?.[n],o,a)}addResource(t,n,o,s,a={silent:!1}){const i=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let l=[t,n];o&&(l=l.concat(i?o.split(i):o)),t.indexOf(".")>-1&&(l=t.split("."),s=n,n=l[1]),this.addNamespaces(n),zu(this.data,l,s),a.silent||this.emit("added",t,n,o,s)}addResources(t,n,o,s={silent:!1}){for(const a in o)(Ce(o[a])||Array.isArray(o[a]))&&this.addResource(t,n,a,o[a],{silent:!0});s.silent||this.emit("added",t,n,o)}addResourceBundle(t,n,o,s,a,i={silent:!1,skipCopy:!1}){let l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),s=o,o=n,n=l[1]),this.addNamespaces(n);let c=$s(this.data,l)||{};i.skipCopy||(o=JSON.parse(JSON.stringify(o))),s?Cy(c,o,a):c={...c,...o},zu(this.data,l,c),i.silent||this.emit("added",t,n,o)}removeResourceBundle(t,n){this.hasResourceBundle(t,n)&&delete this.data[t][n],this.removeNamespaces(n),this.emit("removed",t,n)}hasResourceBundle(t,n){return this.getResource(t,n)!==void 0}getResourceBundle(t,n){return n||(n=this.options.defaultNS),this.getResource(t,n)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const n=this.getDataByLanguage(t);return!!(n&&Object.keys(n)||[]).find(s=>n[s]&&Object.keys(n[s]).length>0)}toJSON(){return this.data}}var My={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,o,s){return e.forEach(a=>{t=this.processors[a]?.process(t,n,o,s)??t}),t}};const Iy=Symbol("i18next/PATH_KEY");function uR(){const e=[],t=Object.create(null);let n;return t.get=(o,s)=>(n?.revoke?.(),s===Iy?e:(e.push(s),n=Proxy.revocable(o,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function cr(e,t){const{[Iy]:n}=e(uR()),o=t?.keySeparator??".",s=t?.nsSeparator??":";if(n.length>1&&s){const a=t?.ns,i=Array.isArray(a)?a:null;if(i&&i.length>1&&i.slice(1).includes(n[0]))return`${n[0]}${s}${n.slice(1).join(o)}`}return n.join(o)}const Fu={},li=e=>!Ce(e)&&typeof e!="boolean"&&typeof e!="number";class Ds extends Na{constructor(t,n={}){super(),eR(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Vt.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t,n={interpolation:{}}){const o={...n};if(t==null)return!1;const s=this.resolve(t,o);if(s?.res===void 0)return!1;const a=li(s.res);return!(o.returnObjects===!1&&a)}extractFromKey(t,n){let o=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");const s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const i=o&&t.indexOf(o)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!cR(t,o,s);if(i&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:Ce(a)?[a]:a};const d=t.split(o);(o!==s||o===s&&this.options.ns.indexOf(d[0])>-1)&&(a=d.shift()),t=d.join(s)}return{key:t,namespaces:Ce(a)?[a]:a}}translate(t,n,o){let s=typeof n=="object"?{...n}:n;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof s=="object"&&(s={...s}),s||(s={}),t==null)return"";typeof t=="function"&&(t=cr(t,{...this.options,...s})),Array.isArray(t)||(t=[String(t)]),t=t.map(R=>typeof R=="function"?cr(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 f=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;f===void 0&&(f=":");const p=s.lng||this.language,m=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p?.toLowerCase()==="cimode")return m?a?{res:`${d}${f}${l}`,usedKey:l,exactUsedKey:l,usedLng:p,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:`${d}${f}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:p,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:l;const h=this.resolve(t,s);let g=h?.res;const b=h?.usedKey||l,x=h?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],w=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,N=s.count!==void 0&&!Ce(s.count),k=Ds.hasDefaultValue(s),S=N?this.pluralResolver.getSuffix(p,s.count,s):"",M=s.ordinal&&N?this.pluralResolver.getSuffix(p,s.count,{ordinal:!1}):"",P=N&&!s.ordinal&&s.count===0,I=P&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${S}`]||s[`defaultValue${M}`]||s.defaultValue;let z=g;y&&!g&&k&&(z=I);const $=li(z),O=Object.prototype.toString.apply(z);if(y&&z&&$&&v.indexOf(O)<0&&!(Ce(w)&&Array.isArray(z))){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const R=this.options.returnedObjectHandler?this.options.returnedObjectHandler(b,z,{...s,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(h.res=R,h.usedParams=this.getUsedParamsDetails(s),h):R}if(i){const R=Array.isArray(z),A=R?[]:{},L=R?x:b;for(const D in z)if(Object.prototype.hasOwnProperty.call(z,D)){const T=`${L}${i}${D}`;k&&!g?A[D]=this.translate(T,{...s,defaultValue:li(I)?I[D]:void 0,joinArrays:!1,ns:c}):A[D]=this.translate(T,{...s,joinArrays:!1,ns:c}),A[D]===T&&(A[D]=z[D])}g=A}}else if(y&&Ce(w)&&Array.isArray(g))g=g.join(w),g&&(g=this.extendTranslation(g,t,s,o));else{let R=!1,A=!1;!this.isValidLookup(g)&&k&&(R=!0,g=I),this.isValidLookup(g)||(A=!0,g=l);const D=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&A?void 0:g,T=k&&I!==g&&this.options.updateMissing;if(A||R||T){if(this.logger.log(T?"updateKey":"missingKey",p,d,l,T?I:g),i){const H=this.resolve(l,{...s,keySeparator:!1});H&&H.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let B=[];const F=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&F&&F[0])for(let H=0;H<F.length;H++)B.push(F[H]);else this.options.saveMissingTo==="all"?B=this.languageUtils.toResolveHierarchy(s.lng||this.language):B.push(s.lng||this.language);const j=(H,E,Q)=>{const K=k&&Q!==g?Q:D;this.options.missingKeyHandler?this.options.missingKeyHandler(H,d,E,K,T,s):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(H,d,E,K,T,s),this.emit("missingKey",H,d,E,g)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?B.forEach(H=>{const E=this.pluralResolver.getSuffixes(H,s);P&&s[`defaultValue${this.options.pluralSeparator}zero`]&&E.indexOf(`${this.options.pluralSeparator}zero`)<0&&E.push(`${this.options.pluralSeparator}zero`),E.forEach(Q=>{j([H],l+Q,s[`defaultValue${Q}`]||I)})}):j(B,l,I))}g=this.extendTranslation(g,t,s,h,o),A&&g===l&&this.options.appendNamespaceToMissingKey&&(g=`${d}${f}${l}`),(A||R)&&this.options.parseMissingKeyHandler&&(g=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${f}${l}`:l,R?g:void 0,s))}return a?(h.res=g,h.usedParams=this.getUsedParamsDetails(s),h):g}extendTranslation(t,n,o,s,a){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...o},o.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!o.skipInterpolation){o.interpolation&&this.interpolator.init({...o,interpolation:{...this.options.interpolation,...o.interpolation}});const c=Ce(t)&&(o?.interpolation?.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(c){const p=t.match(this.interpolator.nestingRegexp);d=p&&p.length}let f=o.replace&&!Ce(o.replace)?o.replace:o;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),t=this.interpolator.interpolate(t,f,o.lng||this.language||s.usedLng,o),c){const p=t.match(this.interpolator.nestingRegexp),m=p&&p.length;d<m&&(o.nest=!1)}!o.lng&&s&&s.res&&(o.lng=this.language||s.usedLng),o.nest!==!1&&(t=this.interpolator.nest(t,(...p)=>a?.[0]===p[0]&&!o.context?(this.logger.warn(`It seems you are nesting recursively key: ${p[0]} in key: ${n[0]}`),null):this.translate(...p,n),o)),o.interpolation&&this.interpolator.reset()}const i=o.postProcess||this.options.postProcess,l=Ce(i)?[i]:i;return t!=null&&l?.length&&o.applyPostProcessor!==!1&&(t=My.handle(l,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(o)},...o}:o,this)),t}resolve(t,n={}){let o,s,a,i,l;return Ce(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(c=>typeof c=="function"?cr(c,{...this.options,...n}):c)),t.forEach(c=>{if(this.isValidLookup(o))return;const d=this.extractFromKey(c,n),f=d.key;s=f;let p=d.namespaces;this.options.fallbackNS&&(p=p.concat(this.options.fallbackNS));const m=n.count!==void 0&&!Ce(n.count),h=m&&!n.ordinal&&n.count===0,g=n.context!==void 0&&(Ce(n.context)||typeof n.context=="number")&&n.context!=="",b=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);p.forEach(x=>{this.isValidLookup(o)||(l=x,!Fu[`${b[0]}-${x}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(Fu[`${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(v=>{if(this.isValidLookup(o))return;i=v;const w=[f];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(w,f,v,x,n);else{let N;m&&(N=this.pluralResolver.getSuffix(v,n.count,n));const k=`${this.options.pluralSeparator}zero`,S=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&N.indexOf(S)===0&&w.push(f+N.replace(S,this.options.pluralSeparator)),w.push(f+N),h&&w.push(f+k)),g){const M=`${f}${this.options.contextSeparator||"_"}${n.context}`;w.push(M),m&&(n.ordinal&&N.indexOf(S)===0&&w.push(M+N.replace(S,this.options.pluralSeparator)),w.push(M+N),h&&w.push(M+k))}}let y;for(;y=w.pop();)this.isValidLookup(o)||(a=y,o=this.getResource(v,x,y,n))}))})}),{res:o,usedKey:s,exactUsedKey:a,usedLng:i,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,o,s={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,n,o,s):this.resourceStore.getResource(t,n,o,s)}getUsedParamsDetails(t={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],o=t.replace&&!Ce(t.replace);let s=o?t.replace:t;if(o&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!o){s={...s};for(const a of n)delete s[a]}return s}static hasDefaultValue(t){const n="defaultValue";for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&n===o.substring(0,n.length)&&t[o]!==void 0)return!0;return!1}}class ju{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Vt.create("languageUtils")}getScriptPartFromCode(t){if(t=co(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=co(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(Ce(t)&&t.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(t)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(o=>{if(n)return;const s=this.formatLanguageCode(o);(!this.options.supportedLngs||this.isSupportedCode(s))&&(n=s)}),!n&&this.options.supportedLngs&&t.forEach(o=>{if(n)return;const s=this.getScriptPartFromCode(o);if(this.isSupportedCode(s))return n=s;const a=this.getLanguagePartFromCode(o);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(i=>{if(i===a)return i;if(!(i.indexOf("-")<0&&a.indexOf("-")<0)&&(i.indexOf("-")>0&&a.indexOf("-")<0&&i.substring(0,i.indexOf("-"))===a||i.indexOf(a)===0&&a.length>1))return i})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),Ce(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let o=t[n];return o||(o=t[this.getScriptPartFromCode(n)]),o||(o=t[this.formatLanguageCode(n)]),o||(o=t[this.getLanguagePartFromCode(n)]),o||(o=t.default),o||[]}toResolveHierarchy(t,n){const o=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],t),s=[],a=i=>{i&&(this.isSupportedCode(i)?s.push(i):this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`))};return Ce(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(t))):Ce(t)&&a(this.formatLanguageCode(t)),o.forEach(i=>{s.indexOf(i)<0&&a(this.formatLanguageCode(i))}),s}}const Hu={zero:0,one:1,two:2,few:3,many:4,other:5},Vu={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class pR{constructor(t,n={}){this.languageUtils=t,this.options=n,this.logger=Vt.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,n={}){const o=co(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:o,type:s});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let i;try{i=new Intl.PluralRules(o,{type:s})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),Vu;if(!t.match(/-|_/))return Vu;const c=this.languageUtils.getLanguagePartFromCode(t);i=this.getRule(c,n)}return this.pluralRulesCache[a]=i,i}needsPlural(t,n={}){let o=this.getRule(t,n);return o||(o=this.getRule("dev",n)),o?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,n,o={}){return this.getSuffixes(t,o).map(s=>`${n}${s}`)}getSuffixes(t,n={}){let o=this.getRule(t,n);return o||(o=this.getRule("dev",n)),o?o.resolvedOptions().pluralCategories.sort((s,a)=>Hu[s]-Hu[a]).map(s=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(t,n,o={}){const s=this.getRule(t,o);return s?`${this.options.prepend}${o.ordinal?`ordinal${this.options.prepend}`:""}${s.select(n)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",n,o))}}const qu=(e,t,n,o=".",s=!0)=>{let a=rR(e,t,n);return!a&&s&&Ce(n)&&(a=sl(e,n,o),a===void 0&&(a=sl(t,n,o))),a},ci=e=>e.replace(/\$/g,"$$$$");class Qu{constructor(t={}){this.logger=Vt.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(n=>n),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});const{escape:n,escapeValue:o,useRawValueToEscape:s,prefix:a,prefixEscaped:i,suffix:l,suffixEscaped:c,formatSeparator:d,unescapeSuffix:f,unescapePrefix:p,nestingPrefix:m,nestingPrefixEscaped:h,nestingSuffix:g,nestingSuffixEscaped:b,nestingOptionsSeparator:x,maxReplaces:v,alwaysFormat:w}=t.interpolation;this.escape=n!==void 0?n:sR,this.escapeValue=o!==void 0?o:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=a?En(a):i||"{{",this.suffix=l?En(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=f?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=m?En(m):h||En("$t("),this.nestingSuffix=g?En(g):b||En(")"),this.nestingOptionsSeparator=x||",",this.maxReplaces=v||1e3,this.alwaysFormat=w!==void 0?w:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,o)=>n?.source===o?(n.lastIndex=0,n):new RegExp(o,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,n,o,s){let a,i,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=h=>{if(h.indexOf(this.formatSeparator)<0){const v=qu(n,c,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,o,{...s,...n,interpolationkey:h}):v}const g=h.split(this.formatSeparator),b=g.shift().trim(),x=g.join(this.formatSeparator).trim();return this.format(qu(n,c,b,this.options.keySeparator,this.options.ignoreJSONStructure),x,o,{...s,...n,interpolationkey:b})};this.resetRegExp();const f=s?.missingInterpolationHandler||this.options.missingInterpolationHandler,p=s?.interpolation?.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>ci(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?ci(this.escape(h)):ci(h)}].forEach(h=>{for(l=0;a=h.regex.exec(t);){const g=a[1].trim();if(i=d(g),i===void 0)if(typeof f=="function"){const x=f(t,a,s);i=Ce(x)?x:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))i="";else if(p){i=a[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),i="";else!Ce(i)&&!this.useRawValueToEscape&&(i=Tu(i));const b=h.safeValue(i);if(t=t.replace(a[0],b),p?(h.regex.lastIndex+=i.length,h.regex.lastIndex-=a[0].length):h.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n,o={}){let s,a,i;const l=(c,d)=>{const f=this.nestingOptionsSeparator;if(c.indexOf(f)<0)return c;const p=c.split(new RegExp(`${En(f)}[ ]*{`));let m=`{${p[1]}`;c=p[0],m=this.interpolate(m,i);const h=m.match(/'/g),g=m.match(/"/g);((h?.length??0)%2===0&&!g||(g?.length??0)%2!==0)&&(m=m.replace(/'/g,'"'));try{i=JSON.parse(m),d&&(i={...d,...i})}catch(b){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,b),`${c}${f}${m}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];i={...o},i=i.replace&&!Ce(i.replace)?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;const d=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(d!==-1&&(c=s[1].slice(d).split(this.formatSeparator).map(f=>f.trim()).filter(Boolean),s[1]=s[1].slice(0,d)),a=n(l.call(this,s[1].trim(),i),i),a&&s[0]===t&&!Ce(a))return a;Ce(a)||(a=Tu(a)),a||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),a=""),c.length&&(a=c.reduce((f,p)=>this.format(f,p,o.lng,{...o,interpolationkey:s[1].trim()}),a.trim())),t=t.replace(s[0],a),this.regexp.lastIndex=0}return t}}const fR=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const o=e.split("(");t=o[0].toLowerCase().trim();const s=o[1].substring(0,o[1].length-1);t==="currency"&&s.indexOf(":")<0?n.currency||(n.currency=s.trim()):t==="relativetime"&&s.indexOf(":")<0?n.range||(n.range=s.trim()):s.split(";").forEach(i=>{if(i){const[l,...c]=i.split(":"),d=c.join(":").trim().replace(/^'+|'+$/g,""),f=l.trim();n[f]||(n[f]=d),d==="false"&&(n[f]=!1),d==="true"&&(n[f]=!0),isNaN(d)||(n[f]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},Uu=e=>{const t={};return(n,o,s)=>{let a=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(a={...a,[s.interpolationkey]:void 0});const i=o+JSON.stringify(a);let l=t[i];return l||(l=e(co(o),s),t[i]=l),l(n)}},mR=e=>(t,n,o)=>e(co(n),o)(t);class hR{constructor(t={}){this.logger=Vt.create("formatter"),this.options=t,this.init(t)}init(t,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const o=n.cacheInBuiltFormats?Uu:mR;this.formats={number:o((s,a)=>{const i=new Intl.NumberFormat(s,{...a});return l=>i.format(l)}),currency:o((s,a)=>{const i=new Intl.NumberFormat(s,{...a,style:"currency"});return l=>i.format(l)}),datetime:o((s,a)=>{const i=new Intl.DateTimeFormat(s,{...a});return l=>i.format(l)}),relativetime:o((s,a)=>{const i=new Intl.RelativeTimeFormat(s,{...a});return l=>i.format(l,a.range||"day")}),list:o((s,a)=>{const i=new Intl.ListFormat(s,{...a});return l=>i.format(l)})}}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=Uu(n)}format(t,n,o,s={}){const a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(l=>l.indexOf(")")>-1)){const l=a.findIndex(c=>c.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,l)].join(this.formatSeparator)}return a.reduce((l,c)=>{const{formatName:d,formatOptions:f}=fR(c);if(this.formats[d]){let p=l;try{const m=s?.formatParams?.[s.interpolationkey]||{},h=m.locale||m.lng||s.locale||s.lng||o;p=this.formats[d](l,h,{...f,...s,...m})}catch(m){this.logger.warn(m)}return p}else this.logger.warn(`there was no format function for ${d}`);return l},t)}}const gR=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class bR extends Na{constructor(t,n,o,s={}){super(),this.backend=t,this.store=n,this.services=o,this.languageUtils=o.languageUtils,this.options=s,this.logger=Vt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(o,s.backend,s)}queueLoad(t,n,o,s){const a={},i={},l={},c={};return t.forEach(d=>{let f=!0;n.forEach(p=>{const m=`${d}|${p}`;!o.reload&&this.store.hasResourceBundle(d,p)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?i[m]===void 0&&(i[m]=!0):(this.state[m]=1,f=!1,i[m]===void 0&&(i[m]=!0),a[m]===void 0&&(a[m]=!0),c[p]===void 0&&(c[p]=!0)))}),f||(l[d]=!0)}),(Object.keys(a).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(a),pending:Object.keys(i),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(t,n,o){const s=t.split("|"),a=s[0],i=s[1];n&&this.emit("failedLoading",a,i,n),!n&&o&&this.store.addResourceBundle(a,i,o,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&o&&(this.state[t]=0);const l={};this.queue.forEach(c=>{nR(c.loaded,[a],i),gR(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(d=>{l[d]||(l[d]={});const f=c.loaded[d];f.length&&f.forEach(p=>{l[d][p]===void 0&&(l[d][p]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,o,s=0,a=this.retryTimeout,i){if(!t.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:o,tried:s,wait:a,callback:i});return}this.readingCalls++;const l=(d,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const p=this.waitingReads.shift();this.read(p.lng,p.ns,p.fcName,p.tried,p.wait,p.callback)}if(d&&f&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,o,s+1,a*2,i)},a);return}i(d,f)},c=this.backend[o].bind(this.backend);if(c.length===2){try{const d=c(t,n);d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}return}return c(t,n,l)}prepareLoading(t,n,o={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();Ce(t)&&(t=this.languageUtils.toResolveHierarchy(t)),Ce(n)&&(n=[n]);const a=this.queueLoad(t,n,o,s);if(!a.toLoad.length)return a.pending.length||s(),null;a.toLoad.forEach(i=>{this.loadOne(i)})}load(t,n,o){this.prepareLoading(t,n,{},o)}reload(t,n,o){this.prepareLoading(t,n,{reload:!0},o)}loadOne(t,n=""){const o=t.split("|"),s=o[0],a=o[1];this.read(s,a,"read",void 0,void 0,(i,l)=>{i&&this.logger.warn(`${n}loading namespace ${a} for language ${s} failed`,i),!i&&l&&this.logger.log(`${n}loaded namespace ${a} for language ${s}`,l),this.loaded(t,i,l)})}saveMissing(t,n,o,s,a,i={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${o}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(o==null||o==="")){if(this.backend?.create){const c={...i,isUpdate:a},d=this.backend.create.bind(this.backend);if(d.length<6)try{let f;d.length===5?f=d(t,n,o,s,c):f=d(t,n,o,s),f&&typeof f.then=="function"?f.then(p=>l(null,p)).catch(l):l(null,f)}catch(f){l(f)}else d(t,n,o,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,o,s)}}}const di=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),Ce(e[1])&&(t.defaultValue=e[1]),Ce(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(o=>{t[o]=n[o]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Ku=e=>(Ce(e.ns)&&(e.ns=[e.ns]),Ce(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),Ce(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),typeof e.initImmediate=="boolean"&&(e.initAsync=e.initImmediate),e),Wo=()=>{},xR=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})},Ay="__i18next_supportNoticeShown",yR=()=>!!(typeof globalThis<"u"&&globalThis[Ay]||typeof process<"u"&&ii&&ii.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&ii),vR=()=>{typeof globalThis<"u"&&(globalThis[Ay]=!0)},wR=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 Xr extends Na{constructor(t={},n){if(super(),this.options=Ku(t),this.services={},this.logger=Vt,this.modules={external:[]},xR(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(t={},n){this.isInitializing=!0,typeof t=="function"&&(n=t,t={}),t.defaultNS==null&&t.ns&&(Ce(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const o=di();this.options={...o,...this.options,...Ku(t)},this.options.interpolation={...o.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=o.overloadTranslationOptionHandler),this.options.showSupportNotice!==!1&&!wR(this)&&!yR()&&(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 💙"),vR());const s=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Vt.init(s(this.modules.logger),this.options):Vt.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=hR;const f=new ju(this.options);this.store=new Bu(this.options.resources,this.options);const p=this.services;p.logger=Vt,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new pR(f,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==o.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),d&&(!this.options.interpolation.format||this.options.interpolation.format===o.interpolation.format)&&(p.formatter=s(d),p.formatter.init&&p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new Qu(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new bR(s(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",(h,...g)=>{this.emit(h,...g)}),this.modules.languageDetector&&(p.languageDetector=s(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=s(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new Ds(this.services,this.options),this.translator.on("*",(h,...g)=>{this.emit(h,...g)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Wo),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(d=>{this[d]=(...f)=>this.store[d](...f)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=(...f)=>(this.store[d](...f),this)});const l=Br(),c=()=>{const d=(f,p)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(p),n(f,p)};if(this.languages&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(t,n=Wo){let o=n;const s=Ce(t)?t:this.language;if(typeof t=="function"&&(o=t),!this.options.resources||this.options.partialBundledLanguages){if(s?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return o();const a=[],i=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(d=>{d!=="cimode"&&a.indexOf(d)<0&&a.push(d)})};s?i(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>i(c)),this.options.preload?.forEach?.(l=>i(l)),this.services.backendConnector.load(a,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),o(l)})}else o(null)}reloadResources(t,n,o){const s=Br();return typeof t=="function"&&(o=t,t=void 0),typeof n=="function"&&(o=n,n=void 0),t||(t=this.languages),n||(n=this.options.ns),o||(o=Wo),this.services.backendConnector.reload(t,n,a=>{s.resolve(),o(a)}),s}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&My.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!(["cimode","dev"].indexOf(t)>-1)){for(let n=0;n<this.languages.length;n++){const o=this.languages[n];if(!(["cimode","dev"].indexOf(o)>-1)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}!this.resolvedLanguage&&this.languages.indexOf(t)<0&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,n){this.isLanguageChangingTo=t;const o=Br();this.emit("languageChanging",t);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(l,c)=>{c?this.isLanguageChangingTo===t&&(s(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,o.resolve((...d)=>this.t(...d)),n&&n(l,(...d)=>this.t(...d))},i=l=>{!t&&!l&&this.services.languageDetector&&(l=[]);const c=Ce(l)?l:l&&l[0],d=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(Ce(l)?[l]:l);d&&(this.language||s(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector?.cacheUserLanguage?.(d)),this.loadResources(d,f=>{a(f,d)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?i(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(i):this.services.languageDetector.detect(i):i(t),o}getFixedT(t,n,o){const s=(a,i,...l)=>{let c;typeof i!="object"?c=this.options.overloadTranslationOptionHandler([a,i].concat(l)):c={...i},c.lng=c.lng||s.lng,c.lngs=c.lngs||s.lngs,c.ns=c.ns||s.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||o||s.keyPrefix);const d={...this.options,...c};typeof c.keyPrefix=="function"&&(c.keyPrefix=cr(c.keyPrefix,d));const f=this.options.keySeparator||".";let p;return c.keyPrefix&&Array.isArray(a)?p=a.map(m=>(typeof m=="function"&&(m=cr(m,d)),`${c.keyPrefix}${f}${m}`)):(typeof a=="function"&&(a=cr(a,d)),p=c.keyPrefix?`${c.keyPrefix}${f}${a}`:a),this.t(p,c)};return Ce(t)?s.lng=t:s.lngs=t,s.ns=n,s.keyPrefix=o,s}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const o=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(o.toLowerCase()==="cimode")return!0;const i=(l,c)=>{const d=this.services.backendConnector.state[`${l}|${c}`];return d===-1||d===0||d===2};if(n.precheck){const l=n.precheck(this,i);if(l!==void 0)return l}return!!(this.hasResourceBundle(o,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(o,t)&&(!s||i(a,t)))}loadNamespaces(t,n){const o=Br();return this.options.ns?(Ce(t)&&(t=[t]),t.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{o.resolve(),n&&n(s)}),o):(n&&n(),Promise.resolve())}loadLanguages(t,n){const o=Br();Ce(t)&&(t=[t]);const s=this.options.preload||[],a=t.filter(i=>s.indexOf(i)<0&&this.services.languageUtils.isSupportedCode(i));return a.length?(this.options.preload=s.concat(a),this.loadResources(i=>{o.resolve(),n&&n(i)}),o):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return"rtl";try{const s=new Intl.Locale(t);if(s&&s.getTextInfo){const a=s.getTextInfo();if(a&&a.direction)return a.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],o=this.services?.languageUtils||new ju(di());return t.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(o.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},n){const o=new Xr(t,n);return o.createInstance=Xr.createInstance,o}cloneInstance(t={},n=Wo){const o=t.forkResourceStore;o&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},a=new Xr(s);if((t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),["store","services","language"].forEach(l=>{a[l]=this[l]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},o){const l=Object.keys(this.store.data).reduce((c,d)=>(c[d]={...this.store.data[d]},c[d]=Object.keys(c[d]).reduce((f,p)=>(f[p]={...c[d][p]},f),c[d]),c),{});a.store=new Bu(l,s),a.services.resourceStore=a.store}if(t.interpolation){const c={...di().interpolation,...this.options.interpolation,...t.interpolation},d={...s,interpolation:c};a.services.interpolator=new Qu(d)}return a.translator=new Ds(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 Ye=Xr.createInstance();Ye.createInstance;Ye.dir;Ye.init;Ye.loadResources;Ye.reloadResources;Ye.use;Ye.changeLanguage;Ye.getFixedT;Ye.t;Ye.exists;Ye.setDefaultNamespace;Ye.hasLoadedNamespace;Ye.loadNamespaces;Ye.loadLanguages;const NR=(e,t,n,o)=>{const s=[n,{code:t,...o||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(s,"warn","react-i18next::",!0);jn(s[0])&&(s[0]=`react-i18next:: ${s[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...s):console?.warn&&console.warn(...s)},Gu={},al=(e,t,n,o)=>{jn(n)&&Gu[n]||(jn(n)&&(Gu[n]=new Date),NR(e,t,n,o))},Py=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}},il=(e,t,n)=>{e.loadNamespaces(t,Py(e,n))},Wu=(e,t,n,o)=>{if(jn(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return il(e,n,o);n.forEach(s=>{e.options.ns.indexOf(s)<0&&e.options.ns.push(s)}),e.loadLanguages(t,Py(e,o))},kR=(e,t,n={})=>!t.languages||!t.languages.length?(al(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(o,s)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&o.services.backendConnector.backend&&o.isLanguageChangingTo&&!s(o.isLanguageChangingTo,e))return!1}}),jn=e=>typeof e=="string",SR=e=>typeof e=="object"&&e!==null,CR=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,MR={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},IR=e=>MR[e],AR=e=>e.replace(CR,IR);let ll={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:AR,transDefaultProps:void 0};const PR=(e={})=>{ll={...ll,...e}},ER=()=>ll;let Ey;const $R=e=>{Ey=e},_R=()=>Ey,DR={type:"3rdParty",init(e){PR(e.options.react),$R(e)}},LR=Oe();class TR{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var $y={exports:{}},_y={};/**
|
|
1076
|
+
* @license React
|
|
1077
|
+
* use-sync-external-store-shim.production.js
|
|
1078
|
+
*
|
|
1079
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1080
|
+
*
|
|
1081
|
+
* This source code is licensed under the MIT license found in the
|
|
1082
|
+
* LICENSE file in the root directory of this source tree.
|
|
1083
|
+
*/var xr=Vf;function RR(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var OR=typeof Object.is=="function"?Object.is:RR,zR=xr.useState,BR=xr.useEffect,FR=xr.useLayoutEffect,jR=xr.useDebugValue;function HR(e,t){var n=t(),o=zR({inst:{value:n,getSnapshot:t}}),s=o[0].inst,a=o[1];return FR(function(){s.value=n,s.getSnapshot=t,ui(s)&&a({inst:s})},[e,n,t]),BR(function(){return ui(s)&&a({inst:s}),e(function(){ui(s)&&a({inst:s})})},[e]),jR(n),n}function ui(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!OR(e,n)}catch{return!0}}function VR(e,t){return t()}var qR=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?VR:HR;_y.useSyncExternalStore=xr.useSyncExternalStore!==void 0?xr.useSyncExternalStore:qR;$y.exports=_y;var Dy=$y.exports;const QR=(e,t)=>{if(jn(t))return t;if(SR(t)&&jn(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},UR={t:QR,ready:!1},KR=()=>()=>{},Rt=(e,t={})=>{const{i18n:n}=t,{i18n:o,defaultNS:s}=ve(LR)||{},a=n||o||_R();a&&!a.reportNamespaces&&(a.reportNamespaces=new TR),a||al(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const i=U(()=>({...ER(),...a?.options?.react,...t}),[a,t]),{useSuspense:l,keyPrefix:c}=i,d=s||a?.options?.defaultNS,f=jn(d)?[d]:d||["translation"],p=U(()=>f,f);a?.reportNamespaces?.addUsedNamespaces?.(p);const m=ne(0),h=q(I=>{if(!a)return KR;const{bindI18n:z,bindI18nStore:$}=i,O=()=>{m.current+=1,I()};return z&&a.on(z,O),$&&a.store.on($,O),()=>{z&&z.split(" ").forEach(R=>a.off(R,O)),$&&$.split(" ").forEach(R=>a.store.off(R,O))}},[a,i]),g=ne(),b=q(()=>{if(!a)return UR;const I=!!(a.isInitialized||a.initializedStoreOnce)&&p.every(L=>kR(L,a,i)),z=t.lng||a.language,$=m.current,O=g.current;if(O&&O.ready===I&&O.lng===z&&O.keyPrefix===c&&O.revision===$)return O;const A={t:a.getFixedT(z,i.nsMode==="fallback"?p:p[0],c),ready:I,lng:z,keyPrefix:c,revision:$};return g.current=A,A},[a,p,c,i,t.lng]),[x,v]=_(0),{t:w,ready:y}=Dy.useSyncExternalStore(h,b,b);Z(()=>{if(a&&!y&&!l){const I=()=>v(z=>z+1);t.lng?Wu(a,t.lng,p,I):il(a,p,I)}},[a,t.lng,p,y,l,x]);const N=a||{},k=ne(null),S=ne(),M=I=>{const z=Object.getOwnPropertyDescriptors(I);z.__original&&delete z.__original;const $=Object.create(Object.getPrototypeOf(I),z);if(!Object.prototype.hasOwnProperty.call($,"__original"))try{Object.defineProperty($,"__original",{value:I,writable:!1,enumerable:!1,configurable:!1})}catch{}return $},P=U(()=>{const I=N,z=I?.language;let $=I;I&&(k.current&&k.current.__original===I?S.current!==z?($=M(I),k.current=$,S.current=z):$=k.current:($=M(I),k.current=$,S.current=z));const O=!y&&!l?(...A)=>(al(a,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),w(...A)):w,R=[O,$,y];return R.t=O,R.i18n=$,R.ready=y,R},[w,N,y,N.resolvedLanguage,N.language,N.languages]);if(a&&l&&!y)throw new Promise(I=>{const z=()=>I();t.lng?Wu(a,t.lng,p,z):il(a,p,z)});return P},Yu={info:Ps,success:ey,warning:xt,error:xa},GR={info:"text-blue-400",success:"text-green-400",warning:"text-amber-400",error:"text-red-400"},Zu={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 WR(e){const t=Math.floor((Date.now()-e)/1e3);if(t<60)return"just now";const n=Math.floor(t/60);if(n<60)return`${String(n)}m ago`;const o=Math.floor(n/60);if(o<24)return`${String(o)}h ago`;const s=Math.floor(o/24);return`${String(s)}d ago`}function Xu({alert:e,onMarkRead:t,onDismiss:n}){const o=e.severity in Yu?e.severity:"info",s=e.status in Zu?e.status:"active",a=Yu[o],i=GR[o],l=Zu[s];return u("div",{className:`flex items-start gap-2.5 px-3 py-2.5 border-l-2 ${l} ${e.read?"opacity-60":""} hover:bg-surface-hover transition-colors`,children:[r(a,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${i}`}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:`text-[11px] font-semibold ${e.read?"text-foreground-subtle":"text-foreground"}`,children:e.title}),!e.read&&r("span",{className:"h-1.5 w-1.5 rounded-full bg-primary shrink-0"})]}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-2",children:e.message}),e.status==="in-progress"&&e.progress!==void 0&&u("div",{className:"mt-1.5 flex items-center gap-2",children:[r("div",{className:"flex-1 h-1 bg-surface-hover rounded-full overflow-hidden",children:r("div",{className:"h-full bg-primary rounded-full transition-all duration-300",style:{width:`${String(Math.min(100,Math.max(0,e.progress)))}%`}})}),u("span",{className:"text-[9px] text-foreground-subtle font-mono shrink-0",children:[String(Math.round(e.progress)),"%"]})]}),r("div",{className:"text-[9px] text-foreground-subtle/60 mt-1",children:WR(e.updatedAt)})]}),u("div",{className:"flex items-center gap-0.5 shrink-0",children:[!e.read&&r("button",{type:"button",onClick:c=>{c.stopPropagation(),t(e.id)},className:"p-1 rounded hover:bg-surface-hover transition-colors",title:"Mark as read",children:r(Mt,{className:"h-3 w-3 text-foreground-subtle"})}),e.status!=="in-progress"&&r("button",{type:"button",onClick:c=>{c.stopPropagation(),n(e.id)},className:"p-1 rounded hover:bg-surface-hover transition-colors",title:"Dismiss",children:r(Ve,{className:"h-3 w-3 text-foreground-subtle"})})]})]})}function Ju({variant:e="icon",compact:t=!1}={}){const[n,o]=_(!1),[s,a]=_(!1),i=ne(null),l=ne(null),c=ke(),{data:d=0}=rg(void 0,{staleTime:1e4,refetchInterval:3e4}),{data:f=[],isLoading:p}=ng({limit:50},{enabled:n,staleTime:5e3}),m=s?f:f.filter(I=>!I.read),h=f.filter(I=>I.read).length,g=()=>{c.invalidateQueries({queryKey:[["alerts"]]})},b=og({onSuccess:g}),x=sg({onSuccess:g}),v=ag({onSuccess:g});ct("alert.created",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),ct("alert.updated",()=>{c.invalidateQueries({queryKey:[["alerts"]]})}),Z(()=>{if(!n)return;const I=z=>{const $=z.target;i.current&&!i.current.contains($)&&l.current&&!l.current.contains($)&&o(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[n]);const w=q(I=>{b.mutate({alertId:I})},[b]),y=q(I=>{I&&v.mutate({alertId:I})},[v]),N=q(()=>{x.mutate(void 0),o(!1)},[x]),k=m.filter(I=>I.status==="in-progress"),S=m.filter(I=>I.status!=="in-progress"),[M,P]=_({});return Z(()=>{if(n&&l.current){const I=l.current.getBoundingClientRect();P({position:"fixed",left:I.left,bottom:window.innerHeight-I.top+4,zIndex:9999})}},[n]),u("div",{children:[e==="sidebar"?u("button",{ref:l,type:"button",onClick:()=>o(!n),className:`flex w-full items-center gap-2.5 rounded-md ${t?"justify-center px-0 py-2":"px-2.5 py-1.5"} text-[12px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,title:t?`Alerts${d>0?` (${d})`:""}`:void 0,children:[u("span",{className:"relative inline-flex shrink-0",children:[r(Ze,{className:"h-3.5 w-3.5"}),t&&d>0&&r("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary"})]}),!t&&r("span",{className:"flex-1 text-left",children:"Alerts"}),!t&&d>0&&r("span",{className:"flex items-center justify-center h-4 min-w-4 px-1 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none",children:d>99?"99+":String(d)})]}):u("button",{ref:l,type:"button",onClick:()=>o(!n),className:"relative p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors","aria-label":"Alerts",children:[r(Ze,{className:"h-4.5 w-4.5"}),d>0&&r("span",{className:"absolute -top-0.5 -right-0.5 flex items-center justify-center h-4 min-w-4 px-0.5 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none",children:d>99?"99+":String(d)})]}),n&&vo(u("div",{ref:i,style:M,className:"w-80 max-h-[28rem] bg-surface border border-border rounded-lg shadow-xl flex flex-col overflow-hidden",children:[u("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border shrink-0",children:[r("span",{className:"text-[12px] font-semibold text-foreground",children:"Alerts"}),u("div",{className:"flex items-center gap-2",children:[h>0&&u("label",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle cursor-pointer select-none",children:[r("input",{type:"checkbox",checked:s,onChange:I=>a(I.target.checked),className:"h-3 w-3 rounded border-border accent-primary cursor-pointer"}),"Show read"]}),d>0&&u("button",{type:"button",onClick:N,className:"flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors",children:[r(uD,{className:"h-3 w-3"}),"Mark all read"]})]})]}),u("div",{className:"flex-1 overflow-y-auto",children:[p&&r("div",{className:"flex items-center justify-center py-8",children:r(Pe,{className:"h-4 w-4 animate-spin text-foreground-subtle"})}),!p&&m.length===0&&u("div",{className:"flex flex-col items-center justify-center py-8 text-foreground-subtle",children:[r(Ze,{className:"h-6 w-6 mb-2 opacity-40"}),r("span",{className:"text-[11px]",children:f.length>0?"No unread alerts":"No alerts"}),f.length>0&&!s&&u("button",{type:"button",onClick:()=>a(!0),className:"text-[10px] text-primary mt-1 hover:underline",children:["Show ",h," read alert",h!==1?"s":""]})]}),k.length>0&&u("div",{className:"border-b border-border",children:[r("div",{className:"px-3 py-1.5 bg-surface-hover/50",children:r("span",{className:"text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:"In Progress"})}),k.map(I=>r(Xu,{alert:I,onMarkRead:w,onDismiss:y},I.id))]}),S.map(I=>r(Xu,{alert:I,onMarkRead:w,onDismiss:y},I.id))]})]}),document.body)]})}function Ly(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 ep=new Map,Yo=new Map,tp=new Set;function YR(e){return!e||typeof e!="object"?!1:typeof e.default=="function"}async function ZR(e,t){const n=ep.get(e);if(n)return n;const o=Yo.get(e);if(o)return o;tp.has(e)||(Tl(),pr.registerRemotes([{name:e,entry:t,type:"module"}],{force:!1}),tp.add(e));const s=pr.loadRemote(`${e}/page`).then(a=>{if(!YR(a))throw new Error(`Addon page remote ${e} (${t}) does not expose a default React component on './page'`);return ep.set(e,a.default),Yo.delete(e),a.default}).catch(a=>{throw Yo.delete(e),a});return Yo.set(e,s),s}function XR(){const{pagePath:e}=Bc(),t=Le(),{data:n}=lc(void 0,{staleTime:6e4}),o=U(()=>n?Ly(n):void 0,[n]),s=o?.find(d=>d.path===`/addon/${e}`),[a,i]=_(null),[l,c]=_(null);return Z(()=>{if(!s)return;c(null),i(null);let d=!1;return ZR(s.remoteName,s.bundleUrl).then(f=>{d||i(()=>f)}).catch(f=>{if(d)return;const p=f instanceof Error?f.message:String(f);c(`Failed to load addon page: ${p}`)}),()=>{d=!0}},[s]),o?s?l?r("div",{className:"flex items-center justify-center h-full text-red-400 text-sm",children:l}):a?r(a,{trpc:t.trpcClient,theme:{isDark:document.documentElement.classList.contains("dark")},navigate:d=>{window.location.href=d}}):r("div",{className:"flex items-center justify-center h-full",children:r("div",{className:"animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full"})}):r("div",{className:"flex items-center justify-center h-full text-foreground-subtle",children:"Addon page not found"}):r("div",{className:"flex items-center justify-center h-full",children:r("div",{className:"animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full"})})}const JR={dark:dy,light:sT,system:xL},e6={gauge:oy,puzzle:Es,bot:nD,cpu:dt,terminal:by,box:ga,wrench:xT,activity:Mo,plug:Yc};function t6(){const e=ht(),t=Je(),{user:n,logout:o}=Lr(),s=Mr(),{t:a,i18n:i}=Rt(),l=Zn(),c=nh(),d=B_(),f=d!=="connected",p=d==="connecting",[m,h]=_(!1),[g,b]=_(()=>typeof window>"u"?!1:window.localStorage.getItem("camstack:sidebar-collapsed")==="1");Z(()=>{typeof window>"u"||window.localStorage.setItem("camstack:sidebar-collapsed",g?"1":"0")},[g]);const[x,v]=_(()=>{if(typeof window>"u")return new Set;try{const E=window.localStorage.getItem("camstack:sidebar-collapsed-groups");if(!E)return new Set;const Q=JSON.parse(E);return Array.isArray(Q)?new Set(Q.filter(K=>typeof K=="string")):new Set}catch{return new Set}});Z(()=>{typeof window>"u"||window.localStorage.setItem("camstack:sidebar-collapsed-groups",JSON.stringify([...x]))},[x]),Z(()=>{c&&window.localStorage.getItem("camstack:sidebar-collapsed")===null&&b(!0)},[c]);const{data:w=[]}=dc(void 0,{staleTime:3e4,refetchInterval:3e4}),y=w.length,N=ke(),k=ne(Date.now()),S=3e4,M=2e3,{data:P}=lc(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:E=>{const Q=E.state.data;return Q&&Q.length>0||Date.now()-k.current>=S?!1:M}}),I=U(()=>P?Ly(P):[],[P]);ct("addon.page-ready",()=>{N.invalidateQueries({queryKey:[["addonPages","listPages"]]})});const z=()=>{o(),t("/login")},$=E=>!!(e.pathname===E||e.pathname.startsWith(E+"/")),R=["/pipeline","/timeline"].some(E=>e.pathname===E||e.pathname.startsWith(E+"/")),A=()=>{const E=i.language==="en"?"it":"en";i.changeLanguage(E)},L=[{label:a("nav.devices","Devices"),icon:hr,path:"/devices"},{label:a("nav.integrations"),icon:Yc,path:"/integrations"},{label:a("nav.timeline","Timeline"),icon:SD,path:"/timeline"},{label:a("nav.pipeline","Pipeline"),icon:sy,path:"/pipeline"}],D=[{label:a("system.identity","Identity & Access"),icon:ly,path:"/system/identity"},{label:a("system.network","Network"),icon:gr,path:"/system/network"},{label:a("system.data","Data"),icon:ny,path:"/system/data"},{label:a("system.cluster","Cluster"),icon:on,path:"/system/cluster"},{label:a("system.addons"),icon:Es,path:"/system/addons"},{label:a("system.addonSettings","Addon Settings"),icon:Nt,path:"/system/settings"},{label:a("system.logs","Logs"),icon:Ze,path:"/system/logs"}],T=s?.mode??"system",B={dark:a("theme.dark"),light:a("theme.light"),system:a("theme.system")},F=g&&!l,j=(E,Q="md")=>`flex w-full items-center gap-2.5 rounded-md ${F?"justify-center px-0 py-2":"px-2.5 py-1.5"} ${Q==="lg"?"text-[13px] font-medium":"text-[12px]"} transition-all ${E?Q==="lg"?"bg-primary/12 text-primary shadow-sm shadow-primary/5":"bg-primary/12 text-primary":"text-foreground-subtle hover:bg-surface-hover hover:text-foreground"}`,H=u(xe,{children:[u("div",{className:`flex h-14 items-center border-b border-border ${F?"justify-center px-1":"pl-3 pr-4 gap-2"}`,children:[!F&&r("img",{src:s?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack Admin",className:"h-9 flex-1 min-w-0"}),!l&&r("button",{onClick:()=>b(E=>!E),className:`p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle transition-colors flex-shrink-0 ${F?"":"mr-2"}`,"aria-label":g?"Expand sidebar":"Collapse sidebar",title:g?"Expand sidebar":"Collapse sidebar",children:g?r(It,{className:"h-4 w-4"}):r(Kc,{className:"h-4 w-4"})})]}),u("nav",{className:`flex-1 overflow-y-auto py-3 ${F?"px-1.5":"px-2"} space-y-0.5`,children:[(()=>{const E=$("/dashboard");return u("button",{"data-testid":"nav-dashboard",onClick:()=>{t("/dashboard"),h(!1)},className:j(E,"lg"),title:F?a("nav.dashboard"):void 0,children:[r(iy,{className:`h-4 w-4 shrink-0 ${E?"text-primary":""}`}),!F&&a("nav.dashboard")]})})(),!F&&r("div",{className:"pt-4 pb-1.5 px-2.5",children:r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("nav.camerasSection","Cameras")})}),F&&r("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),L.map(E=>{const Q=E.icon,K=$(E.path),Y=`nav-${E.path.replace(/^\//,"").replace(/\//g,"-")}`;return u("button",{"data-testid":Y,onClick:()=>{t(E.path),h(!1)},className:j(K),title:F?E.label:void 0,children:[r(Q,{className:`h-3.5 w-3.5 shrink-0 ${K?"text-primary":""}`}),!F&&E.label]},E.path)}),!F&&r("div",{className:"pt-4 pb-1.5 px-2.5",children:r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("system.title")})}),F&&r("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),D.map(E=>{const Q=E.icon,K=$(E.path),Y=E.path==="/system/addons",re=`nav-${E.path.replace(/^\//,"").replace(/\//g,"-")}`;return u("button",{"data-testid":re,onClick:()=>{t(E.path),h(!1)},className:j(K),title:F?E.label:void 0,children:[r(Q,{className:`h-3.5 w-3.5 shrink-0 ${K?"text-primary":""}`}),!F&&u(xe,{children:[r("span",{className:"flex-1 text-left",children:E.label}),Y&&y>0&&r("span",{className:"ml-auto rounded-full bg-primary px-1.5 py-0.5 text-[9px] font-bold text-primary-foreground leading-none",children:y})]}),F&&Y&&y>0&&r("span",{className:"absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary"})]},E.path)}),I&&I.length>0&&!F&&r("div",{className:"pt-4 pb-1.5 px-2.5",children:r("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60",children:a("nav.addonPages","Addon Pages")})}),F&&I&&I.length>0&&r("div",{className:"pt-3 mb-1 mx-2 border-t border-border/60"}),I?.map(E=>{const Q=$(E.path),K=e6[E.icon]??Es;return u("button",{onClick:()=>{t(E.path),h(!1)},className:j(Q),title:F?E.label:void 0,children:[r(K,{className:`h-3.5 w-3.5 shrink-0 ${Q?"text-primary":""}`}),!F&&E.label]},E.id)})]}),u("div",{className:`border-t border-border ${F?"p-1.5":"p-2"} space-y-0.5`,children:[u("button",{onClick:A,title:a("language.select"),className:j(!1),children:[r(XD,{className:"h-3.5 w-3.5 shrink-0"}),!F&&r("span",{children:i.language==="en"?a("language.en"):a("language.it")})]}),u("button",{onClick:()=>s?.toggleMode(),className:j(!1),title:F?B[T]:void 0,children:[(()=>{const E=JR[T];return r(E,{className:"h-3.5 w-3.5 shrink-0"})})(),!F&&r("span",{children:B[T]})]}),r(Ju,{variant:"sidebar",compact:F}),u("button",{onClick:z,className:j(!1).replace("hover:text-foreground","hover:text-danger"),title:F?n?.username??"Logout":void 0,children:[r(cy,{className:"h-3.5 w-3.5 shrink-0"}),!F&&r("span",{className:"truncate",children:n?.username??"User"})]})]})]});return u("div",{className:"flex h-screen bg-background text-foreground",children:[!l&&r("aside",{className:`flex flex-col border-r border-border bg-surface/80 backdrop-blur-sm shrink-0 transition-[width] duration-150 ease-out ${F?"w-12":"w-48"}`,children:H}),l&&r(Wl,{open:m,onClose:()=>h(!1),width:"w-64",children:H}),u("div",{className:"flex flex-1 flex-col min-w-0",children:[f&&u("div",{className:"flex items-center justify-center gap-2 bg-danger/90 px-3 py-2 text-[12px] font-medium text-white shrink-0",children:[r(vy,{className:"h-3.5 w-3.5"}),r("span",{children:p?a("connection.reconnecting","Reconnecting…"):a("connection.disconnected","Server unreachable — reconnecting…")}),r(Pe,{className:"h-3.5 w-3.5 animate-spin"})]}),l&&u("header",{className:"flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm",children:[r("button",{onClick:()=>h(!0),className:"p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors","aria-label":"Open menu",children:r(fL,{className:"h-5 w-5"})}),r("div",{className:"flex-1 flex justify-center",children:r("img",{src:s?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack",className:"h-7"})}),r(Ju,{})]}),u("main",{className:`relative flex-1 min-h-0 bg-background ${R?"overflow-hidden":"overflow-auto"}`,children:[f&&r("div",{className:"absolute inset-0 z-40 bg-background/60 backdrop-blur-[2px]"}),r(Z$,{})]})]})]})}function n6(){const{login:e}=Lr(),t=Mr(),n=Je(),[o,s]=_(""),[a,i]=_(""),[l,c]=_(!1),[d,f]=_(""),[p,m]=_(!1),h=async g=>{g.preventDefault(),f(""),m(!0);try{await e(o,a),n(a==="changeme"?"/change-password":"/dashboard",{replace:!0})}catch(b){f(b instanceof Error?b.message:"Login failed")}finally{m(!1)}};return r("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:u("div",{className:"w-full max-w-sm",children:[r("div",{className:"flex justify-center mb-8",children:r("img",{src:t?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack Admin",className:"h-12"})}),u("form",{onSubmit:h,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[d&&r("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:d}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Username"}),r("input",{"data-testid":"login-username",type:"text",placeholder:"Username",value:o,onChange:g=>s(g.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all",autoFocus:!0})]}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Password"}),u("div",{className:"relative",children:[r("input",{"data-testid":"login-password",type:l?"text":"password",placeholder:"Password",value:a,onChange:g=>i(g.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all"}),r("button",{type:"button",onClick:()=>c(!l),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors",tabIndex:-1,children:l?r(ry,{className:"h-4 w-4"}):r(ya,{className:"h-4 w-4"})})]})]}),r("button",{"data-testid":"login-submit",type:"submit",disabled:p||!o||!a,className:"w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all",children:p?u("span",{className:"flex items-center justify-center gap-2",children:[r("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground/30 border-t-primary-foreground"}),"Logging in..."]}):"Log in"})]}),r(r6,{}),r("p",{className:"mt-6 text-center text-[10px] text-foreground-subtle/50",children:"CamStack v0.1.0"})]})})}function r6(){const t=(pc().data??[]).filter(n=>n.enabled&&n.hasRedirectFlow);return t.length===0?null:u("div",{className:"mt-6 space-y-3",children:[u("div",{className:"flex items-center gap-3",children:[r("div",{className:"h-px flex-1 bg-border"}),r("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Or continue with"}),r("div",{className:"h-px flex-1 bg-border"})]}),r("div",{className:"space-y-2",children:t.map(n=>u("a",{href:`/addon/${encodeURIComponent(n.addonId)}/start`,className:"flex items-center justify-center gap-2 w-full rounded-lg border border-border bg-surface px-4 py-2.5 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors",children:[r(br,{className:"h-4 w-4 text-primary"}),n.displayName]},n.addonId))})]})}const np=8;function o6(){const{user:e,mustChangePassword:t,clearMustChangePassword:n,logout:o}=Lr(),s=Mr(),a=Je(),[i,l]=_(""),[c,d]=_(""),[f,p]=_(!1),[m,h]=_(""),g=Cc({onSuccess:()=>{n(),a("/dashboard",{replace:!0})},onError:x=>{h(x instanceof Error?x.message:"Could not change password")}}),b=async x=>{if(x.preventDefault(),h(""),!e){h("Not signed in");return}if(i.length<np){h(`Password must be at least ${np} characters`);return}if(i!==c){h("The two passwords do not match");return}if(i==="changeme"){h("Choose a password different from the seed default");return}g.mutate({id:e.id,newPassword:i})};return r("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:u("div",{className:"w-full max-w-sm",children:[r("div",{className:"flex justify-center mb-8",children:r("img",{src:s?.resolvedMode==="light"?"/brand/logo-horizontal-light.svg":"/brand/logo-horizontal-dark.svg",alt:"CamStack Admin",className:"h-12"})}),u("form",{onSubmit:b,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[u("div",{className:"space-y-1",children:[r("h1",{className:"text-sm font-semibold text-foreground",children:"Set a new password"}),r("p",{className:"text-xs text-foreground-subtle",children:t?"You must rotate the seed password before continuing.":"Choose a new password for your account."})]}),m&&r("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:m}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"New password"}),u("div",{className:"relative",children:[r("input",{"data-testid":"change-password-new",type:f?"text":"password",value:i,onChange:x=>l(x.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all",autoFocus:!0}),r("button",{type:"button",onClick:()=>p(!f),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors",tabIndex:-1,children:f?r(ry,{className:"h-4 w-4"}):r(ya,{className:"h-4 w-4"})})]})]}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-xs font-medium text-foreground-subtle",children:"Confirm new password"}),r("input",{"data-testid":"change-password-confirm",type:f?"text":"password",value:c,onChange:x=>d(x.target.value),className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all"})]}),r("button",{"data-testid":"change-password-submit",type:"submit",disabled:g.isPending||!i||!c,className:"w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all",children:g.isPending?"Saving…":"Save and continue"}),t&&r("button",{type:"button",onClick:()=>{o(),a("/login",{replace:!0})},className:"w-full text-xs text-foreground-subtle hover:text-foreground transition-colors",children:"Sign out instead"})]})]})})}function s6(){const e=Je();return u("div",{className:"flex min-h-screen flex-col items-center justify-center bg-background text-foreground p-4",children:[r("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-danger/10 mb-4",children:r(WL,{className:"h-8 w-8 text-danger"})}),r("h1",{className:"text-xl font-bold",children:"Access Denied"}),r("p",{className:"mt-2 text-sm text-foreground-subtle",children:"You don't have permission to access this page."}),r("button",{onClick:()=>e("/dashboard"),className:"mt-6 rounded-lg bg-primary px-5 py-2.5 text-sm font-medium text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all",children:"Go to Dashboard"})]})}const Ty="camstack:dashboard-layout",pi={version:1,widgets:[]};function a6(){try{const e=localStorage.getItem(Ty);if(!e)return pi;const t=JSON.parse(e);return t&&t.version===1&&Array.isArray(t.widgets)?{version:1,widgets:t.widgets}:pi}catch{return pi}}function i6(e){try{localStorage.setItem(Ty,JSON.stringify(e))}catch{}}function l6(){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 c6(){const[e,t]=_(a6),[n,o]=_(!1),s=px(),a=U(()=>s.filter(d=>d.hosts.includes("dashboard")),[s]),i=q(d=>{t(d),i6(d)},[]),l=q(d=>{i({version:1,widgets:[...e.widgets,d]})},[e,i]),c=q(d=>{i({version:1,widgets:e.widgets.filter(f=>f.instanceId!==d)})},[e,i]);return u("div",{className:"p-4",children:[u("div",{className:"flex items-center justify-between mb-4",children:[r("h1",{className:"text-lg font-semibold text-foreground",children:"Dashboard"}),u("button",{onClick:()=>o(!0),className:"flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors",children:[r(ut,{className:"h-3.5 w-3.5"}),"Add widget"]})]}),e.widgets.length===0?r(d6,{onAdd:()=>o(!0)}):r("div",{className:"grid grid-cols-12 gap-3 auto-rows-[minmax(80px,_auto)]",children:e.widgets.map(d=>r(u6,{entry:d,onRemove:()=>c(d.instanceId)},d.instanceId))}),n&&r(f6,{widgets:a,onClose:()=>o(!1),onAdd:d=>{l(d),o(!1)}})]})}function d6({onAdd:e}){return u("div",{className:"flex flex-col items-center justify-center py-24 text-foreground-subtle",children:[r("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-surface border border-border mb-4",children:r(iy,{className:"h-8 w-8 text-foreground-subtle/40"})}),r("p",{className:"text-sm font-medium text-foreground/70",children:"Your dashboard is empty"}),r("p",{className:"text-xs text-foreground-subtle mt-1 mb-4",children:"Add widgets to monitor your cameras and system"}),u("button",{onClick:e,className:"flex items-center gap-1.5 rounded-lg bg-primary px-4 py-2 text-xs font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all",children:[r(ut,{className:"h-3.5 w-3.5"}),"Add your first widget"]})]})}function u6({entry:e,onRemove:t}){const n=p6(e.columns),o=Math.max(1,Math.min(12,e.rows));return u("div",{className:"relative group rounded-lg border border-border bg-surface overflow-hidden flex flex-col",style:{gridColumn:`span ${n} / span ${n}`,gridRow:`span ${o} / span ${o}`},children:[r("button",{type:"button",onClick:t,title:"Remove widget",className:"absolute right-1.5 top-1.5 z-10 inline-flex h-5 w-5 items-center justify-center rounded-md border border-border/60 bg-surface/80 text-foreground-subtle opacity-0 group-hover:opacity-100 hover:bg-danger/10 hover:text-danger hover:border-danger/40 transition-all",children:r(Ve,{className:"h-3 w-3"})}),r("div",{className:"flex-1 min-h-0 overflow-auto p-2",children:r(at,{widgetId:e.widgetId,host:"dashboard",instanceId:e.instanceId,config:e.config,deviceId:e.deviceId,size:e.size,columns:e.columns,rows:e.rows})})]})}function p6(e){return!Number.isFinite(e)||e<1?6:Math.min(12,Math.floor(e))}function f6({widgets:e,onClose:t,onAdd:n}){const[o,s]=_(null);return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:t,children:u("div",{className:"w-full max-w-2xl rounded-xl border border-border bg-surface p-5 shadow-2xl shadow-black/20",onClick:a=>a.stopPropagation(),children:[u("div",{className:"flex items-center justify-between mb-4",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:o?`Configure: ${o.label}`:"Add widget"}),r("button",{onClick:t,className:"p-1 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",children:r(Ve,{className:"h-4 w-4"})})]}),o===null?r(m6,{widgets:e,onSelect:s}):r(h6,{widget:o,onCancel:()=>s(null),onAdd:n})]})})}function m6({widgets:e,onSelect:t}){return e.length===0?r("div",{className:"text-center py-8 text-xs text-foreground-subtle italic",children:"No dashboard-host widgets registered. Make sure the contributing addons are enabled and have rebuilt their widget bundles."}):r("div",{className:"grid grid-cols-2 gap-2 max-h-96 overflow-auto",children:e.map(n=>u("button",{onClick:()=>t(n),className:"flex flex-col rounded-lg border border-border p-3 text-left hover:bg-surface-hover hover:border-primary/30 transition-all group",children:[r("span",{className:"text-xs font-medium text-foreground block",children:n.label}),r("span",{className:"text-[10px] text-foreground-subtle truncate",title:n.widgetId,children:n.widgetId}),n.description&&r("span",{className:"text-[10px] text-foreground-subtle mt-1 line-clamp-2",children:n.description})]},n.widgetId))})}function h6({widget:e,onCancel:t,onAdd:n}){const[o,s]=_(e.defaultSize),[a,i]=_(e.defaultColumns),[l,c]=_(e.defaultRows),[d,f]=_(null),{data:p}=Xn({},{enabled:e.requires.deviceContext,staleTime:3e4}),m=!e.requires.deviceContext||d!==null&&d>0,h=()=>{if(!m)return;const g={instanceId:l6(),widgetId:e.widgetId,size:o,columns:a,rows:l,...e.requires.deviceContext&&d!==null?{deviceId:d}:{}};n(g)};return u("div",{className:"space-y-3",children:[u("div",{children:[r("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:"Size"}),r("div",{className:"flex items-center gap-1",children:e.allowedSizes.map(g=>r("button",{onClick:()=>s(g),className:`px-3 py-1 rounded-md text-[11px] font-medium border transition-colors ${o===g?"bg-primary/10 text-primary border-primary/30":"border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground"}`,children:g.toUpperCase()},g))})]}),u("div",{className:"grid grid-cols-2 gap-3",children:[r(rp,{label:"Columns (1-12)",value:a,min:1,max:12,onChange:i}),r(rp,{label:"Rows (1-12)",value:l,min:1,max:12,onChange:c})]}),e.requires.deviceContext&&u("div",{children:[r("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:"Device"}),u("select",{value:d??"",onChange:g=>f(g.target.value===""?null:Number(g.target.value)),className:"w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none",children:[r("option",{value:"",children:"— select a device —"}),(p??[]).map(g=>u("option",{value:g.id,children:[g.name??g.stableId," (#",g.id,")"]},g.id))]})]}),u("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-border",children:[r("button",{onClick:t,className:"px-3 py-1.5 rounded-md text-xs font-medium border border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors",children:"Back"}),r("button",{disabled:!m,onClick:h,className:"px-3 py-1.5 rounded-md text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Add to dashboard"})]})]})}function rp({label:e,value:t,min:n,max:o,onChange:s}){return u("div",{children:[r("label",{className:"block text-[11px] font-medium text-foreground-subtle mb-1",children:e}),r("input",{type:"number",min:n,max:o,value:t,onChange:a=>{const i=Number(a.target.value);Number.isFinite(i)&&s(Math.max(n,Math.min(o,Math.floor(i))))},className:"w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none"})]})}function g6(){return r(c6,{})}function un({icon:e,title:t,subtitle:n,actions:o,children:s}){return u("div",{className:"p-6 space-y-4",children:[u("div",{className:"flex items-center justify-between gap-4",children:[u("div",{className:"min-w-0",children:[u("h1",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e&&r(e,{className:"h-4 w-4 text-foreground-subtle"}),t]}),n&&r("p",{className:"text-xs text-foreground-subtle mt-0.5",children:n})]}),o&&r("div",{className:"shrink-0 flex items-center gap-2",children:o})]}),s]})}const op=["camera","hub","nvr","light","siren","switch","sensor","thermostat","button","generic"];function b6(){const{t:e}=Rt(),t=Je(),n=Le();yt(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]),yt(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped"]);const{data:o}=Xn({},{staleTime:3e4}),{data:s}=sa(void 0,{staleTime:3e4}),a=U(()=>o??[],[o]),{activeDevices:i,orphanDevices:l}=U(()=>{const h=new Set((s??[]).map(k=>k.addonId)),g=k=>typeof k.addonId=="string"&&k.addonId.length>0&&!h.has(k.addonId),b=new Set;for(const k of a)g(k)&&b.add(k.id);const x=new Set(b),v=new Map;for(const k of a)v.set(k.id,k);const w=(k,S=0)=>{if(S>32)return!1;if(b.has(k.id))return!0;if(k.parentDeviceId==null)return!1;const M=v.get(k.parentDeviceId);return M?w(M,S+1):!1};for(const k of a)w(k)&&x.add(k.id);const y=[],N=[];for(const k of a)x.has(k.id)?N.push(k):y.push(k);return{activeDevices:y,orphanDevices:N}},[a,s]),c=U(()=>{const h=new Map;for(const g of a)h.set(g.id,{id:g.id,name:g.name??g.stableId??`#${String(g.id)}`});return h},[a]),d=q(h=>c.get(h)??null,[c]),f=U(()=>(s??[]).map(h=>({id:h.addonId,name:h.name??h.addonId,icon:r(an,{type:h.addonId,size:"sm"})})),[s]),p=q(h=>r(an,{type:h,size:"sm"}),[]),m=q(h=>t(`/devices/${String(h)}`),[t]);return u(un,{icon:hr,title:e("nav.devices","Devices"),children:[r(so,{devices:i,trpc:n.trpcClient,filters:{types:op,addons:f},resolveIntegrationIcon:p,resolveParent:d,onNavigate:m}),l.length>0&&u("div",{className:"mt-6 space-y-2",children:[u("div",{className:"flex items-baseline gap-2",children:[r(xt,{className:"h-3.5 w-3.5 text-warning shrink-0"}),r("h2",{className:"text-sm font-semibold text-foreground",children:"Orphan devices"}),u("span",{className:"text-[10px] text-foreground-subtle",children:[l.length," device",l.length===1?"":"s"," pointing at integrations no longer registered"]})]}),u("div",{className:"rounded-lg border border-warning/30 bg-warning/5 p-2",children:[r("p",{className:"text-[11px] text-foreground-subtle px-2 pb-2",children:"These devices reference an addonId that has no matching integration. Delete them, or re-install the missing integration to bring them back online. The provider scope (`addonId`) shown beside each row is what's failing to resolve."}),r(so,{devices:l,trpc:n.trpcClient,filters:{types:op,addons:f},urlScope:"nested",lsKey:"devices:orphan",resolveIntegrationIcon:p,resolveParent:d,onNavigate:m})]})]})]})}function x6({onSelect:e,onClose:t,pendingAddonId:n=null}){const{t:o}=Rt(),s=Je(),{data:a,isLoading:i}=Og();if(i)return r("div",{className:"space-y-2 p-2",children:[1,2,3].map(c=>r("div",{className:"h-14 rounded-lg bg-surface animate-pulse"},c))});const l=n!==null;return u("div",{className:"space-y-2",children:[(a??[]).map(c=>{const d=c.instanceMode==="unique"&&c.existingInstances.length>0,f=n===c.addonId,p=l;return u("button",{disabled:p,onClick:()=>{if(!p)if(d){const m=c.existingInstances[0].id;t(),s(`/integrations/${m}`)}else e(c.addonId,c.instanceMode,c.discoveryMode,c.name)},className:"flex w-full items-center gap-3 rounded-lg border border-border bg-surface p-3 text-left hover:border-foreground-subtle/30 transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border",children:[c.iconUrl?r("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0",style:{backgroundColor:`${c.color}15`},children:r("img",{src:c.iconUrl,alt:"",className:"h-5 w-5"})}):r("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0",style:{backgroundColor:`${c.color}15`},children:r("span",{className:"text-sm",style:{color:c.color},children:"◉"})}),u("div",{className:"flex-1 min-w-0",children:[r("p",{className:"text-xs font-semibold text-foreground",children:c.name}),c.description&&r("p",{className:"text-[10px] text-foreground-subtle mt-0.5 truncate",children:c.description})]}),f?r(Pe,{className:"h-4 w-4 animate-spin text-primary flex-shrink-0"}):d?u("span",{className:"flex items-center gap-1 text-[10px] font-medium text-foreground-subtle",children:[r(Nt,{className:"h-3 w-3"}),o("integrations.manage")]}):r(It,{className:"h-4 w-4 text-foreground-subtle flex-shrink-0"})]},c.addonId)}),(a??[]).length===0&&r("div",{className:"py-8 text-center text-xs text-foreground-subtle",children:o("integrations.noProviders")})]})}function y6(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function sp(e,t){if(e!==void 0)return t&&y6(e)?t(e):e}function v6({section:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i,onAction:l}){const[c,d]=_(e.defaultCollapsed??!1),f=e.style==="accordion";if(e.fields.reduce((b,x)=>b+(Mc(x,t,e.fields)?1:0),0)===0)return null;const m=e.columns??2,h=m===1?"grid-cols-1":m===3?"grid-cols-1 @[420px]:grid-cols-2 @[680px]:grid-cols-3":m===4?"grid-cols-1 @[420px]:grid-cols-2 @[900px]:grid-cols-4":"grid-cols-1 @[480px]:grid-cols-2",g=!e.title&&!e.description;return u("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[!g&&u("div",{className:["flex items-center justify-between mb-2",f?"cursor-pointer":""].join(" "),onClick:f?()=>d(b=>!b):void 0,children:[u("div",{children:[e.title&&r("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:sp(e.title,s)}),e.description&&r("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:sp(e.description,s)})]}),f&&r("span",{className:"text-foreground-subtle text-xs ml-2",children:c?"▸":"▾"})]}),!c&&r("div",{className:`grid ${h} gap-x-3 gap-y-2.5`,children:e.fields.map(b=>r(er,{field:b,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,externalProbe:i?.[b.key],allFields:e.fields,onAction:l},b.key))})]})}function wn({schema:e,values:t,onChange:n,disabled:o,translationFn:s,onTestField:a,probeResults:i,onClearProbe:l,onAction:c}){const d=(f,p)=>{n({...t,[f]:p}),l?.(f)};return r("div",{className:"space-y-4",children:e.sections.map((f,p)=>r(v6,{section:f,values:t,onChange:d,disabled:o,translationFn:s,onTestField:a,probeResults:i,onAction:c},`${f.id}-${p}`))})}function w6({addonId:e,configSchema:t,onSave:n,onBack:o}){const{t:s}=Rt(),[a,i]=_(""),[l,c]=_({}),[d,f]=_(null),p=zg({onSuccess:m=>f(m),onError:m=>f({success:!1,error:String(m)})});return u("div",{className:"space-y-4",children:[u("div",{children:[r("label",{className:"block text-[11px] font-medium text-foreground mb-1",children:s("integrations.integrationName")}),r("input",{type:"text",value:a,onChange:m=>i(m.target.value),placeholder:s("integrations.integrationNamePlaceholder"),className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:border-primary/50"})]}),t&&r(wn,{schema:t,values:l,onChange:c}),d&&r("div",{className:`rounded-lg border px-3 py-2 text-xs ${d.success?"border-success/30 bg-success/5 text-success":"border-danger/30 bg-danger/5 text-danger"}`,children:d.success?s("integrations.connectionSuccess"):`${s("integrations.errorPrefix")} ${d.error}`}),u("div",{className:"flex items-center justify-between pt-2",children:[r("button",{onClick:o,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors",children:s("integrations.back")}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>p.mutate({addonId:e,settings:l}),disabled:p.isPending,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:p.isPending?s("integrations.testing"):s("integrations.testConnection")}),r("button",{onClick:()=>n({name:a,config:l}),disabled:!a.trim(),className:"rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:s("integrations.forward")})]})]})]})}function N6({providerId:e,onImport:t,onSkip:n}){const{t:o}=Rt(),[s,a]=_(new Set),i=gc(),l=i.data,c=i.isPending||!i.data&&!i.isError;Z(()=>{e&&(i.isPending||i.data||i.mutate({addonId:e}))},[e,i]);function d(p){a(m=>{const h=new Set(m);return h.has(p)?h.delete(p):h.add(p),h})}if(c)return u("div",{className:"flex flex-col items-center py-12",children:[r("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"}),r("p",{className:"mt-3 text-xs text-foreground-subtle",children:o("integrations.searchingDevices")})]});const f=l??[];return u("div",{className:"space-y-4",children:[r("p",{className:"text-xs text-foreground-subtle",children:f.length>0?o("integrations.foundDevices",{count:f.length}):o("integrations.noDevicesFound")}),f.length>0&&r("div",{className:"space-y-1.5 max-h-64 overflow-y-auto",children:f.map(p=>{const m=p.stableId,h=p.suggestedName??m,g=s.has(m);return u("button",{onClick:()=>d(m),className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${g?"border-primary/40 bg-primary/5":"border-border bg-surface hover:border-foreground-subtle/30"}`,children:[r("div",{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${g?"border-primary bg-primary":"border-border"}`,children:g&&r(Mt,{className:"h-3 w-3 text-primary-foreground"})}),r(hr,{className:"h-3.5 w-3.5 text-foreground-subtle flex-shrink-0"}),r("span",{className:"text-xs font-medium text-foreground truncate",children:h})]},m)})}),u("div",{className:"flex items-center justify-between pt-2",children:[r("button",{onClick:n,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors",children:o("integrations.skip")}),f.length>0&&u("button",{onClick:()=>t(Array.from(s)),disabled:s.size===0,className:"rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:[o("integrations.importSelected")," (",s.size,")"]})]})]})}function k6(e){const t=n=>{if(n.type==="separator"||n.type==="info"||n.type==="button")return n;if(n.type==="group")return{...n,fields:n.fields.map(i=>t(i))};const o=n,{value:s,...a}=o;return a};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(n=>({...n,fields:n.fields.map(t)}))}}function S6({open:e,onClose:t}){const{t:n}=Rt(),o=Je(),s=ke(),[a,i]=_("picker"),[l,c]=_(null),[d,f]=_(null),[p,m]=_("manual"),{data:h}=uc({addonId:l??"",nodeId:"hub"},{enabled:l!=null}),g=U(()=>h?k6(h):null,[h]),b=Lg({onSuccess:()=>s.invalidateQueries({queryKey:[["integrations"]]})}),x=gc(),v=x.data;Z(()=>{a!=="discovery"||!d||!l||x.isPending||x.data||x.mutate({addonId:l})},[a,d,l,x]);const w=Pg({onSuccess:()=>s.invalidateQueries({queryKey:[["deviceManager"]]})});async function y(R,A,L,D){if(!b.isPending){if(c(R),m(L),A==="unique"){try{const T=await b.mutateAsync({addonId:R,name:D,settings:{}});t(),M(),o(`/integrations/${T.id}`)}catch{}return}i("config")}}async function N(R){if(l)try{const A=await b.mutateAsync({addonId:l,name:R.name,settings:R.config});f(A.id),p==="auto"||p==="both"?i("discovery"):S(A.id)}catch{}}async function k(R){if(l){for(const A of R){const L=v?.find(D=>D.stableId===A);L&&await w.mutateAsync({addonId:l,candidate:L})}S()}}function S(R){const A=R??d??l;t(),M(),A&&o(`/integrations/${A}`)}function M(){i("picker"),c(null),f(null),m("manual")}function P(){t(),M()}if(!e)return null;const I={picker:n("integrations.newIntegration"),config:n("integrations.configureIntegration"),discovery:n("integrations.importDevices")},z=b.isPending,$=z?l:null,O=b.error;return u("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[r("div",{className:"absolute inset-0 bg-black/60",onClick:z?void 0:P}),u("div",{className:"relative z-10 w-full max-w-lg rounded-xl border border-border bg-background shadow-2xl",children:[u("div",{className:"flex items-center justify-between border-b border-border px-5 py-4",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:I[a]}),r("button",{onClick:P,disabled:z,className:"rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:r(Ve,{className:"h-4 w-4"})})]}),u("div",{className:"relative px-5 py-4",children:[O&&!z&&r("div",{className:"mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:O instanceof Error?O.message:String(O)}),a==="picker"&&r(x6,{onSelect:y,onClose:P,pendingAddonId:$}),a==="config"&&l&&r(w6,{addonId:l,configSchema:g??null,onSave:N,onBack:()=>i("picker")}),a==="discovery"&&d&&r(N6,{providerId:d,onImport:k,onSkip:S}),z&&u("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background/85 backdrop-blur-sm",children:[r(Pe,{className:"h-6 w-6 animate-spin text-primary"}),r("p",{className:"text-xs font-medium text-foreground",children:n("integrations.creating",{defaultValue:"Creating integration…"})}),r("p",{className:"text-[10px] text-foreground-subtle",children:n("integrations.creatingHint",{defaultValue:"Waiting for the addon to restart and register"})})]})]})]})]})}const ap={running:{bg:"bg-success/10",text:"text-success",dot:"bg-success",label:"Running"},stopped:{bg:"bg-foreground-subtle/10",text:"text-foreground-subtle",dot:"bg-foreground-subtle",label:"Stopped"},error:{bg:"bg-danger/10",text:"text-danger",dot:"bg-danger",label:"Error"},online:{bg:"bg-success/10",text:"text-success",dot:"bg-success",label:"Online"},offline:{bg:"bg-foreground-subtle/10",text:"text-foreground-subtle",dot:"bg-foreground-subtle",label:"Offline"},idle:{bg:"bg-info/10",text:"text-info",dot:"bg-info",label:"Idle"},disabled:{bg:"bg-warning/10",text:"text-warning",dot:"bg-warning",label:"Disabled"},enabled:{bg:"bg-success/10",text:"text-success",dot:"bg-success",label:"Enabled"}};function ka({status:e}){const t=ap[e]??ap.stopped;return u("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-medium ${t.bg} ${t.text}`,children:[r("span",{className:`h-1.5 w-1.5 rounded-full ${t.dot}`}),t.label]})}const fi="px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle";function C6({integrations:e,expandedAddonId:t,onToggleExpand:n,onOpenSettings:o,renderExpanded:s}){const a=q(i=>n(i),[n]);return r("div",{className:"overflow-hidden rounded-lg border border-border bg-surface",children:u("table",{className:"w-full table-fixed text-xs",children:[r("thead",{className:"bg-surface-hover/40",children:u("tr",{children:[r("th",{className:W(fi,"w-[60%]"),children:"Integration"}),r("th",{className:W(fi,"w-[15%]"),children:"Devices"}),r("th",{className:W(fi,"w-[25%]"),children:"Status"})]})}),r("tbody",{children:e.map(i=>{const l=t===i.addonId;return r(M6,{integration:i,isExpanded:l,onClick:a,onOpenSettings:o,renderExpanded:s},i.id)})})]})})}function M6({integration:e,isExpanded:t,onClick:n,onOpenSettings:o,renderExpanded:s}){const a=q(c=>{c.stopPropagation(),o(e.id)},[e.id,o]),i=q(()=>{n(e.addonId)},[e.addonId,n]),l=q(c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),i())},[i]);return u(xe,{children:[u("tr",{role:"button",tabIndex:0,"aria-expanded":t,className:W("cursor-pointer border-t border-border transition-colors hover:bg-surface-hover","focus:outline-none focus-visible:ring-1 focus-visible:ring-primary/40",t&&"bg-surface-hover/60"),onClick:i,onKeyDown:l,children:[r("td",{className:"px-3 py-2.5",children:u("div",{className:"flex items-center gap-2.5",children:[t?r(wt,{className:"h-3.5 w-3.5 flex-shrink-0 text-foreground-subtle"}):r(It,{className:"h-3.5 w-3.5 flex-shrink-0 text-foreground-subtle"}),r(an,{type:e.addonId,size:"sm"}),u("div",{className:"flex min-w-0 flex-col",children:[r("span",{className:"truncate text-xs font-semibold text-foreground",children:e.name}),r("span",{className:"truncate text-[10px] text-foreground-subtle",children:e.addonId})]})]})}),u("td",{className:"px-3 py-2.5 text-[11px] text-foreground-subtle",children:[e.deviceCount," device",e.deviceCount!==1?"s":""]}),r("td",{className:"px-3 py-2.5",children:u("div",{className:"flex items-center justify-between gap-2",children:[r(ka,{status:e.status}),u("button",{type:"button",onClick:a,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary",title:"Open integration settings",children:[r(Nt,{className:"h-3 w-3"}),"Settings"]})]})})]}),t&&r("tr",{className:"border-t border-border bg-surface",children:r("td",{colSpan:3,className:"px-3 py-3",children:s(e.addonId)})})]})}function I6(e){if(!e.enabled)return"disabled";switch(e.processState){case"running":return"running";case"stopped":case"crashed":case"unknown":default:return"stopped"}}const Zo="expand";function A6(){const{t:e}=Rt(),t=Je(),n=Le(),[o]=ha(),[s,a]=_(!1),i=q(()=>a(!0),[]),l=q(()=>a(!1),[]);yt(["integrations"],["integration.enabled","integration.disabled","integration.deleted","provider.started","provider.stopped","addon.installed","addon.uninstalled","addon.started","addon.stopped","addon.updated"]),yt(["deviceManager"],["device.registered","device.unregistered","device.online","device.offline","device.disabled","device.enabled"]);const{data:c,isLoading:d,refetch:f}=sa(void 0,{staleTime:3e4}),{data:p,isLoading:m,refetch:h}=Xn({},{staleTime:3e4}),g=U(()=>p??[],[p]),b=U(()=>c??[],[c]),x=U(()=>{const R=new Map;for(const A of g)R.set(A.id,{id:A.id,name:A.name??A.stableId??`#${String(A.id)}`});return R},[g]),v=U(()=>{const R=new Map;for(const A of g){if(A.parentDeviceId!==null&&A.parentDeviceId!==void 0&&!!A.role)continue;const D=A.addonId??"";D&&R.set(D,(R.get(D)??0)+1)}return R},[g]),w=U(()=>b.map(R=>({id:R.id,addonId:R.addonId,name:R.name,enabled:R.enabled,status:I6(R),deviceCount:v.get(R.addonId)??0})),[b,v]),y=o.get(Zo),N=q(R=>{const A=new URLSearchParams(window.location.search);A.get(Zo)===R?A.delete(Zo):A.set(Zo,R);const D=A.toString(),T=`${window.location.pathname}${D?`?${D}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",T),window.dispatchEvent(new PopStateEvent("popstate"))},[]),k=q(R=>t(`/integrations/${R}`),[t]),S=q(R=>x.get(R)??null,[x]),M=q(R=>r(an,{type:R,size:"sm"}),[]),P=q(R=>t(`/devices/${String(R)}`),[t]),I=q(R=>r(so,{devices:g,trpc:n.trpcClient,forceAddon:R,urlScope:"nested",lsKey:`integrations:nested:${R}`,resolveIntegrationIcon:M,resolveParent:S,onNavigate:P}),[g,n.trpcClient,M,S,P]),z=q(()=>{f(),h()},[f,h]),$=d||m,O=b.length>0;return u(un,{icon:Yc,title:e("nav.integrations","Integrations"),actions:u(xe,{children:[r("button",{onClick:z,disabled:$,className:"flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",title:"Refresh",children:r(pt,{className:W("h-3.5 w-3.5",$&&"animate-spin")})}),u("button",{onClick:i,className:"flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm",children:[r(ut,{className:"h-3.5 w-3.5"}),"New Integration"]})]}),children:[$&&r("div",{className:"space-y-2",children:[1,2,3].map(R=>r("div",{className:"h-12 rounded-lg border border-border bg-surface animate-pulse"},R))}),!$&&!O&&u("div",{className:"flex flex-col items-center py-20 text-foreground-subtle",children:[r("p",{className:"text-sm",children:"No integrations configured."}),r("p",{className:"text-xs mt-1",children:'Click "New Integration" to connect cameras and devices.'})]}),!$&&O&&r(C6,{integrations:w,expandedAddonId:y,onToggleExpand:N,onOpenSettings:k,renderExpanded:I}),r(S6,{open:s,onClose:l})]})}function Ry(e){const t=[];for(const n of e)n.type==="probe"&&t.push(n.key),n.type==="group"&&"fields"in n&&t.push(...Ry(n.fields));return t}function P6(e,t,n){const[o,s]=_("idle"),[a,i]=_({}),l=U(()=>{const p=[];for(const m of e.sections)p.push(...Ry(m.fields));return p},[e]),c=l.length>0&&n!==void 0,d=q(p=>{i(m=>{if(!m[p])return m;const h={...m};return delete h[p],h})},[]),f=q(async()=>{if(!n)return;const p=l.filter(b=>{const x=t[b];return x!=null&&String(x).trim()!==""});if(p.length===0)return;s("testing");const m={};for(const b of p)m[b]={status:"probing"};i(m);const h=await Promise.allSettled(p.map(async b=>{try{const x=await n(b,t[b]);return{key:b,result:x}}catch(x){const w={status:"error",error:x instanceof Error?x.message:String(x)};return{key:b,result:w}}})),g={};for(const b of h)if(b.status==="fulfilled"){const{key:x,result:v}=b.value;g[x]={status:v.status==="ok"?"ok":"error",result:v}}i(g),s("idle")},[n,l,t]);return{testAllStatus:o,hasProbeFields:c,probeResults:a,handleTestAll:f,clearProbeResult:d}}function Oy(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(...Oy(n.fields));return t}function mi(e){return e==null?!0:typeof e=="string"?e.trim()==="":!1}function cl(e,t={}){for(const n of e){if(n.type==="group"&&"fields"in n){cl(n.fields,t);continue}"key"in n&&n.key&&"default"in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function ip(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function E6({open:e,integrationId:t,addonId:n,onClose:o}){const{t:s}=Rt(),a=ke(),[i,l]=_({}),[c,d]=_(!1),[f,p]=_(null),[m,h]=_(ip),g=Eg({addonId:n,type:st.Camera},{enabled:e}),b=g.data??null;Z(()=>{if(e){const A=b?cl(b.sections.flatMap(L=>L.fields)):{};l(A),h(ip()),d(!1),p(null)}},[e,t,b]);const x=U(()=>({...i,_probeRequestId:m}),[i,m]),v=$g({onSuccess:()=>{a.invalidateQueries({queryKey:[["deviceManager"]]})}}),w=bc(),y=q(async(A,L)=>{d(!0);const D=await w.mutateAsync({addonId:n,type:st.Camera,key:A,value:L,formValues:x});return D.status==="ok"&&D.suggestedValues&&l(T=>{let B=!1;const F={...T};for(const[j,H]of Object.entries(D.suggestedValues??{}))mi(T[j])&&!mi(H)&&(F[j]=H,B=!0);return B?F:T}),D},[w,n,x]),{testAllStatus:N,hasProbeFields:k,probeResults:S,handleTestAll:M,clearProbeResult:P}=P6(b??{sections:[]},i,y);async function I(A){p(null);try{if(await v.mutateAsync({addonId:n,type:st.Camera,config:i}),A){const L=b?cl(b.sections.flatMap(D=>D.fields)):{};l(L)}else o()}catch(L){p(L instanceof Error?L.message:String(L))}}if(!e)return null;const $=Oy((b?.sections??[]).flatMap(A=>A.fields)).filter(A=>mi(i[A])),O=$.length===0,R=!g.isLoading&&(g.isError||b===null);return u("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[r("div",{className:"absolute inset-0 bg-black/60",onClick:o}),u("div",{className:"relative z-10 flex w-full max-w-2xl flex-col max-h-[90vh] rounded-xl border border-border bg-background shadow-2xl",children:[u("div",{className:"flex items-center justify-between border-b border-border px-5 py-4 shrink-0",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:s("integrations.addDevice")}),r("button",{onClick:o,className:"rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:r(Ve,{className:"h-4 w-4"})})]}),r("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-3",children:g.isLoading?r("div",{className:"flex items-center justify-center py-8",children:r(Pe,{className:"h-5 w-5 animate-spin text-primary"})}):R?u("div",{className:"flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3",children:[r(xt,{className:"h-4 w-4 text-destructive mt-0.5 shrink-0"}),u("div",{className:"space-y-1",children:[r("p",{className:"text-xs font-medium text-destructive",children:"Provider unavailable"}),u("p",{className:"text-xs text-foreground-subtle",children:["The addon ",r("span",{className:"font-mono",children:n})," is not ready or does not support manual device creation. Check that the integration is online and try again."]})]})]}):r(wn,{schema:b,values:i,onChange:l,onTestField:y,probeResults:S,onClearProbe:P})}),!R&&!g.isLoading&&u("div",{className:"border-t border-border bg-surface/50 shrink-0",children:[u("button",{type:"button",onClick:()=>d(A=>!A),className:"flex w-full items-center justify-between px-5 py-2 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:[u("span",{className:"flex items-center gap-2",children:[r(Ze,{className:"h-3.5 w-3.5"}),"Test logs",r("span",{className:"font-mono text-[9px] opacity-60",children:m.slice(0,14)})]}),r(wt,{className:`h-3.5 w-3.5 transition-transform ${c?"rotate-180":""}`})]}),c&&r("div",{className:"border-t border-border max-h-64 overflow-hidden",children:r(Ut,{addonId:n,requestId:m,limit:50,maxHeight:"max-h-64",showFilters:!1,showScope:!1,className:"border-0 rounded-none"})})]}),!R&&!g.isLoading&&(f||$.length>0)&&r("div",{className:"border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0",children:u("div",{className:"flex items-start gap-2",children:[r(xt,{className:"h-3.5 w-3.5 text-destructive mt-0.5 shrink-0"}),r("p",{className:"text-[11px] text-destructive",children:f||`Required: ${$.join(", ")}`})]})}),u("div",{className:"flex items-center justify-between border-t border-border px-5 py-3 shrink-0",children:[u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:o,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors",children:s("integrations.cancel")}),!R&&k&&u("button",{type:"button",onClick:M,disabled:N==="testing",className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:[N==="testing"?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):r(Fn,{className:"h-3.5 w-3.5"}),"Test All"]})]}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>I(!0),disabled:R||!O||v.isPending,className:"rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:s("integrations.saveAndNew")}),r("button",{onClick:()=>I(!1),disabled:R||!O||v.isPending,className:"rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50",children:v.isPending?s("integrations.saving"):s("integrations.save")})]})]})]})]})}function $6(){const{t:e}=Rt(),{integrationId:t}=Bc(),n=ke(),o=Je(),s=Le(),[a,i]=_(!1),[l,c]=_(!1),[d,f]=_(!1),[p,m]=_(!1),{data:h,isLoading:g}=_g({id:t??""},{enabled:!!t}),{data:b}=uc({addonId:h?.addonId??"",nodeId:"hub"},{enabled:!!h?.addonId}),x=b!=null&&Array.isArray(b.sections)&&b.sections.some(O=>O.fields.length>0),{data:v}=Xn({},{refetchInterval:5e3}),w=[["integrations","get"],{input:{id:t??""},type:"query"}],y=Tg({onMutate:async O=>{await n.cancelQueries({queryKey:w});const R=n.getQueryData(w);return R!=null&&n.setQueryData(w,{...R,enabled:O.enabled}),{previous:R}},onError:(O,R,A)=>{const L=A;L?.previous!=null&&n.setQueryData(w,L.previous)},onSettled:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),N=Rg({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]}),f(!1),o("/integrations")}}),k=oa({onSuccess:()=>{n.invalidateQueries({queryKey:[["integrations"]]}),n.invalidateQueries({queryKey:[["deviceManager"]]})}}),S=U(()=>v??[],[v]),M=U(()=>{const O=new Map;for(const R of S)O.set(R.id,{id:R.id,name:R.name??R.stableId??`#${String(R.id)}`});return O},[S]),P=q(O=>M.get(O)??null,[M]),I=q(O=>r(an,{type:O,size:"sm"}),[]),z=q(O=>o(`/devices/${String(O)}`),[o]),$=U(()=>{const O=h?.addonId;if(!O)return 0;let R=0;for(const A of S)A.addonId!==O||A.parentDeviceId!==null&&A.parentDeviceId!==void 0&&A.role||(R+=1);return R},[S,h?.addonId]);return g?u("div",{className:"p-6",children:[r("div",{className:"h-16 rounded-lg bg-surface animate-pulse mb-4"}),r("div",{className:"h-40 rounded-lg bg-surface animate-pulse"})]}):h?u("div",{className:"p-6 space-y-5",children:[r(Yl,{items:[{label:"Integrations",onClick:()=>o("/integrations")},{label:h.name}]}),u("div",{className:"flex items-center justify-between",children:[u("div",{className:"flex items-center gap-3",children:[r("img",{src:`/api/addon-assets/${h.addonId}/assets/icon.svg`,alt:"",className:"h-8 w-8 rounded-lg",onError:O=>{O.target.style.display="none"}}),u("div",{children:[r("h1",{className:"text-lg font-semibold text-foreground",children:h.name}),u("p",{className:"text-[11px] text-foreground-subtle mt-0.5",children:[h.addonId," · ",$," ",e("integrations.devices")]})]})]}),u("div",{className:"flex items-center gap-3",children:[u("div",{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${y.isPending?"opacity-60":""} ${h.enabled?"border-success/30 bg-success/5":"border-border bg-surface"}`,title:e("integrations.toggleHint",{defaultValue:"Click to toggle"}),children:[r(ql,{checked:h.enabled,onCheckedChange:O=>y.mutate({id:t,enabled:O}),disabled:y.isPending,"aria-label":h.enabled?"Disable integration":"Enable integration"}),r("span",{className:`text-[11px] font-medium ${h.enabled?"text-success":"text-foreground-subtle"}`,children:h.enabled?"Enabled":"Disabled"}),y.isPending&&r(Pe,{className:"h-3 w-3 animate-spin text-foreground-subtle"})]}),x&&u("button",{onClick:()=>c(!0),className:"flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:[r(Nt,{className:"h-3 w-3"}),e("integrations.config")]}),u("button",{onClick:()=>m(!0),className:"flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",title:e("integrations.logs",{defaultValue:"View logs"}),children:[r(Ze,{className:"h-3 w-3"}),e("integrations.logs",{defaultValue:"Logs"})]}),r(Mx,{label:"Restart",icon:pt,title:`Restart "${h.name}"?`,description:`Restarting the addon will briefly disconnect every device backed by it (${$} active). Streams will reconnect automatically.`,confirmLabel:"Restart",triggerVariant:"outline",confirmVariant:"danger",disabled:k.isPending,action:()=>k.mutateAsync({addonId:h.addonId})}),u("button",{onClick:()=>f(!0),className:"flex items-center gap-1.5 rounded-lg border border-danger bg-danger/10 px-3 py-1.5 text-[11px] font-medium text-danger hover:bg-danger hover:text-background transition-colors",title:e("integrations.delete",{defaultValue:"Delete integration"}),children:[r(Ge,{className:"h-3 w-3"}),e("integrations.delete",{defaultValue:"Delete"})]})]})]}),r(so,{devices:S,trpc:s.trpcClient,defaultView:"cards",forceAddon:h.addonId,urlScope:"root",lsKey:`integration-detail:${h.addonId}`,resolveIntegrationIcon:I,resolveParent:P,onNavigate:z}),r("button",{onClick:()=>i(!0),className:"fixed bottom-6 right-6 flex h-12 w-12 items-center justify-center rounded-full bg-primary shadow-lg shadow-primary/30 hover:shadow-primary/40 transition-shadow",title:e("integrations.addDevice"),children:r(ut,{className:"h-5 w-5 text-primary-foreground"})}),a&&t&&r(E6,{open:a,integrationId:t,addonId:h.addonId,onClose:()=>i(!1)}),l&&r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>c(!1),children:u("div",{className:"rounded-xl border border-border bg-surface p-6 shadow-xl w-80",onClick:O=>O.stopPropagation(),children:[r("h2",{className:"text-sm font-semibold text-foreground mb-2",children:e("integrations.providerConfig")}),r("p",{className:"text-[11px] text-foreground-subtle",children:e("integrations.configComingSoon")}),r("button",{onClick:()=>c(!1),className:"mt-4 w-full rounded-lg bg-primary px-3 py-1.5 text-[11px] text-primary-foreground hover:bg-primary/90 transition-colors",children:"Close"})]})}),p&&r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onClick:()=>m(!1),children:u("div",{className:"flex flex-col rounded-xl border border-border bg-surface shadow-xl w-full max-w-5xl h-[80vh]",onClick:O=>O.stopPropagation(),children:[u("div",{className:"flex items-center justify-between border-b border-border px-4 py-2.5",children:[u("div",{className:"flex items-center gap-2 min-w-0",children:[r(Ze,{className:"h-4 w-4 text-primary shrink-0"}),r("h2",{className:"text-sm font-semibold text-foreground truncate",children:h.name}),u("span",{className:"text-[10px] text-foreground-subtle font-mono truncate",children:[h.addonId,t?` · ${t}`:""]})]}),r("button",{onClick:()=>m(!1),className:"flex h-7 w-7 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors","aria-label":"Close logs",children:r(Ve,{className:"h-4 w-4"})})]}),r("div",{className:"flex-1 min-h-0 overflow-hidden",children:r(Ut,{addonId:h.addonId,limit:200,maxHeight:"max-h-full",showScope:!1,className:"h-full border-0 rounded-none"})})]})}),d&&r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>!N.isPending&&f(!1),children:u("div",{className:"rounded-xl border border-border bg-background p-5 shadow-2xl w-96 space-y-3",onClick:O=>O.stopPropagation(),children:[u("div",{className:"flex items-start gap-3",children:[r("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-danger/10 shrink-0",children:r(xt,{className:"h-4 w-4 text-danger"})}),u("div",{className:"min-w-0",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:e("integrations.deleteTitle",{defaultValue:"Delete integration?"})}),r("p",{className:"mt-1 text-[11px] text-foreground-subtle",children:e("integrations.deleteWarning",{defaultValue:'This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.',name:h.name,count:$})})]})]}),N.error&&r("div",{className:"rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger",children:N.error instanceof Error?N.error.message:String(N.error)}),u("div",{className:"flex items-center justify-end gap-2 pt-1",children:[r("button",{onClick:()=>f(!1),disabled:N.isPending,className:"rounded-lg border border-border px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:e("integrations.cancel",{defaultValue:"Cancel"})}),r("button",{onClick:()=>N.mutate({id:t}),disabled:N.isPending,className:"inline-flex items-center gap-1.5 rounded-lg bg-danger px-3 py-1.5 text-[11px] font-medium text-background hover:bg-danger/90 transition-colors disabled:opacity-60 disabled:cursor-not-allowed",children:N.isPending?u(xe,{children:[r(Pe,{className:"h-3 w-3 animate-spin"}),e("integrations.deleting",{defaultValue:"Deleting…"})]}):u(xe,{children:[r(Ge,{className:"h-3 w-3"}),e("integrations.confirmDelete",{defaultValue:"Delete integration"})]})})]})]})})]}):u("div",{className:"flex flex-col items-center justify-center py-20 px-6 text-center gap-4",children:[r("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10",children:r(VL,{className:"h-6 w-6 text-foreground-subtle"})}),u("div",{className:"space-y-1 max-w-sm",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:e("integrations.integrationNotFound",{defaultValue:"Integration not found"})}),r("p",{className:"text-[11px] text-foreground-subtle",children:e("integrations.integrationNotFoundHint",{defaultValue:'The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.',id:t??""})})]}),u("button",{onClick:()=>o("/integrations"),className:"inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors",children:[r(Yx,{className:"h-3 w-3"}),e("integrations.backToList",{defaultValue:"Back to integrations"})]})]})}function _6({label:e,color:t,title:n,style:o}){return u("div",{className:"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 z-10 group cursor-pointer",style:o,title:n,children:[r("div",{className:"h-2.5 w-2.5 rounded-full border-2 border-background shadow-sm transition-transform group-hover:scale-150",style:{backgroundColor:t}}),n&&r("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-1.5 hidden group-hover:block z-20 pointer-events-none",children:u("div",{className:"bg-surface border border-border rounded px-2 py-1 text-[10px] text-foreground whitespace-nowrap shadow-lg",children:[r("span",{className:"inline-block h-1.5 w-1.5 rounded-full mr-1 align-middle",style:{backgroundColor:t}}),e]})})]})}const hi=36e5;function D6(e){return String(e).padStart(2,"0")}function L6(e){const t=new Date(e);return`${D6(t.getHours())}:00`}function T6({startMs:e,endMs:t,segments:n,events:o,playheadMs:s,onSeek:a}){const i=ne(null),l=t-e,c=q(h=>Math.max(0,Math.min(100,(h-e)/l*100)),[e,l]);function d(h){if(!i.current)return;const g=i.current.getBoundingClientRect(),b=Math.max(0,Math.min(1,(h.clientX-g.left)/g.width));a(Math.round(e+b*l))}const f=[],p=Math.floor(e/hi),m=Math.ceil(t/hi);for(let h=p;h<=m;h++){const g=h*hi;g<e||g>t||f.push({percent:c(g),label:L6(g)})}return u("div",{className:"select-none",children:[r("div",{className:"relative h-5 mb-1",children:f.map(({percent:h,label:g})=>r("span",{className:"absolute -translate-x-1/2 text-[10px] text-foreground-subtle",style:{left:`${h}%`},children:g},g))}),u("div",{ref:i,className:"relative h-8 rounded bg-surface-hover cursor-pointer overflow-hidden border border-border",onClick:d,onPointerMove:h=>{h.buttons===1&&d(h)},children:[n.map((h,g)=>{const b=c(h.startMs),x=c(h.endMs)-b;return r("div",{className:"absolute top-1 bottom-1 rounded-sm bg-success/60",style:{left:`${b}%`,width:`${Math.max(x,.1)}%`}},g)}),o.map(h=>r(_6,{label:h.label,color:h.color,title:`${h.label} — ${new Date(h.timestampMs).toLocaleTimeString()}`,style:{left:`${c(h.timestampMs)}%`}},h.id)),r("div",{className:"absolute top-0 bottom-0 w-0.5 bg-danger z-20 pointer-events-none",style:{left:`${c(s)}%`},children:r("div",{className:"absolute -top-0.5 left-1/2 -translate-x-1/2 w-2.5 h-2.5 bg-danger rotate-45"})})]})]})}const lp={person:"#f59e0b",vehicle:"#3b82f6",car:"#3b82f6",face:"#a855f7",plate:"#ec4899",animal:"#10b981",motion:"#ef4444",unknown:"#6b7280"};function dl(e){return lp[e.toLowerCase()]??lp.unknown}function R6(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function O6(e){return new Date(e).toISOString().slice(0,10)}function z6(e){return new Date(e+"T00:00:00").getTime()}function B6(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 F6(e){const t=["person","vehicle","face","motion"];return Array.from({length:24},(n,o)=>({id:`placeholder-${o}`,timestampMs:e+Math.floor(Math.random()*24*36e5),label:t[o%t.length],color:dl(t[o%t.length])})).sort((n,o)=>n.timestampMs-o.timestampMs)}function j6(){const{t:e}=Rt(),t=R6(new Date),[n,o]=_(t),[s,a]=_(null),[i,l]=_(t+12*36e5),c=n,d=n+24*36e5,{data:f,isLoading:p}=Xn({},{staleTime:3e4}),m=f??[],h=U(()=>m.filter(N=>{const k=N.type.toLowerCase();return k==="camera"||k.includes("camera")||N.features.some(S=>S.toLowerCase().includes("video")||S.toLowerCase().includes("stream"))}).map(N=>({id:N.id,name:N.name??N.stableId})),[m]),g=s??h[0]?.id??null,{data:b}=Un({queryKey:["events",g,c],queryFn:()=>Promise.resolve(null),enabled:!!g,staleTime:6e4}),x=U(()=>{const y=Array.isArray(b)?b:(()=>{const k=Pd(b)?.events;return Array.isArray(k)?k:[]})();return y.length===0?g?F6(c):[]:y.flatMap((N,k)=>{const S=Pd(N);if(!S)return[];const M=String(S.class??S.type??S.label??"unknown").toLowerCase(),P=typeof S.timestamp=="number"?S.timestamp:c;return[{id:String(S.id??k),timestampMs:P,label:M,color:dl(M)}]})},[b,g,c]),v=U(()=>g?B6(c):[],[g,c]);function w(y){o(N=>N+y*24*36e5),l(N=>N+y*24*36e5)}return u("div",{className:"flex flex-col h-full p-6 gap-5 overflow-hidden",children:[u("div",{className:"flex items-center justify-between gap-4 shrink-0",children:[r("h1",{className:"text-lg font-semibold text-foreground",children:e("nav.timeline","Timeline")}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>w(-1),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",children:r(Kc,{className:"h-4 w-4"})}),u("div",{className:"relative flex items-center",children:[r(Xx,{className:"absolute left-2 h-3.5 w-3.5 text-foreground-subtle pointer-events-none"}),r("input",{type:"date",value:O6(n),onChange:y=>{if(y.target.value){const N=z6(y.target.value);o(N),l(N+12*36e5)}},className:"rounded-lg border border-border bg-surface pl-7 pr-3 py-1.5 text-xs text-foreground focus:outline-none focus:border-primary/50"})]}),r("button",{onClick:()=>w(1),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",disabled:n>=t,children:r(It,{className:"h-4 w-4"})})]})]}),u("div",{className:"flex gap-1.5 shrink-0 overflow-x-auto pb-1",children:[p&&r("div",{className:"h-8 w-48 rounded-lg bg-surface animate-pulse"}),!p&&h.length===0&&r("span",{className:"text-xs text-foreground-subtle",children:"No cameras found"}),h.map(y=>{const N=y.id===g;return r("button",{onClick:()=>a(y.id),className:`shrink-0 rounded-lg px-3 py-1.5 text-[12px] font-medium transition-all border ${N?"bg-primary/12 text-primary border-primary/30":"bg-surface text-foreground-subtle border-border hover:bg-surface-hover hover:text-foreground"}`,children:y.name},y.id)})]}),u("div",{className:"relative w-full aspect-video rounded-xl border border-border bg-black shrink-0 overflow-hidden max-h-[45vh]",children:[u("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 text-foreground-subtle",children:[r(Yr,{className:"h-12 w-12 opacity-20"}),r("p",{className:"text-sm opacity-50",children:g?`${h.find(y=>y.id===g)?.name??g} — seek to play`:"Select a camera"})]}),r("div",{className:"absolute top-3 left-3 rounded bg-black/60 px-2 py-1 text-[11px] text-white font-mono",children:new Date(i).toLocaleTimeString()})]}),u("div",{className:"rounded-xl border border-border bg-surface px-4 pt-3 pb-4 shrink-0",children:[u("div",{className:"flex flex-wrap items-center gap-4 mb-3",children:[r("span",{className:"text-[10px] font-semibold text-foreground-subtle uppercase tracking-wider",children:"Timeline"}),u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"inline-block h-2 w-4 rounded-sm bg-success/60"}),r("span",{className:"text-[10px] text-foreground-subtle",children:"Recording"})]}),Array.from(new Set(x.map(y=>y.label))).slice(0,5).map(y=>u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{backgroundColor:dl(y)}}),r("span",{className:"text-[10px] text-foreground-subtle capitalize",children:y})]},y))]}),g?r(T6,{startMs:c,endMs:d,segments:v,events:x,playheadMs:i,onSeek:l}):r("div",{className:"h-8 rounded bg-surface-hover flex items-center justify-center text-xs text-foreground-subtle",children:"Select a camera to view timeline"})]})]})}function H6({selectedNodeId:e,onSelect:t,refreshToken:n}){const{data:o}=Mn(void 0,{staleTime:3e4}),{data:s}=ia(void 0,{staleTime:3e4}),a=new Map;for(const d of s??[])a.set(d.agentNodeId,(a.get(d.agentNodeId)??0)+1);const i=o??[],l=i.filter(d=>d.isOnline).length,c=i.filter(d=>!d.isOnline).length;return u("div",{className:"flex flex-col h-full",children:[u("button",{type:"button",onClick:()=>t(Jr),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===Jr?"bg-primary/10 text-primary":"text-foreground hover:bg-surface-hover"}`,children:[r(gr,{className:"h-4 w-4 flex-shrink-0"}),u("div",{className:"min-w-0 flex-1",children:[r("div",{className:"text-xs font-semibold truncate",children:"Cluster"}),r("div",{className:"text-[10px] text-foreground-subtle",children:"Balancer + failover + assignments"})]})]}),r("div",{className:"flex-1 overflow-y-auto",children:i.map(d=>{const f=e===d.id,p=a.get(d.id)??0,m=d.isHub?sn:dt;return u("button",{type:"button",onClick:()=>t(d.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${f?"bg-primary/10 text-primary":"text-foreground hover:bg-surface-hover"}`,children:[r(m,{className:"h-4 w-4 flex-shrink-0"}),u("div",{className:"min-w-0 flex-1",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-xs font-semibold truncate",children:d.name}),d.isHub&&r("span",{className:"text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5",children:"hub"}),!d.isOnline&&r("span",{className:"h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0"}),d.isOnline&&r("span",{className:"h-1.5 w-1.5 rounded-full bg-success flex-shrink-0"})]}),u("div",{className:"text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5",children:[u("span",{children:[d.cpuCores," cores"]}),r("span",{children:"•"}),u("span",{children:[Math.round(d.memoryMB/1024)," GB"]}),p>0&&u(xe,{children:[r("span",{children:"•"}),u("span",{className:"inline-flex items-center gap-0.5 text-foreground",children:[r(yy,{className:"h-2.5 w-2.5"}),p]})]})]})]})]},d.id)})}),u("div",{className:"px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between",children:[u("span",{children:[l," online"]}),c>0&&u("span",{className:"text-destructive",children:[c," offline"]})]})]})}function V6({nodeId:e,refreshToken:t}){const{data:n}=Mn(void 0,{staleTime:3e4}),o=n?.find(i=>i.id===e),a=Ir("pipeline.runner-load-snapshot",i=>i.nodeId===e)?.load??null;return o?u("div",{className:"px-6 py-4 border-b border-border",children:[u("div",{className:"flex items-center gap-2 mb-1",children:[r("h2",{className:"text-base font-semibold text-foreground",children:o.name}),o.isOnline?r("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success",children:"online"}):r("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:"offline"}),o.isHub&&r("span",{className:"text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5",children:"hub"})]}),u("div",{className:"text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap",children:[r("span",{children:o.cpuModel??"CPU"}),r("span",{children:"•"}),u("span",{children:[o.cpuCores," cores"]}),r("span",{children:"•"}),u("span",{children:[Math.round(o.memoryMB/1024)," GB"]}),a&&u(xe,{children:[r("span",{children:"•"}),u("span",{children:[a.attachedCameras," cameras (",a.activeCameras," active)"]}),r("span",{children:"•"}),u("span",{children:[a.avgInferenceTimeMs.toFixed(0),"ms avg inference"]}),r("span",{children:"•"}),u("span",{children:["queue ",a.queueDepthTotal]}),a.hardware.hasGpu&&u(xe,{children:[r("span",{children:"•"}),r("span",{className:"text-success",children:"GPU"})]})]})]})]}):r("div",{className:"px-6 py-4 border-b border-border",children:u("div",{className:"text-xs text-foreground-subtle",children:["Node not found: ",e]})})}function zy({refreshToken:e,nodeId:t}){const[n,o]=_(new Map),{nodes:s}=Ar();ct("pipeline.camera-metrics-snapshot",p=>{const m=p.data;typeof m?.deviceId=="number"&&o(h=>{const g=new Map(h);return g.set(m.deviceId,m),g})});const{data:a}=Nb(void 0,{staleTime:5e3}),i=U(()=>{const p=new Map;for(const m of a??[])p.set(m.nodeId,m.deviceCount);return p},[a]),l=U(()=>{const p=new Map,m=Date.now()-3e4;for(const h of n.values()){if(h.timestamp<m)continue;const g=h.nodeId??"hub",b=p.get(g)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};b.attachedCameras++,h.metrics.phase==="active"&&b.activeCameras++,b.totalFps+=h.metrics.actualFps,b.totalInferenceWeighted+=h.metrics.avgInferenceTimeMs,b.queueDepth+=h.metrics.queueDepth,p.set(g,b)}return p},[n]),c=U(()=>{const p=new Map;for(const m of s)p.set(m.id,m.shortName);return p},[s]),d=U(()=>{let p=0,m=0,h=0,g=0,b=0;for(const v of l.values())p+=v.attachedCameras,m+=v.activeCameras,h+=v.totalFps,g+=v.totalInferenceWeighted,b+=v.queueDepth;const x=p>0?g/p:0;return{totalAgents:s.length,onlineAgents:s.filter(v=>v.isOnline).length,attachedCameras:p,activeCameras:m,avgInferenceTimeMs:x,queueDepth:b,totalFps:h}},[l,s]);if(t){const p=l.get(t);return u("div",{className:"@container/liveload",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-2",children:"Live load"}),u("div",{className:"grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3",children:[r(Ft,{label:"FPS",value:p?p.totalFps.toFixed(1):"—"}),r(Ft,{label:"Cameras",value:p?`${p.activeCameras}/${p.attachedCameras}`:"—"}),r(Ft,{label:"Avg infer ms",value:p&&p.attachedCameras>0?(p.totalInferenceWeighted/p.attachedCameras).toFixed(0):"—"}),r(Ft,{label:"Queue",value:p?String(p.queueDepth):"—"}),r(Ft,{label:"Audio",value:String(i.get(t)??"—")})]})]})}const f=[...l.entries()].sort(([p],[m])=>p==="hub"?-1:m==="hub"?1:p.localeCompare(m));return u("div",{className:"@container/liveload",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-2",children:"Live load"}),u("div",{className:"grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3",children:[r(Ft,{label:"Total agents",value:`${d.onlineAgents}/${d.totalAgents}`}),r(Ft,{label:"Cameras",value:`${d.activeCameras}/${d.attachedCameras}`}),r(Ft,{label:"Total FPS",value:d.totalFps.toFixed(1)}),r(Ft,{label:"Avg inference ms",value:d.avgInferenceTimeMs.toFixed(0)}),r(Ft,{label:"Queue depth",value:String(d.queueDepth)})]}),r("div",{className:"rounded-lg border border-border overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[480px]",children:[r("thead",{className:"bg-surface",children:u("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[r("th",{className:"text-left px-3 py-2",children:"Agent"}),r("th",{className:"text-right px-3 py-2",children:"FPS"}),r("th",{className:"text-right px-3 py-2",children:"Cameras"}),r("th",{className:"text-right px-3 py-2",children:"Inference ms"}),r("th",{className:"text-right px-3 py-2",children:"Queue"}),r("th",{className:"text-right px-3 py-2",children:"Audio"})]})}),u("tbody",{children:[f.map(([p,m])=>u("tr",{className:"border-t border-border",children:[r("td",{className:"px-3 py-2 text-foreground font-medium",children:c.get(p)??p}),r("td",{className:"px-3 py-2 text-right text-foreground",children:m.totalFps.toFixed(1)}),r("td",{className:"px-3 py-2 text-right text-foreground",children:m.attachedCameras}),r("td",{className:"px-3 py-2 text-right text-foreground",children:m.attachedCameras>0?(m.totalInferenceWeighted/m.attachedCameras).toFixed(0):"—"}),r("td",{className:"px-3 py-2 text-right text-foreground",children:m.queueDepth}),r("td",{className:"px-3 py-2 text-right text-foreground",children:i.get(p)??"—"})]},p)),f.length===0&&r("tr",{children:r("td",{colSpan:6,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:"No camera metrics received yet"})})]})]})})]})}function Ft({label:e,value:t}){return u("div",{className:"rounded-lg border border-border bg-surface/60 p-3",children:[r("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle mb-1",children:e}),r("div",{className:"text-lg font-semibold text-foreground",children:t})]})}function By(e){return Xn({addonId:e})}function q6(e){return Bn({deviceId:e},{enabled:Number.isFinite(e)})}const Q6=3e4,U6=2e3;function Fy(e){const t=ne(0);return t.current===0&&(t.current=Date.now()),wg({parentDeviceId:e},{enabled:Number.isFinite(e),staleTime:0,refetchOnMount:"always",refetchInterval:n=>{const o=n.state.data;return o&&o.length>0||Date.now()-t.current>=Q6?!1:U6}})}const gi={active:!1,pinned:!1,nodeId:null,reason:""},bi=["pipeline.camera-assigned","pipeline.camera-unassigned","pipeline.camera-updated","agent.online","agent.offline"],K6={pipeline:dt,decoder:Yr,audio:rl},cp={pipeline:"Pipeline",decoder:"Decoder",audio:"Audio"};function jy({mode:e,nodeId:t,compact:n=!1}){if(e==="agent"&&!t)throw new Error('CameraAssignmentsTable: nodeId is required when mode === "agent"');const o=ke(),[s,a]=_(null),[i,l]=_(null),[c,d]=_(new Map);yt(["pipelineOrchestrator","getPipelineAssignments"],bi),yt(["pipelineOrchestrator","getDecoderAssignments"],bi),yt(["pipelineOrchestrator","getAudioAssignments"],bi);const{data:f}=ia(void 0,{staleTime:3e4}),{data:p}=yb(void 0,{staleTime:3e4}),{data:m}=kb(void 0,{staleTime:3e4}),{nodes:h}=Ar(),{data:g}=By();ct("pipeline.camera-metrics-snapshot",$=>{const O=$.data;typeof O.deviceId=="number"&&d(R=>{const A=new Map(R);return A.set(O.deviceId,O),A})}),Z(()=>{if(c.size===0)return;const $=setInterval(()=>{d(O=>{const R=Date.now()-1e4;let A=!1;const L=new Map(O);for(const[D,T]of O)T.timestamp<R&&(L.delete(D),A=!0);return A?L:O})},5e3);return()=>clearInterval($)},[c.size]);const b=U(()=>{const $=new Map;for(const O of g??[])$.set(O.id,O.name);return $},[g]),x=U(()=>{const $=new Map,O=A=>{const L=$.get(A);if(L)return L;const D={deviceId:A,deviceName:b.get(A)??`Device ${A}`,pipeline:gi,decoder:gi,audio:gi};return $.set(A,D),D};for(const A of f??[]){const L=O(A.deviceId);$.set(A.deviceId,{...L,pipeline:{active:e==="cluster"?!0:A.agentNodeId===t,pinned:A.pinned,nodeId:A.agentNodeId,reason:A.reason??""}})}for(const A of p??[]){const L=O(A.deviceId);$.set(A.deviceId,{...L,decoder:{active:e==="cluster"?!0:A.decoderNodeId===t,pinned:A.pinned,nodeId:A.decoderNodeId,reason:A.reason??""}})}for(const A of m??[]){const L=O(A.deviceId);$.set(A.deviceId,{...L,audio:{active:e==="cluster"?!0:A.nodeId===t,pinned:A.pinned,nodeId:A.nodeId,reason:"capacity"}})}let R=[...$.values()];return e==="agent"&&(R=R.filter(A=>A.pipeline.active||A.decoder.active||A.audio.active)),R.sort((A,L)=>A.deviceId-L.deviceId),R},[f,p,m,b,e,t]),v=U(()=>(h??[]).filter($=>$.isOnline).map($=>({id:$.id,name:$.name})),[h]),w=()=>{o.invalidateQueries({queryKey:[["pipelineOrchestrator","getPipelineAssignments"]]}),o.invalidateQueries({queryKey:[["pipelineOrchestrator","getDecoderAssignments"]]}),o.invalidateQueries({queryKey:[["pipelineOrchestrator","getAudioAssignments"]]})},y=ub({onSuccess:w}),N=pb({onSuccess:w}),k=bb({onSuccess:w}),S=xb({onSuccess:w}),M=vb({onSuccess:w}),P=wb({onSuccess:w}),I=($,O,R)=>{O==="pipeline"?y.mutate({deviceId:$,agentNodeId:R}):O==="decoder"?k.mutate({deviceId:$,nodeId:R}):M.mutate({deviceId:$,nodeId:R}),a(null)},z=($,O)=>{O==="pipeline"?N.mutate({deviceId:$}):O==="decoder"?S.mutate({deviceId:$}):P.mutate({deviceId:$}),a(null)};return r("div",{className:"rounded-lg border border-border overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[640px]",children:[r("thead",{className:"bg-surface",children:u("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[!n&&r("th",{className:"w-6"}),r("th",{className:"text-left px-3 py-2 align-middle",children:"Camera"}),r("th",{className:"text-left px-3 py-2 align-middle",children:"Pipeline"}),r("th",{className:"text-left px-3 py-2 align-middle",children:"Decoder"}),r("th",{className:"text-left px-3 py-2 align-middle",children:"Audio"}),r("th",{className:"text-left px-3 py-2 align-middle",children:"Status"})]})}),u("tbody",{children:[x.map($=>{const O=c.get($.deviceId),R=i===$.deviceId;return u(El.Fragment,{children:[u("tr",{className:"border-t border-border align-middle relative",children:[!n&&r("td",{className:"px-2 py-2 align-middle",children:r("button",{type:"button",onClick:()=>l(R?null:$.deviceId),className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle","aria-label":R?"Collapse broker details":"Expand broker details",children:R?r(wt,{className:"h-3.5 w-3.5"}):r(It,{className:"h-3.5 w-3.5"})})}),u("td",{className:"px-3 py-2 align-middle",children:[r("div",{className:"text-foreground font-medium leading-tight",children:$.deviceName}),u("div",{className:"text-[10px] text-foreground-subtle leading-tight",children:["#",$.deviceId]})]}),r(xi,{role:"pipeline",state:$.pipeline,mode:e,deviceId:$.deviceId,onlineNodes:v,isMenuOpen:s?.deviceId===$.deviceId&&s.role==="pipeline",onToggleMenu:()=>a(s?.deviceId===$.deviceId&&s.role==="pipeline"?null:{deviceId:$.deviceId,role:"pipeline"}),onCloseMenu:()=>a(null),onMove:A=>I($.deviceId,"pipeline",A),onUnpin:()=>z($.deviceId,"pipeline")}),r(xi,{role:"decoder",state:$.decoder,mode:e,deviceId:$.deviceId,onlineNodes:v,isMenuOpen:s?.deviceId===$.deviceId&&s.role==="decoder",onToggleMenu:()=>a(s?.deviceId===$.deviceId&&s.role==="decoder"?null:{deviceId:$.deviceId,role:"decoder"}),onCloseMenu:()=>a(null),onMove:A=>I($.deviceId,"decoder",A),onUnpin:()=>z($.deviceId,"decoder")}),r(xi,{role:"audio",state:$.audio,mode:e,deviceId:$.deviceId,onlineNodes:v,isMenuOpen:s?.deviceId===$.deviceId&&s.role==="audio",onToggleMenu:()=>a(s?.deviceId===$.deviceId&&s.role==="audio"?null:{deviceId:$.deviceId,role:"audio"}),onCloseMenu:()=>a(null),onMove:A=>I($.deviceId,"audio",A),onUnpin:()=>z($.deviceId,"audio")}),r("td",{className:"px-3 py-2 align-middle",children:r(Y6,{snap:O})})]}),R&&!n&&u("tr",{className:"bg-surface/50",children:[r("td",{}),r("td",{colSpan:5,className:"px-3 py-2",children:r(at,{widgetId:"stream-broker/stream-broker-panel",host:"device-tab",deviceId:$.deviceId,instanceId:`pipeline-row/${$.deviceId}`,config:{variant:"compact",title:"Stream brokers & clients"}})})]})]},$.deviceId)}),x.length===0&&r("tr",{children:r("td",{colSpan:n?5:6,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:e==="agent"?"No cameras assigned to this node":"No cameras currently assigned"})})]})]})})}function xi({role:e,state:t,mode:n,onlineNodes:o,isMenuOpen:s,onToggleMenu:a,onCloseMenu:i,onMove:l,onUnpin:c}){const d=K6[e],f=o.filter(h=>h.id!==(t.nodeId??"")),m=(t.active||n==="cluster")&&(f.length>0||t.pinned);return u("td",{className:"px-3 py-2 align-middle relative",children:[u("div",{className:"flex items-center gap-2",children:[n==="agent"?r(G6,{state:t,Icon:d}):r(W6,{state:t,Icon:d}),r("div",{className:"ml-auto",children:m&&r("button",{type:"button",onClick:a,className:"p-1 rounded hover:bg-surface-hover","aria-label":`${cp[e]} actions`,children:r(DD,{className:"h-3 w-3 text-foreground-subtle"})})})]}),s&&m&&r(Z6,{title:cp[e],targets:f,pinned:t.pinned,onMove:l,onUnpin:c,onClose:i})]})}function G6({state:e,Icon:t}){const n=e.active?gy:Po;return u("div",{className:"flex items-center gap-1.5",children:[r(n,{className:`h-3.5 w-3.5 ${e.active?"text-success":"text-foreground-subtle/50"}`}),r(t,{className:`h-3 w-3 ${e.active?"text-foreground-subtle":"text-foreground-subtle/40"}`}),e.pinned&&r(py,{className:"h-2.5 w-2.5 text-amber-400"})]})}function W6({state:e,Icon:t}){return!e.active||!e.nodeId?u("div",{className:"flex items-center gap-1.5 text-foreground-subtle/60",children:[r(t,{className:"h-3 w-3"}),r("span",{className:"text-[10px] italic",children:"—"})]}):u("div",{className:"flex items-center gap-1.5 min-w-0",children:[r(t,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),u("div",{className:"flex flex-col leading-tight min-w-0",children:[r("span",{className:"font-mono text-[11px] text-foreground truncate",children:e.nodeId}),r("span",{className:"flex items-center gap-1 text-[10px]",children:e.pinned?u("span",{className:"inline-flex items-center gap-0.5 text-amber-400",children:[r(py,{className:"h-2.5 w-2.5"})," manual"]}):u("span",{className:"text-foreground-subtle truncate",children:["auto · ",e.reason||"capacity"]})})]})]})}function Y6({snap:e}){if(!e)return r("span",{className:"text-[10px] text-foreground-subtle italic",children:"—"});const{phase:t,actualFps:n,avgInferenceTimeMs:o,queueDepth:s,configuredFps:a}=e.metrics,i=Gn(t);return u("div",{className:"flex flex-col gap-0.5 font-mono text-[10px] tabular-nums leading-tight",children:[u("span",{className:`inline-flex items-center gap-1 ${i.textColor}`,children:[r(Ec,{phase:t,className:"h-2.5 w-2.5"}),r("span",{className:"font-semibold uppercase tracking-wider",children:i.label})]}),u("span",{className:"text-foreground-subtle",children:[r("span",{className:"text-foreground",children:n.toFixed(1)}),u("span",{children:["/",a.toFixed(0)," fps"]})]}),u("span",{className:"text-foreground-subtle",children:[r("span",{className:"text-foreground",children:o.toFixed(0)}),r("span",{children:" ms"}),s>0&&u("span",{className:"text-warning ml-1",children:["q",s]})]})]})}function Z6({title:e,targets:t,pinned:n,onMove:o,onUnpin:s,onClose:a}){const i=ne(null);return Z(()=>{const l=c=>{i.current?.contains(c.target)||a()};return window.addEventListener("mousedown",l),()=>window.removeEventListener("mousedown",l)},[a]),u("div",{ref:i,className:"absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left",children:[r("div",{className:"px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border",children:e}),t.length>0&&r("div",{className:"py-1",children:t.map(l=>u("button",{type:"button",onClick:()=>o(l.id),className:"block w-full text-left px-3 py-1 text-[11px] text-foreground hover:bg-surface-hover",children:["Move to ",l.name]},l.id))}),n&&u("button",{type:"button",onClick:s,className:"block w-full text-left px-3 py-1.5 text-[11px] text-destructive hover:bg-destructive/10 border-t border-border",children:["Unpin ",e.toLowerCase()]}),t.length===0&&!n&&r("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle italic",children:"Already auto · no other nodes online"})]})}function X6({nodeId:e,refreshToken:t}){return u("div",{className:"space-y-6",children:[r(zy,{refreshToken:t,nodeId:e}),u("div",{children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Cameras on this node"}),u("p",{className:"text-[11px] text-foreground-subtle",children:["Checkboxes mark the roles currently running on ",e,". Use the kebab to move a role to another node or unpin it; live KPIs come from the runner snapshot stream."]})]}),r(jy,{mode:"agent",nodeId:e,compact:!0})]})}function J6(e,t){const n=Math.max(0,t-e),o=Math.floor(e/1e3),s=Math.floor(n/1e3);return`${o}s idle · ${s}s left`}function eO({nodeId:e,refreshToken:t}){const n=ke(),o=db({onSettled:()=>{n.invalidateQueries({queryKey:["pipelineExecutor","listLoadedEngines"]})}}),{data:s}=cb({nodeId:e},{staleTime:5e3}),i=Ir("pipeline.engine-metrics-snapshot",m=>m.nodeId===e)?.engines??s??null,l=i===null;yt(["pipelineRunner","getLocalCameras"],["pipeline.camera-assigned","pipeline.camera-unassigned"]);const{data:c}=_b({nodeId:e},{staleTime:3e4}),{values:d}=tc("pipeline.camera-metrics-snapshot",m=>m.deviceId,m=>m.nodeId===e),f=U(()=>d.filter(m=>m.metrics.phase==="active").length,[d]),p=m=>{const h=c??[];h.length>0&&!window.confirm(`${h.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||o.mutate({nodeId:e,engine:m,force:h.length>0})};return u("div",{className:"space-y-6",children:[u("div",{children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Inference engines on this node"}),u("p",{className:"text-[11px] text-foreground-subtle",children:[(i??[]).length," engine(s) resident in RAM. ",(c??[]).length," camera(s) attached, ",f," actively dispatching frames. Refreshes every 5s."]})]}),r("div",{className:"rounded-lg border border-border overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[640px]",children:[r("thead",{className:"bg-surface",children:u("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[r("th",{className:"text-left px-3 py-2 whitespace-nowrap",children:"Kind"}),r("th",{className:"text-left px-3 py-2 whitespace-nowrap",children:"Runtime / Backend / Device"}),r("th",{className:"text-left px-3 py-2",children:"Models"}),r("th",{className:"text-right px-3 py-2 whitespace-nowrap",children:"Pool PID"}),r("th",{className:"text-right px-3 py-2 whitespace-nowrap",children:"Auto-kill"}),r("th",{className:"text-right px-3 py-2 whitespace-nowrap",children:"In use"}),r("th",{className:"w-20"})]})}),u("tbody",{children:[l&&r("tr",{children:r("td",{colSpan:7,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:"Loading…"})}),!l&&(i??[]).map(m=>{const h=m.kind==="warm-override";return u("tr",{className:`border-t border-border ${h?"bg-amber-500/5":""}`,children:[r("td",{className:"px-3 py-2",children:u("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${h?"bg-amber-500/15 text-amber-400":"bg-success/15 text-success"}`,children:[h?r(BD,{className:"h-3 w-3"}):r(dt,{className:"h-3 w-3"}),h?"warm":"runtime"]})}),r("td",{className:"px-3 py-2",children:u("span",{className:"inline-flex items-center gap-1 text-[11px] text-sky-400",children:[r(Jc,{className:"h-3 w-3"}),m.engine.runtime,"/",m.engine.backend,m.engine.device?`/${m.engine.device}`:"",m.engine.format?` · ${m.engine.format}`:""]})}),r("td",{className:"px-3 py-2",children:m.modelsLoaded.length===0?r("span",{className:"text-foreground-subtle text-[11px]",children:"—"}):r("div",{className:"flex flex-wrap gap-1",children:m.modelsLoaded.map(g=>r("span",{className:"inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle",children:g},g))})}),r("td",{className:"px-3 py-2 text-right font-mono text-foreground",children:m.poolPid??"—"}),r("td",{className:"px-3 py-2 text-right text-[11px]",children:m.idleMs!==null&&m.idleTtlMs!==null?r("span",{className:"text-foreground-subtle",children:J6(m.idleMs,m.idleTtlMs)}):r("span",{className:"text-foreground-subtle/50",children:"never"})}),r("td",{className:"px-3 py-2 text-right text-foreground",children:h?"—":(c??[]).length}),r("td",{className:"px-3 py-2 text-right",children:u("button",{type:"button",disabled:o.isPending,onClick:()=>p(m.engine),className:"inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50",children:[r(Ge,{className:"h-3 w-3"}),"Kill"]})})]},m.engineKey)}),!l&&(i??[]).length===0&&r("tr",{children:r("td",{colSpan:7,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:"No engines resident — the factory spins up on the first pipeline run."})})]})]})}),u("div",{className:"text-[10px] text-foreground-subtle leading-relaxed",children:[r("strong",{className:"text-foreground",children:"runtime"}),": main camera-serving engine; never auto-killed while cameras attached. ",r("strong",{className:"text-foreground",children:"warm"}),": benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL."]}),o.isError&&u("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive",children:["Kill failed: ",o.error instanceof Error?o.error.message:"unknown"]})]})}function kt(e){if(!Number.isFinite(e)||e<0)return"—";if(e<1024)return`${Math.round(e)} B`;const t=["KB","MB","GB","TB","PB"];let n=e/1024,o="KB";for(const a of t){if(o=a,n<1024)break;n/=1024}return`${n>=100?Math.round(n).toString():n.toFixed(1)} ${o}`}function Hy(e){return kt(e*1024*1024)}const tO=new Set(ow);function dp(e){return tO.has(e)}function yi(e,t,n){return`${e}/${t}/${n}`}function ul(e){return{coreml:"CoreML",openvino:"OpenVINO",onnx:"ONNX"}[e.format]??e.format.toUpperCase()}function up(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 $n(e){return e.format}function nO(e,t){let n=0,o=0,s=0;for(const a of e)for(const i of a.addons)for(const l of i.models){const c=l.formats[t];c&&(n++,c.downloaded&&(o++,s+=c.sizeMB))}return{total:n,downloaded:o,downloadedSizeMB:s}}function rO({addonId:e,model:t,format:n,isActive:o,progress:s,errorMsg:a,onDownload:i,onDelete:l}){const c=t.formats[n];return c?u("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/50 last:border-b-0 hover:bg-surface-hover/30 transition-colors",children:[r("div",{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?"bg-success":"bg-foreground-subtle/30"}`}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-sm font-medium text-foreground",children:t.name}),u("span",{className:"text-[10px] text-foreground-subtle font-mono",children:["(",t.id,")"]})]}),s&&s.progress>=0&&s.progress<100&&u("div",{className:"mt-1.5 flex items-center gap-2 max-w-xs",children:[r("div",{className:"flex-1 h-1 bg-surface-hover rounded-full overflow-hidden",children:r("div",{className:"bg-primary h-full rounded-full transition-all duration-300",style:{width:`${s.progress}%`}})}),u("span",{className:"text-[9px] text-primary font-mono tabular-nums shrink-0",children:[Math.round(s.progress),"%"]})]})]}),r("span",{className:"text-xs text-foreground-subtle tabular-nums shrink-0",children:Hy(c.sizeMB)}),a&&u("span",{className:"flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0",title:a,children:[r(xa,{className:"h-3 w-3 shrink-0"}),a]}),c.downloaded?u("button",{onClick:l,disabled:o,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md border border-danger/30 text-danger hover:bg-danger/10 disabled:opacity-50 transition-colors shrink-0",children:[o?r(Pe,{className:"h-3 w-3 animate-spin"}):r(Ge,{className:"h-3 w-3"}),o?"Deleting...":"Delete"]}):u("button",{onClick:i,disabled:o,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0",children:[o?r(Pe,{className:"h-3 w-3 animate-spin"}):r(vn,{className:"h-3 w-3"}),o?"Downloading...":"Download"]})]}):null}function oO({engines:e,activeEngine:t,viewEngine:n,onSelect:o}){const[s,a]=_(!1);return u("div",{className:"relative",children:[u("button",{type:"button",onClick:()=>a(!s),className:"flex items-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 w-full text-left hover:bg-surface-hover transition-colors",children:[r(dt,{className:"h-4 w-4 text-primary shrink-0"}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-sm font-medium text-foreground",children:ul(n)}),$n(n)===$n(t)&&r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium",children:"Active"})]}),r("div",{className:"text-[10px] text-foreground-subtle",children:up(n)})]}),r(wt,{className:`h-4 w-4 text-foreground-subtle transition-transform ${s?"rotate-180":""}`})]}),s&&r("div",{className:"absolute top-full left-0 right-0 mt-1 rounded-lg border border-border bg-surface shadow-lg z-50 overflow-hidden",children:e.map(i=>{const l=$n(i)===$n(n),c=$n(i)===$n(t);return u("button",{type:"button",onClick:()=>{o(i),a(!1)},className:`flex items-center gap-3 px-4 py-2.5 w-full text-left transition-colors ${l?"bg-primary/5":"hover:bg-surface-hover"}`,children:[r(dt,{className:`h-4 w-4 shrink-0 ${l?"text-primary":"text-foreground-subtle"}`}),u("div",{className:"flex-1",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:`text-sm font-medium ${l?"text-primary":"text-foreground"}`,children:ul(i)}),c&&r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium",children:"Active"})]}),r("div",{className:"text-[10px] text-foreground-subtle",children:up(i)})]}),l&&r(ey,{className:"h-4 w-4 text-primary shrink-0"})]},$n(i))})})]})}function sO({embedded:e=!1,nodeId:t}={}){const n=ke(),o=t??"hub",[s,a]=_(null),[i,l]=_(new Set),[c,d]=_(new Map),[f,p]=_(new Map),[m,h]=_(""),{data:g=[]}=ob({nodeId:o},{staleTime:6e4}),x=g.filter((T,B,F)=>F.findIndex(j=>j.format===T.format)===B),{data:v}=sb({nodeId:o},{staleTime:3e4}),w=v,{data:y,isLoading:N}=ko({nodeId:o},{staleTime:1e4}),k=ib(),S=lb();ct("model.download.progress",T=>{const B=T.data,F=typeof B.modelId=="string"?B.modelId:void 0,j=typeof B.progress=="number"?B.progress:void 0,H=typeof B.totalMB=="number"?B.totalMB:0;F===void 0||j===void 0||(d(E=>{const Q=new Map(E);return j===100||j===-1?Q.delete(F):Q.set(F,{modelId:F,progress:j,totalMB:H}),Q}),j===100&&n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]}))});const M=w??{runtime:"node",backend:"cpu",format:"onnx"},P=x.find(T=>T.format===s)??M,I=P.format,z=y?.slots??[],$=z.map(T=>({...T,addons:T.addons.map(B=>({...B,models:B.models.filter(F=>F.formats[I]!==void 0)})).filter(B=>B.models.length>0)})).filter(T=>T.addons.length>0),O=nO($,I),R=q(async(T,B,F)=>{if(!dp(F))return;const j=yi(T,B,F);l(H=>new Set([...H,j])),p(H=>{const E=new Map(H);return E.delete(j),E});try{await k.mutateAsync({addonId:T,modelId:B,format:F,nodeId:o}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch(H){p(E=>new Map([...E,[j,H instanceof Error?H.message:"Download failed"]]))}finally{l(H=>{const E=new Set(H);return E.delete(j),E})}},[k,n,o]),A=q(async(T,B,F)=>{if(!dp(F))return;const j=yi(T,B,F);l(H=>new Set([...H,j])),p(H=>{const E=new Map(H);return E.delete(j),E});try{await S.mutateAsync({addonId:T,modelId:B,format:F,nodeId:o}),n.invalidateQueries({queryKey:[["pipelineExecutor","getSchema"]]})}catch(H){p(E=>new Map([...E,[j,H instanceof Error?H.message:"Delete failed"]]))}finally{l(H=>{const E=new Set(H);return E.delete(j),E})}},[S,n,o]),L=q(T=>{a(T.format)},[]),D=m.trim()?$.map(T=>({...T,addons:T.addons.map(B=>({...B,models:B.models.filter(F=>F.name.toLowerCase().includes(m.toLowerCase())||F.id.toLowerCase().includes(m.toLowerCase())||B.name.toLowerCase().includes(m.toLowerCase()))})).filter(B=>B.models.length>0)})).filter(T=>T.addons.length>0):$;return u("div",{className:e?"space-y-4":"p-6 space-y-6 max-w-5xl mx-auto",children:[!e&&u("div",{children:[r("h1",{className:"text-lg font-bold text-foreground",children:"Models"}),r("p",{className:"text-xs text-foreground-subtle mt-0.5",children:"Manage ML models for the detection pipeline. Select an engine to see its compatible models."})]}),N&&r("div",{className:"flex items-center justify-center py-16",children:r(Pe,{className:"h-5 w-5 animate-spin text-foreground-subtle"})}),!N&&z.length===0&&u("div",{className:"flex flex-col items-center justify-center py-16 text-foreground-subtle",children:[r(lo,{className:"h-8 w-8 mb-3 opacity-30"}),r("span",{className:"text-sm",children:"No pipeline steps available"}),r("span",{className:"text-xs mt-1",children:"Configure the detection pipeline to see available models."})]}),!N&&z.length>0&&u(xe,{children:[r(oO,{engines:x,activeEngine:M,viewEngine:P,onSelect:L}),u("div",{className:"flex items-center gap-4 text-xs text-foreground-subtle",children:[u("span",{children:[r("span",{className:"font-semibold text-foreground tabular-nums",children:O.total}),r("span",{className:"ml-1",children:"compatible models"})]}),r("span",{className:"text-border",children:"|"}),u("span",{children:[r("span",{className:"font-semibold text-success tabular-nums",children:O.downloaded}),r("span",{className:"ml-1",children:"downloaded"})]}),r("span",{className:"text-border",children:"|"}),u("span",{className:"tabular-nums",children:[Hy(O.downloadedSizeMB),r("span",{className:"ml-1",children:"on disk"})]})]}),O.total>5&&u("div",{className:"relative",children:[r(hy,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle"}),r("input",{type:"text",value:m,onChange:T=>h(T.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"})]}),D.map(T=>{const B=T.addons.reduce((j,H)=>j+H.models.length,0),F=T.addons.reduce((j,H)=>j+H.models.filter(E=>E.formats[I]?.downloaded).length,0);return u("div",{children:[u("div",{className:"flex items-center gap-2 mb-2",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:T.label}),r("div",{className:"flex-1 h-px bg-border"}),u("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[F,"/",B]})]}),r("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:T.addons.map(j=>j.models.map(H=>{const E=yi(j.id,H.id,I);return r(rO,{addonId:j.id,model:H,format:I,isActive:i.has(E),progress:c.get(H.id),errorMsg:f.get(E),onDownload:()=>R(j.id,H.id,I),onDelete:()=>A(j.id,H.id,I)},`${j.id}/${H.id}`)}))})]},T.id)}),D.length===0&&r("div",{className:"text-center py-8 text-sm text-foreground-subtle",children:m.trim()?u(xe,{children:["No models matching “",m,"”"]}):u(xe,{children:["No models available for ",ul(P)," format"]})})]})]})}function aO({nodeId:e,refreshToken:t}){return r(sO,{embedded:!0,nodeId:e})}function Vy({nodeId:e,title:t}){const{data:n}=By(),{data:o}=ia(void 0,{staleTime:3e4}),s=U(()=>{const d=new Map;for(const f of n??[])d.set(f.id,f.name);return d},[n]),a=U(()=>{if(!e)return null;const d=new Set;for(const f of o??[])f.agentNodeId===e&&d.add(f.deviceId);return d},[e,o]),[i,l]=_(new Map);ct("pipeline.camera-metrics-snapshot",d=>{const f=d.data;typeof f.deviceId=="number"&&(e&&f.nodeId!==e||l(p=>{const m=new Map(p);return m.set(f.deviceId,f),m}))}),Z(()=>{if(i.size===0)return;const d=setInterval(()=>{l(f=>{const p=Date.now()-1e4;let m=!1;const h=new Map(f);for(const[g,b]of f)b.timestamp<p&&(h.delete(g),m=!0);return m?h:f})},5e3);return()=>clearInterval(d)},[i.size]);const c=U(()=>{const d=[];for(const f of i.values())a&&!a.has(f.deviceId)||d.push(f);return d.sort((f,p)=>f.deviceId-p.deviceId),d},[i,a]);return c.length===0?u("div",{className:"rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic",children:[t??"Cameras",": no live snapshots yet"]}):u("div",{className:"rounded-md border border-border bg-surface px-3 py-2",children:[u("div",{className:"flex items-center gap-2 mb-1.5",children:[r("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:t??"Cameras"}),r("span",{className:"text-[10px] text-foreground-subtle",children:c.length})]}),r("div",{className:"flex flex-wrap gap-1.5",children:c.map(d=>{const f=s.get(d.deviceId)??`#${d.deviceId}`,p=Gn(d.metrics.phase);return u("div",{title:`${f} · ${p.label} · ${d.metrics.actualFps.toFixed(1)} fps · ${d.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${d.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${p.badgeClass}`,children:[r(Ec,{phase:d.metrics.phase,className:"h-2.5 w-2.5"}),r("span",{className:"font-medium text-foreground/90 max-w-[120px] truncate",children:f}),r("span",{className:"font-mono tabular-nums",children:d.metrics.actualFps.toFixed(1)}),r("span",{className:"opacity-60",children:"fps"})]},d.deviceId)})})]})}function vi(e,t){if(!e)return null;for(const n of e.slots)for(const o of n.addons)if(o.id===t)return o;return null}function iO({nodeId:e,refreshToken:t}){const n=ke(),[o,s]=_(null),[a,i]=_(null),l=ko({nodeId:e},{refetchOnMount:"always"}),c=yc({agentNodeId:e},{refetchOnMount:"always"}),d=vc({onSuccess:()=>{n.invalidateQueries({queryKey:[["addonSettings"]]}),n.invalidateQueries({queryKey:[["pipelineOrchestrator"]]}),n.invalidateQueries({queryKey:[["pipelineExecutor"]]})}}),f=l.data??null,p=c.data,m=f?.selectedEngine.format??"coreml",h=U(()=>f?ea(f):[],[f]),g=U(()=>[{agentNodeId:e,engineLabel:m}],[e,m]),b=(S,M)=>{const P=p?.addonDefaults[S];return vi(f,S)?.models.some($=>!!$.formats[m])?P?P.enabled?{kind:"enabled",modelId:P.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},x=o&&f?vi(f,o.addonId):null,v=S=>{const M=p?.addonDefaults[S]??null;s({addonId:S,agentNodeId:e}),i(M)},w=(S,M)=>{if(!p)return;const P=p.addonDefaults[S],I=vi(f,S);if(!P&&!I)return;const z={enabled:M,modelId:P?.modelId??I?.defaultModelId??"",settings:P?.settings??{}};d.mutate({agentNodeId:e,defaults:{...p.addonDefaults,[S]:z}})},y=()=>{s(null),i(null)},N=()=>{!a||!o||!p||d.mutate({agentNodeId:e,defaults:{...p.addonDefaults,[o.addonId]:a}},{onSuccess:y})};if(l.isLoading||c.isLoading)return r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading pipeline…"});if(l.error)return u("div",{className:"text-xs text-red-400",children:["Failed to load catalog: ",String(l.error)]});if(!f)return r("div",{className:"text-xs text-foreground-subtle",children:"Catalog unavailable for this node (runner offline?)."});const k=o!==null&&x!==null&&a!==null;return u("div",{className:"relative h-full w-full space-y-3",children:[r(Vy,{nodeId:e}),r("div",{className:k?"pr-[360px]":"",children:h.length>0?r(Xl,{tree:h,agents:g,getCellState:b,onCellClick:v,selectedCell:o,onToggleEnabled:w}):r("div",{className:"text-xs text-foreground-subtle",children:"Catalog empty."})}),r(Zl,{open:k,onClose:y,title:x?.name??"",subtitle:o?`${o.agentNodeId} · ${m}`:"",footer:u(xe,{children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:y,children:"Cancel"}),r("button",{type:"button",disabled:!a||!o||d.isPending,className:"px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50",onClick:N,children:d.isPending?"Saving…":"Save"})]}),children:x&&a&&o&&r(na,{mode:"agent",addon:x,agentDefault:a,agentNodeId:o.agentNodeId,engineFormat:m,onChangeAgentConfig:S=>i(S)})})]})}function qy({pendingCount:e,onSave:t,onDiscard:n,saving:o=!1,saveLabel:s="Save",discardLabel:a="Discard"}){return e<=0?null:u("div",{className:"sticky bottom-0 -mb-3 flex items-center justify-between gap-3 rounded-lg border border-primary/40 bg-primary/5 px-3 py-2 shadow-sm z-10",children:[u("span",{className:"text-xs text-foreground",children:[e," unsaved change",e===1?"":"s"]}),u("div",{className:"flex items-center gap-2",children:[r("button",{type:"button",onClick:n,disabled:o,className:"inline-flex items-center rounded-md border border-border px-2.5 py-1 text-xs text-foreground-subtle hover:bg-surface-hover disabled:opacity-50",children:a}),r("button",{type:"button",onClick:t,disabled:o,className:"inline-flex items-center rounded-md bg-primary px-3 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:o?"Saving…":s})]})]})}function Qy({tabs:e,activeId:t,onChange:n,countByTab:o,pendingByTab:s}){return e.length===0?null:r("div",{className:"flex flex-wrap items-center gap-1 border-b border-border shrink-0",children:e.map(a=>{const i=a.id===t,l=o?.get(a.id)??0,c=s?.get(a.id)??0;return u("button",{type:"button",onClick:()=>n(a.id),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${i?"text-primary border-primary bg-primary/5":"text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover"}`,children:[a.label,l>0&&u("span",{className:"ml-1.5 text-[10px] opacity-60",children:["(",l,")"]}),c>0&&r("span",{className:"ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-primary"})]},a.id)})})}function lO(e,t){for(const n of e)for(const o of n.fields){if(!("key"in o)||o.key!==t)continue;if(o.type==="button"||o.type==="separator"||o.type==="info")return!0;const s=o.immediate;return s===!0?!0:s===!1?!1:n.immediate===!0}return!1}function Uy({schema:e,serverValues:t,onImmediateSave:n,onDeferredSave:o}){const[s,a]=_({}),[i,l]=_(!1),c=ne(null),d=e?.sections??[],f=Object.keys(s).length>0,p=U(()=>({...t,...s}),[t,s]);Z(()=>{if(f){l(!0);return}c.current&&clearTimeout(c.current),c.current=setTimeout(()=>l(!1),500)},[f]);const m=q(()=>{l(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>l(!1),2e3)},[]),h=q(v=>{m();const w={},y={},N={...t,...s};for(const[k,S]of Object.entries(v))N[k]!==S&&(lO(d,k)?w[k]=S:y[k]=S);Object.keys(w).length>0&&n(w),a(k=>{const S={...k};for(const M of Object.keys(w))delete S[M];for(const[M,P]of Object.entries(y))S[M]=P;return S})},[m,t,s,d,n]),g=q(v=>{const w={},y={};for(const[N,k]of Object.entries(s))v.includes(N)?w[N]=k:y[N]=k;a(y),Object.keys(w).length>0&&o(w)},[s,o]),b=q(v=>{a(w=>{const y={...w};for(const N of v)delete y[N];return y})},[]),x=q(()=>{a({})},[]);return{values:p,pendingKeys:Object.keys(s),hasPendingEdits:f,editingPaused:i,handleChange:h,handleSave:g,handleDiscard:b,resetAll:x}}const cO=He(function({addonId:t,schema:n,serverValues:o,onImmediateSave:s,onStateChange:a,onAction:i,disabled:l},c){const d=Uy({schema:n,serverValues:o,onImmediateSave:q(b=>s(t,b),[t,s]),onDeferredSave:q(()=>{},[])});W1(c,()=>({flush:()=>{const b={};for(const x of d.pendingKeys)b[x]=d.values[x];return d.handleDiscard(d.pendingKeys),b},discard:()=>d.resetAll()}),[d]);const f=d.pendingKeys,p=f.join("|"),m=U(()=>f.map(b=>`${b}=${JSON.stringify(d.values[b])}`).join(","),[f,d.values]),h=ne(a);Z(()=>{h.current=a},[a]),Z(()=>{const b={};for(const x of f)b[x]=d.values[x];h.current({addonId:t,pendingKeys:f,pendingValues:b})},[t,p,m]);const g=U(()=>{if(i)return(b,x,v)=>i(t,b,x,v)},[t,i]);return r(wn,{schema:n,values:d.values,onChange:d.handleChange,disabled:l,onAction:g})});function Ky(e,t){if(e.type==="separator"||e.type==="info"||e.type==="button")return e;if(e.type==="group"){const a=e.fields.map(i=>Ky(i,t));return{...e,fields:a}}const n=e;t[e.key]=n.value;const{value:o,...s}=n;return s}function dO(e,t){return{...e,fields:e.fields.map(n=>Ky(n,t))}}function uO(e){const t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(o=>dO(o,t))},values:t}}function Tr({nodeId:e,addonIds:t,level:n,deviceId:o,sectionIds:s,sectionTab:a,extraTabs:i,title:l,description:c}){const d=ke(),f=Le().trpcClient,p=Jh(),m=eg(),h=ab(),g=hg(),b=ig(),x=!!(i&&i.length>0),[v,w]=_(null);if(n==="device"&&!o)throw new Error('NodeAddonsSettingsPanel: deviceId is required when level === "device"');const y=e??"hub",N=X1({queries:t.map(J=>({queryKey:[["addonSettings",n==="global"?"getGlobalSettings":"getDeviceSettings"],{addonId:J,nodeId:y,deviceId:o??null}],queryFn:async()=>{if(n==="global"){const ee=await f.addonSettings.getGlobalSettings.query({addonId:J,nodeId:y});return{addonId:J,result:ee}}const G=await f.addonSettings.getDeviceSettings.query({addonId:J,deviceId:o,nodeId:y});return{addonId:J,result:G}},staleTime:3e4}))}),k=N.some(J=>J.isLoading),S=N.map(J=>{if(!J.data)return"-";if(J.data.result===null)return`${J.data.addonId}:n`;const G=[];for(const ee of J.data.result.sections){G.push(`s:${ee.id}:${ee.tab??"general"}`);for(const ae of ee.fields){if(!("key"in ae))continue;const fe="options"in ae&&Array.isArray(ae.options)?ae.options.map(ie=>ie.value).join(","):"",he=ae.value,V=he===void 0?"":typeof he=="string"?he:JSON.stringify(he);G.push(`f:${ae.key}:${fe}:${V}`)}}return`${J.data.addonId}:${G.join("|")}`}).join("||"),M=U(()=>{const J=new Set;for(const G of N){const ee=G.data?.result?.sections;if(ee)for(const ae of ee)J.add(ae.tab??"general")}return[...J]},[S+"::"+N.map(J=>(J.data?.result?.sections??[]).map(G=>G.tab??"general").join(",")).join("::")]),P=U(()=>new Map((i??[]).map(J=>[J.id,J])),[i]),I=U(()=>{if(!x)return[];const J=[...new Set([...M,...(i??[]).map(ee=>ee.id)])],G=ee=>{const ae=P.get(ee);if(ae?.order!==void 0)return ae.order;const fe=Di[ee];return fe?fe.order:50};return J.sort((ee,ae)=>{const fe=G(ee),he=G(ae);return fe!==he?fe-he:ee.localeCompare(ae)})},[x,M,i,P]),z=U(()=>{const J=new Map;for(const G of M){const ee=Di[G];J.set(G,ee?.label??G.charAt(0).toUpperCase()+G.slice(1))}for(const G of i??[])J.set(G.id,G.label);return J},[M,i]),$=x?v&&I.includes(v)?v:I[0]??null:null,O=$!==null&&P.has($),R=x?$&&!O?$:void 0:a,{data:A}=ra(void 0,{staleTime:6e4}),L=U(()=>{const J=new Map;for(const G of A??[]){const ee=G.manifest?.id;if(!ee)continue;const ae=G.manifest?.name??G.manifest?.packageDisplayName??ee;J.set(ee,ae)}return J},[A]),D=U(()=>{const J=s?new Set(s):null,G=[];for(const ee of N){if(!ee.data||ee.data.result===null)continue;const{schema:ae,values:fe}=uO(ee.data.result),he=ae.sections.filter(ue=>J?J.has(ue.id):!0);if(he.length===0)continue;const V={...ee.data.result,sections:ee.data.result.sections.filter(ue=>J?J.has(ue.id):!0)},ie={...ae,sections:he};G.push({addonId:ee.data.addonId,schemaWithValues:V,schema:ie,serverValues:fe})}return G},[S,s]),[T,B]=_(new Map),F=q(J=>{B(G=>{const ee=new Map(G);return ee.set(J.addonId,J),ee})},[]),j=ne(new Map),H=q(J=>G=>{G?j.current.set(J,G):j.current.delete(J)},[]),E=q(async(J,G)=>{n==="global"?await p.mutateAsync({addonId:J,nodeId:y,patch:G}):await m.mutateAsync({addonId:J,deviceId:o,nodeId:y,patch:G}),d.invalidateQueries({queryKey:[["addonSettings"]]})},[p,m,y,n,o,d]),Q=q(async(J,G,ee,ae)=>{const fe=y;try{switch(G){case"reprobe-engine":await h.mutateAsync({nodeId:fe}),d.invalidateQueries({queryKey:[["addonSettings"]]});return;case"reprobe-hwaccel":await g.mutateAsync({nodeId:fe}),d.invalidateQueries({queryKey:[["addonSettings"]]});return;case"reprobe-audio-engine":await b.mutateAsync({nodeId:fe}),d.invalidateQueries({queryKey:[["addonSettings"]]});return;default:{const he=await f.addons.custom.mutate({addonId:J,action:G,input:ae});return d.invalidateQueries({queryKey:[["addonSettings"]]}),he}}}catch(he){throw console.error("[NodeAddonsSettingsPanel] action failed",{addonId:J,action:G,err:he}),he}},[h,g,b,y,d,f]),K=q((J,G)=>{E(J,G)},[E]),Y=_l({mutationFn:async()=>{const J=[];for(const ee of D){const ae=T.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:y,patch:ae}):await m.mutateAsync({addonId:ee,deviceId:o,nodeId:y,patch:ae}),ee)))}},onSuccess:({saved:J})=>{for(const G of J)j.current.get(G)?.discard();d.invalidateQueries({queryKey:[["addonSettings"]]})}}),re=q(()=>{for(const J of j.current.values())J.discard()},[]),te=U(()=>{let J=0;for(const G of D){const ee=T.get(G.addonId);ee&&(J+=ee.pendingKeys.length)}return J},[D,T]),X=U(()=>{const J=new Map;for(const G of D){const ee=T.get(G.addonId);if(!ee||ee.pendingKeys.length===0)continue;const ae=new Set(ee.pendingKeys);for(const fe of G.schema.sections){const he=fe.tab??"general";for(const V of fe.fields)"key"in V&&ae.has(V.key)&&J.set(he,(J.get(he)??0)+1)}}return J},[D,T]);if(k)return r("div",{className:"h-24 rounded-lg border border-border bg-surface animate-pulse"});const oe=$&&O?P.get($):void 0;if(!x&&D.length===0)return u("div",{className:"text-[11px] text-foreground-subtle italic",children:["No addons in ",t.length>0?`[${t.join(", ")}]`:"the current selection"," ","expose ",n,"-level settings on this node."]});const ge=Y.isPending;return u("div",{className:"space-y-4",children:[(l||c)&&u("div",{className:"border-b border-border pb-2",children:[l&&r("h2",{className:"text-sm font-semibold text-foreground",children:l}),c&&r("p",{className:"text-[11px] text-foreground-subtle mt-0.5",children:c})]}),x&&r(Qy,{tabs:I.map(J=>({id:J,label:z.get(J)??J})),activeId:$,onChange:w,pendingByTab:X}),Y.isError&&u("div",{className:"rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400",children:["Save failed: ",String(Y.error?.message??Y.error)]}),oe?oe.content:(()=>{const J=R?D.reduce((ae,fe)=>ae+fe.schemaWithValues.sections.filter(he=>(he.tab??"general")===R).length,0):0,G=R!==null&&J<=1,ee=D.map(ae=>({...ae,renderedWithValues:{...ae.schemaWithValues,sections:ae.schemaWithValues.sections.filter(fe=>R?(fe.tab??"general")===R:!0).map(fe=>G?{...fe,title:"",description:void 0}:fe)}})).filter(ae=>ae.renderedWithValues.sections.length>0).sort((ae,fe)=>{const he=ue=>{let de=Number.POSITIVE_INFINITY;for(const le of ue)typeof le.order=="number"&&le.order<de&&(de=le.order);return de},V=he(ae.renderedWithValues.sections),ie=he(fe.renderedWithValues.sections);return V!==ie?V-ie:0});return ee.length===0?r("div",{className:"text-[11px] text-foreground-subtle italic",children:"Nothing to configure here for this node."}):r(pO,{entries:ee,paneStates:T,displayNames:L,disabled:ge,setPaneRef:H,onPaneStateChange:F,onImmediateSave:K,onAction:Q,inline:x||!!a})})(),!k&&r(qy,{pendingCount:te,onSave:()=>Y.mutate(),onDiscard:re,saving:ge})]})}function pO({entries:e,paneStates:t,displayNames:n,disabled:o,setPaneRef:s,onPaneStateChange:a,onImmediateSave:i,onAction:l,inline:c}){const d=U(()=>[...e].sort((x,v)=>{if(x.addonId==="system-config")return-1;if(v.addonId==="system-config")return 1;const w=n.get(x.addonId)??x.addonId,y=n.get(v.addonId)??v.addonId;return w.localeCompare(y)}),[e,n]),f=d[0]?.addonId??"",[p,m]=_(f);Z(()=>{d.length!==0&&(d.find(x=>x.addonId===p)||m(d[0].addonId))},[d,p]);const h=d.find(x=>x.addonId===p)??d[0];if(!h)return null;const g=U(()=>l?(x,v,w,y)=>l(x,v,w,y):void 0,[l]),b=x=>r(cO,{ref:s(x.addonId),addonId:x.addonId,schema:x.renderedWithValues,serverValues:x.serverValues,onImmediateSave:i,onStateChange:a,onAction:g,disabled:o},x.addonId);return d.length===1||c?r("div",{className:"flex flex-col gap-4",children:d.map(b)}):u("div",{className:"flex flex-col gap-3",children:[r("div",{className:"flex flex-wrap items-center gap-1 border-b border-border shrink-0",children:d.map(x=>{const v=n.get(x.addonId)??x.addonId,w=x.addonId===h.addonId,y=(t.get(x.addonId)?.pendingKeys.length??0)>0;return u("button",{type:"button",onClick:()=>m(x.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${w?"text-primary border-primary bg-primary/5":"text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover"}`,children:[v,y&&r("span",{className:"ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400"})]},x.addonId)})}),r("div",{className:"space-y-2",children:d.map(x=>r("div",{style:x.addonId===h.addonId?void 0:{display:"none"},children:b(x)},x.addonId))})]})}const fO=["detection-pipeline","decoder-nodeav","audio-analyzer","pipeline-runner"];function mO({nodeId:e,refreshToken:t}){return u("div",{className:"flex flex-col h-full",children:[r(V6,{nodeId:e,refreshToken:t}),r("div",{className:"flex-1 min-h-0 overflow-y-auto p-6",children:r(Tr,{nodeId:e,addonIds:fO,level:"global",extraTabs:[{id:"assignments",label:"Assignments",order:-10,content:r(X6,{nodeId:e,refreshToken:t})},{id:"tree",label:"Pipeline",order:39,content:r(iO,{nodeId:e,refreshToken:t})},{id:"engines",label:"Warm instances",order:180,content:r(eO,{nodeId:e,refreshToken:t})},{id:"models",label:"Models",order:200,content:r(aO,{nodeId:e,refreshToken:t})}]})})]})}function hO({refreshToken:e}){const t=ke(),n=fb({onSuccess:()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","getPipelineAssignments"]]}),t.invalidateQueries({queryKey:[["pipelineOrchestrator","getDecoderAssignments"]]}),t.invalidateQueries({queryKey:[["pipelineOrchestrator","getAudioAssignments"]]})}});return u("div",{className:"space-y-6",children:[r(zy,{refreshToken:e}),u("div",{className:"flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between",children:[u("div",{className:"min-w-0",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Placement matrix"}),r("p",{className:"text-[11px] text-foreground-subtle",children:"Pipeline · decoder · audio assignments per camera. Click the kebab to pin / unpin / move any role; expand the chevron for the per-camera broker drill-down."})]}),u("button",{type:"button",onClick:()=>n.mutate(void 0),disabled:n.isPending,className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-white hover:bg-primary/90 disabled:opacity-50 shrink-0 self-start @md/clustertab:self-auto whitespace-nowrap",children:[r(Jc,{className:"h-3.5 w-3.5"}),n.isPending?"Rebalancing…":"Rebalance pipelines"]})]}),r(jy,{mode:"cluster"})]})}const gO=["pipeline-orchestrator"];function bO({refreshToken:e}){return r("div",{className:"space-y-4 max-w-3xl",children:r(Tr,{nodeId:"hub",addonIds:gO,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 xO({refreshToken:e}){const t=ke(),{data:n,isLoading:o}=Pb(),[s,a]=_(null),[i,l]=_(""),[c,d]=_(""),f=()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","listTemplates"]]})},p=Eb({onSuccess:()=>{a(null),f()}}),m=$b({onSuccess:f}),h=v=>{a(v.id),l(v.name),d(v.description??"")},g=()=>{a(null),l(""),d("")},b=()=>{if(!s)return;const v=c.trim();p.mutate({id:s,name:i.trim()||"Untitled",...v?{description:v}:{}})};if(o)return r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading templates…"});const x=[...n??[]].sort((v,w)=>v.name.localeCompare(w.name));return r("div",{className:"space-y-6 max-w-4xl",children:u("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"border-b border-border px-4 py-3 flex items-center justify-between",children:[u("div",{children:[r("h3",{className:"text-sm font-semibold text-foreground",children:"Templates"}),r("p",{className:"text-[11px] text-foreground-subtle mt-0.5",children:"Curated pipeline presets operators can apply to any camera. Apply-time is a copy — future edits to a template don't retroactively change cameras that were seeded from it. Save a template from the device Pipeline tab."})]}),u("div",{className:"text-[11px] text-foreground-subtle",children:[x.length," template",x.length===1?"":"s"]})]}),x.length===0?u("div",{className:"px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2",children:[r(ut,{className:"h-6 w-6 opacity-40"}),r("div",{children:'No templates yet. Create one from a device Pipeline tab ("Save as template").'})]}):r("ul",{className:"divide-y divide-border",children:x.map(v=>{const w=s===v.id;return r("li",{className:"px-4 py-3 text-xs",children:u("div",{className:"flex items-start gap-3",children:[r("div",{className:"flex-1 min-w-0",children:w?u("div",{className:"space-y-2",children:[r("input",{className:"w-full rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary",value:i,onChange:y=>l(y.target.value),placeholder:"Template name",autoFocus:!0}),r("input",{className:"w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary",value:c,onChange:y=>d(y.target.value),placeholder:"Description (optional)"})]}):u(xe,{children:[r("div",{className:"font-medium text-foreground",children:v.name}),v.description&&r("div",{className:"text-foreground-subtle mt-0.5",children:v.description}),u("div",{className:"mt-1 font-mono text-[10px] text-foreground-subtle",children:["engine ",v.config.engine.runtime,"/",v.config.engine.backend," · ",v.config.steps.length," step(s)",v.config.audio?.enabled?" · audio":"",u("span",{className:"ml-2",children:["updated ",new Date(v.updatedAt).toLocaleString()]})]})]})}),r("div",{className:"flex items-center gap-1 shrink-0",children:w?u(xe,{children:[u("button",{type:"button",onClick:b,disabled:p.isPending,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-50",children:[r(Mt,{className:"h-3 w-3"}),"Save"]}),u("button",{type:"button",onClick:g,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover",children:[r(Ve,{className:"h-3 w-3"}),"Cancel"]})]}):u(xe,{children:[r("button",{type:"button",onClick:()=>h(v),title:"Rename",className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover",children:r(Ao,{className:"h-3 w-3"})}),r("button",{type:"button",onClick:()=>{confirm(`Delete template "${v.name}"?`)&&m.mutate({id:v.id})},disabled:m.isPending,title:"Delete",className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-red-400 hover:bg-surface-hover disabled:opacity-50",children:r(Ge,{className:"h-3 w-3"})})]})})]})},v.id)})})]})})}function pp(e,t){if(!e)return null;for(const n of e.slots)for(const o of n.addons)if(o.id===t)return o;return null}function yO({nodeId:e,refreshToken:t}){const n=ke(),o=Le().trpcClient,[s,a]=_(null),[i,l]=_(null),c=Er(void 0,{refetchOnMount:"always"});yt(["nodes","topology"],["agent.online","agent.offline","agent.unregistered","addon.installed","addon.uninstalled","addon.updated"]);const d=Mn(void 0,{staleTime:3e4,refetchOnMount:"always"}),f=U(()=>{const I=new Set;for(const z of d.data??[])z.isOnline&&I.add(z.id);return I},[d.data]),p=ko({nodeId:e},{refetchOnMount:"always"}),m=U(()=>(c.data??[]).filter(I=>f.has(I.nodeId)).map(I=>I.nodeId),[c.data,f]),h=Un({enabled:m.length>0,queryKey:[["pipelineExecutor","getSchema"],"schema-by-agent",m.join(","),t],queryFn:async()=>{const I={};for(const z of m)try{const $=await o.pipelineExecutor.getSchema.query({nodeId:z});I[z]=$.selectedEngine.format}catch{I[z]="coreml"}return I}}),g=vc({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator"]]}),n.invalidateQueries({queryKey:[["pipelineExecutor"]]}),n.invalidateQueries({queryKey:[["addonSettings"]]})}}),b=U(()=>p.data?ea(p.data):[],[p.data]),x=U(()=>{const I=c.data??[],z=f;return(z.size===0?[]:I.filter(O=>z.has(O.nodeId))).map(O=>{const R=h.data?.[O.nodeId];return{agentNodeId:O.nodeId,engineLabel:R??"(engine unknown)"}})},[c.data,h.data,f]),v=(I,z)=>{const O=c.data?.find(D=>D.nodeId===z)?.settings.addonDefaults[I],R=h.data?.[z];return pp(p.data??null,I)?.models.some(D=>R!==void 0&&!!D.formats[R])?O?O.enabled?{kind:"enabled",modelId:O.modelId}:{kind:"disabled"}:{kind:"na"}:{kind:"na"}},w=s?c.data?.find(I=>I.nodeId===s.agentNodeId)??null:null,y=s&&p.data?pp(p.data,s.addonId):null,N=s?h.data?.[s.agentNodeId]??"coreml":"coreml",k=()=>{a(null),l(null)},S=(I,z)=>{const O=c.data?.find(R=>R.nodeId===z)?.settings.addonDefaults[I]??null;a({addonId:I,agentNodeId:z}),l(O)},M=()=>{!i||!s||!w||g.mutate({agentNodeId:s.agentNodeId,defaults:{...w.settings.addonDefaults,[s.addonId]:i}},{onSuccess:k})};if(c.isLoading||p.isLoading)return r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading agents…"});if(!p.data)return u("div",{className:"text-xs text-foreground-subtle",children:["Catalog unavailable for ",e,"."]});const P=s!==null&&y!==null&&i!==null;return u("div",{className:"relative h-full w-full space-y-3",children:[r(Vy,{title:"Cluster cameras"}),r("div",{className:P?"pr-[360px]":"",children:b.length>0&&x.length>0?r(Xl,{tree:b,agents:x,getCellState:v,onCellClick:S,selectedCell:s}):r("div",{className:"text-xs text-foreground-subtle",children:"No agents or catalog empty."})}),r(Zl,{open:P,onClose:k,title:y?.name??"",subtitle:s?`${s.agentNodeId} · ${N}`:"",footer:u(xe,{children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:k,children:"Cancel"}),r("button",{type:"button",disabled:!i||!s||g.isPending,className:"px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50",onClick:M,children:g.isPending?"Saving…":"Save"})]}),children:y&&i&&s&&r(na,{mode:"agent",addon:y,agentDefault:i,agentNodeId:s.agentNodeId,engineFormat:N,onChangeAgentConfig:I=>l(I)})})]})}const vO=[{id:"assignments",label:"Assignments"},{id:"pipeline",label:"Pipeline"},{id:"settings",label:"Settings"},{id:"templates",label:"Templates"}];function wO({refreshToken:e}){const[t,n]=_("assignments"),{data:o}=Mn(void 0,{staleTime:3e4}),s=o?.find(a=>a.isHub&&a.isOnline)?.id??o?.find(a=>a.isOnline)?.id??null;return u("div",{className:"flex flex-col h-full",children:[u("div",{className:"px-6 py-4 border-b border-border",children:[r("h2",{className:"text-base font-semibold text-foreground",children:"Cluster Orchestration"}),r("div",{className:"text-[11px] text-foreground-subtle mt-1",children:"Assignments with live load, cluster-wide settings, pipeline template library, per-camera pipeline overrides."})]}),r("div",{className:"flex items-center gap-1 px-6 border-b border-border",children:vO.map(a=>r("button",{type:"button",onClick:()=>n(a.id),className:`px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===a.id?"border-primary text-primary":"border-transparent text-foreground-subtle hover:text-foreground"}`,children:a.label},a.id))}),u("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab",children:[t==="assignments"&&r(hO,{refreshToken:e}),t==="pipeline"&&(s?r(yO,{nodeId:s,refreshToken:e}):r("div",{className:"text-xs text-foreground-subtle",children:"No online node available — schema unreachable."})),t==="settings"&&r(bO,{refreshToken:e}),t==="templates"&&r(xO,{refreshToken:e})]})]})}const Jr="__cluster__";function NO(){const[e,t]=ha(),n=e.get("node")??Jr,[o,s]=_(0);return Z(()=>{e.get("node")||t({node:Jr},{replace:!0})},[e,t]),u("div",{className:"flex flex-col h-full overflow-hidden",children:[u("div",{className:"flex items-center justify-between gap-4 px-6 py-4 border-b border-border shrink-0",children:[u("div",{className:"flex items-center gap-2",children:[r(sy,{className:"h-4 w-4 text-foreground-subtle"}),r("h1",{className:"text-lg font-semibold text-foreground",children:"Pipeline"})]}),u("button",{type:"button",onClick:()=>s(i=>i+1),title:"Refresh",className:"inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:[r(pt,{className:"h-3.5 w-3.5"}),"Refresh"]})]}),u("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden min-h-0",children:[r("aside",{className:"w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border overflow-y-auto",children:r(H6,{selectedNodeId:n,onSelect:i=>{t({node:i},{replace:!0})},refreshToken:o})}),r("section",{className:"flex-1 min-h-0 overflow-hidden",children:n===Jr?r(wO,{refreshToken:o}):r(mO,{nodeId:n,refreshToken:o})})]})]})}function kO(e){const[t,n]=_("idle"),[o,s]=_(null),a=ne(null),i=ne(null),l=ne(null),c=ne(!0),d=Bg(),f=Fg(),p=jg(),m=q(()=>{if(a.current){try{a.current.close()}catch{}a.current=null}if(i.current){for(const b of i.current.getTracks())try{b.stop()}catch{}i.current=null}l.current=null},[]),h=q(async()=>{if(t==="idle")return;n("stopping");const b=l.current;if(b&&e!==null)try{await Promise.race([p.mutateAsync({deviceId:e,sessionId:b}),new Promise((v,w)=>setTimeout(()=>w(new Error("server stopSession timeout")),2e3))])}catch(v){console.warn("[intercom] server stopSession failed (continuing teardown)",v)}m(),c.current&&(n("idle"),s(null))},[t,e,p,m]),g=q(async()=>{if(e===null||t!=="idle"&&t!=="error")return;s(null);let b=null,x=null,v=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});v=w.sessionId,l.current=v,n("connecting"),x=new RTCPeerConnection,a.current=x,x.oniceconnectionstatechange=()=>{if(!c.current)return;const k=x.iceConnectionState;k==="connected"||k==="completed"?n("talking"):(k==="failed"||k==="closed"||k==="disconnected")&&c.current&&(s(k==="failed"?"WebRTC connection failed":null),h())};for(const k of b.getAudioTracks())x.addTrack(k,b);await x.setRemoteDescription({type:"offer",sdp:w.sdpOffer});const y=await x.createAnswer();await x.setLocalDescription(y);const N=x.localDescription?.sdp??y.sdp??"";await f.mutateAsync({deviceId:e,sessionId:v,sdpAnswer:N})}catch(w){const y=w instanceof Error?w.message:String(w);if(console.warn("[intercom] start failed",w),x)try{x.close()}catch{}if(b)for(const N of b.getTracks())try{N.stop()}catch{}if(a.current=null,i.current=null,v!==null)try{await p.mutateAsync({deviceId:e,sessionId:v})}catch{}l.current=null,c.current&&(s(y),n("error"))}},[e,t,d,f,p,h]);return Z(()=>(c.current=!0,()=>{c.current=!1;const b=l.current;if(b!==null&&e!==null&&p.mutate({deviceId:e,sessionId:b}),a.current){try{a.current.close()}catch{}a.current=null}if(i.current){for(const x of i.current.getTracks())try{x.stop()}catch{}i.current=null}l.current=null}),[e]),{state:t,error:o,start:g,stop:h,isTalking:t==="talking"}}let SO=0;function ot(){return++SO}function wi(e){switch(e.type){case"system":return"system";case"device":return`#${e.deviceId}`;case"provider":return e.providerId;case"addon":return e.addonId}}function CO(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 MO(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 IO(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 AO({scope:e,greeting:t,className:n}){const o=Le(),[s,a]=_(()=>{const y=[];return t&&y.push({id:ot(),kind:"info",text:t}),y.push({id:ot(),kind:"info",text:`scope: ${wi(e)} — type help or context for available commands`}),y}),[i,l]=_(""),[c,d]=_([]),[f,p]=_(-1),m=ne(null),h=ne(null);Z(()=>{const y=h.current;y&&(y.scrollTop=y.scrollHeight)},[s]);const g=q(()=>{m.current?.focus()},[]),b=_l({mutationFn:y=>o.trpcClient.repl.execute.mutate({code:y,scope:e}),onSuccess:y=>{const N=y??{},k=typeof N.output=="string"?N.output:y==null?"undefined":typeof y=="string"?y:JSON.stringify(y,null,2),S=N.type==="error";a(M=>[...M,{id:ot(),kind:S?"error":"result",text:k}])},onError:y=>{const N=y instanceof Error?y.message:String(y);a(k=>[...k,{id:ot(),kind:"error",text:N}])}});function x(y){const N=y.trim();if(N){if(N==="clear"){a([{id:ot(),kind:"info",text:`scope: ${wi(e)}`}]),l("");return}if(N==="help"){a(k=>[...k,{id:ot(),kind:"input",text:`> ${N}`},...CO(e).map(S=>({id:ot(),kind:"info",text:S}))]),l("");return}if(N==="context"){a(k=>[...k,{id:ot(),kind:"input",text:`> ${N}`},...IO(e).map(S=>({id:ot(),kind:"info",text:S}))]),l("");return}if(N==="examples"){a(k=>[...k,{id:ot(),kind:"input",text:`> ${N}`},...MO(e).map(S=>({id:ot(),kind:"info",text:S}))]),l("");return}d(k=>[...k,N]),p(-1),a(k=>[...k,{id:ot(),kind:"input",text:`> ${N}`}]),l(""),b.mutate(N)}}function v(y){if(y.key==="Enter"){y.preventDefault(),x(i);return}if(y.key==="ArrowUp"){if(y.preventDefault(),c.length===0)return;const N=f===-1?c.length-1:Math.max(0,f-1);p(N),l(c[N]??"");return}if(y.key==="ArrowDown"){if(y.preventDefault(),f===-1)return;const N=f+1;N>=c.length?(p(-1),l("")):(p(N),l(c[N]??""));return}y.ctrlKey&&y.key==="l"&&(y.preventDefault(),a([{id:ot(),kind:"info",text:`scope: ${wi(e)}`}]))}const w={input:"text-zinc-300",result:"text-emerald-300",error:"text-red-300",info:"text-zinc-400"};return u("div",{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${n??""}`,onClick:g,children:[u("div",{ref:h,className:"flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]",children:[s.map(y=>r("pre",{className:`whitespace-pre-wrap break-words leading-relaxed ${w[y.kind]}`,children:y.text},y.id)),b.isPending&&r("span",{className:"text-zinc-500 animate-pulse",children:"…thinking"})]}),u("div",{className:"flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]",children:[r("span",{className:"text-emerald-400 flex-shrink-0 select-none font-bold",children:">"}),r("input",{ref:m,value:i,onChange:y=>l(y.target.value),onKeyDown:v,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 PO(e){const t=ke(),n=e!==null&&Number.isFinite(e),o=Db({deviceId:e??0},{enabled:n,refetchInterval:5e3,retry:1}),s=Lb({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),a=Tb({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),i=q(async d=>{e!==null&&await s.mutateAsync({deviceId:e,enabled:d})},[e,s]),l=q(async d=>{e!==null&&await a.mutateAsync({deviceId:e,settings:d})},[e,a]),c=o.error?o.error.message:s.error?s.error.message:a.error?a.error.message:null;return{status:o.data??null,isLoading:o.isLoading,isPending:s.isPending||a.isPending,error:c,setEnabled:i,setSettings:l}}function EO({deviceId:e}){const{status:t,isLoading:n,isPending:o,error:s,setEnabled:a,setSettings:i}=PO(Number.isFinite(e)?e:null),[l,c]=_({targetType:"",stopDelaySeconds:30,disappearDelaySeconds:15}),[d,f]=_(!1);return Z(()=>{if(d)return;const p=t?.currentSettings;p&&c({targetType:p.targetType,stopDelaySeconds:p.stopDelaySeconds,disappearDelaySeconds:p.disappearDelaySeconds})},[t,d]),n&&!t?u("div",{className:"flex items-center gap-2 px-3 py-2 text-[10.5px] text-foreground-subtle",children:[r(Pe,{className:"h-3 w-3 animate-spin"}),"Loading autotrack…"]}):u("div",{className:"border-t border-border/40 mt-2 pt-2 px-1 space-y-2",children:[u("div",{className:"flex items-center justify-between px-2",children:[u("div",{className:"flex items-center gap-1.5 text-[10.5px] font-semibold text-foreground",children:[r(PD,{className:"h-3 w-3 text-primary"}),"Autotracking"]}),u("button",{type:"button",onClick:()=>{a(!(t?.enabled??!1))},disabled:o,className:`flex items-center gap-1.5 rounded-md px-2 py-1 text-[10px] font-medium transition-colors ${t?.enabled?"bg-success/15 text-success hover:bg-success/25":"bg-surface-elevated/40 text-foreground-subtle hover:bg-surface-hover hover:text-foreground"} disabled:opacity-50`,"aria-pressed":t?.enabled??!1,children:[r("span",{className:`h-1.5 w-1.5 rounded-full ${t?.enabled?"bg-success":"bg-foreground-subtle/40"}`}),t?.enabled?"Enabled":"Disabled"]})]}),s&&u("div",{className:"flex items-start gap-1.5 rounded-md border border-danger/30 bg-danger/5 px-2 py-1.5 text-[10px] text-danger",children:[r(xa,{className:"h-3 w-3 flex-shrink-0 mt-0.5"}),r("span",{className:"leading-snug break-words",children:s})]}),u("div",{className:"grid grid-cols-2 gap-2 px-2",children:[(t?.supportedTargetTypes?.length??0)>0&&u("label",{className:"col-span-2 flex flex-col gap-1",children:[r("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Target type"}),r("select",{value:l.targetType,onFocus:()=>f(!0),onChange:p=>c(m=>({...m,targetType:p.target.value})),onBlur:()=>{f(!1);const p=t?.currentSettings?.targetType??"";l.targetType!==p&&i({targetType:l.targetType})},disabled:o,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50",children:(t?.supportedTargetTypes??[]).map(p=>r("option",{value:p.value,children:p.label},p.value))})]}),u("label",{className:"flex flex-col gap-1",children:[r("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Stop delay (s)"}),r("input",{type:"number",min:0,max:300,value:l.stopDelaySeconds,onFocus:()=>f(!0),onChange:p=>c(m=>({...m,stopDelaySeconds:Number(p.target.value)||0})),onBlur:()=>{f(!1);const p=t?.currentSettings?.stopDelaySeconds??30;l.stopDelaySeconds!==p&&i({stopDelaySeconds:l.stopDelaySeconds})},disabled:o,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50"})]}),u("label",{className:"flex flex-col gap-1",children:[r("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Disappear delay (s)"}),r("input",{type:"number",min:0,max:300,value:l.disappearDelaySeconds,onFocus:()=>f(!0),onChange:p=>c(m=>({...m,disappearDelaySeconds:Number(p.target.value)||0})),onBlur:()=>{f(!1);const p=t?.currentSettings?.disappearDelaySeconds??15;l.disappearDelaySeconds!==p&&i({disappearDelaySeconds:l.disappearDelaySeconds})},disabled:o,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50"})]})]}),r("p",{className:"px-2 text-[9.5px] text-foreground-subtle leading-snug italic",children:"Settings save on blur. Vendor support varies — Reolink honours all three; Hikvision honours target type + stop delay only (disappear delay is accepted but ignored at firmware push)."})]})}function $O({deviceId:e,intercomAvailable:t=!1}){const n=Le(),o=typeof window<"u"?window.location.origin:"",s=Number.isFinite(e),a=wy(s?e:null),{streams:i,pipelineMetrics:l,createSession:c,sendAnswer:d,closeSession:f}=Lc(n.trpcClient,s?e:null),p=rc(n.trpcClient,s?e:null),m=kO(s&&t?e:null),h=m.state==="requesting-mic"||m.state==="starting"||m.state==="connecting"||m.state==="stopping",g=m.isTalking||h,b=()=>{m.state==="idle"||m.state==="error"?m.start():m.state!=="stopping"&&m.stop()},x=wx(),v=x.length>0?r(xe,{children:x.map(w=>r("div",{className:"absolute inset-0",children:w.node},w.id))}):null;return r(Pc,{serverUrl:o,createSession:c,sendAnswer:d,closeSession:f,streams:i,pipelineMetrics:l,phase:a.phase,detections:a,defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:p.src,snapshotLoading:p.loading,onRefreshSnapshot:p.refresh,intercomAvailable:t,intercomShown:g,onIntercomToggle:b,extraOverlay:v,chromeless:!0,className:"h-full"})}function _O({deviceId:e}){return Number.isFinite(e)?r("div",{className:"flex flex-col h-full",children:r(Ut,{deviceId:e,limit:50,maxHeight:"max-h-full",showScope:!1,showFilters:!1})}):u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function DO({deviceId:e}){if(!Number.isFinite(e))return u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]});const t=[`CamStack REPL — device #${e}`,""," device.state.battery.value sync state read"," await device.snapshot.getSnapshot({}) cap action",""," type 'examples' for more, 'context' for the full API"].join(`
|
|
1084
|
+
`);return r(AO,{scope:{type:"device",deviceId:e},greeting:t,className:"h-full border-0 rounded-none"})}function LO({deviceId:e}){const t=Le(),n=Number.isFinite(e),o=Tc(t.trpcClient,n?e:0,{enabled:n}),{data:s}=q6(n?e:0);if(!n)return u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]});const a=(s?.features??[]).includes(Tn.PtzAutotrack);return u("div",{className:"flex flex-col h-full overflow-y-auto",children:[r(_c,{controls:o,mode:"panel"}),a&&r(EO,{deviceId:e})]})}function TO({deviceId:e}){return Number.isFinite(e)?r("div",{className:"flex flex-col h-full overflow-y-auto",children:r(tr,{deviceId:e,limit:50,maxHeight:"max-h-full"})}):u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function RO({deviceId:e}){return Number.isFinite(e)?r("div",{className:"flex flex-col h-full overflow-y-auto",children:r($c,{deviceId:e,limit:50,maxHeight:"max-h-full"})}):u("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]})}function OO({parentDeviceId:e}){const{t}=Rt(),n=Je(),o=Le(),{data:s,isLoading:a,isError:i}=Fy(e);if(a)return r("div",{className:"rounded-lg border border-border bg-surface p-3",children:r("p",{className:"text-[10px] text-foreground-subtle",children:t("common.loading",{defaultValue:"Loading…"})})});if(i)return r("div",{className:"rounded-lg border border-border bg-surface p-3",children:r("p",{className:"text-[10px] text-warning",children:t("integrations.childrenLoadError",{defaultValue:"Failed to load children"})})});const l=s??[];if(l.length===0)return null;const c=l.some(p=>!!p.role),d=l.some(p=>!p.role),f=c&&!d?t("device.accessories",{defaultValue:"Accessories"}):!c&&d?t("device.adoptedDevices",{defaultValue:"Adopted devices"}):t("device.children",{defaultValue:"Children"});return u("div",{className:"rounded-lg border border-border bg-surface p-3",children:[r("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5",children:f}),r("div",{className:"space-y-1",children:l.map(p=>r(oo,{trpc:o.trpcClient,device:p,variant:"minimal",onNavigate:m=>n(`/devices/${String(m)}`)},p.id))})]})}function Ni(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function zO({device:e}){const t=Je(),n=typeof e.id=="number"?e.id:null,o=String(e.type??""),s=o===st.Camera,a=o===st.Hub,i=e.features??[],{data:l}=xc({deviceId:n??0},{enabled:n!==null&&s,refetchInterval:5e3}),c=l?.streams??{},d=Object.entries(c),f=i.includes(Tn.DoorbellButton),p=Rc(f?{deviceId:n??void 0,historyLimit:10}:void 0),m=p.latest?Date.now()-p.latest.timestamp<3e4:!1;return u("div",{className:"space-y-5",children:[a&&n!==null&&r(Cx,{deviceId:n,onOpenChild:h=>t(`/devices/${h}`)}),s&&n!==null&&r(at,{widgetId:"pipeline-orchestrator/pipeline-quick-stats",host:"device-tab",deviceId:n}),f&&r(Dc,{history:p.history,latestIsFresh:m}),s&&n!==null&&r(at,{widgetId:"stream-broker/stream-broker-panel",host:"device-tab",deviceId:n}),s&&d.length>0&&u("div",{className:"@container rounded-lg border border-border bg-surface overflow-hidden",style:{containerType:"inline-size"},children:[r("div",{className:"border-b border-border px-4 py-2",children:r("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"Stream Network"})}),r("div",{className:"divide-y divide-border",children:d.map(([h,g])=>u("div",{className:"px-4 py-2.5",children:[u("div",{className:"flex items-center gap-2 mb-2",children:[r(Fn,{className:"h-3 w-3 text-foreground-subtle"}),r("span",{className:"text-[11px] font-medium text-foreground",children:h})]}),u("div",{className:"grid grid-cols-2 @[640px]:grid-cols-4 gap-2",children:[r(Xo,{label:"Nominal",value:Ni(g.nominalBitrateKbps??0)}),r(Xo,{label:"Observed",value:Ni(g.observedBitrateKbps??0)}),r(Xo,{label:"Peak",value:Ni(g.peakBitrateKbps??0)}),r(Xo,{label:"Packet Loss",value:`${(g.packetLossPercent??0).toFixed(2)}%`,warning:(g.packetLossPercent??0)>1})]})]},h))})]}),r(ky,{})]})}function Xo({label:e,value:t,warning:n}){return u("div",{children:[r("p",{className:"text-[10px] text-foreground-subtle",children:e}),r("p",{className:`text-xs font-medium ${n?"text-warning":"text-foreground"}`,children:t})]})}function BO({schema:e,values:t,pendingKeys:n,onChange:o,onAction:s,onSave:a,onDiscard:i,disabled:l}){const c=e.tabs??[],d=U(()=>{const k=new Map;for(const S of e.sections){const M=S.tab??"general",P=k.get(M)??[];P.push(S),k.set(M,P)}return k},[e.sections]),f=new Set(c.map(k=>k.id)),p=[...c,...[...d.keys()].filter(k=>!f.has(k)).map(k=>({id:k,label:k,icon:"wrench",order:100}))],m=p[0]?.id??"general",[h,g]=_(m),b=d.get(h)??[],v={sections:b.length<=1?b.length===1?[{...b[0],title:""}]:b:b.every(S=>!S.title)?[{...b[0],title:"",fields:b.flatMap(S=>S.fields)}]:b},w=r(qy,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>i(n),saving:l});if(p.length<=1)return u("div",{className:"flex flex-col gap-3",children:[r(wn,{schema:e,values:t,onChange:o,onAction:s,disabled:l}),w]});const y=new Map,N=new Map;for(const[k,S]of d){y.set(k,S.length);const M=new Set,P=z=>{for(const $ of z)if("key"in $&&typeof $.key=="string"&&M.add($.key),$.type==="group")P($.fields);else if($.type==="sub-tabs")for(const O of $.tabs)P(O.fields)};for(const z of S)P(z.fields);const I=n.filter(z=>M.has(z)).length;I>0&&N.set(k,I)}return u("div",{className:"flex flex-col gap-3",children:[r(Qy,{tabs:p.map(k=>({id:k.id,label:k.label})),activeId:h,onChange:g,countByTab:y,pendingByTab:N}),r(wn,{schema:v,values:t,onChange:o,onAction:s,disabled:l}),w]})}const fp={viewer:10,admin:20,super_admin:30};function FO(e,t){if(!t)return!0;const n=fp[t];return n===void 0?!0:(e?fp[e]??0:0)>=n}function jO(e){if(!e)return null;const n={sections:[...e.sections].sort((o,s)=>{const a=o.tab??"general",i=s.tab??"general";return a!==i?a.localeCompare(i):(o.order??0)-(s.order??0)})};return e.tabs?{...n,tabs:e.tabs}:n}function Gy(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="widget"||e.type==="addon-action-button"}function Wy(e){return e.key}function HO(e){if(!Gy(e))return e.value}function Yy(e){return Gy(e)?null:e}function Ls(e,t){for(const n of e)if(t(n),n.type==="group")Ls(n.fields,t);else if(n.type==="sub-tabs")for(const o of n.tabs)Ls(o.fields,t)}function VO(e){if(!e)return{};const t={};for(const n of e.sections)Ls(n.fields,o=>{const s=Wy(o);s!==null&&(t[s]=HO(o))});return t}function mp(e,t){if(!e)return null;let n=null;for(const o of e.sections)if(Ls(o.fields,s=>{if(n!==null||Wy(s)!==t)return;const a=Yy(s);a&&a.writerCapName&&a.writerAddonId&&(n={capName:a.writerCapName,addonId:a.writerAddonId})}),n!==null)break;return n}function qO(e){return{...e,fields:e.fields.map(Zy)}}function Zy(e){return e.type==="separator"||e.type==="info"||e.type==="button"||e.type==="object-array"?e:{...e,readonlyField:!0}}function QO(e,t){return e&&{...e,sections:e.sections.map(n=>({...n,fields:n.fields.map(o=>{const s=Yy(o);return s?FO(t,s.minRole)?o:Zy(o):o})}))}}function Xy({deviceId:e,sectionFilter:t}){const n=ke(),{user:o}=Lr(),s=o?.role,a=ne(!1),{data:i,isLoading:l}=hc({deviceId:e},{refetchInterval:()=>a.current?!1:2500,staleTime:6e4,enabled:Number.isFinite(e)}),{data:c}=Bn({deviceId:e},{staleTime:6e4,enabled:Number.isFinite(e)}),d=i?.settings??null,f=i?.live??null,p=U(()=>{if(!d&&!f)return null;const O=d?.sections??[],R=(f?.sections??[]).map(qO),A=[...O,...R],L=t?A.filter(t):A.filter(F=>F.location!=="top-tab");if(L.length===0)return null;const D=new Set;for(const F of L)D.add(F.tab??"general");const B=[...d?.tabs??[],...(f?.tabs??[]).filter(F=>!(d?.tabs??[]).some(j=>j.id===F.id))].filter(F=>D.has(F.id));return B.length>0?{tabs:B,sections:L}:{sections:L}},[d,f,t]),m=U(()=>jO(p),[p]),h=U(()=>QO(m,s),[m,s]),g=U(()=>VO(h),[h]),b=Wb(),x=bc(),v=Ag({onSuccess:()=>{n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]})}}),w={isPending:v.isPending,mutate:O=>{v.mutate({deviceId:e,changes:[...O]})}},y=q(O=>{const R=Object.entries(O).map(([A,L])=>{const D=mp(h,A);return D?{writerCapName:D.capName,writerAddonId:D.addonId,key:A,value:L}:null}).filter(A=>A!==null);R.length>0&&w.mutate(R)},[h,w]),N=q(O=>{const R=Object.entries(O).map(([A,L])=>{const D=mp(h,A);return D?{writerCapName:D.capName,writerAddonId:D.addonId,key:A,value:L}:null}).filter(A=>A!==null);R.length>0&&w.mutate(R)},[h,w]),k=Uy({schema:h,serverValues:g,onImmediateSave:y,onDeferredSave:N}),{values:S,pendingKeys:M,handleChange:P,handleSave:I,handleDiscard:z}=k;if(a.current=k.editingPaused,l)return u("div",{className:"flex items-center justify-center py-12 text-foreground-subtle",children:[r(Pe,{className:"h-4 w-4 animate-spin mr-2"}),r("span",{className:"text-xs",children:"Loading device aggregate…"})]});if(!h||h.sections.length===0)return r("div",{className:"text-xs text-foreground-subtle italic py-4 text-center",children:"No aggregate contributions for this device."});async function $(O,R,A){if(O==="regenerate-rtsp-token"){const L=["rtspUrl:","regenerateToken:"].find(B=>R.startsWith(B));if(!L)throw new Error(`regenerate-rtsp-token: unrecognised key "${R}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);const D=R.slice(L.length);if(!D)throw new Error(`regenerate-rtsp-token: key "${R}" has no streamId after prefix`);const T=`${e}/${D}`;await b.mutateAsync({brokerId:T}),n.invalidateQueries({queryKey:[["deviceManager","getDeviceAggregate"]]});return}if(O==="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:A})}catch(L){return{status:"error",error:L instanceof Error?L.message:String(L)}}}if(O==="refresh-driver-data"){await v.mutateAsync({deviceId:e,changes:[{writerCapName:"device-manager",writerAddonId:"device-manager",key:R,value:Date.now()}]});return}throw new Error(`[device-aggregate] unknown action "${O}"`)}return r(BO,{schema:h,values:S,pendingKeys:M,onChange:P,onAction:$,onSave:I,onDiscard:z,disabled:w.isPending})}function UO({deviceId:e}){return r(Xy,{deviceId:e})}const Jy=6e4,pl=60*Jy,hp=24*pl;function Sa(e){if(e==null||e<=0)return"—";const t=Date.now()-e;return t<0||t<3e4?"just now":t<pl?`${String(Math.floor(t/Jy))}m ago`:t<hp?`${String(Math.floor(t/pl))}h ago`:`${String(Math.floor(t/hp))}d ago`}function KO(e,t=new Date){const n=new Date(e);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()}function e0({dev:e,busy:t,setBusy:n}){const o=e?.motionTrigger,s=nn(e?.state.motionTrigger),[a,i]=_(!1);if(!o)return null;const l=s?.enabled===!0,c=s!==void 0,d=async()=>{if(t||!c)return;const p=!l;n(!0),i(!0);try{await o.setMotionTrigger({enabled:p})}finally{n(!1),i(!1)}};return u("button",{type:"button",onClick:()=>{d()},disabled:t||!c,title:c?l?"Disable trigger on motion":"Enable trigger on motion":"Awaiting state…","aria-pressed":l,className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${l?"border-primary/50 bg-primary/15 text-primary":"border-border bg-surface text-foreground-subtle hover:text-foreground"}`,children:[r(Mo,{className:"h-3 w-3"}),r("span",{children:a?l?"Disabling…":"Enabling…":c?l?"On motion: on":"On motion: off":"On motion: …"})]})}function t0({deviceId:e,deviceName:t,useSiren:n=!1}){const o=Le(),s=St(o.trpcClient,e),a=nn(s?.state.switch),[i,l]=_(!1),c=a?.on??!1,d=a?.lastChangedAt??null,f=a!==void 0,p=n?Io:fy,m=async()=>{if(!(i||!f||!s?.switch)){l(!0);try{await s.switch.setState({on:!c})}finally{l(!1)}}};return u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[r("button",{type:"button",onClick:()=>{m()},disabled:i||!f||!s?.switch,title:f?c?`Turn off ${t}`:`Turn on ${t}`:"Awaiting state…","aria-pressed":c,className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all disabled:cursor-not-allowed disabled:opacity-50 ${c?"border-success bg-success/20 text-success shadow-lg shadow-success/20":"border-border bg-surface text-foreground-subtle hover:border-foreground-subtle hover:text-foreground"}`,children:r(p,{className:"h-10 w-10"})}),r(e0,{dev:s,busy:i,setBusy:l}),u("div",{className:"text-center",children:[r("div",{className:`text-sm font-semibold ${c?"text-success":"text-foreground-subtle"}`,children:f?c?"On":"Off":"Unknown"}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:f?`Changed ${Sa(d)}`:"Awaiting state…"})]})]})}function GO({deviceId:e,deviceName:t}){const n=Le(),o=St(n.trpcClient,e),s=nn(o?.state.switch),a=nn(o?.state.brightness),i=s?.on??!1,l=s?.lastChangedAt??null,c=s!==void 0,d=a!==void 0,f=o?.brightness!==void 0,[p,m]=_(!1),[h,g]=_(a?.percentage??0);Z(()=>{a?.percentage!==void 0&&g(a.percentage)},[a?.percentage]);const b=async()=>{if(!(p||!c||!o?.switch)){m(!0);try{await o.switch.setState({on:!i})}finally{m(!1)}}},x=async()=>{if(!(p||!d||!o?.brightness)){m(!0);try{await o.brightness.setBrightness({percentage:h})}finally{m(!1)}}};return u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[r("button",{type:"button",onClick:()=>{b()},disabled:p||!c||!o?.switch,title:c?i?`Turn off ${t}`:`Turn on ${t}`:"Awaiting state…","aria-pressed":i,className:`flex h-20 w-20 items-center justify-center rounded-full border-2 transition-all disabled:cursor-not-allowed disabled:opacity-50 ${i?"border-warning bg-warning/20 text-warning shadow-lg shadow-warning/30":"border-border bg-surface text-foreground-subtle hover:border-foreground-subtle hover:text-foreground"}`,children:r(rL,{className:"h-9 w-9"})}),f?u("div",{className:"flex w-full max-w-xs flex-col items-center gap-1",children:[r("input",{type:"range",min:0,max:100,step:1,value:h,disabled:p||!i||!d,onChange:v=>g(Number(v.currentTarget.value)),onPointerUp:()=>{x()},onKeyUp:v=>{v.key==="Enter"&&x()},"aria-label":"Brightness",className:"w-full accent-warning disabled:cursor-not-allowed disabled:opacity-50"}),r("div",{className:"text-[10px] text-foreground-subtle tabular-nums",children:d?`${String(h)}%`:"Brightness unavailable"})]}):null,r(e0,{dev:o,busy:p,setBusy:m}),u("div",{className:"text-center",children:[r("div",{className:`text-sm font-semibold ${i?"text-warning":"text-foreground-subtle"}`,children:c?i?"On":"Off":"Unknown"}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:c?`Changed ${Sa(l)}`:"Awaiting state…"})]})]})}function WO({deviceId:e}){const t=Le(),n=St(t.trpcClient,e),o=nn(n?.state.motion),s=o?.detected??!1,a=o?.lastDetectedAt??null,i=o!==void 0;return u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[r("div",{className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all ${s?"border-danger bg-danger/20 text-danger shadow-lg shadow-danger/30 animate-pulse":"border-border bg-surface text-foreground-subtle"}`,"aria-live":"polite",title:s?"Motion detected":"Idle",children:s?r(LL,{className:"h-10 w-10"}):r(Mo,{className:"h-10 w-10"})}),u("div",{className:"text-center",children:[r("div",{className:`text-sm font-semibold ${s?"text-danger":"text-foreground-subtle"}`,children:i?s?"Triggered":"Idle":"Unknown"}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5",children:i?`Last trip ${Sa(a)}`:"Awaiting state…"})]})]})}function YO({deviceId:e}){const t=Le(),n=St(t.trpcClient,e),o=nn(n?.state.doorbell),s=o?.lastPressedAt??null,a=o!==void 0,i=s!==null&&Date.now()-s<6e4,[l,c]=_(0),[d,f]=_(null);return Z(()=>{s===null||s===d||(f(s),KO(s)&&c(p=>p+1))},[s,d]),u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 p-4",children:[r("div",{className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all ${i?"border-primary bg-primary/20 text-primary shadow-lg shadow-primary/30 animate-pulse":"border-border bg-surface text-foreground-subtle"}`,"aria-live":"polite",title:i?"Just pressed":"Idle",children:r(Io,{className:"h-10 w-10"})}),u("div",{className:"text-center",children:[r("div",{className:`text-sm font-semibold ${i?"text-primary":"text-foreground-subtle"}`,children:a?`Last press ${Sa(s)}`:"Unknown"}),r("div",{className:"text-[10px] text-foreground-subtle mt-0.5 tabular-nums",children:a?`${String(l)} ring${l===1?"":"s"} today`:"Awaiting state…"})]})]})}function ZO({deviceName:e,deviceType:t,provider:n,isOnline:o,features:s}){return u("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border bg-surface p-6 text-center",children:[r(an,{type:n,size:"lg"}),u("div",{children:[r("div",{className:"text-sm font-semibold text-foreground",children:e}),r("div",{className:"text-[10px] text-foreground-subtle uppercase tracking-wider mt-0.5",children:t})]}),u("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[r(ka,{status:o?"online":"offline"}),s.length>0&&r(wa,{capabilities:s})]}),r("div",{className:"text-[10px] text-foreground-subtle italic max-w-xs mt-1",children:"No live view for this device type. Use the Config tab or the shortcut row to interact."})]})}function XO({deviceId:e}){const t=ke(),n=gg({deviceId:e},{refetchInterval:1e4,retry:!1}),o=bg({onSuccess:()=>{t.invalidateQueries({queryKey:[["deviceDiscovery","listDiscovered"]]}),t.invalidateQueries({queryKey:[["deviceDiscovery","getStatus"]]})}}),s=U(()=>JO(n.data??[]),[n.data]);return u("div",{className:"flex h-full w-full flex-col gap-3 p-3 sm:p-4",children:[u("div",{className:"flex flex-wrap items-stretch gap-2 sm:gap-3",children:[r(ki,{label:"Discovered",value:s.total,icon:r(on,{className:"h-3.5 w-3.5"})}),r(ki,{label:"Adopted",value:s.adopted,accent:"success"}),r(ki,{label:"Available",value:s.available,accent:s.available>0?"primary":void 0}),u("button",{type:"button",onClick:()=>{o.mutateAsync({deviceId:e}).catch(()=>{})},disabled:o.isPending,className:"inline-flex items-center justify-center gap-1.5 rounded-lg border border-border px-3 py-2 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 self-stretch shrink-0",children:[o.isPending?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):r(pt,{className:"h-3.5 w-3.5"}),r("span",{className:"hidden sm:inline",children:"Discover"})]})]}),u("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-foreground-subtle border-t border-border-subtle pt-2",children:[r(Jo,{icon:r(Fn,{className:"h-3 w-3 text-emerald-500"}),label:`${s.online} online`}),r(Jo,{icon:r(dy,{className:"h-3 w-3 text-amber-500"}),label:`${s.sleeping} sleeping`}),r(Jo,{icon:r(vy,{className:"h-3 w-3 text-destructive"}),label:`${s.offline} offline`}),s.unknown>0?r(Jo,{icon:r(ND,{className:"h-3 w-3 text-foreground-subtle"}),label:`${s.unknown} unknown`}):null]})]})}function JO(e){const t={total:e.length,adopted:0,available:0,online:0,sleeping:0,offline:0,unknown:0};for(const n of e)n.alreadyAdopted?t.adopted+=1:t.available+=1,t[n.status]+=1;return t}function ki({label:e,value:t,icon:n,accent:o}){return u("div",{className:`flex flex-1 basis-[140px] min-w-0 flex-col gap-1 rounded-lg border px-2 py-1.5 sm:px-3 sm:py-2 ${o==="success"?"bg-emerald-500/10 border-emerald-500/30 text-emerald-500":o==="primary"?"bg-primary/10 border-primary/30 text-primary":"bg-surface-hover border-border text-foreground"}`,children:[u("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider opacity-70 truncate",children:[n,r("span",{className:"truncate",children:e})]}),r("div",{className:"text-xl sm:text-2xl font-semibold tabular-nums leading-none",children:t})]})}function Jo({icon:e,label:t}){return u("span",{className:"inline-flex items-center gap-1",children:[e,r("span",{children:t})]})}const e8=e=>r(t0,{...e,useSiren:!0}),t8={[st.Switch]:t0,[st.Siren]:e8,[st.Light]:GO,[st.Sensor]:WO,[st.Button]:YO,[st.Hub]:XO};function n8(e){const t=t8[e.deviceType]??ZO;return r(t,{...e})}function ed(e){if(e<60)return`${Math.round(e)}s`;const t=Math.floor(e/60),n=Math.round(e%60);if(t<60)return n>0?`${t}m ${n}s`:`${t}m`;const o=Math.floor(t/60),s=t%60;return s>0?`${o}h ${s}m`:`${o}h`}function Ts(e){return new Date(e).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Rs(e){return e.toISOString().slice(0,10)}function r8(e,t){return Rs(e)===Rs(t)}function Qr(e){const t=new Date(e);return t.setHours(0,0,0,0),t}function o8(e){const t=new Date(e);return t.setHours(23,59,59,999),t}function At({className:e=""}){return r("div",{className:`animate-pulse rounded bg-foreground-subtle/10 ${e}`})}function _n(){return u("div",{className:"flex items-center gap-3 px-4 py-3",children:[r(At,{className:"h-4 w-4"}),r(At,{className:"h-3 w-24"}),r(At,{className:"h-3 w-16 ml-auto"})]})}function Fr({children:e,actions:t}){return u("div",{className:"border-b border-border px-4 py-2.5 flex items-center justify-between",children:[r("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:e}),t]})}function gp({icon:e,label:t,value:n}){return u("div",{className:"flex items-center gap-2",children:[r(e,{className:"h-3.5 w-3.5 text-foreground-subtle flex-shrink-0"}),u("div",{className:"min-w-0",children:[r("p",{className:"text-[10px] text-foreground-subtle leading-tight",children:t}),r("p",{className:"text-xs font-medium text-foreground leading-tight",children:n})]})]})}function s8({segments:e,selectedDate:t}){const n=Qr(t).getTime(),o=1440*60*1e3,s=Array.from({length:25},(a,i)=>i);return u("div",{className:"space-y-1",children:[r("div",{className:"flex justify-between px-0.5",children:s.filter(a=>a%3===0).map(a=>r("span",{className:"text-[9px] text-foreground-subtle font-mono",children:String(a).padStart(2,"0")},a))}),u("div",{className:"relative h-6 rounded bg-background border border-border overflow-hidden",children:[e.map(a=>{const i=new Date(a.startTime).getTime()-n,l=new Date(a.endTime).getTime()-n,c=Math.max(0,i/o*100),d=Math.min(100-c,(l-i)/o*100);return d<=0?null:r("div",{className:"absolute top-0 bottom-0 bg-primary/60 hover:bg-primary/80 transition-colors",style:{left:`${c}%`,width:`${Math.max(d,.3)}%`},title:`${Ts(a.startTime)} - ${Ts(a.endTime)} (${ed(a.duration)})`},a.id)}),s.slice(1,-1).map(a=>r("div",{className:"absolute top-0 bottom-0 w-px bg-border/50",style:{left:`${a/24*100}%`}},a))]})]})}function a8({segment:e,selected:t,onToggle:n,onPlay:o,onDownload:s,onDelete:a}){return u("div",{className:`flex items-center gap-3 px-4 py-2 border-b border-border last:border-b-0 hover:bg-background/50 transition-colors ${t?"bg-primary/5":""}`,children:[r("button",{onClick:n,className:"flex-shrink-0 text-foreground-subtle hover:text-foreground",children:t?r(gy,{className:"h-4 w-4 text-primary"}):r(Po,{className:"h-4 w-4"})}),u("div",{className:"flex-1 min-w-0",children:[u("p",{className:"text-xs font-mono text-foreground",children:[Ts(e.startTime)," - ",Ts(e.endTime)]}),u("p",{className:"text-[10px] text-foreground-subtle",children:[ed(e.duration),e.sizeBytes!=null&&` · ${kt(e.sizeBytes)}`]})]}),u("div",{className:"flex items-center gap-1 flex-shrink-0",children:[r("button",{onClick:o,title:"Play",className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:r(va,{className:"h-3.5 w-3.5"})}),r("button",{onClick:s,title:"Download",className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:r(vn,{className:"h-3.5 w-3.5"})}),r("button",{onClick:a,title:"Delete",className:"p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger transition-colors",children:r(Ge,{className:"h-3.5 w-3.5"})})]})]})}function i8({deviceId:e}){const t=ke(),[n,o]=_(()=>Qr(new Date)),[s,a]=_(new Set),i=Hb({deviceId:e},{refetchInterval:5e3}),l=Bb({deviceId:e}),c=l.data?.streams[0]?.streamId??"stream0",d=Fb({deviceId:e,streamId:c,startTime:Qr(n).getTime(),endTime:o8(n).getTime()}),f=jb({deviceId:e,streamId:c},{refetchInterval:3e4}),p=Vb({deviceId:e,dataCategory:"recording:main"}),m=q(()=>{t.invalidateQueries({queryKey:["recordingEngine","getPolicyStatus"]}),t.invalidateQueries({queryKey:["recordingEngine","getSegments"]}),t.invalidateQueries({queryKey:["recordingEngine","getStorageUsage"]})},[t]),h=Ob({onSuccess:m}),g={isPending:h.isPending,error:h.error,mutate:()=>{const D=l.data,T=D?{mode:D.mode,streams:D.streams,enabled:!0,preBufferSec:D.preBufferSec,postBufferSec:D.postBufferSec,scheduleRules:D.scheduleRules}:{mode:"continuous",streams:[{streamId:c,mode:"always"}],enabled:!0,preBufferSec:10,postBufferSec:5};h.mutate({deviceId:e,policy:T})}},b=zb({onSuccess:m}),x=i.data??void 0,v=l.data??void 0,w=d.data??[],y=f.data,N=p.data??void 0,k=(x?.enabled??!1)&&(x?.activeStreams??0)>0,S=g.isPending||b.isPending,M=r8(n,new Date),P=U(()=>[...w].sort((D,T)=>new Date(T.startTime).getTime()-new Date(D.startTime).getTime()),[w]),I=U(()=>w.reduce((D,T)=>D+(T.duration??0),0),[w]),z=U(()=>w.reduce((D,T)=>D+(T.sizeBytes??0),0),[w]);function $(){k?b.mutate({deviceId:e}):g.mutate()}function O(){o(D=>{const T=new Date(D);return T.setDate(T.getDate()-1),Qr(T)}),a(new Set)}function R(){M||(o(D=>{const T=new Date(D);return T.setDate(T.getDate()+1),Qr(T)}),a(new Set))}function A(D){a(T=>{const B=new Set(T);return B.has(D)?B.delete(D):B.add(D),B})}function L(){s.size===P.length?a(new Set):a(new Set(P.map(D=>D.id)))}return i.isLoading&&l.isLoading?u("div",{className:"space-y-4",children:[u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(Fr,{children:"Recording Status"}),u("div",{className:"px-4 py-4 space-y-3",children:[r(At,{className:"h-10 w-full"}),r(At,{className:"h-4 w-48"})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(Fr,{children:"Segments"}),u("div",{className:"divide-y divide-border",children:[r(_n,{}),r(_n,{}),r(_n,{})]})]})]}):u("div",{className:"space-y-4",children:[u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(Fr,{children:"Recording Status"}),u("div",{className:"px-4 py-4 flex items-center justify-between gap-4",children:[u("div",{className:"flex items-center gap-3 min-w-0",children:[r("div",{className:`flex items-center justify-center rounded-full p-2 flex-shrink-0 ${k?"bg-danger/10":"bg-foreground-subtle/10"}`,children:r(ty,{className:`h-5 w-5 ${k?"text-danger animate-pulse":"text-foreground-subtle"}`})}),u("div",{className:"min-w-0",children:[r("p",{className:`text-sm font-medium ${k?"text-danger":"text-foreground-subtle"}`,children:k?"Recording":"Not Recording"}),r("p",{className:"text-[11px] text-foreground-subtle mt-0.5 truncate",children:k&&x?`${x.mode} – ${x.activeStreams} stream(s)`:"No active recording session"})]})]}),r("button",{onClick:$,disabled:S,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors flex-shrink-0 disabled:opacity-50 ${k?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:k?u(xe,{children:[r(Po,{className:"h-3.5 w-3.5"}),S?"Stopping...":"Stop Recording"]}):u(xe,{children:[r(va,{className:"h-3.5 w-3.5"}),S?"Starting...":"Start Recording"]})})]}),k&&x&&u("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-[11px] text-foreground-subtle",children:[r(Yr,{className:"h-3.5 w-3.5 text-primary flex-shrink-0"}),u("span",{children:[x.activeStreams," active stream",x.activeStreams!==1?"s":""," · mode: ",x.mode]})]})]}),u("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(Fr,{children:u("span",{className:"flex items-center gap-1.5",children:[r(Nt,{className:"h-3.5 w-3.5"}),"Settings"]})}),l.isLoading?u("div",{className:"px-4 py-3 space-y-2",children:[r(At,{className:"h-3 w-32"}),r(At,{className:"h-3 w-40"}),r(At,{className:"h-3 w-28"})]}):u("div",{className:"divide-y divide-border",children:[r(jr,{label:"Stream",value:c}),r(jr,{label:"Pre-buffer",value:v?`${v.preBufferSec}s`:"N/A"}),r(jr,{label:"Mode",value:v?.mode??"continuous"}),r(jr,{label:"Retention",value:N?.retentionDays!=null?`${N.retentionDays} days`:"N/A"}),N?.retentionGb!=null&&r(jr,{label:"Max Storage",value:`${N.retentionGb} GB`})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r(Fr,{children:u("span",{className:"flex items-center gap-1.5",children:[r(lo,{className:"h-3.5 w-3.5"}),"Storage"]})}),f.isLoading?u("div",{className:"px-4 py-3 space-y-2",children:[r(At,{className:"h-3 w-28"}),r(At,{className:"h-3 w-36"}),r(At,{className:"h-3 w-24"})]}):f.error?u("div",{className:"px-4 py-4 flex items-center gap-2 text-xs text-danger",children:[r(xt,{className:"h-4 w-4"}),"Failed to load storage info"]}):u("div",{className:"px-4 py-3 grid grid-cols-2 gap-3",children:[r(gp,{icon:lo,label:"Total",value:y?.totalBytes!=null?kt(y.totalBytes):"N/A"}),r(gp,{icon:Yr,label:"Segments",value:y?.segmentCount!=null?String(y.segmentCount):"N/A"})]})]})]}),u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"border-b border-border px-4 py-2.5 flex items-center justify-between",children:[r("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:"Segment Browser"}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:O,className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",children:r(Kc,{className:"h-4 w-4"})}),u("div",{className:"flex items-center gap-1.5 text-xs text-foreground font-medium",children:[r(Xx,{className:"h-3.5 w-3.5 text-foreground-subtle"}),M?"Today":Rs(n)]}),r("button",{onClick:R,disabled:M,className:"p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:r(It,{className:"h-4 w-4"})})]})]}),u("div",{className:"px-4 py-3 border-b border-border",children:[r(s8,{segments:w,selectedDate:n}),u("div",{className:"flex items-center gap-4 mt-2 text-[10px] text-foreground-subtle",children:[u("span",{children:[w.length," segment",w.length!==1?"s":""]}),I>0&&u("span",{children:[ed(I)," recorded"]}),z>0&&r("span",{children:kt(z)})]})]}),P.length>0&&u("div",{className:"border-b border-border px-4 py-2 flex items-center justify-between",children:[r("button",{onClick:L,className:"text-[11px] text-foreground-subtle hover:text-foreground transition-colors",children:s.size===P.length?"Deselect All":"Select All"}),s.size>0&&u("div",{className:"flex items-center gap-2",children:[u("span",{className:"text-[10px] text-foreground-subtle",children:[s.size," selected"]}),u("button",{className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-medium bg-foreground-subtle/10 text-foreground-subtle hover:text-foreground transition-colors",title:"Download selected",children:[r(vn,{className:"h-3 w-3"}),"Download"]}),u("button",{className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-medium bg-danger/10 text-danger hover:bg-danger/20 transition-colors",title:"Delete selected",children:[r(Ge,{className:"h-3 w-3"}),"Delete"]})]})]}),d.isLoading?u("div",{className:"divide-y divide-border",children:[r(_n,{}),r(_n,{}),r(_n,{}),r(_n,{})]}):P.length===0?u("div",{className:"flex flex-col items-center justify-center py-12 text-foreground-subtle",children:[r(Yr,{className:"h-8 w-8 mb-3 opacity-30"}),r("p",{className:"text-sm",children:"No recorded segments"}),r("p",{className:"text-xs mt-1 opacity-70",children:M?"Recorded clips will appear here as they are created":`No recordings found for ${Rs(n)}`})]}):r("div",{className:"max-h-[400px] overflow-y-auto",children:P.map(D=>r(a8,{segment:D,selected:s.has(D.id),onToggle:()=>A(D.id),onPlay:()=>{},onDownload:()=>{},onDelete:()=>{}},D.id))})]}),i.error&&u("div",{className:"rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 flex items-center gap-2 text-xs text-danger",children:[r(xt,{className:"h-4 w-4 flex-shrink-0"}),"Failed to load recording status. Will retry automatically."]}),(g.error||b.error)&&u("div",{className:"rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 flex items-center gap-2 text-xs text-danger",children:[r(xt,{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 jr({label:e,value:t}){return u("div",{className:"flex items-center justify-between px-4 py-2.5",children:[r("span",{className:"text-xs text-foreground-subtle",children:e}),r("span",{className:"text-xs font-medium text-foreground",children:t})]})}function l8({deviceId:e}){const t=ke(),n=Number.isFinite(e),{data:o}=Bn({deviceId:e},{enabled:n}),s=typeof o?.type=="string"?o.type:"camera";yt(["deviceManager","getBindings"],["capability.binding-changed"]);const{data:a,isLoading:i,isError:l,error:c}=Cg({deviceId:e},{staleTime:3e4,enabled:n}),{data:d}=Ig({deviceType:s},{staleTime:3e4,enabled:!!s}),f=Mg({onSuccess:()=>{t.invalidateQueries({queryKey:[["deviceManager","getBindings"]]})}});if(i)return r("div",{className:"p-4",children:r("div",{className:"h-20 rounded-lg border border-border bg-surface animate-pulse"})});if(l)return u("div",{className:"p-4 text-xs text-red-400",children:["Failed to load bindings: ",c instanceof Error?c.message:String(c)]});const p=new Map,m={};for(const b of d??[])m[b.capName]=b.wrappers;for(const b of a?.entries??[])p.set(b.capName,{...b,wrappers:m[b.capName]??[]});for(const b of d??[])p.has(b.capName)||p.set(b.capName,{capName:b.capName,kind:"unbound",providerAddonId:"",providerNodeId:"",nativeAddonId:"",wrappers:b.wrappers});const h=[...p.values()].sort((b,x)=>b.capName.localeCompare(x.capName));if(h.length===0)return u("div",{className:"flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle",children:[r(ba,{className:"h-8 w-8 opacity-40"}),r("p",{className:"text-xs",children:"No capability providers applicable to this device yet."}),r("p",{className:"text-[10px] opacity-60",children:"Native providers show up here as soon as the owning addon registers them."})]});const g=h.filter(b=>b.kind!=="unbound").length;return u("div",{className:"flex flex-col gap-3 p-1",children:[u("div",{className:"text-[11px] text-foreground-subtle",children:[r("span",{className:"font-medium text-foreground",children:g})," ","of ",h.length," capabilit",h.length===1?"y":"ies"," bound — rows marked ",r("em",{children:"unbound"})," have a wrapper available you can activate."]}),r("div",{className:"overflow-hidden rounded-lg border border-border bg-surface",children:u("table",{className:"w-full border-collapse text-[11px]",children:[r("thead",{children:u("tr",{className:"bg-surface-hover/50 text-left text-[10px] uppercase tracking-wide text-foreground-subtle",children:[r("th",{className:"px-3 py-2 font-medium",children:"Capability"}),r("th",{className:"px-3 py-2 font-medium",children:"Kind"}),r("th",{className:"px-3 py-2 font-medium",children:"Active Provider"}),r("th",{className:"px-3 py-2 font-medium",children:"Node"}),r("th",{className:"px-3 py-2 font-medium",children:"Native"}),r("th",{className:"px-3 py-2 font-medium",children:"Wrapper"})]})}),r("tbody",{children:h.map(b=>{const x=b.kind==="wrapped"?b.providerAddonId:null;return u("tr",{className:"border-t border-border align-middle",children:[r("td",{className:"px-3 py-2 font-mono text-foreground",children:b.capName}),r("td",{className:"px-3 py-2",children:r(c8,{kind:b.kind})}),r("td",{className:"px-3 py-2 font-mono text-foreground-subtle",children:b.providerAddonId||r("span",{className:"opacity-40",children:"—"})}),r("td",{className:"px-3 py-2",children:b.providerNodeId?r(d8,{nodeId:b.providerNodeId}):r("span",{className:"text-[10px] opacity-40",children:"—"})}),r("td",{className:"px-3 py-2 font-mono text-foreground-subtle",children:b.nativeAddonId||r("span",{className:"opacity-40",children:"—"})}),r("td",{className:"px-3 py-2",children:r(u8,{wrappers:b.wrappers,activeWrapperId:x,disabled:f.isPending,onPick:v=>{const w=x===v;f.mutate({deviceId:e,capName:b.capName,wrapperAddonId:v,active:!w})}})})]},b.capName)})})]})})]})}function c8({kind:e}){return e==="native"?u("span",{className:"inline-flex items-center gap-1 rounded-md border border-success/30 text-success bg-success/5 px-1.5 py-0.5 text-[10px] font-medium",children:[r(sn,{className:"h-3 w-3"}),"native"]}):e==="wrapped"?u("span",{className:"inline-flex items-center gap-1 rounded-md border border-primary/30 text-primary bg-primary/5 px-1.5 py-0.5 text-[10px] font-medium",children:[r(eL,{className:"h-3 w-3"}),"wrapped"]}):u("span",{className:"inline-flex items-center gap-1 rounded-md border border-border text-foreground-subtle/70 px-1.5 py-0.5 text-[10px] font-medium",children:[r(gL,{className:"h-3 w-3"}),"unbound"]})}function d8({nodeId:e}){return r("span",{className:`inline-flex items-center rounded-md border border-border px-1.5 py-0.5 font-mono text-[10px] ${e==="hub"?"text-foreground-subtle":"text-foreground"}`,children:e})}function u8({wrappers:e,activeWrapperId:t,disabled:n,onPick:o}){return e.length===0?r("span",{className:"text-[10px] opacity-40",children:"none available"}):r("div",{className:"flex flex-wrap gap-1",children:e.map(s=>{const a=s===t;return u("button",{disabled:n,onClick:()=>o(s),title:a?"Click to deactivate (revert to native)":`Activate wrapper ${s}`,className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[10px] transition-colors disabled:opacity-50 ${a?"border-primary/40 bg-primary/10 text-primary":"border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,children:[a?r(Mt,{className:"h-3 w-3"}):r(my,{className:"h-3 w-3"}),s]},s)})})}function p8(e,t){if(!e)return null;for(const n of e.slots)for(const o of n.addons)if(o.id===t)return o;return null}function f8(e,t,n){const o=e?.stepOverridesByAgent?.[t]?.[n];if(o)return o.enabled===!1?"off":(o.enabled===!0,"on");const s=e?.stepToggles?.[n];return s===!1?"off":s===!0?"on":"inherit"}function m8({agents:e,currentAgent:t,onPick:n}){const[o,s]=_(!1);return u("div",{className:"relative",children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:()=>s(a=>!a),children:"Mirror from ▾"}),o&&r("div",{className:"absolute top-full left-0 mt-1 min-w-[140px] bg-surface border border-border rounded shadow-lg z-10",children:e.filter(a=>a!==t).map(a=>r("button",{type:"button",className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted",onClick:()=>{s(!1),n(a)},children:a},a))})]})}function h8({deviceId:e,refreshToken:t}){const n=ke(),[o,s]=_(null),[a,i]=_(null),[l,c]=_(null),[d,f]=_(null),p=wc({deviceId:e}),m=Er(),h=la({deviceId:e}),g=mb(),b=U(()=>{const L=h.data?.agentNodeId;if(L)return L;const D=g.data?.find(T=>T.online)?.nodeId;return D||"hub"},[h.data?.agentNodeId,g.data]),x=a??b,v=ko({nodeId:x??""},{enabled:!!x}),w=Mb({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCameraSettings"]]}),c(null)}}),y=U(()=>v.data?ea(v.data):[],[v.data]),N=U(()=>{const L=p.data??null,D={};for(const T of m.data??[])for(const B of Object.keys(T.settings.addonDefaults)){const F=D[B]??[];F.push({agentNodeId:T.nodeId,state:f8(L,T.nodeId,B)}),D[B]=F}return D},[p.data,m.data]),k=o?p8(v.data??null,o):null,S=x?m.data?.find(L=>L.nodeId===x)??null:null,M=o&&S?S.settings.addonDefaults[o]??null:null,P=o&&x?p.data?.stepOverridesByAgent?.[x]?.[o]??null:null,I=v.data?.selectedEngine.format??"coreml",z=L=>{i(L),c(null),f(null)},$=L=>{s(L),c(null),f(null)},O=L=>{if(!x||!o||!v.data||!m.data)return;const D=m.data.find(F=>F.nodeId===L),T=m.data.find(F=>F.nodeId===x);if(!D||!T)return;const[B]=gm({source:{nodeId:D.nodeId,engine:{format:I},defaults:D.settings.addonDefaults},target:{nodeId:T.nodeId,engine:{format:I},defaults:T.settings.addonDefaults},catalog:v.data,addonIds:[o]});if(!B){f("no mirror result");return}if(B.outcome==="skip"){f(`skipped: ${B.reason??"no candidate"}`);return}c(B.patch),f(`${B.outcome} from ${L}`)},R=()=>{!x||!o||w.mutate({deviceId:e,agentNodeId:x,addonId:o,patch:l})},A=()=>{!x||!o||w.mutate({deviceId:e,agentNodeId:x,addonId:o,patch:null})};return m.isLoading||v.isLoading?r("div",{className:"text-xs text-foreground-subtle animate-pulse p-4",children:"Loading pipeline…"}):v.data?r("div",{className:"@container h-full",style:{containerType:"inline-size"},children:u("div",{className:"flex flex-col @[720px]:flex-row h-full",children:[r("aside",{className:"w-full @[720px]:w-[300px] @[720px]:flex-shrink-0 border-b @[720px]:border-b-0 @[720px]:border-r border-border overflow-y-auto max-h-[40vh] @[720px]:max-h-none",children:r(ph,{tree:y,selectedAddonId:o,onSelect:$,agentDots:N})}),r("section",{className:"flex-1 min-w-0 p-4 overflow-y-auto",children:!o||!k?r("div",{className:"text-sm text-foreground-subtle",children:"Select a step on the left to configure it for this camera."}):u("div",{className:"space-y-4",children:[u("div",{children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Selected step"}),r("div",{className:"text-base font-semibold",children:k.name})]}),u("div",{className:"flex items-end gap-3 flex-wrap",children:[u("div",{children:[r("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle mb-1",children:"Agent"}),r("div",{className:"flex rounded border border-border overflow-hidden",children:(m.data??[]).map(L=>r("button",{type:"button",onClick:()=>z(L.nodeId),className:`px-3 py-1 text-xs ${x===L.nodeId?"bg-primary text-primary-foreground":"bg-surface hover:bg-muted"}`,children:L.nodeId},L.nodeId))})]}),r(m8,{agents:(m.data??[]).map(L=>L.nodeId),currentAgent:x,onPick:O}),d&&r("div",{className:"text-[10px] text-foreground-subtle",children:d})]}),M&&r(na,{mode:"device",addon:k,agentDefault:M,agentNodeId:x??"",currentPatch:l??P,engineFormat:I,onChangePatch:c}),u("div",{className:"flex items-center justify-between gap-2 pt-4 border-t border-border",children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted text-foreground-subtle",disabled:!P||w.isPending,onClick:A,children:"Clear override"}),u("div",{className:"flex items-center gap-2",children:[r("button",{type:"button",className:"px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted",onClick:()=>c(null),children:"Reset draft"}),r("button",{type:"button",className:"px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50",disabled:!x||!o||w.isPending,onClick:R,children:w.isPending?"Saving…":"Save"})]})]})]})})]})}):r("div",{className:"text-xs text-foreground-subtle p-4",children:"Catalog unavailable."})}const g8=[{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 b8(e){const t=e===st.Camera;return g8.filter(n=>t||!n.cameraOnly).map(({id:n,label:o})=>({id:n,label:o}))}const x8=[{id:"logs",icon:Ze,label:"Logs"},{id:"repl",icon:by,label:"REPL"},{id:"events",icon:Io,label:"Events"},{id:"state",icon:ny,label:"State"},{id:"ptz",icon:wL,label:"PTZ",featureGate:Tn.PanTiltZoom}];function y8(){const e=Bc(),t=Number(e.deviceId),n=Number.isFinite(t),o=Je(),s=ke(),a=nt(),i=Le(),[l,c]=_("overview"),[d,f]=_("logs"),p="device-detail.left-col-width-px",[m,h]=_(()=>{if(typeof window>"u")return null;const de=window.localStorage.getItem(p),le=de?Number(de):NaN;return Number.isFinite(le)&&le>0?le:null}),g=ne(m);g.current=m;function b(de){de.preventDefault();const le=de.clientX,Se=de.currentTarget.previousElementSibling?.getBoundingClientRect().width??m??0,pe=280,Ie=Math.max(pe+50,Math.floor(window.innerWidth*.7)),Te=rt=>{const nr=Math.max(pe,Math.min(Ie,Se+(rt.clientX-le)));h(nr)},We=()=>{document.removeEventListener("mousemove",Te),document.removeEventListener("mouseup",We);const rt=g.current;if(rt!==null)try{window.localStorage.setItem(p,String(Math.round(rt)))}catch{}document.body.style.userSelect="",document.body.style.cursor=""};document.body.style.userSelect="none",document.body.style.cursor="col-resize",document.addEventListener("mousemove",Te),document.addEventListener("mouseup",We)}const{data:x,isLoading:v,isError:w}=Bn({deviceId:t},{enabled:n,refetchInterval:5e3,retry:1}),{data:y}=hc({deviceId:t},{enabled:n,staleTime:3e4}),N=U(()=>{const de=y?.settings?.sections??[],le=y?.live?.sections??[],Se=[...de,...le],pe=new Set;for(const Ie of Se)Ie.location==="top-tab"&&Ie.tab&&pe.add(Ie.tab);return[...pe].map(Ie=>{const Te=Di[Ie];return{id:Ie,label:Te?.label??Ie,isAddonContrib:!0}})},[y]),k=x,S=String(k?.name??e.deviceId??"Device"),M=k?.online===!0,P=M?"online":"offline",I=String(k?.addonId??"rtsp"),z=k?.features??[],$=k?.type,O=$===st.Camera,R=typeof k?.parentDeviceId=="number"?k.parentDeviceId:null,{data:A}=Bn({deviceId:R??0},{enabled:R!==null,staleTime:3e4}),L=Zn(),D=U(()=>[...b8($),...N],[$,N]),{data:T}=Fy(n?t:0),B=(T??[]).length>0,F=U(()=>x8.filter(({featureGate:de})=>!de||z.includes(de)),[z]),{data:j}=Dg({addonId:I},{enabled:!!I&&I!=="rtsp"}),H=Sg({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]}),o(j?.id?`/integrations/${j.id}`:"/integrations")}}),E=Ng({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),Q=kg({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),K=Rb(),Y=oa({onSuccess:()=>{s.invalidateQueries({queryKey:[["deviceManager"]]})}}),re=z.includes(Tn.Rebootable),te=z.includes(Tn.BatteryOperated),X=nc(i.trpcClient,te&&n?t:null),[oe,ge]=_(!1),J=St(i.trpcClient,n?t:null),G=async()=>{if(!(oe||!J)){ge(!0);try{await J.snapshot?.invalidateCache({});const de=await J.snapshot?.getSnapshot({});if(!de)return;const le=`data:${de.contentType};base64,${de.base64}`,Se=de.contentType.includes("png")?"png":"jpg",pe=S.replace(/[^a-zA-Z0-9_.-]+/g,"_"),Ie=new Date().toISOString().replace(/[:.]/g,"-"),Te=document.createElement("a");Te.href=le,Te.download=`${pe}-${Ie}.${Se}`,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te)}finally{ge(!1)}}},ee=E.isPending||Q.isPending,{data:ae}=la({deviceId:t},{enabled:n,refetchInterval:1e4}),fe=ae?.agentNodeId??null,V=typeof fe=="string"&&fe.length>0&&!fe.startsWith("addon:")?fe:void 0,{data:ie}=Nc({deviceId:t,...V?{nodeId:V}:{}},{enabled:n,refetchInterval:3e3,retry:!1});function ue(){if(!n)return null;switch(l){case"overview":return r(zO,{device:k??{}});case"config":return r(UO,{deviceId:t});case"pipeline":return r(h8,{deviceId:t,refreshToken:0});case"bindings":return r(l8,{deviceId:t});case"recording":return r(i8,{deviceId:t});default:{const de=l;return N.some(Se=>Se.id===de)?r(Xy,{deviceId:t,sectionFilter:Se=>Se.location==="top-tab"&&Se.tab===de}):null}}}return n?v?u("div",{className:"flex flex-col h-full",children:[u("div",{className:"border-b border-border bg-surface px-6 py-4",children:[r("div",{className:"h-4 w-48 rounded bg-surface-hover animate-pulse mb-3"}),r("div",{className:"h-8 w-64 rounded bg-surface-hover animate-pulse"})]}),r("div",{className:"flex-1 p-6",children:r("div",{className:"h-40 rounded-lg border border-border bg-surface animate-pulse"})})]}):w||!x?u("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle",children:[r("p",{className:"text-lg font-semibold text-foreground",children:"Device not found"}),u("p",{className:"text-xs",children:["No device with ID ",u("code",{className:"font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]",children:["#",t]})]}),r("button",{onClick:()=>o("/integrations"),className:"mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors",children:"Back to Integrations"})]}):u("div",{className:"absolute inset-0 flex flex-col overflow-hidden",children:[u("div",{className:"border-b border-border bg-surface px-6 py-3 flex-shrink-0",children:[r("div",{className:"mb-2",children:r(Yl,{items:[{label:"Integrations",onClick:()=>o("/integrations")},{label:j?.name??I,onClick:()=>j?.id&&o(`/integrations/${j.id}`)},{label:S}]})}),u("div",{className:"flex items-center gap-2 sm:gap-3",children:[r(an,{type:I,size:"lg"}),u("div",{className:"min-w-0 flex-1",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("h1",{className:"text-sm sm:text-base font-semibold text-foreground truncate",children:S}),r(ka,{status:P}),te&&r(oc,{status:X,variant:"full"})]}),R!==null&&A&&u("button",{type:"button",onClick:()=>o(`/devices/${R}`),className:"text-[10px] text-foreground-subtle hover:text-primary transition-colors mt-0.5 inline-flex items-center gap-1",title:`Open parent device ${A.name}`,children:[r("span",{children:"↑"}),r("span",{className:"truncate",children:String(A.name??`Device #${R}`)})]}),r("div",{className:"hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle",children:z.length>0&&r(wa,{capabilities:z})})]}),ie&&r("div",{className:"hidden lg:flex",children:r(v8,{metrics:ie})}),u("div",{className:"flex items-center gap-1 shrink-0",children:[u("button",{onClick:async()=>{await a({title:`Disable "${S}"?`,message:"The device will stop processing streams and events. You can re-enable it later.",confirmLabel:"Disable",variant:"danger"})&&Q.mutate({deviceId:t})},disabled:ee,title:"Disable device",className:"inline-flex items-center gap-1.5 rounded-lg px-2 sm:px-2.5 py-1.5 text-[11px] font-medium border transition-colors disabled:opacity-50 border-success/30 text-success hover:bg-success/10",children:[r(fy,{className:"h-3.5 w-3.5"}),r("span",{className:"hidden sm:inline",children:ee?"Updating…":"Enabled"})]}),r("div",{className:"hidden sm:block h-5 w-px bg-border mx-1"}),r(Ix,{triggerClassName:"ml-1",items:[{id:"snapshot",label:"Take snapshot",description:"Fetch a fresh frame and download it.",icon:hr,disabled:oe,onClick:()=>{G()}},{id:"reboot",label:"Reboot device",description:"Camera goes offline for ~30 seconds.",icon:bt,hidden:!re,disabled:K.isPending,danger:!0,onClick:async()=>{await a({title:`Reboot "${S}"?`,message:"The camera will go offline for around 30 seconds while the firmware reboots.",confirmLabel:"Reboot",variant:"danger"})&&K.mutate({deviceId:t})}},{id:"restart-addon",label:"Restart addon",description:`Bounces every device served by ${j?.name??I}.`,icon:pt,disabled:Y.isPending,danger:!0,onClick:async()=>{await a({title:`Restart "${j?.name??I}"?`,message:`Restarting the addon will briefly disconnect every device served by it (not just "${S}"). Streams will reconnect automatically.`,confirmLabel:"Restart",variant:"danger"})&&Y.mutate({addonId:I})}},{id:"delete",label:"Delete device",description:"Remove the device and all its settings.",icon:Ge,separatorBefore:!0,disabled:H.isPending,danger:!0,onClick:async()=>{await a({title:`Delete "${S}"?`,message:"This will remove the device and all its settings. This action cannot be undone.",confirmLabel:"Delete",variant:"danger"})&&H.mutate({deviceId:t})}}]})]})]})]}),r(jh,{deviceId:t,device:k??void 0,children:r(vx,{children:r(Px,{children:u("main",{className:L?"flex-1 overflow-y-auto flex flex-col":"flex-1 min-h-0 overflow-hidden flex flex-row",children:[u("div",{className:L?"flex flex-col bg-surface":`${m===null?"w-1/2 lg:w-1/3":""} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-hidden`,style:!L&&m!==null?{width:`${String(m)}px`}:void 0,children:[r("div",{className:`flex-shrink-0 border-b border-border-subtle ${O?"aspect-video bg-black":"bg-surface"}`,children:O?r($O,{deviceId:t,intercomAvailable:z.includes(Tn.TwoWayAudio)}):r(n8,{deviceId:t,deviceName:S,deviceType:$??"unknown",provider:I,isOnline:M,features:z})}),u("div",{className:L?"flex flex-col border-b border-border":"flex-1 min-h-0 flex flex-col overflow-hidden",children:[r("div",{className:"flex-shrink-0 border-b border-border-subtle px-2 py-1.5",children:r("div",{className:"flex gap-1 overflow-x-auto -mx-1 px-1 pb-0.5",children:F.map(({id:de,label:le,icon:Se})=>u("button",{onClick:()=>f(de),title:le,className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors flex-shrink-0 ${d===de?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,children:[r(Se,{className:"h-3 w-3"}),le]},de))})}),u("div",{className:L?"h-72 overflow-hidden":"flex-1 min-h-0 overflow-hidden",children:[d==="logs"&&r(_O,{deviceId:t}),d==="repl"&&r(DO,{deviceId:t}),d==="events"&&r(TO,{deviceId:t}),d==="state"&&r(RO,{deviceId:t}),d==="ptz"&&r(LO,{deviceId:t})]})]})]}),!L&&r("div",{role:"separator","aria-orientation":"vertical",title:"Drag to resize",onMouseDown:b,className:"flex-shrink-0 w-1 cursor-col-resize bg-border hover:bg-primary/40 transition-colors group relative z-10",children:r("span",{className:"absolute inset-y-0 -left-1 -right-1"})}),u("div",{className:L?"flex flex-col":"flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden",children:[r("div",{className:"flex-shrink-0 border-b border-border bg-surface px-4",children:r("div",{className:"flex flex-wrap items-center gap-0",children:D.map(de=>{const le=l===de.id;return u("button",{onClick:()=>c(de.id),className:`relative flex-shrink-0 px-3 py-2 text-xs font-medium transition-colors ${le?"text-primary":"text-foreground-subtle hover:text-foreground"}`,children:[de.label,le&&r("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 rounded-full bg-primary"})]},de.id)})})}),u("div",{className:L?"p-3 flex flex-col gap-3":"flex-1 min-h-0 overflow-y-auto p-4 flex flex-col gap-3",children:[l==="overview"&&B&&r(OO,{parentDeviceId:t}),ue()]})]})]})})})})]}):u("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle",children:[r("p",{className:"text-lg font-semibold text-foreground",children:"Invalid device id"}),u("p",{className:"text-xs",children:["The URL segment ",r("code",{className:"font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]",children:e.deviceId})," is not a number."]}),r("button",{onClick:()=>o("/integrations"),className:"mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors",children:"Back to Integrations"})]})}function v8({metrics:e}){const t=e.phase??"idle",n=Gn(t);return u("div",{className:"flex items-center gap-3 flex-shrink-0",children:[u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:`h-1.5 w-1.5 rounded-full ${n.dotClass}`}),r("span",{className:`text-[10px] font-medium ${n.textColor}`,children:n.label})]}),r("div",{className:"h-3 w-px bg-border"}),u("div",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle",children:[r(Mo,{className:"h-3 w-3"}),r("span",{className:"text-foreground tabular-nums",children:(e.actualFps??0).toFixed(1)}),r("span",{children:"fps"})]}),u("div",{className:"flex items-center gap-1 text-[10px] text-foreground-subtle",children:[r(dt,{className:"h-3 w-3"}),r("span",{className:"text-foreground tabular-nums",children:(e.avgInferenceTimeMs??0).toFixed(0)}),r("span",{children:"ms"})]}),(e.queueDepth??0)>0&&u("span",{className:"text-[10px] text-warning tabular-nums",children:["q:",e.queueDepth]})]})}function w8({packageName:e,currentVersion:t,onInstall:n,onClose:o}){const{data:s,isLoading:a}=Kh({name:e},{staleTime:3e5});return u("div",{className:"fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden",style:{top:"auto",bottom:"auto"},ref:i=>{if(!i)return;const l=i.parentElement?.getBoundingClientRect();if(!l)return;const c=window.innerHeight-l.bottom,d=l.top;c<280&&d>c?(i.style.bottom=`${window.innerHeight-l.top+4}px`,i.style.top="auto"):(i.style.top=`${l.bottom+4}px`,i.style.bottom="auto"),i.style.right=`${window.innerWidth-l.right}px`},onClick:i=>i.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Versions"}),r("button",{type:"button",onClick:o,className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-3 w-3"})})]}),a&&u("div",{className:"flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle",children:[r(Pe,{className:"h-3.5 w-3.5 animate-spin"}),"Loading versions..."]}),s&&r("div",{className:"max-h-64 overflow-auto divide-y divide-border",children:s.map(i=>{const l=i.version===t,c=/-(alpha|beta|rc|dev|canary|next)/i.test(i.version);return u("div",{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${l?"bg-primary/5":"hover:bg-surface-hover"} transition-colors`,children:[r("span",{className:`font-mono flex-1 ${l?"text-primary font-semibold":c?"text-amber-400":"text-foreground"}`,children:i.version}),i.distTags.map(d=>r("span",{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${d==="latest"?"bg-emerald-500/15 text-emerald-400":d==="beta"?"bg-amber-500/15 text-amber-400":"bg-gray-500/15 text-gray-400"}`,children:d},d)),i.deprecated&&r("span",{className:"text-[9px] text-red-400 line-through",children:"deprecated"}),r("span",{className:"text-[9px] text-foreground-subtle shrink-0",children:new Date(i.publishedAt).toLocaleDateString()}),l?r(Mt,{className:"h-3 w-3 text-primary shrink-0"}):r("button",{type:"button",onClick:()=>n(i.version),className:"shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors",title:`Install ${i.version}`,children:r(vn,{className:"h-3 w-3"})})]},i.version)})}),s&&s.length===0&&r("div",{className:"py-4 text-center text-[10px] text-foreground-subtle",children:"No versions found"})]})}function N8({isBundle:e,installSource:t}){return u("div",{className:"relative flex-shrink-0",children:[r("div",{className:`h-9 w-9 rounded-lg flex items-center justify-center ${e?"bg-indigo-500/20 text-indigo-700 dark:text-indigo-300":"bg-purple-500/20 text-purple-700 dark:text-purple-300"}`,children:e?r(uy,{className:"h-4 w-4"}):r(Es,{className:"h-4 w-4"})}),t==="local"&&r("span",{className:"absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm",children:"DEV"}),t==="npm"&&r("span",{className:"absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm",children:r("svg",{viewBox:"0 0 780 250",className:"w-[11px] h-[11px]",children:r("path",{fill:"#fff",d:"M240 250h100V50h100v200h340V0H0v250z"})})}),t==="upload"&&r("span",{className:"absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm",children:r(Xc,{className:"h-2.5 w-2.5 text-white"})})]})}function k8({addonId:e}){const t=ke(),{data:n="inherit"}=Yh({addonId:e},{staleTime:3e4}),o=Zh({onSuccess:()=>{t.invalidateQueries({queryKey:[["addons","getAddonAutoUpdate"]]})}});return r("div",{className:"flex rounded-lg border border-border overflow-hidden text-[10px] font-medium",children:["inherit","off","latest","beta"].map(s=>r("button",{type:"button",onClick:a=>{a.stopPropagation(),o.mutate({addonId:e,channel:s})},disabled:o.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===s?s==="inherit"?"bg-gray-700/50 text-gray-700 dark:text-gray-300":s==="off"?"bg-gray-700 text-gray-700 dark:text-gray-300":s==="latest"?"bg-blue-500/20 text-blue-400":"bg-amber-500/20 text-amber-400":"bg-transparent text-foreground-subtle hover:bg-surface-hover"} ${s!=="inherit"?"border-l border-border":""}`,children:s},s))})}function fl({addon:e,agents:t=[],clusterStatus:n,hideVersion:o,availableUpdate:s,onUpdate:a,isUpdating:i,bundle:l}){const[c,d]=_(!1),[f,p]=_(!1),[m,h]=_(!1),[g,b]=_(!1),[x,v]=_(!1),[w,y]=_("logs"),N=ke(),k=nt(),{manifest:S}=e,M=e.installedOn??[],P=!l&&!S.protected&&S.removable!==!1,I=!!l,z=l?.displayName??S.name,$=l?.packageName??S.packageName,O=l?.version??S.packageVersion??S.version,R=l?.installSource??e.installSource,A=l?l.bundle?.description??l.addons[0]?.manifest.description:S.description;!l&&(S.components&&S.components.length>0||t.length>=2);const L=Hh({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]})}}),D=oa({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]})}}),T=cc({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["addonPages"]]}),N.invalidateQueries({queryKey:[["capabilities"]]}),N.invalidateQueries({queryKey:[["integrations"]]})}}),B=Gh({onSuccess:()=>{N.invalidateQueries({queryKey:[["addons"]]}),N.invalidateQueries({queryKey:[["alerts"]]})}}),F=e.health,j=F?.phase==="failed"&&!F.inGracePeriod,H=j&&F?.nextRetryAt&&!F.retrying;return u("div",{className:`rounded-lg border bg-surface overflow-hidden ${j?"border-red-500/50":"border-border"}`,children:[j&&F&&u("div",{className:"bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5",children:[r(SL,{className:"h-4 w-4 text-danger shrink-0 mt-0.5"}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"text-xs font-semibold text-danger",children:["Failed to load (attempt #",F.retryCount,")"]}),r("div",{className:"text-[11px] text-foreground mt-0.5 break-words font-mono",children:F.lastError?.message??"Unknown error"}),H&&F.nextRetryAt&&u("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["Auto-retry at ",new Date(F.nextRetryAt).toLocaleTimeString()]})]}),u("button",{type:"button",disabled:B.isPending||F.retrying,onClick:E=>{E.stopPropagation(),B.mutate({packageName:$})},className:"inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0",title:"Reset retry counter and force immediate reload",children:[r(pt,{className:`h-3 w-3 ${B.isPending||F.retrying?"animate-spin":""}`}),"Retry now"]})]}),u("div",{className:"flex items-start gap-3 px-4 py-3",children:[r(N8,{isBundle:I||!!S.components&&S.components.length>1,installSource:R}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-sm font-semibold text-foreground truncate",children:z}),u("span",{className:"text-[10px] text-foreground-subtle font-mono shrink-0",children:["(",$,")"]}),I&&u("span",{className:"text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1",children:[r(uy,{className:"h-3 w-3"}),l.addons.length]})]}),A&&r("p",{className:"text-[10px] text-foreground-subtle mt-0.5 line-clamp-1",children:A}),!I&&e.process&&u("div",{className:"flex items-center gap-1.5 mt-1",children:[r("span",{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode==="forked"?"bg-blue-500/15 text-blue-400":"bg-gray-500/15 text-gray-400"}`,children:e.process.mode==="forked"?"forked":"in-process"}),e.process.pid!=null&&u("span",{className:"text-[9px] font-mono text-foreground-subtle",children:["PID ",e.process.pid]}),r("span",{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state==="running"?"bg-emerald-500/15 text-emerald-400":e.process.state==="crashed"?"bg-red-500/15 text-red-400":"bg-gray-500/15 text-gray-400"}`,children:e.process.state})]})]}),!o&&u("div",{className:"relative inline-flex items-center gap-1.5 shrink-0 pt-0.5",children:[i?u("span",{className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400",children:[r(Pe,{className:"h-3 w-3 animate-spin"}),"Updating to ",s,"…"]}):s&&a?u("button",{type:"button",onClick:E=>{E.stopPropagation(),a()},className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-semibold border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors animate-pulse",title:`Update to ${s}`,children:[r(vn,{className:"h-3 w-3"}),s]}):null,u("button",{type:"button",onClick:E=>{E.stopPropagation(),h(Q=>!Q)},className:["inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-bold font-mono border transition-colors",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 ${O} — newer ${s} available`:"View all versions",children:[O,r(wt,{className:"h-3 w-3 opacity-50"})]}),m&&r(w8,{packageName:$,currentVersion:O,onInstall:E=>{h(!1),T.mutate({packageName:$,version:E})},onClose:()=>h(!1)})]})]}),!I&&u("div",{className:"flex items-center gap-1 px-4 py-1.5 border-t border-border/50 bg-surface-hover/20",children:[u("button",{type:"button",onClick:E=>{E.stopPropagation(),D.mutate({addonId:S.id})},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-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors",children:[r(pt,{className:`h-3 w-3 ${D.isPending?"animate-spin":""}`}),"Restart"]}),u("button",{type:"button",onClick:E=>{E.stopPropagation(),b(Q=>!Q)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${g?"border-primary/30 bg-primary/10 text-primary":"border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10"}`,children:[r(Ze,{className:"h-3 w-3"}),"Logs"]}),!I&&u("button",{type:"button",onClick:E=>{E.stopPropagation(),v(!0)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${x?"border-primary/30 bg-primary/10 text-primary":"border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10"}`,children:[r(Nt,{className:"h-3 w-3"}),"Settings"]}),r("div",{className:"flex-1"}),P&&u("button",{type:"button",onClick:async E=>{E.stopPropagation(),await k({title:`Uninstall ${S.name}?`,message:"This will remove the addon package and all its data. This action cannot be undone.",confirmLabel:"Uninstall",variant:"danger"})&&L.mutate({packageName:S.packageName})},disabled:L.isPending,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors",children:[r(Ge,{className:"h-3 w-3"}),L.isPending?"Removing...":"Uninstall"]})]}),n&&n.nodes.length>1&&!I&&u("div",{className:"border-t border-border px-4 py-2 bg-muted/10",children:[r("div",{className:"text-[10px] font-medium text-foreground-subtle mb-1.5",children:"Cluster Deployment"}),r("div",{className:"space-y-1",children:n.nodes.map(E=>u("div",{className:"flex items-center gap-2 text-[10px]",children:[r("div",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${E.status==="offline"?"bg-muted-foreground/30":E.synced?"bg-success":"bg-amber-500"}`}),r("span",{className:"font-medium text-foreground min-w-[60px]",children:E.name}),r("span",{className:"font-mono text-foreground-subtle",children:E.version}),!E.synced&&E.status!=="offline"&&r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"outdated"}),E.status==="offline"&&r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground",children:"offline"}),E.synced&&E.status!=="offline"&&r("span",{className:"text-[9px] text-success",children:"synced"})]},E.nodeId))})]}),g&&!I&&u("div",{className:"border-t border-border",children:[u("div",{className:"flex items-center px-4 py-1 bg-surface-hover/20 border-b border-border/50",children:[u("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:[r("button",{type:"button",onClick:()=>y("logs"),className:`px-2 py-0.5 transition-colors ${w==="logs"?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover"}`,children:"Logs"}),r("button",{type:"button",onClick:()=>y("events"),className:`px-2 py-0.5 border-l border-border transition-colors ${w==="events"?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover"}`,children:"Events"})]}),r("div",{className:"flex-1"}),r("button",{type:"button",onClick:E=>{E.stopPropagation(),b(!1)},className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-3.5 w-3.5"})})]}),w==="logs"&&r(Ut,{addonId:S.id,maxHeight:"max-h-64",showFilters:!1}),w==="events"&&r(tr,{addonId:S.id,category:"addon.*",maxHeight:"max-h-64"})]}),I&&u(xe,{children:[r("button",{type:"button",onClick:()=>d(E=>!E),className:"w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors",children:c?r(bD,{className:"h-3.5 w-3.5 text-foreground-subtle"}):r(wt,{className:"h-3.5 w-3.5 text-foreground-subtle"})}),c&&r("div",{className:"border-t border-border px-3 py-2 space-y-2",children:l.addons.map(E=>r(fl,{addon:E,agents:t,hideVersion:!0},E.manifest.id))})]}),x&&!I&&r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:()=>v(!1),children:u("div",{className:"w-full max-w-lg max-h-[80vh] rounded-xl border border-border bg-surface shadow-2xl flex flex-col overflow-hidden",onClick:E=>E.stopPropagation(),children:[u("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border flex-shrink-0",children:[u("div",{className:"flex items-center gap-2",children:[r(Nt,{className:"h-4 w-4 text-primary"}),u("h2",{className:"text-sm font-semibold text-foreground",children:[z," Settings"]})]}),r("button",{onClick:()=>v(!1),className:"text-foreground-subtle hover:text-foreground transition-colors p-1 rounded",children:r(Ve,{className:"h-4 w-4"})})]}),u("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[r(Tr,{nodeId:"hub",addonIds:[S.id],level:"global"}),R==="npm"&&u("div",{children:[r("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Auto-Update"}),r(k8,{addonId:S.id})]}),S.components&&S.components.length>0&&u("div",{children:[u("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Components (",S.components.length,")"]}),r("div",{className:"flex flex-wrap gap-1",children:S.components.map(E=>r("span",{className:"text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono",children:E},E))})]}),t.length>=2&&u("div",{children:[r("div",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:"Installed on"}),u("div",{className:"flex items-center gap-1.5 flex-wrap",children:[M.length===0&&r("span",{className:"text-[10px] text-foreground-subtle",children:"Hub (local)"}),M.map(E=>r("span",{className:"rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle",children:E},E)),u("div",{className:"relative",children:[u("button",{type:"button",onClick:E=>{E.stopPropagation(),p(Q=>!Q)},className:"inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:border-primary transition-colors",title:"Install on more agents",children:[r(ut,{className:"h-3 w-3"}),"Add agent"]}),f&&u("div",{className:"absolute left-0 top-full mt-1 z-10 min-w-[160px] rounded-md border border-border bg-surface shadow-lg overflow-hidden",children:[t.filter(E=>!E.isHub&&!M.includes(E.name)).map(E=>r("button",{type:"button",onClick:Q=>{Q.stopPropagation(),p(!1)},className:"w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors",children:E.name},E.id)),t.filter(E=>!E.isHub&&!M.includes(E.name)).length===0&&r("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle",children:"No available agents"})]})]})]})]})]}),r("div",{className:"flex items-center justify-end px-5 py-3 border-t border-border flex-shrink-0",children:r("button",{type:"button",onClick:()=>v(!1),className:"rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:"Close"})})]})})]})}const S8=".tgz,.tar.gz,.zip";function C8({onUploadSuccess:e}){const[t,n]=_(!1),o=ne(null),s=q(async i=>{n(!0);const l=new FormData;l.append("file",i);const c=localStorage.getItem("camstack_admin_token")??"";try{(await(await fetch("/api/addons/upload",{method:"POST",headers:{Authorization:`Bearer ${c}`},body:l})).json()).success&&e()}finally{n(!1)}},[e]),a=q(i=>{const l=i.target.files?.[0];l&&s(l),i.target.value=""},[s]);return u(xe,{children:[r("input",{ref:o,type:"file",accept:S8,onChange:a,className:"hidden"}),u("button",{type:"button",onClick:()=>o.current?.click(),disabled:t,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors",children:[t?r(Pe,{className:"w-3.5 h-3.5 animate-spin"}):r(Xc,{className:"w-3.5 h-3.5"}),t?"Uploading...":"Upload"]})]})}function M8(e,t){const n=e??"hub-only";return n==="any-node"?!0:n==="hub-only"?t:!t}function I8(e){const t=e;if(!t?.manifest)return null;const n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??"0.0.0",capabilities:t.manifest.capabilities??[]},o=t.process,s=o?{pid:o.pid,mode:o.mode==="forked"?"forked":"in-process",state:o.state??"unknown"}:void 0,a=t.health;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...s?{process:s}:{},hasBackup:t.hasBackup,...a?{health:a}:{}}}function A8(e){const t=new Map,n=[];for(const s of e){const a=s.manifest.packageName;if(!a){n.push(s);continue}const i=t.get(a);if(i)i.addons.push(s);else{const l=s.manifest.bundle,c={packageName:a,displayName:l?.displayName??s.manifest.packageDisplayName??s.manifest.name,version:s.manifest.packageVersion,addons:[s],...s.installSource!==void 0?{installSource:s.installSource}:{},...l!==void 0?{bundle:l}:{}};t.set(a,c)}}const o=[];for(const s of t.values())s.bundle!==void 0||s.addons.length>=2?o.push({bundle:s,representative:s.addons[0]}):o.push(s.addons[0]);return o.push(...n),o}function Wt(e){return"bundle"in e}function P8({addons:e,clusterStatus:t,selectedNode:n,onRefresh:o,isRefreshing:s}){const a=ke(),[i,l]=_(""),c=Y1(i),[d,f]=_(!1),p=ne(null);Z(()=>{if(!d)return;const E=Q=>{p.current&&!p.current.contains(Q.target)&&f(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[d]);const{data:m}=dc(void 0,{staleTime:5*6e4}),h=U(()=>{const E=new Map;for(const Q of m??[])E.set(Q.name,Q.latestVersion);return E},[m]),[g,b]=_(null),[x,v]=_(null),w=Ki({onMutate:E=>{b(E.name),v(null)},onSuccess:(E,Q)=>{b(null);const K=E;if(K&&K.success===!1){v({name:Q.name,message:K.error??"Update failed (no error message returned by server)"});return}a.invalidateQueries({queryKey:[["addons"]]}),a.invalidateQueries({queryKey:[["addons","listUpdates"]]})},onError:(E,Q)=>{b(null),v({name:Q.name,message:E instanceof Error?E.message:String(E)})}}),{data:y}=Wh(void 0,{staleTime:3e4}),N=Xh({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons","getAutoUpdateSettings"]]})}}),{data:k,isFetching:S}=qh({query:c||void 0},{enabled:d,staleTime:6e4}),M=Ki(),P=async()=>{const E=m??[];for(const Q of E)await M.mutateAsync({name:Q.name,version:Q.latestVersion});a.invalidateQueries({queryKey:[["addons"]]})},I=cc({onSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),a.invalidateQueries({queryKey:[["addonPages"]]}),a.invalidateQueries({queryKey:[["capabilities"]]}),a.invalidateQueries({queryKey:[["integrations"]]})}}),[z,$]=_("type"),[O,R]=_(()=>typeof window>"u"?"grouped":window.localStorage.getItem("camstack.addons.viewMode")==="flat"?"flat":"grouped"),A=E=>{R(E),typeof window<"u"&&window.localStorage.setItem("camstack.addons.viewMode",E)},[L,D]=ha(),T=L.get("capability"),B=U(()=>{let E=n.isHub?e:e.filter(Q=>{const K=Q.manifest.execution;return M8(K?.placement,n.isHub)});return T&&(E=E.filter(Q=>(Q.manifest.capabilities??[]).some(Y=>(typeof Y=="string"?Y:Y.name)===T))),E},[e,n.isHub,T]),F=()=>{const E=new URLSearchParams(L);E.delete("capability"),D(E,{replace:!0})},j=O==="flat"?B:A8(B),H=U(()=>{const E=[...j];switch(z){case"type":E.sort((Q,K)=>{const Y=Wt(Q)?0:1,re=Wt(K)?0:1;if(Y!==re)return Y-re;const te=Wt(Q)?Q.bundle.displayName:Q.manifest.name,X=Wt(K)?K.bundle.displayName:K.manifest.name;return te.localeCompare(X)});break;case"name":E.sort((Q,K)=>{const Y=Wt(Q)?Q.bundle.displayName:Q.manifest.name,re=Wt(K)?K.bundle.displayName:K.manifest.name;return Y.localeCompare(re)});break;case"source":E.sort((Q,K)=>{const Y=Wt(Q)?Q.bundle.installSource??"":Q.installSource??"",re=Wt(K)?K.bundle.installSource??"":K.installSource??"";return Y.localeCompare(re)});break}return E},[j,z]);return u("div",{className:"space-y-4",children:[x&&r("div",{className:"rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px]",children:u("div",{className:"flex items-start justify-between gap-3",children:[u("div",{className:"space-y-0.5",children:[u("div",{className:"font-medium text-danger",children:["Failed to update ",x.name]}),r("div",{className:"text-foreground-subtle font-mono",children:x.message})]}),r("button",{type:"button",onClick:()=>v(null),className:"text-foreground-subtle hover:text-foreground text-[10px]",children:"dismiss"})]})}),u("div",{className:"flex items-center gap-2 flex-wrap",children:[u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"text-[10px] text-foreground-subtle",children:"Sort:"}),u("select",{value:z,onChange:E=>$(E.target.value),className:"rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground focus:outline-none focus:border-primary/50",children:[r("option",{value:"type",children:"Bundles first"}),r("option",{value:"name",children:"Name"}),r("option",{value:"source",children:"Install source"})]})]}),u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"text-[10px] text-foreground-subtle",children:"View:"}),r("div",{className:"flex rounded-md border border-border overflow-hidden text-[10px] font-medium",children:["grouped","flat"].map(E=>r("button",{type:"button",onClick:()=>A(E),className:`px-2.5 py-1.5 transition-colors capitalize ${O===E?"bg-primary/10 text-primary":"bg-transparent text-foreground-subtle hover:bg-surface-hover"}`,title:E==="grouped"?"Group multi-addon packages into a bundle card":"Show every addon as its own card",children:E},E))})]}),u("div",{className:"flex items-center gap-1.5",children:[r(pt,{className:"h-3 w-3 text-foreground-subtle"}),r("span",{className:"text-[10px] text-foreground-subtle",children:"Auto-Update:"}),r("div",{className:"flex rounded-md border border-border overflow-hidden text-[10px] font-medium",children:["off","latest","beta"].map(E=>r("button",{type:"button",onClick:()=>N.mutate({channel:E}),disabled:N.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${y?.channel===E?E==="off"?"bg-gray-700 text-gray-200":E==="latest"?"bg-blue-500/20 text-blue-400":"bg-amber-500/20 text-amber-400":"bg-transparent text-foreground-subtle hover:bg-surface-hover"} ${E!=="off"?"border-l border-border":""}`,children:E},E))})]}),(m?.length??0)>0&&u("button",{type:"button",onClick:()=>void P(),disabled:M.isPending,className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/30 disabled:opacity-50 transition-colors font-medium",children:[r(vn,{className:`w-3 h-3 ${M.isPending?"animate-bounce":""}`}),"Update All (",m.length,")"]}),u("button",{type:"button",onClick:o,disabled:s,className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors",children:[r(pt,{className:`w-3 h-3 ${s?"animate-spin":""}`}),"Refresh"]})]}),u("div",{className:"flex items-center gap-3",children:[u("div",{className:"relative flex-1 min-w-[200px]",ref:p,children:[r(hy,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle"}),r("input",{type:"text",value:i,onChange:E=>{l(E.target.value),f(!0)},onFocus:()=>f(!0),placeholder:"Search addons on npm...",className:"w-full rounded-lg border border-border bg-background pl-9 pr-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"}),S&&r(Pe,{className:"absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin"}),d&&k&&k.length>0&&u("div",{className:"absolute left-0 right-0 top-full mt-1 z-40 rounded-lg border border-border bg-surface shadow-xl overflow-hidden",children:[k.length>0&&u("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border",children:["npm results (",k.length,")"]}),k&&k.length>0&&r("div",{className:"max-h-72 overflow-auto divide-y divide-border",children:k.map(E=>u("div",{className:"flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors",children:[r("div",{className:"w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0",children:E.name.replace("@camstack/addon-","").charAt(0).toUpperCase()}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-[11px] font-semibold truncate",children:E.name}),u("span",{className:"text-[10px] text-foreground-subtle",children:["v",E.version]})]}),E.description&&r("div",{className:"text-[10px] text-foreground-subtle truncate",children:E.description})]}),E.installed?u("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md border border-emerald-500/30 bg-emerald-500/10 text-emerald-400 shrink-0",children:[r(Mt,{className:"h-3 w-3"}),E.installedVersion??"Installed"]}):u("button",{type:"button",onClick:()=>I.mutate({packageName:E.name}),disabled:I.isPending,className:"inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0",children:[I.isPending?r(Pe,{className:"h-3 w-3 animate-spin"}):r(vn,{className:"h-3 w-3"}),"Install"]})]},E.name))})]})]}),r(C8,{onUploadSuccess:()=>{a.invalidateQueries({queryKey:[["addons"]]}),o()}})]}),T&&u("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/10 border border-primary/30 text-sm",children:[r("span",{className:"text-foreground-subtle",children:"Filtering by capability:"}),r("span",{className:"font-mono text-primary font-semibold",children:T}),r("button",{type:"button",onClick:F,className:"ml-auto text-xs text-foreground-subtle hover:text-foreground underline",children:"Clear"})]}),B.length===0&&r("div",{className:"text-xs text-foreground-subtle",children:e.length===0?"No addons installed":T?`No installed addons declare the "${T}" capability. Browse the npm catalog above to find a compatible addon.`:`No addons compatible with ${n.name} (placement filter active)`}),r("div",{className:"space-y-2",children:H.map(E=>{if(Wt(E)){const Y=E.bundle.packageName,re=h.get(Y);return r(fl,{addon:E.representative,clusterStatus:t?.[E.representative.manifest.id],bundle:E.bundle,availableUpdate:re,isUpdating:g===Y,onUpdate:re?()=>w.mutate({name:Y,version:re}):void 0},Y)}const Q=E.manifest.packageName,K=h.get(Q);return r(fl,{addon:E,clusterStatus:t?.[E.manifest.id],availableUpdate:K,isUpdating:g===Q,onUpdate:K?()=>w.mutate({name:E.manifest.packageName,version:K}):void 0},E.manifest.id)})})]})}function E8(){const e=ke(),{data:t,isLoading:n,isError:o}=ra(),{data:s}=nb(void 0,{staleTime:15e3}),{data:a}=Mn(void 0,{staleTime:3e4,refetchInterval:1e4}),i=U(()=>{const x=new Map;x.set("hub",{id:"hub",name:"Hub",isHub:!0});for(const v of a??[]){const w=String(v.id??"");w&&x.set(w,{id:w,name:String(v.name??w),isHub:!!v.isHub})}return[...x.values()]},[a]),[l,c]=_("hub"),d=i.find(x=>x.id===l)??i[0],f=Qh(),p=Vh(),m=f.isPending||p.isPending,h=async()=>{await f.mutateAsync(),await p.mutateAsync(),e.invalidateQueries({queryKey:[["addons"]]})},g=ne(f);g.current=f,Z(()=>{g.current.mutate()},[]);const b=(t??[]).map(I8).filter(x=>x!==null);return u("div",{className:"p-6 space-y-5",children:[u("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[u("div",{children:[r("h1",{className:"text-lg font-semibold text-foreground",children:"Addons"}),r("p",{className:"text-xs text-foreground-subtle mt-0.5",children:"Manage installed addons and explore capability providers."})]}),u("div",{className:"flex items-center gap-3 flex-wrap",children:[r(hh,{selectedNodeId:l,onSelect:c}),!n&&!o&&u("span",{className:"text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium",children:[b.length," installed"]}),u("button",{type:"button",onClick:()=>void h(),disabled:m,className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors",title:"Re-fetch addons + check npm for new versions",children:[r(pt,{className:`w-3 h-3 ${m?"animate-spin":""}`}),"Check for updates"]})]})]}),!d.isHub&&u("div",{className:"rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle",children:["Showing only addons compatible with"," ",r("span",{className:"font-medium text-foreground",children:d.name})," ","— agents only run ",r("code",{className:"font-mono",children:"agent-only"})," and"," ",r("code",{className:"font-mono",children:"any-node"})," addons. Install / uninstall is hub-driven; agents auto-sync from the hub."]}),n&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading…"}),o&&r("div",{className:"text-xs text-danger",children:"Failed to load addons"}),!n&&!o&&r(P8,{addons:b,clusterStatus:s,selectedNode:d,onRefresh:()=>void h(),isRefreshing:m})]})}function $8(){return r(un,{icon:Ze,title:"Logs",children:r("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:r(Ut,{limit:500,maxHeight:"max-h-[calc(100vh-250px)]",showScope:!0,showFilters:!0})})})}function td({tabs:e,defaultTab:t}){const[n,o]=ha(),s=n.get("tab"),a=t??e[0]?.id??"",i=e.some(d=>d.id===s)?s:a,l=e.find(d=>d.id===i)??e[0],c=d=>{const f=new URLSearchParams(n);f.set("tab",d),o(f,{replace:!0})};return u("div",{className:"space-y-3",children:[r("div",{className:"flex border-b border-border",children:e.map(d=>{const f=d.icon,p=d.id===i;return u("button",{onClick:()=>c(d.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors ${p?"border-primary text-primary":"border-transparent text-foreground-subtle hover:text-foreground"}`,children:[f&&r(f,{className:"h-3.5 w-3.5"}),d.label]},d.id)})}),r("div",{children:l?.content})]})}const bp={super_admin:"bg-danger/10 text-danger",admin:"bg-primary/10 text-primary",viewer:"bg-foreground-subtle/10 text-foreground-subtle"};function _8(){const e=ke(),[t,n]=_(!1),[o,s]=_(""),[a,i]=_(""),[l,c]=_("viewer"),[d,f]=_(null),{data:p,isLoading:m,isError:h}=Sc(),g=nt(),b=()=>e.invalidateQueries({queryKey:[["userManagement","listUsers"]]}),x=ex({onSuccess:()=>{b(),n(!1),s(""),i(""),c("viewer"),f(null)},onError:I=>{f(I instanceof Error?I.message:"Failed to create user")}}),v=nx({onSuccess:b}),w=tx({onSuccess:b}),y=Cc({onSuccess:b}),N=p??[];async function k(I){await g({title:"Delete user",message:`Permanently delete user "${I.username}"? This cannot be undone — any active sessions will be revoked on next request.`,confirmLabel:"Delete",variant:"danger"})&&v.mutate({id:I.id})}async function S(I){const z=window.prompt(`New password for "${I.username}":`);if(!z)return;if(z.length<8){window.alert("Password must be at least 8 characters.");return}await g({title:"Reset password",message:`Reset the password for "${I.username}"? They will need to use the new password on their next login.`,confirmLabel:"Reset"})&&y.mutate({id:I.id,newPassword:z})}function M(I,z){z!==I.role&&w.mutate({id:I.id,role:z})}function P(I){return I?new Date(typeof I=="number"?I:String(I)).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):"—"}return u(un,{icon:xy,title:"Users",actions:u("button",{onClick:()=>n(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm hover:bg-primary/90",children:[r(ut,{className:"h-3.5 w-3.5"}),"Create User"]}),children:[t&&u("div",{className:"rounded-lg border border-border bg-surface p-4 space-y-3",children:[u("div",{className:"flex items-center justify-between",children:[r("span",{className:"text-xs font-medium text-foreground",children:"New User"}),r("button",{onClick:()=>n(!1),className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-4 w-4"})})]}),u("div",{className:"grid grid-cols-3 gap-3",children:[u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Username"}),r("input",{type:"text",value:o,onChange:I=>s(I.target.value),placeholder:"john",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Password"}),r("input",{type:"password",value:a,onChange:I=>i(I.target.value),placeholder:"••••••••",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Role"}),u("select",{value:l,onChange:I=>c(I.target.value),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"viewer",children:"Viewer"}),r("option",{value:"admin",children:"Admin"}),r("option",{value:"super_admin",children:"Super Admin"})]})]})]}),d&&r("p",{className:"text-[10px] text-danger",children:d}),u("div",{className:"flex justify-end gap-2",children:[r("button",{onClick:()=>n(!1),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),r("button",{onClick:()=>x.mutate({username:o,password:a,role:l}),disabled:x.isPending||!o||!a,className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:x.isPending?"Creating...":"Create"})]})]}),m&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading..."}),h&&r("div",{className:"text-xs text-danger",children:"Failed to load"}),!m&&!h&&N.length===0&&r("div",{className:"text-xs text-foreground-subtle",children:"No data"}),(()=>{const I=$=>v.isPending&&v.variables?.id===$.id||w.isPending&&w.variables?.id===$.id||y.isPending&&y.variables?.id===$.id;return r(dh,{columns:[{key:"username",header:"Username",render:$=>$.username},{key:"role",header:"Role",render:$=>{const O=$.role??"viewer",R=bp[O]??bp.viewer;return u("select",{value:O,onChange:A=>M($,A.target.value),disabled:I($),className:`rounded border border-border bg-background px-2 py-0.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 ${R}`,title:"Change role",children:[r("option",{value:"viewer",children:"Viewer"}),r("option",{value:"admin",children:"Admin"}),r("option",{value:"super_admin",children:"Super Admin"})]})}},{key:"createdAt",header:"Created",render:$=>r("span",{className:"text-foreground-subtle",children:P($.createdAt)})},{key:"actions",header:"Actions",align:"right",render:$=>{const O=I($);return u("div",{className:"flex items-center justify-end gap-1",children:[u("button",{onClick:()=>S($),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:[r(YD,{className:"h-3 w-3"}),"Reset password"]}),u("button",{onClick:()=>k($),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?r(Pe,{className:"h-3 w-3 animate-spin"}):r(Ge,{className:"h-3 w-3"}),"Delete"]})]})}}],rows:N,rowKey:$=>$.id,minWidthPx:560})})()]})}const D8={super_admin:"bg-danger/10 text-danger",admin:"bg-primary/10 text-primary",viewer:"bg-foreground-subtle/10 text-foreground-subtle",agent:"bg-warning/10 text-warning"};function eo(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}function L8(e){return e?e==="*"?"*":e.join(", "):""}function T8(e){return e.type==="integration"?{type:"addon",target:e.target}:{type:e.type,target:e.target}}function R8(){const e=ke(),t=nt(),{data:n,isLoading:o}=rx(),{data:s}=Sc(),a=U(()=>n??[],[n]),i=U(()=>s??[],[s]),l=()=>e.invalidateQueries({queryKey:[["userManagement","listApiKeys"]]}),c=()=>e.invalidateQueries({queryKey:[["userManagement","listScopedTokens"]]}),[d,f]=_(!1),[p,m]=_(null),h=ox({onSuccess:l}),g=sx({onSuccess:({token:w,record:y})=>{c(),f(!1),m({token:w,label:y.name})}}),b=ax({onSuccess:c}),x=async(w,y)=>{await t({title:`Revoke "${y}"?`,message:"Any client using this token will lose access immediately. This cannot be undone.",confirmLabel:"Revoke",variant:"danger"})&&h.mutate({id:w})},v=async(w,y)=>{await t({title:`Revoke "${y}"?`,message:"The scoped token will be invalid on its next use.",confirmLabel:"Revoke",variant:"danger"})&&b.mutate({id:w})};return u(un,{icon:ay,title:"Tokens",subtitle:"Issue scoped tokens to grant a user a narrow surface — a specific addon, integration, route prefix, or capability. Every token MUST be scoped: revoking it has predictable blast radius.",actions:u("button",{onClick:()=>f(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",disabled:i.length===0,title:i.length===0?"Create a user first":"Issue a scoped token",children:[r(br,{className:"h-3.5 w-3.5"}),"New token"]}),children:[u(xp,{title:"Scoped tokens",subtitle:"Grouped per user",children:[i.length===0&&r(z8,{text:"No users yet — scoped tokens are issued on behalf of an existing user."}),i.map(w=>r(B8,{userId:w.id,username:w.username,onRevoke:(y,N)=>{v(y,N)},revokePending:b.isPending,revokeId:b.variables?.id},w.id))]}),a.length>0&&r(xp,{title:"Legacy API keys",subtitle:`${a.length} pre-existing — revoke only`,children:r(n0,{headers:["Label","Role","Prefix","Allowed providers","Created","Last used",""],rows:a.map(w=>{const y=w.role??"viewer",N=h.isPending&&h.variables?.id===w.id;return u("tr",{className:"hover:bg-primary/5",children:[r("td",{className:"px-3 py-2 text-foreground border-b border-border font-medium",children:w.label}),r("td",{className:"px-3 py-2 text-foreground border-b border-border",children:r("span",{className:`inline-block rounded px-2 py-0.5 text-[10px] uppercase tracking-wide ${D8[y]}`,children:y})}),u("td",{className:"px-3 py-2 text-foreground border-b border-border font-mono text-[11px]",children:[w.tokenPrefix,"…"]}),r("td",{className:"px-3 py-2 text-foreground border-b border-border text-foreground-subtle",children:L8(w.allowedProviders)||"all"}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:eo(w.createdAt)}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:eo(w.lastUsedAt)}),r("td",{className:"px-3 py-2 border-b border-border text-right",children:u("button",{onClick:()=>{x(w.id,w.label)},disabled:N,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50",title:"Revoke",children:[N?r(Pe,{className:"h-3 w-3 animate-spin"}):r(Ge,{className:"h-3 w-3"}),"Revoke"]})})]},w.id)})})}),o&&r(O8,{}),d&&r(F8,{users:i.map(w=>({id:w.id,username:w.username})),onClose:()=>f(!1),onSubmit:w=>g.mutate({userId:w.userId,name:w.name,scopes:w.scopes,...w.expiresAt!==void 0?{expiresAt:w.expiresAt}:{}}),submitting:g.isPending}),p&&r(H8,{token:p.token,label:p.label,onClose:()=>m(null)})]})}function xp({title:e,subtitle:t,children:n}){return u("div",{className:"space-y-2",children:[u("div",{className:"flex items-baseline justify-between",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:e}),t&&r("span",{className:"text-[10px] text-foreground-subtle",children:t})]}),n]})}function O8(){return r("div",{className:"space-y-2",children:[1,2].map(e=>r("div",{className:"h-10 rounded border border-border bg-surface animate-pulse"},e))})}function z8({text:e}){return r("div",{className:"rounded border border-dashed border-border bg-surface px-3 py-4 text-xs text-foreground-subtle text-center",children:e})}function n0({headers:e,rows:t}){return r("div",{className:"rounded-lg border border-border bg-surface overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[640px]",children:[r("thead",{children:r("tr",{children:e.map((n,o)=>r("th",{className:`px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border whitespace-nowrap ${o===e.length-1?"text-right":"text-left"}`,children:n},o))})}),r("tbody",{children:t})]})})}function B8({userId:e,username:t,onRevoke:n,revokePending:o,revokeId:s}){const{data:a,isLoading:i}=ix({userId:e}),l=a??[];return i||l.length===0?null:u("div",{className:"space-y-1.5",children:[r("div",{className:"text-[11px] font-medium text-foreground",children:t}),r(n0,{headers:["Name","Prefix","Scopes","Expires","Last used","Created",""],rows:l.map(c=>{const d=o&&s===c.id;return u("tr",{className:"hover:bg-primary/5",children:[r("td",{className:"px-3 py-2 text-foreground border-b border-border font-medium",children:c.name}),u("td",{className:"px-3 py-2 text-foreground border-b border-border font-mono text-[11px]",children:[c.tokenPrefix,"…"]}),r("td",{className:"px-3 py-2 text-foreground border-b border-border",children:r("div",{className:"flex flex-wrap gap-1",children:c.scopes.map((f,p)=>u("span",{className:"inline-block rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-mono",children:[f.type,":",f.target]},p))})}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:eo(c.expiresAt)}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:eo(c.lastUsedAt)}),r("td",{className:"px-3 py-2 text-foreground-subtle border-b border-border",children:eo(c.createdAt)}),r("td",{className:"px-3 py-2 border-b border-border text-right",children:u("button",{onClick:()=>n(c.id,c.name),disabled:d,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50",children:[d?r(Pe,{className:"h-3 w-3 animate-spin"}):r(Ge,{className:"h-3 w-3"}),"Revoke"]})})]},c.id)})})]})}function F8({users:e,onClose:t,onSubmit:n,submitting:o}){const[s,a]=_(e[0]?.id??""),[i,l]=_(""),[c,d]=_([{type:"addon",target:""}]),[f,p]=_(""),{data:m=[]}=ra(),{data:h=[]}=sa(),g=(w,y)=>{d(N=>N.map((k,S)=>{if(S!==w)return k;const M={...k,...y};return y.type!==void 0&&y.type!==k.type&&(M.target=""),M}))},b=c.filter(w=>w.target.trim().length>0).map(T8),x=s!==""&&i.trim().length>0&&b.length>0&&!o,v=()=>{const w=parseInt(f,10),y=Number.isFinite(w)&&w>0?Date.now()+w*864e5:void 0;n({userId:s,name:i.trim(),scopes:b,expiresAt:y})};return u(r0,{title:"Create scoped token",onClose:t,children:[u("div",{className:"space-y-3",children:[r(es,{label:"On behalf of user",children:r("select",{value:s,onChange:w=>a(w.target.value),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary",children:e.map(w=>r("option",{value:w.id,children:w.username},w.id))})}),r(es,{label:"Name",children:r("input",{value:i,onChange:w=>l(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"})}),r(es,{label:"Scopes",hint:"Each scope picks a concrete surface. The token can access ONLY what's listed.",children:u("div",{className:"space-y-1.5",children:[c.map((w,y)=>r(j8,{scope:w,addons:m,integrations:h,onChange:N=>g(y,N),onRemove:c.length>1?()=>d(N=>N.filter((k,S)=>S!==y)):void 0},y)),u("button",{onClick:()=>d(w=>[...w,{type:"addon",target:""}]),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",children:[r(ut,{className:"h-3 w-3"}),"Add scope"]})]})}),r(es,{label:"Expires in (days)",hint:"Leave blank for non-expiring.",children:r("input",{type:"number",min:1,value:f,onChange:w=>p(w.target.value),placeholder:"30",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary"})})]}),u(o0,{children:[r("button",{onClick:t,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),u("button",{onClick:v,disabled:!x,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[o?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):r(br,{className:"h-3.5 w-3.5"}),"Issue token"]})]})]})}function j8({scope:e,addons:t,integrations:n,onChange:o,onRemove:s}){const a=t.map(l=>({id:l.manifest.id})),i=()=>{switch(e.type){case"addon":return u("select",{value:e.target,onChange:l=>o({target:l.target.value}),className:"flex-1 rounded border border-border bg-background px-2 py-1.5 text-xs font-mono focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"",children:"— pick addon —"}),a.map(l=>r("option",{value:l.id,children:l.id},l.id))]});case"integration":return u("select",{value:e.target,onChange:l=>o({target:l.target.value}),className:"flex-1 rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"",children:"— pick integration —"}),n.map(l=>u("option",{value:l.addonId,children:[l.name," (",l.addonId,")"]},l.id))]});case"capability":return u("select",{value:e.target,onChange:l=>o({target:l.target.value}),className:"flex-1 rounded border border-border bg-background px-2 py-1.5 text-xs font-mono focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"",children:"— pick capability —"}),Object.values(aw).sort().map(l=>r("option",{value:l,children:l},l))]});case"route-prefix":return r("input",{value:e.target,onChange:l=>o({target:l.target.value}),placeholder:"/api/cloudflare",className:"flex-1 rounded border border-border bg-background px-2 py-1.5 text-xs font-mono focus:outline-none focus:ring-1 focus:ring-primary"})}};return u("div",{className:"flex items-center gap-1.5",children:[u("select",{value:e.type,onChange:l=>o({type:l.target.value}),className:"rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"addon",children:"addon"}),r("option",{value:"integration",children:"integration"}),r("option",{value:"capability",children:"capability"}),r("option",{value:"route-prefix",children:"route-prefix"})]}),i(),s&&r("button",{onClick:s,className:"rounded p-1 text-foreground-subtle hover:text-danger hover:bg-danger/10",title:"Remove scope",children:r(Ve,{className:"h-3 w-3"})})]})}function H8({token:e,label:t,onClose:n}){const[o,s]=_(!1),a=async()=>{try{await navigator.clipboard.writeText(e),s(!0)}catch{}};return u(r0,{title:`Token: ${t}`,onClose:n,children:[u("div",{className:"space-y-3",children:[r("div",{className:"rounded border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",children:"Copy this token now. Once you close this dialog the secret cannot be displayed again."}),r("div",{className:"rounded border border-border bg-background p-2 font-mono text-[11px] break-all select-all",children:e})]}),u(o0,{children:[u("button",{onClick:()=>{a()},className:"inline-flex items-center gap-1.5 rounded bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30",children:[o?r(Mt,{className:"h-3.5 w-3.5 text-primary"}):r(MD,{className:"h-3.5 w-3.5"}),o?"Copied":"Copy"]}),r("button",{onClick:n,className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:"Done"})]})]})}function r0({title:e,onClose:t,children:n}){return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:t,children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:o=>o.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:e}),r("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-4 w-4"})})]}),r("div",{className:"p-4",children:n})]})})}function o0({children:e}){return r("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:e})}function es({label:e,hint:t,children:n}){return u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:e}),n,t&&r("p",{className:"text-[10px] text-foreground-subtle",children:t})]})}function Ca(e){const{title:t,subtitle:n,pageIcon:o,itemIcon:s,capability:a,installButtonLabel:i="Add addon",items:l,isLoading:c,emptyTitle:d="No addons installed for this capability",emptyDescription:f,itemIconColor:p,renderStatusBadges:m,renderActionButtons:h,renderExpandedBody:g,trailing:b}=e,x=l.length>1,[v,w]=_(()=>l[0]?.addonId??null);Z(()=>{v&&(l.some(k=>k.addonId===v)||w(l[0]?.addonId??null))},[l,v]);const y=k=>w(S=>S===k?null:k),N=a?`/system/addons?capability=${encodeURIComponent(a)}`:null;return r(un,{icon:o,title:t,subtitle:n,actions:N?r(io,{to:N,children:u(Qe,{variant:"primary",size:"sm",children:[r(ut,{className:"h-3.5 w-3.5 mr-1"}),i]})}):void 0,children:c?r(en,{children:r("div",{className:"p-6 text-sm text-foreground-subtle",children:"Loading…"})}):l.length===0?r(en,{children:r(bh,{title:d,description:f??(N?`Install an addon that declares the "${a}" capability to get started.`:void 0),action:N?r(io,{to:N,children:u(Qe,{variant:"primary",size:"sm",children:[r(ut,{className:"h-3.5 w-3.5 mr-1"}),i]})}):void 0})}):u("div",{className:"flex flex-col gap-4",children:[l.map(k=>{const S=!x||v===k.addonId,M=p?.(k)??"bg-primary/15 text-primary";return u(en,{children:[u("div",{className:`flex items-center gap-4 p-4 ${S?"border-b border-border":""}`,children:[u("button",{type:"button",onClick:()=>x&&y(k.addonId),className:`flex items-center gap-4 flex-1 min-w-0 text-left ${x?"hover:opacity-80 transition-opacity":""}`,disabled:!x,children:[r("div",{className:`h-10 w-10 rounded-lg flex items-center justify-center shrink-0 ${M}`,children:r(s,{className:"h-5 w-5"})}),u("div",{className:"flex-1 min-w-0",children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:"font-semibold text-foreground",children:k.displayName}),m?.(k)]}),u("div",{className:"text-xs text-foreground-subtle mt-1 font-mono",children:["@camstack/addon-",k.addonId]})]}),x&&r(wt,{className:`h-4 w-4 text-foreground-subtle shrink-0 transition-transform ${S?"rotate-180":""}`})]}),h&&r("div",{className:"flex items-center gap-1 shrink-0",children:h(k)})]}),S&&g?.(k)]},k.addonId)}),b]})})}function V8(){const e=pc(),t=e.data??[];return r(Ca,{title:"Authentication",subtitle:"Login providers exposed to the admin UI. Local username + password is always available; OIDC / SAML / LDAP can be added by installing a provider addon.",pageIcon:br,itemIcon:br,capability:"auth-provider",installButtonLabel:"Add provider",items:t,isLoading:e.isLoading,emptyTitle:"No authentication providers registered",emptyDescription:"Local auth should always be available — if this list is empty, the local-auth builtin failed to register. Check the Addons page for load errors.",renderStatusBadges:n=>n.enabled?null:r("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-red-500/15 text-red-700 dark:text-red-300",children:"Disabled"}),renderExpandedBody:n=>u("div",{className:"p-4 space-y-3",children:[u("div",{className:"text-xs text-foreground-subtle flex flex-wrap items-center gap-3",children:[n.hasCredentialFlow&&r("span",{children:"· username + password"}),n.hasRedirectFlow&&r("span",{children:"· redirect (SSO)"}),!n.hasCredentialFlow&&!n.hasRedirectFlow&&r("span",{children:"· no active flow"})]}),n.status&&r("div",{className:"text-xs text-foreground-subtle",children:n.status}),r("div",{className:"flex justify-end pt-2",children:u(io,{to:`/system/addons?addon=${encodeURIComponent(n.addonId)}`,className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[r(Nt,{className:"h-3.5 w-3.5"}),"Configure",r(Zx,{className:"h-3.5 w-3.5"})]})})]})})}function q8(){return r("div",{className:"flex flex-col",children:r("div",{className:"px-6 pt-6",children:r(td,{tabs:[{id:"users",label:"Users",icon:xy,content:r(_8,{})},{id:"api-keys",label:"Tokens",icon:ay,content:r(R8,{})},{id:"authentication",label:"Authentication",icon:br,content:r(V8,{})}]})})})}function nd({addonId:e,defaultActivity:t,showActivity:n=!0,maxHeight:o="max-h-64",defaultTab:s}){const a=t??(s==="events"?"events":"logs"),[i,l]=_(a);return u("div",{className:"flex flex-col gap-4",children:[r(Tr,{nodeId:"hub",addonIds:[e],level:"global"}),n&&u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[u("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-surface-hover/20",children:[r("span",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Activity"}),u("div",{className:"flex items-center gap-1",children:[r(yp,{kind:"logs",active:i==="logs",onClick:()=>l("logs")}),r(yp,{kind:"events",active:i==="events",onClick:()=>l("events")})]})]}),i==="logs"?r(Ut,{addonId:e,maxHeight:o,showFilters:!1}):r(tr,{addonId:e,category:"addon.*",maxHeight:o})]})]})}function yp({kind:e,active:t,onClick:n}){return u("button",{onClick:n,className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${t?"bg-primary/10 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,children:[r(e==="logs"?Ze:Io,{className:"h-3 w-3"}),e==="logs"?"Logs":"Events"]})}function Q8(){const e=ke(),t=qb(void 0,{refetchInterval:5e3}),n=t.data??[],[o,s]=_(null),a=()=>{e.invalidateQueries({queryKey:[["remoteAccess"]]}),s(null)},i=Qb({onSuccess:a,onError:()=>s(null)}),l=Ub({onSuccess:a,onError:()=>s(null)});return r(Ca,{title:"Remote Access",subtitle:"Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …). Settings, Logs and Events are docked under every provider.",pageIcon:gr,itemIcon:gr,capability:"network-access",installButtonLabel:"Add tunnel",items:n,isLoading:t.isLoading,emptyTitle:"No remote-access providers installed",emptyDescription:"Install a tunnel addon (e.g. @camstack/addon-cloudflare-tunnel) to expose this hub publicly.",itemIconColor:c=>c.connected?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle",renderStatusBadges:c=>u(xe,{children:[r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${c.connected?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:c.connected?"Connected":"Disconnected"}),c.endpoint&&u("a",{href:c.endpoint.url,target:"_blank",rel:"noopener noreferrer",onClick:d=>d.stopPropagation(),className:"text-[10px] text-emerald-700 dark:text-emerald-300 hover:underline flex items-center gap-1",children:[r(Gc,{className:"h-3 w-3"}),c.endpoint.url]}),c.error&&r("span",{className:"text-[10px] text-danger",children:c.error})]}),renderActionButtons:c=>{const d=o===c.addonId;return c.connected?u(Qe,{size:"sm",variant:"secondary",disabled:d,onClick:()=>{s(c.addonId),l.mutate({addonId:c.addonId})},children:[d?r(Pe,{className:"h-3 w-3 animate-spin"}):r(Po,{className:"h-3 w-3"}),"Stop"]}):u(Qe,{size:"sm",variant:"primary",disabled:d,onClick:()=>{s(c.addonId),i.mutate({addonId:c.addonId})},children:[d?r(Pe,{className:"h-3 w-3 animate-spin"}):r(va,{className:"h-3 w-3"}),"Start"]})},renderExpandedBody:c=>r("div",{className:"p-4",children:r(nd,{addonId:c.addonId,maxHeight:"max-h-72"})})})}function U8(){const e=ke(),t=Zb(void 0,{refetchInterval:3e4}),n=Xb(),o=t.data??[],s=n.data??[],[a,i]=_(null),l=Jb({onSuccess:()=>{e.invalidateQueries({queryKey:[["turnOrchestrator"]]}),i(null)},onError:()=>i(null)});return r(Ca,{title:"TURN Servers",subtitle:"ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.",pageIcon:on,itemIcon:on,capability:"turn-provider",installButtonLabel:"Add provider",items:o,isLoading:t.isLoading,emptyTitle:"No TURN providers installed",emptyDescription:"Install a TURN addon (e.g. @camstack/addon-cloudflare-turn) to enable WebRTC behind restrictive NATs.",itemIconColor:c=>c.error?"bg-danger/15 text-danger":c.enabled?"bg-violet-500/15 text-violet-700 dark:text-violet-300":"bg-foreground-subtle/15 text-foreground-subtle",renderStatusBadges:c=>u(xe,{children:[r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${c.enabled?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:c.enabled?"Enabled":"Disabled"}),u("span",{className:"text-[10px] text-foreground-subtle",children:["· ",c.serverCount," server",c.serverCount===1?"":"s"]}),c.error&&r("span",{className:"text-[10px] text-danger",children:c.error})]}),renderActionButtons:c=>{const d=a===c.addonId;return c.enabled?u(Qe,{size:"sm",variant:"secondary",disabled:d,onClick:()=>{i(c.addonId),l.mutate({addonId:c.addonId,enabled:!1})},children:[d?r(Pe,{className:"h-3 w-3 animate-spin"}):r(Po,{className:"h-3 w-3"}),"Disable"]}):u(Qe,{size:"sm",variant:"primary",disabled:d,onClick:()=>{i(c.addonId),l.mutate({addonId:c.addonId,enabled:!0})},children:[d?r(Pe,{className:"h-3 w-3 animate-spin"}):r(va,{className:"h-3 w-3"}),"Enable"]})},renderExpandedBody:c=>u(xe,{children:[c.urls.length>0&&u("div",{className:"px-4 py-3 border-b border-border",children:[u("div",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide mb-2",children:["Discovered ICE servers (",c.urls.length,")"]}),r("div",{className:"flex flex-wrap gap-1",children:c.urls.map(d=>r("span",{className:"inline-block rounded px-1.5 py-0.5 text-[10px] font-mono bg-foreground-subtle/10 text-foreground",children:d},d))})]}),r("div",{className:"p-4",children:r(nd,{addonId:c.addonId,maxHeight:"max-h-72"})})]}),trailing:u(en,{children:[u("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[u("div",{children:[r("div",{className:"text-sm font-semibold",children:"Combined ICE server list"}),r("div",{className:"text-xs text-foreground-subtle",children:"What the WebRTC layer fetches per-session."})]}),r(Qe,{size:"sm",variant:"secondary",onClick:()=>n.refetch(),disabled:n.isFetching,children:"Refresh"})]}),r("div",{className:"p-4",children:s.length===0?r("div",{className:"text-xs text-foreground-subtle",children:"No servers from enabled providers."}):r("div",{className:"flex flex-col gap-3",children:s.map((c,d)=>{const f=Array.isArray(c.urls)?c.urls:[c.urls];return u("div",{className:"rounded border border-border bg-surface",children:[(c.username||c.credential)&&u("div",{className:"px-3 py-1.5 border-b border-border text-[10px] font-mono text-foreground-subtle flex items-center gap-3",children:[c.username&&u("span",{children:[r("span",{className:"text-foreground-subtle",children:"user:"})," ",r("span",{className:"text-foreground",children:c.username})]}),c.credential&&u("span",{title:c.credential,children:[r("span",{className:"text-foreground-subtle",children:"credential:"})," ",r("span",{className:"text-foreground",children:`${c.credential.slice(0,8)}…${c.credential.slice(-4)}`})]})]}),r("ul",{className:"divide-y divide-border",children:f.map(p=>r("li",{className:"px-3 py-1.5 font-mono text-xs text-foreground break-all",children:p},p))})]},d)})})})]})})}const K8={lan:on,wifi:Fn,docker:ba,vpn:ly,loopback:sn,other:sn},G8={lan:"LAN",wifi:"Wi-Fi",docker:"Docker",vpn:"VPN",loopback:"Loopback",other:"Other"},W8=["lan","wifi","vpn","docker","other","loopback"];function Y8(e){const{interfaces:t,disabled:n,hideLoopback:o,ipv4Only:s,emptyMessage:a}=e,i=U(()=>t.filter(f=>!(o&&f.kind==="loopback"||s&&f.family!=="IPv4")),[t,o,s]),l=U(()=>{const f=new Map;for(const p of i){const m=f.get(p.kind)??[];m.push(p),f.set(p.kind,m)}return W8.filter(p=>f.has(p)).map(p=>({kind:p,items:f.get(p)}))},[i]),c=f=>e.mode==="single"?e.value===f:e.value.includes(f),d=f=>{if(n||f.kind==="loopback")return;if(e.mode==="single"){e.onChange(e.value===f.address?null:f.address);return}const p=new Set(e.value);p.has(f.address)?p.delete(f.address):p.add(f.address),e.onChange([...p])};return i.length===0?r("div",{className:"text-xs text-foreground-subtle italic",children:a??"No addresses available."}):r("div",{className:"flex flex-col gap-3",children:l.map(({kind:f,items:p})=>{const m=K8[f]??sn;return u("div",{className:"rounded-md border border-border overflow-hidden",children:[u("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border",children:[r(m,{className:"h-3.5 w-3.5 text-foreground-subtle"}),r("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle",children:G8[f]??f}),u("span",{className:"text-[10px] text-foreground-subtle",children:["· ",p.length]})]}),r("ul",{className:"divide-y divide-border",children:p.map(h=>{const g=c(h.address),b=h.kind==="loopback",x=!h.plausible&&!b;return u("li",{className:`flex items-center gap-3 px-3 py-2 ${b?"opacity-60 cursor-not-allowed":n?"opacity-60":x?"cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]":"cursor-pointer hover:bg-surface-hover/30"}`,onClick:()=>d(h),children:[r("span",{className:`flex items-center justify-center h-4 w-4 rounded ${e.mode==="single"?"rounded-full":"rounded"} border ${g?"border-primary bg-primary text-primary-foreground":"border-border bg-surface"}`,children:g&&r(Mt,{className:"h-3 w-3"})}),u("div",{className:`flex-1 min-w-0 ${x?"text-foreground-subtle":""}`,children:[u("div",{className:"flex items-center gap-2 flex-wrap",children:[r("span",{className:`font-mono text-xs font-semibold ${x?"text-foreground-subtle":"text-foreground"}`,children:h.name}),r("span",{className:"text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono",children:h.family}),h.preferred&&r("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary",children:"Auto-preferred"}),b&&r("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle",children:"Always included"}),x&&u("span",{className:"inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300",title:h.plausibleReason||void 0,children:[r(xt,{className:"h-2.5 w-2.5"}),"Unlikely usable"]})]}),u("div",{className:"text-xs text-foreground-subtle mt-0.5 font-mono break-all",children:[h.address,h.cidr&&h.cidr!==h.address?` (${h.cidr})`:""]})]})]},`${h.name}-${h.family}-${h.address}`)})})]},f)})})}const vp={"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 Z8(){const e=ke(),t=Le(),n=Hg(void 0,{refetchInterval:3e4}),o=qg(void 0),s=Qg({onSuccess:()=>{e.invalidateQueries({queryKey:[["localNetwork"]]})}}),a=Ug({onSuccess:S=>{p(S.addresses),e.invalidateQueries({queryKey:[["localNetwork"]]})}}),i=U(()=>n.data?.interfaces??[],[n.data]),l=typeof window<"u"?Number(window.location.port)||(window.location.protocol==="https:"?443:80):4e3,c=typeof window<"u"&&window.location.protocol==="https:"?"https":"http",d=Vg({port:l,scheme:c},{refetchInterval:3e4}),[f,p]=_([]),[m,h]=_(!1);Z(()=>{!m&&o.data&&(p(o.data.addresses),h(!0))},[o.data,m]);const g=o.data?.addresses??[],b=U(()=>{if(f.length!==g.length)return!0;const S=[...f].sort(),M=[...g].sort();return S.some((P,I)=>P!==M[I])},[f,g]),x=()=>{s.mutate({addresses:[...f]})},v=()=>{p(g)},w=()=>{p([])},y=()=>{n.refetch(),d.refetch(),o.refetch()},N=async()=>{try{const S=await t.raceConnectionEndpoints({perCandidateTimeoutMs:1500});console.info("[network-addresses] race result",S)}catch(S){console.warn("[network-addresses] race failed",S)}},k=d.data?.endpoints??[];return r(un,{icon:on,title:"Network Addresses",subtitle:"Pick the local addresses SDK clients should race for the fastest path to this hub. Empty selection (auto) lets every non-loopback / non-link-local interface participate.",actions:u("div",{className:"flex items-center gap-2",children:[u(Qe,{size:"sm",variant:"secondary",onClick:y,disabled:n.isLoading,children:[r(pt,{className:`h-3 w-3 ${n.isLoading?"animate-spin":""}`}),"Refresh"]}),r(Qe,{size:"sm",variant:"secondary",onClick:N,children:"Probe race"})]}),children:u("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[u(en,{children:[u("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[u("div",{children:[r("div",{className:"text-sm font-semibold",children:"Allowed addresses"}),r("div",{className:"text-xs text-foreground-subtle",children:f.length===0?"Auto — every non-loopback / non-link-local interface participates.":`${f.length} pinned`})]}),u("div",{className:"flex items-center gap-1",children:[u(Qe,{size:"sm",variant:"secondary",onClick:()=>a.mutate(void 0),disabled:a.isPending||s.isPending,title:"Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.",children:[r(eT,{className:"h-3 w-3"}),a.isPending?"Detecting…":"Best match"]}),u(Qe,{size:"sm",variant:"secondary",onClick:w,disabled:f.length===0||s.isPending,children:[r(my,{className:"h-3 w-3"}),"Clear"]}),b&&r(Qe,{size:"sm",variant:"secondary",onClick:v,disabled:s.isPending,children:"Discard"}),u(Qe,{size:"sm",variant:"primary",onClick:x,disabled:!b||s.isPending,children:[r(FL,{className:"h-3 w-3"}),s.isPending?"Saving…":"Save"]})]})]}),r("div",{className:"p-4",children:r(Y8,{mode:"multiple",interfaces:i,value:f,onChange:p,disabled:s.isPending,emptyMessage:n.isLoading?"Loading interfaces…":"No interfaces detected."})})]}),u(en,{children:[u("div",{className:"px-4 py-3 border-b border-border",children:[r("div",{className:"text-sm font-semibold",children:"Connection endpoints — priority order"}),r("div",{className:"text-xs text-foreground-subtle",children:"Live preview of the ranked candidate list the SDK would race against. Updates with each Save."})]}),r("div",{className:"p-4",children:k.length===0?r("div",{className:"text-xs text-foreground-subtle italic",children:d.isLoading?"Loading…":"No endpoints available."}):r("ul",{className:"space-y-1 text-xs",children:k.map(S=>u("li",{className:`flex items-center gap-2 flex-wrap ${S.plausible?"":"opacity-80"}`,children:[r("span",{className:"font-mono text-[10px] w-10 text-foreground-subtle",children:String(S.priority).padStart(4,"0")}),r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${vp[S.kind]??vp.loopback}`,children:S.kind}),S.interfaceKind!=="lan"&&S.interfaceKind!=="public"&&r("span",{className:"text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-medium uppercase",children:S.interfaceKind}),!S.plausible&&S.interfaceKind!=="loopback"&&u("span",{className:"inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300",title:S.plausibleReason||void 0,children:[r(xt,{className:"h-2.5 w-2.5"}),"Unlikely usable"]}),r("span",{className:`font-mono break-all ${S.plausible?"text-foreground":"text-foreground-subtle"}`,children:S.baseUrl}),u("span",{className:"text-foreground-subtle",children:["— ",S.label]})]},`${S.priority}-${S.baseUrl}`))})})]})]})})}const X8={mesh:"bg-violet-500/15 text-violet-700 dark:text-violet-300",public:"bg-blue-500/15 text-blue-700 dark:text-blue-300"};function J8(){const e=ke(),t=Kg(void 0,{refetchInterval:5e3}),n=t.data??[],[o,s]=_(null),[a,i]=_({}),[l,c]=_({}),d=()=>{e.invalidateQueries({queryKey:[["meshOrchestrator"]]}),s(null)},f=Gg({onSuccess:d,onError:()=>s(null)}),p=Wg({onSuccess:d,onError:()=>s(null)});return r(Ca,{title:"Mesh Networks",subtitle:"Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).",pageIcon:ba,itemIcon:on,capability:"mesh-network",installButtonLabel:"Add mesh",items:n,isLoading:t.isLoading,emptyTitle:"No mesh-network providers installed",emptyDescription:"Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.",itemIconColor:m=>m.joined?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle",renderStatusBadges:m=>u(xe,{children:[r("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${m.joined?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"bg-foreground-subtle/15 text-foreground-subtle"}`,children:m.joined?"Joined":"Not joined"}),m.joined&&u("span",{className:"text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle",children:[m.peerCount," peer",m.peerCount===1?"":"s"]})]}),renderActionButtons:m=>{const h=o===m.addonId;return m.joined?u(Qe,{size:"sm",variant:"secondary",disabled:h,onClick:()=>{s(m.addonId),p.mutate({addonId:m.addonId})},children:[h?r(Pe,{className:"h-3 w-3 animate-spin"}):r(cy,{className:"h-3 w-3"}),"Leave"]}):null},renderExpandedBody:m=>{const h=o===m.addonId,g=a[m.addonId]??"",b=l[m.addonId]??"",x=g.trim().length>=8;return u(xe,{children:[m.joined?u("div",{className:"p-4 space-y-3",children:[u("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[m.meshIp&&u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"text-foreground-subtle",children:"Mesh IP:"}),r("span",{className:"font-mono text-foreground",children:m.meshIp})]}),m.magicDnsHostname&&u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"text-foreground-subtle",children:"MagicDNS:"}),r("span",{className:"font-mono text-foreground break-all",children:m.magicDnsHostname})]})]}),m.endpoints.length>0&&u("div",{className:"flex flex-col gap-1",children:[r("div",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Endpoints"}),m.endpoints.map(v=>u("div",{className:"flex items-center gap-2 text-xs",children:[u("span",{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${X8[v.scope]??"bg-foreground-subtle/15 text-foreground-subtle"}`,children:[v.scope==="public"?r(gr,{className:"inline h-2.5 w-2.5 mr-0.5"}):null,v.label]}),u("a",{href:v.url,target:"_blank",rel:"noopener noreferrer",onClick:w=>w.stopPropagation(),className:"text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1",children:[r(Gc,{className:"h-3 w-3 shrink-0"}),v.url]})]},v.id))]}),m.error&&r("div",{className:"text-xs text-danger",children:m.error})]}):u("div",{className:"p-4 space-y-3",children:[r("div",{className:"text-xs text-foreground-subtle",children:"Provide an auth key to join this hub into the mesh. The key is forwarded to the daemon and never persisted in clear."}),u("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[r("input",{type:"password",autoComplete:"off",placeholder:"Auth key (tskey-auth-…)",value:g,onChange:v=>i(w=>({...w,[m.addonId]:v.target.value})),className:"rounded-md border border-border bg-surface px-2 py-1 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"}),r("input",{type:"text",placeholder:"Hostname (optional)",value:b,onChange:v=>c(w=>({...w,[m.addonId]:v.target.value})),className:"rounded-md border border-border bg-surface px-2 py-1 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),r("div",{className:"flex justify-end",children:u(Qe,{size:"sm",variant:"primary",disabled:h||!x,onClick:()=>{s(m.addonId),f.mutate({addonId:m.addonId,authKey:g.trim(),hostname:b.trim()?b.trim():void 0})},children:[h?r(Pe,{className:"h-3 w-3 animate-spin"}):r(iL,{className:"h-3 w-3"}),"Join"]})}),m.error&&r("div",{className:"text-xs text-danger",children:m.error})]}),r("div",{className:"p-4 border-t border-border",children:r(nd,{addonId:m.addonId,maxHeight:"max-h-72"})})]})}})}function e9(){return r("div",{className:"flex flex-col",children:r("div",{className:"px-6 pt-6",children:r(td,{tabs:[{id:"addresses",label:"Network Addresses",icon:sn,content:r(Z8,{})},{id:"remote-access",label:"Remote Access",icon:gr,content:r(Q8,{})},{id:"mesh",label:"Mesh Networks",icon:ba,content:r(J8,{})},{id:"turn",label:"TURN Servers",icon:on,content:r(U8,{})}]})})})}function t9(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 n9({location:e,onEdit:t,onDelete:n,onSetDefault:o}){const s=t9(e.config);return u("div",{className:"flex items-center gap-3 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5",children:[u("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[r("div",{className:"w-[88px] shrink-0",children:e.isDefault?u("span",{className:"inline-flex items-center gap-0.5 rounded bg-primary/10 border border-primary/20 px-1.5 py-0.5 text-[10px] font-semibold text-primary uppercase tracking-wide",title:"Default location for this type",children:[r(si,{className:"h-2.5 w-2.5 fill-primary"}),"Default"]}):u("button",{onClick:()=>o(e),className:"inline-flex items-center gap-0.5 rounded border border-border px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 hover:border-primary/30 uppercase tracking-wide",title:"Promote to default for this type",children:[r(si,{className:"h-2.5 w-2.5"}),"Set default"]})}),r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono",children:e.providerId}),e.isSystem&&r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5",title:"System-managed location — cannot be deleted; edit config to relocate",children:"system"}),u("div",{className:"min-w-0",children:[r("div",{className:"text-xs font-medium text-foreground truncate",children:e.displayName}),s&&r("div",{className:"text-[10px] text-foreground-subtle truncate font-mono",children:s})]})]}),u("div",{className:"flex items-center gap-1 shrink-0",children:[!e.isDefault&&u("button",{onClick:()=>o(e),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10",title:"Set as default for this type",children:[r(si,{className:"h-3 w-3"}),"Set default"]}),u("button",{onClick:()=>t(e),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10",children:[r(Ao,{className:"h-3 w-3"}),"Edit"]}),!e.isSystem&&us[e.type]!=="singleton"&&r("button",{onClick:()=>n(e),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10",title:"Delete location",children:r(Ge,{className:"h-3 w-3"})})]})]})}function r9({type:e,displayName:t,description:n,locations:o,onAdd:s,onEdit:a,onDelete:i,onSetDefault:l}){const c=U(()=>{const d=[...o];return d.sort((f,p)=>f.isDefault!==p.isDefault?f.isDefault?-1:1:f.displayName.localeCompare(p.displayName)),d},[o]);return u("div",{className:"rounded-lg border border-border bg-surface",children:[u("div",{className:"flex items-start justify-between border-b border-border px-3 py-2",children:[u("div",{className:"space-y-0.5",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-sm font-semibold text-foreground capitalize",children:t}),r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono",children:e})]}),n&&r("p",{className:"text-[11px] text-foreground-subtle",children:n}),us[e]==="singleton"&&r("p",{className:"text-[10px] text-foreground-subtle italic",children:"Singleton — one location per type. Edit the existing entry; it can't be split."})]}),us[e]==="multi"&&u("button",{onClick:()=>s(e),className:"inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90",children:[r(ut,{className:"h-3 w-3"}),"Add"]})]}),c.length===0?r("div",{className:"px-3 py-4 text-center text-[11px] text-foreground-subtle italic",children:us[e]==="multi"?'No location registered. Click "Add" to register one.':"No location registered yet — should be auto-seeded at next boot."}):r("div",{children:c.map(d=>r(n9,{location:d,onEdit:a,onDelete:i,onSetDefault:l},d.id))})]})}function o9(e){const t=e.trim().toLowerCase();return t.length===0?"":t.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function wp(e,t){const n=o9(t),o=n.length>0?n:"default";return`${e}:${o}`}function s0({initialType:e,onClose:t,onCreated:n}){const o=ke(),s=Le().trpcClient,[a,i]=_("picker"),[l,c]=_(e),[d,f]=_(null),[p,m]=_({}),[h,g]=_(""),[b,x]=_(null),[v,w]=_(!1),[y,N]=_(null),[k,S]=_(!1),M=kc(),P=U(()=>{const L=M.data;return Array.isArray(L)?L.filter(T=>T.supportedLocationTypes.includes(l)):[]},[M.data,l]),I=M.isLoading,z=ca({onSuccess:()=>{o.invalidateQueries({queryKey:[["storage","listLocations"]]}),n()}}),$=U(()=>b!==null&&b.length>0?b:wp(l,h),[l,h,b]),O=async()=>{if(d){S(!0),N(null);try{const T=await(B=>s.storage.testConfig.query(B))({providerId:d.providerId,config:p});N(T)}catch(L){N({ok:!1,error:L instanceof Error?L.message:String(L)})}finally{S(!1)}}},R=()=>{d&&z.mutate({id:$,type:l,displayName:h.trim(),providerId:d.providerId,config:p,isDefault:v})},A={picker:"Add Location — Pick provider",config:`Add Location — ${d?.displayName??""}`,naming:"Add Location — Name & defaults"};return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:t,children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:L=>L.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:A[a]}),u("p",{className:"text-xs text-foreground-subtle",children:["Type: ",r("span",{className:"font-mono",children:l})]})]}),r("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-4 w-4"})})]}),a==="picker"&&u("div",{className:"p-4 space-y-2",children:[I&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading providers…"}),!I&&P.length===0&&u("div",{className:"rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle",children:['No storage-provider supports type "',l,'". Install a compatible addon (e.g. ',r("code",{className:"font-mono",children:"remote-storage"}),") to enable it."]}),P.map(L=>u("button",{onClick:()=>{f(L),i("config")},className:"flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors",children:[u("div",{className:"flex-1 min-w-0",children:[r("p",{className:"text-xs font-semibold text-foreground",children:L.displayName}),r("p",{className:"text-[10px] text-foreground-subtle font-mono mt-0.5 truncate",children:L.providerId})]}),r(It,{className:"h-4 w-4 text-foreground-subtle flex-shrink-0"})]},L.providerId))]}),a==="config"&&d&&u("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[r(wn,{schema:d.configSchema,values:p,onChange:m}),y&&r("div",{className:`rounded border px-3 py-2 text-[11px] ${y.ok?"border-success/30 bg-success/5 text-success":"border-danger/30 bg-danger/5 text-danger"}`,children:y.ok?"Connection OK.":`Test failed: ${y.error??"unknown error"}`}),u("div",{className:"flex items-center justify-between pt-1",children:[r("button",{onClick:()=>i("picker"),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Back"}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>{O()},disabled:k,className:"rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50",children:k?"Testing…":"Test connection"}),r("button",{onClick:()=>i("naming"),className:"rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:"Next"})]})]})]}),a==="naming"&&d&&u("div",{className:"p-4 space-y-3",children:[u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Display name"}),r("input",{type:"text",value:h,onChange:L=>g(L.target.value),placeholder:`${l} on ${d.displayName}`,className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1",children:[u("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:["Id ",r("span",{className:"lowercase tracking-normal text-foreground-subtle",children:"— auto-derived; override if needed"})]}),r("input",{type:"text",value:$,onChange:L=>x(L.target.value),placeholder:wp(l,h),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-1 focus:ring-primary"}),u("p",{className:"text-[10px] text-foreground-subtle",children:["Format: ",r("code",{className:"font-mono",children:"<type>:<slug>"}),". Lowercase letters, digits, and hyphens only."]})]}),u("label",{className:"flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5",children:[r("input",{type:"checkbox",checked:v,onChange:L=>w(L.target.checked),className:"accent-primary mt-0.5"}),u("div",{className:"space-y-0.5",children:[u("div",{className:"text-xs font-medium text-foreground",children:['Mark as default for type "',l,'"']}),u("div",{className:"text-[10px] text-foreground-subtle",children:["Setting this as default will demote the current default for this type. References like"," ",u("code",{className:"font-mono",children:['"',l,'"']})," resolve to whichever location is the default."]})]})]}),z.isError&&r("div",{className:"rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]",children:z.error instanceof Error?z.error.message:String(z.error)}),u("div",{className:"flex items-center justify-between pt-1",children:[r("button",{onClick:()=>i("config"),className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Back"}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>{c(e),f(null),m({}),g(""),x(null),w(!1),N(null),i("picker")},className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Reset"}),u("button",{onClick:R,disabled:z.isPending||h.trim().length===0,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[z.isPending?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):null,z.isPending?"Saving…":"Save"]})]})]})]})]})})}function s9({location:e,onClose:t,onSaved:n}){const o=ke(),s=Le().trpcClient,[a,i]=_({...e.config}),[l,c]=_(e.displayName),[d,f]=_(null),[p,m]=_(!1),h=kc(),g=U(()=>{const w=h.data;return Array.isArray(w)?w.find(N=>N.providerId===e.providerId)??null:null},[h.data,e.providerId]),b=ca({onSuccess:()=>{o.invalidateQueries({queryKey:[["storage","listLocations"]]}),n()}}),x=async()=>{m(!0),f(null);try{const y=await(N=>s.storage.testConfig.query(N))({providerId:e.providerId,config:a});f(y)}catch(w){f({ok:!1,error:w instanceof Error?w.message:String(w)})}finally{m(!1)}},v=()=>{b.mutate({id:e.id,type:e.type,providerId:e.providerId,isDefault:e.isDefault,displayName:l.trim(),config:a})};return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:t,children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:w=>w.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[u("h2",{className:"text-sm font-semibold text-foreground",children:["Edit ",e.displayName]}),u("p",{className:"text-xs text-foreground-subtle",children:[r("span",{className:"font-mono",children:e.id})," · ",g?.displayName??e.providerId]})]}),r("button",{onClick:t,className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-4 w-4"})})]}),u("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Display name"}),r("input",{type:"text",value:l,onChange:w=>c(w.target.value),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary"})]}),g&&r(wn,{schema:g.configSchema,values:a,onChange:i}),!g&&!h.isLoading&&u("div",{className:"rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300",children:["Provider ",r("code",{className:"font-mono",children:e.providerId})," is no longer registered. Field schema unavailable; raw config is preserved on save."]}),d&&r("div",{className:`rounded border px-3 py-2 text-[11px] ${d.ok?"border-success/30 bg-success/5 text-success":"border-danger/30 bg-danger/5 text-danger"}`,children:d.ok?"Connection OK.":`Test failed: ${d.error??"unknown error"}`}),b.isError&&r("div",{className:"rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]",children:b.error instanceof Error?b.error.message:String(b.error)})]}),u("div",{className:"flex items-center justify-between gap-2 border-t border-border px-4 py-3",children:[r("button",{onClick:t,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:()=>{x()},disabled:p||!g,className:"rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50",children:p?"Testing…":"Test connection"}),u("button",{onClick:v,disabled:b.isPending||l.trim().length===0,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[b.isPending?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):null,b.isPending?"Saving…":"Save"]})]})]})]})})}const a9={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"},i9={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 l9(){const e=ke(),t=nt(),{data:n,isLoading:o,isError:s}=Kb({}),[a,i]=_(null),[l,c]=_(null),d=Gb({onSuccess:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]})}}),f=ca({onSuccess:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]})}}),p=g=>{g.isDefault||f.mutate({id:g.id,type:g.type,providerId:g.providerId,displayName:g.displayName,config:g.config,isDefault:!0})},m=async g=>{if(g.isDefault){await t({title:"Cannot delete default location",message:`"${g.displayName}" is the default for type "${g.type}". Mark another location as default first, then delete this one.`,confirmLabel:"OK",variant:"warning"});return}await t({title:`Delete location "${g.displayName}"?`,message:"This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.",confirmLabel:"Delete",variant:"danger"})&&d.mutate({id:g.id})},h=U(()=>{const g=new Map;for(const b of Ed)g.set(b,[]);for(const b of n??[]){const x=g.get(b.type);x?x.push(b):g.set(b.type,[b])}return g},[n]);return u(un,{icon:lo,title:"Storage Locations",subtitle:u(xe,{children:["Register where each kind of data lives. Each type can have multiple locations — one is the default, the rest are addressable by their fully-qualified id (",r("code",{className:"font-mono",children:"<type>:<slug>"}),")."]}),children:[o&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading locations…"}),s&&r("div",{className:"text-xs text-danger",children:"Failed to load storage locations."}),!o&&!s&&r("div",{className:"space-y-3",children:Ed.map(g=>r(r9,{type:g,displayName:a9[g],description:i9[g],locations:h.get(g)??[],onAdd:b=>i(b),onEdit:b=>c(b),onDelete:b=>{m(b)},onSetDefault:b=>p(b)},g))}),a!==null&&r(s0,{initialType:a,onClose:()=>i(null),onCreated:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),i(null)}}),l!==null&&r(s9,{location:l,onClose:()=>c(null),onSaved:()=>{e.invalidateQueries({queryKey:[["storage","listLocations"]]}),c(null)}})]})}const c9=[["backup","listDestinations"]],d9=["backup","listArchives"];function u9({destinationId:e,restoreSupported:t,onOpenRestoreWizard:n}){const o=ke(),s=nt(),{data:a,isLoading:i,isError:l}=mc({destinationId:e}),c=a??[],d=pg({onSuccess:()=>{o.invalidateQueries({queryKey:[[...d9]]}),o.invalidateQueries({queryKey:c9})}}),f=q(async b=>{await s({title:"Delete this archive?",message:`Permanently deletes "${b.label??b.id}" and frees ${kt(b.sizeBytes)}.`,confirmLabel:"Delete",variant:"danger"})&&d.mutate({destinationId:e,backupId:b.id})},[s,e,d]),[p,m]=_(null),h=q(async b=>{m(b.id);try{const x=localStorage.getItem("camstack_admin_token"),v={};x&&(v.Authorization=`Bearer ${x}`);const w=await fetch(p9(e,b.id),{headers:v});if(!w.ok)throw new Error(`download failed: ${w.status} ${w.statusText}`);const y=await w.blob(),N=URL.createObjectURL(y),k=document.createElement("a");k.href=N,k.download=`${b.label??b.id}.tar.gz`,document.body.appendChild(k),k.click(),k.remove(),URL.revokeObjectURL(N)}finally{m(null)}},[e]),g=U(()=>[...c].sort((b,x)=>x.createdAt-b.createdAt),[c]);return i?r("div",{className:"text-xs text-foreground-subtle animate-pulse py-2",children:"Loading archives…"}):l?r("div",{className:"text-xs text-danger py-2",children:"Failed to read manifest for this destination"}):g.length===0?r("div",{className:"text-xs text-foreground-subtle italic py-2",children:"No archives at this destination yet."}):r("div",{className:"rounded border border-border bg-surface overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[640px]",children:[r("thead",{children:u("tr",{className:"text-foreground-subtle bg-background/30",children:[r("th",{className:"text-left px-3 py-1.5 font-medium",children:"When"}),r("th",{className:"text-left px-3 py-1.5 font-medium",children:"Label"}),r("th",{className:"text-left px-3 py-1.5 font-medium",children:"Includes"}),r("th",{className:"text-right px-3 py-1.5 font-medium",children:"Size"}),r("th",{className:"text-right px-3 py-1.5 font-medium w-52",children:"Actions"})]})}),r("tbody",{children:g.map(b=>u("tr",{className:"border-t border-border hover:bg-primary/5",children:[r("td",{className:"px-3 py-1.5 text-foreground tabular-nums",children:f9(b.createdAt)}),r("td",{className:"px-3 py-1.5 text-foreground",children:b.label??r("span",{className:"text-foreground-subtle italic",children:"—"})}),r("td",{className:"px-3 py-1.5 text-foreground-subtle",children:b.locations.join(", ")}),r("td",{className:"px-3 py-1.5 text-foreground text-right tabular-nums",children:kt(b.sizeBytes)}),r("td",{className:"px-3 py-1.5",children:u("div",{className:"flex items-center justify-end gap-1",children:[u("button",{onClick:()=>{h(b)},disabled:p===b.id,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 disabled:opacity-50",title:"Download archive",children:[p===b.id?r(Pe,{className:"h-3 w-3 animate-spin"}):r(vn,{className:"h-3 w-3"}),"Download"]}),t&&n&&u("button",{onClick:()=>n({destinationId:e,archiveId:b.id}),className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-primary hover:bg-primary/10",title:"Restore from this archive",children:[r(bt,{className:"h-3 w-3"}),"Restore"]}),r("button",{onClick:()=>{f(b)},disabled:d.isPending,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50",title:"Delete archive",children:d.isPending?r(Pe,{className:"h-3 w-3 animate-spin"}):r(Ge,{className:"h-3 w-3"})})]})})]},b.id))})]})})}function p9(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function f9(e){return new Date(e).toLocaleString(void 0,{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}const a0=[{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 m9(e){const t=e.trim();for(const n of a0)if(n.cron===t)return n.id;return"custom"}function h9({value:e,onChange:t,previewCount:n=5,disabled:o=!1}){const s=m9(e),[a,i]=_(s==="custom");Z(()=>{s!=="custom"&&i(!1)},[s]);const l=x9(e,250),c=mg({cron:l,count:n},{enabled:l.trim().length>0}),d=c.data??null,f=m=>{i(!1),t(m.cron)},p=a||s==="custom";return u("div",{className:"space-y-3",children:[u("div",{className:"space-y-1",children:[r("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Schedule preset"}),u("div",{className:"flex flex-wrap gap-1.5",children:[a0.map(m=>{const h=!a&&s===m.id;return r("button",{type:"button",onClick:()=>f(m),disabled:o,className:"rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 "+(h?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground"),title:m.description??m.label,children:m.label},m.id)}),r("button",{type:"button",onClick:()=>{i(!0),e.trim().length===0&&t("0 3 * * *")},disabled:o,className:"rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 "+(p?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground"),children:"Custom…"})]})]}),p&&u("div",{className:"space-y-1",children:[r("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Cron expression (5-field POSIX)"}),r("input",{type:"text",value:e,onChange:m=>t(m.target.value),disabled:o,placeholder:"0 3 * * *",spellCheck:!1,className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"}),u("p",{className:"text-[10px] text-foreground-subtle",children:["Format: ",r("span",{className:"font-mono",children:"minute hour day-of-month month day-of-week"})," · all times server-local"]})]}),r(g9,{cron:l,preview:d,loading:c.isFetching})]})}function g9({cron:e,preview:t,loading:n}){return n&&t===null?u("div",{className:"flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle",children:[r(Pe,{className:"h-3 w-3 animate-spin"}),"Validating…"]}):t===null?null:t.ok?t.nextRuns.length===0?r("div",{className:"rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle",children:"No future runs match this expression."}):u("div",{className:"space-y-1",children:[r("div",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle",children:"Next runs"}),r("ul",{className:"rounded border border-border bg-background/40 divide-y divide-border",children:t.nextRuns.map((o,s)=>u("li",{className:"flex items-center justify-between px-3 py-1.5 text-[11px]",children:[r("span",{className:"text-foreground tabular-nums",children:new Date(o).toLocaleString()}),r("span",{className:"text-foreground-subtle text-[10px] tabular-nums",children:b9(o)})]},`${o}-${s}`))})]}):r("div",{className:"rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger",children:t.error??"Invalid cron expression"})}function b9(e){const t=e-Date.now();if(t<=0)return"now";const n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;const o=Math.floor(n/60);if(o<60)return`in ${o}m`;const s=Math.floor(o/60);return s<24?`in ${s}h`:`in ${Math.floor(s/24)}d`}function x9(e,t){const[n,o]=_(e),s=U(()=>e,[e]);return Z(()=>{const a=setTimeout(()=>o(s),t);return()=>clearTimeout(a)},[s,t]),n}const y9=[["backup","listDestinations"]];function v9({onCreateAt:e,onOpenRestoreWizard:t}){const{data:n,isLoading:o,isError:s}=fc(),a=n??[],[i,l]=_(null),c=f=>{l(p=>p===f?null:f)},d=C9();return o?r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Loading destinations…"}):s?r("div",{className:"text-xs text-danger",children:"Failed to load destinations"}):a.length===0?r("div",{className:"rounded-lg border border-border bg-surface px-4 py-8 text-center",children:r("p",{className:"text-xs text-foreground-subtle",children:"No `backups`-typed storage locations registered. Add one in Settings → Storage to begin."})}):r("div",{className:"rounded-lg border border-border bg-surface overflow-x-auto",children:u("table",{className:"w-full text-xs min-w-[720px]",children:[r("thead",{children:u("tr",{className:"text-foreground-subtle border-b border-border bg-background/40",children:[r("th",{className:"text-left px-3 py-2 font-medium w-6"}),r("th",{className:"text-left px-3 py-2 font-medium",children:"Destination"}),r("th",{className:"text-left px-3 py-2 font-medium w-20",children:"Enabled"}),r("th",{className:"text-left px-3 py-2 font-medium w-28",children:"Retention"}),r("th",{className:"text-left px-3 py-2 font-medium w-56",children:"Schedule"}),r("th",{className:"text-left px-3 py-2 font-medium w-44",children:"Last success"}),r("th",{className:"text-right px-3 py-2 font-medium w-44",children:"Actions"})]})}),r("tbody",{children:a.map(f=>{const p=d.get(f.id);return r(w9,{row:f,isOpen:i===f.id,onToggle:()=>c(f.id),onCreateAt:e,liveLastSuccessAt:p?.at,liveLastSuccessSizeBytes:p?.sizeBytes,...t?{onOpenRestoreWizard:t}:{}},f.id)})})]})})}function w9({row:e,isOpen:t,onToggle:n,onCreateAt:o,onOpenRestoreWizard:s,liveLastSuccessAt:a,liveLastSuccessSizeBytes:i}){const l=ke(),c=fg({onSuccess:()=>{l.invalidateQueries({queryKey:y9})}}),[d,f]=_(String(e.retentionCount));Z(()=>{f(String(e.retentionCount))},[e.retentionCount]);const[p,m]=_(!1),h=q(x=>{c.mutate({locationId:e.id,enabled:x,retentionCount:e.retentionCount,...e.label!==void 0?{label:e.label}:{},...e.cron!==void 0?{cron:e.cron}:{}})},[c,e.id,e.retentionCount,e.label,e.cron]),g=q(()=>{const x=Number.parseInt(d,10);if(Number.isNaN(x)||x<1){f(String(e.retentionCount));return}x!==e.retentionCount&&c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:x,...e.label!==void 0?{label:e.label}:{},...e.cron!==void 0?{cron:e.cron}:{}})},[c,d,e.id,e.enabled,e.retentionCount,e.label,e.cron]),b=q(x=>{c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:e.retentionCount,...e.label!==void 0?{label:e.label}:{},cron:x},{onSuccess:()=>{m(!1)}})},[c,e.id,e.enabled,e.retentionCount,e.label]);return u(xe,{children:[u("tr",{className:"border-t border-border first:border-t-0 hover:bg-primary/5",children:[r("td",{className:"px-2 py-2",children:r("button",{onClick:n,className:"inline-flex items-center justify-center rounded p-1 text-foreground-subtle hover:bg-primary/10 hover:text-foreground",title:t?"Hide archives":"Show archives",children:t?r(wt,{className:"h-3.5 w-3.5"}):r(It,{className:"h-3.5 w-3.5"})})}),r("td",{className:"px-3 py-2",children:u("button",{onClick:n,className:"text-left hover:underline focus:outline-none",title:"View archives",children:[r("div",{className:"text-foreground font-medium",children:e.displayName}),u("div",{className:"flex items-center gap-1.5 mt-0.5",children:[r("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5",children:e.kind}),r("span",{className:"text-[10px] text-foreground-subtle font-mono",children:e.id})]})]})}),r("td",{className:"px-3 py-2",children:r("label",{className:"inline-flex items-center cursor-pointer",children:r("input",{type:"checkbox",className:"accent-primary",checked:e.enabled,disabled:c.isPending,onChange:x=>h(x.target.checked)})})}),r("td",{className:"px-3 py-2",children:r("input",{type:"number",min:1,max:1e3,value:d,disabled:c.isPending,onChange:x=>f(x.target.value),onBlur:g,onKeyDown:x=>{x.key==="Enter"&&x.target.blur(),x.key==="Escape"&&f(String(e.retentionCount))},className:"w-16 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary"})}),r("td",{className:"px-3 py-2",children:r(N9,{cron:e.cron,nextRunAt:e.nextRunAt,onEdit:()=>m(!0),disabled:c.isPending})}),r("td",{className:"px-3 py-2 text-foreground-subtle",children:(()=>{const x=M9(a,e.lastSuccessAt),v=x===a?i:e.lastSuccessSizeBytes;return x!==void 0?r(I9,{at:x,sizeBytes:v}):r("span",{className:"italic",children:"Never"})})()}),r("td",{className:"px-3 py-2",children:r("div",{className:"flex items-center justify-end gap-1.5",children:e.triggerSupported&&u("button",{onClick:()=>o(e),className:"inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90",children:[r(ut,{className:"h-3 w-3"}),"Create here"]})})})]}),t&&r("tr",{className:"border-t border-border bg-background/30",children:r("td",{colSpan:7,className:"px-4 py-3",children:r(u9,{destinationId:e.id,restoreSupported:e.restoreSupported,...s?{onOpenRestoreWizard:s}:{}})})}),p&&r(S9,{destinationName:e.displayName,currentCron:e.cron??"",onSave:b,onClose:()=>m(!1),saving:c.isPending,saveError:c.error instanceof Error?c.error.message:null})]})}function N9({cron:e,nextRunAt:t,onEdit:n,disabled:o}){const s=typeof e=="string"&&e.trim().length>0;return u("button",{type:"button",onClick:n,disabled:o,className:"group flex flex-col items-start gap-0.5 text-left rounded px-1.5 py-1 -mx-1.5 hover:bg-primary/5 disabled:opacity-50",title:"Edit schedule",children:[u("div",{className:"flex items-center gap-1.5",children:[r(aD,{className:"h-3 w-3 text-foreground-subtle group-hover:text-foreground"}),r("span",{className:s?"font-mono text-foreground":"italic text-foreground-subtle",children:s?e:"Manual"})]}),s&&t!==void 0&&u("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:["next ",k9(t)]})]})}function k9(e){const t=e-Date.now();if(t<=0)return"imminent";const n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;const o=Math.floor(n/60);if(o<60)return`in ${o}m`;const s=Math.floor(o/60);return s<24?`in ${s}h`:`in ${Math.floor(s/24)}d`}function S9({destinationName:e,currentCron:t,onSave:n,onClose:o,saving:s,saveError:a}){const[i,l]=_(t);return r("tr",{children:r("td",{colSpan:7,className:"p-0",children:r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:o,children:u("div",{className:"w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl",onClick:c=>c.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:"Schedule"}),u("p",{className:"text-xs text-foreground-subtle",children:["→ ",e]})]}),r("button",{onClick:o,className:"text-foreground-subtle hover:text-foreground",title:"Close",children:r(Ve,{className:"h-4 w-4"})})]}),u("div",{className:"p-4",children:[r(h9,{value:i,onChange:l,disabled:s}),a!==null&&r("div",{className:"mt-3 rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger",children:a})]}),u("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:[r("button",{onClick:o,disabled:s,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground disabled:opacity-50",children:"Cancel"}),r("button",{onClick:()=>n(i.trim()),disabled:s||i.trim()===t.trim(),className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:s?"Saving…":"Save"})]})]})})})})}function C9(){const{map:e}=tc(Ne.BackupCompleted,t=>t.destinationId);return U(()=>{const t=new Map;for(const[n,o]of e)t.set(n,{at:Date.now(),sizeBytes:o.sizeMB*1024*1024});return t},[e])}function M9(e,t){return e===void 0?t:t===void 0||e>t?e:t}function I9({at:e,sizeBytes:t}){const n=A9(e),o=U(()=>new Date(e).toLocaleString(),[e]);return u("span",{title:o,className:"text-foreground tabular-nums",children:[n,t!==void 0&&u("span",{className:"ml-1 text-foreground-subtle",children:["· ",kt(t)]})]})}function A9(e){const[,t]=_(0);return Z(()=>{const n=setInterval(()=>t(o=>o+1),3e4);return()=>clearInterval(n)},[]),P9(e)}function P9(e){const t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const o=Math.floor(n/60);if(o<60)return`${o}m ago`;const s=Math.floor(o/60);if(s<24)return`${s}h ago`;const a=Math.floor(s/24);if(a<30)return`${a}d ago`;const i=Math.floor(a/30);return i<12?`${i}mo ago`:`${Math.floor(a/365)}y ago`}const E9=[["backup","list"]];function $9({initialDestinationId:e,initialArchiveId:t,onClose:n,onScheduled:o}){const s=ke(),[a,i]=_(e&&t?2:1),[l,c]=_(e),[d,f]=_(t),[p,m]=_(new Set),{data:h}=fc(),g=h??[],{data:b,isLoading:x}=mc({destinationId:l??""},{enabled:!!l}),v=b??[];Z(()=>{if(l!==void 0)return;const z=g.filter($=>$.restoreSupported);z.length===1&&c(z[0].id)},[l,g]);const{data:w}=dg({destinationId:l??"",backupId:d??""},{enabled:!!l&&!!d}),y=U(()=>w?.locations??[],[w]);Z(()=>{y.length!==0&&m(z=>z.size===0?new Set(y):z)},[y]);const N=ug({onSuccess:()=>{s.invalidateQueries({queryKey:E9}),o(),n()}}),k=z=>{m($=>{const O=new Set($);return O.has(z)?O.delete(z):O.add(z),O})},S=!!l&&!!d,M=p.size>0,P=S&&M&&!N.isPending,I=()=>{!l||!d||N.mutate({destinationId:l,backupId:d,locations:[...p]})};return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:n,children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:z=>z.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:"Restore Backup"}),u("p",{className:"text-xs text-foreground-subtle",children:["Step ",a," of 3 — ",a===1?"pick source":a===2?"pick locations":"confirm"]})]}),r("button",{onClick:n,className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-4 w-4"})})]}),a===1&&r(_9,{destinations:g,destinationId:l,onPickDestination:z=>{c(z),f(void 0),m(new Set)},archives:v,archivesLoading:x,archiveId:d,onPickArchive:f}),a===2&&r(D9,{locations:y,picked:p,onToggle:k}),a===3&&r(L9,{destinationName:g.find(z=>z.id===l)?.displayName??l??"",archive:v.find(z=>z.id===d),picked:[...p]}),u("div",{className:"flex justify-between gap-2 border-t border-border px-4 py-3",children:[r("div",{children:a>1&&u("button",{onClick:()=>i(z=>z===3?2:1),className:"inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:[r(Yx,{className:"h-3 w-3"}),"Back"]})}),u("div",{className:"flex items-center gap-2",children:[r("button",{onClick:n,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),a<3?u("button",{disabled:a===1&&!S||a===2&&!M,onClick:()=>i(z=>z===1?2:3),className:"inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:["Next",r(Zx,{className:"h-3 w-3"})]}):u("button",{onClick:I,disabled:!P,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[N.isPending?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):r(bt,{className:"h-3.5 w-3.5"}),"Schedule Restore"]})]})]})]})})}function _9({destinations:e,destinationId:t,onPickDestination:n,archives:o,archivesLoading:s,archiveId:a,onPickArchive:i}){const l=e.filter(c=>c.restoreSupported);return u("div",{className:"p-4 space-y-3",children:[u("div",{className:"space-y-1.5",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Destination"}),u("select",{value:t??"",onChange:c=>n(c.target.value),className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary",children:[r("option",{value:"",disabled:!0,children:"Select destination…"}),l.map(c=>u("option",{value:c.id,children:[c.displayName," (",c.kind,")"]},c.id))]})]}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Archive"}),!t&&r("div",{className:"text-xs text-foreground-subtle italic",children:"Pick a destination first."}),t&&s&&r("div",{className:"text-xs text-foreground-subtle animate-pulse",children:"Reading archives…"}),t&&!s&&o.length===0&&r("div",{className:"text-xs text-foreground-subtle italic",children:"No archives available at this destination."}),t&&o.length>0&&r("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:o.map(c=>{const d=a===c.id;return u("label",{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${d?"bg-primary/10":"hover:bg-primary/5"}`,children:[u("div",{className:"flex items-center gap-2",children:[r("input",{type:"radio",name:"archive",checked:d,onChange:()=>i(c.id),className:"accent-primary"}),u("div",{children:[r("div",{className:"font-medium text-foreground",children:c.label??c.id}),r("div",{className:"text-[10px] text-foreground-subtle",children:new Date(c.createdAt).toLocaleString()})]})]}),r("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:kt(c.sizeBytes)})]},c.id)})})]})]})}function D9({locations:e,picked:t,onToggle:n}){return e.length===0?r("div",{className:"p-4",children:r("div",{className:"text-xs text-foreground-subtle",children:"Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball."})}):u("div",{className:"p-4 space-y-3",children:[r("div",{className:"rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300",children:"Selected entries will overwrite live data on the next server restart. Unchecked entries stay current."}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Apply"}),r("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:e.map(o=>u("label",{className:"flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer",children:[r("input",{type:"checkbox",checked:t.has(o),onChange:()=>n(o),className:"accent-primary"}),r("span",{className:"font-mono text-foreground",children:o}),r("span",{className:"ml-auto text-[10px] text-foreground-subtle",children:R9(o)})]},o))})]})]})}function L9({destinationName:e,archive:t,picked:n}){return u("div",{className:"p-4 space-y-3 text-xs",children:[r("div",{className:"rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-300",children:"Restore is applied at next server boot. Active connections will drop when you restart."}),u("dl",{className:"space-y-1.5",children:[r(ts,{term:"Destination",value:e}),r(ts,{term:"Archive",value:t?.label??t?.id??"—"}),t&&r(ts,{term:"Created",value:`${new Date(t.createdAt).toLocaleString()} · ${kt(t.sizeBytes)}`}),r(ts,{term:"Locations",value:n.length>0?n.join(", "):"— (full archive)"})]})]})}function ts({term:e,value:t}){return u("div",{className:"flex justify-between gap-3",children:[r("dt",{className:"text-foreground-subtle",children:e}),r("dd",{className:"text-foreground font-mono text-right truncate",children:t})]})}const T9={db:"Database",addons:"Addon configs","addons-data":"Addon data",tls:"TLS certificates",cache:"Cache",data:"Top-level data"};function R9(e){return T9[e]??""}const O9=[["backup","list"]],z9=[["backup","listLocations"]];function B9(){const e=ke(),t=nt(),{data:n}=cg(),o=lg({onSuccess:()=>{e.invalidateQueries({queryKey:O9}),e.invalidateQueries({queryKey:[["backup","listDestinations"]]}),e.invalidateQueries({queryKey:[["backup","listArchives"]]})}}),s=Uh(),[a,i]=_(null),[l,c]=_(null),[d,f]=_(!1),[p,m]=_(!1),[h,g]=_(!1),b=async()=>{await t({title:"Restart server now?",message:"Active connections will drop and the apply-backup hook will run before boot.",confirmLabel:"Restart",variant:"warning"})&&s.mutate({confirm:!0})};return u(un,{icon:Uc,title:"Backup & Restore",subtitle:"Schedule + per-destination retention live in the orchestrator. Each `backups` storage location is a destination.",actions:u(xe,{children:[u("button",{onClick:()=>g(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:[r(ut,{className:"h-3.5 w-3.5"}),"Add destination"]}),u("button",{onClick:()=>f(!0),className:"inline-flex items-center gap-1.5 rounded-lg bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30",children:[r(bt,{className:"h-3.5 w-3.5"}),"Restore…"]})]}),children:[p&&r("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs text-amber-700 dark:text-amber-300",children:u("div",{className:"flex items-center justify-between gap-3",children:[u("div",{className:"flex items-center gap-2",children:[r(bt,{className:"h-3.5 w-3.5"}),r("span",{children:"Restore scheduled. Restart the server to apply."})]}),u("button",{onClick:()=>{b()},disabled:s.isPending,className:"inline-flex items-center gap-1.5 rounded bg-amber-500/20 px-2 py-1 font-medium text-amber-800 dark:text-amber-200 hover:bg-amber-500/30 disabled:opacity-50",children:[s.isPending?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):r(bt,{className:"h-3.5 w-3.5"}),"Restart Now"]})]})}),r(v9,{onCreateAt:x=>i(x),onOpenRestoreWizard:x=>c(x)}),a&&r(F9,{destination:a,locations:n??[],onClose:()=>i(null),onSubmit:(x,v)=>{o.mutate({destinations:[a.id],locations:x,label:v||void 0},{onSuccess:()=>{i(null),e.invalidateQueries({queryKey:z9})}})},submitting:o.isPending}),(l||d)&&r($9,{...l?{initialDestinationId:l.destinationId,initialArchiveId:l.archiveId}:{},onClose:()=>{c(null),f(!1)},onScheduled:()=>m(!0)}),h&&r(s0,{initialType:"backups",onClose:()=>g(!1),onCreated:()=>{g(!1),e.invalidateQueries({queryKey:[["backup","listDestinations"]]})}})]})}function F9({destination:e,locations:t,onClose:n,onSubmit:o,submitting:s}){const a=t.filter(p=>p.present),[i,l]=_(""),[c,d]=_(()=>new Set(a.map(p=>p.name))),f=p=>{d(m=>{const h=new Set(m);return h.has(p)?h.delete(p):h.add(p),h})};return r("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",onClick:n,children:u("div",{className:"w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl",onClick:p=>p.stopPropagation(),children:[u("div",{className:"flex items-start justify-between border-b border-border px-4 py-3",children:[u("div",{className:"space-y-0.5",children:[r("h2",{className:"text-sm font-semibold text-foreground",children:"Create Backup"}),u("p",{className:"text-xs text-foreground-subtle",children:["→ ",e.displayName]})]}),r("button",{onClick:n,className:"text-foreground-subtle hover:text-foreground",children:r(Ve,{className:"h-4 w-4"})})]}),u("div",{className:"p-4 space-y-3",children:[u("div",{className:"space-y-1",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Label (optional)"}),r("input",{type:"text",value:i,onChange:p=>l(p.target.value),placeholder:"pre-upgrade",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary"})]}),u("div",{className:"space-y-1.5",children:[r("label",{className:"text-[10px] text-foreground-subtle uppercase tracking-wide",children:"Include"}),u("div",{className:"rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto",children:[a.length===0&&r("div",{className:"px-3 py-2 text-xs text-foreground-subtle italic",children:"Nothing to back up."}),a.map(p=>u("label",{className:"flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer",children:[u("div",{className:"flex items-center gap-2",children:[r("input",{type:"checkbox",checked:c.has(p.name),onChange:()=>f(p.name),className:"accent-primary"}),r("span",{className:"font-mono text-foreground",children:p.name})]}),u("div",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[kt(p.sizeBytes)," · ",p.fileCount," files"]})]},p.name))]})]})]}),u("div",{className:"flex justify-end gap-2 border-t border-border px-4 py-3",children:[r("button",{onClick:n,className:"rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground",children:"Cancel"}),u("button",{onClick:()=>o(Array.from(c),i.trim()),disabled:s||c.size===0,className:"inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:[s?r(Pe,{className:"h-3.5 w-3.5 animate-spin"}):r(Uc,{className:"h-3.5 w-3.5"}),s?"Creating…":"Create"]})]})]})})}function j9(){return r("div",{className:"flex flex-col",children:r("div",{className:"px-6 pt-6",children:r(td,{tabs:[{id:"storage",label:"Storage",icon:lo,content:r(l9,{})},{id:"backup",label:"Backup",icon:Uc,content:r(B9,{})}]})})})}function H9(){const{data:e,isLoading:t}=Mn(void 0,{staleTime:3e4}),n=(e??[]).find(s=>s.isHub&&s.isOnline),o=n?.addons.map(s=>s.id)??[];return u("div",{className:"flex flex-col h-full gap-4 p-4",children:[u("div",{className:"flex items-center gap-3",children:[r(Nt,{className:"h-5 w-5 text-muted-foreground"}),r("h1",{className:"text-xl font-semibold",children:"Settings"}),n&&u("span",{className:"text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground",children:["hub: ",n.name]})]}),t?r("div",{className:"flex items-center justify-center flex-1 text-muted-foreground text-sm",children:"Loading hub topology…"}):n?o.length===0?r("div",{className:"flex items-center justify-center flex-1 text-muted-foreground text-sm",children:"No addons installed on the hub yet."}):r("div",{className:"w-full",children:r(Tr,{nodeId:n.id,addonIds:o,level:"global"})}):u("div",{className:"flex flex-col items-center justify-center flex-1 text-muted-foreground text-sm gap-2",children:[r(Nt,{className:"h-8 w-8 opacity-30"}),r("p",{children:"No online hub node found."}),r("p",{className:"text-xs",children:"Settings will appear once the hub is reachable."})]})]})}function V9(e){const t=new FormData;return t.append("file",e.file,e.file.name),t.append("nodeId",e.nodeId),e.addonId&&t.append("addonId",e.addonId),new Promise((n,o)=>{const s=new XMLHttpRequest;s.open("POST","/api/addons/upload"),e.token&&s.setRequestHeader("Authorization",`Bearer ${e.token}`),s.upload.addEventListener("progress",a=>{a.lengthComputable&&e.onProgress(Math.round(a.loaded/a.total*100))}),s.addEventListener("load",()=>{let a;try{a=JSON.parse(s.responseText)}catch{o(new Error(`HTTP ${s.status}`));return}s.status>=200&&s.status<300?n(a):o(new Error(a.error??`HTTP ${s.status}`))}),s.addEventListener("error",()=>o(new Error("Network error during upload"))),s.addEventListener("abort",()=>o(new Error("Upload aborted"))),s.send(t)})}function q9({nodeId:e,addons:t,isHub:n}){const o=ke(),s=nt(),[a,i]=_(null),[l,c]=_(null),[d,f]=_(!1),[p,m]=_(null),[h,g]=_(0),b=ne(null),x=aa(),v=Xg(),w=()=>{o.invalidateQueries({queryKey:[["nodes","topology"]]})},y=async M=>{i(M);try{await x.mutateAsync({nodeId:e,addonId:M}),w()}catch(P){console.error("Failed to restart addon:",P)}finally{i(null)}},N=async M=>{if(await s({title:"Uninstall addon",message:`Remove "${M}" from ${e}? The addon directory will be deleted on disk.`,confirmLabel:"Uninstall",variant:"danger"})){c(M);try{await v.mutateAsync({nodeId:e,addonId:M}),w()}catch(I){console.error("Failed to uninstall addon:",I)}finally{c(null)}}},S=u("div",{className:"flex items-center gap-2 mb-2",children:[r("input",{ref:b,type:"file",accept:".tgz,.tar.gz",className:"hidden",onChange:async M=>{const P=M.target.files?.[0];if(P){M.target.value="",m(null),f(!0),g(0);try{const I=localStorage.getItem("camstack_admin_token");await V9({file:P,nodeId:e,token:I,onProgress:g}),w()}catch(I){m(I instanceof Error?I.message:String(I))}finally{f(!1),g(0)}}}}),u("button",{onClick:()=>b.current?.click(),disabled:d,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",children:[d?r(Pe,{className:"h-3 w-3 animate-spin"}):r(Xc,{className:"h-3 w-3"}),d?`Uploading… ${h}%`:"Upload addon (.tgz)"]}),d&&r("div",{className:"flex-1 h-1 rounded-full bg-muted overflow-hidden max-w-[140px]",children:r("div",{className:"h-full bg-primary transition-all",style:{width:`${h}%`}})}),p&&r("span",{className:"text-[10px] text-destructive",children:p})]});return t.length===0?u("div",{children:[S,r("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No addons on this node"})]}):u("div",{children:[S,u("table",{className:"w-full text-xs",children:[r("thead",{children:u("tr",{className:"text-muted-foreground text-left",children:[r("th",{className:"py-2 font-medium",children:"Addon"}),r("th",{className:"py-2 font-medium",children:"Capabilities"}),r("th",{className:"py-2 font-medium",children:"Status"}),r("th",{className:"py-2 font-medium w-16"})]})}),r("tbody",{children:t.map(M=>u("tr",{className:"border-t border-border/50",children:[r("td",{className:"py-2 font-medium",children:M.id}),r("td",{className:"py-2",children:r("div",{className:"flex flex-wrap gap-1",children:M.capabilities.length>0?M.capabilities.map(P=>r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400",children:P},P)):r("span",{className:"text-muted-foreground",children:"—"})})}),r("td",{className:"py-2",children:r("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${M.status==="running"?"bg-success/10 text-success":M.status==="error"?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground"}`,children:M.status})}),r("td",{className:"py-2",children:u("div",{className:"flex items-center gap-1 justify-end",children:[r("button",{onClick:()=>y(M.id),disabled:a===M.id||l===M.id,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:`Restart ${M.id}`,children:r(bt,{className:`h-3 w-3 ${a===M.id?"animate-spin":""}`})}),r("button",{onClick:()=>N(M.id),disabled:a===M.id||l===M.id,className:"p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50",title:`Uninstall ${M.id}`,children:l===M.id?r(Pe,{className:"h-3 w-3 animate-spin"}):r(Ge,{className:"h-3 w-3"})})]})})]},M.id))})]})]})}function Q9(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 U9({state:e}){return r("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e==="running"?"bg-success/10 text-success":e==="crashed"?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground"}`,children:e})}const K9=["trace","debug","info","warn","error"];function G9({proc:e,nodeId:t,defaultExpanded:n,activePanel:o,onTogglePanel:s}){const a=e.services??[],i=a.length===1,[l,c]=_(i||n),[d,f]=_(null),[p,m]=_("info"),h=e.name.includes("(core)"),g=aa(),b=Jg(),x=rb(),v=async N=>{f(N);try{await g.mutateAsync({nodeId:t,addonId:N})}catch(k){console.error("Failed to restart addon:",k)}finally{f(null)}},w=async()=>{f(e.name);try{await b.mutateAsync({nodeId:t,processName:e.name})}catch(N){console.error("Failed to restart process:",N)}finally{f(null)}},y=async N=>{const k=`${t}/${e.name}`;try{await x.mutateAsync({nodeId:k,level:N}),m(N)}catch(S){console.error("Failed to set log level:",S)}};return u("div",{className:"border border-border/50 rounded-lg overflow-hidden",children:[u("div",{role:i?void 0:"button",tabIndex:i?void 0:0,onClick:i?void 0:()=>c(!l),onKeyDown:i?void 0:N=>{(N.key==="Enter"||N.key===" ")&&c(!l)},className:`flex items-center gap-2 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${i?"":"hover:bg-muted/40 cursor-pointer"}`,children:[i?r("span",{className:"h-3 w-3 shrink-0"}):l?r(wt,{className:"h-3 w-3 text-muted-foreground shrink-0"}):r(It,{className:"h-3 w-3 text-muted-foreground shrink-0"}),h?r(sn,{className:"h-3.5 w-3.5 text-primary shrink-0"}):r(ga,{className:"h-3.5 w-3.5 text-amber-500 shrink-0"}),r("span",{className:"text-xs font-semibold flex-1",children:e.name}),u("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:["PID ",e.pid]}),r(U9,{state:e.state}),u("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[e.cpuPercent,"% CPU"]}),r("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:kt(e.memoryRss)}),r("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:Q9(e.uptimeSeconds)}),!h&&u("div",{className:"flex items-center gap-1",onClick:N=>N.stopPropagation(),children:[u(Km,{children:[r(Gm,{className:"text-[9px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors font-mono",title:"Set log level",children:p}),r(Wm,{align:"end",className:"min-w-[70px] py-0.5",children:K9.map(N=>r(Ym,{onClick:()=>y(N),className:`h-auto px-2 py-1 text-[10px] font-mono ${N===p?"text-primary font-semibold":""}`,children:N},N))})]}),r("button",{onClick:w,disabled:d===e.name,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:"Restart process",children:r(bt,{className:`h-3 w-3 ${d===e.name?"animate-spin":""}`})})]})]}),l&&a.length>0&&r("div",{className:"divide-y divide-border/30",children:a.map(N=>u("div",{children:[u("div",{className:"flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors",children:[r("div",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${N.status==="running"?"bg-success":"bg-muted-foreground/30"}`}),r("span",{className:"text-xs font-medium flex-1 min-w-0 truncate",children:N.addonId}),N.capabilities.length>0&&u("div",{className:"flex gap-1 flex-shrink-0",children:[N.capabilities.slice(0,3).map(k=>r("span",{className:"text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400 truncate max-w-[80px]",children:k},k)),N.capabilities.length>3&&u("span",{className:"text-[9px] text-muted-foreground",children:["+",N.capabilities.length-3]})]}),u("div",{className:"flex items-center gap-1 shrink-0",children:[r("button",{onClick:()=>s(N.addonId,"logs"),className:`p-0.5 rounded transition-colors ${o?.addonId===N.addonId&&o.type==="logs"?"bg-primary/10 text-primary":"hover:bg-muted text-muted-foreground hover:text-foreground"}`,title:`Show logs for ${N.addonId}`,children:r(Ze,{className:"h-3 w-3"})}),r("button",{onClick:()=>s(N.addonId,"events"),className:`p-0.5 rounded transition-colors ${o?.addonId===N.addonId&&o.type==="events"?"bg-primary/10 text-primary":"hover:bg-muted text-muted-foreground hover:text-foreground"}`,title:`Show events for ${N.addonId}`,children:r(Zc,{className:"h-3 w-3"})}),r("button",{onClick:()=>v(N.addonId),disabled:d===N.addonId,className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:`Restart ${N.addonId}`,children:r(bt,{className:`h-3 w-3 ${d===N.addonId?"animate-spin":""}`})})]})]}),o?.addonId===N.addonId&&o.type==="logs"&&r("div",{className:"border-t border-border/40 bg-muted/5",children:r(Ut,{addonId:N.addonId,agentId:t,maxHeight:"max-h-48",showFilters:!1,onClose:()=>s(N.addonId,"logs")})}),o?.addonId===N.addonId&&o.type==="events"&&r("div",{className:"border-t border-border/40 bg-muted/5",children:r(tr,{addonId:N.addonId,category:"addon.*",maxHeight:"max-h-48",onClose:()=>s(N.addonId,"events")})})]},N.addonId))}),l&&a.length===0&&r("div",{className:"px-3 py-2 pl-9 text-[10px] text-muted-foreground",children:"No services"})]})}function W9({nodeId:e,processes:t}){const[n,o]=_(null),s=(a,i)=>{o(l=>l?.addonId===a&&l.type===i?null:{addonId:a,type:i})};return t.length===0?r("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No processes on this node"}):r("div",{className:"space-y-2 py-1",children:t.map((a,i)=>r(G9,{proc:a,nodeId:e,defaultExpanded:i===0,activePanel:n,onTogglePanel:s},a.name))})}function Y9(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 Z9(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function X9({nodeId:e}){const t=ke(),n=nt(),[o,s]=_("all"),a=Ir("metrics.node-processes-snapshot",k=>k.nodeId===e),{data:i}=Yg({nodeId:e},{staleTime:6e4}),l=a?.processes??i,c=U(()=>l?[...l]:[],[l]),d=U(()=>o==="ghost"?c.filter(k=>k.classification==="ghost"):c,[c,o]),f=U(()=>{const k=c.filter(M=>M.classification==="ghost"),S=new Map;for(const M of k)S.has(M.ppid)||S.set(M.ppid,[]),S.get(M.ppid).push(M);return[...S.entries()].filter(([,M])=>M.length>1).map(([M,P])=>({ppid:M,children:P})).sort((M,P)=>P.children.length-M.children.length)},[c]),p=Zg({onSettled:()=>{t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]})}}),m=U(()=>{const k=new Map;for(const S of c)k.set(S.pid,S.classification);return k},[c]),h=async(k,S)=>{if(k.classification==="root"||k.classification==="system")return;const M=k.classification==="ghost"?"ghost":k.addonId??"process",P=S?"SIGKILL":"SIGTERM";await n({title:`Send ${P}?`,message:`Target pid ${k.pid} (${M}) on node ${e}.`,confirmLabel:`Send ${P}`,variant:"danger"})&&p.mutate({nodeId:e,pid:k.pid,force:S})},g=async(k,S)=>{try{await p.mutateAsync({nodeId:e,pid:k,force:S})}catch{}},b=async k=>{const S=m.get(k.ppid);if(S==="root"||S==="system"){await n({title:"Cannot kill protected ancestor",message:S==="root"?`pid ${k.ppid} is the current node supervisor. Restart the node via the cluster page instead.`:`pid ${k.ppid} is a system ancestor (concurrently / vite / npm wrapper). Killing it would tear down the dev tree.`,confirmLabel:"OK",cancelLabel:"Close",variant:"warning"});return}await n({title:`Kill ghost parent + ${k.children.length} child(ren)?`,message:`SIGKILL parent pid ${k.ppid} and SIGTERM ${k.children.length} ghost child(ren) on node ${e}.`,confirmLabel:"Kill all",variant:"danger"})&&(await Promise.all([g(k.ppid,!0),...k.children.map(P=>g(P.pid,!1))]),t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}))},x=async()=>{const k=c.filter(M=>M.classification==="ghost");k.length===0||!await n({title:`Kill all ${k.length} ghost process(es)?`,message:`SIGKILL ${k.length} ghost process(es) on node ${e}. This is irreversible.`,confirmLabel:"Kill all",variant:"danger"})||(await Promise.all(k.map(M=>g(M.pid,!0))),t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}))},v=c.filter(k=>k.classification==="ghost").length,w=c.filter(k=>k.classification==="managed").length,y=c.filter(k=>k.classification==="root").length,N=c.filter(k=>k.classification==="system").length;return u("div",{className:"space-y-4",children:[u("div",{className:"flex items-start justify-between gap-4",children:[u("p",{className:"text-[11px] text-foreground-subtle",children:["ps"," scan + kernel `$process.list` cross-reference. Ghosts = camstack-shaped commands with no managed binding (usually orphaned to ppid=1). Refreshes every 10s."]}),u("button",{type:"button",onClick:()=>t.invalidateQueries({queryKey:[["metricsProvider","listNodeProcesses"]]}),className:"inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover",children:[r(pt,{className:"h-3 w-3"})," Refresh"]})]}),u("div",{className:"grid grid-cols-4 gap-3",children:[u("div",{className:"rounded-lg border border-border p-3",children:[r("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Root"}),r("div",{className:"text-xl font-semibold text-foreground",children:y})]}),u("div",{className:"rounded-lg border border-border p-3",children:[r("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"Managed"}),r("div",{className:"text-xl font-semibold text-foreground",children:w})]}),u("div",{className:"rounded-lg border border-border p-3",children:[r("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:"System"}),r("div",{className:"text-xl font-semibold text-foreground",children:N})]}),u("div",{className:`rounded-lg border p-3 ${v>0?"border-destructive/40 bg-destructive/5":"border-border"}`,children:[u("div",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle flex items-center gap-1",children:[v>0&&r(Uo,{className:"h-3 w-3 text-destructive"})," Ghosts"]}),r("div",{className:`text-xl font-semibold ${v>0?"text-destructive":"text-foreground"}`,children:v})]})]}),f.length>0&&u("div",{className:"rounded-lg border border-amber-500/40 bg-amber-500/5 p-3",children:[u("div",{className:"flex items-center gap-1 text-[11px] font-semibold text-amber-400 mb-2",children:[r(xt,{className:"h-3 w-3"})," Recurring ghost parents (",f.length,")"]}),r("div",{className:"space-y-1.5",children:f.map(k=>u("div",{className:"text-[11px] text-foreground flex items-center justify-between gap-2",children:[u("div",{className:"flex items-center gap-2",children:[u("span",{className:"font-mono text-foreground-subtle",children:["ppid ",k.ppid]}),u("span",{children:["→ ",k.children.length," ghost(s)"]})]}),u("button",{type:"button",disabled:p.isPending,onClick:()=>{b(k)},className:"inline-flex items-center gap-1 rounded border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] text-amber-400 hover:bg-amber-500/20 disabled:opacity-30",children:[r(Uo,{className:"h-3 w-3"})," Kill parent + ",k.children.length]})]},k.ppid))})]}),u("div",{className:"flex items-center justify-between gap-2 text-[11px]",children:[u("div",{className:"flex items-center gap-2",children:[r("span",{className:"text-foreground-subtle",children:"Filter:"}),u("button",{type:"button",className:`px-2 py-0.5 rounded ${o==="all"?"bg-primary text-primary-foreground":"border border-border text-foreground hover:bg-surface-hover"}`,onClick:()=>s("all"),children:["All (",c.length,")"]}),u("button",{type:"button",className:`px-2 py-0.5 rounded ${o==="ghost"?"bg-destructive text-destructive-foreground":"border border-border text-foreground hover:bg-surface-hover"}`,onClick:()=>s("ghost"),children:["Ghost only (",v,")"]})]}),v>0&&u("button",{type:"button",disabled:p.isPending,onClick:()=>{x()},className:"inline-flex items-center gap-1 rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive/20 disabled:opacity-30",children:[r(Uo,{className:"h-3 w-3"})," Kill all ",v," ghost(s)"]})]}),r("div",{className:"rounded-lg border border-border overflow-hidden",children:u("table",{className:"w-full text-xs",children:[r("thead",{className:"bg-surface",children:u("tr",{className:"text-foreground-subtle text-[10px] uppercase tracking-wider",children:[r("th",{className:"text-left px-3 py-2",children:"Class"}),r("th",{className:"text-right px-3 py-2",children:"PID"}),r("th",{className:"text-right px-3 py-2",children:"PPID"}),r("th",{className:"text-left px-3 py-2",children:"Addon"}),r("th",{className:"text-left px-3 py-2",children:"Command"}),r("th",{className:"text-right px-3 py-2",children:"CPU%"}),r("th",{className:"text-right px-3 py-2",children:"RSS"}),r("th",{className:"text-right px-3 py-2",children:"Uptime"}),r("th",{className:"w-44"})]})}),u("tbody",{children:[d.length===0&&r("tr",{children:r("td",{colSpan:9,className:"px-3 py-4 text-center text-foreground-subtle text-[11px]",children:o==="ghost"?"No ghost processes detected.":"Scanning…"})}),d.map(k=>u("tr",{className:`border-t border-border ${k.classification==="ghost"?"bg-destructive/5":""}`,children:[r("td",{className:"px-3 py-2",children:r("span",{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${k.classification==="ghost"?"bg-destructive/20 text-destructive":k.classification==="root"?"bg-sky-500/20 text-sky-400":k.classification==="system"?"bg-foreground-subtle/20 text-foreground-subtle":"bg-success/20 text-success"}`,children:k.classification})}),r("td",{className:"px-3 py-2 text-right font-mono text-foreground",children:k.pid}),u("td",{className:"px-3 py-2 text-right font-mono text-foreground-subtle",children:[k.ppid,k.orphaned?" ⚠":""]}),r("td",{className:"px-3 py-2 text-foreground-subtle text-[11px]",children:k.addonId??"—"}),r("td",{className:"px-3 py-2 font-mono text-[10px] text-foreground-subtle break-all",children:Z9(k.command)}),r("td",{className:"px-3 py-2 text-right text-foreground",children:k.cpuPercent.toFixed(1)}),r("td",{className:"px-3 py-2 text-right text-foreground",children:kt(k.memoryRssBytes)}),r("td",{className:"px-3 py-2 text-right text-foreground-subtle",children:Y9(k.uptimeSec)}),r("td",{className:"px-3 py-2 text-right",children:u("div",{className:"inline-flex gap-1",children:[u("button",{type:"button",disabled:p.isPending||k.classification==="root"||k.classification==="system",onClick:()=>{h(k,!1)},title:"SIGTERM",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-border text-[10px] text-foreground hover:bg-surface-hover disabled:opacity-30",children:[r(Ge,{className:"h-3 w-3"})," Term"]}),u("button",{type:"button",disabled:p.isPending||k.classification==="root"||k.classification==="system",onClick:()=>{h(k,!0)},title:"SIGKILL",className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-destructive/30 text-[10px] text-destructive hover:bg-destructive/10 disabled:opacity-30",children:[r(Uo,{className:"h-3 w-3"})," Kill"]})]})})]},k.pid))]})]})}),p.isError&&u("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive",children:["Kill failed: ",p.error instanceof Error?p.error.message:"unknown"]})]})}function J9({nodeId:e,addonIds:t}){return t.length===0?r("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No addons on this node"}):r("div",{className:"w-full py-2",children:r(Tr,{nodeId:e,addonIds:t,level:"global"})})}function e7({nodeId:e,addons:t}){const n=ke(),{data:o,isLoading:s}=hb({nodeId:e}),a=U(()=>{const l=new Map;for(const c of t)for(const d of c.capabilities){const f=l.get(d)??[];f.push(c.id),l.set(d,f)}return[...l.entries()].sort(([c],[d])=>c.localeCompare(d)).map(([c,d])=>({capName:c,providers:d}))},[t]),i=gb({onSuccess:()=>{n.invalidateQueries({queryKey:[["pipelineOrchestrator","getCapabilityBindings"]]})}});return a.length===0?r("div",{className:"py-4 text-xs text-muted-foreground text-center",children:"No capabilities on this node"}):u("table",{className:"w-full text-xs",children:[r("thead",{children:u("tr",{className:"text-muted-foreground text-left",children:[r("th",{className:"py-2 font-medium w-1/2",children:"Capability"}),r("th",{className:"py-2 font-medium",children:"Bound provider"})]})}),r("tbody",{children:a.map(({capName:l,providers:c})=>{const f=o?.[l]??c[0]??"",p=c.length===1;return u("tr",{className:"border-t border-border/50",children:[r("td",{className:"py-2 font-medium",children:l}),r("td",{className:"py-2",children:r("select",{value:f,onChange:m=>i.mutate({nodeId:e,capName:l,addonId:m.target.value}),disabled:p||i.isPending||s,className:"w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-60",title:p?"Only one provider installed — choice becomes available once a second addon registers this capability":void 0,children:c.map(m=>r("option",{value:m,children:m},m))})})]},l)})})]})}function t7(e){if(e==null)return"—";const t=Math.floor(e/1e3),n=Math.floor(t/86400),o=Math.floor(t%86400/3600),s=Math.floor(t%3600/60);return n>0?`${n}d ${o}h ${s}m`:o>0?`${o}h ${s}m`:`${s}m`}function n7(e){const[t,n]=_(!1),[o,s]=_(e.name),a=ke(),i=tb({onSuccess:()=>{a.invalidateQueries({queryKey:[["nodes","topology"]]})}}),l=(e.localIps??[]).filter(p=>!p.includes(":")),c=(e.localIps??[]).filter(p=>p.includes(":")),d=async()=>{if(!o.trim()||o===e.name){n(!1);return}try{await i.mutateAsync({nodeId:e.nodeId,name:o.trim()}),n(!1)}catch(p){console.error("Rename failed:",p)}},f=[["Node ID",r("span",{className:"font-mono text-xs",children:e.nodeId})],["Display Name",t?u("div",{className:"flex items-center gap-1.5",children:[r("input",{type:"text",className:"flex-1 px-2 py-0.5 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary",value:o,onChange:p=>s(p.target.value),onKeyDown:p=>{p.key==="Enter"&&d(),p.key==="Escape"&&n(!1)},disabled:i.isPending,autoFocus:!0}),r("button",{onClick:()=>void d(),disabled:i.isPending,className:"p-0.5 text-success hover:bg-success/10 rounded",title:"Save",children:r(Mt,{className:"h-3.5 w-3.5"})}),r("button",{onClick:()=>n(!1),className:"p-0.5 text-muted-foreground hover:bg-muted rounded",title:"Cancel",children:r(Ve,{className:"h-3.5 w-3.5"})})]}):u("div",{className:"flex items-center gap-1.5",children:[r("span",{className:"text-xs",children:e.name}),!e.isHub&&r("button",{onClick:()=>{s(e.name),n(!0)},className:"p-0.5 text-muted-foreground hover:text-primary rounded",title:"Rename",children:r(Ao,{className:"h-3 w-3"})})]})],["Hostname",r("span",{className:"text-xs",children:e.hostname})],["Role",e.isHub?r("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium",children:"Hub"}):r("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium",children:"Agent"})],["Platform",u("span",{className:"text-xs",children:[e.platform," / ",e.arch]})],["CPU",u("span",{className:"text-xs",children:[e.cpuModel??"—"," (",e.cpuCores," cores)"]})],["Memory",r("span",{className:"text-xs",children:e.memoryMB>0?`${(e.memoryMB/1024).toFixed(1)} GB`:"—"})],["Uptime",r("span",{className:"text-xs",children:t7(e.uptime)})],["Engines",e.engines.length>0?r("div",{className:"flex flex-wrap gap-1",children:e.engines.map(p=>r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:p},p))}):r("span",{className:"text-xs text-muted-foreground",children:"—"})]];return l.length>0&&f.push(["IPv4",r("div",{className:"flex flex-wrap gap-1.5",children:l.map((p,m)=>r("span",{className:"font-mono text-xs px-1.5 py-0.5 rounded bg-muted",children:p},`${p}-${m}`))})]),c.length>0&&f.push(["IPv6",r("div",{className:"flex flex-wrap gap-1.5",children:c.map((p,m)=>r("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]",title:p,children:p},`${p}-${m}`))})]),r("div",{className:"py-2",children:r("table",{className:"w-full text-sm",children:r("tbody",{children:f.map(([p,m],h)=>u("tr",{className:h%2===0?"bg-muted/20":"",children:[r("td",{className:"py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap",children:p}),r("td",{className:"py-1.5 px-2",children:m})]},p))})})})}function r7({node:e}){const[t,n]=_("info"),o=e.processes??[],s=e.addons.map(a=>a.id);return e.isOnline?u("div",{className:"border border-border rounded-xl overflow-hidden",children:[u("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/30 border-b border-border",children:[r("div",{className:"w-2.5 h-2.5 rounded-full bg-success"}),r("span",{className:"text-sm font-semibold",children:e.name}),u("span",{className:"text-xs text-muted-foreground",children:[e.cpuModel??e.platform," · ",e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:""," · ",e.arch]}),e.engines.map(a=>r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:a},a)),u("div",{className:"ml-auto flex gap-3 text-xs text-muted-foreground",children:[u("span",{className:"flex items-center gap-1",children:[r(dt,{className:"h-3 w-3"})," ",e.cpuPercent,"%"]}),u("span",{className:"flex items-center gap-1",children:[r(Wc,{className:"h-3 w-3"})," ",e.memoryPercent,"%"]})]})]}),r("div",{className:"flex border-b border-border px-4",children:["info","addons","forks","processes","settings","capabilities"].map(a=>r("button",{onClick:()=>n(a),className:`px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===a?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:a==="info"?"Info":a==="addons"?`Addons (${e.addons.length})`:a==="forks"?`Forks (${o.length})`:a==="processes"?"Processes":a==="settings"?"Settings":"Capabilities"},a))}),u("div",{className:"px-4 py-2",children:[t==="info"&&r(n7,{nodeId:e.id,name:e.name,hostname:e.hostname,platform:e.platform,arch:e.arch,cpuModel:e.cpuModel,cpuCores:e.cpuCores,memoryMB:e.memoryMB,engines:e.engines,isHub:e.isHub,uptime:e.uptime,localIps:e.localIps}),t==="addons"&&r(q9,{nodeId:e.id,addons:e.addons,isHub:e.isHub}),t==="forks"&&r(W9,{nodeId:e.id,processes:o}),t==="processes"&&r(X9,{nodeId:e.id}),t==="settings"&&r(J9,{nodeId:e.id,addonIds:s}),t==="capabilities"&&r(e7,{nodeId:e.id,addons:e.addons})]})]}):u("div",{className:"border border-border rounded-xl overflow-hidden opacity-60",children:[u("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/30",children:[r("div",{className:"w-2.5 h-2.5 rounded-full bg-destructive"}),r("span",{className:"text-sm font-semibold",children:e.name}),u("span",{className:"text-xs text-muted-foreground",children:[e.cpuModel??e.platform," · ",e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:""," · ",e.arch]}),e.engines.map(a=>r("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:a},a)),r("span",{className:"ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:"offline"})]}),u("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:[e.addons.length," addon",e.addons.length!==1?"s":""," assigned — will resume when node reconnects"]})]})}function o7({nodes:e}){const t=[...e].sort((n,o)=>n.isHub?-1:o.isHub?1:n.isOnline&&!o.isOnline?-1:!n.isOnline&&o.isOnline?1:n.name.localeCompare(o.name));return r("div",{className:"flex flex-col gap-4",children:t.map(n=>r(r7,{node:n},n.id))})}function Ue(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=Ue(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var s7={value:()=>{}};function Ma(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new gs(n)}function gs(e){this._=e}function a7(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",s=n.indexOf(".");if(s>=0&&(o=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}gs.prototype=Ma.prototype={constructor:gs,on:function(e,t){var n=this._,o=a7(e+"",n),s,a=-1,i=o.length;if(arguments.length<2){for(;++a<i;)if((s=(e=o[a]).type)&&(s=i7(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<i;)if(s=(e=o[a]).type)n[s]=Np(n[s],e.name,t);else if(t==null)for(s in n)n[s]=Np(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 gs(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),o=0,s,a;o<s;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],o=0,s=a.length;o<s;++o)a[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],s=0,a=o.length;s<a;++s)o[s].value.apply(t,n)}};function i7(e,t){for(var n=0,o=e.length,s;n<o;++n)if((s=e[n]).name===t)return s.value}function Np(e,t,n){for(var o=0,s=e.length;o<s;++o)if(e[o].name===t){e[o]=s7,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var ml="http://www.w3.org/1999/xhtml";const kp={svg:"http://www.w3.org/2000/svg",xhtml:ml,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ia(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),kp.hasOwnProperty(t)?{space:kp[t],local:e}:e}function l7(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ml&&t.documentElement.namespaceURI===ml?t.createElement(e):t.createElementNS(n,e)}}function c7(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function i0(e){var t=Ia(e);return(t.local?c7:l7)(t)}function d7(){}function rd(e){return e==null?d7:function(){return this.querySelector(e)}}function u7(e){typeof e!="function"&&(e=rd(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=o[s]=new Array(i),c,d,f=0;f<i;++f)(c=a[f])&&(d=e.call(c,c.__data__,f,a))&&("__data__"in c&&(d.__data__=c.__data__),l[f]=d);return new ft(o,this._parents)}function p7(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function f7(){return[]}function l0(e){return e==null?f7:function(){return this.querySelectorAll(e)}}function m7(e){return function(){return p7(e.apply(this,arguments))}}function h7(e){typeof e=="function"?e=m7(e):e=l0(e);for(var t=this._groups,n=t.length,o=[],s=[],a=0;a<n;++a)for(var i=t[a],l=i.length,c,d=0;d<l;++d)(c=i[d])&&(o.push(e.call(c,c.__data__,d,i)),s.push(c));return new ft(o,s)}function c0(e){return function(){return this.matches(e)}}function d0(e){return function(t){return t.matches(e)}}var g7=Array.prototype.find;function b7(e){return function(){return g7.call(this.children,e)}}function x7(){return this.firstElementChild}function y7(e){return this.select(e==null?x7:b7(typeof e=="function"?e:d0(e)))}var v7=Array.prototype.filter;function w7(){return Array.from(this.children)}function N7(e){return function(){return v7.call(this.children,e)}}function k7(e){return this.selectAll(e==null?w7:N7(typeof e=="function"?e:d0(e)))}function S7(e){typeof e!="function"&&(e=c0(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=o[s]=[],c,d=0;d<i;++d)(c=a[d])&&e.call(c,c.__data__,d,a)&&l.push(c);return new ft(o,this._parents)}function u0(e){return new Array(e.length)}function C7(){return new ft(this._enter||this._groups.map(u0),this._parents)}function Os(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Os.prototype={constructor:Os,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 M7(e){return function(){return e}}function I7(e,t,n,o,s,a){for(var i=0,l,c=t.length,d=a.length;i<d;++i)(l=t[i])?(l.__data__=a[i],o[i]=l):n[i]=new Os(e,a[i]);for(;i<c;++i)(l=t[i])&&(s[i]=l)}function A7(e,t,n,o,s,a,i){var l,c,d=new Map,f=t.length,p=a.length,m=new Array(f),h;for(l=0;l<f;++l)(c=t[l])&&(m[l]=h=i.call(c,c.__data__,l,t)+"",d.has(h)?s[l]=c:d.set(h,c));for(l=0;l<p;++l)h=i.call(e,a[l],l,a)+"",(c=d.get(h))?(o[l]=c,c.__data__=a[l],d.delete(h)):n[l]=new Os(e,a[l]);for(l=0;l<f;++l)(c=t[l])&&d.get(m[l])===c&&(s[l]=c)}function P7(e){return e.__data__}function E7(e,t){if(!arguments.length)return Array.from(this,P7);var n=t?A7:I7,o=this._parents,s=this._groups;typeof e!="function"&&(e=M7(e));for(var a=s.length,i=new Array(a),l=new Array(a),c=new Array(a),d=0;d<a;++d){var f=o[d],p=s[d],m=p.length,h=$7(e.call(f,f&&f.__data__,d,o)),g=h.length,b=l[d]=new Array(g),x=i[d]=new Array(g),v=c[d]=new Array(m);n(f,p,b,x,v,h,t);for(var w=0,y=0,N,k;w<g;++w)if(N=b[w]){for(w>=y&&(y=w+1);!(k=x[y])&&++y<g;);N._next=k||null}}return i=new ft(i,o),i._enter=l,i._exit=c,i}function $7(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function _7(){return new ft(this._exit||this._groups.map(u0),this._parents)}function D7(e,t,n){var o=this.enter(),s=this,a=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?a.remove():n(a),o&&s?o.merge(s).order():s}function L7(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,s=n.length,a=o.length,i=Math.min(s,a),l=new Array(s),c=0;c<i;++c)for(var d=n[c],f=o[c],p=d.length,m=l[c]=new Array(p),h,g=0;g<p;++g)(h=d[g]||f[g])&&(m[g]=h);for(;c<s;++c)l[c]=n[c];return new ft(l,this._parents)}function T7(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],s=o.length-1,a=o[s],i;--s>=0;)(i=o[s])&&(a&&i.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(i,a),a=i);return this}function R7(e){e||(e=O7);function t(p,m){return p&&m?e(p.__data__,m.__data__):!p-!m}for(var n=this._groups,o=n.length,s=new Array(o),a=0;a<o;++a){for(var i=n[a],l=i.length,c=s[a]=new Array(l),d,f=0;f<l;++f)(d=i[f])&&(c[f]=d);c.sort(t)}return new ft(s,this._parents).order()}function O7(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function z7(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function B7(){return Array.from(this)}function F7(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],s=0,a=o.length;s<a;++s){var i=o[s];if(i)return i}return null}function j7(){let e=0;for(const t of this)++e;return e}function H7(){return!this.node()}function V7(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var s=t[n],a=0,i=s.length,l;a<i;++a)(l=s[a])&&e.call(l,l.__data__,a,s);return this}function q7(e){return function(){this.removeAttribute(e)}}function Q7(e){return function(){this.removeAttributeNS(e.space,e.local)}}function U7(e,t){return function(){this.setAttribute(e,t)}}function K7(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function G7(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function W7(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 Y7(e,t){var n=Ia(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?Q7:q7:typeof t=="function"?n.local?W7:G7:n.local?K7:U7)(n,t))}function p0(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Z7(e){return function(){this.style.removeProperty(e)}}function X7(e,t,n){return function(){this.style.setProperty(e,t,n)}}function J7(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function ez(e,t,n){return arguments.length>1?this.each((t==null?Z7:typeof t=="function"?J7:X7)(e,t,n??"")):yr(this.node(),e)}function yr(e,t){return e.style.getPropertyValue(t)||p0(e).getComputedStyle(e,null).getPropertyValue(t)}function tz(e){return function(){delete this[e]}}function nz(e,t){return function(){this[e]=t}}function rz(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function oz(e,t){return arguments.length>1?this.each((t==null?tz:typeof t=="function"?rz:nz)(e,t)):this.node()[e]}function f0(e){return e.trim().split(/^|\s+/)}function od(e){return e.classList||new m0(e)}function m0(e){this._node=e,this._names=f0(e.getAttribute("class")||"")}m0.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 h0(e,t){for(var n=od(e),o=-1,s=t.length;++o<s;)n.add(t[o])}function g0(e,t){for(var n=od(e),o=-1,s=t.length;++o<s;)n.remove(t[o])}function sz(e){return function(){h0(this,e)}}function az(e){return function(){g0(this,e)}}function iz(e,t){return function(){(t.apply(this,arguments)?h0:g0)(this,e)}}function lz(e,t){var n=f0(e+"");if(arguments.length<2){for(var o=od(this.node()),s=-1,a=n.length;++s<a;)if(!o.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?iz:t?sz:az)(n,t))}function cz(){this.textContent=""}function dz(e){return function(){this.textContent=e}}function uz(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function pz(e){return arguments.length?this.each(e==null?cz:(typeof e=="function"?uz:dz)(e)):this.node().textContent}function fz(){this.innerHTML=""}function mz(e){return function(){this.innerHTML=e}}function hz(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function gz(e){return arguments.length?this.each(e==null?fz:(typeof e=="function"?hz:mz)(e)):this.node().innerHTML}function bz(){this.nextSibling&&this.parentNode.appendChild(this)}function xz(){return this.each(bz)}function yz(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function vz(){return this.each(yz)}function wz(e){var t=typeof e=="function"?e:i0(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Nz(){return null}function kz(e,t){var n=typeof e=="function"?e:i0(e),o=t==null?Nz:typeof t=="function"?t:rd(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Sz(){var e=this.parentNode;e&&e.removeChild(this)}function Cz(){return this.each(Sz)}function Mz(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Iz(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Az(e){return this.select(e?Iz:Mz)}function Pz(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Ez(e){return function(t){e.call(this,t,this.__data__)}}function $z(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function _z(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,s=t.length,a;n<s;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++o]=a;++o?t.length=o:delete this.__on}}}function Dz(e,t,n){return function(){var o=this.__on,s,a=Ez(t);if(o){for(var i=0,l=o.length;i<l;++i)if((s=o[i]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=a,s.options=n),s.value=t;return}}this.addEventListener(e.type,a,n),s={type:e.type,name:e.name,value:t,listener:a,options:n},o?o.push(s):this.__on=[s]}}function Lz(e,t,n){var o=$z(e+""),s,a=o.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,d=l.length,f;c<d;++c)for(s=0,f=l[c];s<a;++s)if((i=o[s]).type===f.type&&i.name===f.name)return f.value}return}for(l=t?Dz:_z,s=0;s<a;++s)this.each(l(o[s],t,n));return this}function b0(e,t,n){var o=p0(e),s=o.CustomEvent;typeof s=="function"?s=new s(t,n):(s=o.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function Tz(e,t){return function(){return b0(this,e,t)}}function Rz(e,t){return function(){return b0(this,e,t.apply(this,arguments))}}function Oz(e,t){return this.each((typeof t=="function"?Rz:Tz)(e,t))}function*zz(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],s=0,a=o.length,i;s<a;++s)(i=o[s])&&(yield i)}var x0=[null];function ft(e,t){this._groups=e,this._parents=t}function Eo(){return new ft([[document.documentElement]],x0)}function Bz(){return this}ft.prototype=Eo.prototype={constructor:ft,select:u7,selectAll:h7,selectChild:y7,selectChildren:k7,filter:S7,data:E7,enter:C7,exit:_7,join:D7,merge:L7,selection:Bz,order:T7,sort:R7,call:z7,nodes:B7,node:F7,size:j7,empty:H7,each:V7,attr:Y7,style:ez,property:oz,classed:lz,text:pz,html:gz,raise:xz,lower:vz,append:wz,insert:kz,remove:Cz,clone:Az,datum:Pz,on:Lz,dispatch:Oz,[Symbol.iterator]:zz};function it(e){return typeof e=="string"?new ft([[document.querySelector(e)]],[document.documentElement]):new ft([[e]],x0)}function Fz(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Pt(e,t){if(e=Fz(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const jz={passive:!1},uo={capture:!0,passive:!1};function Si(e){e.stopImmediatePropagation()}function dr(e){e.preventDefault(),e.stopImmediatePropagation()}function y0(e){var t=e.document.documentElement,n=it(e).on("dragstart.drag",dr,uo);"onselectstart"in t?n.on("selectstart.drag",dr,uo):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function v0(e,t){var n=e.document.documentElement,o=it(e).on("dragstart.drag",null);t&&(o.on("click.drag",dr,uo),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const ns=e=>()=>e;function hl(e,{sourceEvent:t,subject:n,target:o,identifier:s,active:a,x:i,y:l,dx:c,dy:d,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:f}})}hl.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Hz(e){return!e.ctrlKey&&!e.button}function Vz(){return this.parentNode}function qz(e,t){return t??{x:e.x,y:e.y}}function Qz(){return navigator.maxTouchPoints||"ontouchstart"in this}function w0(){var e=Hz,t=Vz,n=qz,o=Qz,s={},a=Ma("start","drag","end"),i=0,l,c,d,f,p=0;function m(N){N.on("mousedown.drag",h).filter(o).on("touchstart.drag",x).on("touchmove.drag",v,jz).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(N,k){if(!(f||!e.call(this,N,k))){var S=y(this,t.call(this,N,k),N,k,"mouse");S&&(it(N.view).on("mousemove.drag",g,uo).on("mouseup.drag",b,uo),y0(N.view),Si(N),d=!1,l=N.clientX,c=N.clientY,S("start",N))}}function g(N){if(dr(N),!d){var k=N.clientX-l,S=N.clientY-c;d=k*k+S*S>p}s.mouse("drag",N)}function b(N){it(N.view).on("mousemove.drag mouseup.drag",null),v0(N.view,d),dr(N),s.mouse("end",N)}function x(N,k){if(e.call(this,N,k)){var S=N.changedTouches,M=t.call(this,N,k),P=S.length,I,z;for(I=0;I<P;++I)(z=y(this,M,N,k,S[I].identifier,S[I]))&&(Si(N),z("start",N,S[I]))}}function v(N){var k=N.changedTouches,S=k.length,M,P;for(M=0;M<S;++M)(P=s[k[M].identifier])&&(dr(N),P("drag",N,k[M]))}function w(N){var k=N.changedTouches,S=k.length,M,P;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),M=0;M<S;++M)(P=s[k[M].identifier])&&(Si(N),P("end",N,k[M]))}function y(N,k,S,M,P,I){var z=a.copy(),$=Pt(I||S,k),O,R,A;if((A=n.call(N,new hl("beforestart",{sourceEvent:S,target:m,identifier:P,active:i,x:$[0],y:$[1],dx:0,dy:0,dispatch:z}),M))!=null)return O=A.x-$[0]||0,R=A.y-$[1]||0,function L(D,T,B){var F=$,j;switch(D){case"start":s[P]=L,j=i++;break;case"end":delete s[P],--i;case"drag":$=Pt(B||T,k),j=i;break}z.call(D,N,new hl(D,{sourceEvent:T,subject:A,target:m,identifier:P,active:j,x:$[0]+O,y:$[1]+R,dx:$[0]-F[0],dy:$[1]-F[1],dispatch:z}),M)}}return m.filter=function(N){return arguments.length?(e=typeof N=="function"?N:ns(!!N),m):e},m.container=function(N){return arguments.length?(t=typeof N=="function"?N:ns(N),m):t},m.subject=function(N){return arguments.length?(n=typeof N=="function"?N:ns(N),m):n},m.touchable=function(N){return arguments.length?(o=typeof N=="function"?N:ns(!!N),m):o},m.on=function(){var N=a.on.apply(a,arguments);return N===a?m:N},m.clickDistance=function(N){return arguments.length?(p=(N=+N)*N,m):Math.sqrt(p)},m}function sd(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function N0(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function $o(){}var po=.7,zs=1/po,ur="\\s*([+-]?\\d+)\\s*",fo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",qt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Uz=/^#([0-9a-f]{3,8})$/,Kz=new RegExp(`^rgb\\(${ur},${ur},${ur}\\)$`),Gz=new RegExp(`^rgb\\(${qt},${qt},${qt}\\)$`),Wz=new RegExp(`^rgba\\(${ur},${ur},${ur},${fo}\\)$`),Yz=new RegExp(`^rgba\\(${qt},${qt},${qt},${fo}\\)$`),Zz=new RegExp(`^hsl\\(${fo},${qt},${qt}\\)$`),Xz=new RegExp(`^hsla\\(${fo},${qt},${qt},${fo}\\)$`),Sp={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};sd($o,Hn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Cp,formatHex:Cp,formatHex8:Jz,formatHsl:eB,formatRgb:Mp,toString:Mp});function Cp(){return this.rgb().formatHex()}function Jz(){return this.rgb().formatHex8()}function eB(){return k0(this).formatHsl()}function Mp(){return this.rgb().formatRgb()}function Hn(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Uz.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Ip(t):n===3?new tt(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?rs(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?rs(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=Kz.exec(e))?new tt(t[1],t[2],t[3],1):(t=Gz.exec(e))?new tt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Wz.exec(e))?rs(t[1],t[2],t[3],t[4]):(t=Yz.exec(e))?rs(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Zz.exec(e))?Ep(t[1],t[2]/100,t[3]/100,1):(t=Xz.exec(e))?Ep(t[1],t[2]/100,t[3]/100,t[4]):Sp.hasOwnProperty(e)?Ip(Sp[e]):e==="transparent"?new tt(NaN,NaN,NaN,0):null}function Ip(e){return new tt(e>>16&255,e>>8&255,e&255,1)}function rs(e,t,n,o){return o<=0&&(e=t=n=NaN),new tt(e,t,n,o)}function tB(e){return e instanceof $o||(e=Hn(e)),e?(e=e.rgb(),new tt(e.r,e.g,e.b,e.opacity)):new tt}function gl(e,t,n,o){return arguments.length===1?tB(e):new tt(e,t,n,o??1)}function tt(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}sd(tt,gl,N0($o,{brighter(e){return e=e==null?zs:Math.pow(zs,e),new tt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?po:Math.pow(po,e),new tt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new tt(On(this.r),On(this.g),On(this.b),Bs(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:Ap,formatHex:Ap,formatHex8:nB,formatRgb:Pp,toString:Pp}));function Ap(){return`#${Ln(this.r)}${Ln(this.g)}${Ln(this.b)}`}function nB(){return`#${Ln(this.r)}${Ln(this.g)}${Ln(this.b)}${Ln((isNaN(this.opacity)?1:this.opacity)*255)}`}function Pp(){const e=Bs(this.opacity);return`${e===1?"rgb(":"rgba("}${On(this.r)}, ${On(this.g)}, ${On(this.b)}${e===1?")":`, ${e})`}`}function Bs(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function On(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ln(e){return e=On(e),(e<16?"0":"")+e.toString(16)}function Ep(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Et(e,t,n,o)}function k0(e){if(e instanceof Et)return new Et(e.h,e.s,e.l,e.opacity);if(e instanceof $o||(e=Hn(e)),!e)return new Et;if(e instanceof Et)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,s=Math.min(t,n,o),a=Math.max(t,n,o),i=NaN,l=a-s,c=(a+s)/2;return l?(t===a?i=(n-o)/l+(n<o)*6:n===a?i=(o-t)/l+2:i=(t-n)/l+4,l/=c<.5?a+s:2-a-s,i*=60):l=c>0&&c<1?0:i,new Et(i,l,c,e.opacity)}function rB(e,t,n,o){return arguments.length===1?k0(e):new Et(e,t,n,o??1)}function Et(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}sd(Et,rB,N0($o,{brighter(e){return e=e==null?zs:Math.pow(zs,e),new Et(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?po:Math.pow(po,e),new Et(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,s=2*n-o;return new tt(Ci(e>=240?e-240:e+120,s,o),Ci(e,s,o),Ci(e<120?e+240:e-120,s,o),this.opacity)},clamp(){return new Et($p(this.h),os(this.s),os(this.l),Bs(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=Bs(this.opacity);return`${e===1?"hsl(":"hsla("}${$p(this.h)}, ${os(this.s)*100}%, ${os(this.l)*100}%${e===1?")":`, ${e})`}`}}));function $p(e){return e=(e||0)%360,e<0?e+360:e}function os(e){return Math.max(0,Math.min(1,e||0))}function Ci(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const ad=e=>()=>e;function oB(e,t){return function(n){return e+n*t}}function sB(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function aB(e){return(e=+e)==1?S0:function(t,n){return n-t?sB(t,n,e):ad(isNaN(t)?n:t)}}function S0(e,t){var n=t-e;return n?oB(e,n):ad(isNaN(e)?t:e)}const Fs=(function e(t){var n=aB(t);function o(s,a){var i=n((s=gl(s)).r,(a=gl(a)).r),l=n(s.g,a.g),c=n(s.b,a.b),d=S0(s.opacity,a.opacity);return function(f){return s.r=i(f),s.g=l(f),s.b=c(f),s.opacity=d(f),s+""}}return o.gamma=e,o})(1);function iB(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),s;return function(a){for(s=0;s<n;++s)o[s]=e[s]*(1-a)+t[s]*a;return o}}function lB(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function cB(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,s=new Array(o),a=new Array(n),i;for(i=0;i<o;++i)s[i]=to(e[i],t[i]);for(;i<n;++i)a[i]=t[i];return function(l){for(i=0;i<o;++i)a[i]=s[i](l);return a}}function dB(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function jt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function uB(e,t){var n={},o={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=to(e[s],t[s]):o[s]=t[s];return function(a){for(s in n)o[s]=n[s](a);return o}}var bl=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Mi=new RegExp(bl.source,"g");function pB(e){return function(){return e}}function fB(e){return function(t){return e(t)+""}}function C0(e,t){var n=bl.lastIndex=Mi.lastIndex=0,o,s,a,i=-1,l=[],c=[];for(e=e+"",t=t+"";(o=bl.exec(e))&&(s=Mi.exec(t));)(a=s.index)>n&&(a=t.slice(n,a),l[i]?l[i]+=a:l[++i]=a),(o=o[0])===(s=s[0])?l[i]?l[i]+=s:l[++i]=s:(l[++i]=null,c.push({i,x:jt(o,s)})),n=Mi.lastIndex;return n<t.length&&(a=t.slice(n),l[i]?l[i]+=a:l[++i]=a),l.length<2?c[0]?fB(c[0].x):pB(t):(t=c.length,function(d){for(var f=0,p;f<t;++f)l[(p=c[f]).i]=p.x(d);return l.join("")})}function to(e,t){var n=typeof t,o;return t==null||n==="boolean"?ad(t):(n==="number"?jt:n==="string"?(o=Hn(t))?(t=o,Fs):C0:t instanceof Hn?Fs:t instanceof Date?dB:lB(t)?iB:Array.isArray(t)?cB:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?uB:jt)(e,t)}var _p=180/Math.PI,xl={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function M0(e,t,n,o,s,a){var i,l,c;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(l=Math.sqrt(n*n+o*o))&&(n/=l,o/=l,c/=l),e*o<t*n&&(e=-e,t=-t,c=-c,i=-i),{translateX:s,translateY:a,rotate:Math.atan2(t,e)*_p,skewX:Math.atan(c)*_p,scaleX:i,scaleY:l}}var ss;function mB(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?xl:M0(t.a,t.b,t.c,t.d,t.e,t.f)}function hB(e){return e==null||(ss||(ss=document.createElementNS("http://www.w3.org/2000/svg","g")),ss.setAttribute("transform",e),!(e=ss.transform.baseVal.consolidate()))?xl:(e=e.matrix,M0(e.a,e.b,e.c,e.d,e.e,e.f))}function I0(e,t,n,o){function s(d){return d.length?d.pop()+" ":""}function a(d,f,p,m,h,g){if(d!==p||f!==m){var b=h.push("translate(",null,t,null,n);g.push({i:b-4,x:jt(d,p)},{i:b-2,x:jt(f,m)})}else(p||m)&&h.push("translate("+p+t+m+n)}function i(d,f,p,m){d!==f?(d-f>180?f+=360:f-d>180&&(d+=360),m.push({i:p.push(s(p)+"rotate(",null,o)-2,x:jt(d,f)})):f&&p.push(s(p)+"rotate("+f+o)}function l(d,f,p,m){d!==f?m.push({i:p.push(s(p)+"skewX(",null,o)-2,x:jt(d,f)}):f&&p.push(s(p)+"skewX("+f+o)}function c(d,f,p,m,h,g){if(d!==p||f!==m){var b=h.push(s(h)+"scale(",null,",",null,")");g.push({i:b-4,x:jt(d,p)},{i:b-2,x:jt(f,m)})}else(p!==1||m!==1)&&h.push(s(h)+"scale("+p+","+m+")")}return function(d,f){var p=[],m=[];return d=e(d),f=e(f),a(d.translateX,d.translateY,f.translateX,f.translateY,p,m),i(d.rotate,f.rotate,p,m),l(d.skewX,f.skewX,p,m),c(d.scaleX,d.scaleY,f.scaleX,f.scaleY,p,m),d=f=null,function(h){for(var g=-1,b=m.length,x;++g<b;)p[(x=m[g]).i]=x.x(h);return p.join("")}}}var gB=I0(mB,"px, ","px)","deg)"),bB=I0(hB,", ",")",")"),xB=1e-12;function Dp(e){return((e=Math.exp(e))+1/e)/2}function yB(e){return((e=Math.exp(e))-1/e)/2}function vB(e){return((e=Math.exp(2*e))-1)/(e+1)}const bs=(function e(t,n,o){function s(a,i){var l=a[0],c=a[1],d=a[2],f=i[0],p=i[1],m=i[2],h=f-l,g=p-c,b=h*h+g*g,x,v;if(b<xB)v=Math.log(m/d)/t,x=function(M){return[l+M*h,c+M*g,d*Math.exp(t*M*v)]};else{var w=Math.sqrt(b),y=(m*m-d*d+o*b)/(2*d*n*w),N=(m*m-d*d-o*b)/(2*m*n*w),k=Math.log(Math.sqrt(y*y+1)-y),S=Math.log(Math.sqrt(N*N+1)-N);v=(S-k)/t,x=function(M){var P=M*v,I=Dp(k),z=d/(n*w)*(I*vB(t*P+k)-yB(k));return[l+z*h,c+z*g,d*I/Dp(t*P+k)]}}return x.duration=v*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 vr=0,Ur=0,Hr=0,A0=1e3,js,Kr,Hs=0,Vn=0,Aa=0,mo=typeof performance=="object"&&performance.now?performance:Date,P0=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function id(){return Vn||(P0(wB),Vn=mo.now()+Aa)}function wB(){Vn=0}function Vs(){this._call=this._time=this._next=null}Vs.prototype=E0.prototype={constructor:Vs,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?id():+n)+(t==null?0:+t),!this._next&&Kr!==this&&(Kr?Kr._next=this:js=this,Kr=this),this._call=e,this._time=n,yl()},stop:function(){this._call&&(this._call=null,this._time=1/0,yl())}};function E0(e,t,n){var o=new Vs;return o.restart(e,t,n),o}function NB(){id(),++vr;for(var e=js,t;e;)(t=Vn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--vr}function Lp(){Vn=(Hs=mo.now())+Aa,vr=Ur=0;try{NB()}finally{vr=0,SB(),Vn=0}}function kB(){var e=mo.now(),t=e-Hs;t>A0&&(Aa-=t,Hs=e)}function SB(){for(var e,t=js,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:js=n);Kr=e,yl(o)}function yl(e){if(!vr){Ur&&(Ur=clearTimeout(Ur));var t=e-Vn;t>24?(e<1/0&&(Ur=setTimeout(Lp,e-mo.now()-Aa)),Hr&&(Hr=clearInterval(Hr))):(Hr||(Hs=mo.now(),Hr=setInterval(kB,A0)),vr=1,P0(Lp))}}function Tp(e,t,n){var o=new Vs;return t=t==null?0:+t,o.restart(s=>{o.stop(),e(s+t)},t,n),o}var CB=Ma("start","end","cancel","interrupt"),MB=[],$0=0,Rp=1,vl=2,xs=3,Op=4,wl=5,ys=6;function Pa(e,t,n,o,s,a){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;IB(e,n,{name:t,index:o,group:s,on:CB,tween:MB,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:$0})}function ld(e,t){var n=Ot(e,t);if(n.state>$0)throw new Error("too late; already scheduled");return n}function Kt(e,t){var n=Ot(e,t);if(n.state>xs)throw new Error("too late; already running");return n}function Ot(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function IB(e,t,n){var o=e.__transition,s;o[t]=n,n.timer=E0(a,0,n.time);function a(d){n.state=Rp,n.timer.restart(i,n.delay,n.time),n.delay<=d&&i(d-n.delay)}function i(d){var f,p,m,h;if(n.state!==Rp)return c();for(f in o)if(h=o[f],h.name===n.name){if(h.state===xs)return Tp(i);h.state===Op?(h.state=ys,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[f]):+f<t&&(h.state=ys,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[f])}if(Tp(function(){n.state===xs&&(n.state=Op,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=vl,n.on.call("start",e,e.__data__,n.index,n.group),n.state===vl){for(n.state=xs,s=new Array(m=n.tween.length),f=0,p=-1;f<m;++f)(h=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(s[++p]=h);s.length=p+1}}function l(d){for(var f=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(c),n.state=wl,1),p=-1,m=s.length;++p<m;)s[p].call(e,f);n.state===wl&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=ys,n.timer.stop(),delete o[t];for(var d in o)return;delete e.__transition}}function vs(e,t){var n=e.__transition,o,s,a=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((o=n[i]).name!==t){a=!1;continue}s=o.state>vl&&o.state<wl,o.state=ys,o.timer.stop(),o.on.call(s?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[i]}a&&delete e.__transition}}function AB(e){return this.each(function(){vs(this,e)})}function PB(e,t){var n,o;return function(){var s=Kt(this,e),a=s.tween;if(a!==n){o=n=a;for(var i=0,l=o.length;i<l;++i)if(o[i].name===t){o=o.slice(),o.splice(i,1);break}}s.tween=o}}function EB(e,t,n){var o,s;if(typeof n!="function")throw new Error;return function(){var a=Kt(this,e),i=a.tween;if(i!==o){s=(o=i).slice();for(var l={name:t,value:n},c=0,d=s.length;c<d;++c)if(s[c].name===t){s[c]=l;break}c===d&&s.push(l)}a.tween=s}}function $B(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=Ot(this.node(),n).tween,s=0,a=o.length,i;s<a;++s)if((i=o[s]).name===e)return i.value;return null}return this.each((t==null?PB:EB)(n,e,t))}function cd(e,t,n){var o=e._id;return e.each(function(){var s=Kt(this,o);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Ot(s,o).value[t]}}function _0(e,t){var n;return(typeof t=="number"?jt:t instanceof Hn?Fs:(n=Hn(t))?(t=n,Fs):C0)(e,t)}function _B(e){return function(){this.removeAttribute(e)}}function DB(e){return function(){this.removeAttributeNS(e.space,e.local)}}function LB(e,t,n){var o,s=n+"",a;return function(){var i=this.getAttribute(e);return i===s?null:i===o?a:a=t(o=i,n)}}function TB(e,t,n){var o,s=n+"",a;return function(){var i=this.getAttributeNS(e.space,e.local);return i===s?null:i===o?a:a=t(o=i,n)}}function RB(e,t,n){var o,s,a;return function(){var i,l=n(this),c;return l==null?void this.removeAttribute(e):(i=this.getAttribute(e),c=l+"",i===c?null:i===o&&c===s?a:(s=c,a=t(o=i,l)))}}function OB(e,t,n){var o,s,a;return function(){var i,l=n(this),c;return l==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),c=l+"",i===c?null:i===o&&c===s?a:(s=c,a=t(o=i,l)))}}function zB(e,t){var n=Ia(e),o=n==="transform"?bB:_0;return this.attrTween(e,typeof t=="function"?(n.local?OB:RB)(n,o,cd(this,"attr."+e,t)):t==null?(n.local?DB:_B)(n):(n.local?TB:LB)(n,o,t))}function BB(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function FB(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function jB(e,t){var n,o;function s(){var a=t.apply(this,arguments);return a!==o&&(n=(o=a)&&FB(e,a)),n}return s._value=t,s}function HB(e,t){var n,o;function s(){var a=t.apply(this,arguments);return a!==o&&(n=(o=a)&&BB(e,a)),n}return s._value=t,s}function VB(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=Ia(e);return this.tween(n,(o.local?jB:HB)(o,t))}function qB(e,t){return function(){ld(this,e).delay=+t.apply(this,arguments)}}function QB(e,t){return t=+t,function(){ld(this,e).delay=t}}function UB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?qB:QB)(t,e)):Ot(this.node(),t).delay}function KB(e,t){return function(){Kt(this,e).duration=+t.apply(this,arguments)}}function GB(e,t){return t=+t,function(){Kt(this,e).duration=t}}function WB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?KB:GB)(t,e)):Ot(this.node(),t).duration}function YB(e,t){if(typeof t!="function")throw new Error;return function(){Kt(this,e).ease=t}}function ZB(e){var t=this._id;return arguments.length?this.each(YB(t,e)):Ot(this.node(),t).ease}function XB(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Kt(this,e).ease=n}}function JB(e){if(typeof e!="function")throw new Error;return this.each(XB(this._id,e))}function eF(e){typeof e!="function"&&(e=c0(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=o[s]=[],c,d=0;d<i;++d)(c=a[d])&&e.call(c,c.__data__,d,a)&&l.push(c);return new ln(o,this._parents,this._name,this._id)}function tF(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,s=n.length,a=Math.min(o,s),i=new Array(o),l=0;l<a;++l)for(var c=t[l],d=n[l],f=c.length,p=i[l]=new Array(f),m,h=0;h<f;++h)(m=c[h]||d[h])&&(p[h]=m);for(;l<o;++l)i[l]=t[l];return new ln(i,this._parents,this._name,this._id)}function nF(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 rF(e,t,n){var o,s,a=nF(t)?ld:Kt;return function(){var i=a(this,e),l=i.on;l!==o&&(s=(o=l).copy()).on(t,n),i.on=s}}function oF(e,t){var n=this._id;return arguments.length<2?Ot(this.node(),n).on.on(e):this.each(rF(n,e,t))}function sF(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function aF(){return this.on("end.remove",sF(this._id))}function iF(e){var t=this._name,n=this._id;typeof e!="function"&&(e=rd(e));for(var o=this._groups,s=o.length,a=new Array(s),i=0;i<s;++i)for(var l=o[i],c=l.length,d=a[i]=new Array(c),f,p,m=0;m<c;++m)(f=l[m])&&(p=e.call(f,f.__data__,m,l))&&("__data__"in f&&(p.__data__=f.__data__),d[m]=p,Pa(d[m],t,n,m,d,Ot(f,n)));return new ln(a,this._parents,t,n)}function lF(e){var t=this._name,n=this._id;typeof e!="function"&&(e=l0(e));for(var o=this._groups,s=o.length,a=[],i=[],l=0;l<s;++l)for(var c=o[l],d=c.length,f,p=0;p<d;++p)if(f=c[p]){for(var m=e.call(f,f.__data__,p,c),h,g=Ot(f,n),b=0,x=m.length;b<x;++b)(h=m[b])&&Pa(h,t,n,b,m,g);a.push(m),i.push(f)}return new ln(a,i,t,n)}var cF=Eo.prototype.constructor;function dF(){return new cF(this._groups,this._parents)}function uF(e,t){var n,o,s;return function(){var a=yr(this,e),i=(this.style.removeProperty(e),yr(this,e));return a===i?null:a===n&&i===o?s:s=t(n=a,o=i)}}function D0(e){return function(){this.style.removeProperty(e)}}function pF(e,t,n){var o,s=n+"",a;return function(){var i=yr(this,e);return i===s?null:i===o?a:a=t(o=i,n)}}function fF(e,t,n){var o,s,a;return function(){var i=yr(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),yr(this,e))),i===c?null:i===o&&c===s?a:(s=c,a=t(o=i,l))}}function mF(e,t){var n,o,s,a="style."+t,i="end."+a,l;return function(){var c=Kt(this,e),d=c.on,f=c.value[a]==null?l||(l=D0(t)):void 0;(d!==n||s!==f)&&(o=(n=d).copy()).on(i,s=f),c.on=o}}function hF(e,t,n){var o=(e+="")=="transform"?gB:_0;return t==null?this.styleTween(e,uF(e,o)).on("end.style."+e,D0(e)):typeof t=="function"?this.styleTween(e,fF(e,o,cd(this,"style."+e,t))).each(mF(this._id,e)):this.styleTween(e,pF(e,o,t),n).on("end.style."+e,null)}function gF(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function bF(e,t,n){var o,s;function a(){var i=t.apply(this,arguments);return i!==s&&(o=(s=i)&&gF(e,i,n)),o}return a._value=t,a}function xF(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,bF(e,t,n??""))}function yF(e){return function(){this.textContent=e}}function vF(e){return function(){var t=e(this);this.textContent=t??""}}function wF(e){return this.tween("text",typeof e=="function"?vF(cd(this,"text",e)):yF(e==null?"":e+""))}function NF(e){return function(t){this.textContent=e.call(this,t)}}function kF(e){var t,n;function o(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&NF(s)),t}return o._value=e,o}function SF(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,kF(e))}function CF(){for(var e=this._name,t=this._id,n=L0(),o=this._groups,s=o.length,a=0;a<s;++a)for(var i=o[a],l=i.length,c,d=0;d<l;++d)if(c=i[d]){var f=Ot(c,t);Pa(c,e,n,d,i,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new ln(o,this._parents,e,n)}function MF(){var e,t,n=this,o=n._id,s=n.size();return new Promise(function(a,i){var l={value:i},c={value:function(){--s===0&&a()}};n.each(function(){var d=Kt(this,o),f=d.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),d.on=t}),s===0&&a()})}var IF=0;function ln(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function L0(){return++IF}var Yt=Eo.prototype;ln.prototype={constructor:ln,select:iF,selectAll:lF,selectChild:Yt.selectChild,selectChildren:Yt.selectChildren,filter:eF,merge:tF,selection:dF,transition:CF,call:Yt.call,nodes:Yt.nodes,node:Yt.node,size:Yt.size,empty:Yt.empty,each:Yt.each,on:oF,attr:zB,attrTween:VB,style:hF,styleTween:xF,text:wF,textTween:SF,remove:aF,tween:$B,delay:UB,duration:WB,ease:ZB,easeVarying:JB,end:MF,[Symbol.iterator]:Yt[Symbol.iterator]};function AF(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var PF={time:null,delay:0,duration:250,ease:AF};function EF(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 $F(e){var t,n;e instanceof ln?(t=e._id,e=e._name):(t=L0(),(n=PF).time=id(),e=e==null?null:e+"");for(var o=this._groups,s=o.length,a=0;a<s;++a)for(var i=o[a],l=i.length,c,d=0;d<l;++d)(c=i[d])&&Pa(c,e,t,d,i,n||EF(c,t));return new ln(o,this._parents,e,t)}Eo.prototype.interrupt=AB;Eo.prototype.transition=$F;const as=e=>()=>e;function _F(e,{sourceEvent:t,target:n,transform:o,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:s}})}function Jt(e,t,n){this.k=e,this.x=t,this.y=n}Jt.prototype={constructor:Jt,scale:function(e){return e===1?this:new Jt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Jt(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Ea=new Jt(1,0,0);T0.prototype=Jt.prototype;function T0(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ea;return e.__zoom}function Ii(e){e.stopImmediatePropagation()}function Vr(e){e.preventDefault(),e.stopImmediatePropagation()}function DF(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function LF(){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 zp(){return this.__zoom||Ea}function TF(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function RF(){return navigator.maxTouchPoints||"ontouchstart"in this}function OF(e,t,n){var o=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s),i>a?(a+i)/2:Math.min(0,a)||Math.max(0,i))}function R0(){var e=DF,t=LF,n=OF,o=TF,s=RF,a=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,c=bs,d=Ma("start","zoom","end"),f,p,m,h=500,g=150,b=0,x=10;function v(A){A.property("__zoom",zp).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",z).filter(s).on("touchstart.zoom",$).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",R).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(A,L,D,T){var B=A.selection?A.selection():A;B.property("__zoom",zp),A!==B?k(A,L,D,T):B.interrupt().each(function(){S(this,arguments).event(T).start().zoom(null,typeof L=="function"?L.apply(this,arguments):L).end()})},v.scaleBy=function(A,L,D,T){v.scaleTo(A,function(){var B=this.__zoom.k,F=typeof L=="function"?L.apply(this,arguments):L;return B*F},D,T)},v.scaleTo=function(A,L,D,T){v.transform(A,function(){var B=t.apply(this,arguments),F=this.__zoom,j=D==null?N(B):typeof D=="function"?D.apply(this,arguments):D,H=F.invert(j),E=typeof L=="function"?L.apply(this,arguments):L;return n(y(w(F,E),j,H),B,i)},D,T)},v.translateBy=function(A,L,D,T){v.transform(A,function(){return n(this.__zoom.translate(typeof L=="function"?L.apply(this,arguments):L,typeof D=="function"?D.apply(this,arguments):D),t.apply(this,arguments),i)},null,T)},v.translateTo=function(A,L,D,T,B){v.transform(A,function(){var F=t.apply(this,arguments),j=this.__zoom,H=T==null?N(F):typeof T=="function"?T.apply(this,arguments):T;return n(Ea.translate(H[0],H[1]).scale(j.k).translate(typeof L=="function"?-L.apply(this,arguments):-L,typeof D=="function"?-D.apply(this,arguments):-D),F,i)},T,B)};function w(A,L){return L=Math.max(a[0],Math.min(a[1],L)),L===A.k?A:new Jt(L,A.x,A.y)}function y(A,L,D){var T=L[0]-D[0]*A.k,B=L[1]-D[1]*A.k;return T===A.x&&B===A.y?A:new Jt(A.k,T,B)}function N(A){return[(+A[0][0]+ +A[1][0])/2,(+A[0][1]+ +A[1][1])/2]}function k(A,L,D,T){A.on("start.zoom",function(){S(this,arguments).event(T).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(T).end()}).tween("zoom",function(){var B=this,F=arguments,j=S(B,F).event(T),H=t.apply(B,F),E=D==null?N(H):typeof D=="function"?D.apply(B,F):D,Q=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),K=B.__zoom,Y=typeof L=="function"?L.apply(B,F):L,re=c(K.invert(E).concat(Q/K.k),Y.invert(E).concat(Q/Y.k));return function(te){if(te===1)te=Y;else{var X=re(te),oe=Q/X[2];te=new Jt(oe,E[0]-X[0]*oe,E[1]-X[1]*oe)}j.zoom(null,te)}})}function S(A,L,D){return!D&&A.__zooming||new M(A,L)}function M(A,L){this.that=A,this.args=L,this.active=0,this.sourceEvent=null,this.extent=t.apply(A,L),this.taps=0}M.prototype={event:function(A){return A&&(this.sourceEvent=A),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(A,L){return this.mouse&&A!=="mouse"&&(this.mouse[1]=L.invert(this.mouse[0])),this.touch0&&A!=="touch"&&(this.touch0[1]=L.invert(this.touch0[0])),this.touch1&&A!=="touch"&&(this.touch1[1]=L.invert(this.touch1[0])),this.that.__zoom=L,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(A){var L=it(this.that).datum();d.call(A,this.that,new _F(A,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:d}),L)}};function P(A,...L){if(!e.apply(this,arguments))return;var D=S(this,L).event(A),T=this.__zoom,B=Math.max(a[0],Math.min(a[1],T.k*Math.pow(2,o.apply(this,arguments)))),F=Pt(A);if(D.wheel)(D.mouse[0][0]!==F[0]||D.mouse[0][1]!==F[1])&&(D.mouse[1]=T.invert(D.mouse[0]=F)),clearTimeout(D.wheel);else{if(T.k===B)return;D.mouse=[F,T.invert(F)],vs(this),D.start()}Vr(A),D.wheel=setTimeout(j,g),D.zoom("mouse",n(y(w(T,B),D.mouse[0],D.mouse[1]),D.extent,i));function j(){D.wheel=null,D.end()}}function I(A,...L){if(m||!e.apply(this,arguments))return;var D=A.currentTarget,T=S(this,L,!0).event(A),B=it(A.view).on("mousemove.zoom",E,!0).on("mouseup.zoom",Q,!0),F=Pt(A,D),j=A.clientX,H=A.clientY;y0(A.view),Ii(A),T.mouse=[F,this.__zoom.invert(F)],vs(this),T.start();function E(K){if(Vr(K),!T.moved){var Y=K.clientX-j,re=K.clientY-H;T.moved=Y*Y+re*re>b}T.event(K).zoom("mouse",n(y(T.that.__zoom,T.mouse[0]=Pt(K,D),T.mouse[1]),T.extent,i))}function Q(K){B.on("mousemove.zoom mouseup.zoom",null),v0(K.view,T.moved),Vr(K),T.event(K).end()}}function z(A,...L){if(e.apply(this,arguments)){var D=this.__zoom,T=Pt(A.changedTouches?A.changedTouches[0]:A,this),B=D.invert(T),F=D.k*(A.shiftKey?.5:2),j=n(y(w(D,F),T,B),t.apply(this,L),i);Vr(A),l>0?it(this).transition().duration(l).call(k,j,T,A):it(this).call(v.transform,j,T,A)}}function $(A,...L){if(e.apply(this,arguments)){var D=A.touches,T=D.length,B=S(this,L,A.changedTouches.length===T).event(A),F,j,H,E;for(Ii(A),j=0;j<T;++j)H=D[j],E=Pt(H,this),E=[E,this.__zoom.invert(E),H.identifier],B.touch0?!B.touch1&&B.touch0[2]!==E[2]&&(B.touch1=E,B.taps=0):(B.touch0=E,F=!0,B.taps=1+!!f);f&&(f=clearTimeout(f)),F&&(B.taps<2&&(p=E[0],f=setTimeout(function(){f=null},h)),vs(this),B.start())}}function O(A,...L){if(this.__zooming){var D=S(this,L).event(A),T=A.changedTouches,B=T.length,F,j,H,E;for(Vr(A),F=0;F<B;++F)j=T[F],H=Pt(j,this),D.touch0&&D.touch0[2]===j.identifier?D.touch0[0]=H:D.touch1&&D.touch1[2]===j.identifier&&(D.touch1[0]=H);if(j=D.that.__zoom,D.touch1){var Q=D.touch0[0],K=D.touch0[1],Y=D.touch1[0],re=D.touch1[1],te=(te=Y[0]-Q[0])*te+(te=Y[1]-Q[1])*te,X=(X=re[0]-K[0])*X+(X=re[1]-K[1])*X;j=w(j,Math.sqrt(te/X)),H=[(Q[0]+Y[0])/2,(Q[1]+Y[1])/2],E=[(K[0]+re[0])/2,(K[1]+re[1])/2]}else if(D.touch0)H=D.touch0[0],E=D.touch0[1];else return;D.zoom("touch",n(y(j,H,E),D.extent,i))}}function R(A,...L){if(this.__zooming){var D=S(this,L).event(A),T=A.changedTouches,B=T.length,F,j;for(Ii(A),m&&clearTimeout(m),m=setTimeout(function(){m=null},h),F=0;F<B;++F)j=T[F],D.touch0&&D.touch0[2]===j.identifier?delete D.touch0:D.touch1&&D.touch1[2]===j.identifier&&delete D.touch1;if(D.touch1&&!D.touch0&&(D.touch0=D.touch1,delete D.touch1),D.touch0)D.touch0[1]=this.__zoom.invert(D.touch0[0]);else if(D.end(),D.taps===2&&(j=Pt(j,this),Math.hypot(p[0]-j[0],p[1]-j[1])<x)){var H=it(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return v.wheelDelta=function(A){return arguments.length?(o=typeof A=="function"?A:as(+A),v):o},v.filter=function(A){return arguments.length?(e=typeof A=="function"?A:as(!!A),v):e},v.touchable=function(A){return arguments.length?(s=typeof A=="function"?A:as(!!A),v):s},v.extent=function(A){return arguments.length?(t=typeof A=="function"?A:as([[+A[0][0],+A[0][1]],[+A[1][0],+A[1][1]]]),v):t},v.scaleExtent=function(A){return arguments.length?(a[0]=+A[0],a[1]=+A[1],v):[a[0],a[1]]},v.translateExtent=function(A){return arguments.length?(i[0][0]=+A[0][0],i[1][0]=+A[1][0],i[0][1]=+A[0][1],i[1][1]=+A[1][1],v):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},v.constrain=function(A){return arguments.length?(n=A,v):n},v.duration=function(A){return arguments.length?(l=+A,v):l},v.interpolate=function(A){return arguments.length?(c=A,v):c},v.on=function(){var A=d.on.apply(d,arguments);return A===d?v:A},v.clickDistance=function(A){return arguments.length?(b=(A=+A)*A,v):Math.sqrt(b)},v.tapDistance=function(A){return arguments.length?(x=+A,v):x},v}const Qt={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ho=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],O0=["Enter"," ","Escape"],z0={"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 wr;(function(e){e.Strict="strict",e.Loose="loose"})(wr||(wr={}));var zn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(zn||(zn={}));var go;(function(e){e.Partial="partial",e.Full="full"})(go||(go={}));const B0={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var bn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(bn||(bn={}));var qs;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(qs||(qs={}));var we;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(we||(we={}));const Bp={[we.Left]:we.Right,[we.Right]:we.Left,[we.Top]:we.Bottom,[we.Bottom]:we.Top};function F0(e){return e===null?null:e?"valid":"invalid"}const j0=e=>"id"in e&&"source"in e&&"target"in e,zF=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),dd=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),_o=(e,t=[0,0])=>{const{width:n,height:o}=pn(e),s=e.origin??t,a=n*s[0],i=o*s[1];return{x:e.position.x-a,y:e.position.y-i}},BF=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,s)=>{const a=typeof s=="string";let i=!t.nodeLookup&&!a?s:void 0;t.nodeLookup&&(i=a?t.nodeLookup.get(s):dd(s)?s:t.nodeLookup.get(s.id));const l=i?Qs(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return $a(o,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return _a(n)},Do=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=$a(n,Qs(s)),o=!0)}),o?_a(n):{x:0,y:0,width:0,height:0}},ud=(e,t,[n,o,s]=[0,0,1],a=!1,i=!1)=>{const l={...To(t,[n,o,s]),width:t.width/s,height:t.height/s},c=[];for(const d of e.values()){const{measured:f,selectable:p=!0,hidden:m=!1}=d;if(i&&!p||m)continue;const h=f.width??d.width??d.initialWidth??null,g=f.height??d.height??d.initialHeight??null,b=bo(l,kr(d)),x=(h??0)*(g??0),v=a&&b>0;(!d.internals.handleBounds||v||b>=x||d.dragging)&&c.push(d)}return c},FF=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function jF(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&(t?.includeHiddenNodes||!s.hidden)&&(!o||o.has(s.id))&&n.set(s.id,s)}),n}async function HF({nodes:e,width:t,height:n,panZoom:o,minZoom:s,maxZoom:a},i){if(e.size===0)return Promise.resolve(!0);const l=jF(e,i),c=Do(l),d=pd(c,t,n,i?.minZoom??s,i?.maxZoom??a,i?.padding??.1);return await o.setViewport(d,{duration:i?.duration,ease:i?.ease,interpolate:i?.interpolate}),Promise.resolve(!0)}function H0({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:s,onError:a}){const i=n.get(e),l=i.parentId?n.get(i.parentId):void 0,{x:c,y:d}=l?l.internals.positionAbsolute:{x:0,y:0},f=i.origin??o;let p=i.extent||s;if(i.extent==="parent"&&!i.expandParent)if(!l)a?.("005",Qt.error005());else{const h=l.measured.width,g=l.measured.height;h&&g&&(p=[[c,d],[c+h,d+g]])}else l&&Sr(i.extent)&&(p=[[i.extent[0][0]+c,i.extent[0][1]+d],[i.extent[1][0]+c,i.extent[1][1]+d]]);const m=Sr(p)?qn(t,p,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&a?.("015",Qt.error015()),{position:{x:m.x-c+(i.measured.width??0)*f[0],y:m.y-d+(i.measured.height??0)*f[1]},positionAbsolute:m}}async function VF({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:s}){const a=new Set(e.map(m=>m.id)),i=[];for(const m of n){if(m.deletable===!1)continue;const h=a.has(m.id),g=!h&&m.parentId&&i.find(b=>b.id===m.parentId);(h||g)&&i.push(m)}const l=new Set(t.map(m=>m.id)),c=o.filter(m=>m.deletable!==!1),f=FF(i,c);for(const m of c)l.has(m.id)&&!f.find(g=>g.id===m.id)&&f.push(m);if(!s)return{edges:f,nodes:i};const p=await s({nodes:i,edges:f});return typeof p=="boolean"?p?{edges:f,nodes:i}:{edges:[],nodes:[]}:p}const Nr=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),qn=(e={x:0,y:0},t,n)=>({x:Nr(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Nr(e.y,t[0][1],t[1][1]-(n?.height??0))});function V0(e,t,n){const{width:o,height:s}=pn(n),{x:a,y:i}=n.internals.positionAbsolute;return qn(e,[[a,i],[a+o,i+s]],t)}const Fp=(e,t,n)=>e<t?Nr(Math.abs(e-t),1,t)/t:e>n?-Nr(Math.abs(e-n),1,t)/t:0,q0=(e,t,n=15,o=40)=>{const s=Fp(e.x,o,t.width-o)*n,a=Fp(e.y,o,t.height-o)*n;return[s,a]},$a=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Nl=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),_a=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),kr=(e,t=[0,0])=>{const{x:n,y:o}=dd(e)?e.internals.positionAbsolute:_o(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Qs=(e,t=[0,0])=>{const{x:n,y:o}=dd(e)?e.internals.positionAbsolute:_o(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},Q0=(e,t)=>_a($a(Nl(e),Nl(t))),bo=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},jp=e=>$t(e.width)&&$t(e.height)&&$t(e.x)&&$t(e.y),$t=e=>!isNaN(e)&&isFinite(e),qF=(e,t)=>{},Lo=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),To=({x:e,y:t},[n,o,s],a=!1,i=[1,1])=>{const l={x:(e-n)/s,y:(t-o)/s};return a?Lo(l,i):l},Us=({x:e,y:t},[n,o,s])=>({x:e*s+n,y:t*s+o});function rr(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 QF(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=rr(e,n),s=rr(e,t);return{top:o,right:s,bottom:o,left:s,x:s*2,y:o*2}}if(typeof e=="object"){const o=rr(e.top??e.y??0,n),s=rr(e.bottom??e.y??0,n),a=rr(e.left??e.x??0,t),i=rr(e.right??e.x??0,t);return{top:o,right:i,bottom:s,left:a,x:a+i,y:o+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function UF(e,t,n,o,s,a){const{x:i,y:l}=Us(e,[t,n,o]),{x:c,y:d}=Us({x:e.x+e.width,y:e.y+e.height},[t,n,o]),f=s-c,p=a-d;return{left:Math.floor(i),top:Math.floor(l),right:Math.floor(f),bottom:Math.floor(p)}}const pd=(e,t,n,o,s,a)=>{const i=QF(a,t,n),l=(t-i.x)/e.width,c=(n-i.y)/e.height,d=Math.min(l,c),f=Nr(d,o,s),p=e.x+e.width/2,m=e.y+e.height/2,h=t/2-p*f,g=n/2-m*f,b=UF(e,h,g,f,t,n),x={left:Math.min(b.left-i.left,0),top:Math.min(b.top-i.top,0),right:Math.min(b.right-i.right,0),bottom:Math.min(b.bottom-i.bottom,0)};return{x:h-x.left+x.right,y:g-x.top+x.bottom,zoom:f}},xo=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Sr(e){return e!=null&&e!=="parent"}function pn(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function U0(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function K0(e,t={width:0,height:0},n,o,s){const a={...e},i=o.get(n);if(i){const l=i.origin||s;a.x+=i.internals.positionAbsolute.x-(t.width??0)*l[0],a.y+=i.internals.positionAbsolute.y-(t.height??0)*l[1]}return a}function Hp(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function KF(){let e,t;return{promise:new Promise((o,s)=>{e=o,t=s}),resolve:e,reject:t}}function GF(e){return{...z0,...e||{}}}function no(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:s}){const{x:a,y:i}=_t(e),l=To({x:a-(s?.left??0),y:i-(s?.top??0)},o),{x:c,y:d}=n?Lo(l,t):l;return{xSnapped:c,ySnapped:d,...l}}const fd=e=>({width:e.offsetWidth,height:e.offsetHeight}),G0=e=>e?.getRootNode?.()||window?.document,WF=["INPUT","SELECT","TEXTAREA"];function W0(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:WF.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Y0=e=>"clientX"in e,_t=(e,t)=>{const n=Y0(e),o=n?e.clientX:e.touches?.[0].clientX,s=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:s-(t?.top??0)}},Vp=(e,t,n,o,s)=>{const a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(i=>{const l=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:s,position:i.getAttribute("data-handlepos"),x:(l.left-n.left)/o,y:(l.top-n.top)/o,...fd(i)}})};function Z0({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:s,sourceControlY:a,targetControlX:i,targetControlY:l}){const c=e*.125+s*.375+i*.375+n*.125,d=t*.125+a*.375+l*.375+o*.125,f=Math.abs(c-e),p=Math.abs(d-t);return[c,d,f,p]}function is(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function qp({pos:e,x1:t,y1:n,x2:o,y2:s,c:a}){switch(e){case we.Left:return[t-is(t-o,a),n];case we.Right:return[t+is(o-t,a),n];case we.Top:return[t,n-is(n-s,a)];case we.Bottom:return[t,n+is(s-n,a)]}}function X0({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:o,targetY:s,targetPosition:a=we.Top,curvature:i=.25}){const[l,c]=qp({pos:n,x1:e,y1:t,x2:o,y2:s,c:i}),[d,f]=qp({pos:a,x1:o,y1:s,x2:e,y2:t,c:i}),[p,m,h,g]=Z0({sourceX:e,sourceY:t,targetX:o,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:f});return[`M${e},${t} C${l},${c} ${d},${f} ${o},${s}`,p,m,h,g]}function J0({sourceX:e,sourceY:t,targetX:n,targetY:o}){const s=Math.abs(n-e)/2,a=n<e?n+s:n-s,i=Math.abs(o-t)/2,l=o<t?o+i:o-i;return[a,l,s,i]}function YF({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:s=!1,zIndexMode:a="basic"}){if(a==="manual")return o;const i=s&&n?o+1e3:o,l=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return i+l}function ZF({sourceNode:e,targetNode:t,width:n,height:o,transform:s}){const a=$a(Qs(e),Qs(t));a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1);const i={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:o/s[2]};return bo(i,_a(a))>0}const XF=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,JF=(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)),ej=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||XF;let s;return j0(e)?s={...e}:s={...e,id:o(e)},JF(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function ev({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[s,a,i,l]=J0({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,s,a,i,l]}const Qp={[we.Left]:{x:-1,y:0},[we.Right]:{x:1,y:0},[we.Top]:{x:0,y:-1},[we.Bottom]:{x:0,y:1}},tj=({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},Up=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function nj({source:e,sourcePosition:t=we.Bottom,target:n,targetPosition:o=we.Top,center:s,offset:a,stepPosition:i}){const l=Qp[t],c=Qp[o],d={x:e.x+l.x*a,y:e.y+l.y*a},f={x:n.x+c.x*a,y:n.y+c.y*a},p=tj({source:d,sourcePosition:t,target:f}),m=p.x!==0?"x":"y",h=p[m];let g=[],b,x;const v={x:0,y:0},w={x:0,y:0},[,,y,N]=J0({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[m]*c[m]===-1){m==="x"?(b=s.x??d.x+(f.x-d.x)*i,x=s.y??(d.y+f.y)/2):(b=s.x??(d.x+f.x)/2,x=s.y??d.y+(f.y-d.y)*i);const P=[{x:b,y:d.y},{x:b,y:f.y}],I=[{x:d.x,y:x},{x:f.x,y:x}];l[m]===h?g=m==="x"?P:I:g=m==="x"?I:P}else{const P=[{x:d.x,y:f.y}],I=[{x:f.x,y:d.y}];if(m==="x"?g=l.x===h?I:P:g=l.y===h?P:I,t===o){const A=Math.abs(e[m]-n[m]);if(A<=a){const L=Math.min(a-1,a-A);l[m]===h?v[m]=(d[m]>e[m]?-1:1)*L:w[m]=(f[m]>n[m]?-1:1)*L}}if(t!==o){const A=m==="x"?"y":"x",L=l[m]===c[A],D=d[A]>f[A],T=d[A]<f[A];(l[m]===1&&(!L&&D||L&&T)||l[m]!==1&&(!L&&T||L&&D))&&(g=m==="x"?P:I)}const z={x:d.x+v.x,y:d.y+v.y},$={x:f.x+w.x,y:f.y+w.y},O=Math.max(Math.abs(z.x-g[0].x),Math.abs($.x-g[0].x)),R=Math.max(Math.abs(z.y-g[0].y),Math.abs($.y-g[0].y));O>=R?(b=(z.x+$.x)/2,x=g[0].y):(b=g[0].x,x=(z.y+$.y)/2)}const k={x:d.x+v.x,y:d.y+v.y},S={x:f.x+w.x,y:f.y+w.y};return[[e,...k.x!==g[0].x||k.y!==g[0].y?[k]:[],...g,...S.x!==g[g.length-1].x||S.y!==g[g.length-1].y?[S]:[],n],b,x,y,N]}function rj(e,t,n,o){const s=Math.min(Up(e,t)/2,Up(t,n)/2,o),{x:a,y:i}=t;if(e.x===a&&a===n.x||e.y===i&&i===n.y)return`L${a} ${i}`;if(e.y===i){const d=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${a+s*d},${i}Q ${a},${i} ${a},${i+s*f}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${a},${i+s*c}Q ${a},${i} ${a+s*l},${i}`}function kl({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:o,targetY:s,targetPosition:a=we.Top,borderRadius:i=5,centerX:l,centerY:c,offset:d=20,stepPosition:f=.5}){const[p,m,h,g,b]=nj({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:s},targetPosition:a,center:{x:l,y:c},offset:d,stepPosition:f});let x=`M${p[0].x} ${p[0].y}`;for(let v=1;v<p.length-1;v++)x+=rj(p[v-1],p[v],p[v+1],i);return x+=`L${p[p.length-1].x} ${p[p.length-1].y}`,[x,m,h,g,b]}function Kp(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function oj(e){const{sourceNode:t,targetNode:n}=e;if(!Kp(t)||!Kp(n))return null;const o=t.internals.handleBounds||Gp(t.handles),s=n.internals.handleBounds||Gp(n.handles),a=Wp(o?.source??[],e.sourceHandle),i=Wp(e.connectionMode===wr.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!a||!i)return e.onError?.("008",Qt.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=Qn(t,a,l),f=Qn(n,i,c);return{sourceX:d.x,sourceY:d.y,targetX:f.x,targetY:f.y,sourcePosition:l,targetPosition:c}}function Gp(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function Qn(e,t,n=we.Left,o=!1){const s=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:i,height:l}=t??pn(e);if(o)return{x:s+i/2,y:a+l/2};switch(t?.position??n){case we.Top:return{x:s+i/2,y:a};case we.Right:return{x:s+i,y:a+l/2};case we.Bottom:return{x:s+i/2,y:a+l};case we.Left:return{x:s,y:a+l/2}}}function Wp(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Sl(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function sj(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:s}){const a=new Set;return e.reduce((i,l)=>([l.markerStart||o,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const d=Sl(c,t);a.has(d)||(i.push({id:d,color:c.color||n,...c}),a.add(d))}}),i),[]).sort((i,l)=>i.id.localeCompare(l.id))}const tv=1e3,aj=10,md={nodeOrigin:[0,0],nodeExtent:ho,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ij={...md,checkEquality:!0};function hd(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function lj(e,t,n){const o=hd(md,n);for(const s of e.values())if(s.parentId)bd(s,e,t,o);else{const a=_o(s,o.nodeOrigin),i=Sr(s.extent)?s.extent:o.nodeExtent,l=qn(a,i,pn(s));s.internals.positionAbsolute=l}}function cj(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const s of e.handles){const a={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(a):s.type==="target"&&o.push(a)}return{source:n,target:o}}function gd(e){return e==="manual"}function Cl(e,t,n,o={}){const s=hd(ij,o),a={i:0},i=new Map(t),l=s?.elevateNodesOnSelect&&!gd(s.zIndexMode)?tv:0;let c=e.length>0,d=!1;t.clear(),n.clear();for(const f of e){let p=i.get(f.id);if(s.checkEquality&&f===p?.internals.userNode)t.set(f.id,p);else{const m=_o(f,s.nodeOrigin),h=Sr(f.extent)?f.extent:s.nodeExtent,g=qn(m,h,pn(f));p={...s.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:g,handleBounds:cj(f,p),z:nv(f,l,s.zIndexMode),userNode:f}},t.set(f.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(c=!1),f.parentId&&bd(p,t,n,o,a),d||=f.selected??!1}return{nodesInitialized:c,hasSelectedNodes:d}}function dj(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 bd(e,t,n,o,s){const{elevateNodesOnSelect:a,nodeOrigin:i,nodeExtent:l,zIndexMode:c}=hd(md,o),d=e.parentId,f=t.get(d);if(!f){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}dj(e,n),s&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++s.i,f.internals.z=f.internals.z+s.i*aj),s&&f.internals.rootParentIndex!==void 0&&(s.i=f.internals.rootParentIndex);const p=a&&!gd(c)?tv:0,{x:m,y:h,z:g}=uj(e,f,i,l,p,c),{positionAbsolute:b}=e.internals,x=m!==b.x||h!==b.y;(x||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:m,y:h}:b,z:g}})}function nv(e,t,n){const o=$t(e.zIndex)?e.zIndex:0;return gd(n)?o:o+(e.selected?t:0)}function uj(e,t,n,o,s,a){const{x:i,y:l}=t.internals.positionAbsolute,c=pn(e),d=_o(e,n),f=Sr(e.extent)?qn(d,e.extent,c):d;let p=qn({x:i+f.x,y:l+f.y},o,c);e.extent==="parent"&&(p=V0(p,c,t));const m=nv(e,s,a),h=t.internals.z??0;return{x:p.x,y:p.y,z:h>=m?h+1:m}}function xd(e,t,n,o=[0,0]){const s=[],a=new Map;for(const i of e){const l=t.get(i.parentId);if(!l)continue;const c=a.get(i.parentId)?.expandedRect??kr(l),d=Q0(c,i.rect);a.set(i.parentId,{expandedRect:d,parent:l})}return a.size>0&&a.forEach(({expandedRect:i,parent:l},c)=>{const d=l.internals.positionAbsolute,f=pn(l),p=l.origin??o,m=i.x<d.x?Math.round(Math.abs(d.x-i.x)):0,h=i.y<d.y?Math.round(Math.abs(d.y-i.y)):0,g=Math.max(f.width,Math.round(i.width)),b=Math.max(f.height,Math.round(i.height)),x=(g-f.width)*p[0],v=(b-f.height)*p[1];(m>0||h>0||x||v)&&(s.push({id:c,type:"position",position:{x:l.position.x-m+x,y:l.position.y-h+v}}),n.get(c)?.forEach(w=>{e.some(y=>y.id===w.id)||s.push({id:w.id,type:"position",position:{x:w.position.x+m,y:w.position.y+h}})})),(f.width<i.width||f.height<i.height||m||h)&&s.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:g+(m?p[0]*m-x:0),height:b+(h?p[1]*h-v:0)}})}),s}function pj(e,t,n,o,s,a,i){const l=o?.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const d=[],f=window.getComputedStyle(l),{m22:p}=new window.DOMMatrixReadOnly(f.transform),m=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const b=fd(h.nodeElement),x=g.measured.width!==b.width||g.measured.height!==b.height;if(!!(b.width&&b.height&&(x||!g.internals.handleBounds||h.force))){const w=h.nodeElement.getBoundingClientRect(),y=Sr(g.extent)?g.extent:a;let{positionAbsolute:N}=g.internals;g.parentId&&g.extent==="parent"?N=V0(N,b,t.get(g.parentId)):y&&(N=qn(N,y,b));const k={...g,measured:b,internals:{...g.internals,positionAbsolute:N,handleBounds:{source:Vp("source",h.nodeElement,w,p,g.id),target:Vp("target",h.nodeElement,w,p,g.id)}}};t.set(g.id,k),g.parentId&&bd(k,t,n,{nodeOrigin:s,zIndexMode:i}),c=!0,x&&(d.push({id:g.id,type:"dimensions",dimensions:b}),g.expandParent&&g.parentId&&m.push({id:g.id,parentId:g.parentId,rect:kr(k,s)}))}}if(m.length>0){const h=xd(m,t,n,s);d.push(...h)}return{changes:d,updatedInternals:c}}async function fj({delta:e,panZoom:t,transform:n,translateExtent:o,width:s,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,a]],o),l=!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2]);return Promise.resolve(l)}function Yp(e,t,n,o,s,a){let i=s;const l=o.get(i)||new Map;o.set(i,l.set(n,t)),i=`${s}-${e}`;const c=o.get(i)||new Map;if(o.set(i,c.set(n,t)),a){i=`${s}-${e}-${a}`;const d=o.get(i)||new Map;o.set(i,d.set(n,t))}}function rv(e,t,n){e.clear(),t.clear();for(const o of n){const{source:s,target:a,sourceHandle:i=null,targetHandle:l=null}=o,c={edgeId:o.id,source:s,target:a,sourceHandle:i,targetHandle:l},d=`${s}-${i}--${a}-${l}`,f=`${a}-${l}--${s}-${i}`;Yp("source",c,f,e,s,i),Yp("target",c,d,e,a,l),t.set(o.id,o)}}function ov(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:ov(n,t):!1}function Zp(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function mj(e,t,n,o){const s=new Map;for(const[a,i]of e)if((i.selected||i.id===o)&&(!i.parentId||!ov(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){const l=e.get(a);l&&s.set(a,{id:a,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return s}function Ai({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const s=[];for(const[i,l]of t){const c=n.get(i)?.internals.userNode;c&&s.push({...c,position:l.position,dragging:o})}if(!e)return[s[0],s];const a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:o}:s[0],s]}function hj({dragItems:e,snapGrid:t,x:n,y:o}){const s=e.values().next().value;if(!s)return null;const a={x:n-s.distance.x,y:o-s.distance.y},i=Lo(a,t);return{x:i.x-a.x,y:i.y-a.y}}function gj({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:s}){let a={x:null,y:null},i=0,l=new Map,c=!1,d={x:0,y:0},f=null,p=!1,m=null,h=!1,g=!1,b=null;function x({noDragClassName:w,handleSelector:y,domNode:N,isSelectable:k,nodeId:S,nodeClickDistance:M=0}){m=it(N);function P({x:O,y:R}){const{nodeLookup:A,nodeExtent:L,snapGrid:D,snapToGrid:T,nodeOrigin:B,onNodeDrag:F,onSelectionDrag:j,onError:H,updateNodePositions:E}=t();a={x:O,y:R};let Q=!1;const K=l.size>1,Y=K&&L?Nl(Do(l)):null,re=K&&T?hj({dragItems:l,snapGrid:D,x:O,y:R}):null;for(const[te,X]of l){if(!A.has(te))continue;let oe={x:O-X.distance.x,y:R-X.distance.y};T&&(oe=re?{x:Math.round(oe.x+re.x),y:Math.round(oe.y+re.y)}:Lo(oe,D));let ge=null;if(K&&L&&!X.extent&&Y){const{positionAbsolute:ee}=X.internals,ae=ee.x-Y.x+L[0][0],fe=ee.x+X.measured.width-Y.x2+L[1][0],he=ee.y-Y.y+L[0][1],V=ee.y+X.measured.height-Y.y2+L[1][1];ge=[[ae,he],[fe,V]]}const{position:J,positionAbsolute:G}=H0({nodeId:te,nextPosition:oe,nodeLookup:A,nodeExtent:ge||L,nodeOrigin:B,onError:H});Q=Q||X.position.x!==J.x||X.position.y!==J.y,X.position=J,X.internals.positionAbsolute=G}if(g=g||Q,!!Q&&(E(l,!0),b&&(o||F||!S&&j))){const[te,X]=Ai({nodeId:S,dragItems:l,nodeLookup:A});o?.(b,l,te,X),F?.(b,te,X),S||j?.(b,X)}}async function I(){if(!f)return;const{transform:O,panBy:R,autoPanSpeed:A,autoPanOnNodeDrag:L}=t();if(!L){c=!1,cancelAnimationFrame(i);return}const[D,T]=q0(d,f,A);(D!==0||T!==0)&&(a.x=(a.x??0)-D/O[2],a.y=(a.y??0)-T/O[2],await R({x:D,y:T})&&P(a)),i=requestAnimationFrame(I)}function z(O){const{nodeLookup:R,multiSelectionActive:A,nodesDraggable:L,transform:D,snapGrid:T,snapToGrid:B,selectNodesOnDrag:F,onNodeDragStart:j,onSelectionDragStart:H,unselectNodesAndEdges:E}=t();p=!0,(!F||!k)&&!A&&S&&(R.get(S)?.selected||E()),k&&F&&S&&e?.(S);const Q=no(O.sourceEvent,{transform:D,snapGrid:T,snapToGrid:B,containerBounds:f});if(a=Q,l=mj(R,L,Q,S),l.size>0&&(n||j||!S&&H)){const[K,Y]=Ai({nodeId:S,dragItems:l,nodeLookup:R});n?.(O.sourceEvent,l,K,Y),j?.(O.sourceEvent,K,Y),S||H?.(O.sourceEvent,Y)}}const $=w0().clickDistance(M).on("start",O=>{const{domNode:R,nodeDragThreshold:A,transform:L,snapGrid:D,snapToGrid:T}=t();f=R?.getBoundingClientRect()||null,h=!1,g=!1,b=O.sourceEvent,A===0&&z(O),a=no(O.sourceEvent,{transform:L,snapGrid:D,snapToGrid:T,containerBounds:f}),d=_t(O.sourceEvent,f)}).on("drag",O=>{const{autoPanOnNodeDrag:R,transform:A,snapGrid:L,snapToGrid:D,nodeDragThreshold:T,nodeLookup:B}=t(),F=no(O.sourceEvent,{transform:A,snapGrid:L,snapToGrid:D,containerBounds:f});if(b=O.sourceEvent,(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1||S&&!B.has(S))&&(h=!0),!h){if(!c&&R&&p&&(c=!0,I()),!p){const j=_t(O.sourceEvent,f),H=j.x-d.x,E=j.y-d.y;Math.sqrt(H*H+E*E)>T&&z(O)}(a.x!==F.xSnapped||a.y!==F.ySnapped)&&l&&p&&(d=_t(O.sourceEvent,f),P(F))}}).on("end",O=>{if(!(!p||h)&&(c=!1,p=!1,cancelAnimationFrame(i),l.size>0)){const{nodeLookup:R,updateNodePositions:A,onNodeDragStop:L,onSelectionDragStop:D}=t();if(g&&(A(l,!1),g=!1),s||L||!S&&D){const[T,B]=Ai({nodeId:S,dragItems:l,nodeLookup:R,dragging:!1});s?.(O.sourceEvent,l,T,B),L?.(O.sourceEvent,T,B),S||D?.(O.sourceEvent,B)}}}).filter(O=>{const R=O.target;return!O.button&&(!w||!Zp(R,`.${w}`,N))&&(!y||Zp(R,y,N))});m.call($)}function v(){m?.on(".drag",null)}return{update:x,destroy:v}}function bj(e,t,n){const o=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const a of t.values())bo(s,kr(a))>0&&o.push(a);return o}const xj=250;function yj(e,t,n,o){let s=[],a=1/0;const i=bj(e,n,t+xj);for(const l of i){const c=[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]];for(const d of c){if(o.nodeId===d.nodeId&&o.type===d.type&&o.id===d.id)continue;const{x:f,y:p}=Qn(l,d,d.position,!0),m=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(p-e.y,2));m>t||(m<a?(s=[{...d,x:f,y:p}],a=m):m===a&&s.push({...d,x:f,y:p}))}}if(!s.length)return null;if(s.length>1){const l=o.type==="source"?"target":"source";return s.find(c=>c.type===l)??s[0]}return s[0]}function sv(e,t,n,o,s,a=!1){const i=o.get(e);if(!i)return null;const l=s==="strict"?i.internals.handleBounds?.[t]:[...i.internals.handleBounds?.source??[],...i.internals.handleBounds?.target??[]],c=(n?l?.find(d=>d.id===n):l?.[0])??null;return c&&a?{...c,...Qn(i,c,c.position,!0)}:c}function av(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function vj(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const iv=()=>!0;function wj(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:s,edgeUpdaterType:a,isTarget:i,domNode:l,nodeLookup:c,lib:d,autoPanOnConnect:f,flowId:p,panBy:m,cancelConnection:h,onConnectStart:g,onConnect:b,onConnectEnd:x,isValidConnection:v=iv,onReconnectEnd:w,updateConnection:y,getTransform:N,getFromHandle:k,autoPanSpeed:S,dragThreshold:M=1,handleDomNode:P}){const I=G0(e.target);let z=0,$;const{x:O,y:R}=_t(e),A=av(a,P),L=l?.getBoundingClientRect();let D=!1;if(!L||!A)return;const T=sv(s,A,o,c,t);if(!T)return;let B=_t(e,L),F=!1,j=null,H=!1,E=null;function Q(){if(!f||!L)return;const[J,G]=q0(B,L,S);m({x:J,y:G}),z=requestAnimationFrame(Q)}const K={...T,nodeId:s,type:A,position:T.position},Y=c.get(s);let te={inProgress:!0,isValid:null,from:Qn(Y,K,we.Left,!0),fromHandle:K,fromPosition:K.position,fromNode:Y,to:B,toHandle:null,toPosition:Bp[K.position],toNode:null,pointer:B};function X(){D=!0,y(te),g?.(e,{nodeId:s,handleId:o,handleType:A})}M===0&&X();function oe(J){if(!D){const{x:V,y:ie}=_t(J),ue=V-O,de=ie-R;if(!(ue*ue+de*de>M*M))return;X()}if(!k()||!K){ge(J);return}const G=N();B=_t(J,L),$=yj(To(B,G,!1,[1,1]),n,c,K),F||(Q(),F=!0);const ee=lv(J,{handle:$,connectionMode:t,fromNodeId:s,fromHandleId:o,fromType:i?"target":"source",isValidConnection:v,doc:I,lib:d,flowId:p,nodeLookup:c});E=ee.handleDomNode,j=ee.connection,H=vj(!!$,ee.isValid);const ae=c.get(s),fe=ae?Qn(ae,K,we.Left,!0):te.from,he={...te,from:fe,isValid:H,to:ee.toHandle&&H?Us({x:ee.toHandle.x,y:ee.toHandle.y},G):B,toHandle:ee.toHandle,toPosition:H&&ee.toHandle?ee.toHandle.position:Bp[K.position],toNode:ee.toHandle?c.get(ee.toHandle.nodeId):null,pointer:B};y(he),te=he}function ge(J){if(!("touches"in J&&J.touches.length>0)){if(D){($||E)&&j&&H&&b?.(j);const{inProgress:G,...ee}=te,ae={...ee,toPosition:te.toHandle?te.toPosition:null};x?.(J,ae),a&&w?.(J,ae)}h(),cancelAnimationFrame(z),F=!1,H=!1,j=null,E=null,I.removeEventListener("mousemove",oe),I.removeEventListener("mouseup",ge),I.removeEventListener("touchmove",oe),I.removeEventListener("touchend",ge)}}I.addEventListener("mousemove",oe),I.addEventListener("mouseup",ge),I.addEventListener("touchmove",oe),I.addEventListener("touchend",ge)}function lv(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:s,fromType:a,doc:i,lib:l,flowId:c,isValidConnection:d=iv,nodeLookup:f}){const p=a==="target",m=t?i.querySelector(`.${l}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:g}=_t(e),b=i.elementFromPoint(h,g),x=b?.classList.contains(`${l}-flow__handle`)?b:m,v={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const w=av(void 0,x),y=x.getAttribute("data-nodeid"),N=x.getAttribute("data-handleid"),k=x.classList.contains("connectable"),S=x.classList.contains("connectableend");if(!y||!w)return v;const M={source:p?y:o,sourceHandle:p?N:s,target:p?o:y,targetHandle:p?s:N};v.connection=M;const I=k&&S&&(n===wr.Strict?p&&w==="source"||!p&&w==="target":y!==o||N!==s);v.isValid=I&&d(M),v.toHandle=sv(y,w,N,f,n,!0)}return v}const Ml={onPointerDown:wj,isValid:lv};function Nj({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const s=it(e);function a({translateExtent:l,width:c,height:d,zoomStep:f=1,pannable:p=!0,zoomable:m=!0,inversePan:h=!1}){const g=y=>{if(y.sourceEvent.type!=="wheel"||!t)return;const N=n(),k=y.sourceEvent.ctrlKey&&xo()?10:1,S=-y.sourceEvent.deltaY*(y.sourceEvent.deltaMode===1?.05:y.sourceEvent.deltaMode?1:.002)*f,M=N[2]*Math.pow(2,S*k);t.scaleTo(M)};let b=[0,0];const x=y=>{(y.sourceEvent.type==="mousedown"||y.sourceEvent.type==="touchstart")&&(b=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY])},v=y=>{const N=n();if(y.sourceEvent.type!=="mousemove"&&y.sourceEvent.type!=="touchmove"||!t)return;const k=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY],S=[k[0]-b[0],k[1]-b[1]];b=k;const M=o()*Math.max(N[2],Math.log(N[2]))*(h?-1:1),P={x:N[0]-S[0]*M,y:N[1]-S[1]*M},I=[[0,0],[c,d]];t.setViewportConstrained({x:P.x,y:P.y,zoom:N[2]},I,l)},w=R0().on("start",x).on("zoom",p?v:null).on("zoom.wheel",m?g:null);s.call(w,{})}function i(){s.on("zoom",null)}return{update:a,destroy:i,pointer:Pt}}const Da=e=>({x:e.x,y:e.y,zoom:e.k}),Pi=({x:e,y:t,zoom:n})=>Ea.translate(e,t).scale(n),sr=(e,t)=>e.target.closest(`.${t}`),cv=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),kj=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ei=(e,t=0,n=kj,o=()=>{})=>{const s=typeof t=="number"&&t>0;return s||o(),s?e.transition().duration(t).ease(n).on("end",o):e},dv=e=>{const t=e.ctrlKey&&xo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Sj({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:i,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:d}){return f=>{if(sr(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(f.ctrlKey&&i){const x=Pt(f),v=dv(f),w=p*Math.pow(2,v);o.scaleTo(n,w,x,f);return}const m=f.deltaMode===1?20:1;let h=s===zn.Vertical?0:f.deltaX*m,g=s===zn.Horizontal?0:f.deltaY*m;!xo()&&f.shiftKey&&s!==zn.Vertical&&(h=f.deltaY*m,g=0),o.translateBy(n,-(h/p)*a,-(g/p)*a,{internal:!0});const b=Da(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(f,b),e.panScrollTimeout=setTimeout(()=>{d?.(f,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(f,b))}}function Cj({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,s){const a=o.type==="wheel",i=!t&&a&&!o.ctrlKey,l=sr(o,e);if(o.ctrlKey&&a&&l&&o.preventDefault(),i||l)return null;o.preventDefault(),n.call(this,o,s)}}function Mj({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const s=Da(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=s,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,s)}}function Ij({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:s}){return a=>{e.usedRightMouseButton=!!(n&&cv(t,e.mouseButton??0)),a.sourceEvent?.sync||o([a.transform.x,a.transform.y,a.transform.k]),s&&!a.sourceEvent?.internal&&s?.(a.sourceEvent,Da(a.transform))}}function Aj({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:s,onPaneContextMenu:a}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&cv(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&a(i.sourceEvent),e.usedRightMouseButton=!1,o(!1),s)){const l=Da(i.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(i.sourceEvent,l)},n?150:0)}}}function Pj({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:s,zoomOnDoubleClick:a,userSelectionActive:i,noWheelClassName:l,noPanClassName:c,lib:d,connectionInProgress:f}){return p=>{const m=e||t,h=n&&p.ctrlKey,g=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(sr(p,`${d}-flow__node`)||sr(p,`${d}-flow__edge`)))return!0;if(!o&&!m&&!s&&!a&&!n||i||f&&!g||sr(p,l)&&g||sr(p,c)&&(!g||s&&g&&!e)||!n&&p.ctrlKey&&g)return!1;if(!n&&p.type==="touchstart"&&p.touches?.length>1)return p.preventDefault(),!1;if(!m&&!s&&!h&&g||!o&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(o)&&!o.includes(p.button)&&p.type==="mousedown")return!1;const b=Array.isArray(o)&&o.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||g)&&b}}function Ej({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:s,onPanZoom:a,onPanZoomStart:i,onPanZoomEnd:l,onDraggingChange:c}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),p=R0().scaleExtent([t,n]).translateExtent(o),m=it(e).call(p);w({x:s.x,y:s.y,zoom:Nr(s.zoom,t,n)},[[0,0],[f.width,f.height]],o);const h=m.on("wheel.zoom"),g=m.on("dblclick.zoom");p.wheelDelta(dv);function b($,O){return m?new Promise(R=>{p?.interpolate(O?.interpolate==="linear"?to:bs).transform(Ei(m,O?.duration,O?.ease,()=>R(!0)),$)}):Promise.resolve(!1)}function x({noWheelClassName:$,noPanClassName:O,onPaneContextMenu:R,userSelectionActive:A,panOnScroll:L,panOnDrag:D,panOnScrollMode:T,panOnScrollSpeed:B,preventScrolling:F,zoomOnPinch:j,zoomOnScroll:H,zoomOnDoubleClick:E,zoomActivationKeyPressed:Q,lib:K,onTransformChange:Y,connectionInProgress:re,paneClickDistance:te,selectionOnDrag:X}){A&&!d.isZoomingOrPanning&&v();const oe=L&&!Q&&!A;p.clickDistance(X?1/0:!$t(te)||te<0?0:te);const ge=oe?Sj({zoomPanValues:d,noWheelClassName:$,d3Selection:m,d3Zoom:p,panOnScrollMode:T,panOnScrollSpeed:B,zoomOnPinch:j,onPanZoomStart:i,onPanZoom:a,onPanZoomEnd:l}):Cj({noWheelClassName:$,preventScrolling:F,d3ZoomHandler:h});if(m.on("wheel.zoom",ge,{passive:!1}),!A){const G=Mj({zoomPanValues:d,onDraggingChange:c,onPanZoomStart:i});p.on("start",G);const ee=Ij({zoomPanValues:d,panOnDrag:D,onPaneContextMenu:!!R,onPanZoom:a,onTransformChange:Y});p.on("zoom",ee);const ae=Aj({zoomPanValues:d,panOnDrag:D,panOnScroll:L,onPaneContextMenu:R,onPanZoomEnd:l,onDraggingChange:c});p.on("end",ae)}const J=Pj({zoomActivationKeyPressed:Q,panOnDrag:D,zoomOnScroll:H,panOnScroll:L,zoomOnDoubleClick:E,zoomOnPinch:j,userSelectionActive:A,noPanClassName:O,noWheelClassName:$,lib:K,connectionInProgress:re});p.filter(J),E?m.on("dblclick.zoom",g):m.on("dblclick.zoom",null)}function v(){p.on("zoom",null)}async function w($,O,R){const A=Pi($),L=p?.constrain()(A,O,R);return L&&await b(L),new Promise(D=>D(L))}async function y($,O){const R=Pi($);return await b(R,O),new Promise(A=>A(R))}function N($){if(m){const O=Pi($),R=m.property("__zoom");(R.k!==$.zoom||R.x!==$.x||R.y!==$.y)&&p?.transform(m,O,null,{sync:!0})}}function k(){const $=m?T0(m.node()):{x:0,y:0,k:1};return{x:$.x,y:$.y,zoom:$.k}}function S($,O){return m?new Promise(R=>{p?.interpolate(O?.interpolate==="linear"?to:bs).scaleTo(Ei(m,O?.duration,O?.ease,()=>R(!0)),$)}):Promise.resolve(!1)}function M($,O){return m?new Promise(R=>{p?.interpolate(O?.interpolate==="linear"?to:bs).scaleBy(Ei(m,O?.duration,O?.ease,()=>R(!0)),$)}):Promise.resolve(!1)}function P($){p?.scaleExtent($)}function I($){p?.translateExtent($)}function z($){const O=!$t($)||$<0?0:$;p?.clickDistance(O)}return{update:x,destroy:v,setViewport:y,setViewportConstrained:w,getViewport:k,scaleTo:S,scaleBy:M,setScaleExtent:P,setTranslateExtent:I,syncViewport:N,setClickDistance:z}}var Cr;(function(e){e.Line="line",e.Handle="handle"})(Cr||(Cr={}));function $j({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:s,affectsY:a}){const i=e-t,l=n-o,c=[i>0?1:i<0?-1:0,l>0?1:l<0?-1:0];return i&&s&&(c[0]=c[0]*-1),l&&a&&(c[1]=c[1]*-1),c}function Xp(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:s}}function hn(e,t){return Math.max(0,t-e)}function gn(e,t){return Math.max(0,e-t)}function ls(e,t,n){return Math.max(0,t-e,e-n)}function Jp(e,t){return e?!t:t}function _j(e,t,n,o,s,a,i,l){let{affectsX:c,affectsY:d}=t;const{isHorizontal:f,isVertical:p}=t,m=f&&p,{xSnapped:h,ySnapped:g}=n,{minWidth:b,maxWidth:x,minHeight:v,maxHeight:w}=o,{x:y,y:N,width:k,height:S,aspectRatio:M}=e;let P=Math.floor(f?h-e.pointerX:0),I=Math.floor(p?g-e.pointerY:0);const z=k+(c?-P:P),$=S+(d?-I:I),O=-a[0]*k,R=-a[1]*S;let A=ls(z,b,x),L=ls($,v,w);if(i){let B=0,F=0;c&&P<0?B=hn(y+P+O,i[0][0]):!c&&P>0&&(B=gn(y+z+O,i[1][0])),d&&I<0?F=hn(N+I+R,i[0][1]):!d&&I>0&&(F=gn(N+$+R,i[1][1])),A=Math.max(A,B),L=Math.max(L,F)}if(l){let B=0,F=0;c&&P>0?B=gn(y+P,l[0][0]):!c&&P<0&&(B=hn(y+z,l[1][0])),d&&I>0?F=gn(N+I,l[0][1]):!d&&I<0&&(F=hn(N+$,l[1][1])),A=Math.max(A,B),L=Math.max(L,F)}if(s){if(f){const B=ls(z/M,v,w)*M;if(A=Math.max(A,B),i){let F=0;!c&&!d||c&&!d&&m?F=gn(N+R+z/M,i[1][1])*M:F=hn(N+R+(c?P:-P)/M,i[0][1])*M,A=Math.max(A,F)}if(l){let F=0;!c&&!d||c&&!d&&m?F=hn(N+z/M,l[1][1])*M:F=gn(N+(c?P:-P)/M,l[0][1])*M,A=Math.max(A,F)}}if(p){const B=ls($*M,b,x)/M;if(L=Math.max(L,B),i){let F=0;!c&&!d||d&&!c&&m?F=gn(y+$*M+O,i[1][0])/M:F=hn(y+(d?I:-I)*M+O,i[0][0])/M,L=Math.max(L,F)}if(l){let F=0;!c&&!d||d&&!c&&m?F=hn(y+$*M,l[1][0])/M:F=gn(y+(d?I:-I)*M,l[0][0])/M,L=Math.max(L,F)}}}I=I+(I<0?L:-L),P=P+(P<0?A:-A),s&&(m?z>$*M?I=(Jp(c,d)?-P:P)/M:P=(Jp(c,d)?-I:I)*M:f?(I=P/M,d=c):(P=I*M,c=d));const D=c?y+P:y,T=d?N+I:N;return{width:k+(c?-P:P),height:S+(d?-I:I),x:a[0]*P*(c?-1:1)+D,y:a[1]*I*(d?-1:1)+T}}const uv={width:0,height:0,x:0,y:0},Dj={...uv,pointerX:0,pointerY:0,aspectRatio:1};function Lj(e){return[[0,0],[e.measured.width,e.measured.height]]}function Tj(e,t,n){const o=t.position.x+e.position.x,s=t.position.y+e.position.y,a=e.measured.width??0,i=e.measured.height??0,l=n[0]*a,c=n[1]*i;return[[o-l,s-c],[o+a-l,s+i-c]]}function Rj({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:s}){const a=it(e);let i={controlDirection:Xp("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:d,boundaries:f,keepAspectRatio:p,resizeDirection:m,onResizeStart:h,onResize:g,onResizeEnd:b,shouldResize:x}){let v={...uv},w={...Dj};i={boundaries:f,resizeDirection:m,keepAspectRatio:p,controlDirection:Xp(d)};let y,N=null,k=[],S,M,P,I=!1;const z=w0().on("start",$=>{const{nodeLookup:O,transform:R,snapGrid:A,snapToGrid:L,nodeOrigin:D,paneDomNode:T}=n();if(y=O.get(t),!y)return;N=T?.getBoundingClientRect()??null;const{xSnapped:B,ySnapped:F}=no($.sourceEvent,{transform:R,snapGrid:A,snapToGrid:L,containerBounds:N});v={width:y.measured.width??0,height:y.measured.height??0,x:y.position.x??0,y:y.position.y??0},w={...v,pointerX:B,pointerY:F,aspectRatio:v.width/v.height},S=void 0,y.parentId&&(y.extent==="parent"||y.expandParent)&&(S=O.get(y.parentId),M=S&&y.extent==="parent"?Lj(S):void 0),k=[],P=void 0;for(const[j,H]of O)if(H.parentId===t&&(k.push({id:j,position:{...H.position},extent:H.extent}),H.extent==="parent"||H.expandParent)){const E=Tj(H,y,H.origin??D);P?P=[[Math.min(E[0][0],P[0][0]),Math.min(E[0][1],P[0][1])],[Math.max(E[1][0],P[1][0]),Math.max(E[1][1],P[1][1])]]:P=E}h?.($,{...v})}).on("drag",$=>{const{transform:O,snapGrid:R,snapToGrid:A,nodeOrigin:L}=n(),D=no($.sourceEvent,{transform:O,snapGrid:R,snapToGrid:A,containerBounds:N}),T=[];if(!y)return;const{x:B,y:F,width:j,height:H}=v,E={},Q=y.origin??L,{width:K,height:Y,x:re,y:te}=_j(w,i.controlDirection,D,i.boundaries,i.keepAspectRatio,Q,M,P),X=K!==j,oe=Y!==H,ge=re!==B&&X,J=te!==F&&oe;if(!ge&&!J&&!X&&!oe)return;if((ge||J||Q[0]===1||Q[1]===1)&&(E.x=ge?re:v.x,E.y=J?te:v.y,v.x=E.x,v.y=E.y,k.length>0)){const fe=re-B,he=te-F;for(const V of k)V.position={x:V.position.x-fe+Q[0]*(K-j),y:V.position.y-he+Q[1]*(Y-H)},T.push(V)}if((X||oe)&&(E.width=X&&(!i.resizeDirection||i.resizeDirection==="horizontal")?K:v.width,E.height=oe&&(!i.resizeDirection||i.resizeDirection==="vertical")?Y:v.height,v.width=E.width,v.height=E.height),S&&y.expandParent){const fe=Q[0]*(E.width??0);E.x&&E.x<fe&&(v.x=fe,w.x=w.x-(E.x-fe));const he=Q[1]*(E.height??0);E.y&&E.y<he&&(v.y=he,w.y=w.y-(E.y-he))}const G=$j({width:v.width,prevWidth:j,height:v.height,prevHeight:H,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),ee={...v,direction:G};x?.($,ee)!==!1&&(I=!0,g?.($,ee),o(E,T))}).on("end",$=>{I&&(b?.($,{...v}),s?.({...v}),I=!1)});a.call(z)}function c(){a.on(".drag",null)}return{update:l,destroy:c}}var pv={exports:{}},fv={};/**
|
|
1085
|
+
* @license React
|
|
1086
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
1087
|
+
*
|
|
1088
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1089
|
+
*
|
|
1090
|
+
* This source code is licensed under the MIT license found in the
|
|
1091
|
+
* LICENSE file in the root directory of this source tree.
|
|
1092
|
+
*/var La=Vf,Oj=Dy;function zj(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Bj=typeof Object.is=="function"?Object.is:zj,Fj=Oj.useSyncExternalStore,jj=La.useRef,Hj=La.useEffect,Vj=La.useMemo,qj=La.useDebugValue;fv.useSyncExternalStoreWithSelector=function(e,t,n,o,s){var a=jj(null);if(a.current===null){var i={hasValue:!1,value:null};a.current=i}else i=a.current;a=Vj(function(){function c(h){if(!d){if(d=!0,f=h,h=o(h),s!==void 0&&i.hasValue){var g=i.value;if(s(g,h))return p=g}return p=h}if(g=p,Bj(f,h))return g;var b=o(h);return s!==void 0&&s(g,b)?(f=h,g):(f=h,p=b)}var d=!1,f,p,m=n===void 0?null:n;return[function(){return c(t())},m===null?void 0:function(){return c(m())}]},[t,n,o,s]);var l=Fj(e,a[0],a[1]);return Hj(function(){i.hasValue=!0,i.value=l},[l]),qj(l),l};pv.exports=fv;var Qj=pv.exports;const Uj=Q1(Qj),Kj={},ef=e=>{let t;const n=new Set,o=(f,p)=>{const m=typeof f=="function"?f(t):f;if(!Object.is(m,t)){const h=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(g=>g(t,h))}},s=()=>t,c={setState:o,getState:s,getInitialState:()=>d,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(Kj?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(o,s,c);return c},Gj=e=>e?ef(e):ef,{useDebugValue:Wj}=El,{useSyncExternalStoreWithSelector:Yj}=Uj,Zj=e=>e;function mv(e,t=Zj,n){const o=Yj(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Wj(o),o}const tf=(e,t)=>{const n=Gj(e),o=(s,a=t)=>mv(n,s,a);return Object.assign(o,n),o},Xj=(e,t)=>e?tf(e,t):tf;function Be(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,s]of e)if(!Object.is(s,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const Ta=Oe(null),Jj=Ta.Provider,hv=Qt.error001();function $e(e,t){const n=ve(Ta);if(n===null)throw new Error(hv);return mv(n,e,t)}function je(){const e=ve(Ta);if(e===null)throw new Error(hv);return U(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const nf={display:"none"},eH={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},gv="react-flow__node-desc",bv="react-flow__edge-desc",tH="react-flow__aria-live",nH=e=>e.ariaLiveMessage,rH=e=>e.ariaLabelConfig;function oH({rfId:e}){const t=$e(nH);return r("div",{id:`${tH}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:eH,children:t})}function sH({rfId:e,disableKeyboardA11y:t}){const n=$e(rH);return u(xe,{children:[r("div",{id:`${gv}-${e}`,style:nf,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),r("div",{id:`${bv}-${e}`,style:nf,children:n["edge.a11yDescription.default"]}),!t&&r(oH,{rfId:e})]})}const Ra=He(({position:e="top-left",children:t,className:n,style:o,...s},a)=>{const i=`${e}`.split("-");return r("div",{className:Ue(["react-flow__panel",n,...i]),style:o,ref:a,...s,children:t})});Ra.displayName="Panel";function aH({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:r(Ra,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:r("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const iH=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},cs=e=>e.id;function lH(e,t){return Be(e.selectedNodes.map(cs),t.selectedNodes.map(cs))&&Be(e.selectedEdges.map(cs),t.selectedEdges.map(cs))}function cH({onSelectionChange:e}){const t=je(),{selectedNodes:n,selectedEdges:o}=$e(iH,lH);return Z(()=>{const s={nodes:n,edges:o};e?.(s),t.getState().onSelectionChangeHandlers.forEach(a=>a(s))},[n,o,e]),null}const dH=e=>!!e.onSelectionChangeHandlers;function uH({onSelectionChange:e}){const t=$e(dH);return e||t?r(cH,{onSelectionChange:e}):null}const Il=typeof window<"u"?Gs:Z,xv=[0,0],pH={x:0,y:0,zoom:1},fH=["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"],rf=[...fH,"rfId"],mH=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}),of={translateExtent:ho,nodeOrigin:xv,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function hH(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:s,setTranslateExtent:a,setNodeExtent:i,reset:l,setDefaultNodesAndEdges:c}=$e(mH,Be),d=je();Il(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=of,l()}),[]);const f=ne(of);return Il(()=>{for(const p of rf){const m=e[p],h=f.current[p];m!==h&&(typeof e[p]>"u"||(p==="nodes"?t(m):p==="edges"?n(m):p==="minZoom"?o(m):p==="maxZoom"?s(m):p==="translateExtent"?a(m):p==="nodeExtent"?i(m):p==="ariaLabelConfig"?d.setState({ariaLabelConfig:GF(m)}):p==="fitView"?d.setState({fitViewQueued:m}):p==="fitViewOptions"?d.setState({fitViewOptions:m}):d.setState({[p]:m})))}f.current=e},rf.map(p=>e[p])),null}function sf(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function gH(e){const[t,n]=_(e==="system"?null:e);return Z(()=>{if(e!=="system"){n(e);return}const o=sf(),s=()=>n(o?.matches?"dark":"light");return s(),o?.addEventListener("change",s),()=>{o?.removeEventListener("change",s)}},[e]),t!==null?t:sf()?.matches?"dark":"light"}const af=typeof document<"u"?document:null;function yo(e=null,t={target:af,actInsideInputWithModifier:!0}){const[n,o]=_(!1),s=ne(!1),a=ne(new Set([])),[i,l]=U(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",`
|
|
1093
|
+
`).replace(`
|
|
1094
|
+
|
|
1095
|
+
`,`
|
|
1096
|
+
+`).split(`
|
|
1097
|
+
`)),f=d.reduce((p,m)=>p.concat(...m),[]);return[d,f]}return[[],[]]},[e]);return Z(()=>{const c=t?.target??af,d=t?.actInsideInputWithModifier??!0;if(e!==null){const f=h=>{if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!d)&&W0(h))return!1;const b=cf(h.code,l);if(a.current.add(h[b]),lf(i,a.current,!1)){const x=h.composedPath?.()?.[0]||h.target,v=x?.nodeName==="BUTTON"||x?.nodeName==="A";t.preventDefault!==!1&&(s.current||!v)&&h.preventDefault(),o(!0)}},p=h=>{const g=cf(h.code,l);lf(i,a.current,!0)?(o(!1),a.current.clear()):a.current.delete(h[g]),h.key==="Meta"&&a.current.clear(),s.current=!1},m=()=>{a.current.clear(),o(!1)};return c?.addEventListener("keydown",f),c?.addEventListener("keyup",p),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{c?.removeEventListener("keydown",f),c?.removeEventListener("keyup",p),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[e,o]),n}function lf(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(s=>t.has(s)))}function cf(e,t){return t.includes(e)?"code":"key"}const bH=()=>{const e=je();return U(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[o,s,a],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??o,y:t.y??s,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{const{width:o,height:s,minZoom:a,maxZoom:i,panZoom:l}=e.getState(),c=pd(t,o,s,a,i,n?.padding??.1);return l?(await l.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:s,snapToGrid:a,domNode:i}=e.getState();if(!i)return t;const{x:l,y:c}=i.getBoundingClientRect(),d={x:t.x-l,y:t.y-c},f=n.snapGrid??s,p=n.snapToGrid??a;return To(d,o,p,f)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:s,y:a}=o.getBoundingClientRect(),i=Us(t,n);return{x:i.x+s,y:i.y+a}}}),[])};function yv(e,t){const n=[],o=new Map,s=[];for(const a of e)if(a.type==="add"){s.push(a);continue}else if(a.type==="remove"||a.type==="replace")o.set(a.id,[a]);else{const i=o.get(a.id);i?i.push(a):o.set(a.id,[a])}for(const a of t){const i=o.get(a.id);if(!i){n.push(a);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){n.push({...i[0].item});continue}const l={...a};for(const c of i)xH(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 xH(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 yH(e,t){return yv(e,t)}function vH(e,t){return yv(e,t)}function Dn(e,t){return{id:e,type:"select",selected:t}}function ar(e,t=new Set,n=!1){const o=[];for(const[s,a]of e){const i=t.has(s);!(a.selected===void 0&&!i)&&a.selected!==i&&(n&&(a.selected=i),o.push(Dn(a.id,i)))}return o}function df({items:e=[],lookup:t}){const n=[],o=new Map(e.map(s=>[s.id,s]));for(const[s,a]of e.entries()){const i=t.get(a.id),l=i?.internals?.userNode??i;l!==void 0&&l!==a&&n.push({id:a.id,item:a,type:"replace"}),l===void 0&&n.push({item:a,type:"add",index:s})}for(const[s]of t)o.get(s)===void 0&&n.push({id:s,type:"remove"});return n}function uf(e){return{id:e.id,type:"remove"}}const pf=e=>zF(e),wH=e=>j0(e);function vv(e){return He(e)}function ff(e){const[t,n]=_(BigInt(0)),[o]=_(()=>NH(()=>n(s=>s+BigInt(1))));return Il(()=>{const s=o.get();s.length&&(e(s),o.reset())},[t]),o}function NH(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const wv=Oe(null);function kH({children:e}){const t=je(),n=q(l=>{const{nodes:c=[],setNodes:d,hasDefaultNodes:f,onNodesChange:p,nodeLookup:m,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let b=c;for(const v of l)b=typeof v=="function"?v(b):v;let x=df({items:b,lookup:m});for(const v of g.values())x=v(x);f&&d(b),x.length>0?p?.(x):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:v,nodes:w,setNodes:y}=t.getState();v&&y(w)})},[]),o=ff(n),s=q(l=>{const{edges:c=[],setEdges:d,hasDefaultEdges:f,onEdgesChange:p,edgeLookup:m}=t.getState();let h=c;for(const g of l)h=typeof g=="function"?g(h):g;f?d(h):p&&p(df({items:h,lookup:m}))},[]),a=ff(s),i=U(()=>({nodeQueue:o,edgeQueue:a}),[]);return r(wv.Provider,{value:i,children:e})}function SH(){const e=ve(wv);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const CH=e=>!!e.panZoom;function yd(){const e=bH(),t=je(),n=SH(),o=$e(CH),s=U(()=>{const a=p=>t.getState().nodeLookup.get(p),i=p=>{n.nodeQueue.push(p)},l=p=>{n.edgeQueue.push(p)},c=p=>{const{nodeLookup:m,nodeOrigin:h}=t.getState(),g=pf(p)?p:m.get(p.id),b=g.parentId?K0(g.position,g.measured,g.parentId,m,h):g.position,x={...g,position:b,width:g.measured?.width??g.width,height:g.measured?.height??g.height};return kr(x)},d=(p,m,h={replace:!1})=>{i(g=>g.map(b=>{if(b.id===p){const x=typeof m=="function"?m(b):m;return h.replace&&pf(x)?x:{...b,...x}}return b}))},f=(p,m,h={replace:!1})=>{l(g=>g.map(b=>{if(b.id===p){const x=typeof m=="function"?m(b):m;return h.replace&&wH(x)?x:{...b,...x}}return b}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>a(p)?.internals.userNode,getInternalNode:a,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(m=>({...m}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:i,setEdges:l,addNodes:p=>{const m=Array.isArray(p)?p:[p];n.nodeQueue.push(h=>[...h,...m])},addEdges:p=>{const m=Array.isArray(p)?p:[p];n.edgeQueue.push(h=>[...h,...m])},toObject:()=>{const{nodes:p=[],edges:m=[],transform:h}=t.getState(),[g,b,x]=h;return{nodes:p.map(v=>({...v})),edges:m.map(v=>({...v})),viewport:{x:g,y:b,zoom:x}}},deleteElements:async({nodes:p=[],edges:m=[]})=>{const{nodes:h,edges:g,onNodesDelete:b,onEdgesDelete:x,triggerNodeChanges:v,triggerEdgeChanges:w,onDelete:y,onBeforeDelete:N}=t.getState(),{nodes:k,edges:S}=await VF({nodesToRemove:p,edgesToRemove:m,nodes:h,edges:g,onBeforeDelete:N}),M=S.length>0,P=k.length>0;if(M){const I=S.map(uf);x?.(S),w(I)}if(P){const I=k.map(uf);b?.(k),v(I)}return(P||M)&&y?.({nodes:k,edges:S}),{deletedNodes:k,deletedEdges:S}},getIntersectingNodes:(p,m=!0,h)=>{const g=jp(p),b=g?p:c(p),x=h!==void 0;return b?(h||t.getState().nodes).filter(v=>{const w=t.getState().nodeLookup.get(v.id);if(w&&!g&&(v.id===p.id||!w.internals.positionAbsolute))return!1;const y=kr(x?v:w),N=bo(y,b);return m&&N>0||N>=y.width*y.height||N>=b.width*b.height}):[]},isNodeIntersecting:(p,m,h=!0)=>{const b=jp(p)?p:c(p);if(!b)return!1;const x=bo(b,m);return h&&x>0||x>=m.width*m.height||x>=b.width*b.height},updateNode:d,updateNodeData:(p,m,h={replace:!1})=>{d(p,g=>{const b=typeof m=="function"?m(g):m;return h.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},h)},updateEdge:f,updateEdgeData:(p,m,h={replace:!1})=>{f(p,g=>{const b=typeof m=="function"?m(g):m;return h.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},h)},getNodesBounds:p=>{const{nodeLookup:m,nodeOrigin:h}=t.getState();return BF(p,{nodeLookup:m,nodeOrigin:h})},getHandleConnections:({type:p,id:m,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}-${p}${m?`-${m}`:""}`)?.values()??[]),getNodeConnections:({type:p,handleId:m,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}${p?m?`-${p}-${m}`:`-${p}`:""}`)?.values()??[]),fitView:async p=>{const m=t.getState().fitViewResolver??KF();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:m}),n.nodeQueue.push(h=>[...h]),m.promise}}},[]);return U(()=>({...s,...e,viewportInitialized:o}),[o])}const mf=e=>e.selected,MH=typeof window<"u"?window:void 0;function IH({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=je(),{deleteElements:o}=yd(),s=yo(e,{actInsideInputWithModifier:!1}),a=yo(t,{target:MH});Z(()=>{if(s){const{edges:i,nodes:l}=n.getState();o({nodes:l.filter(mf),edges:i.filter(mf)}),n.setState({nodesSelectionActive:!1})}},[s]),Z(()=>{n.setState({multiSelectionActive:a})},[a])}function AH(e){const t=je();Z(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const o=fd(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",Qt.error004()),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);const o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}const Oa={position:"absolute",width:"100%",height:"100%",top:0,left:0},PH=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function EH({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:s=.5,panOnScrollMode:a=zn.Free,zoomOnDoubleClick:i=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:d,minZoom:f,maxZoom:p,zoomActivationKeyCode:m,preventScrolling:h=!0,children:g,noWheelClassName:b,noPanClassName:x,onViewportChange:v,isControlledViewport:w,paneClickDistance:y,selectionOnDrag:N}){const k=je(),S=ne(null),{userSelectionActive:M,lib:P,connectionInProgress:I}=$e(PH,Be),z=yo(m),$=ne();AH(S);const O=q(R=>{v?.({x:R[0],y:R[1],zoom:R[2]}),w||k.setState({transform:R})},[v,w]);return Z(()=>{if(S.current){$.current=Ej({domNode:S.current,minZoom:f,maxZoom:p,translateExtent:d,viewport:c,onDraggingChange:D=>k.setState(T=>T.paneDragging===D?T:{paneDragging:D}),onPanZoomStart:(D,T)=>{const{onViewportChangeStart:B,onMoveStart:F}=k.getState();F?.(D,T),B?.(T)},onPanZoom:(D,T)=>{const{onViewportChange:B,onMove:F}=k.getState();F?.(D,T),B?.(T)},onPanZoomEnd:(D,T)=>{const{onViewportChangeEnd:B,onMoveEnd:F}=k.getState();F?.(D,T),B?.(T)}});const{x:R,y:A,zoom:L}=$.current.getViewport();return k.setState({panZoom:$.current,transform:[R,A,L],domNode:S.current.closest(".react-flow")}),()=>{$.current?.destroy()}}},[]),Z(()=>{$.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:s,panOnScrollMode:a,zoomOnDoubleClick:i,panOnDrag:l,zoomActivationKeyPressed:z,preventScrolling:h,noPanClassName:x,userSelectionActive:M,noWheelClassName:b,lib:P,onTransformChange:O,connectionInProgress:I,selectionOnDrag:N,paneClickDistance:y})},[e,t,n,o,s,a,i,l,z,h,x,M,b,P,O,I,N,y]),r("div",{className:"react-flow__renderer",ref:S,style:Oa,children:g})}const $H=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function _H(){const{userSelectionActive:e,userSelectionRect:t}=$e($H,Be);return e&&t?r("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const $i=(e,t)=>n=>{n.target===t.current&&e?.(n)},DH=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function LH({isSelecting:e,selectionKeyPressed:t,selectionMode:n=go.Full,panOnDrag:o,paneClickDistance:s,selectionOnDrag:a,onSelectionStart:i,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:d,onPaneScroll:f,onPaneMouseEnter:p,onPaneMouseMove:m,onPaneMouseLeave:h,children:g}){const b=je(),{userSelectionActive:x,elementsSelectable:v,dragging:w,connectionInProgress:y}=$e(DH,Be),N=v&&(e||x),k=ne(null),S=ne(),M=ne(new Set),P=ne(new Set),I=ne(!1),z=B=>{if(I.current||y){I.current=!1;return}c?.(B),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},$=B=>{if(Array.isArray(o)&&o?.includes(2)){B.preventDefault();return}d?.(B)},O=f?B=>f(B):void 0,R=B=>{I.current&&(B.stopPropagation(),I.current=!1)},A=B=>{const{domNode:F}=b.getState();if(S.current=F?.getBoundingClientRect(),!S.current)return;const j=B.target===k.current;if(!j&&!!B.target.closest(".nokey")||!e||!(a&&j||t)||B.button!==0||!B.isPrimary)return;B.target?.setPointerCapture?.(B.pointerId),I.current=!1;const{x:Q,y:K}=_t(B.nativeEvent,S.current);b.setState({userSelectionRect:{width:0,height:0,startX:Q,startY:K,x:Q,y:K}}),j||(B.stopPropagation(),B.preventDefault())},L=B=>{const{userSelectionRect:F,transform:j,nodeLookup:H,edgeLookup:E,connectionLookup:Q,triggerNodeChanges:K,triggerEdgeChanges:Y,defaultEdgeOptions:re,resetSelectedElements:te}=b.getState();if(!S.current||!F)return;const{x:X,y:oe}=_t(B.nativeEvent,S.current),{startX:ge,startY:J}=F;if(!I.current){const he=t?0:s;if(Math.hypot(X-ge,oe-J)<=he)return;te(),i?.(B)}I.current=!0;const G={startX:ge,startY:J,x:X<ge?X:ge,y:oe<J?oe:J,width:Math.abs(X-ge),height:Math.abs(oe-J)},ee=M.current,ae=P.current;M.current=new Set(ud(H,G,j,n===go.Partial,!0).map(he=>he.id)),P.current=new Set;const fe=re?.selectable??!0;for(const he of M.current){const V=Q.get(he);if(V)for(const{edgeId:ie}of V.values()){const ue=E.get(ie);ue&&(ue.selectable??fe)&&P.current.add(ie)}}if(!Hp(ee,M.current)){const he=ar(H,M.current,!0);K(he)}if(!Hp(ae,P.current)){const he=ar(E,P.current);Y(he)}b.setState({userSelectionRect:G,userSelectionActive:!0,nodesSelectionActive:!1})},D=B=>{B.button===0&&(B.target?.releasePointerCapture?.(B.pointerId),!x&&B.target===k.current&&b.getState().userSelectionRect&&z?.(B),b.setState({userSelectionActive:!1,userSelectionRect:null}),I.current&&(l?.(B),b.setState({nodesSelectionActive:M.current.size>0})))},T=o===!0||Array.isArray(o)&&o.includes(0);return u("div",{className:Ue(["react-flow__pane",{draggable:T,dragging:w,selection:e}]),onClick:N?void 0:$i(z,k),onContextMenu:$i($,k),onWheel:$i(O,k),onPointerEnter:N?void 0:p,onPointerMove:N?L:m,onPointerUp:N?D:void 0,onPointerDownCapture:N?A:void 0,onClickCapture:N?R:void 0,onPointerLeave:h,ref:k,style:Oa,children:[g,r(_H,{})]})}function Al({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:s,unselectNodesAndEdges:a,multiSelectionActive:i,nodeLookup:l,onError:c}=t.getState(),d=l.get(e);if(!d){c?.("012",Qt.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&i)&&(a({nodes:[d],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):s([e])}function Nv({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:s,isSelectable:a,nodeClickDistance:i}){const l=je(),[c,d]=_(!1),f=ne();return Z(()=>{f.current=gj({getStoreItems:()=>l.getState(),onNodeMouseDown:p=>{Al({id:p,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),Z(()=>{if(!(t||!e.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:a,nodeId:s,nodeClickDistance:i}),()=>{f.current?.destroy()}},[n,o,t,a,e,s,i]),c}const TH=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function kv(){const e=je();return q(n=>{const{nodeExtent:o,snapToGrid:s,snapGrid:a,nodesDraggable:i,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:f}=e.getState(),p=new Map,m=TH(i),h=s?a[0]:5,g=s?a[1]:5,b=n.direction.x*h*n.factor,x=n.direction.y*g*n.factor;for(const[,v]of d){if(!m(v))continue;let w={x:v.internals.positionAbsolute.x+b,y:v.internals.positionAbsolute.y+x};s&&(w=Lo(w,a));const{position:y,positionAbsolute:N}=H0({nodeId:v.id,nextPosition:w,nodeLookup:d,nodeExtent:o,nodeOrigin:f,onError:l});v.position=y,v.internals.positionAbsolute=N,p.set(v.id,v)}c(p)},[])}const vd=Oe(null),RH=vd.Provider;vd.Consumer;const Sv=()=>ve(vd),OH=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),zH=(e,t,n)=>o=>{const{connectionClickStartHandle:s,connectionMode:a,connection:i}=o,{fromHandle:l,toHandle:c,isValid:d}=i,f=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:l?.nodeId===e&&l?.id===t&&l?.type===n,connectingTo:f,clickConnecting:s?.nodeId===e&&s?.id===t&&s?.type===n,isPossibleEndHandle:a===wr.Strict?l?.type!==n:e!==l?.nodeId||t!==l?.id,connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:f&&d}};function BH({type:e="source",position:t=we.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:s=!0,isConnectableEnd:a=!0,id:i,onConnect:l,children:c,className:d,onMouseDown:f,onTouchStart:p,...m},h){const g=i||null,b=e==="target",x=je(),v=Sv(),{connectOnClick:w,noPanClassName:y,rfId:N}=$e(OH,Be),{connectingFrom:k,connectingTo:S,clickConnecting:M,isPossibleEndHandle:P,connectionInProcess:I,clickConnectionInProcess:z,valid:$}=$e(zH(v,g,e),Be);v||x.getState().onError?.("010",Qt.error010());const O=L=>{const{defaultEdgeOptions:D,onConnect:T,hasDefaultEdges:B}=x.getState(),F={...D,...L};if(B){const{edges:j,setEdges:H}=x.getState();H(ej(F,j))}T?.(F),l?.(F)},R=L=>{if(!v)return;const D=Y0(L.nativeEvent);if(s&&(D&&L.button===0||!D)){const T=x.getState();Ml.onPointerDown(L.nativeEvent,{handleDomNode:L.currentTarget,autoPanOnConnect:T.autoPanOnConnect,connectionMode:T.connectionMode,connectionRadius:T.connectionRadius,domNode:T.domNode,nodeLookup:T.nodeLookup,lib:T.lib,isTarget:b,handleId:g,nodeId:v,flowId:T.rfId,panBy:T.panBy,cancelConnection:T.cancelConnection,onConnectStart:T.onConnectStart,onConnectEnd:(...B)=>x.getState().onConnectEnd?.(...B),updateConnection:T.updateConnection,onConnect:O,isValidConnection:n||((...B)=>x.getState().isValidConnection?.(...B)??!0),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:T.autoPanSpeed,dragThreshold:T.connectionDragThreshold})}D?f?.(L):p?.(L)},A=L=>{const{onClickConnectStart:D,onClickConnectEnd:T,connectionClickStartHandle:B,connectionMode:F,isValidConnection:j,lib:H,rfId:E,nodeLookup:Q,connection:K}=x.getState();if(!v||!B&&!s)return;if(!B){D?.(L.nativeEvent,{nodeId:v,handleId:g,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:v,type:e,id:g}});return}const Y=G0(L.target),re=n||j,{connection:te,isValid:X}=Ml.isValid(L.nativeEvent,{handle:{nodeId:v,id:g,type:e},connectionMode:F,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:re,flowId:E,doc:Y,lib:H,nodeLookup:Q});X&&te&&O(te);const oe=structuredClone(K);delete oe.inProgress,oe.toPosition=oe.toHandle?oe.toHandle.position:null,T?.(L,oe),x.setState({connectionClickStartHandle:null})};return r("div",{"data-handleid":g,"data-nodeid":v,"data-handlepos":t,"data-id":`${N}-${v}-${g}-${e}`,className:Ue(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",y,d,{source:!b,target:b,connectable:o,connectablestart:s,connectableend:a,clickconnecting:M,connectingfrom:k,connectingto:S,valid:$,connectionindicator:o&&(!I||P)&&(I||z?a:s)}]),onMouseDown:R,onTouchStart:R,onClick:w?A:void 0,ref:h,...m,children:c})}const Nn=Fe(vv(BH));function FH({data:e,isConnectable:t,sourcePosition:n=we.Bottom}){return u(xe,{children:[e?.label,r(Nn,{type:"source",position:n,isConnectable:t})]})}function jH({data:e,isConnectable:t,targetPosition:n=we.Top,sourcePosition:o=we.Bottom}){return u(xe,{children:[r(Nn,{type:"target",position:n,isConnectable:t}),e?.label,r(Nn,{type:"source",position:o,isConnectable:t})]})}function HH(){return null}function VH({data:e,isConnectable:t,targetPosition:n=we.Top}){return u(xe,{children:[r(Nn,{type:"target",position:n,isConnectable:t}),e?.label]})}const Ks={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},hf={input:FH,default:jH,output:VH,group:HH};function qH(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 QH=e=>{const{width:t,height:n,x:o,y:s}=Do(e.nodeLookup,{filter:a=>!!a.selected});return{width:$t(t)?t:null,height:$t(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${s}px)`}};function UH({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=je(),{width:s,height:a,transformString:i,userSelectionActive:l}=$e(QH,Be),c=kv(),d=ne(null);Z(()=>{n||d.current?.focus({preventScroll:!0})},[n]);const f=!l&&s!==null&&a!==null;if(Nv({nodeRef:d,disabled:!f}),!f)return null;const p=e?h=>{const g=o.getState().nodes.filter(b=>b.selected);e(h,g)}:void 0,m=h=>{Object.prototype.hasOwnProperty.call(Ks,h.key)&&(h.preventDefault(),c({direction:Ks[h.key],factor:h.shiftKey?4:1}))};return r("div",{className:Ue(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:r("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:m,style:{width:s,height:a}})})}const gf=typeof window<"u"?window:void 0,KH=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Cv({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:i,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:d,selectionOnDrag:f,selectionMode:p,onSelectionStart:m,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:b,zoomActivationKeyCode:x,elementsSelectable:v,zoomOnScroll:w,zoomOnPinch:y,panOnScroll:N,panOnScrollSpeed:k,panOnScrollMode:S,zoomOnDoubleClick:M,panOnDrag:P,defaultViewport:I,translateExtent:z,minZoom:$,maxZoom:O,preventScrolling:R,onSelectionContextMenu:A,noWheelClassName:L,noPanClassName:D,disableKeyboardA11y:T,onViewportChange:B,isControlledViewport:F}){const{nodesSelectionActive:j,userSelectionActive:H}=$e(KH,Be),E=yo(d,{target:gf}),Q=yo(b,{target:gf}),K=Q||P,Y=Q||N,re=f&&K!==!0,te=E||H||re;return IH({deleteKeyCode:c,multiSelectionKeyCode:g}),r(EH,{onPaneContextMenu:a,elementsSelectable:v,zoomOnScroll:w,zoomOnPinch:y,panOnScroll:Y,panOnScrollSpeed:k,panOnScrollMode:S,zoomOnDoubleClick:M,panOnDrag:!E&&K,defaultViewport:I,translateExtent:z,minZoom:$,maxZoom:O,zoomActivationKeyCode:x,preventScrolling:R,noWheelClassName:L,noPanClassName:D,onViewportChange:B,isControlledViewport:F,paneClickDistance:l,selectionOnDrag:re,children:u(LH,{onSelectionStart:m,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:i,panOnDrag:K,isSelecting:!!te,selectionMode:p,selectionKeyPressed:E,paneClickDistance:l,selectionOnDrag:re,children:[e,j&&r(UH,{onSelectionContextMenu:A,noPanClassName:D,disableKeyboardA11y:T})]})})}Cv.displayName="FlowRenderer";const GH=Fe(Cv),WH=e=>t=>e?ud(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 YH(e){return $e(q(WH(e),[e]),Be)}const ZH=e=>e.updateNodeInternals;function XH(){const e=$e(ZH),[t]=_(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;n.forEach(s=>{const a=s.target.getAttribute("data-id");o.set(a,{id:a,nodeElement:s.target,force:!0})}),e(o)}));return Z(()=>()=>{t?.disconnect()},[t]),t}function JH({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const s=je(),a=ne(null),i=ne(null),l=ne(e.sourcePosition),c=ne(e.targetPosition),d=ne(t),f=n&&!!e.internals.handleBounds;return Z(()=>{a.current&&!e.hidden&&(!f||i.current!==a.current)&&(i.current&&o?.unobserve(i.current),o?.observe(a.current),i.current=a.current)},[f,e.hidden]),Z(()=>()=>{i.current&&(o?.unobserve(i.current),i.current=null)},[]),Z(()=>{if(a.current){const p=d.current!==t,m=l.current!==e.sourcePosition,h=c.current!==e.targetPosition;(p||m||h)&&(d.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function eV({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:s,onContextMenu:a,onDoubleClick:i,nodesDraggable:l,elementsSelectable:c,nodesConnectable:d,nodesFocusable:f,resizeObserver:p,noDragClassName:m,noPanClassName:h,disableKeyboardA11y:g,rfId:b,nodeTypes:x,nodeClickDistance:v,onError:w}){const{node:y,internals:N,isParent:k}=$e(X=>{const oe=X.nodeLookup.get(e),ge=X.parentLookup.has(e);return{node:oe,internals:oe.internals,isParent:ge}},Be);let S=y.type||"default",M=x?.[S]||hf[S];M===void 0&&(w?.("003",Qt.error003(S)),S="default",M=x?.default||hf.default);const P=!!(y.draggable||l&&typeof y.draggable>"u"),I=!!(y.selectable||c&&typeof y.selectable>"u"),z=!!(y.connectable||d&&typeof y.connectable>"u"),$=!!(y.focusable||f&&typeof y.focusable>"u"),O=je(),R=U0(y),A=JH({node:y,nodeType:S,hasDimensions:R,resizeObserver:p}),L=Nv({nodeRef:A,disabled:y.hidden||!P,noDragClassName:m,handleSelector:y.dragHandle,nodeId:e,isSelectable:I,nodeClickDistance:v}),D=kv();if(y.hidden)return null;const T=pn(y),B=qH(y),F=I||P||t||n||o||s,j=n?X=>n(X,{...N.userNode}):void 0,H=o?X=>o(X,{...N.userNode}):void 0,E=s?X=>s(X,{...N.userNode}):void 0,Q=a?X=>a(X,{...N.userNode}):void 0,K=i?X=>i(X,{...N.userNode}):void 0,Y=X=>{const{selectNodesOnDrag:oe,nodeDragThreshold:ge}=O.getState();I&&(!oe||!P||ge>0)&&Al({id:e,store:O,nodeRef:A}),t&&t(X,{...N.userNode})},re=X=>{if(!(W0(X.nativeEvent)||g)){if(O0.includes(X.key)&&I){const oe=X.key==="Escape";Al({id:e,store:O,unselect:oe,nodeRef:A})}else if(P&&y.selected&&Object.prototype.hasOwnProperty.call(Ks,X.key)){X.preventDefault();const{ariaLabelConfig:oe}=O.getState();O.setState({ariaLiveMessage:oe["node.a11yDescription.ariaLiveMessage"]({direction:X.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),D({direction:Ks[X.key],factor:X.shiftKey?4:1})}}},te=()=>{if(g||!A.current?.matches(":focus-visible"))return;const{transform:X,width:oe,height:ge,autoPanOnNodeFocus:J,setCenter:G}=O.getState();if(!J)return;ud(new Map([[e,y]]),{x:0,y:0,width:oe,height:ge},X,!0).length>0||G(y.position.x+T.width/2,y.position.y+T.height/2,{zoom:X[2]})};return r("div",{className:Ue(["react-flow__node",`react-flow__node-${S}`,{[h]:P},y.className,{selected:y.selected,selectable:I,parent:k,draggable:P,dragging:L}]),ref:A,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:F?"all":"none",visibility:R?"visible":"hidden",...y.style,...B},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:j,onMouseMove:H,onMouseLeave:E,onContextMenu:Q,onClick:Y,onDoubleClick:K,onKeyDown:$?re:void 0,tabIndex:$?0:void 0,onFocus:$?te:void 0,role:y.ariaRole??($?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${gv}-${b}`,"aria-label":y.ariaLabel,...y.domAttributes,children:r(RH,{value:e,children:r(M,{id:e,data:y.data,type:S,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:y.selected??!1,selectable:I,draggable:P,deletable:y.deletable??!0,isConnectable:z,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:L,dragHandle:y.dragHandle,zIndex:N.z,parentId:y.parentId,...T})})})}var tV=Fe(eV);const nV=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Mv(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:s,onError:a}=$e(nV,Be),i=YH(e.onlyRenderVisibleElements),l=XH();return r("div",{className:"react-flow__nodes",style:Oa,children:i.map(c=>r(tV,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:a},c))})}Mv.displayName="NodeRenderer";const rV=Fe(Mv);function oV(e){return $e(q(n=>{if(!e)return n.edges.map(s=>s.id);const o=[];if(n.width&&n.height)for(const s of n.edges){const a=n.nodeLookup.get(s.source),i=n.nodeLookup.get(s.target);a&&i&&ZF({sourceNode:a,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&o.push(s.id)}return o},[e]),Be)}const sV=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return r("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},aV=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return r("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},bf={[qs.Arrow]:sV,[qs.ArrowClosed]:aV};function iV(e){const t=je();return U(()=>Object.prototype.hasOwnProperty.call(bf,e)?bf[e]:(t.getState().onError?.("009",Qt.error009(e)),null),[e])}const lV=({id:e,type:t,color:n,width:o=12.5,height:s=12.5,markerUnits:a="strokeWidth",strokeWidth:i,orient:l="auto-start-reverse"})=>{const c=iV(t);return c?r("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:l,refX:"0",refY:"0",children:r(c,{color:n,strokeWidth:i})}):null},Iv=({defaultColor:e,rfId:t})=>{const n=$e(a=>a.edges),o=$e(a=>a.defaultEdgeOptions),s=U(()=>sj(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return s.length?r("svg",{className:"react-flow__marker","aria-hidden":"true",children:r("defs",{children:s.map(a=>r(lV,{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};Iv.displayName="MarkerDefinitions";var cV=Fe(Iv);function Av({x:e,y:t,label:n,labelStyle:o,labelShowBg:s=!0,labelBgStyle:a,labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...f}){const[p,m]=_({x:1,y:0,width:0,height:0}),h=Ue(["react-flow__edge-textwrapper",d]),g=ne(null);return Z(()=>{if(g.current){const b=g.current.getBBox();m({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?u("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:h,visibility:p.width?"visible":"hidden",...f,children:[s&&r("rect",{width:p.width+2*i[0],x:-i[0],y:-i[1],height:p.height+2*i[1],className:"react-flow__edge-textbg",style:a,rx:l,ry:l}),r("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:g,style:o,children:n}),c]}):null}Av.displayName="EdgeText";const dV=Fe(Av);function za({path:e,labelX:t,labelY:n,label:o,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:d=20,...f}){return u(xe,{children:[r("path",{...f,d:e,fill:"none",className:Ue(["react-flow__edge-path",f.className])}),d?r("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,o&&$t(t)&&$t(n)?r(dV,{x:t,y:n,label:o,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function xf({pos:e,x1:t,y1:n,x2:o,y2:s}){return e===we.Left||e===we.Right?[.5*(t+o),n]:[t,.5*(n+s)]}function Pv({sourceX:e,sourceY:t,sourcePosition:n=we.Bottom,targetX:o,targetY:s,targetPosition:a=we.Top}){const[i,l]=xf({pos:n,x1:e,y1:t,x2:o,y2:s}),[c,d]=xf({pos:a,x1:o,y1:s,x2:e,y2:t}),[f,p,m,h]=Z0({sourceX:e,sourceY:t,targetX:o,targetY:s,sourceControlX:i,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${i},${l} ${c},${d} ${o},${s}`,f,p,m,h]}function Ev(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,sourcePosition:i,targetPosition:l,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:x,interactionWidth:v})=>{const[w,y,N]=Pv({sourceX:n,sourceY:o,sourcePosition:i,targetX:s,targetY:a,targetPosition:l}),k=e.isInternal?void 0:t;return r(za,{id:k,path:w,labelX:y,labelY:N,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:x,interactionWidth:v})})}const uV=Ev({isInternal:!1}),$v=Ev({isInternal:!0});uV.displayName="SimpleBezierEdge";$v.displayName="SimpleBezierEdgeInternal";function _v(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,sourcePosition:h=we.Bottom,targetPosition:g=we.Top,markerEnd:b,markerStart:x,pathOptions:v,interactionWidth:w})=>{const[y,N,k]=kl({sourceX:n,sourceY:o,sourcePosition:h,targetX:s,targetY:a,targetPosition:g,borderRadius:v?.borderRadius,offset:v?.offset,stepPosition:v?.stepPosition}),S=e.isInternal?void 0:t;return r(za,{id:S,path:y,labelX:N,labelY:k,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:b,markerStart:x,interactionWidth:w})})}const Dv=_v({isInternal:!1}),Lv=_v({isInternal:!0});Dv.displayName="SmoothStepEdge";Lv.displayName="SmoothStepEdgeInternal";function Tv(e){return Fe(({id:t,...n})=>{const o=e.isInternal?void 0:t;return r(Dv,{...n,id:o,pathOptions:U(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const pV=Tv({isInternal:!1}),Rv=Tv({isInternal:!0});pV.displayName="StepEdge";Rv.displayName="StepEdgeInternal";function Ov(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:b})=>{const[x,v,w]=ev({sourceX:n,sourceY:o,targetX:s,targetY:a}),y=e.isInternal?void 0:t;return r(za,{id:y,path:x,labelX:v,labelY:w,label:i,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:b})})}const fV=Ov({isInternal:!1}),zv=Ov({isInternal:!0});fV.displayName="StraightEdge";zv.displayName="StraightEdgeInternal";function Bv(e){return Fe(({id:t,sourceX:n,sourceY:o,targetX:s,targetY:a,sourcePosition:i=we.Bottom,targetPosition:l=we.Top,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:x,pathOptions:v,interactionWidth:w})=>{const[y,N,k]=X0({sourceX:n,sourceY:o,sourcePosition:i,targetX:s,targetY:a,targetPosition:l,curvature:v?.curvature}),S=e.isInternal?void 0:t;return r(za,{id:S,path:y,labelX:N,labelY:k,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:p,labelBgPadding:m,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:x,interactionWidth:w})})}const mV=Bv({isInternal:!1}),Fv=Bv({isInternal:!0});mV.displayName="BezierEdge";Fv.displayName="BezierEdgeInternal";const yf={default:Fv,straight:zv,step:Rv,smoothstep:Lv,simplebezier:$v},vf={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},hV=(e,t,n)=>n===we.Left?e-t:n===we.Right?e+t:e,gV=(e,t,n)=>n===we.Top?e-t:n===we.Bottom?e+t:e,wf="react-flow__edgeupdater";function Nf({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:s,onMouseEnter:a,onMouseOut:i,type:l}){return r("circle",{onMouseDown:s,onMouseEnter:a,onMouseOut:i,className:Ue([wf,`${wf}-${l}`]),cx:hV(t,o,e),cy:gV(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function bV({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:s,targetX:a,targetY:i,sourcePosition:l,targetPosition:c,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,setReconnecting:m,setUpdateHover:h}){const g=je(),b=(N,k)=>{if(N.button!==0)return;const{autoPanOnConnect:S,domNode:M,connectionMode:P,connectionRadius:I,lib:z,onConnectStart:$,cancelConnection:O,nodeLookup:R,rfId:A,panBy:L,updateConnection:D}=g.getState(),T=k.type==="target",B=(H,E)=>{m(!1),p?.(H,n,k.type,E)},F=H=>d?.(n,H),j=(H,E)=>{m(!0),f?.(N,n,k.type),$?.(H,E)};Ml.onPointerDown(N.nativeEvent,{autoPanOnConnect:S,connectionMode:P,connectionRadius:I,domNode:M,handleId:k.id,nodeId:k.nodeId,nodeLookup:R,isTarget:T,edgeUpdaterType:k.type,lib:z,flowId:A,cancelConnection:O,panBy:L,isValidConnection:(...H)=>g.getState().isValidConnection?.(...H)??!0,onConnect:F,onConnectStart:j,onConnectEnd:(...H)=>g.getState().onConnectEnd?.(...H),onReconnectEnd:B,updateConnection:D,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"}),v=N=>b(N,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),w=()=>h(!0),y=()=>h(!1);return u(xe,{children:[(e===!0||e==="source")&&r(Nf,{position:l,centerX:o,centerY:s,radius:t,onMouseDown:x,onMouseEnter:w,onMouseOut:y,type:"source"}),(e===!0||e==="target")&&r(Nf,{position:c,centerX:a,centerY:i,radius:t,onMouseDown:v,onMouseEnter:w,onMouseOut:y,type:"target"})]})}function xV({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:s,onDoubleClick:a,onContextMenu:i,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,reconnectRadius:f,onReconnect:p,onReconnectStart:m,onReconnectEnd:h,rfId:g,edgeTypes:b,noPanClassName:x,onError:v,disableKeyboardA11y:w}){let y=$e(G=>G.edgeLookup.get(e));const N=$e(G=>G.defaultEdgeOptions);y=N?{...N,...y}:y;let k=y.type||"default",S=b?.[k]||yf[k];S===void 0&&(v?.("011",Qt.error011(k)),k="default",S=b?.default||yf.default);const M=!!(y.focusable||t&&typeof y.focusable>"u"),P=typeof p<"u"&&(y.reconnectable||n&&typeof y.reconnectable>"u"),I=!!(y.selectable||o&&typeof y.selectable>"u"),z=ne(null),[$,O]=_(!1),[R,A]=_(!1),L=je(),{zIndex:D,sourceX:T,sourceY:B,targetX:F,targetY:j,sourcePosition:H,targetPosition:E}=$e(q(G=>{const ee=G.nodeLookup.get(y.source),ae=G.nodeLookup.get(y.target);if(!ee||!ae)return{zIndex:y.zIndex,...vf};const fe=oj({id:e,sourceNode:ee,targetNode:ae,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:G.connectionMode,onError:v});return{zIndex:YF({selected:y.selected,zIndex:y.zIndex,sourceNode:ee,targetNode:ae,elevateOnSelect:G.elevateEdgesOnSelect,zIndexMode:G.zIndexMode}),...fe||vf}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),Be),Q=U(()=>y.markerStart?`url('#${Sl(y.markerStart,g)}')`:void 0,[y.markerStart,g]),K=U(()=>y.markerEnd?`url('#${Sl(y.markerEnd,g)}')`:void 0,[y.markerEnd,g]);if(y.hidden||T===null||B===null||F===null||j===null)return null;const Y=G=>{const{addSelectedEdges:ee,unselectNodesAndEdges:ae,multiSelectionActive:fe}=L.getState();I&&(L.setState({nodesSelectionActive:!1}),y.selected&&fe?(ae({nodes:[],edges:[y]}),z.current?.blur()):ee([e])),s&&s(G,y)},re=a?G=>{a(G,{...y})}:void 0,te=i?G=>{i(G,{...y})}:void 0,X=l?G=>{l(G,{...y})}:void 0,oe=c?G=>{c(G,{...y})}:void 0,ge=d?G=>{d(G,{...y})}:void 0,J=G=>{if(!w&&O0.includes(G.key)&&I){const{unselectNodesAndEdges:ee,addSelectedEdges:ae}=L.getState();G.key==="Escape"?(z.current?.blur(),ee({edges:[y]})):ae([e])}};return r("svg",{style:{zIndex:D},children:u("g",{className:Ue(["react-flow__edge",`react-flow__edge-${k}`,y.className,x,{selected:y.selected,animated:y.animated,inactive:!I&&!s,updating:$,selectable:I}]),onClick:Y,onDoubleClick:re,onContextMenu:te,onMouseEnter:X,onMouseMove:oe,onMouseLeave:ge,onKeyDown:M?J:void 0,tabIndex:M?0:void 0,role:y.ariaRole??(M?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":M?`${bv}-${g}`:void 0,ref:z,...y.domAttributes,children:[!R&&r(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:I,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:T,sourceY:B,targetX:F,targetY:j,sourcePosition:H,targetPosition:E,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:Q,markerEnd:K,pathOptions:"pathOptions"in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),P&&r(bV,{edge:y,isReconnectable:P,reconnectRadius:f,onReconnect:p,onReconnectStart:m,onReconnectEnd:h,sourceX:T,sourceY:B,targetX:F,targetY:j,sourcePosition:H,targetPosition:E,setUpdateHover:O,setReconnecting:A})]})})}var yV=Fe(xV);const vV=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function jv({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:s,onReconnect:a,onEdgeContextMenu:i,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeClick:f,reconnectRadius:p,onEdgeDoubleClick:m,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:b}){const{edgesFocusable:x,edgesReconnectable:v,elementsSelectable:w,onError:y}=$e(vV,Be),N=oV(t);return u("div",{className:"react-flow__edges",children:[r(cV,{defaultColor:e,rfId:n}),N.map(k=>r(yV,{id:k,edgesFocusable:x,edgesReconnectable:v,elementsSelectable:w,noPanClassName:s,onReconnect:a,onContextMenu:i,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onClick:f,reconnectRadius:p,onDoubleClick:m,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:y,edgeTypes:o,disableKeyboardA11y:b},k))]})}jv.displayName="EdgeRenderer";const wV=Fe(jv),NV=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function kV({children:e}){const t=$e(NV);return r("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function SV(e){const t=yd(),n=ne(!1);Z(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const CV=e=>e.panZoom?.syncViewport;function MV(e){const t=$e(CV),n=je();return Z(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function IV(e){return e.connection.inProgress?{...e.connection,to:To(e.connection.to,e.transform)}:{...e.connection}}function AV(e){return IV}function PV(e){const t=AV();return $e(t,Be)}const EV=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function $V({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:s,width:a,height:i,isValid:l,inProgress:c}=$e(EV,Be);return!(a&&s&&c)?null:r("svg",{style:e,width:a,height:i,className:"react-flow__connectionline react-flow__container",children:r("g",{className:Ue(["react-flow__connection",F0(l)]),children:r(Hv,{style:t,type:n,CustomComponent:o,isValid:l})})})}const Hv=({style:e,type:t=bn.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:s,from:a,fromNode:i,fromHandle:l,fromPosition:c,to:d,toNode:f,toHandle:p,toPosition:m,pointer:h}=PV();if(!s)return;if(n)return r(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:l,fromX:a.x,fromY:a.y,toX:d.x,toY:d.y,fromPosition:c,toPosition:m,connectionStatus:F0(o),toNode:f,toHandle:p,pointer:h});let g="";const b={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:d.x,targetY:d.y,targetPosition:m};switch(t){case bn.Bezier:[g]=X0(b);break;case bn.SimpleBezier:[g]=Pv(b);break;case bn.Step:[g]=kl({...b,borderRadius:0});break;case bn.SmoothStep:[g]=kl(b);break;default:[g]=ev(b)}return r("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};Hv.displayName="ConnectionLine";const _V={};function kf(e=_V){ne(e),je(),Z(()=>{},[e])}function DV(){je(),ne(!1),Z(()=>{},[])}function Vv({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:s,onNodeDoubleClick:a,onEdgeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,onSelectionContextMenu:p,onSelectionStart:m,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:b,connectionLineComponent:x,connectionLineContainerStyle:v,selectionKeyCode:w,selectionOnDrag:y,selectionMode:N,multiSelectionKeyCode:k,panActivationKeyCode:S,zoomActivationKeyCode:M,deleteKeyCode:P,onlyRenderVisibleElements:I,elementsSelectable:z,defaultViewport:$,translateExtent:O,minZoom:R,maxZoom:A,preventScrolling:L,defaultMarkerColor:D,zoomOnScroll:T,zoomOnPinch:B,panOnScroll:F,panOnScrollSpeed:j,panOnScrollMode:H,zoomOnDoubleClick:E,panOnDrag:Q,onPaneClick:K,onPaneMouseEnter:Y,onPaneMouseMove:re,onPaneMouseLeave:te,onPaneScroll:X,onPaneContextMenu:oe,paneClickDistance:ge,nodeClickDistance:J,onEdgeContextMenu:G,onEdgeMouseEnter:ee,onEdgeMouseMove:ae,onEdgeMouseLeave:fe,reconnectRadius:he,onReconnect:V,onReconnectStart:ie,onReconnectEnd:ue,noDragClassName:de,noWheelClassName:le,noPanClassName:Se,disableKeyboardA11y:pe,nodeExtent:Ie,rfId:Te,viewport:We,onViewportChange:rt}){return kf(e),kf(t),DV(),SV(n),MV(We),r(GH,{onPaneClick:K,onPaneMouseEnter:Y,onPaneMouseMove:re,onPaneMouseLeave:te,onPaneContextMenu:oe,onPaneScroll:X,paneClickDistance:ge,deleteKeyCode:P,selectionKeyCode:w,selectionOnDrag:y,selectionMode:N,onSelectionStart:m,onSelectionEnd:h,multiSelectionKeyCode:k,panActivationKeyCode:S,zoomActivationKeyCode:M,elementsSelectable:z,zoomOnScroll:T,zoomOnPinch:B,zoomOnDoubleClick:E,panOnScroll:F,panOnScrollSpeed:j,panOnScrollMode:H,panOnDrag:Q,defaultViewport:$,translateExtent:O,minZoom:R,maxZoom:A,onSelectionContextMenu:p,preventScrolling:L,noDragClassName:de,noWheelClassName:le,noPanClassName:Se,disableKeyboardA11y:pe,onViewportChange:rt,isControlledViewport:!!We,children:u(kV,{children:[r(wV,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:i,onReconnect:V,onReconnectStart:ie,onReconnectEnd:ue,onlyRenderVisibleElements:I,onEdgeContextMenu:G,onEdgeMouseEnter:ee,onEdgeMouseMove:ae,onEdgeMouseLeave:fe,reconnectRadius:he,defaultMarkerColor:D,noPanClassName:Se,disableKeyboardA11y:pe,rfId:Te}),r($V,{style:b,type:g,component:x,containerStyle:v}),r("div",{className:"react-flow__edgelabel-renderer"}),r(rV,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,nodeClickDistance:J,onlyRenderVisibleElements:I,noPanClassName:Se,noDragClassName:de,disableKeyboardA11y:pe,nodeExtent:Ie,rfId:Te}),r("div",{className:"react-flow__viewport-portal"})]})})}Vv.displayName="GraphView";const LV=Fe(Vv),Sf=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c=.5,maxZoom:d=2,nodeOrigin:f,nodeExtent:p,zIndexMode:m="basic"}={})=>{const h=new Map,g=new Map,b=new Map,x=new Map,v=o??t??[],w=n??e??[],y=f??[0,0],N=p??ho;rv(b,x,v);const{nodesInitialized:k}=Cl(w,h,g,{nodeOrigin:y,nodeExtent:N,zIndexMode:m});let S=[0,0,1];if(i&&s&&a){const M=Do(h,{filter:$=>!!(($.width||$.initialWidth)&&($.height||$.initialHeight))}),{x:P,y:I,zoom:z}=pd(M,s,a,c,d,l?.padding??.1);S=[P,I,z]}return{rfId:"1",width:s??0,height:a??0,transform:S,nodes:w,nodesInitialized:k,nodeLookup:h,parentLookup:g,edges:v,edgeLookup:x,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:c,maxZoom:d,translateExtent:ho,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:wr.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:i??!1,fitViewOptions:l,fitViewResolver:null,connection:{...B0},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:qF,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:z0,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},TV=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:p,zIndexMode:m})=>Xj((h,g)=>{async function b(){const{nodeLookup:x,panZoom:v,fitViewOptions:w,fitViewResolver:y,width:N,height:k,minZoom:S,maxZoom:M}=g();v&&(await HF({nodes:x,width:N,height:k,panZoom:v,minZoom:S,maxZoom:M},w),y?.resolve(!0),h({fitViewResolver:null}))}return{...Sf({nodes:e,edges:t,width:s,height:a,fitView:i,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:p,defaultNodes:n,defaultEdges:o,zIndexMode:m}),setNodes:x=>{const{nodeLookup:v,parentLookup:w,nodeOrigin:y,elevateNodesOnSelect:N,fitViewQueued:k,zIndexMode:S,nodesSelectionActive:M}=g(),{nodesInitialized:P,hasSelectedNodes:I}=Cl(x,v,w,{nodeOrigin:y,nodeExtent:p,elevateNodesOnSelect:N,checkEquality:!0,zIndexMode:S}),z=M&&I;k&&P?(b(),h({nodes:x,nodesInitialized:P,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:z})):h({nodes:x,nodesInitialized:P,nodesSelectionActive:z})},setEdges:x=>{const{connectionLookup:v,edgeLookup:w}=g();rv(v,w,x),h({edges:x})},setDefaultNodesAndEdges:(x,v)=>{if(x){const{setNodes:w}=g();w(x),h({hasDefaultNodes:!0})}if(v){const{setEdges:w}=g();w(v),h({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:v,nodeLookup:w,parentLookup:y,domNode:N,nodeOrigin:k,nodeExtent:S,debug:M,fitViewQueued:P,zIndexMode:I}=g(),{changes:z,updatedInternals:$}=pj(x,w,y,N,k,S,I);$&&(lj(w,y,{nodeOrigin:k,nodeExtent:S,zIndexMode:I}),P?(b(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),z?.length>0&&(M&&console.log("React Flow: trigger node changes",z),v?.(z)))},updateNodePositions:(x,v=!1)=>{const w=[];let y=[];const{nodeLookup:N,triggerNodeChanges:k,connection:S,updateConnection:M,onNodesChangeMiddlewareMap:P}=g();for(const[I,z]of x){const $=N.get(I),O=!!($?.expandParent&&$?.parentId&&z?.position),R={id:I,type:"position",position:O?{x:Math.max(0,z.position.x),y:Math.max(0,z.position.y)}:z.position,dragging:v};if($&&S.inProgress&&S.fromNode.id===$.id){const A=Qn($,S.fromHandle,we.Left,!0);M({...S,from:A})}O&&$.parentId&&w.push({id:I,parentId:$.parentId,rect:{...z.internals.positionAbsolute,width:z.measured.width??0,height:z.measured.height??0}}),y.push(R)}if(w.length>0){const{parentLookup:I,nodeOrigin:z}=g(),$=xd(w,N,I,z);y.push(...$)}for(const I of P.values())y=I(y);k(y)},triggerNodeChanges:x=>{const{onNodesChange:v,setNodes:w,nodes:y,hasDefaultNodes:N,debug:k}=g();if(x?.length){if(N){const S=yH(x,y);w(S)}k&&console.log("React Flow: trigger node changes",x),v?.(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:v,setEdges:w,edges:y,hasDefaultEdges:N,debug:k}=g();if(x?.length){if(N){const S=vH(x,y);w(S)}k&&console.log("React Flow: trigger edge changes",x),v?.(x)}},addSelectedNodes:x=>{const{multiSelectionActive:v,edgeLookup:w,nodeLookup:y,triggerNodeChanges:N,triggerEdgeChanges:k}=g();if(v){const S=x.map(M=>Dn(M,!0));N(S);return}N(ar(y,new Set([...x]),!0)),k(ar(w))},addSelectedEdges:x=>{const{multiSelectionActive:v,edgeLookup:w,nodeLookup:y,triggerNodeChanges:N,triggerEdgeChanges:k}=g();if(v){const S=x.map(M=>Dn(M,!0));k(S);return}k(ar(w,new Set([...x]))),N(ar(y,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:v}={})=>{const{edges:w,nodes:y,nodeLookup:N,triggerNodeChanges:k,triggerEdgeChanges:S}=g(),M=x||y,P=v||w,I=[];for(const $ of M){if(!$.selected)continue;const O=N.get($.id);O&&(O.selected=!1),I.push(Dn($.id,!1))}const z=[];for(const $ of P)$.selected&&z.push(Dn($.id,!1));k(I),S(z)},setMinZoom:x=>{const{panZoom:v,maxZoom:w}=g();v?.setScaleExtent([x,w]),h({minZoom:x})},setMaxZoom:x=>{const{panZoom:v,minZoom:w}=g();v?.setScaleExtent([w,x]),h({maxZoom:x})},setTranslateExtent:x=>{g().panZoom?.setTranslateExtent(x),h({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:v,triggerNodeChanges:w,triggerEdgeChanges:y,elementsSelectable:N}=g();if(!N)return;const k=v.reduce((M,P)=>P.selected?[...M,Dn(P.id,!1)]:M,[]),S=x.reduce((M,P)=>P.selected?[...M,Dn(P.id,!1)]:M,[]);w(k),y(S)},setNodeExtent:x=>{const{nodes:v,nodeLookup:w,parentLookup:y,nodeOrigin:N,elevateNodesOnSelect:k,nodeExtent:S,zIndexMode:M}=g();x[0][0]===S[0][0]&&x[0][1]===S[0][1]&&x[1][0]===S[1][0]&&x[1][1]===S[1][1]||(Cl(v,w,y,{nodeOrigin:N,nodeExtent:x,elevateNodesOnSelect:k,checkEquality:!1,zIndexMode:M}),h({nodeExtent:x}))},panBy:x=>{const{transform:v,width:w,height:y,panZoom:N,translateExtent:k}=g();return fj({delta:x,panZoom:N,transform:v,translateExtent:k,width:w,height:y})},setCenter:async(x,v,w)=>{const{width:y,height:N,maxZoom:k,panZoom:S}=g();if(!S)return Promise.resolve(!1);const M=typeof w?.zoom<"u"?w.zoom:k;return await S.setViewport({x:y/2-x*M,y:N/2-v*M,zoom:M},{duration:w?.duration,ease:w?.ease,interpolate:w?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...B0}})},updateConnection:x=>{h({connection:x})},reset:()=>h({...Sf()})}},Object.is);function RV({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:s,initialHeight:a,initialMinZoom:i,initialMaxZoom:l,initialFitViewOptions:c,fitView:d,nodeOrigin:f,nodeExtent:p,zIndexMode:m,children:h}){const[g]=_(()=>TV({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:s,height:a,fitView:d,minZoom:i,maxZoom:l,fitViewOptions:c,nodeOrigin:f,nodeExtent:p,zIndexMode:m}));return r(Jj,{value:g,children:r(kH,{children:h})})}function OV({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:s,width:a,height:i,fitView:l,fitViewOptions:c,minZoom:d,maxZoom:f,nodeOrigin:p,nodeExtent:m,zIndexMode:h}){return ve(Ta)?r(xe,{children:e}):r(RV,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:i,fitView:l,initialFitViewOptions:c,initialMinZoom:d,initialMaxZoom:f,nodeOrigin:p,nodeExtent:m,zIndexMode:h,children:e})}const zV={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function BV({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:s,nodeTypes:a,edgeTypes:i,onNodeClick:l,onEdgeClick:c,onInit:d,onMove:f,onMoveStart:p,onMoveEnd:m,onConnect:h,onConnectStart:g,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:v,onNodeMouseEnter:w,onNodeMouseMove:y,onNodeMouseLeave:N,onNodeContextMenu:k,onNodeDoubleClick:S,onNodeDragStart:M,onNodeDrag:P,onNodeDragStop:I,onNodesDelete:z,onEdgesDelete:$,onDelete:O,onSelectionChange:R,onSelectionDragStart:A,onSelectionDrag:L,onSelectionDragStop:D,onSelectionContextMenu:T,onSelectionStart:B,onSelectionEnd:F,onBeforeDelete:j,connectionMode:H,connectionLineType:E=bn.Bezier,connectionLineStyle:Q,connectionLineComponent:K,connectionLineContainerStyle:Y,deleteKeyCode:re="Backspace",selectionKeyCode:te="Shift",selectionOnDrag:X=!1,selectionMode:oe=go.Full,panActivationKeyCode:ge="Space",multiSelectionKeyCode:J=xo()?"Meta":"Control",zoomActivationKeyCode:G=xo()?"Meta":"Control",snapToGrid:ee,snapGrid:ae,onlyRenderVisibleElements:fe=!1,selectNodesOnDrag:he,nodesDraggable:V,autoPanOnNodeFocus:ie,nodesConnectable:ue,nodesFocusable:de,nodeOrigin:le=xv,edgesFocusable:Se,edgesReconnectable:pe,elementsSelectable:Ie=!0,defaultViewport:Te=pH,minZoom:We=.5,maxZoom:rt=2,translateExtent:nr=ho,preventScrolling:me=!0,nodeExtent:Ee,defaultMarkerColor:_e="#b1b1b7",zoomOnScroll:Re=!0,zoomOnPinch:In=!0,panOnScroll:An=!1,panOnScrollSpeed:Rr=.5,panOnScrollMode:Gv=zn.Free,zoomOnDoubleClick:Wv=!0,panOnDrag:Yv=!0,onPaneClick:Zv,onPaneMouseEnter:Xv,onPaneMouseMove:Jv,onPaneMouseLeave:e1,onPaneScroll:t1,onPaneContextMenu:n1,paneClickDistance:r1=1,nodeClickDistance:o1=0,children:s1,onReconnect:a1,onReconnectStart:i1,onReconnectEnd:l1,onEdgeContextMenu:c1,onEdgeDoubleClick:d1,onEdgeMouseEnter:u1,onEdgeMouseMove:p1,onEdgeMouseLeave:f1,reconnectRadius:m1=10,onNodesChange:h1,onEdgesChange:g1,noDragClassName:b1="nodrag",noWheelClassName:x1="nowheel",noPanClassName:wd="nopan",fitView:Nd,fitViewOptions:kd,connectOnClick:y1,attributionPosition:v1,proOptions:w1,defaultEdgeOptions:N1,elevateNodesOnSelect:k1=!0,elevateEdgesOnSelect:S1=!1,disableKeyboardA11y:Sd=!1,autoPanOnConnect:C1,autoPanOnNodeDrag:M1,autoPanSpeed:I1,connectionRadius:A1,isValidConnection:P1,onError:E1,style:$1,id:Cd,nodeDragThreshold:_1,connectionDragThreshold:D1,viewport:L1,onViewportChange:T1,width:R1,height:O1,colorMode:z1="light",debug:B1,onScroll:Md,ariaLabelConfig:F1,zIndexMode:Id="basic",...j1},H1){const Ba=Cd||"1",V1=gH(z1),q1=q(Ad=>{Ad.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Md?.(Ad)},[Md]);return r("div",{"data-testid":"rf__wrapper",...j1,onScroll:q1,style:{...$1,...zV},ref:H1,className:Ue(["react-flow",s,V1]),id:Cd,role:"application",children:u(OV,{nodes:e,edges:t,width:R1,height:O1,fitView:Nd,fitViewOptions:kd,minZoom:We,maxZoom:rt,nodeOrigin:le,nodeExtent:Ee,zIndexMode:Id,children:[r(hH,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:h,onConnectStart:g,onConnectEnd:b,onClickConnectStart:x,onClickConnectEnd:v,nodesDraggable:V,autoPanOnNodeFocus:ie,nodesConnectable:ue,nodesFocusable:de,edgesFocusable:Se,edgesReconnectable:pe,elementsSelectable:Ie,elevateNodesOnSelect:k1,elevateEdgesOnSelect:S1,minZoom:We,maxZoom:rt,nodeExtent:Ee,onNodesChange:h1,onEdgesChange:g1,snapToGrid:ee,snapGrid:ae,connectionMode:H,translateExtent:nr,connectOnClick:y1,defaultEdgeOptions:N1,fitView:Nd,fitViewOptions:kd,onNodesDelete:z,onEdgesDelete:$,onDelete:O,onNodeDragStart:M,onNodeDrag:P,onNodeDragStop:I,onSelectionDrag:L,onSelectionDragStart:A,onSelectionDragStop:D,onMove:f,onMoveStart:p,onMoveEnd:m,noPanClassName:wd,nodeOrigin:le,rfId:Ba,autoPanOnConnect:C1,autoPanOnNodeDrag:M1,autoPanSpeed:I1,onError:E1,connectionRadius:A1,isValidConnection:P1,selectNodesOnDrag:he,nodeDragThreshold:_1,connectionDragThreshold:D1,onBeforeDelete:j,debug:B1,ariaLabelConfig:F1,zIndexMode:Id}),r(LV,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:w,onNodeMouseMove:y,onNodeMouseLeave:N,onNodeContextMenu:k,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:i,connectionLineType:E,connectionLineStyle:Q,connectionLineComponent:K,connectionLineContainerStyle:Y,selectionKeyCode:te,selectionOnDrag:X,selectionMode:oe,deleteKeyCode:re,multiSelectionKeyCode:J,panActivationKeyCode:ge,zoomActivationKeyCode:G,onlyRenderVisibleElements:fe,defaultViewport:Te,translateExtent:nr,minZoom:We,maxZoom:rt,preventScrolling:me,zoomOnScroll:Re,zoomOnPinch:In,zoomOnDoubleClick:Wv,panOnScroll:An,panOnScrollSpeed:Rr,panOnScrollMode:Gv,panOnDrag:Yv,onPaneClick:Zv,onPaneMouseEnter:Xv,onPaneMouseMove:Jv,onPaneMouseLeave:e1,onPaneScroll:t1,onPaneContextMenu:n1,paneClickDistance:r1,nodeClickDistance:o1,onSelectionContextMenu:T,onSelectionStart:B,onSelectionEnd:F,onReconnect:a1,onReconnectStart:i1,onReconnectEnd:l1,onEdgeContextMenu:c1,onEdgeDoubleClick:d1,onEdgeMouseEnter:u1,onEdgeMouseMove:p1,onEdgeMouseLeave:f1,reconnectRadius:m1,defaultMarkerColor:_e,noDragClassName:b1,noWheelClassName:x1,noPanClassName:wd,rfId:Ba,disableKeyboardA11y:Sd,nodeExtent:Ee,viewport:L1,onViewportChange:T1}),r(uH,{onSelectionChange:R}),s1,r(aH,{proOptions:w1,position:v1}),r(sH,{rfId:Ba,disableKeyboardA11y:Sd})]})})}var FV=vv(BV);function jV({dimensions:e,lineWidth:t,variant:n,className:o}){return r("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Ue(["react-flow__background-pattern",n,o])})}function HV({radius:e,className:t}){return r("circle",{cx:e,cy:e,r:e,className:Ue(["react-flow__background-pattern","dots",t])})}var yn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(yn||(yn={}));const VV={[yn.Dots]:1,[yn.Lines]:1,[yn.Cross]:6},qV=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function qv({id:e,variant:t=yn.Dots,gap:n=20,size:o,lineWidth:s=1,offset:a=0,color:i,bgColor:l,style:c,className:d,patternClassName:f}){const p=ne(null),{transform:m,patternId:h}=$e(qV,Be),g=o||VV[t],b=t===yn.Dots,x=t===yn.Cross,v=Array.isArray(n)?n:[n,n],w=[v[0]*m[2]||1,v[1]*m[2]||1],y=g*m[2],N=Array.isArray(a)?a:[a,a],k=x?[y,y]:w,S=[N[0]*m[2]||1+k[0]/2,N[1]*m[2]||1+k[1]/2],M=`${h}${e||""}`;return u("svg",{className:Ue(["react-flow__background",d]),style:{...c,...Oa,"--xy-background-color-props":l,"--xy-background-pattern-color-props":i},ref:p,"data-testid":"rf__background",children:[r("pattern",{id:M,x:m[0]%w[0],y:m[1]%w[1],width:w[0],height:w[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${S[0]},-${S[1]})`,children:b?r(HV,{radius:y/2,className:f}):r(jV,{dimensions:k,lineWidth:s,variant:t,className:f})}),r("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}qv.displayName="Background";const QV=Fe(qv);function UV(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:r("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function KV(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:r("path",{d:"M0 0h32v4.2H0z"})})}function GV(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:r("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function WV(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function YV(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function ds({children:e,className:t,...n}){return r("button",{type:"button",className:Ue(["react-flow__controls-button",t]),...n,children:e})}const ZV=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Qv({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:s,onZoomIn:a,onZoomOut:i,onFitView:l,onInteractiveChange:c,className:d,children:f,position:p="bottom-left",orientation:m="vertical","aria-label":h}){const g=je(),{isInteractive:b,minZoomReached:x,maxZoomReached:v,ariaLabelConfig:w}=$e(ZV,Be),{zoomIn:y,zoomOut:N,fitView:k}=yd(),S=()=>{y(),a?.()},M=()=>{N(),i?.()},P=()=>{k(s),l?.()},I=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),c?.(!b)};return u(Ra,{className:Ue(["react-flow__controls",m==="horizontal"?"horizontal":"vertical",d]),position:p,style:e,"data-testid":"rf__controls","aria-label":h??w["controls.ariaLabel"],children:[t&&u(xe,{children:[r(ds,{onClick:S,className:"react-flow__controls-zoomin",title:w["controls.zoomIn.ariaLabel"],"aria-label":w["controls.zoomIn.ariaLabel"],disabled:v,children:r(UV,{})}),r(ds,{onClick:M,className:"react-flow__controls-zoomout",title:w["controls.zoomOut.ariaLabel"],"aria-label":w["controls.zoomOut.ariaLabel"],disabled:x,children:r(KV,{})})]}),n&&r(ds,{className:"react-flow__controls-fitview",onClick:P,title:w["controls.fitView.ariaLabel"],"aria-label":w["controls.fitView.ariaLabel"],children:r(GV,{})}),o&&r(ds,{className:"react-flow__controls-interactive",onClick:I,title:w["controls.interactive.ariaLabel"],"aria-label":w["controls.interactive.ariaLabel"],children:b?r(YV,{}):r(WV,{})}),f]})}Qv.displayName="Controls";const XV=Fe(Qv);function JV({id:e,x:t,y:n,width:o,height:s,style:a,color:i,strokeColor:l,strokeWidth:c,className:d,borderRadius:f,shapeRendering:p,selected:m,onClick:h}){const{background:g,backgroundColor:b}=a||{},x=i||g||b;return r("rect",{className:Ue(["react-flow__minimap-node",{selected:m},d]),x:t,y:n,rx:f,ry:f,width:o,height:s,style:{fill:x,stroke:l,strokeWidth:c},shapeRendering:p,onClick:h?v=>h(v,e):void 0})}const eq=Fe(JV),tq=e=>e.nodes.map(t=>t.id),_i=e=>e instanceof Function?e:()=>e;function nq({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:s,nodeComponent:a=eq,onClick:i}){const l=$e(tq,Be),c=_i(t),d=_i(e),f=_i(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return r(xe,{children:l.map(m=>r(oq,{id:m,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:f,nodeBorderRadius:o,nodeStrokeWidth:s,NodeComponent:a,onClick:i,shapeRendering:p},m))})}function rq({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:s,nodeStrokeWidth:a,shapeRendering:i,NodeComponent:l,onClick:c}){const{node:d,x:f,y:p,width:m,height:h}=$e(g=>{const b=g.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const x=b.internals.userNode,{x:v,y:w}=b.internals.positionAbsolute,{width:y,height:N}=pn(x);return{node:x,x:v,y:w,width:y,height:N}},Be);return!d||d.hidden||!U0(d)?null:r(l,{x:f,y:p,width:m,height:h,style:d.style,selected:!!d.selected,className:o(d),color:t(d),borderRadius:s,strokeColor:n(d),strokeWidth:a,shapeRendering:i,onClick:c,id:d.id})}const oq=Fe(rq);var sq=Fe(nq);const aq=200,iq=150,lq=e=>!e.hidden,cq=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?Q0(Do(e.nodeLookup,{filter:lq}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},dq="react-flow__minimap-desc";function Uv({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:s="",nodeBorderRadius:a=5,nodeStrokeWidth:i,nodeComponent:l,bgColor:c,maskColor:d,maskStrokeColor:f,maskStrokeWidth:p,position:m="bottom-right",onClick:h,onNodeClick:g,pannable:b=!1,zoomable:x=!1,ariaLabel:v,inversePan:w,zoomStep:y=1,offsetScale:N=5}){const k=je(),S=ne(null),{boundingRect:M,viewBB:P,rfId:I,panZoom:z,translateExtent:$,flowWidth:O,flowHeight:R,ariaLabelConfig:A}=$e(cq,Be),L=e?.width??aq,D=e?.height??iq,T=M.width/L,B=M.height/D,F=Math.max(T,B),j=F*L,H=F*D,E=N*F,Q=M.x-(j-M.width)/2-E,K=M.y-(H-M.height)/2-E,Y=j+E*2,re=H+E*2,te=`${dq}-${I}`,X=ne(0),oe=ne();X.current=F,Z(()=>{if(S.current&&z)return oe.current=Nj({domNode:S.current,panZoom:z,getTransform:()=>k.getState().transform,getViewScale:()=>X.current}),()=>{oe.current?.destroy()}},[z]),Z(()=>{oe.current?.update({translateExtent:$,width:O,height:R,inversePan:w,pannable:b,zoomStep:y,zoomable:x})},[b,x,w,y,$,O,R]);const ge=h?ee=>{const[ae,fe]=oe.current?.pointer(ee)||[0,0];h(ee,{x:ae,y:fe})}:void 0,J=g?q((ee,ae)=>{const fe=k.getState().nodeLookup.get(ae).internals.userNode;g(ee,fe)},[]):void 0,G=v??A["minimap.ariaLabel"];return r(Ra,{position:m,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*F:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof i=="number"?i:void 0},className:Ue(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:u("svg",{width:L,height:D,viewBox:`${Q} ${K} ${Y} ${re}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":te,ref:S,onClick:ge,children:[G&&r("title",{id:te,children:G}),r(sq,{onClick:J,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:s,nodeStrokeWidth:i,nodeComponent:l}),r("path",{className:"react-flow__minimap-mask",d:`M${Q-E},${K-E}h${Y+E*2}v${re+E*2}h${-Y-E*2}z
|
|
1098
|
+
M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Uv.displayName="MiniMap";Fe(Uv);const uq=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,pq={[Cr.Line]:"right",[Cr.Handle]:"bottom-right"};function fq({nodeId:e,position:t,variant:n=Cr.Handle,className:o,style:s=void 0,children:a,color:i,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:m,autoScale:h=!0,shouldResize:g,onResizeStart:b,onResize:x,onResizeEnd:v}){const w=Sv(),y=typeof e=="string"?e:w,N=je(),k=ne(null),S=n===Cr.Handle,M=$e(q(uq(S&&h),[S,h]),Be),P=ne(null),I=t??pq[n];Z(()=>{if(!(!k.current||!y))return P.current||(P.current=Rj({domNode:k.current,nodeId:y,getStoreItems:()=>{const{nodeLookup:$,transform:O,snapGrid:R,snapToGrid:A,nodeOrigin:L,domNode:D}=N.getState();return{nodeLookup:$,transform:O,snapGrid:R,snapToGrid:A,nodeOrigin:L,paneDomNode:D}},onChange:($,O)=>{const{triggerNodeChanges:R,nodeLookup:A,parentLookup:L,nodeOrigin:D}=N.getState(),T=[],B={x:$.x,y:$.y},F=A.get(y);if(F&&F.expandParent&&F.parentId){const j=F.origin??D,H=$.width??F.measured.width??0,E=$.height??F.measured.height??0,Q={id:F.id,parentId:F.parentId,rect:{width:H,height:E,...K0({x:$.x??F.position.x,y:$.y??F.position.y},{width:H,height:E},F.parentId,A,j)}},K=xd([Q],A,L,D);T.push(...K),B.x=$.x?Math.max(j[0]*H,$.x):void 0,B.y=$.y?Math.max(j[1]*E,$.y):void 0}if(B.x!==void 0&&B.y!==void 0){const j={id:y,type:"position",position:{...B}};T.push(j)}if($.width!==void 0&&$.height!==void 0){const H={id:y,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:$.width,height:$.height}};T.push(H)}for(const j of O){const H={...j,type:"position"};T.push(H)}R(T)},onEnd:({width:$,height:O})=>{const R={id:y,type:"dimensions",resizing:!1,dimensions:{width:$,height:O}};N.getState().triggerNodeChanges([R])}})),P.current.update({controlPosition:I,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:f},keepAspectRatio:p,resizeDirection:m,onResizeStart:b,onResize:x,onResizeEnd:v,shouldResize:g}),()=>{P.current?.destroy()}},[I,l,c,d,f,p,b,x,v,g]);const z=I.split("-");return r("div",{className:Ue(["react-flow__resize-control","nodrag",...z,n,o]),ref:k,style:{...s,scale:M,...i&&{[S?"backgroundColor":"borderColor"]:i}},children:a})}Fe(fq);function mq({data:e,selected:t}){const n=e.isOnline,o=e.isHub,s=e.engines??[],a=e.addons??[],i=e.processes??[],l=e.name,c=e.hostname,d=e.localIps??[],f=e.cpuPercent,p=e.memoryPercent,m=e.isExpanded,h=e.onToggleExpand,g=e.onShowNodeLogs,b=e.onRestartNode,x=e.id,v=i.length,w=q(M=>{M.stopPropagation(),h?.()},[h]),y=q(M=>{M.stopPropagation(),g?.()},[g]),N=q(M=>{M.stopPropagation(),b?.()},[b]);return u("div",{className:`rounded-xl bg-surface px-3 py-2.5 min-w-[180px] max-w-[260px] transition-all duration-200 ${n?o?"border-2 border-success":"border-2 border-dashed border-primary/60 bg-primary/5":"border-2 border-dashed border-muted-foreground/30 opacity-50"} ${t?"ring-2 ring-primary ring-offset-1":""}`,children:[r(Nn,{type:"target",position:we.Top,className:"!bg-border !w-2 !h-2"}),u("div",{className:"flex items-center gap-1.5 mb-1.5",children:[r("div",{className:`w-2 h-2 rounded-full ${n?"bg-success":"bg-destructive"}`}),r("span",{className:"text-xs font-semibold truncate flex-1",children:l}),o?r("span",{className:"text-[8px] px-1 py-0.5 rounded bg-primary/10 text-primary font-medium",children:"HUB"}):r("span",{className:"text-[8px] px-1 py-0.5 rounded bg-muted text-muted-foreground font-medium",children:"AGENT"})]}),(c||d.length>0)&&(()=>{const M=d.filter(P=>!P.includes(":"));return u("div",{className:"text-[9px] text-muted-foreground mb-1 space-y-0.5",title:[c,...d].filter(Boolean).join(", "),children:[c&&r("div",{className:"truncate",children:c}),M.length>0&&r("div",{className:"truncate font-mono opacity-70",children:M.join(", ")})]})})(),s.length>0&&r("div",{className:"flex flex-wrap gap-1 mb-1.5",children:s.map(M=>r("span",{className:"text-[8px] px-1 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium",children:M},M))}),a.length>0&&u("div",{className:"text-[9px] text-muted-foreground mb-1",children:[a.length," addon",a.length!==1?"s":""," in-process"]}),n&&u("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground",children:[u("span",{className:"flex items-center gap-0.5",children:[r(dt,{className:"h-2.5 w-2.5"}),f,"%"]}),u("span",{className:"flex items-center gap-0.5",children:[r(Wc,{className:"h-2.5 w-2.5"}),p,"%"]}),u("div",{className:"flex items-center gap-1 ml-auto",children:[v>0&&u("button",{onClick:w,className:"flex items-center gap-0.5 px-1 py-0.5 rounded hover:bg-amber-500/10 text-amber-500 transition-colors",title:m?"Collapse processes":`Expand ${v} process${v!==1?"es":""}`,children:[m?r(wt,{className:"h-3 w-3"}):r(It,{className:"h-3 w-3"}),r("span",{className:"text-[9px] font-medium",children:v})]}),r("button",{onClick:y,className:"p-0.5 rounded hover:bg-primary/10 text-muted-foreground hover:text-primary transition-colors",title:`Logs: ${x}`,children:r(Ze,{className:"h-3 w-3"})}),r("button",{onClick:N,className:"p-0.5 rounded hover:bg-primary/10 text-muted-foreground hover:text-primary transition-colors",title:"Restart all processes",children:r(bt,{className:"h-3 w-3"})})]})]}),!n&&r("div",{className:"text-[10px] text-muted-foreground",children:"offline"}),r(Nn,{type:"source",position:we.Bottom,className:"!bg-border !w-2 !h-2"})]})}const hq=Fe(mq);function gq(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 bq({data:e}){const t=e.name,n=e.state,o=e.pid,s=e.cpuPercent,a=e.memoryRss,i=e.addonId,l=e.services??[],c=e.isExpanded,d=e.onToggleServices,f=e.parentNodeId,p=e.onShowLogs,m=e.onRestartAddon,h=n==="running",g=t.includes("(core)"),b=!g&&l.length===1,x=b?l[0]:null,v=f??"hub",w=`${v}/${t}`,y=q(M=>{M.stopPropagation(),d?.()},[d]),N=g?sn:ga,k=g?"border-primary/50":h?"border-amber-500/50":"border-destructive/50",S=g?"text-primary":"text-amber-500";return u("div",{className:`rounded-lg bg-surface min-w-[150px] border ${k} ${c?"max-w-[240px]":"max-w-[210px]"}`,children:[r(Nn,{type:"target",position:we.Top,className:`!w-1.5 !h-1.5 ${g?"!bg-primary":"!bg-amber-500"}`}),u("div",{className:"px-2.5 pt-2 pb-1.5",children:[u("div",{className:"flex items-start gap-1.5 mb-1.5",children:[r(N,{className:`h-3 w-3 ${S} shrink-0 mt-0.5`}),r("span",{className:"text-[10px] font-semibold truncate flex-1",children:g?"core":i??t}),r("span",{className:"text-[8px] text-muted-foreground/60 tabular-nums shrink-0",children:o})]}),u("div",{className:"flex items-center gap-2 text-[9px] text-muted-foreground",children:[r("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${h?"bg-success":"bg-destructive"}`}),u("span",{className:"flex items-center gap-0.5",children:[r(dt,{className:"h-2 w-2"}),s,"%"]}),u("span",{className:"flex items-center gap-0.5",children:[r(Wc,{className:"h-2 w-2"}),gq(a)]}),b&&x?u("div",{className:"flex items-center gap-0.5 ml-auto",children:[r("button",{onClick:M=>{M.stopPropagation(),p?.(x.addonId,v)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Logs: ${x.addonId}`,children:r(Ze,{className:"h-2.5 w-2.5"})}),r("button",{onClick:M=>{M.stopPropagation(),m?.(x.addonId,w)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Restart: ${x.addonId}`,children:r(bt,{className:"h-2.5 w-2.5"})})]}):l.length>0?u("button",{onClick:y,className:"flex items-center gap-0.5 ml-auto px-0.5 rounded hover:bg-blue-500/10 text-blue-400 transition-colors",title:c?"Hide addons":`Show ${l.length} addon${l.length!==1?"s":""}`,children:[c?r(wt,{className:"h-2.5 w-2.5"}):r(It,{className:"h-2.5 w-2.5"}),r("span",{className:"text-[8px] font-medium",children:l.length})]}):null]})]}),c&&l.length>0&&!b&&r("div",{className:"border-t border-border/40 px-2 py-1 space-y-0.5 max-h-[200px] overflow-y-auto",children:l.map(M=>{const P=g?v:`${v}/${t}`;return u("div",{className:"flex items-center gap-1 py-0.5",children:[r("div",{className:`w-1 h-1 rounded-full shrink-0 ${M.status==="running"?"bg-success":"bg-muted-foreground/30"}`}),r("span",{className:"text-[9px] truncate flex-1",children:M.addonId}),r("button",{onClick:I=>{I.stopPropagation(),p?.(M.addonId,v)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Logs: ${M.addonId}`,children:r(Ze,{className:"h-2.5 w-2.5"})}),r("button",{onClick:I=>{I.stopPropagation(),m?.(M.addonId,P)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:`Restart: ${M.addonId}`,children:r(bt,{className:"h-2.5 w-2.5"})})]},M.addonId)})}),r(Nn,{type:"source",position:we.Bottom,className:`!w-1.5 !h-1.5 ${g?"!bg-primary":"!bg-amber-500"}`})]})}const xq=Fe(bq),yq={clusterNode:hq,processNode:xq},Cf=280,Mf=40,If=280,Af=200,vq=150;function wq({topology:e}){const{resolvedMode:t}=Mr(),n=eb(),o=aa(),[,s]=_(null),[a,i]=_(()=>e.length<=1?new Set(e.map(M=>M.id)):new Set),[l,c]=_(null),[d,f]=_(null),p=q((M,P)=>{f(I=>I?.addonId===M&&I?.agentId===P?null:{addonId:M,agentId:P})},[]),m=q(M=>{f(P=>P?.agentId===M&&!P?.addonId?null:{agentId:M})},[]),h=q(async M=>{try{await n.mutateAsync({nodeId:M})}catch(P){console.error("Failed to restart node:",P)}},[n]),g=q(async(M,P)=>{try{await o.mutateAsync({nodeId:P,addonId:M})}catch(I){console.error("Failed to restart addon:",I)}},[o]),b=q(M=>{i(P=>{const I=new Set(P);return I.has(M)?I.delete(M):I.add(M),I})},[]),x=q(M=>{c(P=>P===M?null:M)},[]),v=q(M=>{s(M)},[]),w=U(()=>{const M=e.filter(L=>L.isHub),P=e.filter(L=>!L.isHub),I=[],z=[],$=M[0]?.id,O=$?a.has($):!1;function R(L,D,T,B){const F=[...B];if(F.length===0)return;const j=(F.length-1)*Af,H=D-j/2,E=T+vq;for(let Q=0;Q<F.length;Q++){const K=F[Q],Y=`proc:${L}/${K.name}`,re=K.services??[],te=l===Y;I.push({id:Y,type:"processNode",position:{x:H+Q*Af,y:E},data:{...K,addonId:K.name.includes("(core)")?void 0:re.length>1?K.name:re[0]?.addonId??K.name,parentNodeId:L,services:re,isExpanded:te,onToggleServices:()=>x(Y),onShowLogs:p,onRestartAddon:g}}),z.push({id:`edge:${L}-${Y}`,source:L,target:Y,animated:!0,style:{stroke:"var(--amber-500, #f59e0b)",strokeWidth:1,strokeDasharray:"4 4"}})}}for(const L of M){const D=Math.max(0,(P.length-1)*Cf)/2;I.push({id:L.id,type:"clusterNode",position:{x:D,y:Mf},data:{...L,label:L.name,isExpanded:a.has(L.id),onToggleExpand:()=>b(L.id),onShowDetail:()=>v(L.id),onShowNodeLogs:()=>m(L.id),onRestartNode:()=>h(L.id)}}),a.has(L.id)&&R(L.id,D,Mf,L.processes??[])}const A=O?If+120:If;for(let L=0;L<P.length;L++){const D=P[L],T=L*Cf;I.push({id:D.id,type:"clusterNode",position:{x:T,y:A},data:{...D,label:D.name,isExpanded:a.has(D.id),onToggleExpand:()=>b(D.id),onShowDetail:()=>v(D.id),onShowNodeLogs:()=>m(D.id),onRestartNode:()=>h(D.id)}}),$&&D.isOnline&&z.push({id:`${$}-${D.id}`,source:$,target:D.id,animated:!0,style:{stroke:"var(--border)",strokeWidth:1.5}}),a.has(D.id)&&R(D.id,T,A,D.processes??[])}return{nodes:I,edges:z}},[e,a,l,b,x,v,p,m,h,g]),y=ne(new Map),N=U(()=>{const M=y.current;return w.nodes.map(I=>({...I,position:M.get(I.id)??I.position}))},[w.nodes]),k=q(M=>{for(const P of M)P.type==="position"&&P.position&&y.current.set(P.id,P.position)},[]),S=q(()=>s(null),[]);return r("div",{className:"flex flex-col gap-4 flex-1",children:u("div",{className:"relative flex-1 min-h-[350px] border border-border rounded-xl overflow-hidden",children:[u(FV,{nodes:N,edges:w.edges,onNodesChange:k,onPaneClick:S,nodeTypes:yq,nodesConnectable:!1,fitView:!0,fitViewOptions:{padding:.2,maxZoom:1.2},proOptions:{hideAttribution:!0},className:"bg-background",colorMode:t,children:[r(QV,{gap:20,size:1}),r(XV,{showInteractive:!1})]}),d&&r(Sx,{addonId:d.addonId,agentId:d.agentId,showScope:!0,onClose:()=>f(null)})]})})}function Nq({onlineNodeIds:e}){const t=ke(),n=nt(),{data:o,isLoading:s}=Er(),a=Sb({onSuccess:()=>{t.invalidateQueries({queryKey:[["pipelineOrchestrator","listAgentSettings"]]})}}),i=U(()=>{if(!o)return[];const c=new Set(e);return c.add("hub"),o.filter(d=>!c.has(d.nodeId))},[o,e]);if(s)return r("section",{className:"rounded-lg border border-border bg-surface p-6 text-xs text-muted-foreground animate-pulse",children:"Loading persisted agent settings…"});const l=async c=>{await n({title:"Remove offline agent?",message:`Drop the persisted orchestrator settings for "${c}". This won't affect a node that comes back online — it just clears stale addonDefaults so it stops cluttering the cluster view.`,confirmLabel:"Remove",cancelLabel:"Keep",variant:"danger"})&&a.mutate({agentNodeId:c})};return i.length===0?r("section",{className:"rounded-lg border border-border bg-surface p-6",children:u("div",{className:"flex flex-col items-center gap-2 text-center text-muted-foreground",children:[r(nl,{className:"h-6 w-6 opacity-40"}),r("p",{className:"text-xs",children:"No stale agent entries."}),r("p",{className:"text-[11px] opacity-60",children:"Every persisted nodeId matches a node currently online in the cluster."})]})}):u("section",{className:"rounded-lg border border-border bg-surface",children:[u("header",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[r(nl,{className:"h-4 w-4 text-muted-foreground"}),r("h2",{className:"text-sm font-semibold",children:"Offline agents"}),u("span",{className:"ml-auto text-[11px] text-muted-foreground",children:[i.length," stale ",i.length===1?"entry":"entries"]})]}),r("p",{className:"px-4 pt-3 text-[11px] text-muted-foreground",children:"Persisted orchestrator settings for nodes not currently in the live topology. Remove entries you don't expect to come back — leftover from data-dir resets, env-driven nodeId changes, or decommissioned hosts."}),r("ul",{className:"divide-y divide-border",children:i.map(c=>{const d=Object.keys(c.settings.addonDefaults??{}).length,f=Object.values(c.settings.addonDefaults??{}).filter(p=>p?.enabled).length;return u("li",{className:"flex items-center gap-3 px-4 py-2 text-xs",children:[r("span",{className:"font-mono text-foreground",children:c.nodeId}),u("span",{className:"text-muted-foreground",children:[d," addons configured",d>0&&u(xe,{children:[" · ",f," enabled"]})]}),u("button",{type:"button",onClick:()=>{l(c.nodeId)},disabled:a.isPending,className:"ml-auto flex items-center gap-1 px-2 py-1 rounded text-destructive hover:bg-destructive/10 disabled:opacity-50",children:[r(Ge,{className:"h-3 w-3"}),"Remove"]})]},c.nodeId)})})]})}function kq(e){const[t,n]=_(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return Z(()=>{const o=window.matchMedia(e),s=a=>n(a.matches);return o.addEventListener("change",s),()=>o.removeEventListener("change",s)},[e]),t}function Sq(){const{data:e,isLoading:t}=Mn(void 0,{staleTime:1/0}),[n,o]=_(null);return ct("cluster.topology-snapshot",a=>{const i=a.data?.nodes;Array.isArray(i)&&o(i)}),{nodes:U(()=>n??e??[],[n,e]),isLoading:t&&!n}}function Cq(){const[e,t]=_("diagram"),n=kq("(max-width: 767px)"),o=n&&e==="diagram"?"table":e,{nodes:s,isLoading:a}=Sq(),i=s.filter(m=>m.isOnline).length,l=s.filter(m=>!m.isOnline).length,c=U(()=>s.map(m=>m.id??"").filter(Boolean),[s]),{data:d}=Er(),f=U(()=>{if(!d)return 0;const m=new Set(c);return m.add("hub"),d.filter(h=>!m.has(h.nodeId)).length},[d,c]),p=(m,h,g,b)=>u("button",{onClick:()=>t(m),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${e===m?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:[r(g,{className:"h-3.5 w-3.5"}),h,b!==void 0&&b>0&&r("span",{className:`ml-1 inline-flex h-4 min-w-[1rem] items-center justify-center rounded-full px-1 text-[10px] font-semibold ${e===m?"bg-primary-foreground/20 text-primary-foreground":"bg-destructive/15 text-destructive"}`,children:b})]});return u("div",{className:"flex flex-col h-full gap-4 p-4",children:[u("div",{className:"flex items-center justify-between",children:[u("div",{className:"flex items-center gap-3",children:[r("h1",{className:"text-xl font-semibold",children:"Cluster"}),i>0&&u("span",{className:"text-xs px-2 py-0.5 rounded-full bg-success/10 text-success",children:[i," online"]}),l>0&&u("span",{className:"text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive",children:[l," offline"]})]}),u("div",{className:"flex gap-0.5 p-1 rounded-lg bg-muted",children:[!n&&p("diagram","Diagram",on),p("table","Table",iT),p("offline-agents","Offline agents",nl,f)]})]}),a?r("div",{className:"flex items-center justify-center flex-1 text-muted-foreground",children:"Loading cluster topology..."}):o==="diagram"?r(wq,{topology:s}):o==="table"?r("div",{className:"flex-1 overflow-auto",children:r(o7,{nodes:s})}):r("div",{className:"flex-1 overflow-auto",children:r(Nq,{onlineNodeIds:c})})]})}function Zt({title:e,children:t}){return u("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[r("div",{className:"border-b border-border px-4 py-2.5",children:r("h2",{className:"text-xs font-semibold text-foreground uppercase tracking-wider",children:e})}),r("div",{className:"p-4",children:t})]})}function et({name:e,cssVar:t,hex:n}){const o=t?`var(${t})`:n;return u("div",{className:"flex flex-col items-center gap-1.5",children:[r("div",{className:"h-10 w-10 rounded-lg border border-border shadow-inner",style:{backgroundColor:o}}),r("span",{className:"text-[10px] text-foreground-subtle text-center leading-tight",children:e})]})}const Mq={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 Iq(){const[e,t]=_({name:"Example",count:10,enabled:!0,mode:"a",tags:["camera"],confidence:60});return u("div",{className:"p-6 space-y-6 max-w-5xl mx-auto",children:[u("div",{className:"mb-6",children:[r("h1",{className:"text-xl font-bold text-foreground",children:"Component Showroom"}),r("p",{className:"text-sm text-foreground-subtle mt-1",children:"All UI components at a glance"})]}),r(Zt,{title:"Typography",children:u("div",{className:"space-y-3",children:[r("h1",{className:"text-2xl font-bold text-foreground",children:"Heading 1 — Display title"}),r("h2",{className:"text-xl font-semibold text-foreground",children:"Heading 2 — Section title"}),r("h3",{className:"text-base font-semibold text-foreground",children:"Heading 3 — Card title"}),r("h4",{className:"text-sm font-semibold text-foreground",children:"Heading 4 — Sub-section"}),r("p",{className:"text-sm text-foreground",children:"Body text — Regular paragraph content goes here. It uses the foreground color."}),r("p",{className:"text-sm text-foreground-subtle",children:"Subtle text — Secondary/descriptive text with reduced emphasis."}),r("p",{className:"text-xs text-foreground-subtle uppercase tracking-wider font-semibold",children:"Label / Caption"}),r("p",{className:"text-xs text-foreground-disabled",children:"Disabled / placeholder text"})]})}),r(Zt,{title:"Colors",children:u("div",{className:"flex flex-wrap gap-4",children:[r(et,{name:"primary",cssVar:"--color-primary"}),r(et,{name:"background",cssVar:"--color-background"}),r(et,{name:"surface",cssVar:"--color-surface"}),r(et,{name:"foreground",cssVar:"--color-foreground"}),r(et,{name:"success",cssVar:"--color-success"}),r(et,{name:"warning",cssVar:"--color-warning"}),r(et,{name:"danger",cssVar:"--color-danger"}),r(et,{name:"info",cssVar:"--color-info"}),r(et,{name:"border",cssVar:"--color-border"}),r("div",{className:"w-px"}),r(et,{name:"frigate",hex:"#3b82f6"}),r(et,{name:"scrypted",hex:"#a855f7"}),r(et,{name:"reolink",hex:"#06b6d4"}),r(et,{name:"ha",hex:"#22d3ee"}),r(et,{name:"rtsp",hex:"#78716c"})]})}),r(Zt,{title:"Buttons",children:u("div",{className:"flex flex-wrap gap-3",children:[r("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity",children:"Primary"}),r("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-4 py-2 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors",children:"Secondary"}),r("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-danger/40 bg-danger/10 px-4 py-2 text-sm font-medium text-danger hover:bg-danger/20 transition-colors",children:"Danger"}),r("button",{disabled:!0,className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white opacity-40 cursor-not-allowed",children:"Disabled"}),r("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-4 py-2 text-sm font-medium text-warning hover:bg-warning/20 transition-colors",children:"Warning"}),r("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-success/40 bg-success/10 px-4 py-2 text-sm font-medium text-success hover:bg-success/20 transition-colors",children:"Success"})]})}),r(Zt,{title:"Inputs",children:u("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Text input"}),r("input",{type:"text",className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30",placeholder:"Type something..."})]}),u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Number input"}),r("input",{type:"number",className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30",placeholder:"0"})]}),u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Password input"}),r("input",{type:"password",className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30",placeholder:"••••••••"})]}),u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Select"}),u("select",{className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30",children:[r("option",{children:"Option A"}),r("option",{children:"Option B"}),r("option",{children:"Option C"})]})]}),u("div",{className:"md:col-span-2",children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Textarea"}),r("textarea",{className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 resize-y min-h-[60px]",placeholder:"Enter multi-line text...",rows:3})]}),r("div",{children:u("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[r("input",{type:"checkbox",className:"h-3.5 w-3.5 rounded border-border accent-primary",defaultChecked:!0}),r("span",{className:"text-xs font-medium text-foreground",children:"Checkbox (checked)"})]})}),r("div",{children:u("div",{className:"flex items-center justify-between",children:[r("span",{className:"text-xs font-medium text-foreground",children:"Toggle switch"}),r(Aq,{})]})}),u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Slider"}),r("input",{type:"range",className:"w-full h-1 accent-primary cursor-pointer",min:0,max:100,defaultValue:60})]}),u("div",{children:[r("label",{className:"block text-xs font-medium text-foreground mb-1",children:"Tags example"}),r("div",{className:"flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px]",children:["camera","zone","alert"].map(n=>r("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:n},n))})]})]})}),r(Zt,{title:"Badges",children:u("div",{className:"space-y-3",children:[u("div",{children:[r("p",{className:"text-xs text-foreground-subtle mb-2",children:"StatusBadge"}),r("div",{className:"flex flex-wrap gap-2",children:["running","stopped","error","online","offline","idle"].map(n=>r(ka,{status:n},n))})]}),u("div",{children:[r("p",{className:"text-xs text-foreground-subtle mb-2",children:"CapabilityBadges"}),r(wa,{capabilities:["streaming","detection","recording","audio"]})]})]})}),r(Zt,{title:"Cards",children:u("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[u("div",{className:"rounded-lg bg-surface p-4",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Surface card"}),r("p",{className:"text-xs text-foreground-subtle",children:"Uses `bg-surface`. Default card background."})]}),u("div",{className:"rounded-lg border border-border bg-surface p-4",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Bordered card"}),r("p",{className:"text-xs text-foreground-subtle",children:"Uses `border border-border bg-surface`."})]}),u("div",{className:"rounded-lg border border-primary/30 bg-primary/5 p-4",children:[r("h3",{className:"text-sm font-semibold text-primary mb-1",children:"Accent card"}),r("p",{className:"text-xs text-foreground-subtle",children:"Highlighted with primary color."})]}),u("div",{className:"rounded-lg bg-background p-4",children:[r("h3",{className:"text-sm font-semibold text-foreground mb-1",children:"Background card"}),r("p",{className:"text-xs text-foreground-subtle",children:"Uses `bg-background`. Inset card."})]})]})}),r(Zt,{title:"Provider Icons",children:r("div",{className:"flex flex-wrap gap-4",children:["frigate","scrypted","reolink","homeassistant","rtsp","onvif"].map(n=>r(an,{type:n,size:"lg",showLabel:!0},n))})}),u(Zt,{title:"Form Builder Demo",children:[r(wn,{schema:Mq,values:e,onChange:t}),u("details",{className:"mt-3",children:[r("summary",{className:"text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground",children:"View current values"}),r("pre",{className:"mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto",children:JSON.stringify(e,null,2)})]})]}),r(Zt,{title:"Info Boxes",children:r("div",{className:"space-y-2",children:[{variant:"info",label:"Info",content:"This is an informational message. Use it for tips and hints."},{variant:"warning",label:"Warning",content:"This action may have side effects. Proceed with caution."},{variant:"success",label:"Success",content:"Operation completed successfully. All systems are green."},{variant:"danger",label:"Danger",content:"This operation is irreversible. Data will be permanently deleted."}].map(({variant:n,label:o,content:s})=>{const i={info:{border:"border-info",bg:"bg-info/5",text:"text-info"},warning:{border:"border-warning",bg:"bg-warning/5",text:"text-warning"},success:{border:"border-success",bg:"bg-success/5",text:"text-success"},danger:{border:"border-danger",bg:"bg-danger/5",text:"text-danger"}}[n];return u("div",{className:`rounded-md border-l-4 px-3 py-2.5 ${i.border} ${i.bg}`,children:[r("p",{className:`text-xs font-semibold mb-0.5 ${i.text}`,children:o}),r("p",{className:"text-xs text-foreground-subtle leading-relaxed",children:s})]},n)})})})]})}function Aq(){const[e,t]=_(!0);return r("button",{type:"button",role:"switch","aria-checked":e,onClick:()=>t(n=>!n),className:["relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150 cursor-pointer",e?"bg-primary":"bg-foreground-subtle/30"].join(" "),children:r("span",{className:["inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150",e?"translate-x-4":"translate-x-0.5"].join(" ")})})}const Pf={info:{bg:"bg-blue-500/10",border:"border-blue-500/30",icon:Ps},warning:{bg:"bg-orange-500/10",border:"border-orange-500/30",icon:xt},critical:{bg:"bg-red-500/10",border:"border-red-500/30",icon:xa}};function Pq({toast:e,onDismiss:t}){const n=Pf[e.severity]??Pf.info,o=n.icon;return Z(()=>{const s=e.duration??5e3;if(s<=0)return;const a=setTimeout(()=>t(e.id),s);return()=>clearTimeout(a)},[e.id,e.duration,t]),u("div",{className:`flex items-start gap-3 px-4 py-3 rounded-lg border ${n.border} ${n.bg} shadow-lg backdrop-blur-sm animate-in slide-in-from-right-5 fade-in duration-200`,children:[r(o,{className:"h-4 w-4 shrink-0 mt-0.5 text-foreground-subtle"}),u("div",{className:"flex-1 min-w-0",children:[r("div",{className:"text-xs font-semibold text-foreground",children:e.title}),r("div",{className:"text-[11px] text-foreground-subtle mt-0.5",children:e.message})]}),r("button",{type:"button",onClick:()=>t(e.id),className:"shrink-0 p-0.5 rounded hover:bg-surface-hover transition-colors",children:r(Ve,{className:"h-3.5 w-3.5 text-foreground-subtle"})})]})}function Eq(){const[e,t]=_([]),n=q(o=>{t(s=>s.filter(a=>a.id!==o))},[]);return Yb(void 0,{onData:o=>{const s=o,a=`toast-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;t(i=>[...i,{...s,id:a,timestamp:Date.now()}])}}),e.length===0?null:r("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2 max-w-sm w-full pointer-events-none",children:e.map(o=>r("div",{className:"pointer-events-auto",children:r(Pq,{toast:o,onDismiss:n})},o.id))})}const Pl=new Rf({defaultOptions:{queries:{staleTime:3e4,retry:!1,refetchOnWindowFocus:!1}}});function $q({field:e,value:t,onChange:n,disabled:o}){return r(kT,{field:e,value:t,onChange:n,disabled:o})}function _q({field:e,value:t,onChange:n,disabled:o}){return r(DT,{field:e,value:t,onChange:n,disabled:o})}const Dq={"zone-editor":F_,"live-stats":H_,"pipeline-editor":$q,"model-selector":_q,"live-stream-viewer":TT,"pipeline-stats":RT,"stream-network-stats":OT,"doorbell-recent":BT,"device-info":ky};function Lq({children:e}){const{user:t}=Lr(),[n,o]=_(0),s=ne(t?.username??null);Z(()=>{const p=t?.username??null;p!==s.current&&(s.current=p,Wr(),o(m=>m+1))},[t]);const a=U(()=>tl(),[n]),[i,l]=_(!1),[c,d]=_(null);Z(()=>{if(l(!1),d(null),!t){l(!0);return}let p=!1;return a.init().then(()=>{p||l(!0)},m=>{if(p)return;const h=m instanceof Error?m.message:String(m);d(h),l(!0)}),()=>{p=!0}},[a,t]);const f=q(()=>{Wr(),o(p=>p+1),Pl.invalidateQueries()},[]);return T_(f),r(ec,{system:a,children:r(C.Provider,{client:a.trpcClient,queryClient:Pl,children:u(cx,{children:[i?e:r(Tq,{}),c!==null&&i&&u("div",{className:"fixed bottom-4 right-4 z-50 max-w-sm rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning shadow-lg",children:["Boot probe failed: ",c,". Retrying in background."]})]})})})}function Tq(){return r("div",{className:"flex min-h-screen items-center justify-center bg-background",children:u("div",{className:"flex items-center gap-3 text-sm text-foreground-subtle",children:[r("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary"}),"Connecting…"]})})}function Rq(){return r(ws,{defaultMode:"dark",children:r(Of,{client:Pl,children:r(JT,{children:r(Lq,{children:r(yh,{children:u(Bh,{renderers:Dq,children:[r(S_,{children:u(J$,{children:[r(De,{path:"/login",element:r(n6,{})}),r(De,{path:"/change-password",element:r(Bt,{children:r(o6,{})})}),r(De,{path:"/access-denied",element:r(s6,{})}),r(De,{path:"/showroom",element:r(Iq,{})}),u(De,{element:r(Bt,{children:r(t6,{})}),children:[r(De,{index:!0,element:r(gt,{to:"/dashboard",replace:!0})}),r(De,{path:"/dashboard",element:r(g6,{})}),r(De,{path:"/devices",element:r(b6,{})}),r(De,{path:"/cameras",element:r(gt,{to:"/devices",replace:!0})}),r(De,{path:"/integrations",element:r(A6,{})}),r(De,{path:"/integrations/:integrationId",element:r($6,{})}),r(De,{path:"/timeline",element:r(j6,{})}),r(De,{path:"/pipeline",element:r(NO,{})}),r(De,{path:"/devices/:deviceId",element:r(y8,{})}),r(De,{path:"/system/logs",element:r(Bt,{requiredRole:"admin",children:r($8,{})})}),r(De,{path:"/system/addons",element:r(Bt,{requiredRole:"admin",children:r(E8,{})})}),r(De,{path:"/system/settings",element:r(Bt,{requiredRole:"admin",children:r(H9,{})})}),r(De,{path:"/system/cluster",element:r(Bt,{requiredRole:"admin",children:r(Cq,{})})}),r(De,{path:"/system/identity",element:r(Bt,{requiredRole:"admin",children:r(q8,{})})}),r(De,{path:"/system/network",element:r(Bt,{requiredRole:"admin",children:r(e9,{})})}),r(De,{path:"/system/data",element:r(Bt,{requiredRole:"admin",children:r(j9,{})})}),r(De,{path:"/system/users",element:r(gt,{to:"/system/identity?tab=users",replace:!0})}),r(De,{path:"/system/api-keys",element:r(gt,{to:"/system/identity?tab=api-keys",replace:!0})}),r(De,{path:"/system/authentication",element:r(gt,{to:"/system/identity?tab=authentication",replace:!0})}),r(De,{path:"/system/remote-access",element:r(gt,{to:"/system/network?tab=remote-access",replace:!0})}),r(De,{path:"/system/turn",element:r(gt,{to:"/system/network?tab=turn",replace:!0})}),r(De,{path:"/system/storage",element:r(gt,{to:"/system/data?tab=storage",replace:!0})}),r(De,{path:"/system/backup",element:r(gt,{to:"/system/data?tab=backup",replace:!0})}),r(De,{path:"/addon/:pagePath",element:r(Bt,{requiredRole:"admin",children:r(XR,{})})})]})]})}),r(Eq,{})]})})})})})})}const Oq={dashboard:"Dashboard",integrations:"Integrations",metrics:"Metrics"},zq={title:"System",addons:"Addons",agents:"Agents",processes:"Processes",logs:"Logs",users:"Users",settings:"Settings",repl:"REPL",models:"Models"},Bq={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"},Fq={disconnected:"Server unreachable — reconnecting…",connected:"Connected"},jq={online:"Online",offline:"Offline",connecting:"Connecting",error:"Error",disabled:"Disabled",enabled:"Enabled",active:"Active",inactive:"Inactive",running:"Running",stopped:"Stopped",pending:"Pending",unknown:"Unknown"},Hq={login:"Login",logout:"Logout",username:"Username",password:"Password",signIn:"Sign In",invalidCredentials:"Invalid username or password"},Vq={dark:"Dark",light:"Light",system:"System"},qq={select:"Language",en:"English",it:"Italian"},Qq={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"}},Uq={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"},Kq={nav:Oq,system:zq,common:Bq,connection:Fq,status:jq,auth:Hq,theme:Vq,language:qq,pages:Qq,integrations:Uq},Gq={dashboard:"Dashboard",integrations:"Integrazioni",metrics:"Metriche"},Wq={title:"Sistema",addons:"Addon",agents:"Agenti",processes:"Processi",logs:"Log",users:"Utenti",settings:"Impostazioni",repl:"REPL",models:"Modelli"},Yq={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"},Zq={disconnected:"Server non raggiungibile — riconnessione in corso…",connected:"Connesso"},Xq={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"},Jq={login:"Accesso",logout:"Esci",username:"Nome utente",password:"Password",signIn:"Accedi",invalidCredentials:"Nome utente o password non validi"},eQ={dark:"Scuro",light:"Chiaro",system:"Sistema"},tQ={select:"Lingua",en:"Inglese",it:"Italiano"},nQ={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"}},rQ={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"},oQ={nav:Gq,system:Wq,common:Yq,connection:Zq,status:Xq,auth:Jq,theme:eQ,language:tQ,pages:nQ,integrations:rQ},Kv="camstack_language",sQ=localStorage.getItem(Kv)??"en";Ye.use(DR).init({resources:{en:{translation:Kq},it:{translation:oQ}},lng:sQ,fallbackLng:"en",interpolation:{escapeValue:!1}});Ye.on("languageChanged",e=>{localStorage.setItem(Kv,e)});window.__camstackUiLibrary=XE;window.__camstackSdk=iw;window.__camstackTypes=lw;Lf(document.getElementById("root")).render(r(Z1,{children:r(Rq,{})}));
|