@camstack/addon-admin-ui 1.2.622 → 1.2.623
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 +6 -0
- package/dist/assets/{Addons-B0-JHWDN.js → Addons-KzL11keT.js} +1 -1
- package/dist/assets/{AdminPage-C6Nfjqwk.js → AdminPage-CLrZRo9Q.js} +1 -1
- package/dist/assets/{AdminSectionedPage-qDgtM4yK.js → AdminSectionedPage-QZujp_Rk.js} +1 -1
- package/dist/assets/{AiProfiles-BuQvWBCk.js → AiProfiles-CJymDhUN.js} +1 -1
- package/dist/assets/{Authentication-BgS7NhZX.js → Authentication-JPI5tNQR.js} +1 -1
- package/dist/assets/{Build-Blu_Rek1.js → Build-JfcMscnG.js} +1 -1
- package/dist/assets/{Calendars-D1HqtZRO.js → Calendars-C9ZSLbHl.js} +1 -1
- package/dist/assets/{CameraGrids-CTVWt5In.js → CameraGrids-CPw3_tbn.js} +1 -1
- package/dist/assets/{Cluster-CiamsdEf.js → Cluster-B5g_W7EV.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-C-77HSpC.js → CompositionBlockEditor-DFvE9jtV.js} +1 -1
- package/dist/assets/{CompositionEditorPage-2bkol2ck.js → CompositionEditorPage-C4jc1B6k.js} +1 -1
- package/dist/assets/{Data-BKLSNpfc.js → Data-DUlmeoKU.js} +1 -1
- package/dist/assets/{DeviceDetail-GJkHbY0h.js → DeviceDetail-CWLf4l8q.js} +1 -1
- package/dist/assets/{DeviceDoActionFields-DeEzCG7W.js → DeviceDoActionFields-xv3Yexk0.js} +1 -1
- package/dist/assets/{Devices-DnnB5-0E.js → Devices-Bc4BHwpe.js} +1 -1
- package/dist/assets/{EditTemplateButton-BhYRcPAZ.js → EditTemplateButton-BqvyA5Pg.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-Fv2jvgXD.js → EmbedPlayerPage-D_hbiDn0.js} +1 -1
- package/dist/assets/{History-sL1i9hpN.js → History-pMj6FeqQ.js} +1 -1
- package/dist/assets/{Identity-DWLT_K89.js → Identity-DxoiP6P_.js} +1 -1
- package/dist/assets/{InstancesTable-Bd3Q_rDK.js → InstancesTable-CrMiPOFq.js} +1 -1
- package/dist/assets/{IntegrationDetail-Culq1Ni9.js → IntegrationDetail-CUUOhCzq.js} +1 -1
- package/dist/assets/{IntegrationHub-dC2c-gZh.js → IntegrationHub-vGZZvN9Y.js} +1 -1
- package/dist/assets/{Integrations-BSA9HPyd.js → Integrations-DIgPCmCb.js} +1 -1
- package/dist/assets/{Integrations-B1KxBrwc.js → Integrations-NjDYWDHO.js} +1 -1
- package/dist/assets/{Library-CDrsfdbN.js → Library-Bl_xkCam.js} +1 -1
- package/dist/assets/{Locations-8ETbKpeR.js → Locations-CcTd8h93.js} +1 -1
- package/dist/assets/{Logs-DaigxSX8.js → Logs-CdgFEAUx.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-CWvoDF7d.js → MaskShapeCanvas-BLVQpjX5.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BGdLFhDm.js → MotionZonesSettings-4zZUDnfh.js} +1 -1
- package/dist/assets/{MyAccess-yDg5ZUb3.js → MyAccess-DAZSxq6w.js} +1 -1
- package/dist/assets/{Network-4RdFqBxG.js → Network-LqpZJtlD.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-IP_pDLF5.js → NodeAddonsSettingsPanel-D9kXGkje.js} +1 -1
- package/dist/assets/{Notifications-nPHvnL47.js → Notifications-BtvOosgt.js} +1 -1
- package/dist/assets/{Pipeline-DrZixiLL.js → Pipeline-DdsVy_AV.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-DaxBCWbY.js → PrivacyMaskSettings-1aaAaXXs.js} +1 -1
- package/dist/assets/{Recordings-xllrAH4z.js → Recordings-Qtccm3Yn.js} +1 -1
- package/dist/assets/{ScanSubnetEditor-CRSiRPeu.js → ScanSubnetEditor-t8MFwLUw.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-DGT86wag.js → SceneMonitorEditor-DQtQEj4e.js} +1 -1
- package/dist/assets/{SessionsList-Dsi9j6a5.js → SessionsList-B2cVisrj.js} +1 -1
- package/dist/assets/{Showroom-Cy61Met3.js → Showroom-TwupeRdK.js} +1 -1
- package/dist/assets/{StorageLocationsTable-BIWNuKSZ.js → StorageLocationsTable-CcXglcoI.js} +1 -1
- package/dist/assets/{System-IFiHQlVG.js → System-yvxoK1-C.js} +1 -1
- package/dist/assets/{Templates-CI8sfkWl.js → Templates-C4mFSZiC.js} +1 -1
- package/dist/assets/{Terminal-CLVwElWa.js → Terminal-CCImGxuy.js} +1 -1
- package/dist/assets/{TrainingProviders-CGnhynXm.js → TrainingProviders-B4mcZKfz.js} +1 -1
- package/dist/assets/{Viewer-DAzWPu1t.js → Viewer-B_9mn9kj.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C0elo_dQ.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BLj3clZf.js} +1 -1
- package/dist/assets/{addon-icons-context-DqoJ5IMg.js → addon-icons-context-C_8qaE3G.js} +1 -1
- package/dist/assets/{archive-BeVgBgkN.js → archive-C3vMcjeD.js} +1 -1
- package/dist/assets/{assignment-candidates-D8UC0IoK.js → assignment-candidates-BuIx_7M-.js} +1 -1
- package/dist/assets/{authed-media-C4mHNO6d.js → authed-media-DMusU87j.js} +1 -1
- package/dist/assets/{bell-off-DkGKDKAc.js → bell-off-CY2cs307.js} +1 -1
- package/dist/assets/{boxes-BPVZkV90.js → boxes-DKifHkk7.js} +1 -1
- package/dist/assets/{calendar-clock-CjQG8xEz.js → calendar-clock-DDLq2ake.js} +1 -1
- package/dist/assets/circle-slash-D9aFPEN1.js +1 -0
- package/dist/assets/client-DRdJu8dM.js +809 -0
- package/dist/assets/{create-composition-mIiTaJQn.js → create-composition-SYDEmWRj.js} +1 -1
- package/dist/assets/crop-D1nLFU4t.js +1 -0
- package/dist/assets/{database-zap-BuOgAYwR.js → database-zap-Dhs7epvK.js} +1 -1
- package/dist/assets/{device-integration-icon-BiD2ooYo.js → device-integration-icon-CQA-gqJ3.js} +1 -1
- package/dist/assets/device-picker-model-CgDeVP8s.js +1 -0
- package/dist/assets/{dist-CVgm2V5y.js → dist-DhVqbh46.js} +1 -1
- package/dist/assets/dist-UQng_ywA.js +809 -0
- package/dist/assets/{eraser-UP1ptJ_D.js → eraser-BXrd43PO.js} +1 -1
- package/dist/assets/{file-up-BejsNlHS.js → file-up-C4GXJyov.js} +1 -1
- package/dist/assets/{grip-vertical-DotKiQvj.js → grip-vertical-C9DzhrBS.js} +1 -1
- package/dist/assets/{hard-drive-download-_b0JXZNX.js → hard-drive-download-CZYdVqd_.js} +1 -1
- package/dist/assets/{hostInit-CWlv6NTe.js → hostInit-C49TaBck.js} +1 -1
- package/dist/assets/{icons-DiWpMBOB.js → icons-Ud0oSLOy.js} +1 -1
- package/dist/assets/{index-CrUUqNNL.js → index-BCCGVD9f.js} +3 -3
- package/dist/assets/{key-DRR-Ggvt.js → key-2bnMZjKx.js} +1 -1
- package/dist/assets/{key-square-BlorbeI7.js → key-square-DcGB0_0B.js} +1 -1
- package/dist/assets/{layers-DQIEg2Bq.js → layers-1dZdqzsn.js} +1 -1
- package/dist/assets/{link-2-off-HbwYwcoz.js → link-2-off-DHNm-mat.js} +1 -1
- package/dist/assets/{linked-devices-model-oxPM2lDe.js → linked-devices-model-o0v4Bm2S.js} +1 -1
- package/dist/assets/{list-ordered-D2_q30rO.js → list-ordered-DS1i0RJW.js} +1 -1
- package/dist/assets/{memory-stick-Kr65AHO7.js → memory-stick-uePzeBGn.js} +1 -1
- package/dist/assets/{message-square-plus-CGcfLb4n.js → message-square-plus-CCwZJhae.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-aafe4c56.js → mf-entry-bootstrap-0-a9d1f756.js} +2 -2
- package/dist/assets/{mic-off-B-YLSqUh.js → mic-off-BCSgetxJ.js} +1 -1
- package/dist/assets/{monitor-off-dhLiqvAE.js → monitor-off-CS4v-A38.js} +1 -1
- package/dist/assets/{monitor-smartphone-D68gh_0x.js → monitor-smartphone-Dd7prEi4.js} +1 -1
- package/dist/assets/mount-CgDeVP8s.js +1 -0
- package/dist/assets/{player-overlays-DRXPDzoq.js → player-overlays-oE7aPZdg.js} +1 -1
- package/dist/assets/remoteEntry-C7_kKwaq.js +1 -0
- package/dist/assets/{ruler-CE2hOxvv.js → ruler-BkEZ6CMq.js} +1 -1
- package/dist/assets/{scissors-BOlEHQ2s.js → scissors-Dtc0iZPF.js} +1 -1
- package/dist/assets/{search-x-Basn6vad.js → search-x-C7zLOTi7.js} +1 -1
- package/dist/assets/{send-snsa07qR.js → send-BA_OtGrV.js} +1 -1
- package/dist/assets/{settings-2-D42zZvIi.js → settings-2-BzcfNdMc.js} +1 -1
- package/dist/assets/{shapes-DzuZ0aqU.js → shapes-CaybZ7kz.js} +1 -1
- package/dist/assets/{sigma-BRwCaWxw.js → sigma-DFDTfJlI.js} +1 -1
- package/dist/assets/{speaker-Oma9Nd4V.js → speaker-PGSeODKI.js} +1 -1
- package/dist/assets/{src-CrkcMdUT.js → src-CCPnH3Vz.js} +3 -3
- package/dist/assets/{step-inspector-model-Qusf3gxD.js → step-inspector-model-B1Tuq6co.js} +1 -1
- package/dist/assets/{table-2-CLSgkWSh.js → table-2-B1IGjGV3.js} +1 -1
- package/dist/assets/{timer-reset-XJzcf-X9.js → timer-reset-BePL4KnU.js} +1 -1
- package/dist/assets/{tv-DHoz7k2K.js → tv-Be97KtJK.js} +1 -1
- package/dist/assets/{unlink-TvpkDUay.js → unlink-WMRglu7x.js} +1 -1
- package/dist/assets/{usb-CYYF7-XT.js → usb-DELsHf1A.js} +1 -1
- package/dist/assets/{use-device-bound-caps-BmCkwmRR.js → use-device-bound-caps-Ci1qRqfj.js} +1 -1
- package/dist/assets/{use-scenes-feed-B68kNFHc.js → use-scenes-feed-CSRDiXlC.js} +1 -1
- package/dist/assets/{use-stationary-objects-DMEbWObh.js → use-stationary-objects-C4uhF0Lo.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-B9K8nXpf.js → useAdminDeviceRemoval-C5k2S_qW.js} +1 -1
- package/dist/assets/useEventInvalidation-CgDeVP8s.js +1 -0
- package/dist/assets/{useNodeUrlSelection-Be7DWORE.js → useNodeUrlSelection-CgRrxNd2.js} +1 -1
- package/dist/assets/user-round-DJFBqcFq.js +1 -0
- package/dist/assets/{user-x-B8bBQJXA.js → user-x-DARSMBU3.js} +1 -1
- package/dist/assets/{variable-BrE4WL4D.js → variable-BCL__P0T.js} +1 -1
- package/dist/assets/{video-BM2xBahl.js → video-B38E1osq.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-B08zgLKv.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Bkkm-53n.js} +2 -2
- package/dist/index.html +8 -8
- package/dist/server/addon.js +5888 -3427
- package/package.json +2 -2
- package/dist/assets/circle-slash-CGfofQoY.js +0 -1
- package/dist/assets/client-Dee-0euI.js +0 -809
- package/dist/assets/crop-B2RwKMNG.js +0 -1
- package/dist/assets/device-picker-model-CEFYlq6I.js +0 -1
- package/dist/assets/dist-DbWYJIOK.js +0 -809
- package/dist/assets/mount-CEFYlq6I.js +0 -1
- package/dist/assets/remoteEntry-BClVE4J6.js +0 -1
- package/dist/assets/useEventInvalidation-CEFYlq6I.js +0 -1
- package/dist/assets/user-round-JSt6qUOY.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-
|
|
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_-B08zgLKv.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{$n as ee,$r as R,Br as te,Cn as ne,Cr as re,Di as ie,Ei as ae,Er as oe,Et as se,Fn as z,Gi as B,Hn as V,Hr as ce,Ii as le,Ki as ue,Kt as de,Li as fe,Mr as pe,Ni as me,Or as he,Pi as ge,Pn as _e,Q as H,Qr as ve,Rr as ye,Sn as be,T as xe,Un as Se,Ut as Ce,Vi as we,Vr as Te,Wi as Ee,Yr as De,Z as Oe,Zi as ke,_a as Ae,_r as je,br as U,bt as Me,ci as Ne,ct as Pe,dt as Fe,ei as Ie,fr as Le,gn as Re,ha as ze,hr as Be,ht as W,it as Ve,ki as He,ln as Ue,nn as We,or as Ge,pt as Ke,ra as qe,rt as Je,sn as Ye,ua as Xe,ui as Ze,ur as Qe,ut as $e,vn as et,wn as tt,wt as nt,xi as rt,xn as it,xt as at,yt as ot,zn as st}from"./player-overlays-DRXPDzoq.js";import{Ao as ct,At as lt,B as ut,Bo as dt,Dt as ft,Et as pt,F as mt,Gt as ht,H as gt,Hr as _t,Ht as vt,I as yt,It as bt,Jt as xt,Kt as St,L as Ct,Lt as wt,M as Tt,N as Et,No as Dt,Nt as Ot,O as kt,Or as At,P as jt,Pt as Mt,Q as Nt,R as Pt,Ss as Ft,St as It,Tt as Lt,U as Rt,Ur as zt,Ut as Bt,V as Vt,Wr as Ht,Wt as Ut,Xt as Wt,Yt as Gt,Z as Kt,Zt as qt,_t as Jt,bt as Yt,gt as Xt,ht as Zt,i as Qt,j as $t,jt as en,kt as tn,ls as nn,o as rn,qt as an,r as on,s as sn,t as cn,vt as ln,xi as un,xt as dn,yt as fn,z as pn,zt as mn}from"./client-Dee-0euI.js";import{_ as hn,a as gn,c as _n,d as vn,f as yn,g as bn,h as xn,i as Sn,l as Cn,m as wn,n as Tn,o as En,p as Dn,r as On,s as kn,t as An,u as jn,v as Mn,y as Nn}from"./video-BM2xBahl.js";import{Af as Pn,Br as Fn,C as In,Ca as Ln,Cn as Rn,Cr as zn,Di as Bn,Dr as Vn,Dt as Hn,Ea as Un,En as Wn,Ff as Gn,Fr as Kn,Ft as qn,Gi as Jn,Go as Yn,Gt as Xn,Ho as Zn,Ir as Qn,Ld as $n,Lr as er,Mr as tr,Ms as nr,Of as rr,On as ir,Or as ar,Pf as or,Pr as sr,Qr as cr,Ro as lr,Rr as ur,Sa as dr,Sf as fr,Si as pr,Sn as mr,Ta as hr,Vo as gr,Vr as _r,Xr as vr,Yr as yr,Z as br,Zr as xr,Zs as Sr,Zt as Cr,_f as wr,_i as Tr,a as Er,an as Dr,ar as Or,bi as kr,bn as Ar,bs as jr,cf as Mr,ci as Nr,cr as Pr,cs as Fr,en as Ir,er as Lr,fi as Rr,fu as zr,gf as Br,gi as Vr,gs as Hr,h as Ur,hd as Wr,hf as Gr,hi as Kr,hs as qr,i as Jr,ii as Yr,ir as Xr,jn as Zr,jr as Qr,k as $r,kr as ei,kt as ti,li as ni,ls as ri,md as ii,mf as ai,mi as oi,ms as si,mu as ci,n as li,na as ui,nf as di,nn as fi,oa as pi,oi as mi,p as hi,pf as gi,pi as _i,rn as vi,rr as yi,rt as bi,sa as xi,sf as G,tf as Si,tr as Ci,ua as wi,uc as Ti,ui as Ei,ur as Di,us as Oi,vi as ki,wa as Ai,wf as ji,wi as Mi,wn as Ni,ws as Pi,xd as Fi,xn as Ii,xs as Li,y as Ri,yi as K,yn as zi,zo as Bi,zr as Vi}from"./src-CrkcMdUT.js";import{r as Hi,t as Ui}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js";import{t as Wi}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js";import{n as Gi,t as q}from"./i18n-DFz3VmFc.js";import{a as Ki,c as qi,i as Ji,l as Yi,n as Xi,o as Zi,s as Qi,t as J,u as $i}from"./useTranslation-BJr-n0es.js";import"./mount-CEFYlq6I.js";import{a as ea,c as ta,d as na,i as ra,n as ia,o as aa,r as oa,s as sa,t as ca,u as la}from"./sso-popup-Cs85_JEB.js";import{n as ua,t as da}from"./addon-icons-context-DqoJ5IMg.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(),Hi();var fa=`camstack.debugLayers`,pa=/(transform|opacity|filter|perspective)/;function ma(e){return e!==``&&e!==`none`}function ha(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`),(ma(e.backdropFilter)||ma(e.webkitBackdropFilter))&&r.push(`backdrop-filter`),ma(e.filter)&&r.push(`filter`);let i=Number.parseFloat(e.opacity);return Number.isFinite(i)&&i<1&&r.push(`opacity`),ma(e.transform)&&r.push(`transform`),ma(e.perspective)&&r.push(`perspective`),e.isolation===`isolate`&&r.push(`isolation`),e.mixBlendMode!==``&&e.mixBlendMode!==`normal`&&r.push(`mix-blend-mode`),pa.test(e.willChange)&&r.push(`will-change`),r.length===0?null:{reasons:r,zIndex:e.zIndex}}function ga(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 _a(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 va=`camstack.debugLayers.noBlur`,ya=`camstack.debugLayers.outlines`,ba=`camstack.debugLayers.topLayer`,xa=`debug-no-backdrop-blur`;function Sa(e,t){try{return e===null?null:e.getItem(t)}catch{return null}}function Ca(e,t,n){try{if(e===null)return;n===null?e.removeItem(t):e.setItem(t,n)}catch{}}function wa(e,t){let n=_a(t,Sa(e,fa));n.persist!==`keep`&&Ca(e,fa,n.persist);let r={on:n.on,noBlur:Sa(e,va)===`1`,outlines:Sa(e,ya)!==`0`,topLayer:Sa(e,ba)!==`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(Ca(e,fa,t?`1`:null),!t){Ca(e,va,null),Ca(e,ya,null),Ca(e,ba,null),a({on:t,noBlur:!1,outlines:!0,topLayer:!0});return}a({...r,on:t})},setNoBlur:t=>{Ca(e,va,t?`1`:null),a({...r,noBlur:t})},setOutlines:t=>{Ca(e,ya,t?null:`0`),a({...r,outlines:t})},setTopLayer:t=>{Ca(e,ba,t?null:`0`),a({...r,topLayer:t})}}}var Ta=[`transform`,`will-change`,`position`,`backdrop-filter`,`filter`,`opacity`];function Ea(e){return Ta.map(t=>`${t}: ${e===null?`n/a`:e(t)||`-`}`)}var Da=null;function Oa(){try{return window.sessionStorage}catch{return null}}function ka(){return Da===null&&(Da=wa(Oa(),window.location.search)),Da}function Aa(){let e=ka();return{...C(e.subscribe,e.getState),setOn:e.setOn,setNoBlur:e.setNoBlur,setOutlines:e.setOutlines,setTopLayer:e.setTopLayer}}O();var ja=`data-debug-layers`,Ma=250,Na=60;function Pa(){let e=[],t=document.body.querySelectorAll(`*`);for(let n of Array.from(t)){if(e.length>=Na)break;if(n.closest(`[${ja}]`)!==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=ha({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:ga(n.tagName,typeof n.className==`string`?n.className:``,a===null?null:`data-testid=${a}`,i),reasons:i.reasons})}return e}function Fa(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 Ia(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 La(){let e=Reflect.get(navigator,`standalone`);return window.matchMedia(`(display-mode: standalone)`).matches||e===!0}function Ra(){return`1.2.622`}function za(e,t){if(!(e===null||typeof e.showPopover!=`function`))try{e.matches(`:popover-open`)&&e.hidePopover(),t&&e.showPopover()}catch{}}function Ba(){let e=document.querySelector(`[data-debug-header]`),t=e===null?null:e.querySelector(`img`),n=e=>Ea(e===null?null:t=>getComputedStyle(e).getPropertyValue(t));return{header:n(e),logo:n(t)}}function Va({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(Ba),_=b(()=>{za(f.current,i),c(n?Pa():[]),g(Ba()),d.current!==null&&u(Fa(d.current))},[n,i]),v=b(()=>{m.current===null&&(m.current=window.setTimeout(()=>{m.current=null,_()},Ma))},[_]);return S(()=>{_();let e=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.closest(`[${ja}]`)!==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]),Ui(s(`div`,{[ja]:``,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=Ia(e.reasons);return x(`div`,{"data-testid":`debug-layer-box`,className:Fe(`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:Fe(`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 `,Ra()]}),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: `,La()?`yes`:`no`]}),s(`div`,{children:[window.innerWidth,`x`,window.innerHeight,` · `,o.length,` layers`]}),x(Or,{checked:e,onCheckedChange:t,label:`no backdrop blur`,className:`pointer-events-auto mt-1 text-[10px]`}),x(Or,{checked:n,onCheckedChange:r,label:`outlines`,className:`pointer-events-auto mt-1 text-[10px]`}),x(Or,{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 Ha(){let{on:e,noBlur:t,setNoBlur:n,outlines:r,setOutlines:i,topLayer:a,setTopLayer:o}=Aa();return S(()=>{let n=e&&t;return document.documentElement.classList.toggle(xa,n),()=>document.documentElement.classList.remove(xa)},[e,t]),e?x(Va,{noBlur:t,onNoBlurChange:n,outlines:r,onOutlinesChange:i,topLayer:a,onTopLayerChange:o}):null}O();var Ua=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Wa=/^[\\/]{2}/;function Ga(e,t){return t+e.replace(/\\/g,`/`)}var Ka=`popstate`;function qa(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function Ja(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return Qa(``,{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:$a(t)}return to(t,n,null,e)}function Y(e,t){if(e===!1||e==null)throw Error(t)}function Ya(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function Xa(){return Math.random().toString(36).substring(2,10)}function Za(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 Qa(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?eo(t):t,state:n,key:t&&t.key||r||Xa(),mask:i}}function $a({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 eo(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 to(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=qa(e)?e:Qa(h.location,e,t);n&&n(r,e),l=u()+1;let d=Za(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=qa(e)?e:Qa(h.location,e,t);n&&n(r,e),l=u();let i=Za(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 no(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(Ka,d),c=e,()=>{i.removeEventListener(Ka,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 no(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:$a(t);return i=i.replace(/ $/,`%20`),!n&&Wa.test(i)&&(i=r+i),new URL(i,r)}function ro(e,t,n=`/`){return io(e,t,n,!1)}function io(e,t,n,r,i){let a=To((typeof t==`string`?eo(t):t).pathname||`/`,n);if(a==null)return null;let o=i??oo(e),s=null,c=wo(a);for(let e=0;s==null&&e<o.length;++e)s=bo(o[e],c,r);return s}function ao(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 oo(e){let t=so(e);return lo(t),t}function so(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=No([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}".`),so(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:vo(l,e.index),routesMeta:u.map((e,t)=>{let[n,r]=Co(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 co(e.path))a(e,t,!0,n)}),t}function co(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=co(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 lo(e){e.sort((e,t)=>e.score===t.score?yo(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var uo=/^:[\w-]+$/,fo=3,po=2,mo=1,ho=10,go=-2,_o=e=>e===`*`;function vo(e,t){let n=e.split(`/`),r=n.length;return n.some(_o)&&(r+=go),t&&(r+=po),n.filter(e=>!_o(e)).reduce((e,t)=>e+(uo.test(t)?fo:t===``?mo:ho),r)}function yo(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 bo(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?So(u,l,s.matcher,s.compiledParams):xo(u,l),f=s.route;if(!d&&c&&n&&!r[r.length-1].route.index&&(d=xo({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!d)return null;Object.assign(i,d.params),o.push({params:i,pathname:No([a,d.pathname]),pathnameBase:Fo(No([a,d.pathnameBase])),route:f}),d.pathnameBase!==`/`&&(a=No([a,d.pathnameBase]))}return o}function xo(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Co(e.path,e.caseSensitive,e.end);return So(e,t,n,r)}function So(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 Co(e,t=!1,n=!0){Ya(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 wo(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return Ya(!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 To(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 Eo(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?eo(e):e,a;return n?(n=Mo(n),a=n.startsWith(`/`)?Do(n.substring(1),`/`):Do(n,t)):a=t,{pathname:a,search:Io(r),hash:Lo(i)}}function Do(e,t){let n=Po(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Oo(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 ko(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Ao(e){let t=ko(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function jo(e,t,n,r=!1){let i;typeof e==`string`?i=eo(e):(i={...e},Y(!i.pathname||!i.pathname.includes(`?`),Oo(`?`,`pathname`,`search`,i)),Y(!i.pathname||!i.pathname.includes(`#`),Oo(`#`,`pathname`,`hash`,i)),Y(!i.search||!i.search.includes(`#`),Oo(`#`,`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=Eo(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var Mo=e=>e.replace(/[\\/]{2,}/g,`/`),No=e=>Mo(e.join(`/`)),Po=e=>e.replace(/\/+$/,``),Fo=e=>Po(e).replace(/^\/*/,`/`),Io=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Lo=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,Ro=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 zo(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Bo(e){return No(e.map(e=>e.route.path).filter(Boolean))||`/`}var Vo=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Ho(e,t){let n=e;if(typeof n!=`string`||!Ua.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Vo)try{let e=new URL(window.location.href),r=Wa.test(n)?new URL(Ga(n,e.protocol)):new URL(n),a=To(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{Ya(!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 Uo=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Uo);var Wo=[`GET`,...Uo];new Set(Wo);var Go=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function Ko(e){try{return Go.includes(new URL(e).protocol)}catch{return!1}}var qo=j(null);qo.displayName=`DataRouter`;var Jo=j(null);Jo.displayName=`DataRouterState`;var Yo=j(!1);function Xo(){return L(Yo)}var Zo=j({isTransitioning:!1});Zo.displayName=`ViewTransition`;var Qo=j(new Map);Qo.displayName=`Fetchers`;var $o=j(null);$o.displayName=`Await`;var es=j(null);es.displayName=`Navigation`;var ts=j(null);ts.displayName=`Location`;var ns=j({outlet:null,matches:[],isDataRoute:!1});ns.displayName=`Route`;var rs=j(null);rs.displayName=`RouteError`;var is=`REACT_ROUTER_ERROR`,as=`REDIRECT`,os=`ROUTE_ERROR_RESPONSE`;function ss(e){if(e.startsWith(`${is}:${as}:{`))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 cs(e){if(e.startsWith(`${is}:${os}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new Ro(t.status,t.statusText,t.data)}catch{}}function ls(e,{relative:t}={}){Y(us(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=L(es),{hash:i,pathname:a,search:o}=ys(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:No([n,a])),r.createHref({pathname:s,search:o,hash:i})}function us(){return L(ts)!=null}function X(){return Y(us(),`useLocation() may be used only in the context of a <Router> component.`),L(ts).location}function ds(){return L(ts).navigationType}var fs=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function ps(e){L(es).static||u(e)}function ms(){let{isDataRoute:e}=L(ns);return e?Rs():hs()}function hs(){Y(us(),`useNavigate() may be used only in the context of a <Router> component.`);let e=L(qo),{basename:t,navigator:n}=L(es),{matches:r}=L(ns),{pathname:i}=X(),a=JSON.stringify(Ao(r)),o=p(!1);return ps(()=>{o.current=!0}),b((r,s={})=>{if(Ya(o.current,fs),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=jo(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:No([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var gs=j(null);function _s(e){let t=L(ns).outlet;return m(()=>t&&o(gs.Provider,{value:e},t),[t,e])}function vs(){let{matches:e}=L(ns);return e[e.length-1]?.params??{}}function ys(e,{relative:t}={}){let{matches:n}=L(ns),{pathname:r}=X(),i=JSON.stringify(Ao(n));return m(()=>jo(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function bs(e,t){return xs(e,t)}function xs(e,t,n){Y(us(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=L(es),{matches:i}=L(ns),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||``;Bs(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.
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-Bc4BHwpe.js","./src-CCPnH3Vz.js","./player-overlays-oE7aPZdg.js","./client-DRdJu8dM.js","./__vite-browser-external-BCAtXlNQ.js","./useTranslation-BJr-n0es.js","./AdminPage-CLrZRo9Q.js","./device-integration-icon-CQA-gqJ3.js","./useAdminDeviceRemoval-C5k2S_qW.js","./useEventInvalidation-CgDeVP8s.js","./addon-kind-filter-CEGKkC1O.js","./Integrations-DIgPCmCb.js","./i18n-DFz3VmFc.js","./table-2-B1IGjGV3.js","./ScanSubnetEditor-t8MFwLUw.js","./framework-packages-DoBKjjer.js","./IntegrationDetail-CUUOhCzq.js","./search-x-C7zLOTi7.js","./addon-icons-context-C_8qaE3G.js","./mount-CgDeVP8s.js","./Pipeline-DdsVy_AV.js","./video-B38E1osq.js","./usb-DELsHf1A.js","./crop-D1nLFU4t.js","./layers-1dZdqzsn.js","./NodeAddonsSettingsPanel-D9kXGkje.js","./step-inspector-model-B1Tuq6co.js","./board-model-D6ERqD8s.js","./DeviceDetail-CWLf4l8q.js","./archive-C3vMcjeD.js","./tv-Be97KtJK.js","./bell-off-CY2cs307.js","./sigma-DFDTfJlI.js","./boxes-DKifHkk7.js","./circle-slash-D9aFPEN1.js","./file-up-C4GXJyov.js","./EditTemplateButton-BqvyA5Pg.js","./grip-vertical-C9DzhrBS.js","./CompositionBlockEditor-DFvE9jtV.js","./use-device-bound-caps-Ci1qRqfj.js","./assignment-candidates-BuIx_7M-.js","./device-picker-model-CgDeVP8s.js","./create-composition-SYDEmWRj.js","./DeviceDoActionFields-xv3Yexk0.js","./format-DAm6he6w.js","./use-stationary-objects-C4uhF0Lo.js","./linked-devices-model-o0v4Bm2S.js","./authed-media-DMusU87j.js","./notification-rule-status-hT9lSvAp.js","./Showroom-TwupeRdK.js","./EmbedPlayerPage-D_hbiDn0.js","./Library-Bl_xkCam.js","./user-x-DARSMBU3.js","./user-round-DJFBqcFq.js","./AdminSectionedPage-QZujp_Rk.js","./use-scenes-feed-CSRDiXlC.js","./Recordings-Qtccm3Yn.js","./scissors-Dtc0iZPF.js","./StorageLocationsTable-CcXglcoI.js","./eraser-BXrd43PO.js","./hard-drive-download-CZYdVqd_.js","./InstancesTable-CrMiPOFq.js","./link-2-off-DHNm-mat.js","./format-size-DIxKXxtj.js","./Viewer-B_9mn9kj.js","./monitor-off-CS4v-A38.js","./Build-JfcMscnG.js","./calendar-clock-DDLq2ake.js","./variable-BCL__P0T.js","./CompositionEditorPage-C4jc1B6k.js","./Locations-CcTd8h93.js","./speaker-PGSeODKI.js","./Addons-KzL11keT.js","./useNodeUrlSelection-CgRrxNd2.js","./AiProfiles-CJymDhUN.js","./send-BA_OtGrV.js","./message-square-plus-CCwZJhae.js","./ai-page.helpers-zhKHU1bv.js","./MyAccess-DAZSxq6w.js","./monitor-smartphone-Dd7prEi4.js","./unlink-WMRglu7x.js","./SessionsList-B2cVisrj.js","./sso-popup-Cs85_JEB.js","./Logs-CdgFEAUx.js","./timer-reset-BePL4KnU.js","./Identity-DxoiP6P_.js","./key-2bnMZjKx.js","./IntegrationHub-vGZZvN9Y.js","./settings-2-BzcfNdMc.js","./Authentication-JPI5tNQR.js","./key-square-DcGB0_0B.js","./useInvalidateAddonSettings-CyofQfBo.js","./Network-LqpZJtlD.js","./Integrations-NjDYWDHO.js","./TrainingProviders-B4mcZKfz.js","./Data-DUlmeoKU.js","./database-zap-Dhs7epvK.js","./System-yvxoK1-C.js","./ruler-BkEZ6CMq.js","./Cluster-B5g_W7EV.js","./memory-stick-uePzeBGn.js","./CameraGrids-CPw3_tbn.js","./Terminal-CCImGxuy.js","./Terminal-kHJ-D0s7.css","./Notifications-BtvOosgt.js","./list-ordered-DS1i0RJW.js","./History-pMj6FeqQ.js","./Calendars-C9ZSLbHl.js","./Templates-C4mFSZiC.js","./shapes-CaybZ7kz.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_-Bkkm-53n.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{$n as ee,$r as R,Br as te,Cn as ne,Cr as re,Di as ie,Ei as ae,Er as oe,Et as se,Fn as z,Gi as B,Hn as V,Hr as ce,Ii as le,Ki as ue,Kt as de,Li as fe,Mr as pe,Ni as me,Or as he,Pi as ge,Pn as _e,Q as H,Qr as ve,Rr as ye,Sn as be,T as xe,Un as Se,Ut as Ce,Vi as we,Vr as Te,Wi as Ee,Yr as De,Z as Oe,Zi as ke,_a as Ae,_r as je,br as U,bt as Me,ci as Ne,ct as Pe,dt as Fe,ei as Ie,fr as Le,gn as Re,ha as ze,hr as Be,ht as W,it as Ve,ki as He,ln as Ue,nn as We,or as Ge,pt as Ke,ra as qe,rt as Je,sn as Ye,ua as Xe,ui as Ze,ur as Qe,ut as $e,vn as et,wn as tt,wt as nt,xi as rt,xn as it,xt as at,yt as ot,zn as st}from"./player-overlays-oE7aPZdg.js";import{Ao as ct,At as lt,B as ut,Bo as dt,Dt as ft,Et as pt,F as mt,Gt as ht,H as gt,Hr as _t,Ht as vt,I as yt,It as bt,Jt as xt,Kt as St,L as Ct,Lt as wt,M as Tt,N as Et,No as Dt,Nt as Ot,O as kt,Or as At,P as jt,Pt as Mt,Q as Nt,R as Pt,Ss as Ft,St as It,Tt as Lt,U as Rt,Ur as zt,Ut as Bt,V as Vt,Wr as Ht,Wt as Ut,Xt as Wt,Yt as Gt,Z as Kt,Zt as qt,_t as Jt,bt as Yt,gt as Xt,ht as Zt,i as Qt,j as $t,jt as en,kt as tn,ls as nn,o as rn,qt as an,r as on,s as sn,t as cn,vt as ln,xi as un,xt as dn,yt as fn,z as pn,zt as mn}from"./client-DRdJu8dM.js";import{_ as hn,a as gn,c as _n,d as vn,f as yn,g as bn,h as xn,i as Sn,l as Cn,m as wn,n as Tn,o as En,p as Dn,r as On,s as kn,t as An,u as jn,v as Mn,y as Nn}from"./video-B38E1osq.js";import{Af as Pn,Br as Fn,C as In,Ca as Ln,Cn as Rn,Cr as zn,Di as Bn,Dr as Vn,Dt as Hn,Ea as Un,En as Wn,Ff as Gn,Fr as Kn,Ft as qn,Gi as Jn,Go as Yn,Gt as Xn,Ho as Zn,Ir as Qn,Ld as $n,Lr as er,Mr as tr,Ms as nr,Of as rr,On as ir,Or as ar,Pf as or,Pr as sr,Qr as cr,Ro as lr,Rr as ur,Sa as dr,Sf as fr,Si as pr,Sn as mr,Ta as hr,Vo as gr,Vr as _r,Xr as vr,Yr as yr,Z as br,Zr as xr,Zs as Sr,Zt as Cr,_f as wr,_i as Tr,a as Er,an as Dr,ar as Or,bi as kr,bn as Ar,bs as jr,cf as Mr,ci as Nr,cr as Pr,cs as Fr,en as Ir,er as Lr,fi as Rr,fu as zr,gf as Br,gi as Vr,gs as Hr,h as Ur,hd as Wr,hf as Gr,hi as Kr,hs as qr,i as Jr,ii as Yr,ir as Xr,jn as Zr,jr as Qr,k as $r,kr as ei,kt as ti,li as ni,ls as ri,md as ii,mf as ai,mi as oi,ms as si,mu as ci,n as li,na as ui,nf as di,nn as fi,oa as pi,oi as mi,p as hi,pf as gi,pi as _i,rn as vi,rr as yi,rt as bi,sa as xi,sf as G,tf as Si,tr as Ci,ua as wi,uc as Ti,ui as Ei,ur as Di,us as Oi,vi as ki,wa as Ai,wf as ji,wi as Mi,wn as Ni,ws as Pi,xd as Fi,xn as Ii,xs as Li,y as Ri,yi as K,yn as zi,zo as Bi,zr as Vi}from"./src-CCPnH3Vz.js";import{r as Hi,t as Ui}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js";import{t as Wi}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js";import{n as Gi,t as q}from"./i18n-DFz3VmFc.js";import{a as Ki,c as qi,i as Ji,l as Yi,n as Xi,o as Zi,s as Qi,t as J,u as $i}from"./useTranslation-BJr-n0es.js";import"./mount-CgDeVP8s.js";import{a as ea,c as ta,d as na,i as ra,n as ia,o as aa,r as oa,s as sa,t as ca,u as la}from"./sso-popup-Cs85_JEB.js";import{n as ua,t as da}from"./addon-icons-context-C_8qaE3G.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(),Hi();var fa=`camstack.debugLayers`,pa=/(transform|opacity|filter|perspective)/;function ma(e){return e!==``&&e!==`none`}function ha(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`),(ma(e.backdropFilter)||ma(e.webkitBackdropFilter))&&r.push(`backdrop-filter`),ma(e.filter)&&r.push(`filter`);let i=Number.parseFloat(e.opacity);return Number.isFinite(i)&&i<1&&r.push(`opacity`),ma(e.transform)&&r.push(`transform`),ma(e.perspective)&&r.push(`perspective`),e.isolation===`isolate`&&r.push(`isolation`),e.mixBlendMode!==``&&e.mixBlendMode!==`normal`&&r.push(`mix-blend-mode`),pa.test(e.willChange)&&r.push(`will-change`),r.length===0?null:{reasons:r,zIndex:e.zIndex}}function ga(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 _a(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 va=`camstack.debugLayers.noBlur`,ya=`camstack.debugLayers.outlines`,ba=`camstack.debugLayers.topLayer`,xa=`debug-no-backdrop-blur`;function Sa(e,t){try{return e===null?null:e.getItem(t)}catch{return null}}function Ca(e,t,n){try{if(e===null)return;n===null?e.removeItem(t):e.setItem(t,n)}catch{}}function wa(e,t){let n=_a(t,Sa(e,fa));n.persist!==`keep`&&Ca(e,fa,n.persist);let r={on:n.on,noBlur:Sa(e,va)===`1`,outlines:Sa(e,ya)!==`0`,topLayer:Sa(e,ba)!==`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(Ca(e,fa,t?`1`:null),!t){Ca(e,va,null),Ca(e,ya,null),Ca(e,ba,null),a({on:t,noBlur:!1,outlines:!0,topLayer:!0});return}a({...r,on:t})},setNoBlur:t=>{Ca(e,va,t?`1`:null),a({...r,noBlur:t})},setOutlines:t=>{Ca(e,ya,t?null:`0`),a({...r,outlines:t})},setTopLayer:t=>{Ca(e,ba,t?null:`0`),a({...r,topLayer:t})}}}var Ta=[`transform`,`will-change`,`position`,`backdrop-filter`,`filter`,`opacity`];function Ea(e){return Ta.map(t=>`${t}: ${e===null?`n/a`:e(t)||`-`}`)}var Da=null;function Oa(){try{return window.sessionStorage}catch{return null}}function ka(){return Da===null&&(Da=wa(Oa(),window.location.search)),Da}function Aa(){let e=ka();return{...C(e.subscribe,e.getState),setOn:e.setOn,setNoBlur:e.setNoBlur,setOutlines:e.setOutlines,setTopLayer:e.setTopLayer}}O();var ja=`data-debug-layers`,Ma=250,Na=60;function Pa(){let e=[],t=document.body.querySelectorAll(`*`);for(let n of Array.from(t)){if(e.length>=Na)break;if(n.closest(`[${ja}]`)!==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=ha({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:ga(n.tagName,typeof n.className==`string`?n.className:``,a===null?null:`data-testid=${a}`,i),reasons:i.reasons})}return e}function Fa(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 Ia(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 La(){let e=Reflect.get(navigator,`standalone`);return window.matchMedia(`(display-mode: standalone)`).matches||e===!0}function Ra(){return`1.2.623`}function za(e,t){if(!(e===null||typeof e.showPopover!=`function`))try{e.matches(`:popover-open`)&&e.hidePopover(),t&&e.showPopover()}catch{}}function Ba(){let e=document.querySelector(`[data-debug-header]`),t=e===null?null:e.querySelector(`img`),n=e=>Ea(e===null?null:t=>getComputedStyle(e).getPropertyValue(t));return{header:n(e),logo:n(t)}}function Va({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(Ba),_=b(()=>{za(f.current,i),c(n?Pa():[]),g(Ba()),d.current!==null&&u(Fa(d.current))},[n,i]),v=b(()=>{m.current===null&&(m.current=window.setTimeout(()=>{m.current=null,_()},Ma))},[_]);return S(()=>{_();let e=new MutationObserver(e=>{e.some(e=>!(e.target instanceof Element&&e.target.closest(`[${ja}]`)!==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]),Ui(s(`div`,{[ja]:``,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=Ia(e.reasons);return x(`div`,{"data-testid":`debug-layer-box`,className:Fe(`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:Fe(`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 `,Ra()]}),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: `,La()?`yes`:`no`]}),s(`div`,{children:[window.innerWidth,`x`,window.innerHeight,` · `,o.length,` layers`]}),x(Or,{checked:e,onCheckedChange:t,label:`no backdrop blur`,className:`pointer-events-auto mt-1 text-[10px]`}),x(Or,{checked:n,onCheckedChange:r,label:`outlines`,className:`pointer-events-auto mt-1 text-[10px]`}),x(Or,{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 Ha(){let{on:e,noBlur:t,setNoBlur:n,outlines:r,setOutlines:i,topLayer:a,setTopLayer:o}=Aa();return S(()=>{let n=e&&t;return document.documentElement.classList.toggle(xa,n),()=>document.documentElement.classList.remove(xa)},[e,t]),e?x(Va,{noBlur:t,onNoBlurChange:n,outlines:r,onOutlinesChange:i,topLayer:a,onTopLayerChange:o}):null}O();var Ua=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Wa=/^[\\/]{2}/;function Ga(e,t){return t+e.replace(/\\/g,`/`)}var Ka=`popstate`;function qa(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function Ja(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return Qa(``,{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:$a(t)}return to(t,n,null,e)}function Y(e,t){if(e===!1||e==null)throw Error(t)}function Ya(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function Xa(){return Math.random().toString(36).substring(2,10)}function Za(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 Qa(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?eo(t):t,state:n,key:t&&t.key||r||Xa(),mask:i}}function $a({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 eo(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 to(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=qa(e)?e:Qa(h.location,e,t);n&&n(r,e),l=u()+1;let d=Za(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=qa(e)?e:Qa(h.location,e,t);n&&n(r,e),l=u();let i=Za(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 no(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(Ka,d),c=e,()=>{i.removeEventListener(Ka,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 no(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:$a(t);return i=i.replace(/ $/,`%20`),!n&&Wa.test(i)&&(i=r+i),new URL(i,r)}function ro(e,t,n=`/`){return io(e,t,n,!1)}function io(e,t,n,r,i){let a=To((typeof t==`string`?eo(t):t).pathname||`/`,n);if(a==null)return null;let o=i??oo(e),s=null,c=wo(a);for(let e=0;s==null&&e<o.length;++e)s=bo(o[e],c,r);return s}function ao(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 oo(e){let t=so(e);return lo(t),t}function so(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=No([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}".`),so(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:vo(l,e.index),routesMeta:u.map((e,t)=>{let[n,r]=Co(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 co(e.path))a(e,t,!0,n)}),t}function co(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=co(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 lo(e){e.sort((e,t)=>e.score===t.score?yo(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var uo=/^:[\w-]+$/,fo=3,po=2,mo=1,ho=10,go=-2,_o=e=>e===`*`;function vo(e,t){let n=e.split(`/`),r=n.length;return n.some(_o)&&(r+=go),t&&(r+=po),n.filter(e=>!_o(e)).reduce((e,t)=>e+(uo.test(t)?fo:t===``?mo:ho),r)}function yo(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 bo(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?So(u,l,s.matcher,s.compiledParams):xo(u,l),f=s.route;if(!d&&c&&n&&!r[r.length-1].route.index&&(d=xo({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!d)return null;Object.assign(i,d.params),o.push({params:i,pathname:No([a,d.pathname]),pathnameBase:Fo(No([a,d.pathnameBase])),route:f}),d.pathnameBase!==`/`&&(a=No([a,d.pathnameBase]))}return o}function xo(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Co(e.path,e.caseSensitive,e.end);return So(e,t,n,r)}function So(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 Co(e,t=!1,n=!0){Ya(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 wo(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return Ya(!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 To(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 Eo(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?eo(e):e,a;return n?(n=Mo(n),a=n.startsWith(`/`)?Do(n.substring(1),`/`):Do(n,t)):a=t,{pathname:a,search:Io(r),hash:Lo(i)}}function Do(e,t){let n=Po(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Oo(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 ko(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Ao(e){let t=ko(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function jo(e,t,n,r=!1){let i;typeof e==`string`?i=eo(e):(i={...e},Y(!i.pathname||!i.pathname.includes(`?`),Oo(`?`,`pathname`,`search`,i)),Y(!i.pathname||!i.pathname.includes(`#`),Oo(`#`,`pathname`,`hash`,i)),Y(!i.search||!i.search.includes(`#`),Oo(`#`,`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=Eo(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var Mo=e=>e.replace(/[\\/]{2,}/g,`/`),No=e=>Mo(e.join(`/`)),Po=e=>e.replace(/\/+$/,``),Fo=e=>Po(e).replace(/^\/*/,`/`),Io=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Lo=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,Ro=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 zo(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Bo(e){return No(e.map(e=>e.route.path).filter(Boolean))||`/`}var Vo=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Ho(e,t){let n=e;if(typeof n!=`string`||!Ua.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Vo)try{let e=new URL(window.location.href),r=Wa.test(n)?new URL(Ga(n,e.protocol)):new URL(n),a=To(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{Ya(!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 Uo=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Uo);var Wo=[`GET`,...Uo];new Set(Wo);var Go=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function Ko(e){try{return Go.includes(new URL(e).protocol)}catch{return!1}}var qo=j(null);qo.displayName=`DataRouter`;var Jo=j(null);Jo.displayName=`DataRouterState`;var Yo=j(!1);function Xo(){return L(Yo)}var Zo=j({isTransitioning:!1});Zo.displayName=`ViewTransition`;var Qo=j(new Map);Qo.displayName=`Fetchers`;var $o=j(null);$o.displayName=`Await`;var es=j(null);es.displayName=`Navigation`;var ts=j(null);ts.displayName=`Location`;var ns=j({outlet:null,matches:[],isDataRoute:!1});ns.displayName=`Route`;var rs=j(null);rs.displayName=`RouteError`;var is=`REACT_ROUTER_ERROR`,as=`REDIRECT`,os=`ROUTE_ERROR_RESPONSE`;function ss(e){if(e.startsWith(`${is}:${as}:{`))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 cs(e){if(e.startsWith(`${is}:${os}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new Ro(t.status,t.statusText,t.data)}catch{}}function ls(e,{relative:t}={}){Y(us(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=L(es),{hash:i,pathname:a,search:o}=ys(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:No([n,a])),r.createHref({pathname:s,search:o,hash:i})}function us(){return L(ts)!=null}function X(){return Y(us(),`useLocation() may be used only in the context of a <Router> component.`),L(ts).location}function ds(){return L(ts).navigationType}var fs=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function ps(e){L(es).static||u(e)}function ms(){let{isDataRoute:e}=L(ns);return e?Rs():hs()}function hs(){Y(us(),`useNavigate() may be used only in the context of a <Router> component.`);let e=L(qo),{basename:t,navigator:n}=L(es),{matches:r}=L(ns),{pathname:i}=X(),a=JSON.stringify(Ao(r)),o=p(!1);return ps(()=>{o.current=!0}),b((r,s={})=>{if(Ya(o.current,fs),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=jo(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:No([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var gs=j(null);function _s(e){let t=L(ns).outlet;return m(()=>t&&o(gs.Provider,{value:e},t),[t,e])}function vs(){let{matches:e}=L(ns);return e[e.length-1]?.params??{}}function ys(e,{relative:t}={}){let{matches:n}=L(ns),{pathname:r}=X(),i=JSON.stringify(Ao(n));return m(()=>jo(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function bs(e,t){return xs(e,t)}function xs(e,t,n){Y(us(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=L(es),{matches:i}=L(ns),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||``;Bs(c,!u||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
3
3
|
|
|
4
|
-
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let d=X(),f;if(t){let e=typeof t==`string`?eo(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})):ro(e,{pathname:m});Ya(u||h!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),Ya(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=Os(h&&h.map(e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:No([l,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?l:No([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(ts.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...f},navigationType:`POP`}},g):g}function Ss(){let e=Ls(),t=zo(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 Cs=o(Ss,null),ws=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=cs(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:o(ns.Provider,{value:this.props.routeContext},o(rs.Provider,{value:e,children:this.props.component}));return this.context?o(Es,{error:e},t):t}};ws.contextType=Yo;var Ts=new WeakMap;function Es({children:e,error:t}){let{basename:n}=L(es);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=ss(t.digest);if(e){let r=Ts.get(t);if(r)throw r;let i=Ho(e.location,n),a=i.absoluteURL||i.to;if(Ko(a))throw Error(`Invalid redirect location`);if(Vo&&!Ts.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 Ts.set(t,n),n}return o(`meta`,{httpEquiv:`refresh`,content:`0;url=${a}`})}}return e}function Ds({routeContext:e,match:t,children:n}){let r=L(qo);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),o(ns.Provider,{value:e},n)}function Os(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:Bo(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||Cs,s&&(c<0&&l===0?(Bs(`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(Ds,{match:n,routeContext:{outlet:e,matches:h,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||l===0)?o(ws,{location:r.location,revalidation:r.revalidation,component:p,error:d,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:u}):g()},null)}function ks(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function As(e){let t=L(qo);return Y(t,ks(e)),t}function js(e){let t=L(Jo);return Y(t,ks(e)),t}function Ms(e){let t=L(ns);return Y(t,ks(e)),t}function Ns(e){let t=Ms(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 Ps(){return Ns(`useRouteId`)}function Fs(){let e=js(`useNavigation`);return m(()=>{let{matches:t,historyAction:n,...r}=e.navigation;return r},[e.navigation])}function Is(){let{matches:e,loaderData:t}=js(`useMatches`);return m(()=>e.map(e=>ao(e,t)),[e,t])}function Ls(){let e=L(rs),t=js(`useRouteError`),n=Ns(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Rs(){let{router:e}=As(`useNavigate`),t=Ns(`useNavigate`),n=p(!1);return ps(()=>{n.current=!0}),b(async(r,i={})=>{Ya(n.current,fs),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var zs={};function Bs(e,t,n){!t&&!zs[e]&&(zs[e]=!0,Ya(!1,n))}v(Vs);function Vs({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return xs(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function Z({to:e,replace:t,state:n,relative:r}){Y(us(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=L(es);Ya(!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(ns),{pathname:o}=X(),s=ms(),c=jo(e,Ao(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 Hs({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,useTransitions:s}){Y(!us(),`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=eo(n));let{pathname:u=`/`,search:d=``,hash:f=``,state:p=null,key:h=`default`,mask:g}=n,_=m(()=>{let e=To(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 Ya(_!=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(es.Provider,{value:l},o(ts.Provider,{children:t,value:_}))}function Us({children:e,location:t}){return bs(Ws(e),t)}function Ws(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,Ws(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=Ws(e.props.children,i)),n.push(a)}),n}var Gs=`get`,Ks=`application/x-www-form-urlencoded`;function qs(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function Js(e){return qs(e)&&e.tagName.toLowerCase()===`button`}function Ys(e){return qs(e)&&e.tagName.toLowerCase()===`form`}function Xs(e){return qs(e)&&e.tagName.toLowerCase()===`input`}function Zs(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Qs(e,t){return e.button===0&&(!t||t===`_self`)&&!Zs(e)}function $s(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 ec(e,t){let n=$s(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var tc=null;function nc(){if(tc===null)try{new FormData(document.createElement(`form`),0),tc=!1}catch{tc=!0}return tc}var rc=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function ic(e){return e!=null&&!rc.has(e)?(Ya(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ks}"`),null):e}function ac(e,t){let n,r,i,a,o;if(Ys(e)){let o=e.getAttribute(`action`);r=o?To(o,t):null,n=e.getAttribute(`method`)||Gs,i=ic(e.getAttribute(`enctype`))||Ks,a=new FormData(e)}else if(Js(e)||Xs(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?To(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||Gs,i=ic(e.getAttribute(`formenctype`))||ic(o.getAttribute(`enctype`))||Ks,a=new FormData(o,e),!nc()){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(qs(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=Gs,r=null,i=Ks,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 oc={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},sc=/[&><\u2028\u2029]/g;function cc(e){return e.replace(sc,e=>oc[e])}function lc(e,t){if(e===!1||e==null)throw Error(t)}function uc(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&&To(i.pathname,t)===`/`?i.pathname=`${Po(t)}/_root.${r}`:i.pathname=`${Po(i.pathname)}.${r}`,i}async function dc(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 fc(e){return e!=null&&typeof e.page==`string`}function pc(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 mc(e,t,n){return yc((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await dc(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(pc).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function hc(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 gc(e,t,{includeHydrateFallback:n}={}){return _c(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 _c(e){return[...new Set(e)]}function vc(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function yc(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!fc(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(vc(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function bc(){let e=L(qo);return lc(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function xc(){let e=L(Jo);return lc(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var Sc=j(void 0);Sc.displayName=`FrameworkContext`;function Cc(){let e=L(Sc);return lc(e,`You must render this element inside a <HydratedRouter> element`),e}function wc(e,t){let n=L(Sc),[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:Tc(s,m),onBlur:Tc(c,h),onMouseEnter:Tc(l,m),onMouseLeave:Tc(u,h),onTouchStart:Tc(d,m)}]:[a,f,{}]:[!1,f,{}]}function Tc(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Ec({page:e,...t}){let n=Xo(),{nonce:r}=Cc(),{router:i}=bc(),a=m(()=>ro(i.routes,e,i.basename),[i.routes,e,i.basename]);return a?(t.nonce==null&&r&&(t={...t,nonce:r}),o(n?Oc:kc,{page:e,matches:a,...t})):null}function Dc(e){let{manifest:t,routeModules:n}=Cc(),[r,i]=w([]);return S(()=>{let r=!1;return mc(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function Oc({page:e,matches:t,...n}){let r=X(),{future:i}=Cc(),{basename:a}=bc();return o(d,null,m(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=uc(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 kc({page:e,matches:t,...n}){let r=X(),{future:i,manifest:a,routeModules:s}=Cc(),{basename:c}=bc(),{loaderData:l,matches:u}=xc(),f=m(()=>hc(e,t,u,a,r,`data`),[e,t,u,a,r]),p=m(()=>hc(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=uc(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(()=>gc(p,a),[p,a]),_=Dc(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 Ac(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var jc=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{jc&&(window.__reactRouterVersion=`7.18.0`)}catch{}function Mc({basename:e,children:t,useTransitions:n,window:r}){let i=p();i.current??=Ja({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(Hs,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:a,useTransitions:n})}function Nc({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(Hs,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,useTransitions:r})}Nc.displayName=`unstable_HistoryRouter`;var Pc=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(es),b=typeof u==`string`&&Ua.test(u),x=Ho(u,_);u=x.to;let S=ls(u,{relative:r}),C=X(),w=null;if(s){let e=jo(s,[],C.mask?C.mask.pathname:`/`,!0);_!==`/`&&(e.pathname=e.pathname===`/`?_:No([_,e.pathname])),w=v.createHref(e)}let[T,E,D]=wc(n,h),O=Vc(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:Ac(g,E),target:l,"data-discover":!b&&t===`render`?`true`:void 0});return T&&!b?o(d,null,j,o(Ec,{page:S})):j});Pc.displayName=`Link`;var Fc=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=ys(a,{relative:l.relative}),f=X(),p=L(Jo),{navigator:m,basename:h}=L(es),g=p!=null&&Qc(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=To(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(Pc,{...l,"aria-current":w,className:T,ref:u,style:E,to:a,viewTransition:s},typeof c==`function`?c(C):c)});Fc.displayName=`NavLink`;var Ic=A(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:s=Gs,action:c,onSubmit:l,relative:u,preventScrollReset:d,viewTransition:p,defaultShouldRevalidate:m,...h},g)=>{let{useTransitions:_}=L(es),v=Gc(),y=Kc(c,{relative:u}),b=s.toLowerCase()===`get`?`get`:`post`,x=typeof c==`string`&&Ua.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})});Ic.displayName=`Form`;function Lc({getKey:e,storageKey:t,...n}){let r=L(Sc),{basename:i}=L(es),a=X(),s=Is();Xc({getKey:e,storageKey:t});let c=m(()=>{if(!r||!e)return null;let t=Yc(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})(${cc(JSON.stringify(t||qc))}, ${cc(JSON.stringify(c))})`}})}Lc.displayName=`ScrollRestoration`;function Rc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function zc(e){let t=L(qo);return Y(t,Rc(e)),t}function Bc(e){let t=L(Jo);return Y(t,Rc(e)),t}function Vc(e,{target:t,replace:n,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c,useTransitions:l}={}){let u=ms(),d=X(),p=ys(e,{relative:o});return b(m=>{if(Qs(m,t)){m.preventDefault();let t=n===void 0?$a(d)===$a(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 Hc(e){Ya(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($s(e)),n=p(!1),r=X(),i=m(()=>ec(r.search,n.current?null:t.current),[r.search]),a=ms();return[i,b((e,t)=>{let r=$s(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var Uc=0,Wc=()=>`__${String(++Uc)}__`;function Gc(){let{router:e}=zc(`useSubmit`),{basename:t}=L(es),n=Ps(),r=e.fetch,i=e.navigate;return b(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=ac(e,t);a.navigate===!1?await r(a.fetcherKey||Wc(),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 Kc(e,{relative:t}={}){let{basename:n}=L(es),r=L(ns);Y(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...ys(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:No([n,a.pathname])),$a(a)}var qc=`react-router-scroll-positions`,Jc={};function Yc(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:To(e.pathname,n)||e.pathname},t)),i??=e.key,i}function Xc({getKey:e,storageKey:t}={}){let{router:n}=zc(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=Bc(`useScrollRestoration`),{basename:a}=L(es),o=X(),s=Is(),c=Fs();S(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Zc(b(()=>{if(c.state===`idle`){let t=Yc(o,s,a,e);Jc[t]=window.scrollY}try{sessionStorage.setItem(t||qc,JSON.stringify(Jc))}catch(e){Ya(!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||qc);e&&(Jc=JSON.parse(e))}catch{}},[t]),u(()=>{let t=n?.enableScrollRestoration(Jc,()=>window.scrollY,e?(t,n)=>Yc(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{Ya(!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 Zc(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 Qc(e,{relative:t}={}){let n=L(Zo);Y(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=zc(`useViewTransitionState`),i=ys(e,{relative:t});if(!n.isTransitioning)return!1;let a=To(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=To(n.nextLocation.pathname,r)||n.nextLocation.pathname;return xo(i.pathname,o)!=null||xo(i.pathname,a)!=null}var $c=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}}))()),el=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function tl(e){var t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],($c.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(el),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 nl=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,rl=/^\s*$/,il=Object.create(null);function al(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(al,``)+`</`+t.name+`>`;case`comment`:return e+`<!--`+t.comment+`-->`}}var ol={parse:function(e,t){t||={},t.components||=il;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(nl,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=tl(s);return a<0?(r.push(m),r):((l=i[a]).children.push(m),r)}if(u&&(a++,(n=tl(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);rl.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+al(``,t)},``)}};O();var sl=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},cl=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?ul(t):t},ll=e=>Array.isArray(e)&&e.every(h),ul=e=>Array.isArray(e)?e:[e],dl=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},fl=e=>{let t={};if(!e)return t;let n=e=>{ul(e).forEach(e=>{qi(e)||(sl(e)?n(cl(e)):Qi(e)&&!h(e)&&Object.assign(t,e))})};return n(e),t},pl=(e,t,n,r)=>{if(!e)return``;let i=``,a=ul(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach((e,a)=>{if(qi(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=qi(d)?d:pl(d,t,n,r);i+=`<${c}>${e}</${c}>`;return}let f=pl(d,t,n,r);i+=`<${a}>${f}</${a}>`;return}if(e===null){Yi(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(Qi(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}Yi(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}Yi(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},ml=(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},hl=(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=>{ul(e).forEach(e=>{qi(e)||(sl(e)?p(cl(e)):Qi(e)&&!h(e)&&Object.assign(f,e))})};p(e);let m=ml(n,l,f),g=ol.parse(`<0>${m}</0>`),v={...f,...a},y=(e,t,n)=>{let r=cl(e),i=x(r,t.children,n);return ll(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=ul(e),d=ul(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];qi(t)&&(g[e]=Zi(t))});let _=Object.keys(g).length===0?m:dl({props:g},m),S=h(_),C=S&&sl(n,!0)&&!n.voidElement,w=u&&Qi(_)&&_.dummy&&!S,T=Qi(t)&&Object.hasOwnProperty.call(t,n.name);if(qi(_)){let t=r.services.interpolator.interpolate(_,v,r.language);e.push(t)}else if(sl(_)||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?ul(cl(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(Qi(_)&&!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:Ki().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 cl(x([{dummy:!0,children:e||[]}],g,ul(e||[]))[0])},gl=(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})},_l=(e,t)=>e.map((e,n)=>gl(e,n,t)),vl=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:gl(e[r],r,t)})}),n},yl=(e,t,n,r)=>e?Array.isArray(e)?_l(e,t):Qi(e)?vl(e,t):($i(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,bl=e=>!Qi(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function xl({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||Ji();if(!h)return $i(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),_={...Ki(),...h.options?.react},v=u||g.ns||h.options?.defaultNS;v=qi(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=pl(e,_,h,r),T=c||b?.defaultValue||w||_.transEmptyNodeValue||(typeof r==`function`?Gi(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=fl(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=yl(C,j,h,r),N=M||e,P=null;bl(M)&&(P=M,N=e);let F=hl(N,P,j,h,_,A,x),I=n??_.defaultTransParent;return I?o(I,m,F):F}O();function Sl({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(Xi)||{},g=u||m||Ji(),_=d||g?.t.bind(g);return xl({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 Cl=`camstack:broker-oauth`;function wl(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`camstack:broker-oauth`&&typeof t.ok==`boolean`}function Tl(e,t){return e.split(`{{brokerId}}`).join(encodeURIComponent(t))}function El(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||wl(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 Dl={open:e=>ra(e),assign:e=>window.location.assign(e),watch:(e,t)=>El(e,t)};function Ol(e,t,n=Dl){let r=H(ta(e)),i=n.open(r);if(i===null){n.assign(r);return}n.watch(i,e=>{t?.(e)})}var kl=[`starting`,`awaiting-login`,`captured`,`error`,`cancelled`],Al=[`awaiting-code`,`captured`,`expired`,`error`,`cancelled`];function jl(e){return typeof e==`object`&&!!e}function Ml(e){return jl(e)&&typeof e.sessionId==`string`&&typeof e.loginUrl==`string`}function Nl(e){return jl(e)&&typeof e.sessionId==`string`&&typeof e.phase==`string`&&kl.includes(e.phase)}function Pl(e){return jl(e)&&typeof e.sessionId==`string`&&typeof e.userCode==`string`&&typeof e.verificationUrl==`string`&&typeof e.expiresAt==`number`}function Fl(e){return Pl(e)&&jl(e)&&typeof e.phase==`string`&&Al.includes(e.phase)}function Il(e){return jl(e)&&typeof e.brokerId==`string`}function Ll(){return{"Content-Type":`application/json`,Authorization:`Bearer ${localStorage.getItem(`camstack_admin_token`)??``}`}}async function Rl(e,t){try{return await e.json()}catch{throw Error(`${t} failed: HTTP ${e.status}`)}}function zl(e){let t=jl(e)&&typeof e.error==`string`?e.error:`Unknown error`;return Error(t)}async function Bl(e,t,n){let r=await fetch(H(e),{method:`POST`,headers:Ll(),body:JSON.stringify(t)}),i=await Rl(r,`Sign-in ${e.split(`/`).pop()??`request`}`);if(!r.ok)throw zl(i);if(!n(i))throw Error(`Unexpected response from server`);return i}function Vl(e,t){return Bl(`${e}/start`,t,Ml)}function Hl(e,t){return Bl(`${e}/code/start`,t,Pl)}async function Ul(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(H(`${e}/status?${n.toString()}`),{headers:{Authorization:Ll().Authorization??``}}),i=await Rl(r,`Sign-in status`);if(!r.ok)throw zl(i);if(!Fl(i))throw Error(`Unexpected status response from server`);return i}async function Wl(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(H(`${e}/status?${n.toString()}`),{headers:{Authorization:Ll().Authorization??``}}),i=await Rl(r,`Sign-in status`);if(!r.ok)throw zl(i);if(!Nl(i))throw Error(`Unexpected status response from server`);return i}function Gl(e,t){return Bl(`${e}/commit`,{...t},Il)}async function Kl(e,t){try{await fetch(H(`${e}/cancel`),{method:`POST`,headers:Ll(),body:JSON.stringify({sessionId:t})})}catch{}}O();var ql=2e3,Jl=1e3;function Yl(e){let t=Math.max(0,Math.ceil(e/1e3));return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,`0`)}`}function Xl({expiresAt:e}){let{t}=J(),[n,r]=w(()=>Date.now());return S(()=>{let e=setInterval(()=>r(Date.now()),Jl);return()=>clearInterval(e)},[]),x(`span`,{className:`text-[11px] text-foreground-subtle`,children:t(`brokers.signIn.codeExpiresIn`,{time:Yl(e-n)})})}function Zl({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&&Kl(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 Gl(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 Ul(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{}})()},ql)},[e,_,g,m,o]),y=async()=>{h(),l({kind:`starting`});try{let t=await Hl(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(yr,{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(Cn,{className:`h-3.5 w-3.5`}):x(_e,{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(U,{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(Ie,{className:`h-3.5 w-3.5`}),` `,o(`brokers.signIn.openCodePage`,{host:Ql(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(U,{className:`h-3 w-3 animate-spin flex-shrink-0`}),` `,o(`brokers.signIn.waitingForCode`)]}),x(Xl,{expiresAt:T.expiresAt})]}),x(K,{variant:`outline`,size:`sm`,className:`shrink-0 whitespace-nowrap`,onClick:C,children:o(`brokers.signIn.cancel`)})]})]})}function Ql(e){try{let t=new URL(e);return`${t.host}${t.pathname===`/`?``:t.pathname}`}catch{return e}}O();var $l=2e3;function eu(e){return e.startsWith(`/`)&&!e.startsWith(`//`)?new URL(e,window.location.origin).toString():e}function tu({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&&Kl(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 Gl(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 Wl(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{}})()},$l)},[e,_,g,m,o]),y=async()=>{h(),l({kind:`starting`});try{let t=await Vl(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(yr,{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(Cn,{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(U,{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(eu(c.loginUrl),`_blank`,`noopener,noreferrer`),children:[x(Ie,{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(U,{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(U,{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 nu=[`device-code`];function ru({methods:e,...t}){let{t:n}=J(),r=e!==void 0&&e.length>0?e:nu,[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(Ci,{value:o,onValueChange:e=>a(e===`device-code`?e:`proxy`),appearance:`pills`,children:x(yi,{"aria-label":n(`brokers.signIn.method`),children:r.map(e=>x(Xr,{value:e,children:n(e===`device-code`?`brokers.signIn.methodDeviceCode`:`brokers.signIn.methodProxy`)},e))})}),o===`device-code`?x(Zl,{...t},`device-code`):x(tu,{...t},`proxy`)]})}function iu(e){return t=>Object.prototype.hasOwnProperty.call(e,t)}var au=iu({devices:!0}),ou=iu({classes:!0,classesExclude:!0,labelEquals:!0,identities:!0,identitiesExclude:!0,eventTypeTokens:!0,sensorKinds:!0}),su=iu({minConfidence:!0,minImportance:!0,minLabelConfidence:!0}),cu=iu({minDwellSeconds:!0}),lu=iu({source:!0}),uu=iu({crossing:!0}),du=iu({packagePhase:!0}),fu=iu({sensorTransition:!0}),pu=iu({plates:!0}),mu=iu({occupancy:!0}),hu=iu({audio:!0}),gu=iu({systemEvent:!0}),_u=iu({deviceState:!0}),vu=iu({scene:!0});function yu(e,t){let n=e[t];return Array.isArray(n)?n:[]}function bu(e,t){let n=e[t];return typeof n==`number`?n:void 0}O();function xu(e,t){let n=W().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 Su(e){let t=W().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 Cu(){let e=nr();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 wu(){let e=zr({limit:200}),t=ci();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 Tu({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(Di,{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 Eu=[{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`)}}],Du=`Immediate, grouped`,Ou=Eu.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 ku(e){return e.groupingSec!==void 0&&Lt(e)?`immediate-grouped`:e.delivery}function Au(e){let t=(e.delivery===`immediate`||e.delivery===`track-end`)&&Lt({delivery:`immediate`,conditions:e.conditions});return Ou.filter(e=>e.value!==`immediate-grouped`||t)}function ju(e){return Ou.find(t=>t.value===e)?.value}function Mu(e,t=Du){return ku(e)===`immediate-grouped`?`${t} · ${String(e.groupingSec)} s`:Pu(e.delivery)}function Nu(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}function Pu(e){return Eu.find(t=>t.value===e)?.label??e}function Fu(e){return Eu.some(t=>t.value===e)}var Iu=[{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 Lu(e){return ft(pt(e)).editable}function Ru(e){return It(zu(e))}function zu(e){switch(e){case`device-events`:case`system`:case`alarm`:case`mixed`:return e;default:return}}var Bu=new Map([[0,`helpers.ruleFormParsers.cdNone`],[60,`helpers.ruleFormParsers.cd1m`],[3600,`helpers.ruleFormParsers.cd1h`]]),Vu=86400;function Hu(e){let t=Bu.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 Uu(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}var Wu=[{value:`rule-device`,get label(){return q.t(`helpers.ruleFormParsers.scopeDevice`)}},{value:`rule`,get label(){return q.t(`helpers.ruleFormParsers.scopeRule`)}}];function Gu(e){return Wu.find(t=>t.value===e)?.value}var Ku=[{value:`per-class`,get label(){return q.t(`helpers.ruleFormParsers.granPerClass`)}},{value:`shared`,get label(){return q.t(`helpers.ruleFormParsers.granShared`)}}];function qu(e){return Ku.find(t=>t.value===e)?.value}var Ju=[{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 Yu(e){return Ju.find(t=>t.value===e)?.value}var Xu=[{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 Zu(e){let t=Xu.find(t=>t.value===e)?.value;return t===``?void 0:t}var Qu=[{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 $u(e){let t=Qu.find(t=>t.value===e)?.value;return t===``?void 0:t}var ed=[{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`)}}],td=[{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`)}}],nd=[{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 rd(e){return e===`raised`||e===`cleared`?e:void 0}function id(e,t){return e===`sensorTransition`?Nt(t.sensorKinds):!0}var ad=[{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`)}}],od=`enter`;function sd(e){return e===`exit`||e===`any`?e:void 0}var cd=[{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 ld(e,t){return e.options&&e.options.length>0?e.options:t}var ud=[{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 dd(e){if(e===``)return;let t=Number(e);return Number.isFinite(t)&&t>=1&&t<=8?t:void 0}var fd={days:[0,1,2,3,4,5,6],minute:480},pd=[{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 md(e){let t=Math.floor(e/60),n=e%60;return`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`}function hd(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 gd={mode:`modes`,onActivation:!0,onDeactivation:!1};function _d(e){return e!==void 0&&$t.includes(e)}function vd(e,t){return gt({conditions:t.length>0?{systemEvent:{kinds:[...t]}}:{},...e===void 0?{}:{systemEventDelivery:e}})}function yd(e){return{mode:`modes`,onActivation:e.onActivation,onDeactivation:e.onDeactivation}}function bd(e,t,n){return t===`activation`?{...e,onActivation:n}:t===`deactivation`?{...e,onDeactivation:n}:n?e.onSchedule===void 0?{...e,onSchedule:{schedule:jt([fd]),grouping:`section`}}:e:yd(e)}function xd(e,t){return{...e,onSchedule:{schedule:t,grouping:e.onSchedule?.grouping??`section`}}}function Sd(e,t){return e.onSchedule===void 0?e:{...e,onSchedule:{...e.onSchedule,grouping:t}}}function Cd(e){let t=new Set,n=0;for(let r of e){let e=Vt(r);e===void 0?n+=1:t.add(e.label)}return{adds:[...t],without:n}}function wd(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 Td(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 Ed(e,t,n,r=`rule`){if(e===`error`)return wd(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=Td(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 Dd=`notificationRules.systemEventKinds.`,Od=`notificationRules.systemEventGroups.`,kd=`notificationRules.systemEventHints.`;function Ad(e){return!Ht.some(t=>t===e)}function jd(e){let t=`${Dd}${e}`;return q.exists(t)?q.t(t):e}function Md(){return Mt.map(e=>({id:e.id,family:e.family,label:q.t(`${Od}${e.id}`,e.label),hint:q.t(`${kd}${e.id}`),kinds:e.kinds.filter(Ad).map(e=>({value:e,label:jd(e)}))}))}function Nd(e){return Md().filter(t=>t.family===e)}function Pd(e){let t=tn(e).conditions.systemEvent;return t===void 0?{kinds:(Nd(e)[0]?.kinds??[]).map(e=>e.value)}:{...t,kinds:[...t.kinds]}}function Fd(){return Md().flatMap(e=>e.kinds)}function Id(e){return{devices:wt(e,`deviceIds`),deviceTypes:wt(e,`deviceTypes`),nodes:wt(e,`nodeIds`),packages:wt(e,`packageNames`),consumableThreshold:wt(e,`consumableLowPercent`)}}function Ld(e,t){let n=Ot[e],r=Id(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}}var Rd=Object.values(Dt).map(e=>({value:e,label:zd(e)})).toSorted((e,t)=>e.label.localeCompare(t.label));function zd(e){let t=e.replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function Bd(e,t){let n=[],r=new Set;for(let i of e.kinds){let e=Vt(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]:ut(e),clears:ut(e),classId:e.id,...t&&e.snapshotSection===null?{noSnapshot:!0}:{}}))}return n}function Vd(e,t){return t.clears.some(t=>e.includes(t))}function Hd(e,t,n){if(!Nd(n).some(e=>e.kinds.some(e=>t.kinds.includes(e.value))))return e;let r=e?.kinds??[];if(Vd(r,t)){let i=r.filter(e=>!t.clears.includes(e));return i.length===0?e:Kd(e,i,n)}return Kd(e,Fd().filter(e=>t.kinds.includes(e.value)||r.includes(e.value)).map(e=>e.value),n)}function Ud(e,t){return t===void 0?void 0:Kd(t,t.kinds,e)}function Wd(e,t){let n=e?.kinds??[];if(n.length===0)return;let r=Gd(t,`deviceIds`,e?.deviceIds),i=Gd(t,`excludeDeviceIds`,e?.excludeDeviceIds),a=Gd(t,`deviceTypes`,e?.deviceTypes),o=Gd(t,`nodeIds`,e?.nodeIds),s=Gd(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 Gd(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 Kd(e,t,n){let r=Ld(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 qd=95;function Jd(e){let t=e.trim();if(t===``)return{kind:`clear`};let n=Number(t);return Number.isInteger(n)&&n>=1&&n<=qd?{kind:`set`,value:n}:{kind:`invalid`}}function Yd(e,t=2){if(e===void 0||e.length===0)return q.t(`helpers.notificationSystemEvents.noneSelected`);let n=e.slice(0,t).map(jd).join(`, `),r=e.length-Math.min(t,e.length);return r>0?`${n} +${r}`:n}function Xd(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(zd).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 Zd(e){return e===void 0||(e.deviceTypes?.length??0)===0?!1:e.kinds.some(e=>_t.includes(e))}var Qd=[`all`,`only`,`except`];function $d(e,t){return(e??[]).length>0?`only`:(t??[]).length>0?`except`:`all`}function ef(e,t){let n=[...e??[]],r=[...t??[]];return{mode:$d(n,r),include:n,exclude:r,legacyBoth:n.length>0&&r.length>0}}function tf(e,t){return{...e,mode:t}}function nf(e){switch(e.mode){case`only`:return e.include;case`except`:return e.exclude;case`all`:return[]}}function rf(e,t){switch(e.mode){case`only`:return{...e,include:[...t]};case`except`:return{...e,exclude:[...t]};case`all`:return e}}function af(e){return e.mode===`only`&&e.legacyBoth?e.exclude:[]}function of(e){return{...e,exclude:[],legacyBoth:!1}}function sf(e){switch(e.mode){case`all`:return{};case`except`:return e.exclude.length>0?{exclude:[...e.exclude]}:{};case`only`:{let t=af(e);return{...e.include.length>0?{include:[...e.include]}:{},...t.length>0?{exclude:[...t]}:{}}}}}function cf(e){let t=sf(e),n=t.include??[],r=t.exclude??[];return[...e.include.filter(e=>!n.includes(e)),...e.exclude.filter(e=>!r.includes(e))]}var lf=[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`],uf={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`)}}},df={onActivation:[],onDeactivation:[],onTrigger:[],onTriggerOff:[],buttons:[]};function ff(e){return e===void 0?df:{onActivation:[...e.onActivation??[]],onDeactivation:[...e.onDeactivation??[]],onTrigger:[...e.onTrigger??[]],onTriggerOff:[...e.onTriggerOff??[]],buttons:[...e.buttons??[]]}}function pf(e){let t=e.buttons.filter(e=>e.id.trim()!==``&&e.label.trim()!==``&&e.sequenceId.trim()!==``),n={onActivation:e.onActivation,onDeactivation:e.onDeactivation,onTrigger:e.onTrigger,onTriggerOff:e.onTriggerOff};if(!(!lf.some(e=>n[e].length>0)&&t.length===0))return{...n.onActivation.length>0?{onActivation:[...n.onActivation]}:{},...n.onDeactivation.length>0?{onDeactivation:[...n.onDeactivation]}:{},...n.onTrigger.length>0?{onTrigger:[...n.onTrigger]}:{},...n.onTriggerOff.length>0?{onTriggerOff:[...n.onTriggerOff]}:{},...t.length>0?{buttons:t}:{}}}function mf(e,t){let n=[];for(let r of lf){let i=e[r];i.length>4&&n.push({kind:`too-many`,message:q.t(`helpers.notificationRuleActions.tooMany`,{title:uf[r].title})});for(let e of i)e.kind===`sequence`&&!t.has(e.sequenceId)&&n.push({kind:`unknown-sequence`,message:q.t(`helpers.notificationRuleActions.hookUnknownSeq`,{title:uf[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.sequenceId.trim())||n.push({kind:`unknown-sequence`,message:q.t(`helpers.notificationRuleActions.buttonUnknownSeq`,{label:i.label||e})}))}return n}function hf(e,t){return{id:`action-${String(e+1)}`,label:q.t(`helpers.notificationRuleActions.newButtonLabel`),sequenceId:t}}function gf(){return{kind:`do`,action:{kind:`cap`,deviceId:0,cap:``,method:``}}}function _f(e){return{kind:`sequence`,sequenceId:e}}function vf(){return{kind:`wait`,seconds:5}}var yf=[{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`)}}],bf=[10,30,60],xf=[5,10,15,30,60,120,240,480];function Sf(e){return e>=60&&e%60==0?q.t(`helpers.ruleFormState.snoozeHours`,{count:e/60}):q.t(`helpers.ruleFormState.snoozeMin`,{count:e})}var Cf=new Set([`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`]),wf=`alarm-panel`;function Tf(e,t){for(let t of e.systemEvent?.kinds??[])if(Cf.has(t))return!0;for(let e of t)if(e.kind===`cap`&&e.cap===wf)return!0;return!1}function Ef(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`])for(let i of e[t])if(i.kind===`do`)r.push(i.action);else{let e=n.get(i.sequenceId);e!==void 0&&r.push(...e.actions)}for(let t of e.buttons){let e=n.get(t.sequenceId);e!==void 0&&r.push(...e.actions)}return r}function Df(e){let{devices:t,devicesExclude:n,classes:r,classesExclude:i,...a}=e;return{conditions:a,deviceScope:ef(t,n),classScope:ef(r,i)}}function Of(e){let t=sf(e.deviceScope),n=sf(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 kf(e){return e.deviceScope.mode===`only`?e.deviceScope.include:[]}function Af(e,t,n){let r=pt(n);return e.some(e=>e.id===t&&fn(e,n.delivery,r))}function jf(e=`immediate`,t={}){return{name:``,enabled:!0,delivery:e,targetIds:[],targetUsers:[],targetParams:{},priority:3,mediaImage:Zt({},pt({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:``,...Df(t),schedule:void 0,systemEventDelivery:e===`system-event`?gd:void 0,snoozeAllowGlobal:!1,groupingSec:void 0,snoozeOptions:void 0,askVerdict:void 0,actions:df,cooldownSec:30,cooldownScope:`rule-device`,cooldownGranularity:void 0}}function Mf(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,enabled:e.enabled,delivery:e.delivery,targetIds:e.targets.map(e=>e.targetId),targetUsers:e.targetUsers??[],targetParams:t,priority:e.priority,mediaImage:Zt(e.media,pt(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??``,...Df(e.conditions),schedule:e.schedule,systemEventDelivery:e.systemEventDelivery,snoozeAllowGlobal:e.snoozeAllowGlobal===!0,groupingSec:e.groupingSec,snoozeOptions:e.snoozeOptions,askVerdict:e.askVerdict,actions:ff(e.actions),cooldownSec:e.throttle.cooldownSec,cooldownScope:e.throttle.scope,cooldownGranularity:e.throttle.granularity}}function Nf(e,t){let n=[];if(Vf(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&&!Hf(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(ht(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(Vu)} (24 hours). 0 means every match is delivered.`),dn(e.delivery))for(let t of Ct({delivery:e.delivery,conditions:e.conditions,...e.systemEventDelivery===void 0?{}:{systemEventDelivery:e.systemEventDelivery},...pf(e.actions)===void 0?{}:{actions:pf(e.actions)}}))n.push(Tt(t));return n}function Pf(e){let t=e.systemEventDelivery;if(t===void 0)return{};if(!dn(e.delivery))return t.mode===`instant`?{}:{systemEventDelivery:{mode:`instant`}};let n=bt(e.conditions.systemEvent?.kinds??[]);if(!(n.kind===`family`&&$t.includes(n.family)))return t.mode===`modes`?{}:{systemEventDelivery:t};let r=Rt({systemEventDelivery:t}).schedule;if(r!==null&&yt(r.schedule)===null){let e=mt(r.schedule);if(e!==null&&e.times.length>0){let n=jt(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 Ff(e){if(!If(e))return null;if(!pn(e.templateBody))return q.t(`helpers.ruleFormState.summaryWarnNone`,{token:`{{summaryText}}`});let t=e.templateBody;return Pt({...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 If(e){return Et({delivery:e.delivery,...e.systemEventDelivery===void 0?{}:{systemEventDelivery:e.systemEventDelivery}})}function Lf(e,t,n=new Set){return Nf(e,t).length===0&&Fu(e.delivery)&&(!dn(e.delivery)||Kf(e)>0)&&pt(e)!==`mixed`&&e.name.trim().length>0&&(e.targetIds.length>0||e.targetUsers.length>0)&&mf(e.actions,n).length===0}function Rf(e,t){let n=Wf(e.conditions,t),r=dn(t)&&(n.systemEvent?.kinds.length??0)===0,i=dn(t)&&e.systemEventDelivery===void 0?gd:e.systemEventDelivery;return r?{...e,delivery:t,systemEventDelivery:i,conditions:{...n,systemEvent:Pd(`device-events`)}}:{...e,delivery:t,conditions:n,systemEventDelivery:i}}function zf(e,t){return t===`immediate-grouped`?{...Rf(e,`immediate`),groupingSec:e.groupingSec??20}:{...Rf(e,t),groupingSec:void 0}}function Bf(e){return e.delivery===`immediate`||e.delivery===`track-end`}function Vf(e){return e.groupingSec!==void 0&&Lt(e)}function Hf(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 Uf=new Set([`immediate`,`track-end`,`package-event`]);function Wf(e,t){if(e.source!==`pipeline`||Uf.has(t))return e;let{source:n,...r}=e;return r}function Gf(e,t){return en(e.conditions.systemEvent)===t?e:{...e,conditions:{...e.conditions,systemEvent:Pd(t)}}}function Kf(e){return e.conditions.systemEvent?.kinds.length??0}function qf(e,t){return e.appliesTo.includes(t)}var Jf={source:`any`};function Yf(e,t){if(t==null)return!0;if(Array.isArray(t))return t.length===0;if(typeof t==`string`)return t.length===0||Jf[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 Xf=zt.filter(e=>e.id===`audio`);function Zf(e){if(e.length===0)return e;let t=new Set(e.map(e=>e.id)),n=Xf.filter(e=>!t.has(e.id));return n.length===0?e:[...e,...n]}function Qf(e,t,n,r=pt({delivery:t,conditions:e})){let i=n.length===0?null:new Set(n.filter(e=>e.id!==`schedule`&&fn(e,t,r)).map(e=>e.id)),a={};for(let[t,n]of Object.entries(e))i!==null&&!i.has(t)||id(t,e)&&(Yf(t,n)||(a[t]=n));return a}function $f(e,t){if(e===void 0)return{};let n=Ud(e,t.systemEvent);return n===void 0?{}:{systemEvent:n}}function ep(e){return e!==void 0&&e.windows.length>0}function tp(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 np(e){let t=tp(e.media);return{...e.confirm===void 0?{}:{confirm:e.confirm},...t===void 0?{}:{media:t}}}function rp(e,t,n=[]){let r=e.templateTitle.trim(),i=e.templateBody.trim(),a=r.length>0||i.length>0?{...r.length>0?{title:r}:{},...i.length>0?{body:i}:{}}:void 0,o=pf(e.actions),s=pt(e),c=ft(s),l=lt(s),u=n.length===0?!0:n.some(t=>t.id===`schedule`&&qf(t,e.delivery)),d=!If(e)&&u&&ep(e.schedule)?e.schedule:void 0,f=n.length===0?!0:n.some(t=>t.id===`devices`&&qf(t,e.delivery)),p=n.length===0?!0:n.some(t=>t.id===`devicesExclude`&&qf(t,e.delivery)),{devices:m,devicesExclude:h,...g}=Of(e),_=Qf(g,e.delivery,n,s);return{name:e.name.trim(),enabled:e.enabled,delivery:e.delivery,conditions:{..._,...f&&m!==void 0?{devices:m}:{},...p&&h!==void 0?{devicesExclude:h}:{},...$f(l,e.conditions)},...d?{schedule:d}:{},...Pf(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]}:{},media:c.carriesMedia?{image:e.mediaImage,...e.mediaShowTriggerZone&&e.mediaImage!==`crop`&&e.mediaImage!==`none`&&Xt(_).length>0?{showTriggerZone:!0}:{},...e.mediaShowSubjectPath&&e.mediaImage!==`none`&&Jt(s)?{showSubjectPath:!0}:{},...e.mediaGif?{gif:!0}:{},...e.mediaClip?{clip:!0}:{},...e.mediaProfile===void 0?{}:{profile:e.mediaProfile},...e.mediaClipSpeed===void 0?{}:{clipSpeed:e.mediaClipSpeed},...s===`sensor`&&e.mediaImage!==`none`&&e.mediaLinkedCameras!==void 0?{linkedCameras:e.mediaLinkedCameras}:{},...s===`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,...a?{template:a}:{},...e.snoozeAllowGlobal?{snoozeAllowGlobal:!0}:{},...Vf(e)?{groupingSec:e.groupingSec}:{},...e.snoozeOptions===void 0?{}:{snoozeOptions:[...e.snoozeOptions]},...e.askVerdict!==void 0&&Bf(e)?{askVerdict:e.askVerdict}:{},...t?.confirm===void 0?{}:{confirm:t.confirm},...o===void 0?{}:{actions:o}}}function ip(e,t){let n=rp(e,void 0,t);return[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`groupingSec`,`actions`].filter(e=>n[e]===void 0)}var ap=[{key:`rule`,get label(){return q.t(`helpers.ruleFormTabs.tab_rule`)},fields:[`name`,`enabled`,`delivery`,`groupingSec`,`targetIds`,`targetUsers`,`targetParams`]},{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 op(e,t={}){let n=pt({delivery:e,conditions:t}),r=ft(n),i=ap.map(e=>e.key===`conditions`?{...e,label:r.label}:e);return It(n)?i.filter(e=>e.key!==`devices`):i}function sp(e){if(e.audio!==void 0)return q.t(`helpers.ruleFormTabs.condSound`);if(e.occupancy!==void 0)return q.t(`helpers.ruleFormTabs.condOccupancy`)}function cp(e){let t=pt(e),n=Yt(Of(e),t);return t===`sensor`&&e.conditions.sensorTransition!==void 0&&!id(`sensorTransition`,e.conditions)?[...n,{conditionId:`sensorTransition`,reason:Kt}]:n}var lp=`rule`;function up(e){return ap.find(t=>t.key===e)?.key}function dp(e){return e?.toLowerCase().startsWith(`it`)===!0?`it`:`en`}function fp(){let{i18n:e}=J(),t=dp(e.language);return e=>kt(e,t)}O();var pp=`block text-[11px] font-medium text-foreground`,mp=`text-[10px] text-foreground-subtle mt-0.5`;function hp({cameras:e,fleet:t,value:n,onChange:r,emptyMeansAll:i=!1,savedHadDevices:a=!1}){return x(br,{devices:e,listState:t.state,fleet:t,value:n,onChange:r,emptyMeansAll:i,savedHadDevices:a})}function gp({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(Me,{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 _p({picker:e,value:t,onChange:n}){let{t:r}=J(),i=m(()=>mn(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 vp({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(Pr,{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 yp({value:e,onChange:t,options:n}){let{t:r}=J(),i=bp(n??[]),a=i.length>0?i:ad;return s(`div`,{className:`mt-1 space-y-1`,children:[x($e,{value:e??`enter`,options:a.map(e=>({value:e.value,label:r(`notificationRules.crossing.${e.value}`,e.label)})),onChange:e=>t(sd(e.target.value))}),x(`p`,{className:mp,children:r(`notificationRules.crossing.hint`,`Which way the subject crosses the zone.`)})]})}function bp(e){let t=[];for(let n of e){let e=n.value===``||n.value===`enter`?od:sd(n.value);e===void 0||t.some(t=>t.value===e)||t.push({value:e,label:n.label})}return t}function xp({deviceIds:e,cameras:t,value:n,onChange:r}){let{options:i,loading:a}=xu(e,t);return x(Tu,{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 Sp({deviceIds:e,value:t,onChange:n}){let{t:r}=J(),{options:i,loading:a}=Su(e);return x(Tu,{options:i,value:t,onChange:n,loading:a,emptyHint:e.length===0?`Select cameras above to pick their event kinds — or type a token.`:`No event kinds reported for the selected cameras — type a token.`,placeholder:r(`system.notificationConditionWidgets.eventToken`,`Event token…`)})}var Cp=[{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 wp(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 Tp({deviceIds:e,cameras:t,classOptions:n,value:r,onChange:i}){let{t:a}=J(),{options:o,loading:c}=xu(e,t),l=r??ln,u=e=>i({...l,...e}),d=l.op===`became-occupied`||l.op===`became-free`,f=wp(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($e,{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($e,{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($e,{value:l.op,options:Cp.map(e=>({value:e.value,label:a(e.labelKey)})),onChange:e=>{let t=Cp.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 Ep=[{value:`label`,labelKey:`system.notificationConditionWidgets.audioModeLabel`,Icon:ne},{value:`level`,labelKey:`system.notificationConditionWidgets.audioModeLevel`,Icon:ze}];function Dp({taxonomy:e,value:t,onChange:n}){let{t:r}=J(),i=xt(t),a=e=>n(Wt(t,e)),{choices:o,unknownLabels:c}=St(e,i.labels),l=an(t)??`label`;return s(`div`,{className:`mt-1 space-y-2`,children:[s(`div`,{className:`flex flex-wrap items-center gap-1`,children:[Ep.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=Gt(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:qt(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(Mi,{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:vt,max:0,step:3,className:`w-20`,value:String(i.dbThreshold??Bt),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:Ut.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:Ut.samplingSeconds})]})]}),x(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`system.notificationConditionWidgets.dbfsHint`,{min:vt})})]}),ht(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 Op({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=wu().filter(e=>!r.includes(e));return s(`div`,{className:`mt-1 space-y-1.5`,children:[x(gp,{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 kp({gateable:e,value:t,onChange:n}){let{t:r}=J(),i=fp(),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($e,{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 Ap(e,t){let n=t(e.verdict);return e.latched?`${n} · ${t(`latched`)}`:n}function jp({scenes:e,value:t,onChange:n}){let{t:r}=J(),i=fp(),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:mp,children:r(`notificationRules.scene.none`,`No scenes yet — create one on the Scenes page.`)}):s(`div`,{className:`mt-1 space-y-2`,children:[x($e,{value:t?.sceneId??``,options:[{value:``,label:r(`notificationRules.scene.noGate`,`— no scene gate —`)},...e.map(e=>({value:e.sceneId,label:`${e.cameraName} · ${e.label} — ${Ap(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($e,{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($e,{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:`),` `,Ap(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 Mp(e){return md(e)}function Np(e){return hd(e)}function Pp(){return{days:[1,2,3,4,5],startMinute:540,endMinute:1080}}function Fp(e){return{days:[...fd.days],minute:e}}var Ip=`Always active — add a window to restrict when the rule fires.`;function Lp({value:e,onChange:t,mode:n=`windows`,defaultMinute:r=fd.minute,emptyHint:i}){return n===`times`?x(zp,{value:e,onChange:t,defaultMinute:r}):x(Rp,{value:e,onChange:t,emptyHint:i??Ip})}function Rp({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,Pp()],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:mp,children:n}):i.map((e,t)=>x(Bp,{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(Se,{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(Di,{checked:a,onChange:e=>o([...i],e.target.checked),className:`accent-primary`}),r(`system.notificationScheduleField.activeOutsideTheWindows`,`Active outside the windows`)]})]})]})}function zp({value:e,onChange:t,defaultMinute:n}){let{t:r}=J(),i=e?.timezone,a=e===void 0?{times:[],approximated:!1}:mt(e);if(a===null)return s(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times-fallback`,children:[x(`p`,{className:mp,children:r(`system.notificationScheduleField.invertedScheduleShownAsBands`,`Inverted schedule — shown as bands. Clear the invert flag (or the windows) to author punctual times.`)}),x(Rp,{value:e,onChange:t,emptyHint:Ip})]});let o=a.times,c=e=>{if(e.length===0){t(void 0);return}t(jt(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:mp,children:r(`system.notificationScheduleField.noTimesYetAddOne`,`No times yet — add one to send on those days at that clock time.`)}):o.map((e,t)=>x(Vp,{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,Fp(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(Se,{className:`h-3 w-3`}),` `,r(`system.notificationScheduleField.addTime`)]})]})}function Bp({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:Mp(e.startMinute),onChange:n=>t({...e,startMinute:Np(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:Mp(e.endMinute),onChange:n=>t({...e,endMinute:Np(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(de,{className:`h-3.5 w-3.5`})})]}),x(Hp,{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 Vp({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:md(e.minute),onChange:t=>n({...e,minute:hd(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(de,{className:`h-3.5 w-3.5`})})]}),x(Hp,{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 Hp({days:e,onToggle:t}){return x(`div`,{className:`flex flex-wrap gap-1`,children:pd.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 Up(e){return e>=8}O();function Wp(e){if(typeof e!=`object`||!e)return;let t=Reflect.get(e,`windows`);if(!(!Array.isArray(t)||t.length===0))return e}function Gp(e){return e.type===`multiselect`}function Kp(e){let t=e.suggestions;return t===void 0||t.length===0?[]:t.map(e=>({value:e,label:e}))}function qp(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 Jp(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Yp({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(!ei(e,t,l))return null;let r=e.creatable!==!1;return x(pr,{mode:`multi`,options:Kp(e),value:Jp(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:Zp(e.label,a),description:e.description===void 0?void 0:Zp(e.description,a),placeholder:e.placeholder??d(`formBuilder.formBuilder.searchOrAdd`,`Search or add…`),testId:`config-tags-${e.key}`})}if(e.type===`schedule`){if(!ei(e,t,l))return null;let r=Zp(e.label,a),i=e.description===void 0?void 0:Zp(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(Lp,{mode:o,value:Wp(t[e.key]),onChange:t=>n(e.key,t)})]})}return Gp(e)&&(Up(e.options.length)||e.creatable===!0)?ei(e,t,l)?x(pr,{mode:`multi`,options:qp(e.options),value:Jp(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:Zp(e.label,a),description:e.description===void 0?void 0:Zp(e.description,a),placeholder:e.placeholder??d(`formBuilder.formBuilder.searchToAdd`,`Search to add…`),testId:`config-multiselect-${e.key}`,listboxId:`msel-${e.key}`}):null:x(ar,{field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:o,externalProbe:c,allFields:l,onAction:u})}function Xp(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Zp(e,t){if(e!==void 0)return t&&Xp(e)?t(e):e}function Qp({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+ +!!ei(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:Zp(e.title,a)}),e.description&&x(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:Zp(e.description,a)})]}),x(di,{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:Zp(e.title,a)}),e.description&&x(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:Zp(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(Yp,{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(ar,{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 $p({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(Qp,{section:e,values:u,onChange:d,onChangeMany:f,disabled:r,translationFn:i,onTestField:a,probeResults:o,onAction:c},`${e.id}-${t}`))})}function em(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 tm={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 nm({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 ${tm[e.status]}`,"data-testid":`connection-test-verdict`,children:n})}var rm=new Set;function im(e){for(let t of rm)t(e)}function am(e){return rm.add(e),()=>{rm.delete(e)}}var om=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`]),sm=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function cm(e){let t=sm.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?sm.length:t}function lm(e){return e.filter(e=>!e.name.startsWith(`.`)&&!om.has(e.name)).toSorted((e,t)=>{let n=cm(e.name)-cm(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}O();function um({nodeId:e,value:t,onChange:n}){let{t:r}=J(),i=W().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(lm(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 dm=`storage/path-browser`,fm=`nodeId`,pm=`providerId`,mm=`basePath`,hm=`hub`;function gm(e,t){let n=e[t];return typeof n==`string`?n:``}function _m(e,t){let n=e.sections.flatMap(e=>e.fields),r=n.find(e=>e.key===fm);if(r===void 0)return null;let i=gm(t,pm),a=`showWhen`in r?r.showWhen:void 0;return a!==void 0&&!(i!==``&&a.in?.includes(i))?null:(i===``?[mm]:[`${i}.${mm}`,mm]).find(e=>n.some(t=>t.key===e))??null}function vm(e,t){let n=_m(e,t);return n===null?[]:[n]}function ym({schema:e,values:t,onValuesChange:n}){let{t:r}=J(),i=_m(e,t);if(i===null)return null;let a=gm(t,fm);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(um,{nodeId:a===``?hm:a,value:gm(t,i),onChange:e=>n({...t,[i]:e})})]})}var bm=new Map([[dm,{Component:ym,ownedKeys:vm}]]);function xm(e){return bm.get(e)??null}function Sm(e,t){return t.length===0?e:{...e,sections:e.sections.map(e=>({...e,fields:e.fields.filter(e=>!t.includes(e.key))}))}}function Cm(e){let t=new Map;for(let n of e){let e=n?.manifest;e?.id&&t.set(e.id,e.name??e.packageDisplayName??e.id)}return t}function wm(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}for(let e of a.instances){let t=Tm(a.description,e.kind);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:a.description.canTest,...e.kind===void 0?{}:{kindId:e.kind},...e.kind===void 0?{}:{kindLabel:t?.label??e.kind},...e.lastCheckedAt===void 0?{}:{lastCheckedAt:e.lastCheckedAt},...t?.connectPath===void 0?{}:{connectPath:t.connectPath},...t?.disconnectPath===void 0?{}:{disconnectPath:t.disconnectPath}})}}return n}function Tm(e,t){return t===void 0?void 0:e.kinds?.find(e=>e.id===t)}function Em(e,t,n){let r=e.kinds;if(r===void 0||r.length===0)return e;let i=r.filter(e=>e.functionCap===t&&(n===void 0||e.id===n));return i.length===0?null:{...e,kinds:i}}function Dm(e,t){let n=Em(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 Om(e){return(e.kinds?.length??0)>1}function km(e,t,n){return Om(e)&&t!==void 0?t.label:n}function Am(e){return e.label!==void 0&&e.label.length>0?e.label:e.state}function jm(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 Mm={error:3,unknown:2,ok:1,off:0};function Nm(e){return e.enabled?e.status===void 0?e.configured?`ok`:`unknown`:e.status.state:`off`}function Pm(e){let t=null;for(let n of e){let e=Nm(n);(t===null||Mm[e]>Mm[t])&&(t=e)}return t??`unknown`}function Fm(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:Pm(a)}:{addonId:e.addonId,name:r,count:1,health:o.isActive?`ok`:`off`}})}function Im(e,t){return t===null?e:e.filter(e=>e.addonId===t)}function Lm(e){return e.filter(e=>e.description.instanceMode===`multiple`||e.instances.length===0)}function Rm(e){return e.some(e=>e.isError)?`error`:e.some(e=>e.isPending)?`pending`:`ready`}function zm(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(!zm(n[e],r[e]))return!1;return!0}var Bm=`enabled`;function Vm(e,t){return t?.sections.some(e=>e.fields.some(e=>e.key===Bm))===!0?{...e}:Object.fromEntries(Object.entries(e).filter(([e])=>e!==Bm))}function Hm(e,t){let n={};for(let[r,i]of Object.entries(t))i!==void 0&&(zm(e[r],i)||(n[r]=i));return n}function Um(e,t){let n={...e};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function Wm(e,t,n){return e===`single`?t:`inst-${n()}`}function Gm(){let e=crypto.getRandomValues(new Uint8Array(4));return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}var Km=`+`;function qm(e,t){return t===void 0?e:`${e}:${t===null?Km:t}`}function Jm(e){let t=e.indexOf(`:`);if(t<0)return{kind:`fixed`,addonId:e};let n=e.slice(0,t),r=e.slice(t+1);return r===Km?{kind:`create`,addonId:n}:{kind:`instance`,addonId:n,id:r}}function Ym(e,t){return e.filter(e=>e.formValues.smtpInstanceId===t).map(e=>e.name)}var Xm=/^[a-z0-9][a-z0-9-]{0,63}$/;function Zm(e,t){return t===``?`empty`:e.pattern.test(t)?`ok`:`invalid`}O();var Qm=5e3,$m=`integration-instances`,eh=`provider-instances-holder`;function th(e){let t=new Map;for(let n of e){let e=n?.manifest;typeof e?.id==`string`&&typeof e.description==`string`&&e.description.length>0&&t.set(e.id,e.description)}return t}function nh(e){let t=W(),n=xi({capName:e},{refetchInterval:Qm}),r=xi({capName:$m},{refetchInterval:Qm}),i=pi(void 0,{refetchInterval:Qm}),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:[eh,e],refetchInterval:Qm,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=Rm([n,r,...o]),c=m(()=>o.flatMap(t=>{let n=t.data===void 0?null:Dm(t.data,e);return n===null?[]:[n]}),[o,e]),l=m(()=>Cm(i.data??[]),[i.data]),u=m(()=>th(i.data??[]),[i.data]),d=m(()=>wm({functionProviders:a,holders:c,displayNames:l,descriptions:u}),[a,c,l,u]),f=n.error??r.error??o.find(e=>e.error)?.error??null,p=b(()=>{n.refetch(),r.refetch();for(let e of o)e.refetch()},[n,r,o]);return{state:s,error:f===null?null:f.message,functionProviders:a,rows:d,holders:c,displayNames:l,descriptions:u,refetch:p}}O();var rh=`name`,ih=`kind`,ah=`restore`,oh=`restoreId`,sh=`typedId`,ch={};function lh({addonId:e,providerName:t,description:n,instance:r,onClose:i,onSaved:a,lead:o,typedId:c}){let{t:l}=J(),u=W(),d=N(),f=r?.id??null,h=n.kinds??[],g=km(n,Tm(n,r?.kind??h[0]?.id),t),[_,v]=w({[rh]:r?.name??g,[ih]:r?.kind??h[0]?.id??``,[ah]:!1,[oh]:``,[sh]:``}),y=p(g),b=_[ih];S(()=>{if(r!==null||typeof b!=`string`)return;let e=km(n,Tm(n,b),t),i=y.current;y.current=e,v(t=>t[rh]===i?{...t,[rh]:e}:t)},[b,n,r,t]);let C=e=>{let t=_[e];return typeof t==`string`?t.trim():``},T=C(rh),D=C(ih),O=Tm(n,D===``?void 0:D),k=_[ah]===!0,A=C(oh),j=r===null&&n.allowRestoreId===!0&&O?.signIn===void 0,M=j&&k&&A===``,F=r===null&&O?.signIn===void 0&&!(j&&k)?c?.(D===``?void 0:D):void 0,L=C(sh),ee=F===void 0?`ok`:Zm(F,L),[R,te]=w({...r?.formValues??ch}),[ne,ie]=w(null),ae=m(()=>({sections:[{id:`instance-identity`,title:l(`providerInstances.identity`,`Identity`),columns:1,fields:[...r===null&&Om(n)?[{type:`select`,key:ih,label:l(`providerInstances.colKind`,`Kind`),options:h.map(e=>({value:e.id,label:e.label}))}]:[],{type:`text`,key:rh,label:l(`providerInstances.colName`,`Name`),required:!0},...F===void 0?[]:[{type:`text`,key:sh,label:l(`providerInstances.typedId`,`Id`),required:!0,description:ee===`invalid`?l(`providerInstances.typedIdInvalid`,`Lowercase letters, digits and dashes, starting with a letter or digit (up to 64).`):l(`providerInstances.typedIdHint`,`Chosen once; it cannot be changed after the record is created.`)}],...j?[{type:`boolean`,key:ah,label:l(`providerInstances.restore`,`Restore under its old id`),description:l(`providerInstances.restoreHint`,`Re-adding something that was removed under its original id keeps everything that points at it working.`)},{type:`text`,key:oh,label:l(`providerInstances.originalId`,`Original id`),required:!0,showWhen:{field:ah,equals:!0}}]:[]]}]}),[j,n,F,r,h,l,ee]),[oe,se]=w(null),z=f===null&&D!==``?D:void 0,B=E({queryKey:[`provider-instance-form`,e,f,z??null],queryFn:()=>u.trpcClient.integrationInstances.instanceFormSchema.query({addonId:e,id:f,...z===void 0?{}:{kind:z}})}),V=m(()=>r===null?ch:Vm(r.formValues,B.data),[r,B.data]),ce=m(()=>Vm(R,B.data),[R,B.data]),le=m(()=>B.data?Ft(B.data,{...V}):null,[B.data,V]),ue=(O?.widgets??[]).flatMap(e=>{let t=e.placement===`connection`?xm(e.id):null;return t===null?[]:[{id:e.id,widget:t}]}),de=le===null?[]:ue.flatMap(({widget:e})=>e.ownedKeys(le,R)),fe=P({mutationFn:async()=>{let t=u.trpcClient.integrationInstances,i=Hm(V,ce);if(r===null){let r=j&&k?A:F===void 0?n.mintsId===!0?void 0:Wm(n.instanceMode,e,Gm):L,a=await t.createInstance.mutate({addonId:e,name:T,...r===void 0?{}:{id:r},...D===``?{}:{kind:D}});return Object.keys(i).length>0&&await t.updateInstance.mutate({addonId:e,id:a.id,values:i}),a.id}return await t.updateInstance.mutate({addonId:e,id:r.id,name:T,values:i}),r.id},onSuccess:e=>{d.invalidateQueries({queryKey:[eh]}),im({title:l(`providerInstances.saved`,`Saved`),message:T,severity:`info`}),a?.(e),i()},onError:e=>ie(e.message)}),pe=P({mutationFn:()=>u.trpcClient.integrationInstances.testInstance.mutate({addonId:e,id:f,values:Hm(V,ce)}),onSuccess:e=>se(em(e)),onError:e=>se({status:`inconclusive`,error:e.message})});return x(Hn,{open:!0,onClose:i,title:r===null?l(`providerInstances.createTitle`,`Add {{provider}}`,{provider:km(n,O,t)}):l(`providerInstances.editTitle`,`Edit {{name}}`,{name:r.name}),error:ne??(B.isError?B.error.message:null),width:`lg`,footer:s(I,{children:[n.canTest&&s(K,{size:`sm`,variant:`outline`,type:`button`,disabled:pe.isPending||le===null,onClick:()=>{se(null),pe.mutate()},children:[pe.isPending?x(U,{className:`h-3.5 w-3.5 animate-spin`}):null,l(`providerInstances.test`,`Test connection`)]}),s(K,{size:`sm`,type:`button`,disabled:fe.isPending||le===null||T.length===0||M||ee!==`ok`,onClick:()=>{ie(null),fe.mutate()},children:[fe.isPending?x(U,{className:`h-3.5 w-3.5 animate-spin`}):null,r===null?l(`providerInstances.create`,`Create`):l(`providerInstances.saveChanges`,`Save changes`)]})]}),children:s(`div`,{className:`space-y-4`,children:[r===null?null:o,x($p,{schema:ae,values:_,onChange:v}),O?.signIn!==void 0&&x(ru,{basePath:O.signIn.basePath,...O.signIn.methods===void 0?{}:{methods:O.signIn.methods},name:T,...r===null?{}:{brokerId:r.id},getSettings:()=>Um(V,ce),disabled:T.length===0,onSignedIn:e=>{d.invalidateQueries({queryKey:[`provider-instances-holder`]}),a?.(e),i()}}),r!==null&&O?.connectPath!==void 0&&s(K,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>Ol(Tl(O.connectPath??``,r.id),()=>void d.invalidateQueries({queryKey:[`provider-instances-holder`]})),children:[x(re,{className:`h-3.5 w-3.5`}),l(`providerInstances.connect`,`Connect account`)]}),le===null?B.isError?null:s(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[x(U,{className:`h-3 w-3 animate-spin`}),l(`providerInstances.loading`,`Loading…`)]}):s(I,{children:[x(Vn,{schema:Sm(le,de),values:R,onChange:te}),ue.map(({id:e,widget:{Component:t}})=>x(t,{schema:le,values:R,onValuesChange:te},e))]}),oe!==null&&x(nm,{verdict:oe})]})})}O();var uh=`integration-instances`,dh=`instance-kinds-describe`;function fh(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(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}})}return n}function ph(e){let t=W(),n=xi({capName:e.functionCap}),r=xi({capName:uh}),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:[dh,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(()=>fh(a,e),[a,e.functionCap,e.addonId,e.kind]),holders:a,isLoading:n.isLoading===!0||r.isLoading===!0||i.some(e=>e.isLoading)}}function mh({children:e,onClose:t}){return x(Kn,{open:!0,onOpenChange:e=>!e&&t(),children:s(er,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[x(Fn,{children:x(_r,{children:`\xA0`})}),x(Qn,{children:e})]})})}function hh({functionCap:e,kind:t,addonId:n,onClose:r,onSaved:i,typedId:a}){let{t:o}=J(),s=W(),c=N(),l=ph({functionCap:e,...n===void 0?{}:{addonId:n},...t===void 0?{}:{kind:t}}),u=l.options[0],d=n??u?.addonId,f=E({queryKey:[`instance-create-description`,d,e,u?.kind??null],enabled:d!==void 0,queryFn:async()=>Em(await s.trpcClient.integrationInstances.describe.query({addonId:d??``}),e,u?.kind)});return d===void 0||f.data===null?x(mh,{onClose:r,children:d===void 0&&l.isLoading?x(U,{className:`h-4 w-4 animate-spin`}):x(yr,{message:o(`brokers.editor.noProvider`)})}):f.isError?x(mh,{onClose:r,children:x(yr,{message:f.error.message})}):f.data===void 0?x(mh,{onClose:r,children:x(U,{className:`h-4 w-4 animate-spin`})}):x(lh,{addonId:d,providerName:u?.label??``,description:f.data,instance:null,onClose:r,...a===void 0?{}:{typedId:a},onSaved:e=>{c.invalidateQueries(),i(e)}})}O();var gh={ok:`success`,off:`default`,unknown:`default`,error:`danger`};function _h({kind:e,value:t,onChange:n,optional:r=!1,noneLabel:i,disabled:a=!1}){let{t:o}=J(),[c,l]=w(!1),u=Er({kind:e}),d=Jr(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(U,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.picker.loading`)]}),u.isError&&x(yr,{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(Bn,{variant:gh[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(Se,{className:`h-3.5 w-3.5`}),` `,o(`brokers.picker.createNew`)]}),c&&x(hh,{functionCap:`broker`,kind:e,onClose:()=>l(!1),onSaved:e=>{l(!1),n(e)}})]})}var vh=`broker`;function yh({functionCap:e,kind:t,noneLabel:n,required:r,disabled:i,value:a,onChange:o}){return e===vh&&t!==void 0?x(_h,{kind:t,value:a,onChange:o,optional:r===!1,disabled:i===!0,...n===void 0?{}:{noneLabel:n}}):x(Qr,{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`}`})}function bh(e,t){return t.map(t=>({subject:{kind:`device`,deviceId:e},key:t.key,scope:t.scope}))}function xh({deviceId:e}){let{t}=J(),{presence:n,list:r}=In(e);return n===`absent`?null:n===`unknown`?x(yr,{message:t(`deviceQuickDetail.historyUnknown`,`Could not tell whether this device has recorded history.`)}):n===`pending`||r.status===`pending`?x(cr,{className:`h-24 w-full`,"aria-busy":`true`}):r.status===`error`?x(yr,{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(Pc,{to:$r(bh(e,r.data)),className:`text-xs text-primary hover:underline`,children:t(`deviceQuickDetail.openHistory`,`Open full history`)})}),x(Ri,{deviceId:e})]})}function Sh(e,t){return e===`present`&&t.status===`ok`&&(t.data?.length??0)>0}var Ch={streaming:{icon:An,labelKey:`capabilityBadges.streaming`},detection:{icon:ve,labelKey:`capabilityBadges.detection`},recording:{icon:ae,labelKey:`capabilityBadges.recording`},audio:{icon:Qe,labelKey:`capabilityBadges.audio`},snapshot:{icon:we,labelKey:`capabilityBadges.snapshot`},motion:{icon:ot,labelKey:`capabilityBadges.motion`},ptz:{icon:it,labelKey:`capabilityBadges.ptz`},webrtc:{icon:z,labelKey:`capabilityBadges.webrtc`},onvif:{icon:Re,labelKey:`capabilityBadges.onvif`},analytics:{icon:Ze,labelKey:`capabilityBadges.analytics`},"battery-operated":{icon:qe,labelKey:`capabilityBadges.battery`},"native-snapshot":{icon:we,labelKey:`capabilityBadges.nativeSnapshot`},"pan-tilt-zoom":{icon:it,labelKey:`capabilityBadges.ptz`},"two-way-audio":{icon:Qe,labelKey:`capabilityBadges.twoWayAudio`},"doorbell-button":{icon:ke,labelKey:`capabilityBadges.doorbell`},rebootable:{icon:_e,labelKey:`capabilityBadges.rebootable`},"vacuum-has-map":{icon:kn,labelKey:`capabilityBadges.map`},"vacuum-has-ai":{icon:Ye,labelKey:`capabilityBadges.aiObstacle`},"mower-has-map":{icon:kn,labelKey:`capabilityBadges.map`},"mower-has-targeted-mowing":{icon:te,labelKey:`capabilityBadges.targetedMowing`}},wh=B;function Th({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=Ch[e],i=r?.icon??wh,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)})})}O();var Eh={amcrest:{icon:Mn,color:`#3b82f6`,label:`Amcrest`},hikvision:{icon:be,color:`#a855f7`,label:`Hikvision`},reolink:{icon:z,color:`#06b6d4`,label:`Reolink`},homeassistant:{icon:pe,color:`#22d3ee`,label:`Home Assistant`},rtsp:{icon:nt,color:`#78716c`,label:`RTSP`},onvif:{icon:nt,color:`#78716c`,label:`ONVIF`}},Dh={sm:`h-4 w-4`,md:`h-5 w-5`,lg:`h-6 w-6`,xl:`h-16 w-16`},Oh={sm:`h-7 w-7`,md:`h-8 w-8`,lg:`h-10 w-10`,xl:`h-16 w-16`};function kh(e){let t=e.toLowerCase();return t.startsWith(`provider-`)?t.slice(9):t}function Ah(e){return Eh[kh(e)]??{icon:Mn,color:`#78716c`,label:e}}function jh({type:e,size:t=`md`,showLabel:n}){let r=Ah(e),i=r.icon,[a,o]=w(!1),c=ua(e);return s(`div`,{className:`flex items-center gap-2`,children:[x(`div`,{className:`flex items-center justify-center rounded-lg ${Oh[t]}`,style:{backgroundColor:`${r.color}15`},children:a||!c?x(i,{className:Dh[t],style:{color:r.color}}):x(`img`,{src:c,alt:r.label,className:Dh[t],onError:()=>o(!0)})}),n&&x(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:r.label})]})}function Mh({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:`${xe} 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 Nh(e){return Yn({addonId:e,projection:`slim`})}function Ph(e){return gr({deviceId:e},{enabled:Number.isFinite(e)})}var Fh=3e4,Ih=2e3;function Lh(e){let t=p(0);return t.current===0&&(t.current=Date.now()),Bi({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>=Fh?!1:Ih}})}O();function Rh({deviceId:e}){let{t}=J(),n=N(),{data:r}=Ph(e),{data:i}=Lh(e),[a,o]=w(null),c=qr({onSuccess:()=>{o(null),n.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{o(`Could not change primary child: ${e.message}`)}});if(r==null||String(r.type??``)!==Dt.Container)return null;let l=String(r.name??``),u=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:fi(e,l),...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}}));if(u.length<=1)return null;let d=Dr(u,typeof r.linkDeviceId==`number`?r.linkDeviceId:null,typeof r.primaryChildEntityId==`string`?r.primaryChildEntityId:null),f=d===null?u[0].id:d.id;return s(I,{children:[x(Mh,{label:t(`shared.primaryChildRow.primaryChild`,`Primary child`),value:x(vi,{childrenList:u,selectedId:f,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 zh=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`];function Bh(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function Vh(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function Hh(){let{t:e}=J(),t=Tr(),n=ki(),{data:r}=gr({deviceId:t??0},{enabled:t!==null}),{data:i}=lr({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=_!==null&&Object.keys(_).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`)}),v&&s(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[x(Uh,{active:o===`identity`,onClick:()=>c(`identity`),label:e(`overviewAdapters.deviceInfoAdapter.identity`,`Identity`)}),x(Uh,{active:o===`hardware`,onClick:()=>c(`hardware`),label:e(`overviewAdapters.deviceInfoAdapter.hardware`,`Hardware`)})]})]}),(!v||o===`identity`)&&s(`div`,{className:`divide-y divide-border`,children:[x(Mh,{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(Rh,{deviceId:t}),d!==null&&x(Mh,{label:e(`overviewAdapters.deviceInfoAdapter.integration`,`Integration`),value:x(`span`,{className:`font-mono text-[11px]`,children:d})}),f!==null&&x(Mh,{label:e(`overviewAdapters.deviceInfoAdapter.parent`,`Parent`),value:x(`span`,{className:`font-mono text-[11px]`,children:`#${String(f)}`})}),x(Mh,{label:e(`overviewAdapters.deviceInfoAdapter.provider`,`Provider`),value:x(jh,{type:u,size:`sm`,showLabel:!0})}),x(Mh,{label:e(`overviewAdapters.deviceInfoAdapter.capabilities`,`Capabilities`),value:g.length>0?x(Th,{capabilities:g,showLabels:!0}):x(`span`,{className:`text-[11px] text-foreground-subtle`,children:e(`overviewAdapters.deviceInfoAdapter.none`,`None`)})})]}),v&&o===`hardware`&&x(Wh,{metadata:_})]})}function Uh({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 Wh({metadata:e}){let{t}=J(),n=zh.filter(t=>t in e),r=Object.keys(e).filter(e=>!zh.includes(e)).toSorted(),i=[...n,...r];return s(`div`,{children:[x(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border bg-surface-subtle/40`,children:t(`overviewAdapters.deviceInfoAdapter.autoPopulatedByTheDriver`,`Auto-populated by the driver on every connect. Read-only.`)}),x(`div`,{className:`divide-y divide-border`,children:i.map(t=>x(Mh,{label:Bh(t),value:x(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:Vh(e[t])})},t))})]})}function Gh(e,t){return e.icon===t.icon&&e.label===t.label&&e.unit===t.unit&&e.precision===t.precision&&e.hidden===t.hidden}function Kh(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function qh(e){if(e.trim()===``)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function Jh(e,t){let n=qh(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 Yh(e){let t=Kh(e.display);return{name:e.name,location:e.location,role:e.role,display:t,baseName:e.name,baseLocation:e.location,baseRole:e.role,baseDisplay:t,persistedDisplay:e.display}}function Xh(e,t){if(e===null)return Yh(t);let n=Kh(t.display),r=e.name===t.name&&e.location===t.location&&e.role===t.role&&Gh(e.display,n);return!Zh(e)||r?Yh(t):e}function Zh(e){return e===null?!1:e.name!==e.baseName||e.location!==e.baseLocation||e.role!==e.baseRole||!Gh(e.display,e.baseDisplay)}function Qh(e){return e.name.trim().length===0?`name`:null}function $h(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},...Gh(e.display,e.baseDisplay)?{}:{display:Jh(e.display,e.persistedDisplay)}}}function eg(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 tg=j(null);function ng(){return L(tg)}function rg({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=Xh(a,t);(a===null||e.name!==a.name||e.location!==a.location||e.role!==a.role||!Gh(e.display,a.display)||e.baseName!==a.baseName||e.baseLocation!==a.baseLocation||e.baseRole!==a.baseRole||!Gh(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})},setIdentityDisplay:e=>{o(t=>t===null?t:{...t,display:{...t.display,...e}})},register:u}),[a,u]);return x(tg.Provider,{value:d,children:x(ig,{deviceId:e,identity:a,contributions:s,onIdentitySaved:e=>o(e),showOpenFull:n,onClose:r,children:i})})}function ig({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:i,onClose:a,children:o}){return s(I,{children:[o,x(og,{deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:i,onClose:a})]})}function ag(e){return e instanceof Error?e.message:String(e)}function og({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:i,onClose:a}){let{t:o}=J(),c=ms(),l=Pe(),u=N(),[d,f]=w(null),[p,m]=w(!1),h=si(),g=Oi(),_=Hr(),v=ri(),y=eg([{dirty:Zh(t),saving:p,error:d},...n]),b=()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})};return!y.dirty&&!y.saving&&y.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:[y.error!==null&&x(`p`,{className:`text-xs text-danger`,children:y.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()=>{y.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});for(let e of n)e.discard();f(null)},disabled:!y.dirty||y.saving,children:o(`deviceQuickDetail.discard`,`Discard`)}),x(K,{type:`button`,size:`sm`,onClick:()=>{if(t!==null&&Zh(t)&&Qh(t)===`name`){f(o(`deviceQuickDetail.nameRequired`,`Name is required`));return}f(null),m(!0),(async()=>{try{let i=t===null?{}:$h(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.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,persistedDisplay:i.display===void 0?t.persistedDisplay:i.display??void 0})}for(let e of n)e.dirty&&await e.save();b()}catch(e){f(ag(e))}finally{m(!1)}})()},disabled:!y.dirty||y.saving,children:y.saving?o(`deviceQuickDetail.saving`,`Saving…`):o(`deviceQuickDetail.save`,`Save`)})]})]})]})}function sg(e){return e.hubReachable?e.authOk===!1?{kind:`auth-expired`}:{kind:`cluster-degraded`,offlineAgents:e.offlineAgents,offlineAgentIds:e.offlineAgentIds}:{kind:`hub-unreachable`}}function cg(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 lg=4e3,ug=5e3;function dg(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 fg(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 pg(e){let t=e.fetchFn??fetch,n=e.timeoutMs??lg,r=e.origin.replace(/\/+$/,``),i;try{i=await fg(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 fg(t,`${r}/health/details`,n,{Authorization:`Bearer ${o}`});e.ok&&(a=await e.json())}catch{}let s;try{s=dg(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 fg(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 mg={kind:`connected`},hg={kind:`reconnecting`};function gg(e){let t=e.probeIntervalMs??ug,n=new Set,r=mg,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(sg(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(mg);return}if(e===`connecting`){c(),s(hg);return}(r.kind===`connected`||r.kind===`reconnecting`)&&s(hg),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 _g=null;function vg(){return _g===null&&(_g=gg({probe:()=>pg({origin:Oe(),getToken:()=>localStorage.getItem(`camstack_admin_token`)})})),_g}function yg(e){vg().onSdkConnectionState(e)}function bg(e){return e===`connected`}function xg(e){M.setOnline(bg(e))}var Sg=null,Cg=0;function wg(){if(!Sg){let e=Cg;Sg=Rn({serverUrl:Oe(),token:localStorage.getItem(`camstack_admin_token`)??void 0,getLanguage:()=>q.language,refreshCredential:async e=>{e===`rejected`?await Vg().refreshNow():await Vg().ensureFresh()},onConnectionChange:t=>{e===Cg&&(yg(t),xg(t))}})}return Sg}function Tg(){let e=Sg;Sg=null,Cg+=1,e?.close()}var Eg=`camstack_admin_token`,Dg=`camstack_admin_refresh`,Og=`camstack_admin_token_expires`;function kg(e){try{let t=localStorage.getItem(e);return t!==null&&t.length>0?t:null}catch{return null}}function Ag(e,t){try{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}function jg(){let e=kg(Eg);if(e===null)return null;let t=kg(Dg),n=Number(kg(Og));return{token:e,...t===null?{}:{refreshToken:t},...Number.isFinite(n)&&n>0?{expiresAt:n}:{}}}function Mg(e){Ag(Eg,e.token),Ag(Dg,e.refreshToken??null),Ag(Og,e.expiresAt===void 0?null:String(e.expiresAt))}function Ng(){Ag(Eg,null),Ag(Dg,null),Ag(Og,null)}function Pg(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 Fg(e){await fetch(H(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}var Ig=new Set;function Lg(e){return Ig.add(e),()=>Ig.delete(e)}var Rg=new Set;function zg(e){return Rg.add(e),()=>Rg.delete(e)}var Bg=null;function Vg(){return Bg===null&&(Bg=new Ni({refresh:async e=>{let t=jg();if(t?.refreshToken!==void 0&&t.refreshToken!==e&&(t.expiresAt??0)>Date.now()+6e4)return t;let n=await wg().refreshSession(e);return{token:n.token,refreshToken:n.refreshToken,expiresAt:n.expiresAt}},onTokens:e=>{Mg(e),wg().setToken(e.token),Fg(e.token);for(let e of Rg)e()},onExpired:()=>{Ng();for(let e of Ig)e()}})),Bg}function Hg(e){Mg(e),Vg().adopt(e)}async function Ug(e){try{await Vg().ensureFresh()}catch(e){console.warn(`[admin-session] pre-reconnect refresh failed; reconnecting anyway`,e)}e()}async function Wg(){return await Vg().refreshNow()!==null}var Gg=512;function Kg(e){if(!e||e.length>Gg)return null;let t=ct(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 qg=/^[A-Za-z0-9_-]{43,128}$/,Jg=/^[A-Za-z0-9._~-]{1,256}$/;function Yg(e){let{codeChallenge:t,state:n}=e;return!t||!qg.test(t)||(e.codeChallengeMethod??`S256`)!==`S256`||!n||!Jg.test(n)?null:{codeChallenge:t,state:n,purpose:e.purpose===`step-up`?`step-up`:`new-session`}}var Xg=`camstack:login-app-handoff`;function Zg(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 Yg({codeChallenge:n(`codeChallenge`),state:n(`state`),purpose:n(`purpose`)})}catch{return null}}function Qg(e,t=Date.now()){e!==null&&u_(Xg,JSON.stringify(e),Zg,t)}function $g(e=Date.now()){return d_(Xg,Zg,e)}function e_(e,t,n){return`${e}?${`code=${encodeURIComponent(t)}`}${n===void 0?``:`&state=${encodeURIComponent(n)}`}`}function t_(e,t=Date.now()){return m_(t)??Kg(e)}var n_=2048;function r_(e){return!e||e.length>n_||!e.startsWith(`/`)||e.startsWith(`//`)||e.includes(`\\`)||e.includes(`://`)||e.includes(`..`)||e===`/login`||e.startsWith(`/login?`)||e.startsWith(`/login/`)?null:e}function i_(e,t=Date.now()){u_(c_,e,r_,t)}function a_(e=Date.now()){return d_(c_,r_,e)}function o_(e,t=Date.now()){return a_(t)??r_(e)}var s_=`camstack:login-redirect`,c_=`camstack:login-next`,l_=10*6e4;function u_(e,t,n,r){let i=f_();if(!i||!n(t))return;let a={raw:t??``,at:r};try{i.setItem(e,JSON.stringify(a))}catch{}}function d_(e,t,n){let r=f_();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>l_?null:t(a)}catch{return null}}function f_(){if(typeof window>`u`)return null;try{return window.sessionStorage}catch{return null}}function p_(e,t=Date.now()){u_(s_,e,Kg,t)}function m_(e=Date.now()){return d_(s_,Kg,e)}var h_=`changeme`;function g_(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:__(n.scopes)}}catch{return null}}function __(e){return rn(sn(e))}function v_(e){let t=g_(e);return t?t.exp*1e3<Date.now():!0}O();var y_=h_;function b_(e){return{token:e.token,...e.refreshToken===void 0?{}:{refreshToken:e.refreshToken},...e.expiresAt===void 0?{}:{expiresAt:e.expiresAt}}}async function x_(e,t){if(await Fg(e),t.kind===`path`){window.location.replace(H(t.path));return}try{Tg();let e=$g();if(e===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await wg().trpcClient.auth.createHandoffCode.mutate({purpose:e.purpose,codeChallenge:e.codeChallenge,state:e.state});window.location.replace(e_(t.url,n,e.state))}catch{window.location.replace(H(`/`))}}async function S_(e,t){await Fg(e),window.location.replace(H(t))}var C_=j(null);function w_({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=Pg(e),n=t?.token??null;if(t!==null&&n!==null){Hg(t);let r=m_();if(r){x_(n,r);return}let i=a_()??r_(e.get(`next`));if(i){S_(n,i);return}window.history.replaceState({},``,H(`/`))}}s()},[]);let s=async()=>{let e=jg();if(e===null){i(!1);return}let t=e.token;if(e.refreshToken!==void 0){let n=Vg();n.adopt(e),await n.ensureFresh();let r=jg();if(r===null){console.warn(`[auth] session restore: signed out — the hub refused the refresh token`),Tg(),i(!1);return}t=r.token}if(v_(t)){console.warn(`[auth] session restore: signed out — access token expired and no refresh recovered it`),Ng(),Tg(),i(!1);return}let r=g_(t);if(!r){console.warn(`[auth] session restore: signed out — the stored access token is unreadable`),Ng(),Tg(),i(!1);return}Fg(t);let a=wg();a.trpcClient.system.info.query().then(()=>n(r)).catch(async e=>{let t=e?.data?.code;if(t===`UNAUTHORIZED`||t===`FORBIDDEN`){if(await Wg()){a.reconnect();try{await wg().trpcClient.system.info.query();let e=jg();n(e&&g_(e.token)||r);return}catch{}}console.warn(`[auth] session restore: logout, probe UNAUTHORIZED and refresh did not recover it`),Vg().stop(),Ng(),Tg()}else n(r)}).finally(()=>i(!1))};S(()=>Lg(()=>{Tg(),n(null),o(!1)}),[]);let c=b(async(e,t)=>{let r=await wg().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 Hg(b_(r)),await Fg(a),Tg(),n(g_(a)),o(t===y_),{kind:`ok`}},[]),l=b(async(e,t)=>{let r=await wg().loginVerifyTotp(e,t,{refreshable:!0}),i=r.token;Hg(b_(r)),await Fg(i),Tg(),n(g_(i)),o(!1)},[]),u=b(async(e,t)=>{Hg({token:e,...t}),await Fg(e),Tg(),n(g_(e)),o(!1)},[]),d=b(()=>{wg().logout().catch(()=>{}),Vg().stop(),Ng(),fetch(H(`/api/auth/session`),{method:`DELETE`}).catch(()=>{}),Tg(),n(null),o(!1)},[]),f=b(()=>{o(!1)},[]);return x(C_.Provider,{value:{user:t,loading:r,mustChangePassword:a,login:c,verifyTotp:l,finalizePasskeyLogin:u,logout:d,clearMustChangePassword:f},children:e})}function T_(){let e=L(C_);if(!e)throw Error(`useAuth must be used within AuthProvider`);return e}O();function E_(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 D_({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&&(E_(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 O_({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 k_({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 A_({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(O_,{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($p,{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(k_,{tabs:b.map(e=>({id:e.id,label:e.label})),activeId:A,onChange:j,countByTab:I,pendingByTab:L}),x(ti,{tabKey:A,children:M===void 0?x($p,{schema:P,values:t,onChange:r,onAction:i,disabled:c,visibilityContext:f}):M.content}),F]})}var j_=`device-export`,M_=`export`,N_=`Export`;function P_(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(P_):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(P_)):e.writerCapName===j_}function F_(e){return e.tab===`export`?!0:e.fields.some(P_)}var I_=`host/extensions-panel`;function L_(e){return e.type===`widget`?e.widgetId===I_:e.type===`group`?e.fields.some(L_):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(L_)):!1}function R_(e){return e.fields.some(L_)}function z_(e,t){return!t&&e!==void 0&&un.includes(e)}function B_(e){return e.location!==`top-tab`&&e.location!==`hero`&&!F_(e)&&!R_(e)}function V_(e,t,n,r){return!r||z_(t,n)?!0:(e??[]).some(B_)}function H_(e,t){for(let n of e){if(n.type===`group`){H_(n.fields,t);continue}if(n.type===`sub-tabs`){for(let e of n.tabs)H_(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 U_(e){let t={};for(let n of e)H_(n.fields,t);return t}O();function W_(e,t){return t&&t===`admin`?e:!0}function G_(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?F_(e)&&F_(t)?e.id.localeCompare(t.id):(e.order??0)-(t.order??0):n.localeCompare(r)})};return e.tabs?{...t,tabs:e.tabs}:t}function K_(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 q_(e){return e.key}function J_(e){if(!K_(e))return e.value}function Y_(e){return K_(e)?null:e}function X_(e,t){for(let n of e)if(t(n),n.type===`group`)X_(n.fields,t);else if(n.type===`sub-tabs`)for(let e of n.tabs)X_(e.fields,t)}function Z_(e){if(!e)return{};let t={};for(let n of e.sections)X_(n.fields,e=>{let n=q_(e);n!==null&&(t[n]=J_(e))});return t}function Q_(e,t){if(!e)return null;let n=null;for(let r of e.sections)if(X_(r.fields,e=>{if(n!==null||q_(e)!==t)return;let r=Y_(e);r&&r.writerCapName&&r.writerAddonId&&(n={capName:r.writerCapName,addonId:r.writerAddonId})}),n!==null)break;return n}function $_(e){return{...e,fields:e.fields.map(ev)}}function ev(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`object-array`?e:{...e,readonlyField:!0}}function tv(e,t){return e&&{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{let n=Y_(e);return n?W_(t,n.minRole)?e:ev(e):e})}))}}var nv={sections:[]};function rv({deviceId:e,sectionFilter:t,activeSubTab:n,onSubTabChange:r,flattenSubTabs:i,subTabGrouping:a,leadingTabs:o}){let{t:c}=J(),l=N(),{user:u}=T_(),d=u?.isAdmin===!0,f=p(!1),{data:h,isLoading:g}=Zn({deviceId:e},{refetchInterval:()=>f.current?!1:2500,enabled:Number.isFinite(e)}),{data:_}=gr({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($_),r=[...e,...n],i=t?r.filter(t):r.filter(B_);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(()=>U_([...v?.sections??[],...y?.sections??[]]),[v,y]),T=m(()=>G_(C),[C]),E=m(()=>tv(T,d),[T,d]),D=m(()=>Z_(E),[E]),O=Wr(),k=ii(),A=jr(),j=Fr(),M=Li({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),P={isPending:M.isPending,mutate:t=>{M.mutate({deviceId:e,changes:[...t]})}},F=D_({schema:E,serverValues:D,onImmediateSave:b(e=>{let t=Object.entries(e).map(([e,t])=>{let n=Q_(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=Q_(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:ee,handleSave:R,handleDiscard:te}=F;f.current=F.editingPaused;let ne=ng(),re=p(R),ie=p(te);re.current=R,ie.current=te;let ae=ne?.register,oe=M.isError?M.error instanceof Error?M.error.message:String(M.error):null,se=L.join(`\0`);S(()=>{if(ae===void 0)return;let e=se===``?[]:se.split(`\0`);return ae({id:`export`,dirty:e.length>0,saving:M.isPending,error:oe,save:()=>(re.current(e),Promise.resolve()),discard:()=>ie.current(e)})},[ae,se,M.isPending,oe]);let z=o!==void 0&&o.length>0;if(g&&!z)return s(`div`,{className:`flex items-center justify-center py-12 text-foreground-subtle`,children:[x(U,{className:`h-4 w-4 animate-spin mr-2`}),x(`span`,{className:`text-xs`,children:c(`device.deviceAggregateSection.loadingDeviceAggregate`,`Loading device aggregate…`)})]});if(!z&&(!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 B(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=nn(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=nn(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(A_,{schema:E??nv,values:I,pendingKeys:L,onChange:ee,onAction:B,onSave:R,onDiscard:te,hideSaveBar:ne!==null,disabled:P.isPending,activeSubTab:n,onSubTabChange:r,flattenTabs:i,leadingTabs:o,visibilityContext:w})}O();function iv({deviceId:e,onClose:t}){let{t:n}=J(),[r,i]=w(`info`),{data:a}=gr({deviceId:e},{enabled:e>0}),o=In(e),c=Sh(o.presence,o.list),l=r===`history`&&!c?`info`:r,u=typeof a?.name==`string`?a.name:``,d=mi(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(Kn,{open:!0,onOpenChange:e=>!e&&t(),children:x(er,{width:`lg`,scroll:`body`,children:s(rg,{deviceId:e,seed:a==null?null:{name:u,location:f,role:typeof a.role==`string`?a.role:null,display:a.display},showOpenFull:!0,onClose:t,children:[x(Fn,{children:x(_r,{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(Qn,{className:`mt-3`,children:s(Vr,{deviceId:e,device:a??void 0,children:[x(`div`,{className:l===`info`?void 0:`hidden`,children:x(Hh,{})}),x(`div`,{className:l===`export`?void 0:`hidden`,children:x(rv,{deviceId:e,sectionFilter:F_})}),c?x(`div`,{className:l===`history`?void 0:`hidden`,children:x(xh,{deviceId:e})}):null]})})]})})})}function av({children:e}){let[t,n]=w(null),r=b(e=>n(e),[]),i=b(()=>n(null),[]);return s(Cr,{open:r,children:[e,t===null?null:x(iv,{deviceId:t,onClose:i})]})}O();function ov({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 sv(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 cv(e){return`${e.inputSize.width}x${e.inputSize.height}`}function lv(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function uv({entry:e,selected:t,onSelect:n,disabled:r}){let{t:i}=J(),a=sv(e),o=cv(e),c=lv(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(le,{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(Ze,{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 dv({field:e,value:t,onChange:n,disabled:r}){let{t:i}=J(),a=e.catalog??[],o=a.length>0,c=dt(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(ov,{tabs:u,active:d,onChange:f}),d===`catalog`&&o&&c&&x(zn,{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(uv,{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(he,{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(he,{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(Ie,{className:`h-3 w-3`})]})]})]})}function fv({to:e}){let{search:t}=X();return x(Z,{to:`${e}${t}`,replace:!0})}O();function pv(){return q.t(`helpers.keychainRevealHost.forbidden`)}function mv(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 hv(e){let t=mv(e);if(t===`FORBIDDEN`||t===`UNAUTHORIZED`)return pv();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 gv({children:e}){let t=Ti();return x(Si,{reveal:b(async e=>{try{return(await t.mutateAsync({ref:e})).value}catch(e){throw Error(hv(e))}},[t]),children:e})}O();function _v(){let e=W(),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}=ui(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=yv(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(vv,{toasts:s})})}function vv({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(ie,{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 yv(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 bv=`/system/settings`,xv=[{path:`/system/capabilities`,tab:`capabilities`}];function Sv(e,t=``){let n=new URLSearchParams(t);return n.delete(`tab`),n.set(`tab`,e),`${bv}?${n.toString()}`}var Cv=`/system/data`,wv=`/system/secrets`;function Tv(e=``){let t=new URLSearchParams(e),n=t.get(`view`);return t.delete(`view`),t.set(`tab`,`secrets`),n===`audit`&&t.set(`secretsView`,`audit`),`${Cv}?${t.toString()}`}function Ev({tab:e}){let{search:t,hash:n}=X();return x(Z,{to:`${Sv(e,t)}${n}`,replace:!0})}function Dv(){let{search:e,hash:t}=X();return x(Z,{to:`${Tv(e)}${t}`,replace:!0})}O();var Ov={info:{bg:`bg-info/10`,border:`border-info/30`,icon:he},warning:{bg:`bg-warning/10`,border:`border-warning/30`,icon:Ce},critical:{bg:`bg-danger/10`,border:`border-danger/30`,icon:He}};function kv({toast:e,onDismiss:t}){let n=Ov[e.severity]??Ov.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]),s(`div`,{className:`flex items-start gap-3 px-4 py-3 rounded-lg border ${n.border} ${n.bg} shadow-lg animate-in slide-in-from-right-5 fade-in duration-200`,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(Me,{className:`h-3.5 w-3.5 text-foreground-subtle`})})]})}function Av(){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 $n(void 0,{onData:e=>r(e)}),S(()=>am(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(kv,{toast:e,onDismiss:n})},e.id))})}function jv(e){return(t,n,r)=>e(t,{...typeof n==`string`?{defaultValue:n}:{defaultValue_one:n.one,defaultValue_other:n.other},...r})}var Mv=(e,t,n)=>jv(q.t.bind(q))(e,t,n);O();function Nv({children:e}){let{t}=J();return x(Ae,{t:m(()=>jv(t),[t]),children:e})}O();function Pv(e){if(typeof e!=`object`||!e)return;let{data:t}=e;return t?.code}function Fv(e,t){let n=Pv(e);return n===`UNAUTHORIZED`||n===`FORBIDDEN`?!0:/UNAUTHORIZED|FORBIDDEN/.test(t)}function Iv(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(Fv(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 Lv=3e4;function Rv(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>=Lv&&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 zv=`@camstack/ui-library`;function Bv(e){return typeof e==`object`&&!!e}var Vv=/^>=\s*(\d+)\.(\d+)\.(\d+)/,Hv=/^(\d+)\.(\d+)\.(\d+)/;function Uv(e){return e===null?null:[Number(e[1]),Number(e[2]),Number(e[3])]}function Wv(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 Gv(e,t){let n=[];for(let r of Object.values(e)){let e=r[zv];if(!(typeof e!=`object`||!e))for(let r of Object.values(e)){if(!Bv(r)||r.from!==t)continue;let e=r.shareConfig?.requiredVersion;typeof e==`string`&&n.push(e)}}return n}function Kv(e,t){let n=e===null?null:Uv(e.match(Hv));if(n===null||e===null)return null;for(let r of t){let t=Uv(r.match(Vv));if(t!==null&&Wv(n,t))return{required:t.join(`.`),host:e}}return null}O();function qv(){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(cr,{className:`h-7 w-48`}),x(cr,{className:`h-5 w-72 max-w-full`}),x(cr,{className:`h-40`})]})}function Jv({message:e}){let{t}=J();return x(`div`,{className:`p-2 sm:p-4`,"data-testid":`addon-page-error`,children:x(yr,{title:t(`layouts.addonPageLoader.failedTitle`,`This page could not be shown`),message:e})})}var Yv=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(Jv,{message:this.state.error.message})}};function Xv({resetKey:e,children:t}){return x(Yv,{resetKey:e,children:t})}function Zv({pageKey:e,children:t}){return x(Yv,{resetKey:e,children:x(y,{fallback:x(qv,{}),children:t})})}O();function Qv(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 $v=2e4;function ey(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 ty=new Map,ny=new Map,ry=new Set;function iy(e){return!e||typeof e!=`object`?!1:typeof e.default==`function`}var ay=class extends Error{problem;constructor(e){super(`ui-library ${e.host} is older than the ${e.required} this page requires`),this.problem=e}};function oy(e){let t=i()?.shareScopeMap;if(!t)return;let n=Kv(Ur,Gv(t,e));if(n!==null)throw new ay(n)}async function sy(e,t){let i=ty.get(e);if(i)return i;let a=ny.get(e);if(a)return a;ry.has(e)||(Kr(),r([{name:e,entry:H(t),type:`module`}],{force:!1}),ry.add(e));let o=n(`${e}/page`).then(n=>{if(oy(e),!iy(n))throw Error(`Addon page remote ${e} (${t}) does not expose a default React component on './page'`);return ty.set(e,n.default),ny.delete(e),n.default}).catch(t=>{throw ny.delete(e),oy(e),t});return ny.set(e,o),o}function cy(){let{t:e}=J(),{pagePath:t}=vs(),n=ms(),r=W(),{data:i,isError:a,error:o}=Jn(void 0),s=m(()=>i?Qv(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=ty.get(l);if(t){f(()=>t);return}f(null);let n=!1;return sy(l,u).then(e=>{n||f(()=>e)}).catch(t=>{n||h(t instanceof ay?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=ey(!s&&!a,$v),_=ey(c!==void 0&&!d&&!p,$v);return s?c?p?x(Jv,{message:p}):d?x(Zv,{pageKey:c.remoteName,children:x(d,{trpc:r.trpcClient,theme:{isDark:document.documentElement.classList.contains(`dark`)},navigate:e=>{n(e.startsWith(`/`)?e:`/${e}`)}})}):_?x(Jv,{message:e(`layouts.addonPageLoader.remoteStalled`,`The page did not load. Its addon may be starting or unreachable.`)}):x(qv,{}):x(`div`,{className:`flex items-center justify-center h-full text-foreground-subtle`,children:e(`layouts.addonPageLoader.addonPageNotFound`,`Addon page not found`)}):a?x(Jv,{message:o?.message??e(`layouts.addonPageLoader.listFailed`,`The page list could not be loaded.`)}):g?x(Jv,{message:e(`layouts.addonPageLoader.listStalled`,`The hub did not send the page list. Try again in a moment.`)}):x(qv,{})}var ly={"/system/pipeline":`pipeline-orchestrator`,"/system/history":`device-history`,"/system/ai":`llm`};function uy(e,t){return e.filter(e=>!e.adminOnly||t).map(e=>{let t=ly[e.path];return t===void 0?e:{...e,requiresCapability:t}})}function dy({t:e,isAdmin:t}){let n=uy([{label:e(`nav.devices`,`Devices`),icon:we,path:`/devices`},{label:e(`nav.integrations`),icon:V,path:`/integrations`},{label:e(`nav.build`,`Build-your-self`),icon:ye,path:`/build`,adminOnly:!0},{label:e(`nav.locations`,`Locations`),icon:Be,path:`/locations`,adminOnly:!0},{label:e(`nav.viewer`,`Viewer`),icon:En,path:`/live`}],t),r=uy([{label:e(`nav.library`,`Library`),icon:jn,path:`/library`,adminOnly:!0,keywords:[`People`,`Vehicles`,`Events`,`Scenes`,`plates`,`faces`,`detection-intelligence`]},{label:e(`nav.recordings`,`Recordings`),icon:De,path:`/recordings`,adminOnly:!0}],t),i=uy([{label:e(`nav.nodes`,`Nodes`),icon:ee,path:`/system/nodes`,adminOnly:!0},{label:e(`nav.history`,`History`),icon:fe,path:`/system/history`,adminOnly:!0,keywords:[`charts`,`graphs`,`energy`,`temperature`,`metrics`,`trends`]},{label:e(`nav.pipeline`,`Pipeline`),icon:wn,path:`/system/pipeline`},{label:e(`system.addons`),icon:st,path:`/system/addons`,adminOnly:!0},{label:e(`system.ai`,`AI`),icon:Ye,path:`/system/ai`,adminOnly:!0}],t),a=uy([{label:e(`system.identity`,`Identity & Access`),icon:je,path:`/system/identity`,adminOnly:!0},{label:e(`system.network`,`Network`),icon:Dn,path:`/system/network`,adminOnly:!0},{label:e(`system.integrations`,`Connectivity`),icon:V,path:`/system/integrations`,adminOnly:!0},{label:e(`system.data`,`Data`),icon:Ne,path:`/system/data`,adminOnly:!0},{label:e(`system.notifications`,`Notifications`),icon:ke,path:`/system/notifications`,adminOnly:!0},{label:e(`system.calendars`,`Calendars`),icon:Nn,path:`/system/calendars`,adminOnly:!0},{label:e(`system.templates`,`Templates`),icon:vn,path:`/system/templates`,adminOnly:!0},{label:e(`system.systemNav`,`System`),icon:it,path:bv,adminOnly:!0},{label:e(`system.logs`,`Logs`),icon:tt,path:`/system/logs`,adminOnly:!0},{label:e(`system.terminal`,`Terminal`),icon:Tn,path:`/system/terminal`,adminOnly:!0},{label:e(`system.cameraGrids`,`Camera grids`),icon:oe,path:`/system/camera-grids`,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 fy={gauge:ce,puzzle:st,bot:ue,cpu:Ze,terminal:Tn,box:B,boxes:B,monitor:En,wrench:at,activity:ze,plug:V,"graduation-cap":Te};function py(e){return fy[e]??st}function my(e,t){for(let n of dy(t))for(let t of n.items)if(t.path===e)return{icon:t.icon,title:t.label,path:t.path};return null}var hy=`/system/addons`;function gy({path:e,children:t}){let n=ly[e];return n===void 0?x(I,{children:t}):x(_y,{path:e,capability:n,children:t})}function _y({path:e,capability:t,children:n}){let{t:r}=J(),i=ms(),a=xr(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(cr,{className:`h-7 w-48`}),x(cr,{className:`h-40`})]});if(a===`unknown`)return x(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-presence-unknown`,children:x(yr,{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=my(e,{t:r,isAdmin:!0});return x(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-not-installed`,children:x(vr,{icon:o?.icon??st,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(hy),children:r(`pageRequires.openAddons`,`Open Addons`)})})})}function vy({capability:e,children:t}){return x(I,{children:t(xr(e)===`absent`)})}function yy({children:e}){return x(Wn,{value:by(Pi({})),children:e})}function by(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 xy(){let e=ir(),{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 Sy=/\p{Mn}/gu;function Cy(e){return e.normalize(`NFD`).replace(Sy,``).toLowerCase().trim()}var wy=[`device`,`page`,`integration`],Ty=0,Ey=1,Dy=2,Oy=3,ky=4,Ay=5,jy=6,My=7;function Ny(e,t,n,r){return n.includes(r)?Ty:e===r?Ey:e.startsWith(r)?Dy:e.split(/\s+/).some(e=>e.startsWith(r))?Oy:e.includes(r)?ky:t.some(e=>e.includes(r))?Ay:null}function Py(e,t){let n=0;for(let r=0;r<e.length&&n<t.length;r++)e[r]===t[n]&&n++;return n===t.length}function Fy(e){return e<4?0:e<=7?1:e<=12?2:3}function Iy(e,t,n){if(e===t)return 0;if(n<=0||Math.abs(e.length-t.length)>n)return null;let r=t.length,i=Array(r+1).fill(0),a=Array.from({length:r+1},(e,t)=>t),o=Array(r+1).fill(0);for(let s=1;s<=e.length;s++){o[0]=s;let c=s,l=e[s-1];for(let n=1;n<=r;n++){let r=t[n-1],u=l===r?0:1,d=Math.min((a[n]??1/0)+1,o[n-1]+1,(a[n-1]??1/0)+u);s>1&&n>1&&l===t[n-2]&&e[s-2]===r&&(d=Math.min(d,(i[n-2]??1/0)+1)),o[n]=d,d<c&&(c=d)}if(c>n)return null;let u=i;i=a,a=o,o=u}let s=a[r]??1/0;return s<=n?s:null}function Ly(e,t){if(Py(e,t))return jy;let n=Fy(t.length);if(n>0){for(let r of e.split(/\s+/))if(Iy(r,t,n)!==null)return My}return null}function Ry(e,t,n=200){let r=Cy(t);if(r.length===0)return{groups:[],totalMatched:0,truncated:!1};let i=new Map;for(let t of e){let e=Cy(t.label),n=Ny(e,(t.keywords??[]).map(Cy),(t.identifiers??[]).map(Cy),r)??Ly(e,r);if(n===null)continue;let a=i.get(t.domain)??[];a.push({item:t,rank:n}),i.set(t.domain,a)}let a=0;for(let e of i.values())a+=e.length;let o=n,s=[];for(let e of wy){let t=i.get(e);if(!t||t.length===0||o<=0)continue;t.sort((e,t)=>e.rank-t.rank||e.item.label.localeCompare(t.item.label));let n=t.slice(0,o).map(e=>e.item);o-=n.length,s.push({domain:e,items:n})}return{groups:s,totalMatched:a,truncated:a>n}}function zy(e){return e.flatMap(e=>e.items)}var By=`instance`;function Vy(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 Hy(e,t){let n=`/integrations/${encodeURIComponent(e)}`;return t===void 0||t.length===0?n:`${n}?${By}=${encodeURIComponent(t)}`}var Uy=` · `;function Wy(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(Uy)}function Gy(e,t=null){let n=bi(e),r=Nr(q.language.startsWith(`it`)?`it`:`en`),i=Ei(e),a=Xn(t);return e.map(e=>{let t=String(e.id),o=Yr(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(Uy).includes(c)),u=a(e),d=u.kind===`resolved`?u.integration.name:``;return{key:`device:${t}`,domain:`device`,label:s,subtitle:Wy(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:rr(e.type).icon}})}function Ky(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:Hy(e.addonId,e.id)}))}function qy(e,t,n){let r=e.section?.trim();return r?t[r]??e.sectionLabel?.trim()??r:n}function Jy(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:qy(e,i,n.ungrouped),keywords:[e.addonId],path:e.path,icon:py(e.icon)}));return[...r,...a]}O();var Yy={device:{labelKey:`search.resultsList.devices`,icon:we},page:{labelKey:`search.resultsList.pages`,icon:bn},integration:{labelKey:`search.resultsList.integrations`,icon:V}};function Xy({groups:e,activeKey:t,query:n,totalMatched:r,truncated:i,onSelect:a,onHover:o}){let{t:c}=J(),l=p(null);if(S(()=>{t&&(l.current?.querySelector(`[data-key="${CSS.escape(t)}"]`))?.scrollIntoView({block:`nearest`})},[t]),n.trim().length===0)return null;if(e.length===0)return x(`div`,{className:`px-3 py-4 text-center text-[12px] text-foreground-subtle`,children:c(`search.resultsList.noResults`,{query:n})});let u=e.reduce((e,t)=>e+t.items.length,0);return s(I,{children:[x(`div`,{ref:l,role:`listbox`,className:`max-h-[60vh] overflow-y-auto py-1`,children:e.map(e=>{let n=Yy[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`}),c(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:()=>o(e),onClick:()=>a(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:c(`search.truncatedResults`,`Showing first {{shown}} of {{total}} — refine your search.`,{shown:u,total:r})})]})}O(),Hi();function Zy({navSections:e,addonPages:t,compact:n,onNavigated:r}){let{t:i}=J(),a=ms(),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}=Yn({projection:`slim`}),{data:T}=Sr(void 0),E=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[...Gy(C??[],T??null),...Jy(e,t,n),...Ky(T??[])]},[C,T,e,t,i]),{groups:D,totalMatched:O,truncated:k}=m(()=>Ry(E,f),[E,f]),A=m(()=>zy(D),[D]);S(()=>{_(0)},[f,E]),S(()=>{v&&o.current?.focus()},[v]);let j=b(()=>{y(!1),h(``),_(0)},[]),M=b(e=>{a(e.path),j(),o.current?.blur(),r?.()},[a,j,r]);Gr(o,{scope:Br}),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 N=v&&f.trim().length>0;S(()=>{if(!N){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)}},[N]);let P=A[g]?.key??null,F=i(`search.placeholder`,`Search devices, pages, integrations…`),I=s(`div`,{className:`relative`,children:[x(ne,{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:F,"aria-label":F,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(),A.length>0&&_(e=>(e+1)%A.length);else if(e.key===`ArrowUp`)e.preventDefault(),A.length>0&&_(e=>(e-1+A.length)%A.length);else if(e.key===`Enter`){e.preventDefault();let t=A[g];t&&M(t)}else e.key===`Escape`&&(e.preventDefault(),j(),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(Me,{className:`h-3 w-3`})}),N&&u!==null&&Ui(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(Xy,{groups:D,activeKey:P,query:f,totalMatched:O,truncated:k,onSelect:M,onHover:e=>{let t=A.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:I}):x(K,{variant:`unstyled`,type:`button`,onClick:()=>y(!0),"aria-label":F,title:F,className:`flex w-full items-center justify-center rounded-md px-0 py-2 text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,children:x(ne,{className:`h-3.5 w-3.5 shrink-0`})})}):x(`div`,{ref:c,className:`px-2 pb-2`,children:I})}var Qy=/^(\d{1,3}\.){3}\d{1,3}$/;function $y(e){let t=e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e;return!!(Qy.test(t)||t.includes(`:`))}function eb(e,t){return!t||$y(e)?!1:e===t||e.endsWith(`.${t}`)}O();var tb=`auth-webauthn/passkey-enrollment`,nb=`camstack_passkey_prompt_dismissed:`,rb=720*60*60*1e3;function ib(e){try{let t=localStorage.getItem(`${nb}${e}`);if(!t)return!1;let n=Number(t);return Number.isFinite(n)?Date.now()-n<rb:!1}catch{return!1}}function ab(e){try{localStorage.setItem(`${nb}${e}`,String(Date.now()))}catch{}}function ob(){let{user:e}=T_(),{t}=J(),n=W(),r=oi(tb),[i,a]=w(!1),[o,c]=w(!1),l=m(()=>e?ib(e.id):!0,[e]),u=Gn.auth.listLoginMethods.useQuery().data?.find(e=>e.kind===`passkey`),d=u!==void 0&&eb(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&&ab(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(Me,{className:`h-3.5 w-3.5`})})]}),o&&x(`div`,{className:`px-3 pb-3`,children:s(`div`,{className:`max-w-xl`,children:[x(sr,{widgetId:tb,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 sb=`system-config`,cb=[`system-config`,`bootstrap-form`];function lb(e){return typeof e==`object`&&!!e&&`sections`in e&&Array.isArray(e.sections)}function ub(){let e=W();return E({queryKey:cb,queryFn:async()=>{let t=await e.trpcClient.addons.custom.mutate({addonId:sb,action:`getBootstrapForm`,input:{}});if(!lb(t))throw Error(`The hub did not return the settings form`);return t}})}function db(){let e=W(),t=N(),n=P({mutationFn:async t=>{await e.trpcClient.addons.custom.mutate({addonId:sb,action:`saveBootstrapForm`,input:t})},onSuccess:()=>Promise.all([t.invalidateQueries({queryKey:cb}),t.invalidateQueries({queryKey:[[`system`,`info`]]})])});return{mutateAsync:n.mutateAsync,isPending:n.isPending}}var fb=6e4;function pb(){let e=Fi(void 0,{staleTime:fb});return{info:e.data?.serverName??null,isLoading:e.isLoading}}O();var mb=`camstack_server_name_prompt_dismissed`;function hb(){try{return sessionStorage.getItem(mb)===`1`}catch{return!1}}function gb(){try{sessionStorage.setItem(mb,`1`)}catch{}}function _b(e){return e.isAdmin&&e.info!==null&&e.info.isDefault&&!e.dismissed}function vb(){let{user:e}=T_(),{info:t}=pb(),[n,r]=w(hb);return _b({isAdmin:e?.isAdmin===!0,info:t,dismissed:n})?x(yb,{suggestion:t?.name??``,onLater:()=>{gb(),r(!0)}}):null}function yb({suggestion:e,onLater:t}){let{t:n}=J(),r=N(),i=db(),[a,o]=w(e),[c,l]=w(null),u=p(null);S(()=>u.current?.focus(),[]);let d=b(async()=>{let e=At.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(Kn,{open:!0,onOpenChange:e=>!e&&t(),children:x(er,{children:s(`form`,{onSubmit:e=>{e.preventDefault(),i.isPending||d()},children:[s(Fn,{children:[x(_r,{children:n(`serverName.title`,`Name this server`)}),x(ur,{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(Qn,{children:x(qn,{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(Vi,{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(U,{className:`h-4 w-4 animate-spin`}),n(`common.save`,`Save`)]})]})]})})})}var bb=4,xb=160,Sb=320,Cb=`env(safe-area-inset-top)`,wb=`env(safe-area-inset-bottom)`;function Tb(e){let{rect:t,viewportWidth:n,viewportHeight:r}=e,i=Math.min(Sb,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+bb}px, calc(${Cb} + 8px))`;return{...a,top:e,maxHeight:`max(${xb}px, calc(100dvh - ${e} - ${wb} - 8px))`}}let o=`max(${r-t.top+bb}px, calc(${wb} + 8px))`;return{...a,bottom:o,maxHeight:`max(${xb}px, calc(100dvh - ${o} - ${Cb} - 8px))`}}var Eb=!1;function Db(){return Eb}function Ob(){Eb=!0}function kb(e){return!e.read&&e.severity===`critical`}function Ab(e){return e.filter(kb)}function jb(e){return e!==void 0&&typeof e.href==`string`&&e.href.length>0}function Mb(e){return jb(e)||e!==void 0&&e.invoke!==void 0}var Nb=/^\/addon\/[^/?#]+\/oauth\//;function Pb(e){return e.navigation===void 0?Nb.test(e.href):e.navigation===`server`}function Fb(e){let t=e.action;if(Mb(t)&&!(t.invoke!==void 0&&(e.status===`completed`||e.status===`dismissed`)))return t}O();function Ib({action:e,className:t,onActivate:n}){let r=N(),i=W(),{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 jb(e)?Pb(e)?x(`a`,{href:H(e.href),className:t,onClick:t=>{t.preventDefault(),n?.(t),Ol(e.href,()=>{r.invalidateQueries({queryKey:[[`alerts`]]}),r.invalidateQueries({queryKey:[[`broker`]]}),r.invalidateQueries({queryKey:[[`recordEntries`]]})})},children:e.label}):x(Pc,{to:e.href,className:t,onClick:n,children:e.label}):x(I,{})}O(),Hi();var Lb={info:he,success:ie,warning:Ce,error:He,critical:gn},Rb={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-danger`,critical:`text-danger`},zb={active:`border-l-info`,"in-progress":`border-l-warning`,completed:`border-l-success`,failed:`border-l-danger`,dismissed:`border-l-foreground-subtle/30`};function Bb(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 Vb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Hb(e){return typeof e==`string`&&e.length>0?e:void 0}function Ub(e){if(Vb(e.metadata)){let t=Hb(e.metadata.nodeId)??Hb(e.metadata.agentId);if(t!==void 0)return t}let t=e.source;if(t!==void 0&&!(t.type!==`node`&&t.type!==`agent`))return Hb(t.id)}function Wb({alert:e,onMarkRead:t,onDismiss:n}){let{t:r}=J(),i=e.severity in Lb?e.severity:`info`,a=Fb(e),o=e.status in zb?e.status:`active`,c=Lb[i],l=Rb[i],u=zb[o],{nodes:d}=Pn(),f=Ub(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(Ib,{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:Bb(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(le,{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(Me,{className:`h-3 w-3 text-foreground-subtle`})})]})]})}function Gb({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}=Ln(void 0,{refetchInterval:3e4}),{data:f=[],isLoading:m}=Ai({limit:50},{enabled:r}),h=a?f:f.filter(e=>!e.read),g=f.filter(e=>e.read).length,_=()=>{u.invalidateQueries({queryKey:[[`alerts`]]})},v=Un({onSuccess:_}),y=hr({onSuccess:_}),C=dr({onSuccess:_});or(`alert.created`,()=>{u.invalidateQueries({queryKey:[[`alerts`]]})}),or(`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(kb),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(Tb({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(tt,{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(tt,{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&&Ui(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(Di,{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(hn,{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(U,{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(tt,{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(Wb,{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(Wb,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),j.map(e=>x(Wb,{alert:e,onMarkRead:T,onDismiss:E},e.id))]})]}),document.body)]})}O(),Hi();function Kb({alert:e,onMarkRead:t}){let{t:n}=J(),r=Fb(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(Ib,{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 qb(){let{t:e}=J(),t=N(),[n,r]=w(Db()),{data:i=[],isLoading:a}=Ai({limit:50}),o=m(()=>Ab(i),[i]),c=Un({onSuccess:b(()=>{t.invalidateQueries({queryKey:[[`alerts`]]})},[t])}),l=b(e=>{c.mutate({alertId:e})},[c]),u=b(()=>{Ob(),r(!0)},[]);return a||n||o.length===0?null:Ui(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(Mr,{type:`button`,variant:`ghost`,onClick:u,"aria-label":e(`ui.criticalAlertsPanel.close`,`Close`),"data-testid":`critical-alerts-panel-close`,icon:Me})]}),x(`div`,{className:`flex-1 overflow-y-auto`,children:o.map(e=>x(Kb,{alert:e,onMarkRead:l},e.id))})]})}),document.body)}O();function Jb(){let e=vg();return C(e.subscribe,e.getSnapshot,e.getSnapshot)}var Yb=[`detection`,`cluster`,`administration`];function Xb(e){return Yb.includes(e)}function Zb(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(Xb(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 Qb=`camstack:last-path`,$b=512,ex=[`/login`,`/change-password`,`/access-denied`,`/logout`];function tx(e){return!e.startsWith(`/`)||e.startsWith(`//`)||e.length>$b?!1:!ex.some(t=>e===t||e.startsWith(t+`/`))}function nx(e){if(!(typeof window>`u`)&&tx(e))try{window.localStorage.setItem(Qb,e)}catch{}}function rx(){if(typeof window>`u`)return null;try{let e=window.localStorage.getItem(Qb);return e===null?null:tx(e)?e:null}catch{return null}}var ix=`/devices`;function ax(e){return e!==void 0&&tx(e)?e:rx()??ix}function ox(e){return e.split(`.`)[0]===`0`?`${e} beta`:e}function sx(e){if(e===null)return null;let t=e.trim();return t.length>0?t:null}function cx(e){let t=sx(e.productVersion),n=sx(e.serverVersion),r=sx(e.fallbackVersion);return t!==null&&n!==null?{kind:`both`,productLabel:ox(t),serverVersion:n}:t===null?n===null?r===null?{kind:`none`}:{kind:`fallback`,version:r}:{kind:`server`,serverVersion:n}:{kind:`product`,productLabel:ox(t)}}function lx(e,t){if(!Object.hasOwn(e,t))return null;let n=Reflect.get(e,t);return typeof n==`string`?n:null}function ux(e){return typeof e!=`object`||!e?null:{productVersion:lx(e,`productVersion`),serverVersion:lx(e,`serverVersion`)}}O();function dx(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 fx({placement:e,compact:t=!1}){let{t:n}=J(),[r,i]=w({kind:`fallback`,version:`1.2.622`});S(()=>{let e=new AbortController;return fetch(H(`/api/release-identity`),{signal:e.signal}).then(async e=>e.ok?ux(await e.json()):null).then(t=>{e.signal.aborted||t===null||i(cx({productVersion:t.productVersion,serverVersion:t.serverVersion,fallbackVersion:`1.2.622`}))}).catch(t=>{e.signal.aborted||t instanceof DOMException&&t.name}),()=>e.abort()},[]);let a=dx(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 px=j(!0);function mx(e){return e===`/addon`||e.startsWith(`/addon/`)}function hx(e,t,n){let r=[...e.filter(e=>e!==t),t];return r.length<=n?r:r.slice(r.length-n)}function gx({maxCached:e=6}){let t=_s(),n=X(),r=ds(),i=L(ns),a=n.pathname,o=mx(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=hx(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(px.Provider,{value:n,children:x(ts.Provider,{value:{location:t.location,navigationType:t.navigationType},children:x(ns.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 _x={dark:Ge,light:We,system:En};function vx(){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 yx(){let e=X(),t=ms(),{user:n,logout:r}=T_(),i=Ar(),{t:a}=J(),o=ai(),c=Aa(),l=gi(),{info:u}=pb();S(()=>{document.title=u===null?`CamStack Admin`:`${u.name} \u00b7 CamStack Admin`},[u]);let d=cg(Jb()),[f,h]=w(!1);S(()=>{nx(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=[]}=wi({nodeId:`hub`},{refetchInterval:3e4}),C=b.length,T=N(),E=p(Date.now()),{data:D}=Jn(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?Qv(D):[],[D,n?.isAdmin]),k=m(()=>Zb(O),[O]),A=k.known.get(`detection`)??[],j=k.known.get(`cluster`)??[],M=k.known.get(`administration`)??[];or(`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+`/`)),ee=n?.isAdmin===!0,R=m(()=>dy({t:a,isAdmin:ee}),[a,ee]),te=R[0]?.items??[],ne=R[1]?.items??[],re=R[2]?.items??[],ie=R[3]?.items??[],ae=i?.mode??`system`,oe={dark:a(`theme.dark`),light:a(`theme.light`),system:a(`theme.system`)},z=g&&!o,B=(e,t=`md`,n=!1)=>`flex w-full items-center gap-2.5 rounded-md ${z?`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`}`,V=(e,t)=>e===0?null:z?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}`),ce=e=>{let n=F(e.path),r=py(e.icon);return s(K,{variant:`unstyled`,onClick:()=>{t(e.path),h(!1)},className:B(n),title:z?e.label:void 0,children:[x(r,{className:`h-3.5 w-3.5 shrink-0 ${n?`text-primary`:``}`}),!z&&e.label]},`${e.addonId}::${e.id}`)},le=e=>e.requiresCapability===void 0?ue(e,!1):x(vy,{capability:e.requiresCapability,children:t=>ue(e,t)},e.path),ue=(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:B(i,`md`,n),"aria-disabled":n||void 0,title:n?a(`nav.notInstalled`,`{{page}} — not installed`,{page:e.label}):z?e.label:void 0,children:[x(r,{className:`h-3.5 w-3.5 shrink-0 ${i?`text-primary`:``}`}),!z&&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})]}),z&&o&&C>0&&x(`span`,{className:`absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary`})]},e.path)},de=s(I,{children:[s(`div`,{className:`flex h-14 items-center border-b border-border ${z?`justify-center px-1`:`pl-3 pr-4 gap-2`}`,children:[!z&&x(`img`,{src:i?.resolvedMode===`light`?H(`/brand/logo-horizontal-light.svg`):H(`/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 ${z?``:`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?me:ge,{className:`h-4 w-4`})})]}),!z&&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(Zy,{navSections:R,addonPages:O,compact:z,onNavigated:()=>h(!1)})}),s(`nav`,{className:`flex-1 overflow-y-auto py-3 ${z?`px-1.5`:`px-2`} space-y-0.5`,children:[te.map(e=>le(e)),V(ne.length+A.length,a(`nav.detectionSection`,`Detection`)),ne.map(e=>le(e)),A.map(e=>ce(e)),V(re.length+j.length,a(`nav.clusterSection`,`Cluster`)),re.map(e=>le(e)),j.map(e=>ce(e)),V(ie.length+M.length,a(`system.title`,`Administration`)),ie.map(e=>le(e)),M.map(e=>ce(e)),k.custom.map(e=>s(`div`,{className:`contents`,children:[V(e.pages.length,e.label),e.pages.map(e=>ce(e))]},`custom-${e.id}`)),V(k.ungrouped.length,a(`nav.addonPages`,`Addon Pages`)),k.ungrouped.map(e=>ce(e))]}),s(`div`,{className:`border-t border-border ${z?`p-1.5`:`p-2`} space-y-0.5`,children:[s(K,{variant:`unstyled`,onClick:()=>i?.toggleMode(),className:B(!1),title:z?oe[ae]:void 0,children:[(()=>{let e=_x[ae];return x(e,{className:`h-3.5 w-3.5 shrink-0`})})(),!z&&x(`span`,{children:oe[ae]})]}),x(Gb,{variant:`sidebar`,compact:z}),s(K,{variant:`unstyled`,type:`button`,onClick:()=>t(`/system/my-access`),className:B(F(`/system/my-access`)),title:z?a(`system.myAccess`,`My access`):void 0,children:[x(et,{className:`h-3.5 w-3.5 shrink-0`}),!z&&x(`span`,{className:`truncate`,children:a(`system.myAccess`,`My access`)})]}),s(K,{variant:`unstyled`,type:`button`,onClick:()=>c.setOn(!c.on),className:B(c.on),"aria-pressed":c.on,title:z?a(`layouts.appLayout.debugLayers`,`Debug layers`):void 0,children:[x(Ee,{className:`h-3.5 w-3.5 shrink-0`}),!z&&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:B(!1).replace(`hover:text-foreground`,`hover:text-danger`),title:z?n?.username??a(`layouts.appLayout.logout`,`Logout`):void 0,children:[x(_n,{className:`h-3.5 w-3.5 shrink-0`}),!z&&x(`span`,{className:`truncate`,children:n?.username??a(`layouts.appLayout.user`,`User`)})]}),x(fx,{placement:`sidebar`,compact:z})]})]});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 ${z?`w-12`:`w-48`}`,children:de}),o&&x(Lr,{open:f,onClose:()=>h(!1),width:`w-64`,children:de}),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(se,{className:`h-3.5 w-3.5`}):x(ze,{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(U,{className:`h-3.5 w-3.5 animate-spin`})]}),x(ob,{}),x(vb,{}),x(qb,{}),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(Le,{className:`h-5 w-5`})}),x(`div`,{className:`flex-1 flex justify-center`,children:x(`img`,{src:i?.resolvedMode===`light`?H(`/brand/logo-horizontal-light.svg`):H(`/brand/logo-horizontal-dark.svg`),alt:a(`layouts.appLayout.camstack`,`CamStack`),className:`h-7`})}),x(Gb,{})]}),s(yy,{children:[x(xy,{}),x(`main`,{className:`relative flex-1 min-h-0 overscroll-contain bg-background ${L?`overflow-hidden`:`overflow-auto`}`,children:x(Xv,{resetKey:e.pathname,children:x(y,{fallback:x(vx,{}),children:x(gx,{})})})})]})]})]})]})}function $({children:e,requireAdmin:t}){let{t:n}=J(),{user:r,loading:i,mustChangePassword:a}=T_(),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 bx=`customize`,xx=`/build/compositions/new`,Sx=`/build/compositions/:blockId`,Cx=`/build?tab=custom-device`;function wx(e){return`/devices/${e}`}function Tx(e){return`/devices/${e}?tab=${bx}`}var Ex=`integration`,Dx=`section`,Ox=[Ex,Dx,`instance`,`instance-new`],kx={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`}},Ax=`settings`,jx=`activity`;function Mx(e,t={}){let{path:n,tab:r}=kx[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(Ex,t.integration),t.section!==void 0&&i.set(Dx,t.section);let a=i.toString();return a.length>0?`${n}?${a}`:n}function Nx(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 Px(e,t,n=null,r=null){let i=new URLSearchParams(e);return i.set(Ex,t),r===null?i.delete(Dx):i.set(Dx,r),n!==null&&i.delete(n),i}function Fx(e){return e===`/admin`||e===`/admin/`?`/`:e.startsWith(`/admin/`)?e.slice(6):e}var Ix=`--color-surface`;function Lx(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 Rx(e=document){let t=e.defaultView?.getComputedStyle(e.documentElement).getPropertyValue(Ix).trim();if(!t)return;let n=Lx(e);n.content!==t&&(n.content=t)}function zx(e=document){Rx(e);let t=e.defaultView;if(!t)return()=>void 0;let n=new t.MutationObserver(()=>Rx(e));return n.observe(e.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>n.disconnect()}function Bx(){let{t:e}=J(),t=ms();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(Sn,{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 Vx(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 Hx(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 Ux(){return window?.PublicKeyCredential!==void 0&&typeof window.PublicKeyCredential==`function`}function Wx(e){let{id:t}=e;return{...e,id:Hx(t),transports:e.transports}}function Gx(e){return e===`localhost`||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var Kx=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),this.name=r??n.name,this.code=t}},qx=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}}},Jx=[`cross-platform`,`platform`];function Yx(e){if(e&&!(Jx.indexOf(e)<0))return e}function Xx(){if(!Ux())return new Promise(e=>e(!1));let e=window.PublicKeyCredential;return e.isConditionalMediationAvailable===void 0?new Promise(e=>e(!1)):e.isConditionalMediationAvailable()}function Zx({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 Kx({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new Kx({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=window.location.hostname;if(!Gx(t))return new Kx({message:`${window.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new Kx({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 Kx({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 Qx(e){let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!Ux())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(Wx));let a={...t,challenge:Hx(t.challenge),allowCredentials:i},o={};if(n){if(!await Xx())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=qx.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Zx({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=Vx(u.userHandle)),{id:c,rawId:Vx(l),response:{authenticatorData:Vx(u.authenticatorData),clientDataJSON:Vx(u.clientDataJSON),signature:Vx(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:Yx(s.authenticatorAttachment)}}function $x(e){return typeof e==`object`&&!!e}function eS(e){return $x(e)&&typeof e.challenge==`string`}O();function tS(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function nS(e){let{t}=J(),n=W(),[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(tS(e,`Password is incorrect`)),l(null)}},_=async()=>{l(`passkey`),d(null);try{let{optionsJSON:e}=await n.reauthBeginPasskey();if(!eS(e))throw Error(`passkey authentication options missing challenge`);let t=await Qx({optionsJSON:e}),{reauthToken:r}=await n.reauthenticate({passkeyResponse:Object.fromEntries(Object.entries(t))});m(r)}catch(e){d(tS(e,`Passkey verification failed`)),l(null)}};return{requestProof:h,dialog:x(Kn,{open:r,onOpenChange:e=>!e&&m(null),children:s(er,{children:[s(Fn,{children:[x(_r,{children:t(`auth.reauthDialog.confirmItSYou`,`Confirm it’s you`)}),x(ur,{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(Vi,{className:`flex flex-wrap gap-2`,children:[s(K,{type:`button`,variant:`outline`,disabled:c!==null,onClick:()=>void _(),children:[c===`passkey`?x(U,{className:`h-4 w-4 animate-spin`}):x(yn,{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(U,{className:`h-4 w-4 animate-spin`}),t(`common.confirm`,`Confirm`)]})]})]})]})})}}O();function rS(e){return e.ip!==null&&e.approverIp!==null&&e.ip!==e.approverIp}function iS(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function aS(e){let t=e instanceof Error?e.message:``;return t.startsWith(`Sign in again first`)||t.startsWith(`Confirm it is you`)}function oS(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 sS({onApproved:e,onDenied:t}){let{t:n}=J(),r=Gn.useUtils(),[i,a]=w(``),[o,c]=w(null),[l,u]=w(``),[d,f]=w(null),[p,m]=w(null),{requestProof:h,dialog:g}=nS(n(`cliLogin.reauthAction`,`Approving a terminal sign-in`)),_=Gn.auth.cliLoginApprove.useMutation(),v=Gn.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(iS(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(!aS(e))throw e;let t=await h();if(t===null)return;await _.mutateAsync({userCode:l,reauthToken:t})}e()}catch(e){m(iS(e,n(`cliLogin.failed`,`That did not work. Try again.`)))}finally{f(null)}},S=o===null?null:oS(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(On,{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(U,{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})})]})]}),rS(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(U,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),n(`cliLogin.approve`,`Approve`)]})]})]}),g]})}O();function cS(){let{t:e}=J(),t=Ar(),n=ms(),[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`?H(`/brand/logo-horizontal-light.svg`):H(`/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(sS,{onApproved:()=>window.location.assign(H(on(null,{status:`success`,action:`cli-login`}))),onDenied:()=>i(!0)})})]})})}var lS=`auth.password-incorrect`;function uS(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function dS(e){if(!(e instanceof Error))return{kind:`connection-lost`};let t=uS(e,`data`);return typeof t!=`object`||!t?{kind:`connection-lost`}:uS(uS(t,`i18n`),`code`)===lS?{kind:`wrong-current`}:uS(t,`code`)===`UNAUTHORIZED`?{kind:`session-ended`}:{kind:`rejected`,message:e.message}}O();var fS=8;function pS(e,t){let n=dS(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 mS(){let{t:e}=J(),{user:t,mustChangePassword:n,clearMustChangePassword:r,logout:i}=T_(),a=W(),o=Ar(),c=ms(),[l,u]=w(``),[d,f]=w(``),[p,m]=w(``),[h,g]=w(!1),[_,v]=w(``),[y,b]=w(!1),S=n?h_: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`?H(`/brand/logo-horizontal-light.svg`):H(`/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<fS){v(`Password must be at least ${fS} 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(pS(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?R:ve,{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 hS(e){if(!eS(e))throw Error(`passkey authentication options missing challenge`);let t=await Qx({optionsJSON:e});return Object.fromEntries(Object.entries(t))}function gS({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=wg();if(t){let r=await hS((await e.loginBeginPasskey(t)).optionsJSON),i=await e.loginVerifyPasskey(t,r,{refreshable:!0});n(i.token,i);return}let a=await hS((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(U,{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 _S=()=>window.location.hostname;function vS(e,t=_S,n=null){return n===!1?!1:Ux()&&eb(t(),e.rpId)}function yS(e,t=_S,n=null){let r=e.filter(e=>e.kind===`passkey`&&e.stage===`second-factor`).filter(e=>vS(e,t,n));return{passkeyMethods:r,widgetMethods:r.length>0?[]:e.filter(e=>e.kind===`widget`&&e.stage===`second-factor`)}}function bS(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 xS(){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 SS=()=>`camstackAgentApp`in window;function CS(){let[e,t]=w(null);return S(()=>{if(!SS())return;let e=!0;return xS().then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}function wS(e){let t=e.onComplete,n=e.onSecondFactor;return typeof t==`function`?{onComplete:t,onSecondFactor:typeof n==`function`?n:void 0}:null}function TS({methods:e,widgetConfig:t,onRedirect:n}){let{t:r}=J();ji();let i=CS(),a=e.filter(e=>e.kind!==`passkey`||vS(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:fr(e.icon))??et;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=wS(t);return n?x(gS,{method:e,onComplete:n.onComplete,onSecondFactor:n.onSecondFactor},e.id):null}return x(ES,{method:e,config:t},e.id)})})]})}function ES({method:e,config:t}){let{t:n}=J(),r=_i(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(U,{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(He,{className:`h-3.5 w-3.5 shrink-0`}),n(`login.primaryMethods.loadFailed`)]}):x(r,{instanceId:e.id,host:`dashboard`,config:t})}var DS=4e3,OS=/^[A-Za-z0-9._-]{1,64}$/;function kS(e){if(e.action===`cli-login`)return Mx(`access`);let t=e.addonId!==void 0&&OS.test(e.addonId)?e.addonId:null,n=e.integration!==void 0&&OS.test(e.integration)?e.integration:null;if(t!==null&&e.brokerId!==void 0)return Mx(`connectivity`,{integration:t,kindSection:`brokers`});let r=n??t;return Mx(`connectivity`,r===null?{}:{integration:r})}function AS(e,t){let n=t.opener;if(n===null||n.closed||aa(n)!==t.origin)return!1;try{return n.postMessage({type:Cl,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 jS=500;function MS(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 NS({outcome:e}){let{t}=J(),n=MS(e.reason??`unknown`);if(e.status===`error`)return s(I,{children:[x(rt,{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(ie,{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(ie,{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 PS({outcome:e,closable:t,onContinue:n,onClose:r}){let{t:i}=J(),a=kS(e);return S(()=>{if(e.status!==`success`)return;let t=window.setTimeout(()=>n(a),DS);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:H(`/brand/logo-horizontal-dark.svg`)}),x(`img`,{src:H(`/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(NS,{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 FS(e,t){window.history.replaceState(null,``,window.location.pathname);let n=window.opener,r=AS(t,{opener:n,origin:window.location.origin}),i=()=>e.render(x(PS,{outcome:t,closable:r,onContinue:e=>window.location.replace(H(e)),onClose:()=>window.close()}));if(r&&t.status===`success`){window.close(),window.setTimeout(i,jS);return}i()}function IS(e){return Qt(e)}var LS=`Done — you can close this window.`,RS=500,zS=`camstack_admin_token`;async function BS(e,t=``){try{let n=Pg(new URLSearchParams(t));n!==null&&n.token===e?Mg(n):localStorage.setItem(zS,e)}catch{}await fetch(H(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}function VS(){try{let e=localStorage.getItem(zS);return e!==null&&e.length>0?e:null}catch{return null}}function HS(e){let t=IS(window.location.hash);if(t!==null){FS(e,t);return}let n=ea(window.location.hash);window.history.replaceState(null,``,window.location.pathname);let r=t=>e.render(x(US,{completion:n,result:t,hasOpener:window.opener!==null}));if(r(null),n===null)return;let i=oa();ca(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:LS}),RS)},continueAt:e=>window.location.replace(H(e)),persistSession:e=>BS(e,n.target===`login`?n.fragment:``),showResult:r,setTimeout:(e,t)=>window.setTimeout(e,t)})}function US({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:H(`/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:H(`/login`),children:r(`ssoComplete.backToSignIn`,`Back to sign-in`)})]})})})}O();function WS(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 GS(){let e=new URLSearchParams(window.location.search);return Yg({codeChallenge:e.get(`code_challenge`),codeChallengeMethod:e.get(`code_challenge_method`),state:e.get(`state`),purpose:e.get(`purpose`)})}function KS(e){return Math.min(1e3*2**e,15e3)}function qS(){let{t:e}=J(),{login:t,verifyTotp:n,finalizePasskeyLogin:r,user:i}=T_(),{i18n:a}=J(),o=Ar(),c=ms(),l=X(),u=new URLSearchParams(window.location.search).get(`next`);S(()=>{i_(u)},[u]);let d=new URLSearchParams(window.location.search).get(`redirect`);S(()=>{p_(d)},[d]);let f=GS();S(()=>{Qg(f)},[f?.codeChallenge,f?.state,f?.purpose]);let m=l.state,h=ax(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(``),[ee,te]=w(void 0),[ne,re]=w(`sso-not-linked`),ie=Gn.auth.listLoginMethods.useQuery(void 0,{retry:!0,retryDelay:KS}),ae=ie.data===void 0,oe=(ie.data??[]).filter(e=>e.kind!==`device-certificate`),se=Gn.auth.getServerName.useQuery().data,z=oe.filter(e=>e.stage===`primary`),B=yS(oe,void 0,CS());S(()=>{let e=la(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}re(e.code),te(e.provider)}},[]);let V=ee==null?null:oe.find(e=>e.id===ee&&`label`in e)?.label??null,ce=T||(ee===void 0?``:na(ne,V)),{passkeyMethods:le,widgetMethods:ue}=B,de=p(!1),fe=async()=>{if(de.current)return;de.current=!0;let e=t_(d);if(e?.kind===`app-callback`){await he(e.url);return}else if(e){window.location.assign(H(e.path));return}let t=o_(u);t?window.location.assign(H(t)):c(h,{replace:!0})},[pe,me]=w(null),he=async e=>{me({callbackBase:e,mintedUrl:null,failed:!1});try{let t=GS()??$g();if(t===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await wg().trpcClient.auth.createHandoffCode.mutate({purpose:t.purpose,codeChallenge:t.codeChallenge,state:t.state}),r=e_(e,n,t.state);me({callbackBase:e,mintedUrl:r,failed:!1}),window.location.assign(r)}catch(t){if(WS(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,ye]=w(!1);S(()=>{!ge||!d&&!u||_e||(ye(!0),fe())},[ge,d,u,_e]);let be=async e=>{e.preventDefault(),E(``),te(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)}},xe=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)}},Se=async(e,t)=>{try{await r(e,t),await fe()}catch(e){E(e instanceof Error?e.message:`Passkey sign-in failed`)}},Ce=p(null);S(()=>()=>Ce.current?.(),[]);let we=async e=>{if(e.target!==`login`)return;let t=Pg(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=la(`#${e.fragment}`);if(n!==null){if(n.kind===`challenge`){Ee({challengeToken:n.challengeToken,factors:n.factors});return}re(n.code),te(n.provider)}},Te=e=>{if(Kg(d)?.kind===`app-callback`)return!1;let t=ra(H(ta(e.startUrl)));return t===null?!1:(E(``),te(void 0),Ce.current?.(),Ce.current=sa(t,{onReturn:e=>{Ce.current?.(),Ce.current=null,we(e)},onDone:e=>{if(Ce.current?.(),Ce.current=null,e.target!==`login`)return;let t=VS()===null?null:jg();t!==null&&we({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)},Ee=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`?H(`/brand/logo-horizontal-light.svg`):H(`/brand/logo-horizontal-dark.svg`),alt:e(`login.camstackAdmin`,`CamStack Admin`),className:`h-12`})}),se!==void 0&&!se.isDefault&&x(`p`,{"data-testid":`login-server-name`,className:`-mt-4 mb-6 text-center text-sm text-foreground-muted`,children:x(Sl,{i18nKey:`login.signInTo`,values:{name:se.name},components:{b:x(`span`,{className:`font-semibold text-foreground`})}})}),k===`credentials`?s(`form`,{onSubmit:be,className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[ce&&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:ce}),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?R:ve,{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(Ue,{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(Sl,{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`)&&le.map(e=>x(gS,{method:e,challengeToken:j,onComplete:Se},e.id)),N.includes(`passkey`)&&ue.map(e=>x(ES,{method:e,config:{challengeToken:j,onComplete:Se}},e.id)),bS(N,B)&&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:xe,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(Xe,{className:`h-3 w-3`}),e(`login.backToUsernamePassword`,`Back to username + password`)]})]}),k===`credentials`&&ae&&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(TS,{methods:z,widgetConfig:{onComplete:Se,onSecondFactor:Ee,locale:a.language},onRedirect:Te}),x(`p`,{className:`mt-6 text-center text-[10px] text-foreground-subtle/50`,children:x(fx,{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`)})]})]})})}O();function JS(){let{pathname:e,search:t,hash:n}=X();return x(Z,{to:`${Fx(e)}${t}${n}`,replace:!0})}function YS(){return x(Z,{to:rx()??`/devices`,replace:!0})}var XS=g(()=>a(()=>import(`./Devices-DnnB5-0E.js`).then(e=>({default:e.DevicesPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]),import.meta.url)),ZS=g(()=>a(()=>import(`./Integrations-BSA9HPyd.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([11,1,2,3,4,12,5,13,6,14,7,9,15]),import.meta.url)),QS=g(()=>a(()=>import(`./IntegrationDetail-Culq1Ni9.js`).then(e=>({default:e.IntegrationDetailPage})),__vite__mapDeps([16,1,2,3,4,17,5,14,7,18,19,8]),import.meta.url)),$S=g(()=>a(()=>import(`./Pipeline-DrZixiLL.js`).then(e=>({default:e.PipelinePage})),__vite__mapDeps([20,1,2,3,4,12,5,21,22,23,24,25,26,27,9]),import.meta.url)),eC=g(()=>a(()=>import(`./DeviceDetail-GJkHbY0h.js`).then(e=>({default:e.DeviceDetailPage})),__vite__mapDeps([28,1,2,3,4,12,5,29,30,31,32,33,21,34,35,24,36,37,38,39,40,41,42,43,44,45,46,26,9,47,19,48]),import.meta.url)),tC=g(()=>a(()=>import(`./Showroom-Cy61Met3.js`).then(e=>({default:e.ShowroomPage})),__vite__mapDeps([49,1,2,3,4]),import.meta.url)),nC=g(()=>a(()=>import(`./EmbedPlayerPage-Fv2jvgXD.js`).then(e=>({default:e.EmbedPlayerPage})),__vite__mapDeps([50,1,2,3,4,5]),import.meta.url)),rC=g(()=>a(()=>import(`./Library-CDrsfdbN.js`).then(e=>({default:e.LibraryPage})),__vite__mapDeps([51,1,2,3,4,12,5,52,21,23,53,54,45,55,47,19]),import.meta.url)),iC=g(()=>a(()=>import(`./Recordings-xllrAH4z.js`).then(e=>({default:e.RecordingsPage})),__vite__mapDeps([56,1,2,3,4,12,5,57,54,58,29,59,60,61,62,25,18,19,63,47]),import.meta.url)),aC=g(()=>a(()=>import(`./Viewer-DAzWPu1t.js`).then(e=>({default:e.ViewerPage})),__vite__mapDeps([64,2,3,4,65,5,19,1]),import.meta.url)),oC=g(()=>a(()=>import(`./Build-Blu_Rek1.js`).then(e=>({default:e.BuildPage})),__vite__mapDeps([66,1,2,3,4,12,5,33,67,21,68,54,38,32,39,40,41,42,43,44]),import.meta.url)),sC=g(()=>a(()=>import(`./CompositionEditorPage-2bkol2ck.js`).then(e=>({default:e.CompositionEditorPage})),__vite__mapDeps([69,1,2,3,4,33,5,6,38,12,32,21,39,40,41]),import.meta.url)),cC=g(()=>a(()=>import(`./Locations-8ETbKpeR.js`).then(e=>({default:e.LocationsPage})),__vite__mapDeps([70,1,2,3,4,12,5,33,71,53,54,46,40,41]),import.meta.url)),lC=g(()=>a(()=>import(`./Addons-B0-JHWDN.js`).then(e=>({default:e.AddonsPage})),__vite__mapDeps([72,1,2,3,4,21,5,6,25,73,10,15,19]),import.meta.url)),uC=g(()=>a(()=>import(`./AiProfiles-BuQvWBCk.js`).then(e=>({default:e.AiProfilesPage})),__vite__mapDeps([74,1,2,3,4,12,5,75,76,6,54,61,62,25,18,19,77]),import.meta.url)),dC=g(()=>a(()=>import(`./MyAccess-yDg5ZUb3.js`).then(e=>({default:e.MyAccessPage})),__vite__mapDeps([78,1,2,3,4,12,5,21,79,80,6,54,81,19,82]),import.meta.url)),fC=g(()=>a(()=>import(`./Logs-DaigxSX8.js`).then(e=>({default:e.LogsPage})),__vite__mapDeps([83,1,2,3,4,24,84,5,6,54,61,62,25,18,19]),import.meta.url)),pC=g(()=>a(()=>import(`./Identity-DWLT_K89.js`).then(e=>({default:e.IdentityPage})),__vite__mapDeps([85,1,2,3,4,12,5,21,35,86,79,80,6,54,81,87,88,61,62,25,18,19,89,90,91]),import.meta.url)),mC=g(()=>a(()=>import(`./Network-4RdFqBxG.js`).then(e=>({default:e.NetworkPage})),__vite__mapDeps([92,1,2,3,4,12,5,33,21,6,54,61,62,25,18,19,91]),import.meta.url)),hC=g(()=>a(()=>import(`./Integrations-B1KxBrwc.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([93,1,2,3,4,12,5,21,54,61,62,25,18,19,87,88,6]),import.meta.url)),gC=g(()=>a(()=>import(`./TrainingProviders-CGnhynXm.js`).then(e=>({default:e.TrainingProvidersPage})),__vite__mapDeps([94,1,2,3,4,5,6,61,62,25,18,19]),import.meta.url)),_C=g(()=>a(()=>import(`./Data-BKLSNpfc.js`).then(e=>({default:e.DataPage})),__vite__mapDeps([95,1,2,3,4,12,5,67,21,34,96,60,6,54,61,62,25,18,19,58,29,59,63,47]),import.meta.url)),vC=g(()=>a(()=>import(`./System-IFiHQlVG.js`).then(e=>({default:e.SystemPage})),__vite__mapDeps([97,1,2,3,4,12,5,98,6,54,25,89,90,21,61,62,18,19,87,88,91]),import.meta.url)),yC=g(()=>a(()=>import(`./Cluster-CiamsdEf.js`).then(e=>({default:e.ClusterPage})),__vite__mapDeps([99,1,2,3,4,12,5,60,100,80,6,44,25,27,73,63]),import.meta.url)),bC=g(()=>a(()=>import(`./CameraGrids-CTVWt5In.js`).then(e=>({default:e.CameraGridsPage})),__vite__mapDeps([101,2,3,4,5,61,1,62,25,18,19]),import.meta.url)),xC=g(()=>a(()=>import(`./Terminal-CLVwElWa.js`).then(e=>({default:e.TerminalPage})),__vite__mapDeps([102,1,2,3,4,21,5,6,61,62,25,18,19,91,103]),import.meta.url)),SC=g(()=>a(()=>import(`./Notifications-nPHvnL47.js`).then(e=>({default:e.NotificationsPage})),__vite__mapDeps([104,1,2,3,4,12,5,31,21,75,105,6,54,61,62,25,18,19,43,39,44,55,77,41,48]),import.meta.url)),CC=g(()=>a(()=>import(`./History-sL1i9hpN.js`).then(e=>({default:e.HistoryPage})),__vite__mapDeps([106,1,2,3,4,5,6]),import.meta.url)),wC=g(()=>a(()=>import(`./Calendars-D1HqtZRO.js`).then(e=>({default:e.CalendarsPage})),__vite__mapDeps([107,1,2,3,4,12,5,21,6]),import.meta.url)),TC=g(()=>a(()=>import(`./Templates-CI8sfkWl.js`).then(e=>({default:e.TemplatesPage})),__vite__mapDeps([108,1,2,3,4,21,109,80,5,36,37,6]),import.meta.url)),EC=new D({defaultOptions:{queries:{gcTime:0,staleTime:0,retry:!1,refetchOnWindowFocus:!1}}});zi(EC);function DC({field:e,value:t,onChange:n,disabled:r}){return x(dv,{field:e,value:t,onChange:n,disabled:r})}var OC={"model-selector":DC};function kC({children:e}){let{t}=J(),{user:n,logout:r}=T_(),[i,a]=w(0),o=p(n?.username??null);S(()=>{let e=n?.username??null;e!==o.current&&(o.current=e,Tg(),a(e=>e+1))},[n]);let c=m(()=>wg(),[i]),l=b(()=>{wg().reconnect(),a(e=>e+1),EC.invalidateQueries()},[]);Rv(b(()=>Ug(l),[l])),S(()=>zg(()=>{wg().isSocketTokenStale()&&l()}),[l]);let u=b(async()=>{let e=await Wg();return e&&l(),e},[l]),{bootReady:d,bootError:f}=Iv(c,n??null,r,u);return x(Nv,{children:x(Ke,{system:c,children:x(Gn.Provider,{client:c.trpcClient,queryClient:EC,children:s(Rr,{children:[x(Ir,{children:x(hi,{children:x(ni,{children:d?e:x(AC,{})})})}),d&&x(_v,{}),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 AC(){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 jC(){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 MC(){return S(()=>zx(),[]),x(Ii,{defaultMode:`dark`,children:x(wr,{children:x(F,{client:EC,children:x(w_,{children:x(kC,{children:x(Ve,{children:x(gv,{children:x(kr,{renderers:OC,children:s(tr,{picker:yh,children:[x(Mc,{basename:Je(),children:x(av,{children:x(y,{fallback:x(jC,{}),children:s(Us,{children:[x(Q,{path:`/login`,element:x(qS,{})}),x(Q,{path:`/admin/*`,element:x(JS,{})}),x(Q,{path:`/admin`,element:x(JS,{})}),x(Q,{path:`/change-password`,element:x($,{children:x(mS,{})})}),x(Q,{path:`/approve`,element:x($,{children:x(cS,{})})}),x(Q,{path:`/showroom`,element:x(tC,{})}),x(Q,{path:`/embed/player`,element:x(nC,{})}),s(Q,{element:x($,{children:x(da,{children:x(yx,{})})}),children:[x(Q,{index:!0,element:x(YS,{})}),x(Q,{path:`/access-denied`,element:x(Bx,{})}),x(Q,{path:`/dashboard`,element:x(Z,{to:`/devices`,replace:!0})}),x(Q,{path:`/devices`,element:x(XS,{})}),x(Q,{path:`/cameras`,element:x(Z,{to:`/devices`,replace:!0})}),x(Q,{path:`/integrations`,element:x(ZS,{})}),x(Q,{path:`/integrations/:addonId`,element:x(QS,{})}),x(Q,{path:`/system/pipeline`,element:x(gy,{path:`/system/pipeline`,children:x($S,{})})}),x(Q,{path:`/pipeline`,element:x(Z,{to:`/system/pipeline`,replace:!0})}),x(Q,{path:`/live`,element:x(aC,{})}),x(Q,{path:`/devices/:deviceId`,element:x(eC,{})}),x(Q,{path:`/system/logs`,element:x($,{requireAdmin:!0,children:x(fC,{})})}),x(Q,{path:`/system/addons`,element:x($,{requireAdmin:!0,children:x(lC,{})})}),x(Q,{path:`/system/ai`,element:x($,{requireAdmin:!0,children:x(uC,{})})}),x(Q,{path:`/system/settings`,element:x($,{requireAdmin:!0,children:x(vC,{})})}),x(Q,{path:`/system/nodes`,element:x($,{requireAdmin:!0,children:x(yC,{})})}),x(Q,{path:`/system/notifications`,element:x($,{requireAdmin:!0,children:x(SC,{})})}),x(Q,{path:`/system/history`,element:x($,{requireAdmin:!0,children:x(CC,{})})}),x(Q,{path:`/system/calendars`,element:x($,{requireAdmin:!0,children:x(wC,{})})}),x(Q,{path:`/system/templates`,element:x($,{requireAdmin:!0,children:x(TC,{})})}),x(Q,{path:`/system/identity`,element:x($,{requireAdmin:!0,children:x(pC,{})})}),x(Q,{path:`/system/my-access`,element:x(dC,{})}),x(Q,{path:`/system/network`,element:x($,{requireAdmin:!0,children:x(mC,{})})}),x(Q,{path:`/training/providers`,element:x($,{requireAdmin:!0,children:x(gC,{})})}),x(Q,{path:`/system/integrations`,element:x($,{requireAdmin:!0,children:x(hC,{})})}),x(Q,{path:`/system/data`,element:x($,{requireAdmin:!0,children:x(_C,{})})}),x(Q,{path:`/system`,element:x(Z,{to:bv,replace:!0})}),x(Q,{path:`/system/camera-grids`,element:x($,{requireAdmin:!0,children:x(bC,{})})}),x(Q,{path:`/system/terminal`,element:x($,{requireAdmin:!0,children:x(xC,{})})}),x(Q,{path:wv,element:x(Dv,{})}),xv.map(e=>x(Q,{path:e.path,element:x(Ev,{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:Mx(`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:Mx(`remoteAccess`),replace:!0})}),x(Q,{path:`/system/turn`,element:x(Z,{to:Mx(`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(rC,{})})}),x(Q,{path:`/retrain`,element:x(Z,{to:`/addon/training`,replace:!0})}),x(Q,{path:`/recordings`,element:x($,{requireAdmin:!0,children:x(iC,{})})}),x(Q,{path:`/build`,element:x($,{requireAdmin:!0,children:x(oC,{})})}),x(Q,{path:xx,element:x($,{requireAdmin:!0,children:x(sC,{})})}),x(Q,{path:Sx,element:x($,{requireAdmin:!0,children:x(sC,{})})}),x(Q,{path:`/locations`,element:x($,{requireAdmin:!0,children:x(cC,{})})}),x(Q,{path:`/automation`,element:x(fv,{to:`/build`})}),x(Q,{path:`/addon/:pagePath`,element:x($,{requireAdmin:!0,children:x(cy,{})})}),x(Q,{path:`*`,element:x(Z,{to:`/devices`,replace:!0})})]})]})})})}),x(Av,{}),x(Ha,{})]})})})})})})})})})}O(),window.__camstackUiLibrary=li,window.__camstackSdk=mr,window.__camstackTypes=cn;var NC=Wi(document.getElementById(`root`));ia(window.location.pathname,Je())?HS(NC):NC.render(x(T,{children:x(MC,{})}));export{Im as $,Fu as $n,uf as $t,M_ as A,vd as An,bu as Ar,op as At,Ph as B,Du as Bn,Hc as Br,kf as Bt,Mv as C,Bd as Cn,du as Cr,gp as Ct,rv as D,Hd as Dn,lu as Dr,sp as Dt,hv as E,Vd as En,fu as Er,lp as Et,D_ as F,Qu as Fn,Pc as Fr,bf as Ft,Th as G,Iu as Gn,Nf as Gt,Nh as H,Xu as Hn,Lf as Ht,T_ as I,ud as In,Z as Ir,xf as It,eh as J,id as Jn,Sf as Jt,_h as K,nd as Kn,Af as Kt,rg as L,Ku as Ln,X as Lr,zf as Lt,F_ as M,bd as Mn,Tl as Mr,rp as Mt,k_ as N,Sd as Nn,Ol as Nr,np as Nt,V_ as O,Cd as On,ou as Or,cp as Ot,O_ as P,xd as Pn,Sl as Pr,Zf as Pt,Hm as Q,ld as Qn,lf as Qt,ng as R,Vu as Rn,ms as Rr,Gf as Rt,my as S,Ld as Sn,mu as Sr,jp as St,Tv as T,jd as Tn,vu as Tr,xp as Tt,Mh as U,td as Un,Tf as Ut,Lh as V,Ju as Vn,Ef as Vt,jh as W,cd as Wn,If as Wt,Xm as X,ku as Xn,Bf as Xt,nh as Y,Hu as Yn,Ff as Yt,Lm as Z,Au as Zn,yf as Zt,ub as _,Zd as _n,uu as _r,mp as _t,kx as a,mf as an,qu as ar,Ym as at,Hy as b,Yd as bn,su as br,Tp as bt,Ax as c,of as cn,Nu as cr,nm as ct,Px as d,af as dn,rd as dr,Lp as dt,pf as en,Lu as er,qm as et,Cx as f,nf as fn,Mu as fr,Dp as ft,pb as g,Rd as gn,hu as gr,Sp as gt,wx as h,qd as hn,xu as hr,kp as ht,Ox as i,vf as in,Uu as ir,Am as it,N_ as j,Ed as jn,yu as jr,ip as jt,z_ as k,_d as kn,gu as kr,up as kt,Mx as l,cf as ln,Zu as lr,em as lt,Tx as m,tf as mn,Cu as mr,hp as mt,nS as n,gf as nn,$u as nr,Fm as nt,Ex as o,Qd as on,Gu as or,Cm as ot,bx as p,rf as pn,Tu as pr,yp as pt,lh as q,ed as qn,Mf as qt,jx as r,_f as rn,dd as rr,jm as rt,Dx as s,sf as sn,ju as sr,im as st,oS as t,hf as tn,Ru as tr,Jm as tt,Nx as u,ef as un,Yu as ur,$p as ut,db as v,Jd as vn,au as vr,pp as vt,bv as w,Nd as wn,pu as wr,_p as wt,Vy as x,Xd as xn,cu as xr,Op as xt,By as y,Wd as yn,_u as yr,vp as yt,Hh as z,Wu as zn,vs as zr,jf as zt};
|
|
4
|
+
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let d=X(),f;if(t){let e=typeof t==`string`?eo(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})):ro(e,{pathname:m});Ya(u||h!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),Ya(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=Os(h&&h.map(e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:No([l,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?l:No([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(ts.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...f},navigationType:`POP`}},g):g}function Ss(){let e=Ls(),t=zo(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 Cs=o(Ss,null),ws=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=cs(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:o(ns.Provider,{value:this.props.routeContext},o(rs.Provider,{value:e,children:this.props.component}));return this.context?o(Es,{error:e},t):t}};ws.contextType=Yo;var Ts=new WeakMap;function Es({children:e,error:t}){let{basename:n}=L(es);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=ss(t.digest);if(e){let r=Ts.get(t);if(r)throw r;let i=Ho(e.location,n),a=i.absoluteURL||i.to;if(Ko(a))throw Error(`Invalid redirect location`);if(Vo&&!Ts.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 Ts.set(t,n),n}return o(`meta`,{httpEquiv:`refresh`,content:`0;url=${a}`})}}return e}function Ds({routeContext:e,match:t,children:n}){let r=L(qo);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),o(ns.Provider,{value:e},n)}function Os(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:Bo(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||Cs,s&&(c<0&&l===0?(Bs(`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(Ds,{match:n,routeContext:{outlet:e,matches:h,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||l===0)?o(ws,{location:r.location,revalidation:r.revalidation,component:p,error:d,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:u}):g()},null)}function ks(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function As(e){let t=L(qo);return Y(t,ks(e)),t}function js(e){let t=L(Jo);return Y(t,ks(e)),t}function Ms(e){let t=L(ns);return Y(t,ks(e)),t}function Ns(e){let t=Ms(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 Ps(){return Ns(`useRouteId`)}function Fs(){let e=js(`useNavigation`);return m(()=>{let{matches:t,historyAction:n,...r}=e.navigation;return r},[e.navigation])}function Is(){let{matches:e,loaderData:t}=js(`useMatches`);return m(()=>e.map(e=>ao(e,t)),[e,t])}function Ls(){let e=L(rs),t=js(`useRouteError`),n=Ns(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Rs(){let{router:e}=As(`useNavigate`),t=Ns(`useNavigate`),n=p(!1);return ps(()=>{n.current=!0}),b(async(r,i={})=>{Ya(n.current,fs),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var zs={};function Bs(e,t,n){!t&&!zs[e]&&(zs[e]=!0,Ya(!1,n))}v(Vs);function Vs({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return xs(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function Z({to:e,replace:t,state:n,relative:r}){Y(us(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=L(es);Ya(!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(ns),{pathname:o}=X(),s=ms(),c=jo(e,Ao(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 Hs({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,useTransitions:s}){Y(!us(),`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=eo(n));let{pathname:u=`/`,search:d=``,hash:f=``,state:p=null,key:h=`default`,mask:g}=n,_=m(()=>{let e=To(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 Ya(_!=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(es.Provider,{value:l},o(ts.Provider,{children:t,value:_}))}function Us({children:e,location:t}){return bs(Ws(e),t)}function Ws(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,Ws(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=Ws(e.props.children,i)),n.push(a)}),n}var Gs=`get`,Ks=`application/x-www-form-urlencoded`;function qs(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function Js(e){return qs(e)&&e.tagName.toLowerCase()===`button`}function Ys(e){return qs(e)&&e.tagName.toLowerCase()===`form`}function Xs(e){return qs(e)&&e.tagName.toLowerCase()===`input`}function Zs(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Qs(e,t){return e.button===0&&(!t||t===`_self`)&&!Zs(e)}function $s(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 ec(e,t){let n=$s(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var tc=null;function nc(){if(tc===null)try{new FormData(document.createElement(`form`),0),tc=!1}catch{tc=!0}return tc}var rc=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function ic(e){return e!=null&&!rc.has(e)?(Ya(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ks}"`),null):e}function ac(e,t){let n,r,i,a,o;if(Ys(e)){let o=e.getAttribute(`action`);r=o?To(o,t):null,n=e.getAttribute(`method`)||Gs,i=ic(e.getAttribute(`enctype`))||Ks,a=new FormData(e)}else if(Js(e)||Xs(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?To(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||Gs,i=ic(e.getAttribute(`formenctype`))||ic(o.getAttribute(`enctype`))||Ks,a=new FormData(o,e),!nc()){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(qs(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=Gs,r=null,i=Ks,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 oc={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},sc=/[&><\u2028\u2029]/g;function cc(e){return e.replace(sc,e=>oc[e])}function lc(e,t){if(e===!1||e==null)throw Error(t)}function uc(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&&To(i.pathname,t)===`/`?i.pathname=`${Po(t)}/_root.${r}`:i.pathname=`${Po(i.pathname)}.${r}`,i}async function dc(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 fc(e){return e!=null&&typeof e.page==`string`}function pc(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 mc(e,t,n){return yc((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await dc(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(pc).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function hc(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 gc(e,t,{includeHydrateFallback:n}={}){return _c(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 _c(e){return[...new Set(e)]}function vc(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function yc(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!fc(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(vc(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function bc(){let e=L(qo);return lc(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function xc(){let e=L(Jo);return lc(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var Sc=j(void 0);Sc.displayName=`FrameworkContext`;function Cc(){let e=L(Sc);return lc(e,`You must render this element inside a <HydratedRouter> element`),e}function wc(e,t){let n=L(Sc),[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:Tc(s,m),onBlur:Tc(c,h),onMouseEnter:Tc(l,m),onMouseLeave:Tc(u,h),onTouchStart:Tc(d,m)}]:[a,f,{}]:[!1,f,{}]}function Tc(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Ec({page:e,...t}){let n=Xo(),{nonce:r}=Cc(),{router:i}=bc(),a=m(()=>ro(i.routes,e,i.basename),[i.routes,e,i.basename]);return a?(t.nonce==null&&r&&(t={...t,nonce:r}),o(n?Oc:kc,{page:e,matches:a,...t})):null}function Dc(e){let{manifest:t,routeModules:n}=Cc(),[r,i]=w([]);return S(()=>{let r=!1;return mc(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function Oc({page:e,matches:t,...n}){let r=X(),{future:i}=Cc(),{basename:a}=bc();return o(d,null,m(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=uc(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 kc({page:e,matches:t,...n}){let r=X(),{future:i,manifest:a,routeModules:s}=Cc(),{basename:c}=bc(),{loaderData:l,matches:u}=xc(),f=m(()=>hc(e,t,u,a,r,`data`),[e,t,u,a,r]),p=m(()=>hc(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=uc(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(()=>gc(p,a),[p,a]),_=Dc(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 Ac(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var jc=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{jc&&(window.__reactRouterVersion=`7.18.0`)}catch{}function Mc({basename:e,children:t,useTransitions:n,window:r}){let i=p();i.current??=Ja({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(Hs,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:a,useTransitions:n})}function Nc({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(Hs,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,useTransitions:r})}Nc.displayName=`unstable_HistoryRouter`;var Pc=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(es),b=typeof u==`string`&&Ua.test(u),x=Ho(u,_);u=x.to;let S=ls(u,{relative:r}),C=X(),w=null;if(s){let e=jo(s,[],C.mask?C.mask.pathname:`/`,!0);_!==`/`&&(e.pathname=e.pathname===`/`?_:No([_,e.pathname])),w=v.createHref(e)}let[T,E,D]=wc(n,h),O=Vc(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:Ac(g,E),target:l,"data-discover":!b&&t===`render`?`true`:void 0});return T&&!b?o(d,null,j,o(Ec,{page:S})):j});Pc.displayName=`Link`;var Fc=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=ys(a,{relative:l.relative}),f=X(),p=L(Jo),{navigator:m,basename:h}=L(es),g=p!=null&&Qc(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=To(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(Pc,{...l,"aria-current":w,className:T,ref:u,style:E,to:a,viewTransition:s},typeof c==`function`?c(C):c)});Fc.displayName=`NavLink`;var Ic=A(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:s=Gs,action:c,onSubmit:l,relative:u,preventScrollReset:d,viewTransition:p,defaultShouldRevalidate:m,...h},g)=>{let{useTransitions:_}=L(es),v=Gc(),y=Kc(c,{relative:u}),b=s.toLowerCase()===`get`?`get`:`post`,x=typeof c==`string`&&Ua.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})});Ic.displayName=`Form`;function Lc({getKey:e,storageKey:t,...n}){let r=L(Sc),{basename:i}=L(es),a=X(),s=Is();Xc({getKey:e,storageKey:t});let c=m(()=>{if(!r||!e)return null;let t=Yc(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})(${cc(JSON.stringify(t||qc))}, ${cc(JSON.stringify(c))})`}})}Lc.displayName=`ScrollRestoration`;function Rc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function zc(e){let t=L(qo);return Y(t,Rc(e)),t}function Bc(e){let t=L(Jo);return Y(t,Rc(e)),t}function Vc(e,{target:t,replace:n,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c,useTransitions:l}={}){let u=ms(),d=X(),p=ys(e,{relative:o});return b(m=>{if(Qs(m,t)){m.preventDefault();let t=n===void 0?$a(d)===$a(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 Hc(e){Ya(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($s(e)),n=p(!1),r=X(),i=m(()=>ec(r.search,n.current?null:t.current),[r.search]),a=ms();return[i,b((e,t)=>{let r=$s(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var Uc=0,Wc=()=>`__${String(++Uc)}__`;function Gc(){let{router:e}=zc(`useSubmit`),{basename:t}=L(es),n=Ps(),r=e.fetch,i=e.navigate;return b(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=ac(e,t);a.navigate===!1?await r(a.fetcherKey||Wc(),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 Kc(e,{relative:t}={}){let{basename:n}=L(es),r=L(ns);Y(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...ys(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:No([n,a.pathname])),$a(a)}var qc=`react-router-scroll-positions`,Jc={};function Yc(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:To(e.pathname,n)||e.pathname},t)),i??=e.key,i}function Xc({getKey:e,storageKey:t}={}){let{router:n}=zc(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=Bc(`useScrollRestoration`),{basename:a}=L(es),o=X(),s=Is(),c=Fs();S(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Zc(b(()=>{if(c.state===`idle`){let t=Yc(o,s,a,e);Jc[t]=window.scrollY}try{sessionStorage.setItem(t||qc,JSON.stringify(Jc))}catch(e){Ya(!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||qc);e&&(Jc=JSON.parse(e))}catch{}},[t]),u(()=>{let t=n?.enableScrollRestoration(Jc,()=>window.scrollY,e?(t,n)=>Yc(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{Ya(!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 Zc(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 Qc(e,{relative:t}={}){let n=L(Zo);Y(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=zc(`useViewTransitionState`),i=ys(e,{relative:t});if(!n.isTransitioning)return!1;let a=To(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=To(n.nextLocation.pathname,r)||n.nextLocation.pathname;return xo(i.pathname,o)!=null||xo(i.pathname,a)!=null}var $c=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}}))()),el=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function tl(e){var t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],($c.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(el),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 nl=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,rl=/^\s*$/,il=Object.create(null);function al(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(al,``)+`</`+t.name+`>`;case`comment`:return e+`<!--`+t.comment+`-->`}}var ol={parse:function(e,t){t||={},t.components||=il;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(nl,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=tl(s);return a<0?(r.push(m),r):((l=i[a]).children.push(m),r)}if(u&&(a++,(n=tl(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);rl.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+al(``,t)},``)}};O();var sl=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},cl=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?ul(t):t},ll=e=>Array.isArray(e)&&e.every(h),ul=e=>Array.isArray(e)?e:[e],dl=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},fl=e=>{let t={};if(!e)return t;let n=e=>{ul(e).forEach(e=>{qi(e)||(sl(e)?n(cl(e)):Qi(e)&&!h(e)&&Object.assign(t,e))})};return n(e),t},pl=(e,t,n,r)=>{if(!e)return``;let i=``,a=ul(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach((e,a)=>{if(qi(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=qi(d)?d:pl(d,t,n,r);i+=`<${c}>${e}</${c}>`;return}let f=pl(d,t,n,r);i+=`<${a}>${f}</${a}>`;return}if(e===null){Yi(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(Qi(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}Yi(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}Yi(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},ml=(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},hl=(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=>{ul(e).forEach(e=>{qi(e)||(sl(e)?p(cl(e)):Qi(e)&&!h(e)&&Object.assign(f,e))})};p(e);let m=ml(n,l,f),g=ol.parse(`<0>${m}</0>`),v={...f,...a},y=(e,t,n)=>{let r=cl(e),i=x(r,t.children,n);return ll(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=ul(e),d=ul(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];qi(t)&&(g[e]=Zi(t))});let _=Object.keys(g).length===0?m:dl({props:g},m),S=h(_),C=S&&sl(n,!0)&&!n.voidElement,w=u&&Qi(_)&&_.dummy&&!S,T=Qi(t)&&Object.hasOwnProperty.call(t,n.name);if(qi(_)){let t=r.services.interpolator.interpolate(_,v,r.language);e.push(t)}else if(sl(_)||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?ul(cl(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(Qi(_)&&!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:Ki().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 cl(x([{dummy:!0,children:e||[]}],g,ul(e||[]))[0])},gl=(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})},_l=(e,t)=>e.map((e,n)=>gl(e,n,t)),vl=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:gl(e[r],r,t)})}),n},yl=(e,t,n,r)=>e?Array.isArray(e)?_l(e,t):Qi(e)?vl(e,t):($i(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,bl=e=>!Qi(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function xl({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||Ji();if(!h)return $i(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),_={...Ki(),...h.options?.react},v=u||g.ns||h.options?.defaultNS;v=qi(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=pl(e,_,h,r),T=c||b?.defaultValue||w||_.transEmptyNodeValue||(typeof r==`function`?Gi(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=fl(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=yl(C,j,h,r),N=M||e,P=null;bl(M)&&(P=M,N=e);let F=hl(N,P,j,h,_,A,x),I=n??_.defaultTransParent;return I?o(I,m,F):F}O();function Sl({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(Xi)||{},g=u||m||Ji(),_=d||g?.t.bind(g);return xl({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 Cl=`camstack:broker-oauth`;function wl(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`camstack:broker-oauth`&&typeof t.ok==`boolean`}function Tl(e,t){return e.split(`{{brokerId}}`).join(encodeURIComponent(t))}function El(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||wl(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 Dl={open:e=>ra(e),assign:e=>window.location.assign(e),watch:(e,t)=>El(e,t)};function Ol(e,t,n=Dl){let r=H(ta(e)),i=n.open(r);if(i===null){n.assign(r);return}n.watch(i,e=>{t?.(e)})}var kl=[`starting`,`awaiting-login`,`captured`,`error`,`cancelled`],Al=[`awaiting-code`,`captured`,`expired`,`error`,`cancelled`];function jl(e){return typeof e==`object`&&!!e}function Ml(e){return jl(e)&&typeof e.sessionId==`string`&&typeof e.loginUrl==`string`}function Nl(e){return jl(e)&&typeof e.sessionId==`string`&&typeof e.phase==`string`&&kl.includes(e.phase)}function Pl(e){return jl(e)&&typeof e.sessionId==`string`&&typeof e.userCode==`string`&&typeof e.verificationUrl==`string`&&typeof e.expiresAt==`number`}function Fl(e){return Pl(e)&&jl(e)&&typeof e.phase==`string`&&Al.includes(e.phase)}function Il(e){return jl(e)&&typeof e.brokerId==`string`}function Ll(){return{"Content-Type":`application/json`,Authorization:`Bearer ${localStorage.getItem(`camstack_admin_token`)??``}`}}async function Rl(e,t){try{return await e.json()}catch{throw Error(`${t} failed: HTTP ${e.status}`)}}function zl(e){let t=jl(e)&&typeof e.error==`string`?e.error:`Unknown error`;return Error(t)}async function Bl(e,t,n){let r=await fetch(H(e),{method:`POST`,headers:Ll(),body:JSON.stringify(t)}),i=await Rl(r,`Sign-in ${e.split(`/`).pop()??`request`}`);if(!r.ok)throw zl(i);if(!n(i))throw Error(`Unexpected response from server`);return i}function Vl(e,t){return Bl(`${e}/start`,t,Ml)}function Hl(e,t){return Bl(`${e}/code/start`,t,Pl)}async function Ul(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(H(`${e}/status?${n.toString()}`),{headers:{Authorization:Ll().Authorization??``}}),i=await Rl(r,`Sign-in status`);if(!r.ok)throw zl(i);if(!Fl(i))throw Error(`Unexpected status response from server`);return i}async function Wl(e,t){let n=new URLSearchParams({sessionId:t}),r=await fetch(H(`${e}/status?${n.toString()}`),{headers:{Authorization:Ll().Authorization??``}}),i=await Rl(r,`Sign-in status`);if(!r.ok)throw zl(i);if(!Nl(i))throw Error(`Unexpected status response from server`);return i}function Gl(e,t){return Bl(`${e}/commit`,{...t},Il)}async function Kl(e,t){try{await fetch(H(`${e}/cancel`),{method:`POST`,headers:Ll(),body:JSON.stringify({sessionId:t})})}catch{}}O();var ql=2e3,Jl=1e3;function Yl(e){let t=Math.max(0,Math.ceil(e/1e3));return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,`0`)}`}function Xl({expiresAt:e}){let{t}=J(),[n,r]=w(()=>Date.now());return S(()=>{let e=setInterval(()=>r(Date.now()),Jl);return()=>clearInterval(e)},[]),x(`span`,{className:`text-[11px] text-foreground-subtle`,children:t(`brokers.signIn.codeExpiresIn`,{time:Yl(e-n)})})}function Zl({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&&Kl(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 Gl(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 Ul(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{}})()},ql)},[e,_,g,m,o]),y=async()=>{h(),l({kind:`starting`});try{let t=await Hl(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(yr,{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(Cn,{className:`h-3.5 w-3.5`}):x(_e,{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(U,{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(Ie,{className:`h-3.5 w-3.5`}),` `,o(`brokers.signIn.openCodePage`,{host:Ql(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(U,{className:`h-3 w-3 animate-spin flex-shrink-0`}),` `,o(`brokers.signIn.waitingForCode`)]}),x(Xl,{expiresAt:T.expiresAt})]}),x(K,{variant:`outline`,size:`sm`,className:`shrink-0 whitespace-nowrap`,onClick:C,children:o(`brokers.signIn.cancel`)})]})]})}function Ql(e){try{let t=new URL(e);return`${t.host}${t.pathname===`/`?``:t.pathname}`}catch{return e}}O();var $l=2e3;function eu(e){return e.startsWith(`/`)&&!e.startsWith(`//`)?new URL(e,window.location.origin).toString():e}function tu({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&&Kl(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 Gl(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 Wl(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{}})()},$l)},[e,_,g,m,o]),y=async()=>{h(),l({kind:`starting`});try{let t=await Vl(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(yr,{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(Cn,{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(U,{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(eu(c.loginUrl),`_blank`,`noopener,noreferrer`),children:[x(Ie,{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(U,{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(U,{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 nu=[`device-code`];function ru({methods:e,...t}){let{t:n}=J(),r=e!==void 0&&e.length>0?e:nu,[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(Ci,{value:o,onValueChange:e=>a(e===`device-code`?e:`proxy`),appearance:`pills`,children:x(yi,{"aria-label":n(`brokers.signIn.method`),children:r.map(e=>x(Xr,{value:e,children:n(e===`device-code`?`brokers.signIn.methodDeviceCode`:`brokers.signIn.methodProxy`)},e))})}),o===`device-code`?x(Zl,{...t},`device-code`):x(tu,{...t},`proxy`)]})}function iu(e){return t=>Object.prototype.hasOwnProperty.call(e,t)}var au=iu({devices:!0}),ou=iu({classes:!0,classesExclude:!0,labelEquals:!0,identities:!0,identitiesExclude:!0,eventTypeTokens:!0,sensorKinds:!0}),su=iu({minConfidence:!0,minImportance:!0,minLabelConfidence:!0}),cu=iu({minDwellSeconds:!0}),lu=iu({source:!0}),uu=iu({crossing:!0}),du=iu({packagePhase:!0}),fu=iu({sensorTransition:!0}),pu=iu({plates:!0}),mu=iu({occupancy:!0}),hu=iu({audio:!0}),gu=iu({systemEvent:!0}),_u=iu({deviceState:!0}),vu=iu({scene:!0});function yu(e,t){let n=e[t];return Array.isArray(n)?n:[]}function bu(e,t){let n=e[t];return typeof n==`number`?n:void 0}O();function xu(e,t){let n=W().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 Su(e){let t=W().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 Cu(){let e=nr();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 wu(){let e=zr({limit:200}),t=ci();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 Tu({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(Di,{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 Eu=[{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`)}}],Du=`Immediate, grouped`,Ou=Eu.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 ku(e){return e.groupingSec!==void 0&&Lt(e)?`immediate-grouped`:e.delivery}function Au(e){let t=(e.delivery===`immediate`||e.delivery===`track-end`)&&Lt({delivery:`immediate`,conditions:e.conditions});return Ou.filter(e=>e.value!==`immediate-grouped`||t)}function ju(e){return Ou.find(t=>t.value===e)?.value}function Mu(e,t=Du){return ku(e)===`immediate-grouped`?`${t} · ${String(e.groupingSec)} s`:Pu(e.delivery)}function Nu(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}function Pu(e){return Eu.find(t=>t.value===e)?.label??e}function Fu(e){return Eu.some(t=>t.value===e)}var Iu=[{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 Lu(e){return ft(pt(e)).editable}function Ru(e){return It(zu(e))}function zu(e){switch(e){case`device-events`:case`system`:case`alarm`:case`mixed`:return e;default:return}}var Bu=new Map([[0,`helpers.ruleFormParsers.cdNone`],[60,`helpers.ruleFormParsers.cd1m`],[3600,`helpers.ruleFormParsers.cd1h`]]),Vu=86400;function Hu(e){let t=Bu.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 Uu(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}var Wu=[{value:`rule-device`,get label(){return q.t(`helpers.ruleFormParsers.scopeDevice`)}},{value:`rule`,get label(){return q.t(`helpers.ruleFormParsers.scopeRule`)}}];function Gu(e){return Wu.find(t=>t.value===e)?.value}var Ku=[{value:`per-class`,get label(){return q.t(`helpers.ruleFormParsers.granPerClass`)}},{value:`shared`,get label(){return q.t(`helpers.ruleFormParsers.granShared`)}}];function qu(e){return Ku.find(t=>t.value===e)?.value}var Ju=[{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 Yu(e){return Ju.find(t=>t.value===e)?.value}var Xu=[{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 Zu(e){let t=Xu.find(t=>t.value===e)?.value;return t===``?void 0:t}var Qu=[{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 $u(e){let t=Qu.find(t=>t.value===e)?.value;return t===``?void 0:t}var ed=[{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`)}}],td=[{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`)}}],nd=[{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 rd(e){return e===`raised`||e===`cleared`?e:void 0}function id(e,t){return e===`sensorTransition`?Nt(t.sensorKinds):!0}var ad=[{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`)}}],od=`enter`;function sd(e){return e===`exit`||e===`any`?e:void 0}var cd=[{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 ld(e,t){return e.options&&e.options.length>0?e.options:t}var ud=[{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 dd(e){if(e===``)return;let t=Number(e);return Number.isFinite(t)&&t>=1&&t<=8?t:void 0}var fd={days:[0,1,2,3,4,5,6],minute:480},pd=[{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 md(e){let t=Math.floor(e/60),n=e%60;return`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`}function hd(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 gd={mode:`modes`,onActivation:!0,onDeactivation:!1};function _d(e){return e!==void 0&&$t.includes(e)}function vd(e,t){return gt({conditions:t.length>0?{systemEvent:{kinds:[...t]}}:{},...e===void 0?{}:{systemEventDelivery:e}})}function yd(e){return{mode:`modes`,onActivation:e.onActivation,onDeactivation:e.onDeactivation}}function bd(e,t,n){return t===`activation`?{...e,onActivation:n}:t===`deactivation`?{...e,onDeactivation:n}:n?e.onSchedule===void 0?{...e,onSchedule:{schedule:jt([fd]),grouping:`section`}}:e:yd(e)}function xd(e,t){return{...e,onSchedule:{schedule:t,grouping:e.onSchedule?.grouping??`section`}}}function Sd(e,t){return e.onSchedule===void 0?e:{...e,onSchedule:{...e.onSchedule,grouping:t}}}function Cd(e){let t=new Set,n=0;for(let r of e){let e=Vt(r);e===void 0?n+=1:t.add(e.label)}return{adds:[...t],without:n}}function wd(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 Td(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 Ed(e,t,n,r=`rule`){if(e===`error`)return wd(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=Td(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 Dd=`notificationRules.systemEventKinds.`,Od=`notificationRules.systemEventGroups.`,kd=`notificationRules.systemEventHints.`;function Ad(e){return!Ht.some(t=>t===e)}function jd(e){let t=`${Dd}${e}`;return q.exists(t)?q.t(t):e}function Md(){return Mt.map(e=>({id:e.id,family:e.family,label:q.t(`${Od}${e.id}`,e.label),hint:q.t(`${kd}${e.id}`),kinds:e.kinds.filter(Ad).map(e=>({value:e,label:jd(e)}))}))}function Nd(e){return Md().filter(t=>t.family===e)}function Pd(e){let t=tn(e).conditions.systemEvent;return t===void 0?{kinds:(Nd(e)[0]?.kinds??[]).map(e=>e.value)}:{...t,kinds:[...t.kinds]}}function Fd(){return Md().flatMap(e=>e.kinds)}function Id(e){return{devices:wt(e,`deviceIds`),deviceTypes:wt(e,`deviceTypes`),nodes:wt(e,`nodeIds`),packages:wt(e,`packageNames`),consumableThreshold:wt(e,`consumableLowPercent`)}}function Ld(e,t){let n=Ot[e],r=Id(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}}var Rd=Object.values(Dt).map(e=>({value:e,label:zd(e)})).toSorted((e,t)=>e.label.localeCompare(t.label));function zd(e){let t=e.replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function Bd(e,t){let n=[],r=new Set;for(let i of e.kinds){let e=Vt(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]:ut(e),clears:ut(e),classId:e.id,...t&&e.snapshotSection===null?{noSnapshot:!0}:{}}))}return n}function Vd(e,t){return t.clears.some(t=>e.includes(t))}function Hd(e,t,n){if(!Nd(n).some(e=>e.kinds.some(e=>t.kinds.includes(e.value))))return e;let r=e?.kinds??[];if(Vd(r,t)){let i=r.filter(e=>!t.clears.includes(e));return i.length===0?e:Kd(e,i,n)}return Kd(e,Fd().filter(e=>t.kinds.includes(e.value)||r.includes(e.value)).map(e=>e.value),n)}function Ud(e,t){return t===void 0?void 0:Kd(t,t.kinds,e)}function Wd(e,t){let n=e?.kinds??[];if(n.length===0)return;let r=Gd(t,`deviceIds`,e?.deviceIds),i=Gd(t,`excludeDeviceIds`,e?.excludeDeviceIds),a=Gd(t,`deviceTypes`,e?.deviceTypes),o=Gd(t,`nodeIds`,e?.nodeIds),s=Gd(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 Gd(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 Kd(e,t,n){let r=Ld(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 qd=95;function Jd(e){let t=e.trim();if(t===``)return{kind:`clear`};let n=Number(t);return Number.isInteger(n)&&n>=1&&n<=qd?{kind:`set`,value:n}:{kind:`invalid`}}function Yd(e,t=2){if(e===void 0||e.length===0)return q.t(`helpers.notificationSystemEvents.noneSelected`);let n=e.slice(0,t).map(jd).join(`, `),r=e.length-Math.min(t,e.length);return r>0?`${n} +${r}`:n}function Xd(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(zd).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 Zd(e){return e===void 0||(e.deviceTypes?.length??0)===0?!1:e.kinds.some(e=>_t.includes(e))}var Qd=[`all`,`only`,`except`];function $d(e,t){return(e??[]).length>0?`only`:(t??[]).length>0?`except`:`all`}function ef(e,t){let n=[...e??[]],r=[...t??[]];return{mode:$d(n,r),include:n,exclude:r,legacyBoth:n.length>0&&r.length>0}}function tf(e,t){return{...e,mode:t}}function nf(e){switch(e.mode){case`only`:return e.include;case`except`:return e.exclude;case`all`:return[]}}function rf(e,t){switch(e.mode){case`only`:return{...e,include:[...t]};case`except`:return{...e,exclude:[...t]};case`all`:return e}}function af(e){return e.mode===`only`&&e.legacyBoth?e.exclude:[]}function of(e){return{...e,exclude:[],legacyBoth:!1}}function sf(e){switch(e.mode){case`all`:return{};case`except`:return e.exclude.length>0?{exclude:[...e.exclude]}:{};case`only`:{let t=af(e);return{...e.include.length>0?{include:[...e.include]}:{},...t.length>0?{exclude:[...t]}:{}}}}}function cf(e){let t=sf(e),n=t.include??[],r=t.exclude??[];return[...e.include.filter(e=>!n.includes(e)),...e.exclude.filter(e=>!r.includes(e))]}var lf=[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`],uf={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`)}}},df={onActivation:[],onDeactivation:[],onTrigger:[],onTriggerOff:[],buttons:[]};function ff(e){return e===void 0?df:{onActivation:[...e.onActivation??[]],onDeactivation:[...e.onDeactivation??[]],onTrigger:[...e.onTrigger??[]],onTriggerOff:[...e.onTriggerOff??[]],buttons:[...e.buttons??[]]}}function pf(e){let t=e.buttons.filter(e=>e.id.trim()!==``&&e.label.trim()!==``&&e.sequenceId.trim()!==``),n={onActivation:e.onActivation,onDeactivation:e.onDeactivation,onTrigger:e.onTrigger,onTriggerOff:e.onTriggerOff};if(!(!lf.some(e=>n[e].length>0)&&t.length===0))return{...n.onActivation.length>0?{onActivation:[...n.onActivation]}:{},...n.onDeactivation.length>0?{onDeactivation:[...n.onDeactivation]}:{},...n.onTrigger.length>0?{onTrigger:[...n.onTrigger]}:{},...n.onTriggerOff.length>0?{onTriggerOff:[...n.onTriggerOff]}:{},...t.length>0?{buttons:t}:{}}}function mf(e,t){let n=[];for(let r of lf){let i=e[r];i.length>4&&n.push({kind:`too-many`,message:q.t(`helpers.notificationRuleActions.tooMany`,{title:uf[r].title})});for(let e of i)e.kind===`sequence`&&!t.has(e.sequenceId)&&n.push({kind:`unknown-sequence`,message:q.t(`helpers.notificationRuleActions.hookUnknownSeq`,{title:uf[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.sequenceId.trim())||n.push({kind:`unknown-sequence`,message:q.t(`helpers.notificationRuleActions.buttonUnknownSeq`,{label:i.label||e})}))}return n}function hf(e,t){return{id:`action-${String(e+1)}`,label:q.t(`helpers.notificationRuleActions.newButtonLabel`),sequenceId:t}}function gf(){return{kind:`do`,action:{kind:`cap`,deviceId:0,cap:``,method:``}}}function _f(e){return{kind:`sequence`,sequenceId:e}}function vf(){return{kind:`wait`,seconds:5}}var yf=[{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`)}}],bf=[10,30,60],xf=[5,10,15,30,60,120,240,480];function Sf(e){return e>=60&&e%60==0?q.t(`helpers.ruleFormState.snoozeHours`,{count:e/60}):q.t(`helpers.ruleFormState.snoozeMin`,{count:e})}var Cf=new Set([`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`]),wf=`alarm-panel`;function Tf(e,t){for(let t of e.systemEvent?.kinds??[])if(Cf.has(t))return!0;for(let e of t)if(e.kind===`cap`&&e.cap===wf)return!0;return!1}function Ef(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`])for(let i of e[t])if(i.kind===`do`)r.push(i.action);else{let e=n.get(i.sequenceId);e!==void 0&&r.push(...e.actions)}for(let t of e.buttons){let e=n.get(t.sequenceId);e!==void 0&&r.push(...e.actions)}return r}function Df(e){let{devices:t,devicesExclude:n,classes:r,classesExclude:i,...a}=e;return{conditions:a,deviceScope:ef(t,n),classScope:ef(r,i)}}function Of(e){let t=sf(e.deviceScope),n=sf(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 kf(e){return e.deviceScope.mode===`only`?e.deviceScope.include:[]}function Af(e,t,n){let r=pt(n);return e.some(e=>e.id===t&&fn(e,n.delivery,r))}function jf(e=`immediate`,t={}){return{name:``,enabled:!0,delivery:e,targetIds:[],targetUsers:[],targetParams:{},priority:3,mediaImage:Zt({},pt({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:``,...Df(t),schedule:void 0,systemEventDelivery:e===`system-event`?gd:void 0,snoozeAllowGlobal:!1,groupingSec:void 0,snoozeOptions:void 0,askVerdict:void 0,actions:df,cooldownSec:30,cooldownScope:`rule-device`,cooldownGranularity:void 0}}function Mf(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,enabled:e.enabled,delivery:e.delivery,targetIds:e.targets.map(e=>e.targetId),targetUsers:e.targetUsers??[],targetParams:t,priority:e.priority,mediaImage:Zt(e.media,pt(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??``,...Df(e.conditions),schedule:e.schedule,systemEventDelivery:e.systemEventDelivery,snoozeAllowGlobal:e.snoozeAllowGlobal===!0,groupingSec:e.groupingSec,snoozeOptions:e.snoozeOptions,askVerdict:e.askVerdict,actions:ff(e.actions),cooldownSec:e.throttle.cooldownSec,cooldownScope:e.throttle.scope,cooldownGranularity:e.throttle.granularity}}function Nf(e,t){let n=[];if(Vf(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&&!Hf(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(ht(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(Vu)} (24 hours). 0 means every match is delivered.`),dn(e.delivery))for(let t of Ct({delivery:e.delivery,conditions:e.conditions,...e.systemEventDelivery===void 0?{}:{systemEventDelivery:e.systemEventDelivery},...pf(e.actions)===void 0?{}:{actions:pf(e.actions)}}))n.push(Tt(t));return n}function Pf(e){let t=e.systemEventDelivery;if(t===void 0)return{};if(!dn(e.delivery))return t.mode===`instant`?{}:{systemEventDelivery:{mode:`instant`}};let n=bt(e.conditions.systemEvent?.kinds??[]);if(!(n.kind===`family`&&$t.includes(n.family)))return t.mode===`modes`?{}:{systemEventDelivery:t};let r=Rt({systemEventDelivery:t}).schedule;if(r!==null&&yt(r.schedule)===null){let e=mt(r.schedule);if(e!==null&&e.times.length>0){let n=jt(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 Ff(e){if(!If(e))return null;if(!pn(e.templateBody))return q.t(`helpers.ruleFormState.summaryWarnNone`,{token:`{{summaryText}}`});let t=e.templateBody;return Pt({...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 If(e){return Et({delivery:e.delivery,...e.systemEventDelivery===void 0?{}:{systemEventDelivery:e.systemEventDelivery}})}function Lf(e,t,n=new Set){return Nf(e,t).length===0&&Fu(e.delivery)&&(!dn(e.delivery)||Kf(e)>0)&&pt(e)!==`mixed`&&e.name.trim().length>0&&(e.targetIds.length>0||e.targetUsers.length>0)&&mf(e.actions,n).length===0}function Rf(e,t){let n=Wf(e.conditions,t),r=dn(t)&&(n.systemEvent?.kinds.length??0)===0,i=dn(t)&&e.systemEventDelivery===void 0?gd:e.systemEventDelivery;return r?{...e,delivery:t,systemEventDelivery:i,conditions:{...n,systemEvent:Pd(`device-events`)}}:{...e,delivery:t,conditions:n,systemEventDelivery:i}}function zf(e,t){return t===`immediate-grouped`?{...Rf(e,`immediate`),groupingSec:e.groupingSec??20}:{...Rf(e,t),groupingSec:void 0}}function Bf(e){return e.delivery===`immediate`||e.delivery===`track-end`}function Vf(e){return e.groupingSec!==void 0&&Lt(e)}function Hf(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 Uf=new Set([`immediate`,`track-end`,`package-event`]);function Wf(e,t){if(e.source!==`pipeline`||Uf.has(t))return e;let{source:n,...r}=e;return r}function Gf(e,t){return en(e.conditions.systemEvent)===t?e:{...e,conditions:{...e.conditions,systemEvent:Pd(t)}}}function Kf(e){return e.conditions.systemEvent?.kinds.length??0}function qf(e,t){return e.appliesTo.includes(t)}var Jf={source:`any`};function Yf(e,t){if(t==null)return!0;if(Array.isArray(t))return t.length===0;if(typeof t==`string`)return t.length===0||Jf[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 Xf=zt.filter(e=>e.id===`audio`);function Zf(e){if(e.length===0)return e;let t=new Set(e.map(e=>e.id)),n=Xf.filter(e=>!t.has(e.id));return n.length===0?e:[...e,...n]}function Qf(e,t,n,r=pt({delivery:t,conditions:e})){let i=n.length===0?null:new Set(n.filter(e=>e.id!==`schedule`&&fn(e,t,r)).map(e=>e.id)),a={};for(let[t,n]of Object.entries(e))i!==null&&!i.has(t)||id(t,e)&&(Yf(t,n)||(a[t]=n));return a}function $f(e,t){if(e===void 0)return{};let n=Ud(e,t.systemEvent);return n===void 0?{}:{systemEvent:n}}function ep(e){return e!==void 0&&e.windows.length>0}function tp(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 np(e){let t=tp(e.media);return{...e.confirm===void 0?{}:{confirm:e.confirm},...t===void 0?{}:{media:t}}}function rp(e,t,n=[]){let r=e.templateTitle.trim(),i=e.templateBody.trim(),a=r.length>0||i.length>0?{...r.length>0?{title:r}:{},...i.length>0?{body:i}:{}}:void 0,o=pf(e.actions),s=pt(e),c=ft(s),l=lt(s),u=n.length===0?!0:n.some(t=>t.id===`schedule`&&qf(t,e.delivery)),d=!If(e)&&u&&ep(e.schedule)?e.schedule:void 0,f=n.length===0?!0:n.some(t=>t.id===`devices`&&qf(t,e.delivery)),p=n.length===0?!0:n.some(t=>t.id===`devicesExclude`&&qf(t,e.delivery)),{devices:m,devicesExclude:h,...g}=Of(e),_=Qf(g,e.delivery,n,s);return{name:e.name.trim(),enabled:e.enabled,delivery:e.delivery,conditions:{..._,...f&&m!==void 0?{devices:m}:{},...p&&h!==void 0?{devicesExclude:h}:{},...$f(l,e.conditions)},...d?{schedule:d}:{},...Pf(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]}:{},media:c.carriesMedia?{image:e.mediaImage,...e.mediaShowTriggerZone&&e.mediaImage!==`crop`&&e.mediaImage!==`none`&&Xt(_).length>0?{showTriggerZone:!0}:{},...e.mediaShowSubjectPath&&e.mediaImage!==`none`&&Jt(s)?{showSubjectPath:!0}:{},...e.mediaGif?{gif:!0}:{},...e.mediaClip?{clip:!0}:{},...e.mediaProfile===void 0?{}:{profile:e.mediaProfile},...e.mediaClipSpeed===void 0?{}:{clipSpeed:e.mediaClipSpeed},...s===`sensor`&&e.mediaImage!==`none`&&e.mediaLinkedCameras!==void 0?{linkedCameras:e.mediaLinkedCameras}:{},...s===`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,...a?{template:a}:{},...e.snoozeAllowGlobal?{snoozeAllowGlobal:!0}:{},...Vf(e)?{groupingSec:e.groupingSec}:{},...e.snoozeOptions===void 0?{}:{snoozeOptions:[...e.snoozeOptions]},...e.askVerdict!==void 0&&Bf(e)?{askVerdict:e.askVerdict}:{},...t?.confirm===void 0?{}:{confirm:t.confirm},...o===void 0?{}:{actions:o}}}function ip(e,t){let n=rp(e,void 0,t);return[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`groupingSec`,`actions`].filter(e=>n[e]===void 0)}var ap=[{key:`rule`,get label(){return q.t(`helpers.ruleFormTabs.tab_rule`)},fields:[`name`,`enabled`,`delivery`,`groupingSec`,`targetIds`,`targetUsers`,`targetParams`]},{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 op(e,t={}){let n=pt({delivery:e,conditions:t}),r=ft(n),i=ap.map(e=>e.key===`conditions`?{...e,label:r.label}:e);return It(n)?i.filter(e=>e.key!==`devices`):i}function sp(e){if(e.audio!==void 0)return q.t(`helpers.ruleFormTabs.condSound`);if(e.occupancy!==void 0)return q.t(`helpers.ruleFormTabs.condOccupancy`)}function cp(e){let t=pt(e),n=Yt(Of(e),t);return t===`sensor`&&e.conditions.sensorTransition!==void 0&&!id(`sensorTransition`,e.conditions)?[...n,{conditionId:`sensorTransition`,reason:Kt}]:n}var lp=`rule`;function up(e){return ap.find(t=>t.key===e)?.key}function dp(e){return e?.toLowerCase().startsWith(`it`)===!0?`it`:`en`}function fp(){let{i18n:e}=J(),t=dp(e.language);return e=>kt(e,t)}O();var pp=`block text-[11px] font-medium text-foreground`,mp=`text-[10px] text-foreground-subtle mt-0.5`;function hp({cameras:e,fleet:t,value:n,onChange:r,emptyMeansAll:i=!1,savedHadDevices:a=!1}){return x(br,{devices:e,listState:t.state,fleet:t,value:n,onChange:r,emptyMeansAll:i,savedHadDevices:a})}function gp({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(Me,{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 _p({picker:e,value:t,onChange:n}){let{t:r}=J(),i=m(()=>mn(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 vp({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(Pr,{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 yp({value:e,onChange:t,options:n}){let{t:r}=J(),i=bp(n??[]),a=i.length>0?i:ad;return s(`div`,{className:`mt-1 space-y-1`,children:[x($e,{value:e??`enter`,options:a.map(e=>({value:e.value,label:r(`notificationRules.crossing.${e.value}`,e.label)})),onChange:e=>t(sd(e.target.value))}),x(`p`,{className:mp,children:r(`notificationRules.crossing.hint`,`Which way the subject crosses the zone.`)})]})}function bp(e){let t=[];for(let n of e){let e=n.value===``||n.value===`enter`?od:sd(n.value);e===void 0||t.some(t=>t.value===e)||t.push({value:e,label:n.label})}return t}function xp({deviceIds:e,cameras:t,value:n,onChange:r}){let{options:i,loading:a}=xu(e,t);return x(Tu,{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 Sp({deviceIds:e,value:t,onChange:n}){let{t:r}=J(),{options:i,loading:a}=Su(e);return x(Tu,{options:i,value:t,onChange:n,loading:a,emptyHint:e.length===0?`Select cameras above to pick their event kinds — or type a token.`:`No event kinds reported for the selected cameras — type a token.`,placeholder:r(`system.notificationConditionWidgets.eventToken`,`Event token…`)})}var Cp=[{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 wp(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 Tp({deviceIds:e,cameras:t,classOptions:n,value:r,onChange:i}){let{t:a}=J(),{options:o,loading:c}=xu(e,t),l=r??ln,u=e=>i({...l,...e}),d=l.op===`became-occupied`||l.op===`became-free`,f=wp(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($e,{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($e,{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($e,{value:l.op,options:Cp.map(e=>({value:e.value,label:a(e.labelKey)})),onChange:e=>{let t=Cp.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 Ep=[{value:`label`,labelKey:`system.notificationConditionWidgets.audioModeLabel`,Icon:ne},{value:`level`,labelKey:`system.notificationConditionWidgets.audioModeLevel`,Icon:ze}];function Dp({taxonomy:e,value:t,onChange:n}){let{t:r}=J(),i=xt(t),a=e=>n(Wt(t,e)),{choices:o,unknownLabels:c}=St(e,i.labels),l=an(t)??`label`;return s(`div`,{className:`mt-1 space-y-2`,children:[s(`div`,{className:`flex flex-wrap items-center gap-1`,children:[Ep.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=Gt(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:qt(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(Mi,{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:vt,max:0,step:3,className:`w-20`,value:String(i.dbThreshold??Bt),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:Ut.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:Ut.samplingSeconds})]})]}),x(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`system.notificationConditionWidgets.dbfsHint`,{min:vt})})]}),ht(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 Op({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=wu().filter(e=>!r.includes(e));return s(`div`,{className:`mt-1 space-y-1.5`,children:[x(gp,{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 kp({gateable:e,value:t,onChange:n}){let{t:r}=J(),i=fp(),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($e,{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 Ap(e,t){let n=t(e.verdict);return e.latched?`${n} · ${t(`latched`)}`:n}function jp({scenes:e,value:t,onChange:n}){let{t:r}=J(),i=fp(),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:mp,children:r(`notificationRules.scene.none`,`No scenes yet — create one on the Scenes page.`)}):s(`div`,{className:`mt-1 space-y-2`,children:[x($e,{value:t?.sceneId??``,options:[{value:``,label:r(`notificationRules.scene.noGate`,`— no scene gate —`)},...e.map(e=>({value:e.sceneId,label:`${e.cameraName} · ${e.label} — ${Ap(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($e,{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($e,{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:`),` `,Ap(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 Mp(e){return md(e)}function Np(e){return hd(e)}function Pp(){return{days:[1,2,3,4,5],startMinute:540,endMinute:1080}}function Fp(e){return{days:[...fd.days],minute:e}}var Ip=`Always active — add a window to restrict when the rule fires.`;function Lp({value:e,onChange:t,mode:n=`windows`,defaultMinute:r=fd.minute,emptyHint:i}){return n===`times`?x(zp,{value:e,onChange:t,defaultMinute:r}):x(Rp,{value:e,onChange:t,emptyHint:i??Ip})}function Rp({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,Pp()],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:mp,children:n}):i.map((e,t)=>x(Bp,{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(Se,{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(Di,{checked:a,onChange:e=>o([...i],e.target.checked),className:`accent-primary`}),r(`system.notificationScheduleField.activeOutsideTheWindows`,`Active outside the windows`)]})]})]})}function zp({value:e,onChange:t,defaultMinute:n}){let{t:r}=J(),i=e?.timezone,a=e===void 0?{times:[],approximated:!1}:mt(e);if(a===null)return s(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times-fallback`,children:[x(`p`,{className:mp,children:r(`system.notificationScheduleField.invertedScheduleShownAsBands`,`Inverted schedule — shown as bands. Clear the invert flag (or the windows) to author punctual times.`)}),x(Rp,{value:e,onChange:t,emptyHint:Ip})]});let o=a.times,c=e=>{if(e.length===0){t(void 0);return}t(jt(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:mp,children:r(`system.notificationScheduleField.noTimesYetAddOne`,`No times yet — add one to send on those days at that clock time.`)}):o.map((e,t)=>x(Vp,{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,Fp(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(Se,{className:`h-3 w-3`}),` `,r(`system.notificationScheduleField.addTime`)]})]})}function Bp({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:Mp(e.startMinute),onChange:n=>t({...e,startMinute:Np(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:Mp(e.endMinute),onChange:n=>t({...e,endMinute:Np(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(de,{className:`h-3.5 w-3.5`})})]}),x(Hp,{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 Vp({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:md(e.minute),onChange:t=>n({...e,minute:hd(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(de,{className:`h-3.5 w-3.5`})})]}),x(Hp,{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 Hp({days:e,onToggle:t}){return x(`div`,{className:`flex flex-wrap gap-1`,children:pd.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 Up(e){return e>=8}O();function Wp(e){if(typeof e!=`object`||!e)return;let t=Reflect.get(e,`windows`);if(!(!Array.isArray(t)||t.length===0))return e}function Gp(e){return e.type===`multiselect`}function Kp(e){let t=e.suggestions;return t===void 0||t.length===0?[]:t.map(e=>({value:e,label:e}))}function qp(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 Jp(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Yp({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(!ei(e,t,l))return null;let r=e.creatable!==!1;return x(pr,{mode:`multi`,options:Kp(e),value:Jp(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:Zp(e.label,a),description:e.description===void 0?void 0:Zp(e.description,a),placeholder:e.placeholder??d(`formBuilder.formBuilder.searchOrAdd`,`Search or add…`),testId:`config-tags-${e.key}`})}if(e.type===`schedule`){if(!ei(e,t,l))return null;let r=Zp(e.label,a),i=e.description===void 0?void 0:Zp(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(Lp,{mode:o,value:Wp(t[e.key]),onChange:t=>n(e.key,t)})]})}return Gp(e)&&(Up(e.options.length)||e.creatable===!0)?ei(e,t,l)?x(pr,{mode:`multi`,options:qp(e.options),value:Jp(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:Zp(e.label,a),description:e.description===void 0?void 0:Zp(e.description,a),placeholder:e.placeholder??d(`formBuilder.formBuilder.searchToAdd`,`Search to add…`),testId:`config-multiselect-${e.key}`,listboxId:`msel-${e.key}`}):null:x(ar,{field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:o,externalProbe:c,allFields:l,onAction:u})}function Xp(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Zp(e,t){if(e!==void 0)return t&&Xp(e)?t(e):e}function Qp({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+ +!!ei(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:Zp(e.title,a)}),e.description&&x(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:Zp(e.description,a)})]}),x(di,{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:Zp(e.title,a)}),e.description&&x(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:Zp(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(Yp,{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(ar,{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 $p({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(Qp,{section:e,values:u,onChange:d,onChangeMany:f,disabled:r,translationFn:i,onTestField:a,probeResults:o,onAction:c},`${e.id}-${t}`))})}function em(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 tm={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 nm({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 ${tm[e.status]}`,"data-testid":`connection-test-verdict`,children:n})}var rm=new Set;function im(e){for(let t of rm)t(e)}function am(e){return rm.add(e),()=>{rm.delete(e)}}var om=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`]),sm=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function cm(e){let t=sm.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?sm.length:t}function lm(e){return e.filter(e=>!e.name.startsWith(`.`)&&!om.has(e.name)).toSorted((e,t)=>{let n=cm(e.name)-cm(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}O();function um({nodeId:e,value:t,onChange:n}){let{t:r}=J(),i=W().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(lm(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 dm=`storage/path-browser`,fm=`nodeId`,pm=`providerId`,mm=`basePath`,hm=`hub`;function gm(e,t){let n=e[t];return typeof n==`string`?n:``}function _m(e,t){let n=e.sections.flatMap(e=>e.fields),r=n.find(e=>e.key===fm);if(r===void 0)return null;let i=gm(t,pm),a=`showWhen`in r?r.showWhen:void 0;return a!==void 0&&!(i!==``&&a.in?.includes(i))?null:(i===``?[mm]:[`${i}.${mm}`,mm]).find(e=>n.some(t=>t.key===e))??null}function vm(e,t){let n=_m(e,t);return n===null?[]:[n]}function ym({schema:e,values:t,onValuesChange:n}){let{t:r}=J(),i=_m(e,t);if(i===null)return null;let a=gm(t,fm);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(um,{nodeId:a===``?hm:a,value:gm(t,i),onChange:e=>n({...t,[i]:e})})]})}var bm=new Map([[dm,{Component:ym,ownedKeys:vm}]]);function xm(e){return bm.get(e)??null}function Sm(e,t){return t.length===0?e:{...e,sections:e.sections.map(e=>({...e,fields:e.fields.filter(e=>!t.includes(e.key))}))}}function Cm(e){let t=new Map;for(let n of e){let e=n?.manifest;e?.id&&t.set(e.id,e.name??e.packageDisplayName??e.id)}return t}function wm(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}for(let e of a.instances){let t=Tm(a.description,e.kind);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:a.description.canTest,...e.kind===void 0?{}:{kindId:e.kind},...e.kind===void 0?{}:{kindLabel:t?.label??e.kind},...e.lastCheckedAt===void 0?{}:{lastCheckedAt:e.lastCheckedAt},...t?.connectPath===void 0?{}:{connectPath:t.connectPath},...t?.disconnectPath===void 0?{}:{disconnectPath:t.disconnectPath}})}}return n}function Tm(e,t){return t===void 0?void 0:e.kinds?.find(e=>e.id===t)}function Em(e,t,n){let r=e.kinds;if(r===void 0||r.length===0)return e;let i=r.filter(e=>e.functionCap===t&&(n===void 0||e.id===n));return i.length===0?null:{...e,kinds:i}}function Dm(e,t){let n=Em(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 Om(e){return(e.kinds?.length??0)>1}function km(e,t,n){return Om(e)&&t!==void 0?t.label:n}function Am(e){return e.label!==void 0&&e.label.length>0?e.label:e.state}function jm(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 Mm={error:3,unknown:2,ok:1,off:0};function Nm(e){return e.enabled?e.status===void 0?e.configured?`ok`:`unknown`:e.status.state:`off`}function Pm(e){let t=null;for(let n of e){let e=Nm(n);(t===null||Mm[e]>Mm[t])&&(t=e)}return t??`unknown`}function Fm(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:Pm(a)}:{addonId:e.addonId,name:r,count:1,health:o.isActive?`ok`:`off`}})}function Im(e,t){return t===null?e:e.filter(e=>e.addonId===t)}function Lm(e){return e.filter(e=>e.description.instanceMode===`multiple`||e.instances.length===0)}function Rm(e){return e.some(e=>e.isError)?`error`:e.some(e=>e.isPending)?`pending`:`ready`}function zm(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(!zm(n[e],r[e]))return!1;return!0}var Bm=`enabled`;function Vm(e,t){return t?.sections.some(e=>e.fields.some(e=>e.key===Bm))===!0?{...e}:Object.fromEntries(Object.entries(e).filter(([e])=>e!==Bm))}function Hm(e,t){let n={};for(let[r,i]of Object.entries(t))i!==void 0&&(zm(e[r],i)||(n[r]=i));return n}function Um(e,t){let n={...e};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function Wm(e,t,n){return e===`single`?t:`inst-${n()}`}function Gm(){let e=crypto.getRandomValues(new Uint8Array(4));return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}var Km=`+`;function qm(e,t){return t===void 0?e:`${e}:${t===null?Km:t}`}function Jm(e){let t=e.indexOf(`:`);if(t<0)return{kind:`fixed`,addonId:e};let n=e.slice(0,t),r=e.slice(t+1);return r===Km?{kind:`create`,addonId:n}:{kind:`instance`,addonId:n,id:r}}function Ym(e,t){return e.filter(e=>e.formValues.smtpInstanceId===t).map(e=>e.name)}var Xm=/^[a-z0-9][a-z0-9-]{0,63}$/;function Zm(e,t){return t===``?`empty`:e.pattern.test(t)?`ok`:`invalid`}O();var Qm=5e3,$m=`integration-instances`,eh=`provider-instances-holder`;function th(e){let t=new Map;for(let n of e){let e=n?.manifest;typeof e?.id==`string`&&typeof e.description==`string`&&e.description.length>0&&t.set(e.id,e.description)}return t}function nh(e){let t=W(),n=xi({capName:e},{refetchInterval:Qm}),r=xi({capName:$m},{refetchInterval:Qm}),i=pi(void 0,{refetchInterval:Qm}),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:[eh,e],refetchInterval:Qm,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=Rm([n,r,...o]),c=m(()=>o.flatMap(t=>{let n=t.data===void 0?null:Dm(t.data,e);return n===null?[]:[n]}),[o,e]),l=m(()=>Cm(i.data??[]),[i.data]),u=m(()=>th(i.data??[]),[i.data]),d=m(()=>wm({functionProviders:a,holders:c,displayNames:l,descriptions:u}),[a,c,l,u]),f=n.error??r.error??o.find(e=>e.error)?.error??null,p=b(()=>{n.refetch(),r.refetch();for(let e of o)e.refetch()},[n,r,o]);return{state:s,error:f===null?null:f.message,functionProviders:a,rows:d,holders:c,displayNames:l,descriptions:u,refetch:p}}O();var rh=`name`,ih=`kind`,ah=`restore`,oh=`restoreId`,sh=`typedId`,ch={};function lh({addonId:e,providerName:t,description:n,instance:r,onClose:i,onSaved:a,lead:o,typedId:c}){let{t:l}=J(),u=W(),d=N(),f=r?.id??null,h=n.kinds??[],g=km(n,Tm(n,r?.kind??h[0]?.id),t),[_,v]=w({[rh]:r?.name??g,[ih]:r?.kind??h[0]?.id??``,[ah]:!1,[oh]:``,[sh]:``}),y=p(g),b=_[ih];S(()=>{if(r!==null||typeof b!=`string`)return;let e=km(n,Tm(n,b),t),i=y.current;y.current=e,v(t=>t[rh]===i?{...t,[rh]:e}:t)},[b,n,r,t]);let C=e=>{let t=_[e];return typeof t==`string`?t.trim():``},T=C(rh),D=C(ih),O=Tm(n,D===``?void 0:D),k=_[ah]===!0,A=C(oh),j=r===null&&n.allowRestoreId===!0&&O?.signIn===void 0,M=j&&k&&A===``,F=r===null&&O?.signIn===void 0&&!(j&&k)?c?.(D===``?void 0:D):void 0,L=C(sh),ee=F===void 0?`ok`:Zm(F,L),[R,te]=w({...r?.formValues??ch}),[ne,ie]=w(null),ae=m(()=>({sections:[{id:`instance-identity`,title:l(`providerInstances.identity`,`Identity`),columns:1,fields:[...r===null&&Om(n)?[{type:`select`,key:ih,label:l(`providerInstances.colKind`,`Kind`),options:h.map(e=>({value:e.id,label:e.label}))}]:[],{type:`text`,key:rh,label:l(`providerInstances.colName`,`Name`),required:!0},...F===void 0?[]:[{type:`text`,key:sh,label:l(`providerInstances.typedId`,`Id`),required:!0,description:ee===`invalid`?l(`providerInstances.typedIdInvalid`,`Lowercase letters, digits and dashes, starting with a letter or digit (up to 64).`):l(`providerInstances.typedIdHint`,`Chosen once; it cannot be changed after the record is created.`)}],...j?[{type:`boolean`,key:ah,label:l(`providerInstances.restore`,`Restore under its old id`),description:l(`providerInstances.restoreHint`,`Re-adding something that was removed under its original id keeps everything that points at it working.`)},{type:`text`,key:oh,label:l(`providerInstances.originalId`,`Original id`),required:!0,showWhen:{field:ah,equals:!0}}]:[]]}]}),[j,n,F,r,h,l,ee]),[oe,se]=w(null),z=f===null&&D!==``?D:void 0,B=E({queryKey:[`provider-instance-form`,e,f,z??null],queryFn:()=>u.trpcClient.integrationInstances.instanceFormSchema.query({addonId:e,id:f,...z===void 0?{}:{kind:z}})}),V=m(()=>r===null?ch:Vm(r.formValues,B.data),[r,B.data]),ce=m(()=>Vm(R,B.data),[R,B.data]),le=m(()=>B.data?Ft(B.data,{...V}):null,[B.data,V]),ue=(O?.widgets??[]).flatMap(e=>{let t=e.placement===`connection`?xm(e.id):null;return t===null?[]:[{id:e.id,widget:t}]}),de=le===null?[]:ue.flatMap(({widget:e})=>e.ownedKeys(le,R)),fe=P({mutationFn:async()=>{let t=u.trpcClient.integrationInstances,i=Hm(V,ce);if(r===null){let r=j&&k?A:F===void 0?n.mintsId===!0?void 0:Wm(n.instanceMode,e,Gm):L,a=await t.createInstance.mutate({addonId:e,name:T,...r===void 0?{}:{id:r},...D===``?{}:{kind:D}});return Object.keys(i).length>0&&await t.updateInstance.mutate({addonId:e,id:a.id,values:i}),a.id}return await t.updateInstance.mutate({addonId:e,id:r.id,name:T,values:i}),r.id},onSuccess:e=>{d.invalidateQueries({queryKey:[eh]}),im({title:l(`providerInstances.saved`,`Saved`),message:T,severity:`info`}),a?.(e),i()},onError:e=>ie(e.message)}),pe=P({mutationFn:()=>u.trpcClient.integrationInstances.testInstance.mutate({addonId:e,id:f,values:Hm(V,ce)}),onSuccess:e=>se(em(e)),onError:e=>se({status:`inconclusive`,error:e.message})});return x(Hn,{open:!0,onClose:i,title:r===null?l(`providerInstances.createTitle`,`Add {{provider}}`,{provider:km(n,O,t)}):l(`providerInstances.editTitle`,`Edit {{name}}`,{name:r.name}),error:ne??(B.isError?B.error.message:null),width:`lg`,footer:s(I,{children:[n.canTest&&s(K,{size:`sm`,variant:`outline`,type:`button`,disabled:pe.isPending||le===null,onClick:()=>{se(null),pe.mutate()},children:[pe.isPending?x(U,{className:`h-3.5 w-3.5 animate-spin`}):null,l(`providerInstances.test`,`Test connection`)]}),s(K,{size:`sm`,type:`button`,disabled:fe.isPending||le===null||T.length===0||M||ee!==`ok`,onClick:()=>{ie(null),fe.mutate()},children:[fe.isPending?x(U,{className:`h-3.5 w-3.5 animate-spin`}):null,r===null?l(`providerInstances.create`,`Create`):l(`providerInstances.saveChanges`,`Save changes`)]})]}),children:s(`div`,{className:`space-y-4`,children:[r===null?null:o,x($p,{schema:ae,values:_,onChange:v}),O?.signIn!==void 0&&x(ru,{basePath:O.signIn.basePath,...O.signIn.methods===void 0?{}:{methods:O.signIn.methods},name:T,...r===null?{}:{brokerId:r.id},getSettings:()=>Um(V,ce),disabled:T.length===0,onSignedIn:e=>{d.invalidateQueries({queryKey:[`provider-instances-holder`]}),a?.(e),i()}}),r!==null&&O?.connectPath!==void 0&&s(K,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>Ol(Tl(O.connectPath??``,r.id),()=>void d.invalidateQueries({queryKey:[`provider-instances-holder`]})),children:[x(re,{className:`h-3.5 w-3.5`}),l(`providerInstances.connect`,`Connect account`)]}),le===null?B.isError?null:s(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[x(U,{className:`h-3 w-3 animate-spin`}),l(`providerInstances.loading`,`Loading…`)]}):s(I,{children:[x(Vn,{schema:Sm(le,de),values:R,onChange:te}),ue.map(({id:e,widget:{Component:t}})=>x(t,{schema:le,values:R,onValuesChange:te},e))]}),oe!==null&&x(nm,{verdict:oe})]})})}O();var uh=`integration-instances`,dh=`instance-kinds-describe`;function fh(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(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}})}return n}function ph(e){let t=W(),n=xi({capName:e.functionCap}),r=xi({capName:uh}),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:[dh,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(()=>fh(a,e),[a,e.functionCap,e.addonId,e.kind]),holders:a,isLoading:n.isLoading===!0||r.isLoading===!0||i.some(e=>e.isLoading)}}function mh({children:e,onClose:t}){return x(Kn,{open:!0,onOpenChange:e=>!e&&t(),children:s(er,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[x(Fn,{children:x(_r,{children:`\xA0`})}),x(Qn,{children:e})]})})}function hh({functionCap:e,kind:t,addonId:n,onClose:r,onSaved:i,typedId:a}){let{t:o}=J(),s=W(),c=N(),l=ph({functionCap:e,...n===void 0?{}:{addonId:n},...t===void 0?{}:{kind:t}}),u=l.options[0],d=n??u?.addonId,f=E({queryKey:[`instance-create-description`,d,e,u?.kind??null],enabled:d!==void 0,queryFn:async()=>Em(await s.trpcClient.integrationInstances.describe.query({addonId:d??``}),e,u?.kind)});return d===void 0||f.data===null?x(mh,{onClose:r,children:d===void 0&&l.isLoading?x(U,{className:`h-4 w-4 animate-spin`}):x(yr,{message:o(`brokers.editor.noProvider`)})}):f.isError?x(mh,{onClose:r,children:x(yr,{message:f.error.message})}):f.data===void 0?x(mh,{onClose:r,children:x(U,{className:`h-4 w-4 animate-spin`})}):x(lh,{addonId:d,providerName:u?.label??``,description:f.data,instance:null,onClose:r,...a===void 0?{}:{typedId:a},onSaved:e=>{c.invalidateQueries(),i(e)}})}O();var gh={ok:`success`,off:`default`,unknown:`default`,error:`danger`};function _h({kind:e,value:t,onChange:n,optional:r=!1,noneLabel:i,disabled:a=!1}){let{t:o}=J(),[c,l]=w(!1),u=Er({kind:e}),d=Jr(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(U,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.picker.loading`)]}),u.isError&&x(yr,{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(Bn,{variant:gh[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(Se,{className:`h-3.5 w-3.5`}),` `,o(`brokers.picker.createNew`)]}),c&&x(hh,{functionCap:`broker`,kind:e,onClose:()=>l(!1),onSaved:e=>{l(!1),n(e)}})]})}var vh=`broker`;function yh({functionCap:e,kind:t,noneLabel:n,required:r,disabled:i,value:a,onChange:o}){return e===vh&&t!==void 0?x(_h,{kind:t,value:a,onChange:o,optional:r===!1,disabled:i===!0,...n===void 0?{}:{noneLabel:n}}):x(Qr,{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`}`})}function bh(e,t){return t.map(t=>({subject:{kind:`device`,deviceId:e},key:t.key,scope:t.scope}))}function xh({deviceId:e}){let{t}=J(),{presence:n,list:r}=In(e);return n===`absent`?null:n===`unknown`?x(yr,{message:t(`deviceQuickDetail.historyUnknown`,`Could not tell whether this device has recorded history.`)}):n===`pending`||r.status===`pending`?x(cr,{className:`h-24 w-full`,"aria-busy":`true`}):r.status===`error`?x(yr,{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(Pc,{to:$r(bh(e,r.data)),className:`text-xs text-primary hover:underline`,children:t(`deviceQuickDetail.openHistory`,`Open full history`)})}),x(Ri,{deviceId:e})]})}function Sh(e,t){return e===`present`&&t.status===`ok`&&(t.data?.length??0)>0}var Ch={streaming:{icon:An,labelKey:`capabilityBadges.streaming`},detection:{icon:ve,labelKey:`capabilityBadges.detection`},recording:{icon:ae,labelKey:`capabilityBadges.recording`},audio:{icon:Qe,labelKey:`capabilityBadges.audio`},snapshot:{icon:we,labelKey:`capabilityBadges.snapshot`},motion:{icon:ot,labelKey:`capabilityBadges.motion`},ptz:{icon:it,labelKey:`capabilityBadges.ptz`},webrtc:{icon:z,labelKey:`capabilityBadges.webrtc`},onvif:{icon:Re,labelKey:`capabilityBadges.onvif`},analytics:{icon:Ze,labelKey:`capabilityBadges.analytics`},"battery-operated":{icon:qe,labelKey:`capabilityBadges.battery`},"native-snapshot":{icon:we,labelKey:`capabilityBadges.nativeSnapshot`},"pan-tilt-zoom":{icon:it,labelKey:`capabilityBadges.ptz`},"two-way-audio":{icon:Qe,labelKey:`capabilityBadges.twoWayAudio`},"doorbell-button":{icon:ke,labelKey:`capabilityBadges.doorbell`},rebootable:{icon:_e,labelKey:`capabilityBadges.rebootable`},"vacuum-has-map":{icon:kn,labelKey:`capabilityBadges.map`},"vacuum-has-ai":{icon:Ye,labelKey:`capabilityBadges.aiObstacle`},"mower-has-map":{icon:kn,labelKey:`capabilityBadges.map`},"mower-has-targeted-mowing":{icon:te,labelKey:`capabilityBadges.targetedMowing`}},wh=B;function Th({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=Ch[e],i=r?.icon??wh,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)})})}O();var Eh={amcrest:{icon:Mn,color:`#3b82f6`,label:`Amcrest`},hikvision:{icon:be,color:`#a855f7`,label:`Hikvision`},reolink:{icon:z,color:`#06b6d4`,label:`Reolink`},homeassistant:{icon:pe,color:`#22d3ee`,label:`Home Assistant`},rtsp:{icon:nt,color:`#78716c`,label:`RTSP`},onvif:{icon:nt,color:`#78716c`,label:`ONVIF`}},Dh={sm:`h-4 w-4`,md:`h-5 w-5`,lg:`h-6 w-6`,xl:`h-16 w-16`},Oh={sm:`h-7 w-7`,md:`h-8 w-8`,lg:`h-10 w-10`,xl:`h-16 w-16`};function kh(e){let t=e.toLowerCase();return t.startsWith(`provider-`)?t.slice(9):t}function Ah(e){return Eh[kh(e)]??{icon:Mn,color:`#78716c`,label:e}}function jh({type:e,size:t=`md`,showLabel:n}){let r=Ah(e),i=r.icon,[a,o]=w(!1),c=ua(e);return s(`div`,{className:`flex items-center gap-2`,children:[x(`div`,{className:`flex items-center justify-center rounded-lg ${Oh[t]}`,style:{backgroundColor:`${r.color}15`},children:a||!c?x(i,{className:Dh[t],style:{color:r.color}}):x(`img`,{src:c,alt:r.label,className:Dh[t],onError:()=>o(!0)})}),n&&x(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:r.label})]})}function Mh({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:`${xe} 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 Nh(e){return Yn({addonId:e,projection:`slim`})}function Ph(e){return gr({deviceId:e},{enabled:Number.isFinite(e)})}var Fh=3e4,Ih=2e3;function Lh(e){let t=p(0);return t.current===0&&(t.current=Date.now()),Bi({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>=Fh?!1:Ih}})}O();function Rh({deviceId:e}){let{t}=J(),n=N(),{data:r}=Ph(e),{data:i}=Lh(e),[a,o]=w(null),c=qr({onSuccess:()=>{o(null),n.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{o(`Could not change primary child: ${e.message}`)}});if(r==null||String(r.type??``)!==Dt.Container)return null;let l=String(r.name??``),u=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:fi(e,l),...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}}));if(u.length<=1)return null;let d=Dr(u,typeof r.linkDeviceId==`number`?r.linkDeviceId:null,typeof r.primaryChildEntityId==`string`?r.primaryChildEntityId:null),f=d===null?u[0].id:d.id;return s(I,{children:[x(Mh,{label:t(`shared.primaryChildRow.primaryChild`,`Primary child`),value:x(vi,{childrenList:u,selectedId:f,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 zh=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`];function Bh(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function Vh(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function Hh(){let{t:e}=J(),t=Tr(),n=ki(),{data:r}=gr({deviceId:t??0},{enabled:t!==null}),{data:i}=lr({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=_!==null&&Object.keys(_).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`)}),v&&s(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[x(Uh,{active:o===`identity`,onClick:()=>c(`identity`),label:e(`overviewAdapters.deviceInfoAdapter.identity`,`Identity`)}),x(Uh,{active:o===`hardware`,onClick:()=>c(`hardware`),label:e(`overviewAdapters.deviceInfoAdapter.hardware`,`Hardware`)})]})]}),(!v||o===`identity`)&&s(`div`,{className:`divide-y divide-border`,children:[x(Mh,{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(Rh,{deviceId:t}),d!==null&&x(Mh,{label:e(`overviewAdapters.deviceInfoAdapter.integration`,`Integration`),value:x(`span`,{className:`font-mono text-[11px]`,children:d})}),f!==null&&x(Mh,{label:e(`overviewAdapters.deviceInfoAdapter.parent`,`Parent`),value:x(`span`,{className:`font-mono text-[11px]`,children:`#${String(f)}`})}),x(Mh,{label:e(`overviewAdapters.deviceInfoAdapter.provider`,`Provider`),value:x(jh,{type:u,size:`sm`,showLabel:!0})}),x(Mh,{label:e(`overviewAdapters.deviceInfoAdapter.capabilities`,`Capabilities`),value:g.length>0?x(Th,{capabilities:g,showLabels:!0}):x(`span`,{className:`text-[11px] text-foreground-subtle`,children:e(`overviewAdapters.deviceInfoAdapter.none`,`None`)})})]}),v&&o===`hardware`&&x(Wh,{metadata:_})]})}function Uh({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 Wh({metadata:e}){let{t}=J(),n=zh.filter(t=>t in e),r=Object.keys(e).filter(e=>!zh.includes(e)).toSorted(),i=[...n,...r];return s(`div`,{children:[x(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border bg-surface-subtle/40`,children:t(`overviewAdapters.deviceInfoAdapter.autoPopulatedByTheDriver`,`Auto-populated by the driver on every connect. Read-only.`)}),x(`div`,{className:`divide-y divide-border`,children:i.map(t=>x(Mh,{label:Bh(t),value:x(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:Vh(e[t])})},t))})]})}function Gh(e,t){return e.icon===t.icon&&e.label===t.label&&e.unit===t.unit&&e.precision===t.precision&&e.hidden===t.hidden}function Kh(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function qh(e){if(e.trim()===``)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function Jh(e,t){let n=qh(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 Yh(e){let t=Kh(e.display);return{name:e.name,location:e.location,role:e.role,display:t,baseName:e.name,baseLocation:e.location,baseRole:e.role,baseDisplay:t,persistedDisplay:e.display}}function Xh(e,t){if(e===null)return Yh(t);let n=Kh(t.display),r=e.name===t.name&&e.location===t.location&&e.role===t.role&&Gh(e.display,n);return!Zh(e)||r?Yh(t):e}function Zh(e){return e===null?!1:e.name!==e.baseName||e.location!==e.baseLocation||e.role!==e.baseRole||!Gh(e.display,e.baseDisplay)}function Qh(e){return e.name.trim().length===0?`name`:null}function $h(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},...Gh(e.display,e.baseDisplay)?{}:{display:Jh(e.display,e.persistedDisplay)}}}function eg(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 tg=j(null);function ng(){return L(tg)}function rg({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=Xh(a,t);(a===null||e.name!==a.name||e.location!==a.location||e.role!==a.role||!Gh(e.display,a.display)||e.baseName!==a.baseName||e.baseLocation!==a.baseLocation||e.baseRole!==a.baseRole||!Gh(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})},setIdentityDisplay:e=>{o(t=>t===null?t:{...t,display:{...t.display,...e}})},register:u}),[a,u]);return x(tg.Provider,{value:d,children:x(ig,{deviceId:e,identity:a,contributions:s,onIdentitySaved:e=>o(e),showOpenFull:n,onClose:r,children:i})})}function ig({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:i,onClose:a,children:o}){return s(I,{children:[o,x(og,{deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:i,onClose:a})]})}function ag(e){return e instanceof Error?e.message:String(e)}function og({deviceId:e,identity:t,contributions:n,onIdentitySaved:r,showOpenFull:i,onClose:a}){let{t:o}=J(),c=ms(),l=Pe(),u=N(),[d,f]=w(null),[p,m]=w(!1),h=si(),g=Oi(),_=Hr(),v=ri(),y=eg([{dirty:Zh(t),saving:p,error:d},...n]),b=()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})};return!y.dirty&&!y.saving&&y.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:[y.error!==null&&x(`p`,{className:`text-xs text-danger`,children:y.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()=>{y.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});for(let e of n)e.discard();f(null)},disabled:!y.dirty||y.saving,children:o(`deviceQuickDetail.discard`,`Discard`)}),x(K,{type:`button`,size:`sm`,onClick:()=>{if(t!==null&&Zh(t)&&Qh(t)===`name`){f(o(`deviceQuickDetail.nameRequired`,`Name is required`));return}f(null),m(!0),(async()=>{try{let i=t===null?{}:$h(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.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,persistedDisplay:i.display===void 0?t.persistedDisplay:i.display??void 0})}for(let e of n)e.dirty&&await e.save();b()}catch(e){f(ag(e))}finally{m(!1)}})()},disabled:!y.dirty||y.saving,children:y.saving?o(`deviceQuickDetail.saving`,`Saving…`):o(`deviceQuickDetail.save`,`Save`)})]})]})]})}function sg(e){return e.hubReachable?e.authOk===!1?{kind:`auth-expired`}:{kind:`cluster-degraded`,offlineAgents:e.offlineAgents,offlineAgentIds:e.offlineAgentIds}:{kind:`hub-unreachable`}}function cg(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 lg=4e3,ug=5e3;function dg(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 fg(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 pg(e){let t=e.fetchFn??fetch,n=e.timeoutMs??lg,r=e.origin.replace(/\/+$/,``),i;try{i=await fg(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 fg(t,`${r}/health/details`,n,{Authorization:`Bearer ${o}`});e.ok&&(a=await e.json())}catch{}let s;try{s=dg(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 fg(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 mg={kind:`connected`},hg={kind:`reconnecting`};function gg(e){let t=e.probeIntervalMs??ug,n=new Set,r=mg,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(sg(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(mg);return}if(e===`connecting`){c(),s(hg);return}(r.kind===`connected`||r.kind===`reconnecting`)&&s(hg),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 _g=null;function vg(){return _g===null&&(_g=gg({probe:()=>pg({origin:Oe(),getToken:()=>localStorage.getItem(`camstack_admin_token`)})})),_g}function yg(e){vg().onSdkConnectionState(e)}function bg(e){return e===`connected`}function xg(e){M.setOnline(bg(e))}var Sg=null,Cg=0;function wg(){if(!Sg){let e=Cg;Sg=Rn({serverUrl:Oe(),token:localStorage.getItem(`camstack_admin_token`)??void 0,getLanguage:()=>q.language,refreshCredential:async e=>{e===`rejected`?await Vg().refreshNow():await Vg().ensureFresh()},onConnectionChange:t=>{e===Cg&&(yg(t),xg(t))}})}return Sg}function Tg(){let e=Sg;Sg=null,Cg+=1,e?.close()}var Eg=`camstack_admin_token`,Dg=`camstack_admin_refresh`,Og=`camstack_admin_token_expires`;function kg(e){try{let t=localStorage.getItem(e);return t!==null&&t.length>0?t:null}catch{return null}}function Ag(e,t){try{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}function jg(){let e=kg(Eg);if(e===null)return null;let t=kg(Dg),n=Number(kg(Og));return{token:e,...t===null?{}:{refreshToken:t},...Number.isFinite(n)&&n>0?{expiresAt:n}:{}}}function Mg(e){Ag(Eg,e.token),Ag(Dg,e.refreshToken??null),Ag(Og,e.expiresAt===void 0?null:String(e.expiresAt))}function Ng(){Ag(Eg,null),Ag(Dg,null),Ag(Og,null)}function Pg(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 Fg(e){await fetch(H(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}var Ig=new Set;function Lg(e){return Ig.add(e),()=>Ig.delete(e)}var Rg=new Set;function zg(e){return Rg.add(e),()=>Rg.delete(e)}var Bg=null;function Vg(){return Bg===null&&(Bg=new Ni({refresh:async e=>{let t=jg();if(t?.refreshToken!==void 0&&t.refreshToken!==e&&(t.expiresAt??0)>Date.now()+6e4)return t;let n=await wg().refreshSession(e);return{token:n.token,refreshToken:n.refreshToken,expiresAt:n.expiresAt}},onTokens:e=>{Mg(e),wg().setToken(e.token),Fg(e.token);for(let e of Rg)e()},onExpired:()=>{Ng();for(let e of Ig)e()}})),Bg}function Hg(e){Mg(e),Vg().adopt(e)}async function Ug(e){try{await Vg().ensureFresh()}catch(e){console.warn(`[admin-session] pre-reconnect refresh failed; reconnecting anyway`,e)}e()}async function Wg(){return await Vg().refreshNow()!==null}var Gg=512;function Kg(e){if(!e||e.length>Gg)return null;let t=ct(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 qg=/^[A-Za-z0-9_-]{43,128}$/,Jg=/^[A-Za-z0-9._~-]{1,256}$/;function Yg(e){let{codeChallenge:t,state:n}=e;return!t||!qg.test(t)||(e.codeChallengeMethod??`S256`)!==`S256`||!n||!Jg.test(n)?null:{codeChallenge:t,state:n,purpose:e.purpose===`step-up`?`step-up`:`new-session`}}var Xg=`camstack:login-app-handoff`;function Zg(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 Yg({codeChallenge:n(`codeChallenge`),state:n(`state`),purpose:n(`purpose`)})}catch{return null}}function Qg(e,t=Date.now()){e!==null&&u_(Xg,JSON.stringify(e),Zg,t)}function $g(e=Date.now()){return d_(Xg,Zg,e)}function e_(e,t,n){return`${e}?${`code=${encodeURIComponent(t)}`}${n===void 0?``:`&state=${encodeURIComponent(n)}`}`}function t_(e,t=Date.now()){return m_(t)??Kg(e)}var n_=2048;function r_(e){return!e||e.length>n_||!e.startsWith(`/`)||e.startsWith(`//`)||e.includes(`\\`)||e.includes(`://`)||e.includes(`..`)||e===`/login`||e.startsWith(`/login?`)||e.startsWith(`/login/`)?null:e}function i_(e,t=Date.now()){u_(c_,e,r_,t)}function a_(e=Date.now()){return d_(c_,r_,e)}function o_(e,t=Date.now()){return a_(t)??r_(e)}var s_=`camstack:login-redirect`,c_=`camstack:login-next`,l_=10*6e4;function u_(e,t,n,r){let i=f_();if(!i||!n(t))return;let a={raw:t??``,at:r};try{i.setItem(e,JSON.stringify(a))}catch{}}function d_(e,t,n){let r=f_();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>l_?null:t(a)}catch{return null}}function f_(){if(typeof window>`u`)return null;try{return window.sessionStorage}catch{return null}}function p_(e,t=Date.now()){u_(s_,e,Kg,t)}function m_(e=Date.now()){return d_(s_,Kg,e)}var h_=`changeme`;function g_(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:__(n.scopes)}}catch{return null}}function __(e){return rn(sn(e))}function v_(e){let t=g_(e);return t?t.exp*1e3<Date.now():!0}O();var y_=h_;function b_(e){return{token:e.token,...e.refreshToken===void 0?{}:{refreshToken:e.refreshToken},...e.expiresAt===void 0?{}:{expiresAt:e.expiresAt}}}async function x_(e,t){if(await Fg(e),t.kind===`path`){window.location.replace(H(t.path));return}try{Tg();let e=$g();if(e===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await wg().trpcClient.auth.createHandoffCode.mutate({purpose:e.purpose,codeChallenge:e.codeChallenge,state:e.state});window.location.replace(e_(t.url,n,e.state))}catch{window.location.replace(H(`/`))}}async function S_(e,t){await Fg(e),window.location.replace(H(t))}var C_=j(null);function w_({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=Pg(e),n=t?.token??null;if(t!==null&&n!==null){Hg(t);let r=m_();if(r){x_(n,r);return}let i=a_()??r_(e.get(`next`));if(i){S_(n,i);return}window.history.replaceState({},``,H(`/`))}}s()},[]);let s=async()=>{let e=jg();if(e===null){i(!1);return}let t=e.token;if(e.refreshToken!==void 0){let n=Vg();n.adopt(e),await n.ensureFresh();let r=jg();if(r===null){console.warn(`[auth] session restore: signed out — the hub refused the refresh token`),Tg(),i(!1);return}t=r.token}if(v_(t)){console.warn(`[auth] session restore: signed out — access token expired and no refresh recovered it`),Ng(),Tg(),i(!1);return}let r=g_(t);if(!r){console.warn(`[auth] session restore: signed out — the stored access token is unreadable`),Ng(),Tg(),i(!1);return}Fg(t);let a=wg();a.trpcClient.system.info.query().then(()=>n(r)).catch(async e=>{let t=e?.data?.code;if(t===`UNAUTHORIZED`||t===`FORBIDDEN`){if(await Wg()){a.reconnect();try{await wg().trpcClient.system.info.query();let e=jg();n(e&&g_(e.token)||r);return}catch{}}console.warn(`[auth] session restore: logout, probe UNAUTHORIZED and refresh did not recover it`),Vg().stop(),Ng(),Tg()}else n(r)}).finally(()=>i(!1))};S(()=>Lg(()=>{Tg(),n(null),o(!1)}),[]);let c=b(async(e,t)=>{let r=await wg().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 Hg(b_(r)),await Fg(a),Tg(),n(g_(a)),o(t===y_),{kind:`ok`}},[]),l=b(async(e,t)=>{let r=await wg().loginVerifyTotp(e,t,{refreshable:!0}),i=r.token;Hg(b_(r)),await Fg(i),Tg(),n(g_(i)),o(!1)},[]),u=b(async(e,t)=>{Hg({token:e,...t}),await Fg(e),Tg(),n(g_(e)),o(!1)},[]),d=b(()=>{wg().logout().catch(()=>{}),Vg().stop(),Ng(),fetch(H(`/api/auth/session`),{method:`DELETE`}).catch(()=>{}),Tg(),n(null),o(!1)},[]),f=b(()=>{o(!1)},[]);return x(C_.Provider,{value:{user:t,loading:r,mustChangePassword:a,login:c,verifyTotp:l,finalizePasskeyLogin:u,logout:d,clearMustChangePassword:f},children:e})}function T_(){let e=L(C_);if(!e)throw Error(`useAuth must be used within AuthProvider`);return e}O();function E_(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 D_({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&&(E_(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 O_({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 k_({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 A_({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(O_,{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($p,{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(k_,{tabs:b.map(e=>({id:e.id,label:e.label})),activeId:A,onChange:j,countByTab:I,pendingByTab:L}),x(ti,{tabKey:A,children:M===void 0?x($p,{schema:P,values:t,onChange:r,onAction:i,disabled:c,visibilityContext:f}):M.content}),F]})}var j_=`device-export`,M_=`export`,N_=`Export`;function P_(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(P_):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(P_)):e.writerCapName===j_}function F_(e){return e.tab===`export`?!0:e.fields.some(P_)}var I_=`host/extensions-panel`;function L_(e){return e.type===`widget`?e.widgetId===I_:e.type===`group`?e.fields.some(L_):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(L_)):!1}function R_(e){return e.fields.some(L_)}function z_(e,t){return!t&&e!==void 0&&un.includes(e)}function B_(e){return e.location!==`top-tab`&&e.location!==`hero`&&!F_(e)&&!R_(e)}function V_(e,t,n,r){return!r||z_(t,n)?!0:(e??[]).some(B_)}function H_(e,t){for(let n of e){if(n.type===`group`){H_(n.fields,t);continue}if(n.type===`sub-tabs`){for(let e of n.tabs)H_(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 U_(e){let t={};for(let n of e)H_(n.fields,t);return t}O();function W_(e,t){return t&&t===`admin`?e:!0}function G_(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?F_(e)&&F_(t)?e.id.localeCompare(t.id):(e.order??0)-(t.order??0):n.localeCompare(r)})};return e.tabs?{...t,tabs:e.tabs}:t}function K_(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 q_(e){return e.key}function J_(e){if(!K_(e))return e.value}function Y_(e){return K_(e)?null:e}function X_(e,t){for(let n of e)if(t(n),n.type===`group`)X_(n.fields,t);else if(n.type===`sub-tabs`)for(let e of n.tabs)X_(e.fields,t)}function Z_(e){if(!e)return{};let t={};for(let n of e.sections)X_(n.fields,e=>{let n=q_(e);n!==null&&(t[n]=J_(e))});return t}function Q_(e,t){if(!e)return null;let n=null;for(let r of e.sections)if(X_(r.fields,e=>{if(n!==null||q_(e)!==t)return;let r=Y_(e);r&&r.writerCapName&&r.writerAddonId&&(n={capName:r.writerCapName,addonId:r.writerAddonId})}),n!==null)break;return n}function $_(e){return{...e,fields:e.fields.map(ev)}}function ev(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`object-array`?e:{...e,readonlyField:!0}}function tv(e,t){return e&&{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{let n=Y_(e);return n?W_(t,n.minRole)?e:ev(e):e})}))}}var nv={sections:[]};function rv({deviceId:e,sectionFilter:t,activeSubTab:n,onSubTabChange:r,flattenSubTabs:i,subTabGrouping:a,leadingTabs:o}){let{t:c}=J(),l=N(),{user:u}=T_(),d=u?.isAdmin===!0,f=p(!1),{data:h,isLoading:g}=Zn({deviceId:e},{refetchInterval:()=>f.current?!1:2500,enabled:Number.isFinite(e)}),{data:_}=gr({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($_),r=[...e,...n],i=t?r.filter(t):r.filter(B_);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(()=>U_([...v?.sections??[],...y?.sections??[]]),[v,y]),T=m(()=>G_(C),[C]),E=m(()=>tv(T,d),[T,d]),D=m(()=>Z_(E),[E]),O=Wr(),k=ii(),A=jr(),j=Fr(),M=Li({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),P={isPending:M.isPending,mutate:t=>{M.mutate({deviceId:e,changes:[...t]})}},F=D_({schema:E,serverValues:D,onImmediateSave:b(e=>{let t=Object.entries(e).map(([e,t])=>{let n=Q_(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=Q_(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:ee,handleSave:R,handleDiscard:te}=F;f.current=F.editingPaused;let ne=ng(),re=p(R),ie=p(te);re.current=R,ie.current=te;let ae=ne?.register,oe=M.isError?M.error instanceof Error?M.error.message:String(M.error):null,se=L.join(`\0`);S(()=>{if(ae===void 0)return;let e=se===``?[]:se.split(`\0`);return ae({id:`export`,dirty:e.length>0,saving:M.isPending,error:oe,save:()=>(re.current(e),Promise.resolve()),discard:()=>ie.current(e)})},[ae,se,M.isPending,oe]);let z=o!==void 0&&o.length>0;if(g&&!z)return s(`div`,{className:`flex items-center justify-center py-12 text-foreground-subtle`,children:[x(U,{className:`h-4 w-4 animate-spin mr-2`}),x(`span`,{className:`text-xs`,children:c(`device.deviceAggregateSection.loadingDeviceAggregate`,`Loading device aggregate…`)})]});if(!z&&(!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 B(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=nn(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=nn(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(A_,{schema:E??nv,values:I,pendingKeys:L,onChange:ee,onAction:B,onSave:R,onDiscard:te,hideSaveBar:ne!==null,disabled:P.isPending,activeSubTab:n,onSubTabChange:r,flattenTabs:i,leadingTabs:o,visibilityContext:w})}O();function iv({deviceId:e,onClose:t}){let{t:n}=J(),[r,i]=w(`info`),{data:a}=gr({deviceId:e},{enabled:e>0}),o=In(e),c=Sh(o.presence,o.list),l=r===`history`&&!c?`info`:r,u=typeof a?.name==`string`?a.name:``,d=mi(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(Kn,{open:!0,onOpenChange:e=>!e&&t(),children:x(er,{width:`lg`,scroll:`body`,children:s(rg,{deviceId:e,seed:a==null?null:{name:u,location:f,role:typeof a.role==`string`?a.role:null,display:a.display},showOpenFull:!0,onClose:t,children:[x(Fn,{children:x(_r,{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(Qn,{className:`mt-3`,children:s(Vr,{deviceId:e,device:a??void 0,children:[x(`div`,{className:l===`info`?void 0:`hidden`,children:x(Hh,{})}),x(`div`,{className:l===`export`?void 0:`hidden`,children:x(rv,{deviceId:e,sectionFilter:F_})}),c?x(`div`,{className:l===`history`?void 0:`hidden`,children:x(xh,{deviceId:e})}):null]})})]})})})}function av({children:e}){let[t,n]=w(null),r=b(e=>n(e),[]),i=b(()=>n(null),[]);return s(Cr,{open:r,children:[e,t===null?null:x(iv,{deviceId:t,onClose:i})]})}O();function ov({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 sv(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 cv(e){return`${e.inputSize.width}x${e.inputSize.height}`}function lv(e){return e.formats?Object.keys(e.formats).filter(t=>e.formats[t]!==void 0):[]}function uv({entry:e,selected:t,onSelect:n,disabled:r}){let{t:i}=J(),a=sv(e),o=cv(e),c=lv(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(le,{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(Ze,{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 dv({field:e,value:t,onChange:n,disabled:r}){let{t:i}=J(),a=e.catalog??[],o=a.length>0,c=dt(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(ov,{tabs:u,active:d,onChange:f}),d===`catalog`&&o&&c&&x(zn,{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(uv,{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(he,{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(he,{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(Ie,{className:`h-3 w-3`})]})]})]})}function fv({to:e}){let{search:t}=X();return x(Z,{to:`${e}${t}`,replace:!0})}O();function pv(){return q.t(`helpers.keychainRevealHost.forbidden`)}function mv(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 hv(e){let t=mv(e);if(t===`FORBIDDEN`||t===`UNAUTHORIZED`)return pv();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 gv({children:e}){let t=Ti();return x(Si,{reveal:b(async e=>{try{return(await t.mutateAsync({ref:e})).value}catch(e){throw Error(hv(e))}},[t]),children:e})}O();function _v(){let e=W(),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}=ui(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=yv(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(vv,{toasts:s})})}function vv({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(ie,{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 yv(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 bv=`/system/settings`,xv=[{path:`/system/capabilities`,tab:`capabilities`}];function Sv(e,t=``){let n=new URLSearchParams(t);return n.delete(`tab`),n.set(`tab`,e),`${bv}?${n.toString()}`}var Cv=`/system/data`,wv=`/system/secrets`;function Tv(e=``){let t=new URLSearchParams(e),n=t.get(`view`);return t.delete(`view`),t.set(`tab`,`secrets`),n===`audit`&&t.set(`secretsView`,`audit`),`${Cv}?${t.toString()}`}function Ev({tab:e}){let{search:t,hash:n}=X();return x(Z,{to:`${Sv(e,t)}${n}`,replace:!0})}function Dv(){let{search:e,hash:t}=X();return x(Z,{to:`${Tv(e)}${t}`,replace:!0})}O();var Ov={info:{bg:`bg-info/10`,border:`border-info/30`,icon:he},warning:{bg:`bg-warning/10`,border:`border-warning/30`,icon:Ce},critical:{bg:`bg-danger/10`,border:`border-danger/30`,icon:He}};function kv({toast:e,onDismiss:t}){let n=Ov[e.severity]??Ov.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]),s(`div`,{className:`flex items-start gap-3 px-4 py-3 rounded-lg border ${n.border} ${n.bg} shadow-lg animate-in slide-in-from-right-5 fade-in duration-200`,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(Me,{className:`h-3.5 w-3.5 text-foreground-subtle`})})]})}function Av(){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 $n(void 0,{onData:e=>r(e)}),S(()=>am(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(kv,{toast:e,onDismiss:n})},e.id))})}function jv(e){return(t,n,r)=>e(t,{...typeof n==`string`?{defaultValue:n}:{defaultValue_one:n.one,defaultValue_other:n.other},...r})}var Mv=(e,t,n)=>jv(q.t.bind(q))(e,t,n);O();function Nv({children:e}){let{t}=J();return x(Ae,{t:m(()=>jv(t),[t]),children:e})}O();function Pv(e){if(typeof e!=`object`||!e)return;let{data:t}=e;return t?.code}function Fv(e,t){let n=Pv(e);return n===`UNAUTHORIZED`||n===`FORBIDDEN`?!0:/UNAUTHORIZED|FORBIDDEN/.test(t)}function Iv(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(Fv(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 Lv=3e4;function Rv(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>=Lv&&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 zv=`@camstack/ui-library`;function Bv(e){return typeof e==`object`&&!!e}var Vv=/^>=\s*(\d+)\.(\d+)\.(\d+)/,Hv=/^(\d+)\.(\d+)\.(\d+)/;function Uv(e){return e===null?null:[Number(e[1]),Number(e[2]),Number(e[3])]}function Wv(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 Gv(e,t){let n=[];for(let r of Object.values(e)){let e=r[zv];if(!(typeof e!=`object`||!e))for(let r of Object.values(e)){if(!Bv(r)||r.from!==t)continue;let e=r.shareConfig?.requiredVersion;typeof e==`string`&&n.push(e)}}return n}function Kv(e,t){let n=e===null?null:Uv(e.match(Hv));if(n===null||e===null)return null;for(let r of t){let t=Uv(r.match(Vv));if(t!==null&&Wv(n,t))return{required:t.join(`.`),host:e}}return null}O();function qv(){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(cr,{className:`h-7 w-48`}),x(cr,{className:`h-5 w-72 max-w-full`}),x(cr,{className:`h-40`})]})}function Jv({message:e}){let{t}=J();return x(`div`,{className:`p-2 sm:p-4`,"data-testid":`addon-page-error`,children:x(yr,{title:t(`layouts.addonPageLoader.failedTitle`,`This page could not be shown`),message:e})})}var Yv=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(Jv,{message:this.state.error.message})}};function Xv({resetKey:e,children:t}){return x(Yv,{resetKey:e,children:t})}function Zv({pageKey:e,children:t}){return x(Yv,{resetKey:e,children:x(y,{fallback:x(qv,{}),children:t})})}O();function Qv(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 $v=2e4;function ey(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 ty=new Map,ny=new Map,ry=new Set;function iy(e){return!e||typeof e!=`object`?!1:typeof e.default==`function`}var ay=class extends Error{problem;constructor(e){super(`ui-library ${e.host} is older than the ${e.required} this page requires`),this.problem=e}};function oy(e){let t=i()?.shareScopeMap;if(!t)return;let n=Kv(Ur,Gv(t,e));if(n!==null)throw new ay(n)}async function sy(e,t){let i=ty.get(e);if(i)return i;let a=ny.get(e);if(a)return a;ry.has(e)||(Kr(),r([{name:e,entry:H(t),type:`module`}],{force:!1}),ry.add(e));let o=n(`${e}/page`).then(n=>{if(oy(e),!iy(n))throw Error(`Addon page remote ${e} (${t}) does not expose a default React component on './page'`);return ty.set(e,n.default),ny.delete(e),n.default}).catch(t=>{throw ny.delete(e),oy(e),t});return ny.set(e,o),o}function cy(){let{t:e}=J(),{pagePath:t}=vs(),n=ms(),r=W(),{data:i,isError:a,error:o}=Jn(void 0),s=m(()=>i?Qv(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=ty.get(l);if(t){f(()=>t);return}f(null);let n=!1;return sy(l,u).then(e=>{n||f(()=>e)}).catch(t=>{n||h(t instanceof ay?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=ey(!s&&!a,$v),_=ey(c!==void 0&&!d&&!p,$v);return s?c?p?x(Jv,{message:p}):d?x(Zv,{pageKey:c.remoteName,children:x(d,{trpc:r.trpcClient,theme:{isDark:document.documentElement.classList.contains(`dark`)},navigate:e=>{n(e.startsWith(`/`)?e:`/${e}`)}})}):_?x(Jv,{message:e(`layouts.addonPageLoader.remoteStalled`,`The page did not load. Its addon may be starting or unreachable.`)}):x(qv,{}):x(`div`,{className:`flex items-center justify-center h-full text-foreground-subtle`,children:e(`layouts.addonPageLoader.addonPageNotFound`,`Addon page not found`)}):a?x(Jv,{message:o?.message??e(`layouts.addonPageLoader.listFailed`,`The page list could not be loaded.`)}):g?x(Jv,{message:e(`layouts.addonPageLoader.listStalled`,`The hub did not send the page list. Try again in a moment.`)}):x(qv,{})}var ly={"/system/pipeline":`pipeline-orchestrator`,"/system/history":`device-history`,"/system/ai":`llm`};function uy(e,t){return e.filter(e=>!e.adminOnly||t).map(e=>{let t=ly[e.path];return t===void 0?e:{...e,requiresCapability:t}})}function dy({t:e,isAdmin:t}){let n=uy([{label:e(`nav.devices`,`Devices`),icon:we,path:`/devices`},{label:e(`nav.integrations`),icon:V,path:`/integrations`},{label:e(`nav.build`,`Build-your-self`),icon:ye,path:`/build`,adminOnly:!0},{label:e(`nav.locations`,`Locations`),icon:Be,path:`/locations`,adminOnly:!0},{label:e(`nav.viewer`,`Viewer`),icon:En,path:`/live`}],t),r=uy([{label:e(`nav.library`,`Library`),icon:jn,path:`/library`,adminOnly:!0,keywords:[`People`,`Vehicles`,`Events`,`Scenes`,`plates`,`faces`,`detection-intelligence`]},{label:e(`nav.recordings`,`Recordings`),icon:De,path:`/recordings`,adminOnly:!0}],t),i=uy([{label:e(`nav.nodes`,`Nodes`),icon:ee,path:`/system/nodes`,adminOnly:!0},{label:e(`nav.history`,`History`),icon:fe,path:`/system/history`,adminOnly:!0,keywords:[`charts`,`graphs`,`energy`,`temperature`,`metrics`,`trends`]},{label:e(`nav.pipeline`,`Pipeline`),icon:wn,path:`/system/pipeline`},{label:e(`system.addons`),icon:st,path:`/system/addons`,adminOnly:!0},{label:e(`system.ai`,`AI`),icon:Ye,path:`/system/ai`,adminOnly:!0}],t),a=uy([{label:e(`system.identity`,`Identity & Access`),icon:je,path:`/system/identity`,adminOnly:!0},{label:e(`system.network`,`Network`),icon:Dn,path:`/system/network`,adminOnly:!0},{label:e(`system.integrations`,`Connectivity`),icon:V,path:`/system/integrations`,adminOnly:!0},{label:e(`system.data`,`Data`),icon:Ne,path:`/system/data`,adminOnly:!0},{label:e(`system.notifications`,`Notifications`),icon:ke,path:`/system/notifications`,adminOnly:!0},{label:e(`system.calendars`,`Calendars`),icon:Nn,path:`/system/calendars`,adminOnly:!0},{label:e(`system.templates`,`Templates`),icon:vn,path:`/system/templates`,adminOnly:!0},{label:e(`system.systemNav`,`System`),icon:it,path:bv,adminOnly:!0},{label:e(`system.logs`,`Logs`),icon:tt,path:`/system/logs`,adminOnly:!0},{label:e(`system.terminal`,`Terminal`),icon:Tn,path:`/system/terminal`,adminOnly:!0},{label:e(`system.cameraGrids`,`Camera grids`),icon:oe,path:`/system/camera-grids`,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 fy={gauge:ce,puzzle:st,bot:ue,cpu:Ze,terminal:Tn,box:B,boxes:B,monitor:En,wrench:at,activity:ze,plug:V,"graduation-cap":Te};function py(e){return fy[e]??st}function my(e,t){for(let n of dy(t))for(let t of n.items)if(t.path===e)return{icon:t.icon,title:t.label,path:t.path};return null}var hy=`/system/addons`;function gy({path:e,children:t}){let n=ly[e];return n===void 0?x(I,{children:t}):x(_y,{path:e,capability:n,children:t})}function _y({path:e,capability:t,children:n}){let{t:r}=J(),i=ms(),a=xr(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(cr,{className:`h-7 w-48`}),x(cr,{className:`h-40`})]});if(a===`unknown`)return x(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-presence-unknown`,children:x(yr,{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=my(e,{t:r,isAdmin:!0});return x(`div`,{className:`p-2 sm:p-4`,"data-testid":`page-not-installed`,children:x(vr,{icon:o?.icon??st,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(hy),children:r(`pageRequires.openAddons`,`Open Addons`)})})})}function vy({capability:e,children:t}){return x(I,{children:t(xr(e)===`absent`)})}function yy({children:e}){return x(Wn,{value:by(Pi({})),children:e})}function by(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 xy(){let e=ir(),{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 Sy=/\p{Mn}/gu;function Cy(e){return e.normalize(`NFD`).replace(Sy,``).toLowerCase().trim()}var wy=[`device`,`page`,`integration`],Ty=0,Ey=1,Dy=2,Oy=3,ky=4,Ay=5,jy=6,My=7;function Ny(e,t,n,r){return n.includes(r)?Ty:e===r?Ey:e.startsWith(r)?Dy:e.split(/\s+/).some(e=>e.startsWith(r))?Oy:e.includes(r)?ky:t.some(e=>e.includes(r))?Ay:null}function Py(e,t){let n=0;for(let r=0;r<e.length&&n<t.length;r++)e[r]===t[n]&&n++;return n===t.length}function Fy(e){return e<4?0:e<=7?1:e<=12?2:3}function Iy(e,t,n){if(e===t)return 0;if(n<=0||Math.abs(e.length-t.length)>n)return null;let r=t.length,i=Array(r+1).fill(0),a=Array.from({length:r+1},(e,t)=>t),o=Array(r+1).fill(0);for(let s=1;s<=e.length;s++){o[0]=s;let c=s,l=e[s-1];for(let n=1;n<=r;n++){let r=t[n-1],u=l===r?0:1,d=Math.min((a[n]??1/0)+1,o[n-1]+1,(a[n-1]??1/0)+u);s>1&&n>1&&l===t[n-2]&&e[s-2]===r&&(d=Math.min(d,(i[n-2]??1/0)+1)),o[n]=d,d<c&&(c=d)}if(c>n)return null;let u=i;i=a,a=o,o=u}let s=a[r]??1/0;return s<=n?s:null}function Ly(e,t){if(Py(e,t))return jy;let n=Fy(t.length);if(n>0){for(let r of e.split(/\s+/))if(Iy(r,t,n)!==null)return My}return null}function Ry(e,t,n=200){let r=Cy(t);if(r.length===0)return{groups:[],totalMatched:0,truncated:!1};let i=new Map;for(let t of e){let e=Cy(t.label),n=Ny(e,(t.keywords??[]).map(Cy),(t.identifiers??[]).map(Cy),r)??Ly(e,r);if(n===null)continue;let a=i.get(t.domain)??[];a.push({item:t,rank:n}),i.set(t.domain,a)}let a=0;for(let e of i.values())a+=e.length;let o=n,s=[];for(let e of wy){let t=i.get(e);if(!t||t.length===0||o<=0)continue;t.sort((e,t)=>e.rank-t.rank||e.item.label.localeCompare(t.item.label));let n=t.slice(0,o).map(e=>e.item);o-=n.length,s.push({domain:e,items:n})}return{groups:s,totalMatched:a,truncated:a>n}}function zy(e){return e.flatMap(e=>e.items)}var By=`instance`;function Vy(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 Hy(e,t){let n=`/integrations/${encodeURIComponent(e)}`;return t===void 0||t.length===0?n:`${n}?${By}=${encodeURIComponent(t)}`}var Uy=` · `;function Wy(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(Uy)}function Gy(e,t=null){let n=bi(e),r=Nr(q.language.startsWith(`it`)?`it`:`en`),i=Ei(e),a=Xn(t);return e.map(e=>{let t=String(e.id),o=Yr(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(Uy).includes(c)),u=a(e),d=u.kind===`resolved`?u.integration.name:``;return{key:`device:${t}`,domain:`device`,label:s,subtitle:Wy(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:rr(e.type).icon}})}function Ky(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:Hy(e.addonId,e.id)}))}function qy(e,t,n){let r=e.section?.trim();return r?t[r]??e.sectionLabel?.trim()??r:n}function Jy(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:qy(e,i,n.ungrouped),keywords:[e.addonId],path:e.path,icon:py(e.icon)}));return[...r,...a]}O();var Yy={device:{labelKey:`search.resultsList.devices`,icon:we},page:{labelKey:`search.resultsList.pages`,icon:bn},integration:{labelKey:`search.resultsList.integrations`,icon:V}};function Xy({groups:e,activeKey:t,query:n,totalMatched:r,truncated:i,onSelect:a,onHover:o}){let{t:c}=J(),l=p(null);if(S(()=>{t&&(l.current?.querySelector(`[data-key="${CSS.escape(t)}"]`))?.scrollIntoView({block:`nearest`})},[t]),n.trim().length===0)return null;if(e.length===0)return x(`div`,{className:`px-3 py-4 text-center text-[12px] text-foreground-subtle`,children:c(`search.resultsList.noResults`,{query:n})});let u=e.reduce((e,t)=>e+t.items.length,0);return s(I,{children:[x(`div`,{ref:l,role:`listbox`,className:`max-h-[60vh] overflow-y-auto py-1`,children:e.map(e=>{let n=Yy[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`}),c(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:()=>o(e),onClick:()=>a(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:c(`search.truncatedResults`,`Showing first {{shown}} of {{total}} — refine your search.`,{shown:u,total:r})})]})}O(),Hi();function Zy({navSections:e,addonPages:t,compact:n,onNavigated:r}){let{t:i}=J(),a=ms(),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}=Yn({projection:`slim`}),{data:T}=Sr(void 0),E=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[...Gy(C??[],T??null),...Jy(e,t,n),...Ky(T??[])]},[C,T,e,t,i]),{groups:D,totalMatched:O,truncated:k}=m(()=>Ry(E,f),[E,f]),A=m(()=>zy(D),[D]);S(()=>{_(0)},[f,E]),S(()=>{v&&o.current?.focus()},[v]);let j=b(()=>{y(!1),h(``),_(0)},[]),M=b(e=>{a(e.path),j(),o.current?.blur(),r?.()},[a,j,r]);Gr(o,{scope:Br}),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 N=v&&f.trim().length>0;S(()=>{if(!N){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)}},[N]);let P=A[g]?.key??null,F=i(`search.placeholder`,`Search devices, pages, integrations…`),I=s(`div`,{className:`relative`,children:[x(ne,{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:F,"aria-label":F,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(),A.length>0&&_(e=>(e+1)%A.length);else if(e.key===`ArrowUp`)e.preventDefault(),A.length>0&&_(e=>(e-1+A.length)%A.length);else if(e.key===`Enter`){e.preventDefault();let t=A[g];t&&M(t)}else e.key===`Escape`&&(e.preventDefault(),j(),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(Me,{className:`h-3 w-3`})}),N&&u!==null&&Ui(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(Xy,{groups:D,activeKey:P,query:f,totalMatched:O,truncated:k,onSelect:M,onHover:e=>{let t=A.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:I}):x(K,{variant:`unstyled`,type:`button`,onClick:()=>y(!0),"aria-label":F,title:F,className:`flex w-full items-center justify-center rounded-md px-0 py-2 text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,children:x(ne,{className:`h-3.5 w-3.5 shrink-0`})})}):x(`div`,{ref:c,className:`px-2 pb-2`,children:I})}var Qy=/^(\d{1,3}\.){3}\d{1,3}$/;function $y(e){let t=e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e;return!!(Qy.test(t)||t.includes(`:`))}function eb(e,t){return!t||$y(e)?!1:e===t||e.endsWith(`.${t}`)}O();var tb=`auth-webauthn/passkey-enrollment`,nb=`camstack_passkey_prompt_dismissed:`,rb=720*60*60*1e3;function ib(e){try{let t=localStorage.getItem(`${nb}${e}`);if(!t)return!1;let n=Number(t);return Number.isFinite(n)?Date.now()-n<rb:!1}catch{return!1}}function ab(e){try{localStorage.setItem(`${nb}${e}`,String(Date.now()))}catch{}}function ob(){let{user:e}=T_(),{t}=J(),n=W(),r=oi(tb),[i,a]=w(!1),[o,c]=w(!1),l=m(()=>e?ib(e.id):!0,[e]),u=Gn.auth.listLoginMethods.useQuery().data?.find(e=>e.kind===`passkey`),d=u!==void 0&&eb(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&&ab(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(Me,{className:`h-3.5 w-3.5`})})]}),o&&x(`div`,{className:`px-3 pb-3`,children:s(`div`,{className:`max-w-xl`,children:[x(sr,{widgetId:tb,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 sb=`system-config`,cb=[`system-config`,`bootstrap-form`];function lb(e){return typeof e==`object`&&!!e&&`sections`in e&&Array.isArray(e.sections)}function ub(){let e=W();return E({queryKey:cb,queryFn:async()=>{let t=await e.trpcClient.addons.custom.mutate({addonId:sb,action:`getBootstrapForm`,input:{}});if(!lb(t))throw Error(`The hub did not return the settings form`);return t}})}function db(){let e=W(),t=N(),n=P({mutationFn:async t=>{await e.trpcClient.addons.custom.mutate({addonId:sb,action:`saveBootstrapForm`,input:t})},onSuccess:()=>Promise.all([t.invalidateQueries({queryKey:cb}),t.invalidateQueries({queryKey:[[`system`,`info`]]})])});return{mutateAsync:n.mutateAsync,isPending:n.isPending}}var fb=6e4;function pb(){let e=Fi(void 0,{staleTime:fb});return{info:e.data?.serverName??null,isLoading:e.isLoading}}O();var mb=`camstack_server_name_prompt_dismissed`;function hb(){try{return sessionStorage.getItem(mb)===`1`}catch{return!1}}function gb(){try{sessionStorage.setItem(mb,`1`)}catch{}}function _b(e){return e.isAdmin&&e.info!==null&&e.info.isDefault&&!e.dismissed}function vb(){let{user:e}=T_(),{info:t}=pb(),[n,r]=w(hb);return _b({isAdmin:e?.isAdmin===!0,info:t,dismissed:n})?x(yb,{suggestion:t?.name??``,onLater:()=>{gb(),r(!0)}}):null}function yb({suggestion:e,onLater:t}){let{t:n}=J(),r=N(),i=db(),[a,o]=w(e),[c,l]=w(null),u=p(null);S(()=>u.current?.focus(),[]);let d=b(async()=>{let e=At.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(Kn,{open:!0,onOpenChange:e=>!e&&t(),children:x(er,{children:s(`form`,{onSubmit:e=>{e.preventDefault(),i.isPending||d()},children:[s(Fn,{children:[x(_r,{children:n(`serverName.title`,`Name this server`)}),x(ur,{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(Qn,{children:x(qn,{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(Vi,{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(U,{className:`h-4 w-4 animate-spin`}),n(`common.save`,`Save`)]})]})]})})})}var bb=4,xb=160,Sb=320,Cb=`env(safe-area-inset-top)`,wb=`env(safe-area-inset-bottom)`;function Tb(e){let{rect:t,viewportWidth:n,viewportHeight:r}=e,i=Math.min(Sb,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+bb}px, calc(${Cb} + 8px))`;return{...a,top:e,maxHeight:`max(${xb}px, calc(100dvh - ${e} - ${wb} - 8px))`}}let o=`max(${r-t.top+bb}px, calc(${wb} + 8px))`;return{...a,bottom:o,maxHeight:`max(${xb}px, calc(100dvh - ${o} - ${Cb} - 8px))`}}var Eb=!1;function Db(){return Eb}function Ob(){Eb=!0}function kb(e){return!e.read&&e.severity===`critical`}function Ab(e){return e.filter(kb)}function jb(e){return e!==void 0&&typeof e.href==`string`&&e.href.length>0}function Mb(e){return jb(e)||e!==void 0&&e.invoke!==void 0}var Nb=/^\/addon\/[^/?#]+\/oauth\//;function Pb(e){return e.navigation===void 0?Nb.test(e.href):e.navigation===`server`}function Fb(e){let t=e.action;if(Mb(t)&&!(t.invoke!==void 0&&(e.status===`completed`||e.status===`dismissed`)))return t}O();function Ib({action:e,className:t,onActivate:n}){let r=N(),i=W(),{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 jb(e)?Pb(e)?x(`a`,{href:H(e.href),className:t,onClick:t=>{t.preventDefault(),n?.(t),Ol(e.href,()=>{r.invalidateQueries({queryKey:[[`alerts`]]}),r.invalidateQueries({queryKey:[[`broker`]]}),r.invalidateQueries({queryKey:[[`recordEntries`]]})})},children:e.label}):x(Pc,{to:e.href,className:t,onClick:n,children:e.label}):x(I,{})}O(),Hi();var Lb={info:he,success:ie,warning:Ce,error:He,critical:gn},Rb={info:`text-info`,success:`text-success`,warning:`text-warning`,error:`text-danger`,critical:`text-danger`},zb={active:`border-l-info`,"in-progress":`border-l-warning`,completed:`border-l-success`,failed:`border-l-danger`,dismissed:`border-l-foreground-subtle/30`};function Bb(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 Vb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Hb(e){return typeof e==`string`&&e.length>0?e:void 0}function Ub(e){if(Vb(e.metadata)){let t=Hb(e.metadata.nodeId)??Hb(e.metadata.agentId);if(t!==void 0)return t}let t=e.source;if(t!==void 0&&!(t.type!==`node`&&t.type!==`agent`))return Hb(t.id)}function Wb({alert:e,onMarkRead:t,onDismiss:n}){let{t:r}=J(),i=e.severity in Lb?e.severity:`info`,a=Fb(e),o=e.status in zb?e.status:`active`,c=Lb[i],l=Rb[i],u=zb[o],{nodes:d}=Pn(),f=Ub(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(Ib,{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:Bb(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(le,{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(Me,{className:`h-3 w-3 text-foreground-subtle`})})]})]})}function Gb({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}=Ln(void 0,{refetchInterval:3e4}),{data:f=[],isLoading:m}=Ai({limit:50},{enabled:r}),h=a?f:f.filter(e=>!e.read),g=f.filter(e=>e.read).length,_=()=>{u.invalidateQueries({queryKey:[[`alerts`]]})},v=Un({onSuccess:_}),y=hr({onSuccess:_}),C=dr({onSuccess:_});or(`alert.created`,()=>{u.invalidateQueries({queryKey:[[`alerts`]]})}),or(`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(kb),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(Tb({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(tt,{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(tt,{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&&Ui(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(Di,{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(hn,{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(U,{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(tt,{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(Wb,{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(Wb,{alert:e,onMarkRead:T,onDismiss:E},e.id))]}),j.map(e=>x(Wb,{alert:e,onMarkRead:T,onDismiss:E},e.id))]})]}),document.body)]})}O(),Hi();function Kb({alert:e,onMarkRead:t}){let{t:n}=J(),r=Fb(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(Ib,{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 qb(){let{t:e}=J(),t=N(),[n,r]=w(Db()),{data:i=[],isLoading:a}=Ai({limit:50}),o=m(()=>Ab(i),[i]),c=Un({onSuccess:b(()=>{t.invalidateQueries({queryKey:[[`alerts`]]})},[t])}),l=b(e=>{c.mutate({alertId:e})},[c]),u=b(()=>{Ob(),r(!0)},[]);return a||n||o.length===0?null:Ui(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(Mr,{type:`button`,variant:`ghost`,onClick:u,"aria-label":e(`ui.criticalAlertsPanel.close`,`Close`),"data-testid":`critical-alerts-panel-close`,icon:Me})]}),x(`div`,{className:`flex-1 overflow-y-auto`,children:o.map(e=>x(Kb,{alert:e,onMarkRead:l},e.id))})]})}),document.body)}O();function Jb(){let e=vg();return C(e.subscribe,e.getSnapshot,e.getSnapshot)}var Yb=[`detection`,`cluster`,`administration`];function Xb(e){return Yb.includes(e)}function Zb(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(Xb(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 Qb=`camstack:last-path`,$b=512,ex=[`/login`,`/change-password`,`/access-denied`,`/logout`];function tx(e){return!e.startsWith(`/`)||e.startsWith(`//`)||e.length>$b?!1:!ex.some(t=>e===t||e.startsWith(t+`/`))}function nx(e){if(!(typeof window>`u`)&&tx(e))try{window.localStorage.setItem(Qb,e)}catch{}}function rx(){if(typeof window>`u`)return null;try{let e=window.localStorage.getItem(Qb);return e===null?null:tx(e)?e:null}catch{return null}}var ix=`/devices`;function ax(e){return e!==void 0&&tx(e)?e:rx()??ix}function ox(e){return e.split(`.`)[0]===`0`?`${e} beta`:e}function sx(e){if(e===null)return null;let t=e.trim();return t.length>0?t:null}function cx(e){let t=sx(e.productVersion),n=sx(e.serverVersion),r=sx(e.fallbackVersion);return t!==null&&n!==null?{kind:`both`,productLabel:ox(t),serverVersion:n}:t===null?n===null?r===null?{kind:`none`}:{kind:`fallback`,version:r}:{kind:`server`,serverVersion:n}:{kind:`product`,productLabel:ox(t)}}function lx(e,t){if(!Object.hasOwn(e,t))return null;let n=Reflect.get(e,t);return typeof n==`string`?n:null}function ux(e){return typeof e!=`object`||!e?null:{productVersion:lx(e,`productVersion`),serverVersion:lx(e,`serverVersion`)}}O();function dx(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 fx({placement:e,compact:t=!1}){let{t:n}=J(),[r,i]=w({kind:`fallback`,version:`1.2.623`});S(()=>{let e=new AbortController;return fetch(H(`/api/release-identity`),{signal:e.signal}).then(async e=>e.ok?ux(await e.json()):null).then(t=>{e.signal.aborted||t===null||i(cx({productVersion:t.productVersion,serverVersion:t.serverVersion,fallbackVersion:`1.2.623`}))}).catch(t=>{e.signal.aborted||t instanceof DOMException&&t.name}),()=>e.abort()},[]);let a=dx(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 px=j(!0);function mx(e){return e===`/addon`||e.startsWith(`/addon/`)}function hx(e,t,n){let r=[...e.filter(e=>e!==t),t];return r.length<=n?r:r.slice(r.length-n)}function gx({maxCached:e=6}){let t=_s(),n=X(),r=ds(),i=L(ns),a=n.pathname,o=mx(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=hx(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(px.Provider,{value:n,children:x(ts.Provider,{value:{location:t.location,navigationType:t.navigationType},children:x(ns.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 _x={dark:Ge,light:We,system:En};function vx(){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 yx(){let e=X(),t=ms(),{user:n,logout:r}=T_(),i=Ar(),{t:a}=J(),o=ai(),c=Aa(),l=gi(),{info:u}=pb();S(()=>{document.title=u===null?`CamStack Admin`:`${u.name} \u00b7 CamStack Admin`},[u]);let d=cg(Jb()),[f,h]=w(!1);S(()=>{nx(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=[]}=wi({nodeId:`hub`},{refetchInterval:3e4}),C=b.length,T=N(),E=p(Date.now()),{data:D}=Jn(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?Qv(D):[],[D,n?.isAdmin]),k=m(()=>Zb(O),[O]),A=k.known.get(`detection`)??[],j=k.known.get(`cluster`)??[],M=k.known.get(`administration`)??[];or(`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+`/`)),ee=n?.isAdmin===!0,R=m(()=>dy({t:a,isAdmin:ee}),[a,ee]),te=R[0]?.items??[],ne=R[1]?.items??[],re=R[2]?.items??[],ie=R[3]?.items??[],ae=i?.mode??`system`,oe={dark:a(`theme.dark`),light:a(`theme.light`),system:a(`theme.system`)},z=g&&!o,B=(e,t=`md`,n=!1)=>`flex w-full items-center gap-2.5 rounded-md ${z?`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`}`,V=(e,t)=>e===0?null:z?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}`),ce=e=>{let n=F(e.path),r=py(e.icon);return s(K,{variant:`unstyled`,onClick:()=>{t(e.path),h(!1)},className:B(n),title:z?e.label:void 0,children:[x(r,{className:`h-3.5 w-3.5 shrink-0 ${n?`text-primary`:``}`}),!z&&e.label]},`${e.addonId}::${e.id}`)},le=e=>e.requiresCapability===void 0?ue(e,!1):x(vy,{capability:e.requiresCapability,children:t=>ue(e,t)},e.path),ue=(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:B(i,`md`,n),"aria-disabled":n||void 0,title:n?a(`nav.notInstalled`,`{{page}} — not installed`,{page:e.label}):z?e.label:void 0,children:[x(r,{className:`h-3.5 w-3.5 shrink-0 ${i?`text-primary`:``}`}),!z&&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})]}),z&&o&&C>0&&x(`span`,{className:`absolute mt-[-14px] ml-3 h-2 w-2 rounded-full bg-primary`})]},e.path)},de=s(I,{children:[s(`div`,{className:`flex h-14 items-center border-b border-border ${z?`justify-center px-1`:`pl-3 pr-4 gap-2`}`,children:[!z&&x(`img`,{src:i?.resolvedMode===`light`?H(`/brand/logo-horizontal-light.svg`):H(`/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 ${z?``:`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?me:ge,{className:`h-4 w-4`})})]}),!z&&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(Zy,{navSections:R,addonPages:O,compact:z,onNavigated:()=>h(!1)})}),s(`nav`,{className:`flex-1 overflow-y-auto py-3 ${z?`px-1.5`:`px-2`} space-y-0.5`,children:[te.map(e=>le(e)),V(ne.length+A.length,a(`nav.detectionSection`,`Detection`)),ne.map(e=>le(e)),A.map(e=>ce(e)),V(re.length+j.length,a(`nav.clusterSection`,`Cluster`)),re.map(e=>le(e)),j.map(e=>ce(e)),V(ie.length+M.length,a(`system.title`,`Administration`)),ie.map(e=>le(e)),M.map(e=>ce(e)),k.custom.map(e=>s(`div`,{className:`contents`,children:[V(e.pages.length,e.label),e.pages.map(e=>ce(e))]},`custom-${e.id}`)),V(k.ungrouped.length,a(`nav.addonPages`,`Addon Pages`)),k.ungrouped.map(e=>ce(e))]}),s(`div`,{className:`border-t border-border ${z?`p-1.5`:`p-2`} space-y-0.5`,children:[s(K,{variant:`unstyled`,onClick:()=>i?.toggleMode(),className:B(!1),title:z?oe[ae]:void 0,children:[(()=>{let e=_x[ae];return x(e,{className:`h-3.5 w-3.5 shrink-0`})})(),!z&&x(`span`,{children:oe[ae]})]}),x(Gb,{variant:`sidebar`,compact:z}),s(K,{variant:`unstyled`,type:`button`,onClick:()=>t(`/system/my-access`),className:B(F(`/system/my-access`)),title:z?a(`system.myAccess`,`My access`):void 0,children:[x(et,{className:`h-3.5 w-3.5 shrink-0`}),!z&&x(`span`,{className:`truncate`,children:a(`system.myAccess`,`My access`)})]}),s(K,{variant:`unstyled`,type:`button`,onClick:()=>c.setOn(!c.on),className:B(c.on),"aria-pressed":c.on,title:z?a(`layouts.appLayout.debugLayers`,`Debug layers`):void 0,children:[x(Ee,{className:`h-3.5 w-3.5 shrink-0`}),!z&&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:B(!1).replace(`hover:text-foreground`,`hover:text-danger`),title:z?n?.username??a(`layouts.appLayout.logout`,`Logout`):void 0,children:[x(_n,{className:`h-3.5 w-3.5 shrink-0`}),!z&&x(`span`,{className:`truncate`,children:n?.username??a(`layouts.appLayout.user`,`User`)})]}),x(fx,{placement:`sidebar`,compact:z})]})]});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 ${z?`w-12`:`w-48`}`,children:de}),o&&x(Lr,{open:f,onClose:()=>h(!1),width:`w-64`,children:de}),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(se,{className:`h-3.5 w-3.5`}):x(ze,{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(U,{className:`h-3.5 w-3.5 animate-spin`})]}),x(ob,{}),x(vb,{}),x(qb,{}),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(Le,{className:`h-5 w-5`})}),x(`div`,{className:`flex-1 flex justify-center`,children:x(`img`,{src:i?.resolvedMode===`light`?H(`/brand/logo-horizontal-light.svg`):H(`/brand/logo-horizontal-dark.svg`),alt:a(`layouts.appLayout.camstack`,`CamStack`),className:`h-7`})}),x(Gb,{})]}),s(yy,{children:[x(xy,{}),x(`main`,{className:`relative flex-1 min-h-0 overscroll-contain bg-background ${L?`overflow-hidden`:`overflow-auto`}`,children:x(Xv,{resetKey:e.pathname,children:x(y,{fallback:x(vx,{}),children:x(gx,{})})})})]})]})]})]})}function $({children:e,requireAdmin:t}){let{t:n}=J(),{user:r,loading:i,mustChangePassword:a}=T_(),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 bx=`customize`,xx=`/build/compositions/new`,Sx=`/build/compositions/:blockId`,Cx=`/build?tab=custom-device`;function wx(e){return`/devices/${e}`}function Tx(e){return`/devices/${e}?tab=${bx}`}var Ex=`integration`,Dx=`section`,Ox=[Ex,Dx,`instance`,`instance-new`],kx={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`}},Ax=`settings`,jx=`activity`;function Mx(e,t={}){let{path:n,tab:r}=kx[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(Ex,t.integration),t.section!==void 0&&i.set(Dx,t.section);let a=i.toString();return a.length>0?`${n}?${a}`:n}function Nx(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 Px(e,t,n=null,r=null){let i=new URLSearchParams(e);return i.set(Ex,t),r===null?i.delete(Dx):i.set(Dx,r),n!==null&&i.delete(n),i}function Fx(e){return e===`/admin`||e===`/admin/`?`/`:e.startsWith(`/admin/`)?e.slice(6):e}var Ix=`--color-surface`;function Lx(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 Rx(e=document){let t=e.defaultView?.getComputedStyle(e.documentElement).getPropertyValue(Ix).trim();if(!t)return;let n=Lx(e);n.content!==t&&(n.content=t)}function zx(e=document){Rx(e);let t=e.defaultView;if(!t)return()=>void 0;let n=new t.MutationObserver(()=>Rx(e));return n.observe(e.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>n.disconnect()}function Bx(){let{t:e}=J(),t=ms();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(Sn,{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 Vx(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 Hx(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 Ux(){return window?.PublicKeyCredential!==void 0&&typeof window.PublicKeyCredential==`function`}function Wx(e){let{id:t}=e;return{...e,id:Hx(t),transports:e.transports}}function Gx(e){return e===`localhost`||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var Kx=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),this.name=r??n.name,this.code=t}},qx=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}}},Jx=[`cross-platform`,`platform`];function Yx(e){if(e&&!(Jx.indexOf(e)<0))return e}function Xx(){if(!Ux())return new Promise(e=>e(!1));let e=window.PublicKeyCredential;return e.isConditionalMediationAvailable===void 0?new Promise(e=>e(!1)):e.isConditionalMediationAvailable()}function Zx({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 Kx({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new Kx({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=window.location.hostname;if(!Gx(t))return new Kx({message:`${window.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new Kx({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 Kx({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 Qx(e){let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!Ux())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(Wx));let a={...t,challenge:Hx(t.challenge),allowCredentials:i},o={};if(n){if(!await Xx())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=qx.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Zx({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=Vx(u.userHandle)),{id:c,rawId:Vx(l),response:{authenticatorData:Vx(u.authenticatorData),clientDataJSON:Vx(u.clientDataJSON),signature:Vx(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:Yx(s.authenticatorAttachment)}}function $x(e){return typeof e==`object`&&!!e}function eS(e){return $x(e)&&typeof e.challenge==`string`}O();function tS(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function nS(e){let{t}=J(),n=W(),[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(tS(e,`Password is incorrect`)),l(null)}},_=async()=>{l(`passkey`),d(null);try{let{optionsJSON:e}=await n.reauthBeginPasskey();if(!eS(e))throw Error(`passkey authentication options missing challenge`);let t=await Qx({optionsJSON:e}),{reauthToken:r}=await n.reauthenticate({passkeyResponse:Object.fromEntries(Object.entries(t))});m(r)}catch(e){d(tS(e,`Passkey verification failed`)),l(null)}};return{requestProof:h,dialog:x(Kn,{open:r,onOpenChange:e=>!e&&m(null),children:s(er,{children:[s(Fn,{children:[x(_r,{children:t(`auth.reauthDialog.confirmItSYou`,`Confirm it’s you`)}),x(ur,{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(Vi,{className:`flex flex-wrap gap-2`,children:[s(K,{type:`button`,variant:`outline`,disabled:c!==null,onClick:()=>void _(),children:[c===`passkey`?x(U,{className:`h-4 w-4 animate-spin`}):x(yn,{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(U,{className:`h-4 w-4 animate-spin`}),t(`common.confirm`,`Confirm`)]})]})]})]})})}}O();function rS(e){return e.ip!==null&&e.approverIp!==null&&e.ip!==e.approverIp}function iS(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function aS(e){let t=e instanceof Error?e.message:``;return t.startsWith(`Sign in again first`)||t.startsWith(`Confirm it is you`)}function oS(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 sS({onApproved:e,onDenied:t}){let{t:n}=J(),r=Gn.useUtils(),[i,a]=w(``),[o,c]=w(null),[l,u]=w(``),[d,f]=w(null),[p,m]=w(null),{requestProof:h,dialog:g}=nS(n(`cliLogin.reauthAction`,`Approving a terminal sign-in`)),_=Gn.auth.cliLoginApprove.useMutation(),v=Gn.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(iS(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(!aS(e))throw e;let t=await h();if(t===null)return;await _.mutateAsync({userCode:l,reauthToken:t})}e()}catch(e){m(iS(e,n(`cliLogin.failed`,`That did not work. Try again.`)))}finally{f(null)}},S=o===null?null:oS(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(On,{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(U,{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})})]})]}),rS(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(U,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),n(`cliLogin.approve`,`Approve`)]})]})]}),g]})}O();function cS(){let{t:e}=J(),t=Ar(),n=ms(),[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`?H(`/brand/logo-horizontal-light.svg`):H(`/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(sS,{onApproved:()=>window.location.assign(H(on(null,{status:`success`,action:`cli-login`}))),onDenied:()=>i(!0)})})]})})}var lS=`auth.password-incorrect`;function uS(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function dS(e){if(!(e instanceof Error))return{kind:`connection-lost`};let t=uS(e,`data`);return typeof t!=`object`||!t?{kind:`connection-lost`}:uS(uS(t,`i18n`),`code`)===lS?{kind:`wrong-current`}:uS(t,`code`)===`UNAUTHORIZED`?{kind:`session-ended`}:{kind:`rejected`,message:e.message}}O();var fS=8;function pS(e,t){let n=dS(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 mS(){let{t:e}=J(),{user:t,mustChangePassword:n,clearMustChangePassword:r,logout:i}=T_(),a=W(),o=Ar(),c=ms(),[l,u]=w(``),[d,f]=w(``),[p,m]=w(``),[h,g]=w(!1),[_,v]=w(``),[y,b]=w(!1),S=n?h_: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`?H(`/brand/logo-horizontal-light.svg`):H(`/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<fS){v(`Password must be at least ${fS} 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(pS(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?R:ve,{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 hS(e){if(!eS(e))throw Error(`passkey authentication options missing challenge`);let t=await Qx({optionsJSON:e});return Object.fromEntries(Object.entries(t))}function gS({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=wg();if(t){let r=await hS((await e.loginBeginPasskey(t)).optionsJSON),i=await e.loginVerifyPasskey(t,r,{refreshable:!0});n(i.token,i);return}let a=await hS((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(U,{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 _S=()=>window.location.hostname;function vS(e,t=_S,n=null){return n===!1?!1:Ux()&&eb(t(),e.rpId)}function yS(e,t=_S,n=null){let r=e.filter(e=>e.kind===`passkey`&&e.stage===`second-factor`).filter(e=>vS(e,t,n));return{passkeyMethods:r,widgetMethods:r.length>0?[]:e.filter(e=>e.kind===`widget`&&e.stage===`second-factor`)}}function bS(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 xS(){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 SS=()=>`camstackAgentApp`in window;function CS(){let[e,t]=w(null);return S(()=>{if(!SS())return;let e=!0;return xS().then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}function wS(e){let t=e.onComplete,n=e.onSecondFactor;return typeof t==`function`?{onComplete:t,onSecondFactor:typeof n==`function`?n:void 0}:null}function TS({methods:e,widgetConfig:t,onRedirect:n}){let{t:r}=J();ji();let i=CS(),a=e.filter(e=>e.kind!==`passkey`||vS(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:fr(e.icon))??et;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=wS(t);return n?x(gS,{method:e,onComplete:n.onComplete,onSecondFactor:n.onSecondFactor},e.id):null}return x(ES,{method:e,config:t},e.id)})})]})}function ES({method:e,config:t}){let{t:n}=J(),r=_i(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(U,{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(He,{className:`h-3.5 w-3.5 shrink-0`}),n(`login.primaryMethods.loadFailed`)]}):x(r,{instanceId:e.id,host:`dashboard`,config:t})}var DS=4e3,OS=/^[A-Za-z0-9._-]{1,64}$/;function kS(e){if(e.action===`cli-login`)return Mx(`access`);let t=e.addonId!==void 0&&OS.test(e.addonId)?e.addonId:null,n=e.integration!==void 0&&OS.test(e.integration)?e.integration:null;if(t!==null&&e.brokerId!==void 0)return Mx(`connectivity`,{integration:t,kindSection:`brokers`});let r=n??t;return Mx(`connectivity`,r===null?{}:{integration:r})}function AS(e,t){let n=t.opener;if(n===null||n.closed||aa(n)!==t.origin)return!1;try{return n.postMessage({type:Cl,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 jS=500;function MS(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 NS({outcome:e}){let{t}=J(),n=MS(e.reason??`unknown`);if(e.status===`error`)return s(I,{children:[x(rt,{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(ie,{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(ie,{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 PS({outcome:e,closable:t,onContinue:n,onClose:r}){let{t:i}=J(),a=kS(e);return S(()=>{if(e.status!==`success`)return;let t=window.setTimeout(()=>n(a),DS);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:H(`/brand/logo-horizontal-dark.svg`)}),x(`img`,{src:H(`/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(NS,{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 FS(e,t){window.history.replaceState(null,``,window.location.pathname);let n=window.opener,r=AS(t,{opener:n,origin:window.location.origin}),i=()=>e.render(x(PS,{outcome:t,closable:r,onContinue:e=>window.location.replace(H(e)),onClose:()=>window.close()}));if(r&&t.status===`success`){window.close(),window.setTimeout(i,jS);return}i()}function IS(e){return Qt(e)}var LS=`Done — you can close this window.`,RS=500,zS=`camstack_admin_token`;async function BS(e,t=``){try{let n=Pg(new URLSearchParams(t));n!==null&&n.token===e?Mg(n):localStorage.setItem(zS,e)}catch{}await fetch(H(`/api/auth/session`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({token:e})}).catch(()=>{})}function VS(){try{let e=localStorage.getItem(zS);return e!==null&&e.length>0?e:null}catch{return null}}function HS(e){let t=IS(window.location.hash);if(t!==null){FS(e,t);return}let n=ea(window.location.hash);window.history.replaceState(null,``,window.location.pathname);let r=t=>e.render(x(US,{completion:n,result:t,hasOpener:window.opener!==null}));if(r(null),n===null)return;let i=oa();ca(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:LS}),RS)},continueAt:e=>window.location.replace(H(e)),persistSession:e=>BS(e,n.target===`login`?n.fragment:``),showResult:r,setTimeout:(e,t)=>window.setTimeout(e,t)})}function US({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:H(`/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:H(`/login`),children:r(`ssoComplete.backToSignIn`,`Back to sign-in`)})]})})})}O();function WS(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 GS(){let e=new URLSearchParams(window.location.search);return Yg({codeChallenge:e.get(`code_challenge`),codeChallengeMethod:e.get(`code_challenge_method`),state:e.get(`state`),purpose:e.get(`purpose`)})}function KS(e){return Math.min(1e3*2**e,15e3)}function qS(){let{t:e}=J(),{login:t,verifyTotp:n,finalizePasskeyLogin:r,user:i}=T_(),{i18n:a}=J(),o=Ar(),c=ms(),l=X(),u=new URLSearchParams(window.location.search).get(`next`);S(()=>{i_(u)},[u]);let d=new URLSearchParams(window.location.search).get(`redirect`);S(()=>{p_(d)},[d]);let f=GS();S(()=>{Qg(f)},[f?.codeChallenge,f?.state,f?.purpose]);let m=l.state,h=ax(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(``),[ee,te]=w(void 0),[ne,re]=w(`sso-not-linked`),ie=Gn.auth.listLoginMethods.useQuery(void 0,{retry:!0,retryDelay:KS}),ae=ie.data===void 0,oe=(ie.data??[]).filter(e=>e.kind!==`device-certificate`),se=Gn.auth.getServerName.useQuery().data,z=oe.filter(e=>e.stage===`primary`),B=yS(oe,void 0,CS());S(()=>{let e=la(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}re(e.code),te(e.provider)}},[]);let V=ee==null?null:oe.find(e=>e.id===ee&&`label`in e)?.label??null,ce=T||(ee===void 0?``:na(ne,V)),{passkeyMethods:le,widgetMethods:ue}=B,de=p(!1),fe=async()=>{if(de.current)return;de.current=!0;let e=t_(d);if(e?.kind===`app-callback`){await he(e.url);return}else if(e){window.location.assign(H(e.path));return}let t=o_(u);t?window.location.assign(H(t)):c(h,{replace:!0})},[pe,me]=w(null),he=async e=>{me({callbackBase:e,mintedUrl:null,failed:!1});try{let t=GS()??$g();if(t===null)throw Error(`The app sent no PKCE challenge and state`);let{code:n}=await wg().trpcClient.auth.createHandoffCode.mutate({purpose:t.purpose,codeChallenge:t.codeChallenge,state:t.state}),r=e_(e,n,t.state);me({callbackBase:e,mintedUrl:r,failed:!1}),window.location.assign(r)}catch(t){if(WS(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,ye]=w(!1);S(()=>{!ge||!d&&!u||_e||(ye(!0),fe())},[ge,d,u,_e]);let be=async e=>{e.preventDefault(),E(``),te(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)}},xe=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)}},Se=async(e,t)=>{try{await r(e,t),await fe()}catch(e){E(e instanceof Error?e.message:`Passkey sign-in failed`)}},Ce=p(null);S(()=>()=>Ce.current?.(),[]);let we=async e=>{if(e.target!==`login`)return;let t=Pg(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=la(`#${e.fragment}`);if(n!==null){if(n.kind===`challenge`){Ee({challengeToken:n.challengeToken,factors:n.factors});return}re(n.code),te(n.provider)}},Te=e=>{if(Kg(d)?.kind===`app-callback`)return!1;let t=ra(H(ta(e.startUrl)));return t===null?!1:(E(``),te(void 0),Ce.current?.(),Ce.current=sa(t,{onReturn:e=>{Ce.current?.(),Ce.current=null,we(e)},onDone:e=>{if(Ce.current?.(),Ce.current=null,e.target!==`login`)return;let t=VS()===null?null:jg();t!==null&&we({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)},Ee=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`?H(`/brand/logo-horizontal-light.svg`):H(`/brand/logo-horizontal-dark.svg`),alt:e(`login.camstackAdmin`,`CamStack Admin`),className:`h-12`})}),se!==void 0&&!se.isDefault&&x(`p`,{"data-testid":`login-server-name`,className:`-mt-4 mb-6 text-center text-sm text-foreground-muted`,children:x(Sl,{i18nKey:`login.signInTo`,values:{name:se.name},components:{b:x(`span`,{className:`font-semibold text-foreground`})}})}),k===`credentials`?s(`form`,{onSubmit:be,className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[ce&&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:ce}),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?R:ve,{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(Ue,{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(Sl,{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`)&&le.map(e=>x(gS,{method:e,challengeToken:j,onComplete:Se},e.id)),N.includes(`passkey`)&&ue.map(e=>x(ES,{method:e,config:{challengeToken:j,onComplete:Se}},e.id)),bS(N,B)&&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:xe,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(Xe,{className:`h-3 w-3`}),e(`login.backToUsernamePassword`,`Back to username + password`)]})]}),k===`credentials`&&ae&&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(TS,{methods:z,widgetConfig:{onComplete:Se,onSecondFactor:Ee,locale:a.language},onRedirect:Te}),x(`p`,{className:`mt-6 text-center text-[10px] text-foreground-subtle/50`,children:x(fx,{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`)})]})]})})}O();function JS(){let{pathname:e,search:t,hash:n}=X();return x(Z,{to:`${Fx(e)}${t}${n}`,replace:!0})}function YS(){return x(Z,{to:rx()??`/devices`,replace:!0})}var XS=g(()=>a(()=>import(`./Devices-Bc4BHwpe.js`).then(e=>({default:e.DevicesPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]),import.meta.url)),ZS=g(()=>a(()=>import(`./Integrations-DIgPCmCb.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([11,1,2,3,4,12,5,13,6,14,7,9,15]),import.meta.url)),QS=g(()=>a(()=>import(`./IntegrationDetail-CUUOhCzq.js`).then(e=>({default:e.IntegrationDetailPage})),__vite__mapDeps([16,1,2,3,4,17,5,14,7,18,19,8]),import.meta.url)),$S=g(()=>a(()=>import(`./Pipeline-DdsVy_AV.js`).then(e=>({default:e.PipelinePage})),__vite__mapDeps([20,1,2,3,4,12,5,21,22,23,24,25,26,27,9]),import.meta.url)),eC=g(()=>a(()=>import(`./DeviceDetail-CWLf4l8q.js`).then(e=>({default:e.DeviceDetailPage})),__vite__mapDeps([28,1,2,3,4,12,5,29,30,31,32,33,21,34,35,24,36,37,38,39,40,41,42,43,44,45,46,26,9,47,19,48]),import.meta.url)),tC=g(()=>a(()=>import(`./Showroom-TwupeRdK.js`).then(e=>({default:e.ShowroomPage})),__vite__mapDeps([49,1,2,3,4]),import.meta.url)),nC=g(()=>a(()=>import(`./EmbedPlayerPage-D_hbiDn0.js`).then(e=>({default:e.EmbedPlayerPage})),__vite__mapDeps([50,1,2,3,4,5]),import.meta.url)),rC=g(()=>a(()=>import(`./Library-Bl_xkCam.js`).then(e=>({default:e.LibraryPage})),__vite__mapDeps([51,1,2,3,4,12,5,52,21,23,53,54,45,55,47,19]),import.meta.url)),iC=g(()=>a(()=>import(`./Recordings-Qtccm3Yn.js`).then(e=>({default:e.RecordingsPage})),__vite__mapDeps([56,1,2,3,4,12,5,57,54,58,29,59,60,61,62,25,18,19,63,47]),import.meta.url)),aC=g(()=>a(()=>import(`./Viewer-B_9mn9kj.js`).then(e=>({default:e.ViewerPage})),__vite__mapDeps([64,2,3,4,65,5,19,1]),import.meta.url)),oC=g(()=>a(()=>import(`./Build-JfcMscnG.js`).then(e=>({default:e.BuildPage})),__vite__mapDeps([66,1,2,3,4,12,5,33,67,21,68,54,38,32,39,40,41,42,43,44]),import.meta.url)),sC=g(()=>a(()=>import(`./CompositionEditorPage-C4jc1B6k.js`).then(e=>({default:e.CompositionEditorPage})),__vite__mapDeps([69,1,2,3,4,33,5,6,38,12,32,21,39,40,41]),import.meta.url)),cC=g(()=>a(()=>import(`./Locations-CcTd8h93.js`).then(e=>({default:e.LocationsPage})),__vite__mapDeps([70,1,2,3,4,12,5,33,71,53,54,46,40,41]),import.meta.url)),lC=g(()=>a(()=>import(`./Addons-KzL11keT.js`).then(e=>({default:e.AddonsPage})),__vite__mapDeps([72,1,2,3,4,21,5,6,25,73,10,15,19]),import.meta.url)),uC=g(()=>a(()=>import(`./AiProfiles-CJymDhUN.js`).then(e=>({default:e.AiProfilesPage})),__vite__mapDeps([74,1,2,3,4,12,5,75,76,6,54,61,62,25,18,19,77]),import.meta.url)),dC=g(()=>a(()=>import(`./MyAccess-DAZSxq6w.js`).then(e=>({default:e.MyAccessPage})),__vite__mapDeps([78,1,2,3,4,12,5,21,79,80,6,54,81,19,82]),import.meta.url)),fC=g(()=>a(()=>import(`./Logs-CdgFEAUx.js`).then(e=>({default:e.LogsPage})),__vite__mapDeps([83,1,2,3,4,24,84,5,6,54,61,62,25,18,19]),import.meta.url)),pC=g(()=>a(()=>import(`./Identity-DxoiP6P_.js`).then(e=>({default:e.IdentityPage})),__vite__mapDeps([85,1,2,3,4,12,5,21,35,86,79,80,6,54,81,87,88,61,62,25,18,19,89,90,91]),import.meta.url)),mC=g(()=>a(()=>import(`./Network-LqpZJtlD.js`).then(e=>({default:e.NetworkPage})),__vite__mapDeps([92,1,2,3,4,12,5,33,21,6,54,61,62,25,18,19,91]),import.meta.url)),hC=g(()=>a(()=>import(`./Integrations-NjDYWDHO.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([93,1,2,3,4,12,5,21,54,61,62,25,18,19,87,88,6]),import.meta.url)),gC=g(()=>a(()=>import(`./TrainingProviders-B4mcZKfz.js`).then(e=>({default:e.TrainingProvidersPage})),__vite__mapDeps([94,1,2,3,4,5,6,61,62,25,18,19]),import.meta.url)),_C=g(()=>a(()=>import(`./Data-DUlmeoKU.js`).then(e=>({default:e.DataPage})),__vite__mapDeps([95,1,2,3,4,12,5,67,21,34,96,60,6,54,61,62,25,18,19,58,29,59,63,47]),import.meta.url)),vC=g(()=>a(()=>import(`./System-yvxoK1-C.js`).then(e=>({default:e.SystemPage})),__vite__mapDeps([97,1,2,3,4,12,5,98,6,54,25,89,90,21,61,62,18,19,87,88,91]),import.meta.url)),yC=g(()=>a(()=>import(`./Cluster-B5g_W7EV.js`).then(e=>({default:e.ClusterPage})),__vite__mapDeps([99,1,2,3,4,12,5,60,100,80,6,44,25,27,73,63]),import.meta.url)),bC=g(()=>a(()=>import(`./CameraGrids-CPw3_tbn.js`).then(e=>({default:e.CameraGridsPage})),__vite__mapDeps([101,2,3,4,5,61,1,62,25,18,19]),import.meta.url)),xC=g(()=>a(()=>import(`./Terminal-CCImGxuy.js`).then(e=>({default:e.TerminalPage})),__vite__mapDeps([102,1,2,3,4,21,5,6,61,62,25,18,19,91,103]),import.meta.url)),SC=g(()=>a(()=>import(`./Notifications-BtvOosgt.js`).then(e=>({default:e.NotificationsPage})),__vite__mapDeps([104,1,2,3,4,12,5,31,21,75,105,6,54,61,62,25,18,19,43,39,44,55,77,41,48]),import.meta.url)),CC=g(()=>a(()=>import(`./History-pMj6FeqQ.js`).then(e=>({default:e.HistoryPage})),__vite__mapDeps([106,1,2,3,4,5,6]),import.meta.url)),wC=g(()=>a(()=>import(`./Calendars-C9ZSLbHl.js`).then(e=>({default:e.CalendarsPage})),__vite__mapDeps([107,1,2,3,4,12,5,21,6]),import.meta.url)),TC=g(()=>a(()=>import(`./Templates-C4mFSZiC.js`).then(e=>({default:e.TemplatesPage})),__vite__mapDeps([108,1,2,3,4,21,109,80,5,36,37,6]),import.meta.url)),EC=new D({defaultOptions:{queries:{gcTime:0,staleTime:0,retry:!1,refetchOnWindowFocus:!1}}});zi(EC);function DC({field:e,value:t,onChange:n,disabled:r}){return x(dv,{field:e,value:t,onChange:n,disabled:r})}var OC={"model-selector":DC};function kC({children:e}){let{t}=J(),{user:n,logout:r}=T_(),[i,a]=w(0),o=p(n?.username??null);S(()=>{let e=n?.username??null;e!==o.current&&(o.current=e,Tg(),a(e=>e+1))},[n]);let c=m(()=>wg(),[i]),l=b(()=>{wg().reconnect(),a(e=>e+1),EC.invalidateQueries()},[]);Rv(b(()=>Ug(l),[l])),S(()=>zg(()=>{wg().isSocketTokenStale()&&l()}),[l]);let u=b(async()=>{let e=await Wg();return e&&l(),e},[l]),{bootReady:d,bootError:f}=Iv(c,n??null,r,u);return x(Nv,{children:x(Ke,{system:c,children:x(Gn.Provider,{client:c.trpcClient,queryClient:EC,children:s(Rr,{children:[x(Ir,{children:x(hi,{children:x(ni,{children:d?e:x(AC,{})})})}),d&&x(_v,{}),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 AC(){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 jC(){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 MC(){return S(()=>zx(),[]),x(Ii,{defaultMode:`dark`,children:x(wr,{children:x(F,{client:EC,children:x(w_,{children:x(kC,{children:x(Ve,{children:x(gv,{children:x(kr,{renderers:OC,children:s(tr,{picker:yh,children:[x(Mc,{basename:Je(),children:x(av,{children:x(y,{fallback:x(jC,{}),children:s(Us,{children:[x(Q,{path:`/login`,element:x(qS,{})}),x(Q,{path:`/admin/*`,element:x(JS,{})}),x(Q,{path:`/admin`,element:x(JS,{})}),x(Q,{path:`/change-password`,element:x($,{children:x(mS,{})})}),x(Q,{path:`/approve`,element:x($,{children:x(cS,{})})}),x(Q,{path:`/showroom`,element:x(tC,{})}),x(Q,{path:`/embed/player`,element:x(nC,{})}),s(Q,{element:x($,{children:x(da,{children:x(yx,{})})}),children:[x(Q,{index:!0,element:x(YS,{})}),x(Q,{path:`/access-denied`,element:x(Bx,{})}),x(Q,{path:`/dashboard`,element:x(Z,{to:`/devices`,replace:!0})}),x(Q,{path:`/devices`,element:x(XS,{})}),x(Q,{path:`/cameras`,element:x(Z,{to:`/devices`,replace:!0})}),x(Q,{path:`/integrations`,element:x(ZS,{})}),x(Q,{path:`/integrations/:addonId`,element:x(QS,{})}),x(Q,{path:`/system/pipeline`,element:x(gy,{path:`/system/pipeline`,children:x($S,{})})}),x(Q,{path:`/pipeline`,element:x(Z,{to:`/system/pipeline`,replace:!0})}),x(Q,{path:`/live`,element:x(aC,{})}),x(Q,{path:`/devices/:deviceId`,element:x(eC,{})}),x(Q,{path:`/system/logs`,element:x($,{requireAdmin:!0,children:x(fC,{})})}),x(Q,{path:`/system/addons`,element:x($,{requireAdmin:!0,children:x(lC,{})})}),x(Q,{path:`/system/ai`,element:x($,{requireAdmin:!0,children:x(uC,{})})}),x(Q,{path:`/system/settings`,element:x($,{requireAdmin:!0,children:x(vC,{})})}),x(Q,{path:`/system/nodes`,element:x($,{requireAdmin:!0,children:x(yC,{})})}),x(Q,{path:`/system/notifications`,element:x($,{requireAdmin:!0,children:x(SC,{})})}),x(Q,{path:`/system/history`,element:x($,{requireAdmin:!0,children:x(CC,{})})}),x(Q,{path:`/system/calendars`,element:x($,{requireAdmin:!0,children:x(wC,{})})}),x(Q,{path:`/system/templates`,element:x($,{requireAdmin:!0,children:x(TC,{})})}),x(Q,{path:`/system/identity`,element:x($,{requireAdmin:!0,children:x(pC,{})})}),x(Q,{path:`/system/my-access`,element:x(dC,{})}),x(Q,{path:`/system/network`,element:x($,{requireAdmin:!0,children:x(mC,{})})}),x(Q,{path:`/training/providers`,element:x($,{requireAdmin:!0,children:x(gC,{})})}),x(Q,{path:`/system/integrations`,element:x($,{requireAdmin:!0,children:x(hC,{})})}),x(Q,{path:`/system/data`,element:x($,{requireAdmin:!0,children:x(_C,{})})}),x(Q,{path:`/system`,element:x(Z,{to:bv,replace:!0})}),x(Q,{path:`/system/camera-grids`,element:x($,{requireAdmin:!0,children:x(bC,{})})}),x(Q,{path:`/system/terminal`,element:x($,{requireAdmin:!0,children:x(xC,{})})}),x(Q,{path:wv,element:x(Dv,{})}),xv.map(e=>x(Q,{path:e.path,element:x(Ev,{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:Mx(`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:Mx(`remoteAccess`),replace:!0})}),x(Q,{path:`/system/turn`,element:x(Z,{to:Mx(`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(rC,{})})}),x(Q,{path:`/retrain`,element:x(Z,{to:`/addon/training`,replace:!0})}),x(Q,{path:`/recordings`,element:x($,{requireAdmin:!0,children:x(iC,{})})}),x(Q,{path:`/build`,element:x($,{requireAdmin:!0,children:x(oC,{})})}),x(Q,{path:xx,element:x($,{requireAdmin:!0,children:x(sC,{})})}),x(Q,{path:Sx,element:x($,{requireAdmin:!0,children:x(sC,{})})}),x(Q,{path:`/locations`,element:x($,{requireAdmin:!0,children:x(cC,{})})}),x(Q,{path:`/automation`,element:x(fv,{to:`/build`})}),x(Q,{path:`/addon/:pagePath`,element:x($,{requireAdmin:!0,children:x(cy,{})})}),x(Q,{path:`*`,element:x(Z,{to:`/devices`,replace:!0})})]})]})})})}),x(Av,{}),x(Ha,{})]})})})})})})})})})}O(),window.__camstackUiLibrary=li,window.__camstackSdk=mr,window.__camstackTypes=cn;var NC=Wi(document.getElementById(`root`));ia(window.location.pathname,Je())?HS(NC):NC.render(x(T,{children:x(MC,{})}));export{Im as $,Fu as $n,uf as $t,M_ as A,vd as An,bu as Ar,op as At,Ph as B,Du as Bn,Hc as Br,kf as Bt,Mv as C,Bd as Cn,du as Cr,gp as Ct,rv as D,Hd as Dn,lu as Dr,sp as Dt,hv as E,Vd as En,fu as Er,lp as Et,D_ as F,Qu as Fn,Pc as Fr,bf as Ft,Th as G,Iu as Gn,Nf as Gt,Nh as H,Xu as Hn,Lf as Ht,T_ as I,ud as In,Z as Ir,xf as It,eh as J,id as Jn,Sf as Jt,_h as K,nd as Kn,Af as Kt,rg as L,Ku as Ln,X as Lr,zf as Lt,F_ as M,bd as Mn,Tl as Mr,rp as Mt,k_ as N,Sd as Nn,Ol as Nr,np as Nt,V_ as O,Cd as On,ou as Or,cp as Ot,O_ as P,xd as Pn,Sl as Pr,Zf as Pt,Hm as Q,ld as Qn,lf as Qt,ng as R,Vu as Rn,ms as Rr,Gf as Rt,my as S,Ld as Sn,mu as Sr,jp as St,Tv as T,jd as Tn,vu as Tr,xp as Tt,Mh as U,td as Un,Tf as Ut,Lh as V,Ju as Vn,Ef as Vt,jh as W,cd as Wn,If as Wt,Xm as X,ku as Xn,Bf as Xt,nh as Y,Hu as Yn,Ff as Yt,Lm as Z,Au as Zn,yf as Zt,ub as _,Zd as _n,uu as _r,mp as _t,kx as a,mf as an,qu as ar,Ym as at,Hy as b,Yd as bn,su as br,Tp as bt,Ax as c,of as cn,Nu as cr,nm as ct,Px as d,af as dn,rd as dr,Lp as dt,pf as en,Lu as er,qm as et,Cx as f,nf as fn,Mu as fr,Dp as ft,pb as g,Rd as gn,hu as gr,Sp as gt,wx as h,qd as hn,xu as hr,kp as ht,Ox as i,vf as in,Uu as ir,Am as it,N_ as j,Ed as jn,yu as jr,ip as jt,z_ as k,_d as kn,gu as kr,up as kt,Mx as l,cf as ln,Zu as lr,em as lt,Tx as m,tf as mn,Cu as mr,hp as mt,nS as n,gf as nn,$u as nr,Fm as nt,Ex as o,Qd as on,Gu as or,Cm as ot,bx as p,rf as pn,Tu as pr,yp as pt,lh as q,ed as qn,Mf as qt,jx as r,_f as rn,dd as rr,jm as rt,Dx as s,sf as sn,ju as sr,im as st,oS as t,hf as tn,Ru as tr,Jm as tt,Nx as u,ef as un,Yu as ur,$p as ut,db as v,Jd as vn,au as vr,pp as vt,bv as w,Nd as wn,pu as wr,_p as wt,Vy as x,Xd as xn,cu as xr,Op as xt,By as y,Wd as yn,_u as yr,vp as yt,Hh as z,Wu as zn,vs as zr,jf as zt};
|