@camstack/addon-admin-ui 1.2.698 → 1.2.700
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/assets/AccessSection-DuhBff2I.js +1 -0
- package/dist/assets/Addons-DkWR3gkq.js +5 -0
- package/dist/assets/{AdminPage-C0rgqBg5.js → AdminPage-CyMuobXy.js} +1 -1
- package/dist/assets/{AdminSectionedPage-CrbDQuju.js → AdminSectionedPage-DiyrPcy9.js} +1 -1
- package/dist/assets/AiProfiles-DUZci2sf.js +3 -0
- package/dist/assets/Archive-BumU9DOS.js +1 -0
- package/dist/assets/{BootstrapSettingsForm-CNwsceSk.js → BootstrapSettingsForm-CEkpZiEK.js} +1 -1
- package/dist/assets/Build-B0Su_s2L.js +40 -0
- package/dist/assets/{Calendars-fZrHEH0S.js → Calendars-DsRFyTPC.js} +1 -1
- package/dist/assets/Cluster-D2qSEqhz.js +1 -0
- package/dist/assets/CompositionBlockEditor-BKG-rKjJ.js +2 -0
- package/dist/assets/CompositionEditorPage-8y0k5Nhe.js +1 -0
- package/dist/assets/Data-D9LaQOXD.js +2 -0
- package/dist/assets/DeviceDetail-BxDpw3WU.js +1 -0
- package/dist/assets/{Devices-C2_XrAsB.js → Devices-CDjecVeO.js} +1 -1
- package/dist/assets/{EmbedDevicePage-B-kXRzxP.js → EmbedDevicePage-BD6_HvMe.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BKlnHqN7.js → EmbedPlayerPage-Bf0oo9Q3.js} +1 -1
- package/dist/assets/{History-C8ZY-Ovj.js → History-CRvVI3U1.js} +1 -1
- package/dist/assets/Identity-CgqjNQVX.js +1 -0
- package/dist/assets/InstancesTable-DcwQ5Z2U.js +1 -0
- package/dist/assets/IntegrationDetail-CTL_BNd5.js +1 -0
- package/dist/assets/Integrations-BWIZL8DT.js +1 -0
- package/dist/assets/{Integrations-w_KbkNum.js → Integrations-DjE3kD95.js} +2 -2
- package/dist/assets/Library-CnuFtxG7.js +1 -0
- package/dist/assets/Locations-C5O5CcZV.js +3 -0
- package/dist/assets/Logs-BPEaFkcQ.js +1 -0
- package/dist/assets/{MaskShapeCanvas-Crc7Vee0.js → MaskShapeCanvas-BwjxoZHj.js} +1 -1
- package/dist/assets/{MotionZonesSettings-CPRbUvmE.js → MotionZonesSettings-CgruOSjK.js} +1 -1
- package/dist/assets/{MyAccess-CvFEb2P_.js → MyAccess-DenZQPxt.js} +1 -1
- package/dist/assets/{Network-BApaJTDv.js → Network-DWGrdbU2.js} +1 -1
- package/dist/assets/{NewExportModal-B87f6wft.js → NewExportModal-Dn5qIfYF.js} +1 -1
- package/dist/assets/NodeAddonsSettingsPanel-C1h8YgnE.js +1 -0
- package/dist/assets/Notifications-RetD-vo3.js +1 -0
- package/dist/assets/{PanelContent-D7u-ISFK.js → PanelContent-CWdEuPnB.js} +2 -2
- package/dist/assets/Pipeline-g9OrBU5t.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-B1fiafV8.js → PrivacyMaskSettings-B6WFh3P4.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-D7pxuNnv.js → SceneMonitorEditor-M-wzPHRE.js} +1 -1
- package/dist/assets/{SessionsList-D6U14Yno.js → SessionsList-PpGdvCRu.js} +2 -2
- package/dist/assets/{Showroom-DU9iMIZh.js → Showroom-DSutXWcf.js} +1 -1
- package/dist/assets/StorageLocationsTable-eT6j45e1.js +1 -0
- package/dist/assets/{System-1Jh6VozL.js → System-BbVT7aZV.js} +2 -2
- package/dist/assets/TemplateEditorDialog-CkVm64ab.js +1 -0
- package/dist/assets/{Terminal-DyWFdRWL.js → Terminal-jh3VZwwP.js} +5 -5
- package/dist/assets/{TrainingProviders-BG7DsUoT.js → TrainingProviders-B0MPb6es.js} +1 -1
- package/dist/assets/{Viewer-Cu1fVuMh.js → Viewer-Fo86cc0-.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Y8Q6lecu.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-rBseLAXs.js} +1 -1
- package/dist/assets/{action-draft-D0S-LJcp.js → action-draft-BIhSMudC.js} +1 -1
- package/dist/assets/{ai-page.helpers-DJ4SE1RA.js → ai-page.helpers-BfJpXMnt.js} +1 -1
- package/dist/assets/{assignment-candidates-FntpKIEo.js → assignment-candidates-tNcnUZOo.js} +1 -1
- package/dist/assets/{authed-media-CkCP7Cpu.js → authed-media-Dmn6VKYc.js} +1 -1
- package/dist/assets/{board-model-CV7df4sG.js → board-model-CyseSL_y.js} +1 -1
- package/dist/assets/{camera-block-model-DoWj--hc.js → camera-block-model-BKFq-3HR.js} +1 -1
- package/dist/assets/client-DQzHwaNb.js +1122 -0
- package/dist/assets/{command-vocab-B1KZgOMw.js → command-vocab-CeQ0ypHW.js} +1 -1
- package/dist/assets/{device-detail-QaaayAym.js → device-detail-CRi_SiN0.js} +1 -1
- package/dist/assets/{device-integration-icon-BMTwf3mF.js → device-integration-icon-DigkwuPa.js} +1 -1
- package/dist/assets/device-picker-model-Ct4hIz-N.js +1 -0
- package/dist/assets/dist-B6zcGpdS.js +1122 -0
- package/dist/assets/{dist-D7aUh2j3.js → dist-Bgy0yfXq.js} +1 -1
- package/dist/assets/{format-D2Wcm0QP.js → format-D9ROMB42.js} +1 -1
- package/dist/assets/{hostInit-4wcUPS8D.js → hostInit-DKsMmBUL.js} +1 -1
- package/dist/assets/i18n-HSlX-YO0.js +1 -0
- package/dist/assets/icons-DrHUdyj-.js +1 -0
- package/dist/assets/index-4KLN9ueQ.css +2 -0
- package/dist/assets/index-BtSb3e7u.js +6 -0
- package/dist/assets/{linked-devices-model-C7til7aR.js → linked-devices-model-DfectUL6.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-4aebb5a9.js → mf-entry-bootstrap-0-3133e5cd.js} +2 -2
- package/dist/assets/mount-Ct4hIz-N.js +1 -0
- package/dist/assets/{notification-rule-status-D5LkcHTp.js → notification-rule-status-CyADOgAm.js} +1 -1
- package/dist/assets/player-overlays-D546iNTv.js +1 -0
- package/dist/assets/remoteEntry-dUdMqzVb.js +1 -0
- package/dist/assets/src-CFKmxwYU.js +279 -0
- package/dist/assets/{sso-popup-Ceq4Jz8a.js → sso-popup--gCyd56l.js} +1 -1
- package/dist/assets/{step-inspector-model-BzUVKPrw.js → step-inspector-model-BTxke2pR.js} +1 -1
- package/dist/assets/{use-scenes-feed-DA7UFRvT.js → use-scenes-feed-BO3ulLXX.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-JYfuB8v_.js → useAdminDeviceRemoval-DnSeZ4C8.js} +1 -1
- package/dist/assets/useEventInvalidation-Ct4hIz-N.js +1 -0
- package/dist/assets/{useNodeUrlSelection-CmeaBXTi.js → useNodeUrlSelection-B7z0eVw2.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DXs1P_5w.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-COrdYohN.js} +2 -2
- package/dist/index.html +9 -9
- package/dist/server/addon.js +210 -14
- package/package.json +2 -2
- package/dist/assets/AccessSection-C3Z4VMbn.js +0 -1
- package/dist/assets/Addons-CBfB4PwF.js +0 -5
- package/dist/assets/AiProfiles-Uzt6ITwV.js +0 -3
- package/dist/assets/Archive-KiES4AK1.js +0 -1
- package/dist/assets/Build-CLqFtQQF.js +0 -40
- package/dist/assets/Cluster-ZhXkbC8q.js +0 -1
- package/dist/assets/CompositionBlockEditor-BAgVN8yN.js +0 -2
- package/dist/assets/CompositionEditorPage-Cjdi12u4.js +0 -1
- package/dist/assets/Data-DkKT4kg4.js +0 -2
- package/dist/assets/DeviceDetail-DphkoMAH.js +0 -1
- package/dist/assets/Identity-BELn4_Lg.js +0 -1
- package/dist/assets/InstancesTable-Blgr9UwH.js +0 -1
- package/dist/assets/IntegrationDetail-Bv3DXRXC.js +0 -1
- package/dist/assets/Integrations-BNc3Xhbg.js +0 -1
- package/dist/assets/Library-CC-yVMZb.js +0 -1
- package/dist/assets/Locations-TgIsNyQs.js +0 -3
- package/dist/assets/Logs-CjVZvl-p.js +0 -1
- package/dist/assets/NodeAddonsSettingsPanel-Dxp-6Ksw.js +0 -1
- package/dist/assets/Notifications-DXM5xtCq.js +0 -1
- package/dist/assets/Pipeline-Bujc9zjR.js +0 -1
- package/dist/assets/StorageLocationsTable-B_F1eKHy.js +0 -1
- package/dist/assets/TemplateEditorDialog-UOirN96h.js +0 -1
- package/dist/assets/client-Dn4ym7AZ.js +0 -1122
- package/dist/assets/device-picker-model-C0oitxOP.js +0 -1
- package/dist/assets/dist-BZARORuz.js +0 -1122
- package/dist/assets/i18n-CsnSJSM7.js +0 -1
- package/dist/assets/icons-DK3iI8sz.js +0 -1
- package/dist/assets/index-CgTEWhcQ.css +0 -2
- package/dist/assets/index-FA3cRm59.js +0 -6
- package/dist/assets/mount-C0oitxOP.js +0 -1
- package/dist/assets/player-overlays-BKicBNcF.js +0 -1
- package/dist/assets/remoteEntry-3rv7Sz7o.js +0 -1
- package/dist/assets/src-CU6u_Uvz.js +0 -279
- package/dist/assets/useEventInvalidation-C0oitxOP.js +0 -1
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-C2_XrAsB.js","./src-CU6u_Uvz.js","./player-overlays-BKicBNcF.js","./chevron-down-CBb-F8DT.js","./client-Dn4ym7AZ.js","./__vite-browser-external-DIbVKiho.js","./useTranslation-BJr-n0es.js","./AdminPage-C0rgqBg5.js","./device-integration-icon-BMTwf3mF.js","./useAdminDeviceRemoval-JYfuB8v_.js","./useEventInvalidation-C0oitxOP.js","./addon-kind-filter-CEGKkC1O.js","./Integrations-BNc3Xhbg.js","./i18n-CsnSJSM7.js","./table-2-DMxm3oyu.js","./IntegrationDetail-Bv3DXRXC.js","./search-x-C5ra3Aft.js","./Pipeline-Bujc9zjR.js","./terminal-DZ5OZpgC.js","./usb-P4R9CjYI.js","./crop-B-t0rzRY.js","./layers-BH9u1mrE.js","./NodeAddonsSettingsPanel-Dxp-6Ksw.js","./settings-section-shape-DbQZZpNL.js","./step-inspector-model-BzUVKPrw.js","./board-model-CV7df4sG.js","./DeviceDetail-DphkoMAH.js","./divide-Bmm9r7CP.js","./circle-slash-Duh934sZ.js","./scan-eye-C862nWtV.js","./shapes-D4IRNSXI.js","./file-up-2YD_M6f_.js","./device-detail-QaaayAym.js","./CompositionBlockEditor-BAgVN8yN.js","./camera-block-model-DoWj--hc.js","./assignment-candidates-FntpKIEo.js","./device-picker-model-C0oitxOP.js","./PanelContent-D7u-ISFK.js","./mount-C0oitxOP.js","./TemplateEditorDialog-UOirN96h.js","./unlink-D3-IGpS8.js","./command-vocab-B1KZgOMw.js","./linked-devices-model-C7til7aR.js","./format-D2Wcm0QP.js","./authed-media-CkCP7Cpu.js","./notification-rule-status-D5LkcHTp.js","./Showroom-DU9iMIZh.js","./EmbedPlayerPage-BKlnHqN7.js","./EmbedDevicePage-B-kXRzxP.js","./Library-CC-yVMZb.js","./user-x-DkWcmF99.js","./square-check-big-DAcFGNUN.js","./AdminSectionedPage-CrbDQuju.js","./NewExportModal-B87f6wft.js","./use-scenes-feed-DA7UFRvT.js","./format-size-DIxKXxtj.js","./Archive-KiES4AK1.js","./scissors-DpiKUioV.js","./StorageLocationsTable-B_F1eKHy.js","./eraser-B3lnG9yK.js","./hard-drive-download-C6N6tovA.js","./InstancesTable-Blgr9UwH.js","./link-2-off-DmsjRAt7.js","./Viewer-Cu1fVuMh.js","./monitor-off-DnOkDa2s.js","./Build-CLqFtQQF.js","./variable-DTEpBbRf.js","./action-draft-D0S-LJcp.js","./CompositionEditorPage-Cjdi12u4.js","./Locations-TgIsNyQs.js","./Addons-CBfB4PwF.js","./useNodeUrlSelection-CmeaBXTi.js","./AiProfiles-Uzt6ITwV.js","./flask-conical-D7tbJQpj.js","./message-square-plus-_aGccjyj.js","./ai-page.helpers-DJ4SE1RA.js","./MyAccess-CvFEb2P_.js","./monitor-smartphone-DPI9EQus.js","./AccessSection-C3Z4VMbn.js","./SessionsList-D6U14Yno.js","./sso-popup-Ceq4Jz8a.js","./Logs-CjVZvl-p.js","./timer-reset-5221y6Jb.js","./Identity-BELn4_Lg.js","./key-CH4aXNMz.js","./BootstrapSettingsForm-CNwsceSk.js","./Network-BApaJTDv.js","./useInvalidateAddonSettings-CyofQfBo.js","./Integrations-w_KbkNum.js","./TrainingProviders-BG7DsUoT.js","./Data-DkKT4kg4.js","./database-zap-DHuELz_w.js","./System-1Jh6VozL.js","./ruler-Buxogset.js","./Cluster-ZhXkbC8q.js","./memory-stick-BQrJMbEW.js","./Terminal-DyWFdRWL.js","./Terminal-kHJ-D0s7.css","./Notifications-DXM5xtCq.js","./languages-Du_pOBpX.js","./History-C8ZY-Ovj.js","./Calendars-fZrHEH0S.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e,t}from"./rolldown-runtime-Cyuzqnbw.js";import"./virtual_mf-exposes___mfe_internal__admin_ui_host__remoteEntry-_hash_-DnnXQRkG.js";import{a as n,o as r,r as i}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DXs1P_5w.js";import{t as a}from"./vite-preload-helper-kNaey6uv.js";import{A as o,C as s,D as c,F as l,G as u,H as d,I as f,J as p,K as m,M as h,N as g,O as _,P as v,Q as y,R as b,S as x,V as S,X as C,Y as w,Z as T,a as E,d as D,et as O,i as k,j as A,k as j,m as M,o as N,t as P,u as F,x as I,z as L}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$a as R,$i as z,Bn as ee,Cn as te,Cr as ne,Dr as B,Dt as re,Ea as ie,Et as V,Ha as ae,Hr as oe,In as se,Ir as ce,Na as le,Nn as H,Nr as ue,Q as U,Qa as de,Qn as fe,Rn as pe,Rt as me,Sr as he,T as ge,Tt as _e,V as ve,Vn as ye,Vr as be,Wi as xe,Xa as Se,Xi as Ce,Xn as we,Yi as Te,Yn as Ee,Z as De,Za as Oe,Zr as ke,Zt as Ae,_a as je,_i as Me,_r as Ne,aa as Pe,ba as Fe,ca as Ie,ci as Le,ct as Re,dn as ze,er as Be,fa as Ve,ft as He,gt as Ue,ir as We,it as Ge,ji as Ke,jn as qe,jt as Je,ki as Ye,kr as Xe,kt as Ze,ma as Qe,oa as $e,oi as et,pa as tt,qr as nt,ri as rt,rr as it,rt as at,sa as ot,si as st,tn as ct,to as lt,vi as ut,wi as dt,wt as ft,xa as pt,ya as mt,yi as ht,yn as gt,yt as _t,zr as W}from"./player-overlays-BKicBNcF.js";import{At as vt,B as yt,Ct as bt,Dt as xt,Et as St,Ft as Ct,G as wt,Gt as Tt,H as Et,Ho as Dt,Ht as Ot,Is as kt,J as At,Jc as jt,Jt as Mt,K as Nt,Kt as Pt,L as Ft,Lc as It,Lt,Nt as Rt,Ot as zt,P as Bt,Pt as Vt,Qi as Ht,R as Ut,Rt as Wt,St as Gt,Tt as Kt,U as qt,Un as Jt,Us as Yt,V as Xt,Vt as Zt,W as Qt,Wr as $t,Wt as en,Xc as tn,Xt as nn,Y as rn,Yc as an,Ys as on,Yt as sn,Zo as cn,Zt as ln,a as un,ai as dn,an as fn,c as pn,cn as mn,d as hn,el as gn,en as _n,f as vn,ft as yn,ii as bn,in as xn,it as Sn,kt as Cn,ln as wn,ma as Tn,n as En,nc as Dn,nn as On,o as kn,oi as An,on as jn,q as Mn,qt as Nn,r as Pn,rn as Fn,rt as In,s as Ln,sl as Rn,sn as zn,t as Bn,ta as Vn,tn as Hn,wt as Un,z as Wn,zt as Gn}from"./client-Dn4ym7AZ.js";import{_ as Kn,a as qn,c as Jn,d as Yn,f as Xn,g as Zn,h as Qn,i as $n,l as er,m as tr,n as nr,o as rr,p as ir,r as ar,s as or,t as sr,u as cr}from"./terminal-DZ5OZpgC.js";import{$c as lr,$t as ur,Aa as dr,Ao as fr,Ba as pr,Cc as mr,Cp as hr,Da as gr,Df as _r,Do as vr,Dp as yr,Ec as br,El as xr,Ep as Sr,Fa as Cr,Fi as wr,Fl as Tr,Fp as Er,Gi as Dr,Gs as Or,Hp as kr,Hs as Ar,Ii as jr,Is as Mr,Jc as Nr,Ji as Pr,Jt as Fr,Ki as Ir,Kp as Lr,Ks as Rr,La as zr,Lc as Br,Ls as Vr,Lt as Hr,M as Ur,Mi as Wr,Nf as Gr,Ni as Kr,Np as qr,Oi as Jr,Oo as Yr,Op as Xr,Or as Zr,P as Qr,Pi as $r,Pt as ei,Ri as ti,Rs as ni,Sr as ri,Tc as ii,Ts as ai,Uf as oi,Ui as si,Us as ci,Va as li,Vi as ui,Vp as di,Wi as fi,Xc as pi,Xd as mi,Yi as hi,Ys as gi,Za as _i,Zc as vi,_a as yi,_p as G,_r as bi,ai as xi,ap as Si,at as Ci,bc as wi,bf as Ti,br as Ei,ci as Di,do as Oi,dp as ki,ds as Ai,f as ji,fa as Mi,fc as Ni,fn as Pi,fo as Fi,fp as Ii,ga as Li,gr as Ri,ha as zi,ho as Bi,hr as Vi,i as Hi,ii as Ui,il as Wi,jo as Gi,jt as Ki,ka as qi,kc as Ji,ko as Yi,la as Xi,lp as K,ls as Zi,m as Qi,ma as $i,mc as ea,n as ta,nn as na,oc as ra,on as ia,op as aa,pa as oa,pc as sa,pi as ca,qa as la,qi as ua,qp as da,r as fa,rl as pa,ro as ma,rt as ha,si as ga,so as _a,ut as va,va as ya,vc as ba,vp as xa,vr as Sa,wp as Ca,wr as wa,xa as Ta,xd as Ea,xf as Da,xt as Oa,ya as ka,yc as Aa,yd as ja,yl as Ma,yr as Na,za as Pa,zi as Fa,zs as Ia,zt as La}from"./src-CU6u_Uvz.js";import{r as Ra,t as za}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js";import{t as Ba}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js";import{n as Va,t as q}from"./i18n-CsnSJSM7.js";import{a as Ha,c as Ua,i as Wa,l as Ga,n as Ka,o as qa,s as Ja,t as J,u as Ya}from"./useTranslation-BJr-n0es.js";import"./mount-C0oitxOP.js";import{a as Xa,c as Za,d as Qa,i as $a,n as eo,o as to,r as no,s as ro,t as io,u as ao}from"./sso-popup-Ceq4Jz8a.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)}})(),O(),Ra();var oo=`camstack.debugLayers`,so=/(transform|opacity|filter|perspective)/;function co(e){return e!==``&&e!==`none`}function lo(e,t,n=120){if(t.width<=0||t.height<=0||t.top>=n||t.bottom<=0)return null;let r=[];e.position===`fixed`&&r.push(`fixed`),e.position===`sticky`&&r.push(`sticky`),(co(e.backdropFilter)||co(e.webkitBackdropFilter))&&r.push(`backdrop-filter`),co(e.filter)&&r.push(`filter`);let i=Number.parseFloat(e.opacity);return Number.isFinite(i)&&i<1&&r.push(`opacity`),co(e.transform)&&r.push(`transform`),co(e.perspective)&&r.push(`perspective`),e.isolation===`isolate`&&r.push(`isolation`),e.mixBlendMode!==``&&e.mixBlendMode!==`normal`&&r.push(`mix-blend-mode`),so.test(e.willChange)&&r.push(`will-change`),r.length===0?null:{reasons:r,zIndex:e.zIndex}}function uo(e,t,n,r){let i=n!==null&&n!==``?`[${n}]`:t.split(/\s+/).filter(e=>e!==``).slice(0,3).map(e=>`.${e}`).join(``);return`${e.toLowerCase()}${i} z=${r.zIndex} ${r.reasons.join(`+`)}`}function fo(e,t){let n=new URLSearchParams(e).get(`debugLayers`);return n===`1`?{on:!0,persist:`1`}:n===`0`?{on:!1,persist:null}:{on:t===`1`,persist:`keep`}}var po=`camstack.debugLayers.noBlur`,mo=`camstack.debugLayers.outlines`,ho=`camstack.debugLayers.topLayer`,go=`debug-no-backdrop-blur`;function _o(e,t){try{return e===null?null:e.getItem(t)}catch{return null}}function vo(e,t,n){try{if(e===null)return;n===null?e.removeItem(t):e.setItem(t,n)}catch{}}function yo(e,t){let n=fo(t,_o(e,oo));n.persist!==`keep`&&vo(e,oo,n.persist);let r={on:n.on,noBlur:_o(e,po)===`1`,outlines:_o(e,mo)!==`0`,topLayer:_o(e,ho)!==`0`},i=new Set,a=e=>{r=e;for(let e of i)e()};return{getState:()=>r,subscribe:e=>(i.add(e),()=>{i.delete(e)}),setOn:t=>{if(vo(e,oo,t?`1`:null),!t){vo(e,po,null),vo(e,mo,null),vo(e,ho,null),a({on:t,noBlur:!1,outlines:!0,topLayer:!0});return}a({...r,on:t})},setNoBlur:t=>{vo(e,po,t?`1`:null),a({...r,noBlur:t})},setOutlines:t=>{vo(e,mo,t?null:`0`),a({...r,outlines:t})},setTopLayer:t=>{vo(e,ho,t?null:`0`),a({...r,topLayer:t})}}}var bo=[`transform`,`will-change`,`position`,`backdrop-filter`,`filter`,`opacity`];function xo(e){return bo.map(t=>`${t}: ${e===null?`n/a`:e(t)||`-`}`)}var So=null;function Co(){try{return window.sessionStorage}catch{return null}}function wo(){return So===null&&(So=yo(Co(),window.location.search)),So}function To(){let e=wo();return{...C(e.subscribe,e.getState),setOn:e.setOn,setNoBlur:e.setNoBlur,setOutlines:e.setOutlines,setTopLayer:e.setTopLayer}}O();var Eo=`data-debug-layers`,Do=250,Oo=60;function ko(){let e=[],t=document.body.querySelectorAll(`*`);for(let n of Array.from(t)){if(e.length>=Oo)break;if(n.closest(`[${Eo}]`)!==null)continue;let t=n.getBoundingClientRect();if(t.width<=0||t.height<=0||t.top>=120||t.bottom<=0)continue;let r=getComputedStyle(n),i=lo({position:r.position,zIndex:r.zIndex,opacity:r.opacity,filter:r.filter,backdropFilter:r.backdropFilter,webkitBackdropFilter:r.getPropertyValue(`-webkit-backdrop-filter`),transform:r.transform,perspective:r.perspective,isolation:r.isolation,mixBlendMode:r.mixBlendMode,willChange:r.willChange},t);if(i===null)continue;let a=n.getAttribute(`data-testid`);e.push({id:e.length,top:t.top,left:t.left,width:t.width,height:t.height,label:uo(n.tagName,typeof n.className==`string`?n.className:``,a===null?null:`data-testid=${a}`,i),reasons:i.reasons})}return e}function Ao(e){let t=getComputedStyle(e),n=e=>Number.parseFloat(e)||0;return{top:n(t.paddingTop),right:n(t.paddingRight),bottom:n(t.paddingBottom),left:n(t.paddingLeft)}}function jo(e){return e.includes(`backdrop-filter`)||e.includes(`filter`)?{outline:`outline-danger`,chip:`bg-danger`}:e.includes(`opacity`)||e.includes(`mix-blend-mode`)?{outline:`outline-warning`,chip:`bg-warning`}:e.includes(`fixed`)||e.includes(`sticky`)?{outline:`outline-info`,chip:`bg-info`}:{outline:`outline-primary`,chip:`bg-primary`}}function Mo(){let e=Reflect.get(navigator,`standalone`);return window.matchMedia(`(display-mode: standalone)`).matches||e===!0}function No(){return`1.2.698`}function Po(e,t){if(!(e===null||typeof e.showPopover!=`function`))try{e.matches(`:popover-open`)&&e.hidePopover(),t&&e.showPopover()}catch{}}function Fo(){let e=document.querySelector(`[data-debug-header]`),t=e===null?null:e.querySelector(`img`),n=e=>xo(e===null?null:t=>getComputedStyle(e).getPropertyValue(t));return{header:n(e),logo:n(t)}}function Io({noBlur:e,onNoBlurChange:t,outlines:n,onOutlinesChange:r,topLayer:i,onTopLayerChange:a}){let[o,c]=w([]),[l,u]=w({top:0,right:0,bottom:0,left:0}),d=p(null),f=p(null),m=p(null),[h,g]=w(Fo),_=b(()=>{Po(f.current,i),c(n?ko():[]),g(Fo()),d.current!==null&&u(Ao(d.current))},[n,i]),v=b(()=>{m.current===null&&(m.current=window.setTimeout(()=>{m.current=null,_()},Do))},[_]);return S(()=>{_();let e=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.closest(`[${Eo}]`)!==null))&&v()});return e.observe(document.body,{childList:!0,subtree:!0,attributes:!0}),window.addEventListener(`resize`,v),window.addEventListener(`orientationchange`,v),window.addEventListener(`scroll`,v,!0),()=>{e.disconnect(),window.removeEventListener(`resize`,v),window.removeEventListener(`orientationchange`,v),window.removeEventListener(`scroll`,v,!0),m.current!==null&&window.clearTimeout(m.current)}},[_,v]),za(s(`div`,{[Eo]:``,ref:f,popover:`manual`,className:`pointer-events-none fixed inset-0 z-[2147483647] m-0 h-full w-full overflow-visible border-0 bg-transparent p-0`,children:[x(`div`,{ref:d,"aria-hidden":!0,className:`invisible absolute h-0 w-0`,style:{paddingTop:`env(safe-area-inset-top)`,paddingRight:`env(safe-area-inset-right)`,paddingBottom:`env(safe-area-inset-bottom)`,paddingLeft:`env(safe-area-inset-left)`}}),o.map(e=>{let t=jo(e.reasons);return x(`div`,{"data-testid":`debug-layer-box`,className:R(`absolute outline outline-1 -outline-offset-1`,t.outline),style:{top:e.top,left:e.left,width:e.width,height:e.height},children:x(`span`,{className:R(`absolute left-0 max-w-[90vw] truncate px-1 font-mono text-[9px] leading-3 text-primary-foreground`,t.chip),style:{top:e.id%6*12},children:e.label})},e.id)}),s(`div`,{"data-testid":`debug-layers-badge`,className:`absolute right-1 top-14 rounded-md bg-background-elevated px-2 py-1 font-mono text-[10px] leading-4 text-foreground outline outline-1 outline-border`,children:[s(`div`,{children:[`admin-ui `,No()]}),s(`div`,{children:[`inset t`,l.top,` r`,l.right,` b`,l.bottom,` l`,l.left]}),s(`div`,{children:[`display-mode standalone:`,` `,window.matchMedia(`(display-mode: standalone)`).matches?`yes`:`no`,` · `,`navigator.standalone: `,Mo()?`yes`:`no`]}),s(`div`,{children:[window.innerWidth,`x`,window.innerHeight,` · `,o.length,` layers`]}),x(ca,{checked:e,onCheckedChange:t,label:`no backdrop blur`,className:`pointer-events-auto mt-1 text-[10px]`}),x(ca,{checked:n,onCheckedChange:r,label:`outlines`,className:`pointer-events-auto mt-1 text-[10px]`}),x(ca,{checked:i,onCheckedChange:a,label:`top layer`,className:`pointer-events-auto mt-1 text-[10px]`}),s(`div`,{"data-testid":`debug-header-styles`,className:`mt-1`,children:[x(`div`,{children:`header`}),h.header.map(e=>x(`div`,{children:e},e)),x(`div`,{children:`header logo`}),h.logo.map(e=>x(`div`,{children:e},e))]})]})]}),document.body)}function Lo(){let{on:e,noBlur:t,setNoBlur:n,outlines:r,setOutlines:i,topLayer:a,setTopLayer:o}=To();return S(()=>{let n=e&&t;return document.documentElement.classList.toggle(go,n),()=>document.documentElement.classList.remove(go)},[e,t]),e?x(Io,{noBlur:t,onNoBlurChange:n,outlines:r,onOutlinesChange:i,topLayer:a,onTopLayerChange:o}):null}var Ro=`camera`;function zo(e){return e===null||!/^\d+$/.test(e)?null:Number(e)}function Bo(e,t){return t===null?e:e.filter(e=>e.deviceId===t)}function Vo(e,t){let n=new Set(e.map(e=>e.deviceId));return t!==null&&n.add(t),[...n].sort((e,t)=>e-t)}var Ho=`/archive`,Uo=`/addon/training`,Wo=`/library?tab=exports`,Go=`section`,Ko=`camera`,qo=`view`;function Jo(e,t){let n=`${Ho}?${Go}=cameras&${Ko}=${String(e)}`;return t===void 0?n:`${n}&${qo}=${t}`}function Yo(e){return e===void 0?Wo:`${Wo}&${Ro}=${String(e)}`}var Xo={settings:`settings`,space:`health`,health:`health`,events:`review`,review:`review`},Zo={storage:Ho,events:Ho,cameras:Ho,exports:Wo,activity:`${Ho}#activity`,management:`${Ho}#tools`},Qo=/^\/archive\/(\d+)\/?$/;function $o(e,t){let n=new URLSearchParams(t);if(e===`/recordings`){let e=n.get(`tab`);return e===null?Ho:Zo[e]??`/archive`}if(e===`/library`&&n.get(`tab`)===`events`)return n.get(`section`)===`retrain`?Uo:Ho;let r=Qo.exec(e);if(r?.[1]!==void 0){let e=Number(r[1]),t=n.get(Go);return t===`exports`?Yo(e):Jo(e,t===null?void 0:Xo[t])}return null}O();var es=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,ts=/^[\\/]{2}/;function ns(e,t){return t+e.replace(/\\/g,`/`)}var rs=`popstate`;function is(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function as(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return ls(``,{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:us(t)}return fs(t,n,null,e)}function Y(e,t){if(e===!1||e==null)throw Error(t)}function os(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function ss(){return Math.random().toString(36).substring(2,10)}function cs(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 ls(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?ds(t):t,state:n,key:t&&t.key||r||ss(),mask:i}}function us({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 ds(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 fs(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=is(e)?e:ls(h.location,e,t);n&&n(r,e),l=u()+1;let d=cs(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=is(e)?e:ls(h.location,e,t);n&&n(r,e),l=u();let i=cs(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 ps(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(rs,d),c=e,()=>{i.removeEventListener(rs,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 ps(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),Y(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:us(t);return i=i.replace(/ $/,`%20`),!n&&ts.test(i)&&(i=r+i),new URL(i,r)}function ms(e,t,n=`/`){return hs(e,t,n,!1)}function hs(e,t,n,r,i){let a=Fs((typeof t==`string`?ds(t):t).pathname||`/`,n);if(a==null)return null;let o=i??_s(e),s=null,c=Ps(a);for(let e=0;s==null&&e<o.length;++e)s=As(o[e],c,r);return s}function gs(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 _s(e){let t=vs(e);return bs(t),t}function vs(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;Y(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=Us([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(Y(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),vs(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:Os(l,e.index),routesMeta:u.map((e,t)=>{let[n,r]=Ns(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 ys(e.path))a(e,t,!0,n)}),t}function ys(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=ys(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 bs(e){e.sort((e,t)=>e.score===t.score?ks(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var xs=/^:[\w-]+$/,Ss=3,Cs=2,ws=1,Ts=10,Es=-2,Ds=e=>e===`*`;function Os(e,t){let n=e.split(`/`),r=n.length;return n.some(Ds)&&(r+=Es),t&&(r+=Cs),n.filter(e=>!Ds(e)).reduce((e,t)=>e+(xs.test(t)?Ss:t===``?ws:Ts),r)}function ks(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 As(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?Ms(u,l,s.matcher,s.compiledParams):js(u,l),f=s.route;if(!d&&c&&n&&!r[r.length-1].route.index&&(d=js({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!d)return null;Object.assign(i,d.params),o.push({params:i,pathname:Us([a,d.pathname]),pathnameBase:Gs(Us([a,d.pathnameBase])),route:f}),d.pathnameBase!==`/`&&(a=Us([a,d.pathnameBase]))}return o}function js(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Ns(e.path,e.caseSensitive,e.end);return Ms(e,t,n,r)}function Ms(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 Ns(e,t=!1,n=!0){os(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 Ps(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return os(!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 Fs(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 Is(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?ds(e):e,a;return n?(n=Hs(n),a=n.startsWith(`/`)?Ls(n.substring(1),`/`):Ls(n,t)):a=t,{pathname:a,search:Ks(r),hash:qs(i)}}function Ls(e,t){let n=Ws(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Rs(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 zs(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Bs(e){let t=zs(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function Vs(e,t,n,r=!1){let i;typeof e==`string`?i=ds(e):(i={...e},Y(!i.pathname||!i.pathname.includes(`?`),Rs(`?`,`pathname`,`search`,i)),Y(!i.pathname||!i.pathname.includes(`#`),Rs(`#`,`pathname`,`hash`,i)),Y(!i.search||!i.search.includes(`#`),Rs(`#`,`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=Is(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var Hs=e=>e.replace(/[\\/]{2,}/g,`/`),Us=e=>Hs(e.join(`/`)),Ws=e=>e.replace(/\/+$/,``),Gs=e=>Ws(e).replace(/^\/*/,`/`),Ks=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,qs=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,Js=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 Ys(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Xs(e){return Us(e.map(e=>e.route.path).filter(Boolean))||`/`}var Zs=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Qs(e,t){let n=e;if(typeof n!=`string`||!es.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Zs)try{let e=new URL(window.location.href),r=ts.test(n)?new URL(ns(n,e.protocol)):new URL(n),a=Fs(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{os(!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 $s=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set($s);var ec=[`GET`,...$s];new Set(ec);var tc=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function nc(e){try{return tc.includes(new URL(e).protocol)}catch{return!1}}var rc=j(null);rc.displayName=`DataRouter`;var ic=j(null);ic.displayName=`DataRouterState`;var ac=j(!1);function oc(){return L(ac)}var sc=j({isTransitioning:!1});sc.displayName=`ViewTransition`;var cc=j(new Map);cc.displayName=`Fetchers`;var lc=j(null);lc.displayName=`Await`;var uc=j(null);uc.displayName=`Navigation`;var dc=j(null);dc.displayName=`Location`;var fc=j({outlet:null,matches:[],isDataRoute:!1});fc.displayName=`Route`;var pc=j(null);pc.displayName=`RouteError`;var mc=`REACT_ROUTER_ERROR`,hc=`REDIRECT`,gc=`ROUTE_ERROR_RESPONSE`;function _c(e){if(e.startsWith(`${mc}:${hc}:{`))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 vc(e){if(e.startsWith(`${mc}:${gc}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new Js(t.status,t.statusText,t.data)}catch{}}function yc(e,{relative:t}={}){Y(bc(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=L(uc),{hash:i,pathname:a,search:o}=kc(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:Us([n,a])),r.createHref({pathname:s,search:o,hash:i})}function bc(){return L(dc)!=null}function X(){return Y(bc(),`useLocation() may be used only in the context of a <Router> component.`),L(dc).location}function xc(){return L(dc).navigationType}var Sc=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Cc(e){L(uc).static||u(e)}function wc(){let{isDataRoute:e}=L(fc);return e?Jc():Tc()}function Tc(){Y(bc(),`useNavigate() may be used only in the context of a <Router> component.`);let e=L(rc),{basename:t,navigator:n}=L(uc),{matches:r}=L(fc),{pathname:i}=X(),a=JSON.stringify(Bs(r)),o=p(!1);return Cc(()=>{o.current=!0}),b((r,s={})=>{if(os(o.current,Sc),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=Vs(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:Us([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var Ec=j(null);function Dc(e){let t=L(fc).outlet;return m(()=>t&&o(Ec.Provider,{value:e},t),[t,e])}function Oc(){let{matches:e}=L(fc);return e[e.length-1]?.params??{}}function kc(e,{relative:t}={}){let{matches:n}=L(fc),{pathname:r}=X(),i=JSON.stringify(Bs(n));return m(()=>Vs(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function Ac(e,t){return jc(e,t)}function jc(e,t,n){Y(bc(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=L(uc),{matches:i}=L(fc),a=i[i.length-1],s=a?a.params:{},c=a?a.pathname:`/`,l=a?a.pathnameBase:`/`,u=a&&a.route;{let e=u&&u.path||``;Xc(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
|
-
|
|
4
|
-
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let d=X(),f;if(t){let e=typeof t==`string`?ds(t):t;Y(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})):ms(e,{pathname:m});os(u||h!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),os(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=Rc(h&&h.map(e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:Us([l,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?l:Us([l,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&g?o(dc.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...f},navigationType:`POP`}},g):g}function Mc(){let e=qc(),t=Ys(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},s=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),s=o(d,null,o(`p`,null,`💿 Hey developer 👋`),o(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,o(`code`,{style:a},`ErrorBoundary`),` or`,` `,o(`code`,{style:a},`errorElement`),` prop on your route.`)),o(d,null,o(`h2`,null,`Unexpected Application Error!`),o(`h3`,{style:{fontStyle:`italic`}},t),n?o(`pre`,{style:i},n):null,s)}var Nc=o(Mc,null),Pc=class extends l{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=vc(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:o(fc.Provider,{value:this.props.routeContext},o(pc.Provider,{value:e,children:this.props.component}));return this.context?o(Ic,{error:e},t):t}};Pc.contextType=ac;var Fc=new WeakMap;function Ic({children:e,error:t}){let{basename:n}=L(uc);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=_c(t.digest);if(e){let r=Fc.get(t);if(r)throw r;let i=Qs(e.location,n),a=i.absoluteURL||i.to;if(nc(a))throw Error(`Invalid redirect location`);if(Zs&&!Fc.get(t))if(i.isExternal||e.reloadDocument)window.location.href=a;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw Fc.set(t,n),n}return o(`meta`,{httpEquiv:`refresh`,content:`0;url=${a}`})}}return e}function Lc({routeContext:e,match:t,children:n}){let r=L(rc);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),o(fc.Provider,{value:e},n)}function Rc(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);Y(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let s=!1,c=-1;if(n&&r){s=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(c=e),t.route.id){let{loaderData:e,errors:a}=r,o=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||o){n.isStatic&&(s=!0),i=c>=0?i.slice(0,c+1):[i[0]];break}}}}let l=n?.onError,u=r&&l?(e,t)=>{l(e,{location:r.location,params:r.matches?.[0]?.params??{},pattern:Xs(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,l)=>{let d,f=!1,p=null,m=null;r&&(d=a&&n.route.id?a[n.route.id]:void 0,p=n.route.errorElement||Nc,s&&(c<0&&l===0?(Xc(`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(i.slice(0,l+1)),g=()=>{let t;return t=d?p:f?m:n.route.Component?o(n.route.Component,null):n.route.element?n.route.element:e,o(Lc,{match:n,routeContext:{outlet:e,matches:h,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||l===0)?o(Pc,{location:r.location,revalidation:r.revalidation,component:p,error:d,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:u}):g()},null)}function zc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Bc(e){let t=L(rc);return Y(t,zc(e)),t}function Vc(e){let t=L(ic);return Y(t,zc(e)),t}function Hc(e){let t=L(fc);return Y(t,zc(e)),t}function Uc(e){let t=Hc(e),n=t.matches[t.matches.length-1];return Y(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Wc(){return Uc(`useRouteId`)}function Gc(){let e=Vc(`useNavigation`);return m(()=>{let{matches:t,historyAction:n,...r}=e.navigation;return r},[e.navigation])}function Kc(){let{matches:e,loaderData:t}=Vc(`useMatches`);return m(()=>e.map(e=>gs(e,t)),[e,t])}function qc(){let e=L(pc),t=Vc(`useRouteError`),n=Uc(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Jc(){let{router:e}=Bc(`useNavigate`),t=Uc(`useNavigate`),n=p(!1);return Cc(()=>{n.current=!0}),b(async(r,i={})=>{os(n.current,Sc),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var Yc={};function Xc(e,t,n){!t&&!Yc[e]&&(Yc[e]=!0,os(!1,n))}v(Zc);function Zc({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return jc(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function Z({to:e,replace:t,state:n,relative:r}){Y(bc(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=L(uc);os(!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}=L(fc),{pathname:o}=X(),s=wc(),c=Vs(e,Bs(a),o,r===`path`),l=JSON.stringify(c);return S(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function Q(e){Y(!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 Qc({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,useTransitions:s}){Y(!bc(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let c=e.replace(/^\/*/,`/`),l=m(()=>({basename:c,navigator:i,static:a,useTransitions:s,future:{}}),[c,i,a,s]);typeof n==`string`&&(n=ds(n));let{pathname:u=`/`,search:d=``,hash:f=``,state:p=null,key:h=`default`,mask:g}=n,_=m(()=>{let e=Fs(u,c);return e==null?null:{location:{pathname:e,search:d,hash:f,state:p,key:h,mask:g},navigationType:r}},[c,u,d,f,p,h,r,g]);return os(_!=null,`<Router basename="${c}"> is not able to match the URL "${u}${d}${f}" because it does not start with the basename, so the <Router> won't render anything.`),_==null?null:o(uc.Provider,{value:l},o(dc.Provider,{children:t,value:_}))}function $c({children:e,location:t}){return Ac(el(e),t)}function el(e,t=[]){let n=[];return c.forEach(e,(e,r)=>{if(!h(e))return;let i=[...t,r];if(e.type===d){n.push.apply(n,el(e.props.children,i));return}Y(e.type===Q,`[${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>`),Y(!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=el(e.props.children,i)),n.push(a)}),n}var tl=`get`,nl=`application/x-www-form-urlencoded`;function rl(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function il(e){return rl(e)&&e.tagName.toLowerCase()===`button`}function al(e){return rl(e)&&e.tagName.toLowerCase()===`form`}function ol(e){return rl(e)&&e.tagName.toLowerCase()===`input`}function sl(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function cl(e,t){return e.button===0&&(!t||t===`_self`)&&!sl(e)}function ll(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 ul(e,t){let n=ll(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var dl=null;function fl(){if(dl===null)try{new FormData(document.createElement(`form`),0),dl=!1}catch{dl=!0}return dl}var pl=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function ml(e){return e!=null&&!pl.has(e)?(os(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${nl}"`),null):e}function hl(e,t){let n,r,i,a,o;if(al(e)){let o=e.getAttribute(`action`);r=o?Fs(o,t):null,n=e.getAttribute(`method`)||tl,i=ml(e.getAttribute(`enctype`))||nl,a=new FormData(e)}else if(il(e)||ol(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?Fs(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||tl,i=ml(e.getAttribute(`formenctype`))||ml(o.getAttribute(`enctype`))||nl,a=new FormData(o,e),!fl()){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(rl(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=tl,r=null,i=nl,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 gl={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},_l=/[&><\u2028\u2029]/g;function vl(e){return e.replace(_l,e=>gl[e])}function yl(e,t){if(e===!1||e==null)throw Error(t)}function bl(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&&Fs(i.pathname,t)===`/`?i.pathname=`${Ws(t)}/_root.${r}`:i.pathname=`${Ws(i.pathname)}.${r}`,i}async function xl(e,t){if(e.id in t)return t[e.id];try{let n=await a(()=>import(e.module),[],import.meta.url);return t[e.id]=n,n}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 Sl(e){return e!=null&&typeof e.page==`string`}function Cl(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 wl(e,t,n){return kl((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await xl(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(Cl).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function Tl(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 El(e,t,{includeHydrateFallback:n}={}){return Dl(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 Dl(e){return[...new Set(e)]}function Ol(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function kl(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!Sl(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(Ol(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function Al(){let e=L(rc);return yl(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function jl(){let e=L(ic);return yl(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var Ml=j(void 0);Ml.displayName=`FrameworkContext`;function Nl(){let e=L(Ml);return yl(e,`You must render this element inside a <HydratedRouter> element`),e}function Pl(e,t){let n=L(Ml),[r,i]=w(!1),[a,o]=w(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=p(null);S(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),S(()=>{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,f,{onFocus:Fl(s,m),onBlur:Fl(c,h),onMouseEnter:Fl(l,m),onMouseLeave:Fl(u,h),onTouchStart:Fl(d,m)}]:[a,f,{}]:[!1,f,{}]}function Fl(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Il({page:e,...t}){let n=oc(),{nonce:r}=Nl(),{router:i}=Al(),a=m(()=>ms(i.routes,e,i.basename),[i.routes,e,i.basename]);return a?(t.nonce==null&&r&&(t={...t,nonce:r}),o(n?Rl:zl,{page:e,matches:a,...t})):null}function Ll(e){let{manifest:t,routeModules:n}=Nl(),[r,i]=w([]);return S(()=>{let r=!1;return wl(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function Rl({page:e,matches:t,...n}){let r=X(),{future:i}=Nl(),{basename:a}=Al();return o(d,null,m(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=bl(e,a,i.v8_trailingSlashAwareDataRequests,`rsc`),o=!1,s=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?o=!0:s.push(e.route.id);return o&&s.length>0&&n.searchParams.set(`_routes`,s.join(`,`)),[n.pathname+n.search]},[a,i.v8_trailingSlashAwareDataRequests,e,r,t]).map(e=>o(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})))}function zl({page:e,matches:t,...n}){let r=X(),{future:i,manifest:a,routeModules:s}=Nl(),{basename:c}=Al(),{loaderData:l,matches:u}=jl(),f=m(()=>Tl(e,t,u,a,r,`data`),[e,t,u,a,r]),p=m(()=>Tl(e,t,u,a,r,`assets`),[e,t,u,a,r]),h=m(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,o=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!f.some(t=>t.route.id===e.route.id)&&e.route.id in l&&s[e.route.id]?.shouldRevalidate||t.hasClientLoader?o=!0:n.add(e.route.id))}),n.size===0)return[];let u=bl(e,c,i.v8_trailingSlashAwareDataRequests,`data`);return o&&n.size>0&&u.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[u.pathname+u.search]},[c,i.v8_trailingSlashAwareDataRequests,l,r,a,f,t,e,s]),g=m(()=>El(p,a),[p,a]),_=Ll(p);return o(d,null,h.map(e=>o(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),g.map(e=>o(`link`,{key:e,rel:`modulepreload`,href:e,...n})),_.map(({key:e,link:t})=>o(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function Bl(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var Vl=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{Vl&&(window.__reactRouterVersion=`7.18.0`)}catch{}function Hl({basename:e,children:t,useTransitions:n,window:r}){let i=p();i.current??=as({window:r,v5Compat:!0});let a=i.current,[s,c]=w({action:a.action,location:a.location}),l=b(e=>{n===!1?c(e):f(()=>c(e))},[n]);return u(()=>a.listen(l),[a,l]),o(Qc,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:a,useTransitions:n})}function Ul({basename:e,children:t,history:n,useTransitions:r}){let[i,a]=w({action:n.action,location:n.location}),s=b(e=>{r===!1?a(e):f(()=>a(e))},[r]);return u(()=>n.listen(s),[n,s]),o(Qc,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,useTransitions:r})}Ul.displayName=`unstable_HistoryRouter`;var Wl=A(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,mask:s,state:c,target:l,to:u,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m,...h},g){let{basename:_,navigator:v,useTransitions:y}=L(uc),b=typeof u==`string`&&es.test(u),x=Qs(u,_);u=x.to;let S=yc(u,{relative:r}),C=X(),w=null;if(s){let e=Vs(s,[],C.mask?C.mask.pathname:`/`,!0);_!==`/`&&(e.pathname=e.pathname===`/`?_:Us([_,e.pathname])),w=v.createHref(e)}let[T,E,D]=Pl(n,h),O=Zl(u,{replace:a,mask:s,state:c,target:l,preventScrollReset:f,relative:r,viewTransition:p,defaultShouldRevalidate:m,useTransitions:y});function k(t){e&&e(t),t.defaultPrevented||O(t)}let A=!(x.isExternal||i),j=o(`a`,{...h,...D,href:(A?w:void 0)||x.absoluteURL||S,onClick:A?k:e,ref:Bl(g,E),target:l,"data-discover":!b&&t===`render`?`true`:void 0});return T&&!b?o(d,null,j,o(Il,{page:S})):j});Wl.displayName=`Link`;var Gl=A(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:s,children:c,...l},u){let d=kc(a,{relative:l.relative}),f=X(),p=L(ic),{navigator:m,basename:h}=L(uc),g=p!=null&&cu(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=Fs(y,h)||y);let b=_!==`/`&&_.endsWith(`/`)?_.length-1:_.length,x=v===_||!r&&v.startsWith(_)&&v.charAt(b)===`/`,S=y!=null&&(y===_||!r&&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 i==`function`?i(C):i;return o(Wl,{...l,"aria-current":w,className:T,ref:u,style:E,to:a,viewTransition:s},typeof c==`function`?c(C):c)});Gl.displayName=`NavLink`;var Kl=A(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:s=tl,action:c,onSubmit:l,relative:u,preventScrollReset:d,viewTransition:p,defaultShouldRevalidate:m,...h},g)=>{let{useTransitions:_}=L(uc),v=tu(),y=nu(c,{relative:u}),b=s.toLowerCase()===`get`?`get`:`post`,x=typeof c==`string`&&es.test(c);return o(`form`,{ref:g,method:b,action:y,onSubmit:r?l:e=>{if(l&&l(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,o=r?.getAttribute(`formmethod`)||s,c=()=>v(r||e.currentTarget,{fetcherKey:t,method:o,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:p,defaultShouldRevalidate:m});_&&n!==!1?f(()=>c()):c()},...h,"data-discover":!x&&e===`render`?`true`:void 0})});Kl.displayName=`Form`;function ql({getKey:e,storageKey:t,...n}){let r=L(Ml),{basename:i}=L(uc),a=X(),s=Kc();ou({getKey:e,storageKey:t});let c=m(()=>{if(!r||!e)return null;let t=au(a,s,i,e);return t===a.key?null:t},[]);if(!r||r.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&&r?.nonce&&(n.nonce=r.nonce),o(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${l})(${vl(JSON.stringify(t||ru))}, ${vl(JSON.stringify(c))})`}})}ql.displayName=`ScrollRestoration`;function Jl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Yl(e){let t=L(rc);return Y(t,Jl(e)),t}function Xl(e){let t=L(ic);return Y(t,Jl(e)),t}function Zl(e,{target:t,replace:n,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c,useTransitions:l}={}){let u=wc(),d=X(),p=kc(e,{relative:o});return b(m=>{if(cl(m,t)){m.preventDefault();let t=n===void 0?us(d)===us(p):n,h=()=>u(e,{replace:t,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c});l?f(()=>h()):h()}},[d,u,p,n,r,i,t,e,a,o,s,c,l])}function Ql(e){os(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=p(ll(e)),n=p(!1),r=X(),i=m(()=>ul(r.search,n.current?null:t.current),[r.search]),a=wc();return[i,b((e,t)=>{let r=ll(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var $l=0,eu=()=>`__${String(++$l)}__`;function tu(){let{router:e}=Yl(`useSubmit`),{basename:t}=L(uc),n=Wc(),r=e.fetch,i=e.navigate;return b(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=hl(e,t);a.navigate===!1?await r(a.fetcherKey||eu(),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 nu(e,{relative:t}={}){let{basename:n}=L(uc),r=L(fc);Y(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...kc(e||`.`,{relative:t})},o=X();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:Us([n,a.pathname])),us(a)}var ru=`react-router-scroll-positions`,iu={};function au(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:Fs(e.pathname,n)||e.pathname},t)),i??=e.key,i}function ou({getKey:e,storageKey:t}={}){let{router:n}=Yl(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=Xl(`useScrollRestoration`),{basename:a}=L(uc),o=X(),s=Kc(),c=Gc();S(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),su(b(()=>{if(c.state===`idle`){let t=au(o,s,a,e);iu[t]=window.scrollY}try{sessionStorage.setItem(t||ru,JSON.stringify(iu))}catch(e){os(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(u(()=>{try{let e=sessionStorage.getItem(t||ru);e&&(iu=JSON.parse(e))}catch{}},[t]),u(()=>{let t=n?.enableScrollRestoration(iu,()=>window.scrollY,e?(t,n)=>au(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),u(()=>{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{os(!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 su(e,t){let{capture:n}=t||{};S(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function cu(e,{relative:t}={}){let n=L(sc);Y(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Yl(`useViewTransitionState`),i=kc(e,{relative:t});if(!n.isTransitioning)return!1;let a=Fs(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Fs(n.nextLocation.pathname,r)||n.nextLocation.pathname;return js(i.pathname,o)!=null||js(i.pathname,a)!=null}var lu=e(t(((e,t)=>{t.exports={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}}))()),uu=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function du(e){var t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(lu.default[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){var r=e.indexOf(`-->`);return{type:`comment`,comment:r===-1?``:e.slice(4,r)}}for(var i=new RegExp(uu),a=null;(a=i.exec(e))!==null;)if(a[0].trim())if(a[1]){var o=a[1].trim(),s=[o,``];o.indexOf(`=`)>-1&&(s=o.split(`=`)),t.attrs[s[0]]=s[1],i.lastIndex--}else a[2]&&(t.attrs[a[2]]=a[3].trim().substring(1,a[3].length-1));return t}var fu=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,pu=/^\s*$/,mu=Object.create(null);function hu(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:return e+=`<`+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+`="`+e[n]+`"`);return t.length?` `+t.join(` `):``}(t.attrs):``)+(t.voidElement?`/>`:`>`),t.voidElement?e:e+t.children.reduce(hu,``)+`</`+t.name+`>`;case`comment`:return e+`<!--`+t.comment+`-->`}}var gu={parse:function(e,t){t||={},t.components||=mu;var n,r=[],i=[],a=-1,o=!1;if(e.indexOf(`<`)!==0){var s=e.indexOf(`<`);r.push({type:`text`,content:s===-1?e:e.substring(0,s)})}return e.replace(fu,function(s,c){if(o){if(s!==`</`+n.name+`>`)return;o=!1}var l,u=s.charAt(1)!==`/`,d=s.startsWith(`<!--`),f=c+s.length,p=e.charAt(f);if(d){var m=du(s);return a<0?(r.push(m),r):((l=i[a]).children.push(m),r)}if(u&&(a++,(n=du(s)).type===`tag`&&t.components[n.name]&&(n.type=`component`,o=!0),n.voidElement||o||!p||p===`<`||n.children.push({type:`text`,content:e.slice(f,e.indexOf(`<`,f))}),a===0&&r.push(n),(l=i[a-1])&&l.children.push(n),i[a]=n),(!u||n.voidElement)&&(a>-1&&(n.voidElement||n.name===s.slice(2,-1))&&(a--,n=a===-1?r:i[a]),!o&&p!==`<`&&p)){l=a===-1?r:i[a].children;var h=e.indexOf(`<`,f),g=e.slice(f,h===-1?void 0:h);pu.test(g)&&(g=` `),(h>-1&&a+l.length>=0||g!==` `)&&l.push({type:`text`,content:g})}}),r},stringify:function(e){return e.reduce(function(e,t){return e+hu(``,t)},``)}};O();var _u=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},vu=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?bu(t):t},yu=e=>Array.isArray(e)&&e.every(h),bu=e=>Array.isArray(e)?e:[e],xu=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},Su=e=>{let t={};if(!e)return t;let n=e=>{bu(e).forEach(e=>{Ua(e)||(_u(e)?n(vu(e)):Ja(e)&&!h(e)&&Object.assign(t,e))})};return n(e),t},Cu=(e,t,n,r)=>{if(!e)return``;let i=``,a=bu(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach((e,a)=>{if(Ua(e)){i+=`${e}`;return}if(h(e)){let{props:s,type:c}=e,l=Object.keys(s).length,u=o.indexOf(c)>-1,d=s.children;if(!d&&u&&!l){i+=`<${c}/>`;return}if(!d&&(!u||l)||s.i18nIsDynamicList){i+=`<${a}></${a}>`;return}if(u&&l<=1){let e=Ua(d)?d:Cu(d,t,n,r);i+=`<${c}>${e}</${c}>`;return}let f=Cu(d,t,n,r);i+=`<${a}>${f}</${a}>`;return}if(e===null){Ga(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(Ja(e)){let{format:t,...a}=e,o=Object.keys(a);if(o.length===1){let e=t?`${o[0]}, ${t}`:o[0];i+=`{{${e}}}`;return}Ga(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}Ga(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},wu=(e,t=[],n={})=>{if(!e)return e;let r=Object.keys(n),i=[...t,...r],a=``,o=0;for(;o<e.length;)if(e[o]===`<`){let t=!1,n=e.slice(o).match(/^<\/(\d+|[a-zA-Z][a-zA-Z0-9_-]*)>/);if(n){let e=n[1];(/^\d+$/.test(e)||i.includes(e))&&(t=!0,a+=n[0],o+=n[0].length)}if(!t){let n=e.slice(o).match(/^<(\d+|[a-zA-Z][a-zA-Z0-9_-]*)(\s+[\w-]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?)*\s*(\/)?>/);if(n){let e=n[1];(/^\d+$/.test(e)||i.includes(e))&&(t=!0,a+=n[0],o+=n[0].length)}}t||(a+=`<`,o+=1)}else a+=e[o],o+=1;return a},Tu=(e,t,n,r,i,a,s)=>{if(n===``)return[];let l=i.transKeepBasicHtmlNodesFor||[],u=n&&new RegExp(l.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!u&&!s)return[n];let f=t??{},p=e=>{bu(e).forEach(e=>{Ua(e)||(_u(e)?p(vu(e)):Ja(e)&&!h(e)&&Object.assign(f,e))})};p(e);let m=wu(n,l,f),g=gu.parse(`<0>${m}</0>`),v={...f,...a},y=(e,t,n)=>{let r=vu(e),i=x(r,t.children,n);return yu(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},b=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push(_(e,{key:r},i?void 0:t))):n.push(...c.map([e],e=>{if(e.type===d||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`children`||t===`i18nIsDynamicList`||(n[t]=e.props[t])}),o(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`ref`||t===`children`||(n[t]=e.props[t])}),_(e,n,i?null:t)}))},x=(e,n,a)=>{let c=bu(e),d=bu(n),f={};return d.reduce((e,n,d)=>{let p=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,v,r.language);if(n.type===`tag`){let m=c[parseInt(n.name,10)];!m&&t&&(m=t[n.name]),a.length===1&&!m&&(m=a[0][n.name]),m||={};let g={...n.attrs};s&&Object.keys(g).forEach(e=>{let t=g[e];Ua(t)&&(g[e]=qa(t))});let _=Object.keys(g).length===0?m:xu({props:g},m),S=h(_),C=S&&_u(n,!0)&&!n.voidElement,w=u&&Ja(_)&&_.dummy&&!S,T=Ja(t)&&Object.hasOwnProperty.call(t,n.name);if(Ua(_)){let t=r.services.interpolator.interpolate(_,v,r.language);e.push(t)}else if(_u(_)||C)b(_,y(_,n,a),e,d);else if(w)b(_,x(c,n.children,a),e,d);else if(Number.isNaN(parseFloat(n.name)))if(T)b(_,y(_,n,a),e,d,n.voidElement);else if(i.transSupportBasicHtmlNodes&&l.indexOf(n.name)>-1)if(n.voidElement)e.push(o(n.name,{key:`${n.name}-${d}`}));else{let t=f[n.name]||0;f[n.name]=t+1;let r,i=0;for(let e=0;e<c.length;e+=1){let a=c[e];if(h(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let s=x(r?bu(vu(r)):c,n.children,a);e.push(o(n.name,{key:`${n.name}-${d}`},s))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=x(c,n.children,a);e.push(`<${n.name}>${t}</${n.name}>`)}else if(Ja(_)&&!S){let t=n.children[0]?p:null;t&&e.push(t)}else b(_,p,e,d,n.children.length!==1||!p)}else if(n.type===`text`){let t=i.transWrapTextNodes,a=typeof i.unescape==`function`?i.unescape:Ha().unescape,c=s?a(r.services.interpolator.interpolate(n.content,v,r.language)):r.services.interpolator.interpolate(n.content,v,r.language);t?e.push(o(t,{key:`${n.name}-${d}`},c)):e.push(c)}return e},[])};return vu(x([{dummy:!0,children:e||[]}],g,bu(e||[]))[0])},Eu=(e,t,n)=>{let r=e.key||t,i=_(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return o(d,null,i)}return o(a,{key:r})},Du=(e,t)=>e.map((e,n)=>Eu(e,n,t)),Ou=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:Eu(e[r],r,t)})}),n},ku=(e,t,n,r)=>e?Array.isArray(e)?Du(e,t):Ja(e)?Ou(e,t):(Ya(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,Au=e=>!Ja(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function ju({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:s,defaults:c,components:l,ns:u,i18n:d,t:f,shouldUnescape:p,...m}){let h=d||Wa();if(!h)return Ya(h,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using i18nextReactModule`,{i18nKey:r}),e;let g=f||h.t.bind(h)||(e=>e),_={...Ha(),...h.options?.react},v=u||g.ns||h.options?.defaultNS;v=Ua(v)?[v]:v||[`translation`];let{transDefaultProps:y}=_,b=y?.tOptions?{...y.tOptions,...a}:a,x=p??y?.shouldUnescape,S=y?.values?{...y.values,...s}:s,C=y?.components?{...y.components,...l}:l,w=Cu(e,_,h,r),T=c||b?.defaultValue||w||_.transEmptyNodeValue||(typeof r==`function`?Va(r):r),{hashTransKey:E}=_,D=r||(E?E(w||T):w||T);s=h.options?.interpolation?.defaultVariables?S&&Object.keys(S).length>0?{...S,...h.options.interpolation.defaultVariables}:{...h.options.interpolation.defaultVariables}:S;let O=Su(e);O&&typeof O.count==`number`&&t===void 0&&(t=O.count);let k=s||t!==void 0&&!h.options?.interpolation?.alwaysFormat||!e?b.interpolation:{interpolation:{...b.interpolation,prefix:`#$?`,suffix:`?$#`}},A={...b,context:i||b.context,count:t,...s,...k,defaultValue:T,ns:v},j=D?g(D,A):T;j===D&&T&&(j=T);let M=ku(C,j,h,r),N=M||e,P=null;Au(M)&&(P=M,N=e);let F=Tu(N,P,j,h,_,A,x),I=n??_.defaultTransParent;return I?o(I,m,F):F}O();function Mu({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:o,defaults:s,components:c,ns:l,i18n:u,t:d,shouldUnescape:f,...p}){let{i18n:m,defaultNS:h}=L(Ka)||{},g=u||m||Wa(),_=d||g?.t.bind(g);return ju({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a,values:o,defaults:s,components:c,ns:l||_?.ns||h||g?.options?.defaultNS,i18n:g,t:d,shouldUnescape:f,...p})}var Nu=`camstack:broker-oauth`;function Pu(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`camstack:broker-oauth`&&typeof t.ok==`boolean`}function Fu(e,t){return e.split(`{{brokerId}}`).join(encodeURIComponent(t))}function Iu(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||Pu(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 Lu={open:e=>$a(e),assign:e=>window.location.assign(e),watch:(e,t)=>Iu(e,t)};function Ru(e,t,n=Lu){let r=U(Za(e)),i=n.open(r);if(i===null){n.assign(r);return}n.watch(i,e=>{t?.(e)})}var zu=[`starting`,`awaiting-login`,`captured`,`error`,`cancelled`],Bu=[`awaiting-code`,`captured`,`expired`,`error`,`cancelled`];function Vu(e){return typeof e==`object`&&!!e}function Hu(e){return Vu(e)&&typeof e.sessionId==`string`&&typeof e.loginUrl==`string`}function Uu(e){return Vu(e)&&typeof e.sessionId==`string`&&typeof e.phase==`string`&&zu.includes(e.phase)}function Wu(e){return Vu(e)&&typeof e.sessionId==`string`&&typeof e.userCode==`string`&&typeof e.verificationUrl==`string`&&typeof e.expiresAt==`number`}function Gu(e){return Wu(e)&&Vu(e)&&typeof e.phase==`string`&&Bu.includes(e.phase)}function Ku(e){return Vu(e)&&typeof e.brokerId==`string`}function qu(){return{"Content-Type":`application/json`,Authorization:`Bearer ${localStorage.getItem(`camstack_admin_token`)??``}`}}async function Ju(e,t){try{return await e.json()}catch{throw Error(`${t} failed: HTTP ${e.status}`)}}function Yu(e){let t=Vu(e)&&typeof e.error==`string`?e.error:`Unknown error`;return Error(t)}async function Xu(e,t,n){let r=await fetch(U(e),{method:`POST`,headers:qu(),body:JSON.stringify(t)}),i=await Ju(r,`Sign-in ${e.split(`/`).pop()??`request`}`);if(!r.ok)throw Yu(i);if(!n(i))throw Error(`Unexpected response from server`);return i}function Zu(e,t){return Xu(`${e}/start`,t,Hu)}function Qu(e,t){return Xu(`${e}/code/start`,t,Wu)}async function $u(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(U(`${e}/status?${n.toString()}`),{headers:{Authorization:qu().Authorization??``}}),i=await Ju(r,`Sign-in status`);if(!r.ok)throw Yu(i);if(!Gu(i))throw Error(`Unexpected status response from server`);return i}async function ed(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(U(`${e}/status?${n.toString()}`),{headers:{Authorization:qu().Authorization??``}}),i=await Ju(r,`Sign-in status`);if(!r.ok)throw Yu(i);if(!Uu(i))throw Error(`Unexpected status response from server`);return i}function td(e,t){return Xu(`${e}/commit`,{...t},Ku)}async function nd(e,t){try{await fetch(U(`${e}/cancel`),{method:`POST`,headers:qu(),body:JSON.stringify({sessionId:t})})}catch{}}O();var rd=2e3,id=1e3;function ad(e){let t=Math.max(0,Math.ceil(e/1e3));return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,`0`)}`}function od({expiresAt:e}){let{t}=J(),[n,r]=w(()=>Date.now());return S(()=>{let e=setInterval(()=>r(Date.now()),id);return()=>clearInterval(e)},[]),x(`span`,{className:`text-[11px] text-foreground-subtle`,children:t(`brokers.signIn.codeExpiresIn`,{time:ad(e-n)})})}function sd({basePath:e,name:t,brokerId:n,getSettings:r,disabled:i,onSignedIn:a}){let{t:o}=J(),[c,l]=w({kind:`idle`}),u=p(!0),d=p(null),f=p(null),m=b(()=>{f.current!==null&&clearInterval(f.current),f.current=null},[]),h=b(()=>{m();let t=d.current;d.current=null,t!==null&&nd(e,t)},[e,m]);S(()=>(u.current=!0,()=>{u.current=!1,h()}),[h]);let g=b(e=>{m(),u.current&&l({kind:`error`,message:e})},[m]),_=b(async r=>{m(),u.current&&l({kind:`committing`});try{let i=await td(e,{sessionId:r,name:t,...n===void 0?{}:{brokerId:n}});d.current=null,u.current&&a(i.brokerId)}catch(e){g(e instanceof Error?e.message:String(e))}},[e,n,g,t,a,m]),v=b(t=>{m(),f.current=setInterval(()=>{(async()=>{try{let n=await $u(e,t);if(n.phase===`captured`)return void await _(t);if(n.phase===`error`)return g(n.error??o(`brokers.signIn.proxyError`));if(n.phase===`expired`){m(),u.current&&l({kind:`expired`});return}n.phase===`cancelled`&&(m(),u.current&&l({kind:`idle`}))}catch{}})()},rd)},[e,_,g,m,o]),y=async()=>{h(),l({kind:`starting`});try{let t=await Qu(e,r());d.current=t.sessionId,l({kind:`waiting`,code:t}),v(t.sessionId)}catch(e){g(e instanceof Error?e.message:String(e))}},C=()=>{h(),l({kind:`idle`})};if(c.kind===`idle`||c.kind===`error`||c.kind===`expired`)return s(`div`,{className:`space-y-2`,children:[c.kind===`error`&&x(gr,{message:c.message}),c.kind===`expired`&&x(`p`,{className:`text-xs text-warning`,children:o(`brokers.signIn.codeExpired`)}),x(`p`,{className:`text-xs text-foreground-muted`,children:o(`brokers.signIn.codeIntro`)}),s(K,{variant:`primary`,size:`sm`,disabled:i===!0||t.trim().length===0,onClick:()=>void y(),children:[c.kind===`idle`?x(rr,{className:`h-3.5 w-3.5`}):x(Ee,{className:`h-3.5 w-3.5`}),` `,c.kind===`idle`?o(`brokers.signIn.getCode`):o(`brokers.signIn.newCode`)]})]});if(c.kind===`starting`||c.kind===`committing`)return s(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[x(W,{className:`h-4 w-4 animate-spin flex-shrink-0`}),c.kind===`starting`?o(`brokers.signIn.starting`):o(`brokers.signIn.saving`)]});let{code:T}=c;return s(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-3`,children:[x(`p`,{className:`text-xs text-foreground-muted`,children:o(`brokers.signIn.codeInstructions`)}),s(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border-subtle bg-background px-3 py-2`,children:[x(`span`,{"data-testid":`device-code`,className:`font-mono text-2xl font-semibold tracking-widest text-foreground break-all`,children:T.userCode}),x(Zr,{value:T.userCode,srLabel:o(`brokers.signIn.copyCode`)})]}),s(K,{variant:`primary`,size:`sm`,onClick:()=>window.open(T.verificationUrl,`_blank`,`noopener,noreferrer`),children:[x(ht,{className:`h-3.5 w-3.5`}),` `,o(`brokers.signIn.openCodePage`,{host:cd(T.verificationUrl)})]}),s(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-1`,children:[s(`span`,{className:`flex min-w-0 flex-col text-[11px] text-foreground-subtle`,children:[s(`span`,{className:`flex items-center gap-2`,children:[x(W,{className:`h-3 w-3 animate-spin flex-shrink-0`}),` `,o(`brokers.signIn.waitingForCode`)]}),x(od,{expiresAt:T.expiresAt})]}),x(K,{variant:`outline`,size:`sm`,className:`shrink-0 whitespace-nowrap`,onClick:C,children:o(`brokers.signIn.cancel`)})]})]})}function cd(e){try{let t=new URL(e);return`${t.host}${t.pathname===`/`?``:t.pathname}`}catch{return e}}O();var ld=2e3;function ud(e){return e.startsWith(`/`)&&!e.startsWith(`//`)?new URL(e,window.location.origin).toString():e}function dd({basePath:e,name:t,brokerId:n,getSettings:r,disabled:i,onSignedIn:a}){let{t:o}=J(),[c,l]=w({kind:`idle`}),u=p(!0),d=p(null),f=p(null),m=b(()=>{f.current!==null&&clearInterval(f.current),f.current=null},[]),h=b(()=>{m();let t=d.current;d.current=null,t!==null&&nd(e,t)},[e,m]);S(()=>(u.current=!0,()=>{u.current=!1,h()}),[h]);let g=b(e=>{m(),u.current&&l({kind:`error`,message:e})},[m]),_=b(async r=>{m(),u.current&&l({kind:`committing`});try{let i=await td(e,{sessionId:r,name:t,...n===void 0?{}:{brokerId:n}});d.current=null,u.current&&a(i.brokerId)}catch(e){g(e instanceof Error?e.message:String(e))}},[e,n,g,t,a,m]),v=b(t=>{m(),f.current=setInterval(()=>{(async()=>{try{let n=await ed(e,t);if(n.phase===`captured`)return void await _(t);if(n.phase===`error`)return g(n.error??o(`brokers.signIn.proxyError`));if(n.phase===`cancelled`){m(),u.current&&l({kind:`idle`});return}u.current&&l({kind:`waiting`,loginUrl:n.loginUrl,ready:n.phase===`awaiting-login`})}catch{}})()},ld)},[e,_,g,m,o]),y=async()=>{h(),l({kind:`starting`});try{let t=await Zu(e,r());d.current=t.sessionId,l({kind:`waiting`,loginUrl:t.loginUrl,ready:!1}),v(t.sessionId)}catch(e){g(e instanceof Error?e.message:String(e))}};return c.kind===`idle`||c.kind===`error`?s(`div`,{className:`space-y-2`,children:[c.kind===`error`&&x(gr,{message:c.message}),x(`p`,{className:`text-xs text-foreground-muted`,children:o(`brokers.signIn.intro`)}),s(K,{variant:`primary`,size:`sm`,disabled:i===!0||t.trim().length===0,onClick:()=>void y(),children:[x(rr,{className:`h-3.5 w-3.5`}),` `,c.kind===`error`?o(`common.retry`):o(`brokers.signIn.start`)]})]}):c.kind===`starting`||c.kind===`committing`?s(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[x(W,{className:`h-4 w-4 animate-spin flex-shrink-0`}),c.kind===`starting`?o(`brokers.signIn.starting`):o(`brokers.signIn.saving`)]}):s(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-3`,children:[c.ready?s(I,{children:[x(`p`,{className:`text-xs font-semibold text-foreground`,children:o(`brokers.signIn.openLink`)}),x(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`brokers.signIn.afterLogin`)}),s(K,{variant:`primary`,size:`sm`,onClick:()=>window.open(ud(c.loginUrl),`_blank`,`noopener,noreferrer`),children:[x(ht,{className:`h-3.5 w-3.5`}),` `,o(`brokers.signIn.openLoginPage`)]})]}):s(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[x(W,{className:`h-4 w-4 animate-spin flex-shrink-0`}),o(`brokers.signIn.waitingForProxy`)]}),s(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[s(`span`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[x(W,{className:`h-3 w-3 animate-spin`}),` `,o(`brokers.signIn.waitingForLogin`)]}),x(K,{variant:`outline`,size:`sm`,onClick:()=>{h(),l({kind:`idle`})},children:o(`brokers.signIn.cancel`)})]})]})}O();var fd=[`device-code`];function pd({methods:e,...t}){let{t:n}=J(),r=e!==void 0&&e.length>0?e:fd,[i,a]=w(null),o=i!==null&&r.includes(i)?i:r[0]??`device-code`;return s(`div`,{className:`space-y-2`,children:[r.length>1&&x(xi,{value:o,onValueChange:e=>a(e===`device-code`?e:`proxy`),appearance:`pills`,children:x(ga,{"aria-label":n(`brokers.signIn.method`),children:r.map(e=>x(Di,{value:e,children:n(e===`device-code`?`brokers.signIn.methodDeviceCode`:`brokers.signIn.methodProxy`)},e))})}),o===`device-code`?x(sd,{...t},`device-code`):x(dd,{...t},`proxy`)]})}function md(e){return t=>Object.prototype.hasOwnProperty.call(e,t)}var hd=md({devices:!0}),gd=md({classes:!0,classesExclude:!0,labelEquals:!0,identities:!0,identitiesExclude:!0,eventTypeTokens:!0,sensorKinds:!0}),_d=md({minConfidence:!0,minImportance:!0,minLabelConfidence:!0}),vd=md({minDwellSeconds:!0}),yd=md({source:!0}),bd=md({crossing:!0}),xd=md({packagePhase:!0}),Sd=md({sensorTransition:!0}),Cd=md({plates:!0}),wd=md({occupancy:!0}),Td=md({audio:!0}),Ed=md({systemEvent:!0}),Dd=md({deviceState:!0}),Od=md({scene:!0});function kd(e,t){let n=e[t];return Array.isArray(n)?n:[]}function Ad(e,t){let n=e[t];return typeof n==`number`?n:void 0}var jd=`event-emitter`;function Md(e){let t=new Map,n=[],r=!1,i=0;for(let a of e){if(a.status===`pending`){r=!0;continue}if(a.status===`error`){n.push(a.deviceName);continue}if(a.data===null||a.data===void 0)continue;let e=Dt.safeParse(a.data);if(!e.success){n.push(a.deviceName);continue}i+=1;for(let n of kt(e.data)){let e=t.get(n.id);e===void 0?t.set(n.id,{label:n.label,devices:[a.deviceName]}):e.devices.includes(a.deviceName)||t.set(n.id,{label:e.label,devices:[...e.devices,a.deviceName]})}}let a=i>1;return{options:[...t.entries()].map(([e,t])=>a?{value:e,label:t.label,hint:t.devices.join(`, `)}:{value:e,label:t.label}),pending:r,unknownDevices:n,eventDeviceCount:i}}function Nd(e,t,n){let r=new Set(t.map(e=>e.id)),i=new Map((n??[]).map(e=>[e.id,e.name]));return e.filter(e=>!r.has(e)).map(e=>({deviceId:e,deviceName:i.get(e)??`#${e}`}))}O();function Pd(e,t){let n=_t().trpcClient,r=k({queries:e.map(e=>({queryKey:[[`nc-pickers`,`zones`],{deviceId:e}],staleTime:3e4,queryFn:async()=>({deviceId:e,zones:(await n.zones.listZones.query({deviceId:e})).map(e=>({id:e.id,name:e.name}))})}))});return m(()=>{let e=[],n=new Set;for(let i of r){if(!i.data)continue;let r=t.find(e=>e.id===i.data.deviceId)?.name;for(let t of i.data.zones)n.has(t.id)||(n.add(t.id),e.push({value:t.id,label:t.name,...r===void 0?{}:{hint:r}}))}return{options:e,loading:r.some(e=>e.isLoading),failed:r.some(e=>e.isError)}},[r,t])}function Fd(e){let t=_t().trpcClient,n=k({queries:e.map(e=>({queryKey:[[`nc-pickers`,`event-kinds`],{deviceId:e}],staleTime:6e4,queryFn:async()=>(await t.pipelineAnalytics.listEventKinds.query({deviceId:e})).map(e=>({kind:e.kind,label:e.label}))}))});return m(()=>{let e=new Map;for(let t of n)for(let n of t.data??[])e.has(n.kind)||e.set(n.kind,n.label);let t=[...e.entries()].map(([e,t])=>({value:e,label:t}));return t.sort((e,t)=>e.label.localeCompare(t.label)),{options:t,loading:n.some(e=>e.isLoading)}},[n])}function Id(e){let t=_t().trpcClient,n=k({queries:e.map(({deviceId:e})=>({queryKey:[[`nc-pickers`,`declared-events`],{deviceId:e}],staleTime:3e4,queryFn:async()=>t.deviceState.getCapSlice.query({deviceId:e,capName:jd})}))});return m(()=>Md(e.map((e,t)=>({...e,status:n[t]?.status??`pending`,data:n[t]?.data}))),[e,n])}function Ld(){let e=Br();return m(()=>({options:(e.data??[]).map(e=>({value:e.id,label:e.name})),loading:e.isLoading,failed:e.isError===!0}),[e.data,e.isLoading,e.isError])}function Rd(){let e=ja({limit:200}),t=Ea();return m(()=>{let n=new Set;for(let e of t.data??[])e.name.trim().length>0&&n.add(e.name);let r=new Set;for(let t of e.data??[])t.text.trim().length>0&&r.add(t.text);return[...[...n].sort(),...[...r].sort()]},[e.data,t.data])}function zd({options:e,value:t,onChange:n,loading:r,emptyHint:i,placeholder:a,noFreeText:o=!1}){let{t:c}=J(),[l,u]=w(``),d=m(()=>new Set(e.map(e=>e.value)),[e]),f=m(()=>new Set(t),[t]),p=t.filter(e=>!d.has(e)),h=e=>{n(f.has(e)?t.filter(t=>t!==e):[...t,e])},g=()=>{let e=l.trim();e.length===0||t.includes(e)||(n([...t,e]),u(``))};return s(`div`,{className:`mt-1 space-y-1.5`,children:[p.length>0&&x(`div`,{className:`flex flex-wrap gap-1`,children:p.map(e=>s(K,{variant:`unstyled`,type:`button`,onClick:()=>n(t.filter(t=>t!==e)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:c(`system.notificationRulePickers.customValueClickToRemove`,`Custom value — click to remove`),children:[e,` ×`]},e))}),e.length>0?x(`div`,{className:`max-h-40 overflow-y-auto rounded-md border border-border divide-y divide-border`,children:e.map(e=>s(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[x(Oe,{checked:f.has(e.value),onChange:()=>h(e.value),className:`accent-primary`}),x(`span`,{className:`flex-1 truncate`,children:e.label}),e.hint!==void 0&&x(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.hint})]},e.value))}):x(`p`,{className:`text-[10px] text-foreground-subtle`,children:r===!0?c(`common.loading`,`Loading…`):i}),!o&&x(G,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),g())},placeholder:a,className:`w-full rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground placeholder:text-foreground-subtle`})]})}var Bd=[{value:`immediate`,get label(){return q.t(`helpers.ruleFormParsers.immediate`)},get hint(){return q.t(`helpers.ruleFormParsers.immediateHint`)}},{value:`track-end`,get label(){return q.t(`helpers.ruleFormParsers.trackEnd`)},get hint(){return q.t(`helpers.ruleFormParsers.trackEndHint`)}},{value:`device-event`,get label(){return q.t(`helpers.ruleFormParsers.deviceEvent`)},get hint(){return q.t(`helpers.ruleFormParsers.deviceEventHint`)}},{value:`package-event`,get label(){return q.t(`helpers.ruleFormParsers.packageEvent`)},get hint(){return q.t(`helpers.ruleFormParsers.packageEventHint`)}},{value:`system-event`,get label(){return q.t(`helpers.ruleFormParsers.systemEvent`)},get hint(){return q.t(`helpers.ruleFormParsers.systemEventHint`)}}],Vd=`Immediate, grouped`,Hd=Bd.flatMap(e=>e.value===`immediate`?[e,{value:`immediate-grouped`,get label(){return q.t(`notificationRules.grouping.choice`)},get hint(){return q.t(`helpers.ruleFormParsers.groupedHint`)}}]:[e]);function Ud(e){return e.groupingSec!==void 0&&Rt(e)?`immediate-grouped`:e.delivery}function Wd(e){let t=(e.delivery===`immediate`||e.delivery===`track-end`)&&Rt({delivery:`immediate`,conditions:e.conditions});return Hd.filter(e=>e.value!==`immediate-grouped`||t)}function Gd(e){return Hd.find(t=>t.value===e)?.value}function Kd(e,t=Vd){return Ud(e)===`immediate-grouped`?`${t} · ${String(e.groupingSec)} s`:Jd(e.delivery)}function qd(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}function Jd(e){return Bd.find(t=>t.value===e)?.label??e}function Yd(e){return Bd.some(t=>t.value===e)}var Xd=[{key:`all`,get label(){return q.t(`helpers.ruleFormParsers.sec_all_label`)},get blurb(){return q.t(`helpers.ruleFormParsers.sec_all_blurb`)},get newRuleLabel(){return q.t(`helpers.ruleFormParsers.sec_all_new`)},get emptyHint(){return q.t(`helpers.ruleFormParsers.sec_all_empty`)},creatable:!0},{key:`detection`,get label(){return q.t(`helpers.ruleFormParsers.sec_detection_label`)},get blurb(){return q.t(`helpers.ruleFormParsers.sec_detection_blurb`)},get newRuleLabel(){return q.t(`helpers.ruleFormParsers.sec_detection_new`)},get emptyHint(){return q.t(`helpers.ruleFormParsers.sec_detection_empty`)},creatable:!0},{key:`sensor`,get label(){return q.t(`helpers.ruleFormParsers.sec_sensor_label`)},get blurb(){return q.t(`helpers.ruleFormParsers.sec_sensor_blurb`)},get newRuleLabel(){return q.t(`helpers.ruleFormParsers.sec_sensor_new`)},get emptyHint(){return q.t(`helpers.ruleFormParsers.sec_sensor_empty`)},creatable:!0},{key:`audio`,get label(){return q.t(`helpers.ruleFormParsers.sec_audio_label`)},get blurb(){return q.t(`helpers.ruleFormParsers.sec_audio_blurb`)},get newRuleLabel(){return q.t(`helpers.ruleFormParsers.sec_audio_new`)},get emptyHint(){return q.t(`helpers.ruleFormParsers.sec_audio_empty`)},creatable:!0},{key:`occupancy`,get label(){return q.t(`helpers.ruleFormParsers.sec_occupancy_label`)},get blurb(){return q.t(`helpers.ruleFormParsers.sec_occupancy_blurb`)},get newRuleLabel(){return q.t(`helpers.ruleFormParsers.sec_occupancy_new`)},get emptyHint(){return q.t(`helpers.ruleFormParsers.sec_occupancy_empty`)},creatable:!0},{key:`device-events`,get label(){return q.t(`helpers.ruleFormParsers.sec_deviceEvents_label`)},get blurb(){return q.t(`helpers.ruleFormParsers.sec_deviceEvents_blurb`)},get newRuleLabel(){return q.t(`helpers.ruleFormParsers.sec_deviceEvents_new`)},get emptyHint(){return q.t(`helpers.ruleFormParsers.sec_deviceEvents_empty`)},creatable:!0},{key:`system`,get label(){return q.t(`helpers.ruleFormParsers.sec_system_label`)},get blurb(){return q.t(`helpers.ruleFormParsers.sec_system_blurb`)},get newRuleLabel(){return q.t(`helpers.ruleFormParsers.sec_system_new`)},get emptyHint(){return q.t(`helpers.ruleFormParsers.sec_system_empty`)},creatable:!0},{key:`alarm`,get label(){return q.t(`helpers.ruleFormParsers.sec_alarm_label`)},get blurb(){return q.t(`helpers.ruleFormParsers.sec_alarm_blurb`)},get newRuleLabel(){return q.t(`helpers.ruleFormParsers.sec_alarm_new`)},get emptyHint(){return q.t(`helpers.ruleFormParsers.sec_alarm_empty`)},creatable:!0},{key:`mixed`,get label(){return q.t(`helpers.ruleFormParsers.sec_mixed_label`)},get blurb(){return q.t(`helpers.ruleFormParsers.sec_mixed_blurb`)},get newRuleLabel(){return q.t(`helpers.ruleFormParsers.sec_mixed_new`)},get emptyHint(){return q.t(`helpers.ruleFormParsers.sec_mixed_empty`)},creatable:!1}];function Zd(e){return Ct(Vt(e)).editable}function Qd(e){return vt($d(e))}function $d(e){switch(e){case`device-events`:case`system`:case`alarm`:case`mixed`:return e;default:return}}var ef=new Map([[0,`helpers.ruleFormParsers.cdNone`],[60,`helpers.ruleFormParsers.cd1m`],[3600,`helpers.ruleFormParsers.cd1h`]]),tf=86400;function nf(e){let t=ef.get(e);return t===void 0?e%3600==0?q.t(`helpers.ruleFormParsers.cdHours`,{count:e/3600}):e%60==0?q.t(`helpers.ruleFormParsers.cdMinutes`,{count:e/60}):q.t(`helpers.ruleFormParsers.cdSeconds`,{count:e}):q.t(t)}function rf(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}var af=[{value:`rule-device`,get label(){return q.t(`helpers.ruleFormParsers.scopeDevice`)}},{value:`rule`,get label(){return q.t(`helpers.ruleFormParsers.scopeRule`)}}];function of(e){return af.find(t=>t.value===e)?.value}var sf=[{value:`per-class`,get label(){return q.t(`helpers.ruleFormParsers.granPerClass`)}},{value:`shared`,get label(){return q.t(`helpers.ruleFormParsers.granShared`)}}];function cf(e){return sf.find(t=>t.value===e)?.value}var lf=[{value:`scene-boxes`,get label(){return q.t(`helpers.ruleFormParsers.imageSceneBoxes`)},get description(){return q.t(`helpers.ruleFormParsers.imageSceneBoxesDesc`)}},{value:`crop`,get label(){return q.t(`helpers.ruleFormParsers.imageCrop`)},get description(){return q.t(`helpers.ruleFormParsers.imageCropDesc`)}},{value:`clean`,get label(){return q.t(`helpers.ruleFormParsers.imageClean`)},get description(){return q.t(`helpers.ruleFormParsers.imageCleanDesc`)}},{value:`none`,get label(){return q.t(`helpers.ruleFormParsers.imageNone`)},get description(){return q.t(`helpers.ruleFormParsers.imageNoneDesc`)}}];function uf(e){return lf.find(t=>t.value===e)?.value}var df=[{value:``,get label(){return q.t(`helpers.ruleFormParsers.linkedDefault`)}},{value:`mosaic`,get label(){return q.t(`helpers.ruleFormParsers.linkedMosaic`)}},{value:`each`,get label(){return q.t(`helpers.ruleFormParsers.linkedEach`)}}];function ff(e){let t=df.find(t=>t.value===e)?.value;return t===``?void 0:t}var pf=[{value:``,get label(){return q.t(`helpers.ruleFormParsers.profileLowest`)}},{value:`low`,get label(){return q.t(`helpers.ruleFormParsers.profileLow`)}},{value:`mid`,get label(){return q.t(`helpers.ruleFormParsers.profileMid`)}},{value:`high`,get label(){return q.t(`helpers.ruleFormParsers.profileHigh`)}}];function mf(e){let t=pf.find(t=>t.value===e)?.value;return t===``?void 0:t}var hf=[{value:`any`,get label(){return q.t(`helpers.ruleFormParsers.srcAny`)}},{value:`pipeline`,get label(){return q.t(`helpers.ruleFormParsers.srcPipeline`)}},{value:`onboard`,get label(){return q.t(`helpers.ruleFormParsers.srcOnboard`)}},{value:`sensor`,get label(){return q.t(`helpers.ruleFormParsers.srcSensor`)}}],gf=[{value:`delivered`,get label(){return q.t(`helpers.ruleFormParsers.phaseDelivered`)}},{value:`picked-up`,get label(){return q.t(`helpers.ruleFormParsers.phasePickedUp`)}},{value:`both`,get label(){return q.t(`helpers.ruleFormParsers.phaseBoth`)}}],_f=[{value:``,get label(){return q.t(`helpers.ruleFormParsers.stBoth`)}},{value:`raised`,get label(){return q.t(`helpers.ruleFormParsers.stRaised`)}},{value:`cleared`,get label(){return q.t(`helpers.ruleFormParsers.stCleared`)}}];function vf(e){return e===`raised`||e===`cleared`?e:void 0}function yf(e,t){return e===`sensorTransition`?Sn(t.sensorKinds):!0}var bf=[{value:`enter`,get label(){return q.t(`helpers.ruleFormParsers.crossEnter`)}},{value:`exit`,get label(){return q.t(`helpers.ruleFormParsers.crossExit`)}},{value:`any`,get label(){return q.t(`helpers.ruleFormParsers.crossAny`)}}],xf=`enter`;function Sf(e){return e===`exit`||e===`any`?e:void 0}var Cf=[{value:1,get label(){return q.t(`helpers.ruleFormParsers.prioMin`)}},{value:2,get label(){return q.t(`helpers.ruleFormParsers.prioLow`)}},{value:3,get label(){return q.t(`helpers.ruleFormParsers.prioDefault`)}},{value:4,get label(){return q.t(`helpers.ruleFormParsers.prioHigh`)}},{value:5,get label(){return q.t(`helpers.ruleFormParsers.prioMax`)}}];function wf(e,t){return e.options&&e.options.length>0?e.options:t}var Tf=[{value:``,get label(){return q.t(`helpers.ruleFormParsers.speedDefault`)}},{value:`1`,get label(){return q.t(`helpers.ruleFormParsers.speedReal`)}},{value:`2`,label:`2×`},{value:`3`,label:`3×`},{value:`4`,label:`4×`},{value:`6`,label:`6×`},{value:`8`,label:`8×`}];function Ef(e){if(e===``)return;let t=Number(e);return Number.isFinite(t)&&t>=1&&t<=8?t:void 0}var Df={days:[0,1,2,3,4,5,6],minute:480},Of=[{value:1,get label(){return q.t(`helpers.notificationSystemEventDelivery.wd_mon`)}},{value:2,get label(){return q.t(`helpers.notificationSystemEventDelivery.wd_tue`)}},{value:3,get label(){return q.t(`helpers.notificationSystemEventDelivery.wd_wed`)}},{value:4,get label(){return q.t(`helpers.notificationSystemEventDelivery.wd_thu`)}},{value:5,get label(){return q.t(`helpers.notificationSystemEventDelivery.wd_fri`)}},{value:6,get label(){return q.t(`helpers.notificationSystemEventDelivery.wd_sat`)}},{value:0,get label(){return q.t(`helpers.notificationSystemEventDelivery.wd_sun`)}}];function kf(e){let t=Math.floor(e/60),n=e%60;return`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`}function Af(e){let[t,n]=e.split(`:`),r=Number(t)*60+Number(n);return Number.isFinite(r)?Math.max(0,Math.min(1439,r)):0}var jf={mode:`modes`,onActivation:!0,onDeactivation:!1};function Mf(e){return e!==void 0&&Ft.includes(e)}function Nf(e,t){return At({conditions:t.length>0?{systemEvent:{kinds:[...t]}}:{},...e===void 0?{}:{systemEventDelivery:e}})}function Pf(e){return{mode:`modes`,onActivation:e.onActivation,onDeactivation:e.onDeactivation}}function Ff(e,t,n){return t===`activation`?{...e,onActivation:n}:t===`deactivation`?{...e,onDeactivation:n}:n?e.onSchedule===void 0?{...e,onSchedule:{schedule:yt([Df]),grouping:`section`}}:e:Pf(e)}function If(e,t){return{...e,onSchedule:{schedule:t,grouping:e.onSchedule?.grouping??`section`}}}function Lf(e,t){return e.onSchedule===void 0?e:{...e,onSchedule:{...e.onSchedule,grouping:t}}}function Rf(e){let t=new Set,n=0;for(let r of e){let e=Mn(r);e===void 0?n+=1:t.add(e.label)}return{adds:[...t],without:n}}function zf(e){if(typeof e!=`object`||!e||!(`data`in e))return;let t=e.data;if(!(typeof t!=`object`||!t||!(`code`in t)))return typeof t.code==`string`?t.code:void 0}function Bf(e){let t=Object.entries(e).map(([e,t])=>`${e} ${String(t)}`);return t.length>0?q.t(`helpers.notificationSystemEventDelivery.dropped`,{parts:t.join(`, `)}):null}function Vf(e,t,n,r=`rule`){if(e===`error`)return zf(n)===`NOT_FOUND`?{lines:[`This hub does not serve summary rules yet — update @camstack/server first. A rule saved now would be stored without its summary, and stay instant.`]}:{lines:[`The preview could not be read: ${n instanceof Error?n.message:String(n)}`]};if(e!==`success`||t===void 0)return null;let i=[];if(r===`section`&&t.split===void 0&&i.push(`This hub does not send per-category summaries yet — update @camstack/server first. Until then it sends one message.`),t.empty)i.push(`Nothing to report right now — no notification would be sent.`);else if(t.split===`section`&&t.rows!==void 0){let e=t.rows.length;i.push(`${String(e)} notification${e===1?``:`s`} would be sent now, one per category:`);for(let e of t.rows)i.push(`${e.title}\n${e.text}`)}else i.push(`${String(t.count)} item(s) would be sent now:\n${t.text}`);let a=Bf(t.dropped);return a!==null&&i.push(a),t.excludedGroups.includes(`backups-exports`)&&i.push(`Backups and exports are completed jobs, not a state — they are not in a summary.`),{lines:i}}var Hf=`notificationRules.systemEventKinds.`,Uf=`notificationRules.systemEventGroups.`,Wf=`notificationRules.systemEventHints.`;function Gf(e){return!An.some(t=>t===e)}function Kf(e){let t=`${Hf}${e}`;return q.exists(t)?q.t(t):e}function qf(){return Ot.map(e=>({id:e.id,family:e.family,label:q.t(`${Uf}${e.id}`,e.label),hint:q.t(`${Wf}${e.id}`),kinds:e.kinds.filter(Gf).map(e=>({value:e,label:Kf(e)}))}))}function Jf(e){return qf().filter(t=>t.family===e)}function Yf(e){let t=Lt(e).conditions.systemEvent;return t===void 0?{kinds:(Jf(e)[0]?.kinds??[]).map(e=>e.value)}:{...t,kinds:[...t.kinds]}}function Xf(){return qf().flatMap(e=>e.kinds)}function Zf(e){return{devices:Tt(e,`deviceIds`),deviceTypes:Tt(e,`deviceTypes`),nodes:Tt(e,`nodeIds`),packages:Tt(e,`packageNames`),consumableThreshold:Tt(e,`consumableLowPercent`),commandActions:Tt(e,`commandActions`),commandOutcomes:Tt(e,`commandOutcomes`),commandActorKinds:Tt(e,`commandActorKinds`)}}function Qf(e,t){let n=Zt[e],r=Zf(t);return{devices:n.includes(`deviceIds`)&&r.devices,excludeDevices:n.includes(`excludeDeviceIds`)&&r.devices,deviceTypes:n.includes(`deviceTypes`)&&r.deviceTypes,nodes:n.includes(`nodeIds`)&&r.nodes,packages:n.includes(`packageNames`)&&r.packages,consumableThreshold:n.includes(`consumableLowPercent`)&&r.consumableThreshold,commandActions:n.includes(`commandActions`)&&r.commandActions,commandOutcomes:n.includes(`commandOutcomes`)&&r.commandOutcomes,commandActorKinds:n.includes(`commandActorKinds`)&&r.commandActorKinds}}var $f=Object.values(on).map(e=>({value:e,label:ep(e)})).toSorted((e,t)=>e.label.localeCompare(t.label));function ep(e){let t=e.replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function tp(e,t){let n=[],r=new Set;for(let i of e.kinds){let e=Mn(i.value);if(e===void 0){n.push({key:i.value,label:i.label,kinds:[i.value],clears:[i.value]});continue}r.has(e.id)||(r.add(e.id),n.push({key:`class:${e.id}`,label:t?e.snapshotLabel:e.label,kinds:t?[...e.bad]:Nt(e),clears:Nt(e),classId:e.id,...t&&e.snapshotSection===null?{noSnapshot:!0}:{}}))}return n}function np(e,t){return t.clears.some(t=>e.includes(t))}function rp(e,t,n){if(!Jf(n).some(e=>e.kinds.some(e=>t.kinds.includes(e.value))))return e;let r=e?.kinds??[];if(np(r,t)){let i=r.filter(e=>!t.clears.includes(e));return i.length===0?e:sp(e,i,n)}return sp(e,Xf().filter(e=>t.kinds.includes(e.value)||r.includes(e.value)).map(e=>e.value),n)}function ip(e,t){return t===void 0?void 0:sp(t,t.kinds,e)}function ap(e,t){let n=e?.kinds??[];if(n.length===0)return;let r=op(t,`deviceIds`,e?.deviceIds),i=op(t,`excludeDeviceIds`,e?.excludeDeviceIds),a=op(t,`deviceTypes`,e?.deviceTypes),o=op(t,`nodeIds`,e?.nodeIds),s=op(t,`packageNames`,e?.packageNames),c=Object.prototype.hasOwnProperty.call(t,`consumableLowPercent`)?t.consumableLowPercent:e?.consumableLowPercent;return{kinds:[...n],...r===void 0?{}:{deviceIds:[...r]},...i===void 0?{}:{excludeDeviceIds:[...i]},...a===void 0?{}:{deviceTypes:[...a]},...o===void 0?{}:{nodeIds:[...o]},...s===void 0?{}:{packageNames:[...s]},...c===void 0?{}:{consumableLowPercent:c}}}function op(e,t,n){let r=Object.prototype.hasOwnProperty.call(e,t)?e[t]:n;return r!==void 0&&r.length===0?void 0:r}function sp(e,t,n){let r=Qf(n,t),i=r.devices?e?.deviceIds:void 0,a=r.excludeDevices?e?.excludeDeviceIds:void 0,o=r.deviceTypes?e?.deviceTypes:void 0,s=r.nodes?e?.nodeIds:void 0,c=r.packages?e?.packageNames:void 0,l=r.consumableThreshold?e?.consumableLowPercent:void 0;return{kinds:[...t],...i&&i.length>0?{deviceIds:[...i]}:{},...a&&a.length>0?{excludeDeviceIds:[...a]}:{},...o&&o.length>0?{deviceTypes:[...o]}:{},...s&&s.length>0?{nodeIds:[...s]}:{},...c&&c.length>0?{packageNames:[...c]}:{},...l===void 0?{}:{consumableLowPercent:l}}}var cp=95;function lp(e){let t=e.trim();if(t===``)return{kind:`clear`};let n=Number(t);return Number.isInteger(n)&&n>=1&&n<=cp?{kind:`set`,value:n}:{kind:`invalid`}}function up(e,t=2){if(e===void 0||e.length===0)return q.t(`helpers.notificationSystemEvents.noneSelected`);let n=e.slice(0,t).map(Kf).join(`, `),r=e.length-Math.min(t,e.length);return r>0?`${n} +${r}`:n}function dp(e){if(e===void 0)return`—`;let t=[],n=e.deviceIds?.length??0,r=e.deviceTypes?.length??0,i=e.nodeIds?.length??0,a=e.packageNames?.length??0,o=e.excludeDeviceIds?.length??0;r>0&&t.push(e.deviceTypes?.map(ep).join(`, `)??``),n>0&&t.push(`${n} device${n===1?``:`s`}`),i>0&&t.push(`${i} node${i===1?``:`s`}`),a>0&&t.push(`${a} package${a===1?``:`s`}`);let s=o>0?`except ${o} device${o===1?``:`s`}`:null,c=e.consumableLowPercent===void 0?[]:[`consumables at ${e.consumableLowPercent}%`];return t.length===0?[s===null?`Everything`:`Everything ${s}`,...c].join(` · `):[...t,...s===null?[]:[s],...c].join(` · `)}function fp(e){return e===void 0||(e.deviceTypes?.length??0)===0?!1:e.kinds.some(e=>bn.includes(e))}var pp=[`all`,`only`,`except`];function mp(e,t){return(e??[]).length>0?`only`:(t??[]).length>0?`except`:`all`}function hp(e,t){let n=[...e??[]],r=[...t??[]];return{mode:mp(n,r),include:n,exclude:r,legacyBoth:n.length>0&&r.length>0}}function gp(e,t){return{...e,mode:t}}function _p(e){switch(e.mode){case`only`:return e.include;case`except`:return e.exclude;case`all`:return[]}}function vp(e,t){switch(e.mode){case`only`:return{...e,include:[...t]};case`except`:return{...e,exclude:[...t]};case`all`:return e}}function yp(e){return e.mode===`only`&&e.legacyBoth?e.exclude:[]}function bp(e){return{...e,exclude:[],legacyBoth:!1}}function xp(e){switch(e.mode){case`all`:return{};case`except`:return e.exclude.length>0?{exclude:[...e.exclude]}:{};case`only`:{let t=yp(e);return{...e.include.length>0?{include:[...e.include]}:{},...t.length>0?{exclude:[...t]}:{}}}}}function Sp(e){let t=xp(e),n=t.include??[],r=t.exclude??[];return[...e.include.filter(e=>!n.includes(e)),...e.exclude.filter(e=>!r.includes(e))]}var Cp=[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`],wp={onActivation:{get title(){return q.t(`helpers.notificationRuleActions.onActivationTitle`)},get hint(){return q.t(`helpers.notificationRuleActions.onActivationHint`)}},onDeactivation:{get title(){return q.t(`helpers.notificationRuleActions.onDeactivationTitle`)},get hint(){return q.t(`helpers.notificationRuleActions.onDeactivationHint`)}},onTrigger:{get title(){return q.t(`helpers.notificationRuleActions.onTriggerTitle`)},get hint(){return q.t(`helpers.notificationRuleActions.onTriggerHint`)}},onTriggerOff:{get title(){return q.t(`helpers.notificationRuleActions.onTriggerOffTitle`)},get hint(){return q.t(`helpers.notificationRuleActions.onTriggerOffHint`)}}},Tp={onActivation:[],onDeactivation:[],onTrigger:[],onTriggerOff:[],buttons:[]};function Ep(e){return e===void 0?Tp:{onActivation:[...e.onActivation??[]],onDeactivation:[...e.onDeactivation??[]],onTrigger:[...e.onTrigger??[]],onTriggerOff:[...e.onTriggerOff??[]],buttons:[...e.buttons??[]]}}function Dp(e){let t=e.buttons.filter(e=>e.id.trim()!==``&&e.label.trim()!==``&&e.actionId.trim()!==``),n=e=>e.filter(e=>e.trim()!==``),r={onActivation:n(e.onActivation),onDeactivation:n(e.onDeactivation),onTrigger:n(e.onTrigger),onTriggerOff:n(e.onTriggerOff)};if(!(!Cp.some(e=>r[e].length>0)&&t.length===0))return{...r.onActivation.length>0?{onActivation:[...r.onActivation]}:{},...r.onDeactivation.length>0?{onDeactivation:[...r.onDeactivation]}:{},...r.onTrigger.length>0?{onTrigger:[...r.onTrigger]}:{},...r.onTriggerOff.length>0?{onTriggerOff:[...r.onTriggerOff]}:{},...t.length>0?{buttons:t}:{}}}function Op(e,t){let n=[];for(let r of Cp){let i=e[r];i.length>4&&n.push({kind:`too-many`,message:q.t(`helpers.notificationRuleActions.tooMany`,{title:wp[r].title})}),i.some(e=>e.trim()!==``&&!t.has(e))&&n.push({kind:`unknown-action`,message:q.t(`helpers.notificationRuleActions.hookUnknownAction`,{title:wp[r].title})})}let r=new Set;for(let i of e.buttons){let e=i.id.trim();e!==``&&(r.has(e)&&n.push({kind:`duplicate-button`,message:q.t(`helpers.notificationRuleActions.dupButton`,{id:e})}),r.add(e),t.has(i.actionId.trim())||n.push({kind:`unknown-action`,message:q.t(`helpers.notificationRuleActions.buttonUnknownAction`,{label:i.label||e})}))}return n}function kp(e,t){return{id:`action-${String(e+1)}`,label:q.t(`helpers.notificationRuleActions.newButtonLabel`),actionId:t}}var Ap=[{value:`acknowledge`,get label(){return q.t(`helpers.notificationRuleActions.icon_acknowledge`)}},{value:`dismiss`,get label(){return q.t(`helpers.notificationRuleActions.icon_dismiss`)}},{value:`silence`,get label(){return q.t(`helpers.notificationRuleActions.icon_silence`)}},{value:`snooze`,get label(){return q.t(`helpers.notificationRuleActions.icon_snooze`)}},{value:`view`,get label(){return q.t(`helpers.notificationRuleActions.icon_view`)}},{value:`play`,get label(){return q.t(`helpers.notificationRuleActions.icon_play`)}},{value:`camera`,get label(){return q.t(`helpers.notificationRuleActions.icon_camera`)}},{value:`open`,get label(){return q.t(`helpers.notificationRuleActions.icon_open`)}},{value:`close`,get label(){return q.t(`helpers.notificationRuleActions.icon_close`)}},{value:`unlock`,get label(){return q.t(`helpers.notificationRuleActions.icon_unlock`)}},{value:`lock`,get label(){return q.t(`helpers.notificationRuleActions.icon_lock`)}},{value:`disarm`,get label(){return q.t(`helpers.notificationRuleActions.icon_disarm`)}},{value:`arm`,get label(){return q.t(`helpers.notificationRuleActions.icon_arm`)}},{value:`arm-home`,get label(){return q.t(`helpers.notificationRuleActions.icon_arm_home`)}},{value:`arm-away`,get label(){return q.t(`helpers.notificationRuleActions.icon_arm_away`)}},{value:`arm-night`,get label(){return q.t(`helpers.notificationRuleActions.icon_arm_night`)}},{value:`light`,get label(){return q.t(`helpers.notificationRuleActions.icon_light`)}},{value:`alert`,get label(){return q.t(`helpers.notificationRuleActions.icon_alert`)}}];function jp(e){let t=new Set;for(let n of Cp)for(let r of e[n])r.trim()!==``&&t.add(r);for(let n of e.buttons)n.actionId.trim()!==``&&t.add(n.actionId);return t}function Mp(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of jp(e))r.push(...n.get(t)?.steps??[]);return r}var Np=[10,30,60],Pp=[5,10,15,30,60,120,240,480];function Fp(e){return e>=60&&e%60==0?q.t(`helpers.ruleFormState.snoozeHours`,{count:e/60}):q.t(`helpers.ruleFormState.snoozeMin`,{count:e})}var Ip=new Set([`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`]);function Lp(e,t){for(let t of e.systemEvent?.kinds??[])if(Ip.has(t))return!0;for(let e of t)if(yn(e))return!0;return!1}function Rp(e,t){return Mp(e,t)}function zp(e){let{devices:t,devicesExclude:n,classes:r,classesExclude:i,...a}=e;return{conditions:a,deviceScope:hp(t,n),classScope:hp(r,i)}}function Bp(e){let t=xp(e.deviceScope),n=xp(e.classScope);return{...e.conditions,...t.include===void 0?{}:{devices:[...t.include]},...t.exclude===void 0?{}:{devicesExclude:[...t.exclude]},...n.include===void 0?{}:{classes:[...n.include]},...n.exclude===void 0?{}:{classesExclude:[...n.exclude]}}}function Vp(e){return e.deviceScope.mode===`only`?e.deviceScope.include:[]}function Hp(e,t,n){let r=Vt(n);return e.some(e=>e.id===t&&xt(e,n.delivery,r))}function Up(e=`immediate`,t={}){return{name:``,tags:[],enabled:!0,delivery:e,targetIds:[],targetUsers:[],targetParams:{},targetOverrides:{},priority:3,mediaImage:Gt({},Vt({delivery:e,conditions:t})),mediaShowTriggerZone:!1,mediaShowSubjectPath:!1,mediaGif:!1,mediaClip:!1,mediaProfile:void 0,mediaClipSpeed:void 0,mediaLinkedCameras:void 0,mediaWakeSleepingCamera:void 0,templateTitle:``,templateBody:``,...zp(t),schedule:void 0,systemEventDelivery:e===`system-event`?jf:void 0,snoozeAllowGlobal:!1,groupingSec:void 0,groupWithinSec:Kt({delivery:e}),snoozeOptions:void 0,askVerdict:void 0,actions:Tp,cooldownSec:30,cooldownScope:`rule-device`,cooldownGranularity:void 0}}function Wp(e){let t={};for(let n of e.targets)n.params&&Object.keys(n.params).length>0&&(t[n.targetId]=n.params);return{name:e.name,tags:e.tags??[],enabled:e.enabled,delivery:e.delivery,targetIds:e.targets.map(e=>e.targetId),targetUsers:e.targetUsers??[],targetParams:t,targetOverrides:e.targetOverrides??{},priority:e.priority,mediaImage:Gt(e.media,Vt(e)),mediaShowTriggerZone:e.media.showTriggerZone===!0,mediaShowSubjectPath:e.media.showSubjectPath===!0,mediaGif:e.media.gif===!0,mediaClip:e.media.clip===!0,mediaProfile:e.media.profile,mediaClipSpeed:e.media.clipSpeed,mediaLinkedCameras:e.media.linkedCameras,mediaWakeSleepingCamera:e.media.wakeSleepingCamera,templateTitle:e.template?.title??``,templateBody:e.template?.body??``,...zp(e.conditions),schedule:e.schedule,systemEventDelivery:e.systemEventDelivery,snoozeAllowGlobal:e.snoozeAllowGlobal===!0,groupingSec:e.groupingSec,groupWithinSec:Kt(e),snoozeOptions:e.snoozeOptions,askVerdict:e.askVerdict,actions:Ep(e.actions),cooldownSec:e.throttle.cooldownSec,cooldownScope:e.throttle.scope,cooldownGranularity:e.throttle.granularity}}function Gp(e,t){let n=[],r=e.groupWithinSec;if((!Number.isInteger(r)||r<0||r>300)&&n.push(`Group notifications within is a whole number of seconds between 0 and 300.`),em(e)){let r=e.groupingSec;r!==void 0&&(!Number.isInteger(r)||r<5||r>60)&&n.push(`The grouping window is a whole number of seconds between 5 and 60.`);let i=t?.confirm;i?.enabled===!0&&i.expect!==void 0&&!tm(i.expect)&&n.push(`This rule’s AI confirm expects more than one subject, but a grouped message judges one picture per subject, so it would never send. Remove the confirm expectation (viewer or API), or choose Immediate.`)}if(Fn(e.conditions.audio)&&n.push(`This sound rule names neither a sound nor a level threshold, so it can never fire — every sample would count as a hit and the engine refuses it rather than notifying on silence. Pick at least one sound, or add a level.`),(!Number.isInteger(e.cooldownSec)||e.cooldownSec<0||e.cooldownSec>86400)&&n.push(`The cooldown is a whole number of seconds between 0 and ${String(tf)} (24 hours). 0 means every match is delivered.`),Cn(e.delivery))for(let t of qt({delivery:e.delivery,conditions:e.conditions,...e.systemEventDelivery===void 0?{}:{systemEventDelivery:e.systemEventDelivery},...Dp(e.actions)===void 0?{}:{actions:Dp(e.actions)}}))n.push(Ut(t));return n}function Kp(e){let t=e.systemEventDelivery;if(t===void 0)return{};if(!Cn(e.delivery))return t.mode===`instant`?{}:{systemEventDelivery:{mode:`instant`}};let n=en(e.conditions.systemEvent?.kinds??[]);if(!(n.kind===`family`&&Ft.includes(n.family)))return t.mode===`modes`?{}:{systemEventDelivery:t};let r=rn({systemEventDelivery:t}).schedule;if(r!==null&&Et(r.schedule)===null){let e=Xt(r.schedule);if(e!==null&&e.times.length>0){let n=yt(e.times,r.schedule.timezone);if(t.mode===`modes`)return{systemEventDelivery:{...t,onSchedule:{...r,schedule:n}}};if(t.mode===`summary`)return{systemEventDelivery:{...t,schedule:n}}}}return{systemEventDelivery:t}}function qp(e){if(!Jp(e))return null;if(!wt(e.templateBody))return q.t(`helpers.ruleFormState.summaryWarnNone`,{token:`{{summaryText}}`});let t=e.templateBody;return Qt({...e.systemEventDelivery===void 0?{}:{systemEventDelivery:e.systemEventDelivery}})===`section`&&t.trim().length>0&&!/\{\{\s*summaryText\s*\}\}/.test(t)?q.t(`helpers.ruleFormState.summaryWarnSplit`,{token:`{{summaryText}}`}):null}function Jp(e){return Wn({delivery:e.delivery,...e.systemEventDelivery===void 0?{}:{systemEventDelivery:e.systemEventDelivery}})}function Yp(e,t,n=new Set){return Gp(e,t).length===0&&Yd(e.delivery)&&(!Cn(e.delivery)||am(e)>0)&&Vt(e)!==`mixed`&&e.name.trim().length>0&&(e.targetIds.length>0||e.targetUsers.length>0)&&Op(e.actions,n).length===0}function Xp(e,t){let n=rm(e.conditions,t),r=Cn(t)&&(n.systemEvent?.kinds.length??0)===0,i=Cn(t)&&e.systemEventDelivery===void 0?jf:e.systemEventDelivery;return r?{...e,delivery:t,systemEventDelivery:i,conditions:{...n,systemEvent:Yf(`device-events`)}}:{...e,delivery:t,conditions:n,systemEventDelivery:i}}function Zp(e,t){return t===`immediate-grouped`?Qp(e,{...Xp(e,`immediate`),groupingSec:e.groupingSec??20}):Qp(e,{...Xp(e,t),groupingSec:void 0})}function Qp(e,t){let n=Kt({delivery:e.delivery}),r=Kt({delivery:t.delivery}),i=e.groupWithinSec!==n;return{...t,groupWithinSec:i?e.groupWithinSec:r}}function $p(e){return e.delivery===`immediate`||e.delivery===`track-end`}function em(e){return e.groupingSec!==void 0&&Rt(e)}function tm(e){switch(e.op){case`>`:return 1>e.count;case`<=`:return 1<=e.count;case`<`:return 1<e.count;case`==`:return e.count===1;default:return 1>=e.count}}var nm=new Set([`immediate`,`track-end`,`package-event`]);function rm(e,t){if(e.source!==`pipeline`||nm.has(t))return e;let{source:n,...r}=e;return r}function im(e,t){return Gn(e.conditions.systemEvent)===t?e:{...e,conditions:{...e.conditions,systemEvent:Yf(t)}}}function am(e){return e.conditions.systemEvent?.kinds.length??0}function om(e,t){return n=>{let r=e.find(e=>e.id===n);if(r===void 0)return;let i=t.find(e=>e.kind===r.kind&&e.addonId===r.addonId)?.caps;return i===void 0?void 0:Nn(i)}}function sm(e,t,n){let r=om(t,n),i=Mt(e.map(e=>({name:t.find(t=>t.id===e)?.name??e,fields:r(e)})));return new Map(i.map(e=>[e.field,e]))}function cm(e,t,n){let r={};for(let i of e){let e=t[i];if(e===void 0)continue;let a=nn(e,n?.(i));a!==void 0&&(r[i]=a)}return r}function lm(e,t,n){let{[t]:r,...i}=e;return n===void 0?i:{...i,[t]:n}}function um(e,t,n,r){let{[t]:i,...a}=e,{[n]:o,...s}=i??{},c=r===void 0?s:{...s,[n]:r};return Object.keys(c).length===0?a:{...a,[t]:c}}function dm(e,t,n){let r=t.find(t=>t.id===e);if(r===void 0)return;let i=n.find(e=>e.kind===r.kind&&e.addonId===r.addonId)?.caps;if(i!==void 0)return{levels:sn(i),attachmentKinds:Pt(i)}}var fm={rule:{fields:[`title`,`body`,`priority`,`attachments`,`actions`],attachmentKinds:[`none`,`image`,`clip`,`gif`]},summary:{fields:[`title`,`body`,`priority`,`attachments`],attachmentKinds:[`none`,`image`]},timelapse:{fields:[`title`,`body`,`priority`,`attachments`],attachmentKinds:[`none`,`image`,`clip`]},"calendar-events":{fields:[`title`,`body`,`priority`],attachmentKinds:[]}};function pm(e,t){return fm[e].fields.includes(t)}function mm(e,t){let n=fm[e].attachmentKinds;return t.filter(e=>n.includes(e))}function hm(e){return e.map(e=>({id:e.id,name:e.name,enabled:e.enabled,kind:e.kind??``,addonId:e.addonId??``,config:{}}))}function gm(e,t){return e.appliesTo.includes(t)}var _m={source:`any`};function vm(e,t){if(t==null)return!0;if(Array.isArray(t))return t.length===0;if(typeof t==`string`)return t.length===0||_m[e]===t;if(typeof t==`number`)return!Number.isFinite(t);if(typeof t==`object`){if(`ids`in t){let e=t.ids;return!Array.isArray(e)||e.length===0}if(`values`in t){let e=t.values;return!Array.isArray(e)||e.length===0}return!1}return!1}var ym=dn.filter(e=>e.id===`audio`);function bm(e){if(e.length===0)return e;let t=new Set(e.map(e=>e.id)),n=ym.filter(e=>!t.has(e.id));return n.length===0?e:[...e,...n]}function xm(e,t,n,r=Vt({delivery:t,conditions:e})){let i=n.length===0?null:new Set(n.filter(e=>e.id!==`schedule`&&xt(e,t,r)).map(e=>e.id)),a={};for(let[t,n]of Object.entries(e))i!==null&&!i.has(t)||yf(t,e)&&(vm(t,n)||(a[t]=n));return a}function Sm(e,t){if(e===void 0)return{};let n=ip(e,t.systemEvent);return n===void 0?{}:{systemEvent:n}}function Cm(e){return e!==void 0&&e.windows.length>0}function wm(e){let t={...e.clipPreRollSec===void 0?{}:{clipPreRollSec:e.clipPreRollSec},...e.clipPostRollSec===void 0?{}:{clipPostRollSec:e.clipPostRollSec}};return Object.keys(t).length>0?t:void 0}function Tm(e){let t=wm(e.media);return{...e.confirm===void 0?{}:{confirm:e.confirm},...t===void 0?{}:{media:t}}}function Em(e,t,n=[],r){let i=e.templateTitle.trim(),a=e.templateBody.trim(),o=i.length>0||a.length>0?{...i.length>0?{title:i}:{},...a.length>0?{body:a}:{}}:void 0,s=Dp(e.actions),c=Vt(e),l=Ct(c),u=Wt(c),d=n.length===0?!0:n.some(t=>t.id===`schedule`&&gm(t,e.delivery)),f=!Jp(e)&&d&&Cm(e.schedule)?e.schedule:void 0,p=n.length===0?!0:n.some(t=>t.id===`devices`&&gm(t,e.delivery)),m=n.length===0?!0:n.some(t=>t.id===`devicesExclude`&&gm(t,e.delivery)),{devices:h,devicesExclude:g,..._}=Bp(e),v=xm(_,e.delivery,n,c);return{name:e.name.trim(),tags:[...e.tags],enabled:e.enabled,delivery:e.delivery,conditions:{...v,...p&&h!==void 0?{devices:h}:{},...m&&g!==void 0?{devicesExclude:g}:{},...Sm(u,e.conditions)},...f?{schedule:f}:{},...Kp(e),targets:e.targetIds.map(t=>{let n=e.targetParams[t];return n&&Object.keys(n).length>0?{targetId:t,params:n}:{targetId:t}}),...e.targetUsers.length>0?{targetUsers:[...e.targetUsers]}:{},targetOverrides:cm(e.targetIds,e.targetOverrides,r),media:l.carriesMedia?{image:e.mediaImage,...e.mediaShowTriggerZone&&e.mediaImage!==`crop`&&e.mediaImage!==`none`&&bt(v).length>0?{showTriggerZone:!0}:{},...e.mediaShowSubjectPath&&e.mediaImage!==`none`&&Un(c)?{showSubjectPath:!0}:{},...e.mediaGif?{gif:!0}:{},...e.mediaClip?{clip:!0}:{},...e.mediaProfile===void 0?{}:{profile:e.mediaProfile},...e.mediaClipSpeed===void 0?{}:{clipSpeed:e.mediaClipSpeed},...c===`sensor`&&e.mediaImage!==`none`&&e.mediaLinkedCameras!==void 0?{linkedCameras:e.mediaLinkedCameras}:{},...c===`sensor`&&e.mediaImage!==`none`&&e.mediaWakeSleepingCamera===!1?{wakeSleepingCamera:!1}:{},...(e.mediaGif||e.mediaClip)&&t?.media?.clipPreRollSec!==void 0?{clipPreRollSec:t.media.clipPreRollSec}:{},...(e.mediaGif||e.mediaClip)&&t?.media?.clipPostRollSec!==void 0?{clipPostRollSec:t.media.clipPostRollSec}:{}}:{image:`none`},throttle:{cooldownSec:e.cooldownSec,scope:e.cooldownScope,...e.cooldownGranularity===void 0?{}:{granularity:e.cooldownGranularity}},priority:e.priority,...o?{template:o}:{},...e.snoozeAllowGlobal?{snoozeAllowGlobal:!0}:{},...em(e)?{groupingSec:e.groupingSec}:{},groupWithinSec:e.groupWithinSec,...e.snoozeOptions===void 0?{}:{snoozeOptions:[...e.snoozeOptions]},...e.askVerdict!==void 0&&$p(e)?{askVerdict:e.askVerdict}:{},...t?.confirm===void 0?{}:{confirm:t.confirm},...s===void 0?{}:{actions:s}}}function Dm(e,t){let n=Em(e,void 0,t);return[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`groupingSec`,`actions`].filter(e=>n[e]===void 0)}var Om=[{key:`rule`,get label(){return q.t(`helpers.ruleFormTabs.tab_rule`)},fields:[`name`,`tags`,`enabled`,`delivery`,`groupingSec`,`groupWithinSec`,`targetIds`,`targetUsers`,`targetParams`,`targetOverrides`]},{key:`devices`,get label(){return q.t(`helpers.ruleFormTabs.tab_devices`)},fields:[`deviceScope`]},{key:`conditions`,get label(){return q.t(`helpers.ruleFormTabs.tab_conditions`)},fields:[`conditions`,`classScope`,`schedule`]},{key:`notification`,get label(){return q.t(`helpers.ruleFormTabs.tab_notification`)},fields:[`priority`,`mediaImage`,`mediaShowTriggerZone`,`mediaShowSubjectPath`,`mediaGif`,`mediaClip`,`mediaProfile`,`mediaClipSpeed`,`mediaLinkedCameras`,`mediaWakeSleepingCamera`,`templateTitle`,`templateBody`,`systemEventDelivery`]},{key:`actions`,get label(){return q.t(`helpers.ruleFormTabs.tab_actions`)},fields:[`actions`]},{key:`advanced`,get label(){return q.t(`helpers.ruleFormTabs.tab_advanced`)},fields:[`snoozeAllowGlobal`,`snoozeOptions`,`askVerdict`,`cooldownSec`,`cooldownScope`,`cooldownGranularity`]}];function km(e,t={}){let n=Vt({delivery:e,conditions:t}),r=Ct(n),i=Om.map(e=>e.key===`conditions`?{...e,label:r.label}:e);return vt(n)?i.filter(e=>e.key!==`devices`):i}function Am(e){if(e.audio!==void 0)return q.t(`helpers.ruleFormTabs.condSound`);if(e.occupancy!==void 0)return q.t(`helpers.ruleFormTabs.condOccupancy`)}function jm(e){let t=Vt(e),n=zt(Bp(e),t);return t===`sensor`&&e.conditions.sensorTransition!==void 0&&!yf(`sensorTransition`,e.conditions)?[...n,{conditionId:`sensorTransition`,reason:In}]:n}var Mm=`rule`;function Nm(e){return Om.find(t=>t.key===e)?.key}function Pm(e){return e?.toLowerCase().startsWith(`it`)===!0?`it`:`en`}function Fm(){let{i18n:e}=J(),t=Pm(e.language);return e=>Bt(e,t)}O();var Im=`block text-[11px] font-medium text-foreground`,Lm=`text-[10px] text-foreground-subtle mt-0.5`;function Rm({cameras:e,fleet:t,value:n,onChange:r,emptyMeansAll:i=!1,savedHadDevices:a=!1}){return x(Ur,{devices:e,listState:t.state,fleet:t,value:n,onChange:r,emptyMeansAll:i,savedHadDevices:a})}function zm({value:e,placeholder:t,onChange:n}){let{t:r}=J(),[i,a]=w(``),o=()=>{let t=i.trim();if(t.length===0||e.includes(t)){a(``);return}n([...e,t]),a(``)},c=t=>n(e.filter(e=>e!==t));return s(`div`,{className:`mt-1 space-y-1.5`,children:[e.length>0&&x(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>s(`span`,{className:`inline-flex items-center gap-1 rounded bg-surface-hover px-1.5 py-0.5 text-[11px] text-foreground`,children:[e,x(K,{variant:`unstyled`,type:`button`,onClick:()=>c(e),"aria-label":r(`system.notificationConditionWidgets.remove`,`remove {{v}}`,{v:e}),className:`text-foreground-subtle hover:text-danger`,children:x(_e,{className:`h-3 w-3`})})]},e))}),x(G,{value:i,placeholder:t,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())},onBlur:o})]})}function Bm({picker:e,value:t,onChange:n}){let{t:r}=J(),i=m(()=>ln(e),[e]),a=m(()=>new Set(t),[t]),o=t.filter(e=>!i.has(e)),c=e=>{n(a.has(e)?t.filter(t=>t!==e):[...t,e])};return s(`div`,{className:`space-y-2`,children:[o.length>0&&x(`div`,{className:`flex flex-wrap gap-1`,children:o.map(e=>s(K,{variant:`unstyled`,type:`button`,onClick:()=>n(t.filter(t=>t!==e)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:r(`system.notificationConditionWidgets.customValueClickToRemove`,`Custom value — click to remove`),children:[e,` ×`]},e))}),e.groups.map(e=>s(`div`,{children:[x(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-muted mb-1`,children:e.fallbackLabel}),x(`div`,{className:`flex flex-wrap gap-1`,children:e.options.map(e=>{let t=a.has(e.value);return x(K,{variant:`unstyled`,type:`button`,"aria-pressed":t,onClick:()=>c(e.value),className:t?`rounded border border-primary bg-primary/15 px-1.5 py-0.5 text-[10px] text-foreground`:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,children:e.label},e.value)})})]},e.key))]})}function Vm({value:e,min:t,max:n,step:r,onChange:i}){let{t:a}=J();return s(`div`,{className:`mt-1 flex items-center gap-2`,children:[x(G,{type:`number`,value:e??``,min:t,max:n,step:r,className:`max-w-[8rem]`,onChange:e=>{let t=e.target.value;if(t===``){i(void 0);return}let n=Number(t);i(Number.isFinite(n)?n:void 0)}}),e!==void 0&&n!==void 0&&x(de,{min:t,max:n,step:r,value:e,onChange:e=>i(Number(e.target.value)),className:`flex-1 accent-primary`,"aria-label":a(`common.valueWord`)})]})}function Hm({value:e,onChange:t,options:n}){let{t:r}=J(),i=Um(n??[]),a=i.length>0?i:bf;return s(`div`,{className:`mt-1 space-y-1`,children:[x(He,{value:e??`enter`,options:a.map(e=>({value:e.value,label:r(`notificationRules.crossing.${e.value}`,e.label)})),onChange:e=>t(Sf(e.target.value))}),x(`p`,{className:Lm,children:r(`notificationRules.crossing.hint`,`Which way the subject crosses the zone.`)})]})}function Um(e){let t=[];for(let n of e){let e=n.value===``||n.value===`enter`?xf:Sf(n.value);e===void 0||t.some(t=>t.value===e)||t.push({value:e,label:n.label})}return t}function Wm({deviceIds:e,cameras:t,value:n,onChange:r}){let{options:i,loading:a}=Pd(e,t);return x(zd,{options:i,value:n,onChange:r,loading:a,noFreeText:!0,emptyHint:e.length===0?`Select cameras first — a rule can only use zones those cameras actually have.`:`The selected cameras have no zones. Draw one in the camera’s zone editor first.`,placeholder:``})}function Gm({deviceIds:e,cameras:t,allDevices:n,value:r,onChange:i}){let{t:a}=J(),{options:o,loading:c}=Fd(e),l=Id(m(()=>Nd(e,t,n),[e,t,n]));return s(I,{children:[x(zd,{options:m(()=>{let e=new Set(l.options.map(e=>e.value));return[...l.options,...o.filter(t=>!e.has(t.value))]},[l.options,o]),value:r,onChange:i,loading:c||l.pending,emptyHint:e.length===0?a(`system.notificationConditionWidgets.eventTokensSelectDevices`,`Select a device above to pick one of its events — or type a token.`):a(`system.notificationConditionWidgets.eventTokensNone`,`The selected devices declare no events — type a token.`),placeholder:a(`system.notificationConditionWidgets.eventToken`,`Event token…`)}),l.unknownDevices.length>0&&x(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:a(`system.notificationConditionWidgets.eventTokensUnknown`,`Could not read the events of: {{devices}}. They are unknown, not absent.`,{devices:l.unknownDevices.join(`, `)})})]})}var Km=[{value:`became-occupied`,labelKey:`system.notificationConditionWidgets.opBecameOccupied`},{value:`became-free`,labelKey:`system.notificationConditionWidgets.opBecameFree`},{value:`>=`,labelKey:`system.notificationConditionWidgets.opCountAtLeast`},{value:`<=`,labelKey:`system.notificationConditionWidgets.opCountAtMost`}];function qm(e,t){let n=e.map(e=>({value:e.value,label:e.label}));return t===void 0||t===``||n.some(e=>e.value===t)?n:[...n,{value:t,label:q.t(`system.notificationConditionWidgets.subTypeNeverCountsAlways`,`{{stored}} — sub-type, never counts (always 0)`,{stored:t})}]}function Jm({deviceIds:e,cameras:t,classOptions:n,value:r,onChange:i}){let{t:a}=J(),{options:o,loading:c}=Pd(e,t),l=r??St,u=e=>i({...l,...e}),d=l.op===`became-occupied`||l.op===`became-free`,f=qm(n,l.className);return s(`div`,{className:`mt-1 space-y-1.5`,children:[s(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[x(`div`,{className:`min-w-[10rem]`,children:x(He,{value:l.zoneId??``,options:[{value:``,label:c?a(`system.notificationConditionWidgets.loadingZones`,`Loading zones…`):a(`system.notificationConditionWidgets.wholeFrame`,`— whole frame —`)},...o.map(e=>({value:e.value,label:e.label}))],onChange:e=>u({zoneId:e.target.value===``?void 0:e.target.value})})}),x(`div`,{className:`min-w-[9rem]`,children:x(He,{value:l.className??``,options:[{value:``,label:a(`system.notificationConditionWidgets.anyClass`,`— any class —`)},...f],onChange:e=>u({className:e.target.value===``?void 0:e.target.value})})}),x(`div`,{className:`min-w-[9rem]`,children:x(He,{value:l.op,options:Km.map(e=>({value:e.value,label:a(e.labelKey)})),onChange:e=>{let t=Km.find(t=>t.value===e.target.value);t&&u({op:t.value})}})})]}),s(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[s(`label`,{className:`flex items-center gap-1`,children:[d?a(`system.notificationConditionWidgets.threshold`,`Threshold`):a(`system.notificationConditionWidgets.count`,`Count`),x(G,{type:`number`,min:0,className:`w-16`,value:String(l.count),onChange:e=>u({count:Math.max(0,Number(e.target.value)||0)})})]}),s(`label`,{className:`flex items-center gap-1`,children:[a(`system.notificationConditionWidgets.holdFor`,`Hold for`),x(G,{type:`number`,min:0,max:3600,className:`w-16`,value:String(l.sustainSeconds),onChange:e=>u({sustainSeconds:Math.min(3600,Math.max(0,Number(e.target.value)||0))})}),`s`]}),r===void 0?null:x(K,{variant:`unstyled`,type:`button`,onClick:()=>i(void 0),className:`underline hover:text-foreground`,children:a(`system.notificationConditionWidgets.clear`,`Clear`)})]}),e.length===0&&x(`p`,{className:`text-[11px] text-warning`,children:a(`system.notificationConditionWidgets.noCameraPickedOnThe`,`No camera picked on the Devices tab: this watches EVERY camera's occupancy, and no zone can be offered until you choose one — a zone id belongs to a camera.`)}),x(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`system.notificationConditionWidgets.countsConfirmedTrackedObjectsFrom`,`Counts confirmed tracked objects from zone analytics. The change must hold for the sustain window before it fires; with no snapshot for the camera or zone the rule never fires.`)})]})}var Ym=[{value:`label`,labelKey:`system.notificationConditionWidgets.audioModeLabel`,Icon:ee},{value:`level`,labelKey:`system.notificationConditionWidgets.audioModeLevel`,Icon:Se}];function Xm({taxonomy:e,value:t,onChange:n}){let{t:r}=J(),i=jn(t),a=e=>n(mn(t,e)),{choices:o,unknownLabels:c}=xn(e,i.labels),l=fn(t)??`label`;return s(`div`,{className:`mt-1 space-y-2`,children:[s(`div`,{className:`flex flex-wrap items-center gap-1`,children:[Ym.map(e=>x(K,{variant:`unstyled`,type:`button`,"aria-pressed":l===e.value,onClick:()=>a({mode:e.value}),className:`rounded border px-2 py-0.5 text-[11px] ${l===e.value?`border-primary bg-primary/15 text-foreground`:`border-border text-foreground-subtle hover:bg-surface-hover`}`,children:s(`span`,{className:`inline-flex items-center gap-1`,children:[x(e.Icon,{className:`h-3 w-3`}),r(e.labelKey)]})},e.value)),t===void 0?null:x(K,{variant:`unstyled`,type:`button`,onClick:()=>n(void 0),className:`ml-1 text-xs text-foreground-subtle underline hover:text-foreground`,children:r(`system.notificationConditionWidgets.clear`,`Clear`)})]}),l===`label`?s(I,{children:[x(`div`,{className:`flex flex-wrap gap-1`,children:o.map(e=>{let t=zn(i.labels,e.value),n=e.unknown?`border-dashed border-warning text-warning`:t?`border-primary bg-primary/15 text-foreground`:`border-border text-foreground hover:bg-surface-hover`;return x(K,{variant:`unstyled`,type:`button`,"aria-pressed":t,title:e.unknown?r(`system.notificationConditionWidgets.storedByTheRuleNot`,`Stored by the rule — not offered by this hub`):void 0,onClick:()=>a({labels:wn(i.labels,e.value)}),className:`rounded border px-1.5 py-0.5 text-[10px] ${n}`,children:s(`span`,{className:`inline-flex items-center gap-1`,children:[x(aa,{iconId:e.iconId,size:12}),e.label]})},e.value)})}),c.length>0&&s(`p`,{className:`text-[10px] text-warning`,children:[r(`system.notificationConditionWidgets.keptFromTheRuleUnknown`,`Kept from the rule, unknown to this hub:`),` `,c.join(`, `)]}),s(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[s(`label`,{className:`flex items-center gap-1`,children:[r(`system.notificationConditionWidgets.confirmAfter`,`Confirm after`),x(G,{type:`number`,min:1,max:20,step:1,className:`w-16`,value:String(i.confirmHits??2),onChange:e=>a({confirmHits:Number(e.target.value)})}),r(`system.notificationConditionWidgets.frames`)]}),s(`label`,{className:`flex items-center gap-1`,children:[r(`system.notificationConditionWidgets.within`),x(G,{type:`number`,min:1,max:60,step:1,className:`w-16`,value:String(i.confirmWindowSec??5),onChange:e=>a({confirmWindowSec:Number(e.target.value)})}),`s`]})]}),x(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`system.notificationConditionWidgets.audioConfirmHint`,{hits:2,window:5})})]}):s(I,{children:[x(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:s(`label`,{className:`flex items-center gap-1`,children:[r(`system.notificationConditionWidgets.louderThan`,`Louder than`),x(G,{type:`number`,min:_n,max:0,step:3,className:`w-20`,value:String(i.dbThreshold??Hn),onChange:e=>a({dbThreshold:Number(e.target.value)})}),`dBFS`]})}),s(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[s(`label`,{className:`flex items-center gap-1`,children:[r(`system.notificationConditionWidgets.hits`,`Hits`),x(G,{type:`number`,min:1,max:100,step:5,className:`w-16`,value:String(i.hitPercent),onChange:e=>a({hitPercent:Number(e.target.value)})}),r(`system.notificationConditionWidgets.hitsPercentDefault`,{value:On.hitPercent})]}),s(`label`,{className:`flex items-center gap-1`,children:[r(`system.notificationConditionWidgets.over`),x(G,{type:`number`,min:1,max:300,step:5,className:`w-16`,value:String(i.samplingSeconds),onChange:e=>a({samplingSeconds:Number(e.target.value)})}),r(`system.notificationConditionWidgets.secondsDefault`,{value:On.samplingSeconds})]})]}),x(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`system.notificationConditionWidgets.dbfsHint`,{min:_n})})]}),Fn(t)?x(`p`,{className:`text-[11px] text-warning`,children:r(`system.notificationConditionWidgets.withNeitherASoundNor`,`With neither a sound nor a level threshold this can never match — every sample would be a hit, so the engine refuses it rather than notifying on silence.`)}):null]})}function Zm({value:e,onChange:t}){let{t:n}=J(),r=e?.values??[],i=e?.maxDistance??1,a=e=>t(e.length>0?{values:e,maxDistance:i}:void 0),o=e=>t(r.length>0?{values:r,maxDistance:e}:void 0),c=Rd().filter(e=>!r.includes(e));return s(`div`,{className:`mt-1 space-y-1.5`,children:[x(zm,{value:r,placeholder:n(`system.notificationConditionWidgets.plateText`,`Plate text…`),onChange:a}),c.length>0&&s(`div`,{className:`flex flex-wrap items-center gap-1`,children:[x(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`system.notificationConditionWidgets.seen`,`Seen:`)}),c.slice(0,12).map(e=>x(K,{variant:`unstyled`,type:`button`,onClick:()=>a([...r,e]),className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:e},e))]}),s(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[n(`system.notificationConditionWidgets.maxDistance`,`Max distance`),x(G,{type:`number`,min:0,max:3,step:1,value:i,className:`max-w-[5rem]`,onChange:e=>{let t=Number(e.target.value);o(Number.isFinite(t)?Math.max(0,Math.min(3,t)):1)}})]})]})}function Qm({gateable:e,value:t,onChange:n}){let{t:r}=J(),i=Fm(),a=e.find(e=>e.id===t?.deviceId),o=new Set(t?.states??[]),c=e=>{let t=Number(e);if(!Number.isFinite(t)||t===0)return n(void 0);n({deviceId:t,states:[]})},l=e=>{if(t===void 0)return;let r=new Set(o);r.has(e)?r.delete(e):r.add(e),n(r.size===0?void 0:{deviceId:t.deviceId,states:[...r]})};return s(`div`,{className:`mt-1 space-y-2`,children:[x(He,{value:t===void 0?``:String(t.deviceId),options:[{value:``,label:r(`system.notificationConditionWidgets.noDeviceGate`,`— no device gate —`)},...e.map(e=>({value:String(e.id),label:e.name}))],onChange:e=>c(e.target.value)}),a!==void 0&&x(`div`,{className:`flex flex-wrap gap-1.5`,children:a.states.map(e=>x(K,{variant:`unstyled`,type:`button`,onClick:()=>l(e),className:o.has(e)?`rounded-md border border-primary bg-primary/10 px-2 py-0.5 text-[11px] text-primary`:`rounded-md border border-border px-2 py-0.5 text-[11px] text-foreground-subtle`,children:i(e)},e))}),a!==void 0&&a.states.length===0&&x(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:r(`system.notificationConditionWidgets.thisDeviceReportsNoState`,`This device reports no state the gate can read, so it cannot arm a rule.`)}),t!==void 0&&x(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:r(`system.notificationConditionWidgets.theRuleIsSilentWhile`,`The rule is silent while the device is in any other state — including when its state cannot be read at all.`)})]})}function $m(e,t){let n=t(e.verdict);return e.latched?`${n} · ${t(`latched`)}`:n}function eh({scenes:e,value:t,onChange:n}){let{t:r}=J(),i=Fm(),a=e.find(e=>e.sceneId===t?.sceneId),o=r=>{if(r===``)return n(void 0);let i=e.find(e=>e.sceneId===r);if(i===void 0)return n(void 0);n({sceneId:r,deviceId:i.deviceId,requiredState:t?.requiredState??`diverged`,...t?.latched===void 0?{}:{latched:t.latched}})},c=e=>{t!==void 0&&n({...t,requiredState:e===`matched`?`matched`:`diverged`})},l=e=>{if(t!==void 0){if(e===``){let{latched:e,...r}=t;return n(r)}n({...t,latched:e===`latched`})}};return e.length===0?x(`p`,{className:Lm,children:r(`notificationRules.scene.none`,`No scenes yet — create one on the Scenes page.`)}):s(`div`,{className:`mt-1 space-y-2`,children:[x(He,{value:t?.sceneId??``,options:[{value:``,label:r(`notificationRules.scene.noGate`,`— no scene gate —`)},...e.map(e=>({value:e.sceneId,label:`${e.cameraName} · ${e.label} — ${$m(e,i)}`}))],onChange:e=>o(e.target.value)}),t!==void 0&&s(`div`,{className:`flex flex-wrap items-center gap-2`,children:[s(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[r(`notificationRules.scene.onlyWhile`,`Only while it is`),x(He,{value:t.requiredState,options:[{value:`diverged`,label:i(`diverged`)},{value:`matched`,label:i(`matched`)}],onChange:e=>c(e.target.value)})]}),s(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[r(`notificationRules.scene.read`,`Read`),x(He,{value:t.latched===void 0?``:t.latched?`latched`:`live`,options:[{value:``,label:a===void 0?r(`notificationRules.scene.readOwn`,`The scene's own setting`):`${r(`notificationRules.scene.readOwn`,`The scene's own setting`)} (${i(a.emit)})`},{value:`latched`,label:i(`latched`)},{value:`live`,label:i(`live`)}],onChange:e=>l(e.target.value)})]})]}),a!==void 0&&s(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:[r(`notificationRules.scene.rightNow`,`Right now:`),` `,$m(a,i)]}),t!==void 0&&a===void 0&&x(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:r(`notificationRules.scene.missing`,`This scene no longer exists — pick another or remove the gate.`)})]})}function th(e){return kf(e)}function nh(e){return Af(e)}function rh(){return{days:[1,2,3,4,5],startMinute:540,endMinute:1080}}function ih(e){return{days:[...Df.days],minute:e}}var ah=`Always active — add a window to restrict when the rule fires.`;function oh({value:e,onChange:t,mode:n=`windows`,defaultMinute:r=Df.minute,emptyHint:i}){return n===`times`?x(ch,{value:e,onChange:t,defaultMinute:r}):x(sh,{value:e,onChange:t,emptyHint:i??ah})}function sh({value:e,onChange:t,emptyHint:n}){let{t:r}=J(),i=e?.windows??[],a=e?.invert??!1,o=(n,r)=>{if(n.length===0){t(void 0);return}t({windows:n,...r?{invert:!0}:{},...e?.timezone?{timezone:e.timezone}:{}})},c=()=>o([...i,rh()],a),l=e=>o(i.filter((t,n)=>n!==e),a),u=(e,t)=>o(i.map((n,r)=>r===e?t:n),a);return s(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-windows`,children:[i.length===0?x(`p`,{className:Lm,children:n}):i.map((e,t)=>x(lh,{window:e,onChange:e=>u(t,e),onRemove:()=>l(t)},t)),s(`div`,{className:`flex items-center gap-3`,children:[s(K,{variant:`unstyled`,type:`button`,onClick:c,className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[x(We,{className:`h-3 w-3`}),` `,r(`system.notificationScheduleField.addWindow`)]}),i.length>0&&s(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[x(Oe,{checked:a,onChange:e=>o([...i],e.target.checked),className:`accent-primary`}),r(`system.notificationScheduleField.activeOutsideTheWindows`,`Active outside the windows`)]})]})]})}function ch({value:e,onChange:t,defaultMinute:n}){let{t:r}=J(),i=e?.timezone,a=e===void 0?{times:[],approximated:!1}:Xt(e);if(a===null)return s(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times-fallback`,children:[x(`p`,{className:Lm,children:r(`system.notificationScheduleField.invertedScheduleShownAsBands`,`Inverted schedule — shown as bands. Clear the invert flag (or the windows) to author punctual times.`)}),x(sh,{value:e,onChange:t,emptyHint:ah})]});let o=a.times,c=e=>{if(e.length===0){t(void 0);return}t(yt(e,i))};return s(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times`,children:[a.approximated&&x(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,"data-testid":`schedule-field-times-approximated`,children:r(`system.notificationScheduleField.shownAsSendAtTimes`,`Shown as send-at times from each window's end (when the summary fires). Edit or save to store them as punctual one-minute windows.`)}),o.length===0?x(`p`,{className:Lm,children:r(`system.notificationScheduleField.noTimesYetAddOne`,`No times yet — add one to send on those days at that clock time.`)}):o.map((e,t)=>x(uh,{time:e,index:t,onChange:e=>c(o.map((n,r)=>r===t?e:n)),onRemove:o.length>1?()=>c(o.filter((e,n)=>n!==t)):void 0},t)),s(K,{variant:`unstyled`,type:`button`,onClick:()=>c([...o,ih(n)]),className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,"data-testid":`schedule-field-add-time`,children:[x(We,{className:`h-3 w-3`}),` `,r(`system.notificationScheduleField.addTime`)]})]})}function lh({window:e,onChange:t,onRemove:n}){let{t:r}=J();return s(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[s(`div`,{className:`flex items-center gap-2 text-xs`,children:[x(G,{type:`time`,value:th(e.startMinute),onChange:n=>t({...e,startMinute:nh(n.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),x(`span`,{className:`text-foreground-subtle`,children:`→`}),x(G,{type:`time`,value:th(e.endMinute),onChange:n=>t({...e,endMinute:nh(n.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),x(`span`,{className:`flex-1`}),x(K,{variant:`unstyled`,type:`button`,onClick:n,"aria-label":r(`system.notificationScheduleField.removeWindow`,`Remove window`),className:`text-foreground-subtle hover:text-danger`,children:x(ct,{className:`h-3.5 w-3.5`})})]}),x(dh,{days:e.days,onToggle:n=>{let r=e.days.includes(n)?e.days.filter(e=>e!==n):[...e.days,n];r.length!==0&&t({...e,days:r})}})]})}function uh({time:e,index:t,onChange:n,onRemove:r}){let{t:i}=J();return s(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[s(`div`,{className:`flex items-center gap-2 text-xs`,children:[x(`span`,{className:`text-foreground-subtle`,children:i(`system.notificationScheduleField.at`,`At`)}),x(G,{type:`time`,value:kf(e.minute),onChange:t=>n({...e,minute:Af(t.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`,"data-testid":`schedule-field-time-${String(t)}`}),x(`span`,{className:`flex-1`}),r!==void 0&&x(K,{variant:`unstyled`,type:`button`,onClick:r,"aria-label":i(`system.notificationScheduleField.removeTime`,`Remove time`),className:`text-foreground-subtle hover:text-danger`,children:x(ct,{className:`h-3.5 w-3.5`})})]}),x(dh,{days:e.days,onToggle:t=>{let r=e.days.includes(t)?e.days.filter(e=>e!==t):[...e.days,t];r.length!==0&&n({...e,days:r})}})]})}function dh({days:e,onToggle:t}){return x(`div`,{className:`flex flex-wrap gap-1`,children:Of.map(n=>x(K,{variant:`unstyled`,type:`button`,onClick:()=>t(n.value),className:`rounded px-1.5 py-0.5 text-[10px] ${e.includes(n.value)?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:n.label},n.value))})}function fh(e){return e>=8}O();function ph(e){if(typeof e!=`object`||!e)return;let t=Reflect.get(e,`windows`);if(!(!Array.isArray(t)||t.length===0))return e}function mh(e){return e.type===`multiselect`}function hh(e){let t=e.suggestions;return t===void 0||t.length===0?[]:t.map(e=>({value:e,label:e}))}function gh(e){return e.map(e=>({value:e.value,label:e.label,...e.description===void 0?{}:{description:e.description},...e.iconId===void 0?{}:{iconId:e.iconId}}))}function _h(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function vh({field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:o,externalProbe:c,allFields:l,onAction:u}){let{t:d}=J();if(e.type===`tags`){if(!$r(e,t,l))return null;let r=e.creatable!==!1;return x(Ta,{mode:`multi`,options:hh(e),value:_h(t[e.key]),onChange:t=>n(e.key,t),disabled:i===!0||e.disabled===!0,creatable:r,...e.createLabel===void 0?{}:{createLabel:e.createLabel},...e.maxTags===void 0?{}:{maxItems:e.maxTags},label:bh(e.label,a),description:e.description===void 0?void 0:bh(e.description,a),placeholder:e.placeholder??d(`formBuilder.formBuilder.searchOrAdd`,`Search or add…`),testId:`config-tags-${e.key}`})}if(e.type===`schedule`){if(!$r(e,t,l))return null;let r=bh(e.label,a),i=e.description===void 0?void 0:bh(e.description,a),o=e.mode===`times`?`times`:`windows`;return s(`div`,{className:`space-y-1`,"data-testid":`config-schedule-${e.key}`,children:[r!==void 0&&x(`label`,{className:`block text-[11px] font-medium text-foreground-subtle`,children:r}),i!==void 0&&x(`p`,{className:`text-[10px] text-foreground-subtle`,children:i}),x(oh,{mode:o,value:ph(t[e.key]),onChange:t=>n(e.key,t)})]})}return mh(e)&&(fh(e.options.length)||e.creatable===!0)?$r(e,t,l)?x(Ta,{mode:`multi`,options:gh(e.options),value:_h(t[e.key]),onChange:t=>n(e.key,t),disabled:i===!0||e.disabled===!0,creatable:e.creatable===!0,...e.createLabel===void 0?{}:{createLabel:e.createLabel},...e.maxItems===void 0?{}:{maxItems:e.maxItems},label:bh(e.label,a),description:e.description===void 0?void 0:bh(e.description,a),placeholder:e.placeholder??d(`formBuilder.formBuilder.searchToAdd`,`Search to add…`),testId:`config-multiselect-${e.key}`,listboxId:`msel-${e.key}`}):null:x(Kr,{field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:o,externalProbe:c,allFields:l,onAction:u})}function yh(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function bh(e,t){if(e!==void 0)return t&&yh(e)?t(e):e}function xh({section:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:o,probeResults:c,onAction:l}){let[u,d]=w(e.defaultCollapsed??!1),f=e.style===`accordion`;if(e.fields.reduce((n,r)=>n+ +!!$r(r,t,e.fields),0)===0)return null;let p=e.fields,m=e.columns??2,h=m===1?`grid-cols-1`:m===3?`grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3`:m===4?`grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4`:`grid-cols-1 @[480px]:grid-cols-2`,g=e.fields.length===1&&e.fields[0]?.type===`widget`?e.fields[0]:void 0,_=g!==void 0||!e.title&&!e.description;return s(`div`,{className:`@container rounded-lg border border-border bg-surface p-3`,style:{containerType:`inline-size`},"data-settings-section":e.id,children:[!_&&(f?s(`button`,{type:`button`,"aria-expanded":!u,onClick:()=>d(e=>!e),className:`flex w-full items-center justify-between mb-2 text-left`,children:[s(`div`,{children:[e.title&&x(`h3`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider`,children:bh(e.title,a)}),e.description&&x(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:bh(e.description,a)})]}),x(Ii,{expanded:!u,className:`ml-2`})]}):x(`div`,{className:`flex items-center justify-between mb-2`,children:s(`div`,{children:[e.title&&x(`h3`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider`,children:bh(e.title,a)}),e.description&&x(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:bh(e.description,a)})]})})),!(u&&!_)&&(g===void 0?x(I,{children:x(`div`,{className:`grid ${h} gap-x-3 gap-y-2.5`,children:p.map(s=>x(vh,{field:s,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:o,externalProbe:c?.[s.key],allFields:e.fields,onAction:l},s.key))})}):x(Kr,{field:g,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:o,externalProbe:c?.[g.key],allFields:e.fields,onAction:l},g.key))]})}function Sh({schema:e,values:t,onChange:n,disabled:r,translationFn:i,onTestField:a,probeResults:o,onClearProbe:s,onAction:c,visibilityContext:l}){let u=l?{...l,...t}:t,d=(e,r)=>{n({...t,[e]:r}),s?.(e)},f=e=>{n({...t,...e});for(let t of Object.keys(e))s?.(t)};return x(`div`,{className:`space-y-4`,children:e.sections.map((e,t)=>x(xh,{section:e,values:u,onChange:d,onChangeMany:f,disabled:r,translationFn:i,onTestField:a,probeResults:o,onAction:c},`${e.id}-${t}`))})}function Ch(e){return{status:e.status===`validated`||e.status===`rejected`||e.status===`inconclusive`||e.status===`unsupported`?e.status:e.success?`validated`:`rejected`,...e.error===void 0?{}:{error:e.error},...e.detail===void 0?{}:{detail:e.detail}}}var wh={validated:`border-success/30 bg-success/5 text-success`,rejected:`border-danger/30 bg-danger/5 text-danger`,inconclusive:`border-warning/30 bg-warning/5 text-warning`,unsupported:`border-border bg-surface text-foreground-subtle`};function Th({verdict:e}){let{t}=J(),n=(()=>{switch(e.status){case`validated`:return e.detail?`${t(`integrations.connectionSuccess`)} — ${e.detail}`:t(`integrations.connectionSuccess`);case`rejected`:return`${t(`integrations.errorPrefix`)} ${e.error??``}`;case`inconclusive`:return`${t(`integrations.connectionInconclusive`,{defaultValue:`Could not be checked:`})} ${e.error??``}`;case`unsupported`:return e.error??t(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`})}})();return x(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${wh[e.status]}`,"data-testid":`connection-test-verdict`,children:n})}var Eh=new Set;function Dh(e){for(let t of Eh)t(e)}function Oh(e){return Eh.add(e),()=>{Eh.delete(e)}}var kh=new Set([`proc`,`sys`,`dev`,`run`,`boot`,`lost+found`,`snap`,`bin`,`sbin`,`lib`,`lib32`,`lib64`,`libx32`,`usr`,`etc`,`var`,`opt`,`tmp`,`srv`,`root`,`System`,`Library`,`Applications`,`cores`,`private`]),Ah=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function jh(e){let t=Ah.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?Ah.length:t}function Mh(e){return e.filter(e=>!e.name.startsWith(`.`)&&!kh.has(e.name)).toSorted((e,t)=>{let n=jh(e.name)-jh(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}O();function Nh({nodeId:e,value:t,onChange:n}){let{t:r}=J(),i=_t().trpcClient,[a,o]=w([]),[c,l]=w(t),[u,d]=w(null),[f,p]=w(null),[m,h]=w(``),g=b(async(t,r)=>{p(null);try{let a=await i.filesystemBrowse.browse.query({nodeId:e,path:t});d(a),l(a.path),r&&n(a.path)}catch(e){p(e instanceof Error?e.message:`browse failed`)}},[i,e,n]);S(()=>{l(t),(async()=>{let n=await i.filesystemBrowse.browse.query({nodeId:e,path:`/`}).then(e=>e).catch(()=>null);if(n){o(Mh(n.entries)),await g(t.startsWith(`/`)?t:`/`,!1);return}try{let n=await i.filesystemBrowse.listAllowedRoots.query({nodeId:e});o(n),await g(t&&n.some(e=>t.startsWith(e))?t:n[0]??``,!1)}catch(e){o([]),d(null),p(e instanceof Error&&/not available on node/i.test(e.message)?`This node can't be browsed remotely. Enter the path manually.`:e instanceof Error?e.message:`browse unavailable`)}})()},[e]);let _=async()=>{if(!(!m.trim()||!u)){p(null);try{let t=`${u.path.replace(/\/+$/,``)}/${m.trim()}`;await i.filesystemBrowse.createDir.mutate({nodeId:e,path:t}),h(``),await g(u.path,!0)}catch(e){p(e instanceof Error?e.message:`create failed`)}}},v=e=>`${(e/1e9).toFixed(1)} GB`;return s(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[x(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>x(K,{variant:`unstyled`,onClick:()=>void g(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),x(G,{value:c,onChange:e=>{l(e.target.value),n(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),u&&x(`div`,{className:`text-[10px] text-foreground-subtle`,children:r(`storage.pathBrowser.free`,{free:v(u.freeBytes),total:v(u.totalBytes)})}),x(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:u?.entries.map(e=>s(K,{variant:`unstyled`,onClick:()=>void g(e.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,e.name]},e.path))}),s(`div`,{className:`flex gap-1`,children:[x(G,{value:m,onChange:e=>h(e.target.value),placeholder:r(`storage.pathBrowser.newFolder`,`new folder`),className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),x(K,{variant:`unstyled`,onClick:()=>void _(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:r(`storage.pathBrowser.create`,`Create`)})]}),f&&x(`div`,{className:`text-[10px] text-danger`,children:f})]})}var Ph=`storage/path-browser`,Fh=`nodeId`,Ih=`providerId`,Lh=`basePath`,Rh=`hub`;function zh(e,t){let n=e[t];return typeof n==`string`?n:``}function Bh(e,t){let n=e.sections.flatMap(e=>e.fields),r=n.find(e=>e.key===Fh);if(r===void 0)return null;let i=zh(t,Ih),a=`showWhen`in r?r.showWhen:void 0;return a!==void 0&&!(i!==``&&a.in?.includes(i))?null:(i===``?[Lh]:[`${i}.${Lh}`,Lh]).find(e=>n.some(t=>t.key===e))??null}function Vh(e,t){let n=Bh(e,t);return n===null?[]:[n]}function Hh({schema:e,values:t,onValuesChange:n}){let{t:r}=J(),i=Bh(e,t);if(i===null)return null;let a=zh(t,Fh);return s(`div`,{className:`space-y-1`,children:[x(`p`,{className:`text-xs font-medium text-foreground-muted`,children:r(`storage.pathBrowser.label`,`Folder on the node`)}),x(Nh,{nodeId:a===``?Rh:a,value:zh(t,i),onChange:e=>n({...t,[i]:e})})]})}var Uh=new Map([[Ph,{Component:Hh,ownedKeys:Vh}]]);function Wh(e){return Uh.get(e)??null}function Gh(e,t){return t.length===0?e:{...e,sections:e.sections.map(e=>({...e,fields:e.fields.filter(e=>!t.includes(e.key))}))}}O();function Kh({field:e,values:t,onLabels:n}){let{t:r}=J(),{query:i,found:a}=jr(e,t);return S(()=>{n(new Map(a.map(e=>[e.value,e.label])))},[a.map(e=>`${e.value}\u0000${e.label}`).join(``),n]),i.isError?x(`p`,{"data-testid":`create-many-labels-failed`,className:`text-xs text-warning`,children:r(`providerInstances.createManyLabelsFailed`,`The names of the choices could not be read ({{message}}); each is named after its value.`,{message:i.error?.message??``})}):null}function qh(e){for(let t of e?.sections??[])for(let e of t.fields)if(e.type===`select`&&e.discoverOptions?.pickManyOnCreate===!0)return e;return null}function Jh(e,t){return e.type!==`select`||e.key!==t||e.discoverOptions===void 0?e:{...e,discoverOptions:{...e.discoverOptions,multiple:!0}}}function Yh(e,t){return{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>Jh(e,t))}))}}function Xh(e){let{key:t,picked:n,labels:r,typedName:i,values:a}=e;return n.map(e=>({name:n.length===1&&i.length>0?i:r.get(e)??e,values:{...a,[t]:e}}))}function Zh(e,t){let n=[];for(let r of e.links??[]){let e=t[r.field],i=Array.isArray(e)?e:[e];for(let e of i)typeof e!=`string`||e===``||n.some(t=>t.field===r.field&&t.instanceId===e)||n.push({field:r.field,cap:r.to.cap,...r.to.kind===void 0?{}:{kind:r.to.kind},instanceId:e})}return n}function Qh(e,t){return e.find(e=>e.id===t.instanceId&&(t.kind===void 0||e.kind===t.kind))}function $h(e){let t=new Map(e.holders.map(e=>[e.addonId,e])),n=[];for(let r of e.functionProviders){let i=e.displayNames.get(r.addonId)??r.addonId,a=t.get(r.addonId);if(a===void 0){n.push({kind:`fixed`,key:`fixed:${r.addonId}`,addonId:r.addonId,providerName:i,name:i,description:e.descriptions.get(r.addonId)??``,isActive:r.isActive});continue}let o=e.notRunning?.get(r.addonId);for(let e of a.instances){let t=og(a.description,e.kind),s=Zh(a.description,e.formValues);n.push({kind:`instance`,key:`${r.addonId}:${e.id}`,addonId:r.addonId,providerName:i,id:e.id,name:e.name,configured:e.configured,enabled:e.enabled??!0,status:e.status,canTest:t?.canTest??a.description.canTest,...e.kind===void 0?{}:{kindId:e.kind},...e.kind===void 0?{}:{kindLabel:t?.label??e.kind},...t?.iconUrl===void 0?{}:{kindIconUrl:t.iconUrl},...e.lastCheckedAt===void 0?{}:{lastCheckedAt:e.lastCheckedAt},...t?.connectPath===void 0?{}:{connectPath:t.connectPath},...t?.disconnectPath===void 0?{}:{disconnectPath:t.disconnectPath},...o===void 0?{}:{notRunning:o},...s.length>0?{links:s}:{}})}}return n}var eg=new Set([`running`,`unknown`]);function tg(e){return e!==void 0&&!eg.has(e)}function ng(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function rg(e){let t=new Map;for(let n of e){let e=ng(ng(n,`manifest`),`id`),r=ng(ng(n,`process`),`state`);typeof e!=`string`||typeof r!=`string`||tg(r)&&t.set(e,r)}return t}function ig(e){let t=new Map;for(let n of e){let e=ng(n,`manifest`),r=ng(e,`id`);if(typeof r!=`string`||r.length===0)continue;let i=ng(e,`name`),a=ng(e,`packageDisplayName`);t.set(r,typeof i==`string`?i:typeof a==`string`?a:r)}return t}function ag(e){let t=new Map;for(let n of e){let e=ng(n,`manifest`),r=ng(e,`id`),i=ng(e,`description`);typeof r!=`string`||typeof i!=`string`||i.length>0&&t.set(r,i)}return t}function og(e,t){return t===void 0?void 0:e.kinds?.find(e=>e.id===t)}function sg(e,t,n){let r=e.kinds;if(r===void 0||r.length===0)return e;let i=r.filter(e=>n===void 0?e.functionCap===t:e.id===n&&jt(e,t));return i.length===0?null:{...e,kinds:i}}function cg(e,t){let n=sg(e.description,t);if(n===null)return null;let r=n.kinds;if(e.description.kinds===void 0||r===void 0)return e;let i=new Set(r.map(e=>e.id));return{...e,description:n,instances:e.instances.filter(e=>e.kind===void 0||i.has(e.kind))}}function lg(e){return(e.kinds?.length??0)>1}function ug(e,t,n){return lg(e)&&t!==void 0?t.label:n}function dg(e){return e.label!==void 0&&e.label.length>0?e.label:e.state}function fg(e){let t=new Set,n=[];for(let r of e)t.has(r.addonId)||(t.add(r.addonId),n.push({addonId:r.addonId,name:r.providerName}));return n}var pg={error:3,unknown:2,ok:1,off:0};function mg(e){return e.enabled?e.status===void 0?e.configured?`ok`:`unknown`:e.status.state:`off`}function hg(e){let t=null;for(let n of e){let e=mg(n);(t===null||pg[e]>pg[t])&&(t=e)}return t??`unknown`}function gg(e,t,n){return e.map(e=>{let r=n.get(e.addonId)??e.addonId,i=t.filter(t=>t.addonId===e.addonId),a=i.filter(e=>e.kind===`instance`),o=i.find(e=>e.kind===`fixed`);return o===void 0?{addonId:e.addonId,name:r,count:a.length,health:hg(a)}:{addonId:e.addonId,name:r,count:1,health:o.isActive?`ok`:`off`}})}function _g(e,t){return t===null?e:e.filter(e=>e.addonId===t)}function vg(e){return e.filter(e=>e.description.instanceMode===`multiple`||e.instances.length===0)}function yg(e,t){return e.flatMap(e=>{let n=t(e.addonId),r=e.description.kinds??[];return r.length===0?[{addonId:e.addonId,label:n,providerName:n}]:r.map(t=>({addonId:e.addonId,kind:t.id,label:t.label,providerName:n,...t.iconUrl===void 0?{}:{iconUrl:t.iconUrl}}))})}function bg(e){return e.some(e=>e.isError)?`error`:e.some(e=>e.isPending)?`pending`:`ready`}function xg(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;let n=e,r=t,i=new Set([...Object.keys(n),...Object.keys(r)]);for(let e of i)if(!xg(n[e],r[e]))return!1;return!0}var Sg=`enabled`;function Cg(e,t){return t?.sections.some(e=>e.fields.some(e=>e.key===Sg))===!0?{...e}:Object.fromEntries(Object.entries(e).filter(([e])=>e!==Sg))}function wg(e,t){let n={};for(let[r,i]of Object.entries(t))i!==void 0&&(xg(e[r],i)||(n[r]=i));return n}function Tg(e,t){let n={...e};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function Eg(e,t){return e.mintsId===!0?!1:(t?.role??e.role)!==`devices`}function Dg(e,t,n){return e===`single`?t:`inst-${n()}`}function Og(){let e=crypto.getRandomValues(new Uint8Array(4));return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}var kg=`+`;function Ag(e,t,n){return t===void 0?e:t===null?`${e}:${kg}${n??``}`:`${e}:${t}`}function jg(e){let t=e.indexOf(`:`);if(t<0)return{kind:`fixed`,addonId:e};let n=e.slice(0,t),r=e.slice(t+1);if(!r.startsWith(kg))return{kind:`instance`,addonId:n,id:r};let i=r.slice(1);return i===``?{kind:`create`,addonId:n}:{kind:`create`,addonId:n,kindId:i}}var Mg=`sendWith`,Ng=`smtpInstanceId`;function Pg(e,t){return e.filter(e=>e.formValues[Mg]===t||e.formValues[Ng]===t).map(e=>e.name)}var Fg=/^[a-z0-9][a-z0-9-]{0,63}$/;function Ig(e,t){return t===``?`empty`:e.pattern.test(t)?`ok`:`invalid`}O();var Lg=5e3,Rg=`integration-instances`,zg=`provider-instances-holder`;function Bg(e){let t=_t(),n=Fi({capName:e},{refetchInterval:Lg}),r=Fi({capName:Rg},{refetchInterval:Lg}),i=Oi(void 0,{refetchInterval:Lg}),a=m(()=>(n.data??[]).map(e=>({addonId:e.addonId,isActive:e.isActive})),[n.data]),o=k({queries:m(()=>{let e=new Set((r.data??[]).map(e=>e.addonId));return a.map(e=>e.addonId).filter(t=>e.has(t))},[a,r.data]).map(e=>({queryKey:[zg,e],refetchInterval:Lg,queryFn:async()=>{let n=t.trpcClient.integrationInstances,[r,i]=await Promise.all([n.describe.query({addonId:e}),n.listInstances.query({addonId:e})]);return{addonId:e,description:r,instances:i}}}))}),s=bg([n,r,...o]),c=m(()=>o.flatMap(t=>{let n=t.data===void 0?null:cg(t.data,e);return n===null?[]:[n]}),[o,e]),l=m(()=>ig(i.data??[]),[i.data]),u=m(()=>ag(i.data??[]),[i.data]),d=m(()=>rg(i.data??[]),[i.data]),f=m(()=>$h({functionProviders:a,holders:c,displayNames:l,descriptions:u,notRunning:d}),[a,c,l,u,d]),p=n.error??r.error??o.find(e=>e.error)?.error??null,h=b(()=>{n.refetch(),r.refetch();for(let e of o)e.refetch()},[n,r,o]);return{state:s,error:p===null?null:p.message,functionProviders:a,rows:f,holders:c,displayNames:l,descriptions:u,refetch:h}}O();var Vg=`name`,Hg=`kind`,Ug=`restore`,Wg=`restoreId`,Gg=`typedId`,Kg={};function qg(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Jg(e,t){let n=qg(e)?e:{};return t===null?{...n}:{...n,integrationId:t}}function Yg({addonId:e,providerName:t,description:n,instance:r,onClose:i,onSaved:a,lead:o,typedId:c,testLabel:l,testHint:u}){let{t:d}=J(),f=_t(),h=N(),g=r?.id??null,_=async(t,n,r)=>{let i=await f.trpcClient.addons.custom.mutate({addonId:e,action:t,input:Jg(r,g)});return g!==null&&h.invalidateQueries({queryKey:[zg]}),i},v=n.kinds??[],y=ug(n,og(n,r?.kind??v[0]?.id),t),[C,T]=w({[Vg]:r?.name??y,[Hg]:r?.kind??v[0]?.id??``,[Ug]:!1,[Wg]:``,[Gg]:``}),D=p(y),O=C[Hg];S(()=>{if(r!==null||typeof O!=`string`)return;let e=ug(n,og(n,O),t),i=D.current;D.current=e,T(t=>t[Vg]===i?{...t,[Vg]:e}:t)},[O,n,r,t]);let k=e=>{let t=C[e];return typeof t==`string`?t.trim():``},A=k(Vg),j=k(Hg),M=og(n,j===``?void 0:j),F=C[Ug]===!0,L=k(Wg),R=r===null&&n.allowRestoreId===!0&&M?.signIn===void 0,z=R&&F&&L===``,ee=r===null&&M?.signIn===void 0&&!(R&&F)?c?.(j===``?void 0:j):void 0,te=k(Gg),ne=ee===void 0?`ok`:Ig(ee,te),[B,re]=w({...r?.formValues??Kg}),[ie,V]=w(null),ae=m(()=>({sections:[{id:`instance-identity`,title:d(`providerInstances.identity`,`Identity`),columns:1,fields:[...r===null&&lg(n)?[{type:`select`,key:Hg,label:d(`providerInstances.colKind`,`Kind`),options:v.map(e=>({value:e.id,label:e.label}))}]:[],{type:`text`,key:Vg,label:d(`providerInstances.colName`,`Name`),required:!0},...ee===void 0?[]:[{type:`text`,key:Gg,label:d(`providerInstances.typedId`,`Id`),required:!0,description:ne===`invalid`?d(`providerInstances.typedIdInvalid`,`Lowercase letters, digits and dashes, starting with a letter or digit (up to 64).`):d(`providerInstances.typedIdHint`,`Chosen once; it cannot be changed after the record is created.`)}],...R?[{type:`boolean`,key:Ug,label:d(`providerInstances.restore`,`Restore under its old id`),description:d(`providerInstances.restoreHint`,`Re-adding something that was removed under its original id keeps everything that points at it working.`)},{type:`text`,key:Wg,label:d(`providerInstances.originalId`,`Original id`),required:!0,showWhen:{field:Ug,equals:!0}}]:[]]}]}),[R,n,ee,r,v,d,ne]),[se,ce]=w(null),le=g===null&&j!==``?j:void 0,H=E({queryKey:[`provider-instance-form`,e,g,le??null],queryFn:()=>f.trpcClient.integrationInstances.instanceFormSchema.query({addonId:e,id:g,...le===void 0?{}:{kind:le}})}),ue=m(()=>r===null?Kg:Cg(r.formValues,H.data),[r,H.data]),U=m(()=>Cg(B,H.data),[B,H.data]),de=r===null?qh(H.data):null,fe=de?.key,pe=m(()=>H.data&&fe!==void 0?Yh(H.data,fe):H.data,[H.data,fe]),me=de===null?[]:wr(B[de.key]),he=me.length>1,[ge,_e]=w(()=>new Map),ve=b(e=>{_e(e)},[]),ye=m(()=>pe?gn(pe,{...ue}):null,[pe,ue]),be=H.isSuccess&&!H.data,xe=(M?.widgets??[]).flatMap(e=>{let t=e.placement===`connection`?Wh(e.id):null;return t===null?[]:[{id:e.id,widget:t}]}),Se=ye===null?[]:xe.flatMap(({widget:e})=>e.ownedKeys(ye,B)),Ce=P({mutationFn:async()=>{let t=f.trpcClient.integrationInstances,i=wg(ue,U),a=de!==null&&me.length===1?{...i,[de.key]:me[0]}:i;if(r===null&&de!==null&&he){let r=Xh({key:de.key,picked:me,labels:ge,typedName:A,values:a}),i=``;for(let[a,o]of r.entries())try{let r=await t.createInstance.mutate({addonId:e,name:o.name,...Eg(n,M)?{id:Dg(n.instanceMode,e,Og)}:{},...j===``?{}:{kind:j}});await t.updateInstance.mutate({addonId:e,id:r.id,values:o.values}),i=r.id}catch(e){throw h.invalidateQueries({queryKey:[zg]}),Error(d(`providerInstances.createManyStopped`,`{{done}} of {{total}} created: {{message}}`,{done:a,total:r.length,message:e instanceof Error?e.message:String(e)}))}return i}if(r===null){let r=R&&F?L:ee===void 0?Eg(n,M)?Dg(n.instanceMode,e,Og):void 0:te,i=await t.createInstance.mutate({addonId:e,name:A,...r===void 0?{}:{id:r},...j===``?{}:{kind:j}});return Object.keys(a).length>0&&await t.updateInstance.mutate({addonId:e,id:i.id,values:a}),i.id}return await t.updateInstance.mutate({addonId:e,id:r.id,name:A,values:a}),r.id},onSuccess:e=>{h.invalidateQueries({queryKey:[zg]}),Dh({title:d(`providerInstances.saved`,`Saved`),message:he?String(me.length):A,severity:`info`}),a?.(e),i()},onError:e=>V(e.message)}),we=P({mutationFn:()=>f.trpcClient.integrationInstances.testInstance.mutate({addonId:e,id:g,values:wg(ue,U),...g===null&&M!==void 0?{kind:M.id}:{}}),onSuccess:e=>ce(Ch(e)),onError:e=>ce({status:`inconclusive`,error:e.message})});return x(ha,{open:!0,onClose:i,title:r===null?d(`providerInstances.createTitle`,`Add {{provider}}`,{provider:ug(n,M,t)}):d(`providerInstances.editTitle`,`Edit {{name}}`,{name:r.name}),error:ie??(H.isError?H.error.message:null),width:`lg`,footer:s(I,{children:[(M?.canTest??n.canTest)&&s(K,{size:`sm`,variant:`outline`,type:`button`,disabled:we.isPending||ye===null&&!be,onClick:()=>{ce(null),we.mutate()},children:[we.isPending?x(W,{className:`h-3.5 w-3.5 animate-spin`}):null,l??d(`providerInstances.test`,`Test connection`)]}),s(K,{size:`sm`,type:`button`,disabled:Ce.isPending||ye===null&&!be||A.length===0&&!he||!he&&(z||ne!==`ok`),onClick:()=>{V(null),Ce.mutate()},children:[Ce.isPending?x(W,{className:`h-3.5 w-3.5 animate-spin`}):null,r===null&&he?d(`providerInstances.createMany`,`Create {{count}}`,{count:me.length}):r===null?d(`providerInstances.create`,`Create`):d(`providerInstances.saveChanges`,`Save changes`)]})]}),children:s(`div`,{className:`space-y-4`,children:[r===null?null:o,x(Sh,{schema:he?Gh(ae,[Vg,Gg,Ug,Wg]):ae,values:C,onChange:T}),de!==null&&he&&x(Kh,{field:de,values:B,onLabels:ve}),M?.signIn!==void 0&&x(pd,{basePath:M.signIn.basePath,...M.signIn.methods===void 0?{}:{methods:M.signIn.methods},name:A,...r===null?{}:{brokerId:r.id},getSettings:()=>Tg(ue,U),disabled:A.length===0,onSignedIn:e=>{h.invalidateQueries({queryKey:[`provider-instances-holder`]}),a?.(e),i()}}),r!==null&&M?.connectPath!==void 0&&s(K,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>Ru(Fu(M.connectPath??``,r.id),()=>void h.invalidateQueries({queryKey:[`provider-instances-holder`]})),children:[x(oe,{className:`h-3.5 w-3.5`}),d(`providerInstances.connect`,`Connect account`)]}),ye===null?H.isError?null:be?x(`p`,{className:`text-xs text-foreground-muted`,children:d(`providerInstances.noForm`,`This record has no configuration form beyond its name.`)}):s(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[x(W,{className:`h-3 w-3 animate-spin`}),d(`providerInstances.loading`,`Loading…`)]}):s(I,{children:[x(Wr,{schema:Gh(ye,Se),values:B,onChange:re,onAction:_}),xe.map(({id:e,widget:{Component:t}})=>x(t,{schema:ye,values:B,onValuesChange:re},e))]}),u!==void 0&&(M?.canTest??n.canTest)&&x(`p`,{className:`text-xs text-foreground-subtle`,children:u}),se!==null&&x(Th,{verdict:se})]})})}O();var Xg=`integration-instances`,Zg=`instance-kinds-describe`;function Qg(e,t){let n=[];for(let r of e)if(!(t.addonId!==void 0&&r.addonId!==t.addonId))for(let e of r.description.kinds??[]){if(!(t.match===`link`?jt(e,t.functionCap):e.functionCap===t.functionCap))continue;let i=e.brokerKind??e.id;t.kind!==void 0&&i!==t.kind&&e.id!==t.kind||n.push({addonId:r.addonId,kind:e.id,brokerKind:i,label:e.label,...e.connectPath===void 0?{}:{connectPath:e.connectPath},...e.disconnectPath===void 0?{}:{disconnectPath:e.disconnectPath},...e.signIn===void 0?{}:{signInBasePath:e.signIn.basePath},...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl},canTest:e.canTest??r.description.canTest===!0})}return n}function $g(e){let t=_t(),n=Fi({capName:e.functionCap}),r=Fi({capName:Xg}),i=k({queries:m(()=>{let e=new Set((r.data??[]).map(e=>e.addonId));return(n.data??[]).map(e=>e.addonId).filter(t=>e.has(t))},[n.data,r.data]).map(e=>({queryKey:[Zg,e],queryFn:async()=>({addonId:e,description:await t.trpcClient.integrationInstances.describe.query({addonId:e})})}))}),a=m(()=>i.flatMap(e=>e.data===void 0?[]:[e.data]),[i]);return{options:m(()=>Qg(a,e),[a,e.functionCap,e.addonId,e.kind,e.match]),holders:a,isLoading:n.isLoading===!0||r.isLoading===!0||i.some(e=>e.isLoading)}}function e_({children:e,onClose:t}){return x(si,{open:!0,onOpenChange:e=>!e&&t(),children:s(Dr,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[x(Pr,{children:x(hi,{children:`\xA0`})}),x(fi,{children:e})]})})}function t_({functionCap:e,kind:t,addonId:n,onClose:r,onSaved:i,typedId:a,match:o}){let{t:s}=J(),c=_t(),l=N(),u=$g({functionCap:e,...n===void 0?{}:{addonId:n},...t===void 0?{}:{kind:t},...o===void 0?{}:{match:o}}),d=u.options[0],f=n??d?.addonId,p=E({queryKey:[`instance-create-description`,f,e,d?.kind??null],enabled:f!==void 0,queryFn:async()=>sg(await c.trpcClient.integrationInstances.describe.query({addonId:f??``}),e,d?.kind)});return f===void 0||p.data===null?x(e_,{onClose:r,children:f===void 0&&u.isLoading?x(W,{className:`h-4 w-4 animate-spin`}):x(gr,{message:s(`brokers.editor.noProvider`)})}):p.isError?x(e_,{onClose:r,children:x(gr,{message:p.error.message})}):p.data===void 0?x(e_,{onClose:r,children:x(W,{className:`h-4 w-4 animate-spin`})}):x(Yg,{addonId:f,providerName:d?.label??``,description:p.data,instance:null,onClose:r,...a===void 0?{}:{typedId:a},onSaved:e=>{l.invalidateQueries(),i(e)}})}O();var n_={ok:`success`,off:`default`,unknown:`default`,error:`danger`};function r_({kind:e,value:t,onChange:n,optional:r=!1,noneLabel:i,disabled:a=!1}){let{t:o}=J(),[c,l]=w(!1),u=Hi({kind:e}),d=fa(u.data??[],t),f=d[0]?.id??null,p=!u.isLoading&&!u.isError&&u.data!==void 0;return S(()=>{!r&&!a&&p&&t===null&&f!==null&&n(f)},[r,a,p,t,f,n]),s(`div`,{className:`space-y-2`,children:[u.isLoading&&s(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[x(W,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.picker.loading`)]}),u.isError&&x(gr,{message:o(`brokers.picker.loadFailed`,{message:u.error?.message??o(`common.unknownError`)})}),!u.isLoading&&!u.isError&&d.length===0&&x(`p`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-xs text-foreground-subtle`,children:o(`brokers.picker.none`)}),r&&x(`button`,{type:`button`,"aria-pressed":t===null,disabled:a,onClick:()=>n(null),className:`flex w-full items-center rounded-lg border bg-surface p-3 text-left text-xs text-foreground-subtle transition-colors ${t===null?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:i??o(`brokers.picker.noneChoice`)}),d.map(e=>s(`button`,{type:`button`,"aria-pressed":t===e.id,disabled:a,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:[x(`span`,{className:`text-xs font-semibold text-foreground`,children:e.name}),x(qi,{variant:n_[e.state],className:`text-[10px]`,children:e.stateLabel??e.state})]},e.id)),s(K,{variant:`outline`,size:`sm`,disabled:a,onClick:()=>l(!0),children:[x(We,{className:`h-3.5 w-3.5`}),` `,o(`brokers.picker.createNew`)]}),c&&x(t_,{functionCap:`broker`,kind:e,onClose:()=>l(!1),onSaved:e=>{l(!1),n(e)}})]})}var i_=an;function a_(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 o_(e,t){return tn(e,t)}O();function s_(e=!0){S(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e])}O();function c_(e,t){let[n,r]=w(!1);return S(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}O();function l_({kind:e,onResolved:t,onBack:n}){let{t:r}=J(),[i,a]=w(null);return s(`div`,{className:`space-y-4`,children:[s(K,{variant:`ghost`,size:`sm`,onClick:n,children:[x($e,{className:`h-3.5 w-3.5`}),` `,r(`common.back`)]}),x(r_,{kind:e,value:i,onChange:a}),x(`div`,{className:`flex justify-end pt-1`,children:x(K,{variant:`primary`,size:`sm`,disabled:i===null,onClick:()=>i!==null&&t(i),children:r(`integrations.brokerStep.useThisBroker`,`Use this broker`)})})]})}O();function u_({providerId:e,onImport:t,onSkip:n}){let{t:r}=J(),[i,a]=w(new Set),o=Vr(),c=o.data,l=o.isPending||!o.data&&!o.isError;S(()=>{e&&(o.isPending||o.data||o.mutate({addonId:e}))},[e,o]);function u(e){a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(l)return s(`div`,{className:`flex flex-col items-center py-12`,children:[x(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),x(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:r(`integrations.searchingDevices`)})]});let d=c??[];return s(`div`,{className:`space-y-4`,children:[x(`p`,{className:`text-xs text-foreground-subtle`,children:d.length>0?r(`integrations.foundDevices`,{count:d.length}):r(`integrations.noDevicesFound`)}),d.length>0&&x(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:d.map(e=>{let t=e.stableId,n=e.suggestedName??t,a=i.has(t),o=e.alreadyOnboarded===!0;return s(K,{variant:`unstyled`,onClick:()=>{o||u(t)},disabled:o,title:o?r(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:e.onboardedName??n}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${o?`border-border bg-surface opacity-60 cursor-not-allowed`:a?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[x(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${a&&!o?`border-primary bg-primary`:`border-border`}`,children:a&&!o&&x(ot,{className:`h-3 w-3 text-primary-foreground`})}),x(Ve,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),x(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n}),o&&x(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:r(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},t)})}),s(`div`,{className:`flex items-center justify-between pt-2`,children:[x(K,{variant:`unstyled`,onClick:n,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:r(`integrations.skip`)}),d.length>0&&s(K,{variant:`unstyled`,onClick:()=>t(Array.from(i)),disabled:i.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[r(`integrations.importSelected`),` (`,i.size,`)`]})]})]})}O();function d_({addonId:e,configSchema:t,canTest:n=!0,instanceKind:r,initialName:i,initialConfig:a,submitLabel:o,hideName:c=!1,saving:l=!1,onScan:u,onSave:d,onBack:f}){let{t:p}=J(),[m,h]=w(i??``),[g,_]=w(a??{}),[v,y]=w(null),b=lr({onSuccess:e=>y(Ch(e)),onError:e=>y({status:`inconclusive`,error:String(e)})}),S=ma(),C=!n||v?.status===`validated`,T=!c&&m.trim().length===0,E=!T&&C;return s(`div`,{className:`space-y-4`,children:[!c&&s(`div`,{children:[x(`label`,{htmlFor:`integration-name`,className:`block text-[11px] font-medium text-foreground mb-1`,children:p(`integrations.integrationName`)}),x(G,{id:`integration-name`,type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:p(`integrations.integrationNamePlaceholder`),"aria-invalid":T,"aria-describedby":T?`integration-name-error`:void 0,className:`w-full rounded-lg border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none ${T?`border-danger focus:border-danger`:`border-border focus:border-primary/50`}`}),T&&x(`p`,{id:`integration-name-error`,"data-testid":`integration-name-error`,className:`mt-1 text-xs text-danger`,children:p(`integrations.nameRequired`,`Name is required`)})]}),t&&x(Sh,{schema:t,values:g,onChange:e=>{_(e),y(null)},onAction:async(i,a,o)=>{let s=await S.mutateAsync({addonId:e,action:i,input:o??{}});if(n&&typeof s==`object`&&s){let n=s;if(!(typeof n.token==`string`||typeof n.sslCertificate==`string`||typeof n.host==`string`))return s;let i={...g};for(let[e,t]of Object.entries(n))typeof t==`string`&&e!==`summary`&&(i[e]=t);let a=Rn(t,i);_(a),y(null),b.mutate({addonId:e,id:null,values:a,...r===void 0?{}:{kind:r}})}return s}}),v&&x(Th,{verdict:v}),s(`div`,{className:`flex items-center justify-between pt-2`,children:[x(K,{variant:`unstyled`,onClick:f,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:p(`integrations.back`)}),s(`div`,{className:`flex items-center gap-2`,children:[u&&s(K,{variant:`outline`,size:`sm`,onClick:u,"data-testid":`integration-scan`,children:[x(fe,{className:`h-3.5 w-3.5`}),p(`integrations.scanFromForm`,`Scan the network`)]}),n&&x(K,{variant:`unstyled`,onClick:()=>b.mutate({addonId:e,id:null,values:Rn(t,g),...r===void 0?{}:{kind:r}}),disabled:b.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:b.isPending?p(`integrations.testing`):p(`integrations.testConnection`)}),s(`div`,{className:`flex flex-col items-end gap-1`,children:[T&&x(`p`,{"data-testid":`integration-name-submit-error`,className:`text-xs text-danger`,children:p(`integrations.nameRequiredSubmit`,`Enter a name before continuing.`)}),x(K,{variant:`unstyled`,onClick:()=>{T||d({name:m,config:Rn(t,g)})},disabled:!E||l,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:l?p(`integrations.saving`,{defaultValue:`Saving…`}):o??p(`integrations.forward`)})]})]})]})]})}var f_=new Set([`@camstack/server`,`@camstack/types`,`@camstack/sdk`,`@camstack/shm-ring`,`@camstack/ui-library`]);function p_(e){return e!==void 0&&f_.has(e)}var m_=`@camstack/addon-agent-ui`;function h_(e){return p_(e)||e===m_}function g_(e){return e.integrationSection===void 0?p_(e.packageName)?`system`:`providers`:e.integrationSection}function __(e){let t=new Set;for(let n of e??[])g_(n.manifest)===`system`&&t.add(n.manifest.id);return t}function v_(e,t){return{providers:e.filter(e=>!t.has(e.addonId)),system:e.filter(e=>t.has(e.addonId))}}function y_(e,t){return[...e].sort((e,n)=>e.name.localeCompare(n.name,t,{sensitivity:`base`}))}var b_=/\.(svg|png|jpe?g|webp)$/i,x_=`provider-`;function S_(e){return typeof e==`string`&&b_.test(e)&&!e.includes(`..`)}function C_(e){let t=[];for(let n of e??[]){let e=n,r=e?.manifest?.id;if(typeof r!=`string`||r.length===0)continue;let i=e?.declaration?.icon??e?.manifest?.icon;S_(i)&&t.push([r,i])}return new Map(t)}function w_(e,t){if(!t)return null;let n=t.startsWith(x_)?[t]:[t,`${x_}${t}`];for(let t of n){let n=e.get(t);if(n)return U(`/api/addon-assets/${encodeURIComponent(t)}/${n}`)}return null}O();var T_=5*6e4,E_=j(new Map);function D_({children:e}){let{data:t}=Oi(void 0,{staleTime:T_}),n=m(()=>C_(t),[t]);return x(E_.Provider,{value:n,children:e})}function O_(e){return w_(L(E_),e)}O();var k_={amcrest:{icon:Zn,color:`#3b82f6`,label:`Amcrest`},hikvision:{icon:pe,color:`#a855f7`,label:`Hikvision`},reolink:{icon:we,color:`#06b6d4`,label:`Reolink`},homeassistant:{icon:ke,color:`#22d3ee`,label:`Home Assistant`},rtsp:{icon:Ze,color:`#78716c`,label:`RTSP`},onvif:{icon:Ze,color:`#78716c`,label:`ONVIF`}},A_={sm:`h-4 w-4`,md:`h-5 w-5`,lg:`h-6 w-6`,xl:`h-16 w-16`},j_={sm:`h-7 w-7`,md:`h-8 w-8`,lg:`h-10 w-10`,xl:`h-16 w-16`};function M_(e){let t=e.toLowerCase();return t.startsWith(`provider-`)?t.slice(9):t}function N_(e){return k_[M_(e)]??{icon:Zn,color:`#78716c`,label:e}}function P_({type:e,size:t=`md`,showLabel:n,iconUrl:r}){let i=N_(e),a=i.icon,[o,c]=w(new Set),l=[r,O_(e)].find(e=>typeof e==`string`&&e!==``&&!o.has(e));return s(`div`,{className:`flex items-center gap-2`,children:[x(`div`,{className:`flex items-center justify-center rounded-lg ${j_[t]}`,style:{backgroundColor:`${i.color}15`},children:l===void 0?x(a,{className:A_[t],style:{color:i.color}}):x(`img`,{src:l,alt:i.label,className:A_[t],onError:()=>c(e=>new Set([...e,l]))})}),n&&x(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:i.label})]})}function F_({children:e}){return x(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3`,children:e})}function I_({addonId:e,name:t,openLabel:n,onOpen:r,body:i,footer:a,disabled:o=!1,testId:c,buttonTestId:l,iconUrl:u}){return s(`article`,{"data-testid":c,className:`relative flex min-w-0 items-stretch gap-3 overflow-x-clip rounded-lg border border-border bg-surface p-3`,children:[x(K,{type:`button`,variant:`ghost`,"aria-label":n,disabled:o,"data-testid":l,onClick:r,className:`absolute inset-0 z-0 h-auto w-auto rounded-lg p-0 focus-visible:ring-2 focus-visible:ring-primary`}),x(`div`,{className:`pointer-events-none relative z-10 flex w-20 shrink-0 items-center justify-center`,children:x(P_,{type:e,size:`xl`,...u===void 0?{}:{iconUrl:u}})}),s(`div`,{className:`pointer-events-none relative z-10 grid min-w-0 flex-1 grid-rows-[1fr_auto_1fr] gap-1`,children:[x(`p`,{className:`min-w-0 self-start truncate text-sm font-semibold text-foreground`,children:t}),i,x(`div`,{className:`self-end justify-self-start`,children:a})]})]})}function L_({kind:e,children:t}){let{t:n}=J(),r=`integrations-section-${e}`;return s(`section`,{"aria-labelledby":r,"data-testid":r,className:`min-w-0 space-y-2`,children:[x(`h2`,{id:r,className:ve,children:e===`providers`?n(`integrations.sections.providers`,`Providers`):n(`integrations.sections.system`,`System`)}),t]})}var R_=`(hover: none) and (pointer: coarse)`;function z_(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return!0;try{return!window.matchMedia(R_).matches}catch{return!0}}O();function B_(e,t){return`${e.name} ${e.description} ${e.addonId}`.toLowerCase().includes(t)}function V_({onSelect:e,onClose:t,pendingAddonId:n=null,source:r}){let{t:i,i18n:a}=J(),o=wc(),[c,l]=w(``),u=p(null),d=pa(void 0,{enabled:r===void 0}),f=r===void 0?d.data:void 0,h=r===void 0&&d.isLoading;S(()=>{h||!z_()||u.current?.focus()},[h]);let{data:g}=Oi(void 0),_=n!==null,v=m(()=>r===void 0?(f??[]).map(n=>{let r=n.instanceMode===`unique`&&n.existingInstances.length>0;return{key:n.addonId,addonId:n.addonId,name:n.name,description:n.description??``,open:()=>{let i=n.existingInstances[0];r&&i!==void 0?(t(),o(o_(n.addonId,i.id))):e(n.addonId,n.instanceMode,n.discoveryMode,n.providerLabel??n.name,n.kind,n.brokerKind,n.mode,n.canTest)},footer:r?s(`span`,{className:`flex items-center gap-1 text-xs font-medium text-foreground-subtle`,children:[x(se,{className:`h-3 w-3`}),i(`integrations.manage`)]}):null}}):r.providers.map(e=>({...e,key:e.kind===void 0?e.addonId:`${e.addonId}-${e.kind}`,open:()=>r.onPick(e.addonId,e.kind),footer:null})),[r,f,t,e,o,i]),y=m(()=>{let e=c.trim().toLowerCase();return e.length===0?v:v.filter(t=>B_(t,e))},[v,c]),b=m(()=>{let e=v_(y,__(g));return{providers:y_(e.providers,a.language),system:y_(e.system,a.language)}},[y,g,a.language]);if(h)return x(`div`,{className:`grid grid-cols-1 gap-2 p-2 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3,4].map(e=>x(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let C=e=>x(F_,{children:e.map(e=>x(I_,{testId:`provider-card-${e.key}`,buttonTestId:`provider-pick-${e.key}`,addonId:e.addonId,...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl},name:e.name,openLabel:e.name,disabled:_,onOpen:e.open,body:e.description.length>0?x(`p`,{className:`line-clamp-2 text-xs text-foreground-muted`,children:e.description}):x(`span`,{}),footer:n===e.addonId?x(W,{className:`h-4 w-4 animate-spin text-primary`}):e.footer},e.key))});return s(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[s(`div`,{className:`relative`,children:[x(ee,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),x(G,{ref:u,type:`search`,value:c,onChange:e=>l(e.target.value),placeholder:i(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"data-dialog-autofocus":!0,"aria-label":i(`integrations.searchProviders`,`Search integrations…`)})]}),b.providers.length>0&&x(L_,{kind:`providers`,children:C(b.providers)}),b.system.length>0&&x(L_,{kind:`system`,children:C(b.system)}),y.length===0&&x(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:v.length===0?i(`integrations.noProviders`):i(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}function H_(e){return e.setupIntegration===!0||e.prefilledConfig.setupIntegration===!0}function U_(e,t,n){let r={};for(let[e,n]of Object.entries(t.prefilledConfig))e!==`setupIntegration`&&(r[e]=typeof n==`string`&&e===`host`?n.trim():n);let i=n?.trim()??``;return{addonId:e,name:i.length>0?Ln(i):t.suggestedName,config:r,...t.stableId===void 0?{}:{originStableId:t.stableId}}}function W_(e,t,n){return H_(t)?U_(e,t,n):null}function G_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K_(e){if(!G_(e)||!G_(e.integrationSeed))return null;let t=e.integrationSeed,n=t.addonId,r=t.name,i=t.config;if(typeof n!=`string`||n.length===0||typeof r!=`string`||!G_(i))return null;let a={};for(let[e,t]of Object.entries(i))a[e]=t;let o=t.originStableId;return{addonId:n,name:r,config:a,...typeof o==`string`&&o.length>0?{originStableId:o}:{}}}function q_(e){let t=new Map;for(let n of e)t.set(n.stableId,n);let n=e=>{let n=e.parentStableId;if(n===void 0||n===e.stableId)return null;let r=t.get(n);if(r===void 0)return null;let i=new Set([e.stableId]),a=r;for(;a!==void 0;){if(i.has(a.stableId))return null;i.add(a.stableId),a=a.parentStableId===void 0?void 0:t.get(a.parentStableId)}return r},r=new Map,i=[];for(let t of e){let e=n(t);if(e===null){i.push(t);continue}let a=r.get(e.stableId)??[];a.push(t),r.set(e.stableId,a)}let a=e=>({candidate:e,children:(r.get(e.stableId)??[]).map(a)});return i.map(a)}function J_(e){return e.flatMap(e=>[e.candidate,...J_(e.children)])}var Y_=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/;function X_(e){let t=Y_.exec(e.trim());if(t===null)return{ok:!1,reason:`format`};let n=[t[1],t[2],t[3],t[4]].map(e=>Number(e));if(n.some(e=>e>255))return{ok:!1,reason:`format`};let r=Number(t[5]);return r>32?{ok:!1,reason:`format`}:r<22?{ok:!1,reason:`prefix`}:{ok:!0,cidr:`${n.join(`.`)}/${r}`}}O();function Z_(){let{t:e}=J(),t=xr(),n=Tr({onSuccess:()=>void t.refetch()}),[r,i]=w(``),[a,o]=w(null),c=t.data?.subnets??[],l=async t=>{try{return await n.mutateAsync({subnets:[...t]}),!0}catch{return o(e(`integrations.scanNetworkModal.subnets.saveFailed`,`The network list could not be saved.`)),!1}},u=async()=>{let t=X_(r);if(!t.ok){o(t.reason===`prefix`?e(`integrations.scanNetworkModal.subnets.errorPrefix`,`A network larger than a /22 cannot be scanned.`):e(`integrations.scanNetworkModal.subnets.errorFormat`,`Enter a network like 192.0.2.0/24.`));return}if(c.includes(t.cidr)){o(e(`integrations.scanNetworkModal.subnets.errorDuplicate`,`Already in the list.`));return}o(null),await l([...c,t.cidr])&&i(``)};return s(`section`,{className:`space-y-2`,"data-testid":`scan-subnets`,children:[x(`h3`,{className:ve,children:e(`integrations.scanNetworkModal.subnets.title`,`Extra networks to scan`)}),x(`p`,{className:`text-xs text-foreground-muted`,children:c.length===0?e(`integrations.scanNetworkModal.subnets.none`,`Only this hub's own networks are scanned.`):e(`integrations.scanNetworkModal.subnets.hint`,`Every scan covers this hub's own networks and these.`)}),c.length>0&&x(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>x(Si,{label:e,testId:`scan-subnet-${e}`,onRemove:()=>void l(c.filter(t=>t!==e))},e))}),s(`div`,{className:`flex items-start gap-2`,children:[s(`div`,{className:`min-w-0 flex-1`,children:[x(G,{value:r,onChange:e=>{i(e.target.value),o(null)},onKeyDown:e=>{e.key===`Enter`&&u()},placeholder:`192.0.2.0/24`,state:a===null?`default`:`error`,"aria-label":e(`integrations.scanNetworkModal.subnets.title`,`Extra networks to scan`),"data-testid":`scan-subnet-input`}),a!==null&&x(`p`,{className:`mt-1 text-xs text-danger`,children:a})]}),s(K,{variant:`outline`,size:`sm`,onClick:()=>void u(),disabled:n.isPending||r.trim().length===0,"data-testid":`scan-subnet-add`,children:[x(We,{className:`h-3.5 w-3.5`}),e(`integrations.scanNetworkModal.subnets.add`,`Add network`)]})]})]})}O();function Q_({open:e,onClose:t,scope:n,onSetupIntegration:r,pickMode:i=`adopt`}){let{t:a}=J(),o=ai(),[c,l]=w(new Set),[u,d]=w(new Set),[f,p]=w(new Set),{data:h}=gi({projection:`slim`}),g=m(()=>new Set((h??[]).map(e=>e.stableId)),[h]),_=b(async(e,t)=>{d(e=>new Set(e).add(t.stableId));try{await o.mutateAsync({addonId:e,candidate:t}),l(e=>new Set(e).add(t.stableId)),p(e=>{let n=new Set(e);return n.delete(t.stableId),n})}catch{}finally{d(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[o]),v=b(async(e,n)=>{let a=i===`fill`?U_(e,n):W_(e,n);if(a!==null){r?.(a),t();return}await _(e,n)},[_,t,r,i]),y=b(e=>{p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),S=b(()=>{l(new Set),p(new Set)},[]),C=m(()=>({existingStableIds:g,adopted:c,adopting:u,selection:{selected:f,toggle:y},pick:v,adoptOne:_,fill:i===`fill`}),[g,c,u,f,y,v,i]),T=n?a(`integrations.scanNetworkModal.titleScoped`,`Scan network — {{label}}`,{label:n.label}):a(`integrations.scanNetworkModal.title`,`Scan network for devices`);return x(si,{open:e,onOpenChange:e=>!e&&t(),children:s(Dr,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[x(Pr,{children:x(hi,{children:s(`span`,{className:`flex items-center gap-2`,children:[x(fe,{className:`h-4 w-4 text-primary`}),T]})})}),s(fi,{className:`space-y-4`,children:[x(Z_,{}),n?x(av,{scope:n,row:C,onReset:S}):x(iv,{row:C,onReset:S})]})]})})}function $_(e,t){return!t&&e.selectable!==!1&&!H_(e)}function ev({addonId:e,nodes:t,row:n,depth:r}){return x(`div`,{className:r===0?`space-y-1.5`:`ml-4 space-y-1.5 border-l border-border pl-3`,"data-testid":r===0?void 0:`scan-children`,children:t.map(t=>s(`div`,{className:`space-y-1.5`,children:[x(tv,{addonId:e,candidate:t.candidate,row:n}),t.children.length>0&&x(ev,{addonId:e,nodes:t.children,row:n,depth:r+1})]},t.candidate.stableId))})}function tv({addonId:e,candidate:t,row:n}){let{t:r}=J(),i=t.prefilledConfig.host,a=typeof i==`string`?i:null,o=n.existingStableIds.has(t.stableId)||t.alreadyOnboarded===!0||t.onboardedDeviceId!==void 0,c=n.adopted.has(t.stableId)||o,l=n.adopting.has(t.stableId),u=n.fill||H_(t),d=!c&&(u||t.selectable!==!1),f=d&&$_(t,n.fill);return s(`div`,{className:`flex items-center gap-3 rounded-lg border border-border bg-surface px-3 py-2`,"data-testid":`scan-row-${t.stableId}`,children:[f&&x(Oe,{checked:n.selection.selected.has(t.stableId),onChange:()=>n.selection.toggle(t.stableId),disabled:l,"aria-label":r(`integrations.scanNetworkModal.select`,`Select {{name}}`,{name:t.suggestedName})}),s(`div`,{className:`min-w-0 flex-1`,children:[x(`p`,{className:`truncate text-xs font-medium text-foreground`,children:t.suggestedName}),a&&x(`p`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,children:a}),o&&t.onboardedName!==void 0&&x(`p`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.onboardedName})]}),c?s(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[x(ot,{className:`h-3.5 w-3.5`}),` `,o?r(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):r(`integrations.scanNetworkModal.added`,`Added`)]}):d?s(K,{size:`sm`,variant:u?`outline`:`primary`,onClick:()=>void n.pick(e,t),disabled:l,children:[l?x(W,{className:`h-3.5 w-3.5 animate-spin`}):u?null:x(dt,{className:`h-3.5 w-3.5`}),u?n.fill?r(`integrations.scanNetworkModal.use`,`Use`):r(`integrations.scanNetworkModal.setUp`,`Set up`):r(`common.add`,`Add`)]}):null]})}function nv({addonId:e,label:t,candidates:n,row:r}){let i=m(()=>q_(n),[n]);return s(`section`,{className:`space-y-2`,"data-testid":`scan-group-${e}`,children:[s(`h3`,{className:`flex items-center gap-2`,children:[x(P_,{type:e,size:`sm`}),x(`span`,{className:ve,children:t}),s(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,n.length,`)`]})]}),x(ev,{addonId:e,nodes:i,row:r,depth:0})]})}function rv(e,t){return e.flatMap(e=>J_(q_(e.candidates)).filter(e=>$_(e,t)).map(t=>({addonId:e.addonId,candidate:t})))}function iv({row:e,onReset:t}){let{t:n}=J(),r=Mr(),i=b(()=>{t(),r.mutate({})},[r,t]);S(()=>{!r.isPending&&!r.data&&i()},[]);let a=m(()=>(r.data?.groups??[]).filter(e=>e.candidates.length>0),[r.data]),o=m(()=>a.reduce((e,t)=>e+t.candidates.length,0),[a]),c=m(()=>rv(a,e.fill),[a,e.fill]);return s(`div`,{className:`space-y-4`,children:[s(`div`,{className:`flex items-center justify-between gap-2`,children:[x(`p`,{className:`text-xs text-foreground-subtle`,children:!r.isPending&&a.length>0?n(`integrations.scanNetworkModal.found`,{count:o}):null}),s(`div`,{className:`flex items-center gap-2`,children:[x(ov,{entries:c,row:e}),s(K,{variant:`outline`,size:`sm`,onClick:i,disabled:r.isPending,children:[x(Ee,{className:`h-3.5 w-3.5 ${r.isPending?`animate-spin`:``}`}),n(`integrations.scanNetworkModal.reScan`,`Re-scan`)]})]})]}),r.isPending&&x(cv,{label:n(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!r.isPending&&r.isError&&x(lv,{}),!r.isPending&&r.data&&a.length===0&&x(sv,{}),!r.isPending&&a.map(t=>x(nv,{addonId:t.addonId,label:t.label,candidates:t.candidates,row:e},t.addonId))]})}function av({scope:e,row:t,onReset:n}){let{t:r}=J(),i=ra({addonId:e.addonId}).data??null,[a,o]=w({}),c=ni(),l=b(()=>{n(),c.mutate({addonId:e.addonId,params:a})},[c,e.addonId,a,n]),u=m(()=>c.data?.candidates??[],[c.data]),d=m(()=>rv([{addonId:e.addonId,candidates:u}],t.fill),[e.addonId,u,t.fill]);return s(`div`,{className:`space-y-4`,children:[i&&x(Sh,{schema:i,values:a,onChange:o}),s(K,{onClick:l,disabled:c.isPending,children:[c.isPending?x(W,{className:`h-3.5 w-3.5 animate-spin`}):x(fe,{className:`h-3.5 w-3.5`}),c.isPending?r(`integrations.scanNetworkModal.scanning`,`Scanning…`):r(`integrations.scanNetworkModal.scan`,`Scan`)]}),x(ov,{entries:d,row:t}),c.isError&&x(lv,{}),!c.isPending&&c.data&&u.length===0&&x(sv,{}),!c.isPending&&u.length>0&&s(`div`,{className:`space-y-2`,children:[x(`p`,{className:`text-xs text-foreground-subtle`,children:r(`integrations.scanNetworkModal.foundShort`,{count:u.length})}),x(nv,{addonId:e.addonId,label:e.label,candidates:u,row:t})]})]})}function ov({entries:e,row:t}){let{t:n}=J(),r=e.filter(e=>t.selection.selected.has(e.candidate.stableId));if(r.length===0)return null;let i=async()=>{for(let e of r)await t.adoptOne(e.addonId,e.candidate)};return s(K,{size:`sm`,onClick:()=>void i(),"data-testid":`scan-add-selected`,children:[x(dt,{className:`h-3.5 w-3.5`}),n(`integrations.scanNetworkModal.addSelected`,`Add selected ({{count}})`,{count:r.length})]})}function sv(){let{t:e}=J();return x(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:e(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)})}function cv({label:e}){return s(`div`,{className:`flex flex-col items-center py-12`,children:[x(W,{className:`h-6 w-6 animate-spin text-primary`}),x(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:e})]})}function lv(){let{t:e}=J();return s(`div`,{className:`flex items-start gap-3 rounded-lg border border-danger/40 bg-danger/10 px-4 py-3`,children:[x(Ae,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`}),x(`p`,{className:`text-xs text-danger`,children:e(`integrations.scanNetworkModal.theScanFailedTryAgain`,`The scan failed. Try again.`)})]})}O();function uv(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}var dv=2e4;function fv({open:e,onClose:t,seed:n=null,pickFrom:r}){let{t:i}=J(),a=wc(),o=N(),[c,l]=w(`picker`),[u,d]=w(null),[f,p]=w(null),[h,g]=w(`manual`),[_,v]=w(null),[y,b]=w(``),[C,T]=w(null),[E,D]=w(null),[O,k]=w(!1),[A,j]=w({}),[M,P]=w(``),[F,L]=w(!1),[R,z]=w(0),[ee,te]=w(``),ne=Ia({},{enabled:e&&c===`config`}),B=(pi({addonId:u??``},{enabled:e&&c===`config`&&u!==null}).data?.kinds??[]).filter(e=>e.canTest!==!1),re=B.length===1?B[0]?.id:void 0,ie=u!==null&&(ne.data?.providers??[]).some(e=>e.addonId===u),V=n?.config.host,ae=n===null?``:`${n.addonId}\0${n.name}\0${typeof V==`string`?V:``}`;e&&n!==null&&M!==ae&&(P(ae),d(n.addonId),b(n.name),j({...n.config}),l(`config`));let oe=pa(void 0,{enabled:e&&n!==null}),se=oe.data?.find(e=>e.addonId===u)?.mode??`account`,{data:ce}=vi({addonId:u??``,id:null,mode:se,...n?.originStableId===void 0?{}:{candidateStableId:n.originStableId}},{enabled:u!=null}),le=m(()=>ce?uv(ce):null,[ce]),H=Nr({onSuccess:()=>{o.invalidateQueries({queryKey:[[`integrations`]]}),o.invalidateQueries({queryKey:[[`integrationInstances`]]})}}),ue=Vr(),U=ue.data;S(()=>{if(!e||n===null)return;let t=oe.data?.find(e=>e.addonId===n.addonId);if(!t)return;k(t.canTest),g(t.discoveryMode);let r=t.providerLabel??t.name;typeof r==`string`&&r.length>0&&b(pn({providerLabel:r,mode:t.mode,brokerKind:t.brokerKind}))},[e,n,oe.data]),S(()=>{c!==`discovery`||!f||!u||ue.isPending||ue.data||ue.mutate({addonId:u})},[c,f,u,ue]);let de=ai({onSuccess:()=>o.invalidateQueries({queryKey:[[`deviceManager`]]})});function fe(e,t,n,r,i,a,o,s){if(H.isPending)return;let c=pn({providerLabel:r,mode:o,brokerKind:a});if(d(e),k(s),g(n),b(c),D(null),H.reset(),o===`broker`){if(!a){D(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}v(a),l(`broker`);return}if(o===`account`){l(`config`);return}pe(e,c)}async function pe(e,n){try{let r=await H.mutateAsync({addonId:e,name:n,values:{}});t(),ve(),a(`${o_(e,r.id)}&add=1`)}catch{}}async function me(e){if(u)try{let t=await H.mutateAsync({addonId:u,name:e.name,values:e.config,...re===void 0?{}:{kind:re},...n!==null&&n.addonId===u&&n.originStableId!==void 0?{originStableId:n.originStableId}:{}});p(t.id),T(t.id),h===`auto`||h===`both`?l(`discovery`):_e(t.id,{openAdd:!0})}catch{}}async function he(e){if(u)try{let t=await H.mutateAsync({addonId:u,name:y,values:{brokerId:e}});T(t.id),p(t.id),_e(t.id)}catch{}}async function ge(e){if(u){for(let t of e){let e=U?.find(e=>e.stableId===t);e&&await de.mutateAsync({addonId:u,candidate:e,...C===null?{}:{integrationId:C}})}_e()}}function _e(e,n){let r=e??f??u;if(t(),ve(),r&&u){let e=o_(u,r);a(n?.openAdd===!0?`${e}&add=1`:e)}}function ve(){l(`picker`),d(null),p(null),g(`manual`),v(null),b(``),T(null),D(null),H.reset(),k(!1),j({}),P(``)}function ye(){t(),ve()}s_(e);let be=H.isPending,xe=c_(be,dv);if(!e)return null;let Se={picker:r?.title??i(`integrations.newIntegration`),config:i(`integrations.configureIntegration`),discovery:i(`integrations.importDevices`),broker:i(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},Ce=be?u:null,we=H.error,Te=be&&!xe;return s(I,{children:[x(si,{open:!0,onOpenChange:e=>{!e&&!Te&&ye()},children:s(Dr,{width:c===`picker`?`xl`:`lg`,scroll:`body`,onCancel:e=>{Te&&e.preventDefault()},children:[x(Pr,{children:x(hi,{children:Se[c]})}),s(fi,{children:[we&&!be&&x(`div`,{className:`mb-3 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:we instanceof Error?we.message:String(we)}),c===`picker`&&s(I,{children:[E&&x(`div`,{className:`mb-3 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:E}),x(V_,{onSelect:fe,onClose:ye,pendingAddonId:Ce,...r===void 0?{}:{source:r}})]}),c===`config`&&u&&x(d_,{addonId:u,configSchema:le??null,canTest:O,...re===void 0?{}:{instanceKind:re},initialName:y.length>0?y:void 0,initialConfig:{...A},onScan:ie?()=>{te(y.length>0?y:u),L(!0)}:void 0,onSave:me,onBack:()=>{j({}),l(`picker`)}},`${ae.length>0?ae:u}:${y}:${R}`),c===`broker`&&_&&x(l_,{kind:_,onResolved:e=>{he(e)},onBack:()=>l(`picker`)}),c===`discovery`&&f&&x(u_,{providerId:f,onImport:ge,onSkip:_e})]}),be&&s(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-lg bg-background/85 backdrop-blur-sm px-6 text-center`,children:[x(W,{className:`h-6 w-6 animate-spin text-primary`}),x(`p`,{className:`text-xs font-medium text-foreground`,children:i(`integrations.creating`,{defaultValue:`Creating integration…`})}),!xe&&x(`p`,{className:`text-[10px] text-foreground-subtle`,children:i(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),xe&&s(I,{children:[x(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:i(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),x(K,{variant:`unstyled`,onClick:ye,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:i(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})}),F&&u!==null&&x(Q_,{open:F,scope:{addonId:u,label:ee},pickMode:`fill`,onClose:()=>L(!1),onSetupIntegration:e=>{b(e.name),j({...e.config}),z(e=>e+1)}})]})}O();function pv({functionCap:e,disabled:t,onCreated:n}){let{t:r}=J(),{options:i}=$g({functionCap:e,match:`link`}),[a,o]=w({at:`closed`});if(i.length===0)return null;let c=()=>o({at:`closed`});return s(I,{children:[s(K,{variant:`outline`,size:`sm`,disabled:t,onClick:()=>{let e=i.length===1?i[0]:void 0;o(e===void 0?{at:`choose`}:{at:`edit`,option:e})},children:[x(We,{className:`h-3.5 w-3.5`}),` `,r(`brokers.picker.createNew`)]}),a.at===`choose`&&x(fv,{open:!0,onClose:c,pickFrom:{title:r(`brokers.picker.createNew`),providers:i.map(e=>({addonId:e.addonId,kind:e.kind,name:e.label,description:``,...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl}})),onPick:(e,t)=>{let n=i.find(n=>n.addonId===e&&n.kind===t);o(n===void 0?{at:`closed`}:{at:`edit`,option:n})}}}),a.at===`edit`&&x(t_,{functionCap:e,addonId:a.option.addonId,kind:a.option.kind,match:`link`,onClose:c,onSaved:e=>{c(),n(e)}})]})}var mv=`broker`;function hv({functionCap:e,kind:t,noneLabel:n,required:r,disabled:i,value:a,onChange:o}){return e===mv&&t!==void 0?x(r_,{kind:t,value:a,onChange:o,optional:r===!1,disabled:i===!0,...n===void 0?{}:{noneLabel:n}}):s(`div`,{className:`space-y-2`,children:[x(ti,{functionCap:e,...t===void 0?{}:{kind:t},...n===void 0?{}:{noneLabel:n},value:a??``,disabled:i===!0,onChange:e=>o(e===``?null:e),controlId:`instance-picker-${e}-${t??`any`}`}),t===void 0&&x(`div`,{children:x(pv,{functionCap:e,disabled:i===!0,onCreated:o})})]})}function gv(e,t){return t.map(t=>({subject:{kind:`device`,deviceId:e},key:t.key,scope:t.scope}))}function _v({deviceId:e}){let{t}=J(),{presence:n,list:r}=ia(e);return n===`absent`?null:n===`unknown`?x(gr,{message:t(`deviceQuickDetail.historyUnknown`,`Could not tell whether this device has recorded history.`)}):n===`pending`||r.status===`pending`?x(dr,{className:`h-24 w-full`,"aria-busy":`true`}):r.status===`error`?x(gr,{title:t(`deviceQuickDetail.historyUnknown`,`Could not tell whether this device has recorded history.`),message:r.error}):r.data.length===0?null:s(`section`,{className:`flex flex-col gap-2`,"aria-label":t(`deviceQuickDetail.tabHistory`,`History`),children:[x(`div`,{className:`flex justify-end`,children:x(Wl,{to:Pi(gv(e,r.data)),className:`text-xs text-primary hover:underline`,children:t(`deviceQuickDetail.openHistory`,`Open full history`)})}),x(na,{deviceId:e})]})}function vv(e,t){return e===`present`&&t.status===`ok`&&(t.data?.length??0)>0}var yv={streaming:{icon:me,labelKey:`capabilityBadges.streaming`},detection:{icon:Me,labelKey:`capabilityBadges.detection`},recording:{icon:Te,labelKey:`capabilityBadges.recording`},audio:{icon:B,labelKey:`capabilityBadges.audio`},snapshot:{icon:Ve,labelKey:`capabilityBadges.snapshot`},motion:{icon:ft,labelKey:`capabilityBadges.motion`},ptz:{icon:se,labelKey:`capabilityBadges.ptz`},webrtc:{icon:we,labelKey:`capabilityBadges.webrtc`},onvif:{icon:qe,labelKey:`capabilityBadges.onvif`},analytics:{icon:Ke,labelKey:`capabilityBadges.analytics`},"battery-operated":{icon:le,labelKey:`capabilityBadges.battery`},"native-snapshot":{icon:Ve,labelKey:`capabilityBadges.nativeSnapshot`},"pan-tilt-zoom":{icon:se,labelKey:`capabilityBadges.ptz`},"two-way-audio":{icon:B,labelKey:`capabilityBadges.twoWayAudio`},"doorbell-button":{icon:ie,labelKey:`capabilityBadges.doorbell`},rebootable:{icon:Ee,labelKey:`capabilityBadges.rebootable`},"vacuum-has-ai":{icon:gt,labelKey:`capabilityBadges.aiObstacle`},"mower-has-targeted-mowing":{icon:et,labelKey:`capabilityBadges.targetedMowing`}},bv=Fe;function xv({capabilities:e,showLabels:t=!1}){let{t:n}=J();return x(`div`,{className:`flex items-center gap-1 flex-wrap`,children:e.map(e=>{let r=yv[e],i=r?.icon??bv,a=r?n(r.labelKey):e;return s(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] text-foreground-subtle`,title:a,children:[x(i,{className:`h-3 w-3`}),t&&x(`span`,{children:a})]},e)})})}function Sv({label:e,value:t,layout:n=`inline`}){return n===`stacked`?s(`div`,{className:`min-w-0 flex flex-col gap-0.5 px-0.5`,children:[x(`span`,{className:`text-[11px] text-foreground-subtle`,children:e}),x(`div`,{className:`min-w-0 text-[11px] text-foreground`,children:t})]}):s(`div`,{className:`${ge} flex items-start gap-2 sm:gap-3`,children:[x(`span`,{className:`w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle`,children:e}),x(`div`,{className:`flex-1 min-w-0 text-[11px] text-foreground`,children:t})]})}O();function Cv(e){return gi({addonId:e,projection:`slim`})}function wv(e){return Or({deviceId:e},{enabled:Number.isFinite(e)})}var Tv=3e4,Ev=2e3;function Dv(e){let t=p(0);return t.current===0&&(t.current=Date.now()),ci({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>=Tv?!1:Ev}})}O();function Ov({deviceId:e}){let{t}=J(),n=N(),{data:r}=wv(e),{data:i}=Dv(e),[a,o]=w(null),c=Aa({onSuccess:()=>{o(null),n.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{o(`Could not change primary child: ${e.message}`)}});if(r==null)return null;let l=String(r.type??``);if(l!==on.Container)return null;let u=String(r.name??``),d=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:Ki(e,u),...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}}));if(d.length<=1)return null;let f=La(d,typeof r.linkDeviceId==`number`?r.linkDeviceId:null,typeof r.primaryChildEntityId==`string`?r.primaryChildEntityId:null,l,Jt(r)),p=f===null?d[0].id:f.id;return s(I,{children:[x(Sv,{label:t(`shared.primaryChildRow.primaryChild`,`Primary child`),value:x(Hr,{childrenList:d,selectedId:p,onSetPrimary:t=>c.mutate({deviceId:e,primaryChildEntityId:t}),disabled:c.isPending})}),a!==null&&x(`p`,{role:`alert`,className:`px-3 sm:px-4 py-1.5 text-[11px] text-danger`,children:a})]})}O();var kv=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`],Av=[`mac`,`serial`,`vendor-uid`,`machine-uuid`,`hostname`,`ip`];function jv(e){let t=Vn.safeParse(e);if(!t.success)return[];let n=t.data;return Av.flatMap(e=>{if(e===`mac`)return(n.mac??[]).map(t=>({key:e,value:t.value,derived:t.origin===`derived`}));let t=n[e];return t?[{key:e,value:t.value,derived:t.origin===`derived`}]:[]})}function Mv(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function Nv(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function Pv(){let{t:e}=J(),t=yi(),n=ya(),{data:r}=Or({deviceId:t??0},{enabled:t!==null}),{data:i}=Ar({deviceId:t??0},{enabled:t!==null}),a=r??n??null,[o,c]=w(`identity`);if(t===null||!a)return null;let l=String(a.stableId??``),u=String(a.addonId??``),d=typeof a.integrationId==`string`&&a.integrationId.length>0?a.integrationId:null,f=typeof a.parentDeviceId==`number`?a.parentDeviceId:null,p=a.features??[],m=new Set([`device-status`,`feature-probe`,`device-ops`]),h=(i?.entries??[]).filter(e=>e.kind===`native`&&!m.has(e.capName)).map(e=>e.capName),g=p.length>0?p:h,_=a.metadata??null,v=jv(a.identifiers),y=_!==null&&Object.keys(_).length>0||v.length>0;return s(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[s(`div`,{className:`border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3`,children:[x(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:e(`overviewAdapters.deviceInfoAdapter.deviceInfo`,`Device Info`)}),y&&s(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[x(Fv,{active:o===`identity`,onClick:()=>c(`identity`),label:e(`overviewAdapters.deviceInfoAdapter.identity`,`Identity`)}),x(Fv,{active:o===`hardware`,onClick:()=>c(`hardware`),label:e(`overviewAdapters.deviceInfoAdapter.hardware`,`Hardware`)})]})]}),(!y||o===`identity`)&&s(`div`,{className:`divide-y divide-border`,children:[x(Sv,{label:`ID`,value:s(`span`,{className:`font-mono text-[11px] text-foreground`,children:[`#${t}`,s(`span`,{className:`ml-1.5 text-foreground-subtle`,children:[`(`,l,`)`]})]})}),x(Ov,{deviceId:t}),d!==null&&x(Sv,{label:e(`overviewAdapters.deviceInfoAdapter.integration`,`Integration`),value:x(`span`,{className:`font-mono text-[11px]`,children:d})}),f!==null&&x(Sv,{label:e(`overviewAdapters.deviceInfoAdapter.parent`,`Parent`),value:x(`span`,{className:`font-mono text-[11px]`,children:`#${String(f)}`})}),x(Sv,{label:e(`overviewAdapters.deviceInfoAdapter.provider`,`Provider`),value:x(P_,{type:u,size:`sm`,showLabel:!0})}),x(Sv,{label:e(`overviewAdapters.deviceInfoAdapter.capabilities`,`Capabilities`),value:g.length>0?x(xv,{capabilities:g,showLabels:!0}):x(`span`,{className:`text-[11px] text-foreground-subtle`,children:e(`overviewAdapters.deviceInfoAdapter.none`,`None`)})})]}),y&&o===`hardware`&&x(Iv,{metadata:_??{},identifiers:v})]})}function Fv({active:e,onClick:t,label:n}){return x(K,{variant:`unstyled`,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 Iv({metadata:e,identifiers:t}){let{t:n}=J(),r={mac:n(`overviewAdapters.deviceInfoAdapter.identifierMac`,`MAC address`),serial:n(`overviewAdapters.deviceInfoAdapter.identifierSerial`,`Serial number`),"vendor-uid":n(`overviewAdapters.deviceInfoAdapter.identifierVendorUid`,`Vendor ID`),"machine-uuid":n(`overviewAdapters.deviceInfoAdapter.identifierMachineUuid`,`Machine UUID`),hostname:n(`overviewAdapters.deviceInfoAdapter.identifierHostname`,`Hostname`),ip:n(`overviewAdapters.deviceInfoAdapter.identifierIp`,`IP address`)},i=kv.filter(t=>t in e),a=Object.keys(e).filter(e=>!kv.includes(e)).toSorted(),o=[...i,...a];return s(`div`,{children:[x(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border`,children:n(`overviewAdapters.deviceInfoAdapter.autoPopulatedByTheDriver`,`Auto-populated by the driver on every connect. Read-only.`)}),x(`div`,{className:`divide-y divide-border`,children:o.map(t=>x(Sv,{label:Mv(t),value:x(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:Nv(e[t])})},t))}),t.length>0&&s(I,{children:[x(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-y border-border`,children:n(`overviewAdapters.deviceInfoAdapter.identifiersDeclared`,`Identifiers declared by the provider. Read-only.`)}),x(`div`,{className:`divide-y divide-border`,children:t.map(e=>x(Sv,{label:r[e.key],value:s(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:[e.value,e.derived&&x(`span`,{className:`ml-1.5 text-foreground-subtle`,children:n(`overviewAdapters.deviceInfoAdapter.identifierDerived`,`(derived)`)})]})},`${e.key}:${e.value}`))})]})]})}function Lv(e,t){return e.icon===t.icon&&e.label===t.label&&e.unit===t.unit&&e.precision===t.precision&&e.hidden===t.hidden}function Rv(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function zv(e){if(e.trim()===``)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function Bv(e,t){let n=zv(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 Vv(e){let t=Rv(e.display),n=e.tags??[];return{name:e.name,location:e.location,role:e.role,display:t,tags:n,baseName:e.name,baseLocation:e.location,baseRole:e.role,baseDisplay:t,baseTags:n,persistedDisplay:e.display}}function Hv(e,t){if(e===null)return Vv(t);let n=Rv(t.display),r=e.name===t.name&&e.location===t.location&&e.role===t.role&&Wv(e.tags,t.tags??[])&&Lv(e.display,n);return!Uv(e)||r?Vv(t):e}function Uv(e){return e===null?!1:e.name!==e.baseName||e.location!==e.baseLocation||e.role!==e.baseRole||!Wv(e.tags,e.baseTags)||!Lv(e.display,e.baseDisplay)}function Wv(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Gv(e){return e.name.trim().length===0?`name`:null}function Kv(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},...Wv(e.tags,e.baseTags)?{}:{tags:[...e.tags]},...Lv(e.display,e.baseDisplay)?{}:{display:Bv(e.display,e.persistedDisplay)}}}function qv(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(`; `)}}O();var Jv=j(null);function Yv(){return L(Jv)}function Xv({deviceId:e,seed:t,showOpenFull:n=!1,onClose:r,children:i}){let[a,o]=w(null),[s,c]=w([]),l=p(new Map);if(t!==null){let e=Hv(a,t);(a===null||e.name!==a.name||e.location!==a.location||e.role!==a.role||!Wv(e.tags,a.tags)||!Wv(e.baseTags,a.baseTags)||!Lv(e.display,a.display)||e.baseName!==a.baseName||e.baseLocation!==a.baseLocation||e.baseRole!==a.baseRole||!Lv(e.baseDisplay,a.baseDisplay)||e.persistedDisplay!==a.persistedDisplay)&&o(e)}let u=b(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))}),[]),d=m(()=>({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})},setIdentityTags:e=>{o(t=>t===null?t:{...t,tags:e})},setIdentityDisplay:e=>{o(t=>t===null?t:{...t,display:{...t.display,...e}})},register:u}),[a,u]);return x(Jv.Provider,{value:d,children:x(Zv,{deviceId:e,identity:a,contributions:s,onIdentitySaved:e=>o(e),showOpenFull:n,onClose:r,children:i})})}function Zv({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:i,onClose:a,children:o}){return s(I,{children:[o,x($v,{deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:i,onClose:a})]})}function Qv(e){return e instanceof Error?e.message:String(e)}function $v({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:i,onClose:a}){let{t:o}=J(),c=wc(),l=Re(),u=N(),[d,f]=w(null),[p,m]=w(!1),h=ba(),g=ea(),_=wi(),v=sa(),y=mr(),b=qv([{dirty:Uv(t),saving:p,error:d},...n]),S=()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})};return!b.dirty&&!b.saving&&b.error===null&&!i?null:s(`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:[b.error!==null&&x(`p`,{className:`text-xs text-danger`,children:b.error}),s(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[i?x(K,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{(async()=>{b.dirty&&!await l({title:o(`deviceQuickDetail.leaveTitle`,`Discard unsaved changes?`),message:o(`deviceQuickDetail.leaveMessage`,`Unsaved edits on this device will be discarded.`),confirmLabel:o(`deviceQuickDetail.discard`,`Discard`),variant:`warning`})||(c(`/devices/${String(e)}?tab=customize`),a?.())})()},children:o(`deviceQuickDetail.openFull`,`Open full detail`)}):x(`span`,{}),s(`div`,{className:`flex items-center gap-2`,children:[x(K,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{t!==null&&r({...t,name:t.baseName,location:t.baseLocation,role:t.baseRole,display:t.baseDisplay,tags:t.baseTags});for(let e of n)e.discard();f(null)},disabled:!b.dirty||b.saving,children:o(`deviceQuickDetail.discard`,`Discard`)}),x(K,{type:`button`,size:`sm`,onClick:()=>{if(t!==null&&Uv(t)&&Gv(t)===`name`){f(o(`deviceQuickDetail.nameRequired`,`Name is required`));return}f(null),m(!0),(async()=>{try{let i=t===null?{}:Kv(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 _.mutateAsync({deviceId:e,role:i.role}),t!==null&&i.tags!==void 0&&await y.mutateAsync({deviceId:e,tags:i.tags}),t!==null&&i.display!==void 0&&await v.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,baseTags:t.tags,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(Qv(e))}finally{m(!1)}})()},disabled:!b.dirty||b.saving,children:b.saving?o(`deviceQuickDetail.saving`,`Saving…`):o(`deviceQuickDetail.save`,`Save`)})]})]})]})}function ey(e){return e.hubReachable?e.authOk===!1?{kind:`auth-expired`}:{kind:`cluster-degraded`,offlineAgents:e.offlineAgents,offlineAgentIds:e.offlineAgentIds}:{kind:`hub-unreachable`}}function ty(e){switch(e.kind){case`connected`:return null;case`reconnecting`:return{severity:`warning`,message:q.t(`connection.reconnecting`),i18nKey:`connection.reconnecting`,showSpinner:!0};case`cluster-degraded`:{let t=e.offlineAgentIds??[];return t.length>0?{severity:`warning`,message:q.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:q.t(`connection.degradedCount`,{count:e.offlineAgents}),i18nKey:`connection.degradedCount`,i18nParams:{count:e.offlineAgents},showSpinner:!0}:{severity:`warning`,message:q.t(`connection.degraded`),i18nKey:`connection.degraded`,showSpinner:!0}}case`hub-unreachable`:return{severity:`danger`,message:q.t(`connection.disconnected`),i18nKey:`connection.disconnected`,showSpinner:!0};case`auth-expired`:return{severity:`danger`,message:q.t(`connection.sessionExpired`),i18nKey:`connection.sessionExpired`,showSpinner:!1,action:`sign-in`}}}var ny=4e3,ry=5e3;function iy(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 ay(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 oy(e){let t=e.fetchFn??fetch,n=e.timeoutMs??ny,r=e.origin.replace(/\/+$/,``),i;try{i=await ay(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 ay(t,`${r}/health/details`,n,{Authorization:`Bearer ${o}`});e.ok&&(a=await e.json())}catch{}let s;try{s=iy(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 ay(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 sy={kind:`connected`},cy={kind:`reconnecting`};function ly(e){let t=e.probeIntervalMs??ry,n=new Set,r=sy,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(ey(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(sy);return}if(e===`connecting`){c(),s(cy);return}(r.kind===`connected`||r.kind===`reconnecting`)&&s(cy),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 uy=null;function dy(){return uy===null&&(uy=ly({probe:()=>oy({origin:De(),getToken:()=>localStorage.getItem(`camstack_admin_token`)})})),uy}function fy(e){dy().onSdkConnectionState(e)}function py(e){return e===`connected`}function my(e){M.setOnline(py(e))}var hy=null,gy=0;function _y(){if(!hy){let e=gy;hy=Na({serverUrl:De(),token:localStorage.getItem(`camstack_admin_token`)??void 0,getLanguage:()=>q.language,refreshCredential:async e=>{e===`rejected`?await Fy().refreshNow():await Fy().ensureFresh()},onConnectionChange:t=>{e===gy&&(fy(t),my(t))}})}return hy}function vy(){let e=hy;hy=null,gy+=1,e?.close()}var yy=`camstack_admin_token`,by=`camstack_admin_refresh`,xy=`camstack_admin_token_expires`;function Sy(e){try{let t=localStorage.getItem(e);return t!==null&&t.length>0?t:null}catch{return null}}function Cy(e,t){try{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}function wy(){let e=Sy(yy);if(e===null)return null;let t=Sy(by),n=Number(Sy(xy));return{token:e,...t===null?{}:{refreshToken:t},...Number.isFinite(n)&&n>0?{expiresAt:n}:{}}}function Ty(e){Cy(yy,e.token),Cy(by,e.refreshToken??null),Cy(xy,e.expiresAt===void 0?null:String(e.expiresAt))}function Ey(e){Cy(yy,e),Cy(by,null),Cy(xy,null)}function Dy(){Cy(yy,null),Cy(by,null),Cy(xy,null)}function Oy(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 ky(e){await fetch(U(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}var Ay=new Set;function jy(e){return Ay.add(e),()=>Ay.delete(e)}var My=new Set;function Ny(e){return My.add(e),()=>My.delete(e)}var Py=null;function Fy(){return Py===null&&(Py=new Ei({refresh:async e=>{let t=wy();if(t?.refreshToken!==void 0&&t.refreshToken!==e&&(t.expiresAt??0)>Date.now()+6e4)return t;let n=await _y().refreshSession(e);return{token:n.token,refreshToken:n.refreshToken,expiresAt:n.expiresAt}},onTokens:e=>{Ty(e),_y().setToken(e.token),ky(e.token);for(let e of My)e()},onExpired:()=>{Dy();for(let e of Ay)e()}})),Py}function Iy(e){Ty(e),Fy().adopt(e)}async function Ly(e){try{await Fy().ensureFresh()}catch(e){console.warn(`[admin-session] pre-reconnect refresh failed; reconnecting anyway`,e)}e()}async function Ry(){return await Fy().refreshNow()!==null}var zy=512;function By(e){if(!e||e.length>zy)return null;let t=Yt(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 Vy=/^[A-Za-z0-9_-]{43,128}$/,Hy=/^[A-Za-z0-9._~-]{1,256}$/;function Uy(e){let{codeChallenge:t,state:n}=e;return!t||!Vy.test(t)||(e.codeChallengeMethod??`S256`)!==`S256`||!n||!Hy.test(n)?null:{codeChallenge:t,state:n,purpose:e.purpose===`step-up`?`step-up`:`new-session`}}var Wy=`camstack:login-app-handoff`;function Gy(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 Uy({codeChallenge:n(`codeChallenge`),state:n(`state`),purpose:n(`purpose`)})}catch{return null}}function Ky(e,t=Date.now()){e!==null&&ib(Wy,JSON.stringify(e),Gy,t)}function qy(e=Date.now()){return ab(Wy,Gy,e)}function Jy(e,t,n){return`${e}?${`code=${encodeURIComponent(t)}`}${n===void 0?``:`&state=${encodeURIComponent(n)}`}`}function Yy(e,t=Date.now()){return cb(t)??By(e)}var Xy=2048;function Zy(e){return!e||e.length>Xy||!e.startsWith(`/`)||e.startsWith(`//`)||e.includes(`\\`)||e.includes(`://`)||e.includes(`..`)||e===`/login`||e.startsWith(`/login?`)||e.startsWith(`/login/`)?null:e}function Qy(e,t=Date.now()){ib(nb,e,Zy,t)}function $y(e=Date.now()){return ab(nb,Zy,e)}function eb(e,t=Date.now()){return $y(t)??Zy(e)}var tb=`camstack:login-redirect`,nb=`camstack:login-next`,rb=10*6e4;function ib(e,t,n,r){let i=ob();if(!i||!n(t))return;let a={raw:t??``,at:r};try{i.setItem(e,JSON.stringify(a))}catch{}}function ab(e,t,n){let r=ob();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>rb?null:t(a)}catch{return null}}function ob(){if(typeof window>`u`)return null;try{return window.sessionStorage}catch{return null}}function sb(e,t=Date.now()){ib(tb,e,By,t)}function cb(e=Date.now()){return ab(tb,By,e)}var lb=`changeme`;function ub(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:db(n.scopes)}}catch{return null}}function db(e){return hn(vn(e))}function fb(e){let t=ub(e);return t?t.exp*1e3<Date.now():!0}O();var pb=lb;function mb(e){return{token:e.token,...e.refreshToken===void 0?{}:{refreshToken:e.refreshToken},...e.expiresAt===void 0?{}:{expiresAt:e.expiresAt}}}async function hb(e,t){if(await ky(e),t.kind===`path`){window.location.replace(U(t.path));return}try{vy();let e=qy();if(e===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await _y().trpcClient.auth.createHandoffCode.mutate({purpose:e.purpose,codeChallenge:e.codeChallenge,state:e.state});window.location.replace(Jy(t.url,n,e.state))}catch{window.location.replace(U(`/`))}}async function gb(e,t){await ky(e),window.location.replace(U(t))}var _b=j(null);function vb({children:e}){let[t,n]=w(null),[r,i]=w(!0),[a,o]=w(!1);S(()=>{if(typeof window<`u`&&window.location.hash.startsWith(`#token=`)){let e=new URLSearchParams(window.location.hash.slice(1)),t=Oy(e),n=t?.token??null;if(t!==null&&n!==null){Iy(t);let r=cb();if(r){hb(n,r);return}let i=$y()??Zy(e.get(`next`));if(i){gb(n,i);return}window.history.replaceState({},``,U(`/`))}}s()},[]);let s=async()=>{let e=wy();if(e===null){i(!1);return}let t=e.token;if(e.refreshToken!==void 0){let n=Fy();n.adopt(e),await n.ensureFresh();let r=wy();if(r===null){console.warn(`[auth] session restore: signed out — the hub refused the refresh token`),vy(),i(!1);return}t=r.token}if(fb(t)){console.warn(`[auth] session restore: signed out — access token expired and no refresh recovered it`),Dy(),vy(),i(!1);return}let r=ub(t);if(!r){console.warn(`[auth] session restore: signed out — the stored access token is unreadable`),Dy(),vy(),i(!1);return}ky(t);let a=_y();a.trpcClient.system.info.query().then(()=>n(r)).catch(async e=>{let t=e?.data?.code;if(t===`UNAUTHORIZED`||t===`FORBIDDEN`){if(await Ry()){a.reconnect();try{await _y().trpcClient.system.info.query();let e=wy();n(e&&ub(e.token)||r);return}catch{}}console.warn(`[auth] session restore: logout, probe UNAUTHORIZED and refresh did not recover it`),Fy().stop(),Dy(),vy()}else n(r)}).finally(()=>i(!1))};S(()=>jy(()=>{vy(),n(null),o(!1)}),[]);let c=b(async(e,t)=>{let r=await _y().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 Iy(mb(r)),await ky(a),vy(),n(ub(a)),o(t===pb),{kind:`ok`}},[]),l=b(async(e,t)=>{let r=await _y().loginVerifyTotp(e,t,{refreshable:!0}),i=r.token;Iy(mb(r)),await ky(i),vy(),n(ub(i)),o(!1)},[]),u=b(async(e,t)=>{Iy({token:e,...t}),await ky(e),vy(),n(ub(e)),o(!1)},[]),d=b(()=>{_y().logout().catch(()=>{}),Fy().stop(),Dy(),fetch(U(`/api/auth/session`),{method:`DELETE`}).catch(()=>{}),vy(),n(null),o(!1)},[]),f=b(()=>{o(!1)},[]);return x(_b.Provider,{value:{user:t,loading:r,mustChangePassword:a,login:c,verifyTotp:l,finalizePasskeyLogin:u,logout:d,clearMustChangePassword:f},children:e})}function yb(){let e=L(_b);if(!e)throw Error(`useAuth must be used within AuthProvider`);return e}O();function bb(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 xb({schema:e,serverValues:t,onImmediateSave:n,onDeferredSave:r}){let[i,a]=w({}),[o,s]=w({}),[c,l]=w(!1),u=p(null),d=e?.sections??[],f=Object.keys(i).length>0,h=m(()=>({...t,...o,...i}),[t,o,i]);S(()=>{if(f||Object.keys(o).length>0){l(!0);return}u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),500)},[f,o]),S(()=>()=>{u.current&&clearTimeout(u.current)},[]);let g=b(()=>{l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),2e3)},[]),_=b(e=>{g();let r={},o={},s={...t,...i};for(let[t,n]of Object.entries(e))s[t]!==n&&(bb(d,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})},[g,t,i,d,n]),v=b(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]),y=b(e=>{a(t=>{let n={...t};for(let t of e)delete n[t];return n})},[]),x=b(()=>{a({})},[]);return{values:h,pendingKeys:Object.keys(i),hasPendingEdits:f,editingPaused:c,handleChange:_,handleSave:v,handleDiscard:y,resetAll:x}}function Sb({pendingCount:e,onSave:t,onDiscard:n,saving:r=!1,saveLabel:i=`Save`,discardLabel:a=`Discard`}){let{t:o}=J();return e<=0?null:s(`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:[x(`span`,{className:`text-xs text-foreground`,children:o(`formBuilder.saveBar.unsavedChanges`,{count:e})}),s(`div`,{className:`flex items-center gap-2`,children:[x(K,{variant:`unstyled`,type:`button`,onClick:n,disabled:r,className:`inline-flex items-center rounded-md border border-border px-2.5 py-1 text-xs text-foreground-subtle hover:bg-surface-hover disabled:opacity-50`,children:a}),x(K,{variant:`unstyled`,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?o(`formBuilder.formSaveBar.saving`,`Saving…`):i})]})]})}function Cb({tabs:e,activeId:t,onChange:n,countByTab:r,pendingByTab:i}){return e.length===0?null:x(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:e.map(e=>{let a=e.id===t,o=r?.get(e.id)??0,c=i?.get(e.id)??0;return s(K,{variant:`unstyled`,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 ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[e.label,o>0&&s(`span`,{className:`ml-1.5 text-[10px] opacity-60`,children:[`(`,o,`)`]}),c>0&&x(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-primary`})]},e.id)})})}O();function wb({schema:e,values:t,pendingKeys:n,onChange:r,onAction:i,onSave:a,onDiscard:o,disabled:c,activeSubTab:l,onSubTabChange:u,flattenTabs:d=!1,visibilityContext:f,hideSaveBar:h=!1,leadingTabs:g=[]}){let _=e.tabs??[],v=m(()=>{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]),y=new Set(_.map(e=>e.id)),b=[...g.map(e=>({id:e.id,label:e.label})),..._,...[...v.keys()].filter(e=>!y.has(e)).map(e=>({id:e,label:e,icon:`wrench`,order:100}))],S=b[0]?.id??`general`,[C,T]=w(S),E=u!==void 0,D=new Set(b.map(e=>e.id)),O=p(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:S)(E?l:C),j=e=>{E?u(e):T(e)},M=g.find(e=>e.id===A),N=v.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:x(Sb,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>o(n),saving:c});if(g.length===0&&(d||b.length<=1))return s(`div`,{className:`flex flex-col gap-3`,children:[x(Sh,{schema:e,values:t,onChange:r,onAction:i,disabled:c,visibilityContext:f}),F]});let I=new Map,L=new Map;for(let[e,t]of v){I.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&&L.set(e,a)}return s(`div`,{className:`flex flex-col gap-3`,children:[x(Cb,{tabs:b.map(e=>({id:e.id,label:e.label})),activeId:A,onChange:j,countByTab:I,pendingByTab:L}),x(Ci,{tabKey:A,children:M===void 0?x(Sh,{schema:P,values:t,onChange:r,onAction:i,disabled:c,visibilityContext:f}):M.content}),F]})}var Tb=`device-export`,Eb=`export`,Db=`Export`;function Ob(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(Ob):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(Ob)):e.writerCapName===Tb}function kb(e){return e.tab===`export`?!0:e.fields.some(Ob)}var Ab=`host/extensions-panel`;function jb(e){return e.type===`widget`?e.widgetId===Ab:e.type===`group`?e.fields.some(jb):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(jb)):!1}function Mb(e){return e.fields.some(jb)}function Nb(e,t){return!t&&e!==void 0&&Ht.includes(e)}function Pb(e){return e.location!==`top-tab`&&e.location!==`hero`&&!kb(e)&&!Mb(e)}function Fb(e,t,n,r){return!r||Nb(t,n)?!0:(e??[]).some(Pb)}function Ib(e,t){for(let n of e){if(n.type===`group`){Ib(n.fields,t);continue}if(n.type===`sub-tabs`){for(let e of n.tabs)Ib(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 Lb(e){let t={};for(let n of e)Ib(n.fields,t);return t}O();function Rb(e,t){return t&&t===`admin`?e:!0}function zb(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?kb(e)&&kb(t)?e.id.localeCompare(t.id):(e.order??0)-(t.order??0):n.localeCompare(r)})};return e.tabs?{...t,tabs:e.tabs}:t}function Bb(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 Vb(e){return e.key}function Hb(e){if(!Bb(e))return e.value}function Ub(e){return Bb(e)?null:e}function Wb(e,t){for(let n of e)if(t(n),n.type===`group`)Wb(n.fields,t);else if(n.type===`sub-tabs`)for(let e of n.tabs)Wb(e.fields,t)}function Gb(e){if(!e)return{};let t={};for(let n of e.sections)Wb(n.fields,e=>{let n=Vb(e);n!==null&&(t[n]=Hb(e))});return t}function Kb(e,t){if(!e)return null;let n=null;for(let r of e.sections)if(Wb(r.fields,e=>{if(n!==null||Vb(e)!==t)return;let r=Ub(e);r&&r.writerCapName&&r.writerAddonId&&(n={capName:r.writerCapName,addonId:r.writerAddonId})}),n!==null)break;return n}function qb(e){return{...e,fields:e.fields.map(Jb)}}function Jb(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`object-array`?e:{...e,readonlyField:!0}}function Yb(e,t){return e&&{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{let n=Ub(e);return n?Rb(t,n.minRole)?e:Jb(e):e})}))}}var Xb={sections:[]};function Zb({deviceId:e,sectionFilter:t,activeSubTab:n,onSubTabChange:r,flattenSubTabs:i,subTabGrouping:a,leadingTabs:o}){let{t:c}=J(),l=N(),{user:u}=yb(),d=u?.isAdmin===!0,f=p(!1),{data:h,isLoading:g}=Rr({deviceId:e},{refetchInterval:()=>f.current?!1:2500,enabled:Number.isFinite(e)}),{data:_}=Or({deviceId:e},{enabled:Number.isFinite(e)}),v=h?.settings??null,y=h?.live??null,C=m(()=>{if(!v&&!y)return null;let e=v?.sections??[],n=(y?.sections??[]).map(qb),r=[...e,...n],i=t?r.filter(t):r.filter(Pb);if(i.length===0)return null;if(a){let e=i.map(e=>({...e,tab:a.groupOf(e)})),t=new Set(e.map(e=>e.tab)),n=a.tabs.filter(e=>t.has(e.id));return n.length>0?{tabs:n,sections:e}:{sections:e}}let o=new Set;for(let e of i)o.add(e.tab??`general`);let s=[...v?.tabs??[],...(y?.tabs??[]).filter(e=>!(v?.tabs??[]).some(t=>t.id===e.id))].filter(e=>o.has(e.id));return s.length>0?{tabs:s,sections:i}:{sections:i}},[v,y,t,a]),w=m(()=>Lb([...v?.sections??[],...y?.sections??[]]),[v,y]),T=m(()=>zb(C),[C]),E=m(()=>Yb(T,d),[T,d]),D=m(()=>Gb(E),[E]),O=Da(),k=Ti(),A=ii(),j=Ni(),M=br({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),P={isPending:M.isPending,mutate:t=>{M.mutate({deviceId:e,changes:[...t]})}},F=xb({schema:E,serverValues:D,onImmediateSave:b(e=>{let t=Object.entries(e).map(([e,t])=>{let n=Kb(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:b(async t=>{let n=Object.entries(t).map(([e,t])=>{let n=Kb(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 M.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,M,e,l])}),{values:I,pendingKeys:L,handleChange:R,handleSave:z,handleDiscard:ee}=F;f.current=F.editingPaused;let te=Yv(),ne=p(z),B=p(ee);ne.current=z,B.current=ee;let re=te?.register,ie=M.isError?M.error instanceof Error?M.error.message:String(M.error):null,V=L.join(`\0`);S(()=>{if(re===void 0)return;let e=V===``?[]:V.split(`\0`);return re({id:`export`,dirty:e.length>0,saving:M.isPending,error:ie,save:()=>(ne.current(e),Promise.resolve()),discard:()=>B.current(e)})},[re,V,M.isPending,ie]);let ae=o!==void 0&&o.length>0;if(g&&!ae)return s(`div`,{className:`flex items-center justify-center py-12 text-foreground-subtle`,children:[x(W,{className:`h-4 w-4 animate-spin mr-2`}),x(`span`,{className:`text-xs`,children:c(`device.deviceAggregateSection.loadingDeviceAggregate`,`Loading device aggregate…`)})]});if(!ae&&(!E||E.sections.length===0))return x(`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 oe(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=It(e,r);await O.mutateAsync({brokerId:i}),l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]});return}if(t===`test-probe`){if(!_)return{status:`error`,error:c(`device.deviceAggregateSection.metadataNotLoaded`)};try{return await A.mutateAsync({addonId:_.addonId,type:_.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=It(e,t),i=await k.mutateAsync({brokerId:r});return l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),i}if(t===`device-custom-action`){let t=await j.mutateAsync({deviceId:e,action:n,input:r});return l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),t}throw Error(`[device-aggregate] unknown action "${t}"`)}return x(wb,{schema:E??Xb,values:I,pendingKeys:L,onChange:R,onAction:oe,onSave:z,onDiscard:ee,hideSaveBar:te!==null,disabled:P.isPending,activeSubTab:n,onSubTabChange:r,flattenTabs:i,leadingTabs:o,visibilityContext:w})}O();function Qb({deviceId:e,onClose:t}){let{t:n}=J(),[r,i]=w(`info`),{data:a}=Or({deviceId:e},{enabled:e>0}),o=ia(e),c=vv(o.presence,o.list),l=r===`history`&&!c?`info`:r,u=typeof a?.name==`string`?a.name:``,d=zr(e,`full`,u.length>0?u:`#${String(e)}`),f=typeof a?.location==`string`?a.location:``,p=[[`info`,n(`deviceQuickDetail.tabInfo`,{defaultValue:`Device info`})],[`export`,n(`deviceQuickDetail.tabExport`,{defaultValue:`Export`})],...c?[[`history`,n(`deviceQuickDetail.tabHistory`,{defaultValue:`History`})]]:[]];return x(si,{open:!0,onOpenChange:e=>!e&&t(),children:x(Dr,{width:`lg`,scroll:`body`,children:s(Xv,{deviceId:e,seed:a==null?null:{name:u,location:f,role:typeof a.role==`string`?a.role:null,display:a.display,tags:a.tags},showOpenFull:!0,onClose:t,children:[x(Pr,{children:x(hi,{children:d})}),x(`div`,{className:`mt-3 flex items-center gap-1 rounded-md bg-surface-hover p-0.5 w-fit`,children:p.map(([e,t])=>x(`button`,{type:`button`,onClick:()=>i(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))}),x(fi,{className:`mt-3`,children:s(Li,{deviceId:e,device:a??void 0,children:[x(`div`,{className:l===`info`?void 0:`hidden`,children:x(Pv,{})}),x(`div`,{className:l===`export`?void 0:`hidden`,children:x(Zb,{deviceId:e,sectionFilter:kb})}),c?x(`div`,{className:l===`history`?void 0:`hidden`,children:x(_v,{deviceId:e})}):null]})})]})})})}function $b({children:e}){let[t,n]=w(null),r=b(e=>n(e),[]),i=b(()=>n(null),[]);return s(ur,{open:r,children:[e,t===null?null:x(Qb,{deviceId:t,onClose:i})]})}O();function ex({tabs:e,active:t,onChange:n}){return x(`div`,{className:`flex rounded-lg border border-border bg-surface p-0.5 gap-0.5`,children:e.map(e=>x(K,{variant:`unstyled`,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 tx(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 nx(e){return`${e.inputSize.width}x${e.inputSize.height}`}function rx(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function ix({entry:e,selected:t,onSelect:n,disabled:r}){let{t:i}=J(),a=tx(e),o=nx(e),c=rx(e);return s(K,{variant:`unstyled`,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:[x(`div`,{className:`flex items-start justify-between gap-2`,children:s(`div`,{className:`flex-1 min-w-0`,children:[s(`div`,{className:`flex items-center gap-2`,children:[x(`span`,{className:`text-xs font-semibold text-foreground truncate`,children:e.name}),t&&x(ot,{className:`h-3.5 w-3.5 text-primary shrink-0`})]}),x(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 line-clamp-2`,children:e.description})]})}),s(`div`,{className:`flex items-center gap-3 mt-2 flex-wrap`,children:[s(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[x(Ke,{className:`h-3 w-3`}),o]}),a&&x(`span`,{className:`text-[10px] text-foreground-subtle`,children:a}),c.length>0&&x(`div`,{className:`flex gap-1`,children:c.map(e=>x(`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&&x(`span`,{className:`text-[10px] text-foreground-subtle`,children:i(`common.labels`,{count:e.labels.length})})]})]})}function ax({field:e,value:t,onChange:n,disabled:r}){let{t:i}=J(),a=e.catalog??[],o=a.length>0,c=Dn(a).length>0,l=e.allowCustomPath!==!1||e.allowCustom===!0,u=[...o?[{id:`catalog`,label:i(`formBuilder.modelSelector.models`,`Models ({{length}})`,{length:a.length})}]:[],...l?[{id:`custom`,label:i(`formBuilder.modelSelector.customPath`,`Custom Path`)}]:[]],[d,f]=w(o?`catalog`:`custom`),p=t==null?``:String(t);return s(`div`,{className:`space-y-3`,children:[u.length>1&&x(ex,{tabs:u,active:d,onChange:f}),d===`catalog`&&o&&c&&x(Jr,{catalog:a,value:p,onChange:e=>n(e),disabled:r||e.disabled}),d===`catalog`&&o&&!c&&x(`div`,{className:`space-y-1.5 max-h-[320px] overflow-y-auto pr-1`,children:a.filter(e=>e.legacy!==!0).map(t=>x(ix,{entry:t,selected:p===t.id,onSelect:()=>n(t.id),disabled:r||e.disabled},t.id))}),d===`catalog`&&!o&&s(`div`,{className:`rounded-md border border-info/30 bg-info/5 px-3 py-2 flex items-start gap-2`,children:[x(nt,{className:`h-3.5 w-3.5 text-info shrink-0 mt-0.5`}),x(`p`,{className:`text-[11px] text-foreground-subtle leading-relaxed`,children:i(`formBuilder.modelSelector.noPredefinedModelsAvailableUse`,`No predefined models available. Use the Custom Path tab to specify a model file path or URL.`)})]}),d===`custom`&&l&&s(`div`,{className:`space-y-2`,children:[x(G,{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:i(`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&&s(`p`,{className:`text-[10px] text-foreground-subtle`,children:[i(`formBuilder.modelSelector.acceptedFormats`,`Accepted formats:`),` `,e.acceptFormats.join(`, `)]})]}),(e.compatibilityNote||e.conversionGuideUrl)&&s(`div`,{className:`flex items-start justify-between gap-3 pt-1`,children:[e.compatibilityNote&&s(`p`,{className:`flex items-start gap-1 text-[10px] text-foreground-subtle`,children:[x(nt,{className:`h-3 w-3 mt-0.5 shrink-0`}),e.compatibilityNote]}),e.conversionGuideUrl&&s(`a`,{href:e.conversionGuideUrl,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-[11px] text-primary hover:underline shrink-0`,children:[i(`formBuilder.modelSelector.howToConvertYourModel`,`How to convert your model`),x(ht,{className:`h-3 w-3`})]})]})]})}function ox({to:e}){let{search:t}=X();return x(Z,{to:`${e}${t}`,replace:!0})}O();function sx(){return q.t(`helpers.keychainRevealHost.forbidden`)}function cx(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 lx(e){let t=cx(e);if(t===`FORBIDDEN`||t===`UNAUTHORIZED`)return sx();let n=e instanceof Error?e.message:String(e);return n.length>0?q.t(`helpers.keychainRevealHost.failedWith`,{message:n}):q.t(`helpers.keychainRevealHost.failed`)}function ux({children:e}){let t=Ma();return x(ki,{reveal:b(async e=>{try{return(await t.mutateAsync({ref:e})).value}catch(e){throw Error(lx(e))}},[t]),children:e})}O();function dx(){let e=_t(),t=N(),[n,r]=w(()=>e.isConnected()?`connected`:`disconnected`),i=p(!1),[a,o]=w(0),[s,c]=w([]);S(()=>e.subscribeConnectionEvents(e=>{r(t=>(t!==`connected`&&e===`connected`&&i.current&&o(e=>e+1),e!==`connected`&&(i.current=!0),e))}),[e]),S(()=>{a!==0&&t.invalidateQueries({queryKey:[[`addons`,`getLastRestart`]]})},[a,t]);let{data:l}=_a(void 0,{enabled:n===`connected`&&a>0,staleTime:0,refetchOnMount:!1,refetchOnWindowFocus:!1}),u=p(null);return S(()=>{if(l==null||l.requestedAt===u.current)return;u.current=l.requestedAt;let e=px(l);c(t=>[...t,e]);let t=window.setTimeout(()=>{c(t=>t.filter(t=>t.id!==e.id))},6e3);return()=>window.clearTimeout(t)},[l]),x(I,{children:s.length>0&&x(fx,{toasts:s})})}function fx({toasts:e}){return x(`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=>s(`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`,children:[x(Ce,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),s(`div`,{children:[x(`div`,{className:`text-[11px] font-semibold text-foreground`,children:e.title}),x(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:e.message})]})]},e.id))})}function px(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:q.t(`system.reconnectOverlay.frameworkUpdated`,`Framework updated`),message:q.t(`system.reconnectOverlay.isNow`,`{{packageName}} is now {{fromTo}}.`,{packageName:e.packageName,fromTo:n})}}return{id:t,title:q.t(`system.reconnectOverlay.serverRestarted`,`Server restarted`),message:e.requestedBy===void 0?q.t(`system.reconnectOverlay.manualRestartCompleted`,`Manual restart completed.`):q.t(`system.reconnectOverlay.manualRestartByCompleted`,`Manual restart by {{requestedBy}} completed.`,{requestedBy:e.requestedBy})}}var mx=`/system/settings`,hx=[{path:`/system/capabilities`,tab:`capabilities`},{path:`/system/api-explorer`,tab:`api-explorer`}];function gx(e,t=``){let n=new URLSearchParams(t);return n.delete(`tab`),n.set(`tab`,e),`${mx}?${n.toString()}`}var _x=`/system/data`,vx=`/system/secrets`;function yx(e=``){let t=new URLSearchParams(e),n=t.get(`view`);return t.delete(`view`),t.set(`tab`,`secrets`),n===`audit`&&t.set(`secretsView`,`audit`),`${_x}?${t.toString()}`}function bx({tab:e}){let{search:t,hash:n}=X();return x(Z,{to:`${gx(e,t)}${n}`,replace:!0})}function xx(){let{search:e,hash:t}=X();return x(Z,{to:`${yx(e)}${t}`,replace:!0})}O();var Sx={info:{bg:`bg-info/10`,border:`border-info/30`,icon:nt},warning:{bg:`bg-warning/10`,border:`border-warning/30`,icon:Ae},critical:{bg:`bg-danger/10`,border:`border-danger/30`,icon:z}};function Cx({toast:e,onDismiss:t}){let n=Sx[e.severity]??Sx.info,r=n.icon;return S(()=>{let n=e.duration??5e3;if(n<=0)return;let r=setTimeout(()=>t(e.id),n);return()=>clearTimeout(r)},[e.id,e.duration,t]),x(`div`,{className:`rounded-lg bg-surface shadow-lg animate-in slide-in-from-right-5 fade-in duration-200`,children:s(`div`,{className:`flex items-start gap-3 px-4 py-3 rounded-lg border ${n.border} ${n.bg}`,children:[x(r,{className:`h-4 w-4 shrink-0 mt-0.5 text-foreground-subtle`}),s(`div`,{className:`flex-1 min-w-0`,children:[x(`div`,{className:`text-xs font-semibold text-foreground`,children:e.title}),x(`div`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:e.message})]}),x(K,{variant:`unstyled`,type:`button`,onClick:()=>t(e.id),className:`shrink-0 p-0.5 rounded hover:bg-surface-hover transition-colors`,children:x(_e,{className:`h-3.5 w-3.5 text-foreground-subtle`})})]})})}function wx(){let[e,t]=w([]),n=b(e=>{t(t=>t.filter(t=>t.id!==e))},[]),r=b(e=>{let n=`toast-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;t(t=>[...t,{...e,id:n,timestamp:Date.now()}])},[]);return oi(void 0,{onData:e=>r(e)}),S(()=>Oh(r),[r]),e.length===0?null:x(`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=>x(`div`,{className:`pointer-events-auto`,children:x(Cx,{toast:e,onDismiss:n})},e.id))})}function Tx(e){return(t,n,r)=>e(t,{...typeof n==`string`?{defaultValue:n}:{defaultValue_one:n.one,defaultValue_other:n.other},...r})}var Ex=(e,t,n)=>Tx(q.t.bind(q))(e,t,n);O();function Dx({children:e}){let{t}=J();return x(lt,{t:m(()=>Tx(t),[t]),children:e})}O();function Ox(e){if(typeof e!=`object`||!e)return;let{data:t}=e;return t?.code}function kx(e,t){let n=Ox(e);return n===`UNAUTHORIZED`||n===`FORBIDDEN`?!0:/UNAUTHORIZED|FORBIDDEN/.test(t)}function Ax(e,t,n,r){let[i,a]=w(!1),[o,s]=w(null);return S(()=>{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(kx(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}}O();var jx=3e4;function Mx(e){let t=p(e);t.current=e,S(()=>{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>=jx&&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)}},[])}var Nx=`@camstack/ui-library`;function Px(e){return typeof e==`object`&&!!e}var Fx=/^>=\s*(\d+)\.(\d+)\.(\d+)/,Ix=/^(\d+)\.(\d+)\.(\d+)/;function Lx(e){return e===null?null:[Number(e[1]),Number(e[2]),Number(e[3])]}function Rx(e,t){for(let n=0;n<3;n++){let r=e[n]??0,i=t[n]??0;if(r!==i)return r<i}return!1}function zx(e,t){let n=[];for(let r of Object.values(e)){let e=r[Nx];if(!(typeof e!=`object`||!e))for(let r of Object.values(e)){if(!Px(r)||r.from!==t)continue;let e=r.shareConfig?.requiredVersion;typeof e==`string`&&n.push(e)}}return n}function Bx(e,t){let n=e===null?null:Lx(e.match(Ix));if(n===null||e===null)return null;for(let r of t){let t=Lx(r.match(Fx));if(t!==null&&Rx(n,t))return{required:t.join(`.`),host:e}}return null}O();function Vx(){let{t:e}=J();return s(`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:[x(dr,{className:`h-7 w-48`}),x(dr,{className:`h-5 w-72 max-w-full`}),x(dr,{className:`h-40`})]})}function Hx({message:e}){let{t}=J();return x(`div`,{className:`p-2 sm:p-4`,"data-testid":`addon-page-error`,children:x(gr,{title:t(`layouts.addonPageLoader.failedTitle`,`This page could not be shown`),message:e})})}var Ux=class extends l{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:x(Hx,{message:this.state.error.message})}};function Wx({resetKey:e,children:t}){return x(Ux,{resetKey:e,children:t})}function Gx({pageKey:e,children:t}){return x(Ux,{resetKey:e,children:x(y,{fallback:x(Vx,{}),children:t})})}O();function Kx(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 qx=2e4;function Jx(e,t){let[n,r]=w(!1);return S(()=>{if(!e){r(!1);return}let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}var Yx=new Map,Xx=new Map,Zx=new Set;function Qx(e){return!e||typeof e!=`object`?!1:typeof e.default==`function`}var $x=class extends Error{problem;constructor(e){super(`ui-library ${e.host} is older than the ${e.required} this page requires`),this.problem=e}};function eS(e){let t=i()?.shareScopeMap;if(!t)return;let n=Bx(Qi,zx(t,e));if(n!==null)throw new $x(n)}async function tS(e,t){let i=Yx.get(e);if(i)return i;let a=Xx.get(e);if(a)return a;Zx.has(e)||(zi(),r([{name:e,entry:U(t),type:`module`}],{force:!1}),Zx.add(e));let o=n(`${e}/page`).then(n=>{if(eS(e),!Qx(n))throw Error(`Addon page remote ${e} (${t}) does not expose a default React component on './page'`);return Yx.set(e,n.default),Xx.delete(e),n.default}).catch(t=>{throw Xx.delete(e),eS(e),t});return Xx.set(e,o),o}function nS(){let{t:e}=J(),{pagePath:t}=Oc(),n=wc(),r=_t(),{data:i,isError:a,error:o}=_i(void 0),s=m(()=>i?Kx(i):void 0,[i]),c=s?.find(e=>e.path===`/addon/${t}`),l=c?.remoteName,u=c?.bundleUrl,[d,f]=w(null),[p,h]=w(null);S(()=>{if(!l||!u)return;h(null);let t=Yx.get(l);if(t){f(()=>t);return}f(null);let n=!1;return tS(l,u).then(e=>{n||f(()=>e)}).catch(t=>{n||h(t instanceof $x?e(`layouts.addonPageLoader.hostTooOld`,{defaultValue:`This page needs a newer admin UI (UI library {{required}} or later; this one has {{host}}). Update admin-ui.`,required:t.problem.required,host:t.problem.host}):t instanceof Error?t.message:String(t))}),()=>{n=!0}},[l,u]);let g=Jx(!s&&!a,qx),_=Jx(c!==void 0&&!d&&!p,qx);return s?c?p?x(Hx,{message:p}):d?x(Gx,{pageKey:c.remoteName,children:x(d,{trpc:r.trpcClient,theme:{isDark:document.documentElement.classList.contains(`dark`)},navigate:e=>{n(e.startsWith(`/`)?e:`/${e}`)}})}):_?x(Hx,{message:e(`layouts.addonPageLoader.remoteStalled`,`The page did not load. Its addon may be starting or unreachable.`)}):x(Vx,{}):x(`div`,{className:`flex items-center justify-center h-full text-foreground-subtle`,children:e(`layouts.addonPageLoader.addonPageNotFound`,`Addon page not found`)}):a?x(Hx,{message:o?.message??e(`layouts.addonPageLoader.listFailed`,`The page list could not be loaded.`)}):g?x(Hx,{message:e(`layouts.addonPageLoader.listStalled`,`The hub did not send the page list. Try again in a moment.`)}):x(Vx,{})}var rS={"/system/pipeline":`pipeline-orchestrator`,"/system/history":`device-history`,"/system/ai":`llm`};function iS(e,t){return e.filter(e=>!e.adminOnly||t).map(e=>{let t=rS[e.path];return t===void 0?e:{...e,requiresCapability:t}})}function aS({t:e,isAdmin:t}){let n=iS([{label:e(`nav.devices`,`Devices`),icon:Ve,path:`/devices`},{label:e(`nav.integrations`),icon:it,path:`/integrations`},{label:e(`nav.build`,`Build-your-self`),icon:rt,path:`/build`,adminOnly:!0},{label:e(`nav.locations`,`Locations`),icon:ue,path:`/locations`,adminOnly:!0},{label:e(`nav.viewer`,`Viewer`),icon:ne,path:`/live`}],t),r=iS([{label:e(`nav.library`,`Library`),icon:or,path:`/library`,adminOnly:!0,keywords:[`People`,`Vehicles`,`Events`,`Scenes`,`plates`,`faces`,`detection-intelligence`]},{label:e(`nav.archive`,`Archive`),icon:Kn,path:`/archive`,adminOnly:!0}],t),i=iS([{label:e(`nav.nodes`,`Nodes`),icon:Ne,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:Yn,path:`/system/pipeline`},{label:e(`system.addons`),icon:Be,path:`/system/addons`,adminOnly:!0},{label:e(`system.ai`,`AI`),icon:gt,path:`/system/ai`,adminOnly:!0}],t),a=iS([{label:e(`system.identity`,`Identity & Access`),icon:ce,path:`/system/identity`,adminOnly:!0},{label:e(`system.network`,`Network`),icon:cr,path:`/system/network`,adminOnly:!0},{label:e(`system.integrations`,`Connectivity`),icon:it,path:`/system/integrations`,adminOnly:!0},{label:e(`system.data`,`Data`),icon:Ye,path:`/system/data`,adminOnly:!0},{label:e(`system.notifications`,`Notifications`),icon:ie,path:`/system/notifications`,adminOnly:!0},{label:e(`system.calendars`,`Calendars`),icon:tt,path:`/system/calendars`,adminOnly:!0},{label:e(`system.systemNav`,`System`),icon:se,path:mx,adminOnly:!0},{label:e(`system.logs`,`Logs`),icon:ye,path:`/system/logs`,adminOnly:!0},{label:e(`system.terminal`,`Terminal`),icon:sr,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 oS={gauge:Le,puzzle:Be,bot:pt,cpu:Ke,terminal:sr,box:Fe,boxes:Fe,monitor:ne,wrench:V,activity:Se,plug:it,"graduation-cap":st};function sS(e){return oS[e]??Be}function cS(e,t){for(let n of aS(t))for(let t of n.items)if(t.path===e)return{icon:t.icon,title:t.label,path:t.path};return null}var lS=`/system/addons`;function uS({path:e,children:t}){let n=rS[e];return n===void 0?x(I,{children:t}):x(dS,{path:e,capability:n,children:t})}function dS({path:e,capability:t,children:n}){let{t:r}=J(),i=wc(),a=di(t);if(a===`present`)return x(I,{children:n});if(a===`pending`)return s(`div`,{className:`flex flex-col gap-4 p-2 sm:p-4`,"data-testid":`page-presence-pending`,children:[x(dr,{className:`h-7 w-48`}),x(dr,{className:`h-40`})]});if(a===`unknown`)return x(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-presence-unknown`,children:x(gr,{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 o=cS(e,{t:r,isAdmin:!0});return x(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-not-installed`,children:x(Xi,{icon:o?.icon??Be,title:r(`pageRequires.absentTitle`,`{{page}} is not installed`,{page:o?.title??e}),description:r(`pageRequires.absentDescription`,`The addon that provides this page is not installed. Install it from System → Addons.`),action:x(K,{variant:`primary`,onClick:()=>i(lS),children:r(`pageRequires.openAddons`,`Open Addons`)})})})}function fS({capability:e,children:t}){return x(I,{children:t(di(e)===`absent`)})}function pS({children:e}){return x(ri,{value:mS(Ji({})),children:e})}function mS(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 hS(){let e=wa(),{t}=J();return e.status===`unknown`?x(`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}var gS=[`device`,`page`,`automation`,`script`,`scheduler`,`action`,`template`,`customDevice`,`integration`];function _S(e,t,n=200){if(En(t).length===0)return{groups:[],totalMatched:0,truncated:!1};let r=new Map;for(let n of e){let e=Pn(t,{label:n.label,keywords:n.keywords,identifiers:n.identifiers});if(e===null)continue;let i=r.get(n.domain)??[];i.push({item:n,rank:e}),r.set(n.domain,i)}let i=0;for(let e of r.values())i+=e.length;let a=n,o=[];for(let e of gS){let t=r.get(e);if(!t||t.length===0||a<=0)continue;t.sort((e,t)=>e.rank-t.rank||e.item.label.localeCompare(t.item.label));let n=t.slice(0,a).map(e=>e.item);a-=n.length,o.push({domain:e,items:n})}return{groups:o,totalMatched:i,truncated:i>n}}function vS(e){return e.flatMap(e=>e.items)}var yS=` · `;function bS(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(yS)}function xS(e,t=null){let n=Qr(e),r=Pa(q.language.startsWith(`it`)?`it`:`en`),i=li(e),a=Oa(t);return e.map(e=>{let t=String(e.id),o=Cr(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(yS).includes(c)),u=a(e),d=u.kind===`resolved`?u.integration.name:``;return{key:`device:${t}`,domain:`device`,label:s,subtitle:bS(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:ei(e)}})}function SS(e){return e.map(e=>({key:`integration:${e.id}`,domain:`integration`,label:e.name||e.addonId,subtitle:e.enabled?e.addonId:q.t(`helpers.searchItems.disabled`,{addonId:e.addonId}),keywords:[e.addonId,e.processState],path:o_(e.addonId,e.id)}))}function CS(e,t,n){let r=e.section?.trim();return r?t[r]??e.sectionLabel?.trim()??r:n}function wS(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:CS(e,i,n.ungrouped),keywords:[e.addonId],path:e.path,icon:sS(e.icon)}));return[...r,...a]}var TS=`edit`;function ES(e){return`/build?tab=templates&${TS}=${encodeURIComponent(e)}`}var DS=`const AUTOMATION_RECIPE =`,OS=`// EJECTED from the visual automation editor — this file is now hand-owned.
|
|
5
|
-
// The recipe that produced it was removed with it, on purpose: while it was
|
|
6
|
-
// here the editor could re-open this block and overwrite everything below.`;function kS(e){return e.includes(DS)}function AS(e){return!kS(e.code)}function jS(e){let t=e.indexOf(DS);if(t<0)return null;let n=e.indexOf(`{`,t+25);if(n<0)return null;let r=0,i=!1,a=!1;for(let o=n;o<e.length;o+=1){let s=e.charAt(o);if(i){a?a=!1:s===`\\`?a=!0:s===`"`&&(i=!1);continue}if(s===`"`){i=!0;continue}if(s===`{`)r+=1;else if(s===`}`&&(--r,r===0))return{declStart:t,literalEnd:o+1,json:e.slice(n,o+1)}}return null}function MS(e){let t=jS(e);if(t===null)return{ok:!1,reason:q.t(`helpers.recipeFromCode.noLiteral`)};let n;try{n=JSON.parse(t.json)}catch(e){let t=e instanceof Error?e.message:String(e);return{ok:!1,reason:q.t(`helpers.recipeFromCode.badJson`,{detail:t})}}let r=cn.safeParse(n);if(!r.success){let e=r.error.issues[0];return{ok:!1,reason:e===void 0?q.t(`helpers.recipeFromCode.schemaMismatch`):q.t(`helpers.recipeFromCode.schemaMismatchAt`,{path:e.path.join(`.`),message:e.message})}}return{ok:!0,recipe:r.data}}function NS(e){let t=jS(e);if(t===null)return e;let n=e.slice(t.literalEnd),r=/^\s*as\s+const/.exec(n),i=t.literalEnd+(r===null?0:r[0].length);return`${e.slice(0,t.declStart)}${OS}${e.slice(i)}`}var PS=`customize`,FS=`/build/compositions/new`,IS=`/build/compositions/:blockId`,LS=`/build?tab=custom-device`;function RS(e){return`/devices/${e}`}function zS(e){return`/devices/${e}?tab=${PS}`}function BS(e){return`/build/compositions/${encodeURIComponent(e)}`}var VS=`template`,HS=`terminalId`;function US(e){return`/build?${new URLSearchParams({tab:`custom-device`,new:`helper`,[VS]:`terminal`,[HS]:e}).toString()}`}function WS(e,t,n){return`/build?tab=${e}&${t}=${encodeURIComponent(n)}`}function GS(e){return e??[]}function KS(e){let t=[];for(let n of e.blocks??[])kS(n.code)?t.push({key:`automation:${n.id}`,domain:`automation`,label:n.name,keywords:GS(n.tags),path:WS(`automations`,`block`,n.id)}):Tn(n)===`code`&&AS(n)&&t.push({key:`script:${n.id}`,domain:`script`,label:n.name,keywords:GS(n.tags),path:WS(`scripts`,`block`,n.id)});for(let n of e.schedulers??[])t.push({key:`scheduler:${n.id}`,domain:`scheduler`,label:n.name,keywords:GS(n.tags),path:WS(`schedulers`,`scheduler`,n.id)});for(let n of e.actions??[])t.push({key:`action:${n.id}`,domain:`action`,label:n.name,keywords:GS(n.tags),path:WS(`actions`,`action`,n.id)});for(let n of e.templates??[])t.push({key:`template:${n.id}`,domain:`template`,label:n.name,subtitle:n.kind,keywords:GS(n.tags),path:ES(n.id)});for(let n of e.compositions??[])t.push({key:`customDevice:${n.block.id}`,domain:`customDevice`,label:n.block.name,keywords:GS(n.block.tags),path:BS(n.block.id)});return t}O();var qS={device:{labelKey:`search.resultsList.devices`,icon:Ve},page:{labelKey:`search.resultsList.pages`,icon:ir},integration:{labelKey:`search.resultsList.integrations`,icon:it},automation:{labelKey:`search.resultsList.automations`,icon:re},script:{labelKey:`search.resultsList.scripts`,icon:tr},scheduler:{labelKey:`search.resultsList.schedulers`,icon:Qe},action:{labelKey:`search.resultsList.actions`,icon:be},template:{labelKey:`search.resultsList.templates`,icon:Jn},customDevice:{labelKey:`search.resultsList.customDevices`,icon:mt}};function JS({groups:e,activeKey:t,query:n,totalMatched:r,truncated:i,pending:a=!1,onSelect:o,onHover:c}){let{t:l}=J(),u=p(null);if(S(()=>{t&&(u.current?.querySelector(`[data-key="${CSS.escape(t)}"]`))?.scrollIntoView({block:`nearest`})},[t]),n.trim().length===0)return null;if(e.length===0&&a)return x(`div`,{role:`status`,className:`px-3 py-4 text-center text-[12px] text-foreground-subtle`,"data-testid":`search-pending`,children:l(`search.resultsList.searching`,`Searching…`)});if(e.length===0)return x(`div`,{className:`px-3 py-4 text-center text-[12px] text-foreground-subtle`,children:l(`search.resultsList.noResults`,{query:n})});let d=e.reduce((e,t)=>e+t.items.length,0);return s(I,{children:[x(`div`,{ref:u,role:`listbox`,className:`max-h-[60vh] overflow-y-auto py-1`,children:e.map(e=>{let n=qS[e.domain],r=n.icon;return s(`div`,{className:`px-1 py-1`,children:[s(`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:[x(r,{className:`h-3 w-3`}),l(n.labelKey)]}),e.items.map(e=>{let r=e.icon??n.icon,i=e.key===t;return s(K,{variant:`unstyled`,type:`button`,role:`option`,"aria-selected":i,"data-key":e.key,onMouseEnter:()=>c(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 ${i?`bg-primary/12 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[x(r,{className:`h-3.5 w-3.5 shrink-0 ${i?`text-primary`:`text-foreground-subtle`}`}),s(`span`,{className:`flex-1 min-w-0`,children:[x(`span`,{className:`block truncate font-medium`,children:e.label}),e.subtitle&&x(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:e.subtitle})]})]},e.key)})]},e.domain)})}),i&&x(`div`,{className:`border-t border-border px-3 py-1.5 text-center text-[10px] text-foreground-subtle`,children:l(`search.truncatedResults`,`Showing first {{shown}} of {{total}} — refine your search.`,{shown:d,total:r})})]})}O(),Ra();function YS({navSections:e,addonPages:t,compact:n,onNavigated:r}){let{t:i}=J(),a=wc(),o=p(null),c=p(null),l=p(null),[u,d]=w(null),[f,h]=w(``),[g,_]=w(0),[v,y]=w(!1),{data:C}=gi({projection:`slim`}),{data:T}=Wi(void 0),E=v&&f.trim().length>0,D={enabled:E},O=Zi({},D),k=la({},D),A=mi({},D),j=Gr({},D),M=Ai({},D),N=E&&[O,k,A,j,M].some(e=>e.isLoading),P=m(()=>{let n={detection:i(`nav.detectionSection`,`Detection`),cluster:i(`nav.clusterSection`,`Cluster`),administration:i(`system.title`,`Administration`),ungrouped:i(`nav.addonPages`,`Addon Pages`)};return[...xS(C??[],T??null),...wS(e,t,n),...SS(T??[]),...KS({blocks:O.data?.blocks,actions:k.data,schedulers:A.data,templates:j.data,compositions:M.data?.state===`loaded`?M.data.views:void 0})]},[C,T,e,t,i,O.data,k.data,A.data,j.data,M.data]),{groups:F,totalMatched:I,truncated:L}=m(()=>_S(P,f),[P,f]),R=m(()=>vS(F),[F]);S(()=>{_(0)},[f,P]),S(()=>{v&&o.current?.focus()},[v]);let z=b(()=>{y(!1),h(``),_(0)},[]),te=b(e=>{a(e.path),z(),o.current?.blur(),r?.()},[a,z,r]);Sr(o,{scope:yr}),S(()=>{if(!v)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&&y(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[v]);let ne=v&&f.trim().length>0;S(()=>{if(!ne){d(null);return}let e=()=>{let e=o.current?.getBoundingClientRect();e&&d({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)}},[ne]);let B=R[g]?.key??null,re=i(`search.placeholder`,`Search devices, pages, automations, scripts…`),ie=s(`div`,{className:`relative`,children:[x(ee,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`}),x(G,{ref:o,type:`text`,value:f,placeholder:re,"aria-label":re,role:`combobox`,"aria-expanded":v&&f.trim().length>0,"aria-controls":`global-search-results`,onChange:e=>{h(e.target.value),y(!0)},onFocus:()=>y(!0),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),R.length>0&&_(e=>(e+1)%R.length);else if(e.key===`ArrowUp`)e.preventDefault(),R.length>0&&_(e=>(e-1+R.length)%R.length);else if(e.key===`Enter`){e.preventDefault();let t=R[g];t&&te(t)}else e.key===`Escape`&&(e.preventDefault(),z(),o.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`}),f.length>0&&x(K,{variant:`unstyled`,type:`button`,"aria-label":i(`search.globalSearch.clearSearch`,`Clear search`),onClick:()=>{h(``),o.current?.focus()},className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground`,children:x(_e,{className:`h-3 w-3`})}),ne&&u!==null&&za(x(`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:u.left,top:u.top,minWidth:u.width},children:x(JS,{groups:F,activeKey:B,query:f,totalMatched:I,truncated:L,pending:N,onSelect:te,onHover:e=>{let t=R.findIndex(t=>t.key===e.key);t>=0&&_(t)}})}),document.body)]});return n?x(`div`,{ref:c,className:`px-1.5 pb-1.5`,children:v?x(`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:ie}):x(K,{variant:`unstyled`,type:`button`,onClick:()=>y(!0),"aria-label":re,title:re,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:x(ee,{className:`h-3.5 w-3.5 shrink-0`})})}):x(`div`,{ref:c,className:`px-2 pb-2`,children:ie})}var XS=/^(\d{1,3}\.){3}\d{1,3}$/;function ZS(e){let t=e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e;return!!(XS.test(t)||t.includes(`:`))}function QS(e,t){return!t||ZS(e)?!1:e===t||e.endsWith(`.${t}`)}O();var $S=`auth-webauthn/passkey-enrollment`,eC=`camstack_passkey_prompt_dismissed:`,tC=720*60*60*1e3;function nC(e){try{let t=localStorage.getItem(`${eC}${e}`);if(!t)return!1;let n=Number(t);return Number.isFinite(n)?Date.now()-n<tC:!1}catch{return!1}}function rC(e){try{localStorage.setItem(`${eC}${e}`,String(Date.now()))}catch{}}function iC(){let{user:e}=yb(),{t}=J(),n=_t(),r=$i($S),[i,a]=w(!1),[o,c]=w(!1),l=m(()=>e?nC(e.id):!0,[e]),u=da.auth.listLoginMethods.useQuery().data?.find(e=>e.kind===`passkey`),d=u!==void 0&&QS(window.location.hostname,u.rpId),f=e!==null&&d&&r!=null&&!l,p=E({queryKey:[`auth`,`listOwnPasskeys`],queryFn:()=>n.listOwnPasskeys(),enabled:f,staleTime:6e4}),h=b(()=>{e&&rC(e.id),a(!0),c(!1)},[e]),g=b(()=>{c(!1),p.refetch()},[p]);return!f||i||p.data===void 0||p.data.length>0?null:s(`div`,{className:`shrink-0 border-b border-primary/20 bg-primary/5`,children:[s(`div`,{className:`flex items-center gap-2.5 px-3 py-2 text-xs text-foreground`,children:[x(Xn,{className:`h-4 w-4 text-primary shrink-0`}),x(`span`,{className:`flex-1 min-w-0`,children:t(`passkeyPrompt.message`,`Save a passkey for faster sign-in?`)}),x(K,{variant:`unstyled`,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`)}),x(K,{variant:`unstyled`,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`)}),x(K,{variant:`unstyled`,onClick:h,"aria-label":t(`passkeyPrompt.notNow`,`Not now`),className:`p-1 rounded text-foreground-subtle hover:text-foreground`,children:x(_e,{className:`h-3.5 w-3.5`})})]}),o&&x(`div`,{className:`px-3 pb-3`,children:s(`div`,{className:`max-w-xl`,children:[x(ui,{widgetId:$S,host:`dashboard`}),x(`div`,{className:`mt-2 flex justify-end`,children:x(K,{variant:`unstyled`,onClick:g,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 aC=`system-config`,oC=[`system-config`,`bootstrap-form`];function sC(e){return typeof e==`object`&&!!e&&`sections`in e&&Array.isArray(e.sections)}function cC(){let e=_t();return E({queryKey:oC,queryFn:async()=>{let t=await e.trpcClient.addons.custom.mutate({addonId:aC,action:`getBootstrapForm`,input:{}});if(!sC(t))throw Error(`The hub did not return the settings form`);return t}})}function lC(){let e=_t(),t=N(),n=P({mutationFn:async t=>{await e.trpcClient.addons.custom.mutate({addonId:aC,action:`saveBootstrapForm`,input:t})},onSuccess:()=>Promise.all([t.invalidateQueries({queryKey:oC}),t.invalidateQueries({queryKey:[[`system`,`info`]]})])});return{mutateAsync:n.mutateAsync,isPending:n.isPending}}var uC=6e4;function dC(){let e=_r(void 0,{staleTime:uC});return{info:e.data?.serverName??null,isLoading:e.isLoading}}O();var fC=`camstack_server_name_prompt_dismissed`;function pC(){try{return sessionStorage.getItem(fC)===`1`}catch{return!1}}function mC(){try{sessionStorage.setItem(fC,`1`)}catch{}}function hC(e){return e.isAdmin&&e.info!==null&&e.info.isDefault&&!e.dismissed}function gC(){let{user:e}=yb(),{info:t}=dC(),[n,r]=w(pC);return hC({isAdmin:e?.isAdmin===!0,info:t,dismissed:n})?x(_C,{suggestion:t?.name??``,onLater:()=>{mC(),r(!0)}}):null}function _C({suggestion:e,onLater:t}){let{t:n}=J(),r=N(),i=lC(),[a,o]=w(e),[c,l]=w(null),u=p(null);S(()=>u.current?.focus(),[]);let d=b(async()=>{let e=$t.safeParse(a);if(!e.success){l(e.error.issues[0]?.message??n(`serverName.invalid`,`Not a valid name`));return}l(null);try{await i.mutateAsync({patch:{name:e.data}}),await r.invalidateQueries({queryKey:[[`system`,`info`]]})}catch(e){l(e instanceof Error&&e.message.length>0?e.message:`Could not save`)}},[r,i,n,a]);return x(si,{open:!0,onOpenChange:e=>!e&&t(),children:x(Dr,{children:s(`form`,{onSubmit:e=>{e.preventDefault(),i.isPending||d()},children:[s(Pr,{children:[x(hi,{children:n(`serverName.title`,`Name this server`)}),x(Ir,{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.`)})]}),x(fi,{children:x(va,{label:n(`serverName.label`,`Server name`),...c===null?{}:{error:c},children:x(G,{ref:u,value:a,maxLength:48,onChange:e=>o(e.target.value),state:c===null?`default`:`error`,"aria-label":n(`serverName.label`,`Server name`)})})}),s(ua,{children:[x(K,{type:`button`,variant:`ghost`,onClick:t,disabled:i.isPending,children:n(`serverName.later`,`Later`)}),s(K,{type:`submit`,disabled:i.isPending||a.trim().length===0,children:[i.isPending&&x(W,{className:`h-4 w-4 animate-spin`}),n(`common.save`,`Save`)]})]})]})})})}var vC=4,yC=160,bC=320,xC=`env(safe-area-inset-top)`,SC=`env(safe-area-inset-bottom)`;function CC(e){let{rect:t,viewportWidth:n,viewportHeight:r}=e,i=Math.min(bC,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+vC}px, calc(${xC} + 8px))`;return{...a,top:e,maxHeight:`max(${yC}px, calc(100dvh - ${e} - ${SC} - 8px))`}}let o=`max(${r-t.top+vC}px, calc(${SC} + 8px))`;return{...a,bottom:o,maxHeight:`max(${yC}px, calc(100dvh - ${o} - ${xC} - 8px))`}}var wC=!1;function TC(){return wC}function EC(){wC=!0}function DC(e){return!e.read&&e.severity===`critical`}function OC(e){return e.filter(DC)}function kC(e){return e!==void 0&&typeof e.href==`string`&&e.href.length>0}function AC(e){return kC(e)||e!==void 0&&e.invoke!==void 0}var jC=/^\/addon\/[^/?#]+\/oauth\//;function MC(e){return e.navigation===void 0?jC.test(e.href):e.navigation===`server`}function NC(e){let t=e.action;if(AC(t)&&!(t.invoke!==void 0&&(e.status===`completed`||e.status===`dismissed`)))return t}O();function PC({action:e,className:t,onActivate:n}){let r=N(),i=_t(),{t:a}=J(),[o,c]=w(!1),[l,u]=w(null);if(e.invoke!==void 0){let{addonId:d,action:f,input:p}=e.invoke;return s(`span`,{className:`inline-flex flex-col items-start gap-0.5`,children:[x(`button`,{type:`button`,className:t,disabled:o,onClick:e=>{e.preventDefault(),n?.(e),c(!0),u(null),i.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:o?a(`ui.alertAction.running`,`Working…`):e.label}),l!==null&&x(`span`,{role:`alert`,className:`text-[10px] text-destructive`,children:l})]})}return kC(e)?MC(e)?x(`a`,{href:U(e.href),className:t,onClick:t=>{t.preventDefault(),n?.(t),Ru(e.href,()=>{r.invalidateQueries({queryKey:[[`alerts`]]}),r.invalidateQueries({queryKey:[[`broker`]]}),r.invalidateQueries({queryKey:[[`recordEntries`]]})})},children:e.label}):x(Wl,{to:e.href,className:t,onClick:n,children:e.label}):x(I,{})}O(),Ra();var FC={info:nt,success:Ce,warning:Ae,error:z,critical:$n},IC={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-danger`,critical:`text-danger`},LC={active:`border-l-info`,"in-progress":`border-l-warning`,completed:`border-l-success`,failed:`border-l-danger`,dismissed:`border-l-foreground-subtle/30`};function RC(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return q.t(`helpers.relativeTime.justNow`);let n=Math.floor(t/60);if(n<60)return q.t(`helpers.relativeTime.minutesAgo`,{count:n});let r=Math.floor(n/60);if(r<24)return q.t(`helpers.relativeTime.hoursAgo`,{count:r});let i=Math.floor(r/24);return q.t(`helpers.relativeTime.daysAgo`,{count:i})}function zC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function BC(e){return typeof e==`string`&&e.length>0?e:void 0}function VC(e){if(zC(e.metadata)){let t=BC(e.metadata.nodeId)??BC(e.metadata.agentId);if(t!==void 0)return t}let t=e.source;if(t!==void 0&&!(t.type!==`node`&&t.type!==`agent`))return BC(t.id)}function HC({alert:e,onMarkRead:t,onDismiss:n}){let{t:r}=J(),i=e.severity in FC?e.severity:`info`,a=NC(e),o=e.status in LC?e.status:`active`,c=FC[i],l=IC[i],u=LC[o],{nodes:d}=kr(),f=VC(e),p=f===void 0?void 0:d.find(e=>e.id===f),m=f===void 0?void 0:p?.name??f;return s(`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:[x(c,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${l}`}),s(`div`,{className:`flex-1 min-w-0`,children:[s(`div`,{className:`flex items-center gap-1.5`,children:[x(`span`,{className:`text-[11px] font-semibold ${e.read?`text-foreground-subtle`:`text-foreground`}`,children:e.title}),!e.read&&x(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary shrink-0`})]}),m!==void 0&&x(`div`,{className:`text-foreground-subtle text-[10px] mt-0.5 truncate`,children:m}),x(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5 line-clamp-2`,children:e.message}),a!==void 0&&x(PC,{action:a,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&&s(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[x(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:x(`div`,{className:`h-full bg-primary rounded-full transition-all duration-300`,style:{width:`${String(Math.min(100,Math.max(0,e.progress)))}%`}})}),s(`span`,{className:`text-[9px] text-foreground-subtle font-mono shrink-0`,children:[String(Math.round(e.progress)),`%`]})]}),x(`div`,{className:`text-[9px] text-foreground-subtle/60 mt-1`,children:RC(e.updatedAt)})]}),s(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[!e.read&&x(K,{variant:`unstyled`,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:x(ot,{className:`h-3 w-3 text-foreground-subtle`})}),e.status!==`in-progress`&&x(K,{variant:`unstyled`,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:x(_e,{className:`h-3 w-3 text-foreground-subtle`})})]})]})}function UC({variant:e=`icon`,compact:t=!1}={}){let{t:n}=J(),[r,i]=w(!1),[a,o]=w(!1),c=p(null),l=p(null),u=N(),{data:d=0}=Yr(void 0,{refetchInterval:3e4}),{data:f=[],isLoading:m}=Yi({limit:50},{enabled:r}),h=a?f:f.filter(e=>!e.read),g=f.filter(e=>e.read).length,_=()=>{u.invalidateQueries({queryKey:[[`alerts`]]})},v=Gi({onSuccess:_}),y=fr({onSuccess:_}),C=vr({onSuccess:_});Lr(`alert.created`,()=>{u.invalidateQueries({queryKey:[[`alerts`]]})}),Lr(`alert.updated`,()=>{u.invalidateQueries({queryKey:[[`alerts`]]})}),S(()=>{if(!r)return;let e=e=>{let t=e.target;c.current&&!c.current.contains(t)&&l.current&&!l.current.contains(t)&&i(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[r]);let T=b(e=>{v.mutate({alertId:e})},[v]),E=b(e=>{e&&C.mutate({alertId:e})},[C]),D=b(()=>{y.mutate(void 0),i(!1)},[y]),O=h.filter(DC),k=new Set(O.map(e=>e.id)),A=h.filter(e=>e.status===`in-progress`&&!k.has(e.id)),j=h.filter(e=>e.status!==`in-progress`&&!k.has(e.id)),[M,P]=w({}),F=b(()=>{let e=l.current;e&&P(CC({rect:e.getBoundingClientRect(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}))},[]);return S(()=>{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]),s(`div`,{children:[e===`sidebar`?s(K,{variant:`unstyled`,ref:l,type:`button`,onClick:()=>i(!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?d>0?n(`ui.alertBell.alertsUnread`,{count:d}):n(`ui.alertBell.alerts`):void 0,children:[s(`span`,{className:`relative inline-flex shrink-0`,children:[x(ye,{className:`h-3.5 w-3.5`}),t&&d>0&&x(`span`,{className:`absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary`})]}),!t&&x(`span`,{className:`flex-1 text-left`,children:n(`ui.alertBell.alerts`,`Alerts`)}),!t&&d>0&&x(`span`,{className:`flex items-center justify-center h-4 min-w-4 px-1 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none`,children:d>99?`99+`:String(d)})]}):s(K,{variant:`unstyled`,ref:l,type:`button`,onClick:()=>i(!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:[x(ye,{className:`h-4.5 w-4.5`}),d>0&&x(`span`,{className:`absolute -top-0.5 -right-0.5 flex items-center justify-center h-4 min-w-4 px-0.5 rounded-full bg-primary text-primary-foreground text-[9px] font-bold leading-none`,children:d>99?`99+`:String(d)})]}),r&&za(s(`div`,{ref:c,style:M,className:`bg-surface border border-border rounded-lg shadow-xl flex flex-col overflow-hidden`,children:[s(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border shrink-0`,children:[x(`span`,{className:`text-[12px] font-semibold text-foreground`,children:n(`ui.alertBell.alerts`,`Alerts`)}),s(`div`,{className:`flex items-center gap-2`,children:[g>0&&s(`label`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle cursor-pointer select-none`,children:[x(Oe,{checked:a,onChange:e=>o(e.target.checked),className:`h-3 w-3 rounded border-border accent-primary cursor-pointer`}),n(`ui.alertBell.showRead`,`Show read`)]}),d>0&&s(K,{variant:`unstyled`,type:`button`,onClick:D,className:`flex items-center gap-1 text-[10px] text-primary hover:text-primary/80 transition-colors`,children:[x(Qn,{className:`h-3 w-3`}),n(`ui.alertBell.markAllRead`,`Mark all read`)]})]})]}),s(`div`,{className:`flex-1 overflow-y-auto`,children:[m&&x(`div`,{className:`flex items-center justify-center py-8`,children:x(W,{className:`h-4 w-4 animate-spin text-foreground-subtle`})}),!m&&h.length===0&&s(`div`,{className:`flex flex-col items-center justify-center py-8 text-foreground-subtle`,children:[x(ye,{className:`h-6 w-6 mb-2 opacity-40`}),x(`span`,{className:`text-[11px]`,children:f.length>0?n(`ui.alertBell.noUnreadAlerts`,`No unread alerts`):n(`ui.alertBell.noAlerts`,`No alerts`)}),f.length>0&&!a&&x(K,{variant:`unstyled`,type:`button`,onClick:()=>o(!0),className:`text-[10px] text-primary mt-1 hover:underline`,children:n(`ui.alertBell.showRead`,{count:g})})]}),O.length>0&&s(`div`,{className:`border-b border-border`,children:[x(`div`,{className:`px-3 py-1.5 bg-danger/5`,children:x(`span`,{className:`text-[9px] font-semibold uppercase tracking-widest text-danger`,children:n(`ui.alertBell.urgent`,`Urgent`)})}),O.map(e=>x(HC,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),A.length>0&&s(`div`,{className:`border-b border-border`,children:[x(`div`,{className:`px-3 py-1.5 bg-surface-hover/50`,children:x(`span`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:n(`ui.alertBell.inProgress`,`In Progress`)})}),A.map(e=>x(HC,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),j.map(e=>x(HC,{alert:e,onMarkRead:T,onDismiss:E},e.id))]})]}),document.body)]})}O(),Ra();function WC({alert:e,onMarkRead:t}){let{t:n}=J(),r=NC(e);return s(`div`,{className:`border-b border-border last:border-b-0 px-3 py-2.5`,children:[x(`div`,{className:`text-[12px] font-semibold text-foreground`,children:e.title}),x(`div`,{className:`text-[11px] text-foreground-muted mt-0.5`,children:e.message}),s(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[r!==void 0&&x(PC,{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`}),x(K,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>t(e.id),children:n(`ui.alertBell.markAsRead`,`Mark as read`)})]})]})}function GC(){let{t:e}=J(),t=N(),[n,r]=w(TC()),{data:i=[],isLoading:a}=Yi({limit:50}),o=m(()=>OC(i),[i]),c=Gi({onSuccess:b(()=>{t.invalidateQueries({queryKey:[[`alerts`]]})},[t])}),l=b(e=>{c.mutate({alertId:e})},[c]),u=b(()=>{EC(),r(!0)},[]);return a||n||o.length===0?null:za(x(`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:s(`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:[s(`div`,{className:`flex items-start justify-between gap-2 px-3 py-2.5 border-b border-border shrink-0 bg-danger/5`,children:[s(`div`,{children:[x(`h2`,{id:`critical-alerts-panel-title`,className:`text-[12px] font-semibold text-foreground`,children:e(`ui.criticalAlertsPanel.title`,`Urgent alerts`)}),x(`p`,{className:`text-[10px] text-foreground-muted mt-0.5`,children:e(`ui.criticalAlertsPanel.subtitle`,`These need your attention.`)})]}),x(xa,{type:`button`,variant:`ghost`,onClick:u,"aria-label":e(`ui.criticalAlertsPanel.close`,`Close`),"data-testid":`critical-alerts-panel-close`,icon:_e})]}),x(`div`,{className:`flex-1 overflow-y-auto`,children:o.map(e=>x(WC,{alert:e,onMarkRead:l},e.id))})]})}),document.body)}O();function KC(){let e=dy();return C(e.subscribe,e.getSnapshot,e.getSnapshot)}var qC=[`detection`,`cluster`,`administration`];function JC(e){return qC.includes(e)}function YC(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(JC(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 XC=`camstack:last-path`,ZC=512,QC=[`/login`,`/change-password`,`/access-denied`,`/logout`];function $C(e){return!e.startsWith(`/`)||e.startsWith(`//`)||e.length>ZC?!1:!QC.some(t=>e===t||e.startsWith(t+`/`))}function ew(e){if(!(typeof window>`u`)&&$C(e))try{window.localStorage.setItem(XC,e)}catch{}}function tw(){if(typeof window>`u`)return null;try{let e=window.localStorage.getItem(XC);return e===null?null:$C(e)?e:null}catch{return null}}var nw=`/devices`;function rw(e){return e!==void 0&&$C(e)?e:tw()??nw}function iw(e){return e.split(`.`)[0]===`0`?`${e} beta`:e}function aw(e){if(e===null)return null;let t=e.trim();return t.length>0?t:null}function ow(e){let t=aw(e.productVersion),n=aw(e.serverVersion),r=aw(e.fallbackVersion);return t!==null&&n!==null?{kind:`both`,productLabel:iw(t),serverVersion:n}:t===null?n===null?r===null?{kind:`none`}:{kind:`fallback`,version:r}:{kind:`server`,serverVersion:n}:{kind:`product`,productLabel:iw(t)}}function sw(e,t){if(!Object.hasOwn(e,t))return null;let n=Reflect.get(e,t);return typeof n==`string`?n:null}function cw(e){return typeof e!=`object`||!e?null:{productVersion:sw(e,`productVersion`),serverVersion:sw(e,`serverVersion`)}}O();function lw(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 uw({placement:e,compact:t=!1}){let{t:n}=J(),[r,i]=w({kind:`fallback`,version:`1.2.698`});S(()=>{let e=new AbortController;return fetch(U(`/api/release-identity`),{signal:e.signal}).then(async e=>e.ok?cw(await e.json()):null).then(t=>{e.signal.aborted||t===null||i(ow({productVersion:t.productVersion,serverVersion:t.serverVersion,fallbackVersion:`1.2.698`}))}).catch(t=>{e.signal.aborted||t instanceof DOMException&&t.name}),()=>e.abort()},[]);let a=lw(r,n);return a===null?null:e===`login`?x(`span`,{"data-testid":`release-identity`,children:a}):x(`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})}O();var dw=j(!0);function fw(e){return e===`/addon`||e.startsWith(`/addon/`)}function pw(e,t,n){let r=[...e.filter(e=>e!==t),t];return r.length<=n?r:r.slice(r.length-n)}function mw({maxCached:e=6}){let t=Dc(),n=X(),r=xc(),i=L(fc),a=n.pathname,o=fw(a),c=p(new Map),l=p([]);if(o){c.current.set(a,{key:a,outlet:t,location:n,navigationType:r,routeContext:i});let o=pw(l.current,a,e),s=new Set(o);for(let e of c.current.keys())s.has(e)||c.current.delete(e);l.current=o}return s(I,{children:[l.current.map(e=>{let t=c.current.get(e);if(t?.outlet==null)return null;let n=o&&e===a;return x(`div`,{className:n?`h-full min-h-0`:void 0,style:n?void 0:{display:`none`},hidden:!n,"aria-hidden":!n,children:x(dw.Provider,{value:n,children:x(dc.Provider,{value:{location:t.location,navigationType:t.navigationType},children:x(fc.Provider,{value:t.routeContext,children:t.outlet})})})},e)}),!o&&t!=null?x(`div`,{className:`h-full min-h-0`,children:t},a):null]})}O();var hw={dark:he,light:ze,system:ne};function gw(){return x(`div`,{className:`flex h-full min-h-[50vh] items-center justify-center`,children:x(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`})})}function _w(){let e=X(),t=wc(),{user:n,logout:r}=yb(),i=Ri(),{t:a}=J(),o=Ca(),c=To(),l=hr(),{info:u}=dC();S(()=>{document.title=u===null?`CamStack Admin`:`${u.name} \u00b7 CamStack Admin`},[u]);let d=ty(KC()),[f,h]=w(!1);S(()=>{ew(e.pathname+e.search)},[e.pathname,e.search]);let[g,_]=w(()=>typeof window>`u`?!1:window.localStorage.getItem(`camstack:sidebar-collapsed`)===`1`);S(()=>{typeof window>`u`||window.localStorage.setItem(`camstack:sidebar-collapsed`,g?`1`:`0`)},[g]);let[v]=w(()=>{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}});S(()=>{typeof window>`u`||window.localStorage.setItem(`camstack:sidebar-collapsed-groups`,JSON.stringify([...v]))},[v]),S(()=>{l&&window.localStorage.getItem(`camstack:sidebar-collapsed`)===null&&_(!0)},[l]);let{data:b=[]}=Bi({nodeId:`hub`},{refetchInterval:3e4}),C=b.length,T=N(),E=p(Date.now()),{data:D}=_i(void 0,{staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let t=e.state.data;return t&&t.length>0||Date.now()-E.current>=3e4?!1:2e3}}),O=m(()=>D&&n?.isAdmin?Kx(D):[],[D,n?.isAdmin]),k=m(()=>YC(O),[O]),A=k.known.get(`detection`)??[],j=k.known.get(`cluster`)??[],M=k.known.get(`administration`)??[];Lr(`addon.page-ready`,()=>{T.invalidateQueries({queryKey:[[`addonPages`,`listPages`]]})});let P=()=>{r(),t(`/login`)},F=t=>!!(e.pathname===t||e.pathname.startsWith(t+`/`)),L=[`/system/pipeline`,`/live`,`/addon/osd-manager`,`/build`].some(t=>e.pathname===t||e.pathname.startsWith(t+`/`)),R=n?.isAdmin===!0,z=m(()=>aS({t:a,isAdmin:R}),[a,R]),ee=z[0]?.items??[],te=z[1]?.items??[],ne=z[2]?.items??[],B=z[3]?.items??[],re=i?.mode??`system`,ie={dark:a(`theme.dark`),light:a(`theme.light`),system:a(`theme.system`)},V=g&&!o,ae=(e,t=`md`,n=!1)=>`flex w-full items-center gap-2.5 rounded-md ${V?`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`}`,oe=(e,t)=>e===0?null:V?x(`div`,{className:`pt-3 mb-1 mx-2 border-t border-border/60`},`sep-${t}`):x(`div`,{className:`pt-4 pb-1.5 px-2.5`,children:x(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/60`,children:t})},`hdr-${t}`),se=e=>{let n=F(e.path),r=sS(e.icon);return s(K,{variant:`unstyled`,onClick:()=>{t(e.path),h(!1)},className:ae(n),title:V?e.label:void 0,children:[x(r,{className:`h-3.5 w-3.5 shrink-0 ${n?`text-primary`:``}`}),!V&&e.label]},`${e.addonId}::${e.id}`)},ce=e=>e.requiresCapability===void 0?le(e,!1):x(fS,{capability:e.requiresCapability,children:t=>le(e,t)},e.path),le=(e,n)=>{let r=e.icon,i=F(e.path),o=e.path===`/system/addons`;return s(K,{variant:`unstyled`,"data-testid":`nav-${e.path.replace(/^\//,``).replace(/\//g,`-`)}`,onClick:()=>{t(e.path),h(!1)},className:ae(i,`md`,n),"aria-disabled":n||void 0,title:n?a(`nav.notInstalled`,`{{page}} — not installed`,{page:e.label}):V?e.label:void 0,children:[x(r,{className:`h-3.5 w-3.5 shrink-0 ${i?`text-primary`:``}`}),!V&&s(I,{children:[x(`span`,{className:`flex-1 text-left`,children:e.label}),o&&C>0&&x(`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})]}),V&&o&&C>0&&x(`span`,{className:`absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary`})]},e.path)},ue=s(I,{children:[s(`div`,{className:`flex h-14 items-center border-b border-border ${V?`justify-center px-1`:`pl-3 pr-4 gap-2`}`,children:[!V&&x(`img`,{src:i?.resolvedMode===`light`?U(`/brand/logo-horizontal-light.svg`):U(`/brand/logo-horizontal-dark.svg`),alt:a(`layouts.appLayout.camstackAdmin`,`CamStack Admin`),className:`h-9 flex-1 min-w-0`}),!o&&x(K,{variant:`unstyled`,onClick:()=>_(e=>!e),className:`p-1.5 rounded-md hover:bg-surface-hover text-foreground-subtle transition-colors flex-shrink-0 ${V?``:`mr-2`}`,"aria-label":g?a(`layouts.appLayout.expandSidebar`,`Expand sidebar`):a(`layouts.appLayout.collapseSidebar`,`Collapse sidebar`),title:g?a(`layouts.appLayout.expandSidebar`,`Expand sidebar`):a(`layouts.appLayout.collapseSidebar`,`Collapse sidebar`),children:x(g?Pe:$e,{className:`h-4 w-4`})})]}),!V&&u!==null&&x(`div`,{"data-testid":`sidebar-server-name`,title:u.name,className:`truncate border-b border-border px-3 py-1.5 text-xs font-medium text-foreground-muted`,children:u.name}),x(`div`,{className:`border-b border-border pt-2`,children:x(YS,{navSections:z,addonPages:O,compact:V,onNavigated:()=>h(!1)})}),s(`nav`,{className:`flex-1 overflow-y-auto py-3 ${V?`px-1.5`:`px-2`} space-y-0.5`,children:[ee.map(e=>ce(e)),oe(te.length+A.length,a(`nav.detectionSection`,`Detection`)),te.map(e=>ce(e)),A.map(e=>se(e)),oe(ne.length+j.length,a(`nav.clusterSection`,`Cluster`)),ne.map(e=>ce(e)),j.map(e=>se(e)),oe(B.length+M.length,a(`system.title`,`Administration`)),B.map(e=>ce(e)),M.map(e=>se(e)),k.custom.map(e=>s(`div`,{className:`contents`,children:[oe(e.pages.length,e.label),e.pages.map(e=>se(e))]},`custom-${e.id}`)),oe(k.ungrouped.length,a(`nav.addonPages`,`Addon Pages`)),k.ungrouped.map(e=>se(e))]}),s(`div`,{className:`border-t border-border ${V?`p-1.5`:`p-2`} space-y-0.5`,children:[s(K,{variant:`unstyled`,onClick:()=>i?.toggleMode(),className:ae(!1),title:V?ie[re]:void 0,children:[(()=>{let e=hw[re];return x(e,{className:`h-3.5 w-3.5 shrink-0`})})(),!V&&x(`span`,{children:ie[re]})]}),x(UC,{variant:`sidebar`,compact:V}),s(K,{variant:`unstyled`,type:`button`,onClick:()=>t(`/system/my-access`),className:ae(F(`/system/my-access`)),title:V?a(`system.myAccess`,`My access`):void 0,children:[x(H,{className:`h-3.5 w-3.5 shrink-0`}),!V&&x(`span`,{className:`truncate`,children:a(`system.myAccess`,`My access`)})]}),s(K,{variant:`unstyled`,type:`button`,onClick:()=>c.setOn(!c.on),className:ae(c.on),"aria-pressed":c.on,title:V?a(`layouts.appLayout.debugLayers`,`Debug layers`):void 0,children:[x(je,{className:`h-3.5 w-3.5 shrink-0`}),!V&&x(`span`,{className:`truncate`,children:c.on?a(`layouts.appLayout.debugLayersOn`,`Debug layers: on`):a(`layouts.appLayout.debugLayers`,`Debug layers`)})]}),s(K,{variant:`unstyled`,onClick:P,className:ae(!1).replace(`hover:text-foreground`,`hover:text-danger`),title:V?n?.username??a(`layouts.appLayout.logout`,`Logout`):void 0,children:[x(qn,{className:`h-3.5 w-3.5 shrink-0`}),!V&&x(`span`,{className:`truncate`,children:n?.username??a(`layouts.appLayout.user`,`User`)})]}),x(uw,{placement:`sidebar`,compact:V})]})]});return s(`div`,{className:`flex h-dvh flex-col overflow-hidden bg-background text-foreground pb-[env(safe-area-inset-bottom)]`,children:[x(`div`,{"aria-hidden":`true`,className:`h-[env(safe-area-inset-top)] shrink-0 bg-surface`}),s(`div`,{className:`flex min-h-0 flex-1`,children:[!o&&x(`aside`,{className:`flex flex-col border-r border-border bg-surface shrink-0 transition-[width] duration-150 ease-out ${V?`w-12`:`w-48`}`,children:ue}),o&&x(Ui,{open:f,onClose:()=>h(!1),width:`w-64`,children:ue}),s(`div`,{className:`flex flex-1 flex-col min-w-0`,children:[d!==null&&s(`div`,{className:`flex items-center justify-center gap-2 px-3 py-2 text-[12px] font-medium shrink-0 ${d.severity===`danger`?`bg-danger/90 text-white`:`bg-warning/15 text-warning border-b border-warning/30`}`,children:[d.severity===`danger`?x(Je,{className:`h-3.5 w-3.5`}):x(Se,{className:`h-3.5 w-3.5`}),x(`span`,{children:a(d.i18nKey,{defaultValue:d.message,...d.i18nParams})}),d.action===`sign-in`&&x(K,{variant:`unstyled`,onClick:()=>r(),className:`ml-2 rounded border border-white/40 px-2 py-0.5 text-[11px] font-semibold hover:bg-white/10`,children:a(`connection.signIn`,`Sign in`)}),d.showSpinner&&x(W,{className:`h-3.5 w-3.5 animate-spin`})]}),x(iC,{}),x(gC,{}),x(GC,{}),o&&s(`header`,{"data-debug-header":``,className:`flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface`,children:[x(K,{variant:`unstyled`,onClick:()=>h(!0),className:`p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors`,"aria-label":a(`layouts.appLayout.openMenu`,`Open menu`),children:x(Xe,{className:`h-5 w-5`})}),x(`div`,{className:`flex-1 flex justify-center`,children:x(`img`,{src:i?.resolvedMode===`light`?U(`/brand/logo-horizontal-light.svg`):U(`/brand/logo-horizontal-dark.svg`),alt:a(`layouts.appLayout.camstack`,`CamStack`),className:`h-7`})}),x(UC,{})]}),s(pS,{children:[x(hS,{}),x(`main`,{className:`relative flex-1 min-h-0 overscroll-contain bg-background ${L?`overflow-hidden`:`overflow-auto`}`,children:x(Wx,{resetKey:e.pathname,children:x(y,{fallback:x(gw,{}),children:x(mw,{})})})})]})]})]})]})}function $({children:e,requireAdmin:t}){let{t:n}=J(),{user:r,loading:i,mustChangePassword:a}=yb(),o=X();return i?x(`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(Z,{to:`/change-password`,replace:!0}):t&&!r.isAdmin?x(Z,{to:`/access-denied`,replace:!0}):x(I,{children:e}):x(Z,{to:`/login`,replace:!0,state:{from:o.pathname+o.search}})}var vw=`integration`,yw=`section`,bw=[vw,yw,`instance`,`instance-new`],xw={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`}},Sw=`activity`;function Cw(e,t={}){let{path:n,tab:r}=xw[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(vw,t.integration),t.section!==void 0&&i.set(yw,t.section);let a=i.toString();return a.length>0?`${n}?${a}`:n}function ww(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 Tw(e,t,n=null,r=null){let i=new URLSearchParams(e);return i.set(vw,t),r===null?i.delete(yw):i.set(yw,r),n!==null&&i.delete(n),i}function Ew(e){return e===`/admin`||e===`/admin/`?`/`:e.startsWith(`/admin/`)?e.slice(6):e}var Dw=`--color-surface`;function Ow(e){let t=e.querySelector(`meta[name="theme-color"]`);if(t)return t;let n=e.createElement(`meta`);return n.name=`theme-color`,e.head.appendChild(n),n}function kw(e=document){let t=e.defaultView?.getComputedStyle(e.documentElement).getPropertyValue(Dw).trim();if(!t)return;let n=Ow(e);n.content!==t&&(n.content=t)}function Aw(e=document){kw(e);let t=e.defaultView;if(!t)return()=>void 0;let n=new t.MutationObserver(()=>kw(e));return n.observe(e.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>n.disconnect()}function jw(){let{t:e}=J(),t=wc();return s(`div`,{className:`flex flex-col items-center justify-center text-foreground py-16 px-4`,children:[x(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-2xl bg-danger/10 mb-4`,children:x(ar,{className:`h-8 w-8 text-danger`})}),x(`h1`,{className:`text-xl font-bold`,children:e(`accessDenied.accessDenied`,`Access Denied`)}),x(`p`,{className:`mt-2 text-sm text-foreground-subtle`,children:e(`accessDenied.youDonTHavePermission`,`You don't have permission to access this page.`)}),x(K,{variant:`unstyled`,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`)})]})}function Mw(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 Nw(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 Pw(){return window?.PublicKeyCredential!==void 0&&typeof window.PublicKeyCredential==`function`}function Fw(e){let{id:t}=e;return{...e,id:Nw(t),transports:e.transports}}function Iw(e){return e===`localhost`||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var Lw=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),this.name=r??n.name,this.code=t}},Rw=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}}},zw=[`cross-platform`,`platform`];function Bw(e){if(e&&!(zw.indexOf(e)<0))return e}function Vw(){if(!Pw())return new Promise(e=>e(!1));let e=window.PublicKeyCredential;return e.isConditionalMediationAvailable===void 0?new Promise(e=>e(!1)):e.isConditionalMediationAvailable()}function Hw({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 Lw({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new Lw({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=window.location.hostname;if(!Iw(t))return new Lw({message:`${window.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new Lw({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 Lw({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 Uw(e){let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!Pw())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(Fw));let a={...t,challenge:Nw(t.challenge),allowCredentials:i},o={};if(n){if(!await Vw())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=Rw.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Hw({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=Mw(u.userHandle)),{id:c,rawId:Mw(l),response:{authenticatorData:Mw(u.authenticatorData),clientDataJSON:Mw(u.clientDataJSON),signature:Mw(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:Bw(s.authenticatorAttachment)}}function Ww(e){return typeof e==`object`&&!!e}function Gw(e){return Ww(e)&&typeof e.challenge==`string`}O();function Kw(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function qw(e){let{t}=J(),n=_t(),[r,i]=w(!1),[a,o]=w(``),[c,l]=w(null),[u,d]=w(null),f=p(null),m=b(e=>{f.current?.(e),f.current=null,i(!1),o(``),l(null),d(null)},[]),h=b(()=>new Promise(e=>{f.current?.(null),f.current=e,d(null),i(!0)}),[]),g=async()=>{l(`password`),d(null);try{let{reauthToken:e}=await n.reauthenticate({password:a});m(e)}catch(e){d(Kw(e,`Password is incorrect`)),l(null)}},_=async()=>{l(`passkey`),d(null);try{let{optionsJSON:e}=await n.reauthBeginPasskey();if(!Gw(e))throw Error(`passkey authentication options missing challenge`);let t=await Uw({optionsJSON:e}),{reauthToken:r}=await n.reauthenticate({passkeyResponse:Object.fromEntries(Object.entries(t))});m(r)}catch(e){d(Kw(e,`Passkey verification failed`)),l(null)}};return{requestProof:h,dialog:x(si,{open:r,onOpenChange:e=>!e&&m(null),children:s(Dr,{children:[s(Pr,{children:[x(hi,{children:t(`auth.reauthDialog.confirmItSYou`,`Confirm it’s you`)}),x(Ir,{children:t(`auth.reauthDialog.needsPassword`,{action:e})})]}),s(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),a.length>0&&c===null&&g()},children:[x(G,{type:`password`,autoComplete:`current-password`,placeholder:t(`auth.reauthDialog.currentPassword`,`Current password`),value:a,onChange:e=>o(e.target.value),"aria-label":t(`auth.reauthDialog.currentPassword`,`Current password`)}),u!==null&&x(`p`,{role:`alert`,className:`text-xs text-danger`,children:u}),s(ua,{className:`flex flex-wrap gap-2`,children:[s(K,{type:`button`,variant:`outline`,disabled:c!==null,onClick:()=>void _(),children:[c===`passkey`?x(W,{className:`h-4 w-4 animate-spin`}):x(er,{className:`h-4 w-4`}),t(`auth.reauthDialog.useAPasskey`,`Use a passkey`)]}),s(K,{type:`submit`,disabled:a.length===0||c!==null,children:[c===`password`&&x(W,{className:`h-4 w-4 animate-spin`}),t(`common.confirm`,`Confirm`)]})]})]})]})})}}O();function Jw(e){return e.ip!==null&&e.approverIp!==null&&e.ip!==e.approverIp}function Yw(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function Xw(e){let t=e instanceof Error?e.message:``;return t.startsWith(`Sign in again first`)||t.startsWith(`Confirm it is you`)}function Zw(e,t){let n=Math.max(0,Math.round((t-e)/1e3));return n<5?{key:`justNow`,value:0}:n<60?{key:`seconds`,value:n}:{key:`minutes`,value:Math.round(n/60)}}function Qw({onApproved:e,onDenied:t}){let{t:n}=J(),r=da.useUtils(),[i,a]=w(``),[o,c]=w(null),[l,u]=w(``),[d,f]=w(null),[p,m]=w(null),{requestProof:h,dialog:g}=qw(n(`cliLogin.reauthAction`,`Approving a terminal sign-in`)),_=da.auth.cliLoginApprove.useMutation(),v=da.auth.cliLoginDeny.useMutation(),y=async e=>{e.preventDefault(),f(`lookup`),m(null);try{c(await r.auth.cliLoginDescribe.fetch({userCode:i})),u(i)}catch(e){c(null),m(Yw(e,n(`cliLogin.unknownCode`,`No pending sign-in with that code. Check the terminal.`)))}finally{f(null)}},b=async r=>{f(r),m(null);try{if(r===`deny`){await v.mutateAsync({userCode:l}),t();return}try{await _.mutateAsync({userCode:l})}catch(e){if(!Xw(e))throw e;let t=await h();if(t===null)return;await _.mutateAsync({userCode:l,reauthToken:t})}e()}catch(e){m(Yw(e,n(`cliLogin.failed`,`That did not work. Try again.`)))}finally{f(null)}},S=o===null?null:Zw(o.createdAt,Date.now());return s(`div`,{className:`space-y-4`,"data-testid":`cli-login-approval`,children:[s(`div`,{className:`space-y-1`,children:[s(`h1`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[x(nr,{className:`h-4 w-4`,"aria-hidden":!0}),n(`cliLogin.title`,`Approve a terminal sign-in`)]}),x(`p`,{className:`text-xs text-foreground-subtle`,children:n(`cliLogin.intro`,`Type the code your terminal shows. Only approve a sign-in you started yourself.`)})]}),p!==null&&x(`div`,{role:`alert`,className:`rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:p}),o===null||S===null?s(`form`,{onSubmit:e=>void y(e),className:`space-y-3`,children:[x(G,{value:i,onChange:e=>a(e.target.value),placeholder:`ABCD-EFGH`,"aria-label":n(`cliLogin.codeLabel`,`Sign-in code`),autoComplete:`off`,autoCapitalize:`characters`,spellCheck:!1,maxLength:16,className:`text-center font-mono tracking-widest`}),s(K,{type:`submit`,variant:`primary`,className:`w-full`,disabled:i.trim().length<8||d!==null,children:[d===`lookup`&&x(W,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),n(`cliLogin.continue`,`Continue`)]})]}):s(`div`,{className:`space-y-3`,children:[s(`dl`,{className:`space-y-1 rounded-md border border-border bg-background-elevated p-3 text-xs`,children:[s(`div`,{className:`flex justify-between gap-3`,children:[x(`dt`,{className:`text-foreground-muted`,children:n(`cliLogin.address`,`Terminal address`)}),x(`dd`,{className:`text-foreground`,"data-testid":`cli-login-ip`,children:o.ip??n(`cliLogin.unknownValue`,`Unknown`)})]}),s(`div`,{className:`flex justify-between gap-3`,children:[x(`dt`,{className:`text-foreground-muted`,children:n(`cliLogin.yourAddress`,`Your address`)}),x(`dd`,{className:`text-foreground`,"data-testid":`cli-login-approver-ip`,children:o.approverIp??n(`cliLogin.unknownValue`,`Unknown`)})]}),s(`div`,{className:`flex justify-between gap-3`,children:[x(`dt`,{className:`text-foreground-muted`,children:n(`cliLogin.program`,`Program (seen by the hub)`)}),x(`dd`,{className:`truncate text-foreground`,"data-testid":`cli-login-agent`,children:o.userAgent??n(`cliLogin.unknownValue`,`Unknown`)})]}),s(`div`,{className:`flex justify-between gap-3`,children:[x(`dt`,{className:`text-foreground-muted`,children:n(`cliLogin.client`,`Name it gave itself (unverified)`)}),x(`dd`,{className:`truncate text-foreground-muted`,"data-testid":`cli-login-client`,children:o.client??n(`cliLogin.unknownValue`,`Unknown`)})]}),s(`div`,{className:`flex justify-between gap-3`,children:[x(`dt`,{className:`text-foreground-muted`,children:n(`cliLogin.requested`,`Requested`)}),x(`dd`,{className:`text-foreground`,children:S.key===`justNow`?n(`cliLogin.ageNow`,`just now`):S.key===`seconds`?n(`cliLogin.ageSeconds`,`{{count}} s ago`,{count:S.value}):n(`cliLogin.ageMinutes`,`{{count}} min ago`,{count:S.value})})]})]}),Jw(o)&&x(`div`,{role:`alert`,"data-testid":`cli-login-mismatch`,className:`rounded-md border border-warning/20 bg-warning/10 px-3 py-2 text-xs text-warning`,children:n(`cliLogin.mismatch`,`This request comes from a different address than the one you are using now. Approve it only if you started it from another machine of yours.`)}),x(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`cli-login-grant`,children:n(`cliLogin.grant`,`Approving signs this terminal in as you, with all of your rights, until the session expires or you end it under Tokens & sessions.`)}),s(`div`,{className:`flex gap-2`,children:[x(K,{type:`button`,variant:`ghost`,className:`flex-1`,disabled:d!==null,onClick:()=>void b(`deny`),children:n(`cliLogin.deny`,`Deny`)}),s(K,{type:`button`,variant:`primary`,className:`flex-1`,disabled:d!==null,onClick:()=>void b(`approve`),children:[d===`approve`&&x(W,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),n(`cliLogin.approve`,`Approve`)]})]})]}),g]})}O();function $w(){let{t:e}=J(),t=Ri(),n=wc(),[r,i]=w(!1);return x(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:s(`div`,{className:`w-full max-w-sm`,children:[x(`div`,{className:`mb-8 flex justify-center`,children:x(`img`,{src:t?.resolvedMode===`light`?U(`/brand/logo-horizontal-light.svg`):U(`/brand/logo-horizontal-dark.svg`),alt:e(`cliLogin.brand`,`CamStack`),className:`h-12`})}),x(`div`,{className:`rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:r?s(`div`,{className:`space-y-3 text-center`,"data-testid":`cli-login-denied`,children:[x(`p`,{className:`text-sm text-foreground`,children:e(`cliLogin.deniedBody`,`The sign-in was denied. The terminal stays signed out.`)}),x(K,{type:`button`,variant:`ghost`,onClick:()=>void n(`/`),children:e(`cliLogin.back`,`Back to CamStack`)})]}):x(Qw,{onApproved:()=>window.location.assign(U(un(null,{status:`success`,action:`cli-login`}))),onDenied:()=>i(!0)})})]})})}var eT=`auth.password-incorrect`;function tT(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function nT(e){if(!(e instanceof Error))return{kind:`connection-lost`};let t=tT(e,`data`);return typeof t!=`object`||!t?{kind:`connection-lost`}:tT(tT(t,`i18n`),`code`)===eT?{kind:`wrong-current`}:tT(t,`code`)===`UNAUTHORIZED`?{kind:`session-ended`}:{kind:`rejected`,message:e.message}}O();var rT=8;function iT(e,t){let n=nT(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 aT(){let{t:e}=J(),{user:t,mustChangePassword:n,clearMustChangePassword:r,logout:i}=yb(),a=_t(),o=Ri(),c=wc(),[l,u]=w(``),[d,f]=w(``),[p,m]=w(``),[h,g]=w(!1),[_,v]=w(``),[y,b]=w(!1),S=n?lb:l;return x(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:s(`div`,{className:`w-full max-w-sm`,children:[x(`div`,{className:`flex justify-center mb-8`,children:x(`img`,{src:o?.resolvedMode===`light`?U(`/brand/logo-horizontal-light.svg`):U(`/brand/logo-horizontal-dark.svg`),alt:e(`changePassword.camstackAdmin`,`CamStack Admin`),className:`h-12`})}),s(`form`,{onSubmit:async i=>{if(i.preventDefault(),v(``),!t){v(`Not signed in`);return}if(!n&&l.length===0){v(e(`changePassword.enterCurrent`,`Enter your current password`));return}if(d.length<rT){v(`Password must be at least ${rT} characters`);return}if(d!==p){v(`The two passwords do not match`);return}if(d===`changeme`){v(`Choose a password different from the seed default`);return}b(!0);try{await a.changeOwnPassword({currentPassword:S,newPassword:d}),r(),c(`/devices`,{replace:!0})}catch(t){v(iT(t,e))}finally{b(!1)}},className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[s(`div`,{className:`space-y-1`,children:[x(`h1`,{className:`text-sm font-semibold text-foreground`,children:e(`changePassword.setANewPassword`,`Set a new password`)}),x(`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.`)})]}),_&&x(`div`,{role:`alert`,className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:_}),!n&&s(`div`,{className:`space-y-1.5`,children:[x(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.currentPassword`,`Current password`)}),x(G,{"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})]}),s(`div`,{className:`space-y-1.5`,children:[x(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.newPassword`,`New password`)}),s(`div`,{className:`relative`,children:[x(G,{"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}),x(K,{variant:`unstyled`,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:x(h?ut:Me,{className:`h-4 w-4`})})]})]}),s(`div`,{className:`space-y-1.5`,children:[x(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`changePassword.confirmNewPassword`,`Confirm new password`)}),x(G,{"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`})]}),x(K,{variant:`unstyled`,"data-testid":`change-password-submit`,type:`submit`,disabled:y||!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:y?e(`changePassword.saving`,`Saving…`):e(`changePassword.saveAndContinue`,`Save and continue`)}),n&&x(K,{variant:`unstyled`,type:`button`,onClick:()=>{i(),c(`/login`,{replace:!0})},className:`w-full text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:e(`changePassword.signOutInstead`,`Sign out instead`)})]})]})})}O();async function oT(e){if(!Gw(e))throw Error(`passkey authentication options missing challenge`);let t=await Uw({optionsJSON:e});return Object.fromEntries(Object.entries(t))}function sT({method:e,challengeToken:t,onComplete:n,onSecondFactor:r,onError:i}){let[a,o]=w(!1),[c,l]=w(null),u=async()=>{l(null),o(!0);try{let e=_y();if(t){let r=await oT((await e.loginBeginPasskey(t)).optionsJSON),i=await e.loginVerifyPasskey(t,r,{refreshable:!0});n(i.token,i);return}let a=await oT((await e.passkeyLoginBegin()).optionsJSON),o=await e.passkeyLoginFinish(a,{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),i?.(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),i?.(r)}finally{o(!1)}};return s(`div`,{className:`space-y-2`,children:[s(K,{variant:`unstyled`,type:`button`,"data-testid":t?`login-passkey`:`login-passkey-direct`,onClick:()=>void u(),disabled:a,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:[a?x(W,{className:`h-4 w-4 animate-spin text-primary`}):x(Xn,{className:`h-4 w-4 text-primary`}),e.label]}),c&&x(`div`,{className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:c})]})}var cT=()=>window.location.hostname;function lT(e,t=cT,n=null){return n===!1?!1:Pw()&&QS(t(),e.rpId)}function uT(e,t=cT,n=null){let r=e.filter(e=>e.kind===`passkey`&&e.stage===`second-factor`).filter(e=>lT(e,t,n));return{passkeyMethods:r,widgetMethods:r.length>0?[]:e.filter(e=>e.kind===`widget`&&e.stage===`second-factor`)}}function dT(e,t){let n=e.includes(`passkey`),r=t.passkeyMethods.length>0||t.widgetMethods.length>0,i=e.includes(`totp`);return n&&!r&&!i}O();async function fT(){if(typeof PublicKeyCredential>`u`)return null;let e=PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable;if(typeof e!=`function`)return null;try{return await e.call(PublicKeyCredential)}catch{return null}}var pT=()=>`camstackAgentApp`in window;function mT(){let[e,t]=w(null);return S(()=>{if(!pT())return;let e=!0;return fT().then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}function hT(e){let t=e.onComplete,n=e.onSecondFactor;return typeof t==`function`?{onComplete:t,onSecondFactor:typeof n==`function`?n:void 0}:null}function gT({methods:e,widgetConfig:t,onRedirect:n}){let{t:r}=J();Er();let i=mT(),a=e.filter(e=>e.kind!==`passkey`||lT(e,void 0,i));return a.length===0?null:s(`div`,{className:`mt-6 space-y-3`,children:[s(`div`,{className:`flex items-center gap-3`,children:[x(`div`,{className:`h-px flex-1 bg-border`}),x(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:r(`login.primaryLoginMethods.orContinueWith`,`Or continue with`)}),x(`div`,{className:`h-px flex-1 bg-border`})]}),x(`div`,{className:`space-y-2`,children:a.map(e=>{if(e.kind===`redirect`){let t=(e.icon===void 0?void 0:qr(e.icon))??H;return s(`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:[x(t,{className:`h-4 w-4 text-primary`}),e.label]},e.id)}if(e.kind===`passkey`){let n=hT(t);return n?x(sT,{method:e,onComplete:n.onComplete,onSecondFactor:n.onSecondFactor},e.id):null}return x(_T,{method:e,config:t},e.id)})})]})}function _T({method:e,config:t}){let{t:n}=J(),r=oa(e.remote,e.bundleUrl);return r===null?s(`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:[x(W,{className:`h-3.5 w-3.5 animate-spin`}),n(`common.loading`,`Loading…`)]}):r===void 0?s(`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:[x(z,{className:`h-3.5 w-3.5 shrink-0`}),n(`login.primaryMethods.loadFailed`)]}):x(r,{instanceId:e.id,host:`dashboard`,config:t})}var vT=4e3,yT=/^[A-Za-z0-9._-]{1,64}$/;function bT(e){if(e.action===`cli-login`)return Cw(`access`);let t=e.addonId!==void 0&&yT.test(e.addonId)?e.addonId:null,n=e.integration!==void 0&&yT.test(e.integration)?e.integration:null;if(t!==null&&e.brokerId!==void 0)return Cw(`connectivity`,{integration:t,kindSection:`brokers`});let r=n??t;return Cw(`connectivity`,r===null?{}:{integration:r})}function xT(e,t){let n=t.opener;if(n===null||n.closed||to(n)!==t.origin)return!1;try{return n.postMessage({type:Nu,ok:e.status===`success`,...e.brokerId===void 0?{}:{brokerId:e.brokerId},...e.status===`error`?{error:e.reason??`unknown`}:{}},t.origin),!0}catch{return!1}}O();var ST=500;function CT(e){let{t}=J();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 wT({outcome:e}){let{t}=J(),n=CT(e.reason??`unknown`);if(e.status===`error`)return s(I,{children:[x(xe,{className:`mx-auto h-8 w-8 text-danger`,"aria-hidden":!0}),x(`h1`,{"data-testid":`oauth-landing-title`,className:`text-sm font-semibold text-foreground`,children:t(`oauthLanding.errorTitle`,`Sign-in did not finish`)}),x(`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})]});if(e.action===`cli-login`)return s(I,{children:[x(Ce,{className:`mx-auto h-8 w-8 text-success`,"aria-hidden":!0}),x(`h1`,{"data-testid":`oauth-landing-title`,className:`text-sm font-semibold text-foreground`,children:t(`oauthLanding.cliLoginTitle`,`Terminal signed in`)}),x(`p`,{className:`text-xs text-foreground-muted`,children:t(`oauthLanding.cliLoginBody`,`Go back to your terminal: it finishes the sign-in by itself.`)})]});let r=e.action===`disconnect`;return s(I,{children:[x(Ce,{className:`mx-auto h-8 w-8 text-success`,"aria-hidden":!0}),x(`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`)}),x(`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 TT({outcome:e,closable:t,onContinue:n,onClose:r}){let{t:i}=J(),a=bT(e);return S(()=>{if(e.status!==`success`)return;let t=window.setTimeout(()=>n(a),vT);return()=>window.clearTimeout(t)},[e.status,n,a]),x(`main`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:s(`div`,{className:`w-full max-w-sm space-y-4`,children:[x(`div`,{className:`flex justify-center`,children:s(`picture`,{children:[x(`source`,{media:`(prefers-color-scheme: dark)`,srcSet:U(`/brand/logo-horizontal-dark.svg`)}),x(`img`,{src:U(`/brand/logo-horizontal-light.svg`),alt:i(`oauthLanding.brand`,`CamStack`),className:`h-12`})]})}),s(`div`,{className:`space-y-4 rounded-xl border border-border bg-surface p-6 text-center shadow-xl shadow-black/10`,children:[x(wT,{outcome:e}),s(`div`,{className:`flex flex-col gap-2`,children:[x(K,{type:`button`,variant:`primary`,onClick:()=>n(a),children:i(`oauthLanding.back`,`Back to CamStack`)}),t&&x(K,{type:`button`,variant:`ghost`,onClick:r,children:i(`oauthLanding.close`,`Close this window`)})]})]})]})})}function ET(e,t){window.history.replaceState(null,``,window.location.pathname);let n=window.opener,r=xT(t,{opener:n,origin:window.location.origin}),i=()=>e.render(x(TT,{outcome:t,closable:r,onContinue:e=>window.location.replace(U(e)),onClose:()=>window.close()}));if(r&&t.status===`success`){window.close(),window.setTimeout(i,ST);return}i()}function DT(e){return kn(e)}var OT=`Done — you can close this window.`,kT=500,AT=`camstack_admin_token`;async function jT(e,t=``){try{let n=Oy(new URLSearchParams(t));n!==null&&n.token===e?Ty(n):localStorage.setItem(AT,e)}catch{}await fetch(U(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}function MT(){try{let e=localStorage.getItem(AT);return e!==null&&e.length>0?e:null}catch{return null}}function NT(e){let t=DT(window.location.hash);if(t!==null){ET(e,t);return}let n=Xa(window.location.hash);window.history.replaceState(null,``,window.location.pathname);let r=t=>e.render(x(PT,{completion:n,result:t,hasOpener:window.opener!==null}));if(r(null),n===null)return;let i=no();io(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:OT}),kT)},continueAt:e=>window.location.replace(U(e)),persistSession:e=>jT(e,n.target===`login`?n.fragment:``),showResult:r,setTimeout:(e,t)=>window.setTimeout(e,t)})}function PT({completion:e,result:t,hasOpener:n=!0}){let{t:r}=J();return x(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:x(`div`,{className:`flex flex-col items-center gap-3 text-sm text-foreground-subtle`,children:e===null?x(`a`,{className:`text-primary underline`,href:U(`/login`),children:r(`ssoComplete.nothingToFinishHereGo`,`Nothing to finish here — go to sign-in`)}):t===null?s(`span`,{className:`flex items-center gap-3`,children:[x(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),r(`ssoComplete.finishingSignIn`,`Finishing sign-in…`)]}):s(I,{children:[x(`span`,{"data-testid":`sso-complete-result`,className:t.kind===`link-error`?`text-danger`:`text-foreground`,children:t.message}),x(K,{variant:`unstyled`,type:`button`,className:`rounded-md border border-border px-3 py-1.5 text-foreground hover:bg-surface-hover`,onClick:()=>window.close(),children:r(`ssoComplete.closeThisWindow`,`Close this window`)}),!n&&x(`a`,{className:`text-primary underline`,href:U(`/login`),children:r(`ssoComplete.backToSignIn`,`Back to sign-in`)})]})})})}O();function FT(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 IT(){let e=new URLSearchParams(window.location.search);return Uy({codeChallenge:e.get(`code_challenge`),codeChallengeMethod:e.get(`code_challenge_method`),state:e.get(`state`),purpose:e.get(`purpose`)})}function LT(e){return Math.min(1e3*2**e,15e3)}function RT(){let{t:e}=J(),{login:t,verifyTotp:n,finalizePasskeyLogin:r,user:i}=yb(),{i18n:a}=J(),o=Ri(),c=wc(),l=X(),u=new URLSearchParams(window.location.search).get(`next`);S(()=>{Qy(u)},[u]);let d=new URLSearchParams(window.location.search).get(`redirect`);S(()=>{sb(d)},[d]);let f=IT();S(()=>{Ky(f)},[f?.codeChallenge,f?.state,f?.purpose]);let m=l.state,h=rw(m?.from),[g,_]=w(``),[v,y]=w(``),[b,C]=w(!1),[T,E]=w(``),[D,O]=w(!1),[k,A]=w(`credentials`),[j,M]=w(``),[N,P]=w([]),[F,L]=w(``),[R,z]=w(void 0),[ee,ne]=w(`sso-not-linked`),B=da.auth.listLoginMethods.useQuery(void 0,{retry:!0,retryDelay:LT}),re=B.data===void 0,ie=(B.data??[]).filter(e=>e.kind!==`device-certificate`),V=da.auth.getServerName.useQuery().data,oe=ie.filter(e=>e.stage===`primary`),se=uT(ie,void 0,mT());S(()=>{let e=ao(window.location.hash);if(e!==null){if(window.history.replaceState({},``,window.location.pathname+window.location.search),e.kind===`challenge`){M(e.challengeToken),P(e.factors),L(``),A(`second-factor`);return}ne(e.code),z(e.provider)}},[]);let ce=R==null?null:ie.find(e=>e.id===R&&`label`in e)?.label??null,le=T||(R===void 0?``:Qa(ee,ce)),{passkeyMethods:H,widgetMethods:ue}=se,de=p(!1),fe=async()=>{if(de.current)return;de.current=!0;let e=Yy(d);if(e?.kind===`app-callback`){await he(e.url);return}else if(e){window.location.assign(U(e.path));return}let t=eb(u);t?window.location.assign(U(t)):c(h,{replace:!0})},[pe,me]=w(null),he=async e=>{me({callbackBase:e,mintedUrl:null,failed:!1});try{let t=IT()??qy();if(t===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await _y().trpcClient.auth.createHandoffCode.mutate({purpose:t.purpose,codeChallenge:t.codeChallenge,state:t.state}),r=Jy(e,n,t.state);me({callbackBase:e,mintedUrl:r,failed:!1}),window.location.assign(r)}catch(t){if(FT(t)){de.current=!1,me(null),E(`Sign in again to confirm it is you.`);return}me({callbackBase:e,mintedUrl:null,failed:!0})}},ge=i!==null,[_e,ve]=w(!1);S(()=>{!ge||!d&&!u||_e||(ve(!0),fe())},[ge,d,u,_e]);let ye=async e=>{e.preventDefault(),E(``),z(void 0),O(!0);try{let e=await t(g,v);if(e.kind===`second-factor`){M(e.challengeToken),P(e.factors),A(`second-factor`);return}v===`changeme`?c(`/change-password`,{replace:!0}):await fe()}catch(e){E(e instanceof Error?e.message:`Login failed`)}finally{O(!1)}},be=async e=>{e.preventDefault(),E(``),O(!0);try{await n(j,F.trim()),await fe()}catch(e){E(e instanceof Error?e.message:`TOTP verification failed`),L(``)}finally{O(!1)}},xe=async(e,t)=>{try{await r(e,t),await fe()}catch(e){E(e instanceof Error?e.message:`Passkey sign-in failed`)}},Se=p(null);S(()=>()=>Se.current?.(),[]);let Ce=async e=>{if(e.target!==`login`)return;let t=Oy(new URLSearchParams(e.fragment));if(t!==null){try{await r(t.token,t),await fe()}catch(e){E(e instanceof Error?e.message:`Sign-in failed`)}return}let n=ao(`#${e.fragment}`);if(n!==null){if(n.kind===`challenge`){Te({challengeToken:n.challengeToken,factors:n.factors});return}ne(n.code),z(n.provider)}},we=e=>{if(By(d)?.kind===`app-callback`)return!1;let t=$a(U(Za(e.startUrl)));return t===null?!1:(E(``),z(void 0),Se.current?.(),Se.current=ro(t,{onReturn:e=>{Se.current?.(),Se.current=null,Ce(e)},onDone:e=>{if(Se.current?.(),Se.current=null,e.target!==`login`)return;let t=MT()===null?null:wy();t!==null&&Ce({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)},Te=e=>{let t=e.factors.filter(e=>e===`totp`||e===`passkey`);M(e.challengeToken),P(t),L(``),E(``),A(`second-factor`)};return pe===null?x(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:s(`div`,{className:`w-full max-w-sm`,children:[x(`div`,{className:`flex justify-center mb-8`,children:x(`img`,{src:o?.resolvedMode===`light`?U(`/brand/logo-horizontal-light.svg`):U(`/brand/logo-horizontal-dark.svg`),alt:e(`login.camstackAdmin`,`CamStack Admin`),className:`h-12`})}),V!==void 0&&!V.isDefault&&x(`p`,{"data-testid":`login-server-name`,className:`-mt-4 mb-6 text-center text-sm text-foreground-muted`,children:x(Mu,{i18nKey:`login.signInTo`,values:{name:V.name},components:{b:x(`span`,{className:`font-semibold text-foreground`})}})}),k===`credentials`?s(`form`,{onSubmit:ye,className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[le&&x(`div`,{"data-testid":`login-error`,className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:le}),s(`div`,{className:`space-y-1.5`,children:[x(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.username`,`Username`)}),x(G,{"data-testid":`login-username`,type:`text`,placeholder:e(`login.username`,`Username`),value:g,onChange:e=>_(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})]}),s(`div`,{className:`space-y-1.5`,children:[x(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.password`,`Password`)}),s(`div`,{className:`relative`,children:[x(G,{"data-testid":`login-password`,type:b?`text`:`password`,placeholder:e(`login.password`,`Password`),value:v,onChange:e=>y(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`}),x(K,{variant:`unstyled`,type:`button`,onClick:()=>C(!b),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground transition-colors`,tabIndex:-1,children:x(b?ut:Me,{className:`h-4 w-4`})})]})]}),x(K,{variant:`unstyled`,"data-testid":`login-submit`,type:`submit`,disabled:D||!g||!v,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?s(`span`,{className:`flex items-center justify-center gap-2`,children:[x(`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`)})]}):s(`div`,{className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[s(`div`,{className:`flex items-center gap-2 pb-1 border-b border-border`,children:[x(te,{className:`h-4 w-4 text-primary`}),x(`div`,{className:`text-sm font-medium text-foreground`,children:e(`login.twoFactorAuthentication`,`Two-factor authentication`)})]}),x(`p`,{className:`text-xs text-foreground-subtle`,children:g?x(I,{children:x(Mu,{i18nKey:`login.finishSigningInAs`,values:{username:g},components:{mono:x(`span`,{className:`font-mono text-foreground`})}})}):e(`login.finishSigningInAs`,`Finish signing in.`)}),T&&x(`div`,{className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:T}),N.includes(`passkey`)&&H.map(e=>x(sT,{method:e,challengeToken:j,onComplete:xe},e.id)),N.includes(`passkey`)&&ue.map(e=>x(_T,{method:e,config:{challengeToken:j,onComplete:xe}},e.id)),dT(N,se)&&x(`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.`)}),N.includes(`passkey`)&&N.includes(`totp`)&&s(`div`,{className:`flex items-center gap-3`,children:[x(`div`,{className:`h-px flex-1 bg-border`}),x(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`or`}),x(`div`,{className:`h-px flex-1 bg-border`})]}),N.includes(`totp`)&&s(`form`,{onSubmit:be,className:`space-y-4`,children:[s(`div`,{className:`space-y-1.5`,children:[x(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:e(`login.authenticationCode`,`Authentication code`)}),x(G,{"data-testid":`login-totp`,type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:F,onChange:e=>L(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})]}),x(K,{variant:`unstyled`,"data-testid":`login-totp-submit`,type:`submit`,disabled:D||F.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?s(`span`,{className:`flex items-center justify-center gap-2`,children:[x(`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`)})]}),s(K,{variant:`unstyled`,type:`button`,onClick:()=>{A(`credentials`),M(``),P([]),L(``),E(``)},className:`w-full flex items-center justify-center gap-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:[x(ae,{className:`h-3 w-3`}),e(`login.backToUsernamePassword`,`Back to username + password`)]})]}),k===`credentials`&&re&&s(`p`,{"data-testid":`login-methods-pending`,role:`status`,className:`mt-4 flex items-center justify-center gap-2 text-xs text-foreground-subtle`,children:[x(`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`&&x(gT,{methods:oe,widgetConfig:{onComplete:xe,onSecondFactor:Te,locale:a.language},onRedirect:we}),x(`p`,{className:`mt-6 text-center text-[10px] text-foreground-subtle/50`,children:x(uw,{placement:`login`})})]})}):x(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:s(`div`,{className:`w-full max-w-sm rounded-xl border border-border bg-surface p-6 text-center space-y-4`,children:[x(`h1`,{className:`text-sm font-semibold text-foreground`,children:e(`login.returningToTheApp`,`Returning to the app…`)}),pe.failed?s(I,{children:[x(`p`,{className:`text-xs text-danger`,children:e(`login.couldNotPrepareTheSign`,`Could not prepare the sign-in handoff. You are logged in — retry below.`)}),x(K,{variant:`unstyled`,onClick:()=>void he(pe.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`)})]}):pe.mintedUrl===null?x(`p`,{className:`text-xs text-foreground-subtle`,children:e(`login.preparingAOneTimeSign`,`Preparing a one-time sign-in code…`)}):s(I,{children:[x(`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).`)}),x(`a`,{href:pe.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`)})]})]})})}function zT(e){let t=new URLSearchParams(e).get(TS),n=new URLSearchParams({tab:`templates`});return t!==null&&n.set(TS,t),`/build?${n.toString()}`}function BT(){let{search:e}=X();return x(Z,{to:zT(e),replace:!0})}O();function VT(){let{pathname:e,search:t,hash:n}=X();return x(Z,{to:`${Ew(e)}${t}${n}`,replace:!0})}function HT(){let{pathname:e,search:t}=X();return x(Z,{to:$o(e,t)??`/archive`,replace:!0})}function UT(){let{nodeId:e=``}=Oc();return x(Z,{to:`/system/terminal?tab=shells&node=${encodeURIComponent(e)}`,replace:!0})}function WT(){let{pathname:e,search:t}=X(),n=$o(e,t);return n===null?x(eE,{}):x(Z,{to:n,replace:!0})}function GT(){return x(Z,{to:tw()??`/devices`,replace:!0})}var KT=g(()=>a(()=>import(`./Devices-C2_XrAsB.js`).then(e=>({default:e.DevicesPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]),import.meta.url)),qT=g(()=>a(()=>import(`./Integrations-BNc3Xhbg.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([12,1,2,3,4,5,13,6,14,7,8,10]),import.meta.url)),JT=g(()=>a(()=>import(`./IntegrationDetail-Bv3DXRXC.js`).then(e=>({default:e.IntegrationDetailPage})),__vite__mapDeps([15,1,2,3,4,5,16,6,8,9]),import.meta.url)),YT=g(()=>a(()=>import(`./Pipeline-Bujc9zjR.js`).then(e=>({default:e.PipelinePage})),__vite__mapDeps([17,1,2,3,4,5,13,6,18,19,20,21,22,23,24,25,10]),import.meta.url)),XT=g(()=>a(()=>import(`./DeviceDetail-DphkoMAH.js`).then(e=>({default:e.DeviceDetailPage})),__vite__mapDeps([26,1,2,3,4,5,13,6,18,27,28,29,30,31,21,32,33,34,35,36,37,38,39,40,41,42,43,24,10,44,45]),import.meta.url)),ZT=g(()=>a(()=>import(`./Showroom-DU9iMIZh.js`).then(e=>({default:e.ShowroomPage})),__vite__mapDeps([46,1,2,3,4,5]),import.meta.url)),QT=g(()=>a(()=>import(`./EmbedPlayerPage-BKlnHqN7.js`).then(e=>({default:e.EmbedPlayerPage})),__vite__mapDeps([47,1,2,3,4,5,6]),import.meta.url)),$T=g(()=>a(()=>import(`./EmbedDevicePage-B-kXRzxP.js`).then(e=>({default:e.EmbedDevicePage})),__vite__mapDeps([48,1,2,3,4,5,32,13,6]),import.meta.url)),eE=g(()=>a(()=>import(`./Library-CC-yVMZb.js`).then(e=>({default:e.LibraryPage})),__vite__mapDeps([49,1,2,3,4,5,13,6,18,50,20,51,52,53,54,44,38,55]),import.meta.url)),tE=g(()=>a(()=>import(`./Archive-KiES4AK1.js`).then(e=>({default:e.ArchivePage})),__vite__mapDeps([56,1,2,3,4,5,13,6,18,57,51,52,53,37,38,58,59,60,61,62,22,23,55,44]),import.meta.url)),nE=g(()=>a(()=>import(`./Viewer-Cu1fVuMh.js`).then(e=>({default:e.ViewerPage})),__vite__mapDeps([63,2,3,4,5,64,6,38,1]),import.meta.url)),rE=g(()=>a(()=>import(`./Build-CLqFtQQF.js`).then(e=>({default:e.BuildPage})),__vite__mapDeps([65,1,2,3,4,5,13,6,18,30,66,52,33,27,34,35,36,39,40,41,43,67]),import.meta.url)),iE=g(()=>a(()=>import(`./CompositionEditorPage-Cjdi12u4.js`).then(e=>({default:e.CompositionEditorPage})),__vite__mapDeps([68,1,2,3,4,5,6,7,33,13,18,27,34,35,36]),import.meta.url)),aE=g(()=>a(()=>import(`./Locations-TgIsNyQs.js`).then(e=>({default:e.LocationsPage})),__vite__mapDeps([69,1,2,3,4,5,13,6,52,42,35,36]),import.meta.url)),oE=g(()=>a(()=>import(`./Addons-CBfB4PwF.js`).then(e=>({default:e.AddonsPage})),__vite__mapDeps([70,1,2,3,4,5,18,6,7,71,22,23,11,38]),import.meta.url)),sE=g(()=>a(()=>import(`./AiProfiles-Uzt6ITwV.js`).then(e=>({default:e.AiProfilesPage})),__vite__mapDeps([72,1,2,3,4,5,13,6,73,74,7,52,61,62,22,23,38,75]),import.meta.url)),cE=g(()=>a(()=>import(`./MyAccess-CvFEb2P_.js`).then(e=>({default:e.MyAccessPage})),__vite__mapDeps([76,1,2,3,4,5,13,6,18,77,40,7,52,78,79,38,80]),import.meta.url)),lE=g(()=>a(()=>import(`./Logs-CjVZvl-p.js`).then(e=>({default:e.LogsPage})),__vite__mapDeps([81,1,2,3,4,5,21,82,6,7,52,61,62,22,23,38]),import.meta.url)),uE=g(()=>a(()=>import(`./Identity-BELn4_Lg.js`).then(e=>({default:e.IdentityPage})),__vite__mapDeps([83,1,2,3,4,5,13,6,18,31,84,77,40,7,52,61,62,22,23,38,78,79,85]),import.meta.url)),dE=g(()=>a(()=>import(`./Network-BApaJTDv.js`).then(e=>({default:e.NetworkPage})),__vite__mapDeps([86,1,2,3,4,5,13,6,18,7,52,61,62,22,23,38,87]),import.meta.url)),fE=g(()=>a(()=>import(`./Integrations-w_KbkNum.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([88,1,2,3,4,5,6,52,61,62,22,23,38]),import.meta.url)),pE=g(()=>a(()=>import(`./TrainingProviders-BG7DsUoT.js`).then(e=>({default:e.TrainingProvidersPage})),__vite__mapDeps([89,1,2,3,4,5,6,7,61,62,22,23,38]),import.meta.url)),mE=g(()=>a(()=>import(`./Data-DkKT4kg4.js`).then(e=>({default:e.DataPage})),__vite__mapDeps([90,1,2,3,4,5,13,6,18,28,91,60,7,52,61,62,22,23,38,58,59,55,44]),import.meta.url)),hE=g(()=>a(()=>import(`./System-1Jh6VozL.js`).then(e=>({default:e.SystemPage})),__vite__mapDeps([92,1,2,3,4,5,13,6,93,7,52,85,23,38]),import.meta.url)),gE=g(()=>a(()=>import(`./Cluster-ZhXkbC8q.js`).then(e=>({default:e.ClusterPage})),__vite__mapDeps([94,1,2,3,4,5,13,6,60,95,40,7,71,43,22,23,25,55]),import.meta.url)),_E=g(()=>a(()=>import(`./Terminal-DyWFdRWL.js`).then(e=>({default:e.TerminalPage})),__vite__mapDeps([96,1,2,3,4,5,18,6,7,61,62,22,23,38,78,34,43,13,87,97]),import.meta.url)),vE=g(()=>a(()=>import(`./Notifications-DXM5xtCq.js`).then(e=>({default:e.NotificationsPage})),__vite__mapDeps([98,1,2,3,4,5,13,6,73,99,7,52,61,62,22,23,38,43,54,67,41,75,36,45]),import.meta.url)),yE=g(()=>a(()=>import(`./History-C8ZY-Ovj.js`).then(e=>({default:e.HistoryPage})),__vite__mapDeps([100,1,2,3,4,5,18,6,7]),import.meta.url)),bE=g(()=>a(()=>import(`./Calendars-fZrHEH0S.js`).then(e=>({default:e.CalendarsPage})),__vite__mapDeps([101,1,2,3,4,5,13,6,7]),import.meta.url)),xE=new D({defaultOptions:{queries:{gcTime:0,staleTime:0,retry:!1,refetchOnWindowFocus:!1}}});Vi(xE);function SE({field:e,value:t,onChange:n,disabled:r}){return x(ax,{field:e,value:t,onChange:n,disabled:r})}var CE={"model-selector":SE};function wE({children:e}){let{t}=J(),{user:n,logout:r}=yb(),[i,a]=w(0),o=p(n?.username??null);S(()=>{let e=n?.username??null;e!==o.current&&(o.current=e,vy(),a(e=>e+1))},[n]);let c=m(()=>_y(),[i]),l=b(()=>{_y().reconnect(),a(e=>e+1),xE.invalidateQueries()},[]);Mx(b(()=>Ly(l),[l])),S(()=>Ny(()=>{_y().isSocketTokenStale()&&l()}),[l]);let u=b(async()=>{let e=await Ry();return e&&l(),e},[l]),{bootReady:d,bootError:f}=Ax(c,n??null,r,u);return x(Dx,{children:x(Ue,{system:c,children:x(da.Provider,{client:c.trpcClient,queryClient:xE,children:s(Mi,{children:[x(Fr,{children:x(ji,{children:x(pr,{children:d?e:x(TE,{})})})}),d&&x(dx,{}),f!==null&&d&&s(`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:`),` `,f,`. Retrying in background.`]})]})})})})}function TE(){let{t:e}=J();return x(`div`,{className:`flex min-h-screen items-center justify-center bg-background`,children:s(`div`,{className:`flex items-center gap-3 text-sm text-foreground-subtle`,children:[x(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`}),e(`app.connecting`,`Connecting…`)]})})}function EE(){return x(`div`,{className:`flex min-h-screen items-center justify-center bg-background`,children:x(`span`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-primary/30 border-t-primary`})})}function DE(){return S(()=>Aw(),[]),x(bi,{defaultMode:`dark`,children:x(Xr,{children:x(F,{client:xE,children:x(vb,{children:x(wE,{children:x(Ge,{children:x(ux,{children:x(ka,{renderers:CE,children:s(Fa,{picker:hv,children:[x(Hl,{basename:at(),children:x($b,{children:x(y,{fallback:x(EE,{}),children:s($c,{children:[x(Q,{path:`/login`,element:x(RT,{})}),x(Q,{path:`/admin/*`,element:x(VT,{})}),x(Q,{path:`/admin`,element:x(VT,{})}),x(Q,{path:`/change-password`,element:x($,{children:x(aT,{})})}),x(Q,{path:`/approve`,element:x($,{children:x($w,{})})}),x(Q,{path:`/showroom`,element:x(ZT,{})}),x(Q,{path:`/embed/player`,element:x(QT,{})}),x(Q,{path:`/embed/device/:deviceId`,element:x($,{children:x($T,{})})}),s(Q,{element:x($,{children:x(D_,{children:x(_w,{})})}),children:[x(Q,{index:!0,element:x(GT,{})}),x(Q,{path:`/access-denied`,element:x(jw,{})}),x(Q,{path:`/dashboard`,element:x(Z,{to:`/devices`,replace:!0})}),x(Q,{path:`/devices`,element:x(KT,{})}),x(Q,{path:`/cameras`,element:x(Z,{to:`/devices`,replace:!0})}),x(Q,{path:`/integrations`,element:x(qT,{})}),x(Q,{path:`/integrations/:addonId`,element:x(JT,{})}),x(Q,{path:`/system/pipeline`,element:x(uS,{path:`/system/pipeline`,children:x(YT,{})})}),x(Q,{path:`/pipeline`,element:x(Z,{to:`/system/pipeline`,replace:!0})}),x(Q,{path:`/live`,element:x(nE,{})}),x(Q,{path:`/devices/:deviceId`,element:x(XT,{})}),x(Q,{path:`/system/logs`,element:x($,{requireAdmin:!0,children:x(lE,{})})}),x(Q,{path:`/system/addons`,element:x($,{requireAdmin:!0,children:x(oE,{})})}),x(Q,{path:`/system/ai`,element:x($,{requireAdmin:!0,children:x(sE,{})})}),x(Q,{path:`/system/settings`,element:x($,{requireAdmin:!0,children:x(hE,{})})}),x(Q,{path:`/system/nodes`,element:x($,{requireAdmin:!0,children:x(gE,{})})}),x(Q,{path:`/system/notifications`,element:x($,{requireAdmin:!0,children:x(vE,{})})}),x(Q,{path:`/system/history`,element:x($,{requireAdmin:!0,children:x(yE,{})})}),x(Q,{path:`/system/calendars`,element:x($,{requireAdmin:!0,children:x(bE,{})})}),x(Q,{path:`/system/templates`,element:x(BT,{})}),x(Q,{path:`/system/identity`,element:x($,{requireAdmin:!0,children:x(uE,{})})}),x(Q,{path:`/system/my-access`,element:x(cE,{})}),x(Q,{path:`/system/network`,element:x($,{requireAdmin:!0,children:x(dE,{})})}),x(Q,{path:`/training/providers`,element:x($,{requireAdmin:!0,children:x(pE,{})})}),x(Q,{path:`/system/integrations`,element:x($,{requireAdmin:!0,children:x(fE,{})})}),x(Q,{path:`/system/data`,element:x($,{requireAdmin:!0,children:x(mE,{})})}),x(Q,{path:`/system`,element:x(Z,{to:mx,replace:!0})}),x(Q,{path:`/system/terminal/:nodeId/*`,element:x(UT,{})}),x(Q,{path:`/system/terminal`,element:x($,{requireAdmin:!0,children:x(_E,{})})}),x(Q,{path:vx,element:x(xx,{})}),hx.map(e=>x(Q,{path:e.path,element:x(bx,{tab:e.tab})},e.path)),x(Q,{path:`/system/users`,element:x(Z,{to:`/system/identity?tab=users`,replace:!0})}),x(Q,{path:`/system/api-keys`,element:x(Z,{to:`/system/identity?tab=api-keys`,replace:!0})}),x(Q,{path:`/system/authentication`,element:x(Z,{to:Cw(`authentication`),replace:!0})}),x(Q,{path:`/system/linked-sessions`,element:x(Z,{to:`/system/identity?tab=linked-sessions`,replace:!0})}),x(Q,{path:`/system/remote-access`,element:x(Z,{to:Cw(`remoteAccess`),replace:!0})}),x(Q,{path:`/system/turn`,element:x(Z,{to:Cw(`turn`),replace:!0})}),x(Q,{path:`/system/storage`,element:x(Z,{to:`/system/data?tab=storage`,replace:!0})}),x(Q,{path:`/system/backup`,element:x(Z,{to:`/system/data?tab=backup`,replace:!0})}),x(Q,{path:`/library`,element:x($,{requireAdmin:!0,children:x(WT,{})})}),x(Q,{path:`/retrain`,element:x(Z,{to:`/addon/training`,replace:!0})}),x(Q,{path:`/archive`,element:x($,{requireAdmin:!0,children:x(tE,{})})}),x(Q,{path:`/archive/:deviceId`,element:x(HT,{})}),x(Q,{path:`/recordings`,element:x(HT,{})}),x(Q,{path:`/build`,element:x($,{requireAdmin:!0,children:x(rE,{})})}),x(Q,{path:FS,element:x($,{requireAdmin:!0,children:x(iE,{})})}),x(Q,{path:IS,element:x($,{requireAdmin:!0,children:x(iE,{})})}),x(Q,{path:`/locations`,element:x($,{requireAdmin:!0,children:x(aE,{})})}),x(Q,{path:`/automation`,element:x(ox,{to:`/build`})}),x(Q,{path:`/addon/:pagePath`,element:x($,{requireAdmin:!0,children:x(nS,{})})}),x(Q,{path:`*`,element:x(Z,{to:`/devices`,replace:!0})})]})]})})})}),x(wx,{}),x(Lo,{})]})})})})})})})})})}O(),window.__camstackUiLibrary=ta,window.__camstackSdk=Sa,window.__camstackTypes=Bn;var OE=Ba(document.getElementById(`root`));eo(window.location.pathname,at())?NT(OE):OE.render(x(T,{children:x(DE,{})}));export{fv as $,fp as $n,bd as $r,Bm as $t,mx as A,Bo as Ai,Hp as An,yf as Ar,jg as At,Sb as B,jp as Bn,rf as Br,oh as Bt,kS as C,Ko as Ci,Up as Cn,lf as Cr,yg as Ct,cS as D,Yo as Di,Lp as Dn,Xd as Dr,tg as Dt,ES as E,Jo as Ei,Yp as En,Cf as Er,Ag as Et,Nb as F,Ap as Fn,Yd as Fr,Pg as Ft,Yv as G,Sp as Gn,ff as Gr,Gm as Gt,yb as H,pp as Hn,of as Hr,Hm as Ht,Eb as I,Cp as In,Zd as Ir,Dh as It,Dv as J,_p as Jn,Kd as Jr,Vm as Jt,Pv as K,hp as Kn,uf as Kr,Lm as Kt,Db as L,wp as Ln,Qd as Lr,Th as Lt,lx as M,Fp as Mn,Ud as Mr,fg as Mt,Zb as N,qp as Nn,Wd as Nr,sg as Nt,Ex as O,Ro as Oi,Jp as On,_f as Or,Qh as Ot,Fb as P,$p as Pn,wf as Pr,dg as Pt,vv as Q,$f as Qn,Td as Qr,zm as Qt,kb as R,Dp as Rn,mf as Rr,Ch as Rt,AS as S,Ql as Si,im as Sn,Vd as Sr,Fg as St,TS as T,qo as Ti,Rp as Tn,gf as Tr,_g as Tt,Ey as U,xp as Un,Gd as Ur,Rm as Ut,xb as V,Op as Vn,cf as Vr,Xm as Vt,Xv as W,bp as Wn,qd as Wr,Qm as Wt,Sv as X,gp as Xn,Ld as Xr,Zm as Xt,Cv as Y,vp as Yn,zd as Yr,Jm as Yt,xv as Z,cp as Zn,Pd as Zr,eh as Zt,PS as _,Wl as _i,lm as _n,pf as _r,a_ as _t,xw as a,xd as ai,km as an,tp as ar,L_ as at,US as b,wc as bi,Pp as bn,tf as br,zg as bt,Cw as c,Sd as ci,Tm as cn,np as cr,P_ as ct,dC as d,Ed as di,cm as dn,Mf as dr,v_ as dt,hd as ei,Wm as en,lp as er,Q_ as et,cC as f,Ad as fi,mm as fn,Nf as fr,__ as ft,HS as g,Mu as gi,hm as gn,If as gr,o_ as gt,VS as h,Ru as hi,om as hn,Lf as hr,i_ as ht,bw as i,wd as ii,Nm as in,Qf as ir,K_ as it,yx as j,zo as ji,Wp as jn,nf as jr,gg as jt,Tx as k,Vo as ki,Gp as kn,hf as kr,lg as kt,ww as l,yd as li,bm as ln,rp as lr,O_ as lt,LS as m,Fu as mi,dm as mn,Ff as mr,h_ as mt,qw as n,_d as ni,Am as nn,up as nr,q_ as nt,vw as o,Cd as oi,Dm as on,Jf as or,I_ as ot,lC as p,kd as pi,pm as pn,Vf as pr,p_ as pt,wv as q,yp as qn,vf as qr,Im as qt,Sw as r,vd as ri,jm as rn,dp as rr,W_ as rt,yw as s,Od as si,Em as sn,Kf as sr,F_ as st,Zw as t,Dd as ti,Mm as tn,ap as tr,Z_ as tt,Tw as u,gd as ui,sm as un,Rf as ur,y_ as ut,zS as v,Z as vi,um as vn,Tf as vr,r_ as vt,MS as w,Go as wi,Vp as wn,df as wr,vg as wt,NS as x,Oc as xi,Zp as xn,af as xr,Bg as xt,RS as y,X as yi,Np as yn,sf as yr,Yg as yt,Cb as z,kp as zn,Ef as zr,Sh as zt};
|