@camstack/addon-admin-ui 1.2.710 → 1.2.712
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 +14 -0
- package/dist/assets/{AccessSection-Cgv04lJf.js → AccessSection-BMHyeXXs.js} +1 -1
- package/dist/assets/{Addons-BJL6WRKD.js → Addons-Czq7HK5o.js} +1 -1
- package/dist/assets/{AdminPage-CFltVUtJ.js → AdminPage-DgcMq51y.js} +1 -1
- package/dist/assets/{AdminSectionedPage-DfZeI0TS.js → AdminSectionedPage-BKAltoSC.js} +1 -1
- package/dist/assets/{AiProfiles-DW29u0zA.js → AiProfiles-C3dVuuEs.js} +1 -1
- package/dist/assets/Archive-DD70ZFMv.js +1 -0
- package/dist/assets/{BootstrapSettingsForm-DKjedbyR.js → BootstrapSettingsForm-DNIVKIZZ.js} +1 -1
- package/dist/assets/Build-B0vH9mDa.js +40 -0
- package/dist/assets/{Calendars-Bfl32yKa.js → Calendars-B1cBJoa1.js} +1 -1
- package/dist/assets/{Cluster-BT8yE3Jd.js → Cluster-BMZ_3SCr.js} +1 -1
- package/dist/assets/CompositionBlockEditor-Bj14wly_.js +2 -0
- package/dist/assets/{CompositionEditorPage-DAZ2EbrI.js → CompositionEditorPage-sUNp8qe7.js} +1 -1
- package/dist/assets/{Data-CCLq4I9_.js → Data-DcunBcmb.js} +1 -1
- package/dist/assets/DeviceDetail-CUJRNGTx.js +1 -0
- package/dist/assets/{Devices-BbWkqyWN.js → Devices-DxX8ybfM.js} +1 -1
- package/dist/assets/{EmbedDevicePage-C3hraaEM.js → EmbedDevicePage-G-VhlNDT.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-RHniI2xA.js → EmbedPlayerPage-CVF9_4Ua.js} +1 -1
- package/dist/assets/{History-B5SE1vph.js → History-DhTpectV.js} +1 -1
- package/dist/assets/{Identity-COMelIL5.js → Identity-BhsJ_1aP.js} +1 -1
- package/dist/assets/{InstancesTable-Gi6mvKws.js → InstancesTable-w-0XwFaG.js} +1 -1
- package/dist/assets/{IntegrationDetail-BJgK3HQZ.js → IntegrationDetail-jDFoyrP9.js} +1 -1
- package/dist/assets/{Integrations-DBIDhCAF.js → Integrations-C28hBhrU.js} +1 -1
- package/dist/assets/{Integrations-BAxIjtmf.js → Integrations-C9wh6FxD.js} +1 -1
- package/dist/assets/{Library-j-P8SKgP.js → Library-Cia1655I.js} +1 -1
- package/dist/assets/{Locations-BPRZSbLT.js → Locations-C1F9DRbX.js} +1 -1
- package/dist/assets/Logs-D24n8jj9.js +1 -0
- package/dist/assets/{MaskShapeCanvas-BN6ufTmt.js → MaskShapeCanvas-mnq8FU_f.js} +1 -1
- package/dist/assets/{MotionZonesSettings-DsM7FPZE.js → MotionZonesSettings-D7_18_A_.js} +1 -1
- package/dist/assets/{MyAccess-B3gTfVDq.js → MyAccess-CHM9pog8.js} +1 -1
- package/dist/assets/{Network-CBAabM0h.js → Network-dIj7QC_n.js} +1 -1
- package/dist/assets/{NewExportModal-DGq6CWpy.js → NewExportModal-94DuvHcM.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-DCa3tgOb.js → NodeAddonsSettingsPanel-D_zP_si3.js} +1 -1
- package/dist/assets/Notifications-BtDiQ8BU.js +1 -0
- package/dist/assets/{PanelContent-CVkHXftN.js → PanelContent-_kL0sZaa.js} +1 -1
- package/dist/assets/{Pipeline-CdKKet5N.js → Pipeline-Cz-2Qr0F.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-m809AVSj.js → PrivacyMaskSettings-D4w4a5Cj.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-BRoTpS7V.js → SceneMonitorEditor-CUpdk172.js} +1 -1
- package/dist/assets/{SessionsList-Dqh1pfhl.js → SessionsList-DoB89UjE.js} +1 -1
- package/dist/assets/{Showroom-DO5dhVVy.js → Showroom-Bc0RMx1T.js} +1 -1
- package/dist/assets/{StorageLocationsTable-DjJKdT5E.js → StorageLocationsTable-DdQZaTIL.js} +1 -1
- package/dist/assets/System-xU_4F1qj.js +2 -0
- package/dist/assets/TemplateEditorDialog-DFNJgsxk.js +1 -0
- package/dist/assets/{Terminal-AxKgimJQ.js → Terminal-CF3uGeFD.js} +1 -1
- package/dist/assets/{TrainingProviders-DqSWU0Ff.js → TrainingProviders-B_G3A6On.js} +1 -1
- package/dist/assets/{Viewer-BBtW52-D.js → Viewer-WyKz0Azc.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CnAAoU-a.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CkUFXaiW.js} +1 -1
- package/dist/assets/{action-draft-xWZeLJBc.js → action-draft-CwJf5eW2.js} +1 -1
- package/dist/assets/{ai-page.helpers-DutvjEb-.js → ai-page.helpers-BHBXHNQI.js} +1 -1
- package/dist/assets/{assignment-candidates-BJPEmgFZ.js → assignment-candidates-DRmDIzIf.js} +1 -1
- package/dist/assets/{authed-media-BTPD9Rqy.js → authed-media-DQnc3x5u.js} +1 -1
- package/dist/assets/{board-model-p3qXSelJ.js → board-model-CAPxQYkg.js} +1 -1
- package/dist/assets/{camera-block-model-BmK3dL9c.js → camera-block-model-Cvhw1ACQ.js} +1 -1
- package/dist/assets/{client-D93RkunP.js → client-CU9hiVrv.js} +12 -12
- package/dist/assets/{command-vocab-DGcpiUvY.js → command-vocab-3vo0YGZY.js} +1 -1
- package/dist/assets/{device-integration-icon-Cfi7eokn.js → device-integration-icon-CZX0mESs.js} +1 -1
- package/dist/assets/device-picker-model-BoRMX84w.js +1 -0
- package/dist/assets/{dist-SwLD2DK1.js → dist-BWrpV4hP.js} +1 -1
- package/dist/assets/dist-LYFPq0g9.js +1125 -0
- package/dist/assets/{format-Dzip80Uj.js → format-kIcasnZL.js} +1 -1
- package/dist/assets/{hostInit-C3sYu6u4.js → hostInit-BZDzYAHr.js} +1 -1
- package/dist/assets/i18n-B5Xm3ktp.js +1 -0
- package/dist/assets/{icons-C4C8iPI_.js → icons-Cnaoe6qZ.js} +1 -1
- package/dist/assets/{index-BZLBXpx-.js → index-ByN-VTu-.js} +4 -4
- package/dist/assets/index-CaKMKRxP.css +2 -0
- package/dist/assets/{linked-devices-model-ChJFxnJQ.js → linked-devices-model-B9Gz49sE.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-31325a3f.js → mf-entry-bootstrap-0-ac9760ea.js} +2 -2
- package/dist/assets/mount-BoRMX84w.js +1 -0
- package/dist/assets/{notification-rule-status-BWxeQ-_D.js → notification-rule-status-CFjuiCT9.js} +1 -1
- package/dist/assets/{player-overlays-hLBmOC8C.js → player-overlays-C-OmGoqt.js} +1 -1
- package/dist/assets/remoteEntry-ComxP4sU.js +1 -0
- package/dist/assets/src-BL1KpPQ2.js +279 -0
- package/dist/assets/{sso-popup-D5c1Dbz3.js → sso-popup-D9gVafKd.js} +1 -1
- package/dist/assets/{step-inspector-model-kpUIIlrE.js → step-inspector-model-zgo3LXy6.js} +1 -1
- package/dist/assets/{use-scenes-feed-D60vwQnn.js → use-scenes-feed-C4jyU72L.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-DHZF8Bhc.js → useAdminDeviceRemoval-B5adL9sz.js} +1 -1
- package/dist/assets/useEventInvalidation-BoRMX84w.js +1 -0
- package/dist/assets/{useNodeUrlSelection-CxldmcjV.js → useNodeUrlSelection-vqyOWkjs.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DgZGj8av.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DV6hhcvX.js} +2 -2
- package/dist/index.html +9 -9
- package/dist/server/addon.js +22 -1
- package/package.json +2 -2
- package/dist/assets/Archive-DJk2nZPq.js +0 -1
- package/dist/assets/Build-CaXtQUh_.js +0 -40
- package/dist/assets/CompositionBlockEditor-DmYv5ln7.js +0 -2
- package/dist/assets/DeviceDetail-DNKg72IG.js +0 -1
- package/dist/assets/Logs-RCKlFer4.js +0 -1
- package/dist/assets/Notifications-DccqInu6.js +0 -1
- package/dist/assets/System-nfPLxCLF.js +0 -2
- package/dist/assets/TemplateEditorDialog-eOBMrmCP.js +0 -1
- package/dist/assets/device-picker-model-Bbj8t_iL.js +0 -1
- package/dist/assets/dist-ClyHN0ce.js +0 -1125
- package/dist/assets/i18n-ILINfI4k.js +0 -1
- package/dist/assets/index-BFuQYqWe.css +0 -2
- package/dist/assets/mount-Bbj8t_iL.js +0 -1
- package/dist/assets/remoteEntry-9sIn-FFM.js +0 -1
- package/dist/assets/src-CR4MjS0h.js +0 -279
- package/dist/assets/useEventInvalidation-Bbj8t_iL.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$a as d,D as f,Da as p,Dr as m,Ea as h,Ga as g,Hr as _,Ir as v,Jn as y,Ka as b,Lr as x,Lt as S,Nr as C,O as w,Oa as T,On as E,Qa as D,Ra as O,Rn as k,Tr as A,Tt as j,V as M,Vn as N,W as P,Xi as F,Xn as ee,Yn as te,aa as I,ar as ne,ct as re,fa as ie,ft as L,gi as ae,ir as R,ji as z,ki as oe,kt as B,nr as se,ot as ce,q as le,qn as ue,sa as de,so as fe,t as pe,tn as me,tr as he,ur as V,vi as ge,wn as _e,ya as ve,yi as ye,yn as be,yt as xe,z as Se,zr as Ce}from"./player-overlays-hLBmOC8C.js";import{Ar as we,Ba as Te,Cr as H,Ds as Ee,Fr as De,Ga as Oe,Ha as ke,Hs as Ae,Ia as je,Ja as Me,Kc as Ne,Ls as Pe,Ns as Fe,Qs as U,Ra as Ie,Sr as Le,Un as Re,Us as W,Va as ze,Wa as Be,Ws as Ve,Xa as He,Xn as Ue,Xs as We,Ya as Ge,Yc as Ke,Yn as qe,Yr as Je,Zs as G,_c as Ye,_n as Xe,ar as Ze,bo as Qe,er as $e,fn as et,gn as tt,gr as nt,ha as rt,hn as it,hr as at,i as ot,ir as st,ja as ct,lr as lt,mn as ut,mo as dt,mr as ft,na as pt,or as mt,pn as ht,rr as gt,sr as _t,tl as vt,uo as yt,vn as bt,wr as xt,xa as St,y as Ct,yn as wt,yo as Tt}from"./client-D93RkunP.js";import{I as Et,j as Dt,y as Ot}from"./__vite-browser-external-DIbVKiho.js";import{_ as kt,t as At}from"./terminal-DZ5OZpgC.js";import{n as jt}from"./divide-Bmm9r7CP.js";import{t as Mt}from"./circle-slash-Duh934sZ.js";import{a as Nt,i as Pt,n as Ft,r as It,t as Lt}from"./scan-eye-C862nWtV.js";import{r as Rt}from"./shapes-D4IRNSXI.js";import{t as zt}from"./file-up-2YD_M6f_.js";import{t as Bt}from"./layers-BH9u1mrE.js";import{$a as Vt,$d as Ht,$r as Ut,$s as Wt,A as Gt,Aa as K,An as Kt,Ap as qt,Ar as Jt,At as Yt,B as Xt,Bd as Zt,Br as Qt,Bt as $t,C as en,Ct as tn,Dp as nn,Dt as rn,Ep as an,Et as on,Eu as sn,Ft as cn,Fu as ln,Gi as un,Gl as dn,Gp as fn,Gs as pn,Hi as mn,Ia as hn,Id as gn,In as _n,Iu as vn,J as yn,Ja as bn,Ji as xn,Jp as Sn,Jr as Cn,Js as wn,K as Tn,Ka as En,Ki as Dn,Kn as On,Kt as kn,La as An,Ld as jn,Ln as Mn,Lr as Nn,Ls as Pn,Mc as Fn,Mp as In,Ms as Ln,Mt as Rn,Nc as zn,Nt as Bn,Oa as q,Oc as Vn,Op as J,Ot as Hn,Pn as Un,Po as Wn,Pp as Gn,Pu as Kn,Qc as qn,Qd as Jn,Qp as Yn,Qs as Xn,Ra as Zn,Rd as Qn,Ru as $n,Sr as er,Ss as tr,Tc as nr,Tp as rr,U as ir,Ua as ar,Uf as or,Up as sr,Ur as cr,Uu as lr,Vt as ur,W as dr,Wi as fr,Wl as pr,Wp as mr,Ws as hr,X as gr,Xa as _r,Xc as vr,Xd as yr,Xi as br,Xs as xr,Xt as Sr,Y as Cr,Ya as wr,Yi as Tr,Yn as Er,Yp as Dr,Ys as Or,Yu as kr,Zc as Ar,Zi as jr,Zp as Mr,Zs as Nr,_a as Pr,_s as Fr,a as Ir,ac as Lr,ad as Rr,bi as zr,bs as Br,cc as Vr,cd as Hr,cs as Ur,cu as Wr,d as Gr,dc as Kr,di as qr,ds as Jr,dt as Y,ea as Yr,ec as Xr,ef as Zr,fa as Qr,fi as $r,ft as ei,g as ti,gi as ni,gl as ri,hi as ii,hl as ai,is as oi,jp as si,jt as ci,kp as li,kr as ui,kt as di,ld as fi,lu as pi,mi,nu as hi,o as gi,oa as _i,od as vi,pi as yi,ps as bi,q as xi,qi as Si,qp as Ci,rn as wi,rt as Ti,sd as Ei,sn as Di,ss as Oi,ti as ki,tn as Ai,ua as ji,ui as Mi,ul as Ni,vo as Pi,w as Fi,wp as Ii,wt as Li,xd as Ri,xi as zi,xs as Bi,xt as Vi,yp as X,za as Hi,zd as Ui,zr as Wi}from"./src-CR4MjS0h.js";import{t as Z}from"./i18n-ILINfI4k.js";import{t as Q}from"./useTranslation-BJr-n0es.js";import{B as Gi,Ci as Ki,D as qi,E as Ji,H as Yi,I as Xi,M as Zi,N as Qi,O as $i,P as ea,Q as ta,R as na,Si as ra,T as ia,U as aa,V as oa,Z as sa,_i as ca,k as la,q as ua,ut as da,vi as fa,vt as pa,w as ma,xi as ha}from"./index-BZLBXpx-.js";import{t as ga}from"./authed-media-BTPD9Rqy.js";import{a as _a,i as va,n as ya,r as ba,t as xa}from"./PanelContent-CVkHXftN.js";import{n as Sa,t as Ca}from"./format-Dzip80Uj.js";import{$ as wa,A as Ta,B as Ea,C as Da,D as Oa,Dt as ka,E as Aa,Et as ja,F as Ma,G as Na,H as Pa,I as Fa,J as Ia,K as La,L as Ra,M as za,N as Ba,O as Va,Ot as Ha,P as Ua,Q as Wa,R as Ga,S as Ka,Tt as qa,U as Ja,V as Ya,W as Xa,X as Za,Y as Qa,Z as $a,_t as eo,at as to,bt as no,ct as ro,d as io,dt as ao,et as oo,f as so,ft as co,g as lo,gt as uo,h as fo,ht as po,it as mo,j as ho,k as go,kt as _o,l as vo,lt as yo,m as bo,mt as xo,nt as So,ot as Co,p as wo,pt as To,q as Eo,rt as Do,s as Oo,st as ko,t as Ao,tt as $,u as jo,ut as Mo,v as No,vt as Po,wt as Fo,x as Io,y as Lo,yt as Ro,z as zo}from"./CompositionBlockEditor-DmYv5ln7.js";import{a as Bo,f as Vo,l as Ho,s as Uo,t as Wo}from"./TemplateEditorDialog-eOBMrmCP.js";import{t as Go}from"./assignment-candidates-BJPEmgFZ.js";import"./useEventInvalidation-Bbj8t_iL.js";import{h as Ko,i as qo,m as Jo,o as Yo,t as Xo,v as Zo}from"./step-inspector-model-kpUIIlrE.js";import{a as Qo}from"./notification-rule-status-BWxeQ-_D.js";import{a as $o,c as es,i as ts,l as ns,n as rs,o as is,r as as,s as os,t as ss,u as cs}from"./linked-devices-model-ChJFxnJQ.js";c();function ls(e){if(typeof e!=`object`||!e)return null;let t=e,n=t.id,r=t.label;if(typeof n!=`string`||typeof r!=`string`)return null;let i=t.available===!0,a=t.enabled,o=t.unavailableReason;return{id:n,label:r,costWhenOff:typeof t.costWhenOff==`string`?t.costWhenOff:``,on:i&&typeof a==`boolean`?a:null,available:i,unavailableReason:typeof o==`string`?o:null}}function us(e){if(typeof e!=`object`||!e)return null;let t=e.switches;if(!Array.isArray(t))return null;let n=t.map(ls).filter(e=>e!==null);return n.length===0?null:n}var ds=[[/privacy|mask/i,`privacy`],[/microphone|mic\b/i,`microphone`],[/speaker|broker audio|stream audio/i,`speaker`],[/audio/i,`listening`],[/object|detect/i,`detection`],[/event/i,`archive`],[/record/i,`recording`],[/notif/i,`notifications`],[/stream|broker/i,`stream`]];function fs(e){for(let[t,n]of ds)if(t.test(e))return n;return`generic`}function ps(e){let t=e.filter(e=>e.on===!1).map(e=>e.id),n=e.filter(e=>e.on===null).map(e=>e.id),r=t=>t.map(t=>e.find(e=>e.id===t)?.label??t).join(`, `),i=[];return t.length>0&&i.push(Z.t(`helpers.cameraSwitchRows.off`,{list:r(t)})),n.length>0&&i.push(Z.t(`helpers.cameraSwitchRows.unknown`,{list:r(n)})),{offIds:t,unknownIds:n,summary:i.length===0?Z.t(`helpers.cameraSwitchRows.allOn`):i.join(` · `)}}var ms={stream:ee,detection:Lt,privacy:ge,microphone:m,speaker:S,listening:Pt,archive:kt,recording:Nt,notifications:h,generic:_e};function hs({deviceId:t}){let{t:n}=Q(),a=l(),s=Number.isFinite(t),[c,u]=o(null),[d,f]=o(!1),p=$n({deviceId:t},{enabled:s});Ir([`pipelineOrchestrator`,`getCameraSwitches`],[`capability.binding-changed`]);let m=us(p.data),h=fi({onError:(e,n)=>{console.error(`[CameraFunctionSwitches] switch write failed — reverting`,{tags:{deviceId:t},meta:{switchId:n.switchId,error:e instanceof Error?e.message:String(e)}}),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSwitches`]]}),u({id:n.switchId,message:e instanceof Error?e.message:String(e)})},onSuccess:()=>{u(null),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),a.invalidateQueries({queryKey:[[`deviceManager`]]}),a.invalidateQueries({queryKey:[[`recording`]]})}}),g=r(e=>{!e.available||e.on===null||h.mutate({deviceId:t,switchId:e.id,enabled:!e.on})},[t,h]);if(m===null)return null;let _=ps(m),v=e=>c?.id===e.id?c.message:null;return e(qt,{open:d,onOpenChange:f,children:[e(In,{"aria-label":n(`device.cameraFunctionSwitches.cameraFunctions`,`Camera functions`),title:_.summary,className:`inline-flex items-center gap-1 rounded-lg border px-2 py-1.5 text-[11px] font-medium transition-colors ${c===null?_.offIds.length>0?`border-warning/40 text-warning hover:bg-warning/10`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`:`border-danger/50 text-danger bg-danger/5`}`,children:[i(_e,{className:`h-3.5 w-3.5`}),i(`span`,{className:`hidden lg:inline`,children:n(`device.cameraFunctionSwitches.functions`,`Functions`)}),_.offIds.length>0&&i(`span`,{className:`rounded bg-warning/20 px-1 text-[9px] font-semibold uppercase tracking-wide`,children:n(`device.cameraFunctionSwitches.offCount`,{count:_.offIds.length})})]}),e(si,{align:`end`,className:`min-w-[240px] max-h-[60vh] overflow-y-auto p-1`,children:[i(`div`,{className:`px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle`,children:n(`device.cameraFunctionSwitches.cameraFunctions`,`Camera functions`)}),i(`ul`,{className:`space-y-0.5`,children:m.map(e=>i(`li`,{children:i(gs,{row:e,failure:v(e),onToggle:()=>g(e)})},e.id))})]})]})}function gs({row:t,failure:n,onToggle:r}){let{t:a}=Q(),o=ms[fs(t.label)],s=t.on===null,c=t.on===!1,l=n===null?s?t.unavailableReason??`The source that owns this did not answer.`:t.costWhenOff:`Write failed: ${n}`,u=n===null?s?t.unavailableReason??`unknown`:null:`write failed`;return e(X,{variant:`unstyled`,type:`button`,role:`switch`,"aria-label":t.label,"aria-checked":t.on===!0,disabled:!t.available,onClick:r,title:l,className:`flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-[12px] text-foreground transition-colors hover:bg-surface-hover disabled:opacity-40 disabled:cursor-not-allowed`,children:[i(o,{className:`h-3.5 w-3.5 shrink-0 ${n===null?s?`text-foreground-subtle/50`:c?`text-warning`:`text-success`:`text-danger`}`}),e(`span`,{className:`flex-1 min-w-0 truncate`,children:[t.label,u!==null&&e(`span`,{className:`ml-1 text-[10px] text-foreground-subtle`,children:[`· `,u]})]}),i(`span`,{className:`shrink-0 rounded px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide ${s?`bg-surface-hover text-foreground-subtle/60`:c?`bg-warning/20 text-warning`:`bg-success/20 text-success`}`,children:s?`—`:a(c?`common.off`:`common.on`)})]})}function _s({parentDeviceId:t}){let{t:n}=Q(),r=ha(),a=xe(),{data:o,isLoading:s,isError:c}=oa(t),{data:l}=wn({deviceId:t},{enabled:Number.isFinite(t)});if(s)return i(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:i(`p`,{className:`text-[10px] text-foreground-subtle`,children:n(`common.loading`,{defaultValue:`Loading…`})})});if(c)return i(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:i(`p`,{className:`text-[10px] text-warning`,children:n(`integrations.childrenLoadError`,{defaultValue:`Failed to load children`})})});let d=(o??[]).filter(e=>e.display?.hidden!==!0);if(d.length===0)return null;let f=Hn(l?.stableId??``,d,l?.childLayout),p=f.ungrouped,m=e=>r(`/devices/${String(e)}`),h=l?.name??``,g=(e,t)=>i(on,{trpc:a.trpcClient,device:{...t,name:Rn(t,h)},nameForm:`nested`,...l?{parent:{id:l.id,name:l.name,type:l.type}}:{},variant:`minimal`,onNavigate:m},e),_=Bn({type:l?.type??``,stableId:l?.stableId??``,linkDeviceId:l?.linkDeviceId,primaryChildEntityId:l?.primaryChildEntityId,primaryChildPreference:l?.primaryChildPreference},p),v=_.accessories.length>0,y=_.adopted.length>0,b=_.parts.length>0||_.primary.length>0,x=_.primary.length>0&&_.parts.length>0&&!y&&!v,S=x?``:y&&!v&&!b?n(`device.adoptedDevices`,{defaultValue:`Adopted devices`}):v&&!y&&!b?n(`device.accessories`,{defaultValue:`Accessories`}):_.primary.length>0&&_.parts.length===0&&!y&&!v?n(`device.primary`,{defaultValue:`Primary`}):b&&!y&&!v?n(`device.parts`,{defaultValue:`Parts`}):n(`device.children`,{defaultValue:`Children`}),C=p.length>0?i(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:x?e(`div`,{className:`space-y-2`,children:[e(`div`,{children:[i(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5`,children:n(`device.primary`,{defaultValue:`Primary`})}),i(`div`,{className:`space-y-1`,children:_.primary.map(e=>g(e.id,e))})]}),e(`div`,{children:[i(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5`,children:n(`device.parts`,{defaultValue:`Parts`})}),i(`div`,{className:`space-y-1`,children:_.parts.map(e=>g(e.id,e))})]})]}):e(u,{children:[S.length>0&&i(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5`,children:S}),i(`div`,{className:`space-y-1`,children:p.map(e=>g(e.id,e))})]})}):null,w=f.disabledSection===void 0?null:i(rn,{title:n(`device.disabledSection`,{defaultValue:`Disabled`}),count:f.disabledSection.children.length,defaultOpen:!1,children:i(`div`,{className:`opacity-60 space-y-1`,children:f.disabledSection.children.map(e=>g(e.id,e))})},f.disabledSection.title);if(f.sections.length===0)return w===null?C:e(`div`,{className:`space-y-2`,children:[C,w]});let T=y&&!v&&!b;return e(`div`,{className:`space-y-2`,children:[T?C:null,f.sections.map(e=>i(rn,{title:e.title,count:e.children.length,defaultOpen:e.defaultOpen,children:e.children.map(e=>g(e.id,e))},e.title)),T?null:C,w]})}function vs({initialName:e,label:t=`Name`,layout:n=`inline`,bound:r}){return i(aa,{label:t,layout:n,value:i(nn,{type:`text`,value:r.value,"aria-label":t,placeholder:e,onChange:e=>r.onChange(e.target.value),className:`flex-1 min-w-0 w-full px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`})})}c();function ys({label:t=`Location`,layout:r=`inline`,bound:a}){let{t:o}=Q(),{data:s}=Lr(),c=s??[],l=a.value.trim().toLowerCase(),u=n(()=>l.length===0?[]:c.filter(e=>e.toLowerCase()!==l&&e.toLowerCase().includes(l)),[c,l]);return i(aa,{label:t,layout:r,value:e(`div`,{className:`relative`,children:[i(nn,{type:`text`,value:a.value,"aria-label":t,onChange:e=>a.onChange(e.target.value),placeholder:o(`shared.locationRow.roomAreaOrLeaveEmpty`,`Room / area (or leave empty to clear)`),className:`flex-1 min-w-0 w-full px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),u.length>0&&i(`div`,{className:`absolute z-10 left-0 right-0 mt-0.5 max-h-40 overflow-y-auto rounded-md border border-border bg-surface shadow-md`,children:u.map(t=>e(`button`,{type:`button`,onClick:()=>a.onChange(t),className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover`,children:[i(C,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),i(`span`,{className:`truncate`,children:t})]},t))})]})})}var bs=`w-full min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary disabled:opacity-50 disabled:cursor-not-allowed`,xs=0,Ss=10;function Cs(e){if(e.trim()===``)return``;let t=Number.parseInt(e,10);return Number.isFinite(t)?String(t<xs?xs:t>Ss?Ss:t):``}function ws({value:e,onChange:t,disabled:n=!1,placeholder:r,className:a,id:o,"aria-label":s}){return i(nn,{type:`number`,min:xs,max:Ss,step:1,id:o,className:a??bs,"aria-label":s,placeholder:r,value:e,onChange:e=>{t(Cs(e.target.value))},disabled:n})}function Ts({deviceName:t,value:n,inheritedIcon:r,inheritedLabel:a,disabled:o,onChange:s}){let{t:c}=Q(),l={trigger:c(`deviceDisplay.pickIcon`,{name:t}),panel:c(`deviceDisplay.iconFor`,{name:t}),searchPlaceholder:c(`deviceDisplay.iconSearchPlaceholder`),clear:a,noMatches:c(`deviceDisplay.iconNoMatches`)};return e(`div`,{className:`flex items-center gap-2`,children:[i(li,{value:n===``?null:n,onPick:e=>s(e??``),categoryLabel:e=>c(`deviceDisplay.iconCategory.${e}`,{defaultValue:Ye(e)}),fallbackGlyph:r,labels:l,disabled:o}),i(`span`,{className:`text-[11px] text-foreground-subtle`,children:n===``?a:n})]})}var Es=`w-full min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary disabled:opacity-50`;function Ds(e){if(e.trim()===``)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function Os({device:t,role:n,display:r,onChange:a}){let o=fe();fn();let{t:s}=Q(),c=l(),d=n===null?void 0:kn[n],f=d?.kind===`numeric`,p=n!==null||t.parentDeviceId!==null&&t.parentDeviceId!==void 0,m=t.sourceInfo?.quantity,h=d?.kind===`numeric`?d.quantity??(m!==void 0&&m!==`device`?m:void 0):void 0,g=h===void 0?void 0:Ne(h),_=g===void 0?void 0:Ee(g),{data:v}=xr({},{staleTime:6e4,enabled:n!==null}),y=nr({onSuccess:()=>{c.invalidateQueries({queryKey:[[`deviceManager`]]})}}),b=()=>{if(n===null)return;let e=Ds(r.precision),t={...r.icon===``?{}:{icon:r.icon},...r.unit===``?{}:{unit:r.unit},...e===void 0?{}:{precision:e}};y.mutate({defaults:{...v?.defaults,[n]:t}})},x=n===null?void 0:v?.defaults?.[n]?.icon,S=x===void 0?void 0:sr(x),C=n===null?Dr(t.type,o):Sn(n,o),w={icon:S??Ci(t.type,n),label:S===void 0?C.label:String(x)},T=n===null&&t.type===U.Container?s(`deviceDisplay.inheritedContainer`):S===void 0?s(`deviceDisplay.inherited`,{name:w.label}):s(`deviceDisplay.inheritedRoleDefault`,{icon:w.label,role:C.label}),E=n===null?``:Sn(n,o).label;return e(`div`,{className:`mt-3 divide-y divide-border border-t border-border`,children:[i(aa,{label:s(`deviceDisplay.icon`),value:i(Ts,{deviceName:t.name,value:r.icon,inheritedIcon:w.icon,inheritedLabel:T,disabled:!1,onChange:e=>a({icon:e})})}),p&&i(aa,{label:s(`deviceDisplay.label`),value:i(nn,{type:`text`,className:Es,"aria-label":s(`deviceDisplay.label`),placeholder:n===null?t.name:E,value:r.label,onChange:e=>a({label:e.target.value})})}),f&&e(u,{children:[i(aa,{label:s(`deviceDisplay.unit`),value:i(Gt,{dimension:_,value:r.unit,onChange:e=>a({unit:e}),disabled:!1,"aria-label":s(`deviceDisplay.unit`),inheritLabel:s(`deviceDisplay.unitSource`,{unit:g===void 0?``:` (${g})`}),emptyReason:s(`deviceDisplay.unitSource`,{unit:``})})}),i(aa,{label:s(`deviceDisplay.precision`),value:i(ws,{"aria-label":s(`deviceDisplay.precision`),placeholder:s(`deviceDisplay.precisionInherit`),value:r.precision,onChange:e=>a({precision:e}),disabled:!1})})]}),n!==null&&i(`div`,{className:`px-3 sm:px-4 py-2`,children:i(X,{type:`button`,variant:`outline`,size:`sm`,onClick:b,disabled:y.isPending,title:s(`deviceDisplay.setRoleDefaultTitle`,{role:E}),children:s(`deviceDisplay.setRoleDefault`,{role:E})})})]})}var ks=new Set(Object.values(G));function As(e){return ks.has(e)}var js={[U.Switch]:[G.Siren,G.Floodlight,G.Spotlight,G.PirSensor,G.Chime,G.Autotrack,G.Nightvision,G.PrivacyMask,G.BinaryHelper,G.SwitchHeater,G.SwitchFan,G.SwitchLight],[U.Climate]:[G.ClimateThermostat,G.ClimateAc,G.ClimateFloor,G.ClimateRadiator,G.ClimateHeater,G.ClimateHeatPumpCircuit],[U.Light]:[G.Floodlight,G.Spotlight,G.Nightvision],[U.Siren]:[G.Siren],[U.Button]:[G.Doorbell],[U.Cover]:[G.CoverBlind,G.CoverShutter,G.CoverAwning,G.CoverCurtain,G.CoverGarage,G.CoverGate,G.CoverDoor,G.CoverWindow],[U.Sensor]:[G.MotionSensor,G.ContactSensor,G.LeakSensor,G.SmokeSensor,G.COSensor,G.GasSensor,G.TamperSensor,G.VibrationSensor,G.ConnectivitySensor,G.SoundSensor,G.BinarySensor,G.TemperatureSensor,G.HumiditySensor,G.AmbientLightSensor,G.PressureSensor,G.WindSensor,G.RainSensor,G.UvSensor,G.SolarRadiationSensor,G.SoilMoistureSensor,G.PowerSensor,G.EnergySensor,G.VoltageSensor,G.CurrentSensor,G.AirQualitySensor,G.BatterySensor,G.NumericSensor,G.EnumSensor,G.DateTimeSensor,G.GenericSensor],[U.Control]:[G.NumericControl,G.SelectControl,G.TextControl,G.DateTimeControl],[U.Notifier]:[G.MobilePushNotifier,G.MessagingNotifier,G.EmailNotifier,G.GenericNotifier],[U.Workload]:[...De]};function Ms(e){for(let t of Object.values(U))if(t===e)return!0;return!1}function Ns(e){return Ms(e)?js[e]??[]:[]}function Ps(e,t){let n=Ns(t);return e==null||e===``||n.includes(e)?n:[...n,e]}function Fs({device:t}){let{t:n}=Q(),r=fe(),a=Qi(),o=Li(),s=a?.identity??null,c=s?.name??t.name,l=s?.location??t.location??``,u=s?.role??t.role??null,p=s?.tags??t.tags??[],m=s?.display.hidden??t.display?.hidden===!0,h=a!==null&&s!==null;return e(`section`,{"aria-label":n(`customize.identity.title`),className:`${w} ${f}`,children:[e(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[h?i(vs,{deviceId:t.id,initialName:c,label:n(`customize.identity.name`),layout:`stacked`,bound:{value:c,onChange:a.setIdentityName}}):i(aa,{label:n(`customize.identity.name`),layout:`stacked`,value:c}),h?i(ys,{deviceId:t.id,initialLocation:l,label:n(`customize.identity.room`),layout:`stacked`,bound:{value:l,onChange:a.setIdentityLocation}}):i(aa,{label:n(`customize.identity.room`),layout:`stacked`,value:l===``?n(`common.unset`):l}),i(aa,{label:n(`common.tags`,`Tags`),layout:`stacked`,value:h?i(ti,{value:p,onChange:a.setIdentityTags,label:n(`common.tags`,`Tags`)}):p.length>0?i(di,{tags:p,entries:o.entries}):n(`common.unset`)}),i(aa,{label:n(`customize.identity.type`),layout:`stacked`,value:t.type}),i(aa,{label:n(`customize.identity.hidden`),layout:`stacked`,value:i(d,{"aria-label":n(`deviceDisplay.hideFromLists`),checked:m,disabled:!h,onChange:e=>a?.setIdentityDisplay({hidden:e.target.checked})})}),i(aa,{label:n(`customize.identity.role`),layout:`stacked`,value:h?i(L,{"aria-label":n(`customize.identity.role`),value:u??``,options:[{value:``,label:n(`customize.identity.noRole`)},...Ps(u,t.type).map(e=>({value:e,label:Is(e,n(`customize.identity.noRole`),r)}))],onChange:e=>a.setIdentityRole(e.target.value===``?null:e.target.value)}):i(`span`,{children:Is(u,n(`customize.identity.noRole`),r)})})]}),s!==null&&a!==null&&i(Os,{device:t,role:u,display:s.display,onChange:a.setIdentityDisplay})]})}function Is(e,t,n){return e==null||e===``?t:As(e)?Sn(e,n).label:e}var Ls=`running-state`,Rs=`running`;function zs(e){return{...e,features:e.features.filter(e=>e.cap!==Ls)}}function Bs(e,t){return e===Ls&&t===Rs}function Vs(e){if(e===null||!ft(zs(e)))return{offered:!1};let t=Eo(e,Ls);return t===null?{offered:!0,following:!0,discardsRule:!1}:{offered:!0,following:!1,discardsRule:!at(t)}}function Hs(e,t){return t?$a(e,Ls):{...zs(e),features:[...zs(e).features,nt()]}}function Us(e,t,n){return Bs(e,t)&&Vs(n).offered}var Ws=`Assigned · `;function Gs(e,t){if(e===`Native`)return{kind:`native`};if(e===`Native · source missing`)return{kind:`released`};if(e===`pending`)return{kind:`pending`};if(e===`unknown`)return{kind:`unknown`};if(e.startsWith(Ws)){let n=e.slice(11);return{kind:`assigned`,source:t??n}}return{kind:`unknown`}}var Ks={id:0,name:``,type:`unknown`,stableId:``,parentDeviceId:null};function qs(e,t){return e.state.kind===`pending`?{kind:`pending`}:e.state.kind===`unknown`||e.state.kind===`not-loaded`?{kind:`unknown`,reason:e.state.reason}:{kind:`known`,value:t}}function Js(e,t,n){let r=Eo($(e.state),t);return at(r)?null:st(r,t,n)}function Ys(e,t,n){return e?t===`pending`?`pending`:t===`unknown`?`unknown`:n?`present`:`absent`:`present`}function Xs(e,t,n,r){let i=e(`customize.scalar.caps.${n}`);if(gt(n)<=1)return i;let a=r.path??r.id,o=qa(n,a,t);if(o!==a)return`${i} · ${o}`;let s=`customize.scalar.targets.${n}.${r.id}`,c=e(s);return`${i} · ${c===s?a:c}`}function Zs(e,t,n,r){let{t:i,i18n:a}=Q(),o=La(),s=r.path??r.id,c=Xs(i,a.language,n,r),l=$(t.state),u=Eo(l,n),d=qs(t,Js(t,n,r.id)),f=d.kind===`known`&&d.value!==null?$e({feature:d.value,device:t.target,cap:n,targetId:r.id}):null,p=f!==null,m=Do(p),h=f===null||m.kind!==`known`?null:m.value.find(e=>yt({addonId:e.addonId,stableId:e.stableId})===yt(f.draft.source))??null,g=An(h===null?Ks:ro(h),`compact`),_=h===null?null:g,v=An(e,`full`),y=Ys(p,m.kind,h!==null),b=bt({cap:n,targetId:r.id,device:t.target,stored:d,sourcePresence:y,sourceUnknownReason:m.kind===`unknown`?m.reason:null}),x=async e=>{let n=await t.save(e);return n.kind===`refused`?n.reason:null},S=async()=>{if(l===null)return null;let e=Wa(l,n,r.id);return await o(i(`customize.scalar.removeWhat`,{name:_??(f===null?v:yt(f.draft.source))}),e===null)?x(e):null},C=f===null?null:{source:{addonId:f.draft.source.addonId,stableId:f.draft.source.stableId,cap:f.draft.source.cap,fieldPath:f.draft.source.fieldPath,valueKind:f.sourceValueKind,sourceUnit:f.sourceUnit,changedAtField:f.changedAtField},transform:f.draft.transform};return{title:c,path:s,stored:d,recognized:p,otherFormula:!p&&d.kind===`known`&&d.value!==null,presence:y,released:b.status.state===`released`,badge:Gs(b.text,_),sourceName:_,sourceCap:f?.draft.source.cap??``,sourcePath:f?.draft.source.fieldPath??``,sourceField:f===null?``:qa(f.draft.source.cap,f.draft.source.fieldPath,a.language),sourceDeviceId:h?.id??null,seed:C,answered:t.state.kind===`none`||t.state.kind===`present`,saving:t.saving,saveFeature:e=>x(Za(l,t.target,e,n,r.id)),remove:S,linkStamp:u?.contributedBy?.linkId??null,enabled:u?.enabled!==!1,setEnabled:async e=>u===null?null:x(Qa(l,t.target,{...u,enabled:e}))}}var Qs=Ie,$s=[`power`,`readings`,`oscillation-axes`,`events`,`lists`,`extensions`],ec=new Set([`power-meter`,`power-source`,`battery`]),tc={scalar:`scalar`,keyedArray:`keyed`,event:`event`,config:`config`};function nc(e,t,n){if(n.section!==void 0)return n.section;if(ec.has(e))return`power`;switch(t){case`scalar`:return`readings`;case`event`:return`events`;case`keyed`:return`lists`;case`config`:return`extensions`}}function rc(e){let t=[];for(let[n,r]of Object.entries(Qs))for(let i of r.targets){let r=tc[i.cardinality];i.deviceTypes.includes(e)&&t.push({key:`${n}.${i.id}`,cap:n,kind:r,section:nc(n,r,i),target:i})}return t.toSorted((e,t)=>$s.indexOf(e.section)-$s.indexOf(t.section))}function ic(e,t,n){return e.map(e=>{if(e.kind===`config`)return{spec:e,availability:{kind:`present`,mode:`add`},linked:!0};let r=Ma(Ra(e.cap,e.target),t),i=n(e);return e.kind===`keyed`&&r.kind===`absent`&&i?{spec:e,availability:{kind:`present`,mode:`add`},linked:i}:{spec:e,availability:r,linked:i}})}function ac(e){let t=[],n=[],r=!1,i=null;for(let a of e)switch(a.availability.kind){case`absent`:break;case`pending`:r=!0;break;case`unknown`:i=a.availability.reason;break;case`present`:a.linked?t.push(a):n.push(a)}return{active:t,addable:n,pending:r,unknownReason:i}}function oc(e){return $s.filter(t=>e.some(e=>e.spec.section===t))}function sc(e){return e?.contributedBy?.linkId??null}function cc(e){return{remove:(e.recognized||e.otherFormula)&&e.linkStamp===null,linkToggle:e.linkStamp!==null}}function lc({children:e,muted:t}){return i(`span`,{className:`text-xs ${t===!0?`text-foreground-subtle`:`text-foreground`}`,children:e})}function uc(){let{t:e}=Q();return i(`span`,{role:`status`,className:`text-xs text-foreground-subtle`,children:e(`customize.event.checking`)})}function dc({reason:e}){let{t}=Q();return i(`span`,{role:`alert`,className:`text-xs text-warning`,title:e??void 0,children:t(`customize.table.unknown`)})}function fc(e){switch(e.spec.cap){case`remote`:return i(mc,{device:e.device});case`fan-presets`:return i(gc,{device:e.device});default:return i(dc,{reason:null})}}function pc(e){switch(e.spec.cap){case`remote`:return i(hc,{device:e.device});case`fan-presets`:return i(_c,{device:e.device});default:return i(dc,{reason:null})}}function mc({device:e}){let{t}=Q(),n=yr({deviceId:e.id});if(n.status===`error`)return i(dc,{reason:n.error?.message??null});if(n.data===void 0)return i(uc,{});let r=Object.keys(n.data.bindings).length;return r===0&&n.data.layoutTemplateId==null?i(lc,{muted:!0,children:t(`customize.table.notConfigured`)}):i(lc,{children:t(`customize.table.commandsCount`,{count:r})})}function hc({device:e}){let{t}=Q(),n=yr({deviceId:e.id}),r=or({kind:`remote`});if(n.status===`error`)return i(dc,{reason:n.error?.message??null});if(n.data===void 0)return i(uc,{});let a=n.data.layoutTemplateId;if(a==null)return i(lc,{muted:!0,children:t(`remote.dialog.noTemplate`)});if(r.status===`error`)return i(dc,{reason:r.error?.message??null});let o=(r.data??[]).find(e=>e.id===a)?.name??null;return r.data===void 0?i(uc,{}):o===null?i(dc,{reason:null}):i(lc,{children:o})}function gc({device:e}){let{t}=Q(),n=Ar({deviceId:e.id});return n.status===`error`?i(dc,{reason:n.error?.message??null}):n.data===void 0?i(uc,{}):n.data.length===0?i(lc,{muted:!0,children:t(`customize.table.noPresets`)}):i(lc,{children:t(`customize.table.presetsCount`,{count:n.data.length})})}function _c({device:e}){let{t}=Q(),n=Ar({deviceId:e.id});return n.status===`error`?i(dc,{reason:n.error?.message??null}):n.data===void 0?i(uc,{}):n.data.length===0?i(lc,{muted:!0,children:t(`customize.table.noSource`)}):i(lc,{children:e.name})}function vc(e){let t=mt({draft:{kind:`pulse`,cap:e.cap,targetId:e.targetId,enabled:e.enabled,debounceMs:e.debounceMs,...e.edges===void 0?{}:{edges:[...e.edges]},sources:e.sources.map(e=>({addonId:e.addonId,stableId:e.stableId,cap:e.cap,fieldPath:e.fieldPath}))},device:e.device,changedAtFields:e.sources.map(e=>e.changedAtField)});return t.ok?t.value:null}function yc(e){let t=_t({draft:{kind:`span`,cap:e.cap,targetId:e.targetId,timeoutMs:e.timeoutMs,...e.cooldownMs===void 0?{}:{cooldownMs:e.cooldownMs},sources:e.sources.map(e=>({addonId:e.addonId,stableId:e.stableId,cap:e.cap,fieldPath:e.fieldPath,mode:e.mode}))},device:e.device});return t.ok?t.value:null}function bc(e,t){return{deviceId:e,config:t.config}}function xc(e,t){return{deviceId:e,patch:{motionCooldownMs:t}}}async function Sc(e,t,n,r){await n(bc(e,t)),await r(xc(e,t.timeoutMs))}c();function Cc(t){let{t:n}=Q(),r=t.mode===`change`?n(`customize.scalar.changeTitle`,{title:t.title}):n(`customize.scalar.addTitle`,{title:t.title});return i(fr,{open:t.open,onOpenChange:e=>!e&&t.onClose(),children:e(Dn,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":r,children:[i(Tr,{children:i(br,{children:r})}),t.open?i(wc,{...t}):null]})})}function wc(t){let{t:r}=Q(),a=Xn({projection:`slim`}),s=ko(n(()=>a.status===`success`?_o(a.data):[],[a.status,a.data]),t.sources[0]),[c,l]=o(()=>Tc(t.sources)),[d,f]=o(null),[p,m]=o(!1);!p&&s!==null&&(f(s),m(!0));let[h,g]=o(t.edge),[_,v]=o(t.debounceMs/1e3),y=Ec(c),b=y.length===0?null:vc({cap:t.cap,targetId:t.targetId,device:t.target,enabled:t.enabled,debounceMs:Math.round(_*1e3),edges:[h],sources:y}),x=y[0]??null,S=zn({deviceId:c[0]?.deviceId??0}),C=Oc(S.status===`success`?S.data:void 0,x),w=tt(ut,C,Math.round(_*1e3));return e(u,{children:[e(un,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:[i(`p`,{className:`text-[11px] text-foreground-muted`,children:r(`customize.event.pulseBody`)}),i(Co,{kind:`event`,shape:`pulse`,enabled:t.open,hostId:t.host.id,devicePickerTestId:`event-pulse-picker`,destination:{cap:t.cap,targetId:t.targetId,title:t.title},device:d,picked:c,onDeviceChange:f,onPickedChange:l,edges:t.edges,edge:h,onEdgeChange:g,debounceSec:_,onDebounceSecChange:v,sourceModes:[],timeoutSec:0,onTimeoutSecChange:()=>void 0,cooldownSec:null,onCooldownSecChange:()=>void 0}),C.kind===`level`?i(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:r(Dc(C,w.lastPressedAt))}):null]}),e(xn,{className:`flex flex-wrap gap-2`,children:[i(X,{variant:`ghost`,onClick:t.onClose,children:r(`customize.scalar.cancel`)}),i(X,{"data-testid":`event-save`,disabled:!t.canSave||b===null,onClick:()=>{b!==null&&t.onSave(b)},children:r(`customize.scalar.save`)})]})]})}function Tc(e){return e.map(e=>({deviceId:0,addonId:e.addonId,stableId:e.stableId,cap:e.cap,fieldPath:e.fieldPath,deviceName:e.stableId,changedAtField:e.changedAtField}))}function Ec(e){return e.map(e=>({addonId:e.addonId,stableId:e.stableId,cap:e.cap,fieldPath:e.fieldPath,changedAtField:e.changedAtField??Pe[e.cap]??`lastChangedAt`}))}function Dc(e,t){return e.kind===`unread`?`customize.event.previewWaiting`:e.active&&t===null?`customize.event.previewAlreadyOn`:t===null?`customize.event.previewQuiet`:`customize.event.previewCounted`}function Oc(e,t){if(e===void 0||t===null)return{kind:`unread`};let n=e[t.cap],r=n===void 0?void 0:Ha(n,t.fieldPath),i=Pe[t.cap]??t.changedAtField,a=n===void 0?void 0:Ha(n,i);return typeof r==`boolean`?{kind:`level`,active:r,changedAt:typeof a==`number`&&Number.isFinite(a)?a:null}:{kind:`unread`}}function kc(e,t,n){if(e===`pending`)return{kind:`pending`,seconds:null};if(e===`unknown`||e==null)return{kind:`unknown`,seconds:null};if(!e)return{kind:`quiet`,seconds:null};let r=Ac(t,n);return r===null?{kind:`unknown`,seconds:null}:{kind:`active`,seconds:r}}function Ac(e,t){if(e==null||!Number.isFinite(e)||e<Ca)return null;let n=Math.floor((t-e)/1e3);return n<0?0:n}function jc(e,t){if(e===`pending`)return{kind:`pending`,lastPressedAt:null,pressCount:null};if(e===`unknown`)return{kind:`unknown`,lastPressedAt:null,pressCount:null};let n=typeof e==`number`&&Number.isFinite(e)&&e>=Ca?e:null,r=typeof t==`number`&&Number.isFinite(t)&&t>=0?t:null;return n===null?{kind:`none`,lastPressedAt:null,pressCount:r}:{kind:`ring`,lastPressedAt:n,pressCount:r}}c();var Mc={id:0,name:``,type:`unknown`,stableId:``,parentDeviceId:null};function Nc({device:t,handle:n,availability:r,cap:a,title:s,view:c}){let{t:l,i18n:f}=Q(),m=La(),[h,g]=o(!1),[_,v]=o(null),y=$(n.state),b=Eo(y,a),x=Fc(n,b),S=x.kind===`known`&&x.value!==null?Ze({feature:x.value,device:n.target,cap:a,targetId:c.id,timestampPath:c.timestampPath,counterPath:c.counterPath}):null,C=S!==null,w=Do(C),T=S?.draft.sources[0]??null,E=T===null||w.kind!==`known`?null:w.value.find(e=>yt({addonId:e.addonId,stableId:e.stableId})===yt(T))??null,D=Ic(C,w.kind,E!==null),O=An(E===null?Mc:ro(E),`compact`),k=An(t,`full`),A=et({cap:a,targetId:c.id,device:n.target,timestampPath:c.timestampPath,counterPath:c.counterPath,apply:c.apply,stored:x,sourcePresence:D,sourceUnknownReason:w.kind===`unknown`?w.reason:null}),j=n.state.kind===`none`||n.state.kind===`present`;if(r.kind===`absent`||!c.deviceTypes.includes(t.type))return null;let M=async e=>{let t=await n.save(e);v(t.kind===`refused`?t.reason:null)},N=Lc(S),P=S?.draft.edges?.[0],F=P!==void 0&&c.edges.includes(P)?P:c.defaultEdge,ee=T===null?``:qa(T.cap,T.fieldPath,f.language),te=x.kind===`known`&&x.value===null,I=!C&&x.kind===`known`&&x.value!==null;return e(u,{children:[i(to,{id:a,icon:p,title:s,testId:`event-card-${a}`,actions:e(u,{children:[b!==null&&e(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground`,children:[i(d,{"aria-label":l(`customize.doorbell.active`),checked:b.enabled!==!1,disabled:!j||n.saving,onChange:e=>{M(Qa(y,n.target,{...b,enabled:e.target.checked}))}}),l(`customize.doorbell.active`)]}),i(K,{children:l(Ga(A.text,A.status.state))})]}),children:i(`div`,{className:`flex flex-col gap-2 px-3 py-2 sm:px-4`,children:r.kind===`pending`||r.kind===`present`&&!j?i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:l(`customize.event.checking`)}):r.kind===`unknown`?i(q,{title:l(`customize.scalar.unreadable`),message:r.reason}):e(u,{children:[C&&T!==null&&i(`p`,{className:`text-xs text-foreground`,children:l(`customize.scalar.override`,{name:E===null?T.stableId:O,field:ee})}),C&&i(Pc,{deviceId:t.id,cap:a,timestampPath:c.timestampPath,counterPath:c.counterPath,startedAt:n.state.kind===`present`?n.state.view.block.createdAt:null}),I&&b!==null&&e(`p`,{className:`text-xs text-foreground flex flex-wrap items-center gap-1`,children:[l(`customize.doorbell.otherFormula`),i(Ua,{handle:n,cap:a,fieldPath:c.counterPath})]}),te&&i(`p`,{className:`text-xs text-foreground-subtle`,children:l(`customize.scalar.noOverride`)}),_!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger break-words`,children:_}),e(`div`,{className:`flex flex-wrap gap-2`,children:[C&&i(X,{variant:`outline`,size:`sm`,disabled:n.saving,onClick:()=>g(!0),children:l(`customize.scalar.change`)}),C&&i(X,{variant:`ghost`,size:`sm`,disabled:n.saving,onClick:()=>{if(y===null)return;let e=$a(y,a);m(l(`customize.doorbell.removeWhat`,{name:E===null?k:O}),e===null).then(t=>{t&&M(e)})},children:l(`customize.scalar.remove`)}),te&&i(X,{variant:`outline`,size:`sm`,"data-testid":`event-add-${a}`,disabled:n.saving,onClick:()=>g(!0),children:l(`customize.scalar.add`)})]})]})})}),i(Cc,{open:h,mode:C?`change`:`add`,title:s,cap:a,targetId:c.id,host:t,target:n.target,enabled:b?.enabled!==!1,debounceMs:S?.draft.debounceMs??c.debounceMs,edges:c.edges,edge:F,sources:N,canSave:j&&!n.saving,onClose:()=>g(!1),onSave:e=>{g(!1),M(Qa(y,n.target,e))}})]})}function Pc({deviceId:t,cap:n,timestampPath:r,counterPath:a,startedAt:o}){let{t:s}=Q(),c=Xa({deviceId:t,cap:n,path:r}),l=Xa({deviceId:t,cap:n,path:a}),u=jc(c.kind===`pending`?`pending`:c.kind!==`value`||typeof c.value!=`number`?`unknown`:c.value,l.kind===`value`&&typeof l.value==`number`?l.value:null);return u.kind===`pending`?i(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:s(`customize.event.checking`)}):u.kind===`unknown`?i(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:s(`customize.event.doorbellLast.unknown`)}):u.kind===`none`?e(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:[s(`customize.event.doorbellLast.none`,{when:o===null?``:Sa(o)}),u.pressCount===null?``:` · ${s(`customize.event.doorbellCount`,{count:u.pressCount})}`]}):e(`p`,{role:`status`,className:`text-[11px] text-foreground`,children:[s(`customize.event.doorbellLast.ring`,{when:Sa(u.lastPressedAt)}),u.pressCount===null?``:` · ${s(`customize.event.doorbellCount`,{count:u.pressCount})}`]})}function Fc(e,t){return e.state.kind===`pending`?{kind:`pending`}:e.state.kind===`unknown`||e.state.kind===`not-loaded`?{kind:`unknown`,reason:e.state.reason}:{kind:`known`,value:t}}function Ic(e,t,n){return e?t===`pending`?`pending`:t===`unknown`?`unknown`:n?`present`:`absent`:`present`}function Lc(e){return e===null?[]:e.draft.sources.map((t,n)=>({addonId:t.addonId,stableId:t.stableId,cap:t.cap,fieldPath:t.fieldPath,changedAtField:e.changedAtFields[n]??``}))}c();function Rc(t){let{t:n}=Q(),r=t.mode===`change`?n(`customize.scalar.changeTitle`,{title:t.title}):n(`customize.scalar.addTitle`,{title:t.title});return i(fr,{open:t.open,onOpenChange:e=>!e&&t.onClose(),children:e(Dn,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":r,children:[i(Tr,{children:i(br,{children:r})}),t.open?i(zc,{...t}):null]})})}function zc(t){let{t:r}=Q(),a=Xn({projection:`slim`}),s=ko(n(()=>a.status===`success`?_o(a.data):[],[a.status,a.data]),t.sources[0]),[c,l]=o(()=>Bc(t.sources)),[d,f]=o(null),[p,m]=o(!1);!p&&s!==null&&(f(s),m(!0));let[h,g]=o(t.timeoutMs/1e3),[_,v]=o((t.cooldownMs??0)/1e3),y=Vc(c),b=yc({cap:t.cap,targetId:t.targetId,device:t.target,timeoutMs:Math.round(h*1e3),cooldownMs:t.cooldownMs===null?void 0:Math.round(_*1e3),sources:y}),x=c[0];return e(u,{children:[e(un,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:[i(`p`,{className:`text-[11px] text-foreground-muted`,children:r(`customize.event.spanBody`)}),i(Co,{kind:`event`,shape:`span`,enabled:t.open,hostId:t.host.id,devicePickerTestId:`event-span-picker`,destination:{cap:t.cap,targetId:t.targetId,title:t.title},device:d,picked:c,onDeviceChange:f,onPickedChange:e=>l(e.filter(e=>!(e.addonId===t.host.addonId&&e.stableId===t.host.stableId))),edges:[],edge:`rising`,onEdgeChange:()=>void 0,debounceSec:0,onDebounceSecChange:()=>void 0,sourceModes:t.sourceModes,timeoutSec:h,onTimeoutSecChange:g,cooldownSec:t.cooldownMs===null?null:_,onCooldownSecChange:v}),x!==void 0&&i(Hc,{deviceId:x.deviceId,cap:x.cap,fieldPath:x.fieldPath,timeoutMs:Math.round(h*1e3)})]}),e(xn,{className:`flex flex-wrap gap-2`,children:[i(X,{variant:`ghost`,onClick:t.onClose,children:r(`customize.scalar.cancel`)}),i(X,{"data-testid":`event-save`,disabled:!t.canSave||b===null,onClick:()=>{b!==null&&t.onSave(b)},children:r(`customize.scalar.save`)})]})]})}function Bc(e){return e.map(e=>({deviceId:0,addonId:e.addonId,stableId:e.stableId,cap:e.cap,fieldPath:e.fieldPath,deviceName:e.label.length>0?e.label:e.stableId,mode:e.mode}))}function Vc(e){return e.map(e=>({addonId:e.addonId,stableId:e.stableId,cap:e.cap,fieldPath:e.fieldPath,mode:e.mode??`in-addition`,label:e.deviceName}))}function Hc({deviceId:e,cap:t,fieldPath:n,timeoutMs:r}){let{t:a}=Q(),o=Xa({deviceId:e,cap:t,path:n}),s=o.kind===`value`&&typeof o.value==`boolean`?{kind:`level`,active:o.value,changedAt:null}:{kind:`unread`},c=Xe(it,s,{timeoutMs:r,cooldownMs:0,nowMs:Date.now()});return s.kind===`unread`?null:i(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:a(Uc(s,c.open))})}function Uc(e,t){return e.kind===`unread`?`customize.event.previewWaiting`:t?`customize.event.previewMotionOn`:e.active?`customize.event.previewSensorOn`:`customize.event.previewMotionOff`}var Wc=60;function Gc(e){let t=Number.isFinite(e)?Math.max(0,Math.round(e)):0;return t<Wc?Z.t(`customize.event.durationSeconds`,{count:t}):Qo(t*1e3)}c();function Kc({device:n,availability:r,cap:a,title:s,view:c,sensors:l}){let{t:d}=Q(),f=vi(),p=sn(),m=Vt({addonId:`pipeline-orchestrator`,deviceId:n.id,nodeId:`hub`}),[h,g]=o(!1),[_,v]=o(null),y=t(!1),[b,x]=o(!1),S=Jc(l),C=Do(!0),w=ht(c.id,S),T=Qc(Zo(m.data).motionCooldownMs,c.timeoutMs);if(r.kind===`absent`||!c.deviceTypes.includes(n.type))return null;let E=b||f.isPending||p.isPending,O=w.writable&&!E&&r.kind===`present`,k=async e=>{if(!w.writable||y.current){v(d(`customize.saveInFlight`));return}y.current=!0,x(!0);try{await Sc(n.id,e,async e=>{await f.mutateAsync({deviceId:e.deviceId,config:e.config===null?null:{sensors:e.config.sensors.map(e=>({addonId:e.addonId,stableId:e.stableId,mode:e.mode}))}})},async e=>{let t={motionCooldownMs:e.patch.motionCooldownMs};await p.mutateAsync({deviceId:e.deviceId,patch:t})}),v(null),await l.refetch()===`failed`&&v(d(`customize.motion.refetchFailed`))}catch(e){v(e instanceof Error?e.message:String(e))}finally{y.current=!1,x(!1)}},A=w.rows.map(e=>({addonId:e.addonId,stableId:e.stableId,cap:`binary`,fieldPath:`on`,mode:e.mode,label:e.name}));return e(u,{children:[i(to,{id:a,icon:D,title:s,testId:`event-card-${a}`,actions:i(K,{children:d(Ga(w.text,w.status.state))}),children:i(`div`,{className:`flex flex-col gap-2 px-3 py-2 sm:px-4`,children:r.kind===`pending`||S.kind===`pending`?i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:d(`customize.motion.reading`)}):r.kind===`unknown`||S.kind===`unknown`?i(Yc,{reason:Zc(S)||(r.kind===`unknown`?r.reason:``)}):e(u,{children:[i(qc,{deviceId:n.id}),w.rows.length===0?i(`p`,{className:`text-xs text-foreground-subtle`,children:d(`customize.scalar.noOverride`)}):i(`ul`,{className:`flex flex-col gap-1`,children:w.rows.map(t=>e(`li`,{className:`text-xs text-foreground`,children:[i(Xc,{row:t,fleet:C}),t.reason===null?``:` — ${d(`customize.motion.state.${t.state}`)}`]},t.key))}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:d(`customize.event.timeoutSeconds`,{duration:Gc(T/1e3)})}),_!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger break-words`,children:_}),i(`div`,{className:`flex flex-wrap gap-2`,children:i(X,{variant:`outline`,size:`sm`,"data-testid":`event-add-${a}`,disabled:!O,onClick:()=>g(!0),children:w.rows.length===0?d(`customize.scalar.add`):d(`customize.scalar.change`)})})]})})}),i(Rc,{open:h,mode:w.rows.length===0?`add`:`change`,title:s,cap:a,targetId:c.id,host:n,target:{addonId:n.addonId,stableId:n.stableId},timeoutMs:T,cooldownMs:c.cooldownMs,sourceModes:c.sourceModes,sources:A,canSave:O,onClose:()=>g(!1),onSave:e=>{g(!1),k(e)}})]})}function qc({deviceId:e}){let{t}=Q(),n=Xa({deviceId:e,cap:`motion`,path:`detected`}),r=Xa({deviceId:e,cap:`motion`,path:`lastDetectedAt`}),a=kc(n.kind===`pending`?`pending`:n.kind!==`value`||typeof n.value!=`boolean`?`unknown`:n.value,r.kind===`value`&&typeof r.value==`number`?r.value:null,Date.now());return i(`p`,{role:`status`,className:`text-xs text-foreground`,children:t(a.kind===`active`?`customize.event.motionNow.active`:`customize.event.motionNow.${a.kind}`,a.seconds===null?void 0:{duration:Gc(a.seconds)})})}function Jc(e){return e.presence===`pending`?{kind:`pending`}:e.status===null?{kind:`unknown`,reason:e.failureReason}:{kind:`known`,value:e.status}}function Yc({reason:e}){let{t}=Q(),n=e.trim();return n.length===0?i(q,{message:t(`customize.motion.unreadableBare`)}):i(q,{title:t(`customize.motion.unreadable`,{reason:n}),message:n})}function Xc({row:e,fleet:t}){let n=Hi();if(t.kind!==`known`)return e.name;let r=t.value.find(t=>t.addonId===e.addonId&&t.stableId===e.stableId);return r===void 0?e.name:yo(ro(r),t.value.map(ro),n)}function Zc(e){return e.kind===`unknown`?e.reason??``:e.kind===`known`&&e.value.state===`unreadable`?e.value.reason:``}function Qc(e,t){return e!==null&&Number.isFinite(e)?e:t}var $c={id:0,name:``,type:`unknown`,stableId:``,parentDeviceId:null};function el(e){return zo().find(t=>t.cap===e)??null}function tl({spec:e,device:t,handle:n}){let r=el(e.cap);return r===null?i(rl,{}):r.pulse===null?i(qc,{deviceId:t.id}):i(Pc,{deviceId:t.id,cap:e.cap,timestampPath:r.pulse.timestampPath,counterPath:r.pulse.counterPath,startedAt:n.state.kind===`present`?n.state.view.block.createdAt:null})}function nl(e){let t=el(e.spec.cap);return t===null?i(rl,{}):t.pulse===null?i(ol,{...e,view:t.span}):i(al,{...e,cap:e.spec.cap,view:t.pulse})}function rl(){let{t:e}=Q();return i(`span`,{className:`text-xs text-foreground-subtle`,children:e(`customize.table.unknown`)})}function il(){let{t:e}=Q();return i(`span`,{role:`status`,className:`text-xs text-foreground-subtle`,children:e(`customize.event.checking`)})}function al({cap:e,view:t,handle:n}){let{t:r,i18n:a}=Q(),o=qs(n,Eo($(n.state),e)),s=(o.kind===`known`&&o.value!==null?Ze({feature:o.value,device:n.target,cap:e,targetId:t.id,timestampPath:t.timestampPath,counterPath:t.counterPath}):null)?.draft.sources[0]??null,c=Do(s!==null),l=s===null||c.kind!==`known`?null:c.value.find(e=>yt({addonId:e.addonId,stableId:e.stableId})===yt(s))??null,u=An(l===null?$c:ro(l),`compact`);return o.kind===`pending`?i(il,{}):o.kind===`unknown`?i(rl,{}):o.value===null?i(`span`,{className:`text-xs text-foreground-subtle`,children:r(`customize.scalar.noOverride`)}):s===null?i(`span`,{className:`text-xs text-foreground`,children:r(`customize.table.otherFormula`)}):c.kind===`pending`?i(il,{}):c.kind===`unknown`?i(`span`,{role:`alert`,className:`text-[11px] text-warning`,children:r(`customize.scalar.sourceUnreadable`)}):l===null?i(K,{variant:`warning`,children:r(`customize.table.sourceMissing`)}):i(`span`,{className:`text-xs text-foreground`,children:r(`customize.table.sourceOf`,{name:u,field:qa(s.cap,s.fieldPath,a.language)})})}function ol({sensors:t,view:n}){let{t:r}=Q(),a=Do(!0),o=Jc(t);if(n===null)return i(rl,{});if(o.kind===`pending`)return i(il,{});if(o.kind===`unknown`)return i(rl,{});let s=ht(n.id,o);return s.rows.length===0?i(K,{children:r(Ga(s.text,s.status.state))}):i(`span`,{className:`flex flex-col gap-0.5`,children:s.rows.map(t=>e(`span`,{className:`text-xs text-foreground`,children:[i(Xc,{row:t,fleet:a}),t.reason===null?``:` — ${r(`customize.motion.state.${t.state}`)}`]},t.key))})}function sl(e,t){return e.some(e=>e.id===t.id)?e.map(e=>e.id===t.id?t:e):[...e,t]}function cl(e,t){return e.filter(e=>e.id!==t)}function ll(e){let t=new Set(e.map(e=>e.id)),n=1;for(;t.has(`p${String(n)}`);)n+=1;return`p${String(n)}`}var ul=[`horizontal`,`vertical`],dl=[`angle`,`sweepFrom`,`sweepTo`];function fl(e){let t=[e.speed,e.preset,e.direction].filter(e=>e!==void 0).length;return ul.reduce((t,n)=>{let r=e.oscillationAxes?.[n];return r===void 0?t:t+[r.oscillating,r.angle,r.sweepFrom,r.sweepTo].filter(e=>e!==void 0).length},t)}function pl(e,t,n){let r={...n.oscillating===void 0?{}:{oscillating:n.oscillating},...n.angle===void 0?{}:{angle:n.angle},...n.sweepFrom===void 0?{}:{sweepFrom:n.sweepFrom},...n.sweepTo===void 0?{}:{sweepTo:n.sweepTo}},i=n=>{let i=n===t?r:e.oscillationAxes?.[n];return i===void 0||Object.keys(i).length===0?void 0:i},a=i(`horizontal`),o=i(`vertical`),{oscillationAxes:s,...c}=e;return a===void 0&&o===void 0?c:{...c,oscillationAxes:{...a===void 0?{}:{horizontal:a},...o===void 0?{}:{vertical:o}}}}var ml=(e,t)=>e.trim().toLowerCase()===t.trim().toLowerCase();function hl(e,t){return t.name.trim()===``?{ok:!1,reason:`no-name`}:fl(t.state)===0?{ok:!1,reason:`no-fields`}:e.some(e=>e.id!==t.id&&ml(e.name,t.name))?{ok:!1,reason:`duplicate-name`}:{ok:!0}}function gl(e){return`${e.what}: ${e.reason}`}function _l(e){if(e.trim()===``)return;let t=Number(e);return Number.isFinite(t)?t:void 0}c();function vl(){let{t:e}=Q();return t=>{if(t.ok)return null;switch(t.reason){case`no-name`:return e(`fanPresets.problem.name`,`Give the preset a name.`);case`no-fields`:return e(`fanPresets.problem.noFields`,`Set at least one value, or use the current values.`);case`duplicate-name`:return e(`fanPresets.problem.duplicate`,`Another preset already has this name.`)}}}function yl({options:e,value:t,onChange:n,testId:r}){return i(`div`,{className:`flex flex-wrap gap-1`,"data-testid":r,children:e.map(e=>i(X,{size:`sm`,variant:e.value===t?`primary`:`outline`,onClick:()=>n(e.value),children:e.label},e.label))})}function bl({label:e,value:t,onChange:n,testId:r}){let{t:a}=Q();return i(Y,{label:e,children:i(nn,{type:`number`,value:t===void 0?``:String(t),placeholder:a(`fanPresets.dialog.unchanged`,`Unchanged`),onChange:e=>n(_l(e.target.value)),"data-testid":r})})}function xl({axis:t,want:n,onChange:r}){let{t:a}=Q(),o=t===`horizontal`?a(`fanPresets.axis.horizontal`,`Horizontal axis`):a(`fanPresets.axis.vertical`,`Vertical axis`),s={angle:a(`fanPresets.axis.angle`,`Angle (°)`),sweepFrom:a(`fanPresets.axis.sweepFrom`,`Sweep from (°)`),sweepTo:a(`fanPresets.axis.sweepTo`,`Sweep to (°)`)};return e(`div`,{className:`space-y-2 rounded border border-border p-3`,"data-testid":`fan-preset-axis-${t}`,children:[i(`p`,{className:`text-xs font-medium text-foreground`,children:o}),i(Y,{label:a(`fanPresets.axis.oscillating`,`Oscillation`),children:i(yl,{testId:`fan-preset-axis-${t}-oscillating`,value:n.oscillating,onChange:e=>r({...n,oscillating:e}),options:[{value:void 0,label:a(`fanPresets.dialog.unchanged`,`Unchanged`)},{value:!0,label:a(`fanPresets.axis.on`,`On`)},{value:!1,label:a(`fanPresets.axis.off`,`Off`)}]})}),i(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:dl.map(e=>i(bl,{label:s[e],value:n[e],onChange:t=>r({...n,[e]:t}),testId:`fan-preset-axis-${t}-${e}`},e))})]})}function Sl({fanId:t,draft:n,others:r,saving:a,error:s,onSave:c,onClose:l}){let{t:u}=Q(),d=vl(),[f,p]=o(n),[m,h]=o([]),g=vr({deviceId:t},{enabled:!1,gcTime:0,retry:!1}),_=hl(r,f),v=d(_),y=e=>p(t=>({...t,state:e})),b=f.state;return i(fr,{open:!0,onOpenChange:e=>!e&&l(),children:e(Dn,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(Tr,{children:i(br,{children:u(`fanPresets.dialog.title`,`Fan preset`)})}),i(un,{children:e(`div`,{className:`space-y-3`,"data-testid":`fan-preset-editor`,children:[i(Y,{label:u(`fanPresets.dialog.name`,`Name`),children:i(nn,{value:f.name,maxLength:40,placeholder:u(`fanPresets.dialog.namePlaceholder`,`Night, Boost, Away…`),onChange:e=>p({...f,name:e.target.value})})}),e(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[i(`p`,{className:`text-xs text-foreground-muted`,children:u(`fanPresets.dialog.stateHint`,`Set only what this preset should change. An empty value is left as it is.`)}),e(X,{size:`sm`,variant:`outline`,disabled:g.isFetching,onClick:()=>{g.refetch().then(e=>{e.data!==void 0&&(y(e.data.state),h(e.data.omitted))})},"data-testid":`fan-preset-use-current`,children:[g.isFetching?i(Ce,{className:`h-4 w-4 animate-spin`}):i(ie,{className:`h-4 w-4`}),` `,u(`fanPresets.dialog.useCurrent`,`Use current values`)]})]}),g.isError&&i(q,{message:g.error?.message??u(`fanPresets.dialog.captureFailed`,`The current values could not be read.`)}),m.length>0&&e(`div`,{role:`status`,className:`rounded border border-warning/40 bg-warning/10 p-3 text-xs text-warning`,"data-testid":`fan-preset-omitted`,children:[i(`p`,{children:u(`fanPresets.dialog.omitted`,`These values could not be read, so they were left out:`)}),i(`ul`,{className:`mt-1 list-disc pl-4`,children:m.map(e=>i(`li`,{children:gl(e)},`${e.what}:${e.reason}`))})]}),e(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[i(bl,{label:u(`fanPresets.field.speed`,`Speed (%)`),value:b.speed,onChange:e=>{let{speed:t,...n}=b;y(e===void 0?n:{...n,speed:e})},testId:`fan-preset-speed`}),i(Y,{label:u(`fanPresets.field.preset`,`Fan preset mode`),children:i(nn,{value:b.preset??``,placeholder:u(`fanPresets.dialog.unchanged`,`Unchanged`),onChange:e=>{let{preset:t,...n}=b,r=e.target.value;y(r===``?n:{...n,preset:r})},"data-testid":`fan-preset-mode`})})]}),i(Y,{label:u(`fanPresets.field.direction`,`Direction`),children:i(yl,{testId:`fan-preset-direction`,value:b.direction,onChange:e=>{let{direction:t,...n}=b;y(e===void 0?n:{...n,direction:e})},options:[{value:void 0,label:u(`fanPresets.dialog.unchanged`,`Unchanged`)},{value:`forward`,label:u(`fanPresets.field.forward`,`Forward`)},{value:`reverse`,label:u(`fanPresets.field.reverse`,`Reverse`)}]})}),ul.map(e=>i(xl,{axis:e,want:b.oscillationAxes?.[e]??{},onChange:t=>y(pl(b,e,t))},e)),v!==null&&f.name!==``&&i(`p`,{className:`text-xs text-warning`,children:v}),s!==null&&i(q,{message:s})]})}),e(xn,{children:[i(X,{variant:`ghost`,onClick:l,children:u(`common.cancel`,`Cancel`)}),e(X,{disabled:a||!_.ok,onClick:()=>c({...f,name:f.name.trim()}),children:[a&&i(Ce,{className:`h-4 w-4 animate-spin`}),` `,u(`common.save`,`Save`)]})]})]})})}c();function Cl({device:t}){let{t:n}=Q(),r=re(),a=l(),s=Ar({deviceId:t.id}),[c,u]=o(null),[d,f]=o(null),p=qn({onSuccess:e=>{if(e.status===`refused`){f(e.detail);return}f(null),u(null),a.invalidateQueries({queryKey:[[`fanPresets`]]}),a.invalidateQueries({queryKey:[[`actions`]]})}}),m=s.data,h=e=>p.mutate({deviceId:t.id,presets:[...e]});return e(to,{id:`fan-presets`,title:n(`fanPresets.card.title`,`Presets`),icon:ae,testId:`customize-fan-presets`,actions:e(X,{size:`sm`,variant:`outline`,disabled:m===void 0,onClick:()=>u({id:ll(m??[]),name:``,state:{}}),"data-testid":`fan-presets-add`,children:[i(R,{className:`h-4 w-4`}),` `,n(`fanPresets.card.add`,`Add preset`)]}),children:[s.status===`error`?i(`p`,{role:`alert`,className:`px-3 py-2 text-xs text-danger`,children:s.error?.message??n(`fanPresets.card.unreadable`,`The presets could not be read.`)}):m===void 0?i(`p`,{role:`status`,className:`px-3 py-2 text-xs text-foreground-subtle`,children:n(`fanPresets.card.loading`,`Loading presets…`)}):m.length===0?i(`p`,{className:`px-3 py-2 text-xs text-foreground-muted`,"data-testid":`fan-presets-empty`,children:n(`fanPresets.card.none`,`No presets yet. A preset sets the fan’s speed, mode, direction and oscillation in one go.`)}):i(`ul`,{className:`divide-y divide-border-subtle`,"data-testid":`fan-presets-list`,children:m.map(t=>e(`li`,{className:`flex items-center gap-2 px-3 py-2`,children:[i(`span`,{className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:t.name}),i(K,{variant:`info`,children:n(`fanPresets.card.fields`,`Values: {{count}}`,{count:fl(t.state)})}),i(J,{icon:V,variant:`ghost`,"aria-label":n(`fanPresets.card.edit`,`Edit {{name}}`,{name:t.name}),onClick:()=>u(t)}),i(J,{icon:me,variant:`ghost`,"aria-label":n(`fanPresets.card.delete`,`Delete {{name}}`,{name:t.name}),onClick:()=>{r({title:n(`fanPresets.card.deleteTitle`,`Delete this preset?`),message:n(`fanPresets.card.deleteMessage`,`{{name}} will be deleted, and Alexa, HomeKit and Home Assistant stop offering it.`,{name:t.name}),confirmLabel:n(`common.delete`,`Delete`),variant:`danger`}).then(e=>{e&&h(cl(m,t.id))})}})]},t.id))}),c!==null&&m!==void 0&&i(Sl,{fanId:t.id,draft:c,others:m,saving:p.isPending,error:d??p.error?.message??null,onSave:e=>h(sl(m,e)),onClose:()=>{u(null),f(null)}})]})}function wl(e){let t={kind:`devices`,ids:e.deviceId>0?[e.deviceId]:[]},n=e.cap===``?void 0:W(e.cap,e.method,e.args),r=n===void 0?{}:Ae(n)?.action.args??{},i=Object.fromEntries(Object.entries(e.args??{}).filter(([e])=>!(e in r)));return{kind:`command`,target:t,actionId:n??``,...Object.keys(i).length===0?{}:{args:i},...e.argUnits===void 0?{}:{argUnits:e.argUnits}}}function Tl(e){if(e.target.kind!==`devices`||e.target.ids.length!==1)return null;let t=e.target.ids[0];if(t===void 0)return null;let n=Ve(e.actionId,e.args);return{kind:`cap`,deviceId:t,cap:n.cap,method:n.method,...Object.keys(n.args).length===0?{}:{args:{...n.args}},...e.argUnits===void 0?{}:{argUnits:e.argUnits}}}var El=`ir-transmitter`;function Dl(e,t){let n=new Map(t.customButtons.map(e=>[Oe(e.key),e.name])),r=new Map;for(let t of e?.buttons??[])t.label!==void 0&&!r.has(t.role)&&r.set(t.role,t.label);let i=new Set,a=[],o=(e,t)=>{if(i.has(e)||Me(e))return;i.add(e);let o=Be(e)!==null;a.push({role:e,custom:o,inLayout:t,name:o?n.get(e)??r.get(e)??On(e):null})};for(let t of e?.buttons??[])o(t.role,!0);for(let e of n.keys())o(e,!1);for(let e of Object.keys(t.bindings))o(e,!1);return a}function Ol(e,t,n){let r=Be(t);if(r===null||e.customButtons.some(e=>e.key===r))return e;let i={key:r,name:n};return{...e,customButtons:[...e.customButtons,i]}}function kl(e,t,n,r=On(t)){return Ol({...e,bindings:{...e.bindings,[t]:{action:n}}},t,r)}function Al(e,t){let n=Object.fromEntries(Object.entries(e.bindings).filter(([e])=>e!==t)),r=Be(t);return{...e,bindings:n,customButtons:r===null?e.customButtons:e.customButtons.filter(e=>e.key!==r)}}function jl(e){return e.deviceId>0&&e.cap!==``&&e.method!==``}var Ml={kind:`cap`,deviceId:0,cap:``,method:``};function Nl(e){let{action:t}=e;return t.cap===`ir-transmitter`&&t.method===`send`?t.deviceId:null}function Pl(e,t){return{action:{...e.action,deviceId:t}}}function Fl(e){let t=Object.entries(e.bindings).filter(([,e])=>!jl(e.action)).map(([e])=>e);if(t.length>0)return{incomplete:t,config:null};let n=Je.safeParse(e);return{incomplete:t,config:n.success?n.data:null}}function Il(e,t){if(t===null||t<=0)return{status:`refused`,reason:`no-transmitter`};let n;try{n=JSON.parse(e)}catch{return{status:`refused`,reason:`not-json`}}try{let e=ot(n),r=xt(e.table,{transmitterDeviceId:t}),i=[...e.skipped.map(e=>({name:e.name,reason:e.reason})),...r.skipped];return{status:`ok`,draft:r,bound:Object.keys(r.bindings).length,skipped:i}}catch(e){if(e instanceof He)return{status:`refused`,reason:`not-smartir`};throw e}}function Ll(e,t){if(t===null||t<=0)return{status:`refused`,reason:`no-transmitter`};try{let n=Le(H(e),{transmitterDeviceId:t});return{status:`ok`,draft:n,bound:Object.keys(n.bindings).length,skipped:n.skipped}}catch(e){if(e instanceof He)return{status:`refused`,reason:`not-flipper`};throw e}}function Rl(e,t){let n=new Set(e.customButtons.map(e=>e.key));return{...e,bindings:{...e.bindings,...t.bindings},customButtons:[...e.customButtons,...t.customButtons.filter(e=>!n.has(e.key))]}}var zl={kind:`digits`,name:``,number:``,steps:[],transmitterId:null,encoding:`raw`,nativeFormat:`tuya`,code:``,carrierKhz:``};function Bl(e){switch(e.kind){case`digits`:return{...zl,kind:`digits`,name:e.name,number:e.number};case`sequence`:return{...zl,kind:`sequence`,name:e.name,steps:e.steps};case`ir`:return{...zl,kind:`ir`,name:e.name,transmitterId:e.transmitterId??null,...e.payload.kind===`pronto`?{encoding:`pronto`,code:e.payload.code}:e.payload.kind===`native`?{encoding:`native`,nativeFormat:e.payload.format,code:e.payload.code}:{encoding:`raw`,code:e.payload.timings.join(`, `),carrierKhz:e.payload.settings?.carrierHz===void 0?``:String(e.payload.settings.carrierHz/1e3)}}}}function Vl(e){if(e.encoding===`pronto`)return{kind:`pronto`,code:e.code.trim()};if(e.encoding===`native`)return{kind:`native`,format:e.nativeFormat,code:e.code.trim()};let t=e.code.replace(/[[\]]/g,` `).split(/[\s,]+/).filter(e=>e!==``).map(Number),n=e.carrierKhz.trim();return n===``?{kind:`raw`,timings:t}:{kind:`raw`,timings:t,settings:{carrierHz:Math.round(Number(n)*1e3)}}}function Hl(e){let t=e.payload.kind;try{let{timings:n,settings:r}=Ge(e.payload);return{encoding:t,pulses:n.length,carrierKhz:r.carrierHz===void 0?null:r.carrierHz/1e3}}catch(e){if(e instanceof He)return{encoding:t,pulses:null,carrierKhz:null};throw e}}function Ul(e){return Object.keys(e.bindings)}var Wl=48;function Gl(e,t){let n=t.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,Wl-4).replace(/-+$/g,``),r=n===``?`source`:n,i=new Set(e.sources.map(e=>e.id)),a=r;for(let e=2;i.has(a);e++)a=`${r}-${e}`;return a}function Kl(e,t){switch(e.kind){case`digits`:return{id:t,kind:`digits`,name:e.name,number:e.number};case`sequence`:return{id:t,kind:`sequence`,name:e.name,steps:[...e.steps]};case`ir`:return{id:t,kind:`ir`,name:e.name,...e.transmitterId===null?{}:{transmitterId:e.transmitterId},payload:Vl(e)}}}function ql(e,t,n){if(n===null){let n=Kl(t,Gl(e,t.name));return{...e,sources:[...e.sources,n]}}return{...e,sources:e.sources.map(e=>e.id===n?Kl(t,n):e)}}function Jl(e,t){return{...e,sources:e.sources.filter(e=>e.id!==t)}}function Yl(e,t,n){let r=e.sources.findIndex(e=>e.id===t),i=r+n;if(r<0||i<0||i>=e.sources.length)return e;let a=[...e.sources],[o]=a.splice(r,1);return o===void 0?e:(a.splice(i,0,o),{...e,sources:a})}function Xl(e,t){return{...e,stepDelayMs:t}}var Zl=[`id`,`name`,`number`,`steps`,`kind`,`transmitterId`,`payload`];function Ql(e){return Zl.some(t=>t===e)}function $l(e){let t=Je.safeParse(e),n=new Map,r=null;if(!t.success)for(let e of t.error.issues){let[t,i,a]=e.path;if(t===`stepDelayMs`)r={field:`kind`,code:e.code,message:e.message};else if(t===`sources`&&typeof i==`number`){let t=Ql(a)?a:`kind`,r=n.get(i)??[];r.push({field:t,code:e.code,message:e.message}),n.set(i,r)}}return{bySource:n,stepDelay:r}}function eu(e,t,n){let r=ql(e,t,n),i=n===null?r.sources.length-1:r.sources.findIndex(e=>e.id===n),a=$l(r).bySource.get(i)??[];return t.kind===`ir`&&t.transmitterId===null&&e.defaultTransmitterId===null?[...a,{field:`transmitterId`,code:`no_emitter`,message:`Pick an emitter: the remote has no default one`}]:a}function tu(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function nu(e){let t=e.args??{},n=t.timings,r=t.settings,i=typeof r==`object`&&r&&`carrierHz`in r?tu(r.carrierHz):null;return{call:`${e.cap}.${e.method}`,timings:Array.isArray(n)?n.length:null,carrierHz:i}}function ru(e,t,n){let r=t.find(t=>t.id===e);return r===void 0?n:iu(r)}function iu(e){return e.parentName?`${e.name} · ${e.parentName}`:e.name}function au(e){return Object.entries(e).flatMap(([e,t])=>typeof t==`string`||typeof t==`number`||typeof t==`boolean`?[{name:e,value:String(t)}]:[])}function ou(e,t){if(e===void 0)return{kind:`unbound`};if(!jl(e))return{kind:`incomplete`};let n=ru(e.deviceId,t,`#${e.deviceId}`),r=nu(e),i=au(e.args??{});return e.cap===`ir-transmitter`&&e.method===`send`?{kind:`infrared`,target:n,pulses:r.timings,carrierKhz:r.carrierHz===null?null:Math.round(r.carrierHz/1e3),args:i}:{kind:`call`,target:n,call:r.call,args:i}}function su(e){return Array.isArray(e)&&e.every(e=>typeof e==`number`)}function cu(e){if(!jl(e))return null;let t=e.args??{};if(e.cap===`ir-transmitter`&&e.method===`send`&&su(t.timings)){let n=t.timings,r=nu(e).carrierHz;return{kind:`infrared`,timings:n,pulses:n.length,carrierKhz:r===null?null:r/1e3,text:n.join(`, `)}}let n=Object.keys(t).length===0?``:JSON.stringify(t);return{kind:`call`,text:`${e.cap}.${e.method}(${n})`}}c();function lu({description:e}){let{t}=Q();switch(e.kind){case`unbound`:return t(`remote.panel.unbound`);case`incomplete`:return t(`remote.panel.incomplete`);case`infrared`:return e.pulses===null?t(`remote.panel.infrared`,{target:e.target}):e.carrierKhz===null?t(`remote.panel.infraredPulses`,{count:e.pulses,target:e.target}):t(`remote.panel.infraredPulsesCarrier`,{count:e.pulses,khz:e.carrierKhz,target:e.target});case`call`:return t(`remote.panel.call`,{call:e.call,target:e.target})}}function uu({label:t,children:n}){return e(`div`,{className:`grid gap-1 sm:grid-cols-[6rem_minmax(0,1fr)] sm:gap-2`,children:[i(`dt`,{className:`text-xs text-foreground-muted`,children:t}),i(`dd`,{className:`min-w-0 text-xs text-foreground`,children:n})]})}function du({code:t,role:n}){let{t:r}=Q();return e(`div`,{className:`space-y-1`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`span`,{className:`text-[11px] text-foreground-subtle`,children:t.kind===`infrared`?[r(`remote.panel.codeRaw`,{count:t.pulses}),...t.carrierKhz===null?[]:[r(`remote.panel.codeCarrier`,{khz:t.carrierKhz})]].join(` · `):r(`remote.panel.callCode`)}),i(ui,{value:t.text,srLabel:r(`remote.panel.copyCode`)})]}),i(`pre`,{className:`max-h-28 overflow-auto whitespace-pre-wrap break-all rounded border border-border bg-surface p-2 font-mono text-[11px] leading-snug text-foreground`,"data-testid":`code-${n}`,children:t.text})]})}function fu({role:t,name:n,binding:r,devices:a,transmitters:s,testable:c,testResult:l,onBind:d,onClear:f,onTest:p}){let{t:m}=Q(),h=mr()(we(t.role)),[g,_]=o(!1),v=r!==void 0&&jl(r.action),y=r===void 0?null:Nl(r),b=ou(r?.action,a),x=r===void 0?null:cu(r.action),S=r!==void 0&&y===null&&r.action.cap!==``&&wl(r.action).actionId===``,C=r!==void 0&&y===null&&(g||!v&&!S);return e(`aside`,{className:`min-w-0 space-y-3 rounded border border-border bg-surface p-3`,"data-testid":`binding-panel`,"aria-label":m(`remote.panel.title`,{name:n}),children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[h!==void 0&&i(h,{className:`h-4 w-4 shrink-0 text-foreground-muted`,"aria-hidden":!0}),i(`h4`,{className:`text-sm font-medium text-foreground`,children:n}),t.custom&&i(K,{variant:`neutral`,children:m(`remote.bindings.custom`)}),!t.inLayout&&i(K,{variant:`warning`,children:m(`remote.bindings.notInLayout`)}),y!==null&&i(K,{variant:`info`,children:m(`remote.bindings.infrared`)})]}),e(`dl`,{className:`space-y-2`,"data-testid":`binding-description`,children:[e(uu,{label:m(`remote.panel.does`),children:[i(`span`,{className:r===void 0?`text-foreground-subtle`:void 0,"data-testid":`summary-${t.role}`,children:i(lu,{description:b})}),v&&i(`span`,{className:`block text-foreground-muted`,children:m(`remote.panel.repeatValue`)})]}),y!==null&&r!==void 0&&i(uu,{label:m(`remote.panel.through`),children:i(L,{"aria-label":m(`remote.bindings.transmitterFor`,{name:n}),value:String(y),options:s.map(e=>({value:String(e.id),label:iu(e)})),onChange:e=>d(Pl(r,Number(e.target.value)).action),"data-testid":`transmitter-${t.role}`})}),x!==null&&i(uu,{label:m(`remote.panel.code`),children:i(du,{code:x,role:t.role})})]}),C&&r!==void 0&&i(Y,{label:m(`commands.change`),children:i(Vo,{step:wl(r.action),devices:a,variables:[],singleTarget:!0,autoOpen:S,onChange:e=>{let t=Tl(e);t!==null&&d(t)}})}),i(`div`,{className:`flex flex-wrap items-center gap-1`,children:r===void 0?i(X,{size:`sm`,variant:`outline`,onClick:()=>{_(!0),d(Ml)},"data-testid":`bind-${t.role}`,children:m(`remote.bindings.bind`)}):e(u,{children:[y===null&&(v||S)&&!g&&i(X,{size:`sm`,variant:`outline`,onClick:()=>_(!0),"data-testid":`edit-${t.role}`,children:m(`commands.change`)}),i(X,{size:`sm`,variant:`outline`,disabled:!c||!v,title:c?void 0:m(`remote.bindings.saveToTest`),onClick:p,"data-testid":`test-${t.role}`,children:m(`remote.bindings.test`)}),i(X,{size:`sm`,variant:`ghost`,onClick:()=>{_(!1),f()},"data-testid":`clear-${t.role}`,children:m(`remote.bindings.clear`)})]})}),l!==null&&i(`p`,{role:`status`,className:`text-xs text-foreground-muted`,"data-testid":`result-${t.role}`,children:l})]})}var pu=`media-player`;function mu(e){return e.stableId.startsWith(`composed-`)?e.stableId.slice(dt.length):null}function hu(e){return e.target.kind!==`new`||e.features.some(e=>e.cap===pu)?null:{...e,features:[...e.features,{kind:`fields`,cap:pu,fields:{},commands:je()}]}}var gu=`Lucaslhm/Flipper-IRDB`,_u=`main`,vu=600*1e3,yu=class extends Error{code;resetAtMs;constructor(e,t,n=null){super(t),this.name=`FlipperIrdbError`,this.code=e,this.resetAtMs=n}},bu=Ot(Dt({name:Et(),path:Et(),type:Et()}));function xu(e){return e.split(`/`).filter(e=>e!==``).map(encodeURIComponent).join(`/`)}function Su(e){let t=[];for(let n of e)n.type===`dir`?t.push({name:n.name,path:n.path,kind:`dir`}):n.type===`file`&&n.name.toLowerCase().endsWith(`.ir`)&&t.push({name:n.name,path:n.path,kind:`file`});return t.sort((e,t)=>e.kind===t.kind?e.name.localeCompare(t.name):e.kind===`dir`?-1:1)}function Cu(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>e.name.toLowerCase().includes(n))}function wu(e={}){let t=e.fetchFn??((e,t)=>fetch(e,t)),n=e.now??Date.now,r=e.ttlMs??vu,i=new Map;async function a(e){let n;try{n=await t(e)}catch(e){throw new yu(`network`,e instanceof Error?e.message:`request failed`)}if(n.status===404)throw new yu(`not-found`,`Not found in the library`);let r=n.headers.get(`x-ratelimit-remaining`)===`0`;if(n.status===429||n.status===403&&r){let e=Number(n.headers.get(`x-ratelimit-reset`));throw new yu(`rate-limited`,`GitHub rate limit reached`,Number.isFinite(e)&&e>0?e*1e3:null)}if(!n.ok)throw new yu(`bad-response`,`GitHub answered ${n.status}`);return n}return{async list(e){let t=xu(e),o=i.get(t);if(o!==void 0&&n()-o.at<=r)return o.entries;let s=await a(`https://api.github.com/repos/${gu}/contents/${t}`),c=bu.safeParse(await s.json().catch(()=>null));if(!c.success)throw new yu(`bad-response`,`Not a directory listing`);let l=Su(c.data);return i.set(t,{at:n(),entries:l}),l},async readFile(e){return(await a(`https://raw.githubusercontent.com/${gu}/${_u}/${xu(e)}`)).text()}}}c();function Tu(e){return e instanceof yu?e:new yu(`network`,`request failed`)}function Eu({transmitterId:t,onApply:r,client:s}){let{t:c}=Q(),l=n(()=>s??wu(),[s]),[u,d]=o(``),[f,p]=o(``),[m,h]=o({status:`loading`}),[g,_]=o(null),[v,y]=o(null);a(()=>{let e=!0;return h({status:`loading`}),l.list(u).then(t=>{e&&h({status:`ready`,entries:t})}).catch(t=>{e&&h({status:`error`,error:Tu(t)})}),()=>{e=!1}},[l,u]);let b=e=>{if(y(null),_(null),e.kind===`dir`){p(``),d(e.path);return}l.readFile(e.path).then(e=>y(Ll(e,t))).catch(e=>_(Tu(e)))},x=e=>e.code===`rate-limited`&&e.resetAtMs!==null?c(`remote.flipper.error.rate-limitedAt`,{time:new Date(e.resetAtMs).toLocaleTimeString()}):c(`remote.flipper.error.${e.code}`),S=u===``?[]:u.split(`/`),C=m.status===`ready`?Cu(m.entries,f):[];return e(`div`,{className:`space-y-2`,"data-testid":`flipper-import`,children:[i(`p`,{className:`text-xs text-foreground-muted`,children:c(`remote.flipper.hint`)}),e(`nav`,{className:`flex flex-wrap items-center gap-1 text-xs`,"aria-label":c(`remote.flipper.title`),children:[i(X,{size:`sm`,variant:`ghost`,onClick:()=>{d(``),p(``),y(null)},children:c(`remote.flipper.root`)}),S.map((t,n)=>e(`span`,{className:`flex items-center gap-1`,children:[i(I,{className:`h-3 w-3 text-foreground-subtle`,"aria-hidden":!0}),i(X,{size:`sm`,variant:`ghost`,onClick:()=>{d(S.slice(0,n+1).join(`/`)),p(``),y(null)},children:t})]},t+String(n)))]}),i(nn,{value:f,onChange:e=>p(e.target.value),placeholder:c(`remote.flipper.search`),"aria-label":c(`remote.flipper.search`),"data-testid":`flipper-search`}),m.status===`loading`&&i(`p`,{className:`text-xs text-foreground-muted`,children:c(`remote.flipper.loading`)}),m.status===`error`&&i(`p`,{role:`alert`,className:`text-xs text-danger`,"data-testid":`flipper-error`,children:x(m.error)}),m.status===`ready`&&C.length===0&&i(`p`,{className:`text-xs text-foreground-muted`,children:c(`remote.flipper.empty`)}),C.length>0&&i(`ul`,{className:`max-h-48 space-y-0.5 overflow-y-auto`,"data-testid":`flipper-entries`,children:C.map(t=>i(`li`,{children:e(X,{size:`sm`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>b(t),children:[t.kind===`dir`?i(It,{className:`mr-1 h-3 w-3`,"aria-hidden":!0}):i(Rt,{className:`mr-1 h-3 w-3`,"aria-hidden":!0}),i(`span`,{className:`truncate`,children:t.name})]})},t.path))}),g!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger`,"data-testid":`flipper-file-error`,children:x(g)}),v?.status===`refused`&&i(`p`,{role:`alert`,className:`text-xs text-danger`,"data-testid":`flipper-refused`,children:c(`remote.flipper.refused.${v.reason}`)}),v?.status===`ok`&&e(`div`,{className:`space-y-2`,"data-testid":`flipper-summary`,children:[i(`p`,{className:`text-xs text-foreground`,children:c(`remote.import.summary`,{count:v.bound})}),v.skipped.length>0&&e(`div`,{className:`space-y-1`,children:[i(`p`,{className:`text-xs text-warning`,children:c(`remote.import.skipped`,{count:v.skipped.length})}),i(`ul`,{className:`max-h-24 space-y-0.5 overflow-y-auto text-[11px] text-foreground-muted`,children:v.skipped.map(t=>e(`li`,{children:[t.name,` — `,t.reason]},`${t.name}:${t.reason}`))})]}),i(X,{size:`sm`,disabled:v.bound===0,onClick:()=>{r(v.draft),y(null)},"data-testid":`flipper-apply`,children:c(`remote.import.apply`)})]})]})}c();function Du({transmitterId:n,onApply:r}){let{t:a}=Q(),s=t(null),[c,l]=o(``),[u,d]=o(null),[f,p]=o(null),m=e=>{p(e.trim()===``?null:Il(e,n))},h=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t===void 0)return;d(t.name);let n=await t.text();l(n),m(n)};return e(`div`,{className:`space-y-2`,"data-testid":`smartir-import`,children:[i(`p`,{className:`text-xs text-foreground-muted`,children:a(`remote.import.hint`)}),i(Y,{label:a(`remote.import.pasteLabel`),children:i(ni,{value:c,rows:5,onChange:e=>{l(e.target.value),d(null),p(null)},className:`w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`,"data-testid":`smartir-text`})}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(ii,{ref:s,accept:`application/json,.json`,className:`hidden`,onChange:e=>void h(e),"data-testid":`smartir-file`}),e(X,{size:`sm`,variant:`outline`,onClick:()=>s.current?.click(),children:[i(zt,{className:`mr-1 h-3 w-3`,"aria-hidden":!0}),a(`remote.import.chooseFile`)]}),u!==null&&i(`span`,{className:`truncate font-mono text-[11px] text-foreground-subtle`,children:u}),i(X,{size:`sm`,variant:`secondary`,disabled:c.trim()===``,onClick:()=>m(c),"data-testid":`smartir-read`,children:a(`remote.import.read`)})]}),f?.status===`refused`&&i(`p`,{role:`alert`,className:`text-xs text-danger`,"data-testid":`smartir-refused`,children:a(`remote.import.refused.${f.reason}`)}),f?.status===`ok`&&e(`div`,{className:`space-y-2`,"data-testid":`smartir-summary`,children:[i(`p`,{className:`text-xs text-foreground`,children:a(`remote.import.summary`,{count:f.bound})}),f.skipped.length>0&&e(`div`,{className:`space-y-1`,children:[i(`p`,{className:`text-xs text-warning`,children:a(`remote.import.skipped`,{count:f.skipped.length})}),i(`ul`,{className:`max-h-24 space-y-0.5 overflow-y-auto text-[11px] text-foreground-muted`,children:f.skipped.map(t=>e(`li`,{children:[t.name,` — `,t.reason]},`${t.name}:${t.reason}`))})]}),i(X,{size:`sm`,disabled:f.bound===0,onClick:()=>{r(f.draft),l(``),d(null),p(null)},"data-testid":`smartir-apply`,children:a(`remote.import.apply`)})]})]})}c();function Ou(e){return e.native===null?{encoding:`raw`,code:e.timings.join(`, `),carrierKhz:e.carrierHz===null?``:String(e.carrierHz/1e3)}:{encoding:`native`,nativeFormat:e.native.format,code:e.native.code,carrierKhz:``}}function ku({transmitterId:t,onLearned:n}){let{t:r}=Q(),a=ai({deviceId:t}),s=ri(),[c,l]=o(null);return a.data?.learn===!0?e(`div`,{className:`flex flex-col gap-1`,children:[i(X,{variant:`secondary`,size:`sm`,className:`self-start`,disabled:s.isPending,onClick:()=>{l(null),s.mutateAsync({deviceId:t}).then(e=>n(Ou(e))).catch(e=>{l(e instanceof Error?e.message:r(`remote.sources.learn.failed`))})},"data-testid":`source-learn`,children:s.isPending?r(`remote.sources.learn.pending`):r(`remote.sources.learn.button`)}),i(`p`,{className:`text-xs text-foreground-muted`,children:r(`remote.sources.learn.hint`)}),c!==null&&i(`p`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`source-learn-error`,children:c})]}):null}function Au(e,t){return t(`remote.sources.error.${e.field}.${e.code}`,{defaultValue:e.message})}function ju(e,t,n){return e.filter(e=>{switch(t){case`name`:return e.field===`name`||e.field===`id`;case`number`:return e.field===`number`||n===`digits`&&e.field===`steps`;case`steps`:return n===`sequence`&&e.field===`steps`;case`transmitterId`:case`payload`:return n===`ir`&&e.field===t}})}c();function Mu({lines:e}){return e.length===0?null:i(`div`,{role:`alert`,className:`space-y-0.5 text-xs text-danger`,children:e.map(e=>i(`p`,{children:e},e))})}function Nu(e){return Te.some(t=>t===e)}function Pu({config:t,source:r,roleLabel:a,transmitters:s,onClose:c,onSave:l}){let{t:d}=Q(),[f,p]=o(r===null?zl:Bl(r)),[m,h]=o(!1),[g,_]=o(``),v=n(()=>eu(t,f,r?.id??null),[t,f,r]),y=Ul(t),x=e=>p(t=>({...t,...e})),S=e=>m?ju(v,e,f.kind).map(e=>Au(e,d)):[],C=(e,t)=>{let n=e+t;if(n<0||n>=f.steps.length)return;let r=[...f.steps],[i]=r.splice(e,1);i!==void 0&&(r.splice(n,0,i),x({steps:r}))};return i(Ti,{open:!0,onClose:c,title:d(r===null?`remote.sources.dialog.addTitle`:`remote.sources.dialog.editTitle`),testId:`source-dialog`,footer:i(X,{onClick:()=>{h(!0),!(v.length>0)&&l(ql(t,f,r?.id??null))},"data-testid":`source-save`,children:d(`common.save`)}),children:e(`div`,{className:`space-y-4`,children:[i(Y,{label:d(`remote.sources.dialog.kind`),children:i(L,{value:f.kind,options:Te.map(e=>({value:e,label:d(`remote.sources.kind.${e}`)})),onChange:e=>{Nu(e.target.value)&&x({kind:e.target.value})},"data-testid":`source-kind`})}),i(Y,{label:d(`remote.sources.dialog.name`),children:i(nn,{value:f.name,state:S(`name`).length>0?`error`:`default`,onChange:e=>x({name:e.target.value}),"data-testid":`source-name`})}),i(Mu,{lines:S(`name`)}),f.kind===`ir`&&i(Iu,{draft:f,transmitters:s,defaultTransmitterId:t.defaultTransmitterId,patch:x,lines:S}),f.kind===`digits`&&e(u,{children:[i(Y,{label:d(`remote.sources.dialog.number`),description:d(`remote.sources.dialog.numberHint`),children:i(nn,{value:f.number,inputMode:`numeric`,state:S(`number`).length>0?`error`:`default`,onChange:e=>x({number:e.target.value}),"data-testid":`source-number`})}),i(Mu,{lines:S(`number`)})]}),f.kind===`sequence`&&e(`div`,{className:`space-y-2`,children:[i(Y,{label:d(`remote.sources.dialog.steps`),description:d(`remote.sources.dialog.stepsHint`),children:f.steps.length===0?i(`p`,{className:`text-xs text-foreground-muted`,children:d(`remote.sources.dialog.stepsEmpty`)}):i(`ol`,{className:`space-y-1`,"data-testid":`source-steps`,children:f.steps.map((t,n)=>e(`li`,{className:`flex items-center gap-1 rounded border border-border bg-surface px-2 py-1`,children:[i(`span`,{className:`w-5 text-xs text-foreground-subtle`,children:n+1}),i(`span`,{className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:a(t)}),i(J,{icon:O,size:`sm`,variant:`ghost`,"aria-label":d(`remote.sources.dialog.stepUp`),disabled:n===0,onClick:()=>C(n,-1)}),i(J,{icon:b,size:`sm`,variant:`ghost`,"aria-label":d(`remote.sources.dialog.stepDown`),disabled:n===f.steps.length-1,onClick:()=>C(n,1)}),i(J,{icon:me,size:`sm`,variant:`ghost`,"aria-label":d(`remote.sources.dialog.stepRemove`),onClick:()=>x({steps:f.steps.filter((e,t)=>t!==n)})})]},`${n}:${t}`))})}),y.length===0?i(`p`,{className:`text-xs text-foreground-muted`,"data-testid":`source-no-bound`,children:d(`remote.sources.dialog.noBound`)}):e(`div`,{className:`flex items-center gap-2`,children:[i(L,{"aria-label":d(`remote.sources.dialog.pickStep`),value:g,options:[{value:``,label:d(`remote.sources.dialog.pickStep`)},...y.map(e=>({value:e,label:a(e)}))],onChange:e=>_(e.target.value),"data-testid":`source-step-pick`}),i(X,{size:`sm`,variant:`secondary`,disabled:g===``,onClick:()=>{x({steps:[...f.steps,g]}),_(``)},"data-testid":`source-step-add`,children:d(`remote.sources.dialog.addStep`)})]}),i(Mu,{lines:S(`steps`)})]})]})})}function Fu(e,t){return e===`pronto`?`pronto`:e===`native`&&t===`native`?`native`:`raw`}function Iu({draft:t,transmitters:n,defaultTransmitterId:r,patch:a,lines:o}){let{t:s}=Q(),c=n.find(e=>e.id===r)?.label,l=t.transmitterId??r??null;return e(u,{children:[i(Y,{label:s(`remote.sources.dialog.transmitter`),children:i(L,{value:t.transmitterId===null?``:String(t.transmitterId),options:[{value:``,label:c===void 0?s(`remote.sources.dialog.noTransmitter`):`${s(`remote.sources.dialog.noTransmitter`)} (${c})`},...n.map(e=>({value:String(e.id),label:e.label}))],onChange:e=>a({transmitterId:e.target.value===``?null:Number(e.target.value)}),"data-testid":`source-transmitter`})}),i(Mu,{lines:o(`transmitterId`)}),l!==null&&i(ku,{transmitterId:l,onLearned:a}),i(Y,{label:s(`remote.sources.dialog.encoding`),children:i(L,{value:t.encoding,options:[{value:`raw`,label:s(`remote.sources.encoding.raw`)},{value:`pronto`,label:s(`remote.sources.encoding.pronto`)},...t.encoding===`native`?[{value:`native`,label:s(`remote.sources.encoding.native`)}]:[]],onChange:e=>a({encoding:Fu(e.target.value,t.encoding)}),"data-testid":`source-encoding`})}),i(Y,{label:s(`remote.sources.dialog.code`),description:t.encoding===`pronto`?s(`remote.sources.dialog.prontoHint`):t.encoding===`native`?s(`remote.sources.dialog.nativeHint`):s(`remote.sources.dialog.codeHint`),children:i(ni,{value:t.code,rows:4,spellCheck:!1,className:`font-mono text-xs`,state:o(`payload`).length>0?`error`:`default`,onChange:e=>a({code:e.target.value}),"data-testid":`source-code`})}),t.encoding===`raw`&&i(Y,{label:s(`remote.sources.dialog.carrier`),description:s(`remote.sources.dialog.carrierHint`),children:i(nn,{value:t.carrierKhz,inputMode:`decimal`,className:`w-32`,onChange:e=>a({carrierKhz:e.target.value}),"data-testid":`source-carrier`})}),i(Mu,{lines:o(`payload`)})]})}c();function Lu({source:e,roleLabel:t}){let{t:n}=Q();switch(e.kind){case`digits`:return e.number;case`sequence`:return ke(e).map(t).join(` → `);case`ir`:{let t=Hl(e);return t.pulses===null?n(`remote.sources.irDetailBroken`):t.carrierKhz===null?n(`remote.sources.irDetail`,{pulses:t.pulses}):n(`remote.sources.irDetailCarrier`,{pulses:t.pulses,khz:t.carrierKhz})}}}function Ru({config:t,onChange:r,roleLabel:a,transmitters:s}){let{t:c}=Q(),[l,u]=o(null),d=n(()=>$l(t),[t]),f=t.sources.length-1,p=[{key:`name`,header:c(`remote.sources.col.name`),nowrap:!1,render:t=>e(`div`,{className:`space-y-1`,children:[i(`span`,{className:`font-medium text-foreground`,children:t.name}),i(`div`,{children:i(K,{variant:`default`,children:c(`remote.sources.kind.${t.kind}`)})})]})},{key:`detail`,header:c(`remote.sources.col.detail`),nowrap:!1,render:(t,n)=>e(`div`,{className:`space-y-0.5`,children:[i(`span`,{className:`text-foreground-muted`,children:i(Lu,{source:t,roleLabel:a})}),(d.bySource.get(n)??[]).map(e=>i(`p`,{role:`alert`,className:`text-xs text-danger`,children:Au(e,c)},`${e.field}:${e.message}`))]})},{key:`actions`,header:c(`remote.sources.col.actions`),align:`right`,render:(t,n)=>e(`div`,{className:`flex justify-end gap-0.5`,children:[i(J,{icon:O,size:`sm`,variant:`ghost`,"aria-label":c(`remote.sources.moveUp`),disabled:n===0,onClick:()=>r(e=>Yl(e,t.id,-1))}),i(J,{icon:b,size:`sm`,variant:`ghost`,"aria-label":c(`remote.sources.moveDown`),disabled:n===f,onClick:()=>r(e=>Yl(e,t.id,1))}),i(J,{icon:V,size:`sm`,variant:`ghost`,"aria-label":c(`remote.sources.edit`),onClick:()=>u({source:t})}),i(J,{icon:me,size:`sm`,variant:`ghost`,"aria-label":c(`remote.sources.delete`),onClick:()=>r(e=>Jl(e,t.id))})]})}];return e(`section`,{className:`space-y-3`,"data-testid":`remote-sources`,children:[e(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[e(`div`,{className:`min-w-0 flex-1`,children:[i(`h3`,{className:`text-sm font-medium text-foreground`,children:c(`remote.sources.title`)}),i(`p`,{className:`text-xs text-foreground-muted`,children:c(`remote.sources.hint`)})]}),e(X,{size:`sm`,variant:`outline`,className:`shrink-0`,onClick:()=>u({source:null}),"data-testid":`source-add`,children:[i(R,{className:`mr-1 h-3 w-3`,"aria-hidden":!0}),c(`remote.sources.add`)]})]}),t.sources.length===0?i(ji,{icon:Ft,title:c(`remote.sources.empty`)}):i(Qt,{columns:p,rows:t.sources,rowKey:e=>e.id,minWidthPx:320}),(t.refusedSources??[]).length>0&&e(`div`,{role:`alert`,className:`space-y-1`,"data-testid":`remote-refused-sources`,children:[i(`p`,{className:`text-xs font-medium text-danger`,children:c(`remote.sources.refusedTitle`)}),(t.refusedSources??[]).map(e=>i(`p`,{className:`text-xs text-foreground-muted`,children:c(`remote.sources.refusedRow`,{name:e.name??e.id??`#${e.index+1}`,reason:e.reason})},e.index))]}),i(Y,{label:c(`remote.sources.stepDelay`),description:c(`remote.sources.stepDelayHint`),error:d.stepDelay===null?void 0:c(`remote.sources.error.stepDelay`,{min:100,max:ze}),children:i(nn,{type:`number`,inputMode:`numeric`,className:`w-32`,value:Number.isNaN(t.stepDelayMs)?``:t.stepDelayMs,state:d.stepDelay===null?`default`:`error`,onChange:e=>r(t=>Xl(t,e.target.valueAsNumber)),"data-testid":`source-step-delay`})}),l!==null&&i(Pu,{config:t,source:l.source,roleLabel:a,transmitters:s,onClose:()=>u(null),onSave:e=>{r(()=>e),u(null)}},l.source?.id??`new`)]})}c();function zu({device:t,open:n,onClose:r}){let{t:a}=Q(),o=yr({deviceId:t.id},{enabled:n});return i(fr,{open:n,onOpenChange:e=>!e&&r(),children:i(Dn,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,children:o.data===void 0?e(u,{children:[i(Tr,{children:i(br,{children:a(`remote.dialog.title`,{name:t.name})})}),i(un,{children:o.status===`error`?i(q,{title:a(`remote.dialog.unreadable`),message:o.error?.message??``,onRetry:()=>void o.refetch()}):i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:a(`remote.dialog.loading`)})})]}):i(Vu,{device:t,initial:o.data,onClose:r})})})}function Bu(e,t){switch(e.status){case`sent`:return t(`remote.test.sent`,{count:e.sends});case`skipped`:return t(`remote.test.skipped`);case`refused`:return t(`remote.test.refused.${e.reason}`,{detail:e.detail??``})}}function Vu({device:t,initial:r,onClose:a}){let{t:s,i18n:c}=Q(),d=l(),[f,p]=o(r),[m,h]=o(null),[g,_]=o(null),[v,y]=o(null),b=Bo(),[x,S]=o({}),C=or({kind:`remote`}),w=Jn({deviceId:t.id}),T=Ho(),E=Xr({capNames:[El]}),D=Zr(),O=mu(t),k=Oi({blockId:O??``},{enabled:O!==null}),A=Fr(),j=Ht(),M=n(()=>{let e=new Set(E.data??[]);return T.filter(t=>e.has(t.id))},[T,E.data]),N=(C.data??[]).find(e=>e.id===f.layoutTemplateId),P=N===void 0?null:Er(N.payload),F=n(()=>Dl(P,f),[P,f]),ee=n(()=>new Set((w.data?.commands??[]).map(e=>e.role)),[w.data]),te=e=>e.name??P?.buttons.find(t=>t.role===e.role)?.label??Mn(e.role,c.language),I=F.find(e=>e.role===g),ne=P?.buttons.find(e=>e.role===g)?.id??null,re=F.filter(e=>!e.inLayout),ie=Fl(f),ae=n(()=>new Set(Object.keys(f.bindings)),[f.bindings]),R=async()=>{let e=k.data?.state===`loaded`?k.data.view:null;if(O===null||e===null)return;let t=rt(e.block),n=t===null?null:hu(t);n!==null&&await A.mutateAsync({blockId:O,expectedUpdatedAt:e.block.updatedAt,block:{composition:n}})},z=async()=>{if(ie.config!==null){h(null);try{let e=await D.mutateAsync({deviceId:t.id,config:ie.config});if(e.status===`refused`){h(e.detail);return}await R(),await d.invalidateQueries({queryKey:[[`remote`]]}),a()}catch(e){h(e instanceof Error?e.message:String(e))}}},oe=async e=>{try{let n=await j.mutateAsync({deviceId:t.id,role:e,repeat:1});S(t=>({...t,[e]:Bu(n,s)}))}catch(t){S(n=>({...n,[e]:t instanceof Error?t.message:String(t)}))}},B=(e,t)=>p(n=>kl(n,e,t));return v===null?e(u,{children:[i(Tr,{children:i(br,{children:s(`remote.dialog.title`,{name:t.name})})}),e(un,{className:`space-y-5`,children:[e(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[i(Y,{label:s(`remote.dialog.template`),children:i(L,{value:f.layoutTemplateId??``,options:[{value:``,label:s(`remote.dialog.noTemplate`)},...(C.data??[]).map(e=>({value:e.id,label:e.name}))],onChange:e=>p(t=>({...t,layoutTemplateId:e.target.value===``?null:e.target.value})),"data-testid":`remote-template`})}),i(Y,{label:s(`remote.dialog.transmitter`),children:i(L,{value:f.defaultTransmitterId===null?``:String(f.defaultTransmitterId),options:[{value:``,label:s(`remote.dialog.noTransmitter`)},...M.map(e=>({value:String(e.id),label:iu(e)}))],onChange:e=>p(t=>({...t,defaultTransmitterId:e.target.value===``?null:Number(e.target.value)})),"data-testid":`remote-transmitter`})})]}),C.data!==void 0&&C.data.length===0&&i(`p`,{className:`text-xs text-foreground-muted`,children:s(`remote.dialog.noTemplatesHint`)}),P!==null&&e(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,20rem)_1fr]`,children:[i(`div`,{className:`mx-auto w-full max-w-xs`,"data-testid":`remote-preview`,children:i(_n,{grid:P,label:s(`remote.dialog.preview`),boundRoles:ae,selectedId:ne,onSelect:e=>_(P.buttons.find(t=>t.id===e)?.role??null)})}),e(`div`,{className:`min-w-0 space-y-2`,children:[I===void 0?i(`p`,{className:`text-xs text-foreground-muted`,"data-testid":`binding-hint`,children:s(`remote.panel.hint`)}):i(fu,{role:I,name:te(I),binding:f.bindings[I.role],devices:T,transmitters:M,testable:ee.has(I.role),testResult:x[I.role]??null,onBind:e=>B(I.role,e),onClear:()=>p(e=>Al(e,I.role)),onTest:()=>void oe(I.role)},I.role),re.length>0&&i(Y,{label:s(`remote.panel.otherCommands`),description:s(`remote.panel.pickOtherHint`),children:i(L,{value:I?.inLayout===!1?I.role:``,options:[{value:``,label:s(`remote.panel.pickOther`)},...re.map(e=>({value:e.role,label:te(e)}))],onChange:e=>_(e.target.value===``?null:e.target.value),"data-testid":`binding-other`})})]})]}),N!==void 0&&i(`div`,{className:`flex justify-end`,children:e(X,{size:`sm`,variant:`ghost`,onClick:()=>{b.clearError(),y({id:N.id,kind:N.kind,name:N.name,payload:N.payload})},"data-testid":`remote-edit-layout`,children:[i(V,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),s(`remote.editTemplate`)]})}),i(Ru,{config:f,onChange:p,roleLabel:e=>F.find(t=>t.role===e)?.name??Mn(e,c.language),transmitters:M.map(e=>({id:e.id,label:iu(e)}))}),e(`section`,{className:`space-y-2`,children:[i(`h3`,{className:`text-sm font-medium text-foreground`,children:s(`remote.import.title`)}),i(`h4`,{className:`text-xs font-medium text-foreground-muted`,children:s(`remote.import.smartirTitle`)}),i(Du,{transmitterId:f.defaultTransmitterId,onApply:e=>p(t=>Rl(t,e))}),i(`h4`,{className:`text-xs font-medium text-foreground-muted`,children:s(`remote.flipper.title`)}),i(Eu,{transmitterId:f.defaultTransmitterId,onApply:e=>p(t=>Rl(t,e))})]}),ie.incomplete.length>0&&i(`p`,{role:`alert`,className:`text-xs text-warning`,"data-testid":`remote-incomplete`,children:s(`remote.dialog.incomplete`,{count:ie.incomplete.length})}),m!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger`,children:m})]}),e(xn,{children:[i(X,{variant:`ghost`,onClick:a,children:s(`common.cancel`)}),i(X,{disabled:ie.config===null||D.isPending,onClick:()=>void z(),"data-testid":`remote-save`,children:s(`common.save`)})]})]}):i(Wo,{draft:v,saving:b.saving,error:b.error,back:{label:t.name,title:s(`remote.layout.editorTitle`,{name:v.name}),onBack:()=>y(null)},onSave:e=>void b.save(e).then(e=>{e&&y(null)}),onClose:()=>y(null)},v.id??`new`)}function Hu({device:e,onClose:t}){return i(zu,{device:e,open:!0,onClose:t})}var Uu={remote:Hu};function Wu(e){return Uu[e]??null}var Gu={"fan-presets":Cl};function Ku(e){let t=[];for(let[n,r]of Object.entries(Ie))r.targets.some(t=>t.cardinality===`config`&&t.deviceTypes.includes(e))&&t.push(n);return t}function qu({device:e,onlyCap:t}){return Ku(e.type).map(n=>{if(t!==void 0&&n!==t)return null;let r=Gu[n];return r===void 0?null:i(r,{device:e},n)})}function Ju(e){let t=new Set;for(let{cap:e}of Aa())t.add(e);for(let{cap:e}of Va())t.add(e);for(let{cap:e}of zo())t.add(e);for(let n of Ku(e))t.add(n);return t}function Yu(e,t){if(e===null)return[];let n=[];for(let r of qe(e).model.cards)r.card.cardKind===`fields`&&!t.has(r.card.cap)&&n.push(r.card);return n}function Xu(e){switch(e.kind){case`from`:return e.sources;case`convert-unit`:return[e.source];case`formula`:return Object.values(e.bindings).flatMap(e=>e.kind===`from`?[e]:[]);case`companion`:return[]}}function Zu(e){return wt(e.cap,e.path)===void 0?null:`number`}function Qu(e,t){return t.cap===e.cap&&t.path===e.path?2:+(t.path===e.path)}function $u(e,t,n,r){return e.filter(e=>e.entry===null&&e.item===null).map(e=>({row:e,candidates:ka(t,n,r,Zu(e)).flatMap(e=>e.source===null?[]:[{cap:e.cap,path:e.path,source:e.source,value:e.value}]).map(t=>({candidate:t,score:Qu(e,t)})).filter(e=>e.score>0).toSorted((e,t)=>t.score-e.score).map(e=>e.candidate)}))}c();var ed=``;function td(e,t){return`${e}.${t}`}function nd(e,t){let n=e.candidates[0];return t.get(e.row.key)??(n===void 0?ed:td(n.cap,n.path))}function rd(t){let{t:n,i18n:r}=Q(),[a,s]=o(null),[c,l]=o(new Map),u=en({deviceId:a,capNames:[t.cap],fit:()=>``,capTitle:e=>Fo(e,r.language),fieldLabel:(e,t)=>qa(e,t,r.language)}),d=Xn({projection:`slim`}),f=Nr({deviceId:a??0},{enabled:a!==null}),p=zn({deviceId:a??0},{enabled:a!==null}),m=a===null||d.data===void 0?null:_o(d.data).find(e=>e.id===a)??null,h=ja(f.status===`success`?f.data:{caps:[]},p.status===`success`?p.data:null),g=m===null?[]:$u(t.rows,m,h,p.status===`success`?p.data:null),_=g.flatMap(e=>{let t=nd(e,c),n=e.candidates.find(e=>td(e.cap,e.path)===t);return n===void 0?[]:[{proposal:e,candidate:n}]});return i(fr,{open:!0,onOpenChange:e=>e?void 0:t.onClose(),children:e(Dn,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":t.title,children:[i(Tr,{children:i(br,{children:t.title})}),i(un,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:i(Fi,{testId:`fill-from-device`,requires:u.requires,contextDeviceId:t.device.id,deviceId:a,onDeviceChange:s,deviceLabel:m?.name??``,valuesState:f.status===`error`?`failed`:f.status===`success`?`ready`:`loading`,groups:[],value:null,onValueChange:()=>void 0,valuesOverride:i(`ul`,{className:`flex flex-col gap-2`,"data-testid":`fill-proposals`,children:g.map(e=>i(id,{proposal:e,chosen:nd(e,c),onChoose:t=>l(new Map(c).set(e.row.key,t))},e.row.key))}),heading:n(`customize.table.fillHeading`),noDeviceText:n(`customize.table.fillNoDevice`),noValuesText:n(`customize.table.fillNothing`)})}),e(xn,{children:[i(X,{variant:`ghost`,onClick:t.onClose,children:n(`customize.table.close`)}),i(X,{"data-testid":`fill-apply`,disabled:_.length===0||t.handle.saving,onClick:()=>{let e=$(t.handle.state),n=_.reduce((e,{proposal:n,candidate:r})=>Ya(e,t.handle.target,t.cap,n.row.path,r.source,[]),e);n!==null&&t.handle.save(n).then(()=>t.onClose())},children:n(`customize.table.fillApply`)})]})]})})}function id({proposal:t,chosen:n,onChoose:r}){let{t:a,i18n:o}=Q(),s=qa(t.row.cap,t.row.path,o.language);return e(`li`,{className:`flex flex-col gap-1 text-[11px]`,"data-testid":`fill-row-${t.row.key}`,children:[i(`span`,{className:`font-medium text-foreground`,children:s}),t.candidates.length===0?i(`span`,{className:`text-foreground-subtle`,children:a(`customize.table.fillNothing`)}):i(L,{value:n,"aria-label":s,options:[...t.candidates.map(e=>({value:td(e.cap,e.path),label:`${qa(e.cap,e.path,o.language)} · ${String(e.value??`—`)}`})),{value:ed,label:a(`customize.table.fillSkip`)}],onChange:e=>r(e.target.value)})]})}var ad={level:`level`,status:`status`,"remaining.value":`remaining`};function od(e,t){if(t.item===null)return qa(t.cap,t.path,e);let n=ad[t.path],r=n===void 0?t.path:Z.t(`customize.table.itemLeaf.${n}`);return`${t.item.label} · ${r}`}function sd(e,t){return Fo(t,e)}function cd(e,t,n,r){return`${t.get(yt(e.source))??r} · ${qa(e.cap,e.fieldPath,n)}`}function ld(e,t,n,r){switch(e.kind){case`from`:return e.sources.map(e=>cd(e,t,n,r)).join(`, `);case`convert-unit`:return`${cd(e.source,t,n,r)} → ${e.to}`;case`formula`:return Pa(e.expr,e.bindings,t,n,r);case`companion`:return null}}var ud={toFill:`warning`,checking:`default`,bound:`success`,notAnswering:`warning`,missing:`danger`};function dd({state:e}){let{t}=Q();return i(K,{variant:ud[e.kind],"data-testid":`field-state-${e.kind}`,children:t(`customize.table.fieldState.${e.kind}`)})}function fd({device:e,cap:t,item:n,path:r}){let a=Fn({deviceId:e.id,capName:t});if(a.status===`pending`)return i(`span`,{className:`text-xs text-foreground-subtle`,children:`…`});let o=Ha(a.data,`items`),s=Ha(Array.isArray(o)?o.find(e=>Ha(e,`key`)===n):void 0,r);return i(`span`,{className:`text-xs text-foreground`,children:typeof s==`string`||typeof s==`number`?String(s):`—`})}function pd({device:e,row:t,state:n}){return n.kind===`toFill`?i(dd,{state:n}):t.item===null?i(Ja,{target:{deviceId:e.id,cap:t.cap,path:t.path}}):i(fd,{device:e,cap:t.cap,item:t.item.key,path:t.path})}function md({row:t,state:n,names:r}){let{t:a,i18n:o}=Q();return e(`span`,{className:`flex flex-wrap items-center gap-1 text-xs text-foreground`,children:[(t.entry===null?null:ld(t.entry,r,o.language,a(`customize.fieldsCard.unknownDevice`)))??i(`span`,{className:`text-foreground-subtle`,children:a(`customize.table.noSource`)}),n.kind!==`bound`&&n.kind!==`toFill`&&i(dd,{state:n})]})}function hd({row:e,title:t,onEdit:n}){let{t:r}=Q();return e.entry===null?i(X,{variant:`outline`,size:`sm`,"data-testid":`customize-manage-${e.key}`,"aria-label":`${r(`customize.table.bind`)} ${t}`,onClick:n,children:r(`customize.table.bind`)}):i(J,{variant:`ghost`,size:`sm`,icon:V,"aria-label":r(`customize.table.editWhat`,{title:t}),"data-testid":`customize-manage-${e.key}`,onClick:n})}function gd({cap:t,title:n,handle:r,onFill:a}){let{t:o}=Q(),s=La(),c=$(r.state);return c===null?null:e(`div`,{className:`flex items-center justify-end gap-1`,children:[a!==void 0&&i(X,{variant:`ghost`,size:`sm`,"data-testid":`customize-fill-${t}`,disabled:r.saving,onClick:a,children:o(`customize.table.fillFromDevice`)}),i(J,{variant:`ghost`,size:`sm`,icon:me,"aria-label":`${o(`customize.table.remove`)} ${n}`,"data-testid":`customize-remove-offcatalog.${t}`,disabled:r.saving,onClick:()=>{let e=$a(c,t);s(o(`customize.fieldsCard.removeWhat`,{cap:n}),e===null).then(t=>{t&&r.save(e)})}})]})}function _d({row:t,title:n,device:r,handle:a,names:o,onClose:s}){let{t:c,i18n:l}=Q(),u=An(r,`compact`);return i(fr,{open:!0,onOpenChange:e=>e?void 0:s(),children:e(Dn,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":n,children:[i(Tr,{children:i(br,{children:n})}),i(un,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:i(Ea,{deviceId:r.id,self:a.target,selfName:u,cap:t.cap,fieldPath:t.path,label:qa(t.cap,t.path,l.language),unit:wt(t.cap,t.path),handle:a,names:o,toFill:t.entry===null})}),i(xn,{children:i(X,{variant:`ghost`,onClick:s,children:c(`customize.table.close`)})})]})})}function vd(e){return/At$/.test(e)}function yd(e){return e.kind===`companion`||e.kind===`formula`&&Object.keys(e.bindings).length===0}function bd(e){return e.map(e=>{let t=new Set(Object.keys(e.entries)),n=oo(e.cap,t).map(t=>({key:`${e.cap}.${t}`,cap:e.cap,path:t,entry:null,advanced:vd(t),item:null})),r=Object.entries(e.entries).map(([t,n])=>({key:`${e.cap}.${t}`,cap:e.cap,path:t,entry:n,advanced:vd(t)||yd(n),item:null})),i=[...n,...r];return{cap:e.cap,rows:i.filter(e=>!e.advanced),advanced:i.filter(e=>e.advanced)}})}function xd(e,t){if(e.entry===null)return{kind:`toFill`};let n=Xu(e.entry);if(n.length===0)return{kind:`bound`};if(t===null)return{kind:`checking`};let r=n.map(e=>t.get(yt(e.source))??`missing`);return r.includes(`missing`)?{kind:`missing`}:r.includes(`offline`)?{kind:`notAnswering`}:{kind:`bound`}}function Sd(e){return Object.entries(e?.items??{}).flatMap(([t,n])=>Object.entries(n.fields).filter(([,e])=>!yd(lt(e))).map(([r,i])=>({key:`${e?.cap??``}.items[${t}].${r}`,cap:e?.cap??``,path:r,entry:lt(i),advanced:!1,item:{key:t,label:n.label}})))}c();var Cd={names:new Map,presence:null};function wd(e){let t=Xn({projection:`slim`},{enabled:e});return n(()=>{if(t.data===void 0)return Cd;let e=new Map,n=new Map;for(let r of t.data){let t=yt({addonId:r.addonId,stableId:r.stableId});e.set(t,r.name),n.set(t,r.online?`answering`:`offline`)}return{names:e,presence:n}},[t.data])}function Td({labels:t}){let{t:n}=Q(),r=Na(t),a=r.labels.join(`, `),o=`${r.shown.join(`, `)}${r.truncated?`…`:``}`;return e(Ii,{className:`block w-full min-w-0`,children:[i(an,{children:i(`span`,{className:`block truncate text-xs text-foreground`,"data-testid":`list-value-shown`,children:`${n(`customize.table.listCount`,{count:r.labels.length})}: ${o}`})}),i(rr,{className:`whitespace-normal max-w-xs text-left`,children:a})]})}function Ed(){let{t:e}=Q();return i(`span`,{role:`status`,className:`text-xs text-foreground-subtle`,children:e(`customize.event.checking`)})}function Dd({reason:e}){let{t}=Q();return i(`span`,{role:`alert`,className:`text-xs text-warning`,title:e,children:t(`customize.table.unknown`)})}function Od(e,t){return e.kind===`item`?e.item.label:t(`customize.consumables.fields.${e.key}`,{defaultValue:za(e.key)})}function kd({handle:e,spec:t,defaults:n}){let{t:r}=Q();if(e.state.kind===`pending`||e.state.kind===`not-loaded`)return i(Ed,{});if(e.state.kind===`unknown`)return i(Dd,{reason:e.state.reason});if(t.cap===`consumables`&&n.kind===`pending`)return i(Ed,{});if(t.cap===`consumables`&&n.kind===`unknown`)return i(Dd,{reason:n.reason});let a=Eo($(e.state),t.cap),o=a===null?[]:Ue(a,t.cap,t.target.id)?.items??[],s=[...t.cap===`consumables`&&n.kind===`known`?n.value.map(e=>Od(e,r)):[],...o.map(e=>e.label.trim()||e.key)];return s.length===0?i(`span`,{className:`text-xs text-foreground-subtle`,children:r(`customize.table.listNone`)}):i(Td,{labels:s})}c();function Ad(e){let t=e.error===null?[]:[{kind:`actionError`,message:e.error}];return e.ready?e.rows.length===0?[{kind:`actionSection`},{kind:`actionEmpty`},...t]:[{kind:`actionSection`},...e.rows.map(e=>({kind:`actionEntry`,entry:e})),...t]:[{kind:`actionSection`},{kind:`actionPending`},...t]}function jd(e){return e.kind===`actionSection`||e.kind===`actionPending`||e.kind===`actionEmpty`||e.kind===`actionError`||e.kind===`actionEntry`}function Md(t){let{t:n}=Q(),r=l(),a=bn({}),s=En({deviceId:t.id}),[c,u]=o(!1),[f,p]=o([]),m=()=>void r.invalidateQueries({queryKey:[[`actions`]]}),h=_r({onSuccess:m}),g=wr({onSuccess:m}),_=a.data??[],v=s.data?.actionIds??[],y=v.flatMap(e=>_.filter(t=>t.id===e)),b=_.filter(e=>!v.includes(e.id)),x=s.data!==void 0&&a.data!==void 0,S=e=>h.mutate({deviceId:t.id,actionIds:[...e]}),C=()=>{p([]),u(!0)},w=e=>p(f.includes(e)?f.filter(t=>t!==e):[...f,e]);return{ready:x,rows:y,available:b,error:h.error===null||h.error===void 0?null:h.error.message,saving:h.isPending,running:g.isPending,deviceName:t.name,openPicker:C,unlink:e=>S(v.filter(t=>t!==e)),run:e=>g.mutate({actionId:e,deviceId:t.id}),dialog:i(fr,{open:c,onOpenChange:u,children:e(Dn,{placement:`sheet-on-mobile`,children:[e(Tr,{children:[i(br,{children:n(`customize.linkedActions.pickTitle`,{name:t.name})}),i(Si,{children:n(`customize.linkedActions.pickHint`)})]}),i(un,{children:i(`ul`,{className:`space-y-1`,children:b.map(t=>i(`li`,{children:e(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-surface-hover`,children:[i(d,{checked:f.includes(t.id),onChange:()=>w(t.id)}),i(`span`,{className:`flex-1`,children:t.name}),i(Nd,{entry:t})]})},t.id))})}),e(xn,{className:`flex flex-wrap gap-2`,children:[i(X,{variant:`outline`,onClick:()=>u(!1),children:n(`common.cancel`,`Cancel`)}),i(X,{disabled:f.length===0||h.isPending,onClick:()=>{S([...v,...f]),u(!1)},children:n(`customize.linkedActions.addN`,{count:f.length})})]})]})})}}function Nd({entry:e}){let{t}=Q();return e.readOnly?i(K,{variant:`info`,children:e.addonId}):i(K,{variant:`primary`,children:t(`actions.source.internal`,`Internal`)})}function Pd({children:e}){return i(`span`,{className:`text-xs text-foreground-subtle`,children:e})}function Fd({line:e}){let{t}=Q();switch(e.kind){case`actionSection`:return i(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-foreground-muted`,title:t(`customize.linkedActions.hint`),children:t(`customize.table.section.actions`)});case`actionPending`:return i(Pd,{children:t(`customize.linkedActions.loading`)});case`actionEmpty`:return i(Pd,{children:t(`customize.linkedActions.none`)});case`actionError`:return i(`span`,{role:`alert`,className:`text-xs text-danger break-words`,children:e.message});case`actionEntry`:return i(`span`,{className:`text-xs text-foreground`,children:e.entry.name})}}function Id({line:e}){let{t}=Q();if(e.kind===`actionEntry`){let n=e.entry.steps;return n===void 0?i(Pd,{children:`—`}):i(`span`,{className:`text-xs text-foreground`,children:t(`customize.linkedActions.steps`,{count:n.length})})}return e.kind===`actionPending`?i(Pd,{children:t(`customize.linkedActions.loading`)}):null}function Ld({line:e}){return e.kind===`actionEntry`?i(Nd,{entry:e.entry}):null}function Rd({line:t,state:n}){let{t:r}=Q();if(t.kind===`actionSection`&&n.ready&&n.available.length>0)return i(X,{variant:`outline`,size:`sm`,disabled:n.saving,onClick:n.openPicker,children:r(`customize.linkedActions.add`)});if(t.kind!==`actionEntry`)return null;let{entry:a}=t;return e(`span`,{className:`flex items-center justify-end gap-1`,children:[i(J,{icon:ne,variant:`ghost`,size:`sm`,"aria-label":r(`customize.linkedActions.run`,{name:a.name}),disabled:n.running,onClick:()=>n.run(a.id)}),i(J,{icon:j,variant:`ghost`,size:`sm`,"aria-label":r(`customize.linkedActions.unlink`,{name:a.name}),disabled:n.saving,onClick:()=>n.unlink(a.id)})]})}var zd=Ie;function Bd(e,t){let n=zd[e];return n===void 0?null:n.targets.find(e=>e.id===t)??null}function Vd({device:e,handle:t,facts:n,sensors:r,onlyCap:a}){let{t:o}=Q();return i(u,{children:zo().map(s=>{if(a!==void 0&&s.cap!==a)return null;let c=s.pulse??s.span;if(c===null||!c.deviceTypes.includes(e.type))return null;let l=Bd(s.cap,c.id);if(l===null)return null;let u=o(s.pulse===null?`customize.motion.title`:`customize.doorbell.title`),d=Ma(Ra(s.cap,l),n);return s.pulse===null?s.span===null?null:i(Kc,{device:e,availability:d,cap:s.cap,title:u,view:s.span,sensors:r},s.cap):i(Nc,{device:e,handle:t,availability:d,cap:s.cap,title:u,view:s.pulse},s.cap)})})}function Hd(t){let{t:n}=Q(),{spec:r,device:a,handle:o}=t,s=r.kind===`config`?Wu(r.cap):null;return s===null?i(fr,{open:!0,onOpenChange:e=>e?void 0:t.onClose(),children:e(Dn,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":t.title,children:[i(Tr,{children:i(br,{children:t.title})}),e(un,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:[r.kind===`event`&&i(Vd,{device:a,handle:o,facts:t.facts,sensors:t.sensors,onlyCap:r.cap}),r.kind===`keyed`&&i(Oa,{device:a,handle:o,facts:t.facts,defaults:t.defaults,onlyCap:r.cap}),r.kind===`config`&&i(qu,{device:a,onlyCap:r.cap})]}),i(xn,{children:i(X,{variant:`ghost`,onClick:t.onClose,children:n(`customize.table.close`)})})]})}):i(s,{device:a,onClose:t.onClose})}c();function Ud({handle:t}){let{t:n}=Q(),[r,a]=o(null),s=re(),c=$(t.state),l=Vs(c);if(c===null||!l.offered)return null;let u=async e=>{if(e&&l.discardsRule&&!await s({title:n(`customize.followSwitch.discardTitle`),message:n(`customize.followSwitch.discardMessage`),confirmLabel:n(`customize.followSwitch.discardConfirm`),variant:`danger`}))return;let r=await t.save(Hs(c,e));a(r.kind===`refused`?r.reason:null)};return e(`span`,{className:`flex flex-col gap-0.5`,children:[i(`span`,{className:`flex items-center gap-2 text-xs text-foreground`,children:i(mi,{checked:l.following,disabled:t.saving,label:n(`customize.followSwitch.label`),"data-testid":`follow-switch-toggle`,onCheckedChange:e=>void u(e)})}),r!==null&&i(`span`,{role:`alert`,className:`text-[11px] text-danger`,children:r})]})}var Wd=864e5;function Gd({state:t,onApply:n}){let{t:r}=Q();return e(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] text-foreground`,"data-testid":`running-proposal`,children:[i(`span`,{className:`text-foreground-muted`,children:r(`customize.scalar.proposal.label`)}),t.kind===`pending`&&i(`span`,{children:`…`}),t.kind===`error`&&i(`span`,{className:`text-warning`,children:r(`customize.scalar.proposal.error`)}),t.kind===`answer`&&t.proposal.state===`proposal`&&i(Kd,{proposal:t.proposal,onApply:n}),t.kind===`answer`&&t.proposal.state===`insufficient`&&e(`span`,{children:[r(`customize.scalar.proposal.reason.${t.proposal.reason}`),` `,t.proposal.fallback.kind===`threshold`&&r(`customize.scalar.proposal.defaults`,{threshold:t.proposal.fallback.threshold,start:qd(r,t.proposal.fallback.startDwellMs),stop:qd(r,t.proposal.fallback.stopDwellMs)})]})]})}function Kd(t){let{t:n}=Q(),{transform:r,evidence:a,confidence:o}=t.proposal;return e(u,{children:[i(`span`,{children:n(`customize.scalar.proposal.summary`,{runs:a.runsFound,days:Math.max(1,Math.round(a.spanMs/Wd)),threshold:r.threshold,start:qd(n,r.startDwellMs),stop:qd(n,r.stopDwellMs)})}),i(`span`,{className:`text-foreground-muted`,children:n(`customize.scalar.proposal.confidence.${o}`)}),i(X,{size:`sm`,variant:`outline`,"data-testid":`running-proposal-apply`,onClick:()=>t.onApply(r),children:n(`customize.scalar.proposal.apply`)})]})}function qd(e,t){let{unit:n,n:r}=ao(t);return e(`customize.scalar.proposal.${n}`,{n:r})}function Jd(e){let t=co(e);if(t===null)return{kind:`failed`,reason:eo};if(e.transform.kind===`threshold`)return Yd(e.transform,e);let n=uo(e.cap,e.targetId),r=n===null?void 0:t.fields[n];if(r===void 0)return{kind:`failed`,reason:eo};if(r.kind===`from`)return Zd(e.sourceValue);if(r.kind!==`expression`)return{kind:`failed`,reason:eo};if(r.expr.startsWith(`dwell(`))return{kind:`failed`,reason:Po};let i=Xd(e.sourceValue);if(i===void 0)return{kind:`failed`,reason:no};let a=Fe(r.expr,{x:i},e.nowMs);return a.ok?Zd(a.value):{kind:`failed`,reason:a.error}}function Yd(e,t){if(typeof t.sourceValue!=`number`||!Number.isFinite(t.sourceValue))return{kind:`failed`,reason:no};let n=e.comparison===`gte`?t.sourceValue>=e.threshold:t.sourceValue<=e.threshold,r=t.source.sourceUnit;return{kind:`dwell`,sourceText:r===null?String(t.sourceValue):`${t.sourceValue} ${r}`,active:n,countdownMs:n?e.startDwellMs:e.stopDwellMs}}function Xd(e){if(typeof e==`number`||typeof e==`string`||typeof e==`boolean`)return e;if(e===null)return null}function Zd(e){return e==null||typeof e==`number`&&!Number.isFinite(e)?{kind:`failed`,reason:Ro}:typeof e==`number`||typeof e==`string`||typeof e==`boolean`?{kind:`value`,text:String(e)}:{kind:`failed`,reason:Ro}}c();function Qd(t){let{t:n}=Q(),r=t.mode===`change`?n(`customize.scalar.changeTitle`,{title:t.title}):n(`customize.scalar.addTitle`,{title:t.title});return i(fr,{open:t.open,onOpenChange:e=>e?void 0:t.onClose(),children:e(Dn,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":r,children:[i(Tr,{children:i(br,{children:r})}),t.open&&i($d,{...t,heading:r})]})})}function $d(t){let{t:r}=Q(),a=Xn({projection:`slim`}),s=n(()=>a.status===`success`?_o(a.data):[],[a.status,a.data]),c=nf(t.seed,s),[l,d]=o(null),[f,p]=o(!1);!f&&c!==null&&(d(c),p(!0));let m=Nr({deviceId:l?.id??0}),h=zn({deviceId:l?.id??0}),g=ja(m.status===`success`?m.data:{caps:[]},h.status===`success`?h.data:null),_=po(g,h.status===`success`?h.data:null),[v,y]=o(rf(t.seed)),[b,x]=o(t.seed?.transform??{kind:`identity`}),S=v===null?null:(()=>{let[e,t]=v.split(`.`);return e===void 0||t===void 0?null:{cap:e,path:t}})(),C=_.find(e=>ef(e)===v)??null,w=C===null?null:xo(t.cap,t.targetId,C),T=C===null||w===null||!w.ok?null:tf(l,C,w,g),E=T===null?null:co({cap:t.cap,targetId:t.targetId,device:t.target,apply:t.apply,source:T,transform:b}),D=C===null||h.status!==`success`||l===null?void 0:Ha(h.data[C.cap],C.path),O=T===null?null:h.status===`pending`?{kind:`pending`}:Jd({cap:t.cap,targetId:t.targetId,device:t.target,apply:t.apply,source:T,transform:b,sourceValue:D,nowMs:Date.now()}),k=t.cap===`running-state`&&b.kind===`threshold`&&T!==null&&T.valueKind===`number`&&l!==null,A=bi({deviceId:l?.id??0,cap:T?.cap??`-`,fieldPath:T?.fieldPath??`-`,deviceType:t.host.type},{enabled:k,retry:!1}),j=k?A.status===`success`?{kind:`answer`,proposal:A.data}:A.status===`error`?{kind:`error`}:{kind:`pending`}:null;return e(u,{children:[i(un,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:i(Co,{kind:`scalar`,enabled:t.open,hostId:t.host.id,destination:{cap:t.cap,targetId:t.targetId,title:t.title},device:l,field:S,transform:b,onDeviceChange:e=>{d(e),y(null),x({kind:`identity`})},onFieldChange:e=>{if(e===null){y(null);return}y(`${e.cap}.${e.path}`)},onTransformChange:x,preview:O===null?void 0:i(Ba,{preview:O}),proposal:j===null?void 0:i(Gd,{state:j,onApply:e=>x(To(e,Mo(t.host.type)))})})}),e(xn,{className:`flex flex-wrap gap-2`,children:[i(X,{variant:`ghost`,onClick:t.onClose,children:r(`customize.scalar.cancel`)}),i(X,{"data-testid":`scalar-save-override`,disabled:!t.canSave||E===null,onClick:()=>{E!==null&&t.onSave(E)},children:r(`customize.scalar.save`)})]})]})}function ef(e){return`${e.cap}.${e.path}`}function tf(e,t,n,r){if(e===null||t.kind!==`boolean`&&t.kind!==`number`&&t.kind!==`string`)return null;let i=r.caps.find(e=>e.cap===t.cap),a=t.kind===`boolean`&&i?.fields.some(e=>e.path===`lastChangedAt`)?`lastChangedAt`:null;return{addonId:e.addonId,stableId:e.stableId,cap:t.cap,fieldPath:t.path,valueKind:t.kind,sourceUnit:n.sourceUnit,changedAtField:a}}function nf(e,t){return e===null?null:t.find(t=>t.addonId===e.source.addonId&&t.stableId===e.source.stableId)??null}function rf(e){return e===null?null:`${e.source.cap}.${e.source.fieldPath}`}function af({device:e,cap:t,target:n}){return i(Ja,{target:{deviceId:e.id,cap:t,path:n.path??n.id}})}function of(e,t){return t.badge.kind===`assigned`?e(`customize.scalar.badge.assigned`,{source:t.badge.source}):e(`customize.scalar.badge.${t.badge.kind}`)}function sf(t){let n=i(cf,{...t});return Bs(t.cap,t.target.id)?e(`span`,{className:`flex flex-col gap-1`,children:[n,i(Ud,{handle:t.handle})]}):n}function cf(t){let{t:n}=Q(),r=Zs(t.device,t.handle,t.cap,t.target);return r.recognized&&!r.released?e(`span`,{className:`flex flex-col gap-0.5`,children:[i(`span`,{className:`text-xs text-foreground`,children:n(`customize.table.sourceOf`,{name:r.sourceName??`…`,field:r.sourceField})}),sc(Eo($(t.handle.state),t.cap))!==null&&i(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`customize.table.fromLink`)}),r.presence===`unknown`&&i(`span`,{role:`alert`,className:`text-[11px] text-warning`,children:n(`customize.scalar.sourceUnreadable`)})]}):r.released?i(K,{variant:`warning`,children:n(`customize.table.sourceMissing`)}):r.otherFormula&&r.stored.kind===`known`&&r.stored.value!==null?i(lf,{feature:r.stored.value,path:r.path}):Bs(t.cap,t.target.id)&&Vs($(t.handle.state)).offered&&r.stored.kind===`known`&&r.stored.value===null?i(`span`,{className:`text-xs text-foreground`,children:n(`customize.followSwitch.default`)}):i(K,{children:of(n,r)})}function lf({feature:e,path:t}){let{t:n,i18n:r}=Q(),a=e.fields[t],o=wd(a!==void 0);if(a===void 0)return null;let s=n(`customize.fieldsCard.unknownDevice`),c=a.kind===`expression`?Object.keys(a.bindings).length===0?n(`customize.table.fixedValue`,{value:a.expr}):n(`customize.table.formulaOf`,{formula:Pa(a.expr,a.bindings,o.names,r.language,s)}):a.kind===`from`?n(`customize.table.sourceOf`,{name:o.names.get(yt(a.source))??s,field:qa(a.cap,a.fieldPath,r.language)}):n(`customize.table.otherFormula`);return i(`span`,{className:`text-xs text-foreground`,"data-testid":`scalar-formula-${e.cap}`,children:c})}function uf(t){let{t:n}=Q(),r=Zs(t.device,t.handle,t.cap,t.target),a=`${t.cap}.${t.target.id}`,o=Bs(t.cap,t.target.id)&&Vs($(t.handle.state)).offered,s=cc(r);return e(`span`,{className:`flex items-center justify-end gap-1`,children:[(r.recognized||o)&&i(J,{variant:`ghost`,size:`sm`,icon:V,"aria-label":n(`customize.table.editWhat`,{title:r.title}),"data-testid":`scalar-change-${a}`,disabled:r.saving,onClick:t.onEdit}),r.otherFormula&&!o&&i(Ua,{icon:!0,handle:t.handle,cap:t.cap,fieldPath:r.path,label:n(`customize.table.editWhat`,{title:r.title}),testId:`scalar-change-${a}`}),s.linkToggle&&e(`label`,{className:`flex items-center gap-1.5 text-xs text-foreground`,children:[i(d,{"aria-label":`${n(`customize.table.linkActive`)} ${r.title}`,"data-testid":`scalar-link-active-${a}`,checked:r.enabled,disabled:r.saving,onChange:e=>void r.setEnabled(e.target.checked).then(t.onError)}),n(`customize.table.linkActive`)]}),s.remove&&i(J,{variant:`ghost`,size:`sm`,icon:me,"aria-label":`${n(`customize.table.remove`)} ${r.title}`,"data-testid":`scalar-remove-${a}`,disabled:r.saving,onClick:()=>void r.remove().then(t.onError)})]})}function df(e){let t=Zs(e.device,e.handle,e.cap,e.target);return i(Qd,{open:!0,mode:t.seed===null?`add`:`change`,title:t.title,cap:e.cap,targetId:e.target.id,host:e.device,target:e.handle.target,apply:e.mode,seed:t.seed,canSave:t.answered&&!t.saving,onClose:e.onClose,onSave:n=>{e.onClose(),t.saveFeature(n).then(e.onError)}})}c();function ff(e){switch(e.kind){case`section`:return`section:${e.section}`;case`row`:return e.plan.spec.key;case`capSection`:return`capSection:${e.cap}`;case`field`:return`field:${e.row.key}`;case`advanced`:return`advanced:${e.cap}`;case`actionSection`:return`action-section`;case`actionPending`:return`action-pending`;case`actionEmpty`:return`action-empty`;case`actionError`:return`action-error`;case`actionEntry`:return`action:${e.entry.id}`}}function pf(e,t,n,r,i){let a=oc(e).flatMap(t=>[{kind:`section`,section:t},...e.filter(e=>e.spec.section===t).flatMap(e=>[{kind:`row`,plan:e},...e.spec.kind===`keyed`?r(e.spec.cap):[]])]),o=t.flatMap(e=>[{kind:`capSection`,cap:e.cap},...e.rows.map(e=>({kind:`field`,row:e})),...e.advanced.length===0?[]:[{kind:`advanced`,cap:e.cap,rows:e.advanced}],...n.has(e.cap)?e.advanced.map(e=>({kind:`field`,row:e})):[]]);return[...a,...o,...i]}function mf(e){return e.device.type===U.Camera?i(hf,{...e}):i(gf,{...e,actions:null})}function hf(e){let t=Md(e.device);return i(gf,{...e,actions:t})}function gf(t){let{device:r,handle:a,facts:s,actions:c}=t,{t:l,i18n:u}=Q(),[d,f]=o(null),[p,m]=o(null),h=a.state.kind===`none`||a.state.kind===`present`,g=$(a.state),_=t.defaults.kind===`known`&&t.defaults.value.length>0,v=n(()=>rc(r.type),[r.type]),y=e=>{switch(e.kind){case`scalar`:return Js(a,e.cap,e.target.id)!==null||Us(e.cap,e.target.id,g);case`keyed`:return Eo(g,e.cap)!==null||_;case`event`:return e.target.applyAuthority?.kind===`camera-sensors`?!0:Eo(g,e.cap)!==null;case`config`:return!0}},b=n(()=>Yu(g,Ju(r.type)),[g,r.type]),x=n(()=>bd(b),[b]),S=wd(x.length>0),[C,w]=o(new Set),T=e=>w(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),E=ac(ic(v,s,y)),D=c===null?[]:Ad(c);if(v.length===0&&x.length===0&&D.length===0)return null;let O=e=>e.kind===`scalar`?Xs(l,u.language,e.cap,e.target):l(`customize.table.caps.${e.cap}`),k=[...E.active,...E.addable].find(e=>e.spec.key===d),A=pf(E.active,x,C,e=>Sd(Eo(g,e)).map(e=>({kind:`field`,row:e})),D),j=x.flatMap(e=>[...e.rows,...e.advanced]).find(e=>e.key===d),M=e=>(x.find(t=>t.cap===e)?.rows??[]).filter(e=>e.entry===null),N=x.find(e=>`fill:${e.cap}`===d),P=e=>({cap:e.cap,target:e.target}),F=[{key:`item`,header:l(`customize.table.col.item`),notSortableReason:l(`customize.table.col.item`),nowrap:!1,render:t=>{if(jd(t))return i(Fd,{line:t});if(t.kind===`section`||t.kind===`capSection`)return i(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-foreground-muted`,children:t.kind===`section`?l(`customize.table.section.${t.section}`):sd(u.language,t.cap)});if(t.kind===`advanced`)return i(X,{variant:`ghost`,size:`sm`,className:`whitespace-nowrap`,"data-testid":`customize-advanced-${t.cap}`,"aria-expanded":C.has(t.cap),onClick:()=>T(t.cap),children:l(`customize.table.advanced`,{count:t.rows.length})});let n=t.kind===`row`?`customize.scalar.hints.${t.plan.spec.cap}`:``,r=t.kind===`row`&&u.exists(n)?l(n):null;return e(`span`,{className:`flex flex-col gap-0.5`,children:[i(`span`,{className:`text-xs text-foreground`,children:t.kind===`row`?O(t.plan.spec):od(u.language,t.row)}),r!==null&&i(`span`,{className:`text-[11px] text-foreground-muted`,children:r})]})}},{key:`value`,header:l(`customize.table.col.value`),notSortableReason:l(`customize.table.col.value`),render:e=>{if(jd(e))return i(Id,{line:e});if(e.kind===`section`||e.kind===`capSection`||e.kind===`advanced`)return null;if(e.kind===`field`)return i(pd,{device:r,row:e.row,state:xd(e.row,S.presence)});let{spec:n}=e.plan;return n.kind===`scalar`?i(af,{device:r,handle:a,...P(n)}):n.kind===`keyed`?i(kd,{device:r,handle:a,spec:n,defaults:t.defaults}):n.kind===`event`?i(tl,{spec:n,device:r,handle:a,sensors:t.sensors}):i(fc,{spec:n,device:r})}},{key:`source`,header:l(`customize.table.col.source`),notSortableReason:l(`customize.table.col.source`),nowrap:!1,render:e=>{if(jd(e))return i(Ld,{line:e});if(e.kind===`section`||e.kind===`capSection`||e.kind===`advanced`)return null;if(e.kind===`field`)return i(md,{row:e.row,state:xd(e.row,S.presence),names:S.names});let{spec:n}=e.plan;return n.kind===`event`?i(nl,{spec:n,device:r,handle:a,sensors:t.sensors}):n.kind===`config`?i(pc,{spec:n,device:r}):n.kind===`scalar`?i(sf,{device:r,handle:a,...P(n)}):i(`span`,{className:`text-xs text-foreground-subtle`,children:`—`})}},{key:`actions`,headerRender:()=>i(`span`,{className:`sr-only sm:not-sr-only`,children:l(`customize.table.col.actions`)}),notSortableReason:l(`customize.table.col.actions`),align:`right`,width:`w-px`,render:e=>{if(jd(e))return c===null?null:i(Rd,{line:e,state:c});if(e.kind===`section`||e.kind===`advanced`)return null;if(e.kind===`capSection`)return i(gd,{cap:e.cap,title:sd(u.language,e.cap),handle:a,onFill:M(e.cap).length===0?void 0:()=>f(`fill:${e.cap}`)});if(e.kind===`field`)return i(hd,{row:e.row,title:od(u.language,e.row),onEdit:()=>f(e.row.item===null?e.row.key:`${e.row.cap}.items`)});let{spec:t}=e.plan;return t.kind===`scalar`?i(uf,{device:r,handle:a,...P(t),onEdit:()=>f(t.key),onError:m}):i(J,{variant:`ghost`,size:`sm`,icon:V,"aria-label":l(`customize.table.editWhat`,{title:O(t)}),"data-testid":`customize-manage-${t.key}`,onClick:()=>f(t.key)})}}];return e(Nn,{headingId:`customize-table`,icon:_e,title:l(`customize.table.title`),testId:`customize-table`,actions:i(_f,{rows:E.addable,titleOf:O,disabled:!h||a.saving,onPick:e=>f(e)}),children:[e(`div`,{className:`flex flex-col gap-2 p-2 sm:p-3`,children:[!h||E.pending?i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:l(`customize.scalar.checking`)}):null,E.unknownReason!==null&&i(q,{title:l(`customize.scalar.unreadable`),message:E.unknownReason}),p!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger break-words`,children:p}),h&&A.length>0&&i(Qt,{columns:F,rows:A,rowKey:ff,bordered:!1,minWidthPx:320,rowClassName:e=>e.kind===`section`||e.kind===`capSection`||e.kind===`actionSection`?`bg-surface-hover`:void 0}),h&&A.length===0&&!E.pending&&E.unknownReason===null&&i(`p`,{className:`text-xs text-foreground-subtle`,children:l(E.addable.length>0?`customize.table.empty`:`customize.table.nothingToAdd`)})]}),k!==void 0&&k.spec.kind===`scalar`&&k.availability.kind===`present`&&i(df,{device:r,handle:a,...P(k.spec),mode:k.availability.mode,onClose:()=>f(null),onError:m},k.spec.key),j!==void 0&&i(_d,{row:j,title:od(u.language,j),device:r,handle:a,names:S.names,onClose:()=>f(null)},j.key),N!==void 0&&i(rd,{cap:N.cap,title:l(`customize.table.fillTitle`,{cap:sd(u.language,N.cap)}),rows:M(N.cap),device:r,handle:a,onClose:()=>f(null)},N.cap),c?.dialog,k!==void 0&&k.spec.kind!==`scalar`&&i(Hd,{spec:k.spec,title:O(k.spec),device:r,handle:a,facts:s,sensors:t.sensors,defaults:t.defaults,onClose:()=>f(null)},k.spec.key)]})}function _f({rows:t,titleOf:n,disabled:r,onPick:a}){let{t:o}=Q();return t.length===0?null:e(Mi,{children:[i(yi,{className:`h-7 px-2.5 text-xs rounded-md border border-border bg-surface text-foreground`,disabled:r,"aria-label":o(`customize.table.addAria`),"data-testid":`customize-table-add`,children:o(`customize.table.add`)}),i(qr,{children:t.map(e=>i($r,{"data-testid":`customize-table-add-${e.spec.key}`,onClick:()=>a(e.spec.key),children:n(e.spec)},e.spec.key))})]})}function vf({id:t,icon:n,title:r,headerControl:a,addLabel:o,onAdd:s,addDisabled:c=!1,notices:l,suggestion:d,children:f}){let{t:p}=Q(),m=s!==void 0&&o!==void 0;return e(to,{id:t,icon:n,title:r,actions:e(u,{children:[a,m&&!c&&d!==void 0&&d.count>0&&e(X,{variant:`ghost`,size:`sm`,onClick:d.onOpen,children:[i(be,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),p(`customize.suggest.hint`,{count:d.count,location:d.location})]}),m&&i(X,{variant:`outline`,size:`sm`,disabled:c,onClick:s,children:o})]}),children:[l!==void 0&&i(`div`,{className:`flex flex-col gap-1 px-3 pt-2 empty:hidden sm:px-4`,children:l}),i(`ul`,{className:`flex flex-col divide-y divide-border`,children:f})]})}c();function yf(e,t){let r=typeof e==`string`&&e.length>0,i=Do(t&&r);return n(()=>t?Ka(i,e):null,[t,i,e])}function bf({name:t,deviceId:n,detail:r,children:a}){return e(`div`,{className:`flex flex-col min-w-0`,children:[i(`span`,{className:`truncate text-xs text-foreground`,children:t??`#${n}`}),r!==null&&i(`span`,{className:`truncate text-[11px] text-foreground-subtle`,children:r}),a]})}c();function xf({camera:t,deviceId:n}){let{t:r}=Q(),a=l(),s=Bi({deviceId:t.id}),c=tr(),[u,d]=o(!1),[f,p]=o(null),m=as({status:s.status,data:s.data,error:s.error===null||s.error===void 0?null:{message:s.error.message}}),h=m.kind===`present`?ts(m.slot,m.value,n):null,g=s.isFetching,_=async e=>{if(!(m.kind!==`present`||u||g)){d(!0),p(null);try{await c.mutateAsync({deviceId:t.id,slotRef:m.slot.slotRef,value:os(m.value,n,e)}),await s.refetch(),await a.invalidateQueries({queryKey:[[`deviceManager`]]})}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}};return e(`div`,{className:`flex flex-col items-end gap-0.5`,children:[i(mi,{checked:h?.linked??!1,disabled:m.kind!==`present`||u||g||h?.implied===!0,"aria-label":r(`customize.linked.linkTo`,{name:t.name}),onCheckedChange:e=>void _(e)}),m.kind===`pending`&&i(`span`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:r(`customize.assign.checking`)}),m.kind===`unknown`&&i(`span`,{role:`alert`,className:`text-[11px] text-warning break-words text-right`,children:r(`customize.assign.unknown`,{reason:m.reason})}),m.kind===`absent`&&i(`span`,{role:`alert`,className:`text-[11px] text-warning break-words text-right`,children:r(`customize.assign.unknown`,{reason:r(`customize.assign.none`)})}),h?.implied===!0&&i(`span`,{className:`text-[11px] text-foreground-subtle text-right`,children:r(`customize.linked.impliedByStructure`)}),f!==null&&i(`span`,{role:`alert`,className:`text-[11px] text-danger break-words text-right`,children:f})]})}function Sf({device:t}){let{t:n}=Q(),r=Do(!0),a=r.kind===`known`?r.value.filter(e=>is(`linked-devices`,e.type)===`host`):[],o=[{key:`camera`,header:n(`customize.linked.camera`),cell:e=>i(bf,{name:e.name,deviceId:e.id,detail:Go(e.integration,e.location)})},{key:`linked`,header:n(`customize.linked.linkedColumn`),cellClassName:`text-right`,headerClassName:`text-right`,cell:e=>i(xf,{camera:e,deviceId:t.id})}];return i(vf,{id:`linked`,icon:_,title:n(`customize.linked.reverseTitle`),notices:r.kind===`pending`?i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:n(`customize.assign.checking`)}):r.kind===`unknown`?i(`p`,{role:`alert`,className:`text-xs text-warning break-words`,children:n(`customize.assign.devicesUnreadable`,{reason:r.reason})}):null,children:r.kind===`known`&&e(`li`,{className:`list-none px-3 py-2 sm:px-4`,children:[a.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`customize.linked.noCameras`)}):i(Vi,{mode:`generic`,items:a,getKey:e=>String(e.id),getSearchText:e=>[e.name,e.location??``,String(e.id)].join(` `),columns:o,searchPlaceholder:n(`customize.assign.search`),emptyLabel:n(`customize.linked.noCameras`)}),i(`p`,{className:`mt-2 text-[10px] text-foreground-subtle`,children:n(`customize.linked.reverseHint`)})]})})}c();function Cf(e){return e==null?null:e.message}function wf({device:e}){let t=is(`linked-devices`,e.type);return t===`host`?i(Tf,{device:e}):t===`guest`?i(Sf,{device:e}):null}function Tf({device:t}){let n=fe(),{t:r}=Q(),a=l(),s=La(),[c,d]=o(!1),[f,p]=o(!1),[m,h]=o(null),g=Bi({deviceId:t.id},{enabled:!0}),v=as({status:g.status,data:g.data,error:Cf(g.error)===null?null:{message:Cf(g.error)??``}}),y=v.kind===`present`?v.slot.slotRef:``,b=v.kind===`present`?[...rs(v.slot,v.value).map(e=>e.deviceId),...$o(v.slot,v.value)]:[],x=tr(),S=Do(v.kind===`present`&&(c||b.length>0)),C=yf(t.location,v.kind===`present`),w=Br({deviceId:t.id,slotRef:y},{enabled:(c||C!==null)&&v.kind===`present`});if(v.kind===`absent`)return null;if(v.kind!==`present`)return i(vf,{id:`linked`,icon:_,title:r(`customize.linked.title`),notices:v.kind===`pending`?i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:r(`customize.assign.checking`)}):i(`p`,{role:`alert`,className:`text-xs text-warning break-words`,children:r(`customize.assign.unknown`,{reason:v.reason})}),children:null});let T=v.value,E=new Map(S.kind===`known`?S.value.map(e=>[e.id,e]):[]),D=T.trackedDeviceIds!==void 0,O=(e,t)=>{let n=E.get(e.deviceId);return{...e,name:e.name??n?.name??null,type:n?.type??null,detail:n===void 0?null:Go(n.integration,n.location),orphan:t}},k=[...rs(v.slot,T).map(e=>O(e,!1)),...$o(v.slot,T).map(e=>O({deviceId:e,name:null,health:`ok`,implied:!1,tracked:!0},!0))],A=new Set(b),M=S.kind===`unknown`?S:w.status===`error`?{kind:`unknown`,reason:Cf(w.error)??r(`helpers.customize.requestFailed`)}:S.kind===`pending`||w.status===`pending`||w.data===void 0?{kind:`pending`}:{kind:`known`,value:ss(w.data.candidates,E,A)},N=async e=>{if(f){h(r(`customize.saveInFlight`));return}p(!0),h(null);try{await x.mutateAsync({deviceId:t.id,slotRef:v.slot.slotRef,value:e}),await g.refetch(),await a.invalidateQueries({queryKey:[[`deviceManager`]]})}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}},P=async e=>{await s(r(`customize.linked.removeWhat`,{name:e.name??`#${e.deviceId}`}),!1)&&await N(cs(T,e.deviceId))},F=[{key:`device`,header:r(`customize.linked.device`),cell:t=>e(bf,{name:t.name,deviceId:t.deviceId,detail:t.detail,children:[t.orphan&&i(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`customize.linked.notLinked`)}),t.health!==`ok`&&i(`span`,{role:`alert`,className:`text-[11px] text-warning`,children:r(`customize.linked.health.${t.health}`)})]})},{key:`type`,header:r(`customize.linked.type`),headerClassName:`hidden sm:table-cell`,cellClassName:`hidden sm:table-cell text-xs text-foreground-subtle`,cell:e=>e.type===null?`—`:Dr(e.type,n).label},{key:`controls`,header:r(`customize.linked.controls`),headerClassName:`hidden md:table-cell`,cellClassName:`hidden md:table-cell text-xs text-foreground-subtle`,cell:e=>e.orphan?`—`:r(`customize.linked.yes`)},...D?[{key:`tracked`,header:r(`customize.linked.tracked`),cellClassName:`text-right`,headerClassName:`text-right`,cell:e=>i(mi,{checked:e.tracked,disabled:f,"aria-label":r(`customize.linked.trackFor`,{name:e.name??e.deviceId}),onCheckedChange:t=>void N(ns(T,e.deviceId,t))})}]:[],{key:`remove`,header:``,cellClassName:`text-right w-10`,cell:e=>e.implied||e.orphan?null:i(J,{icon:j,variant:`ghost`,size:`sm`,"aria-label":r(`customize.assign.removeNamed`,{name:e.name??e.deviceId}),disabled:f,onClick:t=>{t.stopPropagation(),P(e)}})}];return e(u,{children:[i(vf,{id:`linked`,icon:_,title:r(`customize.linked.title`),addLabel:r(`customize.linked.add`),onAdd:f?void 0:()=>d(!0),...C===null?{}:{suggestion:{count:Da(M,C,e=>e.deviceId),location:C.location,onOpen:()=>d(!0)}},notices:e(u,{children:[S.kind===`unknown`&&i(`p`,{role:`alert`,className:`text-xs text-warning break-words`,children:r(`customize.assign.devicesUnreadable`,{reason:S.reason})}),m!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger break-words`,children:m})]}),children:e(`li`,{className:`list-none px-3 py-2 sm:px-4`,children:[k.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`customize.assign.none`)}):i(Vi,{mode:`generic`,items:k,getKey:e=>String(e.deviceId),getSearchText:e=>[e.name??``,e.detail??``,e.type??``,String(e.deviceId)].join(` `),getFilterType:e=>e.type===null?null:Dr(e.type,n).label,columns:F,searchPlaceholder:r(`customize.assign.search`),emptyLabel:r(`customize.assign.none`)}),k.some(e=>!e.orphan)&&i(`p`,{className:`mt-2 text-[10px] text-foreground-subtle`,children:r(`customize.linked.controlsAlways`)}),D&&i(`p`,{className:`mt-0.5 text-[10px] text-foreground-subtle`,children:r(`customize.linked.trackedHint`)})]})}),i(Io,{open:c,title:r(`customize.linked.pickTitle`),selection:`multi`,candidates:M,room:C,confirmLabel:e=>r(`customize.assign.addCount`,{count:e}),onConfirm:e=>{d(!1),N(es(T,e.map(e=>e.deviceId)))},onClose:()=>d(!1)})]})}var Ef={"linked-devices":wf};function Df({device:e}){return i(u,{children:pt.filter(t=>is(t,e.type)!==null).map(t=>{let n=Ef[t];return i(n,{device:e},t)})})}c();function Of(e){return e instanceof Error?e.message:String(e)}function kf(e){let n=Ur({addonId:e.addonId,stableId:e.stableId}),r=Uo(),i=Fr(),a=oi(),s=So({status:n.status,data:n.data,error:n.error===null||n.error===void 0?null:{message:n.error.message}}),{t:c}=Q(),l=t(!1),[u,d]=o(!1),f=async e=>{let t=Ia(s,e);try{switch(t.kind){case`refused`:return{kind:`refused`,reason:t.reason};case`noop`:return{kind:`saved`};case`create`:await r.mutateAsync({block:t.input});break;case`update`:await i.mutateAsync({blockId:t.blockId,expectedUpdatedAt:t.expectedUpdatedAt,block:{composition:t.composition}});break;case`delete`:await a.mutateAsync({blockId:t.blockId});break}return await n.refetch(),{kind:`saved`}}catch(e){return{kind:`refused`,reason:Of(e)}}};return{target:e,state:s,saving:u||r.isPending||i.isPending||a.isPending,save:async e=>{if(l.current)return{kind:`refused`,reason:c(`customize.saveInFlight`)};l.current=!0,d(!0);try{return await f(e)}finally{l.current=!1,d(!1)}}}}var Af=`pipeline-orchestrator`;function jf(e){return e.data===void 0?e.status===`pending`?`pending`:e.status===`error`?`unknown`:`pending`:e.data.cameraSensors===void 0?`absent`:`present`}function Mf(e,t){return e===`absent`?`absent`:jf(t)}async function Nf(e){try{return(await e()).isError?`failed`:`answered`}catch{return`failed`}}function Pf(e,t){let n=Mr(Af),r=vn({deviceId:e},{enabled:t&&n!==`absent`}),i=()=>Nf(r.refetch),a=r.data===void 0&&r.status===`error`?r.error?.message??null:null;return t?{presence:Mf(n,{status:r.status,data:r.data}),status:r.data?.cameraSensors??null,failureReason:a,refetch:i}:{presence:`absent`,status:null,failureReason:null,refetch:i}}function Ff(e,t){let n=Jr({deviceType:e.type}),r=pn({deviceId:e.id}),i=Nr({deviceId:e.id}),a=mo(n,e=>new Set(e.caps.map(e=>e.cap))),o=mo(r,e=>Fa(e.entries)),s=mo(i,e=>ja(e,null));return{deviceType:e.type,composable:a,nativeCaps:o,wireable:s,composed:new Set((t?.features??[]).map(e=>e.cap))}}function If(e,t,n){let r=t.kind===`known`&&t.value.has(`consumables`),i=Xa(r?{deviceId:e,cap:go,path:Ta}:null);return ho(t,n,r?i:null)}function Lf({blockId:e,onClose:t}){let{t:n}=Q();return i(Ti,{open:e!==null,onClose:t,title:n(`build.customDeviceTab.editComposedDevice`,`Edit composed device`),icon:ve,width:`xl`,testId:`composed-device-editor`,fill:!0,children:e!==null&&i(Ao,{blockId:e,fillHeight:!0})})}function Rf(e,t){switch(e.kind){case`group`:return e.active===null?t(`helper.aggregate.${e.aggregate}`):t(`helper.active.${e.active}`);case`statistic`:return t(`helper.statName.${e.stat}`);case`integral`:case`threshold`:case`derivative`:case`grid`:case`terminal`:return t(`helper.template.${e.kind}`);case`arithmetic`:return t(`helper.template.${e.op}`);case`expression`:return e.expr}}function zf(e,t){switch(e.kind){case`integral`:return[{label:t(`helper.reset`),value:t(`helper.resetName.${e.reset}`)}];case`threshold`:return[{label:t(`helper.highEdge`),value:String(e.high)},{label:t(`helper.lowEdge`),value:String(e.low)}];case`derivative`:return[{label:t(`helper.per`),value:t(`helper.perName.${e.per}`)}];default:return[]}}function Bf({draft:t,device:n,onEdit:r}){let{t:a,i18n:o}=Q(),s=Yi(),c=jo(t),l=zf(t,e=>a(e));return i(Nn,{headingId:`helper-summary-${n.id}`,title:a(`customize.composed.helper.title`),testId:`helper-summary`,actions:e(X,{variant:`outline`,size:`sm`,onClick:r,"data-testid":`helper-summary-edit`,children:[i(V,{className:`h-3 w-3`,"aria-hidden":!0}),a(`common.edit`)]}),children:e(`div`,{className:f,children:[i(Wi,{label:a(`customize.composed.helper.function`),children:Rf(t,e=>a(e))}),l.map(e=>i(Wi,{label:e.label,children:e.value},e.label)),c.length>0&&i(Wi,{label:a(`customize.composed.helper.members`),children:i(`ul`,{className:`flex flex-col gap-0.5`,"data-testid":`helper-summary-members`,children:c.map(t=>{let n=s.data?.find(e=>e.addonId===t.source.addonId&&e.stableId===t.source.stableId);return e(`li`,{className:`flex flex-wrap items-baseline gap-x-1.5`,children:[n===void 0?i(`span`,{children:t.source.stableId}):i(Qr,{device:n,form:`compact`}),i(`span`,{className:`text-foreground-muted`,children:qa(t.cap,t.fieldPath,o.language)})]},`${t.source.addonId}:${t.source.stableId}:${t.cap}:${t.fieldPath}`)})})})]})})}c();function Vf({device:t}){let{t:n}=Q(),r=t.stableId.startsWith(`composed-`)?t.stableId.slice(dt.length):null,a=Oi({blockId:r??``},{enabled:r!==null}),s=Fr(),[c,l]=o(!1),d=Ff(t,null),f=Pf(t.id,!1),p=If(t.id,d.nativeCaps,d.wireable);if(r===null)return i(`p`,{className:`text-xs text-foreground-subtle`,children:n(`customize.composed.missingBlock`)});if(a.status===`pending`)return i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:n(`customize.loadingDevice`)});if(a.status===`error`)return i(q,{title:n(`customize.composed.loadFailed`),message:a.error.message,onRetry:()=>void a.refetch()});if(a.data.state===`not-loaded`)return i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:n(`customize.status.notLoaded`,{reason:a.data.reason})});let m=a.data.view;if(m===null)return i(`p`,{className:`text-xs text-foreground-subtle`,children:n(`customize.composed.notFound`)});let h=rt(m.block);if(h===null)return i(`p`,{className:`text-xs text-foreground-subtle`,children:n(`compositionEditor.notComposition`)});let g={target:{addonId:t.addonId,stableId:t.stableId},state:{kind:`present`,view:m,composition:h},saving:s.isPending,save:async e=>{let t=e??{...h,features:[]};try{return await s.mutateAsync({blockId:m.block.id,expectedUpdatedAt:m.block.updatedAt,block:{composition:t}}),await a.refetch(),{kind:`saved`}}catch(e){return{kind:`refused`,reason:e instanceof Error?e.message:String(e)}}}},_={deviceType:t.type,composable:d.composable,nativeCaps:d.nativeCaps,cameraSensors:`absent`},v=wo(h)?vo(h.helper,t.name,t.location??``):null;return e(`div`,{className:`flex flex-col gap-3`,children:[i(Fs,{device:t}),wo(h)&&!Tt(h.helper)&&v===null&&i(`p`,{role:`alert`,children:n(`helper.unreadable`)}),v!==null&&e(u,{children:[i(Bf,{draft:v,device:t,onEdit:()=>l(!0)}),i(Lf,{blockId:c?m.block.id:null,onClose:()=>{l(!1),a.refetch()}})]}),wa(h)===`incomplete`&&i(K,{variant:`warning`,children:n(`customize.blockStatus.incomplete`)}),i(mf,{device:t,handle:g,facts:_,sensors:f,defaults:p}),i(Df,{device:t})]})}function Hf({deviceId:e}){let{t}=Q(),n=wn({deviceId:e}),r=n.data;if(r==null)return n.status===`error`?i(q,{title:t(`customize.deviceUnreadable`),message:n.error?.message??``,onRetry:()=>void n.refetch()}):r===null?i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:t(`customize.noSuchDevice`,{deviceId:e})}):i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:t(`customize.loadingDevice`)});let a=r.addonId===`composer`?i(Vf,{device:r}):i(Uf,{device:r,target:{addonId:r.addonId,stableId:r.stableId}});return i(Zi,{deviceId:r.id,seed:{name:r.name,location:r.location??``,role:r.role??null,display:r.display,tags:r.tags},children:a})}function Uf({device:t,target:n}){let r=kf(n),a=Mr(`composer`),{t:o}=Q(),s=Pf(t.id,t.type===U.Camera),c=Ff(t,$(r.state)),l=If(t.id,c.nativeCaps,c.wireable),u={deviceType:t.type,composable:c.composable,nativeCaps:c.nativeCaps,cameraSensors:s.presence};return e(`div`,{className:`flex flex-col gap-3`,children:[i(Fs,{device:t}),a===`absent`&&i(`p`,{role:`alert`,className:`text-xs text-warning`,children:o(`customize.composerAbsent`)}),r.state.kind!==`none`&&i(Wf,{state:r.state}),i(mf,{device:t,handle:r,facts:u,sensors:s,defaults:l}),i(Df,{device:t})]})}function Wf({state:t}){let{t:n}=Q();switch(t.kind){case`pending`:return i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:n(`customize.status.pending`)});case`unknown`:return i(q,{title:n(`customize.status.unknownTitle`),message:t.reason});case`not-loaded`:return i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:n(`customize.status.notLoaded`,{reason:t.reason})});case`none`:return null;case`present`:{let r=t.view.block;return e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(K,{variant:r.status===`running`?`success`:r.status===`failed`?`danger`:`warning`,children:n(`customize.blockStatus.${r.status}`)}),!r.enabled&&i(K,{variant:`default`,children:n(`customize.status.off`)}),r.lastError!==void 0&&i(`span`,{className:`text-[11px] text-foreground-muted break-words`,children:r.lastError}),t.view.state.kind===`unreachable`&&i(`span`,{className:`text-[11px] text-warning`,children:n(`customize.status.composerUnreachable`,{reason:t.view.state.error})})]})}}}function Gf({deviceId:t}){let n=Ai(xe().trpcClient,t);return n===null?null:e(`a`,{href:n.url,target:`_blank`,rel:`noopener noreferrer`,title:`${n.label} — ${n.host}`,className:`inline-flex items-center gap-1.5 rounded-lg px-2 sm:px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[i(ye,{className:`h-3.5 w-3.5`}),i(`span`,{className:`hidden sm:inline`,children:n.label})]})}function Kf({deviceId:e,widgets:t}){return t.length===0?null:i(`div`,{className:`flex flex-col gap-3 px-3 pb-3 sm:px-4 sm:pb-4`,"data-testid":`device-hero-widgets`,children:t.map(t=>{let n=i(mn,{widgetId:t.widgetId,deviceId:t.deviceId});return i(`div`,{children:t.deviceId===e?n:i(Pr,{deviceId:t.deviceId,children:n})},t.widgetId)})})}var qf={[U.Sensor]:[`host/power-meter-line`]};function Jf(e){let t=Object.values(U).find(t=>t===e);return t===void 0?[]:qf[t]??[]}function Yf(e){return e.sections.filter(e=>e.location===`hero`).flatMap(t=>t.fields.flatMap(n=>{if(typeof n!=`object`||!n)return[];let r=Reflect.get(n,`type`),i=Reflect.get(n,`widgetId`);return r!==`widget`||typeof i!=`string`||i.length===0?[]:[{widgetId:i,deviceId:e.deviceId,order:t.order??0}]}))}function Xf(e){let t=new Set(e.drawnByHero??[]),n=Yf(e).filter(e=>!t.has(e.widgetId)),r=new Set(n.map(e=>e.widgetId)),i=e.child===void 0?[]:Yf(e.child),a=[...n,...i.filter(e=>!r.has(e.widgetId))],o=new Set;return a.filter(e=>o.has(e.widgetId)?!1:(o.add(e.widgetId),!0)).sort((e,t)=>e.order-t.order)}var Zf=`overview`;function Qf(e,t){return e.some(e=>e.id===t)?t:Zf}function $f({deviceId:t}){let{t:n}=Q(),r=l(),a=Number.isFinite(t),{data:o}=wn({deviceId:t},{enabled:a}),s=typeof o?.type==`string`?o.type:`camera`;Ir([`deviceManager`,`getBindings`],[`capability.binding-changed`]);let{data:c,isLoading:u,isError:d,error:f}=pn({deviceId:t},{enabled:a}),{data:p}=Wt({deviceType:s},{enabled:!!s}),m=Vn({onSuccess:()=>{r.invalidateQueries({queryKey:[[`deviceManager`,`getBindings`]]})}});if(u)return i(`div`,{className:`p-4`,children:i(`div`,{className:`h-20 rounded-lg border border-border bg-surface animate-pulse`})});if(d)return e(`div`,{className:`p-4 text-xs text-red-400`,children:[n(`device.bindingsTab.failedToLoadBindings`,`Failed to load bindings:`),` `,f instanceof Error?f.message:String(f)]});let h=new Map,g={};for(let e of p??[])g[e.capName]=e.wrappers;for(let e of c?.entries??[])h.set(e.capName,{...e,wrappers:g[e.capName]??[]});for(let e of p??[])h.has(e.capName)||h.set(e.capName,{capName:e.capName,kind:`unbound`,providerAddonId:``,providerNodeId:``,nativeAddonId:``,wrappers:e.wrappers});let _=[...h.values()].toSorted((e,t)=>e.capName.localeCompare(t.capName));if(_.length===0)return e(`div`,{className:`flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle`,children:[i(ve,{className:`h-8 w-8 opacity-40`}),i(`p`,{className:`text-xs`,children:n(`device.bindingsTab.noCapabilityProvidersApplicableTo`,`No capability providers applicable to this device yet.`)}),i(`p`,{className:`text-[10px] opacity-60`,children:n(`device.bindingsTab.nativeProvidersShowUpHere`,`Native providers show up here as soon as the owning addon registers them.`)})]});let v=_.filter(e=>e.kind!==`unbound`).length,y=[{key:`capability`,header:n(`device.bindingsTab.capability`,`Capability`),render:e=>i(`span`,{className:`font-mono text-foreground`,children:e.capName})},{key:`kind`,header:n(`device.bindingsTab.kind`,`Kind`),render:e=>i(ep,{kind:e.kind})},{key:`provider`,header:n(`device.bindingsTab.activeProvider`,`Active Provider`),render:e=>i(`span`,{className:`font-mono text-foreground-subtle`,children:e.providerAddonId||i(`span`,{className:`opacity-40`,children:`—`})})},{key:`node`,header:n(`device.bindingsTab.node`,`Node`),render:e=>e.providerNodeId?i(tp,{nodeId:e.providerNodeId}):i(`span`,{className:`text-[10px] opacity-40`,children:`—`})},{key:`native`,header:n(`device.bindingsTab.kindNative`,`Native`),render:e=>i(`span`,{className:`font-mono text-foreground-subtle`,children:e.nativeAddonId||i(`span`,{className:`opacity-40`,children:`—`})})},{key:`wrapper`,header:n(`device.bindingsTab.wrapper`,`Wrapper`),render:e=>{let n=e.kind===`wrapped`?e.providerAddonId:null;return i(np,{wrappers:e.wrappers,activeWrapperId:n,disabled:m.isPending,onPick:r=>{let i=n===r;m.mutate({deviceId:t,capName:e.capName,wrapperAddonId:r,active:!i})}})}}];return e(`div`,{className:`flex flex-col gap-3 p-1`,children:[i(`div`,{className:`text-[11px] text-foreground-subtle`,children:i(ca,{i18nKey:`device.bindingsTab.boundSummary`,count:_.length,values:{bound:v},components:{b:i(`span`,{className:`font-medium text-foreground`}),em:i(`em`,{})}})}),i(Qt,{columns:y,rows:_,rowKey:e=>e.capName,minWidthPx:720})]})}function ep({kind:t}){let{t:n}=Q();return t===`native`?e(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-success/30 text-success bg-success/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[i(k,{className:`h-3 w-3`}),n(`device.bindingsTab.kindNative`)]}):t===`wrapped`?e(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-primary/30 text-primary bg-primary/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[i(Bt,{className:`h-3 w-3`}),n(`device.bindingsTab.wrapped`)]}):t===`linked`?e(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-warning/30 text-warning bg-warning/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[i(_,{className:`h-3 w-3`}),n(`device.bindingsTab.linked`)]}):e(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border text-foreground-subtle/70 px-1.5 py-0.5 text-[10px] font-medium`,children:[i(A,{className:`h-3 w-3`}),n(`common.unbound`)]})}function tp({nodeId:e}){return i(`span`,{className:`inline-flex items-center rounded-md border border-border px-1.5 py-0.5 font-mono text-[10px] ${e===`hub`?`text-foreground-subtle`:`text-foreground`}`,children:e})}function np({wrappers:t,activeWrapperId:n,disabled:r,onPick:a}){let{t:o}=Q();return t.length===0?i(`span`,{className:`text-[10px] opacity-40`,children:o(`device.bindingsTab.noneAvailable`,`none available`)}):i(`div`,{className:`flex flex-wrap gap-1`,children:t.map(t=>{let s=t===n;return e(X,{variant:`unstyled`,disabled:r,onClick:()=>a(t),title:s?o(`device.bindingsTab.clickToDeactivateRevertTo`,`Click to deactivate (revert to native)`):o(`device.bindingsTab.activateWrapper`,`Activate wrapper {{wrapperId}}`,{wrapperId:t}),className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[10px] transition-colors disabled:opacity-50 ${s?`border-primary/40 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[i(s?de:y,{className:`h-3 w-3`}),t]},t)})})}function rp({deviceId:t,activeSubTab:n,onSubTabChange:r,deviceType:a,isAdmin:o}){return e(`div`,{className:`flex flex-col gap-3`,children:[Ji(a,o)&&i(Yr,{deviceId:t,readOnly:!0}),i(ma,{deviceId:t,activeSubTab:n,onSubTabChange:r})]})}c();var ip=[[`pipelineOrchestrator`,`getCameraDetectionSource`]];function ap(e){let t=l(),n=Kn({deviceId:e},{refetchOnMount:`always`}),i=Rr(),[a,s]=o(null),[c,u]=o(null),d=r(async n=>{u(null),s(n);try{await i.mutateAsync({deviceId:e,source:n}),await t.invalidateQueries({queryKey:ip})}catch(e){u(e instanceof Error?e.message:`Could not change the root detector`),await t.invalidateQueries({queryKey:ip})}finally{s(null)}},[e,i,t]),f=n.data??null;return{view:f,isLoading:n.isLoading,source:a??f?.source??null,saving:a!==null,error:c,pick:d}}var op=`object-detection`;function sp(e){return[e.addonId,...e.children.flatMap(sp)]}function cp(e,t){if(e===`pipeline`)return new Set;let n=lp(t,op);return n===void 0?new Set:new Set(e===`onboard`?[n.addonId]:sp(n))}function lp(e,t){for(let n of e){if(n.addonId===t)return n;let e=lp(n.children,t);if(e!==void 0)return e}}function up(e,t){return e===`onboard`?Z.t(`helpers.detectionSourceModel.badgeCameraAi`):t===`object-detection`?Z.t(`helpers.detectionSourceModel.badgeNoRoot`):Z.t(`helpers.detectionSourceModel.badgeIdle`)}function dp(e){switch(e){case`pipeline`:return Z.t(`helpers.detectionSourceModel.explainPipeline`);case`onboard`:return Z.t(`helpers.detectionSourceModel.explainOnboard`);case`none`:return Z.t(`helpers.detectionSourceModel.explainNone`)}}function fp(e){switch(e){case`boxed`:return``;case`while-streaming`:return Z.t(`helpers.detectionSourceModel.geometryWhileStreaming`);case`flag-only`:return Z.t(`helpers.detectionSourceModel.geometryFlagOnly`);case`unknown`:return Z.t(`helpers.detectionSourceModel.geometryUnknown`)}}function pp(e,t){return e===`onboard`?Z.t(`helpers.detectionSourceModel.noticeOnboard`):t===`object-detection`?Z.t(`helpers.detectionSourceModel.noticeNoRoot`):Z.t(`helpers.detectionSourceModel.noticeIdle`)}var mp=[`pl-2`,`pl-6`,`pl-10`,`pl-14`],hp={detector:`success`,cropper:`info`,classifier:`primary`,refiner:`warning`,"audio-classifier":`neutral`};function gp(e){return mp[Math.min(e,mp.length-1)]??`pl-2`}function _p(e){return e.zoneDriven?{kind:`zone-driven`}:{kind:`gate`,effectiveOn:e.ownOn,defaultOn:e.defaultOn,explicit:e.choice!==`auto`}}function vp(e,t,n){return e.kind===`parent`?n:up(e.source,t)}function yp({inputs:t,outputs:n}){return t.length===0&&n.length===0?null:e(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[t.map(e=>i(K,{size:`sm`,variant:`info`,children:e},`in-${e}`)),t.length>0&&n.length>0&&i(`span`,{className:`text-[10px] text-foreground-subtle`,"aria-hidden":!0,children:`→`}),n.map(e=>i(K,{size:`sm`,variant:`success`,children:e},`out-${e}`))]})}function bp({rows:t,label:n,selectedId:r,busy:a,onOpen:o,onSet:s}){let{t:c}=Q(),l=e=>{switch(e){case`detector`:return c(`device.cameraStepInspector.kindDetector`,`detector`);case`cropper`:return c(`device.cameraStepInspector.kindCropper`,`cropper`);case`classifier`:return c(`device.cameraStepInspector.kindClassifier`,`classifier`);case`refiner`:return c(`device.cameraStepInspector.kindRefiner`,`refiner`);case`audio-classifier`:return c(`device.cameraStepInspector.kindAudio`,`audio`)}},u=c(`device.cameraStepInspector.offBecauseParent`,`Off because its parent is off`);return i(`ul`,{"aria-label":n,className:`divide-y divide-border rounded-md border border-border`,children:t.map(t=>{let n=t.stepId===r,c=t.blocked===null?null:vp(t.blocked,t.stepId,u);return e(`li`,{"data-step":t.stepId,"data-runs":t.runs?`yes`:`no`,className:`flex flex-wrap items-center gap-x-2 gap-y-1.5 py-2 pr-2 ${gp(t.depth)} ${n?`bg-primary/10`:t.runs?``:`bg-muted/40`}`,children:[e(`button`,{type:`button`,"aria-expanded":n,onClick:()=>o(t.stepId),className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 text-left`,children:[i(`span`,{className:`text-sm font-medium ${t.runs?`text-foreground`:`text-foreground-muted`}`,children:t.name}),i(K,{size:`sm`,variant:hp[t.kind],children:l(t.kind)}),i(yp,{inputs:t.inputs,outputs:t.outputs}),c!==null&&i(`span`,{className:`text-[11px] text-warning`,children:c})]}),i(yn,{gate:_p(t),busy:a,onSet:e=>s(t.stepId,e)})]},t.stepId)})})}function xp(e,t){let n=e?.[t];return n===void 0?`auto`:n?`on`:`off`}function Sp(e,t){return e===`auto`?t:e===`on`}function Cp(e,t,n){return e!==`onboard`&&e!==`none`||!n.has(t)?null:{kind:`source`,source:e}}function wp(e,t,n,r,i){let a=e.zoneDrivenIds??new Set;return t.flatMap(t=>{let o=a.has(t.addonId),s=xp(e.toggles,t.addonId),c=e.defaults[t.addonId]??!0,l=o||Sp(s,c),u=r===null?Cp(e.source,t.addonId,i):{kind:`parent`,ancestorId:r.stepId},d={stepId:t.addonId,name:t.addonName,kind:t.slot,depth:n,inputs:t.inputClasses,outputs:t.outputClasses,choice:s,defaultOn:c,ownOn:l,runs:u===null&&l,blocked:u,zoneDriven:o},f=l?r:{stepId:t.addonId};return[d,...wp(e,t.children,n+1,f,i)]})}function Tp(e){let t=e.source===null?new Set:cp(e.source,e.tree);return wp(e,e.tree,0,null,t)}function Ep({source:t,geometry:n,saving:r,error:a,onPick:o}){let{t:s}=Q(),c=n===`flag-only`,l=fp(n);return e(`section`,{"aria-label":s(`device.detectionSourceControl.rootDetector`,`Root detector`),"aria-busy":r,className:`space-y-1.5 rounded-md border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[i(`h3`,{className:M,children:s(`device.detectionSourceControl.rootDetector`,`Root detector`)}),i(xi,{label:s(`device.detectionSourceControl.rootDetector`,`Root detector`),value:t,onChange:e=>{!r&&e!==t&&o(e)},options:[{value:`pipeline`,label:s(`device.detectionSourceControl.thisNode`,`This node`)},{value:`onboard`,label:s(`device.detectionSourceControl.cameraOnboardAi`,`Camera onboard AI`),disabled:c&&t!==`onboard`,reason:l},{value:`none`,label:s(`device.detectionSourceControl.none`,`None`)}]}),r&&i(`span`,{className:`text-[10px] text-foreground-subtle`,children:s(`device.detectionSourceControl.saving`,`Saving…`)})]}),e(`p`,{className:Se,children:[dp(t),` `,s(`device.detectionSourceControl.oneRoot`)]}),l!==``&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:l}),a!==null&&i(`p`,{role:`alert`,className:`text-[11px] text-danger`,children:a})]})}c();var Dp=new Set([`package-detection`]),Op=`/system/pipeline?view=nodes`;function kp(e){return Object.fromEntries(e.slots.flatMap(e=>e.addons.map(e=>[e.id,e.enabledByDefault??!0])))}function Ap({deviceId:a}){let{t:c}=Q(),u=re(),d=Gn(),f=l(),p=xe().trpcClient,m=t(null),h=t(null),g=ln({deviceId:a},{refetchOnMount:`always`}),_=kr(void 0,{refetchOnMount:`always`});Ir([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`]);let{nodes:v}=Yn(),y=n(()=>{let e=new Set((_.data??[]).map(e=>e.nodeId));return v.filter(t=>t.isOnline&&e.has(t.id)).map(e=>({id:e.id,name:e.name}))},[_.data,v]),b=y.map(e=>e.id).join(`,`),x=s({enabled:y.length>0,queryKey:[[`pipelineExecutor`,`getSchema`],`camera-step-schemas`,b],queryFn:async()=>{let e={};for(let t of y)try{e[t.id]=await p.pipelineExecutor.getSchema.query({nodeId:t.id})}catch{}return e}}),S=r(()=>{f.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]})},[f]),C=Hr({onSuccess:S}),w=Ei(),[T,E]=o(null),[D,O]=o(!1),[k,A]=o(null),M=ap(a),N=x.data??{},P=g.data??null,F=y.map(e=>N[e.id]).find(e=>e!==void 0)??null,ee=n(()=>F?Xt(F):[],[F]),te=n(()=>F===null?[]:Tp({tree:ee,toggles:P?.stepToggles,defaults:kp(F),source:M.source,zoneDrivenIds:Dp}),[ee,F,P?.stepToggles,M.source]),{selection:I,open:ne,close:ie}=Jo(n(()=>te.map(e=>e.stepId),[te]),[]),L=y[0]?.id,ae=r(async e=>{if(T!==null){if(!await u({title:c(`stepInspector.stepMatrixFrame.discardUnsavedChanges`,`Discard unsaved changes?`),message:c(`stepInspector.stepMatrixFrame.thisStepHasChangesThat`,`This step has changes that are not saved yet.`),confirmLabel:c(`stepInspector.stepMatrixFrame.discard`,`Discard`),variant:`danger`}))return;E(null)}e()},[u,T,c]),R=e=>{e!==I.stepId&&ae(()=>ne({stepId:e}))},z=()=>{ae(()=>ie())};if(_.isLoading||y.length>0&&x.isLoading)return i(`div`,{className:`animate-pulse p-4 text-xs text-foreground-subtle`,children:c(`device.cameraStepInspector.loadingPipeline`,`Loading pipeline…`)});if(y.length===0)return i(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:c(`device.cameraStepInspector.noPipelineNodeIsOnline`,`No pipeline node is online.`)});if(F===null)return i(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:c(`device.cameraStepInspector.catalogUnavailable`,`Catalog unavailable.`)});let oe=e=>_.data?.find(e=>e.nodeId===L)?.settings.stepSettings?.[e]??{},B=te.find(e=>e.stepId===I.stepId)??null,se=B===null?null:qo(F,B.stepId),ce=d?i(dr,{onClick:z}):i(J,{icon:j,variant:`ghost`,size:`sm`,"aria-label":c(`common.close`,`Close`),onClick:z});return e(`div`,{ref:m,className:`space-y-2`,children:[M.view?.onboard.available===!0&&M.source!==null&&i(Ep,{source:M.source,geometry:M.view.onboard.geometry,saving:M.saving,error:M.error,onPick:e=>void M.pick(e)}),i(`p`,{className:Se,children:i(ca,{i18nKey:`device.cameraStepInspector.modelsChosenByAccelerators`,components:{nodes:i(fa,{to:Op,className:`font-medium text-primary hover:underline`})}})}),I.staleStepId!==null&&i(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-1.5 text-[11px] text-warning`,children:c(`stepInspector.stepMatrixFrame.staleStep`,{id:I.staleStepId})}),i(bp,{rows:te,label:c(`device.cameraStepInspector.detectionStepsOfThisCamera`,`Detection steps of this camera`),selectedId:I.stepId,busy:C.isPending,onOpen:R,onSet:(e,t)=>C.mutate({deviceId:a,addonId:e,enabled:t})}),i(Tn,{open:B!==null&&se!==null,anchor:m,onClose:z,label:c(`stepInspector.stepMatrixFrame.stepSettings`,`Step settings`),children:B!==null&&se!==null&&i(jp,{addon:se,nodeBag:oe(B.stepId),storedCamera:P?.stepSettings?.[B.stepId],draft:T?.stepId===B.stepId?T:null,saving:D,status:k,notice:B.blocked?.kind===`source`?pp(B.blocked.source,B.stepId):null,closeButton:ce,onEscape:z,headingRef:e=>{h.current=e},onDraft:e=>{A(null),E({stepId:B.stepId,camera:e})},onDiscard:()=>E(null),onSave:async e=>{O(!0);try{await w.mutateAsync({deviceId:a,addonId:B.stepId,settings:Object.keys(e).length>0?{...e}:null}),E(null),A({kind:`saved`})}catch(e){A({kind:`error`,error:e instanceof Error?e.message:c(`device.cameraStepInspector.saveFailed`)})}finally{O(!1),S()}}})})]})}function jp({addon:t,nodeBag:n,storedCamera:r,draft:a,saving:o,status:s,notice:c,closeButton:l,onEscape:u,headingRef:d,onDraft:f,onDiscard:p,onSave:m}){let{t:h}=Q(),g=zr(t),_=Xo(g),v=Yo(g),y=a?.camera??r,b=a!==null&&!Ct(a.camera,r??{});return i(ir,{ref:d,title:h(`device.cameraStepInspector.thisCamera`,`{{name}} · this camera`,{name:t.name}),subtitle:t.slot,leading:l,onEscape:u,..._.length>0?{saveBar:{dirtyCount:+!!b,saving:o,status:s?.kind??null,...s?.error===void 0?{}:{error:s.error},onSave:()=>void m(a?.camera??r??{}),onDiscard:p,scope:i(`p`,{className:Se,children:h(`device.cameraStepInspector.appliesToAllAcceleratorsOf`,`Applies to: all accelerators of this camera.`)})}}:{},children:e(`div`,{className:`space-y-3`,children:[c!==null&&i(`p`,{role:`note`,className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-1.5 text-[11px] text-warning`,children:c}),_.length>0?i(Mp,{addon:t,fields:_,nodeBag:n,cameraBag:y,onChange:f}):i(`p`,{className:Se,children:h(`device.cameraStepInspector.noCameraSettings`,`This step has no settings on this camera.`)}),v&&i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-only-thresholds`,children:h(`device.cameraStepInspector.thresholdsAreTheAccelerators`,`Confidence thresholds belong to the model, so they are set on the accelerator that runs it (Pipeline → Nodes), not per camera.`)})]})})}function Mp({addon:e,fields:t,nodeBag:n,cameraBag:r,onChange:a}){let{t:o}=Q();return i(zi,{addon:e,fields:t,layers:{node:n,...r===void 0?{}:{camera:r}},target:`camera`,labels:{camera:o(`device.cameraStepInspector.layerCamera`,`This camera`),node:o(`device.cameraStepInspector.layerNode`,`Node`)},modelId:e.defaultModelId,onChangeLayer:a})}function Np(e,t,n){return{id:e,get label(){return Z.t(t)},icon:n}}var Pp=[Np(`zones`,`helpers.detectionSettingsGroups.zones`,`shapes`),Np(`object-detection`,`helpers.detectionSettingsGroups.objectDetection`,`scan-search`),Np(`tracking`,`helpers.detectionSettingsGroups.tracking`,`route`),Np(`motion`,`helpers.detectionSettingsGroups.motion`,`activity`),Np(`stationary`,`helpers.detectionSettingsGroups.stationary`,`square-parking`),Np(`audio`,`helpers.detectionSettingsGroups.audio`,`volume-2`),Np(`cluster`,`helpers.detectionSettingsGroups.cluster`,`server`)],Fp={"pipeline-object-detection":`object-detection`,"detection-sensitivity":`object-detection`,tracking:`tracking`,"motion-tuning":`motion`,"stationary-objects":`stationary`,occupancy:`stationary`,zones:`zones`,"pipeline-audio":`audio`,"cluster-assignment":`cluster`,"orchestrator-live":`cluster`};function Ip(e){return Fp[e]??`object-detection`}c();var Lp=`steps`,Rp=`settings`,zp=`object-detection`;function Bp(e){return e.location===`top-tab`&&(e.tab===`detection-pipeline`||e.tab===`zones`)}var Vp={groupOf:e=>Ip(e.id),tabs:Pp};function Hp({deviceId:e,activeSubTab:t,onSubTabChange:r}){let{t:a}=Q();return i(ma,{deviceId:e,sectionFilter:Bp,subTabGrouping:Vp,leadingTabs:n(()=>[{id:Lp,label:a(`device.detectionPipelineTab.steps`,`Steps`),content:i(Ap,{deviceId:e})}],[e,a]),activeSubTab:t===Rp?zp:t,onSubTabChange:r})}var Up=`Notifications`,Wp={i18nKey:`device.deviceNotificationMute.cameraCostWhenOff`,text:`This camera never notifies — no rule, no target, no alarm. Existing events, tracks and recordings are unaffected.`},Gp={i18nKey:`device.deviceNotificationMute.deviceCostWhenOff`,text:`This device never notifies — no rule, no target, no alarm.`};function Kp(e){let{mutedDeviceIds:t,deviceId:n}=e,r=t===null?null:!t.includes(n),i=e.pendingOn??null;return{label:Up,on:r===null?null:i??r,available:r!==null,costWhenOff:e.isCamera?Wp:Gp}}function qp(e,t){return!e.available||e.on===null?null:{deviceId:t,muted:e.on}}c();function Jp(e){if(typeof e!=`object`||!e)return null;let t={...e}.mutedDeviceIds;return Array.isArray(t)?t.filter(e=>typeof e==`number`):null}function Yp({deviceId:t,isCamera:n}){let{t:a}=Q(),s=l(),c=Number.isFinite(t),[u,d]=o(null),[f,m]=o(null),h=Kp({mutedDeviceIds:Jp(Wr({},{enabled:c}).data),deviceId:t,isCamera:n,pendingOn:f}),g=a(h.costWhenOff.i18nKey,h.costWhenOff.text),_=pi({onError:e=>{console.error(`[DeviceNotificationMute] mute write failed — reverting`,{tags:{deviceId:t},meta:{error:e instanceof Error?e.message:String(e)}}),m(null),d(e instanceof Error?e.message:String(e)),s.invalidateQueries({queryKey:[[`notificationRules`,`listDeviceMutes`]]})},onSuccess:()=>{d(null),m(null),s.invalidateQueries({queryKey:[[`notificationRules`]]})}}),v=r(()=>{let e=qp(h,t);e!==null&&(m(!e.muted),_.mutate(e))},[t,_,h]),y=h.on===null,b=h.on===!1,x=b?T:p;return e(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[e(`div`,{className:`border-b border-border px-4 py-2 flex items-center justify-between gap-2`,children:[i(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:a(`device.deviceNotificationMute.notifications`,`Notifications`)}),b&&i(`span`,{className:`rounded bg-warning/20 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-warning`,children:a(`common.muted`)})]}),e(`div`,{className:`px-4 py-3 flex items-start gap-3`,children:[e(X,{variant:`unstyled`,type:`button`,role:`switch`,"aria-label":h.label,"aria-checked":h.on===!0,disabled:!h.available||_.isPending,onClick:v,title:y?a(`device.deviceNotificationMute.notificationMuteStateUnknownThe`,`Notification mute — state unknown; the notification centre did not answer.`):b?a(`device.deviceNotificationMute.muted`,`Muted. {{costWhenOff}}`,{costWhenOff:g}):a(`device.deviceNotificationMute.notifyingMutingIt`,`Notifying. Muting it: {{costWhenOff}}`,{costWhenOff:g}),className:`inline-flex items-center gap-1.5 rounded-lg border px-2 py-1.5 text-[11px] font-medium transition-colors disabled:cursor-not-allowed ${u===null?y?`border-dashed border-border text-foreground-subtle/50`:b?`border-warning/40 text-warning hover:bg-warning/10`:`border-success/30 text-success hover:bg-success/10`:`border-danger/50 text-danger bg-danger/5`}`,children:[i(x,{className:`h-3.5 w-3.5`}),i(`span`,{children:y?a(`device.deviceNotificationMute.unknown`,`Unknown`):b?a(`device.deviceNotificationMute.muted2`,`Muted`):a(`device.deviceNotificationMute.notifying`,`Notifying`)})]}),i(`p`,{className:`flex-1 text-[11px] leading-relaxed text-foreground-subtle`,children:u===null?y?a(`device.deviceNotificationMute.theNotificationCentreDidNot`,`The notification centre did not answer, so this device’s mute state is unknown.`):g:a(`device.deviceNotificationMute.writeFailed`,`Write failed: {{failure}}`,{failure:u})})]})]})}c();function Xp({deviceId:t,template:n,members:a,fleet:s,fleetKind:c,snapshot:l,nameOf:d}){let{t:f}=Q(),[p,m]=o(()=>new Map),h=r((e,t)=>{m(n=>{if(rm(n.get(e),t))return n;let r=new Map(n);return r.set(e,t),r})},[]);if(n.family!==`actuator`)return null;let g=Oo(l),_=n.id!==`switch`,v=_?No(n.id,a.map(e=>p.get(nm(e))??{kind:`pending`})):null;return e(u,{children:[_&&a.map(e=>i(em,{member:e,row:tm(s,e),fleetKind:c,onRead:h},nm(e))),v!==null&&i(Zp,{view:v}),n.id===`lock`&&i(Qp,{deviceId:t}),e(`div`,{"data-testid":`helper-commands`,children:[i(`h3`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:f(`helper.commandTitle`)}),g.kind===`pending`&&i(`p`,{role:`status`,className:`mt-1 text-xs text-foreground-subtle`,children:f(`helper.reportingPending`)}),g.kind===`unavailable`&&i(q,{title:f(`helper.outputUnavailable`),message:g.message}),g.kind===`none`&&i(`p`,{className:`mt-1 text-xs text-foreground-muted`,children:f(`helper.commandNone`)}),g.kind===`rows`&&i($p,{view:g,nameOf:d})]})]})}function Zp({view:t}){let{t:n}=Q(),r=t.kind===`ready`?t.methods.filter(e=>e!==`switch.setState`):[];return e(`div`,{"data-testid":`helper-shared-caps`,children:[i(`h3`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:n(`helper.sharedCaps`)}),t.kind===`pending`&&i(`p`,{role:`status`,className:`mt-1 text-xs text-foreground-subtle`,children:n(`helper.sharedPending`)}),t.kind===`unavailable`&&i(`p`,{role:`status`,className:`mt-1 text-xs text-foreground-subtle`,children:n(`helper.sharedUnavailable`)}),t.kind===`ready`&&r.length===0&&i(`p`,{className:`mt-1 text-xs text-foreground-muted`,children:n(`helper.sharedNone`)}),t.kind===`ready`&&r.length>0&&e(`ul`,{className:`mt-1 flex flex-col gap-0.5 text-xs text-foreground`,children:[r.map(e=>i(`li`,{children:n(`helper.method.${e}`)},e)),t.modes.filter(e=>e.startsWith(`light-color`)).map(e=>i(`li`,{children:n(`helper.mode.${e}`)},e))]})]})}function Qp({deviceId:t}){let{t:n}=Q(),r=pr(),a=dn(),[s,c]=o(null);return e(`div`,{className:`flex flex-col gap-2`,"data-testid":`helper-lock-controls`,children:[e(`div`,{className:`flex flex-wrap gap-2`,children:[e(X,{variant:`outline`,"data-testid":`helper-lock-all`,disabled:r.isPending,onClick:()=>{c(null),r.mutateAsync({deviceId:t}).catch(e=>c(e instanceof Error?e.message:String(e)))},children:[i(v,{className:`h-4 w-4`,"aria-hidden":!0}),n(`helper.lockAll`)]}),i(Jt,{label:n(`helper.unlockAll`),icon:x,title:n(`helper.unlockTitle`),description:n(`helper.unlockBody`),confirmLabel:n(`helper.unlockConfirm`),triggerVariant:`outline`,action:()=>a.mutateAsync({deviceId:t,confirm:!0})})]}),s!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger`,children:s})]})}function $p({view:t,nameOf:n}){let{t:r}=Q();return i(`ul`,{className:`mt-1 flex flex-col gap-0.5 text-xs text-foreground`,"data-testid":`helper-command-rows`,children:t.rows.map(t=>e(`li`,{children:[n(t.deviceId),` — `,r(`helper.method.${t.cap}.${t.method}`),` —`,` `,t.ok?r(`helper.commandOk`):r(`helper.commandFailed`),t.error===null?``:` — ${t.error}`]},`${t.deviceId}:${t.cap}:${t.at}`))})}function em({member:e,row:t,fleetKind:n,onRead:r}){let i=nm(e),o=pn({deviceId:t?.id??0},{enabled:n===`answered`&&t!==null});return a(()=>{if(n!==`answered`){r(i,{kind:`pending`});return}if(t===null){r(i,{kind:`ready`,caps:[],features:[]});return}if(o.status===`pending`){r(i,{kind:`pending`});return}if(o.status===`error`){r(i,{kind:`error`});return}r(i,{kind:`ready`,caps:o.data.entries.map(e=>e.capName),features:[...t.features]})},[o.data,o.status,n,i,r,t]),null}function tm(e,t){let n=e.find(e=>e.addonId===t.source.addonId&&e.stableId===t.source.stableId);return n===void 0?null:{id:n.id,name:n.name,features:n.features}}function nm(e){return`${e.source.addonId}/${e.source.stableId}`}function rm(e,t){return e===void 0||e.kind!==t.kind?!1:e.kind!==`ready`||t.kind!==`ready`?!0:e.caps.join(`\0`)===t.caps.join(`\0`)&&e.features.join(`\0`)===t.features.join(`\0`)}function im({helper:t,snapshot:n}){let{t:r}=Q(),a=so(n),o=om(n,t);return i(Nn,{headingId:`helper-history-status`,title:r(`helper.template.${t.kind}`),icon:jt,testId:`helper-history-status`,children:e(`div`,{className:`${f} flex flex-col gap-3`,children:[o.kind===`pending`&&i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:r(`helper.outputPending`)}),o.kind===`number`&&i(gr,{value:am(t,o.value),label:r(`helper.output`)}),o.kind===`empty`&&i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`helper.noReading`)}),a.kind===`ready`&&a.excluded>0&&i(`p`,{className:`text-xs text-foreground-muted`,"data-testid":`helper-history-gaps`,children:r(`helper.gaps`,{count:a.excluded})}),a.kind===`unavailable`&&i(q,{title:r(`helper.outputUnavailable`),message:a.message})]})})}function am(e,t){if(e.kind!==`derivative`)return String(t);let n=St(e);return n===null?String(t):`${t} ${n}`}function om(e,t){if(e.kind===`pending`)return{kind:`pending`};if(e.kind!==`answered`)return{kind:`empty`};let n=t.kind===`statistic`||t.kind===`derivative`?{cap:`numeric-sensor`,field:`value`}:t.output===`energy`?{cap:`power-meter`,field:`energy`}:{cap:`meter`,field:`value`},r=e.caps[n.cap]?.[n.field];return typeof r==`number`&&Number.isFinite(r)?{kind:`number`,value:r}:{kind:`empty`}}function sm({helper:t,snapshot:n}){let{t:r}=Q(),a=um(n,t),o=t.kind===`arithmetic`?so(n):null;return i(Nn,{headingId:`helper-math-status`,title:r(`helper.template.${cm(t)}`),icon:E,testId:`helper-math-status`,children:e(`div`,{className:`${f} flex flex-col gap-3`,children:[a.kind===`pending`&&i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:r(`helper.outputPending`)}),a.kind===`number`&&i(gr,{value:String(a.value),label:r(`helper.output`)}),a.kind===`boolean`&&i(gr,{value:a.value?r(`helper.on`):r(`helper.off`),label:r(`helper.output`)}),a.kind===`empty`&&i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`helper.noReading`)}),o?.kind===`ready`&&i(`p`,{className:`text-sm text-foreground`,"data-testid":`helper-reporting`,children:r(`helper.reporting`,{included:o.included,total:o.total})}),o?.kind===`unavailable`&&i(q,{title:r(`helper.outputUnavailable`),message:o.message})]})})}function cm(e){return e.kind===`arithmetic`?e.op:e.kind}function lm(e){return e.kind===`threshold`||e.kind===`expression`&&e.output===`boolean`?{cap:`binary`,field:`on`}:{cap:`numeric-sensor`,field:`value`}}function um(e,t){if(e.kind===`pending`)return{kind:`pending`};if(e.kind!==`answered`)return{kind:`empty`};let n=lm(t),r=e.caps[n.cap]?.[n.field];return typeof r==`number`&&Number.isFinite(r)?{kind:`number`,value:r}:typeof r==`boolean`?{kind:`boolean`,value:r}:{kind:`empty`}}c();function dm({deviceId:t,stableId:n}){let{t:a}=Q(),s=n.startsWith(`composed-`)?n.slice(dt.length):null,c=Oi({blockId:s??``},{enabled:s!==null}),l=zn({deviceId:t},{enabled:s!==null}),u=Xn({projection:`slim`},{enabled:s!==null}),[d,p]=o(()=>new Map),m=ar(),h=Hi(),g=r((e,t)=>{p(n=>{let r=n.get(e);if(r?.name===t.name&&r.presence===t.presence)return n;let i=new Map(n);return i.set(e,t),i})},[]);if(s===null)return null;if(c.status===`pending`)return i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:a(`helper.checking`)});if(c.status===`error`)return i(q,{title:a(`helper.outputUnavailable`),message:c.error.message});if(c.data.state!==`loaded`||c.data.view===null)return null;let _=rt(c.data.view.block);if(_===null||!wo(_))return null;let v=_.helper;if(v.kind===`threshold`||v.kind===`arithmetic`||v.kind===`expression`)return i(sm,{helper:v,snapshot:hm(l.status,l.data,l.error?.message)});if(Qe(v))return i(im,{helper:v,snapshot:hm(l.status,l.data,l.error?.message)});if(v.kind!==`group`)return null;let y=ct(v.templateId);if(y===null)return null;let b=hm(l.status,l.data,l.error?.message),x=lo(b,y),S=so(b),C=u.status===`success`?u.data.map(gm):[],w=_m(u.status),T=fo(v.members.map(e=>d.get(mm(e))??{name:e.source.stableId,presence:`unknown`})),E=x.kind===`number`?x.unit===void 0?String(x.value):`${x.value} ${x.unit}`:x.kind===`boolean`?x.value?a(pm(y.id,`on`)):a(pm(y.id,`off`)):x.kind===`empty`?a(`helper.noReading`):null;return i(Nn,{headingId:`helper-group-status`,title:a(`helper.statusTitle`),icon:ve,testId:`helper-group-status`,children:e(`div`,{className:`${f} flex flex-col gap-3`,children:[v.members.map(e=>i(fm,{member:e,row:C.find(t=>t.addonId===e.source.addonId&&t.stableId===e.source.stableId)??null,fleetKind:w,isState:y.activeWhen!==void 0,onLive:g},mm(e))),x.kind===`pending`&&i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:a(`helper.outputPending`)}),x.kind===`unavailable`&&i(q,{title:a(`helper.outputUnavailable`),message:x.message}),E!==null&&i(gr,{value:E,label:a(`helper.template.${y.id}`)}),S.kind===`pending`&&i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:a(`helper.reportingPending`)}),S.kind===`unavailable`&&i(q,{title:a(`helper.outputUnavailable`),message:S.message}),S.kind===`absent`&&i(`p`,{role:`status`,className:`text-xs text-foreground-subtle`,children:a(`helper.reportingAbsent`)}),S.kind===`ready`&&i(`p`,{className:`text-sm text-foreground`,"data-testid":`helper-reporting`,children:a(`helper.reporting`,{included:S.included,total:S.total})}),S.kind===`ready`&&S.excluded>0&&e(`div`,{children:[i(`h3`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:a(`helper.excluded`)}),T.kind===`pending`?i(`p`,{role:`status`,className:`mt-1 text-xs text-foreground-subtle`,children:a(`helper.excludedPending`)}):T.names.length===0?i(`p`,{className:`mt-1 text-xs text-foreground-muted`,children:a(`helper.excludedUnnamed`)}):i(`ul`,{className:`mt-1 flex flex-col gap-0.5 text-xs text-foreground`,"data-testid":`helper-excluded`,children:T.names.map(e=>i(`li`,{children:e},e))})]}),i(Xp,{deviceId:t,template:y,members:v.members,fleet:C.map(e=>({id:e.id,name:e.name,addonId:e.addonId,stableId:e.stableId,features:e.features})),fleetKind:w,snapshot:b,nameOf:e=>{if(m===null)return C.find(t=>t.id===e)?.name??String(e);let t=m.byId.get(e);return t===void 0?String(e):hn(t,`compact`,m,h)}})]})})}function fm({member:e,row:t,fleetKind:n,isState:r,onLive:i}){let o=t?.online===!0,s=zn({deviceId:t?.id??0},{enabled:n===`answered`&&t!==null&&o}),c=io(s.status,s.status===`success`?Lo(s.data):void 0,e.cap,e.fieldPath,r),l=bo({fleet:n,deviceOnline:n===`answered`?t===null?null:t.online:!0,field:c}),u=t?.name??e.source.stableId,d=Zn(t?.id??0,`compact`,u),f=t===null?u:d,p=mm(e);return a(()=>{i(p,{name:f,presence:l})},[p,f,i,l]),null}function pm(e,t){return[`cover`,`valve`,`lock`,`media-player`,`climate`].includes(e)?`helper.state.${e}.${t}`:`helper.${t}`}function mm(e){return`${e.source.addonId}/${e.source.stableId}/${e.cap}.${e.fieldPath}`}function hm(e,t,n){return e===`pending`?{kind:`pending`}:e===`error`?{kind:`error`,message:n??``}:{kind:`answered`,caps:Lo(t)}}function gm(e){return{id:e.id,name:e.name,online:e.online,addonId:e.addonId,stableId:e.stableId,features:e.features??[]}}function _m(e){return e===`pending`?`pending`:e===`error`?`error`:`answered`}function vm(e,t){return{switchId:e,label:Ke[e].label,detail:t===void 0||t.length===0?null:t}}function ym(e){let t=new Map;for(let n of e.switches)n.deviceId===e.sourceId&&(t.has(n.switchId)||t.set(n.switchId,n));return t}function bm(e){let t=ym(e),n=new Set(e.sourceStillLive),r=e.sourceStillLive.map(e=>vm(e,t.get(e)?.detail)),i=[...t.values()].filter(e=>e.outcome===`not-offered`&&!n.has(e.switchId)).map(e=>vm(e.switchId,e.detail));return{inheritedId:e.sourceId,retiredId:e.targetId,swapped:e.swapped,verdict:r.length===0?`quiet`:`still-live`,stillLive:r,neverOffered:i}}c();function xm(e,t){return e.filter(e=>e.isCamera&&e.id!==t).map(e=>({id:e.id,name:e.name})).toSorted((e,t)=>e.name.localeCompare(t.name))}function Sm({deviceId:t,deviceName:r}){let{t:a}=Q(),s=re(),[c,l]=o(null),u=Xn({isCamera:!0,projection:`slim`}),d=Vr(),f=u.data!==void 0,p=n(()=>u.data===void 0?[]:xm(u.data,t),[u.data,t]),m=p.find(e=>e.id===c)??null,h=d.data===void 0?null:bm(d.data),_=d.error===null?null:d.error.message,v=async()=>{m===null||m.id===t||await s({title:a(`deviceMigrate.confirmTitle`,`Replace “{{source}}” with “{{target}}”?`,{source:r,target:m.name}),message:a(`deviceMigrate.confirmMessage`,`“{{target}}” takes over number {{sourceId}}. That number is what every recording, event, rule, zone and home-automation export of “{{source}}” is filed under, so all of it follows the number to the new hardware and keeps working. “{{source}}” is switched off and handed number {{targetId}} in exchange. This swaps two device identities and cannot be undone from here.`,{source:r,target:m.name,sourceId:t,targetId:m.id}),confirmLabel:a(`deviceMigrate.confirmAction`,`Migrate`),variant:`danger`})&&d.mutate({sourceId:t,targetId:m.id})};return e(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[e(`div`,{className:`min-w-0`,children:[i(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-foreground`,children:a(`deviceMigrate.title`,`Migrate to…`)}),i(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:a(`deviceMigrate.subtitle`,`Replace this camera with other hardware you have already adopted. The new camera inherits number {{deviceId}}, so recordings, rules and integrations follow it.`,{deviceId:t})})]}),e(`div`,{className:`flex shrink-0 items-center gap-2`,children:[e(L,{wrapperClassName:`inline-block w-auto`,"aria-label":a(`deviceMigrate.pickerLabel`,`Replacement camera`),disabled:!f||p.length===0||d.isPending,value:c===null?``:String(c),onChange:e=>{let t=e.target.value;l(t===``?null:Number(t))},children:[i(`option`,{value:``,children:f?a(`deviceMigrate.pickerPlaceholder`,`Select a camera…`):a(`deviceMigrate.pickerPending`,`Reading the fleet…`)}),p.map(t=>e(`option`,{value:String(t.id),children:[t.name,` (#`,t.id,`)`]},t.id))]}),e(X,{variant:`unstyled`,type:`button`,disabled:m===null||d.isPending,onClick:()=>{v()},className:`inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-surface disabled:opacity-50`,children:[i(g,{className:`h-3 w-3`}),d.isPending?a(`deviceMigrate.running`,`Migrating…`):a(`deviceMigrate.action`,`Migrate`)]})]})]}),f&&p.length===0&&i(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:a(`deviceMigrate.noTargets`,`No other camera is adopted, so there is nothing to migrate to.`)}),_!==null&&i(`p`,{className:`mt-2 text-[11px] text-danger`,children:a(`deviceMigrate.failed`,`Migration failed: {{error}}`,{error:_})}),h!==null&&i(Cm,{report:h})]})}function Cm({report:t}){let{t:n}=Q(),r=t.verdict===`quiet`;return e(`div`,{className:`mt-3 space-y-2 border-t border-border pt-3`,children:[i(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`deviceMigrate.swapped`,`The replacement now answers on number {{inheritedId}}; the old camera was handed number {{retiredId}}.`,{inheritedId:t.inheritedId,retiredId:t.retiredId})}),r?e(`div`,{className:`flex items-start gap-2 rounded-md border border-success/30 bg-success/5 px-3 py-2`,children:[i(F,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-success`}),i(`p`,{className:`text-[11px] leading-relaxed text-foreground`,children:n(`deviceMigrate.quiet`,`Every function on the replaced camera was switched off — the old hardware is quiet.`)})]}):e(`div`,{className:`rounded-md border border-warning/40 bg-warning/5 px-3 py-2`,children:[e(`div`,{className:`flex items-start gap-2`,children:[i(ee,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),i(`p`,{className:`text-[11px] leading-relaxed text-foreground`,children:n(`deviceMigrate.stillLive`,`The replaced camera could not be reached, so these functions are STILL RUNNING on the old hardware. Nothing here failed to migrate — but until you unplug it or reach it physically, it can still produce data.`)})]}),i(`ul`,{className:`mt-2 space-y-1 pl-5`,children:t.stillLive.map(t=>e(`li`,{className:`text-[11px] text-foreground`,children:[i(`span`,{className:`font-medium`,children:t.label}),t.detail!==null&&e(`span`,{className:`text-foreground-subtle`,children:[` — `,t.detail]})]},t.switchId))})]}),t.neverOffered.length>0&&e(`div`,{className:`rounded-md border border-border px-3 py-2`,children:[e(`div`,{className:`flex items-start gap-2`,children:[i(Mt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),i(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:n(`deviceMigrate.neverOffered`,`The replaced camera never offered these, so there was nothing to switch off. They are not running.`)})]}),i(`ul`,{className:`mt-2 space-y-1 pl-5`,children:t.neverOffered.map(e=>i(`li`,{className:`text-[11px] text-foreground-subtle`,children:e.label},e.switchId))})]})]})}c();function wm({deviceId:t}){let{t:n}=Q(),[r,a]=o(null),s=Ln({onSuccess:e=>{a(e.changed?`Re-aligned with source — ${e.rebuiltChildren} child${e.rebuiltChildren===1?``:`ren`} rebuilt.`:`Already up to date.`)},onError:e=>a(`Re-sync failed: ${e.message}`)});return e(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3`,children:[e(`div`,{className:`flex items-center justify-between gap-3`,children:[e(`div`,{children:[i(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-foreground`,children:n(`device.resyncButton.reSync`,`Re-sync`)}),i(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:n(`device.resyncButton.reAlignThisDeviceS`,`Re-align this device's type, role, capabilities and units with its source.`)})]}),e(X,{variant:`unstyled`,type:`button`,disabled:s.isPending,onClick:()=>{a(null),s.mutate({camDeviceId:t})},className:`inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-surface disabled:opacity-50`,children:[i(te,{className:`h-3 w-3 ${s.isPending?`animate-spin`:``}`}),s.isPending?n(`device.resyncButton.reSyncing`,`Re-syncing…`):n(`device.resyncButton.reSync`,`Re-sync`)]})]}),r!==null&&i(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:r})]})}function Tm(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function Em({device:t}){let{t:n}=Q(),r=typeof t.id==`number`?t.id:null,a=typeof t.name==`string`?t.name:``,o=Zn(r??0,`full`,a),s=String(t.type??``)===U.Camera,c=t.features??[],l=c.includes(We.Resyncable),{data:u}=hi({deviceId:r??0},{enabled:r!==null&&s,refetchInterval:5e3}),d=u?.streams??{},f=Object.entries(d),p=c.includes(We.DoorbellButton),m=gi(p?{deviceId:r??void 0,historyLimit:10}:void 0),h=m.latest?Date.now()-m.latest.timestamp<3e4:!1;return e(`div`,{className:`space-y-5`,children:[t.addonId===`composer`&&r!==null&&typeof t.stableId==`string`&&i(dm,{deviceId:r,stableId:t.stableId}),l&&r!==null&&i(wm,{deviceId:r}),s&&r!==null&&i(Sm,{deviceId:r,deviceName:o}),r!==null&&i(ta,{deviceId:r}),r!==null&&i(Yp,{deviceId:r,isCamera:s}),s&&r!==null&&i(mn,{widgetId:`pipeline-orchestrator/pipeline-quick-stats`,host:`device-tab`,deviceId:r}),p&&i(ei,{history:m.history,latestIsFresh:h}),s&&r!==null&&i(mn,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:r}),s&&f.length>0&&e(`div`,{className:`@container rounded-lg border border-border bg-surface overflow-hidden`,style:{containerType:`inline-size`},children:[i(`div`,{className:`border-b border-border px-4 py-2`,children:i(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:n(`device.overviewTab.streamNetwork`,`Stream Network`)})}),i(`div`,{className:`divide-y divide-border`,children:f.map(([t,r])=>e(`div`,{className:`px-4 py-2.5`,children:[e(`div`,{className:`flex items-center gap-2 mb-2`,children:[i(B,{className:`h-3 w-3 text-foreground-subtle`}),i(`span`,{className:`text-[11px] font-medium text-foreground`,children:t})]}),e(`div`,{className:`grid grid-cols-2 @[640px]:grid-cols-4 gap-2`,children:[i(Dm,{label:n(`device.overviewTab.nominal`,`Nominal`),value:Tm(r.nominalBitrateKbps??0)}),i(Dm,{label:n(`device.overviewTab.observed`,`Observed`),value:Tm(r.observedBitrateKbps??0)}),i(Dm,{label:n(`device.overviewTab.peak`,`Peak`),value:Tm(r.peakBitrateKbps??0)}),i(Dm,{label:n(`device.overviewTab.packetLoss`,`Packet Loss`),value:`${(r.packetLossPercent??0).toFixed(2)}%`,warning:(r.packetLossPercent??0)>1})]})]},t))})]}),i(Gi,{})]})}function Dm({label:t,value:n,warning:r}){return e(`div`,{children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,children:t}),i(`p`,{className:`text-xs font-medium ${r?`text-warning`:`text-foreground`}`,children:n})]})}var Om=`history`,km=[{id:`overview`,labelKey:`helpers.structuralTabs.overview`,cameraOnly:!1,adminOnly:!1},{id:`config`,labelKey:`helpers.structuralTabs.config`,cameraOnly:!1,adminOnly:!1},{id:ua,labelKey:`helpers.structuralTabs.customize`,cameraOnly:!1,adminOnly:!0},{id:Om,labelKey:`helpers.structuralTabs.history`,cameraOnly:!1,adminOnly:!1},{id:`detection-pipeline`,labelKey:`helpers.structuralTabs.detectionPipeline`,cameraOnly:!0,adminOnly:!1},{id:`bindings`,labelKey:`helpers.structuralTabs.bindings`,cameraOnly:!0,adminOnly:!1}],Am=new Set([U.Container]);function jm(e,t,n){let r=e===U.Camera,i=n&&(e===void 0||!Am.has(e));return km.filter(e=>(r||!e.cameraOnly)&&(t||!e.adminOnly)&&(i||e.id!==`history`)).map(({id:e,labelKey:t})=>({id:e,label:Z.t(t)}))}function Mm({provider:e,integrationId:t,name:n}){let r=ha(),a=t===null?`/integrations`:pa(e,t),o=n===null?`Open integrations`:`Open integration ${n}`;return i(X,{variant:`unstyled`,type:`button`,onClick:()=>r(a),className:`shrink-0 rounded-md transition-opacity hover:opacity-80 focus:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,title:o,"aria-label":o,children:i(da,{type:e,size:`lg`})})}c();var Nm=[{id:`logs`,icon:N,labelKey:`common.logs`},{id:`repl`,icon:At,labelKey:`deviceDetail.repl`},{id:`events`,icon:h,labelKey:`common.events`},{id:`state`,icon:oe,labelKey:`common.state`}];function Pm(){let{t:a}=Q(),s=ra(),c=Number(s.deviceId),d=Number.isFinite(c),f=ha(),p=l(),m=re(),h=xe(),{user:g}=na(),_=g?.isAdmin===!0,[v,y]=Ki(),b=v.get(`tab`)??`overview`,x=v.get(`sub`),[S,C]=o(`logs`),w=`device-detail.left-col-width-px`,[T,E]=o(()=>{if(typeof window>`u`)return null;let e=window.localStorage.getItem(w),t=e?Number(e):NaN;return Number.isFinite(t)&&t>0?t:null}),D=t(T);D.current=T;function O(e){e.preventDefault();let t=e.clientX,n=e.currentTarget.previousElementSibling?.getBoundingClientRect().width??T??0,r=Math.max(330,Math.floor(window.innerWidth*.7)),i=e=>{E(Math.max(280,Math.min(r,n+(e.clientX-t))))},a=()=>{document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a);let e=D.current;if(e!==null)try{window.localStorage.setItem(w,String(Math.round(e)))}catch{}document.body.style.userSelect=``,document.body.style.cursor=``};document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a)}let{data:k,isLoading:A,isError:j}=wn({deviceId:c},{enabled:d,refetchInterval:5e3,retry:1}),{data:M}=Or({deviceId:c},{enabled:d}),N=n(()=>{let e=M?.settings?.sections??[],t=M?.live?.sections??[],n=[...e,...t],r=new Set;for(let e of n)e.location===`top-tab`&&e.tab&&r.add(e.tab===`zones`?`detection-pipeline`:e.tab);return n.some(la)&&r.add(qi),[...r].map(e=>e===`export`?{id:e,label:$i,isAddonContrib:!0}:{id:e,label:vt[e]?.label??e,isAddonContrib:!0})},[M]),F=k,ee=String(F?.name??s.deviceId??`Device`),I=F?.online===!1,ne=String(F?.addonId??`rtsp`),L=F?.features??[],ae=pn({deviceId:c}),R=F?.type,z=R===U.Camera,{data:oe}=oa(d?c:0),B=R===U.Container,de=n(()=>(oe??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),[oe]),fe=n(()=>B?$t(de,typeof F?.linkDeviceId==`number`?F.linkDeviceId:null,typeof F?.primaryChildEntityId==`string`?F.primaryChildEntityId:null,R,F?Re(F):void 0)?.id??null:null,[B,de,F?.linkDeviceId,F?.primaryChildEntityId,F?.stableId,F?.primaryChildPreference,R]),{data:V}=Or({deviceId:fe??0},{enabled:fe!==null}),ge=n(()=>{if(fe===null)return[];let e=V?.settings?.sections??[],t=V?.live?.sections??[],n=new Set;for(let r of[...e,...t])r.location===`top-tab`&&r.tab&&n.add(r.tab);return[...n].map(e=>({id:e,label:vt[e]?.label??e,isAddonContrib:!0,childDeviceId:fe}))},[fe,V]),[_e,ve]=o(!1),ye=Di(c),be=Xi(ye.presence,ye.list),Se=n(()=>Xf({sections:[...M?.settings?.sections??[],...M?.live?.sections??[]],deviceId:c,drawnByHero:[...Jf(R),..._e?[`host/power-meter-line`]:[]],...fe===null?{}:{child:{sections:[...V?.settings?.sections??[],...V?.live?.sections??[]],deviceId:fe}}}),[M,V,c,R,_e,fe]),Ce=typeof F?.parentDeviceId==`number`?F.parentDeviceId:null,{data:we}=wn({deviceId:Ce??0},{enabled:Ce!==null}),Te={id:Number.isFinite(c)?c:0,name:ee,type:`unknown`,stableId:``,parentDeviceId:null},H=An(F??Te,`full`),Ee=An(we??Te,`full`),De=Gn(),Oe=F?.disabled!==!0,ke=n(()=>{let e=M?.settings?.sections??[],t=M?.live?.sections??[];return ia([...e,...t],R,_,M!==void 0)},[M,R,_]),Ae=n(()=>{let e=new Set,t=[];for(let n of[...jm(R,_,be).filter(e=>!(e.id===`history`&&_e&&!z)),...N,...ge])n.id===`config`&&!ke||e.has(n.id)||(e.add(n.id),t.push(n));return t},[R,_,be,N,ge,ke,_e,z]),je=n(()=>Qf(Ae,b),[Ae,b]),Me=r(e=>{y(t=>{let n=new URLSearchParams(t);e===`overview`?n.delete(`tab`):n.set(`tab`,e),n.delete(`sub`);for(let e of Ko)n.delete(e);return n},{replace:!0})},[y]),Ne=r(e=>{y(t=>{let n=new URLSearchParams(t);return n.set(`sub`,e),n},{replace:!0})},[y]),Pe=(oe??[]).length>0,Fe=n(()=>Nm.filter(({featureGate:e})=>!e||L.includes(e)),[L]),{data:Ie}=Ni(void 0),Le=n(()=>F?tn(F,Ie):null,[F,Ie]),W=Le?.kind===`resolved`?Le.integration:null,ze=W===null?Le?.kind===`unknown`?a(`deviceDetail.loadingIntegration`):Le?.kind===`orphan`?a(`deviceDetail.missingIntegration`):a(`deviceDetail.noIntegration`):W.name,Be=W!==null&&W.addonId===ne?W.name:ne,Ve=Kr({onSuccess:()=>{p.invalidateQueries({queryKey:[[`deviceManager`]]}),f(W?.id?pa(W.addonId,W.id):`/integrations`)}}),He=hr({onSuccess:()=>{p.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ue=Pn({onSuccess:()=>{p.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ge=Zt(),Ke=Pi({onSuccess:()=>{p.invalidateQueries({queryKey:[[`deviceManager`]]})}}),qe=jn({deviceId:c},{enabled:d,staleTime:15e3}),Je=qe.data?.linked===!0,G=qe.data?.switchSettable!==!1,Ye=ce(),Xe=e=>{p.invalidateQueries({queryKey:[[`powerSource`]]}),e.accepted||Ye({title:a(`deviceDetail.powerSourceRefused`,`The power action was not done`),message:e.message,variant:`danger`})},Ze=Ui({onSuccess:Xe}),Qe=Qn({onSuccess:Xe}),$e=gn({onSuccess:Xe}),et=qe.data?.switchName??``,tt=qe.data?.offSeconds??0,nt=L.includes(We.Rebootable),rt=L.includes(We.BatteryOperated),it=ci(h.trpcClient,rt&&d?c:null),at=Yt(h.trpcClient,d?c:null),ot=le(h.trpcClient,d?c:null,e=>e.runningState),st=ot===void 0||ot.running===null?null:ot.running,ct=Sr(),lt=cn({type:R??`unknown`,role:F?.role??null,display:F?.display},ct),[ut,dt]=o(!1),ft=async()=>{if(!ut){dt(!0);try{let e=H.replace(/[^a-zA-Z0-9_.-]+/g,`_`),t=new Date().toISOString().replace(/[:.]/g,`-`);await ga(`${P}/${String(c)}.jpg?force=1`,`${e}-${t}.jpg`)}finally{dt(!1)}}},pt=He.isPending||Ue.isPending,{data:mt}=lr({deviceId:c},{enabled:d&&z,refetchInterval:1e4}),ht=mt?.agentNodeId??null,gt=typeof ht==`string`&&ht.length>0&&!ht.startsWith(`addon:`)?ht:void 0,{data:_t}=Ri({deviceId:c,...gt?{nodeId:gt}:{}},{enabled:d&&z,refetchInterval:3e3,retry:!1}),{data:yt}=Wn({deviceId:c},{enabled:d&&z,refetchInterval:3e3,retry:!1}),bt=yt?.level?.dbfs??null;function xt(){if(!d)return null;switch(je){case`overview`:return i(Em,{device:F??{}});case`config`:return i(rp,{deviceId:c,activeSubTab:x,onSubTabChange:Ne,deviceType:R,isAdmin:_});case`detection-pipeline`:return i(Hp,{deviceId:c,activeSubTab:x,onSubTabChange:Ne});case`bindings`:return i($f,{deviceId:c});case Om:return i(wi,{deviceId:c,onNavigate:e=>f(e)});case ua:return i(Hf,{deviceId:c});default:{let e=je,t=N.some(t=>t.id===e),n=ge.find(t=>t.id===e);if(!t&&n===void 0)return null;let r=n?.childDeviceId??c;if(e===`export`)return i(ma,{deviceId:c,sectionFilter:la,activeSubTab:x,onSubTabChange:Ne});let a=i(ma,{deviceId:r,sectionFilter:t=>t.location===`top-tab`&&t.tab===e,activeSubTab:x,onSubTabChange:Ne});return n!==void 0&&r!==c?i(Pr,{deviceId:r,children:a}):a}}}return d?A?e(`div`,{className:`flex flex-col h-full`,children:[e(`div`,{className:`border-b border-border bg-surface px-2 py-4 sm:px-4`,children:[i(`div`,{className:`h-4 w-48 rounded bg-surface-hover animate-pulse mb-3`}),i(`div`,{className:`h-8 w-64 rounded bg-surface-hover animate-pulse`})]}),i(`div`,{className:`flex-1 p-2 sm:p-4`,children:i(`div`,{className:`h-40 rounded-lg border border-border bg-surface animate-pulse`})})]}):j||!k?e(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[i(`p`,{className:`text-lg font-semibold text-foreground`,children:a(`deviceDetail.deviceNotFound`,`Device not found`)}),i(`p`,{className:`text-xs`,children:i(ca,{i18nKey:`deviceDetail.noDeviceWithId`,values:{id:c},components:{code:i(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`})}})}),i(X,{variant:`unstyled`,onClick:()=>f(`/integrations`),className:`mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:a(`deviceDetail.backToIntegrations`,`Back to Integrations`)})]}):e(`div`,{className:`absolute inset-0 flex flex-col overflow-clip`,children:[e(`div`,{className:`border-b border-border bg-surface px-2 py-3 sm:px-4 flex-shrink-0`,children:[i(`div`,{className:`mb-2`,children:i(cr,{items:[{label:a(`deviceDetail.integrations`,`Integrations`),onClick:()=>f(`/integrations`)},W===null?{label:ze}:{label:ze,onClick:()=>f(pa(W.addonId,W.id))},{label:H}]})}),e(`div`,{className:`flex items-center gap-2 sm:gap-3`,children:[W!==null&&i(Mm,{provider:W.addonId,integrationId:W.id,name:W.name}),i(Ut,{running:st,children:i(lt,{className:`h-5 w-5 text-foreground-subtle shrink-0`,"aria-hidden":!0})}),e(`div`,{className:`min-w-0 flex-1`,children:[e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[i(`h1`,{className:`text-sm sm:text-base font-semibold text-foreground truncate`,children:H}),I&&i(Cr,{status:`offline`}),rt&&i(ki,{status:it,variant:`full`}),i(Cn,{status:at})]}),Ce!==null&&we&&e(X,{variant:`unstyled`,type:`button`,onClick:()=>f(`/devices/${Ce}`),className:`text-[10px] text-foreground-subtle hover:text-primary transition-colors mt-0.5 inline-flex items-center gap-1`,title:a(`deviceDetail.openParentDevice`,`Open parent device {{name}}`,{name:Ee}),children:[i(`span`,{children:`↑`}),i(`span`,{className:`truncate`,children:Ee})]}),i(`div`,{className:`hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle`,children:L.length>0&&i(sa,{capabilities:L})})]}),_t&&i(`div`,{className:`hidden lg:flex`,children:i(Fm,{metrics:_t,dbfs:bt})}),e(`div`,{className:`flex items-center gap-1 shrink-0`,children:[e(X,{variant:`unstyled`,onClick:async()=>{Oe?await m({title:a(`deviceDetail.disable`,`Disable "{{name}}"?`,{name:H}),message:a(`deviceDetail.theDeviceWillStopProcessing`,`The device will stop processing streams and events. You can re-enable it later.`),confirmLabel:a(`common.disable`,`Disable`),variant:`danger`})&&Ue.mutate({deviceId:c}):He.mutate({deviceId:c})},disabled:pt,title:Oe?a(`deviceDetail.disableDevice`,`Disable device`):a(`deviceDetail.enableDevice`,`Enable device`),className:`inline-flex items-center gap-1.5 rounded-lg px-2 sm:px-2.5 py-1.5 text-[11px] font-medium border transition-colors disabled:opacity-50 ${Oe?`border-success/30 text-success hover:bg-success/10`:`border-border text-foreground-subtle/50 hover:text-foreground hover:bg-surface-hover`}`,children:[i(he,{className:`h-3.5 w-3.5`}),i(`span`,{className:`hidden sm:inline`,children:pt?a(`deviceDetail.updating`,`Updating…`):Oe?a(`deviceDetail.enabled`,`Enabled`):a(`deviceDetail.disabled`,`Disabled`)})]}),i(`div`,{className:`hidden sm:block h-5 w-px bg-border mx-1`}),z&&e(u,{children:[i(hs,{deviceId:c}),i(`div`,{className:`hidden sm:block h-5 w-px bg-border mx-1`})]}),i(Gf,{deviceId:c}),i(Kt,{triggerClassName:`ml-1`,items:[{id:`snapshot`,label:a(`deviceDetail.takeSnapshot`,`Take snapshot`),description:a(`deviceDetail.fetchAFreshFrameAnd`,`Fetch a fresh frame and download it.`),icon:ie,disabled:ut,onClick:()=>{ft()}},{id:`reboot`,label:a(`deviceDetail.rebootDevice`,`Reboot device`),description:a(`deviceDetail.cameraGoesOfflineFor30`,`Camera goes offline for ~30 seconds.`),icon:ue,hidden:!nt,disabled:Ge.isPending,danger:!0,onClick:async()=>{await m({title:a(`deviceDetail.reboot`,`Reboot "{{name}}"?`,{name:H}),message:a(`deviceDetail.theCameraWillGoOffline`,`The camera will go offline for around 30 seconds while the firmware reboots.`),confirmLabel:a(`deviceDetail.reboot2`,`Reboot`),variant:`danger`})&&Ge.mutate({deviceId:c})}},{id:`power-source-on`,label:a(`deviceDetail.powerOn`,`Power on`),description:a(`deviceDetail.powerOnDescription`,`Switch on {{switchName}}, which powers this device.`,{switchName:et}),icon:he,hidden:!Je||!G,disabled:Ze.isPending,onClick:()=>Ze.mutate({deviceId:c})},{id:`power-source-off`,label:a(`deviceDetail.powerOff`,`Power off`),description:a(`deviceDetail.powerOffDescription`,`Switch off {{switchName}}, which powers this device.`,{switchName:et}),icon:se,hidden:!Je||!G,disabled:Qe.isPending,danger:!0,onClick:async()=>{await m({title:a(`deviceDetail.powerOffTitle`,`Cut the power of "{{name}}"?`,{name:H}),message:a(`deviceDetail.powerOffMessage`,`{{switchName}} will be switched off and "{{name}}" stays off until you power it on again.`,{switchName:et,name:H}),confirmLabel:a(`deviceDetail.powerOffConfirm`,`Power off`),variant:`danger`})&&Qe.mutate({deviceId:c})}},{id:`power-source-restart`,label:a(`deviceDetail.forceRestartPower`,`Force restart (power)`),description:a(`deviceDetail.forceRestartPowerDescription`,`Cut the power of {{switchName}} for {{seconds}} seconds, then switch it back on.`,{switchName:et,seconds:tt}),icon:te,hidden:!Je,disabled:$e.isPending||qe.data?.restartInProgress===!0,danger:!0,onClick:async()=>{await m({title:a(`deviceDetail.forceRestartTitle`,`Force restart "{{name}}"?`,{name:H}),message:a(`deviceDetail.forceRestartMessage`,`{{switchName}} will be switched off for {{seconds}} seconds and then back on. "{{name}}" loses power meanwhile.`,{switchName:et,seconds:tt,name:H}),confirmLabel:a(`deviceDetail.forceRestartConfirm`,`Restart`),variant:`danger`})&&$e.mutate({deviceId:c})}},{id:`restart-addon`,label:a(`deviceDetail.restartAddon`,`Restart addon`),description:a(`deviceDetail.bouncesEveryDeviceServedBy`,`Bounces every device served by {{servingAddonLabel}}.`,{servingAddonLabel:Be}),icon:te,disabled:Ke.isPending,danger:!0,onClick:async()=>{await m({title:a(`deviceDetail.restart`,`Restart "{{servingAddonLabel}}"?`,{servingAddonLabel:Be}),message:a(`deviceDetail.restartingTheAddonWillBriefly`,`Restarting the addon will briefly disconnect every device served by it (not just "{{name}}"). Streams will reconnect automatically.`,{name:H}),confirmLabel:a(`deviceDetail.restart2`,`Restart`),variant:`danger`})&&Ke.mutate({addonId:ne})}},{id:`delete`,label:a(`deviceDetail.deleteDevice`,`Delete device`),description:a(`deviceDetail.removeTheDeviceAndAll`,`Remove the device and all its settings.`),icon:me,separatorBefore:!0,disabled:Ve.isPending,danger:!0,onClick:async()=>{await m({title:a(`deviceDetail.delete`,`Delete "{{name}}"?`,{name:H}),message:a(`deviceDetail.thisWillRemoveTheDevice`,`This will remove the device and all its settings. This action cannot be undone.`),confirmLabel:a(`common.delete`,`Delete`),variant:`danger`})&&Ve.mutate({deviceId:c})}}]})]})]})]}),i(Pr,{deviceId:c,device:F??void 0,children:i(_i,{children:i(jr,{children:i(pe,{children:i(Gr,{children:e(`main`,{className:De?`flex-1 overflow-y-auto flex flex-col`:`flex-1 min-h-0 overflow-hidden flex flex-row`,children:[e(`div`,{className:De?`flex flex-col bg-surface`:`${T===null?`w-1/2 lg:w-1/3`:``} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-y-auto`,style:!De&&T!==null?{width:`${String(T)}px`}:void 0,children:[i(`div`,{className:z?`flex-shrink-0 border-b border-border-subtle bg-black`:De?`flex-shrink-0 border-b border-border-subtle bg-surface`:`shrink-0 border-b border-border-subtle bg-surface`,children:z?i(_a,{deviceId:c,intercomAvailable:L.includes(We.TwoWayAudio)}):i(`div`,{"data-card-frame":`bare`,className:`p-2 sm:p-4`,children:e(Un,{frame:`bare`,children:[i(ea,{deviceId:c,device:F,deviceName:H,defaultHistoryOpen:v.get(`tab`)===Om,onDrawn:ve}),i(ur,{trpc:h.trpcClient,deviceId:c,features:L,entries:ae.data?.entries}),_e?null:i(Kf,{deviceId:c,widgets:Se})]})})}),z&&Se.length>0&&i(`div`,{className:`flex-shrink-0 border-b border-border-subtle bg-surface pt-3 sm:pt-4`,children:i(Kf,{deviceId:c,widgets:Se})}),e(`div`,{className:De?`flex flex-col border-b border-border`:`flex-1 min-h-64 flex flex-col overflow-hidden`,children:[i(`div`,{className:`flex-shrink-0 border-b border-border-subtle px-2 py-1.5`,children:i(`div`,{className:`flex gap-1 overflow-x-auto -mx-1 px-1 pb-0.5`,children:Fe.map(({id:t,labelKey:n,icon:r})=>{let o=S===t;return e(X,{variant:`unstyled`,onClick:()=>C(t),title:a(n),className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors flex-shrink-0 ${o?`bg-primary/15 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[i(r,{className:`h-3 w-3`}),a(n)]},t)})})}),e(`div`,{className:De?`h-72 overflow-hidden`:`flex-1 min-h-0 overflow-hidden`,children:[S===`logs`&&i(ya,{deviceId:c,containerDeviceId:R===`container`?c:void 0}),S===`repl`&&i(ba,{deviceId:c}),S===`events`&&i(xa,{deviceId:c}),S===`state`&&i(va,{deviceId:c})]})]})]}),!De&&i(`div`,{role:`separator`,"aria-orientation":`vertical`,title:a(`deviceDetail.dragToResize`,`Drag to resize`),onMouseDown:O,className:`flex-shrink-0 w-1 cursor-col-resize bg-border hover:bg-primary/40 transition-colors group relative z-10`,children:i(`span`,{className:`absolute inset-y-0 -left-1 -right-1`})}),e(`div`,{className:De?`flex flex-1 flex-col`:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden`,children:[i(`div`,{className:`flex-shrink-0 border-b border-border bg-surface px-2 sm:px-4`,children:i(`div`,{className:`flex flex-nowrap overflow-x-auto md:flex-wrap md:overflow-x-visible items-center gap-0`,children:Ae.map(t=>{let n=je===t.id;return e(X,{variant:`unstyled`,onClick:()=>Me(t.id),className:`relative flex-shrink-0 px-3 py-2 text-xs font-medium transition-colors ${n?`text-primary`:`text-foreground-subtle hover:text-foreground`}`,children:[t.label,n&&i(`span`,{className:`absolute bottom-0 left-0 right-0 h-0.5 rounded-full bg-primary`})]},t.id)})})}),e(`div`,{className:De?`p-2 sm:p-4 flex flex-1 flex-col gap-3`:`flex-1 min-h-0 overflow-y-auto p-2 sm:p-4 flex flex-col gap-3`,children:[je===`overview`&&Pe&&i(_s,{parentDeviceId:c}),xt()]})]})]})})})})})})]}):e(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[i(`p`,{className:`text-lg font-semibold text-foreground`,children:a(`deviceDetail.invalidDeviceId`,`Invalid device id`)}),i(`p`,{className:`text-xs`,children:i(ca,{i18nKey:`deviceDetail.invalidSegment`,values:{segment:s.deviceId},components:{code:i(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`})}})}),i(X,{variant:`unstyled`,onClick:()=>f(`/integrations`),className:`mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:a(`deviceDetail.backToIntegrations`,`Back to Integrations`)})]})}function Fm({metrics:t,dbfs:n}){let r=fe(),{t:a}=Q(),o=er(t.phase??`idle`,r);return e(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[e(`div`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`h-1.5 w-1.5 rounded-full ${o.dotClass}`}),i(`span`,{className:`text-[10px] font-medium ${o.textColor}`,children:o.label})]}),i(`div`,{className:`h-3 w-px bg-border`}),e(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[i(D,{className:`h-3 w-3`}),i(`span`,{className:`text-foreground tabular-nums`,children:(t.actualFps??0).toFixed(1)}),i(`span`,{children:a(`common.fpsWord`)})]}),e(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[i(z,{className:`h-3 w-3`}),i(`span`,{className:`text-foreground tabular-nums`,children:(t.avgInferenceTimeMs??0).toFixed(0)}),i(`span`,{children:`ms`})]}),e(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,title:a(`deviceDetail.currentAudioLevelDbfs`,`Current audio level (dBFS)`),children:[i(S,{className:`h-3 w-3`}),i(`span`,{className:`text-foreground tabular-nums`,children:n==null?`—`:n.toFixed(0)}),i(`span`,{children:`dB`})]}),(t.queueDepth??0)>0&&e(`span`,{className:`text-[10px] text-warning tabular-nums`,children:[`q:`,t.queueDepth]})]})}export{Pm as DeviceDetailPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$a as s,Qa as c,Vn as l,_i as u,fa as d,ft as f,mn as p,sa as m,zr as h}from"./player-overlays-hLBmOC8C.js";import{Oc as g,Qs as _}from"./client-D93RkunP.js";import{t as v}from"./layers-BH9u1mrE.js";import{t as y}from"./timer-reset-5221y6Jb.js";import{$i as b,Dp as x,Ff as S,Lr as C,Mf as w,Qi as T,Qp as E,Rf as D,Ta as O,hr as k,yp as A}from"./src-CR4MjS0h.js";import{t as j}from"./useTranslation-BJr-n0es.js";import{Ci as M,a as N,b as P,i as F}from"./index-BZLBXpx-.js";import{t as I}from"./AdminSectionedPage-DfZeI0TS.js";import{t as L}from"./InstancesTable-Gi6mvKws.js";import{t as R}from"./AdminPage-CFltVUtJ.js";o();var z=[12e4,3e5,6e5,18e5],B={"request-census":`Counts every tRPC call by TRANSPORT PLANE — http, ws, mesh — and by procedure, caller, address and user-agent. Subscriptions are counted apart from calls, so a long-lived stream cannot pass for a storm. Arm it, then restart: the deadline is persisted, so the window is still running when clients reconnect.`};function V(){let{t}=j(),n=S({},{refetchInterval:5e3}),i=D(),[o,s]=a(null),l=(e,t)=>{s(e),i.mutate({patch:{diagnostics:[{id:e,armMs:t}]}},{onSettled:()=>{s(null),n.refetch()}})},u=n.data?.activeWindows??[],d=(n.data?.channels??[]).filter(e=>e.kind!==`debug`),f=n.data?.activeChannels??[],p=(e,t,r)=>{s(e),i.mutate({patch:{channels:[{channel:e,armMs:t,deviceIds:r}]}},{onSettled:()=>{s(null),n.refetch()}})};return e(R,{embedded:!0,icon:c,title:t(`logging.diagnostics.title`,`Diagnostics`),subtitle:t(`logging.diagnostics.subtitle`,`Diagnostics are armed for a window, never switched on. Each carries a deadline and expires by itself — one left running is an incident of its own.`),children:[n.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(h,{className:`h-3.5 w-3.5 animate-spin`}),t(`common.loading`,`Loading…`)]}):r(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:u.map(e=>r(U,{window:e,busy:o===e.id,onArm:t=>l(e.id,t)},e.id))}),r(`h3`,{className:`mt-6 text-sm font-medium text-foreground`,children:t(`logging.diagnostics.channels`,`Component channels`)}),r(`p`,{className:`mb-2 max-w-3xl text-[11px] text-foreground-subtle`,children:t(`logging.diagnostics.channelsSubtitle`,`Declared by the addons that own them — this list is not maintained by hand. Arming a channel opens a window with a deadline; it closes by itself.`)}),d.length===0?r(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`logging.diagnostics.noChannels`,`No addon on this cluster declares a log channel, or none could be reached right now.`)}):r(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:d.map(e=>r(H,{channel:e,state:f.find(t=>t.channel===e.name),busy:o===e.name,onArm:(t,n)=>p(e.name,t,n)},e.name))})]})}function H({channel:t,state:n,busy:i,onArm:o}){let{t:s}=j(),[c,l]=a(``),u=n?.armed===!0,f=()=>{let e=c.split(/[\s,+]+/).filter(e=>/^\d+$/.test(e)).map(e=>Number(e));return e.length>0?e:null};return e(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),u?e(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[r(y,{className:`h-3 w-3`}),s(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:W(n?.remainingMs??0)})]}):r(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:s(`logging.diagnostics.disarmed`,`disarmed`)}),u&&n?.deviceIds!==null&&n?.deviceIds!==void 0&&e(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[r(d,{className:`h-3 w-3`}),n.deviceIds.join(`, `)]}),!t.perDevice&&r(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:s(`logging.diagnostics.notPerCamera`,`not filterable per camera`)})]}),r(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:t.description})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[t.perDevice&&r(x,{type:`text`,inputMode:`numeric`,value:c,disabled:i,onChange:e=>l(e.target.value),placeholder:s(`logging.diagnostics.camerasPlaceholder`,`all cameras`),className:`w-28 rounded border border-border bg-surface px-2 py-1 text-[11px] text-foreground`}),z.map(e=>r(A,{variant:`unstyled`,type:`button`,disabled:i,onClick:()=>o(e,f()),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:W(e)},e)),r(A,{variant:`unstyled`,type:`button`,disabled:i||!u,onClick:()=>o(0,null),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:s(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function U({window:t,busy:n,onArm:i}){let{t:a}=j();return e(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`text-sm font-medium text-foreground`,children:t.id}),t.armed?e(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[r(y,{className:`h-3 w-3`}),a(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:W(t.remainingMs)})]}):r(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:a(`logging.diagnostics.disarmed`,`disarmed`)}),t.armed&&!t.persisted&&r(`span`,{className:`text-[10px] text-warning`,children:a(`logging.diagnostics.notPersisted`,`not persisted — will not survive a restart`)})]}),r(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:B[t.id]??``})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[z.map(e=>r(A,{variant:`unstyled`,type:`button`,disabled:n,onClick:()=>i(e),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:W(e)},e)),r(A,{variant:`unstyled`,type:`button`,disabled:n||!t.armed,onClick:()=>i(0),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:a(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function W(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:r===0?`${n}m`:`${n}m ${r}s`}function G(){let{t:e}=j();return r(L,{functionCap:`log-destination`,icon:l,title:e(`system.logging.destinations`,`Destinations`),subtitle:e(`system.logging.everyRegisteredLogDestinationEntries`,`Every registered log destination. Entries are fanned to all enabled destinations at once — enabling one does not disable another.`),emptyTitle:e(`system.logging.noLogDestinationsRegistered`,`No log destinations registered`),emptyDescription:e(`system.logging.thisShouldNotHappenThe`,`This should not happen — the console and rotated-file destinations are builtins. If the list is empty, the node is still booting.`),defaultKindLabel:e(`system.logging.kindDestination`,`Log destination`),addLabel:e(`system.logging.addDestination`,`Add destination`),install:{capability:`log-destination`,label:e(`system.logging.installDestination`,`Install a destination`)}})}o();var K=[`debug`,`info`,`warn`,`error`],q=``,J=``;function Y(){let{t:n}=j(),[i,o]=a(q),[s,c]=a(J),{nodes:l}=E(),u=t(()=>l.map(e=>({id:e.id,label:e.name||e.id})),[l]),d=S({...i===q?{}:{scopeNodeId:i},...s===J?{}:{scopeComponent:s}},{refetchInterval:15e3}),p=D(),m=d.data,g=p.isPending||d.isFetching,_=(m?.channels??[]).filter(e=>e.kind!==`debug`),y=(e,t)=>{p.mutate({...e.nodeId===null?{}:{scopeNodeId:e.nodeId},...e.component===null?{}:{scopeComponent:e.component},patch:{level:t}},{onSuccess:()=>void d.refetch()})};return r(R,{embedded:!0,icon:v,title:n(`logging.levels.title`,`Levels`),subtitle:n(`logging.levels.subtitle`,`Cluster → node, most specific wins. The floor gates what reaches the log destinations; the in-memory viewer keeps every line either way.`),actions:e(`div`,{className:`flex flex-wrap items-center gap-3`,children:[e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(`logging.levels.scope`,`Scope`),e(f,{wrapperClassName:`inline-block w-auto`,value:i,disabled:s!==J,onChange:e=>o(e.target.value),children:[r(`option`,{value:q,children:n(`logging.levels.cluster`,`Cluster`)}),u.map(e=>r(`option`,{value:e.id,children:e.label},e.id))]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(`logging.levels.component`,`Component`),e(f,{wrapperClassName:`inline-block w-auto`,value:s,onChange:e=>c(e.target.value),children:[r(`option`,{value:J,children:n(`logging.levels.noComponent`,`None`)}),_.map(e=>r(`option`,{value:e.name,children:e.name},e.name))]})]})]}),children:d.isLoading||m===void 0?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(h,{className:`h-3.5 w-3.5 animate-spin`}),n(`common.loading`,`Loading…`)]}):e(`div`,{className:`space-y-3`,children:[r(Z,{level:m.effective.level,source:m.effective.levelSource,persisted:m.persisted}),r(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:m.explicit.layers.map(e=>r(Q,{layer:e,inForce:e.scope===m.effective.levelSource,busy:g,onSet:t=>y(e,t),onClear:()=>y(e,null)},`${e.scope}:${e.nodeId??e.component??`cluster`}`))}),s!==J&&r(`p`,{className:`text-[11px] text-foreground-subtle`,children:_.find(e=>e.name===s)?.description??``}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`logging.levels.componentNote`,`A component is a log channel an addon declared. Its level is cluster-wide and beats both the node and the cluster layer.`)}),r(X,{days:m.opsLogRetentionDays,busy:g,onSet:e=>p.mutate({patch:{opsLogRetentionDays:e}},{onSuccess:()=>void d.refetch()})})]})})}function X({days:t,busy:n,onSet:i}){let{t:a}=j();return e(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-1`,children:[e(`label`,{className:`flex items-center justify-between gap-3`,children:[r(`span`,{className:`text-xs font-medium`,children:a(`logging.levels.opsLogRetention`,`Retention audit trail`)}),e(`span`,{className:`flex items-center gap-1.5`,children:[r(x,{type:`number`,min:0,max:3650,step:1,defaultValue:t,disabled:n,onBlur:e=>{let n=Number.parseInt(e.target.value,10);Number.isFinite(n)&&n!==t&&i(n)},className:`w-20 rounded border border-border bg-surface px-2 py-1 text-xs`}),r(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`common.days`,`days`)})]})]}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`logging.levels.opsLogRetentionNote`,`How long the record of what retention deleted is kept. Cluster-wide, and deliberately longer than any camera window — it is the history of the sweep, not of the camera, and it is what makes a storage leak explainable after the fact. 0 keeps it forever.`)})]})}function Z({level:t,source:n,persisted:i}){let{t:a}=j();return e(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`text-xs text-foreground-subtle`,children:a(`logging.levels.effective`,`In force here`)}),r(`span`,{className:`rounded bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary`,children:t}),r(`span`,{className:`text-[11px] text-foreground-subtle`,children:n==="default"?a(`logging.levels.fromDefault`,`nothing is set anywhere — this is the default`):a(`logging.levels.fromLayer`,`decided by the {{source}} layer`,{source:n})})]}),!i&&r(`p`,{className:`mt-1 text-[11px] text-warning`,children:a(`logging.levels.notPersisted`,`The settings store could not be read or written — what you see is live, but it would not survive a restart.`)})]})}function Q({layer:t,inForce:n,busy:i,onSet:a,onClear:o}){let{t:s}=j();return e(`div`,{className:`flex flex-col gap-2 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`text-sm font-medium text-foreground`,children:t.scope===`cluster`?s(`logging.levels.cluster`,`Cluster`):t.scope===`component`?t.component??``:t.nodeId??``}),n&&e(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[r(m,{className:`h-3 w-3`}),s(`logging.levels.inForce`,`in force`)]})]}),r(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:t.level===null?s(`logging.levels.inherits`,`inherits — nothing set at this layer`):s(`logging.levels.setHere`,`set here: {{level}}`,{level:t.level})})]}),e(`div`,{className:`flex shrink-0 items-center gap-1`,children:[K.map(e=>r(A,{variant:`unstyled`,type:`button`,disabled:i,onClick:()=>a(e),className:`rounded px-2 py-1 text-[11px] font-medium transition-colors disabled:opacity-50 ${t.level===e?`bg-primary text-primary-foreground`:`border border-border text-foreground-subtle hover:text-foreground`}`,children:e},e)),r(A,{variant:`unstyled`,type:`button`,disabled:i||t.level===null,onClick:o,className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-40`,children:s(`logging.levels.clear`,`Clear`)})]})]})}function $(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:`${n}m ${String(r).padStart(2,`0`)}s`}function ee(e,t){return{windowMs:Math.max(0,e.untilMs-t),capMs:Math.max(0,e.capAtMs-t)}}function te(e,t){let n=new Set(e.map(e=>e.channel));return t.filter(e=>n.has(e))}o();var ne=[_.Camera],re=8,ie=1e3,ae=15e3;function oe(){let{t:o}=j(),c=S({},{refetchInterval:15e3}),l=w(),[d,f]=a([]),[m,_]=a([]),[v,x]=a([]),[E,D]=a(()=>Date.now()),[M,N]=a([]),P=t(()=>(c.data?.channels??[]).filter(e=>e.kind===`debug`),[c.data]),F=n((e,t,n)=>{l.mutate({action:e,channels:t,deviceIds:n},{onSuccess:e=>{f(e.watches),N(e.lapsed)}})},[]);i(()=>{let e=setInterval(()=>D(Date.now()),ie);return()=>clearInterval(e)},[]),i(()=>{F(`list`,[],[]);let e=setInterval(()=>F(`list`,[],[]),ae);return()=>clearInterval(e)},[F]);let I=te(d,m).join(`|`);i(()=>{if(I===``)return;let e=setInterval(()=>F(`rearm`,I.split(`|`),[]),g);return()=>clearInterval(e)},[I,F]);let L=m.length>0&&v.length>0&&!l.isPending,z=[...new Set(d.flatMap(e=>e.deviceIds))],B=(e,t)=>_(n=>t?[...n,e]:n.filter(t=>t!==e));return e(R,{embedded:!0,icon:u,title:o(`logging.watch.title`,`Watch`),subtitle:o(`logging.watch.subtitle`,`Switch a debug channel on for chosen devices and read it live. A watch lasts 10 minutes, is renewed while this page stays open, and ends by itself after 60 minutes at most.`),children:[r(C,{headingId:`log-watch-setup`,title:o(`logging.watch.setup`,`Channels and devices`),children:c.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(h,{className:`h-3.5 w-3.5 animate-spin`}),o(`common.loading`,`Loading…`)]}):P.length===0?r(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`logging.watch.noChannels`,`No addon on this cluster offers a debug channel, or none could be reached right now.`)}):e(`div`,{className:`space-y-3 p-3`,children:[r(`div`,{className:`space-y-2`,children:P.map(t=>e(`label`,{className:`flex items-start gap-2`,children:[r(s,{checked:m.includes(t.name),onChange:e=>B(t.name,e.target.checked)}),e(`span`,{className:`min-w-0`,children:[r(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),r(`span`,{className:`block text-[11px] text-foreground-subtle`,children:t.description})]})]},t.name))}),e(`div`,{className:`flex flex-col gap-1`,children:[r(`span`,{className:`text-xs font-medium text-foreground`,children:o(`logging.watch.devices`,`Devices`)}),r(O,{multiple:!0,pick:`device`,noun:`camera`,fixedTypes:ne,maxItems:re,recentKey:`log-watch-devices`,testId:`log-watch-devices`,value:b(v),onChange:e=>x(T(e))})]}),e(`div`,{className:`flex flex-wrap gap-2`,children:[r(A,{type:`button`,disabled:!L,onClick:()=>F(`start`,m,v),children:o(`logging.watch.start`,`Start watching`)}),e(A,{type:`button`,variant:`secondary`,disabled:d.length===0||l.isPending,onClick:()=>F(`stop`,d.map(e=>e.channel),[]),children:[r(p,{className:`mr-1 h-3.5 w-3.5`}),o(`logging.watch.stop`,`Stop`)]})]}),l.isError&&r(`p`,{className:`text-[11px] text-destructive`,children:l.error.message}),M.length>0&&r(`p`,{className:`text-[11px] text-warning`,children:o(`logging.watch.lapsed`,`Already ended, not renewed: {{names}}. Start again to continue.`,{names:M.join(`, `)})})]})}),d.length>0&&e(C,{headingId:`log-watch-live`,title:o(`logging.watch.live`,`Live`),children:[r(`div`,{className:`divide-y divide-border`,children:d.map(t=>{let n=ee(t,E);return e(`div`,{className:`flex flex-wrap items-center gap-2 p-3`,children:[r(`span`,{className:`text-sm font-medium text-foreground`,children:t.channel}),e(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[r(y,{className:`h-3 w-3`}),o(`logging.watch.endsIn`,`ends in {{left}}`,{left:$(n.windowMs)})]}),r(`span`,{className:`text-[11px] text-foreground-subtle`,children:o(`logging.watch.capIn`,`hard stop in {{left}}`,{left:$(n.capMs)})}),e(`span`,{className:`text-[11px] text-foreground-subtle`,children:[`#`,t.deviceIds.join(`, #`)]})]},t.channel)})}),z.map(e=>r(`div`,{className:`border-t border-border`,children:r(k,{deviceId:e,limit:200,maxHeight:`max-h-80`,showScope:!0,showFilters:!1})},e))]})]})}function se(){let[e]=M(),t=e.get(`deviceId`),n=t===null?void 0:Number(t);return r(R,{embedded:!0,children:r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:r(k,{deviceId:n!==void 0&&Number.isFinite(n)?n:void 0,limit:500,maxHeight:`max-h-[calc(100vh-310px)]`,showFilters:!0,showOriginFilter:!0,columns:{available:[`integration`,`device`],defaultVisible:[`integration`,`device`]}})})})}function ce(){let{t:e}=j(),t=P(`/system/logs`,{t:e,isAdmin:!0})??{icon:l,title:e(`system.logs`,`Logs`)};return r(I,{icon:t.icon,title:t.title,defaultSection:`viewer`,sectionsLabel:`${t.title} sections`,sections:[{id:`viewer`,label:e(`admin.system.logs.viewer`,`Viewer`),content:r(se,{})},{id:N.logging.tab,label:e(`admin.system.logs.destinations`,`Destinations`),content:r(G,{}),ownedParams:F},{id:`levels`,label:e(`admin.system.logs.levels`,`Levels`),content:r(Y,{})},{id:`watch`,label:e(`admin.system.logs.watch`,`Watch`),content:r(oe,{})},{id:`diagnostics`,label:e(`admin.system.logs.diagnostics`,`Diagnostics`),content:r(V,{})}]})}export{ce as LogsPage};
|