@camstack/addon-admin-ui 1.0.7 → 1.1.0
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/dist/assets/{AddLocationWizard-BPXjVkoq.js → AddLocationWizard-g-iCisaY.js} +1 -1
- package/dist/assets/AddonCollectionPage-Be4jy8Na.js +1 -0
- package/dist/assets/Addons-B8Uz3p3b.js +1 -0
- package/dist/assets/AdminPage-vtcsGqRq.js +1 -0
- package/dist/assets/{AdminTabs-C5BWg3Pz.js → AdminTabs-82KAodwc.js} +1 -1
- package/dist/assets/{BrokerForm-CwBhT_Zu.js → BrokerForm-CMM9A0YF.js} +1 -1
- package/dist/assets/{BrokerStep-kInoZsZ8.js → BrokerStep-Cuy5HRqo.js} +1 -1
- package/dist/assets/Capabilities-v-1LhcyN.js +1 -0
- package/dist/assets/{CapabilityBadges-CqlDFU27.js → CapabilityBadges-_mvuGKpR.js} +1 -1
- package/dist/assets/{Cluster-vA3G3Xt-.js → Cluster-Ct5NThFV.js} +1 -1
- package/dist/assets/{Dashboard-CIarzGjr.js → Dashboard-Wvx41atC.js} +1 -1
- package/dist/assets/{Data-CBUx81MG.js → Data-B6aXh0KW.js} +1 -1
- package/dist/assets/DetectionIntelligence-C8fXC3er.js +1 -0
- package/dist/assets/DeviceDetail-YGwPomw3.js +2 -0
- package/dist/assets/{Devices-KDtIE02J.js → Devices-91ljVfC2.js} +1 -1
- package/dist/assets/EmbedPlayerPage-CdA-C2RV.js +1 -0
- package/dist/assets/FormBuilder-lgISTqit.js +1 -0
- package/dist/assets/{Identity-CYHFXu1M.js → Identity-4Vbqib91.js} +1 -1
- package/dist/assets/IntegrationDetail-CbT-KOnh.js +1 -0
- package/dist/assets/{Integrations-BXICd-JI.js → Integrations-CA9f1mkA.js} +1 -1
- package/dist/assets/Integrations-Csosdze5.js +1 -0
- package/dist/assets/{Logs-kzrdYdPu.js → Logs-BniPjEHE.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-C5K6H6Th.js → MaskShapeCanvas-CQ2SgaNa.js} +1 -1
- package/dist/assets/MotionZonesSettings-CsC6s4D-.js +1 -0
- package/dist/assets/MyAccess-C4uyXRm5.js +2 -0
- package/dist/assets/Network-UKU1_Wz1.js +1 -0
- package/dist/assets/NodeAddonsSettingsPanel-CYN-oFxS.js +1 -0
- package/dist/assets/{Pipeline-C460Q1dM.js → Pipeline-CdUm5Au3.js} +1 -1
- package/dist/assets/PrivacyMaskSettings-CHHQ8IRg.js +1 -0
- package/dist/assets/{ProviderIcon-BS00rCO4.js → ProviderIcon-Qs52Bs5y.js} +1 -1
- package/dist/assets/SchemaTabBar-DRo5sGP1.js +1 -0
- package/dist/assets/Settings-C9_KnucX.js +1 -0
- package/dist/assets/Showroom-3ChHkIOI.js +1 -0
- package/dist/assets/{StatusBadge-CkYubfRG.js → StatusBadge-BSsUNFG6.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BCWO2hJt.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-B5VtjlIx.js} +1 -1
- package/dist/assets/{_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CK8iQdP1.js → _virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CCjPq1YD.js} +1 -1
- package/dist/assets/{_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DEeasWo3.js → _virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DqrXu-jG.js} +1 -1
- package/dist/assets/{_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-C1rR7FKs.js → _virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-DcnMG4y9.js} +1 -1
- package/dist/assets/{_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-DQOBkcAT.js → _virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-CUURKTLp.js} +1 -1
- package/dist/assets/{_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-PYw2UAZ_.js → _virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-xmx-auwe.js} +3 -3
- package/dist/assets/{bell-CRa7XWAs.js → bell-DExIwcYQ.js} +1 -1
- package/dist/assets/circle-check-big-B0dF5gJZ.js +1 -0
- package/dist/assets/{copy-Bi-BgxBp.js → copy-Dbvs5ZFj.js} +1 -1
- package/dist/assets/dist-DBAJfCeK.js +1 -0
- package/dist/assets/{dist-B82tlPWR.js → dist-DivYVFrG.js} +1 -1
- package/dist/assets/{download-Bq_ArgRU.js → download-uGUg4MiO.js} +1 -1
- package/dist/assets/{esm-C6_--ziT.js → esm-BxvhK64b.js} +3 -3
- package/dist/assets/{hostInit-B8ISRO-X.js → hostInit-BA6qu1oM.js} +1 -1
- package/dist/assets/index-CmHNa_oF.js +4 -0
- package/dist/assets/{key-round-DdK6mTCz.js → key-round-Dv37pGLu.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-ebe1e057.js → mf-entry-bootstrap-0-3ed6fffa.js} +2 -2
- package/dist/assets/{pencil-WwVUhRC9.js → pencil-Bhm5xitE.js} +1 -1
- package/dist/assets/{player-overlays-ZG1nYuYj.js → player-overlays-BD7QrhVv.js} +1 -1
- package/dist/assets/plus-CkYGohZo.js +1 -0
- package/dist/assets/{radio-B8E0UhzS.js → radio-3gUKVJtq.js} +1 -1
- package/dist/assets/{refresh-cw-DewUBhjl.js → refresh-cw-DakczWNP.js} +1 -1
- package/dist/assets/remoteEntry-Dhb4tik2.js +1 -0
- package/dist/assets/{rotate-ccw-CZ8RwUso.js → rotate-ccw-BWniHp6E.js} +1 -1
- package/dist/assets/rotate-cw-B9ioWOhh.js +1 -0
- package/dist/assets/search-nxykxEeu.js +1 -0
- package/dist/assets/{server-DnaOYw5t.js → server-CTIRdXE3.js} +1 -1
- package/dist/assets/{sparkles-D9CcRRON.js → sparkles-DjKBLEHs.js} +1 -1
- package/dist/assets/{square-check-big-9Ki4zQ6C.js → square-check-big-dQtGbsrJ.js} +1 -1
- package/dist/assets/square-k19zsBE3.js +1 -0
- package/dist/assets/src-DsE0ulBa.js +1 -0
- package/dist/assets/{src-BB1LG2-C.js → src-FrhjLfXG.js} +6 -6
- package/dist/assets/{upload-DHwenRyJ.js → upload-B3OAHFII.js} +1 -1
- package/dist/assets/{useDevice-BuSIXBXp.js → useDevice-B88gjmGG.js} +1 -1
- package/dist/assets/useEventInvalidation-BfLge4TE.js +1 -0
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-OHA5nJNY.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CZ1gZe2y.js} +2 -2
- package/dist/assets/{wifi-BJgMgcFe.js → wifi-BXqTH5i3.js} +1 -1
- package/dist/assets/{zap-BAH9oFRn.js → zap-BszHFP1r.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/server/addon.js +4 -4
- package/package.json +1 -1
- package/dist/assets/AddonCollectionPage-BHk_82L1.js +0 -1
- package/dist/assets/Addons-Bu6k7qrw.js +0 -1
- package/dist/assets/AdminPage-CN6ZMhf0.js +0 -1
- package/dist/assets/Capabilities-DazohgP2.js +0 -1
- package/dist/assets/DetectionIntelligence-DmE8QQvK.js +0 -1
- package/dist/assets/DeviceDetail-DqTWl3Kz.js +0 -2
- package/dist/assets/EmbedPlayerPage-BcG6bilu.js +0 -1
- package/dist/assets/FormBuilder-DBTf1H_B.js +0 -1
- package/dist/assets/IntegrationDetail-DqViKcp6.js +0 -1
- package/dist/assets/Integrations-Cyg_bOkD.js +0 -1
- package/dist/assets/MotionZonesSettings-C1INb9Ec.js +0 -1
- package/dist/assets/MyAccess-DvxBmUhb.js +0 -2
- package/dist/assets/Network-BEet8LbP.js +0 -1
- package/dist/assets/NodeAddonsSettingsPanel-BU3fsQhW.js +0 -1
- package/dist/assets/PrivacyMaskSettings-Isrt2Rzc.js +0 -1
- package/dist/assets/SchemaTabBar-ByWwzBUZ.js +0 -1
- package/dist/assets/Settings-BPtVhsDv.js +0 -1
- package/dist/assets/Showroom-qtUMm-lj.js +0 -1
- package/dist/assets/circle-check-big-Ca1L631f.js +0 -1
- package/dist/assets/dist-B8KtyWbO.js +0 -1
- package/dist/assets/index-D5OTguVm.js +0 -4
- package/dist/assets/plus-D2fCWFPc.js +0 -1
- package/dist/assets/remoteEntry-vWrz4ebK.js +0 -1
- package/dist/assets/rotate-cw-DiyghCam.js +0 -1
- package/dist/assets/search-DZ8Fw9-F.js +0 -1
- package/dist/assets/square-CO0xPDBD.js +0 -1
- package/dist/assets/src-Cno9Ci3x.js +0 -1
- package/dist/assets/useEventInvalidation-wNGhDdi_.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{An as e,Cn as t,Dn as n,En as r,Mn as i,Nn as a,On as o,Pn as s,Tn as c,aa as l,ca as u,fa as d,ia as f,jn as p,kn as m,oa as h,pa as g,ra as _,sa as v,ua as y,wn as b}from"./src-BB1LG2-C.js";import{G as x,U as S,X as C,b as w,o as T,x as E,y as D}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CK8iQdP1.js";import{t as O}from"./pencil-WwVUhRC9.js";import{t as k}from"./plus-D2fCWFPc.js";import{t as A}from"./sparkles-D9CcRRON.js";import{t as j}from"./square-check-big-9Ki4zQ6C.js";import{t as M}from"./square-CO0xPDBD.js";import{B as N,F as P,M as F,P as I,i as L,m as R,s as z,x as B}from"./index-D5OTguVm.js";import{t as V}from"./AdminPage-CN6ZMhf0.js";var H=N(`user-check`,[[`path`,{d:`m16 11 2 2 4-4`,key:`9rsbq5`}],[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),U=N(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]),W=N(`user-x`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`17`,x2:`22`,y1:`8`,y2:`13`,key:`3nzzx3`}],[`line`,{x1:`22`,x2:`17`,y1:`8`,y2:`13`,key:`1swrse`}]]);C();var G=[[`faceGallery`]];function K({identityId:t}){let n=T(),{data:r,isLoading:i}=o({identityId:t}),a=e();function s(e){a.mutate({identityId:t,sampleId:e.id},{onSettled:()=>{n.invalidateQueries({queryKey:G})}})}return i?E(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[w(B,{className:`h-3.5 w-3.5 animate-spin`}),`Loading samples…`]}):!r||r.length===0?w(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No samples yet.`}):w(`div`,{className:`mt-2 grid grid-cols-4 gap-2 sm:grid-cols-6 md:grid-cols-8`,children:r.map(e=>E(`div`,{className:`group relative aspect-square overflow-hidden rounded-md border border-border bg-surface`,children:[e.base64?w(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Sample`,className:`h-full w-full object-cover`}):w(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:w(U,{className:`h-6 w-6`})}),w(`button`,{type:`button`,onClick:()=>s(e),disabled:a.isPending,className:`absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100 disabled:cursor-not-allowed`,"aria-label":`Remove sample`,children:w(L,{className:`h-4 w-4 text-white`})})]},e.id))})}function q({identity:e,expanded:t,onToggle:n}){let i=T(),[a,o]=x(``),[s,c]=x(!1),[m,b]=x(!1),S=p(),C=r();function k(){o(e.name),c(!0)}function A(){c(!1),o(``)}function j(){let t=a.trim();if(!t||t===e.name){A();return}S.mutate({id:e.id,name:t},{onSettled:()=>{i.invalidateQueries({queryKey:G}),A()}})}function M(){C.mutate({id:e.id},{onSettled:()=>{i.invalidateQueries({queryKey:G}),b(!1)}})}return E(`div`,{className:`rounded-md border border-border bg-surface`,children:[E(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[w(`div`,{className:`h-8 w-8 shrink-0 overflow-hidden rounded-full border border-border bg-surface-hover`,children:e.coverBase64?w(`img`,{src:`data:image/jpeg;base64,${e.coverBase64}`,alt:e.name,className:`h-full w-full object-cover`}):w(`div`,{className:`flex h-full w-full items-center justify-center`,children:w(U,{className:`h-4 w-4 text-foreground-subtle`})})}),w(`div`,{className:`flex flex-1 min-w-0 items-center gap-2`,children:s?E(D,{children:[w(y,{value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j(),e.key===`Escape`&&A()},className:`h-6 text-xs`,autoFocus:!0}),w(`button`,{type:`button`,onClick:j,disabled:S.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Confirm rename`,children:w(P,{className:`h-3.5 w-3.5`})}),w(`button`,{type:`button`,onClick:A,className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel rename`,children:w(L,{className:`h-3.5 w-3.5`})})]}):w(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name})}),w(d,{variant:`default`,className:`text-[10px]`,children:e.sampleCount}),!s&&E(`div`,{className:`flex items-center gap-1`,children:[w(`button`,{type:`button`,onClick:k,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground`,"aria-label":`Rename`,children:w(O,{className:`h-3.5 w-3.5`})}),w(`button`,{type:`button`,onClick:()=>b(!0),className:`p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger`,"aria-label":`Delete`,children:w(z,{className:`h-3.5 w-3.5`})})]}),w(`button`,{type:`button`,onClick:n,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":t?`Collapse`:`Expand`,children:w(t?I:F,{className:`h-3.5 w-3.5`})})]}),t&&w(`div`,{className:`border-t border-border px-3 pb-3 pt-2`,children:w(K,{identityId:e.id})}),w(_,{open:m,onOpenChange:e=>!e&&b(!1),children:E(f,{children:[E(v,{children:[w(u,{children:`Delete person`}),E(l,{children:[`Delete `,w(`strong`,{children:e.name}),` and all their samples? This cannot be undone.`]})]}),E(h,{children:[w(g,{variant:`secondary`,onClick:()=>b(!1),children:`Cancel`}),E(g,{variant:`danger`,onClick:M,disabled:C.isPending,children:[C.isPending?w(B,{className:`h-3.5 w-3.5 animate-spin`}):null,`Delete`]})]})]})})]})}function J(){let e=T(),[t,n]=x(``),r=b();function i(){let i=t.trim();i&&r.mutate({name:i},{onSettled:()=>{e.invalidateQueries({queryKey:G}),n(``)}})}return E(`div`,{className:`flex items-center gap-2 pt-2`,children:[w(y,{placeholder:`New person name…`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i()},className:`h-7 text-xs flex-1`}),E(g,{variant:`primary`,size:`sm`,onClick:i,disabled:r.isPending||!t.trim(),children:[r.isPending?w(B,{className:`h-3.5 w-3.5 animate-spin`}):w(k,{className:`h-3.5 w-3.5`}),`Add`]})]})}function Y(){let{data:e,isLoading:t}=n(),[r,i]=x(null);function a(e){i(t=>t===e?null:e)}return t?E(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[w(B,{className:`h-4 w-4 animate-spin`}),`Loading people…`]}):E(`div`,{className:`space-y-2`,children:[(!e||e.length===0)&&w(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No people enrolled yet. Add one below.`}),e?.map(e=>w(q,{identity:e,expanded:r===e.id,onToggle:()=>a(e.id)},e.id)),w(J,{})]})}C();var X=[[`faceGallery`]];function Z({faceIds:e,identities:n,onDone:r}){let i=T(),a=t(),o=b(),[s,c]=x(``),[d,p]=x(!1),[m,S]=x(null),C=e!==null&&e.length>0,D=e?.length??0;function O(){p(!1),c(``),S(null)}function k(){O(),r()}function A(t){!e||e.length===0||a.mutate({faceIds:[...e],identityId:t},{onSettled:()=>{i.invalidateQueries({queryKey:X}),k()}})}function j(){!e||!s.trim()||o.mutate({name:s.trim()},{onSuccess:e=>{e?.id&&A(e.id)},onError:()=>{i.invalidateQueries({queryKey:X}),k()}})}let M=a.isPending||o.isPending;return w(_,{open:C,onOpenChange:e=>!e&&k(),children:E(f,{children:[E(v,{children:[w(u,{children:D>1?`Assign ${D} faces to person`:`Assign face to person`}),w(l,{children:`Select an existing person or create a new one.`})]}),w(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:n.map(e=>E(`button`,{type:`button`,onClick:()=>S(e.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${m===e.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[w(`span`,{className:`font-medium`,children:e.name}),E(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.sampleCount,` samples`]})]},e.id))}),d?w(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:w(y,{placeholder:`New person name…`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j()},autoFocus:!0,className:`flex-1`})}):w(`button`,{type:`button`,onClick:()=>{S(null),p(!0)},className:`mt-2 w-full rounded-md border border-dashed border-border px-3 py-2 text-left text-xs text-foreground-subtle hover:border-primary hover:text-primary transition-colors`,children:`+ New person…`}),E(h,{children:[w(g,{variant:`secondary`,onClick:k,disabled:M,children:`Cancel`}),d?E(g,{variant:`primary`,onClick:j,disabled:M||!s.trim(),children:[M&&w(B,{className:`h-3.5 w-3.5 animate-spin`}),`Create & assign`]}):E(g,{variant:`primary`,onClick:()=>m&&A(m),disabled:M||!m,children:[M&&w(B,{className:`h-3.5 w-3.5 animate-spin`}),`Assign`,D>1?` ${D}`:``]})]})]})})}function Q({face:e,selected:t,onToggleSelect:n,onAssign:r}){let i=T(),o=a(),s=c(),l=()=>{i.invalidateQueries({queryKey:X})};return E(`div`,{className:`group relative flex flex-col gap-1 rounded-md border bg-surface overflow-hidden ${t?`border-primary ring-1 ring-primary`:`border-border`}`,children:[E(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[e.base64?w(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Face`,className:`h-full w-full object-cover`}):w(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:w(U,{className:`h-8 w-8`})}),w(`button`,{type:`button`,onClick:()=>n(e.faceId),className:`absolute left-1 top-1 rounded bg-black/40 p-0.5 text-white hover:bg-black/60`,"aria-label":t?`Deselect`:`Select`,children:t?w(j,{className:`h-3.5 w-3.5 text-primary`}):w(M,{className:`h-3.5 w-3.5`})}),E(`div`,{className:`absolute inset-0 flex items-center justify-center gap-2 bg-black/50 opacity-0 transition-opacity group-hover:opacity-100`,children:[e.assigned?w(`button`,{type:`button`,onClick:()=>o.mutate({faceId:e.faceId},{onSettled:l}),disabled:o.isPending,className:`rounded-full bg-warning/80 p-1.5 text-white hover:bg-warning disabled:opacity-50`,title:`Detach`,children:o.isPending?w(B,{className:`h-3.5 w-3.5 animate-spin`}):w(W,{className:`h-3.5 w-3.5`})}):w(`button`,{type:`button`,onClick:()=>r(e.faceId),className:`rounded-full bg-primary/80 p-1.5 text-white hover:bg-primary`,title:`Assign to person`,children:w(H,{className:`h-3.5 w-3.5`})}),w(`button`,{type:`button`,onClick:()=>s.mutate({faceId:e.faceId},{onSettled:l}),disabled:s.isPending,className:`rounded-full bg-danger/80 p-1.5 text-white hover:bg-danger disabled:opacity-50`,title:`Delete face`,children:s.isPending?w(B,{className:`h-3.5 w-3.5 animate-spin`}):w(z,{className:`h-3.5 w-3.5`})})]})]}),E(`div`,{className:`px-2 pb-2 space-y-0.5`,children:[w(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.deviceId}),e.identityName&&w(`p`,{className:`text-[10px] font-medium text-primary truncate`,title:e.identityName,children:e.identityName})]})]})}var $=[{label:`All`,value:`all`},{label:`Unassigned`,value:`unassigned`},{label:`Recognized`,value:`recognized`}];function ee(){let e=T(),[r,a]=x(`all`),[o,l]=x(new Set),[u,d]=x(null),[f,p]=x(!1),{data:h,isLoading:_}=m({limit:100,filter:r}),{data:v=[]}=n(),{data:y,isFetching:b}=i({threshold:.5,minClusterSize:2,limit:20},{enabled:f}),C=t(),D=s(),O=c(),k=h??[],j=S(()=>new Map(k.map(e=>[e.faceId,e])),[k]),M=()=>{e.invalidateQueries({queryKey:X})},N=()=>l(new Set);function P(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function F(e){l(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}let I=[...o],R=C.isPending||D.isPending||O.isPending;function V(){I.length!==0&&D.mutate({faceIds:I},{onSettled:()=>{M(),N()}})}function G(){I.length!==0&&Promise.allSettled(I.map(e=>O.mutateAsync({faceId:e}))).then(()=>{M(),N()})}return E(`div`,{className:`space-y-3`,children:[E(`div`,{className:`flex items-center gap-1`,children:[$.map(e=>w(`button`,{type:`button`,onClick:()=>a(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${r===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.label},e.value)),E(`button`,{type:`button`,onClick:()=>p(e=>!e),className:`ml-2 flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${f?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[w(A,{className:`h-3.5 w-3.5`}),` Similar groups`]}),!_&&E(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:[k.length,` face`,k.length===1?``:`s`]})]}),o.size>0&&E(`div`,{className:`flex items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[E(`span`,{className:`text-xs font-medium text-foreground`,children:[o.size,` selected`]}),E(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[E(g,{variant:`primary`,onClick:()=>d(I),disabled:R,children:[w(H,{className:`h-3.5 w-3.5`}),` Assign`]}),E(g,{variant:`secondary`,onClick:V,disabled:R,children:[D.isPending?w(B,{className:`h-3.5 w-3.5 animate-spin`}):w(W,{className:`h-3.5 w-3.5`}),` `,`Detach`]}),E(g,{variant:`secondary`,onClick:G,disabled:R,children:[w(z,{className:`h-3.5 w-3.5`}),` Delete`]}),w(g,{variant:`ghost`,onClick:N,disabled:R,children:w(L,{className:`h-3.5 w-3.5`})})]})]}),f&&E(`div`,{className:`rounded-md border border-border bg-surface p-3`,children:[w(`p`,{className:`mb-2 text-xs font-medium text-foreground`,children:`Look-alike groups`}),b?E(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[w(B,{className:`h-4 w-4 animate-spin`}),` Finding similar faces…`]}):!y||y.length===0?w(`p`,{className:`text-xs text-foreground-subtle`,children:`No look-alike groups found among unassigned faces.`}):w(`div`,{className:`space-y-2`,children:y.map(e=>E(`div`,{className:`flex items-center gap-2 rounded-md bg-surface-hover/50 p-2`,children:[w(`div`,{className:`flex -space-x-1.5`,children:e.faceIds.slice(0,6).map(e=>{let t=j.get(e);return w(`div`,{className:`h-8 w-8 overflow-hidden rounded border border-border bg-surface`,children:t?.base64?w(`img`,{src:`data:image/jpeg;base64,${t.base64}`,alt:``,className:`h-full w-full object-cover`}):w(U,{className:`h-full w-full p-1.5 text-foreground-subtle`})},e)})}),E(`span`,{className:`text-xs text-foreground-subtle`,children:[e.size,` faces · `,Math.round(e.cohesion*100),`% alike`]}),E(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[w(g,{variant:`secondary`,onClick:()=>F(e.faceIds),children:`Select group`}),E(g,{variant:`primary`,onClick:()=>d(e.faceIds),children:[w(H,{className:`h-3.5 w-3.5`}),` Assign all`]})]})]},e.representativeFaceId))})]}),_&&E(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[w(B,{className:`h-4 w-4 animate-spin`}),` Loading faces…`]}),!_&&k.length===0&&w(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:`No faces found for this filter.`}),!_&&k.length>0&&w(`div`,{className:`grid grid-cols-4 gap-2 sm:grid-cols-6 md:grid-cols-8 lg:grid-cols-10`,children:k.map(e=>w(Q,{face:e,selected:o.has(e.faceId),onToggleSelect:P,onAssign:e=>d([e])},e.faceId))}),w(Z,{faceIds:u,identities:v,onDone:()=>{d(null),N()}})]})}function te(){return w(V,{icon:R,title:`Detection Intelligence`,subtitle:`Manage enrolled identities and assign detected face crops to people.`,children:E(`section`,{className:`space-y-3`,children:[E(`div`,{children:[w(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`People`}),w(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Enrolled identities used for face recognition. Expand a row to view or remove training samples.`}),w(Y,{})]}),E(`div`,{className:`pt-4 border-t border-border`,children:[w(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Recent detected faces`}),w(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Face crops captured by the detection pipeline. Assign them to a person to build recognition training data.`}),w(ee,{})]})]})})}export{te as DetectionIntelligencePage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{A as e,Ai as t,Ar as n,B as r,E as i,G as a,Gi as o,Gn as s,H as c,I as l,Ji as u,Jt as d,K as f,Ki as p,Kn as m,L as h,Pi as g,Pr as _,Qi as v,Sn as y,T as b,Tt as x,U as S,V as C,Vr as w,W as T,Wi as E,Yi as D,Yr as O,Yt as k,_n as A,a as j,an as M,bn as ee,cn as N,di as P,dn as F,f as I,fn as te,g as ne,gn as re,hn as L,i as ie,ii as ae,in as oe,j as se,k as ce,ki as le,l as ue,ln as de,lr as fe,lt as pe,m as me,mn as he,n as ge,ni as _e,nn as ve,o as ye,p as be,pn as xe,qn as Se,qt as Ce,r as R,u as we,ui as Te,un as Ee,va as De,vn as Oe,w as ke,xn as Ae,xr as je,y as Me,ya as Ne,yn as Pe,zn as Fe,zr as Ie}from"./src-BB1LG2-C.js";import{F as z,G as B,R as V,U as H,W as U,X as W,b as G,o as K,t as Le,x as q,y as Re}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CK8iQdP1.js";import{c as ze,k as Be,p as J,r as Ve,t as He,u as Ue}from"./player-overlays-ZG1nYuYj.js";import{C as We,E as Ge,b as Y,g as Ke,v as qe}from"./src-Cno9Ci3x.js";import{t as Je}from"./CapabilityBadges-CqlDFU27.js";import{t as Ye}from"./bell-CRa7XWAs.js";import{n as Xe,t as Ze}from"./rotate-ccw-CZ8RwUso.js";import{t as Qe}from"./ProviderIcon-BS00rCO4.js";import{t as $e}from"./pencil-WwVUhRC9.js";import{t as et}from"./plus-D2fCWFPc.js";import{t as tt}from"./refresh-cw-DewUBhjl.js";import{t as nt}from"./rotate-cw-DiyghCam.js";import{t as rt}from"./server-DnaOYw5t.js";import{t as it}from"./wifi-BJgMgcFe.js";import{B as X,F as at,H as ot,I as st,O as ct,U as lt,W as ut,_ as dt,a as ft,c as pt,i as mt,k as ht,p as gt,r as _t,s as vt,t as yt,v as bt,x as xt,z as St}from"./index-D5OTguVm.js";import{t as Ct}from"./StatusBadge-CkYubfRG.js";import{n as wt,t as Tt}from"./useDevice-BuSIXBXp.js";import{n as Et,r as Dt,t as Ot}from"./SchemaTabBar-ByWwzBUZ.js";import{t as kt}from"./FormBuilder-DBTf1H_B.js";import{t as At}from"./useEventInvalidation-wNGhDdi_.js";var jt=X(`circle-help`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Mt=X(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),Nt=X(`link-2-off`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),Pt=X(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Ft=X(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),It=X(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Lt=X(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),Rt=X(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]);W();var zt=`device-export`,Bt=`export`,Vt=`Export`;function Ht(e){return e.type===`separator`||e.type===`info`||e.type===`object-array`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`?!1:e.type===`group`?e.fields.some(Ht):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(Ht)):e.writerCapName===zt}function Ut(e){return e.fields.some(Ht)}function Wt(e){return j(J().trpcClient,e)}function Gt(e){let[t,n]=B(`idle`),[r,i]=B(null),a=U(null),o=U(null),c=U(null),l=U(!0),u=m(),d=s(),f=Se(),p=z(()=>{if(a.current){try{a.current.close()}catch{}a.current=null}if(o.current){for(let e of o.current.getTracks())try{e.stop()}catch{}o.current=null}c.current=null},[]),h=z(async()=>{if(t===`idle`)return;n(`stopping`);let r=c.current;if(r&&e!==null)try{await Promise.race([f.mutateAsync({deviceId:e,sessionId:r}),new Promise((e,t)=>setTimeout(()=>t(Error(`server stopSession timeout`)),2e3))])}catch(e){console.warn(`[intercom] server stopSession failed (continuing teardown)`,e)}p(),l.current&&(n(`idle`),i(null))},[t,e,f,p]),g=z(async()=>{if(e===null||t!==`idle`&&t!==`error`)return;i(null);let r=null,s=null,p=null;try{n(`requesting-mic`),r=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),o.current=r,n(`starting`);let t=await u.mutateAsync({deviceId:e});p=t.sessionId,c.current=p,n(`connecting`),s=new RTCPeerConnection,a.current=s,s.oniceconnectionstatechange=()=>{if(!l.current)return;let e=s.iceConnectionState;e===`connected`||e===`completed`?n(`talking`):(e===`failed`||e===`closed`||e===`disconnected`)&&l.current&&(i(e===`failed`?`WebRTC connection failed`:null),h())};for(let e of r.getAudioTracks())s.addTrack(e,r);await s.setRemoteDescription({type:`offer`,sdp:t.sdpOffer});let f=await s.createAnswer();await s.setLocalDescription(f);let m=s.localDescription?.sdp??f.sdp??``;await d.mutateAsync({deviceId:e,sessionId:p,sdpAnswer:m})}catch(t){let u=t instanceof Error?t.message:String(t);if(console.warn(`[intercom] start failed`,t),s)try{s.close()}catch{}if(r)for(let e of r.getTracks())try{e.stop()}catch{}if(a.current=null,o.current=null,p!==null)try{await f.mutateAsync({deviceId:e,sessionId:p})}catch{}c.current=null,l.current&&(i(u),n(`error`))}},[e,t,u,d,f,h]);return V(()=>(l.current=!0,()=>{l.current=!1;let t=c.current;if(t!==null&&e!==null&&f.mutate({deviceId:e,sessionId:t}),a.current){try{a.current.close()}catch{}a.current=null}if(o.current){for(let e of o.current.getTracks())try{e.stop()}catch{}o.current=null}c.current=null}),[e]),{state:t,error:r,start:g,stop:h,isTalking:t===`talking`}}W();var Kt=0;function Z(){return++Kt}function qt(e){switch(e.type){case`system`:return`system`;case`device`:return`#${e.deviceId}`;case`provider`:return e.providerId;case`addon`:return e.addonId}}function Jt(e){return[``,`Commands`,` help Show this help`,` examples Show usage examples for the current scope`,` context Show every available variable + full API surface`,` clear Clear terminal (also Ctrl+L)`,``,`Shortcuts`,` Enter Execute expression`,` Arrow Up/Down Navigate command history`,` Ctrl+L Clear terminal`,``,`Try: ${{system:` sm.summary() // fleet overview`,device:` device.state.battery.value?.sleeping // sync read`,provider:` devices.map(d => d.name)`,addon:` manifest.version`}[e.type]}`,``,`Top-level objects: sm (SystemMirror), DeviceType, Math, JSON, Date, …`]}function Yt(e){switch(e.type){case`device`:return[``,`── State (sync, zero round-trip) ─────────────────────────`,` device.state.battery.value`,` device.state.battery.value?.percentage`,` device.state.motion.value?.detected`,``,`── Actions (async, through wrapper chain) ────────────────`,` await device.snapshot.getSnapshot({})`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.switch.setState({ on: true })`,``,`── Wait for condition ───────────────────────────────────`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`── Subscribe to changes ─────────────────────────────────`,` const off = device.state.battery.subscribe(s => console.log(s))`,``,`── Quick info ───────────────────────────────────────────`,` info.name device name`,` info.addonId owning addon`,` sm.dump(deviceId) full debug dump`];case`system`:return[``,`── Lookups ──────────────────────────────────────────────`,` sm.getDeviceById(8)`,` sm.getDeviceByName('Sala da pranzo')`,` sm.getDevicesByAddon('reolink')`,` sm.getDevicesByType(DeviceType.Camera)`,``,`── Filters (typed query) ────────────────────────────────`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] })`,` sm.query({ name: /^Cam-/ })`,``,`── Cross-device ─────────────────────────────────────────`,` sm.whereState('battery', s => s.percentage < 20).length`,` sm.mapState('battery', s => s.percentage)`,` sm.countByCap('snapshot')`,``,`── Batch action ─────────────────────────────────────────`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,``,`── Listen ───────────────────────────────────────────────`,` sm.listenCap('motion', (id, s) => console.log(id, s))`,` sm.onDeviceAdded((id, info) => console.log('+', info.name))`,``,`── Diagnostics ──────────────────────────────────────────`,` sm.summary()`,` sm.dump(8)`];case`provider`:return[``,` devices.map(d => d.name)`,` await getIntegration()`,` sm.getDevicesByAddon('<this-addon-id>').length`];case`addon`:return[``,` manifest.name`,` manifest.version`,` declaration`]}}function Xt(e){let t=[``,`Scope: ${e.type}`,``];switch(e.type){case`system`:return[...t,`Primary API — sm (SystemMirror):`,` sm.getDeviceById(id) DeviceProxy | null (sync)`,` sm.getDeviceByName(name) DeviceProxy | null`,` sm.getDeviceByStableId(sid) DeviceProxy | null`,` sm.getAllDevices() readonly DeviceProxy[]`,` sm.getDeviceInfo(id) DeviceInfo | null`,` sm.summary() fleet stats`,``,`Filters — sm.query({...}):`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] }) // ALL caps required`,` sm.query({ anyCap: ['ptz', 'motion'] }) // ANY cap`,` sm.query({ name: { contains: 'sala' } }) // case-insensitive`,` sm.query({ name: /^Cam-\\d+$/ })`,` sm.query({ type: DeviceType.Camera })`,` sm.query({ parentDeviceId: 8 }) // accessories of cam 8`,` sm.query({ where: (info, dev) => dev.state.battery.value?.sleeping })`,``,`State queries:`,` sm.whereState('battery', s => s.percentage < 20)`,` sm.mapState('battery', s => s.percentage)`,` sm.findState('motion', s => s.detected)`,` sm.countByCap('snapshot')`,``,`Listeners (return unsubscribe fn):`,` sm.listen((id, cap, slice) => …) // every state change`,` sm.listenCap('motion', (id, slice) => …)`,` sm.listenDevice(8, (id, cap, slice) => …)`,` sm.onDeviceAdded((id, info) => …)`,` sm.onDeviceRemoved((id, info) => …)`,``,`Wait primitives:`,` await sm.waitForState(8, 'battery', s => !s.sleeping, 30_000)`,` await sm.waitForDevice(99, 30_000)`,``,`Batch:`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,` await sm.forEachCap('reboot', d => d.reboot.reboot({}))`,``,`Diagnostics:`,` sm.dump(8) debug dump (one device)`,` sm.dump() full fleet dump`,` sm.summary() breakdown by cap/addon/type`,``,`Legacy: deviceRegistry, addonRegistry, eventBus, devices(), addons()`];case`device`:return[...t,`Pre-bound variables:`,` device DeviceProxy for this device (sync state + async methods)`,` deviceId number`,` info DeviceInfo metadata (name, addonId, type, online, …)`,` sm SystemMirror (full cluster view)`,` rawDevice legacy IDevice instance (escape hatch)`,``,`Reactive state (sync, zero round-trip):`,` device.state.battery.value BatteryStatus | undefined`,` device.state.battery.value?.sleeping`,` device.state.battery.value?.percentage`,` device.state.motion.value?.detected`,` device.state.switch.value?.on`,` device.state.brightness.value?.percentage`,` device.state.doorbell.value?.lastPressedAt`,``,`Cap actions (async, through wrapper chain):`,` await device.snapshot.getSnapshot({})`,` await device.snapshot.getSnapshot({ streamId: 'high' })`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.ptz.goToPreset({ presetId: 'home' })`,` await device.switch.setState({ on: true })`,` await device.brightness.setBrightness({ percentage: 60 })`,` await device.reboot.reboot({})`,``,`Subscribe to slice changes:`,` const off = device.state.battery.subscribe(s => console.log(s))`,` // off() to unsubscribe`,``,`Wait for a state condition:`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`Diagnostics:`,` info.name device name`,` info.addonId which addon owns it`,` info.online transport health`,` sm.dump(deviceId) full debug dump (binding + state + info)`];case`provider`:return[...t,`Pre-bound variables:`,` devices Devices belonging to this provider (raw IDevice[])`,` getIntegration() Integration metadata`,``,`For typed device access use the SystemMirror:`,` await getSystemMirror()`,` sm.getDevicesByAddon('this-addon-id')`];case`addon`:return[...t,`Pre-bound variables:`,` manifest { name, version, ... }`,` declaration addon declaration`,` source addon source location`,``,`Examples:`,` manifest.name`,` manifest.version`]}}function Zt({scope:e,greeting:t,className:n}){let r=J(),[i,a]=B(()=>{let n=[];return t&&n.push({id:Z(),kind:`info`,text:t}),n.push({id:Z(),kind:`info`,text:`scope: ${qt(e)} — type help or context for available commands`}),n}),[o,s]=B(``),[c,l]=B([]),[u,d]=B(-1),f=U(null),p=U(null);V(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight)},[i]);let m=z(()=>{f.current?.focus()},[]),h=Le({mutationFn:t=>r.trpcClient.repl.execute.mutate({code:t,scope:e}),onSuccess:e=>{let t=e??{},n=typeof t.output==`string`?t.output:e==null?`undefined`:typeof e==`string`?e:JSON.stringify(e,null,2),r=t.type===`error`;a(e=>[...e,{id:Z(),kind:r?`error`:`result`,text:n}])},onError:e=>{let t=e instanceof Error?e.message:String(e);a(e=>[...e,{id:Z(),kind:`error`,text:t}])}});function g(t){let n=t.trim();if(n){if(n===`clear`){a([{id:Z(),kind:`info`,text:`scope: ${qt(e)}`}]),s(``);return}if(n===`help`){a(t=>[...t,{id:Z(),kind:`input`,text:`> ${n}`},...Jt(e).map(e=>({id:Z(),kind:`info`,text:e}))]),s(``);return}if(n===`context`){a(t=>[...t,{id:Z(),kind:`input`,text:`> ${n}`},...Xt(e).map(e=>({id:Z(),kind:`info`,text:e}))]),s(``);return}if(n===`examples`){a(t=>[...t,{id:Z(),kind:`input`,text:`> ${n}`},...Yt(e).map(e=>({id:Z(),kind:`info`,text:e}))]),s(``);return}l(e=>[...e,n]),d(-1),a(e=>[...e,{id:Z(),kind:`input`,text:`> ${n}`}]),s(``),h.mutate(n)}}function _(t){if(t.key===`Enter`){t.preventDefault(),g(o);return}if(t.key===`ArrowUp`){if(t.preventDefault(),c.length===0)return;let e=u===-1?c.length-1:Math.max(0,u-1);d(e),s(c[e]??``);return}if(t.key===`ArrowDown`){if(t.preventDefault(),u===-1)return;let e=u+1;e>=c.length?(d(-1),s(``)):(d(e),s(c[e]??``));return}t.ctrlKey&&t.key===`l`&&(t.preventDefault(),a([{id:Z(),kind:`info`,text:`scope: ${qt(e)}`}]))}let v={input:`text-zinc-300`,result:`text-emerald-300`,error:`text-red-300`,info:`text-zinc-400`};return q(`div`,{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${n??``}`,onClick:m,children:[q(`div`,{ref:p,className:`flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]`,children:[i.map(e=>G(`pre`,{className:`whitespace-pre-wrap break-words leading-relaxed ${v[e.kind]}`,children:e.text},e.id)),h.isPending&&G(`span`,{className:`text-zinc-500 animate-pulse`,children:`…thinking`})]}),q(`div`,{className:`flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]`,children:[G(`span`,{className:`text-emerald-400 flex-shrink-0 select-none font-bold`,children:`>`}),G(`input`,{ref:f,value:o,onChange:e=>s(e.target.value),onKeyDown:_,disabled:h.isPending,placeholder:`device.state.battery.value`,autoFocus:!0,className:`flex-1 bg-transparent text-zinc-100 placeholder:text-zinc-600 focus:outline-none caret-emerald-400 disabled:opacity-50`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`})]})]})}function Qt({deviceId:e,intercomAvailable:t=!1}){let n=J(),r=typeof window<`u`?window.location.origin:``,a=Number.isFinite(e),o=Wt(a?e:null),{streams:s,pipelineMetrics:c,createSession:l,sendAnswer:u,handleOffer:d,getIceServers:f,addIceCandidate:p,getIceCandidates:m,closeSession:h,getSessionState:g}=ie(n.trpcClient,a?e:null),_=T(n.trpcClient,a?e:null),v=Gt(a&&t?e:null),y=v.state===`requesting-mic`||v.state===`starting`||v.state===`connecting`||v.state===`stopping`,b=v.isTalking||y,x=()=>{v.state===`idle`||v.state===`error`?v.start():v.state!==`stopping`&&v.stop()},S=Ve(),C=i(),w=typeof window<`u`?window.localStorage.getItem(`camstack_admin_token`):null,E=S.length>0?G(Re,{children:S.map(e=>G(`div`,{className:`absolute inset-0`,children:e.node},e.id))}):null;return G(Me,{serverUrl:r,createSession:l,sendAnswer:u,handleOffer:d,getIceServers:f,addIceCandidate:p,getIceCandidates:m,closeSession:h,getSessionState:g,...C.request?{playbackUrl:C.request.url,playbackAuthToken:w,...C.request.label?{playbackLabel:C.request.label}:{},onExitPlayback:()=>C.clear()}:{},streams:s,pipelineMetrics:c,phase:o.phase,detections:o,defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:_.src,..._.src?{posterUrl:_.src}:{},snapshotLoading:_.loading,onRefreshSnapshot:_.refresh,intercomAvailable:t,intercomShown:b,onIntercomToggle:x,extraOverlay:E,chromeless:!0,className:`h-full`})}function $t({deviceId:e,containerDeviceId:t}){return Number.isFinite(e)?G(`div`,{className:`flex flex-col h-full`,children:G(ne,{...t===void 0?{deviceId:e}:{containerDeviceId:t},limit:50,maxHeight:`max-h-full`,showScope:!1,showFilters:!1})}):q(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function en({deviceId:e}){if(!Number.isFinite(e))return q(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]});let t=[`CamStack REPL — device #${e}`,``,` device.state.battery.value sync state read`,` await device.snapshot.getSnapshot({}) cap action`,``,` type 'examples' for more, 'context' for the full API`].join(`
|
|
2
|
-
`);return G(Zt,{scope:{type:`device`,deviceId:e},greeting:t,className:`h-full border-0 rounded-none`})}function tn({deviceId:e}){return Number.isFinite(e)?G(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:G(me,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):q(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function nn({deviceId:e}){return Number.isFinite(e)?G(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:G(I,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):q(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function rn({parentDeviceId:e}){let{t}=yt(),n=ot(),i=J(),{data:a,isLoading:o,isError:s}=wt(e),{data:l}=N({deviceId:e},{enabled:Number.isFinite(e)});if(o)return G(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:G(`p`,{className:`text-[10px] text-foreground-subtle`,children:t(`common.loading`,{defaultValue:`Loading…`})})});if(s)return G(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:G(`p`,{className:`text-[10px] text-warning`,children:t(`integrations.childrenLoadError`,{defaultValue:`Failed to load children`})})});let u=a??[];if(u.length===0)return null;let d=C(l?.stableId??``,u,l?.childLayout),f=d.ungrouped,p=e=>n(`/devices/${String(e)}`),m=(e,t)=>G(r,{trpc:i.trpcClient,device:t,variant:`minimal`,onNavigate:p},e),h=f.some(e=>!!e.role),g=f.some(e=>!e.role),_=h&&!g?t(`device.accessories`,{defaultValue:`Accessories`}):!h&&g?t(`device.adoptedDevices`,{defaultValue:`Adopted devices`}):t(`device.children`,{defaultValue:`Children`}),v=f.length>0?q(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[G(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5`,children:_}),G(`div`,{className:`space-y-1`,children:f.map(e=>m(e.id,e))})]}):null,y=d.disabledSection===void 0?null:G(c,{title:t(`device.disabledSection`,{defaultValue:`Disabled`}),count:d.disabledSection.children.length,defaultOpen:!1,children:G(`div`,{className:`opacity-60 space-y-1`,children:d.disabledSection.children.map(e=>m(e.id,e))})},d.disabledSection.title);return d.sections.length===0?y===null?v:q(`div`,{className:`space-y-2`,children:[v,y]}):q(`div`,{className:`space-y-2`,children:[d.sections.map(e=>G(c,{title:e.title,count:e.children.length,defaultOpen:e.defaultOpen,children:e.children.map(e=>m(e.id,e))},e.title)),v,y]})}function Q({label:e,value:t}){return q(`div`,{className:`${Be} flex items-start gap-2 sm:gap-3`,children:[G(`span`,{className:`w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle`,children:e}),G(`div`,{className:`flex-1 min-w-0 text-[11px] text-foreground`,children:t})]})}W();function an({deviceId:e,initialName:t}){let n=K(),[r,i]=B(!1),[a,o]=B(t),[s,c]=B(!1),l=U(null);V(()=>{r||o(t)},[t,r]),V(()=>{r&&l.current?.focus()},[r]);let u=Oe({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`,`getDevice`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),d=async()=>{let n=a.trim();if(n.length===0||n===t){i(!1),o(t);return}c(!0);try{await u.mutateAsync({deviceId:e,name:n}),i(!1)}catch{}finally{c(!1)}},f=()=>{o(t),i(!1)};return r?G(Q,{label:`Name`,value:q(`div`,{className:`flex items-center gap-1`,children:[G(`input`,{ref:l,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?d():e.key===`Escape`&&f()},disabled:s,className:`flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),G(`button`,{type:`button`,onClick:()=>void d(),disabled:s,className:`p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50`,"aria-label":`Save`,children:G(at,{className:`h-3 w-3`})}),G(`button`,{type:`button`,onClick:f,disabled:s,className:`p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50`,"aria-label":`Cancel`,children:G(mt,{className:`h-3 w-3`})})]})}):G(Q,{label:`Name`,value:q(`div`,{className:`flex items-center gap-2 group`,children:[G(`span`,{className:`truncate`,children:t}),G(`button`,{type:`button`,onClick:()=>i(!0),className:`opacity-0 group-hover:opacity-100 transition-opacity p-0.5 rounded hover:bg-surface-hover`,"aria-label":`Edit name`,children:G($e,{className:`h-3 w-3 text-foreground-subtle`})})]})})}W();function on({deviceId:e,initialLocation:t}){let n=K(),[r,i]=B(!1),[a,o]=B(t??``),[s,c]=B(!1),l=U(null),{data:u}=xe(void 0,{enabled:r}),d=u??[];V(()=>{r||o(t??``)},[t,r]),V(()=>{r&&l.current?.focus()},[r]);let f=A({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`,`getDevice`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]})}}),p=H(()=>{let e=a.trim().toLowerCase();return e.length===0?d:d.filter(t=>t.toLowerCase()!==e&&t.toLowerCase().includes(e))},[d,a]),m=a.trim().length>0&&!d.some(e=>e.toLowerCase()===a.trim().toLowerCase()),h=async n=>{let r=(n??a).trim(),o=r.length===0?null:r;if(o===(t??null)){i(!1);return}c(!0);try{await f.mutateAsync({deviceId:e,location:o}),i(!1)}catch{}finally{c(!1)}},g=()=>{o(t??``),i(!1)};return r?G(Q,{label:`Location`,value:q(`div`,{className:`relative`,children:[q(`div`,{className:`flex items-center gap-1`,children:[G(`input`,{ref:l,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?h():e.key===`Escape`&&g()},disabled:s,placeholder:`Room / area (or leave empty to clear)`,className:`flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),G(`button`,{type:`button`,onClick:()=>void h(),disabled:s,className:`p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50`,"aria-label":`Save`,children:G(at,{className:`h-3 w-3`})}),G(`button`,{type:`button`,onClick:g,disabled:s,className:`p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50`,"aria-label":`Cancel`,children:G(mt,{className:`h-3 w-3`})})]}),(p.length>0||m)&&q(`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:[p.map(e=>q(`button`,{type:`button`,onClick:()=>{o(e),h(e)},className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover`,children:[G(Ft,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),G(`span`,{className:`truncate`,children:e})]},e)),m&&q(`button`,{type:`button`,onClick:()=>void h(),className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover border-t border-border`,children:[G(`span`,{className:`text-foreground-subtle`,children:`Create`}),q(`span`,{className:`font-medium truncate`,children:[`"`,a.trim(),`"`]})]})]})]})}):G(Q,{label:`Location`,value:q(`div`,{className:`flex items-center gap-2 group`,children:[t?G(`span`,{className:`truncate`,children:t}):G(`span`,{className:`italic text-foreground-subtle`,children:`unset`}),G(`button`,{type:`button`,onClick:()=>i(!0),className:`opacity-0 group-hover:opacity-100 transition-opacity p-0.5 rounded hover:bg-surface-hover`,"aria-label":`Edit location`,children:G($e,{className:`h-3 w-3 text-foreground-subtle`})})]})})}W();var sn=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`];function cn(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function ln(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function un(){let t=e(),n=se(),{data:r}=N({deviceId:t??0},{enabled:t!==null}),{data:i}=M({deviceId:t??0},{enabled:t!==null}),a=r??n??null,[o,s]=B(`identity`);if(t===null||!a)return null;let c=String(a.stableId??``),l=String(a.name??``),u=String(a.type??``),d=String(a.addonId??``),f=a.features??[],p=new Set([`device-status`,`feature-probe`,`device-ops`]),m=(i?.entries??[]).filter(e=>e.kind===`native`&&!p.has(e.capName)).map(e=>e.capName),h=f.length>0?f:m,g=a.location??null,_=a.metadata??null,v=_!==null&&Object.keys(_).length>0;return q(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[q(`div`,{className:`border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3`,children:[G(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:`Device Info`}),v&&q(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[G(dn,{active:o===`identity`,onClick:()=>s(`identity`),label:`Identity`}),G(dn,{active:o===`hardware`,onClick:()=>s(`hardware`),label:`Hardware`})]})]}),(!v||o===`identity`)&&q(`div`,{className:`divide-y divide-border`,children:[G(Q,{label:`ID`,value:q(`span`,{className:`font-mono text-[11px] text-foreground`,children:[`#${t}`,q(`span`,{className:`ml-1.5 text-foreground-subtle`,children:[`(`,c,`)`]})]})}),G(an,{deviceId:t,initialName:l}),G(on,{deviceId:t,initialLocation:g}),G(Q,{label:`Type`,value:u}),G(Q,{label:`Provider`,value:G(Qe,{type:d,size:`sm`,showLabel:!0})}),G(Q,{label:`Capabilities`,value:h.length>0?G(Je,{capabilities:h,showLabels:!0}):G(`span`,{className:`text-[11px] text-foreground-subtle`,children:`None`})})]}),v&&o===`hardware`&&G(fn,{metadata:_})]})}function dn({active:e,onClick:t,label:n}){return G(`button`,{type:`button`,onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${e?`bg-surface text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`}`,children:n})}function fn({metadata:e}){let t=sn.filter(t=>t in e),n=Object.keys(e).filter(e=>!sn.includes(e)).toSorted(),r=[...t,...n];return q(`div`,{children:[G(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border bg-surface-subtle/40`,children:`Auto-populated by the driver on every connect. Read-only.`}),G(`div`,{className:`divide-y divide-border`,children:r.map(t=>G(Q,{label:cn(t),value:G(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:ln(e[t])})},t))})]})}W();function pn({deviceId:e}){let[t,n]=B(null),r=Ce({onSuccess:e=>{n(e.changed?`Re-aligned with source — ${e.rebuiltChildren} child${e.rebuiltChildren===1?``:`ren`} rebuilt.`:`Already up to date.`)},onError:e=>n(`Re-sync failed: ${e.message}`)});return q(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3`,children:[q(`div`,{className:`flex items-center justify-between gap-3`,children:[q(`div`,{children:[G(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-foreground`,children:`Re-sync`}),G(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:`Re-align this device's type, role, capabilities and units with its source.`})]}),q(`button`,{type:`button`,disabled:r.isPending,onClick:()=>{n(null),r.mutate({camDeviceId:e})},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:[G(tt,{className:`h-3 w-3 ${r.isPending?`animate-spin`:``}`}),r.isPending?`Re-syncing…`:`Re-sync`]})]}),t!==null&&G(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:t})]})}function mn(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function hn({device:e}){let t=ot(),n=typeof e.id==`number`?e.id:null,r=String(e.type??``),i=r===Y.Camera,a=r===Y.Hub,o=e.features??[],s=o.includes(qe.Resyncable),{data:c}=fe({deviceId:n??0},{enabled:n!==null&&i,refetchInterval:5e3}),l=c?.streams??{},u=Object.entries(l),d=o.includes(qe.DoorbellButton),f=R(d?{deviceId:n??void 0,historyLimit:10}:void 0),p=f.latest?Date.now()-f.latest.timestamp<3e4:!1;return q(`div`,{className:`space-y-5`,children:[a&&n!==null&&G(be,{deviceId:n,onOpenChild:e=>t(`/devices/${e}`)}),s&&n!==null&&G(pn,{deviceId:n}),i&&n!==null&&G(ke,{widgetId:`pipeline-orchestrator/pipeline-quick-stats`,host:`device-tab`,deviceId:n}),d&&G(we,{history:f.history,latestIsFresh:p}),i&&n!==null&&G(ke,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:n}),i&&u.length>0&&q(`div`,{className:`@container rounded-lg border border-border bg-surface overflow-hidden`,style:{containerType:`inline-size`},children:[G(`div`,{className:`border-b border-border px-4 py-2`,children:G(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:`Stream Network`})}),G(`div`,{className:`divide-y divide-border`,children:u.map(([e,t])=>q(`div`,{className:`px-4 py-2.5`,children:[q(`div`,{className:`flex items-center gap-2 mb-2`,children:[G(it,{className:`h-3 w-3 text-foreground-subtle`}),G(`span`,{className:`text-[11px] font-medium text-foreground`,children:e})]}),q(`div`,{className:`grid grid-cols-2 @[640px]:grid-cols-4 gap-2`,children:[G(gn,{label:`Nominal`,value:mn(t.nominalBitrateKbps??0)}),G(gn,{label:`Observed`,value:mn(t.observedBitrateKbps??0)}),G(gn,{label:`Peak`,value:mn(t.peakBitrateKbps??0)}),G(gn,{label:`Packet Loss`,value:`${(t.packetLossPercent??0).toFixed(2)}%`,warning:(t.packetLossPercent??0)>1})]})]},e))})]}),G(un,{})]})}function gn({label:e,value:t,warning:n}){return q(`div`,{children:[G(`p`,{className:`text-[10px] text-foreground-subtle`,children:e}),G(`p`,{className:`text-xs font-medium ${n?`text-warning`:`text-foreground`}`,children:t})]})}W();function _n({schema:e,values:t,pendingKeys:n,onChange:r,onAction:i,onSave:a,onDiscard:o,disabled:s,activeSubTab:c,onSubTabChange:l}){let u=e.tabs??[],d=H(()=>{let t=new Map;for(let n of e.sections){let e=n.tab??`general`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t},[e.sections]),f=new Set(u.map(e=>e.id)),p=[...u,...[...d.keys()].filter(e=>!f.has(e)).map(e=>({id:e,label:e,icon:`wrench`,order:100}))],m=p[0]?.id??`general`,[h,g]=B(m),_=l!==void 0,v=new Set(p.map(e=>e.id)),y=_?c&&v.has(c)?c:m:v.has(h)?h:m,b=e=>{_?l(e):g(e)},x=d.get(y)??[],S={sections:x.length<=1?x.length===1?[{...x[0],title:``}]:x:x.every(e=>!e.title)?[{...x[0],title:``,fields:x.flatMap(e=>e.fields)}]:x},C=G(Et,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>o(n),saving:s});if(p.length<=1)return q(`div`,{className:`flex flex-col gap-3`,children:[G(kt,{schema:e,values:t,onChange:r,onAction:i,disabled:s}),C]});let w=new Map,T=new Map;for(let[e,t]of d){w.set(e,t.length);let r=new Set,i=e=>{for(let t of e)if(`key`in t&&typeof t.key==`string`&&r.add(t.key),t.type===`group`)i(t.fields);else if(t.type===`sub-tabs`)for(let e of t.tabs)i(e.fields)};for(let e of t)i(e.fields);let a=n.filter(e=>r.has(e)).length;a>0&&T.set(e,a)}return q(`div`,{className:`flex flex-col gap-3`,children:[G(Ot,{tabs:p.map(e=>({id:e.id,label:e.label})),activeId:y,onChange:b,countByTab:w,pendingByTab:T}),G(kt,{schema:S,values:t,onChange:r,onAction:i,disabled:s}),C]})}W();function vn(e,t){return t&&t===`admin`?e:!0}function yn(e){if(!e)return null;let t={sections:[...e.sections].toSorted((e,t)=>{let n=e.tab??`general`,r=t.tab??`general`;return n===r?Ut(e)&&Ut(t)?e.id.localeCompare(t.id):(e.order??0)-(t.order??0):n.localeCompare(r)})};return e.tabs?{...t,tabs:e.tabs}:t}function bn(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`}function xn(e){return e.key}function Sn(e){if(!bn(e))return e.value}function Cn(e){return bn(e)?null:e}function wn(e,t){for(let n of e)if(t(n),n.type===`group`)wn(n.fields,t);else if(n.type===`sub-tabs`)for(let e of n.tabs)wn(e.fields,t)}function Tn(e){if(!e)return{};let t={};for(let n of e.sections)wn(n.fields,e=>{let n=xn(e);n!==null&&(t[n]=Sn(e))});return t}function En(e,t){if(!e)return null;let n=null;for(let r of e.sections)if(wn(r.fields,e=>{if(n!==null||xn(e)!==t)return;let r=Cn(e);r&&r.writerCapName&&r.writerAddonId&&(n={capName:r.writerCapName,addonId:r.writerAddonId})}),n!==null)break;return n}function Dn(e){return{...e,fields:e.fields.map(On)}}function On(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`object-array`?e:{...e,readonlyField:!0}}function kn(e,t){return e&&{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{let n=Cn(e);return n?vn(t,n.minRole)?e:On(e):e})}))}}function An({deviceId:e,sectionFilter:t,activeSubTab:n,onSubTabChange:r}){let i=K(),{user:a}=_t(),o=a?.isAdmin===!0,s=U(!1),{data:c,isLoading:l}=de({deviceId:e},{refetchInterval:()=>s.current?!1:2500,enabled:Number.isFinite(e)}),{data:u}=N({deviceId:e},{enabled:Number.isFinite(e)}),d=c?.settings??null,f=c?.live??null,p=H(()=>{if(!d&&!f)return null;let e=d?.sections??[],n=(f?.sections??[]).map(Dn),r=[...e,...n],i=t?r.filter(t):r.filter(e=>e.location!==`top-tab`&&!Ut(e));if(i.length===0)return null;let a=new Set;for(let e of i)a.add(e.tab??`general`);let o=[...d?.tabs??[],...(f?.tabs??[]).filter(e=>!(d?.tabs??[]).some(t=>t.id===e.id))].filter(e=>a.has(e.id));return o.length>0?{tabs:o,sections:i}:{sections:i}},[d,f,t]),m=H(()=>yn(p),[p]),h=H(()=>kn(m,o),[m,o]),g=H(()=>Tn(h),[h]),_=P(),v=Te(),b=Ae(),x=L(),S=y({onSuccess:()=>{i.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),C={isPending:S.isPending,mutate:t=>{S.mutate({deviceId:e,changes:[...t]})}},w=Dt({schema:h,serverValues:g,onImmediateSave:z(e=>{let t=Object.entries(e).map(([e,t])=>{let n=En(h,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&C.mutate(t)},[h,C]),onDeferredSave:z(e=>{let t=Object.entries(e).map(([e,t])=>{let n=En(h,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&C.mutate(t)},[h,C])}),{values:T,pendingKeys:E,handleChange:D,handleSave:O,handleDiscard:k}=w;if(s.current=w.editingPaused,l)return q(`div`,{className:`flex items-center justify-center py-12 text-foreground-subtle`,children:[G(xt,{className:`h-4 w-4 animate-spin mr-2`}),G(`span`,{className:`text-xs`,children:`Loading device aggregate…`})]});if(!h||h.sections.length===0)return G(`div`,{className:`text-xs text-foreground-subtle italic py-4 text-center`,children:`No aggregate contributions for this device.`});async function A(t,n,r){if(t===`regenerate-rtsp-token`){let t=[`rtspUrl:`,`regenerateToken:`].find(e=>n.startsWith(e));if(!t)throw Error(`regenerate-rtsp-token: unrecognised key "${n}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);let r=n.slice(t.length);if(!r)throw Error(`regenerate-rtsp-token: key "${n}" has no streamId after prefix`);let a=We(e,r);await _.mutateAsync({brokerId:a}),i.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]});return}if(t===`test-probe`){if(!u)return{status:`error`,error:`Device metadata not loaded yet`};try{return await b.mutateAsync({addonId:u.addonId,type:u.type,key:n,value:r})}catch(e){return{status:`error`,error:e instanceof Error?e.message:String(e)}}}if(t===`refresh-probe`){if(!n.startsWith(`probedInfo:`))throw Error(`refresh-probe: unrecognised key "${n}" (expected "probedInfo:<streamId>")`);let t=n.slice(11);if(!t)throw Error(`refresh-probe: key "${n}" has no streamId after prefix`);let r=We(e,t),a=await v.mutateAsync({brokerId:r});return i.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),a}if(t===`device-custom-action`){let t=await x.mutateAsync({deviceId:e,action:n,input:r});return i.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),t}throw Error(`[device-aggregate] unknown action "${t}"`)}return G(_n,{schema:h,values:T,pendingKeys:E,onChange:D,onAction:A,onSave:O,onDiscard:k,disabled:C.isPending,activeSubTab:n,onSubTabChange:r})}function jn({deviceId:e,activeSubTab:t,onSubTabChange:n}){return G(`div`,{className:`flex flex-col gap-3`,children:G(An,{deviceId:e,activeSubTab:t,onSubTabChange:n})})}W(),W();function Mn({deviceName:e,deviceType:t,provider:n,isOnline:r,features:i}){return q(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border bg-surface p-6 text-center`,children:[G(Qe,{type:n,size:`lg`}),q(`div`,{children:[G(`div`,{className:`text-sm font-semibold text-foreground`,children:e}),G(`div`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wider mt-0.5`,children:t})]}),q(`div`,{className:`flex items-center gap-2 flex-wrap justify-center`,children:[G(Ct,{status:r?`online`:`offline`}),i.length>0&&G(Je,{capabilities:i})]}),G(`div`,{className:`text-[10px] text-foreground-subtle italic max-w-xs mt-1`,children:`No live view for this device type. Use the Config tab or the shortcut row to interact.`})]})}W();function Nn({deviceId:e}){let t=K(),n=d({deviceId:e},{refetchInterval:1e4,retry:!1}),r=k({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceDiscovery`,`listDiscovered`]]}),t.invalidateQueries({queryKey:[[`deviceDiscovery`,`getStatus`]]})}}),i=H(()=>Pn(n.data??[]),[n.data]);return q(`div`,{className:`flex h-full w-full flex-col gap-3 p-3 sm:p-4`,children:[q(`div`,{className:`flex flex-wrap items-stretch gap-2 sm:gap-3`,children:[G(Fn,{label:`Discovered`,value:i.total,icon:G(dt,{className:`h-3.5 w-3.5`})}),G(Fn,{label:`Adopted`,value:i.adopted,accent:`success`}),G(Fn,{label:`Available`,value:i.available,accent:i.available>0?`primary`:void 0}),q(`button`,{type:`button`,onClick:()=>{r.mutateAsync({deviceId:e}).catch(()=>{})},disabled:r.isPending,className:`inline-flex items-center justify-center gap-1.5 rounded-lg border border-border px-3 py-2 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 self-stretch shrink-0`,children:[r.isPending?G(xt,{className:`h-3.5 w-3.5 animate-spin`}):G(tt,{className:`h-3.5 w-3.5`}),G(`span`,{className:`hidden sm:inline`,children:`Discover`})]})]}),q(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-foreground-subtle border-t border-border-subtle pt-2`,children:[G(In,{icon:G(it,{className:`h-3 w-3 text-emerald-500`}),label:`${i.online} online`}),G(In,{icon:G(bt,{className:`h-3 w-3 text-amber-500`}),label:`${i.sleeping} sleeping`}),G(In,{icon:G(ft,{className:`h-3 w-3 text-destructive`}),label:`${i.offline} offline`}),i.unknown>0?G(In,{icon:G(jt,{className:`h-3 w-3 text-foreground-subtle`}),label:`${i.unknown} unknown`}):null]})]})}function Pn(e){let t={total:e.length,adopted:0,available:0,online:0,sleeping:0,offline:0,unknown:0};for(let n of e)n.alreadyAdopted?t.adopted+=1:t.available+=1,t[n.status]+=1;return t}function Fn({label:e,value:t,icon:n,accent:r}){return q(`div`,{className:`flex flex-1 basis-[140px] min-w-0 flex-col gap-1 rounded-lg border px-2 py-1.5 sm:px-3 sm:py-2 ${r===`success`?`bg-emerald-500/10 border-emerald-500/30 text-emerald-500`:r===`primary`?`bg-primary/10 border-primary/30 text-primary`:`bg-surface-hover border-border text-foreground`}`,children:[q(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wider opacity-70 truncate`,children:[n,G(`span`,{className:`truncate`,children:e})]}),G(`div`,{className:`text-xl sm:text-2xl font-semibold tabular-nums leading-none`,children:t})]})}function In({icon:e,label:t}){return q(`span`,{className:`inline-flex items-center gap-1`,children:[e,G(`span`,{children:t})]})}function Ln({deviceId:e,features:n}){return G(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:G(t,{trpc:J().trpcClient,deviceId:e,features:n})})}function Rn({deviceId:e,features:t}){return G(`div`,{className:`flex h-full w-full flex-col items-stretch p-3 sm:p-4`,children:G(le,{trpc:J().trpcClient,deviceId:e,features:t})})}function $({deviceId:e,deviceType:t,features:n}){let r=J(),i=f(t)?.HeroCard??le,a=Ue(ze(r.trpcClient,e)?.state.deviceStatus),o=a!==void 0&&a.online===!1,s=o?a.lastChangedAt:null;return q(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:[o?G(`div`,{className:`flex justify-center`,children:G(h,{lastChangedAt:s})}):null,G(i,{trpc:r.trpcClient,deviceId:e,features:n})]})}W();function zn({deviceId:e}){let t=J(),n=K(),{data:r,isLoading:i}=Tt(e),{data:a,isLoading:o}=wt(e),s=i||o,[c,u]=B(null),d=Pe({onSuccess:()=>{u(null),n.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{u(`Could not change primary child: ${e.message}`)}}),f=(a??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:e.name,features:e.features,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),p=typeof r?.linkDeviceId==`number`?r.linkDeviceId:null,m=typeof r?.primaryChildEntityId==`string`?r.primaryChildEntityId:null;return s?G(`div`,{className:`h-full min-h-32 w-full animate-pulse rounded-lg bg-surface`,"aria-hidden":`true`}):q(`div`,{className:`flex h-full w-full flex-col`,children:[G(l,{trpc:t.trpcClient,children:f,linkDeviceId:p,primaryChildEntityId:m,onSetPrimary:t=>d.mutate({deviceId:e,primaryChildEntityId:t})}),c!==null&&G(`p`,{role:`alert`,className:`px-3 pb-2 text-[11px] text-danger sm:px-4`,children:c})]})}var Bn={[Y.Switch]:$,[Y.Siren]:$,[Y.Light]:$,[Y.Sensor]:$,[Y.Button]:$,[Y.Hub]:Nn,[Y.Cover]:Ln,[Y.Valve]:$,[Y.Humidifier]:$,[Y.WaterHeater]:$,[Y.Container]:zn,[Y.Lock]:$,[Y.Fan]:$,[Y.Thermostat]:$,[Y.MediaPlayer]:$,[Y.Control]:$,[Y.AlarmPanel]:Rn,[Y.EventEmitter]:Rn,[Y.Notifier]:Rn,[Y.Script]:Rn,[Y.Automation]:Rn,[Y.Presence]:$,[Y.Update]:$,[Y.Vacuum]:$,[Y.LawnMower]:$,[Y.Weather]:$,[Y.Image]:$};function Vn(e){return G(Bn[e.deviceType]??Mn,{...e})}function Hn({deviceId:e}){let t=K(),n=Number.isFinite(e),{data:r}=N({deviceId:e},{enabled:n}),i=typeof r?.type==`string`?r.type:`camera`;At([`deviceManager`,`getBindings`],[`capability.binding-changed`]);let{data:a,isLoading:o,isError:s,error:c}=M({deviceId:e},{enabled:n}),{data:l}=te({deviceType:i},{enabled:!!i}),d=ee({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceManager`,`getBindings`]]})}});if(o)return G(`div`,{className:`p-4`,children:G(`div`,{className:`h-20 rounded-lg border border-border bg-surface animate-pulse`})});if(s)return q(`div`,{className:`p-4 text-xs text-red-400`,children:[`Failed to load bindings: `,c instanceof Error?c.message:String(c)]});let f=new Map,p={};for(let e of l??[])p[e.capName]=e.wrappers;for(let e of a?.entries??[])f.set(e.capName,{...e,wrappers:p[e.capName]??[]});for(let e of l??[])f.has(e.capName)||f.set(e.capName,{capName:e.capName,kind:`unbound`,providerAddonId:``,providerNodeId:``,nativeAddonId:``,wrappers:e.wrappers});let m=[...f.values()].toSorted((e,t)=>e.capName.localeCompare(t.capName));if(m.length===0)return q(`div`,{className:`flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle`,children:[G(Xe,{className:`h-8 w-8 opacity-40`}),G(`p`,{className:`text-xs`,children:`No capability providers applicable to this device yet.`}),G(`p`,{className:`text-[10px] opacity-60`,children:`Native providers show up here as soon as the owning addon registers them.`})]});let h=m.filter(e=>e.kind!==`unbound`).length;return q(`div`,{className:`flex flex-col gap-3 p-1`,children:[q(`div`,{className:`text-[11px] text-foreground-subtle`,children:[G(`span`,{className:`font-medium text-foreground`,children:h}),` of `,m.length,` capabilit`,m.length===1?`y`:`ies`,` bound — rows marked `,G(`em`,{children:`unbound`}),` have a wrapper available you can activate.`]}),G(u,{columns:[{key:`capability`,header:`Capability`,render:e=>G(`span`,{className:`font-mono text-foreground`,children:e.capName})},{key:`kind`,header:`Kind`,render:e=>G(Un,{kind:e.kind})},{key:`provider`,header:`Active Provider`,render:e=>G(`span`,{className:`font-mono text-foreground-subtle`,children:e.providerAddonId||G(`span`,{className:`opacity-40`,children:`—`})})},{key:`node`,header:`Node`,render:e=>e.providerNodeId?G(Wn,{nodeId:e.providerNodeId}):G(`span`,{className:`text-[10px] opacity-40`,children:`—`})},{key:`native`,header:`Native`,render:e=>G(`span`,{className:`font-mono text-foreground-subtle`,children:e.nativeAddonId||G(`span`,{className:`opacity-40`,children:`—`})})},{key:`wrapper`,header:`Wrapper`,render:t=>{let n=t.kind===`wrapped`?t.providerAddonId:null;return G(Gn,{wrappers:t.wrappers,activeWrapperId:n,disabled:d.isPending,onPick:r=>{let i=n===r;d.mutate({deviceId:e,capName:t.capName,wrapperAddonId:r,active:!i})}})}}],rows:m,rowKey:e=>e.capName,minWidthPx:720})]})}function Un({kind:e}){return e===`native`?q(`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:[G(rt,{className:`h-3 w-3`}),`native`]}):e===`wrapped`?q(`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:[G(Mt,{className:`h-3 w-3`}),`wrapped`]}):q(`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:[G(It,{className:`h-3 w-3`}),`unbound`]})}function Wn({nodeId:e}){return G(`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 Gn({wrappers:e,activeWrapperId:t,disabled:n,onPick:r}){return e.length===0?G(`span`,{className:`text-[10px] opacity-40`,children:`none available`}):G(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>{let i=e===t;return q(`button`,{disabled:n,onClick:()=>r(e),title:i?`Click to deactivate (revert to native)`:`Activate wrapper ${e}`,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 ${i?`border-primary/40 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[G(i?at:Ze,{className:`h-3 w-3`}),e]},e)})})}W();function Kn(e,t){if(!e)return null;for(let n of e.slots)for(let e of n.addons)if(e.id===t)return e;return null}function qn(e,t,n){let r=e?.stepOverridesByAgent?.[t]?.[n];if(r)return r.enabled===!1?`off`:(r.enabled,`on`);let i=e?.stepToggles?.[n];return i===!1?`off`:i===!0?`on`:`inherit`}function Jn({agents:e,currentAgent:t,onPick:n}){let[r,i]=B(!1);return q(`div`,{className:`relative`,children:[G(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:()=>i(e=>!e),children:`Mirror from ▾`}),r&&G(`div`,{className:`absolute top-full left-0 mt-1 min-w-[140px] bg-surface border border-border rounded shadow-lg z-10`,children:e.filter(e=>e!==t).map(e=>G(`button`,{type:`button`,className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted`,onClick:()=>{i(!1),n(e)},children:e},e))})]})}function Yn({deviceId:e,refreshToken:t}){let r=K(),[i,a]=B(null),[s,c]=B(null),[l,u]=B(null),[d,f]=B(null),m=_({deviceId:e}),h=w(),g=Ie({deviceId:e}),v=n(),y=H(()=>g.data?.agentNodeId||v.data?.find(e=>e.online)?.nodeId||`hub`,[g.data?.agentNodeId,v.data]),b=s??y,x=je({nodeId:b??``},{enabled:!!b}),S=O({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]}),u(null)}}),C=H(()=>x.data?p(x.data):[],[x.data]),T=H(()=>{let e=m.data??null,t={};for(let n of h.data??[])for(let r of Object.keys(n.settings.addonDefaults)){let i=t[r]??[];i.push({agentNodeId:n.nodeId,state:qn(e,n.nodeId,r)}),t[r]=i}return t},[m.data,h.data]),D=i?Kn(x.data??null,i):null,k=b?h.data?.find(e=>e.nodeId===b)??null:null,A=i&&k?k.settings.addonDefaults[i]??null:null,j=i&&b?m.data?.stepOverridesByAgent?.[b]?.[i]??null:null,M=x.data?.selectedEngine.format??`coreml`,ee=e=>{c(e),u(null),f(null)};return h.isLoading||x.isLoading?G(`div`,{className:`text-xs text-foreground-subtle animate-pulse p-4`,children:`Loading pipeline…`}):x.data?G(`div`,{className:`@container h-full`,style:{containerType:`inline-size`},children:q(`div`,{className:`flex flex-col @[720px]:flex-row h-full`,children:[G(`aside`,{className:`w-full @[720px]:w-[300px] @[720px]:flex-shrink-0 border-b @[720px]:border-b-0 @[720px]:border-r border-border overflow-y-auto max-h-[40vh] @[720px]:max-h-none`,children:G(o,{tree:C,selectedAddonId:i,onSelect:e=>{a(e),u(null),f(null)},agentDots:T})}),G(`section`,{className:`flex-1 min-w-0 p-4 overflow-y-auto`,children:!i||!D?G(`div`,{className:`text-sm text-foreground-subtle`,children:`Select a step on the left to configure it for this camera.`}):q(`div`,{className:`space-y-4`,children:[q(`div`,{children:[G(`div`,{className:`text-[10px] uppercase tracking-widest text-foreground-subtle`,children:`Selected step`}),G(`div`,{className:`text-base font-semibold`,children:D.name})]}),q(`div`,{className:`flex items-end gap-3 flex-wrap`,children:[q(`div`,{children:[G(`div`,{className:`text-[10px] uppercase tracking-widest text-foreground-subtle mb-1`,children:`Agent`}),G(`div`,{className:`flex rounded border border-border overflow-hidden`,children:(h.data??[]).map(e=>G(`button`,{type:`button`,onClick:()=>ee(e.nodeId),className:`px-3 py-1 text-xs ${b===e.nodeId?`bg-primary text-primary-foreground`:`bg-surface hover:bg-muted`}`,children:e.nodeId},e.nodeId))})]}),G(Jn,{agents:(h.data??[]).map(e=>e.nodeId),currentAgent:b,onPick:e=>{if(!b||!i||!x.data||!h.data)return;let t=h.data.find(t=>t.nodeId===e),n=h.data.find(e=>e.nodeId===b);if(!t||!n)return;let[r]=Ne({source:{nodeId:t.nodeId,engine:{format:M},defaults:t.settings.addonDefaults},target:{nodeId:n.nodeId,engine:{format:M},defaults:n.settings.addonDefaults},catalog:x.data,addonIds:[i]});if(!r){f(`no mirror result`);return}if(r.outcome===`skip`){f(`skipped: ${r.reason??`no candidate`}`);return}u(r.patch),f(`${r.outcome} from ${e}`)}}),d&&G(`div`,{className:`text-[10px] text-foreground-subtle`,children:d})]}),A&&G(E,{mode:`device`,addon:D,agentDefault:A,agentNodeId:b??``,currentPatch:l??j,engineFormat:M,onChangePatch:u}),q(`div`,{className:`flex items-center justify-between gap-2 pt-4 border-t border-border`,children:[G(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted text-foreground-subtle`,disabled:!j||S.isPending,onClick:()=>{!b||!i||S.mutate({deviceId:e,agentNodeId:b,addonId:i,patch:null})},children:`Clear override`}),q(`div`,{className:`flex items-center gap-2`,children:[G(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:()=>u(null),children:`Reset draft`}),G(`button`,{type:`button`,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,disabled:!b||!i||S.isPending,onClick:()=>{!b||!i||S.mutate({deviceId:e,agentNodeId:b,addonId:i,patch:l})},children:S.isPending?`Saving…`:`Save`})]})]})]})})]})}):G(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`Catalog unavailable.`})}W();function Xn(e,t){if(t===`number`){let t=Number(e);return Number.isNaN(t)?e:t}return t===`boolean`?e===`true`:e}function Zn(e,t){let n={};for(let r of e)r.key!==``&&r.value!==``&&(n[r.key]=Xn(r.value,t));return n}function Qn(e,t){return e?.kind===`enum-map`?Object.entries(e.mapping).map(([e,t])=>({key:e,value:String(t)})):t?.kind===`enum`&&t.enumValues?t.enumValues.map(e=>({key:e,value:``})):[{key:``,value:``}]}function $n(e){return e?.kind===`linear`?{scale:String(e.scale),offset:String(e.offset),clampMin:e.clamp?String(e.clamp[0]):``,clampMax:e.clamp?String(e.clamp[1]):``,useClamp:e.clamp!=null}:{scale:`1`,offset:`0`,clampMin:``,clampMax:``,useClamp:!1}}function er(e){return e==null?`identity`:e.kind}function tr({value:e,onChange:t,sourceField:n,targetKind:r}){let[i,a]=B(()=>er(e)),[o,s]=B(()=>Qn(e,n)),[c,l]=B(()=>e?.kind===`enum-map`&&e.fallback!=null?String(e.fallback):``),[u,d]=B(()=>$n(e));V(()=>{if(i===`enum-map`&&n?.kind===`enum`&&n.enumValues){let e=n.enumValues;s(t=>e.map(e=>({key:e,value:t.find(t=>t.key===e)?.value??``})))}},[n,i]),V(()=>{if(i===`identity`){t(void 0);return}if(i===`enum-map`){let e=Zn(o,r),n=c===``?void 0:Xn(c,r);t({kind:`enum-map`,mapping:e,...n===void 0?{}:{fallback:n}});return}if(i===`linear`){let e=Number(u.scale),n=Number(u.offset);if(Number.isNaN(e)||Number.isNaN(n))return;let r=Number(u.clampMin),i=Number(u.clampMax),a=u.useClamp&&!Number.isNaN(r)&&!Number.isNaN(i)?[r,i]:void 0;t({kind:`linear`,scale:e,offset:n,...a?{clamp:a}:{}})}},[i,o,c,u,r,t]);let f=e=>{a(e),e===`enum-map`&&s(Qn(void 0,n)),e===`linear`&&d($n(void 0))},p=(e,t,n)=>{s(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))},m=()=>s(e=>[...e,{key:``,value:``}]),h=e=>s(t=>t.filter((t,n)=>n!==e));return q(`div`,{className:`flex flex-col gap-3`,children:[q(`div`,{children:[G(`p`,{className:`text-[11px] font-medium text-foreground-subtle mb-1.5`,children:`Transform`}),G(`div`,{className:`flex items-center gap-4`,children:[`identity`,`enum-map`,`linear`].map(e=>q(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[G(`input`,{type:`radio`,name:`transform-kind`,value:e,checked:i===e,onChange:()=>f(e),className:`accent-primary`}),e===`identity`?`None`:e]},e))})]}),i===`enum-map`&&q(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-3`,children:[G(`p`,{className:`text-[10px] font-medium text-foreground-subtle/70 uppercase tracking-wide`,children:`Key → Value mapping`}),o.map((e,t)=>q(`div`,{className:`flex items-center gap-1.5`,children:[G(`input`,{"aria-label":`enum key ${t}`,type:`text`,value:e.key,readOnly:n?.kind===`enum`,onChange:e=>p(t,`key`,e.target.value),placeholder:`source value`,className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs font-mono text-foreground focus:border-primary outline-none read-only:opacity-70`}),G(`span`,{className:`text-foreground-subtle/50 text-xs`,children:`→`}),r===`boolean`?q(`select`,{"aria-label":`enum value ${t}`,value:e.value,onChange:e=>p(t,`value`,e.target.value),className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:border-primary outline-none`,children:[G(`option`,{value:``,children:`—`}),G(`option`,{value:`true`,children:`true`}),G(`option`,{value:`false`,children:`false`})]}):G(`input`,{"aria-label":`enum value ${t}`,type:r===`number`?`number`:`text`,value:e.value,onChange:e=>p(t,`value`,e.target.value),placeholder:`target value`,className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs font-mono text-foreground focus:border-primary outline-none`}),n?.kind!==`enum`&&G(`button`,{type:`button`,onClick:()=>h(t),className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] border border-border/80 text-foreground-subtle hover:text-danger hover:border-danger/50 transition-colors`,children:`✕`})]},t)),n?.kind!==`enum`&&G(`button`,{type:`button`,onClick:m,className:`self-start text-[10px] text-primary/70 hover:text-primary transition-colors`,children:`+ Add row`}),q(`div`,{className:`flex items-center gap-2 pt-1 border-t border-border/50`,children:[G(`label`,{className:`text-[10px] text-foreground-subtle/70 whitespace-nowrap`,children:`Fallback:`}),G(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`(leave empty for none)`,className:`flex-1 rounded border border-border bg-background px-2 py-0.5 text-xs font-mono text-foreground focus:border-primary outline-none`})]})]}),i===`linear`&&q(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-3`,children:[G(`p`,{className:`text-[10px] font-medium text-foreground-subtle/70 uppercase tracking-wide`,children:`Linear: value × scale + offset`}),q(`div`,{className:`grid grid-cols-2 gap-2`,children:[q(`label`,{className:`flex flex-col gap-0.5`,children:[G(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Scale`}),G(`input`,{type:`number`,value:u.scale,onChange:e=>d(t=>({...t,scale:e.target.value})),className:`rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:border-primary outline-none`})]}),q(`label`,{className:`flex flex-col gap-0.5`,children:[G(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Offset`}),G(`input`,{type:`number`,value:u.offset,onChange:e=>d(t=>({...t,offset:e.target.value})),className:`rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:border-primary outline-none`})]})]}),q(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[G(`input`,{type:`checkbox`,checked:u.useClamp,onChange:e=>d(t=>({...t,useClamp:e.target.checked})),className:`accent-primary`}),G(`span`,{className:`text-foreground-subtle`,children:`Clamp output`})]}),u.useClamp&&q(`div`,{className:`grid grid-cols-2 gap-2`,children:[q(`label`,{className:`flex flex-col gap-0.5`,children:[G(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Min`}),G(`input`,{type:`number`,value:u.clampMin,onChange:e=>d(t=>({...t,clampMin:e.target.value})),className:`rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:border-primary outline-none`})]}),q(`label`,{className:`flex flex-col gap-0.5`,children:[G(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Max`}),G(`input`,{type:`number`,value:u.clampMax,onChange:e=>d(t=>({...t,clampMax:e.target.value})),className:`rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:border-primary outline-none`})]})]})]})]})}W();function nr(e,t){return`${e.replace(/[^a-z0-9]/gi,`-`)}-${t.replace(/[^a-z0-9]/gi,`-`)}`}function rr(e,t,n){let r=`${t}-${e}`;return n.find(e=>e.stableId===r)?.id??null}function ir({deviceId:e,parentDeviceId:t,deviceStableId:n,initial:r,onSave:i,onCancel:a}){let{data:o}=F({}),s=o??[],c=t==null?n:s.find(e=>e.id===t)?.stableId??n,l=s.filter(n=>n.parentDeviceId===t&&n.id!==e),{data:u}=Ee({deviceId:e}),d=u?.caps??[],f=r==null?null:rr(r.source.sourceKey,c,s),[p,m]=B(r?.target.cap??``),[h,g]=B(r?.target.fieldPath??``),[_,v]=B(f),[y,b]=B(r?.source.cap??``),[x,S]=B(r?.source.fieldPath??``),[C,w]=B(r?.transform);V(()=>{if(r!=null&&_===null&&s.length>0){let e=rr(r.source.sourceKey,c,s);e!==null&&v(e)}},[r,_,s,c]);let{data:T}=Ee({deviceId:_??0},{enabled:_!=null}),E=T?.caps??[],D=d.find(e=>e.cap===p)?.fields??[],O=D.find(e=>e.path===h),k=E.find(e=>e.cap===y)?.fields??[],A=k.find(e=>e.path===x),j=e=>{m(e),g(``)},M=e=>{v(e===``?null:Number(e)),b(``),S(``)},ee=e=>{b(e),S(``)},N=p!==``&&h!==``&&_!=null&&y!==``&&x!==``,P=()=>{if(!N)return;let e=s.find(e=>e.id===_),t=`${c}-`,n=e&&e.stableId.startsWith(t)?e.stableId.slice(t.length):``;i({id:r?.id??nr(p,h),source:{sourceKey:n,cap:y,fieldPath:x},target:{cap:p,fieldPath:h},...C==null?{}:{transform:C}})},I=`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none disabled:opacity-50`;return q(`div`,{className:`flex flex-col gap-4 p-3`,children:[q(`fieldset`,{className:`flex flex-col gap-3`,children:[G(`legend`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/70 mb-1`,children:`Target (this device)`}),q(`div`,{children:[G(`label`,{htmlFor:`link-target-cap`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Target cap`}),q(`select`,{id:`link-target-cap`,value:p,onChange:e=>j(e.target.value),className:I,children:[G(`option`,{value:``,children:`— select a cap —`}),d.map(e=>G(`option`,{value:e.cap,children:e.cap},e.cap))]})]}),q(`div`,{children:[G(`label`,{htmlFor:`link-target-field`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Target field`}),q(`select`,{id:`link-target-field`,value:h,disabled:p===``,onChange:e=>g(e.target.value),className:I,children:[G(`option`,{value:``,children:`— select a field —`}),D.map(e=>q(`option`,{value:e.path,children:[e.path,` (`,e.kind,`)`]},e.path))]})]})]}),q(`fieldset`,{className:`flex flex-col gap-3`,children:[G(`legend`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/70 mb-1`,children:`Source (sibling device)`}),q(`div`,{children:[G(`label`,{htmlFor:`link-source-device`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Source device`}),q(`select`,{id:`link-source-device`,value:_??``,onChange:e=>M(e.target.value),className:I,children:[G(`option`,{value:``,children:`— select a device —`}),l.map(e=>q(`option`,{value:e.id,children:[e.name??e.stableId,` (#`,e.id,`)`]},e.id))]})]}),q(`div`,{children:[G(`label`,{htmlFor:`link-source-cap`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Source cap`}),q(`select`,{id:`link-source-cap`,value:y,disabled:_==null,onChange:e=>ee(e.target.value),className:I,children:[G(`option`,{value:``,children:`— select a cap —`}),E.map(e=>G(`option`,{value:e.cap,children:e.cap},e.cap))]})]}),q(`div`,{children:[G(`label`,{htmlFor:`link-source-field`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Source field`}),q(`select`,{id:`link-source-field`,value:x,disabled:y===``,onChange:e=>S(e.target.value),className:I,children:[G(`option`,{value:``,children:`— select a field —`}),k.map(e=>q(`option`,{value:e.path,children:[e.path,` (`,e.kind,`)`]},e.path))]})]})]}),G(tr,{value:C,onChange:w,sourceField:A,targetKind:O?.kind}),q(`div`,{className:`flex items-center justify-end gap-2 pt-2 border-t border-border`,children:[G(`button`,{type:`button`,onClick:a,className:`px-3 py-1.5 rounded-md text-xs font-medium border border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,children:`Cancel`}),G(`button`,{type:`button`,disabled:!N,onClick:P,className:`px-3 py-1.5 rounded-md text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:`Save`})]})]})}W();function ar({deviceId:e}){let t=J(),n=K(),{data:r,isLoading:i}=N({deviceId:e},{enabled:Number.isFinite(e),refetchInterval:1e4}),a=re({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}}),o=r?.deviceLinks??[],s=typeof r?.parentDeviceId==`number`?r.parentDeviceId:null,c=typeof r?.stableId==`string`?r.stableId:``,[l,u]=B(null),d=t=>{a.mutate({deviceId:e,deviceLinks:o.filter(e=>e.id!==t)})};return i?G(`div`,{className:`p-4`,children:G(`div`,{className:`h-20 rounded-lg border border-border bg-surface animate-pulse`})}):l===null?q(`div`,{className:`flex flex-col gap-3 p-1`,children:[q(`div`,{className:`flex items-center justify-between`,children:[G(`h3`,{className:`text-xs font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Wiring`}),q(`button`,{type:`button`,onClick:()=>u(`new`),title:`Add a cross-device link`,className:`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-[10px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[G(et,{className:`h-3 w-3`}),`Add link`]})]}),o.length===0?q(`div`,{className:`flex flex-col items-center justify-center gap-2 py-8 text-foreground-subtle`,children:[G(Nt,{className:`h-8 w-8 opacity-30`}),G(`p`,{className:`text-xs`,children:`No links yet.`}),G(`p`,{className:`text-[10px] opacity-60`,children:`Cross-device field wirings will appear here once authored.`})]}):G(`div`,{className:`flex flex-col divide-y divide-border rounded-lg border border-border overflow-hidden`,children:o.map(n=>G(or,{deviceId:e,link:n,trpcClient:t.trpcClient,onDelete:()=>d(n.id),onEdit:()=>u(n),isPending:a.isPending},n.id))})]}):q(`div`,{className:`flex flex-col gap-3 p-1`,children:[G(`div`,{className:`flex items-center justify-between`,children:G(`h3`,{className:`text-xs font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:l===`new`?`Add link`:`Edit link`})}),G(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:G(ir,{deviceId:e,parentDeviceId:s,deviceStableId:c,initial:l===`new`?null:l,onSave:t=>{let n=o.some(e=>e.id===t.id)?o.map(e=>e.id===t.id?t:e):[...o,t];a.mutate({deviceId:e,deviceLinks:n}),u(null)},onCancel:()=>{u(null)}})})]})}function or({deviceId:e,link:t,trpcClient:n,onDelete:r,onEdit:i,isPending:a}){let o=ge(n,e,t.target.cap),s=o===void 0?void 0:Ke(o,t.target.fieldPath),c=s==null?`—`:String(s);return q(`div`,{className:`flex items-center gap-3 px-3 py-2.5 bg-surface hover:bg-surface-hover transition-colors`,children:[G(Pt,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle/40`}),q(`div`,{className:`min-w-0 flex-1 flex flex-col gap-0.5`,children:[q(`div`,{className:`flex items-baseline gap-1 flex-wrap`,children:[G(`span`,{className:`font-mono text-[11px] font-medium text-foreground`,children:t.target.cap}),G(`span`,{className:`text-[10px] text-foreground-subtle/60`,children:`.`}),G(`span`,{className:`font-mono text-[11px] text-foreground-subtle`,children:t.target.fieldPath})]}),q(`div`,{className:`flex items-baseline gap-1 flex-wrap text-[10px] text-foreground-subtle/70`,children:[G(`span`,{children:`←`}),G(`span`,{className:`font-mono`,children:t.source.sourceKey}),G(`span`,{className:`opacity-60`,children:`/`}),G(`span`,{className:`font-mono`,children:t.source.cap}),G(`span`,{className:`opacity-60`,children:`.`}),G(`span`,{className:`font-mono`,children:t.source.fieldPath})]})]}),t.transform&&G(sr,{kind:t.transform.kind}),G(`span`,{className:`font-mono text-[11px] tabular-nums min-w-[2.5rem] text-right text-foreground-subtle`,title:`Live resolved value (from this device's runtime-state slice)`,children:c}),G(`button`,{type:`button`,"aria-label":`Edit link`,title:`Edit this link`,disabled:a,onClick:i,className:`shrink-0 inline-flex items-center gap-1 rounded-md border border-border/80 px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:`Edit`}),G(`button`,{type:`button`,"aria-label":`Delete link`,title:`Remove this link`,disabled:a,onClick:r,className:`shrink-0 inline-flex items-center gap-1 rounded-md border border-border/80 px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:text-danger hover:border-danger/50 hover:bg-danger/5 transition-colors disabled:opacity-50`,children:`Delete`})]})}function sr({kind:e}){return G(`span`,{className:`inline-flex items-center rounded-md border border-primary/20 bg-primary/5 px-1.5 py-0.5 font-mono text-[10px] text-primary/80 shrink-0`,children:e})}W();var cr=[{id:`overview`,label:`Overview`,cameraOnly:!1},{id:`config`,label:`Config`,cameraOnly:!1},{id:`pipeline`,label:`Pipeline steps`,cameraOnly:!0},{id:`bindings`,label:`Bindings`,cameraOnly:!0},{id:`wiring`,label:`Wiring`,cameraOnly:!1}];function lr(e){let t=e===Y.Camera;return cr.filter(e=>t||!e.cameraOnly).map(({id:e,label:t})=>({id:e,label:t}))}var ur=[{id:`logs`,icon:gt,label:`Logs`},{id:`repl`,icon:pt,label:`REPL`},{id:`events`,icon:Ye,label:`Events`},{id:`state`,icon:ct,label:`State`}];function dr(){let e=lt(),t=Number(e.deviceId),n=Number.isFinite(t),r=ot(),i=K(),o=g(),s=J(),[c,l]=ut(),u=c.get(`tab`)??`overview`,d=c.get(`sub`),[f,p]=B(`logs`),m=`device-detail.left-col-width-px`,[h,_]=B(()=>{if(typeof window>`u`)return null;let e=window.localStorage.getItem(m),t=e?Number(e):NaN;return Number.isFinite(t)&&t>0?t:null}),y=U(h);y.current=h;function C(e){e.preventDefault();let t=e.clientX,n=e.currentTarget.previousElementSibling?.getBoundingClientRect().width??h??0,r=Math.max(330,Math.floor(window.innerWidth*.7)),i=e=>{_(Math.max(280,Math.min(r,n+(e.clientX-t))))},a=()=>{document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a);let e=y.current;if(e!==null)try{window.localStorage.setItem(m,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:w,isLoading:T,isError:E}=N({deviceId:t},{enabled:n,refetchInterval:5e3,retry:1}),{data:O}=de({deviceId:t},{enabled:n}),k=H(()=>{let e=O?.settings?.sections??[],t=O?.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(Ut)&&r.add(Bt),[...r].map(e=>e===`export`?{id:e,label:Vt,isAddonContrib:!0}:{id:e,label:Ge[e]?.label??e,isAddonContrib:!0})},[O]),A=w,j=String(A?.name??e.deviceId??`Device`),M=A?.online===!0,ee=M?`online`:`offline`,P=String(A?.addonId??`rtsp`),F=A?.features??[],I=A?.type,te=I===Y.Camera,ne=typeof A?.parentDeviceId==`number`?A.parentDeviceId:null,{data:re}=N({deviceId:ne??0},{enabled:ne!==null}),L=v(),ie=A?.disabled!==!0,{data:se}=Ee({deviceId:t},{enabled:n}),le=(se?.caps.length??0)>0,fe=H(()=>{let e=new Set,t=[];for(let n of[...lr(I),...k])e.has(n.id)||(e.add(n.id),!(n.id===`wiring`&&!le)&&t.push(n));return t},[I,k,le]),me=H(()=>fe.some(e=>e.id===u)?u:`overview`,[fe,u]),ge=z(e=>{l(t=>{let n=new URLSearchParams(t);return e===`overview`?n.delete(`tab`):n.set(`tab`,e),n.delete(`sub`),n},{replace:!0})},[l]),be=z(e=>{l(t=>{let n=new URLSearchParams(t);return n.set(`sub`,e),n},{replace:!0})},[l]),{data:xe}=wt(n?t:0),Se=(xe??[]).length>0,Ce=H(()=>ur.filter(({featureGate:e})=>!e||F.includes(e)),[F]),{data:R}=Fe({addonId:P},{enabled:!!P&&P!==`rtsp`}),we=he({onSuccess:()=>{i.invalidateQueries({queryKey:[[`deviceManager`]]}),r(R?.id?`/integrations/${R.id}`:`/integrations`)}}),Te=oe({onSuccess:()=>{i.invalidateQueries({queryKey:[[`deviceManager`]]})}}),De=ve({onSuccess:()=>{i.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Oe=ae(),ke=pe({onSuccess:()=>{i.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ae=F.includes(qe.Rebootable),je=F.includes(qe.BatteryOperated),Me=a(s.trpcClient,je&&n?t:null),[Ne,Pe]=B(!1),V=ze(s.trpcClient,n?t:null),W=async()=>{if(!(Ne||!V)){Pe(!0);try{await V.snapshot?.invalidateCache({});let e=await V.snapshot?.getSnapshot({});if(!e)return;let t=`data:${e.contentType};base64,${e.base64}`,n=e.contentType.includes(`png`)?`png`:`jpg`,r=j.replace(/[^a-zA-Z0-9_.-]+/g,`_`),i=new Date().toISOString().replace(/[:.]/g,`-`),a=document.createElement(`a`);a.href=t,a.download=`${r}-${i}.${n}`,document.body.appendChild(a),a.click(),document.body.removeChild(a)}finally{Pe(!1)}}},Le=Te.isPending||De.isPending,{data:Re}=Ie({deviceId:t},{enabled:n,refetchInterval:1e4}),Be=Re?.agentNodeId??null,Ve=typeof Be==`string`&&Be.length>0&&!Be.startsWith(`addon:`)?Be:void 0,{data:Ue}=_e({deviceId:t,...Ve?{nodeId:Ve}:{}},{enabled:n,refetchInterval:3e3,retry:!1}),{data:We}=x({deviceId:t},{enabled:n,refetchInterval:3e3,retry:!1}),Ke=We?.level?.dbfs??null;function Ye(){if(!n)return null;switch(me){case`overview`:return G(hn,{device:A??{}});case`config`:return G(jn,{deviceId:t,activeSubTab:d,onSubTabChange:be});case`pipeline`:return G(Yn,{deviceId:t,refreshToken:0});case`bindings`:return G(Hn,{deviceId:t});case`wiring`:return G(ar,{deviceId:t});default:{let e=me;return k.some(t=>t.id===e)?e===`export`?G(An,{deviceId:t,sectionFilter:Ut,activeSubTab:d,onSubTabChange:be}):G(An,{deviceId:t,sectionFilter:t=>t.location===`top-tab`&&(t.tab===e||e===`detection-pipeline`&&t.tab===`zones`),activeSubTab:d,onSubTabChange:be}):null}}}return n?T?q(`div`,{className:`flex flex-col h-full`,children:[q(`div`,{className:`border-b border-border bg-surface px-6 py-4`,children:[G(`div`,{className:`h-4 w-48 rounded bg-surface-hover animate-pulse mb-3`}),G(`div`,{className:`h-8 w-64 rounded bg-surface-hover animate-pulse`})]}),G(`div`,{className:`flex-1 p-6`,children:G(`div`,{className:`h-40 rounded-lg border border-border bg-surface animate-pulse`})})]}):E||!w?q(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[G(`p`,{className:`text-lg font-semibold text-foreground`,children:`Device not found`}),q(`p`,{className:`text-xs`,children:[`No device with ID`,` `,q(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`,children:[`#`,t]})]}),G(`button`,{onClick:()=>r(`/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:`Back to Integrations`})]}):q(`div`,{className:`absolute inset-0 flex flex-col overflow-hidden`,children:[q(`div`,{className:`border-b border-border bg-surface px-6 py-3 flex-shrink-0`,children:[G(`div`,{className:`mb-2`,children:G(D,{items:[{label:`Integrations`,onClick:()=>r(`/integrations`)},{label:R?.name??P,onClick:()=>R?.id&&r(`/integrations/${R.id}`)},{label:j}]})}),q(`div`,{className:`flex items-center gap-2 sm:gap-3`,children:[G(Qe,{type:P,size:`lg`}),q(`div`,{className:`min-w-0 flex-1`,children:[q(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[G(`h1`,{className:`text-sm sm:text-base font-semibold text-foreground truncate`,children:j}),G(Ct,{status:ee}),je&&G(S,{status:Me,variant:`full`})]}),ne!==null&&re&&q(`button`,{type:`button`,onClick:()=>r(`/devices/${ne}`),className:`text-[10px] text-foreground-subtle hover:text-primary transition-colors mt-0.5 inline-flex items-center gap-1`,title:`Open parent device ${re.name}`,children:[G(`span`,{children:`↑`}),G(`span`,{className:`truncate`,children:String(re.name??`Device #${ne}`)})]}),G(`div`,{className:`hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle`,children:F.length>0&&G(Je,{capabilities:F})})]}),Ue&&G(`div`,{className:`hidden lg:flex`,children:G(fr,{metrics:Ue,dbfs:Ke})}),q(`div`,{className:`flex items-center gap-1 shrink-0`,children:[q(`button`,{onClick:async()=>{ie?await o({title:`Disable "${j}"?`,message:`The device will stop processing streams and events. You can re-enable it later.`,confirmLabel:`Disable`,variant:`danger`})&&De.mutate({deviceId:t}):Te.mutate({deviceId:t})},disabled:Le,title:ie?`Disable device`:`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 ${ie?`border-success/30 text-success hover:bg-success/10`:`border-border text-foreground-subtle/50 hover:text-foreground hover:bg-surface-hover`}`,children:[G(Lt,{className:`h-3.5 w-3.5`}),G(`span`,{className:`hidden sm:inline`,children:Le?`Updating…`:ie?`Enabled`:`Disabled`})]}),G(`div`,{className:`hidden sm:block h-5 w-px bg-border mx-1`}),G(ue,{triggerClassName:`ml-1`,items:[{id:`snapshot`,label:`Take snapshot`,description:`Fetch a fresh frame and download it.`,icon:st,disabled:Ne,onClick:()=>{W()}},{id:`reboot`,label:`Reboot device`,description:`Camera goes offline for ~30 seconds.`,icon:nt,hidden:!Ae,disabled:Oe.isPending,danger:!0,onClick:async()=>{await o({title:`Reboot "${j}"?`,message:`The camera will go offline for around 30 seconds while the firmware reboots.`,confirmLabel:`Reboot`,variant:`danger`})&&Oe.mutate({deviceId:t})}},{id:`restart-addon`,label:`Restart addon`,description:`Bounces every device served by ${R?.name??P}.`,icon:tt,disabled:ke.isPending,danger:!0,onClick:async()=>{await o({title:`Restart "${R?.name??P}"?`,message:`Restarting the addon will briefly disconnect every device served by it (not just "${j}"). Streams will reconnect automatically.`,confirmLabel:`Restart`,variant:`danger`})&&ke.mutate({addonId:P})}},{id:`delete`,label:`Delete device`,description:`Remove the device and all its settings.`,icon:vt,separatorBefore:!0,disabled:we.isPending,danger:!0,onClick:async()=>{await o({title:`Delete "${j}"?`,message:`This will remove the device and all its settings. This action cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&we.mutate({deviceId:t})}}]})]})]})]}),G(ce,{deviceId:t,device:A??void 0,children:G(b,{children:G(He,{children:G(ye,{children:q(`main`,{className:L?`flex-1 overflow-y-auto flex flex-col`:`flex-1 min-h-0 overflow-hidden flex flex-row`,children:[q(`div`,{className:L?`flex flex-col bg-surface`:`${h===null?`w-1/2 lg:w-1/3`:``} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-hidden`,style:!L&&h!==null?{width:`${String(h)}px`}:void 0,children:[G(`div`,{className:`flex-shrink-0 border-b border-border-subtle ${te?`bg-black`:`bg-surface`}`,children:te?G(Qt,{deviceId:t,intercomAvailable:F.includes(qe.TwoWayAudio)}):G(Vn,{deviceId:t,deviceName:j,deviceType:I??`unknown`,provider:P,isOnline:M,features:F})}),q(`div`,{className:L?`flex flex-col border-b border-border`:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[G(`div`,{className:`flex-shrink-0 border-b border-border-subtle px-2 py-1.5`,children:G(`div`,{className:`flex gap-1 overflow-x-auto -mx-1 px-1 pb-0.5`,children:Ce.map(({id:e,label:t,icon:n})=>q(`button`,{onClick:()=>p(e),title:t,className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors flex-shrink-0 ${f===e?`bg-primary/15 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[G(n,{className:`h-3 w-3`}),t]},e))})}),q(`div`,{className:L?`h-72 overflow-hidden`:`flex-1 min-h-0 overflow-hidden`,children:[f===`logs`&&G($t,{deviceId:t,containerDeviceId:I===`container`?t:void 0}),f===`repl`&&G(en,{deviceId:t}),f===`events`&&G(tn,{deviceId:t}),f===`state`&&G(nn,{deviceId:t})]})]})]}),!L&&G(`div`,{role:`separator`,"aria-orientation":`vertical`,title:`Drag to resize`,onMouseDown:C,className:`flex-shrink-0 w-1 cursor-col-resize bg-border hover:bg-primary/40 transition-colors group relative z-10`,children:G(`span`,{className:`absolute inset-y-0 -left-1 -right-1`})}),q(`div`,{className:L?`flex flex-col`:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden`,children:[G(`div`,{className:`flex-shrink-0 border-b border-border bg-surface px-4`,children:G(`div`,{className:`flex flex-wrap items-center gap-0`,children:fe.map(e=>{let t=me===e.id;return q(`button`,{onClick:()=>ge(e.id),className:`relative flex-shrink-0 px-3 py-2 text-xs font-medium transition-colors ${t?`text-primary`:`text-foreground-subtle hover:text-foreground`}`,children:[e.label,t&&G(`span`,{className:`absolute bottom-0 left-0 right-0 h-0.5 rounded-full bg-primary`})]},e.id)})})}),q(`div`,{className:L?`p-3 flex flex-col gap-3`:`flex-1 min-h-0 overflow-y-auto p-4 flex flex-col gap-3`,children:[me===`overview`&&Se&&G(rn,{parentDeviceId:t}),Ye()]})]})]})})})})})]}):q(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[G(`p`,{className:`text-lg font-semibold text-foreground`,children:`Invalid device id`}),q(`p`,{className:`text-xs`,children:[`The URL segment`,` `,G(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`,children:e.deviceId}),` `,`is not a number.`]}),G(`button`,{onClick:()=>r(`/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:`Back to Integrations`})]})}function fr({metrics:e,dbfs:t}){let n=De(e.phase??`idle`);return q(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[q(`div`,{className:`flex items-center gap-1.5`,children:[G(`span`,{className:`h-1.5 w-1.5 rounded-full ${n.dotClass}`}),G(`span`,{className:`text-[10px] font-medium ${n.textColor}`,children:n.label})]}),G(`div`,{className:`h-3 w-px bg-border`}),q(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[G(St,{className:`h-3 w-3`}),G(`span`,{className:`text-foreground tabular-nums`,children:(e.actualFps??0).toFixed(1)}),G(`span`,{children:`fps`})]}),q(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[G(ht,{className:`h-3 w-3`}),G(`span`,{className:`text-foreground tabular-nums`,children:(e.avgInferenceTimeMs??0).toFixed(0)}),G(`span`,{children:`ms`})]}),q(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,title:`Current audio level (dBFS)`,children:[G(Rt,{className:`h-3 w-3`}),G(`span`,{className:`text-foreground tabular-nums`,children:t==null?`—`:t.toFixed(0)}),G(`span`,{children:`dB`})]}),(e.queueDepth??0)>0&&q(`span`,{className:`text-[10px] text-warning tabular-nums`,children:[`q:`,e.queueDepth]})]})}export{dr as DeviceDetailPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Hi as e,P as t,b as n,i as r}from"./src-BB1LG2-C.js";import{G as i,R as a,U as o,X as s,b as c,d as l,u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CK8iQdP1.js";import{d as f}from"./player-overlays-ZG1nYuYj.js";import{C as p,D as m,S as h,g,k as _,w as v}from"./schemas-CuE8EXQ7.js";import{S as y}from"./src-Cno9Ci3x.js";s();var b=_([v({kind:h(`adaptive`)}),v({kind:h(`profile`),profile:y})]),x=v({serverUrl:m().min(1),token:m().min(1),deviceId:p().int().nonnegative(),target:b,muted:g()});function S(e,t){let n=t===void 0?{type:`state`,state:e}:{type:`state`,state:e,message:t};window.ReactNativeWebView?.postMessage(JSON.stringify(n))}function C(e){switch(e){case`playing`:return`playing`;case`error`:return`error`;case`connecting`:case`disconnected`:case`idle`:return`connecting`}}function w(e){return e.kind===`adaptive`?{kind:`adaptive`}:{kind:`profile`,profile:e.profile}}function T(e){return e.kind===`adaptive`?`embed:adaptive`:`embed:profile:${e.profile}`}function E(){let e=window.__CAMSTACK_EMBED__;if(e==null)return{ok:!1,error:`window.__CAMSTACK_EMBED__ is not set`};let t=x.safeParse(e);return t.success?{ok:!0,config:t.data}:{ok:!1,error:t.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `)}}function D({message:e}){return a(()=>{S(`error`,e)},[e]),d(`div`,{style:{position:`fixed`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`#000`,color:`#f87171`,fontFamily:`system-ui, sans-serif`,fontSize:13,padding:16,textAlign:`center`},children:[`Embed config error: `,e]})}function O({system:e,deviceId:t,initialTarget:s,initialMuted:l}){let[u,d]=i(s),[f,p]=i(l),{handleOffer:m,getIceServers:h,addIceCandidate:g,getIceCandidates:_,closeSession:v,getSessionState:y}=r(e.trpcClient,t),x=o(()=>w(u),[u]),E=o(()=>(e,t)=>m(x,e,t),[m,x]),D=o(()=>(e,t,n)=>m(n,t,e),[m]);a(()=>(window.__camstackEmbed={setMuted:e=>p(e),setTarget:e=>{let t=b.safeParse(e);t.success&&d(t.data)}},()=>{window.__camstackEmbed&&delete window.__camstackEmbed}),[]);let O=T(u);return c(`div`,{style:{position:`fixed`,inset:0,width:`100vw`,height:`100vh`,background:`#000`},children:c(n,{serverUrl:e.serverUrl,streamKey:O,autoPlay:!0,muted:f,showControls:!1,className:`w-full h-full`,handleOffer:E,reoffer:D,getSessionState:y,getIceServers:h,addIceCandidate:g,getIceCandidates:_,closeSession:v,onStateChange:e=>S(C(e)),onError:e=>S(`error`,e)},O)})}function k(){let n=o(()=>E(),[]),r=o(()=>n.ok?{system:t({serverUrl:n.config.serverUrl,token:n.config.token}),queryClient:new l({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}})}:null,[n]);return a(()=>{if(r)return()=>{r.system.close()}},[r]),n.ok?r?c(f,{system:r.system,children:c(u,{client:r.queryClient,children:c(e.Provider,{client:r.system.trpcClient,queryClient:r.queryClient,children:c(O,{system:r.system,deviceId:n.config.deviceId,initialTarget:n.config.target,initialMuted:n.config.muted})})})}):c(D,{message:`Failed to initialise the embed player`}):c(D,{message:n.error})}export{k as EmbedPlayerPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,S as t}from"./src-BB1LG2-C.js";import{G as n,X as r,b as i,x as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CK8iQdP1.js";r();function o(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function s(e,t){if(e!==void 0)return t&&o(e)?t(e):e}function c({section:r,values:o,onChange:c,disabled:l,translationFn:u,onTestField:d,probeResults:f,onAction:p}){let[m,h]=n(r.defaultCollapsed??!1),g=r.style===`accordion`;if(r.fields.reduce((t,n)=>t+ +!!e(n,o,r.fields),0)===0)return null;let _=r.columns??2,v=_===1?`grid-cols-1`:_===3?`grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3`:_===4?`grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4`:`grid-cols-1 @[480px]:grid-cols-2`,y=r.fields.length===1&&r.fields[0]?.type===`widget`?r.fields[0]:void 0;return a(`div`,{className:`@container rounded-lg border border-border bg-surface p-3`,style:{containerType:`inline-size`},children:[!(y!==void 0||!r.title&&!r.description)&&a(`div`,{className:[`flex items-center justify-between mb-2`,g?`cursor-pointer`:``].join(` `),onClick:g?()=>h(e=>!e):void 0,children:[a(`div`,{children:[r.title&&i(`h3`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider`,children:s(r.title,u)}),r.description&&i(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:s(r.description,u)})]}),g&&i(`span`,{className:`text-foreground-subtle text-xs ml-2`,children:m?`▸`:`▾`})]}),!m&&(y===void 0?i(`div`,{className:`grid ${v} gap-x-3 gap-y-2.5`,children:r.fields.map(e=>i(t,{field:e,values:o,onChange:c,disabled:l,translationFn:u,onTestField:d,externalProbe:f?.[e.key],allFields:r.fields,onAction:p},e.key))}):i(t,{field:y,values:o,onChange:c,disabled:l,translationFn:u,onTestField:d,externalProbe:f?.[y.key],allFields:r.fields,onAction:p},y.key))]})}function l({schema:e,values:t,onChange:n,disabled:r,translationFn:a,onTestField:o,probeResults:s,onClearProbe:l,onAction:u}){let d=(e,r)=>{n({...t,[e]:r}),l?.(e)};return i(`div`,{className:`space-y-4`,children:e.sections.map((e,n)=>i(c,{section:e,values:t,onChange:d,disabled:r,translationFn:a,onTestField:o,probeResults:s,onAction:u},`${e.id}-${n}`))})}export{l as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$t as e,Bn as t,Hn as n,In as r,J as i,Kt as a,Ln as o,Mi as s,Qt as c,R as l,Rn as u,Wn as d,Yi as f,d as p,dn as m,en as h,g,in as _,ji as v,la as y,lt as b,mn as x,nn as S,sn as ee,tn as C,x as w,xn as T,z as te}from"./src-BB1LG2-C.js";import{F as E,G as D,R as O,U as k,W as A,X as j,b as M,o as N,x as P,y as F}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CK8iQdP1.js";import{p as I}from"./player-overlays-ZG1nYuYj.js";import{b as L}from"./src-Cno9Ci3x.js";import{t as R}from"./ProviderIcon-BS00rCO4.js";import{t as ne}from"./plus-D2fCWFPc.js";import{t as re}from"./refresh-cw-DewUBhjl.js";import{t as z}from"./rotate-cw-DiyghCam.js";import{t as B}from"./wifi-BJgMgcFe.js";import{B as V,E as H,F as ie,H as ae,M as oe,P as U,R as se,T as W,U as ce,f as G,i as K,o as q,p as le,s as ue,t as de,x as J}from"./index-D5OTguVm.js";import{t as Y}from"./FormBuilder-DBTf1H_B.js";import{t as X}from"./BrokerStep-kInoZsZ8.js";var fe=V(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]);j();function Z(e){let t=[];for(let n of e)n.type===`probe`&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...Z(n.fields));return t}function pe(e,t,n){let[r,i]=D(`idle`),[a,o]=D({}),s=k(()=>{let t=[];for(let n of e.sections)t.push(...Z(n.fields));return t},[e]),c=s.length>0&&n!==void 0,l=E(e=>{o(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]);return{testAllStatus:r,hasProbeFields:c,probeResults:a,handleTestAll:E(async()=>{if(!n)return;let e=s.filter(e=>{let n=t[e];return n!=null&&String(n).trim()!==``});if(e.length===0)return;i(`testing`);let r={};for(let t of e)r[t]={status:`probing`};o(r);let a=await Promise.allSettled(e.map(async e=>{try{return{key:e,result:await n(e,t[e])}}catch(t){return{key:e,result:{status:`error`,error:t instanceof Error?t.message:String(t)}}}})),c={};for(let e of a)if(e.status===`fulfilled`){let{key:t,result:n}=e.value;c[t]={status:n.status===`ok`?`ok`:`error`,result:n}}o(c),i(`idle`)},[n,s,t]),clearProbeResult:l}}j();function me(e){let t=[];for(let n of e)`required`in n&&n.required===!0&&`key`in n&&n.key&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...me(n.fields));return t}function he(e){return e==null?!0:typeof e==`string`?e.trim()===``:!1}function ge(e,t={}){for(let n of e){if(n.type===`group`&&`fields`in n){ge(n.fields,t);continue}`key`in n&&n.key&&`default`in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function Q(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function _e({open:e,integrationId:t,addonId:n,onClose:r}){let{t:i}=de(),a=N(),[o,s]=D({}),[c,l]=D(!1),[u,d]=D(null),[f,p]=D(Q),m=ee({addonId:n,type:L.Camera},{enabled:e}),h=m.data??null;O(()=>{e&&(s(h?ge(h.sections.flatMap(e=>e.fields)):{}),p(Q()),l(!1),d(null))},[e,t,h]);let _=k(()=>({...o,_probeRequestId:f}),[o,f]),v=C({onSuccess:()=>{a.invalidateQueries({queryKey:[[`deviceManager`]]})}}),y=T(),b=E(async(e,t)=>{l(!0);let r=await y.mutateAsync({addonId:n,type:L.Camera,key:e,value:t,formValues:_});return r.status===`ok`&&r.suggestedValues&&s(e=>{let t=!1,n={...e};for(let[i,a]of Object.entries(r.suggestedValues??{}))he(e[i])&&!he(a)&&(n[i]=a,t=!0);return t?n:e}),r},[y,n,_]),{testAllStatus:x,hasProbeFields:S,probeResults:w,handleTestAll:te,clearProbeResult:A}=pe(h??{sections:[]},o,b);async function j(e){d(null);try{await v.mutateAsync({addonId:n,type:L.Camera,config:o,integrationId:t}),e?s(h?ge(h.sections.flatMap(e=>e.fields)):{}):r()}catch(e){d(e instanceof Error?e.message:String(e))}}if(!e)return null;let F=me((h?.sections??[]).flatMap(e=>e.fields)).filter(e=>he(o[e])),I=F.length===0,R=!m.isLoading&&(m.isError||h===null);return P(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[M(`div`,{className:`absolute inset-0 bg-black/60`,onClick:r}),P(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col max-h-[90vh] rounded-xl border border-border bg-background shadow-2xl`,children:[P(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[M(`h2`,{className:`text-sm font-semibold text-foreground`,children:i(`integrations.addDevice`)}),M(`button`,{onClick:r,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:M(K,{className:`h-4 w-4`})})]}),M(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-3`,children:m.isLoading?M(`div`,{className:`flex items-center justify-center py-8`,children:M(J,{className:`h-5 w-5 animate-spin text-primary`})}):R?P(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[M(q,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),P(`div`,{className:`space-y-1`,children:[M(`p`,{className:`text-xs font-medium text-destructive`,children:`Provider unavailable`}),P(`p`,{className:`text-xs text-foreground-subtle`,children:[`The addon `,M(`span`,{className:`font-mono`,children:n}),` is not ready or does not support manual device creation. Check that the integration is online and try again.`]})]})]}):M(Y,{schema:h,values:o,onChange:s,onTestField:b,probeResults:w,onClearProbe:A})}),!R&&!m.isLoading&&P(`div`,{className:`border-t border-border bg-surface/50 shrink-0`,children:[P(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`flex w-full items-center justify-between px-5 py-2 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[P(`span`,{className:`flex items-center gap-2`,children:[M(le,{className:`h-3.5 w-3.5`}),`Test logs`,M(`span`,{className:`font-mono text-[9px] opacity-60`,children:f.slice(0,14)})]}),M(U,{className:`h-3.5 w-3.5 transition-transform ${c?`rotate-180`:``}`})]}),c&&M(`div`,{className:`border-t border-border max-h-64 overflow-hidden`,children:M(g,{addonId:n,requestId:f,limit:50,maxHeight:`max-h-64`,showFilters:!1,showScope:!1,className:`border-0 rounded-none`})})]}),!R&&!m.isLoading&&(u||F.length>0)&&M(`div`,{className:`border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0`,children:P(`div`,{className:`flex items-start gap-2`,children:[M(q,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),M(`p`,{className:`text-[11px] text-destructive`,children:u||`Required: ${F.join(`, `)}`})]})}),P(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[P(`div`,{className:`flex items-center gap-2`,children:[M(`button`,{onClick:r,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:i(`integrations.cancel`)}),!R&&S&&P(`button`,{type:`button`,onClick:te,disabled:x===`testing`,className:`inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[x===`testing`?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(B,{className:`h-3.5 w-3.5`}),`Test All`]})]}),P(`div`,{className:`flex items-center gap-2`,children:[M(`button`,{onClick:()=>j(!0),disabled:R||!I||v.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:i(`integrations.saveAndNew`)}),M(`button`,{onClick:()=>j(!1),disabled:R||!I||v.isPending,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:v.isPending?i(`integrations.saving`):i(`integrations.save`)})]})]})]})]})}function ve(e){let t=e.metadata;return[e.name,e.childNativeId,t.model,t.manufacturer,t.integration,t.externalLocation].filter(e=>typeof e==`string`&&e.length>0).join(` `)}j();var $=`devices`,ye={id:$,label:`Devices`,isDefault:!0},be=2e4,xe=100;function Se({addonId:t,integrationId:n,onClose:r}){let{t:i}=de(),[o,d]=D(new Set),[f,p]=D(new Set),[m,g]=D(new Map),[_,y]=D(null),{data:b}=u(),x=(b??[]).find(e=>e.addonId===t)?.supportsLocationImport??!1,[S,ee]=D(!0),C=a({integrationId:n}).data?.filters,w=C&&C.length>0?C:[ye],[T,te]=D(w.find(e=>e.isDefault)?.id??(w.some(e=>e.id===$)?$:w[0].id)),k=T!==$,j=h(),N=e({addonId:t,integrationId:n,page:1,pageSize:be,filter:T}),F=N.refetch,I=j.mutate,L=E(()=>{I({addonId:t,integrationId:n},{onSettled:()=>{F()}})},[I,t,n,F]),R=A(null);O(()=>{let e=`${t}::${n}`;R.current===e||N.isLoading||(R.current=e,(N.data?.candidates.length??0)===0&&L())},[t,n,N.isLoading,N.data,L]);let ne=j.isPending,re=j.isError?j.error instanceof Error?j.error.message:String(j.error):null,B=N.data?.candidates??[],V=N.isError?N.error instanceof Error?N.error.message:String(N.error):null,H=c(),ae=E(e=>{e.alreadyAdopted||d(t=>{let n=new Set(t);return n.has(e.childNativeId)?n.delete(e.childNativeId):n.add(e.childNativeId),n})},[]),oe=E(e=>{p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),U=E((e,t)=>{g(n=>{let r=new Map(n),i=r.get(e)?.hiddenChildIds??new Set,a=new Set(i);return a.has(t)?a.delete(t):a.add(t),a.size===0?r.delete(e):r.set(e,{hiddenChildIds:a}),r})},[]),se=E(e=>{let t={};for(let n of e){let e=m.get(n);e&&e.hiddenChildIds.size>0&&(t[n]={hiddenChildIds:[...e.hiddenChildIds]})}return Object.keys(t).length>0?t:void 0},[m]),W=E(async()=>{y(null);let e=[...o];if(e.length!==0)try{let i=se(e);await H.mutateAsync({addonId:t,integrationId:n,filter:T,childNativeIds:e,...i?{perCandidate:i}:{},...x?{importLocations:S}:{}}),d(new Set),g(new Map),await F(),r()}catch(e){y(e instanceof Error?e.message:String(e))}},[o,se,H,t,n,T,F,x,S]),ce=E(e=>{te(e),d(new Set),p(new Set),g(new Map),y(null)},[]),G=o.size;return P(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[M(`div`,{className:`absolute inset-0 bg-black/60`,onClick:r}),P(`div`,{className:`relative z-10 flex w-full max-w-3xl flex-col h-[85vh] rounded-xl border border-border bg-background shadow-2xl`,children:[P(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[P(`div`,{className:`min-w-0`,children:[M(`h2`,{className:`text-sm font-semibold text-foreground`,children:i(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}),M(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:i(`integrations.adoptDevicesHint`,{defaultValue:`Preview the candidate devices and add the ones you want.`})})]}),P(`div`,{className:`flex items-center gap-3 shrink-0`,children:[x&&P(`label`,{className:`flex items-center gap-1.5 cursor-pointer text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:[M(`input`,{type:`checkbox`,checked:S,onChange:e=>ee(e.target.checked),className:`accent-primary`}),i(`integrations.importLocations`,{defaultValue:`Import locations from the integration`})]}),M(`button`,{onClick:r,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Close`,children:M(K,{className:`h-4 w-4`})})]})]}),P(`div`,{className:`flex-1 min-h-0 px-5 py-3 flex flex-col gap-2 overflow-hidden`,children:[(re??V)&&B.length===0&&M(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3 shrink-0`,children:P(`div`,{className:`flex items-start gap-2`,children:[M(q,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),P(`div`,{className:`min-w-0`,children:[M(`p`,{className:`text-xs font-medium text-destructive`,children:i(`integrations.adoptRefreshFailed`,{defaultValue:`Could not discover devices.`})}),M(`p`,{className:`text-[11px] text-destructive/90 mt-0.5`,children:re??V})]})]})}),w.length>1&&M(Ce,{filters:w,activeFilter:T,onSelect:ce}),M(`div`,{className:`flex-1 min-h-0`,children:M(l,{mode:`generic`,items:B,pageSize:xe,getKey:e=>e.childNativeId,getSearchText:ve,getFilterType:e=>e.type,filterOptions:v(),filterLabel:i(`integrations.adoptColType`,{defaultValue:`Type`}),isLoading:N.isLoading||ne&&B.length===0,searchPlaceholder:i(`integrations.adoptSearch`,{defaultValue:`Search candidates…`}),emptyLabel:(re??V)&&B.length===0?``:i(`integrations.adoptNoCandidates`,{defaultValue:`No candidate devices found.`}),toolbar:P(`button`,{type:`button`,onClick:L,disabled:ne,title:i(`integrations.adoptRefreshTitle`,{defaultValue:`Re-scan Home Assistant for devices`}),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-60 shrink-0`,children:[M(z,{className:`h-3.5 w-3.5 ${ne?`animate-spin`:``}`}),i(`integrations.adoptRefresh`,{defaultValue:`Refresh`})]}),columns:[{key:`name`,header:i(`integrations.adoptColName`,{defaultValue:`Name`}),headerClassName:`w-[55%]`,cell:e=>M(we,{candidate:e,expandable:!k,expanded:f.has(e.childNativeId),onToggleExpand:()=>oe(e.childNativeId),adoptedLabel:i(`integrations.adoptAlready`,{defaultValue:`Adopted`})})},{key:`type`,header:i(`integrations.adoptColType`,{defaultValue:`Type`}),headerClassName:`w-[30%] hidden sm:table-cell`,cellClassName:`hidden sm:table-cell`,cell:e=>{let t=s(e.type),n=t.icon;return P(`span`,{className:`inline-flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[M(n,{className:`h-3.5 w-3.5 shrink-0`}),t.label]})}},{key:`select`,header:``,headerClassName:`w-[15%] text-right`,cellClassName:`text-right`,cell:e=>M(`div`,{className:`flex items-center justify-end`,children:M(`button`,{onClick:()=>ae(e),disabled:e.alreadyAdopted,"aria-label":o.has(e.childNativeId)?`Deselect`:`Select`,className:`inline-flex h-5 w-5 items-center justify-center rounded border ${o.has(e.childNativeId)?`border-primary bg-primary`:`border-border`} ${e.alreadyAdopted?`cursor-not-allowed opacity-50`:``}`,children:o.has(e.childNativeId)&&M(ie,{className:`h-3 w-3 text-primary-foreground`})})})}],isExpanded:e=>!k&&f.has(e.childNativeId),renderExpanded:k?void 0:e=>M(Te,{candidate:e,hiddenChildIds:m.get(e.childNativeId)?.hiddenChildIds??new Set,onToggleChildHidden:t=>U(e.childNativeId,t)}),rowClassName:e=>e.alreadyAdopted?`opacity-60`:o.has(e.childNativeId)?`bg-primary/5`:``})})]}),_&&M(`div`,{className:`border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0`,children:P(`div`,{className:`flex items-start gap-2`,children:[M(q,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),M(`p`,{className:`text-[11px] text-destructive`,children:_})]})}),P(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[M(`div`,{}),P(`div`,{className:`flex items-center gap-2`,children:[M(`button`,{onClick:r,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:i(`integrations.cancel`,{defaultValue:`Cancel`})}),P(`button`,{onClick:W,disabled:G===0||H.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50 disabled:cursor-not-allowed`,children:[H.isPending&&M(J,{className:`h-3.5 w-3.5 animate-spin`}),i(`integrations.addSelected`,{defaultValue:`Add selected`}),G>0?` (${G})`:``]})]})]})]})]})}function Ce({filters:e,activeFilter:t,onSelect:n}){return M(`div`,{role:`tablist`,"aria-label":`Discovery granularity`,className:`inline-flex shrink-0 self-start rounded-lg border border-border bg-surface p-0.5`,children:e.map(e=>{let r=e.id===t;return M(`button`,{type:`button`,role:`tab`,"aria-selected":r,onClick:()=>n(e.id),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${r?`bg-primary text-primary-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:e.label},e.id)})})}function we({candidate:e,expandable:t,expanded:n,onToggleExpand:r,adoptedLabel:i}){let a=(e.children??[]).length;return P(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[t&&a>0?P(`button`,{type:`button`,onClick:r,"aria-label":n?`Collapse`:`Expand`,"aria-expanded":n,className:`flex h-5 flex-shrink-0 items-center justify-center gap-0.5 rounded px-0.5 text-[10px] text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:[M(n?U:oe,{className:`h-3.5 w-3.5`}),a]}):M(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center text-foreground-subtle/40`,children:`—`}),M(`span`,{className:`truncate text-xs font-medium text-foreground`,children:e.name}),e.alreadyAdopted&&M(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[9px] font-medium text-success shrink-0`,children:i})]})}function Te({candidate:e,hiddenChildIds:t,onToggleChildHidden:n}){let r=e.children??[];return r.length===0?null:M(`div`,{className:`space-y-1 py-1`,children:r.map(e=>{let r=t.has(e.childNativeId),i=e.capabilities??[];return P(`div`,{className:`flex items-center gap-2 rounded px-2 py-1 ${r?`opacity-50`:``}`,children:[M(`span`,{className:`text-[11px] text-foreground truncate flex-1 min-w-0`,children:e.name}),i.length>0&&M(`span`,{className:`text-[9px] text-foreground-subtle truncate`,children:i.join(`, `)}),M(`button`,{onClick:()=>n(e.childNativeId),"aria-label":r?`Show child`:`Hide child`,title:r?`Show after adopt`:`Hide after adopt`,className:`flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors flex-shrink-0`,children:M(r?H:W,{className:`h-3 w-3`})})]},e.childNativeId)})})}j();function Ee({integrationId:e,addonId:r,name:i,kind:a,brokerKind:o,trpc:s,onClose:c}){let{t:l}=de(),u=N(),d=a===`device-adoption`,{data:f}=t({id:e},{enabled:d}),p=k(()=>{let e=f?.brokerId;return typeof e==`string`?e:null},[f]),m=n();return M(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,onClick:c,children:P(`div`,{className:`max-h-[85vh] w-full max-w-md overflow-y-auto rounded-xl border border-border bg-surface p-5 shadow-xl`,onClick:e=>e.stopPropagation(),children:[P(`div`,{className:`mb-3 flex items-center justify-between`,children:[P(`h2`,{className:`text-sm font-semibold text-foreground`,children:[l(`integrations.editConfig`,{defaultValue:`Edit configuration`}),` — `,i]}),M(`button`,{onClick:c,className:`rounded-md p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":l(`common.close`,{defaultValue:`Close`}),children:M(K,{className:`h-4 w-4`})})]}),d?o?P(`div`,{className:`space-y-3`,children:[M(`p`,{className:`text-[11px] text-foreground-subtle`,children:l(`integrations.relinkBrokerHelp`,{defaultValue:`Choose the broker this integration connects through. Picking a different broker re-points it and restarts the addon.`})}),p&&P(`p`,{className:`text-[11px] text-foreground`,children:[l(`integrations.currentBroker`,{defaultValue:`Current broker`}),`:`,` `,M(`span`,{className:`font-mono text-foreground-subtle`,children:p})]}),m.isPending?P(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[M(J,{className:`h-3 w-3 animate-spin`}),l(`integrations.saving`,{defaultValue:`Saving…`})]}):M(X,{kind:o,onResolved:t=>{m.mutate({id:e,settings:{brokerId:t}},{onSuccess:()=>{u.invalidateQueries(),c()}})},onBack:c}),m.isError&&M(`p`,{className:`text-[11px] text-danger`,children:l(`integrations.relinkFailed`,{defaultValue:`Failed to update broker link.`})})]}):M(`p`,{className:`text-[11px] text-danger`,children:l(`integrations.noBrokerKind`,{defaultValue:`This integration declares device-adoption but its addon manifest has no brokerKind.`})}):M(w,{trpc:s,addonId:r,nodeId:`hub`,title:i})]})})}j();function De(){let{t:e}=de(),{integrationId:t}=ce(),n=N(),a=ae(),s=I(),[c,h]=D(!1),[v,ee]=D(!1),[C,w]=D(!1),[T,O]=D(!1),{data:A,isLoading:j}=o({id:t??``},{enabled:!!t}),{data:L}=i({addonId:A?.addonId??``,nodeId:`hub`},{enabled:!!A?.addonId}),{data:z,isSuccess:B}=u(),V=k(()=>{let e=A?.addonId;return!e||!B?null:(z??[]).find(t=>t.addonId===e)?.kind===`device-adoption`?`device-adoption`:`device-provider`},[z,A?.addonId,B]),H=V!==null,ie=H?V===`device-adoption`?e(`integrations.adoptDevices`,{defaultValue:`Adopt devices`}):e(`integrations.addDevice`):e(`integrations.addDeviceLoading`,{defaultValue:`Loading…`}),oe=k(()=>{let e=A?.addonId;return!e||!B?null:(z??[]).find(t=>t.addonId===e)?.brokerKind??null},[z,A?.addonId,B]),U=L!=null&&Array.isArray(L.sections)&&L.sections.some(e=>e.fields.length>0),{data:W}=m({},{refetchInterval:5e3}),Y=[[`integrations`,`get`],{input:{id:t??``},type:`query`}],X=d({onMutate:async e=>{await n.cancelQueries({queryKey:Y});let t=n.getQueryData(Y);return t!=null&&n.setQueryData(Y,{...t,enabled:e.enabled}),{previous:t}},onError:(e,t,r)=>{let i=r;i?.previous!=null&&n.setQueryData(Y,i.previous)},onSettled:()=>{n.invalidateQueries({queryKey:[[`integrations`]]}),n.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Z=r({onSuccess:()=>{n.invalidateQueries({queryKey:[[`integrations`]]}),n.invalidateQueries({queryKey:[[`deviceManager`]]}),w(!1),a(`/integrations`)}}),pe=b({onSuccess:()=>{n.invalidateQueries({queryKey:[[`integrations`]]}),n.invalidateQueries({queryKey:[[`deviceManager`]]})}}),me=x({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}}),he=S({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}}),ge=_({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Q=k(()=>W??[],[W]),ve=k(()=>{let e=new Map;for(let t of Q)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[Q]),$=E(e=>ve.get(e)??null,[ve]),ye=E(e=>M(R,{type:e,size:`sm`}),[]),be=E(e=>a(`/devices/${String(e)}`),[a]),xe=k(()=>{let e=A?.addonId;return e?Q.filter(t=>t.addonId===e):[]},[Q,A?.addonId]),Ce=k(()=>te(xe).length,[xe]);return j?P(`div`,{className:`p-4`,children:[M(`div`,{className:`h-16 rounded-lg bg-surface animate-pulse mb-4`}),M(`div`,{className:`h-40 rounded-lg bg-surface animate-pulse`})]}):A?P(`div`,{className:`p-4 space-y-4 overflow-x-hidden`,children:[M(f,{items:[{label:`Integrations`,onClick:()=>a(`/integrations`)},{label:A.name}]}),P(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[P(`div`,{className:`flex items-center gap-3 min-w-0`,children:[M(`img`,{src:`/api/addon-assets/${A.addonId}/assets/icon.svg`,alt:``,className:`h-8 w-8 rounded-lg shrink-0`,onError:e=>{e.target.style.display=`none`}}),P(`div`,{className:`min-w-0`,children:[M(`h1`,{className:`text-lg font-semibold text-foreground truncate`,children:A.name}),P(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5 truncate`,children:[A.addonId,` · `,Ce,` `,e(`integrations.devices`)]})]})]}),P(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[P(`button`,{onClick:()=>h(!0),disabled:!H,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50 disabled:cursor-not-allowed`,title:ie,children:[M(ne,{className:`h-3.5 w-3.5`}),ie]}),P(`div`,{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${X.isPending?`opacity-60`:``} ${A.enabled?`border-success/30 bg-success/5`:`border-border bg-surface`}`,title:e(`integrations.toggleHint`,{defaultValue:`Click to toggle`}),children:[M(y,{checked:A.enabled,onCheckedChange:e=>X.mutate({id:t,enabled:e}),disabled:X.isPending,"aria-label":A.enabled?`Disable integration`:`Enable integration`}),M(`span`,{className:`text-[11px] font-medium ${A.enabled?`text-success`:`text-foreground-subtle`}`,children:A.enabled?`Enabled`:`Disabled`}),X.isPending&&M(J,{className:`h-3 w-3 animate-spin text-foreground-subtle`})]}),(U||V===`device-adoption`)&&P(`button`,{onClick:()=>ee(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[M(G,{className:`h-3 w-3`}),e(`integrations.config`)]}),P(`button`,{onClick:()=>O(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:e(`integrations.logs`,{defaultValue:`View logs`}),children:[M(le,{className:`h-3 w-3`}),e(`integrations.logs`,{defaultValue:`Logs`})]}),M(p,{label:`Restart`,icon:re,title:`Restart "${A.name}"?`,description:`Restarting the addon will briefly disconnect every device backed by it (${Ce} active). Streams will reconnect automatically.`,confirmLabel:`Restart`,triggerVariant:`outline`,confirmVariant:`danger`,disabled:pe.isPending,action:()=>pe.mutateAsync({addonId:A.addonId})}),P(`button`,{onClick:()=>w(!0),className:`flex items-center gap-1.5 rounded-lg border border-danger bg-danger/10 px-3 py-1.5 text-[11px] font-medium text-danger hover:bg-danger hover:text-background transition-colors`,title:e(`integrations.delete`,{defaultValue:`Delete integration`}),children:[M(ue,{className:`h-3 w-3`}),e(`integrations.delete`,{defaultValue:`Delete`})]})]})]}),M(l,{context:`integration-detail`,devices:Q,trpc:s.trpcClient,defaultView:`cards`,forceAddon:A.addonId,urlScope:`root`,lsKey:`integration-detail:${A.addonId}`,resolveIntegrationIcon:ye,resolveParent:$,onNavigate:be,batchActions:{remove:me.mutate,disable:he.mutate,enable:ge.mutate},onDeleteDevice:e=>me.mutate({deviceId:e.id})}),c&&t&&V===`device-adoption`&&M(Se,{addonId:A.addonId,integrationId:t,onClose:()=>h(!1)}),c&&t&&V===`device-provider`&&M(_e,{open:c,integrationId:t,addonId:A.addonId,onClose:()=>h(!1)}),v&&t&&V!==null&&M(Ee,{integrationId:t,addonId:A.addonId,name:A.name,kind:V,brokerKind:oe,trpc:s.trpcClient,onClose:()=>ee(!1)}),T&&M(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6`,onClick:()=>O(!1),children:P(`div`,{className:`flex flex-col rounded-xl border border-border bg-surface shadow-xl w-full max-w-5xl h-[80vh]`,onClick:e=>e.stopPropagation(),children:[P(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2.5`,children:[P(`div`,{className:`flex items-center gap-2 min-w-0`,children:[M(le,{className:`h-4 w-4 text-primary shrink-0`}),M(`h2`,{className:`text-sm font-semibold text-foreground truncate`,children:A.name}),P(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate`,children:[A.addonId,t?` · ${t}`:``]})]}),M(`button`,{onClick:()=>O(!1),className:`flex h-7 w-7 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Close logs`,children:M(K,{className:`h-4 w-4`})})]}),M(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:M(g,{addonId:A.addonId,limit:200,maxHeight:`max-h-full`,showScope:!1,className:`h-full border-0 rounded-none`})})]})}),C&&M(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,onClick:()=>!Z.isPending&&w(!1),children:P(`div`,{className:`rounded-xl border border-border bg-background p-5 shadow-2xl w-96 space-y-3`,onClick:e=>e.stopPropagation(),children:[P(`div`,{className:`flex items-start gap-3`,children:[M(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg bg-danger/10 shrink-0`,children:M(q,{className:`h-4 w-4 text-danger`})}),P(`div`,{className:`min-w-0`,children:[M(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`integrations.deleteTitle`,{defaultValue:`Delete integration?`})}),M(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`integrations.deleteWarning`,{defaultValue:`This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.`,name:A.name,count:Ce})})]})]}),Z.error&&M(`div`,{className:`rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:Z.error instanceof Error?Z.error.message:String(Z.error)}),P(`div`,{className:`flex items-center justify-end gap-2 pt-1`,children:[M(`button`,{onClick:()=>w(!1),disabled:Z.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:e(`integrations.cancel`,{defaultValue:`Cancel`})}),M(`button`,{onClick:()=>Z.mutate({id:t}),disabled:Z.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-danger px-3 py-1.5 text-[11px] font-medium text-background hover:bg-danger/90 transition-colors disabled:opacity-60 disabled:cursor-not-allowed`,children:Z.isPending?P(F,{children:[M(J,{className:`h-3 w-3 animate-spin`}),e(`integrations.deleting`,{defaultValue:`Deleting…`})]}):P(F,{children:[M(ue,{className:`h-3 w-3`}),e(`integrations.confirmDelete`,{defaultValue:`Delete integration`})]})})]})]})})]}):P(`div`,{className:`flex flex-col items-center justify-center py-20 px-6 text-center gap-4`,children:[M(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10`,children:M(fe,{className:`h-6 w-6 text-foreground-subtle`})}),P(`div`,{className:`space-y-1 max-w-sm`,children:[M(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`integrations.integrationNotFound`,{defaultValue:`Integration not found`})}),M(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`integrations.integrationNotFoundHint`,{defaultValue:`The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.`,id:t??``})})]}),P(`button`,{onClick:()=>a(`/integrations`),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:[M(se,{className:`h-3 w-3`}),e(`integrations.backToList`,{defaultValue:`Back to integrations`})]})]})}export{De as IntegrationDetailPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Fn as e,J as t,R as n,Rn as r,Un as i,Vn as a,Zt as o,ba as s,dn as c,rn as l,z as u}from"./src-BB1LG2-C.js";import{F as d,G as f,R as p,U as m,X as h,b as g,o as _,x as v,y}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CK8iQdP1.js";import{p as b}from"./player-overlays-ZG1nYuYj.js";import{t as x}from"./ProviderIcon-BS00rCO4.js";import{t as S}from"./plus-D2fCWFPc.js";import{t as C}from"./refresh-cw-DewUBhjl.js";import{F as w,H as T,I as E,M as D,P as O,W as k,f as A,g as j,i as M,t as N,x as P}from"./index-D5OTguVm.js";import{t as F}from"./AdminPage-CN6ZMhf0.js";import{t as I}from"./StatusBadge-CkYubfRG.js";import{t as L}from"./FormBuilder-DBTf1H_B.js";import{t as R}from"./useEventInvalidation-wNGhDdi_.js";import{t as z}from"./BrokerStep-kInoZsZ8.js";h();function B({onSelect:e,onClose:t,pendingAddonId:n=null}){let{t:i}=N(),a=T(),{data:o,isLoading:s}=r();if(s)return g(`div`,{className:`space-y-2 p-2`,children:[1,2,3].map(e=>g(`div`,{className:`h-14 rounded-lg bg-surface animate-pulse`},e))});let c=n!==null;return v(`div`,{className:`space-y-2`,children:[(o??[]).map(r=>{let o=r.instanceMode===`unique`&&r.existingInstances.length>0,s=n===r.addonId,l=c;return v(`button`,{disabled:l,onClick:()=>{if(!l)if(o){let e=r.existingInstances[0].id;t(),a(`/integrations/${e}`)}else e(r.addonId,r.instanceMode,r.discoveryMode,r.name,r.kind,r.brokerKind)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-surface p-3 text-left hover:border-foreground-subtle/30 transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border`,children:[r.iconUrl?g(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${r.color}15`},children:g(`img`,{src:r.iconUrl,alt:``,className:`h-5 w-5`})}):g(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${r.color}15`},children:g(`span`,{className:`text-sm`,style:{color:r.color},children:`◉`})}),v(`div`,{className:`flex-1 min-w-0`,children:[g(`p`,{className:`text-xs font-semibold text-foreground`,children:r.name}),r.description&&g(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 truncate`,children:r.description})]}),s?g(P,{className:`h-4 w-4 animate-spin text-primary flex-shrink-0`}):o?v(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[g(A,{className:`h-3 w-3`}),i(`integrations.manage`)]}):g(D,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},r.addonId)}),(o??[]).length===0&&g(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:i(`integrations.noProviders`)})]})}function V({addonId:e,configSchema:t,onSave:n,onBack:r}){let{t:a}=N(),[o,s]=f(``),[c,l]=f({}),[u,d]=f(null),p=i({onSuccess:e=>d(e),onError:e=>d({success:!1,error:String(e)})});return v(`div`,{className:`space-y-4`,children:[v(`div`,{children:[g(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:a(`integrations.integrationName`)}),g(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:a(`integrations.integrationNamePlaceholder`),className:`w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:border-primary/50`})]}),t&&g(L,{schema:t,values:c,onChange:l}),u&&g(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${u.success?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:u.success?a(`integrations.connectionSuccess`):`${a(`integrations.errorPrefix`)} ${u.error}`}),v(`div`,{className:`flex items-center justify-between pt-2`,children:[g(`button`,{onClick:r,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:a(`integrations.back`)}),v(`div`,{className:`flex items-center gap-2`,children:[g(`button`,{onClick:()=>p.mutate({addonId:e,settings:c}),disabled:p.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:p.isPending?a(`integrations.testing`):a(`integrations.testConnection`)}),g(`button`,{onClick:()=>n({name:o,config:c}),disabled:!o.trim(),className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:a(`integrations.forward`)})]})]})]})}h();function H({providerId:e,onImport:t,onSkip:n}){let{t:r}=N(),[i,a]=f(new Set),o=l(),s=o.data,c=o.isPending||!o.data&&!o.isError;p(()=>{e&&(o.isPending||o.data||o.mutate({addonId:e}))},[e,o]);function u(e){a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(c)return v(`div`,{className:`flex flex-col items-center py-12`,children:[g(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),g(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:r(`integrations.searchingDevices`)})]});let d=s??[];return v(`div`,{className:`space-y-4`,children:[g(`p`,{className:`text-xs text-foreground-subtle`,children:d.length>0?r(`integrations.foundDevices`,{count:d.length}):r(`integrations.noDevicesFound`)}),d.length>0&&g(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:d.map(e=>{let t=e.stableId,n=e.suggestedName??t,r=i.has(t);return v(`button`,{onClick:()=>u(t),className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${r?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[g(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${r?`border-primary bg-primary`:`border-border`}`,children:r&&g(w,{className:`h-3 w-3 text-primary-foreground`})}),g(E,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),g(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n})]},t)})}),v(`div`,{className:`flex items-center justify-between pt-2`,children:[g(`button`,{onClick:n,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:r(`integrations.skip`)}),d.length>0&&v(`button`,{onClick:()=>t(Array.from(i)),disabled:i.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[r(`integrations.importSelected`),` (`,i.size,`)`]})]})]})}h();function U(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}function W({open:n,onClose:r}){let{t:i}=N(),a=T(),s=_(),[c,u]=f(`picker`),[d,h]=f(null),[b,x]=f(null),[S,C]=f(`manual`),[w,E]=f(null),[D,O]=f(``),[k,A]=f(null),[j,F]=f(null),{data:I}=t({addonId:d??``,nodeId:`hub`},{enabled:d!=null}),L=m(()=>I?U(I):null,[I]),R=e({onSuccess:()=>s.invalidateQueries({queryKey:[[`integrations`]]})}),W=l(),G=W.data;p(()=>{c!==`discovery`||!b||!d||W.isPending||W.data||W.mutate({addonId:d})},[c,b,d,W]);let ee=o({onSuccess:()=>s.invalidateQueries({queryKey:[[`deviceManager`]]})});async function te(e,t,n,i,o,s){if(!R.isPending){if(h(e),C(n),O(i),F(null),o===`device-adoption`){if(!s){F(`Addon '${e}' declares device-adoption but no brokerKind in its manifest`);return}E(s),u(`broker`);return}if(t===`unique`){try{let t=await R.mutateAsync({addonId:e,name:i,settings:{}});r(),Y(),a(`/integrations/${t.id}`)}catch{}return}u(`config`)}}async function K(e){if(d)try{let t=await R.mutateAsync({addonId:d,name:e.name,settings:e.config});x(t.id),S===`auto`||S===`both`?u(`discovery`):J(t.id)}catch{}}async function q(e){if(d)try{let t=await R.mutateAsync({addonId:d,name:D,settings:{brokerId:e}});A(t.id),x(t.id),J(t.id)}catch{}}async function ne(e){if(d){for(let t of e){let e=G?.find(e=>e.stableId===t);e&&await ee.mutateAsync({addonId:d,candidate:e,...k===null?{}:{integrationId:k}})}J()}}function J(e){let t=e??b??d;r(),Y(),t&&a(`/integrations/${t}`)}function Y(){u(`picker`),h(null),x(null),C(`manual`),E(null),O(``),A(null),F(null)}function X(){r(),Y()}if(!n)return null;let re={picker:i(`integrations.newIntegration`),config:i(`integrations.configureIntegration`),discovery:i(`integrations.importDevices`),broker:i(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},Z=R.isPending,Q=Z?d:null,$=R.error;return v(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[g(`div`,{className:`absolute inset-0 bg-black/60`,onClick:Z?void 0:X}),v(`div`,{className:`relative z-10 w-full max-w-lg max-h-[85vh] rounded-xl border border-border bg-background shadow-2xl flex flex-col overflow-hidden`,children:[v(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[g(`h2`,{className:`text-sm font-semibold text-foreground`,children:re[c]}),g(`button`,{onClick:X,disabled:Z,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:g(M,{className:`h-4 w-4`})})]}),v(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto`,children:[$&&!Z&&g(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:$ instanceof Error?$.message:String($)}),c===`picker`&&v(y,{children:[j&&g(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:j}),g(B,{onSelect:te,onClose:X,pendingAddonId:Q})]}),c===`config`&&d&&g(V,{addonId:d,configSchema:L??null,onSave:K,onBack:()=>u(`picker`)}),c===`broker`&&w&&g(z,{kind:w,onResolved:e=>{q(e)},onBack:()=>u(`picker`)}),c===`discovery`&&b&&g(H,{providerId:b,onImport:ne,onSkip:J})]}),Z&&v(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-xl bg-background/85 backdrop-blur-sm`,children:[g(P,{className:`h-6 w-6 animate-spin text-primary`}),g(`p`,{className:`text-xs font-medium text-foreground`,children:i(`integrations.creating`,{defaultValue:`Creating integration…`})}),g(`p`,{className:`text-[10px] text-foreground-subtle`,children:i(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})})]})]})]})}function G({integration:e,expanded:t,onToggleExpand:n}){return v(`div`,{className:`flex items-center gap-2.5`,children:[g(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),n(e.addonId)},"aria-label":t?`Collapse`:`Expand`,"aria-expanded":t,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:g(t?O:D,{className:`h-3.5 w-3.5`})}),g(x,{type:e.addonId,size:`sm`}),v(`div`,{className:`flex min-w-0 flex-col`,children:[g(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:e.name}),g(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:e.addonId})]})]})}function ee(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:`Integration`,headerClassName:`w-[55%]`,cell:e=>g(G,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:`Devices`,headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>`${e.deviceCount} device${e.deviceCount===1?``:`s`}`},{key:`status`,header:`Status`,headerClassName:`w-[15%]`,cell:e=>g(I,{status:e.status})}]}h();function te(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var K=`expand`;function q(){let{t:e}=N(),t=T(),r=b(),[i]=k(),[o,l]=f(!1),p=d(()=>l(!0),[]),h=d(()=>l(!1),[]);R([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),R([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:_,isLoading:w,refetch:E}=a(void 0),{data:D,isLoading:O,refetch:A}=c({}),M=m(()=>D??[],[D]),P=m(()=>_??[],[_]),I=m(()=>{let e=new Map;for(let t of M)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[M]),L=m(()=>{let e=new Map;for(let t of u(M)){let n=t.addonId??``;n&&e.set(n,(e.get(n)??0)+1)}return e},[M]),z=m(()=>P.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:te(e),deviceCount:L.get(e.addonId)??0})),[P,L]),B=i.get(K),V=d(e=>{let t=new URLSearchParams(window.location.search);t.get(K)===e?t.delete(K):t.set(K,e);let n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:``}${window.location.hash}`;window.history.replaceState(window.history.state,``,r),window.dispatchEvent(new PopStateEvent(`popstate`))},[]),H=d(e=>t(`/integrations/${e.id}`),[t]),U=d(e=>I.get(e)??null,[I]),G=d(e=>g(x,{type:e,size:`sm`}),[]),q=d(e=>t(`/devices/${String(e)}`),[t]),ne=d(e=>g(n,{context:`integration-detail`,devices:M,trpc:r.trpcClient,forceAddon:e.addonId,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:G,resolveParent:U,onNavigate:q}),[M,r.trpcClient,G,U,q]),J=d(e=>B===e.addonId,[B]),Y=m(()=>ee({isExpanded:J,onToggleExpand:V}),[J,V]),X=d(e=>`${e.name} ${e.addonId}`,[]),re=d(e=>e.addonId,[]),Z=d(()=>{E(),A()},[E,A]),Q=w||O,$=P.length>0;return v(F,{icon:j,title:e(`nav.integrations`,`Integrations`),actions:v(y,{children:[g(`button`,{onClick:Z,disabled:Q,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:`Refresh`,children:g(C,{className:s(`h-3.5 w-3.5`,Q&&`animate-spin`)})}),v(`button`,{onClick:p,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[g(S,{className:`h-3.5 w-3.5`}),`New Integration`]})]}),children:[Q&&g(`div`,{className:`space-y-2`,children:[1,2,3].map(e=>g(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Q&&!$&&v(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[g(`p`,{className:`text-sm`,children:`No integrations configured.`}),g(`p`,{className:`text-xs mt-1`,children:`Click "New Integration" to connect cameras and devices.`})]}),!Q&&$&&g(n,{mode:`generic`,items:z,getKey:re,getSearchText:X,columns:Y,onRowClick:H,isExpanded:J,renderExpanded:ne,searchPlaceholder:e(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:e(`integrations.empty`,{defaultValue:`No integrations found.`})}),g(W,{open:o,onClose:h})]})}export{q as IntegrationsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as e,G as t,R as n,U as r,W as i,X as a,b as o,x as s,y as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CK8iQdP1.js";import{L as l,V as u,c as ee,g as d,n as f,p,s as m}from"./player-overlays-ZG1nYuYj.js";import{MaskShapeCanvas as h}from"./MaskShapeCanvas-C5K6H6Th.js";var te=d(`grid-2x2`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]);a();var ne=110,g=`motion-zones`,_=0,re=[1,2,3],v=1,y=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,b=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function x(e,t,n){let r=t*n,i=Array(r);for(let t=0;t<r;t+=1)i[t]=e[t]===!0;return i}function S(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function C(e,t){return Math.ceil(e/t)}function w(e,t,n){return Math.min(n-1,Math.floor((e+.5)/t*n))}function T(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array(i*a).fill(!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)e[r*t+n]===!0&&(o[s*i+w(n,t,i)]=!0)}return o}function E(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array(t*n).fill(!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)o[r*t+n]=e[s*i+w(n,t,i)]===!0}return o}function D({deviceId:a}){let d=ee(p().trpcClient,a),[w,D]=t(null),[O,k]=t(!1),[A,j]=t(null),[M,N]=t(null),[P,F]=t(v),[I,L]=t(!1),[R,z]=t(!1),B=i(!1);n(()=>{if(!d)return;let e=!1;return B.current=!1,D(null),k(!1),j(null),N(null),F(v),z(!1),(async()=>{try{let t=await d.motionZones?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(D(t),B.current)return;let n=await d.motionZones?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);B.current=!0;let r=n.regions.find(e=>e.shape.kind===`grid`),i=x(r?r.shape.cells:[],t.grid.width,t.grid.height);N(i),j(T(i,t.grid.width,t.grid.height,v))}catch(t){if(e)return;u(t)?k(!0):console.error(`Motion Zones load failed`,t)}})(),()=>{e=!0}},[d]);let V=w?w.grid.width:0,H=w?w.grid.height:0,U=C(V,P),W=C(H,P),G=r(()=>A&&w?E(A,V,H,P):null,[A,w,V,H,P]),K=r(()=>G!==null&&M!==null&&!S(G,M),[G,M]),q=r(()=>G?G.reduce((e,t)=>t?e+1:e,0):0,[G]),J=V*H,Y=U*W,X=e(e=>{Y>0&&j(Array(Y).fill(e))},[Y]),Z=e(()=>{j(e=>e&&e.map(e=>!e))},[]),ie=e(()=>{M&&w&&j(T(M,V,H,P))},[M,w,V,H,P]),ae=e(e=>{e===P||!w||j(t=>{if(!t)return F(e),t;let n=T(E(t,V,H,P),V,H,e);return F(e),n})},[P,w,V,H]),Q=r(()=>w&&A?[{id:_,shape:{kind:`grid`,gridWidth:U,gridHeight:W,cells:[...A]}}]:[],[w,A,U,W]),$=e((e,t)=>{t.kind===`grid`&&j(t.cells)},[]),oe=e(async()=>{if(!(!d||!A||!w)){L(!0);try{let e=E(A,w.grid.width,w.grid.height,P),t={kind:`grid`,gridWidth:w.grid.width,gridHeight:w.grid.height,cells:e};await d.motionZones?.setZone({patch:{regions:[{id:_,enabled:!0,shape:t}]}});let n=await d.motionZones?.getStatus({});if(n){let e=n.regions.find(e=>e.shape.kind===`grid`),t=x(e?e.shape.cells:[],w.grid.width,w.grid.height);N(t),j(T(t,w.grid.width,w.grid.height,P))}}catch(e){console.error(`Motion Zones save failed`,e)}finally{L(!1)}}},[d,A,w,P]);return f(r(()=>R&&!O&&w&&A?{id:g,order:ne,node:o(h,{transparent:!0,items:Q,supportedShapes:[`grid`],grid:{width:U,height:W},selectedId:_,onSelect:()=>{},onShapeChange:$,onDrawComplete:()=>{},drawingKind:null})}:null,[R,O,w,A,Q,$,U,W])),d?o(m,{title:`Motion Zones`,icon:o(te,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:o(`div`,{className:`flex flex-col gap-3`,children:O?o(`p`,{className:`${l} leading-relaxed`,children:`This camera doesn't expose an on-board motion zones grid.`}):!O&&w!==null&&A!==null?s(c,{children:[s(`p`,{className:`${l} leading-relaxed`,children:[`Toggle `,o(`strong`,{className:`text-foreground`,children:`Edit grid`}),` to paint the region directly on the live frame, then `,o(`strong`,{className:`text-foreground`,children:`Save`}),` to push the mask to the camera. Pick a bigger`,` `,o(`strong`,{className:`text-foreground`,children:`Cell size`}),` for quicker, broad-stroke painting — it's resampled to the camera's native `,w.grid.width,`×`,w.grid.height,` grid on save (×1 is the finest).`]}),s(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[o(`button`,{type:`button`,onClick:()=>z(e=>!e),disabled:I,"aria-pressed":R,className:R?b:y,children:R?`Done editing`:`Edit grid`}),o(`button`,{type:`button`,onClick:()=>X(!0),disabled:I,className:y,children:`All on`}),o(`button`,{type:`button`,onClick:()=>X(!1),disabled:I,className:y,children:`All off`}),o(`button`,{type:`button`,onClick:Z,disabled:I,className:y,children:`Invert`}),s(`div`,{className:`flex items-center gap-1 ml-1`,role:`group`,"aria-label":`Cell size`,children:[o(`span`,{className:`${l} mr-0.5`,children:`Cell size`}),re.map(e=>s(`button`,{type:`button`,onClick:()=>ae(e),disabled:I,"aria-pressed":P===e,title:e===1?`Camera grid ${V}×${H} (finest)`:`${C(V,e)}×${C(H,e)} painting grid · cells ×${e} bigger`,className:P===e?b:y,children:[`×`,e]},e))]}),s(`span`,{className:`${l} ml-1 tabular-nums`,children:[q,` / `,J,` cells · `,w.grid.width,`×`,w.grid.height,P===1?``:` · paint ${U}×${W}`]}),o(`span`,{className:`flex-1`}),o(`button`,{type:`button`,onClick:ie,disabled:I||!K,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:`Revert`}),o(`button`,{type:`button`,onClick:()=>void oe(),disabled:I||!K,className:b,children:I?`Saving…`:`Save`})]})]}):o(`p`,{className:`${l} leading-relaxed`,children:`Loading the camera's grid…`})})}):null}export{D as MotionZonesSettings};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-BHo8W_uH.js","assets/rolldown-runtime-Cyuzqnbw.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-zJ_50EbN.js";import"./src-BB1LG2-C.js";import{G as n,R as r,U as i,X as a,a as o,b as s,t as c,x as l,y as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CK8iQdP1.js";import{p as d}from"./player-overlays-ZG1nYuYj.js";import{t as f}from"./circle-check-big-Ca1L631f.js";import{t as p}from"./copy-Bi-BgxBp.js";import{t as m}from"./key-round-DdK6mTCz.js";import{t as h}from"./pencil-WwVUhRC9.js";import{C as g,T as _,b as v,j as y,l as b,r as x,s as S,x as C,y as w}from"./index-D5OTguVm.js";import{t as T}from"./AdminPage-CN6ZMhf0.js";a();function E({value:i,size:a=192}){let[o,c]=n(null),[u,d]=n(null);if(r(()=>{let n=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(n)return;let t=e.create;if(typeof t!=`function`){d(`qrcode.create() unavailable in installed version`);return}try{let e=t(i,{errorCorrectionLevel:`M`});n||c(e)}catch(e){n||d(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1])).catch(()=>{n||d(`qrcode library not installed`)}),()=>{n=!0}},[i]),u)return s(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:a,height:a},children:`QR rendering unavailable — use the secret below.`});if(!o)return s(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:a,height:a},children:`Generating…`});let f=o.modules.size,p=a/f,m=[];for(let e=0;e<f;e++)for(let t=0;t<f;t++)o.modules.data[e*f+t]&&m.push(s(`rect`,{x:t*p,y:e*p,width:p,height:p,fill:`currentColor`},`${t}-${e}`));return l(`svg`,{width:a,height:a,viewBox:`0 0 ${a} ${a}`,className:`text-black`,children:[s(`rect`,{x:0,y:0,width:a,height:a,fill:`white`}),m]})}a();var D={view:{icon:_,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:h,cls:`bg-primary/15 text-primary`},delete:{icon:S,cls:`bg-danger/15 text-danger`}};function O(){let{user:e,logout:t}=x();if(!e)return s(T,{children:s(`div`,{className:`text-xs text-foreground-subtle`,children:`Not signed in.`})});let n=e.isAdmin,r=e.scopes??[];return l(T,{children:[l(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[s(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),l(`div`,{className:`flex-1 min-w-0`,children:[s(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),l(`div`,{className:`text-[11px] text-foreground-subtle`,children:[n?`Administrator`:`User`,` · session id`,` `,l(`span`,{className:`font-mono`,children:[e.id.slice(0,8),`…`]})]})]})]}),n&&l(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[s(g,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),l(`div`,{children:[s(`div`,{className:`font-semibold text-foreground`,children:`Unrestricted access`}),s(`p`,{className:`text-foreground-subtle mt-0.5`,children:`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`})]})]}),s(k,{}),s(j,{username:e.username}),r.length>0&&l(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[l(`div`,{className:`px-4 py-2 border-b border-border`,children:[s(`div`,{className:`text-xs font-semibold text-foreground`,children:`Granted scopes`}),s(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Baked into your session token at login; sign out + back in to refresh after changes.`})]}),l(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[s(`div`,{children:`Type`}),s(`div`,{children:`Target`}),s(`div`,{children:`Access`})]}),s(`ul`,{className:`divide-y divide-border`,children:r.map((e,t)=>l(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[s(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),s(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?e.targets.join(`, `):e.target}),s(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(t=>{let n=e.access.includes(t),{icon:r,cls:i}=D[t];return l(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n?i:`bg-transparent text-foreground-subtle/40 line-through`}`,title:n?`Can ${t}`:`Cannot ${t}`,children:[s(r,{className:`h-3 w-3`}),t]},t)})})]},t))})]}),s(`div`,{className:`flex justify-end`,children:l(`button`,{onClick:t,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground transition-colors`,children:[s(w,{className:`h-3 w-3`}),`Sign out`]})})]})}function k(){let e=d(),[t,r]=n(``),[i,a]=n(``),[o,u]=n(``),[p,h]=n(null),g=c({mutationFn:t=>e.changeOwnPassword(t),onSuccess:()=>{h({kind:`success`,msg:`Password updated.`}),r(``),a(``),u(``)},onError:e=>{h({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),_=i.length>0&&o.length>0&&i!==o,b=i.length>0&&i.length<8,x=t.length>=1&&i.length>=8&&i===o;return l(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[l(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[s(m,{className:`h-3.5 w-3.5 text-foreground-subtle`}),s(`div`,{className:`text-xs font-semibold text-foreground`,children:`Change password`})]}),l(`div`,{className:`p-4 space-y-3`,children:[s(A,{label:`Current password`,value:t,onChange:r,autoComplete:`current-password`}),s(A,{label:`New password`,value:i,onChange:a,autoComplete:`new-password`,hint:`At least 8 characters.`}),s(A,{label:`Confirm new password`,value:o,onChange:u,autoComplete:`new-password`}),(_||b)&&s(`div`,{className:`text-[11px] text-danger`,children:_?`Passwords do not match.`:`New password must be at least 8 characters.`}),p&&l(`div`,{className:`text-[11px] flex items-center gap-1 ${p.kind===`success`?`text-emerald-500`:`text-danger`}`,children:[p.kind===`success`?s(f,{className:`h-3 w-3`}):s(y,{className:`h-3 w-3`}),p.msg]}),s(`div`,{className:`flex justify-end`,children:l(`button`,{onClick:()=>{h(null),g.mutate({currentPassword:t,newPassword:i})},disabled:!x||g.isPending,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[g.isPending?s(C,{className:`h-3 w-3 animate-spin`}):s(v,{className:`h-3 w-3`}),`Update password`]})})]})]})}function A({label:e,value:t,onChange:n,autoComplete:r,hint:i}){return l(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),s(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),autoComplete:r,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),i&&s(`div`,{className:`text-[10px] text-foreground-subtle`,children:i})]})}function j({username:e}){let t=d(),a=o({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>t.getOwnTotpStatus()}),m=a.data,[h,g]=n(null),[_,v]=n(``),[x,S]=n(null),[w,T]=n(!1),D=c({mutationFn:()=>t.setupOwnTotp(),onSuccess:e=>{g({secret:e.secret,otpauthUrl:e.otpauthUrl}),v(``),S(null)},onError:e=>S(e instanceof Error?e.message:`Setup failed`)}),O=c({mutationFn:e=>t.confirmOwnTotp(e),onSuccess:()=>{g(null),v(``),S(null),a.refetch()},onError:e=>S(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),k=c({mutationFn:()=>t.disableOwnTotp(),onSuccess:()=>{S(null),a.refetch()},onError:e=>S(e instanceof Error?e.message:`Disable failed`)});r(()=>{if(!w)return;let e=setTimeout(()=>T(!1),1500);return()=>clearTimeout(e)},[w]);let A=i(()=>a.isLoading?`loading`:h?`setup_in_progress`:m?.enabled?`enrolled`:`not_enrolled`,[a.isLoading,m?.enabled,h]);return l(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[l(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[s(b,{className:`h-3.5 w-3.5 text-foreground-subtle`}),s(`div`,{className:`text-xs font-semibold text-foreground`,children:`Two-factor authentication`})]}),l(`div`,{className:`p-4 space-y-3`,children:[A===`loading`&&l(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[s(C,{className:`h-3.5 w-3.5 animate-spin`}),`Checking status…`]}),A===`not_enrolled`&&l(u,{children:[s(`div`,{className:`text-xs text-foreground-subtle`,children:`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`}),s(`div`,{className:`flex justify-end`,children:l(`button`,{onClick:()=>{S(null),D.mutate()},disabled:D.isPending,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[D.isPending?s(C,{className:`h-3 w-3 animate-spin`}):s(b,{className:`h-3 w-3`}),`Enable 2FA`]})})]}),A===`setup_in_progress`&&h&&l(u,{children:[l(`div`,{className:`text-[11px] text-foreground-subtle`,children:[`Scan the QR code (or enter the secret manually) into your authenticator app for`,` `,s(`span`,{className:`font-mono`,children:e}),`, then enter the 6-digit code below to confirm.`]}),l(`div`,{className:`flex flex-col items-center gap-3`,children:[s(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:s(E,{value:h.otpauthUrl,size:180})}),l(`div`,{className:`w-full`,children:[s(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:`Secret (manual entry)`}),l(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[s(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:h.secret}),l(`button`,{onClick:()=>{h&&navigator.clipboard.writeText(h.secret).then(()=>T(!0))},className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground`,children:[w?s(f,{className:`h-3 w-3 text-emerald-500`}):s(p,{className:`h-3 w-3`}),w?`Copied`:`Copy`]})]})]})]}),l(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),s(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:_,onChange:e=>v(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),x&&l(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[s(y,{className:`h-3 w-3`}),x]}),l(`div`,{className:`flex justify-end gap-2`,children:[s(`button`,{onClick:()=>{g(null),S(null),v(``)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),l(`button`,{onClick:()=>{S(null),O.mutate({code:_})},disabled:O.isPending||_.length!==6,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[O.isPending?s(C,{className:`h-3 w-3 animate-spin`}):s(f,{className:`h-3 w-3`}),`Confirm`]})]})]}),A===`enrolled`&&m&&l(u,{children:[l(`div`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5`,children:[s(f,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),l(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[s(`div`,{className:`font-medium`,children:`2FA is active`}),l(`div`,{className:`text-foreground-subtle`,children:[`Enrolled on`,` `,m.confirmedAt?new Date(m.confirmedAt).toLocaleString():`—`]})]})]}),x&&l(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[s(y,{className:`h-3 w-3`}),x]}),s(`div`,{className:`flex justify-end`,children:l(`button`,{onClick:()=>{S(null),k.mutate()},disabled:k.isPending,className:`rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1`,children:[k.isPending?s(C,{className:`h-3 w-3 animate-spin`}):s(b,{className:`h-3 w-3`}),`Disable 2FA`]})})]})]})]})}export{O as MyAccessPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$n as e,Fi as t,Ji as n,Jn as r,Qn as i,Xn as a,Yn as o,Zn as s,at as c,cr as l,da as u,er as d,fa as f,it as p,nr as m,or as h,pa as g,pi as _,rr as v,sr as y,tr as b}from"./src-BB1LG2-C.js";import{F as x,G as S,R as ee,U as C,X as w,b as T,o as E,x as D,y as O}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CK8iQdP1.js";import{p as k}from"./player-overlays-ZG1nYuYj.js";import{a as A,s as j}from"./src-Cno9Ci3x.js";import{n as M,t as te}from"./rotate-ccw-CZ8RwUso.js";import{t as N}from"./copy-Bi-BgxBp.js";import{n as ne,t as P}from"./AddonCollectionPage-BHk_82L1.js";import{t as re}from"./refresh-cw-DewUBhjl.js";import{t as F}from"./server-DnaOYw5t.js";import{t as ie}from"./sparkles-D9CcRRON.js";import{t as ae}from"./square-CO0xPDBD.js";import{t as oe}from"./wifi-BJgMgcFe.js";import{B as I,D as L,F as se,_ as R,b as ce,i as le,o as z,w as B,x as V,y as ue}from"./index-D5OTguVm.js";import{t as H}from"./AdminPage-CN6ZMhf0.js";import{t as U}from"./AdminTabs-C5BWg3Pz.js";var de=I(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),fe=I(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),W=I(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]);w();var G=5e3,pe={connected:!1,endpoint:null};function me(e){let t=new Map;for(let n of e){let e=n?.manifest;e?.id&&t.set(e.id,e.packageDisplayName??e.name??e.id)}return t}function he(){let e=E(),t=c({capName:`network-access`},{refetchInterval:G}),n=p(void 0,{refetchInterval:G}),r=C(()=>me(n.data??[]),[n.data]),i=C(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:r.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,r]),[a,o]=S(null),[s,u]=S({}),d=(t,n)=>{let r=n?.addonId;e.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),o(null),u(e=>{let t=n?.addonId;if(t===void 0||!(t in e))return e;let r={...e};return delete r[t],r})},f=(e,t)=>{o(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);u(e=>({...e,[n]:r}))},m=y({onSuccess:d,onError:f}),h=l({onSuccess:d,onError:f});return T(P,{title:`Remote Access`,subtitle:`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …). Settings, Logs and Events are docked under every provider.`,pageIcon:B,itemIcon:B,capability:`network-access`,installButtonLabel:`Add tunnel`,items:i,isLoading:t.isLoading,emptyTitle:`No remote-access providers installed`,emptyDescription:`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`,renderStatusBadges:e=>T(ge,{addonId:e.addonId}),itemError:e=>s[e.addonId]??null,renderPrimaryAction:e=>T(q,{addonId:e.addonId,busyId:a,onStart:e=>{o(e),m.mutate({addonId:e})},onStop:e=>{o(e),h.mutate({addonId:e})}})})}function K(e){let{data:t}=h({addonId:e},{refetchInterval:G,retry:!1}),n=t?j.safeParse(t):null;return n?.success?n.data:pe}function ge({addonId:e}){let t=K(e);return D(O,{children:[T(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.connected?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:t.connected?`Connected`:`Disconnected`}),t.endpoint&&D(`a`,{href:t.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`text-[10px] text-emerald-700 dark:text-emerald-300 hover:underline flex items-center gap-1`,children:[T(L,{className:`h-3 w-3`}),t.endpoint.url]})]})}function q({addonId:e,busyId:t,onStart:n,onStop:r}){let i=K(e),a=t===e;return i.connected?D(g,{size:`sm`,variant:`secondary`,disabled:a,onClick:()=>r(e),children:[a?T(V,{className:`h-3 w-3 animate-spin`}):T(ae,{className:`h-3 w-3`}),`Stop`]}):D(g,{size:`sm`,variant:`primary`,disabled:a,onClick:()=>n(e),children:[a?T(V,{className:`h-3 w-3 animate-spin`}):T(ne,{className:`h-3 w-3`}),`Start`]})}w();var J=3e4;function _e(e){let t=new Map;for(let n of e){let e=n?.manifest;e?.id&&t.set(e.id,e.packageDisplayName??e.name??e.id)}return t}function ve(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function ye(){let e=c({capName:`turn-provider`},{refetchInterval:J}),t=p(void 0,{refetchInterval:J}),n=_(),r=n.data??[],i=C(()=>_e(t.data??[]),[t.data]);return T(P,{title:`TURN Servers`,subtitle:`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`,pageIcon:R,itemIcon:R,capability:`turn-provider`,installButtonLabel:`Add provider`,items:C(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:i.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,i]),isLoading:e.isLoading,emptyTitle:`No TURN providers installed`,emptyDescription:`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`,renderExpandedPanel:e=>T(be,{addonId:e.addonId,enabled:e.isActive}),trailing:D(u,{children:[D(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[D(`div`,{children:[T(`div`,{className:`text-sm font-semibold`,children:`Combined ICE server list`}),T(`div`,{className:`text-xs text-foreground-subtle`,children:`What the WebRTC layer fetches per-session.`})]}),T(g,{size:`sm`,variant:`secondary`,onClick:()=>n.refetch(),disabled:n.isFetching,children:`Refresh`})]}),T(`div`,{className:`p-4`,children:r.length===0?T(`div`,{className:`text-xs text-foreground-subtle`,children:`No servers from enabled providers.`}):T(`div`,{className:`flex flex-col gap-3`,children:r.map((e,t)=>{let n=Array.isArray(e.urls)?e.urls:[e.urls];return D(`div`,{className:`rounded border border-border bg-surface`,children:[(e.username||e.credential)&&D(`div`,{className:`px-3 py-1.5 border-b border-border text-[10px] font-mono text-foreground-subtle flex items-center gap-3`,children:[e.username&&D(`span`,{children:[T(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,T(`span`,{className:`text-foreground`,children:e.username})]}),e.credential&&D(`span`,{children:[T(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,T(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),T(`ul`,{className:`divide-y divide-border`,children:n.map(e=>T(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},t)})})})]})})}function be({addonId:e,enabled:t}){let n=_({addonId:e},{enabled:t,retry:!1}),r=C(()=>ve(n.data??[]),[n.data]);return!t||r.length===0?null:D(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[D(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Discovered ICE servers (`,r.length,`)`]}),T(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>T(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-[10px] font-mono bg-foreground-subtle/10 text-foreground`,children:e},e))})]})}w();var xe={lan:R,wifi:oe,docker:M,vpn:ce,loopback:F,other:F},Se={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},Ce=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function we(e){let{interfaces:t,disabled:n,hideLoopback:r,ipv4Only:i,emptyMessage:a}=e,o=C(()=>t.filter(e=>!(r&&e.kind===`loopback`||i&&e.family!==`IPv4`)),[t,r,i]),s=C(()=>{let e=new Map;for(let t of o){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return Ce.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[o]),c=t=>e.mode===`single`?e.value===t:e.value.includes(t),l=t=>{if(n||t.kind===`loopback`)return;if(e.mode===`single`){e.onChange(e.value===t.address?null:t.address);return}let r=new Set(e.value);r.has(t.address)?r.delete(t.address):r.add(t.address),e.onChange([...r])};return o.length===0?T(`div`,{className:`text-xs text-foreground-subtle italic`,children:a??`No addresses available.`}):T(`div`,{className:`flex flex-col gap-3`,children:s.map(({kind:t,items:r})=>D(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[D(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[T(xe[t]??F,{className:`h-3.5 w-3.5 text-foreground-subtle`}),T(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:Se[t]??t}),D(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,r.length]})]}),T(`ul`,{className:`divide-y divide-border`,children:r.map(t=>{let r=c(t.address),i=t.kind===`loopback`,a=!t.plausible&&!i;return D(`li`,{className:`flex items-center gap-3 px-3 py-2 ${i?`opacity-60 cursor-not-allowed`:n?`opacity-60`:a?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>l(t),children:[T(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${e.mode===`single`?`rounded-full`:`rounded`} border ${r?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:r&&T(se,{className:`h-3 w-3`})}),D(`div`,{className:`flex-1 min-w-0 ${a?`text-foreground-subtle`:``}`,children:[D(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[T(`span`,{className:`font-mono text-xs font-semibold ${a?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),T(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono`,children:t.family}),t.preferred&&T(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:`Auto-preferred`}),i&&T(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:`Always included`}),a&&D(`span`,{className:`inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300`,title:t.plausibleReason||void 0,children:[T(z,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]}),D(`div`,{className:`text-xs text-foreground-subtle mt-0.5 font-mono break-all`,children:[t.address,t.cidr&&t.cidr!==t.address?` (${t.cidr})`:``]})]})]},`${t.name}-${t.family}-${t.address}`)})})]},t))})}w();var Y={"lan-ipv4":`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,"lan-ipv6":`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`,loopback:`bg-foreground-subtle/15 text-foreground-subtle`};function Te(){let e=E(),t=k(),n=a(void 0,{refetchInterval:3e4}),c=r(void 0),l=i({onSuccess:()=>{e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),d=s({onSuccess:t=>{h(t.addresses),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),f=C(()=>n.data?.interfaces??[],[n.data]),p=o({port:typeof window<`u`?Number(window.location.port)||(window.location.protocol===`https:`?443:80):4e3,scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),[m,h]=S([]),[_,v]=S(!1);ee(()=>{!_&&c.data&&(h(c.data.addresses),v(!0))},[c.data,_]);let y=c.data?.addresses??[],b=C(()=>{if(m.length!==y.length)return!0;let e=[...m].toSorted(),t=[...y].toSorted();return e.some((e,n)=>e!==t[n])},[m,y]),x=()=>{l.mutate({addresses:[...m]})},w=()=>{h(y)},O=()=>{h([])},A=()=>{n.refetch(),p.refetch(),c.refetch()},j=async()=>{try{let e=await t.raceConnectionEndpoints({perCandidateTimeoutMs:1500});console.info(`[network-addresses] race result`,e)}catch(e){console.warn(`[network-addresses] race failed`,e)}},M=p.data?.endpoints??[];return D(H,{children:[D(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[T(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:`Pick the local addresses SDK clients should race for the fastest path to this hub. Empty selection (auto) lets every non-loopback / non-link-local interface participate.`}),D(`div`,{className:`flex items-center gap-2 shrink-0`,children:[D(g,{size:`sm`,variant:`secondary`,onClick:A,disabled:n.isLoading,children:[T(re,{className:`h-3 w-3 ${n.isLoading?`animate-spin`:``}`}),`Refresh`]}),T(g,{size:`sm`,variant:`secondary`,onClick:j,children:`Probe race`})]})]}),D(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[D(u,{children:[D(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[D(`div`,{children:[T(`div`,{className:`text-sm font-semibold`,children:`Allowed addresses`}),T(`div`,{className:`text-xs text-foreground-subtle`,children:m.length===0?`Auto — every non-loopback / non-link-local interface participates.`:`${m.length} pinned`})]}),D(`div`,{className:`flex items-center gap-1`,children:[D(g,{size:`sm`,variant:`secondary`,onClick:()=>d.mutate(void 0),disabled:d.isPending||l.isPending,title:`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`,children:[T(ie,{className:`h-3 w-3`}),d.isPending?`Detecting…`:`Best match`]}),D(g,{size:`sm`,variant:`secondary`,onClick:O,disabled:m.length===0||l.isPending,children:[T(te,{className:`h-3 w-3`}),`Clear`]}),b&&T(g,{size:`sm`,variant:`secondary`,onClick:w,disabled:l.isPending,children:`Discard`}),D(g,{size:`sm`,variant:`primary`,onClick:x,disabled:!b||l.isPending,children:[T(fe,{className:`h-3 w-3`}),l.isPending?`Saving…`:`Save`]})]})]}),T(`div`,{className:`p-4`,children:T(we,{mode:`multiple`,interfaces:f,value:m,onChange:h,disabled:l.isPending,emptyMessage:n.isLoading?`Loading interfaces…`:`No interfaces detected.`})})]}),D(u,{children:[D(`div`,{className:`px-4 py-3 border-b border-border`,children:[T(`div`,{className:`text-sm font-semibold`,children:`Connection endpoints — priority order`}),T(`div`,{className:`text-xs text-foreground-subtle`,children:`Live preview of the ranked candidate list the SDK would race against. Updates with each Save.`})]}),T(`div`,{className:`p-4`,children:M.length===0?T(`div`,{className:`text-xs text-foreground-subtle italic`,children:p.isLoading?`Loading…`:`No endpoints available.`}):T(`ul`,{className:`space-y-1 text-xs`,children:M.map(e=>D(`li`,{className:`flex items-center gap-2 flex-wrap ${e.plausible?``:`opacity-80`}`,children:[T(`span`,{className:`font-mono text-[10px] w-10 text-foreground-subtle`,children:String(e.priority).padStart(4,`0`)}),T(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${Y[e.kind]??Y.loopback}`,children:e.kind}),e.interfaceKind!==`lan`&&e.interfaceKind!==`public`&&T(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-medium uppercase`,children:e.interfaceKind}),!e.plausible&&e.interfaceKind!==`loopback`&&D(`span`,{className:`inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300`,title:e.plausibleReason||void 0,children:[T(z,{className:`h-2.5 w-2.5`}),`Unlikely usable`]}),T(`span`,{className:`font-mono break-all ${e.plausible?`text-foreground`:`text-foreground-subtle`}`,children:e.baseUrl}),D(`span`,{className:`text-foreground-subtle`,children:[`— `,e.label]})]},`${e.priority}-${e.baseUrl}`))})})]})]})]})}w();var Ee={mesh:`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},X=5e3,De=3e4,Oe={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function ke(e){let t=new Map;for(let n of e){let e=n?.manifest;e?.id&&t.set(e.id,e.packageDisplayName??e.name??e.id)}return t}function Ae(){let e=c({capName:`mesh-network`},{refetchInterval:X}),t=p(void 0,{refetchInterval:X}),n=C(()=>ke(t.data??[]),[t.data]);return T(P,{title:`Mesh Networks`,subtitle:`Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).`,pageIcon:M,itemIcon:R,capability:`mesh-network`,installButtonLabel:`Add mesh`,items:C(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:n.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,n]),isLoading:e.isLoading,emptyTitle:`No mesh-network providers installed`,emptyDescription:`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`,renderStatusBadges:e=>T(je,{addonId:e.addonId}),renderPrimaryAction:e=>T(Me,{addonId:e.addonId}),renderExpandedPanel:e=>T(Ne,{addonId:e.addonId})})}function Z(t){let{data:n,isLoading:r}=e({addonId:t},{refetchInterval:X,retry:!1}),i=n?A.safeParse(n):null;return{status:i?.success?i.data:Oe,isLoading:r}}function je({addonId:e}){let{status:t}=Z(e);return D(O,{children:[T(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.joined?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:t.joined?`Joined`:`Not joined`}),t.joined&&D(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:[t.peerCount,` peer`,t.peerCount===1?``:`s`]})]})}function Me({addonId:e}){let t=E(),[n,r]=S(!1),[i,a]=S(null),o=k(),{status:s}=Z(e),c=x(()=>{t.invalidateQueries({queryKey:[[`meshNetwork`]]})},[t]),l=v(),u=d({onSuccess:c}),f=m({onSuccess:c}),p=x(async()=>{r(!0);let t={cancelled:!1};a(t);try{let n=await l.mutateAsync({addonId:e});if(t.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!t.cancelled&&(await Re(2e3),!t.cancelled);){let t=await o.trpcClient.meshNetwork.getStatus.query({addonId:e}).catch(()=>null),n=t?A.safeParse(t):null;if(n?.success&&n.data.joined){c();break}if(Date.now()-r>6e5)break}}finally{r(!1),a(null)}},[e,c,l,o]),h=x(()=>{i&&(i.cancelled=!0),r(!1),a(null)},[i]);return T(O,{children:s.joined?D(O,{children:[D(g,{size:`sm`,variant:`secondary`,disabled:u.isPending,onClick:()=>u.mutate({addonId:e}),children:[u.isPending?T(V,{className:`h-3 w-3 animate-spin`}):T(ue,{className:`h-3 w-3`}),`Disconnect`]}),D(g,{size:`sm`,variant:`ghost`,disabled:f.isPending,onClick:()=>f.mutate({addonId:e}),children:[f.isPending?T(V,{className:`h-3 w-3 animate-spin`}):T(W,{className:`h-3 w-3`}),`Log out`]})]}):n?D(g,{size:`sm`,variant:`ghost`,onClick:h,children:[T(le,{className:`h-3 w-3 mr-1`}),` Cancel`]}):D(O,{children:[D(g,{size:`sm`,variant:`primary`,onClick:()=>void p(),children:[T(de,{className:`h-3 w-3`}),`Connect`]}),D(g,{size:`sm`,variant:`ghost`,disabled:f.isPending,onClick:()=>f.mutate({addonId:e}),children:[f.isPending?T(V,{className:`h-3 w-3 animate-spin`}):T(W,{className:`h-3 w-3`}),`Log out`]})]})})}function Ne({addonId:e}){let{status:n}=Z(e),r=b({addonId:e},{refetchInterval:De,retry:!1});return D(`div`,{className:`rounded-lg border border-border bg-surface`,children:[D(`div`,{className:`p-4 space-y-4`,children:[n.error&&T(t,{message:n.error}),T(Pe,{status:n}),n.endpoints.length>0&&D(`div`,{className:`space-y-1.5`,children:[T(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:`Endpoints`}),n.endpoints.map(e=>D(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[D(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${Ee[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?T(B,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,e.label]}),D(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1`,children:[T(L,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),T(`div`,{className:`border-t border-border`,children:T(Ie,{peers:r.data?.peers??[],loading:r.isLoading})})]})}function Pe({status:e}){return T(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:`Tenant`,value:e.tenantName||`—`},{label:`User`,value:e.userLogin??`—`},{label:`Control plane`,value:e.controlPlaneUrl||`—`},{label:`Mesh IP`,value:e.meshIp||`—`,mono:!0},{label:`MagicDNS`,value:e.magicDnsHostname||`—`,mono:!0},{label:`DNS suffix`,value:e.magicDnsSuffix||`—`,mono:!0},{label:`Peers`,value:String(e.peerCount)},{label:`Key expiry`,value:e.keyExpiry?Fe(e.keyExpiry):`—`}].map(e=>D(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[T(`span`,{className:`text-foreground-subtle shrink-0`,children:e.label}),T(`span`,{className:`text-foreground truncate ${e.mono?`font-mono`:``}`,children:e.value})]},e.label))})}function Fe(e){let t=e-Date.now();if(t<0)return`Expired ${$(e)}`;let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return`in ${n} days`;let r=Math.floor(t/36e5);return r>1?`in ${r}h`:`in ${Math.max(1,Math.floor(t/6e4))} min`}function Ie({peers:e,loading:t}){let r=C(()=>e.map(e=>({...e,_id:e.id})),[e]),i=x(e=>{e&&navigator.clipboard?.writeText(e)},[]),a=C(()=>[{key:`hostname`,header:`Hostname`,render:e=>D(`div`,{className:`flex flex-col`,children:[D(`div`,{className:`flex items-center gap-1.5`,children:[T(`span`,{className:`font-medium text-foreground`,children:e.hostname||`(unknown)`}),e.isSelf&&T(f,{variant:`info`,children:`self`}),e.exitNodeOption&&T(f,{variant:`warning`,children:`exit-node`})]}),e.userLogin&&T(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.userLogin})]})},{key:`magicDns`,header:`MagicDNS`,render:e=>e.magicDns?D(`div`,{className:`flex items-center gap-1`,children:[T(`span`,{className:`font-mono text-xs truncate`,children:e.magicDns}),T(`button`,{onClick:()=>i(e.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy MagicDNS`,children:T(N,{className:`h-3 w-3 text-foreground-subtle`})})]}):T(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:e=>{let t=e.addresses[0]??``;return t?D(`div`,{className:`flex items-center gap-1`,children:[T(`span`,{className:`font-mono text-xs`,children:t}),T(`button`,{onClick:()=>i(t),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy IP`,children:T(N,{className:`h-3 w-3 text-foreground-subtle`})})]}):T(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:`Connection`,render:e=>D(`div`,{className:`flex items-center gap-1.5`,children:[T(f,{variant:Le(e.connection),children:e.connection}),e.relay&&T(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.relay})]})},{key:`routes`,header:`Routes`,render:e=>e.advertisedRoutes.length>0?T(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):T(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:`TX / RX`,render:e=>D(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,Q(e.txBytes),` · ↓ `,Q(e.rxBytes)]})},{key:`lastSeen`,header:`Last seen`,render:e=>T(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?$(e.lastSeenMs):`—`})}],[i]);return t&&e.length===0?D(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[T(V,{className:`h-3 w-3 animate-spin inline mr-1`}),` Loading peers…`]}):e.length===0?T(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:`No peers visible — your tailnet may be empty or the host is not joined.`}):T(`div`,{className:`p-4`,children:T(n,{columns:a,rows:r,rowKey:e=>e._id,minWidthPx:820})})}function Le(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function Q(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(2)}GB`}function $(e){let t=Date.now()-e;return t<6e4?`just now`:t<36e5?`${Math.round(t/6e4)}m ago`:t<864e5?`${Math.round(t/36e5)}h ago`:`${Math.round(t/864e5)}d ago`}function Re(e){return new Promise(t=>setTimeout(t,e))}function ze(){return T(`div`,{className:`flex flex-col p-4`,children:T(U,{tabs:[{id:`addresses`,label:`Network Addresses`,icon:F,content:T(Te,{})},{id:`remote-access`,label:`Remote Access`,icon:B,content:T(he,{})},{id:`mesh`,label:`Mesh Networks`,icon:M,content:T(Ae,{})},{id:`turn`,label:`TURN Servers`,icon:R,content:T(ye,{})}]})})}export{ze as NetworkPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Gt as e,Tr as t,X as n,Y as r,it as i,wt as a}from"./src-BB1LG2-C.js";import{F as o,G as s,O as c,R as l,U as u,V as d,W as f,X as p,b as m,i as h,o as g,t as _,x as v}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CK8iQdP1.js";import{p as y}from"./player-overlays-ZG1nYuYj.js";import{E as b}from"./src-Cno9Ci3x.js";import{n as ee,r as x,t as te}from"./SchemaTabBar-ByWwzBUZ.js";import{t as S}from"./FormBuilder-DBTf1H_B.js";p();var C=c(function({addonId:e,schema:t,serverValues:n,onImmediateSave:r,onStateChange:i,onAction:a,disabled:s},c){let p=x({schema:t,serverValues:n,onImmediateSave:o(t=>r(e,t),[e,r]),onDeferredSave:o(()=>{},[])});d(c,()=>({flush:()=>{let e={};for(let t of p.pendingKeys)e[t]=p.values[t];return p.handleDiscard(p.pendingKeys),e},discard:()=>p.resetAll()}),[p]);let h=p.pendingKeys,g=h.join(`|`),_=u(()=>h.map(e=>`${e}=${JSON.stringify(p.values[e])}`).join(`,`),[h,p.values]),v=f(i);l(()=>{v.current=i},[i]),l(()=>{let t={};for(let e of h)t[e]=p.values[e];v.current({addonId:e,pendingKeys:h,pendingValues:t})},[e,g,_]);let y=u(()=>{if(a)return(t,n,r)=>a(e,t,n,r)},[e,a]);return m(S,{schema:t,values:p.values,onChange:p.handleChange,disabled:s,onAction:y})});p();function w(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>w(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function T(e,t){return{...e,fields:e.fields.map(e=>w(e,t))}}function ne(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>T(e,t))},values:t}}function E({nodeId:c,addonIds:l,level:d,deviceId:p,capability:x,sectionIds:S,sectionTab:C,extraTabs:w,title:T,description:E}){let D=g(),O=y().trpcClient,k=n(),A=r(),j=t(),M=e(),N=a(),P=!!(w&&w.length>0),[F,ie]=s(null);if(d===`device`&&!p)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let I=c??`hub`,L=h({queries:l.map(e=>({queryKey:[[`addonSettings`,d===`global`?`getGlobalSettings`:`getDeviceSettings`],{addonId:e,nodeId:I,deviceId:p??null,cap:x??null}],queryFn:async()=>d===`global`?{addonId:e,result:await O.addonSettings.getGlobalSettings.query({addonId:e,nodeId:I,...x?{cap:x}:{}})}:{addonId:e,result:await O.addonSettings.getDeviceSettings.query({addonId:e,deviceId:p,nodeId:I})}}))}),R=L.some(e=>e.isLoading),z=L.map(e=>{if(!e.data)return`-`;if(e.data.result===null)return`${e.data.addonId}:n`;let t=[];for(let n of e.data.result.sections){t.push(`s:${n.id}:${n.tab??`general`}`);for(let e of n.fields){if(!(`key`in e))continue;let n=`options`in e&&Array.isArray(e.options)?e.options.map(e=>e.value).join(`,`):``,r=e.value,i=r===void 0?``:typeof r==`string`?r:JSON.stringify(r);t.push(`f:${e.key}:${n}:${i}`)}}return`${e.data.addonId}:${t.join(`|`)}`}).join(`||`),B=u(()=>{let e=new Set;for(let t of L){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(t.tab??`general`)}return[...e]},[z+`::`+L.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),V=u(()=>new Map((w??[]).map(e=>[e.id,e])),[w]),H=u(()=>{if(!P)return[];let e=[...new Set([...B,...(w??[]).map(e=>e.id)])],t=e=>{let t=V.get(e);if(t?.order!==void 0)return t.order;let n=b[e];return n?n.order:50};return e.toSorted((e,n)=>{let r=t(e),i=t(n);return r===i?e.localeCompare(n):r-i})},[P,B,w,V]),ae=u(()=>{let e=new Map;for(let t of B){let n=b[t];e.set(t,n?.label??t.charAt(0).toUpperCase()+t.slice(1))}for(let t of w??[])e.set(t.id,t.label);return e},[B,w]),U=P?F&&H.includes(F)?F:H[0]??null:null,W=U!==null&&V.has(U),G=P?U&&!W?U:void 0:C,{data:K}=i(void 0),oe=u(()=>{let e=new Map;for(let t of K??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[K]),q=u(()=>{let e=S?new Set(S):null,t=[];for(let n of L){if(!n.data||n.data.result===null)continue;let{schema:r,values:i}=ne(n.data.result),a=r.sections.filter(t=>e?e.has(t.id):!0);if(a.length===0)continue;let o={...n.data.result,sections:n.data.result.sections.filter(t=>e?e.has(t.id):!0)},s={...r,sections:a};t.push({addonId:n.data.addonId,schemaWithValues:o,schema:s,serverValues:i})}return t},[z,S]),[J,se]=s(new Map),ce=o(e=>{se(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),Y=f(new Map),le=o(e=>t=>{t?Y.current.set(e,t):Y.current.delete(e)},[]),X=o(async(e,t)=>{d===`global`?await k.mutateAsync({addonId:e,nodeId:I,patch:t}):await A.mutateAsync({addonId:e,deviceId:p,nodeId:I,patch:t}),D.invalidateQueries({queryKey:[[`addonSettings`]]})},[k,A,I,d,p,D]),ue=o(async(e,t,n,r)=>{let i=I;try{switch(t){case`reprobe-engine`:await j.mutateAsync({nodeId:i}),D.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-hwaccel`:await M.mutateAsync({nodeId:i}),D.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await N.mutateAsync({nodeId:i}),D.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await O.addons.custom.mutate({addonId:e,action:t,input:r});return D.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[j,M,N,I,D,O]),de=o((e,t)=>{X(e,t)},[X]),Z=_({mutationFn:async()=>{let e=[];for(let t of q){let n=J.get(t.addonId);!n||n.pendingKeys.length===0||e.push({addonId:t.addonId,patch:n.pendingValues})}return e.length===0?{saved:[]}:{saved:await Promise.all(e.map(async({addonId:e,patch:t})=>(d===`global`?await k.mutateAsync({addonId:e,nodeId:I,patch:t}):await A.mutateAsync({addonId:e,deviceId:p,nodeId:I,patch:t}),e)))}},onSuccess:({saved:e})=>{for(let t of e)Y.current.get(t)?.discard();D.invalidateQueries({queryKey:[[`addonSettings`]]})}}),fe=o(()=>{for(let e of Y.current.values())e.discard()},[]),pe=u(()=>{let e=0;for(let t of q){let n=J.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[q,J]),me=u(()=>{let e=new Map;for(let t of q){let n=J.get(t.addonId);if(!n||n.pendingKeys.length===0)continue;let r=new Set(n.pendingKeys);for(let n of t.schema.sections){let t=n.tab??`general`;for(let i of n.fields)`key`in i&&r.has(i.key)&&e.set(t,(e.get(t)??0)+1)}}return e},[q,J]);if(R)return m(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let Q=U&&W?V.get(U):void 0;if(!P&&q.length===0)return v(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:[`No addons in `,l.length>0?`[${l.join(`, `)}]`:`the current selection`,` `,`expose `,d,`-level settings on this node.`]});let $=Z.isPending;return v(`div`,{className:`space-y-4`,children:[(T||E)&&v(`div`,{className:`border-b border-border pb-2`,children:[T&&m(`h2`,{className:`text-sm font-semibold text-foreground`,children:T}),E&&m(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:E})]}),P&&m(te,{tabs:H.map(e=>({id:e,label:ae.get(e)??e})),activeId:U,onChange:ie,pendingByTab:me}),Z.isError&&v(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[`Save failed: `,String(Z.error?.message??Z.error)]}),Q?Q.content:(()=>{let e=G?q.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===G).length,0):0,t=G!==null&&e<=1,n=q.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>G?(e.tab??`general`)===G:!0).map(e=>t?{...e,title:``,description:void 0}:e)}})).filter(e=>e.renderedWithValues.sections.length>0).toSorted((e,t)=>{let n=e=>{let t=1/0;for(let n of e)typeof n.order==`number`&&n.order<t&&(t=n.order);return t},r=n(e.renderedWithValues.sections),i=n(t.renderedWithValues.sections);return r===i?0:r-i});return n.length===0?m(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:`Nothing to configure here for this node.`}):m(re,{entries:n,paneStates:J,displayNames:oe,disabled:$,setPaneRef:le,onPaneStateChange:ce,onImmediateSave:de,onAction:ue,inline:P||!!C})})(),!R&&m(ee,{pendingCount:pe,onSave:()=>Z.mutate(),onDiscard:fe,saving:$})]})}function re({entries:e,paneStates:t,displayNames:n,disabled:r,setPaneRef:i,onPaneStateChange:a,onImmediateSave:o,onAction:c,inline:d}){let f=u(()=>[...e].toSorted((e,t)=>{if(e.addonId===`system-config`)return-1;if(t.addonId===`system-config`)return 1;let r=n.get(e.addonId)??e.addonId,i=n.get(t.addonId)??t.addonId;return r.localeCompare(i)}),[e,n]),[p,h]=s(f[0]?.addonId??``);l(()=>{f.length!==0&&(f.find(e=>e.addonId===p)||h(f[0].addonId))},[f,p]);let g=f.find(e=>e.addonId===p)??f[0];if(!g)return null;let _=u(()=>c?(e,t,n,r)=>c(e,t,n,r):void 0,[c]),y=e=>m(C,{ref:i(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:o,onStateChange:a,onAction:_,disabled:r},e.addonId);return f.length===1||d?m(`div`,{className:`flex flex-col gap-4`,children:f.map(y)}):v(`div`,{className:`flex flex-col gap-3`,children:[m(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:f.map(e=>{let r=n.get(e.addonId)??e.addonId,i=e.addonId===g.addonId,a=(t.get(e.addonId)?.pendingKeys.length??0)>0;return v(`button`,{type:`button`,onClick:()=>h(e.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${i?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[r,a&&m(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},e.addonId)})}),m(`div`,{className:`space-y-2`,children:f.map(e=>m(`div`,{style:e.addonId===g.addonId?void 0:{display:`none`},children:y(e)},e.addonId))})]})}export{E as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ga as e,ha as t,ma as n}from"./src-BB1LG2-C.js";import{F as r,G as i,R as a,U as o,W as s,X as c,b as l,x as u,y as ee}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CK8iQdP1.js";import{L as d,V as te,c as f,g as p,n as ne,p as re,s as m}from"./player-overlays-ZG1nYuYj.js";import{MaskShapeCanvas as h}from"./MaskShapeCanvas-C5K6H6Th.js";var g=p(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]);c();var _=120,ie=`privacy-mask`,v=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,y=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function b(e){return e.kind===`rect`||e.kind===`polygon`?e:null}function x(e){let t=new Set(e.map(e=>e.id)),n=0;for(;t.has(n);)n+=1;return n}function S(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(JSON.stringify(e[n])!==JSON.stringify(t[n]))return!1;return!0}function C({deviceId:c}){let p=f(re().trpcClient,c),[C,w]=i(null),[T,E]=i(!1),[D,O]=i(null),[k,A]=i(null),[j,M]=i(!1),[N,P]=i(!1),[F,I]=i(null),[L,R]=i(null),z=s(!1);a(()=>{if(!p)return;let e=!1;return z.current=!1,w(null),E(!1),O(null),A(null),P(!1),I(null),R(null),(async()=>{try{let t=await p.privacyMask?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(w(t),z.current)return;let n=await p.privacyMask?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);z.current=!0;let r={enabled:n.enabled,regions:n.regions};A(r),O(r)}catch(t){if(e)return;te(t)?E(!0):console.error(`Privacy Mask load failed`,t)}})(),()=>{e=!0}},[p]);let B=o(()=>D!==null&&k!==null&&(D.enabled!==k.enabled||!S(D.regions,k.regions)),[D,k]),V=D?D.regions.length:0,H=C?C.maxRegions:0,U=s(0);a(()=>{U.current=H},[H]);let W=H>0&&V>=H,G=r(()=>{O(e=>e&&{...e,enabled:!e.enabled})},[]),K=r(e=>{I(typeof e==`number`?e:null)},[]),q=o(()=>D?D.regions.map(e=>({id:e.id,shape:e.shape,enabled:e.enabled,label:`Zone ${String(e.id)}`})):[],[D]),J=r((e,t)=>{let n=b(t);n&&O(t=>t&&{...t,regions:t.regions.map(t=>t.id===e?{...t,shape:n}:t)})},[]),Y=r(e=>{let t=b(e);t&&(R(null),O(e=>{if(!e)return e;let n=U.current;if(n>0&&e.regions.length>=n)return e;let r=x(e.regions),i={id:r,enabled:!0,shape:t};return I(r),{...e,regions:[...e.regions,i]}}))},[]),X=r(e=>{P(!0),I(null),R(e)},[]),Z=r(e=>{P(!0),R(null),I(e)},[]),ae=r(e=>{I(t=>t===e?null:t),O(t=>t&&{...t,regions:t.regions.filter(t=>t.id!==e)})},[]),oe=r(()=>{R(null),I(null),k&&O({enabled:k.enabled,regions:k.regions})},[k]),se=r(async()=>{if(!(!p||!D)){M(!0);try{await p.privacyMask?.setMask({patch:{enabled:D.enabled,regions:[...D.regions]}});let e=await p.privacyMask?.getStatus({});if(e){let t={enabled:e.enabled,regions:e.regions};A(t),O(t)}}catch(e){console.error(`Privacy Mask save failed`,e)}finally{M(!1)}}},[p,D]),ce=r(()=>{P(e=>(e&&(R(null),I(null)),!e))},[]),Q=C?.supportedShapes??[];ne(o(()=>N&&!T&&C&&D?{id:ie,order:_,node:l(h,{transparent:!0,items:q,supportedShapes:Q,polygonVertices:C.polygonVertices,selectedId:F,onSelect:K,onShapeChange:J,onDrawComplete:Y,drawingKind:L})}:null,[N,T,C,D,q,Q,F,K,J,Y,L]));let le=C?.supportedShapes.includes(`rect`)??!1,ue=C?.supportedShapes.includes(`polygon`)??!1,$=C!==null&&(C.maxRegions<=0||C.supportedShapes.length===0);return p?l(m,{title:`Privacy Mask`,icon:l(e,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:l(`div`,{className:`flex flex-col gap-3`,children:T||$?l(`p`,{className:`${d} leading-relaxed`,children:`This camera doesn't support an on-board privacy mask.`}):!T&&!$&&C!==null&&D!==null?u(ee,{children:[u(`p`,{className:`${d} leading-relaxed`,children:[`Toggle `,l(`strong`,{className:`text-foreground`,children:`Edit mask`}),` to draw blanked-out zones on the live frame, then `,l(`strong`,{className:`text-foreground`,children:`Save`}),` to push them to the camera. Drag a rectangle to move, its corner to resize; drag polygon vertices, click an edge midpoint to add one, or right-click a vertex to remove it.`]}),u(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[l(`button`,{type:`button`,onClick:ce,disabled:j,"aria-pressed":N,className:N?y:v,children:N?`Done editing`:`Edit mask`}),l(`button`,{type:`button`,onClick:G,disabled:j,"aria-pressed":D.enabled,className:D.enabled?y:v,children:D.enabled?`Mask on`:`Mask off`}),le&&l(`button`,{type:`button`,onClick:()=>X(`rect`),disabled:j||W,"aria-pressed":L===`rect`,className:L===`rect`?y:v,title:W?`Maximum zones reached`:`Add a rectangle zone`,children:`+ Rect`}),ue&&l(`button`,{type:`button`,onClick:()=>X(`polygon`),disabled:j||W,"aria-pressed":L===`polygon`,className:L===`polygon`?y:v,title:W?`Maximum zones reached`:`Add a polygon zone`,children:`+ Polygon`}),u(`span`,{className:`${d} ml-1 tabular-nums`,children:[V,` / `,H,` zones`]}),l(`span`,{className:`flex-1`}),l(`button`,{type:`button`,onClick:oe,disabled:j||!B,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:`Revert`}),l(`button`,{type:`button`,onClick:()=>void se(),disabled:j||!B,className:y,children:j?`Saving…`:`Save`})]}),V>0?l(`div`,{className:`flex flex-col gap-1`,children:D.regions.map(e=>{let r=F===e.id,i=e.shape.kind===`polygon`?g:t;return u(`div`,{className:`flex items-center gap-2 rounded-md border px-2 py-1 transition-colors ${r?`border-primary/50 bg-primary/10`:`border-border bg-surface`}`,children:[u(`button`,{type:`button`,onClick:()=>Z(e.id),disabled:j,className:`flex flex-1 items-center gap-2 text-left text-[11px] font-medium text-foreground-subtle hover:text-foreground disabled:opacity-40 transition-colors`,children:[l(i,{className:`h-3.5 w-3.5 shrink-0`}),u(`span`,{children:[`Zone `,e.id]}),l(`span`,{className:`text-foreground-faint capitalize`,children:e.shape.kind})]}),l(`button`,{type:`button`,onClick:()=>ae(e.id),disabled:j,"aria-label":`Delete zone ${String(e.id)}`,title:`Delete zone`,className:`inline-flex h-6 w-6 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:border-red-400/40 hover:bg-red-500/10 hover:text-red-400 disabled:opacity-40 transition-colors`,children:l(n,{className:`h-3.5 w-3.5`})})]},e.id)})}):null]}):l(`p`,{className:`${d} leading-relaxed`,children:`Loading the camera's privacy mask…`})})}):null}export{C as PrivacyMaskSettings};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as e,G as t,R as n,U as r,W as i,X as a,b as o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CK8iQdP1.js";a();function c(e,t){for(let n of e)for(let e of n.fields){if(!(`key`in e)||e.key!==t)continue;if(e.type===`button`||e.type===`separator`||e.type===`info`)return!0;let r=e.immediate;return r===!0?!0:r===!1?!1:n.immediate===!0}return!1}function l({schema:a,serverValues:o,onImmediateSave:s,onDeferredSave:l}){let[u,d]=t({}),[f,p]=t(!1),m=i(null),h=a?.sections??[],g=Object.keys(u).length>0,_=r(()=>({...o,...u}),[o,u]);n(()=>{if(g){p(!0);return}m.current&&clearTimeout(m.current),m.current=setTimeout(()=>p(!1),500)},[g]);let v=e(()=>{p(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>p(!1),2e3)},[]),y=e(e=>{v();let t={},n={},r={...o,...u};for(let[i,a]of Object.entries(e))r[i]!==a&&(c(h,i)?t[i]=a:n[i]=a);Object.keys(t).length>0&&s(t),d(e=>{let r={...e};for(let e of Object.keys(t))delete r[e];for(let[e,t]of Object.entries(n))r[e]=t;return r})},[v,o,u,h,s]),b=e(e=>{let t={},n={};for(let[r,i]of Object.entries(u))e.includes(r)?t[r]=i:n[r]=i;d(n),Object.keys(t).length>0&&l(t)},[u,l]),x=e(e=>{d(t=>{let n={...t};for(let t of e)delete n[t];return n})},[]),S=e(()=>{d({})},[]);return{values:_,pendingKeys:Object.keys(u),hasPendingEdits:g,editingPaused:f,handleChange:y,handleSave:b,handleDiscard:x,resetAll:S}}function u({pendingCount:e,onSave:t,onDiscard:n,saving:r=!1,saveLabel:i=`Save`,discardLabel:a=`Discard`}){return e<=0?null:s(`div`,{className:`sticky bottom-0 -mb-3 flex items-center justify-between gap-3 rounded-lg border border-primary/40 bg-primary/5 px-3 py-2 shadow-sm z-10`,children:[s(`span`,{className:`text-xs text-foreground`,children:[e,` unsaved change`,e===1?``:`s`]}),s(`div`,{className:`flex items-center gap-2`,children:[o(`button`,{type:`button`,onClick:n,disabled:r,className:`inline-flex items-center rounded-md border border-border px-2.5 py-1 text-xs text-foreground-subtle hover:bg-surface-hover disabled:opacity-50`,children:a}),o(`button`,{type:`button`,onClick:t,disabled:r,className:`inline-flex items-center rounded-md bg-primary px-3 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:r?`Saving…`:i})]})]})}function d({tabs:e,activeId:t,onChange:n,countByTab:r,pendingByTab:i}){return e.length===0?null:o(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:e.map(e=>{let a=e.id===t,c=r?.get(e.id)??0,l=i?.get(e.id)??0;return s(`button`,{type:`button`,onClick:()=>n(e.id),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[e.label,c>0&&s(`span`,{className:`ml-1.5 text-[10px] opacity-60`,children:[`(`,c,`)`]}),l>0&&o(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-primary`})]},e.id)})})}export{u as n,l as r,d as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{gr as e}from"./src-BB1LG2-C.js";import{b as t,x as n}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CK8iQdP1.js";import{f as r}from"./index-D5OTguVm.js";import{t as i}from"./AdminPage-CN6ZMhf0.js";import{t as a}from"./NodeAddonsSettingsPanel-BU3fsQhW.js";function o(){let{data:o,isLoading:s}=e(void 0),c=(o??[]).find(e=>e.isHub&&e.isOnline),l=c?.addons.map(e=>e.id)??[];return t(i,{children:s?t(`div`,{className:`text-muted-foreground text-sm py-12 text-center`,children:`Loading hub topology…`}):c?l.length===0?t(`div`,{className:`text-muted-foreground text-sm py-12 text-center`,children:`No addons installed on the hub yet.`}):t(a,{nodeId:c.id,addonIds:l,level:`global`}):n(`div`,{className:`flex flex-col items-center justify-center text-muted-foreground text-sm gap-2 py-12`,children:[t(r,{className:`h-8 w-8 opacity-30`}),t(`p`,{children:`No online hub node found.`}),t(`p`,{className:`text-xs`,children:`Settings will appear once the hub is reachable.`})]})})}export{o as SettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{G as e,X as t,b as n,x as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CK8iQdP1.js";import{t as i}from"./CapabilityBadges-CqlDFU27.js";import{t as a}from"./ProviderIcon-BS00rCO4.js";import{t as o}from"./StatusBadge-CkYubfRG.js";import{t as s}from"./FormBuilder-DBTf1H_B.js";t();function c({title:e,children:t}){return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`border-b border-border px-4 py-2.5`,children:n(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:e})}),n(`div`,{className:`p-4`,children:t})]})}function l({name:e,cssVar:t,hex:i}){return r(`div`,{className:`flex flex-col items-center gap-1.5`,children:[n(`div`,{className:`h-10 w-10 rounded-lg border border-border shadow-inner`,style:{backgroundColor:t?`var(${t})`:i}}),n(`span`,{className:`text-[10px] text-foreground-subtle text-center leading-tight`,children:e})]})}var u={sections:[{id:`demo`,title:`Demo Fields`,columns:2,fields:[{key:`name`,type:`text`,label:`Name`,placeholder:`Enter name`},{key:`count`,type:`number`,label:`Count`,min:0,max:100,unit:`items`},{key:`enabled`,type:`boolean`,label:`Enabled`},{key:`mode`,type:`select`,label:`Mode`,options:[{value:`a`,label:`Alpha`},{value:`b`,label:`Beta`}]},{key:`tags`,type:`tags`,label:`Tags`,span:2,suggestions:[`camera`,`zone`,`alert`]},{key:`confidence`,type:`slider`,label:`Confidence`,min:0,max:100,step:5,unit:`%`,span:2},{key:`info`,type:`info`,label:`Note`,content:`This is an informational message for the user.`,variant:`info`}]}]};function d(){let[t,d]=e({name:`Example`,count:10,enabled:!0,mode:`a`,tags:[`camera`],confidence:60});return r(`div`,{className:`p-6 space-y-6 max-w-5xl mx-auto`,children:[r(`div`,{className:`mb-6`,children:[n(`h1`,{className:`text-xl font-bold text-foreground`,children:`Component Showroom`}),n(`p`,{className:`text-sm text-foreground-subtle mt-1`,children:`All UI components at a glance`})]}),n(c,{title:`Typography`,children:r(`div`,{className:`space-y-3`,children:[n(`h1`,{className:`text-2xl font-bold text-foreground`,children:`Heading 1 — Display title`}),n(`h2`,{className:`text-xl font-semibold text-foreground`,children:`Heading 2 — Section title`}),n(`h3`,{className:`text-base font-semibold text-foreground`,children:`Heading 3 — Card title`}),n(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Heading 4 — Sub-section`}),n(`p`,{className:`text-sm text-foreground`,children:`Body text — Regular paragraph content goes here. It uses the foreground color.`}),n(`p`,{className:`text-sm text-foreground-subtle`,children:`Subtle text — Secondary/descriptive text with reduced emphasis.`}),n(`p`,{className:`text-xs text-foreground-subtle uppercase tracking-wider font-semibold`,children:`Label / Caption`}),n(`p`,{className:`text-xs text-foreground-disabled`,children:`Disabled / placeholder text`})]})}),n(c,{title:`Colors`,children:r(`div`,{className:`flex flex-wrap gap-4`,children:[n(l,{name:`primary`,cssVar:`--color-primary`}),n(l,{name:`background`,cssVar:`--color-background`}),n(l,{name:`surface`,cssVar:`--color-surface`}),n(l,{name:`foreground`,cssVar:`--color-foreground`}),n(l,{name:`success`,cssVar:`--color-success`}),n(l,{name:`warning`,cssVar:`--color-warning`}),n(l,{name:`danger`,cssVar:`--color-danger`}),n(l,{name:`info`,cssVar:`--color-info`}),n(l,{name:`border`,cssVar:`--color-border`}),n(`div`,{className:`w-px`}),n(l,{name:`frigate`,hex:`#3b82f6`}),n(l,{name:`scrypted`,hex:`#a855f7`}),n(l,{name:`reolink`,hex:`#06b6d4`}),n(l,{name:`ha`,hex:`#22d3ee`}),n(l,{name:`rtsp`,hex:`#78716c`})]})}),n(c,{title:`Buttons`,children:r(`div`,{className:`flex flex-wrap gap-3`,children:[n(`button`,{className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity`,children:`Primary`}),n(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-4 py-2 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors`,children:`Secondary`}),n(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-danger/40 bg-danger/10 px-4 py-2 text-sm font-medium text-danger hover:bg-danger/20 transition-colors`,children:`Danger`}),n(`button`,{disabled:!0,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white opacity-40 cursor-not-allowed`,children:`Disabled`}),n(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-4 py-2 text-sm font-medium text-warning hover:bg-warning/20 transition-colors`,children:`Warning`}),n(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-success/40 bg-success/10 px-4 py-2 text-sm font-medium text-success hover:bg-success/20 transition-colors`,children:`Success`})]})}),n(c,{title:`Inputs`,children:r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[r(`div`,{children:[n(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Text input`}),n(`input`,{type:`text`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`Type something...`})]}),r(`div`,{children:[n(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Number input`}),n(`input`,{type:`number`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`0`})]}),r(`div`,{children:[n(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Password input`}),n(`input`,{type:`password`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`••••••••`})]}),r(`div`,{children:[n(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Select`}),r(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,children:[n(`option`,{children:`Option A`}),n(`option`,{children:`Option B`}),n(`option`,{children:`Option C`})]})]}),r(`div`,{className:`md:col-span-2`,children:[n(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Textarea`}),n(`textarea`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 resize-y min-h-[60px]`,placeholder:`Enter multi-line text...`,rows:3})]}),n(`div`,{children:r(`label`,{className:`flex items-center gap-2 cursor-pointer select-none`,children:[n(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 rounded border-border accent-primary`,defaultChecked:!0}),n(`span`,{className:`text-xs font-medium text-foreground`,children:`Checkbox (checked)`})]})}),n(`div`,{children:r(`div`,{className:`flex items-center justify-between`,children:[n(`span`,{className:`text-xs font-medium text-foreground`,children:`Toggle switch`}),n(f,{})]})}),r(`div`,{children:[n(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Slider`}),n(`input`,{type:`range`,className:`w-full h-1 accent-primary cursor-pointer`,min:0,max:100,defaultValue:60})]}),r(`div`,{children:[n(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Tags example`}),n(`div`,{className:`flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px]`,children:[`camera`,`zone`,`alert`].map(e=>n(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary`,children:e},e))})]})]})}),n(c,{title:`Badges`,children:r(`div`,{className:`space-y-3`,children:[r(`div`,{children:[n(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`StatusBadge`}),n(`div`,{className:`flex flex-wrap gap-2`,children:[`running`,`stopped`,`error`,`online`,`offline`,`idle`].map(e=>n(o,{status:e},e))})]}),r(`div`,{children:[n(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`CapabilityBadges`}),n(i,{capabilities:[`streaming`,`detection`,`recording`,`audio`]})]})]})}),n(c,{title:`Cards`,children:r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[r(`div`,{className:`rounded-lg bg-surface p-4`,children:[n(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Surface card`}),n(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-surface`. Default card background."})]}),r(`div`,{className:`rounded-lg border border-border bg-surface p-4`,children:[n(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Bordered card`}),n(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `border border-border bg-surface`."})]}),r(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 p-4`,children:[n(`h3`,{className:`text-sm font-semibold text-primary mb-1`,children:`Accent card`}),n(`p`,{className:`text-xs text-foreground-subtle`,children:`Highlighted with primary color.`})]}),r(`div`,{className:`rounded-lg bg-background p-4`,children:[n(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Background card`}),n(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-background`. Inset card."})]})]})}),n(c,{title:`Provider Icons`,children:n(`div`,{className:`flex flex-wrap gap-4`,children:[`frigate`,`scrypted`,`reolink`,`homeassistant`,`rtsp`,`onvif`].map(e=>n(a,{type:e,size:`lg`,showLabel:!0},e))})}),r(c,{title:`Form Builder Demo`,children:[n(s,{schema:u,values:t,onChange:d}),r(`details`,{className:`mt-3`,children:[n(`summary`,{className:`text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground`,children:`View current values`}),n(`pre`,{className:`mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto`,children:JSON.stringify(t,null,2)})]})]}),n(c,{title:`Info Boxes`,children:n(`div`,{className:`space-y-2`,children:[{variant:`info`,label:`Info`,content:`This is an informational message. Use it for tips and hints.`},{variant:`warning`,label:`Warning`,content:`This action may have side effects. Proceed with caution.`},{variant:`success`,label:`Success`,content:`Operation completed successfully. All systems are green.`},{variant:`danger`,label:`Danger`,content:`This operation is irreversible. Data will be permanently deleted.`}].map(({variant:e,label:t,content:i})=>{let a={info:{border:`border-info`,bg:`bg-info/5`,text:`text-info`},warning:{border:`border-warning`,bg:`bg-warning/5`,text:`text-warning`},success:{border:`border-success`,bg:`bg-success/5`,text:`text-success`},danger:{border:`border-danger`,bg:`bg-danger/5`,text:`text-danger`}}[e];return r(`div`,{className:`rounded-md border-l-4 px-3 py-2.5 ${a.border} ${a.bg}`,children:[n(`p`,{className:`text-xs font-semibold mb-0.5 ${a.text}`,children:t}),n(`p`,{className:`text-xs text-foreground-subtle leading-relaxed`,children:i})]},e)})})})]})}function f(){let[t,r]=e(!0);return n(`button`,{type:`button`,role:`switch`,"aria-checked":t,onClick:()=>r(e=>!e),className:[`relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150 cursor-pointer`,t?`bg-primary`:`bg-foreground-subtle/30`].join(` `),children:n(`span`,{className:[`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150`,t?`translate-x-4`:`translate-x-0.5`].join(` `)})})}export{d as ShowroomPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e}from"./index-D5OTguVm.js";var t=e(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]);export{t};
|