@camstack/addon-admin-ui 1.2.528 → 1.2.529
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/assets/{Addons-jOEeQSpu.js → Addons-CZ_5JUVc.js} +1 -1
- package/dist/assets/{AdminSectionedPage-DuWHEheV.js → AdminSectionedPage-B_tSbkIV.js} +1 -1
- package/dist/assets/{AiProfiles-BEeNwF2L.js → AiProfiles-W2ByefcY.js} +1 -1
- package/dist/assets/{Build-Co5ZdxuK.js → Build-BesaIcQt.js} +1 -1
- package/dist/assets/{Calendars-BtDHWxd-.js → Calendars-PHb_rEbJ.js} +1 -1
- package/dist/assets/{Cluster-BIBo49N1.js → Cluster-CnMcgkaB.js} +1 -1
- package/dist/assets/{ComposedDeviceEditDialog-B4GFluaT.js → ComposedDeviceEditDialog-DlxMQhZP.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-BpvjitmC.js → CompositionBlockEditor-Ctx6d-qx.js} +1 -1
- package/dist/assets/{CompositionEditorPage-dKqEx-JR.js → CompositionEditorPage-CVp1OM-C.js} +1 -1
- package/dist/assets/{Data-RjeL53U1.js → Data-OpXlBhEa.js} +1 -1
- package/dist/assets/{DeviceDetail-eIrghHfV.js → DeviceDetail-CUzPIb4E.js} +1 -1
- package/dist/assets/{DeviceDoActionFields-NGMXRetO.js → DeviceDoActionFields-D1rhgn3I.js} +1 -1
- package/dist/assets/{Devices-BGUXCPk6.js → Devices-DFfVPHVt.js} +1 -1
- package/dist/assets/{FormBuilder-C-ti9Mun.js → FormBuilder-BvQZWKCS.js} +1 -1
- package/dist/assets/{History-DFE__TwY.js → History-BLJJzgUt.js} +1 -1
- package/dist/assets/{Identity-xGpm6dM2.js → Identity-B_TiHuO-.js} +1 -1
- package/dist/assets/IntegrationDetail-DtTxTigM.js +1 -0
- package/dist/assets/{IntegrationHub-zoj_qUVu.js → IntegrationHub-BvDB6bjh.js} +1 -1
- package/dist/assets/{Integrations-BgOMB--y.js → Integrations-CK3qys8g.js} +1 -1
- package/dist/assets/{Integrations-Dnahdxh6.js → Integrations-Xub2OY5T.js} +1 -1
- package/dist/assets/{Library-Dta_WXbr.js → Library-CO10lVu2.js} +1 -1
- package/dist/assets/{Locations-qtdnIjEQ.js → Locations-CaL7Y2a3.js} +1 -1
- package/dist/assets/{Logs-DY8msvrb.js → Logs-Bu40SOPP.js} +1 -1
- package/dist/assets/{MyAccess-ayWZOTHE.js → MyAccess-CNQzuYsW.js} +1 -1
- package/dist/assets/{Network-DDRo1U4A.js → Network-BBm6sZIX.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-Bin3whKR.js → NodeAddonsSettingsPanel-DZwxKBXw.js} +1 -1
- package/dist/assets/{Notifications-DxWf70ir.js → Notifications-BS4cbFH2.js} +1 -1
- package/dist/assets/{Pipeline-B1zEi2hO.js → Pipeline-BhNYn1U-.js} +1 -1
- package/dist/assets/{Recordings-BQZ9OaK2.js → Recordings-B8VQL_Ik.js} +1 -1
- package/dist/assets/{ScanNetworkModal-DNtPeZ2B.js → ScanNetworkModal-SyHjZF2T.js} +1 -1
- package/dist/assets/{SessionsList-DqDv9LKK.js → SessionsList-BD87Vhfu.js} +1 -1
- package/dist/assets/{Showroom-D8Shgmh7.js → Showroom-BS88iBLb.js} +1 -1
- package/dist/assets/{System-Cl5e6KJW.js → System-D-Xj3jc0.js} +1 -1
- package/dist/assets/{Terminal-BBAoUjfs.js → Terminal-DhbVA89N.js} +5 -5
- package/dist/assets/{Trans-DvLMqjNd.js → Trans-Bsz5Pghy.js} +1 -1
- package/dist/assets/{assignment-candidates-YAud75JK.js → assignment-candidates-DWivr3bV.js} +1 -1
- package/dist/assets/{board-model-BgDnb_No.js → board-model-CCD7fB3T.js} +1 -1
- package/dist/assets/{device-integration-icon-Dxf6i9YB.js → device-integration-icon-D-OosuOg.js} +1 -1
- package/dist/assets/{format-D6gOZRRr.js → format-ChSVChsY.js} +1 -1
- package/dist/assets/i18n-Bg2ooh3q.js +1 -0
- package/dist/assets/index-CyqhCHax.css +2 -0
- package/dist/assets/{index-CoVcMsxX.js → index-DMMw81r0.js} +3 -3
- package/dist/assets/{linked-devices-model-CPj1sFzr.js → linked-devices-model-D9m6pafu.js} +1 -1
- package/dist/assets/{location-owned-usage-BhWswowa.js → location-owned-usage-DasgH3RR.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-bba9c01e.js → mf-entry-bootstrap-0-dd19d57d.js} +1 -1
- package/dist/assets/{notification-schedule-field-XRy8SQoM.js → notification-schedule-field-B7FdiF_t.js} +1 -1
- package/dist/assets/{sso-popup-BYo1cU_K.js → sso-popup-BjTl8T6g.js} +1 -1
- package/dist/assets/{step-inspector-model-DG2Cy9_m.js → step-inspector-model-DINPtCNq.js} +1 -1
- package/dist/assets/{useNodeUrlSelection-Pafi-8p7.js → useNodeUrlSelection-A-NDcCsx.js} +1 -1
- package/dist/index.html +8 -8
- package/dist/server/addon.js +1 -1
- package/package.json +1 -1
- package/dist/assets/IntegrationDetail-BV550NaL.js +0 -1
- package/dist/assets/i18n-C02pTNTJ.js +0 -1
- package/dist/assets/index-BrupW6X6.css +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./i18n-
|
|
1
|
+
import{t as e}from"./i18n-Bg2ooh3q.js";import{t}from"./assignment-candidates-DWivr3bV.js";function n(e){return e.slot===`linked-devices`}function r(t){if(t.status===`error`)return{kind:`unknown`,reason:t.error?.message??e.t(`helpers.customize.requestFailed`)};if(t.status===`pending`||t.data===void 0)return{kind:`pending`};for(let e of t.data)if(e.state===`ok`&&e.slot===`linked-devices`&&n(e.value))return{kind:`present`,slot:e,value:e.value};let r=t.data.find(e=>e.state===`unreachable`);return r!==void 0&&r.state===`unreachable`?{kind:`unknown`,reason:r.reason}:{kind:`absent`}}function i(e,t){let n=t.trackedDeviceIds??[],r=e=>t=>({deviceId:t.deviceId,name:t.name,health:t.health,implied:e,tracked:n.includes(t.deviceId)});return[...e.sources.map(r(!1)),...(e.impliedSources??[]).map(r(!0))]}function a(e,t){let n=new Set([...e.sources,...e.impliedSources??[]].map(e=>e.deviceId));return(t.trackedDeviceIds??[]).filter(e=>!n.has(e))}function o(e,t){return{...e,deviceIds:[...e.deviceIds,...t.filter(t=>!e.deviceIds.includes(t))]}}function s(e,t){return{...e,deviceIds:e.deviceIds.filter(e=>e!==t),...e.trackedDeviceIds===void 0?{}:{trackedDeviceIds:e.trackedDeviceIds.filter(e=>e!==t)}}}function c(e,t,n){let r=e.trackedDeviceIds??[],i=n?[...r.filter(e=>e!==t),t]:r.filter(e=>e!==t);return{...e,trackedDeviceIds:i}}function l(e,n,r){return e.flatMap(e=>{let i=n.get(e.deviceId);return r.has(e.deviceId)||i===void 0?[]:[{deviceId:e.deviceId,ref:{addonId:i.addonId,stableId:i.stableId},name:e.parentName===null?e.name:`${e.parentName} · ${e.name}`,detail:t(i.integration,e.location),meta:e.type,caps:[],value:null}]})}export{o as a,a as i,i as n,c as o,r,s,l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as c,Di as l,Hn as u,Ht as d,In as f,Jr as p,Kr as m,Nn as h,dt as g,gt as _,ki as v,kr as y,pr as b,st as x}from"./player-overlays-DpZIxQHp.js";import{xo as S}from"./client-BvflqtP1.js";import{t as C}from"./archive-Bu9T4BL0.js";import{t as w}from"./hard-drive-download-Cd122TYb.js";import{Bu as ee,Ct as te,Dn as T,Er as ne,Fi as E,Ou as re,Sr as ie,Tr as ae,br as oe,ii as D,wr as O,xr as se}from"./src-KDhMZ5Ob.js";import{t as k}from"./i18n-C02pTNTJ.js";import{t as A}from"./Trans-DvLMqjNd.js";import{t as j}from"./useTranslation-BJr-n0es.js";import{t as ce}from"./FormBuilder-C-ti9Mun.js";import{t as M}from"./format-size-DIxKXxtj.js";o();function N(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function P(e,t){let n=N(t);return`${e}:${n.length>0?n:`default`}`}var F=new Set([`proc`,`sys`,`dev`,`run`,`boot`,`lost+found`,`snap`,`bin`,`sbin`,`lib`,`lib32`,`lib64`,`libx32`,`usr`,`etc`,`var`,`opt`,`tmp`,`srv`,`root`,`System`,`Library`,`Applications`,`cores`,`private`]),I=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function L(e){let t=I.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?I.length:t}function le(e){return e.filter(e=>!e.name.startsWith(`.`)&&!F.has(e.name)).toSorted((e,t)=>{let n=L(e.name)-L(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function ue({nodeId:t,value:o,onChange:s}){let{t:c}=j(),l=g().trpcClient,[u,d]=a([]),[f,p]=a(o),[m,h]=a(null),[_,v]=a(null),[y,b]=a(``),x=n(async(e,n)=>{v(null);try{let r=await l.filesystemBrowse.browse.query({nodeId:t,path:e});h(r),p(r.path),n&&s(r.path)}catch(e){v(e instanceof Error?e.message:`browse failed`)}},[l,t,s]);i(()=>{p(o),(async()=>{let e=await l.filesystemBrowse.browse.query({nodeId:t,path:`/`}).then(e=>e).catch(()=>null);if(e){d(le(e.entries)),await x(o.startsWith(`/`)?o:`/`,!1);return}try{let e=await l.filesystemBrowse.listAllowedRoots.query({nodeId:t});d(e),await x(o&&e.some(e=>o.startsWith(e))?o:e[0]??``,!1)}catch(e){d([]),h(null),v(e instanceof Error&&/not available on node/i.test(e.message)?`This node can't be browsed remotely. Enter the path manually.`:e instanceof Error?e.message:`browse unavailable`)}})()},[t]);let S=async()=>{if(!(!y.trim()||!m)){v(null);try{let e=`${m.path.replace(/\/+$/,``)}/${y.trim()}`;await l.filesystemBrowse.createDir.mutate({nodeId:t,path:e}),b(``),await x(m.path,!0)}catch(e){v(e instanceof Error?e.message:`create failed`)}}},C=e=>`${(e/1e9).toFixed(1)} GB`;return e(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[r(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>r(`button`,{onClick:()=>void x(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),r(`input`,{value:f,onChange:e=>{p(e.target.value),s(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),m&&r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.pathBrowser.free`,{free:C(m.freeBytes),total:C(m.totalBytes)})}),r(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:m?.entries.map(t=>e(`button`,{onClick:()=>void x(t.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,t.name]},t.path))}),e(`div`,{className:`flex gap-1`,children:[r(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:c(`storage.pathBrowser.newFolder`,`new folder`),className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),r(`button`,{onClick:()=>void S(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:c(`storage.pathBrowser.create`,`Create`)})]}),_&&r(`div`,{className:`text-[10px] text-red-400`,children:_})]})}o();function R({initialType:n,onClose:i,onCreated:o}){let{t:c}=j(),u=s(),d=g().trpcClient,[f,p]=a(`picker`),[m,h]=a(n),[_,v]=a(null),[y,x]=a({}),[S,C]=a(``),[w,T]=a(null),[E,D]=a(!1),[O,k]=a(`hub`),[M,N]=a(null),[F,I]=a(!1),L=e=>x(t=>({...t,basePath:e})),le=typeof y.basePath==`string`?y.basePath:``,R=re(),z=t(()=>{let e=R.data;return Array.isArray(e)?e:[]},[R.data]),B=R.isLoading,V=ee({onSuccess:()=>{u.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),H=t(()=>w!==null&&w.length>0?w:P(m,S),[m,S,w]),de=async()=>{if(_){I(!0),N(null);try{N(await(e=>d.storage.testConfig.query(e))({providerId:_.providerId,config:y}))}catch(e){N({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{I(!1)}}};return r(oe,{open:!0,onOpenChange:e=>!e&&i(),children:e(ie,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(ae,{children:[r(ne,{children:{picker:`Add Location — Pick provider`,config:`Add Location — ${_?.displayName??``}`,naming:`Add Location — Name`}[f]}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[c(`storage.addLocationWizard.type`,`Type:`),` `,r(`span`,{className:`font-mono`,children:m})]})]}),e(se,{children:[f===`picker`&&e(`div`,{className:`space-y-2`,children:[B&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:c(`storage.addLocationWizard.loadingProviders`,`Loading providers…`)}),!B&&z.length===0&&r(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:r(A,{i18nKey:`storage.addLocationWizard.noProvider`,values:{type:m},components:{code:r(`code`,{className:`font-mono`})}})}),z.map(t=>e(`button`,{onClick:()=>{v(t),p(`config`)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors`,children:[e(`div`,{className:`flex-1 min-w-0`,children:[r(`p`,{className:`text-xs font-semibold text-foreground`,children:t.displayName}),r(`p`,{className:`text-[10px] text-foreground-subtle font-mono mt-0.5 truncate`,children:t.providerId})]}),r(l,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},t.providerId))]}),f===`config`&&_&&e(`div`,{className:`space-y-3`,children:[r(ce,{schema:_.configSchema,values:y,onChange:x}),_.nodeLocal&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.node`,`Node`)}),r(te,{selectedNodeId:O,onSelect:k,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.path`,`Path`)}),r(ue,{nodeId:O,value:le,onChange:L})]}),M&&r(`div`,{className:`rounded border px-3 py-2 text-[11px] ${M.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:M.ok?c(`storage.addLocationWizard.connectionOk`,`Connection OK.`):c(`storage.addLocationWizard.testFailed`,`Test failed: {{value1}}`,{value1:M.error??`unknown error`})}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>p(`picker`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{de()},disabled:F,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:F?c(`storage.addLocationWizard.testing`,`Testing…`):c(`storage.addLocationWizard.testConnection`,`Test connection`)}),r(`button`,{onClick:()=>p(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:c(`common.next`,`Next`)})]})]})]}),f===`naming`&&_&&e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.displayName`,`Display name`)}),r(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:c(`storage.addLocationWizard.on`,`{{type}} on {{displayName}}`,{type:m,displayName:_.displayName}),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`})]}),e(`div`,{className:`space-y-1`,children:[e(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:[c(`storage.addLocationWizard.idLabel`),` `,r(`span`,{className:`lowercase tracking-normal text-foreground-subtle`,children:c(`storage.addLocationWizard.autoDerivedOverrideIfNeeded`,`— auto-derived; override if needed`)})]}),r(`input`,{type:`text`,value:H,onChange:e=>T(e.target.value),placeholder:P(m,S),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-1 focus:ring-primary`}),e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[c(`storage.addLocationWizard.format`,`Format:`),` `,r(`code`,{className:`font-mono`,children:c(`storage.addLocationWizard.typeSlug`,`<type>:<slug>`)}),`. Lowercase letters, digits, and hyphens only.`]})]}),e(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[r(`input`,{type:`checkbox`,checked:E,onChange:e=>D(e.target.checked),className:`accent-primary mt-0.5`}),e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`text-xs font-medium text-foreground`,children:c(`storage.addLocationWizard.enableImmediately`,`Enable immediately`)}),r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.addLocationWizard.aDisabledLocationReceivesNo`,`A disabled location receives no writes until enabled — reads and age-based retention still work, nothing new lands here. Leave this off to register the disk now and start using it later.`)})]})]}),V.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:V.error instanceof Error?V.error.message:String(V.error)}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>p(`config`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{h(n),v(null),x({}),C(``),T(null),D(!1),N(null),p(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.reset`,`Reset`)}),e(`button`,{onClick:()=>{_&&V.mutate({id:H,type:m,displayName:S.trim(),providerId:_.providerId,config:y,enabled:E,nodeId:_.nodeLocal?O:void 0})},disabled:V.isPending||S.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[V.isPending?r(b,{className:`h-3.5 w-3.5 animate-spin`}):null,V.isPending?c(`storage.addLocationWizard.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})]})]})})}function z(e){return S(e)}function B(e){return e===`active`}var V=[{mode:`active`,get label(){return k.t(`helpers.locationMode.activeLabel`)},get consequence(){return k.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return k.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return k.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return k.t(`helpers.locationMode.drainLabel`)},get consequence(){return k.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return k.t(`helpers.locationMode.disabledLabel`)},get consequence(){return k.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function H(e){return V.find(t=>t.mode===e)??V[0]}function de(e){return H(e).requiresConfirmation}var fe=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function U(e,t,n){return B(n)||!B(z(e))||t.some(t=>t.id!==e.id&&B(z(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:fe}}function pe(e,t){return{active:U(e,t,`active`).reason,readonly:U(e,t,`readonly`).reason,drain:U(e,t,`drain`).reason,disabled:U(e,t,`disabled`).reason}}function me(e,t,n){return!(n===`single`||t.length<=1||B(z(e))&&t.filter(e=>B(z(e))).length<=1)}function he(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function ge(e,t){let n={...t.config??e.config};t.mode!==void 0&&(he(t.mode).readOnly?n.readOnly=!0:delete n.readOnly);let r={id:e.id,type:e.type,displayName:t.displayName??e.displayName,providerId:e.providerId,config:n,isSystem:e.isSystem},i=t.nodeId??e.nodeId,a=i===void 0?r:{...r,nodeId:i};return t.mode===void 0?e.enabled===void 0?a:{...a,enabled:e.enabled}:{...a,mode:t.mode,enabled:he(t.mode).enabled}}var _e=1024**3;function W(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function ve(e){let t=W(e.minFreeGb);if(t!==null)return{unit:`gb`,value:t};let n=W(e.minFreePercent);return n===null?{unit:`percent`,value:null}:{unit:`percent`,value:n}}function ye(e,t){return W(e[t===`gb`?`minFreeGb`:`minFreePercent`])}function be(e,t){let n={...e};return delete n.minFreePercent,delete n.minFreeGb,t.value===null?n:t.unit===`gb`?{...n,minFreeGb:t.value}:{...n,minFreePercent:t.value}}function xe(e,t){let n=e.trim();if(n===``)return null;let r=Number(n);return Number.isFinite(r)?t===`percent`?Math.min(100,Math.max(0,r)):Math.max(0,r):null}function Se(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*_e;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function Ce(e){return e===`gb`?k.t(`helpers.locationProtection.unitGb`):k.t(`helpers.locationProtection.unitPercent`)}function we(e,t=10){let n=e.value===null?k.t(`helpers.locationProtection.targetDefault`,{percent:String(t)}):e.unit===`gb`?k.t(`helpers.locationProtection.targetGb`,{value:String(e.value)}):k.t(`helpers.locationProtection.targetPercent`,{value:String(e.value)});return k.t(`helpers.locationProtection.helpText`,{target:n,percent:String(t)})}function Te(e){return W(e.maxUsedGb)}function Ee(e,t){let n=W(e.maxUsedGb);return n===null||n<0?null:{bytes:n*_e,reason:t===`drain`?`drain`:`legacy`}}o();function De({config:t,defaultPercent:n=10,onChange:i}){let{t:o}=j(),[s,c]=a(()=>ve(t).unit),l=ye(t,s),u={unit:s,value:l},d=Te(t),f=e=>{c(e),i(be(t,{unit:e,value:null}))},p=e=>{i(be(t,{unit:s,value:xe(e,s)}))};return e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`storage.protectionPolicyField.protectedFreeSpace`,`Protected free space`)}),e(`div`,{className:`flex items-center gap-2`,children:[e(`select`,{"aria-label":o(`storage.protectionPolicyField.protectionUnit`,`Protection unit`),value:s,onChange:e=>{f(e.target.value===`gb`?`gb`:`percent`)},className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:[r(`option`,{value:`percent`,children:o(`storage.protectionPolicyField.ofTheVolume`,`% of the volume`)}),r(`option`,{value:`gb`,children:o(`storage.protectionPolicyField.gbOfFreeSpace`,`GB of free space`)})]}),r(`input`,{type:`number`,"aria-label":Ce(s),min:0,max:s===`percent`?100:void 0,value:l===null?``:l,placeholder:s===`percent`?String(n):o(`common.defaultWord`),onChange:e=>{p(e.target.value)},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`})]}),r(`p`,{className:`text-[10px] text-foreground-subtle`,children:we(u,n)}),d!==null&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`storage.protectionPolicyField.legacyMax`,{gb:d})})]})}o();function Oe({location:n,onClose:i,onSaved:o}){let{t:c}=j(),l=s(),u=g().trpcClient,[d,f]=a({...n.config}),[p,m]=a(n.displayName),[h,_]=a(null),[v,y]=a(!1),x=re(),S=t(()=>{let e=x.data;return Array.isArray(e)?e.find(e=>e.providerId===n.providerId)??null:null},[x.data,n.providerId]),C=ee({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),w=S?.shouldSaveDiskSpace===!0,T=S?.nodeLocal===!0,[E,k]=a(typeof n.nodeId==`string`?n.nodeId:`hub`),M=typeof d.basePath==`string`?d.basePath:``,N=e=>f(t=>({...t,basePath:e})),P=S?.minFreePercent??10,F=async()=>{y(!0),_(null);try{_(await(e=>u.storage.testConfig.query(e))({providerId:n.providerId,locationId:n.id,config:d}))}catch(e){_({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{y(!1)}};return r(oe,{open:!0,onOpenChange:e=>!e&&i(),children:e(ie,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(ae,{children:[r(ne,{children:c(`storage.editLocationModal.title`,{name:n.displayName})}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[r(`span`,{className:`font-mono`,children:n.id}),` ·`,` `,S?.displayName??n.providerId]})]}),e(se,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.displayName`,`Display name`)}),r(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),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`})]}),S&&r(ce,{schema:S.configSchema,values:d,onChange:f}),T&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.node`,`Node`)}),r(te,{selectedNodeId:E,onSelect:k,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.path`,`Path`)}),r(ue,{nodeId:E,value:M,onChange:N})]}),w&&r(De,{config:d,defaultPercent:P,onChange:f}),!S&&!x.isLoading&&r(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:r(A,{i18nKey:`storage.editLocationModal.providerGone`,values:{id:n.providerId},components:{code:r(`code`,{className:`font-mono`})}})}),h&&r(`div`,{className:`rounded border px-3 py-2 text-[11px] ${h.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:h.ok?c(`storage.editLocationModal.connectionOk`,`Connection OK.`):c(`storage.editLocationModal.testFailed`,`Test failed: {{value1}}`,{value1:h.error??`unknown error`})}),C.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:C.error instanceof Error?C.error.message:String(C.error)})]}),e(O,{className:`justify-between`,children:[r(D,{variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(D,{variant:`outline`,size:`sm`,onClick:()=>{F()},disabled:v||!S,children:v?c(`storage.editLocationModal.testing`,`Testing…`):c(`storage.editLocationModal.testConnection`,`Test connection`)}),e(D,{size:`sm`,onClick:()=>{C.mutate(ge(n,{displayName:p.trim(),config:d,nodeId:T?E:n.nodeId}))},disabled:C.isPending||p.trim().length===0,children:[C.isPending?r(b,{className:`h-3.5 w-3.5 animate-spin`}):null,C.isPending?c(`storage.editLocationModal.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})})}function ke(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Ae(e){if(!ke(e))return null;let t=e.locationId;if(typeof t!=`string`||t.length===0)return null;let n=G(e.startedAtMs),r=G(e.startBytes),i=G(e.bytesRemaining);return n===null||r===null||i===null||typeof e.drained!=`boolean`?null:{locationId:t,startedAtMs:n,startBytes:r,bytesRemaining:i,drained:e.drained,estimatedEmptyAtMs:G(e.estimatedEmptyAtMs)}}function je(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=Ae(n);e!==null&&t.set(e.locationId,e)}return t}function Me(e){if(e.startBytes<=0||e.bytesRemaining>e.startBytes)return null;let t=e.startBytes-e.bytesRemaining;return Math.min(1,Math.max(0,t/e.startBytes))}function Ne(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:Me(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function Pe(e){return e.mode===`drain`?!0:e.config.readOnly===!0}function Fe(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function Ie(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function Le({drain:t}){let{t:n}=j();if(t.kind===`idle`)return null;if(t.kind===`unreported`)return r(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:n(`storage.drainProgressLine.thisLocationIsDrainingThe`,`This location is draining. The hub has not reported how much is left yet — either the drain has just been set, or this hub predates the drain-progress report.`),children:n(`storage.drainProgressLine.drainingRemainingNotReportedYet`,`Draining · remaining not reported yet`)});if(t.kind===`drained`)return r(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:n(`storage.drainProgressLine.everythingThatWasHereHas`,`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`),children:n(`storage.drainProgressLine.drainedNothingLeftToMove`,`Drained · nothing left to move`)});let i=t.drainedFraction===null?null:Math.round(t.drainedFraction*100);return e(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[i!==null&&r(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":n(`storage.drainProgressLine.drainProgress`,`Drain progress`),"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:r(`span`,{className:`block h-full bg-warning`,style:{width:`${i}%`}})}),e(`span`,{children:[n(`storage.drainProgressLine.left`,{size:Fe(t.bytesRemaining)}),i!==null&&` · ${n(`storage.drainProgressLine.moved`,{percent:i})}`]}),t.estimatedEmptyAtMs===null?r(`span`,{"data-testid":`drain-eta-absent`,title:n(`storage.drainProgressLine.theDrainIsPacedBy`,`The drain is paced by how fast this class of data is still growing, and that has not been observed yet. There is no date to give.`),children:n(`storage.drainProgressLine.emptyTimeNotKnownYet`,`· empty time not known yet`)}):e(`span`,{"data-testid":`drain-eta`,children:[`·`,` `,n(`storage.drainProgressLine.empty`,{when:Ie(t.estimatedEmptyAtMs)})]})]})}var Re=[`ok`,`warn`,`critical`];function ze(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function Be(e){return Math.min(1,Math.max(0,e))}function K(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=Be((n-t)/n);return{fraction:r,severity:ze(r),recordingsFraction:Be(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Ve(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=K(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||Re.indexOf(e.severity)>Re.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}function q(e){return Math.min(1,Math.max(0,e))}function J(e){return Math.round(q(e)*1e3)/10}function Y(e){return`${String(Math.round(q(e)*100))}%`}function He(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:M(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?k.t(`helpers.locationCapacityBar.unknownSummary`):k.t(`helpers.locationCapacityBar.unknownSummaryOwned`,{size:e})}}let a=Math.min(Math.max(i,0),r),o=r-a,s=t===null||t<=0?0:t,c=Math.min(s,a),l=s>a,u=a-c,d=n.ownedBytes,f=d==null||!Number.isFinite(d)||d<0?null:Math.min(d,o),p=o-(f??0),m=K({usedBytes:f??o,availableBytes:a,totalBytes:r}),h=m===null?q(o/r):m.fraction,g=m===null?ze(h):m.severity,_=f===null?null:m===null?q(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:q((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:M(r),freeTotal:M(a),freeTotalPercent:Y(a/r),used:M(p),usedPercent:Y(p/r),free:M(u),freePercent:Y(u/r),reserve:s===0?null:k.t(`helpers.locationCapacityBar.reserveKept`,{size:M(s)}),owned:f===null||_===null?null:k.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:M(f),percent:Y(_)}),cap:v===null?null:v.reason===`drain`?k.t(`helpers.locationCapacityBar.capDrain`,{size:M(v.bytes)}):k.t(`helpers.locationCapacityBar.capCap`,{size:M(v.bytes)})},S=[k.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:k.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?k.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?k.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:k.t(`helpers.locationCapacityBar.legendKeptFree`),value:M(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:k.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?k.t(`helpers.locationCapacityBar.legendUsed`):k.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:k.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?k.t(`helpers.locationCapacityBar.legendDrainTarget`):k.t(`helpers.locationCapacityBar.legendCap`),value:k.t(`helpers.locationCapacityBar.legendCapValue`,{size:M(v.bytes)}),alarming:b}),{kind:`known`,severity:g,legend:C,segments:{reservePercent:J(c/r),ownedPercent:f===null?null:J(f/r),usedPercent:J(p/r),freePercent:J(u/r),capPercent:y===null?null:J(y)},labels:x,reserveExceedsFree:l,capBelowOwned:b,summary:S}}var Ue={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},X={reserve:`bg-danger/40`,owned:`bg-foreground/50`,free:`bg-border`,cap:`bg-foreground`};function We(e,t){return e===`used`?Ue[t]:X[e]}function Ge({location:t,ownedBytes:n}){let{t:i}=j(),a=t.capacity??null,o=Se(ve(t.config),a?.totalBytes??null),s=He({totalBytes:a?.totalBytes??null,availableBytes:a?.availableBytes??null},o,{ownedBytes:n??null,cap:Ee(t.config,z(t))});return s.kind===`unknown`?r(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:s.summary,children:s.owned===null?i(`storage.locationCapacityBar.capacityUnknown`,`Capacity unknown`):i(`storage.locationCapacityBar.capacityUnknownCamstackHolds`,`Capacity unknown · CamStack holds {{owned}}`,{owned:s.owned})}):e(`div`,{className:`mt-1 space-y-1`,title:s.summary,children:[e(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[s.segments.reservePercent>0&&r(`div`,{className:X.reserve,style:{width:`${String(s.segments.reservePercent)}%`}}),s.segments.ownedPercent!==null&&r(`div`,{className:X.owned,style:{width:`${String(s.segments.ownedPercent)}%`}}),r(`div`,{className:Ue[s.severity],style:{width:`${String(s.segments.usedPercent)}%`}}),r(`div`,{className:X.free,style:{width:`${String(s.segments.freePercent)}%`}}),s.segments.capPercent!==null&&r(`div`,{className:`absolute inset-y-0 w-px ${s.capBelowOwned?`bg-danger`:X.cap}`,style:{left:`${String(s.segments.capPercent)}%`}})]}),r(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:s.legend.map(t=>e(`li`,{className:`flex items-center gap-1`,children:[r(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${We(t.segment,s.severity)}`}),e(`span`,{className:`text-[10px] tabular-nums ${t.alarming?`text-danger`:`text-foreground-subtle`}`,children:[t.label,` `,t.value]})]},t.segment))})]})}var Ke={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},qe={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},Je=`storage.discardLocation`,Z=`storage.discardLocationStatus`,Ye=`storage.discardLocationCancel`;function Xe(e){return Ke[e]??null}function Ze(e){return qe[e]??null}function Qe(e){return!B(z(e))}function $e(e,t){return Xe(e.type)===null||!Qe(e)?!1:t.some(t=>t.id!==e.id&&B(z(t)))}var et=new Set([`idle`,`scanning`,`wiping-fs`,`wiping-db`,`cascading`,`complete`,`cancelled`,`error`]);function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function $(e){return typeof e==`string`?e:null}function tt(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.running!=`boolean`)return null;let n=t.phase;if(typeof n!=`string`||!et.has(n))return null;let r=Q(t.camerasTotal),i=Q(t.camerasDone),a=Q(t.foldersRemoved),o=Q(t.dbRowsDeleted),s=Q(t.ownersCascaded);return r===null||i===null||a===null||o===null||s===null?null:{running:t.running,locationId:$(t.locationId),jobId:$(t.jobId),phase:n,camerasTotal:r,camerasDone:i,foldersRemoved:a,dbRowsDeleted:o,ownersCascaded:s,detail:$(t.detail)??``,startedAtMs:Q(t.startedAtMs),finishedAtMs:Q(t.finishedAtMs),error:$(t.error)}}function nt(e){if(e.phase===`complete`)return 100;if(e.phase===`cancelled`||e.phase===`error`||e.phase===`idle`)return e.camerasTotal>0?Math.min(99,Math.round(e.camerasDone/e.camerasTotal*100)):0;if(e.camerasTotal>0){let t=e.camerasDone/e.camerasTotal*85;return e.phase===`wiping-db`?Math.min(95,Math.round(t+8)):e.phase===`cascading`?Math.min(99,Math.round(t+12)):Math.min(85,Math.round(t))}return e.phase===`scanning`?2:5}o();var rt=2e3;function it({location:e,siblings:t}){return $e(e,t)?r(at,{location:e}):null}function at({location:t}){let{t:n}=j(),o=x(),s=E(),c=Ze(t.type),[l,u]=a(null),[d,f]=a(null),[m,h]=a(!1);if(i(()=>{if(c===null)return;let e=!1,t=async()=>{try{let t=await s.mutateAsync({addonId:c,action:Z,input:{}});if(e)return;u(tt(t))}catch{}};t();let n=setInterval(()=>void t(),rt);return()=>{e=!0,clearInterval(n)}},[c,t.id]),c===null)return null;let g=l!==null&&l.locationId===t.id,v=g&&l.running,y=g&&l.phase!==`idle`,S=async()=>{if(await o({title:n(`storage.locationDiscardControl.discardLeftoversOn`,`Discard leftovers on "{{displayName}}"?`,{displayName:t.displayName}),message:n(`storage.locationDiscardControl.permanentlyDeletesLeftoverFilesAnd`,`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`),confirmLabel:n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`),variant:`danger`})){f(null),h(!0);try{await s.mutateAsync({addonId:c,action:Je,input:{locationId:t.id}}),u(tt(await s.mutateAsync({addonId:c,action:Z,input:{}})))}catch(e){f(e instanceof Error?e.message:String(e))}finally{h(!1)}}},C=async()=>{try{await s.mutateAsync({addonId:c,action:Ye,input:{}})}catch(e){f(e instanceof Error?e.message:String(e))}};return e(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[v?e(`button`,{type:`button`,onClick:()=>void C(),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10`,children:[r(_,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]}):e(`button`,{type:`button`,onClick:()=>void S(),disabled:m,title:n(`storage.locationDiscardControl.permanentlyDeleteLeftoverFilesOn`,`Permanently delete leftover files on this location. Other locations are not affected.`),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10 disabled:opacity-50`,children:[m?r(b,{className:`h-3 w-3 animate-spin`}):r(p,{className:`h-3 w-3`}),n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),y&&l!==null&&e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:r(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${nt(l)}%`}})}),e(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[l.phase,l.camerasTotal>0?` · ${n(`storage.locationDiscardControl.camsProgress`,{done:l.camerasDone,total:l.camerasTotal})}`:``,l.dbRowsDeleted>0?` · ${n(`storage.locationDiscardControl.rowsDeleted`,{count:l.dbRowsDeleted})}`:``,l.detail?` · ${l.detail}`:``]})]}),(d||g&&l?.error)&&r(`p`,{className:`text-[10px] text-danger leading-tight`,children:d??l?.error})]})}o();var ot={active:h,readonly:C,drain:w,disabled:m},st={active:`border-success/30 text-success hover:bg-success/10`,readonly:`border-border text-foreground-subtle hover:text-foreground hover:bg-primary/10`,drain:`border-warning/40 text-warning hover:bg-warning/10`,disabled:`border-danger/40 text-danger hover:bg-danger/10`};function ct({mode:t,open:n,onToggle:i}){let{t:a}=j(),o=H(t),s=ot[t];return e(`button`,{type:`button`,"aria-expanded":n,"aria-label":a(`storage.locationModeSelector.locationState`,`Location state`),onClick:i,title:o.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${st[t]}`,children:[r(s,{className:`h-3 w-3`}),o.label,r(v,{className:`h-3 w-3 ${n?`rotate-180`:``}`})]})}function lt({mode:t,blockedReasons:n,onSelect:a,onDismiss:o}){let{t:s}=j();return i(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[o]),e(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":s(`storage.locationModeSelector.locationStateChoices`,`Location state choices`),children:[e(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[r(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`storage.locationModeSelector.locationState`,`Location state`)}),r(`button`,{type:`button`,"aria-label":s(`storage.locationModeSelector.closeLocationStateChoices`,`Close location state choices`),onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:r(_,{className:`h-3 w-3`})})]}),V.map(i=>{let c=n[i.mode],l=c!==``,u=ot[i.mode],d=i.mode===t;return e(`button`,{type:`button`,role:`radio`,"aria-checked":d,"aria-label":i.label,disabled:l,onClick:()=>{l||(o(),d||a(i.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${l?`cursor-not-allowed opacity-60`:d?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[r(u,{className:`h-3 w-3`}),i.label,d&&r(`span`,{className:`text-[9px] uppercase text-primary`,children:s(`common.current`)})]}),r(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:i.consequence}),l&&r(`span`,{className:`text-[10px] leading-snug text-warning`,children:c})]},i.mode)})]})}o();function ut(e){let t=e.basePath;if(typeof t==`string`&&t.length>0)return t;let n=Object.keys(e);return n.length===0?``:n.join(`, `)}function dt({location:t,onEdit:n,onDelete:i,onSetMode:o,blockedReasons:s,canDelete:c,siblings:l=[],drain:f,ownedBytes:p}){let{t:m}=j(),[h,g]=a(!1),_=ut(t.config),v=z(t);return e(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5`,children:[e(`div`,{className:`flex items-start gap-2 min-w-0 flex-1 basis-72`,children:[r(`div`,{className:`shrink-0 sm:w-32`,"data-testid":`location-badge-slot`,children:r(`span`,{className:`inline-block text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:t.providerId})}),e(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`text-xs font-medium text-foreground truncate`,children:t.displayName}),_&&r(`div`,{className:`text-[10px] text-foreground-subtle truncate font-mono`,children:_}),r(Ge,{location:t,ownedBytes:p??null}),f!==void 0&&r(Le,{drain:f})]})]}),e(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[r(it,{location:t,siblings:l}),r(ct,{mode:v,open:h,onToggle:()=>{g(e=>!e)}}),e(`button`,{onClick:()=>n(t),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10`,children:[r(u,{className:`h-3 w-3`}),m(`common.edit`,`Edit`)]}),c&&r(`button`,{onClick:()=>i(t),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,title:m(`storage.locationCard.deleteLocation`,`Delete location`),children:r(d,{className:`h-3 w-3`})})]}),h&&r(lt,{mode:v,blockedReasons:s,onSelect:e=>o(t,e),onDismiss:()=>{g(!1)}})]})}o();function ft({type:n,displayName:i,description:a,cardinality:o,locations:s,onAdd:l,onEdit:u,onDelete:d,onSetMode:p,ownedBytesById:m,drainById:h}){let{t:g}=j(),_=t(()=>{let e=[...s];return e.sort((e,t)=>{let n=B(z(e));return n===B(z(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return e(T,{headingId:`storage-location-${n}`,title:i,icon:y,testId:`storage-location-group-${n}`,actions:o===`multi`?e(D,{size:`sm`,type:`button`,onClick:()=>l(n),children:[r(f,{className:`h-3 w-3`}),g(`common.add`,`Add`)]}):void 0,children:[e(`div`,{className:`${c} space-y-2`,children:[e(`div`,{className:`space-y-0.5`,children:[r(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:n}),a!==void 0&&a!==``&&r(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:a}),o===`single`&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:g(`storage.locationGroup.singleOneLocationPerType`,`Single — one location per type. Edit the existing entry; it can't be split.`)})]}),_.length===0&&r(`div`,{className:`py-2 text-center text-[11px] text-foreground-subtle italic`,children:o===`multi`?g(`storage.locationGroup.noLocationRegisteredClickAdd`,`No location registered. Click "Add" to register one.`):g(`storage.locationGroup.noLocationRegisteredYetShould`,`No location registered yet — should be auto-seeded at next boot.`)})]}),_.length>0&&r(`div`,{className:`border-t border-border`,children:_.map(e=>r(dt,{location:e,cardinality:o,canDelete:me(e,_,o),onEdit:u,onDelete:d,onSetMode:p,blockedReasons:pe(e,_),ownedBytes:m?.get(e.id)??null,drain:Ne(Pe(e),h?.get(e.id)),siblings:_},e.id))})]})}var pt=[`recordings`,`recordingsLow`];function mt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function ht(e,t){if(t===void 0||!pt.includes(e.type))return null;let n=t.find(t=>mt(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function gt(e,t){let n=new Map;for(let r of e){let e=ht(r,t);e!==null&&n.set(r.id,e)}return n}export{je as a,H as c,Ve as i,de as l,ft as n,Oe as o,K as r,ge as s,gt as t,R as u};
|
|
1
|
+
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as c,Di as l,Hn as u,Ht as d,In as f,Jr as p,Kr as m,Nn as h,dt as g,gt as _,ki as v,kr as y,pr as b,st as x}from"./player-overlays-DpZIxQHp.js";import{xo as S}from"./client-BvflqtP1.js";import{t as C}from"./archive-Bu9T4BL0.js";import{t as w}from"./hard-drive-download-Cd122TYb.js";import{Bu as ee,Ct as te,Dn as T,Er as ne,Fi as E,Ou as re,Sr as ie,Tr as ae,br as oe,ii as D,wr as O,xr as se}from"./src-KDhMZ5Ob.js";import{t as k}from"./i18n-Bg2ooh3q.js";import{t as A}from"./Trans-Bsz5Pghy.js";import{t as j}from"./useTranslation-BJr-n0es.js";import{t as ce}from"./FormBuilder-BvQZWKCS.js";import{t as M}from"./format-size-DIxKXxtj.js";o();function N(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function P(e,t){let n=N(t);return`${e}:${n.length>0?n:`default`}`}var F=new Set([`proc`,`sys`,`dev`,`run`,`boot`,`lost+found`,`snap`,`bin`,`sbin`,`lib`,`lib32`,`lib64`,`libx32`,`usr`,`etc`,`var`,`opt`,`tmp`,`srv`,`root`,`System`,`Library`,`Applications`,`cores`,`private`]),I=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function L(e){let t=I.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?I.length:t}function le(e){return e.filter(e=>!e.name.startsWith(`.`)&&!F.has(e.name)).toSorted((e,t)=>{let n=L(e.name)-L(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function ue({nodeId:t,value:o,onChange:s}){let{t:c}=j(),l=g().trpcClient,[u,d]=a([]),[f,p]=a(o),[m,h]=a(null),[_,v]=a(null),[y,b]=a(``),x=n(async(e,n)=>{v(null);try{let r=await l.filesystemBrowse.browse.query({nodeId:t,path:e});h(r),p(r.path),n&&s(r.path)}catch(e){v(e instanceof Error?e.message:`browse failed`)}},[l,t,s]);i(()=>{p(o),(async()=>{let e=await l.filesystemBrowse.browse.query({nodeId:t,path:`/`}).then(e=>e).catch(()=>null);if(e){d(le(e.entries)),await x(o.startsWith(`/`)?o:`/`,!1);return}try{let e=await l.filesystemBrowse.listAllowedRoots.query({nodeId:t});d(e),await x(o&&e.some(e=>o.startsWith(e))?o:e[0]??``,!1)}catch(e){d([]),h(null),v(e instanceof Error&&/not available on node/i.test(e.message)?`This node can't be browsed remotely. Enter the path manually.`:e instanceof Error?e.message:`browse unavailable`)}})()},[t]);let S=async()=>{if(!(!y.trim()||!m)){v(null);try{let e=`${m.path.replace(/\/+$/,``)}/${y.trim()}`;await l.filesystemBrowse.createDir.mutate({nodeId:t,path:e}),b(``),await x(m.path,!0)}catch(e){v(e instanceof Error?e.message:`create failed`)}}},C=e=>`${(e/1e9).toFixed(1)} GB`;return e(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[r(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>r(`button`,{onClick:()=>void x(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),r(`input`,{value:f,onChange:e=>{p(e.target.value),s(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),m&&r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.pathBrowser.free`,{free:C(m.freeBytes),total:C(m.totalBytes)})}),r(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:m?.entries.map(t=>e(`button`,{onClick:()=>void x(t.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,t.name]},t.path))}),e(`div`,{className:`flex gap-1`,children:[r(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:c(`storage.pathBrowser.newFolder`,`new folder`),className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),r(`button`,{onClick:()=>void S(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:c(`storage.pathBrowser.create`,`Create`)})]}),_&&r(`div`,{className:`text-[10px] text-red-400`,children:_})]})}o();function R({initialType:n,onClose:i,onCreated:o}){let{t:c}=j(),u=s(),d=g().trpcClient,[f,p]=a(`picker`),[m,h]=a(n),[_,v]=a(null),[y,x]=a({}),[S,C]=a(``),[w,T]=a(null),[E,D]=a(!1),[O,k]=a(`hub`),[M,N]=a(null),[F,I]=a(!1),L=e=>x(t=>({...t,basePath:e})),le=typeof y.basePath==`string`?y.basePath:``,R=re(),z=t(()=>{let e=R.data;return Array.isArray(e)?e:[]},[R.data]),B=R.isLoading,V=ee({onSuccess:()=>{u.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),H=t(()=>w!==null&&w.length>0?w:P(m,S),[m,S,w]),de=async()=>{if(_){I(!0),N(null);try{N(await(e=>d.storage.testConfig.query(e))({providerId:_.providerId,config:y}))}catch(e){N({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{I(!1)}}};return r(oe,{open:!0,onOpenChange:e=>!e&&i(),children:e(ie,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(ae,{children:[r(ne,{children:{picker:`Add Location — Pick provider`,config:`Add Location — ${_?.displayName??``}`,naming:`Add Location — Name`}[f]}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[c(`storage.addLocationWizard.type`,`Type:`),` `,r(`span`,{className:`font-mono`,children:m})]})]}),e(se,{children:[f===`picker`&&e(`div`,{className:`space-y-2`,children:[B&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:c(`storage.addLocationWizard.loadingProviders`,`Loading providers…`)}),!B&&z.length===0&&r(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:r(A,{i18nKey:`storage.addLocationWizard.noProvider`,values:{type:m},components:{code:r(`code`,{className:`font-mono`})}})}),z.map(t=>e(`button`,{onClick:()=>{v(t),p(`config`)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors`,children:[e(`div`,{className:`flex-1 min-w-0`,children:[r(`p`,{className:`text-xs font-semibold text-foreground`,children:t.displayName}),r(`p`,{className:`text-[10px] text-foreground-subtle font-mono mt-0.5 truncate`,children:t.providerId})]}),r(l,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},t.providerId))]}),f===`config`&&_&&e(`div`,{className:`space-y-3`,children:[r(ce,{schema:_.configSchema,values:y,onChange:x}),_.nodeLocal&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.node`,`Node`)}),r(te,{selectedNodeId:O,onSelect:k,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.path`,`Path`)}),r(ue,{nodeId:O,value:le,onChange:L})]}),M&&r(`div`,{className:`rounded border px-3 py-2 text-[11px] ${M.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:M.ok?c(`storage.addLocationWizard.connectionOk`,`Connection OK.`):c(`storage.addLocationWizard.testFailed`,`Test failed: {{value1}}`,{value1:M.error??`unknown error`})}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>p(`picker`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{de()},disabled:F,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:F?c(`storage.addLocationWizard.testing`,`Testing…`):c(`storage.addLocationWizard.testConnection`,`Test connection`)}),r(`button`,{onClick:()=>p(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:c(`common.next`,`Next`)})]})]})]}),f===`naming`&&_&&e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.displayName`,`Display name`)}),r(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:c(`storage.addLocationWizard.on`,`{{type}} on {{displayName}}`,{type:m,displayName:_.displayName}),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`})]}),e(`div`,{className:`space-y-1`,children:[e(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:[c(`storage.addLocationWizard.idLabel`),` `,r(`span`,{className:`lowercase tracking-normal text-foreground-subtle`,children:c(`storage.addLocationWizard.autoDerivedOverrideIfNeeded`,`— auto-derived; override if needed`)})]}),r(`input`,{type:`text`,value:H,onChange:e=>T(e.target.value),placeholder:P(m,S),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-1 focus:ring-primary`}),e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[c(`storage.addLocationWizard.format`,`Format:`),` `,r(`code`,{className:`font-mono`,children:c(`storage.addLocationWizard.typeSlug`,`<type>:<slug>`)}),`. Lowercase letters, digits, and hyphens only.`]})]}),e(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[r(`input`,{type:`checkbox`,checked:E,onChange:e=>D(e.target.checked),className:`accent-primary mt-0.5`}),e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`text-xs font-medium text-foreground`,children:c(`storage.addLocationWizard.enableImmediately`,`Enable immediately`)}),r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.addLocationWizard.aDisabledLocationReceivesNo`,`A disabled location receives no writes until enabled — reads and age-based retention still work, nothing new lands here. Leave this off to register the disk now and start using it later.`)})]})]}),V.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:V.error instanceof Error?V.error.message:String(V.error)}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>p(`config`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{h(n),v(null),x({}),C(``),T(null),D(!1),N(null),p(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.reset`,`Reset`)}),e(`button`,{onClick:()=>{_&&V.mutate({id:H,type:m,displayName:S.trim(),providerId:_.providerId,config:y,enabled:E,nodeId:_.nodeLocal?O:void 0})},disabled:V.isPending||S.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[V.isPending?r(b,{className:`h-3.5 w-3.5 animate-spin`}):null,V.isPending?c(`storage.addLocationWizard.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})]})]})})}function z(e){return S(e)}function B(e){return e===`active`}var V=[{mode:`active`,get label(){return k.t(`helpers.locationMode.activeLabel`)},get consequence(){return k.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return k.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return k.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return k.t(`helpers.locationMode.drainLabel`)},get consequence(){return k.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return k.t(`helpers.locationMode.disabledLabel`)},get consequence(){return k.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function H(e){return V.find(t=>t.mode===e)??V[0]}function de(e){return H(e).requiresConfirmation}var fe=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function U(e,t,n){return B(n)||!B(z(e))||t.some(t=>t.id!==e.id&&B(z(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:fe}}function pe(e,t){return{active:U(e,t,`active`).reason,readonly:U(e,t,`readonly`).reason,drain:U(e,t,`drain`).reason,disabled:U(e,t,`disabled`).reason}}function me(e,t,n){return!(n===`single`||t.length<=1||B(z(e))&&t.filter(e=>B(z(e))).length<=1)}function he(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function ge(e,t){let n={...t.config??e.config};t.mode!==void 0&&(he(t.mode).readOnly?n.readOnly=!0:delete n.readOnly);let r={id:e.id,type:e.type,displayName:t.displayName??e.displayName,providerId:e.providerId,config:n,isSystem:e.isSystem},i=t.nodeId??e.nodeId,a=i===void 0?r:{...r,nodeId:i};return t.mode===void 0?e.enabled===void 0?a:{...a,enabled:e.enabled}:{...a,mode:t.mode,enabled:he(t.mode).enabled}}var _e=1024**3;function W(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function ve(e){let t=W(e.minFreeGb);if(t!==null)return{unit:`gb`,value:t};let n=W(e.minFreePercent);return n===null?{unit:`percent`,value:null}:{unit:`percent`,value:n}}function ye(e,t){return W(e[t===`gb`?`minFreeGb`:`minFreePercent`])}function be(e,t){let n={...e};return delete n.minFreePercent,delete n.minFreeGb,t.value===null?n:t.unit===`gb`?{...n,minFreeGb:t.value}:{...n,minFreePercent:t.value}}function xe(e,t){let n=e.trim();if(n===``)return null;let r=Number(n);return Number.isFinite(r)?t===`percent`?Math.min(100,Math.max(0,r)):Math.max(0,r):null}function Se(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*_e;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function Ce(e){return e===`gb`?k.t(`helpers.locationProtection.unitGb`):k.t(`helpers.locationProtection.unitPercent`)}function we(e,t=10){let n=e.value===null?k.t(`helpers.locationProtection.targetDefault`,{percent:String(t)}):e.unit===`gb`?k.t(`helpers.locationProtection.targetGb`,{value:String(e.value)}):k.t(`helpers.locationProtection.targetPercent`,{value:String(e.value)});return k.t(`helpers.locationProtection.helpText`,{target:n,percent:String(t)})}function Te(e){return W(e.maxUsedGb)}function Ee(e,t){let n=W(e.maxUsedGb);return n===null||n<0?null:{bytes:n*_e,reason:t===`drain`?`drain`:`legacy`}}o();function De({config:t,defaultPercent:n=10,onChange:i}){let{t:o}=j(),[s,c]=a(()=>ve(t).unit),l=ye(t,s),u={unit:s,value:l},d=Te(t),f=e=>{c(e),i(be(t,{unit:e,value:null}))},p=e=>{i(be(t,{unit:s,value:xe(e,s)}))};return e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`storage.protectionPolicyField.protectedFreeSpace`,`Protected free space`)}),e(`div`,{className:`flex items-center gap-2`,children:[e(`select`,{"aria-label":o(`storage.protectionPolicyField.protectionUnit`,`Protection unit`),value:s,onChange:e=>{f(e.target.value===`gb`?`gb`:`percent`)},className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:[r(`option`,{value:`percent`,children:o(`storage.protectionPolicyField.ofTheVolume`,`% of the volume`)}),r(`option`,{value:`gb`,children:o(`storage.protectionPolicyField.gbOfFreeSpace`,`GB of free space`)})]}),r(`input`,{type:`number`,"aria-label":Ce(s),min:0,max:s===`percent`?100:void 0,value:l===null?``:l,placeholder:s===`percent`?String(n):o(`common.defaultWord`),onChange:e=>{p(e.target.value)},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`})]}),r(`p`,{className:`text-[10px] text-foreground-subtle`,children:we(u,n)}),d!==null&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`storage.protectionPolicyField.legacyMax`,{gb:d})})]})}o();function Oe({location:n,onClose:i,onSaved:o}){let{t:c}=j(),l=s(),u=g().trpcClient,[d,f]=a({...n.config}),[p,m]=a(n.displayName),[h,_]=a(null),[v,y]=a(!1),x=re(),S=t(()=>{let e=x.data;return Array.isArray(e)?e.find(e=>e.providerId===n.providerId)??null:null},[x.data,n.providerId]),C=ee({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),w=S?.shouldSaveDiskSpace===!0,T=S?.nodeLocal===!0,[E,k]=a(typeof n.nodeId==`string`?n.nodeId:`hub`),M=typeof d.basePath==`string`?d.basePath:``,N=e=>f(t=>({...t,basePath:e})),P=S?.minFreePercent??10,F=async()=>{y(!0),_(null);try{_(await(e=>u.storage.testConfig.query(e))({providerId:n.providerId,locationId:n.id,config:d}))}catch(e){_({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{y(!1)}};return r(oe,{open:!0,onOpenChange:e=>!e&&i(),children:e(ie,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(ae,{children:[r(ne,{children:c(`storage.editLocationModal.title`,{name:n.displayName})}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[r(`span`,{className:`font-mono`,children:n.id}),` ·`,` `,S?.displayName??n.providerId]})]}),e(se,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.displayName`,`Display name`)}),r(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),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`})]}),S&&r(ce,{schema:S.configSchema,values:d,onChange:f}),T&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.node`,`Node`)}),r(te,{selectedNodeId:E,onSelect:k,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.path`,`Path`)}),r(ue,{nodeId:E,value:M,onChange:N})]}),w&&r(De,{config:d,defaultPercent:P,onChange:f}),!S&&!x.isLoading&&r(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:r(A,{i18nKey:`storage.editLocationModal.providerGone`,values:{id:n.providerId},components:{code:r(`code`,{className:`font-mono`})}})}),h&&r(`div`,{className:`rounded border px-3 py-2 text-[11px] ${h.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:h.ok?c(`storage.editLocationModal.connectionOk`,`Connection OK.`):c(`storage.editLocationModal.testFailed`,`Test failed: {{value1}}`,{value1:h.error??`unknown error`})}),C.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:C.error instanceof Error?C.error.message:String(C.error)})]}),e(O,{className:`justify-between`,children:[r(D,{variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(D,{variant:`outline`,size:`sm`,onClick:()=>{F()},disabled:v||!S,children:v?c(`storage.editLocationModal.testing`,`Testing…`):c(`storage.editLocationModal.testConnection`,`Test connection`)}),e(D,{size:`sm`,onClick:()=>{C.mutate(ge(n,{displayName:p.trim(),config:d,nodeId:T?E:n.nodeId}))},disabled:C.isPending||p.trim().length===0,children:[C.isPending?r(b,{className:`h-3.5 w-3.5 animate-spin`}):null,C.isPending?c(`storage.editLocationModal.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})})}function ke(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Ae(e){if(!ke(e))return null;let t=e.locationId;if(typeof t!=`string`||t.length===0)return null;let n=G(e.startedAtMs),r=G(e.startBytes),i=G(e.bytesRemaining);return n===null||r===null||i===null||typeof e.drained!=`boolean`?null:{locationId:t,startedAtMs:n,startBytes:r,bytesRemaining:i,drained:e.drained,estimatedEmptyAtMs:G(e.estimatedEmptyAtMs)}}function je(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=Ae(n);e!==null&&t.set(e.locationId,e)}return t}function Me(e){if(e.startBytes<=0||e.bytesRemaining>e.startBytes)return null;let t=e.startBytes-e.bytesRemaining;return Math.min(1,Math.max(0,t/e.startBytes))}function Ne(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:Me(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function Pe(e){return e.mode===`drain`?!0:e.config.readOnly===!0}function Fe(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function Ie(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function Le({drain:t}){let{t:n}=j();if(t.kind===`idle`)return null;if(t.kind===`unreported`)return r(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:n(`storage.drainProgressLine.thisLocationIsDrainingThe`,`This location is draining. The hub has not reported how much is left yet — either the drain has just been set, or this hub predates the drain-progress report.`),children:n(`storage.drainProgressLine.drainingRemainingNotReportedYet`,`Draining · remaining not reported yet`)});if(t.kind===`drained`)return r(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:n(`storage.drainProgressLine.everythingThatWasHereHas`,`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`),children:n(`storage.drainProgressLine.drainedNothingLeftToMove`,`Drained · nothing left to move`)});let i=t.drainedFraction===null?null:Math.round(t.drainedFraction*100);return e(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[i!==null&&r(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":n(`storage.drainProgressLine.drainProgress`,`Drain progress`),"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:r(`span`,{className:`block h-full bg-warning`,style:{width:`${i}%`}})}),e(`span`,{children:[n(`storage.drainProgressLine.left`,{size:Fe(t.bytesRemaining)}),i!==null&&` · ${n(`storage.drainProgressLine.moved`,{percent:i})}`]}),t.estimatedEmptyAtMs===null?r(`span`,{"data-testid":`drain-eta-absent`,title:n(`storage.drainProgressLine.theDrainIsPacedBy`,`The drain is paced by how fast this class of data is still growing, and that has not been observed yet. There is no date to give.`),children:n(`storage.drainProgressLine.emptyTimeNotKnownYet`,`· empty time not known yet`)}):e(`span`,{"data-testid":`drain-eta`,children:[`·`,` `,n(`storage.drainProgressLine.empty`,{when:Ie(t.estimatedEmptyAtMs)})]})]})}var Re=[`ok`,`warn`,`critical`];function ze(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function Be(e){return Math.min(1,Math.max(0,e))}function K(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=Be((n-t)/n);return{fraction:r,severity:ze(r),recordingsFraction:Be(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Ve(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=K(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||Re.indexOf(e.severity)>Re.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}function q(e){return Math.min(1,Math.max(0,e))}function J(e){return Math.round(q(e)*1e3)/10}function Y(e){return`${String(Math.round(q(e)*100))}%`}function He(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:M(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?k.t(`helpers.locationCapacityBar.unknownSummary`):k.t(`helpers.locationCapacityBar.unknownSummaryOwned`,{size:e})}}let a=Math.min(Math.max(i,0),r),o=r-a,s=t===null||t<=0?0:t,c=Math.min(s,a),l=s>a,u=a-c,d=n.ownedBytes,f=d==null||!Number.isFinite(d)||d<0?null:Math.min(d,o),p=o-(f??0),m=K({usedBytes:f??o,availableBytes:a,totalBytes:r}),h=m===null?q(o/r):m.fraction,g=m===null?ze(h):m.severity,_=f===null?null:m===null?q(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:q((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:M(r),freeTotal:M(a),freeTotalPercent:Y(a/r),used:M(p),usedPercent:Y(p/r),free:M(u),freePercent:Y(u/r),reserve:s===0?null:k.t(`helpers.locationCapacityBar.reserveKept`,{size:M(s)}),owned:f===null||_===null?null:k.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:M(f),percent:Y(_)}),cap:v===null?null:v.reason===`drain`?k.t(`helpers.locationCapacityBar.capDrain`,{size:M(v.bytes)}):k.t(`helpers.locationCapacityBar.capCap`,{size:M(v.bytes)})},S=[k.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:k.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?k.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?k.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:k.t(`helpers.locationCapacityBar.legendKeptFree`),value:M(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:k.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?k.t(`helpers.locationCapacityBar.legendUsed`):k.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:k.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?k.t(`helpers.locationCapacityBar.legendDrainTarget`):k.t(`helpers.locationCapacityBar.legendCap`),value:k.t(`helpers.locationCapacityBar.legendCapValue`,{size:M(v.bytes)}),alarming:b}),{kind:`known`,severity:g,legend:C,segments:{reservePercent:J(c/r),ownedPercent:f===null?null:J(f/r),usedPercent:J(p/r),freePercent:J(u/r),capPercent:y===null?null:J(y)},labels:x,reserveExceedsFree:l,capBelowOwned:b,summary:S}}var Ue={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},X={reserve:`bg-danger/40`,owned:`bg-foreground/50`,free:`bg-border`,cap:`bg-foreground`};function We(e,t){return e===`used`?Ue[t]:X[e]}function Ge({location:t,ownedBytes:n}){let{t:i}=j(),a=t.capacity??null,o=Se(ve(t.config),a?.totalBytes??null),s=He({totalBytes:a?.totalBytes??null,availableBytes:a?.availableBytes??null},o,{ownedBytes:n??null,cap:Ee(t.config,z(t))});return s.kind===`unknown`?r(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:s.summary,children:s.owned===null?i(`storage.locationCapacityBar.capacityUnknown`,`Capacity unknown`):i(`storage.locationCapacityBar.capacityUnknownCamstackHolds`,`Capacity unknown · CamStack holds {{owned}}`,{owned:s.owned})}):e(`div`,{className:`mt-1 space-y-1`,title:s.summary,children:[e(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[s.segments.reservePercent>0&&r(`div`,{className:X.reserve,style:{width:`${String(s.segments.reservePercent)}%`}}),s.segments.ownedPercent!==null&&r(`div`,{className:X.owned,style:{width:`${String(s.segments.ownedPercent)}%`}}),r(`div`,{className:Ue[s.severity],style:{width:`${String(s.segments.usedPercent)}%`}}),r(`div`,{className:X.free,style:{width:`${String(s.segments.freePercent)}%`}}),s.segments.capPercent!==null&&r(`div`,{className:`absolute inset-y-0 w-px ${s.capBelowOwned?`bg-danger`:X.cap}`,style:{left:`${String(s.segments.capPercent)}%`}})]}),r(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:s.legend.map(t=>e(`li`,{className:`flex items-center gap-1`,children:[r(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${We(t.segment,s.severity)}`}),e(`span`,{className:`text-[10px] tabular-nums ${t.alarming?`text-danger`:`text-foreground-subtle`}`,children:[t.label,` `,t.value]})]},t.segment))})]})}var Ke={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},qe={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},Je=`storage.discardLocation`,Z=`storage.discardLocationStatus`,Ye=`storage.discardLocationCancel`;function Xe(e){return Ke[e]??null}function Ze(e){return qe[e]??null}function Qe(e){return!B(z(e))}function $e(e,t){return Xe(e.type)===null||!Qe(e)?!1:t.some(t=>t.id!==e.id&&B(z(t)))}var et=new Set([`idle`,`scanning`,`wiping-fs`,`wiping-db`,`cascading`,`complete`,`cancelled`,`error`]);function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function $(e){return typeof e==`string`?e:null}function tt(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.running!=`boolean`)return null;let n=t.phase;if(typeof n!=`string`||!et.has(n))return null;let r=Q(t.camerasTotal),i=Q(t.camerasDone),a=Q(t.foldersRemoved),o=Q(t.dbRowsDeleted),s=Q(t.ownersCascaded);return r===null||i===null||a===null||o===null||s===null?null:{running:t.running,locationId:$(t.locationId),jobId:$(t.jobId),phase:n,camerasTotal:r,camerasDone:i,foldersRemoved:a,dbRowsDeleted:o,ownersCascaded:s,detail:$(t.detail)??``,startedAtMs:Q(t.startedAtMs),finishedAtMs:Q(t.finishedAtMs),error:$(t.error)}}function nt(e){if(e.phase===`complete`)return 100;if(e.phase===`cancelled`||e.phase===`error`||e.phase===`idle`)return e.camerasTotal>0?Math.min(99,Math.round(e.camerasDone/e.camerasTotal*100)):0;if(e.camerasTotal>0){let t=e.camerasDone/e.camerasTotal*85;return e.phase===`wiping-db`?Math.min(95,Math.round(t+8)):e.phase===`cascading`?Math.min(99,Math.round(t+12)):Math.min(85,Math.round(t))}return e.phase===`scanning`?2:5}o();var rt=2e3;function it({location:e,siblings:t}){return $e(e,t)?r(at,{location:e}):null}function at({location:t}){let{t:n}=j(),o=x(),s=E(),c=Ze(t.type),[l,u]=a(null),[d,f]=a(null),[m,h]=a(!1);if(i(()=>{if(c===null)return;let e=!1,t=async()=>{try{let t=await s.mutateAsync({addonId:c,action:Z,input:{}});if(e)return;u(tt(t))}catch{}};t();let n=setInterval(()=>void t(),rt);return()=>{e=!0,clearInterval(n)}},[c,t.id]),c===null)return null;let g=l!==null&&l.locationId===t.id,v=g&&l.running,y=g&&l.phase!==`idle`,S=async()=>{if(await o({title:n(`storage.locationDiscardControl.discardLeftoversOn`,`Discard leftovers on "{{displayName}}"?`,{displayName:t.displayName}),message:n(`storage.locationDiscardControl.permanentlyDeletesLeftoverFilesAnd`,`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`),confirmLabel:n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`),variant:`danger`})){f(null),h(!0);try{await s.mutateAsync({addonId:c,action:Je,input:{locationId:t.id}}),u(tt(await s.mutateAsync({addonId:c,action:Z,input:{}})))}catch(e){f(e instanceof Error?e.message:String(e))}finally{h(!1)}}},C=async()=>{try{await s.mutateAsync({addonId:c,action:Ye,input:{}})}catch(e){f(e instanceof Error?e.message:String(e))}};return e(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[v?e(`button`,{type:`button`,onClick:()=>void C(),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10`,children:[r(_,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]}):e(`button`,{type:`button`,onClick:()=>void S(),disabled:m,title:n(`storage.locationDiscardControl.permanentlyDeleteLeftoverFilesOn`,`Permanently delete leftover files on this location. Other locations are not affected.`),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10 disabled:opacity-50`,children:[m?r(b,{className:`h-3 w-3 animate-spin`}):r(p,{className:`h-3 w-3`}),n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),y&&l!==null&&e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:r(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${nt(l)}%`}})}),e(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[l.phase,l.camerasTotal>0?` · ${n(`storage.locationDiscardControl.camsProgress`,{done:l.camerasDone,total:l.camerasTotal})}`:``,l.dbRowsDeleted>0?` · ${n(`storage.locationDiscardControl.rowsDeleted`,{count:l.dbRowsDeleted})}`:``,l.detail?` · ${l.detail}`:``]})]}),(d||g&&l?.error)&&r(`p`,{className:`text-[10px] text-danger leading-tight`,children:d??l?.error})]})}o();var ot={active:h,readonly:C,drain:w,disabled:m},st={active:`border-success/30 text-success hover:bg-success/10`,readonly:`border-border text-foreground-subtle hover:text-foreground hover:bg-primary/10`,drain:`border-warning/40 text-warning hover:bg-warning/10`,disabled:`border-danger/40 text-danger hover:bg-danger/10`};function ct({mode:t,open:n,onToggle:i}){let{t:a}=j(),o=H(t),s=ot[t];return e(`button`,{type:`button`,"aria-expanded":n,"aria-label":a(`storage.locationModeSelector.locationState`,`Location state`),onClick:i,title:o.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${st[t]}`,children:[r(s,{className:`h-3 w-3`}),o.label,r(v,{className:`h-3 w-3 ${n?`rotate-180`:``}`})]})}function lt({mode:t,blockedReasons:n,onSelect:a,onDismiss:o}){let{t:s}=j();return i(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[o]),e(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":s(`storage.locationModeSelector.locationStateChoices`,`Location state choices`),children:[e(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[r(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`storage.locationModeSelector.locationState`,`Location state`)}),r(`button`,{type:`button`,"aria-label":s(`storage.locationModeSelector.closeLocationStateChoices`,`Close location state choices`),onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:r(_,{className:`h-3 w-3`})})]}),V.map(i=>{let c=n[i.mode],l=c!==``,u=ot[i.mode],d=i.mode===t;return e(`button`,{type:`button`,role:`radio`,"aria-checked":d,"aria-label":i.label,disabled:l,onClick:()=>{l||(o(),d||a(i.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${l?`cursor-not-allowed opacity-60`:d?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[r(u,{className:`h-3 w-3`}),i.label,d&&r(`span`,{className:`text-[9px] uppercase text-primary`,children:s(`common.current`)})]}),r(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:i.consequence}),l&&r(`span`,{className:`text-[10px] leading-snug text-warning`,children:c})]},i.mode)})]})}o();function ut(e){let t=e.basePath;if(typeof t==`string`&&t.length>0)return t;let n=Object.keys(e);return n.length===0?``:n.join(`, `)}function dt({location:t,onEdit:n,onDelete:i,onSetMode:o,blockedReasons:s,canDelete:c,siblings:l=[],drain:f,ownedBytes:p}){let{t:m}=j(),[h,g]=a(!1),_=ut(t.config),v=z(t);return e(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5`,children:[e(`div`,{className:`flex items-start gap-2 min-w-0 flex-1 basis-72`,children:[r(`div`,{className:`shrink-0 sm:w-32`,"data-testid":`location-badge-slot`,children:r(`span`,{className:`inline-block text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:t.providerId})}),e(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`text-xs font-medium text-foreground truncate`,children:t.displayName}),_&&r(`div`,{className:`text-[10px] text-foreground-subtle truncate font-mono`,children:_}),r(Ge,{location:t,ownedBytes:p??null}),f!==void 0&&r(Le,{drain:f})]})]}),e(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[r(it,{location:t,siblings:l}),r(ct,{mode:v,open:h,onToggle:()=>{g(e=>!e)}}),e(`button`,{onClick:()=>n(t),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10`,children:[r(u,{className:`h-3 w-3`}),m(`common.edit`,`Edit`)]}),c&&r(`button`,{onClick:()=>i(t),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,title:m(`storage.locationCard.deleteLocation`,`Delete location`),children:r(d,{className:`h-3 w-3`})})]}),h&&r(lt,{mode:v,blockedReasons:s,onSelect:e=>o(t,e),onDismiss:()=>{g(!1)}})]})}o();function ft({type:n,displayName:i,description:a,cardinality:o,locations:s,onAdd:l,onEdit:u,onDelete:d,onSetMode:p,ownedBytesById:m,drainById:h}){let{t:g}=j(),_=t(()=>{let e=[...s];return e.sort((e,t)=>{let n=B(z(e));return n===B(z(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return e(T,{headingId:`storage-location-${n}`,title:i,icon:y,testId:`storage-location-group-${n}`,actions:o===`multi`?e(D,{size:`sm`,type:`button`,onClick:()=>l(n),children:[r(f,{className:`h-3 w-3`}),g(`common.add`,`Add`)]}):void 0,children:[e(`div`,{className:`${c} space-y-2`,children:[e(`div`,{className:`space-y-0.5`,children:[r(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:n}),a!==void 0&&a!==``&&r(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:a}),o===`single`&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:g(`storage.locationGroup.singleOneLocationPerType`,`Single — one location per type. Edit the existing entry; it can't be split.`)})]}),_.length===0&&r(`div`,{className:`py-2 text-center text-[11px] text-foreground-subtle italic`,children:o===`multi`?g(`storage.locationGroup.noLocationRegisteredClickAdd`,`No location registered. Click "Add" to register one.`):g(`storage.locationGroup.noLocationRegisteredYetShould`,`No location registered yet — should be auto-seeded at next boot.`)})]}),_.length>0&&r(`div`,{className:`border-t border-border`,children:_.map(e=>r(dt,{location:e,cardinality:o,canDelete:me(e,_,o),onEdit:u,onDelete:d,onSetMode:p,blockedReasons:pe(e,_),ownedBytes:m?.get(e.id)??null,drain:Ne(Pe(e),h?.get(e.id)),siblings:_},e.id))})]})}var pt=[`recordings`,`recordingsLow`];function mt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function ht(e,t){if(t===void 0||!pt.includes(e.type))return null;let n=t.find(t=>mt(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function gt(e,t){let n=new Map;for(let r of e){let e=ht(r,t);e!==null&&n.set(r.id,e)}return n}export{je as a,H as c,Ve as i,de as l,ft as n,Oe as o,K as r,ge as s,gt as t,R as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,S as n,Y as r,et as i,i as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ht as s,In as c,dt as l,gt as u,la as d,vn as f}from"./player-overlays-DpZIxQHp.js";import{A as p,At as m,Bt as h,Ct as g,Dt as _,E as ee,Ft as te,G as ne,Gr as re,Ht as ie,I as ae,It as oe,K as se,Kr as ce,L as v,Lt as y,M as b,Mt as le,N as ue,Ot as de,P as fe,R as pe,Rt as me,Tt as he,Ut as ge,Vt as _e,Wt as ve,bt as x,dt as ye,eo as be,ft as xe,gt as Se,ht as S,j as Ce,lt as we,mt as Te,pt as Ee,qr as De,ut as Oe,wt as ke,xt as C,yt as w,zt as Ae}from"./client-BvflqtP1.js";import{Pd as T,Ql as je,Ss as Me,U as Ne,eu as Pe,li as Fe,zd as E}from"./src-KDhMZ5Ob.js";import{t as D}from"./i18n-C02pTNTJ.js";import{t as O}from"./useTranslation-BJr-n0es.js";i();function k(e){return t=>Object.prototype.hasOwnProperty.call(e,t)}var Ie=k({devices:!0}),Le=k({classes:!0,classesExclude:!0,labelEquals:!0,identities:!0,identitiesExclude:!0,eventTypeTokens:!0,sensorKinds:!0}),Re=k({minConfidence:!0,minImportance:!0,minLabelConfidence:!0}),ze=k({minDwellSeconds:!0}),Be=k({source:!0}),Ve=k({crossing:!0}),He=k({packagePhase:!0}),Ue=k({sensorTransition:!0}),We=k({plates:!0}),Ge=k({occupancy:!0}),Ke=k({audio:!0}),qe=k({systemEvent:!0}),Je=k({deviceState:!0}),Ye=k({scene:!0});function Xe(e,t){let n=e[t];return Array.isArray(n)?n:[]}function Ze(e,t){let n=e[t];return typeof n==`number`?n:void 0}function A(e,n){let r=l().trpcClient,i=a({queries:e.map(e=>({queryKey:[[`nc-pickers`,`zones`],{deviceId:e}],staleTime:3e4,queryFn:async()=>({deviceId:e,zones:(await r.zones.listZones.query({deviceId:e})).map(e=>({id:e.id,name:e.name}))})}))});return t(()=>{let e=[],t=new Set;for(let r of i){if(!r.data)continue;let i=n.find(e=>e.id===r.data.deviceId)?.name;for(let n of r.data.zones)t.has(n.id)||(t.add(n.id),e.push({value:n.id,label:n.name,...i===void 0?{}:{hint:i}}))}return{options:e,loading:i.some(e=>e.isLoading),failed:i.some(e=>e.isError)}},[i,n])}function Qe(e){let n=l().trpcClient,r=a({queries:e.map(e=>({queryKey:[[`nc-pickers`,`event-kinds`],{deviceId:e}],staleTime:6e4,queryFn:async()=>(await n.pipelineAnalytics.listEventKinds.query({deviceId:e})).map(e=>({kind:e.kind,label:e.label}))}))});return t(()=>{let e=new Map;for(let t of r)for(let n of t.data??[])e.has(n.kind)||e.set(n.kind,n.label);let t=[...e.entries()].map(([e,t])=>({value:e,label:t}));return t.sort((e,t)=>e.label.localeCompare(t.label)),{options:t,loading:r.some(e=>e.isLoading)}},[r])}function $e(){let e=Me();return t(()=>({options:(e.data??[]).map(e=>({value:e.id,label:e.name})),loading:e.isLoading,failed:e.isError===!0}),[e.data,e.isLoading,e.isError])}function et(){let e=je({limit:200}),n=Pe();return t(()=>{let t=new Set;for(let e of n.data??[])e.name.trim().length>0&&t.add(e.name);let r=new Set;for(let t of e.data??[])t.text.trim().length>0&&r.add(t.text);return[...[...t].sort(),...[...r].sort()]},[e.data,n.data])}function j({options:i,value:a,onChange:o,loading:s,emptyHint:c,placeholder:l,noFreeText:u=!1}){let{t:d}=O(),[f,p]=r(``),m=t(()=>new Set(i.map(e=>e.value)),[i]),h=t(()=>new Set(a),[a]),g=a.filter(e=>!m.has(e)),_=e=>{o(h.has(e)?a.filter(t=>t!==e):[...a,e])},ee=()=>{let e=f.trim();e.length===0||a.includes(e)||(o([...a,e]),p(``))};return e(`div`,{className:`mt-1 space-y-1.5`,children:[g.length>0&&n(`div`,{className:`flex flex-wrap gap-1`,children:g.map(t=>e(`button`,{type:`button`,onClick:()=>o(a.filter(e=>e!==t)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:d(`system.notificationRulePickers.customValueClickToRemove`,`Custom value — click to remove`),children:[t,` ×`]},t))}),i.length>0?n(`div`,{className:`max-h-40 overflow-y-auto rounded-md border border-border divide-y divide-border`,children:i.map(t=>e(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[n(`input`,{type:`checkbox`,checked:h.has(t.value),onChange:()=>_(t.value),className:`accent-primary`}),n(`span`,{className:`flex-1 truncate`,children:t.label}),t.hint!==void 0&&n(`span`,{className:`text-[10px] text-foreground-subtle`,children:t.hint})]},t.value))}):n(`p`,{className:`text-[10px] text-foreground-subtle`,children:s===!0?d(`common.loading`,`Loading…`):c}),!u&&n(`input`,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ee())},placeholder:l,className:`w-full rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground placeholder:text-foreground-subtle`})]})}var M=[{value:`immediate`,get label(){return D.t(`helpers.ruleFormParsers.immediate`)},get hint(){return D.t(`helpers.ruleFormParsers.immediateHint`)}},{value:`track-end`,get label(){return D.t(`helpers.ruleFormParsers.trackEnd`)},get hint(){return D.t(`helpers.ruleFormParsers.trackEndHint`)}},{value:`device-event`,get label(){return D.t(`helpers.ruleFormParsers.deviceEvent`)},get hint(){return D.t(`helpers.ruleFormParsers.deviceEventHint`)}},{value:`package-event`,get label(){return D.t(`helpers.ruleFormParsers.packageEvent`)},get hint(){return D.t(`helpers.ruleFormParsers.packageEventHint`)}},{value:`system-event`,get label(){return D.t(`helpers.ruleFormParsers.systemEvent`)},get hint(){return D.t(`helpers.ruleFormParsers.systemEventHint`)}}],tt=`Immediate, grouped`,nt=M.flatMap(e=>e.value===`immediate`?[e,{value:`immediate-grouped`,get label(){return D.t(`notificationRules.grouping.choice`)},get hint(){return D.t(`helpers.ruleFormParsers.groupedHint`)}}]:[e]);function rt(e){return e.groupingSec!==void 0&&w(e)?`immediate-grouped`:e.delivery}function it(e){let t=(e.delivery===`immediate`||e.delivery===`track-end`)&&w({delivery:`immediate`,conditions:e.conditions});return nt.filter(e=>e.value!==`immediate-grouped`||t)}function at(e){return nt.find(t=>t.value===e)?.value}function ot(e,t=tt){return rt(e)===`immediate-grouped`?`${t} · ${String(e.groupingSec)} s`:ct(e.delivery)}function st(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}function ct(e){return M.find(t=>t.value===e)?.label??e}function lt(e){return M.some(t=>t.value===e)}var ut=[{key:`all`,get label(){return D.t(`helpers.ruleFormParsers.sec_all_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_all_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_all_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_all_empty`)},creatable:!0},{key:`detection`,get label(){return D.t(`helpers.ruleFormParsers.sec_detection_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_detection_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_detection_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_detection_empty`)},creatable:!0},{key:`sensor`,get label(){return D.t(`helpers.ruleFormParsers.sec_sensor_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_sensor_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_sensor_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_sensor_empty`)},creatable:!0},{key:`audio`,get label(){return D.t(`helpers.ruleFormParsers.sec_audio_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_audio_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_audio_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_audio_empty`)},creatable:!0},{key:`occupancy`,get label(){return D.t(`helpers.ruleFormParsers.sec_occupancy_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_occupancy_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_occupancy_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_occupancy_empty`)},creatable:!0},{key:`device-events`,get label(){return D.t(`helpers.ruleFormParsers.sec_deviceEvents_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_deviceEvents_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_deviceEvents_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_deviceEvents_empty`)},creatable:!0},{key:`system`,get label(){return D.t(`helpers.ruleFormParsers.sec_system_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_system_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_system_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_system_empty`)},creatable:!0},{key:`alarm`,get label(){return D.t(`helpers.ruleFormParsers.sec_alarm_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_alarm_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_alarm_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_alarm_empty`)},creatable:!0},{key:`mixed`,get label(){return D.t(`helpers.ruleFormParsers.sec_mixed_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_mixed_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_mixed_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_mixed_empty`)},creatable:!1}];function dt(e){return C(x(e)).editable}function ft(e){return Se(pt(e))}function pt(e){switch(e){case`device-events`:case`system`:case`alarm`:case`mixed`:return e;default:return}}var mt=new Map([[0,`helpers.ruleFormParsers.cdNone`],[60,`helpers.ruleFormParsers.cd1m`],[3600,`helpers.ruleFormParsers.cd1h`]]),ht=86400;function gt(e){let t=mt.get(e);return t===void 0?e%3600==0?D.t(`helpers.ruleFormParsers.cdHours`,{count:e/3600}):e%60==0?D.t(`helpers.ruleFormParsers.cdMinutes`,{count:e/60}):D.t(`helpers.ruleFormParsers.cdSeconds`,{count:e}):D.t(t)}function _t(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}var vt=[{value:`rule-device`,get label(){return D.t(`helpers.ruleFormParsers.scopeDevice`)}},{value:`rule`,get label(){return D.t(`helpers.ruleFormParsers.scopeRule`)}}];function yt(e){return vt.find(t=>t.value===e)?.value}var bt=[{value:`per-class`,get label(){return D.t(`helpers.ruleFormParsers.granPerClass`)}},{value:`shared`,get label(){return D.t(`helpers.ruleFormParsers.granShared`)}}];function xt(e){return bt.find(t=>t.value===e)?.value}var N=[{value:`scene-boxes`,get label(){return D.t(`helpers.ruleFormParsers.imageSceneBoxes`)},get description(){return D.t(`helpers.ruleFormParsers.imageSceneBoxesDesc`)}},{value:`crop`,get label(){return D.t(`helpers.ruleFormParsers.imageCrop`)},get description(){return D.t(`helpers.ruleFormParsers.imageCropDesc`)}},{value:`clean`,get label(){return D.t(`helpers.ruleFormParsers.imageClean`)},get description(){return D.t(`helpers.ruleFormParsers.imageCleanDesc`)}},{value:`none`,get label(){return D.t(`helpers.ruleFormParsers.imageNone`)},get description(){return D.t(`helpers.ruleFormParsers.imageNoneDesc`)}}];function St(e){return N.find(t=>t.value===e)?.value}var P=[{value:``,get label(){return D.t(`helpers.ruleFormParsers.linkedDefault`)}},{value:`mosaic`,get label(){return D.t(`helpers.ruleFormParsers.linkedMosaic`)}},{value:`each`,get label(){return D.t(`helpers.ruleFormParsers.linkedEach`)}}];function Ct(e){let t=P.find(t=>t.value===e)?.value;return t===``?void 0:t}var F=[{value:``,get label(){return D.t(`helpers.ruleFormParsers.profileLowest`)}},{value:`low`,get label(){return D.t(`helpers.ruleFormParsers.profileLow`)}},{value:`mid`,get label(){return D.t(`helpers.ruleFormParsers.profileMid`)}},{value:`high`,get label(){return D.t(`helpers.ruleFormParsers.profileHigh`)}}];function wt(e){let t=F.find(t=>t.value===e)?.value;return t===``?void 0:t}var Tt=[{value:`any`,get label(){return D.t(`helpers.ruleFormParsers.srcAny`)}},{value:`pipeline`,get label(){return D.t(`helpers.ruleFormParsers.srcPipeline`)}},{value:`onboard`,get label(){return D.t(`helpers.ruleFormParsers.srcOnboard`)}},{value:`sensor`,get label(){return D.t(`helpers.ruleFormParsers.srcSensor`)}}],Et=[{value:`delivered`,get label(){return D.t(`helpers.ruleFormParsers.phaseDelivered`)}},{value:`picked-up`,get label(){return D.t(`helpers.ruleFormParsers.phasePickedUp`)}},{value:`both`,get label(){return D.t(`helpers.ruleFormParsers.phaseBoth`)}}],Dt=[{value:``,get label(){return D.t(`helpers.ruleFormParsers.stBoth`)}},{value:`raised`,get label(){return D.t(`helpers.ruleFormParsers.stRaised`)}},{value:`cleared`,get label(){return D.t(`helpers.ruleFormParsers.stCleared`)}}];function Ot(e){return e===`raised`||e===`cleared`?e:void 0}function I(e,t){return e===`sensorTransition`?se(t.sensorKinds):!0}var kt=[{value:`enter`,get label(){return D.t(`helpers.ruleFormParsers.crossEnter`)}},{value:`exit`,get label(){return D.t(`helpers.ruleFormParsers.crossExit`)}},{value:`any`,get label(){return D.t(`helpers.ruleFormParsers.crossAny`)}}],At=`enter`;function L(e){return e===`exit`||e===`any`?e:void 0}var jt=[{value:1,get label(){return D.t(`helpers.ruleFormParsers.prioMin`)}},{value:2,get label(){return D.t(`helpers.ruleFormParsers.prioLow`)}},{value:3,get label(){return D.t(`helpers.ruleFormParsers.prioDefault`)}},{value:4,get label(){return D.t(`helpers.ruleFormParsers.prioHigh`)}},{value:5,get label(){return D.t(`helpers.ruleFormParsers.prioMax`)}}];function Mt(e,t){return e.options&&e.options.length>0?e.options:t}var Nt=[{value:``,get label(){return D.t(`helpers.ruleFormParsers.speedDefault`)}},{value:`1`,get label(){return D.t(`helpers.ruleFormParsers.speedReal`)}},{value:`2`,label:`2×`},{value:`3`,label:`3×`},{value:`4`,label:`4×`},{value:`6`,label:`6×`},{value:`8`,label:`8×`}];function Pt(e){if(e===``)return;let t=Number(e);return Number.isFinite(t)&&t>=1&&t<=8?t:void 0}var Ft=`notificationRules.systemEventKinds.`,It=`notificationRules.systemEventGroups.`,Lt=`notificationRules.systemEventHints.`;function Rt(e){return!De.some(t=>t===e)}function R(e){let t=`${Ft}${e}`;return D.exists(t)?D.t(t):e}function z(){return de.map(e=>({id:e.id,family:e.family,label:D.t(`${It}${e.id}`,e.label),hint:D.t(`${Lt}${e.id}`),kinds:e.kinds.filter(Rt).map(e=>({value:e,label:R(e)}))}))}function B(e){return z().filter(t=>t.family===e)}function V(e){let t=g(e).conditions.systemEvent;return t===void 0?{kinds:(B(e)[0]?.kinds??[]).map(e=>e.value)}:{...t,kinds:[...t.kinds]}}function zt(){return z().flatMap(e=>e.kinds)}function Bt(e){return{devices:m(e,`deviceIds`),deviceTypes:m(e,`deviceTypes`),nodes:m(e,`nodeIds`),packages:m(e,`packageNames`),consumableThreshold:m(e,`consumableLowPercent`)}}function Vt(e,t){let n=_[e],r=Bt(t);return{devices:n.includes(`deviceIds`)&&r.devices,excludeDevices:n.includes(`excludeDeviceIds`)&&r.devices,deviceTypes:n.includes(`deviceTypes`)&&r.deviceTypes,nodes:n.includes(`nodeIds`)&&r.nodes,packages:n.includes(`packageNames`)&&r.packages,consumableThreshold:n.includes(`consumableLowPercent`)&&r.consumableThreshold}}var Ht=Object.values(be).map(e=>({value:e,label:Ut(e)})).toSorted((e,t)=>e.label.localeCompare(t.label));function Ut(e){let t=e.replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function Wt(e,t){let n=[],r=new Set;for(let i of e.kinds){let e=pe(i.value);if(e===void 0){n.push({key:i.value,label:i.label,kinds:[i.value],clears:[i.value]});continue}r.has(e.id)||(r.add(e.id),n.push({key:`class:${e.id}`,label:t?e.snapshotLabel:e.label,kinds:t?[...e.bad]:v(e),clears:v(e),classId:e.id,...t&&e.snapshotSection===null?{noSnapshot:!0}:{}}))}return n}function Gt(e,t){return t.clears.some(t=>e.includes(t))}function Kt(e,t,n){if(!B(n).some(e=>e.kinds.some(e=>t.kinds.includes(e.value))))return e;let r=e?.kinds??[];if(Gt(r,t)){let i=r.filter(e=>!t.clears.includes(e));return i.length===0?e:U(e,i,n)}return U(e,zt().filter(e=>t.kinds.includes(e.value)||r.includes(e.value)).map(e=>e.value),n)}function qt(e,t){return t===void 0?void 0:U(t,t.kinds,e)}function Jt(e,t){let n=e?.kinds??[];if(n.length===0)return;let r=H(t,`deviceIds`,e?.deviceIds),i=H(t,`excludeDeviceIds`,e?.excludeDeviceIds),a=H(t,`deviceTypes`,e?.deviceTypes),o=H(t,`nodeIds`,e?.nodeIds),s=H(t,`packageNames`,e?.packageNames),c=Object.prototype.hasOwnProperty.call(t,`consumableLowPercent`)?t.consumableLowPercent:e?.consumableLowPercent;return{kinds:[...n],...r===void 0?{}:{deviceIds:[...r]},...i===void 0?{}:{excludeDeviceIds:[...i]},...a===void 0?{}:{deviceTypes:[...a]},...o===void 0?{}:{nodeIds:[...o]},...s===void 0?{}:{packageNames:[...s]},...c===void 0?{}:{consumableLowPercent:c}}}function H(e,t,n){let r=Object.prototype.hasOwnProperty.call(e,t)?e[t]:n;return r!==void 0&&r.length===0?void 0:r}function U(e,t,n){let r=Vt(n,t),i=r.devices?e?.deviceIds:void 0,a=r.excludeDevices?e?.excludeDeviceIds:void 0,o=r.deviceTypes?e?.deviceTypes:void 0,s=r.nodes?e?.nodeIds:void 0,c=r.packages?e?.packageNames:void 0,l=r.consumableThreshold?e?.consumableLowPercent:void 0;return{kinds:[...t],...i&&i.length>0?{deviceIds:[...i]}:{},...a&&a.length>0?{excludeDeviceIds:[...a]}:{},...o&&o.length>0?{deviceTypes:[...o]}:{},...s&&s.length>0?{nodeIds:[...s]}:{},...c&&c.length>0?{packageNames:[...c]}:{},...l===void 0?{}:{consumableLowPercent:l}}}var Yt=95;function Xt(e){let t=e.trim();if(t===``)return{kind:`clear`};let n=Number(t);return Number.isInteger(n)&&n>=1&&n<=Yt?{kind:`set`,value:n}:{kind:`invalid`}}function Zt(e,t=2){if(e===void 0||e.length===0)return D.t(`helpers.notificationSystemEvents.noneSelected`);let n=e.slice(0,t).map(R).join(`, `),r=e.length-Math.min(t,e.length);return r>0?`${n} +${r}`:n}function Qt(e){if(e===void 0)return`—`;let t=[],n=e.deviceIds?.length??0,r=e.deviceTypes?.length??0,i=e.nodeIds?.length??0,a=e.packageNames?.length??0,o=e.excludeDeviceIds?.length??0;r>0&&t.push(e.deviceTypes?.map(Ut).join(`, `)??``),n>0&&t.push(`${n} device${n===1?``:`s`}`),i>0&&t.push(`${i} node${i===1?``:`s`}`),a>0&&t.push(`${a} package${a===1?``:`s`}`);let s=o>0?`except ${o} device${o===1?``:`s`}`:null,c=e.consumableLowPercent===void 0?[]:[`consumables at ${e.consumableLowPercent}%`];return t.length===0?[s===null?`Everything`:`Everything ${s}`,...c].join(` · `):[...t,...s===null?[]:[s],...c].join(` · `)}function $t(e){return e===void 0||(e.deviceTypes?.length??0)===0?!1:e.kinds.some(e=>re.includes(e))}var en=[`all`,`only`,`except`];function tn(e,t){return(e??[]).length>0?`only`:(t??[]).length>0?`except`:`all`}function W(e,t){let n=[...e??[]],r=[...t??[]];return{mode:tn(n,r),include:n,exclude:r,legacyBoth:n.length>0&&r.length>0}}function nn(e,t){return{...e,mode:t}}function rn(e){switch(e.mode){case`only`:return e.include;case`except`:return e.exclude;case`all`:return[]}}function an(e,t){switch(e.mode){case`only`:return{...e,include:[...t]};case`except`:return{...e,exclude:[...t]};case`all`:return e}}function on(e){return e.mode===`only`&&e.legacyBoth?e.exclude:[]}function sn(e){return{...e,exclude:[],legacyBoth:!1}}function G(e){switch(e.mode){case`all`:return{};case`except`:return e.exclude.length>0?{exclude:[...e.exclude]}:{};case`only`:{let t=on(e);return{...e.include.length>0?{include:[...e.include]}:{},...t.length>0?{exclude:[...t]}:{}}}}}function cn(e){let t=G(e),n=t.include??[],r=t.exclude??[];return[...e.include.filter(e=>!n.includes(e)),...e.exclude.filter(e=>!r.includes(e))]}var K=[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`],q={onActivation:{get title(){return D.t(`helpers.notificationRuleActions.onActivationTitle`)},get hint(){return D.t(`helpers.notificationRuleActions.onActivationHint`)}},onDeactivation:{get title(){return D.t(`helpers.notificationRuleActions.onDeactivationTitle`)},get hint(){return D.t(`helpers.notificationRuleActions.onDeactivationHint`)}},onTrigger:{get title(){return D.t(`helpers.notificationRuleActions.onTriggerTitle`)},get hint(){return D.t(`helpers.notificationRuleActions.onTriggerHint`)}},onTriggerOff:{get title(){return D.t(`helpers.notificationRuleActions.onTriggerOffTitle`)},get hint(){return D.t(`helpers.notificationRuleActions.onTriggerOffHint`)}}},ln={onActivation:[],onDeactivation:[],onTrigger:[],onTriggerOff:[],buttons:[]};function un(e){return e===void 0?ln:{onActivation:[...e.onActivation??[]],onDeactivation:[...e.onDeactivation??[]],onTrigger:[...e.onTrigger??[]],onTriggerOff:[...e.onTriggerOff??[]],buttons:[...e.buttons??[]]}}function J(e){let t=e.buttons.filter(e=>e.id.trim()!==``&&e.label.trim()!==``&&e.sequenceId.trim()!==``),n={onActivation:e.onActivation,onDeactivation:e.onDeactivation,onTrigger:e.onTrigger,onTriggerOff:e.onTriggerOff};if(!(!K.some(e=>n[e].length>0)&&t.length===0))return{...n.onActivation.length>0?{onActivation:[...n.onActivation]}:{},...n.onDeactivation.length>0?{onDeactivation:[...n.onDeactivation]}:{},...n.onTrigger.length>0?{onTrigger:[...n.onTrigger]}:{},...n.onTriggerOff.length>0?{onTriggerOff:[...n.onTriggerOff]}:{},...t.length>0?{buttons:t}:{}}}function dn(e,t){let n=[];for(let r of K){let i=e[r];i.length>4&&n.push({kind:`too-many`,message:D.t(`helpers.notificationRuleActions.tooMany`,{title:q[r].title})});for(let e of i)e.kind===`sequence`&&!t.has(e.sequenceId)&&n.push({kind:`unknown-sequence`,message:D.t(`helpers.notificationRuleActions.hookUnknownSeq`,{title:q[r].title})})}let r=new Set;for(let i of e.buttons){let e=i.id.trim();e!==``&&(r.has(e)&&n.push({kind:`duplicate-button`,message:D.t(`helpers.notificationRuleActions.dupButton`,{id:e})}),r.add(e),t.has(i.sequenceId.trim())||n.push({kind:`unknown-sequence`,message:D.t(`helpers.notificationRuleActions.buttonUnknownSeq`,{label:i.label||e})}))}return n}function fn(e,t){return{id:`action-${String(e+1)}`,label:D.t(`helpers.notificationRuleActions.newButtonLabel`),sequenceId:t}}function pn(){return{kind:`do`,action:{kind:`cap`,deviceId:0,cap:``,method:``}}}function mn(e){return{kind:`sequence`,sequenceId:e}}function hn(){return{kind:`wait`,seconds:5}}var gn=[{value:`acknowledge`,get label(){return D.t(`helpers.notificationRuleActions.icon_acknowledge`)}},{value:`dismiss`,get label(){return D.t(`helpers.notificationRuleActions.icon_dismiss`)}},{value:`silence`,get label(){return D.t(`helpers.notificationRuleActions.icon_silence`)}},{value:`snooze`,get label(){return D.t(`helpers.notificationRuleActions.icon_snooze`)}},{value:`view`,get label(){return D.t(`helpers.notificationRuleActions.icon_view`)}},{value:`play`,get label(){return D.t(`helpers.notificationRuleActions.icon_play`)}},{value:`camera`,get label(){return D.t(`helpers.notificationRuleActions.icon_camera`)}},{value:`open`,get label(){return D.t(`helpers.notificationRuleActions.icon_open`)}},{value:`close`,get label(){return D.t(`helpers.notificationRuleActions.icon_close`)}},{value:`unlock`,get label(){return D.t(`helpers.notificationRuleActions.icon_unlock`)}},{value:`lock`,get label(){return D.t(`helpers.notificationRuleActions.icon_lock`)}},{value:`disarm`,get label(){return D.t(`helpers.notificationRuleActions.icon_disarm`)}},{value:`arm`,get label(){return D.t(`helpers.notificationRuleActions.icon_arm`)}},{value:`arm-home`,get label(){return D.t(`helpers.notificationRuleActions.icon_arm_home`)}},{value:`arm-away`,get label(){return D.t(`helpers.notificationRuleActions.icon_arm_away`)}},{value:`arm-night`,get label(){return D.t(`helpers.notificationRuleActions.icon_arm_night`)}},{value:`light`,get label(){return D.t(`helpers.notificationRuleActions.icon_light`)}},{value:`alert`,get label(){return D.t(`helpers.notificationRuleActions.icon_alert`)}}],_n=[10,30,60],vn=[5,10,15,30,60,120,240,480];function yn(e){return e>=60&&e%60==0?D.t(`helpers.ruleFormState.snoozeHours`,{count:e/60}):D.t(`helpers.ruleFormState.snoozeMin`,{count:e})}var bn=new Set([`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`]),xn=`alarm-panel`;function Sn(e,t){for(let t of e.systemEvent?.kinds??[])if(bn.has(t))return!0;for(let e of t)if(e.kind===`cap`&&e.cap===xn)return!0;return!1}function Cn(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`])for(let i of e[t])if(i.kind===`do`)r.push(i.action);else{let e=n.get(i.sequenceId);e!==void 0&&r.push(...e.actions)}for(let t of e.buttons){let e=n.get(t.sequenceId);e!==void 0&&r.push(...e.actions)}return r}function wn(e){let{devices:t,devicesExclude:n,classes:r,classesExclude:i,...a}=e;return{conditions:a,deviceScope:W(t,n),classScope:W(r,i)}}function Tn(e){let t=G(e.deviceScope),n=G(e.classScope);return{...e.conditions,...t.include===void 0?{}:{devices:[...t.include]},...t.exclude===void 0?{}:{devicesExclude:[...t.exclude]},...n.include===void 0?{}:{classes:[...n.include]},...n.exclude===void 0?{}:{classesExclude:[...n.exclude]}}}function En(e){return e.deviceScope.mode===`only`?e.deviceScope.include:[]}function Dn(e,t,n){let r=x(n);return e.some(e=>e.id===t&&Ee(e,n.delivery,r))}function On(e=`immediate`,t={}){return{name:``,enabled:!0,delivery:e,targetIds:[],targetUsers:[],targetParams:{},priority:3,mediaImage:we({},x({delivery:e,conditions:t})),mediaShowTriggerZone:!1,mediaShowSubjectPath:!1,mediaGif:!1,mediaClip:!1,mediaProfile:void 0,mediaClipSpeed:void 0,mediaLinkedCameras:void 0,templateTitle:``,templateBody:``,...wn(t),schedule:void 0,systemEventDelivery:void 0,snoozeAllowGlobal:!1,groupingSec:void 0,snoozeOptions:void 0,askVerdict:void 0,actions:ln,cooldownSec:30,cooldownScope:`rule-device`,cooldownGranularity:void 0}}function kn(e){let t={};for(let n of e.targets)n.params&&Object.keys(n.params).length>0&&(t[n.targetId]=n.params);return{name:e.name,enabled:e.enabled,delivery:e.delivery,targetIds:e.targets.map(e=>e.targetId),targetUsers:e.targetUsers??[],targetParams:t,priority:e.priority,mediaImage:we(e.media,x(e)),mediaShowTriggerZone:e.media.showTriggerZone===!0,mediaShowSubjectPath:e.media.showSubjectPath===!0,mediaGif:e.media.gif===!0,mediaClip:e.media.clip===!0,mediaProfile:e.media.profile,mediaClipSpeed:e.media.clipSpeed,mediaLinkedCameras:e.media.linkedCameras,templateTitle:e.template?.title??``,templateBody:e.template?.body??``,...wn(e.conditions),schedule:e.schedule,systemEventDelivery:e.systemEventDelivery,snoozeAllowGlobal:e.snoozeAllowGlobal===!0,groupingSec:e.groupingSec,snoozeOptions:e.snoozeOptions,askVerdict:e.askVerdict,actions:un(e.actions),cooldownSec:e.throttle.cooldownSec,cooldownScope:e.throttle.scope,cooldownGranularity:e.throttle.granularity}}function An(e,t){let n=[];if(Ln(e)){let r=e.groupingSec;r!==void 0&&(!Number.isInteger(r)||r<5||r>60)&&n.push(`The grouping window is a whole number of seconds between 5 and 60.`);let i=t?.confirm;i?.enabled===!0&&i.expect!==void 0&&!Rn(i.expect)&&n.push(`This rule’s AI confirm expects more than one subject, but a grouped message judges one picture per subject, so it would never send. Remove the confirm expectation (viewer or API), or choose Immediate.`)}if(me(e.conditions.audio)&&n.push(`This sound rule names neither a sound nor a level threshold, so it can never fire — every sample would count as a hit and the engine refuses it rather than notifying on silence. Pick at least one sound, or add a level.`),(!Number.isInteger(e.cooldownSec)||e.cooldownSec<0||e.cooldownSec>86400)&&n.push(`The cooldown is a whole number of seconds between 0 and ${String(ht)} (24 hours). 0 means every match is delivered.`),Y(e))for(let t of fe({delivery:e.delivery,conditions:e.conditions,...e.systemEventDelivery===void 0?{}:{systemEventDelivery:e.systemEventDelivery},...J(e.actions)===void 0?{}:{actions:J(e.actions)}}))n.push(p(t));return n}function jn(e){let t=e.systemEventDelivery;if(t===void 0)return{};if(!S(e.delivery))return t.mode===`summary`?{systemEventDelivery:{mode:`instant`}}:{};if(t.mode===`summary`&&ue(t.schedule)===null){let e=b(t.schedule);if(e!==null&&e.times.length>0)return{systemEventDelivery:{...t,schedule:Ce(e.times,t.schedule.timezone)}}}return{systemEventDelivery:t}}function Mn(e){if(!Y(e))return null;if(!ae(e.templateBody))return D.t(`helpers.ruleFormState.summaryWarnNone`,{token:`{{summaryText}}`});let t=e.templateBody;return(e.systemEventDelivery?.mode===`summary`?e.systemEventDelivery.split:void 0)===`section`&&t.trim().length>0&&!/\{\{\s*summaryText\s*\}\}/.test(t)?D.t(`helpers.ruleFormState.summaryWarnSplit`,{token:`{{summaryText}}`}):null}function Y(e){return S(e.delivery)&&e.systemEventDelivery?.mode===`summary`}function Nn(e,t,n=new Set){return An(e,t).length===0&<(e.delivery)&&(!S(e.delivery)||Hn(e)>0)&&x(e)!==`mixed`&&e.name.trim().length>0&&(e.targetIds.length>0||e.targetUsers.length>0)&&dn(e.actions,n).length===0}function Pn(e,t){let n=Bn(e.conditions,t);return S(t)&&(n.systemEvent?.kinds.length??0)===0?{...e,delivery:t,conditions:{...n,systemEvent:V(`device-events`)}}:{...e,delivery:t,conditions:n}}function Fn(e,t){return t===`immediate-grouped`?{...Pn(e,`immediate`),groupingSec:e.groupingSec??20}:{...Pn(e,t),groupingSec:void 0}}function In(e){return e.delivery===`immediate`||e.delivery===`track-end`}function Ln(e){return e.groupingSec!==void 0&&w(e)}function Rn(e){switch(e.op){case`>`:return 1>e.count;case`<=`:return 1<=e.count;case`<`:return 1<e.count;case`==`:return e.count===1;default:return 1>=e.count}}var zn=new Set([`immediate`,`track-end`,`package-event`]);function Bn(e,t){if(e.source!==`pipeline`||zn.has(t))return e;let{source:n,...r}=e;return r}function Vn(e,t){return he(e.conditions.systemEvent)===t?e:{...e,conditions:{...e.conditions,systemEvent:V(t)}}}function Hn(e){return e.conditions.systemEvent?.kinds.length??0}function X(e,t){return e.appliesTo.includes(t)}var Un={source:`any`};function Wn(e,t){if(t==null)return!0;if(Array.isArray(t))return t.length===0;if(typeof t==`string`)return t.length===0||Un[e]===t;if(typeof t==`number`)return!Number.isFinite(t);if(typeof t==`object`){if(`ids`in t){let e=t.ids;return!Array.isArray(e)||e.length===0}if(`values`in t){let e=t.values;return!Array.isArray(e)||e.length===0}return!1}return!1}var Gn=ce.filter(e=>e.id===`audio`);function Kn(e){if(e.length===0)return e;let t=new Set(e.map(e=>e.id)),n=Gn.filter(e=>!t.has(e.id));return n.length===0?e:[...e,...n]}function qn(e,t,n,r=x({delivery:t,conditions:e})){let i=n.length===0?null:new Set(n.filter(e=>e.id!==`schedule`&&Ee(e,t,r)).map(e=>e.id)),a={};for(let[t,n]of Object.entries(e))i!==null&&!i.has(t)||I(t,e)&&(Wn(t,n)||(a[t]=n));return a}function Jn(e,t){if(e===void 0)return{};let n=qt(e,t.systemEvent);return n===void 0?{}:{systemEvent:n}}function Yn(e){return e!==void 0&&e.windows.length>0}function Xn(e){let t={...e.clipPreRollSec===void 0?{}:{clipPreRollSec:e.clipPreRollSec},...e.clipPostRollSec===void 0?{}:{clipPostRollSec:e.clipPostRollSec}};return Object.keys(t).length>0?t:void 0}function Zn(e){let t=Xn(e.media);return{...e.confirm===void 0?{}:{confirm:e.confirm},...t===void 0?{}:{media:t}}}function Qn(e,t,n=[]){let r=e.templateTitle.trim(),i=e.templateBody.trim(),a=r.length>0||i.length>0?{...r.length>0?{title:r}:{},...i.length>0?{body:i}:{}}:void 0,o=J(e.actions),s=x(e),c=C(s),l=ke(s),u=n.length===0?!0:n.some(t=>t.id===`schedule`&&X(t,e.delivery)),d=!Y(e)&&u&&Yn(e.schedule)?e.schedule:void 0,f=n.length===0?!0:n.some(t=>t.id===`devices`&&X(t,e.delivery)),p=n.length===0?!0:n.some(t=>t.id===`devicesExclude`&&X(t,e.delivery)),{devices:m,devicesExclude:h,...g}=Tn(e),_=qn(g,e.delivery,n,s);return{name:e.name.trim(),enabled:e.enabled,delivery:e.delivery,conditions:{..._,...f&&m!==void 0?{devices:m}:{},...p&&h!==void 0?{devicesExclude:h}:{},...Jn(l,e.conditions)},...d?{schedule:d}:{},...jn(e),targets:e.targetIds.map(t=>{let n=e.targetParams[t];return n&&Object.keys(n).length>0?{targetId:t,params:n}:{targetId:t}}),...e.targetUsers.length>0?{targetUsers:[...e.targetUsers]}:{},media:c.carriesMedia?{image:e.mediaImage,...e.mediaShowTriggerZone&&e.mediaImage!==`crop`&&e.mediaImage!==`none`&&Oe(_).length>0?{showTriggerZone:!0}:{},...e.mediaShowSubjectPath&&e.mediaImage!==`none`&&ye(s)?{showSubjectPath:!0}:{},...e.mediaGif?{gif:!0}:{},...e.mediaClip?{clip:!0}:{},...e.mediaProfile===void 0?{}:{profile:e.mediaProfile},...e.mediaClipSpeed===void 0?{}:{clipSpeed:e.mediaClipSpeed},...s===`sensor`&&e.mediaImage!==`none`&&e.mediaLinkedCameras!==void 0?{linkedCameras:e.mediaLinkedCameras}:{},...(e.mediaGif||e.mediaClip)&&t?.media?.clipPreRollSec!==void 0?{clipPreRollSec:t.media.clipPreRollSec}:{},...(e.mediaGif||e.mediaClip)&&t?.media?.clipPostRollSec!==void 0?{clipPostRollSec:t.media.clipPostRollSec}:{}}:{image:`none`},throttle:{cooldownSec:e.cooldownSec,scope:e.cooldownScope,...e.cooldownGranularity===void 0?{}:{granularity:e.cooldownGranularity}},priority:e.priority,...a?{template:a}:{},...e.snoozeAllowGlobal?{snoozeAllowGlobal:!0}:{},...Ln(e)?{groupingSec:e.groupingSec}:{},...e.snoozeOptions===void 0?{}:{snoozeOptions:[...e.snoozeOptions]},...e.askVerdict!==void 0&&In(e)?{askVerdict:e.askVerdict}:{},...t?.confirm===void 0?{}:{confirm:t.confirm},...o===void 0?{}:{actions:o}}}function $n(e,t){let n=Qn(e,void 0,t);return[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`groupingSec`,`actions`].filter(e=>n[e]===void 0)}var er=[{key:`rule`,get label(){return D.t(`helpers.ruleFormTabs.tab_rule`)},fields:[`name`,`enabled`,`delivery`,`groupingSec`,`targetIds`,`targetUsers`,`targetParams`]},{key:`devices`,get label(){return D.t(`helpers.ruleFormTabs.tab_devices`)},fields:[`deviceScope`]},{key:`conditions`,get label(){return D.t(`helpers.ruleFormTabs.tab_conditions`)},fields:[`conditions`,`classScope`,`schedule`,`systemEventDelivery`]},{key:`notification`,get label(){return D.t(`helpers.ruleFormTabs.tab_notification`)},fields:[`priority`,`mediaImage`,`mediaShowTriggerZone`,`mediaShowSubjectPath`,`mediaGif`,`mediaClip`,`mediaProfile`,`mediaClipSpeed`,`mediaLinkedCameras`,`templateTitle`,`templateBody`]},{key:`actions`,get label(){return D.t(`helpers.ruleFormTabs.tab_actions`)},fields:[`actions`]},{key:`advanced`,get label(){return D.t(`helpers.ruleFormTabs.tab_advanced`)},fields:[`snoozeAllowGlobal`,`snoozeOptions`,`askVerdict`,`cooldownSec`,`cooldownScope`,`cooldownGranularity`]}];function tr(e,t={}){let n=x({delivery:e,conditions:t}),r=C(n),i=er.map(e=>e.key===`conditions`?{...e,label:r.label}:e);return Se(n)?i.filter(e=>e.key!==`devices`):i}function nr(e){if(e.audio!==void 0)return D.t(`helpers.ruleFormTabs.condSound`);if(e.occupancy!==void 0)return D.t(`helpers.ruleFormTabs.condOccupancy`)}function rr(e){let t=x(e),n=Te(Tn(e),t);return t===`sensor`&&e.conditions.sensorTransition!==void 0&&!I(`sensorTransition`,e.conditions)?[...n,{conditionId:`sensorTransition`,reason:ne}]:n}var ir=`rule`;function ar(e){return er.find(t=>t.key===e)?.key}function or(e){return e?.toLowerCase().startsWith(`it`)===!0?`it`:`en`}function sr(){let{i18n:e}=O(),t=or(e.language);return e=>ee(e,t)}i();var cr=`block text-[11px] font-medium text-foreground`,Z=`text-[10px] text-foreground-subtle mt-0.5`;function lr({cameras:e,fleet:t,value:r,onChange:i,emptyMeansAll:a=!1,savedHadDevices:o=!1}){return n(Ne,{devices:e,listState:t.state,fleet:t,value:r,onChange:i,emptyMeansAll:a,savedHadDevices:o})}function Q({value:t,placeholder:i,onChange:a}){let{t:o}=O(),[s,c]=r(``),l=()=>{let e=s.trim();if(e.length===0||t.includes(e)){c(``);return}a([...t,e]),c(``)},d=e=>a(t.filter(t=>t!==e));return e(`div`,{className:`mt-1 space-y-1.5`,children:[t.length>0&&n(`div`,{className:`flex flex-wrap gap-1`,children:t.map(t=>e(`span`,{className:`inline-flex items-center gap-1 rounded bg-surface-hover px-1.5 py-0.5 text-[11px] text-foreground`,children:[t,n(`button`,{type:`button`,onClick:()=>d(t),"aria-label":o(`system.notificationConditionWidgets.remove`,`remove {{v}}`,{v:t}),className:`text-foreground-subtle hover:text-danger`,children:n(u,{className:`h-3 w-3`})})]},t))}),n(E,{value:s,placeholder:i,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l())},onBlur:l})]})}function ur({picker:r,value:i,onChange:a}){let{t:o}=O(),s=t(()=>le(r),[r]),c=t(()=>new Set(i),[i]),l=i.filter(e=>!s.has(e)),u=e=>{a(c.has(e)?i.filter(t=>t!==e):[...i,e])};return e(`div`,{className:`space-y-2`,children:[l.length>0&&n(`div`,{className:`flex flex-wrap gap-1`,children:l.map(t=>e(`button`,{type:`button`,onClick:()=>a(i.filter(e=>e!==t)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:o(`system.notificationConditionWidgets.customValueClickToRemove`,`Custom value — click to remove`),children:[t,` ×`]},t))}),r.groups.map(t=>e(`div`,{children:[n(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-muted mb-1`,children:t.fallbackLabel}),n(`div`,{className:`flex flex-wrap gap-1`,children:t.options.map(e=>{let t=c.has(e.value);return n(`button`,{type:`button`,"aria-pressed":t,onClick:()=>u(e.value),className:t?`rounded border border-primary bg-primary/15 px-1.5 py-0.5 text-[10px] text-foreground`:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,children:e.label},e.value)})})]},t.key))]})}function dr({value:t,min:r,max:i,step:a,onChange:o}){let{t:s}=O();return e(`div`,{className:`mt-1 flex items-center gap-2`,children:[n(E,{type:`number`,value:t??``,min:r,max:i,step:a,className:`max-w-[8rem]`,onChange:e=>{let t=e.target.value;if(t===``){o(void 0);return}let n=Number(t);o(Number.isFinite(n)?n:void 0)}}),t!==void 0&&i!==void 0&&n(`input`,{type:`range`,min:r,max:i,step:a,value:t,onChange:e=>o(Number(e.target.value)),className:`flex-1 accent-primary`,"aria-label":s(`common.valueWord`)})]})}function fr({value:t,onChange:r,options:i}){let{t:a}=O(),o=pr(i??[]),s=o.length>0?o:kt;return e(`div`,{className:`mt-1 space-y-1`,children:[n(T,{value:t??`enter`,options:s.map(e=>({value:e.value,label:a(`notificationRules.crossing.${e.value}`,e.label)})),onChange:e=>r(L(e.target.value))}),n(`p`,{className:Z,children:a(`notificationRules.crossing.hint`,`Which way the subject crosses the zone.`)})]})}function pr(e){let t=[];for(let n of e){let e=n.value===``||n.value===`enter`?At:L(n.value);e===void 0||t.some(t=>t.value===e)||t.push({value:e,label:n.label})}return t}function mr({deviceIds:e,cameras:t,value:r,onChange:i}){let{options:a,loading:o}=A(e,t);return n(j,{options:a,value:r,onChange:i,loading:o,noFreeText:!0,emptyHint:e.length===0?`Select cameras first — a rule can only use zones those cameras actually have.`:`The selected cameras have no zones. Draw one in the camera’s zone editor first.`,placeholder:``})}function hr({deviceIds:e,value:t,onChange:r}){let{t:i}=O(),{options:a,loading:o}=Qe(e);return n(j,{options:a,value:t,onChange:r,loading:o,emptyHint:e.length===0?`Select cameras above to pick their event kinds — or type a token.`:`No event kinds reported for the selected cameras — type a token.`,placeholder:i(`system.notificationConditionWidgets.eventToken`,`Event token…`)})}var gr=[{value:`became-occupied`,labelKey:`system.notificationConditionWidgets.opBecameOccupied`},{value:`became-free`,labelKey:`system.notificationConditionWidgets.opBecameFree`},{value:`>=`,labelKey:`system.notificationConditionWidgets.opCountAtLeast`},{value:`<=`,labelKey:`system.notificationConditionWidgets.opCountAtMost`}];function _r(e,t){let n=e.map(e=>({value:e.value,label:e.label}));return t===void 0||t===``||n.some(e=>e.value===t)?n:[...n,{value:t,label:D.t(`system.notificationConditionWidgets.subTypeNeverCountsAlways`,`{{stored}} — sub-type, never counts (always 0)`,{stored:t})}]}function vr({deviceIds:t,cameras:r,classOptions:i,value:a,onChange:o}){let{t:s}=O(),{options:c,loading:l}=A(t,r),u=a??xe,d=e=>o({...u,...e}),f=u.op===`became-occupied`||u.op===`became-free`,p=_r(i,u.className);return e(`div`,{className:`mt-1 space-y-1.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[n(`div`,{className:`min-w-[10rem]`,children:n(T,{value:u.zoneId??``,options:[{value:``,label:l?s(`system.notificationConditionWidgets.loadingZones`,`Loading zones…`):s(`system.notificationConditionWidgets.wholeFrame`,`— whole frame —`)},...c.map(e=>({value:e.value,label:e.label}))],onChange:e=>d({zoneId:e.target.value===``?void 0:e.target.value})})}),n(`div`,{className:`min-w-[9rem]`,children:n(T,{value:u.className??``,options:[{value:``,label:s(`system.notificationConditionWidgets.anyClass`,`— any class —`)},...p],onChange:e=>d({className:e.target.value===``?void 0:e.target.value})})}),n(`div`,{className:`min-w-[9rem]`,children:n(T,{value:u.op,options:gr.map(e=>({value:e.value,label:s(e.labelKey)})),onChange:e=>{let t=gr.find(t=>t.value===e.target.value);t&&d({op:t.value})}})})]}),e(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[e(`label`,{className:`flex items-center gap-1`,children:[f?s(`system.notificationConditionWidgets.threshold`,`Threshold`):s(`system.notificationConditionWidgets.count`,`Count`),n(E,{type:`number`,min:0,className:`w-16`,value:String(u.count),onChange:e=>d({count:Math.max(0,Number(e.target.value)||0)})})]}),e(`label`,{className:`flex items-center gap-1`,children:[s(`system.notificationConditionWidgets.holdFor`,`Hold for`),n(E,{type:`number`,min:0,max:3600,className:`w-16`,value:String(u.sustainSeconds),onChange:e=>d({sustainSeconds:Math.min(3600,Math.max(0,Number(e.target.value)||0))})}),`s`]}),a===void 0?null:n(`button`,{type:`button`,onClick:()=>o(void 0),className:`underline hover:text-foreground`,children:s(`system.notificationConditionWidgets.clear`,`Clear`)})]}),t.length===0&&n(`p`,{className:`text-[11px] text-warning`,children:s(`system.notificationConditionWidgets.noCameraPickedOnThe`,`No camera picked on the Devices tab: this watches EVERY camera's occupancy, and no zone can be offered until you choose one — a zone id belongs to a camera.`)}),n(`p`,{className:`text-[11px] text-foreground-subtle`,children:s(`system.notificationConditionWidgets.countsConfirmedTrackedObjectsFrom`,`Counts confirmed tracked objects from zone analytics. The change must hold for the sustain window before it fires; with no snapshot for the camera or zone the rule never fires.`)})]})}var yr=[{value:`label`,labelKey:`system.notificationConditionWidgets.audioModeLabel`,Icon:f},{value:`level`,labelKey:`system.notificationConditionWidgets.audioModeLevel`,Icon:d}];function br({taxonomy:t,value:r,onChange:i}){let{t:a}=O(),s=_e(r),c=e=>i(ge(r,e)),{choices:l,unknownLabels:u}=Ae(t,s.labels),d=h(r)??`label`;return e(`div`,{className:`mt-1 space-y-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[yr.map(t=>n(`button`,{type:`button`,"aria-pressed":d===t.value,onClick:()=>c({mode:t.value}),className:`rounded border px-2 py-0.5 text-[11px] ${d===t.value?`border-primary bg-primary/15 text-foreground`:`border-border text-foreground-subtle hover:bg-surface-hover`}`,children:e(`span`,{className:`inline-flex items-center gap-1`,children:[n(t.Icon,{className:`h-3 w-3`}),a(t.labelKey)]})},t.value)),r===void 0?null:n(`button`,{type:`button`,onClick:()=>i(void 0),className:`ml-1 text-xs text-foreground-subtle underline hover:text-foreground`,children:a(`system.notificationConditionWidgets.clear`,`Clear`)})]}),d===`label`?e(o,{children:[n(`div`,{className:`flex flex-wrap gap-1`,children:l.map(t=>{let r=ie(s.labels,t.value),i=t.unknown?`border-dashed border-warning text-warning`:r?`border-primary bg-primary/15 text-foreground`:`border-border text-foreground hover:bg-surface-hover`;return n(`button`,{type:`button`,"aria-pressed":r,title:t.unknown?a(`system.notificationConditionWidgets.storedByTheRuleNot`,`Stored by the rule — not offered by this hub`):void 0,onClick:()=>c({labels:ve(s.labels,t.value)}),className:`rounded border px-1.5 py-0.5 text-[10px] ${i}`,children:e(`span`,{className:`inline-flex items-center gap-1`,children:[n(Fe,{iconId:t.iconId,size:12}),t.label]})},t.value)})}),u.length>0&&e(`p`,{className:`text-[10px] text-warning`,children:[a(`system.notificationConditionWidgets.keptFromTheRuleUnknown`,`Kept from the rule, unknown to this hub:`),` `,u.join(`, `)]}),e(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[e(`label`,{className:`flex items-center gap-1`,children:[a(`system.notificationConditionWidgets.confirmAfter`,`Confirm after`),n(E,{type:`number`,min:1,max:20,step:1,className:`w-16`,value:String(s.confirmHits??2),onChange:e=>c({confirmHits:Number(e.target.value)})}),a(`system.notificationConditionWidgets.frames`)]}),e(`label`,{className:`flex items-center gap-1`,children:[a(`system.notificationConditionWidgets.within`),n(E,{type:`number`,min:1,max:60,step:1,className:`w-16`,value:String(s.confirmWindowSec??5),onChange:e=>c({confirmWindowSec:Number(e.target.value)})}),`s`]})]}),n(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`system.notificationConditionWidgets.audioConfirmHint`,{hits:2,window:5})})]}):e(o,{children:[n(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:e(`label`,{className:`flex items-center gap-1`,children:[a(`system.notificationConditionWidgets.louderThan`,`Louder than`),n(E,{type:`number`,min:te,max:0,step:3,className:`w-20`,value:String(s.dbThreshold??oe),onChange:e=>c({dbThreshold:Number(e.target.value)})}),`dBFS`]})}),e(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[e(`label`,{className:`flex items-center gap-1`,children:[a(`system.notificationConditionWidgets.hits`,`Hits`),n(E,{type:`number`,min:1,max:100,step:5,className:`w-16`,value:String(s.hitPercent),onChange:e=>c({hitPercent:Number(e.target.value)})}),a(`system.notificationConditionWidgets.hitsPercentDefault`,{value:y.hitPercent})]}),e(`label`,{className:`flex items-center gap-1`,children:[a(`system.notificationConditionWidgets.over`),n(E,{type:`number`,min:1,max:300,step:5,className:`w-16`,value:String(s.samplingSeconds),onChange:e=>c({samplingSeconds:Number(e.target.value)})}),a(`system.notificationConditionWidgets.secondsDefault`,{value:y.samplingSeconds})]})]}),n(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`system.notificationConditionWidgets.dbfsHint`,{min:te})})]}),me(r)?n(`p`,{className:`text-[11px] text-warning`,children:a(`system.notificationConditionWidgets.withNeitherASoundNor`,`With neither a sound nor a level threshold this can never match — every sample would be a hit, so the engine refuses it rather than notifying on silence.`)}):null]})}function xr({value:t,onChange:r}){let{t:i}=O(),a=t?.values??[],o=t?.maxDistance??1,s=e=>r(e.length>0?{values:e,maxDistance:o}:void 0),c=e=>r(a.length>0?{values:a,maxDistance:e}:void 0),l=et().filter(e=>!a.includes(e));return e(`div`,{className:`mt-1 space-y-1.5`,children:[n(Q,{value:a,placeholder:i(`system.notificationConditionWidgets.plateText`,`Plate text…`),onChange:s}),l.length>0&&e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[n(`span`,{className:`text-[10px] text-foreground-subtle`,children:i(`system.notificationConditionWidgets.seen`,`Seen:`)}),l.slice(0,12).map(e=>n(`button`,{type:`button`,onClick:()=>s([...a,e]),className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:e},e))]}),e(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(`system.notificationConditionWidgets.maxDistance`,`Max distance`),n(E,{type:`number`,min:0,max:3,step:1,value:o,className:`max-w-[5rem]`,onChange:e=>{let t=Number(e.target.value);c(Number.isFinite(t)?Math.max(0,Math.min(3,t)):1)}})]})]})}function Sr({gateable:t,value:r,onChange:i}){let{t:a}=O(),o=sr(),s=t.find(e=>e.id===r?.deviceId),c=new Set(r?.states??[]),l=e=>{let t=Number(e);if(!Number.isFinite(t)||t===0)return i(void 0);i({deviceId:t,states:[]})},u=e=>{if(r===void 0)return;let t=new Set(c);t.has(e)?t.delete(e):t.add(e),i(t.size===0?void 0:{deviceId:r.deviceId,states:[...t]})};return e(`div`,{className:`mt-1 space-y-2`,children:[n(T,{value:r===void 0?``:String(r.deviceId),options:[{value:``,label:a(`system.notificationConditionWidgets.noDeviceGate`,`— no device gate —`)},...t.map(e=>({value:String(e.id),label:e.name}))],onChange:e=>l(e.target.value)}),s!==void 0&&n(`div`,{className:`flex flex-wrap gap-1.5`,children:s.states.map(e=>n(`button`,{type:`button`,onClick:()=>u(e),className:c.has(e)?`rounded-md border border-primary bg-primary/10 px-2 py-0.5 text-[11px] text-primary`:`rounded-md border border-border px-2 py-0.5 text-[11px] text-foreground-subtle`,children:o(e)},e))}),s!==void 0&&s.states.length===0&&n(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:a(`system.notificationConditionWidgets.thisDeviceReportsNoState`,`This device reports no state the gate can read, so it cannot arm a rule.`)}),r!==void 0&&n(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:a(`system.notificationConditionWidgets.theRuleIsSilentWhile`,`The rule is silent while the device is in any other state — including when its state cannot be read at all.`)})]})}function Cr(e,t){let n=t(e.verdict);return e.latched?`${n} · ${t(`latched`)}`:n}function wr({scenes:t,value:r,onChange:i}){let{t:a}=O(),o=sr(),s=t.find(e=>e.sceneId===r?.sceneId),c=e=>{if(e===``)return i(void 0);let n=t.find(t=>t.sceneId===e);if(n===void 0)return i(void 0);i({sceneId:e,deviceId:n.deviceId,requiredState:r?.requiredState??`diverged`,...r?.latched===void 0?{}:{latched:r.latched}})},l=e=>{r!==void 0&&i({...r,requiredState:e===`matched`?`matched`:`diverged`})},u=e=>{if(r!==void 0){if(e===``){let{latched:e,...t}=r;return i(t)}i({...r,latched:e===`latched`})}};return t.length===0?n(`p`,{className:Z,children:a(`notificationRules.scene.none`,`No scenes yet — create one on the Scenes page.`)}):e(`div`,{className:`mt-1 space-y-2`,children:[n(T,{value:r?.sceneId??``,options:[{value:``,label:a(`notificationRules.scene.noGate`,`— no scene gate —`)},...t.map(e=>({value:e.sceneId,label:`${e.cameraName} · ${e.label} — ${Cr(e,o)}`}))],onChange:e=>c(e.target.value)}),r!==void 0&&e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[a(`notificationRules.scene.onlyWhile`,`Only while it is`),n(T,{value:r.requiredState,options:[{value:`diverged`,label:o(`diverged`)},{value:`matched`,label:o(`matched`)}],onChange:e=>l(e.target.value)})]}),e(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[a(`notificationRules.scene.read`,`Read`),n(T,{value:r.latched===void 0?``:r.latched?`latched`:`live`,options:[{value:``,label:s===void 0?a(`notificationRules.scene.readOwn`,`The scene's own setting`):`${a(`notificationRules.scene.readOwn`,`The scene's own setting`)} (${o(s.emit)})`},{value:`latched`,label:o(`latched`)},{value:`live`,label:o(`live`)}],onChange:e=>u(e.target.value)})]})]}),s!==void 0&&e(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:[a(`notificationRules.scene.rightNow`,`Right now:`),` `,Cr(s,o)]}),r!==void 0&&s===void 0&&n(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:a(`notificationRules.scene.missing`,`This scene no longer exists — pick another or remove the gate.`)})]})}var $={days:[0,1,2,3,4,5,6],minute:480},Tr=[{value:1,get label(){return D.t(`helpers.notificationSystemEventDelivery.wd_mon`)}},{value:2,get label(){return D.t(`helpers.notificationSystemEventDelivery.wd_tue`)}},{value:3,get label(){return D.t(`helpers.notificationSystemEventDelivery.wd_wed`)}},{value:4,get label(){return D.t(`helpers.notificationSystemEventDelivery.wd_thu`)}},{value:5,get label(){return D.t(`helpers.notificationSystemEventDelivery.wd_fri`)}},{value:6,get label(){return D.t(`helpers.notificationSystemEventDelivery.wd_sat`)}},{value:0,get label(){return D.t(`helpers.notificationSystemEventDelivery.wd_sun`)}}];function Er(e){let t=Math.floor(e/60),n=e%60;return`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`}function Dr(e){let[t,n]=e.split(`:`),r=Number(t)*60+Number(n);return Number.isFinite(r)?Math.max(0,Math.min(1439,r)):0}function Or(e){if(typeof e!=`object`||!e||!(`data`in e))return;let t=e.data;if(!(typeof t!=`object`||!t||!(`code`in t)))return typeof t.code==`string`?t.code:void 0}function kr(e){let t=Object.entries(e).map(([e,t])=>`${e} ${String(t)}`);return t.length>0?D.t(`helpers.notificationSystemEventDelivery.dropped`,{parts:t.join(`, `)}):null}function Ar(e,t,n,r=`rule`){if(e===`error`)return Or(n)===`NOT_FOUND`?{lines:[`This hub does not serve summary rules yet — update @camstack/server first. A rule saved now would be stored without its summary, and stay instant.`]}:{lines:[`The preview could not be read: ${n instanceof Error?n.message:String(n)}`]};if(e!==`success`||t===void 0)return null;let i=[];if(r===`section`&&t.split===void 0&&i.push(`This hub does not send per-category summaries yet — update @camstack/server first. Until then it sends one message.`),t.empty)i.push(`Nothing to report right now — no notification would be sent.`);else if(t.split===`section`&&t.rows!==void 0){let e=t.rows.length;i.push(`${String(e)} notification${e===1?``:`s`} would be sent now, one per category:`);for(let e of t.rows)i.push(`${e.title}\n${e.text}`)}else i.push(`${String(t.count)} item(s) would be sent now:\n${t.text}`);let a=kr(t.dropped);return a!==null&&i.push(a),t.excludedGroups.includes(`backups-exports`)&&i.push(`Backups and exports are completed jobs, not a state — they are not in a summary.`),{lines:i}}function jr(e,t){return{...e,schedule:t}}function Mr(e,t){let{split:n,...r}=e;return t===`section`?{...r,split:t}:r}function Nr(e){return Er(e)}function Pr(e){return Dr(e)}function Fr(){return{days:[1,2,3,4,5],startMinute:540,endMinute:1080}}function Ir(e){return{days:[...$.days],minute:e}}var Lr=`Always active — add a window to restrict when the rule fires.`;function Rr({value:e,onChange:t,mode:r=`windows`,defaultMinute:i=$.minute,emptyHint:a}){return r===`times`?n(Br,{value:e,onChange:t,defaultMinute:i}):n(zr,{value:e,onChange:t,emptyHint:a??Lr})}function zr({value:t,onChange:r,emptyHint:i}){let{t:a}=O(),o=t?.windows??[],s=t?.invert??!1,l=(e,n)=>{if(e.length===0){r(void 0);return}r({windows:e,...n?{invert:!0}:{},...t?.timezone?{timezone:t.timezone}:{}})},u=()=>l([...o,Fr()],s),d=e=>l(o.filter((t,n)=>n!==e),s),f=(e,t)=>l(o.map((n,r)=>r===e?t:n),s);return e(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-windows`,children:[o.length===0?n(`p`,{className:Z,children:i}):o.map((e,t)=>n(Vr,{window:e,onChange:e=>f(t,e),onRemove:()=>d(t)},t)),e(`div`,{className:`flex items-center gap-3`,children:[e(`button`,{type:`button`,onClick:u,className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[n(c,{className:`h-3 w-3`}),` `,a(`system.notificationScheduleField.addWindow`)]}),o.length>0&&e(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[n(`input`,{type:`checkbox`,checked:s,onChange:e=>l([...o],e.target.checked),className:`accent-primary`}),a(`system.notificationScheduleField.activeOutsideTheWindows`,`Active outside the windows`)]})]})]})}function Br({value:t,onChange:r,defaultMinute:i}){let{t:a}=O(),o=t?.timezone,s=t===void 0?{times:[],approximated:!1}:b(t);if(s===null)return e(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times-fallback`,children:[n(`p`,{className:Z,children:a(`system.notificationScheduleField.invertedScheduleShownAsBands`,`Inverted schedule — shown as bands. Clear the invert flag (or the windows) to author punctual times.`)}),n(zr,{value:t,onChange:r,emptyHint:Lr})]});let l=s.times,u=e=>{if(e.length===0){r(void 0);return}r(Ce(e,o))};return e(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times`,children:[s.approximated&&n(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,"data-testid":`schedule-field-times-approximated`,children:a(`system.notificationScheduleField.shownAsSendAtTimes`,`Shown as send-at times from each window's end (when the summary fires). Edit or save to store them as punctual one-minute windows.`)}),l.length===0?n(`p`,{className:Z,children:a(`system.notificationScheduleField.noTimesYetAddOne`,`No times yet — add one to send on those days at that clock time.`)}):l.map((e,t)=>n(Hr,{time:e,index:t,onChange:e=>u(l.map((n,r)=>r===t?e:n)),onRemove:l.length>1?()=>u(l.filter((e,n)=>n!==t)):void 0},t)),e(`button`,{type:`button`,onClick:()=>u([...l,Ir(i)]),className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,"data-testid":`schedule-field-add-time`,children:[n(c,{className:`h-3 w-3`}),` `,a(`system.notificationScheduleField.addTime`)]})]})}function Vr({window:t,onChange:r,onRemove:i}){let{t:a}=O();return e(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[e(`div`,{className:`flex items-center gap-2 text-xs`,children:[n(`input`,{type:`time`,value:Nr(t.startMinute),onChange:e=>r({...t,startMinute:Pr(e.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),n(`span`,{className:`text-foreground-subtle`,children:`→`}),n(`input`,{type:`time`,value:Nr(t.endMinute),onChange:e=>r({...t,endMinute:Pr(e.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),n(`span`,{className:`flex-1`}),n(`button`,{type:`button`,onClick:i,"aria-label":a(`system.notificationScheduleField.removeWindow`,`Remove window`),className:`text-foreground-subtle hover:text-danger`,children:n(s,{className:`h-3.5 w-3.5`})})]}),n(Ur,{days:t.days,onToggle:e=>{let n=t.days.includes(e)?t.days.filter(t=>t!==e):[...t.days,e];n.length!==0&&r({...t,days:n})}})]})}function Hr({time:t,index:r,onChange:i,onRemove:a}){let{t:o}=O();return e(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[e(`div`,{className:`flex items-center gap-2 text-xs`,children:[n(`span`,{className:`text-foreground-subtle`,children:o(`system.notificationScheduleField.at`,`At`)}),n(`input`,{type:`time`,value:Er(t.minute),onChange:e=>i({...t,minute:Dr(e.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`,"data-testid":`schedule-field-time-${String(r)}`}),n(`span`,{className:`flex-1`}),a!==void 0&&n(`button`,{type:`button`,onClick:a,"aria-label":o(`system.notificationScheduleField.removeTime`,`Remove time`),className:`text-foreground-subtle hover:text-danger`,children:n(s,{className:`h-3.5 w-3.5`})})]}),n(Ur,{days:t.days,onToggle:e=>{let n=t.days.includes(e)?t.days.filter(t=>t!==e):[...t.days,e];n.length!==0&&i({...t,days:n})}})]})}function Ur({days:e,onToggle:t}){return n(`div`,{className:`flex flex-wrap gap-1`,children:Tr.map(r=>n(`button`,{type:`button`,onClick:()=>t(r.value),className:`rounded px-1.5 py-0.5 text-[10px] ${e.includes(r.value)?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:r.label},r.value))})}export{dn as $,ot as $t,vn as A,Et as At,Dn as B,lt as Bt,ar as C,Nt as Ct,Zn as D,tt as Dt,Qn as E,vt as Et,Cn as F,I as Ft,gn as G,_t as Gt,yn as H,ft as Ht,Nn as I,gt as It,J,at as Jt,K,xt as Kt,Sn as L,rt as Lt,Vn as M,ut as Mt,On as N,Dt as Nt,Kn as O,N as Ot,En as P,Tt as Pt,hn as Q,Ot as Qt,Y as R,it as Rt,rr as S,F as St,$n as T,ht as Tt,Mn as U,wt as Ut,kn as V,dt as Vt,In as W,Pt as Wt,pn as X,Ct as Xt,fn as Y,st as Yt,mn as Z,St as Zt,Q as _,Ze as _n,Wt as _t,Mr as a,Ie as an,on as at,ir as b,Gt as bt,lr as c,ze as cn,nn as ct,Z as d,We as dn,$t as dt,j as en,en as et,cr as f,Ye as fn,Xt as ft,wr as g,qe as gn,Vt as gt,xr as h,Le as hn,Qt as ht,jr as i,Ve as in,W as it,Fn as j,jt,_n as k,P as kt,Sr as l,Ge as ln,Yt as lt,vr as m,Be as mn,Zt as mt,$ as n,A as nn,sn as nt,br as o,Je as on,rn as ot,dr as p,Ue as pn,Jt as pt,q,yt as qt,Ar as r,Ke as rn,cn as rt,fr as s,Re as sn,an as st,Rr as t,$e as tn,G as tt,hr as u,He as un,Ht as ut,ur as v,Xe as vn,B as vt,tr as w,bt as wt,nr as x,Kt as xt,mr as y,R as yt,An as z,Mt as zt};
|
|
1
|
+
import{C as e,K as t,S as n,Y as r,et as i,i as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ht as s,In as c,dt as l,gt as u,la as d,vn as f}from"./player-overlays-DpZIxQHp.js";import{A as p,At as m,Bt as h,Ct as g,Dt as _,E as ee,Ft as te,G as ne,Gr as re,Ht as ie,I as ae,It as oe,K as se,Kr as ce,L as v,Lt as y,M as b,Mt as le,N as ue,Ot as de,P as fe,R as pe,Rt as me,Tt as he,Ut as ge,Vt as _e,Wt as ve,bt as x,dt as ye,eo as be,ft as xe,gt as Se,ht as S,j as Ce,lt as we,mt as Te,pt as Ee,qr as De,ut as Oe,wt as ke,xt as C,yt as w,zt as Ae}from"./client-BvflqtP1.js";import{Pd as T,Ql as je,Ss as Me,U as Ne,eu as Pe,li as Fe,zd as E}from"./src-KDhMZ5Ob.js";import{t as D}from"./i18n-Bg2ooh3q.js";import{t as O}from"./useTranslation-BJr-n0es.js";i();function k(e){return t=>Object.prototype.hasOwnProperty.call(e,t)}var Ie=k({devices:!0}),Le=k({classes:!0,classesExclude:!0,labelEquals:!0,identities:!0,identitiesExclude:!0,eventTypeTokens:!0,sensorKinds:!0}),Re=k({minConfidence:!0,minImportance:!0,minLabelConfidence:!0}),ze=k({minDwellSeconds:!0}),Be=k({source:!0}),Ve=k({crossing:!0}),He=k({packagePhase:!0}),Ue=k({sensorTransition:!0}),We=k({plates:!0}),Ge=k({occupancy:!0}),Ke=k({audio:!0}),qe=k({systemEvent:!0}),Je=k({deviceState:!0}),Ye=k({scene:!0});function Xe(e,t){let n=e[t];return Array.isArray(n)?n:[]}function Ze(e,t){let n=e[t];return typeof n==`number`?n:void 0}function A(e,n){let r=l().trpcClient,i=a({queries:e.map(e=>({queryKey:[[`nc-pickers`,`zones`],{deviceId:e}],staleTime:3e4,queryFn:async()=>({deviceId:e,zones:(await r.zones.listZones.query({deviceId:e})).map(e=>({id:e.id,name:e.name}))})}))});return t(()=>{let e=[],t=new Set;for(let r of i){if(!r.data)continue;let i=n.find(e=>e.id===r.data.deviceId)?.name;for(let n of r.data.zones)t.has(n.id)||(t.add(n.id),e.push({value:n.id,label:n.name,...i===void 0?{}:{hint:i}}))}return{options:e,loading:i.some(e=>e.isLoading),failed:i.some(e=>e.isError)}},[i,n])}function Qe(e){let n=l().trpcClient,r=a({queries:e.map(e=>({queryKey:[[`nc-pickers`,`event-kinds`],{deviceId:e}],staleTime:6e4,queryFn:async()=>(await n.pipelineAnalytics.listEventKinds.query({deviceId:e})).map(e=>({kind:e.kind,label:e.label}))}))});return t(()=>{let e=new Map;for(let t of r)for(let n of t.data??[])e.has(n.kind)||e.set(n.kind,n.label);let t=[...e.entries()].map(([e,t])=>({value:e,label:t}));return t.sort((e,t)=>e.label.localeCompare(t.label)),{options:t,loading:r.some(e=>e.isLoading)}},[r])}function $e(){let e=Me();return t(()=>({options:(e.data??[]).map(e=>({value:e.id,label:e.name})),loading:e.isLoading,failed:e.isError===!0}),[e.data,e.isLoading,e.isError])}function et(){let e=je({limit:200}),n=Pe();return t(()=>{let t=new Set;for(let e of n.data??[])e.name.trim().length>0&&t.add(e.name);let r=new Set;for(let t of e.data??[])t.text.trim().length>0&&r.add(t.text);return[...[...t].sort(),...[...r].sort()]},[e.data,n.data])}function j({options:i,value:a,onChange:o,loading:s,emptyHint:c,placeholder:l,noFreeText:u=!1}){let{t:d}=O(),[f,p]=r(``),m=t(()=>new Set(i.map(e=>e.value)),[i]),h=t(()=>new Set(a),[a]),g=a.filter(e=>!m.has(e)),_=e=>{o(h.has(e)?a.filter(t=>t!==e):[...a,e])},ee=()=>{let e=f.trim();e.length===0||a.includes(e)||(o([...a,e]),p(``))};return e(`div`,{className:`mt-1 space-y-1.5`,children:[g.length>0&&n(`div`,{className:`flex flex-wrap gap-1`,children:g.map(t=>e(`button`,{type:`button`,onClick:()=>o(a.filter(e=>e!==t)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:d(`system.notificationRulePickers.customValueClickToRemove`,`Custom value — click to remove`),children:[t,` ×`]},t))}),i.length>0?n(`div`,{className:`max-h-40 overflow-y-auto rounded-md border border-border divide-y divide-border`,children:i.map(t=>e(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[n(`input`,{type:`checkbox`,checked:h.has(t.value),onChange:()=>_(t.value),className:`accent-primary`}),n(`span`,{className:`flex-1 truncate`,children:t.label}),t.hint!==void 0&&n(`span`,{className:`text-[10px] text-foreground-subtle`,children:t.hint})]},t.value))}):n(`p`,{className:`text-[10px] text-foreground-subtle`,children:s===!0?d(`common.loading`,`Loading…`):c}),!u&&n(`input`,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ee())},placeholder:l,className:`w-full rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground placeholder:text-foreground-subtle`})]})}var M=[{value:`immediate`,get label(){return D.t(`helpers.ruleFormParsers.immediate`)},get hint(){return D.t(`helpers.ruleFormParsers.immediateHint`)}},{value:`track-end`,get label(){return D.t(`helpers.ruleFormParsers.trackEnd`)},get hint(){return D.t(`helpers.ruleFormParsers.trackEndHint`)}},{value:`device-event`,get label(){return D.t(`helpers.ruleFormParsers.deviceEvent`)},get hint(){return D.t(`helpers.ruleFormParsers.deviceEventHint`)}},{value:`package-event`,get label(){return D.t(`helpers.ruleFormParsers.packageEvent`)},get hint(){return D.t(`helpers.ruleFormParsers.packageEventHint`)}},{value:`system-event`,get label(){return D.t(`helpers.ruleFormParsers.systemEvent`)},get hint(){return D.t(`helpers.ruleFormParsers.systemEventHint`)}}],tt=`Immediate, grouped`,nt=M.flatMap(e=>e.value===`immediate`?[e,{value:`immediate-grouped`,get label(){return D.t(`notificationRules.grouping.choice`)},get hint(){return D.t(`helpers.ruleFormParsers.groupedHint`)}}]:[e]);function rt(e){return e.groupingSec!==void 0&&w(e)?`immediate-grouped`:e.delivery}function it(e){let t=(e.delivery===`immediate`||e.delivery===`track-end`)&&w({delivery:`immediate`,conditions:e.conditions});return nt.filter(e=>e.value!==`immediate-grouped`||t)}function at(e){return nt.find(t=>t.value===e)?.value}function ot(e,t=tt){return rt(e)===`immediate-grouped`?`${t} · ${String(e.groupingSec)} s`:ct(e.delivery)}function st(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}function ct(e){return M.find(t=>t.value===e)?.label??e}function lt(e){return M.some(t=>t.value===e)}var ut=[{key:`all`,get label(){return D.t(`helpers.ruleFormParsers.sec_all_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_all_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_all_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_all_empty`)},creatable:!0},{key:`detection`,get label(){return D.t(`helpers.ruleFormParsers.sec_detection_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_detection_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_detection_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_detection_empty`)},creatable:!0},{key:`sensor`,get label(){return D.t(`helpers.ruleFormParsers.sec_sensor_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_sensor_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_sensor_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_sensor_empty`)},creatable:!0},{key:`audio`,get label(){return D.t(`helpers.ruleFormParsers.sec_audio_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_audio_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_audio_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_audio_empty`)},creatable:!0},{key:`occupancy`,get label(){return D.t(`helpers.ruleFormParsers.sec_occupancy_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_occupancy_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_occupancy_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_occupancy_empty`)},creatable:!0},{key:`device-events`,get label(){return D.t(`helpers.ruleFormParsers.sec_deviceEvents_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_deviceEvents_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_deviceEvents_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_deviceEvents_empty`)},creatable:!0},{key:`system`,get label(){return D.t(`helpers.ruleFormParsers.sec_system_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_system_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_system_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_system_empty`)},creatable:!0},{key:`alarm`,get label(){return D.t(`helpers.ruleFormParsers.sec_alarm_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_alarm_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_alarm_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_alarm_empty`)},creatable:!0},{key:`mixed`,get label(){return D.t(`helpers.ruleFormParsers.sec_mixed_label`)},get blurb(){return D.t(`helpers.ruleFormParsers.sec_mixed_blurb`)},get newRuleLabel(){return D.t(`helpers.ruleFormParsers.sec_mixed_new`)},get emptyHint(){return D.t(`helpers.ruleFormParsers.sec_mixed_empty`)},creatable:!1}];function dt(e){return C(x(e)).editable}function ft(e){return Se(pt(e))}function pt(e){switch(e){case`device-events`:case`system`:case`alarm`:case`mixed`:return e;default:return}}var mt=new Map([[0,`helpers.ruleFormParsers.cdNone`],[60,`helpers.ruleFormParsers.cd1m`],[3600,`helpers.ruleFormParsers.cd1h`]]),ht=86400;function gt(e){let t=mt.get(e);return t===void 0?e%3600==0?D.t(`helpers.ruleFormParsers.cdHours`,{count:e/3600}):e%60==0?D.t(`helpers.ruleFormParsers.cdMinutes`,{count:e/60}):D.t(`helpers.ruleFormParsers.cdSeconds`,{count:e}):D.t(t)}function _t(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}var vt=[{value:`rule-device`,get label(){return D.t(`helpers.ruleFormParsers.scopeDevice`)}},{value:`rule`,get label(){return D.t(`helpers.ruleFormParsers.scopeRule`)}}];function yt(e){return vt.find(t=>t.value===e)?.value}var bt=[{value:`per-class`,get label(){return D.t(`helpers.ruleFormParsers.granPerClass`)}},{value:`shared`,get label(){return D.t(`helpers.ruleFormParsers.granShared`)}}];function xt(e){return bt.find(t=>t.value===e)?.value}var N=[{value:`scene-boxes`,get label(){return D.t(`helpers.ruleFormParsers.imageSceneBoxes`)},get description(){return D.t(`helpers.ruleFormParsers.imageSceneBoxesDesc`)}},{value:`crop`,get label(){return D.t(`helpers.ruleFormParsers.imageCrop`)},get description(){return D.t(`helpers.ruleFormParsers.imageCropDesc`)}},{value:`clean`,get label(){return D.t(`helpers.ruleFormParsers.imageClean`)},get description(){return D.t(`helpers.ruleFormParsers.imageCleanDesc`)}},{value:`none`,get label(){return D.t(`helpers.ruleFormParsers.imageNone`)},get description(){return D.t(`helpers.ruleFormParsers.imageNoneDesc`)}}];function St(e){return N.find(t=>t.value===e)?.value}var P=[{value:``,get label(){return D.t(`helpers.ruleFormParsers.linkedDefault`)}},{value:`mosaic`,get label(){return D.t(`helpers.ruleFormParsers.linkedMosaic`)}},{value:`each`,get label(){return D.t(`helpers.ruleFormParsers.linkedEach`)}}];function Ct(e){let t=P.find(t=>t.value===e)?.value;return t===``?void 0:t}var F=[{value:``,get label(){return D.t(`helpers.ruleFormParsers.profileLowest`)}},{value:`low`,get label(){return D.t(`helpers.ruleFormParsers.profileLow`)}},{value:`mid`,get label(){return D.t(`helpers.ruleFormParsers.profileMid`)}},{value:`high`,get label(){return D.t(`helpers.ruleFormParsers.profileHigh`)}}];function wt(e){let t=F.find(t=>t.value===e)?.value;return t===``?void 0:t}var Tt=[{value:`any`,get label(){return D.t(`helpers.ruleFormParsers.srcAny`)}},{value:`pipeline`,get label(){return D.t(`helpers.ruleFormParsers.srcPipeline`)}},{value:`onboard`,get label(){return D.t(`helpers.ruleFormParsers.srcOnboard`)}},{value:`sensor`,get label(){return D.t(`helpers.ruleFormParsers.srcSensor`)}}],Et=[{value:`delivered`,get label(){return D.t(`helpers.ruleFormParsers.phaseDelivered`)}},{value:`picked-up`,get label(){return D.t(`helpers.ruleFormParsers.phasePickedUp`)}},{value:`both`,get label(){return D.t(`helpers.ruleFormParsers.phaseBoth`)}}],Dt=[{value:``,get label(){return D.t(`helpers.ruleFormParsers.stBoth`)}},{value:`raised`,get label(){return D.t(`helpers.ruleFormParsers.stRaised`)}},{value:`cleared`,get label(){return D.t(`helpers.ruleFormParsers.stCleared`)}}];function Ot(e){return e===`raised`||e===`cleared`?e:void 0}function I(e,t){return e===`sensorTransition`?se(t.sensorKinds):!0}var kt=[{value:`enter`,get label(){return D.t(`helpers.ruleFormParsers.crossEnter`)}},{value:`exit`,get label(){return D.t(`helpers.ruleFormParsers.crossExit`)}},{value:`any`,get label(){return D.t(`helpers.ruleFormParsers.crossAny`)}}],At=`enter`;function L(e){return e===`exit`||e===`any`?e:void 0}var jt=[{value:1,get label(){return D.t(`helpers.ruleFormParsers.prioMin`)}},{value:2,get label(){return D.t(`helpers.ruleFormParsers.prioLow`)}},{value:3,get label(){return D.t(`helpers.ruleFormParsers.prioDefault`)}},{value:4,get label(){return D.t(`helpers.ruleFormParsers.prioHigh`)}},{value:5,get label(){return D.t(`helpers.ruleFormParsers.prioMax`)}}];function Mt(e,t){return e.options&&e.options.length>0?e.options:t}var Nt=[{value:``,get label(){return D.t(`helpers.ruleFormParsers.speedDefault`)}},{value:`1`,get label(){return D.t(`helpers.ruleFormParsers.speedReal`)}},{value:`2`,label:`2×`},{value:`3`,label:`3×`},{value:`4`,label:`4×`},{value:`6`,label:`6×`},{value:`8`,label:`8×`}];function Pt(e){if(e===``)return;let t=Number(e);return Number.isFinite(t)&&t>=1&&t<=8?t:void 0}var Ft=`notificationRules.systemEventKinds.`,It=`notificationRules.systemEventGroups.`,Lt=`notificationRules.systemEventHints.`;function Rt(e){return!De.some(t=>t===e)}function R(e){let t=`${Ft}${e}`;return D.exists(t)?D.t(t):e}function z(){return de.map(e=>({id:e.id,family:e.family,label:D.t(`${It}${e.id}`,e.label),hint:D.t(`${Lt}${e.id}`),kinds:e.kinds.filter(Rt).map(e=>({value:e,label:R(e)}))}))}function B(e){return z().filter(t=>t.family===e)}function V(e){let t=g(e).conditions.systemEvent;return t===void 0?{kinds:(B(e)[0]?.kinds??[]).map(e=>e.value)}:{...t,kinds:[...t.kinds]}}function zt(){return z().flatMap(e=>e.kinds)}function Bt(e){return{devices:m(e,`deviceIds`),deviceTypes:m(e,`deviceTypes`),nodes:m(e,`nodeIds`),packages:m(e,`packageNames`),consumableThreshold:m(e,`consumableLowPercent`)}}function Vt(e,t){let n=_[e],r=Bt(t);return{devices:n.includes(`deviceIds`)&&r.devices,excludeDevices:n.includes(`excludeDeviceIds`)&&r.devices,deviceTypes:n.includes(`deviceTypes`)&&r.deviceTypes,nodes:n.includes(`nodeIds`)&&r.nodes,packages:n.includes(`packageNames`)&&r.packages,consumableThreshold:n.includes(`consumableLowPercent`)&&r.consumableThreshold}}var Ht=Object.values(be).map(e=>({value:e,label:Ut(e)})).toSorted((e,t)=>e.label.localeCompare(t.label));function Ut(e){let t=e.replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function Wt(e,t){let n=[],r=new Set;for(let i of e.kinds){let e=pe(i.value);if(e===void 0){n.push({key:i.value,label:i.label,kinds:[i.value],clears:[i.value]});continue}r.has(e.id)||(r.add(e.id),n.push({key:`class:${e.id}`,label:t?e.snapshotLabel:e.label,kinds:t?[...e.bad]:v(e),clears:v(e),classId:e.id,...t&&e.snapshotSection===null?{noSnapshot:!0}:{}}))}return n}function Gt(e,t){return t.clears.some(t=>e.includes(t))}function Kt(e,t,n){if(!B(n).some(e=>e.kinds.some(e=>t.kinds.includes(e.value))))return e;let r=e?.kinds??[];if(Gt(r,t)){let i=r.filter(e=>!t.clears.includes(e));return i.length===0?e:U(e,i,n)}return U(e,zt().filter(e=>t.kinds.includes(e.value)||r.includes(e.value)).map(e=>e.value),n)}function qt(e,t){return t===void 0?void 0:U(t,t.kinds,e)}function Jt(e,t){let n=e?.kinds??[];if(n.length===0)return;let r=H(t,`deviceIds`,e?.deviceIds),i=H(t,`excludeDeviceIds`,e?.excludeDeviceIds),a=H(t,`deviceTypes`,e?.deviceTypes),o=H(t,`nodeIds`,e?.nodeIds),s=H(t,`packageNames`,e?.packageNames),c=Object.prototype.hasOwnProperty.call(t,`consumableLowPercent`)?t.consumableLowPercent:e?.consumableLowPercent;return{kinds:[...n],...r===void 0?{}:{deviceIds:[...r]},...i===void 0?{}:{excludeDeviceIds:[...i]},...a===void 0?{}:{deviceTypes:[...a]},...o===void 0?{}:{nodeIds:[...o]},...s===void 0?{}:{packageNames:[...s]},...c===void 0?{}:{consumableLowPercent:c}}}function H(e,t,n){let r=Object.prototype.hasOwnProperty.call(e,t)?e[t]:n;return r!==void 0&&r.length===0?void 0:r}function U(e,t,n){let r=Vt(n,t),i=r.devices?e?.deviceIds:void 0,a=r.excludeDevices?e?.excludeDeviceIds:void 0,o=r.deviceTypes?e?.deviceTypes:void 0,s=r.nodes?e?.nodeIds:void 0,c=r.packages?e?.packageNames:void 0,l=r.consumableThreshold?e?.consumableLowPercent:void 0;return{kinds:[...t],...i&&i.length>0?{deviceIds:[...i]}:{},...a&&a.length>0?{excludeDeviceIds:[...a]}:{},...o&&o.length>0?{deviceTypes:[...o]}:{},...s&&s.length>0?{nodeIds:[...s]}:{},...c&&c.length>0?{packageNames:[...c]}:{},...l===void 0?{}:{consumableLowPercent:l}}}var Yt=95;function Xt(e){let t=e.trim();if(t===``)return{kind:`clear`};let n=Number(t);return Number.isInteger(n)&&n>=1&&n<=Yt?{kind:`set`,value:n}:{kind:`invalid`}}function Zt(e,t=2){if(e===void 0||e.length===0)return D.t(`helpers.notificationSystemEvents.noneSelected`);let n=e.slice(0,t).map(R).join(`, `),r=e.length-Math.min(t,e.length);return r>0?`${n} +${r}`:n}function Qt(e){if(e===void 0)return`—`;let t=[],n=e.deviceIds?.length??0,r=e.deviceTypes?.length??0,i=e.nodeIds?.length??0,a=e.packageNames?.length??0,o=e.excludeDeviceIds?.length??0;r>0&&t.push(e.deviceTypes?.map(Ut).join(`, `)??``),n>0&&t.push(`${n} device${n===1?``:`s`}`),i>0&&t.push(`${i} node${i===1?``:`s`}`),a>0&&t.push(`${a} package${a===1?``:`s`}`);let s=o>0?`except ${o} device${o===1?``:`s`}`:null,c=e.consumableLowPercent===void 0?[]:[`consumables at ${e.consumableLowPercent}%`];return t.length===0?[s===null?`Everything`:`Everything ${s}`,...c].join(` · `):[...t,...s===null?[]:[s],...c].join(` · `)}function $t(e){return e===void 0||(e.deviceTypes?.length??0)===0?!1:e.kinds.some(e=>re.includes(e))}var en=[`all`,`only`,`except`];function tn(e,t){return(e??[]).length>0?`only`:(t??[]).length>0?`except`:`all`}function W(e,t){let n=[...e??[]],r=[...t??[]];return{mode:tn(n,r),include:n,exclude:r,legacyBoth:n.length>0&&r.length>0}}function nn(e,t){return{...e,mode:t}}function rn(e){switch(e.mode){case`only`:return e.include;case`except`:return e.exclude;case`all`:return[]}}function an(e,t){switch(e.mode){case`only`:return{...e,include:[...t]};case`except`:return{...e,exclude:[...t]};case`all`:return e}}function on(e){return e.mode===`only`&&e.legacyBoth?e.exclude:[]}function sn(e){return{...e,exclude:[],legacyBoth:!1}}function G(e){switch(e.mode){case`all`:return{};case`except`:return e.exclude.length>0?{exclude:[...e.exclude]}:{};case`only`:{let t=on(e);return{...e.include.length>0?{include:[...e.include]}:{},...t.length>0?{exclude:[...t]}:{}}}}}function cn(e){let t=G(e),n=t.include??[],r=t.exclude??[];return[...e.include.filter(e=>!n.includes(e)),...e.exclude.filter(e=>!r.includes(e))]}var K=[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`],q={onActivation:{get title(){return D.t(`helpers.notificationRuleActions.onActivationTitle`)},get hint(){return D.t(`helpers.notificationRuleActions.onActivationHint`)}},onDeactivation:{get title(){return D.t(`helpers.notificationRuleActions.onDeactivationTitle`)},get hint(){return D.t(`helpers.notificationRuleActions.onDeactivationHint`)}},onTrigger:{get title(){return D.t(`helpers.notificationRuleActions.onTriggerTitle`)},get hint(){return D.t(`helpers.notificationRuleActions.onTriggerHint`)}},onTriggerOff:{get title(){return D.t(`helpers.notificationRuleActions.onTriggerOffTitle`)},get hint(){return D.t(`helpers.notificationRuleActions.onTriggerOffHint`)}}},ln={onActivation:[],onDeactivation:[],onTrigger:[],onTriggerOff:[],buttons:[]};function un(e){return e===void 0?ln:{onActivation:[...e.onActivation??[]],onDeactivation:[...e.onDeactivation??[]],onTrigger:[...e.onTrigger??[]],onTriggerOff:[...e.onTriggerOff??[]],buttons:[...e.buttons??[]]}}function J(e){let t=e.buttons.filter(e=>e.id.trim()!==``&&e.label.trim()!==``&&e.sequenceId.trim()!==``),n={onActivation:e.onActivation,onDeactivation:e.onDeactivation,onTrigger:e.onTrigger,onTriggerOff:e.onTriggerOff};if(!(!K.some(e=>n[e].length>0)&&t.length===0))return{...n.onActivation.length>0?{onActivation:[...n.onActivation]}:{},...n.onDeactivation.length>0?{onDeactivation:[...n.onDeactivation]}:{},...n.onTrigger.length>0?{onTrigger:[...n.onTrigger]}:{},...n.onTriggerOff.length>0?{onTriggerOff:[...n.onTriggerOff]}:{},...t.length>0?{buttons:t}:{}}}function dn(e,t){let n=[];for(let r of K){let i=e[r];i.length>4&&n.push({kind:`too-many`,message:D.t(`helpers.notificationRuleActions.tooMany`,{title:q[r].title})});for(let e of i)e.kind===`sequence`&&!t.has(e.sequenceId)&&n.push({kind:`unknown-sequence`,message:D.t(`helpers.notificationRuleActions.hookUnknownSeq`,{title:q[r].title})})}let r=new Set;for(let i of e.buttons){let e=i.id.trim();e!==``&&(r.has(e)&&n.push({kind:`duplicate-button`,message:D.t(`helpers.notificationRuleActions.dupButton`,{id:e})}),r.add(e),t.has(i.sequenceId.trim())||n.push({kind:`unknown-sequence`,message:D.t(`helpers.notificationRuleActions.buttonUnknownSeq`,{label:i.label||e})}))}return n}function fn(e,t){return{id:`action-${String(e+1)}`,label:D.t(`helpers.notificationRuleActions.newButtonLabel`),sequenceId:t}}function pn(){return{kind:`do`,action:{kind:`cap`,deviceId:0,cap:``,method:``}}}function mn(e){return{kind:`sequence`,sequenceId:e}}function hn(){return{kind:`wait`,seconds:5}}var gn=[{value:`acknowledge`,get label(){return D.t(`helpers.notificationRuleActions.icon_acknowledge`)}},{value:`dismiss`,get label(){return D.t(`helpers.notificationRuleActions.icon_dismiss`)}},{value:`silence`,get label(){return D.t(`helpers.notificationRuleActions.icon_silence`)}},{value:`snooze`,get label(){return D.t(`helpers.notificationRuleActions.icon_snooze`)}},{value:`view`,get label(){return D.t(`helpers.notificationRuleActions.icon_view`)}},{value:`play`,get label(){return D.t(`helpers.notificationRuleActions.icon_play`)}},{value:`camera`,get label(){return D.t(`helpers.notificationRuleActions.icon_camera`)}},{value:`open`,get label(){return D.t(`helpers.notificationRuleActions.icon_open`)}},{value:`close`,get label(){return D.t(`helpers.notificationRuleActions.icon_close`)}},{value:`unlock`,get label(){return D.t(`helpers.notificationRuleActions.icon_unlock`)}},{value:`lock`,get label(){return D.t(`helpers.notificationRuleActions.icon_lock`)}},{value:`disarm`,get label(){return D.t(`helpers.notificationRuleActions.icon_disarm`)}},{value:`arm`,get label(){return D.t(`helpers.notificationRuleActions.icon_arm`)}},{value:`arm-home`,get label(){return D.t(`helpers.notificationRuleActions.icon_arm_home`)}},{value:`arm-away`,get label(){return D.t(`helpers.notificationRuleActions.icon_arm_away`)}},{value:`arm-night`,get label(){return D.t(`helpers.notificationRuleActions.icon_arm_night`)}},{value:`light`,get label(){return D.t(`helpers.notificationRuleActions.icon_light`)}},{value:`alert`,get label(){return D.t(`helpers.notificationRuleActions.icon_alert`)}}],_n=[10,30,60],vn=[5,10,15,30,60,120,240,480];function yn(e){return e>=60&&e%60==0?D.t(`helpers.ruleFormState.snoozeHours`,{count:e/60}):D.t(`helpers.ruleFormState.snoozeMin`,{count:e})}var bn=new Set([`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`]),xn=`alarm-panel`;function Sn(e,t){for(let t of e.systemEvent?.kinds??[])if(bn.has(t))return!0;for(let e of t)if(e.kind===`cap`&&e.cap===xn)return!0;return!1}function Cn(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`])for(let i of e[t])if(i.kind===`do`)r.push(i.action);else{let e=n.get(i.sequenceId);e!==void 0&&r.push(...e.actions)}for(let t of e.buttons){let e=n.get(t.sequenceId);e!==void 0&&r.push(...e.actions)}return r}function wn(e){let{devices:t,devicesExclude:n,classes:r,classesExclude:i,...a}=e;return{conditions:a,deviceScope:W(t,n),classScope:W(r,i)}}function Tn(e){let t=G(e.deviceScope),n=G(e.classScope);return{...e.conditions,...t.include===void 0?{}:{devices:[...t.include]},...t.exclude===void 0?{}:{devicesExclude:[...t.exclude]},...n.include===void 0?{}:{classes:[...n.include]},...n.exclude===void 0?{}:{classesExclude:[...n.exclude]}}}function En(e){return e.deviceScope.mode===`only`?e.deviceScope.include:[]}function Dn(e,t,n){let r=x(n);return e.some(e=>e.id===t&&Ee(e,n.delivery,r))}function On(e=`immediate`,t={}){return{name:``,enabled:!0,delivery:e,targetIds:[],targetUsers:[],targetParams:{},priority:3,mediaImage:we({},x({delivery:e,conditions:t})),mediaShowTriggerZone:!1,mediaShowSubjectPath:!1,mediaGif:!1,mediaClip:!1,mediaProfile:void 0,mediaClipSpeed:void 0,mediaLinkedCameras:void 0,templateTitle:``,templateBody:``,...wn(t),schedule:void 0,systemEventDelivery:void 0,snoozeAllowGlobal:!1,groupingSec:void 0,snoozeOptions:void 0,askVerdict:void 0,actions:ln,cooldownSec:30,cooldownScope:`rule-device`,cooldownGranularity:void 0}}function kn(e){let t={};for(let n of e.targets)n.params&&Object.keys(n.params).length>0&&(t[n.targetId]=n.params);return{name:e.name,enabled:e.enabled,delivery:e.delivery,targetIds:e.targets.map(e=>e.targetId),targetUsers:e.targetUsers??[],targetParams:t,priority:e.priority,mediaImage:we(e.media,x(e)),mediaShowTriggerZone:e.media.showTriggerZone===!0,mediaShowSubjectPath:e.media.showSubjectPath===!0,mediaGif:e.media.gif===!0,mediaClip:e.media.clip===!0,mediaProfile:e.media.profile,mediaClipSpeed:e.media.clipSpeed,mediaLinkedCameras:e.media.linkedCameras,templateTitle:e.template?.title??``,templateBody:e.template?.body??``,...wn(e.conditions),schedule:e.schedule,systemEventDelivery:e.systemEventDelivery,snoozeAllowGlobal:e.snoozeAllowGlobal===!0,groupingSec:e.groupingSec,snoozeOptions:e.snoozeOptions,askVerdict:e.askVerdict,actions:un(e.actions),cooldownSec:e.throttle.cooldownSec,cooldownScope:e.throttle.scope,cooldownGranularity:e.throttle.granularity}}function An(e,t){let n=[];if(Ln(e)){let r=e.groupingSec;r!==void 0&&(!Number.isInteger(r)||r<5||r>60)&&n.push(`The grouping window is a whole number of seconds between 5 and 60.`);let i=t?.confirm;i?.enabled===!0&&i.expect!==void 0&&!Rn(i.expect)&&n.push(`This rule’s AI confirm expects more than one subject, but a grouped message judges one picture per subject, so it would never send. Remove the confirm expectation (viewer or API), or choose Immediate.`)}if(me(e.conditions.audio)&&n.push(`This sound rule names neither a sound nor a level threshold, so it can never fire — every sample would count as a hit and the engine refuses it rather than notifying on silence. Pick at least one sound, or add a level.`),(!Number.isInteger(e.cooldownSec)||e.cooldownSec<0||e.cooldownSec>86400)&&n.push(`The cooldown is a whole number of seconds between 0 and ${String(ht)} (24 hours). 0 means every match is delivered.`),Y(e))for(let t of fe({delivery:e.delivery,conditions:e.conditions,...e.systemEventDelivery===void 0?{}:{systemEventDelivery:e.systemEventDelivery},...J(e.actions)===void 0?{}:{actions:J(e.actions)}}))n.push(p(t));return n}function jn(e){let t=e.systemEventDelivery;if(t===void 0)return{};if(!S(e.delivery))return t.mode===`summary`?{systemEventDelivery:{mode:`instant`}}:{};if(t.mode===`summary`&&ue(t.schedule)===null){let e=b(t.schedule);if(e!==null&&e.times.length>0)return{systemEventDelivery:{...t,schedule:Ce(e.times,t.schedule.timezone)}}}return{systemEventDelivery:t}}function Mn(e){if(!Y(e))return null;if(!ae(e.templateBody))return D.t(`helpers.ruleFormState.summaryWarnNone`,{token:`{{summaryText}}`});let t=e.templateBody;return(e.systemEventDelivery?.mode===`summary`?e.systemEventDelivery.split:void 0)===`section`&&t.trim().length>0&&!/\{\{\s*summaryText\s*\}\}/.test(t)?D.t(`helpers.ruleFormState.summaryWarnSplit`,{token:`{{summaryText}}`}):null}function Y(e){return S(e.delivery)&&e.systemEventDelivery?.mode===`summary`}function Nn(e,t,n=new Set){return An(e,t).length===0&<(e.delivery)&&(!S(e.delivery)||Hn(e)>0)&&x(e)!==`mixed`&&e.name.trim().length>0&&(e.targetIds.length>0||e.targetUsers.length>0)&&dn(e.actions,n).length===0}function Pn(e,t){let n=Bn(e.conditions,t);return S(t)&&(n.systemEvent?.kinds.length??0)===0?{...e,delivery:t,conditions:{...n,systemEvent:V(`device-events`)}}:{...e,delivery:t,conditions:n}}function Fn(e,t){return t===`immediate-grouped`?{...Pn(e,`immediate`),groupingSec:e.groupingSec??20}:{...Pn(e,t),groupingSec:void 0}}function In(e){return e.delivery===`immediate`||e.delivery===`track-end`}function Ln(e){return e.groupingSec!==void 0&&w(e)}function Rn(e){switch(e.op){case`>`:return 1>e.count;case`<=`:return 1<=e.count;case`<`:return 1<e.count;case`==`:return e.count===1;default:return 1>=e.count}}var zn=new Set([`immediate`,`track-end`,`package-event`]);function Bn(e,t){if(e.source!==`pipeline`||zn.has(t))return e;let{source:n,...r}=e;return r}function Vn(e,t){return he(e.conditions.systemEvent)===t?e:{...e,conditions:{...e.conditions,systemEvent:V(t)}}}function Hn(e){return e.conditions.systemEvent?.kinds.length??0}function X(e,t){return e.appliesTo.includes(t)}var Un={source:`any`};function Wn(e,t){if(t==null)return!0;if(Array.isArray(t))return t.length===0;if(typeof t==`string`)return t.length===0||Un[e]===t;if(typeof t==`number`)return!Number.isFinite(t);if(typeof t==`object`){if(`ids`in t){let e=t.ids;return!Array.isArray(e)||e.length===0}if(`values`in t){let e=t.values;return!Array.isArray(e)||e.length===0}return!1}return!1}var Gn=ce.filter(e=>e.id===`audio`);function Kn(e){if(e.length===0)return e;let t=new Set(e.map(e=>e.id)),n=Gn.filter(e=>!t.has(e.id));return n.length===0?e:[...e,...n]}function qn(e,t,n,r=x({delivery:t,conditions:e})){let i=n.length===0?null:new Set(n.filter(e=>e.id!==`schedule`&&Ee(e,t,r)).map(e=>e.id)),a={};for(let[t,n]of Object.entries(e))i!==null&&!i.has(t)||I(t,e)&&(Wn(t,n)||(a[t]=n));return a}function Jn(e,t){if(e===void 0)return{};let n=qt(e,t.systemEvent);return n===void 0?{}:{systemEvent:n}}function Yn(e){return e!==void 0&&e.windows.length>0}function Xn(e){let t={...e.clipPreRollSec===void 0?{}:{clipPreRollSec:e.clipPreRollSec},...e.clipPostRollSec===void 0?{}:{clipPostRollSec:e.clipPostRollSec}};return Object.keys(t).length>0?t:void 0}function Zn(e){let t=Xn(e.media);return{...e.confirm===void 0?{}:{confirm:e.confirm},...t===void 0?{}:{media:t}}}function Qn(e,t,n=[]){let r=e.templateTitle.trim(),i=e.templateBody.trim(),a=r.length>0||i.length>0?{...r.length>0?{title:r}:{},...i.length>0?{body:i}:{}}:void 0,o=J(e.actions),s=x(e),c=C(s),l=ke(s),u=n.length===0?!0:n.some(t=>t.id===`schedule`&&X(t,e.delivery)),d=!Y(e)&&u&&Yn(e.schedule)?e.schedule:void 0,f=n.length===0?!0:n.some(t=>t.id===`devices`&&X(t,e.delivery)),p=n.length===0?!0:n.some(t=>t.id===`devicesExclude`&&X(t,e.delivery)),{devices:m,devicesExclude:h,...g}=Tn(e),_=qn(g,e.delivery,n,s);return{name:e.name.trim(),enabled:e.enabled,delivery:e.delivery,conditions:{..._,...f&&m!==void 0?{devices:m}:{},...p&&h!==void 0?{devicesExclude:h}:{},...Jn(l,e.conditions)},...d?{schedule:d}:{},...jn(e),targets:e.targetIds.map(t=>{let n=e.targetParams[t];return n&&Object.keys(n).length>0?{targetId:t,params:n}:{targetId:t}}),...e.targetUsers.length>0?{targetUsers:[...e.targetUsers]}:{},media:c.carriesMedia?{image:e.mediaImage,...e.mediaShowTriggerZone&&e.mediaImage!==`crop`&&e.mediaImage!==`none`&&Oe(_).length>0?{showTriggerZone:!0}:{},...e.mediaShowSubjectPath&&e.mediaImage!==`none`&&ye(s)?{showSubjectPath:!0}:{},...e.mediaGif?{gif:!0}:{},...e.mediaClip?{clip:!0}:{},...e.mediaProfile===void 0?{}:{profile:e.mediaProfile},...e.mediaClipSpeed===void 0?{}:{clipSpeed:e.mediaClipSpeed},...s===`sensor`&&e.mediaImage!==`none`&&e.mediaLinkedCameras!==void 0?{linkedCameras:e.mediaLinkedCameras}:{},...(e.mediaGif||e.mediaClip)&&t?.media?.clipPreRollSec!==void 0?{clipPreRollSec:t.media.clipPreRollSec}:{},...(e.mediaGif||e.mediaClip)&&t?.media?.clipPostRollSec!==void 0?{clipPostRollSec:t.media.clipPostRollSec}:{}}:{image:`none`},throttle:{cooldownSec:e.cooldownSec,scope:e.cooldownScope,...e.cooldownGranularity===void 0?{}:{granularity:e.cooldownGranularity}},priority:e.priority,...a?{template:a}:{},...e.snoozeAllowGlobal?{snoozeAllowGlobal:!0}:{},...Ln(e)?{groupingSec:e.groupingSec}:{},...e.snoozeOptions===void 0?{}:{snoozeOptions:[...e.snoozeOptions]},...e.askVerdict!==void 0&&In(e)?{askVerdict:e.askVerdict}:{},...t?.confirm===void 0?{}:{confirm:t.confirm},...o===void 0?{}:{actions:o}}}function $n(e,t){let n=Qn(e,void 0,t);return[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`groupingSec`,`actions`].filter(e=>n[e]===void 0)}var er=[{key:`rule`,get label(){return D.t(`helpers.ruleFormTabs.tab_rule`)},fields:[`name`,`enabled`,`delivery`,`groupingSec`,`targetIds`,`targetUsers`,`targetParams`]},{key:`devices`,get label(){return D.t(`helpers.ruleFormTabs.tab_devices`)},fields:[`deviceScope`]},{key:`conditions`,get label(){return D.t(`helpers.ruleFormTabs.tab_conditions`)},fields:[`conditions`,`classScope`,`schedule`,`systemEventDelivery`]},{key:`notification`,get label(){return D.t(`helpers.ruleFormTabs.tab_notification`)},fields:[`priority`,`mediaImage`,`mediaShowTriggerZone`,`mediaShowSubjectPath`,`mediaGif`,`mediaClip`,`mediaProfile`,`mediaClipSpeed`,`mediaLinkedCameras`,`templateTitle`,`templateBody`]},{key:`actions`,get label(){return D.t(`helpers.ruleFormTabs.tab_actions`)},fields:[`actions`]},{key:`advanced`,get label(){return D.t(`helpers.ruleFormTabs.tab_advanced`)},fields:[`snoozeAllowGlobal`,`snoozeOptions`,`askVerdict`,`cooldownSec`,`cooldownScope`,`cooldownGranularity`]}];function tr(e,t={}){let n=x({delivery:e,conditions:t}),r=C(n),i=er.map(e=>e.key===`conditions`?{...e,label:r.label}:e);return Se(n)?i.filter(e=>e.key!==`devices`):i}function nr(e){if(e.audio!==void 0)return D.t(`helpers.ruleFormTabs.condSound`);if(e.occupancy!==void 0)return D.t(`helpers.ruleFormTabs.condOccupancy`)}function rr(e){let t=x(e),n=Te(Tn(e),t);return t===`sensor`&&e.conditions.sensorTransition!==void 0&&!I(`sensorTransition`,e.conditions)?[...n,{conditionId:`sensorTransition`,reason:ne}]:n}var ir=`rule`;function ar(e){return er.find(t=>t.key===e)?.key}function or(e){return e?.toLowerCase().startsWith(`it`)===!0?`it`:`en`}function sr(){let{i18n:e}=O(),t=or(e.language);return e=>ee(e,t)}i();var cr=`block text-[11px] font-medium text-foreground`,Z=`text-[10px] text-foreground-subtle mt-0.5`;function lr({cameras:e,fleet:t,value:r,onChange:i,emptyMeansAll:a=!1,savedHadDevices:o=!1}){return n(Ne,{devices:e,listState:t.state,fleet:t,value:r,onChange:i,emptyMeansAll:a,savedHadDevices:o})}function Q({value:t,placeholder:i,onChange:a}){let{t:o}=O(),[s,c]=r(``),l=()=>{let e=s.trim();if(e.length===0||t.includes(e)){c(``);return}a([...t,e]),c(``)},d=e=>a(t.filter(t=>t!==e));return e(`div`,{className:`mt-1 space-y-1.5`,children:[t.length>0&&n(`div`,{className:`flex flex-wrap gap-1`,children:t.map(t=>e(`span`,{className:`inline-flex items-center gap-1 rounded bg-surface-hover px-1.5 py-0.5 text-[11px] text-foreground`,children:[t,n(`button`,{type:`button`,onClick:()=>d(t),"aria-label":o(`system.notificationConditionWidgets.remove`,`remove {{v}}`,{v:t}),className:`text-foreground-subtle hover:text-danger`,children:n(u,{className:`h-3 w-3`})})]},t))}),n(E,{value:s,placeholder:i,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l())},onBlur:l})]})}function ur({picker:r,value:i,onChange:a}){let{t:o}=O(),s=t(()=>le(r),[r]),c=t(()=>new Set(i),[i]),l=i.filter(e=>!s.has(e)),u=e=>{a(c.has(e)?i.filter(t=>t!==e):[...i,e])};return e(`div`,{className:`space-y-2`,children:[l.length>0&&n(`div`,{className:`flex flex-wrap gap-1`,children:l.map(t=>e(`button`,{type:`button`,onClick:()=>a(i.filter(e=>e!==t)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:o(`system.notificationConditionWidgets.customValueClickToRemove`,`Custom value — click to remove`),children:[t,` ×`]},t))}),r.groups.map(t=>e(`div`,{children:[n(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-muted mb-1`,children:t.fallbackLabel}),n(`div`,{className:`flex flex-wrap gap-1`,children:t.options.map(e=>{let t=c.has(e.value);return n(`button`,{type:`button`,"aria-pressed":t,onClick:()=>u(e.value),className:t?`rounded border border-primary bg-primary/15 px-1.5 py-0.5 text-[10px] text-foreground`:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,children:e.label},e.value)})})]},t.key))]})}function dr({value:t,min:r,max:i,step:a,onChange:o}){let{t:s}=O();return e(`div`,{className:`mt-1 flex items-center gap-2`,children:[n(E,{type:`number`,value:t??``,min:r,max:i,step:a,className:`max-w-[8rem]`,onChange:e=>{let t=e.target.value;if(t===``){o(void 0);return}let n=Number(t);o(Number.isFinite(n)?n:void 0)}}),t!==void 0&&i!==void 0&&n(`input`,{type:`range`,min:r,max:i,step:a,value:t,onChange:e=>o(Number(e.target.value)),className:`flex-1 accent-primary`,"aria-label":s(`common.valueWord`)})]})}function fr({value:t,onChange:r,options:i}){let{t:a}=O(),o=pr(i??[]),s=o.length>0?o:kt;return e(`div`,{className:`mt-1 space-y-1`,children:[n(T,{value:t??`enter`,options:s.map(e=>({value:e.value,label:a(`notificationRules.crossing.${e.value}`,e.label)})),onChange:e=>r(L(e.target.value))}),n(`p`,{className:Z,children:a(`notificationRules.crossing.hint`,`Which way the subject crosses the zone.`)})]})}function pr(e){let t=[];for(let n of e){let e=n.value===``||n.value===`enter`?At:L(n.value);e===void 0||t.some(t=>t.value===e)||t.push({value:e,label:n.label})}return t}function mr({deviceIds:e,cameras:t,value:r,onChange:i}){let{options:a,loading:o}=A(e,t);return n(j,{options:a,value:r,onChange:i,loading:o,noFreeText:!0,emptyHint:e.length===0?`Select cameras first — a rule can only use zones those cameras actually have.`:`The selected cameras have no zones. Draw one in the camera’s zone editor first.`,placeholder:``})}function hr({deviceIds:e,value:t,onChange:r}){let{t:i}=O(),{options:a,loading:o}=Qe(e);return n(j,{options:a,value:t,onChange:r,loading:o,emptyHint:e.length===0?`Select cameras above to pick their event kinds — or type a token.`:`No event kinds reported for the selected cameras — type a token.`,placeholder:i(`system.notificationConditionWidgets.eventToken`,`Event token…`)})}var gr=[{value:`became-occupied`,labelKey:`system.notificationConditionWidgets.opBecameOccupied`},{value:`became-free`,labelKey:`system.notificationConditionWidgets.opBecameFree`},{value:`>=`,labelKey:`system.notificationConditionWidgets.opCountAtLeast`},{value:`<=`,labelKey:`system.notificationConditionWidgets.opCountAtMost`}];function _r(e,t){let n=e.map(e=>({value:e.value,label:e.label}));return t===void 0||t===``||n.some(e=>e.value===t)?n:[...n,{value:t,label:D.t(`system.notificationConditionWidgets.subTypeNeverCountsAlways`,`{{stored}} — sub-type, never counts (always 0)`,{stored:t})}]}function vr({deviceIds:t,cameras:r,classOptions:i,value:a,onChange:o}){let{t:s}=O(),{options:c,loading:l}=A(t,r),u=a??xe,d=e=>o({...u,...e}),f=u.op===`became-occupied`||u.op===`became-free`,p=_r(i,u.className);return e(`div`,{className:`mt-1 space-y-1.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[n(`div`,{className:`min-w-[10rem]`,children:n(T,{value:u.zoneId??``,options:[{value:``,label:l?s(`system.notificationConditionWidgets.loadingZones`,`Loading zones…`):s(`system.notificationConditionWidgets.wholeFrame`,`— whole frame —`)},...c.map(e=>({value:e.value,label:e.label}))],onChange:e=>d({zoneId:e.target.value===``?void 0:e.target.value})})}),n(`div`,{className:`min-w-[9rem]`,children:n(T,{value:u.className??``,options:[{value:``,label:s(`system.notificationConditionWidgets.anyClass`,`— any class —`)},...p],onChange:e=>d({className:e.target.value===``?void 0:e.target.value})})}),n(`div`,{className:`min-w-[9rem]`,children:n(T,{value:u.op,options:gr.map(e=>({value:e.value,label:s(e.labelKey)})),onChange:e=>{let t=gr.find(t=>t.value===e.target.value);t&&d({op:t.value})}})})]}),e(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[e(`label`,{className:`flex items-center gap-1`,children:[f?s(`system.notificationConditionWidgets.threshold`,`Threshold`):s(`system.notificationConditionWidgets.count`,`Count`),n(E,{type:`number`,min:0,className:`w-16`,value:String(u.count),onChange:e=>d({count:Math.max(0,Number(e.target.value)||0)})})]}),e(`label`,{className:`flex items-center gap-1`,children:[s(`system.notificationConditionWidgets.holdFor`,`Hold for`),n(E,{type:`number`,min:0,max:3600,className:`w-16`,value:String(u.sustainSeconds),onChange:e=>d({sustainSeconds:Math.min(3600,Math.max(0,Number(e.target.value)||0))})}),`s`]}),a===void 0?null:n(`button`,{type:`button`,onClick:()=>o(void 0),className:`underline hover:text-foreground`,children:s(`system.notificationConditionWidgets.clear`,`Clear`)})]}),t.length===0&&n(`p`,{className:`text-[11px] text-warning`,children:s(`system.notificationConditionWidgets.noCameraPickedOnThe`,`No camera picked on the Devices tab: this watches EVERY camera's occupancy, and no zone can be offered until you choose one — a zone id belongs to a camera.`)}),n(`p`,{className:`text-[11px] text-foreground-subtle`,children:s(`system.notificationConditionWidgets.countsConfirmedTrackedObjectsFrom`,`Counts confirmed tracked objects from zone analytics. The change must hold for the sustain window before it fires; with no snapshot for the camera or zone the rule never fires.`)})]})}var yr=[{value:`label`,labelKey:`system.notificationConditionWidgets.audioModeLabel`,Icon:f},{value:`level`,labelKey:`system.notificationConditionWidgets.audioModeLevel`,Icon:d}];function br({taxonomy:t,value:r,onChange:i}){let{t:a}=O(),s=_e(r),c=e=>i(ge(r,e)),{choices:l,unknownLabels:u}=Ae(t,s.labels),d=h(r)??`label`;return e(`div`,{className:`mt-1 space-y-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[yr.map(t=>n(`button`,{type:`button`,"aria-pressed":d===t.value,onClick:()=>c({mode:t.value}),className:`rounded border px-2 py-0.5 text-[11px] ${d===t.value?`border-primary bg-primary/15 text-foreground`:`border-border text-foreground-subtle hover:bg-surface-hover`}`,children:e(`span`,{className:`inline-flex items-center gap-1`,children:[n(t.Icon,{className:`h-3 w-3`}),a(t.labelKey)]})},t.value)),r===void 0?null:n(`button`,{type:`button`,onClick:()=>i(void 0),className:`ml-1 text-xs text-foreground-subtle underline hover:text-foreground`,children:a(`system.notificationConditionWidgets.clear`,`Clear`)})]}),d===`label`?e(o,{children:[n(`div`,{className:`flex flex-wrap gap-1`,children:l.map(t=>{let r=ie(s.labels,t.value),i=t.unknown?`border-dashed border-warning text-warning`:r?`border-primary bg-primary/15 text-foreground`:`border-border text-foreground hover:bg-surface-hover`;return n(`button`,{type:`button`,"aria-pressed":r,title:t.unknown?a(`system.notificationConditionWidgets.storedByTheRuleNot`,`Stored by the rule — not offered by this hub`):void 0,onClick:()=>c({labels:ve(s.labels,t.value)}),className:`rounded border px-1.5 py-0.5 text-[10px] ${i}`,children:e(`span`,{className:`inline-flex items-center gap-1`,children:[n(Fe,{iconId:t.iconId,size:12}),t.label]})},t.value)})}),u.length>0&&e(`p`,{className:`text-[10px] text-warning`,children:[a(`system.notificationConditionWidgets.keptFromTheRuleUnknown`,`Kept from the rule, unknown to this hub:`),` `,u.join(`, `)]}),e(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[e(`label`,{className:`flex items-center gap-1`,children:[a(`system.notificationConditionWidgets.confirmAfter`,`Confirm after`),n(E,{type:`number`,min:1,max:20,step:1,className:`w-16`,value:String(s.confirmHits??2),onChange:e=>c({confirmHits:Number(e.target.value)})}),a(`system.notificationConditionWidgets.frames`)]}),e(`label`,{className:`flex items-center gap-1`,children:[a(`system.notificationConditionWidgets.within`),n(E,{type:`number`,min:1,max:60,step:1,className:`w-16`,value:String(s.confirmWindowSec??5),onChange:e=>c({confirmWindowSec:Number(e.target.value)})}),`s`]})]}),n(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`system.notificationConditionWidgets.audioConfirmHint`,{hits:2,window:5})})]}):e(o,{children:[n(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:e(`label`,{className:`flex items-center gap-1`,children:[a(`system.notificationConditionWidgets.louderThan`,`Louder than`),n(E,{type:`number`,min:te,max:0,step:3,className:`w-20`,value:String(s.dbThreshold??oe),onChange:e=>c({dbThreshold:Number(e.target.value)})}),`dBFS`]})}),e(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[e(`label`,{className:`flex items-center gap-1`,children:[a(`system.notificationConditionWidgets.hits`,`Hits`),n(E,{type:`number`,min:1,max:100,step:5,className:`w-16`,value:String(s.hitPercent),onChange:e=>c({hitPercent:Number(e.target.value)})}),a(`system.notificationConditionWidgets.hitsPercentDefault`,{value:y.hitPercent})]}),e(`label`,{className:`flex items-center gap-1`,children:[a(`system.notificationConditionWidgets.over`),n(E,{type:`number`,min:1,max:300,step:5,className:`w-16`,value:String(s.samplingSeconds),onChange:e=>c({samplingSeconds:Number(e.target.value)})}),a(`system.notificationConditionWidgets.secondsDefault`,{value:y.samplingSeconds})]})]}),n(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`system.notificationConditionWidgets.dbfsHint`,{min:te})})]}),me(r)?n(`p`,{className:`text-[11px] text-warning`,children:a(`system.notificationConditionWidgets.withNeitherASoundNor`,`With neither a sound nor a level threshold this can never match — every sample would be a hit, so the engine refuses it rather than notifying on silence.`)}):null]})}function xr({value:t,onChange:r}){let{t:i}=O(),a=t?.values??[],o=t?.maxDistance??1,s=e=>r(e.length>0?{values:e,maxDistance:o}:void 0),c=e=>r(a.length>0?{values:a,maxDistance:e}:void 0),l=et().filter(e=>!a.includes(e));return e(`div`,{className:`mt-1 space-y-1.5`,children:[n(Q,{value:a,placeholder:i(`system.notificationConditionWidgets.plateText`,`Plate text…`),onChange:s}),l.length>0&&e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[n(`span`,{className:`text-[10px] text-foreground-subtle`,children:i(`system.notificationConditionWidgets.seen`,`Seen:`)}),l.slice(0,12).map(e=>n(`button`,{type:`button`,onClick:()=>s([...a,e]),className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:e},e))]}),e(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(`system.notificationConditionWidgets.maxDistance`,`Max distance`),n(E,{type:`number`,min:0,max:3,step:1,value:o,className:`max-w-[5rem]`,onChange:e=>{let t=Number(e.target.value);c(Number.isFinite(t)?Math.max(0,Math.min(3,t)):1)}})]})]})}function Sr({gateable:t,value:r,onChange:i}){let{t:a}=O(),o=sr(),s=t.find(e=>e.id===r?.deviceId),c=new Set(r?.states??[]),l=e=>{let t=Number(e);if(!Number.isFinite(t)||t===0)return i(void 0);i({deviceId:t,states:[]})},u=e=>{if(r===void 0)return;let t=new Set(c);t.has(e)?t.delete(e):t.add(e),i(t.size===0?void 0:{deviceId:r.deviceId,states:[...t]})};return e(`div`,{className:`mt-1 space-y-2`,children:[n(T,{value:r===void 0?``:String(r.deviceId),options:[{value:``,label:a(`system.notificationConditionWidgets.noDeviceGate`,`— no device gate —`)},...t.map(e=>({value:String(e.id),label:e.name}))],onChange:e=>l(e.target.value)}),s!==void 0&&n(`div`,{className:`flex flex-wrap gap-1.5`,children:s.states.map(e=>n(`button`,{type:`button`,onClick:()=>u(e),className:c.has(e)?`rounded-md border border-primary bg-primary/10 px-2 py-0.5 text-[11px] text-primary`:`rounded-md border border-border px-2 py-0.5 text-[11px] text-foreground-subtle`,children:o(e)},e))}),s!==void 0&&s.states.length===0&&n(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:a(`system.notificationConditionWidgets.thisDeviceReportsNoState`,`This device reports no state the gate can read, so it cannot arm a rule.`)}),r!==void 0&&n(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:a(`system.notificationConditionWidgets.theRuleIsSilentWhile`,`The rule is silent while the device is in any other state — including when its state cannot be read at all.`)})]})}function Cr(e,t){let n=t(e.verdict);return e.latched?`${n} · ${t(`latched`)}`:n}function wr({scenes:t,value:r,onChange:i}){let{t:a}=O(),o=sr(),s=t.find(e=>e.sceneId===r?.sceneId),c=e=>{if(e===``)return i(void 0);let n=t.find(t=>t.sceneId===e);if(n===void 0)return i(void 0);i({sceneId:e,deviceId:n.deviceId,requiredState:r?.requiredState??`diverged`,...r?.latched===void 0?{}:{latched:r.latched}})},l=e=>{r!==void 0&&i({...r,requiredState:e===`matched`?`matched`:`diverged`})},u=e=>{if(r!==void 0){if(e===``){let{latched:e,...t}=r;return i(t)}i({...r,latched:e===`latched`})}};return t.length===0?n(`p`,{className:Z,children:a(`notificationRules.scene.none`,`No scenes yet — create one on the Scenes page.`)}):e(`div`,{className:`mt-1 space-y-2`,children:[n(T,{value:r?.sceneId??``,options:[{value:``,label:a(`notificationRules.scene.noGate`,`— no scene gate —`)},...t.map(e=>({value:e.sceneId,label:`${e.cameraName} · ${e.label} — ${Cr(e,o)}`}))],onChange:e=>c(e.target.value)}),r!==void 0&&e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[a(`notificationRules.scene.onlyWhile`,`Only while it is`),n(T,{value:r.requiredState,options:[{value:`diverged`,label:o(`diverged`)},{value:`matched`,label:o(`matched`)}],onChange:e=>l(e.target.value)})]}),e(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[a(`notificationRules.scene.read`,`Read`),n(T,{value:r.latched===void 0?``:r.latched?`latched`:`live`,options:[{value:``,label:s===void 0?a(`notificationRules.scene.readOwn`,`The scene's own setting`):`${a(`notificationRules.scene.readOwn`,`The scene's own setting`)} (${o(s.emit)})`},{value:`latched`,label:o(`latched`)},{value:`live`,label:o(`live`)}],onChange:e=>u(e.target.value)})]})]}),s!==void 0&&e(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:[a(`notificationRules.scene.rightNow`,`Right now:`),` `,Cr(s,o)]}),r!==void 0&&s===void 0&&n(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:a(`notificationRules.scene.missing`,`This scene no longer exists — pick another or remove the gate.`)})]})}var $={days:[0,1,2,3,4,5,6],minute:480},Tr=[{value:1,get label(){return D.t(`helpers.notificationSystemEventDelivery.wd_mon`)}},{value:2,get label(){return D.t(`helpers.notificationSystemEventDelivery.wd_tue`)}},{value:3,get label(){return D.t(`helpers.notificationSystemEventDelivery.wd_wed`)}},{value:4,get label(){return D.t(`helpers.notificationSystemEventDelivery.wd_thu`)}},{value:5,get label(){return D.t(`helpers.notificationSystemEventDelivery.wd_fri`)}},{value:6,get label(){return D.t(`helpers.notificationSystemEventDelivery.wd_sat`)}},{value:0,get label(){return D.t(`helpers.notificationSystemEventDelivery.wd_sun`)}}];function Er(e){let t=Math.floor(e/60),n=e%60;return`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`}function Dr(e){let[t,n]=e.split(`:`),r=Number(t)*60+Number(n);return Number.isFinite(r)?Math.max(0,Math.min(1439,r)):0}function Or(e){if(typeof e!=`object`||!e||!(`data`in e))return;let t=e.data;if(!(typeof t!=`object`||!t||!(`code`in t)))return typeof t.code==`string`?t.code:void 0}function kr(e){let t=Object.entries(e).map(([e,t])=>`${e} ${String(t)}`);return t.length>0?D.t(`helpers.notificationSystemEventDelivery.dropped`,{parts:t.join(`, `)}):null}function Ar(e,t,n,r=`rule`){if(e===`error`)return Or(n)===`NOT_FOUND`?{lines:[`This hub does not serve summary rules yet — update @camstack/server first. A rule saved now would be stored without its summary, and stay instant.`]}:{lines:[`The preview could not be read: ${n instanceof Error?n.message:String(n)}`]};if(e!==`success`||t===void 0)return null;let i=[];if(r===`section`&&t.split===void 0&&i.push(`This hub does not send per-category summaries yet — update @camstack/server first. Until then it sends one message.`),t.empty)i.push(`Nothing to report right now — no notification would be sent.`);else if(t.split===`section`&&t.rows!==void 0){let e=t.rows.length;i.push(`${String(e)} notification${e===1?``:`s`} would be sent now, one per category:`);for(let e of t.rows)i.push(`${e.title}\n${e.text}`)}else i.push(`${String(t.count)} item(s) would be sent now:\n${t.text}`);let a=kr(t.dropped);return a!==null&&i.push(a),t.excludedGroups.includes(`backups-exports`)&&i.push(`Backups and exports are completed jobs, not a state — they are not in a summary.`),{lines:i}}function jr(e,t){return{...e,schedule:t}}function Mr(e,t){let{split:n,...r}=e;return t===`section`?{...r,split:t}:r}function Nr(e){return Er(e)}function Pr(e){return Dr(e)}function Fr(){return{days:[1,2,3,4,5],startMinute:540,endMinute:1080}}function Ir(e){return{days:[...$.days],minute:e}}var Lr=`Always active — add a window to restrict when the rule fires.`;function Rr({value:e,onChange:t,mode:r=`windows`,defaultMinute:i=$.minute,emptyHint:a}){return r===`times`?n(Br,{value:e,onChange:t,defaultMinute:i}):n(zr,{value:e,onChange:t,emptyHint:a??Lr})}function zr({value:t,onChange:r,emptyHint:i}){let{t:a}=O(),o=t?.windows??[],s=t?.invert??!1,l=(e,n)=>{if(e.length===0){r(void 0);return}r({windows:e,...n?{invert:!0}:{},...t?.timezone?{timezone:t.timezone}:{}})},u=()=>l([...o,Fr()],s),d=e=>l(o.filter((t,n)=>n!==e),s),f=(e,t)=>l(o.map((n,r)=>r===e?t:n),s);return e(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-windows`,children:[o.length===0?n(`p`,{className:Z,children:i}):o.map((e,t)=>n(Vr,{window:e,onChange:e=>f(t,e),onRemove:()=>d(t)},t)),e(`div`,{className:`flex items-center gap-3`,children:[e(`button`,{type:`button`,onClick:u,className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[n(c,{className:`h-3 w-3`}),` `,a(`system.notificationScheduleField.addWindow`)]}),o.length>0&&e(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[n(`input`,{type:`checkbox`,checked:s,onChange:e=>l([...o],e.target.checked),className:`accent-primary`}),a(`system.notificationScheduleField.activeOutsideTheWindows`,`Active outside the windows`)]})]})]})}function Br({value:t,onChange:r,defaultMinute:i}){let{t:a}=O(),o=t?.timezone,s=t===void 0?{times:[],approximated:!1}:b(t);if(s===null)return e(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times-fallback`,children:[n(`p`,{className:Z,children:a(`system.notificationScheduleField.invertedScheduleShownAsBands`,`Inverted schedule — shown as bands. Clear the invert flag (or the windows) to author punctual times.`)}),n(zr,{value:t,onChange:r,emptyHint:Lr})]});let l=s.times,u=e=>{if(e.length===0){r(void 0);return}r(Ce(e,o))};return e(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times`,children:[s.approximated&&n(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,"data-testid":`schedule-field-times-approximated`,children:a(`system.notificationScheduleField.shownAsSendAtTimes`,`Shown as send-at times from each window's end (when the summary fires). Edit or save to store them as punctual one-minute windows.`)}),l.length===0?n(`p`,{className:Z,children:a(`system.notificationScheduleField.noTimesYetAddOne`,`No times yet — add one to send on those days at that clock time.`)}):l.map((e,t)=>n(Hr,{time:e,index:t,onChange:e=>u(l.map((n,r)=>r===t?e:n)),onRemove:l.length>1?()=>u(l.filter((e,n)=>n!==t)):void 0},t)),e(`button`,{type:`button`,onClick:()=>u([...l,Ir(i)]),className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,"data-testid":`schedule-field-add-time`,children:[n(c,{className:`h-3 w-3`}),` `,a(`system.notificationScheduleField.addTime`)]})]})}function Vr({window:t,onChange:r,onRemove:i}){let{t:a}=O();return e(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[e(`div`,{className:`flex items-center gap-2 text-xs`,children:[n(`input`,{type:`time`,value:Nr(t.startMinute),onChange:e=>r({...t,startMinute:Pr(e.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),n(`span`,{className:`text-foreground-subtle`,children:`→`}),n(`input`,{type:`time`,value:Nr(t.endMinute),onChange:e=>r({...t,endMinute:Pr(e.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),n(`span`,{className:`flex-1`}),n(`button`,{type:`button`,onClick:i,"aria-label":a(`system.notificationScheduleField.removeWindow`,`Remove window`),className:`text-foreground-subtle hover:text-danger`,children:n(s,{className:`h-3.5 w-3.5`})})]}),n(Ur,{days:t.days,onToggle:e=>{let n=t.days.includes(e)?t.days.filter(t=>t!==e):[...t.days,e];n.length!==0&&r({...t,days:n})}})]})}function Hr({time:t,index:r,onChange:i,onRemove:a}){let{t:o}=O();return e(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[e(`div`,{className:`flex items-center gap-2 text-xs`,children:[n(`span`,{className:`text-foreground-subtle`,children:o(`system.notificationScheduleField.at`,`At`)}),n(`input`,{type:`time`,value:Er(t.minute),onChange:e=>i({...t,minute:Dr(e.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`,"data-testid":`schedule-field-time-${String(r)}`}),n(`span`,{className:`flex-1`}),a!==void 0&&n(`button`,{type:`button`,onClick:a,"aria-label":o(`system.notificationScheduleField.removeTime`,`Remove time`),className:`text-foreground-subtle hover:text-danger`,children:n(s,{className:`h-3.5 w-3.5`})})]}),n(Ur,{days:t.days,onToggle:e=>{let n=t.days.includes(e)?t.days.filter(t=>t!==e):[...t.days,e];n.length!==0&&i({...t,days:n})}})]})}function Ur({days:e,onToggle:t}){return n(`div`,{className:`flex flex-wrap gap-1`,children:Tr.map(r=>n(`button`,{type:`button`,onClick:()=>t(r.value),className:`rounded px-1.5 py-0.5 text-[10px] ${e.includes(r.value)?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:r.label},r.value))})}export{dn as $,ot as $t,vn as A,Et as At,Dn as B,lt as Bt,ar as C,Nt as Ct,Zn as D,tt as Dt,Qn as E,vt as Et,Cn as F,I as Ft,gn as G,_t as Gt,yn as H,ft as Ht,Nn as I,gt as It,J,at as Jt,K,xt as Kt,Sn as L,rt as Lt,Vn as M,ut as Mt,On as N,Dt as Nt,Kn as O,N as Ot,En as P,Tt as Pt,hn as Q,Ot as Qt,Y as R,it as Rt,rr as S,F as St,$n as T,ht as Tt,Mn as U,wt as Ut,kn as V,dt as Vt,In as W,Pt as Wt,pn as X,Ct as Xt,fn as Y,st as Yt,mn as Z,St as Zt,Q as _,Ze as _n,Wt as _t,Mr as a,Ie as an,on as at,ir as b,Gt as bt,lr as c,ze as cn,nn as ct,Z as d,We as dn,$t as dt,j as en,en as et,cr as f,Ye as fn,Xt as ft,wr as g,qe as gn,Vt as gt,xr as h,Le as hn,Qt as ht,jr as i,Ve as in,W as it,Fn as j,jt,_n as k,P as kt,Sr as l,Ge as ln,Yt as lt,vr as m,Be as mn,Zt as mt,$ as n,A as nn,sn as nt,br as o,Je as on,rn as ot,dr as p,Ue as pn,Jt as pt,q,yt as qt,Ar as r,Ke as rn,cn as rt,fr as s,Re as sn,an as st,Rr as t,$e as tn,G as tt,hr as u,He as un,Ht as ut,ur as v,Xe as vn,B as vt,tr as w,bt as wt,nr as x,Kt as xt,mr as y,R as yt,An as z,Mt as zt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./i18n-
|
|
1
|
+
import{t as e}from"./i18n-Bg2ooh3q.js";function t(e){return e===`totp`||e===`passkey`}function n(e){if(!e.startsWith(`#`))return null;let n=new URLSearchParams(e.slice(1)),r=n.get(`challenge`);if(r!==null){if(r.length===0)return null;let e=(n.get(`factors`)??``).split(`,`).filter(t);return e.length===0?null:{kind:`challenge`,challengeToken:r,factors:e}}let i=n.get(`error`);return i===`sso-not-linked`||i===`sso-state`?{kind:`error`,code:i,provider:n.get(`provider`)}:null}function r(t,n){switch(t){case`sso-not-linked`:return e.t(`helpers.ssoReturn.notLinked`,{provider:n??e.t(`helpers.ssoReturn.signInFallback`)});case`sso-state`:return e.t(`helpers.ssoReturn.state`)}}var i={expired:`helpers.ssoReturn.link.expired`,provider:`helpers.ssoReturn.link.provider`,session:`helpers.ssoReturn.link.session`,conflict:`helpers.ssoReturn.link.conflict`,state:`helpers.ssoReturn.link.state`};function a(t){let n=new URLSearchParams(t),r=n.get(`linked`);if(r!==null&&r.length>0)return{kind:`linked`,provider:r};let a=n.get(`linkError`);return a===null?null:{kind:`error`,message:e.t(i[a]??`helpers.ssoReturn.link.failed`)}}var o=`camstack:sso-return`,s=`camstack:sso-ack`,c=`/sso-complete`,l=1500,u=520,d=680;function f(e){if(!e.startsWith(`#`))return null;let t=new URLSearchParams(e.slice(1)),n=t.get(`return`);t.delete(`return`);let r=t.toString();return n===`login`?r.length>0?{target:n,fragment:r}:null:n===`profile`&&r.length>0?{target:n,query:r}:null}function p(e){return e.target===`login`?`/login#${e.fragment}`:`/system/my-access?${e.query}`}function m(e){let t=new URL(e,`http://placeholder.invalid`);return t.searchParams.set(`popup`,`1`),/^[a-z][a-z0-9+.-]*:/i.test(e)?t.toString():`${t.pathname}${t.search}${t.hash}`}function h(e=window){let t=Math.max(0,Math.round(e.screenX+(e.outerWidth-u)/2)),n=Math.max(0,Math.round(e.screenY+(e.outerHeight-d)/2));return[`popup=yes`,`width=${u}`,`height=${d}`,`left=${t}`,`top=${n}`,`toolbar=no`,`menubar=no`,`location=no`,`status=no`,`resizable=yes`,`scrollbars=yes`].join(`,`)}function g(e){try{return window.open(e??`about:blank`,`camstack-sso`,h())??null}catch{return null}}function _(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.target===`login`?typeof t.fragment==`string`:t.target===`profile`?typeof t.query==`string`:!1}function v(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`camstack:sso-return`&&_(t.completion)}function y(e,t,n){return t===null||e.source!==t||e.origin!==n?null:v(e.data)?e.data.completion:null}var b=`camstack-sso`,x=`camstack:sso-done`;function S(e,t){return e.target===`profile`?{target:`profile`,query:e.query}:t?{target:`login`}:null}function C(e){if(typeof e!=`object`||!e)return null;let t=e;if(t.type!==`camstack:sso-done`)return null;let n=Object.keys(t).sort().join(`,`);return t.target===`login`&&n===`target,type`?{target:`login`}:t.target===`profile`&&typeof t.query==`string`&&n===`query,target,type`?{target:`profile`,query:t.query}:null}function w(e){return typeof e==`object`&&!!e&&e.type===`camstack:sso-done-ack`}function T(e){try{let t=e.location.origin;return typeof t==`string`?t:null}catch{return null}}function E(){if(typeof BroadcastChannel>`u`)return null;try{let e=new BroadcastChannel(b);return{post:t=>e.postMessage(t),subscribe:t=>{let n=e=>t(e.data);return e.addEventListener(`message`,n),()=>e.removeEventListener(`message`,n)},close:()=>e.close()}}catch{return null}}var D=500;function O(e,t,n=window,r={}){let i=n.location.origin,a=r.channel===void 0?E():null,o=r.channel===void 0?a:r.channel,c=r.setInterval??((e,t)=>window.setInterval(e,t)),l=r.clearInterval??(e=>window.clearInterval(e)),u=!1,d=!1,f=r=>{let a=y(r,e,i);a===null||u||(u=!0,n.removeEventListener(`message`,f),e.postMessage({type:s},i),t.onReturn(a))};n.addEventListener(`message`,f);let p=o?.subscribe(e=>{let n=C(e);n===null||u||(u=!0,o.post({type:`camstack:sso-done-ack`}),t.onDone?.(n))})??null,m=c(()=>{d||!e.closed||(d=!0,l(m),t.onClosed?.())},D);return()=>{n.removeEventListener(`message`,f),p?.(),a?.close(),l(m)}}function k(e,t,n){if(t===null||e.source!==t||e.origin!==n)return!1;let r=e.data;return typeof r==`object`&&!!r&&r.type===`camstack:sso-ack`}function A(e,t){return new Promise(n=>{let r=!1,i=t(()=>{r||(r=!0,i(),n(!0))});e.setTimeout(()=>{r||(r=!0,i(),n(!1))},l)})}function j(e,t,n){let r=A(n,e=>{let r=r=>{k(r,t,n.origin)&&e()};return n.addEventListener(`message`,r),()=>n.removeEventListener(`message`,r)});try{let r={type:o,completion:e};t.postMessage(r,n.origin)}catch{}return r}function M(e,t,n){let r=A(n,e=>t.subscribe(t=>{w(t)&&e()}));return t.post({type:x,...e}),r}async function N(e,t){let n=t.opener!==null&&!t.opener.closed?t.opener:null;if(n!==null&&T(n)===t.origin&&await j(e,n,t)){t.close();return}let r=e.target===`login`?new URLSearchParams(e.fragment).get(`token`):null,i=r!==null&&r.length>0,o=S(e,i);if(o!==null&&t.channel!==null&&(r!==null&&i&&await t.persistSession(r),await M(o,t.channel,t))){t.close();return}if(n!==null&&e.target===`profile`){let n=a(`?${e.query}`);if(n?.kind===`error`){t.showResult({kind:`link-error`,message:n.message});return}t.close();return}t.continueAt(p(e))}function P(e,t){return(t.length>0&&e.startsWith(t)?e.slice(t.length):e).replace(/\/+$/,``)===c}export{f as a,m as c,r as d,g as i,a as l,P as n,T as o,E as r,O as s,N as t,n as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as e,R as t,et as n}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ur as r,ao as i,oo as a,zo as o,zr as s}from"./client-BvflqtP1.js";import{dr as c,ir as l,or as u,rr as d,sr as f,ur as p}from"./src-KDhMZ5Ob.js";import{t as m}from"./i18n-
|
|
1
|
+
import{K as e,R as t,et as n}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ur as r,ao as i,oo as a,zo as o,zr as s}from"./client-BvflqtP1.js";import{dr as c,ir as l,or as u,rr as d,sr as f,ur as p}from"./src-KDhMZ5Ob.js";import{t as m}from"./i18n-Bg2ooh3q.js";import{et as h}from"./index-DMMw81r0.js";n();var g=`step`,_=[g,`acc`];function v(e,t){return`${e}/${t}`}function y(e,t,n){let r=n.step!==null&&e.includes(n.step),i=n.acc!==null&&t.includes(n.acc);return{stepId:r?n.step:null,acceleratorId:i?n.acc:null,staleStepId:n.step!==null&&n.step!==``&&!r&&e.length>0?n.step:null}}var b=`armed:`;function x(e){return e.assignment.reasons.detection?.startsWith(b)===!0}function S(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null&&!x(e)?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function C(e){let t=[],n=[],{assignment:r,detection:i,broker:a}=e;i!==null&&i.provisioning.state===`failed`&&t.push({code:`provisioning-failed`,severity:`error`,message:i.provisioning.error!==void 0&&i.provisioning.error.length>0?m.t(`helpers.cameraCardModel.provisioningFailedWith`,{error:i.provisioning.error}):m.t(`helpers.cameraCardModel.provisioningFailed`)}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:m.t(`helpers.cameraCardModel.blackHole`)}),r.detectionNodeId===null&&i===null&&!x(e)&&n.push({code:`unassigned`,severity:`warning`,message:m.t(`helpers.cameraCardModel.unassigned`)});let o=e.degraded??[];if(o.length>0){let e=[...new Set(o.map(e=>e.stage))].join(`, `);n.push({code:`status-unreadable`,severity:`warning`,message:m.t(`helpers.cameraCardModel.statusUnreadable`,{stages:e})})}n.push(...ne(e.cameraSensors));for(let e of a?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:m.t(`helpers.cameraCardModel.brokerStalled`,{profile:e.profile})});return[...t,...n]}function ee(e){return e.state===`unreadable`&&r.state===`unreadable`&&e.reason===r.reason}function te(e){switch(e.state){case`ready`:return null;case`missing`:return{code:`camera-sensor-missing`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorMissing`,{addonId:e.addonId,stableId:e.stableId})};case`offline`:return{code:`camera-sensor-offline`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorOffline`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unsupported`:return{code:`camera-sensor-unsupported`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorUnsupported`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unreadable`:return{code:`camera-sensor-unreadable`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorUnreadable`,{addonId:e.addonId,stableId:e.stableId,reason:e.reason})}}}function ne(e){if(e===void 0||e.state===`not-configured`)return[];if(e.state===`unreadable`)return ee(e)?[]:[{code:`camera-sensors-unreadable`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorsUnreadable`,{reason:e.reason})}];let t=e.sensors.flatMap(e=>{let t=te(e);return t===null?[]:[t]}),n=e.notForwarded===void 0?t:[w(e.notForwarded),...t];return e.notEnforced===void 0?n:[{code:`camera-sensors-not-enforced`,severity:`warning`,message:m.t(`helpers.cameraCardModel.notEnforced`)},...n]}function w(e){return{code:`camera-sensors-not-forwarded`,severity:`warning`,message:e===`onboard-not-listed`?m.t(`helpers.cameraCardModel.notForwardedOnboard`):m.t(`helpers.cameraCardModel.notForwardedNoDetection`)}}function T(e){return e===void 0?m.t(`helpers.cameraCardModel.summaryUnavailable`):e.state===`not-configured`?m.t(`helpers.cameraCardModel.summaryNone`):e.state===`unreadable`?m.t(`helpers.cameraCardModel.summaryUnknown`,{reason:e.reason}):e.sensors.map(D).join(`, `)}function E(e){return e.mode===`in-addition`?``:` · ${e.mode}`}function D(e){return`${O(e)}${E(e)}`}function O(e){switch(e.state){case`ready`:return`${e.name} (#${e.deviceId})`;case`offline`:return`${e.name} (#${e.deviceId}) — ${e.reason}`;case`unsupported`:return m.t(`helpers.cameraCardModel.summaryUnsupported`,{name:e.name,deviceId:e.deviceId});case`missing`:case`unreadable`:return`${e.addonId}/${e.stableId} — ${e.state}`}}function k(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function A(e){return typeof e==`string`&&e.length>0?e:null}function j(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function M(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function N(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var P={detectionMode:null,detectionStreamProfile:null,detectionFps:null,motionSources:[],motionFps:null,motionCooldownMs:null,motionStreamProfile:null,audioMode:null,pipelineNodeId:null,decoderNodeId:null,audioNodeId:null,overriddenKeys:new Set};function F(e){if(!k(e)||!Array.isArray(e.sections))return P;let t=o(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},r=new Set;for(let[e,n]of t)N(n.value,n.default)&&r.add(e);return{detectionMode:A(n(`detectionMode`)),detectionStreamProfile:A(n(`detectionStreamProfile`)),detectionFps:j(n(`detectionFps`)),motionSources:M(n(`motionSources`)),motionFps:j(n(`motionFps`)),motionCooldownMs:j(n(`motionCooldownMs`)),motionStreamProfile:A(n(`motionStreamProfile`)),audioMode:A(n(`audioMode`)),pipelineNodeId:A(n(`pipelineNodeId`)),decoderNodeId:A(n(`decoderNodeId`)),audioNodeId:A(n(`audioNodeId`)),overriddenKeys:r}}function I(e,t=0){let n=[];for(let r of e)n.push({addonId:r.addonId,modelId:r.modelId??null,enabled:r.enabled,depth:t}),r.children!==void 0&&r.children.length>0&&n.push(...I(r.children,t+1));return n}function L(n,r){let[i,a]=h(),o=i.get(g),s=i.get(`acc`),c=e(()=>y(n,r,{step:o,acc:s}),[n,r,o,s]),l=t(e=>{a(t=>{let n=new URLSearchParams(t);return e(n),n},{replace:!0})},[a]);return{selection:c,open:t(e=>l(t=>{t.set(g,e.stepId),e.acceleratorId===void 0?t.delete(`acc`):t.set(`acc`,e.acceleratorId)}),[l]),close:t(()=>l(e=>{e.delete(g),e.delete(`acc`)}),[l])}}function R(e,t){for(let n of e?.slots??[])for(let e of n.addons)if(e.id===t)return e;return null}function z(e){return e.split(`.`)[0]??e}function B(e,t,n){return{id:v(e,n.key),nodeId:e,deviceKey:n.key,device:n,label:`${z(t)} · ${p(n)}`,shortLabel:`${z(t)} · ${c(n)}`,nodeLabel:z(t),disabled:!n.enabled}}function V(e,t,n,r=!1){return n.filter(e=>r||e.enabled).map(n=>B(e,t,n))}function H(e,t,n){return{modelId:u({catalog:e,device:t.device,base:n.nodePin}),source:n.nodePin===void 0?`default`:`node`}}function U(e,t){let n=R(e,`object-detection`);if(n===null)return;let r=u({catalog:n,device:t.device,base:t.device.steps?.[`object-detection`]?.modelId});if(r===void 0)return;let i=n.models.find(e=>e.id===r);return{modelId:r,name:i?.name??r,supplies:i?.suppliesSteps??[]}}function W(e,t,n){return!i(e)||n===void 0?!1:a(e,t,n.supplies).effective}function G(e,t){return e!==null&&f(e.models,t.device.format)}function K(e){return G(e.addon,e.acc)?e.clusterModelId===void 0?{kind:`enabled`,modelId:e.model.modelId??`Auto`,...e.rootName===void 0?{}:{suppliedByRoot:e.rootName},...e.jumpTo===void 0?{}:{jumpTo:e.jumpTo}}:{kind:`enabled`,modelId:e.clusterModelId,clusterWide:!0}:e.gatedOn?e.jumpTo===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:e.jumpTo}:{kind:`na`}}function q(e){if(e===null)return[];let t=(e.configSchema??[]).flatMap(e=>`label`in e&&typeof e.label==`string`?[e.label]:[]),n=s(e.id).map(e=>e.label);return[...new Set([...t,...n])]}function J(e){return e.flatMap(e=>[{node:e,depth:0},...J(e.children).map(e=>({node:e.node,depth:e.depth+1}))])}function Y(e){return l(e)}function X(e){return{nodeFields:Y(e),acceleratorFields:Z(e)}}function Z(e){return e.flatMap(e=>{if(e.type===`group`){let t=Z(e.fields);return t.length>0?[{...e,fields:[...t]}]:[]}return d(e)?[e]:[]})}function Q(e){return e.some(e=>e.type===`group`?Q(e.fields):d(e))}function $(e,t){return e.flatMap(e=>{let n=$(e.children,t);return t.has(e.addonId)||n.length>0?[{...e,children:n}]:[]})}export{F as _,J as a,_ as b,U as c,q as d,H as f,C as g,T as h,R as i,G as l,L as m,K as n,Q as o,W as p,$ as r,V as s,Y as t,X as u,I as v,S as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,et as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{zt as a}from"./player-overlays-DpZIxQHp.js";import{t as o}from"./Trans-
|
|
1
|
+
import{C as e,K as t,R as n,S as r,et as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{zt as a}from"./player-overlays-DpZIxQHp.js";import{t as o}from"./Trans-Bsz5Pghy.js";import{et as s}from"./index-DMMw81r0.js";function c({staleNodeId:t,shownNodeName:n}){return t===null?null:e(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[r(a,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),r(`span`,{children:r(o,{i18nKey:`shared.staleNodeNotice.notice`,values:{id:t,name:n},components:{b:r(`span`,{className:`font-medium text-foreground`})}})})]})}i();var l=`node`;function u(e){return[...e].toSorted((e,t)=>e.isHub===t.isHub?e.isOnline===t.isOnline?e.name.localeCompare(t.name):e.isOnline?-1:1:e.isHub?-1:1)}function d(e,t){let n=u(e),r=n[0]??null;if(r===null)return{node:null,outcome:`empty`,staleNodeId:null};if(t===null||t.length===0)return{node:r,outcome:`default`,staleNodeId:null};let i=n.find(e=>e.id===t);return i===void 0?{node:r,outcome:`stale`,staleNodeId:t}:{node:i,outcome:`requested`,staleNodeId:null}}function f(e){let[r,i]=s(),a=r.get(l);return{selection:t(()=>d(e,a),[e,a]),selectNode:n(e=>{let t=new URLSearchParams(r);t.set(l,e),i(t,{replace:!0})},[r,i]),requestedNodeId:a}}export{c as n,f as t};
|