@camstack/addon-admin-ui 0.1.25 → 0.1.26

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.
@@ -0,0 +1,80 @@
1
+ import{b as Aj,g as Pj}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-C_6K4VBY.js";import{r as Rl}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-CSyOECfO.js";import{r as Dl}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs_commonjs-proxy-DrLZNXOX.js";import{r as Rj}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-xw6c6JeS.js";import{r as Dj}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs_commonjs-proxy-BEKtiDI3.js";import{r as Tj}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-DXPQtD9p.js";import{r as Ij}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.mjs_commonjs-proxy-WD2WouMQ.js";import{r as Lj}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-GvBGLFI2.js";import{r as Oj}from"./index-DV9irWJe.js";import{s as _j}from"./index-D9kg0e9y.js";function $j(c,Me){for(var gt=0;gt<Me.length;gt++){const Fe=Me[gt];if(typeof Fe!="string"&&!Array.isArray(Fe)){for(const ze in Fe)if(ze!=="default"&&!(ze in c)){const st=Object.getOwnPropertyDescriptor(Fe,ze);st&&Object.defineProperty(c,ze,st.get?st:{enumerable:!0,get:()=>Fe[ze]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var En={},An={},Al;function Gj(){return Al||(Al=1,(function(c){Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}),Tl();let Me=Rl,gt=Dl;var Fe={frigate:"#3b82f6",scrypted:"#a855f7",reolink:"#06b6d4",homeAssistant:"#22d3ee",rtsp:"#78716c"},ze={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:Fe},st={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:Fe},Et={colors:{dark:ze,light:st},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 br(le,ge){const me={...le};for(const we in ge){const Ue=ge[we],Ye=le[we];Ue!==void 0&&typeof Ue=="object"&&Ue!==null&&!Array.isArray(Ue)&&typeof Ye=="object"&&Ye!==null?me[we]=br(Ye,Ue):Ue!==void 0&&(me[we]=Ue)}return me}function xr(le){return le?br(structuredClone(Et),le):structuredClone(Et)}function Qe(le){return le.replace(/[A-Z]/g,ge=>`-${ge.toLowerCase()}`)}function Ge(le){return`--color-${Qe(le)}`}function h(le){const ge=[];for(const[me,we]of Object.entries(le))me!=="provider"&&ge.push(` ${Ge(me)}: ${we};`);return ge.join(`
2
+ `)}function r(le){const ge=[];for(const[me,we]of Object.entries(le))ge.push(` --color-provider-${Qe(me)}: ${we};`);return ge.join(`
3
+ `)}function Ze(le){const ge=[];for(const[me,we]of Object.entries(le))ge.push(` --spacing-${me}: ${we}px;`);return ge.join(`
4
+ `)}function bt(le){const ge=[];for(const[me,we]of Object.entries(le))ge.push(` --radius-${me}: ${we}px;`);return ge.join(`
5
+ `)}function Ae(le){const ge=h(le.colors.dark),me=h(le.colors.light);return`@theme {
6
+ ${r(le.colors.dark.provider)}
7
+ ${Ze(le.spacing)}
8
+ ${bt(le.radius)}
9
+ }
10
+
11
+ .dark {
12
+ ${ge}
13
+ }
14
+
15
+ .light {
16
+ ${me}
17
+ }
18
+
19
+ @media (prefers-color-scheme: dark) {
20
+ :root {
21
+ ${ge.replace(/^ {2}/gm," ")}
22
+ }
23
+ }
24
+
25
+ @media (prefers-color-scheme: light) {
26
+ :root {
27
+ ${me.replace(/^ {2}/gm," ")}
28
+ }
29
+ }
30
+ `}var Te=(0,Me.createContext)(null),nt=["dark","light","system"];function F(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ns(le,ge){if(typeof window>"u")return ge;const me=localStorage.getItem(le);return me==="dark"||me==="light"||me==="system"?me:ge}function Vt(le){return le==="system"?F():le}function Wt({children:le,defaultMode:ge="system",storageKey:me="camstack-theme-mode"}){const[we,Ue]=(0,Me.useState)(()=>ns(me,ge)),[Ye,qt]=(0,Me.useState)(()=>Vt(we)),At=(0,Me.useCallback)(Ie=>{Ue(Ie),qt(Vt(Ie)),typeof window<"u"&&localStorage.setItem(me,Ie)},[me]),yr=(0,Me.useCallback)(()=>{At(nt[(nt.indexOf(we)+1)%nt.length]??"dark")},[we,At]);(0,Me.useEffect)(()=>{if(typeof document>"u")return;const Ie=document.documentElement;Ie.classList.remove("dark","light"),Ie.classList.add(Ye)},[we,Ye]),(0,Me.useEffect)(()=>{if(typeof window>"u"||we!=="system")return;const Ie=window.matchMedia("(prefers-color-scheme: dark)"),wr=()=>{qt(F())};return Ie.addEventListener("change",wr),()=>Ie.removeEventListener("change",wr)},[we]);const os=(0,Me.useMemo)(()=>({mode:we,resolvedMode:Ye,setMode:At,toggleMode:yr}),[we,Ye,At,yr]);return(0,gt.jsx)(Te.Provider,{value:os,children:le})}function vr(){const le=(0,Me.useContext)(Te);if(!le)throw new Error("useThemeMode must be used within a ThemeProvider");return le}c.ThemeProvider=Wt,c.ThemeProvider$1=Wt,c.createTheme=xr,c.createTheme$1=xr,c.darkColors=ze,c.darkColors$1=ze,c.defaultTheme=Et,c.defaultTheme$1=Et,c.lightColors=st,c.lightColors$1=st,c.themeToCss=Ae,c.themeToCss$1=Ae,c.useThemeMode=vr,c.useThemeMode$1=vr})(An)),An}const Bj=Aj(_j);var Pl;function Tl(){return Pl||(Pl=1,(function(c){var Me={};Object.defineProperty(c,Symbol.toStringTag,{value:"Module"});var gt=Object.create,Fe=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,st=Object.getOwnPropertyNames,Et=Object.getPrototypeOf,br=Object.prototype.hasOwnProperty,xr=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(var o=st(t),a=0,i=o.length,l;a<i;a++)l=o[a],!br.call(e,l)&&l!==s&&Fe(e,l,{get:(u=>t[u]).bind(null,l),enumerable:!(n=ze(t,l))||n.enumerable});return e},Qe=(e,t,s)=>(s=e!=null?gt(Et(e)):{},xr(t||!e||!e.__esModule?Fe(s,"default",{value:e,enumerable:!0}):s,e));const Ge=Gj();let h=Rl;h=Qe(h,1);let r=Dl;r=Qe(r,1);let Ze=Rj;Ze=Qe(Ze,1);let bt=Dj;bt=Qe(bt,1);let Ae=Tj;Ae=Qe(Ae,1);let Te=Ij;Te=Qe(Te,1);let nt=Lj;nt=Qe(nt,1);let F=Oj,ns=Bj;function Vt(e){var t,s,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(s=Vt(e[t]))&&(n&&(n+=" "),n+=s)}else for(s in e)e[s]&&(n&&(n+=" "),n+=s);return n}function Wt(){for(var e,t,s=0,n="",o=arguments.length;s<o;s++)(e=arguments[s])&&(t=Vt(e))&&(n&&(n+=" "),n+=t);return n}var vr=(e,t)=>{const s=new Array(e.length+t.length);for(let n=0;n<e.length;n++)s[n]=e[n];for(let n=0;n<t.length;n++)s[e.length+n]=t[n];return s},le=(e,t)=>({classGroupId:e,validator:t}),ge=(e=new Map,t=null,s)=>({nextPart:e,validators:t,classGroupId:s}),me="-",we=[],Ue="arbitrary..",Ye=e=>{const t=yr(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return At(i);const l=i.split(me);return qt(l,l[0]===""&&l.length>1?1:0,t)},getConflictingClassGroupIds:(i,l)=>{if(l){const u=n[i],d=s[i];return u?d?vr(d,u):u:d||we}return s[i]||we}}},qt=(e,t,s)=>{if(e.length-t===0)return s.classGroupId;const n=e[t],o=s.nextPart.get(n);if(o){const u=qt(e,t+1,o);if(u)return u}const a=s.validators;if(a===null)return;const i=t===0?e.join(me):e.slice(t).join(me),l=a.length;for(let u=0;u<l;u++){const d=a[u];if(d.validator(i))return d.classGroupId}},At=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),s=t.indexOf(":"),n=t.slice(0,s);return n?Ue+n:void 0})(),yr=e=>{const{theme:t,classGroups:s}=e;return os(s,t)},os=(e,t)=>{const s=ge();for(const n in e){const o=e[n];Ie(o,s,n,t)}return s},Ie=(e,t,s,n)=>{const o=e.length;for(let a=0;a<o;a++){const i=e[a];wr(i,t,s,n)}},wr=(e,t,s,n)=>{if(typeof e=="string"){Ll(e,t,s);return}if(typeof e=="function"){Ol(e,t,s,n);return}_l(e,t,s,n)},Ll=(e,t,s)=>{const n=e===""?t:Pn(t,e);n.classGroupId=s},Ol=(e,t,s,n)=>{if($l(e)){Ie(e(n),t,s,n);return}t.validators===null&&(t.validators=[]),t.validators.push(le(s,e))},_l=(e,t,s,n)=>{const o=Object.entries(e),a=o.length;for(let i=0;i<a;i++){const[l,u]=o[i];Ie(u,Pn(t,l),s,n)}},Pn=(e,t)=>{let s=e;const n=t.split(me),o=n.length;for(let a=0;a<o;a++){const i=n[a];let l=s.nextPart.get(i);l||(l=ge(),s.nextPart.set(i,l)),s=l}return s},$l=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Gl=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,s=Object.create(null),n=Object.create(null);const o=(a,i)=>{s[a]=i,t++,t>e&&(t=0,n=s,s=Object.create(null))};return{get(a){let i=s[a];if(i!==void 0)return i;if((i=n[a])!==void 0)return o(a,i),i},set(a,i){a in s?s[a]=i:o(a,i)}}},as="!",Rn=":",Bl=[],Dn=(e,t,s,n,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:s,maybePostfixModifierPosition:n,isExternal:o}),Fl=e=>{const{prefix:t,experimentalParseClassName:s}=e;let n=o=>{const a=[];let i=0,l=0,u=0,d;const f=o.length;for(let v=0;v<f;v++){const w=o[v];if(i===0&&l===0){if(w===Rn){a.push(o.slice(u,v)),u=v+1;continue}if(w==="/"){d=v;continue}}w==="["?i++:w==="]"?i--:w==="("?l++:w===")"&&l--}const m=a.length===0?o:o.slice(u);let g=m,b=!1;m.endsWith(as)?(g=m.slice(0,-1),b=!0):m.startsWith(as)&&(g=m.slice(1),b=!0);const x=d&&d>u?d-u:void 0;return Dn(a,b,g,x)};if(t){const o=t+Rn,a=n;n=i=>i.startsWith(o)?a(i.slice(o.length)):Dn(Bl,!1,i,void 0,!0)}if(s){const o=n;n=a=>s({className:a,parseClassName:o})}return n},zl=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((s,n)=>{t.set(s,1e6+n)}),s=>{const n=[];let o=[];for(let a=0;a<s.length;a++){const i=s[a],l=i[0]==="[",u=t.has(i);l||u?(o.length>0&&(o.sort(),n.push(...o),o=[]),n.push(i)):o.push(i)}return o.length>0&&(o.sort(),n.push(...o)),n}},Ql=e=>({cache:Gl(e.cacheSize),parseClassName:Fl(e),sortModifiers:zl(e),...Ye(e)}),Ul=/\s+/,Hl=(e,t)=>{const{parseClassName:s,getClassGroupId:n,getConflictingClassGroupIds:o,sortModifiers:a}=t,i=[],l=e.trim().split(Ul);let u="";for(let d=l.length-1;d>=0;d-=1){const f=l[d],{isExternal:m,modifiers:g,hasImportantModifier:b,baseClassName:x,maybePostfixModifierPosition:v}=s(f);if(m){u=f+(u.length>0?" "+u:u);continue}let w=!!v,y=n(w?x.substring(0,v):x);if(!y){if(!w){u=f+(u.length>0?" "+u:u);continue}if(y=n(x),!y){u=f+(u.length>0?" "+u:u);continue}w=!1}const S=g.length===0?"":g.length===1?g[0]:a(g).join(":"),k=b?S+as:S,C=k+y;if(i.indexOf(C)>-1)continue;i.push(C);const N=o(y,w);for(let E=0;E<N.length;++E){const R=N[E];i.push(k+R)}u=f+(u.length>0?" "+u:u)}return u},Vl=(...e)=>{let t=0,s,n,o="";for(;t<e.length;)(s=e[t++])&&(n=Tn(s))&&(o&&(o+=" "),o+=n);return o},Tn=e=>{if(typeof e=="string")return e;let t,s="";for(let n=0;n<e.length;n++)e[n]&&(t=Tn(e[n]))&&(s&&(s+=" "),s+=t);return s},Wl=(e,...t)=>{let s,n,o,a;const i=u=>(s=Ql(t.reduce((d,f)=>f(d),e())),n=s.cache.get,o=s.cache.set,a=l,l(u)),l=u=>{const d=n(u);if(d)return d;const f=Hl(u,s);return o(u,f),f};return a=i,(...u)=>a(Vl(...u))},ql=[],Ce=e=>{const t=s=>s[e]||ql;return t.isThemeGetter=!0,t},In=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Ln=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Kl=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Zl=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Yl=/\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$/,Xl=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Jl=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ec=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,lt=e=>Kl.test(e),oe=e=>!!e&&!Number.isNaN(Number(e)),ct=e=>!!e&&Number.isInteger(Number(e)),is=e=>e.endsWith("%")&&oe(e.slice(0,-1)),ot=e=>Zl.test(e),On=()=>!0,tc=e=>Yl.test(e)&&!Xl.test(e),ls=()=>!1,rc=e=>Jl.test(e),sc=e=>ec.test(e),nc=e=>!G(e)&&!B(e),oc=e=>ut(e,zn,ls),G=e=>In.test(e),xt=e=>ut(e,Qn,tc),_n=e=>ut(e,mc,oe),ac=e=>ut(e,Hn,On),ic=e=>ut(e,Un,ls),$n=e=>ut(e,Bn,ls),lc=e=>ut(e,Fn,sc),Sr=e=>ut(e,Vn,rc),B=e=>Ln.test(e),Kt=e=>vt(e,Qn),cc=e=>vt(e,Un),Gn=e=>vt(e,Bn),uc=e=>vt(e,zn),dc=e=>vt(e,Fn),kr=e=>vt(e,Vn,!0),fc=e=>vt(e,Hn,!0),ut=(e,t,s)=>{const n=In.exec(e);return n?n[1]?t(n[1]):s(n[2]):!1},vt=(e,t,s=!1)=>{const n=Ln.exec(e);return n?n[1]?t(n[1]):s:!1},Bn=e=>e==="position"||e==="percentage",Fn=e=>e==="image"||e==="url",zn=e=>e==="length"||e==="size"||e==="bg-size",Qn=e=>e==="length",mc=e=>e==="number",Un=e=>e==="family-name",Hn=e=>e==="number"||e==="weight",Vn=e=>e==="shadow",pc=()=>{const e=Ce("color"),t=Ce("font"),s=Ce("text"),n=Ce("font-weight"),o=Ce("tracking"),a=Ce("leading"),i=Ce("breakpoint"),l=Ce("container"),u=Ce("spacing"),d=Ce("radius"),f=Ce("shadow"),m=Ce("inset-shadow"),g=Ce("text-shadow"),b=Ce("drop-shadow"),x=Ce("blur"),v=Ce("perspective"),w=Ce("aspect"),y=Ce("ease"),S=Ce("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],C=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],N=()=>[...C(),B,G],E=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto","contain","none"],A=()=>[B,G,u],Q=()=>[lt,"full","auto",...A()],ee=()=>[ct,"none","subgrid",B,G],ne=()=>["auto",{span:["full",ct,B,G]},ct,B,G],pe=()=>[ct,"auto",B,G],ae=()=>["auto","min","max","fr",B,G],ce=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],se=()=>["start","end","center","stretch","center-safe","end-safe"],J=()=>["auto",...A()],H=()=>[lt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...A()],xe=()=>[lt,"screen","full","dvw","lvw","svw","min","max","fit",...A()],de=()=>[lt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...A()],D=()=>[e,B,G],$=()=>[...C(),Gn,$n,{position:[B,G]}],_=()=>["no-repeat",{repeat:["","x","y","space","round"]}],te=()=>["auto","cover","contain",uc,oc,{size:[B,G]}],U=()=>[is,Kt,xt],V=()=>["","none","full",d,B,G],W=()=>["",oe,Kt,xt],z=()=>["solid","dashed","dotted","double"],X=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],q=()=>[oe,is,Gn,$n],Re=()=>["","none",x,B,G],De=()=>["none",oe,B,G],K=()=>["none",oe,B,G],ue=()=>[oe,B,G],ve=()=>[lt,"full",...A()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ot],breakpoint:[ot],color:[On],container:[ot],"drop-shadow":[ot],ease:["in","out","in-out"],font:[nc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ot],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ot],shadow:[ot],spacing:["px",oe],text:[ot],"text-shadow":[ot],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",lt,G,B,w]}],container:["container"],columns:[{columns:[oe,G,B,l]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"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:N()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:R()}],"overscroll-x":[{"overscroll-x":R()}],"overscroll-y":[{"overscroll-y":R()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:Q()}],"inset-x":[{"inset-x":Q()}],"inset-y":[{"inset-y":Q()}],start:[{"inset-s":Q(),start:Q()}],end:[{"inset-e":Q(),end:Q()}],"inset-bs":[{"inset-bs":Q()}],"inset-be":[{"inset-be":Q()}],top:[{top:Q()}],right:[{right:Q()}],bottom:[{bottom:Q()}],left:[{left:Q()}],visibility:["visible","invisible","collapse"],z:[{z:[ct,"auto",B,G]}],basis:[{basis:[lt,"full","auto",l,...A()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[oe,lt,"auto","initial","none",G]}],grow:[{grow:["",oe,B,G]}],shrink:[{shrink:["",oe,B,G]}],order:[{order:[ct,"first","last","none",B,G]}],"grid-cols":[{"grid-cols":ee()}],"col-start-end":[{col:ne()}],"col-start":[{"col-start":pe()}],"col-end":[{"col-end":pe()}],"grid-rows":[{"grid-rows":ee()}],"row-start-end":[{row:ne()}],"row-start":[{"row-start":pe()}],"row-end":[{"row-end":pe()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ae()}],"auto-rows":[{"auto-rows":ae()}],gap:[{gap:A()}],"gap-x":[{"gap-x":A()}],"gap-y":[{"gap-y":A()}],"justify-content":[{justify:[...ce(),"normal"]}],"justify-items":[{"justify-items":[...se(),"normal"]}],"justify-self":[{"justify-self":["auto",...se()]}],"align-content":[{content:["normal",...ce()]}],"align-items":[{items:[...se(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...se(),{baseline:["","last"]}]}],"place-content":[{"place-content":ce()}],"place-items":[{"place-items":[...se(),"baseline"]}],"place-self":[{"place-self":["auto",...se()]}],p:[{p:A()}],px:[{px:A()}],py:[{py:A()}],ps:[{ps:A()}],pe:[{pe:A()}],pbs:[{pbs:A()}],pbe:[{pbe:A()}],pt:[{pt:A()}],pr:[{pr:A()}],pb:[{pb:A()}],pl:[{pl:A()}],m:[{m:J()}],mx:[{mx:J()}],my:[{my:J()}],ms:[{ms:J()}],me:[{me:J()}],mbs:[{mbs:J()}],mbe:[{mbe:J()}],mt:[{mt:J()}],mr:[{mr:J()}],mb:[{mb:J()}],ml:[{ml:J()}],"space-x":[{"space-x":A()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":A()}],"space-y-reverse":["space-y-reverse"],size:[{size:H()}],"inline-size":[{inline:["auto",...xe()]}],"min-inline-size":[{"min-inline":["auto",...xe()]}],"max-inline-size":[{"max-inline":["none",...xe()]}],"block-size":[{block:["auto",...de()]}],"min-block-size":[{"min-block":["auto",...de()]}],"max-block-size":[{"max-block":["none",...de()]}],w:[{w:[l,"screen",...H()]}],"min-w":[{"min-w":[l,"screen","none",...H()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...H()]}],h:[{h:["screen","lh",...H()]}],"min-h":[{"min-h":["screen","lh","none",...H()]}],"max-h":[{"max-h":["screen","lh",...H()]}],"font-size":[{text:["base",s,Kt,xt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,fc,ac]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",is,G]}],"font-family":[{font:[cc,ic,t]}],"font-features":[{"font-features":[G]}],"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:[o,B,G]}],"line-clamp":[{"line-clamp":[oe,"none",B,_n]}],leading:[{leading:[a,...A()]}],"list-image":[{"list-image":["none",B,G]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",B,G]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...z(),"wavy"]}],"text-decoration-thickness":[{decoration:[oe,"from-font","auto",B,xt]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[oe,"auto",B,G]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:A()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",B,G]}],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",B,G]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:$()}],"bg-repeat":[{bg:_()}],"bg-size":[{bg:te()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ct,B,G],radial:["",B,G],conic:[ct,B,G]},dc,lc]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:W()}],"border-w-x":[{"border-x":W()}],"border-w-y":[{"border-y":W()}],"border-w-s":[{"border-s":W()}],"border-w-e":[{"border-e":W()}],"border-w-bs":[{"border-bs":W()}],"border-w-be":[{"border-be":W()}],"border-w-t":[{"border-t":W()}],"border-w-r":[{"border-r":W()}],"border-w-b":[{"border-b":W()}],"border-w-l":[{"border-l":W()}],"divide-x":[{"divide-x":W()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":W()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...z(),"hidden","none"]}],"divide-style":[{divide:[...z(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...z(),"none","hidden"]}],"outline-offset":[{"outline-offset":[oe,B,G]}],"outline-w":[{outline:["",oe,Kt,xt]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","none",f,kr,Sr]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",m,kr,Sr]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:W()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[oe,xt]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":W()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",g,kr,Sr]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[oe,B,G]}],"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":[oe]}],"mask-image-linear-from-pos":[{"mask-linear-from":q()}],"mask-image-linear-to-pos":[{"mask-linear-to":q()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":q()}],"mask-image-t-to-pos":[{"mask-t-to":q()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":q()}],"mask-image-r-to-pos":[{"mask-r-to":q()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":q()}],"mask-image-b-to-pos":[{"mask-b-to":q()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":q()}],"mask-image-l-to-pos":[{"mask-l-to":q()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":q()}],"mask-image-x-to-pos":[{"mask-x-to":q()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":q()}],"mask-image-y-to-pos":[{"mask-y-to":q()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[B,G]}],"mask-image-radial-from-pos":[{"mask-radial-from":q()}],"mask-image-radial-to-pos":[{"mask-radial-to":q()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"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":C()}],"mask-image-conic-pos":[{"mask-conic":[oe]}],"mask-image-conic-from-pos":[{"mask-conic-from":q()}],"mask-image-conic-to-pos":[{"mask-conic-to":q()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:$()}],"mask-repeat":[{mask:_()}],"mask-size":[{mask:te()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",B,G]}],filter:[{filter:["","none",B,G]}],blur:[{blur:Re()}],brightness:[{brightness:[oe,B,G]}],contrast:[{contrast:[oe,B,G]}],"drop-shadow":[{"drop-shadow":["","none",b,kr,Sr]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",oe,B,G]}],"hue-rotate":[{"hue-rotate":[oe,B,G]}],invert:[{invert:["",oe,B,G]}],saturate:[{saturate:[oe,B,G]}],sepia:[{sepia:["",oe,B,G]}],"backdrop-filter":[{"backdrop-filter":["","none",B,G]}],"backdrop-blur":[{"backdrop-blur":Re()}],"backdrop-brightness":[{"backdrop-brightness":[oe,B,G]}],"backdrop-contrast":[{"backdrop-contrast":[oe,B,G]}],"backdrop-grayscale":[{"backdrop-grayscale":["",oe,B,G]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[oe,B,G]}],"backdrop-invert":[{"backdrop-invert":["",oe,B,G]}],"backdrop-opacity":[{"backdrop-opacity":[oe,B,G]}],"backdrop-saturate":[{"backdrop-saturate":[oe,B,G]}],"backdrop-sepia":[{"backdrop-sepia":["",oe,B,G]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":A()}],"border-spacing-x":[{"border-spacing-x":A()}],"border-spacing-y":[{"border-spacing-y":A()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",B,G]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[oe,"initial",B,G]}],ease:[{ease:["linear","initial",y,B,G]}],delay:[{delay:[oe,B,G]}],animate:[{animate:["none",S,B,G]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,B,G]}],"perspective-origin":[{"perspective-origin":N()}],rotate:[{rotate:De()}],"rotate-x":[{"rotate-x":De()}],"rotate-y":[{"rotate-y":De()}],"rotate-z":[{"rotate-z":De()}],scale:[{scale:K()}],"scale-x":[{"scale-x":K()}],"scale-y":[{"scale-y":K()}],"scale-z":[{"scale-z":K()}],"scale-3d":["scale-3d"],skew:[{skew:ue()}],"skew-x":[{"skew-x":ue()}],"skew-y":[{"skew-y":ue()}],transform:[{transform:[B,G,"","none","gpu","cpu"]}],"transform-origin":[{origin:N()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ve()}],"translate-x":[{"translate-x":ve()}],"translate-y":[{"translate-y":ve()}],"translate-z":[{"translate-z":ve()}],"translate-none":["translate-none"],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"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",B,G]}],"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":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mbs":[{"scroll-mbs":A()}],"scroll-mbe":[{"scroll-mbe":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pbs":[{"scroll-pbs":A()}],"scroll-pbe":[{"scroll-pbe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"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",B,G]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[oe,Kt,xt,_n]}],stroke:[{stroke:["none",...D()]}],"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"]}},hc=Wl(pc);function j(...e){return hc(Wt(e))}var gc="rounded-lg border border-border bg-surface overflow-hidden",bc="border-b border-border px-3 sm:px-4 py-1.5 sm:py-2",xc="p-2 sm:p-3 lg:p-4",vc="space-y-3 sm:space-y-4",yc="gap-2 sm:gap-3",wc="px-3 sm:px-4 py-1.5 sm:py-2",Sc="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4",kc="grid grid-cols-1 lg:grid-cols-2",jc="flex flex-col-reverse md:flex-row",Nc="w-full md:w-44 lg:w-52 md:flex-shrink-0 border-b md:border-b-0 md:border-l border-border",Cc="text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider",Mc="text-[11px] sm:text-xs text-foreground",Ec="text-[10px] text-foreground-subtle",Ac="text-[11px] sm:text-xs font-medium text-foreground",Pc="text-base sm:text-lg font-semibold leading-tight text-foreground",Rc="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",Dc="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",Tc="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",Ic="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",Lc="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",Oc="inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors",_c="border-primary/50 bg-primary/15 text-primary",$c="border-border bg-surface text-foreground-subtle hover:bg-surface-hover";function Gc(e,t){for(const s of e.slots)for(const n of s.addons)if(n.id===t)return n;return null}function Bc(e,t){return e.models.find(s=>s.id===t)??null}function Fc(e,t){return e.models.find(s=>!!s.formats[t])??null}function zc(e,t){const s=new Set((t.configSchema??[]).map(o=>o.key)),n={};for(const[o,a]of Object.entries(e))s.has(o)&&(n[o]=a);return n}function Qc(e){const{source:t,target:s,catalog:n,addonIds:o}=e,a=[];for(const i of o){const l=t.defaults[i];if(!l){a.push({addonId:i,outcome:"skip",modelId:null,reason:"no source entry",patch:null});continue}const u=Gc(n,i);if(!u){a.push({addonId:i,outcome:"skip",modelId:null,reason:"addon not in target catalog",patch:null});continue}const d=Bc(u,l.modelId),f=d!==null&&!!d.formats[s.engine.format];let m,g;if(f)m=l.modelId,g="exact";else{const x=Fc(u,s.engine.format);if(!x){a.push({addonId:i,outcome:"skip",modelId:null,reason:"no compatible model for target format",patch:null});continue}m=x.id,g="mapped"}const b={enabled:l.enabled,modelId:m,settings:zc(l.settings,u)};a.push({addonId:i,outcome:g,modelId:m,patch:b})}return a}var cs={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 us(e){return cs[e]??cs.watching}function at(e,t){if(typeof globalThis>"u")return(0,h.createContext)(t);const s=globalThis.__camstackSharedContexts,n=s??new Map;s||(globalThis.__camstackSharedContexts=n);const o=n.get(e);if(o)return o;const a=(0,h.createContext)(t);return n.set(e,a),a}var Uc="FEDERATION_DEBUG",ds=(function(e){return e[e.UNKNOWN=1]="UNKNOWN",e[e.CALCULATED=2]="CALCULATED",e[e.NO_USE=0]="NO_USE",e})({}),Wn=!0;function Hc(){return Wn}function Vc(){try{if(Hc()&&window.localStorage)return!!localStorage.getItem(Uc)}catch{return!1}return!1}function fs(){return typeof process<"u"&&Me&&Me.FEDERATION_DEBUG?!!Me.FEDERATION_DEBUG:typeof FEDERATION_DEBUG<"u"&&FEDERATION_DEBUG?!0:Vc()}var Wc="[ Federation Runtime ]",qn=function(...e){return e.length?e.reduce((t,s)=>s?t?`${t}:${s}`:s:t,""):""},ms=(e,t)=>{if("getPublicPath"in e){let s;return e.getPublicPath.startsWith("function")?s=new Function("return "+e.getPublicPath)()():s=new Function(e.getPublicPath)(),`${s}${t}`}else return"publicPath"in e?`${e.publicPath}${t}`:(console.warn("Cannot get resource URL. If in debug mode, please ignore.",e,t),"")},Kn=e=>{console.warn(`${Wc}: ${e}`)};function Zn(e){try{return JSON.stringify(e,null,2)}catch{return""}}var ps=(e,t)=>{if(!e)return t;const n=(o=>{if(o===".")return"";if(o.startsWith("./"))return o.replace("./","");if(o.startsWith("/")){const a=o.slice(1);return a.endsWith("/")?a.slice(0,-1):a}return o})(e);return n?n.endsWith("/")?`${n}${t}`:`${n}/${t}`:t};function qc(e){return e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")}function Kc(e,t={}){const{remotes:s={},overrides:n={},version:o}=t;let a;const i=()=>"publicPath"in e.metaData?(e.metaData.publicPath==="auto"||e.metaData.publicPath==="")&&o?qc(o):e.metaData.publicPath:e.metaData.getPublicPath,l=Object.keys(n);let u={};Object.keys(s).length||(u=e.remotes?.reduce((S,k)=>{let C;const N=k.federationContainerName;return l.includes(N)?C=n[N]:"version"in k?C=k.version:C=k.entry,S[N]={matchedVersion:C},S},{})||{}),Object.keys(s).forEach(S=>u[S]={matchedVersion:l.includes(S)?n[S]:s[S]});const{remoteEntry:{path:d,name:f,type:m},types:g={path:"",name:"",zip:"",api:""},buildInfo:{buildVersion:b},globalName:x,ssrRemoteEntry:v}=e.metaData,{exposes:w}=e;let y={version:o||"",buildVersion:b,globalName:x,remoteEntry:ps(d,f),remoteEntryType:m,remoteTypes:ps(g.path,g.name),remoteTypesZip:g.zip||"",remoteTypesAPI:g.api||"",remotesInfo:u,shared:e?.shared.map(S=>({assets:S.assets,sharedName:S.name,version:S.version,usedExports:S.referenceExports||[]})),modules:w?.map(S=>({moduleName:S.name,modulePath:S.path,assets:S.assets}))};if("publicPath"in e.metaData?(a={...y,publicPath:i()},typeof e.metaData.ssrPublicPath=="string"&&(a.ssrPublicPath=e.metaData.ssrPublicPath)):a={...y,getPublicPath:i()},v){const S=ps(v.path,v.name);a.ssrRemoteEntry=S,a.ssrRemoteEntryType=v.type||"commonjs-module"}return a}function Yn(e){return!!("remoteEntry"in e&&e.remoteEntry.includes(".json"))}var Zc="[ Module Federation ]",Zt=console,Yc=["logger.ts","logger.js","captureStackTrace","Logger.emit","Logger.log","Logger.info","Logger.warn","Logger.error","Logger.debug"];function Xc(){try{const e=new Error().stack;if(!e)return;const[,...t]=e.split(`
31
+ `),s=t.filter(n=>!Yc.some(o=>n.includes(o)));return s.length?`Stack trace:
32
+ ${s.slice(0,5).join(`
33
+ `)}`:void 0}catch{return}}var Xn=class{constructor(e,t=Zt){this.prefix=e,this.delegate=t??Zt}setPrefix(e){this.prefix=e}setDelegate(e){this.delegate=e??Zt}emit(e,t){const s=this.delegate,n=fs()?Xc():void 0,o=n?[...t,n]:t,a=(()=>{switch(e){case"log":return["log","info"];case"info":return["info","log"];case"warn":return["warn","info","log"];case"error":return["error","warn","log"];default:return["debug","log"]}})();for(const i of a){const l=s[i];if(typeof l=="function"){l.call(s,this.prefix,...o);return}}for(const i of a){const l=Zt[i];if(typeof l=="function"){l.call(Zt,this.prefix,...o);return}}}log(...e){this.emit("log",e)}warn(...e){this.emit("warn",e)}error(...e){this.emit("error",e)}success(...e){this.emit("info",e)}info(...e){this.emit("info",e)}ready(...e){this.emit("info",e)}debug(...e){fs()&&this.emit("debug",e)}};function Jc(e){return new Xn(e)}function eu(e){const t=new Xn(e);return Object.defineProperty(t,"__mf_infrastructure_logger__",{value:!0,enumerable:!1,configurable:!1}),t}eu(Zc);async function Jn(e,t){try{return await e()}catch(s){Kn(s);return}}function hs(e,t){const s=/^(https?:)?\/\//i;return e.replace(s,"").replace(/\/$/,"")===t.replace(s,"").replace(/\/$/,"")}function eo(e){let t=null,s=!0,n=2e4,o;const a=document.getElementsByTagName("script");for(let d=0;d<a.length;d++){const f=a[d],m=f.getAttribute("src");if(m&&hs(m,e.url)){t=f,s=!1;break}}if(!t){const d=e.attrs;t=document.createElement("script"),t.type=d?.type==="module"?"module":"text/javascript";let f;e.createScriptHook&&(f=e.createScriptHook(e.url,e.attrs),f instanceof HTMLScriptElement?t=f:typeof f=="object"&&("script"in f&&f.script&&(t=f.script),"timeout"in f&&f.timeout&&(n=f.timeout))),t.src||(t.src=e.url),d&&!f&&Object.keys(d).forEach(m=>{t&&(m==="async"||m==="defer"?t[m]=d[m]:t.getAttribute(m)||t.setAttribute(m,d[m]))})}let i=null;const l=typeof window<"u"?d=>{if(d.filename&&hs(d.filename,e.url)){const f=new Error(`ScriptExecutionError: Script "${e.url}" loaded but threw a runtime error during execution: ${d.message} (${d.filename}:${d.lineno}:${d.colno})`);f.name="ScriptExecutionError",i=f}}:null;l&&window.addEventListener("error",l);const u=async(d,f)=>{clearTimeout(o),l&&window.removeEventListener("error",l);const m=()=>{if(f?.type==="error"){const g=new Error(f?.isTimeout?`ScriptNetworkError: Script "${e.url}" timed out.`:`ScriptNetworkError: Failed to load script "${e.url}" - the script URL is unreachable or the server returned an error (network failure, 404, CORS, etc.)`);g.name="ScriptNetworkError",e?.onErrorCallback&&e?.onErrorCallback(g)}else i?e?.onErrorCallback&&e?.onErrorCallback(i):e?.cb&&e?.cb()};if(t&&(t.onerror=null,t.onload=null,Jn(()=>{const{needDeleteScript:g=!0}=e;g&&t?.parentNode&&t.parentNode.removeChild(t)}),d&&typeof d=="function")){const g=d(f);if(g instanceof Promise){const b=await g;return m(),b}return m(),g}m()};return t.onerror=u.bind(null,t.onerror),t.onload=u.bind(null,t.onload),o=setTimeout(()=>{u(null,{type:"error",isTimeout:!0})},n),{script:t,needAttach:s}}function gs(e){let t=null,s=!0;const n=document.getElementsByTagName("link");for(let a=0;a<n.length;a++){const i=n[a],l=i.getAttribute("href"),u=i.getAttribute("rel");if(l&&hs(l,e.url)&&u===e.attrs.rel){t=i,s=!1;break}}if(!t){t=document.createElement("link"),t.setAttribute("href",e.url);let a;const i=e.attrs;e.createLinkHook&&(a=e.createLinkHook(e.url,i),a instanceof HTMLLinkElement&&(t=a)),i&&!a&&Object.keys(i).forEach(l=>{t&&!t.getAttribute(l)&&t.setAttribute(l,i[l])})}const o=(a,i)=>{const l=()=>{i?.type==="error"?e?.onErrorCallback&&e?.onErrorCallback(i):e?.cb&&e?.cb()};if(t&&(t.onerror=null,t.onload=null,Jn(()=>{const{needDeleteLink:u=!0}=e;u&&t?.parentNode&&t.parentNode.removeChild(t)}),a)){const u=a(i);return l(),u}l()};return t.onerror=o.bind(null,t.onerror),t.onload=o.bind(null,t.onload),{link:t,needAttach:s}}function tu(e,t){const{attrs:s={},createScriptHook:n}=t;return new Promise((o,a)=>{const{script:i,needAttach:l}=eo({url:e,cb:o,onErrorCallback:a,attrs:{fetchpriority:"high",...s},createScriptHook:n,needDeleteScript:!0});l&&document.head.appendChild(i)})}var ru=e=>`View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${e.split("-")[0].toLowerCase()}#${e.toLowerCase()}`,to=(e,t,s,n)=>{const o=[`${[t[e]]} #${e}`];return s&&o.push(`args: ${JSON.stringify(s)}`),o.push(ru(e)),n&&o.push(`Original Error Message:
34
+ ${n}`),o.join(`
35
+ `)};function su(e,t,s,n,o,a){return n(to(e,t,s,o))}var yt="[ Federation Runtime ]",bs=Jc(yt);function Le(e,t,s,n,o){e||(s!==void 0?ke(t,s,n,void 0):ke(t))}function ke(e,t,s,n,o){if(t!==void 0)return su(e,t,s??{},i=>{throw new Error(`${yt}: ${i}`)},n);const a=e;throw a instanceof Error?(a.message.startsWith(yt)||(a.message=`${yt}: ${a.message}`),a):new Error(`${yt}: ${a}`)}function xs(e){e instanceof Error&&(e.message.startsWith(yt)||(e.message=`${yt}: ${e.message}`)),bs.warn(e)}function nu(e,t){return e.findIndex(s=>s===t)===-1&&e.push(t),e}function Yt(e){return"version"in e&&e.version?`${e.name}:${e.version}`:"entry"in e&&e.entry?`${e.name}:${e.entry}`:`${e.name}`}function vs(e){return typeof e.entry<"u"}function ro(e){return!e.entry.includes(".json")}function ys(e){return e&&typeof e=="object"}var ou=Object.prototype.toString;function au(e){return ou.call(e)==="[object Object]"}function so(e){return Array.isArray(e)?e:[e]}function no(e){const t={url:"",type:"global",globalName:""};return"remoteEntry"in e?{url:e.remoteEntry,type:e.remoteEntryType,globalName:e.globalName}:t}var iu=(e,t)=>{let s;return e.endsWith("/")?s=e.slice(0,-1):s=e,t.startsWith(".")&&(t=t.slice(1)),s=s+t,s},Ne=typeof globalThis=="object"?globalThis:window,He=(()=>{try{return document.defaultView}catch{return Ne}})(),Xt=He;function jr(e,t,s){Object.defineProperty(e,t,{value:s,configurable:!1,writable:!0})}function Nr(e,t){return Object.hasOwnProperty.call(e,t)}Nr(Ne,"__GLOBAL_LOADING_REMOTE_ENTRY__")||jr(Ne,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});var Pt=Ne.__GLOBAL_LOADING_REMOTE_ENTRY__;function oo(e){Nr(e,"__VMOK__")&&!Nr(e,"__FEDERATION__")&&jr(e,"__FEDERATION__",e.__VMOK__),Nr(e,"__FEDERATION__")||(jr(e,"__FEDERATION__",{__GLOBAL_PLUGIN__:[],__INSTANCES__:[],moduleInfo:{},__SHARE__:{},__MANIFEST_LOADING__:{},__PRELOADED_MAP__:new Map}),jr(e,"__VMOK__",e.__FEDERATION__)),e.__FEDERATION__.__GLOBAL_PLUGIN__??=[],e.__FEDERATION__.__INSTANCES__??=[],e.__FEDERATION__.moduleInfo??={},e.__FEDERATION__.__SHARE__??={},e.__FEDERATION__.__MANIFEST_LOADING__??={},e.__FEDERATION__.__PRELOADED_MAP__??=new Map}oo(Ne),oo(He);function lu(e){Ne.__FEDERATION__.__INSTANCES__.push(e)}function cu(){return Ne.__FEDERATION__.__DEBUG_CONSTRUCTOR__}function uu(e,t=fs()){t&&(Ne.__FEDERATION__.__DEBUG_CONSTRUCTOR__=e,Ne.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__="2.4.0")}function Rt(e,t){if(typeof t=="string"){if(e[t])return{value:e[t],key:t};{const s=Object.keys(e);for(const n of s){const[o,a]=n.split(":"),i=`${o}:${t}`,l=e[i];if(l)return{value:l,key:i}}return{value:void 0,key:t}}}else ke(`getInfoWithoutType: "key" must be a string, got ${typeof t} (${JSON.stringify(t)}).`)}var ao=()=>He.__FEDERATION__.moduleInfo,du=(e,t)=>{const s=Rt(t,Yt(e)).value;if(s&&!s.version&&"version"in e&&e.version&&(s.version=e.version),s)return s;if("version"in e&&e.version){const{version:n,...o}=e,a=Yt(o),i=Rt(He.__FEDERATION__.moduleInfo,a).value;if(i?.version===n)return i}},Cr=e=>du(e,He.__FEDERATION__.moduleInfo),io=(e,t)=>{const s=Yt(e);return He.__FEDERATION__.moduleInfo[s]=t,He.__FEDERATION__.moduleInfo},fu=e=>(He.__FEDERATION__.moduleInfo={...He.__FEDERATION__.moduleInfo,...e},()=>{const t=Object.keys(e);for(const s of t)delete He.__FEDERATION__.moduleInfo[s]}),lo=(e,t)=>{const s=t||`__FEDERATION_${e}:custom__`;return{remoteEntryKey:s,entryExports:Ne[s]}},mu=()=>He.__FEDERATION__.__GLOBAL_PLUGIN__,pu=e=>Ne.__FEDERATION__.__PRELOADED_MAP__.get(e),hu=e=>Ne.__FEDERATION__.__PRELOADED_MAP__.set(e,!0),co="[0-9A-Za-z-]+",ws=`(?:\\+(${co}(?:\\.${co})*))`,Jt="0|[1-9]\\d*",Mr="[0-9]+",uo="\\d*[a-zA-Z-][a-zA-Z0-9-]*",fo=`(?:${Mr}|${uo})`,gu=`(?:-?(${fo}(?:\\.${fo})*))`,mo=`(?:${Jt}|${uo})`,po=`(?:-(${mo}(?:\\.${mo})*))`,Ss=`${Jt}|x|X|\\*`,Dt=`[v=\\s]*(${Ss})(?:\\.(${Ss})(?:\\.(${Ss})(?:${po})?${ws}?)?)?`,bu=`^\\s*(${Dt})\\s+-\\s+(${Dt})\\s*$`,xu=`[v=\\s]*${`(${Mr})\\.(${Mr})\\.(${Mr})`}${gu}?${ws}?`,ks="((?:<|>)?=?)",vu=`(\\s*)${ks}\\s*(${xu}|${Dt})`,ho="(?:~>?)",yu=`(\\s*)${ho}\\s+`,go="(?:\\^)",wu=`(\\s*)${go}\\s+`,Su="(<|>)?=?\\s*\\*",ku=`^${go}${Dt}$`,ju=`v?${`(${Jt})\\.(${Jt})\\.(${Jt})`}${po}?${ws}?`,Nu=`^${ho}${Dt}$`,Cu=`^${ks}\\s*${Dt}$`,Mu=`^${ks}\\s*(${ju})$|^$`,Eu="^\\s*>=\\s*0.0.0\\s*$";function Xe(e){return new RegExp(e)}function Pe(e){return!e||e.toLowerCase()==="x"||e==="*"}function bo(...e){return t=>e.reduce((s,n)=>n(s),t)}function xo(e){return e.match(Xe(Mu))}function vo(e,t,s,n){const o=`${e}.${t}.${s}`;return n?`${o}-${n}`:o}function Au(e){return e.replace(Xe(bu),(t,s,n,o,a,i,l,u,d,f,m,g)=>(Pe(n)?s="":Pe(o)?s=`>=${n}.0.0`:Pe(a)?s=`>=${n}.${o}.0`:s=`>=${s}`,Pe(d)?u="":Pe(f)?u=`<${Number(d)+1}.0.0-0`:Pe(m)?u=`<${d}.${Number(f)+1}.0-0`:g?u=`<=${d}.${f}.${m}-${g}`:u=`<=${u}`,`${s} ${u}`.trim()))}function Pu(e){return e.replace(Xe(vu),"$1$2$3")}function Ru(e){return e.replace(Xe(yu),"$1~")}function Du(e){return e.replace(Xe(wu),"$1^")}function Tu(e){return e.trim().split(/\s+/).map(t=>t.replace(Xe(ku),(s,n,o,a,i)=>Pe(n)?"":Pe(o)?`>=${n}.0.0 <${Number(n)+1}.0.0-0`:Pe(a)?n==="0"?`>=${n}.${o}.0 <${n}.${Number(o)+1}.0-0`:`>=${n}.${o}.0 <${Number(n)+1}.0.0-0`:i?n==="0"?o==="0"?`>=${n}.${o}.${a}-${i} <${n}.${o}.${Number(a)+1}-0`:`>=${n}.${o}.${a}-${i} <${n}.${Number(o)+1}.0-0`:`>=${n}.${o}.${a}-${i} <${Number(n)+1}.0.0-0`:n==="0"?o==="0"?`>=${n}.${o}.${a} <${n}.${o}.${Number(a)+1}-0`:`>=${n}.${o}.${a} <${n}.${Number(o)+1}.0-0`:`>=${n}.${o}.${a} <${Number(n)+1}.0.0-0`)).join(" ")}function Iu(e){return e.trim().split(/\s+/).map(t=>t.replace(Xe(Nu),(s,n,o,a,i)=>Pe(n)?"":Pe(o)?`>=${n}.0.0 <${Number(n)+1}.0.0-0`:Pe(a)?`>=${n}.${o}.0 <${n}.${Number(o)+1}.0-0`:i?`>=${n}.${o}.${a}-${i} <${n}.${Number(o)+1}.0-0`:`>=${n}.${o}.${a} <${n}.${Number(o)+1}.0-0`)).join(" ")}function Lu(e){return e.split(/\s+/).map(t=>t.trim().replace(Xe(Cu),(s,n,o,a,i,l)=>{const u=Pe(o),d=u||Pe(a),f=d||Pe(i);return n==="="&&f&&(n=""),l="",u?n===">"||n==="<"?"<0.0.0-0":"*":n&&f?(d&&(a=0),i=0,n===">"?(n=">=",d?(o=Number(o)+1,a=0,i=0):(a=Number(a)+1,i=0)):n==="<="&&(n="<",d?o=Number(o)+1:a=Number(a)+1),n==="<"&&(l="-0"),`${n+o}.${a}.${i}${l}`):d?`>=${o}.0.0${l} <${Number(o)+1}.0.0-0`:f?`>=${o}.${a}.0${l} <${o}.${Number(a)+1}.0-0`:s})).join(" ")}function Ou(e){return e.trim().replace(Xe(Su),"")}function _u(e){return e.trim().replace(Xe(Eu),"")}function Er(e,t){return e=Number(e)||e,t=Number(t)||t,e>t?1:e===t?0:-1}function $u(e,t){const{preRelease:s}=e,{preRelease:n}=t;if(s===void 0&&n)return 1;if(s&&n===void 0)return-1;if(s===void 0&&n===void 0)return 0;for(let o=0,a=s.length;o<=a;o++){const i=s[o],l=n[o];if(i!==l)return i===void 0&&l===void 0?0:i?l?Er(i,l):-1:1}return 0}function Ar(e,t){return Er(e.major,t.major)||Er(e.minor,t.minor)||Er(e.patch,t.patch)||$u(e,t)}function js(e,t){return e.version===t.version}function Gu(e,t){switch(e.operator){case"":case"=":return js(e,t);case">":return Ar(e,t)<0;case">=":return js(e,t)||Ar(e,t)<0;case"<":return Ar(e,t)>0;case"<=":return js(e,t)||Ar(e,t)>0;case void 0:return!0;default:return!1}}function Bu(e){return bo(Tu,Iu,Lu,Ou)(e)}function Fu(e){return bo(Au,Pu,Ru,Du)(e.trim()).split(/\s+/).join(" ")}function er(e,t){if(!e)return!1;const s=xo(e);if(!s)return!1;const[,n,,o,a,i,l]=s,u={operator:n,version:vo(o,a,i,l),major:o,minor:a,patch:i,preRelease:l?.split(".")},d=t.split("||");for(const f of d){const m=f.trim();if(!m||m==="*"||m==="x")return!0;try{const g=Fu(m);if(!g.trim())return!0;const b=g.split(" ").map(w=>Bu(w)).join(" ");if(!b.trim())return!0;const x=b.split(/\s+/).map(w=>_u(w)).filter(Boolean);if(x.length===0)continue;let v=!0;for(const w of x){const y=xo(w);if(!y){v=!1;break}const[,S,,k,C,N,E]=y;if(!Gu({operator:S,version:vo(k,C,N,E),major:k,minor:C,patch:N,preRelease:E?.split(".")},u)){v=!1;break}}if(v)return!0}catch(g){console.error(`[semver] Error processing range part "${m}":`,g);continue}}return!1}var Pr="default",zu="global";function Qu(e,t,s,n){let o;return"get"in e?o=e.get:"lib"in e?o=()=>Promise.resolve(e.lib):o=()=>Promise.resolve(()=>{ke(`Cannot get shared "${s}" from "${t}": neither "get" nor "lib" is provided in the share config.`)}),e.shareConfig?.eager&&e.treeShaking?.mode&&ke(`Invalid shared config for "${s}" from "${t}": cannot use both "eager: true" and "treeShaking.mode" simultaneously. Choose one strategy.`),{deps:[],useIn:[],from:t,loading:null,...e,shareConfig:{requiredVersion:`^${e.version}`,singleton:!1,eager:!1,strictVersion:!1,...e.shareConfig},get:o,loaded:e?.loaded||"lib"in e?!0:void 0,version:e.version??"0",scope:Array.isArray(e.scope)?e.scope:[e.scope??"default"],strategy:(e.strategy??n)||"version-first",treeShaking:e.treeShaking?{...e.treeShaking,mode:e.treeShaking.mode??"server-calc",status:e.treeShaking.status??ds.UNKNOWN,useIn:[]}:void 0}}function yo(e,t){const s=t.shared||{},n=t.name,o=Object.keys(s).reduce((i,l)=>{const u=so(s[l]);return i[l]=i[l]||[],u.forEach(d=>{i[l].push(Qu(d,n,l,t.shareStrategy))}),i},{}),a={...e.shared};return Object.keys(o).forEach(i=>{a[i]?o[i].forEach(l=>{a[i].find(u=>u.version===l.version)||a[i].push(l)}):a[i]=o[i]}),{allShareInfos:a,newShareInfos:o}}function tr(e,t){if(!e)return!1;const{status:s,mode:n}=e;return s===ds.NO_USE?!1:s===ds.CALCULATED?!0:n==="runtime-infer"?t?Hu(e,t):!0:!1}function wt(e,t){const s=n=>{if(!Number.isNaN(Number(n))){const o=n.split(".");let a=n;for(let i=0;i<3-o.length;i++)a+=".0";return a}return n};return!!er(s(e),`<=${s(t)}`)}var rr=(e,t)=>{const s=t||function(n,o){return wt(n,o)};return Object.keys(e).reduce((n,o)=>!n||s(n,o)||n==="0"?o:n,0)},Rr=e=>!!e.loaded||typeof e.lib=="function",Uu=e=>!!e.loading,Hu=(e,t)=>{if(!e||!t)return!1;const{usedExports:s}=e;return s?!!t.every(n=>s.includes(n)):!1};function Vu(e,t,s,n){const o=e[t][s];let a="",i=tr(n);const l=function(u,d){return i?o[u].treeShaking?o[d].treeShaking?!Rr(o[u].treeShaking)&&wt(u,d):!1:!0:!Rr(o[u])&&wt(u,d)};if(i){if(a=rr(e[t][s],l),a)return{version:a,useTreesShaking:i};i=!1}return{version:rr(e[t][s],l),useTreesShaking:i}}var Tt=e=>Rr(e)||Uu(e);function Wu(e,t,s,n){const o=e[t][s];let a="",i=tr(n);const l=function(u,d){if(i){if(!o[u].treeShaking)return!0;if(!o[d].treeShaking)return!1;if(Tt(o[d].treeShaking))return Tt(o[u].treeShaking)?!!wt(u,d):!0;if(Tt(o[u].treeShaking))return!1}return Tt(o[d])?Tt(o[u])?!!wt(u,d):!0:Tt(o[u])?!1:wt(u,d)};if(i){if(a=rr(e[t][s],l),a)return{version:a,useTreesShaking:i};i=!1}return{version:rr(e[t][s],l),useTreesShaking:i}}function qu(e){return e==="loaded-first"?Wu:Vu}function Dr(e,t,s,n){if(!e)return;const{shareConfig:o,scope:a=Pr,strategy:i,treeShaking:l}=s,u=Array.isArray(a)?a:[a];for(const d of u)if(o&&e[d]&&e[d][t]){const{requiredVersion:f}=o,{version:m,useTreesShaking:g}=qu(i)(e,d,t,l),b=()=>{const v=e[d][t][m];if(o.singleton){if(typeof f=="string"&&!er(m,f)){const w=`Version ${m} from ${m&&v.from} of shared singleton module ${t} does not satisfy the requirement of ${s.from} which needs ${f})`;o.strictVersion?ke(w):xs(w)}return{shared:v,useTreesShaking:g}}else{if(f===!1||f==="*")return{shared:v,useTreesShaking:g};if(er(m,f))return{shared:v,useTreesShaking:g};const w=tr(l);if(w){for(const[y,S]of Object.entries(e[d][t]))if(tr(S.treeShaking,l?.usedExports)&&er(y,f))return{shared:S,useTreesShaking:w}}for(const[y,S]of Object.entries(e[d][t]))if(er(y,f))return{shared:S,useTreesShaking:!1}}},x={shareScopeMap:e,scope:d,pkgName:t,version:m,GlobalFederation:Xt.__FEDERATION__,shareInfo:s,resolver:b};return(n.emit(x)||x).resolver()}}function wo(){return Xt.__FEDERATION__.__SHARE__}function So(e){const{pkgName:t,extraOptions:s,shareInfos:n}=e,o=u=>{if(!u)return;const d={};return u.forEach(m=>{d[m.version]=m}),d[rr(d,function(m,g){return!Rr(d[m])&&wt(m,g)})]},a=s?.resolver??o,i=u=>u!==null&&typeof u=="object"&&!Array.isArray(u),l=(...u)=>{const d={};for(const f of u)if(f)for(const[m,g]of Object.entries(f)){const b=d[m];i(b)&&i(g)?d[m]=l(b,g):g!==void 0&&(d[m]=g)}return d};return l(a(n[t]),s?.customShareInfo)}var It=(e,t)=>{e.useIn||(e.useIn=[]),nu(e.useIn,t)};function Tr(e,t){return t&&e.treeShaking?e.treeShaking:e}function Ku(e,t){for(const s of e){const n=t.startsWith(s.name);let o=t.replace(s.name,"");if(n){if(o.startsWith("/")){const l=s.name;return o=`.${o}`,{pkgNameOrAlias:l,expose:o,remote:s}}else if(o==="")return{pkgNameOrAlias:s.name,expose:".",remote:s}}const a=s.alias&&t.startsWith(s.alias);let i=s.alias&&t.replace(s.alias,"");if(s.alias&&a){if(i&&i.startsWith("/")){const l=s.alias;return i=`.${i}`,{pkgNameOrAlias:l,expose:i,remote:s}}else if(i==="")return{pkgNameOrAlias:s.alias,expose:".",remote:s}}}}function Zu(e,t){for(const s of e)if(t===s.name||s.alias&&t===s.alias)return s}var ko="RUNTIME-001",jo="RUNTIME-002",No="RUNTIME-003",Co="RUNTIME-004",Mo="RUNTIME-005",Ns="RUNTIME-006",Eo="RUNTIME-007",Ao="RUNTIME-008",Cs="RUNTIME-009",Po="RUNTIME-010",Ro="RUNTIME-011",Yu="RUNTIME-012",Oe={[ko]:"Failed to get remoteEntry exports.",[jo]:'The remote entry interface does not contain "init"',[No]:"Failed to get manifest.",[Co]:"Failed to locate remote.",[Mo]:"Invalid loadShareSync function call from bundler runtime",[Ns]:"Invalid loadShareSync function call from runtime",[Eo]:"Failed to get remote snapshot.",[Ao]:"Failed to load script resources.",[Cs]:"Please call createInstance first.",[Po]:'The name option cannot be changed after initialization. If you want to create a new instance with a different name, please use "createInstance" api.',[Ro]:"The remoteEntry URL is missing from the remote snapshot.",[Yu]:'The getter for the shared module is not a function. This may be caused by setting "shared.import: false" without the host providing the corresponding lib.'};({...Oe});var Do=".then(callbacks[0]).catch(callbacks[1])";async function Xu({entry:e,remoteEntryExports:t}){return new Promise((s,n)=>{try{t?s(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${e}")${Do}`)([s,n]):import(e).then(s).catch(n)}catch(o){ke(`Failed to load ESM entry from "${e}". ${o instanceof Error?o.message:String(o)}`)}})}async function Ju({entry:e,remoteEntryExports:t}){return new Promise((s,n)=>{try{t?s(t):typeof __system_context__>"u"?System.import(e).then(s).catch(n):new Function("callbacks",`System.import("${e}")${Do}`)([s,n])}catch(o){ke(`Failed to load SystemJS entry from "${e}". ${o instanceof Error?o.message:String(o)}`)}})}function ed(e,t,s){const{remoteEntryKey:n,entryExports:o}=lo(e,t);return o||ke(ko,Oe,{remoteName:e,remoteEntryUrl:s,remoteEntryKey:n}),o}async function td({name:e,globalName:t,entry:s,remoteInfo:n,loaderHook:o,getEntryUrl:a}){const{entryExports:i}=lo(e,t);if(i)return i;const l=a?a(s):s;return tu(l,{attrs:{},createScriptHook:(u,d)=>{const f=o.lifecycle.createScript.emit({url:u,attrs:d,remoteInfo:n});if(f&&(f instanceof HTMLScriptElement||"script"in f||"timeout"in f))return f}}).then(()=>ed(e,t,s),u=>{const d=u instanceof Error?u.message:String(u);ke(Ao,Oe,{remoteName:e,resourceUrl:l},d)})}async function rd({remoteInfo:e,remoteEntryExports:t,loaderHook:s,getEntryUrl:n}){const{entry:o,entryGlobalName:a,name:i,type:l}=e;switch(l){case"esm":case"module":return Xu({entry:o,remoteEntryExports:t});case"system":return Ju({entry:o,remoteEntryExports:t});default:return td({entry:o,globalName:a,name:i,remoteInfo:e,loaderHook:s,getEntryUrl:n})}}function Ms(e){const{entry:t,name:s}=e;return qn(s,t)}async function Ir(e){const{origin:t,remoteEntryExports:s,remoteInfo:n,getEntryUrl:o,_inErrorHandling:a=!1}=e,i=Ms(n);if(s)return s;if(!Pt[i]){const l=t.remoteHandler.hooks.lifecycle.loadEntry,u=t.loaderHook;Pt[i]=l.emit({loaderHook:u,remoteInfo:n,remoteEntryExports:s}).then(d=>d||rd({remoteInfo:n,remoteEntryExports:s,loaderHook:u,getEntryUrl:o})).catch(async d=>{const f=Ms(n),m=d instanceof Error&&d.message.includes("ScriptExecutionError");if(d instanceof Error&&d.message.includes("RUNTIME-008")&&!m&&!a){const g=x=>Ir({...x,_inErrorHandling:!0}),b=await t.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry:g,origin:t,remoteInfo:n,remoteEntryExports:s,globalLoading:Pt,uniqueKey:f});if(b)return b}throw d})}return Pt[i]}function Lr(e){return{...e,entry:"entry"in e?e.entry:"",type:e.type||"global",entryGlobalName:e.entryGlobalName||e.name,shareScope:e.shareScope||"default"}}function sd(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function nd(e,t){const s=mu(),n=[t.hooks,t.remoteHandler.hooks,t.sharedHandler.hooks,t.snapshotHandler.hooks,t.loaderHook,t.bridgeHook];return s.length>0&&s.forEach(o=>{e?.find(a=>a.name!==o.name)&&e.push(o)}),e&&e.length>0&&e.forEach(o=>{n.forEach(a=>{a.applyPlugin(o,t)})}),e}function od(e){return{name:e.name,alias:e.alias,entry:"entry"in e?e.entry:void 0,version:"version"in e?e.version:void 0,type:e.type,entryGlobalName:e.entryGlobalName,shareScope:e.shareScope}}function Lt(e){const t={};for(const[s,n]of Object.entries(e.shared)){const o=n[0];o&&(t[s]={version:o.version,singleton:o.shareConfig?.singleton,requiredVersion:o.shareConfig?.requiredVersion===!1?!1:o.shareConfig?.requiredVersion,eager:o.eager,strictVersion:o.shareConfig?.strictVersion})}return{project:{name:e.name,mfRole:e.remotes?.length>0?"host":"unknown"},mfConfig:{name:e.name,remotes:e.remotes?.map(od)??[],shared:t}}}function To(e){return{resourceCategory:"sync",share:!0,depsRemote:!0,...e}}function ad(e,t){return t.map(s=>{const n=Zu(e,s.nameOrAlias);return Le(n,`Unable to preload ${s.nameOrAlias} as it is not included in ${!n&&Zn({remoteInfo:n,remotes:e})}`),{remote:n,preloadConfig:To(s)}})}function id(e){return e?e.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function Io(e,t,s,n=!0){const{cssAssets:o,jsAssetsWithoutEntry:a,entryAssets:i}=s;if(t.options.inBrowser){if(i.forEach(l=>{const{moduleInfo:u}=l,d=t.moduleCache.get(e.name);Ir(d?{origin:t,remoteInfo:u,remoteEntryExports:d.remoteEntryExports}:{origin:t,remoteInfo:u,remoteEntryExports:void 0})}),n){const l={rel:"preload",as:"style"};o.forEach(u=>{const{link:d,needAttach:f}=gs({url:u,cb:()=>{},attrs:l,createLinkHook:(m,g)=>{const b=t.loaderHook.lifecycle.createLink.emit({url:m,attrs:g,remoteInfo:e});if(b instanceof HTMLLinkElement)return b}});f&&document.head.appendChild(d)})}else{const l={rel:"stylesheet",type:"text/css"};o.forEach(u=>{const{link:d,needAttach:f}=gs({url:u,cb:()=>{},attrs:l,createLinkHook:(m,g)=>{const b=t.loaderHook.lifecycle.createLink.emit({url:m,attrs:g,remoteInfo:e});if(b instanceof HTMLLinkElement)return b},needDeleteLink:!1});f&&document.head.appendChild(d)})}if(n){const l={rel:"preload",as:"script"};a.forEach(u=>{const{link:d,needAttach:f}=gs({url:u,cb:()=>{},attrs:l,createLinkHook:(m,g)=>{const b=t.loaderHook.lifecycle.createLink.emit({url:m,attrs:g,remoteInfo:e});if(b instanceof HTMLLinkElement)return b}});f&&document.head.appendChild(d)})}else{const l={fetchpriority:"high",type:e?.type==="module"?"module":"text/javascript"};a.forEach(u=>{const{script:d,needAttach:f}=eo({url:u,cb:()=>{},attrs:l,createScriptHook:(m,g)=>{const b=t.loaderHook.lifecycle.createScript.emit({url:m,attrs:g,remoteInfo:e});if(b instanceof HTMLScriptElement)return b},needDeleteScript:!0});f&&document.head.appendChild(d)})}}}function ld(e,t,s){const n=t,o=Array.isArray(e.shareScope)?e.shareScope:[e.shareScope];o.length||o.push("default"),o.forEach(i=>{n[i]||(n[i]={})});const a={version:e.version||"",shareScopeKeys:Array.isArray(e.shareScope)?o:e.shareScope||"default"};return Object.defineProperty(a,"shareScopeMap",{value:n,enumerable:!1}),{remoteEntryInitOptions:a,shareScope:n[o[0]],initScope:s??[]}}var Lo=class{constructor({remoteInfo:e,host:t}){this.inited=!1,this.initing=!1,this.lib=void 0,this.remoteInfo=e,this.host=t}async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;const e=await Ir({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports});return Le(e,`remoteEntryExports is undefined
36
+ ${Zn(this.remoteInfo)}`),this.remoteEntryExports=e,this.remoteEntryExports}async init(e,t,s){const n=await this.getEntry();if(this.inited)return n;if(this.initPromise)return await this.initPromise,n;this.initing=!0,this.initPromise=(async()=>{const{remoteEntryInitOptions:o,shareScope:a,initScope:i}=ld(this.remoteInfo,this.host.shareScopeMap,s),l=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:a,remoteEntryInitOptions:o,initScope:i,remoteInfo:this.remoteInfo,origin:this.host});typeof n?.init>"u"&&ke(jo,Oe,{hostName:this.host.name,remoteName:this.remoteInfo.name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName},void 0,Lt(this.host.options)),await n.init(l.shareScope,l.initScope,l.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit({...l,id:e,remoteSnapshot:t,remoteEntryExports:n}),this.inited=!0})();try{await this.initPromise}finally{this.initing=!1,this.initPromise=void 0}return n}async get(e,t,s,n){const{loadFactory:o=!0}=s||{loadFactory:!0},a=await this.init(e,n);this.lib=a;let i;i=await this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:a,expose:t,moduleInfo:this.remoteInfo}),i||(i=await a.get(t)),Le(i,`${Yt(this.remoteInfo)} remote don't export ${t}.`);const l=iu(this.remoteInfo.name,t),u=this.wraperFactory(i,l);return o?await u():u}wraperFactory(e,t){function s(n,o){n&&typeof n=="object"&&Object.isExtensible(n)&&!Object.getOwnPropertyDescriptor(n,Symbol.for("mf_module_id"))&&Object.defineProperty(n,Symbol.for("mf_module_id"),{value:o,enumerable:!1})}return e instanceof Promise?async()=>{const n=await e();return s(n,t),n}:()=>{const n=e();return s(n,t),n}}},Be=class{constructor(e){this.type="",this.listeners=new Set,e&&(this.type=e)}on(e){typeof e=="function"&&this.listeners.add(e)}once(e){const t=this;this.on(function s(...n){return t.remove(s),e.apply(null,n)})}emit(...e){let t;return this.listeners.size>0&&this.listeners.forEach(s=>{t=s(...e)}),t}remove(e){this.listeners.delete(e)}removeAll(){this.listeners.clear()}},Ve=class extends Be{emit(...e){let t;const s=Array.from(this.listeners);if(s.length>0){let n=0;const o=a=>a===!1?!1:n<s.length?Promise.resolve(s[n++].apply(null,e)).then(o):a;t=o()}return Promise.resolve(t)}};function Oo(e,t){if(!ys(t))return!1;if(e!==t){for(const s in e)if(!(s in t))return!1}return!0}var Ot=class extends Be{constructor(e){super(),this.onerror=ke,this.type=e}emit(e){ys(e)||ke(`The data for the "${this.type}" hook should be an object.`);for(const t of this.listeners)try{const s=t(e);if(Oo(e,s))e=s;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(s){xs(s),this.onerror(s)}return e}},dt=class extends Be{constructor(e){super(),this.onerror=ke,this.type=e}emit(e){ys(e)||ke(`The response data for the "${this.type}" hook must be an object.`);const t=Array.from(this.listeners);if(t.length>0){let s=0;const n=a=>(xs(a),this.onerror(a),e),o=a=>{if(Oo(e,a)){if(e=a,s<t.length)try{return Promise.resolve(t[s++](e)).then(o,n)}catch(i){return n(i)}}else this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);return e};return Promise.resolve(o(e))}return Promise.resolve(e)}},_t=class{constructor(e){this.registerPlugins={},this.lifecycle=e,this.lifecycleKeys=Object.keys(e)}applyPlugin(e,t){Le(au(e),"Plugin configuration is invalid.");const s=e.name;Le(s,"A name must be provided by the plugin."),this.registerPlugins[s]||(this.registerPlugins[s]=e,e.apply?.(t),Object.keys(this.lifecycle).forEach(n=>{const o=e[n];o&&this.lifecycle[n].on(o)}))}removePlugin(e){Le(e,"A name is required.");const t=this.registerPlugins[e];Le(t,`The plugin "${e}" is not registered.`),Object.keys(t).forEach(s=>{s!=="name"&&this.lifecycle[s].remove(t[s])})}};function _o(e,t){const s=no(t);s.url||ke(Ro,Oe,{remoteName:e.name});let n=ms(t,s.url);e.type=s.type,e.entryGlobalName=s.globalName,e.entry=n,e.version=t.version,e.buildVersion=t.buildVersion}function cd(){return{name:"snapshot-plugin",async afterResolve(e){const{remote:t,pkgNameOrAlias:s,expose:n,origin:o,remoteInfo:a,id:i}=e;if(!vs(t)||!ro(t)){const{remoteSnapshot:l,globalSnapshot:u}=await o.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t,id:i});_o(a,l);const d={remote:t,preloadConfig:{nameOrAlias:s,exposes:[n],resourceCategory:"sync",share:!1,depsRemote:!1}},f=await o.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:o,preloadOptions:d,remoteInfo:a,remote:t,remoteSnapshot:l,globalSnapshot:u});return f&&Io(a,o,f,!1),{...e,remoteSnapshot:l}}return e}}}function ud(e){const t=e.split(":");return t.length===1?{name:t[0],version:void 0}:t.length===2?{name:t[0],version:t[1]}:{name:t[1],version:t[2]}}function $o(e,t,s,n,o={},a){const{value:i}=Rt(e,Yt(t)),l=a||i;if(l&&!Yn(l)&&(s(l,t,n),l.remotesInfo)){const u=Object.keys(l.remotesInfo);for(const d of u){if(o[d])continue;o[d]=!0;const f=ud(d),m=l.remotesInfo[d];$o(e,{name:f.name,version:m.matchedVersion},s,!1,o,void 0)}}}var Es=(e,t)=>document.querySelector(`${e}[${e==="link"?"href":"src"}="${t}"]`);function dd(e,t,s,n,o){const a=[],i=[],l=[],u=new Set,d=new Set,{options:f}=e,{preloadConfig:m}=t,{depsRemote:g}=m;if($o(n,s,(x,v,w)=>{let y;if(w)y=m;else if(Array.isArray(g)){const E=g.find(R=>R.nameOrAlias===v.name||R.nameOrAlias===v.alias);if(!E)return;y=To(E)}else if(g===!0)y=m;else return;const S=ms(x,no(x).url);S&&l.push({name:v.name,moduleInfo:{name:v.name,entry:S,type:"remoteEntryType"in x?x.remoteEntryType:"global",entryGlobalName:"globalName"in x?x.globalName:v.name,shareScope:"",version:"version"in x?x.version:void 0},url:S});let k="modules"in x?x.modules:[];const C=id(y.exposes);C.length&&"modules"in x&&(k=x?.modules?.reduce((E,R)=>(C?.indexOf(R.moduleName)!==-1&&E.push(R),E),[]));function N(E){const R=E.map(A=>ms(x,A));return y.filter?R.filter(y.filter):R}if(k){const E=k.length;for(let R=0;R<E;R++){const A=k[R],Q=`${v.name}/${A.moduleName}`;e.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:A.moduleName==="."?v.name:Q,name:v.name,remoteSnapshot:x,preloadConfig:y,remote:v,origin:e}),!pu(Q)&&(y.resourceCategory==="all"?(a.push(...N(A.assets.css.async)),a.push(...N(A.assets.css.sync)),i.push(...N(A.assets.js.async)),i.push(...N(A.assets.js.sync))):y.resourceCategory==="sync"&&(a.push(...N(A.assets.css.sync)),i.push(...N(A.assets.js.sync))),hu(Q))}}},!0,{},o),o.shared&&o.shared.length>0){const x=(v,w)=>{const{shared:y}=Dr(e.shareScopeMap,w.sharedName,v,e.sharedHandler.hooks.lifecycle.resolveShare)||{};y&&typeof y.lib=="function"&&(w.assets.js.sync.forEach(S=>{u.add(S)}),w.assets.css.sync.forEach(S=>{d.add(S)}))};o.shared.forEach(v=>{const w=f.shared?.[v.sharedName];if(!w)return;const y=v.version?w.find(S=>S.version===v.version):w;y&&so(y).forEach(S=>{x(S,v)})})}const b=i.filter(x=>!u.has(x)&&!Es("script",x));return{cssAssets:a.filter(x=>!d.has(x)&&!Es("link",x)),jsAssetsWithoutEntry:b,entryAssets:l.filter(x=>!Es("script",x.url))}}var fd=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(e){const{origin:t,preloadOptions:s,remoteInfo:n,remote:o,globalSnapshot:a,remoteSnapshot:i}=e;return vs(o)&&ro(o)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:o.name,url:o.entry,moduleInfo:{name:n.name,entry:o.entry,type:n.type||"global",entryGlobalName:"",shareScope:""}}]}:(_o(n,i),dd(t,s,n,a,i))}}};function Go(e,t){const s=Cr({name:t.name,version:t.options.version}),n=s&&"remotesInfo"in s&&s.remotesInfo&&Rt(s.remotesInfo,e.name).value;return n&&n.matchedVersion?{hostGlobalSnapshot:s,globalSnapshot:ao(),remoteSnapshot:Cr({name:e.name,version:n.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:ao(),remoteSnapshot:Cr({name:e.name,version:"version"in e?e.version:void 0})}}var md=class{constructor(e){this.loadingHostSnapshot=null,this.manifestCache=new Map,this.hooks=new _t({beforeLoadRemoteSnapshot:new Ve("beforeLoadRemoteSnapshot"),loadSnapshot:new dt("loadGlobalSnapshot"),loadRemoteSnapshot:new dt("loadRemoteSnapshot"),afterLoadSnapshot:new dt("afterLoadSnapshot")}),this.manifestLoading=Xt.__FEDERATION__.__MANIFEST_LOADING__,this.HostInstance=e,this.loaderHook=e.loaderHook}async loadRemoteSnapshotInfo({moduleInfo:e,id:t,expose:s}){const{options:n}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:n,moduleInfo:e});let o=Cr({name:this.HostInstance.options.name,version:this.HostInstance.options.version});o||(o={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},fu({[this.HostInstance.options.name]:o})),o&&"remotesInfo"in o&&!Rt(o.remotesInfo,e.name).value&&("version"in e||"entry"in e)&&(o.remotesInfo={...o?.remotesInfo,[e.name]:{matchedVersion:"version"in e?e.version:e.entry}});const{hostGlobalSnapshot:a,remoteSnapshot:i,globalSnapshot:l}=this.getGlobalRemoteInfo(e),{remoteSnapshot:u,globalSnapshot:d}=await this.hooks.lifecycle.loadSnapshot.emit({options:n,moduleInfo:e,hostGlobalSnapshot:a,remoteSnapshot:i,globalSnapshot:l});let f,m;if(u)if(Yn(u)){const g=u.remoteEntry,b=await this.getManifestJson(g,e,{}),x=io({...e,entry:g},b);f=b,m=x}else{const{remoteSnapshot:g}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:e,remoteSnapshot:u,from:"global"});f=g,m=d}else if(vs(e)){const g=await this.getManifestJson(e.entry,e,{}),b=io(e,g),{remoteSnapshot:x}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:e,remoteSnapshot:g,from:"global"});f=x,m=b}else ke(Eo,Oe,{remoteName:e.name,remoteVersion:e.version,hostName:this.HostInstance.options.name,globalSnapshot:JSON.stringify(d)},void 0,Lt(this.HostInstance.options));return await this.hooks.lifecycle.afterLoadSnapshot.emit({id:t,host:this.HostInstance,options:n,moduleInfo:e,remoteSnapshot:f}),{remoteSnapshot:f,globalSnapshot:m}}getGlobalRemoteInfo(e){return Go(e,this.HostInstance)}async getManifestJson(e,t,s){const n=async()=>{let a=this.manifestCache.get(e);if(a)return a;try{let i=await this.loaderHook.lifecycle.fetch.emit(e,{},Lr(t));(!i||!(i instanceof Response))&&(i=await fetch(e,{})),a=await i.json()}catch(i){a=await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:e,error:i,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance}),a||(delete this.manifestLoading[e],ke(No,Oe,{manifestUrl:e,moduleName:t.name,hostName:this.HostInstance.options.name},`${i}`,Lt(this.HostInstance.options)))}return Le(a.metaData&&a.exposes&&a.shared,`"${e}" is not a valid federation manifest for remote "${t.name}". Missing required fields: ${[!a.metaData&&"metaData",!a.exposes&&"exposes",!a.shared&&"shared"].filter(Boolean).join(", ")}.`),this.manifestCache.set(e,a),a},o=async()=>{const a=await n(),i=Kc(a,{version:e}),{remoteSnapshot:l}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,manifestJson:a,remoteSnapshot:i,manifestUrl:e,from:"manifest"});return l};return this.manifestLoading[e]||(this.manifestLoading[e]=o().then(a=>a)),this.manifestLoading[e]}},pd=class{constructor(e){this.hooks=new _t({beforeRegisterShare:new Ot("beforeRegisterShare"),afterResolve:new dt("afterResolve"),beforeLoadShare:new dt("beforeLoadShare"),loadShare:new Ve,resolveShare:new Ot("resolveShare"),initContainerShareScopeMap:new Ot("initContainerShareScopeMap")}),this.host=e,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(e.options)}registerShared(e,t){const{newShareInfos:s,allShareInfos:n}=yo(e,t);return Object.keys(s).forEach(o=>{s[o].forEach(a=>{a.scope.forEach(i=>{this.hooks.lifecycle.beforeRegisterShare.emit({origin:this.host,pkgName:o,shared:a}),this.shareScopeMap[i]?.[o]||this.setShared({pkgName:o,lib:a.lib,get:a.get,loaded:a.loaded||!!a.lib,shared:a,from:t.name})})})}),{newShareInfos:s,allShareInfos:n}}async loadShare(e,t){const{host:s}=this,n=So({pkgName:e,extraOptions:t,shareInfos:s.options.shared});n?.scope&&await Promise.all(n.scope.map(async l=>{await Promise.all(this.initializeSharing(l,{strategy:n.strategy}))}));const{shareInfo:o}=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:e,shareInfo:n,shared:s.options.shared,origin:s});Le(o,`Cannot find shared "${e}" in host "${s.options.name}". Ensure the shared config for "${e}" is declared in the federation plugin options and the host has been initialized before loading shares.`);const{shared:a,useTreesShaking:i}=Dr(this.shareScopeMap,e,o,this.hooks.lifecycle.resolveShare)||{};if(a){const l=Tr(a,i);if(l.lib)return It(l,s.options.name),l.lib;if(l.loading&&!l.loaded){const u=await l.loading;return l.loaded=!0,l.lib||(l.lib=u),It(l,s.options.name),u}else{const d=(async()=>{const f=await l.get();return It(l,s.options.name),l.loaded=!0,l.lib=f,f})();return this.setShared({pkgName:e,loaded:!1,shared:a,from:s.options.name,lib:null,loading:d,treeShaking:i?l:void 0}),d}}else{if(t?.customShareInfo)return!1;const l=tr(o.treeShaking),u=Tr(o,l),f=(async()=>{const m=await u.get();u.lib=m,u.loaded=!0,It(u,s.options.name);const{shared:g,useTreesShaking:b}=Dr(this.shareScopeMap,e,o,this.hooks.lifecycle.resolveShare)||{};if(g){const x=Tr(g,b);x.lib=m,x.loaded=!0,g.from=o.from}return m})();return this.setShared({pkgName:e,loaded:!1,shared:o,from:s.options.name,lib:null,loading:f,treeShaking:l?u:void 0}),f}}initializeSharing(e=Pr,t){const{host:s}=this,n=t?.from,o=t?.strategy;let a=t?.initScope;const i=[];if(n!=="build"){const{initTokens:g}=this;a||(a=[]);let b=g[e];if(b||(b=g[e]={from:this.host.name}),a.indexOf(b)>=0)return i;a.push(b)}const l=this.shareScopeMap,u=s.options.name;l[e]||(l[e]={});const d=l[e],f=(g,b)=>{const{version:x,eager:v}=b;d[g]=d[g]||{};const w=d[g],y=w[x]&&Tr(w[x]),S=!!(y&&("eager"in y&&y.eager||"shareConfig"in y&&y.shareConfig?.eager));(!y||y.strategy!=="loaded-first"&&!y.loaded&&(!v!=!S?v:u>w[x].from))&&(w[x]=b)},m=async g=>{const{module:b}=await s.remoteHandler.getRemoteModuleAndOptions({id:g});let x;try{x=await b.getEntry()}catch(v){if(x=await s.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:g,error:v,from:"runtime",lifecycle:"beforeLoadShare",origin:s}),!x)return}finally{x?.init&&!b.initing&&(b.remoteEntryExports=x,await b.init(void 0,void 0,a))}};return Object.keys(s.options.shared).forEach(g=>{s.options.shared[g].forEach(b=>{b.scope.includes(e)&&f(g,b)})}),(s.options.shareStrategy==="version-first"||o==="version-first")&&s.options.remotes.forEach(g=>{g.shareScope===e&&i.push(m(g.name))}),i}loadShareSync(e,t){const{host:s}=this,n=So({pkgName:e,extraOptions:t,shareInfos:s.options.shared});n?.scope&&n.scope.forEach(i=>{this.initializeSharing(i,{strategy:n.strategy})});const{shared:o,useTreesShaking:a}=Dr(this.shareScopeMap,e,n,this.hooks.lifecycle.resolveShare)||{};if(o){if(typeof o.lib=="function")return It(o,s.options.name),o.loaded||(o.loaded=!0,o.from===s.options.name&&(n.loaded=!0)),o.lib;if(typeof o.get=="function"){const i=o.get();if(!(i instanceof Promise))return It(o,s.options.name),this.setShared({pkgName:e,loaded:!0,from:s.options.name,lib:i,shared:o}),i}}if(n.lib)return n.loaded||(n.loaded=!0),n.lib;if(n.get){const i=n.get();return i instanceof Promise&&ke(t?.from==="build"?Mo:Ns,Oe,{hostName:s.options.name,sharedPkgName:e},void 0,Lt(s.options)),n.lib=i,this.setShared({pkgName:e,loaded:!0,from:s.options.name,lib:n.lib,shared:n}),n.lib}ke(Ns,Oe,{hostName:s.options.name,sharedPkgName:e},void 0,Lt(s.options))}initShareScopeMap(e,t,s={}){const{host:n}=this;this.shareScopeMap[e]=t,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:t,options:n.options,origin:n,scopeName:e,hostShareScopeMap:s.hostShareScopeMap})}setShared({pkgName:e,shared:t,from:s,lib:n,loading:o,loaded:a,get:i,treeShaking:l}){const{version:u,scope:d="default",...f}=t,m=Array.isArray(d)?d:[d],g=b=>{const x=(w,y,S)=>{S&&!w[y]&&(w[y]=S)},v=l?b.treeShaking:b;x(v,"loaded",a),x(v,"loading",o),x(v,"get",i)};m.forEach(b=>{this.shareScopeMap[b]||(this.shareScopeMap[b]={}),this.shareScopeMap[b][e]||(this.shareScopeMap[b][e]={}),this.shareScopeMap[b][e][u]||(this.shareScopeMap[b][e][u]={version:u,scope:[b],...f,lib:n});const x=this.shareScopeMap[b][e][u];g(x),s&&x.from!==s&&(x.from=s)})}_setGlobalShareScopeMap(e){const t=wo(),s=e.id||e.name;s&&!t[s]&&(t[s]=this.shareScopeMap)}},hd=class{constructor(e){this.hooks=new _t({beforeRegisterRemote:new Ot("beforeRegisterRemote"),registerRemote:new Ot("registerRemote"),beforeRequest:new dt("beforeRequest"),onLoad:new Ve("onLoad"),handlePreloadModule:new Be("handlePreloadModule"),errorLoadRemote:new Ve("errorLoadRemote"),beforePreloadRemote:new Ve("beforePreloadRemote"),generatePreloadAssets:new Ve("generatePreloadAssets"),afterPreloadRemote:new Ve,loadEntry:new Ve}),this.host=e,this.idToRemoteMap={}}formatAndRegisterRemote(e,t){return(t.remotes||[]).reduce((s,n)=>(this.registerRemote(n,s,{force:!1}),s),e.remotes)}setIdToRemoteMap(e,t){const{remote:s,expose:n}=t,{name:o,alias:a}=s;if(this.idToRemoteMap[e]={name:s.name,expose:n},a&&e.startsWith(o)){const i=e.replace(o,a);this.idToRemoteMap[i]={name:s.name,expose:n};return}if(a&&e.startsWith(a)){const i=e.replace(a,o);this.idToRemoteMap[i]={name:s.name,expose:n}}}async loadRemote(e,t){const{host:s}=this;try{const{loadFactory:n=!0}=t||{loadFactory:!0},{module:o,moduleOptions:a,remoteMatchInfo:i}=await this.getRemoteModuleAndOptions({id:e}),{pkgNameOrAlias:l,remote:u,expose:d,id:f,remoteSnapshot:m}=i,g=await o.get(f,d,t,m),b=await this.hooks.lifecycle.onLoad.emit({id:f,pkgNameOrAlias:l,expose:d,exposeModule:n?g:void 0,exposeModuleFactory:n?void 0:g,remote:u,options:a,moduleInstance:o,origin:s});return this.setIdToRemoteMap(e,i),typeof b=="function"?b:g}catch(n){const{from:o="runtime"}=t||{from:"runtime"},a=await this.hooks.lifecycle.errorLoadRemote.emit({id:e,error:n,from:o,lifecycle:"onLoad",origin:s});if(!a)throw n;return a}}async preloadRemote(e){const{host:t}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:e,options:t.options,origin:t});const s=ad(t.options.remotes,e);await Promise.all(s.map(async n=>{const{remote:o}=n,a=Lr(o),{globalSnapshot:i,remoteSnapshot:l}=await t.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:o}),u=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:t,preloadOptions:n,remote:o,remoteInfo:a,globalSnapshot:i,remoteSnapshot:l});u&&Io(a,t,u)}))}registerRemotes(e,t){const{host:s}=this;e.forEach(n=>{this.registerRemote(n,s.options.remotes,{force:t?.force})})}async getRemoteModuleAndOptions(e){const{host:t}=this,{id:s}=e;let n;try{n=await this.hooks.lifecycle.beforeRequest.emit({id:s,options:t.options,origin:t})}catch(b){if(n=await this.hooks.lifecycle.errorLoadRemote.emit({id:s,options:t.options,origin:t,from:"runtime",error:b,lifecycle:"beforeRequest"}),!n)throw b}const{id:o}=n,a=Ku(t.options.remotes,o);a||ke(Co,Oe,{hostName:t.options.name,requestId:o},void 0,Lt(t.options));const{remote:i}=a,l=Lr(i),u=await t.sharedHandler.hooks.lifecycle.afterResolve.emit({id:o,...a,options:t.options,origin:t,remoteInfo:l}),{remote:d,expose:f}=u;Le(d&&f,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${o}.`);let m=t.moduleCache.get(d.name);const g={host:t,remoteInfo:l};return m||(m=new Lo(g),t.moduleCache.set(d.name,m)),{module:m,moduleOptions:g,remoteMatchInfo:u}}registerRemote(e,t,s){const{host:n}=this,o=()=>{if(e.alias){const i=t.find(l=>e.alias&&(l.name.startsWith(e.alias)||l.alias?.startsWith(e.alias)));Le(!i,`The alias ${e.alias} of remote ${e.name} is not allowed to be the prefix of ${i&&i.name} name or alias`)}"entry"in e&&typeof window<"u"&&!e.entry.startsWith("http")&&(e.entry=new URL(e.entry,window.location.origin).href),e.shareScope||(e.shareScope=Pr),e.type||(e.type=zu)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:e,origin:n});const a=t.find(i=>i.name===e.name);if(!a)o(),t.push(e),this.hooks.lifecycle.registerRemote.emit({remote:e,origin:n});else{const i=[`The remote "${e.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];s?.force&&(this.removeRemote(a),o(),t.push(e),this.hooks.lifecycle.registerRemote.emit({remote:e,origin:n}),Kn(i.join(" ")))}}removeRemote(e){try{const{host:t}=this,{name:s}=e,n=t.options.remotes.findIndex(a=>a.name===s);n!==-1&&t.options.remotes.splice(n,1);const o=t.moduleCache.get(e.name);if(o){const a=o.remoteInfo,i=a.entryGlobalName;Ne[i]&&(Object.getOwnPropertyDescriptor(Ne,i)?.configurable?delete Ne[i]:Ne[i]=void 0);const l=Ms(o.remoteInfo);Pt[l]&&delete Pt[l],t.snapshotHandler.manifestCache.delete(a.entry);let u=a.buildVersion?qn(a.name,a.buildVersion):a.name;const d=Ne.__FEDERATION__.__INSTANCES__.findIndex(m=>a.buildVersion?m.options.id===u:m.name===u);if(d!==-1){const m=Ne.__FEDERATION__.__INSTANCES__[d];u=m.options.id||u;const g=wo();let b=!0;const x=[];Object.keys(g).forEach(v=>{const w=g[v];w&&Object.keys(w).forEach(y=>{const S=w[y];S&&Object.keys(S).forEach(k=>{const C=S[k];C&&Object.keys(C).forEach(N=>{const E=C[N];E&&typeof E=="object"&&E.from===a.name&&(E.loaded||E.loading?(E.useIn=E.useIn.filter(R=>R!==a.name),E.useIn.length?b=!1:x.push([v,y,k,N])):x.push([v,y,k,N]))})})})}),b&&(m.shareScopeMap={},delete g[u]),x.forEach(([v,w,y,S])=>{delete g[v]?.[w]?.[y]?.[S]}),Ne.__FEDERATION__.__INSTANCES__.splice(d,1)}const{hostGlobalSnapshot:f}=Go(e,t);if(f){const m=f&&"remotesInfo"in f&&f.remotesInfo&&Rt(f.remotesInfo,e.name).key;m&&(delete f.remotesInfo[m],Xt.__FEDERATION__.__MANIFEST_LOADING__[m]&&delete Xt.__FEDERATION__.__MANIFEST_LOADING__[m])}t.moduleCache.delete(e.name)}}catch(t){bs.error(`removeRemote failed: ${t instanceof Error?t.message:String(t)}`)}}},gd=typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN=="boolean"?!FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN:!0,Bo=class{constructor(e){this.hooks=new _t({beforeInit:new Ot("beforeInit"),init:new Be,beforeInitContainer:new dt("beforeInitContainer"),initContainer:new dt("initContainer")}),this.version="2.4.0",this.moduleCache=new Map,this.loaderHook=new _t({getModuleInfo:new Be,createScript:new Be,createLink:new Be,fetch:new Ve,loadEntryError:new Ve,getModuleFactory:new Ve}),this.bridgeHook=new _t({beforeBridgeRender:new Be,afterBridgeRender:new Be,beforeBridgeDestroy:new Be,afterBridgeDestroy:new Be});const t=gd?[cd(),fd()]:[],s={id:sd(),name:e.name,plugins:t,remotes:[],shared:{},inBrowser:Wn};this.name=e.name,this.options=s,this.snapshotHandler=new md(this),this.sharedHandler=new pd(this),this.remoteHandler=new hd(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...s.plugins,...e.plugins||[]]),this.options=this.formatOptions(s,e)}initOptions(e){e.name&&e.name!==this.options.name&&ke(to(Po,Oe)),this.registerPlugins(e.plugins);const t=this.formatOptions(this.options,e);return this.options=t,t}async loadShare(e,t){return this.sharedHandler.loadShare(e,t)}loadShareSync(e,t){return this.sharedHandler.loadShareSync(e,t)}initializeSharing(e=Pr,t){return this.sharedHandler.initializeSharing(e,t)}initRawContainer(e,t,s){const n=Lr({name:e,entry:t}),o=new Lo({host:this,remoteInfo:n});return o.remoteEntryExports=s,this.moduleCache.set(e,o),o}async loadRemote(e,t){return this.remoteHandler.loadRemote(e,t)}async preloadRemote(e){return this.remoteHandler.preloadRemote(e)}initShareScopeMap(e,t,s={}){this.sharedHandler.initShareScopeMap(e,t,s)}formatOptions(e,t){const{allShareInfos:s}=yo(e,t),{userOptions:n,options:o}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:t,options:e,shareInfo:s}),a=this.remoteHandler.formatAndRegisterRemote(o,n),{allShareInfos:i}=this.sharedHandler.registerShared(o,n),l=[...o.plugins];n.plugins&&n.plugins.forEach(d=>{l.includes(d)||l.push(d)});const u={...e,...t,plugins:l,remotes:a,shared:i,id:n.id||e.id};return this.hooks.lifecycle.init.emit({origin:this,options:u}),u}registerPlugins(e){const t=nd(e,this);this.options.plugins=this.options.plugins.reduce((s,n)=>(n&&s&&!s.find(o=>o.name===n.name)&&s.push(n),s),t||[])}registerRemotes(e,t){return this.remoteHandler.registerRemotes(e,t)}registerShared(e){this.sharedHandler.registerShared(this.options,{...this.options,shared:e})}};function bd(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function xd(e,t){const s=bd();return Ne.__FEDERATION__.__INSTANCES__.find(n=>!!(s&&n.options.id===s||n.options.name===e&&!n.options.version&&!t||n.options.name===e&&t&&n.options.version===t))}function vd(e){const t=new(cu()||Bo)({id:`${e.name}@${e.version||Date.now()}`,...e});return lu(t),t}var We=null;function yd(e){const t=xd(e.name,e.version),s={...e,id:e.id||""};return t?(t.initOptions(s),We||(We=t),t):(We=vd(s),We)}function wd(...e){return Le(We,Cs,Oe),We.loadRemote.apply(We,e)}function Sd(...e){return Le(We,Cs,Oe),We.registerRemotes.apply(We,e)}function kd(){return We}uu(Bo);function $t(e){const t=(typeof globalThis<"u"?globalThis:void 0)?.[e];return t&&typeof t=="object"?t:{}}var jd={singleton:!0,requiredVersion:!1,eager:!0},Je=e=>({version:"0.0.0",scope:"default",lib:e,shareConfig:jd}),Fo="__mf_module_cache__";function Nd(){const e=globalThis,t=e[Fo];if(t&&typeof t=="object"){const n=t;return n.share??={},n.remote??={},n}const s={share:{},remote:{}};return e[Fo]=s,s}function Cd(){const e=Nd();e.share.react??=h,e.share["react-dom"]??=Ze,e.share["react-dom/client"]??=bt,e.share["react/jsx-runtime"]??=r,e.share["@tanstack/react-query"]??=Ae,e.share["@trpc/client"]??=Te,e.share["@trpc/react-query"]??=nt,e.share["@camstack/ui-library"]??=$t("__camstackUiLibrary"),e.share["@camstack/sdk"]??=$t("__camstackSdk"),e.share["@camstack/types"]??=$t("__camstackTypes")}function zo(){Cd(),kd()===null&&yd({name:"admin_ui_host",remotes:[],shared:{react:Je(()=>h),"react-dom":Je(()=>Ze),"react-dom/client":Je(()=>bt),"react/jsx-runtime":Je(()=>r),"@tanstack/react-query":Je(()=>Ae),"@trpc/client":Je(()=>Te),"@trpc/react-query":Je(()=>nt),"@camstack/ui-library":Je(()=>$t("__camstackUiLibrary")),"@camstack/sdk":Je(()=>$t("__camstackSdk")),"@camstack/types":Je(()=>$t("__camstackTypes"))}})}/**
37
+ * @license lucide-react v0.576.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */var Qo=(...e)=>e.filter((t,s,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===s).join(" ").trim();/**
42
+ * @license lucide-react v0.576.0 - ISC
43
+ *
44
+ * This source code is licensed under the ISC license.
45
+ * See the LICENSE file in the root directory of this source tree.
46
+ */var Md=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
47
+ * @license lucide-react v0.576.0 - ISC
48
+ *
49
+ * This source code is licensed under the ISC license.
50
+ * See the LICENSE file in the root directory of this source tree.
51
+ */var Ed=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,s,n)=>n?n.toUpperCase():s.toLowerCase());/**
52
+ * @license lucide-react v0.576.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */var Uo=e=>{const t=Ed(e);return t.charAt(0).toUpperCase()+t.slice(1)};/**
57
+ * @license lucide-react v0.576.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */var Ad={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"};/**
62
+ * @license lucide-react v0.576.0 - ISC
63
+ *
64
+ * This source code is licensed under the ISC license.
65
+ * See the LICENSE file in the root directory of this source tree.
66
+ */var Pd=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/**
67
+ * @license lucide-react v0.576.0 - ISC
68
+ *
69
+ * This source code is licensed under the ISC license.
70
+ * See the LICENSE file in the root directory of this source tree.
71
+ */var Rd=(0,h.forwardRef)(({color:e="currentColor",size:t=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:o="",children:a,iconNode:i,...l},u)=>(0,h.createElement)("svg",{ref:u,...Ad,width:t,height:t,stroke:e,strokeWidth:n?Number(s)*24/Number(t):s,className:Qo("lucide",o),...!a&&!Pd(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,f])=>(0,h.createElement)(d,f)),...Array.isArray(a)?a:[a]]));/**
72
+ * @license lucide-react v0.576.0 - ISC
73
+ *
74
+ * This source code is licensed under the ISC license.
75
+ * See the LICENSE file in the root directory of this source tree.
76
+ */var P=(e,t)=>{const s=(0,h.forwardRef)(({className:n,...o},a)=>(0,h.createElement)(Rd,{ref:a,iconNode:t,className:Qo(`lucide-${Md(Uo(e))}`,`lucide-${e}`,n),...o}));return s.displayName=Uo(e),s},ft=P("activity",[["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"}]]),Dd=P("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),Td=P("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),Id=P("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),As=P("arrow-up-to-line",[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]]),Ld=P("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),Od=P("battery-full",[["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"}]]),_d=P("battery-low",[["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"}]]),$d=P("battery-warning",[["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"}]]),Ho=P("battery",[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]]),Gd=P("bell-ring",[["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"}]]),Or=P("bell",[["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"}]]),Bd=P("bug",[["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"}]]),Ps=P("camera",[["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"}]]),Fd=P("cast",[["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"}]]),sr=P("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),St=P("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),zd=P("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),mt=P("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),_r=P("circle-alert",[["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"}]]),Qd=P("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),Ud=P("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),Hd=P("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]),Vd=P("circle-pause",[["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"}]]),Wd=P("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),Vo=P("circle-question-mark",[["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"}]]),qd=P("circle-x",[["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"}]]),Kd=P("copy-plus",[["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"}]]),pt=P("copy",[["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"}]]),Zd=P("cpu",[["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"}]]),Wo=P("crosshair",[["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"}]]),Yd=P("database",[["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"}]]),qo=P("door-open",[["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"}]]),Rs=P("download",[["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"}]]),Ko=P("ellipsis-vertical",[["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"}]]),Zo=P("external-link",[["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"}]]),Yo=P("eye-off",[["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"}]]),nr=P("eye",[["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"}]]),Xo=P("funnel",[["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"}]]),Xd=P("grip-horizontal",[["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"}]]),Jo=P("house",[["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"}]]),Jd=P("image",[["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"}]]),ef=P("inbox",[["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"}]]),tf=P("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),rf=P("layout-grid",[["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"}]]),ea=P("lightbulb",[["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"}]]),qe=P("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),sf=P("locate-fixed",[["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"}]]),ta=P("maximize-2",[["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"}]]),nf=P("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]),ra=P("mic",[["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"}]]),sa=P("minimize-2",[["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"}]]),na=P("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),Ds=P("moon",[["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"}]]),of=P("music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]),Ts=P("network",[["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"}]]),af=P("pencil",[["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"}]]),Is=P("play",[["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"}]]),or=P("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),lf=P("plug",[["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"}]]),cf=P("power-off",[["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"}]]),oa=P("radar",[["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"}]]),uf=P("radio",[["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"}]]),Ls=P("refresh-cw",[["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"}]]),aa=P("rotate-ccw",[["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"}]]),ia=P("rotate-cw",[["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"}]]),df=P("save",[["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"}]]),ff=P("scan",[["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"}]]),mf=P("scroll-text",[["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"}]]),ar=P("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),pf=P("server",[["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"}]]),hf=P("shield",[["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"}]]),gf=P("ship",[["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"}]]),bf=P("sliders-horizontal",[["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"}]]),la=P("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),xf=P("star",[["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"}]]),ca=P("sun",[["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"}]]),vf=P("table-2",[["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"}]]),ua=P("target",[["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"}]]),yf=P("thermometer",[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]]),wf=P("toggle-left",[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]]),et=P("trash-2",[["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"}]]),Sf=P("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]]),kf=P("trending-down",[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]]),ir=P("triangle-alert",[["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"}]]),da=P("upload",[["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"}]]),jf=P("wifi-off",[["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"}]]),fa=P("wifi",[["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"}]]),Os=P("wrench",[["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"}]]),Ee=P("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),ma=P("zap",[["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"}]]),Nf=P("zoom-in",[["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"}]]),Cf=P("zoom-out",[["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"}]]),Mf={frigate:gf,scrypted:hf,reolink:uf,homeAssistant:Jo,rtsp:Fd},Ef={online:Ud,offline:qd,degraded:_r,unknown:Vo},pa=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,ha=Wt,kt=(e,t)=>s=>{var n;if(t?.variants==null)return ha(e,s?.class,s?.className);const{variants:o,defaultVariants:a}=t,i=Object.keys(o).map(u=>{const d=s?.[u],f=a?.[u];if(d===null)return null;const m=pa(d)||pa(f);return o[u][m]}),l=s&&Object.entries(s).reduce((u,d)=>{let[f,m]=d;return m===void 0||(u[f]=m),u},{});return ha(e,i,t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,d)=>{let{class:f,className:m,...g}=d;return Object.entries(g).every(b=>{let[x,v]=b;return Array.isArray(v)?v.includes({...a,...l}[x]):{...a,...l}[x]===v})?[...u,f,m]:u},[]),s?.class,s?.className)},Af=kt("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"}}),lr=(0,h.forwardRef)(({className:e,variant:t,size:s,...n},o)=>(0,r.jsx)("button",{ref:o,className:j(Af({variant:t,size:s}),e),...n}));lr.displayName="Button";var Pf=kt("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"}}),_s=(0,h.forwardRef)(({className:e,variant:t,size:s,icon:n,...o},a)=>(0,r.jsx)("button",{ref:a,className:j(Pf({variant:t,size:s}),e),...o,children:(0,r.jsx)(n,{className:"h-4 w-4"})}));_s.displayName="IconButton";var Rf=kt("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"}}),Gt=(0,h.forwardRef)(({className:e,variant:t,style:s,...n},o)=>(0,r.jsx)("span",{ref:o,className:j(Rf({variant:t,styleVariant:s}),e),...n}));Gt.displayName="Badge";var Df=kt("rounded-lg p-3",{variants:{variant:{flat:"bg-surface",bordered:"bg-surface border border-border"}},defaultVariants:{variant:"bordered"}}),$s=(0,h.forwardRef)(({className:e,variant:t,...s},n)=>(0,r.jsx)("div",{ref:n,className:j(Df({variant:t}),e),...s}));$s.displayName="Card";function ga({expanded:e,onExpandedChange:t,header:s,children:n,dimmed:o=!1,hideChevron:a=!1,className:i}){return(0,r.jsxs)("div",{className:j("rounded-lg border border-border bg-surface overflow-hidden",o&&"opacity-[0.45]",i),children:[(0,r.jsxs)("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&&(0,r.jsx)("span",{className:"text-foreground-subtle shrink-0",children:e?(0,r.jsx)(St,{className:"h-4 w-4"}):(0,r.jsx)(mt,{className:"h-4 w-4"})}),s]}),e&&n&&(0,r.jsx)("div",{className:"border-t border-border px-3 py-3",children:n})]})}var Gs=(0,h.forwardRef)(({className:e,...t},s)=>(0,r.jsx)("label",{ref:s,className:j("text-[10px] uppercase tracking-wider text-foreground-muted font-medium",e),...t}));Gs.displayName="Label";var Tf=kt("",{variants:{orientation:{horizontal:"h-px w-full bg-border-subtle",vertical:"w-px h-full bg-border-subtle"}},defaultVariants:{orientation:"horizontal"}}),Bs=(0,h.forwardRef)(({className:e,orientation:t,...s},n)=>(0,r.jsx)("div",{ref:n,role:"separator",className:j(Tf({orientation:t}),e),...s}));Bs.displayName="Separator";var ba=(0,h.forwardRef)(({className:e,...t},s)=>(0,r.jsx)("div",{ref:s,className:j("animate-pulse bg-surface-hover rounded-md h-4 w-full",e),...t}));ba.displayName="Skeleton";var xa=kt("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"}}),$r=(0,h.forwardRef)(({className:e,state:t,leftSlot:s,rightSlot:n,...o},a)=>s||n?(0,r.jsxs)("div",{className:"relative flex items-center w-full",children:[s&&(0,r.jsx)("div",{className:"absolute left-2.5 flex items-center pointer-events-none",children:s}),(0,r.jsx)("input",{ref:a,className:j(xa({state:t}),s?"pl-7":"",n?"pr-7":"",e),...o}),n&&(0,r.jsx)("div",{className:"absolute right-2.5 flex items-center pointer-events-none",children:n})]}):(0,r.jsx)("input",{ref:a,className:j(xa({state:t}),e),...o}));$r.displayName="Input";var Gr=(0,h.forwardRef)(({className:e,options:t,...s},n)=>(0,r.jsxs)("div",{className:"relative w-full",children:[(0,r.jsx)("select",{ref:n,className:j("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),...s,children:t.map(o=>(0,r.jsx)("option",{value:o.value,children:o.label},o.value))}),(0,r.jsx)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none text-foreground-muted",children:(0,r.jsx)(St,{className:"h-3.5 w-3.5"})})]}));Gr.displayName="Select";var va=(0,h.forwardRef)(({className:e,...t},s)=>(0,r.jsx)("input",{ref:s,type:"checkbox",className:j("w-3.5 h-3.5 rounded-sm border border-border accent-primary",e),...t}));va.displayName="Checkbox";var ya=(0,h.forwardRef)(({className:e,checked:t,onCheckedChange:s,label:n,...o},a)=>(0,r.jsxs)("button",{ref:a,role:"switch","aria-checked":t,type:"button",onClick:()=>s(!t),className:j("inline-flex items-center gap-2",e),...o,children:[(0,r.jsx)("span",{className:j("w-8 h-4 rounded-full transition-colors",t?"bg-primary":"bg-surface-hover"),children:(0,r.jsx)("span",{className:j("block w-3.5 h-3.5 rounded-full bg-white transition-transform",t?"translate-x-4":"translate-x-0.5")})}),n&&(0,r.jsx)("span",{className:"text-xs text-foreground",children:n})]}));ya.displayName="Switch";var wa=(0,h.createContext)(null);function Sa(){const e=(0,h.useContext)(wa);if(!e)throw new Error("Dialog compound components must be used within <Dialog>");return e}function ka({children:e,open:t,onOpenChange:s}){const[n,o]=(0,h.useState)(!1),a=t??n,i=(0,h.useId)(),l=(0,h.useCallback)(u=>{s?.(u),t===void 0&&o(u)},[t,s]);return(0,r.jsx)(wa.Provider,{value:{open:a,setOpen:l,contentId:i},children:e})}function If({children:e,...t}){const{setOpen:s}=Sa();return(0,r.jsx)("button",{type:"button",onClick:()=>s(!0),...t,children:e})}var Lf=kt("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"}}),Fs=(0,h.forwardRef)(({className:e,width:t,children:s,...n},o)=>{const{open:a,setOpen:i,contentId:l}=Sa(),u=(0,h.useRef)(null),d=o??u;(0,h.useEffect)(()=>{const m=d.current;m&&(a&&!m.open&&m.showModal(),!a&&m.open&&m.close())},[a,d]);const f=m=>{m.target===m.currentTarget&&i(!1)};return(0,r.jsx)("dialog",{ref:d,id:l,className:j(Lf({width:t}),"w-full",e),onClick:f,onClose:()=>i(!1),...n,children:s})});Fs.displayName="DialogContent";function ja({className:e,...t}){return(0,r.jsx)("div",{className:j("flex flex-col gap-1 mb-3",e),...t})}function Na({className:e,...t}){return(0,r.jsx)("div",{className:j("flex justify-end gap-2 mt-4",e),...t})}function Ca({className:e,...t}){return(0,r.jsx)("h2",{className:j("text-sm font-semibold text-foreground",e),...t})}function Ma({className:e,...t}){return(0,r.jsx)("p",{className:j("text-xs text-foreground-muted",e),...t})}var Ea=(0,h.createContext)(null);function zs(){const e=(0,h.useContext)(Ea);if(!e)throw new Error("Dropdown compound components must be used within <Dropdown>");return e}function Of({children:e}){const[t,s]=(0,h.useState)(!1),n=(0,h.useId)(),o=(0,h.useId)(),a=(0,h.useRef)(null);return(0,r.jsx)(Ea.Provider,{value:{open:t,setOpen:s,triggerId:n,contentId:o,triggerRef:a},children:(0,r.jsx)("div",{className:"relative inline-block",children:e})})}function _f({children:e,...t}){const{open:s,setOpen:n,triggerId:o,contentId:a,triggerRef:i}=zs();return(0,r.jsx)("button",{type:"button",ref:i,id:o,"aria-haspopup":"menu","aria-expanded":s,"aria-controls":s?a:void 0,onClick:()=>n(!s),...t,children:e})}function $f({className:e,children:t,align:s="start",offset:n=4,...o}){const{open:a,setOpen:i,contentId:l,triggerId:u,triggerRef:d}=zs(),f=(0,h.useRef)(null),[m,g]=(0,h.useState)(null);return(0,h.useLayoutEffect)(()=>{if(!a){g(null);return}const b=()=>{const x=d.current;if(!x)return;const v=x.getBoundingClientRect(),w=s==="end"?v.right:v.left;g({top:v.bottom+n,left:w,minWidth:v.width})};return b(),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),()=>{window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0)}},[a,s,n,d]),(0,h.useEffect)(()=>{if(!a)return;const b=v=>{const w=f.current,y=d.current;w&&!w.contains(v.target)&&!y?.contains(v.target)&&i(!1)},x=v=>{v.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",x)}},[a,i,d]),!a||!m||typeof document>"u"?null:(0,Ze.createPortal)((0,r.jsx)("div",{ref:f,id:l,role:"menu","aria-labelledby":u,style:{position:"fixed",top:m.top,...s==="end"?{right:window.innerWidth-m.left}:{left:m.left},minWidth:m.minWidth},className:j("z-50 bg-background-elevated border border-border rounded-md shadow-lg py-1 min-w-[160px]",e),...o,children:t}),document.body)}function Gf({className:e,icon:t,variant:s="default",children:n,onClick:o,...a}){const{setOpen:i}=zs(),l=(0,h.useCallback)(u=>{o?.(u),i(!1)},[o,i]);return(0,r.jsxs)("button",{type:"button",role:"menuitem",className:j("h-7 text-xs px-2 w-full text-left flex items-center gap-2",s==="danger"?"text-danger hover:bg-danger/10":"text-foreground hover:bg-surface-hover",e),onClick:l,...a,children:[t&&(0,r.jsx)(t,{size:14}),n]})}var Aa=(0,h.createContext)(null);function Pa(){const e=(0,h.useContext)(Aa);if(!e)throw new Error("Tooltip compound components must be used within <Tooltip>");return e}function Bf({children:e}){const[t,s]=(0,h.useState)(!1),n=(0,h.useRef)(null),o=(0,h.useId)(),a=()=>{n.current=setTimeout(()=>s(!0),300)},i=()=>{n.current&&clearTimeout(n.current),s(!1)};return(0,r.jsx)(Aa.Provider,{value:{open:t,show:a,hide:i,tooltipId:o},children:(0,r.jsx)("div",{className:"relative inline-block",children:e})})}function Ff({children:e,...t}){const{show:s,hide:n,tooltipId:o,open:a}=Pa();return(0,r.jsx)("div",{onMouseEnter:s,onMouseLeave:n,onFocus:s,onBlur:n,"aria-describedby":a?o:void 0,...t,children:e})}function zf({className:e,children:t,...s}){const{open:n,tooltipId:o}=Pa();return(0,r.jsx)("div",{id:o,role:"tooltip",className:j("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",n?"opacity-100":"opacity-0",e),...s,children:t})}var Ra="(max-width: 767px)",Da="(min-width: 768px) and (max-width: 1023px)";function Ta(e){return t=>{const s=window.matchMedia(e);return s.addEventListener("change",t),()=>s.removeEventListener("change",t)}}function Ia(e){return()=>window.matchMedia(e).matches}function La(){return!1}function cr(){return(0,h.useSyncExternalStore)(Ta(Ra),Ia(Ra),La)}function Qf(){return(0,h.useSyncExternalStore)(Ta(Da),Ia(Da),La)}function Qs({open:e,onClose:t,title:s,children:n,className:o}){return(0,h.useEffect)(()=>{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]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:j("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"}),(0,r.jsxs)("div",{role:"dialog","aria-modal":"true",className:j("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",o),children:[(0,r.jsx)("div",{className:"flex justify-center pt-2 pb-1",children:(0,r.jsx)("div",{className:"h-1 w-8 rounded-full bg-foreground-subtle/30"})}),s&&(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 pb-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:s}),(0,r.jsx)("button",{onClick:t,className:"p-1 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors",children:(0,r.jsx)(Ee,{className:"h-4 w-4"})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:n})]})]})}var Oa=(0,h.createContext)(null);function _a(){const e=(0,h.useContext)(Oa);if(!e)throw new Error("Popover compound components must be used within <Popover>");return e}function $a({children:e,open:t,onOpenChange:s}){const[n,o]=(0,h.useState)(!1),a=t??n,i=(0,h.useId)(),l=(0,h.useId)(),u=(0,h.useCallback)(d=>{s?.(d),t===void 0&&o(d)},[t,s]);return(0,r.jsx)(Oa.Provider,{value:{open:a,setOpen:u,triggerId:i,contentId:l},children:(0,r.jsx)("div",{className:"relative inline-block",children:e})})}function Ga({children:e,...t}){const{open:s,setOpen:n,triggerId:o,contentId:a}=_a();return(0,r.jsx)("button",{type:"button",id:o,"aria-haspopup":"dialog","aria-expanded":s,"aria-controls":s?a:void 0,onClick:()=>n(!s),...t,children:e})}function Ba({className:e,children:t,...s}){const{open:n,setOpen:o,contentId:a,triggerId:i}=_a(),l=cr(),u=(0,h.useRef)(null);return(0,h.useEffect)(()=>{if(!n||l)return;const d=m=>{const g=u.current,b=document.getElementById(i);g&&!g.contains(m.target)&&!b?.contains(m.target)&&o(!1)},f=m=>{m.key==="Escape"&&o(!1)};return document.addEventListener("mousedown",d),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",f)}},[n,o,i,l]),n?l?(0,r.jsx)(Qs,{open:n,onClose:()=>o(!1),children:t}):(0,r.jsx)("div",{ref:u,id:a,role:"dialog","aria-labelledby":i,className:j("absolute left-0 top-full z-50 mt-1 bg-background-elevated border border-border rounded-lg shadow-lg p-3",e),...s,children:t}):null}var Fa=(0,h.createContext)(null);function za(){const e=(0,h.useContext)(Fa);if(!e)throw new Error("Tabs compound components must be used within <Tabs>");return e}function Uf({value:e,onValueChange:t,defaultValue:s="",className:n,...o}){const[a,i]=(0,h.useState)(s),l=e??a,u=(0,h.useCallback)(d=>{t?.(d),e===void 0&&i(d)},[e,t]);return(0,r.jsx)(Fa.Provider,{value:{value:l,setValue:u},children:(0,r.jsx)("div",{className:n,...o})})}function Hf({className:e,...t}){return(0,r.jsx)("div",{role:"tablist",className:j("flex flex-row border-b border-border-subtle",e),...t})}function Vf({value:e,className:t,...s}){const{value:n,setValue:o}=za(),a=e===n;return(0,r.jsx)("button",{type:"button",role:"tab","aria-selected":a,"aria-controls":`tabpanel-${e}`,tabIndex:a?0:-1,className:j("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:()=>o(e),...s})}function Wf({value:e,className:t,...s}){const{value:n}=za();return e!==n?null:(0,r.jsx)("div",{role:"tabpanel",id:`tabpanel-${e}`,className:j("pt-3",t),...s})}var Us=(0,h.forwardRef)(({className:e,...t},s)=>(0,r.jsx)("div",{ref:s,className:j("overflow-auto [&::-webkit-scrollbar]:w-1 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-surface-hover [&::-webkit-scrollbar-thumb]:rounded-full",e),...t}));Us.displayName="ScrollArea";function qf({title:e,onClose:t,children:s,defaultWidth:n=360,defaultHeight:o=280,minWidth:a=280,minHeight:i=160,offsetIndex:l=0,className:u}){const[d,f]=(0,h.useState)({x:80+l*30,y:80+l*30}),[m,g]=(0,h.useState)({w:n,h:o}),[b,x]=(0,h.useState)(!1),v=(0,h.useRef)(!1),w=(0,h.useRef)(!1),y=(0,h.useRef)({x:0,y:0}),S=cr(),k=(0,h.useCallback)(N=>{N.preventDefault(),v.current=!0,y.current={x:N.clientX-d.x,y:N.clientY-d.y}},[d]),C=(0,h.useCallback)(N=>{N.preventDefault(),N.stopPropagation(),w.current=!0,y.current={x:N.clientX,y:N.clientY}},[]);return(0,h.useEffect)(()=>{const N=R=>{if(v.current&&f({x:R.clientX-y.current.x,y:R.clientY-y.current.y}),w.current){const A=R.clientX-y.current.x,Q=R.clientY-y.current.y;y.current={x:R.clientX,y:R.clientY},g(ee=>({w:Math.max(a,ee.w+A),h:Math.max(i,ee.h+Q)}))}},E=()=>{v.current=!1,w.current=!1};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",E),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",E)}},[a,i]),S?(0,r.jsxs)("div",{className:j("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",u),style:{maxHeight:"60dvh"},children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border shrink-0 bg-surface",children:[(0,r.jsx)("span",{className:"text-[11px] font-medium truncate",children:e}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)("button",{onClick:()=>x(!b),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",children:b?(0,r.jsx)(ta,{size:12}):(0,r.jsx)(sa,{size:12})}),(0,r.jsx)("button",{onClick:t,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",children:(0,r.jsx)(Ee,{size:12})})]})]}),!b&&(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:s})]}):(0,r.jsxs)("div",{className:j("fixed z-50 rounded-lg border border-border bg-background-elevated shadow-2xl flex flex-col overflow-hidden",u),style:{left:d.x,top:d.y,width:b?280:m.w,height:b?"auto":m.h},children:[(0,r.jsxs)("div",{onMouseDown:k,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:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)(Xd,{size:12,className:"text-foreground-subtle shrink-0"}),(0,r.jsx)("span",{className:"text-[11px] font-medium truncate",children:e})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)("button",{onClick:()=>x(!b),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",title:b?"Restore":"Minimize",children:b?(0,r.jsx)(ta,{size:12}):(0,r.jsx)(sa,{size:12})}),(0,r.jsx)("button",{onClick:t,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",title:"Close",children:(0,r.jsx)(Ee,{size:12})})]})]}),!b&&(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto relative",children:[s,(0,r.jsx)("div",{onMouseDown:C,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 Qa({open:e,onClose:t,children:s,className:n,width:o="w-64"}){const a=(0,h.useRef)(null);return(0,h.useEffect)(()=>{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]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:j("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"}),(0,r.jsx)("div",{ref:a,role:"dialog","aria-modal":"true",className:j("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",o,e?"translate-x-0":"-translate-x-full",n),children:s})]})}function Kf({items:e,className:t}){return(0,r.jsx)("nav",{className:`flex items-center gap-1 text-[11px] text-foreground-subtle ${t??""}`,children:e.map((s,n)=>{const o=n===e.length-1,a=!o&&(s.onClick||s.href);return(0,r.jsxs)(h.default.Fragment,{children:[n>0&&(0,r.jsx)(mt,{className:"h-3 w-3 flex-shrink-0"}),a?s.onClick?(0,r.jsx)("button",{type:"button",onClick:s.onClick,className:"hover:text-foreground transition-colors",children:s.label}):(0,r.jsx)("a",{href:s.href,className:"hover:text-foreground transition-colors",children:s.label}):(0,r.jsx)("span",{className:o?"text-foreground font-medium":"",children:s.label})]},n)})})}var Ua={left:"text-left",right:"text-right",center:"text-center"};function Zf({columns:e,rows:t,rowKey:s,onRowClick:n,minWidthPx:o=480,emptyMessage:a,className:i,bordered:l=!0,rowClassName:u}){return t.length===0&&a?(0,r.jsx)("div",{className:`rounded-lg ${l?"border border-border":""} bg-surface px-3 py-4 text-xs text-foreground-subtle text-center ${i??""}`,children:a}):t.length===0?null:(0,r.jsx)("div",{className:`rounded-lg ${l?"border border-border":""} bg-surface overflow-x-auto ${i??""}`,children:(0,r.jsxs)("table",{className:"w-full text-xs",style:{minWidth:`${o}px`},children:[(0,r.jsx)("thead",{className:"bg-surface",children:(0,r.jsx)("tr",{children:e.map(d=>{const f=d.align??"left",m=d.nowrap??!0;return(0,r.jsx)("th",{className:["px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border",Ua[f],m?"whitespace-nowrap":"",d.width??""].filter(Boolean).join(" "),children:d.headerRender?d.headerRender():d.header},d.key)})})}),(0,r.jsx)("tbody",{children:t.map((d,f)=>{const m=s?s(d,f):f,g=u?.(d,f)??"",b=n!==void 0;return(0,r.jsx)("tr",{onClick:b?()=>n(d,f):void 0,className:[b?"cursor-pointer hover:bg-primary/5":"hover:bg-primary/5",g].filter(Boolean).join(" "),children:e.map(x=>{const v=x.align??"left",w=x.nowrap??!1;return(0,r.jsx)("td",{className:["px-3 py-2 text-foreground border-b border-border",Ua[v],w?"whitespace-nowrap":""].filter(Boolean).join(" "),children:x.render(d,f)},x.key)})},m)})})]})})}function Yf({open:e,onClose:t,title:s,subtitle:n,footer:o,children:a,widthClass:i="w-[360px]"}){return(0,h.useEffect)(()=>{if(!e)return;const l=u=>{u.key==="Escape"&&t()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e,t]),e?(0,r.jsxs)("aside",{className:j("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:[(0,r.jsxs)("header",{className:"flex items-start justify-between gap-2 px-4 py-3 border-b border-border",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("div",{className:"text-sm font-semibold text-foreground truncate",children:s}),n!==void 0&&(0,r.jsx)("div",{className:"text-[11px] text-foreground-subtle mt-0.5 truncate",children:n})]}),(0,r.jsx)("button",{type:"button",onClick:t,className:"p-1 rounded hover:bg-muted text-foreground-subtle hover:text-foreground","aria-label":"Close panel",children:(0,r.jsx)(Ee,{className:"w-4 h-4"})})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-3",children:a}),o!==void 0&&(0,r.jsx)("footer",{className:"flex items-center gap-2 justify-end px-4 py-3 border-t border-border",children:o})]}):null}var Xf={inherit:"bg-muted",on:"bg-emerald-500",off:"bg-orange-500",na:"bg-gray-300 opacity-50"};function Ha({node:e,depth:t,selectedAddonId:s,onSelect:n,agentDots:o}){const a=e.addonId===s,i=o?.[e.addonId]??[];return(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{type:"button",onClick:()=>n(e.addonId),className:j("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:[(0,r.jsx)("span",{className:"truncate",children:e.addonName}),i.length>0&&(0,r.jsx)("span",{className:"flex items-center gap-1 shrink-0",children:i.map(l=>(0,r.jsx)("span",{title:`${l.agentNodeId}: ${l.state}`,className:j("w-2 h-2 rounded-full",Xf[l.state])},l.agentNodeId))})]}),e.children.map(l=>(0,r.jsx)(Ha,{node:l,depth:t+1,selectedAddonId:s,onSelect:n,agentDots:o},l.addonId))]})}function Jf({tree:e,selectedAddonId:t,onSelect:s,agentDots:n,className:o}){return(0,r.jsx)("div",{className:j("flex flex-col py-2",o),children:e.map(a=>(0,r.jsx)(Ha,{node:a,depth:0,selectedAddonId:t,onSelect:s,agentDots:n},a.addonId))})}function em(e){const t=[],s=[],n=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):(s.push(l),n.set(i.id,l))}const o=[];for(const a of s){if(a.inputClasses.length===0){o.push(a);continue}const i=s.find(l=>l.addonId!==a.addonId&&l.outputClasses.some(u=>a.inputClasses.includes(u)));i&&i.children.push(a)}return[...o,...t]}function tm(e){return e?e.models.map(t=>({id:t.id,name:t.name})):[]}function Br({step:e,schema:t,allSchemas:s,depth:n=0,onChange:o,onDelete:a,readOnly:i=!1,toggleMode:l="simple",overrideState:u=null,onOverrideChange:d,inheritedEnabled:f,hideModelAndSettings:m=!1}){const[g,b]=(0,h.useState)(!1),x=tm(t);if(x.length>0&&!x.some(w=>w.id===e.modelId)&&!i){const w=(t?.defaultModelId?x.find(y=>y.id===t.defaultModelId):null)??x[0];w&&w.id!==e.modelId&&queueMicrotask(()=>o({...e,modelId:w.id}))}const v=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-wider font-medium text-foreground-subtle/60 block leading-none",children:e.slot}),(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground truncate block leading-tight",children:e.addonName}),(0,r.jsxs)("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(w=>(0,r.jsx)("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-blue-500/12 text-blue-400",children:w},w)),e.inputClasses.length>0&&e.outputClasses.length>0&&(0,r.jsx)("span",{className:"text-foreground-subtle/40 text-[10px]",children:"→"}),e.outputClasses.map(w=>(0,r.jsx)("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-green-500/12 text-green-400",children:w},w))]})]}),!i&&l==="simple"&&(0,r.jsx)("button",{onClick:w=>{w.stopPropagation(),o({...e,enabled:!e.enabled})},className:j("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors",e.enabled?"bg-success":"bg-foreground-subtle/30"),children:(0,r.jsx)("span",{className:j("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&&(0,r.jsxs)("div",{className:"flex items-center gap-0.5 rounded-md border border-border p-0.5",onClick:w=>w.stopPropagation(),children:[(0,r.jsx)(Vs,{label:"Inherit",active:u===null,variant:"inherit",subtext:f===void 0?void 0:f?"on":"off",onClick:()=>d(null)}),(0,r.jsx)(Vs,{label:"On",active:u===!0,variant:"on",onClick:()=>d(!0)}),(0,r.jsx)(Vs,{label:"Off",active:u===!1,variant:"off",onClick:()=>d(!1)})]})]});return(0,r.jsx)(ga,{expanded:g,onExpandedChange:b,dimmed:!e.enabled,header:v,children:m?(0,r.jsx)("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."}):(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(Hs,{label:"Model",value:e.modelId,disabled:i,options:x.map(w=>({value:w.id,label:w.name})),onChange:w=>o({...e,modelId:w})}),e.slot==="audio-classifier"&&e.engine&&(0,r.jsx)(Hs,{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:w=>{const[y,S]=w.split("/");o({...e,engine:{runtime:y,backend:S,format:S==="coreml"?"coreml":"onnx"}})}}),t?.configSchema?.map(w=>(0,r.jsx)(Fr,{field:w,allFields:t.configSchema??[],step:e,disabled:i,onChange:o},w.key))]})})}function Hs({label:e,value:t,options:s,disabled:n,onChange:o}){return(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e}),(0,r.jsxs)("select",{value:t,onChange:a=>o(a.target.value),disabled:n,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:[s.length===0&&(0,r.jsx)("option",{value:t,children:t||"default"}),s.map(a=>(0,r.jsx)("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]})]})}function rm({label:e,description:t,value:s,options:n,disabled:o,onChange:a}){function i(l){o||a(s.includes(l)?s.filter(u=>u!==l):[...s,l])}return(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1",children:e}),t&&(0,r.jsx)("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:t}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:n.map(l=>(0,r.jsx)("button",{type:"button",disabled:o,onClick:()=>i(l.value),className:j("text-[10px] font-medium px-2 py-1 rounded-md border transition-colors",s.includes(l.value)?"bg-primary/20 text-primary border-primary/40":"bg-surface text-foreground-subtle border-border hover:border-primary/30",o&&"opacity-50 cursor-not-allowed"),children:l.label},l.value))})]})}function sm(e,t,s){const n=t.settings?.[e];if(n!==void 0)return n;const o=s.find(a=>"key"in a&&a.key===e);return o&&"default"in o?o.default:void 0}function Fr({field:e,allFields:t,step:s,disabled:n,onChange:o}){const a=e.type!=="separator"&&e.type!=="info"?e.showWhen:void 0;if(a){const{field:l,equals:u,notEquals:d,in:f,notIn:m}=a,g=sm(l,s,t);if(u!==void 0&&g!==u||d!==void 0&&g===d||f!==void 0&&!f.includes(g)||m!==void 0&&m.includes(g))return null}function i(l){o({...s,settings:{...s.settings,[e.key]:l}})}if(e.type==="select"){const l=s.settings?.[e.key],u=typeof l=="string"?l:e.default??"";return(0,r.jsx)(Hs,{label:e.label,value:u,disabled:n||e.disabled,options:e.options,onChange:i})}if(e.type==="multiselect"){const l=s.settings?.[e.key],u=Array.isArray(l)?l:Array.isArray(e.default)?e.default:[];return(0,r.jsx)(rm,{label:e.label,description:e.description,value:u,options:e.options,disabled:n||e.disabled,onChange:i})}if(e.type==="slider"||e.type==="number"){const l=s.settings?.[e.key],u=typeof e.default=="number"?e.default:e.min??0,d=typeof l=="number"?l:u,f=e.min??0,m=e.max??1,g=e.step??.01,b=e.type==="slider"?e.showValue:!0,x="unit"in e?e.unit:void 0,v=e.type==="slider"?e.displayScale:void 0,w=v?d/v:d;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,r.jsx)("span",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide",children:e.label}),b&&(0,r.jsxs)("span",{className:"text-xs font-medium text-foreground tabular-nums",children:[typeof w=="number"?w.toFixed(2).replace(/\.?0+$/,""):w,x?` ${x}`:""]})]}),e.description&&(0,r.jsx)("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:e.description}),(0,r.jsx)("input",{type:"range",min:f,max:m,step:g,value:d,disabled:n||e.disabled,onChange:y=>i(Number(y.target.value)),className:"w-full accent-primary h-1.5"})]})}if(e.type==="boolean"){const l=s.settings?.[e.key];return(0,r.jsxs)("label",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"checkbox",checked:typeof l=="boolean"?l:e.default===!0,disabled:n||e.disabled,onChange:u=>i(u.target.checked),className:"h-3.5 w-3.5 accent-primary"}),(0,r.jsx)("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=s.settings?.[e.key],u=typeof l=="string"?l:e.default??"",d=e.type==="password"?"password":"text";return(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e.label}),e.type==="textarea"?(0,r.jsx)("textarea",{value:u,disabled:n||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"}):(0,r.jsx)("input",{type:d,value:u,disabled:n||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"?(0,r.jsx)("div",{className:"border-t border-border my-2"}):e.type==="info"?(0,r.jsx)("div",{className:"rounded-md border border-border bg-surface px-2 py-1.5 text-[10px] text-foreground-subtle",children:e.content}):null}function Vs({label:e,active:t,variant:s,subtext:n,onClick:o}){return(0,r.jsxs)("button",{type:"button",onClick:o,className:j("px-2 py-1 text-[10px] font-medium rounded transition-colors",t?s==="on"?"bg-green-500/20 text-green-400":s==="off"?"bg-red-500/20 text-red-400":"bg-primary/20 text-primary":"text-foreground-subtle hover:bg-surface-hover"),children:[e,n&&t&&(0,r.jsxs)("span",{className:"ml-1 opacity-60",children:["(",n,")"]})]})}function Va(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 nm(e,t,s){return s?{enabled:s.enabled??t.enabled,modelId:s.modelId??t.modelId,settings:s.settings??t.settings}:t}function om({addon:e,agentDefault:t,modelsForFormat:s,onChangeAgentConfig:n}){const o=a=>{n?.({...t,...a})};return(0,r.jsxs)("div",{className:"space-y-4 text-xs",children:[(0,r.jsxs)("label",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"checkbox",checked:t.enabled,onChange:a=>o({enabled:a.target.checked})}),(0,r.jsxs)("span",{children:["Enabled on this agent (",e.name,")"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle mb-1",children:"Model"}),(0,r.jsx)("select",{className:"w-full bg-surface border border-border rounded px-2 py-1 text-xs",value:t.modelId,onChange:a=>o({modelId:a.target.value}),children:s.map(a=>(0,r.jsx)("option",{value:a.id,children:a.name},a.id))})]}),(e.configSchema?.length??0)>0&&(0,r.jsxs)("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[(0,r.jsx)("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),e.configSchema?.map(a=>(0,r.jsx)(Fr,{field:a,allFields:e.configSchema??[],step:Va(e,t),disabled:!1,onChange:i=>o({settings:{...i.settings}})},a.key))]})]})}function am({addon:e,agentDefault:t,agentNodeId:s,currentPatch:n,modelsForFormat:o,onChangePatch:a}){const i=nm("device",t,n),l=b=>{const x=b.enabled!==void 0||b.modelId!==void 0||b.settings!==void 0;a?.(x?b:null)},u=b=>{const{enabled:x,...v}=n??{};l(b==="inherit"?v:{...v,enabled:b==="on"})},d=b=>{const{modelId:x,...v}=n??{};l(b===void 0?v:{...v,modelId:b})},f=b=>{const{settings:x,...v}=n??{};l(b===void 0?v:{...v,settings:b})},m=n?.enabled===void 0?"inherit":n.enabled?"on":"off",g=n?.modelId!==void 0;return(0,r.jsxs)("div",{className:"space-y-4 text-xs",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[["inherit","on","off"].map(b=>(0,r.jsx)("button",{type:"button",onClick:()=>u(b),className:j("px-3 py-1 border border-border rounded text-xs capitalize",m===b?"bg-primary text-primary-foreground border-primary":"bg-surface text-foreground hover:bg-muted"),children:b},b)),(0,r.jsxs)("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["agent default: ",(0,r.jsx)("span",{className:"font-semibold",children:t.enabled?"on":"off"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,r.jsx)("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Model"}),g?(0,r.jsx)("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>d(void 0),children:"Clear"}):(0,r.jsx)("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>d(t.modelId),children:"Override"})]}),(0,r.jsx)("select",{disabled:!g,className:"w-full bg-surface border border-border rounded px-2 py-1 text-xs disabled:opacity-50",value:g?n?.modelId??t.modelId:t.modelId,onChange:b=>d(b.target.value),children:o.map(b=>(0,r.jsx)("option",{value:b.id,children:b.name},b.id))}),!g&&(0,r.jsxs)("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["inherits from ",s]})]}),(e.configSchema?.length??0)>0&&(()=>{const b=n?.settings!==void 0;return(0,r.jsxs)("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),b?(0,r.jsx)("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>f(void 0),children:"Clear"}):(0,r.jsx)("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>f({...t.settings}),children:"Override"})]}),e.configSchema?.map(x=>(0,r.jsx)(Fr,{field:x,allFields:e.configSchema??[],step:Va(e,i),disabled:!b,onChange:v=>f({...v.settings})},x.key)),!b&&(0,r.jsxs)("div",{className:"text-[10px] text-foreground-subtle",children:["inherits from ",s]})]})})(),(0,r.jsxs)("div",{className:"rounded bg-muted/40 px-3 py-2 text-[11px] text-foreground-subtle",children:[(0,r.jsx)("div",{className:"font-semibold text-foreground mb-0.5",children:"Effective config preview"}),(0,r.jsxs)("div",{className:"font-mono truncate",children:[e.id," · model: ",i.modelId," · ",i.enabled?"on":"off"]})]})]})}function im(e){const{mode:t,addon:s,agentDefault:n,agentNodeId:o,currentPatch:a,onChangeAgentConfig:i,onChangePatch:l,engineFormat:u}=e,d=(0,h.useMemo)(()=>s.models.filter(f=>!!f.formats[u]),[s.models,u]);return t==="agent"?(0,r.jsx)(om,{addon:s,agentDefault:n,modelsForFormat:d,onChangeAgentConfig:i}):(0,r.jsx)(am,{addon:s,agentDefault:n,agentNodeId:o,currentPatch:a,modelsForFormat:d,onChangePatch:l})}function lm(e){const t=[],s=(n,o)=>{for(const a of n)t.push({node:a,depth:o}),s(a.children,o+1)};return s(e,0),t}var Wa={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 cm({slot:e}){const t=Wa[e]??Wa.classifier;return(0,r.jsx)("span",{className:j("text-[9px] font-semibold uppercase tracking-widest leading-none",t.className),children:t.label})}var qa="inline-flex items-center rounded bg-muted px-1.5 py-px text-[9px] font-medium text-foreground-subtle";function um({inputs:e,outputs:t}){return e.length===0&&t.length===0?null:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[e.map(s=>(0,r.jsx)("span",{className:j(qa,"bg-blue-500/10 text-blue-500"),children:s},`in-${s}`)),e.length>0&&t.length>0&&(0,r.jsx)("span",{className:"text-foreground-subtle/60 text-[9px]",children:"→"}),t.map(s=>(0,r.jsx)("span",{className:j(qa,"bg-emerald-500/10 text-emerald-500"),children:s},`out-${s}`))]})}function dm({enabled:e,onChange:t,disabled:s}){return(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":e,disabled:s,onClick:n=>{n.stopPropagation(),t(!e)},className:j("relative inline-flex h-3.5 w-7 shrink-0 items-center rounded-full transition-colors",e?"bg-emerald-500":"bg-foreground-subtle/30",s?"opacity-50 cursor-not-allowed":"cursor-pointer"),title:e?"Click to disable":"Click to enable",children:(0,r.jsx)("span",{className:j("inline-block h-3 w-3 rounded-full bg-white shadow transition-transform",e?"translate-x-3.5":"translate-x-0.5")})})}function fm(e){return e.kind==="enabled"?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,r.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 shrink-0"}),(0,r.jsx)("span",{className:"font-mono text-foreground",children:e.modelId})]}):e.kind==="disabled"?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-foreground-subtle",children:[(0,r.jsx)("span",{className:"h-1.5 w-1.5 rounded-full border border-foreground-subtle/60 shrink-0"}),"off"]}):(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-foreground-subtle/70",children:[(0,r.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-muted shrink-0"}),"n/a"]})}function mm({node:e,depth:t,agents:s,getCellState:n,onCellClick:o,selectedCell:a,toggleProps:i}){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("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:[(0,r.jsxs)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:[(0,r.jsx)(cm,{slot:e.slot}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"font-semibold truncate",children:e.addonName}),(0,r.jsx)(um,{inputs:e.inputClasses,outputs:e.outputClasses})]})]}),i&&(0,r.jsx)("span",{className:"pl-2 pt-0.5 shrink-0",children:(0,r.jsx)(dm,{enabled:i.enabled,onChange:i.onChange,disabled:i.disabled})})]}),s.map(l=>{const u=n(e.addonId,l.agentNodeId),d=a?.addonId===e.addonId&&a.agentNodeId===l.agentNodeId;return(0,r.jsx)("button",{type:"button",onClick:()=>o(e.addonId,l.agentNodeId),className:j("text-left px-3 py-1.5 border-b border-l border-border text-xs hover:bg-muted/40",u.kind==="enabled"&&"bg-emerald-500/5",u.kind==="na"&&"bg-muted/30",d&&"ring-2 ring-primary ring-inset"),children:fm(u)},l.agentNodeId)})]})}function pm({tree:e,agents:t,getCellState:s,onCellClick:n,selectedCell:o,onToggleEnabled:a}){const i=(0,h.useMemo)(()=>lm(e),[e]),l=`minmax(320px, 1fr) repeat(${t.length}, minmax(160px, 220px))`,u=a!==void 0&&t.length===1,d=t[0]?.agentNodeId;return(0,r.jsx)("div",{className:"overflow-auto border border-border rounded",children:(0,r.jsxs)("div",{className:"grid",style:{gridTemplateColumns:l},children:[(0,r.jsx)("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=>(0,r.jsxs)("div",{className:"sticky top-0 z-10 bg-muted/60 px-3 py-2 border-b border-l border-border",children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-foreground",children:f.agentNodeId}),(0,r.jsx)("div",{className:"text-[10px] text-foreground-subtle truncate",children:f.engineLabel})]},f.agentNodeId)),i.map(({node:f,depth:m})=>{const g=u&&d!==void 0?s(f.addonId,d):null;return(0,r.jsx)(mm,{node:f,depth:m,agents:t,getCellState:s,onCellClick:n,selectedCell:o,toggleProps:u&&g!==null?{enabled:g.kind==="enabled",onChange:b=>a?.(f.addonId,b),disabled:g.kind==="na"}:void 0},f.addonId)})]})})}var Ka=typeof globalThis<"u"?globalThis.__camstackTrpcReact:void 0,p=Ka??(0,nt.createTRPCReact)();typeof globalThis<"u"&&!Ka&&(globalThis.__camstackTrpcReact=p);var Ws=at("camstack:system",null);function Za({system:e,children:t}){return(0,r.jsx)(Ws.Provider,{value:e,children:t})}function jt(){const e=(0,h.useContext)(Ws);if(!e)throw new Error("useSystem(): no <SystemProvider> in tree");return e}function hm(){return(0,h.useContext)(Ws)}function ur(e,t){const s=jt(),n=(0,h.useRef)(t);n.current=t;const[o,a]=(0,h.useState)(s.connectionVersion);(0,h.useEffect)(()=>s.subscribeConnectionEvents((i,l)=>{i==="connected"&&a(l)}),[s]),(0,h.useEffect)(()=>s.subscribeEvent(e,i=>{n.current(i)}),[s,e,o])}function qs(e){const t=(0,h.useRef)(e);return t.current=e,t}function Ks(e,t){const[s,n]=(0,h.useState)(null),o=qs(t);return ur(e,a=>{const i=a.data,l=o.current;l&&!l(i)||n(i)}),s}function gm(e,t,s){const[n,o]=(0,h.useState)(()=>new Map),a=qs(t),i=qs(s);return ur(e,l=>{const u=l.data,d=i.current;if(d&&!d(u))return;const f=a.current(u);o(m=>{const g=new Map(m);return g.set(f,u),g})}),{map:n,values:(0,h.useMemo)(()=>Array.from(n.values()),[n])}}function zr(){const{data:e,isLoading:t}=p.nodes.topology.useQuery(void 0,{staleTime:6e4}),s=Ks("cluster.topology-snapshot")?.nodes??e;return{nodes:(0,h.useMemo)(()=>{const n=[];for(const o of s??[])n.push({id:String(o.id??""),name:String(o.name??o.id??""),shortName:o.isHub?"HUB":String(o.name??o.id??""),isHub:!!o.isHub,isOnline:!!o.isOnline,localIps:o.localIps??[],addons:(o.addons??[]).map(a=>({addonId:a.id,capabilities:a.capabilities}))});return n.sort((o,a)=>o.isHub!==a.isHub?o.isHub?-1:1:o.name.localeCompare(a.name)),n},[s]),isLoading:t}}function bm({selectedNodeId:e,onSelect:t,label:s="Node",hideIcon:n=!1,alwaysShow:o=!1}){const{nodes:a}=zr();return!o&&a.length<=1?null:(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[!n&&(0,r.jsx)(pf,{className:"h-3.5 w-3.5 text-foreground-subtle"}),s&&(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:s}),(0,r.jsx)("div",{className:"flex rounded-md border border-border overflow-hidden text-[11px] font-medium",children:a.map((i,l)=>{const u=e===i.id;return(0,r.jsx)("button",{type:"button",onClick:()=>t(i.id),disabled:!i.isOnline,title:i.isOnline?i.name:`${i.name} (offline)`,className:j("px-2.5 py-1 transition-colors",u?"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)})})]})}var xm={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 vm({status:e,showDot:t=!0,showLabel:s=!0,size:n="sm",className:o}){const a=xm[e];return(0,r.jsxs)("span",{className:j("inline-flex items-center gap-1.5",n==="sm"?"text-xs":"text-sm",o),children:[t&&(0,r.jsx)("span",{className:j("h-1.5 w-1.5 shrink-0 rounded-full",a.colorClass),"aria-hidden":"true"}),s&&(0,r.jsx)("span",{className:"text-foreground",children:a.label})]})}var ym={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 wm({provider:e,showLabel:t=!0,className:s}){const n=ym[e];return(0,r.jsxs)("span",{className:j("inline-flex items-center gap-1.5 text-xs",s),children:[(0,r.jsx)("span",{className:j("h-1.5 w-1.5 shrink-0 rounded-sm",n.colorClass),"aria-hidden":"true"}),t&&(0,r.jsx)("span",{className:"text-foreground",children:n.label})]})}var Sm={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 Ya({children:e,variant:t="neutral",mono:s,className:n}){return(0,r.jsx)("span",{className:j("inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-bold leading-tight",s&&"font-mono",Sm[t],n),children:e})}function km({version:e,preRelease:t,className:s}){return(0,r.jsx)(Ya,{variant:t??/-(alpha|beta|rc|dev|canary|next)/i.test(e)?"warning":"success",mono:!0,className:s,children:e})}function jm({label:e,description:t,error:s,required:n,children:o,orientation:a="vertical",className:i}){const l=a==="horizontal";return(0,r.jsxs)("div",{className:j("flex gap-2",l?"flex-row items-center justify-between":"flex-col",i),children:[(0,r.jsxs)("div",{className:j(l?"flex-1":""),children:[(0,r.jsxs)(Gs,{children:[e,n&&(0,r.jsx)("span",{className:"text-danger ml-0.5",children:"*"})]}),t&&(0,r.jsx)("p",{className:"text-foreground-subtle text-xs mt-0.5",children:t})]}),(0,r.jsx)("div",{className:j(l?"shrink-0":""),children:o}),s&&(0,r.jsx)("p",{className:"text-danger text-xs",children:s})]})}function Nm({title:e,subtitle:t,actions:s,className:n}){return(0,r.jsxs)("div",{className:j("flex flex-col gap-2 mb-3 sm:flex-row sm:items-center sm:justify-between",n),children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-sm font-semibold text-foreground",children:e}),t&&(0,r.jsx)("p",{className:"text-foreground-subtle text-xs",children:t})]}),s&&(0,r.jsx)("div",{className:"flex items-center gap-2 flex-wrap",children:s})]})}function Cm({icon:e,title:t,description:s,action:n,className:o}){return(0,r.jsxs)("div",{className:j("flex flex-col items-center justify-center gap-3 py-12",o),children:[e&&(0,r.jsx)(e,{className:"h-12 w-12 text-foreground-subtle","aria-hidden":"true"}),(0,r.jsxs)("div",{className:"flex flex-col items-center gap-1 text-center",children:[(0,r.jsx)("p",{className:"text-foreground-muted text-sm font-medium",children:t}),s&&(0,r.jsx)("p",{className:"text-foreground-subtle text-xs max-w-xs",children:s})]}),n&&(0,r.jsx)("div",{className:"mt-1",children:n})]})}var Xa=at("camstack:confirm-dialog",null);function Qr(){const e=(0,h.useContext)(Xa);if(!e)throw new Error("useConfirm must be used within ConfirmDialogProvider");return e.confirm}function Mm({children:e}){const[t,s]=(0,h.useState)(null),n=(0,h.useCallback)(u=>new Promise(d=>{s({...u,resolve:d})}),[]),o=()=>{t?.resolve(!0),s(null)},a=()=>{t?.resolve(!1),s(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(0,r.jsxs)(Xa.Provider,{value:{confirm:n},children:[e,t&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:a}),(0,r.jsxs)("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:u=>u.stopPropagation(),children:[(0,r.jsxs)("div",{className:"px-5 pt-5 pb-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:t.title}),(0,r.jsx)("p",{className:"mt-2 text-xs text-foreground-subtle leading-relaxed",children:t.message})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border bg-surface-hover/30",children:[(0,r.jsx)("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"}),(0,r.jsx)("button",{type:"button",onClick:o,className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${l.button}`,children:t.confirmLabel??"Confirm"})]})]})]})]})}function Em({value:e,label:t,trend:s,className:n}){return(0,r.jsxs)($s,{className:j("flex flex-col gap-1",n),children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,r.jsx)("span",{className:"text-2xl font-semibold text-foreground",children:e}),s&&(0,r.jsxs)("span",{className:j("inline-flex items-center gap-0.5 text-xs font-medium",s.direction==="up"?"text-success":"text-danger"),children:[s.direction==="up"?(0,r.jsx)(Sf,{className:"h-3 w-3"}):(0,r.jsx)(kf,{className:"h-3 w-3"}),s.value,"%"]})]}),(0,r.jsx)("span",{className:"text-xs text-foreground-muted",children:t})]})}function Am({items:e,className:t}){return(0,r.jsx)("dl",{className:j("flex flex-col",t),children:e.map(s=>(0,r.jsxs)("div",{className:"flex items-center h-7",children:[(0,r.jsx)("dt",{className:"text-foreground-subtle text-xs w-1/3 shrink-0",children:s.key}),(0,r.jsx)("dd",{className:"text-foreground text-xs",children:s.value})]},s.key))})}function Pm({children:e,maxHeight:t=300,className:s}){const[n,o]=(0,h.useState)(!1),a=(0,h.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)})},[e]);return(0,r.jsxs)("div",{className:j("relative group",s),children:[(0,r.jsx)(Us,{style:{maxHeight:t},children:(0,r.jsx)("pre",{className:"font-mono text-xs bg-surface p-3 rounded-md border border-border-subtle",children:(0,r.jsx)("code",{children:e})})}),(0,r.jsx)("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,r.jsx)(_s,{icon:n?sr:pt,"aria-label":"Copy code",variant:"ghost",size:"sm",onClick:a})})]})}function Rm({filters:e,values:t,onChange:s,className:n}){const o=cr(),[a,i]=(0,h.useState)(!1),l=(d,f)=>{s({...t,[d]:f})},u=Object.values(t).filter(d=>d!==void 0&&d!=="").length;if(o){const d=e.find(m=>m.type==="search"),f=e.some(m=>m.type!=="search");return(0,r.jsxs)("div",{className:j("flex items-center gap-2",n),children:[d&&(0,r.jsx)($r,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:m=>l(d.key,m.target.value),leftSlot:(0,r.jsx)(ar,{className:"h-3 w-3 text-foreground-subtle"}),className:"flex-1"}),f&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("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:[(0,r.jsx)(bf,{className:"h-3.5 w-3.5"}),"Filters",u>0&&(0,r.jsx)(Gt,{variant:"info",className:"ml-1 text-[10px] px-1 py-0",children:u})]}),(0,r.jsx)(Qs,{open:a,onClose:()=>i(!1),title:"Filters",children:(0,r.jsx)("div",{className:"flex flex-col gap-3",children:e.filter(m=>m.type!=="search").map(m=>{switch(m.type){case"select":return(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-foreground-muted mb-1 block",children:m.label}),(0,r.jsx)(Gr,{options:m.options,value:t[m.key]??"",onChange:g=>l(m.key,g.target.value),className:"w-full"})]},m.key);case"badge-toggle":return(0,r.jsx)("div",{className:"flex items-center gap-1 flex-wrap",children:m.options.map(g=>{const b=t[m.key]===g.value;return(0,r.jsx)("button",{type:"button",onClick:()=>l(m.key,b?void 0:g.value),children:(0,r.jsx)(Gt,{variant:b?"info":"default",className:"cursor-pointer",children:g.label})},g.value)})},m.key);default:return null}})})})]})]})}return(0,r.jsx)("div",{className:j("flex items-center gap-2 flex-wrap",n),children:e.map(d=>{switch(d.type){case"search":return(0,r.jsx)($r,{placeholder:d.placeholder??"Search...",value:t[d.key]??"",onChange:f=>l(d.key,f.target.value),leftSlot:(0,r.jsx)(ar,{className:"h-3 w-3 text-foreground-subtle"}),className:"w-48"},d.key);case"select":return(0,r.jsx)(Gr,{options:d.options,value:t[d.key]??"",onChange:f=>l(d.key,f.target.value),className:"w-36"},d.key);case"badge-toggle":return(0,r.jsx)("div",{className:"flex items-center gap-1",children:d.options.map(f=>{const m=t[d.key]===f.value;return(0,r.jsx)("button",{type:"button",onClick:()=>l(d.key,m?void 0:f.value),children:(0,r.jsx)(Gt,{variant:m?"info":"default",className:"cursor-pointer",children:f.label})},f.value)})},d.key);default:return null}})})}function Zs({label:e,icon:t,href:s,badge:n,active:o=!1,className:a}){return(0,r.jsxs)("a",{href:s,className:j("flex items-center gap-2 h-7 px-2 text-[11px] transition-colors",o?"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:[(0,r.jsx)(t,{className:"h-3.5 w-3.5 shrink-0"}),(0,r.jsx)("span",{className:"truncate flex-1",children:e}),n!==void 0&&(0,r.jsx)(Gt,{className:"ml-auto text-[10px] px-1.5 py-0",children:n})]})}function Ys({logo:e,sections:t,footer:s,onNavigate:n,className:o}){return(0,r.jsxs)("nav",{className:j("bg-surface border-r border-border h-full flex flex-col",o),children:[e&&(0,r.jsx)("div",{className:"px-3 py-2 shrink-0",children:e}),(0,r.jsx)("div",{className:"flex-1 overflow-auto px-1 py-1",children:t.map((a,i)=>(0,r.jsxs)("div",{className:j(i>0?"mt-3":""),children:[a.label&&(0,r.jsx)("span",{className:"text-[10px] text-foreground-disabled uppercase tracking-wider px-2 mb-1 block",children:a.label}),(0,r.jsx)("div",{className:"flex flex-col gap-0.5",onClick:n,children:a.items.map(l=>(0,r.jsx)(Zs,{...l},l.href))})]},i))}),s&&s.length>0&&(0,r.jsxs)("div",{className:"shrink-0 px-1 pb-1",children:[(0,r.jsx)(Bs,{className:"mb-1"}),(0,r.jsx)("div",{className:"flex flex-col gap-0.5",onClick:n,children:s.map(a=>(0,r.jsx)(Zs,{...a},a.href))})]})]})}function Dm({sidebar:e,header:t,mobileLogo:s,mobileActions:n,children:o,className:a}){const i=cr(),[l,u]=(0,h.useState)(!1);return(0,r.jsxs)("div",{className:j("flex h-screen",a),children:[!i&&(0,r.jsx)(Ys,{...e,className:j("w-44",e.className)}),i&&(0,r.jsx)(Qa,{open:l,onClose:()=>u(!1),width:"w-64",children:(0,r.jsx)(Ys,{...e,onNavigate:()=>u(!1),className:"w-full border-r-0"})}),(0,r.jsxs)("div",{className:"flex flex-1 flex-col min-w-0",children:[i&&(0,r.jsxs)("header",{className:"flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm",children:[(0,r.jsx)("button",{onClick:()=>u(!0),className:"p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors","aria-label":"Open menu",children:(0,r.jsx)(nf,{className:"h-5 w-5"})}),s&&(0,r.jsx)("div",{className:"flex-1 flex justify-center",children:s}),n&&(0,r.jsx)("div",{className:"shrink-0",children:n})]}),!i&&t&&(0,r.jsxs)("header",{className:"flex items-center h-10 border-b border-border px-4 shrink-0",children:[t.breadcrumbs&&t.breadcrumbs.length>0&&(0,r.jsx)("nav",{className:"flex items-center gap-1 text-xs flex-1 min-w-0",children:t.breadcrumbs.map((d,f)=>{const m=f===t.breadcrumbs.length-1;return(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[f>0&&(0,r.jsx)(mt,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),d.href&&!m?(0,r.jsx)("a",{href:d.href,className:"text-foreground-subtle hover:text-foreground transition-colors truncate",children:d.label}):(0,r.jsx)("span",{className:"text-foreground truncate",children:d.label})]},f)})}),t.actions&&(0,r.jsx)("div",{className:"flex items-center gap-2 ml-auto shrink-0",children:t.actions})]}),(0,r.jsx)("main",{className:"flex-1 overflow-auto p-4",children:o})]})]})}var Tm={online:"bg-success",offline:"bg-danger",warning:"bg-warning",unknown:"bg-foreground-subtle"};function Im({title:e,subtitle:t,status:s,selected:n,onClick:o,badges:a,actions:i,offlineAction:l,className:u}){const d=s==="offline";return(0,r.jsxs)("div",{onClick:o,className:j("w-full rounded-lg border p-3 text-left transition-colors",o&&"cursor-pointer",n?"border-primary bg-primary/10":"border-border bg-surface hover:bg-surface-hover",d&&!n&&"opacity-50",u),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium truncate",children:e}),s&&(0,r.jsx)("span",{className:j("h-2 w-2 rounded-full shrink-0",Tm[s])})]}),t&&(0,r.jsx)("div",{className:"text-[11px] text-foreground-muted",children:t}),a&&a.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1 mt-2",children:a.map((f,m)=>{const g=j("rounded px-1.5 py-0.5 text-[10px] flex items-center gap-0.5",n?"bg-primary/20":"bg-surface-hover",f.onClick&&"hover:opacity-80 transition-opacity cursor-pointer");return f.onClick?(0,r.jsxs)("button",{onClick:b=>{b.stopPropagation(),f.onClick()},className:g,children:[f.icon,f.label]},m):(0,r.jsxs)("span",{className:g,children:[f.icon,f.label]},m)})}),!d&&i&&i.length>0&&(0,r.jsx)("div",{className:"flex items-center gap-0.5 mt-2 -mb-1",children:i.map((f,m)=>(0,r.jsx)("button",{onClick:g=>{g.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},m))}),d&&l&&(0,r.jsx)("div",{className:"mt-2",onClick:f=>f.stopPropagation(),children:l})]})}function Lm({children:e,minCardWidth:t=220,gap:s=3,className:n}){return(0,r.jsx)("div",{className:j("p-4 overflow-y-auto flex-1 content-start",n),style:{display:"grid",gridTemplateColumns:`repeat(auto-fill, minmax(${t}px, 1fr))`,gap:`${s*4}px`},children:e})}var Om="capability.binding-changed";function dr(e,t){const[s,n]=(0,h.useState)(null);return(0,h.useEffect)(()=>{if(t===null){n(null);return}let o=!1;const a=async()=>{try{const l=await e.deviceManager.getBindings.query({deviceId:t});o||n(l)}catch{o||n(l=>l)}};a();const i=e.live?.onEvent.subscribe({category:Om},{onData:l=>{const u=l.data?.source;if(!u){a();return}u.type==="device"&&u.id===t&&a()}});return()=>{o=!0,i?.unsubscribe()}},[e,t]),(0,h.useMemo)(()=>s?(0,F.createDeviceProxy)(e,s):null,[e,s])}function Xs(e){const t=(0,h.useCallback)(n=>e?e.subscribe(()=>n()):()=>{},[e]),s=(0,h.useCallback)(()=>e?.value,[e]);return(0,h.useSyncExternalStore)(t,s,s)}function Ja(e,t,s){const n=dr(e,t);return Xs(n?s(n.state):void 0)}function Bt(e){const t=dr(e.trpc,e.deviceId),s=Xs(t!==null?e.slice(t):void 0),n=t!==null?e.cap(t):void 0;return{dev:t,cap:n,slice:s,available:(e.requireFeature===void 0||(e.deviceFeatures??[]).includes(e.requireFeature))&&n!==void 0&&s!==void 0}}function _m(e){return e.parentDeviceId===null?"top-level":e.role?"accessory":"adopted"}var $m={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 Gm(e){const t=$m[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}}var Bm={siren:Or,floodlight:ea,spotlight:ca,"pir-sensor":oa,chime:of,autotrack:Wo,nightvision:Ds,"privacy-mask":Yo,doorbell:qo},Fm={camera:Ps,hub:Ts,nvr:Ts,light:ea,siren:Or,switch:wf,sensor:oa,thermostat:yf,button:Hd,generic:Os};function ei(e){return e.role?Bm[e.role]??Os:Fm[e.type.toLowerCase()]??Ps}var ti={"native-snapshot":Jd,"two-way-audio":ra,"pan-tilt-zoom":Wo,"ptz-autotrack":sf,"doorbell-button":qo,"motion-trigger":ft,"battery-operated":Ho,rebootable:ia},ri={"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"},zm={"native-snapshot":"snapshot",rebootable:"reboot","pan-tilt-zoom":"ptz","ptz-autotrack":"ptz-autotrack","two-way-audio":"intercom","motion-trigger":"motion-trigger"},si=new Set(["camera","hub","nvr"]);function ni(e){return!si.has(e.type.toLowerCase())}function oi(e){return e.role?!0:!si.has(e.type.toLowerCase())}function ai(e){return(e.features??[]).includes("motion-trigger")}function Qm(e){if(e.length<=24)return e;const t=e.lastIndexOf(":");if(t>=0&&t<e.length-4)return e.slice(t+1);const s=e.split("-");if(s.length>2){const n=s.slice(-2).join("-");if(n.length>=6)return n}return`…${e.slice(-18)}`}function Um({trpc:e,accessoryChildren:t,adoptedChildren:s,onNavigate:n}){return(0,r.jsxs)("div",{className:"border-t border-border-subtle/50",children:[s.length>0&&(0,r.jsx)(ii,{trpc:e,label:"Adopted devices",rows:s,onNavigate:n}),t.length>0&&(0,r.jsx)(ii,{trpc:e,label:"Accessories",rows:t,onNavigate:n})]})}function ii({trpc:e,label:t,rows:s,onNavigate:n}){return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"px-3 pt-1.5 pb-1 text-[9px] font-semibold uppercase tracking-wide text-foreground-subtle",children:t}),(0,r.jsx)("ul",{children:s.map(o=>(0,r.jsx)(Hm,{trpc:e,child:o,onNavigate:n},o.id))})]})}function Hm({trpc:e,child:t,onNavigate:s}){const n=!t.disabled,o=n&&ni(t),a=n&&ai(t);return(0,r.jsx)("li",{children:(0,r.jsxs)("div",{onClick:i=>{i.stopPropagation(),s(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:[(0,r.jsx)(ei(t),{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),(0,r.jsx)("span",{className:"text-[10.5px] text-foreground flex-1 truncate",children:t.name}),a&&(0,r.jsx)(Wm,{trpc:e,deviceId:t.id,features:t.features}),o&&(0,r.jsx)(Vm,{trpc:e,deviceId:t.id}),(0,r.jsx)("span",{className:j("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 Vm({trpc:e,deviceId:t}){const{dev:s,cap:n,slice:o,available:a}=Bt({trpc:e,deviceId:t,cap:m=>m.switch,slice:m=>m.state.switch}),[i,l]=(0,h.useState)(!1);if(s!==null&&!n)return null;const u=o?.on===!0,d={transform:u?"translateX(14px)":"translateX(2px)"},f=async m=>{if(m.stopPropagation(),!(i||!a||!n)){l(!0);try{await n.setState({on:!u})}finally{l(!1)}}};return(0,r.jsx)("button",{type:"button",onClick:m=>{f(m)},disabled:i||!a,className:j("relative inline-flex h-4 w-7 items-center rounded-full border transition-colors flex-shrink-0",u?"bg-success/30 border-success/50":"bg-surface-hover border-border",i&&"opacity-60",!a&&"opacity-40 cursor-not-allowed"),title:a?u?"Turn off":"Turn on":"Awaiting state…","aria-pressed":u,children:(0,r.jsx)("span",{className:j("absolute h-3 w-3 rounded-full transition-all",u?"bg-success":"bg-foreground-subtle"),style:d})})}function Wm({trpc:e,deviceId:t,features:s}){const{dev:n,cap:o,slice:a,available:i}=Bt({trpc:e,deviceId:t,cap:m=>m.motionTrigger,slice:m=>m.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:s}),[l,u]=(0,h.useState)(!1);if(n!==null&&!o)return null;const d=a?.enabled===!0,f=async m=>{if(m.stopPropagation(),!(l||!i||!o)){u(!0);try{await o.setMotionTrigger({enabled:!d})}finally{u(!1)}}};return(0,r.jsx)("button",{type:"button",onClick:m=>{f(m)},disabled:l||!i,className:j("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:(0,r.jsx)(ft,{className:"h-2.5 w-2.5"})})}function li({trpc:e,device:t,flags:s}){if(t.disabled)return null;const n=t.type.toLowerCase(),o=s.showSwitchToggle&&ni(t),a=ai(t),i=n==="hub"||n==="nvr",l=(t.features??[]).includes("rebootable"),u=i&&l;return(0,r.jsxs)(r.Fragment,{children:[a&&(0,r.jsx)(Km,{trpc:e,deviceId:t.id,features:t.features}),o&&(0,r.jsx)(qm,{trpc:e,deviceId:t.id}),u&&(0,r.jsx)(Ym,{trpc:e,deviceId:t.id})]})}function qm({trpc:e,deviceId:t}){const{dev:s,cap:n,slice:o,available:a}=Bt({trpc:e,deviceId:t,cap:m=>m.switch,slice:m=>m.state.switch}),[i,l]=(0,h.useState)(!1);if(s!==null&&!n)return null;const u=o?.on===!0,d={transform:u?"translateX(14px)":"translateX(2px)"},f=async m=>{if(m.stopPropagation(),!(i||!a||!n)){l(!0);try{await n.setState({on:!u})}finally{l(!1)}}};return(0,r.jsx)("button",{type:"button",onClick:m=>{f(m)},disabled:i||!a,className:j("relative inline-flex h-4 w-7 items-center rounded-full border transition-colors flex-shrink-0",u?"bg-success/30 border-success/50":"bg-surface-hover border-border",i&&"opacity-60",!a&&"opacity-40 cursor-not-allowed"),title:a?u?"Turn off":"Turn on":"Awaiting state…","aria-pressed":u,children:(0,r.jsx)("span",{className:j("absolute h-3 w-3 rounded-full transition-all",u?"bg-success":"bg-foreground-subtle"),style:d})})}function Km({trpc:e,deviceId:t,features:s}){const{dev:n,cap:o,slice:a,available:i}=Bt({trpc:e,deviceId:t,cap:m=>m.motionTrigger,slice:m=>m.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:s}),[l,u]=(0,h.useState)(!1);if(n!==null&&!o)return null;const d=a?.enabled===!0,f=async m=>{if(m.stopPropagation(),!(l||!i||!o)){u(!0);try{await o.setMotionTrigger({enabled:!d})}finally{u(!1)}}};return(0,r.jsx)("button",{type:"button",onClick:m=>{f(m)},disabled:l||!i,className:j("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:(0,r.jsx)(ft,{className:"h-2.5 w-2.5"})})}var Js=168,Zm=4;function Ym({trpc:e,deviceId:t}){const{dev:s,cap:n}=Bt({trpc:e,deviceId:t,cap:w=>w.reboot,slice:()=>{}}),o=(0,h.useRef)(null),a=(0,h.useRef)(null),[i,l]=(0,h.useState)(null),[u,d]=(0,h.useState)(!1),f=s!==null&&n!==void 0&&n!==null,m=i!==null,g=()=>l(null),b=()=>{const w=o.current;if(!w)return;const y=w.getBoundingClientRect(),S=y.right-Js,k=Math.max(8,Math.min(S,window.innerWidth-Js-8));l({top:y.bottom+Zm,left:k})};if((0,h.useEffect)(()=>{if(!m)return;const w=S=>{const k=o.current,C=a.current,N=S.target;N!==null&&(k&&k.contains(N)||C&&C.contains(N)||g())},y=S=>{S.key==="Escape"&&(S.stopPropagation(),g())};return document.addEventListener("mousedown",w),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",y)}},[m]),s!==null&&!n)return null;const x=w=>{w.stopPropagation(),m?g():b()},v=async()=>{if(!(u||!f||!n)){d(!0),g();try{await n.reboot({})}finally{d(!1)}}};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{ref:o,type:"button",onClick:x,disabled:u||!f,className:j("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",(u||!f)&&"opacity-50",m&&"bg-surface-hover text-foreground"),title:"More actions","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":m,children:(0,r.jsx)(Ko,{className:"h-3 w-3"})}),i&&(0,Ze.createPortal)((0,r.jsx)("div",{ref:a,role:"menu",style:{position:"fixed",top:i.top,left:i.left,width:Js},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-1",onClick:w=>w.stopPropagation(),children:(0,r.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>{v()},disabled:u||!f,className:j("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:[(0,r.jsx)(ia,{className:"h-3 w-3 shrink-0 text-foreground-subtle"}),(0,r.jsx)("span",{children:"Reboot device"})]})}),document.body)]})}var Xm=Object.freeze([]);function Jm(e){return e==="native"?"native":"enhanced"}function ep(e){return e.map(t=>({kind:"marker",feature:t}))}function tp(e,t){const s=new Map,n=t.entries??[];for(const a of n)s.set(a.capName,a);const o=[];for(const a of e){const i=zm[a];if(i===void 0){o.push({kind:"marker",feature:a});continue}const l=s.get(i);l&&o.push({kind:Jm(l.kind),feature:a,capName:i})}return o}function rp(e,t,s){const[n,o]=(0,h.useState)(null),[a,i]=(0,h.useState)(!1),[l,u]=(0,h.useState)(!0);return(0,h.useEffect)(()=>{if(t===null){o(null),i(!1),u(!1);return}let d=!1;u(!0),i(!1);const f=async()=>{try{const g=await e.deviceManager.getBindings.query({deviceId:t});if(d)return;o(g),u(!1)}catch{if(d)return;i(!0),u(!1)}};f();const m=e.live?.onEvent.subscribe({category:"capability.binding-changed"},{onData:g=>{const b=g.data?.source;if(!b){f();return}b.type==="device"&&b.id===t&&f()}});return()=>{d=!0,m?.unsubscribe()}},[e,t]),s.length===0?{loading:l,resolved:Xm}:l||a||!n?{loading:l,resolved:ep(s)}:{loading:!1,resolved:tp(s,n)}}var sp=[];function ci({trpc:e,device:t,flags:s,accessoryCount:n,adoptedCount:o,showFeatureRow:a=!1}){const i=n+o,l=s.showChildrenAccordion&&i>0,u=t.features??sp,d=a&&u.length>0,{resolved:f}=rp(e,d?t.id:null,u),m=d&&f.length>0;return!l&&!m?null:(0,r.jsxs)("div",{className:"flex items-center gap-1.5 flex-nowrap whitespace-nowrap min-w-0",children:[l&&(0,r.jsx)(np,{accessoryCount:n,adoptedCount:o}),m&&(0,r.jsx)(op,{resolved:f})]})}function np({accessoryCount:e,adoptedCount:t}){const s=e+t;return s===0?null:(0,r.jsxs)("span",{className:"text-[9px] font-medium text-foreground-subtle bg-surface-elevated/60 rounded px-1.5 py-0.5 flex-shrink-0",title: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"}`,children:["+",s]})}var ui=240,di=200;function op({resolved:e}){const t=(0,h.useRef)(null),[s,n]=(0,h.useState)(null),o=()=>{const i=t.current;if(!i)return;const l=i.getBoundingClientRect();n({top:window.innerHeight-l.bottom>=di?l.bottom+4:l.top-di-4,left:Math.max(8,Math.min(l.left,window.innerWidth-ui-8))})},a=()=>n(null);return(0,r.jsxs)("span",{ref:t,className:"relative inline-flex items-center gap-1 cursor-help",onMouseEnter:o,onMouseLeave:a,children:[e.map(i=>{const l=ti[i.feature];return l?(0,r.jsx)("span",{className:"inline-flex items-center justify-center h-4 w-4 rounded bg-surface-elevated/60 text-foreground-subtle",title:ri[i.feature]??i.feature,children:(0,r.jsx)(l,{className:"h-2.5 w-2.5"})},i.feature):null}),s&&(0,Ze.createPortal)((0,r.jsx)(ap,{resolved:e,position:s}),document.body)]})}function ap({resolved:e,position:t}){return(0,r.jsxs)("div",{style:{position:"fixed",top:t.top,left:t.left,width:ui,pointerEvents:"none"},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-2",children:[(0,r.jsx)("h5",{className:"text-[9px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5",children:"Features"}),(0,r.jsx)("ul",{className:"space-y-0.5",children:e.map(s=>(0,r.jsx)(ip,{entry:s},s.feature))})]})}function ip({entry:e}){const t=ti[e.feature],s=ri[e.feature]??e.feature;return(0,r.jsxs)("li",{className:"flex items-center justify-between gap-2 text-[10px]",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1.5 text-foreground",children:[t&&(0,r.jsx)(t,{className:"h-3 w-3 text-foreground-subtle"}),(0,r.jsx)("span",{children:s})]}),(0,r.jsx)(lp,{kind:e.kind})]})}function lp({kind:e}){return e==="marker"?(0,r.jsx)("span",{className:"text-[8.5px] px-1 rounded text-foreground-subtle",title:"Informational marker (no cap registered)",children:"marker"}):(0,r.jsx)("span",{className:j("text-[8.5px] px-1 rounded",e==="native"?"bg-success/15 text-success":"bg-primary/15 text-primary"),children:e})}function fi({device:e,variant:t,flags:s,parent:n,integrationIcon:o,hasChildren:a,expanded:i,onToggleExpand:l,onNavigateToParent:u}){const d=ei(e);return(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[s.showChildrenAccordion&&a?(0,r.jsx)("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?(0,r.jsx)(St,{className:"h-3 w-3"}):(0,r.jsx)(mt,{className:"h-3 w-3"})}):s.showChildrenAccordion?(0,r.jsx)("span",{className:"h-3.5 w-3.5 flex-shrink-0"}):null,(0,r.jsx)(d,{className:j("text-foreground-subtle flex-shrink-0",t==="minimal"?"h-3 w-3":"h-3.5 w-3.5")}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.showIntegrationIcon&&o&&(0,r.jsx)("span",{className:"flex-shrink-0",children:o}),(0,r.jsx)("span",{className:j("font-semibold text-foreground truncate",t==="minimal"?"text-[10.5px]":"text-[11px]"),title:e.name,children:e.name})]}),(s.showId||s.showStableId)&&(0,r.jsxs)("div",{className:"mt-0.5 flex items-center gap-1 text-[9px] text-foreground-subtle font-mono truncate",title:s.showStableId?`stableId: ${e.stableId}`:void 0,children:[s.showId&&(0,r.jsxs)("span",{className:"flex-shrink-0 tabular-nums",children:["#",String(e.id)]}),s.showId&&s.showStableId&&(0,r.jsx)("span",{className:"flex-shrink-0 opacity-50",children:"·"}),s.showStableId&&(0,r.jsx)("span",{className:"truncate",children:Qm(e.stableId)})]}),s.showParentBadge&&n&&(0,r.jsxs)("button",{type:"button",onClick:f=>{f.stopPropagation(),u(n.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: ${n.name} (#${String(n.id)})`,children:[(0,r.jsx)(Ts,{className:"h-2.5 w-2.5 shrink-0"}),(0,r.jsxs)("span",{className:"truncate",children:["Under: ",n.name]})]})]})]})}function mi(e,t){return Ja(e,t,s=>s.battery)??null}function pi(e,t){const s=dr(e,t),n=(0,h.useRef)(!1),{data:o,isLoading:a,isFetching:i,refetch:l}=(0,Ae.useQuery)({queryKey:["device",t,"snapshot"],queryFn:()=>{if(!s)throw new Error("useDeviceSnapshotImage: device proxy not ready");const f=n.current;return n.current=!1,s.snapshot?.getSnapshot({force:f})??null},enabled:s!==null&&t!==null,staleTime:1e4,gcTime:1440*60*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:!1}),u=o?`data:${o.contentType};base64,${o.base64}`:null;function d(){n.current=!0,l()}return{src:u,loading:a||i,refresh:d}}function cp(e){return e<=10?$d:e<=30?_d:e>=95?Od:Ho}function up(e,t){return t!=="none"?"text-emerald-400":e<=10?"text-rose-400":e<=30?"text-amber-400":"text-foreground-subtle"}function hi({status:e,variant:t="compact",className:s}){if(!e)return null;const n=cp(e.percentage),o=up(e.percentage,e.charging),a=e.charging==="solar"?ca:e.charging==="dc"?lf:null,i=e.sleeping;return(0,r.jsxs)("span",{className:j("inline-flex items-center gap-1 text-[10px] font-medium",o,s),title:`Battery: ${Math.round(e.percentage)}%`+(e.charging!=="none"?` · charging (${e.charging})`:"")+(e.sleeping?" · sleeping":""),children:[(0,r.jsx)(n,{className:"h-3.5 w-3.5"}),(0,r.jsxs)("span",{children:[Math.round(e.percentage),"%"]}),a&&(0,r.jsx)(a,{className:"h-3 w-3"}),i&&(0,r.jsx)(Ds,{className:"h-3 w-3 text-blue-300"}),t==="full"&&e.charging!=="none"&&(0,r.jsx)("span",{className:"text-foreground-subtle",children:e.charging})]})}function gi({trpc:e,device:t,status:s,enabled:n,showStatusPills:o=!1}){const a=pi(e,n&&t.online?t.id:null),i=(t.features??[]).includes("battery-operated"),l=o&&i&&!t.disabled,u=mi(e,l?t.id:null);return!n&&!l?null:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5 flex-nowrap whitespace-nowrap",children:[l&&u&&(0,r.jsx)(hi,{status:u}),n&&(0,r.jsx)(dp,{deviceName:t.name,snapshotUrl:a.src,status:s})]})}var en=288,bi=196,tn=8;function dp({deviceName:e,snapshotUrl:t,status:s}){const n=(0,h.useRef)(null),[o,a]=(0,h.useState)(null),i=s==="offline"||s==="disabled",l=()=>{const d=n.current;if(!d)return;const f=d.getBoundingClientRect(),m=f.top,g=window.innerHeight-f.bottom,b=m<bi+tn&&g>m,x=b?f.bottom+tn:f.top-bi-tn,v=f.right-en;a({top:x,left:Math.max(8,Math.min(v,window.innerWidth-en-8)),placeBelow:b})},u=()=>a(null);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{ref:n,type:"button",onClick:d=>d.stopPropagation(),onMouseEnter:l,onMouseLeave:u,onFocus:l,onBlur:u,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:(0,r.jsx)(nr,{className:"h-3.5 w-3.5"})}),o&&(0,Ze.createPortal)((0,r.jsxs)("div",{style:{position:"fixed",top:o.top,left:o.left,width:en,pointerEvents:"none"},className:"rounded-lg border border-border bg-surface shadow-lg shadow-black/30 z-[9999] overflow-hidden",children:[(0,r.jsx)("div",{className:"h-40 bg-background flex items-center justify-center",children:t&&!i?(0,r.jsx)("img",{src:t,alt:e,className:"h-full w-full object-cover"}):(0,r.jsx)("span",{className:"text-xs text-foreground-subtle",children:s==="offline"?"Offline — no snapshot":s==="disabled"?"Disabled":"No snapshot yet"})}),(0,r.jsx)("div",{className:"px-3 py-2",children:(0,r.jsx)("p",{className:"text-xs font-semibold text-foreground truncate",children:e})})]}),document.body)]})}function xi({status:e}){const t=e==="disabled"?"bg-warning":e==="online"?"bg-success":"bg-danger",s=e==="disabled"?"Disabled":e==="online"?"Online":"Offline";return(0,r.jsx)("span",{className:j("h-1.5 w-1.5 rounded-full flex-shrink-0",t),title:s})}function Ur(e){const{trpc:t,device:s,parent:n,integrationIcon:o,onNavigate:a,className:i}=e,l=Gm(e),u=e.variant??"compact",d=e.view??"card",f=!s.disabled,m=s.isCamera??s.type.toLowerCase()==="camera",g=e.children??[],b=g.filter(oi),x=g.filter(R=>!oi(R)),v=g.length>0,[w,y]=(0,h.useState)(!1),S=e.expanded??w,k=e.onToggleExpand??(()=>y(R=>!R)),C=R=>{a?.(R)},N=e.indentLevel??(e.isAccessoryRow?2:0),E=f?s.online?"online":"offline":"disabled";return d==="table"?(0,r.jsx)(mp,{trpc:t,device:s,variant:u,flags:l,parent:n??null,integrationIcon:o??null,accessoryCount:b.length,adoptedCount:x.length,hasChildren:v,expanded:S,onToggleExpand:k,onNavigate:C,displayStatus:E,isCamera:m,showSnapshot:l.showSnapshot&&m,isAccessoryRow:e.isAccessoryRow??!1,indentLevel:N,className:i}):(0,r.jsxs)("div",{className:j("rounded-lg border border-border bg-surface transition-colors",!f&&"opacity-60",i),children:[(0,r.jsxs)("div",{onClick:()=>C(s.id),className:j("flex items-center gap-2 cursor-pointer hover:border-foreground-subtle/30 w-full",u==="minimal"?"px-2.5 py-1.5":"px-3 py-2.5"),children:[(0,r.jsx)(fi,{device:s,variant:u,flags:l,parent:n??null,integrationIcon:o??null,hasChildren:v,expanded:S,onToggleExpand:k,onNavigateToParent:C}),(0,r.jsx)(ci,{trpc:t,device:s,flags:l,accessoryCount:b.length,adoptedCount:x.length,showFeatureRow:!1}),(0,r.jsx)(gi,{trpc:t,device:s,status:E,enabled:l.showSnapshot&&m,showStatusPills:!0}),(0,r.jsx)(li,{trpc:t,device:s,flags:l}),(0,r.jsx)(xi,{status:E})]}),S&&v&&(0,r.jsx)(Um,{trpc:t,accessoryChildren:b,adoptedChildren:x,onNavigate:C})]})}var fp={0:"pl-2",1:"pl-6",2:"pl-8"};function mp(e){const{trpc:t,device:s,variant:n,flags:o,parent:a,integrationIcon:i,accessoryCount:l,adoptedCount:u,hasChildren:d,expanded:f,onToggleExpand:m,onNavigate:g,displayStatus:b,isCamera:x,showSnapshot:v,isAccessoryRow:w,indentLevel:y,className:S}=e;return(0,r.jsxs)("tr",{onClick:()=>g(s.id),className:j("cursor-pointer hover:bg-surface-hover transition-colors",!o.showChildrenAccordion&&"border-b border-border-subtle/40",w&&"bg-foreground-subtle/[0.03]",S),children:[(0,r.jsx)("td",{className:j("py-2 align-middle pr-2",fp[y]),children:(0,r.jsx)(fi,{device:s,variant:n,flags:o,parent:a,integrationIcon:i,hasChildren:d,expanded:f,onToggleExpand:m,onNavigateToParent:g})}),(0,r.jsx)("td",{className:"px-2 py-2 align-middle text-[10px] text-foreground-subtle whitespace-nowrap",children:s.type}),(0,r.jsx)("td",{className:"px-2 py-2 align-middle",children:(0,r.jsx)(ci,{trpc:t,device:s,flags:o,accessoryCount:l,adoptedCount:u,showFeatureRow:!0})}),(0,r.jsx)("td",{className:"px-2 py-2 align-middle",children:(0,r.jsx)(gi,{trpc:t,device:s,status:b,enabled:v&&x,showStatusPills:!0})}),(0,r.jsx)("td",{className:"px-2 py-2 align-middle text-right whitespace-nowrap",children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,r.jsx)(li,{trpc:t,device:s,flags:o}),(0,r.jsx)(xi,{status:b})]})})]})}function vi(e,t){const[s,n]=(0,h.useState)(e);return(0,h.useEffect)(()=>{const o=setTimeout(()=>n(e),t);return()=>clearTimeout(o)},[e,t]),s}var pp=new Set(["hub","nvr"]);function hp(e){const t=new Map;for(const o of e)t.set(o.id,o);const s=[],n=new Map;for(const o of e){const a=o.parentDeviceId;if(a==null){s.push(o);continue}const i=t.get(a);if(!i){s.push(o);continue}const l=o.role!==null&&o.role!==void 0;if(pp.has(i.type)&&!l){s.push(o);continue}const u=n.get(a);u?u.push(o):n.set(a,[o])}return{topLevel:s,accessoriesByParent:n}}var yi=2;function gp(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 s=[],n=Math.max(2,e-yi),o=Math.min(t-1,e+yi);s.push({kind:"page",n:1}),n>2&&s.push({kind:"ellipsis",side:"left"});for(let a=n;a<=o;a++)s.push({kind:"page",n:a});return o<t-1&&s.push({kind:"ellipsis",side:"right"}),s.push({kind:"page",n:t}),s}function bp({currentPage:e,totalItems:t,pageSize:s,onPageChange:n,itemNoun:o="devices"}){if(t<=s)return null;const a=Math.ceil(t/s),i=(e-1)*s+1,l=Math.min(e*s,t),u=gp(e,a);return(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle",children:[(0,r.jsxs)("span",{children:["Showing ",i,"–",l," of ",t," ",o]}),(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,r.jsx)("button",{type:"button","aria-label":"Previous page",disabled:e===1,onClick:()=>n(e-1),className:j("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:(0,r.jsx)(zd,{className:"h-3 w-3"})}),u.map((d,f)=>d.kind==="ellipsis"?(0,r.jsx)("span",{className:"px-1 text-foreground-subtle/60 select-none",children:"…"},`e-${f}`):(0,r.jsx)("button",{type:"button",onClick:()=>n(d.n),className:j("inline-flex items-center justify-center h-7 min-w-7 px-1.5 rounded border text-[10.5px] font-medium transition-colors",d.n===e?"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}`)),(0,r.jsx)("button",{type:"button","aria-label":"Next page",disabled:e===a,onClick:()=>n(e+1),className:j("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:(0,r.jsx)(mt,{className:"h-3 w-3"})})]})]})}function xp({view:e,onViewChange:t,types:s,currentType:n,onTypeChange:o,addons:a,currentAddon:i,onAddonChange:l,hideAddons:u=!1}){return(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsxs)("span",{className:"inline-flex border border-border rounded-md overflow-hidden",children:[(0,r.jsx)("button",{type:"button",onClick:()=>t("cards"),className:j("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:(0,r.jsx)(rf,{className:"h-3.5 w-3.5"})}),(0,r.jsx)("button",{type:"button",onClick:()=>t("table"),className:j("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:(0,r.jsx)(vf,{className:"h-3.5 w-3.5"})})]}),s&&s.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(wi,{children:"Type"}),(0,r.jsx)(rn,{active:n===null,onClick:()=>o(null),children:"All"}),s.map(d=>(0,r.jsx)(rn,{active:n===d,onClick:()=>o(n===d?null:d),children:vp(d)},d))]}),!u&&a&&a.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(wi,{children:"Integration"}),a.map(d=>(0,r.jsx)(rn,{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 wi({children:e}){return(0,r.jsx)("span",{className:"text-[10px] font-medium uppercase tracking-wider text-foreground-subtle ml-1",children:e})}function rn({active:e,icon:t,onClick:s,showClearIcon:n,children:o}){return(0,r.jsxs)("button",{type:"button",onClick:s,className:j("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&&(0,r.jsx)("span",{className:"inline-flex items-center",children:t}),(0,r.jsx)("span",{children:o}),e&&n&&(0,r.jsx)(Ee,{className:"h-2.5 w-2.5 opacity-70"})]})}function vp(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function yp({variant:e,onClearFilters:t}){return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,r.jsx)(ef,{className:"h-8 w-8 text-foreground-subtle/40 mb-3"}),(0,r.jsx)("p",{className:"text-sm font-medium text-foreground-subtle",children:e==="filtered"?"No devices match the current filters":"No devices yet"}),e==="filtered"&&t&&(0,r.jsx)("button",{type:"button",onClick:t,className:"mt-2 text-[11px] text-primary hover:underline",children:"Clear filters"})]})}function tt(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 Si(e){try{const t=localStorage.getItem(`camstack:${e}:lastFilters`);if(!t)return{};const s=JSON.parse(t);return typeof s!="object"||s===null?{}:s}catch{return{}}}function wp(e,t){try{localStorage.setItem(`camstack:${e}:lastFilters`,JSON.stringify(t))}catch{}}function ki(e,t,s){const n=new URLSearchParams(window.location.search),o=n.get(tt(e,"view")),a=o==="cards"||o==="table"?o:s.view??t,i=n.get(tt(e,"page")),l=i?parseInt(i,10):1;return{view:a,page:Number.isFinite(l)&&l>=1?l:1,addon:n.get(tt(e,"addon"))??s.addon??null,type:n.get(tt(e,"type"))??s.type??null,q:n.get(tt(e,"q"))??s.q??""}}function Sp(e,t,s){const n=new URLSearchParams(window.location.search),o=(l,u)=>{u===null||u===""?n.delete(l):n.set(l,u)};o(tt(e,"view"),t.view===s?null:t.view),o(tt(e,"page"),t.page===1?null:String(t.page)),o(tt(e,"addon"),t.addon),o(tt(e,"type"),t.type),o(tt(e,"q"),t.q||null);const a=n.toString(),i=a?`${window.location.pathname}?${a}`:window.location.pathname;window.history.replaceState(null,"",i)}function kp(e){const{scope:t,defaultView:s,lsKey:n}=e,[o,a]=(0,h.useState)(()=>ki(t,s,Si(n))),i=(0,h.useRef)(o);i.current=o,(0,h.useEffect)(()=>{const u=()=>{const d=ki(t,s,Si(n));i.current=d,a(d)};return window.addEventListener("popstate",u),()=>window.removeEventListener("popstate",u)},[t,s,n]);const l=(0,h.useCallback)(u=>{const d=u(i.current);i.current=d,a(d),Sp(t,d,s),wp(n,{view:d.view,addon:d.addon,type:d.type,q:d.q})},[t,s,n]);return{state:o,setView:(0,h.useCallback)(u=>l(d=>({...d,view:u})),[l]),setPage:(0,h.useCallback)(u=>l(d=>({...d,page:u})),[l]),setAddon:(0,h.useCallback)(u=>l(d=>({...d,addon:u,page:1})),[l]),setType:(0,h.useCallback)(u=>l(d=>({...d,type:u,page:1})),[l]),setQ:(0,h.useCallback)(u=>l(d=>({...d,q:u,page:1})),[l]),clearFilters:(0,h.useCallback)(()=>l(u=>({...u,addon:null,type:null,q:"",page:1})),[l])}}var jp={cards:24,table:50};function Np(e){const{devices:t,trpc:s,defaultView:n="table",filters:o,forceAddon:a,resolveIntegrationIcon:i,resolveParent:l,onNavigate:u,pageSize:d=jp,urlScope:f="root",lsKey:m=f==="root"?"devices":"integrations:nested"}=e,g=kp({scope:f,defaultView:n,lsKey:m}),b=g.state.view,x=b==="cards"?d.cards:d.table,[v,w]=(0,h.useState)(g.state.q),y=vi(v,300);(0,h.useEffect)(()=>{y!==g.state.q&&g.setQ(y)},[y]);const S=a??g.state.addon,k=(0,h.useMemo)(()=>{const ae=g.state.q.toLowerCase().trim();return t.filter(ce=>!(S&&ce.addonId!==S||g.state.type&&ce.type!==g.state.type||ae&&!ce.name.toLowerCase().includes(ae)&&!ce.stableId.toLowerCase().includes(ae)))},[t,S,g.state.type,g.state.q]),C=(0,h.useMemo)(()=>hp(k),[k]),N=(0,h.useMemo)(()=>{if(g.state.q.trim()==="")return new Set;const ae=g.state.q.toLowerCase().trim(),ce=new Set;for(const[se,J]of C.accessoriesByParent.entries())J.some(H=>H.name.toLowerCase().includes(ae)||H.stableId.toLowerCase().includes(ae))&&ce.add(se);return ce},[C.accessoriesByParent,g.state.q]),E=C.topLevel.length,R=Math.max(1,Math.ceil(E/x)),A=Math.min(g.state.page,R),Q=(A-1)*x,ee=C.topLevel.slice(Q,Q+x);(0,h.useEffect)(()=>{A!==g.state.page&&g.setPage(A)},[A]),Rp();const ne=S!=null||g.state.type!==null||g.state.q!=="",pe=E===0;return(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,r.jsx)(xp,{view:b,onViewChange:g.setView,types:o?.types,currentType:g.state.type,onTypeChange:g.setType,addons:o?.addons,currentAddon:g.state.addon,onAddonChange:g.setAddon,hideAddons:a!==void 0}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(ar,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle pointer-events-none"}),(0,r.jsx)("input",{type:"text",value:v,onChange:ae=>w(ae.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"})]})]}),pe?(0,r.jsx)(yp,{variant:ne?"filtered":"nofilter",onClearFilters:ne?g.clearFilters:void 0}):b==="cards"?(0,r.jsx)(Cp,{rows:ee,accessoriesByParent:C.accessoriesByParent,trpc:s,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:u??null}):(0,r.jsx)(Ap,{rows:ee,accessoriesByParent:C.accessoriesByParent,autoExpandedParents:N,devices:k,trpc:s,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:u??null}),(0,r.jsx)(bp,{currentPage:A,totalItems:E,pageSize:x,onPageChange:g.setPage}),a===void 0&&ne&&E>0&&(0,r.jsxs)("p",{className:"text-[11px] text-foreground-subtle",children:["Showing ",E," of ",t.length," devices",S&&(0,r.jsxs)(r.Fragment,{children:[" ","· filtered by"," ",(0,r.jsx)("strong",{className:"text-primary",children:o?.addons?.find(ae=>ae.id===S)?.name??S})]})]})]})}function Cp({rows:e,accessoriesByParent:t,trpc:s,resolveIntegrationIcon:n,resolveParent:o,onNavigate:a}){return(0,r.jsx)("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(0,r.jsx)(Ur,{trpc:s,device:i,view:"card",integrationIcon:n?.(i.addonId)??null,parent:i.parentDeviceId!==null?o?.(i.parentDeviceId)??null:null,children:l,onNavigate:a??void 0},i.id)})})}var Mp=new Set(["hub","nvr"]);function Ep(e,t){return e.parentDeviceId===null||t===null?0:Mp.has(t.toLowerCase())?1:0}function Ap({rows:e,accessoriesByParent:t,autoExpandedParents:s,devices:n,trpc:o,resolveIntegrationIcon:a,resolveParent:i,onNavigate:l}){const u=(0,h.useMemo)(()=>{const d=new Map;for(const f of n)d.set(f.id,f.type);return d},[n]);return(0,r.jsx)("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:(0,r.jsxs)("table",{className:"w-full border-collapse",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"border-b border-border",children:[(0,r.jsx)("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle",children:"Name"}),(0,r.jsx)("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-24",children:"Type"}),(0,r.jsx)("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Features"}),(0,r.jsx)("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-20",children:"Preview"}),(0,r.jsx)("th",{className:"text-right px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:e.map(d=>{const f=t.get(d.id)??[],m=f.length>0,g=s.has(d.id),b=d.parentDeviceId!==null?i?.(d.parentDeviceId)??null:null,x=d.parentDeviceId!==null?u.get(d.parentDeviceId)??null:null;return(0,r.jsx)(Pp,{parent:d,accessories:f,hasAccessories:m,forceExpanded:g,trpc:o,integrationIcon:a?.(d.addonId)??null,parentRowParent:b,indentLevel:Ep(d,x),onNavigate:l??null},d.id)})})]})})}function Pp({parent:e,accessories:t,hasAccessories:s,forceExpanded:n,trpc:o,integrationIcon:a,parentRowParent:i,indentLevel:l,onNavigate:u}){const[d,f]=(0,h.useState)(n),m=(0,h.useRef)(n);(0,h.useEffect)(()=>{m.current!==n&&(f(n),m.current=n)},[n]);const g=()=>f(b=>!b);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ur,{trpc:o,device:e,view:"table",integrationIcon:a,parent:i,children:t,onNavigate:u??void 0,showChildrenAccordion:s,expanded:d,onToggleExpand:g,indentLevel:l}),s&&d&&t.map(b=>(0,r.jsx)(Ur,{trpc:o,device:b,view:"table",integrationIcon:null,parent:null,isAccessoryRow:!0,showChildrenAccordion:!1,onNavigate:u??void 0},b.id))]})}function Rp(){(0,Ae.useQueryClient)()}function Dp({options:e,value:t,onChange:s}){return(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:e.map(n=>{const o=n.id===t;return(0,r.jsxs)("button",{onClick:()=>n.available&&s(n.id),disabled:!n.available,className:`flex items-center gap-2 rounded-lg border px-3 py-2 text-xs font-medium transition-all ${o?"border-primary/40 bg-primary/10 text-primary":n.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:[(0,r.jsx)(Zd,{className:"h-3.5 w-3.5 shrink-0"}),n.label,n.isBest&&(0,r.jsxs)("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:[(0,r.jsx)(xf,{className:"h-2.5 w-2.5"}),"Best"]}),n.platformScore!=null&&(0,r.jsxs)("span",{className:"text-[10px] text-foreground-subtle/60",children:["(",n.platformScore,")"]}),(0,r.jsx)("span",{className:`h-1.5 w-1.5 rounded-full ${n.available?"bg-success":"bg-danger"}`})]},n.id)})})}function Tp(e,t){const s=new Set(t.slots.flatMap(i=>i.addons.map(l=>l.id))),n=[];function o(i){if(!s.has(i.addonId))return n.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 u=i.modelId;if(l&&!l.models.some(f=>f.id===u)){const f=l.defaultModelId;n.push(`Model "${u}" not available for ${i.addonId} — using "${f}"`),u=f}const d=i.children.map(f=>o(f)).filter(f=>f!==null);return{...i,modelId:u,children:d}}const a=e.map(i=>o(i)).filter(i=>i!==null);return{valid:n.length===0,steps:a,warnings:n}}function Ip(e){const t=new Map;for(const s of e.slots)for(const n of s.addons)t.set(n.id,n);return t}function sn(e){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:!0,modelId:e.defaultModelId,children:[]}}function nn({addon:e,onClick:t}){return(0,r.jsx)("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:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(Wd,{className:"h-[18px] w-[18px] text-foreground-subtle/30 group-hover:text-primary/60 shrink-0"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"text-[13px] font-medium text-foreground-subtle/50 group-hover:text-foreground-subtle block truncate",children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(s=>(0,r.jsx)("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:s},s)),e.inputClasses.length>0&&e.outputClasses.length>0&&(0,r.jsx)("span",{className:"text-foreground-subtle/25 text-[10px]",children:"→"}),e.outputClasses.map(s=>(0,r.jsx)("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:s},s))]})]})]})})}function Lp({schema:e,steps:t,onChange:s,templates:n,selectedTemplateId:o,onSelectTemplate:a,onSaveTemplate:i,onUpdateTemplate:l,onDeleteTemplate:u,readOnly:d=!1,excludeAddons:f=[],hideTemplates:m=!1,showOnlyEnabled:g=!1,showSlotLabels:b=!1,toggleMode:x="simple",overrides:v={},onOverrideChange:w,inheritedEnabledByAddon:y={},hideModelAndSettings:S=!1}){const k=$=>({toggleMode:x,hideModelAndSettings:S,...x==="threeState"?{overrideState:v[$]!==void 0?v[$]:null,onOverrideChange:w?_=>w($,_):void 0,inheritedEnabled:y[$]}:{}}),C=(0,h.useMemo)(()=>new Set(f),[f]),N=(0,h.useMemo)(()=>Ip(e),[e]),[E,R]=(0,h.useState)([]),A=o?JSON.stringify(t)!==JSON.stringify(n.find($=>$.id===o)?.steps):!1;function Q($){const _=$.target.value||null;if(_){const te=n.find(U=>U.id===_);te&&R([...Tp(te.steps,e).warnings])}else R([]);a(_)}function ee(){o&&l(o,t)}function ne(){const $=window.prompt("Template name:");$?.trim()&&i($.trim(),t)}function pe(){if(!o)return;const $=n.find(_=>_.id===o);$&&window.confirm(`Delete template "${$.name}"?`)&&u(o)}function ae($){s(t.map(_=>_.addonId!==$.addonId?_:ce($)))}function ce($){const _=$.children.some(te=>te.enabled||te.children.some(U=>U.enabled));return{...$,enabled:$.enabled||_,children:$.children.map(te=>{const U=te.children.some(V=>V.enabled);return{...te,enabled:te.enabled||U}})}}function se($,_){const te=sn(_);s(t.map(U=>U.addonId!==$?U:{...U,children:[...U.children,te]}))}function J($){const _=new Set;for(const te of $){_.add(te.addonId);for(const V of te.children)_.add(V.addonId);const U=J(te.children);for(const V of U)_.add(V)}return _}const H=J(t);function xe($){const _=N.get($.addonId);if(!_)return[];const te=e.slots.find(z=>z.id===_.slot)?.parentSlot==null,U=_.childSlots,V=new Set($.children.map(z=>z.addonId)),W=[];for(const z of e.slots)if(U.includes(z.id))for(const X of z.addons){if(V.has(X.id)||C.has(X.id))continue;const q=X.inputClasses.length===0;q&&!te||(q||X.inputClasses.some(Re=>$.outputClasses.includes(Re)))&&W.push(X)}return W}function de($){const _=g?{...$,children:$.children.filter(U=>U.enabled).map(U=>({...U,children:U.children.filter(V=>V.enabled)}))}:$,te=g?[]:xe(_);return(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(Br,{step:_,schema:N.get(_.addonId)??null,allSchemas:N,onChange:ae,onDelete:d?void 0:U=>s(t.filter(V=>V.addonId!==U)),readOnly:d,...k(_.addonId)}),(_.children.length>0||te.length>0)&&(0,r.jsxs)("div",{className:"ml-4 pl-3 border-l border-border/60 space-y-1.5",children:[b&&(0,r.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/40",children:"Slot: Cropper / Classifier"}),_.children.map(U=>{const V=xe(U);return(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(Br,{step:U,schema:N.get(U.addonId)??null,allSchemas:N,depth:1,onChange:W=>{ae({..._,children:_.children.map(z=>z.addonId===W.addonId?W:z)})},onDelete:d?void 0:W=>{ae({..._,children:_.children.filter(z=>z.addonId!==W)})},readOnly:d,...k(U.addonId)}),(U.children.length>0||V.length>0)&&(0,r.jsxs)("div",{className:"ml-4 pl-3 border-l border-border/40 space-y-1.5",children:[b&&(0,r.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/30",children:"Slot: Recognizer"}),U.children.map(W=>(0,r.jsx)(Br,{step:W,schema:N.get(W.addonId)??null,allSchemas:N,depth:2,onChange:z=>{ae({..._,children:_.children.map(X=>X.addonId===U.addonId?{...X,children:X.children.map(q=>q.addonId===z.addonId?z:q)}:X)})},onDelete:d?void 0:z=>{ae({..._,children:_.children.map(X=>X.addonId===U.addonId?{...X,children:X.children.filter(q=>q.addonId!==z)}:X)})},readOnly:d,...k(W.addonId)},W.addonId)),!d&&V.map(W=>(0,r.jsx)(nn,{addon:W,onClick:()=>{const z=sn(W);ae({..._,children:_.children.map(X=>X.addonId===U.addonId?{...X,children:[...X.children,z]}:X)})}},W.id))]})]},U.addonId)}),!d&&te.map(U=>(0,r.jsx)(nn,{addon:U,onClick:()=>se(_.addonId,U)},U.id))]})]},_.addonId)}const D=e.slots.filter($=>$.parentSlot===null).sort(($,_)=>$.priority-_.priority);return(0,r.jsxs)("div",{className:"space-y-4",children:[!m&&(0,r.jsx)("div",{className:"rounded-lg border border-border bg-surface p-3",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"relative flex-1 min-w-0",children:(0,r.jsxs)("select",{value:o??"",onChange:Q,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:[(0,r.jsx)("option",{value:"",children:"No template"}),n.map($=>(0,r.jsx)("option",{value:$.id,children:$.name},$.id))]})}),A&&(0,r.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500 shrink-0"}),(0,r.jsx)("button",{onClick:ee,disabled:!o||d,title:"Save",className:j("p-2 rounded-lg border border-border transition-colors",o&&!d?"text-foreground-subtle hover:bg-surface-hover":"text-foreground-subtle/30 cursor-not-allowed"),children:(0,r.jsx)(df,{className:"h-4 w-4"})}),(0,r.jsx)("button",{onClick:ne,disabled:d,title:"Save As",className:j("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:(0,r.jsx)(Kd,{className:"h-4 w-4"})}),(0,r.jsx)("button",{onClick:pe,disabled:!o||d,title:"Delete",className:j("p-2 rounded-lg border border-border transition-colors",o&&!d?"text-foreground-subtle hover:text-danger":"text-foreground-subtle/30 cursor-not-allowed"),children:(0,r.jsx)(et,{className:"h-4 w-4"})})]})}),E.length>0&&(0,r.jsxs)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 text-xs text-amber-400 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"font-medium",children:"Template loaded with warnings:"}),(0,r.jsx)("button",{onClick:()=>R([]),className:"text-amber-400/60 hover:text-amber-400",children:(0,r.jsx)(Ee,{className:"h-3.5 w-3.5"})})]}),E.map(($,_)=>(0,r.jsxs)("div",{children:["• ",$]},_))]}),D.map($=>{const _=t.filter(z=>z.slot===$.id&&!C.has(z.addonId)),te=g?_.filter(z=>z.enabled):_,U=g?[]:$.addons.filter(z=>!H.has(z.id)&&!C.has(z.id)),V=new Map,W=[];for(const z of te)z.group?(V.has(z.group)||V.set(z.group,[]),V.get(z.group).push(z)):W.push(z);return(0,r.jsxs)("div",{className:"space-y-2",children:[b&&(0,r.jsxs)("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50",children:["Slot: ",$.label]}),W.map(z=>de(z)),[...V.entries()].map(([z,X])=>(0,r.jsxs)("div",{className:"space-y-2 rounded-lg border border-border/40 p-2",children:[(0,r.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50 px-1",children:z}),X.map(q=>de(q))]},z)),!d&&U.map(z=>(0,r.jsx)(nn,{addon:z,onClick:()=>{s([...t,sn(z)])}},z.id))]},$.id)})]})}var fr={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"},ji=["#ef4444","#8b5cf6","#06b6d4","#f97316","#10b981","#6366f1","#e11d48","#0891b2","#7c3aed","#059669"],Op="#f59e42";function _e(e,t){if(t?.[e])return t[e];if(t?.[e.toLowerCase()])return t[e.toLowerCase()];if(fr[e])return fr[e];if(fr[e.toLowerCase()])return fr[e.toLowerCase()];let s=0;for(let n=0;n<e.length;n++)s=s*31+(e.codePointAt(n)??0)>>>0;return ji[s%ji.length]??"#f59e42"}function _p({src:e,imageWidth:t,imageHeight:s,detections:n=[],classColors:o,aspectRatio:a,className:i,placeholder:l,showConfidence:u=!0,minConfidence:d=0,borderWidth:f=2}){function m(y){return _e(y,o)}const g=a??(t&&s?`${t}/${s}`:"16/9"),b=n.filter(y=>y.score>=d),x=b.filter(y=>y.kind==="first-level"),v=b.filter(y=>y.kind==="detail"),w=Bp(v,y=>y.parentId??"");return(0,r.jsx)("div",{className:j("rounded-lg border border-border bg-surface overflow-hidden relative",i),style:{aspectRatio:g},children:e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("img",{src:e,className:"absolute inset-0 w-full h-full object-fill",alt:""}),b.map((y,S)=>y.debug?.mask&&y.debug.maskWidth&&y.debug.maskHeight?(0,r.jsx)($p,{mask:y.debug.mask,maskWidth:y.debug.maskWidth,maskHeight:y.debug.maskHeight,bbox:y.bbox,imageWidth:t,imageHeight:s,color:m(y.macroClass)},`mask-${S}`):null),x.map(y=>{const S=w.get(y.id)??[];return(0,r.jsx)(Ni,{detection:y,imageWidth:t,imageHeight:s,color:m(y.macroClass),showConfidence:u,borderWidth:y.debug?.mask?1:f,children:S.map(k=>(0,r.jsx)(Gp,{child:k,parentBbox:y.bbox,color:m(k.macroClass),showConfidence:u},`child-${k.id}`))},`det-${y.id}`)}),v.filter(y=>!y.parentId||!x.some(S=>S.id===y.parentId)).map(y=>(0,r.jsx)(Ni,{detection:y,imageWidth:t,imageHeight:s,color:m(y.macroClass),showConfidence:u,borderWidth:f},`orphan-${y.id}`))]}):(0,r.jsx)("div",{className:"w-full h-full flex items-center justify-center text-foreground-subtle text-sm",children:l??"No image loaded"})})}function Ni({detection:e,imageWidth:t,imageHeight:s,color:n,showConfidence:o,borderWidth:a,children:i}){const{x:l,y:u,width:d,height:f}=e.bbox,m=(0,r.jsxs)("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"2px"},children:[(0,r.jsxs)("span",{className:"text-[10px] px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:n},children:[e.macroClass,o&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((g,b)=>(0,r.jsxs)("span",{className:"text-[9px] font-semibold px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:_e(g.label)},children:[g.label," ",(g.score*100).toFixed(0),"%"]},`${e.id}-lbl-${b}`))]});return(0,r.jsxs)("div",{className:"absolute rounded-sm",style:{left:`${l/t*100}%`,top:`${u/s*100}%`,width:`${d/t*100}%`,height:`${f/s*100}%`,borderWidth:`${a}px`,borderStyle:"solid",borderColor:n},children:[m,i]})}function $p({mask:e,maskWidth:t,maskHeight:s,bbox:n,imageWidth:o,imageHeight:a,color:i}){const l=(0,h.useRef)(null);return(0,h.useEffect)(()=>{const u=l.current;if(!u)return;const d=u.getContext("2d");if(!d)return;const f=atob(e),m=new Uint8Array(f.length);for(let y=0;y<f.length;y++)m[y]=f.charCodeAt(y);const g=parseInt(i.slice(1,3),16),b=parseInt(i.slice(3,5),16),x=parseInt(i.slice(5,7),16);u.width=t,u.height=s;const v=d.createImageData(t,s),w=t*s;for(let y=0;y<w;y++){const S=y<m.length?m[y]:0,k=y*4;S>0&&(v.data[k]=g,v.data[k+1]=b,v.data[k+2]=x,v.data[k+3]=120)}d.putImageData(v,0,0)},[e,t,s,i]),(0,r.jsx)("canvas",{ref:l,className:"absolute pointer-events-none",style:{left:`${n.x/o*100}%`,top:`${n.y/a*100}%`,width:`${n.width/o*100}%`,height:`${n.height/a*100}%`,imageRendering:"pixelated"}})}function Gp({child:e,parentBbox:t,color:s,showConfidence:n}){if(t.width<=0||t.height<=0)return null;const o=(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(0,r.jsx)("div",{className:"absolute rounded-sm",style:{left:`${Math.max(0,o)}%`,top:`${Math.max(0,a)}%`,width:`${Math.min(100,i)}%`,height:`${Math.min(100,l)}%`,borderWidth:"1px",borderStyle:"solid",borderColor:s},children:(0,r.jsxs)("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"1px"},children:[(0,r.jsxs)("span",{className:"text-[9px] px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:s},children:[e.macroClass,n&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((u,d)=>(0,r.jsxs)("span",{className:"text-[8px] font-semibold px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:_e(u.label)},children:[u.label," ",(u.score*100).toFixed(0),"%"]},`${e.id}-lbl-${d}`))]})})}function Bp(e,t){const s=new Map;for(const n of e){const o=t(n),a=s.get(o)??[];a.push(n),s.set(o,a)}return s}function Fp({detections:e,classColors:t,className:s,hiddenKeys:n,onToggleVisibility:o}){const a=t;if(e.length===0)return(0,r.jsx)("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"),u=new Map;for(const f of l){if(!f.parentId)continue;const m=u.get(f.parentId)??[];m.push(f),u.set(f.parentId,m)}const d=l.filter(f=>!f.parentId||!i.some(m=>m.id===f.parentId));return(0,r.jsxs)("div",{className:s,children:[(0,r.jsxs)("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Detections (",e.length,")"]}),(0,r.jsxs)("div",{className:"space-y-2",children:[i.map(f=>(0,r.jsx)(Ci,{detection:f,children_:u.get(f.id)??[],colors:a,hiddenKeys:n,onToggleVisibility:o},f.id)),d.map(f=>(0,r.jsx)(Ci,{detection:f,children_:[],colors:a,hiddenKeys:n,onToggleVisibility:o},f.id))]})]})}function Ci({detection:e,children_:t,colors:s,hiddenKeys:n,onToggleVisibility:o}){const a=_e(e.macroClass,s),i=!n?.has(e.id),l=e.debug?.mask,u=e.debug?.maskWidth,d=e.debug?.maskHeight,f=e.debug?.alternateLabels;return(0,r.jsxs)("div",{className:`rounded-md border border-border bg-surface p-3 space-y-1 ${i?"":"opacity-40"}`,children:[(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[o&&(0,r.jsx)("input",{type:"checkbox",checked:i,onChange:()=>o(e.id,!i),className:"h-3.5 w-3.5 rounded border-border accent-primary cursor-pointer shrink-0"}),(0,r.jsx)("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:a}}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:e.macroClass}),e.kind==="detail"&&(0,r.jsx)("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:"detail"}),l&&u&&d&&(0,r.jsxs)("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",u,"x",d]})]}),(0,r.jsx)(Up,{confidence:e.score})]}),(0,r.jsxs)("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&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:e.labels.map((m,g)=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{backgroundColor:_e(m.label,s)+"20",color:_e(m.label,s)},children:[m.label,(0,r.jsxs)("span",{className:"opacity-60",children:[(m.score*100).toFixed(0),"%"]}),m.detectionId&&(0,r.jsxs)("span",{className:"opacity-40 text-[8px]",children:["→ ",m.detectionId]})]},g))}),f&&Object.keys(f).length>0&&(0,r.jsx)(Qp,{alternateLabels:f,colors:s}),t.length>0&&(0,r.jsx)(zp,{items:t,colors:s,hiddenKeys:n,onToggleVisibility:o})]})}function zp({items:e,colors:t,hiddenKeys:s,onToggleVisibility:n}){return(0,r.jsx)("div",{className:"ml-4 mt-1.5 space-y-1.5 border-l-2 border-border pl-3",children:e.map(o=>{const a=_e(o.macroClass,t),i=!s?.has(o.id),l=o.debug?.mask,u=o.debug?.maskWidth,d=o.debug?.maskHeight;return(0,r.jsxs)("div",{className:`text-xs space-y-0.5 ${i?"":"opacity-40"}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[n&&(0,r.jsx)("input",{type:"checkbox",checked:i,onChange:()=>n(o.id,!i),className:"h-3 w-3 rounded border-border accent-primary cursor-pointer shrink-0"}),(0,r.jsx)("span",{className:"h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:a}}),(0,r.jsx)("span",{className:"font-medium",style:{color:a},children:o.macroClass}),(0,r.jsxs)("span",{className:"text-foreground-subtle",children:[(o.score*100).toFixed(0),"%"]}),l&&u&&d&&(0,r.jsxs)("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",u,"x",d]})]}),o.labels.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1 ml-5 mt-0.5",children:o.labels.map((f,m)=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-medium px-1 py-0.5 rounded-full",style:{backgroundColor:_e(f.label,t)+"20",color:_e(f.label,t)},children:[f.label," ",(0,r.jsxs)("span",{className:"opacity-60",children:[(f.score*100).toFixed(0),"%"]})]},m))})]},o.id)})})}function Qp({alternateLabels:e,colors:t}){const[s,n]=(0,h.useState)(!1),o=Object.keys(e);return(0,r.jsxs)("div",{className:"mt-1",children:[(0,r.jsxs)("button",{onClick:()=>n(a=>!a),className:"text-[9px] text-foreground-subtle hover:text-foreground transition-colors flex items-center gap-1",children:[(0,r.jsx)("span",{className:`transition-transform ${s?"rotate-90":""}`,children:"▶"}),"Alternates (",o.length," source",o.length!==1?"s":"",")"]}),s&&(0,r.jsx)("div",{className:"mt-1 ml-3 space-y-1.5",children:o.map(a=>{const i=e[a];return!i||i.length===0?null:(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[9px] font-medium text-foreground-subtle mb-0.5",children:a}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:i.map((l,u)=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[9px] px-1 py-0.5 rounded-full",style:{backgroundColor:_e(a,t)+"10",color:_e(a,t),opacity:Math.max(.4,l.score)},children:[l.label,(0,r.jsxs)("span",{className:"opacity-60",children:[(l.score*100).toFixed(1),"%"]})]},u))})]},a)})})]})}function Up({confidence:e}){return(0,r.jsxs)("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${e>=.8?"bg-success/10 text-success":e>=.5?"bg-warning/10 text-warning":"bg-danger/10 text-danger"}`,children:[(e*100).toFixed(1),"%"]})}function Hp({timings:e,totalMs:t,className:s}){const n=Object.entries(e);return n.length===0&&t===void 0?null:(0,r.jsxs)("div",{className:`rounded-lg border border-border bg-surface p-3 space-y-2 ${s??""}`,children:[(0,r.jsx)("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide",children:"Timings"}),(0,r.jsxs)("div",{className:"space-y-1 text-xs",children:[n.map(([o,a])=>(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{className:"text-foreground-subtle",children:o}),(0,r.jsxs)("span",{className:"font-mono text-foreground",children:[a.toFixed(1),"ms"]})]},o)),t!==void 0&&(0,r.jsxs)("div",{className:"flex justify-between pt-1 border-t border-border font-medium text-foreground",children:[(0,r.jsx)("span",{children:"Total"}),(0,r.jsxs)("span",{className:"font-mono",children:[t.toFixed(1),"ms"]})]})]})]})}function Vp({images:e,selectedFilename:t,uploadedName:s,onSelect:n,onUpload:o,className:a,accept:i="image/*",uploadLabel:l="Upload..."}){const u=()=>{const d=document.createElement("input");d.type="file",d.accept=i,d.onchange=()=>{const f=d.files?.[0];if(!f)return;const m=new FileReader;m.onload=()=>{const g=m.result,b=g.split(",")[1];b&&o(b,f.name,g)},m.readAsDataURL(f)},d.click()};return(0,r.jsxs)("div",{className:`flex flex-wrap items-center gap-2 ${a??""}`,children:[e.map(d=>(0,r.jsx)("button",{onClick:()=>n(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)),(0,r.jsx)("button",{onClick:u,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}),s&&(0,r.jsx)("span",{className:"text-xs text-foreground-subtle",children:s})]})}var Hr="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 Wp({runtime:e,backend:t,modelId:s,agentId:n="hub",runtimes:o,backends:a,models:i,agents:l=[],onRuntimeChange:u,onBackendChange:d,onModelChange:f,onAgentChange:m,layout:g="grid",className:b,showAgent:x=!1}){return(0,r.jsxs)("div",{className:`${g==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4":g==="horizontal"?"flex flex-wrap items-end gap-4":"space-y-3"} ${b??""}`,children:[x&&l.length>0&&(0,r.jsxs)("label",{className:"space-y-1",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-foreground-subtle",children:"Agent"}),(0,r.jsx)("select",{value:n,onChange:v=>m?.(v.target.value),className:Hr,children:l.map(v=>(0,r.jsxs)("option",{value:v.id,children:[v.name," (",v.status,")"]},v.id))})]}),(0,r.jsxs)("label",{className:"space-y-1",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-foreground-subtle",children:"Runtime"}),(0,r.jsx)("select",{value:e,onChange:v=>u(v.target.value),className:Hr,children:o.map(v=>(0,r.jsxs)("option",{value:v.value,disabled:!v.available,children:[v.label,v.available?"":" (unavailable)"]},v.value))})]}),(0,r.jsxs)("label",{className:"space-y-1",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-foreground-subtle",children:"Backend"}),(0,r.jsx)("select",{value:t,onChange:v=>d(v.target.value),className:Hr,children:a.map(v=>(0,r.jsxs)("option",{value:v.id,disabled:!v.available,children:[v.label,v.available?"":" (unavailable)"]},v.id))})]}),(0,r.jsxs)("label",{className:"space-y-1",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-foreground-subtle",children:"Model"}),(0,r.jsx)("select",{value:s,onChange:v=>f(v.target.value),className:Hr,children:i.length===0?(0,r.jsx)("option",{value:"",children:"No compatible models"}):i.map(v=>(0,r.jsxs)("option",{value:v.id,children:[v.name,v.downloaded?" ✓":""]},v.id))})]})]})}var qp=class{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,t){this.keyToValue.set(e,t),this.valueToKey.set(t,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}},Mi=class{constructor(e){this.generateIdentifier=e,this.kv=new qp}register(e,t){this.kv.getByValue(e)||(t||(t=this.generateIdentifier(e)),this.kv.set(t,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}},Kp=class extends Mi{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,t){typeof t=="object"?(t.allowProps&&this.classToAllowedProps.set(e,t.allowProps),super.register(e,t.identifier)):super.register(e,t)}getAllowedProps(e){return this.classToAllowedProps.get(e)}};function Zp(e){if("values"in Object)return Object.values(e);const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push(e[s]);return t}function Yp(e,t){const s=Zp(e);if("find"in s)return s.find(t);const n=s;for(let o=0;o<n.length;o++){const a=n[o];if(t(a))return a}}function Ft(e,t){Object.entries(e).forEach(([s,n])=>t(n,s))}function Vr(e,t){return e.indexOf(t)!==-1}function Ei(e,t){for(let s=0;s<e.length;s++){const n=e[s];if(t(n))return n}}var Xp=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return Yp(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},Jp=e=>Object.prototype.toString.call(e).slice(8,-1),Ai=e=>typeof e>"u",eh=e=>e===null,mr=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,on=e=>mr(e)&&Object.keys(e).length===0,ht=e=>Array.isArray(e),th=e=>typeof e=="string",rh=e=>typeof e=="number"&&!isNaN(e),sh=e=>typeof e=="boolean",nh=e=>e instanceof RegExp,pr=e=>e instanceof Map,hr=e=>e instanceof Set,Pi=e=>Jp(e)==="Symbol",oh=e=>e instanceof Date&&!isNaN(e.valueOf()),Ri=e=>e instanceof Error,Di=e=>typeof e=="number"&&isNaN(e),ah=e=>sh(e)||eh(e)||Ai(e)||rh(e)||th(e)||Pi(e),ih=e=>typeof e=="bigint",lh=e=>e===1/0||e===-1/0,ch=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),uh=e=>e instanceof URL,an=e=>e.replace(/\\/g,"\\\\").replace(/\./g,"\\."),ln=e=>e.map(String).map(an).join("."),gr=(e,t)=>{const s=[];let n="";for(let a=0;a<e.length;a++){let i=e.charAt(a);if(!t&&i==="\\"){const l=e.charAt(a+1);if(l==="\\"){n+="\\",a++;continue}else if(l!==".")throw Error("invalid path")}if(i==="\\"&&e.charAt(a+1)==="."){n+=".",a++;continue}if(i==="."){s.push(n),n="";continue}n+=i}const o=n;return s.push(o),s};function rt(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var Ti=[rt(Ai,"undefined",()=>null,()=>{}),rt(ih,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):(console.error("Please add a BigInt polyfill."),e)),rt(oh,"Date",e=>e.toISOString(),e=>new Date(e)),rt(Ri,"Error",(e,t)=>{const s={name:e.name,message:e.message};return"cause"in e&&(s.cause=e.cause),t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s},(e,t)=>{const s=new Error(e.message,{cause:e.cause});return s.name=e.name,s.stack=e.stack,t.allowedErrorProps.forEach(n=>{s[n]=e[n]}),s}),rt(nh,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),s=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,s)}),rt(hr,"set",e=>[...e.values()],e=>new Set(e)),rt(pr,"map",e=>[...e.entries()],e=>new Map(e)),rt(e=>Di(e)||lh(e),"number",e=>Di(e)?"NaN":e>0?"Infinity":"-Infinity",Number),rt(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),rt(uh,"URL",e=>e.toString(),e=>new URL(e))];function Wr(e,t,s,n){return{isApplicable:e,annotation:t,transform:s,untransform:n}}var Ii=Wr((e,t)=>Pi(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,s)=>{const n=s.symbolRegistry.getValue(t[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),dh=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),Li=Wr(ch,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const s=dh[t[1]];if(!s)throw new Error("Trying to deserialize unknown typed array");return new s(e)});function Oi(e,t){return e?.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var _i=Wr(Oi,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const s=t.classRegistry.getAllowedProps(e.constructor);if(!s)return{...e};const n={};return s.forEach(o=>{n[o]=e[o]}),n},(e,t,s)=>{const n=s.classRegistry.getValue(t[1]);if(!n)throw new Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(n.prototype),e)}),$i=Wr((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,s)=>{const n=s.customTransformerRegistry.findByName(t[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(e)}),fh=[_i,Ii,$i,Li],Gi=(e,t)=>{const s=Ei(fh,o=>o.isApplicable(e,t));if(s)return{value:s.transform(e,t),type:s.annotation(e,t)};const n=Ei(Ti,o=>o.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},Bi={};Ti.forEach(e=>{Bi[e.annotation]=e});var mh=(e,t,s)=>{if(ht(t))switch(t[0]){case"symbol":return Ii.untransform(e,t,s);case"class":return _i.untransform(e,t,s);case"custom":return $i.untransform(e,t,s);case"typed-array":return Li.untransform(e,t,s);default:throw new Error("Unknown transformation: "+t)}else{const n=Bi[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,s)}},zt=(e,t)=>{if(t>e.size)throw new Error("index out of bounds");const s=e.keys();for(;t>0;)s.next(),t--;return s.next().value};function Fi(e){if(Vr(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Vr(e,"prototype"))throw new Error("prototype is not allowed as a property");if(Vr(e,"constructor"))throw new Error("constructor is not allowed as a property")}var ph=(e,t)=>{Fi(t);for(let s=0;s<t.length;s++){const n=t[s];if(hr(e))e=zt(e,+n);else if(pr(e)){const o=+n,a=+t[++s]==0?"key":"value",i=zt(e,o);switch(a){case"key":e=i;break;case"value":e=e.get(i);break}}else e=e[n]}return e},cn=(e,t,s)=>{if(Fi(t),t.length===0)return s(e);let n=e;for(let a=0;a<t.length-1;a++){const i=t[a];if(ht(n)){const l=+i;n=n[l]}else if(mr(n))n=n[i];else if(hr(n)){const l=+i;n=zt(n,l)}else if(pr(n)){if(a===t.length-2)break;const l=+i,u=+t[++a]==0?"key":"value",d=zt(n,l);switch(u){case"key":n=d;break;case"value":n=n.get(d);break}}}const o=t[t.length-1];if(ht(n)?n[+o]=s(n[+o]):mr(n)&&(n[o]=s(n[o])),hr(n)){const a=zt(n,+o),i=s(a);a!==i&&(n.delete(a),n.add(i))}if(pr(n)){const a=+t[t.length-2],i=zt(n,a);switch(+o==0?"key":"value"){case"key":{const l=s(i);n.set(l,n.get(i)),l!==i&&n.delete(i);break}case"value":n.set(i,s(n.get(i)));break}}return e},zi=e=>e<1;function un(e,t,s,n=[]){if(!e)return;const o=zi(s);if(!ht(e)){Ft(e,(l,u)=>un(l,t,s,[...n,...gr(u,o)]));return}const[a,i]=e;i&&Ft(i,(l,u)=>{un(l,t,s,[...n,...gr(u,o)])}),t(a,n)}function hh(e,t,s,n){return un(t,(o,a)=>{e=cn(e,a,i=>mh(i,o,n))},s),e}function gh(e,t,s){const n=zi(s);function o(a,i){const l=ph(e,gr(i,n));a.map(u=>gr(u,n)).forEach(u=>{e=cn(e,u,()=>l)})}if(ht(t)){const[a,i]=t;a.forEach(l=>{e=cn(e,gr(l,n),()=>e)}),i&&Ft(i,o)}else Ft(t,o);return e}var bh=(e,t)=>mr(e)||ht(e)||pr(e)||hr(e)||Ri(e)||Oi(e,t);function xh(e,t,s){const n=s.get(e);n?n.push(t):s.set(e,[t])}function vh(e,t){const s={};let n;return e.forEach(o=>{if(o.length<=1)return;t||(o=o.map(l=>l.map(String)).sort((l,u)=>l.length-u.length));const[a,...i]=o;a.length===0?n=i.map(ln):s[ln(a)]=i.map(ln)}),n?on(s)?[n]:[n,s]:on(s)?void 0:s}var Qi=(e,t,s,n,o=[],a=[],i=new Map)=>{const l=ah(e);if(!l){xh(e,o,t);const b=i.get(e);if(b)return n?{transformedValue:null}:b}if(!bh(e,s)){const b=Gi(e,s),x=b?{transformedValue:b.value,annotations:[b.type]}:{transformedValue:e};return l||i.set(e,x),x}if(Vr(a,e))return{transformedValue:null};const u=Gi(e,s),d=u?.value??e,f=ht(d)?[]:{},m={};Ft(d,(b,x)=>{if(x==="__proto__"||x==="constructor"||x==="prototype")throw new Error(`Detected property ${x}. This is a prototype pollution risk, please remove it from your object.`);const v=Qi(b,t,s,n,[...o,x],[...a,e],i);f[x]=v.transformedValue,ht(v.annotations)?m[an(x)]=v.annotations:mr(v.annotations)&&Ft(v.annotations,(w,y)=>{m[an(x)+"."+y]=w})});const g=on(m)?{transformedValue:f,annotations:u?[u.type]:void 0}:{transformedValue:f,annotations:u?[u.type,m]:m};return l||i.set(e,g),g};function Ui(e){return Object.prototype.toString.call(e).slice(8,-1)}function Hi(e){return Ui(e)==="Array"}function yh(e){if(Ui(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function wh(e,t,s,n,o){const a={}.propertyIsEnumerable.call(n,t)?"enumerable":"nonenumerable";a==="enumerable"&&(e[t]=s),o&&a==="nonenumerable"&&Object.defineProperty(e,t,{value:s,enumerable:!1,writable:!0,configurable:!0})}function dn(e,t={}){if(Hi(e))return e.map(o=>dn(o,t));if(!yh(e))return e;const s=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...s,...n].reduce((o,a)=>{if(a==="__proto__"||Hi(t.props)&&!t.props.includes(a))return o;const i=e[a];return wh(o,a,dn(i,t),e,t.nonenumerable),o},{})}var ie=class{constructor({dedupe:e=!1}={}){this.classRegistry=new Kp,this.symbolRegistry=new Mi(t=>t.description??""),this.customTransformerRegistry=new Xp,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,s=Qi(e,t,this,this.dedupe),n={json:s.transformedValue};s.annotations&&(n.meta={...n.meta,values:s.annotations});const o=vh(t,this.dedupe);return o&&(n.meta={...n.meta,referentialEqualities:o}),n.meta&&(n.meta.v=1),n}deserialize(e,t){const{json:s,meta:n}=e;let o=t?.inPlace?s:dn(s);return n?.values&&(o=hh(o,n.values,n.v??0,this)),n?.referentialEqualities&&(o=gh(o,n.referentialEqualities,n.v??0)),o}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e),{inPlace:!0})}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};ie.defaultInstance=new ie,ie.serialize=ie.defaultInstance.serialize.bind(ie.defaultInstance),ie.deserialize=ie.defaultInstance.deserialize.bind(ie.defaultInstance),ie.stringify=ie.defaultInstance.stringify.bind(ie.defaultInstance),ie.parse=ie.defaultInstance.parse.bind(ie.defaultInstance),ie.registerClass=ie.defaultInstance.registerClass.bind(ie.defaultInstance),ie.registerSymbol=ie.defaultInstance.registerSymbol.bind(ie.defaultInstance),ie.registerCustom=ie.defaultInstance.registerCustom.bind(ie.defaultInstance),ie.allowErrorProps=ie.defaultInstance.allowErrorProps.bind(ie.defaultInstance),ie.serialize,ie.deserialize,ie.stringify,ie.parse,ie.registerClass,ie.registerCustom,ie.registerSymbol,ie.allowErrorProps;function Sh({className:e}){return(0,r.jsxs)("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:[(0,r.jsx)("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"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}function kh({className:e}){return(0,r.jsxs)("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:[(0,r.jsx)("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"}),(0,r.jsx)("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),(0,r.jsx)("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"}),(0,r.jsx)("path",{d:"m2 2 20 20"})]})}function jh({className:e}){return(0,r.jsx)("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:(0,r.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}function Vi({onLogin:e,serverUrl:t,logoSrc:s,error:n,className:o}){const[a,i]=(0,h.useState)(""),[l,u]=(0,h.useState)(""),[d,f]=(0,h.useState)(!1),[m,g]=(0,h.useState)(!1),[b,x]=(0,h.useState)(null),v=n??b,w=async y=>{if(y.preventDefault(),!m){x(null),g(!0);try{await e(a,l)}catch(S){x(S instanceof Error?S.message:"Login failed. Please try again.")}finally{g(!1)}}};return(0,r.jsx)("div",{className:j("flex min-h-screen items-center justify-center bg-background p-4",o),children:(0,r.jsxs)("div",{className:"w-full max-w-sm",children:[s&&(0,r.jsx)("div",{className:"flex justify-center mb-8",children:(0,r.jsx)("img",{src:s,alt:"Logo",className:"h-12"})}),t&&(0,r.jsx)("p",{className:"mb-4 text-center text-xs text-foreground-subtle truncate",children:t}),(0,r.jsxs)("form",{onSubmit:w,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[v&&(0,r.jsx)("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:v}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-foreground-subtle",children:"Username"}),(0,r.jsx)("input",{type:"text",value:a,onChange:y=>i(y.target.value),autoComplete:"username",required:!0,className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary"})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-foreground-subtle",children:"Password"}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{type:d?"text":"password",value:l,onChange:y=>u(y.target.value),autoComplete:"current-password",required:!0,className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary"}),(0,r.jsx)("button",{type:"button",onClick:()=>f(y=>!y),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",tabIndex:-1,children:d?(0,r.jsx)(kh,{className:"h-4 w-4"}):(0,r.jsx)(Sh,{className:"h-4 w-4"})})]})]}),(0,r.jsxs)("button",{type:"submit",disabled:m,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:[m&&(0,r.jsx)(jh,{className:"h-4 w-4 animate-spin"}),m?"Logging in...":"Log in"]})]})]})})}var fn="camstack_dev_token",Wi=(0,h.createContext)(null);function Nh(){const e=(0,h.useContext)(Wi);if(!e)throw new Error("useDevShell must be used within a DevShell");return e}function Ch(){return typeof window>"u"?null:localStorage.getItem(fn)}function Mh({className:e}){return(0,r.jsxs)("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:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,r.jsx)("path",{d:"M12 2v2"}),(0,r.jsx)("path",{d:"M12 20v2"}),(0,r.jsx)("path",{d:"m4.93 4.93 1.41 1.41"}),(0,r.jsx)("path",{d:"m17.66 17.66 1.41 1.41"}),(0,r.jsx)("path",{d:"M2 12h2"}),(0,r.jsx)("path",{d:"M20 12h2"}),(0,r.jsx)("path",{d:"m6.34 17.66-1.41 1.41"}),(0,r.jsx)("path",{d:"m19.07 4.93-1.41 1.41"})]})}function Eh({className:e}){return(0,r.jsx)("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:(0,r.jsx)("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function Ah({children:e,serverUrl:t,title:s,token:n,onLogout:o}){const a=Ge.useThemeMode$1(),i=(0,h.useMemo)(()=>[(0,Te.splitLink)({condition:g=>g.type==="subscription",true:(0,Te.wsLink)({client:(0,Te.createWSClient)({url:t.replace(/^http/,"ws")+"/trpc",connectionParams:()=>({token:n})}),transformer:ie}),false:(0,Te.httpLink)({url:`${t}/trpc`,transformer:ie,headers:()=>({authorization:`Bearer ${n}`})})})],[t,n]),l=(0,h.useMemo)(()=>(0,Te.createTRPCClient)({links:i}),[i]),u=(0,h.useMemo)(()=>p.createClient({links:i}),[i]),d=(0,h.useMemo)(()=>(0,ns.createSystem)({serverUrl:t,token:n}),[t,n]);(0,h.useEffect)(()=>(d.init().catch(()=>{}),()=>{d.close()}),[d]);const f=(0,h.useMemo)(()=>new Ae.QueryClient,[]),m=(0,h.useMemo)(()=>({trpc:l,token:n,logout:o}),[l,n,o]);return(0,r.jsx)(Za,{system:d,children:(0,r.jsx)(p.Provider,{client:u,queryClient:f,children:(0,r.jsx)(Ae.QueryClientProvider,{client:f,children:(0,r.jsx)(Wi.Provider,{value:m,children:(0,r.jsxs)("div",{className:"min-h-screen bg-background text-foreground",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border-b border-border bg-surface px-4 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"rounded bg-warning/20 px-2 py-0.5 text-xs font-bold text-warning",children:"DEV MODE"}),s&&(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:s}),(0,r.jsx)("span",{className:"text-xs text-foreground-subtle",children:t})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("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"?(0,r.jsx)(Mh,{className:"h-3.5 w-3.5"}):(0,r.jsx)(Eh,{className:"h-3.5 w-3.5"}),a.mode==="dark"?"Dark":a.mode==="light"?"Light":"System"]}),(0,r.jsx)("button",{type:"button",onClick:o,className:"rounded-md px-2.5 py-1 text-xs font-medium text-danger hover:bg-danger/10 transition-colors",children:"Logout"})]})]}),(0,r.jsx)("div",{className:"p-4",children:e({trpc:l,theme:a})})]})})})})})}function qi({children:e,serverUrl:t="https://localhost:4443",title:s}){const[n,o]=(0,h.useState)(Ch),a=(0,h.useCallback)(async(l,u)=>{const d=await(0,Te.createTRPCClient)({links:[(0,Te.httpLink)({url:`${t}/trpc`,transformer:ie})]}).auth.login.mutate({username:l,password:u});if(!d.token)throw new Error("No token returned");localStorage.setItem(fn,d.token),o(d.token)},[t]),i=(0,h.useCallback)(()=>{localStorage.removeItem(fn),o(null)},[]);return n?(0,r.jsx)(Ge.ThemeProvider$1,{children:(0,r.jsx)(Ah,{serverUrl:t,title:s,token:n,onLogout:i,children:e})}):(0,r.jsx)(Ge.ThemeProvider$1,{children:(0,r.jsx)(Vi,{onLogin:a,serverUrl:t})})}function Ph(e,t={}){const{serverUrl:s="https://localhost:4443",title:n,rootId:o="root"}=t,a=document.getElementById(o);if(!a){console.error(`[mountAddonPage] Element #${o} not found`);return}(0,bt.createRoot)(a).render((0,h.createElement)(qi,{serverUrl:s,title:n,children:({trpc:i,theme:l})=>(0,h.createElement)(e,{trpc:i,theme:{isDark:l.resolvedMode==="dark"},navigate:u=>{console.log("[dev] navigate:",u)}})}))}var Ki=at("camstack:custom-field-renderers",{});function Rh({renderers:e,children:t}){return(0,r.jsx)(Ki.Provider,{value:e,children:t})}function Zi(e){return(0,h.useContext)(Ki)[e]??null}var mn=at("camstack:device-context",null);function Dh({deviceId:e,device:t,children:s}){const n={deviceId:e,device:t??null};return(0,r.jsx)(mn.Provider,{value:n,children:s})}function Yi(){return(0,h.useContext)(mn)?.deviceId??null}function Th(){return(0,h.useContext)(mn)?.device??null}var Ih=p.accessories.getStatus.useQuery,Lh=p.addonPages.listPages.useQuery,Xi=p.addons.list.useQuery,Oh=p.addons.getLogs.useQuery,_h=p.addons.listPackages.useQuery,$h=p.addons.installPackage.useMutation,Gh=p.addons.installFromWorkspace.useMutation,Bh=p.addons.isWorkspaceAvailable.useQuery,Fh=p.addons.listWorkspacePackages.useQuery,zh=p.addons.uninstallPackage.useMutation,Qh=p.addons.reloadPackages.useMutation,Uh=p.addons.searchAvailable.useQuery,Hh=p.addons.listUpdates.useQuery,Vh=p.addons.updatePackage.useMutation,Wh=p.addons.rollbackPackage.useMutation,qh=p.addons.forceRefresh.useMutation,Kh=p.addons.restartServer.useMutation,Zh=p.addons.getVersions.useQuery,Yh=p.addons.restartAddon.useMutation,Xh=p.addons.retryLoad.useMutation,Jh=p.addons.getAutoUpdateSettings.useQuery,eg=p.addons.setAutoUpdateSettings.useMutation,tg=p.addons.getAddonAutoUpdate.useQuery,rg=p.addons.setAddonAutoUpdate.useMutation,sg=p.addons.applyAutoUpdateToAll.useMutation,ng=p.addons.custom.useMutation,og=p.addons.onAddonLogs.useSubscription,ag=p.addonSettings.getGlobalSettings.useQuery,ig=p.addonSettings.updateGlobalSettings.useMutation,lg=p.addonSettings.getDeviceSettings.useQuery,cg=p.addonSettings.updateDeviceSettings.useMutation,Ji=p.addonWidgets.listWidgets.useQuery,ug=p.alerts.emit.useMutation,dg=p.alerts.update.useMutation,fg=p.alerts.list.useQuery,mg=p.alerts.getUnreadCount.useQuery,pg=p.alerts.markRead.useMutation,hg=p.alerts.markAllRead.useMutation,gg=p.alerts.dismiss.useMutation,bg=p.audioAnalysis.resolveDeviceSettings.useQuery,xg=p.audioAnalysis.getDeviceSettingsContribution.useQuery,vg=p.audioAnalysis.getDeviceLiveContribution.useQuery,yg=p.audioAnalysis.applyDeviceSettingsPatch.useMutation,wg=p.audioAnalyzer.analyseChunk.useMutation,Sg=p.audioAnalyzer.classify.useQuery,kg=p.audioAnalyzer.isReady.useQuery,jg=p.audioAnalyzer.dispose.useMutation,Ng=p.audioAnalyzer.reprobeAudioEngine.useMutation,Cg=p.audioCodec.listSupportedCodecs.useQuery,Mg=p.audioCodec.canHandle.useQuery,Eg=p.audioCodec.createDecodeSession.useMutation,Ag=p.audioCodec.createEncodeSession.useMutation,Pg=p.audioCodec.closeSession.useMutation,Rg=p.audioCodec.pushEncodedFrame.useMutation,Dg=p.audioCodec.pullPcm.useQuery,Tg=p.audioCodec.pushPcm.useMutation,Ig=p.audioCodec.pullEncoded.useQuery,Lg=p.audioCodec.flushEncode.useMutation,Og=p.audioCodec.listActiveSessions.useQuery,_g=p.audioMetrics.getCurrentSnapshot.useQuery,$g=p.audioMetrics.getHistory.useQuery,Gg=p.authentication.listProviders.useQuery,Bg=p.authentication.setProviderEnabled.useMutation,Fg=p.backup.listDestinations.useQuery,zg=p.backup.trigger.useMutation,Qg=p.backup.list.useQuery,Ug=p.backup.listLocations.useQuery,Hg=p.backup.getEntries.useQuery,Vg=p.backup.restore.useMutation,Wg=p.backup.delete.useMutation,qg=p.backup.listArchives.useQuery,Kg=p.backup.upsertDestinationPolicy.useMutation,Zg=p.backup.previewSchedule.useQuery,Yg=p.battery.getStatus.useQuery,Xg=p.brightness.setBrightness.useMutation,Jg=p.brightness.getStatus.useQuery,e0=p.cameraStreams.getCameraStreams.useQuery,t0=p.cameraStreams.getBrokerStreams.useQuery,r0=p.cameraStreams.getRtspEntries.useQuery,s0=p.decoder.supportsCodec.useQuery,n0=p.decoder.getInfo.useQuery,o0=p.decoder.createSession.useQuery,a0=p.decoder.destroySession.useQuery,i0=p.decoder.pushPacket.useQuery,l0=p.decoder.openStream.useQuery,c0=p.decoder.pullFrames.useQuery,u0=p.decoder.updateConfig.useQuery,d0=p.decoder.getStats.useQuery,f0=p.decoder.listActiveSessions.useQuery,m0=p.decoder.reprobeHwaccel.useMutation,p0=p.detectionPipeline.getDeviceSettingsContribution.useQuery,h0=p.detectionPipeline.getDeviceLiveContribution.useQuery,g0=p.detectionPipeline.applyDeviceSettingsPatch.useMutation,b0=p.deviceDiscovery.listDiscovered.useQuery,x0=p.deviceDiscovery.refreshDiscovery.useMutation,v0=p.deviceDiscovery.adoptDevice.useMutation,y0=p.deviceDiscovery.releaseDevice.useMutation,w0=p.deviceDiscovery.getStatus.useQuery,S0=p.deviceManager.allocateDeviceId.useMutation,k0=p.deviceManager.registerDevice.useMutation,j0=p.deviceManager.removeDevice.useMutation,N0=p.deviceManager.persistConfig.useMutation,C0=p.deviceManager.loadConfig.useQuery,M0=p.deviceManager.loadRuntimeState.useQuery,E0=p.deviceManager.loadMeta.useQuery,A0=p.deviceManager.setName.useMutation,P0=p.deviceManager.setLocation.useMutation,R0=p.deviceManager.setMetadata.useMutation,D0=p.deviceManager.listLocations.useQuery,T0=p.deviceManager.addLocation.useMutation,I0=p.deviceManager.removeLocation.useMutation,L0=p.deviceManager.setDisabled.useMutation,O0=p.deviceManager.listPersistedByAddon.useQuery,_0=p.deviceManager.listAll.useQuery,$0=p.deviceManager.getDevice.useQuery,G0=p.deviceManager.getChildren.useQuery,B0=p.deviceManager.getStreamSources.useQuery,F0=p.deviceManager.getConfigSchema.useQuery,z0=p.deviceManager.getSettingsSchema.useQuery,Q0=p.deviceManager.updateConfig.useMutation,U0=p.deviceManager.enable.useMutation,H0=p.deviceManager.disable.useMutation,V0=p.deviceManager.remove.useMutation,W0=p.deviceManager.getStreamProfileMap.useQuery,q0=p.deviceManager.setStreamProfileMap.useMutation,K0=p.deviceManager.probeStreams.useMutation,Z0=p.deviceManager.getBindings.useQuery,Y0=p.deviceManager.getAllBindings.useQuery,X0=p.deviceManager.setWrapperActive.useMutation,J0=p.deviceManager.listWrappersForCap.useQuery,eb=p.deviceManager.listBindableCapsForDeviceType.useQuery,tb=p.deviceManager.getDeviceSettingsAggregate.useQuery,rb=p.deviceManager.getDeviceLiveInfoAggregate.useQuery,sb=p.deviceManager.getDeviceAggregate.useQuery,nb=p.deviceManager.updateDeviceField.useMutation,ob=p.deviceManager.updateDeviceFieldsBatch.useMutation,ab=p.deviceManager.discoverDevices.useMutation,ib=p.deviceManager.adoptDevice.useMutation,lb=p.deviceManager.getCreationSchema.useQuery,cb=p.deviceManager.createDevice.useMutation,ub=p.deviceManager.testCreationField.useMutation,db=p.deviceManager.testField.useMutation,fb=p.deviceManager.getDeviceStatusAggregate.useQuery,mb=p.deviceOps.getStreamSources.useQuery,pb=p.deviceOps.getConfigEntries.useQuery,hb=p.deviceOps.setConfig.useMutation,gb=p.deviceOps.removeDevice.useMutation,bb=p.deviceOps.getSettingsSchema.useQuery,xb=p.deviceProvider.start.useMutation,vb=p.deviceProvider.stop.useMutation,yb=p.deviceProvider.getStatus.useQuery,wb=p.deviceProvider.getDevices.useQuery,Sb=p.deviceProvider.supportsDiscovery.useQuery,kb=p.deviceProvider.discoverDevices.useMutation,jb=p.deviceProvider.adoptDiscoveredDevice.useMutation,Nb=p.deviceProvider.supportsManualCreation.useQuery,Cb=p.deviceProvider.getChildCreationSchema.useQuery,Mb=p.deviceProvider.createDevice.useMutation,Eb=p.deviceProvider.testCreationField.useMutation,Ab=p.deviceState.getSnapshot.useQuery,Pb=p.deviceState.getCapSlice.useQuery,Rb=p.deviceState.getAllSnapshots.useQuery,Db=p.deviceState.setCapSlice.useMutation,Tb=p.doorbell.getStatus.useQuery,Ib=p.events.getEvents.useQuery,Lb=p.events.getEventThumbnail.useQuery,Ob=p.events.getEventClipUrl.useQuery,_b=p.integrations.list.useQuery,$b=p.integrations.get.useQuery,Gb=p.integrations.getByAddonId.useQuery,Bb=p.integrations.create.useMutation,Fb=p.integrations.update.useMutation,zb=p.integrations.delete.useMutation,Qb=p.integrations.getSettings.useQuery,Ub=p.integrations.setSettings.useMutation,Hb=p.integrations.getAvailableTypes.useQuery,Vb=p.integrations.testConnection.useMutation,Wb=p.intercom.startSession.useMutation,qb=p.intercom.handleAnswer.useMutation,Kb=p.intercom.stopSession.useMutation,Zb=p.intercom.getStatus.useQuery,Yb=p.localNetwork.list.useQuery,Xb=p.localNetwork.getPreferred.useQuery,Jb=p.localNetwork.getConnectionEndpoints.useQuery,ex=p.localNetwork.getAllowedAddresses.useQuery,tx=p.localNetwork.setAllowedAddresses.useMutation,rx=p.localNetwork.resetAllowlistToBestMatch.useMutation,sx=p.meshOrchestrator.listProviders.useQuery,nx=p.meshOrchestrator.joinProvider.useMutation,ox=p.meshOrchestrator.leaveProvider.useMutation,ax=p.metricsProvider.collectSnapshot.useQuery,ix=p.metricsProvider.getCached.useQuery,lx=p.metricsProvider.getCurrent.useQuery,cx=p.metricsProvider.getDiskSpace.useQuery,ux=p.metricsProvider.getGpuInfo.useQuery,dx=p.metricsProvider.getCpuTemperature.useQuery,fx=p.metricsProvider.getProcessStats.useQuery,mx=p.metricsProvider.listAddonInstances.useQuery,px=p.metricsProvider.getAddonStats.useQuery,hx=p.metricsProvider.listNodeProcesses.useQuery,gx=p.metricsProvider.killProcess.useMutation,bx=p.motion.isDetected.useQuery,xx=p.motion.getStatus.useQuery,vx=p.motionDetection.analyze.useMutation,yx=p.motionDetection.removeCamera.useMutation,wx=p.motionDetection.reset.useMutation,Sx=p.motionDetection.getDeviceSettingsContribution.useQuery,kx=p.motionDetection.getDeviceLiveContribution.useQuery,jx=p.motionDetection.applyDeviceSettingsPatch.useMutation,Nx=p.motionTrigger.setMotionTrigger.useMutation,Cx=p.motionTrigger.getStatus.useQuery,Mx=p.nativeObjectDetection.getStatus.useQuery,Ex=p.networkQuality.getDeviceStats.useQuery,Ax=p.networkQuality.getAllStats.useQuery,Px=p.networkQuality.reportClientStats.useMutation,Rx=p.nodes.topology.useQuery,Dx=p.nodes.deployAddon.useMutation,Tx=p.nodes.undeployAddon.useMutation,Ix=p.nodes.restartAddon.useMutation,Lx=p.nodes.restartProcess.useMutation,Ox=p.nodes.restartNode.useMutation,_x=p.nodes.shutdownNode.useMutation,$x=p.nodes.renameNode.useMutation,Gx=p.nodes.clusterAddonStatus.useQuery,Bx=p.nodes.setProcessLogLevel.useMutation,Fx=p.nodes.executeQuery.useMutation,zx=p.notificationOutput.send.useMutation,Qx=p.notificationOutput.sendTest.useMutation,Ux=p.osd.setOverlay.useMutation,Hx=p.osd.getStatus.useQuery,Vx=p.pipelineAnalytics.getActiveTracks.useQuery,Wx=p.pipelineAnalytics.getTrack.useQuery,qx=p.pipelineAnalytics.listTracks.useQuery,Kx=p.pipelineAnalytics.clearTracks.useMutation,Zx=p.pipelineAnalytics.getMotionEvents.useQuery,Yx=p.pipelineAnalytics.getObjectEvents.useQuery,Xx=p.pipelineAnalytics.getAudioEvents.useQuery,Jx=p.pipelineAnalytics.getEventMedia.useQuery,ev=p.pipelineAnalytics.getTrackMedia.useQuery,tv=p.pipelineAnalytics.getDeviceSettingsContribution.useQuery,rv=p.pipelineAnalytics.getDeviceLiveContribution.useQuery,sv=p.pipelineAnalytics.applyDeviceSettingsPatch.useMutation,nv=p.pipelineExecutor.getAvailableEngines.useQuery,ov=p.pipelineExecutor.getSelectedEngine.useQuery,av=p.pipelineExecutor.getDefaultSteps.useQuery,iv=p.pipelineExecutor.reprobeEngine.useMutation,lv=p.pipelineExecutor.getVideoPipelineSteps.useQuery,cv=p.pipelineExecutor.setVideoPipelineSteps.useMutation,uv=p.pipelineExecutor.getSchema.useQuery,dv=p.pipelineExecutor.getGlobalSteps.useQuery,fv=p.pipelineExecutor.getGlobalPipelineConfig.useQuery,mv=p.pipelineExecutor.getOrchestratorConfigSchema.useQuery,pv=p.pipelineExecutor.listTemplates.useQuery,hv=p.pipelineExecutor.saveTemplate.useMutation,gv=p.pipelineExecutor.updateTemplate.useMutation,bv=p.pipelineExecutor.deleteTemplate.useMutation,xv=p.pipelineExecutor.getCapabilities.useQuery,vv=p.pipelineExecutor.getAddonModels.useQuery,yv=p.pipelineExecutor.downloadModel.useMutation,wv=p.pipelineExecutor.deleteModel.useMutation,Sv=p.pipelineExecutor.detect.useQuery,kv=p.pipelineExecutor.runPipeline.useMutation,jv=p.pipelineExecutor.runPipelineBatch.useMutation,Nv=p.pipelineExecutor.cacheFrameInPool.useMutation,Cv=p.pipelineExecutor.inferCached.useMutation,Mv=p.pipelineExecutor.uncacheFrame.useMutation,Ev=p.pipelineExecutor.getEffectiveTuning.useQuery,Av=p.pipelineExecutor.listLoadedEngines.useQuery,Pv=p.pipelineExecutor.spinEngine.useMutation,Rv=p.pipelineExecutor.killEngine.useMutation,Dv=p.pipelineExecutor.listReferenceImages.useQuery,Tv=p.pipelineExecutor.getReferenceImage.useQuery,Iv=p.pipelineExecutor.getReferenceAudioFiles.useQuery,Lv=p.pipelineExecutor.getReferenceAudio.useQuery,Ov=p.pipelineExecutor.getAudioCapabilities.useQuery,_v=p.pipelineExecutor.runAudioTest.useMutation,$v=p.pipelineExecutor.getDetectionConfigSchema.useQuery,Gv=p.pipelineOrchestrator.assignPipeline.useMutation,Bv=p.pipelineOrchestrator.unassignPipeline.useMutation,Fv=p.pipelineOrchestrator.rebalance.useMutation,zv=p.pipelineOrchestrator.getPipelineAssignments.useQuery,Qv=p.pipelineOrchestrator.getPipelineAssignment.useQuery,Uv=p.pipelineOrchestrator.getAgentLoad.useQuery,Hv=p.pipelineOrchestrator.getGlobalMetrics.useQuery,Vv=p.pipelineOrchestrator.getCameraMetrics.useQuery,Wv=p.pipelineOrchestrator.getCapabilityBindings.useQuery,qv=p.pipelineOrchestrator.setCapabilityBinding.useMutation,Kv=p.pipelineOrchestrator.assignDecoder.useMutation,Zv=p.pipelineOrchestrator.unassignDecoder.useMutation,Yv=p.pipelineOrchestrator.getDecoderAssignments.useQuery,Xv=p.pipelineOrchestrator.assignAudio.useMutation,Jv=p.pipelineOrchestrator.unassignAudio.useMutation,ey=p.pipelineOrchestrator.getAudioAssignment.useQuery,ty=p.pipelineOrchestrator.getAudioNodeLoad.useQuery,ry=p.pipelineOrchestrator.getAudioAssignments.useQuery,sy=p.pipelineOrchestrator.getDecoderAssignment.useQuery,ny=p.pipelineOrchestrator.getAgentSettings.useQuery,oy=p.pipelineOrchestrator.listAgentSettings.useQuery,ay=p.pipelineOrchestrator.setAgentAddonDefaults.useMutation,iy=p.pipelineOrchestrator.removeAgentSettings.useMutation,ly=p.pipelineOrchestrator.getCameraSettings.useQuery,cy=p.pipelineOrchestrator.setCameraStepToggle.useMutation,uy=p.pipelineOrchestrator.getCameraStepOverrides.useQuery,dy=p.pipelineOrchestrator.setCameraStepOverride.useMutation,fy=p.pipelineOrchestrator.setCameraPipelineForAgent.useMutation,my=p.pipelineOrchestrator.resolvePipeline.useQuery,py=p.pipelineOrchestrator.listTemplates.useQuery,hy=p.pipelineOrchestrator.saveTemplate.useMutation,gy=p.pipelineOrchestrator.updateTemplate.useMutation,by=p.pipelineOrchestrator.deleteTemplate.useMutation,xy=p.pipelineOrchestrator.getDeviceSettingsContribution.useQuery,vy=p.pipelineOrchestrator.getDeviceLiveContribution.useQuery,yy=p.pipelineOrchestrator.applyDeviceSettingsPatch.useMutation,wy=p.pipelineRunner.attachCamera.useMutation,Sy=p.pipelineRunner.detachCamera.useMutation,ky=p.pipelineRunner.reportMotion.useMutation,jy=p.pipelineRunner.getLocalLoad.useQuery,Ny=p.pipelineRunner.getLocalMetrics.useQuery,Cy=p.pipelineRunner.getCameraMetrics.useQuery,My=p.pipelineRunner.getAllCameraMetrics.useQuery,Ey=p.pipelineRunner.getLocalCameras.useQuery,Ay=p.platformProbe.getCapabilities.useQuery,Py=p.platformProbe.getHardware.useQuery,Ry=p.platformProbe.resolveInferenceConfig.useQuery,Dy=p.platformProbe.resolveHwAccel.useQuery,Ty=p.ptz.move.useMutation,Iy=p.ptz.continuousMove.useMutation,Ly=p.ptz.stop.useMutation,Oy=p.ptz.getPresets.useQuery,_y=p.ptz.goToPreset.useMutation,$y=p.ptz.goHome.useMutation,Gy=p.ptz.getPosition.useQuery,By=p.ptz.getStatus.useQuery,Fy=p.ptzAutotrack.getStatus.useQuery,zy=p.ptzAutotrack.setEnabled.useMutation,Qy=p.ptzAutotrack.getSettings.useQuery,Uy=p.ptzAutotrack.setSettings.useMutation,Hy=p.reboot.reboot.useMutation,Vy=p.recording.getSegments.useQuery,Wy=p.recording.getPlaybackUrl.useQuery,qy=p.recording.getThumbnailAt.useQuery,Ky=p.recordingEngine.getStatus.useQuery,Zy=p.recordingEngine.enable.useMutation,Yy=p.recordingEngine.disable.useMutation,Xy=p.recordingEngine.getConfig.useQuery,Jy=p.recordingEngine.updateConfig.useMutation,e1=p.recordingEngine.getPlaylist.useQuery,t1=p.recordingEngine.getThumbnail.useQuery,r1=p.recordingEngine.getSegments.useQuery,s1=p.recordingEngine.getAvailability.useQuery,n1=p.recordingEngine.estimateStorage.useQuery,o1=p.recordingEngine.estimateGlobalStorage.useQuery,a1=p.recordingEngine.getStorageUsage.useQuery,i1=p.recordingEngine.setPolicy.useMutation,l1=p.recordingEngine.getPolicy.useQuery,c1=p.recordingEngine.getPolicyStatus.useQuery,u1=p.recordingEngine.getRetentionConfig.useQuery,d1=p.recordingEngine.updateRetentionConfig.useMutation,f1=p.recordingEngine.getMotionStats.useQuery,m1=p.remoteAccess.listProviders.useQuery,p1=p.remoteAccess.startProvider.useMutation,h1=p.remoteAccess.stopProvider.useMutation,g1=p.settingsStore.get.useQuery,b1=p.settingsStore.set.useMutation,x1=p.settingsStore.query.useQuery,v1=p.settingsStore.insert.useMutation,y1=p.settingsStore.update.useMutation,w1=p.settingsStore.delete.useMutation,S1=p.settingsStore.count.useQuery,k1=p.settingsStore.isEmpty.useQuery,j1=p.settingsStore.declareCollection.useMutation,N1=p.snapshot.getSnapshot.useQuery,C1=p.snapshot.invalidateCache.useMutation,M1=p.snapshot.getStatus.useQuery,E1=p.snapshot.getDeviceSettingsContribution.useQuery,A1=p.snapshot.getDeviceLiveContribution.useQuery,P1=p.snapshot.applyDeviceSettingsPatch.useMutation,R1=p.snapshotProvider.supportsDevice.useQuery,D1=p.snapshotProvider.getSnapshot.useQuery,T1=p.storage.resolve.useQuery,I1=p.storage.write.useMutation,L1=p.storage.read.useQuery,O1=p.storage.exists.useQuery,_1=p.storage.list.useQuery,$1=p.storage.delete.useMutation,G1=p.storage.getAvailableSpace.useQuery,B1=p.storage.beginUpload.useMutation,F1=p.storage.writeChunk.useMutation,z1=p.storage.finalizeUpload.useMutation,Q1=p.storage.abortUpload.useMutation,U1=p.storage.beginDownload.useMutation,H1=p.storage.readChunk.useQuery,V1=p.storage.endDownload.useMutation,W1=p.storage.listLocations.useQuery,q1=p.storage.getDefaultLocation.useQuery,K1=p.storage.upsertLocation.useMutation,Z1=p.storage.deleteLocation.useMutation,Y1=p.storage.testLocation.useQuery,X1=p.storage.listProviders.useQuery,J1=p.storage.testConfig.useQuery,ew=p.streamBroker.publishCameraStream.useMutation,tw=p.streamBroker.retractCameraStream.useMutation,rw=p.streamBroker.assignProfile.useMutation,sw=p.streamBroker.unassignProfile.useMutation,nw=p.streamBroker.listAllCameraStreams.useQuery,ow=p.streamBroker.listAllProfileSlots.useQuery,aw=p.streamBroker.getBrokerStats.useQuery,iw=p.streamBroker.listClients.useQuery,lw=p.streamBroker.killClient.useMutation,cw=p.streamBroker.restartProfile.useMutation,uw=p.streamBroker.getStreamUrl.useQuery,dw=p.streamBroker.getBroker.useQuery,fw=p.streamBroker.setPreBufferDuration.useMutation,mw=p.streamBroker.getPreBufferInfo.useQuery,pw=p.streamBroker.getRtspPort.useQuery,hw=p.streamBroker.getAllRtspEntries.useQuery,gw=p.streamBroker.getRtspEntry.useQuery,bw=p.streamBroker.regenerateRtspToken.useMutation,xw=p.streamBroker.setRtspEnabled.useMutation,vw=p.streamBroker.isRtspEnabled.useQuery,yw=p.streamBroker.getDeviceSettingsContribution.useQuery,ww=p.streamBroker.getDeviceLiveContribution.useQuery,Sw=p.streamBroker.applyDeviceSettingsPatch.useMutation,kw=p.switch.setState.useMutation,jw=p.switch.getStatus.useQuery,Nw=p.system.info.useQuery,Cw=p.system.health.useQuery,Mw=p.system.featureFlags.useQuery,Ew=p.system.networkAddresses.useQuery,Aw=p.system.getRetentionConfig.useQuery,Pw=p.system.setRetentionConfig.useMutation,Rw=p.system.forceRetentionCleanup.useMutation,Dw=p.toast.onToast.useSubscription,Tw=p.turnOrchestrator.listProviders.useQuery,Iw=p.turnOrchestrator.getAllServers.useQuery,Lw=p.turnOrchestrator.setProviderEnabled.useMutation,Ow=p.turnProvider.getTurnServers.useQuery,_w=p.userManagement.listUsers.useQuery,$w=p.userManagement.createUser.useMutation,Gw=p.userManagement.updateUser.useMutation,Bw=p.userManagement.deleteUser.useMutation,Fw=p.userManagement.resetPassword.useMutation,zw=p.userManagement.setUserScopes.useMutation,Qw=p.userManagement.validateCredentials.useMutation,Uw=p.userManagement.listApiKeys.useQuery,Hw=p.userManagement.createApiKey.useMutation,Vw=p.userManagement.revokeApiKey.useMutation,Ww=p.userManagement.validateApiKey.useMutation,qw=p.userManagement.createScopedToken.useMutation,Kw=p.userManagement.revokeScopedToken.useMutation,Zw=p.userManagement.validateScopedToken.useQuery,Yw=p.userManagement.listScopedTokens.useQuery,Xw=p.webrtcSession.listStreams.useQuery,Jw=p.webrtcSession.createSession.useMutation,eS=p.webrtcSession.handleAnswer.useMutation,tS=p.webrtcSession.closeSession.useMutation,rS=p.webrtcSession.hasAdaptiveBitrate.useQuery,sS=p.zoneAnalytics.getCurrentSnapshot.useQuery,nS=p.zoneAnalytics.getZoneHistory.useQuery,oS=p.zoneAnalytics.getCameraHistory.useQuery,aS=p.zoneAnalytics.getUnzonedHistory.useQuery,iS=p.zoneRules.listRules.useQuery,lS=p.zoneRules.setRules.useMutation,cS=p.zones.listZones.useQuery,uS=p.zones.addZone.useMutation,dS=p.zones.removeZone.useMutation,fS=p.zones.updateZone.useMutation,el=at("camstack:widget-registry",null),qr=new Map,Kr=new Map,tl=new Set;function mS(e){if(!e||typeof e!="object")return!1;const t=e.default;return t!==null&&typeof t=="object"}function pS(e){if(!e||typeof e!="object")return typeof e;const t=e,s=Object.getPrototypeOf(t),n=s&&typeof s=="object"?s.constructor?.name:void 0;return{ownKeys:Object.keys(t),allKeys:Object.getOwnPropertyNames(t),proto:typeof n=="string"?n:void 0}}async function hS(e,t){const s=qr.get(e);if(s)return s;const n=Kr.get(e);if(n)return n;tl.has(e)||(zo(),Sd([{name:e,entry:t,type:"module"}],{force:!1}),tl.add(e));const o=wd(`${e}/widgets`).then(a=>{if(!mS(a)){const l=pS(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 qr.set(e,i),Kr.delete(e),i}).catch(a=>{throw Kr.delete(e),a});return Kr.set(e,o),o}var gS=3e4,bS=2e3;function xS({children:e}){const t=(0,Ae.useQueryClient)(),s=(0,h.useRef)(Date.now()),{data:n}=Ji(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:l=>{const u=l.state.data;return u&&u.length>0||Date.now()-s.current>=gS?!1:bS}});ur("addon.widget-ready",()=>{t.invalidateQueries({queryKey:[["addonWidgets","listWidgets"]]})});const[o,a]=(0,h.useState)(0);(0,h.useEffect)(()=>{if(!n)return;let l=!1;const u=new Set;for(const d of n){if(u.has(d.remoteName)||(u.add(d.remoteName),qr.has(d.remoteName)))continue;const f=d.bundleUrl;hS(d.remoteName,f).then(()=>{l||a(m=>m+1)}).catch(m=>{const g=m instanceof Error?m.message:String(m);(typeof globalThis<"u"?globalThis.console:void 0)?.error?.("[WidgetRegistry] Failed to load widget remote",{remoteName:d.remoteName,entryUrl:f,reason:g})})}return()=>{l=!0}},[n]);const i=(0,h.useMemo)(()=>{const l=n??[],u=new Map;for(const f of l)u.set(`${f.addonId}/${f.stableId}`,f);const d=(f,m)=>({widgetId:f,addonId:m.addonId,stableId:m.stableId,label:m.label,description:m.description,icon:m.icon,remoteName:m.remoteName,bundleUrl:m.bundleUrl,hosts:m.hosts,requires:m.requires,defaultSize:m.defaultSize,allowedSizes:m.allowedSizes,defaultColumns:m.defaultColumns,defaultRows:m.defaultRows});return{resolve:f=>{const m=u.get(f);if(!m)return;const g=qr.get(m.remoteName);if(!g)return null;const b=g[m.stableId];if(b)return b},metadata:f=>{const m=u.get(f);if(m)return d(f,m)},listAll:()=>{const f=[];for(const[m,g]of u)f.push(d(m,g));return f}}},[n,o]);return(0,r.jsx)(el.Provider,{value:i,children:e})}function rl(e){return Zr().resolve(e)}function sl(e){return Zr().metadata(e)}function vS(){return Zr().listAll()}function Zr(){const e=nl();if(!e)throw new Error("useWidgetRegistry(): no <WidgetRegistryProvider> in tree");return e}function nl(){return yS(el)}function yS(e){return(0,h.useContext)(e)}function ol(e){const{widgetId:t,host:s="device-tab",config:n,deviceId:o,integrationId:a,instanceId:i,size:l,columns:u,rows:d}=e,f=rl(t),m=sl(t),g=(0,h.useMemo)(()=>i??t,[i,t]);if(f===void 0&&m===void 0)return(0,r.jsx)(Yr,{widgetId:t,reason:"unknown"});if(f===void 0)return(0,r.jsx)(Yr,{widgetId:t,reason:"missing-export"});if(f===null)return(0,r.jsx)(wS,{});if(m){if(m.requires.deviceContext&&o===void 0)return(0,r.jsx)(Yr,{widgetId:t,reason:"missing-device-context"});if(m.requires.integrationContext&&a===void 0)return(0,r.jsx)(Yr,{widgetId:t,reason:"missing-integration-context"})}return(0,r.jsx)(f,{instanceId:g,host:s,config:n,deviceId:o,integrationId:a,size:l,columns:u,rows:d})}function wS(){return(0,r.jsxs)("div",{className:"rounded-lg border border-border bg-surface/40 p-4 animate-pulse",children:[(0,r.jsx)("div",{className:"h-3 w-24 bg-foreground-subtle/20 rounded mb-2"}),(0,r.jsx)("div",{className:"h-2 w-full bg-foreground-subtle/10 rounded mb-1"}),(0,r.jsx)("div",{className:"h-2 w-3/4 bg-foreground-subtle/10 rounded"})]})}function Yr({widgetId:e,reason:t}){return(0,r.jsx)("div",{className:"rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",children: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`})}var Nt="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",Xr="block text-[11px] font-medium text-foreground mb-1",SS="text-[10px] text-foreground-subtle mt-0.5";function je({label:e,description:t,required:s,span:n,children:o,translationFn:a}){const i=n===2?"col-span-2":n===3?"col-span-3":n===4?"col-span-4":"col-span-1",l=Ke(e,a),u=Ke(t,a);return(0,r.jsxs)("div",{className:i,children:[l!==void 0&&l!==""&&(0,r.jsxs)("label",{className:Xr,children:[l,s&&(0,r.jsx)("span",{className:"text-danger ml-0.5",children:"*"})]}),o,u&&(0,r.jsx)("p",{className:SS,children:u})]})}function kS({field:e,value:t,onChange:s,disabled:n,translationFn:o}){return(0,r.jsx)(je,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:(0,r.jsx)("input",{type:e.inputType??"text",className:Nt,value:t==null?"":String(t),placeholder:e.placeholder,maxLength:e.maxLength,pattern:e.pattern,disabled:n||e.disabled,onChange:a=>s(a.target.value)})})}function jS({field:e,value:t,onChange:s,disabled:n,translationFn:o}){const[a,i]=(0,h.useState)(t==null?"":String(t)),l=(0,h.useRef)(!1);(0,h.useEffect)(()=>{l.current||i(t==null?"":String(t))},[t]);const u=d=>{if(i(d),d===""||d==="-"){s(void 0);return}const f=Number(d);Number.isNaN(f)||s(f)};return(0,r.jsx)(je,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("input",{type:"number",className:Nt,value:a,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step,disabled:n||e.disabled,onFocus:()=>{l.current=!0},onBlur:()=>{l.current=!1},onChange:d=>u(d.target.value)}),e.unit&&(0,r.jsx)("span",{className:"text-xs text-foreground-subtle whitespace-nowrap",children:e.unit})]})})}function NS({field:e,value:t,onChange:s,disabled:n,translationFn:o}){const a=!!t,i=n||e.disabled;return e.style==="checkbox"?(0,r.jsx)(je,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:o,children:(0,r.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[(0,r.jsx)("input",{type:"checkbox",className:"h-3.5 w-3.5 rounded border-border accent-primary",checked:a,disabled:i,onChange:l=>s(l.target.checked)}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:Ke(e.label,o)}),e.required&&(0,r.jsx)("span",{className:"text-danger",children:"*"})]})}):(0,r.jsx)(je,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:o,children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("span",{className:Xr+" mb-0",children:[Ke(e.label,o),e.required&&(0,r.jsx)("span",{className:"text-danger ml-0.5",children:"*"})]}),(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":a,disabled:i,onClick:()=>!i&&s(!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:(0,r.jsx)("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 CS({field:e,value:t,onChange:s,disabled:n,translationFn:o}){const a=e.options.some(i=>i.value==="");return(0,r.jsx)(je,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:(0,r.jsxs)("select",{className:Nt,value:t==null?"":String(t),disabled:n||e.disabled,onChange:i=>s(i.target.value),children:[!e.required&&!a&&(0,r.jsx)("option",{value:"",children:"— Select —"}),e.options.map(i=>(0,r.jsx)("option",{value:i.value,children:i.label},i.value))]})})}function MS({field:e,value:t,onChange:s,disabled:n,translationFn:o}){const a=Array.isArray(t)?t:[],i=l=>{if(a.includes(l))s(a.filter(u=>u!==l));else{if(e.maxItems!==void 0&&a.length>=e.maxItems)return;s([...a,l])}};return(0,r.jsx)(je,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:e.options.map(l=>{const u=a.includes(l.value);return(0,r.jsxs)("label",{className:["flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs cursor-pointer select-none transition-colors",u?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground hover:bg-surface",n||e.disabled?"opacity-50 cursor-not-allowed":""].join(" "),children:[(0,r.jsx)("input",{type:"checkbox",className:"sr-only",checked:u,disabled:n||e.disabled,onChange:()=>i(l.value)}),l.label]},l.value)})})})}function ES({field:e,value:t,onChange:s,disabled:n,translationFn:o}){const[a,i]=(0,h.useState)(!1),l=e.showToggle!==!1;return(0,r.jsx)(je,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{type:a?"text":"password",className:Nt+(l?" pr-9":""),value:t==null?"":String(t),placeholder:e.placeholder,disabled:n||e.disabled,onChange:u=>s(u.target.value)}),l&&(0,r.jsx)("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",tabIndex:-1,onClick:()=>i(u=>!u),children:a?(0,r.jsx)(Yo,{className:"h-3.5 w-3.5"}):(0,r.jsx)(nr,{className:"h-3.5 w-3.5"})})]})})}function AS({field:e,value:t,onChange:s,disabled:n,translationFn:o}){return(0,r.jsx)(je,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:(0,r.jsx)("textarea",{className:Nt+" resize-y min-h-[60px]",value:t==null?"":String(t),placeholder:e.placeholder,rows:e.rows??3,maxLength:e.maxLength,disabled:n||e.disabled,onChange:a=>s(a.target.value)})})}function PS({field:e,value:t,onChange:s,disabled:n,translationFn:o}){const a=t==null,i=e.nullable===!0,l=a?e.default??e.min:Number(t),u=e.showValue!==!1,d=e.nullLabel??"Auto",f=n||e.disabled,m=e.displayScale??1,g=e.min/m,b=e.max/m,x=l/m,v=(e.step??1)/m;if(i&&a)return(0,r.jsx)(je,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:(0,r.jsxs)("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:()=>s(e.default??e.min),children:[d," — click to set manually"]})});const w=e.showStepper===!0&&u,y=k=>{const C=l+k*(e.step??1),N=Math.min(e.max,Math.max(e.min,C));N!==l&&s(N)},S="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(0,r.jsx)(je,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 basis-[160px] items-center gap-2",children:[(0,r.jsx)("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:g}),(0,r.jsx)("input",{type:"range",className:"min-w-0 flex-1 h-1 accent-primary cursor-pointer disabled:opacity-50",min:g,max:b,step:v,value:x,disabled:f,onChange:k=>s(Number(k.target.value)*m)}),(0,r.jsx)("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:b})]}),(u||i||e.unit)&&(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[w&&(0,r.jsx)("button",{type:"button",className:S,disabled:f||l<=e.min,onClick:()=>y(-1),title:`Decrease by ${e.step??1}`,"aria-label":"Decrement",children:(0,r.jsx)(na,{className:"h-3 w-3"})}),u&&(0,r.jsx)("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:g,max:b,step:v,value:x,disabled:f,onChange:k=>{if(k.target.value===""){s(i?null:e.min);return}const C=Number(k.target.value)*m,N=e.step??1,E=C-e.min,R=e.min+Math.round(E/N)*N;s(Math.min(e.max,Math.max(e.min,R)))}}),w&&(0,r.jsx)("button",{type:"button",className:S,disabled:f||l>=e.max,onClick:()=>y(1),title:`Increase by ${e.step??1}`,"aria-label":"Increment",children:(0,r.jsx)(or,{className:"h-3 w-3"})}),e.unit&&(0,r.jsx)("span",{className:"text-[10px] text-foreground-subtle",children:e.unit}),i&&(0,r.jsx)("button",{className:"text-[10px] text-foreground-subtle hover:text-primary transition-colors",title:`Reset to ${d}`,disabled:f,onClick:()=>s(null),children:d})]})]})})}function RS({field:e,value:t,onChange:s,disabled:n,translationFn:o}){const a=Array.isArray(t)?t:[],[i,l]=(0,h.useState)(""),u=(0,h.useRef)(null),d=(0,h.useCallback)(b=>{const x=b.trim();!x||a.includes(x)||e.maxTags!==void 0&&a.length>=e.maxTags||(s([...a,x]),l(""))},[a,e.maxTags,s]),f=b=>s(a.filter(x=>x!==b)),m=b=>{b.key==="Enter"||b.key===","?(b.preventDefault(),d(i)):b.key==="Backspace"&&i===""&&a.length>0&&f(a[a.length-1])},g=n||e.disabled;return(0,r.jsx)(je,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:(0,r.jsxs)("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",g?"opacity-50 cursor-not-allowed":""].join(" "),onClick:()=>!g&&u.current?.focus(),children:[a.map(b=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[b,!g&&(0,r.jsx)("button",{type:"button",onClick:()=>f(b),className:"hover:text-danger",children:(0,r.jsx)(Ee,{className:"h-2.5 w-2.5"})})]},b)),(0,r.jsx)("input",{ref:u,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:g,list:`tags-suggestions-${e.key}`,onChange:b=>l(b.target.value),onKeyDown:m,onBlur:()=>{i.trim()&&d(i)}}),e.suggestions&&(0,r.jsx)("datalist",{id:`tags-suggestions-${e.key}`,children:e.suggestions.map(b=>(0,r.jsx)("option",{value:b},b))})]})})}function al({field:e,value:t,onChange:s,disabled:n,translationFn:o}){const{nodes:a}=zr(),i=typeof t=="string"?t:"",l=e.showOffline?a:a.filter(u=>u.isOnline);return(0,r.jsx)(je,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:(0,r.jsxs)("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:u=>s(u.target.value),disabled:n,children:[(0,r.jsx)("option",{value:"",children:"Select node…"}),l.map(u=>(0,r.jsxs)("option",{value:u.id,disabled:!u.isOnline,children:[u.shortName,u.isOnline?"":" (offline)"]},u.id))]})})}function il({field:e,value:t,onChange:s,disabled:n,translationFn:o}){const{nodes:a}=zr(),i=new Set(Array.isArray(t)?t.map(String):[]),l=e.showOffline?a:a.filter(d=>d.isOnline),u=d=>{const f=new Set(i);f.has(d)?f.delete(d):f.add(d),s([...f])};return(0,r.jsx)(je,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:l.map(d=>{const f=i.has(d.id);return(0,r.jsx)("button",{type:"button",onClick:()=>u(d.id),disabled:n||!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 DS({field:e,value:t,onChange:s,disabled:n,translationFn:o}){const a=t==null?"#000000":String(t);return(0,r.jsxs)(je,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("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:n||e.disabled,onChange:i=>s(i.target.value)}),(0,r.jsx)("input",{type:"text",className:Nt+" flex-1 font-mono",value:a,placeholder:"#000000",disabled:n||e.disabled,onChange:i=>s(i.target.value)})]}),e.presets&&e.presets.length>0&&(0,r.jsx)("div",{className:"flex gap-1.5 mt-1.5",children:e.presets.map(i=>(0,r.jsx)("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:n||e.disabled,title:i,onClick:()=>s(i)},i))})]})}function TS({field:e,value:t,onChange:s,disabled:n,translationFn:o,onTestField:a,onAction:i,externalProbe:l}){const[u,d]=(0,h.useState)("idle"),[f,m]=(0,h.useState)(null),g=l?.status??u,b=l?.result??f,x=!!a||!!i,v=(0,h.useCallback)(async()=>{if(x){d("probing"),m(null);try{const S=a?await a(e.key,t):await i("test-probe",e.key,t),k=S&&typeof S=="object"?S:{status:"error",error:"Probe handler returned no result"};m(k),d(k.status==="ok"?"ok":"error")}catch(S){m({status:"error",error:S instanceof Error?S.message:String(S)}),d("error")}}},[a,i,e.key,t,x]),w=g==="probing"?"border-primary/40 bg-primary/10 text-primary":g==="ok"?"border-success/40 bg-success/10 text-success hover:bg-success/15":g==="error"?"border-danger/40 bg-danger/10 text-danger hover:bg-danger/15":"border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover",y=g==="probing"?(0,r.jsx)(qe,{className:"h-3 w-3 animate-spin"}):g==="ok"?(0,r.jsx)(Qd,{className:"h-3 w-3"}):g==="error"?(0,r.jsx)(_r,{className:"h-3 w-3"}):(0,r.jsx)(fa,{className:"h-3 w-3"});return(0,r.jsxs)(je,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:[(0,r.jsxs)("div",{className:"@container flex items-center gap-2",style:{containerType:"inline-size"},children:[(0,r.jsxs)("button",{type:"button",onClick:v,title:"Test",disabled:e.disabled||g==="probing"||!x||!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 ${w}`,children:[y,(0,r.jsx)("span",{className:"hidden @[280px]:inline",children:"Test"})]}),(0,r.jsx)("input",{type:e.inputType??"url",className:Nt+" flex-1 min-w-0",value:t==null?"":String(t),placeholder:e.placeholder,disabled:n||e.disabled,onChange:S=>{s(S.target.value),u!=="idle"&&(d("idle"),m(null))}})]}),g==="ok"&&b?.labels&&b.labels.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1 mt-1.5",children:b.labels.map((S,k)=>(0,r.jsx)("span",{className:"text-xs bg-success/10 text-success rounded px-2 py-0.5 font-mono",children:S},k))}),g==="error"&&b?.error&&(0,r.jsx)("p",{className:"text-xs text-danger mt-1 truncate",title:b.error,children:b.error})]})}function IS({field:e,values:t,onChange:s,disabled:n,translationFn:o,onTestField:a}){const[i,l]=(0,h.useState)(e.defaultCollapsed??!1),u=e.style==="accordion";return(0,r.jsx)("div",{className:e.span===2?"col-span-2":e.span===3?"col-span-3":e.span===4?"col-span-4":"col-span-1",children:(0,r.jsxs)("div",{className:"rounded-lg border border-border bg-surface/50 overflow-hidden",children:[(0,r.jsxs)("div",{className:["px-3 py-2 flex items-center justify-between",u?"cursor-pointer hover:bg-surface":""].join(" "),onClick:u?()=>l(d=>!d):void 0,children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:Ke(e.label,o)}),u&&(0,r.jsx)("span",{className:"text-foreground-subtle text-xs",children:i?"▸":"▾"})]}),!i&&(0,r.jsx)("div",{className:"px-3 pb-3 grid grid-cols-2 gap-x-4 gap-y-3",children:e.fields.map(d=>(0,r.jsx)(Qt,{field:d,values:t,onChange:s,disabled:n,translationFn:o,onTestField:a},d.key))})]})})}function LS({field:e,values:t,onChange:s,disabled:n,translationFn:o,onTestField:a,onAction:i}){const[l,u]=(0,h.useState)(e.tabs[0]?.id??""),d=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:(0,r.jsxs)("div",{className:d,children:[e.label&&(0,r.jsx)("div",{className:Xr,children:Ke(e.label,o)}),(0,r.jsxs)("div",{className:"rounded-lg border border-border-subtle bg-surface-hover/40 overflow-hidden",children:[(0,r.jsx)("div",{className:"flex flex-wrap gap-1 p-1.5 border-b border-border-subtle bg-surface/40",role:"tablist",children:e.tabs.map(f=>{const m=f.id===l;return(0,r.jsxs)("button",{type:"button",role:"tab","aria-selected":m,onClick:()=>u(f.id),className:`inline-flex items-center gap-1.5 whitespace-nowrap rounded-md px-2.5 py-1 text-[11px] transition-colors ${m?"bg-primary text-primary-foreground font-medium shadow-sm":"bg-transparent text-foreground-subtle hover:bg-surface hover:text-foreground"}`,children:[(0,r.jsx)("span",{children:Ke(f.label,o)}),f.badge&&(0,r.jsx)("span",{className:`text-[9px] px-1 py-0.5 rounded-full font-medium ${m?"bg-primary-foreground/20 text-primary-foreground":"bg-primary/10 text-primary"}`,children:f.badge})]},f.id)})}),e.tabs.map(f=>f.id!==l?null:(0,r.jsx)("div",{role:"tabpanel",className:"px-3 pb-3 pt-2 grid grid-cols-2 gap-x-4 gap-y-3",children:f.fields.map((m,g)=>{const b="key"in m&&typeof m.key=="string"?m.key:`__${f.id}__${g}`;return(0,r.jsx)(Qt,{field:m,values:t,onChange:s,disabled:n,translationFn:o,onTestField:a,onAction:i},b)})},f.id))]})]})}function OS({span:e}){return(0,r.jsx)("div",{className:e===2?"col-span-2":e===3?"col-span-3":e===4?"col-span-4":"col-span-full",children:(0,r.jsx)("hr",{className:"border-border"})})}var ll={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 _S(e){if(typeof window>"u"||typeof DOMParser>"u")return"";const t=new Set(["A","UL","OL","LI","STRONG","EM","CODE","BR","P","SPAN"]),s=new DOMParser().parseFromString(`<div>${e}</div>`,"text/html"),n=s.body.firstElementChild;if(!n)return"";const o=a=>{const i=Array.from(a.children);for(const l of i){if(!t.has(l.tagName)){const d=s.createTextNode(l.textContent??"");l.replaceWith(d);continue}const u=l.tagName==="A"?new Set(["href"]):new Set;for(const d of Array.from(l.attributes))u.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"))}o(l)}};return o(n),n.innerHTML}function $S({field:e}){const t=ll[e.variant??"info"]??ll.info,s=e.format==="html";return(0,r.jsx)("div",{className:"col-span-full",children:(0,r.jsxs)("div",{className:`rounded-md border-l-4 px-3 py-2.5 ${t.border} ${t.bg}`,children:[e.label&&(0,r.jsx)("p",{className:`text-xs font-semibold mb-0.5 ${t.text}`,children:e.label}),s?(0,r.jsx)("div",{className:"text-xs text-foreground-subtle leading-relaxed info-html-content",dangerouslySetInnerHTML:{__html:_S(e.content)}}):(0,r.jsx)("p",{className:"text-xs text-foreground-subtle leading-relaxed whitespace-pre-line",children:e.content})]})})}var cl={ok:"bg-success",warn:"bg-amber-500",danger:"bg-danger",idle:"bg-foreground-subtle/40",unknown:"bg-foreground-subtle/40"};function GS(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 s=Math.floor(t/60),n=t%60;return n===0?`${s}m`:`${s}m ${n}s`}function BS(e){return!Number.isFinite(e)||e<=0?"—":new Date(e).toLocaleTimeString()}function FS({kind:e,value:t}){return t==null||t===""?(0,r.jsx)("span",{className:"text-foreground-subtle/60",children:"—"}):e==="monospace"?(0,r.jsx)("span",{className:"font-mono text-[11px]",children:String(t)}):e==="status"?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${cl[String(t).toLowerCase()]??cl.unknown}`}),(0,r.jsx)("span",{children:String(t)})]}):e==="duration"&&typeof t=="number"?(0,r.jsx)("span",{className:"font-mono text-[11px]",children:GS(t)}):e==="timestamp"&&typeof t=="number"?(0,r.jsx)("span",{className:"font-mono text-[11px]",children:BS(t)}):(0,r.jsx)("span",{children:String(t)})}function zS({field:e}){const t=e.value??[],s=e.description;return(0,r.jsxs)("div",{className:"col-span-full",children:[e.label&&(0,r.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1",children:e.label}),s&&(0,r.jsx)("p",{className:"text-xs text-foreground-subtle mb-2",children:s}),t.length===0?(0,r.jsx)("div",{className:"rounded-md border border-border bg-surface-subtle px-3 py-2 text-xs text-foreground-subtle",children:e.emptyMessage??"No entries"}):(0,r.jsx)("div",{className:"rounded-md border border-border overflow-hidden",children:(0,r.jsxs)("table",{className:"w-full text-xs",children:[(0,r.jsx)("thead",{className:"bg-surface-subtle border-b border-border",children:(0,r.jsx)("tr",{children:e.columns.map(n=>(0,r.jsx)("th",{className:"px-3 py-1.5 text-left font-medium text-foreground-subtle",style:n.width?{width:n.width}:void 0,children:n.label},n.key))})}),(0,r.jsx)("tbody",{className:"divide-y divide-border",children:t.map((n,o)=>(0,r.jsx)("tr",{className:"hover:bg-surface-hover/40",children:e.columns.map(a=>(0,r.jsx)("td",{className:"px-3 py-1.5 align-top text-foreground",children:(0,r.jsx)(FS,{kind:a.kind,value:n[a.key]})},a.key))},o))})]})})]})}function QS({field:e,value:t,onChange:s,disabled:n,translationFn:o,onTestField:a,onAction:i}){const l=Array.isArray(t)?t:[],u=e.minRows??0,d=e.maxRows??Number.POSITIVE_INFINITY,f=(w,y,S)=>{const k=l.slice();k[w]={...k[w]??{},[y]:S},s(k)},m=w=>{l.length<=u||s(l.filter((y,S)=>S!==w))},g=()=>{if(l.length>=d)return;const w=e.defaultItem??{};s([...l,{...w}])},b=(w,y)=>e.rowTitleTemplate?e.rowTitleTemplate.replace(/\{(\w+)\}/g,(S,k)=>{const C=w[k];return C==null||C===""?"—":String(C)}):`Row ${y+1}`,x=l.length>u,v=l.length<d;return(0,r.jsxs)("div",{className:"col-span-full space-y-2",children:[(0,r.jsxs)("div",{className:"space-y-0.5",children:[e.label&&(0,r.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:Ke(e.label,o)}),e.description&&(0,r.jsx)("p",{className:"text-[11px] text-foreground-subtle",children:Ke(e.description,o)})]}),l.length===0?(0,r.jsx)("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"}):(0,r.jsx)("div",{className:"space-y-2",children:l.map((w,y)=>(0,r.jsxs)("div",{className:"rounded-md border border-border bg-background",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:b(w,y)}),(0,r.jsxs)("button",{type:"button",onClick:()=>m(y),disabled:n||!x,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:x?"Remove this row":`At least ${u} row(s) required`,children:[(0,r.jsx)(na,{className:"h-3 w-3"}),"Remove"]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 @[420px]:grid-cols-2 gap-x-3 gap-y-2 p-3",children:e.itemFields.map(S=>(0,r.jsx)(Qt,{field:S,values:w,onChange:(k,C)=>f(y,k,C),disabled:n,translationFn:o,onTestField:a,allFields:e.itemFields,onAction:i},S.key))})]},y))}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{type:"button",onClick:g,disabled:n||!v,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:[(0,r.jsx)(or,{className:"h-3 w-3"}),e.addLabel??"Add"]}),!v&&Number.isFinite(d)&&(0,r.jsxs)("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["(limit: ",d,")"]})]})]})}function US({field:e,disabled:t,onAction:s}){const[n,o]=(0,h.useState)(!1),a=Qr(),i=async()=>{if(!(e.confirmMessage&&!await a({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant==="danger"?"danger":"default"}))&&s){o(!0);try{await s(e.action,e.key)}finally{o(!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(0,r.jsx)(je,{label:e.label,description:e.description,required:e.required,span:e.span,children:(0,r.jsx)("button",{onClick:i,disabled:t||n,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:n?"Processing...":e.buttonLabel})})}function ul(e,t){const s={...e.paramsStatic??{}};if(e.paramsFromForm)for(const[n,o]of Object.entries(e.paramsFromForm)){const a=t[o];a!=null&&a!==""&&(s[n]=a)}return s}function HS({field:e,value:t,values:s,onChange:n,disabled:o,onAction:a}){const[i,l]=(0,h.useState)(!1),[u,d]=(0,h.useState)(null),[f,m]=(0,h.useState)(null),g=ul(e,s),b=Object.keys(e.paramsFromForm??{}).some(y=>g[y]===void 0);(0,h.useEffect)(()=>{if(!a||b){m(null),d(null);return}let y=!1;return l(!0),d(null),a(e.action,e.key,g).then(S=>{if(y)return;const k=S;let C=[];if(Array.isArray(k))C=k;else if(k&&typeof k=="object")for(const N of Object.keys(k)){const E=k[N];if(Array.isArray(E)){C=E;break}}m(C)}).catch(S=>{y||(d(S instanceof Error?S.message:String(S)),m([]))}).finally(()=>{y||l(!1)}),()=>{y=!0}},[(e.refreshOn??Object.values(e.paramsFromForm??{})).map(y=>`${y}=${JSON.stringify(s[y])}`).join("|"),a,e.action,e.key]);const x=e.mapOption.value,v=e.mapOption.label,w=e.mapOption.description;return(0,r.jsx)(je,{label:e.label,description:e.description,required:e.required,span:e.span,children:b?(0,r.jsx)("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyParamsMessage??"Fill the prerequisite fields above first."}):i?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-foreground-subtle",children:[(0,r.jsx)(qe,{className:"h-3 w-3 animate-spin"})," Loading options…"]}):u?(0,r.jsx)("div",{className:"text-[11px] text-danger",children:u}):f&&f.length===0?(0,r.jsx)("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyResultsMessage??"No options returned."}):(()=>{const y=(f??[]).some(S=>{const k=S[x];return k===""||k===void 0});return(0,r.jsxs)("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:o,onChange:S=>n(S.target.value),children:[!y&&(0,r.jsx)("option",{value:"",children:"— Select —"}),(f??[]).map((S,k)=>{const C=S[x],N=S[v],E=w?S[w]:void 0,R=typeof C=="string"&&C!==""?C:`row-${k}`;return(0,r.jsxs)("option",{value:typeof C=="string"?C:String(C??""),children:[typeof N=="string"?N:String(N??R),E!==void 0?` (${String(E)})`:""]},R)})]})})()})}function VS({field:e,values:t,disabled:s,onAction:n}){const[o,a]=(0,h.useState)(!1),[i,l]=(0,h.useState)(null),u=Qr(),d=async()=>{if(e.confirmMessage&&!await u({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant==="danger"?"danger":"default"})||!n)return;const m=ul(e,t);a(!0),l(null);try{const g=await n(e.action,e.key,m),b=typeof g=="object"&&g!==null?g:null;l({kind:"ok",text:e.successMessage?e.successMessage.replace(/\{(\w+)\}/g,(x,v)=>{const w=b?.[v];return w===void 0?"":String(w)}):"Done."})}catch(g){l({kind:"error",text:g instanceof Error?g.message:String(g)})}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(0,r.jsx)(je,{label:e.label,description:e.description,required:e.required,span:e.span,children:(0,r.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,r.jsx)("button",{onClick:d,disabled:s||o,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:o?"Working…":e.buttonLabel}),i&&(0,r.jsx)("div",{className:`text-[11px] ${i.kind==="ok"?"text-emerald-700 dark:text-emerald-300":"text-danger"}`,children:i.text})]})})}function WS({field:e}){const t=Yi();return(0,r.jsx)(je,{label:e.label,description:e.description,required:e.required,span:e.span,children:(0,r.jsx)(ol,{widgetId:e.widgetId,host:"device-tab",config:e.widgetConfig,deviceId:t??void 0,instanceId:e.key})})}function qS(e,t){if(e==null)return"—";if(typeof e=="boolean")return e?"yes":"no";if(typeof e=="number"){const s=Number.isInteger(e)?String(e):e.toFixed(2);return t?`${s} ${t}`:s}return typeof e=="string"?e:JSON.stringify(e)}function KS({field:e,values:t,onAction:s,translationFn:n}){const o="key"in e?e.key:void 0;if(!o)return null;const a=t[o],i=a!==void 0?a:"default"in e?e.default:void 0,l=qS(i,"unit"in e?e.unit:void 0),u="label"in e?e.label:void 0,d="description"in e?e.description:void 0,f="span"in e?e.span:void 0,m="actions"in e?e.actions??[]:[];return(0,r.jsx)(je,{label:u,description:d,span:f,translationFn:n,children:(0,r.jsxs)("div",{className:"flex items-stretch gap-1",children:[(0,r.jsx)("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:l}),m.length>0&&(0,r.jsx)("div",{className:"flex items-center gap-1",children:m.map(g=>(0,r.jsx)(YS,{action:g,fieldKey:o,value:i,onAction:s},g.action))})]})})}function ZS({name:e}){const t="h-3.5 w-3.5";switch(e){case"copy":return(0,r.jsx)(pt,{className:t});case"refresh-cw":return(0,r.jsx)(Ls,{className:t});case"external-link":return(0,r.jsx)(Zo,{className:t});case"trash-2":return(0,r.jsx)(et,{className:t});case"download":return(0,r.jsx)(Rs,{className:t});case"upload":return(0,r.jsx)(da,{className:t});default:return(0,r.jsx)(Os,{className:t})}}function YS({action:e,fieldKey:t,value:s,onAction:n}){const o=Qr(),[a,i]=(0,h.useState)(!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",u=async()=>{if(!(e.confirmMessage&&!await o({title:e.tooltip,message:e.confirmMessage,variant:e.variant==="danger"?"danger":"default"}))){if(e.action==="copy-value"){try{await navigator.clipboard.writeText(typeof s=="string"?s:String(s))}catch{}return}if(n){i(!0);try{await n(e.action,t)}finally{i(!1)}}}};return(0,r.jsx)("button",{type:"button",onClick:u,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:(0,r.jsx)(ZS,{name:e.icon})})}function XS(e){return"multiple"in e&&e.multiple!=null}function JS({field:e,values:t,onChange:s,disabled:n,translationFn:o,onTestField:a,externalProbe:i,allFields:l,onAction:u}){const d=e.multiple,f=d.min,m=d.max,g=t[e.key],b=[...Array.isArray(g)?g:g!=null?[g]:[]],x=d.itemDefault!==void 0?d.itemDefault:"default"in e&&e.default!==void 0?e.default:"";for(;b.length<f;)b.push(x);const v=C=>s(e.key,[...C]),w=(C,N)=>{const E=[...b];E[C]=N,v(E)},y=()=>{b.length>=m||v([...b,x])},S=C=>{b.length<=f||v(b.filter((N,E)=>E!==C))},k=()=>{const{multiple:C,...N}=e;return{...N,...{label:void 0,description:void 0,required:!1}}};return(0,r.jsx)(je,{label:e.label,description:e.description,required:f>0?e.required:!1,span:e.span,translationFn:o,children:(0,r.jsxs)("div",{className:"space-y-2",children:[b.map((C,N)=>{const E=d.itemLabel?.replace("${n}",String(N+1));return(0,r.jsxs)("div",{className:"space-y-1",children:[E&&(0,r.jsx)("div",{className:Xr,children:E}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsx)(Qt,{field:k(),values:{...t,[e.key]:C},onChange:(R,A)=>w(N,A),disabled:n,translationFn:o,onTestField:a,onAction:u,allFields:l})}),b.length>f&&(0,r.jsx)("button",{type:"button",onClick:()=>S(N),disabled:n,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:(0,r.jsx)(et,{className:"h-3.5 w-3.5"})})]})]},N)}),(0,r.jsxs)("div",{className:"flex items-center justify-between pt-1",children:[b.length<m?(0,r.jsxs)("button",{type:"button",onClick:y,disabled:n,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:[(0,r.jsx)(or,{className:"h-3 w-3"}),d.addLabel??"Add"]}):(0,r.jsx)("span",{}),(0,r.jsxs)("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[b.length,"/",m]})]})]})})}function dl(e,t,s){if(!("showWhen"in e)||!e.showWhen)return!0;const n=e.showWhen,o=t[n.field],a=s?.find(u=>"key"in u&&u.key===n.field),i=a&&"default"in a?a.default:void 0,l=o!==void 0?o:i;return n.equals!==void 0?l===n.equals:n.notEquals!==void 0?l!==n.notEquals:n.in!==void 0?n.in.includes(l):n.notIn!==void 0?!n.notIn.includes(l):n.includes!==void 0?Array.isArray(l)&&l.includes(n.includes):n.notIncludes!==void 0?!Array.isArray(l)||!l.includes(n.notIncludes):!0}function Qt({field:e,values:t,onChange:s,disabled:n,translationFn:o,onTestField:a,externalProbe:i,allFields:l,onAction:u}){if(XS(e))return(0,r.jsx)(JS,{field:e,values:t,onChange:s,disabled:n,translationFn:o,onTestField:a,externalProbe:i,allFields:l,onAction:u});if("readonlyField"in e&&e.readonlyField===!0)return(0,r.jsx)(KS,{field:e,values:t,onAction:u,translationFn:o});if(!dl(e,t,l))return null;const d=t[e.key],f=d!==void 0?d:"default"in e?e.default:void 0,m=b=>s(e.key,b),g=Zi(e.type);switch(e.type){case"text":return(0,r.jsx)(kS,{field:e,value:f,onChange:m,disabled:n,translationFn:o});case"number":return(0,r.jsx)(jS,{field:e,value:f,onChange:m,disabled:n,translationFn:o});case"boolean":return(0,r.jsx)(NS,{field:e,value:f,onChange:m,disabled:n,translationFn:o});case"select":return(0,r.jsx)(CS,{field:e,value:f,onChange:m,disabled:n,translationFn:o});case"multiselect":return(0,r.jsx)(MS,{field:e,value:f,onChange:m,disabled:n,translationFn:o});case"password":return(0,r.jsx)(ES,{field:e,value:f,onChange:m,disabled:n,translationFn:o});case"textarea":return(0,r.jsx)(AS,{field:e,value:f,onChange:m,disabled:n,translationFn:o});case"slider":return(0,r.jsx)(PS,{field:e,value:f,onChange:m,disabled:n,translationFn:o});case"tags":return(0,r.jsx)(RS,{field:e,value:f,onChange:m,disabled:n,translationFn:o});case"color":return(0,r.jsx)(DS,{field:e,value:f,onChange:m,disabled:n,translationFn:o});case"node-select":return(0,r.jsx)(al,{field:e,value:f,onChange:m,disabled:n,translationFn:o});case"node-multiselect":return(0,r.jsx)(il,{field:e,value:f,onChange:m,disabled:n,translationFn:o});case"probe":return(0,r.jsx)(TS,{field:e,value:f,onChange:m,disabled:n,translationFn:o,onTestField:a,onAction:u,externalProbe:i});case"group":return(0,r.jsx)(IS,{field:e,values:t,onChange:s,disabled:n,translationFn:o,onTestField:a});case"sub-tabs":return(0,r.jsx)(LS,{field:e,values:t,onChange:s,disabled:n,translationFn:o,onTestField:a,onAction:u});case"separator":return(0,r.jsx)(OS,{});case"info":return(0,r.jsx)($S,{field:e});case"object-array":return(0,r.jsx)(zS,{field:e});case"editable-array":return(0,r.jsx)(QS,{field:e,value:f,onChange:m,disabled:n,translationFn:o,onTestField:a,onAction:u});case"button":return(0,r.jsx)(US,{field:e,disabled:n,onAction:u});case"addon-action-select":return(0,r.jsx)(HS,{field:e,value:f,values:t,onChange:m,disabled:n,onAction:u});case"addon-action-button":return(0,r.jsx)(VS,{field:e,values:t,disabled:n,onAction:u});case"widget":return(0,r.jsx)(WS,{field:e});default:return g?(0,r.jsx)(g,{field:e,value:f,onChange:m,disabled:n}):null}}function ek(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Ke(e,t){if(e!==void 0)return t&&ek(e)?t(e):e}function tk({section:e,values:t,onChange:s,disabled:n,translationFn:o,onTestField:a,probeResults:i}){const[l,u]=(0,h.useState)(e.defaultCollapsed??!1),d=e.style==="accordion",f=e.columns??2,m=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(0,r.jsxs)("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[(0,r.jsxs)("div",{className:["flex items-center justify-between mb-2",d?"cursor-pointer":""].join(" "),onClick:d?()=>u(g=>!g):void 0,children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:Ke(e.title,o)}),e.description&&(0,r.jsx)("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:Ke(e.description,o)})]}),d&&(0,r.jsx)("span",{className:"text-foreground-subtle text-xs ml-2",children:l?"▸":"▾"})]}),!l&&(0,r.jsx)("div",{className:`grid ${m} gap-x-3 gap-y-2.5`,children:e.fields.map(g=>(0,r.jsx)(Qt,{field:g,values:t,onChange:s,disabled:n,translationFn:o,onTestField:a,externalProbe:i?.[g.key]},g.key))})]})}function fl({schema:e,values:t,onChange:s,disabled:n,translationFn:o,onTestField:a,probeResults:i,onClearProbe:l}){const u=(d,f)=>{s({...t,[d]:f}),l?.(d)};return(0,r.jsx)("div",{className:"space-y-4",children:e.sections.map(d=>(0,r.jsx)(tk,{section:d,values:t,onChange:u,disabled:n,translationFn:o,onTestField:a,probeResults:i},d.id))})}var rk=({open:e})=>(0,r.jsx)("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:(0,r.jsx)("polyline",{points:"9 18 15 12 9 6"})});function ml(e){const t={};if(!e)return t;for(const s of e.sections)for(const n of s.fields){if(n.type==="separator"||n.type==="info"||n.type==="button"||n.type==="group")continue;const o=n.key;t[o]=n.value}return t}function sk(e){return{...e,sections:e.sections.map(t=>({...t,fields:t.fields.map(s=>{if(s.type==="separator"||s.type==="info"||s.type==="button"||s.type==="group")return s;const{value:n,...o}=s;return o})}))}}function nk({trpc:e,addonId:t,nodeId:s,title:n,disabled:o,onAfterChange:a,refreshToken:i,collapsible:l,defaultOpen:u,mode:d,onOverrideChange:f}){const m=d??"persist",[g,b]=(0,h.useState)(null),[x,v]=(0,h.useState)(!0),[w,y]=(0,h.useState)(null),[S,k]=(0,h.useState)(!1),[C,N]=(0,h.useState)(u??!1),[E,R]=(0,h.useState)({}),[A,Q]=(0,h.useState)(null);(0,h.useEffect)(()=>{Q(null),R({})},[e,t,s,i,m]),(0,h.useEffect)(()=>{let se=!1;v(!0),y(null);const J=m==="override"&&Object.keys(E).length>0?E:void 0;return e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:s,...J?{overlay:J}:{}}).then(H=>{se||(b(H),J||Q(ml(H)),v(!1))}).catch(H=>{se||(y(H instanceof Error?H.message:String(H)),v(!1))}),()=>{se=!0}},[e,t,s,i,m,JSON.stringify(E)]);const ee=(0,h.useMemo)(()=>ml(g),[g]),ne=(0,h.useMemo)(()=>g?sk(g):null,[g]),pe=async se=>{if(m==="override"){const H=A??ee,xe={};for(const D of Object.keys(se))se[D]!==H[D]&&(xe[D]=se[D]);const de={...H,...xe};R(xe),f?.(xe,de);return}const J={};for(const H of Object.keys(se))se[H]!==ee[H]&&(J[H]=se[H]);if(Object.keys(J).length!==0){k(!0);try{await e.addonSettings.updateGlobalSettings.mutate({addonId:t,nodeId:s,patch:J}),b(await e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:s})),a?.()}catch(H){y(H instanceof Error?H.message:String(H))}finally{k(!1)}}};if(x)return(0,r.jsxs)("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading ",n??t,"…"]});if(w)return(0,r.jsxs)("div",{className:"text-xs text-red-400",children:[n??t,": ",w]});if(!g||!ne)return(0,r.jsxs)("div",{className:"text-xs text-foreground-subtle",children:[n??t," not available on ",s,"."]});const ae=m==="override"?{...ee,...E}:ee,ce=(0,r.jsxs)(r.Fragment,{children:[m==="override"?(0,r.jsx)("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,(0,r.jsx)(fl,{schema:ne,values:ae,onChange:pe,disabled:o===!0||S})]});return l===!0?(0,r.jsxs)("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>N(se=>!se),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover text-left","aria-expanded":C,children:[(0,r.jsx)(rk,{open:C}),(0,r.jsx)("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide flex-1",children:n??t}),(0,r.jsx)("span",{className:"text-[10px] text-foreground-subtle",children:C?"hide":"edit"})]}),C?(0,r.jsx)("div",{className:"border-t border-border px-4 py-3",children:ce}):null]}):n?(0,r.jsxs)("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[(0,r.jsx)("div",{className:"border-b border-border px-4 py-2",children:(0,r.jsx)("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:n})}),(0,r.jsx)("div",{className:"px-4 py-3",children:ce})]}):(0,r.jsx)("div",{children:ce})}function pl({detections:{motion:e,motionRaw:t,detection:s,phase:n},showMotionZones:o=!0,showMotionRaw:a=!0,showDetections:i=!0,showPhaseIndicator:l=!0}){const u=o&&e&&e.zones.length>0,d=a&&t&&t.boxes.length>0,f=i&&s&&s.detections.length>0;return!u&&!d&&!f&&!l?null:(0,r.jsxs)("div",{className:"absolute inset-0 pointer-events-none z-10",children:[l&&(0,r.jsx)(ok,{phase:n}),d&&(0,r.jsx)(ak,{raw:t}),u&&(0,r.jsx)(ik,{motion:e}),f&&(0,r.jsx)(lk,{detections:s.detections,frameWidth:s.frameWidth,frameHeight:s.frameHeight})]})}function ok({phase:e}){const t=us(e);return(0,r.jsxs)("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:[(0,r.jsx)("span",{className:`w-2 h-2 rounded-full ${t.dotClass}`}),(0,r.jsx)("span",{className:"text-[10px] font-semibold text-white uppercase tracking-wider",children:t.label})]})}function ak({raw:e}){return e.frameWidth===0||e.frameHeight===0?null:(0,r.jsx)(r.Fragment,{children:e.boxes.map((t,s)=>{const[n,o,a,i]=t.bbox,l=n/e.frameWidth*100,u=o/e.frameHeight*100,d=(a-n)/e.frameWidth*100,f=(i-o)/e.frameHeight*100,m=Math.max(.05,Math.min(.25,t.changeScore*.3));return(0,r.jsx)("div",{className:"absolute rounded-sm",style:{left:`${l}%`,top:`${u}%`,width:`${d}%`,height:`${f}%`,backgroundColor:`rgba(239, 68, 68, ${m})`}},`mr-${s}`)})})}function ik({motion:e}){return e.frameWidth===0||e.frameHeight===0?null:(0,r.jsx)(r.Fragment,{children:e.zones.filter(t=>t.w*t.h/(e.frameWidth*e.frameHeight)<.9).map((t,s)=>{const n=Math.max(.15,Math.min(.5,t.intensity/255));return(0,r.jsx)("div",{className:"absolute rounded-sm",style:{left:`${t.x/e.frameWidth*100}%`,top:`${t.y/e.frameHeight*100}%`,width:`${t.w/e.frameWidth*100}%`,height:`${t.h/e.frameHeight*100}%`,border:`1px solid rgba(250, 204, 21, ${n})`,backgroundColor:`rgba(250, 204, 21, ${n*.15})`}},`mz-${s}`)})})}function lk({detections:e,frameWidth:t,frameHeight:s}){return t===0||s===0?null:(0,r.jsx)(r.Fragment,{children:e.map(n=>{const{x:o,y:a,width:i,height:l}=n.bbox,u=o/t*100,d=a/s*100,f=i/t*100,m=l/s*100,g=_e(n.macroClass),b=[`${n.macroClass} ${(n.score*100).toFixed(0)}%`];for(const x of n.labels)b.push(x.label);return(0,r.jsx)("div",{className:"absolute border-2 rounded-sm",style:{left:`${u}%`,top:`${d}%`,width:`${f}%`,height:`${m}%`,borderColor:g},children:(0,r.jsx)("div",{className:"absolute -top-4 left-0 px-1 py-0.5 text-[9px] font-bold text-white rounded-sm whitespace-nowrap",style:{backgroundColor:g},children:b.join(" | ")})},`det-${n.id}`)})})}function ck(e){const t={};if(typeof window<"u"){if(e){const n=e.getBoundingClientRect();n.width>0&&n.height>0&&(t.viewportWidth=Math.round(n.width),t.viewportHeight=Math.round(n.height))}t.viewportWidth===void 0&&(t.viewportWidth=window.innerWidth,t.viewportHeight=window.innerHeight),t.devicePixelRatio=window.devicePixelRatio||1;const s=navigator.connection;s?.downlink&&s.downlink>0&&(t.downlinkMbps=s.downlink)}return t}var uk=3e3,dk=5;function hl({serverUrl:e,streamKey:t,label:s,autoPlay:n=!0,muted:o=!0,showControls:a=!0,className:i="",onStateChange:l,onError:u,overlay:d,createSession:f,sendAnswer:m,closeSession:g,hintsOverride:b}){const x=(0,h.useRef)(null),v=(0,h.useRef)(null),w=(0,h.useRef)(null),y=(0,h.useRef)(new Set),S=(0,h.useRef)(null),k=(0,h.useRef)(null),C=(0,h.useRef)(0),N=(0,h.useRef)(!0),[E,R]=(0,h.useState)("idle"),[A,Q]=(0,h.useState)(""),[ee,ne]=(0,h.useState)(o),[pe,ae]=(0,h.useState)(!1),[ce,se]=(0,h.useState)(!1),J=(0,h.useRef)(null),H=(0,h.useRef)(!1);(m||f)&&(H.current=!0);const xe=H.current,de=(0,h.useCallback)(K=>{R(K),l?.(K)},[l]),D=(0,h.useCallback)(()=>{if(S.current?.abort(),S.current=null,k.current&&(clearTimeout(k.current),k.current=null),w.current&&(w.current.close(),w.current=null),g&&y.current.size>0){for(const K of y.current)g(K).catch(()=>{});y.current.clear()}x.current&&(x.current.srcObject=null)},[g]),$=(0,h.useCallback)(async()=>{if(!N.current||!f||!m)return;D(),de("connecting");const K=new AbortController;S.current=K;try{const{sessionId:ue,sdpOffer:ve}=await f({...ck(v.current),...b});if(y.current.add(ue),!N.current||K.signal.aborted){g?.(ue).catch(()=>{}),y.current.delete(ue);return}const ye=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});w.current=ye;const L=new MediaStream;ye.ontrack=I=>{console.debug("[WebRTC] ontrack",I.track.kind,I.track.readyState),L.addTrack(I.track),x.current&&(x.current.srcObject=L,x.current.play().catch(()=>{}))},ye.oniceconnectionstatechange=()=>{if(!N.current)return;const I=ye.iceConnectionState;console.debug("[WebRTC] ICE state:",I),I==="connected"||I==="completed"?(C.current=0,de("playing"),x.current?.paused&&(console.debug("[WebRTC] video was paused at ICE connected — calling play()"),x.current.play().catch(()=>{}))):(I==="failed"||I==="disconnected"||I==="closed")&&(de("disconnected"),V())},ye.onicecandidateerror=I=>{console.debug("[WebRTC] ICE candidate error:",I)},console.debug("[WebRTC] Setting remote description (server offer)..."),await ye.setRemoteDescription({type:"offer",sdp:ve});const M=await ye.createAnswer();if(await ye.setLocalDescription(M),console.debug("[WebRTC] Local description set, waiting for ICE gathering..."),await gl(ye),!N.current)return;const T=(ye.localDescription?.sdp??"").split(`
77
+ `).filter(I=>I.startsWith("a=candidate:")).length;console.debug("[WebRTC] Sending answer to server",{localCandidates:T,sessionId:ue.slice(0,8)}),await m(ue,ye.localDescription?.sdp??""),console.debug("[WebRTC] Answer sent successfully");const Z=ye,re=()=>{const I=Z.connectionState;if(I==="closed"||I==="failed")return;const Y=x.current;Y&&Y.readyState===0&&console.log(`[WebRTC] no video data yet (ice=${Z.iceConnectionState})`)};setTimeout(re,3e3),setTimeout(re,8e3)}catch(ue){if(!N.current)return;const ve=ue instanceof Error?ue.message:String(ue);Q(ve),de("error"),u?.(ve),V()}},[e,t,f,m,D,de,u,b]),_=(0,h.useCallback)(async()=>{if(N.current){D(),de("connecting");try{const K=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});w.current=K,K.addTransceiver("video",{direction:"recvonly"}),K.addTransceiver("audio",{direction:"recvonly"});const ue=new MediaStream;K.ontrack=T=>{ue.addTrack(T.track),x.current&&(x.current.srcObject=ue,x.current.play().catch(()=>{}))},K.oniceconnectionstatechange=()=>{if(!N.current)return;const T=K.iceConnectionState;T==="connected"||T==="completed"?(C.current=0,de("playing"),x.current?.paused&&x.current.play().catch(()=>{})):(T==="failed"||T==="disconnected"||T==="closed")&&(de("disconnected"),V())};const ve=await K.createOffer();if(await K.setLocalDescription(ve),await gl(K),!N.current)return;const ye=`${e}/api/webrtc?src=${encodeURIComponent(t)}`,L=await fetch(ye,{method:"POST",headers:{"Content-Type":"application/sdp"},body:K.localDescription?.sdp??""});if(!L.ok)throw new Error(`WHEP ${L.status}: ${L.statusText}`);const M=await L.text();await K.setRemoteDescription({type:"answer",sdp:M})}catch(K){if(!N.current)return;const ue=K instanceof Error?K.message:String(K);Q(ue),de("error"),u?.(ue),V()}}},[e,t,D,de,u]),te=xe?$:_,U=(0,h.useRef)(()=>{});U.current=te;const V=(0,h.useCallback)(()=>{N.current&&(C.current>=dk||(C.current+=1,k.current=setTimeout(()=>{N.current&&U.current()},uk)))},[]);(0,h.useEffect)(()=>(N.current=!0,C.current=0,n&&te(),()=>{N.current=!1,D()}),[e,t]);const W=(0,h.useRef)(!1);(0,h.useEffect)(()=>{!n||!xe||!f||!m||W.current||w.current||(W.current=!0,te())},[n,xe,f,m,te]);const z=()=>{C.current=0,te()},X=()=>{x.current&&(x.current.muted=!x.current.muted,ne(x.current.muted))},q=async()=>{if(v.current)try{document.fullscreenElement?await document.exitFullscreen():await v.current.requestFullscreen()}catch(K){console.warn(`Fullscreen toggle failed: ${K instanceof Error?K.message:K}`)}},Re=()=>{if(!x.current)return;const K=document.createElement("canvas");K.width=x.current.videoWidth||1280,K.height=x.current.videoHeight||720;const ue=K.getContext("2d");if(!ue)return;ue.drawImage(x.current,0,0);const ve=document.createElement("a");ve.download=`${t.replace(/[/:]/g,"-")}-${Date.now()}.jpg`,ve.href=K.toDataURL("image/jpeg",.92),ve.click()};(0,h.useEffect)(()=>{const K=()=>ae(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",K),()=>document.removeEventListener("fullscreenchange",K)},[]);const De=()=>{se(!0),J.current&&clearTimeout(J.current),J.current=setTimeout(()=>se(!1),3e3)};return(0,r.jsxs)("div",{ref:v,className:`relative bg-black overflow-hidden group ${i}`,onMouseMove:De,onMouseEnter:De,children:[(0,r.jsx)("video",{ref:x,autoPlay:n,muted:ee,playsInline:!0,className:"w-full h-full object-contain"}),s&&E==="playing"&&(0,r.jsx)("div",{className:"absolute top-2 left-2 px-2 py-0.5 rounded bg-black/60 text-[10px] text-white font-medium",children:s}),d,E==="connecting"&&(0,r.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[(0,r.jsx)("svg",{className:"h-6 w-6 text-white/60 animate-spin",viewBox:"0 0 24 24",fill:"none",children:(0,r.jsx)("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]"})}),(0,r.jsx)("span",{className:"text-xs text-white/60",children:"Connecting…"})]}),(E==="error"||E==="disconnected")&&(0,r.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[(0,r.jsx)("svg",{className:"h-6 w-6 text-red-400",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("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"})}),(0,r.jsx)("span",{className:"text-xs text-red-400 text-center px-4",children:E==="error"?A||"Connection failed":"Disconnected"}),(0,r.jsx)("button",{onClick:z,className:"mt-1 inline-flex items-center gap-1.5 rounded px-3 py-1 text-xs bg-white/10 text-white hover:bg-white/20 transition-colors",children:"Reconnect"})]}),a&&E==="playing"&&(0,r.jsxs)("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 ${ce?"opacity-100":"opacity-0"}`,children:[(0,r.jsx)("div",{className:"flex items-center gap-1",children:(0,r.jsx)(pn,{onClick:X,title:ee?"Unmute":"Mute",children:ee?(0,r.jsxs)("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,r.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,r.jsx)("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),(0,r.jsx)("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]}):(0,r.jsxs)("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,r.jsx)("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),(0,r.jsx)("path",{d:"M19.07 4.93a10 10 0 010 14.14M15.54 8.46a5 5 0 010 7.07"})]})})}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(pn,{onClick:Re,title:"Take snapshot",children:(0,r.jsxs)("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,r.jsx)("path",{d:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z"}),(0,r.jsx)("circle",{cx:"12",cy:"13",r:"4"})]})}),(0,r.jsx)(pn,{onClick:q,title:pe?"Exit fullscreen":"Fullscreen",children:pe?(0,r.jsx)("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:(0,r.jsx)("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"})}):(0,r.jsx)("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:(0,r.jsx)("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 pn({onClick:e,title:t,children:s}){return(0,r.jsx)("button",{onClick:e,title:t,className:"rounded-full p-1.5 text-white/80 hover:text-white hover:bg-white/20 transition-colors",children:s})}async function gl(e){if(e.iceGatheringState!=="complete")return new Promise(t=>{const s=()=>{e.iceGatheringState==="complete"&&(e.removeEventListener("icegatheringstatechange",s),t())};e.addEventListener("icegatheringstatechange",s),setTimeout(t,5e3)})}var hn=at("camstack:player-overlays-state",null),gn=at("camstack:player-overlays-actions",null);function fk({children:e}){const[t,s]=(0,h.useState)(()=>new Map),[n,o]=(0,h.useState)(()=>new Map),a=(0,h.useCallback)(m=>{s(g=>{const b=new Map(g);return b.set(m.id,m),b})},[]),i=(0,h.useCallback)(m=>{s(g=>{if(!g.has(m))return g;const b=new Map(g);return b.delete(m),b})},[]),l=(0,h.useCallback)(m=>{o(g=>{const b=new Map(g);return b.set(m.id,m),b})},[]),u=(0,h.useCallback)(m=>{o(g=>{if(!g.has(m))return g;const b=new Map(g);return b.delete(m),b})},[]),d=(0,h.useMemo)(()=>({layers:t,buttons:n}),[t,n]),f=(0,h.useMemo)(()=>({setLayer:a,removeLayer:i,setButton:l,removeButton:u}),[a,i,l,u]);return(0,r.jsx)(hn.Provider,{value:d,children:(0,r.jsx)(gn.Provider,{value:f,children:e})})}function mk(){const e=(0,h.useContext)(hn);return(0,h.useMemo)(()=>e?[...e.layers.values()].sort((t,s)=>t.order-s.order):[],[e])}function bl(){const e=(0,h.useContext)(hn);return(0,h.useMemo)(()=>e?[...e.buttons.values()].sort((t,s)=>t.order-s.order):[],[e])}function pk(e){const t=(0,h.useContext)(gn);(0,h.useEffect)(()=>{if(!(!t||!e))return t.setLayer(e),()=>t.removeLayer(e.id)},[t,e])}function hk(e){const t=(0,h.useContext)(gn);(0,h.useEffect)(()=>{if(!(!t||!e))return t.setButton(e),()=>t.removeButton(e.id)},[t,e])}function gk(e){return e==="streaming"?"bg-emerald-500":e==="connecting"?"bg-amber-500":e==="error"?"bg-rose-500":"bg-zinc-500"}function bk(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 bn({className:e}){return(0,r.jsx)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polygon",{points:"5 3 19 12 5 21 5 3"})})}function xk({className:e}){return(0,r.jsx)("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})})}function vk({className:e}){return(0,r.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"}),(0,r.jsx)("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),(0,r.jsx)("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),(0,r.jsx)("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}function yk({className:e}){return(0,r.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[(0,r.jsx)("circle",{cx:"5",cy:"12",r:"2"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,r.jsx)("circle",{cx:"19",cy:"12",r:"2"})]})}function xn({label:e,active:t,onClick:s}){return(0,r.jsxs)("button",{type:"button",onClick:s,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:[(0,r.jsx)("span",{children:e}),(0,r.jsx)("span",{className:`inline-block h-3 w-5 rounded-full transition-colors ${t?"bg-primary":"bg-foreground-subtle/30"} relative`,children:(0,r.jsx)("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-white transition-all ${t?"left-2.5":"left-0.5"}`})})]})}function xl({className:e}){return(0,r.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"23 4 23 10 17 10"}),(0,r.jsx)("polyline",{points:"1 20 1 14 7 14"}),(0,r.jsx)("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]})}function wk({className:e}){return(0,r.jsxs)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),(0,r.jsx)("path",{d:"M10.41 10.41a2 2 0 11-2.83-2.83"}),(0,r.jsx)("line",{x1:"13.5",y1:"13.5",x2:"6",y2:"21"}),(0,r.jsx)("path",{d:"M18 12l-1.5-1.5"}),(0,r.jsx)("path",{d:"M21 15V5a2 2 0 00-2-2H5"}),(0,r.jsx)("path",{d:"M21 21H5a2 2 0 01-2-2V11"})]})}function Sk({serverUrl:e,createSession:t,sendAnswer:s,closeSession:n,streams:o,activeStreamId:a,onStreamChange:i,deviceName:l,phase:u,pipelineMetrics:d,detections:f,defaultShowDetections:m=!0,defaultShowMotion:g=!1,streamStats:b,autoPlay:x=!1,showPlayStop:v=!1,snapshotSrc:w,snapshotLoading:y=!1,onRefreshSnapshot:S,showStreamStats:k=!1,children:C,extraOverlay:N,ptzAvailable:E=!1,ptzShown:R=!1,ptzOverlay:A,onPtzToggle:Q,intercomAvailable:ee=!1,intercomShown:ne=!1,onIntercomToggle:pe,chromeless:ae=!1,className:ce}){const se=bl(),[J,H]=(0,h.useState)(x),[xe,de]=(0,h.useState)(m),[D,$]=(0,h.useState)(g),[_,te]=(0,h.useState)(null),[U,V]=(0,h.useState)(!1),W=(0,h.useRef)(null);(0,h.useEffect)(()=>{if(!U)return;function I(Y){W.current&&!W.current.contains(Y.target)&&V(!1)}return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[U]);const z=a??_??o?.[0]?.id??"",X=o?.find(I=>I.id===z)??o?.[0],q=X?.inputFps!=null?{status:X.status??"unknown",inputFps:X.inputFps,bitrateKbps:X.bitrateKbps??0}:null,Re=I=>{te(I),i?.(I),J&&v&&(H(!1),setTimeout(()=>H(!0),50))},De=(0,h.useMemo)(()=>{const I=X?.target;if(I)return Y=>t(I,Y)},[t,X]),K=o,ue=()=>H(!0),ve=()=>H(!1),ye=d?.phase??u,L=ye==="active",M=!!f,T=M&&(xe||D),Z=E&&R&&!!A,re=v?J:!0;return(0,r.jsxs)("div",{className:`overflow-hidden ${ae?"":"rounded-xl border border-border bg-surface"} ${ce??""}`,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(b??q)&&(0,r.jsx)("span",{className:`w-2 h-2 rounded-full ${gk((b??q).status)}`}),l&&(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:l}),K&&K.length>1&&(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("select",{"data-testid":"stream-profile-select",value:z,onChange:I=>Re(I.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:K.map(I=>(0,r.jsx)("option",{value:I.id,children:I.label},I.id))}),(0,r.jsx)("span",{className:"pointer-events-none absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle",children:(0,r.jsx)("svg",{className:"h-2.5 w-2.5",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"3 4.5 6 7.5 9 4.5"})})})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[ee&&(0,r.jsxs)("button",{"data-testid":"stream-intercom-toggle","data-intercom-shown":ne?"true":"false",onClick:pe,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${ne?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:ne?"Close intercom":"Open intercom",children:[(0,r.jsx)(vk,{className:"h-3 w-3"}),(0,r.jsx)("span",{className:"hidden xl:inline",children:"Intercom"})]}),se.map(I=>{const Y=I.tone==="primary"?"bg-primary text-primary-foreground":"bg-primary/15 text-primary";return(0,r.jsxs)("button",{type:"button","data-toolbar-button-id":I.id,"data-toolbar-button-active":I.active?"true":"false",onClick:I.onClick,disabled:I.disabled,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors disabled:opacity-50 ${I.active?Y:"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:I.title??I.label,children:[I.icon,(0,r.jsx)("span",{className:"hidden xl:inline",children:I.label})]},I.id)}),v&&(0,r.jsxs)("button",{"data-testid":"stream-play-toggle","data-stream-playing":re?"true":"false",onClick:re?ve:ue,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${re?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary/10 text-primary hover:bg-primary/20"}`,title:re?"Stop stream":"Start stream",children:[re?(0,r.jsx)(xk,{className:"h-3 w-3"}):(0,r.jsx)(bn,{className:"h-3 w-3"}),(0,r.jsx)("span",{className:"hidden xl:inline",children:re?"Stop":"Play"})]}),S&&(0,r.jsxs)("button",{"data-testid":"stream-snapshot-refresh",onClick:S,disabled:y,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",title:"Force snapshot refresh",children:[(0,r.jsx)(xl,{className:`h-3 w-3 ${y?"animate-spin":""}`}),(0,r.jsx)("span",{className:"hidden xl:inline",children:"Snapshot"})]}),(M||E||d||ye||b||q&&q.inputFps>0)&&(0,r.jsxs)("div",{ref:W,className:"relative",children:[(0,r.jsx)("button",{onClick:()=>V(I=>!I),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:(0,r.jsx)(yk,{className:"h-3.5 w-3.5"})}),U&&(0,r.jsxs)("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:[k&&b&&(0,r.jsxs)("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[(0,r.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,r.jsx)("span",{children:"Input"}),(0,r.jsxs)("span",{className:"tabular-nums text-foreground",children:[b.inputFps.toFixed(1)," fps"]})]}),(0,r.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,r.jsx)("span",{children:"Decode"}),(0,r.jsxs)("span",{className:"tabular-nums text-foreground",children:[b.decodeFps.toFixed(1)," fps"]})]}),(0,r.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,r.jsx)("span",{children:"Uptime"}),(0,r.jsx)("span",{className:"tabular-nums text-foreground",children:bk(b.uptimeMs)})]})]}),!k&&q&&q.inputFps>0&&(0,r.jsxs)("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[(0,r.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,r.jsx)("span",{children:"Input"}),(0,r.jsxs)("span",{className:"tabular-nums text-foreground",children:[q.inputFps.toFixed(1)," fps"]})]}),q.bitrateKbps>0&&(0,r.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,r.jsx)("span",{children:"Bitrate"}),(0,r.jsxs)("span",{className:"tabular-nums text-foreground",children:[q.bitrateKbps," kbps"]})]})]}),(d||M&&ye)&&(0,r.jsxs)("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[(0,r.jsxs)("div",{className:"flex justify-between gap-3 items-center",children:[(0,r.jsx)("span",{children:"Phase"}),(0,r.jsxs)("span",{className:`flex items-center gap-1 font-semibold uppercase tracking-wider ${L?"text-red-400":"text-emerald-400"}`,children:[(0,r.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${L?"bg-red-500 animate-pulse":"bg-emerald-500"}`}),L?"Active":"Watching"]})]}),d&&d.detectionFps>0&&(0,r.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,r.jsx)("span",{children:"Detection"}),(0,r.jsxs)("span",{className:"tabular-nums text-foreground",children:[d.detectionFps.toFixed(1)," det/s"]})]}),d&&d.avgInferenceMs>0&&(0,r.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,r.jsx)("span",{children:"Inference"}),(0,r.jsxs)("span",{className:"tabular-nums text-foreground",children:[d.avgInferenceMs.toFixed(0)," ms"]})]})]}),M&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(xn,{label:"Show detections",active:xe,onClick:()=>de(I=>!I)}),(0,r.jsx)(xn,{label:"Show motion",active:D,onClick:()=>$(I=>!I)})]}),E&&(0,r.jsx)(xn,{label:"PTZ controls",active:R,onClick:()=>{Q?.(),V(!1)}})]})]})]})]}),re?(0,r.jsx)("div",{className:"aspect-video relative",children:(0,r.jsx)(hl,{serverUrl:e,streamKey:z,autoPlay:!0,className:"w-full h-full",createSession:De,sendAnswer:s,closeSession:n,overlay:T||N||Z?(0,r.jsxs)(r.Fragment,{children:[T&&(0,r.jsx)(pl,{detections:f,showPhaseIndicator:!1,showMotionZones:D,showMotionRaw:D,showDetections:xe}),N,Z&&A]}):void 0},z)}):(0,r.jsx)(kk,{src:w??null,isLoading:y,onPlay:ue,onRetry:S,extraOverlay:N||Z?(0,r.jsxs)(r.Fragment,{children:[N,Z&&A]}):null,suppressPlayHover:!!N||Z}),C]})}function kk({src:e,isLoading:t,onPlay:s,onRetry:n,extraOverlay:o,suppressPlayHover:a=!1}){return e?(0,r.jsxs)("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:[(0,r.jsx)("img",{src:e,alt:"Camera snapshot",className:"w-full h-full object-contain"}),!a&&(0,r.jsx)("button",{onClick:s,className:"absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 hover:opacity-100 transition-opacity cursor-pointer",children:(0,r.jsx)("div",{className:"h-14 w-14 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center",children:(0,r.jsx)(bn,{className:"h-7 w-7 text-white ml-0.5"})})}),o]}):t?(0,r.jsx)("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:(0,r.jsx)("div",{className:"h-8 w-8 border-2 border-white/20 border-t-white/60 rounded-full animate-spin"})}):(0,r.jsx)("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-2 text-white/40",children:[(0,r.jsx)(wk,{className:"h-8 w-8"}),(0,r.jsx)("span",{className:"text-xs",children:"No snapshot available"}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[n&&(0,r.jsxs)("button",{onClick:n,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:[(0,r.jsx)(xl,{className:"h-3 w-3"}),"Retry"]}),(0,r.jsxs)("button",{onClick:s,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:[(0,r.jsx)(bn,{className:"h-3 w-3"}),"Play Live"]})]})]})})}function jk({samples:e,sampleRate:t=16e3,height:s=96,className:n="",color:o="#3b82f6",bgColor:a="transparent"}){const i=(0,h.useRef)(null),l=(0,h.useRef)(null),u=(0,h.useCallback)(()=>{const f=i.current,m=l.current;if(!f||!m||!e||e.length===0)return;const g=m.clientWidth;if(g===0)return;const b=window.devicePixelRatio||1;f.width=g*b,f.height=s*b,f.style.width=`${g}px`,f.style.height=`${s}px`;const x=f.getContext("2d");if(!x)return;x.scale(b,b),a!=="transparent"?(x.fillStyle=a,x.fillRect(0,0,g,s)):x.clearRect(0,0,g,s);const v=e.length/g,w=s/2;x.fillStyle=o,x.globalAlpha=.7;for(let y=0;y<g;y++){const S=Math.floor(y*v),k=Math.min(Math.floor((y+1)*v),e.length);let C=0,N=0;for(let Q=S;Q<k;Q++){const ee=e[Q];ee<C&&(C=ee),ee>N&&(N=ee)}const E=w-N*w,R=w-C*w,A=Math.max(1,R-E);x.fillRect(y,E,1,A)}x.globalAlpha=1,x.strokeStyle=o,x.globalAlpha=.2,x.lineWidth=1,x.beginPath(),x.moveTo(0,w),x.lineTo(g,w),x.stroke(),x.globalAlpha=1},[e,s,o,a]);(0,h.useEffect)(()=>{u()},[u]),(0,h.useEffect)(()=>{const f=new ResizeObserver(()=>u()),m=l.current;return m&&f.observe(m),()=>f.disconnect()},[u]);const d=((e&&t?Math.round(e.length/t*1e3):0)/1e3).toFixed(1);return(0,r.jsxs)("div",{ref:l,className:`relative ${n}`,children:[(0,r.jsx)("canvas",{ref:i,className:"w-full rounded-md"}),e&&e.length>0&&(0,r.jsxs)("div",{className:"absolute bottom-1 right-2 text-[10px] text-foreground-subtle/60 font-mono",children:[d,"s · ",t/1e3,"kHz · ",e.length.toLocaleString()," samples"]})]})}function Nk({currentDbfs:e,durationSec:t=30,maxSamples:s=120,height:n=64,className:o="",color:a="#10b981",clipColor:i="#ef4444",clipThreshold:l=-6,minDbfs:u=-96}){const d=(0,h.useRef)(null),f=(0,h.useRef)(null),[m,g]=(0,h.useState)([]);(0,h.useEffect)(()=>{e!==null&&g(v=>{const w=[...v,{dbfs:e,timestamp:Date.now()}];return w.length>s?w.slice(-s):w})},[e,s]);const b=(0,h.useCallback)(()=>{const v=d.current,w=f.current;if(!v||!w)return;const y=w.clientWidth;if(y===0)return;const S=window.devicePixelRatio||1;v.width=y*S,v.height=n*S,v.style.width=`${y}px`,v.style.height=`${n}px`;const k=v.getContext("2d");if(!k||(k.scale(S,S),k.clearRect(0,0,y,n),m.length===0))return;const C=m[m.length-1].timestamp,N=t*1e3,E=C-N,R=m.filter(ne=>ne.timestamp>=E);if(R.length===0)return;const A=Math.max(1,Math.floor(y/(t*2))),Q=Math.abs(u);for(const ne of R){const pe=ne.timestamp-E,ae=Math.floor(pe/N*y),ce=(Math.max(u,Math.min(0,ne.dbfs))-u)/Q,se=Math.max(1,ce*n);k.fillStyle=ne.dbfs>=l?i:a,k.globalAlpha=.8,k.fillRect(ae,n-se,A,se)}k.globalAlpha=1;const ee=n-(l-u)/Q*n;k.strokeStyle=i,k.globalAlpha=.25,k.lineWidth=1,k.setLineDash([4,4]),k.beginPath(),k.moveTo(0,ee),k.lineTo(y,ee),k.stroke(),k.setLineDash([]),k.globalAlpha=1},[m,t,n,a,i,l,u]);(0,h.useEffect)(()=>{b()},[b]),(0,h.useEffect)(()=>{const v=new ResizeObserver(()=>b()),w=f.current;return w&&v.observe(w),()=>v.disconnect()},[b]);const x=m.length>0?m[m.length-1].dbfs:null;return(0,r.jsxs)("div",{ref:f,className:`relative ${o}`,children:[(0,r.jsx)("canvas",{ref:d,className:"w-full rounded-md"}),(0,r.jsxs)("div",{className:"absolute top-1 left-2 text-[9px] text-foreground-subtle/50 font-mono",children:[t,"s"]}),x!==null&&(0,r.jsxs)("div",{className:"absolute bottom-1 right-2 text-[9px] text-foreground-subtle/50 font-mono",children:[x.toFixed(1)," dBFS · ",m.length," samples"]})]})}function Ck(e){return e>=.8?"bg-emerald-500":e>=.5?"bg-amber-500":e>=.3?"bg-orange-500":"bg-zinc-500"}function Mk(e){return e>=.8?"text-emerald-400":e>=.5?"text-amber-400":e>=.3?"text-orange-400":"text-zinc-400"}function Ek({classifications:e,processing:t=!1,inferenceMs:s,maxItems:n=10,className:o=""}){const a=e.slice(0,n),i=a.length>0?a[0].score:1;return t?(0,r.jsx)("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${o}`,children:(0,r.jsx)("div",{className:"text-sm text-foreground-subtle animate-pulse",children:"Classifying audio..."})}):a.length===0?(0,r.jsx)("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${o}`,children:(0,r.jsx)("div",{className:"text-xs text-foreground-subtle",children:"No classifications yet"})}):(0,r.jsxs)("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${o}`,children:[(0,r.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between",children:[(0,r.jsx)("h3",{className:"text-xs font-medium text-foreground",children:"Audio Classifications"}),(0,r.jsxs)("div",{className:"flex items-center gap-3 text-[10px] text-foreground-subtle",children:[a.length<e.length&&(0,r.jsxs)("span",{children:["showing ",a.length," of ",e.length]}),s!==void 0&&(0,r.jsxs)("span",{className:"font-mono",children:[s.toFixed(1),"ms"]})]})]}),(0,r.jsx)("div",{className:"divide-y divide-border/50",children:a.map((l,u)=>{const d=i>0?l.score/i*100:0;return(0,r.jsxs)("div",{className:"px-3 py-1.5 flex items-center gap-3 hover:bg-surface-hover/30",children:[(0,r.jsx)("span",{className:"text-[10px] text-foreground-subtle w-5 text-right font-mono",children:u+1}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground min-w-[120px]",children:l.className}),(0,r.jsx)("div",{className:"flex-1 h-2 rounded-full bg-zinc-800 overflow-hidden",children:(0,r.jsx)("div",{className:`h-full rounded-full transition-all duration-300 ${Ck(l.score)}`,style:{width:`${d}%`}})}),(0,r.jsxs)("span",{className:`text-xs font-mono font-semibold w-14 text-right ${Mk(l.score)}`,children:[(l.score*100).toFixed(1),"%"]})]},`${l.className}-${u}`)})})]})}function Ak({data:e,label:t="Response",className:s=""}){const[n,o]=(0,h.useState)(!1);if(!e)return null;const a=JSON.stringify(e,null,2);return(0,r.jsxs)("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${s}`,children:[(0,r.jsxs)("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:()=>o(i=>!i),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-[10px] text-foreground-subtle",children:n?"▼":"▶"}),(0,r.jsx)("h3",{className:"text-xs font-medium text-foreground",children:t})]}),(0,r.jsx)("span",{className:"text-[10px] text-foreground-subtle font-mono",children:a.length>1e3?`${(a.length/1024).toFixed(1)} KB`:`${a.length} bytes`})]}),n&&(0,r.jsx)("div",{className:"max-h-80 overflow-y-auto overflow-x-auto",children:(0,r.jsx)("pre",{className:"p-3 text-[10px] leading-4 font-mono text-foreground-subtle whitespace-pre",children:a})})]})}var Pk={Activity:ft,Eye:nr,AlertTriangle:ir,PauseCircle:Vd,PowerOff:cf};function Rk({phase:e,...t}){const s=Pk[us(e).icon];return(0,r.jsx)(s,{...t})}function Ct(e){const[t,s]=(0,h.useState)([]),n=(0,h.useCallback)(a=>{s(i=>{const l=[...i,a];return l.length>e?l.slice(-e):l})},[e]),o=(0,h.useCallback)(()=>{s([])},[]);return(0,h.useMemo)(()=>({entries:t,append:n,reset:o}),[t,n,o])}function vl(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)}}var yl={error:{icon:_r,color:"text-red-400"},warn:{icon:ir,color:"text-amber-400"},info:{icon:tf,color:"text-blue-400"},debug:{icon:Bd,color:"text-gray-500"}},wl={debug:0,info:1,warn:2,error:3},Dk=["all","debug","info","warn","error"],Tk=500;function Ik(e,t){return t?(wl[e]??0)>=(wl[t]??0):!0}function vn({agentId:e,addonId:t,deviceId:s,integrationId:n,requestId:o,level:a,maxHeight:i="max-h-96",showScope:l=!1,showFilters:u=!0,limit:d=100,liveBuffer:f,onClose:m,className:g}){const[b,x]=(0,h.useState)(""),[v,w]=(0,h.useState)(""),[y,S]=(0,h.useState)(a),k=e,C=t??(b||void 0),N=s??(v?Number(v):void 0),E=n,R=o,A=(0,h.useMemo)(()=>{const M={};return k&&(M.agentId=k),C&&(M.addonId=C),N!==void 0&&Number.isFinite(N)&&(M.deviceId=N),E&&(M.integrationId=E),R&&(M.requestId=R),Object.keys(M).length>0?M:void 0},[k,C,N,E,R]),Q=Ct(Tk),ee=f??Q,ne=ee.entries,[pe,ae]=(0,h.useState)(0),[ce,se]=(0,h.useState)(!1),[J,H]=(0,h.useState)(!1),[xe,de]=(0,h.useState)(new Set),[D,$]=(0,h.useState)(""),_=(0,h.useRef)(null),te=`${k??""}:${C??""}:${String(N??"")}:${E??""}:${R??""}`,U=(0,h.useRef)(te);(0,h.useEffect)(()=>{U.current!==te&&(U.current=te,ee.reset(),ae(0),de(new Set))},[te,ee]);const{data:V,isLoading:W}=p.logs.query.useQuery({...A?{tags:A}:{},limit:d},{staleTime:3e4});p.logs.subscribe.useSubscription({...A?{tags:A}:{}},{onData:M=>{ee.append(M)}});const z=(0,h.useRef)(ne.length);(0,h.useEffect)(()=>{const M=_.current;if(!M){z.current=ne.length;return}const T=z.current;if(z.current=ne.length,!(ne.length<=T)){if(ce&&M.scrollTop<=8)M.scrollTo({top:0});else if(!ce&&M.scrollTop>0){const Z=M.querySelector("tbody tr"),re=Z instanceof HTMLElement?Z.offsetHeight:24;M.scrollTop+=re*(ne.length-T)}}},[ne.length,ce]);const X=(0,h.useMemo)(()=>{const M=(V??[]).map(Y=>({timestamp:Y.timestamp,level:Y.level,message:Y.message,scope:Y.scope,tags:Y.tags,meta:Y.meta})),T=new Set,Z=[];for(const Y of[...ne].reverse()){const Se=`${Y.timestamp}|${Y.level}|${Y.scope??""}|${Y.message}`;T.has(Se)||(T.add(Se),Z.push(Y))}for(const Y of M){const Se=`${Y.timestamp}|${Y.level}|${Y.scope??""}|${Y.message}`;T.has(Se)||(T.add(Se),Z.push(Y))}const re=(pe>0?Z.filter(Y=>new Date(Y.timestamp).getTime()>pe):Z).filter(Y=>Ik(Y.level,y)),I=D.trim().toLowerCase();return I?re.filter(Y=>{if(Y.message.toLowerCase().includes(I)||Y.scope&&Y.scope.toLowerCase().includes(I))return!0;if(Y.tags){for(const Se of Object.values(Y.tags))if(Se!==void 0&&String(Se).toLowerCase().includes(I))return!0}if(Y.meta){for(const Se of Object.values(Y.meta))if(Se!=null&&vl(Se).toLowerCase().includes(I))return!0}return!1}):re},[V,ne,y,pe,D]),q=(0,h.useCallback)(()=>{const M=X.map(T=>{const Z=new Date(T.timestamp).toLocaleTimeString(),re=T.tags?" "+Object.entries(T.tags).filter(([,I])=>I).map(([I,Y])=>`${I}=${Y}`).join(" "):"";return`${Z} [${T.level.toUpperCase()}]${T.scope?` [${T.scope}]`:""}${re} ${T.message}`});navigator.clipboard.writeText(M.join(`
78
+ `)).then(()=>{H(!0),setTimeout(()=>H(!1),1500)})},[X]),Re=p.logs.clear.useMutation(),De=(0,h.useCallback)(()=>{ae(Date.now()),ee.reset(),Re.mutate({...A?{tags:A}:{}})},[ee,Re,A]),K=(0,h.useCallback)(M=>{de(T=>{const Z=new Set(T);return Z.has(M)?Z.delete(M):Z.add(M),Z})},[]),[ue,ve]=(0,h.useState)(null),ye=(0,h.useCallback)((M,T)=>{const Z=new Date(M.timestamp).toISOString(),re=M.tags?" "+Object.entries(M.tags).filter(([,Se])=>Se).map(([Se,it])=>`${Se}=${it}`).join(" "):"",I=M.meta&&Object.keys(M.meta).length>0?` meta=${JSON.stringify(M.meta)}`:"",Y=`${Z} [${M.level.toUpperCase()}]${M.scope?` [${M.scope}]`:""}${re} ${M.message}${I}`;navigator.clipboard.writeText(Y).then(()=>{ve(T),setTimeout(()=>ve(Se=>Se===T?null:Se),1200)})},[]),L=(0,h.useCallback)(M=>`${M.timestamp}|${M.level}|${M.scope??""}|${M.message}`,[]);return(0,r.jsxs)("div",{className:j("h-full min-h-0 flex flex-col",g),onClick:M=>M.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Logs"}),k&&(0,r.jsx)(yn,{label:"agent",value:k}),C&&(0,r.jsx)(yn,{label:"addon",value:C}),N!==void 0&&(0,r.jsx)(yn,{label:"device",value:`#${N}`}),(0,r.jsx)("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:Dk.map(M=>(0,r.jsxs)("button",{type:"button",onClick:()=>S(M==="all"?void 0:M),className:j("px-1.5 py-0.5 capitalize transition-colors",M==="all"&&!y||y===M?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover",M!=="all"&&"border-l border-border"),children:[M,M!=="all"?"+":""]},M))}),(0,r.jsx)(wn,{icon:As,label:ce?"Auto":"Paused",active:!ce,onClick:()=>{se(M=>!M),!ce&&_.current&&_.current.scrollTo({top:0,behavior:"smooth"})}}),(0,r.jsx)(wn,{icon:pt,label:J?"Copied!":"Copy",onClick:q,disabled:X.length===0}),(0,r.jsx)(wn,{icon:et,label:"Clear",onClick:De}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{type:"text",value:D,onChange:M=>$(M.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"}),D&&(0,r.jsx)("button",{type:"button",onClick:()=>$(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:(0,r.jsx)(Ee,{className:"h-2.5 w-2.5"})})]}),ne.length>0&&(0,r.jsxs)("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",ne.length," live"]})]}),m&&(0,r.jsx)("button",{type:"button",onClick:m,className:"text-foreground-subtle hover:text-foreground",children:(0,r.jsx)(Ee,{className:"h-3.5 w-3.5"})})]}),u&&(!t||!s)&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1 border-b border-border/50 bg-surface/50 text-[10px]",children:[!t&&(0,r.jsxs)("label",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"text-foreground-subtle",children:"Addon:"}),(0,r.jsx)("input",{type:"text",value:b,onChange:M=>x(M.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"})]}),!s&&(0,r.jsxs)("label",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"text-foreground-subtle",children:"Device:"}),(0,r.jsx)("input",{type:"text",inputMode:"numeric",value:v,onChange:M=>w(M.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"})]})]}),(0,r.jsxs)("div",{ref:_,className:j("flex-1 min-h-0 overflow-auto font-mono text-[10px]",i),children:[W&&(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[(0,r.jsx)(qe,{className:"h-3.5 w-3.5 animate-spin"}),"Loading logs..."]}),!W&&X.length===0&&(0,r.jsx)("div",{className:"py-4 text-center text-foreground-subtle",children:"No logs found"}),X.length>0&&(0,r.jsx)("table",{className:"w-full",children:(0,r.jsx)("tbody",{children:X.map(M=>{const T=yl[M.level]??yl.info,Z=T.icon,re=L(M),I=xe.has(re),Y=M.tags&&Object.keys(M.tags).length>0,Se=M.meta&&Object.keys(M.meta).length>0,it=Y||Se;return(0,r.jsxs)("tr",{className:j("hover:bg-surface-hover/30 border-b border-border/30",it&&"cursor-pointer"),onClick:it?()=>K(re):void 0,children:[(0,r.jsx)("td",{className:"px-2 py-1 text-foreground-subtle whitespace-nowrap align-top w-[70px]",children:new Date(M.timestamp).toLocaleTimeString()}),(0,r.jsx)("td",{className:j("px-1 py-1 align-top w-5",T.color),children:(0,r.jsx)(Z,{className:"h-3 w-3"})}),l&&(0,r.jsx)("td",{className:"px-2 py-1 text-foreground-subtle align-top truncate max-w-[120px]",title:M.scope,children:M.scope?.replace(/^addon:/,"")??""}),(0,r.jsx)("td",{className:"px-2 py-1 text-foreground break-all",children:(0,r.jsxs)("div",{className:"flex items-start gap-1",children:[it&&(I?(0,r.jsx)(St,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"}):(0,r.jsx)(mt,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"})),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[M.message,I&&it&&(0,r.jsxs)("div",{className:"mt-1 text-[9px] text-foreground-subtle bg-surface rounded px-2 py-1 space-y-0.5",children:[Se&&Object.entries(M.meta).filter(([,$e])=>$e!==void 0&&$e!=="").map(([$e,Ht])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-amber-400/80 font-medium",children:$e}),(0,r.jsx)("span",{className:"text-foreground-subtle",children:": "}),(0,r.jsx)("span",{className:"text-foreground break-all",children:vl(Ht)})]},`m-${$e}`)),Y&&Object.entries(M.tags).filter(([,$e])=>$e!==void 0).map(([$e,Ht])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-primary/70 font-medium",children:$e}),(0,r.jsx)("span",{className:"text-foreground-subtle",children:": "}),(0,r.jsx)("span",{className:"text-foreground",children:Ht})]},`t-${$e}`))]})]})]})}),(0,r.jsx)("td",{className:"px-1 py-1 align-top w-5",children:(0,r.jsx)(Ok,{copied:ue===re,onCopy:()=>ye(M,re)})})]},re)})})})]})]})}function Lk({position:e="bottom",className:t,...s}){return(0,r.jsx)("div",{className:j(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:(0,r.jsx)(vn,{maxHeight:"max-h-48",...s})})}function yn({label:e,value:t}){return(0,r.jsxs)("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function Ok({copied:e,onCopy:t}){return(0,r.jsx)("button",{type:"button",title:"Copy this row",onClick:s=>{s.stopPropagation(),t()},className:j("rounded p-0.5 transition-colors",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?(0,r.jsx)(sr,{className:"h-3 w-3"}):(0,r.jsx)(pt,{className:"h-3 w-3"})})}function wn({icon:e,label:t,onClick:s,disabled:n,active:o}){return(0,r.jsxs)("button",{type:"button",onClick:s,disabled:n,className:j("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",o?"border-amber-500/30 bg-amber-500/10 text-amber-400":"border-border text-foreground-subtle hover:text-foreground",n&&"opacity-40 cursor-not-allowed"),children:[(0,r.jsx)(e,{className:"h-2.5 w-2.5"}),t]})}function _k(e,t,s,n){if(n!==void 0&&(e.source.deviceId??(e.source.type==="device"&&typeof e.source.id=="number"?e.source.id:void 0))!==n||s!==void 0&&(e.source.addonId??(e.source.type==="addon"&&typeof e.source.id=="string"?e.source.id:void 0))!==s)return!1;if(t!==void 0){const o=e.source.nodeId;if(!o||o!==t&&!o.startsWith(`${t}/`))return!1}return!0}var $k={[F.EventCategory.AddonStarted]:{icon:Is,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Started"},[F.EventCategory.AddonInstalled]:{icon:Rs,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Installed"},[F.EventCategory.AddonRestarted]:{icon:Ls,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Restarted"},[F.EventCategory.AddonUpdated]:{icon:da,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Updated"},[F.EventCategory.AddonStopped]:{icon:la,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Stopped"},[F.EventCategory.AddonUninstalled]:{icon:et,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Uninstalled"},[F.EventCategory.AddonCrashed]:{icon:_r,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Crashed"},[F.EventCategory.AddonError]:{icon:ir,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Error"},[F.EventCategory.DetectionPhaseTransition]:{icon:ft,color:"bg-violet-500/15 text-violet-400 border-violet-500/30",label:"Phase"},[F.EventCategory.DetectionResult]:{icon:ff,color:"bg-purple-500/15 text-purple-400 border-purple-500/30",label:"Detection"},[F.EventCategory.DetectionEvent]:{icon:nr,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Event"},[F.EventCategory.DetectionCameraNative]:{icon:ua,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Camera AI"},[F.EventCategory.ProviderMotion]:{icon:ma,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[F.EventCategory.MotionOnMotionChanged]:{icon:ma,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[F.EventCategory.MotionAnalysis]:{icon:ft,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion analysis"},[F.EventCategory.MotionZonesRaw]:{icon:ft,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion zones"},[F.EventCategory.ProviderDetection]:{icon:ua,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Provider Det"},[F.EventCategory.PipelineAudioInferenceResult]:{icon:ra,color:"bg-pink-500/15 text-pink-400 border-pink-500/30",label:"Audio"},[F.EventCategory.AgentOnline]:{icon:Is,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Agent Online"},[F.EventCategory.AgentOffline]:{icon:la,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Agent Offline"},[F.EventCategory.DeviceRegistered]:{icon:Rs,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Registered"},[F.EventCategory.DeviceUnregistered]:{icon:et,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Unregistered"},[F.EventCategory.DeviceStateChanged]:{icon:ft,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"State"}};function Sn(e,t){const s=$k[e]??{icon:Is,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:e.split(".").pop()??e};if(e===F.EventCategory.DeviceStateChanged&&t&&typeof t.capName=="string"){const n=t.capName;return{...s,label:n}}return s}var Ut=Object.freeze([...new Set(Object.values(F.EventCategory))].sort()),Gk=Object.freeze([F.EventCategory.PipelineCameraMetricsSnapshot,F.EventCategory.PipelineRunnerLoadSnapshot,F.EventCategory.PipelineEngineMetricsSnapshot,F.EventCategory.PipelineInferenceResult,F.EventCategory.PipelineTrace,F.EventCategory.PipelineProgress,F.EventCategory.StreamBrokerMetricsSnapshot,F.EventCategory.MetricsNodeResourcesSnapshot,F.EventCategory.MetricsNodeProcessesSnapshot,F.EventCategory.ClusterTopologySnapshot,F.EventCategory.MotionAnalysis,F.EventCategory.MotionZonesRaw,F.EventCategory.DetectionResult,F.EventCategory.PipelineAudioInferenceResult,F.EventCategory.PlatformProbePhase,F.EventCategory.BenchmarkProgress,F.EventCategory.ModelDownloadProgress]),Bk=new Set(Gk),Fk=Object.freeze(Ut.filter(e=>!Bk.has(e)));function Jr(e,t){if(e===F.EventCategory.DetectionPhaseTransition){const o=t.to,a=t.from,i=typeof t.source=="string"?t.source:null,l=typeof t.cooldownMs=="number"?t.cooldownMs:null,u=i?` (${i}${l?`, ${Math.round(l/1e3)}s cooldown`:""})`:"";return o==="active"?`Motion detected — phase active${u}`:o==="watching"?`Cooldown expired — phase watching${u}`:`Phase: ${String(a)} → ${String(o)}${u}`}if(e===F.EventCategory.DetectionResult){const o=t.frame?.detections??[];if(o.length===0)return null;const a=new Map;for(const i of o){const l=i,u=l.class??l.macroClass,d=typeof u=="string"?u:"";d&&a.set(d,(a.get(d)??0)+1)}return[...a.entries()].map(([i,l])=>l>1?`${i} ×${l}`:i).join(", ")}if(e===F.EventCategory.PipelineAudioInferenceResult){const o=t.frame?.detections??[];return o.length===0?null:o.map(a=>{const i=a,l=i.macroClass??i.class??i.label,u=typeof l=="string"?l:"",d=i.score;return d?`${u} (${Math.round(d*100)}%)`:u}).filter(Boolean).join(", ")}if(e===F.EventCategory.DetectionEvent){const o=t.label??t.class,a=t.score??t.confidence,i=[];return typeof o=="string"&&i.push(o),typeof a=="number"&&i.push(`${Math.round(a*100)}%`),i.length>0?i.join(" — "):null}if(e===F.EventCategory.ProviderMotion)return t.active===!0?"motion start":"motion stop";if(e===F.EventCategory.DeviceStateChanged){const o=t.slice;if(o&&typeof o=="object"){const a=Object.keys(o).filter(i=>i!=="lastFetchedAt"&&i!=="ts");if(a.length>0)return a.slice(0,4).join(", ")+(a.length>4?"…":"")}return null}if(e===F.EventCategory.MotionOnMotionChanged){const o=t.detected,a=typeof t.source=="string"?t.source:null,i=o===!0?"motion start":o===!1?"motion stop":"motion";return a?`${i} (${a})`:i}if(e===F.EventCategory.ProviderDetection||e===F.EventCategory.DetectionCameraNative){const o=t.detections??[];if(!Array.isArray(o)||o.length===0)return(typeof t.class=="string"?t.class:null)??null;const a=new Map;for(const i of o){const l=i,u=l.class??l.macroClass,d=typeof u=="string"?u:"";d&&a.set(d,(a.get(d)??0)+1)}return[...a.entries()].map(([i,l])=>l>1?`${i} ×${l}`:i).join(", ")}const s=t.addonId,n=t.error;return n||(s?`addon: ${s}`:null)}function zk(e){const t=e.category;return t===F.EventCategory.DetectionResult||t===F.EventCategory.PipelineAudioInferenceResult?Jr(t,e.data)!==null:!0}var Qk=300;function kn({agentId:e,addonId:t,deviceId:s,defaultCategories:n,categories:o,category:a,maxHeight:i="max-h-96",limit:l=50,showCategoryFilter:u=!0,showFilters:d=!1,liveBuffer:f,onClose:m,className:g}){const b=(0,h.useMemo)(()=>n??o??Fk,[n,o]),x=(0,h.useMemo)(()=>[...b].sort().join(","),[b]),[v,w]=(0,h.useState)(()=>new Set(b)),y=(0,h.useRef)(x);(0,h.useEffect)(()=>{y.current!==x&&(y.current=x,w(new Set(b)))},[x,b]);const S=Ct(Qk),k=f??S,C=k.entries,[N,E]=(0,h.useState)(!0),[R,A]=(0,h.useState)(new Set),[Q,ee]=(0,h.useState)(""),[ne,pe]=(0,h.useState)(!1),[ae,ce]=(0,h.useState)(""),[se,J]=(0,h.useState)(0),H=(0,h.useRef)(null),xe=(0,h.useRef)(null),de=`${e??""}:${t??""}:${String(s??"")}:${a??""}`,D=(0,h.useRef)(de);(0,h.useEffect)(()=>{D.current!==de&&(D.current=de,k.reset(),A(new Set),J(0))},[de,k]),(0,h.useEffect)(()=>{if(!ne)return;const O=fe=>{const he=xe.current;he&&fe.target instanceof Node&&!he.contains(fe.target)&&pe(!1)};return document.addEventListener("mousedown",O),()=>{document.removeEventListener("mousedown",O)}},[ne]);const $=(0,h.useMemo)(()=>{const O={};return e&&(O.agentId=e),t&&(O.addonId=t),s!==void 0&&(O.deviceId=s),a&&(O.category=a),O},[e,t,s,a]),_=(0,h.useMemo)(()=>[...v].sort(),[v]),te=(0,h.useMemo)(()=>{const O={...$,limit:l};return _.length>0&&_.length<Ut.length&&(O.category=_),O},[$,l,(0,h.useMemo)(()=>_.join(","),[_]),_]),{data:U,isLoading:V}=p.systemEvents.getRecent.useQuery(te,{staleTime:3e4}),W=(0,h.useRef)(v);(0,h.useEffect)(()=>{W.current=v},[v]);const z=$;p.systemEvents.subscribe.useSubscription(z,{onData:O=>{const fe=O;fe?.id&&_k(fe,e,t,s)&&W.current.has(fe.category)&&k.append(fe)}});const X=(0,h.useRef)(C.length);(0,h.useEffect)(()=>{const O=H.current;if(!O){X.current=C.length;return}const fe=X.current;if(X.current=C.length,!(C.length<=fe)){if(N&&O.scrollTop<=8)O.scrollTo({top:0});else if(!N&&O.scrollTop>0){const he=O.firstElementChild?.firstElementChild,be=he instanceof HTMLElement?he.offsetHeight:28;O.scrollTop+=be*(C.length-fe)}}},[C.length,N]);const q=(0,h.useMemo)(()=>{const O=new Map;for(const be of U??[])O.set(be.id,be);for(const be of C)O.set(be.id,be);let fe=[...O.values()].filter(be=>v.has(be.category)).filter(zk);se>0&&(fe=fe.filter(be=>new Date(be.timestamp).getTime()>se));const he=Q.trim().toLowerCase();return he&&(fe=fe.filter(be=>{if(be.category.toLowerCase().includes(he)||Sn(be.category,be.data).label.toLowerCase().includes(he))return!0;const Mt=Jr(be.category,be.data);if(Mt&&Mt.toLowerCase().includes(he))return!0;try{if(new Date(be.timestamp).toLocaleTimeString().toLowerCase().includes(he))return!0}catch{}try{if(JSON.stringify(be.data).toLowerCase().includes(he)||JSON.stringify(be.source).toLowerCase().includes(he))return!0}catch{}return!1})),fe.sort((be,Mt)=>new Date(Mt.timestamp).getTime()-new Date(be.timestamp).getTime())},[U,C,v,Q,se]),Re=(0,h.useCallback)(O=>{A(fe=>{const he=new Set(fe);return he.has(O)?he.delete(O):he.add(O),he})},[]),De=(0,h.useCallback)(O=>{w(fe=>{const he=new Set(fe);return he.has(O)?he.delete(O):he.add(O),he})},[]),K=(0,h.useCallback)(()=>{w(new Set(b)),ee(""),J(0)},[b]),ue=(0,h.useCallback)(()=>{J(Date.now()),k.reset()},[k]),[ve,ye]=(0,h.useState)(!1),[L,M]=(0,h.useState)(null),T=(0,h.useCallback)(O=>{const fe=new Date(O.timestamp).toISOString(),he=Jr(O.category,O.data)??"",be=he?` ${he}`:"";return`${fe} [${O.category}]${be} data=${JSON.stringify(O.data)}`},[]),Z=(0,h.useCallback)(()=>{const O=q.map(T);navigator.clipboard.writeText(O.join(`
79
+ `)).then(()=>{ye(!0),setTimeout(()=>ye(!1),1500)})},[q,T]),re=(0,h.useCallback)(O=>{navigator.clipboard.writeText(T(O)).then(()=>{M(O.id),setTimeout(()=>M(fe=>fe===O.id?null:fe),1200)})},[T]),I=(0,h.useCallback)(()=>{w(new Set(Ut))},[]),Y=(0,h.useCallback)(()=>{w(new Set)},[]),Se=(0,h.useMemo)(()=>{const O=ae.trim().toLowerCase();return O?Ut.filter(fe=>fe.toLowerCase().includes(O)):Ut},[ae]),it=Ut.length,$e=v.size,Ht=$e===it,Ej=Ht?"All":`${$e}/${it}`;return(0,r.jsxs)("div",{className:j("h-full min-h-0 flex flex-col",g),onClick:O=>O.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Events"}),e&&(0,r.jsx)(es,{label:"agent",value:e}),t&&(0,r.jsx)(es,{label:"addon",value:t}),s!==void 0&&(0,r.jsx)(es,{label:"device",value:`#${s}`}),a&&(0,r.jsx)(es,{label:"category",value:a}),(0,r.jsxs)("button",{type:"button",onClick:()=>{E(O=>!O),!N&&H.current&&H.current.scrollTo({top:0,behavior:"smooth"})},className:j("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",N?"border-border text-foreground-subtle hover:text-foreground":"border-amber-500/30 bg-amber-500/10 text-amber-400"),children:[(0,r.jsx)(As,{className:"h-2.5 w-2.5"}),N?"Auto":"Paused"]}),u&&(0,r.jsxs)("div",{className:"relative",ref:xe,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>pe(O=>!O),className:j("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",Ht?"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:[(0,r.jsx)(Xo,{className:"h-2.5 w-2.5"}),"Filter (",Ej,")"]}),ne&&(0,r.jsx)(Uk,{search:ae,onSearchChange:ce,categories:Se,active:v,onToggle:De,onSelectAll:I,onSelectNone:Y,onResetDefaults:K})]}),(0,r.jsxs)("button",{type:"button",onClick:K,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:[(0,r.jsx)(aa,{className:"h-2.5 w-2.5"}),"Reset"]}),(0,r.jsxs)("button",{type:"button",onClick:ue,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:[(0,r.jsx)(et,{className:"h-2.5 w-2.5"}),"Clear"]}),(0,r.jsxs)("button",{type:"button",onClick:Z,disabled:q.length===0,className:j("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",ve?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",q.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible events",children:[(0,r.jsx)(pt,{className:"h-2.5 w-2.5"}),ve?"Copied!":"Copy"]}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{type:"text",value:Q,onChange:O=>ee(O.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"}),Q&&(0,r.jsx)("button",{type:"button",onClick:()=>ee(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:(0,r.jsx)(Ee,{className:"h-2.5 w-2.5"})})]}),C.length>0&&(0,r.jsxs)("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",C.length," live"]})]}),m&&(0,r.jsx)("button",{type:"button",onClick:m,className:"text-foreground-subtle hover:text-foreground",children:(0,r.jsx)(Ee,{className:"h-3.5 w-3.5"})})]}),(0,r.jsxs)("div",{ref:H,className:j("flex-1 min-h-0 overflow-auto text-[10px]",i),children:[V&&(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[(0,r.jsx)(qe,{className:"h-3.5 w-3.5 animate-spin"}),"Loading events..."]}),!V&&q.length===0&&(0,r.jsx)("div",{className:"py-4 text-center text-foreground-subtle",children:"No events found"}),q.length>0&&(0,r.jsx)("div",{className:"divide-y divide-border/30",children:q.map(O=>{const fe=Sn(O.category,O.data),he=fe.icon,be=Jr(O.category,O.data),Mt=R.has(O.id);return(0,r.jsxs)("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>Re(O.id),children:[(0,r.jsx)("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(O.timestamp).toLocaleTimeString()}),(0,r.jsx)(Vk,{copied:L===O.id,onCopy:()=>re(O)}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[Mt?(0,r.jsx)(St,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):(0,r.jsx)(mt,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),(0,r.jsxs)("span",{className:j("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[9px] font-medium",fe.color),children:[(0,r.jsx)(he,{className:"h-2.5 w-2.5"}),fe.label]}),O.source.nodeId&&O.source.nodeId!=="hub"&&(0,r.jsx)("span",{className:"text-[9px] px-1 py-0.5 rounded bg-foreground-subtle/10 text-foreground-subtle font-mono",children:O.source.nodeId})]}),be&&(0,r.jsx)("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5",children:be}),Mt&&(0,r.jsxs)("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:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-primary/70",children:"source"}),(0,r.jsx)("span",{className:"text-foreground-subtle",children:": "}),(0,r.jsx)("span",{className:"text-foreground",children:JSON.stringify(O.source)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-primary/70",children:"category"}),(0,r.jsx)("span",{className:"text-foreground-subtle",children:": "}),(0,r.jsx)("span",{className:"text-foreground",children:O.category})]}),Object.entries(O.data).map(([El,Mn])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-primary/70",children:El}),(0,r.jsx)("span",{className:"text-foreground-subtle",children:": "}),(0,r.jsx)("span",{className:"text-foreground break-all",children:typeof Mn=="object"?JSON.stringify(Mn):String(Mn)})]},El))]})]})]},O.id)})})]})]})}function Uk({search:e,onSearchChange:t,categories:s,active:n,onToggle:o,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return(0,r.jsxs)("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:u=>u.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[(0,r.jsx)(ar,{className:"h-3 w-3 text-foreground-subtle"}),(0,r.jsx)("input",{type:"text",value:e,onChange:u=>t(u.target.value),placeholder:"Filter categories…",className:"flex-1 bg-transparent text-[10px] focus:outline-none text-foreground placeholder:text-foreground-subtle",autoFocus:!0}),e&&(0,r.jsx)("button",{type:"button",onClick:()=>t(""),className:"text-foreground-subtle hover:text-foreground",children:(0,r.jsx)(Ee,{className:"h-2.5 w-2.5"})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[(0,r.jsx)("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),(0,r.jsx)("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),(0,r.jsx)("button",{type:"button",onClick:l,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),(0,r.jsxs)("div",{className:"overflow-y-auto flex-1",children:[s.length===0&&(0,r.jsx)("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),s.map(u=>{const d=n.has(u),f=Sn(u),m=f.icon;return(0,r.jsxs)("button",{type:"button",onClick:()=>o(u),className:"w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]",children:[(0,r.jsx)("input",{type:"checkbox",readOnly:!0,checked:d,className:"accent-violet-500"}),(0,r.jsxs)("span",{className:j("inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[9px] font-medium shrink-0",f.color),children:[(0,r.jsx)(m,{className:"h-2.5 w-2.5"}),f.label]}),(0,r.jsx)("span",{className:"text-foreground-subtle font-mono truncate",children:u})]},u)})]})]})}function Hk({position:e="bottom",className:t,...s}){return(0,r.jsx)("div",{className:j(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:(0,r.jsx)(kn,{maxHeight:"max-h-48",...s})})}function es({label:e,value:t}){return(0,r.jsxs)("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function Vk({copied:e,onCopy:t}){return(0,r.jsx)("button",{type:"button",title:"Copy this event",onClick:s=>{s.stopPropagation(),t()},className:j("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?(0,r.jsx)(sr,{className:"h-3 w-3"}):(0,r.jsx)(pt,{className:"h-3 w-3"})})}function Wk({deviceId:e,className:t="",onOpenChild:s}){const n=p.useUtils(),o=p.deviceDiscovery.listDiscovered.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),a=p.deviceDiscovery.getStatus.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),i=p.deviceDiscovery.refreshDiscovery.useMutation({onSuccess:()=>{n.deviceDiscovery.listDiscovered.invalidate({deviceId:e}),n.deviceDiscovery.getStatus.invalidate({deviceId:e})}}),l=p.deviceDiscovery.adoptDevice.useMutation({onSuccess:()=>{n.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),u=p.deviceDiscovery.releaseDevice.useMutation({onSuccess:()=>{n.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),[d,f]=(0,h.useState)(null),{available:m,adopted:g}=(0,h.useMemo)(()=>{const k=o.data??[],C=E=>typeof E.metadata.rtspChannel=="number"?E.metadata.rtspChannel:Number.POSITIVE_INFINITY,N=(E,R)=>{const A=C(E),Q=C(R);return A!==Q?A-Q:E.name.localeCompare(R.name)};return{available:k.filter(E=>!E.alreadyAdopted).sort(N),adopted:k.filter(E=>E.alreadyAdopted).sort(N)}},[o.data]),b=a.data,x=b?.lastError??null,v=b?.lastDiscoveryAt??null;async function w(){await i.mutateAsync({deviceId:e}).catch(()=>{})}async function y(k){f(k.childNativeId);try{await l.mutateAsync({deviceId:e,childNativeId:k.childNativeId})}finally{f(null)}}async function S(k){if(k.adoptedDeviceId!=null){f(k.childNativeId);try{await u.mutateAsync({deviceId:e,childDeviceId:k.adoptedDeviceId})}finally{f(null)}}}return(0,r.jsxs)("div",{className:`rounded-xl border border-border bg-surface ${t}`,children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2 border-b border-border px-3 py-2 sm:px-5 sm:py-3",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:"Discovered devices"}),(0,r.jsxs)("p",{className:"text-[11px] text-foreground-subtle",children:["Channels behind this hub. Click ",(0,r.jsx)("span",{className:"font-medium",children:"Add"})," to promote a channel to a managed device, or ",(0,r.jsx)("span",{className:"font-medium",children:"Remove"})," to detach."]})]}),(0,r.jsxs)("button",{type:"button",onClick:w,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?(0,r.jsx)(qe,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(Ls,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Refresh"})]})]}),x?(0,r.jsxs)("div",{className:"flex items-start gap-2 border-b border-border bg-destructive/10 px-5 py-2 text-[11px] text-destructive",children:[(0,r.jsx)(ir,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),(0,r.jsxs)("span",{children:["Last refresh failed: ",x]})]}):null,o.isLoading?(0,r.jsx)("div",{className:"flex items-center justify-center py-8 text-foreground-subtle",children:(0,r.jsx)(qe,{className:"h-5 w-5 animate-spin"})}):m.length===0&&g.length===0?(0,r.jsx)("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."}):(0,r.jsxs)(r.Fragment,{children:[m.length>0?(0,r.jsx)(Sl,{title:"Available to add",count:m.length,tone:"primary",children:m.map(k=>(0,r.jsx)(kl,{child:k,busy:d===k.childNativeId,onAdopt:y,onRelease:S,onOpenChild:s},k.childNativeId))}):null,g.length>0?(0,r.jsx)(Sl,{title:"Already adopted",count:g.length,tone:"muted",children:g.map(k=>(0,r.jsx)(kl,{child:k,busy:d===k.childNativeId,onAdopt:y,onRelease:S,onOpenChild:s},k.childNativeId))}):null]}),v!=null?(0,r.jsxs)("div",{className:"border-t border-border px-5 py-2 text-[10px] text-foreground-subtle",children:["Last refreshed ",new Date(v).toLocaleString()]}):null]})}function Sl({title:e,count:t,tone:s,children:n}){return(0,r.jsxs)("div",{className:"border-t border-border",children:[(0,r.jsxs)("div",{className:`flex items-center justify-between border-b px-3 sm:px-5 py-1.5 text-[10px] uppercase tracking-wider ${s==="primary"?"bg-primary/5 text-primary border-primary/30":"bg-surface text-foreground-subtle border-border"}`,children:[(0,r.jsx)("span",{className:"font-semibold",children:e}),(0,r.jsx)("span",{className:"font-mono",children:t})]}),(0,r.jsx)("div",{className:"divide-y divide-border",children:n})]})}function kl({child:e,busy:t,onAdopt:s,onRelease:n,onOpenChild:o}){return(0,r.jsxs)("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:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[(0,r.jsx)(qk,{status:e.status}),(0,r.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:e.name}),e.metadata.isDoorbell?(0,r.jsx)("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?(0,r.jsx)("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?(0,r.jsx)("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Multifocal"}):null]}),(0,r.jsxs)("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"?(0,r.jsxs)("span",{children:["ch ",(0,r.jsx)("span",{className:"font-mono",children:e.metadata.rtspChannel})]}):null,e.metadata.model?(0,r.jsx)("span",{className:"truncate max-w-[160px]",children:e.metadata.model}):null,e.metadata.uid?(0,r.jsxs)("span",{className:"font-mono truncate max-w-[140px]",children:[e.metadata.uid.slice(0,12),"…"]}):null]})]}),e.alreadyAdopted?(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[o&&e.adoptedDeviceId!==null?(0,r.jsxs)("button",{type:"button",onClick:()=>o(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:[(0,r.jsx)(Zo,{className:"h-3.5 w-3.5"}),"Open"]}):null,(0,r.jsxs)("button",{type:"button",onClick:()=>{n(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?(0,r.jsx)(qe,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(et,{className:"h-3.5 w-3.5"}),"Remove"]})]}):(0,r.jsxs)("button",{type:"button",onClick:()=>{s(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?(0,r.jsx)(qe,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(or,{className:"h-3.5 w-3.5"}),"Add"]})]})}function qk({status:e}){switch(e){case"online":return(0,r.jsxs)("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:[(0,r.jsx)(fa,{className:"h-2.5 w-2.5"})," online"]});case"sleeping":return(0,r.jsxs)("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:[(0,r.jsx)(Ds,{className:"h-2.5 w-2.5"})," sleeping"]});case"offline":return(0,r.jsxs)("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:[(0,r.jsx)(jf,{className:"h-2.5 w-2.5"})," offline"]});default:return(0,r.jsxs)("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:[(0,r.jsx)(Vo,{className:"h-2.5 w-2.5"})," unknown"]})}}function Kk(e,t){if(!e||typeof e!="object")return!1;const s=e;if(s.category!==F.EventCategory.DeviceStateChanged)return!1;const n=s.data;return!(!n||typeof n!="object"||n.deviceId!==t||typeof n.capName!="string"||!n.slice||typeof n.slice!="object")}function jn(e){if(!e||typeof e!="object")return null;const t=e,s=typeof t.id=="string"?t.id:null,n=typeof t.timestamp=="string"?t.timestamp:null,o=t.data;return!s||!n||!o||typeof o!="object"||typeof o.capName!="string"||!o.slice||typeof o.slice!="object"?null:{id:s,timestamp:n,capName:o.capName,slice:o.slice}}var Zk=300,Yk=Object.freeze([...new Set(F.ALL_CAPABILITY_DEFINITIONS.filter(e=>e.scope==="device").map(e=>e.name))].sort());function jl({deviceId:e,defaultCaps:t,maxHeight:s="max-h-96",limit:n=50,liveBuffer:o,onClose:a,className:i}){const[l,u]=(0,h.useState)((0,h.useMemo)(()=>new Set(t??[]),[t])),[d,f]=(0,h.useState)(""),[m,g]=(0,h.useState)(!0),[b,x]=(0,h.useState)(new Set),[v,w]=(0,h.useState)(0),[y,S]=(0,h.useState)(!1),[k,C]=(0,h.useState)(""),N=(0,h.useRef)(null),E=Ct(Zk),R=o??E,A=R.entries,Q=(0,h.useRef)(null),ee=(0,h.useRef)(e);(0,h.useEffect)(()=>{ee.current!==e&&(ee.current=e,R.reset(),x(new Set),w(0))},[e,R]);const ne=(0,h.useMemo)(()=>({deviceId:e,category:F.EventCategory.DeviceStateChanged,limit:n}),[e,n]),{data:pe,isLoading:ae}=p.systemEvents.getRecent.useQuery(ne,{staleTime:3e4}),ce=(0,h.useRef)(l);(0,h.useEffect)(()=>{ce.current=l},[l]),p.systemEvents.subscribe.useSubscription({deviceId:e,category:F.EventCategory.DeviceStateChanged},{onData:L=>{if(!Kk(L,e))return;const M=jn(L);if(!M)return;const T=ce.current;T.size>0&&!T.has(M.capName)||R.append(M)}});const se=(0,h.useRef)(A.length);(0,h.useEffect)(()=>{const L=Q.current;if(!L){se.current=A.length;return}const M=se.current;if(se.current=A.length,!(A.length<=M)){if(m&&L.scrollTop<=8)L.scrollTo({top:0});else if(!m&&L.scrollTop>0){const T=L.firstElementChild?.firstElementChild,Z=T instanceof HTMLElement?T.offsetHeight:28,re=A.length-M;L.scrollTop+=Z*re}}},[A.length,m]);const J=(0,h.useMemo)(()=>{const L=new Map;for(const Z of pe??[]){const re=jn(Z);re&&L.set(re.id,re)}for(const Z of A)L.set(Z.id,Z);let M=[...L.values()];v>0&&(M=M.filter(Z=>new Date(Z.timestamp).getTime()>v)),l.size>0&&(M=M.filter(Z=>l.has(Z.capName)));const T=d.trim().toLowerCase();return T&&(M=M.filter(Z=>{if(Z.capName.toLowerCase().includes(T))return!0;try{if(new Date(Z.timestamp).toLocaleTimeString().toLowerCase().includes(T))return!0}catch{}try{if(Object.entries(Z.slice).map(([re,I])=>`${re}=${Nn(I)}`).join(" · ").toLowerCase().includes(T))return!0}catch{}try{if(JSON.stringify(Z.slice).toLowerCase().includes(T))return!0}catch{}return!1})),M.sort((Z,re)=>new Date(re.timestamp).getTime()-new Date(Z.timestamp).getTime())},[pe,A,l,d,v]),H=(0,h.useMemo)(()=>{const L=new Set(Yk);for(const M of pe??[]){const T=jn(M);T&&L.add(T.capName)}for(const M of A)L.add(M.capName);return[...L].sort()},[pe,A]),xe=(0,h.useCallback)(L=>{x(M=>{const T=new Set(M);return T.has(L)?T.delete(L):T.add(L),T})},[]),de=(0,h.useCallback)(L=>{u(M=>{const T=new Set(M);return T.has(L)?T.delete(L):T.add(L),T})},[]),D=(0,h.useCallback)(()=>{u(new Set(t??[])),f("")},[t]),$=(0,h.useCallback)(()=>{w(Date.now()),R.reset()},[R]),[_,te]=(0,h.useState)(!1),[U,V]=(0,h.useState)(null),W=(0,h.useCallback)(L=>`${new Date(L.timestamp).toISOString()} [${L.capName}] slice=${JSON.stringify(L.slice)}`,[]),z=(0,h.useCallback)(()=>{const L=J.map(W);navigator.clipboard.writeText(L.join(`
80
+ `)).then(()=>{te(!0),setTimeout(()=>te(!1),1500)})},[J,W]),X=(0,h.useCallback)(L=>{navigator.clipboard.writeText(W(L)).then(()=>{V(L.id),setTimeout(()=>V(M=>M===L.id?null:M),1200)})},[W]),q=(0,h.useCallback)(()=>{u(new Set(H))},[H]),Re=(0,h.useCallback)(()=>{u(new Set)},[]),De=(0,h.useMemo)(()=>{const L=k.trim().toLowerCase();return L?H.filter(M=>M.toLowerCase().includes(L)):H},[k,H]),K=H.length,ue=l.size,ve=ue===0||ue===K,ye=ve?"All":`${ue}/${K}`;return(0,h.useEffect)(()=>{if(!y)return;const L=M=>{const T=N.current;T&&!T.contains(M.target)&&S(!1)};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[y]),(0,r.jsxs)("div",{className:j("h-full min-h-0 flex flex-col",i),onClick:L=>L.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"State"}),(0,r.jsx)(Xk,{label:"device",value:`#${e}`}),(0,r.jsxs)("button",{type:"button",onClick:()=>{g(L=>!L),!m&&Q.current&&Q.current.scrollTo({top:0,behavior:"smooth"})},className:j("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:[(0,r.jsx)(As,{className:"h-2.5 w-2.5"}),m?"Auto":"Paused"]}),(0,r.jsxs)("div",{className:"relative",ref:N,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>S(L=>!L),className:j("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",ve?"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:[(0,r.jsx)(Xo,{className:"h-2.5 w-2.5"}),"Filter (",ye,")"]}),y&&(0,r.jsx)(Jk,{search:k,onSearchChange:C,caps:De,active:l,onToggle:de,onSelectAll:q,onSelectNone:Re,onResetDefaults:D})]}),(0,r.jsxs)("button",{type:"button",onClick:D,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:[(0,r.jsx)(aa,{className:"h-2.5 w-2.5"}),"Reset"]}),(0,r.jsxs)("button",{type:"button",onClick:$,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Clear visible entries",children:[(0,r.jsx)(et,{className:"h-2.5 w-2.5"}),"Clear"]}),(0,r.jsxs)("button",{type:"button",onClick:z,disabled:J.length===0,className:j("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",_?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",J.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible state changes",children:[(0,r.jsx)(pt,{className:"h-2.5 w-2.5"}),_?"Copied!":"Copy"]}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{type:"text",value:d,onChange:L=>f(L.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"}),d&&(0,r.jsx)("button",{type:"button",onClick:()=>f(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:(0,r.jsx)(Ee,{className:"h-2.5 w-2.5"})})]}),A.length>0&&(0,r.jsxs)("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",A.length," live"]})]}),a&&(0,r.jsx)("button",{type:"button",onClick:a,className:"text-foreground-subtle hover:text-foreground",children:(0,r.jsx)(Ee,{className:"h-3.5 w-3.5"})})]}),(0,r.jsxs)("div",{ref:Q,className:j("flex-1 min-h-0 overflow-auto text-[10px]",s),children:[ae&&(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[(0,r.jsx)(qe,{className:"h-3.5 w-3.5 animate-spin"}),"Loading state changes..."]}),!ae&&J.length===0&&(0,r.jsx)("div",{className:"py-4 text-center text-foreground-subtle",children:"No state changes"}),J.length>0&&(0,r.jsx)("div",{className:"divide-y divide-border/30",children:J.map(L=>{const M=b.has(L.id),T=Object.entries(L.slice),Z=T.slice(0,3).map(([re,I])=>`${re}=${Nn(I)}`).join(" · ");return(0,r.jsxs)("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>xe(L.id),children:[(0,r.jsx)("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(L.timestamp).toLocaleTimeString()}),(0,r.jsx)(ej,{copied:U===L.id,onCopy:()=>X(L)}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[M?(0,r.jsx)(St,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):(0,r.jsx)(mt,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),(0,r.jsx)("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:L.capName}),T.length>3&&(0,r.jsxs)("span",{className:"text-[9px] text-foreground-subtle",children:["+",T.length-3," more"]})]}),Z&&(0,r.jsx)("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5 truncate",children:Z}),M&&(0,r.jsx)("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:T.length===0?(0,r.jsx)("div",{className:"text-foreground-subtle italic",children:"empty slice"}):T.map(([re,I])=>(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-primary/70",children:re}),(0,r.jsx)("span",{className:"text-foreground-subtle",children:": "}),(0,r.jsx)("span",{className:"text-foreground break-all",children:Nn(I)})]},re))})]})]},L.id)})})]})]})}function Nn(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 Xk({label:e,value:t}){return(0,r.jsxs)("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function Jk({search:e,onSearchChange:t,caps:s,active:n,onToggle:o,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return(0,r.jsxs)("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:u=>u.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[(0,r.jsx)(ar,{className:"h-3 w-3 text-foreground-subtle"}),(0,r.jsx)("input",{type:"text",value:e,onChange:u=>t(u.target.value),placeholder:"Filter caps…",className:"flex-1 bg-transparent text-[10px] focus:outline-none text-foreground placeholder:text-foreground-subtle",autoFocus:!0}),e&&(0,r.jsx)("button",{type:"button",onClick:()=>t(""),className:"text-foreground-subtle hover:text-foreground",children:(0,r.jsx)(Ee,{className:"h-2.5 w-2.5"})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[(0,r.jsx)("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),(0,r.jsx)("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),(0,r.jsx)("button",{type:"button",onClick:l,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),(0,r.jsxs)("div",{className:"overflow-y-auto flex-1",children:[s.length===0&&(0,r.jsx)("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),s.map(u=>(0,r.jsxs)("button",{type:"button",onClick:()=>o(u),className:"w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]",children:[(0,r.jsx)("input",{type:"checkbox",readOnly:!0,checked:n.has(u),className:"accent-violet-500"}),(0,r.jsx)("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:u})]},u))]})]})}function ej({copied:e,onCopy:t}){return(0,r.jsx)("button",{type:"button",title:"Copy this state change",onClick:s=>{s.stopPropagation(),t()},className:j("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?(0,r.jsx)(sr,{className:"h-3 w-3"}):(0,r.jsx)(pt,{className:"h-3 w-3"})})}var Cn=500,tj=[{id:"logs",label:"Logs",icon:mf},{id:"events",label:"Events",icon:Or},{id:"state",label:"State",icon:Yd}];function rj({deviceId:e,defaultEventCategories:t,defaultStateCaps:s,initialTab:n="events",className:o,maxHeight:a="max-h-96"}){const[i,l]=(0,h.useState)(n),u=Ct(Cn),d=Ct(Cn),f=Ct(Cn),m=u.reset,g=d.reset,b=f.reset;return(0,h.useEffect)(()=>{m(),g(),b()},[e,m,g,b]),(0,r.jsxs)("div",{className:j("flex flex-col h-full min-h-0",o),children:[(0,r.jsx)("div",{className:"flex items-center gap-1 mb-2 shrink-0",children:tj.map(({id:x,label:v,icon:w})=>(0,r.jsxs)("button",{type:"button",onClick:()=>l(x),className:j("inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[11px] font-medium transition-colors",i===x?"bg-primary/15 text-primary border border-primary/30":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover border border-transparent"),children:[(0,r.jsx)(w,{className:"h-3.5 w-3.5"}),v]},x))}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:[i==="logs"&&(0,r.jsx)(vn,{deviceId:e,maxHeight:a,showFilters:!1,liveBuffer:u}),i==="events"&&(0,r.jsx)(kn,{deviceId:e,defaultCategories:t,maxHeight:a,showCategoryFilter:!0,liveBuffer:d}),i==="state"&&(0,r.jsx)(jl,{deviceId:e,defaultCaps:s,maxHeight:a,liveBuffer:f})]})]})}function sj({label:e,icon:t,title:s="Confirm action",description:n,confirmLabel:o,triggerVariant:a="outline",confirmVariant:i="danger",size:l="sm",disabled:u,className:d,action:f,onSuccess:m}){const[g,b]=(0,h.useState)(!1),[x,v]=(0,h.useState)(!1),[w,y]=(0,h.useState)(null),S=async()=>{y(null),v(!0);try{const k=await f();m?.(k),b(!1)}catch(k){y(k instanceof Error?k.message:String(k))}finally{v(!1)}};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(lr,{type:"button",variant:a,size:l,disabled:u,onClick:()=>{y(null),b(!0)},className:d,children:[t&&(0,r.jsx)(t,{className:"h-3.5 w-3.5"}),e]}),(0,r.jsx)(ka,{open:g,onOpenChange:k=>!x&&b(k),children:(0,r.jsxs)(Fs,{children:[(0,r.jsxs)(ja,{children:[(0,r.jsxs)(Ca,{className:"flex items-center gap-2",children:[(0,r.jsx)(ir,{className:"h-4 w-4 text-amber-400"}),s]}),typeof n=="string"?(0,r.jsx)(Ma,{children:n}):n]}),w&&(0,r.jsx)("div",{className:j("mt-2 px-3 py-2 rounded border border-danger/40 bg-danger/10","text-xs text-danger"),children:w}),(0,r.jsxs)(Na,{children:[(0,r.jsx)(lr,{type:"button",variant:"ghost",size:l,disabled:x,onClick:()=>b(!1),children:"Cancel"}),(0,r.jsxs)(lr,{type:"button",variant:i,size:l,disabled:x,onClick:()=>{S()},children:[x&&(0,r.jsx)(qe,{className:"h-3.5 w-3.5 animate-spin"}),o??e]})]})]})})]})}function ts({direction:e,icon:t,disabled:s,className:n,variant:o,onMove:a,onStart:i,onStop:l}){const[u,d]=(0,h.useState)(null),[f,m]=(0,h.useState)(!1),g=(0,h.useCallback)(y=>{if(s)return;y.currentTarget.setPointerCapture(y.pointerId),d(Date.now()),m(!1);const S=setTimeout(()=>{m(!0),i(e)},250);y.currentTarget.dataset.timer=String(S)},[e,s,i]),b=(0,h.useCallback)(y=>{const S=Number(y.currentTarget.dataset.timer);S&&clearTimeout(S),y.currentTarget.dataset.timer="",f?l():u!==null&&a(e),d(null),m(!1)},[f,e,a,l,u]),x=(0,h.useCallback)(y=>{const S=Number(y.currentTarget.dataset.timer);S&&clearTimeout(S),y.currentTarget.dataset.timer="",f&&l(),d(null),m(!1)},[f,l]),v=o==="panel"?"h-9 w-9":"h-7 w-7",w=o==="panel"?"h-4 w-4":"h-3.5 w-3.5";return(0,r.jsx)("button",{type:"button",disabled:s,onPointerDown:g,onPointerUp:b,onPointerCancel:x,className:j("flex items-center justify-center rounded transition-colors disabled:opacity-40",o==="panel"?"text-foreground hover:bg-surface-hover active:bg-surface-hover/80":"text-white hover:bg-white/15 active:bg-white/25",v,n),title:e,children:(0,r.jsx)(t,{className:w})})}function nj({controls:e,mode:t="overlay",showPresets:s,showZoom:n=!0,showHome:o=!0,className:a}){const{move:i,startContinuous:l,stopContinuous:u,zoom:d,goHome:f,goToPreset:m,presets:g,busy:b,error:x}=e,[v,w]=(0,h.useState)(!1),y=(s??g.length>0)&&g.length>0,S=t==="panel",k=S?"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",C=j(S?"flex items-center gap-3 rounded-lg p-2":"flex items-center gap-2 rounded-lg border border-white/30 bg-zinc-900/90 backdrop-blur-md p-2 shadow-lg shadow-black/40",b&&"ring-1 ring-primary/40"),N=S?"h-9 w-9":"h-7 w-7",E=S?"h-4 w-4":"h-3.5 w-3.5",R=S?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15",A=S?"h-12 w-px bg-border mx-1":"h-12 w-px bg-white/15 mx-1";return(0,r.jsxs)("div",{className:j(k,a),children:[x&&(0,r.jsxs)("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: ",x]}),(0,r.jsxs)("div",{className:j(C,S&&"justify-center"),children:[(0,r.jsxs)("div",{className:"grid grid-cols-3 gap-0.5",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:S?"h-9 w-9":"h-7 w-7"}),(0,r.jsx)(ts,{direction:"up",icon:Ld,variant:t,onMove:i,onStart:l,onStop:u}),(0,r.jsx)("span",{"aria-hidden":!0,className:S?"h-9 w-9":"h-7 w-7"}),(0,r.jsx)(ts,{direction:"left",icon:Td,variant:t,onMove:i,onStart:l,onStop:u}),(0,r.jsx)("span",{"aria-hidden":!0,className:S?"h-9 w-9":"h-7 w-7"}),(0,r.jsx)(ts,{direction:"right",icon:Id,variant:t,onMove:i,onStart:l,onStop:u}),(0,r.jsx)("span",{"aria-hidden":!0,className:S?"h-9 w-9":"h-7 w-7"}),(0,r.jsx)(ts,{direction:"down",icon:Dd,variant:t,onMove:i,onStart:l,onStop:u}),(0,r.jsx)("span",{"aria-hidden":!0,className:S?"h-9 w-9":"h-7 w-7"})]}),(n||o)&&(0,r.jsx)("div",{className:A}),(0,r.jsxs)("div",{className:"flex flex-col gap-0.5",children:[n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",onClick:()=>d("in"),disabled:b,title:"Zoom in",className:j("flex items-center justify-center rounded disabled:opacity-40",N,R),children:(0,r.jsx)(Nf,{className:E})}),(0,r.jsx)("button",{type:"button",onClick:()=>d("out"),disabled:b,title:"Zoom out",className:j("flex items-center justify-center rounded disabled:opacity-40",N,R),children:(0,r.jsx)(Cf,{className:E})})]}),o&&(0,r.jsx)("button",{type:"button",onClick:()=>f(),disabled:b,title:"Go home",className:j("flex items-center justify-center rounded disabled:opacity-40",N,R),children:(0,r.jsx)(Jo,{className:E})})]}),y&&(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>w(Q=>!Q),disabled:b,className:j("flex items-center gap-1 rounded px-2 text-[10px] disabled:opacity-40",S?"h-9 text-foreground hover:bg-surface-hover":"h-7 text-white hover:bg-white/15"),title:"Presets",children:["Presets",(0,r.jsx)(St,{className:j("h-3 w-3 transition-transform",v&&"rotate-180")})]}),v&&(0,r.jsx)("div",{className:j("absolute right-0 min-w-[140px] rounded-lg shadow-xl py-1 z-20",S?"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:g.map(Q=>(0,r.jsx)("button",{type:"button",onClick:()=>{m(Q.id),w(!1)},disabled:b,className:j("block w-full px-3 py-1.5 text-left text-[10px] disabled:opacity-40",S?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15"),children:Q.name||Q.id},Q.id))})]})]})]})}function oj(e,t){const s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s)}function aj({trpc:e,deviceId:t,deviceName:s,size:n="sm",className:o}){const[a,i]=(0,h.useState)(!1),[l,u]=(0,h.useState)(!1),[d,f]=(0,h.useState)(null),m=s.replace(/[^a-zA-Z0-9_.-]+/g,"_"),g=(0,h.useCallback)(async N=>{i(!0),f(null),u(!1);try{const E=await e.snapshot.getSnapshot.query({deviceId:t,force:!0});if(!E)throw new Error("No snapshot available");const R=`data:${E.contentType};base64,${E.base64}`;if(N==="copy")try{await navigator.clipboard.writeText(R)}catch{throw new Error("Clipboard unavailable")}else{const A=E.contentType.includes("png")?"png":"jpg";oj(`${m}-${new Date().toISOString().replace(/[:.]/g,"-")}.${A}`,R)}u(!0),setTimeout(()=>u(!1),1500)}catch(E){f(E instanceof Error?E.message:String(E))}finally{i(!1)}},[e,t,m]),b=n==="md"?"h-9 px-3 text-sm gap-2":"h-7 px-2.5 text-[11px] gap-1.5",[x,v]=(0,h.useState)(null),[w,y]=(0,h.useState)(!1),S=()=>{y(!1),v(setTimeout(()=>{y(!0),g("copy")},600))},k=()=>{x&&(clearTimeout(x),v(null)),w||g("download")},C=()=>{x&&(clearTimeout(x),v(null))};return(0,r.jsxs)("button",{type:"button",title:"Click to download · long-press to copy",disabled:a,onPointerDown:S,onPointerUp:k,onPointerLeave:C,onPointerCancel:C,className:j("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",b,d&&"border-danger/40 text-danger",o),children:[a?(0,r.jsx)(qe,{className:"h-3.5 w-3.5 animate-spin"}):l?(0,r.jsx)(sr,{className:"h-3.5 w-3.5 text-success"}):(0,r.jsx)(Ps,{className:"h-3.5 w-3.5"}),"Snapshot"]})}function ij(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 lj({history:e,limit:t=5,latestIsFresh:s,className:n}){if(e.length===0)return null;const o=s?Gd:Or,a=e.slice(0,t);return(0,r.jsxs)("div",{className:j("rounded-lg border border-border bg-surface px-3 py-2",n),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,r.jsx)(o,{className:j("h-4 w-4 text-amber-400",s&&"animate-pulse")}),(0,r.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:"Recent presses"}),(0,r.jsx)("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})]}),(0,r.jsx)("ul",{className:"space-y-1",children:a.map(i=>(0,r.jsxs)("li",{className:"flex items-center justify-between text-[11px]",title:new Date(i.timestamp).toLocaleString(),children:[(0,r.jsx)("span",{className:"text-foreground",children:ij(i.timestamp)}),(0,r.jsx)("span",{className:"text-foreground-subtle font-mono text-[10px]",children:new Date(i.timestamp).toLocaleTimeString()})]},`${i.deviceId}-${i.timestamp}`))})]})}function cj({items:e,header:t,triggerClassName:s,title:n="More actions"}){const[o,a]=(0,h.useState)(!1),i=e.filter(l=>!l.hidden);return i.length===0?null:(0,r.jsxs)($a,{open:o,onOpenChange:a,children:[(0,r.jsx)(Ga,{title:n,className:j("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",s),children:(0,r.jsx)(Ko,{className:"h-4 w-4"})}),(0,r.jsxs)(Ba,{className:"left-auto right-0 mt-1 min-w-[200px] p-1",children:[t&&(0,r.jsx)("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle",children:t}),(0,r.jsx)("ul",{className:"space-y-0.5",children:i.map((l,u)=>(0,r.jsxs)("li",{children:[l.separatorBefore&&u>0&&(0,r.jsx)("div",{className:"my-1 h-px bg-border"}),(0,r.jsxs)("button",{type:"button",disabled:l.disabled,onClick:()=>{l.disabled||(l.onClick(),a(!1))},className:j("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&&(0,r.jsx)(l.icon,{className:j("h-3.5 w-3.5 shrink-0 mt-0.5",l.danger&&"text-danger/80")}),(0,r.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"block leading-tight",children:l.label}),l.description&&(0,r.jsx)("span",{className:"block mt-0.5 text-[10px] text-foreground-subtle leading-tight",children:l.description})]})]})]},l.id))})]})]})}var uj=[{value:"view",label:"View",icon:nr,hint:"Read-only — queries + subscriptions"},{value:"create",label:"Create",icon:af,hint:"Mutations that create or update"},{value:"delete",label:"Delete",icon:et,hint:"Destructive ops (delete/revoke/reset/…)"}];function dj(){return{type:"capability",target:"",access:["view"]}}function fj(e,t,s,n){const o=e==="addon"?s:n;if(t==null)return o;const a=new Set(t.filter(i=>i.type===e).map(i=>i.target));return o.filter(i=>a.has(i))}function mj(e,t){if(t==null)return["view","create","delete"];const s=t.filter(o=>o.type===e.type&&o.target===e.target);if(s.length===0)return[];const n=new Set;for(const o of s)for(const a of o.access)n.add(a);return[...n]}function pj({value:e,onChange:t,clampToParent:s,emptyHint:n}){const{data:o}=Xi(),a=(0,h.useMemo)(()=>(o??[]).map(f=>f.manifest.id).sort(),[o]),i=(0,h.useMemo)(()=>[...F.KNOWN_CAP_NAMES].sort(),[]),l=(f,m)=>{t(e.map((g,b)=>{if(b!==f)return g;const x={...g,...m};return m.type!==void 0&&m.type!==g.type&&(x.target=""),x}))},u=f=>{t(e.filter((m,g)=>g!==f))},d=()=>{t([...e,dj()])};return(0,r.jsxs)("div",{className:"space-y-2",children:[e.length===0&&n&&(0,r.jsx)("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-2",children:n}),e.map((f,m)=>{const g=fj(f.type,s,a,i),b=mj(f,s);return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 rounded border border-border bg-surface px-2 py-1.5",children:[(0,r.jsxs)("select",{value:f.type,onChange:x=>l(m,{type:x.target.value}),className:"rounded border border-border bg-background px-2 py-1 text-[11px] focus:outline-none focus:ring-1 focus:ring-primary",children:[(0,r.jsx)("option",{value:"capability",children:"capability"}),(0,r.jsx)("option",{value:"addon",children:"addon"})]}),(0,r.jsxs)("select",{value:f.target,onChange:x=>l(m,{target:x.target.value}),className:"flex-1 min-w-[160px] rounded border border-border bg-background px-2 py-1 text-[11px] font-mono focus:outline-none focus:ring-1 focus:ring-primary",children:[(0,r.jsxs)("option",{value:"",children:["— pick ",f.type," —"]}),g.map(x=>(0,r.jsx)("option",{value:x,children:x},x))]}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:uj.map(({value:x,label:v,icon:w,hint:y})=>{const S=f.access.includes(x),k=s!=null&&!b.includes(x)&&!S;return(0,r.jsxs)("label",{title:k?`${y} — not granted by your scope`:y,className:`inline-flex items-center gap-1 rounded px-1.5 py-1 text-[10px] cursor-pointer transition-colors ${S?"bg-primary/15 text-primary font-medium":"text-foreground-subtle hover:bg-foreground-subtle/10"} ${k?"opacity-40 cursor-not-allowed":""}`,children:[(0,r.jsx)("input",{type:"checkbox",checked:S,disabled:k,onChange:C=>{const N=new Set(f.access);C.target.checked?N.add(x):N.delete(x),l(m,{access:[...N]})},className:"sr-only"}),(0,r.jsx)(w,{className:"h-3 w-3"}),v]},x)})}),(0,r.jsx)("button",{type:"button",onClick:()=>u(m),className:"rounded p-1 text-foreground-subtle hover:bg-danger/10 hover:text-danger transition-colors",title:"Remove scope",children:(0,r.jsx)(Ee,{className:"h-3 w-3"})})]},m)}),(0,r.jsxs)("button",{type:"button",onClick:d,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-foreground-subtle hover:text-foreground hover:bg-foreground-subtle/10 transition-colors",children:[(0,r.jsx)(or,{className:"h-3 w-3"}),"Add scope"]})]})}function hj(e){for(const t of e){if(t.target.trim().length===0)return`Scope ${t.type}: pick a target`;if(t.access.length===0)return`Scope ${t.type}:${t.target}: pick at least one access`}return null}var Nl=at("camstack:zone-editing",null);function gj({children:e}){const[t,s]=(0,h.useState)(!1),[n,o]=(0,h.useState)(null),[a,i]=(0,h.useState)(null),[l,u]=(0,h.useState)(null),d=(0,h.useCallback)(S=>{s(S),S||(o(null),i(null),u(null))},[]),f=(0,h.useCallback)(S=>{o(S)},[]),m=(0,h.useCallback)(S=>{i(S)},[]),g=(0,h.useCallback)(S=>{s(!0),i(null),o(S),u(null)},[]),b=(0,h.useCallback)(()=>{s(!1),o(null),i(null),u(null)},[]),x=(0,h.useCallback)(S=>{i(S.id),u(S)},[]),v=(0,h.useCallback)(S=>{u(k=>k===null?k:{...k,...S})},[]),w=(0,h.useCallback)(()=>{u(null)},[]),y=(0,h.useMemo)(()=>({editing:t,drawingKind:n,selectedZoneId:a,editingDraft:l,setEditing:d,setDrawingKind:f,setSelectedZoneId:m,startDrawing:g,exitEditing:b,enterDraft:x,updateDraft:v,discardDraft:w}),[t,n,a,l,d,f,m,g,b,x,v,w]);return(0,r.jsx)(Nl.Provider,{value:y,children:e})}function bj(){return(0,h.useContext)(Nl)}var Cl=500,xj=800;function rs(e,t,s){try{const n=e.live;if(!n)return null;const o=n.onEvent;return!o||typeof o.subscribe!="function"?null:o.subscribe({category:t},{onData:s})}catch{return null}}function ss(e,t){return e?.id===t}function vj(e,t){const[s,n]=(0,h.useState)(null),[o,a]=(0,h.useState)(null),[i,l]=(0,h.useState)(null),[u,d]=(0,h.useState)("watching"),f=(0,h.useRef)(void 0),m=(0,h.useRef)(void 0),g=(0,h.useRef)(void 0);return(0,h.useEffect)(()=>{if(t===null)return;const b=rs(e,"detection.motion-analysis",x=>{const v=x;if(!ss(v?.source,t))return;const w=v.data;!w?.regions||w.regions.length===0||(n({zones:w.regions.map(y=>({...y.bbox,intensity:y.intensity})),frameWidth:w.frameWidth,frameHeight:w.frameHeight}),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>n(null),Cl))});return()=>{b?.unsubscribe(),f.current&&clearTimeout(f.current)}},[e,t]),(0,h.useEffect)(()=>{if(t===null)return;const b=rs(e,"detection.motion-zones-raw",x=>{const v=x;if(!ss(v?.source,t))return;const w=v.data;w?.zones&&(a({boxes:w.zones.map(y=>({bbox:y.bbox,changeScore:y.changeScore})),frameWidth:w.frameSize?.width??0,frameHeight:w.frameSize?.height??0,motionScore:w.zones.length>0?w.zones.reduce((y,S)=>y+S.changeScore,0)/w.zones.length:0}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>a(null),Cl))});return()=>{b?.unsubscribe(),m.current&&clearTimeout(m.current)}},[e,t]),(0,h.useEffect)(()=>{if(t===null)return;const b=rs(e,"detection.result",x=>{const v=x;if(!ss(v?.source,t))return;const w=v.data?.frame;w?.detections?.length&&(l({detections:w.detections,frameWidth:w.width,frameHeight:w.height}),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>l(null),xj))});return()=>{b?.unsubscribe(),g.current&&clearTimeout(g.current)}},[e,t]),(0,h.useEffect)(()=>{if(t===null)return;const b=rs(e,"detection.phase-transition",x=>{const v=x;ss(v?.source,t)&&v.data?.to&&d(v.data.to)});return()=>{b?.unsubscribe()}},[e,t]),{motion:s,motionRaw:o,detection:i,phase:u}}function yj(e,t,s=5e3){const[n,o]=(0,h.useState)([]);(0,h.useEffect)(()=>{if(t===null)return;let d=!1;const f=()=>{e.webrtcSession.listStreams.query({deviceId:t}).then(g=>{d||o(g)}).catch(()=>{})};f();const m=setInterval(f,s);return()=>{d=!0,clearInterval(m)}},[e,t,s]);const[a,i]=(0,h.useState)(null);(0,h.useEffect)(()=>{if(t===null)return;let d=!1;return e.pipelineOrchestrator&&e.pipelineOrchestrator.getCameraMetrics.query({deviceId:t}).then(f=>{d||!f||i({phase:f.phase,detectionFps:f.actualFps,avgInferenceMs:f.avgInferenceTimeMs,droppedFrames:f.droppedFrames})}).catch(()=>{}),()=>{d=!0}},[e,t]),ur("pipeline.camera-metrics-snapshot",d=>{if(t===null)return;const f=d.data;f.deviceId!==t||!f.metrics||i({phase:f.metrics.phase,detectionFps:f.metrics.actualFps,avgInferenceMs:f.metrics.avgInferenceTimeMs,droppedFrames:f.metrics.droppedFrames})});const{streams:l,hasWebrtc:u}=(0,h.useMemo)(()=>t===null||n.length===0?{streams:[],hasWebrtc:!1}:{streams:n.map(d=>({id:d.id,label:d.label,target:d.target,status:d.status,inputFps:d.inputFps,decodeFps:d.decodeFps,bitrateKbps:d.bitrateKbps})),hasWebrtc:!0},[t,n]);return{streams:l,hasWebrtc:u,pipelineMetrics:a,createSession:(0,h.useCallback)(async(d,f)=>{if(t===null)throw new Error("No device selected");const m=await e.webrtcSession.createSession.mutate({deviceId:t,target:d,hints:f});return{sessionId:m.sessionId,sdpOffer:m.sdpOffer}},[e,t]),sendAnswer:(0,h.useCallback)(async(d,f)=>{if(t===null)throw new Error("No device selected");await e.webrtcSession.handleAnswer.mutate({deviceId:t,sessionId:d,sdpAnswer:f})},[e,t]),closeSession:(0,h.useCallback)(async d=>{t!==null&&await e.webrtcSession.closeSession.mutate({deviceId:t,sessionId:d}).catch(()=>{})},[e,t])}}var Ml={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 wj(e,t,s){const n=s?.defaultSpeed??.5,o=s?.pulseMs??250,a=s?.enabled??!0,i=dr(e,a?t:null)?.ptz,[l,u]=(0,h.useState)([]),[d,f]=(0,h.useState)(!1),[m,g]=(0,h.useState)(null),b=(0,h.useCallback)(async()=>{if(!(!a||!i))try{u(await i.getPresets({}))}catch(v){const w=v instanceof Error?v.message:String(v);if(w.includes("provider not available")||w.includes("no 'ptz' binding"))return;g(w)}},[i,a]);(0,h.useEffect)(()=>{b()},[b]);const x=(0,h.useCallback)(async v=>{if(!(!a||!i)){g(null),f(!0);try{return await v()}catch(w){g(w instanceof Error?w.message:String(w));return}finally{f(!1)}}},[a,i]);return{move:(0,h.useCallback)(async(v,w)=>{if(!i)return;const y=Ml[v],S=w??n;await x(async()=>{await i.move({pan:y.pan,tilt:y.tilt,speed:S}),await new Promise(k=>setTimeout(k,o)),await i.stop({})})},[i,n,o,x]),startContinuous:(0,h.useCallback)(async(v,w)=>{if(!i)return;const y=Ml[v],S=w??n;await x(()=>i.continuousMove({pan:y.pan,tilt:y.tilt,speed:S}))},[i,n,x]),stopContinuous:(0,h.useCallback)(async()=>{i&&await x(()=>i.stop({}))},[i,x]),zoom:(0,h.useCallback)(async(v,w)=>{if(!i)return;const y=v==="in"?1:-1,S=w??n;await x(async()=>{await i.move({zoom:y,speed:S}),await new Promise(k=>setTimeout(k,o)),await i.stop({})})},[i,n,o,x]),goHome:(0,h.useCallback)(async()=>{i&&await x(()=>i.goHome({}))},[i,x]),goToPreset:(0,h.useCallback)(async v=>{i&&await x(()=>i.goToPreset({presetId:v}))},[i,x]),presets:l,refreshPresets:b,busy:d,error:m}}function Sj(e){const t=e?.deviceId??null,s=e?.historyLimit??20,n=Ks("doorbell.onPressed",t!==null?i=>i.deviceId===t:void 0),[o,a]=(0,h.useState)([]);return(0,h.useEffect)(()=>{n&&a(i=>{if(i.length>0&&i[0].deviceId===n.deviceId&&i[0].timestamp===n.timestamp)return i;const l=[n,...i];return l.length>s?l.slice(0,s):l})},[n,s]),{latest:n??null,history:o}}function kj(e){const t=jt(),s=(0,h.useMemo)(()=>e?JSON.stringify(e):"",[e]),[n,o]=(0,h.useState)(()=>t.listDevices(e));return(0,h.useEffect)(()=>{const a=()=>{o(t.listDevices(e))};a();let i=null,l=null;try{i=t.onDeviceAdded(a),l=t.onDeviceRemoved(a)}catch{}const u=t.subscribeConnectionEvents(d=>{d==="connected"&&a()});return()=>{i?.(),l?.(),u()}},[t,e,s]),n}function jj(e){const t=jt(),[s,n]=(0,h.useState)(()=>e===null?null:t.getDevice(e));return(0,h.useEffect)(()=>{if(e===null){n(null);return}const o=()=>{n(t.getDevice(e))};o();let a=null,i=null;try{a=t.onDeviceAdded(o),i=t.onDeviceRemoved(o)}catch{}const l=t.subscribeConnectionEvents(u=>{u==="connected"&&o()});return()=>{a?.(),i?.(),l()}},[t,e]),s}function Nj(e,t,s){const n=jt();return(0,Ae.useQuery)({queryKey:e,queryFn:()=>t(n)(),...s})}function Cj(e,t){const s=jt();return(0,Ae.useMutation)({mutationFn:n=>e(s)(n),...t})}function Mj(e,t){const s=jt(),n=(0,Ae.useQueryClient)(),[o,a]=(0,h.useState)(s.connectionVersion);(0,h.useEffect)(()=>s.subscribeConnectionEvents((u,d)=>{u==="connected"&&a(d)}),[s]);const i=t.join("|"),l=JSON.stringify(e);(0,h.useEffect)(()=>{const u=[],d=()=>{const f=JSON.parse(l),m=f.length===1&&Array.isArray(f[0])?f:[f];n.invalidateQueries({queryKey:m})};d();for(const f of i.split("|"))if(f)try{u.push(s.subscribeEvent(f,d))}catch{}return()=>{for(const f of u)f()}},[s,n,i,l,o])}c.AddonGlobalSettingsForm=nk,c.AgentStepEditor=im,c.AppShell=Dm,c.AudioClassificationList=Ek,c.AudioLevelWaveform=Nk,c.AudioWaveform=jk,c.BTN_COMPACT=Rc,c.BTN_COMPACT_DANGER=Tc,c.BTN_COMPACT_PRIMARY=Dc,c.BTN_COMPACT_WARNING=Ic,c.Badge=Gt,c.BatteryBadge=hi,c.BottomSheet=Qs,c.Breadcrumb=Kf,c.Button=lr,c.CHIP_ACTIVE=_c,c.CHIP_BASE=Oc,c.CHIP_INACTIVE=$c,c.CLASS_COLORS=fr,c.CameraStreamPlayer=hl,c.Card=$s,c.Checkbox=va,c.CodeBlock=Pm,c.CollapsibleCard=ga,c.ConfigFormBuilder=fl,c.ConfigFormField=Qt,c.ConfigSchemaField=Fr,c.ConfirmActionButton=sj,c.ConfirmDialogProvider=Mm,c.CustomFieldRenderersProvider=Rh,c.DEFAULT_COLOR=Op,c.DataTable=Zf,c.DetectionCanvas=_p,c.DetectionOverlay=pl,c.DetectionResultTree=Fp,c.DevShell=qi,c.DeviceActivityPanel=rj,c.DeviceCard=Im,c.DeviceContextProvider=Dh,c.DeviceGrid=Lm,c.DeviceItem=Ur,c.DeviceList=Np,c.Dialog=ka,c.DialogContent=Fs,c.DialogDescription=Ma,c.DialogFooter=Na,c.DialogHeader=ja,c.DialogTitle=Ca,c.DialogTrigger=If,c.DiscoveryPanel=Wk,c.DoorbellRecentPanel=lj,c.Dropdown=Of,c.DropdownContent=$f,c.DropdownItem=Gf,c.DropdownTrigger=_f,c.EmptyState=Cm,c.EventStream=kn,c.FilterBar=Rm,c.FloatingEventStream=Hk,c.FloatingLogStream=Lk,c.FloatingPanel=qf,c.FormField=jm,c.GRID_GAP=yc,c.GRID_PAIRED=kc,c.GRID_QUICK_STATS=Sc,c.INPUT_COMPACT=Lc,c.IconButton=_s,c.ImageSelector=Vp,c.InferenceConfigSelector=Wp,c.Input=$r,c.KebabMenu=cj,c.KeyValueList=Am,c.LIST_ROW=wc,c.Label=Gs,c.LogStream=vn,c.LoginForm=Vi,c.MobileDrawer=Qa,c.NodeMultiSelectField=il,c.NodePicker=bm,c.NodeSelectField=al,c.PHASE_CONFIG=cs,c.PTZOverlay=nj,c.PageHeader=Nm,c.PhaseIcon=Rk,c.PipelineBuilder=Lp,c.PipelineRuntimeSelector=Dp,c.PipelineStep=Br,c.PipelineTreeMatrix=pm,c.PlayerOverlaysProvider=fk,c.Popover=$a,c.PopoverContent=Ba,c.PopoverTrigger=Ga,c.ProviderBadge=wm,c.ResponseLog=Ak,c.SECTION_BODY=xc,c.SECTION_CARD=gc,c.SECTION_HEADER=bc,c.SPLIT_PANEL_OUTER=jc,c.SPLIT_PANEL_SIDE=Nc,c.STACK_GAP=vc,c.ScopePicker=pj,c.ScrollArea=Us,c.Select=Gr,c.SemanticBadge=Ya,c.Separator=Bs,c.Sidebar=Ys,c.SidebarItem=Zs,c.Skeleton=ba,c.SlideOverPanel=Yf,c.SnapshotButton=aj,c.StatCard=Em,c.StateValuesStream=jl,c.StatusBadge=vm,c.StepTimings=Hp,c.StepTreeMaster=Jf,c.StreamPanel=Sk,c.Switch=ya,c.SystemProvider=Za,c.TEXT_FIELD_LABEL=Mc,c.TEXT_HINT=Ec,c.TEXT_METRIC=Pc,c.TEXT_SECTION_LABEL=Cc,c.TEXT_VALUE=Ac,c.Tabs=Uf,c.TabsContent=Wf,c.TabsList=Hf,c.TabsTrigger=Vf,c.ThemeProvider=Ge.ThemeProvider$1,c.Tooltip=Bf,c.TooltipContent=zf,c.TooltipTrigger=Ff,c.VersionBadge=km,c.WidgetRegistryProvider=xS,c.WidgetSlot=ol,c.ZoneEditingProvider=gj,c.__toESM=Qe,c.buildStepTreeFromSchema=em,c.cn=j,c.createSharedContext=at,c.createTheme=Ge.createTheme$1,c.darkColors=Ge.darkColors$1,c.defaultTheme=Ge.defaultTheme$1,c.deriveDeviceKind=_m,c.ensureMfHostInit=zo,c.getClassColor=_e,c.getPhaseVisual=us,c.isFieldVisible=dl,c.lightColors=Ge.lightColors$1,c.mirror=Qc,c.mountAddonPage=Ph,c.providerIcons=Mf,c.statusIcons=Ef,c.themeToCss=Ge.themeToCss$1,c.trpc=p,c.useAccessoriesGetStatus=Ih,c.useAddonPagesListPages=Lh,c.useAddonSettingsGetDeviceSettings=lg,c.useAddonSettingsGetGlobalSettings=ag,c.useAddonSettingsUpdateDeviceSettings=cg,c.useAddonSettingsUpdateGlobalSettings=ig,c.useAddonWidgetsListWidgets=Ji,c.useAddonsApplyAutoUpdateToAll=sg,c.useAddonsCustom=ng,c.useAddonsForceRefresh=qh,c.useAddonsGetAddonAutoUpdate=tg,c.useAddonsGetAutoUpdateSettings=Jh,c.useAddonsGetLogs=Oh,c.useAddonsGetVersions=Zh,c.useAddonsInstallFromWorkspace=Gh,c.useAddonsInstallPackage=$h,c.useAddonsIsWorkspaceAvailable=Bh,c.useAddonsList=Xi,c.useAddonsListPackages=_h,c.useAddonsListUpdates=Hh,c.useAddonsListWorkspacePackages=Fh,c.useAddonsOnAddonLogs=og,c.useAddonsReloadPackages=Qh,c.useAddonsRestartAddon=Yh,c.useAddonsRestartServer=Kh,c.useAddonsRetryLoad=Xh,c.useAddonsRollbackPackage=Wh,c.useAddonsSearchAvailable=Uh,c.useAddonsSetAddonAutoUpdate=rg,c.useAddonsSetAutoUpdateSettings=eg,c.useAddonsUninstallPackage=zh,c.useAddonsUpdatePackage=Vh,c.useAlertsDismiss=gg,c.useAlertsEmit=ug,c.useAlertsGetUnreadCount=mg,c.useAlertsList=fg,c.useAlertsMarkAllRead=hg,c.useAlertsMarkRead=pg,c.useAlertsUpdate=dg,c.useAllWidgets=vS,c.useAudioAnalysisApplyDeviceSettingsPatch=yg,c.useAudioAnalysisGetDeviceLiveContribution=vg,c.useAudioAnalysisGetDeviceSettingsContribution=xg,c.useAudioAnalysisResolveDeviceSettings=bg,c.useAudioAnalyzerAnalyseChunk=wg,c.useAudioAnalyzerClassify=Sg,c.useAudioAnalyzerDispose=jg,c.useAudioAnalyzerIsReady=kg,c.useAudioAnalyzerReprobeAudioEngine=Ng,c.useAudioCodecCanHandle=Mg,c.useAudioCodecCloseSession=Pg,c.useAudioCodecCreateDecodeSession=Eg,c.useAudioCodecCreateEncodeSession=Ag,c.useAudioCodecFlushEncode=Lg,c.useAudioCodecListActiveSessions=Og,c.useAudioCodecListSupportedCodecs=Cg,c.useAudioCodecPullEncoded=Ig,c.useAudioCodecPullPcm=Dg,c.useAudioCodecPushEncodedFrame=Rg,c.useAudioCodecPushPcm=Tg,c.useAudioMetricsGetCurrentSnapshot=_g,c.useAudioMetricsGetHistory=$g,c.useAuthenticationListProviders=Gg,c.useAuthenticationSetProviderEnabled=Bg,c.useBackupDelete=Wg,c.useBackupGetEntries=Hg,c.useBackupList=Qg,c.useBackupListArchives=qg,c.useBackupListDestinations=Fg,c.useBackupListLocations=Ug,c.useBackupPreviewSchedule=Zg,c.useBackupRestore=Vg,c.useBackupTrigger=zg,c.useBackupUpsertDestinationPolicy=Kg,c.useBatteryGetStatus=Yg,c.useBrightnessGetStatus=Jg,c.useBrightnessSetBrightness=Xg,c.useCameraStreamsGetBrokerStreams=t0,c.useCameraStreamsGetCameraStreams=e0,c.useCameraStreamsGetRtspEntries=r0,c.useClusterNodes=zr,c.useConfirm=Qr,c.useCustomFieldRenderer=Zi,c.useDebouncedString=vi,c.useDecoderCreateSession=o0,c.useDecoderDestroySession=a0,c.useDecoderGetInfo=n0,c.useDecoderGetStats=d0,c.useDecoderListActiveSessions=f0,c.useDecoderOpenStream=l0,c.useDecoderPullFrames=c0,c.useDecoderPushPacket=i0,c.useDecoderReprobeHwaccel=m0,c.useDecoderSupportsCodec=s0,c.useDecoderUpdateConfig=u0,c.useDetectionPipelineApplyDeviceSettingsPatch=g0,c.useDetectionPipelineGetDeviceLiveContribution=h0,c.useDetectionPipelineGetDeviceSettingsContribution=p0,c.useDevShell=Nh,c.useDevice=jj,c.useDeviceBattery=mi,c.useDeviceCapability=Bt,c.useDeviceDetections=vj,c.useDeviceDiscoveryAdoptDevice=v0,c.useDeviceDiscoveryGetStatus=w0,c.useDeviceDiscoveryListDiscovered=b0,c.useDeviceDiscoveryRefreshDiscovery=x0,c.useDeviceDiscoveryReleaseDevice=y0,c.useDeviceId=Yi,c.useDeviceManagerAddLocation=T0,c.useDeviceManagerAdoptDevice=ib,c.useDeviceManagerAllocateDeviceId=S0,c.useDeviceManagerCreateDevice=cb,c.useDeviceManagerDisable=H0,c.useDeviceManagerDiscoverDevices=ab,c.useDeviceManagerEnable=U0,c.useDeviceManagerGetAllBindings=Y0,c.useDeviceManagerGetBindings=Z0,c.useDeviceManagerGetChildren=G0,c.useDeviceManagerGetConfigSchema=F0,c.useDeviceManagerGetCreationSchema=lb,c.useDeviceManagerGetDevice=$0,c.useDeviceManagerGetDeviceAggregate=sb,c.useDeviceManagerGetDeviceLiveInfoAggregate=rb,c.useDeviceManagerGetDeviceSettingsAggregate=tb,c.useDeviceManagerGetDeviceStatusAggregate=fb,c.useDeviceManagerGetSettingsSchema=z0,c.useDeviceManagerGetStreamProfileMap=W0,c.useDeviceManagerGetStreamSources=B0,c.useDeviceManagerListAll=_0,c.useDeviceManagerListBindableCapsForDeviceType=eb,c.useDeviceManagerListLocations=D0,c.useDeviceManagerListPersistedByAddon=O0,c.useDeviceManagerListWrappersForCap=J0,c.useDeviceManagerLoadConfig=C0,c.useDeviceManagerLoadMeta=E0,c.useDeviceManagerLoadRuntimeState=M0,c.useDeviceManagerPersistConfig=N0,c.useDeviceManagerProbeStreams=K0,c.useDeviceManagerRegisterDevice=k0,c.useDeviceManagerRemove=V0,c.useDeviceManagerRemoveDevice=j0,c.useDeviceManagerRemoveLocation=I0,c.useDeviceManagerSetDisabled=L0,c.useDeviceManagerSetLocation=P0,c.useDeviceManagerSetMetadata=R0,c.useDeviceManagerSetName=A0,c.useDeviceManagerSetStreamProfileMap=q0,c.useDeviceManagerSetWrapperActive=X0,c.useDeviceManagerTestCreationField=ub,c.useDeviceManagerTestField=db,c.useDeviceManagerUpdateConfig=Q0,c.useDeviceManagerUpdateDeviceField=nb,c.useDeviceManagerUpdateDeviceFieldsBatch=ob,c.useDeviceOpsGetConfigEntries=pb,c.useDeviceOpsGetSettingsSchema=bb,c.useDeviceOpsGetStreamSources=mb,c.useDeviceOpsRemoveDevice=gb,c.useDeviceOpsSetConfig=hb,c.useDeviceProviderAdoptDiscoveredDevice=jb,c.useDeviceProviderCreateDevice=Mb,c.useDeviceProviderDiscoverDevices=kb,c.useDeviceProviderGetChildCreationSchema=Cb,c.useDeviceProviderGetDevices=wb,c.useDeviceProviderGetStatus=yb,c.useDeviceProviderStart=xb,c.useDeviceProviderStop=vb,c.useDeviceProviderSupportsDiscovery=Sb,c.useDeviceProviderSupportsManualCreation=Nb,c.useDeviceProviderTestCreationField=Eb,c.useDeviceProxy=dr,c.useDeviceSnapshot=Th,c.useDeviceSnapshotImage=pi,c.useDeviceState=Ja,c.useDeviceStateGetAllSnapshots=Rb,c.useDeviceStateGetCapSlice=Pb,c.useDeviceStateGetSnapshot=Ab,c.useDeviceStateSetCapSlice=Db,c.useDeviceStateSlice=Xs,c.useDeviceWebrtc=yj,c.useDevices=kj,c.useDoorbellEvents=Sj,c.useDoorbellGetStatus=Tb,c.useEventInvalidation=Mj,c.useEventStreamLatest=Ks,c.useEventStreamMap=gm,c.useEventsGetEventClipUrl=Ob,c.useEventsGetEventThumbnail=Lb,c.useEventsGetEvents=Ib,c.useIntegrationsCreate=Bb,c.useIntegrationsDelete=zb,c.useIntegrationsGet=$b,c.useIntegrationsGetAvailableTypes=Hb,c.useIntegrationsGetByAddonId=Gb,c.useIntegrationsGetSettings=Qb,c.useIntegrationsList=_b,c.useIntegrationsSetSettings=Ub,c.useIntegrationsTestConnection=Vb,c.useIntegrationsUpdate=Fb,c.useIntercomGetStatus=Zb,c.useIntercomHandleAnswer=qb,c.useIntercomStartSession=Wb,c.useIntercomStopSession=Kb,c.useIsMidWidth=Qf,c.useIsMobile=cr,c.useLiveBuffer=Ct,c.useLiveEvent=ur,c.useLocalNetworkGetAllowedAddresses=ex,c.useLocalNetworkGetConnectionEndpoints=Jb,c.useLocalNetworkGetPreferred=Xb,c.useLocalNetworkList=Yb,c.useLocalNetworkResetAllowlistToBestMatch=rx,c.useLocalNetworkSetAllowedAddresses=tx,c.useMeshOrchestratorJoinProvider=nx,c.useMeshOrchestratorLeaveProvider=ox,c.useMeshOrchestratorListProviders=sx,c.useMetricsProviderCollectSnapshot=ax,c.useMetricsProviderGetAddonStats=px,c.useMetricsProviderGetCached=ix,c.useMetricsProviderGetCpuTemperature=dx,c.useMetricsProviderGetCurrent=lx,c.useMetricsProviderGetDiskSpace=cx,c.useMetricsProviderGetGpuInfo=ux,c.useMetricsProviderGetProcessStats=fx,c.useMetricsProviderKillProcess=gx,c.useMetricsProviderListAddonInstances=mx,c.useMetricsProviderListNodeProcesses=hx,c.useMotionDetectionAnalyze=vx,c.useMotionDetectionApplyDeviceSettingsPatch=jx,c.useMotionDetectionGetDeviceLiveContribution=kx,c.useMotionDetectionGetDeviceSettingsContribution=Sx,c.useMotionDetectionRemoveCamera=yx,c.useMotionDetectionReset=wx,c.useMotionGetStatus=xx,c.useMotionIsDetected=bx,c.useMotionTriggerGetStatus=Cx,c.useMotionTriggerSetMotionTrigger=Nx,c.useNativeObjectDetectionGetStatus=Mx,c.useNetworkQualityGetAllStats=Ax,c.useNetworkQualityGetDeviceStats=Ex,c.useNetworkQualityReportClientStats=Px,c.useNodesClusterAddonStatus=Gx,c.useNodesDeployAddon=Dx,c.useNodesExecuteQuery=Fx,c.useNodesRenameNode=$x,c.useNodesRestartAddon=Ix,c.useNodesRestartNode=Ox,c.useNodesRestartProcess=Lx,c.useNodesSetProcessLogLevel=Bx,c.useNodesShutdownNode=_x,c.useNodesTopology=Rx,c.useNodesUndeployAddon=Tx,c.useNotificationOutputSend=zx,c.useNotificationOutputSendTest=Qx,c.useOptionalSystem=hm,c.useOptionalWidgetRegistry=nl,c.useOsdGetStatus=Hx,c.useOsdSetOverlay=Ux,c.usePTZ=wj,c.usePipelineAnalyticsApplyDeviceSettingsPatch=sv,c.usePipelineAnalyticsClearTracks=Kx,c.usePipelineAnalyticsGetActiveTracks=Vx,c.usePipelineAnalyticsGetAudioEvents=Xx,c.usePipelineAnalyticsGetDeviceLiveContribution=rv,c.usePipelineAnalyticsGetDeviceSettingsContribution=tv,c.usePipelineAnalyticsGetEventMedia=Jx,c.usePipelineAnalyticsGetMotionEvents=Zx,c.usePipelineAnalyticsGetObjectEvents=Yx,c.usePipelineAnalyticsGetTrack=Wx,c.usePipelineAnalyticsGetTrackMedia=ev,c.usePipelineAnalyticsListTracks=qx,c.usePipelineExecutorCacheFrameInPool=Nv,c.usePipelineExecutorDeleteModel=wv,c.usePipelineExecutorDeleteTemplate=bv,c.usePipelineExecutorDetect=Sv,c.usePipelineExecutorDownloadModel=yv,c.usePipelineExecutorGetAddonModels=vv,c.usePipelineExecutorGetAudioCapabilities=Ov,c.usePipelineExecutorGetAvailableEngines=nv,c.usePipelineExecutorGetCapabilities=xv,c.usePipelineExecutorGetDefaultSteps=av,c.usePipelineExecutorGetDetectionConfigSchema=$v,c.usePipelineExecutorGetEffectiveTuning=Ev,c.usePipelineExecutorGetGlobalPipelineConfig=fv,c.usePipelineExecutorGetGlobalSteps=dv,c.usePipelineExecutorGetOrchestratorConfigSchema=mv,c.usePipelineExecutorGetReferenceAudio=Lv,c.usePipelineExecutorGetReferenceAudioFiles=Iv,c.usePipelineExecutorGetReferenceImage=Tv,c.usePipelineExecutorGetSchema=uv,c.usePipelineExecutorGetSelectedEngine=ov,c.usePipelineExecutorGetVideoPipelineSteps=lv,c.usePipelineExecutorInferCached=Cv,c.usePipelineExecutorKillEngine=Rv,c.usePipelineExecutorListLoadedEngines=Av,c.usePipelineExecutorListReferenceImages=Dv,c.usePipelineExecutorListTemplates=pv,c.usePipelineExecutorReprobeEngine=iv,c.usePipelineExecutorRunAudioTest=_v,c.usePipelineExecutorRunPipeline=kv,c.usePipelineExecutorRunPipelineBatch=jv,c.usePipelineExecutorSaveTemplate=hv,c.usePipelineExecutorSetVideoPipelineSteps=cv,c.usePipelineExecutorSpinEngine=Pv,c.usePipelineExecutorUncacheFrame=Mv,c.usePipelineExecutorUpdateTemplate=gv,c.usePipelineOrchestratorApplyDeviceSettingsPatch=yy,c.usePipelineOrchestratorAssignAudio=Xv,c.usePipelineOrchestratorAssignDecoder=Kv,c.usePipelineOrchestratorAssignPipeline=Gv,c.usePipelineOrchestratorDeleteTemplate=by,c.usePipelineOrchestratorGetAgentLoad=Uv,c.usePipelineOrchestratorGetAgentSettings=ny,c.usePipelineOrchestratorGetAudioAssignment=ey,c.usePipelineOrchestratorGetAudioAssignments=ry,c.usePipelineOrchestratorGetAudioNodeLoad=ty,c.usePipelineOrchestratorGetCameraMetrics=Vv,c.usePipelineOrchestratorGetCameraSettings=ly,c.usePipelineOrchestratorGetCameraStepOverrides=uy,c.usePipelineOrchestratorGetCapabilityBindings=Wv,c.usePipelineOrchestratorGetDecoderAssignment=sy,c.usePipelineOrchestratorGetDecoderAssignments=Yv,c.usePipelineOrchestratorGetDeviceLiveContribution=vy,c.usePipelineOrchestratorGetDeviceSettingsContribution=xy,c.usePipelineOrchestratorGetGlobalMetrics=Hv,c.usePipelineOrchestratorGetPipelineAssignment=Qv,c.usePipelineOrchestratorGetPipelineAssignments=zv,c.usePipelineOrchestratorListAgentSettings=oy,c.usePipelineOrchestratorListTemplates=py,c.usePipelineOrchestratorRebalance=Fv,c.usePipelineOrchestratorRemoveAgentSettings=iy,c.usePipelineOrchestratorResolvePipeline=my,c.usePipelineOrchestratorSaveTemplate=hy,c.usePipelineOrchestratorSetAgentAddonDefaults=ay,c.usePipelineOrchestratorSetCameraPipelineForAgent=fy,c.usePipelineOrchestratorSetCameraStepOverride=dy,c.usePipelineOrchestratorSetCameraStepToggle=cy,c.usePipelineOrchestratorSetCapabilityBinding=qv,c.usePipelineOrchestratorUnassignAudio=Jv,c.usePipelineOrchestratorUnassignDecoder=Zv,c.usePipelineOrchestratorUnassignPipeline=Bv,c.usePipelineOrchestratorUpdateTemplate=gy,c.usePipelineRunnerAttachCamera=wy,c.usePipelineRunnerDetachCamera=Sy,c.usePipelineRunnerGetAllCameraMetrics=My,c.usePipelineRunnerGetCameraMetrics=Cy,c.usePipelineRunnerGetLocalCameras=Ey,c.usePipelineRunnerGetLocalLoad=jy,c.usePipelineRunnerGetLocalMetrics=Ny,c.usePipelineRunnerReportMotion=ky,c.usePlatformProbeGetCapabilities=Ay,c.usePlatformProbeGetHardware=Py,c.usePlatformProbeResolveHwAccel=Dy,c.usePlatformProbeResolveInferenceConfig=Ry,c.usePlayerOverlayLayer=pk,c.usePlayerOverlayLayers=mk,c.usePlayerToolbarButton=hk,c.usePlayerToolbarButtons=bl,c.usePtzAutotrackGetSettings=Qy,c.usePtzAutotrackGetStatus=Fy,c.usePtzAutotrackSetEnabled=zy,c.usePtzAutotrackSetSettings=Uy,c.usePtzContinuousMove=Iy,c.usePtzGetPosition=Gy,c.usePtzGetPresets=Oy,c.usePtzGetStatus=By,c.usePtzGoHome=$y,c.usePtzGoToPreset=_y,c.usePtzMove=Ty,c.usePtzStop=Ly,c.useRebootReboot=Hy,c.useRecordingEngineDisable=Yy,c.useRecordingEngineEnable=Zy,c.useRecordingEngineEstimateGlobalStorage=o1,c.useRecordingEngineEstimateStorage=n1,c.useRecordingEngineGetAvailability=s1,c.useRecordingEngineGetConfig=Xy,c.useRecordingEngineGetMotionStats=f1,c.useRecordingEngineGetPlaylist=e1,c.useRecordingEngineGetPolicy=l1,c.useRecordingEngineGetPolicyStatus=c1,c.useRecordingEngineGetRetentionConfig=u1,c.useRecordingEngineGetSegments=r1,c.useRecordingEngineGetStatus=Ky,c.useRecordingEngineGetStorageUsage=a1,c.useRecordingEngineGetThumbnail=t1,c.useRecordingEngineSetPolicy=i1,c.useRecordingEngineUpdateConfig=Jy,c.useRecordingEngineUpdateRetentionConfig=d1,c.useRecordingGetPlaybackUrl=Wy,c.useRecordingGetSegments=Vy,c.useRecordingGetThumbnailAt=qy,c.useRemoteAccessListProviders=m1,c.useRemoteAccessStartProvider=p1,c.useRemoteAccessStopProvider=h1,c.useSettingsStoreCount=S1,c.useSettingsStoreDeclareCollection=j1,c.useSettingsStoreDelete=w1,c.useSettingsStoreGet=g1,c.useSettingsStoreInsert=v1,c.useSettingsStoreIsEmpty=k1,c.useSettingsStoreQuery=x1,c.useSettingsStoreSet=b1,c.useSettingsStoreUpdate=y1,c.useSnapshotApplyDeviceSettingsPatch=P1,c.useSnapshotGetDeviceLiveContribution=A1,c.useSnapshotGetDeviceSettingsContribution=E1,c.useSnapshotGetSnapshot=N1,c.useSnapshotGetStatus=M1,c.useSnapshotInvalidateCache=C1,c.useSnapshotProviderGetSnapshot=D1,c.useSnapshotProviderSupportsDevice=R1,c.useStorageAbortUpload=Q1,c.useStorageBeginDownload=U1,c.useStorageBeginUpload=B1,c.useStorageDelete=$1,c.useStorageDeleteLocation=Z1,c.useStorageEndDownload=V1,c.useStorageExists=O1,c.useStorageFinalizeUpload=z1,c.useStorageGetAvailableSpace=G1,c.useStorageGetDefaultLocation=q1,c.useStorageList=_1,c.useStorageListLocations=W1,c.useStorageListProviders=X1,c.useStorageRead=L1,c.useStorageReadChunk=H1,c.useStorageResolve=T1,c.useStorageTestConfig=J1,c.useStorageTestLocation=Y1,c.useStorageUpsertLocation=K1,c.useStorageWrite=I1,c.useStorageWriteChunk=F1,c.useStreamBrokerApplyDeviceSettingsPatch=Sw,c.useStreamBrokerAssignProfile=rw,c.useStreamBrokerGetAllRtspEntries=hw,c.useStreamBrokerGetBroker=dw,c.useStreamBrokerGetBrokerStats=aw,c.useStreamBrokerGetDeviceLiveContribution=ww,c.useStreamBrokerGetDeviceSettingsContribution=yw,c.useStreamBrokerGetPreBufferInfo=mw,c.useStreamBrokerGetRtspEntry=gw,c.useStreamBrokerGetRtspPort=pw,c.useStreamBrokerGetStreamUrl=uw,c.useStreamBrokerIsRtspEnabled=vw,c.useStreamBrokerKillClient=lw,c.useStreamBrokerListAllCameraStreams=nw,c.useStreamBrokerListAllProfileSlots=ow,c.useStreamBrokerListClients=iw,c.useStreamBrokerPublishCameraStream=ew,c.useStreamBrokerRegenerateRtspToken=bw,c.useStreamBrokerRestartProfile=cw,c.useStreamBrokerRetractCameraStream=tw,c.useStreamBrokerSetPreBufferDuration=fw,c.useStreamBrokerSetRtspEnabled=xw,c.useStreamBrokerUnassignProfile=sw,c.useSwitchGetStatus=jw,c.useSwitchSetState=kw,c.useSystem=jt,c.useSystemFeatureFlags=Mw,c.useSystemForceRetentionCleanup=Rw,c.useSystemGetRetentionConfig=Aw,c.useSystemHealth=Cw,c.useSystemInfo=Nw,c.useSystemMutation=Cj,c.useSystemNetworkAddresses=Ew,c.useSystemQuery=Nj,c.useSystemSetRetentionConfig=Pw,c.useThemeMode=Ge.useThemeMode$1,c.useToastOnToast=Dw,c.useTurnOrchestratorGetAllServers=Iw,c.useTurnOrchestratorListProviders=Tw,c.useTurnOrchestratorSetProviderEnabled=Lw,c.useTurnProviderGetTurnServers=Ow,c.useUserManagementCreateApiKey=Hw,c.useUserManagementCreateScopedToken=qw,c.useUserManagementCreateUser=$w,c.useUserManagementDeleteUser=Bw,c.useUserManagementListApiKeys=Uw,c.useUserManagementListScopedTokens=Yw,c.useUserManagementListUsers=_w,c.useUserManagementResetPassword=Fw,c.useUserManagementRevokeApiKey=Vw,c.useUserManagementRevokeScopedToken=Kw,c.useUserManagementSetUserScopes=zw,c.useUserManagementUpdateUser=Gw,c.useUserManagementValidateApiKey=Ww,c.useUserManagementValidateCredentials=Qw,c.useUserManagementValidateScopedToken=Zw,c.useWebrtcSessionCloseSession=tS,c.useWebrtcSessionCreateSession=Jw,c.useWebrtcSessionHandleAnswer=eS,c.useWebrtcSessionHasAdaptiveBitrate=rS,c.useWebrtcSessionListStreams=Xw,c.useWidget=rl,c.useWidgetMetadata=sl,c.useWidgetRegistry=Zr,c.useZoneAnalyticsGetCameraHistory=oS,c.useZoneAnalyticsGetCurrentSnapshot=sS,c.useZoneAnalyticsGetUnzonedHistory=aS,c.useZoneAnalyticsGetZoneHistory=nS,c.useZoneEditing=bj,c.useZoneRulesListRules=iS,c.useZoneRulesSetRules=lS,c.useZonesAddZone=uS,c.useZonesListZones=cS,c.useZonesRemoveZone=dS,c.useZonesUpdateZone=fS,c.validateScopes=hj})(En)),En}var Il=Tl();const Fj=Pj(Il),Xj=$j({__proto__:null,default:Fj},[Il]);export{Xj as i};