@camstack/addon-admin-ui 1.2.529 → 1.2.530

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/assets/{Addons-CZ_5JUVc.js → Addons-DRU_qk60.js} +1 -1
  3. package/dist/assets/{AdminSectionedPage-B_tSbkIV.js → AdminSectionedPage-Dv8ahC-U.js} +1 -1
  4. package/dist/assets/{AiProfiles-W2ByefcY.js → AiProfiles-BJrqkjtX.js} +1 -1
  5. package/dist/assets/{Build-BesaIcQt.js → Build-DTcg9gkb.js} +1 -1
  6. package/dist/assets/{Calendars-PHb_rEbJ.js → Calendars-x_EpS-cd.js} +1 -1
  7. package/dist/assets/{Cluster-CnMcgkaB.js → Cluster-aj2_8TZC.js} +1 -1
  8. package/dist/assets/{ComposedDeviceEditDialog-DlxMQhZP.js → ComposedDeviceEditDialog-DNGwDK80.js} +1 -1
  9. package/dist/assets/{CompositionBlockEditor-Ctx6d-qx.js → CompositionBlockEditor-O3eDPOLD.js} +1 -1
  10. package/dist/assets/{CompositionEditorPage-CVp1OM-C.js → CompositionEditorPage-D09wEj7N.js} +1 -1
  11. package/dist/assets/{Data-OpXlBhEa.js → Data-D4Sz8Rl9.js} +1 -1
  12. package/dist/assets/{DeviceDetail-CUzPIb4E.js → DeviceDetail-BE-C2aGY.js} +1 -1
  13. package/dist/assets/{Devices-DFfVPHVt.js → Devices-BBsDc0QJ.js} +1 -1
  14. package/dist/assets/{History-BLJJzgUt.js → History-TMZn0v_I.js} +1 -1
  15. package/dist/assets/{Identity-B_TiHuO-.js → Identity-DNIHuEKY.js} +1 -1
  16. package/dist/assets/{IntegrationDetail-DtTxTigM.js → IntegrationDetail-CYhU0hEL.js} +1 -1
  17. package/dist/assets/{IntegrationHub-BvDB6bjh.js → IntegrationHub-DviGnYgu.js} +1 -1
  18. package/dist/assets/{Integrations-CK3qys8g.js → Integrations-9bupF3uw.js} +1 -1
  19. package/dist/assets/{Integrations-Xub2OY5T.js → Integrations-B7okjAJ8.js} +1 -1
  20. package/dist/assets/{Library-CO10lVu2.js → Library-BHn4Iifg.js} +1 -1
  21. package/dist/assets/{Locations-CaL7Y2a3.js → Locations-BVaRTbq0.js} +1 -1
  22. package/dist/assets/{Logs-Bu40SOPP.js → Logs-DI7IZGug.js} +1 -1
  23. package/dist/assets/{MyAccess-CNQzuYsW.js → MyAccess-YiGVb3gF.js} +1 -1
  24. package/dist/assets/{Network-BBm6sZIX.js → Network-ZYEqAiF5.js} +1 -1
  25. package/dist/assets/{NodeAddonsSettingsPanel-DZwxKBXw.js → NodeAddonsSettingsPanel-Chb7RIE6.js} +1 -1
  26. package/dist/assets/{Notifications-BS4cbFH2.js → Notifications-DrVDMEuK.js} +1 -1
  27. package/dist/assets/{Pipeline-BhNYn1U-.js → Pipeline-BT9k34b_.js} +1 -1
  28. package/dist/assets/{Recordings-B8VQL_Ik.js → Recordings-Dl-l1Vzi.js} +1 -1
  29. package/dist/assets/{ScanNetworkModal-SyHjZF2T.js → ScanNetworkModal-Cq9BlXXk.js} +1 -1
  30. package/dist/assets/{SessionsList-BD87Vhfu.js → SessionsList-84zwfhuD.js} +1 -1
  31. package/dist/assets/{Showroom-BS88iBLb.js → Showroom-Crq5JUKV.js} +1 -1
  32. package/dist/assets/{System-D-Xj3jc0.js → System-CfurcyNZ.js} +1 -1
  33. package/dist/assets/{Terminal-DhbVA89N.js → Terminal-UyKanKPS.js} +1 -1
  34. package/dist/assets/{device-integration-icon-D-OosuOg.js → device-integration-icon-BpHHi90B.js} +1 -1
  35. package/dist/assets/{index-DMMw81r0.js → index-DGvsu0ui.js} +2 -2
  36. package/dist/assets/{mf-entry-bootstrap-0-dd19d57d.js → mf-entry-bootstrap-0-3390b09e.js} +1 -1
  37. package/dist/assets/{step-inspector-model-DINPtCNq.js → step-inspector-model-D6NC9QoX.js} +1 -1
  38. package/dist/assets/{useNodeUrlSelection-A-NDcCsx.js → useNodeUrlSelection-DytighTL.js} +1 -1
  39. package/dist/index.html +2 -2
  40. package/dist/server/addon.js +1 -1
  41. package/package.json +4 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-DFfVPHVt.js","./src-KDhMZ5Ob.js","./player-overlays-DpZIxQHp.js","./client-BvflqtP1.js","./__vite-browser-external-BCAtXlNQ.js","./useTranslation-BJr-n0es.js","./AdminPage-DmkuRREx.js","./device-integration-icon-D-OosuOg.js","./useEventInvalidation-2dkiqOI6.js","./Integrations-Xub2OY5T.js","./i18n-Bg2ooh3q.js","./table-2-IUuOvuT8.js","./ScanNetworkModal-SyHjZF2T.js","./FormBuilder-BvQZWKCS.js","./notification-schedule-field-B7FdiF_t.js","./framework-packages-B7oma9J4.js","./IntegrationDetail-DtTxTigM.js","./Trans-Bsz5Pghy.js","./search-x-DE4DxdsF.js","./NodeAddonsSettingsPanel-DZwxKBXw.js","./addon-icons-context-DZZCjo9x.js","./mount-2dkiqOI6.js","./Pipeline-BhNYn1U-.js","./video-D0guHpd1.js","./usb-CFK8z-TS.js","./crop-CZJDrMcX.js","./layers-CFNXRt4j.js","./step-inspector-model-DINPtCNq.js","./board-model-CCD7fB3T.js","./DeviceDetail-CUzPIb4E.js","./archive-Bu9T4BL0.js","./scan-eye-Bv4PGTFl.js","./bell-off-E0Abr7jJ.js","./sigma-CxBVWJ85.js","./boxes-BkzsIUkw.js","./circle-slash-pdaivo-U.js","./file-up-Cyg6A2qN.js","./RemoteGrid-CF92aN64.js","./grip-vertical-CLVyc1HC.js","./CompositionBlockEditor-Ctx6d-qx.js","./use-device-bound-caps-DS4FtJtN.js","./assignment-candidates-DWivr3bV.js","./device-picker-model-2dkiqOI6.js","./ComposedDeviceEditDialog-DlxMQhZP.js","./DeviceDoActionFields-D1rhgn3I.js","./use-stationary-objects-CFLRkxjx.js","./linked-devices-model-D9m6pafu.js","./format-ChSVChsY.js","./authed-media-yW7W_8pm.js","./Showroom-BS88iBLb.js","./EmbedPlayerPage-D0lVyXps.js","./Library-CO10lVu2.js","./user-x-KWsBR0tG.js","./user-round-BSVSJsjB.js","./AdminSectionedPage-B_tSbkIV.js","./use-scenes-feed-CE-KFGxN.js","./Recordings-B8VQL_Ik.js","./scissors-BsEkbrx_.js","./location-owned-usage-DasgH3RR.js","./hard-drive-download-Cd122TYb.js","./format-size-DIxKXxtj.js","./Viewer-BTxcZ-BR.js","./monitor-off-B2GWMMt_.js","./Build-BesaIcQt.js","./variable-BG_qKWYf.js","./CompositionEditorPage-CVp1OM-C.js","./Locations-CaL7Y2a3.js","./speaker-Dy79a571.js","./Addons-CZ_5JUVc.js","./useNodeUrlSelection-A-NDcCsx.js","./AiProfiles-W2ByefcY.js","./send-Dd0BBamd.js","./message-square-plus-rkd_X0vs.js","./MyAccess-CNQzuYsW.js","./key-round-pNw827HU.js","./monitor-smartphone-DJzvbVtx.js","./ruler-C1SbVRl3.js","./unlink-DTu1e00O.js","./SessionsList-BD87Vhfu.js","./sso-popup-BjTl8T6g.js","./Logs-Bu40SOPP.js","./timer-reset-D1H0hoMf.js","./IntegrationHub-BvDB6bjh.js","./settings-2-z3X6U2eo.js","./AddonAssetIcon-B1rn0DLw.js","./addon-display-names-BkwMrExv.js","./Identity-B_TiHuO-.js","./key-D_zqd1r-.js","./Network-BBm6sZIX.js","./Integrations-CK3qys8g.js","./recycle-BWLoavmg.js","./Data-OpXlBhEa.js","./cloud-upload-BIjzjy_K.js","./System-D-Xj3jc0.js","./Cluster-CnMcgkaB.js","./memory-stick-Bt2KoB-0.js","./Terminal-DhbVA89N.js","./Terminal-kHJ-D0s7.css","./Notifications-BS4cbFH2.js","./list-ordered-Dy6tCUD8.js","./History-BLJJzgUt.js","./Calendars-PHb_rEbJ.js","./Templates-D0V7IdcS.js","./shapes-D-IaC6en.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-BBsDc0QJ.js","./src-KDhMZ5Ob.js","./player-overlays-DpZIxQHp.js","./client-BvflqtP1.js","./__vite-browser-external-BCAtXlNQ.js","./useTranslation-BJr-n0es.js","./AdminPage-DmkuRREx.js","./device-integration-icon-BpHHi90B.js","./useEventInvalidation-2dkiqOI6.js","./Integrations-B7okjAJ8.js","./i18n-Bg2ooh3q.js","./table-2-IUuOvuT8.js","./ScanNetworkModal-Cq9BlXXk.js","./FormBuilder-BvQZWKCS.js","./notification-schedule-field-B7FdiF_t.js","./framework-packages-B7oma9J4.js","./IntegrationDetail-CYhU0hEL.js","./Trans-Bsz5Pghy.js","./search-x-DE4DxdsF.js","./NodeAddonsSettingsPanel-Chb7RIE6.js","./addon-icons-context-DZZCjo9x.js","./mount-2dkiqOI6.js","./Pipeline-BT9k34b_.js","./video-D0guHpd1.js","./usb-CFK8z-TS.js","./crop-CZJDrMcX.js","./layers-CFNXRt4j.js","./step-inspector-model-D6NC9QoX.js","./board-model-CCD7fB3T.js","./DeviceDetail-BE-C2aGY.js","./archive-Bu9T4BL0.js","./scan-eye-Bv4PGTFl.js","./bell-off-E0Abr7jJ.js","./sigma-CxBVWJ85.js","./boxes-BkzsIUkw.js","./circle-slash-pdaivo-U.js","./file-up-Cyg6A2qN.js","./RemoteGrid-CF92aN64.js","./grip-vertical-CLVyc1HC.js","./CompositionBlockEditor-O3eDPOLD.js","./use-device-bound-caps-DS4FtJtN.js","./assignment-candidates-DWivr3bV.js","./device-picker-model-2dkiqOI6.js","./ComposedDeviceEditDialog-DNGwDK80.js","./DeviceDoActionFields-D1rhgn3I.js","./use-stationary-objects-CFLRkxjx.js","./linked-devices-model-D9m6pafu.js","./format-ChSVChsY.js","./authed-media-yW7W_8pm.js","./Showroom-Crq5JUKV.js","./EmbedPlayerPage-D0lVyXps.js","./Library-BHn4Iifg.js","./user-x-KWsBR0tG.js","./user-round-BSVSJsjB.js","./AdminSectionedPage-Dv8ahC-U.js","./use-scenes-feed-CE-KFGxN.js","./Recordings-Dl-l1Vzi.js","./scissors-BsEkbrx_.js","./location-owned-usage-DasgH3RR.js","./hard-drive-download-Cd122TYb.js","./format-size-DIxKXxtj.js","./Viewer-BTxcZ-BR.js","./monitor-off-B2GWMMt_.js","./Build-DTcg9gkb.js","./variable-BG_qKWYf.js","./CompositionEditorPage-D09wEj7N.js","./Locations-BVaRTbq0.js","./speaker-Dy79a571.js","./Addons-DRU_qk60.js","./useNodeUrlSelection-DytighTL.js","./AiProfiles-BJrqkjtX.js","./send-Dd0BBamd.js","./message-square-plus-rkd_X0vs.js","./MyAccess-YiGVb3gF.js","./key-round-pNw827HU.js","./monitor-smartphone-DJzvbVtx.js","./ruler-C1SbVRl3.js","./unlink-DTu1e00O.js","./SessionsList-84zwfhuD.js","./sso-popup-BjTl8T6g.js","./Logs-DI7IZGug.js","./timer-reset-D1H0hoMf.js","./IntegrationHub-DviGnYgu.js","./settings-2-z3X6U2eo.js","./AddonAssetIcon-B1rn0DLw.js","./addon-display-names-BkwMrExv.js","./Identity-DNIHuEKY.js","./key-D_zqd1r-.js","./Network-ZYEqAiF5.js","./Integrations-9bupF3uw.js","./recycle-BWLoavmg.js","./Data-D4Sz8Rl9.js","./cloud-upload-BIjzjy_K.js","./System-CfurcyNZ.js","./Cluster-aj2_8TZC.js","./memory-stick-Bt2KoB-0.js","./Terminal-UyKanKPS.js","./Terminal-kHJ-D0s7.css","./Notifications-DrVDMEuK.js","./list-ordered-Dy6tCUD8.js","./History-TMZn0v_I.js","./Calendars-x_EpS-cd.js","./Templates-D0V7IdcS.js","./shapes-D-IaC6en.js"])))=>i.map(i=>d[i]);
2
2
  import"./virtual_mf-exposes___mfe_internal__admin_ui_host__remoteEntry-_hash_-DnnXQRkG.js";import{a as e,o as t}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-FCSZ5q7m.js";import{t as n}from"./vite-preload-helper-kNaey6uv.js";import{A as r,C as i,D as a,F as o,G as s,H as c,I as l,J as u,K as d,M as f,N as p,P as m,Q as h,R as g,S as _,V as v,X as y,Y as b,Z as x,a as S,d as C,et as w,j as T,k as E,m as D,o as O,u as k,x as A,z as j}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$n as M,Ai as N,Bi as P,Ci as F,Di as ee,Dn as te,Fi as ne,Fn as I,Fr as re,Gi as ie,Gr as ae,Hr as oe,In as se,Kn as ce,Kr as L,Mn as R,Nr as le,Oi as ue,On as de,Pr as fe,Q as z,Qt as pe,St as me,T as he,Tr as ge,Z as _e,Zi as ve,_n as ye,_t as be,an as xe,ar as Se,bi as Ce,bt as we,cr as Te,da as Ee,dn as De,dt as Oe,gn as ke,gt as Ae,hi as je,ht as Me,ia as Ne,ii as Pe,it as Fe,ji as Ie,jr as Le,la as Re,lt as ze,ni as Be,pn as Ve,pr as B,qr as He,rn as Ue,rr as We,rt as Ge,st as Ke,ur as qe,vn as Je,xi as Ye,xr as Xe,yn as Ze,zi as Qe,zt as $e}from"./player-overlays-DpZIxQHp.js";import{Vo as et,Za as tt,a as nt,cr as rt,eo as it,fi as at,ko as ot,o as st,r as ct,so as lt,t as ut}from"./client-BvflqtP1.js";import{_ as dt,a as ft,c as pt,d as mt,f as ht,g as gt,h as _t,i as vt,l as yt,m as bt,n as xt,o as St,p as Ct,r as wt,s as Tt,t as Et,u as Dt}from"./video-D0guHpd1.js";import{$d as Ot,$o as kt,$r as At,Aa as jt,Ao as Mt,Bd as Nt,Cr as Pt,Er as Ft,Et as It,Fr as Lt,Fs as Rt,Ft as zt,Gd as Bt,Gn as Vt,Gr as Ht,Hu as Ut,Io as Wt,Ir as Gt,Jd as Kt,Jn as qt,Jr as Jt,Kd as Yt,Kt as Xt,La as Zt,Lr as Qt,Md as $t,Mo as en,Na as tn,Ni as nn,No as rn,Oa as an,Oi as on,Pa as sn,Pr as V,Qo as cn,Qr as ln,Sr as un,Tr as dn,Ur as fn,Vt as pn,Vu as mn,Wn as hn,Wt as gn,Xd as _n,Xs as vn,Y as yn,Yd as bn,Yr as xn,Yt as Sn,Zd as Cn,Zr as wn,_r as Tn,aa as En,af as Dn,ai as On,as as kn,br as An,ca as jn,d as Mn,dn as Nn,ds as Pn,ei as Fn,es as In,fi as Ln,fn as Rn,gn as zn,h as Bn,hr as Vn,ii as H,is as Hn,ka as Un,ko as Wn,l as Gn,la as Kn,lf as qn,ln as Jn,lr as Yn,md as Xn,mn as Zn,ms as Qn,n as $n,ni as er,oa as tr,os as nr,pn as rr,qi as ir,qn as ar,qr as or,qt as sr,qu as cr,rf as lr,ri as ur,sa as dr,ti as fr,uf as pr,un as mr,us as hr,vn as gr,wr as _r,x as vr,xn as yr,xr as br,xt as xr,yr as Sr,za as Cr,zd as wr,zi as Tr}from"./src-KDhMZ5Ob.js";import{r as Er,t as Dr}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js";import{t as Or}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js";import{t as U}from"./i18n-Bg2ooh3q.js";import{t as kr}from"./Trans-Bsz5Pghy.js";import{t as W}from"./useTranslation-BJr-n0es.js";import{t as Ar}from"./FormBuilder-BvQZWKCS.js";import"./mount-2dkiqOI6.js";import{a as jr,c as Mr,d as Nr,i as Pr,n as Fr,o as Ir,r as Lr,s as Rr,t as zr,u as Br}from"./sso-popup-BjTl8T6g.js";import{n as Vr,t as Hr}from"./addon-icons-context-DZZCjo9x.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})(),w();var Ur=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Wr=/^[\\/]{2}/;function Gr(e,t){return t+e.replace(/\\/g,`/`)}var Kr=`popstate`;function qr(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function Jr(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return Zr(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:Qr(t)}return ei(t,n,null,e)}function G(e,t){if(e===!1||e==null)throw Error(t)}function K(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function Yr(){return Math.random().toString(36).substring(2,10)}function Xr(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Zr(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?$r(t):t,state:n,key:t&&t.key||r||Yr(),mask:i}}function Qr({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function $r(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function ei(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=qr(e)?e:Zr(h.location,e,t);n&&n(r,e),l=u()+1;let d=Xr(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=qr(e)?e:Zr(h.location,e,t);n&&n(r,e),l=u();let i=Xr(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return ti(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(Kr,d),c=e,()=>{i.removeEventListener(Kr,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function ti(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),G(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:Qr(t);return i=i.replace(/ $/,`%20`),!n&&Wr.test(i)&&(i=r+i),new URL(i,r)}function ni(e,t,n=`/`){return ri(e,t,n,!1)}function ri(e,t,n,r,i){let a=Ci((typeof t==`string`?$r(t):t).pathname||`/`,n);if(a==null)return null;let o=i??ai(e),s=null,c=Si(a);for(let e=0;s==null&&e<o.length;++e)s=vi(o[e],c,r);return s}function ii(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function ai(e){let t=oi(e);return ci(t),t}function oi(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;G(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=ji([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(G(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),oi(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:gi(l,e.index),routesMeta:u.map((e,t)=>{let[n,r]=xi(e.relativePath,e.caseSensitive,t===u.length-1);return{...e,matcher:n,compiledParams:r}})})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of si(e.path))a(e,t,!0,n)}),t}function si(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=si(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function ci(e){e.sort((e,t)=>e.score===t.score?_i(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var li=/^:[\w-]+$/,ui=3,di=2,fi=1,pi=10,mi=-2,hi=e=>e===`*`;function gi(e,t){let n=e.split(`/`),r=n.length;return n.some(hi)&&(r+=mi),t&&(r+=di),n.filter(e=>!hi(e)).reduce((e,t)=>e+(li.test(t)?ui:t===``?fi:pi),r)}function _i(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function vi(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u={path:s.relativePath,caseSensitive:s.caseSensitive,end:c},d=s.matcher&&s.compiledParams?bi(u,l,s.matcher,s.compiledParams):yi(u,l),f=s.route;if(!d&&c&&n&&!r[r.length-1].route.index&&(d=yi({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!d)return null;Object.assign(i,d.params),o.push({params:i,pathname:ji([a,d.pathname]),pathnameBase:Ni(ji([a,d.pathnameBase])),route:f}),d.pathnameBase!==`/`&&(a=ji([a,d.pathnameBase]))}return o}function yi(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=xi(e.path,e.caseSensitive,e.end);return bi(e,t,n,r)}function bi(e,t,n,r){let i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function xi(e,t=!1,n=!0){K(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function Si(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return K(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Ci(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}function wi(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?$r(e):e,a;return n?(n=Ai(n),a=n.startsWith(`/`)?Ti(n.substring(1),`/`):Ti(n,t)):a=t,{pathname:a,search:Pi(r),hash:Fi(i)}}function Ti(e,t){let n=Mi(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Ei(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Di(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Oi(e){let t=Di(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function ki(e,t,n,r=!1){let i;typeof e==`string`?i=$r(e):(i={...e},G(!i.pathname||!i.pathname.includes(`?`),Ei(`?`,`pathname`,`search`,i)),G(!i.pathname||!i.pathname.includes(`#`),Ei(`#`,`pathname`,`hash`,i)),G(!i.search||!i.search.includes(`#`),Ei(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=wi(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var Ai=e=>e.replace(/[\\/]{2,}/g,`/`),ji=e=>Ai(e.join(`/`)),Mi=e=>e.replace(/\/+$/,``),Ni=e=>Mi(e).replace(/^\/*/,`/`),Pi=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Fi=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,Ii=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Li(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Ri(e){return ji(e.map(e=>e.route.path).filter(Boolean))||`/`}var zi=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Bi(e,t){let n=e;if(typeof n!=`string`||!Ur.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(zi)try{let e=new URL(window.location.href),r=Wr.test(n)?new URL(Gr(n,e.protocol)):new URL(n),a=Ci(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{K(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Vi=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Vi);var Hi=[`GET`,...Vi];new Set(Hi);var Ui=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function Wi(e){try{return Ui.includes(new URL(e).protocol)}catch{return!1}}var Gi=E(null);Gi.displayName=`DataRouter`;var Ki=E(null);Ki.displayName=`DataRouterState`;var qi=E(!1);function Ji(){return j(qi)}var Yi=E({isTransitioning:!1});Yi.displayName=`ViewTransition`;var Xi=E(new Map);Xi.displayName=`Fetchers`;var Zi=E(null);Zi.displayName=`Await`;var q=E(null);q.displayName=`Navigation`;var Qi=E(null);Qi.displayName=`Location`;var J=E({outlet:null,matches:[],isDataRoute:!1});J.displayName=`Route`;var $i=E(null);$i.displayName=`RouteError`;var ea=`REACT_ROUTER_ERROR`,ta=`REDIRECT`,na=`ROUTE_ERROR_RESPONSE`;function ra(e){if(e.startsWith(`${ea}:${ta}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function ia(e){if(e.startsWith(`${ea}:${na}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new Ii(t.status,t.statusText,t.data)}catch{}}function aa(e,{relative:t}={}){G(oa(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=j(q),{hash:i,pathname:a,search:o}=ha(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:ji([n,a])),r.createHref({pathname:s,search:o,hash:i})}function oa(){return j(Qi)!=null}function Y(){return G(oa(),`useLocation() may be used only in the context of a <Router> component.`),j(Qi).location}function sa(){return j(Qi).navigationType}var ca=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function la(e){j(q).static||s(e)}function ua(){let{isDataRoute:e}=j(J);return e?Pa():da()}function da(){G(oa(),`useNavigate() may be used only in the context of a <Router> component.`);let e=j(Gi),{basename:t,navigator:n}=j(q),{matches:r}=j(J),{pathname:i}=Y(),a=JSON.stringify(Oi(r)),o=u(!1);return la(()=>{o.current=!0}),g((r,s={})=>{if(K(o.current,ca),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=ki(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:ji([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var fa=E(null);function pa(e){let t=j(J).outlet;return d(()=>t&&r(fa.Provider,{value:e},t),[t,e])}function ma(){let{matches:e}=j(J);return e[e.length-1]?.params??{}}function ha(e,{relative:t}={}){let{matches:n}=j(J),{pathname:r}=Y(),i=JSON.stringify(Oi(n));return d(()=>ki(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function ga(e,t){return _a(e,t)}function _a(e,t,n){G(oa(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:i}=j(q),{matches:a}=j(J),o=a[a.length-1],s=o?o.params:{},c=o?o.pathname:`/`,l=o?o.pathnameBase:`/`,u=o&&o.route;{let e=u&&u.path||``;Ia(c,!u||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
3
3
 
4
- Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let d=Y(),f;if(t){let e=typeof t==`string`?$r(t):t;G(l===`/`||e.pathname?.startsWith(l),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${l}" but pathname "${e.pathname}" was given in the \`location\` prop.`),f=e}else f=d;let p=f.pathname||`/`,m=p;if(l!==`/`){let e=l.replace(/^\//,``).split(`/`);m=`/`+p.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let h=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):ni(e,{pathname:m});K(u||h!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),K(h==null||h[h.length-1].route.element!==void 0||h[h.length-1].route.Component!==void 0||h[h.length-1].route.lazy!==void 0,`Matched leaf route at location "${f.pathname}${f.search}${f.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let g=wa(h&&h.map(e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:ji([l,i.encodeLocation?i.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?l:ji([l,i.encodeLocation?i.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),a,n);return t&&g?r(Qi.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...f},navigationType:`POP`}},g):g}function va(){let e=Na(),t=Li(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,i=`rgba(200,200,200, 0.5)`,a={padding:`0.5rem`,backgroundColor:i},o={padding:`2px 4px`,backgroundColor:i},s=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),s=r(c,null,r(`p`,null,`💿 Hey developer 👋`),r(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,r(`code`,{style:o},`ErrorBoundary`),` or`,` `,r(`code`,{style:o},`errorElement`),` prop on your route.`)),r(c,null,r(`h2`,null,`Unexpected Application Error!`),r(`h3`,{style:{fontStyle:`italic`}},t),n?r(`pre`,{style:a},n):null,s)}var ya=r(va,null),ba=class extends o{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=ia(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:r(J.Provider,{value:this.props.routeContext},r($i.Provider,{value:e,children:this.props.component}));return this.context?r(Sa,{error:e},t):t}};ba.contextType=qi;var xa=new WeakMap;function Sa({children:e,error:t}){let{basename:n}=j(q);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=ra(t.digest);if(e){let i=xa.get(t);if(i)throw i;let a=Bi(e.location,n),o=a.absoluteURL||a.to;if(Wi(o))throw Error(`Invalid redirect location`);if(zi&&!xa.get(t))if(a.isExternal||e.reloadDocument)window.location.href=o;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:e.replace}));throw xa.set(t,n),n}return r(`meta`,{httpEquiv:`refresh`,content:`0;url=${o}`})}}return e}function Ca({routeContext:e,match:t,children:n}){let i=j(Gi);return i&&i.static&&i.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=t.route.id),r(J.Provider,{value:e},n)}function wa(e,t=[],n){let i=n?.state;if(e==null){if(!i)return null;if(i.errors)e=i.matches;else if(t.length===0&&!i.initialized&&i.matches.length>0)e=i.matches;else return null}let a=e,o=i?.errors;if(o!=null){let e=a.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);G(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(`,`)}`),a=a.slice(0,Math.min(a.length,e+1))}let s=!1,c=-1;if(n&&i){s=i.renderFallback;for(let e=0;e<a.length;e++){let t=a[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(c=e),t.route.id){let{loaderData:e,errors:r}=i,o=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!r||r[t.route.id]===void 0);if(t.route.lazy||o){n.isStatic&&(s=!0),a=c>=0?a.slice(0,c+1):[a[0]];break}}}}let l=n?.onError,u=i&&l?(e,t)=>{l(e,{location:i.location,params:i.matches?.[0]?.params??{},pattern:Ri(i.matches),errorInfo:t})}:void 0;return a.reduceRight((e,n,l)=>{let d,f=!1,p=null,m=null;i&&(d=o&&n.route.id?o[n.route.id]:void 0,p=n.route.errorElement||ya,s&&(c<0&&l===0?(Ia(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),f=!0,m=null):c===l&&(f=!0,m=n.route.hydrateFallbackElement||null)));let h=t.concat(a.slice(0,l+1)),g=()=>{let t;return t=d?p:f?m:n.route.Component?r(n.route.Component,null):n.route.element?n.route.element:e,r(Ca,{match:n,routeContext:{outlet:e,matches:h,isDataRoute:i!=null},children:t})};return i&&(n.route.ErrorBoundary||n.route.errorElement||l===0)?r(ba,{location:i.location,revalidation:i.revalidation,component:p,error:d,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:u}):g()},null)}function Ta(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ea(e){let t=j(Gi);return G(t,Ta(e)),t}function Da(e){let t=j(Ki);return G(t,Ta(e)),t}function Oa(e){let t=j(J);return G(t,Ta(e)),t}function ka(e){let t=Oa(e),n=t.matches[t.matches.length-1];return G(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Aa(){return ka(`useRouteId`)}function ja(){let e=Da(`useNavigation`);return d(()=>{let{matches:t,historyAction:n,...r}=e.navigation;return r},[e.navigation])}function Ma(){let{matches:e,loaderData:t}=Da(`useMatches`);return d(()=>e.map(e=>ii(e,t)),[e,t])}function Na(){let e=j($i),t=Da(`useRouteError`),n=ka(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Pa(){let{router:e}=Ea(`useNavigate`),t=ka(`useNavigate`),n=u(!1);return la(()=>{n.current=!0}),g(async(r,i={})=>{K(n.current,ca),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var Fa={};function Ia(e,t,n){!t&&!Fa[e]&&(Fa[e]=!0,K(!1,n))}m(La);function La({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return _a(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function X({to:e,replace:t,state:n,relative:r}){G(oa(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=j(q);K(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=j(J),{pathname:o}=Y(),s=ua(),c=ki(e,Oi(a),o,r===`path`),l=JSON.stringify(c);return v(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function Z(e){G(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function Ra({basename:e=`/`,children:t=null,location:n,navigationType:i=`POP`,navigator:a,static:o=!1,useTransitions:s}){G(!oa(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let c=e.replace(/^\/*/,`/`),l=d(()=>({basename:c,navigator:a,static:o,useTransitions:s,future:{}}),[c,a,o,s]);typeof n==`string`&&(n=$r(n));let{pathname:u=`/`,search:f=``,hash:p=``,state:m=null,key:h=`default`,mask:g}=n,_=d(()=>{let e=Ci(u,c);return e==null?null:{location:{pathname:e,search:f,hash:p,state:m,key:h,mask:g},navigationType:i}},[c,u,f,p,m,h,i,g]);return K(_!=null,`<Router basename="${c}"> is not able to match the URL "${u}${f}${p}" because it does not start with the basename, so the <Router> won't render anything.`),_==null?null:r(q.Provider,{value:l},r(Qi.Provider,{children:t,value:_}))}function za({children:e,location:t}){return ga(Ba(e),t)}function Ba(e,t=[]){let n=[];return a.forEach(e,(e,r)=>{if(!f(e))return;let i=[...t,r];if(e.type===c){n.push.apply(n,Ba(e.props.children,i));return}G(e.type===Z,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),G(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=Ba(e.props.children,i)),n.push(a)}),n}var Va=`get`,Ha=`application/x-www-form-urlencoded`;function Ua(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function Wa(e){return Ua(e)&&e.tagName.toLowerCase()===`button`}function Ga(e){return Ua(e)&&e.tagName.toLowerCase()===`form`}function Ka(e){return Ua(e)&&e.tagName.toLowerCase()===`input`}function qa(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ja(e,t){return e.button===0&&(!t||t===`_self`)&&!qa(e)}function Ya(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function Xa(e,t){let n=Ya(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var Za=null;function Qa(){if(Za===null)try{new FormData(document.createElement(`form`),0),Za=!1}catch{Za=!0}return Za}var $a=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function eo(e){return e!=null&&!$a.has(e)?(K(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ha}"`),null):e}function to(e,t){let n,r,i,a,o;if(Ga(e)){let o=e.getAttribute(`action`);r=o?Ci(o,t):null,n=e.getAttribute(`method`)||Va,i=eo(e.getAttribute(`enctype`))||Ha,a=new FormData(e)}else if(Wa(e)||Ka(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?Ci(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||Va,i=eo(e.getAttribute(`formenctype`))||eo(o.getAttribute(`enctype`))||Ha,a=new FormData(o,e),!Qa()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(Ua(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=Va,r=null,i=Ha,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var no={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},ro=/[&><\u2028\u2029]/g;function io(e){return e.replace(ro,e=>no[e])}function ao(e,t){if(e===!1||e==null)throw Error(t)}function oo(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&Ci(i.pathname,t)===`/`?i.pathname=`${Mi(t)}/_root.${r}`:i.pathname=`${Mi(i.pathname)}.${r}`,i}async function so(e,t){if(e.id in t)return t[e.id];try{let r=await n(()=>import(e.module),[],import.meta.url);return t[e.id]=r,r}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function co(e){return e!=null&&typeof e.page==`string`}function lo(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function uo(e,t,n){return go((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await so(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(lo).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function fo(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function po(e,t,{includeHydrateFallback:n}={}){return mo(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function mo(e){return[...new Set(e)]}function ho(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function go(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!co(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(ho(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function _o(){let e=j(Gi);return ao(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function vo(){let e=j(Ki);return ao(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var yo=E(void 0);yo.displayName=`FrameworkContext`;function bo(){let e=j(yo);return ao(e,`You must render this element inside a <HydratedRouter> element`),e}function xo(e,t){let n=j(yo),[r,i]=b(!1),[a,o]=b(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:d,onTouchStart:f}=t,p=u(null);v(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return p.current&&e.observe(p.current),()=>{e.disconnect()}}},[e]),v(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let m=()=>{i(!0)},h=()=>{i(!1),o(!1)};return n?e===`intent`?[a,p,{onFocus:So(s,m),onBlur:So(c,h),onMouseEnter:So(l,m),onMouseLeave:So(d,h),onTouchStart:So(f,m)}]:[a,p,{}]:[!1,p,{}]}function So(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Co({page:e,...t}){let n=Ji(),{nonce:i}=bo(),{router:a}=_o(),o=d(()=>ni(a.routes,e,a.basename),[a.routes,e,a.basename]);return o?(t.nonce==null&&i&&(t={...t,nonce:i}),r(n?To:Eo,{page:e,matches:o,...t})):null}function wo(e){let{manifest:t,routeModules:n}=bo(),[r,i]=b([]);return v(()=>{let r=!1;return uo(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function To({page:e,matches:t,...n}){let i=Y(),{future:a}=bo(),{basename:o}=_o();return r(c,null,d(()=>{if(e===i.pathname+i.search+i.hash)return[];let n=oo(e,o,a.v8_trailingSlashAwareDataRequests,`rsc`),r=!1,s=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?r=!0:s.push(e.route.id);return r&&s.length>0&&n.searchParams.set(`_routes`,s.join(`,`)),[n.pathname+n.search]},[o,a.v8_trailingSlashAwareDataRequests,e,i,t]).map(e=>r(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})))}function Eo({page:e,matches:t,...n}){let i=Y(),{future:a,manifest:o,routeModules:s}=bo(),{basename:l}=_o(),{loaderData:u,matches:f}=vo(),p=d(()=>fo(e,t,f,o,i,`data`),[e,t,f,o,i]),m=d(()=>fo(e,t,f,o,i,`assets`),[e,t,f,o,i]),h=d(()=>{if(e===i.pathname+i.search+i.hash)return[];let n=new Set,r=!1;if(t.forEach(e=>{let t=o.routes[e.route.id];!t||!t.hasLoader||(!p.some(t=>t.route.id===e.route.id)&&e.route.id in u&&s[e.route.id]?.shouldRevalidate||t.hasClientLoader?r=!0:n.add(e.route.id))}),n.size===0)return[];let c=oo(e,l,a.v8_trailingSlashAwareDataRequests,`data`);return r&&n.size>0&&c.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[c.pathname+c.search]},[l,a.v8_trailingSlashAwareDataRequests,u,i,o,p,t,e,s]),g=d(()=>po(m,o),[m,o]),_=wo(m);return r(c,null,h.map(e=>r(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),g.map(e=>r(`link`,{key:e,rel:`modulepreload`,href:e,...n})),_.map(({key:e,link:t})=>r(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function Do(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var Oo=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{Oo&&(window.__reactRouterVersion=`7.18.0`)}catch{}function ko({basename:e,children:t,useTransitions:n,window:i}){let a=u();a.current??=Jr({window:i,v5Compat:!0});let o=a.current,[c,d]=b({action:o.action,location:o.location}),f=g(e=>{n===!1?d(e):l(()=>d(e))},[n]);return s(()=>o.listen(f),[o,f]),r(Ra,{basename:e,children:t,location:c.location,navigationType:c.action,navigator:o,useTransitions:n})}function Ao({basename:e,children:t,history:n,useTransitions:i}){let[a,o]=b({action:n.action,location:n.location}),c=g(e=>{i===!1?o(e):l(()=>o(e))},[i]);return s(()=>n.listen(c),[n,c]),r(Ra,{basename:e,children:t,location:a.location,navigationType:a.action,navigator:n,useTransitions:i})}Ao.displayName=`unstable_HistoryRouter`;var jo=T(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:i,reloadDocument:a,replace:o,mask:s,state:l,target:u,to:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m,...h},g){let{basename:_,navigator:v,useTransitions:y}=j(q),b=typeof d==`string`&&Ur.test(d),x=Bi(d,_);d=x.to;let S=aa(d,{relative:i}),C=Y(),w=null;if(s){let e=ki(s,[],C.mask?C.mask.pathname:`/`,!0);_!==`/`&&(e.pathname=e.pathname===`/`?_:ji([_,e.pathname])),w=v.createHref(e)}let[T,E,D]=xo(n,h),O=Ro(d,{replace:o,mask:s,state:l,target:u,preventScrollReset:f,relative:i,viewTransition:p,defaultShouldRevalidate:m,useTransitions:y});function k(t){e&&e(t),t.defaultPrevented||O(t)}let A=!(x.isExternal||a),M=r(`a`,{...h,...D,href:(A?w:void 0)||x.absoluteURL||S,onClick:A?k:e,ref:Do(g,E),target:u,"data-discover":!b&&t===`render`?`true`:void 0});return T&&!b?r(c,null,M,r(Co,{page:S})):M});jo.displayName=`Link`;var Mo=T(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:i=!1,style:a,to:o,viewTransition:s,children:c,...l},u){let d=ha(o,{relative:l.relative}),f=Y(),p=j(Ki),{navigator:m,basename:h}=j(q),g=p!=null&&Yo(d)&&s===!0,_=m.encodeLocation?m.encodeLocation(d).pathname:d.pathname,v=f.pathname,y=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;t||(v=v.toLowerCase(),y=y?y.toLowerCase():null,_=_.toLowerCase()),y&&h&&(y=Ci(y,h)||y);let b=_!==`/`&&_.endsWith(`/`)?_.length-1:_.length,x=v===_||!i&&v.startsWith(_)&&v.charAt(b)===`/`,S=y!=null&&(y===_||!i&&y.startsWith(_)&&y.charAt(_.length)===`/`),C={isActive:x,isPending:S,isTransitioning:g},w=x?e:void 0,T;T=typeof n==`function`?n(C):[n,x?`active`:null,S?`pending`:null,g?`transitioning`:null].filter(Boolean).join(` `);let E=typeof a==`function`?a(C):a;return r(jo,{...l,"aria-current":w,className:T,ref:u,style:E,to:o,viewTransition:s},typeof c==`function`?c(C):c)});Mo.displayName=`NavLink`;var No=T(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:i,replace:a,state:o,method:s=Va,action:c,onSubmit:u,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m,...h},g)=>{let{useTransitions:_}=j(q),v=Ho(),y=Uo(c,{relative:d}),b=s.toLowerCase()===`get`?`get`:`post`,x=typeof c==`string`&&Ur.test(c);return r(`form`,{ref:g,method:b,action:y,onSubmit:i?u:e=>{if(u&&u(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,i=r?.getAttribute(`formmethod`)||s,c=()=>v(r||e.currentTarget,{fetcherKey:t,method:i,navigate:n,replace:a,state:o,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m});_&&n!==!1?l(()=>c()):c()},...h,"data-discover":!x&&e===`render`?`true`:void 0})});No.displayName=`Form`;function Po({getKey:e,storageKey:t,...n}){let i=j(yo),{basename:a}=j(q),o=Y(),s=Ma();qo({getKey:e,storageKey:t});let c=d(()=>{if(!i||!e)return null;let t=Ko(o,s,a,e);return t===o.key?null:t},[]);if(!i||i.isSpaMode)return null;let l=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return n.nonce==null&&i?.nonce&&(n.nonce=i.nonce),r(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${l})(${io(JSON.stringify(t||Wo))}, ${io(JSON.stringify(c))})`}})}Po.displayName=`ScrollRestoration`;function Fo(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Io(e){let t=j(Gi);return G(t,Fo(e)),t}function Lo(e){let t=j(Ki);return G(t,Fo(e)),t}function Ro(e,{target:t,replace:n,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c,useTransitions:u}={}){let d=ua(),f=Y(),p=ha(e,{relative:o});return g(m=>{if(Ja(m,t)){m.preventDefault();let t=n===void 0?Qr(f)===Qr(p):n,h=()=>d(e,{replace:t,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c});u?l(()=>h()):h()}},[f,d,p,n,r,i,t,e,a,o,s,c,u])}function zo(e){K(typeof URLSearchParams<`u`,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=u(Ya(e)),n=u(!1),r=Y(),i=d(()=>Xa(r.search,n.current?null:t.current),[r.search]),a=ua();return[i,g((e,t)=>{let r=Ya(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var Bo=0,Vo=()=>`__${String(++Bo)}__`;function Ho(){let{router:e}=Io(`useSubmit`),{basename:t}=j(q),n=Aa(),r=e.fetch,i=e.navigate;return g(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=to(e,t);a.navigate===!1?await r(a.fetcherKey||Vo(),n,a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function Uo(e,{relative:t}={}){let{basename:n}=j(q),r=j(J);G(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...ha(e||`.`,{relative:t})},o=Y();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:ji([n,a.pathname])),Qr(a)}var Wo=`react-router-scroll-positions`,Go={};function Ko(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:Ci(e.pathname,n)||e.pathname},t)),i??=e.key,i}function qo({getKey:e,storageKey:t}={}){let{router:n}=Io(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=Lo(`useScrollRestoration`),{basename:a}=j(q),o=Y(),c=Ma(),l=ja();v(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Jo(g(()=>{if(l.state===`idle`){let t=Ko(o,c,a,e);Go[t]=window.scrollY}try{sessionStorage.setItem(t||Wo,JSON.stringify(Go))}catch(e){K(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[l.state,e,a,o,c,t])),typeof document<`u`&&(s(()=>{try{let e=sessionStorage.getItem(t||Wo);e&&(Go=JSON.parse(e))}catch{}},[t]),s(()=>{let t=n?.enableScrollRestoration(Go,()=>window.scrollY,e?(t,n)=>Ko(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),s(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{K(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function Jo(e,t){let{capture:n}=t||{};v(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function Yo(e,{relative:t}={}){let n=j(Yi);G(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Io(`useViewTransitionState`),i=ha(e,{relative:t});if(!n.isTransitioning)return!1;let a=Ci(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Ci(n.nextLocation.pathname,r)||n.nextLocation.pathname;return yi(i.pathname,o)!=null||yi(i.pathname,a)!=null}var Xo=`camstack:broker-oauth`;function Zo(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`camstack:broker-oauth`&&typeof t.ok==`boolean`}function Qo(e,t){return e.split(`{{brokerId}}`).join(encodeURIComponent(t))}function $o(e,t,n=window){let r=n.location.origin,i=!1,a=e=>{i||(i=!0,n.removeEventListener(`message`,o),window.clearInterval(s),t(e))},o=t=>{t.origin!==r||t.source!==e||Zo(t.data)&&a({ok:t.data.ok,...t.data.brokerId===void 0?{}:{brokerId:t.data.brokerId},...t.data.error===void 0?{}:{error:t.data.error}})};n.addEventListener(`message`,o);let s=window.setInterval(()=>{e.closed&&a({ok:!0})},500);return()=>{i=!0,n.removeEventListener(`message`,o),window.clearInterval(s)}}var es={open:e=>Pr(e),assign:e=>window.location.assign(e),watch:(e,t)=>$o(e,t)};function ts(e,t,n=es){let r=z(Mr(e)),i=n.open(r);if(i===null){n.assign(r);return}n.watch(i,e=>{t?.(e)})}function ns(e,t,n){ts(Qo(e,t),n)}function rs(e,t){let n=e=>e.map(e=>e.type===`group`?{...e,fields:n(e.fields)}:e.type===`sub-tabs`?{...e,tabs:e.tabs.map(e=>({...e,fields:n(e.fields)}))}:e.type===`info`&&typeof e.content==`string`?{...e,content:e.content.split(`{{brokerId}}`).join(t)}:e);return{...e,sections:e.sections.map(e=>({...e,fields:n(e.fields)}))}}var is=`broker-advanced`;function as(e){return`key`in e&&typeof e.key==`string`&&`label`in e}function os(e){let t=new Set;for(let n of e){if(!as(n))continue;let e=n.showWhen;if(e===void 0)continue;let r=Array.isArray(e)?e:[e];for(let e of r)typeof e==`object`&&e&&`field`in e&&typeof e.field==`string`&&t.add(e.field)}return t}function ss(e,t,n){return!as(e)||e.showWhen!==void 0||t.has(e.key)?!1:n&&e.filledBySignIn===!0?!0:e.default!==void 0||e.defaultByCountry!==void 0}function cs(e,t){let n=[],r=[];for(let i of e.sections){let e=os(i.fields),a=[];for(let r of i.fields)ss(r,e,t.hasSignIn)?n.push(r):a.push(r);if(a.length>0)r.push({...i,fields:a});else if(i.description!==void 0){let{description:e,...t}=i;r.push({...t,fields:[{type:`info`,key:`${i.id}-note`,label:``,content:e}]})}}return n.length>0&&r.push({id:is,title:t.advancedTitle,style:`accordion`,defaultCollapsed:!0,columns:1,fields:n}),{...e,sections:r}}function ls(e){if(e===void 0)return null;let t=/[-_]([A-Za-z]{2})(?:[-_]|$)/.exec(e);return t?.[1]===void 0?null:t[1].toUpperCase()}function us(e,t,n){if(e===void 0||t===null)return{};let r={};for(let i of e.sections)for(let e of i.fields){if(!as(e)||n[e.key]!==void 0)continue;let i=e.defaultByCountry;i!==void 0&&t in i&&(r[e.key]=i[t])}return r}var ds=[`starting`,`awaiting-login`,`captured`,`error`,`cancelled`],fs=[`awaiting-code`,`captured`,`expired`,`error`,`cancelled`];function ps(e){return typeof e==`object`&&!!e}function ms(e){return ps(e)&&typeof e.sessionId==`string`&&typeof e.loginUrl==`string`}function hs(e){return ps(e)&&typeof e.sessionId==`string`&&typeof e.phase==`string`&&ds.includes(e.phase)}function gs(e){return ps(e)&&typeof e.sessionId==`string`&&typeof e.userCode==`string`&&typeof e.verificationUrl==`string`&&typeof e.expiresAt==`number`}function _s(e){return gs(e)&&ps(e)&&typeof e.phase==`string`&&fs.includes(e.phase)}function vs(e){return ps(e)&&typeof e.brokerId==`string`}function ys(){return{"Content-Type":`application/json`,Authorization:`Bearer ${localStorage.getItem(`camstack_admin_token`)??``}`}}async function bs(e,t){try{return await e.json()}catch{throw Error(`${t} failed: HTTP ${e.status}`)}}function xs(e){let t=ps(e)&&typeof e.error==`string`?e.error:`Unknown error`;return Error(t)}async function Ss(e,t,n){let r=await fetch(z(e),{method:`POST`,headers:ys(),body:JSON.stringify(t)}),i=await bs(r,`Sign-in ${e.split(`/`).pop()??`request`}`);if(!r.ok)throw xs(i);if(!n(i))throw Error(`Unexpected response from server`);return i}function Cs(e,t){return Ss(`${e}/start`,t,ms)}function ws(e,t){return Ss(`${e}/code/start`,t,gs)}async function Ts(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(z(`${e}/status?${n.toString()}`),{headers:{Authorization:ys().Authorization??``}}),i=await bs(r,`Sign-in status`);if(!r.ok)throw xs(i);if(!_s(i))throw Error(`Unexpected status response from server`);return i}async function Es(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(z(`${e}/status?${n.toString()}`),{headers:{Authorization:ys().Authorization??``}}),i=await bs(r,`Sign-in status`);if(!r.ok)throw xs(i);if(!hs(i))throw Error(`Unexpected status response from server`);return i}function Ds(e,t){return Ss(`${e}/commit`,{...t},vs)}async function Os(e,t){try{await fetch(z(`${e}/cancel`),{method:`POST`,headers:ys(),body:JSON.stringify({sessionId:t})})}catch{}}w();var ks=2e3,As=1e3;function js(e){let t=Math.max(0,Math.ceil(e/1e3));return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,`0`)}`}function Ms({expiresAt:e}){let{t}=W(),[n,r]=b(()=>Date.now());return v(()=>{let e=setInterval(()=>r(Date.now()),As);return()=>clearInterval(e)},[]),_(`span`,{className:`text-[11px] text-foreground-subtle`,children:t(`brokers.signIn.codeExpiresIn`,{time:js(e-n)})})}function Ns({basePath:e,name:t,brokerId:n,getSettings:r,disabled:a,onSignedIn:o}){let{t:s}=W(),[c,l]=b({kind:`idle`}),d=u(!0),f=u(null),p=u(null),m=g(()=>{p.current!==null&&clearInterval(p.current),p.current=null},[]),h=g(()=>{m();let t=f.current;f.current=null,t!==null&&Os(e,t)},[e,m]);v(()=>(d.current=!0,()=>{d.current=!1,h()}),[h]);let y=g(e=>{m(),d.current&&l({kind:`error`,message:e})},[m]),x=g(async r=>{m(),d.current&&l({kind:`committing`});try{let i=await Ds(e,{sessionId:r,name:t,...n===void 0?{}:{brokerId:n}});f.current=null,d.current&&o(i.brokerId)}catch(e){y(e instanceof Error?e.message:String(e))}},[e,n,y,t,o,m]),S=g(t=>{m(),p.current=setInterval(()=>{(async()=>{try{let n=await Ts(e,t);if(n.phase===`captured`)return void await x(t);if(n.phase===`error`)return y(n.error??s(`brokers.signIn.proxyError`));if(n.phase===`expired`){m(),d.current&&l({kind:`expired`});return}n.phase===`cancelled`&&(m(),d.current&&l({kind:`idle`}))}catch{}})()},ks)},[e,x,y,m,s]),C=async()=>{h(),l({kind:`starting`});try{let t=await ws(e,r());f.current=t.sessionId,l({kind:`waiting`,code:t}),S(t.sessionId)}catch(e){y(e instanceof Error?e.message:String(e))}},w=()=>{h(),l({kind:`idle`})};if(c.kind===`idle`||c.kind===`error`||c.kind===`expired`)return i(`div`,{className:`space-y-2`,children:[c.kind===`error`&&_(V,{message:c.message}),c.kind===`expired`&&_(`p`,{className:`text-xs text-warning`,children:s(`brokers.signIn.codeExpired`)}),_(`p`,{className:`text-xs text-foreground-muted`,children:s(`brokers.signIn.codeIntro`)}),i(H,{variant:`primary`,size:`sm`,disabled:a===!0||t.trim().length===0,onClick:()=>void C(),children:[c.kind===`idle`?_(pt,{className:`h-3.5 w-3.5`}):_(te,{className:`h-3.5 w-3.5`}),` `,c.kind===`idle`?s(`brokers.signIn.getCode`):s(`brokers.signIn.newCode`)]})]});if(c.kind===`starting`||c.kind===`committing`)return i(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[_(B,{className:`h-4 w-4 animate-spin flex-shrink-0`}),c.kind===`starting`?s(`brokers.signIn.starting`):s(`brokers.signIn.saving`)]});let{code:T}=c;return i(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-3`,children:[_(`p`,{className:`text-xs text-foreground-muted`,children:s(`brokers.signIn.codeInstructions`)}),i(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border-subtle bg-background px-3 py-2`,children:[_(`span`,{"data-testid":`device-code`,className:`font-mono text-2xl font-semibold tracking-widest text-foreground break-all`,children:T.userCode}),_(yr,{value:T.userCode,srLabel:s(`brokers.signIn.copyCode`)})]}),i(H,{variant:`primary`,size:`sm`,onClick:()=>window.open(T.verificationUrl,`_blank`,`noopener,noreferrer`),children:[_(He,{className:`h-3.5 w-3.5`}),` `,s(`brokers.signIn.openCodePage`,{host:Ps(T.verificationUrl)})]}),i(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-1`,children:[i(`span`,{className:`flex min-w-0 flex-col text-[11px] text-foreground-subtle`,children:[i(`span`,{className:`flex items-center gap-2`,children:[_(B,{className:`h-3 w-3 animate-spin flex-shrink-0`}),` `,s(`brokers.signIn.waitingForCode`)]}),_(Ms,{expiresAt:T.expiresAt})]}),_(H,{variant:`outline`,size:`sm`,className:`shrink-0 whitespace-nowrap`,onClick:w,children:s(`brokers.signIn.cancel`)})]})]})}function Ps(e){try{let t=new URL(e);return`${t.host}${t.pathname===`/`?``:t.pathname}`}catch{return e}}w();var Fs=2e3;function Is(e){return e.startsWith(`/`)&&!e.startsWith(`//`)?new URL(e,window.location.origin).toString():e}function Ls({basePath:e,name:t,brokerId:n,getSettings:r,disabled:a,onSignedIn:o}){let{t:s}=W(),[c,l]=b({kind:`idle`}),d=u(!0),f=u(null),p=u(null),m=g(()=>{p.current!==null&&clearInterval(p.current),p.current=null},[]),h=g(()=>{m();let t=f.current;f.current=null,t!==null&&Os(e,t)},[e,m]);v(()=>(d.current=!0,()=>{d.current=!1,h()}),[h]);let y=g(e=>{m(),d.current&&l({kind:`error`,message:e})},[m]),x=g(async r=>{m(),d.current&&l({kind:`committing`});try{let i=await Ds(e,{sessionId:r,name:t,...n===void 0?{}:{brokerId:n}});f.current=null,d.current&&o(i.brokerId)}catch(e){y(e instanceof Error?e.message:String(e))}},[e,n,y,t,o,m]),S=g(t=>{m(),p.current=setInterval(()=>{(async()=>{try{let n=await Es(e,t);if(n.phase===`captured`)return void await x(t);if(n.phase===`error`)return y(n.error??s(`brokers.signIn.proxyError`));if(n.phase===`cancelled`){m(),d.current&&l({kind:`idle`});return}d.current&&l({kind:`waiting`,loginUrl:n.loginUrl,ready:n.phase===`awaiting-login`})}catch{}})()},Fs)},[e,x,y,m,s]),C=async()=>{h(),l({kind:`starting`});try{let t=await Cs(e,r());f.current=t.sessionId,l({kind:`waiting`,loginUrl:t.loginUrl,ready:!1}),S(t.sessionId)}catch(e){y(e instanceof Error?e.message:String(e))}};return c.kind===`idle`||c.kind===`error`?i(`div`,{className:`space-y-2`,children:[c.kind===`error`&&_(V,{message:c.message}),_(`p`,{className:`text-xs text-foreground-muted`,children:s(`brokers.signIn.intro`)}),i(H,{variant:`primary`,size:`sm`,disabled:a===!0||t.trim().length===0,onClick:()=>void C(),children:[_(pt,{className:`h-3.5 w-3.5`}),` `,c.kind===`error`?s(`common.retry`):s(`brokers.signIn.start`)]})]}):c.kind===`starting`||c.kind===`committing`?i(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[_(B,{className:`h-4 w-4 animate-spin flex-shrink-0`}),c.kind===`starting`?s(`brokers.signIn.starting`):s(`brokers.signIn.saving`)]}):i(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-3`,children:[c.ready?i(A,{children:[_(`p`,{className:`text-xs font-semibold text-foreground`,children:s(`brokers.signIn.openLink`)}),_(`p`,{className:`text-[11px] text-foreground-subtle`,children:s(`brokers.signIn.afterLogin`)}),i(H,{variant:`primary`,size:`sm`,onClick:()=>window.open(Is(c.loginUrl),`_blank`,`noopener,noreferrer`),children:[_(He,{className:`h-3.5 w-3.5`}),` `,s(`brokers.signIn.openLoginPage`)]})]}):i(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[_(B,{className:`h-4 w-4 animate-spin flex-shrink-0`}),s(`brokers.signIn.waitingForProxy`)]}),i(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[i(`span`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[_(B,{className:`h-3 w-3 animate-spin`}),` `,s(`brokers.signIn.waitingForLogin`)]}),_(H,{variant:`outline`,size:`sm`,onClick:()=>{h(),l({kind:`idle`})},children:s(`brokers.signIn.cancel`)})]})]})}w();var Rs=[`device-code`];function zs({methods:e,...t}){let{t:n}=W(),r=e!==void 0&&e.length>0?e:Rs,[a,o]=b(null),s=a!==null&&r.includes(a)?a:r[0]??`device-code`;return i(`div`,{className:`space-y-2`,children:[r.length>1&&_(Vt,{value:s,onValueChange:e=>o(e===`device-code`?e:`proxy`),appearance:`pills`,children:_(ar,{"aria-label":n(`brokers.signIn.method`),children:r.map(e=>_(qt,{value:e,children:n(e===`device-code`?`brokers.signIn.methodDeviceCode`:`brokers.signIn.methodProxy`)},e))})}),s===`device-code`?_(Ns,{...t},`device-code`):_(Ls,{...t},`proxy`)]})}w();function Bs(e,t){if(!e)return t;let n=new Set;for(let r of e.sections){let e=r.fields;for(let r of e)!(`key`in r)||typeof r.key!=`string`||Vn(r,t,e)&&n.add(r.key)}let r={};for(let[e,i]of Object.entries(t))n.has(e)&&(r[e]=i);return r}function Vs({kind:e,addonId:t,brokerId:n,initialValues:r,onSubmit:a,onCancel:o,submitLabel:s,disabled:c,signIn:l}){let{t:u}=W(),[f,p]=b(r??{}),[m,h]=b(null),g=jt({kind:e,...t===void 0?{}:{addonId:t}}),y=d(()=>{let e=g.data;if(e&&typeof e==`object`&&`sections`in e&&Array.isArray(e.sections)){let t=e;return cs(et(n===void 0?t:rs(t,n),f),{hasSignIn:l!==void 0,advancedTitle:u(`brokers.brokerForm.advanced`)})}},[g.data,n,f,l!==void 0,u]);v(()=>{r!==void 0&&p(r)},[r]);let x=ls(typeof navigator>`u`?void 0:navigator.language);v(()=>{if(r!==void 0)return;let e=us(y,x,f);Object.keys(e).length>0&&p(t=>({...e,...t}))},[y,x,r,f]);let S=Cr(),C=async()=>{h(null);let n=Bs(y,f);try{let r=await S.mutateAsync({kind:e,settings:n,...t===void 0?{}:{addonId:t}});h(r.ok?{ok:!0}:{ok:!1,error:r.error})}catch(e){h({ok:!1,error:e instanceof Error?e.message:String(e)})}},w=()=>{let{_calendarCatalog:e,...t}=Bs(y,f);a(t)},T=()=>{let e=new Set;for(let t of y?.sections??[])for(let n of t.fields)as(n)&&n.filledBySignIn===!0&&e.add(n.key);let t=Bs(y,f);return Object.fromEntries(Object.entries(t).filter(([t])=>!e.has(t)))};return i(`div`,{className:`space-y-3`,children:[l!==void 0&&_(zs,{basePath:l.basePath,...l.methods===void 0?{}:{methods:l.methods},name:l.name,...l.brokerId===void 0?{}:{brokerId:l.brokerId},getSettings:T,disabled:c===!0,onSignedIn:l.onSignedIn}),g.isLoading&&i(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[_(B,{className:`h-3.5 w-3.5 animate-spin`}),` `,u(`brokers.brokerForm.loadingSchema`)]}),y&&_(Ar,{schema:y,values:f,onChange:p}),g.isError&&i(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[u(`brokers.brokerForm.failedToLoadSettingsSchema`,`Failed to load settings schema:`),` `,g.error instanceof Error?g.error.message:u(`brokers.brokerForm.unknownError`,`Unknown error`)]}),!y&&!g.isLoading&&!g.isError&&_(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-[11px] text-warning`,children:_(kr,{i18nKey:`brokers.brokerForm.noSchema`,values:{kind:e},components:{code:_(`code`,{className:`font-mono`})}})}),m&&_(`div`,{className:`rounded border px-3 py-2 text-[11px] ${m.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:m.ok?u(`brokers.brokerForm.connectionOk`,`Connection OK.`):u(`brokers.brokerForm.testFailed`,`Test failed: {{value1}}`,{value1:m.error??`unknown error`})}),i(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[_(H,{variant:`outline`,size:`sm`,onClick:o,children:u(`common.cancel`,`Cancel`)}),i(`div`,{className:`flex items-center gap-2`,children:[_(H,{variant:`outline`,size:`sm`,onClick:()=>{C()},disabled:S.isPending||!y,children:S.isPending?u(`brokers.brokerForm.testing`,`Testing…`):u(`brokers.brokerForm.testConnection`,`Test connection`)}),_(H,{variant:l===void 0?`primary`:`outline`,size:`sm`,onClick:w,disabled:!y||c,children:s??u(`common.save`,`Save`)})]})]})]})}w();function Hs(e){return e===void 0?``:`${e.addonId??``}::${e.kind}`}function Us(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function Ws(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}function Gs(e){return typeof e==`string`&&e.length>0?e:void 0}function Ks(e){let t=new Map;for(let n of e.providers)if(!(e.addonId!==void 0&&n.addonId!==e.addonId))for(let r of n.kinds){if(e.kind!==void 0&&r.kind!==e.kind)continue;let i=Gs(r.interactiveConnectPath),a=Gs(r.interactiveDisconnectPath),o=Gs(r.signIn?.basePath);t.set(`${n.addonId}::${r.kind}`,{addonId:n.addonId,kind:r.kind,label:r.label,...i===void 0?{}:{interactiveConnectPath:i},...a===void 0?{}:{interactiveDisconnectPath:a},...o===void 0?{}:{signInBasePath:o},...o!==void 0&&r.signIn?.methods!==void 0&&r.signIn.methods.length>0?{signInMethods:r.signIn.methods}:{}})}for(let n of e.brokers)e.kind!==void 0&&n.kind!==e.kind||[...t.values()].some(e=>e.kind===n.kind)||t.set(`::${n.kind}`,{kind:n.kind,label:n.kind});return[...t.values()]}function qs(e){let t=sn(),n=tn(e.kind===void 0?{}:{kind:e.kind});return{options:d(()=>Ks({providers:Ws(t.data),brokers:Us(n.data).filter(t=>e.addonId===void 0||t.addonId===e.addonId),...e.addonId===void 0?{}:{addonId:e.addonId},...e.kind===void 0?{}:{kind:e.kind}}),[t.data,n.data,e.addonId,e.kind]),isLoading:t.isLoading===!0}}var Js=`kind`,Ys=`name`,Xs=`restore`,Zs=`restoreId`;function Qs(e,t={allowRestore:!0}){let n=[];return e.length>1&&n.push({type:`select`,key:Js,label:U.t(`helpers.brokerIdentitySchema.kind`),options:e.map(e=>({value:e.key,label:e.label}))}),n.push({type:`text`,key:Ys,label:U.t(`helpers.brokerIdentitySchema.name`),placeholder:U.t(`helpers.brokerIdentitySchema.namePlaceholder`),required:!0}),t.allowRestore&&n.push({type:`boolean`,key:Xs,label:U.t(`helpers.brokerIdentitySchema.restore`),description:U.t(`helpers.brokerIdentitySchema.restoreHint`)},{type:`text`,key:Zs,label:U.t(`helpers.brokerIdentitySchema.originalId`),placeholder:`ha_004`,required:!0,showWhen:{field:Xs,equals:!0}}),{sections:[{id:`broker-identity`,title:U.t(`helpers.brokerIdentitySchema.title`),columns:1,fields:n}]}}function $s(e){let t=t=>{let n=e[t];return typeof n==`string`?n.trim():``},n=t(Js);if(n===``)return{ok:!1,problem:`Pick a kind.`};let r=t(Ys);if(r===``)return{ok:!1,problem:`Enter a name before saving.`};if(e.restore!==!0)return{ok:!0,identity:{kindKey:n,name:r,restoreId:null}};let i=t(Zs);return i===``?{ok:!1,problem:`Enter the original id, or turn restore off to create a new broker.`}:{ok:!0,identity:{kindKey:n,name:r,restoreId:i}}}w();function ec({title:e,subtitle:t,onClose:n,children:r}){return _(An,{open:!0,onOpenChange:e=>!e&&n(),children:i(un,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(dn,{children:[_(Ft,{children:e}),t&&_(Pt,{children:t})]}),_(br,{className:`space-y-3 pr-1`,children:r})]})})}function tc(e,t){let n=new Set(t.map(e=>e.trim().toLowerCase()));if(!n.has(e.toLowerCase()))return e;for(let t=2;;t++){let r=`${e} ${t}`;if(!n.has(r.toLowerCase()))return r}}function nc(e){return e.broker===void 0?_(rc,{...e}):_(ic,{...e,broker:e.broker})}function rc({kind:e,addonId:t,onClose:n,onSaved:r}){let{t:a}=W(),o=O(),{options:s,isLoading:c}=qs({...t===void 0?{}:{addonId:t},...e===void 0?{}:{kind:e}}),l=tn({}),f=d(()=>Us(l.data).map(e=>e.name),[l.data]),[p,m]=b({[Ys]:``,[Xs]:!1,[Zs]:``}),[h,g]=b(null),y=s.find(e=>Hs(e)===p.kind)??s[0],x=Hs(y),S=y===void 0?``:tc(y.label,f),C=u(``);v(()=>{x!==``&&m(e=>{let t=typeof e.name==`string`?e[Ys]:``,n=t===``||t===C.current;C.current=S;let r=n?S:t;return e.kind===x&&t===r?e:{...e,[Js]:x,[Ys]:r}})},[x,S]);let w=d(()=>Qs(s.map(e=>({key:Hs(e),label:e.label})),{allowRestore:y?.signInBasePath===void 0}),[s,y?.signInBasePath]),T=e=>{o.invalidateQueries({queryKey:[[`broker`,`list`]]}),r(e)},E=an({onSuccess:e=>{let t=typeof e==`object`&&e&&typeof e.id==`string`?e.id:null,n=y?.interactiveConnectPath;t!==null&&n!==void 0&&ns(n,t,()=>{o.invalidateQueries({queryKey:[[`broker`,`list`]]})}),t!==null&&T(t)}}),D=$s(p),k=D.ok?D.identity.name:``,j=e=>{if(y!==void 0){if(!D.ok){g(D.problem);return}g(null),E.mutate({kind:y.kind,name:D.identity.name,settings:e,...D.identity.restoreId===null?{}:{id:D.identity.restoreId},...y.addonId===void 0?{}:{addonId:y.addonId}})}},M=E.isPending;return _(ec,{title:a(`brokers.editor.createTitle`),subtitle:a(`brokers.editor.createSubtitle`),onClose:M?()=>{}:n,children:c&&s.length===0?i(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[_(B,{className:`h-3.5 w-3.5 animate-spin`}),` `,a(`brokers.editor.loadingKinds`)]}):y===void 0?_(V,{message:a(`brokers.editor.noProvider`)}):i(A,{children:[_(Ar,{schema:w,values:p,onChange:m}),h!==null&&_(V,{message:h}),E.isError&&_(V,{message:E.error instanceof Error?E.error.message:String(E.error)}),_(Vs,{kind:y.kind,...y.addonId===void 0?{}:{addonId:y.addonId},onSubmit:j,onCancel:n,submitLabel:a(M?`brokers.editor.creating`:`brokers.editor.create`),disabled:M,...y.signInBasePath===void 0?{}:{signIn:{basePath:y.signInBasePath,...y.signInMethods===void 0?{}:{methods:y.signInMethods},name:k,onSignedIn:T}}},x)]})})}function ic({broker:e,onClose:t,onSaved:n}){let{t:r}=W(),a=O(),{options:o}=qs({addonId:e.addonId,kind:e.kind}),s=o.find(t=>t.kind===e.kind),c=s?.signInBasePath,l=Un({id:e.id,addonId:e.addonId}),u=Zt({onSuccess:()=>{a.invalidateQueries({queryKey:[[`broker`,`list`]]}),a.invalidateQueries({queryKey:[[`broker`,`getSettings`],{input:{id:e.id,addonId:e.addonId}}]}),n(e.id)}}),f=d(()=>{let e=l.data;return e&&typeof e==`object`?{...e}:{}},[l.data]),p=u.isPending;return _(ec,{title:r(`brokers.brokerManager.edit`,`Edit {{name}}`,{name:e.name}),subtitle:`${e.kind} · ${e.id}`,onClose:p?()=>{}:t,children:l.isLoading?i(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[_(B,{className:`h-3.5 w-3.5 animate-spin`}),` `,r(`brokers.brokerManager.loadingSettings`)]}):l.isError?i(`div`,{className:`space-y-3`,children:[_(V,{message:r(`brokers.brokerManager.loadSettingsFailed`,{message:l.error instanceof Error?l.error.message:r(`common.unknownError`)})}),_(`div`,{className:`flex justify-end`,children:_(H,{variant:`outline`,size:`sm`,onClick:t,children:r(`common.close`,`Close`)})})]}):i(`div`,{className:`space-y-3`,children:[u.isError&&_(V,{message:u.error instanceof Error?u.error.message:String(u.error)}),_(Vs,{kind:e.kind,addonId:e.addonId,brokerId:e.id,initialValues:f,onSubmit:t=>u.mutate({id:e.id,settings:t,addonId:e.addonId}),onCancel:t,submitLabel:p?r(`brokers.brokerManager.saving`):r(`common.save`,`Save`),disabled:p,...c===void 0?{}:{signIn:{basePath:c,...s?.signInMethods===void 0?{}:{methods:s.signInMethods},name:e.name,brokerId:e.id,onSignedIn:e=>{a.invalidateQueries({queryKey:[[`broker`,`list`]]}),n(e)}}}})]})})}w();var ac={connected:`success`,connecting:`warning`,disconnected:`default`,"auth-failed":`danger`,unreachable:`danger`,error:`danger`};function oc({kind:e,value:t,onChange:n}){let{t:r}=W(),[a,o]=b(!1),s=tn({kind:e}),c=Us(s.data).filter(t=>t.kind===e);return i(`div`,{className:`space-y-2`,children:[s.isLoading&&i(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[_(B,{className:`h-3.5 w-3.5 animate-spin`}),` `,r(`brokers.picker.loading`)]}),s.isError&&_(V,{message:r(`brokers.picker.loadFailed`,{message:s.error instanceof Error?s.error.message:r(`common.unknownError`)})}),!s.isLoading&&!s.isError&&c.length===0&&_(`p`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-xs text-foreground-subtle`,children:r(`brokers.picker.none`)}),c.map(e=>i(`button`,{type:`button`,"aria-pressed":t===e.id,onClick:()=>n(e.id),className:`flex w-full items-center justify-between gap-3 rounded-lg border bg-surface p-3 text-left transition-colors ${t===e.id?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:[_(`span`,{className:`text-xs font-semibold text-foreground`,children:e.name}),_(Ln,{variant:ac[e.status],className:`text-[10px]`,children:e.status})]},e.id)),i(H,{variant:`outline`,size:`sm`,onClick:()=>o(!0),children:[_(se,{className:`h-3.5 w-3.5`}),` `,r(`brokers.picker.createNew`)]}),a&&_(nc,{kind:e,onClose:()=>o(!1),onSaved:e=>{o(!1),n(e)}})]})}function sc(e,t){return t.map(t=>({subject:{kind:`device`,deviceId:e},key:t.key,scope:t.scope}))}function cc({deviceId:e}){let{t}=W(),{presence:n,list:r}=Bn(e);return n===`absent`?null:n===`unknown`?_(V,{message:t(`deviceQuickDetail.historyUnknown`,`Could not tell whether this device has recorded history.`)}):n===`pending`||r.status===`pending`?_(Qt,{className:`h-24 w-full`,"aria-busy":`true`}):r.status===`error`?_(V,{title:t(`deviceQuickDetail.historyUnknown`,`Could not tell whether this device has recorded history.`),message:r.error}):r.data.length===0?null:i(`section`,{className:`flex flex-col gap-2`,"aria-label":t(`deviceQuickDetail.tabHistory`,`History`),children:[_(`div`,{className:`flex justify-end`,children:_(jo,{to:vr(sc(e,r.data)),className:`text-xs text-primary hover:underline`,children:t(`deviceQuickDetail.openHistory`,`Open full history`)})}),_(Mn,{deviceId:e})]})}function lc(e,t){return e===`present`&&t.status===`ok`&&(t.data?.length??0)>0}var uc={streaming:{icon:Et,labelKey:`capabilityBadges.streaming`},detection:{icon:ae,labelKey:`capabilityBadges.detection`},recording:{icon:Ce,labelKey:`capabilityBadges.recording`},audio:{icon:We,labelKey:`capabilityBadges.audio`},snapshot:{icon:ne,labelKey:`capabilityBadges.snapshot`},motion:{icon:Me,labelKey:`capabilityBadges.motion`},ptz:{icon:ke,labelKey:`capabilityBadges.ptz`},webrtc:{icon:de,labelKey:`capabilityBadges.webrtc`},onvif:{icon:De,labelKey:`capabilityBadges.onvif`},analytics:{icon:Pe,labelKey:`capabilityBadges.analytics`},"battery-operated":{icon:ve,labelKey:`capabilityBadges.battery`},"native-snapshot":{icon:ne,labelKey:`capabilityBadges.nativeSnapshot`},"pan-tilt-zoom":{icon:ke,labelKey:`capabilityBadges.ptz`},"two-way-audio":{icon:We,labelKey:`capabilityBadges.twoWayAudio`},"doorbell-button":{icon:ie,labelKey:`capabilityBadges.doorbell`},rebootable:{icon:te,labelKey:`capabilityBadges.rebootable`},"vacuum-has-map":{icon:St,labelKey:`capabilityBadges.map`},"vacuum-has-ai":{icon:Ue,labelKey:`capabilityBadges.aiObstacle`},"mower-has-map":{icon:St,labelKey:`capabilityBadges.map`},"mower-has-targeted-mowing":{icon:le,labelKey:`capabilityBadges.targetedMowing`}},dc=Qe;function fc({capabilities:e,showLabels:t=!1}){let{t:n}=W();return _(`div`,{className:`flex items-center gap-1 flex-wrap`,children:e.map(e=>{let r=uc[e],a=r?.icon??dc,o=r?n(r.labelKey):e;return i(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] text-foreground-subtle`,title:o,children:[_(a,{className:`h-3 w-3`}),t&&_(`span`,{children:o})]},e)})})}w();var pc={amcrest:{icon:gt,color:`#3b82f6`,label:`Amcrest`},hikvision:{icon:ye,color:`#a855f7`,label:`Hikvision`},reolink:{icon:de,color:`#06b6d4`,label:`Reolink`},homeassistant:{icon:ge,color:`#22d3ee`,label:`Home Assistant`},rtsp:{icon:we,color:`#78716c`,label:`RTSP`},onvif:{icon:we,color:`#78716c`,label:`ONVIF`}},mc={sm:`h-4 w-4`,md:`h-5 w-5`,lg:`h-6 w-6`,xl:`h-16 w-16`},hc={sm:`h-7 w-7`,md:`h-8 w-8`,lg:`h-10 w-10`,xl:`h-16 w-16`};function gc(e){let t=e.toLowerCase();return t.startsWith(`provider-`)?t.slice(9):t}function _c(e){return pc[gc(e)]??{icon:gt,color:`#78716c`,label:e}}function vc({type:e,size:t=`md`,showLabel:n}){let r=_c(e),a=r.icon,[o,s]=b(!1),c=Vr(e);return i(`div`,{className:`flex items-center gap-2`,children:[_(`div`,{className:`flex items-center justify-center rounded-lg ${hc[t]}`,style:{backgroundColor:`${r.color}15`},children:o||!c?_(a,{className:mc[t],style:{color:r.color}}):_(`img`,{src:c,alt:r.label,className:mc[t],onError:()=>s(!0)})}),n&&_(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:r.label})]})}function yc({label:e,value:t,layout:n=`inline`}){return n===`stacked`?i(`div`,{className:`min-w-0 flex flex-col gap-0.5 px-0.5`,children:[_(`span`,{className:`text-[11px] text-foreground-subtle`,children:e}),_(`div`,{className:`min-w-0 text-[11px] text-foreground`,children:t})]}):i(`div`,{className:`${he} flex items-start gap-2 sm:gap-3`,children:[_(`span`,{className:`w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle`,children:e}),_(`div`,{className:`flex-1 min-w-0 text-[11px] text-foreground`,children:t})]})}w();function bc(e){return Wt({addonId:e,projection:`slim`})}function xc(e){return en({deviceId:e},{enabled:Number.isFinite(e)})}var Sc=3e4,Cc=2e3;function wc(e){let t=u(0);return t.current===0&&(t.current=Date.now()),Mt({parentDeviceId:e},{enabled:Number.isFinite(e),staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let n=e.state.data;return n&&n.length>0||Date.now()-t.current>=Sc?!1:Cc}})}w();function Tc({deviceId:e}){let{t}=W(),n=O(),{data:r}=xc(e),{data:a}=wc(e),[o,s]=b(null),c=kn({onSuccess:()=>{s(null),n.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{s(`Could not change primary child: ${e.message}`)}});if(r==null||String(r.type??``)!==it.Container)return null;let l=String(r.name??``),u=(a??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:Xt(e,l),...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}}));if(u.length<=1)return null;let d=Sn(u,typeof r.linkDeviceId==`number`?r.linkDeviceId:null,typeof r.primaryChildEntityId==`string`?r.primaryChildEntityId:null),f=d===null?u[0].id:d.id;return i(A,{children:[_(yc,{label:t(`shared.primaryChildRow.primaryChild`,`Primary child`),value:_(sr,{childrenList:u,selectedId:f,onSetPrimary:t=>c.mutate({deviceId:e,primaryChildEntityId:t}),disabled:c.isPending})}),o!==null&&_(`p`,{role:`alert`,className:`px-3 sm:px-4 py-1.5 text-[11px] text-danger`,children:o})]})}w();var Ec=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`];function Dc(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function Oc(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function kc(){let{t:e}=W(),t=er(),n=ur(),{data:r}=en({deviceId:t??0},{enabled:t!==null}),{data:a}=Wn({deviceId:t??0},{enabled:t!==null}),o=r??n??null,[s,c]=b(`identity`);if(t===null||!o)return null;let l=String(o.stableId??``),u=String(o.addonId??``),d=typeof o.integrationId==`string`&&o.integrationId.length>0?o.integrationId:null,f=typeof o.parentDeviceId==`number`?o.parentDeviceId:null,p=o.features??[],m=new Set([`device-status`,`feature-probe`,`device-ops`]),h=(a?.entries??[]).filter(e=>e.kind===`native`&&!m.has(e.capName)).map(e=>e.capName),g=p.length>0?p:h,v=o.metadata??null,y=v!==null&&Object.keys(v).length>0;return i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[i(`div`,{className:`border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3`,children:[_(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`overviewAdapters.deviceInfoAdapter.deviceInfo`,`Device Info`)}),y&&i(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[_(Ac,{active:s===`identity`,onClick:()=>c(`identity`),label:e(`overviewAdapters.deviceInfoAdapter.identity`,`Identity`)}),_(Ac,{active:s===`hardware`,onClick:()=>c(`hardware`),label:e(`overviewAdapters.deviceInfoAdapter.hardware`,`Hardware`)})]})]}),(!y||s===`identity`)&&i(`div`,{className:`divide-y divide-border`,children:[_(yc,{label:`ID`,value:i(`span`,{className:`font-mono text-[11px] text-foreground`,children:[`#${t}`,i(`span`,{className:`ml-1.5 text-foreground-subtle`,children:[`(`,l,`)`]})]})}),_(Tc,{deviceId:t}),d!==null&&_(yc,{label:e(`overviewAdapters.deviceInfoAdapter.integration`,`Integration`),value:_(`span`,{className:`font-mono text-[11px]`,children:d})}),f!==null&&_(yc,{label:e(`overviewAdapters.deviceInfoAdapter.parent`,`Parent`),value:_(`span`,{className:`font-mono text-[11px]`,children:`#${String(f)}`})}),_(yc,{label:e(`overviewAdapters.deviceInfoAdapter.provider`,`Provider`),value:_(vc,{type:u,size:`sm`,showLabel:!0})}),_(yc,{label:e(`overviewAdapters.deviceInfoAdapter.capabilities`,`Capabilities`),value:g.length>0?_(fc,{capabilities:g,showLabels:!0}):_(`span`,{className:`text-[11px] text-foreground-subtle`,children:e(`overviewAdapters.deviceInfoAdapter.none`,`None`)})})]}),y&&s===`hardware`&&_(jc,{metadata:v})]})}function Ac({active:e,onClick:t,label:n}){return _(`button`,{type:`button`,onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${e?`bg-surface text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`}`,children:n})}function jc({metadata:e}){let{t}=W(),n=Ec.filter(t=>t in e),r=Object.keys(e).filter(e=>!Ec.includes(e)).toSorted(),a=[...n,...r];return i(`div`,{children:[_(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border bg-surface-subtle/40`,children:t(`overviewAdapters.deviceInfoAdapter.autoPopulatedByTheDriver`,`Auto-populated by the driver on every connect. Read-only.`)}),_(`div`,{className:`divide-y divide-border`,children:a.map(t=>_(yc,{label:Dc(t),value:_(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:Oc(e[t])})},t))})]})}function Mc(e,t){return e.icon===t.icon&&e.label===t.label&&e.unit===t.unit&&e.precision===t.precision&&e.hidden===t.hidden}function Nc(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function Pc(e){if(e.trim()===``)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function Fc(e,t){let n=Pc(e.precision),r={...e.icon===``?{}:{icon:e.icon},...e.label.trim()===``?{}:{label:e.label.trim()},...e.unit===``?{}:{unit:e.unit},...n===void 0?{}:{precision:n},...e.hidden?{hidden:!0}:{},...t?.perCap===void 0?{}:{perCap:t.perCap}};return Object.keys(r).length===0?null:r}function Ic(e){let t=Nc(e.display);return{name:e.name,location:e.location,role:e.role,display:t,baseName:e.name,baseLocation:e.location,baseRole:e.role,baseDisplay:t,persistedDisplay:e.display}}function Lc(e,t){if(e===null)return Ic(t);let n=Nc(t.display),r=e.name===t.name&&e.location===t.location&&e.role===t.role&&Mc(e.display,n);return!Rc(e)||r?Ic(t):e}function Rc(e){return e===null?!1:e.name!==e.baseName||e.location!==e.baseLocation||e.role!==e.baseRole||!Mc(e.display,e.baseDisplay)}function zc(e){return e.name.trim().length===0?`name`:null}function Bc(e){let t=e.name.trim(),n=e.location.trim();return{...t===e.baseName?{}:{name:t},...n===e.baseLocation?{}:{location:n===``?null:n},...e.role===e.baseRole?{}:{role:e.role},...Mc(e.display,e.baseDisplay)?{}:{display:Fc(e.display,e.persistedDisplay)}}}function Vc(e){let t=e.map(e=>e.error).filter(e=>e!==null&&e.length>0);return{dirty:e.some(e=>e.dirty),saving:e.some(e=>e.saving),error:t.length===0?null:t.join(`; `)}}w();var Hc=E(null);function Uc(){return j(Hc)}function Wc({deviceId:e,seed:t,showOpenFull:n=!1,onClose:r,children:i}){let[a,o]=b(null),[s,c]=b([]),l=u(new Map);if(t!==null){let e=Lc(a,t);(a===null||e.name!==a.name||e.location!==a.location||e.role!==a.role||!Mc(e.display,a.display)||e.baseName!==a.baseName||e.baseLocation!==a.baseLocation||e.baseRole!==a.baseRole||!Mc(e.baseDisplay,a.baseDisplay)||e.persistedDisplay!==a.persistedDisplay)&&o(e)}let f=g(e=>(l.current.set(e.id,{save:e.save,discard:e.discard}),c(t=>{let n=t.find(t=>t.id===e.id);return n!==void 0&&n.dirty===e.dirty&&n.saving===e.saving&&n.error===e.error?t:[...t.filter(t=>t.id!==e.id),{...e,save:()=>l.current.get(e.id)?.save()??Promise.resolve(),discard:()=>{l.current.get(e.id)?.discard()}}]}),()=>{l.current.delete(e.id),c(t=>t.filter(t=>t.id!==e.id))}),[]),p=d(()=>({identity:a,setIdentityName:e=>{o(t=>t===null?t:{...t,name:e})},setIdentityLocation:e=>{o(t=>t===null?t:{...t,location:e})},setIdentityRole:e=>{o(t=>t===null?t:{...t,role:e})},setIdentityDisplay:e=>{o(t=>t===null?t:{...t,display:{...t.display,...e}})},register:f}),[a,f]);return _(Hc.Provider,{value:p,children:_(Gc,{deviceId:e,identity:a,contributions:s,onIdentitySaved:e=>o(e),showOpenFull:n,onClose:r,children:i})})}function Gc({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:a,onClose:o,children:s}){return i(A,{children:[s,_(qc,{deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:a,onClose:o})]})}function Kc(e){return e instanceof Error?e.message:String(e)}function qc({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:a,onClose:o}){let{t:s}=W(),c=ua(),l=Ke(),u=O(),[d,f]=b(null),[p,m]=b(!1),h=Hn(),g=In(),v=nr(),y=kt(),x=Vc([{dirty:Rc(t),saving:p,error:d},...n]),S=()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})};return!x.dirty&&!x.saving&&x.error===null&&!a?null:i(`div`,{className:`sticky bottom-0 z-10 mt-auto flex flex-col gap-2 border-t border-border bg-background px-1 pt-3`,children:[x.error!==null&&_(`p`,{className:`text-xs text-danger`,children:x.error}),i(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[a?_(H,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{(async()=>{x.dirty&&!await l({title:s(`deviceQuickDetail.leaveTitle`,`Discard unsaved changes?`),message:s(`deviceQuickDetail.leaveMessage`,`Unsaved edits on this device will be discarded.`),confirmLabel:s(`deviceQuickDetail.discard`,`Discard`),variant:`warning`})||(c(`/devices/${String(e)}?tab=customize`),o?.())})()},children:s(`deviceQuickDetail.openFull`,`Open full detail`)}):_(`span`,{}),i(`div`,{className:`flex items-center gap-2`,children:[_(H,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{t!==null&&r({...t,name:t.baseName,location:t.baseLocation,role:t.baseRole,display:t.baseDisplay});for(let e of n)e.discard();f(null)},disabled:!x.dirty||x.saving,children:s(`deviceQuickDetail.discard`,`Discard`)}),_(H,{type:`button`,size:`sm`,onClick:()=>{if(t!==null&&Rc(t)&&zc(t)===`name`){f(s(`deviceQuickDetail.nameRequired`,`Name is required`));return}f(null),m(!0),(async()=>{try{let i=t===null?{}:Bc(t);if(t!==null&&i.name!==void 0&&await h.mutateAsync({deviceId:e,name:i.name}),t!==null&&i.location!==void 0&&await g.mutateAsync({deviceId:e,location:i.location}),t!==null&&i.role!==void 0&&await v.mutateAsync({deviceId:e,role:i.role}),t!==null&&i.display!==void 0&&await y.mutateAsync({deviceId:e,display:i.display}),t!==null){let e=t.name.trim(),n=t.location.trim();r({...t,name:e,location:n,baseName:e,baseLocation:n,baseRole:t.role,baseDisplay:t.display,persistedDisplay:i.display===void 0?t.persistedDisplay:i.display??void 0})}for(let e of n)e.dirty&&await e.save();S()}catch(e){f(Kc(e))}finally{m(!1)}})()},disabled:!x.dirty||x.saving,children:x.saving?s(`deviceQuickDetail.saving`,`Saving…`):s(`deviceQuickDetail.save`,`Save`)})]})]})]})}function Jc(e){return e.hubReachable?e.authOk===!1?{kind:`auth-expired`}:{kind:`cluster-degraded`,offlineAgents:e.offlineAgents,offlineAgentIds:e.offlineAgentIds}:{kind:`hub-unreachable`}}function Yc(e){switch(e.kind){case`connected`:return null;case`reconnecting`:return{severity:`warning`,message:U.t(`connection.reconnecting`),i18nKey:`connection.reconnecting`,showSpinner:!0};case`cluster-degraded`:{let t=e.offlineAgentIds??[];return t.length>0?{severity:`warning`,message:U.t(`connection.degradedNodes`,{nodes:t.join(`, `),count:t.length}),i18nKey:`connection.degradedNodes`,i18nParams:{nodes:t.join(`, `),count:t.length},showSpinner:!0}:e.offlineAgents!==null&&e.offlineAgents>0?{severity:`warning`,message:U.t(`connection.degradedCount`,{count:e.offlineAgents}),i18nKey:`connection.degradedCount`,i18nParams:{count:e.offlineAgents},showSpinner:!0}:{severity:`warning`,message:U.t(`connection.degraded`),i18nKey:`connection.degraded`,showSpinner:!0}}case`hub-unreachable`:return{severity:`danger`,message:U.t(`connection.disconnected`),i18nKey:`connection.disconnected`,showSpinner:!0};case`auth-expired`:return{severity:`danger`,message:U.t(`connection.sessionExpired`),i18nKey:`connection.sessionExpired`,showSpinner:!1,action:`sign-in`}}}var Xc=4e3,Zc=5e3;function Qc(e){if(typeof e!=`object`||!e)return{offline:null,offlineIds:null,ok:null};let t={...e},n=typeof t.ok==`boolean`?t.ok:null,r=t.agents;if(typeof r!=`object`||!r)return{offline:null,offlineIds:null,ok:n};let i={...r},a=i.offline,o=typeof a==`number`?a:null,s=i.offlineIds;return{offline:o,offlineIds:Array.isArray(s)?s.filter(e=>typeof e==`string`):null,ok:n}}async function $c(e,t,n,r){let i=new AbortController,a=setTimeout(()=>i.abort(),n);try{return await e(t,{method:`GET`,signal:i.signal,credentials:`omit`,...r===void 0?{}:{headers:r}})}finally{clearTimeout(a)}}async function el(e){let t=e.fetchFn??fetch,n=e.timeoutMs??Xc,r=e.origin.replace(/\/+$/,``),i;try{i=await $c(t,`${r}/health`,n)}catch{return{hubReachable:!1,authOk:`unknown`,offlineAgents:null,offlineAgentIds:null}}if(!i.ok)return{hubReachable:!1,authOk:`unknown`,offlineAgents:null,offlineAgentIds:null};let a=null,o=e.getToken();if(o!==null&&o!==``)try{let e=await $c(t,`${r}/health/details`,n,{Authorization:`Bearer ${o}`});e.ok&&(a=await e.json())}catch{}let s;try{s=Qc(a??await i.json())}catch{s={offline:null,offlineIds:null,ok:null}}if(s.ok===!1)return{hubReachable:!1,authOk:`unknown`,offlineAgents:null,offlineAgentIds:null};let c=e.getToken(),l=`unknown`;if(c!==null&&c!==``)try{let e=await $c(t,`${r}/trpc/auth.me`,n,{Authorization:`Bearer ${c}`});e.status===401||e.status===403?l=!1:e.ok&&(l=!0)}catch{l=`unknown`}return{hubReachable:!0,authOk:l,offlineAgents:s.offline,offlineAgentIds:s.offlineIds}}var tl={kind:`connected`},nl={kind:`reconnecting`};function rl(e){let t=e.probeIntervalMs??Zc,n=new Set,r=tl,i=0,a=!1,o=null;function s(e){if(r!==e){r=e;for(let e of n)e()}}function c(){a=!1,o!==null&&(clearTimeout(o),o=null)}function l(){let n=i;e.probe().then(e=>{n!==i||!a||(s(Jc(e)),o=setTimeout(l,t))},()=>{n!==i||!a||(s({kind:`hub-unreachable`}),o=setTimeout(l,t))})}function u(e){if(i+=1,e===`connected`){c(),s(tl);return}if(e===`connecting`){c(),s(nl);return}(r.kind===`connected`||r.kind===`reconnecting`)&&s(nl),o!==null&&(clearTimeout(o),o=null),a=!0,l()}return{getSnapshot:()=>r,subscribe:e=>(n.add(e),()=>{n.delete(e)}),onSdkConnectionState:u,dispose:()=>{i+=1,c(),n.clear()}}}var il=null;function al(){return il===null&&(il=rl({probe:()=>el({origin:_e(),getToken:()=>localStorage.getItem(`camstack_admin_token`)})})),il}function ol(e){al().onSdkConnectionState(e)}function sl(e){return e===`connected`}function cl(e){D.setOnline(sl(e))}var ll=null,ul=0;function Q(){if(!ll){let e=ul;ll=rr({serverUrl:_e(),token:localStorage.getItem(`camstack_admin_token`)??void 0,getLanguage:()=>U.language,refreshCredential:async e=>{e===`rejected`?await Dl().refreshNow():await Dl().ensureFresh()},onConnectionChange:t=>{e===ul&&(ol(t),cl(t))}})}return ll}function dl(){let e=ll;ll=null,ul+=1,e?.close()}var fl=`camstack_admin_token`,pl=`camstack_admin_refresh`,ml=`camstack_admin_token_expires`;function hl(e){try{let t=localStorage.getItem(e);return t!==null&&t.length>0?t:null}catch{return null}}function gl(e,t){try{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}function _l(){let e=hl(fl);if(e===null)return null;let t=hl(pl),n=Number(hl(ml));return{token:e,...t===null?{}:{refreshToken:t},...Number.isFinite(n)&&n>0?{expiresAt:n}:{}}}function vl(e){gl(fl,e.token),gl(pl,e.refreshToken??null),gl(ml,e.expiresAt===void 0?null:String(e.expiresAt))}function yl(){gl(fl,null),gl(pl,null),gl(ml,null)}function bl(e){let t=e.get(`token`);if(t===null||t.length===0)return null;let n=e.get(`refreshToken`),r=Number(e.get(`expiresAt`));return{token:t,...n!==null&&n.length>0?{refreshToken:n}:{},...Number.isFinite(r)&&r>0?{expiresAt:r}:{}}}async function xl(e){await fetch(z(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}var Sl=new Set;function Cl(e){return Sl.add(e),()=>Sl.delete(e)}var wl=new Set;function Tl(e){return wl.add(e),()=>wl.delete(e)}var El=null;function Dl(){return El===null&&(El=new Zn({refresh:async e=>{let t=_l();if(t?.refreshToken!==void 0&&t.refreshToken!==e&&(t.expiresAt??0)>Date.now()+6e4)return t;let n=await Q().refreshSession(e);return{token:n.token,refreshToken:n.refreshToken,expiresAt:n.expiresAt}},onTokens:e=>{vl(e),Q().setToken(e.token),xl(e.token);for(let e of wl)e()},onExpired:()=>{yl();for(let e of Sl)e()}})),El}function Ol(e){vl(e),Dl().adopt(e)}async function kl(e){try{await Dl().ensureFresh()}catch(e){console.warn(`[admin-session] pre-reconnect refresh failed; reconnecting anyway`,e)}e()}async function Al(){return await Dl().refreshNow()!==null}var jl=512;function Ml(e){if(!e||e.length>jl)return null;let t=tt(e);return t===null?!e.startsWith(`/`)||e.startsWith(`//`)||e.includes(`\\`)||e.includes(`://`)||e.includes(`..`)||e===`/login`||e.startsWith(`/login?`)||e.startsWith(`/login/`)?null:{kind:`path`,path:e}:{kind:`app-callback`,url:t}}var Nl=/^[A-Za-z0-9_-]{43,128}$/,Pl=/^[A-Za-z0-9._~-]{1,256}$/;function Fl(e){let{codeChallenge:t,state:n}=e;return!t||!Nl.test(t)||(e.codeChallengeMethod??`S256`)!==`S256`||!n||!Pl.test(n)?null:{codeChallenge:t,state:n,purpose:e.purpose===`step-up`?`step-up`:`new-session`}}var Il=`camstack:login-app-handoff`;function Ll(e){if(!e)return null;try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=e=>{let n=Reflect.get(t,e);return typeof n==`string`?n:null};return Fl({codeChallenge:n(`codeChallenge`),state:n(`state`),purpose:n(`purpose`)})}catch{return null}}function Rl(e,t=Date.now()){e!==null&&Xl(Il,JSON.stringify(e),Ll,t)}function zl(e=Date.now()){return Zl(Il,Ll,e)}function Bl(e,t,n){return`${e}?${`code=${encodeURIComponent(t)}`}${n===void 0?``:`&state=${encodeURIComponent(n)}`}`}function Vl(e,t=Date.now()){return eu(t)??Ml(e)}var Hl=2048;function Ul(e){return!e||e.length>Hl||!e.startsWith(`/`)||e.startsWith(`//`)||e.includes(`\\`)||e.includes(`://`)||e.includes(`..`)||e===`/login`||e.startsWith(`/login?`)||e.startsWith(`/login/`)?null:e}function Wl(e,t=Date.now()){Xl(Jl,e,Ul,t)}function Gl(e=Date.now()){return Zl(Jl,Ul,e)}function Kl(e,t=Date.now()){return Gl(t)??Ul(e)}var ql=`camstack:login-redirect`,Jl=`camstack:login-next`,Yl=10*6e4;function Xl(e,t,n,r){let i=Ql();if(!i||!n(t))return;let a={raw:t??``,at:r};try{i.setItem(e,JSON.stringify(a))}catch{}}function Zl(e,t,n){let r=Ql();if(!r)return null;let i=null;try{i=r.getItem(e),r.removeItem(e)}catch{return null}if(!i)return null;try{let e=JSON.parse(i);if(typeof e!=`object`||!e)return null;let r=Reflect.get(e,`at`),a=Reflect.get(e,`raw`);return typeof r!=`number`||typeof a!=`string`||n-r>Yl?null:t(a)}catch{return null}}function Ql(){if(typeof window>`u`)return null;try{return window.sessionStorage}catch{return null}}function $l(e,t=Date.now()){Xl(ql,e,Ml,t)}function eu(e=Date.now()){return Zl(ql,Ml,e)}var tu=`changeme`;function nu(e){try{let t=e.split(`.`);if(t.length<2||!t[1])return null;let n=JSON.parse(atob(t[1]));return{id:String(n.userId??``),username:String(n.username??`unknown`),isAdmin:!!n.isAdmin,exp:Number(n.exp??0),scopes:ru(n.scopes)}}catch{return null}}function ru(e){return nt(st(e))}function iu(e){let t=nu(e);return t?t.exp*1e3<Date.now():!0}w();var au=tu;function ou(e){return{token:e.token,...e.refreshToken===void 0?{}:{refreshToken:e.refreshToken},...e.expiresAt===void 0?{}:{expiresAt:e.expiresAt}}}async function su(e,t){if(await xl(e),t.kind===`path`){window.location.replace(z(t.path));return}try{dl();let e=zl();if(e===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await Q().trpcClient.auth.createHandoffCode.mutate({purpose:e.purpose,codeChallenge:e.codeChallenge,state:e.state});window.location.replace(Bl(t.url,n,e.state))}catch{window.location.replace(z(`/`))}}async function cu(e,t){await xl(e),window.location.replace(z(t))}var lu=E(null);function uu({children:e}){let[t,n]=b(null),[r,i]=b(!0),[a,o]=b(!1);v(()=>{if(typeof window<`u`&&window.location.hash.startsWith(`#token=`)){let e=new URLSearchParams(window.location.hash.slice(1)),t=bl(e),n=t?.token??null;if(t!==null&&n!==null){Ol(t);let r=eu();if(r){su(n,r);return}let i=Gl()??Ul(e.get(`next`));if(i){cu(n,i);return}window.history.replaceState({},``,z(`/`))}}s()},[]);let s=async()=>{let e=_l();if(e===null){i(!1);return}let t=e.token;if(e.refreshToken!==void 0){let n=Dl();n.adopt(e),await n.ensureFresh();let r=_l();if(r===null){console.warn(`[auth] session restore: signed out — the hub refused the refresh token`),dl(),i(!1);return}t=r.token}if(iu(t)){console.warn(`[auth] session restore: signed out — access token expired and no refresh recovered it`),yl(),dl(),i(!1);return}let r=nu(t);if(!r){console.warn(`[auth] session restore: signed out — the stored access token is unreadable`),yl(),dl(),i(!1);return}xl(t);let a=Q();a.trpcClient.system.info.query().then(()=>n(r)).catch(async e=>{let t=e?.data?.code;if(t===`UNAUTHORIZED`||t===`FORBIDDEN`){if(await Al()){a.reconnect();try{await Q().trpcClient.system.info.query();let e=_l();n(e&&nu(e.token)||r);return}catch{}}console.warn(`[auth] session restore: logout, probe UNAUTHORIZED and refresh did not recover it`),Dl().stop(),yl(),dl()}else n(r)}).finally(()=>i(!1))};v(()=>Cl(()=>{dl(),n(null),o(!1)}),[]);let c=g(async(e,t)=>{let r=await Q().login(e,t,{refreshable:!0}),i=r.secondFactors??(r.requiresTotp===!0?[`totp`]:[]);if(i.length>0)return{kind:`second-factor`,challengeToken:r.token,factors:i};let a=r.token;return Ol(ou(r)),await xl(a),dl(),n(nu(a)),o(t===au),{kind:`ok`}},[]),l=g(async(e,t)=>{let r=await Q().loginVerifyTotp(e,t,{refreshable:!0}),i=r.token;Ol(ou(r)),await xl(i),dl(),n(nu(i)),o(!1)},[]),u=g(async(e,t)=>{Ol({token:e,...t}),await xl(e),dl(),n(nu(e)),o(!1)},[]),d=g(()=>{Q().logout().catch(()=>{}),Dl().stop(),yl(),fetch(z(`/api/auth/session`),{method:`DELETE`}).catch(()=>{}),dl(),n(null),o(!1)},[]),f=g(()=>{o(!1)},[]);return _(lu.Provider,{value:{user:t,loading:r,mustChangePassword:a,login:c,verifyTotp:l,finalizePasskeyLogin:u,logout:d,clearMustChangePassword:f},children:e})}function du(){let e=j(lu);if(!e)throw Error(`useAuth must be used within AuthProvider`);return e}w();function fu(e,t){for(let n of e)for(let e of n.fields){if(!(`key`in e)||e.key!==t)continue;if(e.type===`button`||e.type===`separator`||e.type===`info`)return!0;let r=e.immediate;return r===!0?!0:r===!1?!1:n.immediate===!0}return!1}function pu({schema:e,serverValues:t,onImmediateSave:n,onDeferredSave:r}){let[i,a]=b({}),[o,s]=b({}),[c,l]=b(!1),f=u(null),p=e?.sections??[],m=Object.keys(i).length>0,h=d(()=>({...t,...o,...i}),[t,o,i]);v(()=>{if(m||Object.keys(o).length>0){l(!0);return}f.current&&clearTimeout(f.current),f.current=setTimeout(()=>l(!1),500)},[m,o]),v(()=>()=>{f.current&&clearTimeout(f.current)},[]);let _=g(()=>{l(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>l(!1),2e3)},[]),y=g(e=>{_();let r={},o={},s={...t,...i};for(let[t,n]of Object.entries(e))s[t]!==n&&(fu(p,t)?r[t]=n:o[t]=n);Object.keys(r).length>0&&n(r),a(e=>{let t={...e};for(let e of Object.keys(r))delete t[e];for(let[e,n]of Object.entries(o))t[e]=n;return t})},[_,t,i,p,n]),x=g(e=>{let t={},n={};for(let[r,a]of Object.entries(i))e.includes(r)?t[r]=a:n[r]=a;if(a(n),Object.keys(t).length===0)return;let o=Object.keys(t),c=r(t);if(c===void 0||typeof c.then!=`function`)return;s(e=>({...e,...t}));let l=()=>s(e=>{let t={...e};for(let e of o)delete t[e];return t});c.then(l,()=>{l(),a(e=>{let n={...e};for(let e of o)e in n||(n[e]=t[e]);return n})})},[i,r]),S=g(e=>{a(t=>{let n={...t};for(let t of e)delete n[t];return n})},[]),C=g(()=>{a({})},[]);return{values:h,pendingKeys:Object.keys(i),hasPendingEdits:m,editingPaused:c,handleChange:y,handleSave:x,handleDiscard:S,resetAll:C}}function mu({pendingCount:e,onSave:t,onDiscard:n,saving:r=!1,saveLabel:a=`Save`,discardLabel:o=`Discard`}){let{t:s}=W();return e<=0?null:i(`div`,{className:`sticky bottom-0 -mb-3 flex items-center justify-between gap-3 rounded-lg border border-primary/40 bg-primary/5 px-3 py-2 shadow-sm z-10`,children:[_(`span`,{className:`text-xs text-foreground`,children:s(`formBuilder.saveBar.unsavedChanges`,{count:e})}),i(`div`,{className:`flex items-center gap-2`,children:[_(`button`,{type:`button`,onClick:n,disabled:r,className:`inline-flex items-center rounded-md border border-border px-2.5 py-1 text-xs text-foreground-subtle hover:bg-surface-hover disabled:opacity-50`,children:o}),_(`button`,{type:`button`,onClick:t,disabled:r,className:`inline-flex items-center rounded-md bg-primary px-3 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:r?s(`formBuilder.formSaveBar.saving`,`Saving…`):a})]})]})}function hu({tabs:e,activeId:t,onChange:n,countByTab:r,pendingByTab:a}){return e.length===0?null:_(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:e.map(e=>{let o=e.id===t,s=r?.get(e.id)??0,c=a?.get(e.id)??0;return i(`button`,{type:`button`,onClick:()=>n(e.id),className:`relative shrink-0 px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${o?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[e.label,s>0&&i(`span`,{className:`ml-1.5 text-[10px] opacity-60`,children:[`(`,s,`)`]}),c>0&&_(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-primary`})]},e.id)})})}w();function gu({schema:e,values:t,pendingKeys:n,onChange:r,onAction:a,onSave:o,onDiscard:s,disabled:c,activeSubTab:l,onSubTabChange:f,flattenTabs:p=!1,visibilityContext:m,hideSaveBar:h=!1,leadingTabs:g=[]}){let v=e.tabs??[],y=d(()=>{let t=new Map;for(let n of e.sections){let e=n.tab??`general`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t},[e.sections]),x=new Set(v.map(e=>e.id)),S=[...g.map(e=>({id:e.id,label:e.label})),...v,...[...y.keys()].filter(e=>!x.has(e)).map(e=>({id:e,label:e,icon:`wrench`,order:100}))],C=S[0]?.id??`general`,[w,T]=b(C),E=f!==void 0,D=new Set(S.map(e=>e.id)),O=u(new Set);for(let e of D)O.current.add(e);let k=O.current,A=(e=>e&&(D.has(e)||k.has(e))?e:C)(E?l:w),j=e=>{E?f(e):T(e)},M=g.find(e=>e.id===A),N=y.get(A)??[],P={sections:N.length<=1?N.length===1?[{...N[0],title:``}]:N:N.every(e=>!e.title)?[{...N[0],title:``,fields:N.flatMap(e=>e.fields)}]:N},F=h?null:_(mu,{pendingCount:n.length,onSave:()=>o(n),onDiscard:()=>s(n),saving:c});if(g.length===0&&(p||S.length<=1))return i(`div`,{className:`flex flex-col gap-3`,children:[_(Ar,{schema:e,values:t,onChange:r,onAction:a,disabled:c,visibilityContext:m}),F]});let ee=new Map,te=new Map;for(let[e,t]of y){ee.set(e,t.length);let r=new Set,i=e=>{for(let t of e)if(`key`in t&&typeof t.key==`string`&&r.add(t.key),t.type===`group`)i(t.fields);else if(t.type===`sub-tabs`)for(let e of t.tabs)i(e.fields)};for(let e of t)i(e.fields);let a=n.filter(e=>r.has(e)).length;a>0&&te.set(e,a)}return i(`div`,{className:`flex flex-col gap-3`,children:[_(hu,{tabs:S.map(e=>({id:e.id,label:e.label})),activeId:A,onChange:j,countByTab:ee,pendingByTab:te}),_(xr,{tabKey:A,children:M===void 0?_(Ar,{schema:P,values:t,onChange:r,onAction:a,disabled:c,visibilityContext:m}):M.content}),F]})}var _u=`device-export`,vu=`export`,yu=`Export`;function bu(e){return e.type===`separator`||e.type===`info`||e.type===`object-array`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`?!1:e.type===`group`?e.fields.some(bu):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(bu)):e.writerCapName===_u}function xu(e){return e.tab===`export`?!0:e.fields.some(bu)}var Su=`host/extensions-panel`;function Cu(e){return e.type===`widget`?e.widgetId===Su:e.type===`group`?e.fields.some(Cu):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(Cu)):!1}function wu(e){return e.fields.some(Cu)}function Tu(e,t){return!t&&e!==void 0&&at.includes(e)}function Eu(e){return e.location!==`top-tab`&&e.location!==`hero`&&!xu(e)&&!wu(e)}function Du(e,t,n,r){return!r||Tu(t,n)?!0:(e??[]).some(Eu)}function Ou(e,t){for(let n of e){if(n.type===`group`){Ou(n.fields,t);continue}if(n.type===`sub-tabs`){for(let e of n.tabs)Ou(e.fields,t);continue}if(!(`value`in n))continue;let e=n.value===void 0?n.default:n.value;e!==void 0&&(t[n.key]=e)}}function ku(e){let t={};for(let n of e)Ou(n.fields,t);return t}w();function Au(e,t){return t&&t===`admin`?e:!0}function ju(e){if(!e)return null;let t={sections:[...e.sections].toSorted((e,t)=>{let n=e.tab??`general`,r=t.tab??`general`;return n===r?xu(e)&&xu(t)?e.id.localeCompare(t.id):(e.order??0)-(t.order??0):n.localeCompare(r)})};return e.tabs?{...t,tabs:e.tabs}:t}function Mu(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`||e.type===`account-sign-in`||e.type===`secret-presence`}function Nu(e){return e.key}function Pu(e){if(!Mu(e))return e.value}function Fu(e){return Mu(e)?null:e}function Iu(e,t){for(let n of e)if(t(n),n.type===`group`)Iu(n.fields,t);else if(n.type===`sub-tabs`)for(let e of n.tabs)Iu(e.fields,t)}function Lu(e){if(!e)return{};let t={};for(let n of e.sections)Iu(n.fields,e=>{let n=Nu(e);n!==null&&(t[n]=Pu(e))});return t}function Ru(e,t){if(!e)return null;let n=null;for(let r of e.sections)if(Iu(r.fields,e=>{if(n!==null||Nu(e)!==t)return;let r=Fu(e);r&&r.writerCapName&&r.writerAddonId&&(n={capName:r.writerCapName,addonId:r.writerAddonId})}),n!==null)break;return n}function zu(e){return{...e,fields:e.fields.map(Bu)}}function Bu(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`object-array`?e:{...e,readonlyField:!0}}function Vu(e,t){return e&&{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{let n=Fu(e);return n?Au(t,n.minRole)?e:Bu(e):e})}))}}var Hu={sections:[]};function Uu({deviceId:e,sectionFilter:t,activeSubTab:n,onSubTabChange:r,flattenSubTabs:a,subTabGrouping:o,leadingTabs:s}){let{t:c}=W(),l=O(),{user:f}=du(),p=f?.isAdmin===!0,m=u(!1),{data:h,isLoading:y}=rn({deviceId:e},{refetchInterval:()=>m.current?!1:2500,enabled:Number.isFinite(e)}),{data:b}=en({deviceId:e},{enabled:Number.isFinite(e)}),x=h?.settings??null,S=h?.live??null,C=d(()=>{if(!x&&!S)return null;let e=x?.sections??[],n=(S?.sections??[]).map(zu),r=[...e,...n],i=t?r.filter(t):r.filter(Eu);if(i.length===0)return null;if(o){let e=i.map(e=>({...e,tab:o.groupOf(e)})),t=new Set(e.map(e=>e.tab)),n=o.tabs.filter(e=>t.has(e.id));return n.length>0?{tabs:n,sections:e}:{sections:e}}let a=new Set;for(let e of i)a.add(e.tab??`general`);let s=[...x?.tabs??[],...(S?.tabs??[]).filter(e=>!(x?.tabs??[]).some(t=>t.id===e.id))].filter(e=>a.has(e.id));return s.length>0?{tabs:s,sections:i}:{sections:i}},[x,S,t,o]),w=d(()=>ku([...x?.sections??[],...S?.sections??[]]),[x,S]),T=d(()=>ju(C),[C]),E=d(()=>Vu(T,p),[T,p]),D=d(()=>Lu(E),[E]),k=Ut(),A=mn(),j=hr(),M=cn(),N=Pn({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),P={isPending:N.isPending,mutate:t=>{N.mutate({deviceId:e,changes:[...t]})}},F=pu({schema:E,serverValues:D,onImmediateSave:g(e=>{let t=Object.entries(e).map(([e,t])=>{let n=Ru(E,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&P.mutate(t)},[E,P]),onDeferredSave:g(async t=>{let n=Object.entries(t).map(([e,t])=>{let n=Ru(E,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);if(n.length!==0)try{let t=await N.mutateAsync({deviceId:e,changes:n});if(t.failures.length>0)throw Error(t.failures.map(e=>e.error).join(`; `))}finally{await l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}},[E,N,e,l])}),{values:ee,pendingKeys:te,handleChange:ne,handleSave:I,handleDiscard:re}=F;m.current=F.editingPaused;let ie=Uc(),ae=u(I),oe=u(re);ae.current=I,oe.current=re;let se=ie?.register,ce=N.isError?N.error instanceof Error?N.error.message:String(N.error):null,L=te.join(`\0`);v(()=>{if(se===void 0)return;let e=L===``?[]:L.split(`\0`);return se({id:`export`,dirty:e.length>0,saving:N.isPending,error:ce,save:()=>(ae.current(e),Promise.resolve()),discard:()=>oe.current(e)})},[se,L,N.isPending,ce]);let R=s!==void 0&&s.length>0;if(y&&!R)return i(`div`,{className:`flex items-center justify-center py-12 text-foreground-subtle`,children:[_(B,{className:`h-4 w-4 animate-spin mr-2`}),_(`span`,{className:`text-xs`,children:c(`device.deviceAggregateSection.loadingDeviceAggregate`,`Loading device aggregate…`)})]});if(!R&&(!E||E.sections.length===0))return _(`div`,{className:`text-xs text-foreground-subtle italic py-4 text-center`,children:c(`device.deviceAggregateSection.noAggregateContributionsForThis`,`No aggregate contributions for this device.`)});async function le(t,n,r){if(t===`regenerate-rtsp-token`){let t=[`rtspUrl:`,`regenerateToken:`].find(e=>n.startsWith(e));if(!t)throw Error(`regenerate-rtsp-token: unrecognised key "${n}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);let r=n.slice(t.length);if(!r)throw Error(`regenerate-rtsp-token: key "${n}" has no streamId after prefix`);let i=ot(e,r);await k.mutateAsync({brokerId:i}),l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]});return}if(t===`test-probe`){if(!b)return{status:`error`,error:c(`device.deviceAggregateSection.metadataNotLoaded`)};try{return await j.mutateAsync({addonId:b.addonId,type:b.type,key:n,value:r})}catch(e){return{status:`error`,error:e instanceof Error?e.message:String(e)}}}if(t===`refresh-probe`){if(!n.startsWith(`probedInfo:`))throw Error(`refresh-probe: unrecognised key "${n}" (expected "probedInfo:<streamId>")`);let t=n.slice(11);if(!t)throw Error(`refresh-probe: key "${n}" has no streamId after prefix`);let r=ot(e,t),i=await A.mutateAsync({brokerId:r});return l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),i}if(t===`device-custom-action`){let t=await M.mutateAsync({deviceId:e,action:n,input:r});return l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),t}throw Error(`[device-aggregate] unknown action "${t}"`)}return _(gu,{schema:E??Hu,values:ee,pendingKeys:te,onChange:ne,onAction:le,onSave:I,onDiscard:re,hideSaveBar:ie!==null,disabled:P.isPending,activeSubTab:n,onSubTabChange:r,flattenTabs:a,leadingTabs:s,visibilityContext:w})}w();function Wu({deviceId:e,onClose:t}){let{t:n}=W(),[r,a]=b(`info`),{data:o}=en({deviceId:e},{enabled:e>0}),s=Bn(e),c=lc(s.presence,s.list),l=r===`history`&&!c?`info`:r,u=typeof o?.name==`string`?o.name:``,d=Ht(e,`full`,u.length>0?u:`#${String(e)}`),f=typeof o?.location==`string`?o.location:``,p=[[`info`,n(`deviceQuickDetail.tabInfo`,{defaultValue:`Device info`})],[`export`,n(`deviceQuickDetail.tabExport`,{defaultValue:`Export`})],...c?[[`history`,n(`deviceQuickDetail.tabHistory`,{defaultValue:`History`})]]:[]];return _(An,{open:!0,onOpenChange:e=>!e&&t(),children:_(un,{width:`lg`,scroll:`body`,children:i(Wc,{deviceId:e,seed:o==null?null:{name:u,location:f,role:typeof o.role==`string`?o.role:null,display:o.display},showOpenFull:!0,onClose:t,children:[_(dn,{children:_(Ft,{children:d})}),_(`div`,{className:`mt-3 flex items-center gap-1 rounded-md bg-surface-hover p-0.5 w-fit`,children:p.map(([e,t])=>_(`button`,{type:`button`,onClick:()=>a(e),className:`px-2.5 py-1 rounded text-[11px] font-medium transition-colors ${l===e?`bg-surface text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`}`,children:t},e))}),_(br,{className:`mt-3`,children:i(fr,{deviceId:e,device:o??void 0,children:[_(`div`,{className:l===`info`?void 0:`hidden`,children:_(kc,{})}),_(`div`,{className:l===`export`?void 0:`hidden`,children:_(Uu,{deviceId:e,sectionFilter:xu})}),c?_(`div`,{className:l===`history`?void 0:`hidden`,children:_(cc,{deviceId:e})}):null]})})]})})})}function Gu({children:e}){let[t,n]=b(null),r=g(e=>n(e),[]),a=g(()=>n(null),[]);return i(pn,{open:r,children:[e,t===null?null:_(Wu,{deviceId:t,onClose:a})]})}w();function Ku({tabs:e,active:t,onChange:n}){return _(`div`,{className:`flex rounded-lg border border-border bg-surface p-0.5 gap-0.5`,children:e.map(e=>_(`button`,{type:`button`,onClick:()=>n(e.id),className:[`flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors`,t===e.id?`bg-primary/12 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`].join(` `),children:e.label},e.id))})}function qu(e){let t=e.formats;if(!t)return``;let n=Object.values(t).filter(e=>e!==void 0&&e.sizeMB>0).map(e=>e.sizeMB);if(n.length===0)return``;let r=Math.min(...n),i=Math.max(...n);return r===i?`${r} MB`:`${r}-${i} MB`}function Ju(e){return`${e.inputSize.width}x${e.inputSize.height}`}function Yu(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function Xu({entry:e,selected:t,onSelect:n,disabled:r}){let{t:a}=W(),o=qu(e),s=Ju(e),c=Yu(e);return i(`button`,{type:`button`,onClick:n,disabled:r,className:[`w-full text-left rounded-lg border p-3 transition-all`,t?`border-primary bg-primary/5 ring-1 ring-primary/30`:`border-border bg-background hover:border-foreground-subtle/40 hover:bg-surface-hover/50`,r?`opacity-50 cursor-not-allowed`:`cursor-pointer`].join(` `),children:[_(`div`,{className:`flex items-start justify-between gap-2`,children:i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`flex items-center gap-2`,children:[_(`span`,{className:`text-xs font-semibold text-foreground truncate`,children:e.name}),t&&_(N,{className:`h-3.5 w-3.5 text-primary shrink-0`})]}),_(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 line-clamp-2`,children:e.description})]})}),i(`div`,{className:`flex items-center gap-3 mt-2 flex-wrap`,children:[i(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[_(Pe,{className:`h-3 w-3`}),s]}),o&&_(`span`,{className:`text-[10px] text-foreground-subtle`,children:o}),c.length>0&&_(`div`,{className:`flex gap-1`,children:c.map(e=>_(`span`,{className:`text-[9px] uppercase rounded bg-surface border border-border px-1 py-0.5 text-foreground-subtle font-mono`,children:e},e))}),e.labels.length>0&&_(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`common.labels`,{count:e.labels.length})})]})]})}function Zu({field:e,value:t,onChange:n,disabled:r}){let{t:a}=W(),o=e.catalog??[],s=o.length>0,c=lt(o).length>0,l=e.allowCustomPath!==!1||e.allowCustom===!0,u=[...s?[{id:`catalog`,label:a(`formBuilder.modelSelector.models`,`Models ({{length}})`,{length:o.length})}]:[],...l?[{id:`custom`,label:a(`formBuilder.modelSelector.customPath`,`Custom Path`)}]:[]],[d,f]=b(s?`catalog`:`custom`),p=t==null?``:String(t);return i(`div`,{className:`space-y-3`,children:[u.length>1&&_(Ku,{tabs:u,active:d,onChange:f}),d===`catalog`&&s&&c&&_(Yn,{catalog:o,value:p,onChange:e=>n(e),disabled:r||e.disabled}),d===`catalog`&&s&&!c&&_(`div`,{className:`space-y-1.5 max-h-[320px] overflow-y-auto pr-1`,children:o.filter(e=>e.legacy!==!0).map(t=>_(Xu,{entry:t,selected:p===t.id,onSelect:()=>n(t.id),disabled:r||e.disabled},t.id))}),d===`catalog`&&!s&&i(`div`,{className:`rounded-md border border-info/30 bg-info/5 px-3 py-2 flex items-start gap-2`,children:[_(Xe,{className:`h-3.5 w-3.5 text-info shrink-0 mt-0.5`}),_(`p`,{className:`text-[11px] text-foreground-subtle leading-relaxed`,children:a(`formBuilder.modelSelector.noPredefinedModelsAvailableUse`,`No predefined models available. Use the Custom Path tab to specify a model file path or URL.`)})]}),d===`custom`&&l&&i(`div`,{className:`space-y-2`,children:[_(`input`,{type:`text`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none disabled:opacity-50`,placeholder:a(`formBuilder.modelSelector.enterPathLikeDataModels`,`Enter path like /data/models/custom.onnx or https://...`),value:p,disabled:r||e.disabled,onChange:e=>n(e.target.value)}),e.acceptFormats&&e.acceptFormats.length>0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:[a(`formBuilder.modelSelector.acceptedFormats`,`Accepted formats:`),` `,e.acceptFormats.join(`, `)]})]}),(e.compatibilityNote||e.conversionGuideUrl)&&i(`div`,{className:`flex items-start justify-between gap-3 pt-1`,children:[e.compatibilityNote&&i(`p`,{className:`flex items-start gap-1 text-[10px] text-foreground-subtle`,children:[_(Xe,{className:`h-3 w-3 mt-0.5 shrink-0`}),e.compatibilityNote]}),e.conversionGuideUrl&&i(`a`,{href:e.conversionGuideUrl,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-[11px] text-primary hover:underline shrink-0`,children:[a(`formBuilder.modelSelector.howToConvertYourModel`,`How to convert your model`),_(He,{className:`h-3 w-3`})]})]})]})}function Qu({to:e}){let{search:t}=Y();return _(X,{to:`${e}${t}`,replace:!0})}w();function $u(){return U.t(`helpers.keychainRevealHost.forbidden`)}function ed(e){if(typeof e!=`object`||!e)return null;let t=Reflect.get(e,`data`);if(typeof t!=`object`||!t)return null;let n=Reflect.get(t,`code`);return typeof n==`string`?n:null}function td(e){let t=ed(e);if(t===`FORBIDDEN`||t===`UNAUTHORIZED`)return $u();let n=e instanceof Error?e.message:String(e);return n.length>0?U.t(`helpers.keychainRevealHost.failedWith`,{message:n}):U.t(`helpers.keychainRevealHost.failed`)}function nd({children:e}){let t=vn();return _($t,{reveal:g(async e=>{try{return(await t.mutateAsync({ref:e})).value}catch(e){throw Error(td(e))}},[t]),children:e})}w();function rd(){let e=Oe(),t=O(),[n,r]=b(()=>e.isConnected()?`connected`:`disconnected`),i=u(!1),[a,o]=b(0),[s,c]=b([]);v(()=>e.subscribeConnectionEvents(e=>{r(t=>(t!==`connected`&&e===`connected`&&i.current&&o(e=>e+1),e!==`connected`&&(i.current=!0),e))}),[e]),v(()=>{a!==0&&t.invalidateQueries({queryKey:[[`addons`,`getLastRestart`]]})},[a,t]);let{data:l}=Tr(void 0,{enabled:n===`connected`&&a>0,staleTime:0,refetchOnMount:!1,refetchOnWindowFocus:!1}),d=u(null);return v(()=>{if(l==null||l.requestedAt===d.current)return;d.current=l.requestedAt;let e=ad(l);c(t=>[...t,e]);let t=window.setTimeout(()=>{c(t=>t.filter(t=>t.id!==e.id))},6e3);return()=>window.clearTimeout(t)},[l]),_(A,{children:s.length>0&&_(id,{toasts:s})})}function id({toasts:e}){return _(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex flex-col gap-2 max-w-sm w-full pointer-events-none`,children:e.map(e=>i(`div`,{className:`pointer-events-auto flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm`,children:[_(Ye,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),i(`div`,{children:[_(`div`,{className:`text-[11px] font-semibold text-foreground`,children:e.title}),_(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:e.message})]})]},e.id))})}function ad(e){let t=`restart-${e.requestedAt}`;if(e.kind===`framework-update`&&e.packageName!==void 0&&e.toVersion!==void 0){let n=e.fromVersion===void 0?`v${e.toVersion}`:`v${e.fromVersion} → v${e.toVersion}`;return{id:t,title:U.t(`system.reconnectOverlay.frameworkUpdated`,`Framework updated`),message:U.t(`system.reconnectOverlay.isNow`,`{{packageName}} is now {{fromTo}}.`,{packageName:e.packageName,fromTo:n})}}return{id:t,title:U.t(`system.reconnectOverlay.serverRestarted`,`Server restarted`),message:e.requestedBy===void 0?U.t(`system.reconnectOverlay.manualRestartCompleted`,`Manual restart completed.`):U.t(`system.reconnectOverlay.manualRestartByCompleted`,`Manual restart by {{requestedBy}} completed.`,{requestedBy:e.requestedBy})}}var od=`/system/settings`,sd=[{path:`/system/secrets`,tab:`secrets`},{path:`/system/capabilities`,tab:`capabilities`}];function cd(e,t=``){let n=new URLSearchParams(t);return n.delete(`tab`),n.set(`tab`,e),`${od}?${n.toString()}`}function ld({tab:e}){let{search:t,hash:n}=Y();return _(X,{to:`${cd(e,t)}${n}`,replace:!0})}var ud=new Set;function dd(e){for(let t of ud)t(e)}function fd(e){return ud.add(e),()=>{ud.delete(e)}}w();var pd={info:{bg:`bg-info/10`,border:`border-info/30`,icon:Xe},warning:{bg:`bg-warning/10`,border:`border-warning/30`,icon:$e},critical:{bg:`bg-danger/10`,border:`border-danger/30`,icon:F}};function md({toast:e,onDismiss:t}){let n=pd[e.severity]??pd.info,r=n.icon;return v(()=>{let n=e.duration??5e3;if(n<=0)return;let r=setTimeout(()=>t(e.id),n);return()=>clearTimeout(r)},[e.id,e.duration,t]),i(`div`,{className:`flex items-start gap-3 px-4 py-3 rounded-lg border ${n.border} ${n.bg} shadow-lg backdrop-blur-sm animate-in slide-in-from-right-5 fade-in duration-200`,children:[_(r,{className:`h-4 w-4 shrink-0 mt-0.5 text-foreground-subtle`}),i(`div`,{className:`flex-1 min-w-0`,children:[_(`div`,{className:`text-xs font-semibold text-foreground`,children:e.title}),_(`div`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:e.message})]}),_(`button`,{type:`button`,onClick:()=>t(e.id),className:`shrink-0 p-0.5 rounded hover:bg-surface-hover transition-colors`,children:_(Ae,{className:`h-3.5 w-3.5 text-foreground-subtle`})})]})}function hd(){let[e,t]=b([]),n=g(e=>{t(t=>t.filter(t=>t.id!==e))},[]),r=g(e=>{let n=`toast-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;t(t=>[...t,{...e,id:n,timestamp:Date.now()}])},[]);return Xn(void 0,{onData:e=>r(e)}),v(()=>fd(r),[r]),e.length===0?null:_(`div`,{className:`fixed bottom-[calc(env(safe-area-inset-bottom)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex flex-col gap-2 max-w-sm w-full pointer-events-none`,children:e.map(e=>_(`div`,{className:`pointer-events-auto`,children:_(md,{toast:e,onDismiss:n})},e.id))})}function gd(e){return(t,n,r)=>e(t,{...typeof n==`string`?{defaultValue:n}:{defaultValue_one:n.one,defaultValue_other:n.other},...r})}var _d=(e,t,n)=>gd(U.t.bind(U))(e,t,n);w();function vd({children:e}){let{t}=W();return _(Ee,{t:d(()=>gd(t),[t]),children:e})}w();function yd(e){if(typeof e!=`object`||!e)return;let{data:t}=e;return t?.code}function bd(e,t){let n=yd(e);return n===`UNAUTHORIZED`||n===`FORBIDDEN`?!0:/UNAUTHORIZED|FORBIDDEN/.test(t)}function xd(e,t,n,r){let[i,a]=b(!1),[o,s]=b(null);return v(()=>{if(a(!1),s(null),!t){a(!0);return}let i=!1;e.init().catch(()=>void 0);let o=t=>{e.awaitConnected().then(()=>{i||a(!0)},e=>{if(i)return;let c=e instanceof Error?e.message:String(e);if(bd(e,c)){if(t&&r!==void 0){r().then(e=>{if(!i){if(e){o(!1);return}console.warn(`[boot-gate] logout: probe UNAUTHORIZED and the refresh was refused`),n()}},()=>{i||(console.warn(`[boot-gate] logout: probe UNAUTHORIZED and recovery failed`),n())});return}console.warn(`[boot-gate] logout: probe UNAUTHORIZED after a successful refresh`,c),n();return}s(c),a(!0)})};return o(!0),()=>{i=!0}},[e,t,n,r]),{bootReady:i,bootError:o}}w();var Sd=3e4;function Cd(e){let t=u(e);t.current=e,v(()=>{let e=null,n=()=>{if(document.visibilityState===`hidden`){e=Date.now();return}if(document.visibilityState===`visible`&&e!==null){let n=Date.now()-e;e=null,n>=Sd&&t.current()}},r=()=>{t.current()},i=e=>{e.persisted&&t.current()};return document.addEventListener(`visibilitychange`,n),window.addEventListener(`online`,r),window.addEventListener(`pageshow`,i),()=>{document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`online`,r),window.removeEventListener(`pageshow`,i)}},[])}w();function wd(){let{t:e}=W();return i(`div`,{role:`status`,"aria-busy":`true`,"aria-label":e(`layouts.addonPageLoader.loading`,`Loading page`),"data-testid":`addon-page-loading`,className:`flex flex-col gap-4 p-2 sm:p-4`,children:[_(Qt,{className:`h-7 w-48`}),_(Qt,{className:`h-5 w-72 max-w-full`}),_(Qt,{className:`h-40`})]})}function Td({message:e}){let{t}=W();return _(`div`,{className:`p-2 sm:p-4`,"data-testid":`addon-page-error`,children:_(V,{title:t(`layouts.addonPageLoader.failedTitle`,`This page could not be shown`),message:e})})}var Ed=class extends o{state={error:null,resetKey:this.props.resetKey};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}static getDerivedStateFromProps(e,t){return e.resetKey===t.resetKey?null:{error:null,resetKey:e.resetKey}}componentDidCatch(e,t){console.error(`[addon-page] ${this.props.resetKey} crashed`,e,t.componentStack)}render(){return this.state.error===null?this.props.children:_(Td,{message:this.state.error.message})}};function Dd({resetKey:e,children:t}){return _(Ed,{resetKey:e,children:t})}function Od({pageKey:e,children:t}){return _(Ed,{resetKey:e,children:_(h,{fallback:_(wd,{}),children:t})})}w();function kd(e){let t=new Set,n=new Set,r=e=>e.page.remoteName.includes(e.addonId.replace(/[^a-zA-Z0-9]+/g,`_`)),i=[...e.filter(r),...e.filter(e=>!r(e))],a=[];for(let e of i){let r=`${e.addonId}::${e.page.id}`;t.has(r)||n.has(e.page.path)||(t.add(r),n.add(e.page.path),a.push({id:e.page.id,addonId:e.addonId,label:e.page.label,icon:e.page.icon,path:e.page.path,remoteName:e.page.remoteName,bundle:e.page.bundle,bundleUrl:e.bundleUrl,...e.page.section===void 0?{}:{section:e.page.section},...e.page.sectionLabel===void 0?{}:{sectionLabel:e.page.sectionLabel}}))}return a}var Ad=2e4;function jd(e,t){let[n,r]=b(!1);return v(()=>{if(!e){r(!1);return}let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}var Md=new Map,Nd=new Map,Pd=new Set;function Fd(e){return!e||typeof e!=`object`?!1:typeof e.default==`function`}async function Id(n,r){let i=Md.get(n);if(i)return i;let a=Nd.get(n);if(a)return a;Pd.has(n)||(Fn(),t([{name:n,entry:z(r),type:`module`}],{force:!1}),Pd.add(n));let o=e(`${n}/page`).then(e=>{if(!Fd(e))throw Error(`Addon page remote ${n} (${r}) does not expose a default React component on './page'`);return Md.set(n,e.default),Nd.delete(n),e.default}).catch(e=>{throw Nd.delete(n),e});return Nd.set(n,o),o}function Ld(){let{t:e}=W(),{pagePath:t}=ma(),n=ua(),r=Oe(),{data:i,isError:a,error:o}=on(void 0),s=d(()=>i?kd(i):void 0,[i]),c=s?.find(e=>e.path===`/addon/${t}`),l=c?.remoteName,u=c?.bundleUrl,[f,p]=b(null),[m,h]=b(null);v(()=>{if(!l||!u)return;h(null);let e=Md.get(l);if(e){p(()=>e);return}p(null);let t=!1;return Id(l,u).then(e=>{t||p(()=>e)}).catch(e=>{t||h(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[l,u]);let g=jd(!s&&!a,Ad),y=jd(c!==void 0&&!f&&!m,Ad);return s?c?m?_(Td,{message:m}):f?_(Od,{pageKey:c.remoteName,children:_(f,{trpc:r.trpcClient,theme:{isDark:document.documentElement.classList.contains(`dark`)},navigate:e=>{n(e.startsWith(`/`)?e:`/${e}`)}})}):y?_(Td,{message:e(`layouts.addonPageLoader.remoteStalled`,`The page did not load. Its addon may be starting or unreachable.`)}):_(wd,{}):_(`div`,{className:`flex items-center justify-center h-full text-foreground-subtle`,children:e(`layouts.addonPageLoader.addonPageNotFound`,`Addon page not found`)}):a?_(Td,{message:o?.message??e(`layouts.addonPageLoader.listFailed`,`The page list could not be loaded.`)}):g?_(Td,{message:e(`layouts.addonPageLoader.listStalled`,`The hub did not send the page list. Try again in a moment.`)}):_(wd,{})}var Rd={"/system/pipeline":`pipeline-orchestrator`,"/system/history":`device-history`,"/system/ai":`llm`};function zd(e,t){return e.filter(e=>!e.adminOnly||t).map(e=>{let t=Rd[e.path];return t===void 0?e:{...e,requiresCapability:t}})}function Bd({t:e,isAdmin:t}){let n=zd([{label:e(`nav.devices`,`Devices`),icon:ne,path:`/devices`},{label:e(`nav.integrations`),icon:I,path:`/integrations`},{label:e(`nav.build`,`Build-your-self`),icon:Le,path:`/build`,adminOnly:!0},{label:e(`nav.locations`,`Locations`),icon:Te,path:`/locations`,adminOnly:!0},{label:e(`nav.viewer`,`Viewer`),icon:ft,path:`/live`}],t),r=zd([{label:e(`nav.library`,`Library`),icon:yt,path:`/library`,adminOnly:!0,keywords:[`People`,`Vehicles`,`Events`,`Scenes`,`plates`,`faces`,`detection-intelligence`]},{label:e(`nav.recordings`,`Recordings`),icon:oe,path:`/recordings`,adminOnly:!0}],t),i=zd([{label:e(`nav.nodes`,`Nodes`),icon:ce,path:`/system/nodes`,adminOnly:!0},{label:e(`nav.history`,`History`),icon:Ie,path:`/system/history`,adminOnly:!0,keywords:[`charts`,`graphs`,`energy`,`temperature`,`metrics`,`trends`]},{label:e(`nav.pipeline`,`Pipeline`),icon:ht,path:`/system/pipeline`},{label:e(`system.addons`),icon:R,path:`/system/addons`,adminOnly:!0},{label:e(`system.ai`,`AI`),icon:Ue,path:`/system/ai`,adminOnly:!0}],t),a=zd([{label:e(`system.identity`,`Identity & Access`),icon:qe,path:`/system/identity`,adminOnly:!0},{label:e(`system.network`,`Network`),icon:mt,path:`/system/network`,adminOnly:!0},{label:e(`system.integrations`,`Connectivity`),icon:I,path:`/system/integrations`,adminOnly:!0},{label:e(`system.data`,`Data`),icon:Be,path:`/system/data`,adminOnly:!0},{label:e(`system.notifications`,`Notifications`),icon:ie,path:`/system/notifications`,adminOnly:!0},{label:e(`system.calendars`,`Calendars`),icon:dt,path:`/system/calendars`,adminOnly:!0},{label:e(`system.templates`,`Templates`),icon:Dt,path:`/system/templates`,adminOnly:!0},{label:e(`system.systemNav`,`System`),icon:ke,path:od,adminOnly:!0},{label:e(`system.logs`,`Logs`),icon:Ze,path:`/system/logs`,adminOnly:!0},{label:e(`system.terminal`,`Terminal`),icon:xt,path:`/system/terminal`,adminOnly:!0}],t);return[{key:`top`,label:null,items:n},{key:`detection`,label:e(`nav.detectionSection`,`Detection`),items:r},{key:`cluster`,label:e(`nav.clusterSection`,`Cluster`),items:i},{key:`administration`,label:e(`system.title`,`Administration`),items:a}]}var Vd={gauge:re,puzzle:R,bot:P,cpu:Pe,terminal:xt,box:Qe,boxes:Qe,monitor:ft,wrench:be,activity:Re,plug:I,"graduation-cap":fe};function Hd(e){return Vd[e]??R}function Ud(e,t){for(let n of Bd(t))for(let t of n.items)if(t.path===e)return{icon:t.icon,title:t.label,path:t.path};return null}var Wd=`/system/addons`;function Gd({path:e,children:t}){let n=Rd[e];return n===void 0?_(A,{children:t}):_(Kd,{path:e,capability:n,children:t})}function Kd({path:e,capability:t,children:n}){let{t:r}=W(),a=ua(),o=Gt(t);if(o===`present`)return _(A,{children:n});if(o===`pending`)return i(`div`,{className:`flex flex-col gap-4 p-2 sm:p-4`,"data-testid":`page-presence-pending`,children:[_(Qt,{className:`h-7 w-48`}),_(Qt,{className:`h-40`})]});if(o===`unknown`)return _(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-presence-unknown`,children:_(V,{title:r(`pageRequires.unknownTitle`,`Could not check whether this page is available`),message:r(`pageRequires.unknown`,`The hub did not answer the capability check. Reload the page to try again.`)})});let s=Ud(e,{t:r,isAdmin:!0});return _(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-not-installed`,children:_(Lt,{icon:s?.icon??R,title:r(`pageRequires.absentTitle`,`{{page}} is not installed`,{page:s?.title??e}),description:r(`pageRequires.absentDescription`,`The addon that provides this page is not installed. Install it from System → Addons.`),action:_(H,{variant:`primary`,onClick:()=>a(Wd),children:r(`pageRequires.openAddons`,`Open Addons`)})})})}function qd({capability:e,children:t}){return _(A,{children:t(Gt(e)===`absent`)})}function Jd({children:e}){return _(zn,{value:Yd(Qn({})),children:e})}function Yd(e){return e.data===void 0?e.isPending?{status:`pending`}:{status:`unknown`,reason:e.isError?String(e.error):`no palette`}:e.data.status===`unknown`?{status:`unknown`,reason:e.data.reason}:{status:`ready`,palette:e.data}}function Xd(){let e=gr(),{t}=W();return e.status===`unknown`?_(`p`,{role:`status`,className:`shrink-0 px-4 py-1 text-xs text-warning`,children:t(`pipeline.palette.unknown`,`The stored palette cannot be read ({{reason}}). Boxes use the bundled CamStack preset.`,{reason:e.reason})}):null}Er();var Zd=/\p{Mn}/gu;function Qd(e){return e.normalize(`NFD`).replace(Zd,``).toLowerCase().trim()}var $d=[`device`,`page`,`integration`],ef=0,tf=1,nf=2,rf=3,af=4,of=5,sf=6,cf=7;function lf(e,t,n,r){return n.includes(r)?ef:e===r?tf:e.startsWith(r)?nf:e.split(/\s+/).some(e=>e.startsWith(r))?rf:e.includes(r)?af:t.some(e=>e.includes(r))?of:null}function uf(e,t){let n=0;for(let r=0;r<e.length&&n<t.length;r++)e[r]===t[n]&&n++;return n===t.length}function df(e){return e<4?0:e<=7?1:e<=12?2:3}function ff(e,t,n){if(e===t)return 0;if(n<=0||Math.abs(e.length-t.length)>n)return null;let r=t.length,i=Array(r+1).fill(0),a=Array.from({length:r+1},(e,t)=>t),o=Array(r+1).fill(0);for(let s=1;s<=e.length;s++){o[0]=s;let c=s,l=e[s-1];for(let n=1;n<=r;n++){let r=t[n-1],u=l===r?0:1,d=Math.min((a[n]??1/0)+1,o[n-1]+1,(a[n-1]??1/0)+u);s>1&&n>1&&l===t[n-2]&&e[s-2]===r&&(d=Math.min(d,(i[n-2]??1/0)+1)),o[n]=d,d<c&&(c=d)}if(c>n)return null;let u=i;i=a,a=o,o=u}let s=a[r]??1/0;return s<=n?s:null}function pf(e,t){if(uf(e,t))return sf;let n=df(t.length);if(n>0){for(let r of e.split(/\s+/))if(ff(r,t,n)!==null)return cf}return null}function mf(e,t,n=200){let r=Qd(t);if(r.length===0)return{groups:[],totalMatched:0,truncated:!1};let i=new Map;for(let t of e){let e=Qd(t.label),n=lf(e,(t.keywords??[]).map(Qd),(t.identifiers??[]).map(Qd),r)??pf(e,r);if(n===null)continue;let a=i.get(t.domain)??[];a.push({item:t,rank:n}),i.set(t.domain,a)}let a=0;for(let e of i.values())a+=e.length;let o=n,s=[];for(let e of $d){let t=i.get(e);if(!t||t.length===0||o<=0)continue;t.sort((e,t)=>e.rank-t.rank||e.item.label.localeCompare(t.item.label));let n=t.slice(0,o).map(e=>e.item);o-=n.length,s.push({domain:e,items:n})}return{groups:s,totalMatched:a,truncated:a>n}}function hf(e){return e.flatMap(e=>e.items)}var gf=`instance`;function _f(e,t){let n=t[0];if(n===void 0)return null;let r=t.find(t=>t.id===e);return r===void 0?n.id:r.id}function vf(e,t){let n=`/integrations/${encodeURIComponent(e)}`;return t===void 0||t.length===0?n:`${n}?${gf}=${encodeURIComponent(t)}`}var yf=` · `;function bf(e,t,n,r){let i=[`#${t}`];return r!==void 0&&i.push(r),e.stableId.length>0&&e.stableId!==n&&i.push(e.stableId),i.push(e.type),e.disabled&&i.push(`disabled`),i.join(yf)}function xf(e,t=null){let n=yn(e),r=or(U.language.startsWith(`it`)?`it`:`en`),i=xn(e),a=zt(t);return e.map(e=>{let t=String(e.id),o=fn(e,`compact`,i,r),s=o.length>0?o:e.stableId||`#${t}`,c=n.get(e.id),l=c!==void 0&&(s===c||s.split(yf).includes(c)),u=a(e),d=u.kind===`resolved`?u.integration.name:``;return{key:`device:${t}`,domain:`device`,label:s,subtitle:bf(e,t,s,l?void 0:c),identifiers:[t,`#${t}`],keywords:[...e.name.length>0&&e.name!==s?[e.name]:[],e.stableId,e.addonId,e.location??``,c??``,d].filter(e=>e.length>0),path:`/devices/${t}`,icon:lr(e.type).icon}})}function Sf(e){return e.map(e=>({key:`integration:${e.id}`,domain:`integration`,label:e.name||e.addonId,subtitle:e.enabled?e.addonId:U.t(`helpers.searchItems.disabled`,{addonId:e.addonId}),keywords:[e.addonId,e.processState],path:vf(e.addonId,e.id)}))}function Cf(e,t,n){let r=e.section?.trim();return r?t[r]??e.sectionLabel?.trim()??r:n}function wf(e,t,n){let r=e.flatMap(e=>e.items.map(t=>({key:`page:${t.path}`,domain:`page`,label:t.label,subtitle:e.label??void 0,path:t.path,icon:t.icon,...t.keywords!==void 0&&t.keywords.length>0?{keywords:t.keywords}:{}}))),i={detection:n.detection,cluster:n.cluster,administration:n.administration},a=t.map(e=>({key:`page:addon:${e.addonId}:${e.id}`,domain:`page`,label:e.label,subtitle:Cf(e,i,n.ungrouped),keywords:[e.addonId],path:e.path,icon:Hd(e.icon)}));return[...r,...a]}w();var Tf={device:{labelKey:`search.resultsList.devices`,icon:ne},page:{labelKey:`search.resultsList.pages`,icon:bt},integration:{labelKey:`search.resultsList.integrations`,icon:I}};function Ef({groups:e,activeKey:t,query:n,totalMatched:r,truncated:a,onSelect:o,onHover:s}){let{t:c}=W(),l=u(null);if(v(()=>{t&&(l.current?.querySelector(`[data-key="${CSS.escape(t)}"]`))?.scrollIntoView({block:`nearest`})},[t]),n.trim().length===0)return null;if(e.length===0)return _(`div`,{className:`px-3 py-4 text-center text-[12px] text-foreground-subtle`,children:c(`search.resultsList.noResults`,{query:n})});let d=e.reduce((e,t)=>e+t.items.length,0);return i(A,{children:[_(`div`,{ref:l,role:`listbox`,className:`max-h-[60vh] overflow-y-auto py-1`,children:e.map(e=>{let n=Tf[e.domain],r=n.icon;return i(`div`,{className:`px-1 py-1`,children:[i(`div`,{className:`sticky top-0 z-10 flex items-center gap-1.5 bg-surface px-2 py-1 text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:[_(r,{className:`h-3 w-3`}),c(n.labelKey)]}),e.items.map(e=>{let r=e.icon??n.icon,a=e.key===t;return i(`button`,{type:`button`,role:`option`,"aria-selected":a,"data-key":e.key,onMouseEnter:()=>s(e),onClick:()=>o(e),className:`flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-[12px] transition-colors ${a?`bg-primary/12 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[_(r,{className:`h-3.5 w-3.5 shrink-0 ${a?`text-primary`:`text-foreground-subtle`}`}),i(`span`,{className:`flex-1 min-w-0`,children:[_(`span`,{className:`block truncate font-medium`,children:e.label}),e.subtitle&&_(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:e.subtitle})]})]},e.key)})]},e.domain)})}),a&&_(`div`,{className:`border-t border-border px-3 py-1.5 text-center text-[10px] text-foreground-subtle`,children:c(`search.truncatedResults`,`Showing first {{shown}} of {{total}} — refine your search.`,{shown:d,total:r})})]})}w();function Df({navSections:e,addonPages:t,compact:n,onNavigated:r}){let{t:a}=W(),o=ua(),s=u(null),c=u(null),l=u(null),[f,p]=b(null),[m,h]=b(``),[y,x]=b(0),[S,C]=b(!1),{data:w}=Wt({projection:`slim`}),{data:T}=Rt(void 0),E=d(()=>{let n={detection:a(`nav.detectionSection`,`Detection`),cluster:a(`nav.clusterSection`,`Cluster`),administration:a(`system.title`,`Administration`),ungrouped:a(`nav.addonPages`,`Addon Pages`)};return[...xf(w??[],T??null),...wf(e,t,n),...Sf(T??[])]},[w,T,e,t,a]),{groups:D,totalMatched:O,truncated:k}=d(()=>mf(E,m),[E,m]),A=d(()=>hf(D),[D]);v(()=>{x(0)},[m,E]),v(()=>{S&&s.current?.focus()},[S]);let j=g(()=>{C(!1),h(``),x(0)},[]),M=g(e=>{o(e.path),j(),s.current?.blur(),r?.()},[o,j,r]);Kt(s,{scope:bn}),v(()=>{if(!S)return;function e(e){if(!(e.target instanceof Node))return;let t=c.current?.contains(e.target)===!0,n=l.current?.contains(e.target)===!0;!t&&!n&&C(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[S]);let N=S&&m.trim().length>0;v(()=>{if(!N){p(null);return}let e=()=>{let e=s.current?.getBoundingClientRect();e&&p({left:e.left,top:e.bottom+4,width:e.width})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[N]);let P=A[y]?.key??null,F=a(`search.placeholder`,`Search devices, pages, integrations…`),ee=i(`div`,{className:`relative`,children:[_(Je,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`}),_(`input`,{ref:s,type:`text`,value:m,placeholder:F,"aria-label":F,role:`combobox`,"aria-expanded":S&&m.trim().length>0,"aria-controls":`global-search-results`,onChange:e=>{h(e.target.value),C(!0)},onFocus:()=>C(!0),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),A.length>0&&x(e=>(e+1)%A.length);else if(e.key===`ArrowUp`)e.preventDefault(),A.length>0&&x(e=>(e-1+A.length)%A.length);else if(e.key===`Enter`){e.preventDefault();let t=A[y];t&&M(t)}else e.key===`Escape`&&(e.preventDefault(),j(),s.current?.blur())},className:`w-full rounded-md border border-border bg-surface py-1.5 pl-7 pr-6 text-[12px] text-foreground placeholder:text-foreground-subtle/70 focus:outline-none focus:ring-1 focus:ring-primary/50`}),m.length>0&&_(`button`,{type:`button`,"aria-label":a(`search.globalSearch.clearSearch`,`Clear search`),onClick:()=>{h(``),s.current?.focus()},className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground`,children:_(Ae,{className:`h-3 w-3`})}),N&&f!==null&&Dr(_(`div`,{ref:l,id:`global-search-results`,className:`fixed z-50 w-max max-w-[26rem] rounded-lg border border-border bg-surface shadow-xl`,style:{left:f.left,top:f.top,minWidth:f.width},children:_(Ef,{groups:D,activeKey:P,query:m,totalMatched:O,truncated:k,onSelect:M,onHover:e=>{let t=A.findIndex(t=>t.key===e.key);t>=0&&x(t)}})}),document.body)]});return n?_(`div`,{ref:c,className:`px-1.5 pb-1.5`,children:S?_(`div`,{className:`fixed z-50 w-max min-w-72 max-w-[26rem]`,style:{left:`calc(env(safe-area-inset-left) + 3.5rem)`,top:`calc(env(safe-area-inset-top) + 3.5rem)`},children:ee}):_(`button`,{type:`button`,onClick:()=>C(!0),"aria-label":F,title:F,className:`flex w-full items-center justify-center rounded-md px-0 py-2 text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,children:_(Je,{className:`h-3.5 w-3.5 shrink-0`})})}):_(`div`,{ref:c,className:`px-2 pb-2`,children:ee})}var Of=/^(\d{1,3}\.){3}\d{1,3}$/;function kf(e){let t=e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e;return!!(Of.test(t)||t.includes(`:`))}function Af(e,t){return!t||kf(e)?!1:e===t||e.endsWith(`.${t}`)}w();var jf=`auth-webauthn/passkey-enrollment`,Mf=`camstack_passkey_prompt_dismissed:`,Nf=720*60*60*1e3;function Pf(e){try{let t=localStorage.getItem(`${Mf}${e}`);if(!t)return!1;let n=Number(t);return Number.isFinite(n)?Date.now()-n<Nf:!1}catch{return!1}}function Ff(e){try{localStorage.setItem(`${Mf}${e}`,String(Date.now()))}catch{}}function If(){let{user:e}=du(),{t}=W(),n=Oe(),r=At(jf),[a,o]=b(!1),[s,c]=b(!1),l=d(()=>e?Pf(e.id):!0,[e]),u=pr.auth.listLoginMethods.useQuery().data?.find(e=>e.kind===`passkey`),f=u!==void 0&&Af(window.location.hostname,u.rpId),p=e!==null&&f&&r!=null&&!l,m=S({queryKey:[`auth`,`listOwnPasskeys`],queryFn:()=>n.listOwnPasskeys(),enabled:p,staleTime:6e4}),h=g(()=>{e&&Ff(e.id),o(!0),c(!1)},[e]),v=g(()=>{c(!1),m.refetch()},[m]);return!p||a||m.data===void 0||m.data.length>0?null:i(`div`,{className:`shrink-0 border-b border-primary/20 bg-primary/5`,children:[i(`div`,{className:`flex items-center gap-2.5 px-3 py-2 text-xs text-foreground`,children:[_(Ct,{className:`h-4 w-4 text-primary shrink-0`}),_(`span`,{className:`flex-1 min-w-0`,children:t(`passkeyPrompt.message`,`Save a passkey for faster sign-in?`)}),_(`button`,{onClick:()=>c(e=>!e),className:`rounded bg-primary px-2.5 py-1 text-[11px] font-semibold text-primary-foreground hover:bg-primary/90`,children:t(`passkeyPrompt.enrollNow`,`Enroll now`)}),_(`button`,{onClick:h,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:t(`passkeyPrompt.notNow`,`Not now`)}),_(`button`,{onClick:h,"aria-label":t(`passkeyPrompt.notNow`,`Not now`),className:`p-1 rounded text-foreground-subtle hover:text-foreground`,children:_(Ae,{className:`h-3.5 w-3.5`})})]}),s&&_(`div`,{className:`px-3 pb-3`,children:i(`div`,{className:`max-w-xl`,children:[_(Sr,{widgetId:jf,host:`dashboard`}),_(`div`,{className:`mt-2 flex justify-end`,children:_(`button`,{onClick:v,className:`rounded border border-border px-2.5 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:t(`common.close`,`Close`)})})]})})]})}var Lf=6e4;function Rf(){let e=cr(void 0,{staleTime:Lf});return{info:e.data?.serverName??null,isLoading:e.isLoading}}w();var zf=`system-config`,Bf=`hub`,Vf=`camstack_server_name_prompt_dismissed`;function Hf(){try{return sessionStorage.getItem(Vf)===`1`}catch{return!1}}function Uf(){try{sessionStorage.setItem(Vf,`1`)}catch{}}function Wf(e){return e.isAdmin&&e.info!==null&&e.info.isDefault&&!e.dismissed}function Gf(){let{user:e}=du(),{info:t}=Rf(),[n,r]=b(Hf);return Wf({isAdmin:e?.isAdmin===!0,info:t,dismissed:n})?_(Kf,{suggestion:t?.name??``,onLater:()=>{Uf(),r(!0)}}):null}function Kf({suggestion:e,onLater:t}){let{t:n}=W(),r=O(),a=nn(),[o,s]=b(e),[c,l]=b(null),d=u(null);v(()=>d.current?.focus(),[]);let f=g(async()=>{let e=rt.safeParse(o);if(!e.success){l(e.error.issues[0]?.message??n(`serverName.invalid`,`Not a valid name`));return}l(null);try{await a.mutateAsync({addonId:zf,nodeId:Bf,patch:{name:e.data}}),await r.invalidateQueries({queryKey:[[`system`,`info`]]}),await r.invalidateQueries({queryKey:[[`addonSettings`]]})}catch(e){l(e instanceof Error&&e.message.length>0?e.message:`Could not save`)}},[r,a,n,o]);return _(An,{open:!0,onOpenChange:e=>!e&&t(),children:_(un,{children:i(`form`,{onSubmit:e=>{e.preventDefault(),a.isPending||f()},children:[i(dn,{children:[_(Ft,{children:n(`serverName.title`,`Name this server`)}),_(Pt,{children:n(`serverName.description`,`Pick a name for this hub. It shows in the admin UI and on the apps’ sign-in screen. You can change it later in System settings.`)})]}),_(br,{children:_(It,{label:n(`serverName.label`,`Server name`),...c===null?{}:{error:c},children:_(wr,{ref:d,value:o,maxLength:48,onChange:e=>s(e.target.value),state:c===null?`default`:`error`,"aria-label":n(`serverName.label`,`Server name`)})})}),i(_r,{children:[_(H,{type:`button`,variant:`ghost`,onClick:t,disabled:a.isPending,children:n(`serverName.later`,`Later`)}),i(H,{type:`submit`,disabled:a.isPending||o.trim().length===0,children:[a.isPending&&_(B,{className:`h-4 w-4 animate-spin`}),n(`common.save`,`Save`)]})]})]})})})}var qf=4,Jf=160,Yf=320,Xf=`env(safe-area-inset-top)`,Zf=`env(safe-area-inset-bottom)`;function Qf(e){let{rect:t,viewportWidth:n,viewportHeight:r}=e,i=Math.min(Yf,n-16),a={position:`fixed`,left:Math.max(8,Math.min(t.left,n-8-i)),width:i,zIndex:9999};if(r-t.bottom>=t.top){let e=`max(${t.bottom+qf}px, calc(${Xf} + 8px))`;return{...a,top:e,maxHeight:`max(${Jf}px, calc(100dvh - ${e} - ${Zf} - 8px))`}}let o=`max(${r-t.top+qf}px, calc(${Zf} + 8px))`;return{...a,bottom:o,maxHeight:`max(${Jf}px, calc(100dvh - ${o} - ${Xf} - 8px))`}}var $f=!1;function ep(){return $f}function tp(){$f=!0}function np(e){return!e.read&&e.severity===`critical`}function rp(e){return e.filter(np)}function ip(e){return e!==void 0&&typeof e.href==`string`&&e.href.length>0}function ap(e){return ip(e)||e!==void 0&&e.invoke!==void 0}var op=/^\/addon\/[^/?#]+\/oauth\//;function sp(e){return e.navigation===void 0?op.test(e.href):e.navigation===`server`}function cp(e){let t=e.action;if(ap(t)&&!(t.invoke!==void 0&&(e.status===`completed`||e.status===`dismissed`)))return t}w();function lp({action:e,className:t,onActivate:n}){let r=O(),a=Oe(),{t:o}=W(),[s,c]=b(!1),[l,u]=b(null);if(e.invoke!==void 0){let{addonId:d,action:f,input:p}=e.invoke;return i(`span`,{className:`inline-flex flex-col items-start gap-0.5`,children:[_(`button`,{type:`button`,className:t,disabled:s,onClick:e=>{e.preventDefault(),n?.(e),c(!0),u(null),a.trpcClient.addons.custom.mutate({addonId:d,action:f,input:p}).then(()=>r.invalidateQueries({queryKey:[[`alerts`]]})).catch(e=>u(e instanceof Error?e.message:String(e))).finally(()=>c(!1))},children:s?o(`ui.alertAction.running`,`Working…`):e.label}),l!==null&&_(`span`,{role:`alert`,className:`text-[10px] text-destructive`,children:l})]})}return ip(e)?sp(e)?_(`a`,{href:z(e.href),className:t,onClick:t=>{t.preventDefault(),n?.(t),ts(e.href,()=>{r.invalidateQueries({queryKey:[[`alerts`]]}),r.invalidateQueries({queryKey:[[`broker`]]}),r.invalidateQueries({queryKey:[[`recordEntries`]]})})},children:e.label}):_(jo,{to:e.href,className:t,onClick:n,children:e.label}):_(A,{})}w(),Er();var up={info:Xe,success:Ye,warning:$e,error:F,critical:vt},dp={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-danger`,critical:`text-danger`},fp={active:`border-l-info`,"in-progress":`border-l-warning`,completed:`border-l-success`,failed:`border-l-danger`,dismissed:`border-l-foreground-subtle/30`};function pp(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return U.t(`helpers.relativeTime.justNow`);let n=Math.floor(t/60);if(n<60)return U.t(`helpers.relativeTime.minutesAgo`,{count:n});let r=Math.floor(n/60);if(r<24)return U.t(`helpers.relativeTime.hoursAgo`,{count:r});let i=Math.floor(r/24);return U.t(`helpers.relativeTime.daysAgo`,{count:i})}function mp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function hp(e){return typeof e==`string`&&e.length>0?e:void 0}function gp(e){if(mp(e.metadata)){let t=hp(e.metadata.nodeId)??hp(e.metadata.agentId);if(t!==void 0)return t}let t=e.source;if(t!==void 0&&!(t.type!==`node`&&t.type!==`agent`))return hp(t.id)}function _p({alert:e,onMarkRead:t,onDismiss:n}){let{t:r}=W(),a=e.severity in up?e.severity:`info`,o=cp(e),s=e.status in fp?e.status:`active`,c=up[a],l=dp[a],u=fp[s],{nodes:d}=Dn(),f=gp(e),p=f===void 0?void 0:d.find(e=>e.id===f),m=f===void 0?void 0:p?.name??f;return i(`div`,{className:`flex items-start gap-2.5 px-3 py-2.5 border-l-2 ${u} ${e.read?`opacity-60`:``} hover:bg-surface-hover transition-colors`,children:[_(c,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${l}`}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`flex items-center gap-1.5`,children:[_(`span`,{className:`text-[11px] font-semibold ${e.read?`text-foreground-subtle`:`text-foreground`}`,children:e.title}),!e.read&&_(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary shrink-0`})]}),m!==void 0&&_(`div`,{className:`text-foreground-subtle text-[10px] mt-0.5 truncate`,children:m}),_(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5 line-clamp-2`,children:e.message}),o!==void 0&&_(lp,{action:o,className:`inline-flex mt-1.5 items-center rounded-md bg-primary px-2 py-0.5 text-[10px] font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,onActivate:e=>e.stopPropagation()}),e.status===`in-progress`&&e.progress!==void 0&&i(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[_(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:_(`div`,{className:`h-full bg-primary rounded-full transition-all duration-300`,style:{width:`${String(Math.min(100,Math.max(0,e.progress)))}%`}})}),i(`span`,{className:`text-[9px] text-foreground-subtle font-mono shrink-0`,children:[String(Math.round(e.progress)),`%`]})]}),_(`div`,{className:`text-[9px] text-foreground-subtle/60 mt-1`,children:pp(e.updatedAt)})]}),i(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[!e.read&&_(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),t(e.id)},className:`p-1 rounded hover:bg-surface-hover transition-colors`,title:r(`ui.alertBell.markAsRead`,`Mark as read`),children:_(N,{className:`h-3 w-3 text-foreground-subtle`})}),e.status!==`in-progress`&&_(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),n(e.id)},className:`p-1 rounded hover:bg-surface-hover transition-colors`,title:r(`ui.alertBell.dismiss`,`Dismiss`),children:_(Ae,{className:`h-3 w-3 text-foreground-subtle`})})]})]})}function vp({variant:e=`icon`,compact:t=!1}={}){let{t:n}=W(),[r,a]=b(!1),[o,s]=b(!1),c=u(null),l=u(null),d=O(),{data:f=0}=tr(void 0,{refetchInterval:3e4}),{data:p=[],isLoading:m}=dr({limit:50},{enabled:r}),h=o?p:p.filter(e=>!e.read),y=p.filter(e=>e.read).length,x=()=>{d.invalidateQueries({queryKey:[[`alerts`]]})},S=Kn({onSuccess:x}),C=jn({onSuccess:x}),w=En({onSuccess:x});qn(`alert.created`,()=>{d.invalidateQueries({queryKey:[[`alerts`]]})}),qn(`alert.updated`,()=>{d.invalidateQueries({queryKey:[[`alerts`]]})}),v(()=>{if(!r)return;let e=e=>{let t=e.target;c.current&&!c.current.contains(t)&&l.current&&!l.current.contains(t)&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[r]);let T=g(e=>{S.mutate({alertId:e})},[S]),E=g(e=>{e&&w.mutate({alertId:e})},[w]),D=g(()=>{C.mutate(void 0),a(!1)},[C]),k=h.filter(np),A=new Set(k.map(e=>e.id)),j=h.filter(e=>e.status===`in-progress`&&!A.has(e.id)),M=h.filter(e=>e.status!==`in-progress`&&!A.has(e.id)),[N,P]=b({}),F=g(()=>{let e=l.current;e&&P(Qf({rect:e.getBoundingClientRect(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}))},[]);return v(()=>{if(!r)return;F();let e=()=>F();return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[r,F]),i(`div`,{children:[e===`sidebar`?i(`button`,{ref:l,type:`button`,onClick:()=>a(!r),className:`flex w-full items-center gap-2.5 rounded-md ${t?`justify-center px-0 py-2`:`px-2.5 py-1.5`} text-[12px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,title:t?f>0?n(`ui.alertBell.alertsUnread`,{count:f}):n(`ui.alertBell.alerts`):void 0,children:[i(`span`,{className:`relative inline-flex shrink-0`,children:[_(Ze,{className:`h-3.5 w-3.5`}),t&&f>0&&_(`span`,{className:`absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary`})]}),!t&&_(`span`,{className:`flex-1 text-left`,children:n(`ui.alertBell.alerts`,`Alerts`)}),!t&&f>0&&_(`span`,{className:`flex items-center justify-center h-4 min-w-4 px-1 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none`,children:f>99?`99+`:String(f)})]}):i(`button`,{ref:l,type:`button`,onClick:()=>a(!r),className:`relative p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors`,"aria-label":n(`ui.alertBell.alerts`,`Alerts`),children:[_(Ze,{className:`h-4.5 w-4.5`}),f>0&&_(`span`,{className:`absolute -top-0.5 -right-0.5 flex items-center justify-center h-4 min-w-4 px-0.5 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none`,children:f>99?`99+`:String(f)})]}),r&&Dr(i(`div`,{ref:c,style:N,className:`bg-surface border border-border rounded-lg shadow-xl flex flex-col overflow-hidden`,children:[i(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[_(`span`,{className:`text-[12px] font-semibold text-foreground`,children:n(`ui.alertBell.alerts`,`Alerts`)}),i(`div`,{className:`flex items-center gap-2`,children:[y>0&&i(`label`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle cursor-pointer select-none`,children:[_(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`h-3 w-3 rounded border-border accent-primary cursor-pointer`}),n(`ui.alertBell.showRead`,`Show read`)]}),f>0&&i(`button`,{type:`button`,onClick:D,className:`flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:[_(_t,{className:`h-3 w-3`}),n(`ui.alertBell.markAllRead`,`Mark all read`)]})]})]}),i(`div`,{className:`flex-1 overflow-y-auto`,children:[m&&_(`div`,{className:`flex items-center justify-center py-8`,children:_(B,{className:`h-4 w-4 animate-spin text-foreground-subtle`})}),!m&&h.length===0&&i(`div`,{className:`flex flex-col items-center justify-center py-8 text-foreground-subtle`,children:[_(Ze,{className:`h-6 w-6 mb-2 opacity-40`}),_(`span`,{className:`text-[11px]`,children:p.length>0?n(`ui.alertBell.noUnreadAlerts`,`No unread alerts`):n(`ui.alertBell.noAlerts`,`No alerts`)}),p.length>0&&!o&&_(`button`,{type:`button`,onClick:()=>s(!0),className:`text-[10px] text-primary mt-1 hover:underline`,children:n(`ui.alertBell.showRead`,{count:y})})]}),k.length>0&&i(`div`,{className:`border-b border-border`,children:[_(`div`,{className:`px-3 py-1.5 bg-danger/5`,children:_(`span`,{className:`text-[9px] font-semibold uppercase tracking-widest text-danger`,children:n(`ui.alertBell.urgent`,`Urgent`)})}),k.map(e=>_(_p,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),j.length>0&&i(`div`,{className:`border-b border-border`,children:[_(`div`,{className:`px-3 py-1.5 bg-surface-hover/50`,children:_(`span`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:n(`ui.alertBell.inProgress`,`In Progress`)})}),j.map(e=>_(_p,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),M.map(e=>_(_p,{alert:e,onMarkRead:T,onDismiss:E},e.id))]})]}),document.body)]})}w(),Er();function yp({alert:e,onMarkRead:t}){let{t:n}=W(),r=cp(e);return i(`div`,{className:`border-b border-border last:border-b-0 px-3 py-2.5`,children:[_(`div`,{className:`text-[12px] font-semibold text-foreground`,children:e.title}),_(`div`,{className:`text-[11px] text-foreground-muted mt-0.5`,children:e.message}),i(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[r!==void 0&&_(lp,{action:r,className:`inline-flex items-center justify-center rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90 transition-colors`}),_(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>t(e.id),children:n(`ui.alertBell.markAsRead`,`Mark as read`)})]})]})}function bp(){let{t:e}=W(),t=O(),[n,r]=b(ep()),{data:a=[],isLoading:o}=dr({limit:50}),s=d(()=>rp(a),[a]),c=Kn({onSuccess:g(()=>{t.invalidateQueries({queryKey:[[`alerts`]]})},[t])}),l=g(e=>{c.mutate({alertId:e})},[c]),u=g(()=>{tp(),r(!0)},[]);return o||n||s.length===0?null:Dr(_(`div`,{className:`fixed inset-x-0 bottom-0 z-[10000] flex justify-center p-2 sm:p-4 pb-[max(0.5rem,env(safe-area-inset-bottom))] pointer-events-none`,"data-testid":`critical-alerts-on-load-panel`,children:i(`div`,{className:`pointer-events-auto w-full max-w-lg bg-surface border border-danger/30 rounded-lg shadow-xl flex flex-col max-h-[min(70dvh,32rem)] overflow-hidden`,role:`region`,"aria-labelledby":`critical-alerts-panel-title`,children:[i(`div`,{className:`flex items-start justify-between gap-2 px-3 py-2.5 border-b border-border shrink-0 bg-danger/5`,children:[i(`div`,{children:[_(`h2`,{id:`critical-alerts-panel-title`,className:`text-[12px] font-semibold text-foreground`,children:e(`ui.criticalAlertsPanel.title`,`Urgent alerts`)}),_(`p`,{className:`text-[10px] text-foreground-muted mt-0.5`,children:e(`ui.criticalAlertsPanel.subtitle`,`These need your attention.`)})]}),_(Nt,{type:`button`,variant:`ghost`,onClick:u,"aria-label":e(`ui.criticalAlertsPanel.close`,`Close`),"data-testid":`critical-alerts-panel-close`,icon:Ae})]}),_(`div`,{className:`flex-1 overflow-y-auto`,children:s.map(e=>_(yp,{alert:e,onMarkRead:l},e.id))})]})}),document.body)}w();function xp(){let e=al();return y(e.subscribe,e.getSnapshot,e.getSnapshot)}var Sp=[`detection`,`cluster`,`administration`];function Cp(e){return Sp.includes(e)}function wp(e){let t=new Map,n=new Map,r=[];for(let i of e){let e=i.section?.trim();if(e===void 0||e.length===0){r.push(i);continue}if(Cp(e)){let n=t.get(e)??[];n.push(i),t.set(e,n);continue}let a=n.get(e);a?a.pages.push(i):n.set(e,{label:i.sectionLabel?.trim()||e,pages:[i]})}return{known:t,custom:[...n.entries()].map(([e,t])=>({id:e,label:t.label,pages:t.pages})),ungrouped:r}}var Tp=`camstack:last-path`,Ep=512,Dp=[`/login`,`/change-password`,`/access-denied`,`/logout`];function Op(e){return!e.startsWith(`/`)||e.startsWith(`//`)||e.length>Ep?!1:!Dp.some(t=>e===t||e.startsWith(t+`/`))}function kp(e){if(!(typeof window>`u`)&&Op(e))try{window.localStorage.setItem(Tp,e)}catch{}}function Ap(){if(typeof window>`u`)return null;try{let e=window.localStorage.getItem(Tp);return e===null?null:Op(e)?e:null}catch{return null}}var jp=`/devices`;function Mp(e){return e!==void 0&&Op(e)?e:Ap()??jp}function Np(e){return e.split(`.`)[0]===`0`?`${e} beta`:e}function Pp(e){if(e===null)return null;let t=e.trim();return t.length>0?t:null}function Fp(e){let t=Pp(e.productVersion),n=Pp(e.serverVersion),r=Pp(e.fallbackVersion);return t!==null&&n!==null?{kind:`both`,productLabel:Np(t),serverVersion:n}:t===null?n===null?r===null?{kind:`none`}:{kind:`fallback`,version:r}:{kind:`server`,serverVersion:n}:{kind:`product`,productLabel:Np(t)}}function Ip(e,t){if(!Object.hasOwn(e,t))return null;let n=Reflect.get(e,t);return typeof n==`string`?n:null}function Lp(e){return typeof e!=`object`||!e?null:{productVersion:Ip(e,`productVersion`),serverVersion:Ip(e,`serverVersion`)}}w();function Rp(e,t){return e.kind===`both`?t(`releaseIdentity.both`,`{{product}} · server {{server}}`,{product:e.productLabel,server:e.serverVersion}):e.kind===`product`?e.productLabel:e.kind===`server`?t(`releaseIdentity.serverOnly`,`server {{version}}`,{version:e.serverVersion}):e.kind===`fallback`?t(`releaseIdentity.fallback`,`v{{version}}`,{version:e.version}):null}function zp({placement:e,compact:t=!1}){let{t:n}=W(),[r,i]=b({kind:`fallback`,version:`1.2.529`});v(()=>{let e=new AbortController;return fetch(z(`/api/release-identity`),{signal:e.signal}).then(async e=>e.ok?Lp(await e.json()):null).then(t=>{e.signal.aborted||t===null||i(Fp({productVersion:t.productVersion,serverVersion:t.serverVersion,fallbackVersion:`1.2.529`}))}).catch(t=>{e.signal.aborted||t instanceof DOMException&&t.name}),()=>e.abort()},[]);let a=Rp(r,n);return a===null?null:e===`login`?_(`span`,{"data-testid":`release-identity`,children:a}):_(`div`,{"data-testid":`release-identity`,className:`pt-1 text-[10px] text-foreground-disabled select-none truncate ${t?`text-center`:`px-2`}`,title:a,children:a})}w();var Bp=E(!0);function Vp(e){return e===`/addon`||e.startsWith(`/addon/`)}function Hp(e,t,n){let r=[...e.filter(e=>e!==t),t];return r.length<=n?r:r.slice(r.length-n)}function Up({maxCached:e=6}){let t=pa(),n=Y(),r=sa(),a=j(J),o=n.pathname,s=Vp(o),c=u(new Map),l=u([]);if(s){c.current.set(o,{key:o,outlet:t,location:n,navigationType:r,routeContext:a});let i=Hp(l.current,o,e),s=new Set(i);for(let e of c.current.keys())s.has(e)||c.current.delete(e);l.current=i}return i(A,{children:[l.current.map(e=>{let t=c.current.get(e);if(t?.outlet==null)return null;let n=s&&e===o;return _(`div`,{className:n?`h-full min-h-0`:void 0,style:n?void 0:{display:`none`},hidden:!n,"aria-hidden":!n,children:_(Bp.Provider,{value:n,children:_(Qi.Provider,{value:{location:t.location,navigationType:t.navigationType},children:_(J.Provider,{value:t.routeContext,children:t.outlet})})})},e)}),!s&&t!=null?_(`div`,{className:`h-full min-h-0`,children:t},o):null]})}w();var Wp={dark:M,light:pe,system:ft};function Gp(){return _(`div`,{className:`flex h-full min-h-[50vh] items-center justify-center`,children:_(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`})})}function Kp(){let e=Y(),t=ua(),{user:n,logout:r}=du(),a=mr(),{t:o}=W(),s=Yt(),c=Bt(),{info:l}=Rf();v(()=>{document.title=l===null?`CamStack Admin`:`${l.name} \u00b7 CamStack Admin`},[l]);let f=Yc(xp()),[p,m]=b(!1);v(()=>{kp(e.pathname+e.search)},[e.pathname,e.search]);let[g,y]=b(()=>typeof window>`u`?!1:window.localStorage.getItem(`camstack:sidebar-collapsed`)===`1`);v(()=>{typeof window>`u`||window.localStorage.setItem(`camstack:sidebar-collapsed`,g?`1`:`0`)},[g]);let[x]=b(()=>{if(typeof window>`u`)return new Set;try{let e=window.localStorage.getItem(`camstack:sidebar-collapsed-groups`);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}});v(()=>{typeof window>`u`||window.localStorage.setItem(`camstack:sidebar-collapsed-groups`,JSON.stringify([...x]))},[x]),v(()=>{c&&window.localStorage.getItem(`camstack:sidebar-collapsed`)===null&&y(!0)},[c]);let{data:S=[]}=ir({nodeId:`hub`},{refetchInterval:3e4}),C=S.length,w=O(),T=u(Date.now()),{data:E}=on(void 0,{staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let t=e.state.data;return t&&t.length>0||Date.now()-T.current>=3e4?!1:2e3}}),D=d(()=>E&&n?.isAdmin?kd(E):[],[E,n?.isAdmin]),k=d(()=>wp(D),[D]),j=k.known.get(`detection`)??[],M=k.known.get(`cluster`)??[],N=k.known.get(`administration`)??[];qn(`addon.page-ready`,()=>{w.invalidateQueries({queryKey:[[`addonPages`,`listPages`]]})});let P=()=>{r(),t(`/login`)},F=t=>!!(e.pathname===t||e.pathname.startsWith(t+`/`)),te=[`/system/pipeline`,`/live`,`/addon/osd-manager`,`/build`].some(t=>e.pathname===t||e.pathname.startsWith(t+`/`)),ne=n?.isAdmin===!0,I=d(()=>Bd({t:o,isAdmin:ne}),[o,ne]),re=I[0]?.items??[],ie=I[1]?.items??[],ae=I[2]?.items??[],oe=I[3]?.items??[],se=a?.mode??`system`,ce={dark:o(`theme.dark`),light:o(`theme.light`),system:o(`theme.system`)},L=g&&!s,R=(e,t=`md`,n=!1)=>`flex w-full items-center gap-2.5 rounded-md ${L?`justify-center px-0 py-2`:`px-2.5 py-1.5`} ${t===`lg`?`text-[13px] font-medium`:`text-[12px]`} transition-all ${e?t===`lg`?`bg-primary/12 text-primary shadow-sm shadow-primary/5`:`bg-primary/12 text-primary`:n?`text-foreground-disabled hover:bg-surface-hover`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,le=(e,t)=>e===0?null:L?_(`div`,{className:`pt-3 mb-1 mx-2 border-t border-border/60`},`sep-${t}`):_(`div`,{className:`pt-4 pb-1.5 px-2.5`,children:_(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:t})},`hdr-${t}`),de=e=>{let n=F(e.path),r=Hd(e.icon);return i(`button`,{onClick:()=>{t(e.path),m(!1)},className:R(n),title:L?e.label:void 0,children:[_(r,{className:`h-3.5 w-3.5 shrink-0 ${n?`text-primary`:``}`}),!L&&e.label]},`${e.addonId}::${e.id}`)},fe=e=>e.requiresCapability===void 0?pe(e,!1):_(qd,{capability:e.requiresCapability,children:t=>pe(e,t)},e.path),pe=(e,n)=>{let r=e.icon,a=F(e.path),s=e.path===`/system/addons`;return i(`button`,{"data-testid":`nav-${e.path.replace(/^\//,``).replace(/\//g,`-`)}`,onClick:()=>{t(e.path),m(!1)},className:R(a,`md`,n),"aria-disabled":n||void 0,title:n?o(`nav.notInstalled`,`{{page}} — not installed`,{page:e.label}):L?e.label:void 0,children:[_(r,{className:`h-3.5 w-3.5 shrink-0 ${a?`text-primary`:``}`}),!L&&i(A,{children:[_(`span`,{className:`flex-1 text-left`,children:e.label}),s&&C>0&&_(`span`,{className:`ml-auto rounded-full bg-primary px-1.5 py-0.5 text-[9px] font-bold text-primary-foreground leading-none`,children:C})]}),L&&s&&C>0&&_(`span`,{className:`absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary`})]},e.path)},he=i(A,{children:[i(`div`,{className:`flex h-14 items-center border-b border-border ${L?`justify-center px-1`:`pl-3 pr-4 gap-2`}`,children:[!L&&_(`img`,{src:a?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:o(`layouts.appLayout.camstackAdmin`,`CamStack Admin`),className:`h-9 flex-1 min-w-0`}),!s&&_(`button`,{onClick:()=>y(e=>!e),className:`p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle transition-colors flex-shrink-0 ${L?``:`mr-2`}`,"aria-label":g?o(`layouts.appLayout.expandSidebar`,`Expand sidebar`):o(`layouts.appLayout.collapseSidebar`,`Collapse sidebar`),title:g?o(`layouts.appLayout.expandSidebar`,`Expand sidebar`):o(`layouts.appLayout.collapseSidebar`,`Collapse sidebar`),children:_(g?ee:ue,{className:`h-4 w-4`})})]}),!L&&l!==null&&_(`div`,{"data-testid":`sidebar-server-name`,title:l.name,className:`truncate border-b border-border px-3 py-1.5 text-xs font-medium text-foreground-muted`,children:l.name}),_(`div`,{className:`border-b border-border pt-2`,children:_(Df,{navSections:I,addonPages:D,compact:L,onNavigated:()=>m(!1)})}),i(`nav`,{className:`flex-1 overflow-y-auto py-3 ${L?`px-1.5`:`px-2`} space-y-0.5`,children:[re.map(e=>fe(e)),le(ie.length+j.length,o(`nav.detectionSection`,`Detection`)),ie.map(e=>fe(e)),j.map(e=>de(e)),le(ae.length+M.length,o(`nav.clusterSection`,`Cluster`)),ae.map(e=>fe(e)),M.map(e=>de(e)),le(oe.length+N.length,o(`system.title`,`Administration`)),oe.map(e=>fe(e)),N.map(e=>de(e)),k.custom.map(e=>i(`div`,{className:`contents`,children:[le(e.pages.length,e.label),e.pages.map(e=>de(e))]},`custom-${e.id}`)),le(k.ungrouped.length,o(`nav.addonPages`,`Addon Pages`)),k.ungrouped.map(e=>de(e))]}),i(`div`,{className:`border-t border-border ${L?`p-1.5`:`p-2`} space-y-0.5`,children:[i(`button`,{onClick:()=>a?.toggleMode(),className:R(!1),title:L?ce[se]:void 0,children:[(()=>{let e=Wp[se];return _(e,{className:`h-3.5 w-3.5 shrink-0`})})(),!L&&_(`span`,{children:ce[se]})]}),_(vp,{variant:`sidebar`,compact:L}),i(`button`,{type:`button`,onClick:()=>t(`/system/my-access`),className:R(F(`/system/my-access`)),title:L?o(`system.myAccess`,`My access`):void 0,children:[_(Ve,{className:`h-3.5 w-3.5 shrink-0`}),!L&&_(`span`,{className:`truncate`,children:o(`system.myAccess`,`My access`)})]}),i(`button`,{onClick:P,className:R(!1).replace(`hover:text-foreground`,`hover:text-danger`),title:L?n?.username??o(`layouts.appLayout.logout`,`Logout`):void 0,children:[_(Tt,{className:`h-3.5 w-3.5 shrink-0`}),!L&&_(`span`,{className:`truncate`,children:n?.username??o(`layouts.appLayout.user`,`User`)})]}),_(zp,{placement:`sidebar`,compact:L})]})]});return i(`div`,{className:`flex h-dvh overflow-hidden bg-background text-foreground pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:[!s&&_(`aside`,{className:`flex flex-col border-r border-border bg-surface/80 backdrop-blur-sm shrink-0 transition-[width] duration-150 ease-out ${L?`w-12`:`w-48`}`,children:he}),s&&_(hn,{open:p,onClose:()=>m(!1),width:`w-64`,children:he}),i(`div`,{className:`flex flex-1 flex-col min-w-0`,children:[f!==null&&i(`div`,{className:`flex items-center justify-center gap-2 px-3 py-2 text-[12px] font-medium shrink-0 ${f.severity===`danger`?`bg-danger/90 text-white`:`bg-warning/15 text-warning border-b border-warning/30`}`,children:[f.severity===`danger`?_(me,{className:`h-3.5 w-3.5`}):_(Re,{className:`h-3.5 w-3.5`}),_(`span`,{children:o(f.i18nKey,{defaultValue:f.message,...f.i18nParams})}),f.action===`sign-in`&&_(`button`,{onClick:()=>r(),className:`ml-2 rounded border border-white/40 px-2 py-0.5 text-[11px] font-semibold hover:bg-white/10`,children:o(`connection.signIn`,`Sign in`)}),f.showSpinner&&_(B,{className:`h-3.5 w-3.5 animate-spin`})]}),_(If,{}),_(Gf,{}),_(bp,{}),s&&i(`header`,{className:`flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm`,children:[_(`button`,{onClick:()=>m(!0),className:`p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors`,"aria-label":o(`layouts.appLayout.openMenu`,`Open menu`),children:_(Se,{className:`h-5 w-5`})}),_(`div`,{className:`flex-1 flex justify-center`,children:_(`img`,{src:a?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:o(`layouts.appLayout.camstack`,`CamStack`),className:`h-7`})}),_(vp,{})]}),i(Jd,{children:[_(Xd,{}),_(`main`,{className:`relative flex-1 min-h-0 overscroll-contain bg-background ${te?`overflow-hidden`:`overflow-auto`}`,children:_(Dd,{resetKey:e.pathname,children:_(h,{fallback:_(Gp,{}),children:_(Up,{})})})})]})]})]})}function $({children:e,requireAdmin:t}){let{t:n}=W(),{user:r,loading:i,mustChangePassword:a}=du(),o=Y();return i?_(`div`,{className:`flex h-screen items-center justify-center bg-background text-foreground-subtle`,children:n(`layouts.protectedRoute.loading`,`Loading...`)}):r?a&&o.pathname!==`/change-password`?_(X,{to:`/change-password`,replace:!0}):t&&!r.isAdmin?_(X,{to:`/access-denied`,replace:!0}):_(A,{children:e}):_(X,{to:`/login`,replace:!0,state:{from:o.pathname+o.search}})}var qp=`customize`,Jp=`/build/compositions/new`,Yp=`/build/compositions/:blockId`,Xp=`/build?tab=custom-device`;function Zp(e){return`/devices/${e}`}function Qp(e){return`/devices/${e}?tab=${qp}`}var $p=`integration`,em=`section`,tm=[$p,em],nm={connectivity:{path:`/system/integrations`,tab:null},remoteAccess:{path:`/system/network`,tab:`remote-access`},mesh:{path:`/system/network`,tab:`mesh`},turn:{path:`/system/network`,tab:`turn`},authentication:{path:`/system/identity`,tab:`authentication`},access:{path:`/system/identity`,tab:`access`},logging:{path:`/system/logs`,tab:`destinations`}},rm=`settings`,im=`activity`;function am(e,t={}){let{path:n,tab:r}=nm[e],i=new URLSearchParams;r===null?t.kindSection!==void 0&&i.set(`tab`,t.kindSection):i.set(`tab`,r),t.integration!==void 0&&i.set($p,t.integration),t.section!==void 0&&i.set(em,t.section);let a=i.toString();return a.length>0?`${n}?${a}`:n}function om(e){let{ids:t,requested:n,answered:r,legacyGroup:i=null,groupFirst:a={}}=e;if(n!==null&&t.includes(n))return{selectedId:n,staleId:null};let o=n!==null&&r?n:null,s=i===null?void 0:a[i];return s!==void 0&&t.includes(s)?{selectedId:s,staleId:o}:{selectedId:t[0]??null,staleId:o}}function sm(e,t,n=null,r=null){let i=new URLSearchParams(e);return i.set($p,t),r===null?i.delete(em):i.set(em,r),n!==null&&i.delete(n),i}function cm(e){return e===`/admin`||e===`/admin/`?`/`:e.startsWith(`/admin/`)?e.slice(6):e}function lm(){let{t:e}=W(),t=ua();return i(`div`,{className:`flex flex-col items-center justify-center text-foreground py-16 px-4`,children:[_(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-2xl bg-danger/10 mb-4`,children:_(wt,{className:`h-8 w-8 text-danger`})}),_(`h1`,{className:`text-xl font-bold`,children:e(`accessDenied.accessDenied`,`Access Denied`)}),_(`p`,{className:`mt-2 text-sm text-foreground-subtle`,children:e(`accessDenied.youDonTHavePermission`,`You don't have permission to access this page.`)}),_(`button`,{onClick:()=>t(`/devices`),className:`mt-6 rounded-lg bg-primary px-5 py-2.5 text-sm font-medium text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all`,children:e(`accessDenied.goToDevices`,`Go to Devices`)})]})}var um=`auth.password-incorrect`;function dm(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function fm(e){if(!(e instanceof Error))return{kind:`connection-lost`};let t=dm(e,`data`);return typeof t!=`object`||!t?{kind:`connection-lost`}:dm(dm(t,`i18n`),`code`)===um?{kind:`wrong-current`}:dm(t,`code`)===`UNAUTHORIZED`?{kind:`session-ended`}:{kind:`rejected`,message:e.message}}w();var pm=8;function mm(e,t){let n=fm(e);switch(n.kind){case`wrong-current`:return t(`changePassword.errorWrongCurrent`,`The current password is incorrect.`);case`session-ended`:return t(`changePassword.errorSessionEnded`,`Your session ended before the change was confirmed. Sign in again — try the new password first.`);case`connection-lost`:return t(`changePassword.errorConnectionLost`,`The connection to the hub dropped before it confirmed the change. Sign in again — try the new password first.`);case`rejected`:return n.message}}function hm(){let{t:e}=W(),{user:t,mustChangePassword:n,clearMustChangePassword:r,logout:a}=du(),o=Oe(),s=mr(),c=ua(),[l,u]=b(``),[d,f]=b(``),[p,m]=b(``),[h,g]=b(!1),[v,y]=b(``),[x,S]=b(!1),C=n?tu:l;return _(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:i(`div`,{className:`w-full max-w-sm`,children:[_(`div`,{className:`flex justify-center mb-8`,children:_(`img`,{src:s?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:e(`changePassword.camstackAdmin`,`CamStack Admin`),className:`h-12`})}),i(`form`,{onSubmit:async i=>{if(i.preventDefault(),y(``),!t){y(`Not signed in`);return}if(!n&&l.length===0){y(e(`changePassword.enterCurrent`,`Enter your current password`));return}if(d.length<pm){y(`Password must be at least ${pm} characters`);return}if(d!==p){y(`The two passwords do not match`);return}if(d===`changeme`){y(`Choose a password different from the seed default`);return}S(!0);try{await o.changeOwnPassword({currentPassword:C,newPassword:d}),r(),c(`/devices`,{replace:!0})}catch(t){y(mm(t,e))}finally{S(!1)}},className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[i(`div`,{className:`space-y-1`,children:[_(`h1`,{className:`text-sm font-semibold text-foreground`,children:e(`changePassword.setANewPassword`,`Set a new password`)}),_(`p`,{className:`text-xs text-foreground-subtle`,children:n?e(`changePassword.youMustRotateTheSeed`,`You must rotate the seed password before continuing.`):e(`changePassword.chooseANewPasswordFor`,`Choose a new password for your account.`)})]}),v&&_(`div`,{role:`alert`,className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:v}),!n&&i(`div`,{className:`space-y-1.5`,children:[_(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.currentPassword`,`Current password`)}),_(`input`,{"data-testid":`change-password-current`,type:h?`text`:`password`,value:l,onChange:e=>u(e.target.value),autoComplete:`current-password`,className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:!0})]}),i(`div`,{className:`space-y-1.5`,children:[_(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.newPassword`,`New password`)}),i(`div`,{className:`relative`,children:[_(`input`,{"data-testid":`change-password-new`,type:h?`text`:`password`,value:d,onChange:e=>f(e.target.value),autoComplete:`new-password`,className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:n}),_(`button`,{type:`button`,onClick:()=>g(!h),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors`,tabIndex:-1,children:_(h?L:ae,{className:`h-4 w-4`})})]})]}),i(`div`,{className:`space-y-1.5`,children:[_(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.confirmNewPassword`,`Confirm new password`)}),_(`input`,{"data-testid":`change-password-confirm`,type:h?`text`:`password`,value:p,onChange:e=>m(e.target.value),autoComplete:`new-password`,className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`})]}),_(`button`,{"data-testid":`change-password-submit`,type:`submit`,disabled:x||!d||!p,className:`w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all`,children:x?e(`changePassword.saving`,`Saving…`):e(`changePassword.saveAndContinue`,`Save and continue`)}),n&&_(`button`,{type:`button`,onClick:()=>{a(),c(`/login`,{replace:!0})},className:`w-full text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:e(`changePassword.signOutInstead`,`Sign out instead`)})]})]})})}function gm(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function _m(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function vm(){return window?.PublicKeyCredential!==void 0&&typeof window.PublicKeyCredential==`function`}function ym(e){let{id:t}=e;return{...e,id:_m(t),transports:e.transports}}function bm(e){return e===`localhost`||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var xm=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),this.name=r??n.name,this.code=t}},Sm=new class{createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},Cm=[`cross-platform`,`platform`];function wm(e){if(e&&!(Cm.indexOf(e)<0))return e}function Tm(){if(!vm())return new Promise(e=>e(!1));let e=window.PublicKeyCredential;return e.isConditionalMediationAvailable===void 0?new Promise(e=>e(!1)):e.isConditionalMediationAvailable()}function Em({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new xm({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new xm({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=window.location.hostname;if(!bm(t))return new xm({message:`${window.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new xm({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new xm({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function Dm(e){let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!vm())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(ym));let a={...t,challenge:_m(t.challenge),allowCredentials:i},o={};if(n){if(!await Tm())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=Sm.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Em({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=gm(u.userHandle)),{id:c,rawId:gm(l),response:{authenticatorData:gm(u.authenticatorData),clientDataJSON:gm(u.clientDataJSON),signature:gm(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:wm(s.authenticatorAttachment)}}function Om(e){return typeof e==`object`&&!!e}function km(e){return Om(e)&&typeof e.challenge==`string`}w();async function Am(e){if(!km(e))throw Error(`passkey authentication options missing challenge`);let t=await Dm({optionsJSON:e});return Object.fromEntries(Object.entries(t))}function jm({method:e,challengeToken:t,onComplete:n,onSecondFactor:r,onError:a}){let[o,s]=b(!1),[c,l]=b(null),u=async()=>{l(null),s(!0);try{let e=Q();if(t){let r=await Am((await e.loginBeginPasskey(t)).optionsJSON),i=await e.loginVerifyPasskey(t,r,{refreshable:!0});n(i.token,i);return}let i=await Am((await e.passkeyLoginBegin()).optionsJSON),o=await e.passkeyLoginFinish(i,{refreshable:!0}),s=o.secondFactors??(o.requiresTotp===!0?[`totp`]:[]);if(s.length>0){if(r)r({challengeToken:o.token,factors:s});else{let e=`Additional verification is required — sign in with your password to continue.`;l(e),a?.(e)}return}n(o.token,o)}catch(e){let n=t?`Passkey verification failed`:`Passkey sign-in failed`,r=e instanceof Error?e.message:n;l(r),a?.(r)}finally{s(!1)}};return i(`div`,{className:`space-y-2`,children:[i(`button`,{type:`button`,"data-testid":t?`login-passkey`:`login-passkey-direct`,onClick:()=>void u(),disabled:o,className:`w-full flex items-center justify-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 text-sm font-medium text-foreground hover:bg-surface-hover disabled:opacity-50 transition-colors`,children:[o?_(B,{className:`h-4 w-4 animate-spin text-primary`}):_(Ct,{className:`h-4 w-4 text-primary`}),e.label]}),c&&_(`div`,{className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:c})]})}var Mm=()=>window.location.hostname;function Nm(e,t=Mm){return vm()&&Af(t(),e.rpId)}function Pm(e,t=Mm){let n=e.filter(e=>e.kind===`passkey`&&e.stage===`second-factor`).filter(e=>Nm(e,t));return{passkeyMethods:n,widgetMethods:n.length>0?[]:e.filter(e=>e.kind===`widget`&&e.stage===`second-factor`)}}function Fm(e,t){let n=e.includes(`passkey`),r=t.passkeyMethods.length>0||t.widgetMethods.length>0,i=e.includes(`totp`);return n&&!r&&!i}function Im(e){let t=e.onComplete,n=e.onSecondFactor;return typeof t==`function`?{onComplete:t,onSecondFactor:typeof n==`function`?n:void 0}:null}function Lm({methods:e,widgetConfig:t,onRedirect:n}){let{t:r}=W();Ot();let a=e.filter(e=>e.kind!==`passkey`||Nm(e));return a.length===0?null:i(`div`,{className:`mt-6 space-y-3`,children:[i(`div`,{className:`flex items-center gap-3`,children:[_(`div`,{className:`h-px flex-1 bg-border`}),_(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:r(`login.primaryLoginMethods.orContinueWith`,`Or continue with`)}),_(`div`,{className:`h-px flex-1 bg-border`})]}),_(`div`,{className:`space-y-2`,children:a.map(e=>{if(e.kind===`redirect`){let t=(e.icon===void 0?void 0:Cn(e.icon))??Ve;return i(`a`,{href:e.startUrl,onClick:t=>{n?.(e)===!0&&t.preventDefault()},className:`flex items-center justify-center gap-2 w-full rounded-lg border border-border bg-surface px-4 py-2.5 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors`,children:[_(t,{className:`h-4 w-4 text-primary`}),e.label]},e.id)}if(e.kind===`passkey`){let n=Im(t);return n?_(jm,{method:e,onComplete:n.onComplete,onSecondFactor:n.onSecondFactor},e.id):null}return _(Rm,{method:e,config:t},e.id)})})]})}function Rm({method:e,config:t}){let{t:n}=W(),r=ln(e.remote,e.bundleUrl);return r===null?i(`div`,{className:`flex items-center justify-center gap-2 rounded-lg border border-border bg-background px-4 py-2.5 text-xs text-foreground-subtle`,children:[_(B,{className:`h-3.5 w-3.5 animate-spin`}),n(`common.loading`,`Loading…`)]}):r===void 0?i(`div`,{"data-testid":`login-method-load-error`,className:`flex items-center justify-center gap-2 rounded-lg border border-danger/20 bg-danger/10 px-4 py-2.5 text-xs text-danger`,children:[_(F,{className:`h-3.5 w-3.5 shrink-0`}),n(`login.primaryMethods.loadFailed`)]}):_(r,{instanceId:e.id,host:`dashboard`,config:t})}var zm=4e3,Bm=/^[A-Za-z0-9._-]{1,64}$/;function Vm(e){let t=e.addonId!==void 0&&Bm.test(e.addonId)?e.addonId:null,n=e.integration!==void 0&&Bm.test(e.integration)?e.integration:null;if(t!==null&&e.brokerId!==void 0)return am(`connectivity`,{integration:t,kindSection:`brokers`});let r=n??t;return am(`connectivity`,r===null?{}:{integration:r})}function Hm(e,t){let n=t.opener;if(n===null||n.closed||Ir(n)!==t.origin)return!1;try{return n.postMessage({type:Xo,ok:e.status===`success`,...e.brokerId===void 0?{}:{brokerId:e.brokerId},...e.status===`error`?{error:e.reason??`unknown`}:{}},t.origin),!0}catch{return!1}}w();var Um=500;function Wm(e){let{t}=W();switch(e){case`access_denied`:return t(`oauthLanding.reason.access_denied`,`Access was denied, so nothing was connected.`);case`invalid_state`:return t(`oauthLanding.reason.invalid_state`,`This sign-in link expired or was already used. Start the sign-in again.`);case`invalid_request`:return t(`oauthLanding.reason.invalid_request`,`The request was not valid for this hub. Start the link again from the beginning.`);case`unknown_broker`:return t(`oauthLanding.reason.unknown_broker`,`That connection no longer exists. Add it again, then sign in.`);case`not_configured`:return t(`oauthLanding.reason.not_configured`,`The connection is missing its client ID or secret. Fill them in, save, then sign in.`);case`exchange_failed`:return t(`oauthLanding.reason.exchange_failed`,`The provider did not accept the sign-in. Check the client ID and secret, then try again.`);case`no_authorization_code`:return t(`oauthLanding.reason.no_authorization_code`,`The provider finished the sign-in without granting CamStack access. Start the sign-in again from the beginning.`);case`no_refresh_token`:return t(`oauthLanding.reason.no_refresh_token`,`The provider returned no long-lived access. Remove CamStack from the account’s connected apps, then sign in again.`);case`unavailable`:return t(`oauthLanding.reason.unavailable`,`The hub is still starting this integration. Wait a moment and try again.`);case`unknown`:return t(`oauthLanding.reason.unknown`,`Something went wrong. Try again in a moment.`)}}function Gm({outcome:e}){let{t}=W(),n=Wm(e.reason??`unknown`);if(e.status===`error`)return i(A,{children:[_(je,{className:`mx-auto h-8 w-8 text-danger`,"aria-hidden":!0}),_(`h1`,{"data-testid":`oauth-landing-title`,className:`text-sm font-semibold text-foreground`,children:t(`oauthLanding.errorTitle`,`Sign-in did not finish`)}),_(`p`,{"data-testid":`oauth-landing-reason`,className:`rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:n})]});let r=e.action===`disconnect`;return i(A,{children:[_(Ye,{className:`mx-auto h-8 w-8 text-success`,"aria-hidden":!0}),_(`h1`,{"data-testid":`oauth-landing-title`,className:`text-sm font-semibold text-foreground`,children:r?t(`oauthLanding.signedOutTitle`,`Signed out`):t(`oauthLanding.successTitle`,`Signed in`)}),_(`p`,{className:`text-xs text-foreground-muted`,children:r?t(`oauthLanding.signedOutBody`,`The account was disconnected from this hub.`):t(`oauthLanding.successBody`,`The account is connected. Returning to CamStack…`)})]})}function Km({outcome:e,closable:t,onContinue:n,onClose:r}){let{t:a}=W(),o=Vm(e);return v(()=>{if(e.status!==`success`)return;let t=window.setTimeout(()=>n(o),zm);return()=>window.clearTimeout(t)},[e.status,n,o]),_(`main`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:i(`div`,{className:`w-full max-w-sm space-y-4`,children:[_(`div`,{className:`flex justify-center`,children:i(`picture`,{children:[_(`source`,{media:`(prefers-color-scheme: dark)`,srcSet:z(`/brand/logo-horizontal-dark.svg`)}),_(`img`,{src:z(`/brand/logo-horizontal-light.svg`),alt:a(`oauthLanding.brand`,`CamStack`),className:`h-12`})]})}),i(`div`,{className:`space-y-4 rounded-xl border border-border bg-surface p-6 text-center shadow-xl shadow-black/10`,children:[_(Gm,{outcome:e}),i(`div`,{className:`flex flex-col gap-2`,children:[_(H,{type:`button`,variant:`primary`,onClick:()=>n(o),children:a(`oauthLanding.back`,`Back to CamStack`)}),t&&_(H,{type:`button`,variant:`ghost`,onClick:r,children:a(`oauthLanding.close`,`Close this window`)})]})]})]})})}function qm(e,t){window.history.replaceState(null,``,window.location.pathname);let n=window.opener,r=Hm(t,{opener:n,origin:window.location.origin}),i=()=>e.render(_(Km,{outcome:t,closable:r,onContinue:e=>window.location.replace(z(e)),onClose:()=>window.close()}));if(r&&t.status===`success`){window.close(),window.setTimeout(i,Um);return}i()}function Jm(e){return ct(e)}var Ym=`Done — you can close this window.`,Xm=500,Zm=`camstack_admin_token`;async function Qm(e,t=``){try{let n=bl(new URLSearchParams(t));n!==null&&n.token===e?vl(n):localStorage.setItem(Zm,e)}catch{}await fetch(z(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}function $m(){try{let e=localStorage.getItem(Zm);return e!==null&&e.length>0?e:null}catch{return null}}function eh(e){let t=Jm(window.location.hash);if(t!==null){qm(e,t);return}let n=jr(window.location.hash);window.history.replaceState(null,``,window.location.pathname);let r=t=>e.render(_(th,{completion:n,result:t}));if(r(null),n===null)return;let i=Lr();zr(n,{opener:window.opener,origin:window.location.origin,channel:i,addEventListener:(e,t)=>window.addEventListener(e,t),removeEventListener:(e,t)=>window.removeEventListener(e,t),close:()=>{window.close(),window.setTimeout(()=>r({kind:`done`,message:Ym}),Xm)},continueAt:e=>window.location.replace(z(e)),persistSession:e=>Qm(e,n.target===`login`?n.fragment:``),showResult:r,setTimeout:(e,t)=>window.setTimeout(e,t)})}function th({completion:e,result:t}){let{t:n}=W();return _(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:_(`div`,{className:`flex flex-col items-center gap-3 text-sm text-foreground-subtle`,children:e===null?_(`a`,{className:`text-primary underline`,href:z(`/login`),children:n(`ssoComplete.nothingToFinishHereGo`,`Nothing to finish here — go to sign-in`)}):t===null?i(`span`,{className:`flex items-center gap-3`,children:[_(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),n(`ssoComplete.finishingSignIn`,`Finishing sign-in…`)]}):i(A,{children:[_(`span`,{"data-testid":`sso-complete-result`,className:t.kind===`link-error`?`text-danger`:`text-foreground`,children:t.message}),_(`button`,{type:`button`,className:`rounded-md border border-border px-3 py-1.5 text-foreground hover:bg-surface-hover`,onClick:()=>window.close(),children:n(`ssoComplete.closeThisWindow`,`Close this window`)})]})})})}w();function nh(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`message`),n=Reflect.get(e,`data`);return(typeof n==`object`&&n?Reflect.get(n,`code`):void 0)===`FORBIDDEN`||typeof t==`string`&&/sign in again first/i.test(t)}function rh(){let e=new URLSearchParams(window.location.search);return Fl({codeChallenge:e.get(`code_challenge`),codeChallengeMethod:e.get(`code_challenge_method`),state:e.get(`state`),purpose:e.get(`purpose`)})}function ih(e){return Math.min(1e3*2**e,15e3)}function ah(){let{t:e}=W(),{login:t,verifyTotp:n,finalizePasskeyLogin:r,user:a}=du(),{i18n:o}=W(),s=mr(),c=ua(),l=Y(),d=new URLSearchParams(window.location.search).get(`next`);v(()=>{Wl(d)},[d]);let f=new URLSearchParams(window.location.search).get(`redirect`);v(()=>{$l(f)},[f]);let p=rh();v(()=>{Rl(p)},[p?.codeChallenge,p?.state,p?.purpose]);let m=l.state,h=Mp(m?.from),[g,y]=b(``),[x,S]=b(``),[C,w]=b(!1),[T,E]=b(``),[D,O]=b(!1),[k,j]=b(`credentials`),[M,N]=b(``),[P,F]=b([]),[ee,te]=b(``),[ne,I]=b(void 0),[re,ie]=b(`sso-not-linked`),oe=pr.auth.listLoginMethods.useQuery(void 0,{retry:!0,retryDelay:ih}),se=oe.data===void 0,ce=(oe.data??[]).filter(e=>e.kind!==`device-certificate`),R=pr.auth.getServerName.useQuery().data,le=ce.filter(e=>e.stage===`primary`),ue=Pm(ce);v(()=>{let e=Br(window.location.hash);if(e!==null){if(window.history.replaceState({},``,window.location.pathname+window.location.search),e.kind===`challenge`){N(e.challengeToken),F(e.factors),te(``),j(`second-factor`);return}ie(e.code),I(e.provider)}},[]);let de=ne==null?null:ce.find(e=>e.id===ne&&`label`in e)?.label??null,fe=T||(ne===void 0?``:Nr(re,de)),{passkeyMethods:pe,widgetMethods:me}=ue,he=u(!1),ge=async()=>{if(he.current)return;he.current=!0;let e=Vl(f);if(e?.kind===`app-callback`){await ye(e.url);return}else if(e){window.location.assign(z(e.path));return}let t=Kl(d);t?window.location.assign(z(t)):c(h,{replace:!0})},[_e,ve]=b(null),ye=async e=>{ve({callbackBase:e,mintedUrl:null,failed:!1});try{let t=rh()??zl();if(t===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await Q().trpcClient.auth.createHandoffCode.mutate({purpose:t.purpose,codeChallenge:t.codeChallenge,state:t.state}),r=Bl(e,n,t.state);ve({callbackBase:e,mintedUrl:r,failed:!1}),window.location.assign(r)}catch(t){if(nh(t)){he.current=!1,ve(null),E(`Sign in again to confirm it is you.`);return}ve({callbackBase:e,mintedUrl:null,failed:!0})}},be=a!==null,[Se,Ce]=b(!1);v(()=>{!be||!f&&!d||Se||(Ce(!0),ge())},[be,f,d,Se]);let we=async e=>{e.preventDefault(),E(``),I(void 0),O(!0);try{let e=await t(g,x);if(e.kind===`second-factor`){N(e.challengeToken),F(e.factors),j(`second-factor`);return}x===`changeme`?c(`/change-password`,{replace:!0}):await ge()}catch(e){E(e instanceof Error?e.message:`Login failed`)}finally{O(!1)}},Te=async e=>{e.preventDefault(),E(``),O(!0);try{await n(M,ee.trim()),await ge()}catch(e){E(e instanceof Error?e.message:`TOTP verification failed`),te(``)}finally{O(!1)}},Ee=async(e,t)=>{try{await r(e,t),await ge()}catch(e){E(e instanceof Error?e.message:`Passkey sign-in failed`)}},De=u(null);v(()=>()=>De.current?.(),[]);let Oe=async e=>{if(e.target!==`login`)return;let t=bl(new URLSearchParams(e.fragment));if(t!==null){try{await r(t.token,t),await ge()}catch(e){E(e instanceof Error?e.message:`Sign-in failed`)}return}let n=Br(`#${e.fragment}`);if(n!==null){if(n.kind===`challenge`){Ae({challengeToken:n.challengeToken,factors:n.factors});return}ie(n.code),I(n.provider)}},ke=e=>{if(Ml(f)?.kind===`app-callback`)return!1;let t=Pr(z(Mr(e.startUrl)));return t===null?!1:(E(``),I(void 0),De.current?.(),De.current=Rr(t,{onReturn:e=>{De.current?.(),De.current=null,Oe(e)},onDone:e=>{if(De.current?.(),De.current=null,e.target!==`login`)return;let t=$m()===null?null:_l();t!==null&&Oe({target:`login`,fragment:new URLSearchParams({token:t.token,...t.refreshToken===void 0?{}:{refreshToken:t.refreshToken},...t.expiresAt===void 0?{}:{expiresAt:String(t.expiresAt)}}).toString()})}}),!0)},Ae=e=>{let t=e.factors.filter(e=>e===`totp`||e===`passkey`);N(e.challengeToken),F(t),te(``),E(``),j(`second-factor`)};return _e===null?_(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:i(`div`,{className:`w-full max-w-sm`,children:[_(`div`,{className:`flex justify-center mb-8`,children:_(`img`,{src:s?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:e(`login.camstackAdmin`,`CamStack Admin`),className:`h-12`})}),R!==void 0&&!R.isDefault&&_(`p`,{"data-testid":`login-server-name`,className:`-mt-4 mb-6 text-center text-sm text-foreground-muted`,children:_(kr,{i18nKey:`login.signInTo`,values:{name:R.name},components:{b:_(`span`,{className:`font-semibold text-foreground`})}})}),k===`credentials`?i(`form`,{onSubmit:we,className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[fe&&_(`div`,{"data-testid":`login-error`,className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:fe}),i(`div`,{className:`space-y-1.5`,children:[_(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.username`,`Username`)}),_(`input`,{"data-testid":`login-username`,type:`text`,placeholder:e(`login.username`,`Username`),value:g,onChange:e=>y(e.target.value),className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:!0})]}),i(`div`,{className:`space-y-1.5`,children:[_(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.password`,`Password`)}),i(`div`,{className:`relative`,children:[_(`input`,{"data-testid":`login-password`,type:C?`text`:`password`,placeholder:e(`login.password`,`Password`),value:x,onChange:e=>S(e.target.value),className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`}),_(`button`,{type:`button`,onClick:()=>w(!C),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors`,tabIndex:-1,children:_(C?L:ae,{className:`h-4 w-4`})})]})]}),_(`button`,{"data-testid":`login-submit`,type:`submit`,disabled:D||!g||!x,className:`w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all`,children:D?i(`span`,{className:`flex items-center justify-center gap-2`,children:[_(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground/30 border-t-primary-foreground`}),e(`login.loggingIn`,`Logging in...`)]}):e(`login.logIn`,`Log in`)})]}):i(`div`,{className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[i(`div`,{className:`flex items-center gap-2 pb-1 border-b border-border`,children:[_(xe,{className:`h-4 w-4 text-primary`}),_(`div`,{className:`text-sm font-medium text-foreground`,children:e(`login.twoFactorAuthentication`,`Two-factor authentication`)})]}),_(`p`,{className:`text-xs text-foreground-subtle`,children:g?_(A,{children:_(kr,{i18nKey:`login.finishSigningInAs`,values:{username:g},components:{mono:_(`span`,{className:`font-mono text-foreground`})}})}):e(`login.finishSigningInAs`,`Finish signing in.`)}),T&&_(`div`,{className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:T}),P.includes(`passkey`)&&pe.map(e=>_(jm,{method:e,challengeToken:M,onComplete:Ee},e.id)),P.includes(`passkey`)&&me.map(e=>_(Rm,{method:e,config:{challengeToken:M,onComplete:Ee}},e.id)),Fm(P,ue)&&_(`div`,{className:`rounded-md border border-border bg-background px-3 py-2 text-xs text-foreground-subtle`,children:e(`login.passkeyVerificationIsnTAvailable`,`Passkey verification isn't available on this address. Open the hub via its domain URL to complete sign-in.`)}),P.includes(`passkey`)&&P.includes(`totp`)&&i(`div`,{className:`flex items-center gap-3`,children:[_(`div`,{className:`h-px flex-1 bg-border`}),_(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`or`}),_(`div`,{className:`h-px flex-1 bg-border`})]}),P.includes(`totp`)&&i(`form`,{onSubmit:Te,className:`space-y-4`,children:[i(`div`,{className:`space-y-1.5`,children:[_(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.authenticationCode`,`Authentication code`)}),_(`input`,{"data-testid":`login-totp`,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:ee,onChange:e=>te(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-lg border border-border bg-background px-3 py-3 text-center text-2xl font-mono tracking-widest text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:!0})]}),_(`button`,{"data-testid":`login-totp-submit`,type:`submit`,disabled:D||ee.length!==6,className:`w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all`,children:D?i(`span`,{className:`flex items-center justify-center gap-2`,children:[_(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground/30 border-t-primary-foreground`}),e(`login.verifying`,`Verifying...`)]}):e(`login.verifyAndSignIn`,`Verify and sign in`)})]}),i(`button`,{type:`button`,onClick:()=>{j(`credentials`),N(``),F([]),te(``),E(``)},className:`w-full flex items-center justify-center gap-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:[_(Ne,{className:`h-3 w-3`}),e(`login.backToUsernamePassword`,`Back to username + password`)]})]}),k===`credentials`&&se&&i(`p`,{"data-testid":`login-methods-pending`,role:`status`,className:`mt-4 flex items-center justify-center gap-2 text-xs text-foreground-subtle`,children:[_(`span`,{className:`h-3 w-3 animate-spin rounded-full border-2 border-foreground-subtle/30 border-t-foreground-subtle`}),e(`login.methodsPending`,`Loading other sign-in options...`)]}),k===`credentials`&&_(Lm,{methods:le,widgetConfig:{onComplete:Ee,onSecondFactor:Ae,locale:o.language},onRedirect:ke}),_(`p`,{className:`mt-6 text-center text-[10px] text-foreground-subtle/50`,children:_(zp,{placement:`login`})})]})}):_(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:i(`div`,{className:`w-full max-w-sm rounded-xl border border-border bg-surface p-6 text-center space-y-4`,children:[_(`h1`,{className:`text-sm font-semibold text-foreground`,children:e(`login.returningToTheApp`,`Returning to the app…`)}),_e.failed?i(A,{children:[_(`p`,{className:`text-xs text-danger`,children:e(`login.couldNotPrepareTheSign`,`Could not prepare the sign-in handoff. You are logged in — retry below.`)}),_(`button`,{onClick:()=>void ye(_e.callbackBase),className:`inline-flex rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90`,children:e(`common.retry`,`Retry`)})]}):_e.mintedUrl===null?_(`p`,{className:`text-xs text-foreground-subtle`,children:e(`login.preparingAOneTimeSign`,`Preparing a one-time sign-in code…`)}):i(A,{children:[_(`p`,{className:`text-xs text-foreground-subtle`,children:e(`login.ifTheAppDoesNot`,`If the app does not open automatically, tap below (the code expires in 60s).`)}),_(`a`,{href:_e.mintedUrl,className:`inline-flex rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90`,children:e(`login.openCamstack`,`Open CamStack`)})]})]})})}w();function oh(){let{pathname:e,search:t,hash:n}=Y();return _(X,{to:`${cm(e)}${t}${n}`,replace:!0})}function sh(){return _(X,{to:Ap()??`/devices`,replace:!0})}var ch=p(()=>n(()=>import(`./Devices-DFfVPHVt.js`).then(e=>({default:e.DevicesPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url)),lh=p(()=>n(()=>import(`./Integrations-Xub2OY5T.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([9,1,2,3,4,10,5,11,6,12,13,14,7,8,15]),import.meta.url)),uh=p(()=>n(()=>import(`./IntegrationDetail-DtTxTigM.js`).then(e=>({default:e.IntegrationDetailPage})),__vite__mapDeps([16,1,2,3,4,17,10,5,18,19,13,14,12,7,20,21]),import.meta.url)),dh=p(()=>n(()=>import(`./Pipeline-BhNYn1U-.js`).then(e=>({default:e.PipelinePage})),__vite__mapDeps([22,1,2,3,4,17,10,5,23,24,25,26,19,13,14,27,28,8]),import.meta.url)),fh=p(()=>n(()=>import(`./DeviceDetail-CUzPIb4E.js`).then(e=>({default:e.DeviceDetailPage})),__vite__mapDeps([29,1,2,3,4,17,10,5,30,31,32,33,34,23,35,36,26,37,38,39,40,41,42,43,44,14,45,46,47,27,8,48,21]),import.meta.url)),ph=p(()=>n(()=>import(`./Showroom-BS88iBLb.js`).then(e=>({default:e.ShowroomPage})),__vite__mapDeps([49,1,2,3,4,13,5,14,10]),import.meta.url)),mh=p(()=>n(()=>import(`./EmbedPlayerPage-D0lVyXps.js`).then(e=>({default:e.EmbedPlayerPage})),__vite__mapDeps([50,1,2,3,4,5]),import.meta.url)),hh=p(()=>n(()=>import(`./Library-CO10lVu2.js`).then(e=>({default:e.LibraryPage})),__vite__mapDeps([51,1,2,3,4,17,10,5,52,23,25,53,54,45,55,48,21]),import.meta.url)),gh=p(()=>n(()=>import(`./Recordings-B8VQL_Ik.js`).then(e=>({default:e.RecordingsPage})),__vite__mapDeps([56,1,2,3,4,17,10,5,57,54,58,30,59,13,14,60,48,21]),import.meta.url)),_h=p(()=>n(()=>import(`./Viewer-BTxcZ-BR.js`).then(e=>({default:e.ViewerPage})),__vite__mapDeps([61,2,3,4,62,5,21,1]),import.meta.url)),vh=p(()=>n(()=>import(`./Build-BesaIcQt.js`).then(e=>({default:e.BuildPage})),__vite__mapDeps([63,1,2,3,4,17,10,5,34,23,64,54,39,33,40,41,42,43,44,14,47,13]),import.meta.url)),yh=p(()=>n(()=>import(`./CompositionEditorPage-CVp1OM-C.js`).then(e=>({default:e.CompositionEditorPage})),__vite__mapDeps([65,1,2,3,4,34,5,6,39,17,10,33,23,40,41,42]),import.meta.url)),bh=p(()=>n(()=>import(`./Locations-CaL7Y2a3.js`).then(e=>({default:e.LocationsPage})),__vite__mapDeps([66,1,2,3,4,10,5,34,67,53,54,46,41,42]),import.meta.url)),xh=p(()=>n(()=>import(`./Addons-CZ_5JUVc.js`).then(e=>({default:e.AddonsPage})),__vite__mapDeps([68,1,2,3,4,17,10,5,23,6,19,13,14,69,15,21]),import.meta.url)),Sh=p(()=>n(()=>import(`./AiProfiles-W2ByefcY.js`).then(e=>({default:e.AiProfilesPage})),__vite__mapDeps([70,1,2,3,4,10,5,71,72,6,54,21]),import.meta.url)),Ch=p(()=>n(()=>import(`./MyAccess-CNQzuYsW.js`).then(e=>({default:e.MyAccessPage})),__vite__mapDeps([73,1,2,3,4,17,10,5,23,74,75,76,77,6,54,78,21,79]),import.meta.url)),wh=p(()=>n(()=>import(`./Logs-Bu40SOPP.js`).then(e=>({default:e.LogsPage})),__vite__mapDeps([80,1,2,3,4,81,26,5,6,54,82,17,10,83,19,13,14,84,20,21,85]),import.meta.url)),Th=p(()=>n(()=>import(`./Identity-B_TiHuO-.js`).then(e=>({default:e.IdentityPage})),__vite__mapDeps([86,1,2,3,4,17,10,5,87,23,36,74,75,77,6,54,82,83,19,13,14,84,20,21,78,85]),import.meta.url)),Eh=p(()=>n(()=>import(`./Network-BBm6sZIX.js`).then(e=>({default:e.NetworkPage})),__vite__mapDeps([88,1,2,3,4,10,5,34,23,6,54,82,17,83,19,13,14,84,20,21,85]),import.meta.url)),Dh=p(()=>n(()=>import(`./Integrations-CK3qys8g.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([89,1,2,3,4,10,5,23,75,90,54,82,17,83,6,19,13,14,84,20,21]),import.meta.url)),Oh=p(()=>n(()=>import(`./Data-OpXlBhEa.js`).then(e=>({default:e.DataPage})),__vite__mapDeps([91,1,2,3,4,17,10,5,92,35,59,6,54,58,30,13,14,60,48,21]),import.meta.url)),kh=p(()=>n(()=>import(`./System-D-Xj3jc0.js`).then(e=>({default:e.SystemPage})),__vite__mapDeps([93,1,2,3,4,17,10,5,23,74,6,54,19,13,14,84,20,21]),import.meta.url)),Ah=p(()=>n(()=>import(`./Cluster-CnMcgkaB.js`).then(e=>({default:e.ClusterPage})),__vite__mapDeps([94,1,2,3,4,10,5,59,95,77,6,47,19,13,14,28,69,17,60]),import.meta.url)),jh=p(()=>n(()=>import(`./Terminal-DhbVA89N.js`).then(e=>({default:e.TerminalPage})),__vite__mapDeps([96,1,2,3,4,23,5,6,19,13,14,10,97]),import.meta.url)),Mh=p(()=>n(()=>import(`./Notifications-BS4cbFH2.js`).then(e=>({default:e.NotificationsPage})),__vite__mapDeps([98,1,2,3,4,17,10,5,32,23,71,99,6,54,44,40,14,47,55,21,42]),import.meta.url)),Nh=p(()=>n(()=>import(`./History-BLJJzgUt.js`).then(e=>({default:e.HistoryPage})),__vite__mapDeps([100,1,2,3,4,5,6]),import.meta.url)),Ph=p(()=>n(()=>import(`./Calendars-PHb_rEbJ.js`).then(e=>({default:e.CalendarsPage})),__vite__mapDeps([101,1,2,3,4,17,10,5,23,6]),import.meta.url)),Fh=p(()=>n(()=>import(`./Templates-D0V7IdcS.js`).then(e=>({default:e.TemplatesPage})),__vite__mapDeps([102,1,2,3,4,23,103,77,5,37,38,6]),import.meta.url)),Ih=new C({defaultOptions:{queries:{gcTime:0,staleTime:0,retry:!1,refetchOnWindowFocus:!1}}});Jn(Ih);function Lh({field:e,value:t,onChange:n,disabled:r}){return _(Zu,{field:e,value:t,onChange:n,disabled:r})}var Rh={"model-selector":Lh};function zh({children:e}){let{t}=W(),{user:n,logout:r}=du(),[a,o]=b(0),s=u(n?.username??null);v(()=>{let e=n?.username??null;e!==s.current&&(s.current=e,dl(),o(e=>e+1))},[n]);let c=d(()=>Q(),[a]),l=g(()=>{Q().reconnect(),o(e=>e+1),Ih.invalidateQueries()},[]);Cd(g(()=>kl(l),[l])),v(()=>Tl(()=>{Q().isSocketTokenStale()&&l()}),[l]);let f=g(async()=>{let e=await Al();return e&&l(),e},[l]),{bootReady:p,bootError:m}=xd(c,n??null,r,f);return _(vd,{children:_(ze,{system:c,children:_(pr.Provider,{client:c.trpcClient,queryClient:Ih,children:i(wn,{children:[_(gn,{children:_(Gn,{children:_(Jt,{children:p?e:_(Bh,{})})})}),p&&_(rd,{}),m!==null&&p&&i(`div`,{className:`fixed bottom-[calc(env(safe-area-inset-bottom)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 max-w-sm rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning shadow-lg`,children:[t(`app.bootProbeFailed`,`Boot probe failed:`),` `,m,`. Retrying in background.`]})]})})})})}function Bh(){let{t:e}=W();return _(`div`,{className:`flex min-h-screen items-center justify-center bg-background`,children:i(`div`,{className:`flex items-center gap-3 text-sm text-foreground-subtle`,children:[_(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),e(`app.connecting`,`Connecting…`)]})})}function Vh(){return _(`div`,{className:`flex min-h-screen items-center justify-center bg-background`,children:_(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`})})}function Hh(){return _(Nn,{defaultMode:`dark`,children:_(_n,{children:_(k,{client:Ih,children:_(uu,{children:_(zh,{children:_(Fe,{children:_(nd,{children:_(On,{renderers:Rh,children:i(Tn,{picker:oc,children:[_(ko,{basename:Ge(),children:_(Gu,{children:_(h,{fallback:_(Vh,{}),children:i(za,{children:[_(Z,{path:`/login`,element:_(ah,{})}),_(Z,{path:`/admin/*`,element:_(oh,{})}),_(Z,{path:`/admin`,element:_(oh,{})}),_(Z,{path:`/change-password`,element:_($,{children:_(hm,{})})}),_(Z,{path:`/showroom`,element:_(ph,{})}),_(Z,{path:`/embed/player`,element:_(mh,{})}),i(Z,{element:_($,{children:_(Hr,{children:_(Kp,{})})}),children:[_(Z,{index:!0,element:_(sh,{})}),_(Z,{path:`/access-denied`,element:_(lm,{})}),_(Z,{path:`/dashboard`,element:_(X,{to:`/devices`,replace:!0})}),_(Z,{path:`/devices`,element:_(ch,{})}),_(Z,{path:`/cameras`,element:_(X,{to:`/devices`,replace:!0})}),_(Z,{path:`/integrations`,element:_(lh,{})}),_(Z,{path:`/integrations/:addonId`,element:_(uh,{})}),_(Z,{path:`/system/pipeline`,element:_(Gd,{path:`/system/pipeline`,children:_(dh,{})})}),_(Z,{path:`/pipeline`,element:_(X,{to:`/system/pipeline`,replace:!0})}),_(Z,{path:`/live`,element:_(_h,{})}),_(Z,{path:`/devices/:deviceId`,element:_(fh,{})}),_(Z,{path:`/system/logs`,element:_($,{requireAdmin:!0,children:_(wh,{})})}),_(Z,{path:`/system/addons`,element:_($,{requireAdmin:!0,children:_(xh,{})})}),_(Z,{path:`/system/ai`,element:_($,{requireAdmin:!0,children:_(Sh,{})})}),_(Z,{path:`/system/settings`,element:_($,{requireAdmin:!0,children:_(kh,{})})}),_(Z,{path:`/system/nodes`,element:_($,{requireAdmin:!0,children:_(Ah,{})})}),_(Z,{path:`/system/notifications`,element:_($,{requireAdmin:!0,children:_(Mh,{})})}),_(Z,{path:`/system/history`,element:_($,{requireAdmin:!0,children:_(Nh,{})})}),_(Z,{path:`/system/calendars`,element:_($,{requireAdmin:!0,children:_(Ph,{})})}),_(Z,{path:`/system/templates`,element:_($,{requireAdmin:!0,children:_(Fh,{})})}),_(Z,{path:`/system/identity`,element:_($,{requireAdmin:!0,children:_(Th,{})})}),_(Z,{path:`/system/my-access`,element:_(Ch,{})}),_(Z,{path:`/system/network`,element:_($,{requireAdmin:!0,children:_(Eh,{})})}),_(Z,{path:`/system/integrations`,element:_($,{requireAdmin:!0,children:_(Dh,{})})}),_(Z,{path:`/system/data`,element:_($,{requireAdmin:!0,children:_(Oh,{})})}),_(Z,{path:`/system`,element:_(X,{to:od,replace:!0})}),_(Z,{path:`/system/terminal`,element:_($,{requireAdmin:!0,children:_(jh,{})})}),sd.map(e=>_(Z,{path:e.path,element:_(ld,{tab:e.tab})},e.path)),_(Z,{path:`/system/users`,element:_(X,{to:`/system/identity?tab=users`,replace:!0})}),_(Z,{path:`/system/api-keys`,element:_(X,{to:`/system/identity?tab=api-keys`,replace:!0})}),_(Z,{path:`/system/authentication`,element:_(X,{to:am(`authentication`),replace:!0})}),_(Z,{path:`/system/linked-sessions`,element:_(X,{to:`/system/identity?tab=linked-sessions`,replace:!0})}),_(Z,{path:`/system/remote-access`,element:_(X,{to:am(`remoteAccess`),replace:!0})}),_(Z,{path:`/system/turn`,element:_(X,{to:am(`turn`),replace:!0})}),_(Z,{path:`/system/storage`,element:_(X,{to:`/system/data?tab=storage`,replace:!0})}),_(Z,{path:`/system/backup`,element:_(X,{to:`/system/data?tab=backup`,replace:!0})}),_(Z,{path:`/library`,element:_($,{requireAdmin:!0,children:_(hh,{})})}),_(Z,{path:`/retrain`,element:_(X,{to:`/addon/training`,replace:!0})}),_(Z,{path:`/recordings`,element:_($,{requireAdmin:!0,children:_(gh,{})})}),_(Z,{path:`/build`,element:_($,{requireAdmin:!0,children:_(vh,{})})}),_(Z,{path:Jp,element:_($,{requireAdmin:!0,children:_(yh,{})})}),_(Z,{path:Yp,element:_($,{requireAdmin:!0,children:_(yh,{})})}),_(Z,{path:`/locations`,element:_($,{requireAdmin:!0,children:_(bh,{})})}),_(Z,{path:`/automation`,element:_(Qu,{to:`/build`})}),_(Z,{path:`/addon/:pagePath`,element:_($,{requireAdmin:!0,children:_(Ld,{})})}),_(Z,{path:`*`,element:_(X,{to:`/devices`,replace:!0})})]})]})})})}),_(hd,{})]})})})})})})})})})}w(),window.__camstackUiLibrary=$n,window.__camstackSdk=Rn,window.__camstackTypes=ut;var Uh=Or(document.getElementById(`root`));Fr(window.location.pathname,Ge())?eh(Uh):Uh.render(_(x,{children:_(Hh,{})}));export{ma as $,xu as A,bc as B,od as C,Tu as D,Du as E,Wc as F,nc as G,vc as H,Uc as I,ns as J,Us as K,kc as L,mu as M,pu as N,vu as O,du as P,ua as Q,xc as R,dd as S,Uu as T,fc as U,yc as V,oc as W,X,jo as Y,Y as Z,gf as _,nm as a,Ud as b,rm as c,sm as d,zo as et,Xp as f,Rf as g,Zp as h,tm as i,hu as j,yu as k,am as l,Qp as m,Dm as n,$p as o,qp as p,qs as q,im as r,em as s,km as t,om as u,vf as v,td as w,_d as x,_f as y,wc as z};
4
+ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let d=Y(),f;if(t){let e=typeof t==`string`?$r(t):t;G(l===`/`||e.pathname?.startsWith(l),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${l}" but pathname "${e.pathname}" was given in the \`location\` prop.`),f=e}else f=d;let p=f.pathname||`/`,m=p;if(l!==`/`){let e=l.replace(/^\//,``).split(`/`);m=`/`+p.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let h=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):ni(e,{pathname:m});K(u||h!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),K(h==null||h[h.length-1].route.element!==void 0||h[h.length-1].route.Component!==void 0||h[h.length-1].route.lazy!==void 0,`Matched leaf route at location "${f.pathname}${f.search}${f.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let g=wa(h&&h.map(e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:ji([l,i.encodeLocation?i.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?l:ji([l,i.encodeLocation?i.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),a,n);return t&&g?r(Qi.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...f},navigationType:`POP`}},g):g}function va(){let e=Na(),t=Li(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,i=`rgba(200,200,200, 0.5)`,a={padding:`0.5rem`,backgroundColor:i},o={padding:`2px 4px`,backgroundColor:i},s=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),s=r(c,null,r(`p`,null,`💿 Hey developer 👋`),r(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,r(`code`,{style:o},`ErrorBoundary`),` or`,` `,r(`code`,{style:o},`errorElement`),` prop on your route.`)),r(c,null,r(`h2`,null,`Unexpected Application Error!`),r(`h3`,{style:{fontStyle:`italic`}},t),n?r(`pre`,{style:a},n):null,s)}var ya=r(va,null),ba=class extends o{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=ia(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:r(J.Provider,{value:this.props.routeContext},r($i.Provider,{value:e,children:this.props.component}));return this.context?r(Sa,{error:e},t):t}};ba.contextType=qi;var xa=new WeakMap;function Sa({children:e,error:t}){let{basename:n}=j(q);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=ra(t.digest);if(e){let i=xa.get(t);if(i)throw i;let a=Bi(e.location,n),o=a.absoluteURL||a.to;if(Wi(o))throw Error(`Invalid redirect location`);if(zi&&!xa.get(t))if(a.isExternal||e.reloadDocument)window.location.href=o;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:e.replace}));throw xa.set(t,n),n}return r(`meta`,{httpEquiv:`refresh`,content:`0;url=${o}`})}}return e}function Ca({routeContext:e,match:t,children:n}){let i=j(Gi);return i&&i.static&&i.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=t.route.id),r(J.Provider,{value:e},n)}function wa(e,t=[],n){let i=n?.state;if(e==null){if(!i)return null;if(i.errors)e=i.matches;else if(t.length===0&&!i.initialized&&i.matches.length>0)e=i.matches;else return null}let a=e,o=i?.errors;if(o!=null){let e=a.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);G(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(`,`)}`),a=a.slice(0,Math.min(a.length,e+1))}let s=!1,c=-1;if(n&&i){s=i.renderFallback;for(let e=0;e<a.length;e++){let t=a[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(c=e),t.route.id){let{loaderData:e,errors:r}=i,o=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!r||r[t.route.id]===void 0);if(t.route.lazy||o){n.isStatic&&(s=!0),a=c>=0?a.slice(0,c+1):[a[0]];break}}}}let l=n?.onError,u=i&&l?(e,t)=>{l(e,{location:i.location,params:i.matches?.[0]?.params??{},pattern:Ri(i.matches),errorInfo:t})}:void 0;return a.reduceRight((e,n,l)=>{let d,f=!1,p=null,m=null;i&&(d=o&&n.route.id?o[n.route.id]:void 0,p=n.route.errorElement||ya,s&&(c<0&&l===0?(Ia(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),f=!0,m=null):c===l&&(f=!0,m=n.route.hydrateFallbackElement||null)));let h=t.concat(a.slice(0,l+1)),g=()=>{let t;return t=d?p:f?m:n.route.Component?r(n.route.Component,null):n.route.element?n.route.element:e,r(Ca,{match:n,routeContext:{outlet:e,matches:h,isDataRoute:i!=null},children:t})};return i&&(n.route.ErrorBoundary||n.route.errorElement||l===0)?r(ba,{location:i.location,revalidation:i.revalidation,component:p,error:d,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:u}):g()},null)}function Ta(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ea(e){let t=j(Gi);return G(t,Ta(e)),t}function Da(e){let t=j(Ki);return G(t,Ta(e)),t}function Oa(e){let t=j(J);return G(t,Ta(e)),t}function ka(e){let t=Oa(e),n=t.matches[t.matches.length-1];return G(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Aa(){return ka(`useRouteId`)}function ja(){let e=Da(`useNavigation`);return d(()=>{let{matches:t,historyAction:n,...r}=e.navigation;return r},[e.navigation])}function Ma(){let{matches:e,loaderData:t}=Da(`useMatches`);return d(()=>e.map(e=>ii(e,t)),[e,t])}function Na(){let e=j($i),t=Da(`useRouteError`),n=ka(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Pa(){let{router:e}=Ea(`useNavigate`),t=ka(`useNavigate`),n=u(!1);return la(()=>{n.current=!0}),g(async(r,i={})=>{K(n.current,ca),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var Fa={};function Ia(e,t,n){!t&&!Fa[e]&&(Fa[e]=!0,K(!1,n))}m(La);function La({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return _a(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function X({to:e,replace:t,state:n,relative:r}){G(oa(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=j(q);K(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=j(J),{pathname:o}=Y(),s=ua(),c=ki(e,Oi(a),o,r===`path`),l=JSON.stringify(c);return v(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function Z(e){G(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function Ra({basename:e=`/`,children:t=null,location:n,navigationType:i=`POP`,navigator:a,static:o=!1,useTransitions:s}){G(!oa(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let c=e.replace(/^\/*/,`/`),l=d(()=>({basename:c,navigator:a,static:o,useTransitions:s,future:{}}),[c,a,o,s]);typeof n==`string`&&(n=$r(n));let{pathname:u=`/`,search:f=``,hash:p=``,state:m=null,key:h=`default`,mask:g}=n,_=d(()=>{let e=Ci(u,c);return e==null?null:{location:{pathname:e,search:f,hash:p,state:m,key:h,mask:g},navigationType:i}},[c,u,f,p,m,h,i,g]);return K(_!=null,`<Router basename="${c}"> is not able to match the URL "${u}${f}${p}" because it does not start with the basename, so the <Router> won't render anything.`),_==null?null:r(q.Provider,{value:l},r(Qi.Provider,{children:t,value:_}))}function za({children:e,location:t}){return ga(Ba(e),t)}function Ba(e,t=[]){let n=[];return a.forEach(e,(e,r)=>{if(!f(e))return;let i=[...t,r];if(e.type===c){n.push.apply(n,Ba(e.props.children,i));return}G(e.type===Z,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),G(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=Ba(e.props.children,i)),n.push(a)}),n}var Va=`get`,Ha=`application/x-www-form-urlencoded`;function Ua(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function Wa(e){return Ua(e)&&e.tagName.toLowerCase()===`button`}function Ga(e){return Ua(e)&&e.tagName.toLowerCase()===`form`}function Ka(e){return Ua(e)&&e.tagName.toLowerCase()===`input`}function qa(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ja(e,t){return e.button===0&&(!t||t===`_self`)&&!qa(e)}function Ya(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function Xa(e,t){let n=Ya(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var Za=null;function Qa(){if(Za===null)try{new FormData(document.createElement(`form`),0),Za=!1}catch{Za=!0}return Za}var $a=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function eo(e){return e!=null&&!$a.has(e)?(K(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ha}"`),null):e}function to(e,t){let n,r,i,a,o;if(Ga(e)){let o=e.getAttribute(`action`);r=o?Ci(o,t):null,n=e.getAttribute(`method`)||Va,i=eo(e.getAttribute(`enctype`))||Ha,a=new FormData(e)}else if(Wa(e)||Ka(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?Ci(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||Va,i=eo(e.getAttribute(`formenctype`))||eo(o.getAttribute(`enctype`))||Ha,a=new FormData(o,e),!Qa()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(Ua(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=Va,r=null,i=Ha,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var no={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},ro=/[&><\u2028\u2029]/g;function io(e){return e.replace(ro,e=>no[e])}function ao(e,t){if(e===!1||e==null)throw Error(t)}function oo(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&Ci(i.pathname,t)===`/`?i.pathname=`${Mi(t)}/_root.${r}`:i.pathname=`${Mi(i.pathname)}.${r}`,i}async function so(e,t){if(e.id in t)return t[e.id];try{let r=await n(()=>import(e.module),[],import.meta.url);return t[e.id]=r,r}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function co(e){return e!=null&&typeof e.page==`string`}function lo(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function uo(e,t,n){return go((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await so(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(lo).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function fo(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function po(e,t,{includeHydrateFallback:n}={}){return mo(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function mo(e){return[...new Set(e)]}function ho(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function go(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!co(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(ho(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function _o(){let e=j(Gi);return ao(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function vo(){let e=j(Ki);return ao(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var yo=E(void 0);yo.displayName=`FrameworkContext`;function bo(){let e=j(yo);return ao(e,`You must render this element inside a <HydratedRouter> element`),e}function xo(e,t){let n=j(yo),[r,i]=b(!1),[a,o]=b(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:d,onTouchStart:f}=t,p=u(null);v(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return p.current&&e.observe(p.current),()=>{e.disconnect()}}},[e]),v(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let m=()=>{i(!0)},h=()=>{i(!1),o(!1)};return n?e===`intent`?[a,p,{onFocus:So(s,m),onBlur:So(c,h),onMouseEnter:So(l,m),onMouseLeave:So(d,h),onTouchStart:So(f,m)}]:[a,p,{}]:[!1,p,{}]}function So(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Co({page:e,...t}){let n=Ji(),{nonce:i}=bo(),{router:a}=_o(),o=d(()=>ni(a.routes,e,a.basename),[a.routes,e,a.basename]);return o?(t.nonce==null&&i&&(t={...t,nonce:i}),r(n?To:Eo,{page:e,matches:o,...t})):null}function wo(e){let{manifest:t,routeModules:n}=bo(),[r,i]=b([]);return v(()=>{let r=!1;return uo(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function To({page:e,matches:t,...n}){let i=Y(),{future:a}=bo(),{basename:o}=_o();return r(c,null,d(()=>{if(e===i.pathname+i.search+i.hash)return[];let n=oo(e,o,a.v8_trailingSlashAwareDataRequests,`rsc`),r=!1,s=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?r=!0:s.push(e.route.id);return r&&s.length>0&&n.searchParams.set(`_routes`,s.join(`,`)),[n.pathname+n.search]},[o,a.v8_trailingSlashAwareDataRequests,e,i,t]).map(e=>r(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})))}function Eo({page:e,matches:t,...n}){let i=Y(),{future:a,manifest:o,routeModules:s}=bo(),{basename:l}=_o(),{loaderData:u,matches:f}=vo(),p=d(()=>fo(e,t,f,o,i,`data`),[e,t,f,o,i]),m=d(()=>fo(e,t,f,o,i,`assets`),[e,t,f,o,i]),h=d(()=>{if(e===i.pathname+i.search+i.hash)return[];let n=new Set,r=!1;if(t.forEach(e=>{let t=o.routes[e.route.id];!t||!t.hasLoader||(!p.some(t=>t.route.id===e.route.id)&&e.route.id in u&&s[e.route.id]?.shouldRevalidate||t.hasClientLoader?r=!0:n.add(e.route.id))}),n.size===0)return[];let c=oo(e,l,a.v8_trailingSlashAwareDataRequests,`data`);return r&&n.size>0&&c.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[c.pathname+c.search]},[l,a.v8_trailingSlashAwareDataRequests,u,i,o,p,t,e,s]),g=d(()=>po(m,o),[m,o]),_=wo(m);return r(c,null,h.map(e=>r(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),g.map(e=>r(`link`,{key:e,rel:`modulepreload`,href:e,...n})),_.map(({key:e,link:t})=>r(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function Do(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var Oo=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{Oo&&(window.__reactRouterVersion=`7.18.0`)}catch{}function ko({basename:e,children:t,useTransitions:n,window:i}){let a=u();a.current??=Jr({window:i,v5Compat:!0});let o=a.current,[c,d]=b({action:o.action,location:o.location}),f=g(e=>{n===!1?d(e):l(()=>d(e))},[n]);return s(()=>o.listen(f),[o,f]),r(Ra,{basename:e,children:t,location:c.location,navigationType:c.action,navigator:o,useTransitions:n})}function Ao({basename:e,children:t,history:n,useTransitions:i}){let[a,o]=b({action:n.action,location:n.location}),c=g(e=>{i===!1?o(e):l(()=>o(e))},[i]);return s(()=>n.listen(c),[n,c]),r(Ra,{basename:e,children:t,location:a.location,navigationType:a.action,navigator:n,useTransitions:i})}Ao.displayName=`unstable_HistoryRouter`;var jo=T(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:i,reloadDocument:a,replace:o,mask:s,state:l,target:u,to:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m,...h},g){let{basename:_,navigator:v,useTransitions:y}=j(q),b=typeof d==`string`&&Ur.test(d),x=Bi(d,_);d=x.to;let S=aa(d,{relative:i}),C=Y(),w=null;if(s){let e=ki(s,[],C.mask?C.mask.pathname:`/`,!0);_!==`/`&&(e.pathname=e.pathname===`/`?_:ji([_,e.pathname])),w=v.createHref(e)}let[T,E,D]=xo(n,h),O=Ro(d,{replace:o,mask:s,state:l,target:u,preventScrollReset:f,relative:i,viewTransition:p,defaultShouldRevalidate:m,useTransitions:y});function k(t){e&&e(t),t.defaultPrevented||O(t)}let A=!(x.isExternal||a),M=r(`a`,{...h,...D,href:(A?w:void 0)||x.absoluteURL||S,onClick:A?k:e,ref:Do(g,E),target:u,"data-discover":!b&&t===`render`?`true`:void 0});return T&&!b?r(c,null,M,r(Co,{page:S})):M});jo.displayName=`Link`;var Mo=T(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:i=!1,style:a,to:o,viewTransition:s,children:c,...l},u){let d=ha(o,{relative:l.relative}),f=Y(),p=j(Ki),{navigator:m,basename:h}=j(q),g=p!=null&&Yo(d)&&s===!0,_=m.encodeLocation?m.encodeLocation(d).pathname:d.pathname,v=f.pathname,y=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;t||(v=v.toLowerCase(),y=y?y.toLowerCase():null,_=_.toLowerCase()),y&&h&&(y=Ci(y,h)||y);let b=_!==`/`&&_.endsWith(`/`)?_.length-1:_.length,x=v===_||!i&&v.startsWith(_)&&v.charAt(b)===`/`,S=y!=null&&(y===_||!i&&y.startsWith(_)&&y.charAt(_.length)===`/`),C={isActive:x,isPending:S,isTransitioning:g},w=x?e:void 0,T;T=typeof n==`function`?n(C):[n,x?`active`:null,S?`pending`:null,g?`transitioning`:null].filter(Boolean).join(` `);let E=typeof a==`function`?a(C):a;return r(jo,{...l,"aria-current":w,className:T,ref:u,style:E,to:o,viewTransition:s},typeof c==`function`?c(C):c)});Mo.displayName=`NavLink`;var No=T(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:i,replace:a,state:o,method:s=Va,action:c,onSubmit:u,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m,...h},g)=>{let{useTransitions:_}=j(q),v=Ho(),y=Uo(c,{relative:d}),b=s.toLowerCase()===`get`?`get`:`post`,x=typeof c==`string`&&Ur.test(c);return r(`form`,{ref:g,method:b,action:y,onSubmit:i?u:e=>{if(u&&u(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,i=r?.getAttribute(`formmethod`)||s,c=()=>v(r||e.currentTarget,{fetcherKey:t,method:i,navigate:n,replace:a,state:o,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m});_&&n!==!1?l(()=>c()):c()},...h,"data-discover":!x&&e===`render`?`true`:void 0})});No.displayName=`Form`;function Po({getKey:e,storageKey:t,...n}){let i=j(yo),{basename:a}=j(q),o=Y(),s=Ma();qo({getKey:e,storageKey:t});let c=d(()=>{if(!i||!e)return null;let t=Ko(o,s,a,e);return t===o.key?null:t},[]);if(!i||i.isSpaMode)return null;let l=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return n.nonce==null&&i?.nonce&&(n.nonce=i.nonce),r(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${l})(${io(JSON.stringify(t||Wo))}, ${io(JSON.stringify(c))})`}})}Po.displayName=`ScrollRestoration`;function Fo(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Io(e){let t=j(Gi);return G(t,Fo(e)),t}function Lo(e){let t=j(Ki);return G(t,Fo(e)),t}function Ro(e,{target:t,replace:n,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c,useTransitions:u}={}){let d=ua(),f=Y(),p=ha(e,{relative:o});return g(m=>{if(Ja(m,t)){m.preventDefault();let t=n===void 0?Qr(f)===Qr(p):n,h=()=>d(e,{replace:t,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c});u?l(()=>h()):h()}},[f,d,p,n,r,i,t,e,a,o,s,c,u])}function zo(e){K(typeof URLSearchParams<`u`,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=u(Ya(e)),n=u(!1),r=Y(),i=d(()=>Xa(r.search,n.current?null:t.current),[r.search]),a=ua();return[i,g((e,t)=>{let r=Ya(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var Bo=0,Vo=()=>`__${String(++Bo)}__`;function Ho(){let{router:e}=Io(`useSubmit`),{basename:t}=j(q),n=Aa(),r=e.fetch,i=e.navigate;return g(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=to(e,t);a.navigate===!1?await r(a.fetcherKey||Vo(),n,a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function Uo(e,{relative:t}={}){let{basename:n}=j(q),r=j(J);G(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...ha(e||`.`,{relative:t})},o=Y();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:ji([n,a.pathname])),Qr(a)}var Wo=`react-router-scroll-positions`,Go={};function Ko(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:Ci(e.pathname,n)||e.pathname},t)),i??=e.key,i}function qo({getKey:e,storageKey:t}={}){let{router:n}=Io(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=Lo(`useScrollRestoration`),{basename:a}=j(q),o=Y(),c=Ma(),l=ja();v(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Jo(g(()=>{if(l.state===`idle`){let t=Ko(o,c,a,e);Go[t]=window.scrollY}try{sessionStorage.setItem(t||Wo,JSON.stringify(Go))}catch(e){K(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[l.state,e,a,o,c,t])),typeof document<`u`&&(s(()=>{try{let e=sessionStorage.getItem(t||Wo);e&&(Go=JSON.parse(e))}catch{}},[t]),s(()=>{let t=n?.enableScrollRestoration(Go,()=>window.scrollY,e?(t,n)=>Ko(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),s(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{K(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function Jo(e,t){let{capture:n}=t||{};v(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function Yo(e,{relative:t}={}){let n=j(Yi);G(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Io(`useViewTransitionState`),i=ha(e,{relative:t});if(!n.isTransitioning)return!1;let a=Ci(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Ci(n.nextLocation.pathname,r)||n.nextLocation.pathname;return yi(i.pathname,o)!=null||yi(i.pathname,a)!=null}var Xo=`camstack:broker-oauth`;function Zo(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`camstack:broker-oauth`&&typeof t.ok==`boolean`}function Qo(e,t){return e.split(`{{brokerId}}`).join(encodeURIComponent(t))}function $o(e,t,n=window){let r=n.location.origin,i=!1,a=e=>{i||(i=!0,n.removeEventListener(`message`,o),window.clearInterval(s),t(e))},o=t=>{t.origin!==r||t.source!==e||Zo(t.data)&&a({ok:t.data.ok,...t.data.brokerId===void 0?{}:{brokerId:t.data.brokerId},...t.data.error===void 0?{}:{error:t.data.error}})};n.addEventListener(`message`,o);let s=window.setInterval(()=>{e.closed&&a({ok:!0})},500);return()=>{i=!0,n.removeEventListener(`message`,o),window.clearInterval(s)}}var es={open:e=>Pr(e),assign:e=>window.location.assign(e),watch:(e,t)=>$o(e,t)};function ts(e,t,n=es){let r=z(Mr(e)),i=n.open(r);if(i===null){n.assign(r);return}n.watch(i,e=>{t?.(e)})}function ns(e,t,n){ts(Qo(e,t),n)}function rs(e,t){let n=e=>e.map(e=>e.type===`group`?{...e,fields:n(e.fields)}:e.type===`sub-tabs`?{...e,tabs:e.tabs.map(e=>({...e,fields:n(e.fields)}))}:e.type===`info`&&typeof e.content==`string`?{...e,content:e.content.split(`{{brokerId}}`).join(t)}:e);return{...e,sections:e.sections.map(e=>({...e,fields:n(e.fields)}))}}var is=`broker-advanced`;function as(e){return`key`in e&&typeof e.key==`string`&&`label`in e}function os(e){let t=new Set;for(let n of e){if(!as(n))continue;let e=n.showWhen;if(e===void 0)continue;let r=Array.isArray(e)?e:[e];for(let e of r)typeof e==`object`&&e&&`field`in e&&typeof e.field==`string`&&t.add(e.field)}return t}function ss(e,t,n){return!as(e)||e.showWhen!==void 0||t.has(e.key)?!1:n&&e.filledBySignIn===!0?!0:e.default!==void 0||e.defaultByCountry!==void 0}function cs(e,t){let n=[],r=[];for(let i of e.sections){let e=os(i.fields),a=[];for(let r of i.fields)ss(r,e,t.hasSignIn)?n.push(r):a.push(r);if(a.length>0)r.push({...i,fields:a});else if(i.description!==void 0){let{description:e,...t}=i;r.push({...t,fields:[{type:`info`,key:`${i.id}-note`,label:``,content:e}]})}}return n.length>0&&r.push({id:is,title:t.advancedTitle,style:`accordion`,defaultCollapsed:!0,columns:1,fields:n}),{...e,sections:r}}function ls(e){if(e===void 0)return null;let t=/[-_]([A-Za-z]{2})(?:[-_]|$)/.exec(e);return t?.[1]===void 0?null:t[1].toUpperCase()}function us(e,t,n){if(e===void 0||t===null)return{};let r={};for(let i of e.sections)for(let e of i.fields){if(!as(e)||n[e.key]!==void 0)continue;let i=e.defaultByCountry;i!==void 0&&t in i&&(r[e.key]=i[t])}return r}var ds=[`starting`,`awaiting-login`,`captured`,`error`,`cancelled`],fs=[`awaiting-code`,`captured`,`expired`,`error`,`cancelled`];function ps(e){return typeof e==`object`&&!!e}function ms(e){return ps(e)&&typeof e.sessionId==`string`&&typeof e.loginUrl==`string`}function hs(e){return ps(e)&&typeof e.sessionId==`string`&&typeof e.phase==`string`&&ds.includes(e.phase)}function gs(e){return ps(e)&&typeof e.sessionId==`string`&&typeof e.userCode==`string`&&typeof e.verificationUrl==`string`&&typeof e.expiresAt==`number`}function _s(e){return gs(e)&&ps(e)&&typeof e.phase==`string`&&fs.includes(e.phase)}function vs(e){return ps(e)&&typeof e.brokerId==`string`}function ys(){return{"Content-Type":`application/json`,Authorization:`Bearer ${localStorage.getItem(`camstack_admin_token`)??``}`}}async function bs(e,t){try{return await e.json()}catch{throw Error(`${t} failed: HTTP ${e.status}`)}}function xs(e){let t=ps(e)&&typeof e.error==`string`?e.error:`Unknown error`;return Error(t)}async function Ss(e,t,n){let r=await fetch(z(e),{method:`POST`,headers:ys(),body:JSON.stringify(t)}),i=await bs(r,`Sign-in ${e.split(`/`).pop()??`request`}`);if(!r.ok)throw xs(i);if(!n(i))throw Error(`Unexpected response from server`);return i}function Cs(e,t){return Ss(`${e}/start`,t,ms)}function ws(e,t){return Ss(`${e}/code/start`,t,gs)}async function Ts(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(z(`${e}/status?${n.toString()}`),{headers:{Authorization:ys().Authorization??``}}),i=await bs(r,`Sign-in status`);if(!r.ok)throw xs(i);if(!_s(i))throw Error(`Unexpected status response from server`);return i}async function Es(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(z(`${e}/status?${n.toString()}`),{headers:{Authorization:ys().Authorization??``}}),i=await bs(r,`Sign-in status`);if(!r.ok)throw xs(i);if(!hs(i))throw Error(`Unexpected status response from server`);return i}function Ds(e,t){return Ss(`${e}/commit`,{...t},vs)}async function Os(e,t){try{await fetch(z(`${e}/cancel`),{method:`POST`,headers:ys(),body:JSON.stringify({sessionId:t})})}catch{}}w();var ks=2e3,As=1e3;function js(e){let t=Math.max(0,Math.ceil(e/1e3));return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,`0`)}`}function Ms({expiresAt:e}){let{t}=W(),[n,r]=b(()=>Date.now());return v(()=>{let e=setInterval(()=>r(Date.now()),As);return()=>clearInterval(e)},[]),_(`span`,{className:`text-[11px] text-foreground-subtle`,children:t(`brokers.signIn.codeExpiresIn`,{time:js(e-n)})})}function Ns({basePath:e,name:t,brokerId:n,getSettings:r,disabled:a,onSignedIn:o}){let{t:s}=W(),[c,l]=b({kind:`idle`}),d=u(!0),f=u(null),p=u(null),m=g(()=>{p.current!==null&&clearInterval(p.current),p.current=null},[]),h=g(()=>{m();let t=f.current;f.current=null,t!==null&&Os(e,t)},[e,m]);v(()=>(d.current=!0,()=>{d.current=!1,h()}),[h]);let y=g(e=>{m(),d.current&&l({kind:`error`,message:e})},[m]),x=g(async r=>{m(),d.current&&l({kind:`committing`});try{let i=await Ds(e,{sessionId:r,name:t,...n===void 0?{}:{brokerId:n}});f.current=null,d.current&&o(i.brokerId)}catch(e){y(e instanceof Error?e.message:String(e))}},[e,n,y,t,o,m]),S=g(t=>{m(),p.current=setInterval(()=>{(async()=>{try{let n=await Ts(e,t);if(n.phase===`captured`)return void await x(t);if(n.phase===`error`)return y(n.error??s(`brokers.signIn.proxyError`));if(n.phase===`expired`){m(),d.current&&l({kind:`expired`});return}n.phase===`cancelled`&&(m(),d.current&&l({kind:`idle`}))}catch{}})()},ks)},[e,x,y,m,s]),C=async()=>{h(),l({kind:`starting`});try{let t=await ws(e,r());f.current=t.sessionId,l({kind:`waiting`,code:t}),S(t.sessionId)}catch(e){y(e instanceof Error?e.message:String(e))}},w=()=>{h(),l({kind:`idle`})};if(c.kind===`idle`||c.kind===`error`||c.kind===`expired`)return i(`div`,{className:`space-y-2`,children:[c.kind===`error`&&_(V,{message:c.message}),c.kind===`expired`&&_(`p`,{className:`text-xs text-warning`,children:s(`brokers.signIn.codeExpired`)}),_(`p`,{className:`text-xs text-foreground-muted`,children:s(`brokers.signIn.codeIntro`)}),i(H,{variant:`primary`,size:`sm`,disabled:a===!0||t.trim().length===0,onClick:()=>void C(),children:[c.kind===`idle`?_(pt,{className:`h-3.5 w-3.5`}):_(te,{className:`h-3.5 w-3.5`}),` `,c.kind===`idle`?s(`brokers.signIn.getCode`):s(`brokers.signIn.newCode`)]})]});if(c.kind===`starting`||c.kind===`committing`)return i(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[_(B,{className:`h-4 w-4 animate-spin flex-shrink-0`}),c.kind===`starting`?s(`brokers.signIn.starting`):s(`brokers.signIn.saving`)]});let{code:T}=c;return i(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-3`,children:[_(`p`,{className:`text-xs text-foreground-muted`,children:s(`brokers.signIn.codeInstructions`)}),i(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border-subtle bg-background px-3 py-2`,children:[_(`span`,{"data-testid":`device-code`,className:`font-mono text-2xl font-semibold tracking-widest text-foreground break-all`,children:T.userCode}),_(yr,{value:T.userCode,srLabel:s(`brokers.signIn.copyCode`)})]}),i(H,{variant:`primary`,size:`sm`,onClick:()=>window.open(T.verificationUrl,`_blank`,`noopener,noreferrer`),children:[_(He,{className:`h-3.5 w-3.5`}),` `,s(`brokers.signIn.openCodePage`,{host:Ps(T.verificationUrl)})]}),i(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-1`,children:[i(`span`,{className:`flex min-w-0 flex-col text-[11px] text-foreground-subtle`,children:[i(`span`,{className:`flex items-center gap-2`,children:[_(B,{className:`h-3 w-3 animate-spin flex-shrink-0`}),` `,s(`brokers.signIn.waitingForCode`)]}),_(Ms,{expiresAt:T.expiresAt})]}),_(H,{variant:`outline`,size:`sm`,className:`shrink-0 whitespace-nowrap`,onClick:w,children:s(`brokers.signIn.cancel`)})]})]})}function Ps(e){try{let t=new URL(e);return`${t.host}${t.pathname===`/`?``:t.pathname}`}catch{return e}}w();var Fs=2e3;function Is(e){return e.startsWith(`/`)&&!e.startsWith(`//`)?new URL(e,window.location.origin).toString():e}function Ls({basePath:e,name:t,brokerId:n,getSettings:r,disabled:a,onSignedIn:o}){let{t:s}=W(),[c,l]=b({kind:`idle`}),d=u(!0),f=u(null),p=u(null),m=g(()=>{p.current!==null&&clearInterval(p.current),p.current=null},[]),h=g(()=>{m();let t=f.current;f.current=null,t!==null&&Os(e,t)},[e,m]);v(()=>(d.current=!0,()=>{d.current=!1,h()}),[h]);let y=g(e=>{m(),d.current&&l({kind:`error`,message:e})},[m]),x=g(async r=>{m(),d.current&&l({kind:`committing`});try{let i=await Ds(e,{sessionId:r,name:t,...n===void 0?{}:{brokerId:n}});f.current=null,d.current&&o(i.brokerId)}catch(e){y(e instanceof Error?e.message:String(e))}},[e,n,y,t,o,m]),S=g(t=>{m(),p.current=setInterval(()=>{(async()=>{try{let n=await Es(e,t);if(n.phase===`captured`)return void await x(t);if(n.phase===`error`)return y(n.error??s(`brokers.signIn.proxyError`));if(n.phase===`cancelled`){m(),d.current&&l({kind:`idle`});return}d.current&&l({kind:`waiting`,loginUrl:n.loginUrl,ready:n.phase===`awaiting-login`})}catch{}})()},Fs)},[e,x,y,m,s]),C=async()=>{h(),l({kind:`starting`});try{let t=await Cs(e,r());f.current=t.sessionId,l({kind:`waiting`,loginUrl:t.loginUrl,ready:!1}),S(t.sessionId)}catch(e){y(e instanceof Error?e.message:String(e))}};return c.kind===`idle`||c.kind===`error`?i(`div`,{className:`space-y-2`,children:[c.kind===`error`&&_(V,{message:c.message}),_(`p`,{className:`text-xs text-foreground-muted`,children:s(`brokers.signIn.intro`)}),i(H,{variant:`primary`,size:`sm`,disabled:a===!0||t.trim().length===0,onClick:()=>void C(),children:[_(pt,{className:`h-3.5 w-3.5`}),` `,c.kind===`error`?s(`common.retry`):s(`brokers.signIn.start`)]})]}):c.kind===`starting`||c.kind===`committing`?i(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[_(B,{className:`h-4 w-4 animate-spin flex-shrink-0`}),c.kind===`starting`?s(`brokers.signIn.starting`):s(`brokers.signIn.saving`)]}):i(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-3`,children:[c.ready?i(A,{children:[_(`p`,{className:`text-xs font-semibold text-foreground`,children:s(`brokers.signIn.openLink`)}),_(`p`,{className:`text-[11px] text-foreground-subtle`,children:s(`brokers.signIn.afterLogin`)}),i(H,{variant:`primary`,size:`sm`,onClick:()=>window.open(Is(c.loginUrl),`_blank`,`noopener,noreferrer`),children:[_(He,{className:`h-3.5 w-3.5`}),` `,s(`brokers.signIn.openLoginPage`)]})]}):i(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[_(B,{className:`h-4 w-4 animate-spin flex-shrink-0`}),s(`brokers.signIn.waitingForProxy`)]}),i(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[i(`span`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[_(B,{className:`h-3 w-3 animate-spin`}),` `,s(`brokers.signIn.waitingForLogin`)]}),_(H,{variant:`outline`,size:`sm`,onClick:()=>{h(),l({kind:`idle`})},children:s(`brokers.signIn.cancel`)})]})]})}w();var Rs=[`device-code`];function zs({methods:e,...t}){let{t:n}=W(),r=e!==void 0&&e.length>0?e:Rs,[a,o]=b(null),s=a!==null&&r.includes(a)?a:r[0]??`device-code`;return i(`div`,{className:`space-y-2`,children:[r.length>1&&_(Vt,{value:s,onValueChange:e=>o(e===`device-code`?e:`proxy`),appearance:`pills`,children:_(ar,{"aria-label":n(`brokers.signIn.method`),children:r.map(e=>_(qt,{value:e,children:n(e===`device-code`?`brokers.signIn.methodDeviceCode`:`brokers.signIn.methodProxy`)},e))})}),s===`device-code`?_(Ns,{...t},`device-code`):_(Ls,{...t},`proxy`)]})}w();function Bs(e,t){if(!e)return t;let n=new Set;for(let r of e.sections){let e=r.fields;for(let r of e)!(`key`in r)||typeof r.key!=`string`||Vn(r,t,e)&&n.add(r.key)}let r={};for(let[e,i]of Object.entries(t))n.has(e)&&(r[e]=i);return r}function Vs({kind:e,addonId:t,brokerId:n,initialValues:r,onSubmit:a,onCancel:o,submitLabel:s,disabled:c,signIn:l}){let{t:u}=W(),[f,p]=b(r??{}),[m,h]=b(null),g=jt({kind:e,...t===void 0?{}:{addonId:t}}),y=d(()=>{let e=g.data;if(e&&typeof e==`object`&&`sections`in e&&Array.isArray(e.sections)){let t=e;return cs(et(n===void 0?t:rs(t,n),f),{hasSignIn:l!==void 0,advancedTitle:u(`brokers.brokerForm.advanced`)})}},[g.data,n,f,l!==void 0,u]);v(()=>{r!==void 0&&p(r)},[r]);let x=ls(typeof navigator>`u`?void 0:navigator.language);v(()=>{if(r!==void 0)return;let e=us(y,x,f);Object.keys(e).length>0&&p(t=>({...e,...t}))},[y,x,r,f]);let S=Cr(),C=async()=>{h(null);let n=Bs(y,f);try{let r=await S.mutateAsync({kind:e,settings:n,...t===void 0?{}:{addonId:t}});h(r.ok?{ok:!0}:{ok:!1,error:r.error})}catch(e){h({ok:!1,error:e instanceof Error?e.message:String(e)})}},w=()=>{let{_calendarCatalog:e,...t}=Bs(y,f);a(t)},T=()=>{let e=new Set;for(let t of y?.sections??[])for(let n of t.fields)as(n)&&n.filledBySignIn===!0&&e.add(n.key);let t=Bs(y,f);return Object.fromEntries(Object.entries(t).filter(([t])=>!e.has(t)))};return i(`div`,{className:`space-y-3`,children:[l!==void 0&&_(zs,{basePath:l.basePath,...l.methods===void 0?{}:{methods:l.methods},name:l.name,...l.brokerId===void 0?{}:{brokerId:l.brokerId},getSettings:T,disabled:c===!0,onSignedIn:l.onSignedIn}),g.isLoading&&i(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[_(B,{className:`h-3.5 w-3.5 animate-spin`}),` `,u(`brokers.brokerForm.loadingSchema`)]}),y&&_(Ar,{schema:y,values:f,onChange:p}),g.isError&&i(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[u(`brokers.brokerForm.failedToLoadSettingsSchema`,`Failed to load settings schema:`),` `,g.error instanceof Error?g.error.message:u(`brokers.brokerForm.unknownError`,`Unknown error`)]}),!y&&!g.isLoading&&!g.isError&&_(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-[11px] text-warning`,children:_(kr,{i18nKey:`brokers.brokerForm.noSchema`,values:{kind:e},components:{code:_(`code`,{className:`font-mono`})}})}),m&&_(`div`,{className:`rounded border px-3 py-2 text-[11px] ${m.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:m.ok?u(`brokers.brokerForm.connectionOk`,`Connection OK.`):u(`brokers.brokerForm.testFailed`,`Test failed: {{value1}}`,{value1:m.error??`unknown error`})}),i(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[_(H,{variant:`outline`,size:`sm`,onClick:o,children:u(`common.cancel`,`Cancel`)}),i(`div`,{className:`flex items-center gap-2`,children:[_(H,{variant:`outline`,size:`sm`,onClick:()=>{C()},disabled:S.isPending||!y,children:S.isPending?u(`brokers.brokerForm.testing`,`Testing…`):u(`brokers.brokerForm.testConnection`,`Test connection`)}),_(H,{variant:l===void 0?`primary`:`outline`,size:`sm`,onClick:w,disabled:!y||c,children:s??u(`common.save`,`Save`)})]})]})]})}w();function Hs(e){return e===void 0?``:`${e.addonId??``}::${e.kind}`}function Us(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function Ws(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}function Gs(e){return typeof e==`string`&&e.length>0?e:void 0}function Ks(e){let t=new Map;for(let n of e.providers)if(!(e.addonId!==void 0&&n.addonId!==e.addonId))for(let r of n.kinds){if(e.kind!==void 0&&r.kind!==e.kind)continue;let i=Gs(r.interactiveConnectPath),a=Gs(r.interactiveDisconnectPath),o=Gs(r.signIn?.basePath);t.set(`${n.addonId}::${r.kind}`,{addonId:n.addonId,kind:r.kind,label:r.label,...i===void 0?{}:{interactiveConnectPath:i},...a===void 0?{}:{interactiveDisconnectPath:a},...o===void 0?{}:{signInBasePath:o},...o!==void 0&&r.signIn?.methods!==void 0&&r.signIn.methods.length>0?{signInMethods:r.signIn.methods}:{}})}for(let n of e.brokers)e.kind!==void 0&&n.kind!==e.kind||[...t.values()].some(e=>e.kind===n.kind)||t.set(`::${n.kind}`,{kind:n.kind,label:n.kind});return[...t.values()]}function qs(e){let t=sn(),n=tn(e.kind===void 0?{}:{kind:e.kind});return{options:d(()=>Ks({providers:Ws(t.data),brokers:Us(n.data).filter(t=>e.addonId===void 0||t.addonId===e.addonId),...e.addonId===void 0?{}:{addonId:e.addonId},...e.kind===void 0?{}:{kind:e.kind}}),[t.data,n.data,e.addonId,e.kind]),isLoading:t.isLoading===!0}}var Js=`kind`,Ys=`name`,Xs=`restore`,Zs=`restoreId`;function Qs(e,t={allowRestore:!0}){let n=[];return e.length>1&&n.push({type:`select`,key:Js,label:U.t(`helpers.brokerIdentitySchema.kind`),options:e.map(e=>({value:e.key,label:e.label}))}),n.push({type:`text`,key:Ys,label:U.t(`helpers.brokerIdentitySchema.name`),placeholder:U.t(`helpers.brokerIdentitySchema.namePlaceholder`),required:!0}),t.allowRestore&&n.push({type:`boolean`,key:Xs,label:U.t(`helpers.brokerIdentitySchema.restore`),description:U.t(`helpers.brokerIdentitySchema.restoreHint`)},{type:`text`,key:Zs,label:U.t(`helpers.brokerIdentitySchema.originalId`),placeholder:`ha_004`,required:!0,showWhen:{field:Xs,equals:!0}}),{sections:[{id:`broker-identity`,title:U.t(`helpers.brokerIdentitySchema.title`),columns:1,fields:n}]}}function $s(e){let t=t=>{let n=e[t];return typeof n==`string`?n.trim():``},n=t(Js);if(n===``)return{ok:!1,problem:`Pick a kind.`};let r=t(Ys);if(r===``)return{ok:!1,problem:`Enter a name before saving.`};if(e.restore!==!0)return{ok:!0,identity:{kindKey:n,name:r,restoreId:null}};let i=t(Zs);return i===``?{ok:!1,problem:`Enter the original id, or turn restore off to create a new broker.`}:{ok:!0,identity:{kindKey:n,name:r,restoreId:i}}}w();function ec({title:e,subtitle:t,onClose:n,children:r}){return _(An,{open:!0,onOpenChange:e=>!e&&n(),children:i(un,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(dn,{children:[_(Ft,{children:e}),t&&_(Pt,{children:t})]}),_(br,{className:`space-y-3 pr-1`,children:r})]})})}function tc(e,t){let n=new Set(t.map(e=>e.trim().toLowerCase()));if(!n.has(e.toLowerCase()))return e;for(let t=2;;t++){let r=`${e} ${t}`;if(!n.has(r.toLowerCase()))return r}}function nc(e){return e.broker===void 0?_(rc,{...e}):_(ic,{...e,broker:e.broker})}function rc({kind:e,addonId:t,onClose:n,onSaved:r}){let{t:a}=W(),o=O(),{options:s,isLoading:c}=qs({...t===void 0?{}:{addonId:t},...e===void 0?{}:{kind:e}}),l=tn({}),f=d(()=>Us(l.data).map(e=>e.name),[l.data]),[p,m]=b({[Ys]:``,[Xs]:!1,[Zs]:``}),[h,g]=b(null),y=s.find(e=>Hs(e)===p.kind)??s[0],x=Hs(y),S=y===void 0?``:tc(y.label,f),C=u(``);v(()=>{x!==``&&m(e=>{let t=typeof e.name==`string`?e[Ys]:``,n=t===``||t===C.current;C.current=S;let r=n?S:t;return e.kind===x&&t===r?e:{...e,[Js]:x,[Ys]:r}})},[x,S]);let w=d(()=>Qs(s.map(e=>({key:Hs(e),label:e.label})),{allowRestore:y?.signInBasePath===void 0}),[s,y?.signInBasePath]),T=e=>{o.invalidateQueries({queryKey:[[`broker`,`list`]]}),r(e)},E=an({onSuccess:e=>{let t=typeof e==`object`&&e&&typeof e.id==`string`?e.id:null,n=y?.interactiveConnectPath;t!==null&&n!==void 0&&ns(n,t,()=>{o.invalidateQueries({queryKey:[[`broker`,`list`]]})}),t!==null&&T(t)}}),D=$s(p),k=D.ok?D.identity.name:``,j=e=>{if(y!==void 0){if(!D.ok){g(D.problem);return}g(null),E.mutate({kind:y.kind,name:D.identity.name,settings:e,...D.identity.restoreId===null?{}:{id:D.identity.restoreId},...y.addonId===void 0?{}:{addonId:y.addonId}})}},M=E.isPending;return _(ec,{title:a(`brokers.editor.createTitle`),subtitle:a(`brokers.editor.createSubtitle`),onClose:M?()=>{}:n,children:c&&s.length===0?i(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[_(B,{className:`h-3.5 w-3.5 animate-spin`}),` `,a(`brokers.editor.loadingKinds`)]}):y===void 0?_(V,{message:a(`brokers.editor.noProvider`)}):i(A,{children:[_(Ar,{schema:w,values:p,onChange:m}),h!==null&&_(V,{message:h}),E.isError&&_(V,{message:E.error instanceof Error?E.error.message:String(E.error)}),_(Vs,{kind:y.kind,...y.addonId===void 0?{}:{addonId:y.addonId},onSubmit:j,onCancel:n,submitLabel:a(M?`brokers.editor.creating`:`brokers.editor.create`),disabled:M,...y.signInBasePath===void 0?{}:{signIn:{basePath:y.signInBasePath,...y.signInMethods===void 0?{}:{methods:y.signInMethods},name:k,onSignedIn:T}}},x)]})})}function ic({broker:e,onClose:t,onSaved:n}){let{t:r}=W(),a=O(),{options:o}=qs({addonId:e.addonId,kind:e.kind}),s=o.find(t=>t.kind===e.kind),c=s?.signInBasePath,l=Un({id:e.id,addonId:e.addonId}),u=Zt({onSuccess:()=>{a.invalidateQueries({queryKey:[[`broker`,`list`]]}),a.invalidateQueries({queryKey:[[`broker`,`getSettings`],{input:{id:e.id,addonId:e.addonId}}]}),n(e.id)}}),f=d(()=>{let e=l.data;return e&&typeof e==`object`?{...e}:{}},[l.data]),p=u.isPending;return _(ec,{title:r(`brokers.brokerManager.edit`,`Edit {{name}}`,{name:e.name}),subtitle:`${e.kind} · ${e.id}`,onClose:p?()=>{}:t,children:l.isLoading?i(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[_(B,{className:`h-3.5 w-3.5 animate-spin`}),` `,r(`brokers.brokerManager.loadingSettings`)]}):l.isError?i(`div`,{className:`space-y-3`,children:[_(V,{message:r(`brokers.brokerManager.loadSettingsFailed`,{message:l.error instanceof Error?l.error.message:r(`common.unknownError`)})}),_(`div`,{className:`flex justify-end`,children:_(H,{variant:`outline`,size:`sm`,onClick:t,children:r(`common.close`,`Close`)})})]}):i(`div`,{className:`space-y-3`,children:[u.isError&&_(V,{message:u.error instanceof Error?u.error.message:String(u.error)}),_(Vs,{kind:e.kind,addonId:e.addonId,brokerId:e.id,initialValues:f,onSubmit:t=>u.mutate({id:e.id,settings:t,addonId:e.addonId}),onCancel:t,submitLabel:p?r(`brokers.brokerManager.saving`):r(`common.save`,`Save`),disabled:p,...c===void 0?{}:{signIn:{basePath:c,...s?.signInMethods===void 0?{}:{methods:s.signInMethods},name:e.name,brokerId:e.id,onSignedIn:e=>{a.invalidateQueries({queryKey:[[`broker`,`list`]]}),n(e)}}}})]})})}w();var ac={connected:`success`,connecting:`warning`,disconnected:`default`,"auth-failed":`danger`,unreachable:`danger`,error:`danger`};function oc({kind:e,value:t,onChange:n}){let{t:r}=W(),[a,o]=b(!1),s=tn({kind:e}),c=Us(s.data).filter(t=>t.kind===e);return i(`div`,{className:`space-y-2`,children:[s.isLoading&&i(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[_(B,{className:`h-3.5 w-3.5 animate-spin`}),` `,r(`brokers.picker.loading`)]}),s.isError&&_(V,{message:r(`brokers.picker.loadFailed`,{message:s.error instanceof Error?s.error.message:r(`common.unknownError`)})}),!s.isLoading&&!s.isError&&c.length===0&&_(`p`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-xs text-foreground-subtle`,children:r(`brokers.picker.none`)}),c.map(e=>i(`button`,{type:`button`,"aria-pressed":t===e.id,onClick:()=>n(e.id),className:`flex w-full items-center justify-between gap-3 rounded-lg border bg-surface p-3 text-left transition-colors ${t===e.id?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:[_(`span`,{className:`text-xs font-semibold text-foreground`,children:e.name}),_(Ln,{variant:ac[e.status],className:`text-[10px]`,children:e.status})]},e.id)),i(H,{variant:`outline`,size:`sm`,onClick:()=>o(!0),children:[_(se,{className:`h-3.5 w-3.5`}),` `,r(`brokers.picker.createNew`)]}),a&&_(nc,{kind:e,onClose:()=>o(!1),onSaved:e=>{o(!1),n(e)}})]})}function sc(e,t){return t.map(t=>({subject:{kind:`device`,deviceId:e},key:t.key,scope:t.scope}))}function cc({deviceId:e}){let{t}=W(),{presence:n,list:r}=Bn(e);return n===`absent`?null:n===`unknown`?_(V,{message:t(`deviceQuickDetail.historyUnknown`,`Could not tell whether this device has recorded history.`)}):n===`pending`||r.status===`pending`?_(Qt,{className:`h-24 w-full`,"aria-busy":`true`}):r.status===`error`?_(V,{title:t(`deviceQuickDetail.historyUnknown`,`Could not tell whether this device has recorded history.`),message:r.error}):r.data.length===0?null:i(`section`,{className:`flex flex-col gap-2`,"aria-label":t(`deviceQuickDetail.tabHistory`,`History`),children:[_(`div`,{className:`flex justify-end`,children:_(jo,{to:vr(sc(e,r.data)),className:`text-xs text-primary hover:underline`,children:t(`deviceQuickDetail.openHistory`,`Open full history`)})}),_(Mn,{deviceId:e})]})}function lc(e,t){return e===`present`&&t.status===`ok`&&(t.data?.length??0)>0}var uc={streaming:{icon:Et,labelKey:`capabilityBadges.streaming`},detection:{icon:ae,labelKey:`capabilityBadges.detection`},recording:{icon:Ce,labelKey:`capabilityBadges.recording`},audio:{icon:We,labelKey:`capabilityBadges.audio`},snapshot:{icon:ne,labelKey:`capabilityBadges.snapshot`},motion:{icon:Me,labelKey:`capabilityBadges.motion`},ptz:{icon:ke,labelKey:`capabilityBadges.ptz`},webrtc:{icon:de,labelKey:`capabilityBadges.webrtc`},onvif:{icon:De,labelKey:`capabilityBadges.onvif`},analytics:{icon:Pe,labelKey:`capabilityBadges.analytics`},"battery-operated":{icon:ve,labelKey:`capabilityBadges.battery`},"native-snapshot":{icon:ne,labelKey:`capabilityBadges.nativeSnapshot`},"pan-tilt-zoom":{icon:ke,labelKey:`capabilityBadges.ptz`},"two-way-audio":{icon:We,labelKey:`capabilityBadges.twoWayAudio`},"doorbell-button":{icon:ie,labelKey:`capabilityBadges.doorbell`},rebootable:{icon:te,labelKey:`capabilityBadges.rebootable`},"vacuum-has-map":{icon:St,labelKey:`capabilityBadges.map`},"vacuum-has-ai":{icon:Ue,labelKey:`capabilityBadges.aiObstacle`},"mower-has-map":{icon:St,labelKey:`capabilityBadges.map`},"mower-has-targeted-mowing":{icon:le,labelKey:`capabilityBadges.targetedMowing`}},dc=Qe;function fc({capabilities:e,showLabels:t=!1}){let{t:n}=W();return _(`div`,{className:`flex items-center gap-1 flex-wrap`,children:e.map(e=>{let r=uc[e],a=r?.icon??dc,o=r?n(r.labelKey):e;return i(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] text-foreground-subtle`,title:o,children:[_(a,{className:`h-3 w-3`}),t&&_(`span`,{children:o})]},e)})})}w();var pc={amcrest:{icon:gt,color:`#3b82f6`,label:`Amcrest`},hikvision:{icon:ye,color:`#a855f7`,label:`Hikvision`},reolink:{icon:de,color:`#06b6d4`,label:`Reolink`},homeassistant:{icon:ge,color:`#22d3ee`,label:`Home Assistant`},rtsp:{icon:we,color:`#78716c`,label:`RTSP`},onvif:{icon:we,color:`#78716c`,label:`ONVIF`}},mc={sm:`h-4 w-4`,md:`h-5 w-5`,lg:`h-6 w-6`,xl:`h-16 w-16`},hc={sm:`h-7 w-7`,md:`h-8 w-8`,lg:`h-10 w-10`,xl:`h-16 w-16`};function gc(e){let t=e.toLowerCase();return t.startsWith(`provider-`)?t.slice(9):t}function _c(e){return pc[gc(e)]??{icon:gt,color:`#78716c`,label:e}}function vc({type:e,size:t=`md`,showLabel:n}){let r=_c(e),a=r.icon,[o,s]=b(!1),c=Vr(e);return i(`div`,{className:`flex items-center gap-2`,children:[_(`div`,{className:`flex items-center justify-center rounded-lg ${hc[t]}`,style:{backgroundColor:`${r.color}15`},children:o||!c?_(a,{className:mc[t],style:{color:r.color}}):_(`img`,{src:c,alt:r.label,className:mc[t],onError:()=>s(!0)})}),n&&_(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:r.label})]})}function yc({label:e,value:t,layout:n=`inline`}){return n===`stacked`?i(`div`,{className:`min-w-0 flex flex-col gap-0.5 px-0.5`,children:[_(`span`,{className:`text-[11px] text-foreground-subtle`,children:e}),_(`div`,{className:`min-w-0 text-[11px] text-foreground`,children:t})]}):i(`div`,{className:`${he} flex items-start gap-2 sm:gap-3`,children:[_(`span`,{className:`w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle`,children:e}),_(`div`,{className:`flex-1 min-w-0 text-[11px] text-foreground`,children:t})]})}w();function bc(e){return Wt({addonId:e,projection:`slim`})}function xc(e){return en({deviceId:e},{enabled:Number.isFinite(e)})}var Sc=3e4,Cc=2e3;function wc(e){let t=u(0);return t.current===0&&(t.current=Date.now()),Mt({parentDeviceId:e},{enabled:Number.isFinite(e),staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let n=e.state.data;return n&&n.length>0||Date.now()-t.current>=Sc?!1:Cc}})}w();function Tc({deviceId:e}){let{t}=W(),n=O(),{data:r}=xc(e),{data:a}=wc(e),[o,s]=b(null),c=kn({onSuccess:()=>{s(null),n.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{s(`Could not change primary child: ${e.message}`)}});if(r==null||String(r.type??``)!==it.Container)return null;let l=String(r.name??``),u=(a??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:Xt(e,l),...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}}));if(u.length<=1)return null;let d=Sn(u,typeof r.linkDeviceId==`number`?r.linkDeviceId:null,typeof r.primaryChildEntityId==`string`?r.primaryChildEntityId:null),f=d===null?u[0].id:d.id;return i(A,{children:[_(yc,{label:t(`shared.primaryChildRow.primaryChild`,`Primary child`),value:_(sr,{childrenList:u,selectedId:f,onSetPrimary:t=>c.mutate({deviceId:e,primaryChildEntityId:t}),disabled:c.isPending})}),o!==null&&_(`p`,{role:`alert`,className:`px-3 sm:px-4 py-1.5 text-[11px] text-danger`,children:o})]})}w();var Ec=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`];function Dc(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function Oc(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function kc(){let{t:e}=W(),t=er(),n=ur(),{data:r}=en({deviceId:t??0},{enabled:t!==null}),{data:a}=Wn({deviceId:t??0},{enabled:t!==null}),o=r??n??null,[s,c]=b(`identity`);if(t===null||!o)return null;let l=String(o.stableId??``),u=String(o.addonId??``),d=typeof o.integrationId==`string`&&o.integrationId.length>0?o.integrationId:null,f=typeof o.parentDeviceId==`number`?o.parentDeviceId:null,p=o.features??[],m=new Set([`device-status`,`feature-probe`,`device-ops`]),h=(a?.entries??[]).filter(e=>e.kind===`native`&&!m.has(e.capName)).map(e=>e.capName),g=p.length>0?p:h,v=o.metadata??null,y=v!==null&&Object.keys(v).length>0;return i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[i(`div`,{className:`border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3`,children:[_(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`overviewAdapters.deviceInfoAdapter.deviceInfo`,`Device Info`)}),y&&i(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[_(Ac,{active:s===`identity`,onClick:()=>c(`identity`),label:e(`overviewAdapters.deviceInfoAdapter.identity`,`Identity`)}),_(Ac,{active:s===`hardware`,onClick:()=>c(`hardware`),label:e(`overviewAdapters.deviceInfoAdapter.hardware`,`Hardware`)})]})]}),(!y||s===`identity`)&&i(`div`,{className:`divide-y divide-border`,children:[_(yc,{label:`ID`,value:i(`span`,{className:`font-mono text-[11px] text-foreground`,children:[`#${t}`,i(`span`,{className:`ml-1.5 text-foreground-subtle`,children:[`(`,l,`)`]})]})}),_(Tc,{deviceId:t}),d!==null&&_(yc,{label:e(`overviewAdapters.deviceInfoAdapter.integration`,`Integration`),value:_(`span`,{className:`font-mono text-[11px]`,children:d})}),f!==null&&_(yc,{label:e(`overviewAdapters.deviceInfoAdapter.parent`,`Parent`),value:_(`span`,{className:`font-mono text-[11px]`,children:`#${String(f)}`})}),_(yc,{label:e(`overviewAdapters.deviceInfoAdapter.provider`,`Provider`),value:_(vc,{type:u,size:`sm`,showLabel:!0})}),_(yc,{label:e(`overviewAdapters.deviceInfoAdapter.capabilities`,`Capabilities`),value:g.length>0?_(fc,{capabilities:g,showLabels:!0}):_(`span`,{className:`text-[11px] text-foreground-subtle`,children:e(`overviewAdapters.deviceInfoAdapter.none`,`None`)})})]}),y&&s===`hardware`&&_(jc,{metadata:v})]})}function Ac({active:e,onClick:t,label:n}){return _(`button`,{type:`button`,onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${e?`bg-surface text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`}`,children:n})}function jc({metadata:e}){let{t}=W(),n=Ec.filter(t=>t in e),r=Object.keys(e).filter(e=>!Ec.includes(e)).toSorted(),a=[...n,...r];return i(`div`,{children:[_(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border bg-surface-subtle/40`,children:t(`overviewAdapters.deviceInfoAdapter.autoPopulatedByTheDriver`,`Auto-populated by the driver on every connect. Read-only.`)}),_(`div`,{className:`divide-y divide-border`,children:a.map(t=>_(yc,{label:Dc(t),value:_(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:Oc(e[t])})},t))})]})}function Mc(e,t){return e.icon===t.icon&&e.label===t.label&&e.unit===t.unit&&e.precision===t.precision&&e.hidden===t.hidden}function Nc(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function Pc(e){if(e.trim()===``)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function Fc(e,t){let n=Pc(e.precision),r={...e.icon===``?{}:{icon:e.icon},...e.label.trim()===``?{}:{label:e.label.trim()},...e.unit===``?{}:{unit:e.unit},...n===void 0?{}:{precision:n},...e.hidden?{hidden:!0}:{},...t?.perCap===void 0?{}:{perCap:t.perCap}};return Object.keys(r).length===0?null:r}function Ic(e){let t=Nc(e.display);return{name:e.name,location:e.location,role:e.role,display:t,baseName:e.name,baseLocation:e.location,baseRole:e.role,baseDisplay:t,persistedDisplay:e.display}}function Lc(e,t){if(e===null)return Ic(t);let n=Nc(t.display),r=e.name===t.name&&e.location===t.location&&e.role===t.role&&Mc(e.display,n);return!Rc(e)||r?Ic(t):e}function Rc(e){return e===null?!1:e.name!==e.baseName||e.location!==e.baseLocation||e.role!==e.baseRole||!Mc(e.display,e.baseDisplay)}function zc(e){return e.name.trim().length===0?`name`:null}function Bc(e){let t=e.name.trim(),n=e.location.trim();return{...t===e.baseName?{}:{name:t},...n===e.baseLocation?{}:{location:n===``?null:n},...e.role===e.baseRole?{}:{role:e.role},...Mc(e.display,e.baseDisplay)?{}:{display:Fc(e.display,e.persistedDisplay)}}}function Vc(e){let t=e.map(e=>e.error).filter(e=>e!==null&&e.length>0);return{dirty:e.some(e=>e.dirty),saving:e.some(e=>e.saving),error:t.length===0?null:t.join(`; `)}}w();var Hc=E(null);function Uc(){return j(Hc)}function Wc({deviceId:e,seed:t,showOpenFull:n=!1,onClose:r,children:i}){let[a,o]=b(null),[s,c]=b([]),l=u(new Map);if(t!==null){let e=Lc(a,t);(a===null||e.name!==a.name||e.location!==a.location||e.role!==a.role||!Mc(e.display,a.display)||e.baseName!==a.baseName||e.baseLocation!==a.baseLocation||e.baseRole!==a.baseRole||!Mc(e.baseDisplay,a.baseDisplay)||e.persistedDisplay!==a.persistedDisplay)&&o(e)}let f=g(e=>(l.current.set(e.id,{save:e.save,discard:e.discard}),c(t=>{let n=t.find(t=>t.id===e.id);return n!==void 0&&n.dirty===e.dirty&&n.saving===e.saving&&n.error===e.error?t:[...t.filter(t=>t.id!==e.id),{...e,save:()=>l.current.get(e.id)?.save()??Promise.resolve(),discard:()=>{l.current.get(e.id)?.discard()}}]}),()=>{l.current.delete(e.id),c(t=>t.filter(t=>t.id!==e.id))}),[]),p=d(()=>({identity:a,setIdentityName:e=>{o(t=>t===null?t:{...t,name:e})},setIdentityLocation:e=>{o(t=>t===null?t:{...t,location:e})},setIdentityRole:e=>{o(t=>t===null?t:{...t,role:e})},setIdentityDisplay:e=>{o(t=>t===null?t:{...t,display:{...t.display,...e}})},register:f}),[a,f]);return _(Hc.Provider,{value:p,children:_(Gc,{deviceId:e,identity:a,contributions:s,onIdentitySaved:e=>o(e),showOpenFull:n,onClose:r,children:i})})}function Gc({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:a,onClose:o,children:s}){return i(A,{children:[s,_(qc,{deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:a,onClose:o})]})}function Kc(e){return e instanceof Error?e.message:String(e)}function qc({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:a,onClose:o}){let{t:s}=W(),c=ua(),l=Ke(),u=O(),[d,f]=b(null),[p,m]=b(!1),h=Hn(),g=In(),v=nr(),y=kt(),x=Vc([{dirty:Rc(t),saving:p,error:d},...n]),S=()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})};return!x.dirty&&!x.saving&&x.error===null&&!a?null:i(`div`,{className:`sticky bottom-0 z-10 mt-auto flex flex-col gap-2 border-t border-border bg-background px-1 pt-3`,children:[x.error!==null&&_(`p`,{className:`text-xs text-danger`,children:x.error}),i(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[a?_(H,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{(async()=>{x.dirty&&!await l({title:s(`deviceQuickDetail.leaveTitle`,`Discard unsaved changes?`),message:s(`deviceQuickDetail.leaveMessage`,`Unsaved edits on this device will be discarded.`),confirmLabel:s(`deviceQuickDetail.discard`,`Discard`),variant:`warning`})||(c(`/devices/${String(e)}?tab=customize`),o?.())})()},children:s(`deviceQuickDetail.openFull`,`Open full detail`)}):_(`span`,{}),i(`div`,{className:`flex items-center gap-2`,children:[_(H,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{t!==null&&r({...t,name:t.baseName,location:t.baseLocation,role:t.baseRole,display:t.baseDisplay});for(let e of n)e.discard();f(null)},disabled:!x.dirty||x.saving,children:s(`deviceQuickDetail.discard`,`Discard`)}),_(H,{type:`button`,size:`sm`,onClick:()=>{if(t!==null&&Rc(t)&&zc(t)===`name`){f(s(`deviceQuickDetail.nameRequired`,`Name is required`));return}f(null),m(!0),(async()=>{try{let i=t===null?{}:Bc(t);if(t!==null&&i.name!==void 0&&await h.mutateAsync({deviceId:e,name:i.name}),t!==null&&i.location!==void 0&&await g.mutateAsync({deviceId:e,location:i.location}),t!==null&&i.role!==void 0&&await v.mutateAsync({deviceId:e,role:i.role}),t!==null&&i.display!==void 0&&await y.mutateAsync({deviceId:e,display:i.display}),t!==null){let e=t.name.trim(),n=t.location.trim();r({...t,name:e,location:n,baseName:e,baseLocation:n,baseRole:t.role,baseDisplay:t.display,persistedDisplay:i.display===void 0?t.persistedDisplay:i.display??void 0})}for(let e of n)e.dirty&&await e.save();S()}catch(e){f(Kc(e))}finally{m(!1)}})()},disabled:!x.dirty||x.saving,children:x.saving?s(`deviceQuickDetail.saving`,`Saving…`):s(`deviceQuickDetail.save`,`Save`)})]})]})]})}function Jc(e){return e.hubReachable?e.authOk===!1?{kind:`auth-expired`}:{kind:`cluster-degraded`,offlineAgents:e.offlineAgents,offlineAgentIds:e.offlineAgentIds}:{kind:`hub-unreachable`}}function Yc(e){switch(e.kind){case`connected`:return null;case`reconnecting`:return{severity:`warning`,message:U.t(`connection.reconnecting`),i18nKey:`connection.reconnecting`,showSpinner:!0};case`cluster-degraded`:{let t=e.offlineAgentIds??[];return t.length>0?{severity:`warning`,message:U.t(`connection.degradedNodes`,{nodes:t.join(`, `),count:t.length}),i18nKey:`connection.degradedNodes`,i18nParams:{nodes:t.join(`, `),count:t.length},showSpinner:!0}:e.offlineAgents!==null&&e.offlineAgents>0?{severity:`warning`,message:U.t(`connection.degradedCount`,{count:e.offlineAgents}),i18nKey:`connection.degradedCount`,i18nParams:{count:e.offlineAgents},showSpinner:!0}:{severity:`warning`,message:U.t(`connection.degraded`),i18nKey:`connection.degraded`,showSpinner:!0}}case`hub-unreachable`:return{severity:`danger`,message:U.t(`connection.disconnected`),i18nKey:`connection.disconnected`,showSpinner:!0};case`auth-expired`:return{severity:`danger`,message:U.t(`connection.sessionExpired`),i18nKey:`connection.sessionExpired`,showSpinner:!1,action:`sign-in`}}}var Xc=4e3,Zc=5e3;function Qc(e){if(typeof e!=`object`||!e)return{offline:null,offlineIds:null,ok:null};let t={...e},n=typeof t.ok==`boolean`?t.ok:null,r=t.agents;if(typeof r!=`object`||!r)return{offline:null,offlineIds:null,ok:n};let i={...r},a=i.offline,o=typeof a==`number`?a:null,s=i.offlineIds;return{offline:o,offlineIds:Array.isArray(s)?s.filter(e=>typeof e==`string`):null,ok:n}}async function $c(e,t,n,r){let i=new AbortController,a=setTimeout(()=>i.abort(),n);try{return await e(t,{method:`GET`,signal:i.signal,credentials:`omit`,...r===void 0?{}:{headers:r}})}finally{clearTimeout(a)}}async function el(e){let t=e.fetchFn??fetch,n=e.timeoutMs??Xc,r=e.origin.replace(/\/+$/,``),i;try{i=await $c(t,`${r}/health`,n)}catch{return{hubReachable:!1,authOk:`unknown`,offlineAgents:null,offlineAgentIds:null}}if(!i.ok)return{hubReachable:!1,authOk:`unknown`,offlineAgents:null,offlineAgentIds:null};let a=null,o=e.getToken();if(o!==null&&o!==``)try{let e=await $c(t,`${r}/health/details`,n,{Authorization:`Bearer ${o}`});e.ok&&(a=await e.json())}catch{}let s;try{s=Qc(a??await i.json())}catch{s={offline:null,offlineIds:null,ok:null}}if(s.ok===!1)return{hubReachable:!1,authOk:`unknown`,offlineAgents:null,offlineAgentIds:null};let c=e.getToken(),l=`unknown`;if(c!==null&&c!==``)try{let e=await $c(t,`${r}/trpc/auth.me`,n,{Authorization:`Bearer ${c}`});e.status===401||e.status===403?l=!1:e.ok&&(l=!0)}catch{l=`unknown`}return{hubReachable:!0,authOk:l,offlineAgents:s.offline,offlineAgentIds:s.offlineIds}}var tl={kind:`connected`},nl={kind:`reconnecting`};function rl(e){let t=e.probeIntervalMs??Zc,n=new Set,r=tl,i=0,a=!1,o=null;function s(e){if(r!==e){r=e;for(let e of n)e()}}function c(){a=!1,o!==null&&(clearTimeout(o),o=null)}function l(){let n=i;e.probe().then(e=>{n!==i||!a||(s(Jc(e)),o=setTimeout(l,t))},()=>{n!==i||!a||(s({kind:`hub-unreachable`}),o=setTimeout(l,t))})}function u(e){if(i+=1,e===`connected`){c(),s(tl);return}if(e===`connecting`){c(),s(nl);return}(r.kind===`connected`||r.kind===`reconnecting`)&&s(nl),o!==null&&(clearTimeout(o),o=null),a=!0,l()}return{getSnapshot:()=>r,subscribe:e=>(n.add(e),()=>{n.delete(e)}),onSdkConnectionState:u,dispose:()=>{i+=1,c(),n.clear()}}}var il=null;function al(){return il===null&&(il=rl({probe:()=>el({origin:_e(),getToken:()=>localStorage.getItem(`camstack_admin_token`)})})),il}function ol(e){al().onSdkConnectionState(e)}function sl(e){return e===`connected`}function cl(e){D.setOnline(sl(e))}var ll=null,ul=0;function Q(){if(!ll){let e=ul;ll=rr({serverUrl:_e(),token:localStorage.getItem(`camstack_admin_token`)??void 0,getLanguage:()=>U.language,refreshCredential:async e=>{e===`rejected`?await Dl().refreshNow():await Dl().ensureFresh()},onConnectionChange:t=>{e===ul&&(ol(t),cl(t))}})}return ll}function dl(){let e=ll;ll=null,ul+=1,e?.close()}var fl=`camstack_admin_token`,pl=`camstack_admin_refresh`,ml=`camstack_admin_token_expires`;function hl(e){try{let t=localStorage.getItem(e);return t!==null&&t.length>0?t:null}catch{return null}}function gl(e,t){try{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}function _l(){let e=hl(fl);if(e===null)return null;let t=hl(pl),n=Number(hl(ml));return{token:e,...t===null?{}:{refreshToken:t},...Number.isFinite(n)&&n>0?{expiresAt:n}:{}}}function vl(e){gl(fl,e.token),gl(pl,e.refreshToken??null),gl(ml,e.expiresAt===void 0?null:String(e.expiresAt))}function yl(){gl(fl,null),gl(pl,null),gl(ml,null)}function bl(e){let t=e.get(`token`);if(t===null||t.length===0)return null;let n=e.get(`refreshToken`),r=Number(e.get(`expiresAt`));return{token:t,...n!==null&&n.length>0?{refreshToken:n}:{},...Number.isFinite(r)&&r>0?{expiresAt:r}:{}}}async function xl(e){await fetch(z(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}var Sl=new Set;function Cl(e){return Sl.add(e),()=>Sl.delete(e)}var wl=new Set;function Tl(e){return wl.add(e),()=>wl.delete(e)}var El=null;function Dl(){return El===null&&(El=new Zn({refresh:async e=>{let t=_l();if(t?.refreshToken!==void 0&&t.refreshToken!==e&&(t.expiresAt??0)>Date.now()+6e4)return t;let n=await Q().refreshSession(e);return{token:n.token,refreshToken:n.refreshToken,expiresAt:n.expiresAt}},onTokens:e=>{vl(e),Q().setToken(e.token),xl(e.token);for(let e of wl)e()},onExpired:()=>{yl();for(let e of Sl)e()}})),El}function Ol(e){vl(e),Dl().adopt(e)}async function kl(e){try{await Dl().ensureFresh()}catch(e){console.warn(`[admin-session] pre-reconnect refresh failed; reconnecting anyway`,e)}e()}async function Al(){return await Dl().refreshNow()!==null}var jl=512;function Ml(e){if(!e||e.length>jl)return null;let t=tt(e);return t===null?!e.startsWith(`/`)||e.startsWith(`//`)||e.includes(`\\`)||e.includes(`://`)||e.includes(`..`)||e===`/login`||e.startsWith(`/login?`)||e.startsWith(`/login/`)?null:{kind:`path`,path:e}:{kind:`app-callback`,url:t}}var Nl=/^[A-Za-z0-9_-]{43,128}$/,Pl=/^[A-Za-z0-9._~-]{1,256}$/;function Fl(e){let{codeChallenge:t,state:n}=e;return!t||!Nl.test(t)||(e.codeChallengeMethod??`S256`)!==`S256`||!n||!Pl.test(n)?null:{codeChallenge:t,state:n,purpose:e.purpose===`step-up`?`step-up`:`new-session`}}var Il=`camstack:login-app-handoff`;function Ll(e){if(!e)return null;try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=e=>{let n=Reflect.get(t,e);return typeof n==`string`?n:null};return Fl({codeChallenge:n(`codeChallenge`),state:n(`state`),purpose:n(`purpose`)})}catch{return null}}function Rl(e,t=Date.now()){e!==null&&Xl(Il,JSON.stringify(e),Ll,t)}function zl(e=Date.now()){return Zl(Il,Ll,e)}function Bl(e,t,n){return`${e}?${`code=${encodeURIComponent(t)}`}${n===void 0?``:`&state=${encodeURIComponent(n)}`}`}function Vl(e,t=Date.now()){return eu(t)??Ml(e)}var Hl=2048;function Ul(e){return!e||e.length>Hl||!e.startsWith(`/`)||e.startsWith(`//`)||e.includes(`\\`)||e.includes(`://`)||e.includes(`..`)||e===`/login`||e.startsWith(`/login?`)||e.startsWith(`/login/`)?null:e}function Wl(e,t=Date.now()){Xl(Jl,e,Ul,t)}function Gl(e=Date.now()){return Zl(Jl,Ul,e)}function Kl(e,t=Date.now()){return Gl(t)??Ul(e)}var ql=`camstack:login-redirect`,Jl=`camstack:login-next`,Yl=10*6e4;function Xl(e,t,n,r){let i=Ql();if(!i||!n(t))return;let a={raw:t??``,at:r};try{i.setItem(e,JSON.stringify(a))}catch{}}function Zl(e,t,n){let r=Ql();if(!r)return null;let i=null;try{i=r.getItem(e),r.removeItem(e)}catch{return null}if(!i)return null;try{let e=JSON.parse(i);if(typeof e!=`object`||!e)return null;let r=Reflect.get(e,`at`),a=Reflect.get(e,`raw`);return typeof r!=`number`||typeof a!=`string`||n-r>Yl?null:t(a)}catch{return null}}function Ql(){if(typeof window>`u`)return null;try{return window.sessionStorage}catch{return null}}function $l(e,t=Date.now()){Xl(ql,e,Ml,t)}function eu(e=Date.now()){return Zl(ql,Ml,e)}var tu=`changeme`;function nu(e){try{let t=e.split(`.`);if(t.length<2||!t[1])return null;let n=JSON.parse(atob(t[1]));return{id:String(n.userId??``),username:String(n.username??`unknown`),isAdmin:!!n.isAdmin,exp:Number(n.exp??0),scopes:ru(n.scopes)}}catch{return null}}function ru(e){return nt(st(e))}function iu(e){let t=nu(e);return t?t.exp*1e3<Date.now():!0}w();var au=tu;function ou(e){return{token:e.token,...e.refreshToken===void 0?{}:{refreshToken:e.refreshToken},...e.expiresAt===void 0?{}:{expiresAt:e.expiresAt}}}async function su(e,t){if(await xl(e),t.kind===`path`){window.location.replace(z(t.path));return}try{dl();let e=zl();if(e===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await Q().trpcClient.auth.createHandoffCode.mutate({purpose:e.purpose,codeChallenge:e.codeChallenge,state:e.state});window.location.replace(Bl(t.url,n,e.state))}catch{window.location.replace(z(`/`))}}async function cu(e,t){await xl(e),window.location.replace(z(t))}var lu=E(null);function uu({children:e}){let[t,n]=b(null),[r,i]=b(!0),[a,o]=b(!1);v(()=>{if(typeof window<`u`&&window.location.hash.startsWith(`#token=`)){let e=new URLSearchParams(window.location.hash.slice(1)),t=bl(e),n=t?.token??null;if(t!==null&&n!==null){Ol(t);let r=eu();if(r){su(n,r);return}let i=Gl()??Ul(e.get(`next`));if(i){cu(n,i);return}window.history.replaceState({},``,z(`/`))}}s()},[]);let s=async()=>{let e=_l();if(e===null){i(!1);return}let t=e.token;if(e.refreshToken!==void 0){let n=Dl();n.adopt(e),await n.ensureFresh();let r=_l();if(r===null){console.warn(`[auth] session restore: signed out — the hub refused the refresh token`),dl(),i(!1);return}t=r.token}if(iu(t)){console.warn(`[auth] session restore: signed out — access token expired and no refresh recovered it`),yl(),dl(),i(!1);return}let r=nu(t);if(!r){console.warn(`[auth] session restore: signed out — the stored access token is unreadable`),yl(),dl(),i(!1);return}xl(t);let a=Q();a.trpcClient.system.info.query().then(()=>n(r)).catch(async e=>{let t=e?.data?.code;if(t===`UNAUTHORIZED`||t===`FORBIDDEN`){if(await Al()){a.reconnect();try{await Q().trpcClient.system.info.query();let e=_l();n(e&&nu(e.token)||r);return}catch{}}console.warn(`[auth] session restore: logout, probe UNAUTHORIZED and refresh did not recover it`),Dl().stop(),yl(),dl()}else n(r)}).finally(()=>i(!1))};v(()=>Cl(()=>{dl(),n(null),o(!1)}),[]);let c=g(async(e,t)=>{let r=await Q().login(e,t,{refreshable:!0}),i=r.secondFactors??(r.requiresTotp===!0?[`totp`]:[]);if(i.length>0)return{kind:`second-factor`,challengeToken:r.token,factors:i};let a=r.token;return Ol(ou(r)),await xl(a),dl(),n(nu(a)),o(t===au),{kind:`ok`}},[]),l=g(async(e,t)=>{let r=await Q().loginVerifyTotp(e,t,{refreshable:!0}),i=r.token;Ol(ou(r)),await xl(i),dl(),n(nu(i)),o(!1)},[]),u=g(async(e,t)=>{Ol({token:e,...t}),await xl(e),dl(),n(nu(e)),o(!1)},[]),d=g(()=>{Q().logout().catch(()=>{}),Dl().stop(),yl(),fetch(z(`/api/auth/session`),{method:`DELETE`}).catch(()=>{}),dl(),n(null),o(!1)},[]),f=g(()=>{o(!1)},[]);return _(lu.Provider,{value:{user:t,loading:r,mustChangePassword:a,login:c,verifyTotp:l,finalizePasskeyLogin:u,logout:d,clearMustChangePassword:f},children:e})}function du(){let e=j(lu);if(!e)throw Error(`useAuth must be used within AuthProvider`);return e}w();function fu(e,t){for(let n of e)for(let e of n.fields){if(!(`key`in e)||e.key!==t)continue;if(e.type===`button`||e.type===`separator`||e.type===`info`)return!0;let r=e.immediate;return r===!0?!0:r===!1?!1:n.immediate===!0}return!1}function pu({schema:e,serverValues:t,onImmediateSave:n,onDeferredSave:r}){let[i,a]=b({}),[o,s]=b({}),[c,l]=b(!1),f=u(null),p=e?.sections??[],m=Object.keys(i).length>0,h=d(()=>({...t,...o,...i}),[t,o,i]);v(()=>{if(m||Object.keys(o).length>0){l(!0);return}f.current&&clearTimeout(f.current),f.current=setTimeout(()=>l(!1),500)},[m,o]),v(()=>()=>{f.current&&clearTimeout(f.current)},[]);let _=g(()=>{l(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>l(!1),2e3)},[]),y=g(e=>{_();let r={},o={},s={...t,...i};for(let[t,n]of Object.entries(e))s[t]!==n&&(fu(p,t)?r[t]=n:o[t]=n);Object.keys(r).length>0&&n(r),a(e=>{let t={...e};for(let e of Object.keys(r))delete t[e];for(let[e,n]of Object.entries(o))t[e]=n;return t})},[_,t,i,p,n]),x=g(e=>{let t={},n={};for(let[r,a]of Object.entries(i))e.includes(r)?t[r]=a:n[r]=a;if(a(n),Object.keys(t).length===0)return;let o=Object.keys(t),c=r(t);if(c===void 0||typeof c.then!=`function`)return;s(e=>({...e,...t}));let l=()=>s(e=>{let t={...e};for(let e of o)delete t[e];return t});c.then(l,()=>{l(),a(e=>{let n={...e};for(let e of o)e in n||(n[e]=t[e]);return n})})},[i,r]),S=g(e=>{a(t=>{let n={...t};for(let t of e)delete n[t];return n})},[]),C=g(()=>{a({})},[]);return{values:h,pendingKeys:Object.keys(i),hasPendingEdits:m,editingPaused:c,handleChange:y,handleSave:x,handleDiscard:S,resetAll:C}}function mu({pendingCount:e,onSave:t,onDiscard:n,saving:r=!1,saveLabel:a=`Save`,discardLabel:o=`Discard`}){let{t:s}=W();return e<=0?null:i(`div`,{className:`sticky bottom-0 -mb-3 flex items-center justify-between gap-3 rounded-lg border border-primary/40 bg-primary/5 px-3 py-2 shadow-sm z-10`,children:[_(`span`,{className:`text-xs text-foreground`,children:s(`formBuilder.saveBar.unsavedChanges`,{count:e})}),i(`div`,{className:`flex items-center gap-2`,children:[_(`button`,{type:`button`,onClick:n,disabled:r,className:`inline-flex items-center rounded-md border border-border px-2.5 py-1 text-xs text-foreground-subtle hover:bg-surface-hover disabled:opacity-50`,children:o}),_(`button`,{type:`button`,onClick:t,disabled:r,className:`inline-flex items-center rounded-md bg-primary px-3 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:r?s(`formBuilder.formSaveBar.saving`,`Saving…`):a})]})]})}function hu({tabs:e,activeId:t,onChange:n,countByTab:r,pendingByTab:a}){return e.length===0?null:_(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:e.map(e=>{let o=e.id===t,s=r?.get(e.id)??0,c=a?.get(e.id)??0;return i(`button`,{type:`button`,onClick:()=>n(e.id),className:`relative shrink-0 px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${o?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[e.label,s>0&&i(`span`,{className:`ml-1.5 text-[10px] opacity-60`,children:[`(`,s,`)`]}),c>0&&_(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-primary`})]},e.id)})})}w();function gu({schema:e,values:t,pendingKeys:n,onChange:r,onAction:a,onSave:o,onDiscard:s,disabled:c,activeSubTab:l,onSubTabChange:f,flattenTabs:p=!1,visibilityContext:m,hideSaveBar:h=!1,leadingTabs:g=[]}){let v=e.tabs??[],y=d(()=>{let t=new Map;for(let n of e.sections){let e=n.tab??`general`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t},[e.sections]),x=new Set(v.map(e=>e.id)),S=[...g.map(e=>({id:e.id,label:e.label})),...v,...[...y.keys()].filter(e=>!x.has(e)).map(e=>({id:e,label:e,icon:`wrench`,order:100}))],C=S[0]?.id??`general`,[w,T]=b(C),E=f!==void 0,D=new Set(S.map(e=>e.id)),O=u(new Set);for(let e of D)O.current.add(e);let k=O.current,A=(e=>e&&(D.has(e)||k.has(e))?e:C)(E?l:w),j=e=>{E?f(e):T(e)},M=g.find(e=>e.id===A),N=y.get(A)??[],P={sections:N.length<=1?N.length===1?[{...N[0],title:``}]:N:N.every(e=>!e.title)?[{...N[0],title:``,fields:N.flatMap(e=>e.fields)}]:N},F=h?null:_(mu,{pendingCount:n.length,onSave:()=>o(n),onDiscard:()=>s(n),saving:c});if(g.length===0&&(p||S.length<=1))return i(`div`,{className:`flex flex-col gap-3`,children:[_(Ar,{schema:e,values:t,onChange:r,onAction:a,disabled:c,visibilityContext:m}),F]});let ee=new Map,te=new Map;for(let[e,t]of y){ee.set(e,t.length);let r=new Set,i=e=>{for(let t of e)if(`key`in t&&typeof t.key==`string`&&r.add(t.key),t.type===`group`)i(t.fields);else if(t.type===`sub-tabs`)for(let e of t.tabs)i(e.fields)};for(let e of t)i(e.fields);let a=n.filter(e=>r.has(e)).length;a>0&&te.set(e,a)}return i(`div`,{className:`flex flex-col gap-3`,children:[_(hu,{tabs:S.map(e=>({id:e.id,label:e.label})),activeId:A,onChange:j,countByTab:ee,pendingByTab:te}),_(xr,{tabKey:A,children:M===void 0?_(Ar,{schema:P,values:t,onChange:r,onAction:a,disabled:c,visibilityContext:m}):M.content}),F]})}var _u=`device-export`,vu=`export`,yu=`Export`;function bu(e){return e.type===`separator`||e.type===`info`||e.type===`object-array`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`?!1:e.type===`group`?e.fields.some(bu):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(bu)):e.writerCapName===_u}function xu(e){return e.tab===`export`?!0:e.fields.some(bu)}var Su=`host/extensions-panel`;function Cu(e){return e.type===`widget`?e.widgetId===Su:e.type===`group`?e.fields.some(Cu):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(Cu)):!1}function wu(e){return e.fields.some(Cu)}function Tu(e,t){return!t&&e!==void 0&&at.includes(e)}function Eu(e){return e.location!==`top-tab`&&e.location!==`hero`&&!xu(e)&&!wu(e)}function Du(e,t,n,r){return!r||Tu(t,n)?!0:(e??[]).some(Eu)}function Ou(e,t){for(let n of e){if(n.type===`group`){Ou(n.fields,t);continue}if(n.type===`sub-tabs`){for(let e of n.tabs)Ou(e.fields,t);continue}if(!(`value`in n))continue;let e=n.value===void 0?n.default:n.value;e!==void 0&&(t[n.key]=e)}}function ku(e){let t={};for(let n of e)Ou(n.fields,t);return t}w();function Au(e,t){return t&&t===`admin`?e:!0}function ju(e){if(!e)return null;let t={sections:[...e.sections].toSorted((e,t)=>{let n=e.tab??`general`,r=t.tab??`general`;return n===r?xu(e)&&xu(t)?e.id.localeCompare(t.id):(e.order??0)-(t.order??0):n.localeCompare(r)})};return e.tabs?{...t,tabs:e.tabs}:t}function Mu(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`||e.type===`account-sign-in`||e.type===`secret-presence`}function Nu(e){return e.key}function Pu(e){if(!Mu(e))return e.value}function Fu(e){return Mu(e)?null:e}function Iu(e,t){for(let n of e)if(t(n),n.type===`group`)Iu(n.fields,t);else if(n.type===`sub-tabs`)for(let e of n.tabs)Iu(e.fields,t)}function Lu(e){if(!e)return{};let t={};for(let n of e.sections)Iu(n.fields,e=>{let n=Nu(e);n!==null&&(t[n]=Pu(e))});return t}function Ru(e,t){if(!e)return null;let n=null;for(let r of e.sections)if(Iu(r.fields,e=>{if(n!==null||Nu(e)!==t)return;let r=Fu(e);r&&r.writerCapName&&r.writerAddonId&&(n={capName:r.writerCapName,addonId:r.writerAddonId})}),n!==null)break;return n}function zu(e){return{...e,fields:e.fields.map(Bu)}}function Bu(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`object-array`?e:{...e,readonlyField:!0}}function Vu(e,t){return e&&{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{let n=Fu(e);return n?Au(t,n.minRole)?e:Bu(e):e})}))}}var Hu={sections:[]};function Uu({deviceId:e,sectionFilter:t,activeSubTab:n,onSubTabChange:r,flattenSubTabs:a,subTabGrouping:o,leadingTabs:s}){let{t:c}=W(),l=O(),{user:f}=du(),p=f?.isAdmin===!0,m=u(!1),{data:h,isLoading:y}=rn({deviceId:e},{refetchInterval:()=>m.current?!1:2500,enabled:Number.isFinite(e)}),{data:b}=en({deviceId:e},{enabled:Number.isFinite(e)}),x=h?.settings??null,S=h?.live??null,C=d(()=>{if(!x&&!S)return null;let e=x?.sections??[],n=(S?.sections??[]).map(zu),r=[...e,...n],i=t?r.filter(t):r.filter(Eu);if(i.length===0)return null;if(o){let e=i.map(e=>({...e,tab:o.groupOf(e)})),t=new Set(e.map(e=>e.tab)),n=o.tabs.filter(e=>t.has(e.id));return n.length>0?{tabs:n,sections:e}:{sections:e}}let a=new Set;for(let e of i)a.add(e.tab??`general`);let s=[...x?.tabs??[],...(S?.tabs??[]).filter(e=>!(x?.tabs??[]).some(t=>t.id===e.id))].filter(e=>a.has(e.id));return s.length>0?{tabs:s,sections:i}:{sections:i}},[x,S,t,o]),w=d(()=>ku([...x?.sections??[],...S?.sections??[]]),[x,S]),T=d(()=>ju(C),[C]),E=d(()=>Vu(T,p),[T,p]),D=d(()=>Lu(E),[E]),k=Ut(),A=mn(),j=hr(),M=cn(),N=Pn({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),P={isPending:N.isPending,mutate:t=>{N.mutate({deviceId:e,changes:[...t]})}},F=pu({schema:E,serverValues:D,onImmediateSave:g(e=>{let t=Object.entries(e).map(([e,t])=>{let n=Ru(E,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&P.mutate(t)},[E,P]),onDeferredSave:g(async t=>{let n=Object.entries(t).map(([e,t])=>{let n=Ru(E,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);if(n.length!==0)try{let t=await N.mutateAsync({deviceId:e,changes:n});if(t.failures.length>0)throw Error(t.failures.map(e=>e.error).join(`; `))}finally{await l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}},[E,N,e,l])}),{values:ee,pendingKeys:te,handleChange:ne,handleSave:I,handleDiscard:re}=F;m.current=F.editingPaused;let ie=Uc(),ae=u(I),oe=u(re);ae.current=I,oe.current=re;let se=ie?.register,ce=N.isError?N.error instanceof Error?N.error.message:String(N.error):null,L=te.join(`\0`);v(()=>{if(se===void 0)return;let e=L===``?[]:L.split(`\0`);return se({id:`export`,dirty:e.length>0,saving:N.isPending,error:ce,save:()=>(ae.current(e),Promise.resolve()),discard:()=>oe.current(e)})},[se,L,N.isPending,ce]);let R=s!==void 0&&s.length>0;if(y&&!R)return i(`div`,{className:`flex items-center justify-center py-12 text-foreground-subtle`,children:[_(B,{className:`h-4 w-4 animate-spin mr-2`}),_(`span`,{className:`text-xs`,children:c(`device.deviceAggregateSection.loadingDeviceAggregate`,`Loading device aggregate…`)})]});if(!R&&(!E||E.sections.length===0))return _(`div`,{className:`text-xs text-foreground-subtle italic py-4 text-center`,children:c(`device.deviceAggregateSection.noAggregateContributionsForThis`,`No aggregate contributions for this device.`)});async function le(t,n,r){if(t===`regenerate-rtsp-token`){let t=[`rtspUrl:`,`regenerateToken:`].find(e=>n.startsWith(e));if(!t)throw Error(`regenerate-rtsp-token: unrecognised key "${n}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);let r=n.slice(t.length);if(!r)throw Error(`regenerate-rtsp-token: key "${n}" has no streamId after prefix`);let i=ot(e,r);await k.mutateAsync({brokerId:i}),l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]});return}if(t===`test-probe`){if(!b)return{status:`error`,error:c(`device.deviceAggregateSection.metadataNotLoaded`)};try{return await j.mutateAsync({addonId:b.addonId,type:b.type,key:n,value:r})}catch(e){return{status:`error`,error:e instanceof Error?e.message:String(e)}}}if(t===`refresh-probe`){if(!n.startsWith(`probedInfo:`))throw Error(`refresh-probe: unrecognised key "${n}" (expected "probedInfo:<streamId>")`);let t=n.slice(11);if(!t)throw Error(`refresh-probe: key "${n}" has no streamId after prefix`);let r=ot(e,t),i=await A.mutateAsync({brokerId:r});return l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),i}if(t===`device-custom-action`){let t=await M.mutateAsync({deviceId:e,action:n,input:r});return l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),t}throw Error(`[device-aggregate] unknown action "${t}"`)}return _(gu,{schema:E??Hu,values:ee,pendingKeys:te,onChange:ne,onAction:le,onSave:I,onDiscard:re,hideSaveBar:ie!==null,disabled:P.isPending,activeSubTab:n,onSubTabChange:r,flattenTabs:a,leadingTabs:s,visibilityContext:w})}w();function Wu({deviceId:e,onClose:t}){let{t:n}=W(),[r,a]=b(`info`),{data:o}=en({deviceId:e},{enabled:e>0}),s=Bn(e),c=lc(s.presence,s.list),l=r===`history`&&!c?`info`:r,u=typeof o?.name==`string`?o.name:``,d=Ht(e,`full`,u.length>0?u:`#${String(e)}`),f=typeof o?.location==`string`?o.location:``,p=[[`info`,n(`deviceQuickDetail.tabInfo`,{defaultValue:`Device info`})],[`export`,n(`deviceQuickDetail.tabExport`,{defaultValue:`Export`})],...c?[[`history`,n(`deviceQuickDetail.tabHistory`,{defaultValue:`History`})]]:[]];return _(An,{open:!0,onOpenChange:e=>!e&&t(),children:_(un,{width:`lg`,scroll:`body`,children:i(Wc,{deviceId:e,seed:o==null?null:{name:u,location:f,role:typeof o.role==`string`?o.role:null,display:o.display},showOpenFull:!0,onClose:t,children:[_(dn,{children:_(Ft,{children:d})}),_(`div`,{className:`mt-3 flex items-center gap-1 rounded-md bg-surface-hover p-0.5 w-fit`,children:p.map(([e,t])=>_(`button`,{type:`button`,onClick:()=>a(e),className:`px-2.5 py-1 rounded text-[11px] font-medium transition-colors ${l===e?`bg-surface text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`}`,children:t},e))}),_(br,{className:`mt-3`,children:i(fr,{deviceId:e,device:o??void 0,children:[_(`div`,{className:l===`info`?void 0:`hidden`,children:_(kc,{})}),_(`div`,{className:l===`export`?void 0:`hidden`,children:_(Uu,{deviceId:e,sectionFilter:xu})}),c?_(`div`,{className:l===`history`?void 0:`hidden`,children:_(cc,{deviceId:e})}):null]})})]})})})}function Gu({children:e}){let[t,n]=b(null),r=g(e=>n(e),[]),a=g(()=>n(null),[]);return i(pn,{open:r,children:[e,t===null?null:_(Wu,{deviceId:t,onClose:a})]})}w();function Ku({tabs:e,active:t,onChange:n}){return _(`div`,{className:`flex rounded-lg border border-border bg-surface p-0.5 gap-0.5`,children:e.map(e=>_(`button`,{type:`button`,onClick:()=>n(e.id),className:[`flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors`,t===e.id?`bg-primary/12 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`].join(` `),children:e.label},e.id))})}function qu(e){let t=e.formats;if(!t)return``;let n=Object.values(t).filter(e=>e!==void 0&&e.sizeMB>0).map(e=>e.sizeMB);if(n.length===0)return``;let r=Math.min(...n),i=Math.max(...n);return r===i?`${r} MB`:`${r}-${i} MB`}function Ju(e){return`${e.inputSize.width}x${e.inputSize.height}`}function Yu(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function Xu({entry:e,selected:t,onSelect:n,disabled:r}){let{t:a}=W(),o=qu(e),s=Ju(e),c=Yu(e);return i(`button`,{type:`button`,onClick:n,disabled:r,className:[`w-full text-left rounded-lg border p-3 transition-all`,t?`border-primary bg-primary/5 ring-1 ring-primary/30`:`border-border bg-background hover:border-foreground-subtle/40 hover:bg-surface-hover/50`,r?`opacity-50 cursor-not-allowed`:`cursor-pointer`].join(` `),children:[_(`div`,{className:`flex items-start justify-between gap-2`,children:i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`flex items-center gap-2`,children:[_(`span`,{className:`text-xs font-semibold text-foreground truncate`,children:e.name}),t&&_(N,{className:`h-3.5 w-3.5 text-primary shrink-0`})]}),_(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 line-clamp-2`,children:e.description})]})}),i(`div`,{className:`flex items-center gap-3 mt-2 flex-wrap`,children:[i(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[_(Pe,{className:`h-3 w-3`}),s]}),o&&_(`span`,{className:`text-[10px] text-foreground-subtle`,children:o}),c.length>0&&_(`div`,{className:`flex gap-1`,children:c.map(e=>_(`span`,{className:`text-[9px] uppercase rounded bg-surface border border-border px-1 py-0.5 text-foreground-subtle font-mono`,children:e},e))}),e.labels.length>0&&_(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`common.labels`,{count:e.labels.length})})]})]})}function Zu({field:e,value:t,onChange:n,disabled:r}){let{t:a}=W(),o=e.catalog??[],s=o.length>0,c=lt(o).length>0,l=e.allowCustomPath!==!1||e.allowCustom===!0,u=[...s?[{id:`catalog`,label:a(`formBuilder.modelSelector.models`,`Models ({{length}})`,{length:o.length})}]:[],...l?[{id:`custom`,label:a(`formBuilder.modelSelector.customPath`,`Custom Path`)}]:[]],[d,f]=b(s?`catalog`:`custom`),p=t==null?``:String(t);return i(`div`,{className:`space-y-3`,children:[u.length>1&&_(Ku,{tabs:u,active:d,onChange:f}),d===`catalog`&&s&&c&&_(Yn,{catalog:o,value:p,onChange:e=>n(e),disabled:r||e.disabled}),d===`catalog`&&s&&!c&&_(`div`,{className:`space-y-1.5 max-h-[320px] overflow-y-auto pr-1`,children:o.filter(e=>e.legacy!==!0).map(t=>_(Xu,{entry:t,selected:p===t.id,onSelect:()=>n(t.id),disabled:r||e.disabled},t.id))}),d===`catalog`&&!s&&i(`div`,{className:`rounded-md border border-info/30 bg-info/5 px-3 py-2 flex items-start gap-2`,children:[_(Xe,{className:`h-3.5 w-3.5 text-info shrink-0 mt-0.5`}),_(`p`,{className:`text-[11px] text-foreground-subtle leading-relaxed`,children:a(`formBuilder.modelSelector.noPredefinedModelsAvailableUse`,`No predefined models available. Use the Custom Path tab to specify a model file path or URL.`)})]}),d===`custom`&&l&&i(`div`,{className:`space-y-2`,children:[_(`input`,{type:`text`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none disabled:opacity-50`,placeholder:a(`formBuilder.modelSelector.enterPathLikeDataModels`,`Enter path like /data/models/custom.onnx or https://...`),value:p,disabled:r||e.disabled,onChange:e=>n(e.target.value)}),e.acceptFormats&&e.acceptFormats.length>0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:[a(`formBuilder.modelSelector.acceptedFormats`,`Accepted formats:`),` `,e.acceptFormats.join(`, `)]})]}),(e.compatibilityNote||e.conversionGuideUrl)&&i(`div`,{className:`flex items-start justify-between gap-3 pt-1`,children:[e.compatibilityNote&&i(`p`,{className:`flex items-start gap-1 text-[10px] text-foreground-subtle`,children:[_(Xe,{className:`h-3 w-3 mt-0.5 shrink-0`}),e.compatibilityNote]}),e.conversionGuideUrl&&i(`a`,{href:e.conversionGuideUrl,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-[11px] text-primary hover:underline shrink-0`,children:[a(`formBuilder.modelSelector.howToConvertYourModel`,`How to convert your model`),_(He,{className:`h-3 w-3`})]})]})]})}function Qu({to:e}){let{search:t}=Y();return _(X,{to:`${e}${t}`,replace:!0})}w();function $u(){return U.t(`helpers.keychainRevealHost.forbidden`)}function ed(e){if(typeof e!=`object`||!e)return null;let t=Reflect.get(e,`data`);if(typeof t!=`object`||!t)return null;let n=Reflect.get(t,`code`);return typeof n==`string`?n:null}function td(e){let t=ed(e);if(t===`FORBIDDEN`||t===`UNAUTHORIZED`)return $u();let n=e instanceof Error?e.message:String(e);return n.length>0?U.t(`helpers.keychainRevealHost.failedWith`,{message:n}):U.t(`helpers.keychainRevealHost.failed`)}function nd({children:e}){let t=vn();return _($t,{reveal:g(async e=>{try{return(await t.mutateAsync({ref:e})).value}catch(e){throw Error(td(e))}},[t]),children:e})}w();function rd(){let e=Oe(),t=O(),[n,r]=b(()=>e.isConnected()?`connected`:`disconnected`),i=u(!1),[a,o]=b(0),[s,c]=b([]);v(()=>e.subscribeConnectionEvents(e=>{r(t=>(t!==`connected`&&e===`connected`&&i.current&&o(e=>e+1),e!==`connected`&&(i.current=!0),e))}),[e]),v(()=>{a!==0&&t.invalidateQueries({queryKey:[[`addons`,`getLastRestart`]]})},[a,t]);let{data:l}=Tr(void 0,{enabled:n===`connected`&&a>0,staleTime:0,refetchOnMount:!1,refetchOnWindowFocus:!1}),d=u(null);return v(()=>{if(l==null||l.requestedAt===d.current)return;d.current=l.requestedAt;let e=ad(l);c(t=>[...t,e]);let t=window.setTimeout(()=>{c(t=>t.filter(t=>t.id!==e.id))},6e3);return()=>window.clearTimeout(t)},[l]),_(A,{children:s.length>0&&_(id,{toasts:s})})}function id({toasts:e}){return _(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex flex-col gap-2 max-w-sm w-full pointer-events-none`,children:e.map(e=>i(`div`,{className:`pointer-events-auto flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm`,children:[_(Ye,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),i(`div`,{children:[_(`div`,{className:`text-[11px] font-semibold text-foreground`,children:e.title}),_(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:e.message})]})]},e.id))})}function ad(e){let t=`restart-${e.requestedAt}`;if(e.kind===`framework-update`&&e.packageName!==void 0&&e.toVersion!==void 0){let n=e.fromVersion===void 0?`v${e.toVersion}`:`v${e.fromVersion} → v${e.toVersion}`;return{id:t,title:U.t(`system.reconnectOverlay.frameworkUpdated`,`Framework updated`),message:U.t(`system.reconnectOverlay.isNow`,`{{packageName}} is now {{fromTo}}.`,{packageName:e.packageName,fromTo:n})}}return{id:t,title:U.t(`system.reconnectOverlay.serverRestarted`,`Server restarted`),message:e.requestedBy===void 0?U.t(`system.reconnectOverlay.manualRestartCompleted`,`Manual restart completed.`):U.t(`system.reconnectOverlay.manualRestartByCompleted`,`Manual restart by {{requestedBy}} completed.`,{requestedBy:e.requestedBy})}}var od=`/system/settings`,sd=[{path:`/system/secrets`,tab:`secrets`},{path:`/system/capabilities`,tab:`capabilities`}];function cd(e,t=``){let n=new URLSearchParams(t);return n.delete(`tab`),n.set(`tab`,e),`${od}?${n.toString()}`}function ld({tab:e}){let{search:t,hash:n}=Y();return _(X,{to:`${cd(e,t)}${n}`,replace:!0})}var ud=new Set;function dd(e){for(let t of ud)t(e)}function fd(e){return ud.add(e),()=>{ud.delete(e)}}w();var pd={info:{bg:`bg-info/10`,border:`border-info/30`,icon:Xe},warning:{bg:`bg-warning/10`,border:`border-warning/30`,icon:$e},critical:{bg:`bg-danger/10`,border:`border-danger/30`,icon:F}};function md({toast:e,onDismiss:t}){let n=pd[e.severity]??pd.info,r=n.icon;return v(()=>{let n=e.duration??5e3;if(n<=0)return;let r=setTimeout(()=>t(e.id),n);return()=>clearTimeout(r)},[e.id,e.duration,t]),i(`div`,{className:`flex items-start gap-3 px-4 py-3 rounded-lg border ${n.border} ${n.bg} shadow-lg backdrop-blur-sm animate-in slide-in-from-right-5 fade-in duration-200`,children:[_(r,{className:`h-4 w-4 shrink-0 mt-0.5 text-foreground-subtle`}),i(`div`,{className:`flex-1 min-w-0`,children:[_(`div`,{className:`text-xs font-semibold text-foreground`,children:e.title}),_(`div`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:e.message})]}),_(`button`,{type:`button`,onClick:()=>t(e.id),className:`shrink-0 p-0.5 rounded hover:bg-surface-hover transition-colors`,children:_(Ae,{className:`h-3.5 w-3.5 text-foreground-subtle`})})]})}function hd(){let[e,t]=b([]),n=g(e=>{t(t=>t.filter(t=>t.id!==e))},[]),r=g(e=>{let n=`toast-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;t(t=>[...t,{...e,id:n,timestamp:Date.now()}])},[]);return Xn(void 0,{onData:e=>r(e)}),v(()=>fd(r),[r]),e.length===0?null:_(`div`,{className:`fixed bottom-[calc(env(safe-area-inset-bottom)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex flex-col gap-2 max-w-sm w-full pointer-events-none`,children:e.map(e=>_(`div`,{className:`pointer-events-auto`,children:_(md,{toast:e,onDismiss:n})},e.id))})}function gd(e){return(t,n,r)=>e(t,{...typeof n==`string`?{defaultValue:n}:{defaultValue_one:n.one,defaultValue_other:n.other},...r})}var _d=(e,t,n)=>gd(U.t.bind(U))(e,t,n);w();function vd({children:e}){let{t}=W();return _(Ee,{t:d(()=>gd(t),[t]),children:e})}w();function yd(e){if(typeof e!=`object`||!e)return;let{data:t}=e;return t?.code}function bd(e,t){let n=yd(e);return n===`UNAUTHORIZED`||n===`FORBIDDEN`?!0:/UNAUTHORIZED|FORBIDDEN/.test(t)}function xd(e,t,n,r){let[i,a]=b(!1),[o,s]=b(null);return v(()=>{if(a(!1),s(null),!t){a(!0);return}let i=!1;e.init().catch(()=>void 0);let o=t=>{e.awaitConnected().then(()=>{i||a(!0)},e=>{if(i)return;let c=e instanceof Error?e.message:String(e);if(bd(e,c)){if(t&&r!==void 0){r().then(e=>{if(!i){if(e){o(!1);return}console.warn(`[boot-gate] logout: probe UNAUTHORIZED and the refresh was refused`),n()}},()=>{i||(console.warn(`[boot-gate] logout: probe UNAUTHORIZED and recovery failed`),n())});return}console.warn(`[boot-gate] logout: probe UNAUTHORIZED after a successful refresh`,c),n();return}s(c),a(!0)})};return o(!0),()=>{i=!0}},[e,t,n,r]),{bootReady:i,bootError:o}}w();var Sd=3e4;function Cd(e){let t=u(e);t.current=e,v(()=>{let e=null,n=()=>{if(document.visibilityState===`hidden`){e=Date.now();return}if(document.visibilityState===`visible`&&e!==null){let n=Date.now()-e;e=null,n>=Sd&&t.current()}},r=()=>{t.current()},i=e=>{e.persisted&&t.current()};return document.addEventListener(`visibilitychange`,n),window.addEventListener(`online`,r),window.addEventListener(`pageshow`,i),()=>{document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`online`,r),window.removeEventListener(`pageshow`,i)}},[])}w();function wd(){let{t:e}=W();return i(`div`,{role:`status`,"aria-busy":`true`,"aria-label":e(`layouts.addonPageLoader.loading`,`Loading page`),"data-testid":`addon-page-loading`,className:`flex flex-col gap-4 p-2 sm:p-4`,children:[_(Qt,{className:`h-7 w-48`}),_(Qt,{className:`h-5 w-72 max-w-full`}),_(Qt,{className:`h-40`})]})}function Td({message:e}){let{t}=W();return _(`div`,{className:`p-2 sm:p-4`,"data-testid":`addon-page-error`,children:_(V,{title:t(`layouts.addonPageLoader.failedTitle`,`This page could not be shown`),message:e})})}var Ed=class extends o{state={error:null,resetKey:this.props.resetKey};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}static getDerivedStateFromProps(e,t){return e.resetKey===t.resetKey?null:{error:null,resetKey:e.resetKey}}componentDidCatch(e,t){console.error(`[addon-page] ${this.props.resetKey} crashed`,e,t.componentStack)}render(){return this.state.error===null?this.props.children:_(Td,{message:this.state.error.message})}};function Dd({resetKey:e,children:t}){return _(Ed,{resetKey:e,children:t})}function Od({pageKey:e,children:t}){return _(Ed,{resetKey:e,children:_(h,{fallback:_(wd,{}),children:t})})}w();function kd(e){let t=new Set,n=new Set,r=e=>e.page.remoteName.includes(e.addonId.replace(/[^a-zA-Z0-9]+/g,`_`)),i=[...e.filter(r),...e.filter(e=>!r(e))],a=[];for(let e of i){let r=`${e.addonId}::${e.page.id}`;t.has(r)||n.has(e.page.path)||(t.add(r),n.add(e.page.path),a.push({id:e.page.id,addonId:e.addonId,label:e.page.label,icon:e.page.icon,path:e.page.path,remoteName:e.page.remoteName,bundle:e.page.bundle,bundleUrl:e.bundleUrl,...e.page.section===void 0?{}:{section:e.page.section},...e.page.sectionLabel===void 0?{}:{sectionLabel:e.page.sectionLabel}}))}return a}var Ad=2e4;function jd(e,t){let[n,r]=b(!1);return v(()=>{if(!e){r(!1);return}let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}var Md=new Map,Nd=new Map,Pd=new Set;function Fd(e){return!e||typeof e!=`object`?!1:typeof e.default==`function`}async function Id(n,r){let i=Md.get(n);if(i)return i;let a=Nd.get(n);if(a)return a;Pd.has(n)||(Fn(),t([{name:n,entry:z(r),type:`module`}],{force:!1}),Pd.add(n));let o=e(`${n}/page`).then(e=>{if(!Fd(e))throw Error(`Addon page remote ${n} (${r}) does not expose a default React component on './page'`);return Md.set(n,e.default),Nd.delete(n),e.default}).catch(e=>{throw Nd.delete(n),e});return Nd.set(n,o),o}function Ld(){let{t:e}=W(),{pagePath:t}=ma(),n=ua(),r=Oe(),{data:i,isError:a,error:o}=on(void 0),s=d(()=>i?kd(i):void 0,[i]),c=s?.find(e=>e.path===`/addon/${t}`),l=c?.remoteName,u=c?.bundleUrl,[f,p]=b(null),[m,h]=b(null);v(()=>{if(!l||!u)return;h(null);let e=Md.get(l);if(e){p(()=>e);return}p(null);let t=!1;return Id(l,u).then(e=>{t||p(()=>e)}).catch(e=>{t||h(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[l,u]);let g=jd(!s&&!a,Ad),y=jd(c!==void 0&&!f&&!m,Ad);return s?c?m?_(Td,{message:m}):f?_(Od,{pageKey:c.remoteName,children:_(f,{trpc:r.trpcClient,theme:{isDark:document.documentElement.classList.contains(`dark`)},navigate:e=>{n(e.startsWith(`/`)?e:`/${e}`)}})}):y?_(Td,{message:e(`layouts.addonPageLoader.remoteStalled`,`The page did not load. Its addon may be starting or unreachable.`)}):_(wd,{}):_(`div`,{className:`flex items-center justify-center h-full text-foreground-subtle`,children:e(`layouts.addonPageLoader.addonPageNotFound`,`Addon page not found`)}):a?_(Td,{message:o?.message??e(`layouts.addonPageLoader.listFailed`,`The page list could not be loaded.`)}):g?_(Td,{message:e(`layouts.addonPageLoader.listStalled`,`The hub did not send the page list. Try again in a moment.`)}):_(wd,{})}var Rd={"/system/pipeline":`pipeline-orchestrator`,"/system/history":`device-history`,"/system/ai":`llm`};function zd(e,t){return e.filter(e=>!e.adminOnly||t).map(e=>{let t=Rd[e.path];return t===void 0?e:{...e,requiresCapability:t}})}function Bd({t:e,isAdmin:t}){let n=zd([{label:e(`nav.devices`,`Devices`),icon:ne,path:`/devices`},{label:e(`nav.integrations`),icon:I,path:`/integrations`},{label:e(`nav.build`,`Build-your-self`),icon:Le,path:`/build`,adminOnly:!0},{label:e(`nav.locations`,`Locations`),icon:Te,path:`/locations`,adminOnly:!0},{label:e(`nav.viewer`,`Viewer`),icon:ft,path:`/live`}],t),r=zd([{label:e(`nav.library`,`Library`),icon:yt,path:`/library`,adminOnly:!0,keywords:[`People`,`Vehicles`,`Events`,`Scenes`,`plates`,`faces`,`detection-intelligence`]},{label:e(`nav.recordings`,`Recordings`),icon:oe,path:`/recordings`,adminOnly:!0}],t),i=zd([{label:e(`nav.nodes`,`Nodes`),icon:ce,path:`/system/nodes`,adminOnly:!0},{label:e(`nav.history`,`History`),icon:Ie,path:`/system/history`,adminOnly:!0,keywords:[`charts`,`graphs`,`energy`,`temperature`,`metrics`,`trends`]},{label:e(`nav.pipeline`,`Pipeline`),icon:ht,path:`/system/pipeline`},{label:e(`system.addons`),icon:R,path:`/system/addons`,adminOnly:!0},{label:e(`system.ai`,`AI`),icon:Ue,path:`/system/ai`,adminOnly:!0}],t),a=zd([{label:e(`system.identity`,`Identity & Access`),icon:qe,path:`/system/identity`,adminOnly:!0},{label:e(`system.network`,`Network`),icon:mt,path:`/system/network`,adminOnly:!0},{label:e(`system.integrations`,`Connectivity`),icon:I,path:`/system/integrations`,adminOnly:!0},{label:e(`system.data`,`Data`),icon:Be,path:`/system/data`,adminOnly:!0},{label:e(`system.notifications`,`Notifications`),icon:ie,path:`/system/notifications`,adminOnly:!0},{label:e(`system.calendars`,`Calendars`),icon:dt,path:`/system/calendars`,adminOnly:!0},{label:e(`system.templates`,`Templates`),icon:Dt,path:`/system/templates`,adminOnly:!0},{label:e(`system.systemNav`,`System`),icon:ke,path:od,adminOnly:!0},{label:e(`system.logs`,`Logs`),icon:Ze,path:`/system/logs`,adminOnly:!0},{label:e(`system.terminal`,`Terminal`),icon:xt,path:`/system/terminal`,adminOnly:!0}],t);return[{key:`top`,label:null,items:n},{key:`detection`,label:e(`nav.detectionSection`,`Detection`),items:r},{key:`cluster`,label:e(`nav.clusterSection`,`Cluster`),items:i},{key:`administration`,label:e(`system.title`,`Administration`),items:a}]}var Vd={gauge:re,puzzle:R,bot:P,cpu:Pe,terminal:xt,box:Qe,boxes:Qe,monitor:ft,wrench:be,activity:Re,plug:I,"graduation-cap":fe};function Hd(e){return Vd[e]??R}function Ud(e,t){for(let n of Bd(t))for(let t of n.items)if(t.path===e)return{icon:t.icon,title:t.label,path:t.path};return null}var Wd=`/system/addons`;function Gd({path:e,children:t}){let n=Rd[e];return n===void 0?_(A,{children:t}):_(Kd,{path:e,capability:n,children:t})}function Kd({path:e,capability:t,children:n}){let{t:r}=W(),a=ua(),o=Gt(t);if(o===`present`)return _(A,{children:n});if(o===`pending`)return i(`div`,{className:`flex flex-col gap-4 p-2 sm:p-4`,"data-testid":`page-presence-pending`,children:[_(Qt,{className:`h-7 w-48`}),_(Qt,{className:`h-40`})]});if(o===`unknown`)return _(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-presence-unknown`,children:_(V,{title:r(`pageRequires.unknownTitle`,`Could not check whether this page is available`),message:r(`pageRequires.unknown`,`The hub did not answer the capability check. Reload the page to try again.`)})});let s=Ud(e,{t:r,isAdmin:!0});return _(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-not-installed`,children:_(Lt,{icon:s?.icon??R,title:r(`pageRequires.absentTitle`,`{{page}} is not installed`,{page:s?.title??e}),description:r(`pageRequires.absentDescription`,`The addon that provides this page is not installed. Install it from System → Addons.`),action:_(H,{variant:`primary`,onClick:()=>a(Wd),children:r(`pageRequires.openAddons`,`Open Addons`)})})})}function qd({capability:e,children:t}){return _(A,{children:t(Gt(e)===`absent`)})}function Jd({children:e}){return _(zn,{value:Yd(Qn({})),children:e})}function Yd(e){return e.data===void 0?e.isPending?{status:`pending`}:{status:`unknown`,reason:e.isError?String(e.error):`no palette`}:e.data.status===`unknown`?{status:`unknown`,reason:e.data.reason}:{status:`ready`,palette:e.data}}function Xd(){let e=gr(),{t}=W();return e.status===`unknown`?_(`p`,{role:`status`,className:`shrink-0 px-4 py-1 text-xs text-warning`,children:t(`pipeline.palette.unknown`,`The stored palette cannot be read ({{reason}}). Boxes use the bundled CamStack preset.`,{reason:e.reason})}):null}Er();var Zd=/\p{Mn}/gu;function Qd(e){return e.normalize(`NFD`).replace(Zd,``).toLowerCase().trim()}var $d=[`device`,`page`,`integration`],ef=0,tf=1,nf=2,rf=3,af=4,of=5,sf=6,cf=7;function lf(e,t,n,r){return n.includes(r)?ef:e===r?tf:e.startsWith(r)?nf:e.split(/\s+/).some(e=>e.startsWith(r))?rf:e.includes(r)?af:t.some(e=>e.includes(r))?of:null}function uf(e,t){let n=0;for(let r=0;r<e.length&&n<t.length;r++)e[r]===t[n]&&n++;return n===t.length}function df(e){return e<4?0:e<=7?1:e<=12?2:3}function ff(e,t,n){if(e===t)return 0;if(n<=0||Math.abs(e.length-t.length)>n)return null;let r=t.length,i=Array(r+1).fill(0),a=Array.from({length:r+1},(e,t)=>t),o=Array(r+1).fill(0);for(let s=1;s<=e.length;s++){o[0]=s;let c=s,l=e[s-1];for(let n=1;n<=r;n++){let r=t[n-1],u=l===r?0:1,d=Math.min((a[n]??1/0)+1,o[n-1]+1,(a[n-1]??1/0)+u);s>1&&n>1&&l===t[n-2]&&e[s-2]===r&&(d=Math.min(d,(i[n-2]??1/0)+1)),o[n]=d,d<c&&(c=d)}if(c>n)return null;let u=i;i=a,a=o,o=u}let s=a[r]??1/0;return s<=n?s:null}function pf(e,t){if(uf(e,t))return sf;let n=df(t.length);if(n>0){for(let r of e.split(/\s+/))if(ff(r,t,n)!==null)return cf}return null}function mf(e,t,n=200){let r=Qd(t);if(r.length===0)return{groups:[],totalMatched:0,truncated:!1};let i=new Map;for(let t of e){let e=Qd(t.label),n=lf(e,(t.keywords??[]).map(Qd),(t.identifiers??[]).map(Qd),r)??pf(e,r);if(n===null)continue;let a=i.get(t.domain)??[];a.push({item:t,rank:n}),i.set(t.domain,a)}let a=0;for(let e of i.values())a+=e.length;let o=n,s=[];for(let e of $d){let t=i.get(e);if(!t||t.length===0||o<=0)continue;t.sort((e,t)=>e.rank-t.rank||e.item.label.localeCompare(t.item.label));let n=t.slice(0,o).map(e=>e.item);o-=n.length,s.push({domain:e,items:n})}return{groups:s,totalMatched:a,truncated:a>n}}function hf(e){return e.flatMap(e=>e.items)}var gf=`instance`;function _f(e,t){let n=t[0];if(n===void 0)return null;let r=t.find(t=>t.id===e);return r===void 0?n.id:r.id}function vf(e,t){let n=`/integrations/${encodeURIComponent(e)}`;return t===void 0||t.length===0?n:`${n}?${gf}=${encodeURIComponent(t)}`}var yf=` · `;function bf(e,t,n,r){let i=[`#${t}`];return r!==void 0&&i.push(r),e.stableId.length>0&&e.stableId!==n&&i.push(e.stableId),i.push(e.type),e.disabled&&i.push(`disabled`),i.join(yf)}function xf(e,t=null){let n=yn(e),r=or(U.language.startsWith(`it`)?`it`:`en`),i=xn(e),a=zt(t);return e.map(e=>{let t=String(e.id),o=fn(e,`compact`,i,r),s=o.length>0?o:e.stableId||`#${t}`,c=n.get(e.id),l=c!==void 0&&(s===c||s.split(yf).includes(c)),u=a(e),d=u.kind===`resolved`?u.integration.name:``;return{key:`device:${t}`,domain:`device`,label:s,subtitle:bf(e,t,s,l?void 0:c),identifiers:[t,`#${t}`],keywords:[...e.name.length>0&&e.name!==s?[e.name]:[],e.stableId,e.addonId,e.location??``,c??``,d].filter(e=>e.length>0),path:`/devices/${t}`,icon:lr(e.type).icon}})}function Sf(e){return e.map(e=>({key:`integration:${e.id}`,domain:`integration`,label:e.name||e.addonId,subtitle:e.enabled?e.addonId:U.t(`helpers.searchItems.disabled`,{addonId:e.addonId}),keywords:[e.addonId,e.processState],path:vf(e.addonId,e.id)}))}function Cf(e,t,n){let r=e.section?.trim();return r?t[r]??e.sectionLabel?.trim()??r:n}function wf(e,t,n){let r=e.flatMap(e=>e.items.map(t=>({key:`page:${t.path}`,domain:`page`,label:t.label,subtitle:e.label??void 0,path:t.path,icon:t.icon,...t.keywords!==void 0&&t.keywords.length>0?{keywords:t.keywords}:{}}))),i={detection:n.detection,cluster:n.cluster,administration:n.administration},a=t.map(e=>({key:`page:addon:${e.addonId}:${e.id}`,domain:`page`,label:e.label,subtitle:Cf(e,i,n.ungrouped),keywords:[e.addonId],path:e.path,icon:Hd(e.icon)}));return[...r,...a]}w();var Tf={device:{labelKey:`search.resultsList.devices`,icon:ne},page:{labelKey:`search.resultsList.pages`,icon:bt},integration:{labelKey:`search.resultsList.integrations`,icon:I}};function Ef({groups:e,activeKey:t,query:n,totalMatched:r,truncated:a,onSelect:o,onHover:s}){let{t:c}=W(),l=u(null);if(v(()=>{t&&(l.current?.querySelector(`[data-key="${CSS.escape(t)}"]`))?.scrollIntoView({block:`nearest`})},[t]),n.trim().length===0)return null;if(e.length===0)return _(`div`,{className:`px-3 py-4 text-center text-[12px] text-foreground-subtle`,children:c(`search.resultsList.noResults`,{query:n})});let d=e.reduce((e,t)=>e+t.items.length,0);return i(A,{children:[_(`div`,{ref:l,role:`listbox`,className:`max-h-[60vh] overflow-y-auto py-1`,children:e.map(e=>{let n=Tf[e.domain],r=n.icon;return i(`div`,{className:`px-1 py-1`,children:[i(`div`,{className:`sticky top-0 z-10 flex items-center gap-1.5 bg-surface px-2 py-1 text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:[_(r,{className:`h-3 w-3`}),c(n.labelKey)]}),e.items.map(e=>{let r=e.icon??n.icon,a=e.key===t;return i(`button`,{type:`button`,role:`option`,"aria-selected":a,"data-key":e.key,onMouseEnter:()=>s(e),onClick:()=>o(e),className:`flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-[12px] transition-colors ${a?`bg-primary/12 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[_(r,{className:`h-3.5 w-3.5 shrink-0 ${a?`text-primary`:`text-foreground-subtle`}`}),i(`span`,{className:`flex-1 min-w-0`,children:[_(`span`,{className:`block truncate font-medium`,children:e.label}),e.subtitle&&_(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:e.subtitle})]})]},e.key)})]},e.domain)})}),a&&_(`div`,{className:`border-t border-border px-3 py-1.5 text-center text-[10px] text-foreground-subtle`,children:c(`search.truncatedResults`,`Showing first {{shown}} of {{total}} — refine your search.`,{shown:d,total:r})})]})}w();function Df({navSections:e,addonPages:t,compact:n,onNavigated:r}){let{t:a}=W(),o=ua(),s=u(null),c=u(null),l=u(null),[f,p]=b(null),[m,h]=b(``),[y,x]=b(0),[S,C]=b(!1),{data:w}=Wt({projection:`slim`}),{data:T}=Rt(void 0),E=d(()=>{let n={detection:a(`nav.detectionSection`,`Detection`),cluster:a(`nav.clusterSection`,`Cluster`),administration:a(`system.title`,`Administration`),ungrouped:a(`nav.addonPages`,`Addon Pages`)};return[...xf(w??[],T??null),...wf(e,t,n),...Sf(T??[])]},[w,T,e,t,a]),{groups:D,totalMatched:O,truncated:k}=d(()=>mf(E,m),[E,m]),A=d(()=>hf(D),[D]);v(()=>{x(0)},[m,E]),v(()=>{S&&s.current?.focus()},[S]);let j=g(()=>{C(!1),h(``),x(0)},[]),M=g(e=>{o(e.path),j(),s.current?.blur(),r?.()},[o,j,r]);Kt(s,{scope:bn}),v(()=>{if(!S)return;function e(e){if(!(e.target instanceof Node))return;let t=c.current?.contains(e.target)===!0,n=l.current?.contains(e.target)===!0;!t&&!n&&C(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[S]);let N=S&&m.trim().length>0;v(()=>{if(!N){p(null);return}let e=()=>{let e=s.current?.getBoundingClientRect();e&&p({left:e.left,top:e.bottom+4,width:e.width})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[N]);let P=A[y]?.key??null,F=a(`search.placeholder`,`Search devices, pages, integrations…`),ee=i(`div`,{className:`relative`,children:[_(Je,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`}),_(`input`,{ref:s,type:`text`,value:m,placeholder:F,"aria-label":F,role:`combobox`,"aria-expanded":S&&m.trim().length>0,"aria-controls":`global-search-results`,onChange:e=>{h(e.target.value),C(!0)},onFocus:()=>C(!0),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),A.length>0&&x(e=>(e+1)%A.length);else if(e.key===`ArrowUp`)e.preventDefault(),A.length>0&&x(e=>(e-1+A.length)%A.length);else if(e.key===`Enter`){e.preventDefault();let t=A[y];t&&M(t)}else e.key===`Escape`&&(e.preventDefault(),j(),s.current?.blur())},className:`w-full rounded-md border border-border bg-surface py-1.5 pl-7 pr-6 text-[12px] text-foreground placeholder:text-foreground-subtle/70 focus:outline-none focus:ring-1 focus:ring-primary/50`}),m.length>0&&_(`button`,{type:`button`,"aria-label":a(`search.globalSearch.clearSearch`,`Clear search`),onClick:()=>{h(``),s.current?.focus()},className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground`,children:_(Ae,{className:`h-3 w-3`})}),N&&f!==null&&Dr(_(`div`,{ref:l,id:`global-search-results`,className:`fixed z-50 w-max max-w-[26rem] rounded-lg border border-border bg-surface shadow-xl`,style:{left:f.left,top:f.top,minWidth:f.width},children:_(Ef,{groups:D,activeKey:P,query:m,totalMatched:O,truncated:k,onSelect:M,onHover:e=>{let t=A.findIndex(t=>t.key===e.key);t>=0&&x(t)}})}),document.body)]});return n?_(`div`,{ref:c,className:`px-1.5 pb-1.5`,children:S?_(`div`,{className:`fixed z-50 w-max min-w-72 max-w-[26rem]`,style:{left:`calc(env(safe-area-inset-left) + 3.5rem)`,top:`calc(env(safe-area-inset-top) + 3.5rem)`},children:ee}):_(`button`,{type:`button`,onClick:()=>C(!0),"aria-label":F,title:F,className:`flex w-full items-center justify-center rounded-md px-0 py-2 text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,children:_(Je,{className:`h-3.5 w-3.5 shrink-0`})})}):_(`div`,{ref:c,className:`px-2 pb-2`,children:ee})}var Of=/^(\d{1,3}\.){3}\d{1,3}$/;function kf(e){let t=e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e;return!!(Of.test(t)||t.includes(`:`))}function Af(e,t){return!t||kf(e)?!1:e===t||e.endsWith(`.${t}`)}w();var jf=`auth-webauthn/passkey-enrollment`,Mf=`camstack_passkey_prompt_dismissed:`,Nf=720*60*60*1e3;function Pf(e){try{let t=localStorage.getItem(`${Mf}${e}`);if(!t)return!1;let n=Number(t);return Number.isFinite(n)?Date.now()-n<Nf:!1}catch{return!1}}function Ff(e){try{localStorage.setItem(`${Mf}${e}`,String(Date.now()))}catch{}}function If(){let{user:e}=du(),{t}=W(),n=Oe(),r=At(jf),[a,o]=b(!1),[s,c]=b(!1),l=d(()=>e?Pf(e.id):!0,[e]),u=pr.auth.listLoginMethods.useQuery().data?.find(e=>e.kind===`passkey`),f=u!==void 0&&Af(window.location.hostname,u.rpId),p=e!==null&&f&&r!=null&&!l,m=S({queryKey:[`auth`,`listOwnPasskeys`],queryFn:()=>n.listOwnPasskeys(),enabled:p,staleTime:6e4}),h=g(()=>{e&&Ff(e.id),o(!0),c(!1)},[e]),v=g(()=>{c(!1),m.refetch()},[m]);return!p||a||m.data===void 0||m.data.length>0?null:i(`div`,{className:`shrink-0 border-b border-primary/20 bg-primary/5`,children:[i(`div`,{className:`flex items-center gap-2.5 px-3 py-2 text-xs text-foreground`,children:[_(Ct,{className:`h-4 w-4 text-primary shrink-0`}),_(`span`,{className:`flex-1 min-w-0`,children:t(`passkeyPrompt.message`,`Save a passkey for faster sign-in?`)}),_(`button`,{onClick:()=>c(e=>!e),className:`rounded bg-primary px-2.5 py-1 text-[11px] font-semibold text-primary-foreground hover:bg-primary/90`,children:t(`passkeyPrompt.enrollNow`,`Enroll now`)}),_(`button`,{onClick:h,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:t(`passkeyPrompt.notNow`,`Not now`)}),_(`button`,{onClick:h,"aria-label":t(`passkeyPrompt.notNow`,`Not now`),className:`p-1 rounded text-foreground-subtle hover:text-foreground`,children:_(Ae,{className:`h-3.5 w-3.5`})})]}),s&&_(`div`,{className:`px-3 pb-3`,children:i(`div`,{className:`max-w-xl`,children:[_(Sr,{widgetId:jf,host:`dashboard`}),_(`div`,{className:`mt-2 flex justify-end`,children:_(`button`,{onClick:v,className:`rounded border border-border px-2.5 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:t(`common.close`,`Close`)})})]})})]})}var Lf=6e4;function Rf(){let e=cr(void 0,{staleTime:Lf});return{info:e.data?.serverName??null,isLoading:e.isLoading}}w();var zf=`system-config`,Bf=`hub`,Vf=`camstack_server_name_prompt_dismissed`;function Hf(){try{return sessionStorage.getItem(Vf)===`1`}catch{return!1}}function Uf(){try{sessionStorage.setItem(Vf,`1`)}catch{}}function Wf(e){return e.isAdmin&&e.info!==null&&e.info.isDefault&&!e.dismissed}function Gf(){let{user:e}=du(),{info:t}=Rf(),[n,r]=b(Hf);return Wf({isAdmin:e?.isAdmin===!0,info:t,dismissed:n})?_(Kf,{suggestion:t?.name??``,onLater:()=>{Uf(),r(!0)}}):null}function Kf({suggestion:e,onLater:t}){let{t:n}=W(),r=O(),a=nn(),[o,s]=b(e),[c,l]=b(null),d=u(null);v(()=>d.current?.focus(),[]);let f=g(async()=>{let e=rt.safeParse(o);if(!e.success){l(e.error.issues[0]?.message??n(`serverName.invalid`,`Not a valid name`));return}l(null);try{await a.mutateAsync({addonId:zf,nodeId:Bf,patch:{name:e.data}}),await r.invalidateQueries({queryKey:[[`system`,`info`]]}),await r.invalidateQueries({queryKey:[[`addonSettings`]]})}catch(e){l(e instanceof Error&&e.message.length>0?e.message:`Could not save`)}},[r,a,n,o]);return _(An,{open:!0,onOpenChange:e=>!e&&t(),children:_(un,{children:i(`form`,{onSubmit:e=>{e.preventDefault(),a.isPending||f()},children:[i(dn,{children:[_(Ft,{children:n(`serverName.title`,`Name this server`)}),_(Pt,{children:n(`serverName.description`,`Pick a name for this hub. It shows in the admin UI and on the apps’ sign-in screen. You can change it later in System settings.`)})]}),_(br,{children:_(It,{label:n(`serverName.label`,`Server name`),...c===null?{}:{error:c},children:_(wr,{ref:d,value:o,maxLength:48,onChange:e=>s(e.target.value),state:c===null?`default`:`error`,"aria-label":n(`serverName.label`,`Server name`)})})}),i(_r,{children:[_(H,{type:`button`,variant:`ghost`,onClick:t,disabled:a.isPending,children:n(`serverName.later`,`Later`)}),i(H,{type:`submit`,disabled:a.isPending||o.trim().length===0,children:[a.isPending&&_(B,{className:`h-4 w-4 animate-spin`}),n(`common.save`,`Save`)]})]})]})})})}var qf=4,Jf=160,Yf=320,Xf=`env(safe-area-inset-top)`,Zf=`env(safe-area-inset-bottom)`;function Qf(e){let{rect:t,viewportWidth:n,viewportHeight:r}=e,i=Math.min(Yf,n-16),a={position:`fixed`,left:Math.max(8,Math.min(t.left,n-8-i)),width:i,zIndex:9999};if(r-t.bottom>=t.top){let e=`max(${t.bottom+qf}px, calc(${Xf} + 8px))`;return{...a,top:e,maxHeight:`max(${Jf}px, calc(100dvh - ${e} - ${Zf} - 8px))`}}let o=`max(${r-t.top+qf}px, calc(${Zf} + 8px))`;return{...a,bottom:o,maxHeight:`max(${Jf}px, calc(100dvh - ${o} - ${Xf} - 8px))`}}var $f=!1;function ep(){return $f}function tp(){$f=!0}function np(e){return!e.read&&e.severity===`critical`}function rp(e){return e.filter(np)}function ip(e){return e!==void 0&&typeof e.href==`string`&&e.href.length>0}function ap(e){return ip(e)||e!==void 0&&e.invoke!==void 0}var op=/^\/addon\/[^/?#]+\/oauth\//;function sp(e){return e.navigation===void 0?op.test(e.href):e.navigation===`server`}function cp(e){let t=e.action;if(ap(t)&&!(t.invoke!==void 0&&(e.status===`completed`||e.status===`dismissed`)))return t}w();function lp({action:e,className:t,onActivate:n}){let r=O(),a=Oe(),{t:o}=W(),[s,c]=b(!1),[l,u]=b(null);if(e.invoke!==void 0){let{addonId:d,action:f,input:p}=e.invoke;return i(`span`,{className:`inline-flex flex-col items-start gap-0.5`,children:[_(`button`,{type:`button`,className:t,disabled:s,onClick:e=>{e.preventDefault(),n?.(e),c(!0),u(null),a.trpcClient.addons.custom.mutate({addonId:d,action:f,input:p}).then(()=>r.invalidateQueries({queryKey:[[`alerts`]]})).catch(e=>u(e instanceof Error?e.message:String(e))).finally(()=>c(!1))},children:s?o(`ui.alertAction.running`,`Working…`):e.label}),l!==null&&_(`span`,{role:`alert`,className:`text-[10px] text-destructive`,children:l})]})}return ip(e)?sp(e)?_(`a`,{href:z(e.href),className:t,onClick:t=>{t.preventDefault(),n?.(t),ts(e.href,()=>{r.invalidateQueries({queryKey:[[`alerts`]]}),r.invalidateQueries({queryKey:[[`broker`]]}),r.invalidateQueries({queryKey:[[`recordEntries`]]})})},children:e.label}):_(jo,{to:e.href,className:t,onClick:n,children:e.label}):_(A,{})}w(),Er();var up={info:Xe,success:Ye,warning:$e,error:F,critical:vt},dp={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-danger`,critical:`text-danger`},fp={active:`border-l-info`,"in-progress":`border-l-warning`,completed:`border-l-success`,failed:`border-l-danger`,dismissed:`border-l-foreground-subtle/30`};function pp(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return U.t(`helpers.relativeTime.justNow`);let n=Math.floor(t/60);if(n<60)return U.t(`helpers.relativeTime.minutesAgo`,{count:n});let r=Math.floor(n/60);if(r<24)return U.t(`helpers.relativeTime.hoursAgo`,{count:r});let i=Math.floor(r/24);return U.t(`helpers.relativeTime.daysAgo`,{count:i})}function mp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function hp(e){return typeof e==`string`&&e.length>0?e:void 0}function gp(e){if(mp(e.metadata)){let t=hp(e.metadata.nodeId)??hp(e.metadata.agentId);if(t!==void 0)return t}let t=e.source;if(t!==void 0&&!(t.type!==`node`&&t.type!==`agent`))return hp(t.id)}function _p({alert:e,onMarkRead:t,onDismiss:n}){let{t:r}=W(),a=e.severity in up?e.severity:`info`,o=cp(e),s=e.status in fp?e.status:`active`,c=up[a],l=dp[a],u=fp[s],{nodes:d}=Dn(),f=gp(e),p=f===void 0?void 0:d.find(e=>e.id===f),m=f===void 0?void 0:p?.name??f;return i(`div`,{className:`flex items-start gap-2.5 px-3 py-2.5 border-l-2 ${u} ${e.read?`opacity-60`:``} hover:bg-surface-hover transition-colors`,children:[_(c,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${l}`}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`flex items-center gap-1.5`,children:[_(`span`,{className:`text-[11px] font-semibold ${e.read?`text-foreground-subtle`:`text-foreground`}`,children:e.title}),!e.read&&_(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary shrink-0`})]}),m!==void 0&&_(`div`,{className:`text-foreground-subtle text-[10px] mt-0.5 truncate`,children:m}),_(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5 line-clamp-2`,children:e.message}),o!==void 0&&_(lp,{action:o,className:`inline-flex mt-1.5 items-center rounded-md bg-primary px-2 py-0.5 text-[10px] font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,onActivate:e=>e.stopPropagation()}),e.status===`in-progress`&&e.progress!==void 0&&i(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[_(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:_(`div`,{className:`h-full bg-primary rounded-full transition-all duration-300`,style:{width:`${String(Math.min(100,Math.max(0,e.progress)))}%`}})}),i(`span`,{className:`text-[9px] text-foreground-subtle font-mono shrink-0`,children:[String(Math.round(e.progress)),`%`]})]}),_(`div`,{className:`text-[9px] text-foreground-subtle/60 mt-1`,children:pp(e.updatedAt)})]}),i(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[!e.read&&_(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),t(e.id)},className:`p-1 rounded hover:bg-surface-hover transition-colors`,title:r(`ui.alertBell.markAsRead`,`Mark as read`),children:_(N,{className:`h-3 w-3 text-foreground-subtle`})}),e.status!==`in-progress`&&_(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),n(e.id)},className:`p-1 rounded hover:bg-surface-hover transition-colors`,title:r(`ui.alertBell.dismiss`,`Dismiss`),children:_(Ae,{className:`h-3 w-3 text-foreground-subtle`})})]})]})}function vp({variant:e=`icon`,compact:t=!1}={}){let{t:n}=W(),[r,a]=b(!1),[o,s]=b(!1),c=u(null),l=u(null),d=O(),{data:f=0}=tr(void 0,{refetchInterval:3e4}),{data:p=[],isLoading:m}=dr({limit:50},{enabled:r}),h=o?p:p.filter(e=>!e.read),y=p.filter(e=>e.read).length,x=()=>{d.invalidateQueries({queryKey:[[`alerts`]]})},S=Kn({onSuccess:x}),C=jn({onSuccess:x}),w=En({onSuccess:x});qn(`alert.created`,()=>{d.invalidateQueries({queryKey:[[`alerts`]]})}),qn(`alert.updated`,()=>{d.invalidateQueries({queryKey:[[`alerts`]]})}),v(()=>{if(!r)return;let e=e=>{let t=e.target;c.current&&!c.current.contains(t)&&l.current&&!l.current.contains(t)&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[r]);let T=g(e=>{S.mutate({alertId:e})},[S]),E=g(e=>{e&&w.mutate({alertId:e})},[w]),D=g(()=>{C.mutate(void 0),a(!1)},[C]),k=h.filter(np),A=new Set(k.map(e=>e.id)),j=h.filter(e=>e.status===`in-progress`&&!A.has(e.id)),M=h.filter(e=>e.status!==`in-progress`&&!A.has(e.id)),[N,P]=b({}),F=g(()=>{let e=l.current;e&&P(Qf({rect:e.getBoundingClientRect(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}))},[]);return v(()=>{if(!r)return;F();let e=()=>F();return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[r,F]),i(`div`,{children:[e===`sidebar`?i(`button`,{ref:l,type:`button`,onClick:()=>a(!r),className:`flex w-full items-center gap-2.5 rounded-md ${t?`justify-center px-0 py-2`:`px-2.5 py-1.5`} text-[12px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,title:t?f>0?n(`ui.alertBell.alertsUnread`,{count:f}):n(`ui.alertBell.alerts`):void 0,children:[i(`span`,{className:`relative inline-flex shrink-0`,children:[_(Ze,{className:`h-3.5 w-3.5`}),t&&f>0&&_(`span`,{className:`absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary`})]}),!t&&_(`span`,{className:`flex-1 text-left`,children:n(`ui.alertBell.alerts`,`Alerts`)}),!t&&f>0&&_(`span`,{className:`flex items-center justify-center h-4 min-w-4 px-1 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none`,children:f>99?`99+`:String(f)})]}):i(`button`,{ref:l,type:`button`,onClick:()=>a(!r),className:`relative p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors`,"aria-label":n(`ui.alertBell.alerts`,`Alerts`),children:[_(Ze,{className:`h-4.5 w-4.5`}),f>0&&_(`span`,{className:`absolute -top-0.5 -right-0.5 flex items-center justify-center h-4 min-w-4 px-0.5 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none`,children:f>99?`99+`:String(f)})]}),r&&Dr(i(`div`,{ref:c,style:N,className:`bg-surface border border-border rounded-lg shadow-xl flex flex-col overflow-hidden`,children:[i(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[_(`span`,{className:`text-[12px] font-semibold text-foreground`,children:n(`ui.alertBell.alerts`,`Alerts`)}),i(`div`,{className:`flex items-center gap-2`,children:[y>0&&i(`label`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle cursor-pointer select-none`,children:[_(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`h-3 w-3 rounded border-border accent-primary cursor-pointer`}),n(`ui.alertBell.showRead`,`Show read`)]}),f>0&&i(`button`,{type:`button`,onClick:D,className:`flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:[_(_t,{className:`h-3 w-3`}),n(`ui.alertBell.markAllRead`,`Mark all read`)]})]})]}),i(`div`,{className:`flex-1 overflow-y-auto`,children:[m&&_(`div`,{className:`flex items-center justify-center py-8`,children:_(B,{className:`h-4 w-4 animate-spin text-foreground-subtle`})}),!m&&h.length===0&&i(`div`,{className:`flex flex-col items-center justify-center py-8 text-foreground-subtle`,children:[_(Ze,{className:`h-6 w-6 mb-2 opacity-40`}),_(`span`,{className:`text-[11px]`,children:p.length>0?n(`ui.alertBell.noUnreadAlerts`,`No unread alerts`):n(`ui.alertBell.noAlerts`,`No alerts`)}),p.length>0&&!o&&_(`button`,{type:`button`,onClick:()=>s(!0),className:`text-[10px] text-primary mt-1 hover:underline`,children:n(`ui.alertBell.showRead`,{count:y})})]}),k.length>0&&i(`div`,{className:`border-b border-border`,children:[_(`div`,{className:`px-3 py-1.5 bg-danger/5`,children:_(`span`,{className:`text-[9px] font-semibold uppercase tracking-widest text-danger`,children:n(`ui.alertBell.urgent`,`Urgent`)})}),k.map(e=>_(_p,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),j.length>0&&i(`div`,{className:`border-b border-border`,children:[_(`div`,{className:`px-3 py-1.5 bg-surface-hover/50`,children:_(`span`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:n(`ui.alertBell.inProgress`,`In Progress`)})}),j.map(e=>_(_p,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),M.map(e=>_(_p,{alert:e,onMarkRead:T,onDismiss:E},e.id))]})]}),document.body)]})}w(),Er();function yp({alert:e,onMarkRead:t}){let{t:n}=W(),r=cp(e);return i(`div`,{className:`border-b border-border last:border-b-0 px-3 py-2.5`,children:[_(`div`,{className:`text-[12px] font-semibold text-foreground`,children:e.title}),_(`div`,{className:`text-[11px] text-foreground-muted mt-0.5`,children:e.message}),i(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[r!==void 0&&_(lp,{action:r,className:`inline-flex items-center justify-center rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90 transition-colors`}),_(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>t(e.id),children:n(`ui.alertBell.markAsRead`,`Mark as read`)})]})]})}function bp(){let{t:e}=W(),t=O(),[n,r]=b(ep()),{data:a=[],isLoading:o}=dr({limit:50}),s=d(()=>rp(a),[a]),c=Kn({onSuccess:g(()=>{t.invalidateQueries({queryKey:[[`alerts`]]})},[t])}),l=g(e=>{c.mutate({alertId:e})},[c]),u=g(()=>{tp(),r(!0)},[]);return o||n||s.length===0?null:Dr(_(`div`,{className:`fixed inset-x-0 bottom-0 z-[10000] flex justify-center p-2 sm:p-4 pb-[max(0.5rem,env(safe-area-inset-bottom))] pointer-events-none`,"data-testid":`critical-alerts-on-load-panel`,children:i(`div`,{className:`pointer-events-auto w-full max-w-lg bg-surface border border-danger/30 rounded-lg shadow-xl flex flex-col max-h-[min(70dvh,32rem)] overflow-hidden`,role:`region`,"aria-labelledby":`critical-alerts-panel-title`,children:[i(`div`,{className:`flex items-start justify-between gap-2 px-3 py-2.5 border-b border-border shrink-0 bg-danger/5`,children:[i(`div`,{children:[_(`h2`,{id:`critical-alerts-panel-title`,className:`text-[12px] font-semibold text-foreground`,children:e(`ui.criticalAlertsPanel.title`,`Urgent alerts`)}),_(`p`,{className:`text-[10px] text-foreground-muted mt-0.5`,children:e(`ui.criticalAlertsPanel.subtitle`,`These need your attention.`)})]}),_(Nt,{type:`button`,variant:`ghost`,onClick:u,"aria-label":e(`ui.criticalAlertsPanel.close`,`Close`),"data-testid":`critical-alerts-panel-close`,icon:Ae})]}),_(`div`,{className:`flex-1 overflow-y-auto`,children:s.map(e=>_(yp,{alert:e,onMarkRead:l},e.id))})]})}),document.body)}w();function xp(){let e=al();return y(e.subscribe,e.getSnapshot,e.getSnapshot)}var Sp=[`detection`,`cluster`,`administration`];function Cp(e){return Sp.includes(e)}function wp(e){let t=new Map,n=new Map,r=[];for(let i of e){let e=i.section?.trim();if(e===void 0||e.length===0){r.push(i);continue}if(Cp(e)){let n=t.get(e)??[];n.push(i),t.set(e,n);continue}let a=n.get(e);a?a.pages.push(i):n.set(e,{label:i.sectionLabel?.trim()||e,pages:[i]})}return{known:t,custom:[...n.entries()].map(([e,t])=>({id:e,label:t.label,pages:t.pages})),ungrouped:r}}var Tp=`camstack:last-path`,Ep=512,Dp=[`/login`,`/change-password`,`/access-denied`,`/logout`];function Op(e){return!e.startsWith(`/`)||e.startsWith(`//`)||e.length>Ep?!1:!Dp.some(t=>e===t||e.startsWith(t+`/`))}function kp(e){if(!(typeof window>`u`)&&Op(e))try{window.localStorage.setItem(Tp,e)}catch{}}function Ap(){if(typeof window>`u`)return null;try{let e=window.localStorage.getItem(Tp);return e===null?null:Op(e)?e:null}catch{return null}}var jp=`/devices`;function Mp(e){return e!==void 0&&Op(e)?e:Ap()??jp}function Np(e){return e.split(`.`)[0]===`0`?`${e} beta`:e}function Pp(e){if(e===null)return null;let t=e.trim();return t.length>0?t:null}function Fp(e){let t=Pp(e.productVersion),n=Pp(e.serverVersion),r=Pp(e.fallbackVersion);return t!==null&&n!==null?{kind:`both`,productLabel:Np(t),serverVersion:n}:t===null?n===null?r===null?{kind:`none`}:{kind:`fallback`,version:r}:{kind:`server`,serverVersion:n}:{kind:`product`,productLabel:Np(t)}}function Ip(e,t){if(!Object.hasOwn(e,t))return null;let n=Reflect.get(e,t);return typeof n==`string`?n:null}function Lp(e){return typeof e!=`object`||!e?null:{productVersion:Ip(e,`productVersion`),serverVersion:Ip(e,`serverVersion`)}}w();function Rp(e,t){return e.kind===`both`?t(`releaseIdentity.both`,`{{product}} · server {{server}}`,{product:e.productLabel,server:e.serverVersion}):e.kind===`product`?e.productLabel:e.kind===`server`?t(`releaseIdentity.serverOnly`,`server {{version}}`,{version:e.serverVersion}):e.kind===`fallback`?t(`releaseIdentity.fallback`,`v{{version}}`,{version:e.version}):null}function zp({placement:e,compact:t=!1}){let{t:n}=W(),[r,i]=b({kind:`fallback`,version:`1.2.530`});v(()=>{let e=new AbortController;return fetch(z(`/api/release-identity`),{signal:e.signal}).then(async e=>e.ok?Lp(await e.json()):null).then(t=>{e.signal.aborted||t===null||i(Fp({productVersion:t.productVersion,serverVersion:t.serverVersion,fallbackVersion:`1.2.530`}))}).catch(t=>{e.signal.aborted||t instanceof DOMException&&t.name}),()=>e.abort()},[]);let a=Rp(r,n);return a===null?null:e===`login`?_(`span`,{"data-testid":`release-identity`,children:a}):_(`div`,{"data-testid":`release-identity`,className:`pt-1 text-[10px] text-foreground-disabled select-none truncate ${t?`text-center`:`px-2`}`,title:a,children:a})}w();var Bp=E(!0);function Vp(e){return e===`/addon`||e.startsWith(`/addon/`)}function Hp(e,t,n){let r=[...e.filter(e=>e!==t),t];return r.length<=n?r:r.slice(r.length-n)}function Up({maxCached:e=6}){let t=pa(),n=Y(),r=sa(),a=j(J),o=n.pathname,s=Vp(o),c=u(new Map),l=u([]);if(s){c.current.set(o,{key:o,outlet:t,location:n,navigationType:r,routeContext:a});let i=Hp(l.current,o,e),s=new Set(i);for(let e of c.current.keys())s.has(e)||c.current.delete(e);l.current=i}return i(A,{children:[l.current.map(e=>{let t=c.current.get(e);if(t?.outlet==null)return null;let n=s&&e===o;return _(`div`,{className:n?`h-full min-h-0`:void 0,style:n?void 0:{display:`none`},hidden:!n,"aria-hidden":!n,children:_(Bp.Provider,{value:n,children:_(Qi.Provider,{value:{location:t.location,navigationType:t.navigationType},children:_(J.Provider,{value:t.routeContext,children:t.outlet})})})},e)}),!s&&t!=null?_(`div`,{className:`h-full min-h-0`,children:t},o):null]})}w();var Wp={dark:M,light:pe,system:ft};function Gp(){return _(`div`,{className:`flex h-full min-h-[50vh] items-center justify-center`,children:_(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`})})}function Kp(){let e=Y(),t=ua(),{user:n,logout:r}=du(),a=mr(),{t:o}=W(),s=Yt(),c=Bt(),{info:l}=Rf();v(()=>{document.title=l===null?`CamStack Admin`:`${l.name} \u00b7 CamStack Admin`},[l]);let f=Yc(xp()),[p,m]=b(!1);v(()=>{kp(e.pathname+e.search)},[e.pathname,e.search]);let[g,y]=b(()=>typeof window>`u`?!1:window.localStorage.getItem(`camstack:sidebar-collapsed`)===`1`);v(()=>{typeof window>`u`||window.localStorage.setItem(`camstack:sidebar-collapsed`,g?`1`:`0`)},[g]);let[x]=b(()=>{if(typeof window>`u`)return new Set;try{let e=window.localStorage.getItem(`camstack:sidebar-collapsed-groups`);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}});v(()=>{typeof window>`u`||window.localStorage.setItem(`camstack:sidebar-collapsed-groups`,JSON.stringify([...x]))},[x]),v(()=>{c&&window.localStorage.getItem(`camstack:sidebar-collapsed`)===null&&y(!0)},[c]);let{data:S=[]}=ir({nodeId:`hub`},{refetchInterval:3e4}),C=S.length,w=O(),T=u(Date.now()),{data:E}=on(void 0,{staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let t=e.state.data;return t&&t.length>0||Date.now()-T.current>=3e4?!1:2e3}}),D=d(()=>E&&n?.isAdmin?kd(E):[],[E,n?.isAdmin]),k=d(()=>wp(D),[D]),j=k.known.get(`detection`)??[],M=k.known.get(`cluster`)??[],N=k.known.get(`administration`)??[];qn(`addon.page-ready`,()=>{w.invalidateQueries({queryKey:[[`addonPages`,`listPages`]]})});let P=()=>{r(),t(`/login`)},F=t=>!!(e.pathname===t||e.pathname.startsWith(t+`/`)),te=[`/system/pipeline`,`/live`,`/addon/osd-manager`,`/build`].some(t=>e.pathname===t||e.pathname.startsWith(t+`/`)),ne=n?.isAdmin===!0,I=d(()=>Bd({t:o,isAdmin:ne}),[o,ne]),re=I[0]?.items??[],ie=I[1]?.items??[],ae=I[2]?.items??[],oe=I[3]?.items??[],se=a?.mode??`system`,ce={dark:o(`theme.dark`),light:o(`theme.light`),system:o(`theme.system`)},L=g&&!s,R=(e,t=`md`,n=!1)=>`flex w-full items-center gap-2.5 rounded-md ${L?`justify-center px-0 py-2`:`px-2.5 py-1.5`} ${t===`lg`?`text-[13px] font-medium`:`text-[12px]`} transition-all ${e?t===`lg`?`bg-primary/12 text-primary shadow-sm shadow-primary/5`:`bg-primary/12 text-primary`:n?`text-foreground-disabled hover:bg-surface-hover`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,le=(e,t)=>e===0?null:L?_(`div`,{className:`pt-3 mb-1 mx-2 border-t border-border/60`},`sep-${t}`):_(`div`,{className:`pt-4 pb-1.5 px-2.5`,children:_(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:t})},`hdr-${t}`),de=e=>{let n=F(e.path),r=Hd(e.icon);return i(`button`,{onClick:()=>{t(e.path),m(!1)},className:R(n),title:L?e.label:void 0,children:[_(r,{className:`h-3.5 w-3.5 shrink-0 ${n?`text-primary`:``}`}),!L&&e.label]},`${e.addonId}::${e.id}`)},fe=e=>e.requiresCapability===void 0?pe(e,!1):_(qd,{capability:e.requiresCapability,children:t=>pe(e,t)},e.path),pe=(e,n)=>{let r=e.icon,a=F(e.path),s=e.path===`/system/addons`;return i(`button`,{"data-testid":`nav-${e.path.replace(/^\//,``).replace(/\//g,`-`)}`,onClick:()=>{t(e.path),m(!1)},className:R(a,`md`,n),"aria-disabled":n||void 0,title:n?o(`nav.notInstalled`,`{{page}} — not installed`,{page:e.label}):L?e.label:void 0,children:[_(r,{className:`h-3.5 w-3.5 shrink-0 ${a?`text-primary`:``}`}),!L&&i(A,{children:[_(`span`,{className:`flex-1 text-left`,children:e.label}),s&&C>0&&_(`span`,{className:`ml-auto rounded-full bg-primary px-1.5 py-0.5 text-[9px] font-bold text-primary-foreground leading-none`,children:C})]}),L&&s&&C>0&&_(`span`,{className:`absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary`})]},e.path)},he=i(A,{children:[i(`div`,{className:`flex h-14 items-center border-b border-border ${L?`justify-center px-1`:`pl-3 pr-4 gap-2`}`,children:[!L&&_(`img`,{src:a?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:o(`layouts.appLayout.camstackAdmin`,`CamStack Admin`),className:`h-9 flex-1 min-w-0`}),!s&&_(`button`,{onClick:()=>y(e=>!e),className:`p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle transition-colors flex-shrink-0 ${L?``:`mr-2`}`,"aria-label":g?o(`layouts.appLayout.expandSidebar`,`Expand sidebar`):o(`layouts.appLayout.collapseSidebar`,`Collapse sidebar`),title:g?o(`layouts.appLayout.expandSidebar`,`Expand sidebar`):o(`layouts.appLayout.collapseSidebar`,`Collapse sidebar`),children:_(g?ee:ue,{className:`h-4 w-4`})})]}),!L&&l!==null&&_(`div`,{"data-testid":`sidebar-server-name`,title:l.name,className:`truncate border-b border-border px-3 py-1.5 text-xs font-medium text-foreground-muted`,children:l.name}),_(`div`,{className:`border-b border-border pt-2`,children:_(Df,{navSections:I,addonPages:D,compact:L,onNavigated:()=>m(!1)})}),i(`nav`,{className:`flex-1 overflow-y-auto py-3 ${L?`px-1.5`:`px-2`} space-y-0.5`,children:[re.map(e=>fe(e)),le(ie.length+j.length,o(`nav.detectionSection`,`Detection`)),ie.map(e=>fe(e)),j.map(e=>de(e)),le(ae.length+M.length,o(`nav.clusterSection`,`Cluster`)),ae.map(e=>fe(e)),M.map(e=>de(e)),le(oe.length+N.length,o(`system.title`,`Administration`)),oe.map(e=>fe(e)),N.map(e=>de(e)),k.custom.map(e=>i(`div`,{className:`contents`,children:[le(e.pages.length,e.label),e.pages.map(e=>de(e))]},`custom-${e.id}`)),le(k.ungrouped.length,o(`nav.addonPages`,`Addon Pages`)),k.ungrouped.map(e=>de(e))]}),i(`div`,{className:`border-t border-border ${L?`p-1.5`:`p-2`} space-y-0.5`,children:[i(`button`,{onClick:()=>a?.toggleMode(),className:R(!1),title:L?ce[se]:void 0,children:[(()=>{let e=Wp[se];return _(e,{className:`h-3.5 w-3.5 shrink-0`})})(),!L&&_(`span`,{children:ce[se]})]}),_(vp,{variant:`sidebar`,compact:L}),i(`button`,{type:`button`,onClick:()=>t(`/system/my-access`),className:R(F(`/system/my-access`)),title:L?o(`system.myAccess`,`My access`):void 0,children:[_(Ve,{className:`h-3.5 w-3.5 shrink-0`}),!L&&_(`span`,{className:`truncate`,children:o(`system.myAccess`,`My access`)})]}),i(`button`,{onClick:P,className:R(!1).replace(`hover:text-foreground`,`hover:text-danger`),title:L?n?.username??o(`layouts.appLayout.logout`,`Logout`):void 0,children:[_(Tt,{className:`h-3.5 w-3.5 shrink-0`}),!L&&_(`span`,{className:`truncate`,children:n?.username??o(`layouts.appLayout.user`,`User`)})]}),_(zp,{placement:`sidebar`,compact:L})]})]});return i(`div`,{className:`flex h-dvh overflow-hidden bg-background text-foreground pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:[!s&&_(`aside`,{className:`flex flex-col border-r border-border bg-surface/80 backdrop-blur-sm shrink-0 transition-[width] duration-150 ease-out ${L?`w-12`:`w-48`}`,children:he}),s&&_(hn,{open:p,onClose:()=>m(!1),width:`w-64`,children:he}),i(`div`,{className:`flex flex-1 flex-col min-w-0`,children:[f!==null&&i(`div`,{className:`flex items-center justify-center gap-2 px-3 py-2 text-[12px] font-medium shrink-0 ${f.severity===`danger`?`bg-danger/90 text-white`:`bg-warning/15 text-warning border-b border-warning/30`}`,children:[f.severity===`danger`?_(me,{className:`h-3.5 w-3.5`}):_(Re,{className:`h-3.5 w-3.5`}),_(`span`,{children:o(f.i18nKey,{defaultValue:f.message,...f.i18nParams})}),f.action===`sign-in`&&_(`button`,{onClick:()=>r(),className:`ml-2 rounded border border-white/40 px-2 py-0.5 text-[11px] font-semibold hover:bg-white/10`,children:o(`connection.signIn`,`Sign in`)}),f.showSpinner&&_(B,{className:`h-3.5 w-3.5 animate-spin`})]}),_(If,{}),_(Gf,{}),_(bp,{}),s&&i(`header`,{className:`flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm`,children:[_(`button`,{onClick:()=>m(!0),className:`p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors`,"aria-label":o(`layouts.appLayout.openMenu`,`Open menu`),children:_(Se,{className:`h-5 w-5`})}),_(`div`,{className:`flex-1 flex justify-center`,children:_(`img`,{src:a?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:o(`layouts.appLayout.camstack`,`CamStack`),className:`h-7`})}),_(vp,{})]}),i(Jd,{children:[_(Xd,{}),_(`main`,{className:`relative flex-1 min-h-0 overscroll-contain bg-background ${te?`overflow-hidden`:`overflow-auto`}`,children:_(Dd,{resetKey:e.pathname,children:_(h,{fallback:_(Gp,{}),children:_(Up,{})})})})]})]})]})}function $({children:e,requireAdmin:t}){let{t:n}=W(),{user:r,loading:i,mustChangePassword:a}=du(),o=Y();return i?_(`div`,{className:`flex h-screen items-center justify-center bg-background text-foreground-subtle`,children:n(`layouts.protectedRoute.loading`,`Loading...`)}):r?a&&o.pathname!==`/change-password`?_(X,{to:`/change-password`,replace:!0}):t&&!r.isAdmin?_(X,{to:`/access-denied`,replace:!0}):_(A,{children:e}):_(X,{to:`/login`,replace:!0,state:{from:o.pathname+o.search}})}var qp=`customize`,Jp=`/build/compositions/new`,Yp=`/build/compositions/:blockId`,Xp=`/build?tab=custom-device`;function Zp(e){return`/devices/${e}`}function Qp(e){return`/devices/${e}?tab=${qp}`}var $p=`integration`,em=`section`,tm=[$p,em],nm={connectivity:{path:`/system/integrations`,tab:null},remoteAccess:{path:`/system/network`,tab:`remote-access`},mesh:{path:`/system/network`,tab:`mesh`},turn:{path:`/system/network`,tab:`turn`},authentication:{path:`/system/identity`,tab:`authentication`},access:{path:`/system/identity`,tab:`access`},logging:{path:`/system/logs`,tab:`destinations`}},rm=`settings`,im=`activity`;function am(e,t={}){let{path:n,tab:r}=nm[e],i=new URLSearchParams;r===null?t.kindSection!==void 0&&i.set(`tab`,t.kindSection):i.set(`tab`,r),t.integration!==void 0&&i.set($p,t.integration),t.section!==void 0&&i.set(em,t.section);let a=i.toString();return a.length>0?`${n}?${a}`:n}function om(e){let{ids:t,requested:n,answered:r,legacyGroup:i=null,groupFirst:a={}}=e;if(n!==null&&t.includes(n))return{selectedId:n,staleId:null};let o=n!==null&&r?n:null,s=i===null?void 0:a[i];return s!==void 0&&t.includes(s)?{selectedId:s,staleId:o}:{selectedId:t[0]??null,staleId:o}}function sm(e,t,n=null,r=null){let i=new URLSearchParams(e);return i.set($p,t),r===null?i.delete(em):i.set(em,r),n!==null&&i.delete(n),i}function cm(e){return e===`/admin`||e===`/admin/`?`/`:e.startsWith(`/admin/`)?e.slice(6):e}function lm(){let{t:e}=W(),t=ua();return i(`div`,{className:`flex flex-col items-center justify-center text-foreground py-16 px-4`,children:[_(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-2xl bg-danger/10 mb-4`,children:_(wt,{className:`h-8 w-8 text-danger`})}),_(`h1`,{className:`text-xl font-bold`,children:e(`accessDenied.accessDenied`,`Access Denied`)}),_(`p`,{className:`mt-2 text-sm text-foreground-subtle`,children:e(`accessDenied.youDonTHavePermission`,`You don't have permission to access this page.`)}),_(`button`,{onClick:()=>t(`/devices`),className:`mt-6 rounded-lg bg-primary px-5 py-2.5 text-sm font-medium text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all`,children:e(`accessDenied.goToDevices`,`Go to Devices`)})]})}var um=`auth.password-incorrect`;function dm(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function fm(e){if(!(e instanceof Error))return{kind:`connection-lost`};let t=dm(e,`data`);return typeof t!=`object`||!t?{kind:`connection-lost`}:dm(dm(t,`i18n`),`code`)===um?{kind:`wrong-current`}:dm(t,`code`)===`UNAUTHORIZED`?{kind:`session-ended`}:{kind:`rejected`,message:e.message}}w();var pm=8;function mm(e,t){let n=fm(e);switch(n.kind){case`wrong-current`:return t(`changePassword.errorWrongCurrent`,`The current password is incorrect.`);case`session-ended`:return t(`changePassword.errorSessionEnded`,`Your session ended before the change was confirmed. Sign in again — try the new password first.`);case`connection-lost`:return t(`changePassword.errorConnectionLost`,`The connection to the hub dropped before it confirmed the change. Sign in again — try the new password first.`);case`rejected`:return n.message}}function hm(){let{t:e}=W(),{user:t,mustChangePassword:n,clearMustChangePassword:r,logout:a}=du(),o=Oe(),s=mr(),c=ua(),[l,u]=b(``),[d,f]=b(``),[p,m]=b(``),[h,g]=b(!1),[v,y]=b(``),[x,S]=b(!1),C=n?tu:l;return _(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:i(`div`,{className:`w-full max-w-sm`,children:[_(`div`,{className:`flex justify-center mb-8`,children:_(`img`,{src:s?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:e(`changePassword.camstackAdmin`,`CamStack Admin`),className:`h-12`})}),i(`form`,{onSubmit:async i=>{if(i.preventDefault(),y(``),!t){y(`Not signed in`);return}if(!n&&l.length===0){y(e(`changePassword.enterCurrent`,`Enter your current password`));return}if(d.length<pm){y(`Password must be at least ${pm} characters`);return}if(d!==p){y(`The two passwords do not match`);return}if(d===`changeme`){y(`Choose a password different from the seed default`);return}S(!0);try{await o.changeOwnPassword({currentPassword:C,newPassword:d}),r(),c(`/devices`,{replace:!0})}catch(t){y(mm(t,e))}finally{S(!1)}},className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[i(`div`,{className:`space-y-1`,children:[_(`h1`,{className:`text-sm font-semibold text-foreground`,children:e(`changePassword.setANewPassword`,`Set a new password`)}),_(`p`,{className:`text-xs text-foreground-subtle`,children:n?e(`changePassword.youMustRotateTheSeed`,`You must rotate the seed password before continuing.`):e(`changePassword.chooseANewPasswordFor`,`Choose a new password for your account.`)})]}),v&&_(`div`,{role:`alert`,className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:v}),!n&&i(`div`,{className:`space-y-1.5`,children:[_(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.currentPassword`,`Current password`)}),_(`input`,{"data-testid":`change-password-current`,type:h?`text`:`password`,value:l,onChange:e=>u(e.target.value),autoComplete:`current-password`,className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:!0})]}),i(`div`,{className:`space-y-1.5`,children:[_(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.newPassword`,`New password`)}),i(`div`,{className:`relative`,children:[_(`input`,{"data-testid":`change-password-new`,type:h?`text`:`password`,value:d,onChange:e=>f(e.target.value),autoComplete:`new-password`,className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:n}),_(`button`,{type:`button`,onClick:()=>g(!h),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors`,tabIndex:-1,children:_(h?L:ae,{className:`h-4 w-4`})})]})]}),i(`div`,{className:`space-y-1.5`,children:[_(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.confirmNewPassword`,`Confirm new password`)}),_(`input`,{"data-testid":`change-password-confirm`,type:h?`text`:`password`,value:p,onChange:e=>m(e.target.value),autoComplete:`new-password`,className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`})]}),_(`button`,{"data-testid":`change-password-submit`,type:`submit`,disabled:x||!d||!p,className:`w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all`,children:x?e(`changePassword.saving`,`Saving…`):e(`changePassword.saveAndContinue`,`Save and continue`)}),n&&_(`button`,{type:`button`,onClick:()=>{a(),c(`/login`,{replace:!0})},className:`w-full text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:e(`changePassword.signOutInstead`,`Sign out instead`)})]})]})})}function gm(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function _m(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function vm(){return window?.PublicKeyCredential!==void 0&&typeof window.PublicKeyCredential==`function`}function ym(e){let{id:t}=e;return{...e,id:_m(t),transports:e.transports}}function bm(e){return e===`localhost`||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var xm=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),this.name=r??n.name,this.code=t}},Sm=new class{createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},Cm=[`cross-platform`,`platform`];function wm(e){if(e&&!(Cm.indexOf(e)<0))return e}function Tm(){if(!vm())return new Promise(e=>e(!1));let e=window.PublicKeyCredential;return e.isConditionalMediationAvailable===void 0?new Promise(e=>e(!1)):e.isConditionalMediationAvailable()}function Em({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new xm({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new xm({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=window.location.hostname;if(!bm(t))return new xm({message:`${window.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new xm({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new xm({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function Dm(e){let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!vm())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(ym));let a={...t,challenge:_m(t.challenge),allowCredentials:i},o={};if(n){if(!await Tm())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=Sm.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Em({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=gm(u.userHandle)),{id:c,rawId:gm(l),response:{authenticatorData:gm(u.authenticatorData),clientDataJSON:gm(u.clientDataJSON),signature:gm(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:wm(s.authenticatorAttachment)}}function Om(e){return typeof e==`object`&&!!e}function km(e){return Om(e)&&typeof e.challenge==`string`}w();async function Am(e){if(!km(e))throw Error(`passkey authentication options missing challenge`);let t=await Dm({optionsJSON:e});return Object.fromEntries(Object.entries(t))}function jm({method:e,challengeToken:t,onComplete:n,onSecondFactor:r,onError:a}){let[o,s]=b(!1),[c,l]=b(null),u=async()=>{l(null),s(!0);try{let e=Q();if(t){let r=await Am((await e.loginBeginPasskey(t)).optionsJSON),i=await e.loginVerifyPasskey(t,r,{refreshable:!0});n(i.token,i);return}let i=await Am((await e.passkeyLoginBegin()).optionsJSON),o=await e.passkeyLoginFinish(i,{refreshable:!0}),s=o.secondFactors??(o.requiresTotp===!0?[`totp`]:[]);if(s.length>0){if(r)r({challengeToken:o.token,factors:s});else{let e=`Additional verification is required — sign in with your password to continue.`;l(e),a?.(e)}return}n(o.token,o)}catch(e){let n=t?`Passkey verification failed`:`Passkey sign-in failed`,r=e instanceof Error?e.message:n;l(r),a?.(r)}finally{s(!1)}};return i(`div`,{className:`space-y-2`,children:[i(`button`,{type:`button`,"data-testid":t?`login-passkey`:`login-passkey-direct`,onClick:()=>void u(),disabled:o,className:`w-full flex items-center justify-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 text-sm font-medium text-foreground hover:bg-surface-hover disabled:opacity-50 transition-colors`,children:[o?_(B,{className:`h-4 w-4 animate-spin text-primary`}):_(Ct,{className:`h-4 w-4 text-primary`}),e.label]}),c&&_(`div`,{className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:c})]})}var Mm=()=>window.location.hostname;function Nm(e,t=Mm){return vm()&&Af(t(),e.rpId)}function Pm(e,t=Mm){let n=e.filter(e=>e.kind===`passkey`&&e.stage===`second-factor`).filter(e=>Nm(e,t));return{passkeyMethods:n,widgetMethods:n.length>0?[]:e.filter(e=>e.kind===`widget`&&e.stage===`second-factor`)}}function Fm(e,t){let n=e.includes(`passkey`),r=t.passkeyMethods.length>0||t.widgetMethods.length>0,i=e.includes(`totp`);return n&&!r&&!i}function Im(e){let t=e.onComplete,n=e.onSecondFactor;return typeof t==`function`?{onComplete:t,onSecondFactor:typeof n==`function`?n:void 0}:null}function Lm({methods:e,widgetConfig:t,onRedirect:n}){let{t:r}=W();Ot();let a=e.filter(e=>e.kind!==`passkey`||Nm(e));return a.length===0?null:i(`div`,{className:`mt-6 space-y-3`,children:[i(`div`,{className:`flex items-center gap-3`,children:[_(`div`,{className:`h-px flex-1 bg-border`}),_(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:r(`login.primaryLoginMethods.orContinueWith`,`Or continue with`)}),_(`div`,{className:`h-px flex-1 bg-border`})]}),_(`div`,{className:`space-y-2`,children:a.map(e=>{if(e.kind===`redirect`){let t=(e.icon===void 0?void 0:Cn(e.icon))??Ve;return i(`a`,{href:e.startUrl,onClick:t=>{n?.(e)===!0&&t.preventDefault()},className:`flex items-center justify-center gap-2 w-full rounded-lg border border-border bg-surface px-4 py-2.5 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors`,children:[_(t,{className:`h-4 w-4 text-primary`}),e.label]},e.id)}if(e.kind===`passkey`){let n=Im(t);return n?_(jm,{method:e,onComplete:n.onComplete,onSecondFactor:n.onSecondFactor},e.id):null}return _(Rm,{method:e,config:t},e.id)})})]})}function Rm({method:e,config:t}){let{t:n}=W(),r=ln(e.remote,e.bundleUrl);return r===null?i(`div`,{className:`flex items-center justify-center gap-2 rounded-lg border border-border bg-background px-4 py-2.5 text-xs text-foreground-subtle`,children:[_(B,{className:`h-3.5 w-3.5 animate-spin`}),n(`common.loading`,`Loading…`)]}):r===void 0?i(`div`,{"data-testid":`login-method-load-error`,className:`flex items-center justify-center gap-2 rounded-lg border border-danger/20 bg-danger/10 px-4 py-2.5 text-xs text-danger`,children:[_(F,{className:`h-3.5 w-3.5 shrink-0`}),n(`login.primaryMethods.loadFailed`)]}):_(r,{instanceId:e.id,host:`dashboard`,config:t})}var zm=4e3,Bm=/^[A-Za-z0-9._-]{1,64}$/;function Vm(e){let t=e.addonId!==void 0&&Bm.test(e.addonId)?e.addonId:null,n=e.integration!==void 0&&Bm.test(e.integration)?e.integration:null;if(t!==null&&e.brokerId!==void 0)return am(`connectivity`,{integration:t,kindSection:`brokers`});let r=n??t;return am(`connectivity`,r===null?{}:{integration:r})}function Hm(e,t){let n=t.opener;if(n===null||n.closed||Ir(n)!==t.origin)return!1;try{return n.postMessage({type:Xo,ok:e.status===`success`,...e.brokerId===void 0?{}:{brokerId:e.brokerId},...e.status===`error`?{error:e.reason??`unknown`}:{}},t.origin),!0}catch{return!1}}w();var Um=500;function Wm(e){let{t}=W();switch(e){case`access_denied`:return t(`oauthLanding.reason.access_denied`,`Access was denied, so nothing was connected.`);case`invalid_state`:return t(`oauthLanding.reason.invalid_state`,`This sign-in link expired or was already used. Start the sign-in again.`);case`invalid_request`:return t(`oauthLanding.reason.invalid_request`,`The request was not valid for this hub. Start the link again from the beginning.`);case`unknown_broker`:return t(`oauthLanding.reason.unknown_broker`,`That connection no longer exists. Add it again, then sign in.`);case`not_configured`:return t(`oauthLanding.reason.not_configured`,`The connection is missing its client ID or secret. Fill them in, save, then sign in.`);case`exchange_failed`:return t(`oauthLanding.reason.exchange_failed`,`The provider did not accept the sign-in. Check the client ID and secret, then try again.`);case`no_authorization_code`:return t(`oauthLanding.reason.no_authorization_code`,`The provider finished the sign-in without granting CamStack access. Start the sign-in again from the beginning.`);case`no_refresh_token`:return t(`oauthLanding.reason.no_refresh_token`,`The provider returned no long-lived access. Remove CamStack from the account’s connected apps, then sign in again.`);case`unavailable`:return t(`oauthLanding.reason.unavailable`,`The hub is still starting this integration. Wait a moment and try again.`);case`unknown`:return t(`oauthLanding.reason.unknown`,`Something went wrong. Try again in a moment.`)}}function Gm({outcome:e}){let{t}=W(),n=Wm(e.reason??`unknown`);if(e.status===`error`)return i(A,{children:[_(je,{className:`mx-auto h-8 w-8 text-danger`,"aria-hidden":!0}),_(`h1`,{"data-testid":`oauth-landing-title`,className:`text-sm font-semibold text-foreground`,children:t(`oauthLanding.errorTitle`,`Sign-in did not finish`)}),_(`p`,{"data-testid":`oauth-landing-reason`,className:`rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:n})]});let r=e.action===`disconnect`;return i(A,{children:[_(Ye,{className:`mx-auto h-8 w-8 text-success`,"aria-hidden":!0}),_(`h1`,{"data-testid":`oauth-landing-title`,className:`text-sm font-semibold text-foreground`,children:r?t(`oauthLanding.signedOutTitle`,`Signed out`):t(`oauthLanding.successTitle`,`Signed in`)}),_(`p`,{className:`text-xs text-foreground-muted`,children:r?t(`oauthLanding.signedOutBody`,`The account was disconnected from this hub.`):t(`oauthLanding.successBody`,`The account is connected. Returning to CamStack…`)})]})}function Km({outcome:e,closable:t,onContinue:n,onClose:r}){let{t:a}=W(),o=Vm(e);return v(()=>{if(e.status!==`success`)return;let t=window.setTimeout(()=>n(o),zm);return()=>window.clearTimeout(t)},[e.status,n,o]),_(`main`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:i(`div`,{className:`w-full max-w-sm space-y-4`,children:[_(`div`,{className:`flex justify-center`,children:i(`picture`,{children:[_(`source`,{media:`(prefers-color-scheme: dark)`,srcSet:z(`/brand/logo-horizontal-dark.svg`)}),_(`img`,{src:z(`/brand/logo-horizontal-light.svg`),alt:a(`oauthLanding.brand`,`CamStack`),className:`h-12`})]})}),i(`div`,{className:`space-y-4 rounded-xl border border-border bg-surface p-6 text-center shadow-xl shadow-black/10`,children:[_(Gm,{outcome:e}),i(`div`,{className:`flex flex-col gap-2`,children:[_(H,{type:`button`,variant:`primary`,onClick:()=>n(o),children:a(`oauthLanding.back`,`Back to CamStack`)}),t&&_(H,{type:`button`,variant:`ghost`,onClick:r,children:a(`oauthLanding.close`,`Close this window`)})]})]})]})})}function qm(e,t){window.history.replaceState(null,``,window.location.pathname);let n=window.opener,r=Hm(t,{opener:n,origin:window.location.origin}),i=()=>e.render(_(Km,{outcome:t,closable:r,onContinue:e=>window.location.replace(z(e)),onClose:()=>window.close()}));if(r&&t.status===`success`){window.close(),window.setTimeout(i,Um);return}i()}function Jm(e){return ct(e)}var Ym=`Done — you can close this window.`,Xm=500,Zm=`camstack_admin_token`;async function Qm(e,t=``){try{let n=bl(new URLSearchParams(t));n!==null&&n.token===e?vl(n):localStorage.setItem(Zm,e)}catch{}await fetch(z(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}function $m(){try{let e=localStorage.getItem(Zm);return e!==null&&e.length>0?e:null}catch{return null}}function eh(e){let t=Jm(window.location.hash);if(t!==null){qm(e,t);return}let n=jr(window.location.hash);window.history.replaceState(null,``,window.location.pathname);let r=t=>e.render(_(th,{completion:n,result:t}));if(r(null),n===null)return;let i=Lr();zr(n,{opener:window.opener,origin:window.location.origin,channel:i,addEventListener:(e,t)=>window.addEventListener(e,t),removeEventListener:(e,t)=>window.removeEventListener(e,t),close:()=>{window.close(),window.setTimeout(()=>r({kind:`done`,message:Ym}),Xm)},continueAt:e=>window.location.replace(z(e)),persistSession:e=>Qm(e,n.target===`login`?n.fragment:``),showResult:r,setTimeout:(e,t)=>window.setTimeout(e,t)})}function th({completion:e,result:t}){let{t:n}=W();return _(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:_(`div`,{className:`flex flex-col items-center gap-3 text-sm text-foreground-subtle`,children:e===null?_(`a`,{className:`text-primary underline`,href:z(`/login`),children:n(`ssoComplete.nothingToFinishHereGo`,`Nothing to finish here — go to sign-in`)}):t===null?i(`span`,{className:`flex items-center gap-3`,children:[_(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),n(`ssoComplete.finishingSignIn`,`Finishing sign-in…`)]}):i(A,{children:[_(`span`,{"data-testid":`sso-complete-result`,className:t.kind===`link-error`?`text-danger`:`text-foreground`,children:t.message}),_(`button`,{type:`button`,className:`rounded-md border border-border px-3 py-1.5 text-foreground hover:bg-surface-hover`,onClick:()=>window.close(),children:n(`ssoComplete.closeThisWindow`,`Close this window`)})]})})})}w();function nh(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`message`),n=Reflect.get(e,`data`);return(typeof n==`object`&&n?Reflect.get(n,`code`):void 0)===`FORBIDDEN`||typeof t==`string`&&/sign in again first/i.test(t)}function rh(){let e=new URLSearchParams(window.location.search);return Fl({codeChallenge:e.get(`code_challenge`),codeChallengeMethod:e.get(`code_challenge_method`),state:e.get(`state`),purpose:e.get(`purpose`)})}function ih(e){return Math.min(1e3*2**e,15e3)}function ah(){let{t:e}=W(),{login:t,verifyTotp:n,finalizePasskeyLogin:r,user:a}=du(),{i18n:o}=W(),s=mr(),c=ua(),l=Y(),d=new URLSearchParams(window.location.search).get(`next`);v(()=>{Wl(d)},[d]);let f=new URLSearchParams(window.location.search).get(`redirect`);v(()=>{$l(f)},[f]);let p=rh();v(()=>{Rl(p)},[p?.codeChallenge,p?.state,p?.purpose]);let m=l.state,h=Mp(m?.from),[g,y]=b(``),[x,S]=b(``),[C,w]=b(!1),[T,E]=b(``),[D,O]=b(!1),[k,j]=b(`credentials`),[M,N]=b(``),[P,F]=b([]),[ee,te]=b(``),[ne,I]=b(void 0),[re,ie]=b(`sso-not-linked`),oe=pr.auth.listLoginMethods.useQuery(void 0,{retry:!0,retryDelay:ih}),se=oe.data===void 0,ce=(oe.data??[]).filter(e=>e.kind!==`device-certificate`),R=pr.auth.getServerName.useQuery().data,le=ce.filter(e=>e.stage===`primary`),ue=Pm(ce);v(()=>{let e=Br(window.location.hash);if(e!==null){if(window.history.replaceState({},``,window.location.pathname+window.location.search),e.kind===`challenge`){N(e.challengeToken),F(e.factors),te(``),j(`second-factor`);return}ie(e.code),I(e.provider)}},[]);let de=ne==null?null:ce.find(e=>e.id===ne&&`label`in e)?.label??null,fe=T||(ne===void 0?``:Nr(re,de)),{passkeyMethods:pe,widgetMethods:me}=ue,he=u(!1),ge=async()=>{if(he.current)return;he.current=!0;let e=Vl(f);if(e?.kind===`app-callback`){await ye(e.url);return}else if(e){window.location.assign(z(e.path));return}let t=Kl(d);t?window.location.assign(z(t)):c(h,{replace:!0})},[_e,ve]=b(null),ye=async e=>{ve({callbackBase:e,mintedUrl:null,failed:!1});try{let t=rh()??zl();if(t===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await Q().trpcClient.auth.createHandoffCode.mutate({purpose:t.purpose,codeChallenge:t.codeChallenge,state:t.state}),r=Bl(e,n,t.state);ve({callbackBase:e,mintedUrl:r,failed:!1}),window.location.assign(r)}catch(t){if(nh(t)){he.current=!1,ve(null),E(`Sign in again to confirm it is you.`);return}ve({callbackBase:e,mintedUrl:null,failed:!0})}},be=a!==null,[Se,Ce]=b(!1);v(()=>{!be||!f&&!d||Se||(Ce(!0),ge())},[be,f,d,Se]);let we=async e=>{e.preventDefault(),E(``),I(void 0),O(!0);try{let e=await t(g,x);if(e.kind===`second-factor`){N(e.challengeToken),F(e.factors),j(`second-factor`);return}x===`changeme`?c(`/change-password`,{replace:!0}):await ge()}catch(e){E(e instanceof Error?e.message:`Login failed`)}finally{O(!1)}},Te=async e=>{e.preventDefault(),E(``),O(!0);try{await n(M,ee.trim()),await ge()}catch(e){E(e instanceof Error?e.message:`TOTP verification failed`),te(``)}finally{O(!1)}},Ee=async(e,t)=>{try{await r(e,t),await ge()}catch(e){E(e instanceof Error?e.message:`Passkey sign-in failed`)}},De=u(null);v(()=>()=>De.current?.(),[]);let Oe=async e=>{if(e.target!==`login`)return;let t=bl(new URLSearchParams(e.fragment));if(t!==null){try{await r(t.token,t),await ge()}catch(e){E(e instanceof Error?e.message:`Sign-in failed`)}return}let n=Br(`#${e.fragment}`);if(n!==null){if(n.kind===`challenge`){Ae({challengeToken:n.challengeToken,factors:n.factors});return}ie(n.code),I(n.provider)}},ke=e=>{if(Ml(f)?.kind===`app-callback`)return!1;let t=Pr(z(Mr(e.startUrl)));return t===null?!1:(E(``),I(void 0),De.current?.(),De.current=Rr(t,{onReturn:e=>{De.current?.(),De.current=null,Oe(e)},onDone:e=>{if(De.current?.(),De.current=null,e.target!==`login`)return;let t=$m()===null?null:_l();t!==null&&Oe({target:`login`,fragment:new URLSearchParams({token:t.token,...t.refreshToken===void 0?{}:{refreshToken:t.refreshToken},...t.expiresAt===void 0?{}:{expiresAt:String(t.expiresAt)}}).toString()})}}),!0)},Ae=e=>{let t=e.factors.filter(e=>e===`totp`||e===`passkey`);N(e.challengeToken),F(t),te(``),E(``),j(`second-factor`)};return _e===null?_(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:i(`div`,{className:`w-full max-w-sm`,children:[_(`div`,{className:`flex justify-center mb-8`,children:_(`img`,{src:s?.resolvedMode===`light`?z(`/brand/logo-horizontal-light.svg`):z(`/brand/logo-horizontal-dark.svg`),alt:e(`login.camstackAdmin`,`CamStack Admin`),className:`h-12`})}),R!==void 0&&!R.isDefault&&_(`p`,{"data-testid":`login-server-name`,className:`-mt-4 mb-6 text-center text-sm text-foreground-muted`,children:_(kr,{i18nKey:`login.signInTo`,values:{name:R.name},components:{b:_(`span`,{className:`font-semibold text-foreground`})}})}),k===`credentials`?i(`form`,{onSubmit:we,className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[fe&&_(`div`,{"data-testid":`login-error`,className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:fe}),i(`div`,{className:`space-y-1.5`,children:[_(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.username`,`Username`)}),_(`input`,{"data-testid":`login-username`,type:`text`,placeholder:e(`login.username`,`Username`),value:g,onChange:e=>y(e.target.value),className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:!0})]}),i(`div`,{className:`space-y-1.5`,children:[_(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.password`,`Password`)}),i(`div`,{className:`relative`,children:[_(`input`,{"data-testid":`login-password`,type:C?`text`:`password`,placeholder:e(`login.password`,`Password`),value:x,onChange:e=>S(e.target.value),className:`w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`}),_(`button`,{type:`button`,onClick:()=>w(!C),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors`,tabIndex:-1,children:_(C?L:ae,{className:`h-4 w-4`})})]})]}),_(`button`,{"data-testid":`login-submit`,type:`submit`,disabled:D||!g||!x,className:`w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all`,children:D?i(`span`,{className:`flex items-center justify-center gap-2`,children:[_(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground/30 border-t-primary-foreground`}),e(`login.loggingIn`,`Logging in...`)]}):e(`login.logIn`,`Log in`)})]}):i(`div`,{className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[i(`div`,{className:`flex items-center gap-2 pb-1 border-b border-border`,children:[_(xe,{className:`h-4 w-4 text-primary`}),_(`div`,{className:`text-sm font-medium text-foreground`,children:e(`login.twoFactorAuthentication`,`Two-factor authentication`)})]}),_(`p`,{className:`text-xs text-foreground-subtle`,children:g?_(A,{children:_(kr,{i18nKey:`login.finishSigningInAs`,values:{username:g},components:{mono:_(`span`,{className:`font-mono text-foreground`})}})}):e(`login.finishSigningInAs`,`Finish signing in.`)}),T&&_(`div`,{className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:T}),P.includes(`passkey`)&&pe.map(e=>_(jm,{method:e,challengeToken:M,onComplete:Ee},e.id)),P.includes(`passkey`)&&me.map(e=>_(Rm,{method:e,config:{challengeToken:M,onComplete:Ee}},e.id)),Fm(P,ue)&&_(`div`,{className:`rounded-md border border-border bg-background px-3 py-2 text-xs text-foreground-subtle`,children:e(`login.passkeyVerificationIsnTAvailable`,`Passkey verification isn't available on this address. Open the hub via its domain URL to complete sign-in.`)}),P.includes(`passkey`)&&P.includes(`totp`)&&i(`div`,{className:`flex items-center gap-3`,children:[_(`div`,{className:`h-px flex-1 bg-border`}),_(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`or`}),_(`div`,{className:`h-px flex-1 bg-border`})]}),P.includes(`totp`)&&i(`form`,{onSubmit:Te,className:`space-y-4`,children:[i(`div`,{className:`space-y-1.5`,children:[_(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.authenticationCode`,`Authentication code`)}),_(`input`,{"data-testid":`login-totp`,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:ee,onChange:e=>te(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-lg border border-border bg-background px-3 py-3 text-center text-2xl font-mono tracking-widest text-foreground placeholder:text-foreground-disabled focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none transition-all`,autoFocus:!0})]}),_(`button`,{"data-testid":`login-totp-submit`,type:`submit`,disabled:D||ee.length!==6,className:`w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30 disabled:opacity-50 disabled:shadow-none transition-all`,children:D?i(`span`,{className:`flex items-center justify-center gap-2`,children:[_(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary-foreground/30 border-t-primary-foreground`}),e(`login.verifying`,`Verifying...`)]}):e(`login.verifyAndSignIn`,`Verify and sign in`)})]}),i(`button`,{type:`button`,onClick:()=>{j(`credentials`),N(``),F([]),te(``),E(``)},className:`w-full flex items-center justify-center gap-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:[_(Ne,{className:`h-3 w-3`}),e(`login.backToUsernamePassword`,`Back to username + password`)]})]}),k===`credentials`&&se&&i(`p`,{"data-testid":`login-methods-pending`,role:`status`,className:`mt-4 flex items-center justify-center gap-2 text-xs text-foreground-subtle`,children:[_(`span`,{className:`h-3 w-3 animate-spin rounded-full border-2 border-foreground-subtle/30 border-t-foreground-subtle`}),e(`login.methodsPending`,`Loading other sign-in options...`)]}),k===`credentials`&&_(Lm,{methods:le,widgetConfig:{onComplete:Ee,onSecondFactor:Ae,locale:o.language},onRedirect:ke}),_(`p`,{className:`mt-6 text-center text-[10px] text-foreground-subtle/50`,children:_(zp,{placement:`login`})})]})}):_(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:i(`div`,{className:`w-full max-w-sm rounded-xl border border-border bg-surface p-6 text-center space-y-4`,children:[_(`h1`,{className:`text-sm font-semibold text-foreground`,children:e(`login.returningToTheApp`,`Returning to the app…`)}),_e.failed?i(A,{children:[_(`p`,{className:`text-xs text-danger`,children:e(`login.couldNotPrepareTheSign`,`Could not prepare the sign-in handoff. You are logged in — retry below.`)}),_(`button`,{onClick:()=>void ye(_e.callbackBase),className:`inline-flex rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90`,children:e(`common.retry`,`Retry`)})]}):_e.mintedUrl===null?_(`p`,{className:`text-xs text-foreground-subtle`,children:e(`login.preparingAOneTimeSign`,`Preparing a one-time sign-in code…`)}):i(A,{children:[_(`p`,{className:`text-xs text-foreground-subtle`,children:e(`login.ifTheAppDoesNot`,`If the app does not open automatically, tap below (the code expires in 60s).`)}),_(`a`,{href:_e.mintedUrl,className:`inline-flex rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90`,children:e(`login.openCamstack`,`Open CamStack`)})]})]})})}w();function oh(){let{pathname:e,search:t,hash:n}=Y();return _(X,{to:`${cm(e)}${t}${n}`,replace:!0})}function sh(){return _(X,{to:Ap()??`/devices`,replace:!0})}var ch=p(()=>n(()=>import(`./Devices-BBsDc0QJ.js`).then(e=>({default:e.DevicesPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url)),lh=p(()=>n(()=>import(`./Integrations-B7okjAJ8.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([9,1,2,3,4,10,5,11,6,12,13,14,7,8,15]),import.meta.url)),uh=p(()=>n(()=>import(`./IntegrationDetail-CYhU0hEL.js`).then(e=>({default:e.IntegrationDetailPage})),__vite__mapDeps([16,1,2,3,4,17,10,5,18,19,13,14,12,7,20,21]),import.meta.url)),dh=p(()=>n(()=>import(`./Pipeline-BT9k34b_.js`).then(e=>({default:e.PipelinePage})),__vite__mapDeps([22,1,2,3,4,17,10,5,23,24,25,26,19,13,14,27,28,8]),import.meta.url)),fh=p(()=>n(()=>import(`./DeviceDetail-BE-C2aGY.js`).then(e=>({default:e.DeviceDetailPage})),__vite__mapDeps([29,1,2,3,4,17,10,5,30,31,32,33,34,23,35,36,26,37,38,39,40,41,42,43,44,14,45,46,47,27,8,48,21]),import.meta.url)),ph=p(()=>n(()=>import(`./Showroom-Crq5JUKV.js`).then(e=>({default:e.ShowroomPage})),__vite__mapDeps([49,1,2,3,4,13,5,14,10]),import.meta.url)),mh=p(()=>n(()=>import(`./EmbedPlayerPage-D0lVyXps.js`).then(e=>({default:e.EmbedPlayerPage})),__vite__mapDeps([50,1,2,3,4,5]),import.meta.url)),hh=p(()=>n(()=>import(`./Library-BHn4Iifg.js`).then(e=>({default:e.LibraryPage})),__vite__mapDeps([51,1,2,3,4,17,10,5,52,23,25,53,54,45,55,48,21]),import.meta.url)),gh=p(()=>n(()=>import(`./Recordings-Dl-l1Vzi.js`).then(e=>({default:e.RecordingsPage})),__vite__mapDeps([56,1,2,3,4,17,10,5,57,54,58,30,59,13,14,60,48,21]),import.meta.url)),_h=p(()=>n(()=>import(`./Viewer-BTxcZ-BR.js`).then(e=>({default:e.ViewerPage})),__vite__mapDeps([61,2,3,4,62,5,21,1]),import.meta.url)),vh=p(()=>n(()=>import(`./Build-DTcg9gkb.js`).then(e=>({default:e.BuildPage})),__vite__mapDeps([63,1,2,3,4,17,10,5,34,23,64,54,39,33,40,41,42,43,44,14,47,13]),import.meta.url)),yh=p(()=>n(()=>import(`./CompositionEditorPage-D09wEj7N.js`).then(e=>({default:e.CompositionEditorPage})),__vite__mapDeps([65,1,2,3,4,34,5,6,39,17,10,33,23,40,41,42]),import.meta.url)),bh=p(()=>n(()=>import(`./Locations-BVaRTbq0.js`).then(e=>({default:e.LocationsPage})),__vite__mapDeps([66,1,2,3,4,10,5,34,67,53,54,46,41,42]),import.meta.url)),xh=p(()=>n(()=>import(`./Addons-DRU_qk60.js`).then(e=>({default:e.AddonsPage})),__vite__mapDeps([68,1,2,3,4,17,10,5,23,6,19,13,14,69,15,21]),import.meta.url)),Sh=p(()=>n(()=>import(`./AiProfiles-BJrqkjtX.js`).then(e=>({default:e.AiProfilesPage})),__vite__mapDeps([70,1,2,3,4,10,5,71,72,6,54,21]),import.meta.url)),Ch=p(()=>n(()=>import(`./MyAccess-YiGVb3gF.js`).then(e=>({default:e.MyAccessPage})),__vite__mapDeps([73,1,2,3,4,17,10,5,23,74,75,76,77,6,54,78,21,79]),import.meta.url)),wh=p(()=>n(()=>import(`./Logs-DI7IZGug.js`).then(e=>({default:e.LogsPage})),__vite__mapDeps([80,1,2,3,4,81,26,5,6,54,82,17,10,83,19,13,14,84,20,21,85]),import.meta.url)),Th=p(()=>n(()=>import(`./Identity-DNIHuEKY.js`).then(e=>({default:e.IdentityPage})),__vite__mapDeps([86,1,2,3,4,17,10,5,87,23,36,74,75,77,6,54,82,83,19,13,14,84,20,21,78,85]),import.meta.url)),Eh=p(()=>n(()=>import(`./Network-ZYEqAiF5.js`).then(e=>({default:e.NetworkPage})),__vite__mapDeps([88,1,2,3,4,10,5,34,23,6,54,82,17,83,19,13,14,84,20,21,85]),import.meta.url)),Dh=p(()=>n(()=>import(`./Integrations-9bupF3uw.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([89,1,2,3,4,10,5,23,75,90,54,82,17,83,6,19,13,14,84,20,21]),import.meta.url)),Oh=p(()=>n(()=>import(`./Data-D4Sz8Rl9.js`).then(e=>({default:e.DataPage})),__vite__mapDeps([91,1,2,3,4,17,10,5,92,35,59,6,54,58,30,13,14,60,48,21]),import.meta.url)),kh=p(()=>n(()=>import(`./System-CfurcyNZ.js`).then(e=>({default:e.SystemPage})),__vite__mapDeps([93,1,2,3,4,17,10,5,23,74,6,54,19,13,14,84,20,21]),import.meta.url)),Ah=p(()=>n(()=>import(`./Cluster-aj2_8TZC.js`).then(e=>({default:e.ClusterPage})),__vite__mapDeps([94,1,2,3,4,10,5,59,95,77,6,47,19,13,14,28,69,17,60]),import.meta.url)),jh=p(()=>n(()=>import(`./Terminal-UyKanKPS.js`).then(e=>({default:e.TerminalPage})),__vite__mapDeps([96,1,2,3,4,23,5,6,19,13,14,10,97]),import.meta.url)),Mh=p(()=>n(()=>import(`./Notifications-DrVDMEuK.js`).then(e=>({default:e.NotificationsPage})),__vite__mapDeps([98,1,2,3,4,17,10,5,32,23,71,99,6,54,44,40,14,47,55,21,42]),import.meta.url)),Nh=p(()=>n(()=>import(`./History-TMZn0v_I.js`).then(e=>({default:e.HistoryPage})),__vite__mapDeps([100,1,2,3,4,5,6]),import.meta.url)),Ph=p(()=>n(()=>import(`./Calendars-x_EpS-cd.js`).then(e=>({default:e.CalendarsPage})),__vite__mapDeps([101,1,2,3,4,17,10,5,23,6]),import.meta.url)),Fh=p(()=>n(()=>import(`./Templates-D0V7IdcS.js`).then(e=>({default:e.TemplatesPage})),__vite__mapDeps([102,1,2,3,4,23,103,77,5,37,38,6]),import.meta.url)),Ih=new C({defaultOptions:{queries:{gcTime:0,staleTime:0,retry:!1,refetchOnWindowFocus:!1}}});Jn(Ih);function Lh({field:e,value:t,onChange:n,disabled:r}){return _(Zu,{field:e,value:t,onChange:n,disabled:r})}var Rh={"model-selector":Lh};function zh({children:e}){let{t}=W(),{user:n,logout:r}=du(),[a,o]=b(0),s=u(n?.username??null);v(()=>{let e=n?.username??null;e!==s.current&&(s.current=e,dl(),o(e=>e+1))},[n]);let c=d(()=>Q(),[a]),l=g(()=>{Q().reconnect(),o(e=>e+1),Ih.invalidateQueries()},[]);Cd(g(()=>kl(l),[l])),v(()=>Tl(()=>{Q().isSocketTokenStale()&&l()}),[l]);let f=g(async()=>{let e=await Al();return e&&l(),e},[l]),{bootReady:p,bootError:m}=xd(c,n??null,r,f);return _(vd,{children:_(ze,{system:c,children:_(pr.Provider,{client:c.trpcClient,queryClient:Ih,children:i(wn,{children:[_(gn,{children:_(Gn,{children:_(Jt,{children:p?e:_(Bh,{})})})}),p&&_(rd,{}),m!==null&&p&&i(`div`,{className:`fixed bottom-[calc(env(safe-area-inset-bottom)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 max-w-sm rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning shadow-lg`,children:[t(`app.bootProbeFailed`,`Boot probe failed:`),` `,m,`. Retrying in background.`]})]})})})})}function Bh(){let{t:e}=W();return _(`div`,{className:`flex min-h-screen items-center justify-center bg-background`,children:i(`div`,{className:`flex items-center gap-3 text-sm text-foreground-subtle`,children:[_(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),e(`app.connecting`,`Connecting…`)]})})}function Vh(){return _(`div`,{className:`flex min-h-screen items-center justify-center bg-background`,children:_(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`})})}function Hh(){return _(Nn,{defaultMode:`dark`,children:_(_n,{children:_(k,{client:Ih,children:_(uu,{children:_(zh,{children:_(Fe,{children:_(nd,{children:_(On,{renderers:Rh,children:i(Tn,{picker:oc,children:[_(ko,{basename:Ge(),children:_(Gu,{children:_(h,{fallback:_(Vh,{}),children:i(za,{children:[_(Z,{path:`/login`,element:_(ah,{})}),_(Z,{path:`/admin/*`,element:_(oh,{})}),_(Z,{path:`/admin`,element:_(oh,{})}),_(Z,{path:`/change-password`,element:_($,{children:_(hm,{})})}),_(Z,{path:`/showroom`,element:_(ph,{})}),_(Z,{path:`/embed/player`,element:_(mh,{})}),i(Z,{element:_($,{children:_(Hr,{children:_(Kp,{})})}),children:[_(Z,{index:!0,element:_(sh,{})}),_(Z,{path:`/access-denied`,element:_(lm,{})}),_(Z,{path:`/dashboard`,element:_(X,{to:`/devices`,replace:!0})}),_(Z,{path:`/devices`,element:_(ch,{})}),_(Z,{path:`/cameras`,element:_(X,{to:`/devices`,replace:!0})}),_(Z,{path:`/integrations`,element:_(lh,{})}),_(Z,{path:`/integrations/:addonId`,element:_(uh,{})}),_(Z,{path:`/system/pipeline`,element:_(Gd,{path:`/system/pipeline`,children:_(dh,{})})}),_(Z,{path:`/pipeline`,element:_(X,{to:`/system/pipeline`,replace:!0})}),_(Z,{path:`/live`,element:_(_h,{})}),_(Z,{path:`/devices/:deviceId`,element:_(fh,{})}),_(Z,{path:`/system/logs`,element:_($,{requireAdmin:!0,children:_(wh,{})})}),_(Z,{path:`/system/addons`,element:_($,{requireAdmin:!0,children:_(xh,{})})}),_(Z,{path:`/system/ai`,element:_($,{requireAdmin:!0,children:_(Sh,{})})}),_(Z,{path:`/system/settings`,element:_($,{requireAdmin:!0,children:_(kh,{})})}),_(Z,{path:`/system/nodes`,element:_($,{requireAdmin:!0,children:_(Ah,{})})}),_(Z,{path:`/system/notifications`,element:_($,{requireAdmin:!0,children:_(Mh,{})})}),_(Z,{path:`/system/history`,element:_($,{requireAdmin:!0,children:_(Nh,{})})}),_(Z,{path:`/system/calendars`,element:_($,{requireAdmin:!0,children:_(Ph,{})})}),_(Z,{path:`/system/templates`,element:_($,{requireAdmin:!0,children:_(Fh,{})})}),_(Z,{path:`/system/identity`,element:_($,{requireAdmin:!0,children:_(Th,{})})}),_(Z,{path:`/system/my-access`,element:_(Ch,{})}),_(Z,{path:`/system/network`,element:_($,{requireAdmin:!0,children:_(Eh,{})})}),_(Z,{path:`/system/integrations`,element:_($,{requireAdmin:!0,children:_(Dh,{})})}),_(Z,{path:`/system/data`,element:_($,{requireAdmin:!0,children:_(Oh,{})})}),_(Z,{path:`/system`,element:_(X,{to:od,replace:!0})}),_(Z,{path:`/system/terminal`,element:_($,{requireAdmin:!0,children:_(jh,{})})}),sd.map(e=>_(Z,{path:e.path,element:_(ld,{tab:e.tab})},e.path)),_(Z,{path:`/system/users`,element:_(X,{to:`/system/identity?tab=users`,replace:!0})}),_(Z,{path:`/system/api-keys`,element:_(X,{to:`/system/identity?tab=api-keys`,replace:!0})}),_(Z,{path:`/system/authentication`,element:_(X,{to:am(`authentication`),replace:!0})}),_(Z,{path:`/system/linked-sessions`,element:_(X,{to:`/system/identity?tab=linked-sessions`,replace:!0})}),_(Z,{path:`/system/remote-access`,element:_(X,{to:am(`remoteAccess`),replace:!0})}),_(Z,{path:`/system/turn`,element:_(X,{to:am(`turn`),replace:!0})}),_(Z,{path:`/system/storage`,element:_(X,{to:`/system/data?tab=storage`,replace:!0})}),_(Z,{path:`/system/backup`,element:_(X,{to:`/system/data?tab=backup`,replace:!0})}),_(Z,{path:`/library`,element:_($,{requireAdmin:!0,children:_(hh,{})})}),_(Z,{path:`/retrain`,element:_(X,{to:`/addon/training`,replace:!0})}),_(Z,{path:`/recordings`,element:_($,{requireAdmin:!0,children:_(gh,{})})}),_(Z,{path:`/build`,element:_($,{requireAdmin:!0,children:_(vh,{})})}),_(Z,{path:Jp,element:_($,{requireAdmin:!0,children:_(yh,{})})}),_(Z,{path:Yp,element:_($,{requireAdmin:!0,children:_(yh,{})})}),_(Z,{path:`/locations`,element:_($,{requireAdmin:!0,children:_(bh,{})})}),_(Z,{path:`/automation`,element:_(Qu,{to:`/build`})}),_(Z,{path:`/addon/:pagePath`,element:_($,{requireAdmin:!0,children:_(Ld,{})})}),_(Z,{path:`*`,element:_(X,{to:`/devices`,replace:!0})})]})]})})})}),_(hd,{})]})})})})})})})})})}w(),window.__camstackUiLibrary=$n,window.__camstackSdk=Rn,window.__camstackTypes=ut;var Uh=Or(document.getElementById(`root`));Fr(window.location.pathname,Ge())?eh(Uh):Uh.render(_(x,{children:_(Hh,{})}));export{ma as $,xu as A,bc as B,od as C,Tu as D,Du as E,Wc as F,nc as G,vc as H,Uc as I,ns as J,Us as K,kc as L,mu as M,pu as N,vu as O,du as P,ua as Q,xc as R,dd as S,Uu as T,fc as U,yc as V,oc as W,X,jo as Y,Y as Z,gf as _,nm as a,Ud as b,rm as c,sm as d,zo as et,Xp as f,Rf as g,Zp as h,tm as i,hu as j,yu as k,am as l,Qp as m,Dm as n,$p as o,qp as p,qs as q,im as r,em as s,km as t,om as u,vf as v,td as w,_d as x,_f as y,wc as z};