@camstack/addon-admin-ui 1.2.718 → 1.2.719

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/assets/{AccessSection-P1MJ1Af8.js → AccessSection-BDNf7fWa.js} +1 -1
  3. package/dist/assets/{Addons-CoLqo2lc.js → Addons-BBg5QUv1.js} +3 -3
  4. package/dist/assets/AdminPage-Cgexl7PK.js +1 -0
  5. package/dist/assets/{AdminSectionedPage-hd8ao26g.js → AdminSectionedPage-DeBFqnL9.js} +1 -1
  6. package/dist/assets/AiProfiles-DK-d5If4.js +3 -0
  7. package/dist/assets/{Archive-0caQVUfL.js → Archive-BmeuZDgK.js} +1 -1
  8. package/dist/assets/{BootstrapSettingsForm-DZNHEP1l.js → BootstrapSettingsForm-CQ3gKeRA.js} +1 -1
  9. package/dist/assets/{Build-KW1nXkOY.js → Build-C46zZKEk.js} +4 -4
  10. package/dist/assets/{Calendars-Cqys33rs.js → Calendars-B2_pD0Oc.js} +1 -1
  11. package/dist/assets/{Cluster-Dey295CP.js → Cluster-D35XsJOD.js} +1 -1
  12. package/dist/assets/{CompositionBlockEditor-cTC7q4ie.js → CompositionBlockEditor-QKA5nMCB.js} +2 -2
  13. package/dist/assets/CompositionEditorPage-BsIycFw4.js +1 -0
  14. package/dist/assets/{Data-BgtEMfAp.js → Data-Dufa6STk.js} +2 -2
  15. package/dist/assets/DeviceDetail-iGVYGmkf.js +1 -0
  16. package/dist/assets/{Devices--k3NZKM5.js → Devices-DjJ2lZFz.js} +1 -1
  17. package/dist/assets/{EmbedDevicePage-D1M9MuyT.js → EmbedDevicePage-B6jliGSU.js} +1 -1
  18. package/dist/assets/{EmbedPlayerPage-BOYfGF6S.js → EmbedPlayerPage-DPSpe0fe.js} +1 -1
  19. package/dist/assets/{History-Cj_RFHCP.js → History-YW45zgFF.js} +1 -1
  20. package/dist/assets/{Identity-BpkCUd4w.js → Identity-CB93BP9K.js} +1 -1
  21. package/dist/assets/InstancesTable-DqOZKOiw.js +1 -0
  22. package/dist/assets/{IntegrationDetail-C0zFWEqE.js → IntegrationDetail-DRGef_TD.js} +1 -1
  23. package/dist/assets/{Integrations-CtaAEnny.js → Integrations-BLSCtn93.js} +2 -2
  24. package/dist/assets/Integrations-D3HWeUYL.js +1 -0
  25. package/dist/assets/{Library-CA4q_GKE.js → Library-B0AK9o5k.js} +1 -1
  26. package/dist/assets/{Locations-Cyc1rEId.js → Locations-MSracM56.js} +2 -2
  27. package/dist/assets/{Logs-Bdh6t2qZ.js → Logs-C9YNGUTC.js} +1 -1
  28. package/dist/assets/{MaskShapeCanvas-CRrBVQN6.js → MaskShapeCanvas-DdB2to38.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-BpOT--yi.js → MotionZonesSettings-C0AZq1h1.js} +1 -1
  30. package/dist/assets/{MyAccess-Bip69nz7.js → MyAccess-D1eUb8NO.js} +1 -1
  31. package/dist/assets/{Network-DpJy2Ox2.js → Network-D5UuhaFs.js} +1 -1
  32. package/dist/assets/{NewExportModal-Bh8ZMA-X.js → NewExportModal-CRG5X9Xd.js} +1 -1
  33. package/dist/assets/{NodeAddonsSettingsPanel-ZE9xL-Lw.js → NodeAddonsSettingsPanel-DK5hH6AQ.js} +1 -1
  34. package/dist/assets/Notifications-DkXaGj0i.js +1 -0
  35. package/dist/assets/{PanelContent-C7DmssXY.js → PanelContent-DvRTzrSI.js} +1 -1
  36. package/dist/assets/{Pipeline-B4OKUAfV.js → Pipeline-CUzcbUT6.js} +1 -1
  37. package/dist/assets/{PrivacyMaskSettings-cBVnAPXJ.js → PrivacyMaskSettings-DMAeCCre.js} +1 -1
  38. package/dist/assets/{SceneMonitorEditor-BN6VvtMB.js → SceneMonitorEditor-yL3465Qt.js} +1 -1
  39. package/dist/assets/{SessionsList-BP--gkgA.js → SessionsList-DeqXjMvl.js} +1 -1
  40. package/dist/assets/{Showroom-io1e71Ip.js → Showroom-C8uNo6FX.js} +1 -1
  41. package/dist/assets/{StorageLocationsTable-Din9h-wU.js → StorageLocationsTable-Blio9Uwn.js} +1 -1
  42. package/dist/assets/{System-BF52Cmv1.js → System-B_Bhbm6A.js} +2 -2
  43. package/dist/assets/{TemplateEditorDialog-uOp2nN0j.js → TemplateEditorDialog-B7nwBFDa.js} +1 -1
  44. package/dist/assets/{Terminal-CBEq96Qx.js → Terminal-BSi5279J.js} +1 -1
  45. package/dist/assets/{TrainingProviders-DCnc4U_D.js → TrainingProviders-B5mWrv0H.js} +1 -1
  46. package/dist/assets/{Viewer-Dsyh2qsY.js → Viewer-CVHhRxp4.js} +1 -1
  47. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C2vqPlWv.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BcuvvAg7.js} +1 -1
  48. package/dist/assets/{action-draft-Dnkwhjii.js → action-draft-mvm1fG3Z.js} +1 -1
  49. package/dist/assets/{assignment-candidates-CmTpbdAE.js → assignment-candidates-BspACTRE.js} +1 -1
  50. package/dist/assets/{authed-media-Br5-b-q4.js → authed-media-C1lGKHUu.js} +1 -1
  51. package/dist/assets/{camera-block-model-BNOrk3xs.js → camera-block-model-Cy-p9VXW.js} +1 -1
  52. package/dist/assets/{client-IyXbQ5wB.js → client-CiiufhtZ.js} +1 -1
  53. package/dist/assets/{command-vocab-UYmHJdEK.js → command-vocab-DrT4yI_w.js} +1 -1
  54. package/dist/assets/{device-integration-icon-DehLyJtV.js → device-integration-icon-ltuTuHtu.js} +1 -1
  55. package/dist/assets/device-picker-model-CHH_K0iv.js +1 -0
  56. package/dist/assets/{dist-BueezuOF.js → dist-3oPp68KS.js} +1 -1
  57. package/dist/assets/{dist-DmzPECbr.js → dist-DFGzwWFe.js} +1 -1
  58. package/dist/assets/{hostInit-BMtkho8X.js → hostInit-CML8wGF-.js} +1 -1
  59. package/dist/assets/{icons-BUNXeEdz.js → icons-C86IhfQA.js} +1 -1
  60. package/dist/assets/index-BVScunnp.css +2 -0
  61. package/dist/assets/{index-BmLC_5Cb.js → index-BYgap-bt.js} +4 -4
  62. package/dist/assets/{linked-devices-model-BGMuuMzy.js → linked-devices-model-Bdif5rHp.js} +1 -1
  63. package/dist/assets/{mf-entry-bootstrap-0-a78a180a.js → mf-entry-bootstrap-0-442bdc59.js} +2 -2
  64. package/dist/assets/mount-CHH_K0iv.js +1 -0
  65. package/dist/assets/{player-overlays-DkSQ1HVl.js → player-overlays-CX_koJa1.js} +1 -1
  66. package/dist/assets/remoteEntry-CWH31XW5.js +1 -0
  67. package/dist/assets/{src-CW12NqJP.js → src-vFbZMtSO.js} +20 -20
  68. package/dist/assets/{step-inspector-model-D3UkdAKW.js → step-inspector-model-xQUBFCp-.js} +1 -1
  69. package/dist/assets/{use-scenes-feed-Bl2YPeyM.js → use-scenes-feed-CzaOWh_W.js} +1 -1
  70. package/dist/assets/{useAdminDeviceRemoval-Bzc7SQeT.js → useAdminDeviceRemoval-D_Wkm6SL.js} +1 -1
  71. package/dist/assets/useEventInvalidation-CHH_K0iv.js +1 -0
  72. package/dist/assets/{useNodeUrlSelection-CI6VTVnc.js → useNodeUrlSelection-CfVGV8Yj.js} +1 -1
  73. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Ctg3L5lP.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CGyGOGfX.js} +2 -2
  74. package/dist/index.html +7 -7
  75. package/dist/server/addon.js +3 -1
  76. package/package.json +2 -2
  77. package/dist/assets/AdminPage-BGa6IwpR.js +0 -1
  78. package/dist/assets/AiProfiles-Bmr8Ii_9.js +0 -3
  79. package/dist/assets/CompositionEditorPage-DiSpMpz9.js +0 -1
  80. package/dist/assets/DeviceDetail-DHJ9hpXL.js +0 -1
  81. package/dist/assets/InstancesTable-dsVwH4u-.js +0 -1
  82. package/dist/assets/Integrations-BNgcJLme.js +0 -1
  83. package/dist/assets/Notifications-DEex-X-t.js +0 -1
  84. package/dist/assets/device-picker-model-Bopf0JEx.js +0 -1
  85. package/dist/assets/index-zqjSOnoV.css +0 -2
  86. package/dist/assets/mount-Bopf0JEx.js +0 -1
  87. package/dist/assets/remoteEntry-B1UIN5Qt.js +0 -1
  88. package/dist/assets/useEventInvalidation-Bopf0JEx.js +0 -1
@@ -1110,7 +1110,7 @@ ${d.map(({leaf:e,path:t})=>Kfe(e,t)).join(`
1110
1110
  }
1111
1111
  }
1112
1112
  `}function ipe(e){return`subjects`in e?e.subjects:e.classes.map(yg)}var ape=new Set(Object.values(ug.mapping));function ope(e){return ug.mapping[e]??e}function spe(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r?!0:ape.has(n)&&ope(r)===n}function cpe(e){return e===`start`||e===`update`||e===`end`}var lpe=class{trigger;fired=new Map;subjects;constructor(e){this.trigger=e,this.subjects=ipe(e)}get firedCount(){return this.fired.size}evaluate(e,t){let{deviceId:n,trackId:r,phase:i}=e;if(typeof n!=`number`||typeof r!=`string`||!cpe(i))return{kind:`ignore`,why:`malformed track-lifecycle event`};if(!this.trigger.deviceIds.includes(n))return{kind:`ignore`,why:`device ${n} is not one of the trigger's devices`};let a=`${n}|${r}`;if(i===`end`)return this.fired.delete(a),{kind:`ignore`,why:`track ended`};this.expire(t);let o=typeof e.bestClassName==`string`?e.bestClassName:``,s=typeof e.bestConfidence==`number`?e.bestConfidence:0,c={deviceId:n,className:o,trackId:r,score:s,label:``};if(this.fired.has(a))return{kind:`reject`,reason:`already fired for track ${r}`,vars:c};let l=Cg(this.subjects,{className:o,...Array.isArray(e.classes)?{classes:e.classes.filter(e=>typeof e==`string`)}:{},...typeof e.label==`string`?{label:e.label}:{},...typeof e.identityId==`string`?{identityId:e.identityId}:{},...typeof e.plateText==`string`?{plateText:e.plateText}:{}});if(!l.matches)return{kind:`reject`,reason:l.reason,vars:c};let u={...c,label:l.label};if(this.trigger.minScore!==void 0&&s<this.trigger.minScore)return{kind:`reject`,reason:`score ${s} < ${this.trigger.minScore}`,vars:u};if(this.trigger.zones!==void 0){let t=Array.isArray(e.zonesVisited)?e.zonesVisited.filter(e=>typeof e==`string`):[];if(!this.trigger.zones.some(e=>t.includes(e)))return{kind:`reject`,reason:`zone mismatch: visited [${t.join(`, `)}], wanted [${this.trigger.zones.join(`, `)}]`,vars:u}}return this.remember(a,t),{kind:`fire`,reason:`${l.label===``?o:l.label} ${s} on device ${n}`,vars:u}}remember(e,t){for(this.fired.set(e,t);this.fired.size>512;){let e=this.fired.keys().next();if(e.done===!0)break;this.fired.delete(e.value)}}expire(e){for(let[t,n]of this.fired){if(e-n<9e5)break;this.fired.delete(t)}}};function upe(e){return`classes`in e}function dpe(e){return e===`appeared`||e===`departed`}function fpe(e,t){let{deviceId:n,entryId:r,phase:i}=t;if(typeof n!=`number`||typeof r!=`string`||!dpe(i))return{kind:`ignore`,why:`malformed stationary-changed event`};if(!e.deviceIds.includes(n))return{kind:`ignore`,why:`device ${n} is not one of the trigger's devices`};if(i!==e.phase)return{kind:`ignore`,why:`phase ${i}, the trigger wants ${e.phase}`};let a=typeof t.className==`string`?t.className:``,o=Array.isArray(t.zones)?t.zones.filter(e=>typeof e==`string`):[],s={deviceId:n,className:a,zones:o,phase:i,entryId:r},c=upe(e)?e.classes?.map(yg):e.subjects;if(c!==void 0){let e=Cg(c,{className:a});if(!e.matches)return{kind:`reject`,reason:e.reason,vars:s}}return e.zones!==void 0&&!e.zones.some(e=>o.includes(e))?{kind:`reject`,reason:`zone mismatch: in [${o.join(`, `)}], wanted [${e.zones.join(`, `)}]`,vars:s}:{kind:`fire`,reason:`${a} ${i} on device ${n}`,vars:s}}function L(e,t){return{en:e,it:t}}var yv=x({deviceId:r(),eventType:u(),sourceId:u().optional(),data:h(u(),w()).nullable(),timestamp:r().meta(A(`none`)),seq:r().meta(A(`count`))}),bv=x({eventTypes:C(u()),vocabulary:C(um).default([]),lastEvent:yv.nullable(),eventCountSinceStart:r().meta(A(`count`))}),xv={name:`event-emitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.EventEmitter],methods:{},events:{onEvent:{data:yv,trigger:{category:T.EventEmitted,label:L(`Fired an event`,`Ha generato un evento`),phrase:L(`When {device} fires an event`,`Quando {device} genera un evento`),icon:`zap`}}},status:{schema:bv,kind:`push`},runtimeState:bv,durability:`session`,history:`none`,vocabulary:{noun:L(`Event source`,`Sorgente di eventi`),order:5280}},ppe=3,mpe=32;function hpe(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function Sv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function gpe(e){let t={},n=(e,r,i)=>{if(!(Object.keys(t).length>=mpe)){if(hpe(e)){t[r]=e;return}if(!(!Sv(e)||i>=ppe))for(let[t,a]of Object.entries(e))n(a,`${r}.${t}`,i+1)}};if(Sv(e))for(let[t,r]of Object.entries(e))n(r,`data.${t}`,1);return t}function _pe(e,t){let n=e;for(let e of t.split(`.`)){if(!Sv(n))return;n=n[e]}return n}function vpe(e,t){return t===null?!0:e.timestamp===t.timestamp?e.seq>t.seq:e.timestamp>t.timestamp}var ype=`recovered by reconcile`,bpe=class{leaf;#e=null;#t=!1;#n=null;constructor(e){this.leaf=e}onEvent(e){let t=yv.safeParse(e);if(!t.success)return{kind:`ignore`,why:`malformed event`};let n=t.data;return n.deviceId===this.leaf.deviceId?vpe(n,this.#e)?(this.#e={timestamp:n.timestamp,seq:n.seq},this.#t=!0,this.#i(n,!1)):{kind:`ignore`,why:`this fire was already handled`}:{kind:`ignore`,why:`device ${n.deviceId} is not the trigger's device`}}onStatus(e){let t=bv.safeParse(e);if(!t.success)return{kind:`ignore`,why:`the event-emitter status is unreadable`};this.#n=mm(t.data);let n=t.data.lastEvent,r=!this.#t;return this.#t=!0,n===null?{kind:`ignore`,why:`the device has not fired`}:vpe(n,this.#e)?(this.#e={timestamp:n.timestamp,seq:n.seq},r?{kind:`ignore`,why:`seeded: what fired before the start is not a trigger`}:n.deviceId===this.leaf.deviceId?this.#i(n,!0):{kind:`ignore`,why:`device ${n.deviceId} is not the trigger's device`}):{kind:`ignore`,why:`this fire was already handled`}}#r(e){let t=this.#n??pm([e.eventType]);return(hm(t,e.eventType,e.sourceId)??hm(t,e.eventType))?.kind}#i(e,t){let{eventIds:n,sourceIds:r,kinds:i,match:a}=this.leaf;if(n!==void 0&&!n.includes(e.eventType))return{kind:`ignore`,why:`event ${e.eventType} is not one of [${n.join(`, `)}]`};if(r!==void 0&&(e.sourceId===void 0||!r.includes(e.sourceId)))return{kind:`ignore`,why:`source ${e.sourceId??`(none)`} is not one of [${r.join(`, `)}]`};let o=this.#r(e);if(i!==void 0&&(o===void 0||!i.includes(o)))return{kind:`ignore`,why:`kind ${o??`(none)`} is not one of [${i.join(`, `)}]`};let s={deviceId:e.deviceId,eventType:e.eventType,sourceId:e.sourceId??``,eventKind:o??``},c=gpe(e.data);for(let t of a??[]){let n=_pe(e.data,t.path);if(n!==t.equals)return{kind:`reject`,reason:`data.${t.path} is ${JSON.stringify(n)??`not set`}, the trigger wants ${JSON.stringify(t.equals)}`,vars:s,data:c}}let l=`${e.eventType}${e.sourceId===void 0?``:` from ${e.sourceId}`}`;return{kind:`fire`,reason:t?`${l} — ${ype}`:l,vars:s,data:c}}},xpe=6e4;function Cv(e){return(e/xpe).toFixed(1)}var Spe=class{mode;active=0;pending=0;constructor(e){this.mode=e}get activeRuns(){return this.active}get queuedTriggers(){return this.pending}admit(){let e=this.mode;switch(e.mode){case`single`:case`cooldown`:return this.active>0?{decision:`drop`,reason:`${e.mode}: a run is already in progress`}:(this.active+=1,{decision:`run`,reason:`${e.mode}: no run in progress`});case`restart`:return this.active>0?(this.active+=1,{decision:`restart`,reason:`restart: aborting ${this.active-1} run(s) in progress`}):(this.active+=1,{decision:`run`,reason:`restart: no run in progress`});case`queued`:return this.active===0?(this.active+=1,{decision:`run`,reason:`queued: no run in progress`}):this.pending<e.max?(this.pending+=1,{decision:`queued`,reason:`queued: a run is in progress, waiting ${this.pending} of ${e.max}`}):{decision:`drop`,reason:`queued: a run is in progress and the queue is full (${e.max})`};case`parallel`:return this.active<e.max?(this.active+=1,{decision:`run`,reason:`parallel: ${this.active} of ${e.max} running`}):{decision:`drop`,reason:`parallel: ${e.max} runs already in progress`}}}release(){return this.active>0&&--this.active,this.mode.mode===`queued`&&this.pending>0?(--this.pending,this.active+=1,!0):!1}cooldown(e){if(this.mode.mode!==`cooldown`)return{ok:!0,bypassed:!1,reason:``};let t=this.mode.minutes*xpe;if(e.lastRunStartedAt===null)return{ok:!0,bypassed:!1,reason:`cooldown ${this.mode.minutes} min: no earlier run`};let n=e.now-e.lastRunStartedAt;if(n>=t)return{ok:!0,bypassed:!1,reason:`cooldown ${this.mode.minutes} min: last run started ${Cv(n)} min ago`};let r=`${Cv(t-n)} min left`;return e.manual?{ok:!0,bypassed:!0,reason:`cooldown ${this.mode.minutes} min bypassed by a manual trigger (${r})`}:{ok:!1,bypassed:!1,reason:`cooldown ${this.mode.minutes} min: last run started ${Cv(n)} min ago, ${r}`}}},Cpe=S([`string`,`number`,`boolean`,`select`]),wpe=/^[A-Za-z_][A-Za-z0-9_]*$/,wv=g([u(),r(),y()]),Tv=x({name:u().regex(wpe),label:u().min(1).max(120).optional(),type:Cpe,required:y().optional(),default:wv.optional(),options:C(u().min(1)).min(1).optional()}).superRefine((e,t)=>{e.type===`select`&&e.options===void 0&&t.addIssue({code:`custom`,message:`a select variable needs options`,path:[`options`]}),e.default!==void 0&&Ev(e,e.default)!==null&&t.addIssue({code:`custom`,message:Ev(e,e.default)??`invalid default`,path:[`default`]})});function Ev(e,t){switch(e.type){case`string`:return typeof t==`string`?null:`variable "${e.name}" must be a string`;case`number`:return typeof t==`number`&&Number.isFinite(t)?null:`variable "${e.name}" must be a number`;case`boolean`:return typeof t==`boolean`?null:`variable "${e.name}" must be true or false`;case`select`:return typeof t==`string`&&(e.options??[]).includes(t)?null:`variable "${e.name}" must be one of ${(e.options??[]).join(`, `)}`}}function Tpe(e,t){let n=e??[],r=t??{};for(let e of Object.keys(r))if(!n.some(t=>t.name===e))return{ok:!1,error:`unknown variable "${e}"`};let i={};for(let e of n){let t=r[e.name]??e.default;if(t===void 0){if(e.required===!0)return{ok:!1,error:`variable "${e.name}" is required`};continue}let n=Ev(e,t);if(n!==null)return{ok:!1,error:n};i[e.name]=t}return{ok:!0,values:i}}var Epe=S([`internal`,`addon`]),Dpe=`internal:`;function Ope(e){return`${Dpe}${e}`}function Dv(e){return e.startsWith(`internal:`)&&e.length>9}function kpe(e){if(Dv(e))return null;let t=e.indexOf(`:`);return t>0&&t<e.length-1?e.slice(0,t):null}var Ape=x({isRunning:y(),lastRunAt:r().nullable(),lastError:u().nullable()}),jpe={isRunning:!1,lastRunAt:null,lastError:null},Ov=r().int().min(0).max(86400),kv=x({id:u().min(3),name:u().min(1).max(120),addonId:u().min(1),source:Epe,readOnly:y(),steps:C(u_).min(1).max(50).optional(),variables:C(Tv).max(20).optional(),minDelaySec:Ov.optional(),tags:Td.optional(),status:Ape}).superRefine((e,t)=>{if(e.source===`internal`){Dv(e.id)||t.addIssue({code:`custom`,message:`an internal action id is internal:<uuid>`,path:[`id`]});return}e.steps!==void 0&&t.addIssue({code:`custom`,message:`only an internal action carries steps`,path:[`steps`]}),e.readOnly||t.addIssue({code:`custom`,message:`an addon action is read-only here`,path:[`readOnly`]}),kpe(e.id)===null&&t.addIssue({code:`custom`,message:`an addon action id is <addonId>:<localId>`,path:[`id`]})}),Av=x({name:u().min(1).max(120),steps:C(u_).min(1).max(50),variables:C(Tv).max(20).optional(),minDelaySec:Ov.optional(),tags:Td.optional()}),Mpe=x({blockId:u().min(1).optional()}),Npe=g([z_,m(`started`),m(`timed-out`)]),Ppe=x({runId:u().min(1),outcome:Npe,message:u().optional()}),Fpe=S([`not-found`,`read-only`,`invalid-variables`,`invalid-steps`,`not-linked`,`template-scope`,`busy`]),Ipe=class extends Error{code;constructor(e,t){super(`[${e}] ${t}`),this.name=`ActionError`,this.code=e}},Lpe=x({actionId:u(),runId:u(),isRunning:y(),outcome:z_.optional(),lastRunAt:r().nullable(),lastError:u().nullable()});function Rpe(e){switch(e.kind){case`wait`:case`command`:return`else`in e?e.else??[]:[];case`parallel`:case`repeat`:return e.steps;case`choose`:return[...e.branches.flatMap(e=>e.steps),...e.else??[]];default:return[]}}function zpe(e){return[...e.kind===`command`&&e.target.kind===`devices`?[{actionId:e.actionId,ids:e.target.ids}]:[],...Rpe(e).flatMap(zpe)]}async function Bpe(e,t){let n=e.flatMap(zpe);if(n.length===0)return;let r=[...new Set(n.flatMap(e=>e.ids))],i=r.length===0?new Map:await t.boundCapsOf(r);for(let{actionId:e,ids:t}of n){Qp(e,void 0);for(let n of t)$p(e,n,i.get(n)??[])}}async function Vpe(e,t,n=Date.now,r,i,a){let o=r?.mirror??new mfe(av(e));await o.refresh(t);let s=uv(e,o,n(),{...r===void 0?{}:{holds:r.holds,rootPath:r.rootPath},...i===void 0?{}:{site:i},trigger:a??`unknown`}),c=s.nodes.filter(e=>e.outcome!==`pass`).map(e=>e.reason)[0];return s.unknown?{result:`unknown`,reason:`a state the condition reads is not known${c===void 0?``:` (${c})`}`}:s.pass?{result:`true`,reason:`the condition holds`}:{result:`false`,reason:c??`the condition does not hold`}}async function Hpe(e){try{return await e()}catch(e){return{result:`unknown`,reason:e instanceof Error?e.message:String(e)}}}async function Upe(e){let t=e.now(),n=t+e.timeoutMs;for(;;){let r=await Hpe(e.read),i=e.now()-t;if(e.isAborted())return{result:`aborted`,waitedMs:i};if(r.result===`true`)return{result:`met`,waitedMs:i};let a=n-e.now();if(a<=0)return{result:`timed-out`,waitedMs:i,lastReason:r.reason};if(await e.nextWake(a),e.isAborted())return{result:`aborted`,waitedMs:e.now()-t}}}function Wpe(e,t){return`timed out after ${e} s: ${t}`}function jv(e){return Cc(e)}function Mv(e){let t=jv(e);if(t===void 0)return[];let n=qh(t);return n===void 0?[t]:[t,...$h(n).filter(e=>e!==t)]}var Nv=x({path:u(),deviceId:r().int().optional(),field:u(),value:r(),assumedUnit:u(),message:u()});function Gpe(e){let t=Nh(e);return t instanceof le?t:void 0}function Pv(e){let t=new Map(e.map(e=>[e.name,e]));return{fieldQuantity(e,n){let r=t.get(e)?.status;if(r!==void 0)return[...Ih(r.schema),...r.itemArray===void 0?[]:Lh(r.itemArray)].find(e=>e.path===n)?.quantity},paramMeta(e,n,r){let i=t.get(e)?.methods[n]?.input;if(i===void 0)return;let a=Gpe(i)?.shape[r];return a===void 0?void 0:og(a)}}}function Kpe(e){return Vh(e)??e}function qpe(e){return Mv(e).length>1}function Jpe(e){return{...e,message:`${e.field}: the bare number ${e.value} was taken as ${e.assumedUnit} — send { value, unit } to state the unit`}}function Ype(e,t){rg({value:1,unit:e,target:t})}function Xpe(e,t,n){let r=t.fieldQuantity(e.cap,e.fieldPath),i=r===void 0?void 0:jv(r),a=ng(e.value)||e.unit!==void 0;if(i===void 0||r===void 0){if(a)throw new eg(`no-quantity`,`${e.cap}.${e.fieldPath} is not a quantity — it takes no unit`);return{leaf:e,warnings:[]}}if(ng(e.value)){let t=rg({value:e.value.value,unit:e.value.unit,target:i});return{leaf:{...e,value:t,unit:Kpe(e.value.unit)},warnings:[]}}return typeof e.value==`number`?e.unit===void 0?qpe(r)?{leaf:e,warnings:[Jpe({path:n,deviceId:e.deviceId,field:e.fieldPath,value:e.value,assumedUnit:i})]}:{leaf:e,warnings:[]}:(Ype(e.unit,i),{leaf:e,warnings:[]}):{leaf:e,warnings:[]}}function Fv(e,t,n=`when`){switch(e.kind){case`device-is`:{let{leaf:r,warnings:i}=Xpe(e,t,n);return{value:r,warnings:i}}case`not`:{let r=Fv(e.child,t,`${n}.child`);return{value:{...e,child:r.value},warnings:r.warnings}}case`all`:case`any`:{let r=e.children.map((e,r)=>Fv(e,t,`${n}.children.${r}`));return{value:{...e,children:r.map(e=>e.value)},warnings:r.flatMap(e=>e.warnings)}}default:return{value:e,warnings:[]}}}function Zpe(e,t,n){if(Jp(e.actionId)===void 0)return{value:e,warnings:[]};let r=e.target.kind===`devices`&&e.target.ids.length===1?e.target.ids[0]:void 0,{cap:i,method:a}=Qp(e.actionId,void 0),o={...e.args},s={...e.argUnits},c=[];for(let[n,r]of Object.entries(e.argUnits??{})){let e=t.paramMeta(i,a,n);if(e===void 0)throw new eg(`no-quantity`,`${i}.${a}(${n}) is not a quantity — it takes no unit`);Ype(r,e.unit)}for(let[l,u]of Object.entries(e.args??{})){let e=t.paramMeta(i,a,l);e!==void 0&&(ng(u)?(o[l]=rg({value:u.value,unit:u.unit,target:e.unit}),s[l]=Kpe(u.unit)):typeof u==`number`&&s[l]===void 0&&qpe(e.quantity)&&c.push(Jpe({path:`${n}.args.${l}`,...r===void 0?{}:{deviceId:r},field:l,value:u,assumedUnit:e.unit})))}let{argUnits:l,...u}=e;return{value:{...u,...e.args===void 0?{}:{args:o},...Object.keys(s).length>0?{argUnits:s}:{}},warnings:c}}function Qpe(e,t,n=`steps`){let r=[],i=[];return e.forEach((e,a)=>{if(e.kind!==`command`){r.push(e);return}let o=Zpe(e,t,`${n}.${a}`);r.push(o.value),i.push(...o.warnings)}),{value:r,warnings:i}}function $pe(e,t){let n=Fv(e.when,t,`when`),r=Qpe(e.actions,t,`actions`);return{value:{...e,when:n.value,actions:r.value},warnings:[...n.warnings,...r.warnings]}}function Iv(e,t){switch(e.kind){case`device-is`:{if(typeof e.value!=`number`||e.unit!==void 0)return e;let n=t.fieldQuantity(e.cap,e.fieldPath);if(n===void 0||Mv(n).length<2)return e;let r=jv(n);return r===void 0?e:{...e,unit:r}}case`not`:return{...e,child:Iv(e.child,t)};case`all`:case`any`:return{...e,children:e.children.map(e=>Iv(e,t))};default:return e}}function eme(e,t){if(e.kind!==`command`||e.args===void 0||Jp(e.actionId)===void 0)return e;let{cap:n,method:r}=Qp(e.actionId,void 0),i={...e.argUnits};for(let[a,o]of Object.entries(e.args)){if(typeof o!=`number`||i[a]!==void 0)continue;let e=t.paramMeta(n,r,a);e!==void 0&&Mv(e.quantity).length>1&&(i[a]=e.unit)}return Object.keys(i).length===0?e:{...e,argUnits:i}}function Lv(e,t){let n={...e,when:Iv(e.when,t),actions:e.actions.map(e=>eme(e,t))};try{return{ok:!0,recipe:$pe(n,t).value}}catch(e){if(e instanceof eg)return{ok:!1,error:e.message};throw e}}var tme=[`devices`,`time`,`cameras`,`events`,`logic`,`system`],Rv=[`trigger`,`any`],zv=[`trigger`,`guard`,`any`],Bv={detection:{kind:`detection`,category:`cameras`,role:`event`,allowedIn:Rv,i18nKey:`automation.leafCatalog.detection`,keywords:[`camera`,`person`,`vehicle`,`animal`,`object`,`motion`,`detected`],needsDeviceValue:!1,seed:()=>({kind:`detection`,subjects:[{macro:`person`}],deviceIds:[]})},stationary:{kind:`stationary`,category:`cameras`,role:`event`,allowedIn:Rv,i18nKey:`automation.leafCatalog.stationary`,keywords:[`camera`,`parked`,`stops`,`leaves`,`left`,`appeared`,`object`],needsDeviceValue:!1,seed:()=>({kind:`stationary`,deviceIds:[],phase:`appeared`})},"device-becomes":{kind:`device-becomes`,category:`devices`,role:`event`,allowedIn:Rv,i18nKey:`automation.leafCatalog.device-becomes`,keywords:[`device`,`value`,`changes`,`turns`,`on`,`off`,`above`,`below`,`state`],needsDeviceValue:!0,seed:()=>({kind:`device-becomes`,deviceId:0,cap:``,fieldPath:``})},"device-event":{kind:`device-event`,category:`events`,role:`event`,allowedIn:Rv,i18nKey:`automation.leafCatalog.device-event`,keywords:[`event`,`system`,`button`,`press`,`doorbell`,`alarm`,`category`],needsDeviceValue:!1,seed:()=>({kind:`device-event`,category:``})},"device-fired":{kind:`device-fired`,category:`devices`,role:`event`,allowedIn:Rv,i18nKey:`automation.leafCatalog.device-fired`,keywords:[`button`,`press`,`long`,`remote`,`switch`,`key`,`fires`,`event`,`click`],needsDeviceValue:!1,seed:()=>({kind:`device-fired`,deviceId:0})},schedule:{kind:`schedule`,category:`time`,role:`event`,allowedIn:Rv,i18nKey:`automation.leafCatalog.schedule`,keywords:[`time`,`clock`,`daily`,`cron`,`sunrise`,`sunset`,`at`,`weekday`],needsDeviceValue:!1,seed:()=>({kind:`schedule`,cron:`0 30 23 * * *`})},interval:{kind:`interval`,category:`time`,role:`event`,allowedIn:Rv,i18nKey:`automation.leafCatalog.interval`,keywords:[`time`,`every`,`minutes`,`repeat`,`periodic`,`timer`],needsDeviceValue:!1,seed:()=>({kind:`interval`,minutes:5})},manual:{kind:`manual`,category:`system`,role:`event`,allowedIn:Rv,i18nKey:`automation.leafCatalog.manual`,keywords:[`run`,`button`,`hand`,`test`,`on demand`],needsDeviceValue:!1,seed:()=>({kind:`manual`})},"device-is":{kind:`device-is`,category:`devices`,role:`state`,allowedIn:zv,i18nKey:`automation.leafCatalog.device-is`,keywords:[`device`,`value`,`is`,`equals`,`above`,`below`,`held`,`stable`,`for`],needsDeviceValue:!0,seed:()=>({kind:`device-is`,deviceId:0,cap:``,fieldPath:``,operator:`eq`,value:``})},"stationary-present":{kind:`stationary-present`,category:`cameras`,role:`state`,allowedIn:zv,i18nKey:`automation.leafCatalog.stationary-present`,keywords:[`camera`,`parked`,`present`,`car`,`object`,`still there`],needsDeviceValue:!1,seed:()=>({kind:`stationary-present`,deviceId:0})},"time-is":{kind:`time-is`,category:`time`,role:`state`,allowedIn:zv,i18nKey:`automation.leafCatalog.time-is`,keywords:[`time`,`hour`,`window`,`between`,`night`,`day`,`weekday`,`sunset`,`sunrise`],needsDeviceValue:!1,seed:()=>({kind:`time-is`,between:{from:{kind:`clock`,hh:22,mm:0},to:{kind:`clock`,hh:6,mm:0}}})},"triggered-by":{kind:`triggered-by`,category:`logic`,role:`state`,allowedIn:zv,i18nKey:`automation.leafCatalog.triggered-by`,keywords:[`trigger`,`triggered`,`started`,`which`,`branch`,`fired`],needsDeviceValue:!1,seed:()=>({kind:`triggered-by`,leafIds:[]})},expression:{kind:`expression`,category:`logic`,role:`state`,allowedIn:zv,i18nKey:`automation.leafCatalog.expression`,keywords:[`formula`,`math`,`arithmetic`,`sum`,`compare`,`calculate`,`held`],needsDeviceValue:!1,seed:()=>({kind:`expression`,expr:``,bindings:{}})}},Vv=[`detection`,`stationary`,`device-becomes`,`device-fired`,`device-event`,`schedule`,`interval`,`manual`,`device-is`,`stationary-present`,`time-is`,`triggered-by`,`expression`];function nme(e){return Bv[e]}function rme(e){return Bv[e].seed()}function ime(e){return Vv.filter(t=>Bv[t].allowedIn.includes(e))}function ame(e){return e instanceof Error?e.message:String(e)}function ome(e){return e.startsWith(`[busy]`)?`already-running`:e.startsWith(`[not-found]`)?`not-found`:null}async function sme(e,t,n){let{exporter:r,actionId:i}=n,a={actionId:i},o=(e,n)=>(t.warn(`${r}: exported action not run — ${e}`,{tags:a,meta:{reason:e,...n?{detail:n}:{}}}),{status:`refused`,reason:e});try{let n=await e.actions.run.mutate({actionId:i});if(n.outcome===`skipped-overlap`)return o(`already-running`,n.message);if(n.outcome===`skipped-cooldown`)return o(`cooldown`,n.message);if(n.outcome===`failed`||n.outcome===`aborted`||n.outcome===`timed-out`){let e=n.message??n.outcome;return t.warn(`${r}: exported action failed`,{tags:a,meta:{outcome:n.outcome,message:e}}),{status:`failed`,message:e}}return t.info(`${r}: exported action ran`,{tags:a,meta:{outcome:n.outcome}}),{status:`started`}}catch(e){let n=ame(e),i=ome(n);return i===null?(t.warn(`${r}: exported action failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}):o(i,n)}}async function cme(e,t,n){let{exporter:r,targetId:i}=n,a={targetId:i};try{let{targets:o,unreadable:s}=await ka(e),c=o.find(e=>e.id===i);if(c===void 0&&s.length>0)throw Error(`notification targets unreadable from ${s.map(e=>e.addonId).join(`, `)}`);if(c===void 0)return t.warn(`${r}: exported notifier not used — target-gone`,{tags:a,meta:{reason:`target-gone`}}),{status:`refused`,reason:`target-gone`};if(!c.enabled)return t.warn(`${r}: exported notifier not used — target-disabled`,{tags:a,meta:{reason:`target-disabled`}}),{status:`refused`,reason:`target-disabled`};let l=await e.notificationOutput.send.mutate({targetId:i,addonId:c.addonId,notification:Pi.parse(n.notification)});if(!l.success){let e=l.error??`send failed`;return t.warn(`${r}: exported notifier send failed`,{tags:a,meta:{message:e}}),{status:`failed`,message:e}}return{status:`sent`}}catch(e){let n=ame(e);return t.warn(`${r}: exported notifier send failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}}}function lme(e,t,n,r){let i=[],a=[];for(let o of e)o.kind===`action`&&!t.actionIds.has(o.actionId)?(a.push(o),n.warn(`${r}: exported action was deleted — dropped from the export`,{tags:{actionId:o.actionId}})):o.kind===`notifier`&&!t.targetIds.has(o.targetId)?(a.push(o),n.warn(`${r}: exported notifier target was deleted — dropped from the export`,{tags:{targetId:o.targetId}})):i.push(o);return{kept:i,dropped:a}}var Hv=u().min(1),Uv=x({instanceId:Hv.optional()}),Wv=x({instanceId:Hv,name:u(),enabled:y(),kind:u().optional(),nameRule:u().optional()}),Gv=`export-instance-unknown`,ume=class extends Error{code=Gv;instanceId;constructor(e,t){super(`${Gv}: ${e} serves no instance "${t}"`),this.name=`ExportInstanceUnknownError`,this.instanceId=t}};function dme(e){return`instanceId`in e?e.instanceId:void 0}function fme(e,t,n){if(n!==void 0&&n!==t)throw new ume(e,n)}var pme=S([`unlinked`,`linked`,`error`]),mme=x({label:u(),value:u(),secret:y().optional()}),hme=x({qr:u().optional(),fields:C(mme).readonly().optional(),note:u().optional()}),Kv=x({linkState:pme,exposedDeviceCount:r(),error:u().optional(),setup:hme.optional()}),gme=u(),qv=x({deviceId:u(),exposedAs:u().optional(),exposedName:u().optional(),capabilities:C(u()).optional()}),_me=x({instanceId:Hv,deviceId:u(),capabilities:C(u()).optional(),exposedName:u().nullable().optional()}),vme=x({instanceId:Hv,deviceId:u(),name:u().nullable(),dryRun:y().optional()}),Jv=`export-name-refused`,yme=class extends Error{code=Jv;instanceId;reason;constructor(e,t){super(`${Jv}: ${t}`),this.name=`ExportNameRefusedError`,this.instanceId=e,this.reason=t}},bme=x({instanceId:Hv,deviceId:u()}),Yv=S([`device`,`action`,`notifier`]),Xv=a(`kind`,[x({kind:m(`device`),deviceId:u()}),x({kind:m(`action`),actionId:u().min(1)}),x({kind:m(`notifier`),targetId:u().min(1)})]),Zv=x({entity:Xv,exposedAs:u().optional()}),xme=x({instanceId:Hv,entity:Xv}),Sme=x({instanceId:Hv,entity:Xv}),Cme={name:`device-export`,scope:`system`,mode:`collection`,providerKind:`device-export`,status:{schema:Kv,kind:`poll`},exposesDeviceSettings:!0,methods:{getStatus:D(Uv,Kv),listInstances:D(v(),C(Wv)),listSupportedDeviceKinds:D(Uv,C(gme)),listExposedDevices:D(Uv,C(qv)),exposeDevice:D(_me,v(),{kind:`mutation`,auth:`admin`}),unexposeDevice:D(bme,v(),{kind:`mutation`,auth:`admin`}),setExposedName:D(vme,v(),{kind:`mutation`,auth:`admin`}),listSupportedEntityKinds:O(v(),C(Yv)),listExposedEntities:O(Uv,C(Zv)),exposeEntity:O(xme,v(),{kind:`mutation`,auth:`admin`}),unexposeEntity:O(Sme,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`exports to other ecosystems — configured on the export pages`}},Qv=`exposedNames`,wme=h(u(),u());function $v(e,t){if(e==null)return{ok:!0,name:null};if(typeof e!=`string`)return{ok:!1,reason:`The name must be text.`};let n=e.trim().replace(/\s+/g,` `);return n.length===0?{ok:!0,name:null}:t(n)}function ey(e){let t=wme.safeParse(e[Qv]);return t.success?t.data:{}}function Tme(e,t,n){let r=ey(e)[t];if(r===void 0)return null;let i=$v(r,n);return i.ok?i.name:null}function ty(e,t,n){let r=Object.fromEntries(Object.entries(ey(e)).filter(([e])=>e!==t));return{[Qv]:n===null?r:{...r,[t]:n}}}async function Eme(e){let t=$v(e.raw,e.validate);if(!t.ok)throw new yme(e.instanceId,t.reason);if(e.dryRun===!0)return{changed:!1,name:t.name};let n=await e.store.read(e.deviceId);return(ey(n)[e.instanceId]??null)===t.name?{changed:!1,name:t.name}:(await e.store.write(e.deviceId,ty(n,e.instanceId,t.name)),{changed:!0,name:t.name})}function Dme(e,t){let n=()=>{if(e===void 0)throw Error(`${t}: settings are not available`);return e};return{read:e=>n().readDeviceStore(e),write:(e,t)=>n().writeDeviceStore(e,t)}}async function Ome(e,t){let n=await e.listDeviceStoreIds();if(n.length===0)return[];let r=[];for(let[i,a]of await e.readDeviceStoreBatch(n))ey(a)[t]!==void 0&&(await e.writeDeviceStore(i,ty(a,t,null)),r.push(i));return r}function kme(e,t){return n=>n.length>t?{ok:!1,reason:`The name is ${n.length} characters; ${e} allows at most ${t}.`}:/\p{Cc}/u.test(n)?{ok:!1,reason:`The name may not contain control characters.`}:{ok:!0,name:n}}var Ame=[`automation`,`action`,`scheduler`,`composition`],jme=S(Ame),Mme=x({id:r().int().nonnegative(),name:u().min(1),type:u().min(1),room:u().min(1).nullable(),addonId:u().min(1),stableId:u().min(1),caps:C(u().min(1)),zones:C(u().min(1)).optional()}),Nme=x({timeZone:u().min(1),location:x({latitude:r(),longitude:r()}).nullable(),rooms:C(u().min(1)),devices:C(Mme).min(1),actions:C(x({id:u().min(1),name:u().min(1)})).default([])}),Pme=x({childDeviceIds:C(r()).readonly(),hiddenChildIds:C(r()).readonly()}),Fme={name:`accessories`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera,M.Switch,M.Light,M.Sensor,M.Climate,M.Cover,M.Lock,M.Fan,M.MediaPlayer,M.AlarmPanel,M.Generic],methods:{setChildHidden:D(x({deviceId:r().int().nonnegative(),childDeviceId:r().int().nonnegative(),hidden:y()}),v(),{kind:`mutation`,auth:`admin`})},events:{onAccessoriesChanged:{data:x({deviceId:r(),childDeviceIds:C(r()).readonly(),hiddenChildIds:C(r()).readonly()}),notOperatorFacing:`the device’s child list changed — administration, not a happening`},onChildVisibilityChanged:{data:x({deviceId:r(),childDeviceId:r(),hidden:y()}),notOperatorFacing:`an operator hid or showed a child — administration, not a happening`}},status:{schema:Pme,kind:`command-driven`},vocabulary:{noun:L(`Accessories`,`Accessori`),order:3e3}},Ime={name:`action-source`,scope:`system`,mode:`collection`,methods:{listActions:D(x({}),C(kv),{auth:`admin`}),runAction:D(x({actionId:u().min(1),variables:h(u(),wv).optional()}),v(),{kind:`mutation`,auth:`admin`}),stopAction:D(x({actionId:u().min(1)}),v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.INTERNAL}},Lme=60*6e4,Rme=3e4,zme=363e4;function Bme(e){let t=0;for(let n of e)n.kind===`wait`&&(t+=n.seconds*1e3);return t}var ny=x({actionId:u().min(1)}),ry=x({deviceId:r().int().nonnegative(),actionIds:C(u().min(1)).max(100)}),Vme={name:`actions`,scope:`system`,mode:`singleton`,methods:{list:D(x({}),C(kv),{auth:`admin`}),get:D(x({actionId:u().min(1),deviceId:r().int().nonnegative().optional()}),x({action:kv.nullable()}),{role:`viewer`,auth:`protected`,kind:`query`,caller:`required`}),run:D(x({actionId:u().min(1),variables:h(u(),wv).optional(),wait:y().optional(),origin:Mpe.optional(),deviceId:r().int().nonnegative().optional()}),Ppe,{role:`viewer`,auth:`protected`,kind:`mutation`,caller:`required`,timeoutMs:zme}),stop:D(ny,v(),{kind:`mutation`,auth:`admin`}),getTraces:D(ny,x({traces:C(V_)}),{auth:`admin`}),create:D(x({action:Av}),x({action:kv,warnings:C(Nv).optional()}),{kind:`mutation`,auth:`admin`}),update:D(x({actionId:u().min(1),action:Av.partial()}),x({action:kv,warnings:C(Nv).optional()}),{kind:`mutation`,auth:`admin`}),delete:D(ny,v(),{kind:`mutation`,auth:`admin`}),listForCamera:D(x({deviceId:r().int().nonnegative()}),C(kv),{role:`viewer`,auth:`protected`,kind:`query`}),getLinks:D(x({deviceId:r().int().nonnegative()}),ry,{auth:`admin`}),setLinks:D(ry,ry,{kind:`mutation`,auth:`admin`})},events:{onRunChanged:{data:Lpe}},vocabulary:{notOperatorFacing:`declared actions — run from the Actions page and from the cameras that link them`}},Hme=x({id:u(),label:u(),icon:u(),path:u(),remoteName:u(),bundle:u(),section:u().optional(),sectionLabel:u().optional()}),Ume=x({addonId:u(),page:Hme,bundleUrl:u()}),Wme={name:`addon-pages`,scope:`system`,mode:`singleton`,methods:{listPages:D(v(),C(Ume).readonly())},vocabulary:{notOperatorFacing:k.UI_PLUMBING}},Gme=x({id:u(),label:u(),icon:u(),path:u(),remoteName:u(),bundle:u(),section:u().optional(),sectionLabel:u().optional()}),Kme={name:`addon-pages-source`,scope:`system`,mode:`collection`,internal:!0,methods:{listPages:D(v(),C(Gme).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:k.UI_PLUMBING}},qme=x({method:S([`GET`,`POST`,`PUT`,`DELETE`,`PATCH`]),path:u(),access:S([`public`,`authenticated`,`admin`]).optional(),description:u().optional(),rateLimit:S([`auth`]).optional(),perInstance:y().optional()}),Jme=x({method:u(),path:u(),params:h(u(),u()),query:h(u(),u()),body:w(),headers:h(u(),u()),instanceId:u().optional(),user:x({id:u(),username:u(),isAdmin:y()}).optional(),scopedToken:w().optional()}),Yme=x({status:r().int(),headers:h(u(),u()),redirectUrl:u().nullable(),body:w().optional(),contentType:u().optional()}),Xme={name:`addon-routes`,scope:`system`,mode:`collection`,internal:!0,methods:{getRoutes:D(v(),C(qme)),invoke:D(Jme,Yme,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.UI_PLUMBING}},Zme=x({id:u(),label:u(),icon:u(),order:r().optional()}),Qme=x({id:u(),title:u(),titleKey:u().optional(),description:u().optional(),descriptionKey:u().optional(),style:S([`card`,`accordion`]).optional(),defaultCollapsed:y().optional(),columns:g([m(1),m(2),m(3),m(4)]).optional(),tab:u().optional(),location:S([`settings`,`top-tab`,`hero`]).optional(),order:r().optional(),fields:C(_e())}),iy=x({tabs:C(Zme).optional(),sections:C(Qme)}),ay=h(u(),w()),oy=S(hr),$me=x({cap:u(),scope:oy,sectionIds:C(u())}),sy=x({success:m(!0)}),ehe={name:`addon-settings`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{getScopedSettings:D(x({addonId:u(),cap:u(),scope:oy,nodeId:u().optional()}),iy.nullable()),listScopedSettings:D(x({addonId:u(),nodeId:u().optional()}),C($me).nullable()),updateScopedSettings:D(x({addonId:u(),cap:u(),scope:oy,nodeId:u().optional(),patch:ay}),sy,{kind:`mutation`,auth:`admin`}),readScopedValues:D(x({addonId:u(),cap:u(),scope:oy,nodeId:u().optional()}),h(u(),w()).nullable()),getDeclaredSettingsKeys:D(x({addonId:u(),nodeId:u().optional()}),x({keys:C(u())}).nullable(),{auth:`admin`}),unsetStoredSettingsKeys:D(x({addonId:u(),nodeId:u().optional(),keys:C(u())}),x({removed:C(u()),refused:C(x({key:u(),reason:u()})),secretsCleared:r()}),{kind:`mutation`,auth:`admin`}),getDeviceSettings:D(x({addonId:u(),deviceId:r(),nodeId:u().optional()}),iy.nullable()),updateDeviceSettings:D(x({addonId:u(),deviceId:r(),nodeId:u().optional(),patch:ay}),sy,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.ADDON_ADMIN}},the=S([`device-tab`,`dashboard`,`integration-detail`]),cy=S([`xs`,`sm`,`md`,`lg`,`xl`]),ly=x({remoteName:u(),exposedModule:u(),componentKey:u().optional()}),uy=x({tab:u(),subTab:u().optional(),label:u(),order:r().optional(),kind:m(`remote`),remote:ly,stableId:u(),description:u().optional(),icon:u().optional(),bundle:u(),hosts:C(the).readonly(),requires:x({deviceContext:y().default(!1),integrationContext:y().default(!1)}),preAuth:y().optional().default(!1),defaultSize:cy.default(`md`),allowedSizes:C(cy).readonly().default([`sm`,`md`,`lg`]),defaultColumns:r().int().min(1).max(12).default(6),defaultRows:r().int().min(1).max(12).default(1)}),nhe={name:`addon-widgets-source`,scope:`system`,mode:`collection`,internal:!0,methods:{listWidgets:D(v(),C(uy).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:k.UI_PLUMBING}},rhe=uy.extend({addonId:u(),bundleUrl:u()}),ihe={name:`addon-widgets`,scope:`system`,mode:`singleton`,methods:{listWidgets:D(v(),C(rhe).readonly())},vocabulary:{notOperatorFacing:k.UI_PLUMBING}},ahe=S([`install`,`update`,`uninstall`,`restart`]),dy=S([`queued`,`fetching`,`staged`,`validating`,`applying`,`restarting`,`applied`,`done`,`failed`,`skipped`]),ohe=S([`framework`,`addon`]),she=x({tsMs:r(),nodeId:u(),packageName:u(),phase:dy,message:u()}),che=x({taskId:u(),nodeId:u(),packageName:u(),fromVersion:u().nullable(),toVersion:u(),target:ohe,phase:dy,stagedPath:u().nullable(),attempts:r(),steps:C(she),error:u().nullable(),startedAtMs:r().nullable(),finishedAtMs:r().nullable()}),lhe=S([`running`,`completed`,`failed`,`partially-failed`,`cancelled`]),uhe=S([`single`,`bulk`,`cluster`]),fy=x({jobId:u(),kind:ahe,createdAtMs:r(),createdBy:u(),scope:uhe,tasks:C(che),state:lhe,schemaVersion:m(1)}),dhe=S([`debug`,`info`,`warn`,`error`]),py=S([`off`,`latest`,`beta`]),fhe=S([`off`,`latest`,`beta`,`inherit`]),phe=x({id:u(),name:u().optional(),version:u().optional(),description:u().optional(),icon:u().optional(),color:u().optional(),capabilities:C(w()).readonly().optional(),packageName:u(),packageVersion:u(),packageDisplayName:u().optional(),bundle:x({displayName:u(),description:u().optional(),icon:u().optional()}).optional(),protected:y().optional(),removable:y().optional(),integrationSection:S([`system`,`providers`]).optional()}),mhe=x({pid:r().optional(),mode:u(),state:u(),reason:u().optional()}),hhe=x({phase:S([`pending`,`healthy`,`failed`]),retryCount:r(),firstFailureAt:r().nullable(),lastAttemptAt:r().nullable(),lastError:x({message:u(),stack:u().optional()}).nullable(),nextRetryAt:r().nullable(),alertEmitted:y(),retrying:y(),inGracePeriod:y()}),ghe=x({manifest:phe,declaration:w().optional(),source:u(),installSource:u().optional(),process:mhe.optional(),hasBackup:y().optional(),health:hhe.nullable().optional()}),_he=x({name:u(),version:u(),dir:u(),installSource:u().optional()}),vhe=x({name:u(),currentVersion:u(),latestVersion:u(),category:S([`addon`,`core`]),requiresRestart:y(),isSystem:y(),blockedBy:C(ti).readonly().optional()}),yhe=x({version:u(),publishedAt:u(),deprecated:u().optional(),distTags:C(u()).readonly()}),bhe=a(`status`,[x({status:m(`ok`),markdown:u()}),x({status:m(`missing`)}),x({status:m(`error`),message:u()})]),xhe=x({name:u(),version:u(),readme:bhe,changelog:bhe}),She=x({name:u(),version:u(),description:u(),keywords:C(u()).readonly(),publishedAt:u(),author:u(),installed:y(),installedVersion:u().optional(),capabilities:C(u()).readonly().nullable()}),Che=x({channel:py,intervalSeconds:r(),updateCheckIntervalSeconds:r()}),whe=fhe,The=w(),Ehe=w(),Dhe=w(),Ohe=S([`uninstalled`,`not-installed`,`refused`,`failed`,`pending-reconnect`]),khe=x({nodeId:u(),outcome:Ohe,error:u().optional(),addonIds:C(u()).readonly(),runnersStopped:C(u()).readonly(),warnings:C(u()).readonly()}),Ahe=x({success:y(),packageName:u(),results:C(khe).readonly()}),jhe=x({packageName:u(),nodeId:u(),nodeName:u(),isHub:y(),isOnline:y(),version:u().nullable(),addonIds:C(u()).readonly(),source:S([`live`,`recorded`]),onHub:y()}),Mhe=x({installations:C(jhe).readonly(),unreachable:C(x({nodeId:u(),error:u()})).readonly()}),Nhe=S([`queued`,`updating`,`done`,`done-pending-restart`,`failed`]),Phe=x({name:u(),isSystem:y(),fromVersion:u(),toVersion:u(),status:Nhe,error:u().optional(),startedAtMs:r().optional(),completedAtMs:r().optional()}),Fhe=S([`regular`,`system`,`restarting`,`finalizing`]);x({id:u(),nodeId:u(),startedAtMs:r(),completedAtMs:r().optional(),total:r(),completed:r(),failed:r(),current:u().nullable(),phase:Fhe,cancelled:y(),items:C(Phe).readonly()});var Ihe=x({packageName:u(),currentVersion:u(),latestVersion:u().nullable(),hasUpdate:y(),description:u().optional(),buildId:u().nullable()}),Lhe=x({timestamp:u(),level:u(),message:u(),scope:u().optional()}),Rhe=w(),zhe=x({addonId:u().min(1),action:u().min(1),input:w()}),Bhe={name:`addons`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{list:D(x({nodeId:u().optional()}).optional(),C(ghe).readonly()),getLogs:D(x({addonId:u(),limit:r().min(1).max(500).default(100),level:dhe.optional()}),C(Rhe)),listPackages:D(v(),C(_he).readonly()),installPackage:D(x({packageName:u(),version:u().optional()}),Ehe,{kind:`mutation`,auth:`admin`}),uninstallPackage:D(x({packageName:u().min(1),nodeId:u().optional(),everywhere:y().optional()}),Ahe,{kind:`mutation`,auth:`admin`}),listInstallations:D(x({packageName:u().optional()}),Mhe,{auth:`admin`}),reloadPackages:D(v(),Dhe,{kind:`mutation`,auth:`admin`}),searchAvailable:D(x({query:u().optional(),capability:u().optional()}),C(She)),listUpdates:D(x({nodeId:u().optional()}),C(vhe).readonly(),{auth:`admin`}),updatePackage:D(x({name:u().min(1),version:u().optional(),nodeId:u().optional()}),w(),{kind:`mutation`,auth:`admin`}),rollbackPackage:D(x({name:u().min(1)}),x({rolledBackTo:u().nullable()}),{kind:`mutation`,auth:`admin`}),forceRefresh:D(x({nodeId:u().optional()}),w(),{kind:`mutation`,auth:`admin`}),restartServer:D(x({confirm:m(!0)}),w(),{kind:`mutation`,auth:`admin`}),getLastRestart:D(v(),x({kind:S([`framework-update`,`manual`,`system`,`framework-bulk-update`]),packageName:u().optional(),fromVersion:u().optional(),toVersion:u().optional(),requestedBy:u().optional(),requestedAt:r()}).nullable(),{auth:`admin`}),listFrameworkPackages:D(v(),C(Ihe).readonly(),{auth:`admin`}),listCapabilityProviders:D(x({capName:u().min(1)}),C(x({addonId:u(),mode:S([`singleton`,`collection`]),isActive:y()})).readonly()),setCapabilityProviderEnabled:D(x({capName:u().min(1),addonId:u().min(1),enabled:y()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getVersions:D(x({name:u()}),C(yhe).readonly()),getPackageDocs:D(x({name:u().min(1),version:u().min(1).optional()}),xhe,{auth:`admin`}),restartAddon:D(x({addonId:u()}),The,{kind:`mutation`,auth:`admin`}),retryLoad:D(x({packageName:u()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getAutoUpdateSettings:D(v(),Che,{auth:`admin`}),setAutoUpdateSettings:D(x({channel:py,intervalSeconds:r().min(300).max(86400).optional(),updateCheckIntervalSeconds:r().min(900).max(604800).optional()}),w(),{kind:`mutation`,auth:`admin`}),getAddonAutoUpdate:D(x({addonId:u()}),whe,{auth:`admin`}),setAddonAutoUpdate:D(x({addonId:u(),channel:fhe}),w(),{kind:`mutation`,auth:`admin`}),applyAutoUpdateToAll:D(x({channel:py}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),custom:D(zhe,w(),{role:`viewer`,kind:`mutation`}),startJob:D(x({kind:S([`install`,`update`,`uninstall`,`restart`]),targets:C(x({name:u().min(1),version:u().min(1)})).min(1),nodeIds:C(u()).optional()}),x({jobId:u()}),{kind:`mutation`,auth:`admin`}),getJob:D(x({jobId:u()}),fy.nullable(),{auth:`admin`}),listJobs:D(x({activeOnly:y().optional()}),C(fy),{auth:`admin`}),cancelJob:D(x({jobId:u()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),onAddonLogs:D(x({addonId:u(),level:dhe.optional()}),Lhe,{kind:`subscription`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:k.ADDON_ADMIN}},Vhe=x({staticDir:u()}),Hhe=x({version:u()}),my={name:`admin-ui`,scope:`system`,mode:`singleton`,internal:!0,methods:{getStaticDir:D(v(),Vhe,{auth:`admin`}),getVersion:D(v(),Hhe,{auth:`admin`})},vocabulary:{notOperatorFacing:k.UI_PLUMBING}},hy=x({co2:r().min(0).optional().meta(A(`concentration-volume`)),voc:r().min(0).optional().meta(A(`concentration-ppb`)),pm25:r().min(0).optional().meta(A(`concentration-mass`)),pm10:r().min(0).optional().meta(A(`concentration-mass`)),aqi:r().optional().meta(A(`index`)),lastFetchedAt:r()}),gy={name:`air-quality-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:hy,kind:`push`},runtimeState:hy,durability:`restored`,history:{fields:{co2:{kind:`gauge`,unit:`ppm`,deadband:5},voc:{kind:`gauge`,unit:`ppb`,deadband:5},pm25:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},pm10:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},aqi:{kind:`gauge`,unit:`count`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Air quality`,`Qualità dell’aria`),order:5e3,state:[{kind:`numeric`,field:`co2`,quantity:L(`the CO₂`,`la CO₂`),label:L(`CO₂`,`CO₂`),unit:`ppm`,icon:`wind`},{kind:`numeric`,field:`voc`,quantity:L(`the VOC level`,`il livello di COV`),label:L(`VOC`,`COV`),unit:`ppb`,icon:`wind`},{kind:`numeric`,field:`pm25`,quantity:L(`the PM2.5`,`il PM2,5`),label:L(`PM2.5`,`PM2,5`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`pm10`,quantity:L(`the PM10`,`il PM10`),label:L(`PM10`,`PM10`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`aqi`,quantity:L(`the air quality index`,`l’indice di qualità dell’aria`),label:L(`AQI`,`IQA`),icon:`wind`}]}},_y=S([`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]),vy=S([`home`,`away`,`night`,`vacation`,`custom_bypass`]),yy=x({state:_y,targetMode:vy.nullable().optional(),availableModes:C(vy),codeRequired:y().nullable(),lastChangedAt:r()}),by={name:`alarm-panel`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.AlarmPanel],methods:{trigger:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.trigger`,label:L(`Trigger alarm`,`Fai scattare l’allarme`),phrase:L(`Trigger the alarm on {device}`,`Fai scattare l’allarme su {device}`),icon:`siren`}]}),disarm:D(x({deviceId:r().int().nonnegative(),code:u().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.disarm`,label:L(`Disarm`,`Disinserisci`),phrase:L(`Disarm {device}`,`Disinserisci {device}`),icon:`shield-off`,effect:{field:`state`,value:`disarmed`},hold:{effects:[{field:`state`,value:`disarming`,when:{field:`state`,notIn:[`disarmed`]}}]},openArgs:[{key:`code`,label:L(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),arm:D(x({deviceId:r().int().nonnegative(),mode:vy,code:u().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.arm.home`,label:L(`Arm home`,`Inserisci in casa`),phrase:L(`Arm {device} for home`,`Inserisci {device} in modalità casa`),icon:`house`,effect:{field:`state`,value:`armed_home`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_home`]}}]},args:{mode:`home`},openArgs:[{key:`code`,label:L(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.away`,label:L(`Arm away`,`Inserisci fuori casa`),phrase:L(`Arm {device} for away`,`Inserisci {device} in modalità fuori casa`),icon:`shield-check`,effect:{field:`state`,value:`armed_away`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_away`]}}]},args:{mode:`away`},openArgs:[{key:`code`,label:L(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.night`,label:L(`Arm night`,`Inserisci notte`),phrase:L(`Arm {device} for the night`,`Inserisci {device} in modalità notte`),icon:`moon`,effect:{field:`state`,value:`armed_night`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_night`]}}]},args:{mode:`night`},openArgs:[{key:`code`,label:L(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.vacation`,label:L(`Arm vacation`,`Inserisci vacanza`),phrase:L(`Arm {device} for vacation`,`Inserisci {device} in modalità vacanza`),icon:`plane`,effect:{field:`state`,value:`armed_vacation`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_vacation`]}}]},args:{mode:`vacation`},openArgs:[{key:`code`,label:L(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.custom_bypass`,label:L(`Arm custom bypass`,`Inserisci con esclusioni`),phrase:L(`Arm {device} with its custom bypass`,`Inserisci {device} con le zone escluse`),icon:`shield-half`,effect:{field:`state`,value:`armed_custom_bypass`},hold:{effects:[{field:`state`,value:`arming`,when:{field:`state`,notIn:[`armed_custom_bypass`]}}]},args:{mode:`custom_bypass`},openArgs:[{key:`code`,label:L(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]})},status:{schema:yy,kind:`push`},runtimeState:yy,durability:`restored`,restoredFieldRenames:{requiresCode:`codeRequired`},history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Alarm panel`,`Centrale d’allarme`),order:1120,state:[{kind:`enum`,field:`state`,label:L(`Alarm state`,`Stato dell’allarme`),values:[{value:`disarmed`,label:L(`Disarmed`,`Disinserito`),phrase:L(`When {device} is disarmed`,`Quando {device} viene disinserito`)},{value:`armed_home`,label:L(`Armed home`,`Inserito in casa`),phrase:L(`When {device} is armed for home`,`Quando {device} viene inserito in modalità casa`)},{value:`armed_away`,label:L(`Armed away`,`Inserito fuori casa`),phrase:L(`When {device} is armed for away`,`Quando {device} viene inserito in modalità fuori casa`)},{value:`armed_night`,label:L(`Armed night`,`Inserito notte`),phrase:L(`When {device} is armed for the night`,`Quando {device} viene inserito in modalità notte`)},{value:`armed_vacation`,label:L(`Armed vacation`,`Inserito vacanza`)},{value:`armed_custom_bypass`,label:L(`Armed with bypass`,`Inserito con esclusioni`)},{value:`arming`,label:L(`Arming`,`In inserimento`)},{value:`disarming`,label:L(`Disarming`,`In disinserimento`)},{value:`pending`,label:L(`Entry delay`,`Ritardo d’ingresso`)},{value:`triggered`,label:L(`Triggered`,`In allarme`),phrase:L(`When {device} goes off`,`Quando {device} scatta`)}],icon:`shield`}]}},xy=S([`info`,`success`,`warning`,`error`,`critical`]),Uhe=x({addonId:u().min(1),action:u().min(1),input:h(u(),w()).optional()}),Whe=x({label:u(),href:u().optional(),invoke:Uhe.optional(),navigation:S([`app`,`server`]).optional()}),Sy=S([`active`,`in-progress`,`completed`,`failed`,`dismissed`]),Cy=x({type:u(),id:u()}),wy=x({id:u(),category:u(),severity:xy,title:u(),message:u(),action:Whe.optional(),status:Sy,progress:r().optional(),read:y(),createdAt:r(),updatedAt:r(),source:Cy.optional(),metadata:h(u(),w()).optional()}),Ty={name:`alerts`,scope:`system`,mode:`singleton`,methods:{emit:D(wy,v(),{kind:`mutation`}),update:D(x({alertId:u(),patch:wy.partial()}),v(),{kind:`mutation`}),list:D(x({unreadOnly:y().optional(),limit:r().optional()}).optional(),C(wy).readonly()),getUnreadCount:D(v(),r()),markRead:D(x({alertId:u()}),v(),{kind:`mutation`}),markAllRead:D(v(),v(),{kind:`mutation`}),dismiss:D(x({alertId:u()}),v(),{kind:`mutation`})},vocabulary:{notOperatorFacing:`the alert centre — read and acknowledged on its own page`}},Ey=x({illuminance:r().min(0).nullable().meta(A(`illuminance`,{precision:0,label:`Illuminance`})),lastFetchedAt:r()}),Dy={name:`ambient-light-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:Ey,kind:`push`},runtimeState:Ey,durability:`restored`,history:{fields:{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Light level`,`Luminosità ambiente`),order:5010,state:[{kind:`numeric`,field:`illuminance`,quantity:L(`the light level`,`la luminosità`),label:L(`Illuminance`,`Illuminamento`),unit:`lx`,icon:`sun`}]}},Oy={name:`audio-analysis`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Camera],exposesDeviceSettings:!0,methods:{resolveDeviceSettings:D(x({deviceId:r()}),ye())},events:{onAudioLevel:Ei(x({deviceId:r(),rms:r(),dbfs:r()}),{notOperatorFacing:`a sound-level sample at stream rate; loud-noise rules belong to the detection pipeline`})},vocabulary:{noun:L(`Audio analysis`,`Analisi audio`),order:3010}},Ghe=S([`jpeg`,`rgb`,`bgr`,`yuv420`,`gray`]),ky=x({data:ye(),format:Ghe,width:r(),height:r(),timestamp:r()}),Ay=x({x:r(),y:r(),w:r(),h:r()}),Khe=x({class:u(),originalClass:u(),score:r(),bbox:Ay}),jy=x({data:b(Uint8Array),sampleRate:r(),channels:r(),timestamp:r(),deviceId:r().optional()}),My=x({rms:r(),dbfs:r()}),Ny=x({className:u(),originalClass:u().optional(),score:r()}),Py=[`superseded`,`error`,`timeout`,`disposed`],Fy=a(`state`,[x({state:m(`classified`)}),x({state:m(`not-classified`),reason:S(Py)})]),Iy=x({level:My,classification:x({labels:C(Ny).readonly(),inferenceMs:r()}).optional(),classifyOutcome:Fy,timestamp:r()}),Ly=x({minConfidence:r().min(0).max(1).default(.3),allowedClasses:C(u()).default([])}),Ry=x({deviceId:r(),brokerId:u(),ingestNodeId:u(),settings:Ly}),zy=x({attached:y(),replaced:y()}),By=x({detached:y()}),Vy=x({labels:C(Ny).readonly(),rawLabels:C(Ny).readonly().optional(),inferenceMs:r()}),qhe=[{value:`auto`,label:`Auto (platform default)`},{value:`apple-soundanalysis`,label:`Apple SoundAnalysis (macOS 12+)`},{value:`yamnet-onnx`,label:`YAMNet ONNX (cross-platform)`}],Jhe={audioBackend:`auto`,probedBestAudioBackend:``},Hy={name:`audio-analyzer`,scope:`system`,mode:`singleton`,methods:{analyseChunk:D(x({chunk:jy,settings:Ly}),Iy.nullable(),{kind:`mutation`}),classify:D(jy,Vy,{timeoutMs:3e4}),attachDevice:D(Ry,zy,{kind:`mutation`}),detachDevice:D(x({deviceId:r()}),By,{kind:`mutation`}),isReady:D(v(),y()),dispose:D(v(),v(),{kind:`mutation`}),reprobeAudioEngine:D(v(),x({backend:u()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.PIPELINE}},Uy=S([`f32le`,`s16le`]),Wy=x({codec:u(),canDecode:y(),canEncode:y(),label:u().optional()}),Gy=x({codec:u(),sourceSampleRate:r().int().positive(),sourceChannels:r().int().positive(),extraData:b(Uint8Array).optional(),targetSampleRate:r().int().positive(),targetChannels:r().int().positive(),targetFormat:Uy.optional(),idleMs:r().int().positive().optional(),tag:u().optional()}),Ky=x({codec:u(),sourceSampleRate:r().int().positive(),sourceChannels:r().int().positive(),sourceFormat:Uy.optional(),targetSampleRate:r().int().positive(),targetChannels:r().int().positive(),bitrateKbps:r().int().positive().optional(),idleMs:r().int().positive().optional(),tag:u().optional()}),qy=x({data:b(Uint8Array),sampleRate:r().int().positive(),channels:r().int().positive(),format:Uy,pts:r()}),Jy=x({data:b(Uint8Array),codec:u(),pts:r(),frameComplete:y()}),Yhe=x({sessionId:u(),kind:S([`decode`,`encode`]),codec:u(),sourceSampleRate:r(),sourceChannels:r(),targetSampleRate:r(),targetChannels:r(),format:Uy,tag:u().optional(),createdAtMs:r(),lastActivityMs:r(),framesIn:r(),framesOut:r()}),Yy={name:`audio-codec`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{listSupportedCodecs:D(v(),C(Wy).readonly()),canHandle:D(x({codec:u(),kind:S([`decode`,`encode`])}),y()),createDecodeSession:D(Gy,x({sessionId:u(),nodeId:u()}),{kind:`mutation`}),createEncodeSession:D(Ky,x({sessionId:u(),nodeId:u()}),{kind:`mutation`}),closeSession:D(x({sessionId:u(),nodeId:u().optional()}),v(),{kind:`mutation`}),pushEncodedFrame:D(x({sessionId:u(),nodeId:u().optional(),data:b(Uint8Array),pts:r().optional()}),v(),{kind:`mutation`}),pullPcm:D(x({sessionId:u(),nodeId:u().optional(),maxCount:r().int().positive().default(8)}),C(qy)),pushPcm:D(x({sessionId:u(),nodeId:u().optional(),data:b(Uint8Array),pts:r().optional()}),v(),{kind:`mutation`}),pullEncoded:D(x({sessionId:u(),nodeId:u().optional(),maxCount:r().int().positive().default(8)}),C(Jy)),flushEncode:D(x({sessionId:u(),nodeId:u().optional()}),C(Jy),{kind:`mutation`}),listActiveSessions:D(v(),C(Yhe).readonly())},vocabulary:{notOperatorFacing:k.INTERNAL}},Xy=x({className:u(),hits:r().int().nonnegative(),avgScore:r().min(0).max(1),peakScore:r().min(0).max(1)}),Zy=x({ts:r().int(),windowSec:r().int().positive(),level:x({rms:r(),dbfs:r()}),peakDbfs:r(),avgDbfs:r(),current:x({className:u(),score:r().min(0).max(1),timestamp:r().int()}).nullable(),byClass:C(Xy).readonly()}),Qy=x({ts:r().int(),dbfs:r().nullable(),peakDbfs:r(),avgDbfs:r(),topClass:u().nullable(),topScore:r().min(0).max(1).nullable()}),$y=x({points:C(Qy).readonly(),effectiveSampleEveryMs:r().int().positive(),windowMsActual:r().int().nonnegative()}),eb={name:`audio-metrics`,scope:`device`,mode:`singleton`,deviceTypes:[M.Camera],methods:{getCurrentSnapshot:D(x({deviceId:r()}),Zy.nullable()),getHistory:D(x({deviceId:r(),windowSec:r().int().positive().optional(),sampleEveryMs:r().int().positive().optional()}),$y)},runtimeState:Zy,durability:`session`,history:`none`,vocabulary:{noun:L(`Audio metrics`,`Metriche audio`),order:3020}},tb=x({userId:u(),username:u(),email:u().optional(),displayName:u().optional(),isAdmin:y().default(!1)}),nb={name:`auth-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{validateCredentials:D(x({username:u(),password:u()}),tb.nullable(),{kind:`mutation`}),getLoginUrl:D(x({state:u()}),u()),handleCallback:D(h(u(),u()),tb,{kind:`mutation`}),validateToken:D(x({token:u()}),tb.nullable())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.IDENTITY}},rb=x({enabled:y(),isRunning:y(),lastTriggeredAt:r(),lastError:u().nullable(),lastChangedAt:r()}),ib={name:`automation-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Automation],methods:{enable:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.enable`,effect:{field:`enabled`,value:!0},label:L(`Enable automation`,`Abilita l’automazione`),phrase:L(`Enable {device}`,`Abilita {device}`),icon:`toggle-right`}]}),disable:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.disable`,effect:{field:`enabled`,value:!1},label:L(`Disable automation`,`Disabilita l’automazione`),phrase:L(`Disable {device}`,`Disabilita {device}`),icon:`toggle-left`}]}),trigger:D(x({deviceId:r().int().nonnegative(),skipCondition:y().optional()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.trigger`,label:L(`Trigger automation`,`Avvia l’automazione`),phrase:L(`Run {device} now`,`Esegui subito {device}`),icon:`workflow`}]})},status:{schema:rb,kind:`push`},runtimeState:rb,durability:`session`,history:`none`,vocabulary:{noun:L(`Automation`,`Automazione`),order:2100,state:[{kind:`boolean`,field:`enabled`,label:L(`Enabled`,`Abilitata`),whenTrue:L(`When {device} is enabled`,`Quando {device} viene abilitata`),whenFalse:L(`When {device} is disabled`,`Quando {device} viene disabilitata`),icon:`toggle-right`},{kind:`boolean`,field:`isRunning`,label:L(`Running`,`In esecuzione`),whenTrue:L(`When {device} starts running`,`Quando {device} parte`),whenFalse:L(`When {device} finishes`,`Quando {device} termina`),icon:`workflow`}]}},Xhe=`.backup-snapshot`,Zhe=`.backup-snapshot-partial`,ab=30*6e4,ob=x({databases:C(x({databaseId:Uo,livePath:u()}))}),sb=x({name:u(),rows:r().int().nonnegative()}),cb=x({livePath:u(),snapshotPath:u(),sizeBytes:r().int().nonnegative(),pageCount:r().int().nonnegative(),pageSize:r().int().positive(),tables:C(sb),copyMs:r().nonnegative(),verifyMs:r().nonnegative(),takenAt:r()}),lb=cb.extend({databaseId:Uo}),ub=x({databaseId:Uo}),db=cb.extend({livePath:u(),snapshotPath:u(),databaseId:Uo.optional()}),fb={name:`database-snapshot`,scope:`system`,mode:`singleton`,internal:!0,methods:{listDatabases:D(x({}),ob,{auth:`admin`}),writeSnapshot:D(ub,lb,{kind:`mutation`,auth:`admin`,timeoutMs:ab})},vocabulary:{notOperatorFacing:k.INTERNAL}},pb=x({subId:u(),displayName:u(),description:u().optional(),kind:u(),triggerSupported:y(),restoreSupported:y()}).extend({id:u(),addonId:u(),enabled:y(),retentionCount:r(),label:u().optional(),lastSuccessAt:r().optional(),lastSuccessSizeBytes:r().optional(),cron:u().optional(),nextRunAt:r().optional(),lastAttemptAt:r().optional(),lastError:u().optional()}),mb=x({scheme:u(),keyId:u()}),hb=x({enabled:y(),active:x({keyId:u(),publicKey:u(),createdAt:r()}).nullable(),keys:C(x({keyId:u(),createdAt:r(),retiredAt:r().nullable()})).readonly()}),Qhe=x({id:u(),filename:u(),createdAt:r(),sizeBytes:r(),label:u().optional(),locations:C(u()).readonly(),encryption:mb.optional(),databases:C(Uo).readonly().optional()}),gb=x({id:u(),destinationId:u().optional(),label:u().optional(),createdAt:r(),sizeBytes:r(),locations:C(u()).optional(),encryption:mb.optional()}),_b=x({path:u(),kind:S([`file`,`dir`,`symlink`]),sizeBytes:r(),mtime:r()}),vb=x({archiveVersion:m(1),createdAt:r(),dataDir:u(),locations:C(u()),entries:C(_b),totalBytes:r(),totalFiles:r(),sqliteSnapshots:C(db).optional(),omittedDatabases:C(Uo).optional()}),yb=x({name:u(),sizeBytes:r(),fileCount:r(),present:y()}),bb=S([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),xb=S([`queued`,`building`,`uploading`,`done`]),Sb=x({id:u(),state:bb,phase:xb,destinationIds:C(u()).readonly(),label:u().optional(),requestedAt:r(),startedAt:r().optional(),finishedAt:r().optional(),stagedBytes:r(),archiveSizeBytes:r().optional(),uploadedBytes:r(),completedDestinationIds:C(u()).readonly(),failedDestinationIds:C(u()).readonly(),error:u().optional(),queuePosition:r().int().min(1).optional()}),Cb=x({runId:u(),queued:y(),joined:y(),cancelled:y(),entries:C(gb).readonly()}),wb=x({id:u(),label:u(),cron:u(),enabled:y(),locationIds:C(u()).readonly(),retentionCount:r().int().min(1).max(1e3),dataSources:C(u()).readonly().optional(),databases:C(Uo).readonly().optional(),lastAttemptAt:r().optional(),lastSuccessAt:r().optional(),lastError:u().optional(),nextRunAt:r().optional()}),Tb={name:`backup`,scope:`system`,mode:`singleton`,methods:{listDestinations:D(v(),C(pb).readonly(),{auth:`admin`}),trigger:D(x({destinations:C(u()).optional(),locations:C(u()).optional(),label:u().optional(),retentionCount:r().int().min(1).max(1e3).optional(),databases:C(Uo).optional()}).optional(),Cb,{kind:`mutation`,auth:`admin`}),listRuns:D(v(),C(Sb).readonly(),{auth:`admin`}),cancel:D(x({runId:u()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),list:D(v(),C(gb).readonly(),{auth:`admin`}),listLocations:D(v(),C(yb).readonly(),{auth:`admin`}),getEntries:D(x({destinationId:u(),backupId:u()}),vb.nullable(),{auth:`admin`}),restore:D(x({destinationId:u(),backupId:u(),locations:C(u()).optional(),backupSecretKey:u().optional()}),v(),{kind:`mutation`,auth:`admin`}),getEncryption:D(v(),hb,{auth:`admin`}),setupEncryption:D(x({}),x({keyId:u(),secretKey:u(),publicKey:u(),createdAt:r(),replacedKeyId:u().nullable()}),{kind:`mutation`,auth:`admin`}),disableEncryption:D(x({}),x({disabledKeyId:u().nullable()}),{kind:`mutation`,auth:`admin`}),checkBackupKey:D(x({backupSecretKey:u()}),x({valid:y(),keyId:u().nullable(),known:y(),active:y(),error:u().optional()}),{kind:`mutation`,auth:`admin`}),delete:D(x({destinationId:u(),backupId:u()}),v(),{kind:`mutation`,auth:`admin`}),listArchives:D(x({destinationId:u()}),C(Qhe).readonly(),{auth:`admin`}),upsertDestinationPolicy:D(x({locationId:u(),enabled:y(),retentionCount:r().int().min(1).max(1e3),label:u().optional()}),v(),{kind:`mutation`,auth:`admin`}),previewSchedule:D(x({cron:u(),count:r().int().min(1).max(20).optional()}),x({ok:y(),error:u().optional(),nextRuns:C(r()).readonly()})),listSchedules:D(v(),C(wb).readonly(),{auth:`admin`}),listAvailableDatabases:D(v(),x({answered:y(),databases:C(Uo).readonly()}),{auth:`admin`}),upsertSchedule:D(x({id:u().optional(),label:u(),cron:u(),enabled:y(),locationIds:C(u()).readonly(),retentionCount:r().int().min(1).max(1e3),dataSources:C(u()).readonly().optional(),databases:C(Uo).readonly().optional()}),wb,{kind:`mutation`,auth:`admin`}),deleteSchedule:D(x({id:u()}),v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`system backups — run and restored from the Backups page`}},Eb=x({level:r().min(0).max(100).nullable().meta(A(`percentage`,{label:`Charge`})),charging:S([`dc`,`solar`,`none`,`unknown`]).meta({label:`Charging source`}),sleeping:y().meta({label:`Sleeping`}),lastUpdated:r().meta(A(`none`)),voltage:r().nullable().optional().meta(A(`voltage`,{label:`Voltage`})),chargeState:S([`charging`,`full`,`idle`,`unknown`]).optional().meta({label:`Charge state`}),currentMa:r().nullable().optional().meta(A(`none`,{label:`Current (mA)`})),temperatureC:r().nullable().optional().meta(A(`temperature`,{label:`Temperature`})),lastContactAt:r().optional(),lastFullRefreshAt:r().optional(),binary:y().optional().meta({label:`Binary indicator`})}),Db=[M.Camera,M.Sensor,M.Button,M.Switch,M.PetFeeder,M.Container,M.Climate,M.EventEmitter],$he={version:1,targets:[{id:`level`,cardinality:`scalar`,vocabulary:{cap:`battery`,stateField:`level`},deviceTypes:Db,apply:`add`,path:`level`,sources:[{kind:`field`,valueKinds:[`number`,`string`],transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}],companions:[{kind:`constant`,path:`charging`,value:`unknown`,when:`add`},{kind:`constant`,path:`sleeping`,value:!1,when:`add`},{kind:`clock`,path:`lastUpdated`,when:`add`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},Ob={name:`battery`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:Db,methods:{},events:{onStatusChanged:{data:x({deviceId:r(),status:Eb}),notOperatorFacing:`the level / sleeping / charging state triggers each read one field of this change`}},status:{schema:Eb,kind:`push`,empty:{level:null,charging:`unknown`,sleeping:!1,lastUpdated:0}},runtimeState:Eb,durability:`restored`,history:{fields:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`},temperatureC:{kind:`gauge`,unit:`°C`}}},customize:$he,volatileStateFields:[`lastUpdated`],vocabulary:{noun:L(`Battery`,`Batteria`),order:5240,state:[{kind:`numeric`,field:`level`,quantity:L(`the battery level`,`il livello della batteria`),label:L(`Battery`,`Batteria`),unit:`%`,icon:`battery`},{kind:`boolean`,field:`sleeping`,label:L(`Asleep`,`In sospensione`),whenTrue:L(`When {device} goes to sleep`,`Quando {device} va in sospensione`),whenFalse:L(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`moon`},{kind:`enum`,field:`charging`,label:L(`Charging`,`Ricarica`),values:[{value:`dc`,label:L(`Charging from mains`,`In carica da rete`),phrase:L(`When {device} starts charging`,`Quando {device} inizia a caricarsi`)},{value:`solar`,label:L(`Charging from solar`,`In carica dal pannello solare`),phrase:L(`When {device} charges from its solar panel`,`Quando {device} si carica dal pannello solare`)},{value:`none`,label:L(`Not charging`,`Non in carica`),phrase:L(`When {device} stops charging`,`Quando {device} smette di caricarsi`)},{value:`unknown`,label:L(`Unknown`,`Sconosciuto`)}],icon:`battery-charging`},{kind:`enum`,field:`chargeState`,label:L(`Charge state`,`Stato di carica`),values:[{value:`charging`,label:L(`Charging`,`In carica`)},{value:`full`,label:L(`Full`,`Carica completa`)},{value:`idle`,label:L(`Not charging`,`Non in carica`)},{value:`unknown`,label:L(`Unknown`,`Sconosciuto`)}],icon:`battery-charging`}],extraEvents:[{category:T.DeviceAwake,label:L(`Woke up`,`Risvegliato`),phrase:L(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`sun`},{category:T.DeviceSleeping,label:L(`Went to sleep`,`In sospensione`),phrase:L(`When {device} goes to sleep`,`Quando {device} va in sospensione`),icon:`moon`}]}},kb=x({on:y().meta({label:`On`}),lastChangedAt:r()}),Ab={name:`binary`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:kb,kind:`push`},runtimeState:kb,durability:`restored`,history:{fields:{on:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Binary sensor`,`Sensore binario`),order:5020,state:[{kind:`boolean`,field:`on`,label:L(`On`,`Acceso`),whenTrue:L(`When {device} turns active`,`Quando {device} si attiva`),whenFalse:L(`When {device} turns inactive`,`Quando {device} si disattiva`),icon:`toggle-right`}],overrides:{byRole:{[P.MotionSensor]:{state:{on:{label:L(`Motion`,`Movimento`),whenTrue:L(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:L(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}}},[P.ContactSensor]:{state:{on:{label:L(`Open`,`Aperto`),whenTrue:L(`When {device} opens`,`Quando {device} si apre`),whenFalse:L(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}}},[P.LeakSensor]:{state:{on:{label:L(`Leak`,`Perdita`),whenTrue:L(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:L(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}}},[P.SmokeSensor]:{state:{on:{label:L(`Smoke`,`Fumo`),whenTrue:L(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:L(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}}},[P.COSensor]:{state:{on:{label:L(`Carbon monoxide`,`Monossido di carbonio`),whenTrue:L(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:L(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}}},[P.GasSensor]:{state:{on:{label:L(`Gas`,`Gas`),whenTrue:L(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:L(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}}},[P.TamperSensor]:{state:{on:{label:L(`Tampered`,`Manomesso`),whenTrue:L(`When {device} is tampered with`,`Quando {device} viene manomesso`),whenFalse:L(`When the tamper alert on {device} clears`,`Quando l’allarme di manomissione di {device} rientra`),icon:`shield-alert`}}},[P.VibrationSensor]:{state:{on:{label:L(`Vibration`,`Vibrazione`),whenTrue:L(`When {device} vibrates`,`Quando {device} vibra`),whenFalse:L(`When {device} is still again`,`Quando {device} torna fermo`),icon:`vibrate`}}},[P.ConnectivitySensor]:{state:{on:{label:L(`Connected`,`Connesso`),whenTrue:L(`When {device} connects`,`Quando {device} si connette`),whenFalse:L(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}}},[P.SoundSensor]:{state:{on:{label:L(`Sound`,`Suono`),whenTrue:L(`When {device} hears a sound`,`Quando {device} sente un suono`),whenFalse:L(`When {device} is quiet again`,`Quando {device} torna silenzioso`),icon:`ear`}}},[P.BatterySensor]:{state:{on:{label:L(`Battery low`,`Batteria scarica`),whenTrue:L(`When the battery of {device} runs low`,`Quando la batteria di {device} si scarica`),whenFalse:L(`When the battery of {device} is fine again`,`Quando la batteria di {device} torna a posto`),icon:`battery-low`}}},[P.BinaryHelper]:{state:{on:{label:L(`On`,`Acceso`),whenTrue:L(`When {device} turns on`,`Quando {device} si accende`),whenFalse:L(`When {device} turns off`,`Quando {device} si spegne`),icon:`toggle-right`}}}}}}},jb=S([`unknown-source`,`not-admin`,`no-builder`,`no-ingress-url`,`unreachable`,`unknown-board`,`no-encryption-key`,`unreadable-config`]),ege=x({sourceId:u(),name:u()}),tge=x({configuration:u(),name:u(),address:u().nullable()}),Mb=x({ok:m(!1),reason:jb,detail:u().optional()}),nge=a(`ok`,[x({ok:m(!0),boards:C(tge).readonly()}),Mb]),rge=a(`ok`,[x({ok:m(!0),key:u()}),Mb]),Nb={name:`board-key-source`,scope:`system`,mode:`collection`,methods:{listSources:D(v(),C(ege).readonly(),{auth:`admin`}),listBoards:D(x({sourceId:u().min(1)}),nge,{auth:`admin`}),getBoardKey:D(x({sourceId:u().min(1),configuration:u().min(1)}),rge,{auth:`admin`})},vocabulary:{notOperatorFacing:k.INTERNAL}},Pb=x({level:r().min(0).max(100).meta(A(`percentage`)),lastChangedAt:r()}),Fb={name:`brightness`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Light],methods:{setBrightness:D(x({deviceId:r().int().nonnegative(),level:r().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`brightness.full`,label:L(`Full brightness`,`Luminosità massima`),phrase:L(`Set {device} to full brightness`,`Porta {device} alla massima luminosità`),icon:`sun`,effect:{field:`level`,value:100},args:{level:100}},{id:`brightness.half`,label:L(`Half brightness`,`Luminosità a metà`),phrase:L(`Dim {device} to half`,`Abbassa {device} a metà luminosità`),icon:`sun-dim`,effect:{field:`level`,value:50},args:{level:50}},{id:`brightness.off`,label:L(`Brightness off`,`Luminosità a zero`),phrase:L(`Dim {device} to zero`,`Abbassa {device} a zero`),icon:`lightbulb-off`,effect:{field:`level`,value:0},args:{level:0}},{id:`brightness.set`,label:L(`Set brightness`,`Imposta la luminosità`),phrase:L(`Set the brightness of {device} to {level}`,`Imposta la luminosità di {device} a {level}`),icon:`sun-medium`,effect:{field:`level`,fromArg:`level`},openArgs:[{key:`level`,label:L(`Percentage`,`Percentuale`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},events:{onBrightnessChanged:{data:x({deviceId:r(),level:r().min(0).max(100),lastChangedAt:r()}),notOperatorFacing:"the `level` state trigger reads the same change"}},status:{schema:Pb,kind:`command-driven`},runtimeState:Pb,durability:`session`,history:{fields:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},vocabulary:{noun:L(`Brightness`,`Luminosità`),order:1010,state:[{kind:`numeric`,field:`level`,quantity:L(`the brightness`,`la luminosità`),label:L(`Brightness`,`Luminosità`),unit:`%`,icon:`sun`}]}},ige=S([`connected`,`disconnected`,`connecting`,`auth-failed`,`unreachable`,`error`]),Ib=x({brokerCount:r().int().nonnegative(),connectedCount:r().int().nonnegative()}),age=x({id:u()}),oge=h(u(),w()),Lb=x({brokerId:u(),target:h(u(),w()),payload:w().optional()}),Rb=x({brokerId:u(),filter:h(u(),w())}),zb=x({subscriptionId:u()}),Bb=x({brokerId:u(),subscriptionId:u()}),Vb=x({brokerId:u(),key:u()}),Hb={name:`broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:Ib,kind:`poll`},methods:{getBrokerConfig:D(age,oge.nullable(),{auth:`admin`}),publish:D(Lb,w(),{kind:`mutation`,auth:`admin`}),subscribe:D(Rb,zb,{kind:`mutation`,auth:`admin`}),unsubscribe:D(Bb,v(),{kind:`mutation`,auth:`admin`}),getState:D(Vb,w().nullable(),{auth:`admin`}),getStatus:D(v(),Ib)},vocabulary:{notOperatorFacing:`message-broker connections — configured, not actuated`}},Ub={name:`button`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Button],methods:{press:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`button.press`,label:L(`Press`,`Premi`),phrase:L(`Press {device}`,`Premi {device}`),icon:`circle-dot`}]})},vocabulary:{noun:L(`Button`,`Pulsante`),order:1130}},Wb=S([`ha`,`addon`]),Gb=x({id:u().min(1),name:u().min(1),source:Wb,enabled:y(),instanceId:u().min(1).optional()}),Kb=x({id:u().min(1),calendarId:u().min(1),title:u(),startMs:r().int(),endMs:r().int(),allDay:y().optional(),description:u().optional(),location:u().optional()}),qb=x({calendarIds:C(u().min(1)).max(64).optional(),startMs:r().int(),endMs:r().int()}),Jb={name:`calendar-source`,scope:`system`,mode:`collection`,internal:!0,providerKind:`calendar`,methods:{listCalendars:D(v(),C(Gb).readonly(),{auth:`admin`}),listEvents:D(qb,C(Kb).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:k.INTERNAL}};function Yb(e){let t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()).getTime()}function Xb(e){if(e.allDay!==!0)return{startMs:e.startMs,endMs:e.endMs};let t=Yb(e.startMs),n=Yb(e.endMs);if(n>t)return{startMs:t,endMs:n};let r=new Date(t);return{startMs:t,endMs:new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()}}function Zb(e,t){let n=new Date(t),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1).getTime(),i=Xb(e);return i.startMs<r&&i.endMs>t}var Qb=u().regex(/^#[0-9A-Fa-f]{6}$/,`expected #RRGGBB`),$b=Gb.extend({id:u().min(1),providerAddonId:u().min(1).optional(),defaultColor:Qb,color:Qb,visible:y()}),ex=x({visible:y().optional(),color:Qb.optional()}),tx=x({calendars:h(u(),ex)}),nx=x({calendarId:u().min(1),visible:y().optional(),color:Qb.nullable().optional()}),rx={name:`calendars`,scope:`system`,mode:`singleton`,methods:{listCalendars:D(v(),C($b).readonly(),{auth:`admin`}),listEvents:D(qb,C(Kb).readonly(),{auth:`admin`}),getPreferences:D(x({}),tx,{auth:`admin`,caller:`required`}),setCalendarPreference:D(nx,tx,{auth:`admin`,kind:`mutation`,caller:`required`})},vocabulary:{notOperatorFacing:`calendars feed schedules and conditions, not device actions`}},ix=x({host:u(),port:r().int().positive().optional(),onvifPort:r().int().positive().optional(),rtspPort:r().int().positive().optional(),https:y().optional(),username:u().optional(),password:u().optional(),onvifProfile:u().optional()}),ax=x({host:u(),port:r().int().positive().nullable(),onvifPort:r().int().positive().nullable(),rtspPort:r().int().positive().nullable(),https:y().nullable(),hasUsername:y(),hasPassword:y(),onvifProfile:u().nullable()}),ox={name:`camera-credentials`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],methods:{getCredentials:D(x({deviceId:r()}),ix.nullable(),{kind:`query`,auth:`admin`})},status:{schema:ax,kind:`command-driven`},vocabulary:{noun:L(`Camera credentials`,`Credenziali della telecamera`),order:3030}},sx=x({x:r().min(0).max(1),y:r().min(0).max(1),width:r().gt(0).max(1),height:r().gt(0).max(1)}),cx=x({deviceId:r().int().positive(),source:sx,cell:sx}),sge=x({profile:S([`high`,`mid`,`low`]),offered:y(),missingSources:C(r().int().positive()),canvas:u(),published:y()}),lx=x({blockId:u(),deviceId:r().int().nonnegative(),name:u(),fps:r().int(),cells:C(cx),profiles:C(sge)}),ux=x({deviceId:r().int().nonnegative(),fps:r().int().min(1).max(60).optional(),publishedProfiles:C(S([`high`,`mid`,`low`])).max(3).optional(),cells:C(cx).max(16)}),dx={name:`camera-grid-layout`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],exposesDeviceSettings:!0,methods:{getLayout:D(x({deviceId:r().int().nonnegative()}),lx.nullable(),{auth:`admin`}),saveLayout:D(ux,lx,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:L(`Grid layout`,`Layout a griglia`),order:3040}},fx={name:`camera-pipeline-config`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:L(`Detection settings`,`Impostazioni di rilevamento`),order:3050}},px=S([`webrtc`,`hls`,`mjpeg`,`rtsp`]),mx=S([`mp4`,`gif`]),hx=x({kind:mx,handle:u(),nodeId:u(),mime:u(),bytes:r().int(),width:r().int(),height:r().int()}),gx=x({fromTs:r(),toTs:r(),packets:r().int()}),_x=x({media:C(hx).readonly(),coverage:gx,profile:j,video:S([`copy`,`encode`])}),vx=x({brokerId:u(),url:u(),mutedUrl:u(),enabled:y(),codec:u().optional(),resolution:x({width:r().int().positive(),height:r().int().positive()}).optional()}),yx=x({sessionId:u(),remoteAddr:u(),userAgent:u().nullish(),playing:y(),muted:y(),connectedAt:r(),lastRtpAt:r(),bytesSent:r()}),bx=x({tag:u(),subscribedAt:r(),chunksDelivered:r()}),xx=S([`alexa`,`homekit`,`webrtc-browser`,`webrtc-mobile`,`webrtc-whep`,`rtsp-listen`,`derived-broker`,`recording`,`pipeline`,`snapshot`,`warmup`,`unknown`]),Sx=x({kind:xx,label:u().optional(),media:S([`audio`,`video`,`both`]).optional(),targetCodec:u().optional(),transport:S([`passthrough`,`repacketize`,`transcode`]).optional(),remoteAddr:u().optional(),userAgent:u().optional(),userId:u().optional(),sessionId:u().optional(),extra:h(u(),u()).optional()}).readonly(),Cx=x({id:u(),channel:S([`annexb`,`rtp`]),attribution:Sx,subscribedAt:r(),packetsDelivered:r()}),wx=x({rtsp:C(yx).readonly(),audio:C(bx).readonly(),encoded:C(Cx).readonly(),pipeClients:r(),encodedSubscribers:r()}),Tx=x({deviceId:r().int().nonnegative(),viewers:r().int().positive()}),cge=S([`reconnecting`,`sleeping`,`offline`,`disabled`,`waking`]),lge=S([`h264`,`h265`,`copy`]),uge=S([`aac`,`opus`,`pcmu`,`copy`,`none`]),Ex=x({deviceId:r().int().nonnegative(),video:lge,audio:uge.optional(),profile:j.optional(),targetResolution:x({width:r().int().positive(),height:r().int().positive()}).optional(),outputArgs:C(u()).optional(),audioEgress:y().optional(),hostname:u().optional(),tag:u().optional()}),Dx=x({url:u(),sentryUrl:u().nullable().optional(),videoCodec:S([`H264`,`H265`]),audioCodec:u(),resolution:x({width:r().int().positive(),height:r().int().positive()}),transcoded:y(),encoder:u(),pipelineKey:u()}),Ox=Ma.omit({inputArgs:!0,outputArgs:!0}),kx=S([`tight`,`relaxed`]),Ax=x({deviceId:r().int().nonnegative(),source:a(`kind`,[x({kind:m(`profile`),profile:j}),x({kind:m(`cam-stream`),camStreamId:u().min(1)})]),encode:Ox,rateControl:kx.optional(),bitstreamFilter:S([`dump_extra`,`h264_mp4toannexb`,`hevc_mp4toannexb`]).optional(),publishLocally:y().optional(),pixelFormat:S([`yuv420p`,`nv12`]).optional(),decodeHwAccel:S([`auto`,`none`,`videotoolbox`,`vaapi`,`qsv`,`cuda`]).optional(),hostname:u().optional(),tag:u().optional()}),jx=x({url:u(),pipelineKey:u(),videoCodec:S([`H264`,`H265`]),resolution:x({width:r().int().positive(),height:r().int().positive()}),transcoded:y(),encoder:u(),decodeHwAccel:u().nullable(),camStreamId:u().nullable()}),Mx={name:`stream-broker`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,methods:{reportStreamSignal:D(x({deviceId:r().int().nonnegative(),code:u().min(1),at:r().optional()}),x({accepted:y(),reason:S([`woke`,`hold-extended`,`not-enabled`,`no-consumer`,`unknown-code`])}),{kind:`mutation`}),publishCameraStream:D(x({deviceId:r().int().nonnegative(),camStreamId:u().min(1),kind:kc,url:u().optional(),codec:u().optional(),resolution:Ac.optional(),fps:r().positive().optional(),label:u().optional(),deviceFeatures:C(u()).optional(),autoEligible:y().optional(),profileHint:j.optional(),metadata:h(u(),w()).optional(),sourceCamStreamId:u().min(1).optional(),encodeProfile:Ma.optional()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),retractCameraStream:D(x({deviceId:r().int().nonnegative(),camStreamId:u().min(1)}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),assignProfile:D(x({deviceId:r().int().nonnegative(),profile:j,camStreamId:u().min(1)}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),unassignProfile:D(x({deviceId:r().int().nonnegative(),profile:j}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),forgetDeviceHardware:D(x({deviceId:r().int().nonnegative()}),x({derivedStreamsDeleted:C(u()).readonly(),assignmentsPurged:y(),probeSnapshotsDropped:r().int().nonnegative(),rtspTokenRowsDeleted:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),renderPreBufferClip:D(x({deviceId:r(),profile:j.optional(),aroundMs:r(),preRollSec:r().min(0).max(20).default(3),postRollSec:r().min(0).max(20).default(5),format:S([`gif`,`mp4`]).default(`gif`),maxWidth:r().int().min(120).max(1920).default(480),fps:r().int().min(1).max(15).default(5),speed:r().min(1).max(8).default(2)}),x({base64:u(),mime:u(),bytes:r().int(),profile:j,durationMs:r()}),{kind:`mutation`,auth:`admin`}),produceEventMedia:D(x({deviceId:r(),profile:j.optional(),aroundMs:r(),preSeconds:r().min(0).max(20).default(4),postSeconds:r().min(0).max(20).default(6),kinds:C(mx).min(1).default([`mp4`]),gifMaxWidth:r().int().min(120).max(1280).default(640),gifFps:r().int().min(1).max(15).default(12),gifSpeed:r().min(1).max(8).default(4),speed:r().min(1).max(8).default(4)}),_x,{kind:`mutation`,auth:`admin`}),fetchEventMedia:D(x({handle:u()}),x({base64:u(),mime:u(),bytes:r().int()}).nullable(),{kind:`mutation`,auth:`admin`}),listAllCameraStreams:D(v(),C(jc).readonly()),listAllProfileSlots:D(v(),C(Nc).readonly()),getBrokerStats:D(x({brokerId:u()}),qc),previewDerivedEncode:D(x({deviceId:r().int().nonnegative(),profile:Ma,source:Wc.optional()}),Kc),probeStream:D(x({brokerId:u()}),x({probed:y(),summary:u()}),{kind:`mutation`,auth:`admin`}),listClients:D(x({brokerId:u()}),wx),getLiveViewerCounts:D(v(),C(Tx).readonly(),{role:`viewer`}),killClient:D(x({brokerId:u(),channel:S([`rtsp`,`audio`]),handle:u()}),x({killed:y()}),{kind:`mutation`,auth:`admin`}),restartProfile:D(x({deviceId:r().int().nonnegative(),profile:j}),x({success:y()}),{kind:`mutation`,auth:`admin`}),getStreamUrl:D(x({streamId:u(),format:px}),x({url:u()})),getStreamWithCodec:D(Ex,Dx,{kind:`mutation`,auth:`admin`}),releaseStreamWithCodec:D(x({pipelineKey:u()}),x({released:y(),refcount:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),acquireEgressTranscode:D(Ax,jx,{kind:`mutation`,auth:`admin`}),releaseEgressTranscode:D(x({pipelineKey:u()}),x({released:y(),refcount:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),subscribeAudioChunks:D(Bc,Vc,{kind:`mutation`}),pullAudioChunks:D(x({subscriptionId:u(),maxCount:r().int().positive().default(8)}),C(zc).readonly()),unsubscribeAudioChunks:D(x({subscriptionId:u()}),x({released:y()}),{kind:`mutation`}),setPreBufferDuration:D(x({brokerId:u(),seconds:r().min(0).max(30)}),v(),{kind:`mutation`,auth:`admin`}),getPreBufferInfo:D(x({brokerId:u()}),x({configuredSec:r(),bufferedMs:r(),packetCount:r()})),getRtspPort:D(v(),r()),getAllRtspEntries:D(x({hostname:u().optional()}),C(vx).readonly()),getRtspEntry:D(x({brokerId:u(),hostname:u().optional()}),vx.nullable()),regenerateRtspToken:D(x({brokerId:u()}),u().nullable(),{kind:`mutation`,auth:`admin`}),setRtspEnabled:D(x({brokerId:u(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`}),isRtspEnabled:D(x({brokerId:u()}),y()),getDeviceAudioMute:D(x({deviceId:r().int()}),x({muted:y(),appliedBrokers:r().int().nonnegative()})),setDeviceAudioMute:D(x({deviceId:r().int(),muted:y()}),x({muted:y(),appliedBrokers:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`})},events:{onCamStreamDemand:Ei(x({deviceId:r().int().nonnegative(),camStreamId:u(),profile:j})),onCamStreamIdle:Ei(x({deviceId:r().int().nonnegative(),camStreamId:u()})),onRequestStreamSourceRefresh:Ei(x({deviceId:r().int().nonnegative(),camStreamId:u(),brokerId:u()}))},vocabulary:{notOperatorFacing:k.PIPELINE}},Nx=S([`h264`,`h265`,`hevc`,`av1`,`mjpeg`,`vp8`,`vp9`]),Px=x({acceptCodecs:C(Nx).readonly().optional(),minHeight:r().int().positive().optional(),maxHeight:r().int().positive().optional(),minWidth:r().int().positive().optional(),excludeDerived:y().optional(),requireSiblingCodec:C(Nx).readonly().optional(),allowTranscode:y().optional(),requireProfileBound:y().optional()}).readonly(),Fx=x({preferredProviders:C(u()).readonly().optional(),resolutionPreference:S([`highest`,`lowest`]).optional(),targetHeight:r().int().positive().optional()}).readonly(),Ix=x({camStreamId:u(),codec:u().optional(),resolution:Ac.optional(),transcodes:y(),reason:u(),profile:j.optional(),brokerId:u().optional(),url:u().optional(),fps:r().positive().optional(),fpsSource:S([`published`,`measured`]).optional()}),Lx={name:`camera-streams`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Camera],methods:{getCameraStreams:D(x({deviceId:r().int().nonnegative()}),C(jc).readonly()),getBrokerStreams:D(x({deviceId:r().int().nonnegative()}),C(Nc).readonly()),getRtspEntries:D(x({deviceId:r().int().nonnegative(),hostname:u().optional()}),C(vx).readonly()),getProfileRtspEntries:D(x({deviceId:r().int().nonnegative(),hostname:u().optional()}),C(Jc).readonly()),pickStream:D(x({deviceId:r().int().nonnegative(),requirements:Px,preferences:Fx.optional()}),Ix.nullable())},events:{onCamStreamsChanged:Ei(x({deviceId:r().int().nonnegative(),camStreams:C(jc).readonly()}),{notOperatorFacing:`the stream catalog was rebuilt — plumbing, not a happening`}),onProfileSlotsChanged:Ei(x({deviceId:r().int().nonnegative(),profileSlots:C(Nc).readonly()}),{notOperatorFacing:`stream profiles were reassigned — plumbing, not a happening`})},runtimeState:x({online:y(),slotStatuses:x({high:Mc.optional(),mid:Mc.optional(),low:Mc.optional()}),slotErrors:x({high:u().optional(),mid:u().optional(),low:u().optional()}),lastChangedAt:r()}),durability:`session`,history:`none`,vocabulary:{noun:L(`Camera streams`,`Flussi della telecamera`),order:3060}},Rx=x({detected:y(),lastChangedAt:r()}),zx={name:`carbon-monoxide`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:Rx,kind:`push`},runtimeState:Rx,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Carbon monoxide`,`Monossido di carbonio`),order:5030,state:[{kind:`boolean`,field:`detected`,label:L(`Detected`,`Rilevato`),whenTrue:L(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:L(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}]}},Bx=S([`off`,`heat`,`cool`,`auto`,`heat_cool`,`fan_only`,`dry`]),Vx=S([`heating`,`cooling`,`drying`,`fan`,`idle`,`off`]),Hx=x({mode:Bx,action:Vx.nullable().optional(),availableModes:C(Bx),fanMode:u(),availableFanModes:C(u()),preset:u(),availablePresets:C(u()),target:r().nullable().meta(A(`temperature`)),targetHigh:r().nullable().meta(A(`temperature`)),targetLow:r().nullable().meta(A(`temperature`)),targetHumidity:r().min(0).max(100).nullable().meta(A(`humidity`)),currentTemp:r().nullable().meta(A(`temperature`)),currentHumidity:r().min(0).max(100).nullable().meta(A(`humidity`)),swingVertical:y().nullable(),swingHorizontal:y().nullable(),minTemp:r().nullable().optional().meta(A(`temperature`)),maxTemp:r().nullable().optional().meta(A(`temperature`)),tempStep:r().positive().nullable().optional().meta(A(`temperature`)),lastActiveMode:Bx.exclude([`off`]).optional(),lastFetchedAt:r()}),dge=[M.Climate];function Ux(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`climate-control`,stateField:t},deviceTypes:dge,apply:`replace`,path:t,sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}var Wx=[Ux(`room-temperature`,`currentTemp`),Ux(`room-humidity`,`currentHumidity`)],fge={version:1,overridable:Wx.map(e=>({path:e.path,by:e.id})),targets:Wx},Gx={name:`climate-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Climate],power:{kind:`mode`,field:`mode`,offValue:`off`,set:`setMode`,lastField:`lastActiveMode`},methods:{setMode:D(x({deviceId:r().int().nonnegative(),mode:Bx}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.off`,label:L(`Climate off`,`Clima spento`),phrase:L(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`mode`,value:`off`},args:{mode:`off`}},{id:`climate.heat`,label:L(`Heat`,`Riscalda`),phrase:L(`Set {device} to heat`,`Metti {device} in riscaldamento`),icon:`flame`,effect:{field:`mode`,value:`heat`},args:{mode:`heat`}},{id:`climate.cool`,label:L(`Cool`,`Raffresca`),phrase:L(`Set {device} to cool`,`Metti {device} in raffrescamento`),icon:`snowflake`,effect:{field:`mode`,value:`cool`},args:{mode:`cool`}},{id:`climate.auto`,label:L(`Climate auto`,`Clima automatico`),phrase:L(`Set {device} to automatic`,`Metti {device} in automatico`),icon:`thermometer`,effect:{field:`mode`,value:`auto`},args:{mode:`auto`}},{id:`climate.mode`,label:L(`Set mode`,`Imposta la modalità`),phrase:L(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`thermometer`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:L(`Mode`,`Modalità`),offer:{kind:`enum`,values:[{value:`off`,label:L(`Off`,`Spento`)},{value:`heat`,label:L(`Heat`,`Riscaldamento`)},{value:`cool`,label:L(`Cool`,`Raffrescamento`)},{value:`auto`,label:L(`Automatic`,`Automatico`)},{value:`heat_cool`,label:L(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:L(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:L(`Dry`,`Deumidificazione`)}]}}]}]}),setTarget:D(x({deviceId:r().int().nonnegative(),target:r()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.target`,label:L(`Set temperature`,`Imposta la temperatura`),phrase:L(`Set {device} to {target}`,`Imposta {device} a {target}`),icon:`thermometer`,effect:{field:`target`,fromArg:`target`},openArgs:[{key:`target`,label:L(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetRange:O(x({deviceId:r().int().nonnegative(),targetLow:r(),targetHigh:r()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetRange`,label:L(`Set temperature range`,`Imposta l’intervallo di temperatura`),phrase:L(`Keep {device} between {targetLow} and {targetHigh}`,`Mantieni {device} tra {targetLow} e {targetHigh}`),icon:`thermometer`,effect:{field:`targetLow`,fromArg:`targetLow`},sideEffects:[{field:`targetHigh`,fromArg:`targetHigh`}],openArgs:[{key:`targetLow`,label:L(`Lowest`,`Minima`),offer:{kind:`number`,step:.5,unit:`°C`}},{key:`targetHigh`,label:L(`Highest`,`Massima`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetHumidity:O(x({deviceId:r().int().nonnegative(),targetHumidity:r().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetHumidity`,label:L(`Set humidity`,`Imposta l’umidità`),phrase:L(`Set the humidity target of {device} to {targetHumidity}`,`Imposta l’umidità obiettivo di {device} al {targetHumidity}`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`targetHumidity`},openArgs:[{key:`targetHumidity`,label:L(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setFanMode:O(x({deviceId:r().int().nonnegative(),fanMode:u().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.fanMode`,label:L(`Set fan mode`,`Imposta la ventilazione`),phrase:L(`Set the fan of {device} to {fanMode}`,`Imposta la ventilazione di {device} su {fanMode}`),icon:`fan`,effect:{field:`fanMode`,fromArg:`fanMode`},openArgs:[{key:`fanMode`,label:L(`Fan mode`,`Ventilazione`),offer:{kind:`dynamic`,from:`status`,field:`availableFanModes`}}]}]}),setPreset:O(x({deviceId:r().int().nonnegative(),preset:u().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.preset`,label:L(`Set preset`,`Imposta il preset`),phrase:L(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:L(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setSwingVertical:O(x({deviceId:r().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingVerticalOn`,label:L(`Vertical swing on`,`Oscillazione verticale attiva`),phrase:L(`Start the vertical swing of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,effect:{field:`swingVertical`,value:!0},args:{on:!0}},{id:`climate.swingVerticalOff`,label:L(`Vertical swing off`,`Oscillazione verticale spenta`),phrase:L(`Stop the vertical swing of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,effect:{field:`swingVertical`,value:!1},args:{on:!1}}]}),setSwingHorizontal:O(x({deviceId:r().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingHorizontalOn`,label:L(`Horizontal swing on`,`Oscillazione orizzontale attiva`),phrase:L(`Start the horizontal swing of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,effect:{field:`swingHorizontal`,value:!0},args:{on:!0}},{id:`climate.swingHorizontalOff`,label:L(`Horizontal swing off`,`Oscillazione orizzontale spenta`),phrase:L(`Stop the horizontal swing of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,effect:{field:`swingHorizontal`,value:!1},args:{on:!1}}]})},status:{schema:Hx,kind:`push`},runtimeState:Hx,customize:fge,durability:`restored`,restoredStateFields:[`lastActiveMode`],history:{primary:`currentTemp`,priority:70,fields:{currentTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},target:{group:`temperature`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetHigh:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetLow:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0}}},vocabulary:{noun:L(`Climate`,`Clima`),order:1070,state:[{kind:`enum`,field:`mode`,label:L(`Mode`,`Modalità`),values:[{value:`off`,label:L(`Off`,`Spento`),phrase:L(`When {device} turns off`,`Quando {device} si spegne`)},{value:`heat`,label:L(`Heat`,`Riscaldamento`),phrase:L(`When {device} starts heating`,`Quando {device} passa al riscaldamento`)},{value:`cool`,label:L(`Cool`,`Raffrescamento`),phrase:L(`When {device} starts cooling`,`Quando {device} passa al raffrescamento`)},{value:`auto`,label:L(`Automatic`,`Automatico`)},{value:`heat_cool`,label:L(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:L(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:L(`Dry`,`Deumidificazione`)}],icon:`thermometer`},{kind:`numeric`,field:`currentTemp`,quantity:L(`the temperature`,`la temperatura`),label:L(`Temperature`,`Temperatura`),unit:`°C`,icon:`thermometer`},{kind:`numeric`,field:`currentHumidity`,quantity:L(`the humidity`,`l’umidità`),label:L(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`},{kind:`numeric`,field:`target`,quantity:L(`the set temperature`,`la temperatura impostata`),label:L(`Set temperature`,`Temperatura impostata`),unit:`°C`,icon:`thermometer`}]}},Kx=S([`backup`,`hub-server`,`agent-server`,`addons`]),qx=S([`pending`,`running`,`ok`,`failed`,`skipped`]),Jx=S([`backup-unavailable`,`backup-failed`,`server-refused`,`server-not-on-target`,`node-capless`,`status-unreadable`,`addon-update-failed`,`addons-not-converged`,`interrupted`,`timeout-stall`,`timeout-ceiling`]),Yx=x({kind:Kx,nodeId:u().optional(),status:qx,detail:u(),reason:Jx.optional(),fromVersion:u().nullable().optional(),packages:C(u()).readonly().optional(),startedAt:r().optional(),finishedAt:r().optional()}),Xx=S([`running`,`succeeded`,`failed`]),Zx=x({id:u(),state:Xx,targetVersion:u(),requestedBy:u(),startedAt:r(),finishedAt:r().optional(),steps:C(Yx).readonly(),stoppedAt:u().optional(),reason:Jx.optional(),skippedOffline:C(u()).readonly()}),Qx=x({version:u().optional(),addons:y().optional(),backup:y().optional()}),$x=S([`no-target`,`node-busy`,`job-running`,`nothing-to-do`,`status-unreadable`]),eS=x({targetVersion:u().nullable(),steps:C(Yx).readonly(),skippedOffline:C(u()).readonly(),blocker:$x.nullable(),blockerDetail:u().nullable()}),tS=x({accepted:y(),jobId:u().nullable(),blocker:$x.nullable(),message:u()}),nS={name:`cluster-update`,scope:`system`,mode:`singleton`,methods:{previewClusterUpdate:D(Qx,eS,{auth:`admin`}),startClusterUpdate:D(Qx,tS,{kind:`mutation`,auth:`admin`}),getClusterUpdateJob:D(x({jobId:u().optional()}),Zx.nullable(),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:k.CLUSTER}},rS=x({r:r().int().min(0).max(255).meta(A(`none`)),g:r().int().min(0).max(255).meta(A(`none`)),b:r().int().min(0).max(255).meta(A(`none`))}),iS=x({h:r().min(0).max(360).meta(A(`none`)),s:r().min(0).max(100).meta(A(`none`)),v:r().min(0).max(100).meta(A(`none`))}),aS=a(`mode`,[x({mode:m(`rgb`),rgb:rS}),x({mode:m(`hsv`),hsv:iS}),x({mode:m(`mired`),colorTemperature:r().int().min(50).max(1e3)})]),oS=x({mode:S([`rgb`,`hsv`,`mired`]),rgb:rS.optional(),hsv:iS.optional(),colorTemperature:r().int().optional().meta(A(`colour-temperature`)),lastChangedAt:r()});function pge(e){let t=aS.safeParse(e);return t.success?t.data:null}var sS={name:`color`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Light],methods:{setColor:D(x({deviceId:r().int().nonnegative(),color:aS}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`color.warmWhite`,label:L(`Warm white`,`Bianco caldo`),phrase:L(`Set {device} to warm white`,`Imposta {device} su bianco caldo`),icon:`sun`,args:{color:{mode:`mired`,colorTemperature:370}}},{id:`color.coolWhite`,label:L(`Cool white`,`Bianco freddo`),phrase:L(`Set {device} to cool white`,`Imposta {device} su bianco freddo`),icon:`snowflake`,args:{color:{mode:`mired`,colorTemperature:200}}},{id:`color.red`,label:L(`Red`,`Rosso`),phrase:L(`Turn {device} red`,`Colora {device} di rosso`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:255,g:0,b:0}}}},{id:`color.green`,label:L(`Green`,`Verde`),phrase:L(`Turn {device} green`,`Colora {device} di verde`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:255,b:0}}}},{id:`color.blue`,label:L(`Blue`,`Blu`),phrase:L(`Turn {device} blue`,`Colora {device} di blu`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:0,b:255}}}}]})},events:{onColorChanged:{data:x({deviceId:r(),mode:S([`rgb`,`hsv`,`mired`]),rgb:rS.optional(),hsv:iS.optional(),colorTemperature:r().int().optional(),lastChangedAt:r()}),notOperatorFacing:"a colour change is read through the `mode` state trigger"}},status:{schema:oS,kind:`command-driven`},runtimeState:oS,durability:`session`,history:`none`,vocabulary:{noun:L(`Colour`,`Colore`),order:1020,state:[{kind:`enum`,field:`mode`,label:L(`Colour mode`,`Modalità colore`),values:[{value:`rgb`,label:L(`RGB colour`,`Colore RGB`)},{value:`hsv`,label:L(`HSV colour`,`Colore HSV`)},{value:`mired`,label:L(`White temperature`,`Temperatura del bianco`)}],icon:`palette`}]}},cS=1/36e8;function lS(e){return e*cS}var uS=[`min`,`max`,`mean`,`sum`,`count`,`change`],mge=[`gauge`,`counter`,`boolean`];function dS(e){return typeof e==`number`&&Number.isFinite(e)}function fS(e){return dS(e.value)?e.value:dS(e.last)?e.last:null}function hge(e){let t=e.points.filter(t=>t.t>=e.from&&t.t<e.to),n=dS(e.before?.value)?e.before.value:null,r=n,i=e.from,a=0,o=[];if(r===null){let n=t.find(e=>fS(e)!==null);if(n===void 0)return{segments:o,included:0,gaps:1,end:null,start:null};n.t>e.from&&(a+=1),i=n.t,r=fS(n)}for(let e of t){let t=fS(e);r!==null&&e.t>i&&o.push({value:r,ms:e.t-i}),t!==null&&(r=t),e.t>i&&(i=e.t)}r!==null&&e.to>i&&o.push({value:r,ms:e.to-i});let s=t.reduce((e,t)=>fS(t)??e,r);return{segments:o,included:t.length,gaps:a,end:s,start:n}}function gge(e){let t=e.points.filter(e=>dS(e.twMean)&&dS(e.twMs)&&e.twMs>0);if(t.length===0)return null;let n=t[0],r=+(e.before===null&&n!==void 0&&n.t>e.from),i=e.points.flatMap(e=>dS(e.last)?[e.last]:[]),a=i.length>0?i[i.length-1]??null:null;return{segments:t.flatMap(e=>dS(e.twMean)&&dS(e.twMs)?[{value:e.twMean,ms:e.twMs}]:[]),included:t.length,gaps:r,end:a,start:dS(e.before?.value)?e.before.value:null}}function pS(e){if(e.tier!==`raw`){let t=gge(e);if(t!==null)return t}return hge(e)}function _ge(e){let t=0,n=0;for(let r of e)t+=r.ms,n+=r.value*r.ms;return t<=0?null:n/t}function vge(e,t){let n=[],r=[];for(let t of e.points)dS(t.min)&&n.push(t.min),dS(t.max)&&r.push(t.max);return t.start!==null&&(n.push(t.start),r.push(t.start)),{min:n.length===0?null:Math.min(...n),max:r.length===0?null:Math.max(...r)}}function yge(e){let t=e.points.flatMap(e=>dS(e.delta)?[e.delta]:[]);return t.length===0?null:t.reduce((e,t)=>e+t,0)}function mS(e){return{write:`hold`,value:null,included:0,excluded:0,reason:e}}function hS(e,t){return{write:`null`,value:null,included:t,excluded:1,reason:e}}function gS(e,t,n,r){return{write:`number`,value:e,included:t,excluded:n,reason:n>0?r:null}}var _S=`history has a gap — that interval was not counted as zero`;function bge(e,t){if(t.truncated)return mS(`the history query was truncated — the last statistic is kept`);if(e===`sum`&&t.kind!==`counter`)return mS(`a gauge has no sum — that is the integral template`);if(t.to<=t.from)return hS(`the range is empty`,0);let n=pS(t);if(n.segments.length===0&&n.start===null)return hS(_S,n.included);if(e===`count`)return gS(n.included,n.included,n.gaps,_S);if(e===`sum`||e===`change`&&t.kind===`counter`){let e=yge(t);return e===null?hS(`the counter has no growth in this range`,n.included):gS(e,n.included,n.gaps,_S)}if(e===`change`)return n.start===null||n.end===null?hS(`the change has no value at the start of the range`,n.included):gS(n.end-n.start,n.included,n.gaps,_S);if(e===`min`||e===`max`){let r=vge(t,n),i=e===`min`?r.min:r.max;return i===null?hS(_S,n.included):gS(i,n.included,n.gaps,_S)}let r=_ge(n.segments);return r===null?hS(_S,n.included):gS(r,n.included,n.gaps,_S)}function xge(e,t){if(e.truncated)return mS(`the history query was truncated — the last total is kept`);if(e.kind===`counter`)return mS(`a counter is already a total — it is not integrated again`);if(e.to<=e.from)return hS(`the range is empty`,0);let n=pS(e);if(n.segments.length===0)return{write:`hold`,value:null,included:n.included,excluded:n.gaps,reason:_S};let r=0;for(let e of n.segments)r+=e.value*e.ms;return gS(t===`energy-kwh`?lS(r):r/1e3,n.included,n.gaps,_S)}function Sge(e){let t=[];e.before!==null&&dS(e.before.value)&&t.push({at:e.from,value:e.before.value});for(let n of e.points){if(n.t<e.from||n.t>e.to)continue;let r=fS(n);if(r===null)continue;let i=e.tier===`raw`||!dS(n.twMs)?n.t:n.t+n.twMs;t.push({at:Math.min(i,e.to),value:r})}return t.toSorted((e,t)=>e.at-t.at)}var Cge=.1,wge=`history stops short of the window — the rate is over the part that was measured`;function vS(e,t,n,r,i){return gS(e/(t/n),r,+(i-t>i*Cge),wge)}function Tge(e,t){if(e.truncated)return mS(`the history query was truncated — the last rate is kept`);if(e.to<=e.from)return hS(`the range is empty`,0);let n=e.to-e.from,r=Sge(e),i=r[0],a=r[r.length-1];if(i===void 0||a===void 0)return hS(`history has no reading in this window`,0);if(e.kind===`counter`){let o=e.before!==null&&dS(e.before.value),s=o?e.from:i.at,c=e.points.flatMap(t=>t.t>=e.from&&t.t<=e.to&&dS(t.delta)&&(o||t.t>i.at)?[t.delta]:[]),l=a.at-s;return c.length===0||l<=0?hS(`the counter has no growth in this window`,r.length):vS(c.reduce((e,t)=>e+t,0),l,t,r.length,n)}if(r.length===1&&i.at===e.from&&e.before!==null)return gS(0,1,0,null);let o=a.at-i.at;return r.length<2||o<=0?hS(`the rate needs two readings in the window`,r.length):vS(a.value-i.value,o,t,r.length,n)}var yS=6e4,bS=60*yS,xS=24*bS,SS=[`1h`,`24h`,`2d`,`7d`,`30d`,`custom`],CS=[`today`,`yesterday`,`this-week`,`this-month`],Ege=[`raw`,`5m`,`1h`,`1d`],wS=[`never`,`daily`,`weekly`,`monthly`],TS=6e4,ES=5*yS,Dge={"1h":bS,"24h":24*bS,"2d":2*xS,"7d":7*xS,"30d":30*xS},DS={rawMs:7*xS,fiveMinuteMs:30*xS,hourMs:365*xS,dayMs:null};function Oge(e){return{rawMs:OS(e.rawDays,DS.rawMs),fiveMinuteMs:OS(e.fiveMinuteDays,DS.fiveMinuteMs),hourMs:OS(e.hourDays,DS.hourMs),dayMs:kge(e.dayDays)}}function OS(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>0?e*xS:t}function kge(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?null:e*xS}var kS=x({kind:m(`rolling`),span:S(SS),customMinutes:r().int().min(5).optional()}).check(e=>{e.value.span===`custom`&&e.value.customMinutes===void 0&&e.issues.push({code:`custom`,message:`a custom range needs a duration in minutes`,path:[`customMinutes`],input:e.value}),e.value.span!==`custom`&&e.value.customMinutes!==void 0&&e.issues.push({code:`custom`,message:`only a custom range carries a duration`,path:[`customMinutes`],input:e.value})}),AS=kS,jS=x({kind:m(`calendar`),period:S(CS)}),Age=jS,MS=a(`kind`,[kS,jS]),jge={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6},NS=new Map;function Mge(e){let t=NS.get(e);if(t!==void 0)return t;let n;try{n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,weekday:`short`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`})}catch{n=null}return NS.set(e,n),n}function PS(e,t){let n=Mge(t);if(n===null)return null;let r=n.formatToParts(new Date(e)),i=e=>r.find(t=>t.type===e)?.value,a=Number(i(`year`)),o=Number(i(`month`)),s=Number(i(`day`)),c=Number(i(`hour`)),l=Number(i(`minute`)),u=Number(i(`second`)),d=jge[i(`weekday`)??``];return!Number.isInteger(a)||!Number.isInteger(o)||!Number.isInteger(s)||!Number.isInteger(c)||!Number.isInteger(l)||!Number.isInteger(u)||d===void 0?null:{year:a,month:o,day:s,hour:c===24?0:c,minute:l,second:u,weekday:d}}function FS(e,t){let n=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second),r=PS(n,t);if(r===null)return null;let i=Date.UTC(r.year,r.month-1,r.day,r.hour,r.minute,r.second)-n,a=n-i,o=PS(a,t);if(o===null)return null;let s=Date.UTC(o.year,o.month-1,o.day,o.hour,o.minute,o.second)-a;return s===i?a:n-s}function IS(e,t){let n=PS(e,t);return n===null?null:FS({...n,hour:0,minute:0,second:0},t)}function LS(e,t){let n=PS(e,t);return n===null?null:FS({...n,day:1,hour:0,minute:0,second:0},t)}function RS(e,t){let n=PS(e,t),r=IS(e,t);if(n===null||r===null)return null;let i=n.weekday===0?6:n.weekday-1;for(let e=0;e<i;e++){let e=IS(r-1,t);if(e===null)return null;r=e}return r}function zS(e){return e===null?`forever`:e%864e5==0?`${e/xS} d`:e%36e5==0?`${e/bS} h`:`${e/yS} min`}function Nge(e){return`raw ${zS(e.rawMs)}, 5m ${zS(e.fiveMinuteMs)}, 1h ${zS(e.hourMs)}, 1d ${zS(e.dayMs)}`}function BS(e,t){let n=[{tier:`raw`,keptMs:t.rawMs},{tier:`5m`,keptMs:t.fiveMinuteMs},{tier:`1h`,keptMs:t.hourMs},{tier:`1d`,keptMs:t.dayMs}];for(let t of n)if(t.keptMs===null||t.keptMs>e)return{ok:!0,tier:t.tier,maxDurationMs:e};return{ok:!1,reason:`the range is ${zS(e)} and no history tier is kept strictly longer (${Nge(t)})`}}function VS(e){return e.span===`custom`?e.customMinutes===void 0?null:e.customMinutes*yS:Dge[e.span]}function HS(e){if(e.kind===`rolling`)return VS(e);switch(e.period){case`today`:case`yesterday`:return 25*bS;case`this-week`:return 6084e5;case`this-month`:return 2682e6}}function US(e,t){let n=HS(e);return n===null?{ok:!1,reason:`a custom range needs a duration of at least 5 minutes`}:BS(n,t)}function WS(e,t){switch(e){case`never`:return BS(1/0,t);case`daily`:return BS(25*bS,t);case`weekly`:return BS(6084e5,t);case`monthly`:return BS(2682e6,t)}}function Pge(e,t,n){if(e.kind===`rolling`){let n=VS(e);return n===null?null:{from:t-n,to:t}}let r=IS(t,n);if(r===null)return null;switch(e.period){case`today`:return{from:r,to:t};case`yesterday`:{let e=IS(r-1,n);return e===null?null:{from:e,to:r}}case`this-week`:{let e=RS(t,n);return e===null?null:{from:e,to:t}}case`this-month`:{let e=LS(t,n);return e===null?null:{from:e,to:t}}}}function Fge(e,t,n){if(e===`never`)return{from:0,to:t};let r=IS(t,n);if(r===null)return null;if(e===`daily`)return{from:r,to:t};if(e===`weekly`){let e=RS(t,n);return e===null?null:{from:e,to:t}}let i=LS(t,n);return i===null?null:{from:i,to:t}}function Ige(e,t){let n=IS(e,t);return n===null?null:IS(n+26*bS,t)}function Lge(e){if(e.kind===`calendar`)return e.period===`today`?TS:ES;let t=VS(e);return t!==null&&t<=24*36e5?TS:ES}function Rge(e){return e===`raw`?TS:ES}var GS=x({addonId:u().min(1),stableId:u().min(1)}),KS=[`temperature`,`humidity`,`pressure`,`illuminance`,`power`,`energy`,`battery`,`numeric`,`motion`,`contact`,`leak`,`smoke`,`occupancy`,`binary`,`switch`,`light`,`fan`,`cover`,`valve`,`lock`,`media-player`,`climate`],qS=[`mean`,`median`,`min`,`max`,`sum`],JS=[`any`,`all`],YS=[`at-least-one`,`all`],XS=[`mean`,`median`,`min`,`max`,`sum`,`any`,`all`],ZS=S(KS),QS=S(XS),$S=S(YS),eC=x({source:GS,cap:u().min(1),fieldPath:u().min(1)}),tC=x({kind:m(`group`),templateId:ZS,aggregate:QS,members:C(eC).min(1).max(64),active:$S.optional()}),nC=x({kind:m(`statistic`),stat:S(uS),window:MS,source:eC}),zge=nC,rC=[`energy`,`meter`],iC=x({kind:m(`integral`),reset:S(wS),output:S(rC),source:eC}),Bge=iC,aC=x({kind:m(`threshold`),source:eC,high:r(),low:r(),onForMs:r().int().nonnegative(),offForMs:r().int().nonnegative()}),Vge=aC,oC=[`sum`,`difference`,`ratio`],sC=x({kind:m(`arithmetic`),op:S(oC),inputs:C(eC).min(2).max(64)}),Hge=sC,cC=[`number`,`boolean`],lC=x({kind:m(`expression`),expr:u().min(1),inputs:C(x({name:u().min(1),member:eC})).min(1).max(64),output:S(cC)}),Uge=lC,uC=[`second`,`minute`,`hour`],dC=x({kind:m(`derivative`),window:AS,per:S(uC),source:eC}),Wge=dC,fC=[`high`,`mid`,`low`],pC=x({x:r().min(0).max(1),y:r().min(0).max(1),width:r().gt(0).max(1),height:r().gt(0).max(1)}),mC=x({source:GS,region:pC,cell:pC}),hC=x({kind:m(`grid`),fps:r().int().min(1).max(60),publishedProfiles:C(S(fC)).max(3),cells:C(mC).max(16)}),Gge=hC,gC=[`mid`,`low`];function _C(){return{kind:`grid`,fps:10,publishedProfiles:[...gC],cells:[]}}var vC=[`16:9`,`4:3`,`1:1`,`free`],yC=`16:9`,bC=x({kind:m(`crop`),source:GS,rect:pC,aspect:S(vC),fps:r().int().min(1).max(60),publishedProfiles:C(S(fC)).max(3)}),Kge=bC;function xC(e,t,n=yC){return{kind:`crop`,source:e,rect:t,aspect:n,fps:10,publishedProfiles:[...gC]}}var SC=x({kind:m(`terminal`),terminalId:u().uuid()}),qge=SC,CC=a(`kind`,[hC,bC,SC,tC,nC,iC,aC,sC,lC,dC]);function wC(e){return e.kind===`statistic`||e.kind===`integral`||e.kind===`derivative`}function Jge(e){switch(e.kind){case`group`:return e.members;case`statistic`:case`integral`:case`threshold`:case`derivative`:return[e.source];case`arithmetic`:return e.inputs;case`expression`:return e.inputs.map(e=>e.member);case`grid`:case`crop`:case`terminal`:return[]}}var Yge=[`grid`,`crop`,`terminal`];function TC(e){return e.kind===`grid`||e.kind===`crop`||e.kind===`terminal`}function Xge(e){return e.kind===`grid`?e.cells.map(e=>e.source):e.kind===`crop`?[e.source]:[]}var EC=`composed-`,DC=`composer`,Zge=`customize:`,OC=2e4,kC=x({source:GS,cap:u().min(1),fieldPath:u().min(1)}),AC=kC.extend({kind:m(`from`)}),jC=x({kind:m(`literal`),value:g([u(),r(),y(),oe()])}),MC=a(`kind`,[AC,jC]),NC=x({kind:m(`expression`),expr:u().min(1).max(zm),bindings:h(u().regex(Bm),MC)}).superRefine((e,t)=>{let n=ih(e);n!==null&&t.addIssue({code:`custom`,message:n,path:[`expr`]})}),PC=x({kind:m(`code`),code:u().min(1).max(OC)}),FC=x({kind:m(`aggregate`),reducer:S([`mean`,`median`,`min`,`max`,`sum`,`any`,`all`]),reads:C(kC).min(1).max(64),activeWhen:C(u().min(1)).min(1).optional(),publish:S([`value`,`included`,`excluded`,`total`]),empty:S([`null`,`omit`,`offline`])}),IC=x({kind:m(`series`),read:kC,publish:S([`value`,`included`,`excluded`,`total`]),empty:S([`null`,`omit`,`offline`])}),LC=a(`kind`,[AC,NC,PC,FC,IC]),RC=`$input`,zC=g([u(),r(),y(),c({[RC]:u().min(1)}),h(u().min(1),o(()=>zC))]),BC=zC;function VC(e){return typeof e==`object`&&typeof e.$input==`string`}var HC=x({kind:m(`forward`),source:GS,cap:u().min(1),method:u().min(1),args:h(u().min(1),BC).optional()}),UC=x({kind:m(`extension`),target:m(`remote`)}),WC=a(`kind`,[HC,PC,UC]),GC=/^[a-z0-9][a-z0-9-]{0,47}$/,KC=`items`,qC=x({label:u().min(1).max(80),fields:h(u().min(1),LC),reset:HC.optional()}),JC=x({linkId:u().min(1)}),YC=x({kind:m(`fields`),cap:u().min(1),enabled:y().optional(),fields:h(u().min(1),LC).refine(e=>Object.keys(e).length<=32,{message:`at most 32 fields per capability`}),items:h(u().regex(GC),qC).refine(e=>Object.keys(e).length<=16,{message:`at most 16 items`}).optional(),commands:h(u().min(1),WC).optional(),contributedBy:JC.optional()}),XC=x({kind:m(`passthrough`),cap:u().min(1),enabled:y().optional(),source:GS}),ZC=a(`kind`,[YC,XC]);function QC(e){return e.enabled!==!1}var $C=x({kind:m(`new`),type:S(M),role:S(P).optional()});function Qge(e){if(!ew(e))return e;let t=Reflect.get(e,`source`);if(!ew(t))return e;let n=Reflect.get(t,`composition`);if(!ew(n))return e;let r=Reflect.get(n,`target`);if(!ew(r))return e;let i=Reflect.get(r,`type`);if(typeof i!=`string`)return e;let a={...r,type:Vf(i)};return{...e,source:{...t,composition:{...n,target:a}}}}function ew(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var tw=x({kind:m(`existing`),device:GS}),nw=a(`kind`,[$C,tw]),rw=x({target:nw,features:C(ZC).min(0).max(16),helper:CC.optional()}).superRefine((e,t)=>{let n=new Set;e.features.forEach((e,r)=>{n.has(e.cap)&&t.addIssue({code:`custom`,message:`capability \`${e.cap}\` is composed twice — one feature per capability`,path:[`features`,r,`cap`]}),n.add(e.cap)})});function iw(e){return`${e.addonId}/${e.stableId}`}function aw(e,t){return`${iw(e)}#${t}`}function ow(e){return`${aw(e.source,e.cap)}.${e.fieldPath}`}function sw(e){return`${EC}${e}`}function cw(e){return{addonId:DC,stableId:sw(e)}}function lw(e){switch(e.kind){case`from`:return[{source:e.source,cap:e.cap,fieldPath:e.fieldPath}];case`expression`:return Object.values(e.bindings).flatMap(e=>e.kind===`from`?[{source:e.source,cap:e.cap,fieldPath:e.fieldPath}]:[]);case`aggregate`:return e.reads;case`series`:return[e.read];case`code`:return[]}}function uw(e,t,n){return`${e}[${t}].${n}`}function dw(e,t=KC){return[...Object.entries(e.fields).map(([e,t])=>({fieldPath:e,source:t})),...Object.entries(e.items??{}).flatMap(([e,n])=>Object.entries(n.fields).map(([n,r])=>({fieldPath:uw(t,e,n),source:r})))]}function fw(e){return dw(e).map(e=>e.source)}function pw(e,t){let n=e;for(let e of t.split(`.`)){let t=Nh(n);if(!(t instanceof le))return null;let r=t.shape[e];if(!(r instanceof ae))return null;n=r}return n}function mw(e,t){let n=Ih(e).find(e=>e.path===t);if(n===void 0)return null;let r=pw(e,t);return r===null?null:{path:t,kind:n.kind,nullable:r.safeParse(null).success,required:!r.safeParse(void 0).success,...n.enumValues===void 0?{}:{enumValues:n.enumValues},...n.unionMembers===void 0?{}:{unionMembers:n.unionMembers}}}function hw(e){return new Map(Ih(e).filter(e=>!e.path.includes(`.`)).flatMap(t=>{let n=mw(e,t.path);return n===null?[]:[[t.path,n]]}))}function gw(e){let t=Nh(e);return t instanceof le?Object.entries(t.shape).flatMap(([e,t])=>t instanceof ae&&!t.safeParse(void 0).success?[e]:[]):[]}function _w(e,t){let n=t.split(`.`);return n.slice(0,-1).flatMap((t,r)=>{let i=n.slice(0,r+1).join(`.`),a=pw(e,i);return a!==null&&a.safeParse(void 0).success?[i]:[]})}var vw={"doorbell.onPressed":T.DoorbellOnPressed},$ge=vw,yw=x({featureIndex:r().int().nonnegative(),cap:u(),eventName:u(),category:S(T),stateField:u(),fieldKey:u()});function bw(e,t,n){return{code:e,path:t,message:n}}function e_e(e){return e.issues.map(e=>`${e.path.length===0?`payload`:e.path.join(`.`)}: ${e.message}`).join(`; `)}function xw(e,t,n){if(t.mode===`replace`)return{problems:[],events:[]};let r=[],i=[];for(let[a,o]of Object.entries(e.events??{})){let s=o.fromState;if(s===void 0)continue;let c=`features[${t.featureIndex}].fields.${s.field}`,l=e.runtimeState?mw(e.runtimeState,s.field):null;if(l===null){r.push(bw(`unknown-field`,c,`\`${e.name}.${a}\` derives from missing state field \`${s.field}\``));continue}if(l.kind!==`number`){r.push(bw(`kind-mismatch`,c,`\`${e.name}.${a}\` needs a numeric state field; \`${s.field}\` is ${l.kind}`));continue}let u=`${e.name}.${a}`,d=$ge[u];if(d===void 0){r.push(bw(`not-composable`,`features[${t.featureIndex}].cap`,`\`${u}\` has no explicit composition event-category mapping`));continue}let f=o.data.safeParse({deviceId:1,timestamp:1});if(!f.success){r.push(bw(`not-composable`,`features[${t.featureIndex}].cap`,`\`${u}\` cannot be derived from { deviceId, timestamp }: ${e_e(f.error)}`));continue}let p=n.find(n=>n.featureIndex===t.featureIndex&&n.cap===e.name&&n.path===s.field&&n.item===void 0);if(p===void 0){r.push(bw(`unknown-field`,c,`\`${u}\` derives from \`${s.field}\`, but that field is not composed`));continue}i.push({featureIndex:t.featureIndex,cap:e.name,eventName:a,category:d,stateField:s.field,fieldKey:`${p.cap}.${p.path}`})}return{problems:r,events:i}}var Sw=S(`reserved-variant.unknown-capability.not-composable.wrong-device-type.has-commands.unknown-field.nested-field.missing-field.kind-mismatch.source-kind-mismatch.may-be-null.source-missing.source-unreadable.source-capability-missing.source-field-unknown.expression-invalid.cycle.duplicate-target.not-item-array.item-field-reserved.target-missing.target-unreadable.not-replaceable.native-capability-replace.mixed-quantity.helper-mismatch.member-constraint.retention.command-method-unknown.command-source-unknown.command-input-unknown.command-input-missing.power-source-is-actuator.link-contribution-removed`.split(`.`)),Cw=x({code:Sw,path:u(),message:u()}),ww=S([`string`,`number`,`boolean`,`enum`]),Tw=S([`null`,`offline`,`unknown`,`release`,`omit`]),Ew=S([`derived`,`clock`,`constant`,`accumulator`]),Dw=x({arrayPath:u(),key:u(),label:u(),resettable:y().optional()}),Ow=x({cap:u(),path:u(),item:Dw.optional(),featureIndex:r().int().nonnegative(),kind:ww,nullable:y(),required:y(),unavailable:Tw,role:Ew,source:LC,reads:C(kC)});function kw(e){let t=e.item===void 0?e.path:uw(e.item.arrayPath,e.item.key,e.path);return`${e.cap}.${t}`}var Aw=S([`new`,`add`,`replace`]),jw=x({featureIndex:r().int().nonnegative(),cap:u(),mode:Aw}),Mw=x({ok:y(),problems:C(Cw),fields:C(Ow),features:C(jw),events:C(yw)}),Nw=S([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),Pw=S([`fresh`,`stale`,`unavailable`]),Fw=x({cap:u(),path:u(),item:Dw.optional(),state:Pw,value:g([u(),r(),y(),oe()]),reason:u().optional()}),Iw=x({blockId:u(),deviceId:r().nullable(),status:Nw,reason:u().optional(),fields:C(Fw)}),t_e=DC,Lw=x({id:u().min(1),name:u().min(1).max(120),enabled:y(),updatedAt:r(),composition:rw}),Rw=x({id:u().min(1),name:u().nullable(),error:u()}),zw=x({deviceId:r().int(),capName:u(),owner:u(),error:u()}),Bw=x({integrationId:u().nullable(),storeLoaded:y(),blocks:C(Lw),restartBlockIds:C(u()),unreadableBlocks:C(Rw),retiredBlockIds:C(u()).optional()}),Vw=x({blockId:u(),status:Nw,reason:u().optional()}),Hw=x({blocks:C(Vw),acted:y(),unreleasedClaims:C(zw).optional()}),Uw={name:`composer`,scope:`system`,mode:`singleton`,internal:!0,methods:{applyBlocks:D(Bw,Hw,{kind:`mutation`,auth:`admin`}),getStates:D(x({blockIds:C(u())}),x({states:C(Iw)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`device composition — an authoring tool, not an action`}},Ww=x({connected:y(),lastChangedAt:r()}),Gw={name:`connectivity`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:Ww,kind:`push`},runtimeState:Ww,durability:`restored`,history:{fields:{connected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Connectivity`,`Connettività`),order:5040,state:[{kind:`boolean`,field:`connected`,label:L(`Connected`,`Connesso`),whenTrue:L(`When {device} connects`,`Quando {device} si connette`),whenFalse:L(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}]}},Kw=S([`wear`,`supply`,`waste`]),qw=S([`part`,`tank`,`product`,`bin`]),Jw=S([`ok`,`low`,`empty`,`full`,`replace`]),Yw=S([`ok`,`low`,`empty`,`full`]);function Xw(e){return e.kind??`wear`}var n_e={wear:`part`,waste:`bin`,supply:`product`};function Zw(e){return e.form??n_e[Xw(e)]}var Qw=S([`duration`,`count`]),$w=x({value:r().min(0).nullable().meta(A(`device`)),kind:Qw}),eT=x({key:u().min(1),label:u().min(1),level:r().min(0).max(100).nullable().meta(A(`percentage`)),status:Jw.nullable(),kind:Kw.optional(),form:qw.optional(),lastResetAt:r().nullable(),resettable:y(),remaining:$w.optional()}),tT=x({items:C(eT),lastChangedAt:r()}),r_e={items:[],lastChangedAt:0},i_e={version:1,targets:[{id:`items`,cardinality:`keyedArray`,vocabulary:{cap:`consumables`},deviceTypes:Object.values(M),apply:`add`,path:`items`,keyField:`key`,labelField:`label`,itemSchema:eT,nativeItems:`read-only`,sourceReport:{status:`assignment-status`},fields:[{path:`level`,sources:[{kind:`numeric`,transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}]},{path:`remaining.value`,sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],literals:[{path:`remaining.kind`,values:[...Qw.options]}]},{path:`status`,sources:[{kind:`enum`,transforms:[{kind:`enum-map`,outputValues:[...Jw.options],unmapped:null}]}]}],traits:[{path:`kind`,values:[...Kw.options],defaultValue:`wear`},{path:`form`,values:[...qw.options],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}],advancedExpression:!0}]},nT={name:`consumables`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:Object.values(M),methods:{reset:D(x({deviceId:r().int().nonnegative(),key:u().min(1)}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`consumables.reset`,label:L(`Mark as replaced`,`Segna come sostituito`),phrase:L(`Mark {key} as replaced on {device}`,`Segna {key} come sostituito su {device}`),icon:`refresh-cw`,openArgs:[{key:`key`,label:L(`Consumable`,`Materiale`),offer:{kind:`dynamic`,from:`status`,field:`items`,valueKey:`key`,labelKey:`label`,where:{key:`resettable`,equals:!0}}}]}]})},composedMethods:{reset:{kind:`refuse`,reason:`a consumable added to an existing device is not resettable — only a new composed device forwards a reset`}},status:{schema:tT,kind:`push`,empty:r_e,itemArray:{path:`items`,keyField:`key`,labelField:`label`,itemSchema:eT,emptyItem:{key:``,label:``,level:null,status:null,lastResetAt:null,resettable:!1}}},runtimeState:tT.extend({lastFetchedAt:r()}),durability:`restored`,customize:i_e,history:{fields:{},items:{path:`items`,key:`key`,label:`label`,fields:{level:{kind:`gauge`,unit:`%`,deadband:2,displayName:`Level`},status:{kind:`enum`,displayName:`Status`},"remaining.value":{kind:`gauge`,deadband:1,displayName:`Remaining`}}}},volatileStateFields:[`lastChangedAt`,`lastFetchedAt`],vocabulary:{noun:L(`Consumables`,`Materiali di consumo`),order:2070}},rT=x({entryOpen:y(),lastChangedAt:r()}),iT={name:`contact`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:rT,kind:`push`},runtimeState:rT,durability:`restored`,history:{fields:{entryOpen:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Contact`,`Contatto`),order:5050,state:[{kind:`boolean`,field:`entryOpen`,label:L(`Open`,`Aperto`),whenTrue:L(`When {device} opens`,`Quando {device} si apre`),whenFalse:L(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}]}},aT=S([`numeric`,`select`,`text`,`datetime`]),oT=x({kind:aT,value:g([r().meta(A(`device`)),u()]),options:C(u()),lastChangedAt:r(),min:r().optional().meta(A(`device`)),max:r().optional().meta(A(`device`)),step:r().optional().meta(A(`device`))}),a_e=a(`kind`,[x({kind:m(`numeric`),value:r()}),x({kind:m(`select`),value:u().min(1)}),x({kind:m(`text`),value:u()}),x({kind:m(`datetime`),value:u().min(1)})]),sT=x({deviceId:r().int().nonnegative(),cycle:y().default(!0)}),cT=x({deviceId:r().int().nonnegative()}),lT={name:`control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Control],methods:{setValue:D(x({deviceId:r().int().nonnegative(),control:a_e}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`the value shape depends on the control kind (numeric / select / text / datetime) read from status; a typed picker for it is a follow-up of the automations rework`}),next:O(sT,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.next`,label:L(`Next option`,`Opzione successiva`),phrase:L(`Select the next option on {device}`,`Seleziona l’opzione successiva su {device}`),icon:`skip-forward`,openArgs:[{key:`cycle`,label:L(`Wrap to the first option`,`Ricomincia dalla prima opzione`),offer:{kind:`boolean`}}]}]}),previous:O(sT,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.previous`,label:L(`Previous option`,`Opzione precedente`),phrase:L(`Select the previous option on {device}`,`Seleziona l’opzione precedente su {device}`),icon:`skip-back`,openArgs:[{key:`cycle`,label:L(`Wrap to the last option`,`Ricomincia dall’ultima opzione`),offer:{kind:`boolean`}}]}]}),first:O(cT,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.first`,label:L(`First option`,`Prima opzione`),phrase:L(`Select the first option on {device}`,`Seleziona la prima opzione su {device}`),icon:`chevron-first`}]}),last:O(cT,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.last`,label:L(`Last option`,`Ultima opzione`),phrase:L(`Select the last option on {device}`,`Seleziona l’ultima opzione su {device}`),icon:`chevron-last`}]})},status:{schema:oT,kind:`push`},runtimeState:oT,durability:`session`,history:`none`,vocabulary:{noun:L(`Control`,`Controllo`),order:1150,state:[{kind:`value`,field:`value`,label:L(`Value`,`Valore`),offer:{kind:`dynamic`,from:`status`,field:`options`},icon:`sliders-horizontal`}]}},R=class extends Error{code;constructor(e,t){super(t),this.name=`IrCodecError`,this.code=e}},uT=1024,dT=C(r().int()).min(2).max(uT).superRefine((e,t)=>{e.forEach((e,n)=>{let r=n%2==0;(e===0||e>0!==r)&&t.addIssue({code:`custom`,message:`timing ${n} must be a non-zero ${r?`mark (positive)`:`space (negative)`}`,path:[n]})})}),fT=x({carrierHz:r().int().positive().optional(),dutyCyclePercent:r().int().min(1).max(100).optional(),repeat:r().int().min(0).max(20).optional(),repeatDelayMs:r().int().min(0).optional()}),o_e=.241246,s_e=0;function pT(e){let t=e.trim().split(/\s+/).filter(e=>e.length>0);if(t.length<4)throw new R(`pronto-malformed`,`Pronto code needs at least 4 words, got ${t.length}`);let n=t.map(e=>/^[0-9a-fA-F]{1,4}$/.test(e)?parseInt(e,16):NaN);if(n.some(e=>Number.isNaN(e)))throw new R(`pronto-malformed`,`Pronto code must be 4-digit hexadecimal words`);let[r,i,a,o]=n;if(r===void 0||i===void 0||a===void 0||o===void 0)throw new R(`pronto-malformed`,`Pronto header incomplete`);if(r!==s_e)throw new R(`pronto-unsupported-form`,`Pronto form ${t[0]??``} is not supported, only the learned 0000 form`);if(i===0)throw new R(`pronto-malformed`,`Pronto frequency word is zero`);let s=a+o;if(s===0||n.length!==4+s*2)throw new R(`pronto-malformed`,`Pronto declares ${s} burst pairs but carries ${(n.length-4)/2} word pairs`);let c=i*o_e,l=n.slice(4).map((e,t)=>{let n=Math.max(1,Math.round(e*c));return t%2==0?n:-n}),u=dT.safeParse(l);if(!u.success)throw new R(`invalid-timings`,`Pronto decoded to invalid timings: ${u.error.message}`);return{timings:u.data,carrierHz:Math.round(1e6/c)}}var c_e=8192,mT=32,hT=3,l_e=264,gT=uT*2;function u_e(e){let t=[],n=0,r=e=>{if(t.length+e>gT)throw new R(`tuya-malformed`,`decompressed code is larger than any IR train`)},i=()=>{let t=e[n++];if(t===void 0)throw new R(`tuya-malformed`,`compressed stream is truncated`);return t};for(;n<e.length;){let e=i();if(e<32){r(e+1);for(let n=0;n<=e;n++)t.push(i());continue}let n=(e>>5)-1;n===6&&(n+=i());let a=((e&31)<<8)+i()+1,o=t.length-a;if(o<0)throw new R(`tuya-malformed`,`back-reference points before the stream`);r(n+3);for(let e=0;e<n+3;e++){let n=t[o+e];if(n===void 0)throw new R(`tuya-malformed`,`back-reference is invalid`);t.push(n)}}return Uint8Array.from(t)}function d_e(e){let t=[],n=new Map,r=0,i=n=>{for(let i=r;i<n;i+=mT){let r=Math.min(i+mT,n);t.push(r-i-1);for(let n=i;n<r;n++)t.push(e[n]??0)}},a=0;for(;a<e.length;){let o=0,s=0;if(a+hT<=e.length){let t=(e[a]??0)<<16|(e[a+1]??0)<<8|(e[a+2]??0),r=n.get(t);if(n.set(t,a),r!==void 0&&a-r<=c_e){let t=0;for(;a+t<e.length&&t<l_e&&e[r+t]===e[a+t];)t++;t>=hT&&(o=t,s=a-r-1)}}if(o===0){a++;continue}i(a);let c=o-2;c<7?t.push(c<<5|s>>8):t.push(224|s>>8,c-7),t.push(s&255),a+=o,r=a}return i(e.length),Uint8Array.from(t)}var _T=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,f_e=65535;function p_e(e){let t=``;for(let n=0;n<e.length;n+=3){let r=e[n]??0,i=e[n+1]??0,a=e[n+2]??0,o=r<<16|i<<8|a;t+=_T[o>>18&63],t+=_T[o>>12&63],t+=n+1<e.length?_T[o>>6&63]:`=`,t+=n+2<e.length?_T[o&63]:`=`}return t}function m_e(e){let t=e.trim().replace(/=+$/,``);if(t.length===0||t.length%4==1)throw new R(`tuya-malformed`,`not a base64 string`);let n=[],r=0,i=0;for(let e of t){let t=_T.indexOf(e);if(t<0)throw new R(`tuya-malformed`,`not a base64 string`);i=i<<6|t,r+=6,r>=8&&(r-=8,n.push(i>>r&255))}return Uint8Array.from(n)}function vT(e){let t=new Uint8Array(e.length*2);return e.forEach((e,n)=>{let r=Math.abs(e);if(r===0||r>f_e)throw new R(`invalid-timings`,`timing ${n} does not fit 16 bits`);t[n*2]=r&255,t[n*2+1]=r>>8}),p_e(d_e(t))}function yT(e){let t=u_e(m_e(e));if(t.length===0||t.length%2!=0)throw new R(`tuya-malformed`,`payload is not a list of 16-bit durations`);let n=[];for(let e=0;e<t.length;e+=2){let r=(t[e]??0)|(t[e+1]??0)<<8;n.push(e/2%2==0?r:-r)}let r=dT.safeParse(n);if(!r.success)throw new R(`tuya-malformed`,r.error.message);return r.data}var bT=S([`tuya`]),xT=Math.ceil((gT+Math.ceil(gT/32))/3)*4+256,ST=x({format:bT,code:u().min(1).max(xT)}),CT={tuya:{encode:vT,decode:yT}},wT=a(`kind`,[x({kind:m(`raw`),timings:C(r().int()),settings:fT.optional()}),x({kind:m(`pronto`),code:u()}),x({kind:m(`native`),format:bT,code:u()})]);function TT(e){if(e.kind===`pronto`){let t=pT(e.code);return{timings:t.timings,settings:{carrierHz:t.carrierHz}}}if(e.kind===`native`)return{timings:CT[e.format].decode(e.code),settings:{}};let t=dT.safeParse(e.timings);if(!t.success)throw new R(`invalid-timings`,t.error.message);return{timings:t.data,settings:e.settings??{}}}var ET=`power.power_on.power_off.volume_up.volume_down.mute.channel_up.channel_down.up.down.left.right.ok.back.home.menu.info.guide.exit.input.play.pause.play_pause.stop.next.previous.fast_forward.rewind.digit_0.digit_1.digit_2.digit_3.digit_4.digit_5.digit_6.digit_7.digit_8.digit_9.source_select`.split(`.`),DT=[`source_select`];function OT(e){return DT.includes(e)}var kT=`custom:`,h_e=/^[a-z0-9][a-z0-9_]{0,47}$/,g_e=new Set(ET);function AT(e){return g_e.has(e)}function jT(e){return h_e.test(e)}function MT(e){return`${kT}${e}`}function NT(e){if(!e.startsWith(`custom:`))return null;let t=e.slice(7);return jT(t)?t:null}function PT(e){return AT(e)||NT(e)!==null}var FT=u().refine(PT,{message:`a role is one of the known roles or custom:<key> (lowercase letters, digits, _)`}),IT=[`digits`,`sequence`,`ir`],__e=S(IT),v_e=/^[a-z0-9][a-z0-9_-]{0,47}$/,y_e=RegExp(`^[0-9]{1,6}$`),LT={id:u().regex(v_e,{message:`a lowercase slug`}),name:u().trim().min(1).max(60)},RT=x({...LT,kind:m(`digits`),number:u().regex(y_e,{message:`up to 6 digits`})}),zT=x({...LT,kind:m(`sequence`),steps:C(FT).min(1).max(16)}),BT=x({...LT,kind:m(`ir`),transmitterId:r().int().nonnegative().optional(),payload:wT}),VT=a(`kind`,[RT,zT,BT]),HT=3e3;function UT(e){switch(e.kind){case`sequence`:return e.steps;case`digits`:return Array.from(e.number,e=>`digit_${e}`);case`ir`:return[]}}function WT(e){try{return TT(e.payload),null}catch(e){if(e instanceof R)return e.message;throw e}}function b_e(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function GT(e,t){let n=t.trim();for(let t of e)if(t.kind===`digits`&&t.number===n)return t;return null}function x_e(e,t){let n=e.find(e=>b_e(e.name,t));if(n!==void 0)return n;let r=e.find(e=>e.id===t.trim());return r===void 0?GT(e,t):r}var KT=S([`off`,`on`,`idle`,`playing`,`paused`,`buffering`,`standby`]),qT=S([`off`,`all`,`one`]),S_e=x({type:u(),title:u(),artist:u().optional(),album:u().optional(),imageUrl:u().optional()}),JT=S([`reported`,`assumed`]),YT=S([`state`,`volumeLevel`,`isMuted`,`source`]),XT=x({state:KT,stateSource:JT.default(`reported`),assumedFields:C(YT).default([]),volumeLevel:r().min(0).max(100).nullable().meta(A(`percentage`)),isMuted:y().nullable(),muteReadback:y().optional(),source:u(),availableSources:C(u()),declaredSources:C(x({name:u(),kind:S(IT),number:u().optional()})).optional(),currentMedia:S_e.nullable(),position:r().int().nonnegative().nullable().meta(A(`duration-ms`)),duration:r().int().nonnegative().nullable().meta(A(`duration-ms`)),shuffle:y().nullable(),repeat:qT.nullable(),positionUpdatedAt:r().nullable().default(null),lastChangedAt:r()}),ZT=x({deviceId:r().int().nonnegative(),steps:r().int().min(1).max(50).default(1)}),QT=x({deviceId:r().int().nonnegative()}),$T={name:`media-player`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.MediaPlayer],power:{kind:`methods`,field:`state`,offValues:[`off`,`standby`],on:`turnOn`,off:`turnOff`},methods:{turnOn:O(QT,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOn`,label:L(`Turn on`,`Accendi`),phrase:L(`Turn on {device}`,`Accendi {device}`),icon:`power`}]}),turnOff:O(QT,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOff`,label:L(`Turn off`,`Spegni`),phrase:L(`Turn off {device}`,`Spegni {device}`),icon:`power`}]}),volumeUp:O(ZT,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeUp`,label:L(`Volume up`,`Alza il volume`),phrase:L(`Raise the volume of {device}`,`Alza il volume di {device}`),icon:`volume-2`}]}),volumeDown:O(ZT,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeDown`,label:L(`Volume down`,`Abbassa il volume`),phrase:L(`Lower the volume of {device}`,`Abbassa il volume di {device}`),icon:`volume-2`}]}),channelUp:O(ZT,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelUp`,label:L(`Channel up`,`Canale successivo`),phrase:L(`Go to the next channel on {device}`,`Passa al canale successivo su {device}`),icon:`skip-forward`}]}),channelDown:O(ZT,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelDown`,label:L(`Channel down`,`Canale precedente`),phrase:L(`Go to the previous channel on {device}`,`Torna al canale precedente su {device}`),icon:`skip-back`}]}),play:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.play`,effect:{field:`state`,value:`playing`},label:L(`Play`,`Riproduci`),phrase:L(`Play on {device}`,`Avvia la riproduzione su {device}`),icon:`play`}]}),pause:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.pause`,effect:{field:`state`,value:`paused`},label:L(`Pause media`,`Metti in pausa`),phrase:L(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),stop:O(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.stop`,label:L(`Stop media`,`Ferma la riproduzione`),phrase:L(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),next:O(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.next`,label:L(`Next track`,`Brano successivo`),phrase:L(`Skip to the next track on {device}`,`Passa al brano successivo su {device}`),icon:`skip-forward`}]}),previous:O(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.previous`,label:L(`Previous track`,`Brano precedente`),phrase:L(`Go back to the previous track on {device}`,`Torna al brano precedente su {device}`),icon:`skip-back`}]}),setVolume:O(x({deviceId:r().int().nonnegative(),volumeLevel:r().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volume`,effect:{field:`volumeLevel`,fromArg:`volumeLevel`},label:L(`Set volume`,`Imposta il volume`),phrase:L(`Set the volume of {device} to {volumeLevel}`,`Imposta il volume di {device} al {volumeLevel}`),icon:`volume-2`,openArgs:[{key:`volumeLevel`,label:L(`Volume`,`Volume`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMute:O(x({deviceId:r().int().nonnegative(),muted:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.mute`,effect:{field:`isMuted`,value:!0},label:L(`Mute`,`Silenzia`),phrase:L(`Mute {device}`,`Silenzia {device}`),icon:`volume-x`,args:{muted:!0}},{id:`media.unmute`,effect:{field:`isMuted`,value:!1},label:L(`Unmute`,`Riattiva l’audio`),phrase:L(`Unmute {device}`,`Riattiva l’audio di {device}`),icon:`volume-2`,args:{muted:!1}}]}),setShuffle:O(x({deviceId:r().int().nonnegative(),shuffle:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.shuffleOn`,effect:{field:`shuffle`,value:!0},label:L(`Shuffle on`,`Riproduzione casuale attiva`),phrase:L(`Turn on shuffle on {device}`,`Attiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!0}},{id:`media.shuffleOff`,effect:{field:`shuffle`,value:!1},label:L(`Shuffle off`,`Riproduzione casuale spenta`),phrase:L(`Turn off shuffle on {device}`,`Disattiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!1}}]}),setRepeat:O(x({deviceId:r().int().nonnegative(),repeat:qT}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.repeat`,effect:{field:`repeat`,fromArg:`repeat`},label:L(`Set repeat`,`Imposta la ripetizione`),phrase:L(`Set repeat on {device} to {repeat}`,`Imposta la ripetizione di {device} su {repeat}`),icon:`repeat`,openArgs:[{key:`repeat`,label:L(`Repeat`,`Ripetizione`),offer:{kind:`enum`,values:[{value:`off`,label:L(`Off`,`Disattivata`)},{value:`all`,label:L(`All`,`Tutti i brani`)},{value:`one`,label:L(`One track`,`Un brano`)}]}}]}]}),selectSource:O(x({deviceId:r().int().nonnegative(),source:u().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.source`,effect:{field:`source`,fromArg:`source`},label:L(`Select source`,`Scegli la sorgente`),phrase:L(`Switch {device} to {source}`,`Passa {device} alla sorgente {source}`),icon:`cast`,openArgs:[{key:`source`,label:L(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`}}]}]}),seek:O(x({deviceId:r().int().nonnegative(),position:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.seek`,label:L(`Seek`,`Vai al punto`),phrase:L(`Move {device} to {position}`,`Porta {device} al punto {position}`),icon:`fast-forward`,openArgs:[{key:`position`,label:L(`Position`,`Posizione`),offer:{kind:`number`,min:0,step:1e3,unit:`ms`}}]}]}),playMedia:O(x({deviceId:r().int().nonnegative(),mediaId:u().min(1),mediaType:u().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.playMedia`,label:L(`Play media`,`Riproduci un contenuto`),phrase:L(`Play {mediaId} on {device}`,`Riproduci {mediaId} su {device}`),icon:`music`,openArgs:[{key:`mediaId`,label:L(`Media`,`Contenuto`),offer:{kind:`text`}},{key:`mediaType`,label:L(`Media type`,`Tipo di contenuto`),offer:{kind:`text`}}]}]})},status:{schema:XT,kind:`push`},runtimeState:XT,durability:`session`,history:{fields:{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}}},vocabulary:{noun:L(`Media player`,`Lettore multimediale`),order:2060,state:[{kind:`enum`,field:`state`,label:L(`Playback`,`Riproduzione`),values:[{value:`off`,label:L(`Off`,`Spento`),phrase:L(`When {device} turns off`,`Quando {device} si spegne`)},{value:`on`,label:L(`On`,`Acceso`),phrase:L(`When {device} turns on`,`Quando {device} si accende`)},{value:`idle`,label:L(`Idle`,`Inattivo`)},{value:`playing`,label:L(`Playing`,`In riproduzione`),phrase:L(`When {device} starts playing`,`Quando {device} inizia a riprodurre`)},{value:`paused`,label:L(`Paused`,`In pausa`),phrase:L(`When {device} is paused`,`Quando {device} va in pausa`)},{value:`buffering`,label:L(`Buffering`,`In caricamento`)},{value:`standby`,label:L(`Standby`,`In standby`)}],icon:`music`},{kind:`numeric`,field:`volumeLevel`,quantity:L(`the volume`,`il volume`),label:L(`Volume`,`Volume`),unit:`%`,icon:`volume-2`},{kind:`boolean`,field:`isMuted`,label:L(`Muted`,`Silenziato`),whenTrue:L(`When {device} is muted`,`Quando {device} viene silenziato`),whenFalse:L(`When {device} is unmuted`,`Quando l’audio di {device} torna attivo`),icon:`volume-x`},{kind:`value`,field:`source`,label:L(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`},icon:`cast`}]}},eE={battery:{version:1,targets:[{id:`level`,cardinality:`scalar`,deviceTypes:[M.Camera,M.Sensor,M.Button,M.Switch,M.PetFeeder,M.Container,M.Climate,M.EventEmitter],apply:`add`,vocabularyCap:`battery`,vocabularyStateField:`level`,sources:[{kind:`field`,valueKinds:[`number`,`string`],transformKinds:[`identity`,`linear`],transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`level`,valueKind:`number`,nullable:!0,companions:[{kind:`constant`,path:`charging`,value:`unknown`,when:`add`},{kind:`constant`,path:`sleeping`,value:!1,when:`add`},{kind:`clock`,path:`lastUpdated`,when:`add`}]}]},"climate-control":{version:1,targets:[{id:`room-temperature`,cardinality:`scalar`,deviceTypes:[M.Climate],apply:`replace`,vocabularyCap:`climate-control`,vocabularyStateField:`currentTemp`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`currentTemp`,valueKind:`number`,nullable:!0},{id:`room-humidity`,cardinality:`scalar`,deviceTypes:[M.Climate],apply:`replace`,vocabularyCap:`climate-control`,vocabularyStateField:`currentHumidity`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`currentHumidity`,valueKind:`number`,nullable:!0}],overridable:[{path:`currentTemp`,by:`room-temperature`},{path:`currentHumidity`,by:`room-humidity`}]},consumables:{version:1,targets:[{id:`items`,cardinality:`keyedArray`,deviceTypes:[M.Camera,M.Light,M.Siren,M.Switch,M.Sensor,M.Climate,M.Button,M.EventEmitter,M.Update,M.Generic,M.Notifier,M.Script,M.Automation,M.Lock,M.Cover,M.Valve,M.Humidifier,M.WaterHeater,M.Fan,M.MediaPlayer,M.AlarmPanel,M.Control,M.Presence,M.Weather,M.WeatherStation,M.Vacuum,M.LawnMower,M.Container,M.Image,M.PetFeeder,M.PetFountain,M.Dishwasher,M.Washer,M.Dryer,M.Gateway,M.HeatPump,M.EnergySystem,M.Workload],apply:`add`,vocabularyCap:`consumables`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`items`,keyField:`key`,labelField:`label`,nativeItems:`read-only`,fields:[{path:`level`,valueKind:`number`,nullable:!0,sources:[{kind:`numeric`,transformKinds:[`identity`,`linear`],transforms:[{kind:`identity`},{kind:`linear`,defaultScale:1,defaultOffset:0,clampMin:0,clampMax:100}]}]},{path:`remaining.value`,valueKind:`number`,nullable:!0,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],literals:[{path:`remaining.kind`,values:[`duration`,`count`]}]},{path:`status`,valueKind:`enum`,nullable:!0,enumValues:[`ok`,`low`,`empty`,`full`,`replace`],sources:[{kind:`enum`,transformKinds:[`enum-map`],transforms:[{kind:`enum-map`,outputValues:[`ok`,`low`,`empty`,`full`,`replace`],unmapped:null}]}]}],traits:[{path:`kind`,values:[`wear`,`supply`,`waste`],defaultValue:`wear`},{path:`form`,values:[`part`,`tank`,`product`,`bin`],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}]}]},doorbell:{version:1,targets:[{id:`pressed`,cardinality:`event`,deviceTypes:[M.Camera],apply:`add`,vocabularyCap:`doorbell`,vocabularyEvent:`onPressed`,sources:[{kind:`binary`,transformKinds:[],transforms:[]},{kind:`switch`,transformKinds:[],transforms:[]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,shape:`pulse`,applyAuthority:{kind:`composition-claim`},eventName:`onPressed`,combine:`any`,edges:[`rising`],defaultEdge:`rising`,timestampPath:`lastPressedAt`,counterPath:`pressCountSinceStart`,highWater:`composer-advance`,debounceMs:2e3}]},"fan-control":{version:1,targets:[{id:`horizontal-oscillating`,cardinality:`scalar`,deviceTypes:[M.Fan],apply:`replace`,vocabularyCap:`fan-control`,vocabularyStateField:`oscillating`,sources:[{kind:`switch`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.horizontal.oscillating`,valueKind:`boolean`,nullable:!0},{id:`horizontal-angle`,cardinality:`scalar`,deviceTypes:[M.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.horizontal.angle`,valueKind:`number`,nullable:!0,companions:[{kind:`source-field`,path:`oscillationAxes.horizontal.min`,field:`min`},{kind:`source-field`,path:`oscillationAxes.horizontal.max`,field:`max`},{kind:`source-field`,path:`oscillationAxes.horizontal.step`,field:`step`}]},{id:`horizontal-sweepFrom`,cardinality:`scalar`,deviceTypes:[M.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.horizontal.sweepFrom`,valueKind:`number`,nullable:!0},{id:`horizontal-sweepTo`,cardinality:`scalar`,deviceTypes:[M.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.horizontal.sweepTo`,valueKind:`number`,nullable:!0},{id:`vertical-oscillating`,cardinality:`scalar`,deviceTypes:[M.Fan],apply:`replace`,vocabularyCap:`fan-control`,vocabularyStateField:`oscillating`,sources:[{kind:`switch`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.vertical.oscillating`,valueKind:`boolean`,nullable:!0},{id:`vertical-angle`,cardinality:`scalar`,deviceTypes:[M.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.vertical.angle`,valueKind:`number`,nullable:!0,companions:[{kind:`source-field`,path:`oscillationAxes.vertical.min`,field:`min`},{kind:`source-field`,path:`oscillationAxes.vertical.max`,field:`max`},{kind:`source-field`,path:`oscillationAxes.vertical.step`,field:`step`}]},{id:`vertical-sweepFrom`,cardinality:`scalar`,deviceTypes:[M.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.vertical.sweepFrom`,valueKind:`number`,nullable:!0},{id:`vertical-sweepTo`,cardinality:`scalar`,deviceTypes:[M.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,section:`oscillation-axes`,path:`oscillationAxes.vertical.sweepTo`,valueKind:`number`,nullable:!0},{id:`preset`,cardinality:`scalar`,deviceTypes:[M.Fan],apply:`replace`,vocabularyCap:`fan-control`,sources:[{kind:`field`,valueKinds:[`string`],transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`preset`,valueKind:`string`,nullable:!1}],overridable:[{path:`oscillationAxes.horizontal.oscillating`,by:`horizontal-oscillating`},{path:`oscillationAxes.horizontal.angle`,by:`horizontal-angle`},{path:`oscillationAxes.horizontal.sweepFrom`,by:`horizontal-sweepFrom`},{path:`oscillationAxes.horizontal.sweepTo`,by:`horizontal-sweepTo`},{path:`oscillationAxes.vertical.oscillating`,by:`vertical-oscillating`},{path:`oscillationAxes.vertical.angle`,by:`vertical-angle`},{path:`oscillationAxes.vertical.sweepFrom`,by:`vertical-sweepFrom`},{path:`oscillationAxes.vertical.sweepTo`,by:`vertical-sweepTo`},{path:`preset`,by:`preset`}]},"fan-presets":{version:1,targets:[{id:`presets`,cardinality:`config`,deviceTypes:[M.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`,vocabularyCap:`fan-presets`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},"heat-pump-status":{version:1,targets:[{id:`electrical-power`,cardinality:`scalar`,deviceTypes:[M.HeatPump],apply:`replace`,vocabularyCap:`heat-pump-status`,sources:[{kind:`numeric`,requiredUnit:`W`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`power.electricalW`,valueKind:`number`,nullable:!0},{id:`electrical-energy`,cardinality:`scalar`,deviceTypes:[M.HeatPump],apply:`replace`,vocabularyCap:`heat-pump-status`,sources:[{kind:`numeric`,requiredUnit:`kWh`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`energy.electricalKwh`,valueKind:`number`,nullable:!0}],overridable:[{path:`power.electricalW`,by:`electrical-power`},{path:`energy.electricalKwh`,by:`electrical-energy`}]},"lock-control":{version:1,targets:[{id:`door-contact`,cardinality:`scalar`,deviceTypes:[M.Lock],apply:`replace`,vocabularyCap:`lock-control`,vocabularyStateField:`state`,sources:[{kind:`binary`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},valueKind:`enum`,nullable:!1,enumValues:[`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]}],overridable:[{path:`state`,by:`door-contact`}]},motion:{version:1,targets:[{id:`detected`,cardinality:`event`,deviceTypes:[M.Camera],apply:`add`,vocabularyCap:`motion`,vocabularyEvent:`onMotionChanged`,sources:[{kind:`binary`,transformKinds:[],transforms:[]},{kind:`switch`,transformKinds:[],transforms:[]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,shape:`span`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,combine:`any`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:3e4,sourceModes:[`in-addition`,`confirm`,`replace`]}]},"power-meter":{version:1,targets:[{id:`power`,cardinality:`scalar`,deviceTypes:[M.Switch,M.Light,M.Fan,M.Climate,M.Humidifier,M.WaterHeater,M.MediaPlayer,M.Washer,M.Dryer,M.Dishwasher,M.Vacuum,M.LawnMower,M.PetFeeder,M.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`power`,sources:[{kind:`numeric`,requiredUnit:`W`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`power`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`energy`,cardinality:`scalar`,deviceTypes:[M.Switch,M.Light,M.Fan,M.Climate,M.Humidifier,M.WaterHeater,M.MediaPlayer,M.Washer,M.Dryer,M.Dishwasher,M.Vacuum,M.LawnMower,M.PetFeeder,M.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`energy`,sources:[{kind:`numeric`,requiredUnit:`kWh`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`energy`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`voltage`,cardinality:`scalar`,deviceTypes:[M.Switch,M.Light,M.Fan,M.Climate,M.Humidifier,M.WaterHeater,M.MediaPlayer,M.Washer,M.Dryer,M.Dishwasher,M.Vacuum,M.LawnMower,M.PetFeeder,M.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`voltage`,sources:[{kind:`numeric`,requiredUnit:`V`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`voltage`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]},{id:`current`,cardinality:`scalar`,deviceTypes:[M.Switch,M.Light,M.Fan,M.Climate,M.Humidifier,M.WaterHeater,M.MediaPlayer,M.Washer,M.Dryer,M.Dishwasher,M.Vacuum,M.LawnMower,M.PetFeeder,M.Workload],apply:`add`,vocabularyCap:`power-meter`,vocabularyStateField:`current`,sources:[{kind:`numeric`,requiredUnit:`A`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!0,path:`current`,valueKind:`number`,nullable:!1,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}]}]},"power-source":{version:1,targets:[{id:`switch`,cardinality:`scalar`,deviceTypes:[M.Gateway,M.Camera,M.Sensor,M.MediaPlayer,M.Vacuum,M.Generic,M.Washer,M.Dryer,M.Dishwasher,M.PetFountain,M.Fan,M.Humidifier,M.Climate,M.WaterHeater],apply:`add`,vocabularyCap:`power-source`,vocabularyStateField:`switchOn`,sources:[{kind:`switch`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`switchOn`,valueKind:`boolean`,nullable:!0,companions:[{kind:`constant`,path:`offSeconds`,value:10,when:`add`,formerValues:[0]},{kind:`clock`,path:`lastFetchedAt`,when:`always`}]}]},remote:{version:1,targets:[{id:`remote`,cardinality:`config`,deviceTypes:[M.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`,vocabularyCap:`remote`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},"running-state":{version:1,targets:[{id:`running`,cardinality:`scalar`,deviceTypes:[M.Washer,M.Dryer,M.Dishwasher,M.Vacuum,M.LawnMower,M.MediaPlayer,M.WaterHeater,M.Humidifier,M.Fan,M.Climate,M.PetFeeder],apply:`add`,vocabularyCap:`running-state`,vocabularyStateField:`running`,sources:[{kind:`switch`,transformKinds:[`identity`],transforms:[{kind:`identity`}]},{kind:`binary`,transformKinds:[`identity`,`invert`],transforms:[{kind:`identity`},{kind:`invert`}]},{kind:`numeric`,requiredUnit:`W`,transformKinds:[`threshold`],transforms:[{kind:`threshold`,comparisons:[`gte`,`lte`],comparison:`gte`,defaultThreshold:5,defaultStartDwellMs:3e4,defaultStopDwellMs:18e4,deviceTypeDefaults:{[M.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}},thresholdUnit:`W`}]}],sourceReport:{status:`assignment-status`,runtimeField:`source`,nativeValue:`native`,assignedValue:`assigned`},advancedExpression:!0,path:`running`,valueKind:`boolean`,nullable:!0,companions:[{kind:`constant`,path:`source`,value:`assigned`,when:`always`},{kind:`constant`,path:`phase`,value:null,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`always`},{kind:`transition-time`,path:`since`,sourceChangedAt:`prefer`}]}],overridable:[{path:`running`,by:`running`}]},"weather-station":{version:1,targets:[{id:`temperature`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`temperature`,sources:[{kind:`numeric`,requiredUnit:`°C`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`temperature`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`humidity`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`humidity`,sources:[{kind:`numeric`,requiredUnit:`%`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`humidity`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`pressure`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`pressure`,sources:[{kind:`numeric`,requiredUnit:`hPa`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`pressure`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`windSpeed`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`windSpeed`,sources:[{kind:`numeric`,requiredUnit:`m/s`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`windSpeed`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`windGust`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`windGust`,sources:[{kind:`numeric`,requiredUnit:`m/s`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`windGust`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`windBearing`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`windBearing`,sources:[{kind:`numeric`,requiredUnit:`°`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`windBearing`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainRate`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainRate`,sources:[{kind:`numeric`,requiredUnit:`mm/h`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainRate`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainDaily`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainDaily`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainDaily`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainEvent`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainEvent`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainEvent`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`uv`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`uv`,sources:[{kind:`numeric`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`uv`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`solarRadiation`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`solarRadiation`,sources:[{kind:`numeric`,requiredUnit:`W/m²`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`solarRadiation`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`dewPoint`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`dewPoint`,sources:[{kind:`numeric`,requiredUnit:`°C`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`dewPoint`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`feelsLike`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`feelsLike`,sources:[{kind:`numeric`,requiredUnit:`°C`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`feelsLike`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`vpd`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`vpd`,sources:[{kind:`numeric`,requiredUnit:`kPa`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`vpd`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`windGustMax`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`windGustMax`,sources:[{kind:`numeric`,requiredUnit:`m/s`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`windGustMax`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`windBearingAvg`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`windBearingAvg`,sources:[{kind:`numeric`,requiredUnit:`°`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`windBearingAvg`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rain24h`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rain24h`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rain24h`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainWeekly`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainWeekly`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainWeekly`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainMonthly`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainMonthly`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainMonthly`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]},{id:`rainYearly`,cardinality:`scalar`,deviceTypes:[M.WeatherStation],apply:`add`,vocabularyCap:`weather-station`,vocabularyStateField:`rainYearly`,sources:[{kind:`numeric`,requiredUnit:`mm`,transformKinds:[`identity`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`},advancedExpression:!1,path:`rainYearly`,valueKind:`number`,nullable:!0,companions:[{kind:`clock`,path:`lastFetchedAt`,when:`add`}]}],overridable:[{path:`temperature`,by:`temperature`},{path:`humidity`,by:`humidity`},{path:`pressure`,by:`pressure`},{path:`windSpeed`,by:`windSpeed`},{path:`windGust`,by:`windGust`},{path:`windBearing`,by:`windBearing`},{path:`rainRate`,by:`rainRate`},{path:`rainDaily`,by:`rainDaily`},{path:`rainEvent`,by:`rainEvent`},{path:`uv`,by:`uv`},{path:`solarRadiation`,by:`solarRadiation`},{path:`dewPoint`,by:`dewPoint`},{path:`feelsLike`,by:`feelsLike`},{path:`vpd`,by:`vpd`},{path:`windGustMax`,by:`windGustMax`},{path:`windBearingAvg`,by:`windBearingAvg`},{path:`rain24h`,by:`rain24h`},{path:`rainWeekly`,by:`rainWeekly`},{path:`rainMonthly`,by:`rainMonthly`},{path:`rainYearly`,by:`rainYearly`}]}},tE={"ambient-light-sensor":{illuminance:`lx`},battery:{level:`%`,voltage:`V`,temperatureC:`°C`},"humidity-sensor":{humidity:`%`},"power-meter":{power:`W`,deliveredPower:`W`,energy:`kWh`,voltage:`V`,current:`A`},"temperature-sensor":{temperature:`°C`}};function z(e,t,n){return{code:e,path:t,message:n}}function nE(...e){return{problems:e,fields:[],features:[],events:[]}}function rE(e){let t=e.item===void 0?`fields`:`items.${e.item.key}.fields`;return`features[${e.featureIndex}].${t}.${e.path}`}var iE={kind:`fixed`,result:[`number`]},aE={kind:`fixed`,result:[`boolean`]},oE=Object.freeze({min:iE,max:iE,abs:iE,floor:iE,ceil:iE,sqrt:iE,round:iE,pow:iE,clamp:iE,avg:iE,sum:iE,age:iE,convert:iE,coalesce:{kind:`coalesce`},any:aE,all:aE,within:aE,latest:{kind:`fixed`,result:[`number`,`null`]},number:{kind:`fixed`,result:[`number`,`null`]},rose:{kind:`fixed`,result:[`number`,`null`]},count:iE,dwell:{kind:`fixed`,result:[`boolean`,`null`]},latchedAt:{kind:`fixed`,result:[`number`,`null`]},schmitt:{kind:`fixed`,result:[`boolean`,`null`]}}),sE=class extends Error{};function cE(e){return e===null?`null`:typeof e==`number`?`number`:typeof e==`string`?`string`:`boolean`}function lE(e){return new Set([e])}function uE(...e){return new Set(e.flatMap(e=>[...e]))}function C_e(e){return new Set([...e].filter(e=>e!==`null`))}function w_e(e,t,n){if(e===`+`){let e=[...t,...n];return e.every(e=>e===`string`)?lE(`string`):e.every(e=>e===`number`)?lE(`number`):new Set([`number`,`string`])}return lE(e===`-`||e===`*`||e===`/`||e===`%`?`number`:`boolean`)}function T_e(e){return e.minArgs===e.maxArgs?`exactly ${e.minArgs}`:e.maxArgs===1/0?`at least ${e.minArgs}`:`${e.minArgs}–${e.maxArgs}`}function E_e(e,t){let n=Lm[e];if(n!==void 0&&(t.length<n.minArgs||t.length>n.maxArgs))throw new sE(`${e}: wrong number of arguments (${t.length}); expected ${T_e(n)}`);let r=oE[e];if(r===void 0)throw new sE(`no result-kind rule for builtin '${e}'`);if(r.kind===`fixed`)return new Set(r.result);let i=uE(...t.map(C_e));return t.every(e=>e.has(`null`))?uE(i,lE(`null`)):i}function dE(e,t){switch(e.kind){case`literal`:return lE(cE(e.value));case`identifier`:{if(e.name===`now`)return lE(`number`);let n=t.get(e.name);if(n===void 0)throw new sE(`unbound identifier '${e.name}'`);return n}case`unary`:return lE(e.op===`!`?`boolean`:`number`);case`binary`:return w_e(e.op,dE(e.left,t),dE(e.right,t));case`logical`:return uE(dE(e.left,t),dE(e.right,t));case`conditional`:return uE(dE(e.consequent,t),dE(e.alternate,t));case`call`:return E_e(e.callee,e.args.map(e=>dE(e,t)))}}function fE(e,t){switch(e.kind){case`literal`:case`identifier`:return!1;case`unary`:return fE(e.operand,t);case`binary`:case`logical`:return fE(e.left,t)||fE(e.right,t);case`conditional`:return fE(e.test,t)||fE(e.consequent,t)||fE(e.alternate,t);case`call`:return e.callee===t||e.args.some(e=>fE(e,t))}}function pE(e,t){let n=Jm(e);return n.ok&&fE(n.parsed.ast,t)}function mE(e){let t=Jm(e.expr);if(!t.ok)return{ok:!1,error:t.error};try{return{ok:!0,kinds:dE(t.parsed.ast,e.bindingKinds)}}catch(e){if(e instanceof sE)return{ok:!1,error:e.message};throw e}}function D_e(e){return e.publish===`value`&&e.empty===`null`?{ok:!0,kinds:new Set([`number`,`null`])}:{ok:!0,kinds:new Set([`number`])}}function O_e(e){return e.publish===`value`?e.reducer===`any`||e.reducer===`all`?{ok:!0,kinds:new Set([`boolean`])}:e.empty===`null`?{ok:!0,kinds:new Set([`number`,`null`])}:{ok:!0,kinds:new Set([`number`])}:{ok:!0,kinds:new Set([`number`])}}function hE(e,t){let n=t(e.cap),r=n?.runtimeState??n?.status?.schema;if(n===null||r===void 0)return{ok:!1,code:`source-field-unknown`,message:`no capability \`${e.cap}\` with state to read`};let i=mw(r,e.fieldPath);if(i===null)return{ok:!1,code:`source-field-unknown`,message:`\`${e.cap}\` has no field \`${e.fieldPath}\``};let a=i.kind===`union`?i.unionMembers??[]:[i.kind===`enum`?`string`:i.kind];return{ok:!0,kinds:new Set(i.nullable?[...a,`null`]:a)}}function gE(e,t,n){return z(`kind-mismatch`,n,`\`${e}.${t}\` is a union — it is read as a source, never written`)}function _E(e){return e.kind===`union`?null:e.kind===`enum`?`string`:e.kind}function vE(e,t,n,r){if(e.kind!==`from`)return n;let i=r(e.cap),a=i?.runtimeState??i?.status?.schema;if(a===void 0)return n;let o=mw(a,e.fieldPath),s=_E(t);return o?.kind!==`union`||s===null||!n.has(s)?n:new Set(n.has(`null`)?[s,`null`]:[s])}function yE(e,t){if(e.kind===`from`)return hE(e,t);if(e.kind===`code`)return{ok:!1,code:`reserved-variant`,message:`code fields arrive in slice 4`};if(e.kind===`aggregate`)return O_e(e);if(e.kind===`series`)return D_e(e);let n=new Map;for(let[r,i]of Object.entries(e.bindings)){if(i.kind===`literal`){n.set(r,new Set([cE(i.value)]));continue}let e=hE(i,t);if(!e.ok)return{...e,message:`binding \`${r}\`: ${e.message}`};n.set(r,e.kinds)}let r=mE({expr:e.expr,bindingKinds:n});return r.ok?{ok:!0,kinds:r.kinds}:{ok:!1,code:`expression-invalid`,message:r.error}}function bE(e,t,n,r){let i=_E(t);if(i===null)return[gE(e,t.path,r)];let a=[...n].filter(e=>e!==`null`&&e!==i),o=[];return a.length>0&&o.push(z(`kind-mismatch`,r,`\`${e}.${t.path}\` is a ${t.kind}; this source can produce ${a.join(` or `)}`)),n.has(`null`)&&!t.nullable&&o.push(z(`may-be-null`,r,`\`${e}.${t.path}\` cannot be null and this source can produce null — wrap it in coalesce(…) or pick a non-null source`)),o}function k_e(e){if(e.kind!==`expression`)return null;let t=Jm(e.expr);if(!t.ok)return null;let n=t.parsed.ast;return n.kind===`literal`&&typeof n.value==`string`?n.value:null}function xE(e,t,n,r){if(t.kind!==`enum`||t.enumValues===void 0)return null;let i=k_e(n);if(i===null||t.enumValues.includes(i))return null;let a=t.enumValues.map(e=>`\`${e}\``).join(`, `);return z(`kind-mismatch`,r,`\`${e}.${t.path}\` accepts only ${a}; this source is the literal \`${i}\``)}function SE(e){if(e.kind!==`expression`)return`derived`;if(pE(e.expr,`count`))return`accumulator`;if(lw(e).length>0)return`derived`;let t=Jm(e.expr);return t.ok&&t.parsed.identifiers.has(`now`)?`clock`:`constant`}function CE(e,t,n,r,i){return n===`replace`&&(t===`derived`||t===`accumulator`)?{ok:!0,unavailable:`release`}:n===`new`||t!==`derived`?{ok:!0,unavailable:e.nullable?`null`:`offline`}:e.nullable?{ok:!0,unavailable:`null`}:e.enumValues?.includes(`unknown`)===!0?{ok:!0,unavailable:`unknown`}:e.required?{ok:!1,problem:z(`not-replaceable`,i,`\`${r}.${e.path}\` reads a source but can say neither null nor 'unknown', and an ADDED capability has no native reading to fall back to`)}:{ok:!0,unavailable:`omit`}}var wE={resettable:!1};function A_e(e){return new Set([e.keyField,...e.labelField===void 0?[]:[e.labelField],...Object.keys(wE)])}function j_e(e,t,n){let r=mw(e.itemSchema,t);return r===null||!r.required?!1:_w(e.itemSchema,t).every(e=>n.some(t=>t.startsWith(`${e}.`)))}function M_e({capName:e,itemArray:t,reserved:n},r,i){let a=Object.keys(r.fields);return Ih(t.itemSchema).flatMap(o=>{if(n.has(o.path)||o.path in r.fields||!j_e(t,o.path,a))return[];let s=mw(t.itemSchema,o.path);return s===null||s.nullable?[]:[z(`missing-field`,`${i}.fields.${o.path}`,`\`${e}.${t.path}[].${o.path}\` is required and has no source`)]})}function N_e(e,t){let{capName:n,itemArray:r,featureIndex:i,lookupCap:a}=e,{key:o,label:s,path:c,source:l}=t,u=`features[${i}].items.${o}.fields.${c}`;if(e.reserved.has(c))return nE(z(`item-field-reserved`,u,`\`${n}.${r.path}[].${c}\` is set by the composer itself — it takes no source`));let d=mw(r.itemSchema,c);if(d===null)return nE(z(`unknown-field`,u,`a \`${n}\` item has no field \`${c}\``));if(d.kind===`union`)return nE(gE(n,c,u));let f=yE(l,a);if(!f.ok)return nE(z(f.code,u,f.message));let p=SE(l),m=CE(d,p,e.mode,n,u);if(!m.ok)return nE(m.problem);let h={cap:n,path:c,item:{arrayPath:r.path,key:o,label:s,...t.resettable?{resettable:!0}:{}},featureIndex:i,kind:d.kind,nullable:d.nullable,required:d.required,unavailable:m.unavailable,role:p,source:l,reads:[...lw(l)]},g=xE(n,d,l,u);return{problems:[...bE(n,d,vE(l,d,f.kinds,a),u),...g===null?[]:[g]],fields:[h],features:[],events:[]}}function TE(e,t,n,r,i=`new`){let a=`features[${n}].items`,o=e.status?.itemArray;if(o===void 0)return nE(z(`not-item-array`,a,`\`${e.name}\` has no item array — it takes no \`items\``));if(o.path!==`items`)return nE(z(`not-item-array`,a,`\`${e.name}\`'s item array is at \`${o.path}\`, not \`${KC}\` — not composable yet`));let s={capName:e.name,itemArray:o,reserved:A_e(o),featureIndex:n,lookupCap:r,mode:i},c=Object.entries(t.items??{}).flatMap(([e,t])=>[{problems:M_e(s,t,`${a}.${e}`),fields:[],features:[],events:[]},...Object.entries(t.fields).map(([n,r])=>N_e(s,{key:e,label:t.label,resettable:t.reset!==void 0,path:n,source:r}))]);return{problems:c.flatMap(e=>e.problems),fields:c.flatMap(e=>e.fields),features:[],events:[]}}var EE=`deviceId`;function DE(e,t){let n=`features[${t}]`,r=Object.entries(e.commands??{}).flatMap(([e,t])=>t.kind===`forward`?[{at:`${n}.commands.${e}`,method:e,command:t}]:[]),i=Object.entries(e.items??{}).flatMap(([e,t])=>t.reset===void 0?[]:[{at:`${n}.items.${e}.reset`,method:`reset`,itemKey:e,command:t.reset}]);return[...r,...i]}function OE(e){let t=e.features.flatMap((e,t)=>e.kind===`fields`&&QC(e)?DE(e,t).map(e=>e.command.source):[]);return[...new Map(t.map(e=>[iw(e),e])).values()]}function P_e(e,t){return e.name===`switch`&&t===`toggle`}function kE(e){return Object.entries(e.methods).filter(([t,n])=>n.systemOnly!==!0&&e.composedMethods?.[t]===void 0&&!P_e(e,t)).map(([e])=>e)}function AE(){return Object.fromEntries(kE($T).map(e=>[e,{kind:`extension`,target:`remote`}]))}var jE={all:new Set,required:new Set};function ME(e,t){let n=e.methods[t]?.input;if(n===void 0)return null;let r=Nh(n);if(!(r instanceof le))return null;let i=Object.entries(r.shape).filter(([e])=>e!==EE);return{all:new Set(i.map(([e])=>e)),required:new Set(i.flatMap(([e,t])=>t instanceof ae&&!t.safeParse(void 0).success?[e]:[]))}}function NE(e){return typeof e==`object`?VC(e)?[e.$input]:Object.values(e).flatMap(NE):[]}function PE(e){return[...e].map(e=>`\`${e}\``).join(`, `)}function F_e(e,t){let{command:n,at:r}=e,i=t(n.cap);if(i===null)return{def:null,problems:[z(`command-source-unknown`,`${r}.cap`,`no capability is named \`${n.cap}\``)]};let a=i.methods[n.method];return a===void 0||a.systemOnly===!0?{def:null,problems:[z(`command-source-unknown`,`${r}.method`,`\`${n.cap}\` has no method \`${n.method}\` to forward to`)]}:a.kind===`mutation`?{def:i,problems:[]}:{def:null,problems:[z(`command-source-unknown`,`${r}.method`,`\`${n.cap}.${n.method}\` is a query — a command calls a mutation of the source`)]}}function I_e(e,t,n,r){let{at:i,command:a}=e,o=`${a.cap}.${a.method}`,s=[];if(`deviceId`in r&&s.push(z(`command-input-unknown`,`${i}.args.${EE}`,`\`${EE}\` is the source device's own — a forward never takes it as an argument`)),n!==null){for(let e of Object.keys(r).filter(e=>e!==`deviceId`&&!n.all.has(e)))s.push(z(`command-input-unknown`,`${i}.args.${e}`,`\`${o}\` has no input field \`${e}\` (it takes ${PE(n.all)})`));let e=[...n.required].filter(e=>!(e in r));e.length>0&&s.push(z(`command-input-missing`,`${i}.args`,`\`${o}\` needs ${PE(e)}, which \`args\` does not provide`))}let c=e.itemKey===void 0?t:jE;if(c!==null)for(let t of Object.values(r).flatMap(NE))c.all.has(t)||s.push(z(`command-input-unknown`,`${i}.args`,c===jE?`an item's \`reset\` takes no input — \`$input: ${t}\` has nothing to read`:`\`$input: ${t}\` is not a field of the \`${e.method}\` input (it takes ${PE(c.all)})`));return s}function L_e(e,t,n){let{at:r,command:i}=e,a=`${i.cap}.${i.method}`,o=e.itemKey===void 0?t:jE;if(o===null||n===null)return[];let s=[];for(let t of[...o.all].filter(e=>!n.all.has(e)))s.push(z(`command-input-unknown`,`${r}.args`,`\`${e.method}\` takes \`${t}\`, which \`${a}\` does not (it takes ${PE(n.all)}) — add \`args\` to map it`));let c=[...n.required].filter(e=>!o.all.has(e));return c.length>0&&s.push(z(`command-input-missing`,`${r}.args`,`\`${a}\` needs ${PE(c)}, which \`${e.method}\` does not take — add \`args\` to provide it`)),s}function FE(e,t,n){let r=F_e(t,n);if(r.def===null)return r.problems;let i=ME(e,t.method),a=ME(r.def,t.command.method),o=t.command.args;return o===void 0?L_e(t,i,a):I_e(t,i,a,o)}function IE(e,t,n){let r=new Set(kE(e));return Object.keys(t.commands??{}).flatMap(t=>{if(r.has(t))return[];let i=e.composedMethods?.[t]!==void 0;return[z(`command-method-unknown`,`${n}.commands.${t}`,i?`\`${e.name}.${t}\` is answered by the composer itself — an item's \`reset\` serves it`:`\`${e.name}\` has no method \`${t}\` to serve`)]})}function LE(e,t){return e.features.flatMap((e,n)=>e.kind!==`fields`||!QC(e)?[]:DE(e,n).flatMap(e=>{let n=iw(e.command.source),r=t.get(n),i=`${e.at}.source`;return r===void 0||r.kind===`unreadable`?[z(`source-unreadable`,i,`could not read source \`${n}\` (${r===void 0?`it was not read`:r.error}) — the save is refused rather than stored unchecked`)]:r.kind===`absent`?[z(`source-missing`,i,`source \`${n}\` does not exist`)]:r.caps.has(e.command.cap)?[]:[z(`source-capability-missing`,i,`source \`${n}\` (device ${r.deviceId}) has no \`${e.command.cap}\``)]}))}var RE={fieldPath:`lastFetchedAt`,expr:`now`},zE={fieldPath:`lastChangedAt`,expr:`now`};function BE(e){let{alsoFrom:t,...n}=e;return{...n,family:`numeric`,deviceType:M.Sensor,memberDeviceType:M.Sensor,memberDeviceTypes:[M.Sensor,...t?.deviceTypes??[]],activeWhen:void 0,commandCaps:[],baseUnit:Cc(e.quantity),aggregates:qS,accept:[{cap:e.outputCap,fieldPath:e.outputField},...t===void 0?[]:[t.accept]]}}var VE=[M.Climate];function HE(e){return{...e,family:`binary`,deviceType:M.Sensor,memberDeviceType:M.Sensor,memberDeviceTypes:[M.Sensor],activeWhen:void 0,commandCaps:[],quantity:`none`,baseUnit:void 0,aggregates:JS,empty:`offline`}}var UE=[BE({id:`temperature`,summary:`Mean, median, min, max or sum of temperatures. Offline and unknown members are left out, never read as 0 °C.`,role:P.TemperatureSensor,outputCap:`temperature-sensor`,outputField:`temperature`,quantity:`temperature`,defaultAggregate:`mean`,empty:`null`,companions:[RE],alsoFrom:{deviceTypes:VE,accept:{cap:`climate-control`,fieldPath:`currentTemp`}}}),BE({id:`humidity`,summary:`Humidity in percent. Offline and unknown members are left out, never read as 0 %.`,role:P.HumiditySensor,outputCap:`humidity-sensor`,outputField:`humidity`,quantity:`humidity`,defaultAggregate:`mean`,empty:`null`,companions:[RE],alsoFrom:{deviceTypes:VE,accept:{cap:`climate-control`,fieldPath:`currentHumidity`}}}),BE({id:`pressure`,summary:`Pressure in hectopascals. Offline and unknown members are left out, never read as 0 hPa.`,role:P.PressureSensor,outputCap:`pressure-sensor`,outputField:`pressure`,quantity:`pressure`,defaultAggregate:`mean`,empty:`null`,companions:[RE]}),BE({id:`illuminance`,summary:`Illuminance in lux. Offline and unknown members are left out, never read as 0 lx.`,role:P.AmbientLightSensor,outputCap:`ambient-light-sensor`,outputField:`illuminance`,quantity:`illuminance`,defaultAggregate:`mean`,empty:`null`,companions:[RE]}),BE({id:`power`,summary:`Power in watts, summed by default. Nobody reporting omits the key rather than writing 0 W.`,role:P.PowerSensor,outputCap:`power-meter`,outputField:`power`,quantity:`power`,defaultAggregate:`sum`,empty:`omit`,companions:[RE]}),BE({id:`energy`,summary:`Energy in kilowatt-hours, summed by default. Nobody reporting omits the key rather than writing 0 kWh.`,role:P.EnergySensor,outputCap:`power-meter`,outputField:`energy`,quantity:`energy`,defaultAggregate:`sum`,empty:`omit`,companions:[RE]}),BE({id:`battery`,summary:`Battery charge in percent. Offline and unknown members are left out, never read as 0 %.`,role:P.BatterySensor,outputCap:`battery`,outputField:`level`,quantity:`percentage`,defaultAggregate:`mean`,empty:`null`,companions:[{fieldPath:`charging`,expr:`"unknown"`},{fieldPath:`sleeping`,expr:`false`},{fieldPath:`lastUpdated`,expr:`now`}]}),BE({id:`numeric`,summary:`A numeric reading in the members’ shared quantity. Mixed quantities are refused. Nobody reporting publishes null, not 0.`,role:P.NumericSensor,outputCap:`numeric-sensor`,outputField:`value`,quantity:`device`,defaultAggregate:`mean`,empty:`null`,companions:[RE]}),HE({id:`motion`,summary:`Any or all motion. Offline and unknown members are left out, never read as off. Nobody reporting takes the device offline.`,role:P.MotionSensor,outputCap:`motion`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`}],companions:[{fieldPath:`lastDetectedAt`,expr:`null`},{fieldPath:`autoClearAfterMs`,expr:`null`}]}),HE({id:`contact`,summary:`Any or all open contacts. Offline and unknown members are left out, never read as closed.`,role:P.ContactSensor,outputCap:`contact`,outputField:`entryOpen`,defaultAggregate:`any`,accept:[{cap:`contact`,fieldPath:`entryOpen`}],companions:[zE]}),HE({id:`leak`,summary:`Any or all leak detections. Offline and unknown members are left out, never read as dry.`,role:P.LeakSensor,outputCap:`flood`,outputField:`flooded`,defaultAggregate:`any`,accept:[{cap:`flood`,fieldPath:`flooded`}],companions:[zE]}),HE({id:`smoke`,summary:`Any or all smoke detections. Offline and unknown members are left out, never read as clear.`,role:P.SmokeSensor,outputCap:`smoke`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`smoke`,fieldPath:`detected`}],companions:[zE]}),HE({id:`occupancy`,summary:`Any or all of motion or binary sensors, published as a binary. Presence zones are not aggregated. Nobody reporting is offline, not off.`,role:P.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`},{cap:`binary`,fieldPath:`on`}],companions:[zE]}),HE({id:`binary`,summary:`Any or all generic binary sensors. Offline and unknown members are left out, never read as off.`,role:P.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`binary`,fieldPath:`on`}],companions:[zE]}),WE({id:`switch`,summary:`On when at least one switch is on, or when all of them are. Offline and unknown members are left out of that decision, never read as off, and still receive the command.`,deviceType:M.Switch,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`]}),WE({id:`light`,summary:`On when at least one light is on, or when all of them are. Brightness and colour are offered only when every member has them. A command is not sent to a member that lacks it.`,deviceType:M.Light,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`brightness`,`color`]}),WE({id:`fan`,summary:`On when at least one fan is on, or when all of them are. Speed, preset, direction and oscillation are offered only when every fan has them. A command is not sent to a fan that lacks it.`,deviceType:M.Fan,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`fan-control`]}),WE({id:`cover`,summary:`Open when at least one cover is open or part-open, or only when all of them are. Position and tilt are offered only when every cover has them. A cover that reports nothing is left out, never read as closed.`,deviceType:M.Cover,outputCap:`group-active`,outputField:`active`,member:{cap:`cover`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`cover`]}),WE({id:`valve`,summary:`Open when at least one valve is open or part-open, or only when all of them are. Position is offered only when every valve has it. A valve that reports nothing is left out, never read as closed.`,deviceType:M.Valve,outputCap:`group-active`,outputField:`active`,member:{cap:`valve`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`valve`]}),WE({id:`lock`,summary:`Locked when at least one lock is locked, or only when all of them are. A jammed or moving lock is not locked. Locking is one tap; unlocking the group needs a confirmation every time, and nothing is sent without it.`,deviceType:M.Lock,outputCap:`group-active`,outputField:`active`,member:{cap:`lock-control`,fieldPath:`state`},activeWhen:[`locked`],commandCaps:[`lock-control`]}),WE({id:`media-player`,summary:`Playing when at least one player is playing, or only when all of them are. Volume is offered only when every player has it. A player that reports nothing is left out, never read as stopped.`,deviceType:M.MediaPlayer,outputCap:`group-active`,outputField:`active`,member:{cap:`media-player`,fieldPath:`state`},activeWhen:[`playing`,`buffering`],commandCaps:[`media-player`]}),WE({id:`climate`,summary:`Running when at least one thermostat or air conditioner is not off, or only when all of them are. Target temperature and fan are offered only when every device has them. A device that reports nothing is left out, never read as off.`,deviceType:M.Climate,memberDeviceTypes:[M.Climate],outputCap:`group-active`,outputField:`active`,member:{cap:`climate-control`,fieldPath:`mode`},activeWhen:[`heat`,`cool`,`auto`,`heat_cool`,`fan_only`,`dry`],commandCaps:[`climate-control`]})];function WE(e){return{id:e.id,summary:e.summary,deviceType:e.deviceType,outputCap:e.outputCap,outputField:e.outputField,commandCaps:e.commandCaps,family:`actuator`,role:void 0,memberDeviceType:e.deviceType,memberDeviceTypes:e.memberDeviceTypes??[e.deviceType],activeWhen:e.activeWhen,quantity:`none`,baseUnit:void 0,aggregates:JS,defaultAggregate:`any`,empty:`offline`,accept:[e.member],companions:[zE]}}var R_e=new Map(UE.map(e=>[e.id,e]));function GE(e){return R_e.get(e)??null}var KE={"air-quality-sensor":{co2:{kind:`gauge`,unit:`ppm`,deadband:5},voc:{kind:`gauge`,unit:`ppb`,deadband:5},pm25:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},pm10:{group:`particulates`,kind:`gauge`,unit:`µg/m³`,deadband:1},aqi:{kind:`gauge`,unit:`count`,deadband:1}},"alarm-panel":{state:{kind:`enum`,values:[`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]}},"ambient-light-sensor":{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}},battery:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`},temperatureC:{kind:`gauge`,unit:`°C`}},binary:{on:{kind:`boolean`}},brightness:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}},"carbon-monoxide":{detected:{kind:`boolean`}},"climate-control":{currentTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},target:{group:`temperature`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetHigh:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0},targetLow:{group:`target-range`,kind:`gauge`,unit:`°C`,minIntervalMs:0}},connectivity:{connected:{kind:`boolean`}},contact:{entryOpen:{kind:`boolean`}},cover:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}},"device-status":{online:{kind:`boolean`}},dishwasher:{progress:{kind:`gauge`,unit:`%`,deadband:2},state:{kind:`enum`,values:[`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]},operationState:{kind:`enum`,values:[`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]},remaining:{kind:`gauge`,unit:`s`,minIntervalMs:6e4},doorOpen:{kind:`boolean`},powerOn:{kind:`boolean`}},"do-not-disturb":{enabled:{kind:`boolean`}},"energy-system":{"solar.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Solar power`},"solar.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Solar energy`},"grid.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Grid power`},"grid.importKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid import`},"grid.exportKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid export`},"house.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`House power`},"house.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`House energy`},"heatPump.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Heat pump power`},"heatPump.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Heat pump energy`},"storage.stateOfChargePct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage charge`},"storage.storedKwh":{kind:`gauge`,unit:`kWh`,deadband:.05,displayName:`Stored energy`},"storage.capacityKwh":{kind:`gauge`,unit:`kWh`,deadband:.1,displayName:`Storage capacity`},"storage.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Storage power`},"storage.chargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage charged`},"storage.dischargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage discharged`},"storage.healthPct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage health`}},"enum-sensor":{value:{kind:`enum`,skipWhenSet:`timestamp`}},"fan-control":{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}},flood:{flooded:{kind:`boolean`}},gas:{detected:{kind:`boolean`}},"heat-pump-status":{"power.thermalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Thermal power`},"power.electricalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Electrical power`},"power.compressorPct":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Compressor`},"temperatures.supply":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Supply`},"temperatures.return":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Return`},"temperatures.outdoor":{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Outdoor`},"energy.thermalKwh":{kind:`counter`,unit:`kWh`,displayName:`Thermal energy`},"energy.electricalKwh":{kind:`counter`,unit:`kWh`,displayName:`Electrical energy`}},"heating-valve":{position:{kind:`gauge`,unit:`%`,deadband:1}},humidifier:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}},"humidity-sensor":{humidity:{kind:`gauge`,unit:`%`,deadband:.5}},"lawn-mower-control":{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}},"lock-control":{state:{kind:`enum`,values:[`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]}},"media-player":{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}},meter:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}},motion:{detected:{kind:`boolean`,excludeDeviceTypes:[M.Camera]}},"network-link":{signal:{kind:`gauge`,unit:`%`,deadband:3,minIntervalMs:6e4},rssi:{kind:`gauge`,unit:`dBm`,deadband:2,minIntervalMs:6e4}},"numeric-sensor":{value:{kind:`gauge`,minIntervalMs:3e4}},"pet-feeder":{feeding:{kind:`boolean`},eating:{kind:`boolean`},foodLevel:{kind:`gauge`},bowlFood:{kind:`gauge`},food1:{kind:`gauge`},food2:{kind:`gauge`},batteryPower:{kind:`gauge`,unit:`%`,deadband:2},desiccantLeftDays:{kind:`gauge`,unit:`s`}},"pet-fountain":{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}},"power-meter":{power:{kind:`gauge`,unit:`W`,deadband:1,minIntervalMs:3e4},energy:{kind:`counter`,unit:`kWh`,deadband:.01,minIntervalMs:6e4},voltage:{kind:`gauge`,unit:`V`,deadband:1,minIntervalMs:3e4},current:{kind:`gauge`,unit:`A`,deadband:.05,minIntervalMs:3e4},apparentPower:{kind:`gauge`,unit:`VA`,deadband:1,minIntervalMs:3e4},powerFactor:{kind:`gauge`,unit:`ratio`,deadband:.01,minIntervalMs:6e4}},"pressure-sensor":{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}},"running-state":{running:{kind:`boolean`}},smoke:{detected:{kind:`boolean`}},"stream-params":{"main.bitrate":{group:`bitrate`,kind:`gauge`,unit:`kbps`},"main.framerate":{group:`framerate`,kind:`gauge`,unit:`fps`},"sub.bitrate":{group:`bitrate`,kind:`gauge`,unit:`kbps`},"sub.framerate":{group:`framerate`,kind:`gauge`,unit:`fps`}},switch:{on:{kind:`boolean`}},tamper:{tampered:{kind:`boolean`}},"temperature-sensor":{temperature:{kind:`gauge`,unit:`°C`,deadband:.1}},"vacuum-control":{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}},valve:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}},vibration:{detected:{kind:`boolean`}},"water-heater":{currentTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.5},targetTemp:{group:`temperature`,kind:`gauge`,unit:`°C`,minIntervalMs:0}},weather:{temperature:{kind:`gauge`,unit:`°C`,deadband:.2},humidity:{kind:`gauge`,unit:`%`,deadband:1},pressure:{kind:`gauge`,unit:`hPa`,deadband:.5},windSpeed:{kind:`gauge`,unit:`m/s`,deadband:.5}},"weather-station":{temperature:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},humidity:{kind:`gauge`,unit:`%`,deadband:1},pressure:{kind:`gauge`,unit:`hPa`,deadband:.2},windSpeed:{group:`wind-speed`,kind:`gauge`,unit:`m/s`,deadband:.2},windGust:{group:`wind-speed`,kind:`gauge`,unit:`m/s`,deadband:.2},windBearing:{group:`wind-bearing`,kind:`gauge`,unit:`°`,deadband:5},rainRate:{kind:`gauge`,unit:`mm/h`,deadband:.1},rainDaily:{kind:`gauge`,unit:`mm`,deadband:.1},rainEvent:{kind:`gauge`,unit:`mm`,deadband:.1},uv:{kind:`gauge`,unit:`index`,deadband:.1},solarRadiation:{kind:`gauge`,unit:`W/m²`,deadband:5},dewPoint:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},feelsLike:{group:`temperature`,kind:`gauge`,unit:`°C`,deadband:.1},vpd:{kind:`gauge`,unit:`kPa`,deadband:.05},windGustMax:{group:`wind-speed`,kind:`gauge`,unit:`m/s`,deadband:.2},windBearingAvg:{group:`wind-bearing`,kind:`gauge`,unit:`°`,deadband:5},rain24h:{kind:`gauge`,unit:`mm`,deadband:.1},rainWeekly:{kind:`gauge`,unit:`mm`,deadband:.1},rainMonthly:{kind:`gauge`,unit:`mm`,deadband:.1},rainYearly:{kind:`gauge`,unit:`mm`,deadband:.1}},workload:{state:{kind:`enum`,values:[`running`,`paused`,`stopped`,`starting`,`stopping`,`crashed`]},"resources.cpuPercent":{kind:`gauge`,unit:`%`,deadband:2,displayName:`CPU`},"resources.memoryUsedBytes":{kind:`gauge`,unit:`bytes`,displayName:`Memory used`},"resources.memoryPercent":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Memory`},"resources.netRxKbps":{group:`network`,kind:`gauge`,unit:`kbps`,displayName:`Network received`},"resources.netTxKbps":{group:`network`,kind:`gauge`,unit:`kbps`,displayName:`Network sent`}}},z_e={consumables:{path:`items`,key:`key`,label:`label`,fields:{level:{kind:`gauge`,unit:`%`,deadband:2,displayName:`Level`},status:{kind:`enum`,displayName:`Status`,values:[`ok`,`low`,`empty`,`full`,`replace`]},"remaining.value":{kind:`gauge`,deadband:1,displayName:`Remaining`}}},"heat-pump-status":{path:`circuits`,key:`id`,label:`label`,fields:{currentTemp:{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Temperature`},targetTemp:{kind:`gauge`,unit:`°C`,minIntervalMs:0,displayName:`Setpoint`},mode:{kind:`enum`,displayName:`Mode`}}}},qE={"climate-control":{field:`currentTemp`,priority:70},"energy-system":{field:`house.powerW`,priority:50},"humidity-sensor":{field:`humidity`,priority:90},"power-meter":{field:`power`,priority:80},"temperature-sensor":{field:`temperature`,priority:100},"weather-station":{field:`temperature`,priority:60},workload:{field:`resources.cpuPercent`,priority:40}},B_e=`audio-metrics.automation-control.camera-streams.color.control.day-night.doorbell.error.event-emitter.feature-probe.group-active.group-commands.group-status.image.image-settings.intercom.ir-transmitter.low-power-sleep.motion-trigger.motion-zones.native-object-detection.navigation.notifier.power-source.presence.privacy-mask.ptz-autotrack.pump-cycle.recording-onboard.recording-signal.scene-monitor.script-runner.siren.stream-catalog.stream-signals.timed-run.update.zone-analytics.zone-rules.zones`.split(`.`);function JE(e){return KE[e]??{}}function YE(e,t,n){return XE(e.deviceTypes,t,n)}function XE(e,t,n){return e.length===0||e.some(e=>e===t)?!0:Gf(t,n)&&e.includes(M.Light)}function ZE(e){let t=e.family===`numeric`?`number`:e.activeWhen===void 0?`boolean`:`state`;return{fieldChoice:e.family===`numeric`?`first-match`:`operator`,purpose:`member`,multiple:!0,max:64,deviceTypes:[...e.memberDeviceTypes],accept:e.accept.map(e=>({...e,valueKind:t})),history:{required:!1,minRetentionMs:null},mustBindCaps:e.family===`actuator`?e.accept.map(e=>e.cap):[],exclude:[]}}function QE(e){return{fieldChoice:`operator`,purpose:`historised`,multiple:!1,max:1,deviceTypes:[],accept:$E(e),history:{required:!0,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function $E(e){let t=[];for(let n of Object.keys(KE))for(let[r,i]of Object.entries(JE(n)))i.kind!==`enum`&&(e===`integral`&&i.kind!==`gauge`||t.push({cap:n,fieldPath:r,valueKind:i.kind===`boolean`?`boolean`:`number`}));return t}function eD(e){if(e===`derivative`)return{...QE(`statistic`),accept:tD()};let t=e===`sum`||e===`expression`,n=e===`difference`||e===`ratio`?2:t?64:1;return{fieldChoice:`operator`,purpose:`reading`,multiple:t||n>1,max:n,deviceTypes:[],accept:tD(),history:{required:!1,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function tD(){return $E(`statistic`).filter(e=>e.valueKind===`number`)}var nD=[`switch`,`brightness`,`color`],V_e=[N.LightColorRgb,N.LightColorHsv,N.LightColorMired];function rD(e){return e===`all`?`all`:`any`}function H_e(e){return e===`all`?`all`:`at-least-one`}function U_e(e){return e.length===0?[]:nD.filter(t=>e.every(e=>e.includes(t)))}function iD(e){return e.length===0?[]:V_e.filter(t=>e.every(e=>e.includes(t)))}function W_e(e,t,n,r){return e.flatMap(e=>e.caps.includes(t)?[{deviceId:e.deviceId,cap:t,method:n,args:{...r}}]:[])}async function G_e(e,t){let n=[],r=0,i=async()=>{for(;;){let i=r;r+=1;let a=e[i];if(a===void 0)return;try{await t(a),n[i]={deviceId:a.deviceId,ok:!0}}catch(e){let t=e instanceof Error?e.message:String(e);n[i]={deviceId:a.deviceId,ok:!1,error:t}}}},a=Math.min(4,e.length);return await Promise.all(Array.from({length:a},()=>i())),n}var K_e={kind:`expression`,expr:`now`,bindings:{}};function aD(e,t,n){return{kind:`series`,read:{source:e.source,cap:e.cap,fieldPath:e.fieldPath},publish:t,empty:n}}function q_e(e){return{included:aD(e,`included`,`offline`),excluded:aD(e,`excluded`,`offline`),total:aD(e,`total`,`offline`)}}var J_e={second:`s`,minute:`min`,hour:`h`};function oD(e){let t=JE(e.source.cap)[e.source.fieldPath]?.unit;return t===void 0?null:`${t}/${J_e[e.per]}`}function sD(e){let t=JE(e.cap)[e.fieldPath];return t===void 0?null:t.kind}function cD(e){return sD(e)===null?[z(`member-constraint`,`helper.source`,`${e.cap}.${e.fieldPath} has no history declaration`)]:[]}function lD(e){return{target:{kind:`new`,type:M.Sensor,role:e.role},helper:e.spec,features:[{kind:`fields`,cap:e.cap,fields:{[e.field]:aD(e.member,`value`,e.empty),lastFetchedAt:K_e}},{kind:`fields`,cap:`group-status`,fields:q_e(e.member)}]}}function uD(e,t=DS){let n=[...cD(e.source)],r=sD(e.source);r===`enum`&&n.push(z(`kind-mismatch`,`helper.source`,`a statistic reads a number or a boolean, not a state`)),e.stat===`sum`&&r!==`counter`&&n.push(z(`kind-mismatch`,`helper.stat`,`a gauge has no sum — that is the integral template`));let i=US(e.window,t);return i.ok||n.push(z(`retention`,`helper.window`,i.reason)),{problems:n,draft:lD({role:P.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function dD(e,t=DS){let n=[...cD(e.source)],r=sD(e.source);(r===`enum`||r===`boolean`)&&n.push(z(`kind-mismatch`,`helper.source`,`a derivative reads a number that moves, not a yes/no or a state`));let i=US(e.window,t);return i.ok||n.push(z(`retention`,`helper.window`,i.reason)),{problems:n,draft:lD({role:P.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function fD(e,t=DS){let n=[...cD(e.source)],r=sD(e.source),i=e.source.cap===`power-meter`&&e.source.fieldPath===`power`;(r===`counter`||r===`boolean`||r===`enum`)&&n.push(z(`kind-mismatch`,`helper.source`,`an integral reads an instantaneous gauge, not a counter or a state`)),e.output===`energy`&&!i&&n.push(z(`kind-mismatch`,`helper.output`,`energy is the integral of power-meter.power; another reading uses the meter`)),e.output===`meter`&&i&&n.push(z(`kind-mismatch`,`helper.output`,`power integrates to power-meter.energy, which energy dashboards already read`));let a=WS(e.reset,t);a.ok||n.push(z(`retention`,`helper.reset`,a.reason));let o=e.output===`energy`;return{problems:n,draft:lD({role:o?P.EnergySensor:P.NumericSensor,cap:o?`power-meter`:`meter`,field:o?`energy`:`value`,empty:`offline`,spec:e,member:e.source})}}var Y_e=/^\d+(?:\.\d+)?$/,X_e=/^-?\d+(?:\.\d+)?$/,Z_e=/^dwell\(x (>=|<=) (\d+(?:\.\d+)?), (\d+(?:\.\d+)?), (\d+(?:\.\d+)?)(?:, (\d+))?\)$/,Q_e=/^clamp\((x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?)\)$/,$_e=/^(x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?)$/,eve=/^[A-Za-z_][A-Za-z0-9_]*$/;function pD(e){return CD(e,Y_e)}function mD(e){return CD(e,X_e)}function hD(e){return typeof e==`string`?JSON.stringify(e):typeof e==`number`?mD(e):typeof e==`boolean`?e?`true`:`false`:`null`}function gD(e,t){let n=t.map(e=>`native == ${JSON.stringify(e)}`).join(` || `),r=`(x ? ${JSON.stringify(e)} : native)`;return n===``?r.slice(1,-1):`${n} ? native : ${r}`}function _D(e){return eve.test(e)}function vD(e,t,n,r,i=1){return`dwell(x ${e===`gte`?`>=`:`<=`} ${t}, ${n}, ${r}${i>1?`, ${i}`:``})`}function yD(e,t,n,r,i){let a=`${e} * ${t} + ${n}`;return r===null||i===null?a:`clamp(${a}, ${r}, ${i})`}function bD(e){let t=Z_e.exec(e);if(t===null)return null;let n=Number(t[2]),r=Number(t[3]),i=Number(t[4]);if(!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i))return null;let a=t[1]===`<=`?`lte`:`gte`,o=t[5]===void 0?1:Number(t[5]);return!Number.isInteger(o)||o<1?null:{comparison:a,threshold:n,startDwellMs:r,stopDwellMs:i,minSamples:o}}function xD(e){let t=Q_e.exec(e);if(t!==null)return wD(t[1],t[2],t[3],t[4],t[5]);let n=$_e.exec(e);return n===null?null:wD(n[1],n[2],n[3],void 0,void 0)}function SD(e){if(e.kind===`from`)return{cap:e.cap,fieldPath:e.fieldPath,addonId:e.source.addonId,stableId:e.source.stableId};if(e.kind!==`expression`||Object.keys(e.bindings).length!==1)return null;let t=e.bindings.x;return t===void 0||t.kind!==`from`?null:{cap:t.cap,fieldPath:t.fieldPath,addonId:t.source.addonId,stableId:t.source.stableId}}function CD(e,t){if(!Number.isFinite(e))return null;let n=Object.is(e,-0)?`0`:String(e);return t.test(n)?n:null}function wD(e,t,n,r,i){if(e!==`x`&&e!==`number(x)`||t===void 0||n===void 0)return null;let a=Number(t),o=Number(n);if(!Number.isFinite(a)||!Number.isFinite(o))return null;if(r===void 0||i===void 0)return{inner:e,scale:a,offset:o};let s=Number(r),c=Number(i);return!Number.isFinite(s)||!Number.isFinite(c)?null:{inner:e,scale:a,offset:o,clampMin:s,clampMax:c}}var TD={kind:`expression`,expr:`now`,bindings:{}};function ED(e){return{kind:`from`,source:e.source,cap:e.cap,fieldPath:e.fieldPath}}function DD(e,t){return{kind:`expression`,expr:e,bindings:t}}function tve(e,t){return e.source.addonId===t.source.addonId&&e.source.stableId===t.source.stableId&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function OD(e,t,n=[]){return{target:{kind:`new`,type:M.Sensor,role:P.NumericSensor},helper:e,features:[{kind:`fields`,cap:`numeric-sensor`,fields:{value:t,lastFetchedAt:TD}},...n]}}function kD(e,t){return{target:{kind:`new`,type:M.Sensor,role:P.BinarySensor},helper:e,features:[{kind:`fields`,cap:`binary`,fields:{on:t,lastChangedAt:TD}}]}}function AD(e){let t=[],n=mD(e.high),r=mD(e.low);n===null&&t.push(z(`kind-mismatch`,`helper.high`,`the high edge is a finite number`)),r===null&&t.push(z(`kind-mismatch`,`helper.low`,`the low edge is a finite number`)),n!==null&&r!==null&&e.low>e.high&&t.push(z(`kind-mismatch`,`helper.low`,`the low edge (${e.low}) is above the high edge (${e.high}) — it turns on at the high edge and off at the low one`));let i=pD(e.onForMs),a=pD(e.offForMs);(i===null||a===null)&&t.push(z(`kind-mismatch`,`helper.onForMs`,`the on and off delays are a non-negative number of milliseconds`));let o=i!==null&&a!==null&&(e.onForMs>0||e.offForMs>0)?`, ${i}, ${a}`:``;return{problems:t,draft:kD(e,DD(`coalesce(schmitt(x, ${n??`0`}, ${r??`0`}${o}), false)`,{x:ED(e.source)}))}}var nve=[`a`,`b`];function rve(e){let t=[],n=e.op!==`sum`;return n&&e.inputs.length!==2&&t.push(z(`member-constraint`,`helper.inputs`,`a ${e.op} takes exactly two readings, the first ${e.op===`ratio`?`over`:`minus`} the second`)),!n&&e.inputs.length<2&&t.push(z(`member-constraint`,`helper.inputs`,`a sum takes two or more readings`)),e.inputs.forEach((n,r)=>{e.inputs.slice(0,r).some(e=>tve(e,n))&&t.push(z(`member-constraint`,`helper.inputs[${r}]`,`this reading is already an input`))}),t}var ive=[`included`,`excluded`,`total`];function jD(e){let t=rve(e);if(e.op===`sum`){let n=e.inputs.map(e=>({source:e.source,cap:e.cap,fieldPath:e.fieldPath})),r=e=>({kind:`aggregate`,reducer:`sum`,reads:n,publish:e,empty:`null`}),i=Object.fromEntries(ive.map(e=>[e,r(e)]));return{problems:t,draft:OD(e,r(`value`),[{kind:`fields`,cap:`group-status`,fields:i}])}}let n=Object.fromEntries(e.inputs.slice(0,2).map((e,t)=>[nve[t]??`a`,ED(e)]));return{problems:t,draft:OD(e,DD(e.op===`difference`?`a - b`:`b == 0 ? null : a / b`,n))}}function ave(e){let t=[],n=new Set;if(e.inputs.forEach((e,r)=>{let i=`helper.inputs[${r}].name`;_D(e.name)||t.push(z(`expression-invalid`,i,`\`${e.name}\` is not a name — use letters, digits and _, starting with a letter`)),n.has(e.name)&&t.push(z(`expression-invalid`,i,`the name \`${e.name}\` is used twice`)),n.add(e.name)}),t.length>0)return t;let r=Object.fromEntries(e.inputs.map(e=>[e.name,ED(e.member)])),i=ih({expr:e.expr,bindings:r});return i===null?[]:[z(`expression-invalid`,`helper.expr`,i)]}function MD(e){let t=ave(e),n=Object.fromEntries(e.inputs.map(e=>[e.name,ED(e.member)])),r=DD(e.expr,n);return{problems:t,draft:e.output===`boolean`?kD(e,r):OD(e,r)}}function ove(e,t){return e.addonId===t.addonId&&e.stableId===t.stableId}function sve(e,t){return ove(e.source,t.source)&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function cve(e,t){return e.accept.some(e=>e.cap===t.cap&&e.fieldPath===t.fieldPath)}function lve(e,t){return t.members.flatMap((n,r)=>{let i=`helper.members[${r}]`,a=[];if(!cve(e,n)){let t=e.accept.map(e=>`${e.cap}.${e.fieldPath}`).join(` or `);a.push(z(`member-constraint`,i,`a ${e.id} group reads ${t}; this member is ${n.cap}.${n.fieldPath}`))}return t.members.slice(0,r).some(e=>sve(e,n))&&a.push(z(`member-constraint`,i,`this member is already in the group`)),a})}function ND(e,t,n,r){return{kind:`aggregate`,reducer:t.aggregate,reads:[...n],publish:r,empty:e.empty,...e.activeWhen===void 0?{}:{activeWhen:[...e.activeWhen]}}}function uve(e,t){let n=t.members.map(e=>({source:e.source,cap:e.cap,fieldPath:e.fieldPath})),r=Object.fromEntries(e.companions.map(e=>[e.fieldPath,fve(e.expr)]));return{target:{kind:`new`,type:e.deviceType,...e.role===void 0?{}:{role:e.role}},helper:t,features:[{kind:`fields`,cap:e.outputCap,fields:{[e.outputField]:ND(e,t,n,`value`),...r}},{kind:`fields`,cap:`group-status`,fields:{included:ND(e,t,n,`included`),excluded:ND(e,t,n,`excluded`),total:ND(e,t,n,`total`)}}]}}function dve(e,t){if(e.family===`actuator`){if(t.active===void 0)return[z(`kind-mismatch`,`helper.active`,`a ${e.id} group needs an active criterion (at-least-one or all)`)];let n=rD(t.active);return t.aggregate===n?[]:[z(`kind-mismatch`,`helper.aggregate`,`active \`${t.active}\` aggregates by \`${n}\`, not \`${t.aggregate}\``)]}return t.active===void 0?[]:[z(`kind-mismatch`,`helper.active`,`a ${e.id} group has no active criterion — that belongs to an actuator group`)]}function PD(e){let t=rw.safeParse(e);return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:[z(`helper-mismatch`,`helper`,`the template did not compile: ${t.error.issues.map(e=>e.message).join(`; `)}`)]}}function fve(e,t={}){return{kind:`expression`,expr:e,bindings:t}}function FD(e,t=DS){switch(e.kind){case`group`:return mve(e);case`statistic`:{let n=uD(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:PD(n.draft)}case`integral`:{let n=fD(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:PD(n.draft)}case`derivative`:{let n=dD(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:PD(n.draft)}case`threshold`:return ID(AD(e));case`arithmetic`:return ID(jD(e));case`expression`:return ID(MD(e));case`grid`:case`crop`:case`terminal`:return PD(pve(e))}}function pve(e){return{target:{kind:`new`,type:M.Camera},helper:e,features:[]}}function ID(e){return e.problems.length>0?{ok:!1,problems:e.problems}:PD(e.draft)}function mve(e){let t=GE(e.templateId);if(t===null)return{ok:!1,problems:[z(`member-constraint`,`helper.templateId`,`unknown template \`${e.templateId}\``)]};let n=dve(t,e);if(n.length>0)return{ok:!1,problems:n};if(!t.aggregates.includes(e.aggregate)){let n=t.aggregates.join(`, `);return{ok:!1,problems:[z(`kind-mismatch`,`helper.aggregate`,`a ${t.id} group aggregates by ${n}, not \`${e.aggregate}\``)]}}let r=lve(t,e);return r.length>0?{ok:!1,problems:r}:PD(uve(t,e))}function LD(e,t){return JSON.stringify(e.target)===JSON.stringify(t.target)&&JSON.stringify(e.features)===JSON.stringify(t.features)}function hve(e){return e.kind===`group`?GE(e.templateId)?.memberDeviceType??null:null}function gve(e,t){if(e.kind!==`group`)return[];let n=GE(e.templateId);if(n===null||n.family!==`numeric`)return[];let r=e.members.flatMap((e,n)=>{let r=t.get(iw(e.source))?.quantity;return r===void 0?[]:[{index:n,quantity:r}]});if(n.quantity!==`device`)return r.flatMap(e=>e.quantity===n.quantity?[]:[z(`mixed-quantity`,`helper.members[${e.index}]`,`a ${n.id} group is ${n.quantity}${n.baseUnit===void 0?``:` (${n.baseUnit})`}; this member is ${e.quantity}`)]);let i=[...new Set(r.map(e=>e.quantity))];return i.length<=1?[]:[z(`mixed-quantity`,`helper.members`,`a numeric group requires one quantity; members report ${i.join(` and `)}`)]}function _ve(e,t){if(e.kind!==`group`)return[];let n=GE(e.templateId);return n===null?[]:e.members.flatMap((e,r)=>{let i=t.get(iw(e.source)),a=i?.deviceType;return a===void 0||XE(n.memberDeviceTypes,a,i?.role)?[]:[z(`member-constraint`,`helper.members[${r}]`,`a ${n.id} group takes ${n.memberDeviceTypes.join(` or `)} devices; this member is a ${a}`)]})}function RD(e,t){let n=e.helper;if(n===void 0)return[];let r=FD(n);return r.ok?LD(e,r.composition)?n.kind===`arithmetic`?vve(n,t):n.kind===`group`?[...gve(n,t),..._ve(n,t)]:[]:[z(`helper-mismatch`,`helper`,`the stored features are not this template — the helper spec is the only writer`)]:r.problems}function vve(e,t){let n=e.inputs.flatMap(e=>{let n=t.get(iw(e.source))?.quantity;return n===void 0?[]:[n]}),r=[...new Set(n)];return r.length<=1?[]:[z(`mixed-quantity`,`helper.inputs`,`a ${e.op} needs readings of one quantity; these inputs report ${r.join(` and `)}`)]}var zD=class extends Error{};function yve(e){return new Set(e.composition.features.flatMap(e=>!QC(e)||e.kind!==`fields`?[]:dw(e).map(({fieldPath:t})=>`${e.cap}.${t}`)))}function bve(e,t,n){if(iw(n.source)!==iw(e.target))return!0;let r=`${n.cap}.${n.fieldPath}`;return t.has(r)&&e.replaced?.has(r)!==!0}function xve(e){let t=yve(e);return e.composition.features.flatMap(n=>!QC(n)||n.kind!==`fields`?[]:dw(n).map(({fieldPath:r,source:i})=>[ow({source:e.target,cap:n.cap,fieldPath:r}),lw(i).filter(n=>bve(e,t,n)).map(ow)]))}function Sve(e,t){let n=iw(e.target),r=new Map;for(let i of t){if(i.blockId===e.blockId)continue;let t=iw(i.target);if(t===n)throw new zD(`block \`${i.blockId}\` and block \`${e.blockId}\` both target device \`${t}\` — one composition per device; delete or edit the existing one`);let a=r.get(t);if(a!==void 0)throw new zD(`two stored compositions (\`${a.blockId}\`, \`${i.blockId}\`) both target device \`${t}\` — refusing to build the field graph`);r.set(t,i)}return[...r.values(),e]}function BD(e,t){let n=Sve(e,t).flatMap(xve);return new Map(n)}function Cve(e,t){let n=BD(e,t),r=new Map,i=new Map,a=(e,t)=>{let o=r.get(e);if(o!==`done`){if(o===`visiting`){let n=[...t.slice(t.indexOf(e)),e],r=[...new Set(n)].toSorted().join(`|`);i.has(r)||i.set(r,{path:n});return}r.set(e,`visiting`);for(let r of n.get(e)??[])a(r,[...t,e]);r.set(e,`done`)}};for(let e of n.keys())a(e,[]);return[...i.values()]}function wve(e){let t=new Map,n=new Map,r=new Set,i=[],a=[],o=s=>{t.set(s,t.size),n.set(s,t.get(s)??0),i.push(s),r.add(s);for(let i of e.get(s)??[])t.has(i)?r.has(i)&&n.set(s,Math.min(n.get(s)??0,t.get(i)??0)):(o(i),n.set(s,Math.min(n.get(s)??0,n.get(i)??0)));if(n.get(s)!==t.get(s))return;let c=[];for(let e=i.pop();e!==void 0&&(r.delete(e),c.push(e),e!==s);e=i.pop());a.push(c)};for(let n of e.keys())t.has(n)||o(n);return a}function Tve(e,t,n){let r=new Map,i=[e];for(let a=0;a<i.length;a+=1){let o=i[a];if(o===void 0)break;for(let a of n.get(o)??[]){if(a===e){let t=[];for(let n=o;n!==void 0&&n!==e;n=r.get(n))t.push(n);return[e,...t.reverse(),e]}!t.has(a)||r.has(a)||(r.set(a,o),i.push(a))}}return[e,e]}function VD(e,t){let n=BD(e,t),r=`${iw(e.target)}#`;return wve(n).flatMap(e=>{let t=e.find(e=>e.startsWith(r));if(t===void 0)return[];let i=new Set(e),a=e.length===1&&(n.get(t)??[]).includes(t);return e.length===1&&!a?[]:[{path:Tve(t,i,n),component:i}]})}var HD=S([`no-power-source`,`switch-missing`,`switch-offline`,`switch-unknown`,`restart-in-progress`,`switch-call-failed`,`switch-options-unreadable`,`not-settable`,`switch-is-actuator`,`link-lost`,`link-unknown`]),UD=a(`accepted`,[x({accepted:m(!0)}),x({accepted:m(!1),reason:HD,message:u()})]),WD=x({linked:y(),switchDeviceId:r().nullable(),switchName:u().nullable(),switchOn:y().nullable(),switchOnline:y().nullable(),switchSettable:y().nullable().optional(),restartInProgress:y(),offSeconds:r().int()}),GD=x({switchOn:y().nullable(),offSeconds:r().int(),lastFetchedAt:r()}),KD=[M.Gateway,M.Camera,M.Sensor,M.MediaPlayer,M.Vacuum,M.Generic,M.Washer,M.Dryer,M.Dishwasher,M.PetFountain,M.Fan,M.Humidifier,M.Climate,M.WaterHeater],Eve={version:1,targets:[{id:`switch`,cardinality:`scalar`,vocabulary:{cap:`power-source`,stateField:`switchOn`},deviceTypes:KD,apply:`add`,path:`switchOn`,sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],companions:[{kind:`constant`,path:`offSeconds`,value:10,when:`add`,formerValues:[0]},{kind:`clock`,path:`lastFetchedAt`,when:`always`}],sourceReport:{status:`assignment-status`}}]},qD=x({deviceId:r().int().nonnegative()}),JD={method:`getStatus`,field:`switchSettable`},YD={name:`power-source`,scope:`device`,mode:`singleton`,deviceTypes:KD,methods:{getStatus:Ti(qD,WD,{auth:`protected`}),powerOn:Ti(qD,UD,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.on`,label:L(`Power on`,`Dai corrente`),phrase:L(`Power on {device}`,`Dai corrente a {device}`),icon:`power`,offeredWhen:JD}]}),powerOff:Ti(qD,UD,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.off`,label:L(`Power off`,`Togli corrente`),phrase:L(`Cut the power of {device}`,`Togli la corrente a {device}`),icon:`power-off`,offeredWhen:JD}]}),forceRestart:Ti(qD,UD,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.forceRestart`,label:L(`Force restart`,`Riavvio forzato`),phrase:L(`Force restart {device} by cutting its power`,`Riavvia {device} togliendo la corrente`),icon:`refresh-cw`}]})},runtimeState:GD,customize:Eve,durability:`session`,history:`none`,vocabulary:{noun:L(`Power source`,`Alimentazione`),order:1050,state:[{kind:`boolean`,field:`switchOn`,label:L(`Power switch on`,`Presa accesa`),whenTrue:L(`When the power of {device} comes on`,`Quando arriva la corrente a {device}`),whenFalse:L(`When the power of {device} is cut`,`Quando manca la corrente a {device}`),icon:`power`}]}};function XD(e){return typeof e!=`number`||!Number.isFinite(e)?10:Math.min(120,Math.max(3,Math.round(e)))}function Dve(e){let t=e.features.find(e=>e.cap===`power-source`);if(t===void 0||t.kind!==`fields`)return;let n=t.fields.offSeconds;if(n===void 0||n.kind!==`expression`)return;let r=Number(n.expr);return n.expr.trim()===``||!Number.isFinite(r)?void 0:r}function Ove(e,t){if(e===null)return null;let n;if(e.target.kind===`existing`)n=e.target.device;else if(t!==void 0)n=cw(t);else return null;let r=e.features.find(e=>e.cap===`power-source`);if(r===void 0||r.kind!==`fields`||r.enabled===!1)return null;let i=r.fields.switchOn;if(i===void 0)return null;let a=lw(i).find(e=>e.cap===`switch`);return a===void 0?null:{device:n,switch:a.source,offSeconds:XD(Dve(e)),...r.contributedBy===void 0?{}:{contributedBy:r.contributedBy}}}var ZD=`switch`;function kve(e){let t=new Set;return e.target.kind===`existing`&&t.add(iw(e.target.device)),e.features.forEach((e,n)=>{if(!(e.kind!==`fields`||e.cap!==ZD)&&QC(e)){for(let n of fw(e))for(let e of lw(n))t.add(iw(e.source));for(let r of DE(e,n))t.add(iw(r.command.source))}}),t}function QD(e){let t=e.features.findIndex(e=>e.cap===`power-source`),n=e.features[t];if(n===void 0||n.kind!==`fields`||n.enabled===!1)return[];let r=n.fields.switchOn;if(r===void 0)return[];let i=kve(e);return lw(r).filter(e=>e.cap===ZD&&i.has(iw(e.source))).map(e=>({path:`features[${t}].fields.switchOn`,switch:e.source}))}function $D(e){let t=new Map(e.map(e=>[e.name,e]));return e=>t.get(e)??null}var eO=new Set([`device-status`,`feature-probe`]),Ave={addonId:DC,stableId:`${EC}(unsaved)`},jve=`(unsaved)`;function Mve(e,t,n){let r=n(e.cap);if(r===null)return z(`unknown-capability`,`${t}.cap`,`no capability is named \`${e.cap}\``);if(eO.has(r.name))return z(`not-composable`,`${t}.cap`,`\`${r.name}\` is registered by every device itself — it cannot be composed`);let i=r.runtimeState;return r.scope!==`device`||i===void 0?z(`not-composable`,`${t}.cap`,`\`${r.name}\` has no per-device state to compose`):{def:r,state:i,fields:hw(i)}}function Nve(e){let t=e.helper;if(t===void 0||t.kind!==`group`)return new Set;let n=GE(t.templateId);return n===null||n.family!==`actuator`?new Set:new Set(n.commandCaps)}function Pve(e,t){return e.name===$T.name&&Object.values(t.commands??{}).some(e=>e.kind===`extension`)}function Fve({def:e,state:t,fields:n},r,i,a,o){let s=[];e.deviceTypes!==void 0&&!e.deviceTypes.includes(a)&&s.push(z(`wrong-device-type`,`${i}.cap`,`\`${e.name}\` is not offered on a \`${a}\` device (it allows ${e.deviceTypes.join(`, `)})`));let c=new Set(Object.entries(r.commands??{}).flatMap(([e,t])=>t.kind===`forward`||t.kind===`extension`?[e]:[])),l=kE(e).filter(e=>!c.has(e)).map(e=>`\`${e}\``);l.length>0&&!o.has(e.name)&&s.push(z(`has-commands`,`${i}.cap`,`\`${e.name}\` has ${l.join(`, `)} with no command — a composed device serves a method only through a \`forward\` (D967)`));let u=r.items===void 0?null:e.status?.itemArray?.path??null,d=Pve(e,r);for(let a of d?[]:gw(t))a!==u&&(n.has(a)?a in r.fields||s.push(z(`missing-field`,`${i}.fields.${a}`,`\`${e.name}.${a}\` is required and has no source`)):s.push(z(`not-composable`,`${i}.fields`,`\`${e.name}.${a}\` is not a scalar — nested fields arrive in a later slice`)));return s}function Ive({fields:e,state:t},n,r){return n.includes(`.`)?r===`replace`?mw(t,n)??void 0:`nested`:e.get(n)}function Lve(e,t,n,r){let{def:i}=e,{featureIndex:a,path:o,source:s}=t,c=`features[${a}].fields.${o}`,l=Ive(e,o,n);if(l===`nested`)return nE(z(`nested-field`,c,`\`${o}\` is nested — a nested field is planned only on a declared replace (D1034)`));if(l===void 0)return nE(z(`unknown-field`,c,`\`${i.name}\` has no field \`${o}\``));if(l.kind===`union`)return nE(gE(i.name,o,c));let u=yE(s,r);if(!u.ok)return nE(z(u.code,c,u.message));let d=SE(s),f=CE(l,d,n,i.name,c);if(!f.ok)return nE(f.problem);let p=s.kind===`aggregate`&&s.publish===`value`&&s.empty===`omit`,m={cap:i.name,path:o,featureIndex:a,kind:l.kind,nullable:l.nullable,required:l.required,unavailable:p?`omit`:f.unavailable,role:d,source:s,reads:[...lw(s)]},h=xE(i.name,l,s,c);return{problems:[...bE(i.name,l,vE(s,l,u.kinds,r),c),...h===null?[]:[h]],fields:[m],features:[],events:[]}}function Rve(e,t,n,r,i){let a=`features[${n}]`,o=DE(t,n),s=Object.entries(t.commands??{}).filter(([,e])=>e.kind===`code`).map(([e])=>z(`reserved-variant`,`${a}.commands.${e}`,"a `code` command arrives in slice 4")),c=Object.entries(t.commands??{}).filter(([,e])=>e.kind===`extension`);return c.length>0&&e.name!==$T.name?[...s,...c.map(([t])=>z(`command-method-unknown`,`${a}.commands.${t}`,`the \`remote\` extension serves a \`media-player\` only, not \`${e.name}\``))]:(o.length>0||c.length>0)&&r!==`new`?[...s,z(`reserved-variant`,`${a}.commands`,"commands (`forward`) are served only by a capability a NEW device builds — not on an existing device")]:[...s,...IE(e,t,a),...o.flatMap(t=>FE(e,t,i))]}function tO(e,t,n,r,i){let a=`features[${t}]`,o=Mve(e,a,r);if(`code`in o)return nE(o);let s=n.mode===`replace`?[]:[...Fve(o,e,a,n.deviceType,i)];s.push(...Rve(o.def,e,t,n.mode,r));let c=Object.entries(e.fields).map(([e,i])=>Lve(o,{featureIndex:t,path:e,source:i},n.mode,r)),l=e.items===void 0?[]:[TE(o.def,e,t,r,n.mode)],u=[...c,...l],d=u.flatMap(e=>e.fields),f={featureIndex:t,cap:o.def.name,mode:n.mode},p=xw(o.def,f,d);return{problems:[...s,...u.flatMap(e=>e.problems),...p.problems],fields:d,features:[f],events:p.events}}function nO(e,t){let n=e.nativeCaps.get(t);return n!==void 0&&n!==`composer`}function zve(e){return`code`in e}function Bve(e,t){if(e.target.kind===`new`)return{kind:`new`,type:e.target.type};let n=iw(e.target.device);return t===void 0?z(`target-unreadable`,`target`,`target device \`${n}\` was not read — the save is refused rather than stored unchecked`):t.kind===`absent`?z(`target-missing`,`target`,`target device \`${n}\` does not exist`):t.kind===`unreadable`?z(`target-unreadable`,`target`,`could not read target device \`${n}\` (${t.error}) — the save is refused rather than stored unchecked`):{kind:`existing`,found:t}}var Vve=new Set([`not-composable`,`unknown-capability`,`reserved-variant`]);function Hve(e,t){let n=t.problems.filter(e=>Vve.has(e.code));return n.length>0?{problems:n,fields:[],features:[],events:[]}:nE(e)}var Uve=eE;function Wve(e){let t=Uve[e.cap],n=new Set((t?.overridable??[]).flatMap(e=>{let n=(t?.targets.find(t=>t.id===e.by&&t.path===e.path)?.companions??[]).filter(e=>e.kind===`transition-time`||e.kind===`source-field`||e.when===`always`);return[e.path,...n.map(e=>e.path)]})),r=Object.keys(e.fields);return r.length>0&&r.every(e=>n.has(e))&&e.items===void 0&&e.commands===void 0}function Gve(e,t,n){let r=t.cap;return e.kind===`new`?{mode:`new`,deviceType:e.type}:nO(e.found,r)?Wve(t)?{mode:`replace`,deviceType:e.found.type}:z(`native-capability-replace`,n,`native-capability-replace: stored override replaces native capability \`${r}\` on device ${e.found.deviceId} — refused (D944)`):{mode:`add`,deviceType:e.found.type}}function rO(e,t,n){let r=Bve(e,n);if(`code`in r)return nE(r);let i=Nve(e),a=e.features.map((e,n)=>{let a=`features[${n}]`;if(e.kind===`passthrough`)return nE(z(`reserved-variant`,a,`whole-capability passthrough of \`${e.cap}\` arrives in slice 3`));let o=Gve(r,e,a);if(zve(o))return!QC(e)||r.kind!==`existing`?{problems:[],fields:[],features:[],events:[]}:Hve(o,tO(e,n,{mode:`add`,deviceType:r.found.type},t,i));let s=tO(e,n,o,t,i);return QC(e)?s:{problems:Object.keys(e.fields).length===0?s.problems.filter(e=>e.code!==`missing-field`):s.problems,fields:[],features:[],events:[]}});return{problems:a.flatMap(e=>e.problems),fields:a.flatMap(e=>e.fields),features:a.flatMap(e=>e.features),events:a.flatMap(e=>e.events)}}function Kve(e){let t=e.features.flatMap(e=>QC(e)&&e.kind===`fields`?fw(e).flatMap(lw).map(e=>e.source):[]);return[...new Map([...t,...OE(e)].map(e=>[iw(e),e])).values()]}function qve(e,t){return e.features.flatMap(e=>QC(e)&&e.kind===`fields`?fw(e).flatMap(e=>{if(e.kind!==`from`)return[];let n=t(e.cap),r=n?.runtimeState??n?.status?.schema;return r===void 0?[]:mw(r,e.fieldPath)?.kind===`union`?[e]:[]}):[])}function Jve(e,t,n){return{ref:e.target.kind===`existing`?e.target.device:t.self??Ave,native:e.target.kind===`existing`&&t.target?.kind===`found`?t.target:null,replaced:iO(n)}}function iO(e){let t=new Set(e.features.filter(e=>e.mode===`replace`).map(e=>e.featureIndex));return new Set(e.fields.filter(e=>t.has(e.featureIndex)).map(kw))}function Yve(e,t,n,r){let i=`${e.cap}.${e.fieldPath}`;return n.some(e=>kw(e)===i&&!r.replaced.has(i))?[]:r.native===null?[z(`source-field-unknown`,t,`this device has no composed field \`${e.cap}.${e.fieldPath}\``)]:nO(r.native,e.cap)?[]:[z(`source-capability-missing`,t,`the target device (device ${r.native.deviceId}) has no native \`${e.cap}\``)]}function Xve(e,t,n,r){if(e.source.kind!==`from`)return[];let i=n.liveKinds?.get(`${t.cap}.${t.fieldPath}`),a=e.kind===`enum`?`string`:e.kind;return i===void 0||i===a?[]:[z(`source-kind-mismatch`,r,`\`${t.cap}.${t.fieldPath}\` of device ${n.deviceId} reads a ${i} now; \`${e.cap}.${e.path}\` takes a ${a}`)]}function Zve(e,t,n){let r=iw(n.ref);return e.flatMap(i=>i.reads.flatMap(a=>{let o=rE(i),s=iw(a.source);if(s===r)return Yve(a,o,e,n);let c=t.sources.get(s);return c===void 0||c.kind===`unreadable`?[z(`source-unreadable`,o,`could not read source \`${s}\` (${c===void 0?`it was not read`:c.error}) — the save is refused rather than stored unchecked`)]:c.kind===`absent`?[z(`source-missing`,o,`source \`${s}\` does not exist`)]:c.caps.has(a.cap)?Xve(i,a,c,o):[z(`source-capability-missing`,o,`source \`${s}\` (device ${c.deviceId}) has no \`${a.cap}\``)]}))}function Qve(e,t){let n=`${t}#`;if(!e.startsWith(n))return null;let r=e.slice(n.length),i=r.indexOf(`.`);return i===-1?null:{cap:r.slice(0,i),fieldPath:r.slice(i+1)}}function $ve(e,t,n){for(let r of e){let e=Qve(r,t);if(e===null)continue;let i=`${e.cap}.${e.fieldPath}`,a=n.find(e=>kw(e)===i);if(a!==void 0)return rE(a)}return`features`}function eye(e,t){for(let[n,r]of t)if(e.some(e=>e.startsWith(`${n}#`)))return{key:n,error:r};return null}function tye(e,t,n,r){let i={blockId:t.blockId??`(unsaved)`,target:r.ref,composition:e,replaced:r.replaced},a=iw(i.target),o=t.unreadTargets??new Map;try{return VD(i,t.peers).map(e=>{let t=$ve(e.path,a,n),r=eye([...e.component],o);return r===null?z(`cycle`,t,`a field reads itself: ${e.path.join(` → `)}`):z(`cycle`,t,`possible cycle through \`${r.key}\` — its state could not be read (${r.error}): ${e.path.join(` → `)}`)})}catch(e){if(e instanceof zD)return[z(`duplicate-target`,`features`,e.message)];throw e}}function aO(e,t){let n=rO(e,t.lookupCap,t.target??void 0),r=Jve(e,t,n),i=n.problems.filter(e=>e.code===`native-capability-replace`).map(e=>e.path),a=tye(e,t,n.fields,r).filter(e=>i.some(t=>e.path===t||e.path.startsWith(`${t}.`))?!1:i.length===0||e.path!==`features`),o=new Map([...t.sources].flatMap(([e,t])=>t.kind===`found`?[[e,{deviceType:t.deviceType,role:t.role,quantity:t.quantity}]]:[])),s=[...n.problems,...Zve(n.fields,t,r),...LE(e,t.sources),...a,...RD(e,o),...QD(e).map(e=>z(`power-source-is-actuator`,e.path,`the power source \`${e.switch.stableId}\` is one of this device's own switches — pick the plug that feeds it`))];return{ok:s.length===0,problems:s,fields:[...n.fields],features:[...n.features],events:[...n.events]}}var oO=x({path:u(),kind:ww,nullable:y(),required:y(),enumValues:C(u()).optional()}),sO=x({cap:u(),fields:C(oO),itemArray:x({path:u(),keyField:u()}).optional()}),cO=x({caps:C(sO)});function lO(e,t){if(eO.has(e.name))return[`not-composable`];let n=e.runtimeState;if(e.scope!==`device`||n===void 0)return[`not-composable`];let r=[];e.deviceTypes!==void 0&&!e.deviceTypes.includes(t)&&r.push(`wrong-device-type`),Object.entries(e.methods).filter(([t,n])=>n.systemOnly!==!0&&e.composedMethods?.[t]===void 0).length>0&&r.push(`has-commands`);let i=hw(n),a=e.status?.itemArray?.path??null;return gw(n).some(e=>e!==a&&!i.has(e))&&r.push(`not-composable`),xw(e,{featureIndex:0,cap:e.name,mode:`new`},[]).problems.some(e=>e.code===`not-composable`)&&!r.includes(`not-composable`)&&r.push(`not-composable`),r}function nye(e,t){return e.filter(e=>lO(e,t).length===0).map(e=>{let t=e.runtimeState,n=t===void 0?[]:[...hw(t).values()],r=e.status?.itemArray;return{cap:e.name,fields:n.flatMap(e=>e.kind===`union`?[]:[{path:e.path,kind:e.kind,nullable:e.nullable,required:e.required,...e.enumValues===void 0?{}:{enumValues:[...e.enumValues]}}]),...r===void 0?{}:{itemArray:{path:r.path,keyField:r.keyField}}}}).toSorted((e,t)=>e.cap.localeCompare(t.cap))}var uO=x({addonId:u().min(1),stableId:u().min(1),cap:u().min(1),fieldPath:u().min(1)}),rye=x({kind:m(`identity`)}),iye=x({kind:m(`invert`)}),dO=x({kind:m(`threshold`),comparison:S([`gte`,`lte`]),threshold:r(),startDwellMs:r().nonnegative(),stopDwellMs:r().nonnegative(),minSamples:r().int().min(1).optional()}),fO=a(`kind`,[rye,iye,dO,x({kind:m(`linear`),scale:r(),offset:r(),clampMin:r().optional(),clampMax:r().optional()}),x({kind:m(`enum-map`),mapping:h(u(),u().nullable())}),x({kind:m(`number`)})]),aye=x({kind:m(`scalar`),cap:u().min(1),targetId:u().min(1),source:uO,transform:fO}),oye=x({kind:m(`keyedArray`),cap:u().min(1),targetId:u().min(1),key:u().min(1),label:u().min(1),fieldPath:u().min(1),source:uO,transform:fO}),sye=x({kind:m(`pulse`),cap:u().min(1),targetId:u().min(1),enabled:y(),debounceMs:r().nonnegative(),edges:C(S([`rising`,`button`,`native-event`])).min(1).optional(),sources:C(uO).min(1)}),cye=uO.extend({mode:S([`in-addition`,`confirm`,`replace`]).optional()}),lye=a(`kind`,[aye,oye,sye,x({kind:m(`span`),cap:u().min(1),targetId:u().min(1),timeoutMs:r().nonnegative(),cooldownMs:r().nonnegative().optional(),sources:C(cye)})]),uye=x({targetId:u().min(1),configured:y(),source:S([`native`,`assigned`]),state:S([`active`,`stale`,`released`,`unavailable`]),reason:u().nullable()}),pO=S([`raw`,`5m`]),mO=S([`high`,`medium`,`low`]),hO=S([`no-history`,`span-too-short`,`truncated`,`no-idle-floor`,`no-runs`,`no-separation`]),gO=x({intervals:r().int().nonnegative(),extra:r().int().nonnegative(),missed:r().int().nonnegative()}),_O=x({tier:pO,spanMs:r().nonnegative(),from:r(),to:r(),points:r().int().nonnegative(),runsFound:r().int().nonnegative(),pausesFound:r().int().nonnegative(),longestPauseMs:r().nonnegative(),pulsesFound:r().int().nonnegative(),longestPulseMs:r().nonnegative(),idleFloorW:r(),noiseCeilingW:r(),plateauW:r(),replay:gO}),vO=x({spanMs:r().nonnegative(),points:r().int().nonnegative(),runsFound:r().int().nonnegative()}),yO=a(`state`,[x({state:m(`proposal`),transform:dO,evidence:_O,confidence:mO,notes:C(u())}),x({state:m(`insufficient`),reason:hO,evidence:vO,fallback:dO})]),bO=x({apply:y()}),xO=x({apply:y(),rows:r().int(),raw:r().int(),markers:r().int(),migrated:r().int(),failed:r().int(),remainingRaw:r().int(),unresolvedMarkers:r().int(),redundantCopies:r().int().optional(),verified:y()}),SO=`core-block-`,CO=`core-blocks`;function wO(e){return`${SO}${e}`}function dye(e){if(!e.startsWith(`core-block-`))return null;let t=e.slice(11);return t.length>0?t:null}var TO=g([m(`hub`),u().min(1)]),EO=S([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),DO=`main.ts`,OO=h(u().min(1).max(260),u().max(2e5)),kO=ye(),AO=x({name:u().min(1).max(120),code:u().max(2e5).optional(),files:OO.optional(),entry:u().min(1).max(260).optional(),enabled:y(),placement:TO,integrationId:u().optional(),settingsSchema:kO.optional(),tags:Td.optional()}),jO=AO.superRefine((e,t)=>{let n=e.entry??`main.ts`;if(e.files!==void 0){e.files[n]===void 0&&t.addIssue({code:`custom`,message:`files must include the entry "${n}"`,path:[`files`]});return}e.code===void 0&&t.addIssue({code:`custom`,message:`code or files is required`,path:[`code`]})});function MO(e){return e!==void 0&&e.length>0?e:DO}function NO(e){let t=MO(e.entry);return e.files===void 0?{files:{[t]:e.code},entry:t}:{files:{...e.files},entry:t}}function fye(e){if(e.files!==void 0){let t=MO(e.entry);return{code:e.files[t]??e.code??``,files:{...e.files},entry:t}}return{code:e.code??``,...e.entry===void 0?{}:{entry:e.entry}}}var PO=a(`kind`,[x({kind:m(`code`)}),x({kind:m(`recipe`),recipe:C_}),x({kind:m(`composition`),composition:rw})]),FO=x({name:u().min(1).max(120).optional(),enabled:y(),composition:rw}),IO=x({name:u().min(1).max(120),code:u().max(2e5),files:OO.optional(),entry:u().min(1).max(260).optional(),enabled:y(),placement:TO,integrationId:u().optional(),settingsSchema:kO.optional(),tags:Td.optional(),id:u(),createdAt:r(),updatedAt:r(),createdBy:u(),status:EO,lastError:u().optional(),lastChangedAt:r(),source:PO.optional()});function LO(e){return e.source?.kind??`code`}function RO(e){return e.source?.kind===`composition`?e.source.composition:null}var zO=a(`kind`,[x({kind:m(`answered`),state:Iw.nullable()}),x({kind:m(`unreachable`),error:u()})]),BO=x({block:IO,state:zO}),VO=x({state:m(`not-loaded`),reason:u()}),HO=a(`state`,[x({state:m(`loaded`),views:C(BO)}),VO]),UO=a(`state`,[x({state:m(`loaded`),view:BO.nullable()}),VO]),WO=a(`state`,[x({state:m(`loaded`),view:BO.nullable()}),VO]),GO=x({ok:y(),error:u().optional(),line:r().optional(),column:r().optional()}),KO=x({code:u().optional(),files:OO.optional(),entry:u().min(1).max(260).optional()}).superRefine((e,t)=>{if(e.files!==void 0){let n=e.entry??`main.ts`;e.files[n]===void 0&&t.addIssue({code:`custom`,message:`files must include the entry "${n}"`,path:[`files`]});return}e.code===void 0&&t.addIssue({code:`custom`,message:`code or files is required`,path:[`code`]})}),qO={name:`core-blocks`,scope:`system`,mode:`singleton`,methods:{list:D(x({}),x({blocks:C(IO)}),{auth:`admin`}),get:D(x({blockId:u()}),x({block:IO.nullable()}),{auth:`admin`}),create:D(x({block:jO}),x({block:IO}),{kind:`mutation`,auth:`admin`,caller:`required`}),update:D(x({blockId:u(),block:AO.partial()}),x({block:IO}),{kind:`mutation`,auth:`admin`,caller:`required`}),delete:D(x({blockId:u()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setEnabled:D(x({blockId:u(),enabled:y()}),x({block:IO}),{kind:`mutation`,auth:`admin`}),restart:D(x({blockId:u()}),x({block:IO}),{kind:`mutation`,auth:`admin`}),compile:D(KO,GO,{kind:`mutation`,auth:`admin`}),getBlockSettings:D(x({blockId:u()}),iy.nullable(),{auth:`admin`}),updateBlockSettings:D(x({blockId:u(),patch:ay}),sy,{kind:`mutation`,auth:`admin`}),migrateRawSecrets:D(bO,xO,{kind:`mutation`,auth:`admin`}),getTypeDefs:D(x({}),x({libs:C(x({filePath:u(),content:u()}))}),{auth:`admin`}),createComposition:D(x({block:FO}),x({block:IO}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateComposition:D(x({blockId:u(),expectedUpdatedAt:r(),block:FO.partial()}),x({block:IO}),{kind:`mutation`,auth:`admin`,caller:`required`}),getComposition:D(x({blockId:u()}),UO,{auth:`admin`}),listCompositions:D(x({}),HO,{auth:`admin`}),getCustomization:D(x({addonId:u().min(1),stableId:u().min(1)}),WO,{auth:`admin`}),listComposableCaps:D(x({deviceType:S(M)}),cO,{auth:`admin`}),validateComposition:D(x({composition:rw,blockId:u().optional()}),Mw,{kind:`mutation`,auth:`admin`,access:`view`}),proposeRunningThreshold:D(x({deviceId:r().int(),cap:u().min(1),fieldPath:u().min(1),deviceType:S(M).optional()}),yO,{auth:`admin`,access:`view`}),reportAutomationRun:D(x({blockId:u().min(1),trace:V_.optional(),runStartedAt:r().optional(),keepTraces:r().int().min(1).max(100).optional()}),v(),{kind:`mutation`,auth:`admin`}),getAutomationRunState:D(x({blockId:u().min(1)}),Tde,{auth:`admin`}),getTraces:D(x({blockId:u().min(1)}),x({traces:C(V_),lastError:u().nullable()}),{auth:`admin`})},vocabulary:{notOperatorFacing:k.INTERNAL}},JO=S([`open`,`opening`,`closing`,`closed`,`stopped`]),YO=x({state:JO,position:r().min(0).max(100).nullable().meta(A(`percentage`)),tiltPosition:r().min(0).max(100).nullable().meta(A(`percentage`)),lastChangedAt:r()}),XO={name:`cover`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Cover],methods:{open:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.open`,label:L(`Open`,`Apri`),phrase:L(`Open {device}`,`Apri {device}`),icon:`arrow-up-to-line`,effect:{field:`state`,value:`open`}}]}),close:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.close`,label:L(`Close`,`Chiudi`),phrase:L(`Close {device}`,`Chiudi {device}`),icon:`arrow-down-to-line`,effect:{field:`state`,value:`closed`}}]}),stop:O(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.stop`,label:L(`Stop`,`Ferma`),phrase:L(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setPosition:O(x({deviceId:r().int().nonnegative(),position:r().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.position`,label:L(`Set position`,`Imposta la posizione`),phrase:L(`Move {device} to {position} open`,`Porta {device} al {position} di apertura`),icon:`blinds`,effect:{field:`position`,fromArg:`position`},openArgs:[{key:`position`,label:L(`Position`,`Posizione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setTiltPosition:O(x({deviceId:r().int().nonnegative(),tiltPosition:r().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.tilt`,label:L(`Set tilt`,`Imposta l’inclinazione`),phrase:L(`Tilt {device} to {tiltPosition}`,`Inclina {device} al {tiltPosition}`),icon:`blinds`,effect:{field:`tiltPosition`,fromArg:`tiltPosition`},openArgs:[{key:`tiltPosition`,label:L(`Tilt`,`Inclinazione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},status:{schema:YO,kind:`push`},runtimeState:YO,durability:`restored`,history:{fields:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Cover`,`Copertura`),order:1030,state:[{kind:`enum`,field:`state`,label:L(`State`,`Stato`),values:[{value:`open`,label:L(`Open`,`Aperto`),phrase:L(`When {device} is fully open`,`Quando {device} è tutto aperto`)},{value:`opening`,label:L(`Opening`,`In apertura`),phrase:L(`When {device} starts opening`,`Quando {device} inizia ad aprirsi`)},{value:`closing`,label:L(`Closing`,`In chiusura`),phrase:L(`When {device} starts closing`,`Quando {device} inizia a chiudersi`)},{value:`closed`,label:L(`Closed`,`Chiuso`),phrase:L(`When {device} is fully closed`,`Quando {device} è tutto chiuso`)},{value:`stopped`,label:L(`Stopped`,`Fermo`),phrase:L(`When {device} stops part-way`,`Quando {device} si ferma a metà`)}],icon:`blinds`},{kind:`numeric`,field:`position`,quantity:L(`the opening`,`l’apertura`),label:L(`Position`,`Posizione`),unit:`%`,icon:`blinds`}],overrides:{byRole:{[P.CoverGarage]:{actions:{"cover.open":{phrase:L(`Open the garage door {device}`,`Apri il garage {device}`),icon:`warehouse`},"cover.close":{phrase:L(`Close the garage door {device}`,`Chiudi il garage {device}`),icon:`warehouse`}}},[P.CoverGate]:{actions:{"cover.open":{phrase:L(`Open the gate {device}`,`Apri il cancello {device}`),icon:`fence`},"cover.close":{phrase:L(`Close the gate {device}`,`Chiudi il cancello {device}`),icon:`fence`}}},[P.CoverDoor]:{actions:{"cover.open":{phrase:L(`Open the door {device}`,`Apri la porta {device}`),icon:`door-open`},"cover.close":{phrase:L(`Close the door {device}`,`Chiudi la porta {device}`),icon:`door-closed`}}},[P.CoverWindow]:{actions:{"cover.open":{phrase:L(`Open the window {device}`,`Apri la finestra {device}`),icon:`app-window`},"cover.close":{phrase:L(`Close the window {device}`,`Chiudi la finestra {device}`),icon:`app-window`}}},[P.CoverShutter]:{actions:{"cover.open":{phrase:L(`Raise the shutter {device}`,`Alza la tapparella {device}`)},"cover.close":{phrase:L(`Lower the shutter {device}`,`Abbassa la tapparella {device}`)}}},[P.CoverAwning]:{actions:{"cover.open":{phrase:L(`Extend the awning {device}`,`Apri la tenda da sole {device}`)},"cover.close":{phrase:L(`Retract the awning {device}`,`Chiudi la tenda da sole {device}`)}}}}}}},ZO=x({stepId:u(),entry:Tf}),QO=x({path:u().min(1),bytes:r().int().nonnegative(),sha256:u().regex(/^[0-9a-f]{64}$/)}),$O=x({addonId:u(),stepId:u().min(1),entries:C(Tf).min(1).max(4),bundle:x({ticket:io,bytes:r().int().positive(),sha256:u().regex(/^[0-9a-f]{64}$/)}),files:C(QO).min(1).max(64),distribute:y()}),ek=a(`kind`,[x({kind:m(`imported`),modelIds:C(u()).readonly(),distributed:C(x({modelId:u(),nodeId:u(),format:S(ff),ok:y(),error:u().optional()})).readonly()}),x({kind:m(`refused`),reason:S([`transfer-failed`,`checksum-mismatch`,`bundle-mismatch`,`invalid-entry`,`id-taken`]),detail:u()})]),tk={name:`custom-model-registry`,scope:`system`,mode:`collection`,internal:!0,methods:{listModels:D(v(),C(ZO).readonly(),{auth:`admin`}),importModelBundle:D($O,ek,{kind:`mutation`,auth:`admin`,timeoutMs:30*6e4})},vocabulary:{notOperatorFacing:k.ML}},nk=x({engineId:u(),kind:S([`relational`,`vector`]),displayName:u()}),rk={name:`data-store-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{getEngineInfo:D(v(),nk,{auth:`admin`}),get:D(x({namespace:u().optional(),collection:u(),key:u()}),w(),{auth:`admin`}),set:D(x({namespace:u().optional(),collection:u(),key:u(),value:w()}),v(),{kind:`mutation`,auth:`admin`}),query:D(x({namespace:u().optional(),collection:u(),filter:zo.optional(),columns:C(u()).readonly().optional()}),C(Vo).readonly(),{auth:`admin`}),insert:D(x({namespace:u().optional(),collection:u(),record:x({id:u().optional(),data:h(u(),w())})}),x({id:g([u(),r()])}),{kind:`mutation`,auth:`admin`}),upsert:D(x({namespace:u().optional(),collection:u(),conflict:C(u()).readonly(),record:Ho}),x({id:g([u(),r()])}),{kind:`mutation`,auth:`admin`}),upsertMany:D(x({namespace:u().optional(),collection:u(),conflict:C(u()).readonly(),records:C(Ho).readonly()}),x({upserted:r().int()}),{kind:`mutation`,auth:`admin`}),insertMany:D(x({namespace:u().optional(),collection:u(),records:C(Ho).readonly()}),x({inserted:r().int()}),{kind:`mutation`,auth:`admin`}),transact:D(x({namespace:u().optional(),guard:Nie.optional(),ops:C(Mie).readonly()}),x({applied:y(),current:w().optional()}),{kind:`mutation`,auth:`admin`}),update:D(x({namespace:u().optional(),collection:u(),id:u(),data:h(u(),w())}),v(),{kind:`mutation`,auth:`admin`}),delete:D(x({namespace:u().optional(),collection:u(),key:u()}),v(),{kind:`mutation`,auth:`admin`}),deleteWhere:D(x({namespace:u().optional(),collection:u(),filter:Bo}),x({deleted:r().int()}),{kind:`mutation`,auth:`admin`}),updateWhere:D(x({namespace:u().optional(),collection:u(),filter:Bo,data:h(u(),w())}),x({updated:r().int()}),{kind:`mutation`,auth:`admin`}),count:D(x({namespace:u().optional(),collection:u(),filter:zo.optional()}),r(),{auth:`admin`}),aggregate:D(x({namespace:u().optional(),collection:u(),fields:C(kie).readonly(),filter:zo.optional()}),Aie,{auth:`admin`}),histogram:D(x({namespace:u().optional(),collection:u(),field:u(),bucketSize:r().int().positive(),origin:r().int(),filter:zo.optional()}),C(x({bucket:r().int(),count:r().int()})).readonly(),{auth:`admin`}),isEmpty:D(x({namespace:u().optional(),collection:u()}),y(),{auth:`admin`}),declareCollection:D(Wo,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.INTERNAL}},ik=S([`auto`,`day`,`night`,`schedule`]),ak=x({min:r(),max:r(),step:r()}),ok=x({mode:ik,sensitivity:r().optional().meta(A(`none`)),switchDelaySec:r().optional().meta(A(`duration`)),lastFetchedAt:r()}),sk=x({modes:C(ik),supportsSensitivity:y(),sensitivity:ak.optional(),supportsSwitchDelay:y(),switchDelaySec:ak.optional()}),ck=x({mode:ik.optional(),sensitivity:r().optional(),switchDelaySec:r().optional()}),lk={name:`day-night`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`day-night`,tab:`image`}},methods:{getOptions:D(x({deviceId:r()}),sk),setSettings:D(x({deviceId:r(),settings:ck}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`dayNight.auto`,label:L(`Day/night auto`,`Giorno/notte automatico`),phrase:L(`Let {device} switch day and night by itself`,`Fai passare {device} da giorno a notte in automatico`),icon:`sun-moon`,args:{settings:{mode:`auto`}}},{id:`dayNight.day`,label:L(`Day mode`,`Modalità giorno`),phrase:L(`Force {device} into day mode`,`Forza {device} in modalità giorno`),icon:`sun`,args:{settings:{mode:`day`}}},{id:`dayNight.night`,label:L(`Night mode`,`Modalità notte`),phrase:L(`Force {device} into night mode`,`Forza {device} in modalità notte`),icon:`moon`,args:{settings:{mode:`night`}}}]})},status:{schema:ok,kind:`poll`},runtimeState:ok,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Day/night`,`Giorno/notte`),order:3070,state:[{kind:`enum`,field:`mode`,label:L(`Day/night mode`,`Modalità giorno/notte`),values:[{value:`auto`,label:L(`Automatic`,`Automatica`)},{value:`day`,label:L(`Day`,`Giorno`),phrase:L(`When {device} switches to day mode`,`Quando {device} passa in modalità giorno`)},{value:`night`,label:L(`Night`,`Notte`),phrase:L(`When {device} switches to night mode`,`Quando {device} passa in modalità notte`)},{value:`schedule`,label:L(`Scheduled`,`Programmata`)}],icon:`sun-moon`}]}},pye=[{value:`auto`,label:`Auto (defer to probed best)`},{value:`none`,label:`Off (software)`},{value:`videotoolbox`,label:`VideoToolbox (macOS)`},{value:`cuda`,label:`CUDA (NVIDIA)`},{value:`nvdec`,label:`NVDEC (NVIDIA legacy)`},{value:`vaapi`,label:`VAAPI (Linux Intel/AMD)`},{value:`qsv`,label:`QuickSync (Intel)`},{value:`d3d11va`,label:`D3D11VA (Windows)`},{value:`dxva2`,label:`DXVA2 (Windows legacy)`},{value:`amf`,label:`AMF (AMD)`},{value:`vdpau`,label:`VDPAU (Linux NVIDIA legacy)`},{value:`drm`,label:`DRM (Linux generic)`}],mye={hwaccel:`auto`,probedBestHwaccel:``},uk={name:`decoder`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{getInfo:D(v(),x({id:u(),name:u(),hwaccel:u().optional(),probedBestHwaccel:u().optional()})),reprobeHwaccel:D(v(),x({backend:u()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.PIPELINE}},dk={name:`detection-pipeline`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:L(`Detection pipeline`,`Pipeline di rilevamento`),order:3080}},fk=S([`device`,`integration`]),pk=x({url:u(),label:u(),target:fk,host:u()}),mk={name:`device-admin-link`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getAdminLink:D(x({deviceId:r().int().nonnegative()}),pk.nullable(),{auth:`admin`})},vocabulary:{noun:L(`Admin link`,`Link di amministrazione`),order:3090}},hk=S([`online`,`sleeping`,`offline`,`unknown`]),gk=o(()=>x({childNativeId:u(),name:u(),type:S(M),status:hk,metadata:x({model:u().optional(),serialNumber:u().optional(),uid:u().optional(),rtspChannel:r().int().nonnegative().optional(),isBattery:y().optional(),isDoorbell:y().optional(),isMultifocal:y().optional(),externalLocation:u().optional(),manufacturer:u().optional(),integration:u().optional()}).default({}),alreadyAdopted:y(),adoptedDeviceId:r().int().nonnegative().nullable(),capabilities:C(u()).readonly().optional(),features:C(u()).readonly().optional(),sourceInfo:Rh.optional(),children:C(gk).readonly().optional(),parentStableId:u().optional()})),_k=x({id:u(),label:u(),isDefault:y().optional()}),vk=x({search:u().optional(),area:u().optional(),manufacturer:u().optional(),adoptedOnly:y().optional(),unadoptedOnly:y().optional()}),yk=x({integrationId:u(),page:r().int().positive().default(1),pageSize:r().int().positive().max(2e4).default(50),filter:u().optional(),filterText:vk.optional()}),bk=x({candidates:C(gk).readonly(),totalCount:r().int().nonnegative(),page:r().int().positive(),pageSize:r().int().positive()}),xk=x({integrationId:u(),childNativeId:u()}),Sk=x({lastDiscoveryAt:r().int().nonnegative().nullable(),candidateCount:r().int().nonnegative(),adoptedCount:r().int().nonnegative(),lastError:u().nullable()}),hye=x({name:u().min(1).optional(),hiddenChildIds:C(u()).optional()}),Ck=x({integrationId:u(),childNativeIds:C(u()).min(1),filter:u().optional(),importLocations:y().optional(),perCandidate:h(u(),hye).optional()}),wk=x({adopted:C(x({childNativeId:u(),parentDeviceId:r().int().nonnegative(),accessoryDeviceIds:C(r().int().nonnegative()).readonly()})).readonly()}),Tk=x({integrationId:u(),camDeviceId:r().int().nonnegative()}),Ek=x({camDeviceId:r().int().nonnegative(),resetToSource:y().optional()}),Dk=x({changed:y(),rebuiltChildren:r().int().nonnegative(),removedChildren:r().int().nonnegative().optional()}),Ok={name:`device-adoption`,scope:`system`,mode:`collection`,status:{schema:Sk,kind:`poll`},methods:{listCandidateFilters:D(x({integrationId:u()}),x({filters:C(_k)}),{auth:`admin`}),listCandidates:D(yk,bk,{auth:`admin`}),getCandidate:D(xk,gk.nullable(),{auth:`admin`}),refresh:D(x({integrationId:u()}),Sk,{kind:`mutation`,auth:`admin`}),adopt:D(Ck,wk,{kind:`mutation`,auth:`admin`}),release:D(Tk,v(),{kind:`mutation`,auth:`admin`}),resync:D(Ek,Dk,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`device adoption — an onboarding flow, not an action`}},kk=a(`state`,[x({state:m(`absent`)}),x({state:m(`ready`),subject:u(),fingerprintSha256:u(),validTo:u()}),x({state:m(`unavailable`),reason:u()})]),Ak=x({selfEnrollment:S([`allowed`,`disabled`])}),jk={name:`device-credentials`,scope:`system`,mode:`singleton`,methods:{listDeviceCredentials:D(x({userId:u().min(1).optional(),includeRevoked:y().default(!1)}),C(Rp).readonly(),{auth:`admin`}),startEnrollment:D(x({userId:u().min(1),deviceName:u().min(1).max(80)}),zp,{kind:`mutation`,auth:`admin`,caller:`required`}),revokeDeviceCredential:D(x({id:u().min(1)}),x({revoked:y(),sessionsEnded:r().int(),status:Lp}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCertificateSettings:D(x({}),Ak,{auth:`admin`}),setDeviceCertificateSettings:D(Ak,Ak,{kind:`mutation`,auth:`admin`}),deleteDeviceCredential:D(x({id:u().min(1)}),x({result:S([`deleted`,`live`,`unknown`])}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCaStatus:D(x({}),kk,{auth:`admin`}),renameDeviceCredential:D(x({id:u().min(1),deviceName:u().min(1).max(80)}),x({renamed:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.IDENTITY}},Mk=/^[a-z][a-z0-9_]*$/,gye=new Set(`true.false.none.null.and.or.not.in.is.if.elif.else.endif.for.endfor.loop.set.range.cycler.joiner.self.caller.super.import.include.extends.block.macro.now.camera`.split(`.`)),Nk=u().max(64).regex(Mk);function Pk(e){return gye.has(e)}function Fk(e){let t=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``);return t.length===0?`device`:(/^[0-9]/.test(t)?`device_${t}`:t).slice(0,60).replace(/_+$/g,``)}function _ye(e,t){let n=Fk(e);if(!Pk(n)&&!t(n))return n;for(let e=2;;e+=1){let r=`${n}_${e}`;if(!t(r))return r}}function vye(e,t){return e.length===0?{ok:!1,reason:`empty`}:e.length>64?{ok:!1,reason:`too-long`}:Mk.test(e)?Pk(e)?{ok:!1,reason:`reserved`}:t(e)?{ok:!1,reason:`taken`}:{ok:!0,alias:e}:{ok:!1,reason:`grammar`}}var Ik=[`filter`,`global`,`variable`],Lk=[`number`,`unit`,`text`,`state`,`time`,`fallback`,`loop`,`variable`],Rk=[`string`,`number`,`boolean`],zk=a(`kind`,[x({kind:m(`units-of-field`)}),x({kind:m(`choices`),options:C(x({value:u(),labelKey:u().min(1)})).min(1)}),x({kind:m(`range`),min:r(),max:r(),step:r().positive()})]),yye=zk,Bk=x({name:u().min(1),type:S(Rk),optional:y(),default:g([u(),r(),y()]).optional(),values:zk.optional()}),bye=x({name:u().min(1),kind:S(Ik),category:S(Lk),params:C(Bk),descriptionKey:u().min(1),exampleKey:u().min(1)});function Vk(e,t,n,r,i){let a=r===void 0?{name:e,type:t,optional:n}:{name:e,type:t,optional:n,default:r};return i===void 0?a:{...a,values:i}}function B(e,t,n,r){return{name:e,kind:t,category:n,params:[...r],descriptionKey:`uiLibrary.deviceTemplateCatalogue.${e}.description`,exampleKey:`uiLibrary.deviceTemplateCatalogue.${e}.example`}}var Hk=Vk(`digits`,`number`,!0,0,{kind:`range`,min:0,max:4,step:1}),Uk={kind:`units-of-field`},Wk=[[`hm`,`HH:mm`,`Hours and minutes (14:05)`,`Ore e minuti (14:05)`],[`hms`,`HH:mm:ss`,`Hours, minutes, seconds (14:05:09)`,`Ore, minuti, secondi (14:05:09)`],[`dm`,`DD/MM`,`Day and month (31/12)`,`Giorno e mese (31/12)`],[`dmy`,`DD/MM/YYYY`,`Day, month, year (31/12/2026)`,`Giorno, mese, anno (31/12/2026)`],[`dmyhm`,`DD/MM/YYYY HH:mm`,`Date and time (31/12/2026 14:05)`,`Data e ora (31/12/2026 14:05)`],[`iso`,`YYYY-MM-DD`,`ISO date (2026-12-31)`,`Data ISO (2026-12-31)`],[`isohms`,`YYYY-MM-DD HH:mm:ss`,`ISO date and time (2026-12-31 14:05:09)`,`Data e ora ISO (2026-12-31 14:05:09)`]],Gk=e=>`uiLibrary.deviceTemplateCatalogue.choice.time.${e}`,xye={kind:`choices`,options:Wk.map(([e,t])=>({value:t,labelKey:Gk(e)}))},Kk=Vk(`fallback`,`string`,!1),qk=Vk(`falsy`,`boolean`,!0,!1),Jk=[B(`unit`,`filter`,`unit`,[Vk(`symbol`,`string`,!1,void 0,Uk),Vk(`from`,`string`,!0,void 0,Uk)]),B(`round`,`filter`,`number`,[Hk]),B(`trunc`,`filter`,`number`,[Hk]),B(`onoff`,`filter`,`state`,[]),B(`default`,`filter`,`fallback`,[Kk,qk]),B(`since`,`filter`,`time`,[]),B(`ago`,`filter`,`time`,[]),B(`format`,`filter`,`text`,[Vk(`pattern`,`string`,!1)]),B(`upper`,`filter`,`text`,[]),B(`lower`,`filter`,`text`,[]),B(`title`,`filter`,`text`,[]),B(`capitalize`,`filter`,`text`,[]),B(`trim`,`filter`,`text`,[]),B(`abs`,`filter`,`number`,[]),B(`int`,`filter`,`number`,[Vk(`fallback`,`number`,!0,0)]),B(`float`,`filter`,`number`,[Vk(`fallback`,`number`,!0,0)]),B(`length`,`filter`,`text`,[]),B(`d`,`filter`,`fallback`,[Kk,qk]),B(`join`,`filter`,`text`,[Vk(`separator`,`string`,!0,``)]),B(`replace`,`filter`,`text`,[Vk(`old`,`string`,!1),Vk(`new`,`string`,!1),Vk(`count`,`number`,!0)]),B(`first`,`filter`,`loop`,[]),B(`last`,`filter`,`loop`,[]),B(`sort`,`filter`,`loop`,[Vk(`reverse`,`boolean`,!0,!1),Vk(`caseSensitive`,`boolean`,!0,!1)]),B(`reverse`,`filter`,`loop`,[]),B(`sum`,`filter`,`number`,[]),B(`string`,`filter`,`text`,[]),B(`list`,`filter`,`loop`,[]),B(`truncate`,`filter`,`text`,[Vk(`length`,`number`,!1),Vk(`killwords`,`boolean`,!0,!1),Vk(`end`,`string`,!0,`…`)]),B(`time`,`filter`,`time`,[Vk(`pattern`,`string`,!1,void 0,xye)]),B(`range`,`global`,`loop`,[Vk(`stop`,`number`,!1),Vk(`start`,`number`,!0,0),Vk(`step`,`number`,!0,1)]),B(`now`,`variable`,`time`,[]),B(`camera`,`variable`,`variable`,[]),B(`loop`,`variable`,`loop`,[]),B(`lastPerson`,`variable`,`variable`,[]),B(`lastPlate`,`variable`,`variable`,[])],Sye={unit:{description:[`Converts a number from the field’s base unit and prints the symbol.`,`Converte un numero dall’unità di base del campo e stampa il simbolo.`],example:[`{{ garage.temperature | unit('°C') }}`,`{{ garage.temperature | unit('°C') }}`]},round:{description:[`Rounds a number to the given decimals.`,`Arrotonda un numero ai decimali indicati.`],example:[`{{ garage.temperature | round(1) }}`,`{{ garage.temperature | round(1) }}`]},trunc:{description:[`Cuts decimals toward zero, without rounding.`,`Taglia i decimali verso zero, senza arrotondare.`],example:[`{{ garage.temperature | trunc(1) }}`,`{{ garage.temperature | trunc(1) }}`]},onoff:{description:[`Prints a boolean as ON or OFF.`,`Stampa un sì/no come ON oppure OFF.`],example:[`{{ garage.switch | onoff }}`,`{{ garage.switch | onoff }}`]},default:{description:[`Replaces a missing value. The second argument also replaces a false or zero.`,`Sostituisce un valore assente. Il secondo argomento sostituisce anche falso o zero.`],example:[`{{ camera.lastPerson | default('') }}`,`{{ camera.lastPerson | default('') }}`]},since:{description:[`How long ago a timestamp was, as “5 min”.`,`Quanto tempo fa era un istante, come «5 min».`],example:[`{{ garage.updated | since }}`,`{{ garage.updated | since }}`]},ago:{description:[`The same duration as since, followed by “ago”.`,`La stessa durata di since, seguita da «ago».`],example:[`{{ garage.updated | ago }}`,`{{ garage.updated | ago }}`]},format:{description:[`Prints one value with a single %s, %d or %.Nf placeholder.`,`Stampa un valore con un solo segnaposto %s, %d o %.Nf.`],example:[`{{ garage.temperature | format('%.1f') }}`,`{{ garage.temperature | format('%.1f') }}`]},upper:{description:[`Uppercase text.`,`Testo in maiuscolo.`],example:[`{{ camera.lastPerson | upper }}`,`{{ camera.lastPerson | upper }}`]},lower:{description:[`Lowercase text.`,`Testo in minuscolo.`],example:[`{{ camera.lastPlate | lower }}`,`{{ camera.lastPlate | lower }}`]},title:{description:[`Capitalises each word.`,`Mette la maiuscola a ogni parola.`],example:[`{{ camera.lastPerson | title }}`,`{{ camera.lastPerson | title }}`]},capitalize:{description:[`Capitalises the first letter.`,`Mette la maiuscola alla prima lettera.`],example:[`{{ camera.lastPerson | capitalize }}`,`{{ camera.lastPerson | capitalize }}`]},trim:{description:[`Removes spaces at both ends.`,`Toglie gli spazi alle estremità.`],example:[`{{ camera.lastPerson | trim }}`,`{{ camera.lastPerson | trim }}`]},abs:{description:[`The absolute value of a number.`,`Il valore assoluto di un numero.`],example:[`{{ garage.power | abs }}`,`{{ garage.power | abs }}`]},int:{description:[`The whole part of a number.`,`La parte intera di un numero.`],example:[`{{ garage.temperature | int }}`,`{{ garage.temperature | int }}`]},float:{description:[`Reads the value as a decimal number.`,`Legge il valore come numero decimale.`],example:[`{{ garage.temperature | float }}`,`{{ garage.temperature | float }}`]},length:{description:[`How many characters or items.`,`Quanti caratteri o elementi.`],example:[`{{ camera.lastPerson | length }}`,`{{ camera.lastPerson | length }}`]},d:{description:[`The short name of default.`,`Il nome breve di default.`],example:[`{{ camera.lastPerson | d('') }}`,`{{ camera.lastPerson | d('') }}`]},join:{description:[`Joins a list with a separator.`,`Unisce un elenco con un separatore.`],example:[`{{ range(3) | join(', ') }}`,`{{ range(3) | join(', ') }}`]},replace:{description:[`Replaces text, optionally only the first few times.`,`Sostituisce del testo, volendo solo le prime volte.`],example:[`{{ camera.lastPlate | replace(' ', '') }}`,`{{ camera.lastPlate | replace(' ', '') }}`]},first:{description:[`The first item of a list.`,`Il primo elemento di un elenco.`],example:[`{{ range(3) | first }}`,`{{ range(3) | first }}`]},last:{description:[`The last item of a list.`,`L’ultimo elemento di un elenco.`],example:[`{{ range(3) | last }}`,`{{ range(3) | last }}`]},sort:{description:[`Sorts a list. The arguments reverse it or keep case.`,`Ordina un elenco. Gli argomenti lo invertono o rispettano le maiuscole.`],example:[`{{ range(3) | reverse | sort }}`,`{{ range(3) | reverse | sort }}`]},reverse:{description:[`Reverses a list.`,`Inverte un elenco.`],example:[`{{ range(3) | reverse }}`,`{{ range(3) | reverse }}`]},sum:{description:[`Adds the numbers in a list.`,`Somma i numeri di un elenco.`],example:[`{{ range(3) | sum }}`,`{{ range(3) | sum }}`]},string:{description:[`Prints the value as text.`,`Stampa il valore come testo.`],example:[`{{ garage.temperature | string }}`,`{{ garage.temperature | string }}`]},list:{description:[`Wraps the value in a list.`,`Mette il valore in un elenco.`],example:[`{{ garage.temperature | list }}`,`{{ garage.temperature | list }}`]},truncate:{description:[`Shortens text to a length, with an ending.`,`Accorcia il testo a una lunghezza, con una chiusura.`],example:[`{{ camera.lastPerson | truncate(12) }}`,`{{ camera.lastPerson | truncate(12) }}`]},time:{description:[`Prints a timestamp in the server’s time zone. Tokens: YYYY MM DD HH mm ss.`,`Stampa un istante nel fuso del server. Segni: YYYY MM DD HH mm ss.`],example:[`{{ now | time('HH:mm') }}`,`{{ now | time('HH:mm') }}`]},range:{description:[`The integers up to stop, or from start to stop by step. At most 1000 items.`,`Gli interi fino a stop, oppure da start a stop con step. Al massimo 1000 elementi.`],example:[`{% for i in range(3) %}{{ i }}{% endfor %}`,`{% for i in range(3) %}{{ i }}{% endfor %}`]},now:{description:[`The hub clock. A bare now prints ISO; time prints a pattern.`,`L’orologio dell’hub. now da solo stampa ISO; time stampa un formato.`],example:[`{{ now | time('HH:mm') }}`,`{{ now | time('HH:mm') }}`]},camera:{description:[`The device this text is written for. It stays correct when the text is copied to another camera.`,`Il dispositivo per cui è scritto il testo. Resta corretto se il testo viene copiato su un’altra telecamera.`],example:[`{{ camera.temperature }}`,`{{ camera.temperature }}`]},loop:{description:[`The for-loop counter (index, length) inside {% for %}.`,`Il contatore del ciclo (index, length) dentro {% for %}.`],example:[`{% for i in range(3) %}{{ loop.index }}{% endfor %}`,`{% for i in range(3) %}{{ loop.index }}{% endfor %}`]},lastPerson:{description:[`The last person recognised on this camera, empty until there is one.`,`L’ultima persona riconosciuta su questa telecamera, vuota finché non ce n’è una.`],example:[`{{ camera.lastPerson }}`,`{{ camera.lastPerson }}`]},lastPlate:{description:[`The last plate recognised on this camera, empty until there is one.`,`L’ultima targa riconosciuta su questa telecamera, vuota finché non ce n’è una.`],example:[`{{ camera.lastPlate }}`,`{{ camera.lastPlate }}`]}};function Cye(){let e={};for(let t of Jk){let n=Sye[t.name];n!==void 0&&(e[t.descriptionKey]={en:n.description[0],it:n.description[1]},e[t.exampleKey]={en:n.example[0],it:n.example[1]})}for(let[t,,n,r]of Wk)e[Gk(t)]={en:n,it:r};return e}var Yk=Cye();function Xk(){return Jk.filter(e=>e.kind===`filter`).map(e=>e.name)}function wye(){let e={};for(let t of Jk)t.kind===`filter`&&(e[t.name]=t.params.length);return e}function Tye(){return Jk.filter(e=>e.kind===`global`).map(e=>({name:e.name,min:Math.max(1,e.params.filter(e=>!e.optional).length),max:e.params.length}))}var Zk=new Set([`now`,`camera`,`loop`]);function Qk(){return Jk.filter(e=>e.kind===`variable`&&Zk.has(e.name))}function $k(){return Jk.filter(e=>e.kind===`variable`&&!Zk.has(e.name))}function eA(e){if(e.kind===`variable`)return e.name;let t=e.params.map(e=>e.optional?`${e.name}?`:e.name).join(`, `);return`${e.name}(${t})`}function tA(e,t){return Yk[e]?.[t]}function Eye(){let e=[`| Name | Kind | What it does | Example |`,`| --- | --- | --- | --- |`],t=Jk.map(e=>{let t=nA(tA(e.descriptionKey,`en`)??``),n=nA(tA(e.exampleKey,`en`)??``);return`| \`${eA(e)}\` | ${e.kind} | ${t} | \`${n}\` |`});return[...e,...t].join(`
1113
- `)}function nA(e){return e.replaceAll(`|`,`\\|`)}function Dye(){let e=[];for(let t of Object.values(Wh))e.includes(t.dimension)||e.push(t.dimension);return e.map(e=>({group:e,choices:$h(e).map(e=>({value:e}))}))}function rA(e,t){if(e===void 0)return[];if(e.kind===`choices`)return[{group:null,choices:e.options.map(e=>({...e}))}];if(e.kind===`range`){let t=[],n=Math.floor((e.max-e.min)/e.step+1e-9);for(let r=0;r<=n;r+=1)t.push({value:String(e.min+r*e.step)});return[{group:null,choices:t}]}let n=t===void 0?void 0:qh(t);return n===void 0?Dye():[{group:n,choices:$h(n).map(e=>({value:e}))}]}var iA=4096,Oye=4096,aA=u().min(1).max(iA),kye=`camera`,oA=g([u(),r(),y()]),sA=x({deviceId:r().int(),values:h(u().min(1).max(64),oA).optional()}),Aye=`values`,jye=Xk(),cA=[`too-long`,`syntax`,`forbidden-syntax`,`forbidden-member`,`unknown-filter`,`ambiguous-field`,`busy`,`budget-exceeded`,`timeout`,`output-too-large`,`render-failed`,`out-of-scope`,`unavailable`],lA=x({reason:S(cA),message:u()}),uA=[`unknown-alias`,`unknown-field`,`no-field`,`unavailable`],dA=x({ref:u(),reason:S(uA)}),fA=a(`ok`,[x({ok:m(!0),text:u(),trace:C(dA)}),x({ok:m(!1),refusal:lA,trace:C(dA)})]);function pA(e){return e.replace(/-/g,`_`)}function mA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function hA(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(mA(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function Mye(e,t){let n=t[0];if(n===void 0)return{kind:`missing`,reason:`no-field`};let r=Object.keys(e.slices),i=r.find(e=>e===n||pA(e)===n);if(i!==void 0){let n=t.slice(1);if(n.length===0)return{kind:`missing`,reason:`no-field`};let r=hA(e.slices[i],n);return r===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:i,fieldPath:n,value:r}}let a=r.filter(t=>{let r=e.slices[t];return mA(r)&&Object.hasOwn(r,String(n))});if(a.length===0)return{kind:`missing`,reason:`unknown-field`};let[o]=a;if(a.length>1||o===void 0)return{kind:`ambiguous`,field:String(n),caps:a};let s=hA(e.slices[o],t);return s===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:o,fieldPath:t,value:s}}var gA=x({zoneKey:u(),label:u(),icon:md.nullable(),locationKeys:C(u())});function Nye(e){return e.trim().toLowerCase()}var _A=[`mac`,`serial`,`machine-uuid`,`vendor-uid`,`hostname`,`ip`],vA=S(_A),yA=S([`read`,`derived`]),Pye=/^[0-9a-f]{2}(?::[0-9a-f]{2}){5}$/,bA=/^[a-z0-9][a-z0-9._-]*:[^\sA-Z]+$/,xA=/^[0-9a-f][0-9a-f-]{7,}$/,SA=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function CA(e){return x({value:e,origin:yA,readAt:r().int().nonnegative()}).strict()}var Fye=CA(u().regex(Pye)),Iye=CA(u().regex(bA)),Lye=CA(u().regex(xA)),Rye=CA(u().regex(bA)),zye=CA(u().regex(SA)),Bye=CA(g([ee(),s()])),Vye=x({value:u().min(1),origin:yA,readAt:r().int().nonnegative()}).strict(),wA=x({mac:C(Fye).min(1).readonly().optional(),serial:Iye.optional(),"machine-uuid":Lye.optional(),"vendor-uid":Rye.optional(),hostname:zye.optional(),ip:Bye.optional()}).strict(),Hye={mac:`strong`,serial:`strong`,"machine-uuid":`strong`,"vendor-uid":`strong`,hostname:`weak`,ip:`weak`};function TA(e){return Hye[e]}function EA(e){return _A.every(t=>e[t]===void 0)}var Uye=/^(?:unknown|none|n\/?a|null|undefined|default|0+|-+)$/i,Wye=new Set([`00:00:00:00:00:00`,`ff:ff:ff:ff:ff:ff`]);function DA(e){return{ok:!1,reason:e}}function OA(e){let t=e.trim().toLowerCase().replace(/[\s:.-]/g,``);if(!/^[0-9a-f]{12}$/.test(t))return DA(`not a 48-bit MAC`);let n=(t.match(/../g)??[]).join(`:`);return Wye.has(n)?DA(`placeholder MAC`):{ok:!0,value:n}}function Gye(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[-._]+|[-._]+$/g,``)}function kA(e,t,n){let r=Gye(e);if(r.length===0)return DA(`no ${n}`);let i=t.trim().toLowerCase().replace(/\s+/g,``);return i.length===0?DA(`blank value`):Uye.test(i)?DA(`placeholder value`):{ok:!0,value:`${r}:${i}`}}function Kye(e){let t=e.trim().toLowerCase().replace(/^\{|\}$/g,``);return xA.test(t)?/^[0-]+$/.test(t)||/^[f-]+$/.test(t)?DA(`placeholder uuid`):{ok:!0,value:t}:DA(`not a uuid`)}function AA(e){return g([ee(),s()]).safeParse(e).success}function qye(e){let t=e.trim().toLowerCase().replace(/\.$/,``);if(t.length===0)return DA(`blank hostname`);if(AA(t))return DA(`an address, not a hostname`);let n=t.split(`.`)[0]??``;return SA.test(n)?n===`localhost`?DA(`placeholder hostname`):{ok:!0,value:n}:DA(`not a hostname`)}function Jye(e){let t=e.trim().toLowerCase().replace(/^\[|\]$/g,``);return AA(t)?t===`0.0.0.0`||t===`::`||t===`::1`||t.startsWith(`127.`)?DA(`loopback or unspecified address`):{ok:!0,value:t}:DA(`not an IP address`)}function jA(e){return e==null||e.trim().length===0}function MA(e,t={}){let n=t.readAt??Date.now(),r=e=>t.originByKey?.[e]??t.origin??`read`,i=(e,t)=>({value:t,origin:r(e),readAt:n}),a=[],o=(e,t,n)=>{if(n.ok)return i(e,n.value);a.push({key:e,value:t,reason:n.reason})},s=e.mac===null||e.mac===void 0?[]:[e.mac].flat(),c=[];for(let e of s){if(jA(e))continue;let t=o(`mac`,e,OA(e));t!==void 0&&!c.some(e=>e.value===t.value)&&c.push(t)}let l=e.serial===null||e.serial===void 0||jA(e.serial.serial)?void 0:o(`serial`,`${e.serial.manufacturer}:${e.serial.serial}`,kA(e.serial.manufacturer,e.serial.serial,`manufacturer`)),u=e.vendorUid===null||e.vendorUid===void 0||jA(e.vendorUid.id)?void 0:o(`vendor-uid`,`${e.vendorUid.vendor}:${e.vendorUid.id}`,kA(e.vendorUid.vendor,e.vendorUid.id,`vendor`)),d=jA(e.machineUuid)?void 0:o(`machine-uuid`,e.machineUuid,Kye(e.machineUuid)),f=jA(e.host)?null:e.host.trim(),p=f!==null&&AA(f.toLowerCase().replace(/^\[|\]$/g,``)),m=jA(e.hostname)?p?null:f:e.hostname,h=jA(e.ip)?p?f:null:e.ip,g=m===null?void 0:o(`hostname`,m,qye(m)),_=h===null?void 0:o(`ip`,h,Jye(h));return{identifiers:{...c.length>0?{mac:c}:{},...l===void 0?{}:{serial:l},...d===void 0?{}:{"machine-uuid":d},...u===void 0?{}:{"vendor-uid":u},...g===void 0?{}:{hostname:g},..._===void 0?{}:{ip:_}},rejected:a}}function NA(e,t){return e.value===t.value&&e.origin===t.origin}function PA(e,t){return t!==void 0&&NA(e,t)?t:e}function Yye(e,t,n=[]){let r=e??{},i=t??{},a=new Set(n),o=a.has(`mac`)?r.mac:i.mac?.map(e=>PA(e,r.mac?.find(t=>NA(t,e)))),s=e=>{if(a.has(e))return r[e];let t=i[e];return t===void 0?void 0:PA(t,r[e])},c=s(`serial`),l=s(`machine-uuid`),u=s(`vendor-uid`),d=s(`hostname`),f=s(`ip`),p={...o!==void 0&&o.length>0?{mac:o}:{},...c===void 0?{}:{serial:c},...l===void 0?{}:{"machine-uuid":l},...u===void 0?{}:{"vendor-uid":u},...d===void 0?{}:{hostname:d},...f===void 0?{}:{ip:f}};return EA(p)?null:p}function Xye(e,t){let n=e=>e==null||EA(e)?``:JSON.stringify(_A.map(t=>[t,e[t]??null]).map(([e,t])=>[e,t===null?null:[t].flat().map(e=>[e.value,e.origin,e.readAt])]));return n(e)===n(t)}var FA=S([`auto`,`proposal`]),IA=x({key:vA,value:u()}),LA=x({deviceId:r().int(),addonId:u(),integrationId:u().nullable()}),RA=x({a:LA,b:LA,keys:C(IA).readonly(),confidence:FA}),zA=a(`status`,[x({status:m(`unknown`),reason:u()}),x({status:m(`answered`),pairs:C(RA).readonly(),undeclaredDeviceIds:C(r().int()).readonly()})]),BA=[`same-device`,`poe-power`],VA=S(BA),HA=S([`proposed`,`linked`,`dismissed`]),UA=S([`auto`,`operator`]),WA=x({addonId:u().min(1),stableId:u().min(1),deviceId:r().int()}),GA=x({kind:VA,a:WA,b:WA,state:HA,origin:UA,evidence:C(IA).readonly(),evidenceGone:m(!0).optional(),createdAt:r().int().nonnegative(),decidedAt:r().int().nonnegative().optional()}),KA=GA.extend({id:u().min(1)}),qA={"same-device":{directional:!1,attachingRole:null,contributions:[]},"poe-power":{directional:!0,attachingRole:P.PoePort,contributions:[{cap:`power-source`,targetId:`switch`,host:`b`,source:`a`,sourceCap:`switch`,sourceField:`on`}]}};function Zye(e,t){let n=qA[e].attachingRole;return n===null||t===n?null:`attaching-side-role`}function JA(e){return`${e.addonId}/${e.stableId}`}function Qye(e,t,n){let r=JA(t),i=JA(n);return qA[e].directional||r<=i?`${e}:${r}|${i}`:`${e}:${i}|${r}`}var YA=a(`status`,[x({status:m(`not-loaded`),reason:u()}),x({status:m(`answered`),links:C(KA).readonly()})]),XA=S([`not-loaded`,`unknown-link`,`wrong-state`]),ZA=a(`ok`,[x({ok:m(!0),link:KA}),x({ok:m(!1),reason:XA,message:u()})]),QA=S([`evidence-gone`,`device-removed`,`operator-unlinked`]),$ye=x({linkId:u(),kind:VA,aDeviceId:r().int(),bDeviceId:r().int(),origin:UA,reason:QA.optional()}),$A=x({caps:C(u()).readonly().optional(),actions:C(u()).readonly().optional(),mode:S([`any`,`all`]).optional()}),ej=x({locations:C(u()).readonly().optional(),integrationIds:C(u()).readonly().optional(),types:C(u()).readonly().optional()}),tj=x({text:u().optional(),requires:$A.optional(),filters:ej.optional(),includeIncompatible:y().optional(),contextDeviceId:r().optional(),ids:C(r()).readonly().optional(),cursor:u().nullable().optional(),limit:r().int().min(1).max(200).optional()}),nj=x({cap:u(),path:u(),label:u(),reading:u().nullable(),unit:u().nullable().optional(),quantity:bc.optional()}),rj=x({id:r(),name:u(),type:S(M),location:u().nullable(),integrationId:u().nullable(),integrationLabel:u().nullable(),online:y().nullable(),disabled:y(),compatible:y(),values:C(nj).readonly()}),ij=x({value:u(),count:r()}),aj=x({id:u(),label:u(),count:r()}),oj=x({locations:C(ij).readonly(),integrations:C(aj).readonly(),types:C(ij).readonly()}),sj=x({items:C(rj).readonly(),nextCursor:u().nullable(),total:r(),compatibleTotal:r(),fleetTotal:r(),hiddenIncompatible:r(),facets:oj,suggested:C(rj).readonly(),missingIds:C(r()).readonly()}),cj=x({connected:y(),deviceCount:r(),error:u().optional(),motionSliceWriter:m(`orchestrator`).optional()}),ebe=x({externalId:u(),name:u(),type:u(),metadata:h(u(),w()).optional()}),lj=a(`kind`,[x({kind:m(`mdns`),serviceType:u().min(1),instancePattern:u().optional()}),x({kind:m(`ws-discovery`),types:C(u()).optional()}),x({kind:m(`ssdp`),searchTarget:u().min(1)}),x({kind:m(`udp-broadcast`),port:r().int().min(1).max(65535),payloadHex:u().regex(/^([0-9a-fA-F]{2})*$/),listenPort:r().int().min(1).max(65535).optional()}),x({kind:m(`http-probe`),port:r().int().min(1).max(65535),path:u().startsWith(`/`),method:S([`GET`,`POST`]).default(`GET`),bodyText:u().optional(),contentType:u().optional(),tls:y().default(!1),acceptStatus:C(r().int()).optional()}),x({kind:m(`custom`),reason:u().min(1)})]),uj=x({modeIndex:r().int().min(0),host:u(),port:r().int(),http:x({status:r().int(),headers:h(u(),u()),bodyText:u()}).optional(),mdns:x({instance:u(),host:u(),port:r().int(),txt:h(u(),u())}).optional(),udp:x({payloadHex:u()}).optional(),wsd:x({xaddrs:C(u()),types:C(u()),scopes:C(u())}).optional()}),dj=x({stableId:u(),type:S(M),suggestedName:u(),prefilledConfig:h(u(),w()),sourceInfo:Rh.optional(),alreadyOnboarded:y().optional(),onboardedDeviceId:r().optional(),onboardedName:u().optional(),setupIntegration:y().optional(),parentStableId:u().optional(),selectable:y().optional(),needsParams:C(u()).optional()}),fj=x({id:r(),stableId:u(),addonId:u(),type:u(),name:u(),parentDeviceId:r().nullable(),online:y(),features:C(u()),config:h(u(),w()),sourceInfo:Rh.optional()}),pj=x({status:S([`ok`,`error`]),labels:C(u()).optional(),error:u().optional()}),mj=w(),hj={name:`device-provider`,scope:`system`,mode:`collection`,methods:{start:D(v(),v(),{kind:`mutation`}),stop:D(v(),v(),{kind:`mutation`}),getStatus:D(v(),cj),getDevices:D(v(),C(x({id:u(),name:u(),type:u()}))),reloadDevice:D(x({stableId:u()}),x({deviceId:r()}),{kind:`mutation`,timeoutMs:3*6e4}),supportsDiscovery:D(x({}),y()),discoverDevices:D(x({params:h(u(),w()).optional()}),C(dj),{kind:`mutation`,auth:`admin`}),getDiscoveryModes:D(x({}),C(lj)),classifyDiscoveryHits:D(x({hits:C(uj),params:h(u(),w()).optional()}),C(dj),{kind:`mutation`,auth:`admin`}),getDiscoveryParamsSchema:D(x({}),mj),getManualCreationType:D(x({integrationId:u().optional()}),x({deviceType:S(M).nullable()})),adoptDiscoveredDevice:D(x({candidate:dj,integrationId:u().optional()}),fj,{kind:`mutation`,auth:`admin`}),supportsManualCreation:D(x({}),y()),getChildCreationSchema:D(x({type:S(M),integrationId:u().optional()}),mj),createDevice:D(x({type:S(M),config:h(u(),w()),integrationId:u().optional()}),fj,{kind:`mutation`,auth:`admin`}),testCreationField:D(x({type:S(M),key:u(),value:w(),formValues:h(u(),w()).optional()}),pj,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.INTERNAL}},gj=a(`kind`,[x({kind:m(`mdns`),serviceType:u(),instance:u(),host:u(),address:u().nullable(),port:r().int(),txt:h(u(),u())}),x({kind:m(`ssdp`),host:u(),port:r().int(),target:u(),headers:h(u(),u())})]),tbe=x({addonId:u(),candidate:dj,firstSeenAt:r(),lastSeenAt:r(),dismissed:y()}),_j=x({id:u(),addonId:u(),candidate:dj,firstSeenAt:r(),lastSeenAt:r(),dismissed:y()}),vj=x({childKey:u(),section:u(),order:r().optional(),collapsed:y().optional()}),nbe=x({unit:u().min(1).optional(),precision:r().int().min(0).max(10).optional()}),yj=x({icon:u().min(1).optional(),label:u().min(1).optional(),unit:u().min(1).optional(),precision:r().int().min(0).max(10).optional(),hidden:y().optional(),perCap:h(u(),nbe).optional()}),bj=x({unit:u().min(1).optional(),precision:r().int().min(0).max(10).optional(),icon:u().min(1).optional()}),xj=x({id:r(),stableId:u(),addonId:u(),type:S(M),name:u(),alias:Nk.optional(),location:u().nullable(),tags:Td.optional(),disabled:y(),parentDeviceId:r().nullable(),role:u().nullable().optional(),online:y(),probed:y().optional(),features:C(u()),isCamera:y(),config:h(u(),w()),secretConfigPaths:C(u()).optional(),metadata:h(u(),w()).nullable().optional(),identifiers:wA.optional(),attachedIdentifiers:wA.optional(),sourceInfo:Rh.optional(),integrationId:u().optional(),linkDeviceId:r().nullable().optional(),primaryChildEntityId:u().nullable().optional(),childLayout:C(vj).readonly().optional(),primaryChildPreference:C(u()).readonly().optional(),display:yj.optional()}),Sj=x({key:u(),value:w(),description:u().optional()}),Cj=S([`manual`]),wj=x({deviceId:r(),name:u(),location:u().nullable(),features:C(u()),producesTrackedEvents:y().optional()}),Tj=x({deviceIds:C(r().int().positive()),trackedDeviceIds:C(r().int().positive()).optional()}),Ej={id:`linked-devices`,label:`Linked devices`,description:`Companion devices of this camera: their controls appear with it, and the ones you opt in produce tracked events on it.`,shape:`association`,hostDeviceTypes:[M.Camera],sourceCaps:`any`,cardinality:`many`,value:Tj},rbe=x({deviceId:r(),mode:Cj,devices:C(wj)}),Dj=x({deviceId:r(),entries:C(x({capName:u(),kind:S([`native`,`wrapped`]),providerAddonId:u(),providerNodeId:u(),nativeAddonId:u(),implementedMethods:C(u()).optional()}))}),Oj=a(`kind`,[x({kind:m(`value`),wrapperAddonId:u().nullable()}),x({kind:m(`missing`)}),x({kind:m(`failed`),error:u()})]),ibe=x({id:r(),stableId:u(),type:u(),name:u(),location:u().nullable(),tags:Td.optional(),disabled:y(),parentDeviceId:r().nullable(),role:u().nullable().optional()}),abe=x({id:r(),stableId:u(),addonId:u(),type:u(),name:u(),userNamed:y().optional(),location:u().nullable(),tags:Td.optional(),disabled:y(),parentDeviceId:r().nullable(),metadata:h(u(),w()).nullable().optional(),identifiers:wA.optional(),attachedIdentifiers:wA.optional(),sourceInfo:Rh.optional(),integrationId:u().optional(),linkDeviceId:r().nullable().optional(),primaryChildEntityId:u().nullable().optional(),childLayout:C(vj).readonly().optional(),primaryChildPreference:C(u()).readonly().optional(),role:u().nullable().optional(),display:yj.optional()}),obe=w().nullable(),sbe=x({streamId:u(),width:r().optional(),height:r().optional(),codec:u().optional(),fps:r().optional(),bitrateKbps:r().optional()}),cbe=x({addonId:u(),stableId:u(),id:r(),type:u(),name:u(),location:u().nullable().optional(),disabled:y().optional(),parentDeviceId:r().nullable(),role:u().nullable().optional(),features:C(u()).optional(),config:h(u(),w()),secretConfigPaths:C(u()).optional()}),kj=x({deviceId:r().int().positive(),deletedAt:r(),providerAddonId:u()}),Aj=2160*60*60*1e3,jj=x({deviceId:r().int().positive(),stores:h(u(),r().int().nonnegative())}),Mj=x({status:S([`skipped`,`dry-run`,`cleaned`]),reason:u().nullable(),devices:C(jj),unreachable:C(u())}),lbe=x({deviceId:r()}),ube=x({deviceId:r(),data:h(u(),w()),secretConfigPaths:C(u()).optional()}),Nj=S([`off`,`on`,`not-offered`,`unreachable`]),Pj=x({deviceId:r(),switchId:ao,outcome:Nj,detail:u().optional()}),Fj=x({sourceId:r(),targetId:r(),switches:C(Pj).readonly(),sourceStillLive:C(ao).readonly(),swapped:y()}),Ij={name:`device-manager`,scope:`system`,mode:`singleton`,extensionSlots:[Ej],methods:{allocateDeviceId:D(x({addonId:u(),stableId:u()}),x({id:r()}),{kind:`mutation`}),migrateDevice:D(x({sourceId:r(),targetId:r()}),Fj,{kind:`mutation`,auth:`admin`,timeoutMs:12*6e4}),registerDevice:D(cbe,v(),{kind:`mutation`}),removeDevice:D(lbe,v(),{kind:`mutation`}),persistConfig:D(ube,v(),{kind:`mutation`,auth:`admin`}),loadConfig:D(x({deviceId:r()}),h(u(),w()),{auth:`admin`}),loadRuntimeState:D(x({deviceId:r()}),h(u(),w()),{auth:`admin`}),loadMeta:D(x({deviceId:r()}),abe.nullable()),setName:D(x({deviceId:r(),name:u(),stampUserNamed:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),setAlias:D(x({deviceId:r(),alias:u()}),a(`ok`,[x({ok:m(!0),alias:Nk}),x({ok:m(!1),reason:S([`empty`,`too-long`,`grammar`,`reserved`,`taken`]),takenBy:r().optional()})]),{kind:`mutation`,auth:`admin`}),renderDeviceTemplates:D(x({templates:C(aA).max(64),allowedDeviceIds:C(r().int()).optional(),thisDevice:sA.optional()}),x({results:C(fA)}),{auth:`admin`}),checkDeviceTemplates:D(x({templates:C(u()).max(64),allowedDeviceIds:C(r().int()).optional(),thisDevice:sA.optional()}),x({results:C(a(`ok`,[x({ok:m(!0),aliases:C(x({alias:u(),deviceId:r().int().nullable(),allowed:y(),reads:C(u())})),readsClock:y()}),x({ok:m(!1),refusal:lA})]))}),{auth:`admin`}),setLocation:D(x({deviceId:r(),location:u().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setTags:D(x({deviceId:r(),tags:Td}),v(),{kind:`mutation`,auth:`admin`}),setType:D(x({deviceId:r(),type:S(M)}),v(),{kind:`mutation`,auth:`admin`}),setIntegrationId:D(x({deviceId:r(),integrationId:u()}),v(),{kind:`mutation`,auth:`admin`}),setLinkDeviceId:D(x({deviceId:r(),linkDeviceId:r().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildEntityId:D(x({deviceId:r(),primaryChildEntityId:u().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setChildLayout:D(x({deviceId:r(),childLayout:C(vj).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildPreference:D(x({deviceId:r(),primaryChildPreference:C(u()).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setDisplay:D(x({deviceId:r(),display:yj.nullable()}),v(),{kind:`mutation`,auth:`admin`}),getRoleDisplayDefaults:D(x({}),x({defaults:h(u(),bj)}),{role:`viewer`,kind:`query`}),setRoleDisplayDefaults:D(x({defaults:h(u(),bj)}),v(),{kind:`mutation`,auth:`admin`}),getWireableFields:D(x({deviceId:r(),includeSynthesizable:y().optional()}),x({caps:C(x({cap:u(),fields:C(x({path:u(),kind:S([`string`,`number`,`boolean`,`enum`,`union`]),unionMembers:C(S([`string`,`number`,`boolean`])).optional(),enumValues:C(u()).optional(),item:y().optional(),quantity:bc.optional()})).readonly(),itemArray:x({path:u(),keyField:u()}).optional()})).readonly()}),{kind:`query`}),setRole:D(x({deviceId:r(),role:u().nullable()}),v(),{kind:`mutation`,auth:`admin`}),applyInitialMeta:D(x({deviceId:r(),name:u().optional(),location:u().nullable().optional(),tags:Td.optional(),type:S(M).optional(),integrationId:u().optional(),linkDeviceId:r().nullable().optional(),role:u().nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),setMetadata:D(x({deviceId:r(),patch:h(u(),w())}),v(),{kind:`mutation`,auth:`admin`}),setIdentifiers:D(x({deviceId:r(),identifiers:wA.nullable(),unread:C(vA).optional()}),v(),{kind:`mutation`,auth:`admin`}),listIdentityCandidates:D(x({}),zA,{kind:`query`,auth:`admin`}),setAttachedIdentifiers:D(x({deviceId:r(),identifiers:wA.nullable(),unread:C(vA).optional()}),v(),{kind:`mutation`,auth:`admin`}),listIdentityLinks:D(x({deviceId:r().int().optional()}),YA,{kind:`query`,auth:`admin`}),confirmIdentityLink:D(x({linkId:u().min(1)}),ZA,{kind:`mutation`,auth:`admin`}),dismissIdentityLink:D(x({linkId:u().min(1)}),ZA,{kind:`mutation`,auth:`admin`}),unlinkIdentity:D(x({linkId:u().min(1)}),ZA,{kind:`mutation`,auth:`admin`}),listLocations:D(v(),C(u())),addLocation:D(x({name:u()}),v(),{kind:`mutation`,auth:`admin`}),removeLocation:D(x({name:u(),cascade:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),renameLocation:D(x({from:u(),to:u()}),x({moved:r()}),{kind:`mutation`,auth:`admin`}),listLocationIcons:D(v(),C(tm),{role:`viewer`}),setLocationIcon:D(x({location:u(),icon:md.nullable()}),v(),{kind:`mutation`,auth:`admin`}),listLocationDescriptions:D(v(),C(rm)),setLocationDescription:D(x({location:u(),description:u().max(400).nullable()}),v(),{kind:`mutation`,auth:`admin`}),listSiteZones:D(v(),C(gA),{role:`viewer`}),setSiteZone:D(x({name:u(),icon:md.nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),removeSiteZone:D(x({name:u()}),v(),{kind:`mutation`,auth:`admin`}),renameSiteZone:D(x({from:u(),to:u()}),v(),{kind:`mutation`,auth:`admin`}),setLocationZone:D(x({location:u(),zone:u().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setDisabled:D(x({deviceId:r(),disabled:y()}),v(),{kind:`mutation`,auth:`admin`}),listPersistedByAddon:D(x({addonId:u()}),C(ibe)),listAll:D(x({addonId:u().optional(),projection:S([`full`,`slim`]).optional(),isCamera:y().optional(),deviceIds:C(r()).optional()}),C(xj),{role:`viewer`}),search:D(tj,sj,{role:`viewer`}),getDevice:D(x({deviceId:r()}),xj.nullable()),getChildren:D(x({parentDeviceId:r()}),C(xj),{role:`viewer`}),getChildrenBatch:D(x({parentDeviceIds:C(r()).max(256)}),h(u(),C(xj))),getLinkedDevices:D(x({deviceId:r()}),x({mode:Cj,devices:C(wj)}),{role:`viewer`}),getLinkedDevicesBatch:D(x({deviceIds:C(r())}),C(rbe),{role:`viewer`}),getStreamSources:D(x({deviceId:r()}),C(Ic)),getConfigSchema:D(x({deviceId:r()}),C(Sj)),getSettingsSchema:D(x({deviceId:r()}),obe),updateConfig:D(x({deviceId:r(),values:h(u(),w())}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),enable:D(x({deviceId:r()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),disable:D(x({deviceId:r()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),remove:D(x({deviceId:r()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),listDeletedSince:D(x({sinceMs:r()}),C(kj).readonly(),{auth:`admin`}),cleanupDeletedDevicesData:D(x({confirm:y()}),Mj,{kind:`mutation`,auth:`admin`}),removeByIntegration:D(x({integrationId:u()}),x({removed:r()}),{kind:`mutation`,auth:`admin`}),getStreamProfileMap:D(x({deviceId:r()}),h(u(),u().nullable())),setStreamProfileMap:D(x({deviceId:r(),profileMap:h(u(),u().nullable())}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),probeStreams:D(x({deviceId:r()}),C(sbe),{kind:`mutation`,auth:`admin`}),getBindings:D(x({deviceId:r()}),Dj,{role:`viewer`}),getBindingsBatch:D(x({deviceIds:C(r())}),C(Dj)),getAllBindings:D(x({}),C(Dj)),listDeviceIdsByCaps:D(x({capNames:C(u().min(1)).min(1).max(16)}),C(r()),{role:`viewer`}),setWrapperActive:D(x({deviceId:r(),capName:u(),wrapperAddonId:u(),active:y()}),v(),{kind:`mutation`,auth:`admin`}),getWrapperActivation:D(x({deviceId:r(),capName:u().min(1)}),Oj),listWrappersForCap:D(x({capName:u()}),C(u())),listBindableCapsForDeviceType:D(x({deviceType:u()}),C(x({capName:u(),wrappers:C(u())}))),getDeviceSettingsAggregate:D(x({deviceId:r()}),iy.nullable()),getDeviceLiveInfoAggregate:D(x({deviceId:r()}),iy.nullable(),{role:`viewer`}),getDeviceAggregate:D(x({deviceId:r()}),x({settings:iy.nullable(),live:iy.nullable()})),runDeviceAction:D(x({deviceId:r().int().nonnegative(),action:u().min(1),input:w()}),w(),{kind:`mutation`}),updateDeviceField:D(x({deviceId:r(),writerCapName:u(),writerAddonId:u(),key:u(),value:w()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),updateDeviceFieldsBatch:D(x({deviceId:r(),changes:C(x({writerCapName:u(),writerAddonId:u(),key:u(),value:w()}))}),x({success:m(!0),failures:C(x({writerCapName:u(),writerAddonId:u(),error:u()}))}),{kind:`mutation`,auth:`admin`}),discoverDevices:D(x({addonId:u()}),C(dj),{kind:`mutation`,auth:`admin`}),adoptDevice:D(x({addonId:u(),candidate:dj,integrationId:u().optional()}),fj,{kind:`mutation`,auth:`admin`}),getCreationSchema:D(x({addonId:u(),type:S(M),integrationId:u().optional()}),w().nullable()),createDevice:D(x({addonId:u(),type:S(M),config:h(u(),w()),integrationId:u().optional()}),fj,{kind:`mutation`,auth:`admin`}),testCreationField:D(x({addonId:u(),type:S(M),key:u(),value:w(),formValues:h(u(),w()).optional()}),pj,{kind:`mutation`,auth:`admin`}),adoptionListCandidateFilters:D(x({addonId:u(),integrationId:u()}),x({filters:C(_k)}),{auth:`admin`}),adoptionListCandidates:D(yk.extend({addonId:u()}),bk,{auth:`admin`}),adoptionRefresh:D(x({addonId:u(),integrationId:u()}),Sk,{kind:`mutation`,auth:`admin`}),adoptionAdopt:D(Ck.extend({addonId:u()}),wk,{kind:`mutation`,auth:`admin`}),adoptionRelease:D(Tk.extend({addonId:u()}),v(),{kind:`mutation`,auth:`admin`}),adoptionStartJob:D(Ck.extend({addonId:u()}),x({jobId:u()}),{kind:`mutation`,auth:`admin`}),adoptionListJobs:D(x({addonId:u(),integrationId:u().optional()}),C(jre).readonly(),{auth:`admin`}),adoptionCancelJob:D(x({jobId:u()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),adoptionResync:D(Ek,Dk,{kind:`mutation`,auth:`admin`}),discoveryProviders:D(x({}),x({providers:C(x({addonId:u(),label:u()})).readonly()}),{auth:`admin`}),discoverAllProviders:D(x({subnets:C(u()).optional()}),x({groups:C(x({addonId:u(),label:u(),candidates:C(dj).readonly(),error:u().nullable()})).readonly()}),{kind:`mutation`,auth:`admin`}),discoverProvider:D(x({addonId:u(),params:h(u(),w()).optional(),subnets:C(u()).optional()}),x({candidates:C(dj).readonly()}),{kind:`mutation`,auth:`admin`}),listDiscoveryProposals:D(x({}),x({proposals:C(_j).readonly()}),{auth:`admin`}),dismissDiscoveryProposal:D(x({id:u()}),x({dismissed:y()}),{kind:`mutation`,auth:`admin`}),reportDiscoveryObservations:D(x({observations:C(gj).max(512)}),x({proposed:r().int()}),{kind:`mutation`,auth:`admin`}),runDiscoverySweep:D(x({}),x({providers:r().int(),proposed:r().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),providerCreationType:D(x({addonId:u(),integrationId:u().optional()}),x({deviceType:S(M).nullable()}),{auth:`admin`}),providerDiscoveryParamsSchema:D(x({addonId:u()}),w(),{auth:`admin`}),testField:D(x({deviceId:r(),key:u(),value:w()}),pj,{kind:`mutation`,auth:`admin`}),getDeviceStatusAggregate:D(x({deviceId:r(),caps:C(u()).readonly().optional()}),h(u(),w().nullable())),getDeviceStatusAggregateBatch:D(x({deviceIds:C(r()).readonly(),caps:C(u()).readonly().optional()}),h(u(),h(u(),w().nullable())),{role:`viewer`})},vocabulary:{notOperatorFacing:`the device registry itself — rename, move and remove are administration`}},Lj=[`linked-devices`],Rj=S(Lj),zj={"linked-devices":{descriptor:Ej,declaringCap:`device-manager`,hostDeviceTypes:[M.Camera]}},Bj=a(`slot`,[Tj.extend({slot:m(`linked-devices`)})]),Vj=[M.Camera],dbe=`listSlots`,Hj=a(`state`,[x({state:m(`ok`)}),x({state:m(`unreachable`),reason:u()})]),Uj=x({source:u(),label:u(),addonId:u().optional(),availability:Hj}),Wj=S([`ok`,`missing`,`foreign`,`unavailable`]),Gj=x({deviceId:r().int(),name:u().nullable(),health:Wj,detail:u().optional()}),Kj=x({state:S([`active`,`inactive`,`unknown`]),authority:u(),detail:u().optional()}),qj=x({state:m(`ok`),slotRef:u(),slot:Rj,authority:u(),activation:Kj.nullable(),value:Bj,sources:C(Gj),impliedSources:C(Gj).optional()}),Jj=x({state:m(`unreachable`),addonId:u(),reason:u()}),Yj=a(`state`,[qj,Jj]);function fbe(e,t){return{state:`unreachable`,addonId:e,reason:t}}var Xj=x({deviceId:r().int(),name:u(),type:u(),location:u().nullable(),parentName:u().nullable(),suggested:y(),reason:u().nullable()}),Zj=x({candidates:C(Xj)}),Qj=x({applied:m(!0),reload:S([`none`,`host`,`parent`])}),$j=x({deviceId:r().int(),slotRef:u().min(1)}),eM=$j.extend({value:Bj}),tM={name:`device-extension`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:Vj,deviceConfig:{ui:{kind:`widget`,widgetId:`host/extensions-panel`,tab:`general`,label:`Extensions`,order:72}},methods:{listSources:D(x({deviceId:r().int()}),C(Uj)),listSlots:D(x({deviceId:r().int()}),C(Yj)),listCandidates:D($j,Zj),setSlot:D(eM,Qj,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:L(`Device extension`,`Estensione del dispositivo`),order:3100}},nM=a(`kind`,[x({kind:m(`device`),deviceId:r().int()}),x({kind:m(`node`),nodeId:u().min(1)})]),rM=S([`gauge`,`counter`,`boolean`,`enum`]),iM=S([`gauge`,`counter`,`boolean`]),aM=`derived:energy.kwh`,oM=S([`raw`,`5m`,`1h`,`1d`]),sM=S([`undeclared`,`not-owner`,`opted-out`,`not-a-real-device`,`rate`,`ingest-mismatch`,`out-of-range`]),pbe=x({key:u(),reason:sM,count:r().int()}),cM=x({accepted:r().int(),refused:C(pbe).readonly()}),lM=x({key:u(),scope:u(),kind:rM,unit:u().nullable(),displayName:u(),source:S([`cap`,`addon`,`derived`]),values:C(u()).readonly().nullable(),firstTs:r(),lastTs:r()}),mbe=x({t:r(),samples:r().int(),mean:r().nullable(),twMean:r().nullable(),min:r(),max:r(),last:r().nullable(),delta:r().nullable(),state:u().nullable(),states:h(u(),r()).nullable()}),hbe=x({scope:u(),before:x({t:r(),value:r().nullable(),state:u().nullable()}).nullable(),points:C(mbe).readonly(),derivedFrom:u().nullable()}),uM={key:u(),scope:u().optional(),from:r(),to:r(),resolution:g([oM,m(`auto`)]).default(`auto`),maxPoints:r().int().positive().max(5e3).default(1e3)},dM=x({resolution:oM,series:C(hbe).readonly(),truncated:y()}),gbe=g([x({deviceId:r().int(),key:u(),scope:u().optional()}),x({forNodeId:u().min(1),key:u(),scope:u().optional()})]),_be=a(`ok`,[x({ok:m(!0),result:dM}),x({ok:m(!1),error:u()})]),vbe=x({tier:oM,rows:r().int().nullable(),approxBytes:r().nullable(),countedAt:r().nullable()}),fM=S([`device-gone`,`undeclared`]),pM=x({raw:r().int(),"5m":r().int(),"1h":r().int(),"1d":r().int()}),ybe=x({seriesId:r().int(),deviceId:r().int(),key:u(),scope:u(),displayName:u().nullable(),reason:fM,missingSince:r().nullable(),firstTs:r(),lastTs:r(),rows:pM}),mM=S([`not-found`,`not-orphan`,`failed`]),bbe=a(`ok`,[x({seriesId:r().int(),ok:m(!0),deleted:pM}),x({seriesId:r().int(),ok:m(!1),reason:mM})]),xbe=x({series:C(ybe).readonly(),truncated:y()}),hM=S([`invalid-range`,`range-too-large`,`series-not-found`,`not-a-point-series`]),Sbe=x({"5m":r().int(),"1h":r().int(),"1d":r().int()}),Cbe=a(`ok`,[x({ok:m(!0),dryRun:y(),seriesId:r().int(),rows:pM,rewritten:Sbe.nullable()}),x({ok:m(!1),reason:hM})]),gM=x({startedAt:r(),ready:y(),series:r().int(),metrics:r().int(),optedOutDevices:r().int(),tiers:C(vbe).readonly(),capture:x({eventsSeen:r().int(),pointsEmitted:r().int(),pointsWritten:r().int(),pointsDropped:r().int(),bufferDepth:r().int(),trailingEmitted:r().int(),reconciledPoints:r().int(),reconcileRuns:r().int(),reconcileFailures:r().int(),lastReconcileAt:r().nullable(),lastFlushAt:r().nullable(),flushFailures:r().int(),skipped:h(u(),r().int())}),ingest:x({accepted:r().int(),refused:h(u(),r().int())}),rollup:x({last5mAt:r().nullable(),last1hAt:r().nullable(),last1dAt:r().nullable(),errors:r().int(),dirty5m:r().int(),dirty1h:r().int(),dirty1d:r().int()}),retention:x({lastRunAt:r().nullable(),deleted:h(u(),r().int()),purgedSeries:r().int()}),directory:x({devices:r().int(),lastRefreshAt:r().nullable()})}),_M={name:`device-history`,scope:`system`,mode:`singleton`,methods:{listSeries:D(x({deviceId:r().int()}),C(lM).readonly()),listNodeSeries:D(x({forNodeId:u().min(1)}),C(lM).readonly(),{auth:`admin`}),query:D(x({deviceId:r().int(),...uM}),dM),queryNode:D(x({forNodeId:u().min(1),...uM}),dM,{auth:`admin`}),queryMany:D(x({items:C(gbe).min(1).max(24),from:uM.from,to:uM.to,resolution:uM.resolution,maxPoints:uM.maxPoints}),x({results:C(_be).readonly()}),{auth:`admin`}),declareSeries:D(x({name:u().regex(/^[a-z0-9-]+$/),subjectKind:S([`device`,`node`]),kind:iM,unit:u().optional(),displayName:u().min(1),ingest:S([`points`,`buckets`])}),x({key:u()}),{kind:`mutation`,auth:`admin`}),record:D(x({points:C(x({key:u(),subject:nM,scope:u().default(``),ts:r(),value:r()})).max(5e3)}),cM,{kind:`mutation`,auth:`admin`}),recordBuckets:D(x({buckets:C(x({key:u(),subject:nM,scope:u().default(``),bucketStart:r(),samples:r().int().positive(),sum:r(),min:r(),max:r(),last:r().nullable(),lastTs:r().nullable()})).max(5e3)}),cM,{kind:`mutation`,auth:`admin`}),getDeviceEnabled:D(x({deviceId:r().int()}),x({enabled:y()})),setDeviceEnabled:D(x({deviceId:r().int(),enabled:y()}),x({enabled:y()}),{kind:`mutation`,auth:`admin`}),getStatus:D(x({}),gM,{auth:`admin`}),listOrphanSeries:D(x({}),xbe,{auth:`admin`}),deleteOrphanSeries:D(x({seriesIds:C(r().int()).min(1).max(50)}),x({results:C(bbe).readonly()}),{kind:`mutation`,auth:`admin`}),deleteSeriesRange:D(x({deviceId:r().int(),key:u().min(1),scope:u(),fromMs:r().int().nonnegative(),toMs:r().int().nonnegative(),dryRun:y()}),Cbe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`recorded history of device state — read by charts, not actuated`}},wbe=x({id:u(),label:u(),protocol:S([`rtsp`,`rtmp`,`annexb`,`http-mjpeg`,`webrtc`,`custom`]),url:u().optional(),resolution:x({width:r(),height:r()}).optional(),fps:r().optional(),bitrate:r().optional(),codec:u().optional(),profileHint:j.optional(),sdp:u().optional()}),Tbe=x({key:u(),value:w()}),vM=x({source:u(),data:h(u(),w())}),yM={name:`device-ops`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getStreamSources:D(x({deviceId:r()}),C(wbe)),getConfigEntries:D(x({deviceId:r()}),C(Tbe)),setConfig:D(x({deviceId:r(),values:h(u(),w())}),v(),{kind:`mutation`,auth:`admin`}),runAction:D(x({deviceId:r(),action:u().min(1),input:w()}),w(),{kind:`mutation`,notOperatorFacing:`a provider-defined custom action whose id and input only the addon knows; it reaches the picker through the custom-actions surface, not a fixed phrase`}),removeDevice:D(x({deviceId:r()}),v(),{kind:`mutation`,auth:`admin`}),getSettingsSchema:D(x({deviceId:r()}),w().nullable()),getRawState:D(x({deviceId:r()}),vM.nullable(),{auth:`protected`})},vocabulary:{noun:L(`Device operations`,`Operazioni del dispositivo`),order:3110}},bM=x({deviceId:r().int().positive(),deletedAt:r(),providerAddonId:u()}),xM=x({counts:h(u(),r().int().nonnegative())}),SM=x({store:u(),deviceId:r().int().positive(),count:r().int().nonnegative()}),CM={name:`device-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onDeviceRemoved:D(bM,xM,{kind:`mutation`,auth:`admin`}),listDeviceData:D(v(),C(SM).readonly(),{auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.INTERNAL}},wM=S([`appliance`,`mower`,`vacuum`]),TM=S([`open`,`closed`]),EM=S([`completed`,`aborted`,`error`,`unknown`]),DM=S([`running-state`,`activity`,`reconcile`]),OM=S([`counter-delta`,`history-integral`]),kM=x({phase:u(),at:r()}),AM=x({kind:m(`appliance`),energyKwh:r().nullable().meta(A(`energy`)),energyMethod:OM.nullable(),peakW:r().nullable().meta(A(`power`)),avgW:r().nullable().meta(A(`power`)),program:u().nullable(),remainingAtStartSec:r().nullable().meta(A(`duration`)),finalPhase:u().nullable(),energyStartKwh:r().nullable().meta(A(`energy`)),powerObservedMs:r()}),jM=a(`kind`,[AM]),MM=x({runId:u(),deviceId:r().int(),kind:wM,state:TM,startedAt:r(),endedAt:r().nullable(),durationMs:r().nullable(),outcome:EM.nullable(),startSource:DM,endSource:DM.nullable(),runningSource:S([`native`,`assigned`]).nullable(),phases:C(kM),detail:jM}),NM={name:`device-runs`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Washer,M.Dryer,M.Dishwasher],methods:{listRuns:D(x({deviceId:r().int(),outcome:EM.optional(),atFrom:r().optional(),atTo:r().optional(),limit:r().int().positive().max(200).default(50),cursor:u().optional()}),x({runs:C(MM).readonly(),nextCursor:u().nullable()})),getRun:D(x({deviceId:r().int(),runId:u()}),MM.nullable()),getCurrentRun:D(x({deviceId:r().int()}),MM.nullable())},events:{onRunOpened:{data:MM,notOperatorFacing:`the durable record of a run that the running-state start flip already announces`},onRunClosed:{data:MM,notOperatorFacing:`the durable record of a run that the running-state finish flip already announces`}},vocabulary:{noun:L(`Runs`,`Esecuzioni`),order:2130}},PM=S([`replace`,`add`]),FM=a(`ok`,[x({ok:m(!0),changed:y()}),x({ok:m(!1),code:S([`owned-by-other`,`not-claimed`,`field-not-claimed`,`invalid-slice`,`unknown-device`,`row-unreadable`,`migration-in-flight`]),message:u()})]),IM=x({deviceId:r(),capName:u(),owner:u().min(1),mode:PM,fields:C(u().min(1)).min(1)}),LM=a(`state`,[x({state:m(`loaded`),claims:C(IM)}),x({state:m(`not-loaded`),reason:u()})]),RM={name:`device-state`,scope:`system`,mode:`singleton`,methods:{getSnapshot:D(x({deviceId:r()}),h(u(),h(u(),w()))),getCapSlice:D(x({deviceId:r(),capName:u(),confirmed:y().optional()}),h(u(),w()).nullable()),getAllSnapshots:D(x({confirmed:y().optional()}),h(u(),h(u(),h(u(),w())))),setCapSlice:D(x({deviceId:r(),capName:u(),slice:h(u(),w())}),v(),{kind:`mutation`}),claimFields:D(x({deviceId:r(),capName:u(),owner:u().min(1),mode:PM,fields:C(u().min(1)).min(1),values:h(u(),w())}),FM,{kind:`mutation`,auth:`admin`}),patchOwnedFields:D(x({deviceId:r(),capName:u(),owner:u().min(1),values:h(u(),w())}),FM,{kind:`mutation`,auth:`admin`}),releaseClaim:D(x({deviceId:r(),capName:u(),owner:u().min(1)}),FM,{kind:`mutation`,auth:`admin`}),listClaims:D(x({ownerPrefix:u().optional()}),LM,{auth:`admin`}),getNativeCapSlice:D(x({deviceId:r(),capName:u()}),h(u(),w()).nullable(),{auth:`admin`})},events:{onChanged:Ei(x({deviceId:r(),capName:u(),slice:h(u(),w())}))},vocabulary:{notOperatorFacing:`the runtime-state mirror every trigger already reads through`}},zM=S([`schedule`,`command`,`burst`]),BM=S([`none`,`partial`,`full`]),VM=1e3,Ebe=x({integrationId:u().min(1),minIntervalMs:r().int().min(VM),intervalMs:r().int().positive().optional(),batch:y(),push:BM,heartbeatMs:r().int().positive().optional(),connectionEpoch:r().int().nonnegative().optional()});function Dbe(e){let t=e.intervalMs??0;return Math.max(e.minIntervalMs,t)}var HM=[3e3,1e4],UM=1e4,WM=2e3;function Obe(e){let t=HM.filter(t=>t<e),n=e-WM,r=(t[t.length-1]??0)+UM;for(;r<n;)t.push(r),r+=UM;let i=t[t.length-1];return(i===void 0?n>0:n-i>=1e3)&&t.push(n),t}var kbe=2500,GM=x({deviceId:r().int().nonnegative(),deviceIds:C(r().int().nonnegative()).min(1),reason:zM}),KM=x({deviceId:r().int().nonnegative()}),qM=x({ok:m(!0)}),JM=`the core schedules state refreshes itself; an operator never asks for one`,YM={name:`device-state-refresh`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{refresh:D(GM,qM,{kind:`mutation`,auth:`admin`,notOperatorFacing:JM}),resubscribe:D(KM,qM,{kind:`mutation`,auth:`admin`,notOperatorFacing:JM})},vocabulary:{noun:L(`State refresh`,`Aggiornamento dello stato`),order:3247}},XM=x({online:y(),lastChangedAt:r()}),ZM={name:`device-status`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onStatusChanged:{data:x({deviceId:r(),status:XM}),notOperatorFacing:"the `online` state trigger phrases both edges of this change"}},status:{schema:XM,kind:`push`},runtimeState:XM,durability:`restored`,history:{fields:{online:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Reachability`,`Raggiungibilità`),order:5260,state:[{kind:`boolean`,field:`online`,label:L(`Online`,`Online`),whenTrue:L(`When {device} comes back online`,`Quando {device} torna online`),whenFalse:L(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi`}],extraEvents:[{category:T.DeviceOnline,label:L(`Came online`,`Tornato online`),phrase:L(`When {device} comes back online`,`Quando {device} torna online`),icon:`wifi`},{category:T.DeviceOffline,label:L(`Went offline`,`Andato offline`),phrase:L(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi-off`}]}},QM=S([`not-kernel`,`invalid`]),$M=x({written:r().int().nonnegative(),refused:C(x({id:u(),reason:QM})).readonly()}),eN=x({rows:r().int().nullable(),lastWriteAt:r().nullable(),refused:h(u(),r())}),tN={name:`device-transitions`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Object.values(M).filter(e=>e!==M.Container),methods:{listTransitions:D(x({deviceId:r().int(),capName:u().optional(),actorKind:Io.optional(),outcome:Lo.optional(),atFrom:r().optional(),atTo:r().optional(),limit:r().int().positive().max(200).default(50),cursor:u().optional()}),x({transitions:C(Ro).readonly(),nextCursor:u().nullable()})),getTransition:D(x({deviceId:r().int(),id:u()}),Ro.nullable()),listRecentTransitions:Ti(x({actorKind:Io.optional(),outcome:Lo.optional(),atFrom:r().optional(),atTo:r().optional(),limit:r().int().positive().max(200).default(50),cursor:u().optional()}),x({transitions:C(Ro).readonly(),nextCursor:u().nullable()}),{auth:`admin`}),record:Ti(x({transitions:C(Ro).max(500)}),$M,{kind:`mutation`,auth:`admin`}),getStatus:Ti(x({}),eN,{auth:`admin`})},vocabulary:{noun:L(`Transitions`,`Transizioni`),order:2140}},nN=S([`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]),rN=S([`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]),iN=S([`available`,`offline`,`description-missing`]),aN=x({availability:iN,state:nN,operationState:rN.nullable(),program:u().nullable(),selectedProgram:u().nullable(),availablePrograms:C(u()),remaining:r().int().nonnegative().nullable().meta(A(`duration`)),delayedStart:r().int().nonnegative().nullable().meta(A(`duration`)),progress:r().min(0).max(100).nullable().meta(A(`percentage`)),doorOpen:y().nullable(),doorLocked:y().nullable(),remoteStartAllowed:y().nullable(),remoteControlActive:y().nullable(),localControlActive:y().nullable(),powerOn:y().nullable(),powerState:u().nullable(),filterCleaningDue:y().nullable(),machineCareDue:y().nullable(),machineCareRemainingRuns:r().int().nonnegative().nullable().meta(A(`count`)),halfLoad:y().nullable(),hygienePlus:y().nullable(),extraDry:y().nullable(),intensiveZone:y().nullable(),varioSpeedPlus:y().nullable(),childLock:y().nullable(),activeEvents:C(u()),errorCode:r().nullable().meta(A(`none`)),errorLabel:u().nullable(),lastFetchedAt:r()}),oN=r().int().nonnegative(),sN=g([y(),u(),r()]),cN=S([`none`,`read`,`readWrite`,`writeOnly`,`readStatic`]),lN=x({key:u(),name:u(),type:S([`boolean`,`number`,`enum`,`string`]),access:cN,available:y(),unit:u().nullable(),min:r().nullable(),max:r().nullable(),step:r().nullable(),enumValues:C(u()).nullable(),defaultValue:sN.nullable()}),uN=x({key:u(),name:u(),available:y(),options:C(lN)}),dN=x({availability:iN,supportsStart:y(),supportsPause:y(),supportsResume:y(),supportsStop:y(),supportsPower:y(),programs:C(uN),options:C(lN)}),fN={name:`dishwasher`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Dishwasher],methods:{start:D(x({deviceId:oN,program:u().min(1).optional(),options:h(u(),sN).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.start`,label:L(`Start cycle`,`Avvia il lavaggio`),phrase:L(`Start {device}`,`Avvia {device}`),icon:`play`,openArgs:[{key:`program`,label:L(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`},optional:!0}]}]}),pause:D(x({deviceId:oN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.pause`,label:L(`Pause`,`Metti in pausa`),phrase:L(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),resume:D(x({deviceId:oN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.resume`,label:L(`Resume`,`Riprendi`),phrase:L(`Resume {device}`,`Riprendi il lavaggio di {device}`),icon:`play`}]}),stop:D(x({deviceId:oN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.stop`,label:L(`Stop`,`Ferma`),phrase:L(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setProgram:D(x({deviceId:oN,program:u().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.program`,label:L(`Choose programme`,`Scegli il programma`),phrase:L(`Select the {program} programme on {device}`,`Seleziona il programma {program} su {device}`),icon:`list`,openArgs:[{key:`program`,label:L(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`}}]}]}),setPower:D(x({deviceId:oN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.powerOn`,label:L(`Power on`,`Accendi`),phrase:L(`Turn on {device}`,`Accendi {device}`),icon:`power`,args:{on:!0}},{id:`dishwasher.powerOff`,label:L(`Power off`,`Spegni`),phrase:L(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,args:{on:!1}}]}),setHalfLoad:D(x({deviceId:oN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.halfLoadOn`,label:L(`Half load on`,`Mezzo carico attivo`),phrase:L(`Turn on half load on {device}`,`Attiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!0}},{id:`dishwasher.halfLoadOff`,label:L(`Half load off`,`Mezzo carico spento`),phrase:L(`Turn off half load on {device}`,`Disattiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!1}}]}),setHygienePlus:D(x({deviceId:oN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.hygienePlusOn`,label:L(`Hygiene Plus on`,`Igiene Plus attiva`),phrase:L(`Turn on Hygiene Plus on {device}`,`Attiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!0}},{id:`dishwasher.hygienePlusOff`,label:L(`Hygiene Plus off`,`Igiene Plus spenta`),phrase:L(`Turn off Hygiene Plus on {device}`,`Disattiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!1}}]}),setExtraDry:D(x({deviceId:oN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.extraDryOn`,label:L(`Extra dry on`,`Asciugatura extra attiva`),phrase:L(`Turn on extra dry on {device}`,`Attiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!0}},{id:`dishwasher.extraDryOff`,label:L(`Extra dry off`,`Asciugatura extra spenta`),phrase:L(`Turn off extra dry on {device}`,`Disattiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!1}}]}),setIntensiveZone:D(x({deviceId:oN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.intensiveZoneOn`,label:L(`Intensive zone on`,`Zona intensiva attiva`),phrase:L(`Turn on the intensive zone on {device}`,`Attiva la zona intensiva su {device}`),icon:`flame`,args:{on:!0}},{id:`dishwasher.intensiveZoneOff`,label:L(`Intensive zone off`,`Zona intensiva spenta`),phrase:L(`Turn off the intensive zone on {device}`,`Disattiva la zona intensiva su {device}`),icon:`flame`,args:{on:!1}}]}),setVarioSpeedPlus:D(x({deviceId:oN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.varioSpeedOn`,label:L(`Speed boost on`,`Lavaggio rapido attivo`),phrase:L(`Turn on the speed boost on {device}`,`Attiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!0}},{id:`dishwasher.varioSpeedOff`,label:L(`Speed boost off`,`Lavaggio rapido spento`),phrase:L(`Turn off the speed boost on {device}`,`Disattiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!1}}]}),setChildLock:D(x({deviceId:oN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.childLockOn`,label:L(`Child lock on`,`Blocco bambini attivo`),phrase:L(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`dishwasher.childLockOff`,label:L(`Child lock off`,`Blocco bambini spento`),phrase:L(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setOption:D(x({deviceId:oN,key:u().min(1),value:sN}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw appliance option key/value; every option worth naming has its own action above`}),getOptions:D(x({deviceId:oN}),dN,{auth:`protected`})},status:{schema:aN,kind:`poll`},runtimeState:aN,durability:`session`,history:{fields:{progress:{kind:`gauge`,unit:`%`,deadband:2},state:{kind:`enum`},operationState:{kind:`enum`},remaining:{kind:`gauge`,unit:`s`,minIntervalMs:6e4},doorOpen:{kind:`boolean`},powerOn:{kind:`boolean`}}},vocabulary:{noun:L(`Dishwasher`,`Lavastoviglie`),order:2020,state:[{kind:`enum`,field:`state`,label:L(`Cycle`,`Ciclo`),values:[{value:`idle`,label:L(`Idle`,`Inattiva`)},{value:`running`,label:L(`Running`,`In funzione`),phrase:L(`When {device} starts a cycle`,`Quando {device} inizia un lavaggio`)},{value:`paused`,label:L(`Paused`,`In pausa`)},{value:`finished`,label:L(`Finished`,`Terminato`),phrase:L(`When {device} finishes`,`Quando {device} finisce il lavaggio`)},{value:`error`,label:L(`Error`,`Errore`),phrase:L(`When {device} reports an error`,`Quando {device} segnala un errore`)},{value:`unavailable`,label:L(`Unavailable`,`Non disponibile`)}],icon:`washing-machine`},{kind:`numeric`,field:`progress`,quantity:L(`the cycle progress`,`l’avanzamento del lavaggio`),label:L(`Progress`,`Avanzamento`),unit:`%`,icon:`loader`},{kind:`boolean`,field:`doorOpen`,label:L(`Door open`,`Sportello aperto`),whenTrue:L(`When the door of {device} opens`,`Quando si apre lo sportello di {device}`),whenFalse:L(`When the door of {device} closes`,`Quando si chiude lo sportello di {device}`),icon:`door-open`},{kind:`boolean`,field:`filterCleaningDue`,label:L(`Filter cleaning due`,`Pulizia filtro da fare`),whenTrue:L(`When {device} asks for its filter to be cleaned`,`Quando {device} chiede di pulire il filtro`),whenFalse:L(`When the filter reminder of {device} clears`,`Quando l’avviso filtro di {device} rientra`),icon:`funnel`},{kind:`boolean`,field:`machineCareDue`,label:L(`Machine care due`,`Manutenzione da fare`),whenTrue:L(`When {device} asks for a machine-care cycle`,`Quando {device} chiede un ciclo di manutenzione`),whenFalse:L(`When the machine-care reminder of {device} clears`,`Quando l’avviso di manutenzione di {device} rientra`),icon:`wrench`}]}},pN=`motion.audio.recording.live.heatmapScrub.person.vehicle.animal.package.sensor.control.face.plate.car.truck.bus.motorcycle.bicycle.airplane.boat.train.bird.dog.cat.horse.sheep.cow.elephant.bear.zebra.giraffe.package-delivered.package-picked-up.suitcase.backpack.handbag.contact.motion-sensor.smoke.flood.gas.carbon-monoxide.vibration.tamper.presence.enum-sensor.device-event.lock.cover.switch.siren.button.doorbell.appliance-cycle`.split(`.`),mN=`audio`,hN=[.3,.42,.55,.7,.85,1],gN=[`camstack`,`high-contrast`,`okabe-ito`];function Abe(e){return pN.includes(e)}function jbe(e){return gN.includes(e)}var _N={dark:`#0c0a09`,light:`#fafaf9`},Mbe=[`live`,`heatmapScrub`],vN=/^#[0-9a-fA-F]{6}$/;function yN(e,t){return Number.parseInt(e.slice(t,t+2),16)}function bN(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function xN(e){let t=bN(yN(e,1)),n=bN(yN(e,3)),r=bN(yN(e,5));return .2126*t+.7152*n+.0722*r}function Nbe(e,t){if(!vN.test(e)||!vN.test(t))return 0;let n=Math.max(xN(e),xN(t)),r=Math.min(xN(e),xN(t));return(n+.05)/(r+.05)}function SN(e){let t=bN(yN(e,1)),n=bN(yN(e,3)),r=bN(yN(e,5)),i=.4124564*t+.3575761*n+.1804375*r,a=.2126729*t+.7151522*n+.072175*r,o=.0193339*t+.119192*n+.9503041*r,s=e=>e>.008856?Math.cbrt(e):7.787*e+16/116,c=s(i/.95047),l=s(a),u=s(o/1.08883);return{L:116*l-16,a:500*(c-l),b:200*(l-u)}}function CN(e,t){if(e===0&&t===0)return 0;let n=Math.atan2(t,e)*180/Math.PI;return n<0?n+360:n}function Pbe(e,t){if(!vN.test(e)||!vN.test(t))return 0;let n=SN(e),r=SN(t),i=((Math.hypot(n.a,n.b)+Math.hypot(r.a,r.b))/2)**7,a=.5*(1-Math.sqrt(i/(i+25**7))),o=(1+a)*n.a,s=(1+a)*r.a,c=Math.hypot(o,n.b),l=Math.hypot(s,r.b),u=CN(o,n.b),d=CN(s,r.b),f=0;c*l!==0&&(f=d-u,f>180?f-=360:f<-180&&(f+=360));let p=2*Math.sqrt(c*l)*Math.sin(f*Math.PI/360),m=(n.L+r.L)/2,h=(c+l)/2,g=u+d;c*l!==0&&(Math.abs(u-d)>180&&(g+=g<360?360:-360),g/=2);let _=1-.17*Math.cos((g-30)*Math.PI/180)+.24*Math.cos(2*g*Math.PI/180)+.32*Math.cos((3*g+6)*Math.PI/180)-.2*Math.cos((4*g-63)*Math.PI/180),ee=30*Math.exp(-(((g-275)/25)**2)),te=h**7,v=2*Math.sqrt(te/(te+25**7)),ne=1+.015*(m-50)**2/Math.sqrt(20+(m-50)**2),y=1+.045*h,re=1+.015*h*_,ie=-Math.sin(2*ee*Math.PI/180)*v,ae=r.L-n.L,oe=l-c;return Math.sqrt((ae/ne)**2+(oe/y)**2+(p/re)**2+oe/y*ie*(p/re))}var Fbe={motion:`#d946ef`,audio:`#059eb8`,recording:`#ef4444`,live:`#8d7a00`,heatmapScrub:`#4b32ff`,person:`#11a64c`,vehicle:`#3b82f6`,animal:`#ea6a09`,package:`#924667`,sensor:`#624bbc`,control:`#944d24`,face:`#ed4f8d`,plate:`#4b7027`,car:`#9684cf`,truck:`#0f9b89`,bus:`#a734a9`,motorcycle:`#c1133a`,bicycle:`#0e6a9b`,airplane:`#7c9928`,boat:`#b17933`,train:`#ad6ca3`,bird:`#0f7c55`,dog:`#c82700`,cat:`#7268f2`,horse:`#cb795e`,sheep:`#b8636b`,cow:`#cb2969`,elephant:`#1158d2`,bear:`#8d5e00`,zebra:`#0097d6`,giraffe:`#8f61bb`,"package-delivered":`#cd3f9b`,"package-picked-up":`#388a08`,suitcase:`#666800`,backpack:`#ec5022`,handbag:`#a76ef8`,contact:`#ab5a49`,"motion-sensor":`#b95d1a`,smoke:`#dd3858`,flood:`#b31e7d`,gas:`#5b70b5`,"carbon-monoxide":`#7b4e8e`,vibration:`#e65bba`,tamper:`#98464b`,presence:`#3a9468`,"enum-sensor":`#7885f8`,"device-event":`#8c43c8`,lock:`#649653`,cover:`#c67597`,switch:`#7a812a`,siren:`#ac5d7f`,button:`#b276cd`,doorbell:`#0087ab`,"appliance-cycle":`#2a8c8c`},Ibe=[`#b34dc7`,`#1d7d34`,`#db6b6c`,`#a43d29`,`#0e6ee6`,`#29a10b`,`#a98731`,`#0181c6`],Lbe={motion:`#964360`,audio:`#23a132`,recording:`#2494ca`,live:`#bd7e2b`,heatmapScrub:`#ad6eea`,person:`#62611e`,vehicle:`#f4534c`,animal:`#1556cd`,package:`#9c4415`,sensor:`#066c48`,control:`#f2479f`,face:`#139d8a`,plate:`#909024`,car:`#8e35ab`,truck:`#bd0b2b`,bus:`#7a88ca`,motorcycle:`#e26725`,bicycle:`#a6679b`,airplane:`#7c5720`,boat:`#467a1b`,train:`#6f65a4`,bird:`#cb717f`,dog:`#c62490`,cat:`#b36850`,horse:`#1872ac`,sheep:`#927939`,cow:`#428a5c`,elephant:`#d41160`,bear:`#799453`,zebra:`#a85455`,giraffe:`#746be8`,"package-delivered":`#824a80`,"package-picked-up":`#614ac1`,suitcase:`#2f77f3`,backpack:`#fa476d`,handbag:`#c14cbe`,contact:`#c83921`,"motion-sensor":`#a07ebd`,smoke:`#a25b13`,flood:`#526bab`,gas:`#924938`,"carbon-monoxide":`#bb7e53`,vibration:`#b66182`,tamper:`#3c6931`,presence:`#6c851d`,"enum-sensor":`#ad2d48`,"device-event":`#5e9b04`,lock:`#00a062`,cover:`#ad8624`,switch:`#d05259`,siren:`#cd67b3`,button:`#c9746a`,doorbell:`#338eeb`,"appliance-cycle":`#00848a`},Rbe=[`#817f3b`,`#a0733e`,`#8658b2`,`#956301`,`#bc652d`,`#647331`,`#a14c9e`,`#d14e71`],zbe={motion:`#b88128`,audio:`#1096c8`,recording:`#009e73`,live:`#9c8c22`,heatmapScrub:`#0072b2`,person:`#d55e00`,vehicle:`#c0739f`,animal:`#226d18`,package:`#91446c`,sensor:`#217b56`,control:`#648647`,face:`#c22998`,plate:`#fa4575`,car:`#956301`,truck:`#2f77f3`,bus:`#7a4e86`,motorcycle:`#f54597`,bicycle:`#bb3e75`,airplane:`#e054c0`,boat:`#457942`,train:`#867afa`,bird:`#88914c`,dog:`#1556cd`,cat:`#71702c`,horse:`#9b4fa4`,sheep:`#c0559d`,cow:`#d14f65`,elephant:`#98470f`,bear:`#595896`,zebra:`#96790e`,giraffe:`#cb717b`,"package-delivered":`#139d8a`,"package-picked-up":`#906ead`,suitcase:`#d02939`,backpack:`#d41160`,handbag:`#f64f54`,contact:`#7258d2`,"motion-sensor":`#b66182`,smoke:`#627abb`,flood:`#b86ae4`,gas:`#a95261`,"carbon-monoxide":`#c65d3c`,vibration:`#7a40b7`,tamper:`#914b34`,presence:`#9481c3`,"enum-sensor":`#ac6d47`,"device-event":`#7b6fce`,lock:`#c67662`,cover:`#a6564d`,switch:`#ad2c4e`,siren:`#348e08`,button:`#d27303`,doorbell:`#55770f`,"appliance-cycle":`#00737d`},Bbe=[`#9a3784`,`#a7392c`,`#409d50`,`#6987e7`,`#ee5b3d`,`#c0430d`,`#af79b3`,`#4b6628`],wN=u().regex(/^#[0-9a-f]{6}$/),TN=a(`form`,[x({form:m(`solid`),hex:wN}),x({form:m(`gradient`),hex:wN,alphas:C(r().gt(0).lte(1)).length(hN.length)})]),EN=x({status:m(`ready`),presetId:S(gN),customized:y(),source:S([`stored`,`unconfigured`]),swatches:h(u(),TN),fallbacks:C(wN).length(8)}),DN=a(`status`,[EN,x({status:m(`unknown`),reason:u()})]),ON=g([x({presetId:u()}),x({presetId:u(),overrides:h(u(),TN)})]),kN=x({presetId:u(),overrides:h(u(),TN)});function Vbe(e){return{form:`solid`,hex:e}}function Hbe(e){return{form:`gradient`,hex:e,alphas:[...hN]}}function Ube(e){let t={};for(let n of pN){let r=e[n];if(r===void 0)throw Error(`palette table missing ${n}`);t[n]=n===`audio`?Hbe(r):Vbe(r)}return t}function AN(e,t,n,r){return{id:e,name:t,swatches:Ube(n),fallbacks:r}}var jN=[AN(`camstack`,`CamStack`,Fbe,Ibe),AN(`high-contrast`,`High contrast`,Lbe,Rbe),AN(`okabe-ito`,`Colour-blind safe`,zbe,Bbe)];function MN(e){return jN.find(t=>t.id===e)}function NN(){let e=MN(`camstack`);if(e===void 0)throw Error(`CamStack preset missing`);return Wbe(e,`unconfigured`,!1)}function Wbe(e,t,n){return{status:`ready`,presetId:e.id,customized:n,source:t,swatches:e.swatches,fallbacks:[...e.fallbacks]}}function Gbe(e){return e.hex}function Kbe(e,t){let n=[];for(let t of pN){let r=e[t];r!==void 0&&n.push({name:t,hex:r.hex})}return t.forEach((e,t)=>{n.push({name:`fallback-${t}`,hex:e})}),n}function qbe(e){let t=e[mN];return t===void 0||t.form===`gradient`&&hN.every((e,n)=>t.alphas[n]===e)?[]:[{code:`bad-gradient`,entry:mN}]}function Jbe(e,t){let n=Mbe;return n.includes(e)&&n.includes(t)}function PN(e,t){let n=[];for(let t of pN)e[t]===void 0&&n.push({code:`missing-entry`,entry:t});for(let t of Object.keys(e))Abe(t)||n.push({code:`unknown-entry`,entry:t});t.length!==8&&n.push({code:`bad-fallbacks`}),n.push(...qbe(e));let r=Kbe(e,t);for(let e=0;e<r.length;e++)for(let t=e+1;t<r.length;t++){let i=r[e],a=r[t];if(i===void 0||a===void 0)continue;let o=Pbe(i.hex,a.hex);o<(Jbe(i.name,a.name)?20:7)&&n.push({code:`too-close`,left:i.name,right:a.name,deltaE:o})}for(let e of r)for(let t of[`dark`,`light`]){let r=Nbe(e.hex,_N[t]);r<3&&n.push({code:`low-contrast`,entry:e.name,background:t,contrast:r})}return n.length===0?{ok:!0}:{ok:!1,violations:n}}function Ybe(e){switch(e.code){case`too-close`:return`${e.left} vs ${e.right} (ΔE ${e.deltaE.toFixed(1)})`;case`low-contrast`:return`${e.entry} on ${e.background} (${e.contrast.toFixed(1)}:1)`;case`missing-entry`:return`${e.entry} is missing`;case`unknown-entry`:return`${e.entry} is not a palette entry`;case`bad-gradient`:return`${e.entry} gradient is not the six canonical steps`;case`bad-fallbacks`:return`fallback list must hold eight colours`;case`unknown-preset`:return`${e.presetId} is not a preset`}}function FN(e){return e.map(Ybe).join(`; `)}var IN=class extends Error{violations;constructor(e){super(FN(e)),this.name=`PaletteRejectedError`,this.violations=e}};function LN(e,t){let n=0;for(let t=0;t<e.length;t++)n=n*31+(e.codePointAt(t)??0)>>>0;let r=t[n%t.length];if(r===void 0)throw Error(`display palette has no fallback colour`);return r}function RN(e,t,n){let r=n.trim().toLowerCase();if(r.startsWith(`audio-`)){let n=e[mN];return n===void 0?LN(r,t):n.hex}let i=e[r];return i===void 0?LN(r,t):i.hex}function zN(e,t){return{...e,...t}}function Xbe(e){return`overrides`in e?e.overrides:{}}function Zbe(e){let t=MN(e.presetId);if(t===void 0||!jbe(e.presetId))throw new IN([{code:`unknown-preset`,presetId:e.presetId}]);let n=Xbe(e),r=zN(t.swatches,n),i=PN(r,t.fallbacks);if(!i.ok)throw new IN(i.violations);let a=Object.keys(n).length>0;return{status:`ready`,presetId:t.id,customized:a,source:`stored`,swatches:r,fallbacks:[...t.fallbacks]}}function Qbe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function $be(e){if(e==null||Qbe(e))return NN();let t=kN.safeParse(e);if(!t.success)return{status:`unknown`,reason:`stored palette is unreadable`};let n=MN(t.data.presetId);if(n===void 0)return{status:`unknown`,reason:`unknown preset ${t.data.presetId}`};let r=zN(n.swatches,t.data.overrides),i=PN(r,n.fallbacks);if(!i.ok)return{status:`unknown`,reason:FN(i.violations)};let a=Object.keys(t.data.overrides).length>0;return{status:`ready`,presetId:n.id,customized:a,source:`stored`,swatches:r,fallbacks:[...n.fallbacks]}}function exe(e,t){return{presetId:e.presetId,overrides:{...t}}}var txe=x({id:u(),name:u(),swatches:h(u(),TN),fallbacks:C(u())}),BN={name:`display-palette`,scope:`system`,mode:`singleton`,methods:{getPalette:D(v(),DN,{auth:`protected`,role:`viewer`}),listPresets:D(v(),C(txe).readonly(),{auth:`protected`,role:`viewer`}),setPalette:D(ON,EN,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the cluster display palette — one colour table for every client, not a device action`}},VN=x({enabled:y().nullable().meta({label:`Do not disturb`}),lastChangedAt:r()}),HN={name:`do-not-disturb`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.MediaPlayer],methods:{setEnabled:D(x({deviceId:r().int(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dnd.on`,label:L(`Do not disturb on`,`Attiva Non disturbare`),phrase:L(`Turn on Do not disturb on {device}`,`Attiva Non disturbare su {device}`),icon:`bell-off`,args:{enabled:!0}},{id:`dnd.off`,label:L(`Do not disturb off`,`Disattiva Non disturbare`),phrase:L(`Turn off Do not disturb on {device}`,`Disattiva Non disturbare su {device}`),icon:`bell`,args:{enabled:!1}}]})},status:{schema:VN,kind:`push`},runtimeState:VN,durability:`session`,history:{fields:{enabled:{kind:`boolean`}}},vocabulary:{noun:L(`Do not disturb`,`Non disturbare`),order:2160,state:[{kind:`boolean`,field:`enabled`,label:L(`Do not disturb`,`Non disturbare`),whenTrue:L(`When Do not disturb turns on on {device}`,`Quando {device} attiva Non disturbare`),whenFalse:L(`When Do not disturb turns off on {device}`,`Quando {device} disattiva Non disturbare`),icon:`bell-off`}]}},UN=2e3,nxe={version:1,targets:[{id:`pressed`,cardinality:`event`,shape:`pulse`,vocabulary:{cap:`doorbell`,eventName:`onPressed`},deviceTypes:[M.Camera],apply:`add`,applyAuthority:{kind:`composition-claim`},eventName:`onPressed`,edges:[`rising`],defaultEdge:`rising`,timestampPath:`lastPressedAt`,counterPath:`pressCountSinceStart`,highWater:`composer-advance`,combine:`any`,debounce:{kind:`rising-edge`,defaultDebounceMs:UN,changedAtRequired:!0},sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},WN=x({lastPressedAt:r().nullable(),pressCountSinceStart:r().meta(A(`count`))}),GN=x({deviceId:r(),timestamp:r()}),KN={name:`doorbell`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Button,M.Camera],methods:{},events:{onPressed:{data:GN,fromState:{field:`lastPressedAt`,on:`advance`},trigger:{category:T.DoorbellOnPressed,label:L(`Rang`,`Ha suonato`),phrase:L(`When someone rings {device}`,`Quando qualcuno suona a {device}`),icon:`bell-ring`}}},status:{schema:WN,kind:`push`},runtimeState:WN,durability:`restored`,history:`none`,customize:nxe,vocabulary:{noun:L(`Doorbell`,`Campanello`),order:5270}},qN=x({embedding:C(r()),inferenceMs:r()}),JN=S([`image`,`text`]),YN=x({modelId:u(),tower:JN,nodeId:u(),crashes:r(),windowMs:r(),sinceMs:r(),lastReason:u()}),XN=x({modelId:u(),tower:JN,nodeId:u(),attempts:r(),sinceMs:r(),lastReason:u()}),ZN=x({modelId:u(),embeddingDim:r(),ready:y(),nodeId:u().optional(),failedModels:C(YN).optional(),failedRequirements:C(XN).optional()}),QN=`embedding-model-failed`,$N=`embedding-requirements-unavailable`,eP=`embedding-requirements-failed`,tP=S([QN,$N,eP]);function nP(e,t){return`[${e} model=${t.modelId} tower=${t.tower} node=${t.nodeId}]`}function rxe(e){return Error(`${nP(QN,e)} ${e.modelId} (${e.tower} tower) crashed ${String(e.crashes)} times in ${String(Math.round(e.windowMs/1e3))}s on ${e.nodeId} — ${e.lastReason}. Cleared by embeddingEncoder.resetFailedModels({ modelId: "${e.modelId}", nodeId: "${e.nodeId}" }) or a model change.`)}function ixe(e,t){return Error(`${nP($N,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: ${t}`)}function axe(e){return Error(`${nP(eP,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: requirements can never be met — ${String(e.attempts)} attempts, last: ${e.lastReason}. Cleared by embeddingEncoder.resetFailedModels({ modelId: "${e.modelId}", nodeId: "${e.nodeId}" }) or a model change.`)}var oxe=RegExp(`\\[(${QN}|${$N}|${eP}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);function rP(e){let t=e instanceof Error?e.message:String(e),n=oxe.exec(t);if(n===null)return null;let r=tP.safeParse(n[1]),i=JN.safeParse(n[3]);return!r.success||!i.success||n[2]===void 0||n[4]===void 0?null:{code:r.data,modelId:n[2],tower:i.data,nodeId:n[4]}}function sxe(e){return iP(e)!==null}function iP(e){let t=rP(e);if(t===null||t.code!==`embedding-model-failed`)return null;let{modelId:n,tower:r,nodeId:i}=t;return{modelId:n,tower:r,nodeId:i}}var aP={name:`embedding-encoder`,scope:`system`,mode:`collection`,internal:!0,methods:{encode:D(x({crop:b(Uint8Array),width:r(),height:r()}),qN,{auth:`admin`}),encodeText:D(x({text:u(),modelId:u().min(1).optional()}),qN,{auth:`admin`}),getInfo:D(v(),ZN,{auth:`admin`}),resetFailedModels:D(x({modelId:u().min(1).optional()}),x({cleared:C(u()),nodeId:u()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.ML}},oP=x({powerW:r().nullable().meta(A(`power`)),energyKwh:r().nullable().meta(A(`energy`)),todayKwh:r().nullable().meta(A(`energy`))}),sP=x({powerW:r().nullable().meta(A(`power`)),importKwh:r().nullable().meta(A(`energy`)),exportKwh:r().nullable().meta(A(`energy`)),importTodayKwh:r().nullable().meta(A(`energy`)),exportTodayKwh:r().nullable().meta(A(`energy`))}),cP=x({powerW:r().nullable().meta(A(`power`)),energyKwh:r().nullable().meta(A(`energy`)),todayKwh:r().nullable().meta(A(`energy`))}),lP=x({stateOfChargePct:r().nullable().meta(A(`percentage`)),storedKwh:r().nullable().meta(A(`energy`)),capacityKwh:r().nullable().meta(A(`energy`)),powerW:r().nullable().meta(A(`power`)),chargedKwh:r().nullable().meta(A(`energy`)),dischargedKwh:r().nullable().meta(A(`energy`)),chargedTodayKwh:r().nullable().meta(A(`energy`)),dischargedTodayKwh:r().nullable().meta(A(`energy`)),healthPct:r().nullable().meta(A(`percentage`))}),uP=x({solar:oP.nullable(),grid:sP.nullable(),house:cP.nullable(),heatPump:cP.nullable(),storage:lP.nullable(),lastFetchedAt:r()});function cxe(e){let t=e.solar?.todayKwh??null,n=e.grid?.exportTodayKwh??null;return t===null||n===null||t<=0?null:Math.max(0,Math.min(100,(t-n)/t*100))}var dP={name:`energy-system`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.EnergySystem],methods:{},status:{schema:uP,kind:`push`},runtimeState:uP,durability:`session`,history:{primary:`house.powerW`,priority:50,fields:{"solar.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Solar power`},"solar.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Solar energy`},"grid.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Grid power`},"grid.importKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid import`},"grid.exportKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid export`},"house.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`House power`},"house.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`House energy`},"heatPump.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Heat pump power`},"heatPump.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Heat pump energy`},"storage.stateOfChargePct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage charge`},"storage.storedKwh":{kind:`gauge`,unit:`kWh`,deadband:.05,displayName:`Stored energy`},"storage.capacityKwh":{kind:`gauge`,unit:`kWh`,deadband:.1,displayName:`Storage capacity`},"storage.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Storage power`},"storage.chargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage charged`},"storage.dischargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage discharged`},"storage.healthPct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage health`}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Energy system`,`Sistema energetico`),order:4020}},lxe=S([`date`,`time`,`datetime`]),fP=x({value:u(),timestamp:y().optional(),lastFetchedAt:r()}),pP={name:`enum-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:fP,kind:`push`},runtimeState:fP,durability:`restored`,history:{fields:{value:{kind:`enum`,skipWhenSet:`timestamp`}}},volatileStateFields:[`lastFetchedAt`,`timestamp`],vocabulary:{noun:L(`State sensor`,`Sensore di stato`),order:5060,state:[{kind:`value`,field:`value`,label:L(`State`,`Stato`),icon:`list`}]}},mP=S([`warning`,`error`]),hP=x({code:u(),label:u(),severity:mP}),gP=x({active:y().nullable(),code:u().nullable(),label:u().nullable(),severity:mP,since:r().nullable(),faults:C(hP).optional(),lastFetchedAt:r()}),_P={active:null,code:null,label:null,severity:`error`,since:null,lastFetchedAt:0},vP={name:`error`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},status:{schema:gP,kind:`push`,empty:_P},runtimeState:gP,durability:`restored`,volatileStateFields:[`lastFetchedAt`],history:`none`,vocabulary:{noun:L(`Fault`,`Guasto`),order:5265,state:[{kind:`boolean`,field:`active`,label:L(`Fault`,`Guasto`),whenTrue:L(`When {device} reports a fault`,`Quando {device} segnala un guasto`),whenFalse:L(`When the fault of {device} clears`,`Quando il guasto di {device} si risolve`),icon:`triangle-alert`}]}},yP=x({id:u(),name:u(),sampleCount:r().int().nonnegative(),coverMediaId:r().int().optional(),coverBase64:u().optional()}),uxe=x({id:u(),source:S([`detected`,`photo`]),addedAt:r().int(),deviceId:r().int().optional(),base64:u().optional(),mediaId:r().int().optional(),keyFrameMediaId:r().int().optional(),faceBbox:Ay.optional()}),dxe=x({sampleId:u(),enrolledAt:r().int(),deviceId:r().int().optional(),source:S([`detected`,`photo`]),mediaId:r().int().optional(),comparable:y(),selfMean:r().nullable(),bestForeign:x({identityId:u(),name:u(),score:r()}).optional(),suspicion:r()}),fxe=x({identityId:u(),name:u(),modelId:u(),totalSamples:r().int(),comparableSamples:r().int(),flagged:r().int(),flagThreshold:r(),rows:C(dxe).readonly()}),bP=x({faceId:u(),deviceId:r().int(),trackId:u(),timestamp:r().int(),recognizedIdentityId:u().optional(),identityName:u().optional(),assigned:y(),base64:u().optional(),cropUrl:u().optional(),faceBbox:Ay.optional(),keyFrameMediaId:r().int().optional(),bestMatchScore:r().optional(),nativeFaceShortSidePx:r().optional(),suggestedIdentityId:u().optional(),suggestedMatchScore:r().optional()}),pxe=S([`unassigned`,`recognized`,`identified`,`all`]),mxe=S([`timestamp`,`suggestionConfidence`]),hxe=S([`asc`,`desc`]),gxe=x({faceIds:C(u()).readonly(),representativeFaceId:u(),size:r().int(),cohesion:r()}),_xe=x({mediaId:r().int(),kind:u(),url:u(),sizeBytes:r(),timestamp:r()}),xP={name:`face-gallery`,role:{feature:`face-assignment`},scope:`system`,mode:`singleton`,methods:{listIdentities:D(x({includeCrops:y().optional()}).optional(),C(yP).readonly(),{role:`viewer`}),createIdentity:D(x({name:u().min(1)}),yP,{kind:`mutation`,auth:`admin`}),renameIdentity:D(x({id:u(),name:u().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteIdentity:D(x({id:u()}),v(),{kind:`mutation`,auth:`admin`}),listIdentitySamples:D(x({identityId:u()}),C(uxe).readonly()),auditIdentitySamples:D(x({identityId:u().min(1)}),fxe,{auth:`admin`}),removeSample:D(x({identityId:u(),sampleId:u()}),v(),{kind:`mutation`,auth:`admin`}),moveIdentitySample:D(x({sampleId:u().min(1),toIdentityId:u().min(1)}),v(),{kind:`mutation`,auth:`admin`}),listRecentFaces:D(x({deviceId:r().int().optional(),deviceIds:C(r().int()).optional(),limit:r().int().positive().optional(),filter:pxe.optional(),since:r().int().optional(),until:r().int().optional(),sortBy:mxe.optional(),sortDirection:hxe.optional(),includeCrops:y().optional()}).optional(),C(bP).readonly()),getFaceByTrack:D(x({deviceId:r().int(),trackId:u()}),bP.nullable(),{role:`viewer`}),getFaceMedia:D(x({faceId:u()}),C(_xe).readonly()),assignFace:D(x({faceId:u(),identityId:u()}),v(),{kind:`mutation`,auth:`admin`}),unassignFace:D(x({faceId:u()}),v(),{kind:`mutation`,auth:`admin`}),deleteFace:D(x({faceId:u()}),v(),{kind:`mutation`,auth:`admin`}),assignFaces:D(x({faceIds:C(u()).min(1),identityId:u()}),x({assigned:r().int(),failed:C(u()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignFaces:D(x({faceIds:C(u()).min(1)}),x({unassigned:r().int(),failed:C(u()).readonly()}),{kind:`mutation`,auth:`admin`}),suggestFaceClusters:D(x({threshold:r().min(0).max(1).optional(),minClusterSize:r().int().min(2).optional(),maxClusters:r().int().positive().optional(),limit:r().int().positive().optional(),maxFacesScanned:r().int().positive().optional()}).optional(),C(gxe).readonly())},vocabulary:{notOperatorFacing:`the face gallery — curated on its own page`}},SP=x({reason:u(),count:r().int().nonnegative()}),CP=x({family:u(),deviceId:r().int().positive(),variant:u().optional(),sinceMs:r(),atMs:r(),attempts:r().int().nonnegative(),succeeded:r().int().nonnegative(),reasons:C(SP).readonly()}),wP={name:`failure-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:D(v(),C(CP).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.INTERNAL}},TP=S([`forward`,`reverse`]),EP=[`horizontal`,`vertical`],DP=S(EP),OP=[`oscillating`,`angle`,`sweepFrom`,`sweepTo`],kP=S(OP),AP=[`min`,`max`,`step`],jP=x({oscillating:y().nullable().default(null),angle:r().nullable().default(null),sweepFrom:r().nullable().default(null),sweepTo:r().nullable().default(null),min:r().nullable().default(null),max:r().nullable().default(null),step:r().nullable().default(null)}),MP=x({horizontal:jP.nullable().default(null),vertical:jP.nullable().default(null)}),NP=[`nothing-to-set`,`axis-not-linked`,`out-of-range`,`source-gone`,`source-unknown`,`source-call-failed`],PP=S(NP),FP=a(`status`,[x({status:m(`applied`)}),x({status:m(`refused`),reason:PP,field:kP.optional(),detail:u(),applied:C(kP)})]),IP=x({deviceId:r().int().nonnegative(),axis:DP,oscillating:y().optional(),angle:r().optional(),sweepFrom:r().optional(),sweepTo:r().optional()});function LP(e,t){return`oscillationAxes.${e}.${t}`}var RP=x({speed:r().min(0).max(100).nullable().meta(A(`percentage`)),percentageStep:r().positive().optional().meta(A(`percentage`)),preset:u(),availablePresets:C(u()),direction:TP.nullable(),oscillating:y().nullable(),oscillationAxes:MP.optional(),lastChangedAt:r()});function vxe(e){let t=e.oscillationAxes;if(t===void 0)return e.oscillating;let n=EP.flatMap(e=>{let n=t[e]?.oscillating;return n==null?[]:[n]});return n.length===0?e.oscillating:n.some(Boolean)}var zP=[M.Fan],BP=`oscillation-axes`;function yxe(e){return{id:`${e}-oscillating`,cardinality:`scalar`,vocabulary:{cap:`fan-control`,stateField:`oscillating`},deviceTypes:zP,apply:`replace`,section:BP,path:LP(e,`oscillating`),sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}function VP(e,t){let n={id:`${e}-${t}`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:zP,apply:`replace`,section:BP,path:LP(e,t),sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}};return t===`angle`?{...n,companions:AP.map(t=>({kind:`source-field`,path:LP(e,t),field:t}))}:n}var bxe=EP.flatMap(e=>[yxe(e),VP(e,`angle`),VP(e,`sweepFrom`),VP(e,`sweepTo`)]),xxe={id:`preset`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:zP,apply:`replace`,path:`preset`,sources:[{kind:`field`,valueKinds:[`string`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}},HP=[...bxe,xxe],Sxe={version:1,overridable:HP.map(e=>({path:e.path,by:e.id})),targets:HP},UP={name:`fan-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Fan],methods:{setPercentage:O(x({deviceId:r().int().nonnegative(),speed:r().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.off`,label:L(`Fan off`,`Ventilatore spento`),phrase:L(`Stop {device}`,`Ferma {device}`),icon:`power-off`,effect:{field:`speed`,value:0},args:{speed:0}},{id:`fan.full`,label:L(`Fan full`,`Ventilatore al massimo`),phrase:L(`Run {device} at full speed`,`Porta {device} alla massima velocità`),icon:`fan`,effect:{field:`speed`,value:100},args:{speed:100},sideEffects:[{field:`preset`,value:``,when:{field:`preset`,notIn:[``]}}]},{id:`fan.speed`,label:L(`Set speed`,`Imposta la velocità`),phrase:L(`Set the speed of {device} to {speed}`,`Imposta la velocità di {device} al {speed}`),icon:`fan`,effect:{field:`speed`,fromArg:`speed`},sideEffects:[{field:`preset`,value:``,when:{field:`preset`,notIn:[``]}}],openArgs:[{key:`speed`,label:L(`Speed`,`Velocità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setPreset:O(x({deviceId:r().int().nonnegative(),preset:u().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.preset`,label:L(`Set preset`,`Imposta il preset`),phrase:L(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:L(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setDirection:O(x({deviceId:r().int().nonnegative(),direction:TP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.forward`,label:L(`Spin forward`,`Rotazione avanti`),phrase:L(`Spin {device} forward`,`Fai girare {device} in avanti`),icon:`refresh-cw`,effect:{field:`direction`,value:`forward`},args:{direction:`forward`}},{id:`fan.reverse`,label:L(`Spin in reverse`,`Rotazione inversa`),phrase:L(`Spin {device} in reverse`,`Fai girare {device} al contrario`),icon:`rotate-ccw`,effect:{field:`direction`,value:`reverse`},args:{direction:`reverse`}}]}),setOscillating:O(x({deviceId:r().int().nonnegative(),oscillating:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.oscillateOn`,label:L(`Oscillate`,`Oscillazione attiva`),phrase:L(`Make {device} oscillate`,`Fai oscillare {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!0},args:{oscillating:!0}},{id:`fan.oscillateOff`,label:L(`Stop oscillating`,`Oscillazione spenta`),phrase:L(`Stop {device} oscillating`,`Ferma l’oscillazione di {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!1},args:{oscillating:!1}}]}),setOscillationAxis:O(IP,FP,{kind:`mutation`,auth:`protected`,actions:[{id:`fan.horizontalOscillateOn`,label:L(`Horizontal oscillation on`,`Oscillazione orizzontale attiva`),phrase:L(`Start the horizontal oscillation of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!0}},{id:`fan.horizontalOscillateOff`,label:L(`Horizontal oscillation off`,`Oscillazione orizzontale spenta`),phrase:L(`Stop the horizontal oscillation of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!1}},{id:`fan.verticalOscillateOn`,label:L(`Vertical oscillation on`,`Oscillazione verticale attiva`),phrase:L(`Start the vertical oscillation of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!0}},{id:`fan.verticalOscillateOff`,label:L(`Vertical oscillation off`,`Oscillazione verticale spenta`),phrase:L(`Stop the vertical oscillation of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!1}}]})},status:{schema:RP,kind:`push`},runtimeState:RP,customize:Sxe,durability:`session`,history:{fields:{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}}},vocabulary:{noun:L(`Fan`,`Ventilatore`),order:1080,state:[{kind:`numeric`,field:`speed`,quantity:L(`the speed`,`la velocità`),label:L(`Speed`,`Velocità`),unit:`%`,icon:`fan`},{kind:`boolean`,field:`oscillating`,label:L(`Oscillating`,`Oscillazione`),whenTrue:L(`When {device} starts oscillating`,`Quando {device} inizia a oscillare`),whenFalse:L(`When {device} stops oscillating`,`Quando {device} smette di oscillare`),icon:`move-horizontal`}]}},WP=x({oscillating:y().optional(),angle:r().optional(),sweepFrom:r().optional(),sweepTo:r().optional()}),GP=x({speed:r().min(0).max(100).optional(),preset:u().min(1).optional(),direction:TP.optional(),oscillationAxes:x({horizontal:WP.optional(),vertical:WP.optional()}).optional()}),KP=x({id:u().min(1).max(64),name:u().trim().min(1).max(40),state:GP}),qP=[`empty-state`,`duplicate-name`,`duplicate-id`,`too-many`,`not-a-fan`],JP=S(qP),YP=a(`status`,[x({status:m(`saved`),count:r().int().nonnegative()}),x({status:m(`refused`),reason:JP,detail:u()})]),XP=x({field:u(),outcome:S([`applied`,`failed`,`not-run`,`refused`]),message:u().optional()}),ZP=x({status:S([`applied`,`partial`,`refused`]),fields:C(XP)}),QP=[`speed`,`direction`,`preset`,`oscillationAxes`],$P=S(QP),eF=x({what:u(),reason:u()}),tF=x({state:GP,omitted:C(eF)}),nF=x({deviceId:r().int().nonnegative()}),Cxe={version:1,targets:[{id:`presets`,cardinality:`config`,vocabulary:{cap:`fan-presets`},deviceTypes:[M.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`}]},rF={name:`fan-presets`,scope:`system`,mode:`singleton`,methods:{getPresets:D(nF,C(KP),{auth:`protected`}),setPresets:D(nF.extend({presets:C(KP).max(12)}),YP,{kind:`mutation`,auth:`admin`}),applyPreset:D(nF.extend({presetId:u().min(1)}),ZP,{kind:`mutation`,auth:`protected`}),capturePreset:D(nF.extend({fields:C($P).optional()}),tF,{auth:`protected`})},customize:Cxe,vocabulary:{notOperatorFacing:`the per-fan presets — authored in the Customize presets editor, applied through the actions the exports list`}},iF=x({flags:h(u(),w()),deviceType:u().nullable(),model:u().nullable(),channelCount:r().nullable().meta(A(`count`)),lastProbedAt:r(),lastFetchedAt:r()}),aF={name:`feature-probe`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onProbeChanged:{data:x({deviceId:r(),status:iF}),notOperatorFacing:`the device’s capabilities were re-probed — plumbing, not a happening`}},status:{schema:iF,kind:`push`},runtimeState:iF,durability:`session`,history:`none`,vocabulary:{noun:L(`Feature probe`,`Rilevamento funzioni`),order:3120}},wxe=x({name:u(),path:u()}),Txe=x({path:u(),entries:C(wxe).readonly(),freeBytes:r(),totalBytes:r()}),oF={name:`filesystem-browse`,scope:`system`,mode:`singleton`,internal:!0,methods:{listAllowedRoots:D(v(),C(u()).readonly(),{auth:`admin`}),browse:D(x({path:u()}),Txe,{auth:`admin`}),createDir:D(x({path:u()}),x({path:u()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.INTERNAL}},sF=x({flooded:y(),lastChangedAt:r()}),cF={name:`flood`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:sF,kind:`push`},runtimeState:sF,durability:`restored`,history:{fields:{flooded:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Leak sensor`,`Sensore di allagamento`),order:5070,state:[{kind:`boolean`,field:`flooded`,label:L(`Leak`,`Perdita`),whenTrue:L(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:L(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}]}},lF=x({detected:y(),lastChangedAt:r()}),uF={name:`gas`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:lF,kind:`push`},runtimeState:lF,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Gas sensor`,`Sensore di gas`),order:5080,state:[{kind:`boolean`,field:`detected`,label:L(`Detected`,`Rilevato`),whenTrue:L(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:L(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}]}},dF=x({active:y().meta({label:`Active`}),lastChangedAt:r()}),fF={name:`group-active`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Cover,M.Valve,M.Lock,M.MediaPlayer,M.Climate],methods:{},status:{schema:dF,kind:`push`},runtimeState:dF,durability:`session`,history:`none`,vocabulary:{noun:L(`Group state`,`Stato del gruppo`),order:5090}},pF=x({deviceId:r().int().nonnegative(),cap:u().min(1),method:u().min(1),ok:y(),error:u().optional(),at:r()}),mF=x({results:C(pF)}),hF={name:`group-commands`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Switch,M.Light,M.Fan,M.Cover,M.Valve,M.Lock,M.MediaPlayer,M.Climate],methods:{},status:{schema:mF,kind:`push`},runtimeState:mF,durability:`session`,history:`none`,vocabulary:{noun:L(`Group command`,`Comando di gruppo`),order:5100}},gF=x({included:r().int().nonnegative().meta(A(`count`,{precision:0,label:`Reporting`})),excluded:r().int().nonnegative().meta(A(`count`,{precision:0,label:`Excluded`})),total:r().int().nonnegative().meta(A(`count`,{precision:0,label:`Members`}))}),_F={name:`group-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor,M.Switch,M.Light,M.Fan,M.Cover,M.Valve,M.Lock,M.MediaPlayer,M.Climate],methods:{},status:{schema:gF,kind:`push`},runtimeState:gF,durability:`session`,history:`none`,vocabulary:{noun:L(`Group`,`Gruppo`),order:5110,state:[{kind:`numeric`,field:`included`,quantity:L(`the members reporting`,`i membri che rispondono`),label:L(`Reporting`,`Rispondono`),icon:`users`},{kind:`numeric`,field:`excluded`,quantity:L(`the members left out`,`i membri esclusi`),label:L(`Excluded`,`Esclusi`),icon:`users`},{kind:`numeric`,field:`total`,quantity:L(`the member count`,`il numero di membri`),label:L(`Members`,`Membri`),icon:`sigma`}]}},vF=r().int().nonnegative(),yF=u().min(1),bF=u().min(1),xF=r().finite(),SF={key:`circuitId`,label:L(`Circuit`,`Circuito`),offer:{kind:`dynamic`,from:`status`,cap:`heat-pump-status`,field:`circuits`,valueKey:`id`,labelKey:`label`,where:{key:`kind`,equals:`heating`}}},CF={...SF,label:L(`Hot water circuit`,`Circuito acqua calda`),offer:{...SF.offer,where:{key:`kind`,equals:`dhw`}}},wF={key:`mode`,label:L(`Mode`,`Modalità`),offer:{kind:`text`}},Exe={key:`level`,label:L(`Level`,`Livello`),offer:{kind:`text`}},TF={key:`temp`,label:L(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}},Dxe={key:`minutes`,label:L(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}},EF={name:`heat-pump-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.HeatPump],methods:{setSilentMode:D(x({deviceId:vF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.silent`,label:L(`Set silent mode`,`Imposta la modalità silenziosa`),phrase:L(`Set silent mode of {device} to {mode}`,`Imposta la modalità silenziosa di {device} su {mode}`),icon:`volume-x`,openArgs:[{key:`mode`,label:L(`Silent mode`,`Modalità silenziosa`),offer:{kind:`enum`,values:[{value:`off`,label:L(`Off`,`Off`)},{value:`auto`,label:L(`Auto`,`Auto`)},{value:`on`,label:L(`On`,`On`)}]}}]}]}),setAwayMode:D(x({deviceId:vF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.away`,label:L(`Set away mode`,`Imposta la modalità assente`),phrase:L(`Set away mode of {device} to {mode}`,`Imposta la modalità assente di {device} su {mode}`),icon:`plane`,openArgs:[{key:`mode`,label:L(`Away mode`,`Modalità assente`),offer:{kind:`enum`,values:[{value:`off`,label:L(`Off`,`Off`)},{value:`on`,label:L(`On`,`On`)}]}}]}]}),setAdditionalHeaterMode:D(x({deviceId:vF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.additionalHeater`,label:L(`Set additional heater`,`Imposta il riscaldatore aggiuntivo`),phrase:L(`Set the additional heater of {device} to {mode}`,`Imposta il riscaldatore aggiuntivo di {device} su {mode}`),icon:`flame`,openArgs:[{key:`mode`,label:L(`Additional heater`,`Riscaldatore aggiuntivo`),offer:{kind:`enum`,values:[{value:`off`,label:L(`Off`,`Off`)},{value:`manual`,label:L(`Manual`,`Manuale`)},{value:`auto`,label:L(`Auto`,`Auto`)}]}}]}]}),setHolidayMode:D(x({deviceId:vF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.holiday`,label:L(`Set holiday mode`,`Imposta la modalità vacanza`),phrase:L(`Set holiday mode of {device} to {mode}`,`Imposta la modalità vacanza di {device} su {mode}`),icon:`tree-palm`,openArgs:[{key:`mode`,label:L(`Holiday programme`,`Programma vacanza`),offer:{kind:`enum`,values:[{value:`off`,label:L(`Off`,`Off`)},{value:`hm1`,label:L(`Programme 1`,`Programma 1`)},{value:`hm2`,label:L(`Programme 2`,`Programma 2`)},{value:`hm3`,label:L(`Programme 3`,`Programma 3`)},{value:`hm4`,label:L(`Programme 4`,`Programma 4`)},{value:`hm5`,label:L(`Programme 5`,`Programma 5`)},{value:`hm6`,label:L(`Programme 6`,`Programma 6`)},{value:`hm7`,label:L(`Programme 7`,`Programma 7`)},{value:`hm8`,label:L(`Programme 8`,`Programma 8`)}]}}]}]}),setCircuitOperationMode:D(x({deviceId:vF,circuitId:yF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitOperationMode`,label:L(`Set circuit operation mode`,`Imposta la modalità del circuito`),phrase:L(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`thermometer`,openArgs:[SF,wF]}]}),setCircuitHeatCoolMode:D(x({deviceId:vF,circuitId:yF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitHeatCoolMode`,label:L(`Set circuit heat / cool`,`Imposta caldo / freddo del circuito`),phrase:L(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun-snow`,openArgs:[SF,wF]}]}),setCircuitSummerWinter:D(x({deviceId:vF,circuitId:yF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitSummerWinter`,label:L(`Set circuit summer / winter`,`Imposta estate / inverno del circuito`),phrase:L(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun`,openArgs:[SF,wF]}]}),setCircuitComfortSetpoint:D(x({deviceId:vF,circuitId:yF,temp:xF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitComfortSetpoint`,label:L(`Set comfort temperature`,`Imposta la temperatura comfort`),phrase:L(`Set the comfort temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura comfort di {circuitId} su {device} a {temp}`),icon:`thermometer-sun`,openArgs:[SF,TF]}]}),setCircuitEcoSetpoint:D(x({deviceId:vF,circuitId:yF,temp:xF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitEcoSetpoint`,label:L(`Set eco temperature`,`Imposta la temperatura eco`),phrase:L(`Set the eco temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura eco di {circuitId} su {device} a {temp}`),icon:`leaf`,openArgs:[SF,TF]}]}),setCircuitMaxFlowTemp:D(x({deviceId:vF,circuitId:yF,temp:xF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitMaxFlowTemp`,label:L(`Set maximum flow temperature`,`Imposta la temperatura massima di mandata`),phrase:L(`Set the maximum flow temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura massima di mandata di {circuitId} su {device} a {temp}`),icon:`flame`,openArgs:[SF,TF]}]}),setDhwOperationMode:D(x({deviceId:vF,circuitId:yF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwOperationMode`,label:L(`Set hot water mode`,`Imposta la modalità acqua calda`),phrase:L(`Set hot water {circuitId} of {device} to {mode}`,`Imposta l'acqua calda {circuitId} di {device} su {mode}`),icon:`shower-head`,openArgs:[CF,wF]}]}),setDhwTemperatureLevel:D(x({deviceId:vF,circuitId:yF,level:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwTemperatureLevel`,label:L(`Set hot water level`,`Imposta il livello acqua calda`),phrase:L(`Set hot water {circuitId} of {device} to level {level}`,`Imposta l'acqua calda {circuitId} di {device} al livello {level}`),icon:`droplet`,openArgs:[CF,Exe]}]}),setDhwChargeDuration:D(x({deviceId:vF,circuitId:yF,minutes:r().int().positive()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwChargeDuration`,label:L(`Set hot water charge duration`,`Imposta la durata della carica acqua calda`),phrase:L(`Set the charge of hot water {circuitId} on {device} to {minutes} min`,`Imposta la carica dell'acqua calda {circuitId} di {device} a {minutes} min`),icon:`timer`,openArgs:[CF,Dxe]}]}),startExtraHotWater:D(x({deviceId:vF,circuitId:yF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.extraHotWater`,label:L(`Start extra hot water`,`Avvia acqua calda extra`),phrase:L(`Start an extra hot water charge of {circuitId} on {device}`,`Avvia una carica extra di acqua calda {circuitId} su {device}`),icon:`droplets`,openArgs:[CF]}]})},vocabulary:{noun:L(`Heat pump settings`,`Impostazioni pompa di calore`),order:4010}},DF=[`heating`,`dhw`,`cooling`,`solar`],OF=S(DF),kF=x({value:u().nullable(),allowed:C(u())}),AF=x({value:r().nullable(),min:r().nullable(),max:r().nullable(),step:r().nullable()}),jF=x({id:u().min(1),kind:OF,label:u(),icon:md,currentTemp:r().nullable().meta(A(`temperature`)),targetTemp:r().nullable().meta(A(`temperature`)),mode:u().nullable(),active:y().nullable(),operationMode:kF.nullable(),heatCoolMode:kF.nullable(),summerWinter:kF.nullable(),comfortSetpoint:AF.nullable(),ecoSetpoint:AF.nullable(),maxFlowTemp:AF.nullable(),temperatureLevel:kF.nullable(),chargeDuration:AF.nullable(),extraHotWater:y().nullable()}),MF=x({silent:kF.nullable(),away:kF.nullable(),additionalHeater:kF.nullable(),holiday:kF.nullable()}),NF=x({thermalW:r().nullable().meta(A(`power`)),electricalW:r().nullable().meta(A(`power`)),compressorPct:r().nullable().meta(A(`percentage`))}),PF=x({supply:r().nullable().meta(A(`temperature`)),return:r().nullable().meta(A(`temperature`)),outdoor:r().nullable().meta(A(`temperature`))}),FF=x({thermalKwh:r().nullable().meta(A(`energy`)),electricalKwh:r().nullable().meta(A(`energy`))}),IF=x({circuits:C(jF),system:MF,power:NF,temperatures:PF,energy:FF,waterPressureBar:r().nullable(),starts:r().nullable(),lastFetchedAt:r()});function LF(e){let{thermalW:t,electricalW:n}=e;return t===null||n===null||n<=0?null:t/n}var Oxe=[M.HeatPump];function RF(e,t,n){return{id:e,cardinality:`scalar`,vocabulary:{cap:`heat-pump-status`},deviceTypes:Oxe,apply:`replace`,path:t,sources:[{kind:`numeric`,requiredUnit:n,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}var zF=[RF(`electrical-power`,`power.electricalW`,`W`),RF(`electrical-energy`,`energy.electricalKwh`,`kWh`)],kxe={version:1,overridable:zF.map(e=>({path:e.path,by:e.id})),targets:zF},BF={name:`heat-pump-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.HeatPump],methods:{},status:{schema:IF,kind:`push`},runtimeState:IF,durability:`session`,customize:kxe,history:{fields:{"power.thermalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Thermal power`},"power.electricalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Electrical power`},"power.compressorPct":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Compressor`},"temperatures.supply":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Supply`},"temperatures.return":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Return`},"temperatures.outdoor":{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Outdoor`},"energy.thermalKwh":{kind:`counter`,unit:`kWh`,displayName:`Thermal energy`},"energy.electricalKwh":{kind:`counter`,unit:`kWh`,displayName:`Electrical energy`}},items:{path:`circuits`,key:`id`,label:`label`,fields:{currentTemp:{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Temperature`},targetTemp:{kind:`gauge`,unit:`°C`,minIntervalMs:0,displayName:`Setpoint`},mode:{kind:`enum`,displayName:`Mode`}}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Heat pump`,`Pompa di calore`),order:4e3}},VF=x({position:r().min(0).max(100).nullable().meta(A(`percentage`)),lastFetchedAt:r()}),HF={name:`heating-valve`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Climate],methods:{},status:{schema:VF,kind:`push`},runtimeState:VF,durability:`session`,history:{fields:{position:{kind:`gauge`,unit:`%`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Radiator valve`,`Valvola termostatica`),order:1110,state:[{kind:`numeric`,field:`position`,quantity:L(`the valve opening`,`l’apertura della valvola`),label:L(`Valve opening`,`Apertura della valvola`),unit:`%`,icon:`heater`}]}},UF=S([`s`,`min`]),Axe=S([`switch`,`pet-fountain`]),WF={actuator:`switch`,maxSeconds:10800,unit:`min`,quickRunDefault:30},GF={actuator:`pet-fountain`,maxSeconds:300,unit:`s`,quickRunDefault:60},KF=[M.Switch,M.PetFountain],qF={[M.Switch]:[P.SwitchHeater]};function JF(e,t){return e===M.PetFountain?GF:e===M.Switch&&t===P.SwitchHeater?WF:null}var jxe=1e3,Mxe=6e4;function YF(e,t,n){let r=e-t;return r<=0?0:Math.max(1,Math.ceil(r/(n===`min`?Mxe:jxe)))}function Nxe(e,t){return t===`min`?e*60:e}function XF(e){return e.unit===`min`?Math.floor(e.maxSeconds/60):e.maxSeconds}var ZF=x({duration:r().positive().finite(),unit:UF});function QF(e,t){let n=XF(e);return{duration:Math.min((t!==null&&Number.isFinite(t)&&t>0?t:null)??e.quickRunDefault,n),unit:e.unit}}var $F=S([`unsupported-device`,`over-max`,`command-failed`]),eI=a(`ok`,[x({ok:m(!0),activeUntil:r()}),x({ok:m(!1),reason:$F,maxSeconds:r().nullable()})]),tI=x({activeUntil:r().nullable(),requestedBy:u().nullable(),quickRun:ZF.nullable(),lastFetchedAt:r()}),nI=x({unit:UF,maxDuration:r(),defaultDuration:r()}),rI=x({quickRunDuration:r().positive().finite().nullable().optional()}),iI={name:`timed-run`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:KF,deviceRoles:qF,deviceConfig:{ui:{kind:`derived-form`,builderId:`timed-run`,tab:`general`}},methods:{getOptions:D(x({deviceId:r().int()}),nI),setSettings:D(x({deviceId:r().int(),settings:rI}),v(),{kind:`mutation`,auth:`admin`}),runFor:D(x({deviceId:r().int(),duration:r().positive().finite(),unit:UF}),eI,{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.runForMinutes`,label:L(`Run for minutes`,`Accendi per alcuni minuti`),phrase:L(`Run {device} for {duration} minutes, then switch it off`,`Tieni acceso {device} per {duration} minuti, poi spegnilo`),icon:`timer`,args:{unit:`min`},openArgs:[{key:`duration`,label:L(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}}]},{id:`timedRun.runForSeconds`,label:L(`Run for seconds`,`Accendi per alcuni secondi`),phrase:L(`Run {device} for {duration} seconds, then switch it off`,`Tieni acceso {device} per {duration} secondi, poi spegnilo`),icon:`timer`,args:{unit:`s`},openArgs:[{key:`duration`,label:L(`Seconds`,`Secondi`),offer:{kind:`number`,min:1,step:1,unit:`s`}}]}]}),cancel:D(x({deviceId:r().int()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.cancel`,label:L(`Cancel the timer`,`Annulla il timer`),phrase:L(`Cancel the pending switch-off of {device}`,`Annulla lo spegnimento programmato di {device}`),icon:`timer-off`}]})},status:{schema:tI,kind:`push`},runtimeState:tI,durability:`session`,history:`none`,vocabulary:{noun:L(`Timed run`,`Esecuzione a tempo`),order:2150}},aI=[`on`,`off`,`running`,`idle`,`standby`,`alert`,`offline`,`unknown`],oI=[`success`,`warning`,`danger`,`primary`,`info`,`muted`],sI=[`none`,`pulse`,`spin`,`glow`,`halo`,`wave`,`rise`,`fall`,`tumble`,`equalizer`,`blink`,`breathe`],cI=[`plain`,`heat-rise`,`cool-fall`,`glow`,`water`,`drum`,`sky`,`mist`,`alert-wash`],lI=S(aI),uI=S(oI),Pxe=S(sI),dI=x({icon:md,tone:uI,background:S(cI),animation:Pxe});function fI(e){let t=qE[e];return t===void 0?null:`cap:${e}.${t.field}`}function pI(e){return e.enabledCaps.flatMap(e=>{let t=fI(e),n=qE[e];return t===null||n===void 0?[]:[{key:t,priority:n.priority}]}).sort((e,t)=>t.priority-e.priority).find(t=>e.hasData(t.key))?.key??null}var mI=x({en:u(),it:u()}),hI={en:`—`,it:`—`};function gI(e){return e.en===hI.en&&e.it===hI.it}var _I=[`temperature`,`humidity`,`power`,`contact`,`text`],vI=[`hot`,`mild`,`cold`],yI=[`updated`,`changed`],bI=x({value:r(),quantity:bc}),xI=x({quantity:S(_I),reading:bI.nullable(),icon:md.nullable(),value:mI,unit:u().nullable(),band:S(vI).nullable(),level:r().min(0).max(1).nullable(),word:mI,tone:S(oI),since:r().nullable(),sinceKind:S(yI),historyKey:u().nullable()}),Fxe=3e3,SI=e=>L(e,e),CI=e=>Math.min(1,Math.max(0,e)),Ixe=(e,t)=>String(Number(e.toFixed(t)));function wI(e){return e<12?`cold`:e>28?`hot`:`mild`}var Lxe={hot:L(`Hot`,`Caldo`),mild:L(`Normal`,`Normale`),cold:L(`Cold`,`Freddo`)},Rxe={hot:`warning`,mild:`muted`,cold:`info`};function TI(e,t){let n=wI(e);return{quantity:`temperature`,reading:{value:e,quantity:`temperature`},icon:`thermometer`,value:SI(Ixe(e,1)),unit:`°C`,band:n,level:null,word:Lxe[n],tone:Rxe[n],since:t,sinceKind:`updated`,historyKey:fI(`temperature-sensor`)}}function EI(e,t){let n=e<30,r=e>70;return{quantity:`humidity`,reading:{value:e,quantity:`humidity`},icon:`droplets`,value:SI(String(Math.round(e))),unit:`%`,band:null,level:CI(e/100),word:n?L(`Dry`,`Secco`):r?L(`Humid`,`Umido`):L(`Normal`,`Normale`),tone:n||r?`warning`:`info`,since:t,sinceKind:`updated`,historyKey:fI(`humidity-sensor`)}}function DI(e,t){let n=e>0;return{quantity:`power`,reading:{value:e,quantity:`power`},icon:`zap`,value:SI(String(Math.round(e))),unit:`W`,band:null,level:CI(e/Fxe),word:n?L(`Active`,`Attivo`):L(`Idle`,`Inattivo`),tone:n?`primary`:`muted`,since:t,sinceKind:`updated`,historyKey:fI(`power-meter`)}}function OI(e,t){return{quantity:`contact`,reading:null,icon:e?`door-open`:`door-closed`,value:e?L(`Open`,`Aperto`):L(`Closed`,`Chiuso`),unit:null,band:null,level:+!!e,word:e?L(`Open`,`Aperto`):L(`Closed`,`Chiuso`),tone:e?`warning`:`success`,since:t,sinceKind:`changed`,historyKey:null}}function kI(e,t){return{quantity:`text`,reading:null,icon:null,value:SI(e),unit:null,band:null,level:null,word:L(`Changed`,`Cambiato`),tone:`muted`,since:t,sinceKind:`updated`,historyKey:null}}var zxe={temperature:{icon:`thermometer`,unit:`°C`,sinceKind:`updated`,historyKey:fI(`temperature-sensor`)},humidity:{icon:`droplets`,unit:`%`,sinceKind:`updated`,historyKey:fI(`humidity-sensor`)},power:{icon:`zap`,unit:`W`,sinceKind:`updated`,historyKey:fI(`power-meter`)},contact:{icon:null,unit:null,sinceKind:`changed`,historyKey:null},text:{icon:null,unit:null,sinceKind:`updated`,historyKey:null}};function AI(e){let t=zxe[e];return{quantity:e,reading:null,icon:t.icon,value:hI,unit:t.unit,band:null,level:null,word:hI,tone:`muted`,since:null,sinceKind:t.sinceKind,historyKey:t.historyKey}}var Bxe={power:new Set([`energy-sensor`,`voltage-sensor`,`current-sensor`])};function jI(e,t){return t===null?!0:!(Bxe[e.quantity]?.has(t)??!1)}var MI=`ac.thermostat.heater.heat-pump.fan.washer.dryer.dishwasher.pet-fountain.pet-feeder.vacuum.lawn-mower.tv.speaker.camera.light.cover.lock.alarm.siren.sensor-sparkline.contact.presence.weather.plug.button.update.control-dial.event-stream.gateway.generic`.split(`.`),Vxe=S(MI),NI=[`cool`,`heat`,`dry`,`fan`,`auto`,`playing`,`paused`,`open`,`closed`],PI=x({id:Vxe,mode:S(NI).nullable(),level:r().min(0).max(1).nullable()}),FI={[M.Camera]:`camera`,[M.Light]:`light`,[M.Siren]:`siren`,[M.Switch]:`plug`,[M.Sensor]:`sensor-sparkline`,[M.Climate]:`thermostat`,[M.Button]:`button`,[M.EventEmitter]:`event-stream`,[M.Update]:`update`,[M.Generic]:`generic`,[M.Notifier]:`event-stream`,[M.Script]:`event-stream`,[M.Automation]:`event-stream`,[M.Lock]:`lock`,[M.Cover]:`cover`,[M.Valve]:`control-dial`,[M.Humidifier]:`control-dial`,[M.WaterHeater]:`heater`,[M.HeatPump]:`heat-pump`,[M.EnergySystem]:`generic`,[M.Workload]:`generic`,[M.Fan]:`fan`,[M.MediaPlayer]:`tv`,[M.AlarmPanel]:`alarm`,[M.Control]:`control-dial`,[M.Presence]:`presence`,[M.Weather]:`weather`,[M.WeatherStation]:`weather`,[M.Vacuum]:`vacuum`,[M.LawnMower]:`lawn-mower`,[M.Container]:`generic`,[M.Image]:`camera`,[M.PetFeeder]:`pet-feeder`,[M.PetFountain]:`pet-fountain`,[M.Dishwasher]:`dishwasher`,[M.Washer]:`washer`,[M.Dryer]:`dryer`,[M.Gateway]:`gateway`},II={[P.Siren]:`siren`,[P.Floodlight]:`light`,[P.Spotlight]:`light`,[P.PirSensor]:`presence`,[P.Chime]:`speaker`,[P.Autotrack]:`inherit`,[P.Nightvision]:`inherit`,[P.PrivacyMask]:`inherit`,[P.Doorbell]:`inherit`,[P.CoverBlind]:`inherit`,[P.CoverShutter]:`inherit`,[P.CoverAwning]:`inherit`,[P.CoverCurtain]:`inherit`,[P.CoverGarage]:`inherit`,[P.CoverGate]:`inherit`,[P.CoverDoor]:`inherit`,[P.CoverWindow]:`inherit`,[P.BinaryHelper]:`inherit`,[P.Outlet]:`plug`,[P.SwitchHeater]:`heater`,[P.SwitchFan]:`fan`,[P.SwitchLight]:`light`,[P.PoePort]:`plug`,[P.ClimateAc]:`ac`,[P.ClimateThermostat]:`inherit`,[P.ClimateFloor]:`inherit`,[P.ClimateRadiator]:`inherit`,[P.ClimateHeater]:`inherit`,[P.ClimateHeatPumpCircuit]:`inherit`,[P.MotionSensor]:`presence`,[P.ContactSensor]:`contact`,[P.LeakSensor]:`inherit`,[P.SmokeSensor]:`alarm`,[P.COSensor]:`alarm`,[P.GasSensor]:`alarm`,[P.TamperSensor]:`inherit`,[P.VibrationSensor]:`inherit`,[P.ConnectivitySensor]:`inherit`,[P.SoundSensor]:`inherit`,[P.BinarySensor]:`inherit`,[P.TemperatureSensor]:`sensor-sparkline`,[P.HumiditySensor]:`sensor-sparkline`,[P.AmbientLightSensor]:`inherit`,[P.PressureSensor]:`weather`,[P.WindSensor]:`weather`,[P.RainSensor]:`weather`,[P.UvSensor]:`weather`,[P.SolarRadiationSensor]:`weather`,[P.SoilMoistureSensor]:`inherit`,[P.PowerSensor]:`plug`,[P.EnergySensor]:`plug`,[P.VoltageSensor]:`plug`,[P.CurrentSensor]:`plug`,[P.AirQualitySensor]:`inherit`,[P.BatterySensor]:`inherit`,[P.NumericSensor]:`inherit`,[P.EnumSensor]:`inherit`,[P.DateTimeSensor]:`inherit`,[P.GenericSensor]:`inherit`,[P.NumericControl]:`control-dial`,[P.SelectControl]:`control-dial`,[P.TextControl]:`inherit`,[P.DateTimeControl]:`inherit`,[P.MobilePushNotifier]:`inherit`,[P.MessagingNotifier]:`inherit`,[P.EmailNotifier]:`inherit`,[P.GenericNotifier]:`inherit`,[P.IrTransmitter]:`inherit`,[P.Vm]:`inherit`,[P.AppContainer]:`inherit`,[P.Lxc]:`inherit`,[P.App]:`inherit`,[P.Host]:`inherit`,[P.Ups]:`inherit`};function Hxe(e){return Object.values(M).includes(e)}function Uxe(e){return Object.values(P).includes(e)}function LI(e,t){let n=e!==null&&Uxe(e)?II[e]:void 0;return n!==void 0&&n!==`inherit`?n:Hxe(t)?FI[t]:`generic`}var RI=`progress.run-for.cycle.program.appliance-power.now-playing.playback.volume.source.contact.motion-trigger.lock.alarm.fan.vacuum.vacuum-suction.mower.feeder.fountain.pump-cycle.automation.script.do-not-disturb.brightness.color.cover.valve.humidifier.update.button.climate-mode.climate-fan.setpoint.channel.control.circuit.heat-pump-power.system-mode`.split(`.`),zI=S(RI),BI={progress:L(`Progress`,`Avanzamento`),"run-for":L(`Run for`,`Avvia per`),cycle:L(`Cycle`,`Ciclo`),program:L(`Program`,`Programma`),"appliance-power":L(`Appliance`,`Elettrodomestico`),"now-playing":L(`Now playing`,`In riproduzione`),playback:L(`Playback`,`Riproduzione`),volume:L(`Volume`,`Volume`),source:L(`Source`,`Sorgente`),contact:L(`Door`,`Porta`),"motion-trigger":L(`Motion`,`Movimento`),lock:L(`Lock`,`Serratura`),alarm:L(`Alarm`,`Allarme`),fan:L(`Fan`,`Ventola`),vacuum:L(`Cleaning`,`Pulizia`),"vacuum-suction":L(`Suction`,`Aspirazione`),mower:L(`Mowing`,`Taglio`),feeder:L(`Feed now`,`Eroga ora`),fountain:L(`Pump`,`Pompa`),"pump-cycle":L(`Pump cycle`,`Ciclo pompa`),automation:L(`Automation`,`Automazione`),script:L(`Script`,`Script`),"do-not-disturb":L(`Do not disturb`,`Non disturbare`),brightness:L(`Brightness`,`Luminosità`),color:L(`Colour`,`Colore`),cover:L(`Position`,`Posizione`),valve:L(`Valve`,`Valvola`),humidifier:L(`Humidifier`,`Umidificatore`),update:L(`Firmware`,`Firmware`),button:L(`Action`,`Azione`),"climate-mode":L(`Mode`,`Modalità`),"climate-fan":L(`Fan`,`Ventola`),setpoint:L(`Setpoint`,`Temperatura`),channel:L(`Channel`,`Canale`),control:L(`Control`,`Controllo`),circuit:L(`Circuit`,`Circuito`),"heat-pump-power":L(`Power`,`Potenza`),"system-mode":L(`Mode`,`Modalità`)},VI=o(()=>g([u(),r(),y(),h(u(),VI)])),Wxe=h(u(),VI);function HI(e,t,n){let[r,...i]=t;if(r===void 0)return e;if(i.length===0)return{...e,[r]:n};let a=e[r],o=typeof a==`object`?a:{};return{...e,[r]:HI(o,i,n)}}function UI(e,t,n){return HI(e,t.split(`.`),n)}var WI=x({cap:u(),method:u(),args:Wxe}),Gxe=S([`off-while-running`,`unlock`,`install`,`press`]),GI=x({id:u(),label:mI,icon:md,call:WI,emphasis:S([`primary`,`normal`]),confirm:Gxe.nullable()}),KI=a(`kind`,[x({kind:m(`action`),action:GI}),x({kind:m(`toggle`),id:u(),label:mI,on:y().nullable(),turnOn:GI,turnOff:GI}),x({kind:m(`slider`),id:u(),label:mI,value:r().nullable(),min:r(),max:r(),step:r(),unit:u(),call:WI,valueArg:u()}),x({kind:m(`picker`),id:u(),label:mI,current:u().nullable(),options:C(u()),optionLabels:h(u(),mI).optional(),call:WI,valueArg:u()}),x({kind:m(`number`),id:u(),label:mI,value:r().nullable(),step:r().nullable(),unit:u(),call:WI,valueArg:u()}),x({kind:m(`text`),id:u(),label:mI,value:u().nullable(),call:WI,valueArg:u()})]),Kxe=x({icon:md.nullable(),text:mI,tone:uI}),qxe=new Set([`cover`,`valve`,`lock`,`vacuum`,`playback`,`brightness`]),Jxe=x({id:zI,placement:S([`row`,`scene`]).optional(),label:mI.optional(),group:mI.optional(),pills:C(Kxe).optional(),icon:md,status:mI.nullable(),controls:C(KI),progress:r().min(0).max(1).nullable().optional()}),qI=x({label:mI,value:g([r(),u()]),unit:u().nullable()}),Yxe=x({id:S([`battery`,`network-link`,`integration`]),icon:md,tone:uI,value:r().nullable(),label:mI}),JI=`remote.open`,Xxe=x({commands:r().int().nullable(),open:GI.optional()}),Zxe=x({items:C(x({key:u(),label:u(),level:r().nullable(),needsAttention:y()})),attention:r().int()}),Qxe=a(`kind`,[x({kind:m(`power`),watts:r(),detail:C(qI)}),x({kind:m(`running`),running:y().nullable(),since:r().nullable(),phase:u().nullable(),detail:C(qI)})]),$xe=x({source:S([`switch`,`media-player`,`climate-control`]),on:y().nullable(),assumed:y(),turnOn:GI,turnOff:GI}),eSe=x({activeUntil:r().nullable(),quickRun:ZF,run:GI,cancel:GI,remaining:r().nullable()}),tSe=x({on:y().nullable(),confirmOffWhileRunning:y(),running:y().nullable(),powerOn:GI.nullable(),powerOff:GI.nullable(),restart:GI}),YI=x({token:S(cI),animation:S(sI)}),XI=x({id:S([`power`,`energy`,`battery`,`link`,`phase`,`remaining`,`volume`,`source`,`consumables`,`since`,`speed`,`progress`,`level`,`last-run`,`event`,`members`,`failures`,`reading`,`climate`,`temperature`,`humidity`,`pressure`,`air-quality`,`illuminance`,`valve`]),icon:md.nullable(),text:mI,tone:uI}),ZI=x({label:mI,value:mI,tone:uI.optional(),at:r().optional()}),nSe=x({left:C(ZI).max(2),right:C(ZI).max(2)}),rSe=a(`kind`,[x({kind:m(`artwork`),url:u(),fallback:YI}),x({kind:m(`state`),...YI.shape})]),iSe=x({partId:u(),cap:u()}),aSe=x({deviceId:r().int(),type:u(),role:u().nullable(),name:u(),state:lI,stateAssumed:y(),look:dI,background:rSe,scene:PI,facts:C(XI),sideTiles:nSe,title:mI,caption:mI.optional(),badges:C(Yxe),remote:Xxe.nullable(),historyLabel:mI,consumables:Zxe.nullable(),consumption:Qxe.nullable(),ownPower:$xe.nullable(),timedRun:eSe.nullable(),powerSupply:tSe.nullable(),rows:C(Jxe),measurement:xI.optional(),gated:C(u()),provenance:C(iSe)}),oSe=x({id:S([`timed-run.run`,`timed-run.cancel`]),duration:r(),unit:S([`min`,`s`])}),QI=x({deviceId:r().int(),name:u(),type:u(),state:lI,stateAssumed:y(),look:dI,scene:PI,statusLine:C(mI),primary:KI.nullable(),primaryGated:y().optional(),timedRun:oSe.nullable(),extras:C(KI).max(2).optional(),trailing:XI.nullable(),measurement:xI.optional()}),$I=[`temperature`,`humidity`,`pressure`,`illuminance`,`reading`,`air-quality`,`valve`],sSe=[`power`,`battery`,`consumables`],cSe=new Set($I);function lSe(e){for(let t of sSe){let n=e.facts.find(e=>e.id===t);if(n!==void 0)return n}return e.facts.find(t=>cSe.has(t.id)&&t.text.en===e.title.en)??null}var uSe={[M.Climate]:`climate.mode`};function dSe(e){let t=uSe[e.type];if(t!==void 0){let n=tL(e,t);if(n!==null)return{control:n,gated:!1}}let n=e.ownPower;if(n!==null)return e.gated.includes(`own-power`)?{control:null,gated:!0}:{control:{kind:`toggle`,id:`own-power`,label:n.turnOn.label,on:n.on,turnOn:n.turnOn,turnOff:n.turnOff},gated:!1};for(let t of e.rows){let n=t.controls[0];if(n!==void 0)return e.gated.includes(t.id)?{control:null,gated:!0}:{control:n,gated:!1}}return{control:null,gated:!1}}var fSe={[M.Climate]:[`climate.target`],[M.Vacuum]:[`vacuum.base`],[M.LawnMower]:[`mower.dock`],[M.MediaPlayer]:[`volume.level`,JI],[M.Automation]:[`automation.enabled`]},eL=e=>e.kind===`action`?e.action.id:e.id;function tL(e,t){if(t===`remote.open`){let t=e.remote?.open;return t===void 0||e.gated.includes(`remote`)?null:{kind:`action`,action:t}}for(let n of e.rows){if(e.gated.includes(n.id))continue;let r=n.controls.find(e=>eL(e)===t);if(r!==void 0)return r}return null}function pSe(e,t){let n=fSe[e.type]??[],r=t===null?null:eL(t);return n.filter(e=>e!==r).flatMap(t=>{let n=tL(e,t);return n===null?[]:[n]}).slice(0,2)}function mSe(e,t){let n=e.rows.find(e=>e.id===`now-playing`)?.status??null??e.title,r=e.facts.filter(e=>e!==t).map(e=>e.text).slice(0,3),i=e.timedRun;if(i===null||i.remaining===null)return[n,...r];let a=i.quickRun.unit===`min`?`min`:`s`,o={en:`${i.remaining} ${a}`,it:`${i.remaining} ${a}`};return[n,...r,o]}function hSe(e){let t=e.timedRun;return t===null||e.gated.includes(`timed-run`)?null:{id:t.activeUntil===null?`timed-run.run`:`timed-run.cancel`,duration:t.quickRun.duration,unit:t.quickRun.unit}}function gSe(e){let t=lSe(e),{control:n,gated:r}=dSe(e);return{deviceId:e.deviceId,name:e.name,type:e.type,state:e.state,stateAssumed:e.stateAssumed,look:e.look,scene:e.scene,statusLine:mSe(e,t),primary:n,primaryGated:r,timedRun:hSe(e),extras:pSe(e,n),trailing:t,...e.measurement===void 0?{}:{measurement:e.measurement}}}var _Se=x({deviceId:r().int().nonnegative(),canActuate:y().optional()}),vSe=x({deviceIds:C(r().int().nonnegative()).max(500),canActuate:y().optional()}),nL=x({type:u(),rows:C(zI)}),rL={name:`hero-layout`,scope:`system`,mode:`singleton`,methods:{getHeroModel:D(_Se,aSe.nullable(),{auth:`protected`,role:`viewer`}),getRowModels:D(vSe,C(QI.nullable()),{auth:`protected`,role:`viewer`}),getLayout:D(x({deviceType:u(),role:u().nullable().optional()}),nL,{auth:`protected`,role:`viewer`})},vocabulary:{notOperatorFacing:`the device hero model — read-only data the UI draws, never actuated`}},iL=x({on:y(),currentHumidity:r().min(0).max(100).nullable().meta(A(`humidity`)),targetHumidity:r().min(0).max(100).nullable().meta(A(`humidity`)),mode:u().nullable(),availableModes:C(u()),action:u().nullable(),minHumidity:r().nullable().meta(A(`humidity`)),maxHumidity:r().nullable().meta(A(`humidity`)),lastChangedAt:r()}),aL={name:`humidifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Humidifier],power:{kind:`field`,field:`on`,set:`setOn`},methods:{setOn:D(x({deviceId:r().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.on`,label:L(`Humidifier on`,`Umidificatore acceso`),phrase:L(`Turn on {device}`,`Accendi {device}`),icon:`power`,effect:{field:`on`,value:!0},args:{on:!0}},{id:`humidifier.off`,label:L(`Humidifier off`,`Umidificatore spento`),phrase:L(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`on`,value:!1},args:{on:!1}}]}),setTargetHumidity:D(x({deviceId:r().int().nonnegative(),humidity:r().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.target`,label:L(`Set humidity`,`Imposta l’umidità`),phrase:L(`Set {device} to {humidity} humidity`,`Imposta {device} al {humidity} di umidità`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`humidity`},openArgs:[{key:`humidity`,label:L(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMode:D(x({deviceId:r().int().nonnegative(),mode:u().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.mode`,label:L(`Set mode`,`Imposta la modalità`),phrase:L(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`list`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:L(`Mode`,`Modalità`),offer:{kind:`dynamic`,from:`status`,field:`availableModes`}}]}]})},status:{schema:iL,kind:`push`},runtimeState:iL,durability:`session`,history:{fields:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}}},vocabulary:{noun:L(`Humidifier`,`Umidificatore`),order:1090,state:[{kind:`boolean`,field:`on`,label:L(`On`,`Acceso`),whenTrue:L(`When {device} turns on`,`Quando {device} si accende`),whenFalse:L(`When {device} turns off`,`Quando {device} si spegne`),icon:`power`},{kind:`numeric`,field:`currentHumidity`,quantity:L(`the humidity`,`l’umidità`),label:L(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},oL=x({humidity:r().min(0).max(100).nullable().meta(A(`humidity`,{precision:0,label:`Humidity`})),lastFetchedAt:r()}),sL={name:`humidity-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor,M.Climate],methods:{},status:{schema:oL,kind:`push`},runtimeState:oL,durability:`restored`,history:{primary:`humidity`,priority:90,fields:{humidity:{kind:`gauge`,unit:`%`,deadband:.5}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Humidity`,`Umidità`),order:5120,state:[{kind:`numeric`,field:`humidity`,quantity:L(`the humidity`,`l’umidità`),label:L(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},cL=x({url:u().nullable(),lastUpdated:r().nullable().meta(A(`none`))}),lL={name:`image`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Image],methods:{},status:{schema:cL,kind:`push`},runtimeState:cL,durability:`session`,history:`none`,vocabulary:{noun:L(`Image`,`Immagine`),order:3130}},uL=S([`0`,`90`,`180`,`270`]),dL=S([`auto`,`manual`]),fL=S([`auto`,`manual`]),pL=S([`off`,`blc`,`wdr`,`hlc`]),mL=x({min:r(),max:r(),step:r()}),hL=x({brightness:r().optional().meta(A(`none`)),contrast:r().optional().meta(A(`none`)),saturation:r().optional().meta(A(`none`)),sharpness:r().optional().meta(A(`none`)),mirror:y().optional(),flip:y().optional(),rotate:uL.optional(),whiteBalance:dL.optional(),warmth:r().optional().meta(A(`none`)),exposureMode:fL.optional(),backlightMode:pL.optional(),lastFetchedAt:r()}),gL=x({supportsBrightness:y(),brightness:mL.optional(),supportsContrast:y(),contrast:mL.optional(),supportsSaturation:y(),saturation:mL.optional(),supportsSharpness:y(),sharpness:mL.optional(),supportsMirror:y(),supportsFlip:y(),rotateOptions:C(uL),whiteBalanceModes:C(dL),supportsWarmth:y(),warmth:mL.optional(),exposureModes:C(fL),backlightModes:C(pL)}),_L=x({brightness:r().optional(),contrast:r().optional(),saturation:r().optional(),sharpness:r().optional(),mirror:y().optional(),flip:y().optional(),rotate:uL.optional(),whiteBalance:dL.optional(),warmth:r().optional(),exposureMode:fL.optional(),backlightMode:pL.optional()}),vL={name:`image-settings`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`image-settings`,tab:`image`}},methods:{getOptions:D(x({deviceId:r()}),gL),setSettings:D(x({deviceId:r(),settings:_L}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:hL,kind:`poll`},runtimeState:hL,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Image settings`,`Impostazioni immagine`),order:3140}},yL=x({id:u(),addonId:u(),name:u(),enabled:y(),info:h(u(),w()).readonly(),originStableId:u().optional(),createdAt:r(),updatedAt:r(),processState:u()}),bL=x({id:u(),addonId:u(),name:u(),enabled:y(),info:h(u(),w()).readonly(),originStableId:u().optional(),createdAt:r(),updatedAt:r()}),xL=x({addonId:u(),name:u(),providerLabel:u().optional(),description:u(),iconUrl:u().nullable(),color:u(),instanceMode:u(),mode:S([`standalone`,`account`,`broker`]),discoveryMode:u(),kind:S([`device-adoption`,`device-provider`]),brokerKind:u().nullable(),supportsLocationImport:y(),canTest:y(),existingInstances:C(x({id:u(),name:u()})),canAdd:y()}),SL=S([`validated`,`rejected`,`inconclusive`,`unsupported`]),CL=x({success:y(),error:u().optional(),status:SL.optional(),testedBy:u().nullable().optional(),latencyMs:r().nonnegative().optional(),detail:u().optional()}),wL=x({id:u(),name:u().optional(),enabled:y().optional(),info:h(u(),w()).optional()}),TL=x({success:y(),deletedId:u()}),EL={name:`integrations`,scope:`system`,mode:`singleton`,methods:{list:D(v(),C(yL)),get:D(x({id:u()}),yL),getByAddonId:D(x({addonId:u()}),bL.nullable()),listByAddon:D(x({addonId:u()}),C(bL)),adoptInstanceRows:D(x({addonId:u(),rows:C(x({id:u().min(1),name:u(),enabled:y(),stated:y()}))}),x({created:r().int(),updated:r().int(),conflicts:C(x({id:u(),ownerAddonId:u()}))}),{kind:`mutation`,auth:`admin`}),update:D(wL,bL,{kind:`mutation`,auth:`admin`}),delete:D(x({id:u()}),TL,{kind:`mutation`,auth:`admin`}),getAvailableTypes:D(v(),C(xL),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:k.ADDON_ADMIN}},ySe=ye(),DL=u().min(1),OL=S([`single`,`multiple`]),kL=S([`devices`,`services`]),AL=x({id:u().min(1),label:u().min(1),functionCap:u().min(1),brokerKind:u().min(1).optional(),alsoServes:C(u().min(1)).optional(),iconUrl:u().min(1).optional(),iconMediaType:u().min(1).optional(),role:kL.optional(),canTest:y().optional(),signIn:x({basePath:u().min(1),methods:C(S([`device-code`,`proxy`])).optional()}).optional(),connectPath:u().min(1).optional(),disconnectPath:u().min(1).optional(),widgets:C(x({id:u().min(1),placement:S([`connection`,`model`])})).optional()}),jL=x({mode:S([`none`,`lan`,`account`]),scopedToInstance:y()}),ML=x({kind:u().min(1),field:u().min(1),to:x({cap:u().min(1),kind:u().min(1).optional()})}),NL=x({role:kL,discovery:jL.optional(),instanceMode:OL,kind:u(),canTest:y(),kinds:C(AL).min(1),allowRestoreId:y().optional(),mintsId:y().optional(),links:C(ML).optional(),userScoped:y().optional()}),PL=x({state:S([`ok`,`off`,`error`,`unknown`]),detail:u().optional(),label:u().optional()}),FL=S([`scan`,`children`,`none`]),IL=x({id:DL,name:u(),configured:y(),enabled:y().optional(),kind:u().min(1),formValues:h(u(),w()),status:PL.optional(),lastCheckedAt:r().optional(),addDevice:FL.optional()}),LL=x({id:DL,name:u().min(1).optional(),values:h(u(),w())}),RL={name:`integration-instances`,scope:`system`,mode:`collection`,methods:{describe:D(v(),NL,{auth:`admin`}),instanceFormSchema:D(x({id:DL.nullable(),kind:u().min(1).optional(),mode:S([`standalone`,`account`,`broker`]).optional(),candidateStableId:u().min(1).optional()}),ySe,{auth:`admin`}),listInstances:D(ce({}),C(IL).readonly(),{auth:`protected`,caller:`scoped`}),getInstance:D(x({id:DL}),IL.nullable(),{auth:`protected`,caller:`scoped`}),createInstance:D(x({id:DL.optional(),name:u().min(1),kind:u().min(1).optional(),values:h(u(),w()).optional(),originStableId:u().min(1).optional(),seed:x({info:h(u(),w())}).optional()}),x({id:u()}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),updateInstance:D(LL,x({ok:m(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),setInstanceEnabled:D(x({id:DL,enabled:y()}),x({ok:m(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),deleteInstance:D(x({id:DL}),x({ok:m(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),testInstance:O(x({id:DL.nullable(),values:h(u(),w()),kind:u().min(1).optional()}),CL,{kind:`mutation`,auth:`protected`,caller:`scoped`})},vocabulary:{notOperatorFacing:k.INTERNAL}},zL=x({codecs:C(u()),sampleRate:r().meta(A(`none`)),duplex:S([`half`,`full`]),maxBacklogMs:r().meta(A(`duration-ms`))}),BL=x({talking:y(),lastSessionAt:r().nullable(),ability:zL.nullable()}),bSe=S([`opus`,`s16le`,`g711ulaw`,`g711alaw`]),VL={name:`intercom`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],methods:{startSession:D(x({deviceId:r()}),x({sessionId:u(),sdpOffer:u()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),handleAnswer:D(x({deviceId:r(),sessionId:u(),sdpAnswer:u()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),stopSession:D(x({deviceId:r(),sessionId:u()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),startTalkSession:D(x({deviceId:r()}),x({sessionId:u()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`two-way talk is a person speaking through the viewer, not an automation step`}),pushTalkAudio:D(x({deviceId:r(),audioBase64:u(),codec:bSe.optional(),sampleRate:r().int().positive().optional(),channels:r().int().positive().optional(),sequenceNumber:r().int()}),x({accepted:y()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),endTalkSession:D(x({deviceId:r()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`})},events:{onStatusChanged:{data:x({deviceId:r(),status:BL}),notOperatorFacing:"the `talking` state trigger phrases both edges of this change"}},status:{schema:BL,kind:`command-driven`},runtimeState:BL,durability:`session`,history:`none`,vocabulary:{noun:L(`Intercom`,`Citofono`),order:3150,state:[{kind:`boolean`,field:`talking`,label:L(`Talking`,`In conversazione`),whenTrue:L(`When someone starts talking through {device}`,`Quando qualcuno inizia a parlare tramite {device}`),whenFalse:L(`When the conversation on {device} ends`,`Quando la conversazione su {device} finisce`),icon:`mic`}]}},HL=S([`carrierHz`,`dutyCyclePercent`,`repeat`,`repeatDelayMs`]),UL=S([`ir`,`rf`]),WL=x({ok:m(!0),ignoredSettings:C(u())}),GL=x({media:C(UL),settable:C(HL),maxTimings:r().int().positive(),learn:y().default(!1),formats:C(bT).default([])}),KL=2e4,qL=6e4,JL=x({native:ST.nullable(),timings:dT,carrierHz:r().int().positive().nullable()}),YL=x({at:r(),ok:y(),error:u().nullable()}),XL=YL.extend({medium:UL}),ZL=x({lastSend:XL.nullable(),lastLearn:YL.nullable(),lastFetchedAt:r()});function QL(e){return!(e.kind===`learn`&&e.error===`ir-transmitter.learn-unsupported`)}function xSe(e,t,n){let r=e??{lastSend:null,lastLearn:null,lastFetchedAt:n};return QL(t)?t.kind===`send`?{lastSend:{at:n,ok:t.ok,error:t.error,medium:t.medium},lastLearn:r.lastLearn,lastFetchedAt:n}:{lastSend:r.lastSend,lastLearn:{at:n,ok:t.ok,error:t.error},lastFetchedAt:n}:r}function SSe(e){return _i(e)?.code??null}var $L={name:`ir-transmitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Generic],methods:{send:D(x({deviceId:r().int().nonnegative(),timings:dT.optional(),native:ST.optional(),settings:fT.optional()}).refine(e=>e.timings===void 0!=(e.native===void 0),{message:`send takes exactly one of timings or native`}),WL,{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it`}),learn:D(x({deviceId:r().int().nonnegative(),timeoutMs:r().int().positive().max(qL).default(KL)}),JL,{kind:`mutation`,auth:`protected`,notOperatorFacing:`an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal`}),getInfo:D(x({deviceId:r().int().nonnegative()}),GL,{kind:`query`,auth:`protected`})},runtimeState:ZL,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`IR / RF transmitter`,`Trasmettitore IR / RF`),order:1140}},eR=S([`key-missing`,`wrong-key`,`key-file-unreadable`,`store-unavailable`,`not-initialized`,`decrypt-failed`]),tR=a(`state`,[x({state:m(`ready`)}),x({state:m(`locked`),reason:eR})]),nR=a(`kind`,[x({kind:m(`value`),value:u(),version:r().int()}),x({kind:m(`missing`)}),x({kind:m(`unavailable`),reason:eR}),x({kind:m(`forbidden`)})]),rR=h(u(),nR),iR=x({ref:u(),owner:u(),scope:u(),fieldPath:u(),version:r().int(),createdAt:r(),updatedAt:r(),updatedBy:u(),lastReadAt:r().nullable()}),aR=C(u().min(1)).max(512),oR={name:`keychain`,scope:`system`,mode:`singleton`,internal:!0,methods:{put:D(x({ref:u().min(1),value:u().min(1)}),x({ref:u(),version:r().int()}),{kind:`mutation`,auth:`admin`}),resolve:D(x({refs:aR}),rR,{auth:`admin`}),delete:D(x({refs:aR}),x({deleted:r().int()}),{kind:`mutation`,auth:`admin`}),deleteDeviceScope:D(x({deviceId:r().int()}),x({refs:C(u()).readonly()}),{kind:`mutation`,auth:`admin`}),releaseRecordRefs:D(x({refs:aR,onBehalfOf:u().min(1)}),x({released:r().int()}),{kind:`mutation`,auth:`admin`}),listMeta:D(x({}),C(iR).readonly(),{auth:`admin`}),getState:D(x({}),tR,{auth:`admin`})},vocabulary:{notOperatorFacing:k.IDENTITY}},sR=S([`mounted-file`,`previous-mounted-file`,`platform`,`default-file`]),cR=x({kind:sR,path:u().optional(),sharesBackupWithDatabase:y()}),lR=`trigger-file`,uR=x({id:u(),at:r(),actor:u(),lockedReason:u().nullable(),archived:r().int(),archivedCollection:u().nullable(),archivedKeysCollection:u().nullable(),clearedSettingsKeys:C(u()).readonly(),acknowledgedAt:r().nullable()}),dR=x({keychain:tR,keySource:cR.nullable(),configuredSource:cR,fingerprint:u().nullable(),activeKeyId:u().nullable(),rotationPending:y(),retiredWraps:r().int(),recoveryKeyDownloadedAt:r().nullable(),secretCount:r().int(),lastReset:uR.nullable()}),fR=S([`in-use`,`orphan`,`unknown`]),pR=iR.extend({usage:fR}),mR=S([`put`,`delete`,`reveal`,`rotate-master-key`,`purge-retired-keys`,`download-recovery-key`,`delete-orphans`,`reset`,`acknowledge-reset`,`initialize`]),hR=x({id:u(),at:r(),action:mR,actor:u(),ref:u().nullable(),detail:u().nullable()}),gR=`RESET KEYCHAIN`,_R=S([`jwt-signing-key`]),vR={name:`keychain-admin`,scope:`system`,mode:`singleton`,methods:{status:D(x({}),dR,{auth:`admin`}),listSecrets:D(x({}),C(pR).readonly(),{auth:`admin`}),listAudit:D(x({limit:r().int().min(1).max(500).optional()}),C(hR).readonly(),{auth:`admin`}),reveal:D(x({ref:u().min(1)}),x({value:u(),version:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),setSystemSecret:D(x({name:_R,value:u().min(16)}),x({ref:u(),version:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),importSecret:D(x({ref:u().min(1),value:u().min(1)}),x({ref:u(),version:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteOrphans:D(x({refs:C(u().min(1)).max(1e3)}),x({deleted:C(u()).readonly(),kept:C(x({ref:u(),usage:fR})).readonly()}),{kind:`mutation`,auth:`admin`,caller:`required`}),rotateMasterKey:D(x({}),x({fingerprint:u(),keySource:cR}),{kind:`mutation`,auth:`admin`,caller:`required`}),purgeRetiredKeys:D(x({}),x({purged:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),downloadRecoveryKey:D(x({}),x({key:u(),fingerprint:u(),keySource:cR}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetKeychain:D(x({confirm:m(gR)}),x({archivedCollection:u().nullable(),archived:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetReport:D(x({}),x({reset:uR.nullable(),pendingReentry:C(iR).readonly()}),{auth:`admin`}),acknowledgeReset:D(x({}),x({acknowledged:y()}),{kind:`mutation`,auth:`admin`,caller:`required`})},vocabulary:{notOperatorFacing:k.IDENTITY}},yR=S([`idle`,`mowing`,`paused`,`docked`,`error`]),bR=S([`info`,`warning`,`error`]),xR=x({activity:yR,batteryLevel:r().min(0).max(100).nullable().meta(A(`percentage`)),progress:r().min(0).max(100).nullable().meta(A(`percentage`)),currentCode:r().nullable().meta(A(`none`)),currentCodeLabel:u().nullable(),severity:bR,lastChangedAt:r()}),SR={name:`lawn-mower-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.LawnMower],methods:{startMowing:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.start`,label:L(`Start mowing`,`Avvia il taglio`),phrase:L(`Start {device} mowing`,`Fai partire il taglio di {device}`),icon:`play`}]}),pause:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.pause`,label:L(`Pause mower`,`Metti in pausa il tosaerba`),phrase:L(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),dock:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.dock`,label:L(`Dock mower`,`Riporta alla base`),phrase:L(`Send {device} back to its dock`,`Rimanda {device} alla base`),icon:`house`}]})},status:{schema:xR,kind:`push`},runtimeState:xR,durability:`session`,history:{fields:{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}}},vocabulary:{noun:L(`Robot mower`,`Robot tosaerba`),order:2010,state:[{kind:`enum`,field:`activity`,label:L(`Activity`,`Attività`),values:[{value:`idle`,label:L(`Idle`,`Inattivo`)},{value:`mowing`,label:L(`Mowing`,`In taglio`),phrase:L(`When {device} starts mowing`,`Quando {device} inizia a tagliare`)},{value:`paused`,label:L(`Paused`,`In pausa`)},{value:`docked`,label:L(`Docked`,`Alla base`),phrase:L(`When {device} docks`,`Quando {device} arriva alla base`)},{value:`error`,label:L(`Error`,`Errore`),phrase:L(`When {device} reports an error`,`Quando {device} segnala un errore`)}],icon:`bot`},{kind:`numeric`,field:`batteryLevel`,quantity:L(`the battery level`,`il livello della batteria`),label:L(`Battery`,`Batteria`),unit:`%`,icon:`battery`}]}},CR=6e5,CSe=60*6e4,wR=x({inputTokens:r(),outputTokens:r()}),TR=S([`timeout`,`rate-limited`,`auth`,`refusal`,`bad-request`,`unavailable`,`no-profile`,`budget-exceeded`,`adapter-error`]),ER=x({ok:m(!0),text:u(),model:u(),usage:wR,truncated:y(),latencyMs:r()}),DR=S([`guardrail`,`model`]),OR=x({ok:m(!1),code:TR,message:u(),retryAfterMs:r().optional(),refusalSource:DR.optional()}),kR=a(`ok`,[ER,OR]),AR=x({bytes:b(Uint8Array),mimeType:u()}),jR=x({enabled:y().default(!1),maxAttempts:r().int().min(1).max(5).default(1)}),wSe={totalMs:6e4,connectMs:1e4,firstTokenMs:12e4,idleMs:6e4},MR=x({addonId:u().optional(),profileId:u().optional(),consumer:u(),system:u().optional(),prompt:u(),jsonSchema:h(u(),w()).optional(),maxTokens:r().int().positive().optional(),temperature:r().optional(),topP:r().min(0).max(1).optional(),topK:r().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),timeoutMs:r().int().positive().optional(),retry:jR.optional(),requestId:u().optional()}),NR=x({url:u(),filename:u(),sizeBytes:r(),sha256:u().optional()}),PR=a(`kind`,[x({kind:m(`catalog`),catalogId:u()}),x({kind:m(`url`),url:u(),sha256:u().optional(),label:u().optional(),sizeBytes:r().optional(),extraFiles:C(NR).optional()}),x({kind:m(`path`),path:u()})]),FR=x({nodeId:u(),engine:S([`llama-cpp`]),model:PR,contextSize:r().int().default(4096),gpuLayers:r().int().default(0),threads:r().int().optional(),parallel:r().int().default(1),batchSize:r().int().positive().optional(),ubatchSize:r().int().positive().optional(),flashAttention:y().default(!1),mlock:y().default(!1),noMmap:y().default(!1),cacheTypeK:S([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),cacheTypeV:S([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),extraArgs:C(u()).default([]),autoStart:y().default(!1),idleStopMinutes:r().int().default(30)}),IR=x({phase:S([`downloading`,`verifying`]),file:u(),fileIndex:r().int(),fileCount:r().int(),downloadedBytes:r(),totalBytes:r().optional()}),LR=x({nodeId:u(),state:S([`stopped`,`downloading`,`starting`,`ready`,`crashed`,`failed`]),pid:r().optional(),port:r().optional(),modelPath:u().optional(),modelId:u().optional(),downloadProgress:r().min(0).max(1).optional(),download:IR.optional(),lastError:u().optional(),crashesInWindow:r(),memoryBytes:r().optional(),vramBytes:r().optional()}),RR=x({file:u(),sizeBytes:r(),catalogId:u().optional(),installedAt:r().optional(),path:u().optional()}),zR=x({nodeId:u(),modelsBytes:r(),freeBytes:r().optional()}),BR=MR.extend({images:C(AR).optional(),runtime:FR,timeoutMs:r().int().positive().optional()}),VR=S([`deviceNotEligible`,`appleIntelligenceNotEnabled`,`modelNotReady`,`osTooOld`,`helperMissing`,`helperCrashed`]),HR=a(`state`,[x({state:m(`available`),osVersion:u(),contextSize:r().int().positive(),languages:C(u()),imageInput:y()}),x({state:m(`unavailable`),reason:VR,osVersion:u().nullable(),detail:u()}),x({state:m(`unsupported-platform`),platform:u()}),x({state:m(`unknown`),error:u()})]),UR=MR.extend({images:C(AR).optional(),timeoutMs:r().int().positive().optional()}),WR=x({requestId:u()}),GR={name:`llm-runtime`,scope:`system`,mode:`singleton`,internal:!0,methods:{complete:D(BR,kR,{kind:`mutation`,auth:`admin`,timeoutMs:CR}),ensureStarted:D(x({runtime:FR}),LR,{kind:`mutation`,auth:`admin`,timeoutMs:CR}),stop:D(x({}),v(),{kind:`mutation`,auth:`admin`}),status:D(x({}),LR,{auth:`admin`}),installModel:D(x({model:PR}),v(),{kind:`mutation`,auth:`admin`,timeoutMs:CSe}),deleteModel:D(x({file:u()}),v(),{kind:`mutation`,auth:`admin`}),listLocalModels:D(x({}),C(RR),{auth:`admin`}),getDiskUsage:D(x({}),zR,{auth:`admin`}),cancel:D(WR,v(),{kind:`mutation`,auth:`admin`}),appleAvailability:D(x({}),HR,{auth:`admin`}),completeApple:D(UR,kR,{kind:`mutation`,auth:`admin`,timeoutMs:CR})},vocabulary:{notOperatorFacing:k.ML}},KR=/^[a-z0-9][a-z0-9-]{0,63}$/,qR=u().regex(KR,`a kind id is lower-case letters, digits and dashes`),JR=x({vision:y(),tools:y(),streaming:y(),reasoning:y().nullable().optional()}),YR=x({id:u(),label:u().optional(),contextLength:r().int().positive().optional(),features:JR.partial().optional()}),XR=h(u(),w()),TSe=x({id:u(),name:u(),kind:qR,addonId:u(),enabled:y(),model:u(),supportsVision:y(),temperature:r().min(0).max(2).optional(),topP:r().min(0).max(1).optional(),topK:r().int().positive().optional(),maxTokens:r().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),contextLength:r().int().positive().optional(),systemPrompt:u().optional(),timeoutMs:r().int().positive().default(6e4),connectTimeoutMs:r().int().positive().default(1e4),firstTokenTimeoutMs:r().int().positive().default(12e4),idleTimeoutMs:r().int().positive().default(6e4),retry:jR.default({enabled:!1,maxAttempts:1}),toolsEnabled:y().default(!1),providerConfig:XR.default({})}),ZR=S([`temperature`,`topP`,`topK`,`maxTokens`,`reasoningEffort`,`contextLength`,`systemPrompt`,`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`]),QR=x({id:u(),placement:S([`connection`,`model`]),requires:C(u()).optional()}),$R=w(),ESe=x({kind:qR,label:u(),icon:u(),addonId:u(),connectionSchema:$R,advancedSchema:$R.optional(),features:JR,visionEditable:y(),modelCatalog:S([`fetch`,`static`,`none`]),staticModels:C(YR).optional(),profileFields:C(ZR),providerWidgets:C(QR).optional()}),ez=x({addonId:u(),kind:qR,profileId:u().optional(),connection:XR.optional()}),tz=S([`auth`,`network`,`unsupported`,`invalid`]),nz=a(`ok`,[x({ok:m(!0),models:C(YR)}),x({ok:m(!1),code:tz,message:u()})]),rz=g([x({consumer:u()}),x({purpose:S([`text`,`vision`])})]),iz=x({selector:rz,profileId:u()}),az=x({day:u(),consumer:u(),profileId:u(),calls:r(),okCalls:r(),errorCalls:r(),inputTokens:r(),outputTokens:r(),avgLatencyMs:r()}),oz=x({id:u(),label:u(),family:u(),purpose:S([`text`,`vision`]),url:u(),sha256:u(),sizeBytes:r(),quantization:u(),minRamBytes:r(),contextSizeDefault:r().int(),mmprojUrl:u().optional()}),sz=a(`ok`,[x({ok:m(!0),model:PR,label:u(),repo:u(),quantization:u(),purpose:S([`text`,`vision`]),totalBytes:r(),extraFilenames:C(u())}),x({ok:m(!1),code:u(),message:u(),candidates:C(u()).optional(),requiredBytes:r().optional()})]),cz=x({nodeId:u(),reachable:y(),status:LR.optional(),disk:zR.optional(),error:u().optional(),apple:HR.optional()}),DSe=MR.extend({images:C(AR).min(1)}),lz=x({addonId:u(),profileId:u()}),uz={name:`llm`,scope:`system`,mode:`collection`,internal:!1,providerKind:`ai`,nodeIdMode:`data`,methods:{generate:D(MR,kR,{kind:`mutation`,timeoutMs:CR}),generateVision:D(DSe,kR,{kind:`mutation`,timeoutMs:CR}),cancel:D(x({addonId:u().optional(),requestId:u()}),v(),{kind:`mutation`}),listModels:D(ez,nz,{kind:`mutation`,auth:`admin`}),getDefaults:D(x({}),C(iz)),setDefault:D(x({selector:rz,profileId:u().nullable()}),v(),{kind:`mutation`,auth:`admin`}),getUsage:D(x({since:r().optional(),until:r().optional(),consumer:u().optional(),profileId:u().optional()}),C(az)),listModelCatalog:D(x({}),C(oz)),listRuntimeNodes:D(x({}),C(cz)),listNodeModels:D(x({nodeId:u()}),C(RR)),resolveModelRef:D(x({ref:u(),maxBytes:r().positive().optional()}),sz,{kind:`mutation`,auth:`admin`}),installModel:D(x({nodeId:u(),model:PR}),v(),{kind:`mutation`,auth:`admin`}),deleteModel:D(x({nodeId:u(),file:u()}),v(),{kind:`mutation`,auth:`admin`}),getRuntimeStatus:D(lz,LR),startRuntime:D(lz,LR,{kind:`mutation`,auth:`admin`}),stopRuntime:D(lz,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.ML}},dz=[`decode`,`transcode`,`recording`,`streaming`,`detection`],fz=[`measured`,`accounted`,`unattributable`],pz=x({role:S(dz),deviceId:r().int().positive().nullable(),attribution:S(fz),unit:u(),pid:r().int().positive().optional(),startedAtMs:r().optional(),cpuSeconds:r().optional(),rssBytes:r().optional()}),mz={name:`load-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:D(v(),C(pz).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.INTERNAL}},hz=`https://camstack.zentik.app`,gz=`/viewer/camstack`;function _z(e){if(e==null||e===``)return!1;try{return new URL(e).origin===hz}catch{return!1}}function OSe(e){let t=e.baseUrl??e.resolved;return _z(t)?{form:`app`,hubBaseUrl:e.appLinkHub??null}:{form:`hub`,hubBaseUrl:t}}function vz(e){let t;try{t=new URL(e)}catch{return null}return t.protocol!==`https:`&&t.protocol!==`http:`||t.username!==``||t.password!==``||t.hostname===``?null:t.origin}function kSe(e){let t=e=>e.kind!==`public`||!e.baseUrl.startsWith(`https://`)?null:e.interfaceKind===`public`?0:e.interfaceKind===`vpn`?1:null;return e.flatMap(e=>{let n=t(e),r=vz(e.baseUrl);return n===null||r===null?[]:[{r:n,p:e.priority,origin:r}]}).toSorted((e,t)=>e.r-t.r||e.p-t.p)[0]?.origin??null}function ASe(e){switch(e.kind){case`camera`:{if(!Number.isInteger(e.deviceId)||e.deviceId<=0)return null;let t=e.atMs;return{path:`/camera/${String(e.deviceId)}`,query:t!==void 0&&Number.isFinite(t)?[[`at`,String(Math.trunc(t))]]:[]}}case`events`:return{path:`/events`,query:[]};case`notifications`:return{path:`/notifications`,query:[]}}}function yz(e){return e.length===0?``:`?${e.map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`}function jSe(e){let t=ASe(e.destination);if(t===null)return null;let n=e.base.hubBaseUrl,r=n===null?``:n.replace(/\/+$/,``);if(e.base.form===`app`){let e=r===``?null:vz(r),n=e===null?t.query:[...t.query,[`hub`,e]];return`${hz}${t.path}${yz(n)}`}return r===``||_z(r)?null:`${r}${gz}${t.path}${yz(t.query)}`}var bz=[`appConnections`,`notificationTaps`,`internal`,`publicEndpoint`],MSe=[`notificationTaps`,`internal`,`publicEndpoint`];function NSe(e){return e!==`appConnections`}var PSe={appConnections:[],notificationTaps:null,internal:null,publicEndpoint:null},FSe=/^\d{1,3}(?:\.\d{1,3}){3}$/;function xz(e){try{let t=new URL(e).hostname;return t.length>0?t:null}catch{return null}}function ISe(e){return e.replace(/\/+$/,``)}function Sz(e){return e.kind===`public`&&e.interfaceKind===`vpn`}function LSe(e){return e.kind===`public`&&e.interfaceKind===`public`}function Cz(e){return(e.kind===`lan-ipv4`||e.kind===`lan-ipv6`)&&e.plausible}function wz(e){if(e.kind!==`lan-ipv4`||!e.plausible)return!1;let t=xz(e.baseUrl);return t!==null&&FSe.test(t)}function Tz(e){return e.stable===!1}function RSe(e,t){return t.kind===`loopback`||t.kind===`app-link`||t.kind===`custom`||xz(t.baseUrl)===null||Tz(t)?null:e===`internal`?wz(t)?0:Cz(t)?1:Sz(t)?2:null:LSe(t)?0:Sz(t)?1:wz(t)?2:Cz(t)?3:null}var zSe=new Set([`localhost`,`0.0.0.0`,`::1`,`[::1]`,`::`,`[::]`]);function BSe(e){let t=e.toLowerCase();return zSe.has(t)||t.endsWith(`.localhost`)?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}function Ez(e){let t=e.trim();if(t===``)return{ok:!1,reason:`Enter an address, e.g. https://192.0.2.20:4443.`};let n;try{n=new URL(t)}catch{return{ok:!1,reason:`Not a URL — include http:// or https://.`}}return n.protocol!==`https:`&&n.protocol!==`http:`?{ok:!1,reason:`Use an http:// or https:// address.`}:n.username!==``||n.password!==``?{ok:!1,reason:`The address must not carry a user name or password.`}:n.hostname===``?{ok:!1,reason:`The address has no host.`}:BSe(n.hostname)?{ok:!1,reason:`A loopback address names whoever dials it, never this hub — use an address other machines reach.`}:n.pathname!==`/`||n.search!==``||n.hash!==``?{ok:!1,reason:`Enter only the address (scheme, host and port), without a path.`}:{ok:!0,baseUrl:n.origin}}var Dz=`The public endpoint needs an https:// address: passkeys and most identity providers refuse a plain-http origin. Accept http only when sign-in and notification links never leave your own network.`;function Oz(e,t,n={}){if(_z(t))return e===`notificationTaps`?{ok:!0,baseUrl:hz}:{ok:!1,reason:`The CamStack app link is not a hub address — only notification taps can use it.`};let r=Ez(t);return r.ok&&e===`publicEndpoint`&&r.baseUrl.startsWith(`http:`)&&n.acceptInsecureHttp!==!0?{ok:!1,reason:Dz}:r}function kz(e,t){if(t===null||t===``)return null;let n=Oz(e,t,{acceptInsecureHttp:!0});return n.ok?n.baseUrl:null}function VSe(e,t){let n=e.flatMap(e=>{let n=RSe(t,e);return n===null?[]:[{rank:n,priority:e.priority,endpoint:e}]}).toSorted((e,t)=>e.rank-t.rank||e.priority-t.priority)[0];return n===void 0?null:ISe(n.endpoint.baseUrl)}function Az(e,t,n){let r=kz(t,n);if(r!==null)return{flagged:r,resolved:r,source:`flagged`};let i=VSe(e,t);return{flagged:null,resolved:i,source:i===null?`none`:`auto`}}function jz(e,t){return Az(e,`internal`,t.internal)}function Mz(e,t){return Az(e,`publicEndpoint`,t.publicEndpoint)}function Nz(e){let t=kz(`notificationTaps`,e.notificationTaps);return t!==null&&!_z(t)?{flagged:t,resolved:t,source:`flagged`}:{flagged:null,resolved:hz,source:`auto`}}function Pz(e){return Tz(e)?!1:e.kind===`lan-ipv4`?!0:e.kind===`public`&&e.interfaceKind===`public`}function Fz(e,t){let n=e.filter(Pz);if(t.appConnections.length===0)return n;let r=new Set(t.appConnections),i=e.filter(e=>r.has(e.baseUrl));return i.length>0?i:n}function Iz(e,t){let n=new Set(t.appConnections),r=Fz(e,t),i=r.some(e=>n.has(e.baseUrl));return{flagged:t.appConnections,resolved:r.map(e=>e.baseUrl),source:r.length===0?`none`:i?`flagged`:`auto`}}function HSe(e,t,n){return{appConnections:Iz(e,n),notificationTaps:Nz(n),internal:jz(t,n),publicEndpoint:Mz(t,n)}}function USe(e){return e===null?null:xz(e)}var WSe=`camstack`,GSe=`_camstack._tcp.local`,KSe={nodeId:`nodeId`,version:`version`,role:`role`,url:`url`,hubId:`hubId`},Lz=/^hub-[0-9a-f]{16}$/;function qSe(e){return typeof e==`string`&&Lz.test(e)}var JSe=`camstack-agent`,YSe=`_camstack-agent._tcp.local`,XSe={nodeId:`nodeId`,version:`version`,name:`name`,state:`state`,keyFingerprint:`fp`},ZSe=S([`lan`,`wifi`,`docker`,`vpn`,`loopback`,`other`]),Rz=x({name:u(),family:S([`IPv4`,`IPv6`]),address:u(),cidr:u(),netmask:u(),internal:y(),mac:u(),kind:ZSe,preferred:y(),plausible:y(),plausibleReason:u()}),QSe=x({interfaces:C(Rz).readonly(),probedAt:r()}),$Se=Rz.nullable(),zz=x({label:u(),baseUrl:u(),kind:S([`lan-ipv4`,`lan-ipv6`,`public`,`loopback`,`app-link`,`custom`]),interfaceKind:S([`lan`,`wifi`,`docker`,`vpn`,`other`,`loopback`,`public`]),plausible:y(),plausibleReason:u(),priority:r(),stable:y().optional()}),eCe=S([`server-config`,`server-env`,`caller-hint`,`default`]),tCe=x({port:r().int().min(1).max(65535),source:eCe}),nCe=x({endpoints:C(zz).readonly(),localPort:tCe}),Bz=x({baseUrl:u().nullable(),resolved:u().nullable(),appLinkHub:u().nullable()}),Vz=x({baseUrls:C(u()).readonly(),resolved:C(u()).readonly()}),Hz=x({override:u().nullable(),resolved:u().nullable(),source:S([`override`,`auto`,`none`])}),rCe=x({cluster:Hz,browser:Hz}),Uz=S(bz),Wz=S([`flagged`,`auto`,`none`]),Gz=x({flagged:u().nullable(),resolved:u().nullable(),source:Wz}),iCe=x({flagged:C(u()).readonly(),resolved:C(u()).readonly(),source:Wz}),Kz=x({rows:C(zz.extend({detected:y(),custom:y(),flags:C(Uz).readonly(),inUse:C(Uz).readonly(),eligible:C(Uz).readonly()})).readonly(),roles:x({appConnections:iCe,notificationTaps:Gz,internal:Gz,publicEndpoint:Gz}),appLinkHub:u().nullable(),listenerOrigins:C(u()).readonly().optional()}),qz=x({addresses:C(u()).readonly()}),Jz=x({mode:S([`generated`,`uploaded`,`disabled`]),leafFingerprintSha256:u().nullable(),caFingerprintSha256:u().nullable(),validTo:u().nullable(),sans:C(u()),caCertPem:u().nullable(),reissueError:u().nullable(),restartRequired:y(),caMissing:y(),localCaConstrained:y().nullable(),caReplacedAt:u().nullable(),storedUpload:x({leafFingerprintSha256:u(),validTo:u(),hasCa:y()}).nullable()}),aCe=x({providerId:u().min(1),modes:C(lj)}),oCe=x({providerId:u().optional(),mode:u().optional(),message:u()}),sCe=x({hostsProbed:r().int(),hits:r().int(),timeouts:r().int(),byMode:h(u(),x({probed:r().int(),hits:r().int(),timeouts:r().int()}))}),cCe=x({hits:C(x({providerId:u(),hit:uj})),subnetsScanned:C(u()),errors:C(oCe),stats:sCe}),Yz={name:`local-network`,scope:`system`,mode:`singleton`,methods:{list:D(v(),QSe),getPreferred:D(v(),$Se),getConnectionEndpoints:D(x({port:r().int().min(1).max(65535).optional(),includeLoopback:y().optional(),ipv4Only:y().optional(),scheme:S([`http`,`https`]).optional(),includeAppLink:y().optional()}),nCe),getNotificationEndpoint:D(v(),Bz),setNotificationEndpoint:D(x({baseUrl:u().nullable()}),Bz,{kind:`mutation`}),getViewerEndpoints:D(v(),Vz),setViewerEndpoints:D(x({baseUrls:C(u()).readonly()}),Vz,{kind:`mutation`}),getAddresses:D(x({scheme:S([`http`,`https`]).optional()}).optional(),Kz),addCustomAddress:D(x({baseUrl:u(),label:u().max(80)}),Kz,{kind:`mutation`,auth:`admin`}),removeCustomAddress:D(x({baseUrl:u()}),Kz,{kind:`mutation`,auth:`admin`}),setAddressRole:D(x({role:Uz,baseUrl:u().nullable(),enabled:y(),acceptInsecureHttp:y().optional()}),Kz,{kind:`mutation`,auth:`admin`}),getHubAddresses:D(v(),rCe),getAllowedAddresses:D(v(),qz),setAllowedAddresses:D(qz,x({success:m(!0)}),{kind:`mutation`}),resetAllowlistToBestMatch:D(v(),qz,{kind:`mutation`}),getTlsStatus:D(v(),Jz),regenerateCertificate:D(x({reason:u().optional()}),Jz,{kind:`mutation`,auth:`admin`}),uploadCertificate:D(x({certPem:u().min(1),keyPem:u().min(1),caPem:u().optional()}),Jz,{kind:`mutation`,auth:`admin`}),downloadCa:D(v(),x({pem:u()})),useStoredUploadedCertificate:D(v(),Jz,{kind:`mutation`,auth:`admin`}),scanNetwork:D(x({requests:C(aCe),subnets:C(u()).optional()}),cCe,{kind:`mutation`,auth:`admin`,timeoutMs:9e4}),getScanSubnets:D(v(),x({subnets:C(u())}),{auth:`admin`}),setScanSubnets:D(x({subnets:C(u())}),x({subnets:C(u())}),{kind:`mutation`,auth:`admin`}),revertToGeneratedCertificate:D(v(),Jz,{kind:`mutation`,auth:`admin`})},mount:{kind:`hub-only`},vocabulary:{notOperatorFacing:k.NETWORK}},Xz=S([`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]),Zz=x({state:Xz,codeRequired:y().nullable().optional(),lastChangedAt:r()}),lCe={version:1,overridable:[{path:`state`,by:`door-contact`}],targets:[{id:`door-contact`,cardinality:`scalar`,vocabulary:{cap:`lock-control`,stateField:`state`},deviceTypes:[M.Lock],apply:`replace`,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},sources:[{kind:`binary`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}]},Qz={name:`lock-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Lock],methods:{lock:D(x({deviceId:r().int().nonnegative(),code:u().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.lock`,label:L(`Lock`,`Chiudi a chiave`),phrase:L(`Lock {device}`,`Chiudi a chiave {device}`),icon:`lock`,effect:{field:`state`,value:`locked`},hold:{effects:[{field:`state`,value:`locking`,when:{field:`state`,notIn:[`locked`]}}]},openArgs:[{key:`code`,label:L(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),unlock:D(x({deviceId:r().int().nonnegative(),code:u().min(1).optional(),confirm:y().optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.unlock`,label:L(`Unlock`,`Apri la serratura`),phrase:L(`Unlock {device}`,`Sblocca {device}`),icon:`lock-open`,effect:{field:`state`,value:`unlocked`},hold:{effects:[{field:`state`,value:`unlocking`,when:{field:`state`,notIn:[`unlocked`]}}]},openArgs:[{key:`code`,label:L(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),open:O(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.open`,label:L(`Open latch`,`Apri lo scrocco`),phrase:L(`Release the latch of {device}`,`Fai scattare lo scrocco di {device}`),icon:`door-open`}]})},status:{schema:Zz,kind:`push`},runtimeState:Zz,customize:lCe,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Lock`,`Serratura`),order:1060,state:[{kind:`enum`,field:`state`,label:L(`Lock state`,`Stato della serratura`),values:[{value:`locked`,label:L(`Locked`,`Chiusa a chiave`),phrase:L(`When {device} locks`,`Quando {device} si chiude a chiave`)},{value:`unlocked`,label:L(`Unlocked`,`Sbloccata`),phrase:L(`When {device} unlocks`,`Quando {device} si sblocca`)},{value:`locking`,label:L(`Locking`,`In chiusura`),phrase:L(`When {device} starts locking`,`Quando {device} inizia a chiudersi`)},{value:`unlocking`,label:L(`Unlocking`,`In apertura`),phrase:L(`When {device} starts unlocking`,`Quando {device} inizia a sbloccarsi`)},{value:`jammed`,label:L(`Jammed`,`Inceppata`),phrase:L(`When {device} jams`,`Quando {device} si inceppa`)},{value:`door-open`,label:L(`Door open`,`Porta aperta`),phrase:L(`When the door of {device} opens`,`Quando la porta di {device} si apre`)}],icon:`lock`}]}},$z=x({armed:r().int().min(0),unknown:C(u()).readonly()}),eB={name:`log-channels`,scope:`system`,mode:`collection`,internal:!0,methods:{list:D(v(),C(Bu).readonly()),apply:D(x({windows:C(Vu).readonly()}),$z,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.INTERNAL}},tB=S([`debug`,`info`,`warn`,`error`]),nB=x({timestamp:_(),level:tB,scope:C(u()),message:u(),meta:h(u(),w()).optional(),tags:h(u(),u()).optional()}),rB=x({instanceId:u().min(1).max(200).optional(),requestId:u().min(1).max(64).optional(),deviceId:r().int().optional(),fromAddonId:u().min(1).max(200).optional(),fromNodeId:u().min(1).max(200).optional(),tags:h(u(),g([u(),r()])).optional(),level:tB.optional(),text:u().min(1).max(200).optional(),since:r().optional(),until:r().optional(),before:u().min(1).max(1024).optional(),after:u().min(1).max(1024).optional(),limit:r().int().min(1).max(1e3).optional(),budgetMs:r().int().min(50).max(1e4).optional()}),iB=x({id:u().optional(),timestamp:r(),level:tB,scope:u().optional(),message:u(),tags:h(u(),g([u(),r()])).optional(),meta:h(u(),w()).optional()}),aB=x({entries:C(iB),nextBefore:u().nullable(),nextAfter:u().nullable(),scannedBytes:r().int().nonnegative(),done:y(),cancelled:y().optional()}),uCe=x({instanceId:u().min(1).max(200).optional()}),oB=x({readable:y(),reason:u().nullable(),filters:x({deviceId:y(),addonId:y(),nodeId:y(),tags:y(),level:y(),text:y(),timeRange:y()}),retentionDays:r().nullable()}),sB={name:`log-destination`,scope:`system`,mode:`collection`,internal:!0,methods:{write:D(nB,v(),{kind:`mutation`}),describeRead:O(uCe,oB,{auth:`admin`}),read:O(rB,aB,{auth:`admin`}),cancelRead:O(x({requestId:u().min(1).max(64)}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.INTERNAL}},cB=S([`primary`,`second-factor`]),lB=x({kind:m(`redirect`),id:u(),label:u(),icon:u().optional(),startUrl:u(),stage:cB,linkable:y().optional(),app:Tp.nullable().optional()}),uB=x({kind:m(`widget`),id:u(),addonId:u(),bundle:u(),remote:ly,stage:cB,app:Tp.nullable().optional()}),dB=x({kind:m(`passkey`),id:u(),label:u(),stage:cB,rpId:u(),origin:u().nullable(),app:Tp.nullable().optional()}),fB=a(`kind`,[lB,uB,dB]),pB={name:`login-method`,scope:`system`,mode:`collection`,internal:!0,methods:{getLoginMethods:D(v(),C(fB).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.IDENTITY}},mB=x({sleeping:y().meta({label:`Sleeping`}),lastContactAt:r().optional(),lastUpdated:r().meta(A(`none`))}),hB={name:`low-power-sleep`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],methods:{wakeUp:D(x({deviceId:r(),timeoutMs:r().int().min(500).max(3e4).default(8e3)}),x({awoke:y(),durationMs:r()}),{kind:`mutation`,notOperatorFacing:`a stream consumer wakes a sleeping camera to watch it; an automation that wants footage asks for the footage`})},status:{schema:mB,kind:`push`,empty:{sleeping:!1,lastUpdated:0}},runtimeState:mB,durability:`restored`,history:`none`,volatileStateFields:[`lastUpdated`],vocabulary:{noun:L(`Low-power sleep`,`Sospensione a basso consumo`),order:5245}},dCe=x({id:u(),label:u(),scope:S([`mesh`,`public`]),url:u(),hostname:u(),port:r(),protocol:S([`http`,`https`])}),gB=x({id:u(),hostname:u(),magicDns:u(),addresses:C(u()).readonly(),os:u().optional(),online:y(),lastSeenMs:r(),isSelf:y(),connection:S([`direct`,`relay`,`idle`]),relay:u().nullable(),lastHandshakeMs:r(),rxBytes:r(),txBytes:r(),tags:C(u()).readonly(),exitNodeOption:y(),advertisedRoutes:C(u()).readonly(),userLogin:u().nullable(),keyExpiry:r().nullable()}),_B=x({joined:y(),meshIp:u(),magicDnsHostname:u(),peerCount:r(),endpoints:C(dCe).readonly(),error:u().optional(),tenantName:u(),magicDnsSuffix:u(),userLogin:u().nullable(),controlPlaneUrl:u(),keyExpiry:r().nullable(),daemonSocket:u().optional(),daemonCliPath:u().optional()}),vB={name:`mesh-network`,scope:`system`,mode:`collection`,providerKind:`mesh`,methods:{getStatus:D(v(),_B),join:D(x({authKey:u().min(8),hostname:u().optional()}),x({joined:m(!0)}),{kind:`mutation`}),startLogin:D(x({hostname:u().optional()}),x({loginUrl:u()}),{kind:`mutation`}),leave:D(v(),x({left:m(!0)}),{kind:`mutation`}),logout:D(v(),x({loggedOut:m(!0)}),{kind:`mutation`}),listPeers:D(v(),x({peers:C(gB).readonly()}))},vocabulary:{notOperatorFacing:k.NETWORK}},yB=x({value:r().nullable().meta(A(`device`,{label:`Total`})),lastFetchedAt:r()}),bB={name:`meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:yB,kind:`push`},runtimeState:yB,durability:`restored`,history:{fields:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Meter`,`Contatore`),order:5140,state:[{kind:`numeric`,field:`value`,quantity:L(`the total`,`il totale`),label:L(`Total`,`Totale`),icon:`gauge`}]}},fCe=x({total:r(),user:r(),system:r(),irq:r(),nice:r(),loadAvg:d([r(),r(),r()]),cores:r()}),pCe=x({percent:r().nullable(),totalBytes:r(),usedBytes:r().nullable(),availableBytes:r().nullable(),swapUsedBytes:r(),swapTotalBytes:r()}),mCe=x({readBytes:r(),writeBytes:r(),readOps:r(),writeOps:r(),timestampMs:r()}),hCe=x({rxBytes:r(),txBytes:r(),rxPackets:r(),txPackets:r(),rxErrors:r(),txErrors:r(),timestampMs:r()}),xB=x({utilization:r(),model:u(),memoryUsedBytes:r(),memoryTotalBytes:r(),temperature:r().nullable()}),gCe=x({openFds:r(),threadCount:r(),activeHandles:r(),activeRequests:r()}),SB=x({avg10:r(),avg60:r(),avg300:r()}),CB=x({some:SB,full:SB.nullable()}),wB=x({cpu:fCe,memory:pCe,gpu:xB.nullable(),network:hCe,disk:mCe,pressure:x({cpu:CB.nullable(),memory:CB.nullable(),io:CB.nullable()}),process:gCe,cpuTemperature:r().nullable(),timestampMs:r()}),_Ce=x({path:u(),totalBytes:r(),usedBytes:r(),availableBytes:r(),percent:r()}),TB=x({pid:r(),cpu:r(),memory:r(),privateBytes:r().optional(),sharedBytes:r().optional()}),vCe=x({addonId:u(),nodeId:u(),role:S([`hub`,`worker`]),pid:r(),state:S([`starting`,`running`,`stopping`,`stopped`,`crashed`]),uptimeSec:r()}),yCe=x({pid:r(),ppid:r(),pgid:r(),classification:S([`root`,`managed`,`system`]),addonId:u().nullable(),nodeId:u().nullable(),command:u(),cpuPercent:r(),memoryRssBytes:r(),cpuMainPercent:r().nullable(),cpuGcPercent:r().nullable(),threadCount:r().nullable(),uptimeSec:r()}),bCe=x({source:S([`cgroup-v2`,`cgroup-v1`]),currentBytes:r(),limitBytes:r().nullable(),anonBytes:r().nullable(),fileBytes:r().nullable(),shmemBytes:r().nullable(),slabBytes:r().nullable(),gpuShmemBytes:r().nullable()}).extend({atMs:r()}),xCe=x({atMs:r(),samples:r().int(),cpuMainPercent:r().nullable(),cpuMainPercentMin:r().nullable(),cpuGcPercent:r().nullable(),cpuGcPercentMin:r().nullable(),cpuLifetimePercent:r(),cpuLifetimePercentMin:r(),memoryRssBytes:r(),memoryRssBytesMin:r(),processCount:r().int(),processCountMin:r().int()}),SCe=x({key:u(),kind:S([`addon`,`root`,`unattributed`]),points:C(xCe).readonly()}),CCe=x({nodeId:u(),series:C(SCe).readonly(),containerMemory:C(bCe).readonly(),bucketMs:r(),retainedSamples:r(),oldestAtMs:r().nullable(),cadenceMs:r(),durable:y()}),wCe=x({forNodeId:u(),sinceMs:r().optional(),maxPoints:r().int().positive().optional()}),EB=x({cpuPercent:r(),memoryPercent:r().nullable(),memoryUsedMB:r().nullable(),memoryTotalMB:r(),diskPercent:r().optional(),temperature:r().optional(),gpuPercent:r().optional(),gpuMemoryPercent:r().optional()}),DB={name:`metrics-provider`,scope:`system`,mode:`singleton`,methods:{collectSnapshot:D(v(),wB),getCached:D(v(),wB.nullable()),getCurrent:D(v(),EB),getDiskSpace:D(x({dirPath:u()}),_Ce),getGpuInfo:D(v(),xB.nullable()),getCpuTemperature:D(v(),r().nullable()),getProcessStats:D(x({pids:C(r())}),C(TB)),listAddonInstances:D(v(),C(vCe).readonly()),getAddonStats:D(x({addonId:u()}),TB.nullable()),listNodeProcesses:D(v(),C(yCe).readonly()),getLoadSeries:D(wCe,CCe)},vocabulary:{notOperatorFacing:k.CLUSTER}},OB=u().min(1).max(256),kB=h(u(),w()),AB=x({id:OB,deviceId:r().int().optional(),at:r().int().optional(),expiresAt:r().int().optional(),data:kB}),jB=x({id:u(),deviceId:r().int().nullable(),at:r().nullable(),expiresAt:r().nullable(),rev:r().int(),updatedAt:r(),data:kB}),MB=h(Xi,g([u(),r(),y(),x({in:C(g([u(),r(),y()])).min(1).max(Qn)}),x({gt:g([u(),r()]).optional(),gte:g([u(),r()]).optional(),lt:g([u(),r()]).optional(),lte:g([u(),r()]).optional()}).refine(e=>Object.keys(e).length>0,{message:`name at least one bound`})])),NB={kind:na},PB={deviceId:r().int().optional(),atFrom:r().optional(),atTo:r().optional()},FB=x({...NB,...PB,where:MB.optional(),order:S([`at`,`id`]).optional(),desc:y().optional(),limit:r().int().min(1).max(kee).default(100),cursor:u().min(1).optional()}),IB=x({records:C(jB),nextCursor:u().nullable()}),TCe=S([`created`,`unchanged`,`updated`]),LB=x({kindId:r().int(),state:TCe,createdIndexes:C(u())}),RB=C(u()),zB=a(`op`,[x({op:m(`put`),kind:na,record:AB,ifRev:r().int().min(0).optional()}),x({op:m(`patch`),kind:na,id:OB,data:kB,at:r().int().nullable().optional(),expiresAt:r().int().nullable().optional(),ifRev:r().int().min(1).optional()}),x({op:m(`delete`),kind:na,id:OB})]),BB=h(u(),h(u(),u())),VB={name:`records`,scope:`system`,mode:`singleton`,internal:!0,methods:{declareKinds:D(x({kinds:h(na,ta)}),x({kinds:h(u(),LB)}),{kind:`mutation`,auth:`admin`}),get:D(x({...NB,id:OB}),jB.nullable(),{auth:`admin`}),getMany:D(x({...NB,ids:C(OB).min(1).max(Qn)}),C(jB),{auth:`admin`}),secretRefs:D(x({...NB,ids:C(OB).min(1).max(Qn)}),BB,{auth:`admin`}),put:D(x({...NB,record:AB,ifRev:r().int().min(0).optional()}),x({rev:r().int(),releasedRefs:RB}),{kind:`mutation`,auth:`admin`}),putMany:D(x({...NB,records:C(AB).min(1).max(Qn)}),x({count:r().int(),releasedRefs:RB}),{kind:`mutation`,auth:`admin`}),patch:D(x({...NB,id:OB,data:kB,at:r().int().nullable().optional(),expiresAt:r().int().nullable().optional(),ifRev:r().int().min(1).optional()}),x({rev:r().int(),releasedRefs:RB}),{kind:`mutation`,auth:`admin`}),delete:D(x({...NB,id:OB}),x({deleted:y(),secretRefs:RB}),{kind:`mutation`,auth:`admin`}),deleteMany:D(x({...NB,ids:C(OB).min(1).max(Qn)}),x({deleted:r().int(),secretRefs:RB}),{kind:`mutation`,auth:`admin`}),query:D(FB,IB,{auth:`admin`}),count:D(x({...NB,...PB,where:MB.optional()}),x({count:r().int()}),{auth:`admin`}),histogram:D(x({...NB,deviceId:r().int().optional(),from:r(),to:r(),bucketMs:r().int().positive()}),x({buckets:C(x({bucketStart:r(),count:r().int()}))}),{auth:`admin`}),aggregate:D(x({...NB,op:S([`sum`,`min`,`max`,`count`]),field:Xi.optional(),groupBy:Xi.optional(),where:MB.optional()}),x({rows:C(x({group:g([u(),r(),oe()]),value:r().nullable()}))}),{auth:`admin`}),deleteWhere:D(x({...NB,deviceId:r().int().optional(),atBefore:r().optional(),where:MB.optional()}),x({deleted:r().int(),secretRefs:RB}),{kind:`mutation`,auth:`admin`}),transact:D(x({ops:C(zB).min(1).max(Qn)}),x({results:C(x({rev:r().int().nullable(),deleted:y()})),releasedRefs:RB,secretRefs:RB}),{kind:`mutation`,auth:`admin`}),deleteDevice:D(x({deviceId:r().int(),kinds:C(na).optional()}),x({deleted:h(u(),r().int()),secretRefs:RB}),{kind:`mutation`,auth:`admin`}),allocateId:D(x(NB),x({id:r().int()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.INTERNAL}},HB=h(u(),w()),UB=x({integrationId:u().min(1)}),WB=x({id:u().min(1)}),GB=x({id:u(),deviceId:r().int().nullable(),at:r().nullable(),expiresAt:r().nullable(),rev:r().int(),updatedAt:r(),data:HB}),KB={id:u().min(1),deviceId:r().int().optional(),at:r().int().optional(),expiresAt:r().int().optional(),data:HB},qB=x({id:u(),addonId:u(),name:u(),info:HB,enabled:y().optional(),originStableId:u().optional()}),ECe=x({id:r().int(),integrationId:u().nullable().optional(),parentDeviceId:r().int().nullable().optional(),type:u().optional(),name:u().optional(),stableId:u().optional()}),JB=x({version:r().int(),methods:C(u())}),YB=x({message:u(),meta:HB.optional(),tags:x({deviceId:r().int().optional()}).optional()}),DCe={"ledger.declare":{input:x({owner:u().min(1),metas:C(Xo)}),output:x({bootId:u(),snapshot:S([`none`,`written`,`refused`]),steps:C(ds),migrationApi:JB.optional()}),behaviours:[`ledger.declare.answers-steps-in-engine-order`,`ledger.declare.answers-the-migration-api`]},"ledger.start":{input:x({id:u().min(1)}),output:x({proceed:y(),state:g([m(`pending`),ss]),reason:u().nullable()}),behaviours:[`ledger.start.proceeds-when-predecessors-applied`]},"ledger.finish":{input:x({id:u().min(1),result:os}),output:x({status:ss,error:u().nullable(),rowsChanged:r().int().nonnegative()}),behaviours:[`ledger.finish.records-the-outcome`]},"legacyRows.read":{input:UB,output:HB,behaviours:[`legacyRows.read.returns-stored-rows`,`legacyRows.read.absent-store-is-empty`,`legacyRows.caller.sibling-package`]},"legacyRows.clear":{input:UB,output:x({rows:r().int().nonnegative(),secrets:r().int().nonnegative()}),behaviours:[`legacyRows.clear.deletes-the-rows`,`legacyRows.clear.absent-store-is-noop`]},"legacyRows.patch":{input:UB.extend({patch:HB}),output:x({written:y()}),behaviours:[`legacyRows.patch.upserts-keys-and-keeps-the-rest`,`legacyRows.patch.absent-store-writes-nothing`]},"legacyRows.deleteKeys":{input:UB.extend({keys:C(u().min(1))}),output:x({present:y(),removed:HB}),behaviours:[`legacyRows.deleteKeys.removes-the-named-keys`,`legacyRows.deleteKeys.absent-store-reports-not-present`]},"records.get":{input:WB,output:GB.nullable(),behaviours:[`records.get.returns-the-row-or-null`]},"records.getResolved":{input:WB,output:GB.nullable(),behaviours:[`records.getResolved.resolves-secret-fields`]},"records.put":{input:x({...KB,ifRev:r().int().optional()}),output:x({rev:r().int()}),behaviours:[`records.put.creates-and-replaces`,`records.put.if-rev-conflict-throws`]},"records.putMany":{input:x({records:C(x(KB))}),output:x({count:r().int().nonnegative()}),behaviours:[`records.putMany.writes-every-row`]},"records.patch":{input:WB.extend({partial:HB,ifRev:r().int().optional()}),output:x({rev:r().int()}),behaviours:[`records.patch.merges-and-null-removes`]},"records.delete":{input:WB,output:x({deleted:y()}),behaviours:[`records.delete.reports-whether-a-row-went`]},"records.query":{input:x({deviceId:r().int().optional(),atFrom:r().optional(),atTo:r().optional(),where:MB.optional(),limit:r().int().min(1).optional(),cursor:u().min(1).optional(),resolveSecrets:y().optional()}),output:x({records:C(GB),nextCursor:u().nullable()}),behaviours:[`records.query.pages-with-a-cursor`,`records.query.filters-on-a-declared-index`]},"records.deleteWhere":{input:x({deviceId:r().int().optional(),atBefore:r().optional(),where:MB.optional()}),output:x({count:r().int().nonnegative()}),behaviours:[`records.deleteWhere.deletes-the-matching-rows`]},"settings.read":{input:x({}),output:x({store:HB}),behaviours:[`settings.read.returns-the-addon-store`]},"settings.write":{input:x({patch:HB}),output:x({}),behaviours:[`settings.write.merges-and-keeps-other-keys`]},"settings.deleteKeys":{input:x({keys:C(u().min(1))}),output:x({removed:C(u())}),behaviours:[`settings.deleteKeys.removes-only-the-named-keys`]},"deviceSettings.listIds":{input:x({}),output:x({deviceIds:C(r().int())}),behaviours:[`deviceSettings.listIds.names-only-the-addons-own-devices`]},"deviceSettings.read":{input:x({deviceIds:C(r().int())}),output:x({blobs:h(u(),HB)}),behaviours:[`deviceSettings.read.returns-only-the-addons-own-blobs`]},"secrets.resolve":{input:x({refs:C(u())}),output:x({values:h(u(),u().nullable())}),behaviours:[`secrets.resolve.answers-null-for-a-missing-ref`]},"secrets.put":{input:x({ref:u().min(1),value:u()}),output:x({}),behaviours:[`secrets.put.stores-under-the-owner`]},"secrets.delete":{input:x({refs:C(u())}),output:x({deleted:r().int().nonnegative()}),behaviours:[`secrets.delete.ignores-unknown-refs`]},"integrations.list":{input:x({}),output:x({integrations:C(qB)}),behaviours:[`integrations.list.lists-every-integration`]},"integrations.get":{input:x({id:u().min(1)}),output:qB.nullable(),behaviours:[`integrations.get.null-for-an-unknown-id`]},"devices.list":{input:x({addonId:u().min(1),integrationId:u().min(1).optional()}),output:x({devices:C(ECe)}),behaviours:[`devices.list.scoped-to-the-addon`,`devices.list.filters-by-integration`]},"devices.get":{input:x({deviceId:r().int()}),output:x({id:r().int(),integrationId:u().nullable(),hasConfig:y()}).nullable(),behaviours:[`devices.get.null-for-an-unknown-id`,`devices.get.reports-link-and-config`]},"devices.aliases":{input:x({deviceIds:C(r().int())}),output:x({aliases:h(u(),u())}),behaviours:[`devices.aliases.answers-for-the-named-ids-only`]},"devices.setIntegrationId":{input:x({deviceId:r().int(),integrationId:u().min(1)}),output:x({}),behaviours:[`devices.setIntegrationId.links-the-device`]},"node.localNodeId":{input:x({}),output:x({nodeId:u()}),behaviours:[`node.localNodeId.names-this-node`]},"log.info":{input:YB,output:x({}),behaviours:[`log.info.writes-a-line`]},"log.warn":{input:YB,output:x({}),behaviours:[`log.warn.writes-a-line`]}},XB={name:`migrations`,scope:`system`,mode:`singleton`,internal:!0,methods:{listLedger:D(x({}),x({entries:C(cs)}),{auth:`admin`}),listPending:D(x({owner:u().optional()}),x({pending:C(ls)}),{auth:`admin`}),dryRun:D(x({id:u().min(1)}),us,{auth:`admin`}),markFailed:D(x({id:u().min(1),error:u().min(1)}),cs,{kind:`mutation`,auth:`admin`}),retry:D(x({id:u().min(1)}),x({entries:C(cs)}),{kind:`mutation`,auth:`admin`}),restorePreMigration:D(x({database:Uo,snapshotId:u().min(1)}),x({scheduled:y(),held:C(u()),restartRequired:y()}),{kind:`mutation`,auth:`admin`}),declareOwner:D(x({owner:u().min(1),metas:C(Xo),retired:C(u().min(1)).optional()}),x({bootId:u(),snapshot:S([`none`,`written`,`refused`]),steps:C(ds),migrationApi:JB.optional()}),{kind:`mutation`,auth:`admin`}),startMigration:D(x({id:u().min(1)}),x({proceed:y(),state:g([m(`pending`),ss]),reason:u().nullable()}),{kind:`mutation`,auth:`admin`}),finishMigration:D(x({id:u().min(1),result:os}),x({status:ss,error:u().nullable(),rowsChanged:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),readLegacyIntegrationRows:D(x({integrationId:u().min(1)}),h(u(),w()),{auth:`admin`}),clearLegacyIntegrationRows:D(x({integrationId:u().min(1)}),x({rows:r().int().nonnegative(),secrets:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),patchLegacyIntegrationRows:D(x({integrationId:u().min(1),patch:h(u(),w())}),x({written:y()}),{kind:`mutation`,auth:`admin`}),deleteLegacyIntegrationRowKeys:D(x({integrationId:u().min(1),keys:C(u().min(1))}),x({present:y(),removed:h(u(),w())}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.INTERNAL}},ZB=x({sourceUrl:u(),metadata:Df,targets:C(Ef).min(1).readonly(),calibrationRef:u().optional(),sessionId:u().optional()}),QB={name:`model-convert`,scope:`system`,mode:`singleton`,internal:!0,methods:{convert:D(ZB,kf,{kind:`mutation`,auth:`admin`,timeoutMs:6e5})},vocabulary:{notOperatorFacing:k.ML}},$B=x({targetNodeId:u(),modelId:u(),format:S(ff),entry:Tf}),eV=x({ok:y(),sha256:u(),bytes:r(),path:u()}),tV={name:`model-distributor`,scope:`system`,mode:`singleton`,internal:!0,methods:{distributeModel:D($B,eV,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.ML}},nV=a(`kind`,[x({kind:m(`camera`)}),x({kind:m(`sensor`),deviceId:r().int().positive()})]),rV=Object.freeze({kind:`camera`});function OCe(e){if(e===void 0)return{triggeredBy:rV,malformed:!1};let t=nV.safeParse(e);return t.success?{triggeredBy:t.data,malformed:!1}:{triggeredBy:rV,malformed:!0}}var kCe=`cameraSensors`,iV=x({addonId:u().min(1),stableId:u().min(1)});function aV(e){return`${e.addonId}/${e.stableId}`}var oV=S([`in-addition`,`confirm`,`replace`]),sV=`in-addition`,cV=iV.extend({mode:oV.default(sV)}),lV=x({sensors:C(cV).min(1).max(8)}).superRefine((e,t)=>{let n=new Set;e.sensors.forEach((e,r)=>{let i=aV(e);n.has(i)&&t.addIssue({code:`custom`,path:[`sensors`,r],message:`duplicate camera sensor ${i}`}),n.add(i)})}),uV={addonId:u(),stableId:u(),mode:oV.default(sV)},dV=a(`state`,[x({...uV,state:m(`ready`),deviceId:r(),name:u(),caps:C(u()).readonly()}),x({...uV,state:m(`offline`),deviceId:r(),name:u(),reason:S([`offline`,`disabled`])}),x({...uV,state:m(`missing`),reason:u()}),x({...uV,state:m(`unsupported`),deviceId:r(),name:u(),reason:u()}),x({...uV,state:m(`unreadable`),reason:u()})]),fV=S([`onboard-not-listed`,`no-active-detection`]),pV=S([`always`,`when-confirmed`,`never`]),mV=S([`provider-not-split`]),hV=x({detected:y(),atMs:r()}),gV=a(`state`,[x({state:m(`not-configured`),cameraLevel:hV.optional()}),x({state:m(`unreadable`),reason:u(),cameraLevel:hV.optional()}),x({state:m(`configured`),cameraLevel:hV.optional(),sensors:C(dV).readonly(),cameraMotion:pV.optional(),notForwarded:fV.optional(),notEnforced:mV.optional()})]),_V=Object.freeze({state:`unreadable`,reason:`camera sensor mappings not loaded`}),vV=x({bbox:Ay,pixelCount:r(),intensity:r()}),yV=x({detected:y(),regionCount:r(),regions:C(vV).readonly(),rawRegions:C(vV).readonly(),frameWidth:r(),frameHeight:r(),analysisMs:r()}),bV={name:`motion-detection`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Camera],exposesDeviceSettings:!0,methods:{analyze:D(x({deviceId:r(),frame:ky.optional(),frameHandle:Lc.optional()}),yV,{role:`admin`,kind:`mutation`,notOperatorFacing:`the pipeline feeds it frames — an internal stage, never called by a person`}),removeCamera:D(x({deviceId:r()}),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping when a camera leaves`}),reset:D(v(),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping`})},events:{onMotion:{data:x({deviceId:r(),detected:y(),regionCount:r()}),notOperatorFacing:"the analyzer’s raw verdict; the operator signal is the `motion` cap’s `detected` state"}},vocabulary:{noun:L(`Motion analysis`,`Analisi del movimento`),order:3160}},xV=x({package:y(),confidence:r().min(0).max(1),reason:u().min(1)}),SV=x({x:r(),y:r()}),CV=x({kind:m(`rect`),x:r(),y:r(),width:r(),height:r()}),wV=x({kind:m(`polygon`),points:C(SV)}),TV=x({kind:m(`grid`),gridWidth:r().meta(A(`none`)),gridHeight:r().meta(A(`none`)),cells:C(y())}),EV=x({kind:m(`line`),points:C(SV)}),ACe=a(`kind`,[CV,wV,TV,EV]),DV=S([`rect`,`polygon`,`grid`,`line`]),OV=x({min:r(),max:r()}),kV=x({width:r(),height:r()}),AV=[`owner-not-ready`,`store-read-failed`,`three-way-read-unavailable`,`invalid-stored`,`not-cluster-scoped`],jV=[{stepId:`face-embedding`,label:`Face recognition model`,defaultModelId:`auraface-r100`,indexName:`the enrolled face gallery`,options:[{id:`auraface-r100`,label:`AuraFace R100`}]},{stepId:`clip-embedding`,label:`Semantic search model`,defaultModelId:`siglip2-b16-224`,indexName:`the object semantic-search index`,options:[{id:`siglip2-b16-224`,label:`SigLIP2 B/16 (Apache-2.0)`}]}],jCe=`cluster-step-models`;function MV(e){return`clusterModel:${e}`}function MCe(e){return jV.some(t=>t.stepId===e)}var NV=Object.freeze(Object.fromEntries(jV.map(e=>[e.stepId,e.defaultModelId])));function PV(e){return e==null||e===``?{kind:`absent`}:typeof e==`string`?{kind:`chosen`,modelId:e}:{kind:`invalid`,value:e}}function FV(e){let t=[];for(let n of jV){let r=PV(e[MV(n.stepId)]);r.kind===`invalid`&&t.push({stepId:n.stepId,value:r.value})}return t}function IV(e){let t={};for(let n of jV){let r=PV(e[MV(n.stepId)]);t[n.stepId]=r.kind===`chosen`?r.modelId:n.defaultModelId}return t}function NCe(e){return typeof e==`object`&&!!e&&`key`in e}function LV(e){return e===null?NV:IV(zV(e,RV()))}function PCe(e){return e===null?[]:FV(zV(e,RV()))}function RV(){return new Set(jV.map(e=>MV(e.stepId)))}function zV(e,t){let n={};for(let r of e.sections)for(let e of r.fields)!NCe(e)||typeof e.key!=`string`||t.has(e.key)&&(n[e.key]=e.value);return n}function FCe(e,t){let n=jV.find(t=>t.stepId===e);if(n===void 0)return null;let r=t[e];return r!==void 0&&r!==``?r:n.defaultModelId}var BV=[{stepId:`face-embedding`,key:`minLandmarkFaceSize`,label:`Min face size to embed (detection-frame px)`,description:`Faces smaller than this in the small frame the detector sees are not embedded, so they can never be recognised. Below it the face cannot be aligned reliably and a bad embedding matches everyone. Same value on every node. 0 = no limit.`,type:`slider`,min:0,max:64,step:2,default:24}];function VV(e,t){return`clusterStepSetting:${e}:${t}`}function HV(e){return BV.filter(t=>t.stepId===e)}var ICe=r().finite();function UV(e){let t={};for(let n of BV){let r=ICe.safeParse(e[VV(n.stepId,n.key)]),i=r.success?r.data:n.default,a=t[n.stepId]??{};t[n.stepId]={...a,[n.key]:i}}return t}var WV=UV({});function GV(e){return e===null?WV:UV(zV(e,new Set(BV.map(e=>VV(e.stepId,e.key)))))}function LCe(e,t,n){let r=n[e];return r===void 0||Object.keys(r).length===0?t===void 0?void 0:{...t}:t===void 0?{...r}:{...t,...r}}var KV=S([`new`,`entered`,`left`,`moving`,`idle`]),qV=S([`motion`,`object`,`audio`]),JV=a(`kind`,[CV,wV]),YV=S([`motion`,`audio`,`person`,`vehicle`,`animal`,`door`,`pir`,`smoke`,`water`,`button`,`package`,`generic`]),XV=S([`motion`,`audio`,`detection`,`sensor`,`control`,`custom`,`package`]),RCe=S([`macro`,`sub`]),ZV=x({kind:u(),labelKey:u(),label:u(),color:u(),iconId:u(),icon:YV,category:XV,parentKind:u().nullable(),level:RCe,source:x({capName:u(),deviceId:r()})}),QV=x({deviceId:r(),kinds:C(ZV).readonly()}),$V=x({id:u(),deviceId:r(),sourceDeviceId:r(),kind:u(),value:h(u(),w()).nullable(),timestamp:r()}),eH=x({x:r(),y:r(),timestamp:r(),bbox:Ay,source:S([`frame`,`recovery`]).optional(),score:r().optional()}),zCe=x({timestamp:r(),position:eH,mediaId:r().int()}),tH=x({minX:r(),minY:r(),maxX:r(),maxY:r()}),nH=S([`full`,`slim`]),rH=x({label:u(),peakScore:r(),count:r(),firstAt:r(),lastAt:r()}),iH=S([`pipeline`,`onboard`,`sensor`,`audio`]),aH=S([`none`,`staging`,`trained`]),oH={markForTrain:y().optional(),debug:y().optional(),debugNote:u().max(500).optional(),favourited:y().optional()},sH={retrainStatus:aH.optional()},cH=x(oH),lH=x({trackId:u(),markForTrain:y(),debug:y(),debugNote:u(),favourited:y(),retrainStatus:aH}),BCe=g([m(1),m(2)]),uH=x({stepId:u(),modelId:u().optional(),decidedAt:r(),identityId:u().optional()}),dH={label:u().optional(),labelScore:r().optional(),labelMeta:uH.optional(),subLabel:u().optional(),subLabelScore:r().optional(),subLabelMeta:uH.optional()},fH=x({deviceId:r(),tracks:r().int(),files:r().int(),bytes:r().int()}),pH=x({generatedAt:r(),trackCount:r().int(),fileCount:r().int(),byteCount:r().int(),truncated:y(),devices:C(fH).readonly()}),mH=x({nodeId:u(),deviceKey:u().optional(),modelId:u().optional()}),hH=x({trackId:u(),deviceId:r(),className:u(),...dH,producingDeviceName:u().optional(),source:iH.optional(),firstSeen:r(),lastSeen:r(),positions:C(eH).readonly(),snapshots:C(zCe).readonly(),zonesVisited:C(u()).readonly(),zoneNames:C(u()).readonly().optional(),classes:C(u()).readonly().optional(),totalDistance:r(),state:KV,active:y(),importance:r().optional(),bestEventId:u().optional(),importanceReason:u().optional(),audioLabels:C(rH).readonly().optional(),envelope:tH.optional(),hasFace:y().optional(),hasEmbeddedFace:y().optional(),hasRider:y().optional(),previewMissReason:u().optional(),modelId:u().optional(),openedPlacement:mH.optional(),closedPlacement:mH.optional(),frameWidth:r().optional(),frameHeight:r().optional(),...oH,...sH}),gH={id:r().int(),deviceId:r(),timestamp:r()},_H=x({...gH,kind:m(`motion`),regionCount:r(),regions:C(x({bbox:Ay,pixelCount:r(),intensity:r()})).readonly().optional(),frameWidth:r().optional(),frameHeight:r().optional(),mediaUrl:u().optional(),triggeredBy:nV.optional(),durationMs:r().nullable().optional(),edges:C(r()).readonly().optional()}),vH=S([`pipeline`,`onboard`]),yH=S([`enter`,`exit`]),bH=x({direction:yH,zoneId:u(),zoneName:u().optional()}),VCe=x({zoneId:u(),zoneName:u().optional(),overlapPct:r()}),xH=x({...gH,kind:m(`object`),source:vH.optional(),frameId:u().optional(),idempotencyKey:u().optional(),trackId:u().optional(),className:u(),...dH,confidence:r().optional(),bbox:Ay.optional(),zones:C(u()).readonly().optional(),zoneOverlaps:C(VCe).readonly().optional(),spawnRefused:u().optional(),state:KV.optional(),zoneCrossing:bH.optional(),frameWidth:r().optional(),frameHeight:r().optional(),mediaId:r().int().optional(),keyFrameMediaId:r().int().optional(),mediaUrl:u().optional(),observedAt:r().optional(),packagePossible:y().optional(),packageLlmVerdict:xV.optional(),importance:r().optional()}),SH=x({...gH,kind:m(`audio`),rms:r(),dbfs:r(),classification:x({className:u(),originalClass:u().optional(),score:r()}).optional(),classifyOutcome:Fy.optional(),mediaUrl:u().optional()}),CH=S([`crop`,`thumbnail`,`snapshot`,`firstFrame`,`lastFrame`,`fullFrame`,`fullFrameBoxed`,`faceCrop`,`plateCrop`,`keyFrame`,`keyFrameSmall`,`thumbnailSmall`,`confirmationCrop`,`debugCrop`,`sceneFrame`,`lastSceneFrame`]),wH=x({mediaId:r().int(),kind:CH,sizeBytes:r(),timestamp:r()}),TH=wH.extend({url:u(),base64:u()}),EH=TH.omit({base64:!0}),DH=S([`person`,`vehicle`,`animal`,`package`,`face`,`plate`]),OH=S([`subject`,`model_error`]),kH=S([`operator`,`assist`,`pipeline`,`llm`]),AH=x({x:r(),y:r(),w:r(),h:r()}),jH=x({source:kH,ref:u().min(1),bbox:AH,macroClass:DH,label:u().optional(),score:r().optional(),modelId:u().optional()}),MH=x({ref:u().min(1),snapshot:jH}),NH=S(Bs),PH=x({ref:u(),savedId:u().optional(),status:NH,approximate:y(),origin:jH.optional(),macroClass:DH.optional(),label:u().optional(),iou:r().optional()}),FH=x({boxes:C(PH).readonly(),summary:x({counts:h(NH,r().int()),total:r().int(),changed:r().int(),approximate:y()})}),IH=x({id:u(),trackId:u().optional(),deviceId:r(),mediaKey:u(),bbox:AH,macroClass:DH,label:u().optional(),subLabel:u().optional(),kind:OH,source:kH,assistModelId:u().optional(),assistScore:r().optional(),origin:jH.nullable().optional(),exportedInBatch:u().optional(),createdAt:r()}),LH=IH.omit({id:!0,trackId:!0,deviceId:!0,mediaKey:!0,createdAt:!0,exportedInBatch:!0}),RH=S([`correct`,`wrong`,`wrong-label`]),zH=x({verdict:RH,suggestedClass:u().optional(),suggestedMacroClass:DH.optional(),suggestedLabel:u().optional(),trackId:u(),at:r().optional()}),BH=x({trackId:u(),className:u(),label:u().optional(),bbox:AH.optional(),verdict:RH,suggestedClass:u().optional(),at:r().optional()}),VH=x({trackId:u(),deviceId:r(),className:u(),label:u().optional(),firstSeen:r(),lastSeen:r(),frameCount:r().int(),annotationCount:r().int(),verdict:zH.optional()}),HH=x({mediaId:r().int(),kind:CH,timestamp:r(),sizeBytes:r().int(),copied:y()}),UH=x({bbox:AH,macroClass:DH,label:u().optional(),subLabel:u().optional(),score:r().optional(),modelId:u().optional(),trackId:u(),basis:S([`subject-box`,`position`,`verdict`]),deltaMs:r()}),WH=S([`track`,`recording`]),GH=x({frameId:u(),deviceId:r(),origin:WH,trackId:u().optional(),sourceMediaId:r().int().optional(),epochMs:r().optional(),sourceKind:CH,sizeBytes:r().int(),width:r().int(),height:r().int(),copiedAt:r(),capturedAt:r().optional(),complete:y(),pipelineBoxes:C(UH).readonly().optional(),collectionIds:C(u()).readonly().optional(),verdict:zH.optional(),revision:r().int().optional(),dismissed:C(MH).readonly().optional(),review:FH.optional(),imageUrl:u().optional(),thumbnailUrl:u().optional()}),KH=S([`source-missing`,`unreadable-image`,`write-failed`]),qH=x({copied:C(GH).readonly(),refused:C(x({sourceMediaId:r().int(),reason:KH})).readonly()}),JH=x({candidates:C(HH).readonly(),copies:C(GH).readonly(),autoPickMediaId:r().int().optional()}),YH=S([`unannotated`,`annotated`,`complete`]),XH=x({workState:YH.optional(),deviceIds:C(r()).max(500).optional(),collectionId:u().optional(),classes:C(DH).optional(),page:r().int().positive().default(1),pageSize:r().int().positive().max(100).default(50)}),ZH=GH.extend({workState:YH}),QH=x({frames:C(ZH).readonly(),total:r().int().nonnegative(),page:r().int().positive(),pageSize:r().int().positive()}),$H=x({deviceId:r(),unannotated:r().int().nonnegative(),annotated:r().int().nonnegative(),complete:r().int().nonnegative(),pctOfCorpus:r().min(0).max(1).nullable()}),eU=x({total:r().int().nonnegative(),unannotated:r().int().nonnegative(),annotated:r().int().nonnegative(),complete:r().int().nonnegative(),cameras:C($H).readonly()}),tU=x({deviceIds:C(r()).optional(),frameIds:C(u()).max(2e4).optional(),collectionIds:C(u()).max(200).optional(),collectionId:u().optional(),batchId:u().optional(),completeOnly:y().optional(),workState:YH.optional(),classes:C(DH).optional()}),nU=S([`frames`,`crops`]),rU=x({kind:m(`http`),method:S([`PUT`,`POST`]),url:u().url(),headers:h(u(),u()).optional()}),iU=x({batchId:u(),frames:r().int(),crops:r().int(),annotations:r().int(),missing:r().int(),bytes:r().int(),sha256:u(),status:r().int()}),aU=a(`kind`,[x({kind:m(`package`),zone:AH.optional()}),x({kind:m(`objects`),modelId:u(),minScore:r().optional()})]),oU=a(`kind`,[x({kind:m(`proposed`),modelId:u(),stepId:u(),minScore:r(),proposals:C(LH).readonly(),belowThreshold:r().int()}),x({kind:m(`refused`),reason:u(),detail:u().optional()})]),sU=x({id:u(),name:u(),createdAt:r(),frameCount:r().int()}),cU=a(`kind`,[x({kind:m(`created`),collection:sU}),x({kind:m(`refused`),reason:S([`empty-name`,`duplicate-name`])})]),lU=a(`kind`,[x({kind:m(`renamed`),collection:sU}),x({kind:m(`refused`),reason:S([`empty-name`,`duplicate-name`,`unknown-collection`])})]),uU=a(`kind`,[x({kind:m(`added`),collectionId:u(),frame:GH,reused:y()}),x({kind:m(`refused`),reason:S([`unknown-collection`,`still-unavailable`,`still-busy`,`unreadable-image`,`write-failed`]),detail:u().optional()})]),dU=x({id:u(),name:u(),model:u(),kind:u(),leavesHouse:y()}),fU=LH.extend({reason:u()}),pU=x({ref:u(),verdict:S([`confirmed`,`wrong-class`,`not-an-object`,`uncertain`]),suggestedClass:DH.optional(),reason:u()}),mU=a(`kind`,[x({kind:m(`proposed`),profileId:u(),model:u(),leftHouse:y(),proposals:C(fU).readonly(),reviews:C(pU).readonly(),rejected:r().int()}),x({kind:m(`refused`),reason:S([`unknown-frame`,`unreadable-frame`,`unknown-profile`,`profile-disabled`,`no-vision`,`cloud-not-confirmed`,`llm-error`,`malformed-answer`]),detail:u().optional()})]),hU=x({deviceIds:C(r()).readonly().optional(),collectionIds:C(u()).max(200).readonly().optional(),frameIds:C(u()).max(2e4).readonly().optional()}),gU=x({frames:r().int(),completeFrames:r().int(),completeness:r(),subjects:r().int(),modelErrors:r().int(),hardNegatives:r().int(),cells:C(x({macroClass:u(),deviceId:r(),lighting:S([`day`,`night`,`unknown`]),subjects:r().int(),frames:r().int()})).readonly(),cameras:C(x({deviceId:r(),frames:r().int(),completeFrames:r().int()})).readonly()}),HCe=x({id:u(),name:u(),createdAt:r(),selection:hU,layout:nU,completeOnly:y(),frameCount:r().int(),annotationHash:u(),manifestSchema:u(),stats:gU}),_U=x({collectionIds:C(u()).min(1),workState:S([`complete`,`annotated_or_complete`,`any_annotated`]).default(`complete`)}),vU=a(`kind`,[x({kind:m(`resolved`),frameIds:C(u()).max(2e4).readonly(),stats:gU,annotationHash:u(),layout:nU}),x({kind:m(`refused`),reason:S([`unknown-collection`,`no-frames`]),detail:u()})]),yU=x({trackId:u(),retrainStatus:aH,changed:y(),reason:S([`unknown-track`,`no-frames-copied`,`not-staging`,`not-trained`,`unchanged`]).optional()}),bU=1e3,xU=5e3,SU=x({deviceId:r(),since:r().optional(),until:r().optional(),limit:r().int().min(1).max(xU).default(bU),projection:S([`full`,`slim`]).optional()}),UCe=SU.extend({classFilter:u().optional()}),CU=x({deviceIds:C(r()),since:r().optional(),until:r().optional(),limit:r().int().min(1).max(1e3).default(200),cursor:u().optional(),projection:nH.optional(),includeStationary:y().optional(),classes:C(u()).optional(),excludeSources:C(iH).optional()}),wU=x({tracks:C(hH).readonly(),nextCursor:u().nullable()}),TU=50,EU=200,WCe=x({deviceId:r(),since:r(),until:r(),limit:r().int().min(1).max(EU).default(TU),minImportance:r().min(0).max(1).optional(),classFilter:u().optional()}),DU=x({id:u(),trackId:u(),timestamp:r(),className:u(),...dH,importance:r(),bestEventId:u(),windowMs:r().optional(),audioLabels:C(rH).readonly().optional(),...oH,...sH}),GCe=x({deviceIds:C(r()).min(1).max(200),since:r(),until:r(),limit:r().int().min(1).max(EU).default(TU),minImportance:r().min(0).max(1).optional(),classFilter:u().optional()}),KCe=x({deviceId:r(),events:C(DU).readonly()}),OU=x({bucketStart:r(),motion:r().int(),object:r().int(),audio:r().int(),audioDbfs:r().optional()}),kU=x({deviceId:r(),read:S([`read`,`unreadable`]),buckets:C(OU).readonly()}),qCe=x({trackId:u(),className:u(),confidence:r(),bbox:Ay,zones:C(u()).readonly(),state:KV}),JCe=ce({id:u(),kind:S([`first-level`,`detail`]),macroClass:u(),score:r(),bbox:x({x:r(),y:r(),width:r(),height:r()}),labels:C(ce({label:u(),score:r()})).readonly(),parentId:u().optional()}),AU=xH.extend({score:r()}),YCe=x({text:u(),deviceId:r().optional(),since:r().optional(),until:r().optional(),classFilter:u().optional(),limit:r().default(50),minScore:r().min(0).max(1).optional(),strictness:Wd.optional(),modelId:u().min(1).optional()}),jU=x({tracks:r().int(),events:r().int(),media:r().int(),faces:r().int(),plates:r().int(),embeddings:r().int()}),XCe=x({mediaDropped:r().int(),tracks:r().int(),events:r().int()}),ZCe=x({deviceId:r(),rows:r().int(),bytes:r().int()}),QCe=x({totalRows:r().int(),totalBytes:r().int(),devices:C(ZCe).readonly()}),$Ce=x({kind:CH,rows:r().int(),bytes:r().int()}),ewe=x({totalRows:r().int(),totalBytes:r().int(),kinds:C($Ce).readonly(),unaccountedRows:r().int(),unaccountedBytes:r().int()}),MU=x({motion:r().int(),object:r().int(),audio:r().int()}),twe=x({deviceId:r().optional(),since:r().optional(),until:r().optional(),maxTracks:r().int().positive().optional(),executeOnNodeId:u().optional(),pacingMs:r().int().nonnegative().optional(),force:y().optional()}),nwe=x({deleted:r(),failedIndexes:C(u()).optional()}),NU=S([`stores-unavailable`,...AV,`method-unavailable`,`read-failed`,`reads-disagree`,`not-a-clip-model`,`force-requires-max-tracks`]),rwe=x({started:y(),alreadyRunning:y(),refusal:NU.optional(),modelId:u().optional(),index:u().optional()}),iwe=x({running:y(),scanned:r(),rebuilt:r(),missingKeyFrame:r(),missingEvent:r(),missingBbox:r(),boxSource:x({subjectBox:r(),positions:r(),event:r(),refused:r()}),alreadyInSpace:r(),force:y().nullable(),forcedInSpace:r(),notRunnable:r(),noCapableNode:r(),failed:r(),complete:y().nullable(),startedAtMs:r().nullable(),finishedAtMs:r().nullable(),error:u().nullable(),modelId:u().nullable(),index:u().nullable()}),awe=x({started:y(),alreadyRunning:y()}),owe=x({mode:S([`report`,`reclaim`]).default(`report`),scopes:C(S([`motion-still`,`track-filmstrip`])).min(1).optional(),deviceIds:C(r().int()).min(1).optional(),restart:y().optional(),pageSize:r().int().min(50).max(5e3).optional(),maxRowsPerDevice:r().int().min(1).max(5e5).optional(),maxReclaimPerDevice:r().int().min(1).max(5e5).optional(),maxBytesPerRun:r().int().min(1).optional(),budgetMinutes:r().int().min(1).max(720).optional(),throttleBytesPerSec:r().int().min(64*1024).optional(),graceMinutes:r().int().min(1).max(10080).optional()}),swe=x({running:y(),mode:S([`report`,`reclaim`]).nullable(),totalExamined:r(),totalEligible:r(),totalReclaimed:r(),totalBytesReclaimed:r(),totalRefused:r(),devicesDone:r(),complete:y().nullable(),startedAtMs:r().nullable(),finishedAtMs:r().nullable(),error:u().nullable()}),PU=S([`motion`,`audio-dbfs`,`battery`,`occupancy`]);function cwe(e,t){let n=e??``;return t===void 0?n:`${n}|${t}`}function FU(e){let t=e.indexOf(`|`);return t<0?{zoneId:e}:{zoneId:e.slice(0,t),className:e.slice(t+1)}}var IU=x({scope:u(),bucketStart:r().int(),samples:r().int().nonnegative(),sum:r(),min:r(),max:r()}),LU={name:`pipeline-analytics`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Camera],exposesDeviceSettings:!0,methods:{getActiveTracks:D(x({deviceId:r()}),C(hH).readonly()),getTrack:D(x({deviceId:r(),trackId:u()}),hH.nullable()),listTracks:D(x({deviceId:r(),since:r().optional(),until:r().optional(),limit:r().optional(),zone:JV.optional(),projection:nH.optional(),includeStationary:y().optional(),classes:C(u()).optional(),excludeSources:C(iH).optional()}),C(hH).readonly()),listRecentTracks:D(CU,wU),clearTracks:D(x({deviceId:r()}),v(),{kind:`mutation`,auth:`admin`}),getMotionEvents:D(SU,C(_H).readonly()),getObjectEvents:D(UCe,C(xH).readonly()),getAudioEvents:D(SU,C(SH).readonly()),listEventKinds:D(x({deviceId:r()}),C(ZV).readonly()),listEventKindsBatch:D(x({deviceIds:C(r()).min(1).max(200)}),C(QV).readonly()),getSensorEvents:D(x({deviceId:r(),since:r().optional(),until:r().optional(),kinds:C(u()).optional(),limit:r().int().min(1).max(xU).default(bU)}),C($V).readonly()),getKeyEvents:D(WCe,C(DU).readonly()),getKeyEventsBatch:D(GCe,C(KCe).readonly()),readLongTermSeries:D(x({deviceId:r(),series:PU,scope:u().optional(),from:r(),to:r(),limit:r().int().positive().optional()}),C(IU).readonly()),getEventDensity:D(x({deviceId:r(),since:r(),until:r(),bucketMs:r().int().positive()}),C(OU).readonly()),getEventDensityBatch:D(x({deviceIds:C(r()).min(1).max(200),since:r(),until:r(),bucketMs:r().int().positive()}),C(kU).readonly()),pruneEventsBefore:D(x({deviceId:r(),cutoffMs:r()}),x({motion:r().int(),object:r().int(),audio:r().int()}),{kind:`mutation`,auth:`admin`}),pruneTracksBefore:D(x({deviceId:r(),cutoffMs:r()}),jU,{kind:`mutation`,auth:`admin`}),wipeAllAnalytics:D(x({deviceId:r()}),jU,{kind:`mutation`,auth:`admin`}),reconcileFromDisk:D(x({deviceId:r()}),XCe,{kind:`mutation`,auth:`admin`}),deleteTracks:D(x({deviceId:r(),trackIds:C(u()).min(1)}),x({deleted:r().int(),failed:C(u()).readonly(),sparedMediaIds:C(r().int()).readonly().optional()}),{kind:`mutation`,auth:`admin`}),setTrackFlags:D(x({deviceId:r(),trackId:u(),flags:cH}),lH,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listArchivedDebugNotes:D(Zs,C(Xs).readonly(),{kind:`query`}),setTrackRelation:D(vae,tc,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),clearTrackRelation:D(rc,ic,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),setTrackPurity:D(ac,oc,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listTrackRelations:D(sc,cc,{kind:`query`}),listBirthDecisions:D(Ys,C(Js).readonly(),{kind:`query`}),getEventStoreFootprint:D(x({}),QCe,{kind:`query`,auth:`admin`}),getEventMediaFootprintByKind:D(x({deviceId:r().int().optional()}),ewe,{kind:`query`,auth:`admin`}),pruneEvents:D(x({olderThanMs:r(),reason:gc.optional()}),MU,{kind:`mutation`,auth:`admin`}),deleteDeviceEvents:D(x({deviceId:r()}),MU,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:D(Cl,x({paused:m(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:D(Cl,x({resumed:m(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:D(Cl,x({refreshed:m(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:D(Ml,x({jobId:u()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:D(x({jobId:u()}),bl.nullable(),{auth:`admin`}),cancelStorageMigrationMove:D(x({jobId:u()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateMedia:D(El,x({jobId:u()}),{kind:`mutation`,auth:`admin`}),countUnstampedEventMedia:D(x({}),Ol,{auth:`admin`}),getMediaLocationCensus:D(kl,jl,{kind:`query`,auth:`admin`}),countRelocatableMedia:D(iu,ru,{kind:`query`,auth:`admin`}),listRelocateMediaJobs:D(x({}),C(bl).readonly(),{kind:`query`,auth:`admin`}),cancelRelocateMedia:D(x({jobId:u()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),listOpsLog:D(vc,C(_c).readonly(),{kind:`query`,auth:`admin`}),reclaimDebugMedia:D(owe,awe,{kind:`mutation`,auth:`admin`}),getMediaReclaimStatus:D(x({}),swe,{kind:`query`,auth:`admin`}),getTrainingExportSummary:D(x({deviceIds:C(r()).optional()}),pH,{kind:`query`,auth:`admin`}),getTrainingExportUrl:D(x({deviceIds:C(r()).optional()}),x({url:u()}),{kind:`query`,auth:`admin`}),listRetrainStaging:D(x({deviceIds:C(r()).optional(),limit:r().int().min(1).max(500).optional()}),C(VH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainCorpusPage:D(XH,QH,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getRetrainCorpusKpi:D(x({}),eU,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainFrames:D(x({trackId:u()}),JH,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),selectRetrainFrames:D(x({deviceId:r(),trackId:u(),mediaIds:C(r().int()).min(1)}),qH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deselectRetrainFrame:D(x({deviceId:r(),trackId:u().optional(),frameId:u()}),x({removed:y(),removedAnnotations:r().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainFrameImage:D(x({frameId:u()}),x({base64:u(),width:r().int(),height:r().int()}),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotations:D(x({deviceId:r(),trackId:u().optional(),frameId:u(),subject:aU,nodeId:u().optional()}),oU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainAnnotations:D(x({trackId:u().optional(),frameIds:C(u()).max(2e3).optional()}),C(IH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),saveRetrainAnnotations:D(x({deviceId:r(),trackId:u().optional(),frameId:u(),annotations:C(LH),expectedRevision:r().int().optional(),dismissed:C(MH).optional()}),C(IH).readonly(),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),backfillRetrainOrigins:D(x({deviceId:r(),trackId:u().optional(),frameId:u(),expectedRevision:r().int().optional(),origins:C(x({annotationId:u(),origin:jH})).min(1).max(500)}),x({updated:r().int(),skipped:r().int(),revision:r().int()}),{kind:`mutation`,auth:`admin`}),completeRetrainTrack:D(x({deviceId:r(),trackId:u()}),yU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),restageRetrainTrack:D(x({deviceId:r(),trackId:u()}),yU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainExportUrl:D(tU.extend({layout:nU.optional()}),x({url:u()}),{kind:`query`,auth:`admin`}),setRetrainFrameComplete:D(x({deviceId:r(),trackId:u().optional(),frameId:u(),complete:y()}),GH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),writeRetrainArchive:D(x({filter:tU,layout:nU,target:rU}),iU,{kind:`mutation`,auth:`admin`,timeoutMs:60*6e4}),offerRetrainArchive:D(x({filter:tU,layout:nU}),x({ticket:io,frames:r().int(),annotations:r().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),listRetrainAssistProfiles:D(x({}),C(dU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotationsWithLlm:D(x({deviceId:r(),trackId:u().optional(),frameId:u(),profileId:u(),classes:C(DH).min(1),boxes:C(x({ref:u(),bbox:AH,macroClass:DH,label:u().optional()})).max(50),allowCloud:y()}),mU,{kind:`mutation`,auth:`admin`,timeoutMs:18e4}),createRetrainCollection:D(x({name:u().max(120)}),cU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollections:D(x({}),C(sU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),resolveRetrainTrainingCorpus:D(_U,vU,{kind:`query`,auth:`admin`,timeoutMs:6e4}),renameRetrainCollection:D(x({id:u(),name:u().max(120)}),lU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deleteRetrainCollection:D(x({id:u()}),x({deleted:y(),removedFrames:r().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),addRetrainFrameFromRecording:D(x({collectionId:u(),deviceId:r(),epochMs:r(),verdictSubject:BH.optional()}),uU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`,timeoutMs:6e4}),addRetrainFramesToCollection:D(x({collectionId:u(),frameIds:C(u()).min(1).max(500)}),x({added:r().int(),alreadyMember:r().int(),unknownFrameIds:C(u()).readonly()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),removeRetrainFrameFromCollection:D(x({collectionId:u(),frameId:u()}),x({removed:y(),deletedFrame:y()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollectionFrames:D(x({collectionId:u()}),C(GH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getEventMedia:D(x({ownerType:Ue,eventId:r().int(),kind:CH.optional(),deviceId:r()}),C(TH).readonly()),getTrackMedia:D(x({trackId:u(),kinds:C(CH).optional(),deviceId:r()}),C(TH).readonly()),listTrackMedia:D(x({trackId:u(),deviceId:r()}),C(EH).readonly()),listEventMedia:D(x({ownerType:Ue,eventId:r().int(),deviceId:r()}),C(EH).readonly()),ownersWithMedia:D(x({deviceId:r(),ownerKind:Ge,ownerIds:C(u()).max(5e3)}),C(u()).readonly()),searchObjectEvents:D(YCe,C(AU).readonly(),{caller:`required`}),wipeObjectEmbeddings:D(x({}),nwe,{kind:`mutation`,auth:`admin`}),rebuildObjectEmbeddings:D(twe,rwe,{kind:`mutation`,auth:`admin`}),getObjectEmbeddingRebuildStatus:D(x({}),iwe)},events:{onFrameTracked:{data:x({deviceId:r(),timestamp:r(),frameWidth:r(),frameHeight:r(),detections:C(JCe).readonly()}),notOperatorFacing:`one tracker frame — stream rate, never an automation trigger`},onTrackStarted:{data:x({deviceId:r(),trackId:u(),className:u()}),trigger:{category:T.PipelineAnalyticsTrackStarted,label:L(`Subject appeared`,`Soggetto comparso`),phrase:L(`When {device} starts following a subject`,`Quando {device} inizia a seguire un soggetto`),icon:`scan-eye`}},onTrackEnded:{data:x({deviceId:r(),trackId:u(),className:u(),durationMs:r()}),trigger:{category:T.PipelineAnalyticsTrackEnded,label:L(`Subject left`,`Soggetto uscito`),phrase:L(`When a subject leaves the view of {device}`,`Quando un soggetto esce dall’inquadratura di {device}`),icon:`scan-eye`}},onDetectionEvent:{data:x({deviceId:r(),kind:qV,eventId:u(),timestamp:r()}),trigger:{category:T.PipelineAnalyticsDetectionEvent,label:L(`Detection event`,`Evento di rilevamento`),phrase:L(`When {device} records a detection event`,`Quando {device} registra un evento di rilevamento`),icon:`radar`}}},vocabulary:{noun:L(`Tracking`,`Tracciamento`),order:3200,extraEvents:[{category:T.PipelineAnalyticsPackageDelivered,label:L(`Package delivered`,`Pacco consegnato`),phrase:L(`When a package is left in front of {device}`,`Quando viene lasciato un pacco davanti a {device}`),icon:`package`},{category:T.PipelineAnalyticsPackagePickedUp,label:L(`Package picked up`,`Pacco ritirato`),phrase:L(`When a package is picked up in front of {device}`,`Quando viene ritirato un pacco davanti a {device}`),icon:`package-open`}]}},RU=o(()=>x({addonId:u(),modelId:u().optional(),enabled:y().default(!0),children:C(RU).optional(),settings:h(u(),w()).optional(),jumpDeviceKey:u().optional()})),zU=ye(),BU=x({x:r(),y:r(),w:r(),h:r()}),VU=x({stepId:u(),modelId:u(),detections:C(x({bbox:d([r(),r(),r(),r()]),score:r(),landmarks:C(x({x:r(),y:r()})).optional()})).min(1)}),HU=x({handle:Lc,cropFrameSpace:x({x:r(),y:r(),w:r(),h:r()})});x({crop:x({left:r(),top:r(),width:r().positive(),height:r().positive()}).optional(),content:x({width:r().int().positive(),height:r().int().positive()}),fit:S([`stretch`,`contain`]),format:S([`rgb`,`gray`,`jpeg`])});var lwe=x({registryId:u().min(1),id:u().min(1),width:r().int().positive(),height:r().int().positive(),format:S([`rgb`,`gray`]),timestamp:r(),capturedAt:r().optional()}),UU=S([`onnx`,`coreml`,`openvino`,`tflite`,`pt`,`gguf`]),WU=S([`detector`,`cropper`,`classifier`,`refiner`,`audio-classifier`]),GU=x({runtime:m(`python`),backend:u(),format:UU,device:u().optional()}),KU=x({deviceKey:u().nullable(),runtime:u(),batchMode:u(),windowMs:r(),maxBatchSize:r(),concurrency:r(),numWorkers:r()}),uwe=x({engine:GU,devices:C(x({id:u(),label:u(),description:u().optional()})).readonly(),defaultDevice:u()}),qU=o(()=>x({addonId:u(),addonName:u(),slot:WU,inputClasses:C(u()).readonly(),outputClasses:C(u()).readonly(),enabled:y(),modelId:u(),children:C(qU).readonly(),group:u().optional(),settings:h(u(),w()).optional()})),dwe=x({id:u(),name:u(),formats:h(u(),gf),group:yf.optional(),legacy:y().optional(),provider:xf.optional(),defaultConfidence:r().optional(),suppliesSteps:C(wf).readonly().optional()}),fwe=ye(),pwe=x({id:u(),name:u(),slot:WU,inputClasses:C(u()).readonly(),outputClasses:C(u()).readonly(),childSlots:C(WU).readonly(),models:C(dwe).readonly(),defaultModelId:u(),defaultModelIdByFormat:h(u(),u()).optional(),enabledByDefault:y().optional(),defaultConfidence:r(),group:u().optional(),configSchema:C(fwe).readonly().optional()}),mwe=x({id:WU,label:u(),priority:r(),parentSlot:WU.nullable(),addons:C(pwe).readonly()}),hwe=x({availableEngines:C(uwe).readonly(),selectedEngine:GU,slots:C(mwe).readonly()}),gwe=x({runtimeId:S([`onnx`,`openvino`,`coreml`,`edgetpu`]).nullable(),device:u().nullable(),state:S([`idle`,`installing`,`verifying`,`ready`,`failed`]),progress:r().optional(),error:u().optional(),nextRetryAt:r().optional(),configIssues:C(u()).optional()}),JU=x({addonId:u(),chosen:u(),running:u(),format:u()}),YU=x({addonId:u(),kind:S([`unknown-addon`,`no-format-build`,`unknown-device`]),detail:u()}),XU=x({ok:y(),issues:C(YU).readonly(),substitutions:C(JU).readonly(),format:u()}),_we=x({filename:u(),stepIds:C(u()).readonly().optional()}),vwe=x({base64:u(),filename:u()}),ywe=x({filename:u(),sizeKb:r()}),bwe=x({base64:u()}),xwe=x({id:u(),name:u(),description:u(),available:y(),rawLabels:C(u()).readonly().optional()}),Swe=x({activeBackend:u(),availableBackends:C(xwe).readonly(),sampleRate:r(),chunkDurationMs:r()}),Cwe=x({filePath:u(),sizeMB:r(),durationMs:r()}),wwe=x({success:y(),error:u().optional(),frame:ye().optional()}),Twe=ye(),Ewe=ye(),Dwe=ye(),Owe=ye(),ZU={name:`pipeline-executor`,scope:`system`,mode:`singleton`,methods:{getAvailableEngines:D(v(),C(GU)),getSelectedEngine:D(v(),GU),getEngineProvisioning:D(x({nodeId:u()}),gwe),getVideoPipelineSteps:D(v(),h(u(),x({modelId:u(),settings:h(u(),w()).readonly()}))),setVideoPipelineSteps:D(x({steps:h(u(),x({modelId:u(),settings:h(u(),w()).readonly()}))}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getInferenceDeviceHealth:D(x({nodeId:u()}),x({unhealthy:C(x({deviceKey:u(),state:S([`failed`,`backoff`]),since:r(),deaths:r(),lastError:u(),absentReason:S([`no-gpu-device`]).optional()})).readonly()})),rearmInferenceDevice:D(x({nodeId:u(),deviceKey:u()}),x({rearmed:y()}),{kind:`mutation`,auth:`admin`}),getSchema:D(v(),hwe),getOrchestratorConfigSchema:D(v(),Twe),validatePipeline:D(x({steps:C(RU),deviceKey:u().optional()}),XU),getCapabilities:D(v(),Dwe),getAddonModels:D(x({addonId:u()}),Owe),downloadModel:D(x({addonId:u(),modelId:u(),format:UU}),Cwe,{kind:`mutation`}),deleteModel:D(x({addonId:u(),modelId:u(),format:UU}),x({success:m(!0)}),{kind:`mutation`}),runPipeline:D(x({steps:C(RU).min(1),frame:ky.optional(),frameRef:lwe.optional(),frameHandle:Lc.optional(),imageBase64:u().optional(),image:b(Uint8Array).optional(),referenceImage:u().optional(),deviceId:r().optional(),sessionId:u().optional(),plane:S([`full`,`frame`]).optional(),deviceKey:u().optional(),nativeCropRef:HU.optional(),replay:m(!0).optional(),suppliedRoot:VU.optional(),motionRegions:C(BU).optional()}),zU,{kind:`mutation`}),runPipelineBatch:D(x({steps:C(RU).min(1),frames:C(ky).min(1).max(255),deviceId:r().optional(),sessionId:u().optional(),frameId:r().int().nonnegative().optional(),deviceKey:u().optional()}),x({results:C(zU).readonly()}),{kind:`mutation`}),cacheFrameInPool:D(x({data:b(Uint8Array),width:r().int().positive(),height:r().int().positive(),format:S([`rgb`,`bgr`,`gray`])}),x({frameId:r(),width:r(),height:r()}),{kind:`mutation`}),inferCached:D(x({stepId:u(),frameId:r().int(),modelId:u().min(1)}),h(u(),w()),{kind:`mutation`}),uncacheFrame:D(x({frameId:r().int()}),v(),{kind:`mutation`}),getEffectiveTuning:D(x({deviceKey:u().optional()}),KU),listLoadedEngines:D(v(),C(x({engineKey:u(),engine:GU,modelsLoaded:C(u()).readonly(),inUseByCameras:C(r()).readonly(),kind:S([`runtime`,`device-pool`]),poolPid:r().nullable(),idleMs:r().nullable(),idleTtlMs:r().nullable()})).readonly()),spinEngine:D(x({engine:GU}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),killEngine:D(x({engine:GU,force:y().optional()}),x({success:y(),reason:u().optional()}),{kind:`mutation`,auth:`admin`}),listReferenceImages:D(v(),C(_we).readonly()),getReferenceImage:D(x({filename:u()}),vwe.nullable()),getReferenceAudioFiles:D(v(),C(ywe).readonly()),getReferenceAudio:D(x({filename:u()}),bwe.nullable()),getAudioCapabilities:D(v(),Swe),runAudioTest:D(x({addonId:u(),modelId:u(),filename:u().optional(),settings:h(u(),w()).optional()}),wwe,{kind:`mutation`}),getDetectionConfigSchema:D(v(),Ewe)},vocabulary:{notOperatorFacing:k.PIPELINE}},kwe=x({activeCameras:r(),throttledCameras:r(),avgInferenceTimeMs:r(),queueDepth:r()}),QU=x({detectionMode:S([`disabled`,`always-on`,`on-motion`]),configuredFps:r(),actualFps:r(),queueDepth:r(),avgInferenceTimeMs:r(),droppedFrames:r(),nativeCropMisses:r().optional(),phase:S([`idle`,`watching`,`active`])}),$U=QU.extend({deviceId:r()}),eW=S([`polygon`,`tripwire`]),tW=x({x:r(),y:r()}),nW=x({id:u(),name:u(),kind:eW.default(`polygon`),polygon:C(tW).readonly(),color:u().default(`#3b82f6`)}),rW={name:`zones`,scope:`device`,mode:`singleton`,deviceTypes:[M.Camera],methods:{listZones:D(x({deviceId:r()}),C(nW).readonly()),addZone:D(x({deviceId:r(),zone:nW}),v(),{kind:`mutation`,auth:`admin`}),removeZone:D(x({deviceId:r(),zoneId:u()}),v(),{kind:`mutation`,auth:`admin`}),updateZone:D(x({deviceId:r(),zone:nW}),v(),{kind:`mutation`,auth:`admin`})},runtimeState:x({zones:C(nW).readonly()}),durability:`restored`,history:`none`,vocabulary:{noun:L(`Zones`,`Zone`),order:3370}},iW={fpsPerStream:10,budgetMinutes:45,minBudgetMinutes:10,maxBudgetMinutes:120,staleAfterDays:30,settleSec:5,measureSec:20,drainTimeoutSec:120,maxModelsPerDevice:6},aW=S([`device`,`pipeline`]),oW=x({deviceKey:u().min(1),modelIds:C(u().min(1)).min(1).max(iW.maxModelsPerDevice)}),sW=x({nodeId:u().min(1),devices:C(oW).min(1),phases:C(aW).min(1).default([`device`,`pipeline`]),steps:C(u().min(1)).default([]),fpsPerStream:r().int().min(1).max(30).default(iW.fpsPerStream),budgetMinutes:r().int().min(iW.minBudgetMinutes).max(iW.maxBudgetMinutes).default(iW.budgetMinutes),keepDownloadedModels:y().default(!1),acceptInsufficientHeadroom:y().default(!1)}),cW=S([`benchmark-active`,`node-offline`,`unknown-device`,`no-phase`,`insufficient-headroom`]),lW=x({kind:cW,detail:u(),overridable:y()}),uW=x({deviceId:r(),placedOnNode:y(),pinnedToNode:y()}),dW=x({deviceId:r(),reason:m(`only-frame-source`)}),fW=x({nodeId:u(),online:y(),moving:C(uW).readonly(),staying:C(dW).readonly(),estimatedDurationMs:r(),budgetMs:r(),phases:C(aW).readonly(),steps:C(u()).readonly(),devices:C(oW).readonly(),headroom:x({sessionsNow:r(),otherNodesCapacitySessions:r().nullable()}),refusals:C(lW).readonly(),canStart:y()}),pW=x({phase:S([`preparing`,`device`,`pipeline`,`cleanup`]),deviceKey:u().nullable(),modelId:u().nullable(),load:r().nullable(),cellsDone:r(),cellsTotal:r(),message:u()}),mW=S([`p95`,`drops`,`errors`,`stall`,`cpu`,`ram`,`none`]),hW=x({load:r(),pass:y(),p95Ms:r(),dropRatio:r(),fps:r(),cpuPct:r().nullable(),ramFreePct:r().nullable(),failReasons:C(u()).readonly()}),gW=x({phase:m(`device`),deviceKey:u(),modelId:u(),p50Ms:r(),p95Ms:r(),p99Ms:r(),fps:r(),kMax:r(),limitedBy:mW,warmupMs:r(),ramp:C(hW).readonly()}),_W=x({phase:m(`pipeline`),deviceKey:u(),modelId:u(),steps:C(u()).readonly(),maxSessions:r(),limitedBy:mW,stepsFired:C(u()).readonly(),warmupMs:r(),ramp:C(hW).readonly()}),vW=a(`phase`,[gW,_W]),yW=x({pipelineVersion:u().nullable(),cpuModel:u().nullable(),ramGb:r().nullable(),os:u().nullable(),pools:h(u(),x({runtime:u(),numWorkers:r(),concurrency:r(),batchMode:u()})).default({})}),bW=x({id:u(),revision:u().nullable(),frames:r(),width:r(),height:r()}),xW=x({runId:u().min(1),devices:C(oW).min(1),phases:C(aW).min(1),steps:C(u()).default([]),fpsPerStream:r().int().min(1).max(30),deadlineAtMs:r(),settleSec:r().min(0).max(60).default(iW.settleSec),measureSec:r().min(2).max(300).default(iW.measureSec),keepDownloadedModels:y().default(!1)}),SW=S([`running`,`done`,`failed`,`aborted`]),CW=x({runId:u(),nodeId:u(),state:SW,progress:pW.nullable(),cells:C(vW).readonly(),fingerprint:yW.nullable(),clip:bW.nullable(),activeCameraIds:C(r()).readonly(),deletedModels:C(u()).readonly(),error:u().nullable(),startedAtMs:r(),finishedAtMs:r().nullable()}),wW=S([`draining`,`measuring`,`restoring`,`done`,`failed`,`aborted`]),TW=S([`completed`,`operator-abort`,`deadline`,`node-lost`,`runner-lost`,`hub-restart`,`drain-timeout`,`failed`]),EW=x({runId:u(),nodeId:u(),state:wW,plan:sW,startedAtMs:r(),deadlineAtMs:r(),finishedAtMs:r().nullable(),endReason:TW.nullable(),error:u().nullable(),moved:C(r()).readonly(),staying:C(r()).readonly(),contaminated:y(),progress:pW.nullable(),resultIds:C(u()).readonly()}),DW=x({modeNodeId:u().nullable(),run:EW.nullable()}),OW=x({id:u(),runId:u(),nodeId:u(),cell:vW,fpsPerStream:r(),fingerprint:yW.nullable(),clip:bW.nullable(),contaminated:y(),stayingCameras:C(r()).readonly(),partialRun:y(),measuredAtMs:r()}),kW=x({nodeId:u().optional(),deviceKey:u().optional()}),AW=OW.extend({standing:S([`fresh`,`stale`,`superseded`]),staleWhy:S([`age`,`runtime`,`pool-tuning`]).nullable()}),Awe=x({runId:u(),nodeId:u(),startedAtMs:r(),deadlineAtMs:r(),plan:sW,moved:C(r()).readonly(),staying:C(r()).readonly()}),jW=x({nodeId:u(),reachable:y(),devices:C(x({deviceKey:u(),enabled:y(),available:y(),suggested:C(u()).readonly(),all:C(u()).readonly(),currentModelId:u().nullable()})).readonly(),steps:C(x({id:u(),name:u(),slot:u()})).readonly()}),MW=x({x:r(),y:r(),w:r(),h:r()}),NW=x({bytes:b(Uint8Array).optional(),jpeg:u().optional(),jpegBytes:b(Uint8Array).optional(),width:r().int().positive(),height:r().int().positive(),tier:S([`native`,`ram-fullframe`]).optional()}),PW=S([`keyFrame`,`thumbnail`]),FW=S([`handle-gone`,`encode-failed`]),IW=a(`parked`,[x({parked:m(!0),nodeId:u(),width:r().int().positive(),height:r().int().positive(),bytes:r().int().nonnegative(),replaced:y()}),x({parked:m(!1),nodeId:u(),reason:FW,handleAgeMs:r().nullable(),detail:u().optional()})]),LW=x({jpeg:u().optional(),jpegBytes:b(Uint8Array).optional(),width:r().int().positive(),height:r().int().positive(),timestamp:r(),parkedAt:r()}),jwe=x({bbox:MW,className:u()}),RW=x({stepId:u(),className:u(),score:r(),bbox:MW.optional(),embedding:u().optional(),embeddingMagnitude:r().optional(),embeddingModelId:u().optional(),label:u().optional(),labelTier:g([m(1),m(2)]).optional(),labelModelId:u().optional(),alignedCropJpeg:u().optional(),nativeFaceShortSidePx:r().optional(),landmarks:C(x({x:r(),y:r()})).optional()}),Mwe=S([`unknown-step`,`model-not-servable`,`unreadable-frame`,`execution-failed`,`no-eligible-device`]),Nwe=a(`kind`,[x({kind:m(`ran`),nodeId:u(),modelId:u(),details:C(RW)}),x({kind:m(`refused`),nodeId:u(),reason:Mwe,detail:u()})]),zW={min:0,max:6e4,default:3e4,step:500},BW={min:0,max:6e5,default:12e4,step:5e3},VW={min:5e3,max:6e5,default:9e4,step:5e3},HW={min:1,max:30,default:4,step:1},UW={min:1,max:30,default:10,step:1},WW={min:0,max:300,default:300,step:5},GW={min:1,max:10,default:4,step:1},KW={min:0,max:30,default:12,step:1},qW=S([`onboard`,`analyzer`,`device-activity`]),JW=x({source:qW,triggeredBy:nV,sensorName:u().optional()}),YW=C(qW),XW={analyzer:`Frame-diff Analyzer (motion addon)`,onboard:`Camera sensors`,"device-activity":`Device activity (the device says it is working)`};function ZW(e){let t=qW.safeParse(e);return t.success?XW[t.data]:e}var Pwe=[`analyzer`,`onboard`,`device-activity`],QW=p(e=>Array.isArray(e)&&e.length>1?e.slice(0,1):e,C(vH).max(1)),$W=x({deviceId:r(),detected:y(),source:qW.default(`analyzer`),regions:C(vV).readonly().optional()}),eG=a(`kind`,[x({kind:m(`local-broker`)}),x({kind:m(`remote-restream`),ownerNodeId:u(),ownerReachableHost:u().optional(),hubHostnameOverride:u().optional()})]).describe(`Per-camera frame-source mode for the runner (P2c)`),tG=x({modelId:u().optional(),settings:h(u(),w()).optional()}),nG=x({deviceKey:u(),weight:r().positive().default(1),maxSessions:r().int().positive().nullable().default(null),steps:h(u(),tG).optional(),disabledSteps:C(u()).readonly().optional()}),rG=x({deviceId:r(),detectionMode:S([`disabled`,`always-on`,`on-motion`]).default(`on-motion`),audioMode:S([`disabled`,`always-on`,`on-motion`]).default(`always-on`),motionCooldownMs:r().min(zW.min).default(zW.default),maxSessionHoldMs:r().min(BW.min).max(BW.max).optional(),audioMotionWindowMs:r().min(VW.min).max(VW.max).optional(),motionFps:r().min(HW.min).max(HW.max).default(HW.default),detectionFps:r().min(UW.min).max(UW.max).default(UW.default),motionStreamId:u(),detectionStreamId:u(),audioStreamPick:Oc.optional(),motionSources:YW.default([`analyzer`]),sessionTrigger:JW.optional(),detectionSources:QW.default([`pipeline`]),pipelineEnabled:y().default(!0),steps:C(RU).readonly().optional(),audio:x({modelId:u().optional(),enabled:y()}).nullable().optional(),zones:C(nW).readonly().default([]),onboardMotionDrivesAnalyzer:y().default(!0),preRollInferenceEnabled:y().default(!0),preRollInferenceFrames:r().min(KW.min).max(KW.max).default(KW.default),occupancyRecheckEnabled:y().default(!0),occupancyRecheckSec:r().min(WW.min).max(WW.max).default(WW.default),occupancyRecheckFrames:r().min(GW.min).max(GW.max).default(GW.default),frameSource:eG.default({kind:`local-broker`}),deviceKey:u().optional(),inferenceDevices:C(nG).readonly().optional()}),Fwe=[{key:`motionSources`,type:`multiselect`,label:`Motion Sources`,default:[`analyzer`],options:Pwe.map(e=>e===`onboard`?{value:e,label:XW[e],description:`The camera's own motion, plus any sensor attached to it`}:{value:e,label:XW[e]})},{key:`motionFps`,type:`slider`,label:`Motion FPS (analyzer)`,min:HW.min,max:HW.max,step:HW.step,default:HW.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`,showWhen:{field:`motionSources`,includes:`analyzer`}},{key:`detectionFps`,type:`slider`,label:`Detection FPS`,min:UW.min,max:UW.max,step:UW.step,default:UW.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`},{key:`motionCooldownMs`,type:`slider`,label:`Motion Cooldown`,description:`Time without a fresh motion event before the active phase ends. Applies to all motion sources — every motion event re-arms the timer.`,min:zW.min,max:zW.max,step:zW.step,default:zW.default,showValue:!0,unit:`s`,displayScale:1e3,nullable:!0,nullLabel:`Default`},{key:`maxSessionHoldMs`,type:`slider`,label:`Max session hold`,description:`Upper bound on how long detection keeps running past the motion cooldown while a subject is still moving in-frame but no longer triggering motion. Prevents the detection box from stopping on a slow-moving subject. Set to 0 to disable.`,min:BW.min,max:BW.max,step:BW.step,default:BW.default,showValue:!0,unit:`s`,displayScale:1e3,nullable:!0,nullLabel:`Default`},{key:`audioMotionWindowMs`,type:`slider`,label:`Audio window after motion`,description:`How long audio keeps being analysed after the last motion event. Each new motion event extends the window without restarting the audio stream.`,min:VW.min,max:VW.max,step:VW.step,default:VW.default,showValue:!0,unit:`s`,displayScale:1e3,nullable:!0,nullLabel:`Default`,showWhen:{field:`audioMode`,equals:`on-motion`}},{key:`onboardMotionDrivesAnalyzer`,type:`boolean`,label:`Run motion analyzer on onboard motion`,description:`When onboard motion is detected, temporarily start the frame-diff analyzer to emit zone results. Stops after the motion cooldown window.`,default:!0,showWhen:{field:`motionSources`,includes:`onboard`}},{key:`preRollInferenceEnabled`,type:`boolean`,style:`checkbox`,label:`Detect in the pre-roll`,description:`Run detection over the few seconds of footage the camera had already buffered when motion fired, so a subject that was in view before the trigger is found at the moment it appeared rather than seconds later. The burst is bounded and never delays live detection.`,default:!0},{key:`preRollInferenceFrames`,type:`slider`,label:`Pre-roll frames`,description:`How many frames of buffered history may be detected on, per session. Higher samples the history more densely; 0 disables the pass.`,min:KW.min,max:KW.max,step:KW.step,default:KW.default,showValue:!0,showWhen:{field:`preRollInferenceEnabled`,equals:!0}},{key:`occupancyRecheckEnabled`,type:`boolean`,style:`checkbox`,label:`Occupancy re-check`,description:`Periodically re-sample a few frames during the watching phase, so objects that are simply parked are still counted (motion gating alone loses them after a restart). On by default at a wide interval; turn it off on cameras where the extra decoder re-dial is expensive.`,default:!0},{key:`occupancyRecheckSec`,type:`slider`,label:`Occupancy re-check interval`,description:`How often (in seconds) the runner re-samples a few frames to confirm the scene is truly empty during the watching phase.`,min:WW.min,max:WW.max,step:WW.step,default:WW.default,showValue:!0,unit:`s`,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}},{key:`occupancyRecheckFrames`,type:`slider`,label:`Occupancy re-check frames`,description:`Number of frames sampled per occupancy re-check burst.`,min:GW.min,max:GW.max,step:GW.step,default:GW.default,showValue:!0,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}}],iG=x({nodeId:u(),attachedCameras:r(),activeCameras:r(),avgInferenceFps:r(),avgInferenceTimeMs:r(),queueDepthTotal:r(),devices:C(x({deviceKey:u(),backend:u(),attachedCameras:r()})).default([]),hardware:x({hasGpu:y(),inferenceBackend:u().optional(),cpuCores:r().optional()}),motionSliceWriter:m(`orchestrator`).optional()}),aG=x({framesDecoded:r(),framesAdmitted:r(),framesDroppedPixelFree:r(),viewsMaterialized:r(),viewsSkipped:r(),workerToRunnerBytes:r(),runnerToPoolRawBytes:r(),runnerToPoolJpegBytes:r(),onDemandFullFrameRequests:r(),onDemandCropRequests:r(),nativeHits:r(),nativeMisses:r(),tileHits:r(),tileMisses:r(),fallbackHits:r(),fallbackMisses:r(),retainedWritesAvoided:r(),residentRefs:r(),residentBytes:r(),releases:r(),evictions:r(),staleMisses:r()}),oG=x({node:aG,cameras:C(aG.extend({deviceId:r()}))}),sG=x({nodeId:u(),activeCameras:r(),throttledCameras:r(),avgInferenceTimeMs:r(),queueDepth:r(),frameLazy:oG.optional()}),cG=S([`not-attached`,`battery-asleep`,`not-watching`,`already-bursting`]),lG={name:`pipeline-runner`,scope:`system`,mode:`singleton`,methods:{attachCamera:D(rG,x({success:m(!0)}),{kind:`mutation`}),detachCamera:D(x({deviceId:r()}),x({success:m(!0)}),{kind:`mutation`}),reportMotion:D($W,x({success:m(!0)}),{kind:`mutation`}),getLocalLoad:D(v(),iG),getLocalMetrics:D(v(),sG),getCameraMetrics:D(x({deviceId:r()}),QU.nullable()),getAllCameraMetrics:D(v(),C($U).readonly()),getLocalCameras:D(v(),C(r()).readonly()),requestOccupancyBurst:D(x({deviceId:r(),frames:r().int().positive().optional(),reason:u()}),x({started:y(),refusedBecause:cG.optional()}),{auth:`admin`,kind:`mutation`}),getNativeCrop:D(x({handle:Lc,bbox:MW,maxWidth:r().int().positive().optional(),acceptJpegBytes:y().optional(),encodeJpeg:y().optional()}),NW.nullable()),runDetailSubtree:D(x({deviceId:r(),frameHandle:Lc.optional(),frameJpeg:u().optional(),cropJpeg:u().optional(),parent:jwe,steps:C(u()).optional(),supplied:x({stepId:u(),modelId:u(),boxes:C(x({bbox:MW,score:r()})).min(1)}).optional()}),x({details:C(RW)}).nullable(),{kind:`mutation`}),runStatelessStep:D(x({stepId:u(),modelId:u(),frameJpeg:u(),bbox:MW,className:u(),sourceDeviceId:r()}),Nwe,{kind:`mutation`}),parkTrackFrame:D(x({deviceId:r(),trackId:u(),kind:PW,handle:Lc,bbox:MW,maxWidth:r().int().positive().optional(),timestamp:r()}),IW,{kind:`mutation`}),getParkedTrackFrame:D(x({deviceId:r(),trackId:u(),kind:PW,acceptJpegBytes:y().optional()}),LW.nullable()),releaseParkedTrackFrames:D(x({deviceId:r(),trackId:u()}),x({released:r().int().nonnegative()}),{kind:`mutation`}),startNodeBench:D(xW,x({accepted:m(!0),runId:u()}),{kind:`mutation`,auth:`admin`}),getNodeBenchStatus:D(x({runId:u()}),CW.nullable(),{auth:`admin`}),abortNodeBench:D(x({runId:u()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.PIPELINE}},uG=3e4,Iwe={version:1,targets:[{id:`detected`,cardinality:`event`,shape:`span`,vocabulary:{cap:`motion`,eventName:`onMotionChanged`},deviceTypes:[M.Camera],apply:`add`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:uG,combine:`any`,sourceModes:[`in-addition`,`confirm`,`replace`],sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},Lwe=15e3,dG=x({detected:y(),lastDetectedAt:r().nullable(),autoClearAfterMs:r().nullable().meta(A(`duration-ms`))}),fG=x({deviceId:r(),detected:y(),timestamp:r(),source:qW,regions:C(vV).readonly().optional(),triggeredBy:nV.optional()}),pG={name:`motion`,scope:`device`,mode:`singleton`,deviceNative:!0,deviceTypes:[M.Camera,M.Sensor],methods:{isDetected:D(x({deviceId:r()}),y())},composedMethods:{isDetected:{kind:`slice`,field:`detected`}},events:{onMotionChanged:{data:fG,notOperatorFacing:"the `detected` state trigger phrases both edges, from the mirror that survives a dropped event (D49)"}},status:{schema:dG,kind:`push`},runtimeState:dG,durability:`session`,history:{fields:{detected:{kind:`boolean`,excludeDeviceTypes:[M.Camera]}}},customize:Iwe,vocabulary:{noun:L(`Motion`,`Movimento`),order:5130,state:[{kind:`boolean`,field:`detected`,label:L(`Motion`,`Movimento`),whenTrue:L(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:L(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}]}},mG=x({enabled:y(),lastChangedAt:r()}),hG=mG.extend({lastFetchedAt:r()}),gG={name:`motion-trigger`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Light,M.Siren,M.Switch],methods:{setMotionTrigger:D(x({deviceId:r().int().nonnegative(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`motionTrigger.on`,label:L(`Motion trigger on`,`Attivazione al movimento attiva`),phrase:L(`Let motion trigger {device}`,`Fai attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!0},args:{enabled:!0}},{id:`motionTrigger.off`,label:L(`Motion trigger off`,`Attivazione al movimento spenta`),phrase:L(`Stop motion triggering {device}`,`Non far più attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!1},args:{enabled:!1}}]})},events:{onMotionTriggerChanged:{data:x({deviceId:r(),enabled:y(),lastChangedAt:r()}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:mG,kind:`command-driven`},runtimeState:hG,durability:`session`,history:`none`,vocabulary:{noun:L(`Motion trigger`,`Attivazione al movimento`),order:1160,state:[{kind:`boolean`,field:`enabled`,label:L(`Motion trigger`,`Attivazione al movimento`),whenTrue:L(`When motion triggering is turned on for {device}`,`Quando si attiva l’attivazione al movimento di {device}`),whenFalse:L(`When motion triggering is turned off for {device}`,`Quando si disattiva l’attivazione al movimento di {device}`),icon:`activity`}]}},_G=x({id:r(),enabled:y(),shape:TV}),vG=x({enabled:y(),sensitivity:r().meta(A(`none`)),regions:C(_G),lastFetchedAt:r()}),yG=x({maxRegions:r(),supportedShapes:C(DV),grid:kV,sensitivity:x({min:r(),max:r(),step:r()})}),bG=x({enabled:y().optional(),sensitivity:r().optional(),regions:C(_G).optional()}),xG={name:`motion-zones`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/motion-zones-grid`,tab:`motion`,label:`Motion Zones`}},methods:{getOptions:D(x({deviceId:r()}),yG),setZone:D(x({deviceId:r(),patch:bG}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:vG,kind:`poll`},runtimeState:vG,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Motion zones`,`Zone di movimento`),order:3170}},Rwe=S([`external`,`embedded`]),zwe=S([`connected`,`disconnected`,`auth-failed`,`unreachable`,`tls-error`]),SG=x({id:u(),name:u(),url:u(),kind:Rwe,status:zwe,latencyMs:r().nullable(),error:u().optional(),connectedClients:r().int().nonnegative().optional(),lastCheckedAt:r().optional()}),CG=x({url:u(),username:u().optional(),password:u().optional(),clientIdPrefix:u().optional()}),wG=x({name:u().min(1),url:u().regex(/^(mqtt|mqtts|ws|wss):\/\//,`URL must start with mqtt(s):// or ws(s)://`),username:u().optional(),password:u().optional(),clientIdPrefix:u().optional()}),Bwe=x({id:u()}),TG=x({id:u()}),EG=x({port:r().int().min(1).max(65535).default(1883),allowAnonymous:y().default(!1),username:u().optional(),password:u().optional()}),Vwe=x({id:u(),url:u()}),DG=x({brokerCount:r(),embeddedRunning:y()}),OG={name:`mqtt-broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:DG,kind:`poll`},methods:{listBrokers:D(v(),C(SG)),getBrokerConfig:D(TG,CG,{auth:`admin`}),addBroker:D(wG,Bwe,{kind:`mutation`,auth:`admin`}),removeBroker:D(TG,v(),{kind:`mutation`,auth:`admin`}),startEmbeddedBroker:D(EG,Vwe,{kind:`mutation`,auth:`admin`}),stopEmbeddedBroker:D(TG,v(),{kind:`mutation`,auth:`admin`}),getStatus:D(v(),DG)},vocabulary:{notOperatorFacing:k.NETWORK}},kG=S([`person`,`vehicle`,`animal`,`face`,`package`,`other`]),AG=x({class:kG,timestamp:r(),confidence:r().min(0).max(1).optional()}),jG=x({lastByClass:f(kG,AG.nullable()),supportedClasses:C(kG).readonly(),enabled:y()}),MG=S([`boxed`,`while-streaming`,`flag-only`]),NG=x({supportedClasses:C(kG).readonly(),geometry:MG}),PG=x({enabled:y().optional()}),FG=jG.extend({lastFetchedAt:r()}),IG={name:`native-object-detection`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],methods:{getOptions:D(x({deviceId:r()}),NG),setSettings:D(x({deviceId:r(),settings:PG}),v(),{kind:`mutation`,auth:`admin`}),setEnabled:D(x({deviceId:r(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`nativeDetection.on`,label:L(`On-camera detection on`,`Rilevamento a bordo attivo`),phrase:L(`Turn on the on-camera detection of {device}`,`Attiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!0}},{id:`nativeDetection.off`,label:L(`On-camera detection off`,`Rilevamento a bordo spento`),phrase:L(`Turn off the on-camera detection of {device}`,`Disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!1}}]})},events:{onDetected:{data:x({deviceId:r(),detection:AG}),trigger:{category:T.DetectionCameraNative,label:L(`Camera spotted something`,`La telecamera ha rilevato qualcosa`),phrase:L(`When {device} spots something with its own detector`,`Quando {device} rileva qualcosa con il proprio rilevatore`),icon:`scan-eye`}}},status:{schema:jG,kind:`push`},runtimeState:FG,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`On-camera detection`,`Rilevamento a bordo`),order:3180,state:[{kind:`boolean`,field:`enabled`,label:L(`On-camera detection`,`Rilevamento a bordo`),whenTrue:L(`When the on-camera detection of {device} is turned on`,`Quando si attiva il rilevamento a bordo di {device}`),whenFalse:L(`When the on-camera detection of {device} is turned off`,`Quando si disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`}]}},LG=x({pan:r().min(-1).max(1).optional(),tilt:r().min(-1).max(1).optional(),speed:r().min(0).max(1).optional()}),RG=S([`goHome`,`locate`,`spotClean`,`findPet`,`personFollow`,`stop`,`startClean`,`pauseClean`,`dockWash`,`autoEmpty`,`flashOn`,`flashOff`]),zG=S([`action`,`sound`]),BG=x({id:u(),kind:zG,label:u(),icon:u(),soundId:r().int().optional(),enabled:y()}),Hwe=[{id:`startClean`,kind:`action`,label:`Start cleaning`,icon:`play`,enabled:!0},{id:`pauseClean`,kind:`action`,label:`Pause cleaning`,icon:`pause`,enabled:!0},{id:`stop`,kind:`action`,label:`Stop`,icon:`hand`,enabled:!0},{id:`goHome`,kind:`action`,label:`Return to dock`,icon:`home`,enabled:!0},{id:`locate`,kind:`action`,label:`Locate`,icon:`bell`,enabled:!0},{id:`spotClean`,kind:`action`,label:`Spot clean here`,icon:`crosshair`,enabled:!0},{id:`findPet`,kind:`action`,label:`Find pet`,icon:`paw-print`,enabled:!0},{id:`personFollow`,kind:`action`,label:`Follow me`,icon:`footprints`,enabled:!0},{id:`dockWash`,kind:`action`,label:`Wash mop`,icon:`droplets`,enabled:!0},{id:`autoEmpty`,kind:`action`,label:`Empty dustbin`,icon:`trash-2`,enabled:!0},{id:`flashOn`,kind:`action`,label:`Flash on`,icon:`flashlight`,enabled:!0},{id:`flashOff`,kind:`action`,label:`Flash off`,icon:`flashlight-off`,enabled:!0},{id:`sound:meow`,kind:`sound`,label:`Meow`,icon:`cat`,soundId:684,enabled:!0},{id:`sound:bark`,kind:`sound`,label:`Woof`,icon:`dog`,soundId:685,enabled:!0},{id:`sound:footsteps`,kind:`sound`,label:`Footsteps`,icon:`footprints`,soundId:686,enabled:!0},{id:`sound:purring`,kind:`sound`,label:`Purring`,icon:`cat`,soundId:687,enabled:!0},{id:`sound:tickTock`,kind:`sound`,label:`Tick-tock`,icon:`clock`,soundId:688,enabled:!0}],VG=x({x:r(),y:r()}),HG=x({move:y(),stop:y(),goToPoint:y(),runAction:y(),playSound:y(),light:y(),lightMode:y()}),UG=S([`auto`,`manual`]),WG=S([`idle`,`cleaning`,`spot`,`following`,`goto`,`returning`,`paused`,`unknown`]),GG=x({mode:WG,following:y(),flash:y(),lightMode:UG,lightLevel:r().min(40).max(100).meta(A(`none`)),lastChangedAt:r()}),KG=GG.extend({lastFetchedAt:r()}),qG={name:`navigation`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/navigation-panel`,tab:`navigation`,topTab:!0,label:`Navigation`,order:0}},methods:{move:D(LG.extend({deviceId:r()}),v(),{kind:`mutation`,notOperatorFacing:`joystick control from the live view — continuous, not a discrete step`}),stop:D(x({deviceId:r()}),v(),{kind:`mutation`,actions:[{id:`navigation.stop`,label:L(`Stop`,`Ferma`),phrase:L(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),goToPoint:D(VG.extend({deviceId:r()}),v(),{kind:`mutation`,notOperatorFacing:`tap-to-go on the live map — the point only means something on that picture`}),listActions:D(x({deviceId:r()}),C(BG)),runAction:D(x({deviceId:r(),actionId:RG}),v(),{kind:`mutation`,actions:[{id:`navigation.runAction`,label:L(`Run a routine`,`Esegui una routine`),phrase:L(`Have {device} {actionId}`,`Fai eseguire a {device}: {actionId}`),icon:`bot`,openArgs:[{key:`actionId`,label:L(`Routine`,`Routine`),offer:{kind:`enum`,values:[{value:`goHome`,label:L(`go home`,`torna alla base`)},{value:`locate`,label:L(`beep so you can find it`,`suona per farsi trovare`)},{value:`spotClean`,label:L(`clean this spot`,`pulisci questo punto`)},{value:`findPet`,label:L(`find the pet`,`cerca l’animale`)},{value:`personFollow`,label:L(`follow a person`,`segui una persona`)},{value:`stop`,label:L(`stop`,`fermati`)},{value:`startClean`,label:L(`start cleaning`,`inizia a pulire`)},{value:`pauseClean`,label:L(`pause cleaning`,`metti in pausa la pulizia`)},{value:`dockWash`,label:L(`wash the mop at the dock`,`lava il mocio alla base`)},{value:`autoEmpty`,label:L(`empty the bin at the dock`,`svuota il contenitore alla base`)},{value:`flashOn`,label:L(`turn the flash on`,`accendi il flash`)},{value:`flashOff`,label:L(`turn the flash off`,`spegni il flash`)}]}}]}]}),playSound:D(x({deviceId:r(),soundId:r().int()}),v(),{kind:`mutation`,actions:[{id:`navigation.playSound`,label:L(`Play sound`,`Riproduci un suono`),phrase:L(`Play {soundId} on {device}`,`Riproduci {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:L(`Sound`,`Suono`),offer:{kind:`dynamic`,from:`method`,method:`listActions`,valueKey:`soundId`,labelKey:`label`,where:{key:`kind`,equals:`sound`},valueKind:`number`}}]}]}),setLightOn:D(x({deviceId:r(),on:y()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightOn`,label:L(`Light on`,`Luce accesa`),phrase:L(`Turn on the light of {device}`,`Accendi la luce di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`navigation.lightOff`,label:L(`Light off`,`Luce spenta`),phrase:L(`Turn off the light of {device}`,`Spegni la luce di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setLightMode:D(x({deviceId:r(),mode:UG,level:r().min(40).max(100).optional()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightAuto`,label:L(`Light automatic`,`Luce automatica`),phrase:L(`Set the light of {device} to automatic`,`Metti la luce di {device} in automatico`),icon:`lightbulb`,args:{mode:`auto`}}]}),setLightLevel:D(x({deviceId:r(),level:r().min(40).max(100)}),v(),{kind:`mutation`,actions:[{id:`navigation.lightLevel`,label:L(`Set light level`,`Imposta la luce`),phrase:L(`Set the light of {device} to {level}`,`Imposta la luce di {device} al {level}`),icon:`sun-medium`,openArgs:[{key:`level`,label:L(`Level`,`Livello`),offer:{kind:`number`,min:40,max:100,step:1,unit:`%`}}]}]}),getFeatures:D(x({deviceId:r()}),HG)},events:{onStatusChanged:{data:x({deviceId:r(),status:GG}),notOperatorFacing:"the `mode` state trigger reads the same change"}},status:{schema:GG,kind:`push`},runtimeState:KG,durability:`session`,history:`none`,vocabulary:{noun:L(`Robot movement`,`Movimento del robot`),order:2080,state:[{kind:`enum`,field:`mode`,label:L(`Activity`,`Attività`),values:[{value:`idle`,label:L(`Idle`,`Inattivo`)},{value:`cleaning`,label:L(`Cleaning`,`In pulizia`)},{value:`spot`,label:L(`Spot cleaning`,`Pulizia localizzata`)},{value:`following`,label:L(`Following`,`In inseguimento`)},{value:`goto`,label:L(`Moving to a point`,`In movimento verso un punto`)},{value:`returning`,label:L(`Returning`,`In rientro`)},{value:`paused`,label:L(`Paused`,`In pausa`)},{value:`unknown`,label:L(`Unknown`,`Sconosciuto`)}],icon:`bot`}]}},JG=x({url:u(),hostname:u(),port:r(),protocol:S([`http`,`https`]),stable:y().optional()}),Uwe=x({url:u(),stable:y().optional(),updated:y().optional()}),YG=x({connected:y(),endpoint:JG.nullable(),error:u().optional()}),Wwe=JG.extend({id:u(),label:u(),mode:u().optional(),sourcePort:r().optional()}),XG={name:`network-access`,scope:`system`,mode:`collection`,providerKind:`ingress`,methods:{start:D(v(),JG,{kind:`mutation`}),stop:D(v(),v(),{kind:`mutation`}),getEndpoint:D(v(),JG.nullable()),getStatus:D(v(),YG),listEndpoints:D(v(),C(Wwe).readonly())},vocabulary:{notOperatorFacing:k.NETWORK}},ZG=[`wifi`,`ethernet`,`cellular`,`unknown`],QG=x({type:S(ZG),signal:r().min(0).max(100).nullable().meta(A(`percentage`)),rssi:r().optional().meta(A(`signal-level`)),ssid:u().optional(),speedKbps:r().nonnegative().nullable().optional().meta(A(`bitrate`)),linkUp:y().nullable().optional(),lastUpdated:r().meta(A(`none`))}),$G={type:`unknown`,signal:null,lastUpdated:0};function Gwe(e,t){return e===void 0||!Number.isFinite(e)||t<=0||e<0||e>t?null:Math.round(e/t*100)}function Kwe(e){return e===void 0||!Number.isFinite(e)||e>0?null:Math.round((Math.min(-50,Math.max(-100,e))+100)*2)}var eK={name:`network-link`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera,M.Sensor,M.Button,M.Switch,M.Light,M.Lock,M.Siren],methods:{},events:{onStatusChanged:{data:x({deviceId:r(),status:QG}),notOperatorFacing:`the signal / link-type state triggers each read one field of this change`}},status:{schema:QG,kind:`push`,empty:$G},runtimeState:QG,durability:`restored`,history:{fields:{signal:{kind:`gauge`,unit:`%`,deadband:3,minIntervalMs:6e4},rssi:{kind:`gauge`,unit:`dBm`,deadband:2,minIntervalMs:6e4}}},volatileStateFields:[`lastUpdated`],vocabulary:{noun:L(`Network link`,`Collegamento di rete`),order:5250,state:[{kind:`numeric`,field:`signal`,quantity:L(`the signal strength`,`l’intensità del segnale`),label:L(`Signal`,`Segnale`),unit:`%`,icon:`wifi`},{kind:`enum`,field:`type`,label:L(`Link type`,`Tipo di collegamento`),values:[{value:`wifi`,label:L(`Wi-Fi`,`Wi-Fi`)},{value:`ethernet`,label:L(`Ethernet`,`Ethernet`)},{value:`cellular`,label:L(`Cellular`,`Rete mobile`)},{value:`unknown`,label:L(`Unknown`,`Sconosciuto`)}],icon:`network`}]}},tK=x({nominalBitrateKbps:r(),observedBitrateKbps:r(),peakBitrateKbps:r(),packetLossPercent:r(),lastUpdated:r()}),nK=x({rttMs:r(),jitterMs:r(),estimatedBandwidthKbps:r(),packetLossPercent:r().min(0).max(100),downlinkMbps:r().optional(),downlinkAgeMs:r().optional(),lastUpdated:r()}),rK=x({deviceId:r(),streams:h(u(),tK),client:nK.optional()}),iK={name:`network-quality`,scope:`system`,mode:`singleton`,methods:{getDeviceStats:D(x({deviceId:r()}),rK.nullable()),getAllStats:D(v(),C(rK).readonly()),reportClientStats:D(x({deviceId:r(),rttMs:r().min(0).max(6e4),jitterMs:r().min(0).max(1e4),estimatedBandwidthKbps:r().min(0).max(1e6),packetLossPercent:r().min(0).max(100),downlinkMbps:r().min(0).max(1e5).optional(),downlinkAgeMs:r().min(0).max(864e5).optional()}),v(),{role:`viewer`,kind:`mutation`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:k.NETWORK}},aK=x({cn:u(),serial:u(),fingerprintSha256:u(),notBefore:r(),notAfter:r()}),oK=x({fingerprintSha256:u(),issuer:u(),sans:C(u()),notBefore:r(),notAfter:r()}),sK=a(`state`,[x({state:m(`served`),leaf:oK}),x({state:m(`not-issued`),reason:u()})]),cK={name:`node-certificates`,scope:`system`,mode:`singleton`,internal:!0,methods:{getCertificates:D(x({}),x({nodeId:u(),mesh:aK.nullable(),https:sK}),{auth:`admin`}),prepareMeshRenewal:D(x({}),x({csrPem:u()}),{kind:`mutation`,auth:`admin`}),installMeshLeaf:D(x({certPem:u().min(1),caCertPem:u().min(1),confirmWithinMs:r().int().min(1e4).max(6e5)}),x({fingerprintSha256:u(),serial:u()}),{kind:`mutation`,auth:`admin`}),confirmMeshLeaf:D(x({fingerprintSha256:u()}),x({confirmed:y()}),{kind:`mutation`,auth:`admin`}),rollbackMeshLeaf:D(x({}),x({rolledBack:y()}),{kind:`mutation`,auth:`admin`}),prepareHttpsCertificate:D(x({}),x({csrPem:u(),hostnames:C(u()),addresses:C(u()),pinnedCaFingerprintSha256:u().nullable()}),{kind:`mutation`,auth:`admin`}),forgetHub:D(x({}),x({ok:m(!0)}),{kind:`mutation`,auth:`admin`}),installHttpsCertificate:D(x({certPem:u().min(1),caCertPem:u().min(1),caRotation:y().optional()}),oK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.IDENTITY}},lK=x({nodeId:u().min(1),removedAt:r()}),uK=x({counts:h(u(),r().int().nonnegative())}),dK={name:`node-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onNodeRemoved:D(lK,uK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.INTERNAL}},fK=x({addonId:u(),capabilities:C(u()).readonly(),status:u()}),pK=x({pid:r(),name:u(),state:u(),cpuPercent:r(),memoryRss:r(),uptimeSeconds:r(),services:C(fK).readonly(),groupId:u().optional()}),qwe=x({id:u(),status:u(),cpuPercent:r(),memoryRss:r()}),Jwe=x({category:u(),total:r(),healthy:r(),addons:C(qwe).readonly()}),Ywe=x({name:u(),version:u()}),mK=x({id:u(),name:u(),hostname:u(),platform:u(),arch:u(),cpuModel:u().nullable(),cpuCores:r(),memoryMB:r(),engines:C(u()).readonly(),isHub:y(),isOnline:y(),cpuPercent:r(),memoryPercent:r().nullable(),uptime:r(),lastSeen:u(),localIps:C(u()).readonly(),addons:C(x({id:u(),capabilities:C(u()).readonly(),status:u()})).readonly(),processes:C(pK).readonly(),categories:C(Jwe).readonly(),rootPackage:Ywe.nullable(),meshTransport:S([`tls`,`clear`]).optional(),capabilitiesRegistered:y().optional()}),Xwe=x({callerAddonId:u(),providerAddonId:u(),capName:u(),callsPerMin:r(),lastCallAtMs:r()}),hK=x({nodeId:u(),name:u(),version:u(),status:u(),synced:y()}),gK=x({hubVersion:u(),nodes:C(hK)}),_K=x({nodeId:u(),addonId:u()}),Zwe=x({id:u(),status:u(),version:u().optional(),packageName:u().optional()}),vK=x({success:y()}),Qwe=x({success:y(),reason:u().optional()}),$we=x({restarted:C(u()).readonly(),failed:C(u()).readonly()}),eTe=x({nodeId:u(),name:u()}),yK=x({id:u(),name:u(),isHub:y(),isOnline:y()}),bK=x({nodes:C(yK).readonly(),complete:y()}),xK={name:`nodes`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{topology:D(v(),C(mK).readonly(),{auth:`admin`}),directory:D(v(),bK,{auth:`admin`}),deployAddon:D(_K,vK,{kind:`mutation`,auth:`admin`}),undeployAddon:D(_K,vK,{kind:`mutation`,auth:`admin`}),restartAddon:D(_K,vK,{kind:`mutation`,auth:`admin`}),restartProcess:D(x({nodeId:u(),processName:u()}),Qwe,{kind:`mutation`,auth:`admin`}),restartNode:D(x({nodeId:u()}),$we,{kind:`mutation`,auth:`admin`}),shutdownNode:D(x({nodeId:u()}),vK,{kind:`mutation`,auth:`admin`}),renameNode:D(x({nodeId:u(),name:u().min(1).max(64)}),eTe,{kind:`mutation`,auth:`admin`}),clusterAddonStatus:D(v(),h(u(),gK),{auth:`admin`}),getCapUsageGraph:D(x({windowSeconds:r().int().positive().max(300).default(60)}),C(Xwe).readonly(),{auth:`admin`}),getNodeAddons:D(x({nodeId:u()}),C(Zwe).readonly(),{auth:`admin`}),setProcessLogLevel:D(x({nodeId:u(),level:u()}),vK,{kind:`mutation`,auth:`admin`}),executeQuery:D(x({nodeId:u(),addonId:u(),queryName:u(),params:h(u(),w()).optional()}),w(),{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:k.CLUSTER}},SK=[{id:`speech`,name:`Speech`},{id:`scream`,name:`Scream / Shout`},{id:`crying`,name:`Crying / Baby`},{id:`laughter`,name:`Laughter`},{id:`music`,name:`Music`},{id:`dog`,name:`Dog`},{id:`cat`,name:`Cat`},{id:`bird`,name:`Bird`},{id:`animal`,name:`Animal (other)`},{id:`alarm`,name:`Alarm / Siren`},{id:`doorbell`,name:`Doorbell / Knock`},{id:`glass_breaking`,name:`Glass Breaking`},{id:`gunshot`,name:`Gunshot / Explosion`},{id:`vehicle`,name:`Vehicle`},{id:`siren`,name:`Emergency Siren`},{id:`fire`,name:`Fire / Smoke`},{id:`water`,name:`Water`},{id:`wind`,name:`Wind / Weather`},{id:`door`,name:`Door`},{id:`footsteps`,name:`Footsteps`},{id:`crowd`,name:`Crowd / Chatter`},{id:`telephone`,name:`Telephone`},{id:`engine`,name:`Engine / Motor`},{id:`tools`,name:`Tools / Construction`},{id:`silence`,name:`Silence`}],CK={mapping:{Speech:`speech`,"Child speech, kid speaking":`speech`,Conversation:`speech`,"Narration, monologue":`speech`,Babbling:`speech`,Whispering:`speech`,"Speech synthesizer":`speech`,Humming:`speech`,Rapping:`speech`,Singing:`speech`,Choir:`speech`,"Child singing":`speech`,Shout:`scream`,Bellow:`scream`,Yell:`scream`,Screaming:`scream`,"Children shouting":`scream`,Whoop:`scream`,"Crying, sobbing":`crying`,"Baby cry, infant cry":`crying`,Whimper:`crying`,"Wail, moan":`crying`,Groan:`crying`,Laughter:`laughter`,"Baby laughter":`laughter`,Giggle:`laughter`,Snicker:`laughter`,"Belly laugh":`laughter`,"Chuckle, chortle":`laughter`,Music:`music`,"Musical instrument":`music`,Guitar:`music`,Piano:`music`,Drum:`music`,"Drum kit":`music`,"Violin, fiddle":`music`,Flute:`music`,Saxophone:`music`,Trumpet:`music`,Synthesizer:`music`,"Pop music":`music`,"Rock music":`music`,"Hip hop music":`music`,"Classical music":`music`,Jazz:`music`,"Electronic music":`music`,"Background music":`music`,Dog:`dog`,Bark:`dog`,Yip:`dog`,Howl:`dog`,"Bow-wow":`dog`,Growling:`dog`,"Whimper (dog)":`dog`,Cat:`cat`,Purr:`cat`,Meow:`cat`,Hiss:`cat`,Caterwaul:`cat`,Bird:`bird`,"Bird vocalization, bird call, bird song":`bird`,"Chirp, tweet":`bird`,Squawk:`bird`,Crow:`bird`,Owl:`bird`,"Pigeon, dove":`bird`,Animal:`animal`,"Domestic animals, pets":`animal`,"Livestock, farm animals, working animals":`animal`,Horse:`animal`,"Cattle, bovinae":`animal`,Pig:`animal`,Sheep:`animal`,Goat:`animal`,Frog:`animal`,Insect:`animal`,Cricket:`animal`,Alarm:`alarm`,"Alarm clock":`alarm`,"Smoke detector, smoke alarm":`alarm`,"Fire alarm":`alarm`,Buzzer:`alarm`,"Civil defense siren":`alarm`,"Car alarm":`alarm`,Siren:`siren`,"Police car (siren)":`siren`,"Ambulance (siren)":`siren`,"Fire engine, fire truck (siren)":`siren`,"Emergency vehicle":`siren`,Foghorn:`siren`,Doorbell:`doorbell`,"Ding-dong":`doorbell`,Knock:`doorbell`,Tap:`doorbell`,Glass:`glass_breaking`,Shatter:`glass_breaking`,"Chink, clink":`glass_breaking`,"Gunshot, gunfire":`gunshot`,"Machine gun":`gunshot`,Explosion:`gunshot`,Fireworks:`gunshot`,Firecracker:`gunshot`,"Artillery fire":`gunshot`,"Cap gun":`gunshot`,Boom:`gunshot`,Vehicle:`vehicle`,Car:`vehicle`,Truck:`vehicle`,Bus:`vehicle`,Motorcycle:`vehicle`,"Car passing by":`vehicle`,"Vehicle horn, car horn, honking":`vehicle`,"Traffic noise, roadway noise":`vehicle`,Train:`vehicle`,Aircraft:`vehicle`,Helicopter:`vehicle`,Bicycle:`vehicle`,Skateboard:`vehicle`,Fire:`fire`,Crackle:`fire`,Water:`water`,Rain:`water`,Raindrop:`water`,"Rain on surface":`water`,Stream:`water`,Waterfall:`water`,Ocean:`water`,"Waves, surf":`water`,"Splash, splatter":`water`,Wind:`wind`,Thunderstorm:`wind`,Thunder:`wind`,"Wind noise (microphone)":`wind`,"Rustling leaves":`wind`,Door:`door`,"Sliding door":`door`,Slam:`door`,"Cupboard open or close":`door`,"Walk, footsteps":`footsteps`,Run:`footsteps`,Shuffle:`footsteps`,Crowd:`crowd`,Chatter:`crowd`,Cheering:`crowd`,Applause:`crowd`,"Children playing":`crowd`,"Hubbub, speech noise, speech babble":`crowd`,Telephone:`telephone`,"Telephone bell ringing":`telephone`,Ringtone:`telephone`,"Telephone dialing, DTMF":`telephone`,"Busy signal":`telephone`,Engine:`engine`,"Engine starting":`engine`,Idling:`engine`,"Accelerating, revving, vroom":`engine`,"Light engine (high frequency)":`engine`,"Medium engine (mid frequency)":`engine`,"Heavy engine (low frequency)":`engine`,"Lawn mower":`engine`,Chainsaw:`engine`,Hammer:`tools`,Jackhammer:`tools`,Sawing:`tools`,"Power tool":`tools`,Drill:`tools`,Sanding:`tools`,Silence:`silence`},preserveOriginal:!1},wK={mapping:{speech:`speech`,child_speech:`speech`,conversation:`speech`,whispering:`speech`,singing:`speech`,humming:`speech`,shout:`scream`,yell:`scream`,screaming:`scream`,crying:`crying`,baby_crying:`crying`,sobbing:`crying`,laughter:`laughter`,baby_laughter:`laughter`,giggling:`laughter`,music:`music`,guitar:`music`,piano:`music`,drums:`music`,dog_bark:`dog`,dog_bow_wow:`dog`,dog_growling:`dog`,dog_howl:`dog`,cat_meow:`cat`,cat_purr:`cat`,cat_hiss:`cat`,bird:`bird`,bird_chirp:`bird`,bird_squawk:`bird`,animal:`animal`,horse:`animal`,cow_moo:`animal`,insect:`animal`,alarm:`alarm`,smoke_alarm:`alarm`,fire_alarm:`alarm`,car_alarm:`alarm`,siren:`siren`,police_siren:`siren`,ambulance_siren:`siren`,doorbell:`doorbell`,door_knock:`doorbell`,knocking:`doorbell`,glass_breaking:`glass_breaking`,glass_shatter:`glass_breaking`,gunshot:`gunshot`,explosion:`gunshot`,fireworks:`gunshot`,car:`vehicle`,truck:`vehicle`,motorcycle:`vehicle`,car_horn:`vehicle`,vehicle_horn:`vehicle`,traffic:`vehicle`,fire:`fire`,fire_crackle:`fire`,water:`water`,rain:`water`,ocean:`water`,splash:`water`,wind:`wind`,thunder:`wind`,thunderstorm:`wind`,door:`door`,door_slam:`door`,sliding_door:`door`,footsteps:`footsteps`,walking:`footsteps`,running:`footsteps`,crowd:`crowd`,chatter:`crowd`,cheering:`crowd`,applause:`crowd`,telephone_ring:`telephone`,ringtone:`telephone`,engine:`engine`,engine_starting:`engine`,lawn_mower:`engine`,chainsaw:`engine`,hammer:`tools`,jackhammer:`tools`,drill:`tools`,power_tool:`tools`,silence:`silence`},preserveOriginal:!1},TK=new Map;for(let[e,t]of Object.entries(CK.mapping))TK.set(e.toLowerCase(),t);for(let[e,t]of Object.entries(wK.mapping))TK.set(e.toLowerCase(),t);function tTe(e){return TK.get(e.toLowerCase())??null}function nTe(){return SK.map(e=>e.id)}var EK=NN();function DK(e){return RN(EK.swatches,EK.fallbacks,e)}function rTe(e){let t=e[0];if(t===void 0)throw Error(`display palette has no fallback colour`);return t}var iTe=rTe(EK.fallbacks);function aTe(e){return e.split(/[-_ ]/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var OK=new Map;function kK(e,t,n,r){OK.set(e,{kind:e,parentKind:null,level:`macro`,category:t,color:DK(e),iconId:n,labelKey:`eventKind.${e}`,label:r})}function AK(e,t,n,r,i){OK.set(e,{kind:e,parentKind:t,level:`sub`,category:n,color:DK(e),iconId:r,labelKey:`eventKind.${e}`,label:i})}kK(`motion`,`motion`,`motion`,`Motion`),kK(`audio`,`audio`,`audio`,`Audio`),kK(`person`,`detection`,`person`,`Person`),kK(`vehicle`,`detection`,`vehicle`,`Vehicle`),kK(`animal`,`detection`,`animal`,`Animal`),kK(`package`,`package`,`package`,`Package`),kK(`sensor`,`sensor`,`sensor`,`Sensor`),kK(`control`,`control`,`control`,`Control`);for(let[e,t]of Object.entries(ug.mapping))t!==`vehicle`&&t!==`animal`||OK.has(e)||AK(e,t,`detection`,e,aTe(e));AK(`package-delivered`,`package`,`package`,`package`,`Package delivered`),AK(`package-picked-up`,`package`,`package`,`package`,`Package picked up`),AK(`contact`,`sensor`,`sensor`,`door`,`Contact`),AK(`motion-sensor`,`sensor`,`sensor`,`pir`,`Motion sensor`),AK(`smoke`,`sensor`,`sensor`,`smoke`,`Smoke`),AK(`flood`,`sensor`,`sensor`,`water`,`Water leak`),AK(`gas`,`sensor`,`sensor`,`gas`,`Gas`),AK(`carbon-monoxide`,`sensor`,`sensor`,`smoke`,`Carbon monoxide`),AK(`vibration`,`sensor`,`sensor`,`vibration`,`Vibration`),AK(`tamper`,`sensor`,`sensor`,`tamper`,`Tamper`),AK(`presence`,`sensor`,`sensor`,`presence`,`Presence`),AK(`enum-sensor`,`sensor`,`sensor`,`generic`,`Sensor state`),AK(`device-event`,`sensor`,`sensor`,`button`,`Device event`),AK(`lock`,`control`,`control`,`lock`,`Lock`),AK(`cover`,`control`,`control`,`door`,`Cover`),AK(`switch`,`control`,`control`,`switch`,`Switch`),AK(`siren`,`control`,`control`,`siren`,`Siren`),AK(`button`,`control`,`control`,`button`,`Button`),AK(`doorbell`,`control`,`control`,`doorbell`,`Doorbell`),AK(`appliance-cycle`,`control`,`control`,`switch`,`Appliance cycle`);for(let e of SK){let t=`audio-${e.id}`;OK.has(t)||AK(t,`audio`,`audio`,t,e.name)}var jK=Object.freeze(Object.fromEntries(OK));function MK(e){return jK[e]}function oTe(e){return DK(e)}function sTe(e){let t=[];for(let n of Object.values(jK))n.parentKind===e&&t.push(n);return t}var NK=x({kind:u(),label:u(),parentKind:u().nullable()}),PK=x({videoClasses:C(NK),audioKinds:C(NK),labels:C(NK)});function FK(e,t,n){return{kind:e,label:t,parentKind:n}}function IK(){let e=Object.values(jK);return{videoClasses:e.filter(e=>e.category===`detection`).map(e=>FK(e.kind,e.label,e.parentKind)),audioKinds:e.filter(e=>e.category===`audio`&&e.level===`sub`).map(e=>FK(e.kind,e.label,e.parentKind)),labels:e.filter(e=>e.category===`sensor`||e.category===`control`).map(e=>FK(e.kind,e.label,e.parentKind))}}var cTe=Object.freeze(IK()),LK=S([`immediate`,`track-end`,`device-event`,`package-event`,`system-event`]),RK=S(`device-online.device-offline.device-disabled.device-enabled.device-battery-low.device-battery-normal.device-consumable-low.device-consumable-normal.stream-online.stream-offline.node-online.node-offline.node-restarting.node-updating.node-inference-unavailable.detection-blind.motion-noisy.motion-calm.package-llm-silent.package-llm-answered.recording-stalled.recording-healthy.recording-degraded.device-attention-required.device-attention-resolved.device-command.storage-location-low.storage-location-critical.storage-location-ok.storage-drain-progress.storage-drain-complete.addon-crash-loop.addon-update-available.server-update-available.wrapper-update-available.alarm-triggered.alarm-armed.alarm-disarmed.alarm-arming.alarm-arm-refused.alarm-pending.alarm-rearmed.alarm-sensor-bypass.alarm-check-failed.addon-updated.server-updated.export-completed.backup-completed.alert-critical.alert-error.alert-critical-resolved.rule-broken.rule-repaired.camera-online.camera-offline.camera-disabled.camera-enabled`.split(`.`)),zK=[`camera-online`,`camera-offline`,`camera-disabled`,`camera-enabled`],lTe=new Set(zK),uTe=RK.options.filter(e=>!lTe.has(e)),BK=[`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`],VK=[`device-battery-low`,`device-battery-normal`,`device-consumable-low`,`device-consumable-normal`],HK=[`device-consumable-low`,`device-consumable-normal`],UK=[`confirmed`,`already`,`unconfirmed`,`failed`],WK=[`user`,`addon`,`action`,`scheduler`,`composition`,`node`],GK=x({kinds:C(RK).min(1),deviceIds:C(r().int()).min(1).optional(),deviceTypes:C(u().min(1)).min(1).optional(),excludeDeviceIds:C(r().int()).min(1).optional(),nodeIds:C(u().min(1)).min(1).optional(),packageNames:C(u().min(1)).min(1).optional(),commandActions:C(u().min(1)).min(1).optional(),commandOutcomes:C(S(UK)).min(1).optional(),commandActorKinds:C(S(WK)).min(1).optional(),consumableLowPercent:r().int().min(1).max(95).optional()});function dTe(e){return e.consumableLowPercent??15}var KK=1440,fTe=[10,30,60],qK=x({days:C(r().int().min(0).max(6)).min(1),startMinute:r().int().min(0).max(1439),endMinute:r().int().min(0).max(1439)}),JK=x({windows:C(qK).min(1),timezone:u().optional(),invert:y().optional()}),YK=S([`instant`,`summary`]),pTe=S([`activation`,`deactivation`,`schedule`]),XK=S([`rule`,`section`]),ZK=a(`mode`,[x({mode:m(`instant`)}),x({mode:m(`summary`),schedule:JK,split:XK.optional()}),x({mode:m(`modes`),onActivation:y(),onDeactivation:y(),onSchedule:x({schedule:JK,grouping:XK}).optional()})]),QK=x({values:C(u().min(1)),maxDistance:r().int().min(0).max(3).default(1)}),$K=x({zoneId:u().optional(),className:u().optional(),op:S([`became-occupied`,`became-free`,`>=`,`<=`]).default(`became-occupied`),count:r().int().min(0).default(1),sustainSeconds:r().int().min(0).max(3600).default(15)}),eq=x({labels:C(u().min(1)).min(1).optional(),dbThreshold:r().min(-96).max(0).optional(),hitPercent:r().int().min(1).max(100).default(60),samplingSeconds:r().int().min(1).max(300).default(10),confirmHits:r().int().min(1).max(20).optional(),confirmWindowSec:r().int().min(1).max(60).optional()}),tq=S([`enter`,`exit`,`any`]),nq=S([`raised`,`cleared`]),rq=x({ids:C(u().min(1)).min(1),match:S([`any`,`all`]).optional()}),iq=u().min(1),aq=C(iq).max(4),oq=x({id:u().min(1).max(64),label:u().min(1).max(40),actionId:iq,icon:Ai.optional(),destructive:y().optional()}),sq=x({onActivation:aq.optional(),onDeactivation:aq.optional(),onTrigger:aq.optional(),onTriggerOff:aq.optional(),buttons:C(oq).max(8).optional()}),cq=x({deviceId:r().int(),states:C(u().min(1)).min(1)}),lq=x({sceneId:u().min(1),deviceId:r().int().optional(),requiredState:S([`matched`,`diverged`]),latched:y().optional()}),uq=x({deviceState:cq.optional(),scene:lq.optional(),devices:C(r()).optional(),devicesExclude:C(r()).min(1).optional(),classes:C(u().min(1)).optional(),classesExclude:C(u().min(1)).optional(),minConfidence:r().min(0).max(1).optional(),zones:rq.optional(),zonesExclude:C(u().min(1)).optional(),crossing:tq.optional(),labelEquals:C(u().min(1)).optional(),identities:C(u().min(1)).optional(),plates:QK.optional(),identitiesExclude:C(u().min(1)).optional(),minImportance:r().min(0).max(1).optional(),minDwellSeconds:r().min(0).optional(),source:S([`pipeline`,`onboard`,`sensor`,`audio`,`any`]).optional(),minLabelConfidence:r().min(0).max(1).optional(),eventTypeTokens:C(u().min(1)).optional(),sensorKinds:C(u().min(1)).optional(),sensorTransition:nq.optional(),packagePhase:S([`delivered`,`picked-up`,`both`]).optional(),systemEvent:GK.optional(),customZones:C(wV).optional(),occupancy:$K.optional(),audio:eq.optional()}),dq=x({targetId:u().min(1),params:h(u(),w()).optional()}),fq=S([`none`,`image`,`clip`,`gif`]),pq=x({template:x({title:u().max(500).optional(),body:u().max(2e3).optional()}).optional(),schedule:JK.optional(),priority:r().int().min(1).max(5).optional(),attachment:fq.optional(),actions:y().optional()}),mq=h(u(),pq),hq=S([`scene-boxes`,`crop`,`clean`,`none`]),gq=S([`cropped`,`full`,`boxed`]),_q=S([`mosaic`,`each`]),vq=x({image:hq.optional(),showTriggerZone:y().optional(),showSubjectPath:y().optional(),attach:S([`best`,`best-matching`,`keyFrame`,`none`]).optional(),frame:gq.optional(),zoneCrop:y().optional(),gif:y().optional(),clip:y().optional(),clipPreRollSec:r().int().min(0).max(30).optional(),clipPostRollSec:r().int().min(0).max(30).optional(),clipSpeed:r().min(1).max(8).optional(),profile:j.optional(),linkedCameras:_q.optional(),wakeSleepingCamera:y().optional()}),yq=S([`shared`,`per-class`]),bq=x({cooldownSec:r().int().min(0).max(86400).default(60),scope:S([`rule`,`rule-device`]).default(`rule-device`),granularity:yq.optional()}),xq=1e3,Sq=2e4,Cq=8e3,wq=x({op:S([`>=`,`>`,`<=`,`<`,`==`]),count:r().int().min(0).max(1e3)}),Tq=x({enabled:y().default(!1),profileId:u().optional(),prompt:u().max(1e3).optional(),expect:wq.optional(),timeoutMs:r().int().min(xq).max(Sq).default(Cq),onTimeout:S([`fire`,`suppress`]).default(`fire`),maxImagePx:r().int().min(64).max(2048).default(448)}),Eq=x({name:u().min(1).max(200),enabled:y().default(!0),delivery:LK,conditions:uq.default({}),schedule:JK.optional(),systemEventDelivery:ZK.optional(),targets:C(dq),targetUsers:C(u()).optional(),targetOverrides:mq.optional(),media:vq.default({}),throttle:bq.default({cooldownSec:60,scope:`rule-device`}),template:x({title:u().max(500).optional(),body:u().max(2e3).optional()}).optional(),priority:r().int().min(1).max(5).default(3),ownerUserId:u().optional(),snoozeAllowGlobal:y().optional(),snoozeOptions:C(r().int().min(1).max(KK)).max(4).optional(),actions:sq.optional(),confirm:Tq.optional(),groupingSec:r().int().min(5).max(60).optional(),groupWithinSec:r().int().min(0).max(300).optional(),askVerdict:y().optional(),tags:Td.optional()}),Dq=S([`event`,`summary`,`timelapse`,`calendar-events`]),Oq=x({kind:Dq,ruleId:u(),tags:C(u())}),kq=Eq.partial().extend({disabledTargetIds:C(u()).optional(),enabled:y().optional(),conditions:uq.optional(),media:vq.optional(),throttle:bq.optional(),priority:r().int().min(1).max(5).optional()}),Aq=[`waitForEnhancement`,`groupIdleSec`];function mTe(e){return Aq.some(t=>t===e)}var jq=[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`actions`,`confirm`,`groupingSec`,`waitForEnhancement`,`groupIdleSec`],Mq=S(jq),Nq=x({ruleId:u(),patch:kq,clear:C(Mq).optional()}),Pq=Eq.extend({id:u(),createdBy:u(),createdAt:r(),updatedAt:r(),disabledTargetIds:C(u()).default([])}),Fq=[`device-state`,`streams`,`battery`,`consumables`,`detection-blind`,`nodes`,`addons`,`addon-updates`,`updates`],Iq=S(Fq),Lq=x({id:Iq,status:S([`read`,`unavailable`]),items:r().int().nonnegative(),reason:u().optional()}),Rq=x({section:Iq.optional(),title:u(),text:u(),count:r().int().nonnegative()}),zq=x({empty:y(),count:r().int().nonnegative(),text:u(),sections:C(Lq),dropped:h(u(),r().int().nonnegative()),excludedGroups:C(u()),split:XK.optional(),rows:C(Rq).optional()}),Bq=x({recordId:u(),recordKind:S([`object-event`,`track`,`device-event`,`package-event`,`system-event`]),deviceId:r(),timestamp:r(),wouldFire:y(),failedCondition:u().optional(),className:u().optional(),label:u().optional()}),Vq=S([`detection`,`sensor`,`occupancy`,`sound`,`device-events`,`system`,`alarm`,`mixed`]),Hq=S([`detection`,`sensor`,`occupancy`,`sound`,`system`]),Uq=x({id:S([`appliance-cycle`]),kind:Vq,title:u(),body:u()}),Wq=S([`rule`,`timelapse`,`summary`]),Gq=S([`title`,`body`,`previewText`,`captionText`]),Kq=S([`subject`,`place`,`time`,`rule`,`occupancy`,`sound`,`sensor`,`system`,`digest`,`ai`]),qq=x({name:u().regex(/^\w+$/),label:u(),description:u().optional(),example:u(),group:Kq,families:C(Wq).min(1),fields:C(Gq).optional(),kinds:C(Hq).optional(),deliveries:C(LK).optional(),systemEventKinds:C(RK).optional(),systemEventDeliveries:C(YK).optional(),dynamic:x({prefix:m(`count_`),from:m(`classes`)}).optional()}),Jq=x({family:Wq,field:Gq,kind:Vq.optional(),delivery:LK.optional(),systemEventKinds:C(RK).optional(),systemEventDelivery:YK.optional()}),Yq=x({context:Jq,template:x({title:u().max(500).optional(),body:u().max(2e3).optional()})}),Xq=x({title:u().nullable(),body:u().nullable(),unknown:C(u())}),Zq=x({id:u(),group:S([`scope`,`class`,`zones`,`quality`,`label`,`schedule`,`device`,`package`,`occupancy`,`audio`,`system`]),label:u(),valueType:S([`deviceIdList`,`deviceIdExcludeList`,`stringList`,`number01`,`number`,`sourceSelect`,`zoneSelection`,`zoneIdList`,`schedule`,`plateMatcher`,`packagePhase`,`crossingSelect`,`sensorTransition`,`polygonDraw`,`occupancy`,`audio`,`deviceState`,`scene`,`systemEvent`]),operator:S([`in`,`notIn`,`anyOf`,`allOf`,`gte`,`fuzzyIn`,`withinSchedule`]),appliesTo:C(LK),phase:u(),description:u().optional(),options:C(x({value:u(),label:u(),hint:u().optional()})).readonly().optional()}),Qq=[{id:`systemEvent`,group:`system`,label:`System event`,valueType:`systemEvent`,options:[{value:`device-online`,label:`Device online`},{value:`device-offline`,label:`Device offline`},{value:`device-disabled`,label:`Device switched off`},{value:`device-enabled`,label:`Device switched on`},{value:`stream-online`,label:`Stream online`},{value:`stream-offline`,label:`Stream offline`},{value:`node-online`,label:`Node online`},{value:`node-offline`,label:`Node offline`},{value:`node-restarting`,label:`Node restarting`},{value:`node-updating`,label:`Node updating (restart imminent)`},{value:`node-inference-unavailable`,label:`Node has no usable inference device`},{value:`detection-blind`,label:`Camera detecting nothing`},{value:`motion-noisy`,label:`Camera motion constant, no subject`},{value:`motion-calm`,label:`Camera motion calm again`},{value:`package-llm-silent`,label:`Package confirm not answering`},{value:`package-llm-answered`,label:`Package confirm answering again`},{value:`recording-stalled`,label:`Recording stalled`},{value:`recording-healthy`,label:`Recording healthy again`},{value:`recording-degraded`,label:`Recording degraded (restart storm)`},{value:`device-attention-required`,label:`Device needs attention`},{value:`device-attention-resolved`,label:`Device attention resolved`},{value:`device-command`,label:`Command given to a device`},{value:`storage-location-low`,label:`Storage location low`},{value:`storage-location-critical`,label:`Storage location critical`},{value:`storage-location-ok`,label:`Storage location ok again`},{value:`storage-drain-progress`,label:`Storage drain progress`},{value:`storage-drain-complete`,label:`Storage drain complete`},{value:`addon-crash-loop`,label:`Addon stopped after repeated crashes`},{value:`addon-update-available`,label:`Addon update available`},{value:`server-update-available`,label:`Server update available`},{value:`wrapper-update-available`,label:`Container / app update available`},{value:`addon-updated`,label:`Addons updated`},{value:`server-updated`,label:`Server updated`},{value:`device-battery-low`,label:`Battery low`},{value:`device-battery-normal`,label:`Battery back to normal`},{value:`device-consumable-low`,label:`Consumable low`},{value:`device-consumable-normal`,label:`Consumable replaced`},{value:`export-completed`,label:`Export completed`},{value:`backup-completed`,label:`Backup completed`},{value:`alert-critical`,label:`Critical alert raised`},{value:`alert-error`,label:`Error alert raised`},{value:`alert-critical-resolved`,label:`Critical alert resolved`},{value:`rule-broken`,label:`Notification rule broken`},{value:`rule-repaired`,label:`Notification rule repaired`},{value:`alarm-arm-refused`,label:`Alarm arm refused`},{value:`alarm-check-failed`,label:`Alarm check failed (armed anyway)`},{value:`alarm-arming`,label:`Alarm arming (exit delay)`},{value:`alarm-armed`,label:`Alarm armed`},{value:`alarm-pending`,label:`Alarm entry delay started`},{value:`alarm-triggered`,label:`Alarm triggered`},{value:`alarm-rearmed`,label:`Alarm re-armed after siren`},{value:`alarm-sensor-bypass`,label:`Alarm sensor bypass`},{value:`alarm-disarmed`,label:`Alarm disarmed`}],operator:`in`,appliesTo:[`system-event`],phase:`P1`,description:`Infrastructure and update events. Device liveness covers EVERY device type — narrow it by device type (cameras only, say) and/or by device, node events by node id, and addon updates by package name.`},{id:`devices`,group:`scope`,label:`Devices`,valueType:`deviceIdList`,operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P1`,description:`Restrict the rule to these devices; absent = all devices. A sensor event matches either the SENSOR that fired or the camera it is attributed to, so a rule may name either one.`},{id:`devicesExclude`,group:`scope`,label:`Excluded devices`,valueType:`deviceIdExcludeList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P1`,description:`Every device except these. Judged on the same device ids as Devices: a sensor event is excluded by the SENSOR that fired or by the camera it is attributed to.`},{id:`classes`,group:`class`,label:`Object classes`,valueType:`stringList`,operator:`in`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`,description:`Any overlap with the detection class set passes.`},{id:`classesExclude`,group:`class`,label:`Excluded classes`,valueType:`stringList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`},{id:`minConfidence`,group:`quality`,label:`Minimum confidence`,valueType:`number01`,operator:`gte`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`},{id:`zones`,group:`zones`,label:`Zones`,valueType:`zoneSelection`,operator:`anyOf`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`,description:`The zones the subject must be in (included) or never in (excluded).`},{id:`zonesExclude`,group:`zones`,label:`Excluded zones`,valueType:`zoneIdList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`},{id:`crossing`,group:`zones`,label:`Zone crossing`,valueType:`crossingSelect`,options:[{value:``,label:`Entering`,hint:`Entries and ordinary movement; never an exit.`},{value:`exit`,label:`Leaving`,hint:`Only an exit from a zone.`},{value:`any`,label:`Entering or leaving`,hint:`Entries, exits and ordinary movement.`}],operator:`in`,appliesTo:[`immediate`],phase:`P1`,description:`Which way the subject crosses the zone.`},{id:`labelEquals`,group:`label`,label:`Label equals`,valueType:`stringList`,operator:`in`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Exact match on the collapsed label (identity / plate / subclass).`},{id:`identities`,group:`label`,label:`Known faces`,valueType:`stringList`,operator:`in`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Only recognised people. Selecting NOBODY means every identity in the face gallery; selecting some narrows to those. Matched on the gallery id, so renaming a person does not break the rule. On Immediate delivery the name must already be known when an event is written — choose Immediate, grouped to wait for it.`},{id:`plates`,group:`label`,label:`Known plates`,valueType:`plateMatcher`,operator:`fuzzyIn`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Only vehicles whose plate was read. Selecting NO plate means any readable plate; listed plates are matched Levenshtein-tolerantly, because OCR noise makes an exact match useless.`},{id:`identitiesExclude`,group:`label`,label:`Excluded faces`,valueType:`stringList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Veto by identity (mirror of Known faces, same gallery ids). A subject nobody recognised passes — there is nothing to exclude.`},{id:`minLabelConfidence`,group:`label`,label:`Minimum label confidence`,valueType:`number01`,operator:`gte`,appliesTo:[`track-end`],phase:`P1`,description:`Best identity/plate recognition match confidence [0,1] for the label the track carries at close (peak assigned-identity cosine / peak plate OCR score; the higher of the two when both were read). Distinct from detection confidence. Fails closed for a track that ended un-recognized.`},{id:`minImportance`,group:`quality`,label:`Minimum importance`,valueType:`number01`,operator:`gte`,appliesTo:[`track-end`],phase:`P1`,description:`Server-computed key-event importance [0,1]; track-end rules only (importance is scored at close). Fails when the record has none.`},{id:`minDwellSeconds`,group:`quality`,label:`Minimum dwell (seconds)`,valueType:`number`,operator:`gte`,appliesTo:[`track-end`],phase:`P1`,description:`Track lifespan in seconds (lastSeen − firstSeen); track-end rules only.`},{id:`source`,group:`scope`,label:`Detection source`,valueType:`sourceSelect`,options:[{value:`any`,label:`Any source`},{value:`pipeline`,label:`Pipeline`},{value:`onboard`,label:`Onboard (camera)`},{value:`sensor`,label:`Sensor`},{value:`audio`,label:`Audio marker`}],operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P1`,description:`pipeline / onboard / sensor / audio; a record with no stamped source counts as pipeline.`},{id:`deviceState`,group:`scope`,label:`Device state`,valueType:`deviceState`,operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P2`,description:`Only fire while another device is in one of the chosen states — the alarm armed, a switch on, a contact closed. A state that cannot be read does NOT fire.`},{id:`scene`,group:`scope`,label:`Scene state`,valueType:`scene`,operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P3`,description:`Only fire while a scene is matched or diverged.`},{id:`sensorKinds`,group:`device`,label:`Sensor kinds`,valueType:`stringList`,operator:`in`,appliesTo:[`device-event`],phase:`P1`,description:`Sensor/control taxonomy kinds (doorbell / contact / button / …) matched against the persisted device event.`},{id:`eventTypeTokens`,group:`device`,label:`Event-type tokens`,valueType:`stringList`,operator:`in`,appliesTo:[`device-event`],phase:`P1`,description:`Raw device event-type tokens (e.g. doorbell press / press_long) from the event-emitter slice; absent on doorbell-pulse / passive sensors.`},{id:`sensorTransition`,group:`device`,label:`Notify when`,valueType:`sensorTransition`,options:[{value:``,label:`When it starts and when it finishes`,hint:`Every change: the alert itself, and the return to normal.`},{value:`raised`,label:`Only when it starts`,hint:`Water detected, smoke, a contact opening — never the return to normal.`},{value:`cleared`,label:`Only when it finishes`,hint:`Back to dry, smoke gone, a contact closing — never the alert itself.`}],operator:`in`,appliesTo:[`device-event`],phase:`P2`,description:`Fire on one edge of a boolean sensor. Offered only when every chosen sensor kind raises and clears; a reading that cannot be placed still notifies.`},{id:`packagePhase`,group:`package`,label:`Package phase`,valueType:`packagePhase`,options:[{value:`delivered`,label:`Delivered`},{value:`picked-up`,label:`Picked up`},{value:`both`,label:`Both`}],operator:`in`,appliesTo:[`package-event`],phase:`P1`,description:`Delivered / picked-up / both.`},{id:`occupancy`,group:`occupancy`,label:`Occupancy`,valueType:`occupancy`,operator:`anyOf`,appliesTo:[`device-event`],phase:`P1`,description:`ZoneAnalytics occupancy edge (optionally zone/class-scoped): count crosses the threshold and holds for sustainSeconds. Fail-closed on a missing snapshot.`},{id:`audio`,group:`audio`,label:`Sound`,valueType:`audio`,operator:`anyOf`,appliesTo:[`immediate`],phase:`P2`,description:`Fires when at least hitPercent% of the samples in a samplingSeconds window are hits — a hit clears the dBFS floor AND carries one of the chosen sounds. Both filters are optional and independent, but naming NEITHER never matches: every sample would be a hit, so the engine refuses rather than notifying on silence. dBFS is negative-going (0 = full scale, -96 = silence).`},{id:`customZones`,group:`zones`,label:`Custom zones`,valueType:`polygonDraw`,operator:`anyOf`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`,description:`User-drawn polygons; a detection whose bbox overlaps any polygon matches.`},{id:`schedule`,group:`schedule`,label:`Schedule`,valueType:`schedule`,operator:`withinSchedule`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`,`system-event`],phase:`P1`,description:`Weekly activation windows (invertible); absent = always active.`}],$q=S([`pending`,`sent`,`dead`]),eJ=S([`object-event`,`track-end`,`device-event`,`package-event`,`system-event`]),tJ=x({className:u(),label:u().optional(),confidence:r().optional(),zones:C(u()),timestamp:r(),systemEvent:x({kind:RK,subject:u(),title:u(),body:u(),data:h(u(),w())}).optional()}),nJ=x({id:u(),ruleId:u(),ruleName:u(),delivery:LK,targetId:u(),deviceId:r(),recordKind:eJ,recordId:u(),trackId:u().optional(),status:$q,attempts:r().int(),createdAt:r(),updatedAt:r(),error:u().optional(),subject:tJ,title:u().optional(),body:u().optional(),artifactIds:C(u().min(1)).optional(),groupedInto:u().min(1).optional()}),rJ=x({ruleId:u().optional(),deviceId:r().optional(),status:$q.optional(),since:r().optional(),until:r().optional(),limit:r().int().min(1).max(500).default(100)}),iJ=x({ruleId:u(),lastAt:r(),status:$q,deviceId:r()}),aJ=x({runs:C(iJ),horizonMs:r().nonnegative().nullable()}),oJ=S([`rule`,`device`,`all`]),sJ=x({scope:oJ,ruleId:u().optional(),deviceId:r().int().optional(),classes:C(u().min(1)).min(1).optional(),durationMinutes:r().int().min(1).max(KK),global:y().optional(),summary:y().optional()}),cJ=x({id:u(),userId:u(),scope:oJ,ruleId:u().optional(),deviceId:r().int().optional(),classes:C(u().min(1)).min(1).optional(),startedAt:r(),expiresAt:r(),global:y(),summary:y(),digestSentAt:r().optional()}),hTe=x({snoozeId:u(),targetId:u(),ruleId:u(),ruleName:u(),deviceId:r().int(),count:r().int(),firstAt:r(),lastAt:r()}),lJ=3600,uJ=r().int().min(0).max(600),dJ=r().int().min(0).max(lJ),fJ=e=>new Set(e.map(e=>e.mode)).size===e.length,pJ=S([`rearmAfter`,`disableAfter`,`doNothing`]),mJ=x({mode:vy,exitDelaySec:uJ.optional(),entryDelaySec:uJ.optional(),triggeredDurationSec:dJ.optional(),postTriggeredAction:pJ.optional(),schedule:JK.optional(),notifyDuringEntryDelay:y().optional(),notifySensorRewatched:y().optional(),notifySensorIgnored:y().optional()}),gTe=C(mJ).max(8).refine(fJ,{message:`modeDelays: at most one entry per arm mode`}),hJ=x({mode:vy,exitDelaySec:uJ.nullable().optional(),entryDelaySec:uJ.nullable().optional(),triggeredDurationSec:dJ.nullable().optional(),postTriggeredAction:pJ.nullable().optional(),schedule:JK.nullable().optional(),notifyDuringEntryDelay:y().nullable().optional(),notifySensorRewatched:y().nullable().optional(),notifySensorIgnored:y().nullable().optional()}),_Te=C(hJ).max(8).refine(fJ,{message:`modeDelays: at most one edit per arm mode`}),gJ=x({mode:vy,deviceId:r().int().positive(),nonBlocking:y()}),_J=x({mode:vy,deviceId:r().int().positive(),blocking:y()}),vJ=x({mode:vy,deviceId:r().int().positive(),secureOnArm:y()}),yJ=x({mode:vy,deviceIds:C(r().int()).max(200)}),bJ=yJ,xJ=yJ,SJ=yJ,CJ=C(bJ).max(8).refine(fJ,{message:`nonBlocking: at most one list per arm mode`}),wJ=C(xJ).max(8).refine(fJ,{message:`blocking: at most one list per arm mode`}),TJ=C(SJ).max(8).refine(fJ,{message:`secureOnArmOff: at most one list per arm mode`}),EJ=x({exitDelaySec:uJ,entryDelaySec:uJ,triggeredDurationSec:dJ,postTriggeredAction:pJ.optional(),announceArm:y().optional(),announceTargets:C(u().min(1)).max(16),nonBlocking:CJ.default([]),blocking:wJ.default([]),secureOnArmOff:TJ.default([]),modeDelays:gTe.default([])}),DJ=x({id:u().min(1).max(64),name:u().min(1).max(64),isDefault:y()}),OJ=x({activeId:u().min(1),items:C(DJ).min(1)}),kJ=x({name:u().min(1).max(64),cloneFromId:u().min(1).max(64).optional()}),AJ=x({id:u().min(1).max(64),name:u().min(1).max(64)}),jJ=x({id:u().min(1).max(64)}),MJ=EJ.extend({nonBlocking:CJ,blocking:wJ,secureOnArmOff:TJ,modeDelays:_Te,nonBlockingEdit:gJ,blockingEdit:_J,secureOnArmEdit:vJ}).partial().refine(e=>e.nonBlocking===void 0||e.nonBlockingEdit===void 0,{message:`nonBlocking and nonBlockingEdit are exclusive — send the whole lists or one edit`}).refine(e=>e.blocking===void 0||e.blockingEdit===void 0,{message:`blocking and blockingEdit are exclusive — send the whole lists or one edit`}).refine(e=>e.secureOnArmOff===void 0||e.secureOnArmEdit===void 0,{message:`secureOnArmOff and secureOnArmEdit are exclusive — send the whole lists or one edit`}),NJ=S([`muted`,`detection-off`,`offline`]),PJ=x({deviceId:r().int(),reason:NJ}),FJ=x({mode:vy,ruleCount:r().int().min(0),allDevices:y(),deviceIds:C(r().int()),allDevicesExcept:C(r().int()).default([]),skippedDevices:C(PJ).default([])}),vTe=x({deviceId:r().int(),name:u(),state:u(),blocking:y()}),yTe=x({deviceId:r().int(),name:u(),phase:S([`open`,`closed`])}),bTe=x({mode:vy,devices:C(vTe),unknown:C(r().int())}),xTe=x({ruleId:u(),ruleName:u(),deviceId:r().int(),name:u(),since:r(),dropped:r().int().min(0)}),STe=x({state:_y,targetMode:vy.nullable(),availableModes:C(vy),openings:C(bTe),exclusions:C(yTe),bypassedInputs:C(xTe).default([])}),IJ=x({deviceId:r().int().nullable(),settings:EJ,profiles:OJ.optional(),coverage:C(FJ),live:STe.optional()}),LJ=S([`open`,`closed`,`unknown`,`not-opening`]),RJ=x({deviceId:r().int().positive(),reading:LJ,state:u().nullable(),unknownWhy:S([`read-failed`,`unknown-word`]).nullable(),online:y().nullable(),controllable:y().default(!1)}),zJ=x({deviceIds:C(r().int().positive()).max(500)}),BJ=x({sensors:C(RJ),readAt:r().int().nonnegative()}),VJ=x({deviceId:r().int().nonnegative().optional(),seconds:r().min(0).max(60),profile:j.optional(),ruleId:u(),ruleName:u(),reason:S([`window`,`occupancy`])}),HJ=x({rulesLoaded:y(),asks:C(VJ).readonly()}),UJ={name:`notification-rules`,scope:`system`,mode:`singleton`,methods:{listRules:D(x({}),x({rules:C(Pq)}),{auth:`admin`}),getRule:D(x({ruleId:u()}),x({rule:Pq.nullable()}),{auth:`admin`}),createRule:D(x({rule:Eq}),x({rule:Pq}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateRule:D(Nq,x({rule:Pq}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteRule:D(x({ruleId:u()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setRuleEnabled:D(x({ruleId:u(),enabled:y()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),listRuleTags:D(x({}),x({rules:C(Oq)}),{kind:`query`,auth:`admin`}),setRuleTags:D(x({kind:Dq,ruleId:u(),tags:Td}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getClipRetentionAsks:D(x({}),HJ,{auth:`admin`}),listDeviceMutes:D(x({}),x({mutedDeviceIds:C(r().int()).readonly()}),{auth:`admin`}),setDeviceMuted:D(x({deviceId:r().int(),muted:y()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),testRule:D(x({rule:Eq,lookbackMinutes:r().int().min(1).max(1440).default(60)}),x({results:C(Bq)}),{kind:`mutation`,auth:`admin`}),previewStateSummary:D(x({rule:Eq}),zq,{kind:`mutation`,auth:`admin`,access:`view`}),getConditionCatalog:D(x({}),x({catalog:C(Zq),taxonomy:PK.optional()})),getTemplateCatalog:D(x({}),x({vars:C(qq),defaults:C(Uq)})),previewTemplate:D(Yq,Xq,{kind:`mutation`,access:`view`}),getHistory:D(x({filter:rJ.default({limit:100})}),x({entries:C(nJ)}),{auth:`admin`}),getRuleLastRuns:D(x({}),aJ,{auth:`admin`}),resolveArtifactUrl:D(x({artifactId:u().min(1)}),x({url:u().nullable()}),{auth:`admin`}),listSnoozes:D(x({}),x({snoozes:C(cJ)}),{caller:`required`}),createSnooze:D(x({snooze:sJ}),x({snooze:cJ}),{kind:`mutation`,caller:`required`}),cancelSnooze:D(x({snoozeId:u()}),x({success:m(!0)}),{kind:`mutation`,caller:`required`}),getAlarmConfig:D(x({}),IJ,{auth:`admin`}),setAlarmConfig:D(x({patch:MJ}),IJ,{kind:`mutation`,auth:`admin`}),createAlarmProfile:D(kJ,IJ,{kind:`mutation`,auth:`admin`}),renameAlarmProfile:D(AJ,IJ,{kind:`mutation`,auth:`admin`}),deleteAlarmProfile:D(jJ,IJ,{kind:`mutation`,auth:`admin`}),activateAlarmProfile:D(jJ,IJ,{kind:`mutation`,auth:`admin`}),getAlarmSensors:D(zJ,BJ,{auth:`admin`})},vocabulary:{notOperatorFacing:`notification rules — authored on their own page`}},CTe=S([`min`,`low`,`normal`,`high`]),wTe=x({id:u().min(1),title:u().min(1),uri:i().optional(),destructive:y().optional()}),TTe=x({image:y(),priority:y(),data:y(),actions:y(),recipients:y()}),WJ=x({lastSentAt:r(),lastError:u().nullable(),queueDepth:r().int().nonnegative().meta(A(`count`)),supports:TTe}),ETe=x({deviceId:r().int().nonnegative(),title:u().optional(),body:u().min(1),image:u().optional(),priority:CTe.optional(),channel:u().optional(),recipients:C(u()).optional(),actions:C(wTe).optional(),data:h(u(),w()).optional()}),DTe=x({notificationId:u(),acceptedAt:r()}),GJ={name:`notifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Notifier],methods:{send:D(ETe,DTe,{kind:`mutation`,auth:`admin`,actions:[{id:`notifier.send`,label:L(`Send a notification`,`Invia una notifica`),phrase:L(`Send “{body}” through {device}`,`Invia «{body}» tramite {device}`),icon:`send`,openArgs:[{key:`title`,label:L(`Title`,`Titolo`),offer:{kind:`text`},optional:!0},{key:`body`,label:L(`Message`,`Messaggio`),offer:{kind:`text`}},{key:`priority`,label:L(`Priority`,`Priorità`),offer:{kind:`enum`,values:[{value:`min`,label:L(`Minimal`,`Minima`)},{value:`low`,label:L(`Low`,`Bassa`)},{value:`normal`,label:L(`Normal`,`Normale`)},{value:`high`,label:L(`High`,`Alta`)}]},optional:!0}]}]}),cancel:D(x({deviceId:r().int().nonnegative(),notificationId:u().min(1)}),v(),{kind:`mutation`,auth:`admin`})},events:{onSent:{data:x({deviceId:r(),notificationId:u(),success:y(),error:u().nullable(),acceptedAt:r()}),notOperatorFacing:`a delivery receipt of a send this system made — not a fact about the world`}},status:{schema:WJ,kind:`command-driven`},runtimeState:WJ,durability:`session`,history:`none`,vocabulary:{noun:L(`Notifier`,`Notificatore`),order:2110}},KJ=x({value:r().nullable().meta(A(`device`)),lastFetchedAt:r()}),qJ={name:`numeric-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:KJ,kind:`push`},runtimeState:KJ,durability:`restored`,history:{fields:{value:{kind:`gauge`,minIntervalMs:3e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Sensor`,`Sensore`),order:5150,state:[{kind:`numeric`,field:`value`,quantity:L(`the reading`,`il valore`),label:L(`Reading`,`Valore`),icon:`gauge`}]}},JJ=x({integrationId:u(),displayName:u(),requestedScopes:C(Yf),allowedRedirectPrefixes:C(u()).min(1),allowedPrivateHostPaths:C(u()).optional(),requiresPkce:y().optional(),hubUrl:u().optional(),refreshTokenTtlSec:g([r().int().positive(),m(`never`)]).optional(),instances:C(x({id:u(),displayName:u()})).optional()}),YJ={name:`oauth-integration`,scope:`system`,mode:`collection`,internal:!0,methods:{getDescriptor:D(v(),JJ,{auth:`admin`})},vocabulary:{notOperatorFacing:k.IDENTITY}},XJ=S([`text`,`timestamp`,`watermark`]),ZJ=S([`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`custom`]),QJ=x({id:u(),kind:XJ,enabled:y(),text:u().optional(),position:ZJ.optional(),availablePositions:C(ZJ).readonly(),readOnly:y().optional(),maxCharacters:r().int().positive().optional()}),$J=x({overlays:C(QJ).readonly()}),eY=x({enabled:y().optional(),text:u().optional(),position:ZJ.optional()}).partial(),tY={name:`osd`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],methods:{setOverlay:D(x({deviceId:r(),overlayId:u(),patch:eY}),v(),{kind:`mutation`,auth:`admin`})},events:{onStatusChanged:{data:x({deviceId:r(),status:$J}),notOperatorFacing:`an overlay setting changed — configuration, not a happening`}},status:{schema:$J,kind:`command-driven`},settings:{bindings:[{kind:`array`,statusPath:`overlays`,idField:`id`,method:`setOverlay`,idArg:`overlayId`,patchArg:`patch`,sectionId:`osd`,sectionTitle:`Video overlays`,itemFields:{enabled:{label:e=>`${String(e.id)} enabled`,kind:`boolean`},text:{label:e=>`${String(e.id)} text`,kind:`text`,when:e=>e.kind!==`timestamp`&&!e.readOnly},position:{label:e=>`${String(e.id)} position`,kind:`select`,options:e=>e.availablePositions??[],when:e=>Array.isArray(e.availablePositions)&&e.availablePositions.length>0}}}]},vocabulary:{noun:L(`On-screen text`,`Testo in sovrimpressione`),order:3190}},nY=1024,rY=x({id:u().min(1).max(64),name:u().min(1).max(64),text:u().max(nY).default(``)}),iY=a(`kind`,[x({kind:m(`none`)}),x({kind:m(`static`),text:u().max(nY)}),x({kind:m(`template`),templateId:u().min(1).max(64)})]),aY=x({enabled:y().default(!0),source:iY,schedule:JK.optional(),conditions:uq.optional()}),oY=x({slotId:u(),kind:XJ,readOnly:y(),cameraEnabled:y(),cameraText:u().optional(),binding:aY.nullable()}),sY=S([`written`,`unchanged`,`gated`,`unreadable`,`disabled`,`unbound`,`failed`]),cY=x({slotId:u(),outcome:sY,text:u(),reason:u().optional()}),lY=x({ok:y(),text:u(),notes:C(u())}),uY={name:`osd-manager`,scope:`system`,mode:`singleton`,methods:{getDeviceOsd:D(x({deviceId:r().int()}),x({supported:y(),slots:C(oY)}),{auth:`admin`}),getConditionSupport:D(x({}),x({supported:C(u()),catalog:C(Zq)}),{auth:`admin`}),setSlotBinding:D(x({deviceId:r().int(),slotId:u().min(1),binding:aY}),x({slot:oY,render:cY}),{kind:`mutation`,auth:`admin`}),clearSlotBinding:D(x({deviceId:r().int(),slotId:u().min(1)}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setSlotCameraEnabled:D(x({deviceId:r().int(),slotId:u().min(1),enabled:y()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),copyDeviceConfiguration:D(x({sourceDeviceId:r().int(),targetDeviceId:r().int()}),x({copied:r().int().nonnegative(),skipped:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),previewSlot:D(x({deviceId:r().int(),slotId:u().min(1),binding:aY.optional()}),cY,{kind:`mutation`,auth:`admin`}),previewTemplate:D(x({deviceId:r().int(),text:u().max(nY)}),lY,{kind:`mutation`,auth:`admin`}),renderDevice:D(x({deviceId:r().int()}),x({results:C(cY)}),{kind:`mutation`,auth:`admin`}),listTemplates:D(x({}),x({templates:C(rY)}),{auth:`admin`}),upsertTemplate:D(x({template:rY}),x({template:rY}),{kind:`mutation`,auth:`admin`}),deleteTemplate:D(x({templateId:u().min(1).max(64)}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.PIPELINE}},dY=1e4,OTe=S([`normal`,`offline`,`on_batteries`]),fY=r().int().min(4).max(200),pY=fY.meta(ig({quantity:`mass`,unit:`g`})),mY=x({foodLevel:r().nullable().meta(A(`none`)),bowlFood:r().nullable().meta(A(`mass`)),eating:y(),supportsMarkRefilled:y(),food1:r().nullable().meta(A(`none`)),food2:r().nullable().meta(A(`none`)),lowFood:y(),batteryPower:r().min(0).max(100).nullable().meta(A(`percentage`)),powerSource:S([`mains`,`battery`]).nullable(),desiccantLeftDays:r().nullable().meta(A(`duration`)),feeding:y(),status:OTe.nullable(),error:u().nullable(),errorCode:r().nullable().meta(A(`none`)),isDualHopper:y(),childLock:y(),indicatorLight:y(),feedSound:y(),volume:r().meta(A(`none`)),lastFeedGrams:fY.nullable(),lastFeedHopper1:fY.nullable(),lastFeedHopper2:fY.nullable(),lastFetchedAt:r()}),hY={name:`pet-feeder`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.PetFeeder],methods:{feed:D(x({deviceId:r().int().nonnegative(),grams:pY.optional(),hopper1:pY.optional(),hopper2:pY.optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feed`,label:L(`Feed`,`Dai da mangiare`),phrase:L(`Dispense {grams} from {device}`,`Eroga {grams} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:dY},openArgs:[{key:`grams`,label:L(`Grams`,`Grammi`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]},{id:`petFeeder.feedHoppers`,label:L(`Feed from both hoppers`,`Eroga da entrambi i serbatoi`),phrase:L(`Dispense {hopper1} and {hopper2} from {device}`,`Eroga {hopper1} e {hopper2} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:dY},openArgs:[{key:`hopper1`,label:L(`Hopper 1`,`Serbatoio 1`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0},{key:`hopper2`,label:L(`Hopper 2`,`Serbatoio 2`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]}]}),cancelFeed:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.cancelFeed`,label:L(`Cancel feeding`,`Annulla l’erogazione`),phrase:L(`Cancel the feeding on {device}`,`Annulla l’erogazione di {device}`),icon:`circle-x`}]}),callPet:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.callPet`,label:L(`Call pet`,`Chiama l’animale`),phrase:L(`Call your pet with {device}`,`Chiama l’animale con {device}`),icon:`megaphone`}]}),playSound:D(x({deviceId:r().int().nonnegative(),soundId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.playSound`,label:L(`Play sound`,`Riproduci un suono`),phrase:L(`Play sound {soundId} on {device}`,`Riproduci il suono {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:L(`Sound`,`Suono`),offer:{kind:`number`,min:0,step:1}}]}]}),resetDesiccant:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.resetDesiccant`,label:L(`Desiccant replaced`,`Essiccante sostituito`),phrase:L(`Mark the desiccant of {device} as replaced`,`Segna come sostituito l’essiccante di {device}`),icon:`refresh-cw`}]}),markFoodReplenished:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.foodReplenished`,label:L(`Food refilled`,`Cibo ricaricato`),phrase:L(`Mark {device} as refilled`,`Segna {device} come ricaricato`),icon:`package`}]}),setChildLock:D(x({deviceId:r().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.childLockOn`,effect:{field:`childLock`,value:!0},label:L(`Child lock on`,`Blocco bambini attivo`),phrase:L(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`petFeeder.childLockOff`,effect:{field:`childLock`,value:!1},label:L(`Child lock off`,`Blocco bambini spento`),phrase:L(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setIndicatorLight:D(x({deviceId:r().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.lightOn`,effect:{field:`indicatorLight`,value:!0},label:L(`Indicator light on`,`Spia accesa`),phrase:L(`Turn on the indicator light of {device}`,`Accendi la spia di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`petFeeder.lightOff`,effect:{field:`indicatorLight`,value:!1},label:L(`Indicator light off`,`Spia spenta`),phrase:L(`Turn off the indicator light of {device}`,`Spegni la spia di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setFeedSound:D(x({deviceId:r().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feedSoundOn`,effect:{field:`feedSound`,value:!0},label:L(`Feeding sound on`,`Suono di erogazione attivo`),phrase:L(`Turn on the feeding sound of {device}`,`Attiva il suono di erogazione di {device}`),icon:`volume-2`,args:{on:!0}},{id:`petFeeder.feedSoundOff`,effect:{field:`feedSound`,value:!1},label:L(`Feeding sound off`,`Suono di erogazione spento`),phrase:L(`Turn off the feeding sound of {device}`,`Disattiva il suono di erogazione di {device}`),icon:`volume-x`,args:{on:!1}}]}),setVolume:D(x({deviceId:r().int().nonnegative(),level:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.volume`,effect:{field:`volume`,fromArg:`level`},label:L(`Set volume`,`Imposta il volume`),phrase:L(`Set the volume of {device} to {level}`,`Imposta il volume di {device} a {level}`),icon:`volume-2`,openArgs:[{key:`level`,label:L(`Volume`,`Volume`),offer:{kind:`number`,min:0,step:1}}]}]})},status:{schema:mY,kind:`poll`},runtimeState:mY,durability:`session`,history:{fields:{feeding:{kind:`boolean`},eating:{kind:`boolean`},foodLevel:{kind:`gauge`},bowlFood:{kind:`gauge`},food1:{kind:`gauge`},food2:{kind:`gauge`},batteryPower:{kind:`gauge`,unit:`%`,deadband:2},desiccantLeftDays:{kind:`gauge`,unit:`s`}}},vocabulary:{noun:L(`Pet feeder`,`Distributore di cibo`),order:2030,state:[{kind:`boolean`,field:`lowFood`,label:L(`Food low`,`Cibo in esaurimento`),whenTrue:L(`When {device} runs low on food`,`Quando il cibo di {device} sta finendo`),whenFalse:L(`When {device} has enough food again`,`Quando {device} ha di nuovo cibo a sufficienza`),icon:`package`},{kind:`boolean`,field:`feeding`,label:L(`Feeding`,`In erogazione`),whenTrue:L(`When {device} starts feeding`,`Quando {device} inizia a erogare`),whenFalse:L(`When {device} finishes feeding`,`Quando {device} finisce di erogare`),icon:`paw-print`},{kind:`numeric`,field:`desiccantLeftDays`,quantity:L(`the desiccant life`,`la durata dell’essiccante`),label:L(`Desiccant`,`Essiccante`),unit:`d`,icon:`calendar-clock`}]}},gY=x({waterLevel:r().min(0).max(100).nullable().meta(A(`percentage`)),waterVolume:r().min(0).nullable().meta(A(`volume`)),empty:y().nullable(),pumpRunning:y().nullable(),error:u().nullable(),lastFetchedAt:r()}),_Y=`water`;function kTe(e){let t=e.waterLevel!==null||e.empty===null?null:e.empty?`empty`:`ok`;return{key:_Y,label:`Water`,level:e.waterLevel,status:t,kind:`supply`,form:`tank`,lastResetAt:null,resettable:!1}}var ATe=r().int().nonnegative(),vY={name:`pet-fountain`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.PetFountain],power:{kind:`field`,field:`pumpRunning`,set:`setPump`},methods:{setPump:D(x({deviceId:ATe,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFountain.pumpOn`,effect:{field:`pumpRunning`,value:!0},label:L(`Pump on`,`Pompa accesa`),phrase:L(`Start the pump of {device}`,`Avvia la pompa di {device}`),icon:`play`,args:{on:!0}},{id:`petFountain.pumpOff`,effect:{field:`pumpRunning`,value:!1},label:L(`Pump off`,`Pompa spenta`),phrase:L(`Stop the pump of {device}`,`Ferma la pompa di {device}`),icon:`square`,args:{on:!1}}]})},status:{schema:gY,kind:`push`},runtimeState:gY,durability:`session`,history:{fields:{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}}},vocabulary:{noun:L(`Pet fountain`,`Fontana per animali`),order:2040,state:[{kind:`boolean`,field:`empty`,label:L(`Tank empty`,`Serbatoio vuoto`),whenTrue:L(`When the tank of {device} is empty`,`Quando il serbatoio di {device} è vuoto`),whenFalse:L(`When the tank of {device} is refilled`,`Quando il serbatoio di {device} viene riempito`),icon:`droplet`},{kind:`numeric`,field:`waterLevel`,quantity:L(`the water level`,`il livello dell’acqua`),label:L(`Water level`,`Livello dell’acqua`),unit:`%`,icon:`droplets`}]}},jTe=S(ff),yY={min:1,max:8},bY=S([`intel-core-ultra`,`intel-n-series`,`apple-m-base`,`apple-m-pro`,`amd-phoenix`,`nvidia-gpu`,`unknown`]),xY=S([`intel-npu`,`intel-igpu`,`amd-igpu`,`amd-npu`,`nvidia-gpu`,`x86-cpu`,`arm-cpu`,`apple-ane`,`coral`]),SY=a(`kind`,[x({kind:m(`capacity`),sessions:r(),minSessions:r()}),x({kind:m(`tie-faster`),over:u(),recallDelta:r()}),x({kind:m(`stepped-down`),from:u(),to:u(),limitedBy:u()}),x({kind:m(`no-fit-lightest`),sessions:r(),minSessions:r()}),x({kind:m(`derived-latency`),modelId:u()}),x({kind:m(`cpu-device`)}),x({kind:m(`device-disabled`)}),x({kind:m(`device-unavailable`)}),x({kind:m(`node-offline`)}),x({kind:m(`no-hardware-facts`)}),x({kind:m(`no-measured-data`),hardwareClass:bY}),x({kind:m(`no-family-build`),format:jTe}),x({kind:m(`kept-custom-pin`),modelId:u(),deviceKey:u()})]),CY=S([`custom-pin`]),wY=a(`kind`,[x({kind:m(`table`)}),x({kind:m(`node-benchmark`),resultId:u(),measuredAtMs:r()}),x({kind:m(`estimated`),estimatedFrom:bY})]),TY=x({modelId:u(),p50Ms:r(),fps:r(),measured:y(),source:wY.optional(),estimatedFrom:bY.optional(),capacitySessions:r(),personRecall:r()}),EY=x({deviceKey:u(),accelerator:xY.nullable(),enabled:y(),available:y(),chosen:TY.nullable(),kept:CY.optional(),reasons:C(SY).readonly()}),DY=x({nodeId:u(),reachable:y(),hardwareClass:bY.nullable(),cpuModel:u().nullable(),skipped:y(),acceleratorModelId:u().nullable(),devices:C(EY).readonly(),reasons:C(SY).readonly()}),OY=x({stepId:u(),before:u().nullable(),after:u().nullable()}),kY=x({nodeId:u(),deviceKey:u(),madeExplicit:y(),modelPins:C(OY).readonly(),thresholds:C(x({stepId:u(),keys:C(u()).readonly()})).readonly()}),AY=a(`kind`,[x({kind:m(`custom-pin-kept`),nodeId:u(),deviceKey:u(),modelId:u()}),x({kind:m(`custom-registry-unreadable`),error:u()})]),jY=x({headroom:r().min(.3).max(.5).default(.4),minSessionsPerDevice:r().int().min(yY.min).max(yY.max).default(2)}),MY=x({planHash:u(),family:m(`yolov9`),headroom:r(),minSessionsPerDevice:r(),cameraFps:r(),generatedAt:r(),nodes:C(DY).readonly(),nodeChanges:C(kY).readonly(),warnings:C(AY).readonly()}),NY=x({planHash:u(),headroom:r().min(.3).max(.5).default(.4),minSessionsPerDevice:r().int().min(yY.min).max(yY.max).default(2)}),PY=x({phase:S([`download`,`node-models`,`redispatch`]),ok:y(),detail:u()}),FY=a(`kind`,[x({kind:m(`applied`),planHash:u(),phases:C(PY).readonly()}),x({kind:m(`aborted`),phases:C(PY).readonly()}),x({kind:m(`stale`),plan:MY}),x({kind:m(`refused`),reason:S([`apply-in-progress`])})]),IY=S([`least-loaded`,`share`]),LY=`share`,MTe=`sessionPlacement`;function NTe(e){let t=IY.safeParse(e);return t.success?t.data:LY}var RY=x({nodes:h(u(),r().positive()).default({}),devices:h(u(),h(u(),r().positive())).default({})}),zY=x({windowMs:r().int().min(6e4).max(1440*60*1e3).default(3600*1e3)}),BY=x({deviceKey:u(),sessionsNow:r(),sessionsStarted:r(),observedShare:r().nullable()}),VY=x({nodeId:u(),sessionsNow:r(),sessionsStarted:r(),observedShare:r().nullable(),peakSessions:r(),yieldsAway:r(),devices:C(BY).readonly()}),HY=x({deviceId:r(),deviceKey:u(),reason:S([`disabled`,`absent`])}),UY=x({policy:IY,windowMs:r(),observedForMs:r(),sessionsNow:r(),clusterPeakSessions:r(),nodes:C(VY).readonly(),stalePins:C(HY).readonly()}),WY=S([`hardware`,`benchmark`]),GY=S([`no-benchmark-results`,`partial-benchmark-results`]),KY=x({headroom:r().min(.3).max(.5).default(.4),source:WY.default(`hardware`)}),qY=x({deviceKey:u(),share:r(),modelId:u().nullable(),fps:r().nullable(),measured:y(),suggestedMaxSessions:r().nullable()}),JY=x({nodeId:u(),share:r().nullable(),capacitySessions:r(),devices:C(qY).readonly(),skippedReason:u().nullable(),capacitySource:WY.nullable(),capacityFallback:GY.nullable()}),YY=x({headroom:r(),source:WY,cameraFps:r(),minSessionsPerDevice:r(),nodes:C(JY).readonly()}),XY=S([`hardware`,`benchmark`,`manual`]),ZY=`benchmark`;function QY(e){return e!==`manual`}var PTe=.4,FTe=`shareSource`;function ITe(e){if(e===`auto`)return`hardware`;let t=XY.safeParse(e);return t.success?t.data:ZY}var $Y=x({source:XY}),LTe=x({nodes:h(u(),r()),devices:h(u(),h(u(),r()))}),eX=x({deviceKey:u(),eligible:y(),configuredPct:r(),effectivePct:r()}),tX=x({nodeId:u(),eligible:y(),configuredPct:r(),effectivePct:r(),capacitySource:WY.nullable(),capacityFallback:GY.nullable(),devices:C(eX).readonly()}),nX=x({source:XY,policy:IY,autoPending:y(),computedAt:r().nullable(),trigger:u().nullable(),nodes:C(tX).readonly(),nodeWeights:h(u(),r()),deviceWeights:h(u(),h(u(),r()))}),rX=[`motion-without-detections`,`detections-under-floor`,`inference-too-slow`,`frames-shed`,`inference-device-unusable`],iX=S(rX),aX=S([`info`,`warning`,`critical`]),oX=a(`type`,[x({type:m(`camera`),deviceId:r()}),x({type:m(`node`),nodeId:u()}),x({type:m(`inference-device`),nodeId:u(),deviceKey:u()})]),sX=x({id:u(),kind:iX,severity:aX,subject:oX,what:u(),evidence:h(u(),r().nullable()),action:u()}),cX=x({source:u(),entries:r().nullable()}),lX=x({nodeId:u(),sessionsNow:r(),unusableDevices:C(u()).readonly(),devices:C(x({deviceKey:u(),sessionsNow:r(),usable:y()})).readonly()}),uX=x({deviceId:r(),nativeCropMissesSincePreviousTick:r().nullable()}),dX=x({generatedAt:r(),tickMs:r(),camerasSeen:r().nullable(),findings:C(sX).readonly(),cameraSignals:C(uX).readonly(),nodes:C(lX).readonly(),sources:C(cX).readonly(),notCovered:C(u()).readonly()}),fX=x({history:r().int().min(1).max(24).default(1)}),pX=x({latest:dX.nullable(),previous:C(dX).readonly()}),RTe=x({engine:GU.optional(),steps:C(RU).readonly(),audio:x({engine:GU.optional(),modelId:u().optional(),enabled:y(),settings:h(u(),w()).readonly().optional()}).nullable().optional()}),mX=x({modelId:u().optional(),settings:h(u(),w()).optional(),jumpDeviceKey:u().optional(),enabled:y().optional()}),hX=x({maxCameras:r().int().nonnegative().nullable().default(null),detectWeight:r().positive().optional(),detect:y().optional(),decode:y().optional(),audio:y().optional(),ingest:y().optional(),decodeBudgetMb:r().int().min(1024).max(65536).optional(),maxLiveDecodeWorkers:r().int().min(1).max(32).optional(),reachableHost:u().optional(),color:sd.optional(),stepSettings:h(u(),h(u(),w()).readonly()).optional(),stepEnabled:h(u(),y()).optional(),inferenceDevices:h(u(),x({enabled:y(),weight:r().positive().optional(),maxSessions:r().int().positive().optional(),steps:h(u(),mX).optional()})).optional()}),zTe=h(u(),h(u(),w()).readonly()),gX=S([`pipeline`,`onboard`,`none`]),BTe=x({stepToggles:h(u(),y()).optional(),stepSettings:zTe.optional()}),_X=x({deviceId:r(),agentNodeId:u(),pinned:y(),reason:S([`manual`,`capacity`,`hardware-affinity`,`failover`,`rebalance`]),assignedAt:r()}),vX=x({nodeId:u(),online:y(),load:iG,score:r(),decodeHwaccel:u().nullable()}),yX=x({totalAgents:r(),onlineAgents:r(),totalCameras:r(),attachedCameras:r(),activeCameras:r(),avgInferenceTimeMs:r(),queueDepth:r()}),bX=h(u(),u()),xX=x({ownerNodeId:u(),reachableHost:u().optional(),configIssue:u().optional()}),SX=x({camStreamId:u(),codec:u(),width:r(),height:r(),fps:r(),kind:u()}),CX=x({streams:C(SX).readonly()}),wX=x({detectionNodeId:u().nullable(),decoderNodeId:u().nullable(),audioNodeId:u().nullable(),sourceNodeId:u().nullable(),pinned:x({detection:y(),decoder:y(),audio:y()}),reasons:x({detection:u().optional(),decoder:u().optional(),audio:u().optional()})}),TX=x({profile:u(),status:u(),codec:u(),width:r(),height:r(),subscribers:r(),inFps:r().nullable()}),EX=x({profiles:C(TX).readonly(),webrtcSessions:r(),rtspRestream:y()}),DX=x({nodeId:u()}),OX=x({enabled:y(),fps:r()}),kX=S([`idle`,`installing`,`verifying`,`ready`,`failed`]),AX=x({state:kX,error:u().optional()}),jX=S([`idle`,`watching`,`active`]),MX=x({nodeId:u(),engine:x({backend:u(),device:u()}),phase:jX,configuredFps:r(),actualFps:r(),queueDepth:r(),avgInferenceMs:r(),provisioning:AX}),NX=x({nodeId:u(),enabled:y()}),PX=nl,FX=x({mode:PX,active:y(),storageBytes:r()}),IX=S([`source`,`broker`,`detection`,`recording`,`switches`]),LX=S([`timeout`,`error`,`partial`]),RX=x({stage:IX,reason:LX,elapsedMs:r()}),zX=x({state:S([`idle`,`running`,`done`,`error`]),total:r().int().nonnegative(),completed:r().int().nonnegative(),currentDeviceId:r().int().nullable(),failed:C(r().int()).readonly(),mediaDropped:r().int().nonnegative(),tracks:r().int().nonnegative(),events:r().int().nonnegative(),startedAtMs:r().int().nullable(),finishedAtMs:r().int().nullable(),error:u().nullable()}),BX=x({deviceId:r(),assignment:wX,source:CX,broker:EX.nullable(),decoder:DX.nullable(),motion:OX.nullable(),detection:MX.nullable(),audio:NX.nullable(),recording:FX.nullable(),switchedOff:C(ao).readonly(),cameraSensors:gV.optional(),degraded:C(RX).readonly(),fetchedAt:r()}),VX=[`disabled`,`unavailable`,`cannot-host-camera-root`,`accelerator-preferred`,`root-switched-off`,`no-gpu-device`],HX=S(VX),VTe=x({key:u(),backend:u(),device:u(),format:S(ff),available:y(),presence:S([`present`,`absent`,`unknown`]).optional(),enabled:y(),weight:r(),maxSessions:r().nullable(),defaultModelId:u(),steps:h(u(),mX).optional(),exclusion:HX.nullable()}),UX=a(`kind`,[x({kind:m(`stored`),modelId:u()}),x({kind:m(`absent`),defaultModelId:u()}),x({kind:m(`unreadable`),reason:S(AV),error:u().optional()})]),HTe=x({nodeId:u(),reachable:y(),devices:C(VTe).readonly(),defaultPoolExcluded:y().optional()}),WX=S([`off`,`on`,`opt-in`]),GX=a(`kind`,[x({kind:m(`on`)}),x({kind:m(`off-cluster`)}),x({kind:m(`off-node`)}),x({kind:m(`off-device`)}),x({kind:m(`jump`),toDeviceKey:u()}),x({kind:m(`skip`),reason:S([`no-compatible-model`,`root-not-runnable-on-elected-device`])}),x({kind:m(`zone-driven`)}),x({kind:m(`supplied-by-root`),rootModelId:u()}),x({kind:m(`opt-in-unused`)})]),UTe=x({deviceKey:u(),format:S(ff),stepEnabled:y().nullable(),eligible:y(),cell:GX}),WTe=x({nodeId:u(),reachable:y(),stepEnabled:y().nullable(),devices:C(UTe).readonly()}),KX=x({steps:C(x({stepId:u(),name:u(),slot:u(),clusterMode:WX.nullable(),effectiveMode:WX,camerasEnabling:r().int().nonnegative(),camerasDisabling:r().int().nonnegative(),nodes:C(WTe).readonly()})).readonly()}),qX=x({deviceId:r().int().nonnegative(),config:lV.nullable()}),JX=S([`unknown-camera`,`out-of-range`,`no-burst-producer`,`already-looked`]),YX=x({deviceId:r().int().nonnegative(),afterMs:r().finite(),reason:u()}),XX=x({scheduled:y(),dueInMs:r().optional(),refusedBecause:JX.optional()}),ZX={name:`pipeline-orchestrator`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,exposesDeviceSettings:!0,methods:{requestOccupancyLook:D(YX,XX,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:D(Cl,x({paused:m(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:D(Cl,x({resumed:m(!0)}),{kind:`mutation`,auth:`admin`}),assignPipeline:D(x({deviceId:r(),agentNodeId:u()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),unassignPipeline:D(x({deviceId:r()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setPipelineDevicePin:D(x({deviceId:r(),deviceKey:u()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getPipelineDevicePin:D(x({deviceId:r()}),x({deviceKey:u().nullable()})),rebalance:D(v(),x({migrated:r(),skipped:C(x({deviceId:r(),targetNodeId:u(),reason:u()})).default([])}),{kind:`mutation`,auth:`admin`}),getPipelineAssignments:D(v(),C(_X).readonly()),getPipelineAssignment:D(x({deviceId:r()}),_X.nullable()),getAgentLoad:D(v(),C(vX).readonly()),getClusterModelChoice:D(x({stepId:u()}),UX),getGlobalMetrics:D(v(),yX),getCameraMetrics:D(x({deviceId:r()}),QU.nullable()),getCapabilityBindings:D(x({nodeId:u()}),bX),setCapabilityBinding:D(x({nodeId:u(),capName:u(),addonId:u()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getIngestOwner:D(v(),xX),assignAudio:D(x({deviceId:r(),nodeId:u()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),unassignAudio:D(x({deviceId:r()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getAudioAssignment:D(x({deviceId:r()}),x({nodeId:u(),pinned:y(),assignedAt:r()}).nullable()),getAudioNodeLoad:D(v(),C(x({nodeId:u(),deviceCount:r()}))),getAudioAssignments:D(v(),C(x({deviceId:r(),nodeId:u(),pinned:y(),assignedAt:r()}))),getAgentSettings:D(x({agentNodeId:u()}),hX.nullable()),listAgentSettings:D(v(),C(x({nodeId:u(),settings:hX})).readonly()),removeAgentSettings:D(x({agentNodeId:u()}),x({success:y(),removed:y()}),{kind:`mutation`,auth:`admin`}),setAgentMaxCameras:D(x({agentNodeId:u(),maxCameras:r().int().nonnegative().nullable()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentCapabilities:D(x({agentNodeId:u(),detect:y().nullable().optional(),audio:y().nullable().optional(),ingest:y().nullable().optional()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentDecodeLimits:D(x({agentNodeId:u(),decodeBudgetMb:r().int().min(1024).max(65536).nullable().optional(),maxLiveDecodeWorkers:r().int().min(1).max(32).nullable().optional()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentReachableHost:D(x({agentNodeId:u(),reachableHost:u().nullable().optional(),color:sd.nullable().optional()}).refine(e=>e.reachableHost!==void 0||e.color!==void 0,{message:`reachableHost or color required`}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentInferenceDevices:D(x({agentNodeId:u(),inferenceDevices:h(u(),x({enabled:y(),weight:r().positive().optional(),maxSessions:r().int().positive().optional(),steps:h(u(),mX).optional()}))}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepSettings:D(x({agentNodeId:u(),addonId:u(),settings:h(u(),w()).nullable()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setClusterStepMode:D(x({stepId:u(),mode:WX.nullable()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepEnabled:D(x({agentNodeId:u(),stepId:u(),enabled:y().nullable()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setDeviceStepEnabled:D(x({agentNodeId:u(),deviceKey:u(),stepId:u(),enabled:y().nullable()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getStepSwitches:D(v(),KX),getNodeInferenceDevices:D(x({nodeId:u()}),HTe),forgetInferenceDevice:D(x({agentNodeId:u(),deviceKey:u()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),resetNodePipelineDefaults:D(x({agentNodeId:u()}),x({success:m(!0),effectiveModelId:u().nullable()}),{kind:`mutation`,auth:`admin`}),planAutoTune:D(jY,MY,{auth:`admin`}),applyAutoTune:D(NY,FY,{kind:`mutation`,auth:`admin`}),setLoadBalancingShares:D(RY,x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getPlacementStats:D(zY,UY,{auth:`admin`}),getHealthDigest:D(fX,pX,{auth:`admin`}),suggestShares:D(KY,YY,{auth:`admin`}),getEffectiveShares:D(v(),nX,{auth:`admin`}),setShareSource:D($Y,x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkPreflight:D(sW,fW,{auth:`admin`}),startNodeBenchmark:D(sW,a(`kind`,[x({kind:m(`started`),runId:u()}),x({kind:m(`refused`),preflight:fW})]),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkStatus:D(v(),DW,{auth:`admin`}),abortNodeBenchmark:D(x({runId:u()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkCandidates:D(x({nodeId:u()}),jW,{auth:`admin`}),listNodeBenchmarkResults:D(kW,C(AW).readonly(),{auth:`admin`}),deleteNodeBenchmarkResult:D(x({id:u()}),x({deleted:y()}),{kind:`mutation`,auth:`admin`}),getCameraSettings:D(x({deviceId:r()}),BTe.nullable()),setCameraStepToggle:D(x({deviceId:r(),addonId:u(),enabled:y().nullable()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getCameraDetectionSource:D(x({deviceId:r()}),x({source:gX,explicit:y(),onboard:x({available:y(),geometry:S([`boxed`,`while-streaming`,`flag-only`,`unknown`])})})),setCameraDetectionSource:D(x({deviceId:r(),source:gX}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setCameraStepSettings:D(x({deviceId:r(),addonId:u(),settings:h(u(),w()).nullable()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),resolvePipeline:D(x({deviceId:r(),agentNodeId:u().optional()}),RTe),getCameraSwitches:D(x({deviceId:r()}),so,{role:`viewer`}),setCameraSwitch:D(x({deviceId:r(),switchId:ao,enabled:y()}),so,{kind:`mutation`,auth:`admin`}),getCameraStatus:D(x({deviceId:r()}),BX),getCameraStatuses:D(x({deviceIds:C(r()).optional()}),C(BX).readonly()),setCameraSensors:D(qX,x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),reconcileFromDisk:D(v(),zX,{kind:`mutation`,auth:`admin`}),getReconcileFromDiskStatus:D(v(),zX,{auth:`admin`})},vocabulary:{notOperatorFacing:k.PIPELINE}},QX=x({id:u(),name:u(),sampleCount:r().int().nonnegative(),coverMediaId:r().int().optional(),coverBase64:u().optional()}),GTe=x({id:u(),text:u(),score:r(),addedAt:r().int(),deviceId:r().int().optional(),base64:u().optional(),mediaId:r().int().optional(),keyFrameMediaId:r().int().optional(),plateBbox:Ay.optional()}),$X=x({plateId:u(),deviceId:r().int(),trackId:u(),timestamp:r().int(),text:u(),score:r(),corrected:y(),recognizedVehicleId:u().optional(),vehicleName:u().optional(),assigned:y(),plateBbox:Ay.optional(),keyFrameMediaId:r().int().optional(),base64:u().optional(),cropUrl:u().optional(),cropMissReason:u().optional()}),KTe=x({mediaId:r().int(),kind:u(),url:u(),sizeBytes:r(),timestamp:r()}),qTe=x({plateIds:C(u()).readonly(),representativePlateId:u(),representativeText:u(),size:r().int(),cohesion:r()}),eZ={name:`plate-gallery`,role:{feature:`plate-assignment`},scope:`system`,mode:`singleton`,methods:{listPlates:D(x({deviceId:r().int().optional(),limit:r().int().positive().optional(),includeCrops:y().optional()}).optional(),C($X).readonly()),getPlateByTrack:D(x({deviceId:r().int(),trackId:u()}),$X.nullable(),{role:`viewer`}),getPlateMedia:D(x({plateId:u()}),C(KTe).readonly()),searchPlates:D(x({text:u().min(1),maxDistance:r().int().min(0).optional(),limit:r().int().positive().optional(),includeCrops:y().optional()}),C($X).readonly()),suggestPlateClusters:D(x({maxDistance:r().int().min(0).optional(),minClusterSize:r().int().min(2).optional(),limit:r().int().positive().optional()}).optional(),C(qTe).readonly()),correctPlateText:D(x({plateId:u(),text:u().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deletePlate:D(x({plateId:u()}),v(),{kind:`mutation`,auth:`admin`}),listVehicles:D(x({includeCrops:y().optional()}).optional(),C(QX).readonly()),createVehicle:D(x({name:u().min(1)}),QX,{kind:`mutation`,auth:`admin`}),renameVehicle:D(x({id:u(),name:u().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteVehicle:D(x({id:u()}),v(),{kind:`mutation`,auth:`admin`}),listVehicleSamples:D(x({vehicleId:u()}),C(GTe).readonly()),removeVehicleSample:D(x({vehicleId:u(),sampleId:u()}),v(),{kind:`mutation`,auth:`admin`}),moveVehicleSample:D(x({sampleId:u().min(1),toVehicleId:u().min(1)}),v(),{kind:`mutation`,auth:`admin`}),assignPlate:D(x({plateId:u(),vehicleId:u()}),v(),{kind:`mutation`,auth:`admin`}),unassignPlate:D(x({plateId:u()}),v(),{kind:`mutation`,auth:`admin`}),assignPlates:D(x({plateIds:C(u()).min(1),vehicleId:u()}),x({assigned:r().int(),failed:C(u()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignPlates:D(x({plateIds:C(u()).min(1)}),x({unassigned:r().int(),failed:C(u()).readonly()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the plate gallery — curated on its own page`}},tZ={"intel-core-ultra":{"intel-npu":{"yolov9t-320":{p50Ms:2.9,fps:383,measured:!0},"yolov9t-320-int8":{p50Ms:3.8,fps:333,measured:!0},"yolov9t-640":{p50Ms:7.4,fps:139,measured:!0},"yolov9t-640-int8":{p50Ms:7.5,fps:144,measured:!0},"yolov9s-320":{p50Ms:4.4,fps:241,measured:!0},"yolov9s-320-int8":{p50Ms:4.1,fps:264,measured:!0},"yolov9s-640":{p50Ms:12.7,fps:82,measured:!0},"yolov9s-640-int8":{p50Ms:10.7,fps:99,measured:!0},"yolov9m-320":{p50Ms:8.4,fps:123,measured:!0},"yolov9m-320-int8":{p50Ms:6.5,fps:165,measured:!0},"yolov9m-640":{p50Ms:29.5,fps:32,measured:!0},"yolov9m-640-int8":{p50Ms:19.5,fps:52,measured:!0}},"intel-igpu":{"yolov9t-320":{p50Ms:2.6,fps:405,measured:!0},"yolov9t-320-int8":{p50Ms:2.8,fps:324,measured:!0},"yolov9t-640":{p50Ms:6.5,fps:157,measured:!0},"yolov9t-640-int8":{p50Ms:5.6,fps:185,measured:!0},"yolov9s-320":{p50Ms:4.6,fps:200,measured:!0},"yolov9s-320-int8":{p50Ms:4.1,fps:239,measured:!0},"yolov9s-640":{p50Ms:15.2,fps:69,measured:!0},"yolov9s-640-int8":{p50Ms:10.5,fps:99,measured:!0},"yolov9m-320":{p50Ms:11.4,fps:88,measured:!0},"yolov9m-320-int8":{p50Ms:7,fps:127,measured:!0},"yolov9m-640":{p50Ms:40,fps:25,measured:!0},"yolov9m-640-int8":{p50Ms:23.5,fps:44,measured:!0}},"x86-cpu":{"yolov9t-320":{p50Ms:6.9,fps:145,measured:!0},"yolov9t-320-int8":{p50Ms:2.7,fps:405,measured:!0},"yolov9t-640":{p50Ms:23,fps:44,measured:!0},"yolov9t-640-int8":{p50Ms:8.8,fps:124,measured:!0},"yolov9s-320":{p50Ms:15.8,fps:63,measured:!0},"yolov9s-320-int8":{p50Ms:6.5,fps:180,measured:!0},"yolov9s-640":{p50Ms:58.2,fps:17,measured:!0},"yolov9s-640-int8":{p50Ms:20.1,fps:52,measured:!0},"yolov9m-320":{p50Ms:40,fps:25,measured:!0},"yolov9m-320-int8":{p50Ms:14.2,fps:74,measured:!0},"yolov9m-640":{p50Ms:155.8,fps:6,measured:!0},"yolov9m-640-int8":{p50Ms:52.4,fps:19,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"intel-n-series":{"intel-igpu":{"yolov9t-320":{p50Ms:15,fps:48,measured:!0},"yolov9t-320-int8":{p50Ms:14.1,fps:67,measured:!0},"yolov9t-640":{p50Ms:38.5,fps:26,measured:!0},"yolov9t-640-int8":{p50Ms:50,fps:20,measured:!0},"yolov9s-320":{p50Ms:41.4,fps:24,measured:!0},"yolov9s-320-int8":{p50Ms:23.3,fps:34,measured:!0},"yolov9s-640":{p50Ms:127.4,fps:8,measured:!0},"yolov9s-640-int8":{p50Ms:81,fps:12,measured:!0},"yolov9m-320":{p50Ms:63.5,fps:16,measured:!0},"yolov9m-320-int8":{p50Ms:66,fps:15,measured:!0},"yolov9m-640":{p50Ms:215.5,fps:5,measured:!0},"yolov9m-640-int8":{p50Ms:163,fps:6,measured:!0}},"x86-cpu":{"yolov9t-320":{p50Ms:86.2,fps:12,measured:!0},"yolov9t-320-int8":{p50Ms:52.7,fps:20,measured:!0},"yolov9t-640":{p50Ms:322.1,fps:3,measured:!0},"yolov9t-640-int8":{p50Ms:205.6,fps:5,measured:!0},"yolov9s-320":{p50Ms:164.4,fps:6,measured:!0},"yolov9s-320-int8":{p50Ms:86.9,fps:12,measured:!0},"yolov9s-640":{p50Ms:341.3,fps:3,measured:!0},"yolov9s-640-int8":{p50Ms:185.3,fps:5,measured:!0},"yolov9m-320":{p50Ms:166.8,fps:6,measured:!0},"yolov9m-320-int8":{p50Ms:226.3,fps:4,measured:!0},"yolov9m-640":{p50Ms:663.5,fps:2,measured:!0},"yolov9m-640-int8":{p50Ms:324.4,fps:3,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"amd-phoenix":{"x86-cpu":{"yolov9t-320":{p50Ms:24,fps:42,measured:!0},"yolov9t-320-int8":{p50Ms:12,fps:83,measured:!0},"yolov9t-640":{p50Ms:50,fps:20,measured:!0},"yolov9t-640-int8":{p50Ms:20,fps:50,measured:!0},"yolov9s-320":{p50Ms:30,fps:33,measured:!0},"yolov9s-320-int8":{p50Ms:15,fps:67,measured:!0},"yolov9s-640":{p50Ms:92,fps:11,measured:!0},"yolov9s-640-int8":{p50Ms:27,fps:37,measured:!0},"yolov9m-320":{p50Ms:67,fps:15,measured:!0},"yolov9m-320-int8":{p50Ms:21,fps:48,measured:!0},"yolov9m-640":{p50Ms:229,fps:4,measured:!0},"yolov9m-640-int8":{p50Ms:48,fps:21,measured:!0}},"amd-igpu":{"yolov9t-320":{p50Ms:40,fps:25,measured:!0},"yolov9t-640":{p50Ms:89,fps:11,measured:!0},"yolov9s-320":{p50Ms:65,fps:15,measured:!0},"yolov9s-640":{p50Ms:125,fps:8,measured:!0},"yolov9m-320":{p50Ms:85,fps:12,measured:!0},"yolov9m-640":{p50Ms:228,fps:4,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!0}}},"nvidia-gpu":{"nvidia-gpu":{"yolov9t-320":{p50Ms:12,fps:83,measured:!1},"yolov9t-640":{p50Ms:16,fps:62,measured:!1},"yolov9s-320":{p50Ms:13,fps:77,measured:!1},"yolov9s-640":{p50Ms:20,fps:50,measured:!1},"yolov9m-320":{p50Ms:16,fps:62,measured:!1},"yolov9m-640":{p50Ms:32,fps:31,measured:!1}}},"apple-m-pro":{"apple-ane":{"yolov9t-320":{p50Ms:1.1,fps:952,measured:!0},"yolov9t-640":{p50Ms:3,fps:333,measured:!0},"yolov9s-320":{p50Ms:1.5,fps:667,measured:!0},"yolov9s-640":{p50Ms:5.1,fps:196,measured:!0},"yolov9m-320":{p50Ms:3.2,fps:312,measured:!0},"yolov9m-640":{p50Ms:10.2,fps:98,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"apple-m-base":{"apple-ane":{"yolov9t-320":{p50Ms:1.32,fps:758,measured:!1},"yolov9t-640":{p50Ms:3.45,fps:290,measured:!0},"yolov9s-320":{p50Ms:1.8,fps:556,measured:!1},"yolov9s-640":{p50Ms:5.46,fps:183,measured:!0},"yolov9m-320":{p50Ms:3.79,fps:264,measured:!0},"yolov9m-640":{p50Ms:10.34,fps:97,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}}},nZ={"yolov9m-320":{personPrecision:.979,personRecall:.649},"yolov9m-320-int8":{personPrecision:.974,personRecall:.684},"yolov9m-640":{personPrecision:.976,personRecall:.854},"yolov9m-640-int8":{personPrecision:.976,personRecall:.847},"yolov9s-320":{personPrecision:.958,personRecall:.479},"yolov9s-320-int8":{personPrecision:.969,personRecall:.438},"yolov9s-640":{personPrecision:.986,personRecall:.753},"yolov9s-640-int8":{personPrecision:.963,personRecall:.823},"yolov9t-320":{personPrecision:.946,personRecall:.368},"yolov9t-320-int8":{personPrecision:.943,personRecall:.347},"yolov9t-640":{personPrecision:.979,personRecall:.646},"yolov9t-640-int8":{personPrecision:.979,personRecall:.646}},rZ=.5,JTe=.05,iZ=2e3,aZ=r().nullable().transform(e=>e!==null&&Number.isFinite(e)&&e>0?e:null),oZ=u().nullable().transform(e=>e!==null&&e.trim()!==``?e:null),sZ=x({int8:aZ,fp16:aZ}),cZ=x({deviceKey:u(),fullDeviceName:oZ,executionUnits:aZ,clockMHz:aZ,gops:sZ.nullable(),architecture:oZ,npuName:oZ,tops:aZ,vendor:oZ,webgpuArchitecture:oZ,webgpuDevice:oZ,computeUnits:aZ}),YTe=x({accelerators:C(cZ).nullable()}),lZ=[{hardwareClass:`intel-n-series`,accelerator:`intel-igpu`,score:{metric:`eu-mhz`,value:24*750}},{hardwareClass:`intel-core-ultra`,accelerator:`intel-igpu`,score:{metric:`eu-mhz`,value:64*iZ}},{hardwareClass:`amd-phoenix`,accelerator:`amd-igpu`,score:{metric:`cu`,value:12}}];function XTe(e){let t=YTe.safeParse(e);return!t.success||t.data.accelerators===null?null:t.data.accelerators}function uZ(e){return e!==null&&e>0?e:null}function dZ(e){let t=[],n=uZ(e.gops?.int8??null);n!==null&&t.push({metric:`gops-int8`,value:n});let r=uZ(e.gops?.fp16??null);r!==null&&t.push({metric:`gops-fp16`,value:r});let i=uZ(e.executionUnits),a=uZ(e.clockMHz);i!==null&&a!==null&&t.push({metric:`eu-mhz`,value:i*a});let o=uZ(e.computeUnits);o!==null&&t.push({metric:`cu`,value:o});let s=uZ(e.tops);return s!==null&&t.push({metric:`tops`,value:s}),t}function fZ(e,t,n){let r=n.filter(n=>n.accelerator===e&&n.score.metric===t.metric&&n.score.value>0),i=r[0];return i===void 0?null:r.reduce((e,n)=>Math.abs(Math.log(t.value/n.score.value))<Math.abs(Math.log(t.value/e.score.value))?n:e,i)}function pZ(e,t,n){for(let r of dZ(e))if(fZ(t,r,n)!==null)return r;return null}function mZ(e,t,n=lZ){return pZ(e,t,n)!==null}function hZ(e,t,n){if(t!==`unknown`)return e[t]?.[n]}function ZTe(e){return Math.round(e*10)/10}function QTe(e){return Math.min(2,Math.max(rZ,e))}function $Te(e,t,n){let r={};for(let[i,a]of Object.entries(e))r[i]={p50Ms:ZTe(a.p50Ms/t),fps:Math.max(1,Math.round(a.fps*t)),measured:!1,estimatedFrom:n};return r}function gZ(e){let t=e.perf??tZ,n=e.references??lZ;if(e.accelerator===`nvidia-gpu`){let e=hZ(t,`nvidia-gpu`,`nvidia-gpu`);return e===void 0?null:{column:e,estimatedFrom:null}}let r=hZ(t,e.hardwareClass,e.accelerator);if(r!==void 0&&e.hardwareClass!==`intel-n-series`)return{column:r,estimatedFrom:null};let i=e.report===null?null:pZ(e.report,e.accelerator,n);if(i===null)return r===void 0?null:{column:r,estimatedFrom:null};let a=fZ(e.accelerator,i,n),o=a===null?void 0:hZ(t,a.hardwareClass,e.accelerator);if(a===null||o===void 0)return r===void 0?null:{column:r,estimatedFrom:null};let s=i.value/a.score.value;return e.hardwareClass===a.hardwareClass&&Math.abs(s-1)<=.05?{column:o,estimatedFrom:null}:{column:$Te(o,QTe(s),a.hardwareClass),estimatedFrom:a.hardwareClass}}var _Z=S(ff),eEe=S([`videotoolbox`,`cuda`,`nvdec`,`vaapi`,`qsv`,`d3d11va`,`dxva2`,`amf`,`vdpau`,`drm`,`coreml`,`tensorrt`,`openvino`,`directml`,`webgpu`,`none`]).nullable().optional(),tEe=x({preferred:C(u()).readonly(),rationale:u()}),vZ=S([`h264_videotoolbox`,`hevc_videotoolbox`,`h264_vaapi`,`hevc_vaapi`,`h264_nvenc`,`hevc_nvenc`,`h264_qsv`,`hevc_qsv`,`h264_amf`,`hevc_amf`,`libx264`,`libx265`]);x({encoders:C(x({encoder:vZ,codec:S([`H264`,`H265`]),family:S([`videotoolbox`,`vaapi`,`nvenc`,`qsv`,`amf`,`software`]),available:y(),reason:u().optional()})).readonly(),defaultH264:vZ,defaultH265:vZ,probedAt:r()}),x({methods:C(u()).readonly(),probedAt:r()});var nEe=S([`darwin`,`linux`,`win32`]),rEe=S([`arm64`,`x64`]),iEe=x({type:S([`nvidia`,`amd`,`intel`,`apple`]),name:u(),memoryMB:r().optional()}),aEe=x({type:S([`apple-ane`,`intel-npu`,`amd-xdna`]),name:u().optional(),generation:S([`xdna1`,`xdna2`]).optional()}),yZ=S([`usb`,`pci`]),oEe=x({type:m(`coral-edgetpu`),bus:u().optional(),count:r().int().nonnegative().optional(),units:C(x({bus:yZ,count:r().int().nonnegative()})).readonly().optional(),unavailable:C(x({bus:yZ,count:r().int().nonnegative(),reason:S([`driver-missing`,`device-not-accessible`])})).readonly().optional()}),bZ=x({type:m(`nvidia`),name:u(),memoryMB:r().optional()}),sEe=a(`usable`,[bZ.extend({usable:m(!0)}),bZ.extend({usable:m(!1),reason:S([`no-cuda-execution-provider`])})]),xZ=x({platform:nEe,arch:rEe,cpuModel:u(),cpuCores:r(),totalRAM_MB:r(),availableRAM_MB:r(),gpu:iEe.nullable(),npu:aEe.nullable(),coral:oEe.nullable().optional(),nvidia:sEe.nullable().optional(),accelerators:C(cZ).readonly().optional()}),SZ=x({runtime:m(`python`),backend:u(),format:S([`onnx`,`coreml`,`openvino`,`tflite`]),score:r(),reason:u(),available:y()}),CZ=x({key:u(),backend:u(),device:u(),format:_Z,runtime:m(`python`),score:r(),available:y()}),cEe=x({hardware:xZ,scores:C(SZ).readonly(),bestScore:SZ,pythonPath:u().nullable(),devices:C(CZ).readonly()}),lEe=x({modelId:u(),name:u(),minRAM_MB:r(),accuracyScore:r(),formats:C(u()).readonly()}),uEe=x({modelId:u(),runtime:m(`python`),backend:u(),format:_Z,reason:u()}),dEe=x({devices:C(CZ).readonly(),appeared:C(u()).readonly(),disappeared:C(u()).readonly(),usbBus:S([`observed`,`unobservable`]),decidedBy:S([`usb-ids`,`pci`,`delegate-fallback`,`none`])}),wZ={name:`platform-probe`,scope:`system`,mode:`singleton`,methods:{getCapabilities:D(v(),cEe),getHardware:D(v(),xZ),resolveInferenceConfig:D(x({requirements:C(lEe).readonly()}),uEe),resolveHwAccel:D(x({prefer:eEe}),tEe),rescanAccelerators:D(v(),dEe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.CLUSTER}},TZ=x({power:r().optional().meta(A(`power`,{label:`Power`})),deliveredPower:r().optional().meta(A(`power`,{label:`Delivered`})),energy:r().optional().meta(A(`energy`,{label:`Energy`})),voltage:r().optional().meta(A(`voltage`,{label:`Voltage`})),current:r().optional().meta(A(`current`,{label:`Current`})),apparentPower:r().optional().meta(A(`apparent-power`)),powerFactor:r().min(0).max(1).optional().meta(A(`ratio`)),lastFetchedAt:r()});function EZ(e){if(e.power===void 0)return;let t=e.power-(e.deliveredPower??0);return t<0?void 0:t}var DZ=[M.Sensor,M.Switch,M.Light,M.Fan,M.Climate,M.Humidifier,M.WaterHeater,M.MediaPlayer,M.Washer,M.Dryer,M.Dishwasher,M.Vacuum,M.LawnMower,M.PetFeeder,M.Workload],fEe=DZ.filter(e=>e!==M.Sensor);function OZ(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`power-meter`,stateField:e},deviceTypes:fEe,apply:`add`,path:e,sources:[{kind:`numeric`,requiredUnit:t,transforms:[{kind:`identity`}]}],companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}}var pEe={version:1,targets:[OZ(`power`,`W`),OZ(`energy`,`kWh`),OZ(`voltage`,`V`),OZ(`current`,`A`)]},kZ={name:`power-meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:DZ,deviceConfig:{ui:{kind:`widget`,widgetId:`host/power-meter-line`,tab:`power`,placement:`hero`,label:`Power`,order:4}},methods:{},status:{schema:TZ,kind:`push`},runtimeState:TZ,durability:`restored`,history:{primary:`power`,priority:80,fields:{power:{kind:`gauge`,unit:`W`,deadband:1,minIntervalMs:3e4},energy:{kind:`counter`,unit:`kWh`,deadband:.01,minIntervalMs:6e4},voltage:{kind:`gauge`,unit:`V`,deadband:1,minIntervalMs:3e4},current:{kind:`gauge`,unit:`A`,deadband:.05,minIntervalMs:3e4},apparentPower:{kind:`gauge`,unit:`VA`,deadband:1,minIntervalMs:3e4},powerFactor:{kind:`gauge`,unit:`ratio`,deadband:.01,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],customize:pEe,vocabulary:{noun:L(`Power meter`,`Misuratore di energia`),order:5160,state:[{kind:`numeric`,field:`power`,quantity:L(`the power draw`,`il consumo`),label:L(`Power`,`Potenza`),unit:`W`,icon:`zap`},{kind:`numeric`,field:`energy`,quantity:L(`the energy used`,`l’energia consumata`),label:L(`Energy`,`Energia`),unit:`kWh`,icon:`zap`},{kind:`numeric`,field:`voltage`,quantity:L(`the voltage`,`la tensione`),label:L(`Voltage`,`Tensione`),unit:`V`,icon:`zap`},{kind:`numeric`,field:`current`,quantity:L(`the current`,`la corrente`),label:L(`Current`,`Corrente`),unit:`A`,icon:`zap`}]}},mEe=x({latitude:r().min(-90).max(90).meta(A(`angle`)),longitude:r().min(-180).max(180).meta(A(`angle`)),accuracyMeters:r().nonnegative().meta(A(`length`))}),AZ=x({state:u(),location:u().nullable(),gps:mEe.nullable(),lastChangedAt:r()}),jZ={name:`presence`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Presence],methods:{},status:{schema:AZ,kind:`push`},runtimeState:AZ,durability:`restored`,history:`none`,volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Presence`,`Presenza`),order:5170,state:[{kind:`value`,field:`state`,label:L(`Where`,`Posizione`),phrase:L(`When {device} is at {value}`,`Quando {device} è in {value}`),icon:`map-pin`}]}},MZ=x({pressure:r().nullable().meta(A(`pressure`,{precision:0})),lastFetchedAt:r()}),NZ={name:`pressure-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:MZ,kind:`push`},runtimeState:MZ,durability:`restored`,history:{fields:{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Pressure`,`Pressione`),order:5180,state:[{kind:`numeric`,field:`pressure`,quantity:L(`the pressure`,`la pressione`),label:L(`Pressure`,`Pressione`),unit:`hPa`,icon:`gauge`}]}},PZ=a(`kind`,[CV,wV]),FZ=x({id:r(),enabled:y(),shape:PZ}),IZ=x({enabled:y(),regions:C(FZ).nullable(),audioEnabled:y().nullable(),lastFetchedAt:r()}),LZ=x({maxRegions:r(),supportedShapes:C(DV),polygonVertices:OV.optional(),supportsAudioMute:y()}),RZ=x({enabled:y().optional(),regions:C(FZ).optional()}),zZ={name:`privacy-mask`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/privacy-mask-grid`,tab:`image`,label:`Privacy Mask`}},methods:{getOptions:D(x({deviceId:r()}),LZ),setMask:D(x({deviceId:r(),patch:RZ}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.maskOn`,label:L(`Privacy mask on`,`Maschera privacy attiva`),phrase:L(`Cover the privacy zones of {device}`,`Oscura le zone private di {device}`),icon:`eye-off`,args:{patch:{enabled:!0}}},{id:`privacy.maskOff`,label:L(`Privacy mask off`,`Maschera privacy spenta`),phrase:L(`Uncover the privacy zones of {device}`,`Scopri le zone private di {device}`),icon:`eye`,args:{patch:{enabled:!1}}}]}),setAudioEnabled:D(x({deviceId:r(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.micOn`,label:L(`Microphone on`,`Microfono attivo`),phrase:L(`Turn on the microphone of {device}`,`Attiva il microfono di {device}`),icon:`mic`,args:{enabled:!0}},{id:`privacy.micOff`,label:L(`Microphone off`,`Microfono spento`),phrase:L(`Turn off the microphone of {device}`,`Disattiva il microfono di {device}`),icon:`mic-off`,args:{enabled:!1}}]})},status:{schema:IZ,kind:`poll`},runtimeState:IZ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Privacy`,`Privacy`),order:3210,state:[{kind:`boolean`,field:`enabled`,label:L(`Privacy mask`,`Maschera privacy`),whenTrue:L(`When the privacy mask of {device} is turned on`,`Quando si attiva la maschera privacy di {device}`),whenFalse:L(`When the privacy mask of {device} is turned off`,`Quando si disattiva la maschera privacy di {device}`),icon:`eye-off`},{kind:`boolean`,field:`audioEnabled`,label:L(`Microphone`,`Microfono`),whenTrue:L(`When the microphone of {device} is turned on`,`Quando si attiva il microfono di {device}`),whenFalse:L(`When the microphone of {device} is turned off`,`Quando si disattiva il microfono di {device}`),icon:`mic`}]}};function hEe(e){return e.length===0?null:e.some(e=>e.audioEnabled)}var BZ=S([`home`,`day-mode`,`night-mode`,`day-night-auto`,`set-limits`,`save-limits`,`reboot`,`osd-menu`]),VZ=x({id:u(),name:u(),fn:BZ.nullable(),writable:y()}),HZ=x({pan:r().nullable(),tilt:r().nullable(),zoom:r().nullable()}),UZ=x({pan:r().optional(),tilt:r().optional(),zoom:r().optional(),speed:r().optional()}),WZ=HZ.extend({autofocus:y()}),GZ=x({hasPan:y(),hasTilt:y(),hasZoom:y(),supportsPresets:y(),maxPresets:r().optional(),hasAutofocus:y(),speedSteps:r().int().positive().nullable(),moveImpulseMs:r().int().positive().nullable()}),KZ=x({presetId:u().nullable(),source:S([`operator`,`firmware`,`native`,`none`])}),qZ=x({enabled:y(),seconds:r().int()}),JZ={name:`ptz`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-panel`,tab:`ptz`,topTab:!0,label:`PTZ`,order:0}},methods:{move:D(UZ.extend({deviceId:r()}),v(),{kind:`mutation`,notOperatorFacing:`a relative nudge from the live-view joystick; a fixed place is a preset`}),continuousMove:D(UZ.extend({deviceId:r()}),v(),{kind:`mutation`,notOperatorFacing:`joystick motion held until released — continuous, not a discrete step`}),goHome:D(x({deviceId:r()}),v(),{kind:`mutation`,actions:[{id:`ptz.goHome`,label:L(`PTZ go home`,`Torna alla posizione iniziale`),phrase:L(`Send {device} to its home position`,`Riporta {device} alla posizione iniziale`),icon:`house`}]}),getPresets:D(x({deviceId:r()}),C(VZ)),goToPreset:D(x({deviceId:r(),presetId:u()}),v(),{kind:`mutation`,actions:[{id:`ptz.goToPreset`,label:L(`PTZ go to preset`,`Vai a un preset`),phrase:L(`Move {device} to {presetId}`,`Sposta {device} su {presetId}`),icon:`move`,openArgs:[{key:`presetId`,label:L(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),savePreset:D(x({deviceId:r(),presetId:u(),name:u()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.savePreset`,label:L(`Save PTZ preset here`,`Salva qui un preset`),phrase:L(`Save where {device} points now as preset {presetId} ({name})`,`Salva la posizione attuale di {device} come preset {presetId} ({name})`),icon:`bookmark-plus`,openArgs:[{key:`presetId`,label:L(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}},{key:`name`,label:L(`Name`,`Nome`),offer:{kind:`text`}}]}]}),deletePreset:D(x({deviceId:r(),presetId:u()}),v(),{kind:`mutation`,auth:`admin`}),getOptions:D(x({deviceId:r()}),GZ),stop:D(x({deviceId:r()}),v(),{kind:`mutation`,actions:[{id:`ptz.stop`,label:L(`Stop moving`,`Ferma il movimento`),phrase:L(`Stop {device} moving`,`Ferma il movimento di {device}`),icon:`square`}]}),getHomePreset:D(x({deviceId:r()}),KZ),setHomePreset:D(x({deviceId:r(),presetId:u().nullable()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomePreset`,label:L(`Set PTZ home preset`,`Imposta il preset iniziale`),phrase:L(`Make {presetId} the home position of {device}`,`Rendi {presetId} la posizione iniziale di {device}`),icon:`house`,openArgs:[{key:`presetId`,label:L(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),captureHomeHere:D(x({deviceId:r()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.captureHomeHere`,label:L(`Set PTZ home here`,`Imposta qui la posizione iniziale`),phrase:L(`Make where {device} points now its home position`,`Rendi la posizione attuale di {device} la sua posizione iniziale`),icon:`map-pin`}]}),getHomeReturn:D(x({deviceId:r()}),qZ.nullable()),setHomeReturn:D(x({deviceId:r(),enabled:y(),seconds:r().int().min(0).max(3600)}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomeReturn`,label:L(`Set PTZ return home`,`Imposta il ritorno alla posizione iniziale`),phrase:L(`Set {device} to return home when idle ({enabled}) after {seconds} s`,`Imposta {device} per tornare alla posizione iniziale da fermo ({enabled}) dopo {seconds} s`),icon:`undo-2`,openArgs:[{key:`enabled`,label:L(`Return home`,`Torna alla posizione iniziale`),offer:{kind:`boolean`}},{key:`seconds`,label:L(`Idle seconds`,`Secondi da fermo`),offer:{kind:`number`,min:0,max:3600,step:1,unit:`s`}}]}]}),getPosition:D(x({deviceId:r()}),HZ),setAutofocus:D(x({deviceId:r(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autofocusOn`,label:L(`Autofocus on`,`Autofocus attivo`),phrase:L(`Turn on autofocus on {device}`,`Attiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!0}},{id:`ptz.autofocusOff`,label:L(`Autofocus off`,`Autofocus spento`),phrase:L(`Turn off autofocus on {device}`,`Disattiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!1}}]})},status:{schema:WZ,kind:`command-driven`},vocabulary:{noun:L(`Pan / tilt / zoom`,`Brandeggio`),order:3220}},YZ=x({targetType:u().describe(`Vendor target string (people/vehicle/pet); empty = camera default`),stopDelaySeconds:r().int().min(0).max(300).meta(A(`duration`)),disappearDelaySeconds:r().int().min(0).max(300).meta(A(`duration`))}),XZ=x({value:u(),label:u()}),ZZ=x({enabled:y(),lastChangedAt:r(),currentSettings:YZ.nullable(),supportedTargetTypes:C(XZ)}),QZ=ZZ.extend({lastFetchedAt:r()}),$Z={name:`ptz-autotrack`,scope:`device`,deviceNative:!0,mode:`singleton`,kind:`wrapper`,defaultActive:!1,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-autotrack`,tab:`ptz`,topTab:!0,label:`Auto-Tracking`,order:5}},methods:{getStatus:D(x({deviceId:r()}),ZZ),setEnabled:D(x({deviceId:r(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autotrackOn`,label:L(`Autotrack on`,`Inseguimento attivo`),phrase:L(`Start autotracking on {device}`,`Attiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!0}},{id:`ptz.autotrackOff`,label:L(`Autotrack off`,`Inseguimento spento`),phrase:L(`Stop autotracking on {device}`,`Disattiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!1}}]}),getSettings:D(x({deviceId:r()}),YZ.nullable()),setSettings:D(x({deviceId:r(),settings:YZ.partial()}),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`tracking tuning (target type, delays) — set once on the camera’s PTZ page`})},events:{onStatusChanged:{data:x({deviceId:r(),status:ZZ}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:ZZ,kind:`command-driven`},runtimeState:QZ,durability:`session`,history:`none`,vocabulary:{noun:L(`Autotracking`,`Inseguimento automatico`),order:3230,state:[{kind:`boolean`,field:`enabled`,label:L(`Autotracking`,`Inseguimento automatico`),whenTrue:L(`When autotracking is turned on for {device}`,`Quando si attiva l’inseguimento automatico di {device}`),whenFalse:L(`When autotracking is turned off for {device}`,`Quando si disattiva l’inseguimento automatico di {device}`),icon:`crosshair`}]}},eQ=x({enabled:y().nullable(),onTime:r().min(0).nullable().meta(A(`duration`)),offTime:r().min(0).nullable().meta(A(`duration`)),lastFetchedAt:r()}),tQ=r().int().nonnegative(),nQ=r().int().min(0),rQ={name:`pump-cycle`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.PetFountain],methods:{setEnabled:D(x({deviceId:tQ,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.on`,effect:{field:`enabled`,value:!0},label:L(`Pump cycle on`,`Ciclo pompa attivo`),phrase:L(`Run the pump of {device} on its on/off cycle`,`Fai lavorare la pompa di {device} a ciclo acceso/spento`),icon:`timer`,args:{on:!0}},{id:`pumpCycle.off`,effect:{field:`enabled`,value:!1},label:L(`Pump cycle off`,`Ciclo pompa spento`),phrase:L(`Run the pump of {device} continuously`,`Fai lavorare la pompa di {device} in continuo`),icon:`timer-off`,args:{on:!1}}]}),setOnMinutes:D(x({deviceId:tQ,minutes:nQ}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.onMinutes`,label:L(`Set pump run time`,`Imposta il tempo di lavoro della pompa`),phrase:L(`Set the pump of {device} to run {minutes} minutes per cycle`,`Imposta la pompa di {device} a lavorare {minutes} minuti per ciclo`),icon:`timer`,effect:{field:`onTime`,fromArg:`minutes`,scale:60},openArgs:[{key:`minutes`,label:L(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]}),setOffMinutes:D(x({deviceId:tQ,minutes:nQ}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.offMinutes`,label:L(`Set pump rest time`,`Imposta il tempo di riposo della pompa`),phrase:L(`Set the pump of {device} to rest {minutes} minutes per cycle`,`Imposta la pompa di {device} a riposare {minutes} minuti per ciclo`),icon:`timer-off`,effect:{field:`offTime`,fromArg:`minutes`,scale:60},openArgs:[{key:`minutes`,label:L(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]})},status:{schema:eQ,kind:`push`},runtimeState:eQ,durability:`session`,history:`none`,vocabulary:{noun:L(`Pump cycle`,`Ciclo della pompa`),order:2050,state:[{kind:`boolean`,field:`enabled`,label:L(`Pump cycle`,`Ciclo pompa`),whenTrue:L(`When {device} starts running its pump on a cycle`,`Quando {device} inizia a far lavorare la pompa a ciclo`),whenFalse:L(`When {device} runs its pump continuously`,`Quando {device} fa lavorare la pompa in continuo`),icon:`timer`}]}},iQ={name:`reboot`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera,M.Sensor,M.Switch,M.Gateway],methods:{reboot:D(x({deviceId:r().int().nonnegative()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`,actions:[{id:`reboot.reboot`,label:L(`Reboot device`,`Riavvia il dispositivo`),phrase:L(`Reboot {device}`,`Riavvia {device}`),icon:`refresh-cw`}]})},vocabulary:{noun:L(`Reboot`,`Riavvio`),order:3240}},aQ=x({owner:u(),kind:na,title:u(),nameField:u(),fields:h(u(),w()),secretPaths:C(u()),rows:r().int().nonnegative()}),oQ=x({id:OB,name:u(),rev:r().int(),updatedAt:r(),data:kB}),sQ={owner:u().min(1),kind:na},cQ={name:`record-entries`,scope:`system`,mode:`singleton`,methods:{listEntryKinds:D(x({}),x({kinds:C(aQ)}),{auth:`admin`}),listEntries:D(x({...sQ}),x({entries:C(oQ)}),{auth:`admin`}),putEntry:D(x({...sQ,id:OB.optional(),data:kB,ifRev:r().int().min(1).optional()}),x({id:u(),rev:r().int()}),{kind:`mutation`,auth:`admin`}),deleteEntry:D(x({...sQ,id:OB}),x({deleted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.INTERNAL}},gEe=`camstack`,lQ=`recorder`,uQ=x({profile:u(),startMs:r(),endMs:r()}),dQ=S([`read`,`unreadable`]),fQ=x({deviceId:r(),read:dQ,ranges:C(uQ),profilesWithFootage:C(u())}),pQ=x({deviceId:r(),read:dQ,days:C(r())}),mQ=x({deviceId:r(),localMasterPath:u().nullable(),playbackUrl:u().nullable(),playbackEndpoints:C(u())}),hQ=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:u().optional(),coverageAsOf:r().optional()}),gQ=x({source:u(),label:u(),addonId:u().optional(),availability:hQ}),_Q=x({transport:S([`archive`,`stream`,`realtime`]),coverage:S([`continuous`,`sparse`]),seek:S([`free`,`forward`,`segment`]),stepBack:y(),scrub:y(),rates:C(r().positive()).min(1).readonly(),exclusive:y()}),vQ=a(`kind`,[x({kind:m(`hls`),manifest:mQ}),x({kind:m(`clip`),source:u(),clipId:u(),startsAtMs:r()}),x({kind:m(`none`),reason:u()})]),yQ={name:`recording`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Camera],methods:{listSources:D(x({deviceId:r()}),C(gQ).readonly(),{kind:`query`,auth:`protected`}),getAvailability:D(x({deviceId:r(),provider:u().min(1),fromMs:r(),toMs:r(),profile:u().optional()}),fQ,{kind:`query`,auth:`protected`}),getDaysWithRecordings:D(x({deviceId:r(),provider:u().min(1),fromMs:r(),toMs:r(),tzOffsetMinutes:r()}),pQ,{kind:`query`,auth:`protected`}),getPlayback:D(x({deviceId:r(),provider:u().min(1),fromMs:r(),toMs:r(),profile:j.optional()}),vQ,{kind:`query`,auth:`protected`}),getPlaybackOptions:D(x({deviceId:r(),provider:u().min(1)}),_Q,{kind:`query`,auth:`protected`})},vocabulary:{noun:L(`Recording`,`Registrazione`),order:3250}},bQ=x({deviceId:r(),enabled:y(),activeMode:nl,nodeId:u(),storageBytes:r()}),xQ=x({deviceId:r(),read:S([`read`,`unreadable`]),ranges:C(uQ).readonly(),profilesWithFootage:C(u()).readonly()}),SQ=x({deviceId:r(),read:S([`read`,`unreadable`]),days:C(r()).readonly()}),CQ=x({deviceId:r(),usedBytes:r(),oldestMs:r().nullable().optional(),segments:r().optional(),residentBytes:r().optional(),residentOldestMs:r().nullable().optional()}),wQ=x({locationId:u().nullable(),locationIds:C(u()).optional(),root:u().optional(),usedBytes:r(),availableBytes:r().nullable(),totalBytes:r().nullable()}),TQ=x({nodeId:u(),totalUsedBytes:r(),devices:C(CQ),devicesRead:S([`archive`,`unavailable`]).optional(),complete:y().optional(),locations:C(wQ).optional()}),EQ=x({deviceId:r(),profile:u(),fromLocationId:u(),toLocationId:u(),bytes:r(),files:r().int()}),DQ=S([`unassigned`,`target-not-writable`,`below-threshold`,`no-headroom`]),OQ=x({deviceId:r(),profile:u(),fromLocationId:u(),toLocationId:u().nullable(),bytes:r(),reason:DQ}),kQ=x({moves:C(EQ),skipped:C(OQ),bytesToMove:r(),jobIds:C(u())}),AQ=x({throttleMbps:r().min(1).max(1e3).optional(),minMoveGb:r().min(0).optional()}),_Ee=x({deviceId:r().int(),profile:u(),locationId:u()}),vEe=x({deviceId:r().int(),locationId:u()}),yEe=x({assignments:C(_Ee),pins:C(vEe),defaultLocations:h(u(),u())}),bEe=x({deviceId:r().int(),locationId:u().nullable()}),jQ=a(`kind`,[x({kind:m(`segment`),startMs:r(),durMs:r(),bytes:r()}),x({kind:m(`gap`),nearestEdgeMs:r().nullable(),prevEndMs:r().nullable().optional()})]),MQ=x({data:b(Uint8Array)}),NQ=x({data:b(Uint8Array),gopStartMs:r(),gopDurMs:r()}),PQ=a(`kind`,[x({kind:m(`ok`),data:b(Uint8Array),gopStartMs:r(),gopDurMs:r(),reachesRequestedEnd:y()}),x({kind:m(`spans-multiple-segments`),segmentEndMs:r()})]),FQ={name:`recording-archive`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,status:{schema:bQ,kind:`command-driven`},methods:{getAvailabilityBatch:D(x({deviceIds:C(r()).min(1).max(200),fromMs:r(),toMs:r()}),C(xQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getDaysWithRecordingsBatch:D(x({deviceIds:C(r()).min(1).max(200),fromMs:r(),toMs:r(),tzOffsetMinutes:r()}),C(SQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getStorageUsage:D(x({}),TQ,{kind:`query`,auth:`admin`}),getDeviceConfig:D(x({deviceId:r()}),pl,{role:`viewer`,kind:`query`,auth:`protected`}),locateSegment:D(x({deviceId:r(),profile:u(),epochMs:r()}),jQ,{kind:`query`,auth:`admin`}),readSegmentBytes:D(x({deviceId:r(),profile:u(),startMs:r()}),MQ,{kind:`query`,auth:`admin`}),readGopBytes:D(x({deviceId:r(),profile:u(),startMs:r(),epochMs:r()}),NQ,{kind:`query`,auth:`admin`}),readWindowBytes:D(x({deviceId:r(),profile:u(),startMs:r(),fromMs:r(),toMs:r()}),PQ,{kind:`query`,auth:`admin`}),setDeviceConfig:D(x({deviceId:r(),config:pl}),pl,{kind:`mutation`,auth:`admin`}),rescanStorage:D(x({deviceId:r()}),bQ,{kind:`mutation`,auth:`admin`}),pruneFootage:D(x({deviceId:r(),reason:gc.optional()}),x({floorMs:r().nullable(),deletedBuckets:r().int(),reclaimedBytes:r().int()}),{kind:`mutation`,auth:`admin`}),deleteFootprint:D(x({deviceId:r(),fromMs:r().optional(),toMs:r().optional()}),x({deletedBuckets:r().int(),reclaimedBytes:r().int()}),{kind:`mutation`,auth:`admin`}),listOpsLog:D(vc,C(_c).readonly(),{kind:`query`,auth:`admin`}),renderGif:D(x({deviceId:r(),aroundMs:r(),preRollSec:r().min(0).max(30).default(2),postRollSec:r().min(0).max(30).default(5),maxWidth:r().int().min(120).max(1280).default(480),fps:r().int().min(1).max(15).default(5)}),x({gifBase64:u(),fromMs:r(),toMs:r()}),{kind:`mutation`,auth:`admin`}),renderClip:D(x({deviceId:r(),aroundMs:r(),preRollSec:r().min(0).max(30).default(3),postRollSec:r().min(0).max(30).default(7),maxWidth:r().int().min(160).max(1920).default(640)}),x({clipBase64:u(),mime:u(),fromMs:r(),toMs:r(),bytes:r().int()}),{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:D(Cl,x({paused:m(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:D(Cl,x({resumed:m(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:D(Cl,x({refreshed:m(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:D(wl,x({jobId:u()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:D(x({jobId:u()}),bl.nullable(),{auth:`admin`}),cancelStorageMigrationMove:D(x({jobId:u()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateFootage:D(Sl,x({jobId:u()}),{kind:`mutation`,auth:`admin`}),listRelocateJobs:D(x({}),C(bl).readonly(),{kind:`query`,auth:`admin`}),getRelocateResidue:D(Xl,Zl,{kind:`query`,auth:`admin`}),reconcileLedgerAgainstDisk:D(Ql,nu,{kind:`mutation`,auth:`admin`}),cancelRelocateJob:D(x({jobId:u()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),planStorageRebalance:D(AQ,kQ,{kind:`query`,auth:`admin`}),startStorageRebalance:D(AQ,kQ,{kind:`mutation`,auth:`admin`}),getPlacement:D(x({}),yEe,{kind:`query`,auth:`admin`}),setDevicePlacement:D(bEe,x({ok:m(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.STORAGE}},xEe=S([`queue-full`,`camera-backoff`,`sleeping`,`camera-refused`,`no-keyframe`,`decode-failed`,`no-catalog-row`,`unsupported`,`unknown-device`,`uid-missing`]),SEe=S([`deferred`,`final`]),IQ=`x-camstack-reason`;function CEe(e){let t=e.replace(/[\u2013\u2014\u2212]/g,`-`).replace(/[\u2018\u2019\u201b]/g,`'`).replace(/[\u201c\u201d]/g,`"`).replace(/\u2026/g,`...`).replace(/[\u00a0\u2007\u202f]/g,` `),n=``;for(let e of t){let t=e.codePointAt(0)??0;t<32||t===127?n+=` `:t>255?n+=`?`:n+=e}return n.slice(0,500).trim()}var LQ=`x-camstack-reason-code`,RQ=`x-camstack-disposition`,wEe=`x-camstack-clip-transport`,zQ=x({id:u(),source:u(),kind:S([`motion`,`object`,`audio`,`native`]),timeRange:x({startMs:r(),endMs:r()}),labels:C(u()).max(3).optional(),thumbnail:u().optional(),stillAtMs:r().optional(),eventIds:C(u()).optional(),eventCount:r().int().nonnegative().optional(),holes:C(x({startMs:r(),endMs:r()})).optional(),thumbnailMint:u().optional(),thumbnailUnavailable:x({reason:S([`sleeping`,`camera-refused`,`no-keyframe`,`unsupported`])}).optional(),catalogAsOf:r().optional(),nativeTypes:C(u()).optional(),behaviours:C(u()).optional(),streams:x({sub:x({id:u(),bytes:r().optional()}).optional(),main:x({id:u(),bytes:r().optional()}).optional()}).optional(),supportSub:y().optional(),playable:y().optional(),unplayableReason:u().optional(),inProgress:y().optional()}),BQ=x({playbackUrl:u(),format:S([`hls`,`mp4`]).optional(),served:j.optional(),playbackEndpoints:C(u()).optional(),token:u().optional()}),VQ=S([`authorised`]),TEe=50*1024*1024,EEe=500*1024*1024,HQ=x({base64:u(),contentType:u(),name:u(),bytes:r().int().nonnegative(),served:j,durationMs:r().positive().optional()}),UQ=x({ticket:io,contentType:u(),name:u(),served:j,durationMs:r().positive().optional()}),WQ=S([`opus`,`pcmu`,`none`]),GQ=S([`not-requested`,`unsupported-ask`]),KQ=x({url:u().min(1),expiresAtMs:r(),transport:m(`forward-only`),served:j,servedAudio:WQ,audioReason:GQ.optional()}),qQ=[.25,.5,1,1.5,2,4,8],JQ=[.25,.5,1,1.5,2,4],YQ=[.25,.5,1],XQ=x({transport:S([`stream`,`file`]),seek:S([`forward`,`free`]),stepBack:y(),scrub:y(),rates:C(r().positive()).min(1).readonly()}),ZQ=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:u().optional(),catalogAsOf:r().optional()}),QQ=x({source:u(),label:u(),addonId:u().optional(),availability:ZQ}),$Q={name:`videoclips`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/clips-browser`,tab:`recording`,topTab:!0,label:`Clips`,order:100}},methods:{listClips:D(x({deviceId:r(),since:r(),until:r(),limit:r().int().positive().optional(),provider:u().min(1)}),C(zQ).readonly(),{kind:`query`,auth:`protected`}),listSources:D(x({deviceId:r()}),C(QQ).readonly(),{kind:`query`,auth:`protected`}),getClipPlayback:D(x({deviceId:r(),clipId:u(),profile:j.optional()}),BQ,{kind:`query`,auth:`protected`}),readClipBytes:O(x({deviceId:r(),clipId:u().min(1),provider:u().min(1),profile:j.optional(),maxBytes:r().int().positive().optional(),wake:VQ.optional()}),HQ,{kind:`query`,auth:`protected`}),offerClipBytes:O(x({deviceId:r(),clipId:u().min(1),provider:u().min(1),profile:j.optional(),maxBytes:r().int().positive().optional(),wake:VQ.optional()}),UQ,{kind:`query`,auth:`protected`}),dialClipStream:O(x({deviceId:r(),clipId:u().min(1),provider:u().min(1),profile:j.optional(),audio:WQ.optional(),wake:VQ.optional()}),KQ,{kind:`query`,auth:`protected`}),getPlaybackOptions:O(x({deviceId:r(),provider:u().min(1)}),XQ,{kind:`query`,auth:`protected`})},vocabulary:{noun:L(`Video clips`,`Clip video`),order:3330}},DEe={stream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:JQ},realtimeStream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:YQ},file:{transport:`file`,seek:`free`,stepBack:!0,scrub:!0,rates:qQ}},e$=r().min(.25).max(32),t$=x({fromSec:r().nonnegative(),toSec:r().nonnegative()}).refine(e=>e.toSec>e.fromSec,{message:`dense range must have toSec > fromSec`}),n$=x({everyMs:r().int().positive(),ranges:C(t$).min(1).max(200)}),r$=x({everyMs:r().int().positive(),outputFps:r().int().min(1).max(60).optional(),dense:n$.optional()}).superRefine((e,t)=>{e.dense!==void 0&&e.dense.everyMs>=e.everyMs&&t.addIssue({code:ue.custom,message:`dense.everyMs must be strictly smaller than the base everyMs`,path:[`dense`,`everyMs`]})}),i$=x({speed:e$.optional(),timelapse:r$.optional(),includeAudio:y(),maxLifeMs:r().int().positive(),deleteAfterDownload:y(),title:u().max(200).optional(),notifyTargetIds:C(u().min(1)).max(20).optional()}).superRefine((e,t)=>{e.speed!==void 0&&e.timelapse!==void 0&&t.addIssue({code:ue.custom,message:`speed and timelapse are mutually exclusive`,path:[`timelapse`]})}),a$=S([`queued`,`rendering`,`ready`,`failed`,`expired`,`deleted`]),o$=x({kind:m(`footage`),deviceId:r(),profiles:C(u()).min(1),fromMs:r(),toMs:r()}),s$=x({kind:m(`clip`),deviceId:r(),provider:u().min(1),source:u().min(1),sourceLabel:u().min(1),clipId:u().min(1),catalogWindow:x({sinceMs:r(),untilMs:r()}),profile:S([`high`,`mid`,`low`]),wake:VQ.optional()}),c$=a(`kind`,[o$,s$]),l$=x({id:u(),deviceId:r(),profile:u(),fromMs:r(),toMs:r(),subject:c$.optional(),options:i$,state:a$,progressPct:r().nullable(),fileBytes:r().nullable(),expiresAt:r(),deleteAfterDownload:y(),downloadedAt:r().nullable(),createdAt:r(),createdBy:u(),error:u().nullable()}),u$=S([`catalog-miss`,`catalog-unreachable`,`no-file-for-window`,`clip-in-progress`,`unsupported-option`,`sleeping`,`camera-refused`,`fetch-failed`,`too-large-to-transfer`,`wake-expired`,`wake-timeout`]);function OEe(e,t){return t.length>0?`${e}: ${t}`:e}function kEe(e){if(e===null)return null;let t=e.split(`:`,1)[0]??``,n=u$.safeParse(t.trim());return n.success?n.data:null}var d$=x({url:u(),endpoints:C(u())}),AEe=50*1024*1024,f$=x({base64:u(),contentType:u(),name:u(),bytes:r().int().nonnegative()});function p$(e){return e.profiles!==void 0&&e.profiles.length>0?[...e.profiles]:typeof e.profile==`string`&&e.profile.length>0?[e.profile]:[]}var jEe=x({deviceId:r(),profile:u().optional(),profiles:C(u()).min(1).optional(),fromMs:r().optional(),toMs:r().optional(),subject:c$.optional(),options:i$}).superRefine((e,t)=>{if(e.subject?.kind===`clip`){e.subject.deviceId!==e.deviceId&&t.addIssue({code:ue.custom,message:`subject.deviceId (${e.subject.deviceId}) must equal deviceId (${e.deviceId}) — the top-level field is what per-device scope enforcement reads`,path:[`subject`,`deviceId`]}),(e.fromMs!==void 0||e.toMs!==void 0)&&t.addIssue({code:ue.custom,message:`a clip export asks for no time range: the camera chose the boundaries and they are read from the catalog row`,path:[`fromMs`]});return}e.subject?.kind===`footage`&&e.subject.deviceId!==e.deviceId&&t.addIssue({code:ue.custom,message:`subject.deviceId (${e.subject.deviceId}) must equal deviceId (${e.deviceId})`,path:[`subject`,`deviceId`]});let n=e.subject?.kind===`footage`?e.subject.fromMs:e.fromMs,r=e.subject?.kind===`footage`?e.subject.toMs:e.toMs;(typeof n!=`number`||typeof r!=`number`)&&t.addIssue({code:ue.custom,message:`a footage export needs fromMs and toMs`,path:[`fromMs`]}),(e.subject?.kind===`footage`?[...e.subject.profiles]:p$(e)).length<1&&t.addIssue({code:ue.custom,message:`pass profiles[] (min 1) or legacy profile`,path:[`profiles`]})});function MEe(e){if(e.subject!==void 0)return e.subject;let t=p$(e);if(typeof e.fromMs!=`number`||typeof e.toMs!=`number`)throw Error(`recording-export: a footage export needs fromMs and toMs`);return{kind:`footage`,deviceId:e.deviceId,profiles:t,fromMs:e.fromMs,toMs:e.toMs}}function NEe(e){return e.subject===void 0?{kind:`footage`,deviceId:e.deviceId,profiles:[e.profile],fromMs:e.fromMs,toMs:e.toMs}:e.subject}var m$={name:`recording-export`,scope:`system`,mode:`singleton`,methods:{createExport:D(jEe,l$,{role:`viewer`,kind:`mutation`,auth:`protected`}),listExports:D(x({deviceId:r().optional()}),C(l$),{role:`viewer`,kind:`query`,auth:`protected`}),getExport:D(x({exportId:u()}),l$,{role:`viewer`,kind:`query`,auth:`protected`}),cancelExport:D(x({exportId:u()}),l$,{role:`viewer`,kind:`mutation`,auth:`protected`}),deleteExport:D(x({exportId:u()}),l$,{role:`viewer`,kind:`mutation`,auth:`protected`}),getDownloadUrl:D(x({exportId:u()}),d$,{role:`viewer`,kind:`query`,auth:`protected`}),readExportBytes:D(x({exportId:u()}),f$,{kind:`query`,auth:`protected`})},vocabulary:{notOperatorFacing:`recording exports — requested from the timeline, not an automation step`}},h$=S([`continuous`,`motion`,`person`,`vehicle`,`animal`,`lineCrossing`,`intrusion`,`loitering`,`alarmInput`]),g$=x({trigger:h$,day:r().int().min(0).max(6).meta(A(`none`)),startMinute:r().int().min(0).max(1439).meta(A(`none`)),endMinute:r().int().min(1).max(1440).meta(A(`none`))}),_$=x({id:u(),label:u().optional(),status:S([`ok`,`unformatted`,`error`,`offline`,`unknown`]),capacityMb:r().nullable(),freeMb:r().nullable(),writable:y().optional()}),v$=a(`kind`,[x({kind:m(`present`),volumes:C(_$)}),x({kind:m(`absent`),reason:u()}),x({kind:m(`unknown`),reason:u()})]),y$=x({id:u(),enabled:y(),isVideo:y(),codec:u().nullable(),resolution:u().nullable(),overwriteWhenFull:y().nullable()}),b$=x({storage:v$,tracks:C(y$),primaryTrackId:u().nullable(),enabled:y().nullable(),overwriteWhenFull:y().nullable(),preRecordSec:r().nullable().meta(A(`duration`)),postRecordSec:r().nullable().meta(A(`duration`)),segmentMinutes:r().nullable().meta(A(`none`)),windows:C(g$),unreadableWindows:r().meta(A(`count`)),recordingToNowhere:y(),lastFetchedAt:r()}),x$=x({min:r(),max:r(),step:r()}),S$=x({values:C(r()).min(1),sentinel:x({value:r(),meaning:S([`no-limit`,`disabled`])}).optional()}),C$=x({readable:y(),writable:y(),reason:u().optional()}),w$=x({support:C$,granularityMinutes:r(),triggers:C(h$),supportsOverlappingTriggers:y()}),T$=x({enabled:C$,overwriteWhenFull:C$,preRecordSec:C$,preRecordSecRange:x$.optional(),preRecordSecAllowed:S$.optional(),postRecordSec:C$,postRecordSecRange:x$.optional(),postRecordSecAllowed:S$.optional(),segmentMinutes:C$,segmentMinutesRange:x$.optional(),segmentMinutesAllowed:S$.optional(),schedule:w$}),E$=x({enabled:y().optional(),overwriteWhenFull:y().optional(),preRecordSec:r().optional(),postRecordSec:r().optional(),segmentMinutes:r().optional(),windows:C(g$).optional()}),D$={name:`recording-onboard`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`recording-onboard`,tab:`recording`}},methods:{getOptions:D(x({deviceId:r()}),T$),setSettings:D(x({deviceId:r(),settings:E$}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`recordingOnboard.on`,label:L(`On-camera recording on`,`Registrazione a bordo attiva`),phrase:L(`Turn on recording to the card of {device}`,`Attiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!0}}},{id:`recordingOnboard.off`,label:L(`On-camera recording off`,`Registrazione a bordo spenta`),phrase:L(`Turn off recording to the card of {device}`,`Disattiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!1}}}]})},status:{schema:b$,kind:`poll`},runtimeState:b$,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`On-camera recording`,`Registrazione a bordo`),order:3260,state:[{kind:`boolean`,field:`recordingToNowhere`,label:L(`Recording to nowhere`,`Registra nel vuoto`),whenTrue:L(`When {device} is recording with no card to write to`,`Quando {device} registra senza una scheda su cui scrivere`),whenFalse:L(`When {device} has a card to record to again`,`Quando {device} ha di nuovo una scheda su cui registrare`),icon:`hard-drive`}]}},O$=x({active:y(),reason:u(),lastChangedAt:r()}),k$=O$.extend({lastFetchedAt:r()}),A$={name:`recording-signal`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],methods:{getStatus:D(x({deviceId:r()}),O$)},status:{schema:O$,kind:`push`,empty:{active:!1,reason:`unknown`,lastChangedAt:0}},runtimeState:k$,durability:`session`,history:`none`,vocabulary:{noun:L(`Recording signal`,`Segnale di registrazione`),order:3270,state:[{kind:`boolean`,field:`active`,label:L(`Recording`,`In registrazione`),whenTrue:L(`When {device} starts recording`,`Quando {device} inizia a registrare`),whenFalse:L(`When {device} stops recording`,`Quando {device} smette di registrare`),icon:`circle-dot`}]}},j$=x({kind:m(`cap`),deviceId:r().int().nonnegative(),cap:u().min(1),method:u().min(1),args:h(u(),w()).optional(),argUnits:h(u(),u().min(1)).optional()}),M$=x({action:j$}),N$=x({key:u().refine(jT,{message:`a lowercase slug`}),name:u().min(1).max(60)});function PEe(e,t){let n=new Set,r=new Set,i=new Set;e.sources.forEach((a,o)=>{let s=(e,n)=>{t.addIssue({code:`custom`,message:e,path:[`sources`,o,n]})};n.has(a.id)&&s(`source id "${a.id}" is used twice`,`id`),n.add(a.id);let c=a.name.trim().toLowerCase();if(r.has(c)&&s(`source name "${a.name}" is used twice`,`name`),r.add(c),a.kind===`digits`&&(i.has(a.number)&&s(`channel ${a.number} is declared twice`,`number`),i.add(a.number)),a.kind===`ir`){let e=WT(a);e!==null&&s(e,`payload`)}for(let t of UT(a))OT(t)?s(`"${a.name}" presses ${t}, a layout widget, not a command`,`steps`):e.bindings[t]===void 0&&s(`"${a.name}" presses ${t}, which is not bound`,`steps`)}),e.sources.forEach((n,r)=>{for(let i of e.sources)if(!(i.kind!==`digits`||i===n))for(let e of[`name`,`id`])n[e].trim()===i.number&&t.addIssue({code:`custom`,message:`${e} "${n[e]}" is the channel number of "${i.name}"`,path:[`sources`,r,e]})})}var P$=x({index:r().int().nonnegative(),id:u().nullable(),name:u().nullable(),reason:u()}),F$=x({layoutTemplateId:u().min(1).nullable(),defaultTransmitterId:r().int().nonnegative().nullable().default(null),bindings:h(u(),M$),customButtons:C(N$).max(100),sources:C(VT).max(200).default([]),stepDelayMs:r().int().min(100).max(HT).default(500),refusedSources:C(P$).optional()}).superRefine((e,t)=>{let n=Object.keys(e.bindings);n.length>200&&t.addIssue({code:`custom`,message:`too many bindings`,path:[`bindings`]});for(let e of n)OT(e)?t.addIssue({code:`custom`,message:`"${e}" is a layout widget, not a command: it cannot be bound`,path:[`bindings`,e]}):PT(e)||t.addIssue({code:`custom`,message:`"${e}" is not a role`,path:[`bindings`,e]});let r=new Set;e.customButtons.forEach((e,n)=>{r.has(e.key)&&t.addIssue({code:`custom`,message:`custom button "${e.key}" is listed twice`,path:[`customButtons`,n,`key`]}),r.add(e.key)});for(let e of n){let n=NT(e);n!==null&&!r.has(n)&&t.addIssue({code:`custom`,message:`${e} is bound but has no entry in customButtons`,path:[`bindings`,e]})}PEe(e,t)}),FEe=ce({sources:C(w())}),IEe=x({id:u(),name:u()}).partial();function LEe(e){let t=FEe.safeParse(e);if(!t.success)return I$(F$.safeParse(e));let n=[],r=[];t.data.sources.forEach((e,t)=>{let i=VT.safeParse(e),a=i.success&&i.data.kind===`ir`?WT(i.data):null;if(i.success&&a===null){n.push(e);return}let o=IEe.safeParse(e),s=a??i.error?.issues[0]?.message??`not a source`;r.push({index:t,id:o.success?o.data.id??null:null,name:o.success?o.data.name??null:null,reason:s})});let i=I$(F$.safeParse({...t.data,sources:n}));return!i.success||r.length===0?i:{success:!0,data:{...i.data,refusedSources:r}}}function I$(e){return e.success?{success:!0,data:e.data}:{success:!1,issues:e.error.issues.length}}var REe={layoutTemplateId:null,defaultTransmitterId:null,bindings:{},customButtons:[],sources:[],stepDelayMs:500},zEe=x({power:x({state:S([`on`,`off`]),at:r()}).nullable(),muted:x({value:y(),at:r()}).nullable(),source:x({name:u(),at:r()}).nullable().default(null)}),BEe={power:null,muted:null,source:null},L$=[`rect`,`rounded`,`round`,`pill`],R$=S(L$),z$=[`neutral`,`accent`,`danger`,`red`,`green`,`yellow`,`blue`],B$=S(z$),V$=[`none`,`panel`,`divider`,`dpad`,`rocker-v`,`rocker-h`,`keypad`],H$=S(V$),U$=x({id:u().min(1).max(40),row:r().int().min(0).max(24),col:r().int().min(0).max(24),rowSpan:r().int().min(1).max(24),colSpan:r().int().min(1).max(24),icon:u().min(1).max(60).optional(),label:u().min(1).max(40).optional(),role:FT,shape:R$.optional(),tone:B$.optional(),showLegend:y().optional(),groupId:u().min(1).max(40).optional()}),W$=x({id:u().min(1).max(40),componentId:u().min(1).max(80),frame:H$,row:r().int().min(0).max(24),col:r().int().min(0).max(24),rowSpan:r().int().min(1).max(24),colSpan:r().int().min(1).max(24),title:u().min(1).max(40).optional(),size:S([`compact`,`normal`]).optional(),hideTitle:y().optional()});function G$(e,t){return e.row<t.row+t.rowSpan&&t.row<e.row+e.rowSpan&&e.col<t.col+t.colSpan&&t.col<e.col+e.colSpan}function K$(e,t){return t.row>=e.row&&t.col>=e.col&&t.row+t.rowSpan<=e.row+e.rowSpan&&t.col+t.colSpan<=e.col+e.colSpan}function VEe(e,t){let n=e.groups??[],r=new Map,i=(e,n)=>{t.addIssue({code:`custom`,message:e,path:n})};n.forEach((t,a)=>{r.has(t.id)&&i(`group id "${t.id}" is used twice`,[`groups`,a,`id`]),r.set(t.id,t),(t.row+t.rowSpan>e.rows||t.col+t.colSpan>e.columns)&&i(`group "${t.id}" leaves the grid`,[`groups`,a]);for(let e=0;e<a;e+=1){let r=n[e];if(r!==void 0&&G$(r,t)){i(`groups "${r.id}" and "${t.id}" overlap`,[`groups`,a]);return}}}),e.buttons.forEach((e,t)=>{if(e.groupId!==void 0){let n=r.get(e.groupId);if(n===void 0){i(`button "${e.id}" names the unknown group "${e.groupId}"`,[`buttons`,t,`groupId`]);return}n.frame===`divider`&&i(`a divider group ("${n.id}") holds no buttons`,[`buttons`,t,`groupId`]),K$(n,e)||i(`button "${e.id}" lies outside its group "${n.id}"`,[`buttons`,t]);return}let a=n.find(t=>G$(t,e));a!==void 0&&i(`button "${e.id}" lies inside group "${a.id}" but is not a member`,[`buttons`,t])})}var q$=x({columns:r().int().min(1).max(24),rows:r().int().min(1).max(24),buttons:C(U$).max(200),groups:C(W$).max(50).optional()}).superRefine((e,t)=>{let n=new Set,r=new Map;e.buttons.forEach((i,a)=>{if(n.has(i.id)&&t.addIssue({code:`custom`,message:`button id "${i.id}" is used twice`,path:[`buttons`,a,`id`]}),n.add(i.id),i.row+i.rowSpan>e.rows||i.col+i.colSpan>e.columns){t.addIssue({code:`custom`,message:`button "${i.id}" leaves the grid`,path:[`buttons`,a]});return}for(let e=i.row;e<i.row+i.rowSpan;e+=1)for(let n=i.col;n<i.col+i.colSpan;n+=1){let o=`${e}:${n}`,s=r.get(o);if(s!==void 0){t.addIssue({code:`custom`,message:`buttons "${s}" and "${i.id}" overlap`,path:[`buttons`,a]});return}r.set(o,i.id)}}),VEe(e,t)}),J$=x({role:FT,label:u().optional(),custom:y()}),Y$=x({layoutTemplateId:u().nullable(),commands:C(J$),sources:C(VT)}),X$=[`no-remote`,`unbound-role`,`action-failed`,`unknown-source`,`unbound-step`,`undeclared-channel`,`press-timeout`,`no-transmitter`],Z$=S(X$),Q$=a(`status`,[x({status:m(`sent`),sends:r().int().min(1)}),x({status:m(`skipped`),reason:m(`already-in-state`)}),x({status:m(`refused`),reason:Z$,detail:u().optional(),step:x({index:r().int().min(1),role:u()}).optional()})]),$$=[`play`,`pause`,`stop`,`next`,`previous`,`setMute`,`selectSource`,`playMedia`,`turnOn`,`turnOff`,`volumeUp`,`volumeDown`,`channelUp`,`channelDown`],e1=S($$),t1=a(`status`,[...Q$.options,x({status:m(`not-routed`)})]),n1=[`unknown-template`,`not-a-media-player`],r1=a(`status`,[x({status:m(`saved`)}),x({status:m(`refused`),reason:S(n1),detail:u()})]),i1=x({deviceId:r().int().nonnegative()}),HEe={version:1,targets:[{id:`remote`,cardinality:`config`,vocabulary:{cap:`remote`},deviceTypes:[M.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`}]},a1={name:`remote`,scope:`system`,mode:`singleton`,methods:{getConfig:D(i1,F$,{auth:`admin`}),setConfig:D(i1.extend({config:F$}),r1,{kind:`mutation`,auth:`admin`}),listCommands:D(i1,Y$,{auth:`protected`}),sendCommand:D(i1.extend({role:FT,repeat:r().int().min(1).max(50).default(1)}),Q$,{kind:`mutation`,auth:`protected`}),getAssumedStatus:D(i1,XT.nullable(),{auth:`protected`}),sendMediaCommand:D(i1.extend({command:e1,muted:y().optional(),source:u().optional(),mediaType:u().optional(),mediaId:u().optional(),repeat:r().int().min(1).max(50).default(1)}),t1,{kind:`mutation`,auth:`protected`})},customize:HEe,vocabulary:{notOperatorFacing:`the per-device remote setup — authored in the Customize remote editor, sent through the remote UI`}},o1=[`power`,`navigation`,`volume`,`numbers`,`media`,`colour`,`apps`,`layout`],s1=S(o1),UEe=/^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_-]*$/,c1=x({idSuffix:u().regex(/^[a-z0-9][a-z0-9_-]{0,19}$/,{message:`a short lowercase slug`}),row:r().int().min(0).max(24),col:r().int().min(0).max(24),rowSpan:r().int().min(1).max(24),colSpan:r().int().min(1).max(24),role:FT,icon:u().min(1).max(60).optional(),label:u().min(1).max(40).optional(),shape:R$.optional(),tone:B$.optional(),showLegend:y().optional()}),l1=x({id:u().max(80).regex(UEe,{message:`<namespace>:<name>, lowercase`}),name:u().min(1).max(60),nameI18n:x({en:u().min(1).max(60),it:u().min(1).max(60)}).optional(),icon:u().min(1).max(60),category:s1,size:x({rows:r().int().min(1).max(24),cols:r().int().min(1).max(24)}),group:x({frame:H$,title:u().min(1).max(40).optional()}).nullable(),buttons:C(c1).max(40)}).superRefine((e,t)=>{let n=new Set;e.buttons.forEach((r,i)=>{if(n.has(r.idSuffix)&&t.addIssue({code:`custom`,message:`button "${r.idSuffix}" is listed twice`,path:[`buttons`,i,`idSuffix`]}),n.add(r.idSuffix),r.row+r.rowSpan>e.size.rows||r.col+r.colSpan>e.size.cols){t.addIssue({code:`custom`,message:`button "${r.idSuffix}" leaves the component`,path:[`buttons`,i]});return}for(let n=0;n<i;n+=1){let a=e.buttons[n];if(a!==void 0&&G$(a,r)){t.addIssue({code:`custom`,message:`buttons "${a.idSuffix}" and "${r.idSuffix}" overlap`,path:[`buttons`,i]});return}}}),e.group?.frame===`divider`&&e.buttons.length>0&&t.addIssue({code:`custom`,message:`a divider component holds no buttons`,path:[`buttons`]})}),u1={name:`remote-layout-components`,scope:`system`,mode:`collection`,methods:{listComponents:D(x({}),C(l1),{auth:`protected`})},vocabulary:{notOperatorFacing:`the palette of the remote template editor — read-only data, never actuated`}},d1=x({deviceId:r().int().nonnegative(),resetToSource:y().optional()}),f1={name:`resync`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Container,M.Workload,M.WeatherStation],methods:{resync:D(d1,Dk,{kind:`mutation`,auth:`admin`,notOperatorFacing:`device adoption — re-aligning a device with its source is an onboarding step, not an automation action`})},vocabulary:{noun:L(`Re-sync`,`Risincronizzazione`),order:3245}},p1=3e4,m1=18e4,h1={startDwellMs:p1,stopDwellMs:m1,minSamples:2},g1={[M.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}};function _1(e){return e!==void 0&&g1[e]!==void 0}function v1(e){return e===void 0?h1:g1[e]??h1}var WEe={running:null,since:null,source:`native`,phase:null,lastFetchedAt:null},y1=S([`native`,`assigned`]),b1=x({running:y().nullable(),since:r().nullable().meta(A(`none`)),source:y1.meta({label:`Source`}),phase:u().nullable(),lastFetchedAt:r().nullable()}),x1=x({deviceId:r(),since:r().nullable(),phase:u().nullable()}),GEe=Object.values(M),S1=[M.Washer,M.Dryer,M.Dishwasher,M.Vacuum,M.LawnMower,M.MediaPlayer,M.WaterHeater,M.Humidifier,M.Fan,M.Climate,M.PetFeeder],KEe={version:1,overridable:[{path:`running`,by:`running`}],targets:[{id:`running`,cardinality:`scalar`,vocabulary:{cap:`running-state`,stateField:`running`},deviceTypes:S1,apply:`add`,path:`running`,sources:[{kind:`switch`,transforms:[{kind:`identity`}]},{kind:`binary`,transforms:[{kind:`identity`},{kind:`invert`}]},{kind:`numeric`,requiredUnit:`W`,transforms:[{kind:`threshold`,comparisons:[`gte`,`lte`],comparison:`gte`,defaultThreshold:5,defaultStartDwellMs:p1,defaultStopDwellMs:m1,deviceTypeDefaults:g1,thresholdUnit:`W`}]}],companions:[{kind:`constant`,path:`source`,value:`assigned`,when:`always`},{kind:`constant`,path:`phase`,value:null,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`always`},{kind:`transition-time`,path:`since`,sourceChangedAt:`prefer`}],sourceReport:{status:`assignment-status`,runtimeField:`source`,nativeValue:`native`,assignedValue:`assigned`},advancedExpression:!0}]},C1={name:`running-state`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:GEe,methods:{},events:{onStarted:{data:x1,trigger:{category:T.RunningStarted,label:L(`Started running`,`Ha iniziato a funzionare`),phrase:L(`When {device} starts running`,`Quando {device} inizia a funzionare`),icon:`play`}},onFinished:{data:x1,trigger:{category:T.RunningFinished,label:L(`Finished`,`Ha finito`),phrase:L(`When {device} finishes`,`Quando {device} finisce`),icon:`square`}}},status:{schema:b1,kind:`push`},runtimeState:b1,durability:`restored`,history:{fields:{running:{kind:`boolean`}}},volatileStateFields:[`lastFetchedAt`],customize:KEe,vocabulary:{noun:L(`Running`,`In funzione`),order:2120,state:[{kind:`boolean`,field:`running`,label:L(`Running`,`In funzione`),whenTrue:L(`When {device} starts`,`Quando {device} inizia`),whenFalse:L(`When {device} finishes`,`Quando {device} finisce`),icon:`play`}],overrides:{byType:{[M.Washer]:{state:{running:{whenTrue:L(`When the washing machine starts`,`Quando la lavatrice inizia`),whenFalse:L(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}},events:{onStarted:{phrase:L(`When the washing machine starts`,`Quando la lavatrice inizia`)},onFinished:{phrase:L(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}}},[M.Dryer]:{state:{running:{whenTrue:L(`When the dryer starts`,`Quando l'asciugatrice inizia`),whenFalse:L(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}},events:{onStarted:{phrase:L(`When the dryer starts`,`Quando l'asciugatrice inizia`)},onFinished:{phrase:L(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}}},[M.Dishwasher]:{state:{running:{whenTrue:L(`When the dishwasher starts`,`Quando la lavastoviglie inizia`),whenFalse:L(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}},events:{onStarted:{phrase:L(`When the dishwasher starts`,`Quando la lavastoviglie inizia`)},onFinished:{phrase:L(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}}}}}}},w1=u(),qEe=[`day`,`ir`,`night`,`dawn`,`dusk`],T1=S([`skip`,`judge-anyway`]),JEe=`__diverged__`,E1=S([`matched`,`diverged`,`unknown`]),D1=S([`no-reference-for-condition`,`view-shifted`,`no-vision-profile`,`encoder-model-changed`,`no-snapshot`]),O1=x({embedding:C(r()),modelId:u(),condition:w1,capturedAt:r(),thumbnailMediaId:r().int().optional(),anchorEmbedding:C(r()).optional()}),k1=x({id:u(),label:u(),references:C(O1),textPrompts:C(u()).optional(),referenceCount:r(),currentlyMatched:y()}),A1=a(`mode`,[x({mode:m(`similarity`),threshold:r().min(0).max(1),hysteresisCount:r().int().positive()}),x({mode:m(`llm`),prompt:u(),profileId:u().optional(),hysteresisCount:r().int().positive()})]),j1=.85,M1=`skip`,N1=8e3,P1=x({enabled:y().default(!1),prompt:u().min(1).max(1e3),profileId:u().optional(),timeoutMs:r().int().min(1e3).max(2e4).default(N1),maxImagePx:r().int().min(64).max(2048).default(448),onTimeout:S([`flip`,`hold`]).default(`hold`)}),F1=x({id:u(),label:u(),roi:CV,enabled:y(),triggerMode:S([`periodic`,`on-motion`,`both`]),checkIntervalSec:r().optional(),check:A1,states:C(k1),currentStateId:u().nullable(),lastCheckedAt:r().nullable(),lastConfidence:r().nullable(),currentCondition:w1.nullable(),availability:S([`ok`,`unavailable`]),unavailableReason:u().nullable(),baselineStateId:u().nullable(),emit:S([`latched`,`live`]).default(`latched`),verdict:E1,latched:y(),armedAt:r(),divergedAt:r().nullable(),restoredAt:r().nullable(),quietSeconds:r().int().min(0).max(3600).default(60),minObservationSpacingSec:r().int().min(0).max(3600).default(120),confirm:P1.optional(),anchorThreshold:r().min(0).max(1).default(j1),autoRestore:y().default(!1),onUncoveredCondition:T1.default(M1),suspendedCondition:w1.nullable().default(null),unavailable:D1.nullable(),coveredConditions:C(w1)}),I1=x({monitors:C(F1),lastFetchedAt:r()}),L1=x({deviceId:r(),status:I1.nullable()}),R1={name:`scene-monitor`,role:{feature:`scenes`},scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Camera],methods:{listScenes:D(x({deviceId:r()}),I1),listScenesBatch:D(x({deviceIds:C(r()).min(1).max(200)}),C(L1).readonly()),createScene:D(x({deviceId:r(),label:u(),roi:CV,check:A1,triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:r().optional()}),F1,{kind:`mutation`,auth:`admin`}),updateScene:D(x({deviceId:r(),monitorId:u(),patch:x({label:u().optional(),roi:CV.optional(),enabled:y().optional(),triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:r().optional(),check:A1.optional(),emit:S([`latched`,`live`]).optional(),quietSeconds:r().int().min(0).max(3600).optional(),minObservationSpacingSec:r().int().min(0).max(3600).optional(),anchorThreshold:r().min(0).max(1).optional(),autoRestore:y().optional(),onUncoveredCondition:T1.optional(),confirm:P1.nullable().optional()})}),v(),{kind:`mutation`,auth:`admin`}),deleteScene:D(x({deviceId:r(),monitorId:u()}),v(),{kind:`mutation`,auth:`admin`}),captureReference:D(x({deviceId:r(),monitorId:u(),stateId:u().optional(),label:u().optional(),condition:w1.optional()}),x({stateId:u(),referenceCount:r()}),{kind:`mutation`,auth:`admin`}),deleteReference:D(x({deviceId:r(),monitorId:u(),stateId:u(),index:r()}),v(),{kind:`mutation`,auth:`admin`}),recheckNow:D(x({deviceId:r(),monitorId:u()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`sceneMonitor.recheck`,label:L(`Re-check a scene`,`Ricontrolla una scena`),phrase:L(`Re-check {monitorId} on {device} now`,`Ricontrolla subito {monitorId} su {device}`),icon:`scan-search`,openArgs:[{key:`monitorId`,label:L(`Scene`,`Scena`),offer:{kind:`dynamic`,from:`status`,field:`monitors`,valueKey:`id`,labelKey:`label`}}]}]}),resetScene:D(x({deviceId:r(),monitorId:u(),recapture:y().optional()}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:I1,kind:`push`},runtimeState:I1,durability:`session`,history:`none`,vocabulary:{noun:L(`Scene watch`,`Controllo della scena`),order:3280,extraEvents:[{category:T.EnrichmentSceneStateChanged,label:L(`Scene changed`,`Scena cambiata`),phrase:L(`When a watched scene on {device} changes`,`Quando cambia una scena controllata su {device}`),icon:`scan-search`}]}},z1=x({schedulerId:u().min(1)}),B1={name:`schedulers`,scope:`system`,mode:`singleton`,methods:{list:D(x({}),C(F_),{auth:`admin`}),get:D(z1,x({scheduler:F_.nullable()}),{auth:`admin`}),create:D(x({scheduler:P_}),x({scheduler:F_}),{kind:`mutation`,auth:`admin`}),update:D(x({schedulerId:u().min(1),scheduler:P_}),x({scheduler:F_}),{kind:`mutation`,auth:`admin`}),delete:D(z1,v(),{kind:`mutation`,auth:`admin`}),setEnabled:D(x({schedulerId:u().min(1),profileId:u().min(1).optional(),enabled:y()}),x({scheduler:F_}),{kind:`mutation`,auth:`admin`}),preview:D(x({schedulerId:u().min(1),date:u().regex(L_).optional()}),pde,{auth:`admin`}),conflicts:D(x({scheduler:P_,schedulerId:u().min(1).optional()}),x({conflicts:C(mde)}),{auth:`admin`}),getStatus:D(x({}),C(gde),{auth:`admin`}),getTraces:D(z1,x({traces:C(V_)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`time schedulers — authored on their own page, not device actions`}},V1=x({isRunning:y(),lastRunAt:r(),lastRunSuccess:y().nullable(),lastError:u().nullable(),lastChangedAt:r()}),H1={name:`script-runner`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Script],methods:{run:D(x({deviceId:r().int().nonnegative(),variables:h(u(),w()).optional()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.run`,label:L(`Run script`,`Esegui lo script`),phrase:L(`Run {device}`,`Esegui {device}`),icon:`scroll-text`,hold:{effects:[{field:`isRunning`,value:!0}],holdMs:dY}}]}),stop:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.stop`,effect:{field:`isRunning`,value:!1},label:L(`Stop script`,`Ferma lo script`),phrase:L(`Stop {device}`,`Ferma {device}`),icon:`square`}]})},status:{schema:V1,kind:`push`},runtimeState:V1,durability:`session`,history:`none`,vocabulary:{noun:L(`Script`,`Script`),order:2090,state:[{kind:`boolean`,field:`isRunning`,label:L(`Running`,`In esecuzione`),whenTrue:L(`When {device} starts running`,`Quando {device} parte`),whenFalse:L(`When {device} finishes`,`Quando {device} termina`),icon:`scroll-text`}]}},U1=S([`workspace`,`baked`,`data-root`]),W1=S([`idle`,`checking`,`staging`,`pending-restart`,`awaiting-confirmation`]),G1=S([`in-sync`,`behind-patch`,`behind-series`,`ahead`,`unknown`]),K1=x({state:G1,seedVersion:u().nullable(),contractVersion:u().nullable(),contractSource:S([`registry`,`running`]).nullable(),message:u()}),q1=S([`docker`,`electron`,`native`,`contradictory`,`unknown`]),J1=x({fact:S([`dockerenv-file`,`proc-1-cgroup`,`platform`,`electron-app-version-env`]),mode:S([`observed`,`declared`]),holds:y(),detail:u()}),Y1=x({kind:q1,evidence:C(J1),currentVersion:u().nullable()}),X1=x({fromVersion:u(),toVersion:u().nullable(),atMs:r(),reason:u()}),Z1=x({version:u(),update:x({available:y(),downloaded:y(),version:u().nullable(),checking:y(),error:u().nullable()}),stateAtMs:r(),stale:y()}),Q1=S([`not-electron`,`no-app-state`,`app-state-stale`,`not-downloaded`]),$1=x({accepted:y(),reason:Q1.nullable()}),e0=x({runnerId:u(),addonIds:C(u()),reason:u()}),t0=x({checkedAtMs:r(),expected:r(),running:r(),failed:C(u()),refused:C(e0),missing:C(u()),pending:C(u()).optional(),planKnown:y()}),n0=x({packageName:u(),runningVersion:u().nullable(),nodeRuntimeVersion:u().nullable(),activeVersion:u().nullable(),installedVersion:u().nullable().optional(),restartRequired:y().optional(),previousVersion:u().nullable(),seedVersion:u().nullable(),latestVersion:u().nullable(),updateAvailable:y(),bootMode:U1,updateState:W1,pendingVersion:u().nullable(),rolledBack:X1.nullable(),stateFileCorrupt:y(),lastCheckedAtMs:r().nullable(),imageContract:K1.optional(),wrapper:Y1.optional(),runners:t0.optional(),desktopApp:Z1.optional()}),r0=x({packageName:u(),runningVersion:u().nullable(),latestVersion:u().nullable(),updateAvailable:y(),checkedAtMs:r(),error:u().nullable(),pendingVersion:u().nullable().optional(),restartRequired:y().optional()}),i0=S([`staged`,`restart-scheduled`,`already-current`,`refused`,`failed`]),a0=x({addonId:u(),reason:u(),remedy:u()}),o0=x({accepted:y(),targetVersion:u().nullable(),restarting:y(),message:u(),outcome:i0.optional(),reason:u().nullable().optional(),error:u().nullable().optional(),blockers:C(a0).optional(),unmet:C(ti).optional(),requiredAddonUpdates:C(ni).optional()}),s0=x({heapMb:r().int().nullable(),rssBudgetMb:r().int().nullable()}),YEe=x({heapMb:r().int().min(512).max(65536).nullable(),rssBudgetMb:r().int().min(512).max(65536).nullable().optional()}),XEe=s0.extend({restartRequired:y()}),c0={name:`server-management`,scope:`system`,mode:`singleton`,methods:{getServerPackageStatus:D(v(),n0,{auth:`admin`}),checkServerUpdate:D(v(),r0,{kind:`mutation`,auth:`admin`}),applyServerUpdate:D(x({version:u().optional(),acknowledgeRefusals:y().optional()}),o0,{kind:`mutation`,auth:`admin`,timeoutMs:16*6e4}),installDesktopUpdate:D(v(),$1,{kind:`mutation`,auth:`admin`}),rollbackServerUpdate:D(v(),o0,{kind:`mutation`,auth:`admin`}),restartServer:D(v(),o0,{kind:`mutation`,auth:`admin`}),getLaunchOverrides:D(v(),s0,{auth:`admin`}),setLaunchOverrides:D(YEe,XEe,{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:k.CLUSTER}},l0={Seconds:`seconds`,Plays:`plays`},u0={Camera:`camera`,Fallback:`fallback`},d0=x({min:r().positive(),max:r().positive(),step:r().positive()}),f0=x({allowedSeconds:C(r().positive()).nullable(),rangeSeconds:d0.nullable(),defaultSeconds:r().positive(),allowedPlays:C(r().int().positive()).nullable().default(null),rangePlays:d0.nullable().default(null),defaultPlays:r().int().positive().nullable().default(null),unit:S([l0.Seconds,l0.Plays]),secondsPerPlay:r().positive().nullable(),source:S([u0.Camera,u0.Fallback]),fetchedAt:r()}),p0=x({active:y(),activeUntil:r().nullable(),durationSeconds:r().nullable(),plays:r().int().positive().nullable().default(null),activeUntilEstimated:y().default(!1),lastTriggeredAt:r()}),m0=x({deviceId:r().int().nonnegative(),durationSeconds:r().positive().optional(),plays:r().int().positive().optional()}).refine(e=>e.durationSeconds===void 0||e.plays===void 0,{message:`a siren trigger takes durationSeconds or plays, not both`,path:[`plays`]}),h0=p0.extend({lastFetchedAt:r()}),g0={name:`siren`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Siren],methods:{getOptions:D(x({deviceId:r().int().nonnegative()}),f0,{kind:`query`,auth:`protected`}),getPlayChoices:D(x({deviceId:r().int().nonnegative()}),C(r().int().positive()),{kind:`query`,auth:`protected`}),trigger:D(m0,p0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.trigger`,label:L(`Sound the siren`,`Fai suonare la sirena`),phrase:L(`Sound {device}`,`Fai suonare {device}`),icon:`siren`,args:{}},{id:`siren.triggerPlays`,label:L(`Sound the siren N times`,`Fai suonare la sirena N volte`),phrase:L(`Sound {device} {plays} times`,`Fai suonare {device} {plays} volte`),icon:`siren`,openArgs:[{key:`plays`,label:L(`Plays`,`Riproduzioni`),offer:{kind:`dynamic`,from:`method`,method:`getPlayChoices`,valueKind:`number`}}]}]}),stop:D(x({deviceId:r().int().nonnegative()}),p0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.stop`,label:L(`Silence the siren`,`Zittisci la sirena`),phrase:L(`Silence {device}`,`Zittisci {device}`),icon:`siren`,effect:{field:`active`,value:!1},args:{}}]})},events:{onSirenChanged:{data:x({deviceId:r(),active:y(),activeUntil:r().nullable()}),notOperatorFacing:"the `active` state trigger phrases both edges of this change"}},status:{schema:p0,kind:`command-driven`},runtimeState:h0,durability:`session`,history:`none`,vocabulary:{noun:L(`Siren`,`Sirena`),order:1170,state:[{kind:`boolean`,field:`active`,label:L(`Siren sounding`,`Sirena in funzione`),whenTrue:L(`When {device} starts sounding`,`Quando {device} inizia a suonare`),whenFalse:L(`When {device} falls silent`,`Quando {device} smette di suonare`),icon:`siren`}]}},_0=x({detected:y(),lastChangedAt:r()}),v0={name:`smoke`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:_0,kind:`push`},runtimeState:_0,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Smoke detector`,`Rilevatore di fumo`),order:5190,state:[{kind:`boolean`,field:`detected`,label:L(`Detected`,`Rilevato`),whenTrue:L(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:L(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}]}},y0=5*1024*1024,b0=`<!--camstack-images-->`,x0=x({ticket:io,mime:u().min(1),name:u().min(1),contentId:u().min(1),placement:S([`inline`,`attachment`]),deviceId:r().int().nonnegative().optional()}),S0=0;function C0(e){return S0+=1,`camstack_${e}_${S0.toString(36)}_${Date.now().toString(36)}`}function ZEe(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,`utf8`).toString(`base64`)}?=`}function w0(e){return(Array.isArray(e)?e:[e]).join(`, `)}function QEe(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function T0(e,t){let n=e.replace(/[\r\n"]/g,``).trim();return n.length>0?n:t}function $Ee(e){let t=Buffer.from(e).toString(`base64`),n=[];for(let e=0;e<t.length;e+=76)n.push(t.slice(e,e+76));return n.join(`\r
1113
+ `)}function nA(e){return e.replaceAll(`|`,`\\|`)}function Dye(){let e=[];for(let t of Object.values(Wh))e.includes(t.dimension)||e.push(t.dimension);return e.map(e=>({group:e,choices:$h(e).map(e=>({value:e}))}))}function rA(e,t){if(e===void 0)return[];if(e.kind===`choices`)return[{group:null,choices:e.options.map(e=>({...e}))}];if(e.kind===`range`){let t=[],n=Math.floor((e.max-e.min)/e.step+1e-9);for(let r=0;r<=n;r+=1)t.push({value:String(e.min+r*e.step)});return[{group:null,choices:t}]}let n=t===void 0?void 0:qh(t);return n===void 0?Dye():[{group:n,choices:$h(n).map(e=>({value:e}))}]}var iA=4096,Oye=4096,aA=u().min(1).max(iA),kye=`camera`,oA=g([u(),r(),y()]),sA=x({deviceId:r().int(),values:h(u().min(1).max(64),oA).optional()}),Aye=`values`,jye=Xk(),cA=[`too-long`,`syntax`,`forbidden-syntax`,`forbidden-member`,`unknown-filter`,`ambiguous-field`,`busy`,`budget-exceeded`,`timeout`,`output-too-large`,`render-failed`,`out-of-scope`,`unavailable`],lA=x({reason:S(cA),message:u()}),uA=[`unknown-alias`,`unknown-field`,`no-field`,`unavailable`],dA=x({ref:u(),reason:S(uA)}),fA=a(`ok`,[x({ok:m(!0),text:u(),trace:C(dA)}),x({ok:m(!1),refusal:lA,trace:C(dA)})]);function pA(e){return e.replace(/-/g,`_`)}function mA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function hA(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(mA(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function Mye(e,t){let n=t[0];if(n===void 0)return{kind:`missing`,reason:`no-field`};let r=Object.keys(e.slices),i=r.find(e=>e===n||pA(e)===n);if(i!==void 0){let n=t.slice(1);if(n.length===0)return{kind:`missing`,reason:`no-field`};let r=hA(e.slices[i],n);return r===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:i,fieldPath:n,value:r}}let a=r.filter(t=>{let r=e.slices[t];return mA(r)&&Object.hasOwn(r,String(n))});if(a.length===0)return{kind:`missing`,reason:`unknown-field`};let[o]=a;if(a.length>1||o===void 0)return{kind:`ambiguous`,field:String(n),caps:a};let s=hA(e.slices[o],t);return s===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:o,fieldPath:t,value:s}}var gA=x({zoneKey:u(),label:u(),icon:md.nullable(),locationKeys:C(u())});function Nye(e){return e.trim().toLowerCase()}var _A=[`mac`,`serial`,`machine-uuid`,`vendor-uid`,`hostname`,`ip`],vA=S(_A),yA=S([`read`,`derived`]),Pye=/^[0-9a-f]{2}(?::[0-9a-f]{2}){5}$/,bA=/^[a-z0-9][a-z0-9._-]*:[^\sA-Z]+$/,xA=/^[0-9a-f][0-9a-f-]{7,}$/,SA=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function CA(e){return x({value:e,origin:yA,readAt:r().int().nonnegative()}).strict()}var Fye=CA(u().regex(Pye)),Iye=CA(u().regex(bA)),Lye=CA(u().regex(xA)),Rye=CA(u().regex(bA)),zye=CA(u().regex(SA)),Bye=CA(g([ee(),s()])),Vye=x({value:u().min(1),origin:yA,readAt:r().int().nonnegative()}).strict(),wA=x({mac:C(Fye).min(1).readonly().optional(),serial:Iye.optional(),"machine-uuid":Lye.optional(),"vendor-uid":Rye.optional(),hostname:zye.optional(),ip:Bye.optional()}).strict(),Hye={mac:`strong`,serial:`strong`,"machine-uuid":`strong`,"vendor-uid":`strong`,hostname:`weak`,ip:`weak`};function TA(e){return Hye[e]}function EA(e){return _A.every(t=>e[t]===void 0)}var Uye=/^(?:unknown|none|n\/?a|null|undefined|default|0+|-+)$/i,Wye=new Set([`00:00:00:00:00:00`,`ff:ff:ff:ff:ff:ff`]);function DA(e){return{ok:!1,reason:e}}function OA(e){let t=e.trim().toLowerCase().replace(/[\s:.-]/g,``);if(!/^[0-9a-f]{12}$/.test(t))return DA(`not a 48-bit MAC`);let n=(t.match(/../g)??[]).join(`:`);return Wye.has(n)?DA(`placeholder MAC`):{ok:!0,value:n}}function Gye(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[-._]+|[-._]+$/g,``)}function kA(e,t,n){let r=Gye(e);if(r.length===0)return DA(`no ${n}`);let i=t.trim().toLowerCase().replace(/\s+/g,``);return i.length===0?DA(`blank value`):Uye.test(i)?DA(`placeholder value`):{ok:!0,value:`${r}:${i}`}}function Kye(e){let t=e.trim().toLowerCase().replace(/^\{|\}$/g,``);return xA.test(t)?/^[0-]+$/.test(t)||/^[f-]+$/.test(t)?DA(`placeholder uuid`):{ok:!0,value:t}:DA(`not a uuid`)}function AA(e){return g([ee(),s()]).safeParse(e).success}function qye(e){let t=e.trim().toLowerCase().replace(/\.$/,``);if(t.length===0)return DA(`blank hostname`);if(AA(t))return DA(`an address, not a hostname`);let n=t.split(`.`)[0]??``;return SA.test(n)?n===`localhost`?DA(`placeholder hostname`):{ok:!0,value:n}:DA(`not a hostname`)}function Jye(e){let t=e.trim().toLowerCase().replace(/^\[|\]$/g,``);return AA(t)?t===`0.0.0.0`||t===`::`||t===`::1`||t.startsWith(`127.`)?DA(`loopback or unspecified address`):{ok:!0,value:t}:DA(`not an IP address`)}function jA(e){return e==null||e.trim().length===0}function MA(e,t={}){let n=t.readAt??Date.now(),r=e=>t.originByKey?.[e]??t.origin??`read`,i=(e,t)=>({value:t,origin:r(e),readAt:n}),a=[],o=(e,t,n)=>{if(n.ok)return i(e,n.value);a.push({key:e,value:t,reason:n.reason})},s=e.mac===null||e.mac===void 0?[]:[e.mac].flat(),c=[];for(let e of s){if(jA(e))continue;let t=o(`mac`,e,OA(e));t!==void 0&&!c.some(e=>e.value===t.value)&&c.push(t)}let l=e.serial===null||e.serial===void 0||jA(e.serial.serial)?void 0:o(`serial`,`${e.serial.manufacturer}:${e.serial.serial}`,kA(e.serial.manufacturer,e.serial.serial,`manufacturer`)),u=e.vendorUid===null||e.vendorUid===void 0||jA(e.vendorUid.id)?void 0:o(`vendor-uid`,`${e.vendorUid.vendor}:${e.vendorUid.id}`,kA(e.vendorUid.vendor,e.vendorUid.id,`vendor`)),d=jA(e.machineUuid)?void 0:o(`machine-uuid`,e.machineUuid,Kye(e.machineUuid)),f=jA(e.host)?null:e.host.trim(),p=f!==null&&AA(f.toLowerCase().replace(/^\[|\]$/g,``)),m=jA(e.hostname)?p?null:f:e.hostname,h=jA(e.ip)?p?f:null:e.ip,g=m===null?void 0:o(`hostname`,m,qye(m)),_=h===null?void 0:o(`ip`,h,Jye(h));return{identifiers:{...c.length>0?{mac:c}:{},...l===void 0?{}:{serial:l},...d===void 0?{}:{"machine-uuid":d},...u===void 0?{}:{"vendor-uid":u},...g===void 0?{}:{hostname:g},..._===void 0?{}:{ip:_}},rejected:a}}function NA(e,t){return e.value===t.value&&e.origin===t.origin}function PA(e,t){return t!==void 0&&NA(e,t)?t:e}function Yye(e,t,n=[]){let r=e??{},i=t??{},a=new Set(n),o=a.has(`mac`)?r.mac:i.mac?.map(e=>PA(e,r.mac?.find(t=>NA(t,e)))),s=e=>{if(a.has(e))return r[e];let t=i[e];return t===void 0?void 0:PA(t,r[e])},c=s(`serial`),l=s(`machine-uuid`),u=s(`vendor-uid`),d=s(`hostname`),f=s(`ip`),p={...o!==void 0&&o.length>0?{mac:o}:{},...c===void 0?{}:{serial:c},...l===void 0?{}:{"machine-uuid":l},...u===void 0?{}:{"vendor-uid":u},...d===void 0?{}:{hostname:d},...f===void 0?{}:{ip:f}};return EA(p)?null:p}function Xye(e,t){let n=e=>e==null||EA(e)?``:JSON.stringify(_A.map(t=>[t,e[t]??null]).map(([e,t])=>[e,t===null?null:[t].flat().map(e=>[e.value,e.origin,e.readAt])]));return n(e)===n(t)}var FA=S([`auto`,`proposal`]),IA=x({key:vA,value:u()}),LA=x({deviceId:r().int(),addonId:u(),integrationId:u().nullable()}),RA=x({a:LA,b:LA,keys:C(IA).readonly(),confidence:FA}),zA=a(`status`,[x({status:m(`unknown`),reason:u()}),x({status:m(`answered`),pairs:C(RA).readonly(),undeclaredDeviceIds:C(r().int()).readonly()})]),BA=[`same-device`,`poe-power`],VA=S(BA),HA=S([`proposed`,`linked`,`dismissed`]),UA=S([`auto`,`operator`]),WA=x({addonId:u().min(1),stableId:u().min(1),deviceId:r().int()}),GA=x({kind:VA,a:WA,b:WA,state:HA,origin:UA,evidence:C(IA).readonly(),evidenceGone:m(!0).optional(),createdAt:r().int().nonnegative(),decidedAt:r().int().nonnegative().optional()}),KA=GA.extend({id:u().min(1)}),qA={"same-device":{directional:!1,attachingRole:null,contributions:[]},"poe-power":{directional:!0,attachingRole:P.PoePort,contributions:[{cap:`power-source`,targetId:`switch`,host:`b`,source:`a`,sourceCap:`switch`,sourceField:`on`}]}};function Zye(e,t){let n=qA[e].attachingRole;return n===null||t===n?null:`attaching-side-role`}function JA(e){return`${e.addonId}/${e.stableId}`}function Qye(e,t,n){let r=JA(t),i=JA(n);return qA[e].directional||r<=i?`${e}:${r}|${i}`:`${e}:${i}|${r}`}var YA=a(`status`,[x({status:m(`not-loaded`),reason:u()}),x({status:m(`answered`),links:C(KA).readonly()})]),XA=S([`not-loaded`,`unknown-link`,`wrong-state`]),ZA=a(`ok`,[x({ok:m(!0),link:KA}),x({ok:m(!1),reason:XA,message:u()})]),QA=S([`evidence-gone`,`device-removed`,`operator-unlinked`]),$ye=x({linkId:u(),kind:VA,aDeviceId:r().int(),bDeviceId:r().int(),origin:UA,reason:QA.optional()}),$A=x({caps:C(u()).readonly().optional(),actions:C(u()).readonly().optional(),mode:S([`any`,`all`]).optional()}),ej=x({locations:C(u()).readonly().optional(),integrationIds:C(u()).readonly().optional(),types:C(u()).readonly().optional()}),tj=x({text:u().optional(),requires:$A.optional(),filters:ej.optional(),includeIncompatible:y().optional(),contextDeviceId:r().optional(),ids:C(r()).readonly().optional(),cursor:u().nullable().optional(),limit:r().int().min(1).max(200).optional()}),nj=x({cap:u(),path:u(),label:u(),reading:u().nullable(),unit:u().nullable().optional(),quantity:bc.optional()}),rj=x({id:r(),name:u(),type:S(M),location:u().nullable(),integrationId:u().nullable(),integrationLabel:u().nullable(),online:y().nullable(),disabled:y(),compatible:y(),values:C(nj).readonly()}),ij=x({value:u(),count:r()}),aj=x({id:u(),label:u(),count:r()}),oj=x({locations:C(ij).readonly(),integrations:C(aj).readonly(),types:C(ij).readonly()}),sj=x({items:C(rj).readonly(),nextCursor:u().nullable(),total:r(),compatibleTotal:r(),fleetTotal:r(),hiddenIncompatible:r(),facets:oj,suggested:C(rj).readonly(),missingIds:C(r()).readonly()}),cj=x({connected:y(),deviceCount:r(),error:u().optional(),motionSliceWriter:m(`orchestrator`).optional()}),ebe=x({externalId:u(),name:u(),type:u(),metadata:h(u(),w()).optional()}),lj=a(`kind`,[x({kind:m(`mdns`),serviceType:u().min(1),instancePattern:u().optional()}),x({kind:m(`ws-discovery`),types:C(u()).optional()}),x({kind:m(`ssdp`),searchTarget:u().min(1)}),x({kind:m(`udp-broadcast`),port:r().int().min(1).max(65535),payloadHex:u().regex(/^([0-9a-fA-F]{2})*$/),listenPort:r().int().min(1).max(65535).optional()}),x({kind:m(`http-probe`),port:r().int().min(1).max(65535),path:u().startsWith(`/`),method:S([`GET`,`POST`]).default(`GET`),bodyText:u().optional(),contentType:u().optional(),tls:y().default(!1),acceptStatus:C(r().int()).optional()}),x({kind:m(`custom`),reason:u().min(1)})]),uj=x({modeIndex:r().int().min(0),host:u(),port:r().int(),http:x({status:r().int(),headers:h(u(),u()),bodyText:u()}).optional(),mdns:x({instance:u(),host:u(),port:r().int(),txt:h(u(),u())}).optional(),udp:x({payloadHex:u()}).optional(),wsd:x({xaddrs:C(u()),types:C(u()),scopes:C(u())}).optional()}),dj=x({stableId:u(),type:S(M),suggestedName:u(),prefilledConfig:h(u(),w()),sourceInfo:Rh.optional(),alreadyOnboarded:y().optional(),onboardedDeviceId:r().optional(),onboardedName:u().optional(),setupIntegration:y().optional(),parentStableId:u().optional(),selectable:y().optional(),needsParams:C(u()).optional()}),fj=x({id:r(),stableId:u(),addonId:u(),type:u(),name:u(),parentDeviceId:r().nullable(),online:y(),features:C(u()),config:h(u(),w()),sourceInfo:Rh.optional()}),pj=x({status:S([`ok`,`error`]),labels:C(u()).optional(),error:u().optional()}),mj=w(),hj={name:`device-provider`,scope:`system`,mode:`collection`,methods:{start:D(v(),v(),{kind:`mutation`}),stop:D(v(),v(),{kind:`mutation`}),getStatus:D(v(),cj),getDevices:D(v(),C(x({id:u(),name:u(),type:u()}))),reloadDevice:D(x({stableId:u()}),x({deviceId:r()}),{kind:`mutation`,timeoutMs:3*6e4}),supportsDiscovery:D(x({}),y()),discoverDevices:D(x({params:h(u(),w()).optional()}),C(dj),{kind:`mutation`,auth:`admin`}),getDiscoveryModes:D(x({}),C(lj)),classifyDiscoveryHits:D(x({hits:C(uj),params:h(u(),w()).optional()}),C(dj),{kind:`mutation`,auth:`admin`}),getDiscoveryParamsSchema:D(x({}),mj),getManualCreationType:D(x({integrationId:u().optional()}),x({deviceType:S(M).nullable()})),adoptDiscoveredDevice:D(x({candidate:dj,integrationId:u().optional()}),fj,{kind:`mutation`,auth:`admin`}),supportsManualCreation:D(x({}),y()),getChildCreationSchema:D(x({type:S(M),integrationId:u().optional()}),mj),createDevice:D(x({type:S(M),config:h(u(),w()),integrationId:u().optional()}),fj,{kind:`mutation`,auth:`admin`}),testCreationField:D(x({type:S(M),key:u(),value:w(),formValues:h(u(),w()).optional()}),pj,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.INTERNAL}},gj=a(`kind`,[x({kind:m(`mdns`),serviceType:u(),instance:u(),host:u(),address:u().nullable(),port:r().int(),txt:h(u(),u())}),x({kind:m(`ssdp`),host:u(),port:r().int(),target:u(),headers:h(u(),u())})]),tbe=x({addonId:u(),candidate:dj,firstSeenAt:r(),lastSeenAt:r(),dismissed:y()}),_j=x({id:u(),addonId:u(),candidate:dj,firstSeenAt:r(),lastSeenAt:r(),dismissed:y()}),vj=x({childKey:u(),section:u(),order:r().optional(),collapsed:y().optional()}),nbe=x({unit:u().min(1).optional(),precision:r().int().min(0).max(10).optional()}),yj=x({icon:u().min(1).optional(),label:u().min(1).optional(),unit:u().min(1).optional(),precision:r().int().min(0).max(10).optional(),hidden:y().optional(),perCap:h(u(),nbe).optional()}),bj=x({unit:u().min(1).optional(),precision:r().int().min(0).max(10).optional(),icon:u().min(1).optional()}),xj=x({id:r(),stableId:u(),addonId:u(),type:S(M),name:u(),alias:Nk.optional(),location:u().nullable(),tags:Td.optional(),disabled:y(),parentDeviceId:r().nullable(),role:u().nullable().optional(),online:y(),probed:y().optional(),features:C(u()),isCamera:y(),config:h(u(),w()),secretConfigPaths:C(u()).optional(),metadata:h(u(),w()).nullable().optional(),identifiers:wA.optional(),attachedIdentifiers:wA.optional(),sourceInfo:Rh.optional(),integrationId:u().optional(),linkDeviceId:r().nullable().optional(),primaryChildEntityId:u().nullable().optional(),childLayout:C(vj).readonly().optional(),primaryChildPreference:C(u()).readonly().optional(),display:yj.optional()}),Sj=x({key:u(),value:w(),description:u().optional()}),Cj=S([`manual`]),wj=x({deviceId:r(),name:u(),location:u().nullable(),features:C(u()),producesTrackedEvents:y().optional()}),Tj=x({deviceIds:C(r().int().positive()),trackedDeviceIds:C(r().int().positive()).optional()}),Ej={id:`linked-devices`,label:`Linked devices`,description:`Companion devices of this camera: their controls appear with it, and the ones you opt in produce tracked events on it.`,shape:`association`,hostDeviceTypes:[M.Camera],sourceCaps:`any`,cardinality:`many`,value:Tj},rbe=x({deviceId:r(),mode:Cj,devices:C(wj)}),Dj=x({deviceId:r(),entries:C(x({capName:u(),kind:S([`native`,`wrapped`]),providerAddonId:u(),providerNodeId:u(),nativeAddonId:u(),implementedMethods:C(u()).optional()}))}),Oj=a(`kind`,[x({kind:m(`value`),wrapperAddonId:u().nullable()}),x({kind:m(`missing`)}),x({kind:m(`failed`),error:u()})]),ibe=x({id:r(),stableId:u(),type:u(),name:u(),location:u().nullable(),tags:Td.optional(),disabled:y(),parentDeviceId:r().nullable(),role:u().nullable().optional()}),abe=x({id:r(),stableId:u(),addonId:u(),type:u(),name:u(),userNamed:y().optional(),location:u().nullable(),tags:Td.optional(),disabled:y(),parentDeviceId:r().nullable(),metadata:h(u(),w()).nullable().optional(),identifiers:wA.optional(),attachedIdentifiers:wA.optional(),sourceInfo:Rh.optional(),integrationId:u().optional(),linkDeviceId:r().nullable().optional(),primaryChildEntityId:u().nullable().optional(),childLayout:C(vj).readonly().optional(),primaryChildPreference:C(u()).readonly().optional(),role:u().nullable().optional(),display:yj.optional()}),obe=w().nullable(),sbe=x({streamId:u(),width:r().optional(),height:r().optional(),codec:u().optional(),fps:r().optional(),bitrateKbps:r().optional()}),cbe=x({addonId:u(),stableId:u(),id:r(),type:u(),name:u(),location:u().nullable().optional(),disabled:y().optional(),parentDeviceId:r().nullable(),role:u().nullable().optional(),features:C(u()).optional(),config:h(u(),w()),secretConfigPaths:C(u()).optional()}),kj=x({deviceId:r().int().positive(),deletedAt:r(),providerAddonId:u()}),Aj=2160*60*60*1e3,jj=x({deviceId:r().int().positive(),stores:h(u(),r().int().nonnegative())}),Mj=x({status:S([`skipped`,`dry-run`,`cleaned`]),reason:u().nullable(),devices:C(jj),unreachable:C(u())}),lbe=x({deviceId:r()}),ube=x({deviceId:r(),data:h(u(),w()),secretConfigPaths:C(u()).optional()}),Nj=S([`off`,`on`,`not-offered`,`unreachable`]),Pj=x({deviceId:r(),switchId:ao,outcome:Nj,detail:u().optional()}),Fj=x({sourceId:r(),targetId:r(),switches:C(Pj).readonly(),sourceStillLive:C(ao).readonly(),swapped:y()}),Ij={name:`device-manager`,scope:`system`,mode:`singleton`,extensionSlots:[Ej],methods:{allocateDeviceId:D(x({addonId:u(),stableId:u()}),x({id:r()}),{kind:`mutation`}),migrateDevice:D(x({sourceId:r(),targetId:r()}),Fj,{kind:`mutation`,auth:`admin`,timeoutMs:12*6e4}),registerDevice:D(cbe,v(),{kind:`mutation`}),removeDevice:D(lbe,v(),{kind:`mutation`}),persistConfig:D(ube,v(),{kind:`mutation`,auth:`admin`}),loadConfig:D(x({deviceId:r()}),h(u(),w()),{auth:`admin`}),loadRuntimeState:D(x({deviceId:r()}),h(u(),w()),{auth:`admin`}),loadMeta:D(x({deviceId:r()}),abe.nullable()),setName:D(x({deviceId:r(),name:u(),stampUserNamed:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),setAlias:D(x({deviceId:r(),alias:u()}),a(`ok`,[x({ok:m(!0),alias:Nk}),x({ok:m(!1),reason:S([`empty`,`too-long`,`grammar`,`reserved`,`taken`]),takenBy:r().optional()})]),{kind:`mutation`,auth:`admin`}),renderDeviceTemplates:D(x({templates:C(aA).max(64),allowedDeviceIds:C(r().int()).optional(),thisDevice:sA.optional()}),x({results:C(fA)}),{auth:`admin`}),checkDeviceTemplates:D(x({templates:C(u()).max(64),allowedDeviceIds:C(r().int()).optional(),thisDevice:sA.optional()}),x({results:C(a(`ok`,[x({ok:m(!0),aliases:C(x({alias:u(),deviceId:r().int().nullable(),allowed:y(),reads:C(u())})),readsClock:y()}),x({ok:m(!1),refusal:lA})]))}),{auth:`admin`}),setLocation:D(x({deviceId:r(),location:u().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setTags:D(x({deviceId:r(),tags:Td}),v(),{kind:`mutation`,auth:`admin`}),setType:D(x({deviceId:r(),type:S(M)}),v(),{kind:`mutation`,auth:`admin`}),setIntegrationId:D(x({deviceId:r(),integrationId:u()}),v(),{kind:`mutation`,auth:`admin`}),setLinkDeviceId:D(x({deviceId:r(),linkDeviceId:r().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildEntityId:D(x({deviceId:r(),primaryChildEntityId:u().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setChildLayout:D(x({deviceId:r(),childLayout:C(vj).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildPreference:D(x({deviceId:r(),primaryChildPreference:C(u()).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setDisplay:D(x({deviceId:r(),display:yj.nullable()}),v(),{kind:`mutation`,auth:`admin`}),getRoleDisplayDefaults:D(x({}),x({defaults:h(u(),bj)}),{role:`viewer`,kind:`query`}),setRoleDisplayDefaults:D(x({defaults:h(u(),bj)}),v(),{kind:`mutation`,auth:`admin`}),getWireableFields:D(x({deviceId:r(),includeSynthesizable:y().optional()}),x({caps:C(x({cap:u(),fields:C(x({path:u(),kind:S([`string`,`number`,`boolean`,`enum`,`union`]),unionMembers:C(S([`string`,`number`,`boolean`])).optional(),enumValues:C(u()).optional(),item:y().optional(),quantity:bc.optional()})).readonly(),itemArray:x({path:u(),keyField:u()}).optional()})).readonly()}),{kind:`query`}),setRole:D(x({deviceId:r(),role:u().nullable()}),v(),{kind:`mutation`,auth:`admin`}),applyInitialMeta:D(x({deviceId:r(),name:u().optional(),location:u().nullable().optional(),tags:Td.optional(),type:S(M).optional(),integrationId:u().optional(),linkDeviceId:r().nullable().optional(),role:u().nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),setMetadata:D(x({deviceId:r(),patch:h(u(),w())}),v(),{kind:`mutation`,auth:`admin`}),setIdentifiers:D(x({deviceId:r(),identifiers:wA.nullable(),unread:C(vA).optional()}),v(),{kind:`mutation`,auth:`admin`}),listIdentityCandidates:D(x({}),zA,{kind:`query`,auth:`admin`}),setAttachedIdentifiers:D(x({deviceId:r(),identifiers:wA.nullable(),unread:C(vA).optional()}),v(),{kind:`mutation`,auth:`admin`}),listIdentityLinks:D(x({deviceId:r().int().optional()}),YA,{kind:`query`,auth:`admin`}),confirmIdentityLink:D(x({linkId:u().min(1)}),ZA,{kind:`mutation`,auth:`admin`}),dismissIdentityLink:D(x({linkId:u().min(1)}),ZA,{kind:`mutation`,auth:`admin`}),unlinkIdentity:D(x({linkId:u().min(1)}),ZA,{kind:`mutation`,auth:`admin`}),listLocations:D(v(),C(u())),addLocation:D(x({name:u()}),v(),{kind:`mutation`,auth:`admin`}),removeLocation:D(x({name:u(),cascade:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),renameLocation:D(x({from:u(),to:u()}),x({moved:r()}),{kind:`mutation`,auth:`admin`}),listLocationIcons:D(v(),C(tm),{role:`viewer`}),setLocationIcon:D(x({location:u(),icon:md.nullable()}),v(),{kind:`mutation`,auth:`admin`}),listLocationDescriptions:D(v(),C(rm)),setLocationDescription:D(x({location:u(),description:u().max(400).nullable()}),v(),{kind:`mutation`,auth:`admin`}),listSiteZones:D(v(),C(gA),{role:`viewer`}),setSiteZone:D(x({name:u(),icon:md.nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),removeSiteZone:D(x({name:u()}),v(),{kind:`mutation`,auth:`admin`}),renameSiteZone:D(x({from:u(),to:u()}),v(),{kind:`mutation`,auth:`admin`}),setLocationZone:D(x({location:u(),zone:u().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setDisabled:D(x({deviceId:r(),disabled:y()}),v(),{kind:`mutation`,auth:`admin`}),listPersistedByAddon:D(x({addonId:u()}),C(ibe)),listAll:D(x({addonId:u().optional(),projection:S([`full`,`slim`]).optional(),isCamera:y().optional(),deviceIds:C(r()).optional()}),C(xj),{role:`viewer`}),search:D(tj,sj,{role:`viewer`}),getDevice:D(x({deviceId:r()}),xj.nullable()),getChildren:D(x({parentDeviceId:r()}),C(xj),{role:`viewer`}),getChildrenBatch:D(x({parentDeviceIds:C(r()).max(256)}),h(u(),C(xj))),getLinkedDevices:D(x({deviceId:r()}),x({mode:Cj,devices:C(wj)}),{role:`viewer`}),getLinkedDevicesBatch:D(x({deviceIds:C(r())}),C(rbe),{role:`viewer`}),getStreamSources:D(x({deviceId:r()}),C(Ic)),getConfigSchema:D(x({deviceId:r()}),C(Sj)),getSettingsSchema:D(x({deviceId:r()}),obe),updateConfig:D(x({deviceId:r(),values:h(u(),w())}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),enable:D(x({deviceId:r()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),disable:D(x({deviceId:r()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),remove:D(x({deviceId:r()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),listDeletedSince:D(x({sinceMs:r()}),C(kj).readonly(),{auth:`admin`}),cleanupDeletedDevicesData:D(x({confirm:y()}),Mj,{kind:`mutation`,auth:`admin`}),removeByIntegration:D(x({integrationId:u()}),x({removed:r()}),{kind:`mutation`,auth:`admin`}),getStreamProfileMap:D(x({deviceId:r()}),h(u(),u().nullable())),setStreamProfileMap:D(x({deviceId:r(),profileMap:h(u(),u().nullable())}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),probeStreams:D(x({deviceId:r()}),C(sbe),{kind:`mutation`,auth:`admin`}),getBindings:D(x({deviceId:r()}),Dj,{role:`viewer`}),getBindingsBatch:D(x({deviceIds:C(r())}),C(Dj)),getAllBindings:D(x({}),C(Dj)),listDeviceIdsByCaps:D(x({capNames:C(u().min(1)).min(1).max(16)}),C(r()),{role:`viewer`}),setWrapperActive:D(x({deviceId:r(),capName:u(),wrapperAddonId:u(),active:y()}),v(),{kind:`mutation`,auth:`admin`}),getWrapperActivation:D(x({deviceId:r(),capName:u().min(1)}),Oj),listWrappersForCap:D(x({capName:u()}),C(u())),listBindableCapsForDeviceType:D(x({deviceType:u()}),C(x({capName:u(),wrappers:C(u())}))),getDeviceSettingsAggregate:D(x({deviceId:r()}),iy.nullable()),getDeviceLiveInfoAggregate:D(x({deviceId:r()}),iy.nullable(),{role:`viewer`}),getDeviceAggregate:D(x({deviceId:r()}),x({settings:iy.nullable(),live:iy.nullable()})),runDeviceAction:D(x({deviceId:r().int().nonnegative(),action:u().min(1),input:w()}),w(),{kind:`mutation`}),updateDeviceField:D(x({deviceId:r(),writerCapName:u(),writerAddonId:u(),key:u(),value:w()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),updateDeviceFieldsBatch:D(x({deviceId:r(),changes:C(x({writerCapName:u(),writerAddonId:u(),key:u(),value:w()}))}),x({success:m(!0),failures:C(x({writerCapName:u(),writerAddonId:u(),error:u()}))}),{kind:`mutation`,auth:`admin`}),discoverDevices:D(x({addonId:u()}),C(dj),{kind:`mutation`,auth:`admin`}),adoptDevice:D(x({addonId:u(),candidate:dj,integrationId:u().optional()}),fj,{kind:`mutation`,auth:`admin`}),getCreationSchema:D(x({addonId:u(),type:S(M),integrationId:u().optional()}),w().nullable()),createDevice:D(x({addonId:u(),type:S(M),config:h(u(),w()),integrationId:u().optional()}),fj,{kind:`mutation`,auth:`admin`}),testCreationField:D(x({addonId:u(),type:S(M),key:u(),value:w(),formValues:h(u(),w()).optional()}),pj,{kind:`mutation`,auth:`admin`}),adoptionListCandidateFilters:D(x({addonId:u(),integrationId:u()}),x({filters:C(_k)}),{auth:`admin`}),adoptionListCandidates:D(yk.extend({addonId:u()}),bk,{auth:`admin`}),adoptionRefresh:D(x({addonId:u(),integrationId:u()}),Sk,{kind:`mutation`,auth:`admin`}),adoptionAdopt:D(Ck.extend({addonId:u()}),wk,{kind:`mutation`,auth:`admin`}),adoptionRelease:D(Tk.extend({addonId:u()}),v(),{kind:`mutation`,auth:`admin`}),adoptionStartJob:D(Ck.extend({addonId:u()}),x({jobId:u()}),{kind:`mutation`,auth:`admin`}),adoptionListJobs:D(x({addonId:u(),integrationId:u().optional()}),C(jre).readonly(),{auth:`admin`}),adoptionCancelJob:D(x({jobId:u()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),adoptionResync:D(Ek,Dk,{kind:`mutation`,auth:`admin`}),discoveryProviders:D(x({}),x({providers:C(x({addonId:u(),label:u()})).readonly()}),{auth:`admin`}),discoverAllProviders:D(x({subnets:C(u()).optional()}),x({groups:C(x({addonId:u(),label:u(),candidates:C(dj).readonly(),error:u().nullable()})).readonly()}),{kind:`mutation`,auth:`admin`}),discoverProvider:D(x({addonId:u(),params:h(u(),w()).optional(),subnets:C(u()).optional()}),x({candidates:C(dj).readonly()}),{kind:`mutation`,auth:`admin`}),listDiscoveryProposals:D(x({}),x({proposals:C(_j).readonly()}),{auth:`admin`}),dismissDiscoveryProposal:D(x({id:u()}),x({dismissed:y()}),{kind:`mutation`,auth:`admin`}),reportDiscoveryObservations:D(x({observations:C(gj).max(512)}),x({proposed:r().int()}),{kind:`mutation`,auth:`admin`}),runDiscoverySweep:D(x({}),x({providers:r().int(),proposed:r().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),providerCreationType:D(x({addonId:u(),integrationId:u().optional()}),x({deviceType:S(M).nullable()}),{auth:`admin`}),providerDiscoveryParamsSchema:D(x({addonId:u()}),w(),{auth:`admin`}),testField:D(x({deviceId:r(),key:u(),value:w()}),pj,{kind:`mutation`,auth:`admin`}),getDeviceStatusAggregate:D(x({deviceId:r(),caps:C(u()).readonly().optional()}),h(u(),w().nullable())),getDeviceStatusAggregateBatch:D(x({deviceIds:C(r()).readonly(),caps:C(u()).readonly().optional()}),h(u(),h(u(),w().nullable())),{role:`viewer`})},vocabulary:{notOperatorFacing:`the device registry itself — rename, move and remove are administration`}},Lj=[`linked-devices`],Rj=S(Lj),zj={"linked-devices":{descriptor:Ej,declaringCap:`device-manager`,hostDeviceTypes:[M.Camera]}},Bj=a(`slot`,[Tj.extend({slot:m(`linked-devices`)})]),Vj=[M.Camera],dbe=`listSlots`,Hj=a(`state`,[x({state:m(`ok`)}),x({state:m(`unreachable`),reason:u()})]),Uj=x({source:u(),label:u(),addonId:u().optional(),availability:Hj}),Wj=S([`ok`,`missing`,`foreign`,`unavailable`]),Gj=x({deviceId:r().int(),name:u().nullable(),health:Wj,detail:u().optional()}),Kj=x({state:S([`active`,`inactive`,`unknown`]),authority:u(),detail:u().optional()}),qj=x({state:m(`ok`),slotRef:u(),slot:Rj,authority:u(),activation:Kj.nullable(),value:Bj,sources:C(Gj),impliedSources:C(Gj).optional()}),Jj=x({state:m(`unreachable`),addonId:u(),reason:u()}),Yj=a(`state`,[qj,Jj]);function fbe(e,t){return{state:`unreachable`,addonId:e,reason:t}}var Xj=x({deviceId:r().int(),name:u(),type:u(),location:u().nullable(),parentName:u().nullable(),suggested:y(),reason:u().nullable()}),Zj=x({candidates:C(Xj)}),Qj=x({applied:m(!0),reload:S([`none`,`host`,`parent`])}),$j=x({deviceId:r().int(),slotRef:u().min(1)}),eM=$j.extend({value:Bj}),tM={name:`device-extension`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:Vj,deviceConfig:{ui:{kind:`widget`,widgetId:`host/extensions-panel`,tab:`general`,label:`Extensions`,order:72}},methods:{listSources:D(x({deviceId:r().int()}),C(Uj)),listSlots:D(x({deviceId:r().int()}),C(Yj)),listCandidates:D($j,Zj),setSlot:D(eM,Qj,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:L(`Device extension`,`Estensione del dispositivo`),order:3100}},nM=a(`kind`,[x({kind:m(`device`),deviceId:r().int()}),x({kind:m(`node`),nodeId:u().min(1)})]),rM=S([`gauge`,`counter`,`boolean`,`enum`]),iM=S([`gauge`,`counter`,`boolean`]),aM=`derived:energy.kwh`,oM=S([`raw`,`5m`,`1h`,`1d`]),sM=S([`undeclared`,`not-owner`,`opted-out`,`not-a-real-device`,`rate`,`ingest-mismatch`,`out-of-range`]),pbe=x({key:u(),reason:sM,count:r().int()}),cM=x({accepted:r().int(),refused:C(pbe).readonly()}),lM=x({key:u(),scope:u(),kind:rM,unit:u().nullable(),displayName:u(),source:S([`cap`,`addon`,`derived`]),values:C(u()).readonly().nullable(),firstTs:r(),lastTs:r()}),mbe=x({t:r(),samples:r().int(),mean:r().nullable(),twMean:r().nullable(),min:r(),max:r(),last:r().nullable(),delta:r().nullable(),state:u().nullable(),states:h(u(),r()).nullable()}),hbe=x({scope:u(),before:x({t:r(),value:r().nullable(),state:u().nullable()}).nullable(),points:C(mbe).readonly(),derivedFrom:u().nullable()}),uM={key:u(),scope:u().optional(),from:r(),to:r(),resolution:g([oM,m(`auto`)]).default(`auto`),maxPoints:r().int().positive().max(5e3).default(1e3)},dM=x({resolution:oM,series:C(hbe).readonly(),truncated:y()}),gbe=g([x({deviceId:r().int(),key:u(),scope:u().optional()}),x({forNodeId:u().min(1),key:u(),scope:u().optional()})]),_be=a(`ok`,[x({ok:m(!0),result:dM}),x({ok:m(!1),error:u()})]),vbe=x({tier:oM,rows:r().int().nullable(),approxBytes:r().nullable(),countedAt:r().nullable()}),fM=S([`device-gone`,`undeclared`]),pM=x({raw:r().int(),"5m":r().int(),"1h":r().int(),"1d":r().int()}),ybe=x({seriesId:r().int(),deviceId:r().int(),key:u(),scope:u(),displayName:u().nullable(),reason:fM,missingSince:r().nullable(),firstTs:r(),lastTs:r(),rows:pM}),mM=S([`not-found`,`not-orphan`,`failed`]),bbe=a(`ok`,[x({seriesId:r().int(),ok:m(!0),deleted:pM}),x({seriesId:r().int(),ok:m(!1),reason:mM})]),xbe=x({series:C(ybe).readonly(),truncated:y()}),hM=S([`invalid-range`,`range-too-large`,`series-not-found`,`not-a-point-series`]),Sbe=x({"5m":r().int(),"1h":r().int(),"1d":r().int()}),Cbe=a(`ok`,[x({ok:m(!0),dryRun:y(),seriesId:r().int(),rows:pM,rewritten:Sbe.nullable()}),x({ok:m(!1),reason:hM})]),gM=x({startedAt:r(),ready:y(),series:r().int(),metrics:r().int(),optedOutDevices:r().int(),tiers:C(vbe).readonly(),capture:x({eventsSeen:r().int(),pointsEmitted:r().int(),pointsWritten:r().int(),pointsDropped:r().int(),bufferDepth:r().int(),trailingEmitted:r().int(),reconciledPoints:r().int(),reconcileRuns:r().int(),reconcileFailures:r().int(),lastReconcileAt:r().nullable(),lastFlushAt:r().nullable(),flushFailures:r().int(),skipped:h(u(),r().int())}),ingest:x({accepted:r().int(),refused:h(u(),r().int())}),rollup:x({last5mAt:r().nullable(),last1hAt:r().nullable(),last1dAt:r().nullable(),errors:r().int(),dirty5m:r().int(),dirty1h:r().int(),dirty1d:r().int()}),retention:x({lastRunAt:r().nullable(),deleted:h(u(),r().int()),purgedSeries:r().int()}),directory:x({devices:r().int(),lastRefreshAt:r().nullable()})}),_M={name:`device-history`,scope:`system`,mode:`singleton`,methods:{listSeries:D(x({deviceId:r().int()}),C(lM).readonly()),listNodeSeries:D(x({forNodeId:u().min(1)}),C(lM).readonly(),{auth:`admin`}),query:D(x({deviceId:r().int(),...uM}),dM),queryNode:D(x({forNodeId:u().min(1),...uM}),dM,{auth:`admin`}),queryMany:D(x({items:C(gbe).min(1).max(24),from:uM.from,to:uM.to,resolution:uM.resolution,maxPoints:uM.maxPoints}),x({results:C(_be).readonly()}),{auth:`admin`}),declareSeries:D(x({name:u().regex(/^[a-z0-9-]+$/),subjectKind:S([`device`,`node`]),kind:iM,unit:u().optional(),displayName:u().min(1),ingest:S([`points`,`buckets`])}),x({key:u()}),{kind:`mutation`,auth:`admin`}),record:D(x({points:C(x({key:u(),subject:nM,scope:u().default(``),ts:r(),value:r()})).max(5e3)}),cM,{kind:`mutation`,auth:`admin`}),recordBuckets:D(x({buckets:C(x({key:u(),subject:nM,scope:u().default(``),bucketStart:r(),samples:r().int().positive(),sum:r(),min:r(),max:r(),last:r().nullable(),lastTs:r().nullable()})).max(5e3)}),cM,{kind:`mutation`,auth:`admin`}),getDeviceEnabled:D(x({deviceId:r().int()}),x({enabled:y()})),setDeviceEnabled:D(x({deviceId:r().int(),enabled:y()}),x({enabled:y()}),{kind:`mutation`,auth:`admin`}),getStatus:D(x({}),gM,{auth:`admin`}),listOrphanSeries:D(x({}),xbe,{auth:`admin`}),deleteOrphanSeries:D(x({seriesIds:C(r().int()).min(1).max(50)}),x({results:C(bbe).readonly()}),{kind:`mutation`,auth:`admin`}),deleteSeriesRange:D(x({deviceId:r().int(),key:u().min(1),scope:u(),fromMs:r().int().nonnegative(),toMs:r().int().nonnegative(),dryRun:y()}),Cbe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`recorded history of device state — read by charts, not actuated`}},wbe=x({id:u(),label:u(),protocol:S([`rtsp`,`rtmp`,`annexb`,`http-mjpeg`,`webrtc`,`custom`]),url:u().optional(),resolution:x({width:r(),height:r()}).optional(),fps:r().optional(),bitrate:r().optional(),codec:u().optional(),profileHint:j.optional(),sdp:u().optional()}),Tbe=x({key:u(),value:w()}),vM=x({source:u(),data:h(u(),w())}),yM={name:`device-ops`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getStreamSources:D(x({deviceId:r()}),C(wbe)),getConfigEntries:D(x({deviceId:r()}),C(Tbe)),setConfig:D(x({deviceId:r(),values:h(u(),w())}),v(),{kind:`mutation`,auth:`admin`}),runAction:D(x({deviceId:r(),action:u().min(1),input:w()}),w(),{kind:`mutation`,notOperatorFacing:`a provider-defined custom action whose id and input only the addon knows; it reaches the picker through the custom-actions surface, not a fixed phrase`}),removeDevice:D(x({deviceId:r()}),v(),{kind:`mutation`,auth:`admin`}),getSettingsSchema:D(x({deviceId:r()}),w().nullable()),getRawState:D(x({deviceId:r()}),vM.nullable(),{auth:`protected`})},vocabulary:{noun:L(`Device operations`,`Operazioni del dispositivo`),order:3110}},bM=x({deviceId:r().int().positive(),deletedAt:r(),providerAddonId:u()}),xM=x({counts:h(u(),r().int().nonnegative())}),SM=x({store:u(),deviceId:r().int().positive(),count:r().int().nonnegative()}),CM={name:`device-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onDeviceRemoved:D(bM,xM,{kind:`mutation`,auth:`admin`}),listDeviceData:D(v(),C(SM).readonly(),{auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.INTERNAL}},wM=S([`appliance`,`mower`,`vacuum`]),TM=S([`open`,`closed`]),EM=S([`completed`,`aborted`,`error`,`unknown`]),DM=S([`running-state`,`activity`,`reconcile`]),OM=S([`counter-delta`,`history-integral`]),kM=x({phase:u(),at:r()}),AM=x({kind:m(`appliance`),energyKwh:r().nullable().meta(A(`energy`)),energyMethod:OM.nullable(),peakW:r().nullable().meta(A(`power`)),avgW:r().nullable().meta(A(`power`)),program:u().nullable(),remainingAtStartSec:r().nullable().meta(A(`duration`)),finalPhase:u().nullable(),energyStartKwh:r().nullable().meta(A(`energy`)),powerObservedMs:r()}),jM=a(`kind`,[AM]),MM=x({runId:u(),deviceId:r().int(),kind:wM,state:TM,startedAt:r(),endedAt:r().nullable(),durationMs:r().nullable(),outcome:EM.nullable(),startSource:DM,endSource:DM.nullable(),runningSource:S([`native`,`assigned`]).nullable(),phases:C(kM),detail:jM}),NM={name:`device-runs`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Washer,M.Dryer,M.Dishwasher],methods:{listRuns:D(x({deviceId:r().int(),outcome:EM.optional(),atFrom:r().optional(),atTo:r().optional(),limit:r().int().positive().max(200).default(50),cursor:u().optional()}),x({runs:C(MM).readonly(),nextCursor:u().nullable()})),getRun:D(x({deviceId:r().int(),runId:u()}),MM.nullable()),getCurrentRun:D(x({deviceId:r().int()}),MM.nullable())},events:{onRunOpened:{data:MM,notOperatorFacing:`the durable record of a run that the running-state start flip already announces`},onRunClosed:{data:MM,notOperatorFacing:`the durable record of a run that the running-state finish flip already announces`}},vocabulary:{noun:L(`Runs`,`Esecuzioni`),order:2130}},PM=S([`replace`,`add`]),FM=a(`ok`,[x({ok:m(!0),changed:y()}),x({ok:m(!1),code:S([`owned-by-other`,`not-claimed`,`field-not-claimed`,`invalid-slice`,`unknown-device`,`row-unreadable`,`migration-in-flight`]),message:u()})]),IM=x({deviceId:r(),capName:u(),owner:u().min(1),mode:PM,fields:C(u().min(1)).min(1)}),LM=a(`state`,[x({state:m(`loaded`),claims:C(IM)}),x({state:m(`not-loaded`),reason:u()})]),RM={name:`device-state`,scope:`system`,mode:`singleton`,methods:{getSnapshot:D(x({deviceId:r()}),h(u(),h(u(),w()))),getCapSlice:D(x({deviceId:r(),capName:u(),confirmed:y().optional()}),h(u(),w()).nullable()),getAllSnapshots:D(x({confirmed:y().optional()}),h(u(),h(u(),h(u(),w())))),setCapSlice:D(x({deviceId:r(),capName:u(),slice:h(u(),w())}),v(),{kind:`mutation`}),claimFields:D(x({deviceId:r(),capName:u(),owner:u().min(1),mode:PM,fields:C(u().min(1)).min(1),values:h(u(),w())}),FM,{kind:`mutation`,auth:`admin`}),patchOwnedFields:D(x({deviceId:r(),capName:u(),owner:u().min(1),values:h(u(),w())}),FM,{kind:`mutation`,auth:`admin`}),releaseClaim:D(x({deviceId:r(),capName:u(),owner:u().min(1)}),FM,{kind:`mutation`,auth:`admin`}),listClaims:D(x({ownerPrefix:u().optional()}),LM,{auth:`admin`}),getNativeCapSlice:D(x({deviceId:r(),capName:u()}),h(u(),w()).nullable(),{auth:`admin`})},events:{onChanged:Ei(x({deviceId:r(),capName:u(),slice:h(u(),w())}))},vocabulary:{notOperatorFacing:`the runtime-state mirror every trigger already reads through`}},zM=S([`schedule`,`command`,`burst`]),BM=S([`none`,`partial`,`full`]),VM=1e3,Ebe=x({integrationId:u().min(1),minIntervalMs:r().int().min(VM),intervalMs:r().int().positive().optional(),batch:y(),push:BM,heartbeatMs:r().int().positive().optional(),connectionEpoch:r().int().nonnegative().optional()});function Dbe(e){let t=e.intervalMs??0;return Math.max(e.minIntervalMs,t)}var HM=[3e3,1e4],UM=1e4,WM=2e3;function Obe(e){let t=HM.filter(t=>t<e),n=e-WM,r=(t[t.length-1]??0)+UM;for(;r<n;)t.push(r),r+=UM;let i=t[t.length-1];return(i===void 0?n>0:n-i>=1e3)&&t.push(n),t}var kbe=2500,GM=x({deviceId:r().int().nonnegative(),deviceIds:C(r().int().nonnegative()).min(1),reason:zM}),KM=x({deviceId:r().int().nonnegative()}),qM=x({ok:m(!0)}),JM=`the core schedules state refreshes itself; an operator never asks for one`,YM={name:`device-state-refresh`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{refresh:D(GM,qM,{kind:`mutation`,auth:`admin`,notOperatorFacing:JM}),resubscribe:D(KM,qM,{kind:`mutation`,auth:`admin`,notOperatorFacing:JM})},vocabulary:{noun:L(`State refresh`,`Aggiornamento dello stato`),order:3247}},XM=x({online:y(),lastChangedAt:r()}),ZM={name:`device-status`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onStatusChanged:{data:x({deviceId:r(),status:XM}),notOperatorFacing:"the `online` state trigger phrases both edges of this change"}},status:{schema:XM,kind:`push`},runtimeState:XM,durability:`restored`,history:{fields:{online:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Reachability`,`Raggiungibilità`),order:5260,state:[{kind:`boolean`,field:`online`,label:L(`Online`,`Online`),whenTrue:L(`When {device} comes back online`,`Quando {device} torna online`),whenFalse:L(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi`}],extraEvents:[{category:T.DeviceOnline,label:L(`Came online`,`Tornato online`),phrase:L(`When {device} comes back online`,`Quando {device} torna online`),icon:`wifi`},{category:T.DeviceOffline,label:L(`Went offline`,`Andato offline`),phrase:L(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi-off`}]}},QM=S([`not-kernel`,`invalid`]),$M=x({written:r().int().nonnegative(),refused:C(x({id:u(),reason:QM})).readonly()}),eN=x({rows:r().int().nullable(),lastWriteAt:r().nullable(),refused:h(u(),r())}),tN={name:`device-transitions`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Object.values(M).filter(e=>e!==M.Container),methods:{listTransitions:D(x({deviceId:r().int(),capName:u().optional(),actorKind:Io.optional(),outcome:Lo.optional(),atFrom:r().optional(),atTo:r().optional(),limit:r().int().positive().max(200).default(50),cursor:u().optional()}),x({transitions:C(Ro).readonly(),nextCursor:u().nullable()})),getTransition:D(x({deviceId:r().int(),id:u()}),Ro.nullable()),listRecentTransitions:Ti(x({actorKind:Io.optional(),outcome:Lo.optional(),atFrom:r().optional(),atTo:r().optional(),limit:r().int().positive().max(200).default(50),cursor:u().optional()}),x({transitions:C(Ro).readonly(),nextCursor:u().nullable()}),{auth:`admin`}),record:Ti(x({transitions:C(Ro).max(500)}),$M,{kind:`mutation`,auth:`admin`}),getStatus:Ti(x({}),eN,{auth:`admin`})},vocabulary:{noun:L(`Transitions`,`Transizioni`),order:2140}},nN=S([`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]),rN=S([`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]),iN=S([`available`,`offline`,`description-missing`]),aN=x({availability:iN,state:nN,operationState:rN.nullable(),program:u().nullable(),selectedProgram:u().nullable(),availablePrograms:C(u()),remaining:r().int().nonnegative().nullable().meta(A(`duration`)),delayedStart:r().int().nonnegative().nullable().meta(A(`duration`)),progress:r().min(0).max(100).nullable().meta(A(`percentage`)),doorOpen:y().nullable(),doorLocked:y().nullable(),remoteStartAllowed:y().nullable(),remoteControlActive:y().nullable(),localControlActive:y().nullable(),powerOn:y().nullable(),powerState:u().nullable(),filterCleaningDue:y().nullable(),machineCareDue:y().nullable(),machineCareRemainingRuns:r().int().nonnegative().nullable().meta(A(`count`)),halfLoad:y().nullable(),hygienePlus:y().nullable(),extraDry:y().nullable(),intensiveZone:y().nullable(),varioSpeedPlus:y().nullable(),childLock:y().nullable(),activeEvents:C(u()),errorCode:r().nullable().meta(A(`none`)),errorLabel:u().nullable(),lastFetchedAt:r()}),oN=r().int().nonnegative(),sN=g([y(),u(),r()]),cN=S([`none`,`read`,`readWrite`,`writeOnly`,`readStatic`]),lN=x({key:u(),name:u(),type:S([`boolean`,`number`,`enum`,`string`]),access:cN,available:y(),unit:u().nullable(),min:r().nullable(),max:r().nullable(),step:r().nullable(),enumValues:C(u()).nullable(),defaultValue:sN.nullable()}),uN=x({key:u(),name:u(),available:y(),options:C(lN)}),dN=x({availability:iN,supportsStart:y(),supportsPause:y(),supportsResume:y(),supportsStop:y(),supportsPower:y(),programs:C(uN),options:C(lN)}),fN={name:`dishwasher`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Dishwasher],methods:{start:D(x({deviceId:oN,program:u().min(1).optional(),options:h(u(),sN).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.start`,label:L(`Start cycle`,`Avvia il lavaggio`),phrase:L(`Start {device}`,`Avvia {device}`),icon:`play`,openArgs:[{key:`program`,label:L(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`},optional:!0}]}]}),pause:D(x({deviceId:oN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.pause`,label:L(`Pause`,`Metti in pausa`),phrase:L(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),resume:D(x({deviceId:oN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.resume`,label:L(`Resume`,`Riprendi`),phrase:L(`Resume {device}`,`Riprendi il lavaggio di {device}`),icon:`play`}]}),stop:D(x({deviceId:oN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.stop`,label:L(`Stop`,`Ferma`),phrase:L(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setProgram:D(x({deviceId:oN,program:u().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.program`,label:L(`Choose programme`,`Scegli il programma`),phrase:L(`Select the {program} programme on {device}`,`Seleziona il programma {program} su {device}`),icon:`list`,openArgs:[{key:`program`,label:L(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`}}]}]}),setPower:D(x({deviceId:oN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.powerOn`,label:L(`Power on`,`Accendi`),phrase:L(`Turn on {device}`,`Accendi {device}`),icon:`power`,args:{on:!0}},{id:`dishwasher.powerOff`,label:L(`Power off`,`Spegni`),phrase:L(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,args:{on:!1}}]}),setHalfLoad:D(x({deviceId:oN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.halfLoadOn`,label:L(`Half load on`,`Mezzo carico attivo`),phrase:L(`Turn on half load on {device}`,`Attiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!0}},{id:`dishwasher.halfLoadOff`,label:L(`Half load off`,`Mezzo carico spento`),phrase:L(`Turn off half load on {device}`,`Disattiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!1}}]}),setHygienePlus:D(x({deviceId:oN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.hygienePlusOn`,label:L(`Hygiene Plus on`,`Igiene Plus attiva`),phrase:L(`Turn on Hygiene Plus on {device}`,`Attiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!0}},{id:`dishwasher.hygienePlusOff`,label:L(`Hygiene Plus off`,`Igiene Plus spenta`),phrase:L(`Turn off Hygiene Plus on {device}`,`Disattiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!1}}]}),setExtraDry:D(x({deviceId:oN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.extraDryOn`,label:L(`Extra dry on`,`Asciugatura extra attiva`),phrase:L(`Turn on extra dry on {device}`,`Attiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!0}},{id:`dishwasher.extraDryOff`,label:L(`Extra dry off`,`Asciugatura extra spenta`),phrase:L(`Turn off extra dry on {device}`,`Disattiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!1}}]}),setIntensiveZone:D(x({deviceId:oN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.intensiveZoneOn`,label:L(`Intensive zone on`,`Zona intensiva attiva`),phrase:L(`Turn on the intensive zone on {device}`,`Attiva la zona intensiva su {device}`),icon:`flame`,args:{on:!0}},{id:`dishwasher.intensiveZoneOff`,label:L(`Intensive zone off`,`Zona intensiva spenta`),phrase:L(`Turn off the intensive zone on {device}`,`Disattiva la zona intensiva su {device}`),icon:`flame`,args:{on:!1}}]}),setVarioSpeedPlus:D(x({deviceId:oN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.varioSpeedOn`,label:L(`Speed boost on`,`Lavaggio rapido attivo`),phrase:L(`Turn on the speed boost on {device}`,`Attiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!0}},{id:`dishwasher.varioSpeedOff`,label:L(`Speed boost off`,`Lavaggio rapido spento`),phrase:L(`Turn off the speed boost on {device}`,`Disattiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!1}}]}),setChildLock:D(x({deviceId:oN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.childLockOn`,label:L(`Child lock on`,`Blocco bambini attivo`),phrase:L(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`dishwasher.childLockOff`,label:L(`Child lock off`,`Blocco bambini spento`),phrase:L(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setOption:D(x({deviceId:oN,key:u().min(1),value:sN}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw appliance option key/value; every option worth naming has its own action above`}),getOptions:D(x({deviceId:oN}),dN,{auth:`protected`})},status:{schema:aN,kind:`poll`},runtimeState:aN,durability:`session`,history:{fields:{progress:{kind:`gauge`,unit:`%`,deadband:2},state:{kind:`enum`},operationState:{kind:`enum`},remaining:{kind:`gauge`,unit:`s`,minIntervalMs:6e4},doorOpen:{kind:`boolean`},powerOn:{kind:`boolean`}}},vocabulary:{noun:L(`Dishwasher`,`Lavastoviglie`),order:2020,state:[{kind:`enum`,field:`state`,label:L(`Cycle`,`Ciclo`),values:[{value:`idle`,label:L(`Idle`,`Inattiva`)},{value:`running`,label:L(`Running`,`In funzione`),phrase:L(`When {device} starts a cycle`,`Quando {device} inizia un lavaggio`)},{value:`paused`,label:L(`Paused`,`In pausa`)},{value:`finished`,label:L(`Finished`,`Terminato`),phrase:L(`When {device} finishes`,`Quando {device} finisce il lavaggio`)},{value:`error`,label:L(`Error`,`Errore`),phrase:L(`When {device} reports an error`,`Quando {device} segnala un errore`)},{value:`unavailable`,label:L(`Unavailable`,`Non disponibile`)}],icon:`washing-machine`},{kind:`numeric`,field:`progress`,quantity:L(`the cycle progress`,`l’avanzamento del lavaggio`),label:L(`Progress`,`Avanzamento`),unit:`%`,icon:`loader`},{kind:`boolean`,field:`doorOpen`,label:L(`Door open`,`Sportello aperto`),whenTrue:L(`When the door of {device} opens`,`Quando si apre lo sportello di {device}`),whenFalse:L(`When the door of {device} closes`,`Quando si chiude lo sportello di {device}`),icon:`door-open`},{kind:`boolean`,field:`filterCleaningDue`,label:L(`Filter cleaning due`,`Pulizia filtro da fare`),whenTrue:L(`When {device} asks for its filter to be cleaned`,`Quando {device} chiede di pulire il filtro`),whenFalse:L(`When the filter reminder of {device} clears`,`Quando l’avviso filtro di {device} rientra`),icon:`funnel`},{kind:`boolean`,field:`machineCareDue`,label:L(`Machine care due`,`Manutenzione da fare`),whenTrue:L(`When {device} asks for a machine-care cycle`,`Quando {device} chiede un ciclo di manutenzione`),whenFalse:L(`When the machine-care reminder of {device} clears`,`Quando l’avviso di manutenzione di {device} rientra`),icon:`wrench`}]}},pN=`motion.audio.recording.live.heatmapScrub.person.vehicle.animal.package.sensor.control.face.plate.car.truck.bus.motorcycle.bicycle.airplane.boat.train.bird.dog.cat.horse.sheep.cow.elephant.bear.zebra.giraffe.package-delivered.package-picked-up.suitcase.backpack.handbag.contact.motion-sensor.smoke.flood.gas.carbon-monoxide.vibration.tamper.presence.enum-sensor.device-event.lock.cover.switch.siren.button.doorbell.appliance-cycle`.split(`.`),mN=`audio`,hN=[.3,.42,.55,.7,.85,1],gN=[`camstack`,`high-contrast`,`okabe-ito`];function Abe(e){return pN.includes(e)}function jbe(e){return gN.includes(e)}var _N={dark:`#0c0a09`,light:`#fafaf9`},Mbe=[`live`,`heatmapScrub`],vN=/^#[0-9a-fA-F]{6}$/;function yN(e,t){return Number.parseInt(e.slice(t,t+2),16)}function bN(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function xN(e){let t=bN(yN(e,1)),n=bN(yN(e,3)),r=bN(yN(e,5));return .2126*t+.7152*n+.0722*r}function Nbe(e,t){if(!vN.test(e)||!vN.test(t))return 0;let n=Math.max(xN(e),xN(t)),r=Math.min(xN(e),xN(t));return(n+.05)/(r+.05)}function SN(e){let t=bN(yN(e,1)),n=bN(yN(e,3)),r=bN(yN(e,5)),i=.4124564*t+.3575761*n+.1804375*r,a=.2126729*t+.7151522*n+.072175*r,o=.0193339*t+.119192*n+.9503041*r,s=e=>e>.008856?Math.cbrt(e):7.787*e+16/116,c=s(i/.95047),l=s(a),u=s(o/1.08883);return{L:116*l-16,a:500*(c-l),b:200*(l-u)}}function CN(e,t){if(e===0&&t===0)return 0;let n=Math.atan2(t,e)*180/Math.PI;return n<0?n+360:n}function Pbe(e,t){if(!vN.test(e)||!vN.test(t))return 0;let n=SN(e),r=SN(t),i=((Math.hypot(n.a,n.b)+Math.hypot(r.a,r.b))/2)**7,a=.5*(1-Math.sqrt(i/(i+25**7))),o=(1+a)*n.a,s=(1+a)*r.a,c=Math.hypot(o,n.b),l=Math.hypot(s,r.b),u=CN(o,n.b),d=CN(s,r.b),f=0;c*l!==0&&(f=d-u,f>180?f-=360:f<-180&&(f+=360));let p=2*Math.sqrt(c*l)*Math.sin(f*Math.PI/360),m=(n.L+r.L)/2,h=(c+l)/2,g=u+d;c*l!==0&&(Math.abs(u-d)>180&&(g+=g<360?360:-360),g/=2);let _=1-.17*Math.cos((g-30)*Math.PI/180)+.24*Math.cos(2*g*Math.PI/180)+.32*Math.cos((3*g+6)*Math.PI/180)-.2*Math.cos((4*g-63)*Math.PI/180),ee=30*Math.exp(-(((g-275)/25)**2)),te=h**7,v=2*Math.sqrt(te/(te+25**7)),ne=1+.015*(m-50)**2/Math.sqrt(20+(m-50)**2),y=1+.045*h,re=1+.015*h*_,ie=-Math.sin(2*ee*Math.PI/180)*v,ae=r.L-n.L,oe=l-c;return Math.sqrt((ae/ne)**2+(oe/y)**2+(p/re)**2+oe/y*ie*(p/re))}var Fbe={motion:`#d946ef`,audio:`#059eb8`,recording:`#ef4444`,live:`#8d7a00`,heatmapScrub:`#4b32ff`,person:`#11a64c`,vehicle:`#3b82f6`,animal:`#ea6a09`,package:`#924667`,sensor:`#624bbc`,control:`#944d24`,face:`#ed4f8d`,plate:`#4b7027`,car:`#9684cf`,truck:`#0f9b89`,bus:`#a734a9`,motorcycle:`#c1133a`,bicycle:`#0e6a9b`,airplane:`#7c9928`,boat:`#b17933`,train:`#ad6ca3`,bird:`#0f7c55`,dog:`#c82700`,cat:`#7268f2`,horse:`#cb795e`,sheep:`#b8636b`,cow:`#cb2969`,elephant:`#1158d2`,bear:`#8d5e00`,zebra:`#0097d6`,giraffe:`#8f61bb`,"package-delivered":`#cd3f9b`,"package-picked-up":`#388a08`,suitcase:`#666800`,backpack:`#ec5022`,handbag:`#a76ef8`,contact:`#ab5a49`,"motion-sensor":`#b95d1a`,smoke:`#dd3858`,flood:`#b31e7d`,gas:`#5b70b5`,"carbon-monoxide":`#7b4e8e`,vibration:`#e65bba`,tamper:`#98464b`,presence:`#3a9468`,"enum-sensor":`#7885f8`,"device-event":`#8c43c8`,lock:`#649653`,cover:`#c67597`,switch:`#7a812a`,siren:`#ac5d7f`,button:`#b276cd`,doorbell:`#0087ab`,"appliance-cycle":`#2a8c8c`},Ibe=[`#b34dc7`,`#1d7d34`,`#db6b6c`,`#a43d29`,`#0e6ee6`,`#29a10b`,`#a98731`,`#0181c6`],Lbe={motion:`#964360`,audio:`#23a132`,recording:`#2494ca`,live:`#bd7e2b`,heatmapScrub:`#ad6eea`,person:`#62611e`,vehicle:`#f4534c`,animal:`#1556cd`,package:`#9c4415`,sensor:`#066c48`,control:`#f2479f`,face:`#139d8a`,plate:`#909024`,car:`#8e35ab`,truck:`#bd0b2b`,bus:`#7a88ca`,motorcycle:`#e26725`,bicycle:`#a6679b`,airplane:`#7c5720`,boat:`#467a1b`,train:`#6f65a4`,bird:`#cb717f`,dog:`#c62490`,cat:`#b36850`,horse:`#1872ac`,sheep:`#927939`,cow:`#428a5c`,elephant:`#d41160`,bear:`#799453`,zebra:`#a85455`,giraffe:`#746be8`,"package-delivered":`#824a80`,"package-picked-up":`#614ac1`,suitcase:`#2f77f3`,backpack:`#fa476d`,handbag:`#c14cbe`,contact:`#c83921`,"motion-sensor":`#a07ebd`,smoke:`#a25b13`,flood:`#526bab`,gas:`#924938`,"carbon-monoxide":`#bb7e53`,vibration:`#b66182`,tamper:`#3c6931`,presence:`#6c851d`,"enum-sensor":`#ad2d48`,"device-event":`#5e9b04`,lock:`#00a062`,cover:`#ad8624`,switch:`#d05259`,siren:`#cd67b3`,button:`#c9746a`,doorbell:`#338eeb`,"appliance-cycle":`#00848a`},Rbe=[`#817f3b`,`#a0733e`,`#8658b2`,`#956301`,`#bc652d`,`#647331`,`#a14c9e`,`#d14e71`],zbe={motion:`#b88128`,audio:`#1096c8`,recording:`#009e73`,live:`#9c8c22`,heatmapScrub:`#0072b2`,person:`#d55e00`,vehicle:`#c0739f`,animal:`#226d18`,package:`#91446c`,sensor:`#217b56`,control:`#648647`,face:`#c22998`,plate:`#fa4575`,car:`#956301`,truck:`#2f77f3`,bus:`#7a4e86`,motorcycle:`#f54597`,bicycle:`#bb3e75`,airplane:`#e054c0`,boat:`#457942`,train:`#867afa`,bird:`#88914c`,dog:`#1556cd`,cat:`#71702c`,horse:`#9b4fa4`,sheep:`#c0559d`,cow:`#d14f65`,elephant:`#98470f`,bear:`#595896`,zebra:`#96790e`,giraffe:`#cb717b`,"package-delivered":`#139d8a`,"package-picked-up":`#906ead`,suitcase:`#d02939`,backpack:`#d41160`,handbag:`#f64f54`,contact:`#7258d2`,"motion-sensor":`#b66182`,smoke:`#627abb`,flood:`#b86ae4`,gas:`#a95261`,"carbon-monoxide":`#c65d3c`,vibration:`#7a40b7`,tamper:`#914b34`,presence:`#9481c3`,"enum-sensor":`#ac6d47`,"device-event":`#7b6fce`,lock:`#c67662`,cover:`#a6564d`,switch:`#ad2c4e`,siren:`#348e08`,button:`#d27303`,doorbell:`#55770f`,"appliance-cycle":`#00737d`},Bbe=[`#9a3784`,`#a7392c`,`#409d50`,`#6987e7`,`#ee5b3d`,`#c0430d`,`#af79b3`,`#4b6628`],wN=u().regex(/^#[0-9a-f]{6}$/),TN=a(`form`,[x({form:m(`solid`),hex:wN}),x({form:m(`gradient`),hex:wN,alphas:C(r().gt(0).lte(1)).length(hN.length)})]),EN=x({status:m(`ready`),presetId:S(gN),customized:y(),source:S([`stored`,`unconfigured`]),swatches:h(u(),TN),fallbacks:C(wN).length(8)}),DN=a(`status`,[EN,x({status:m(`unknown`),reason:u()})]),ON=g([x({presetId:u()}),x({presetId:u(),overrides:h(u(),TN)})]),kN=x({presetId:u(),overrides:h(u(),TN)});function Vbe(e){return{form:`solid`,hex:e}}function Hbe(e){return{form:`gradient`,hex:e,alphas:[...hN]}}function Ube(e){let t={};for(let n of pN){let r=e[n];if(r===void 0)throw Error(`palette table missing ${n}`);t[n]=n===`audio`?Hbe(r):Vbe(r)}return t}function AN(e,t,n,r){return{id:e,name:t,swatches:Ube(n),fallbacks:r}}var jN=[AN(`camstack`,`CamStack`,Fbe,Ibe),AN(`high-contrast`,`High contrast`,Lbe,Rbe),AN(`okabe-ito`,`Colour-blind safe`,zbe,Bbe)];function MN(e){return jN.find(t=>t.id===e)}function NN(){let e=MN(`camstack`);if(e===void 0)throw Error(`CamStack preset missing`);return Wbe(e,`unconfigured`,!1)}function Wbe(e,t,n){return{status:`ready`,presetId:e.id,customized:n,source:t,swatches:e.swatches,fallbacks:[...e.fallbacks]}}function Gbe(e){return e.hex}function Kbe(e,t){let n=[];for(let t of pN){let r=e[t];r!==void 0&&n.push({name:t,hex:r.hex})}return t.forEach((e,t)=>{n.push({name:`fallback-${t}`,hex:e})}),n}function qbe(e){let t=e[mN];return t===void 0||t.form===`gradient`&&hN.every((e,n)=>t.alphas[n]===e)?[]:[{code:`bad-gradient`,entry:mN}]}function Jbe(e,t){let n=Mbe;return n.includes(e)&&n.includes(t)}function PN(e,t){let n=[];for(let t of pN)e[t]===void 0&&n.push({code:`missing-entry`,entry:t});for(let t of Object.keys(e))Abe(t)||n.push({code:`unknown-entry`,entry:t});t.length!==8&&n.push({code:`bad-fallbacks`}),n.push(...qbe(e));let r=Kbe(e,t);for(let e=0;e<r.length;e++)for(let t=e+1;t<r.length;t++){let i=r[e],a=r[t];if(i===void 0||a===void 0)continue;let o=Pbe(i.hex,a.hex);o<(Jbe(i.name,a.name)?20:7)&&n.push({code:`too-close`,left:i.name,right:a.name,deltaE:o})}for(let e of r)for(let t of[`dark`,`light`]){let r=Nbe(e.hex,_N[t]);r<3&&n.push({code:`low-contrast`,entry:e.name,background:t,contrast:r})}return n.length===0?{ok:!0}:{ok:!1,violations:n}}function Ybe(e){switch(e.code){case`too-close`:return`${e.left} vs ${e.right} (ΔE ${e.deltaE.toFixed(1)})`;case`low-contrast`:return`${e.entry} on ${e.background} (${e.contrast.toFixed(1)}:1)`;case`missing-entry`:return`${e.entry} is missing`;case`unknown-entry`:return`${e.entry} is not a palette entry`;case`bad-gradient`:return`${e.entry} gradient is not the six canonical steps`;case`bad-fallbacks`:return`fallback list must hold eight colours`;case`unknown-preset`:return`${e.presetId} is not a preset`}}function FN(e){return e.map(Ybe).join(`; `)}var IN=class extends Error{violations;constructor(e){super(FN(e)),this.name=`PaletteRejectedError`,this.violations=e}};function LN(e,t){let n=0;for(let t=0;t<e.length;t++)n=n*31+(e.codePointAt(t)??0)>>>0;let r=t[n%t.length];if(r===void 0)throw Error(`display palette has no fallback colour`);return r}function RN(e,t,n){let r=n.trim().toLowerCase();if(r.startsWith(`audio-`)){let n=e[mN];return n===void 0?LN(r,t):n.hex}let i=e[r];return i===void 0?LN(r,t):i.hex}function zN(e,t){return{...e,...t}}function Xbe(e){return`overrides`in e?e.overrides:{}}function Zbe(e){let t=MN(e.presetId);if(t===void 0||!jbe(e.presetId))throw new IN([{code:`unknown-preset`,presetId:e.presetId}]);let n=Xbe(e),r=zN(t.swatches,n),i=PN(r,t.fallbacks);if(!i.ok)throw new IN(i.violations);let a=Object.keys(n).length>0;return{status:`ready`,presetId:t.id,customized:a,source:`stored`,swatches:r,fallbacks:[...t.fallbacks]}}function Qbe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function $be(e){if(e==null||Qbe(e))return NN();let t=kN.safeParse(e);if(!t.success)return{status:`unknown`,reason:`stored palette is unreadable`};let n=MN(t.data.presetId);if(n===void 0)return{status:`unknown`,reason:`unknown preset ${t.data.presetId}`};let r=zN(n.swatches,t.data.overrides),i=PN(r,n.fallbacks);if(!i.ok)return{status:`unknown`,reason:FN(i.violations)};let a=Object.keys(t.data.overrides).length>0;return{status:`ready`,presetId:n.id,customized:a,source:`stored`,swatches:r,fallbacks:[...n.fallbacks]}}function exe(e,t){return{presetId:e.presetId,overrides:{...t}}}var txe=x({id:u(),name:u(),swatches:h(u(),TN),fallbacks:C(u())}),BN={name:`display-palette`,scope:`system`,mode:`singleton`,methods:{getPalette:D(v(),DN,{auth:`protected`,role:`viewer`}),listPresets:D(v(),C(txe).readonly(),{auth:`protected`,role:`viewer`}),setPalette:D(ON,EN,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the cluster display palette — one colour table for every client, not a device action`}},VN=x({enabled:y().nullable().meta({label:`Do not disturb`}),lastChangedAt:r()}),HN={name:`do-not-disturb`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.MediaPlayer],methods:{setEnabled:D(x({deviceId:r().int(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dnd.on`,label:L(`Do not disturb on`,`Attiva Non disturbare`),phrase:L(`Turn on Do not disturb on {device}`,`Attiva Non disturbare su {device}`),icon:`bell-off`,args:{enabled:!0}},{id:`dnd.off`,label:L(`Do not disturb off`,`Disattiva Non disturbare`),phrase:L(`Turn off Do not disturb on {device}`,`Disattiva Non disturbare su {device}`),icon:`bell`,args:{enabled:!1}}]})},status:{schema:VN,kind:`push`},runtimeState:VN,durability:`session`,history:{fields:{enabled:{kind:`boolean`}}},vocabulary:{noun:L(`Do not disturb`,`Non disturbare`),order:2160,state:[{kind:`boolean`,field:`enabled`,label:L(`Do not disturb`,`Non disturbare`),whenTrue:L(`When Do not disturb turns on on {device}`,`Quando {device} attiva Non disturbare`),whenFalse:L(`When Do not disturb turns off on {device}`,`Quando {device} disattiva Non disturbare`),icon:`bell-off`}]}},UN=2e3,nxe={version:1,targets:[{id:`pressed`,cardinality:`event`,shape:`pulse`,vocabulary:{cap:`doorbell`,eventName:`onPressed`},deviceTypes:[M.Camera],apply:`add`,applyAuthority:{kind:`composition-claim`},eventName:`onPressed`,edges:[`rising`],defaultEdge:`rising`,timestampPath:`lastPressedAt`,counterPath:`pressCountSinceStart`,highWater:`composer-advance`,combine:`any`,debounce:{kind:`rising-edge`,defaultDebounceMs:UN,changedAtRequired:!0},sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},WN=x({lastPressedAt:r().nullable(),pressCountSinceStart:r().meta(A(`count`))}),GN=x({deviceId:r(),timestamp:r()}),KN={name:`doorbell`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Button,M.Camera],methods:{},events:{onPressed:{data:GN,fromState:{field:`lastPressedAt`,on:`advance`},trigger:{category:T.DoorbellOnPressed,label:L(`Rang`,`Ha suonato`),phrase:L(`When someone rings {device}`,`Quando qualcuno suona a {device}`),icon:`bell-ring`}}},status:{schema:WN,kind:`push`},runtimeState:WN,durability:`restored`,history:`none`,customize:nxe,vocabulary:{noun:L(`Doorbell`,`Campanello`),order:5270}},qN=x({embedding:C(r()),inferenceMs:r()}),JN=S([`image`,`text`]),YN=x({modelId:u(),tower:JN,nodeId:u(),crashes:r(),windowMs:r(),sinceMs:r(),lastReason:u()}),XN=x({modelId:u(),tower:JN,nodeId:u(),attempts:r(),sinceMs:r(),lastReason:u()}),ZN=x({modelId:u(),embeddingDim:r(),ready:y(),nodeId:u().optional(),failedModels:C(YN).optional(),failedRequirements:C(XN).optional()}),QN=`embedding-model-failed`,$N=`embedding-requirements-unavailable`,eP=`embedding-requirements-failed`,tP=S([QN,$N,eP]);function nP(e,t){return`[${e} model=${t.modelId} tower=${t.tower} node=${t.nodeId}]`}function rxe(e){return Error(`${nP(QN,e)} ${e.modelId} (${e.tower} tower) crashed ${String(e.crashes)} times in ${String(Math.round(e.windowMs/1e3))}s on ${e.nodeId} — ${e.lastReason}. Cleared by embeddingEncoder.resetFailedModels({ modelId: "${e.modelId}", nodeId: "${e.nodeId}" }) or a model change.`)}function ixe(e,t){return Error(`${nP($N,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: ${t}`)}function axe(e){return Error(`${nP(eP,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: requirements can never be met — ${String(e.attempts)} attempts, last: ${e.lastReason}. Cleared by embeddingEncoder.resetFailedModels({ modelId: "${e.modelId}", nodeId: "${e.nodeId}" }) or a model change.`)}var oxe=RegExp(`\\[(${QN}|${$N}|${eP}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);function rP(e){let t=e instanceof Error?e.message:String(e),n=oxe.exec(t);if(n===null)return null;let r=tP.safeParse(n[1]),i=JN.safeParse(n[3]);return!r.success||!i.success||n[2]===void 0||n[4]===void 0?null:{code:r.data,modelId:n[2],tower:i.data,nodeId:n[4]}}function sxe(e){return iP(e)!==null}function iP(e){let t=rP(e);if(t===null||t.code!==`embedding-model-failed`)return null;let{modelId:n,tower:r,nodeId:i}=t;return{modelId:n,tower:r,nodeId:i}}var aP={name:`embedding-encoder`,scope:`system`,mode:`collection`,internal:!0,methods:{encode:D(x({crop:b(Uint8Array),width:r(),height:r()}),qN,{auth:`admin`}),encodeText:D(x({text:u(),modelId:u().min(1).optional()}),qN,{auth:`admin`}),getInfo:D(v(),ZN,{auth:`admin`}),resetFailedModels:D(x({modelId:u().min(1).optional()}),x({cleared:C(u()),nodeId:u()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.ML}},oP=x({powerW:r().nullable().meta(A(`power`)),energyKwh:r().nullable().meta(A(`energy`)),todayKwh:r().nullable().meta(A(`energy`))}),sP=x({powerW:r().nullable().meta(A(`power`)),importKwh:r().nullable().meta(A(`energy`)),exportKwh:r().nullable().meta(A(`energy`)),importTodayKwh:r().nullable().meta(A(`energy`)),exportTodayKwh:r().nullable().meta(A(`energy`))}),cP=x({powerW:r().nullable().meta(A(`power`)),energyKwh:r().nullable().meta(A(`energy`)),todayKwh:r().nullable().meta(A(`energy`))}),lP=x({stateOfChargePct:r().nullable().meta(A(`percentage`)),storedKwh:r().nullable().meta(A(`energy`)),capacityKwh:r().nullable().meta(A(`energy`)),powerW:r().nullable().meta(A(`power`)),chargedKwh:r().nullable().meta(A(`energy`)),dischargedKwh:r().nullable().meta(A(`energy`)),chargedTodayKwh:r().nullable().meta(A(`energy`)),dischargedTodayKwh:r().nullable().meta(A(`energy`)),healthPct:r().nullable().meta(A(`percentage`))}),uP=x({solar:oP.nullable(),grid:sP.nullable(),house:cP.nullable(),heatPump:cP.nullable(),storage:lP.nullable(),lastFetchedAt:r()});function cxe(e){let t=e.solar?.todayKwh??null,n=e.grid?.exportTodayKwh??null;return t===null||n===null||t<=0?null:Math.max(0,Math.min(100,(t-n)/t*100))}var dP={name:`energy-system`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.EnergySystem],methods:{},status:{schema:uP,kind:`push`},runtimeState:uP,durability:`session`,history:{primary:`house.powerW`,priority:50,fields:{"solar.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Solar power`},"solar.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Solar energy`},"grid.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Grid power`},"grid.importKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid import`},"grid.exportKwh":{kind:`counter`,unit:`kWh`,displayName:`Grid export`},"house.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`House power`},"house.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`House energy`},"heatPump.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Heat pump power`},"heatPump.energyKwh":{kind:`counter`,unit:`kWh`,displayName:`Heat pump energy`},"storage.stateOfChargePct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage charge`},"storage.storedKwh":{kind:`gauge`,unit:`kWh`,deadband:.05,displayName:`Stored energy`},"storage.capacityKwh":{kind:`gauge`,unit:`kWh`,deadband:.1,displayName:`Storage capacity`},"storage.powerW":{group:`power-flow`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Storage power`},"storage.chargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage charged`},"storage.dischargedKwh":{kind:`counter`,unit:`kWh`,displayName:`Storage discharged`},"storage.healthPct":{kind:`gauge`,unit:`%`,deadband:1,displayName:`Storage health`}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Energy system`,`Sistema energetico`),order:4020}},lxe=S([`date`,`time`,`datetime`]),fP=x({value:u(),timestamp:y().optional(),lastFetchedAt:r()}),pP={name:`enum-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:fP,kind:`push`},runtimeState:fP,durability:`restored`,history:{fields:{value:{kind:`enum`,skipWhenSet:`timestamp`}}},volatileStateFields:[`lastFetchedAt`,`timestamp`],vocabulary:{noun:L(`State sensor`,`Sensore di stato`),order:5060,state:[{kind:`value`,field:`value`,label:L(`State`,`Stato`),icon:`list`}]}},mP=S([`warning`,`error`]),hP=x({code:u(),label:u(),severity:mP}),gP=x({active:y().nullable(),code:u().nullable(),label:u().nullable(),severity:mP,since:r().nullable(),faults:C(hP).optional(),lastFetchedAt:r()}),_P={active:null,code:null,label:null,severity:`error`,since:null,lastFetchedAt:0},vP={name:`error`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},status:{schema:gP,kind:`push`,empty:_P},runtimeState:gP,durability:`restored`,volatileStateFields:[`lastFetchedAt`],history:`none`,vocabulary:{noun:L(`Fault`,`Guasto`),order:5265,state:[{kind:`boolean`,field:`active`,label:L(`Fault`,`Guasto`),whenTrue:L(`When {device} reports a fault`,`Quando {device} segnala un guasto`),whenFalse:L(`When the fault of {device} clears`,`Quando il guasto di {device} si risolve`),icon:`triangle-alert`}]}},yP=x({id:u(),name:u(),sampleCount:r().int().nonnegative(),coverMediaId:r().int().optional(),coverBase64:u().optional()}),uxe=x({id:u(),source:S([`detected`,`photo`]),addedAt:r().int(),deviceId:r().int().optional(),base64:u().optional(),mediaId:r().int().optional(),keyFrameMediaId:r().int().optional(),faceBbox:Ay.optional()}),dxe=x({sampleId:u(),enrolledAt:r().int(),deviceId:r().int().optional(),source:S([`detected`,`photo`]),mediaId:r().int().optional(),comparable:y(),selfMean:r().nullable(),bestForeign:x({identityId:u(),name:u(),score:r()}).optional(),suspicion:r()}),fxe=x({identityId:u(),name:u(),modelId:u(),totalSamples:r().int(),comparableSamples:r().int(),flagged:r().int(),flagThreshold:r(),rows:C(dxe).readonly()}),bP=x({faceId:u(),deviceId:r().int(),trackId:u(),timestamp:r().int(),recognizedIdentityId:u().optional(),identityName:u().optional(),assigned:y(),base64:u().optional(),cropUrl:u().optional(),faceBbox:Ay.optional(),keyFrameMediaId:r().int().optional(),bestMatchScore:r().optional(),nativeFaceShortSidePx:r().optional(),suggestedIdentityId:u().optional(),suggestedMatchScore:r().optional()}),pxe=S([`unassigned`,`recognized`,`identified`,`all`]),mxe=S([`timestamp`,`suggestionConfidence`]),hxe=S([`asc`,`desc`]),gxe=x({faceIds:C(u()).readonly(),representativeFaceId:u(),size:r().int(),cohesion:r()}),_xe=x({mediaId:r().int(),kind:u(),url:u(),sizeBytes:r(),timestamp:r()}),xP={name:`face-gallery`,role:{feature:`face-assignment`},scope:`system`,mode:`singleton`,methods:{listIdentities:D(x({includeCrops:y().optional()}).optional(),C(yP).readonly(),{role:`viewer`}),createIdentity:D(x({name:u().min(1)}),yP,{kind:`mutation`,auth:`admin`}),renameIdentity:D(x({id:u(),name:u().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteIdentity:D(x({id:u()}),v(),{kind:`mutation`,auth:`admin`}),listIdentitySamples:D(x({identityId:u()}),C(uxe).readonly()),auditIdentitySamples:D(x({identityId:u().min(1)}),fxe,{auth:`admin`}),removeSample:D(x({identityId:u(),sampleId:u()}),v(),{kind:`mutation`,auth:`admin`}),moveIdentitySample:D(x({sampleId:u().min(1),toIdentityId:u().min(1)}),v(),{kind:`mutation`,auth:`admin`}),listRecentFaces:D(x({deviceId:r().int().optional(),deviceIds:C(r().int()).optional(),limit:r().int().positive().optional(),filter:pxe.optional(),since:r().int().optional(),until:r().int().optional(),sortBy:mxe.optional(),sortDirection:hxe.optional(),includeCrops:y().optional()}).optional(),C(bP).readonly()),getFaceByTrack:D(x({deviceId:r().int(),trackId:u()}),bP.nullable(),{role:`viewer`}),getFaceMedia:D(x({faceId:u()}),C(_xe).readonly()),assignFace:D(x({faceId:u(),identityId:u()}),v(),{kind:`mutation`,auth:`admin`}),unassignFace:D(x({faceId:u()}),v(),{kind:`mutation`,auth:`admin`}),deleteFace:D(x({faceId:u()}),v(),{kind:`mutation`,auth:`admin`}),assignFaces:D(x({faceIds:C(u()).min(1),identityId:u()}),x({assigned:r().int(),failed:C(u()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignFaces:D(x({faceIds:C(u()).min(1)}),x({unassigned:r().int(),failed:C(u()).readonly()}),{kind:`mutation`,auth:`admin`}),suggestFaceClusters:D(x({threshold:r().min(0).max(1).optional(),minClusterSize:r().int().min(2).optional(),maxClusters:r().int().positive().optional(),limit:r().int().positive().optional(),maxFacesScanned:r().int().positive().optional()}).optional(),C(gxe).readonly())},vocabulary:{notOperatorFacing:`the face gallery — curated on its own page`}},SP=x({reason:u(),count:r().int().nonnegative()}),CP=x({family:u(),deviceId:r().int().positive(),variant:u().optional(),sinceMs:r(),atMs:r(),attempts:r().int().nonnegative(),succeeded:r().int().nonnegative(),reasons:C(SP).readonly()}),wP={name:`failure-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:D(v(),C(CP).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.INTERNAL}},TP=S([`forward`,`reverse`]),EP=[`horizontal`,`vertical`],DP=S(EP),OP=[`oscillating`,`angle`,`sweepFrom`,`sweepTo`],kP=S(OP),AP=[`min`,`max`,`step`],jP=x({oscillating:y().nullable().default(null),angle:r().nullable().default(null),sweepFrom:r().nullable().default(null),sweepTo:r().nullable().default(null),min:r().nullable().default(null),max:r().nullable().default(null),step:r().nullable().default(null)}),MP=x({horizontal:jP.nullable().default(null),vertical:jP.nullable().default(null)}),NP=[`nothing-to-set`,`axis-not-linked`,`out-of-range`,`source-gone`,`source-unknown`,`source-call-failed`],PP=S(NP),FP=a(`status`,[x({status:m(`applied`)}),x({status:m(`refused`),reason:PP,field:kP.optional(),detail:u(),applied:C(kP)})]),IP=x({deviceId:r().int().nonnegative(),axis:DP,oscillating:y().optional(),angle:r().optional(),sweepFrom:r().optional(),sweepTo:r().optional()});function LP(e,t){return`oscillationAxes.${e}.${t}`}var RP=x({speed:r().min(0).max(100).nullable().meta(A(`percentage`)),percentageStep:r().positive().optional().meta(A(`percentage`)),preset:u(),availablePresets:C(u()),direction:TP.nullable(),oscillating:y().nullable(),oscillationAxes:MP.optional(),lastChangedAt:r()});function vxe(e){let t=e.oscillationAxes;if(t===void 0)return e.oscillating;let n=EP.flatMap(e=>{let n=t[e]?.oscillating;return n==null?[]:[n]});return n.length===0?e.oscillating:n.some(Boolean)}var zP=[M.Fan],BP=`oscillation-axes`;function yxe(e){return{id:`${e}-oscillating`,cardinality:`scalar`,vocabulary:{cap:`fan-control`,stateField:`oscillating`},deviceTypes:zP,apply:`replace`,section:BP,path:LP(e,`oscillating`),sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}function VP(e,t){let n={id:`${e}-${t}`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:zP,apply:`replace`,section:BP,path:LP(e,t),sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}};return t===`angle`?{...n,companions:AP.map(t=>({kind:`source-field`,path:LP(e,t),field:t}))}:n}var bxe=EP.flatMap(e=>[yxe(e),VP(e,`angle`),VP(e,`sweepFrom`),VP(e,`sweepTo`)]),xxe={id:`preset`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:zP,apply:`replace`,path:`preset`,sources:[{kind:`field`,valueKinds:[`string`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}},HP=[...bxe,xxe],Sxe={version:1,overridable:HP.map(e=>({path:e.path,by:e.id})),targets:HP},UP={name:`fan-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Fan],methods:{setPercentage:O(x({deviceId:r().int().nonnegative(),speed:r().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.off`,label:L(`Fan off`,`Ventilatore spento`),phrase:L(`Stop {device}`,`Ferma {device}`),icon:`power-off`,effect:{field:`speed`,value:0},args:{speed:0}},{id:`fan.full`,label:L(`Fan full`,`Ventilatore al massimo`),phrase:L(`Run {device} at full speed`,`Porta {device} alla massima velocità`),icon:`fan`,effect:{field:`speed`,value:100},args:{speed:100},sideEffects:[{field:`preset`,value:``,when:{field:`preset`,notIn:[``]}}]},{id:`fan.speed`,label:L(`Set speed`,`Imposta la velocità`),phrase:L(`Set the speed of {device} to {speed}`,`Imposta la velocità di {device} al {speed}`),icon:`fan`,effect:{field:`speed`,fromArg:`speed`},sideEffects:[{field:`preset`,value:``,when:{field:`preset`,notIn:[``]}}],openArgs:[{key:`speed`,label:L(`Speed`,`Velocità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setPreset:O(x({deviceId:r().int().nonnegative(),preset:u().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.preset`,label:L(`Set preset`,`Imposta il preset`),phrase:L(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:L(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setDirection:O(x({deviceId:r().int().nonnegative(),direction:TP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.forward`,label:L(`Spin forward`,`Rotazione avanti`),phrase:L(`Spin {device} forward`,`Fai girare {device} in avanti`),icon:`refresh-cw`,effect:{field:`direction`,value:`forward`},args:{direction:`forward`}},{id:`fan.reverse`,label:L(`Spin in reverse`,`Rotazione inversa`),phrase:L(`Spin {device} in reverse`,`Fai girare {device} al contrario`),icon:`rotate-ccw`,effect:{field:`direction`,value:`reverse`},args:{direction:`reverse`}}]}),setOscillating:O(x({deviceId:r().int().nonnegative(),oscillating:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.oscillateOn`,label:L(`Oscillate`,`Oscillazione attiva`),phrase:L(`Make {device} oscillate`,`Fai oscillare {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!0},args:{oscillating:!0}},{id:`fan.oscillateOff`,label:L(`Stop oscillating`,`Oscillazione spenta`),phrase:L(`Stop {device} oscillating`,`Ferma l’oscillazione di {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!1},args:{oscillating:!1}}]}),setOscillationAxis:O(IP,FP,{kind:`mutation`,auth:`protected`,actions:[{id:`fan.horizontalOscillateOn`,label:L(`Horizontal oscillation on`,`Oscillazione orizzontale attiva`),phrase:L(`Start the horizontal oscillation of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!0}},{id:`fan.horizontalOscillateOff`,label:L(`Horizontal oscillation off`,`Oscillazione orizzontale spenta`),phrase:L(`Stop the horizontal oscillation of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!1}},{id:`fan.verticalOscillateOn`,label:L(`Vertical oscillation on`,`Oscillazione verticale attiva`),phrase:L(`Start the vertical oscillation of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!0}},{id:`fan.verticalOscillateOff`,label:L(`Vertical oscillation off`,`Oscillazione verticale spenta`),phrase:L(`Stop the vertical oscillation of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!1}}]})},status:{schema:RP,kind:`push`},runtimeState:RP,customize:Sxe,durability:`session`,history:{fields:{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}}},vocabulary:{noun:L(`Fan`,`Ventilatore`),order:1080,state:[{kind:`numeric`,field:`speed`,quantity:L(`the speed`,`la velocità`),label:L(`Speed`,`Velocità`),unit:`%`,icon:`fan`},{kind:`boolean`,field:`oscillating`,label:L(`Oscillating`,`Oscillazione`),whenTrue:L(`When {device} starts oscillating`,`Quando {device} inizia a oscillare`),whenFalse:L(`When {device} stops oscillating`,`Quando {device} smette di oscillare`),icon:`move-horizontal`}]}},WP=x({oscillating:y().optional(),angle:r().optional(),sweepFrom:r().optional(),sweepTo:r().optional()}),GP=x({speed:r().min(0).max(100).optional(),preset:u().min(1).optional(),direction:TP.optional(),oscillationAxes:x({horizontal:WP.optional(),vertical:WP.optional()}).optional()}),KP=x({id:u().min(1).max(64),name:u().trim().min(1).max(40),state:GP}),qP=[`empty-state`,`duplicate-name`,`duplicate-id`,`too-many`,`not-a-fan`],JP=S(qP),YP=a(`status`,[x({status:m(`saved`),count:r().int().nonnegative()}),x({status:m(`refused`),reason:JP,detail:u()})]),XP=x({field:u(),outcome:S([`applied`,`failed`,`not-run`,`refused`]),message:u().optional()}),ZP=x({status:S([`applied`,`partial`,`refused`]),fields:C(XP)}),QP=[`speed`,`direction`,`preset`,`oscillationAxes`],$P=S(QP),eF=x({what:u(),reason:u()}),tF=x({state:GP,omitted:C(eF)}),nF=x({deviceId:r().int().nonnegative()}),Cxe={version:1,targets:[{id:`presets`,cardinality:`config`,vocabulary:{cap:`fan-presets`},deviceTypes:[M.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`}]},rF={name:`fan-presets`,scope:`system`,mode:`singleton`,methods:{getPresets:D(nF,C(KP),{auth:`protected`}),setPresets:D(nF.extend({presets:C(KP).max(12)}),YP,{kind:`mutation`,auth:`admin`}),applyPreset:D(nF.extend({presetId:u().min(1)}),ZP,{kind:`mutation`,auth:`protected`}),capturePreset:D(nF.extend({fields:C($P).optional()}),tF,{auth:`protected`})},customize:Cxe,vocabulary:{notOperatorFacing:`the per-fan presets — authored in the Customize presets editor, applied through the actions the exports list`}},iF=x({flags:h(u(),w()),deviceType:u().nullable(),model:u().nullable(),channelCount:r().nullable().meta(A(`count`)),lastProbedAt:r(),lastFetchedAt:r()}),aF={name:`feature-probe`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onProbeChanged:{data:x({deviceId:r(),status:iF}),notOperatorFacing:`the device’s capabilities were re-probed — plumbing, not a happening`}},status:{schema:iF,kind:`push`},runtimeState:iF,durability:`session`,history:`none`,vocabulary:{noun:L(`Feature probe`,`Rilevamento funzioni`),order:3120}},wxe=x({name:u(),path:u()}),Txe=x({path:u(),entries:C(wxe).readonly(),freeBytes:r(),totalBytes:r()}),oF={name:`filesystem-browse`,scope:`system`,mode:`singleton`,internal:!0,methods:{listAllowedRoots:D(v(),C(u()).readonly(),{auth:`admin`}),browse:D(x({path:u()}),Txe,{auth:`admin`}),createDir:D(x({path:u()}),x({path:u()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.INTERNAL}},sF=x({flooded:y(),lastChangedAt:r()}),cF={name:`flood`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:sF,kind:`push`},runtimeState:sF,durability:`restored`,history:{fields:{flooded:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Leak sensor`,`Sensore di allagamento`),order:5070,state:[{kind:`boolean`,field:`flooded`,label:L(`Leak`,`Perdita`),whenTrue:L(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:L(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}]}},lF=x({detected:y(),lastChangedAt:r()}),uF={name:`gas`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:lF,kind:`push`},runtimeState:lF,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Gas sensor`,`Sensore di gas`),order:5080,state:[{kind:`boolean`,field:`detected`,label:L(`Detected`,`Rilevato`),whenTrue:L(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:L(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}]}},dF=x({active:y().meta({label:`Active`}),lastChangedAt:r()}),fF={name:`group-active`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Cover,M.Valve,M.Lock,M.MediaPlayer,M.Climate],methods:{},status:{schema:dF,kind:`push`},runtimeState:dF,durability:`session`,history:`none`,vocabulary:{noun:L(`Group state`,`Stato del gruppo`),order:5090}},pF=x({deviceId:r().int().nonnegative(),cap:u().min(1),method:u().min(1),ok:y(),error:u().optional(),at:r()}),mF=x({results:C(pF)}),hF={name:`group-commands`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Switch,M.Light,M.Fan,M.Cover,M.Valve,M.Lock,M.MediaPlayer,M.Climate],methods:{},status:{schema:mF,kind:`push`},runtimeState:mF,durability:`session`,history:`none`,vocabulary:{noun:L(`Group command`,`Comando di gruppo`),order:5100}},gF=x({included:r().int().nonnegative().meta(A(`count`,{precision:0,label:`Reporting`})),excluded:r().int().nonnegative().meta(A(`count`,{precision:0,label:`Excluded`})),total:r().int().nonnegative().meta(A(`count`,{precision:0,label:`Members`}))}),_F={name:`group-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor,M.Switch,M.Light,M.Fan,M.Cover,M.Valve,M.Lock,M.MediaPlayer,M.Climate],methods:{},status:{schema:gF,kind:`push`},runtimeState:gF,durability:`session`,history:`none`,vocabulary:{noun:L(`Group`,`Gruppo`),order:5110,state:[{kind:`numeric`,field:`included`,quantity:L(`the members reporting`,`i membri che rispondono`),label:L(`Reporting`,`Rispondono`),icon:`users`},{kind:`numeric`,field:`excluded`,quantity:L(`the members left out`,`i membri esclusi`),label:L(`Excluded`,`Esclusi`),icon:`users`},{kind:`numeric`,field:`total`,quantity:L(`the member count`,`il numero di membri`),label:L(`Members`,`Membri`),icon:`sigma`}]}},vF=r().int().nonnegative(),yF=u().min(1),bF=u().min(1),xF=r().finite(),SF={key:`circuitId`,label:L(`Circuit`,`Circuito`),offer:{kind:`dynamic`,from:`status`,cap:`heat-pump-status`,field:`circuits`,valueKey:`id`,labelKey:`label`,where:{key:`kind`,equals:`heating`}}},CF={...SF,label:L(`Hot water circuit`,`Circuito acqua calda`),offer:{...SF.offer,where:{key:`kind`,equals:`dhw`}}},wF={key:`mode`,label:L(`Mode`,`Modalità`),offer:{kind:`text`}},Exe={key:`level`,label:L(`Level`,`Livello`),offer:{kind:`text`}},TF={key:`temp`,label:L(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}},Dxe={key:`minutes`,label:L(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}},EF={name:`heat-pump-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.HeatPump],methods:{setSilentMode:D(x({deviceId:vF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.silent`,label:L(`Set silent mode`,`Imposta la modalità silenziosa`),phrase:L(`Set silent mode of {device} to {mode}`,`Imposta la modalità silenziosa di {device} su {mode}`),icon:`volume-x`,openArgs:[{key:`mode`,label:L(`Silent mode`,`Modalità silenziosa`),offer:{kind:`enum`,values:[{value:`off`,label:L(`Off`,`Off`)},{value:`auto`,label:L(`Auto`,`Auto`)},{value:`on`,label:L(`On`,`On`)}]}}]}]}),setAwayMode:D(x({deviceId:vF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.away`,label:L(`Set away mode`,`Imposta la modalità assente`),phrase:L(`Set away mode of {device} to {mode}`,`Imposta la modalità assente di {device} su {mode}`),icon:`plane`,openArgs:[{key:`mode`,label:L(`Away mode`,`Modalità assente`),offer:{kind:`enum`,values:[{value:`off`,label:L(`Off`,`Off`)},{value:`on`,label:L(`On`,`On`)}]}}]}]}),setAdditionalHeaterMode:D(x({deviceId:vF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.additionalHeater`,label:L(`Set additional heater`,`Imposta il riscaldatore aggiuntivo`),phrase:L(`Set the additional heater of {device} to {mode}`,`Imposta il riscaldatore aggiuntivo di {device} su {mode}`),icon:`flame`,openArgs:[{key:`mode`,label:L(`Additional heater`,`Riscaldatore aggiuntivo`),offer:{kind:`enum`,values:[{value:`off`,label:L(`Off`,`Off`)},{value:`manual`,label:L(`Manual`,`Manuale`)},{value:`auto`,label:L(`Auto`,`Auto`)}]}}]}]}),setHolidayMode:D(x({deviceId:vF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.holiday`,label:L(`Set holiday mode`,`Imposta la modalità vacanza`),phrase:L(`Set holiday mode of {device} to {mode}`,`Imposta la modalità vacanza di {device} su {mode}`),icon:`tree-palm`,openArgs:[{key:`mode`,label:L(`Holiday programme`,`Programma vacanza`),offer:{kind:`enum`,values:[{value:`off`,label:L(`Off`,`Off`)},{value:`hm1`,label:L(`Programme 1`,`Programma 1`)},{value:`hm2`,label:L(`Programme 2`,`Programma 2`)},{value:`hm3`,label:L(`Programme 3`,`Programma 3`)},{value:`hm4`,label:L(`Programme 4`,`Programma 4`)},{value:`hm5`,label:L(`Programme 5`,`Programma 5`)},{value:`hm6`,label:L(`Programme 6`,`Programma 6`)},{value:`hm7`,label:L(`Programme 7`,`Programma 7`)},{value:`hm8`,label:L(`Programme 8`,`Programma 8`)}]}}]}]}),setCircuitOperationMode:D(x({deviceId:vF,circuitId:yF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitOperationMode`,label:L(`Set circuit operation mode`,`Imposta la modalità del circuito`),phrase:L(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`thermometer`,openArgs:[SF,wF]}]}),setCircuitHeatCoolMode:D(x({deviceId:vF,circuitId:yF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitHeatCoolMode`,label:L(`Set circuit heat / cool`,`Imposta caldo / freddo del circuito`),phrase:L(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun-snow`,openArgs:[SF,wF]}]}),setCircuitSummerWinter:D(x({deviceId:vF,circuitId:yF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitSummerWinter`,label:L(`Set circuit summer / winter`,`Imposta estate / inverno del circuito`),phrase:L(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun`,openArgs:[SF,wF]}]}),setCircuitComfortSetpoint:D(x({deviceId:vF,circuitId:yF,temp:xF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitComfortSetpoint`,label:L(`Set comfort temperature`,`Imposta la temperatura comfort`),phrase:L(`Set the comfort temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura comfort di {circuitId} su {device} a {temp}`),icon:`thermometer-sun`,openArgs:[SF,TF]}]}),setCircuitEcoSetpoint:D(x({deviceId:vF,circuitId:yF,temp:xF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitEcoSetpoint`,label:L(`Set eco temperature`,`Imposta la temperatura eco`),phrase:L(`Set the eco temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura eco di {circuitId} su {device} a {temp}`),icon:`leaf`,openArgs:[SF,TF]}]}),setCircuitMaxFlowTemp:D(x({deviceId:vF,circuitId:yF,temp:xF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitMaxFlowTemp`,label:L(`Set maximum flow temperature`,`Imposta la temperatura massima di mandata`),phrase:L(`Set the maximum flow temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura massima di mandata di {circuitId} su {device} a {temp}`),icon:`flame`,openArgs:[SF,TF]}]}),setDhwOperationMode:D(x({deviceId:vF,circuitId:yF,mode:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwOperationMode`,label:L(`Set hot water mode`,`Imposta la modalità acqua calda`),phrase:L(`Set hot water {circuitId} of {device} to {mode}`,`Imposta l'acqua calda {circuitId} di {device} su {mode}`),icon:`shower-head`,openArgs:[CF,wF]}]}),setDhwTemperatureLevel:D(x({deviceId:vF,circuitId:yF,level:bF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwTemperatureLevel`,label:L(`Set hot water level`,`Imposta il livello acqua calda`),phrase:L(`Set hot water {circuitId} of {device} to level {level}`,`Imposta l'acqua calda {circuitId} di {device} al livello {level}`),icon:`droplet`,openArgs:[CF,Exe]}]}),setDhwChargeDuration:D(x({deviceId:vF,circuitId:yF,minutes:r().int().positive()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwChargeDuration`,label:L(`Set hot water charge duration`,`Imposta la durata della carica acqua calda`),phrase:L(`Set the charge of hot water {circuitId} on {device} to {minutes} min`,`Imposta la carica dell'acqua calda {circuitId} di {device} a {minutes} min`),icon:`timer`,openArgs:[CF,Dxe]}]}),startExtraHotWater:D(x({deviceId:vF,circuitId:yF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.extraHotWater`,label:L(`Start extra hot water`,`Avvia acqua calda extra`),phrase:L(`Start an extra hot water charge of {circuitId} on {device}`,`Avvia una carica extra di acqua calda {circuitId} su {device}`),icon:`droplets`,openArgs:[CF]}]})},vocabulary:{noun:L(`Heat pump settings`,`Impostazioni pompa di calore`),order:4010}},DF=[`heating`,`dhw`,`cooling`,`solar`],OF=S(DF),kF=x({value:u().nullable(),allowed:C(u())}),AF=x({value:r().nullable(),min:r().nullable(),max:r().nullable(),step:r().nullable()}),jF=x({id:u().min(1),kind:OF,label:u(),icon:md,currentTemp:r().nullable().meta(A(`temperature`)),targetTemp:r().nullable().meta(A(`temperature`)),mode:u().nullable(),active:y().nullable(),operationMode:kF.nullable(),heatCoolMode:kF.nullable(),summerWinter:kF.nullable(),comfortSetpoint:AF.nullable(),ecoSetpoint:AF.nullable(),maxFlowTemp:AF.nullable(),temperatureLevel:kF.nullable(),chargeDuration:AF.nullable(),extraHotWater:y().nullable()}),MF=x({silent:kF.nullable(),away:kF.nullable(),additionalHeater:kF.nullable(),holiday:kF.nullable()}),NF=x({thermalW:r().nullable().meta(A(`power`)),electricalW:r().nullable().meta(A(`power`)),compressorPct:r().nullable().meta(A(`percentage`))}),PF=x({supply:r().nullable().meta(A(`temperature`)),return:r().nullable().meta(A(`temperature`)),outdoor:r().nullable().meta(A(`temperature`))}),FF=x({thermalKwh:r().nullable().meta(A(`energy`)),electricalKwh:r().nullable().meta(A(`energy`))}),IF=x({circuits:C(jF),system:MF,power:NF,temperatures:PF,energy:FF,waterPressureBar:r().nullable(),starts:r().nullable(),lastFetchedAt:r()});function LF(e){let{thermalW:t,electricalW:n}=e;return t===null||n===null||n<=0?null:t/n}var Oxe=[M.HeatPump];function RF(e,t,n){return{id:e,cardinality:`scalar`,vocabulary:{cap:`heat-pump-status`},deviceTypes:Oxe,apply:`replace`,path:t,sources:[{kind:`numeric`,requiredUnit:n,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}var zF=[RF(`electrical-power`,`power.electricalW`,`W`),RF(`electrical-energy`,`energy.electricalKwh`,`kWh`)],kxe={version:1,overridable:zF.map(e=>({path:e.path,by:e.id})),targets:zF},BF={name:`heat-pump-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.HeatPump],methods:{},status:{schema:IF,kind:`push`},runtimeState:IF,durability:`session`,customize:kxe,history:{fields:{"power.thermalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Thermal power`},"power.electricalW":{group:`power`,kind:`gauge`,unit:`W`,deadband:50,displayName:`Electrical power`},"power.compressorPct":{kind:`gauge`,unit:`%`,deadband:2,displayName:`Compressor`},"temperatures.supply":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Supply`},"temperatures.return":{group:`loop`,kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Return`},"temperatures.outdoor":{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Outdoor`},"energy.thermalKwh":{kind:`counter`,unit:`kWh`,displayName:`Thermal energy`},"energy.electricalKwh":{kind:`counter`,unit:`kWh`,displayName:`Electrical energy`}},items:{path:`circuits`,key:`id`,label:`label`,fields:{currentTemp:{kind:`gauge`,unit:`°C`,deadband:.5,displayName:`Temperature`},targetTemp:{kind:`gauge`,unit:`°C`,minIntervalMs:0,displayName:`Setpoint`},mode:{kind:`enum`,displayName:`Mode`}}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Heat pump`,`Pompa di calore`),order:4e3}},VF=x({position:r().min(0).max(100).nullable().meta(A(`percentage`)),lastFetchedAt:r()}),HF={name:`heating-valve`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Climate],methods:{},status:{schema:VF,kind:`push`},runtimeState:VF,durability:`session`,history:{fields:{position:{kind:`gauge`,unit:`%`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Radiator valve`,`Valvola termostatica`),order:1110,state:[{kind:`numeric`,field:`position`,quantity:L(`the valve opening`,`l’apertura della valvola`),label:L(`Valve opening`,`Apertura della valvola`),unit:`%`,icon:`heater`}]}},UF=S([`s`,`min`]),Axe=S([`switch`,`pet-fountain`]),WF={actuator:`switch`,maxSeconds:10800,unit:`min`,quickRunDefault:30},GF={actuator:`pet-fountain`,maxSeconds:300,unit:`s`,quickRunDefault:60},KF=[M.Switch,M.PetFountain],qF={[M.Switch]:[P.SwitchHeater]};function JF(e,t){return e===M.PetFountain?GF:e===M.Switch&&t===P.SwitchHeater?WF:null}var jxe=1e3,Mxe=6e4;function YF(e,t,n){let r=e-t;return r<=0?0:Math.max(1,Math.ceil(r/(n===`min`?Mxe:jxe)))}function Nxe(e,t){return t===`min`?e*60:e}function XF(e){return e.unit===`min`?Math.floor(e.maxSeconds/60):e.maxSeconds}var ZF=x({duration:r().positive().finite(),unit:UF});function QF(e,t){let n=XF(e);return{duration:Math.min((t!==null&&Number.isFinite(t)&&t>0?t:null)??e.quickRunDefault,n),unit:e.unit}}var $F=S([`unsupported-device`,`over-max`,`command-failed`]),eI=a(`ok`,[x({ok:m(!0),activeUntil:r()}),x({ok:m(!1),reason:$F,maxSeconds:r().nullable()})]),tI=x({activeUntil:r().nullable(),requestedBy:u().nullable(),quickRun:ZF.nullable(),lastFetchedAt:r()}),nI=x({unit:UF,maxDuration:r(),defaultDuration:r()}),rI=x({quickRunDuration:r().positive().finite().nullable().optional()}),iI={name:`timed-run`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:KF,deviceRoles:qF,deviceConfig:{ui:{kind:`derived-form`,builderId:`timed-run`,tab:`general`}},methods:{getOptions:D(x({deviceId:r().int()}),nI),setSettings:D(x({deviceId:r().int(),settings:rI}),v(),{kind:`mutation`,auth:`admin`}),runFor:D(x({deviceId:r().int(),duration:r().positive().finite(),unit:UF}),eI,{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.runForMinutes`,label:L(`Run for minutes`,`Accendi per alcuni minuti`),phrase:L(`Run {device} for {duration} minutes, then switch it off`,`Tieni acceso {device} per {duration} minuti, poi spegnilo`),icon:`timer`,args:{unit:`min`},openArgs:[{key:`duration`,label:L(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}}]},{id:`timedRun.runForSeconds`,label:L(`Run for seconds`,`Accendi per alcuni secondi`),phrase:L(`Run {device} for {duration} seconds, then switch it off`,`Tieni acceso {device} per {duration} secondi, poi spegnilo`),icon:`timer`,args:{unit:`s`},openArgs:[{key:`duration`,label:L(`Seconds`,`Secondi`),offer:{kind:`number`,min:1,step:1,unit:`s`}}]}]}),cancel:D(x({deviceId:r().int()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.cancel`,label:L(`Cancel the timer`,`Annulla il timer`),phrase:L(`Cancel the pending switch-off of {device}`,`Annulla lo spegnimento programmato di {device}`),icon:`timer-off`}]})},status:{schema:tI,kind:`push`},runtimeState:tI,durability:`session`,history:`none`,vocabulary:{noun:L(`Timed run`,`Esecuzione a tempo`),order:2150}},aI=[`on`,`off`,`running`,`idle`,`standby`,`alert`,`offline`,`unknown`],oI=[`success`,`warning`,`danger`,`primary`,`info`,`muted`],sI=[`none`,`pulse`,`spin`,`glow`,`halo`,`wave`,`rise`,`fall`,`tumble`,`equalizer`,`blink`,`breathe`],cI=[`plain`,`heat-rise`,`cool-fall`,`glow`,`water`,`drum`,`sky`,`mist`,`alert-wash`],lI=S(aI),uI=S(oI),Pxe=S(sI),dI=x({icon:md,tone:uI,background:S(cI),animation:Pxe});function fI(e){let t=qE[e];return t===void 0?null:`cap:${e}.${t.field}`}function pI(e){return e.enabledCaps.flatMap(e=>{let t=fI(e),n=qE[e];return t===null||n===void 0?[]:[{key:t,priority:n.priority}]}).sort((e,t)=>t.priority-e.priority).find(t=>e.hasData(t.key))?.key??null}var mI=x({en:u(),it:u()}),hI={en:`—`,it:`—`};function gI(e){return e.en===hI.en&&e.it===hI.it}var _I=[`temperature`,`humidity`,`power`,`contact`,`text`],vI=[`hot`,`mild`,`cold`],yI=[`updated`,`changed`],bI=x({value:r(),quantity:bc}),xI=x({quantity:S(_I),reading:bI.nullable(),icon:md.nullable(),value:mI,unit:u().nullable(),band:S(vI).nullable(),level:r().min(0).max(1).nullable(),word:mI,tone:S(oI),since:r().nullable(),sinceKind:S(yI),historyKey:u().nullable()}),Fxe=3e3,SI=e=>L(e,e),CI=e=>Math.min(1,Math.max(0,e)),Ixe=(e,t)=>String(Number(e.toFixed(t)));function wI(e){return e<12?`cold`:e>28?`hot`:`mild`}var Lxe={hot:L(`Hot`,`Caldo`),mild:L(`Normal`,`Normale`),cold:L(`Cold`,`Freddo`)},Rxe={hot:`warning`,mild:`muted`,cold:`info`};function TI(e,t){let n=wI(e);return{quantity:`temperature`,reading:{value:e,quantity:`temperature`},icon:`thermometer`,value:SI(Ixe(e,1)),unit:`°C`,band:n,level:null,word:Lxe[n],tone:Rxe[n],since:t,sinceKind:`updated`,historyKey:fI(`temperature-sensor`)}}function EI(e,t){let n=e<30,r=e>70;return{quantity:`humidity`,reading:{value:e,quantity:`humidity`},icon:`droplets`,value:SI(String(Math.round(e))),unit:`%`,band:null,level:CI(e/100),word:n?L(`Dry`,`Secco`):r?L(`Humid`,`Umido`):L(`Normal`,`Normale`),tone:n||r?`warning`:`info`,since:t,sinceKind:`updated`,historyKey:fI(`humidity-sensor`)}}function DI(e,t){let n=e>0;return{quantity:`power`,reading:{value:e,quantity:`power`},icon:`zap`,value:SI(String(Math.round(e))),unit:`W`,band:null,level:CI(e/Fxe),word:n?L(`Active`,`Attivo`):L(`Idle`,`Inattivo`),tone:n?`primary`:`muted`,since:t,sinceKind:`updated`,historyKey:fI(`power-meter`)}}function OI(e,t){return{quantity:`contact`,reading:null,icon:e?`door-open`:`door-closed`,value:e?L(`Open`,`Aperto`):L(`Closed`,`Chiuso`),unit:null,band:null,level:+!!e,word:e?L(`Open`,`Aperto`):L(`Closed`,`Chiuso`),tone:e?`warning`:`success`,since:t,sinceKind:`changed`,historyKey:null}}function kI(e,t){return{quantity:`text`,reading:null,icon:null,value:SI(e),unit:null,band:null,level:null,word:L(`Changed`,`Cambiato`),tone:`muted`,since:t,sinceKind:`updated`,historyKey:null}}var zxe={temperature:{icon:`thermometer`,unit:`°C`,sinceKind:`updated`,historyKey:fI(`temperature-sensor`)},humidity:{icon:`droplets`,unit:`%`,sinceKind:`updated`,historyKey:fI(`humidity-sensor`)},power:{icon:`zap`,unit:`W`,sinceKind:`updated`,historyKey:fI(`power-meter`)},contact:{icon:null,unit:null,sinceKind:`changed`,historyKey:null},text:{icon:null,unit:null,sinceKind:`updated`,historyKey:null}};function AI(e){let t=zxe[e];return{quantity:e,reading:null,icon:t.icon,value:hI,unit:t.unit,band:null,level:null,word:hI,tone:`muted`,since:null,sinceKind:t.sinceKind,historyKey:t.historyKey}}var Bxe={power:new Set([`energy-sensor`,`voltage-sensor`,`current-sensor`])};function jI(e,t){return t===null?!0:!(Bxe[e.quantity]?.has(t)??!1)}var MI=`ac.thermostat.heater.heat-pump.fan.washer.dryer.dishwasher.pet-fountain.pet-feeder.vacuum.lawn-mower.tv.speaker.camera.light.cover.lock.alarm.siren.sensor-sparkline.contact.presence.weather.plug.button.update.control-dial.event-stream.gateway.generic`.split(`.`),Vxe=S(MI),NI=[`cool`,`heat`,`dry`,`fan`,`auto`,`playing`,`paused`,`open`,`closed`],PI=x({id:Vxe,mode:S(NI).nullable(),level:r().min(0).max(1).nullable()}),FI={[M.Camera]:`camera`,[M.Light]:`light`,[M.Siren]:`siren`,[M.Switch]:`plug`,[M.Sensor]:`sensor-sparkline`,[M.Climate]:`thermostat`,[M.Button]:`button`,[M.EventEmitter]:`event-stream`,[M.Update]:`update`,[M.Generic]:`generic`,[M.Notifier]:`event-stream`,[M.Script]:`event-stream`,[M.Automation]:`event-stream`,[M.Lock]:`lock`,[M.Cover]:`cover`,[M.Valve]:`control-dial`,[M.Humidifier]:`control-dial`,[M.WaterHeater]:`heater`,[M.HeatPump]:`heat-pump`,[M.EnergySystem]:`generic`,[M.Workload]:`generic`,[M.Fan]:`fan`,[M.MediaPlayer]:`tv`,[M.AlarmPanel]:`alarm`,[M.Control]:`control-dial`,[M.Presence]:`presence`,[M.Weather]:`weather`,[M.WeatherStation]:`weather`,[M.Vacuum]:`vacuum`,[M.LawnMower]:`lawn-mower`,[M.Container]:`generic`,[M.Image]:`camera`,[M.PetFeeder]:`pet-feeder`,[M.PetFountain]:`pet-fountain`,[M.Dishwasher]:`dishwasher`,[M.Washer]:`washer`,[M.Dryer]:`dryer`,[M.Gateway]:`gateway`},II={[P.Siren]:`siren`,[P.Floodlight]:`light`,[P.Spotlight]:`light`,[P.PirSensor]:`presence`,[P.Chime]:`speaker`,[P.Autotrack]:`inherit`,[P.Nightvision]:`inherit`,[P.PrivacyMask]:`inherit`,[P.Doorbell]:`inherit`,[P.CoverBlind]:`inherit`,[P.CoverShutter]:`inherit`,[P.CoverAwning]:`inherit`,[P.CoverCurtain]:`inherit`,[P.CoverGarage]:`inherit`,[P.CoverGate]:`inherit`,[P.CoverDoor]:`inherit`,[P.CoverWindow]:`inherit`,[P.BinaryHelper]:`inherit`,[P.Outlet]:`plug`,[P.SwitchHeater]:`heater`,[P.SwitchFan]:`fan`,[P.SwitchLight]:`light`,[P.PoePort]:`plug`,[P.ClimateAc]:`ac`,[P.ClimateThermostat]:`inherit`,[P.ClimateFloor]:`inherit`,[P.ClimateRadiator]:`inherit`,[P.ClimateHeater]:`inherit`,[P.ClimateHeatPumpCircuit]:`inherit`,[P.MotionSensor]:`presence`,[P.ContactSensor]:`contact`,[P.LeakSensor]:`inherit`,[P.SmokeSensor]:`alarm`,[P.COSensor]:`alarm`,[P.GasSensor]:`alarm`,[P.TamperSensor]:`inherit`,[P.VibrationSensor]:`inherit`,[P.ConnectivitySensor]:`inherit`,[P.SoundSensor]:`inherit`,[P.BinarySensor]:`inherit`,[P.TemperatureSensor]:`sensor-sparkline`,[P.HumiditySensor]:`sensor-sparkline`,[P.AmbientLightSensor]:`inherit`,[P.PressureSensor]:`weather`,[P.WindSensor]:`weather`,[P.RainSensor]:`weather`,[P.UvSensor]:`weather`,[P.SolarRadiationSensor]:`weather`,[P.SoilMoistureSensor]:`inherit`,[P.PowerSensor]:`plug`,[P.EnergySensor]:`plug`,[P.VoltageSensor]:`plug`,[P.CurrentSensor]:`plug`,[P.AirQualitySensor]:`inherit`,[P.BatterySensor]:`inherit`,[P.NumericSensor]:`inherit`,[P.EnumSensor]:`inherit`,[P.DateTimeSensor]:`inherit`,[P.GenericSensor]:`inherit`,[P.NumericControl]:`control-dial`,[P.SelectControl]:`control-dial`,[P.TextControl]:`inherit`,[P.DateTimeControl]:`inherit`,[P.MobilePushNotifier]:`inherit`,[P.MessagingNotifier]:`inherit`,[P.EmailNotifier]:`inherit`,[P.GenericNotifier]:`inherit`,[P.IrTransmitter]:`inherit`,[P.Vm]:`inherit`,[P.AppContainer]:`inherit`,[P.Lxc]:`inherit`,[P.App]:`inherit`,[P.Host]:`inherit`,[P.Ups]:`inherit`};function Hxe(e){return Object.values(M).includes(e)}function Uxe(e){return Object.values(P).includes(e)}function LI(e,t){let n=e!==null&&Uxe(e)?II[e]:void 0;return n!==void 0&&n!==`inherit`?n:Hxe(t)?FI[t]:`generic`}var RI=`progress.run-for.cycle.program.appliance-power.now-playing.playback.volume.source.contact.motion-trigger.lock.alarm.fan.vacuum.vacuum-suction.mower.feeder.fountain.pump-cycle.automation.script.do-not-disturb.brightness.color.cover.valve.humidifier.update.button.climate-mode.climate-fan.setpoint.channel.control.circuit.heat-pump-power.system-mode`.split(`.`),zI=S(RI),BI={progress:L(`Progress`,`Avanzamento`),"run-for":L(`Run for`,`Avvia per`),cycle:L(`Cycle`,`Ciclo`),program:L(`Program`,`Programma`),"appliance-power":L(`Appliance`,`Elettrodomestico`),"now-playing":L(`Now playing`,`In riproduzione`),playback:L(`Playback`,`Riproduzione`),volume:L(`Volume`,`Volume`),source:L(`Source`,`Sorgente`),contact:L(`Door`,`Porta`),"motion-trigger":L(`Motion`,`Movimento`),lock:L(`Lock`,`Serratura`),alarm:L(`Alarm`,`Allarme`),fan:L(`Fan`,`Ventola`),vacuum:L(`Cleaning`,`Pulizia`),"vacuum-suction":L(`Suction`,`Aspirazione`),mower:L(`Mowing`,`Taglio`),feeder:L(`Feed now`,`Eroga ora`),fountain:L(`Pump`,`Pompa`),"pump-cycle":L(`Pump cycle`,`Ciclo pompa`),automation:L(`Automation`,`Automazione`),script:L(`Script`,`Script`),"do-not-disturb":L(`Do not disturb`,`Non disturbare`),brightness:L(`Brightness`,`Luminosità`),color:L(`Colour`,`Colore`),cover:L(`Position`,`Posizione`),valve:L(`Valve`,`Valvola`),humidifier:L(`Humidifier`,`Umidificatore`),update:L(`Firmware`,`Firmware`),button:L(`Action`,`Azione`),"climate-mode":L(`Mode`,`Modalità`),"climate-fan":L(`Fan`,`Ventola`),setpoint:L(`Setpoint`,`Temperatura`),channel:L(`Channel`,`Canale`),control:L(`Control`,`Controllo`),circuit:L(`Circuit`,`Circuito`),"heat-pump-power":L(`Power`,`Potenza`),"system-mode":L(`Mode`,`Modalità`)},VI=o(()=>g([u(),r(),y(),h(u(),VI)])),Wxe=h(u(),VI);function HI(e,t,n){let[r,...i]=t;if(r===void 0)return e;if(i.length===0)return{...e,[r]:n};let a=e[r],o=typeof a==`object`?a:{};return{...e,[r]:HI(o,i,n)}}function UI(e,t,n){return HI(e,t.split(`.`),n)}var WI=x({cap:u(),method:u(),args:Wxe}),Gxe=S([`off-while-running`,`unlock`,`install`,`press`]),GI=x({id:u(),label:mI,icon:md,call:WI,emphasis:S([`primary`,`normal`]),confirm:Gxe.nullable()}),KI=a(`kind`,[x({kind:m(`action`),action:GI}),x({kind:m(`toggle`),id:u(),label:mI,on:y().nullable(),turnOn:GI,turnOff:GI}),x({kind:m(`slider`),id:u(),label:mI,value:r().nullable(),min:r(),max:r(),step:r(),unit:u(),call:WI,valueArg:u()}),x({kind:m(`picker`),id:u(),label:mI,current:u().nullable(),options:C(u()),optionLabels:h(u(),mI).optional(),call:WI,valueArg:u()}),x({kind:m(`number`),id:u(),label:mI,value:r().nullable(),step:r().nullable(),unit:u(),call:WI,valueArg:u()}),x({kind:m(`text`),id:u(),label:mI,value:u().nullable(),call:WI,valueArg:u()})]),Kxe=x({icon:md.nullable(),text:mI,tone:uI}),qxe=new Set([`cover`,`valve`,`lock`,`vacuum`,`playback`,`brightness`]),Jxe=x({id:zI,placement:S([`row`,`scene`]).optional(),label:mI.optional(),group:mI.optional(),pills:C(Kxe).optional(),icon:md,status:mI.nullable(),controls:C(KI),progress:r().min(0).max(1).nullable().optional()}),qI=x({label:mI,value:g([r(),u()]),unit:u().nullable()}),Yxe=x({id:S([`battery`,`network-link`,`integration`]),icon:md,tone:uI,value:r().nullable(),label:mI}),JI=`remote.open`,Xxe=x({commands:r().int().nullable(),open:GI.optional()}),Zxe=x({items:C(x({key:u(),label:u(),level:r().nullable(),needsAttention:y()})),attention:r().int()}),Qxe=a(`kind`,[x({kind:m(`power`),watts:r(),detail:C(qI)}),x({kind:m(`running`),running:y().nullable(),since:r().nullable(),phase:u().nullable(),detail:C(qI)})]),$xe=x({source:S([`switch`,`media-player`,`climate-control`]),on:y().nullable(),assumed:y(),turnOn:GI,turnOff:GI}),eSe=x({activeUntil:r().nullable(),quickRun:ZF,run:GI,cancel:GI,remaining:r().nullable()}),tSe=x({on:y().nullable(),confirmOffWhileRunning:y(),running:y().nullable(),powerOn:GI.nullable(),powerOff:GI.nullable(),restart:GI}),YI=x({token:S(cI),animation:S(sI)}),XI=x({id:S([`power`,`energy`,`battery`,`link`,`phase`,`remaining`,`volume`,`source`,`consumables`,`since`,`speed`,`progress`,`level`,`last-run`,`event`,`members`,`failures`,`reading`,`climate`,`temperature`,`humidity`,`pressure`,`air-quality`,`illuminance`,`valve`]),icon:md.nullable(),text:mI,tone:uI}),ZI=x({label:mI,value:mI,tone:uI.optional(),at:r().optional()}),nSe=x({left:C(ZI).max(2),right:C(ZI).max(2)}),rSe=a(`kind`,[x({kind:m(`artwork`),url:u(),fallback:YI}),x({kind:m(`state`),...YI.shape})]),iSe=x({partId:u(),cap:u()}),aSe=x({deviceId:r().int(),type:u(),role:u().nullable(),name:u(),state:lI,stateAssumed:y(),look:dI,background:rSe,scene:PI,facts:C(XI),sideTiles:nSe,title:mI,caption:mI.optional(),badges:C(Yxe),remote:Xxe.nullable(),historyLabel:mI,consumables:Zxe.nullable(),consumption:Qxe.nullable(),ownPower:$xe.nullable(),timedRun:eSe.nullable(),powerSupply:tSe.nullable(),rows:C(Jxe),measurement:xI.optional(),gated:C(u()),provenance:C(iSe)}),oSe=x({id:S([`timed-run.run`,`timed-run.cancel`]),duration:r(),unit:S([`min`,`s`])}),QI=x({deviceId:r().int(),name:u(),type:u(),state:lI,stateAssumed:y(),look:dI,scene:PI,statusLine:C(mI),primary:KI.nullable(),primaryGated:y().optional(),timedRun:oSe.nullable(),extras:C(KI).max(2).optional(),trailing:XI.nullable(),measurement:xI.optional()}),$I=[`temperature`,`humidity`,`pressure`,`illuminance`,`reading`,`air-quality`,`valve`],sSe=[`power`,`battery`,`consumables`],cSe=new Set($I);function lSe(e){for(let t of sSe){let n=e.facts.find(e=>e.id===t);if(n!==void 0)return n}return e.facts.find(t=>cSe.has(t.id)&&t.text.en===e.title.en)??null}var uSe={[M.Climate]:`climate.mode`};function dSe(e){let t=uSe[e.type];if(t!==void 0){let n=tL(e,t);if(n!==null)return{control:n,gated:!1}}let n=e.ownPower;if(n!==null)return e.gated.includes(`own-power`)?{control:null,gated:!0}:{control:{kind:`toggle`,id:`own-power`,label:n.turnOn.label,on:n.on,turnOn:n.turnOn,turnOff:n.turnOff},gated:!1};for(let t of e.rows){let n=t.controls[0];if(n!==void 0)return e.gated.includes(t.id)?{control:null,gated:!0}:{control:n,gated:!1}}return{control:null,gated:!1}}var fSe={[M.Climate]:[`climate.target`],[M.Vacuum]:[`vacuum.base`],[M.LawnMower]:[`mower.dock`],[M.MediaPlayer]:[`volume.level`,JI],[M.Automation]:[`automation.enabled`]},eL=e=>e.kind===`action`?e.action.id:e.id;function tL(e,t){if(t===`remote.open`){let t=e.remote?.open;return t===void 0||e.gated.includes(`remote`)?null:{kind:`action`,action:t}}for(let n of e.rows){if(e.gated.includes(n.id))continue;let r=n.controls.find(e=>eL(e)===t);if(r!==void 0)return r}return null}function pSe(e,t){let n=fSe[e.type]??[],r=t===null?null:eL(t);return n.filter(e=>e!==r).flatMap(t=>{let n=tL(e,t);return n===null?[]:[n]}).slice(0,2)}function mSe(e,t){let n=e.rows.find(e=>e.id===`now-playing`)?.status??null??e.title,r=e.facts.filter(e=>e!==t).map(e=>e.text).slice(0,3),i=e.timedRun;if(i===null||i.remaining===null)return[n,...r];let a=i.quickRun.unit===`min`?`min`:`s`,o={en:`${i.remaining} ${a}`,it:`${i.remaining} ${a}`};return[n,...r,o]}function hSe(e){let t=e.timedRun;return t===null||e.gated.includes(`timed-run`)?null:{id:t.activeUntil===null?`timed-run.run`:`timed-run.cancel`,duration:t.quickRun.duration,unit:t.quickRun.unit}}function gSe(e){let t=lSe(e),{control:n,gated:r}=dSe(e);return{deviceId:e.deviceId,name:e.name,type:e.type,state:e.state,stateAssumed:e.stateAssumed,look:e.look,scene:e.scene,statusLine:mSe(e,t),primary:n,primaryGated:r,timedRun:hSe(e),extras:pSe(e,n),trailing:t,...e.measurement===void 0?{}:{measurement:e.measurement}}}var _Se=x({deviceId:r().int().nonnegative(),canActuate:y().optional()}),vSe=x({deviceIds:C(r().int().nonnegative()).max(500),canActuate:y().optional()}),nL=x({type:u(),rows:C(zI)}),rL={name:`hero-layout`,scope:`system`,mode:`singleton`,methods:{getHeroModel:D(_Se,aSe.nullable(),{auth:`protected`,role:`viewer`}),getRowModels:D(vSe,C(QI.nullable()),{auth:`protected`,role:`viewer`}),getLayout:D(x({deviceType:u(),role:u().nullable().optional()}),nL,{auth:`protected`,role:`viewer`})},vocabulary:{notOperatorFacing:`the device hero model — read-only data the UI draws, never actuated`}},iL=x({on:y(),currentHumidity:r().min(0).max(100).nullable().meta(A(`humidity`)),targetHumidity:r().min(0).max(100).nullable().meta(A(`humidity`)),mode:u().nullable(),availableModes:C(u()),action:u().nullable(),minHumidity:r().nullable().meta(A(`humidity`)),maxHumidity:r().nullable().meta(A(`humidity`)),lastChangedAt:r()}),aL={name:`humidifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Humidifier],power:{kind:`field`,field:`on`,set:`setOn`},methods:{setOn:D(x({deviceId:r().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.on`,label:L(`Humidifier on`,`Umidificatore acceso`),phrase:L(`Turn on {device}`,`Accendi {device}`),icon:`power`,effect:{field:`on`,value:!0},args:{on:!0}},{id:`humidifier.off`,label:L(`Humidifier off`,`Umidificatore spento`),phrase:L(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`on`,value:!1},args:{on:!1}}]}),setTargetHumidity:D(x({deviceId:r().int().nonnegative(),humidity:r().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.target`,label:L(`Set humidity`,`Imposta l’umidità`),phrase:L(`Set {device} to {humidity} humidity`,`Imposta {device} al {humidity} di umidità`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`humidity`},openArgs:[{key:`humidity`,label:L(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMode:D(x({deviceId:r().int().nonnegative(),mode:u().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.mode`,label:L(`Set mode`,`Imposta la modalità`),phrase:L(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`list`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:L(`Mode`,`Modalità`),offer:{kind:`dynamic`,from:`status`,field:`availableModes`}}]}]})},status:{schema:iL,kind:`push`},runtimeState:iL,durability:`session`,history:{fields:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}}},vocabulary:{noun:L(`Humidifier`,`Umidificatore`),order:1090,state:[{kind:`boolean`,field:`on`,label:L(`On`,`Acceso`),whenTrue:L(`When {device} turns on`,`Quando {device} si accende`),whenFalse:L(`When {device} turns off`,`Quando {device} si spegne`),icon:`power`},{kind:`numeric`,field:`currentHumidity`,quantity:L(`the humidity`,`l’umidità`),label:L(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},oL=x({humidity:r().min(0).max(100).nullable().meta(A(`humidity`,{precision:0,label:`Humidity`})),lastFetchedAt:r()}),sL={name:`humidity-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor,M.Climate],methods:{},status:{schema:oL,kind:`push`},runtimeState:oL,durability:`restored`,history:{primary:`humidity`,priority:90,fields:{humidity:{kind:`gauge`,unit:`%`,deadband:.5}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Humidity`,`Umidità`),order:5120,state:[{kind:`numeric`,field:`humidity`,quantity:L(`the humidity`,`l’umidità`),label:L(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},cL=x({url:u().nullable(),lastUpdated:r().nullable().meta(A(`none`))}),lL={name:`image`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Image],methods:{},status:{schema:cL,kind:`push`},runtimeState:cL,durability:`session`,history:`none`,vocabulary:{noun:L(`Image`,`Immagine`),order:3130}},uL=S([`0`,`90`,`180`,`270`]),dL=S([`auto`,`manual`]),fL=S([`auto`,`manual`]),pL=S([`off`,`blc`,`wdr`,`hlc`]),mL=x({min:r(),max:r(),step:r()}),hL=x({brightness:r().optional().meta(A(`none`)),contrast:r().optional().meta(A(`none`)),saturation:r().optional().meta(A(`none`)),sharpness:r().optional().meta(A(`none`)),mirror:y().optional(),flip:y().optional(),rotate:uL.optional(),whiteBalance:dL.optional(),warmth:r().optional().meta(A(`none`)),exposureMode:fL.optional(),backlightMode:pL.optional(),lastFetchedAt:r()}),gL=x({supportsBrightness:y(),brightness:mL.optional(),supportsContrast:y(),contrast:mL.optional(),supportsSaturation:y(),saturation:mL.optional(),supportsSharpness:y(),sharpness:mL.optional(),supportsMirror:y(),supportsFlip:y(),rotateOptions:C(uL),whiteBalanceModes:C(dL),supportsWarmth:y(),warmth:mL.optional(),exposureModes:C(fL),backlightModes:C(pL)}),_L=x({brightness:r().optional(),contrast:r().optional(),saturation:r().optional(),sharpness:r().optional(),mirror:y().optional(),flip:y().optional(),rotate:uL.optional(),whiteBalance:dL.optional(),warmth:r().optional(),exposureMode:fL.optional(),backlightMode:pL.optional()}),vL={name:`image-settings`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`image-settings`,tab:`image`}},methods:{getOptions:D(x({deviceId:r()}),gL),setSettings:D(x({deviceId:r(),settings:_L}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:hL,kind:`poll`},runtimeState:hL,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Image settings`,`Impostazioni immagine`),order:3140}},yL=x({id:u(),addonId:u(),name:u(),enabled:y(),info:h(u(),w()).readonly(),originStableId:u().optional(),createdAt:r(),updatedAt:r(),processState:u()}),bL=x({id:u(),addonId:u(),name:u(),enabled:y(),info:h(u(),w()).readonly(),originStableId:u().optional(),createdAt:r(),updatedAt:r()}),xL=x({addonId:u(),name:u(),providerLabel:u().optional(),description:u(),iconUrl:u().nullable(),color:u(),instanceMode:u(),mode:S([`standalone`,`account`,`broker`]),discoveryMode:u(),kind:S([`device-adoption`,`device-provider`]),brokerKind:u().nullable(),supportsLocationImport:y(),canTest:y(),existingInstances:C(x({id:u(),name:u()})),canAdd:y()}),SL=S([`validated`,`rejected`,`inconclusive`,`unsupported`]),CL=x({success:y(),error:u().optional(),status:SL.optional(),testedBy:u().nullable().optional(),latencyMs:r().nonnegative().optional(),detail:u().optional()}),wL=x({id:u(),name:u().optional(),enabled:y().optional(),info:h(u(),w()).optional()}),TL=x({success:y(),deletedId:u()}),EL={name:`integrations`,scope:`system`,mode:`singleton`,methods:{list:D(v(),C(yL)),get:D(x({id:u()}),yL),getByAddonId:D(x({addonId:u()}),bL.nullable()),listByAddon:D(x({addonId:u()}),C(bL)),adoptInstanceRows:D(x({addonId:u(),rows:C(x({id:u().min(1),name:u(),enabled:y(),stated:y()}))}),x({created:r().int(),updated:r().int(),conflicts:C(x({id:u(),ownerAddonId:u()}))}),{kind:`mutation`,auth:`admin`}),update:D(wL,bL,{kind:`mutation`,auth:`admin`}),delete:D(x({id:u()}),TL,{kind:`mutation`,auth:`admin`}),getAvailableTypes:D(v(),C(xL),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:k.ADDON_ADMIN}},ySe=ye(),DL=u().min(1),OL=S([`single`,`multiple`]),kL=S([`devices`,`services`]),AL=x({id:u().min(1),label:u().min(1),functionCap:u().min(1),brokerKind:u().min(1).optional(),alsoServes:C(u().min(1)).optional(),iconUrl:u().min(1).optional(),iconMediaType:u().min(1).optional(),role:kL.optional(),canTest:y().optional(),creatable:y().optional(),signIn:x({basePath:u().min(1),methods:C(S([`device-code`,`proxy`])).optional()}).optional(),connectPath:u().min(1).optional(),disconnectPath:u().min(1).optional(),widgets:C(x({id:u().min(1),placement:S([`connection`,`model`])})).optional()}),jL=x({mode:S([`none`,`lan`,`account`]),scopedToInstance:y()}),ML=x({kind:u().min(1),field:u().min(1),to:x({cap:u().min(1),kind:u().min(1).optional()})}),NL=x({role:kL,discovery:jL.optional(),instanceMode:OL,kind:u(),canTest:y(),kinds:C(AL).min(1),allowRestoreId:y().optional(),mintsId:y().optional(),links:C(ML).optional(),userScoped:y().optional()}),PL=x({state:S([`ok`,`off`,`error`,`unknown`]),detail:u().optional(),label:u().optional()}),FL=S([`scan`,`children`,`none`]),IL=x({id:DL,name:u(),configured:y(),enabled:y().optional(),kind:u().min(1),formValues:h(u(),w()),status:PL.optional(),lastCheckedAt:r().optional(),addDevice:FL.optional()}),LL=x({id:DL,name:u().min(1).optional(),values:h(u(),w())}),RL={name:`integration-instances`,scope:`system`,mode:`collection`,methods:{describe:D(v(),NL,{auth:`admin`}),instanceFormSchema:D(x({id:DL.nullable(),kind:u().min(1).optional(),mode:S([`standalone`,`account`,`broker`]).optional(),candidateStableId:u().min(1).optional()}),ySe,{auth:`admin`}),listInstances:D(ce({}),C(IL).readonly(),{auth:`protected`,caller:`scoped`}),getInstance:D(x({id:DL}),IL.nullable(),{auth:`protected`,caller:`scoped`}),createInstance:D(x({id:DL.optional(),name:u().min(1),kind:u().min(1).optional(),values:h(u(),w()).optional(),originStableId:u().min(1).optional(),seed:x({info:h(u(),w())}).optional()}),x({id:u()}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),updateInstance:D(LL,x({ok:m(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),setInstanceEnabled:D(x({id:DL,enabled:y()}),x({ok:m(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),deleteInstance:D(x({id:DL}),x({ok:m(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),testInstance:O(x({id:DL.nullable(),values:h(u(),w()),kind:u().min(1).optional()}),CL,{kind:`mutation`,auth:`protected`,caller:`scoped`})},vocabulary:{notOperatorFacing:k.INTERNAL}},zL=x({codecs:C(u()),sampleRate:r().meta(A(`none`)),duplex:S([`half`,`full`]),maxBacklogMs:r().meta(A(`duration-ms`))}),BL=x({talking:y(),lastSessionAt:r().nullable(),ability:zL.nullable()}),bSe=S([`opus`,`s16le`,`g711ulaw`,`g711alaw`]),VL={name:`intercom`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],methods:{startSession:D(x({deviceId:r()}),x({sessionId:u(),sdpOffer:u()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),handleAnswer:D(x({deviceId:r(),sessionId:u(),sdpAnswer:u()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),stopSession:D(x({deviceId:r(),sessionId:u()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),startTalkSession:D(x({deviceId:r()}),x({sessionId:u()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`two-way talk is a person speaking through the viewer, not an automation step`}),pushTalkAudio:D(x({deviceId:r(),audioBase64:u(),codec:bSe.optional(),sampleRate:r().int().positive().optional(),channels:r().int().positive().optional(),sequenceNumber:r().int()}),x({accepted:y()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),endTalkSession:D(x({deviceId:r()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`})},events:{onStatusChanged:{data:x({deviceId:r(),status:BL}),notOperatorFacing:"the `talking` state trigger phrases both edges of this change"}},status:{schema:BL,kind:`command-driven`},runtimeState:BL,durability:`session`,history:`none`,vocabulary:{noun:L(`Intercom`,`Citofono`),order:3150,state:[{kind:`boolean`,field:`talking`,label:L(`Talking`,`In conversazione`),whenTrue:L(`When someone starts talking through {device}`,`Quando qualcuno inizia a parlare tramite {device}`),whenFalse:L(`When the conversation on {device} ends`,`Quando la conversazione su {device} finisce`),icon:`mic`}]}},HL=S([`carrierHz`,`dutyCyclePercent`,`repeat`,`repeatDelayMs`]),UL=S([`ir`,`rf`]),WL=x({ok:m(!0),ignoredSettings:C(u())}),GL=x({media:C(UL),settable:C(HL),maxTimings:r().int().positive(),learn:y().default(!1),formats:C(bT).default([])}),KL=2e4,qL=6e4,JL=x({native:ST.nullable(),timings:dT,carrierHz:r().int().positive().nullable()}),YL=x({at:r(),ok:y(),error:u().nullable()}),XL=YL.extend({medium:UL}),ZL=x({lastSend:XL.nullable(),lastLearn:YL.nullable(),lastFetchedAt:r()});function QL(e){return!(e.kind===`learn`&&e.error===`ir-transmitter.learn-unsupported`)}function xSe(e,t,n){let r=e??{lastSend:null,lastLearn:null,lastFetchedAt:n};return QL(t)?t.kind===`send`?{lastSend:{at:n,ok:t.ok,error:t.error,medium:t.medium},lastLearn:r.lastLearn,lastFetchedAt:n}:{lastSend:r.lastSend,lastLearn:{at:n,ok:t.ok,error:t.error},lastFetchedAt:n}:r}function SSe(e){return _i(e)?.code??null}var $L={name:`ir-transmitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Generic],methods:{send:D(x({deviceId:r().int().nonnegative(),timings:dT.optional(),native:ST.optional(),settings:fT.optional()}).refine(e=>e.timings===void 0!=(e.native===void 0),{message:`send takes exactly one of timings or native`}),WL,{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it`}),learn:D(x({deviceId:r().int().nonnegative(),timeoutMs:r().int().positive().max(qL).default(KL)}),JL,{kind:`mutation`,auth:`protected`,notOperatorFacing:`an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal`}),getInfo:D(x({deviceId:r().int().nonnegative()}),GL,{kind:`query`,auth:`protected`})},runtimeState:ZL,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`IR / RF transmitter`,`Trasmettitore IR / RF`),order:1140}},eR=S([`key-missing`,`wrong-key`,`key-file-unreadable`,`store-unavailable`,`not-initialized`,`decrypt-failed`]),tR=a(`state`,[x({state:m(`ready`)}),x({state:m(`locked`),reason:eR})]),nR=a(`kind`,[x({kind:m(`value`),value:u(),version:r().int()}),x({kind:m(`missing`)}),x({kind:m(`unavailable`),reason:eR}),x({kind:m(`forbidden`)})]),rR=h(u(),nR),iR=x({ref:u(),owner:u(),scope:u(),fieldPath:u(),version:r().int(),createdAt:r(),updatedAt:r(),updatedBy:u(),lastReadAt:r().nullable()}),aR=C(u().min(1)).max(512),oR={name:`keychain`,scope:`system`,mode:`singleton`,internal:!0,methods:{put:D(x({ref:u().min(1),value:u().min(1)}),x({ref:u(),version:r().int()}),{kind:`mutation`,auth:`admin`}),resolve:D(x({refs:aR}),rR,{auth:`admin`}),delete:D(x({refs:aR}),x({deleted:r().int()}),{kind:`mutation`,auth:`admin`}),deleteDeviceScope:D(x({deviceId:r().int()}),x({refs:C(u()).readonly()}),{kind:`mutation`,auth:`admin`}),releaseRecordRefs:D(x({refs:aR,onBehalfOf:u().min(1)}),x({released:r().int()}),{kind:`mutation`,auth:`admin`}),listMeta:D(x({}),C(iR).readonly(),{auth:`admin`}),getState:D(x({}),tR,{auth:`admin`})},vocabulary:{notOperatorFacing:k.IDENTITY}},sR=S([`mounted-file`,`previous-mounted-file`,`platform`,`default-file`]),cR=x({kind:sR,path:u().optional(),sharesBackupWithDatabase:y()}),lR=`trigger-file`,uR=x({id:u(),at:r(),actor:u(),lockedReason:u().nullable(),archived:r().int(),archivedCollection:u().nullable(),archivedKeysCollection:u().nullable(),clearedSettingsKeys:C(u()).readonly(),acknowledgedAt:r().nullable()}),dR=x({keychain:tR,keySource:cR.nullable(),configuredSource:cR,fingerprint:u().nullable(),activeKeyId:u().nullable(),rotationPending:y(),retiredWraps:r().int(),recoveryKeyDownloadedAt:r().nullable(),secretCount:r().int(),lastReset:uR.nullable()}),fR=S([`in-use`,`orphan`,`unknown`]),pR=iR.extend({usage:fR}),mR=S([`put`,`delete`,`reveal`,`rotate-master-key`,`purge-retired-keys`,`download-recovery-key`,`delete-orphans`,`reset`,`acknowledge-reset`,`initialize`]),hR=x({id:u(),at:r(),action:mR,actor:u(),ref:u().nullable(),detail:u().nullable()}),gR=`RESET KEYCHAIN`,_R=S([`jwt-signing-key`]),vR={name:`keychain-admin`,scope:`system`,mode:`singleton`,methods:{status:D(x({}),dR,{auth:`admin`}),listSecrets:D(x({}),C(pR).readonly(),{auth:`admin`}),listAudit:D(x({limit:r().int().min(1).max(500).optional()}),C(hR).readonly(),{auth:`admin`}),reveal:D(x({ref:u().min(1)}),x({value:u(),version:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),setSystemSecret:D(x({name:_R,value:u().min(16)}),x({ref:u(),version:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),importSecret:D(x({ref:u().min(1),value:u().min(1)}),x({ref:u(),version:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteOrphans:D(x({refs:C(u().min(1)).max(1e3)}),x({deleted:C(u()).readonly(),kept:C(x({ref:u(),usage:fR})).readonly()}),{kind:`mutation`,auth:`admin`,caller:`required`}),rotateMasterKey:D(x({}),x({fingerprint:u(),keySource:cR}),{kind:`mutation`,auth:`admin`,caller:`required`}),purgeRetiredKeys:D(x({}),x({purged:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),downloadRecoveryKey:D(x({}),x({key:u(),fingerprint:u(),keySource:cR}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetKeychain:D(x({confirm:m(gR)}),x({archivedCollection:u().nullable(),archived:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetReport:D(x({}),x({reset:uR.nullable(),pendingReentry:C(iR).readonly()}),{auth:`admin`}),acknowledgeReset:D(x({}),x({acknowledged:y()}),{kind:`mutation`,auth:`admin`,caller:`required`})},vocabulary:{notOperatorFacing:k.IDENTITY}},yR=S([`idle`,`mowing`,`paused`,`docked`,`error`]),bR=S([`info`,`warning`,`error`]),xR=x({activity:yR,batteryLevel:r().min(0).max(100).nullable().meta(A(`percentage`)),progress:r().min(0).max(100).nullable().meta(A(`percentage`)),currentCode:r().nullable().meta(A(`none`)),currentCodeLabel:u().nullable(),severity:bR,lastChangedAt:r()}),SR={name:`lawn-mower-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.LawnMower],methods:{startMowing:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.start`,label:L(`Start mowing`,`Avvia il taglio`),phrase:L(`Start {device} mowing`,`Fai partire il taglio di {device}`),icon:`play`}]}),pause:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.pause`,label:L(`Pause mower`,`Metti in pausa il tosaerba`),phrase:L(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),dock:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.dock`,label:L(`Dock mower`,`Riporta alla base`),phrase:L(`Send {device} back to its dock`,`Rimanda {device} alla base`),icon:`house`}]})},status:{schema:xR,kind:`push`},runtimeState:xR,durability:`session`,history:{fields:{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}}},vocabulary:{noun:L(`Robot mower`,`Robot tosaerba`),order:2010,state:[{kind:`enum`,field:`activity`,label:L(`Activity`,`Attività`),values:[{value:`idle`,label:L(`Idle`,`Inattivo`)},{value:`mowing`,label:L(`Mowing`,`In taglio`),phrase:L(`When {device} starts mowing`,`Quando {device} inizia a tagliare`)},{value:`paused`,label:L(`Paused`,`In pausa`)},{value:`docked`,label:L(`Docked`,`Alla base`),phrase:L(`When {device} docks`,`Quando {device} arriva alla base`)},{value:`error`,label:L(`Error`,`Errore`),phrase:L(`When {device} reports an error`,`Quando {device} segnala un errore`)}],icon:`bot`},{kind:`numeric`,field:`batteryLevel`,quantity:L(`the battery level`,`il livello della batteria`),label:L(`Battery`,`Batteria`),unit:`%`,icon:`battery`}]}},CR=6e5,CSe=60*6e4,wR=x({inputTokens:r(),outputTokens:r()}),TR=S([`timeout`,`rate-limited`,`auth`,`refusal`,`bad-request`,`unavailable`,`no-profile`,`budget-exceeded`,`adapter-error`]),ER=x({ok:m(!0),text:u(),model:u(),usage:wR,truncated:y(),latencyMs:r()}),DR=S([`guardrail`,`model`]),OR=x({ok:m(!1),code:TR,message:u(),retryAfterMs:r().optional(),refusalSource:DR.optional()}),kR=a(`ok`,[ER,OR]),AR=x({bytes:b(Uint8Array),mimeType:u()}),jR=x({enabled:y().default(!1),maxAttempts:r().int().min(1).max(5).default(1)}),wSe={totalMs:6e4,connectMs:1e4,firstTokenMs:12e4,idleMs:6e4},MR=x({addonId:u().optional(),profileId:u().optional(),consumer:u(),system:u().optional(),prompt:u(),jsonSchema:h(u(),w()).optional(),maxTokens:r().int().positive().optional(),temperature:r().optional(),topP:r().min(0).max(1).optional(),topK:r().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),timeoutMs:r().int().positive().optional(),retry:jR.optional(),requestId:u().optional()}),NR=x({url:u(),filename:u(),sizeBytes:r(),sha256:u().optional()}),PR=a(`kind`,[x({kind:m(`catalog`),catalogId:u()}),x({kind:m(`url`),url:u(),sha256:u().optional(),label:u().optional(),sizeBytes:r().optional(),extraFiles:C(NR).optional()}),x({kind:m(`path`),path:u()})]),FR=x({nodeId:u(),engine:S([`llama-cpp`]),model:PR,contextSize:r().int().default(4096),gpuLayers:r().int().default(0),threads:r().int().optional(),parallel:r().int().default(1),batchSize:r().int().positive().optional(),ubatchSize:r().int().positive().optional(),flashAttention:y().default(!1),mlock:y().default(!1),noMmap:y().default(!1),cacheTypeK:S([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),cacheTypeV:S([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),extraArgs:C(u()).default([]),autoStart:y().default(!1),idleStopMinutes:r().int().default(30)}),IR=x({phase:S([`downloading`,`verifying`]),file:u(),fileIndex:r().int(),fileCount:r().int(),downloadedBytes:r(),totalBytes:r().optional()}),LR=x({nodeId:u(),state:S([`stopped`,`downloading`,`starting`,`ready`,`crashed`,`failed`]),pid:r().optional(),port:r().optional(),modelPath:u().optional(),modelId:u().optional(),downloadProgress:r().min(0).max(1).optional(),download:IR.optional(),lastError:u().optional(),crashesInWindow:r(),memoryBytes:r().optional(),vramBytes:r().optional()}),RR=x({file:u(),sizeBytes:r(),catalogId:u().optional(),installedAt:r().optional(),path:u().optional()}),zR=x({nodeId:u(),modelsBytes:r(),freeBytes:r().optional()}),BR=MR.extend({images:C(AR).optional(),runtime:FR,timeoutMs:r().int().positive().optional()}),VR=S([`deviceNotEligible`,`appleIntelligenceNotEnabled`,`modelNotReady`,`osTooOld`,`helperMissing`,`helperCrashed`]),HR=a(`state`,[x({state:m(`available`),osVersion:u(),contextSize:r().int().positive(),languages:C(u()),imageInput:y()}),x({state:m(`unavailable`),reason:VR,osVersion:u().nullable(),detail:u()}),x({state:m(`unsupported-platform`),platform:u()}),x({state:m(`unknown`),error:u()})]),UR=MR.extend({images:C(AR).optional(),timeoutMs:r().int().positive().optional()}),WR=x({requestId:u()}),GR={name:`llm-runtime`,scope:`system`,mode:`singleton`,internal:!0,methods:{complete:D(BR,kR,{kind:`mutation`,auth:`admin`,timeoutMs:CR}),ensureStarted:D(x({runtime:FR}),LR,{kind:`mutation`,auth:`admin`,timeoutMs:CR}),stop:D(x({}),v(),{kind:`mutation`,auth:`admin`}),status:D(x({}),LR,{auth:`admin`}),installModel:D(x({model:PR}),v(),{kind:`mutation`,auth:`admin`,timeoutMs:CSe}),deleteModel:D(x({file:u()}),v(),{kind:`mutation`,auth:`admin`}),listLocalModels:D(x({}),C(RR),{auth:`admin`}),getDiskUsage:D(x({}),zR,{auth:`admin`}),cancel:D(WR,v(),{kind:`mutation`,auth:`admin`}),appleAvailability:D(x({}),HR,{auth:`admin`}),completeApple:D(UR,kR,{kind:`mutation`,auth:`admin`,timeoutMs:CR})},vocabulary:{notOperatorFacing:k.ML}},KR=/^[a-z0-9][a-z0-9-]{0,63}$/,qR=u().regex(KR,`a kind id is lower-case letters, digits and dashes`),JR=x({vision:y(),tools:y(),streaming:y(),reasoning:y().nullable().optional()}),YR=x({id:u(),label:u().optional(),contextLength:r().int().positive().optional(),features:JR.partial().optional()}),XR=h(u(),w()),TSe=x({id:u(),name:u(),kind:qR,addonId:u(),enabled:y(),model:u(),supportsVision:y(),temperature:r().min(0).max(2).optional(),topP:r().min(0).max(1).optional(),topK:r().int().positive().optional(),maxTokens:r().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),contextLength:r().int().positive().optional(),systemPrompt:u().optional(),timeoutMs:r().int().positive().default(6e4),connectTimeoutMs:r().int().positive().default(1e4),firstTokenTimeoutMs:r().int().positive().default(12e4),idleTimeoutMs:r().int().positive().default(6e4),retry:jR.default({enabled:!1,maxAttempts:1}),toolsEnabled:y().default(!1),providerConfig:XR.default({})}),ZR=S([`temperature`,`topP`,`topK`,`maxTokens`,`reasoningEffort`,`contextLength`,`systemPrompt`,`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`]),QR=x({id:u(),placement:S([`connection`,`model`]),requires:C(u()).optional()}),$R=w(),ESe=x({kind:qR,label:u(),icon:u(),addonId:u(),connectionSchema:$R,advancedSchema:$R.optional(),features:JR,visionEditable:y(),modelCatalog:S([`fetch`,`static`,`none`]),staticModels:C(YR).optional(),profileFields:C(ZR),providerWidgets:C(QR).optional()}),ez=x({addonId:u(),kind:qR,profileId:u().optional(),connection:XR.optional()}),tz=S([`auth`,`network`,`unsupported`,`invalid`]),nz=a(`ok`,[x({ok:m(!0),models:C(YR)}),x({ok:m(!1),code:tz,message:u()})]),rz=g([x({consumer:u()}),x({purpose:S([`text`,`vision`])})]),iz=x({selector:rz,profileId:u()}),az=x({day:u(),consumer:u(),profileId:u(),calls:r(),okCalls:r(),errorCalls:r(),inputTokens:r(),outputTokens:r(),avgLatencyMs:r()}),oz=x({id:u(),label:u(),family:u(),purpose:S([`text`,`vision`]),url:u(),sha256:u(),sizeBytes:r(),quantization:u(),minRamBytes:r(),contextSizeDefault:r().int(),mmprojUrl:u().optional()}),sz=a(`ok`,[x({ok:m(!0),model:PR,label:u(),repo:u(),quantization:u(),purpose:S([`text`,`vision`]),totalBytes:r(),extraFilenames:C(u())}),x({ok:m(!1),code:u(),message:u(),candidates:C(u()).optional(),requiredBytes:r().optional()})]),cz=x({nodeId:u(),reachable:y(),status:LR.optional(),disk:zR.optional(),error:u().optional(),apple:HR.optional()}),DSe=MR.extend({images:C(AR).min(1)}),lz=x({addonId:u(),profileId:u()}),uz={name:`llm`,scope:`system`,mode:`collection`,internal:!1,providerKind:`ai`,nodeIdMode:`data`,methods:{generate:D(MR,kR,{kind:`mutation`,timeoutMs:CR}),generateVision:D(DSe,kR,{kind:`mutation`,timeoutMs:CR}),cancel:D(x({addonId:u().optional(),requestId:u()}),v(),{kind:`mutation`}),listModels:D(ez,nz,{kind:`mutation`,auth:`admin`}),getDefaults:D(x({}),C(iz)),setDefault:D(x({selector:rz,profileId:u().nullable()}),v(),{kind:`mutation`,auth:`admin`}),getUsage:D(x({since:r().optional(),until:r().optional(),consumer:u().optional(),profileId:u().optional()}),C(az)),listModelCatalog:D(x({}),C(oz)),listRuntimeNodes:D(x({}),C(cz)),listNodeModels:D(x({nodeId:u()}),C(RR)),resolveModelRef:D(x({ref:u(),maxBytes:r().positive().optional()}),sz,{kind:`mutation`,auth:`admin`}),installModel:D(x({nodeId:u(),model:PR}),v(),{kind:`mutation`,auth:`admin`}),deleteModel:D(x({nodeId:u(),file:u()}),v(),{kind:`mutation`,auth:`admin`}),getRuntimeStatus:D(lz,LR),startRuntime:D(lz,LR,{kind:`mutation`,auth:`admin`}),stopRuntime:D(lz,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.ML}},dz=[`decode`,`transcode`,`recording`,`streaming`,`detection`],fz=[`measured`,`accounted`,`unattributable`],pz=x({role:S(dz),deviceId:r().int().positive().nullable(),attribution:S(fz),unit:u(),pid:r().int().positive().optional(),startedAtMs:r().optional(),cpuSeconds:r().optional(),rssBytes:r().optional()}),mz={name:`load-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:D(v(),C(pz).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.INTERNAL}},hz=`https://camstack.zentik.app`,gz=`/viewer/camstack`;function _z(e){if(e==null||e===``)return!1;try{return new URL(e).origin===hz}catch{return!1}}function OSe(e){let t=e.baseUrl??e.resolved;return _z(t)?{form:`app`,hubBaseUrl:e.appLinkHub??null}:{form:`hub`,hubBaseUrl:t}}function vz(e){let t;try{t=new URL(e)}catch{return null}return t.protocol!==`https:`&&t.protocol!==`http:`||t.username!==``||t.password!==``||t.hostname===``?null:t.origin}function kSe(e){let t=e=>e.kind!==`public`||!e.baseUrl.startsWith(`https://`)?null:e.interfaceKind===`public`?0:e.interfaceKind===`vpn`?1:null;return e.flatMap(e=>{let n=t(e),r=vz(e.baseUrl);return n===null||r===null?[]:[{r:n,p:e.priority,origin:r}]}).toSorted((e,t)=>e.r-t.r||e.p-t.p)[0]?.origin??null}function ASe(e){switch(e.kind){case`camera`:{if(!Number.isInteger(e.deviceId)||e.deviceId<=0)return null;let t=e.atMs;return{path:`/camera/${String(e.deviceId)}`,query:t!==void 0&&Number.isFinite(t)?[[`at`,String(Math.trunc(t))]]:[]}}case`events`:return{path:`/events`,query:[]};case`notifications`:return{path:`/notifications`,query:[]}}}function yz(e){return e.length===0?``:`?${e.map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`}function jSe(e){let t=ASe(e.destination);if(t===null)return null;let n=e.base.hubBaseUrl,r=n===null?``:n.replace(/\/+$/,``);if(e.base.form===`app`){let e=r===``?null:vz(r),n=e===null?t.query:[...t.query,[`hub`,e]];return`${hz}${t.path}${yz(n)}`}return r===``||_z(r)?null:`${r}${gz}${t.path}${yz(t.query)}`}var bz=[`appConnections`,`notificationTaps`,`internal`,`publicEndpoint`],MSe=[`notificationTaps`,`internal`,`publicEndpoint`];function NSe(e){return e!==`appConnections`}var PSe={appConnections:[],notificationTaps:null,internal:null,publicEndpoint:null},FSe=/^\d{1,3}(?:\.\d{1,3}){3}$/;function xz(e){try{let t=new URL(e).hostname;return t.length>0?t:null}catch{return null}}function ISe(e){return e.replace(/\/+$/,``)}function Sz(e){return e.kind===`public`&&e.interfaceKind===`vpn`}function LSe(e){return e.kind===`public`&&e.interfaceKind===`public`}function Cz(e){return(e.kind===`lan-ipv4`||e.kind===`lan-ipv6`)&&e.plausible}function wz(e){if(e.kind!==`lan-ipv4`||!e.plausible)return!1;let t=xz(e.baseUrl);return t!==null&&FSe.test(t)}function Tz(e){return e.stable===!1}function RSe(e,t){return t.kind===`loopback`||t.kind===`app-link`||t.kind===`custom`||xz(t.baseUrl)===null||Tz(t)?null:e===`internal`?wz(t)?0:Cz(t)?1:Sz(t)?2:null:LSe(t)?0:Sz(t)?1:wz(t)?2:Cz(t)?3:null}var zSe=new Set([`localhost`,`0.0.0.0`,`::1`,`[::1]`,`::`,`[::]`]);function BSe(e){let t=e.toLowerCase();return zSe.has(t)||t.endsWith(`.localhost`)?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}function Ez(e){let t=e.trim();if(t===``)return{ok:!1,reason:`Enter an address, e.g. https://192.0.2.20:4443.`};let n;try{n=new URL(t)}catch{return{ok:!1,reason:`Not a URL — include http:// or https://.`}}return n.protocol!==`https:`&&n.protocol!==`http:`?{ok:!1,reason:`Use an http:// or https:// address.`}:n.username!==``||n.password!==``?{ok:!1,reason:`The address must not carry a user name or password.`}:n.hostname===``?{ok:!1,reason:`The address has no host.`}:BSe(n.hostname)?{ok:!1,reason:`A loopback address names whoever dials it, never this hub — use an address other machines reach.`}:n.pathname!==`/`||n.search!==``||n.hash!==``?{ok:!1,reason:`Enter only the address (scheme, host and port), without a path.`}:{ok:!0,baseUrl:n.origin}}var Dz=`The public endpoint needs an https:// address: passkeys and most identity providers refuse a plain-http origin. Accept http only when sign-in and notification links never leave your own network.`;function Oz(e,t,n={}){if(_z(t))return e===`notificationTaps`?{ok:!0,baseUrl:hz}:{ok:!1,reason:`The CamStack app link is not a hub address — only notification taps can use it.`};let r=Ez(t);return r.ok&&e===`publicEndpoint`&&r.baseUrl.startsWith(`http:`)&&n.acceptInsecureHttp!==!0?{ok:!1,reason:Dz}:r}function kz(e,t){if(t===null||t===``)return null;let n=Oz(e,t,{acceptInsecureHttp:!0});return n.ok?n.baseUrl:null}function VSe(e,t){let n=e.flatMap(e=>{let n=RSe(t,e);return n===null?[]:[{rank:n,priority:e.priority,endpoint:e}]}).toSorted((e,t)=>e.rank-t.rank||e.priority-t.priority)[0];return n===void 0?null:ISe(n.endpoint.baseUrl)}function Az(e,t,n){let r=kz(t,n);if(r!==null)return{flagged:r,resolved:r,source:`flagged`};let i=VSe(e,t);return{flagged:null,resolved:i,source:i===null?`none`:`auto`}}function jz(e,t){return Az(e,`internal`,t.internal)}function Mz(e,t){return Az(e,`publicEndpoint`,t.publicEndpoint)}function Nz(e){let t=kz(`notificationTaps`,e.notificationTaps);return t!==null&&!_z(t)?{flagged:t,resolved:t,source:`flagged`}:{flagged:null,resolved:hz,source:`auto`}}function Pz(e){return Tz(e)?!1:e.kind===`lan-ipv4`?!0:e.kind===`public`&&e.interfaceKind===`public`}function Fz(e,t){let n=e.filter(Pz);if(t.appConnections.length===0)return n;let r=new Set(t.appConnections),i=e.filter(e=>r.has(e.baseUrl));return i.length>0?i:n}function Iz(e,t){let n=new Set(t.appConnections),r=Fz(e,t),i=r.some(e=>n.has(e.baseUrl));return{flagged:t.appConnections,resolved:r.map(e=>e.baseUrl),source:r.length===0?`none`:i?`flagged`:`auto`}}function HSe(e,t,n){return{appConnections:Iz(e,n),notificationTaps:Nz(n),internal:jz(t,n),publicEndpoint:Mz(t,n)}}function USe(e){return e===null?null:xz(e)}var WSe=`camstack`,GSe=`_camstack._tcp.local`,KSe={nodeId:`nodeId`,version:`version`,role:`role`,url:`url`,hubId:`hubId`},Lz=/^hub-[0-9a-f]{16}$/;function qSe(e){return typeof e==`string`&&Lz.test(e)}var JSe=`camstack-agent`,YSe=`_camstack-agent._tcp.local`,XSe={nodeId:`nodeId`,version:`version`,name:`name`,state:`state`,keyFingerprint:`fp`},ZSe=S([`lan`,`wifi`,`docker`,`vpn`,`loopback`,`other`]),Rz=x({name:u(),family:S([`IPv4`,`IPv6`]),address:u(),cidr:u(),netmask:u(),internal:y(),mac:u(),kind:ZSe,preferred:y(),plausible:y(),plausibleReason:u()}),QSe=x({interfaces:C(Rz).readonly(),probedAt:r()}),$Se=Rz.nullable(),zz=x({label:u(),baseUrl:u(),kind:S([`lan-ipv4`,`lan-ipv6`,`public`,`loopback`,`app-link`,`custom`]),interfaceKind:S([`lan`,`wifi`,`docker`,`vpn`,`other`,`loopback`,`public`]),plausible:y(),plausibleReason:u(),priority:r(),stable:y().optional()}),eCe=S([`server-config`,`server-env`,`caller-hint`,`default`]),tCe=x({port:r().int().min(1).max(65535),source:eCe}),nCe=x({endpoints:C(zz).readonly(),localPort:tCe}),Bz=x({baseUrl:u().nullable(),resolved:u().nullable(),appLinkHub:u().nullable()}),Vz=x({baseUrls:C(u()).readonly(),resolved:C(u()).readonly()}),Hz=x({override:u().nullable(),resolved:u().nullable(),source:S([`override`,`auto`,`none`])}),rCe=x({cluster:Hz,browser:Hz}),Uz=S(bz),Wz=S([`flagged`,`auto`,`none`]),Gz=x({flagged:u().nullable(),resolved:u().nullable(),source:Wz}),iCe=x({flagged:C(u()).readonly(),resolved:C(u()).readonly(),source:Wz}),Kz=x({rows:C(zz.extend({detected:y(),custom:y(),flags:C(Uz).readonly(),inUse:C(Uz).readonly(),eligible:C(Uz).readonly()})).readonly(),roles:x({appConnections:iCe,notificationTaps:Gz,internal:Gz,publicEndpoint:Gz}),appLinkHub:u().nullable(),listenerOrigins:C(u()).readonly().optional()}),qz=x({addresses:C(u()).readonly()}),Jz=x({mode:S([`generated`,`uploaded`,`disabled`]),leafFingerprintSha256:u().nullable(),caFingerprintSha256:u().nullable(),validTo:u().nullable(),sans:C(u()),caCertPem:u().nullable(),reissueError:u().nullable(),restartRequired:y(),caMissing:y(),localCaConstrained:y().nullable(),caReplacedAt:u().nullable(),storedUpload:x({leafFingerprintSha256:u(),validTo:u(),hasCa:y()}).nullable()}),aCe=x({providerId:u().min(1),modes:C(lj)}),oCe=x({providerId:u().optional(),mode:u().optional(),message:u()}),sCe=x({hostsProbed:r().int(),hits:r().int(),timeouts:r().int(),byMode:h(u(),x({probed:r().int(),hits:r().int(),timeouts:r().int()}))}),cCe=x({hits:C(x({providerId:u(),hit:uj})),subnetsScanned:C(u()),errors:C(oCe),stats:sCe}),Yz={name:`local-network`,scope:`system`,mode:`singleton`,methods:{list:D(v(),QSe),getPreferred:D(v(),$Se),getConnectionEndpoints:D(x({port:r().int().min(1).max(65535).optional(),includeLoopback:y().optional(),ipv4Only:y().optional(),scheme:S([`http`,`https`]).optional(),includeAppLink:y().optional()}),nCe),getNotificationEndpoint:D(v(),Bz),setNotificationEndpoint:D(x({baseUrl:u().nullable()}),Bz,{kind:`mutation`}),getViewerEndpoints:D(v(),Vz),setViewerEndpoints:D(x({baseUrls:C(u()).readonly()}),Vz,{kind:`mutation`}),getAddresses:D(x({scheme:S([`http`,`https`]).optional()}).optional(),Kz),addCustomAddress:D(x({baseUrl:u(),label:u().max(80)}),Kz,{kind:`mutation`,auth:`admin`}),removeCustomAddress:D(x({baseUrl:u()}),Kz,{kind:`mutation`,auth:`admin`}),setAddressRole:D(x({role:Uz,baseUrl:u().nullable(),enabled:y(),acceptInsecureHttp:y().optional()}),Kz,{kind:`mutation`,auth:`admin`}),getHubAddresses:D(v(),rCe),getAllowedAddresses:D(v(),qz),setAllowedAddresses:D(qz,x({success:m(!0)}),{kind:`mutation`}),resetAllowlistToBestMatch:D(v(),qz,{kind:`mutation`}),getTlsStatus:D(v(),Jz),regenerateCertificate:D(x({reason:u().optional()}),Jz,{kind:`mutation`,auth:`admin`}),uploadCertificate:D(x({certPem:u().min(1),keyPem:u().min(1),caPem:u().optional()}),Jz,{kind:`mutation`,auth:`admin`}),downloadCa:D(v(),x({pem:u()})),useStoredUploadedCertificate:D(v(),Jz,{kind:`mutation`,auth:`admin`}),scanNetwork:D(x({requests:C(aCe),subnets:C(u()).optional()}),cCe,{kind:`mutation`,auth:`admin`,timeoutMs:9e4}),getScanSubnets:D(v(),x({subnets:C(u())}),{auth:`admin`}),setScanSubnets:D(x({subnets:C(u())}),x({subnets:C(u())}),{kind:`mutation`,auth:`admin`}),revertToGeneratedCertificate:D(v(),Jz,{kind:`mutation`,auth:`admin`})},mount:{kind:`hub-only`},vocabulary:{notOperatorFacing:k.NETWORK}},Xz=S([`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]),Zz=x({state:Xz,codeRequired:y().nullable().optional(),lastChangedAt:r()}),lCe={version:1,overridable:[{path:`state`,by:`door-contact`}],targets:[{id:`door-contact`,cardinality:`scalar`,vocabulary:{cap:`lock-control`,stateField:`state`},deviceTypes:[M.Lock],apply:`replace`,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},sources:[{kind:`binary`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}]},Qz={name:`lock-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Lock],methods:{lock:D(x({deviceId:r().int().nonnegative(),code:u().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.lock`,label:L(`Lock`,`Chiudi a chiave`),phrase:L(`Lock {device}`,`Chiudi a chiave {device}`),icon:`lock`,effect:{field:`state`,value:`locked`},hold:{effects:[{field:`state`,value:`locking`,when:{field:`state`,notIn:[`locked`]}}]},openArgs:[{key:`code`,label:L(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),unlock:D(x({deviceId:r().int().nonnegative(),code:u().min(1).optional(),confirm:y().optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.unlock`,label:L(`Unlock`,`Apri la serratura`),phrase:L(`Unlock {device}`,`Sblocca {device}`),icon:`lock-open`,effect:{field:`state`,value:`unlocked`},hold:{effects:[{field:`state`,value:`unlocking`,when:{field:`state`,notIn:[`unlocked`]}}]},openArgs:[{key:`code`,label:L(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),open:O(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.open`,label:L(`Open latch`,`Apri lo scrocco`),phrase:L(`Release the latch of {device}`,`Fai scattare lo scrocco di {device}`),icon:`door-open`}]})},status:{schema:Zz,kind:`push`},runtimeState:Zz,customize:lCe,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Lock`,`Serratura`),order:1060,state:[{kind:`enum`,field:`state`,label:L(`Lock state`,`Stato della serratura`),values:[{value:`locked`,label:L(`Locked`,`Chiusa a chiave`),phrase:L(`When {device} locks`,`Quando {device} si chiude a chiave`)},{value:`unlocked`,label:L(`Unlocked`,`Sbloccata`),phrase:L(`When {device} unlocks`,`Quando {device} si sblocca`)},{value:`locking`,label:L(`Locking`,`In chiusura`),phrase:L(`When {device} starts locking`,`Quando {device} inizia a chiudersi`)},{value:`unlocking`,label:L(`Unlocking`,`In apertura`),phrase:L(`When {device} starts unlocking`,`Quando {device} inizia a sbloccarsi`)},{value:`jammed`,label:L(`Jammed`,`Inceppata`),phrase:L(`When {device} jams`,`Quando {device} si inceppa`)},{value:`door-open`,label:L(`Door open`,`Porta aperta`),phrase:L(`When the door of {device} opens`,`Quando la porta di {device} si apre`)}],icon:`lock`}]}},$z=x({armed:r().int().min(0),unknown:C(u()).readonly()}),eB={name:`log-channels`,scope:`system`,mode:`collection`,internal:!0,methods:{list:D(v(),C(Bu).readonly()),apply:D(x({windows:C(Vu).readonly()}),$z,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.INTERNAL}},tB=S([`debug`,`info`,`warn`,`error`]),nB=x({timestamp:_(),level:tB,scope:C(u()),message:u(),meta:h(u(),w()).optional(),tags:h(u(),u()).optional()}),rB=x({instanceId:u().min(1).max(200).optional(),requestId:u().min(1).max(64).optional(),deviceId:r().int().optional(),fromAddonId:u().min(1).max(200).optional(),fromNodeId:u().min(1).max(200).optional(),tags:h(u(),g([u(),r()])).optional(),level:tB.optional(),text:u().min(1).max(200).optional(),since:r().optional(),until:r().optional(),before:u().min(1).max(1024).optional(),after:u().min(1).max(1024).optional(),limit:r().int().min(1).max(1e3).optional(),budgetMs:r().int().min(50).max(1e4).optional()}),iB=x({id:u().optional(),timestamp:r(),level:tB,scope:u().optional(),message:u(),tags:h(u(),g([u(),r()])).optional(),meta:h(u(),w()).optional()}),aB=x({entries:C(iB),nextBefore:u().nullable(),nextAfter:u().nullable(),scannedBytes:r().int().nonnegative(),done:y(),cancelled:y().optional()}),uCe=x({instanceId:u().min(1).max(200).optional()}),oB=x({readable:y(),reason:u().nullable(),filters:x({deviceId:y(),addonId:y(),nodeId:y(),tags:y(),level:y(),text:y(),timeRange:y()}),retentionDays:r().nullable()}),sB={name:`log-destination`,scope:`system`,mode:`collection`,internal:!0,methods:{write:D(nB,v(),{kind:`mutation`}),describeRead:O(uCe,oB,{auth:`admin`}),read:O(rB,aB,{auth:`admin`}),cancelRead:O(x({requestId:u().min(1).max(64)}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.INTERNAL}},cB=S([`primary`,`second-factor`]),lB=x({kind:m(`redirect`),id:u(),label:u(),icon:u().optional(),startUrl:u(),stage:cB,linkable:y().optional(),app:Tp.nullable().optional()}),uB=x({kind:m(`widget`),id:u(),addonId:u(),bundle:u(),remote:ly,stage:cB,app:Tp.nullable().optional()}),dB=x({kind:m(`passkey`),id:u(),label:u(),stage:cB,rpId:u(),origin:u().nullable(),app:Tp.nullable().optional()}),fB=a(`kind`,[lB,uB,dB]),pB={name:`login-method`,scope:`system`,mode:`collection`,internal:!0,methods:{getLoginMethods:D(v(),C(fB).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.IDENTITY}},mB=x({sleeping:y().meta({label:`Sleeping`}),lastContactAt:r().optional(),lastUpdated:r().meta(A(`none`))}),hB={name:`low-power-sleep`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],methods:{wakeUp:D(x({deviceId:r(),timeoutMs:r().int().min(500).max(3e4).default(8e3)}),x({awoke:y(),durationMs:r()}),{kind:`mutation`,notOperatorFacing:`a stream consumer wakes a sleeping camera to watch it; an automation that wants footage asks for the footage`})},status:{schema:mB,kind:`push`,empty:{sleeping:!1,lastUpdated:0}},runtimeState:mB,durability:`restored`,history:`none`,volatileStateFields:[`lastUpdated`],vocabulary:{noun:L(`Low-power sleep`,`Sospensione a basso consumo`),order:5245}},dCe=x({id:u(),label:u(),scope:S([`mesh`,`public`]),url:u(),hostname:u(),port:r(),protocol:S([`http`,`https`])}),gB=x({id:u(),hostname:u(),magicDns:u(),addresses:C(u()).readonly(),os:u().optional(),online:y(),lastSeenMs:r(),isSelf:y(),connection:S([`direct`,`relay`,`idle`]),relay:u().nullable(),lastHandshakeMs:r(),rxBytes:r(),txBytes:r(),tags:C(u()).readonly(),exitNodeOption:y(),advertisedRoutes:C(u()).readonly(),userLogin:u().nullable(),keyExpiry:r().nullable()}),_B=x({joined:y(),meshIp:u(),magicDnsHostname:u(),peerCount:r(),endpoints:C(dCe).readonly(),error:u().optional(),tenantName:u(),magicDnsSuffix:u(),userLogin:u().nullable(),controlPlaneUrl:u(),keyExpiry:r().nullable(),daemonSocket:u().optional(),daemonCliPath:u().optional()}),vB={name:`mesh-network`,scope:`system`,mode:`collection`,providerKind:`mesh`,methods:{getStatus:D(v(),_B),join:D(x({authKey:u().min(8),hostname:u().optional()}),x({joined:m(!0)}),{kind:`mutation`}),startLogin:D(x({hostname:u().optional()}),x({loginUrl:u()}),{kind:`mutation`}),leave:D(v(),x({left:m(!0)}),{kind:`mutation`}),logout:D(v(),x({loggedOut:m(!0)}),{kind:`mutation`}),listPeers:D(v(),x({peers:C(gB).readonly()}))},vocabulary:{notOperatorFacing:k.NETWORK}},yB=x({value:r().nullable().meta(A(`device`,{label:`Total`})),lastFetchedAt:r()}),bB={name:`meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:yB,kind:`push`},runtimeState:yB,durability:`restored`,history:{fields:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Meter`,`Contatore`),order:5140,state:[{kind:`numeric`,field:`value`,quantity:L(`the total`,`il totale`),label:L(`Total`,`Totale`),icon:`gauge`}]}},fCe=x({total:r(),user:r(),system:r(),irq:r(),nice:r(),loadAvg:d([r(),r(),r()]),cores:r()}),pCe=x({percent:r().nullable(),totalBytes:r(),usedBytes:r().nullable(),availableBytes:r().nullable(),swapUsedBytes:r(),swapTotalBytes:r()}),mCe=x({readBytes:r(),writeBytes:r(),readOps:r(),writeOps:r(),timestampMs:r()}),hCe=x({rxBytes:r(),txBytes:r(),rxPackets:r(),txPackets:r(),rxErrors:r(),txErrors:r(),timestampMs:r()}),xB=x({utilization:r(),model:u(),memoryUsedBytes:r(),memoryTotalBytes:r(),temperature:r().nullable()}),gCe=x({openFds:r(),threadCount:r(),activeHandles:r(),activeRequests:r()}),SB=x({avg10:r(),avg60:r(),avg300:r()}),CB=x({some:SB,full:SB.nullable()}),wB=x({cpu:fCe,memory:pCe,gpu:xB.nullable(),network:hCe,disk:mCe,pressure:x({cpu:CB.nullable(),memory:CB.nullable(),io:CB.nullable()}),process:gCe,cpuTemperature:r().nullable(),timestampMs:r()}),_Ce=x({path:u(),totalBytes:r(),usedBytes:r(),availableBytes:r(),percent:r()}),TB=x({pid:r(),cpu:r(),memory:r(),privateBytes:r().optional(),sharedBytes:r().optional()}),vCe=x({addonId:u(),nodeId:u(),role:S([`hub`,`worker`]),pid:r(),state:S([`starting`,`running`,`stopping`,`stopped`,`crashed`]),uptimeSec:r()}),yCe=x({pid:r(),ppid:r(),pgid:r(),classification:S([`root`,`managed`,`system`]),addonId:u().nullable(),nodeId:u().nullable(),command:u(),cpuPercent:r(),memoryRssBytes:r(),cpuMainPercent:r().nullable(),cpuGcPercent:r().nullable(),threadCount:r().nullable(),uptimeSec:r()}),bCe=x({source:S([`cgroup-v2`,`cgroup-v1`]),currentBytes:r(),limitBytes:r().nullable(),anonBytes:r().nullable(),fileBytes:r().nullable(),shmemBytes:r().nullable(),slabBytes:r().nullable(),gpuShmemBytes:r().nullable()}).extend({atMs:r()}),xCe=x({atMs:r(),samples:r().int(),cpuMainPercent:r().nullable(),cpuMainPercentMin:r().nullable(),cpuGcPercent:r().nullable(),cpuGcPercentMin:r().nullable(),cpuLifetimePercent:r(),cpuLifetimePercentMin:r(),memoryRssBytes:r(),memoryRssBytesMin:r(),processCount:r().int(),processCountMin:r().int()}),SCe=x({key:u(),kind:S([`addon`,`root`,`unattributed`]),points:C(xCe).readonly()}),CCe=x({nodeId:u(),series:C(SCe).readonly(),containerMemory:C(bCe).readonly(),bucketMs:r(),retainedSamples:r(),oldestAtMs:r().nullable(),cadenceMs:r(),durable:y()}),wCe=x({forNodeId:u(),sinceMs:r().optional(),maxPoints:r().int().positive().optional()}),EB=x({cpuPercent:r(),memoryPercent:r().nullable(),memoryUsedMB:r().nullable(),memoryTotalMB:r(),diskPercent:r().optional(),temperature:r().optional(),gpuPercent:r().optional(),gpuMemoryPercent:r().optional()}),DB={name:`metrics-provider`,scope:`system`,mode:`singleton`,methods:{collectSnapshot:D(v(),wB),getCached:D(v(),wB.nullable()),getCurrent:D(v(),EB),getDiskSpace:D(x({dirPath:u()}),_Ce),getGpuInfo:D(v(),xB.nullable()),getCpuTemperature:D(v(),r().nullable()),getProcessStats:D(x({pids:C(r())}),C(TB)),listAddonInstances:D(v(),C(vCe).readonly()),getAddonStats:D(x({addonId:u()}),TB.nullable()),listNodeProcesses:D(v(),C(yCe).readonly()),getLoadSeries:D(wCe,CCe)},vocabulary:{notOperatorFacing:k.CLUSTER}},OB=u().min(1).max(256),kB=h(u(),w()),AB=x({id:OB,deviceId:r().int().optional(),at:r().int().optional(),expiresAt:r().int().optional(),data:kB}),jB=x({id:u(),deviceId:r().int().nullable(),at:r().nullable(),expiresAt:r().nullable(),rev:r().int(),updatedAt:r(),data:kB}),MB=h(Xi,g([u(),r(),y(),x({in:C(g([u(),r(),y()])).min(1).max(Qn)}),x({gt:g([u(),r()]).optional(),gte:g([u(),r()]).optional(),lt:g([u(),r()]).optional(),lte:g([u(),r()]).optional()}).refine(e=>Object.keys(e).length>0,{message:`name at least one bound`})])),NB={kind:na},PB={deviceId:r().int().optional(),atFrom:r().optional(),atTo:r().optional()},FB=x({...NB,...PB,where:MB.optional(),order:S([`at`,`id`]).optional(),desc:y().optional(),limit:r().int().min(1).max(kee).default(100),cursor:u().min(1).optional()}),IB=x({records:C(jB),nextCursor:u().nullable()}),TCe=S([`created`,`unchanged`,`updated`]),LB=x({kindId:r().int(),state:TCe,createdIndexes:C(u())}),RB=C(u()),zB=a(`op`,[x({op:m(`put`),kind:na,record:AB,ifRev:r().int().min(0).optional()}),x({op:m(`patch`),kind:na,id:OB,data:kB,at:r().int().nullable().optional(),expiresAt:r().int().nullable().optional(),ifRev:r().int().min(1).optional()}),x({op:m(`delete`),kind:na,id:OB})]),BB=h(u(),h(u(),u())),VB={name:`records`,scope:`system`,mode:`singleton`,internal:!0,methods:{declareKinds:D(x({kinds:h(na,ta)}),x({kinds:h(u(),LB)}),{kind:`mutation`,auth:`admin`}),get:D(x({...NB,id:OB}),jB.nullable(),{auth:`admin`}),getMany:D(x({...NB,ids:C(OB).min(1).max(Qn)}),C(jB),{auth:`admin`}),secretRefs:D(x({...NB,ids:C(OB).min(1).max(Qn)}),BB,{auth:`admin`}),put:D(x({...NB,record:AB,ifRev:r().int().min(0).optional()}),x({rev:r().int(),releasedRefs:RB}),{kind:`mutation`,auth:`admin`}),putMany:D(x({...NB,records:C(AB).min(1).max(Qn)}),x({count:r().int(),releasedRefs:RB}),{kind:`mutation`,auth:`admin`}),patch:D(x({...NB,id:OB,data:kB,at:r().int().nullable().optional(),expiresAt:r().int().nullable().optional(),ifRev:r().int().min(1).optional()}),x({rev:r().int(),releasedRefs:RB}),{kind:`mutation`,auth:`admin`}),delete:D(x({...NB,id:OB}),x({deleted:y(),secretRefs:RB}),{kind:`mutation`,auth:`admin`}),deleteMany:D(x({...NB,ids:C(OB).min(1).max(Qn)}),x({deleted:r().int(),secretRefs:RB}),{kind:`mutation`,auth:`admin`}),query:D(FB,IB,{auth:`admin`}),count:D(x({...NB,...PB,where:MB.optional()}),x({count:r().int()}),{auth:`admin`}),histogram:D(x({...NB,deviceId:r().int().optional(),from:r(),to:r(),bucketMs:r().int().positive()}),x({buckets:C(x({bucketStart:r(),count:r().int()}))}),{auth:`admin`}),aggregate:D(x({...NB,op:S([`sum`,`min`,`max`,`count`]),field:Xi.optional(),groupBy:Xi.optional(),where:MB.optional()}),x({rows:C(x({group:g([u(),r(),oe()]),value:r().nullable()}))}),{auth:`admin`}),deleteWhere:D(x({...NB,deviceId:r().int().optional(),atBefore:r().optional(),where:MB.optional()}),x({deleted:r().int(),secretRefs:RB}),{kind:`mutation`,auth:`admin`}),transact:D(x({ops:C(zB).min(1).max(Qn)}),x({results:C(x({rev:r().int().nullable(),deleted:y()})),releasedRefs:RB,secretRefs:RB}),{kind:`mutation`,auth:`admin`}),deleteDevice:D(x({deviceId:r().int(),kinds:C(na).optional()}),x({deleted:h(u(),r().int()),secretRefs:RB}),{kind:`mutation`,auth:`admin`}),allocateId:D(x(NB),x({id:r().int()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.INTERNAL}},HB=h(u(),w()),UB=x({integrationId:u().min(1)}),WB=x({id:u().min(1)}),GB=x({id:u(),deviceId:r().int().nullable(),at:r().nullable(),expiresAt:r().nullable(),rev:r().int(),updatedAt:r(),data:HB}),KB={id:u().min(1),deviceId:r().int().optional(),at:r().int().optional(),expiresAt:r().int().optional(),data:HB},qB=x({id:u(),addonId:u(),name:u(),info:HB,enabled:y().optional(),originStableId:u().optional()}),ECe=x({id:r().int(),integrationId:u().nullable().optional(),parentDeviceId:r().int().nullable().optional(),type:u().optional(),name:u().optional(),stableId:u().optional()}),JB=x({version:r().int(),methods:C(u())}),YB=x({message:u(),meta:HB.optional(),tags:x({deviceId:r().int().optional()}).optional()}),DCe={"ledger.declare":{input:x({owner:u().min(1),metas:C(Xo)}),output:x({bootId:u(),snapshot:S([`none`,`written`,`refused`]),steps:C(ds),migrationApi:JB.optional()}),behaviours:[`ledger.declare.answers-steps-in-engine-order`,`ledger.declare.answers-the-migration-api`]},"ledger.start":{input:x({id:u().min(1)}),output:x({proceed:y(),state:g([m(`pending`),ss]),reason:u().nullable()}),behaviours:[`ledger.start.proceeds-when-predecessors-applied`]},"ledger.finish":{input:x({id:u().min(1),result:os}),output:x({status:ss,error:u().nullable(),rowsChanged:r().int().nonnegative()}),behaviours:[`ledger.finish.records-the-outcome`]},"legacyRows.read":{input:UB,output:HB,behaviours:[`legacyRows.read.returns-stored-rows`,`legacyRows.read.absent-store-is-empty`,`legacyRows.caller.sibling-package`]},"legacyRows.clear":{input:UB,output:x({rows:r().int().nonnegative(),secrets:r().int().nonnegative()}),behaviours:[`legacyRows.clear.deletes-the-rows`,`legacyRows.clear.absent-store-is-noop`]},"legacyRows.patch":{input:UB.extend({patch:HB}),output:x({written:y()}),behaviours:[`legacyRows.patch.upserts-keys-and-keeps-the-rest`,`legacyRows.patch.absent-store-writes-nothing`]},"legacyRows.deleteKeys":{input:UB.extend({keys:C(u().min(1))}),output:x({present:y(),removed:HB}),behaviours:[`legacyRows.deleteKeys.removes-the-named-keys`,`legacyRows.deleteKeys.absent-store-reports-not-present`]},"records.get":{input:WB,output:GB.nullable(),behaviours:[`records.get.returns-the-row-or-null`]},"records.getResolved":{input:WB,output:GB.nullable(),behaviours:[`records.getResolved.resolves-secret-fields`]},"records.put":{input:x({...KB,ifRev:r().int().optional()}),output:x({rev:r().int()}),behaviours:[`records.put.creates-and-replaces`,`records.put.if-rev-conflict-throws`]},"records.putMany":{input:x({records:C(x(KB))}),output:x({count:r().int().nonnegative()}),behaviours:[`records.putMany.writes-every-row`]},"records.patch":{input:WB.extend({partial:HB,ifRev:r().int().optional()}),output:x({rev:r().int()}),behaviours:[`records.patch.merges-and-null-removes`]},"records.delete":{input:WB,output:x({deleted:y()}),behaviours:[`records.delete.reports-whether-a-row-went`]},"records.query":{input:x({deviceId:r().int().optional(),atFrom:r().optional(),atTo:r().optional(),where:MB.optional(),limit:r().int().min(1).optional(),cursor:u().min(1).optional(),resolveSecrets:y().optional()}),output:x({records:C(GB),nextCursor:u().nullable()}),behaviours:[`records.query.pages-with-a-cursor`,`records.query.filters-on-a-declared-index`]},"records.deleteWhere":{input:x({deviceId:r().int().optional(),atBefore:r().optional(),where:MB.optional()}),output:x({count:r().int().nonnegative()}),behaviours:[`records.deleteWhere.deletes-the-matching-rows`]},"settings.read":{input:x({}),output:x({store:HB}),behaviours:[`settings.read.returns-the-addon-store`]},"settings.write":{input:x({patch:HB}),output:x({}),behaviours:[`settings.write.merges-and-keeps-other-keys`]},"settings.deleteKeys":{input:x({keys:C(u().min(1))}),output:x({removed:C(u())}),behaviours:[`settings.deleteKeys.removes-only-the-named-keys`]},"deviceSettings.listIds":{input:x({}),output:x({deviceIds:C(r().int())}),behaviours:[`deviceSettings.listIds.names-only-the-addons-own-devices`]},"deviceSettings.read":{input:x({deviceIds:C(r().int())}),output:x({blobs:h(u(),HB)}),behaviours:[`deviceSettings.read.returns-only-the-addons-own-blobs`]},"secrets.resolve":{input:x({refs:C(u())}),output:x({values:h(u(),u().nullable())}),behaviours:[`secrets.resolve.answers-null-for-a-missing-ref`]},"secrets.put":{input:x({ref:u().min(1),value:u()}),output:x({}),behaviours:[`secrets.put.stores-under-the-owner`]},"secrets.delete":{input:x({refs:C(u())}),output:x({deleted:r().int().nonnegative()}),behaviours:[`secrets.delete.ignores-unknown-refs`]},"integrations.list":{input:x({}),output:x({integrations:C(qB)}),behaviours:[`integrations.list.lists-every-integration`]},"integrations.get":{input:x({id:u().min(1)}),output:qB.nullable(),behaviours:[`integrations.get.null-for-an-unknown-id`]},"devices.list":{input:x({addonId:u().min(1),integrationId:u().min(1).optional()}),output:x({devices:C(ECe)}),behaviours:[`devices.list.scoped-to-the-addon`,`devices.list.filters-by-integration`]},"devices.get":{input:x({deviceId:r().int()}),output:x({id:r().int(),integrationId:u().nullable(),hasConfig:y()}).nullable(),behaviours:[`devices.get.null-for-an-unknown-id`,`devices.get.reports-link-and-config`]},"devices.aliases":{input:x({deviceIds:C(r().int())}),output:x({aliases:h(u(),u())}),behaviours:[`devices.aliases.answers-for-the-named-ids-only`]},"devices.setIntegrationId":{input:x({deviceId:r().int(),integrationId:u().min(1)}),output:x({}),behaviours:[`devices.setIntegrationId.links-the-device`]},"node.localNodeId":{input:x({}),output:x({nodeId:u()}),behaviours:[`node.localNodeId.names-this-node`]},"log.info":{input:YB,output:x({}),behaviours:[`log.info.writes-a-line`]},"log.warn":{input:YB,output:x({}),behaviours:[`log.warn.writes-a-line`]}},XB={name:`migrations`,scope:`system`,mode:`singleton`,internal:!0,methods:{listLedger:D(x({}),x({entries:C(cs)}),{auth:`admin`}),listPending:D(x({owner:u().optional()}),x({pending:C(ls)}),{auth:`admin`}),dryRun:D(x({id:u().min(1)}),us,{auth:`admin`}),markFailed:D(x({id:u().min(1),error:u().min(1)}),cs,{kind:`mutation`,auth:`admin`}),retry:D(x({id:u().min(1)}),x({entries:C(cs)}),{kind:`mutation`,auth:`admin`}),restorePreMigration:D(x({database:Uo,snapshotId:u().min(1)}),x({scheduled:y(),held:C(u()),restartRequired:y()}),{kind:`mutation`,auth:`admin`}),declareOwner:D(x({owner:u().min(1),metas:C(Xo),retired:C(u().min(1)).optional()}),x({bootId:u(),snapshot:S([`none`,`written`,`refused`]),steps:C(ds),migrationApi:JB.optional()}),{kind:`mutation`,auth:`admin`}),startMigration:D(x({id:u().min(1)}),x({proceed:y(),state:g([m(`pending`),ss]),reason:u().nullable()}),{kind:`mutation`,auth:`admin`}),finishMigration:D(x({id:u().min(1),result:os}),x({status:ss,error:u().nullable(),rowsChanged:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),readLegacyIntegrationRows:D(x({integrationId:u().min(1)}),h(u(),w()),{auth:`admin`}),clearLegacyIntegrationRows:D(x({integrationId:u().min(1)}),x({rows:r().int().nonnegative(),secrets:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),patchLegacyIntegrationRows:D(x({integrationId:u().min(1),patch:h(u(),w())}),x({written:y()}),{kind:`mutation`,auth:`admin`}),deleteLegacyIntegrationRowKeys:D(x({integrationId:u().min(1),keys:C(u().min(1))}),x({present:y(),removed:h(u(),w())}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.INTERNAL}},ZB=x({sourceUrl:u(),metadata:Df,targets:C(Ef).min(1).readonly(),calibrationRef:u().optional(),sessionId:u().optional()}),QB={name:`model-convert`,scope:`system`,mode:`singleton`,internal:!0,methods:{convert:D(ZB,kf,{kind:`mutation`,auth:`admin`,timeoutMs:6e5})},vocabulary:{notOperatorFacing:k.ML}},$B=x({targetNodeId:u(),modelId:u(),format:S(ff),entry:Tf}),eV=x({ok:y(),sha256:u(),bytes:r(),path:u()}),tV={name:`model-distributor`,scope:`system`,mode:`singleton`,internal:!0,methods:{distributeModel:D($B,eV,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.ML}},nV=a(`kind`,[x({kind:m(`camera`)}),x({kind:m(`sensor`),deviceId:r().int().positive()})]),rV=Object.freeze({kind:`camera`});function OCe(e){if(e===void 0)return{triggeredBy:rV,malformed:!1};let t=nV.safeParse(e);return t.success?{triggeredBy:t.data,malformed:!1}:{triggeredBy:rV,malformed:!0}}var kCe=`cameraSensors`,iV=x({addonId:u().min(1),stableId:u().min(1)});function aV(e){return`${e.addonId}/${e.stableId}`}var oV=S([`in-addition`,`confirm`,`replace`]),sV=`in-addition`,cV=iV.extend({mode:oV.default(sV)}),lV=x({sensors:C(cV).min(1).max(8)}).superRefine((e,t)=>{let n=new Set;e.sensors.forEach((e,r)=>{let i=aV(e);n.has(i)&&t.addIssue({code:`custom`,path:[`sensors`,r],message:`duplicate camera sensor ${i}`}),n.add(i)})}),uV={addonId:u(),stableId:u(),mode:oV.default(sV)},dV=a(`state`,[x({...uV,state:m(`ready`),deviceId:r(),name:u(),caps:C(u()).readonly()}),x({...uV,state:m(`offline`),deviceId:r(),name:u(),reason:S([`offline`,`disabled`])}),x({...uV,state:m(`missing`),reason:u()}),x({...uV,state:m(`unsupported`),deviceId:r(),name:u(),reason:u()}),x({...uV,state:m(`unreadable`),reason:u()})]),fV=S([`onboard-not-listed`,`no-active-detection`]),pV=S([`always`,`when-confirmed`,`never`]),mV=S([`provider-not-split`]),hV=x({detected:y(),atMs:r()}),gV=a(`state`,[x({state:m(`not-configured`),cameraLevel:hV.optional()}),x({state:m(`unreadable`),reason:u(),cameraLevel:hV.optional()}),x({state:m(`configured`),cameraLevel:hV.optional(),sensors:C(dV).readonly(),cameraMotion:pV.optional(),notForwarded:fV.optional(),notEnforced:mV.optional()})]),_V=Object.freeze({state:`unreadable`,reason:`camera sensor mappings not loaded`}),vV=x({bbox:Ay,pixelCount:r(),intensity:r()}),yV=x({detected:y(),regionCount:r(),regions:C(vV).readonly(),rawRegions:C(vV).readonly(),frameWidth:r(),frameHeight:r(),analysisMs:r()}),bV={name:`motion-detection`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Camera],exposesDeviceSettings:!0,methods:{analyze:D(x({deviceId:r(),frame:ky.optional(),frameHandle:Lc.optional()}),yV,{role:`admin`,kind:`mutation`,notOperatorFacing:`the pipeline feeds it frames — an internal stage, never called by a person`}),removeCamera:D(x({deviceId:r()}),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping when a camera leaves`}),reset:D(v(),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping`})},events:{onMotion:{data:x({deviceId:r(),detected:y(),regionCount:r()}),notOperatorFacing:"the analyzer’s raw verdict; the operator signal is the `motion` cap’s `detected` state"}},vocabulary:{noun:L(`Motion analysis`,`Analisi del movimento`),order:3160}},xV=x({package:y(),confidence:r().min(0).max(1),reason:u().min(1)}),SV=x({x:r(),y:r()}),CV=x({kind:m(`rect`),x:r(),y:r(),width:r(),height:r()}),wV=x({kind:m(`polygon`),points:C(SV)}),TV=x({kind:m(`grid`),gridWidth:r().meta(A(`none`)),gridHeight:r().meta(A(`none`)),cells:C(y())}),EV=x({kind:m(`line`),points:C(SV)}),ACe=a(`kind`,[CV,wV,TV,EV]),DV=S([`rect`,`polygon`,`grid`,`line`]),OV=x({min:r(),max:r()}),kV=x({width:r(),height:r()}),AV=[`owner-not-ready`,`store-read-failed`,`three-way-read-unavailable`,`invalid-stored`,`not-cluster-scoped`],jV=[{stepId:`face-embedding`,label:`Face recognition model`,defaultModelId:`auraface-r100`,indexName:`the enrolled face gallery`,options:[{id:`auraface-r100`,label:`AuraFace R100`}]},{stepId:`clip-embedding`,label:`Semantic search model`,defaultModelId:`siglip2-b16-224`,indexName:`the object semantic-search index`,options:[{id:`siglip2-b16-224`,label:`SigLIP2 B/16 (Apache-2.0)`}]}],jCe=`cluster-step-models`;function MV(e){return`clusterModel:${e}`}function MCe(e){return jV.some(t=>t.stepId===e)}var NV=Object.freeze(Object.fromEntries(jV.map(e=>[e.stepId,e.defaultModelId])));function PV(e){return e==null||e===``?{kind:`absent`}:typeof e==`string`?{kind:`chosen`,modelId:e}:{kind:`invalid`,value:e}}function FV(e){let t=[];for(let n of jV){let r=PV(e[MV(n.stepId)]);r.kind===`invalid`&&t.push({stepId:n.stepId,value:r.value})}return t}function IV(e){let t={};for(let n of jV){let r=PV(e[MV(n.stepId)]);t[n.stepId]=r.kind===`chosen`?r.modelId:n.defaultModelId}return t}function NCe(e){return typeof e==`object`&&!!e&&`key`in e}function LV(e){return e===null?NV:IV(zV(e,RV()))}function PCe(e){return e===null?[]:FV(zV(e,RV()))}function RV(){return new Set(jV.map(e=>MV(e.stepId)))}function zV(e,t){let n={};for(let r of e.sections)for(let e of r.fields)!NCe(e)||typeof e.key!=`string`||t.has(e.key)&&(n[e.key]=e.value);return n}function FCe(e,t){let n=jV.find(t=>t.stepId===e);if(n===void 0)return null;let r=t[e];return r!==void 0&&r!==``?r:n.defaultModelId}var BV=[{stepId:`face-embedding`,key:`minLandmarkFaceSize`,label:`Min face size to embed (detection-frame px)`,description:`Faces smaller than this in the small frame the detector sees are not embedded, so they can never be recognised. Below it the face cannot be aligned reliably and a bad embedding matches everyone. Same value on every node. 0 = no limit.`,type:`slider`,min:0,max:64,step:2,default:24}];function VV(e,t){return`clusterStepSetting:${e}:${t}`}function HV(e){return BV.filter(t=>t.stepId===e)}var ICe=r().finite();function UV(e){let t={};for(let n of BV){let r=ICe.safeParse(e[VV(n.stepId,n.key)]),i=r.success?r.data:n.default,a=t[n.stepId]??{};t[n.stepId]={...a,[n.key]:i}}return t}var WV=UV({});function GV(e){return e===null?WV:UV(zV(e,new Set(BV.map(e=>VV(e.stepId,e.key)))))}function LCe(e,t,n){let r=n[e];return r===void 0||Object.keys(r).length===0?t===void 0?void 0:{...t}:t===void 0?{...r}:{...t,...r}}var KV=S([`new`,`entered`,`left`,`moving`,`idle`]),qV=S([`motion`,`object`,`audio`]),JV=a(`kind`,[CV,wV]),YV=S([`motion`,`audio`,`person`,`vehicle`,`animal`,`door`,`pir`,`smoke`,`water`,`button`,`package`,`generic`]),XV=S([`motion`,`audio`,`detection`,`sensor`,`control`,`custom`,`package`]),RCe=S([`macro`,`sub`]),ZV=x({kind:u(),labelKey:u(),label:u(),color:u(),iconId:u(),icon:YV,category:XV,parentKind:u().nullable(),level:RCe,source:x({capName:u(),deviceId:r()})}),QV=x({deviceId:r(),kinds:C(ZV).readonly()}),$V=x({id:u(),deviceId:r(),sourceDeviceId:r(),kind:u(),value:h(u(),w()).nullable(),timestamp:r()}),eH=x({x:r(),y:r(),timestamp:r(),bbox:Ay,source:S([`frame`,`recovery`]).optional(),score:r().optional()}),zCe=x({timestamp:r(),position:eH,mediaId:r().int()}),tH=x({minX:r(),minY:r(),maxX:r(),maxY:r()}),nH=S([`full`,`slim`]),rH=x({label:u(),peakScore:r(),count:r(),firstAt:r(),lastAt:r()}),iH=S([`pipeline`,`onboard`,`sensor`,`audio`]),aH=S([`none`,`staging`,`trained`]),oH={markForTrain:y().optional(),debug:y().optional(),debugNote:u().max(500).optional(),favourited:y().optional()},sH={retrainStatus:aH.optional()},cH=x(oH),lH=x({trackId:u(),markForTrain:y(),debug:y(),debugNote:u(),favourited:y(),retrainStatus:aH}),BCe=g([m(1),m(2)]),uH=x({stepId:u(),modelId:u().optional(),decidedAt:r(),identityId:u().optional()}),dH={label:u().optional(),labelScore:r().optional(),labelMeta:uH.optional(),subLabel:u().optional(),subLabelScore:r().optional(),subLabelMeta:uH.optional()},fH=x({deviceId:r(),tracks:r().int(),files:r().int(),bytes:r().int()}),pH=x({generatedAt:r(),trackCount:r().int(),fileCount:r().int(),byteCount:r().int(),truncated:y(),devices:C(fH).readonly()}),mH=x({nodeId:u(),deviceKey:u().optional(),modelId:u().optional()}),hH=x({trackId:u(),deviceId:r(),className:u(),...dH,producingDeviceName:u().optional(),source:iH.optional(),firstSeen:r(),lastSeen:r(),positions:C(eH).readonly(),snapshots:C(zCe).readonly(),zonesVisited:C(u()).readonly(),zoneNames:C(u()).readonly().optional(),classes:C(u()).readonly().optional(),totalDistance:r(),state:KV,active:y(),importance:r().optional(),bestEventId:u().optional(),importanceReason:u().optional(),audioLabels:C(rH).readonly().optional(),envelope:tH.optional(),hasFace:y().optional(),hasEmbeddedFace:y().optional(),hasRider:y().optional(),previewMissReason:u().optional(),modelId:u().optional(),openedPlacement:mH.optional(),closedPlacement:mH.optional(),frameWidth:r().optional(),frameHeight:r().optional(),...oH,...sH}),gH={id:r().int(),deviceId:r(),timestamp:r()},_H=x({...gH,kind:m(`motion`),regionCount:r(),regions:C(x({bbox:Ay,pixelCount:r(),intensity:r()})).readonly().optional(),frameWidth:r().optional(),frameHeight:r().optional(),mediaUrl:u().optional(),triggeredBy:nV.optional(),durationMs:r().nullable().optional(),edges:C(r()).readonly().optional()}),vH=S([`pipeline`,`onboard`]),yH=S([`enter`,`exit`]),bH=x({direction:yH,zoneId:u(),zoneName:u().optional()}),VCe=x({zoneId:u(),zoneName:u().optional(),overlapPct:r()}),xH=x({...gH,kind:m(`object`),source:vH.optional(),frameId:u().optional(),idempotencyKey:u().optional(),trackId:u().optional(),className:u(),...dH,confidence:r().optional(),bbox:Ay.optional(),zones:C(u()).readonly().optional(),zoneOverlaps:C(VCe).readonly().optional(),spawnRefused:u().optional(),state:KV.optional(),zoneCrossing:bH.optional(),frameWidth:r().optional(),frameHeight:r().optional(),mediaId:r().int().optional(),keyFrameMediaId:r().int().optional(),mediaUrl:u().optional(),observedAt:r().optional(),packagePossible:y().optional(),packageLlmVerdict:xV.optional(),importance:r().optional()}),SH=x({...gH,kind:m(`audio`),rms:r(),dbfs:r(),classification:x({className:u(),originalClass:u().optional(),score:r()}).optional(),classifyOutcome:Fy.optional(),mediaUrl:u().optional()}),CH=S([`crop`,`thumbnail`,`snapshot`,`firstFrame`,`lastFrame`,`fullFrame`,`fullFrameBoxed`,`faceCrop`,`plateCrop`,`keyFrame`,`keyFrameSmall`,`thumbnailSmall`,`confirmationCrop`,`debugCrop`,`sceneFrame`,`lastSceneFrame`]),wH=x({mediaId:r().int(),kind:CH,sizeBytes:r(),timestamp:r()}),TH=wH.extend({url:u(),base64:u()}),EH=TH.omit({base64:!0}),DH=S([`person`,`vehicle`,`animal`,`package`,`face`,`plate`]),OH=S([`subject`,`model_error`]),kH=S([`operator`,`assist`,`pipeline`,`llm`]),AH=x({x:r(),y:r(),w:r(),h:r()}),jH=x({source:kH,ref:u().min(1),bbox:AH,macroClass:DH,label:u().optional(),score:r().optional(),modelId:u().optional()}),MH=x({ref:u().min(1),snapshot:jH}),NH=S(Bs),PH=x({ref:u(),savedId:u().optional(),status:NH,approximate:y(),origin:jH.optional(),macroClass:DH.optional(),label:u().optional(),iou:r().optional()}),FH=x({boxes:C(PH).readonly(),summary:x({counts:h(NH,r().int()),total:r().int(),changed:r().int(),approximate:y()})}),IH=x({id:u(),trackId:u().optional(),deviceId:r(),mediaKey:u(),bbox:AH,macroClass:DH,label:u().optional(),subLabel:u().optional(),kind:OH,source:kH,assistModelId:u().optional(),assistScore:r().optional(),origin:jH.nullable().optional(),exportedInBatch:u().optional(),createdAt:r()}),LH=IH.omit({id:!0,trackId:!0,deviceId:!0,mediaKey:!0,createdAt:!0,exportedInBatch:!0}),RH=S([`correct`,`wrong`,`wrong-label`]),zH=x({verdict:RH,suggestedClass:u().optional(),suggestedMacroClass:DH.optional(),suggestedLabel:u().optional(),trackId:u(),at:r().optional()}),BH=x({trackId:u(),className:u(),label:u().optional(),bbox:AH.optional(),verdict:RH,suggestedClass:u().optional(),at:r().optional()}),VH=x({trackId:u(),deviceId:r(),className:u(),label:u().optional(),firstSeen:r(),lastSeen:r(),frameCount:r().int(),annotationCount:r().int(),verdict:zH.optional()}),HH=x({mediaId:r().int(),kind:CH,timestamp:r(),sizeBytes:r().int(),copied:y()}),UH=x({bbox:AH,macroClass:DH,label:u().optional(),subLabel:u().optional(),score:r().optional(),modelId:u().optional(),trackId:u(),basis:S([`subject-box`,`position`,`verdict`]),deltaMs:r()}),WH=S([`track`,`recording`]),GH=x({frameId:u(),deviceId:r(),origin:WH,trackId:u().optional(),sourceMediaId:r().int().optional(),epochMs:r().optional(),sourceKind:CH,sizeBytes:r().int(),width:r().int(),height:r().int(),copiedAt:r(),capturedAt:r().optional(),complete:y(),pipelineBoxes:C(UH).readonly().optional(),collectionIds:C(u()).readonly().optional(),verdict:zH.optional(),revision:r().int().optional(),dismissed:C(MH).readonly().optional(),review:FH.optional(),imageUrl:u().optional(),thumbnailUrl:u().optional()}),KH=S([`source-missing`,`unreadable-image`,`write-failed`]),qH=x({copied:C(GH).readonly(),refused:C(x({sourceMediaId:r().int(),reason:KH})).readonly()}),JH=x({candidates:C(HH).readonly(),copies:C(GH).readonly(),autoPickMediaId:r().int().optional()}),YH=S([`unannotated`,`annotated`,`complete`]),XH=x({workState:YH.optional(),deviceIds:C(r()).max(500).optional(),collectionId:u().optional(),classes:C(DH).optional(),page:r().int().positive().default(1),pageSize:r().int().positive().max(100).default(50)}),ZH=GH.extend({workState:YH}),QH=x({frames:C(ZH).readonly(),total:r().int().nonnegative(),page:r().int().positive(),pageSize:r().int().positive()}),$H=x({deviceId:r(),unannotated:r().int().nonnegative(),annotated:r().int().nonnegative(),complete:r().int().nonnegative(),pctOfCorpus:r().min(0).max(1).nullable()}),eU=x({total:r().int().nonnegative(),unannotated:r().int().nonnegative(),annotated:r().int().nonnegative(),complete:r().int().nonnegative(),cameras:C($H).readonly()}),tU=x({deviceIds:C(r()).optional(),frameIds:C(u()).max(2e4).optional(),collectionIds:C(u()).max(200).optional(),collectionId:u().optional(),batchId:u().optional(),completeOnly:y().optional(),workState:YH.optional(),classes:C(DH).optional()}),nU=S([`frames`,`crops`]),rU=x({kind:m(`http`),method:S([`PUT`,`POST`]),url:u().url(),headers:h(u(),u()).optional()}),iU=x({batchId:u(),frames:r().int(),crops:r().int(),annotations:r().int(),missing:r().int(),bytes:r().int(),sha256:u(),status:r().int()}),aU=a(`kind`,[x({kind:m(`package`),zone:AH.optional()}),x({kind:m(`objects`),modelId:u(),minScore:r().optional()})]),oU=a(`kind`,[x({kind:m(`proposed`),modelId:u(),stepId:u(),minScore:r(),proposals:C(LH).readonly(),belowThreshold:r().int()}),x({kind:m(`refused`),reason:u(),detail:u().optional()})]),sU=x({id:u(),name:u(),createdAt:r(),frameCount:r().int()}),cU=a(`kind`,[x({kind:m(`created`),collection:sU}),x({kind:m(`refused`),reason:S([`empty-name`,`duplicate-name`])})]),lU=a(`kind`,[x({kind:m(`renamed`),collection:sU}),x({kind:m(`refused`),reason:S([`empty-name`,`duplicate-name`,`unknown-collection`])})]),uU=a(`kind`,[x({kind:m(`added`),collectionId:u(),frame:GH,reused:y()}),x({kind:m(`refused`),reason:S([`unknown-collection`,`still-unavailable`,`still-busy`,`unreadable-image`,`write-failed`]),detail:u().optional()})]),dU=x({id:u(),name:u(),model:u(),kind:u(),leavesHouse:y()}),fU=LH.extend({reason:u()}),pU=x({ref:u(),verdict:S([`confirmed`,`wrong-class`,`not-an-object`,`uncertain`]),suggestedClass:DH.optional(),reason:u()}),mU=a(`kind`,[x({kind:m(`proposed`),profileId:u(),model:u(),leftHouse:y(),proposals:C(fU).readonly(),reviews:C(pU).readonly(),rejected:r().int()}),x({kind:m(`refused`),reason:S([`unknown-frame`,`unreadable-frame`,`unknown-profile`,`profile-disabled`,`no-vision`,`cloud-not-confirmed`,`llm-error`,`malformed-answer`]),detail:u().optional()})]),hU=x({deviceIds:C(r()).readonly().optional(),collectionIds:C(u()).max(200).readonly().optional(),frameIds:C(u()).max(2e4).readonly().optional()}),gU=x({frames:r().int(),completeFrames:r().int(),completeness:r(),subjects:r().int(),modelErrors:r().int(),hardNegatives:r().int(),cells:C(x({macroClass:u(),deviceId:r(),lighting:S([`day`,`night`,`unknown`]),subjects:r().int(),frames:r().int()})).readonly(),cameras:C(x({deviceId:r(),frames:r().int(),completeFrames:r().int()})).readonly()}),HCe=x({id:u(),name:u(),createdAt:r(),selection:hU,layout:nU,completeOnly:y(),frameCount:r().int(),annotationHash:u(),manifestSchema:u(),stats:gU}),_U=x({collectionIds:C(u()).min(1),workState:S([`complete`,`annotated_or_complete`,`any_annotated`]).default(`complete`)}),vU=a(`kind`,[x({kind:m(`resolved`),frameIds:C(u()).max(2e4).readonly(),stats:gU,annotationHash:u(),layout:nU}),x({kind:m(`refused`),reason:S([`unknown-collection`,`no-frames`]),detail:u()})]),yU=x({trackId:u(),retrainStatus:aH,changed:y(),reason:S([`unknown-track`,`no-frames-copied`,`not-staging`,`not-trained`,`unchanged`]).optional()}),bU=1e3,xU=5e3,SU=x({deviceId:r(),since:r().optional(),until:r().optional(),limit:r().int().min(1).max(xU).default(bU),projection:S([`full`,`slim`]).optional()}),UCe=SU.extend({classFilter:u().optional()}),CU=x({deviceIds:C(r()),since:r().optional(),until:r().optional(),limit:r().int().min(1).max(1e3).default(200),cursor:u().optional(),projection:nH.optional(),includeStationary:y().optional(),classes:C(u()).optional(),excludeSources:C(iH).optional()}),wU=x({tracks:C(hH).readonly(),nextCursor:u().nullable()}),TU=50,EU=200,WCe=x({deviceId:r(),since:r(),until:r(),limit:r().int().min(1).max(EU).default(TU),minImportance:r().min(0).max(1).optional(),classFilter:u().optional()}),DU=x({id:u(),trackId:u(),timestamp:r(),className:u(),...dH,importance:r(),bestEventId:u(),windowMs:r().optional(),audioLabels:C(rH).readonly().optional(),...oH,...sH}),GCe=x({deviceIds:C(r()).min(1).max(200),since:r(),until:r(),limit:r().int().min(1).max(EU).default(TU),minImportance:r().min(0).max(1).optional(),classFilter:u().optional()}),KCe=x({deviceId:r(),events:C(DU).readonly()}),OU=x({bucketStart:r(),motion:r().int(),object:r().int(),audio:r().int(),audioDbfs:r().optional()}),kU=x({deviceId:r(),read:S([`read`,`unreadable`]),buckets:C(OU).readonly()}),qCe=x({trackId:u(),className:u(),confidence:r(),bbox:Ay,zones:C(u()).readonly(),state:KV}),JCe=ce({id:u(),kind:S([`first-level`,`detail`]),macroClass:u(),score:r(),bbox:x({x:r(),y:r(),width:r(),height:r()}),labels:C(ce({label:u(),score:r()})).readonly(),parentId:u().optional()}),AU=xH.extend({score:r()}),YCe=x({text:u(),deviceId:r().optional(),since:r().optional(),until:r().optional(),classFilter:u().optional(),limit:r().default(50),minScore:r().min(0).max(1).optional(),strictness:Wd.optional(),modelId:u().min(1).optional()}),jU=x({tracks:r().int(),events:r().int(),media:r().int(),faces:r().int(),plates:r().int(),embeddings:r().int()}),XCe=x({mediaDropped:r().int(),tracks:r().int(),events:r().int()}),ZCe=x({deviceId:r(),rows:r().int(),bytes:r().int()}),QCe=x({totalRows:r().int(),totalBytes:r().int(),devices:C(ZCe).readonly()}),$Ce=x({kind:CH,rows:r().int(),bytes:r().int()}),ewe=x({totalRows:r().int(),totalBytes:r().int(),kinds:C($Ce).readonly(),unaccountedRows:r().int(),unaccountedBytes:r().int()}),MU=x({motion:r().int(),object:r().int(),audio:r().int()}),twe=x({deviceId:r().optional(),since:r().optional(),until:r().optional(),maxTracks:r().int().positive().optional(),executeOnNodeId:u().optional(),pacingMs:r().int().nonnegative().optional(),force:y().optional()}),nwe=x({deleted:r(),failedIndexes:C(u()).optional()}),NU=S([`stores-unavailable`,...AV,`method-unavailable`,`read-failed`,`reads-disagree`,`not-a-clip-model`,`force-requires-max-tracks`]),rwe=x({started:y(),alreadyRunning:y(),refusal:NU.optional(),modelId:u().optional(),index:u().optional()}),iwe=x({running:y(),scanned:r(),rebuilt:r(),missingKeyFrame:r(),missingEvent:r(),missingBbox:r(),boxSource:x({subjectBox:r(),positions:r(),event:r(),refused:r()}),alreadyInSpace:r(),force:y().nullable(),forcedInSpace:r(),notRunnable:r(),noCapableNode:r(),failed:r(),complete:y().nullable(),startedAtMs:r().nullable(),finishedAtMs:r().nullable(),error:u().nullable(),modelId:u().nullable(),index:u().nullable()}),awe=x({started:y(),alreadyRunning:y()}),owe=x({mode:S([`report`,`reclaim`]).default(`report`),scopes:C(S([`motion-still`,`track-filmstrip`])).min(1).optional(),deviceIds:C(r().int()).min(1).optional(),restart:y().optional(),pageSize:r().int().min(50).max(5e3).optional(),maxRowsPerDevice:r().int().min(1).max(5e5).optional(),maxReclaimPerDevice:r().int().min(1).max(5e5).optional(),maxBytesPerRun:r().int().min(1).optional(),budgetMinutes:r().int().min(1).max(720).optional(),throttleBytesPerSec:r().int().min(64*1024).optional(),graceMinutes:r().int().min(1).max(10080).optional()}),swe=x({running:y(),mode:S([`report`,`reclaim`]).nullable(),totalExamined:r(),totalEligible:r(),totalReclaimed:r(),totalBytesReclaimed:r(),totalRefused:r(),devicesDone:r(),complete:y().nullable(),startedAtMs:r().nullable(),finishedAtMs:r().nullable(),error:u().nullable()}),PU=S([`motion`,`audio-dbfs`,`battery`,`occupancy`]);function cwe(e,t){let n=e??``;return t===void 0?n:`${n}|${t}`}function FU(e){let t=e.indexOf(`|`);return t<0?{zoneId:e}:{zoneId:e.slice(0,t),className:e.slice(t+1)}}var IU=x({scope:u(),bucketStart:r().int(),samples:r().int().nonnegative(),sum:r(),min:r(),max:r()}),LU={name:`pipeline-analytics`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Camera],exposesDeviceSettings:!0,methods:{getActiveTracks:D(x({deviceId:r()}),C(hH).readonly()),getTrack:D(x({deviceId:r(),trackId:u()}),hH.nullable()),listTracks:D(x({deviceId:r(),since:r().optional(),until:r().optional(),limit:r().optional(),zone:JV.optional(),projection:nH.optional(),includeStationary:y().optional(),classes:C(u()).optional(),excludeSources:C(iH).optional()}),C(hH).readonly()),listRecentTracks:D(CU,wU),clearTracks:D(x({deviceId:r()}),v(),{kind:`mutation`,auth:`admin`}),getMotionEvents:D(SU,C(_H).readonly()),getObjectEvents:D(UCe,C(xH).readonly()),getAudioEvents:D(SU,C(SH).readonly()),listEventKinds:D(x({deviceId:r()}),C(ZV).readonly()),listEventKindsBatch:D(x({deviceIds:C(r()).min(1).max(200)}),C(QV).readonly()),getSensorEvents:D(x({deviceId:r(),since:r().optional(),until:r().optional(),kinds:C(u()).optional(),limit:r().int().min(1).max(xU).default(bU)}),C($V).readonly()),getKeyEvents:D(WCe,C(DU).readonly()),getKeyEventsBatch:D(GCe,C(KCe).readonly()),readLongTermSeries:D(x({deviceId:r(),series:PU,scope:u().optional(),from:r(),to:r(),limit:r().int().positive().optional()}),C(IU).readonly()),getEventDensity:D(x({deviceId:r(),since:r(),until:r(),bucketMs:r().int().positive()}),C(OU).readonly()),getEventDensityBatch:D(x({deviceIds:C(r()).min(1).max(200),since:r(),until:r(),bucketMs:r().int().positive()}),C(kU).readonly()),pruneEventsBefore:D(x({deviceId:r(),cutoffMs:r()}),x({motion:r().int(),object:r().int(),audio:r().int()}),{kind:`mutation`,auth:`admin`}),pruneTracksBefore:D(x({deviceId:r(),cutoffMs:r()}),jU,{kind:`mutation`,auth:`admin`}),wipeAllAnalytics:D(x({deviceId:r()}),jU,{kind:`mutation`,auth:`admin`}),reconcileFromDisk:D(x({deviceId:r()}),XCe,{kind:`mutation`,auth:`admin`}),deleteTracks:D(x({deviceId:r(),trackIds:C(u()).min(1)}),x({deleted:r().int(),failed:C(u()).readonly(),sparedMediaIds:C(r().int()).readonly().optional()}),{kind:`mutation`,auth:`admin`}),setTrackFlags:D(x({deviceId:r(),trackId:u(),flags:cH}),lH,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listArchivedDebugNotes:D(Zs,C(Xs).readonly(),{kind:`query`}),setTrackRelation:D(vae,tc,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),clearTrackRelation:D(rc,ic,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),setTrackPurity:D(ac,oc,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listTrackRelations:D(sc,cc,{kind:`query`}),listBirthDecisions:D(Ys,C(Js).readonly(),{kind:`query`}),getEventStoreFootprint:D(x({}),QCe,{kind:`query`,auth:`admin`}),getEventMediaFootprintByKind:D(x({deviceId:r().int().optional()}),ewe,{kind:`query`,auth:`admin`}),pruneEvents:D(x({olderThanMs:r(),reason:gc.optional()}),MU,{kind:`mutation`,auth:`admin`}),deleteDeviceEvents:D(x({deviceId:r()}),MU,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:D(Cl,x({paused:m(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:D(Cl,x({resumed:m(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:D(Cl,x({refreshed:m(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:D(Ml,x({jobId:u()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:D(x({jobId:u()}),bl.nullable(),{auth:`admin`}),cancelStorageMigrationMove:D(x({jobId:u()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateMedia:D(El,x({jobId:u()}),{kind:`mutation`,auth:`admin`}),countUnstampedEventMedia:D(x({}),Ol,{auth:`admin`}),getMediaLocationCensus:D(kl,jl,{kind:`query`,auth:`admin`}),countRelocatableMedia:D(iu,ru,{kind:`query`,auth:`admin`}),listRelocateMediaJobs:D(x({}),C(bl).readonly(),{kind:`query`,auth:`admin`}),cancelRelocateMedia:D(x({jobId:u()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),listOpsLog:D(vc,C(_c).readonly(),{kind:`query`,auth:`admin`}),reclaimDebugMedia:D(owe,awe,{kind:`mutation`,auth:`admin`}),getMediaReclaimStatus:D(x({}),swe,{kind:`query`,auth:`admin`}),getTrainingExportSummary:D(x({deviceIds:C(r()).optional()}),pH,{kind:`query`,auth:`admin`}),getTrainingExportUrl:D(x({deviceIds:C(r()).optional()}),x({url:u()}),{kind:`query`,auth:`admin`}),listRetrainStaging:D(x({deviceIds:C(r()).optional(),limit:r().int().min(1).max(500).optional()}),C(VH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainCorpusPage:D(XH,QH,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getRetrainCorpusKpi:D(x({}),eU,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainFrames:D(x({trackId:u()}),JH,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),selectRetrainFrames:D(x({deviceId:r(),trackId:u(),mediaIds:C(r().int()).min(1)}),qH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deselectRetrainFrame:D(x({deviceId:r(),trackId:u().optional(),frameId:u()}),x({removed:y(),removedAnnotations:r().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainFrameImage:D(x({frameId:u()}),x({base64:u(),width:r().int(),height:r().int()}),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotations:D(x({deviceId:r(),trackId:u().optional(),frameId:u(),subject:aU,nodeId:u().optional()}),oU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainAnnotations:D(x({trackId:u().optional(),frameIds:C(u()).max(2e3).optional()}),C(IH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),saveRetrainAnnotations:D(x({deviceId:r(),trackId:u().optional(),frameId:u(),annotations:C(LH),expectedRevision:r().int().optional(),dismissed:C(MH).optional()}),C(IH).readonly(),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),backfillRetrainOrigins:D(x({deviceId:r(),trackId:u().optional(),frameId:u(),expectedRevision:r().int().optional(),origins:C(x({annotationId:u(),origin:jH})).min(1).max(500)}),x({updated:r().int(),skipped:r().int(),revision:r().int()}),{kind:`mutation`,auth:`admin`}),completeRetrainTrack:D(x({deviceId:r(),trackId:u()}),yU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),restageRetrainTrack:D(x({deviceId:r(),trackId:u()}),yU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainExportUrl:D(tU.extend({layout:nU.optional()}),x({url:u()}),{kind:`query`,auth:`admin`}),setRetrainFrameComplete:D(x({deviceId:r(),trackId:u().optional(),frameId:u(),complete:y()}),GH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),writeRetrainArchive:D(x({filter:tU,layout:nU,target:rU}),iU,{kind:`mutation`,auth:`admin`,timeoutMs:60*6e4}),offerRetrainArchive:D(x({filter:tU,layout:nU}),x({ticket:io,frames:r().int(),annotations:r().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),listRetrainAssistProfiles:D(x({}),C(dU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotationsWithLlm:D(x({deviceId:r(),trackId:u().optional(),frameId:u(),profileId:u(),classes:C(DH).min(1),boxes:C(x({ref:u(),bbox:AH,macroClass:DH,label:u().optional()})).max(50),allowCloud:y()}),mU,{kind:`mutation`,auth:`admin`,timeoutMs:18e4}),createRetrainCollection:D(x({name:u().max(120)}),cU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollections:D(x({}),C(sU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),resolveRetrainTrainingCorpus:D(_U,vU,{kind:`query`,auth:`admin`,timeoutMs:6e4}),renameRetrainCollection:D(x({id:u(),name:u().max(120)}),lU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deleteRetrainCollection:D(x({id:u()}),x({deleted:y(),removedFrames:r().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),addRetrainFrameFromRecording:D(x({collectionId:u(),deviceId:r(),epochMs:r(),verdictSubject:BH.optional()}),uU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`,timeoutMs:6e4}),addRetrainFramesToCollection:D(x({collectionId:u(),frameIds:C(u()).min(1).max(500)}),x({added:r().int(),alreadyMember:r().int(),unknownFrameIds:C(u()).readonly()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),removeRetrainFrameFromCollection:D(x({collectionId:u(),frameId:u()}),x({removed:y(),deletedFrame:y()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollectionFrames:D(x({collectionId:u()}),C(GH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getEventMedia:D(x({ownerType:Ue,eventId:r().int(),kind:CH.optional(),deviceId:r()}),C(TH).readonly()),getTrackMedia:D(x({trackId:u(),kinds:C(CH).optional(),deviceId:r()}),C(TH).readonly()),listTrackMedia:D(x({trackId:u(),deviceId:r()}),C(EH).readonly()),listEventMedia:D(x({ownerType:Ue,eventId:r().int(),deviceId:r()}),C(EH).readonly()),ownersWithMedia:D(x({deviceId:r(),ownerKind:Ge,ownerIds:C(u()).max(5e3)}),C(u()).readonly()),searchObjectEvents:D(YCe,C(AU).readonly(),{caller:`required`}),wipeObjectEmbeddings:D(x({}),nwe,{kind:`mutation`,auth:`admin`}),rebuildObjectEmbeddings:D(twe,rwe,{kind:`mutation`,auth:`admin`}),getObjectEmbeddingRebuildStatus:D(x({}),iwe)},events:{onFrameTracked:{data:x({deviceId:r(),timestamp:r(),frameWidth:r(),frameHeight:r(),detections:C(JCe).readonly()}),notOperatorFacing:`one tracker frame — stream rate, never an automation trigger`},onTrackStarted:{data:x({deviceId:r(),trackId:u(),className:u()}),trigger:{category:T.PipelineAnalyticsTrackStarted,label:L(`Subject appeared`,`Soggetto comparso`),phrase:L(`When {device} starts following a subject`,`Quando {device} inizia a seguire un soggetto`),icon:`scan-eye`}},onTrackEnded:{data:x({deviceId:r(),trackId:u(),className:u(),durationMs:r()}),trigger:{category:T.PipelineAnalyticsTrackEnded,label:L(`Subject left`,`Soggetto uscito`),phrase:L(`When a subject leaves the view of {device}`,`Quando un soggetto esce dall’inquadratura di {device}`),icon:`scan-eye`}},onDetectionEvent:{data:x({deviceId:r(),kind:qV,eventId:u(),timestamp:r()}),trigger:{category:T.PipelineAnalyticsDetectionEvent,label:L(`Detection event`,`Evento di rilevamento`),phrase:L(`When {device} records a detection event`,`Quando {device} registra un evento di rilevamento`),icon:`radar`}}},vocabulary:{noun:L(`Tracking`,`Tracciamento`),order:3200,extraEvents:[{category:T.PipelineAnalyticsPackageDelivered,label:L(`Package delivered`,`Pacco consegnato`),phrase:L(`When a package is left in front of {device}`,`Quando viene lasciato un pacco davanti a {device}`),icon:`package`},{category:T.PipelineAnalyticsPackagePickedUp,label:L(`Package picked up`,`Pacco ritirato`),phrase:L(`When a package is picked up in front of {device}`,`Quando viene ritirato un pacco davanti a {device}`),icon:`package-open`}]}},RU=o(()=>x({addonId:u(),modelId:u().optional(),enabled:y().default(!0),children:C(RU).optional(),settings:h(u(),w()).optional(),jumpDeviceKey:u().optional()})),zU=ye(),BU=x({x:r(),y:r(),w:r(),h:r()}),VU=x({stepId:u(),modelId:u(),detections:C(x({bbox:d([r(),r(),r(),r()]),score:r(),landmarks:C(x({x:r(),y:r()})).optional()})).min(1)}),HU=x({handle:Lc,cropFrameSpace:x({x:r(),y:r(),w:r(),h:r()})});x({crop:x({left:r(),top:r(),width:r().positive(),height:r().positive()}).optional(),content:x({width:r().int().positive(),height:r().int().positive()}),fit:S([`stretch`,`contain`]),format:S([`rgb`,`gray`,`jpeg`])});var lwe=x({registryId:u().min(1),id:u().min(1),width:r().int().positive(),height:r().int().positive(),format:S([`rgb`,`gray`]),timestamp:r(),capturedAt:r().optional()}),UU=S([`onnx`,`coreml`,`openvino`,`tflite`,`pt`,`gguf`]),WU=S([`detector`,`cropper`,`classifier`,`refiner`,`audio-classifier`]),GU=x({runtime:m(`python`),backend:u(),format:UU,device:u().optional()}),KU=x({deviceKey:u().nullable(),runtime:u(),batchMode:u(),windowMs:r(),maxBatchSize:r(),concurrency:r(),numWorkers:r()}),uwe=x({engine:GU,devices:C(x({id:u(),label:u(),description:u().optional()})).readonly(),defaultDevice:u()}),qU=o(()=>x({addonId:u(),addonName:u(),slot:WU,inputClasses:C(u()).readonly(),outputClasses:C(u()).readonly(),enabled:y(),modelId:u(),children:C(qU).readonly(),group:u().optional(),settings:h(u(),w()).optional()})),dwe=x({id:u(),name:u(),formats:h(u(),gf),group:yf.optional(),legacy:y().optional(),provider:xf.optional(),defaultConfidence:r().optional(),suppliesSteps:C(wf).readonly().optional()}),fwe=ye(),pwe=x({id:u(),name:u(),slot:WU,inputClasses:C(u()).readonly(),outputClasses:C(u()).readonly(),childSlots:C(WU).readonly(),models:C(dwe).readonly(),defaultModelId:u(),defaultModelIdByFormat:h(u(),u()).optional(),enabledByDefault:y().optional(),defaultConfidence:r(),group:u().optional(),configSchema:C(fwe).readonly().optional()}),mwe=x({id:WU,label:u(),priority:r(),parentSlot:WU.nullable(),addons:C(pwe).readonly()}),hwe=x({availableEngines:C(uwe).readonly(),selectedEngine:GU,slots:C(mwe).readonly()}),gwe=x({runtimeId:S([`onnx`,`openvino`,`coreml`,`edgetpu`]).nullable(),device:u().nullable(),state:S([`idle`,`installing`,`verifying`,`ready`,`failed`]),progress:r().optional(),error:u().optional(),nextRetryAt:r().optional(),configIssues:C(u()).optional()}),JU=x({addonId:u(),chosen:u(),running:u(),format:u()}),YU=x({addonId:u(),kind:S([`unknown-addon`,`no-format-build`,`unknown-device`]),detail:u()}),XU=x({ok:y(),issues:C(YU).readonly(),substitutions:C(JU).readonly(),format:u()}),_we=x({filename:u(),stepIds:C(u()).readonly().optional()}),vwe=x({base64:u(),filename:u()}),ywe=x({filename:u(),sizeKb:r()}),bwe=x({base64:u()}),xwe=x({id:u(),name:u(),description:u(),available:y(),rawLabels:C(u()).readonly().optional()}),Swe=x({activeBackend:u(),availableBackends:C(xwe).readonly(),sampleRate:r(),chunkDurationMs:r()}),Cwe=x({filePath:u(),sizeMB:r(),durationMs:r()}),wwe=x({success:y(),error:u().optional(),frame:ye().optional()}),Twe=ye(),Ewe=ye(),Dwe=ye(),Owe=ye(),ZU={name:`pipeline-executor`,scope:`system`,mode:`singleton`,methods:{getAvailableEngines:D(v(),C(GU)),getSelectedEngine:D(v(),GU),getEngineProvisioning:D(x({nodeId:u()}),gwe),getVideoPipelineSteps:D(v(),h(u(),x({modelId:u(),settings:h(u(),w()).readonly()}))),setVideoPipelineSteps:D(x({steps:h(u(),x({modelId:u(),settings:h(u(),w()).readonly()}))}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getInferenceDeviceHealth:D(x({nodeId:u()}),x({unhealthy:C(x({deviceKey:u(),state:S([`failed`,`backoff`]),since:r(),deaths:r(),lastError:u(),absentReason:S([`no-gpu-device`]).optional()})).readonly()})),rearmInferenceDevice:D(x({nodeId:u(),deviceKey:u()}),x({rearmed:y()}),{kind:`mutation`,auth:`admin`}),getSchema:D(v(),hwe),getOrchestratorConfigSchema:D(v(),Twe),validatePipeline:D(x({steps:C(RU),deviceKey:u().optional()}),XU),getCapabilities:D(v(),Dwe),getAddonModels:D(x({addonId:u()}),Owe),downloadModel:D(x({addonId:u(),modelId:u(),format:UU}),Cwe,{kind:`mutation`}),deleteModel:D(x({addonId:u(),modelId:u(),format:UU}),x({success:m(!0)}),{kind:`mutation`}),runPipeline:D(x({steps:C(RU).min(1),frame:ky.optional(),frameRef:lwe.optional(),frameHandle:Lc.optional(),imageBase64:u().optional(),image:b(Uint8Array).optional(),referenceImage:u().optional(),deviceId:r().optional(),sessionId:u().optional(),plane:S([`full`,`frame`]).optional(),deviceKey:u().optional(),nativeCropRef:HU.optional(),replay:m(!0).optional(),suppliedRoot:VU.optional(),motionRegions:C(BU).optional()}),zU,{kind:`mutation`}),runPipelineBatch:D(x({steps:C(RU).min(1),frames:C(ky).min(1).max(255),deviceId:r().optional(),sessionId:u().optional(),frameId:r().int().nonnegative().optional(),deviceKey:u().optional()}),x({results:C(zU).readonly()}),{kind:`mutation`}),cacheFrameInPool:D(x({data:b(Uint8Array),width:r().int().positive(),height:r().int().positive(),format:S([`rgb`,`bgr`,`gray`])}),x({frameId:r(),width:r(),height:r()}),{kind:`mutation`}),inferCached:D(x({stepId:u(),frameId:r().int(),modelId:u().min(1)}),h(u(),w()),{kind:`mutation`}),uncacheFrame:D(x({frameId:r().int()}),v(),{kind:`mutation`}),getEffectiveTuning:D(x({deviceKey:u().optional()}),KU),listLoadedEngines:D(v(),C(x({engineKey:u(),engine:GU,modelsLoaded:C(u()).readonly(),inUseByCameras:C(r()).readonly(),kind:S([`runtime`,`device-pool`]),poolPid:r().nullable(),idleMs:r().nullable(),idleTtlMs:r().nullable()})).readonly()),spinEngine:D(x({engine:GU}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),killEngine:D(x({engine:GU,force:y().optional()}),x({success:y(),reason:u().optional()}),{kind:`mutation`,auth:`admin`}),listReferenceImages:D(v(),C(_we).readonly()),getReferenceImage:D(x({filename:u()}),vwe.nullable()),getReferenceAudioFiles:D(v(),C(ywe).readonly()),getReferenceAudio:D(x({filename:u()}),bwe.nullable()),getAudioCapabilities:D(v(),Swe),runAudioTest:D(x({addonId:u(),modelId:u(),filename:u().optional(),settings:h(u(),w()).optional()}),wwe,{kind:`mutation`}),getDetectionConfigSchema:D(v(),Ewe)},vocabulary:{notOperatorFacing:k.PIPELINE}},kwe=x({activeCameras:r(),throttledCameras:r(),avgInferenceTimeMs:r(),queueDepth:r()}),QU=x({detectionMode:S([`disabled`,`always-on`,`on-motion`]),configuredFps:r(),actualFps:r(),queueDepth:r(),avgInferenceTimeMs:r(),droppedFrames:r(),nativeCropMisses:r().optional(),phase:S([`idle`,`watching`,`active`])}),$U=QU.extend({deviceId:r()}),eW=S([`polygon`,`tripwire`]),tW=x({x:r(),y:r()}),nW=x({id:u(),name:u(),kind:eW.default(`polygon`),polygon:C(tW).readonly(),color:u().default(`#3b82f6`)}),rW={name:`zones`,scope:`device`,mode:`singleton`,deviceTypes:[M.Camera],methods:{listZones:D(x({deviceId:r()}),C(nW).readonly()),addZone:D(x({deviceId:r(),zone:nW}),v(),{kind:`mutation`,auth:`admin`}),removeZone:D(x({deviceId:r(),zoneId:u()}),v(),{kind:`mutation`,auth:`admin`}),updateZone:D(x({deviceId:r(),zone:nW}),v(),{kind:`mutation`,auth:`admin`})},runtimeState:x({zones:C(nW).readonly()}),durability:`restored`,history:`none`,vocabulary:{noun:L(`Zones`,`Zone`),order:3370}},iW={fpsPerStream:10,budgetMinutes:45,minBudgetMinutes:10,maxBudgetMinutes:120,staleAfterDays:30,settleSec:5,measureSec:20,drainTimeoutSec:120,maxModelsPerDevice:6},aW=S([`device`,`pipeline`]),oW=x({deviceKey:u().min(1),modelIds:C(u().min(1)).min(1).max(iW.maxModelsPerDevice)}),sW=x({nodeId:u().min(1),devices:C(oW).min(1),phases:C(aW).min(1).default([`device`,`pipeline`]),steps:C(u().min(1)).default([]),fpsPerStream:r().int().min(1).max(30).default(iW.fpsPerStream),budgetMinutes:r().int().min(iW.minBudgetMinutes).max(iW.maxBudgetMinutes).default(iW.budgetMinutes),keepDownloadedModels:y().default(!1),acceptInsufficientHeadroom:y().default(!1)}),cW=S([`benchmark-active`,`node-offline`,`unknown-device`,`no-phase`,`insufficient-headroom`]),lW=x({kind:cW,detail:u(),overridable:y()}),uW=x({deviceId:r(),placedOnNode:y(),pinnedToNode:y()}),dW=x({deviceId:r(),reason:m(`only-frame-source`)}),fW=x({nodeId:u(),online:y(),moving:C(uW).readonly(),staying:C(dW).readonly(),estimatedDurationMs:r(),budgetMs:r(),phases:C(aW).readonly(),steps:C(u()).readonly(),devices:C(oW).readonly(),headroom:x({sessionsNow:r(),otherNodesCapacitySessions:r().nullable()}),refusals:C(lW).readonly(),canStart:y()}),pW=x({phase:S([`preparing`,`device`,`pipeline`,`cleanup`]),deviceKey:u().nullable(),modelId:u().nullable(),load:r().nullable(),cellsDone:r(),cellsTotal:r(),message:u()}),mW=S([`p95`,`drops`,`errors`,`stall`,`cpu`,`ram`,`none`]),hW=x({load:r(),pass:y(),p95Ms:r(),dropRatio:r(),fps:r(),cpuPct:r().nullable(),ramFreePct:r().nullable(),failReasons:C(u()).readonly()}),gW=x({phase:m(`device`),deviceKey:u(),modelId:u(),p50Ms:r(),p95Ms:r(),p99Ms:r(),fps:r(),kMax:r(),limitedBy:mW,warmupMs:r(),ramp:C(hW).readonly()}),_W=x({phase:m(`pipeline`),deviceKey:u(),modelId:u(),steps:C(u()).readonly(),maxSessions:r(),limitedBy:mW,stepsFired:C(u()).readonly(),warmupMs:r(),ramp:C(hW).readonly()}),vW=a(`phase`,[gW,_W]),yW=x({pipelineVersion:u().nullable(),cpuModel:u().nullable(),ramGb:r().nullable(),os:u().nullable(),pools:h(u(),x({runtime:u(),numWorkers:r(),concurrency:r(),batchMode:u()})).default({})}),bW=x({id:u(),revision:u().nullable(),frames:r(),width:r(),height:r()}),xW=x({runId:u().min(1),devices:C(oW).min(1),phases:C(aW).min(1),steps:C(u()).default([]),fpsPerStream:r().int().min(1).max(30),deadlineAtMs:r(),settleSec:r().min(0).max(60).default(iW.settleSec),measureSec:r().min(2).max(300).default(iW.measureSec),keepDownloadedModels:y().default(!1)}),SW=S([`running`,`done`,`failed`,`aborted`]),CW=x({runId:u(),nodeId:u(),state:SW,progress:pW.nullable(),cells:C(vW).readonly(),fingerprint:yW.nullable(),clip:bW.nullable(),activeCameraIds:C(r()).readonly(),deletedModels:C(u()).readonly(),error:u().nullable(),startedAtMs:r(),finishedAtMs:r().nullable()}),wW=S([`draining`,`measuring`,`restoring`,`done`,`failed`,`aborted`]),TW=S([`completed`,`operator-abort`,`deadline`,`node-lost`,`runner-lost`,`hub-restart`,`drain-timeout`,`failed`]),EW=x({runId:u(),nodeId:u(),state:wW,plan:sW,startedAtMs:r(),deadlineAtMs:r(),finishedAtMs:r().nullable(),endReason:TW.nullable(),error:u().nullable(),moved:C(r()).readonly(),staying:C(r()).readonly(),contaminated:y(),progress:pW.nullable(),resultIds:C(u()).readonly()}),DW=x({modeNodeId:u().nullable(),run:EW.nullable()}),OW=x({id:u(),runId:u(),nodeId:u(),cell:vW,fpsPerStream:r(),fingerprint:yW.nullable(),clip:bW.nullable(),contaminated:y(),stayingCameras:C(r()).readonly(),partialRun:y(),measuredAtMs:r()}),kW=x({nodeId:u().optional(),deviceKey:u().optional()}),AW=OW.extend({standing:S([`fresh`,`stale`,`superseded`]),staleWhy:S([`age`,`runtime`,`pool-tuning`]).nullable()}),Awe=x({runId:u(),nodeId:u(),startedAtMs:r(),deadlineAtMs:r(),plan:sW,moved:C(r()).readonly(),staying:C(r()).readonly()}),jW=x({nodeId:u(),reachable:y(),devices:C(x({deviceKey:u(),enabled:y(),available:y(),suggested:C(u()).readonly(),all:C(u()).readonly(),currentModelId:u().nullable()})).readonly(),steps:C(x({id:u(),name:u(),slot:u()})).readonly()}),MW=x({x:r(),y:r(),w:r(),h:r()}),NW=x({bytes:b(Uint8Array).optional(),jpeg:u().optional(),jpegBytes:b(Uint8Array).optional(),width:r().int().positive(),height:r().int().positive(),tier:S([`native`,`ram-fullframe`]).optional()}),PW=S([`keyFrame`,`thumbnail`]),FW=S([`handle-gone`,`encode-failed`]),IW=a(`parked`,[x({parked:m(!0),nodeId:u(),width:r().int().positive(),height:r().int().positive(),bytes:r().int().nonnegative(),replaced:y()}),x({parked:m(!1),nodeId:u(),reason:FW,handleAgeMs:r().nullable(),detail:u().optional()})]),LW=x({jpeg:u().optional(),jpegBytes:b(Uint8Array).optional(),width:r().int().positive(),height:r().int().positive(),timestamp:r(),parkedAt:r()}),jwe=x({bbox:MW,className:u()}),RW=x({stepId:u(),className:u(),score:r(),bbox:MW.optional(),embedding:u().optional(),embeddingMagnitude:r().optional(),embeddingModelId:u().optional(),label:u().optional(),labelTier:g([m(1),m(2)]).optional(),labelModelId:u().optional(),alignedCropJpeg:u().optional(),nativeFaceShortSidePx:r().optional(),landmarks:C(x({x:r(),y:r()})).optional()}),Mwe=S([`unknown-step`,`model-not-servable`,`unreadable-frame`,`execution-failed`,`no-eligible-device`]),Nwe=a(`kind`,[x({kind:m(`ran`),nodeId:u(),modelId:u(),details:C(RW)}),x({kind:m(`refused`),nodeId:u(),reason:Mwe,detail:u()})]),zW={min:0,max:6e4,default:3e4,step:500},BW={min:0,max:6e5,default:12e4,step:5e3},VW={min:5e3,max:6e5,default:9e4,step:5e3},HW={min:1,max:30,default:4,step:1},UW={min:1,max:30,default:10,step:1},WW={min:0,max:300,default:300,step:5},GW={min:1,max:10,default:4,step:1},KW={min:0,max:30,default:12,step:1},qW=S([`onboard`,`analyzer`,`device-activity`]),JW=x({source:qW,triggeredBy:nV,sensorName:u().optional()}),YW=C(qW),XW={analyzer:`Frame-diff Analyzer (motion addon)`,onboard:`Camera sensors`,"device-activity":`Device activity (the device says it is working)`};function ZW(e){let t=qW.safeParse(e);return t.success?XW[t.data]:e}var Pwe=[`analyzer`,`onboard`,`device-activity`],QW=p(e=>Array.isArray(e)&&e.length>1?e.slice(0,1):e,C(vH).max(1)),$W=x({deviceId:r(),detected:y(),source:qW.default(`analyzer`),regions:C(vV).readonly().optional()}),eG=a(`kind`,[x({kind:m(`local-broker`)}),x({kind:m(`remote-restream`),ownerNodeId:u(),ownerReachableHost:u().optional(),hubHostnameOverride:u().optional()})]).describe(`Per-camera frame-source mode for the runner (P2c)`),tG=x({modelId:u().optional(),settings:h(u(),w()).optional()}),nG=x({deviceKey:u(),weight:r().positive().default(1),maxSessions:r().int().positive().nullable().default(null),steps:h(u(),tG).optional(),disabledSteps:C(u()).readonly().optional()}),rG=x({deviceId:r(),detectionMode:S([`disabled`,`always-on`,`on-motion`]).default(`on-motion`),audioMode:S([`disabled`,`always-on`,`on-motion`]).default(`always-on`),motionCooldownMs:r().min(zW.min).default(zW.default),maxSessionHoldMs:r().min(BW.min).max(BW.max).optional(),audioMotionWindowMs:r().min(VW.min).max(VW.max).optional(),motionFps:r().min(HW.min).max(HW.max).default(HW.default),detectionFps:r().min(UW.min).max(UW.max).default(UW.default),motionStreamId:u(),detectionStreamId:u(),audioStreamPick:Oc.optional(),motionSources:YW.default([`analyzer`]),sessionTrigger:JW.optional(),detectionSources:QW.default([`pipeline`]),pipelineEnabled:y().default(!0),steps:C(RU).readonly().optional(),audio:x({modelId:u().optional(),enabled:y()}).nullable().optional(),zones:C(nW).readonly().default([]),onboardMotionDrivesAnalyzer:y().default(!0),preRollInferenceEnabled:y().default(!0),preRollInferenceFrames:r().min(KW.min).max(KW.max).default(KW.default),occupancyRecheckEnabled:y().default(!0),occupancyRecheckSec:r().min(WW.min).max(WW.max).default(WW.default),occupancyRecheckFrames:r().min(GW.min).max(GW.max).default(GW.default),frameSource:eG.default({kind:`local-broker`}),deviceKey:u().optional(),inferenceDevices:C(nG).readonly().optional()}),Fwe=[{key:`motionSources`,type:`multiselect`,label:`Motion Sources`,default:[`analyzer`],options:Pwe.map(e=>e===`onboard`?{value:e,label:XW[e],description:`The camera's own motion, plus any sensor attached to it`}:{value:e,label:XW[e]})},{key:`motionFps`,type:`slider`,label:`Motion FPS (analyzer)`,min:HW.min,max:HW.max,step:HW.step,default:HW.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`,showWhen:{field:`motionSources`,includes:`analyzer`}},{key:`detectionFps`,type:`slider`,label:`Detection FPS`,min:UW.min,max:UW.max,step:UW.step,default:UW.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`},{key:`motionCooldownMs`,type:`slider`,label:`Motion Cooldown`,description:`Time without a fresh motion event before the active phase ends. Applies to all motion sources — every motion event re-arms the timer.`,min:zW.min,max:zW.max,step:zW.step,default:zW.default,showValue:!0,unit:`s`,displayScale:1e3,nullable:!0,nullLabel:`Default`},{key:`maxSessionHoldMs`,type:`slider`,label:`Max session hold`,description:`Upper bound on how long detection keeps running past the motion cooldown while a subject is still moving in-frame but no longer triggering motion. Prevents the detection box from stopping on a slow-moving subject. Set to 0 to disable.`,min:BW.min,max:BW.max,step:BW.step,default:BW.default,showValue:!0,unit:`s`,displayScale:1e3,nullable:!0,nullLabel:`Default`},{key:`audioMotionWindowMs`,type:`slider`,label:`Audio window after motion`,description:`How long audio keeps being analysed after the last motion event. Each new motion event extends the window without restarting the audio stream.`,min:VW.min,max:VW.max,step:VW.step,default:VW.default,showValue:!0,unit:`s`,displayScale:1e3,nullable:!0,nullLabel:`Default`,showWhen:{field:`audioMode`,equals:`on-motion`}},{key:`onboardMotionDrivesAnalyzer`,type:`boolean`,label:`Run motion analyzer on onboard motion`,description:`When onboard motion is detected, temporarily start the frame-diff analyzer to emit zone results. Stops after the motion cooldown window.`,default:!0,showWhen:{field:`motionSources`,includes:`onboard`}},{key:`preRollInferenceEnabled`,type:`boolean`,style:`checkbox`,label:`Detect in the pre-roll`,description:`Run detection over the few seconds of footage the camera had already buffered when motion fired, so a subject that was in view before the trigger is found at the moment it appeared rather than seconds later. The burst is bounded and never delays live detection.`,default:!0},{key:`preRollInferenceFrames`,type:`slider`,label:`Pre-roll frames`,description:`How many frames of buffered history may be detected on, per session. Higher samples the history more densely; 0 disables the pass.`,min:KW.min,max:KW.max,step:KW.step,default:KW.default,showValue:!0,showWhen:{field:`preRollInferenceEnabled`,equals:!0}},{key:`occupancyRecheckEnabled`,type:`boolean`,style:`checkbox`,label:`Occupancy re-check`,description:`Periodically re-sample a few frames during the watching phase, so objects that are simply parked are still counted (motion gating alone loses them after a restart). On by default at a wide interval; turn it off on cameras where the extra decoder re-dial is expensive.`,default:!0},{key:`occupancyRecheckSec`,type:`slider`,label:`Occupancy re-check interval`,description:`How often (in seconds) the runner re-samples a few frames to confirm the scene is truly empty during the watching phase.`,min:WW.min,max:WW.max,step:WW.step,default:WW.default,showValue:!0,unit:`s`,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}},{key:`occupancyRecheckFrames`,type:`slider`,label:`Occupancy re-check frames`,description:`Number of frames sampled per occupancy re-check burst.`,min:GW.min,max:GW.max,step:GW.step,default:GW.default,showValue:!0,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}}],iG=x({nodeId:u(),attachedCameras:r(),activeCameras:r(),avgInferenceFps:r(),avgInferenceTimeMs:r(),queueDepthTotal:r(),devices:C(x({deviceKey:u(),backend:u(),attachedCameras:r()})).default([]),hardware:x({hasGpu:y(),inferenceBackend:u().optional(),cpuCores:r().optional()}),motionSliceWriter:m(`orchestrator`).optional()}),aG=x({framesDecoded:r(),framesAdmitted:r(),framesDroppedPixelFree:r(),viewsMaterialized:r(),viewsSkipped:r(),workerToRunnerBytes:r(),runnerToPoolRawBytes:r(),runnerToPoolJpegBytes:r(),onDemandFullFrameRequests:r(),onDemandCropRequests:r(),nativeHits:r(),nativeMisses:r(),tileHits:r(),tileMisses:r(),fallbackHits:r(),fallbackMisses:r(),retainedWritesAvoided:r(),residentRefs:r(),residentBytes:r(),releases:r(),evictions:r(),staleMisses:r()}),oG=x({node:aG,cameras:C(aG.extend({deviceId:r()}))}),sG=x({nodeId:u(),activeCameras:r(),throttledCameras:r(),avgInferenceTimeMs:r(),queueDepth:r(),frameLazy:oG.optional()}),cG=S([`not-attached`,`battery-asleep`,`not-watching`,`already-bursting`]),lG={name:`pipeline-runner`,scope:`system`,mode:`singleton`,methods:{attachCamera:D(rG,x({success:m(!0)}),{kind:`mutation`}),detachCamera:D(x({deviceId:r()}),x({success:m(!0)}),{kind:`mutation`}),reportMotion:D($W,x({success:m(!0)}),{kind:`mutation`}),getLocalLoad:D(v(),iG),getLocalMetrics:D(v(),sG),getCameraMetrics:D(x({deviceId:r()}),QU.nullable()),getAllCameraMetrics:D(v(),C($U).readonly()),getLocalCameras:D(v(),C(r()).readonly()),requestOccupancyBurst:D(x({deviceId:r(),frames:r().int().positive().optional(),reason:u()}),x({started:y(),refusedBecause:cG.optional()}),{auth:`admin`,kind:`mutation`}),getNativeCrop:D(x({handle:Lc,bbox:MW,maxWidth:r().int().positive().optional(),acceptJpegBytes:y().optional(),encodeJpeg:y().optional()}),NW.nullable()),runDetailSubtree:D(x({deviceId:r(),frameHandle:Lc.optional(),frameJpeg:u().optional(),cropJpeg:u().optional(),parent:jwe,steps:C(u()).optional(),supplied:x({stepId:u(),modelId:u(),boxes:C(x({bbox:MW,score:r()})).min(1)}).optional()}),x({details:C(RW)}).nullable(),{kind:`mutation`}),runStatelessStep:D(x({stepId:u(),modelId:u(),frameJpeg:u(),bbox:MW,className:u(),sourceDeviceId:r()}),Nwe,{kind:`mutation`}),parkTrackFrame:D(x({deviceId:r(),trackId:u(),kind:PW,handle:Lc,bbox:MW,maxWidth:r().int().positive().optional(),timestamp:r()}),IW,{kind:`mutation`}),getParkedTrackFrame:D(x({deviceId:r(),trackId:u(),kind:PW,acceptJpegBytes:y().optional()}),LW.nullable()),releaseParkedTrackFrames:D(x({deviceId:r(),trackId:u()}),x({released:r().int().nonnegative()}),{kind:`mutation`}),startNodeBench:D(xW,x({accepted:m(!0),runId:u()}),{kind:`mutation`,auth:`admin`}),getNodeBenchStatus:D(x({runId:u()}),CW.nullable(),{auth:`admin`}),abortNodeBench:D(x({runId:u()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.PIPELINE}},uG=3e4,Iwe={version:1,targets:[{id:`detected`,cardinality:`event`,shape:`span`,vocabulary:{cap:`motion`,eventName:`onMotionChanged`},deviceTypes:[M.Camera],apply:`add`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:uG,combine:`any`,sourceModes:[`in-addition`,`confirm`,`replace`],sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},Lwe=15e3,dG=x({detected:y(),lastDetectedAt:r().nullable(),autoClearAfterMs:r().nullable().meta(A(`duration-ms`))}),fG=x({deviceId:r(),detected:y(),timestamp:r(),source:qW,regions:C(vV).readonly().optional(),triggeredBy:nV.optional()}),pG={name:`motion`,scope:`device`,mode:`singleton`,deviceNative:!0,deviceTypes:[M.Camera,M.Sensor],methods:{isDetected:D(x({deviceId:r()}),y())},composedMethods:{isDetected:{kind:`slice`,field:`detected`}},events:{onMotionChanged:{data:fG,notOperatorFacing:"the `detected` state trigger phrases both edges, from the mirror that survives a dropped event (D49)"}},status:{schema:dG,kind:`push`},runtimeState:dG,durability:`session`,history:{fields:{detected:{kind:`boolean`,excludeDeviceTypes:[M.Camera]}}},customize:Iwe,vocabulary:{noun:L(`Motion`,`Movimento`),order:5130,state:[{kind:`boolean`,field:`detected`,label:L(`Motion`,`Movimento`),whenTrue:L(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:L(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}]}},mG=x({enabled:y(),lastChangedAt:r()}),hG=mG.extend({lastFetchedAt:r()}),gG={name:`motion-trigger`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Light,M.Siren,M.Switch],methods:{setMotionTrigger:D(x({deviceId:r().int().nonnegative(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`motionTrigger.on`,label:L(`Motion trigger on`,`Attivazione al movimento attiva`),phrase:L(`Let motion trigger {device}`,`Fai attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!0},args:{enabled:!0}},{id:`motionTrigger.off`,label:L(`Motion trigger off`,`Attivazione al movimento spenta`),phrase:L(`Stop motion triggering {device}`,`Non far più attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!1},args:{enabled:!1}}]})},events:{onMotionTriggerChanged:{data:x({deviceId:r(),enabled:y(),lastChangedAt:r()}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:mG,kind:`command-driven`},runtimeState:hG,durability:`session`,history:`none`,vocabulary:{noun:L(`Motion trigger`,`Attivazione al movimento`),order:1160,state:[{kind:`boolean`,field:`enabled`,label:L(`Motion trigger`,`Attivazione al movimento`),whenTrue:L(`When motion triggering is turned on for {device}`,`Quando si attiva l’attivazione al movimento di {device}`),whenFalse:L(`When motion triggering is turned off for {device}`,`Quando si disattiva l’attivazione al movimento di {device}`),icon:`activity`}]}},_G=x({id:r(),enabled:y(),shape:TV}),vG=x({enabled:y(),sensitivity:r().meta(A(`none`)),regions:C(_G),lastFetchedAt:r()}),yG=x({maxRegions:r(),supportedShapes:C(DV),grid:kV,sensitivity:x({min:r(),max:r(),step:r()})}),bG=x({enabled:y().optional(),sensitivity:r().optional(),regions:C(_G).optional()}),xG={name:`motion-zones`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/motion-zones-grid`,tab:`motion`,label:`Motion Zones`}},methods:{getOptions:D(x({deviceId:r()}),yG),setZone:D(x({deviceId:r(),patch:bG}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:vG,kind:`poll`},runtimeState:vG,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Motion zones`,`Zone di movimento`),order:3170}},Rwe=S([`external`,`embedded`]),zwe=S([`connected`,`disconnected`,`auth-failed`,`unreachable`,`tls-error`]),SG=x({id:u(),name:u(),url:u(),kind:Rwe,status:zwe,latencyMs:r().nullable(),error:u().optional(),connectedClients:r().int().nonnegative().optional(),lastCheckedAt:r().optional()}),CG=x({url:u(),username:u().optional(),password:u().optional(),clientIdPrefix:u().optional()}),wG=x({name:u().min(1),url:u().regex(/^(mqtt|mqtts|ws|wss):\/\//,`URL must start with mqtt(s):// or ws(s)://`),username:u().optional(),password:u().optional(),clientIdPrefix:u().optional()}),Bwe=x({id:u()}),TG=x({id:u()}),EG=x({port:r().int().min(1).max(65535).default(1883),allowAnonymous:y().default(!1),username:u().optional(),password:u().optional()}),Vwe=x({id:u(),url:u()}),DG=x({brokerCount:r(),embeddedRunning:y()}),OG={name:`mqtt-broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:DG,kind:`poll`},methods:{listBrokers:D(v(),C(SG)),getBrokerConfig:D(TG,CG,{auth:`admin`}),addBroker:D(wG,Bwe,{kind:`mutation`,auth:`admin`}),removeBroker:D(TG,v(),{kind:`mutation`,auth:`admin`}),startEmbeddedBroker:D(EG,Vwe,{kind:`mutation`,auth:`admin`}),stopEmbeddedBroker:D(TG,v(),{kind:`mutation`,auth:`admin`}),getStatus:D(v(),DG)},vocabulary:{notOperatorFacing:k.NETWORK}},kG=S([`person`,`vehicle`,`animal`,`face`,`package`,`other`]),AG=x({class:kG,timestamp:r(),confidence:r().min(0).max(1).optional()}),jG=x({lastByClass:f(kG,AG.nullable()),supportedClasses:C(kG).readonly(),enabled:y()}),MG=S([`boxed`,`while-streaming`,`flag-only`]),NG=x({supportedClasses:C(kG).readonly(),geometry:MG}),PG=x({enabled:y().optional()}),FG=jG.extend({lastFetchedAt:r()}),IG={name:`native-object-detection`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],methods:{getOptions:D(x({deviceId:r()}),NG),setSettings:D(x({deviceId:r(),settings:PG}),v(),{kind:`mutation`,auth:`admin`}),setEnabled:D(x({deviceId:r(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`nativeDetection.on`,label:L(`On-camera detection on`,`Rilevamento a bordo attivo`),phrase:L(`Turn on the on-camera detection of {device}`,`Attiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!0}},{id:`nativeDetection.off`,label:L(`On-camera detection off`,`Rilevamento a bordo spento`),phrase:L(`Turn off the on-camera detection of {device}`,`Disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!1}}]})},events:{onDetected:{data:x({deviceId:r(),detection:AG}),trigger:{category:T.DetectionCameraNative,label:L(`Camera spotted something`,`La telecamera ha rilevato qualcosa`),phrase:L(`When {device} spots something with its own detector`,`Quando {device} rileva qualcosa con il proprio rilevatore`),icon:`scan-eye`}}},status:{schema:jG,kind:`push`},runtimeState:FG,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`On-camera detection`,`Rilevamento a bordo`),order:3180,state:[{kind:`boolean`,field:`enabled`,label:L(`On-camera detection`,`Rilevamento a bordo`),whenTrue:L(`When the on-camera detection of {device} is turned on`,`Quando si attiva il rilevamento a bordo di {device}`),whenFalse:L(`When the on-camera detection of {device} is turned off`,`Quando si disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`}]}},LG=x({pan:r().min(-1).max(1).optional(),tilt:r().min(-1).max(1).optional(),speed:r().min(0).max(1).optional()}),RG=S([`goHome`,`locate`,`spotClean`,`findPet`,`personFollow`,`stop`,`startClean`,`pauseClean`,`dockWash`,`autoEmpty`,`flashOn`,`flashOff`]),zG=S([`action`,`sound`]),BG=x({id:u(),kind:zG,label:u(),icon:u(),soundId:r().int().optional(),enabled:y()}),Hwe=[{id:`startClean`,kind:`action`,label:`Start cleaning`,icon:`play`,enabled:!0},{id:`pauseClean`,kind:`action`,label:`Pause cleaning`,icon:`pause`,enabled:!0},{id:`stop`,kind:`action`,label:`Stop`,icon:`hand`,enabled:!0},{id:`goHome`,kind:`action`,label:`Return to dock`,icon:`home`,enabled:!0},{id:`locate`,kind:`action`,label:`Locate`,icon:`bell`,enabled:!0},{id:`spotClean`,kind:`action`,label:`Spot clean here`,icon:`crosshair`,enabled:!0},{id:`findPet`,kind:`action`,label:`Find pet`,icon:`paw-print`,enabled:!0},{id:`personFollow`,kind:`action`,label:`Follow me`,icon:`footprints`,enabled:!0},{id:`dockWash`,kind:`action`,label:`Wash mop`,icon:`droplets`,enabled:!0},{id:`autoEmpty`,kind:`action`,label:`Empty dustbin`,icon:`trash-2`,enabled:!0},{id:`flashOn`,kind:`action`,label:`Flash on`,icon:`flashlight`,enabled:!0},{id:`flashOff`,kind:`action`,label:`Flash off`,icon:`flashlight-off`,enabled:!0},{id:`sound:meow`,kind:`sound`,label:`Meow`,icon:`cat`,soundId:684,enabled:!0},{id:`sound:bark`,kind:`sound`,label:`Woof`,icon:`dog`,soundId:685,enabled:!0},{id:`sound:footsteps`,kind:`sound`,label:`Footsteps`,icon:`footprints`,soundId:686,enabled:!0},{id:`sound:purring`,kind:`sound`,label:`Purring`,icon:`cat`,soundId:687,enabled:!0},{id:`sound:tickTock`,kind:`sound`,label:`Tick-tock`,icon:`clock`,soundId:688,enabled:!0}],VG=x({x:r(),y:r()}),HG=x({move:y(),stop:y(),goToPoint:y(),runAction:y(),playSound:y(),light:y(),lightMode:y()}),UG=S([`auto`,`manual`]),WG=S([`idle`,`cleaning`,`spot`,`following`,`goto`,`returning`,`paused`,`unknown`]),GG=x({mode:WG,following:y(),flash:y(),lightMode:UG,lightLevel:r().min(40).max(100).meta(A(`none`)),lastChangedAt:r()}),KG=GG.extend({lastFetchedAt:r()}),qG={name:`navigation`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/navigation-panel`,tab:`navigation`,topTab:!0,label:`Navigation`,order:0}},methods:{move:D(LG.extend({deviceId:r()}),v(),{kind:`mutation`,notOperatorFacing:`joystick control from the live view — continuous, not a discrete step`}),stop:D(x({deviceId:r()}),v(),{kind:`mutation`,actions:[{id:`navigation.stop`,label:L(`Stop`,`Ferma`),phrase:L(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),goToPoint:D(VG.extend({deviceId:r()}),v(),{kind:`mutation`,notOperatorFacing:`tap-to-go on the live map — the point only means something on that picture`}),listActions:D(x({deviceId:r()}),C(BG)),runAction:D(x({deviceId:r(),actionId:RG}),v(),{kind:`mutation`,actions:[{id:`navigation.runAction`,label:L(`Run a routine`,`Esegui una routine`),phrase:L(`Have {device} {actionId}`,`Fai eseguire a {device}: {actionId}`),icon:`bot`,openArgs:[{key:`actionId`,label:L(`Routine`,`Routine`),offer:{kind:`enum`,values:[{value:`goHome`,label:L(`go home`,`torna alla base`)},{value:`locate`,label:L(`beep so you can find it`,`suona per farsi trovare`)},{value:`spotClean`,label:L(`clean this spot`,`pulisci questo punto`)},{value:`findPet`,label:L(`find the pet`,`cerca l’animale`)},{value:`personFollow`,label:L(`follow a person`,`segui una persona`)},{value:`stop`,label:L(`stop`,`fermati`)},{value:`startClean`,label:L(`start cleaning`,`inizia a pulire`)},{value:`pauseClean`,label:L(`pause cleaning`,`metti in pausa la pulizia`)},{value:`dockWash`,label:L(`wash the mop at the dock`,`lava il mocio alla base`)},{value:`autoEmpty`,label:L(`empty the bin at the dock`,`svuota il contenitore alla base`)},{value:`flashOn`,label:L(`turn the flash on`,`accendi il flash`)},{value:`flashOff`,label:L(`turn the flash off`,`spegni il flash`)}]}}]}]}),playSound:D(x({deviceId:r(),soundId:r().int()}),v(),{kind:`mutation`,actions:[{id:`navigation.playSound`,label:L(`Play sound`,`Riproduci un suono`),phrase:L(`Play {soundId} on {device}`,`Riproduci {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:L(`Sound`,`Suono`),offer:{kind:`dynamic`,from:`method`,method:`listActions`,valueKey:`soundId`,labelKey:`label`,where:{key:`kind`,equals:`sound`},valueKind:`number`}}]}]}),setLightOn:D(x({deviceId:r(),on:y()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightOn`,label:L(`Light on`,`Luce accesa`),phrase:L(`Turn on the light of {device}`,`Accendi la luce di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`navigation.lightOff`,label:L(`Light off`,`Luce spenta`),phrase:L(`Turn off the light of {device}`,`Spegni la luce di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setLightMode:D(x({deviceId:r(),mode:UG,level:r().min(40).max(100).optional()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightAuto`,label:L(`Light automatic`,`Luce automatica`),phrase:L(`Set the light of {device} to automatic`,`Metti la luce di {device} in automatico`),icon:`lightbulb`,args:{mode:`auto`}}]}),setLightLevel:D(x({deviceId:r(),level:r().min(40).max(100)}),v(),{kind:`mutation`,actions:[{id:`navigation.lightLevel`,label:L(`Set light level`,`Imposta la luce`),phrase:L(`Set the light of {device} to {level}`,`Imposta la luce di {device} al {level}`),icon:`sun-medium`,openArgs:[{key:`level`,label:L(`Level`,`Livello`),offer:{kind:`number`,min:40,max:100,step:1,unit:`%`}}]}]}),getFeatures:D(x({deviceId:r()}),HG)},events:{onStatusChanged:{data:x({deviceId:r(),status:GG}),notOperatorFacing:"the `mode` state trigger reads the same change"}},status:{schema:GG,kind:`push`},runtimeState:KG,durability:`session`,history:`none`,vocabulary:{noun:L(`Robot movement`,`Movimento del robot`),order:2080,state:[{kind:`enum`,field:`mode`,label:L(`Activity`,`Attività`),values:[{value:`idle`,label:L(`Idle`,`Inattivo`)},{value:`cleaning`,label:L(`Cleaning`,`In pulizia`)},{value:`spot`,label:L(`Spot cleaning`,`Pulizia localizzata`)},{value:`following`,label:L(`Following`,`In inseguimento`)},{value:`goto`,label:L(`Moving to a point`,`In movimento verso un punto`)},{value:`returning`,label:L(`Returning`,`In rientro`)},{value:`paused`,label:L(`Paused`,`In pausa`)},{value:`unknown`,label:L(`Unknown`,`Sconosciuto`)}],icon:`bot`}]}},JG=x({url:u(),hostname:u(),port:r(),protocol:S([`http`,`https`]),stable:y().optional()}),Uwe=x({url:u(),stable:y().optional(),updated:y().optional()}),YG=x({connected:y(),endpoint:JG.nullable(),error:u().optional()}),Wwe=JG.extend({id:u(),label:u(),mode:u().optional(),sourcePort:r().optional()}),XG={name:`network-access`,scope:`system`,mode:`collection`,providerKind:`ingress`,methods:{start:D(v(),JG,{kind:`mutation`}),stop:D(v(),v(),{kind:`mutation`}),getEndpoint:D(v(),JG.nullable()),getStatus:D(v(),YG),listEndpoints:D(v(),C(Wwe).readonly())},vocabulary:{notOperatorFacing:k.NETWORK}},ZG=[`wifi`,`ethernet`,`cellular`,`unknown`],QG=x({type:S(ZG),signal:r().min(0).max(100).nullable().meta(A(`percentage`)),rssi:r().optional().meta(A(`signal-level`)),ssid:u().optional(),speedKbps:r().nonnegative().nullable().optional().meta(A(`bitrate`)),linkUp:y().nullable().optional(),lastUpdated:r().meta(A(`none`))}),$G={type:`unknown`,signal:null,lastUpdated:0};function Gwe(e,t){return e===void 0||!Number.isFinite(e)||t<=0||e<0||e>t?null:Math.round(e/t*100)}function Kwe(e){return e===void 0||!Number.isFinite(e)||e>0?null:Math.round((Math.min(-50,Math.max(-100,e))+100)*2)}var eK={name:`network-link`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera,M.Sensor,M.Button,M.Switch,M.Light,M.Lock,M.Siren],methods:{},events:{onStatusChanged:{data:x({deviceId:r(),status:QG}),notOperatorFacing:`the signal / link-type state triggers each read one field of this change`}},status:{schema:QG,kind:`push`,empty:$G},runtimeState:QG,durability:`restored`,history:{fields:{signal:{kind:`gauge`,unit:`%`,deadband:3,minIntervalMs:6e4},rssi:{kind:`gauge`,unit:`dBm`,deadband:2,minIntervalMs:6e4}}},volatileStateFields:[`lastUpdated`],vocabulary:{noun:L(`Network link`,`Collegamento di rete`),order:5250,state:[{kind:`numeric`,field:`signal`,quantity:L(`the signal strength`,`l’intensità del segnale`),label:L(`Signal`,`Segnale`),unit:`%`,icon:`wifi`},{kind:`enum`,field:`type`,label:L(`Link type`,`Tipo di collegamento`),values:[{value:`wifi`,label:L(`Wi-Fi`,`Wi-Fi`)},{value:`ethernet`,label:L(`Ethernet`,`Ethernet`)},{value:`cellular`,label:L(`Cellular`,`Rete mobile`)},{value:`unknown`,label:L(`Unknown`,`Sconosciuto`)}],icon:`network`}]}},tK=x({nominalBitrateKbps:r(),observedBitrateKbps:r(),peakBitrateKbps:r(),packetLossPercent:r(),lastUpdated:r()}),nK=x({rttMs:r(),jitterMs:r(),estimatedBandwidthKbps:r(),packetLossPercent:r().min(0).max(100),downlinkMbps:r().optional(),downlinkAgeMs:r().optional(),lastUpdated:r()}),rK=x({deviceId:r(),streams:h(u(),tK),client:nK.optional()}),iK={name:`network-quality`,scope:`system`,mode:`singleton`,methods:{getDeviceStats:D(x({deviceId:r()}),rK.nullable()),getAllStats:D(v(),C(rK).readonly()),reportClientStats:D(x({deviceId:r(),rttMs:r().min(0).max(6e4),jitterMs:r().min(0).max(1e4),estimatedBandwidthKbps:r().min(0).max(1e6),packetLossPercent:r().min(0).max(100),downlinkMbps:r().min(0).max(1e5).optional(),downlinkAgeMs:r().min(0).max(864e5).optional()}),v(),{role:`viewer`,kind:`mutation`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:k.NETWORK}},aK=x({cn:u(),serial:u(),fingerprintSha256:u(),notBefore:r(),notAfter:r()}),oK=x({fingerprintSha256:u(),issuer:u(),sans:C(u()),notBefore:r(),notAfter:r()}),sK=a(`state`,[x({state:m(`served`),leaf:oK}),x({state:m(`not-issued`),reason:u()})]),cK={name:`node-certificates`,scope:`system`,mode:`singleton`,internal:!0,methods:{getCertificates:D(x({}),x({nodeId:u(),mesh:aK.nullable(),https:sK}),{auth:`admin`}),prepareMeshRenewal:D(x({}),x({csrPem:u()}),{kind:`mutation`,auth:`admin`}),installMeshLeaf:D(x({certPem:u().min(1),caCertPem:u().min(1),confirmWithinMs:r().int().min(1e4).max(6e5)}),x({fingerprintSha256:u(),serial:u()}),{kind:`mutation`,auth:`admin`}),confirmMeshLeaf:D(x({fingerprintSha256:u()}),x({confirmed:y()}),{kind:`mutation`,auth:`admin`}),rollbackMeshLeaf:D(x({}),x({rolledBack:y()}),{kind:`mutation`,auth:`admin`}),prepareHttpsCertificate:D(x({}),x({csrPem:u(),hostnames:C(u()),addresses:C(u()),pinnedCaFingerprintSha256:u().nullable()}),{kind:`mutation`,auth:`admin`}),forgetHub:D(x({}),x({ok:m(!0)}),{kind:`mutation`,auth:`admin`}),installHttpsCertificate:D(x({certPem:u().min(1),caCertPem:u().min(1),caRotation:y().optional()}),oK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.IDENTITY}},lK=x({nodeId:u().min(1),removedAt:r()}),uK=x({counts:h(u(),r().int().nonnegative())}),dK={name:`node-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onNodeRemoved:D(lK,uK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:k.INTERNAL}},fK=x({addonId:u(),capabilities:C(u()).readonly(),status:u()}),pK=x({pid:r(),name:u(),state:u(),cpuPercent:r(),memoryRss:r(),uptimeSeconds:r(),services:C(fK).readonly(),groupId:u().optional()}),qwe=x({id:u(),status:u(),cpuPercent:r(),memoryRss:r()}),Jwe=x({category:u(),total:r(),healthy:r(),addons:C(qwe).readonly()}),Ywe=x({name:u(),version:u()}),mK=x({id:u(),name:u(),hostname:u(),platform:u(),arch:u(),cpuModel:u().nullable(),cpuCores:r(),memoryMB:r(),engines:C(u()).readonly(),isHub:y(),isOnline:y(),cpuPercent:r(),memoryPercent:r().nullable(),uptime:r(),lastSeen:u(),localIps:C(u()).readonly(),addons:C(x({id:u(),capabilities:C(u()).readonly(),status:u()})).readonly(),processes:C(pK).readonly(),categories:C(Jwe).readonly(),rootPackage:Ywe.nullable(),meshTransport:S([`tls`,`clear`]).optional(),capabilitiesRegistered:y().optional()}),Xwe=x({callerAddonId:u(),providerAddonId:u(),capName:u(),callsPerMin:r(),lastCallAtMs:r()}),hK=x({nodeId:u(),name:u(),version:u(),status:u(),synced:y()}),gK=x({hubVersion:u(),nodes:C(hK)}),_K=x({nodeId:u(),addonId:u()}),Zwe=x({id:u(),status:u(),version:u().optional(),packageName:u().optional()}),vK=x({success:y()}),Qwe=x({success:y(),reason:u().optional()}),$we=x({restarted:C(u()).readonly(),failed:C(u()).readonly()}),eTe=x({nodeId:u(),name:u()}),yK=x({id:u(),name:u(),isHub:y(),isOnline:y()}),bK=x({nodes:C(yK).readonly(),complete:y()}),xK={name:`nodes`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{topology:D(v(),C(mK).readonly(),{auth:`admin`}),directory:D(v(),bK,{auth:`admin`}),deployAddon:D(_K,vK,{kind:`mutation`,auth:`admin`}),undeployAddon:D(_K,vK,{kind:`mutation`,auth:`admin`}),restartAddon:D(_K,vK,{kind:`mutation`,auth:`admin`}),restartProcess:D(x({nodeId:u(),processName:u()}),Qwe,{kind:`mutation`,auth:`admin`}),restartNode:D(x({nodeId:u()}),$we,{kind:`mutation`,auth:`admin`}),shutdownNode:D(x({nodeId:u()}),vK,{kind:`mutation`,auth:`admin`}),renameNode:D(x({nodeId:u(),name:u().min(1).max(64)}),eTe,{kind:`mutation`,auth:`admin`}),clusterAddonStatus:D(v(),h(u(),gK),{auth:`admin`}),getCapUsageGraph:D(x({windowSeconds:r().int().positive().max(300).default(60)}),C(Xwe).readonly(),{auth:`admin`}),getNodeAddons:D(x({nodeId:u()}),C(Zwe).readonly(),{auth:`admin`}),setProcessLogLevel:D(x({nodeId:u(),level:u()}),vK,{kind:`mutation`,auth:`admin`}),executeQuery:D(x({nodeId:u(),addonId:u(),queryName:u(),params:h(u(),w()).optional()}),w(),{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:k.CLUSTER}},SK=[{id:`speech`,name:`Speech`},{id:`scream`,name:`Scream / Shout`},{id:`crying`,name:`Crying / Baby`},{id:`laughter`,name:`Laughter`},{id:`music`,name:`Music`},{id:`dog`,name:`Dog`},{id:`cat`,name:`Cat`},{id:`bird`,name:`Bird`},{id:`animal`,name:`Animal (other)`},{id:`alarm`,name:`Alarm / Siren`},{id:`doorbell`,name:`Doorbell / Knock`},{id:`glass_breaking`,name:`Glass Breaking`},{id:`gunshot`,name:`Gunshot / Explosion`},{id:`vehicle`,name:`Vehicle`},{id:`siren`,name:`Emergency Siren`},{id:`fire`,name:`Fire / Smoke`},{id:`water`,name:`Water`},{id:`wind`,name:`Wind / Weather`},{id:`door`,name:`Door`},{id:`footsteps`,name:`Footsteps`},{id:`crowd`,name:`Crowd / Chatter`},{id:`telephone`,name:`Telephone`},{id:`engine`,name:`Engine / Motor`},{id:`tools`,name:`Tools / Construction`},{id:`silence`,name:`Silence`}],CK={mapping:{Speech:`speech`,"Child speech, kid speaking":`speech`,Conversation:`speech`,"Narration, monologue":`speech`,Babbling:`speech`,Whispering:`speech`,"Speech synthesizer":`speech`,Humming:`speech`,Rapping:`speech`,Singing:`speech`,Choir:`speech`,"Child singing":`speech`,Shout:`scream`,Bellow:`scream`,Yell:`scream`,Screaming:`scream`,"Children shouting":`scream`,Whoop:`scream`,"Crying, sobbing":`crying`,"Baby cry, infant cry":`crying`,Whimper:`crying`,"Wail, moan":`crying`,Groan:`crying`,Laughter:`laughter`,"Baby laughter":`laughter`,Giggle:`laughter`,Snicker:`laughter`,"Belly laugh":`laughter`,"Chuckle, chortle":`laughter`,Music:`music`,"Musical instrument":`music`,Guitar:`music`,Piano:`music`,Drum:`music`,"Drum kit":`music`,"Violin, fiddle":`music`,Flute:`music`,Saxophone:`music`,Trumpet:`music`,Synthesizer:`music`,"Pop music":`music`,"Rock music":`music`,"Hip hop music":`music`,"Classical music":`music`,Jazz:`music`,"Electronic music":`music`,"Background music":`music`,Dog:`dog`,Bark:`dog`,Yip:`dog`,Howl:`dog`,"Bow-wow":`dog`,Growling:`dog`,"Whimper (dog)":`dog`,Cat:`cat`,Purr:`cat`,Meow:`cat`,Hiss:`cat`,Caterwaul:`cat`,Bird:`bird`,"Bird vocalization, bird call, bird song":`bird`,"Chirp, tweet":`bird`,Squawk:`bird`,Crow:`bird`,Owl:`bird`,"Pigeon, dove":`bird`,Animal:`animal`,"Domestic animals, pets":`animal`,"Livestock, farm animals, working animals":`animal`,Horse:`animal`,"Cattle, bovinae":`animal`,Pig:`animal`,Sheep:`animal`,Goat:`animal`,Frog:`animal`,Insect:`animal`,Cricket:`animal`,Alarm:`alarm`,"Alarm clock":`alarm`,"Smoke detector, smoke alarm":`alarm`,"Fire alarm":`alarm`,Buzzer:`alarm`,"Civil defense siren":`alarm`,"Car alarm":`alarm`,Siren:`siren`,"Police car (siren)":`siren`,"Ambulance (siren)":`siren`,"Fire engine, fire truck (siren)":`siren`,"Emergency vehicle":`siren`,Foghorn:`siren`,Doorbell:`doorbell`,"Ding-dong":`doorbell`,Knock:`doorbell`,Tap:`doorbell`,Glass:`glass_breaking`,Shatter:`glass_breaking`,"Chink, clink":`glass_breaking`,"Gunshot, gunfire":`gunshot`,"Machine gun":`gunshot`,Explosion:`gunshot`,Fireworks:`gunshot`,Firecracker:`gunshot`,"Artillery fire":`gunshot`,"Cap gun":`gunshot`,Boom:`gunshot`,Vehicle:`vehicle`,Car:`vehicle`,Truck:`vehicle`,Bus:`vehicle`,Motorcycle:`vehicle`,"Car passing by":`vehicle`,"Vehicle horn, car horn, honking":`vehicle`,"Traffic noise, roadway noise":`vehicle`,Train:`vehicle`,Aircraft:`vehicle`,Helicopter:`vehicle`,Bicycle:`vehicle`,Skateboard:`vehicle`,Fire:`fire`,Crackle:`fire`,Water:`water`,Rain:`water`,Raindrop:`water`,"Rain on surface":`water`,Stream:`water`,Waterfall:`water`,Ocean:`water`,"Waves, surf":`water`,"Splash, splatter":`water`,Wind:`wind`,Thunderstorm:`wind`,Thunder:`wind`,"Wind noise (microphone)":`wind`,"Rustling leaves":`wind`,Door:`door`,"Sliding door":`door`,Slam:`door`,"Cupboard open or close":`door`,"Walk, footsteps":`footsteps`,Run:`footsteps`,Shuffle:`footsteps`,Crowd:`crowd`,Chatter:`crowd`,Cheering:`crowd`,Applause:`crowd`,"Children playing":`crowd`,"Hubbub, speech noise, speech babble":`crowd`,Telephone:`telephone`,"Telephone bell ringing":`telephone`,Ringtone:`telephone`,"Telephone dialing, DTMF":`telephone`,"Busy signal":`telephone`,Engine:`engine`,"Engine starting":`engine`,Idling:`engine`,"Accelerating, revving, vroom":`engine`,"Light engine (high frequency)":`engine`,"Medium engine (mid frequency)":`engine`,"Heavy engine (low frequency)":`engine`,"Lawn mower":`engine`,Chainsaw:`engine`,Hammer:`tools`,Jackhammer:`tools`,Sawing:`tools`,"Power tool":`tools`,Drill:`tools`,Sanding:`tools`,Silence:`silence`},preserveOriginal:!1},wK={mapping:{speech:`speech`,child_speech:`speech`,conversation:`speech`,whispering:`speech`,singing:`speech`,humming:`speech`,shout:`scream`,yell:`scream`,screaming:`scream`,crying:`crying`,baby_crying:`crying`,sobbing:`crying`,laughter:`laughter`,baby_laughter:`laughter`,giggling:`laughter`,music:`music`,guitar:`music`,piano:`music`,drums:`music`,dog_bark:`dog`,dog_bow_wow:`dog`,dog_growling:`dog`,dog_howl:`dog`,cat_meow:`cat`,cat_purr:`cat`,cat_hiss:`cat`,bird:`bird`,bird_chirp:`bird`,bird_squawk:`bird`,animal:`animal`,horse:`animal`,cow_moo:`animal`,insect:`animal`,alarm:`alarm`,smoke_alarm:`alarm`,fire_alarm:`alarm`,car_alarm:`alarm`,siren:`siren`,police_siren:`siren`,ambulance_siren:`siren`,doorbell:`doorbell`,door_knock:`doorbell`,knocking:`doorbell`,glass_breaking:`glass_breaking`,glass_shatter:`glass_breaking`,gunshot:`gunshot`,explosion:`gunshot`,fireworks:`gunshot`,car:`vehicle`,truck:`vehicle`,motorcycle:`vehicle`,car_horn:`vehicle`,vehicle_horn:`vehicle`,traffic:`vehicle`,fire:`fire`,fire_crackle:`fire`,water:`water`,rain:`water`,ocean:`water`,splash:`water`,wind:`wind`,thunder:`wind`,thunderstorm:`wind`,door:`door`,door_slam:`door`,sliding_door:`door`,footsteps:`footsteps`,walking:`footsteps`,running:`footsteps`,crowd:`crowd`,chatter:`crowd`,cheering:`crowd`,applause:`crowd`,telephone_ring:`telephone`,ringtone:`telephone`,engine:`engine`,engine_starting:`engine`,lawn_mower:`engine`,chainsaw:`engine`,hammer:`tools`,jackhammer:`tools`,drill:`tools`,power_tool:`tools`,silence:`silence`},preserveOriginal:!1},TK=new Map;for(let[e,t]of Object.entries(CK.mapping))TK.set(e.toLowerCase(),t);for(let[e,t]of Object.entries(wK.mapping))TK.set(e.toLowerCase(),t);function tTe(e){return TK.get(e.toLowerCase())??null}function nTe(){return SK.map(e=>e.id)}var EK=NN();function DK(e){return RN(EK.swatches,EK.fallbacks,e)}function rTe(e){let t=e[0];if(t===void 0)throw Error(`display palette has no fallback colour`);return t}var iTe=rTe(EK.fallbacks);function aTe(e){return e.split(/[-_ ]/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var OK=new Map;function kK(e,t,n,r){OK.set(e,{kind:e,parentKind:null,level:`macro`,category:t,color:DK(e),iconId:n,labelKey:`eventKind.${e}`,label:r})}function AK(e,t,n,r,i){OK.set(e,{kind:e,parentKind:t,level:`sub`,category:n,color:DK(e),iconId:r,labelKey:`eventKind.${e}`,label:i})}kK(`motion`,`motion`,`motion`,`Motion`),kK(`audio`,`audio`,`audio`,`Audio`),kK(`person`,`detection`,`person`,`Person`),kK(`vehicle`,`detection`,`vehicle`,`Vehicle`),kK(`animal`,`detection`,`animal`,`Animal`),kK(`package`,`package`,`package`,`Package`),kK(`sensor`,`sensor`,`sensor`,`Sensor`),kK(`control`,`control`,`control`,`Control`);for(let[e,t]of Object.entries(ug.mapping))t!==`vehicle`&&t!==`animal`||OK.has(e)||AK(e,t,`detection`,e,aTe(e));AK(`package-delivered`,`package`,`package`,`package`,`Package delivered`),AK(`package-picked-up`,`package`,`package`,`package`,`Package picked up`),AK(`contact`,`sensor`,`sensor`,`door`,`Contact`),AK(`motion-sensor`,`sensor`,`sensor`,`pir`,`Motion sensor`),AK(`smoke`,`sensor`,`sensor`,`smoke`,`Smoke`),AK(`flood`,`sensor`,`sensor`,`water`,`Water leak`),AK(`gas`,`sensor`,`sensor`,`gas`,`Gas`),AK(`carbon-monoxide`,`sensor`,`sensor`,`smoke`,`Carbon monoxide`),AK(`vibration`,`sensor`,`sensor`,`vibration`,`Vibration`),AK(`tamper`,`sensor`,`sensor`,`tamper`,`Tamper`),AK(`presence`,`sensor`,`sensor`,`presence`,`Presence`),AK(`enum-sensor`,`sensor`,`sensor`,`generic`,`Sensor state`),AK(`device-event`,`sensor`,`sensor`,`button`,`Device event`),AK(`lock`,`control`,`control`,`lock`,`Lock`),AK(`cover`,`control`,`control`,`door`,`Cover`),AK(`switch`,`control`,`control`,`switch`,`Switch`),AK(`siren`,`control`,`control`,`siren`,`Siren`),AK(`button`,`control`,`control`,`button`,`Button`),AK(`doorbell`,`control`,`control`,`doorbell`,`Doorbell`),AK(`appliance-cycle`,`control`,`control`,`switch`,`Appliance cycle`);for(let e of SK){let t=`audio-${e.id}`;OK.has(t)||AK(t,`audio`,`audio`,t,e.name)}var jK=Object.freeze(Object.fromEntries(OK));function MK(e){return jK[e]}function oTe(e){return DK(e)}function sTe(e){let t=[];for(let n of Object.values(jK))n.parentKind===e&&t.push(n);return t}var NK=x({kind:u(),label:u(),parentKind:u().nullable()}),PK=x({videoClasses:C(NK),audioKinds:C(NK),labels:C(NK)});function FK(e,t,n){return{kind:e,label:t,parentKind:n}}function IK(){let e=Object.values(jK);return{videoClasses:e.filter(e=>e.category===`detection`).map(e=>FK(e.kind,e.label,e.parentKind)),audioKinds:e.filter(e=>e.category===`audio`&&e.level===`sub`).map(e=>FK(e.kind,e.label,e.parentKind)),labels:e.filter(e=>e.category===`sensor`||e.category===`control`).map(e=>FK(e.kind,e.label,e.parentKind))}}var cTe=Object.freeze(IK()),LK=S([`immediate`,`track-end`,`device-event`,`package-event`,`system-event`]),RK=S(`device-online.device-offline.device-disabled.device-enabled.device-battery-low.device-battery-normal.device-consumable-low.device-consumable-normal.stream-online.stream-offline.node-online.node-offline.node-restarting.node-updating.node-inference-unavailable.detection-blind.motion-noisy.motion-calm.package-llm-silent.package-llm-answered.recording-stalled.recording-healthy.recording-degraded.device-attention-required.device-attention-resolved.device-command.storage-location-low.storage-location-critical.storage-location-ok.storage-drain-progress.storage-drain-complete.addon-crash-loop.addon-update-available.server-update-available.wrapper-update-available.alarm-triggered.alarm-armed.alarm-disarmed.alarm-arming.alarm-arm-refused.alarm-pending.alarm-rearmed.alarm-sensor-bypass.alarm-check-failed.addon-updated.server-updated.export-completed.backup-completed.alert-critical.alert-error.alert-critical-resolved.rule-broken.rule-repaired.camera-online.camera-offline.camera-disabled.camera-enabled`.split(`.`)),zK=[`camera-online`,`camera-offline`,`camera-disabled`,`camera-enabled`],lTe=new Set(zK),uTe=RK.options.filter(e=>!lTe.has(e)),BK=[`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`],VK=[`device-battery-low`,`device-battery-normal`,`device-consumable-low`,`device-consumable-normal`],HK=[`device-consumable-low`,`device-consumable-normal`],UK=[`confirmed`,`already`,`unconfirmed`,`failed`],WK=[`user`,`addon`,`action`,`scheduler`,`composition`,`node`],GK=x({kinds:C(RK).min(1),deviceIds:C(r().int()).min(1).optional(),deviceTypes:C(u().min(1)).min(1).optional(),excludeDeviceIds:C(r().int()).min(1).optional(),nodeIds:C(u().min(1)).min(1).optional(),packageNames:C(u().min(1)).min(1).optional(),commandActions:C(u().min(1)).min(1).optional(),commandOutcomes:C(S(UK)).min(1).optional(),commandActorKinds:C(S(WK)).min(1).optional(),consumableLowPercent:r().int().min(1).max(95).optional()});function dTe(e){return e.consumableLowPercent??15}var KK=1440,fTe=[10,30,60],qK=x({days:C(r().int().min(0).max(6)).min(1),startMinute:r().int().min(0).max(1439),endMinute:r().int().min(0).max(1439)}),JK=x({windows:C(qK).min(1),timezone:u().optional(),invert:y().optional()}),YK=S([`instant`,`summary`]),pTe=S([`activation`,`deactivation`,`schedule`]),XK=S([`rule`,`section`]),ZK=a(`mode`,[x({mode:m(`instant`)}),x({mode:m(`summary`),schedule:JK,split:XK.optional()}),x({mode:m(`modes`),onActivation:y(),onDeactivation:y(),onSchedule:x({schedule:JK,grouping:XK}).optional()})]),QK=x({values:C(u().min(1)),maxDistance:r().int().min(0).max(3).default(1)}),$K=x({zoneId:u().optional(),className:u().optional(),op:S([`became-occupied`,`became-free`,`>=`,`<=`]).default(`became-occupied`),count:r().int().min(0).default(1),sustainSeconds:r().int().min(0).max(3600).default(15)}),eq=x({labels:C(u().min(1)).min(1).optional(),dbThreshold:r().min(-96).max(0).optional(),hitPercent:r().int().min(1).max(100).default(60),samplingSeconds:r().int().min(1).max(300).default(10),confirmHits:r().int().min(1).max(20).optional(),confirmWindowSec:r().int().min(1).max(60).optional()}),tq=S([`enter`,`exit`,`any`]),nq=S([`raised`,`cleared`]),rq=x({ids:C(u().min(1)).min(1),match:S([`any`,`all`]).optional()}),iq=u().min(1),aq=C(iq).max(4),oq=x({id:u().min(1).max(64),label:u().min(1).max(40),actionId:iq,icon:Ai.optional(),destructive:y().optional()}),sq=x({onActivation:aq.optional(),onDeactivation:aq.optional(),onTrigger:aq.optional(),onTriggerOff:aq.optional(),buttons:C(oq).max(8).optional()}),cq=x({deviceId:r().int(),states:C(u().min(1)).min(1)}),lq=x({sceneId:u().min(1),deviceId:r().int().optional(),requiredState:S([`matched`,`diverged`]),latched:y().optional()}),uq=x({deviceState:cq.optional(),scene:lq.optional(),devices:C(r()).optional(),devicesExclude:C(r()).min(1).optional(),classes:C(u().min(1)).optional(),classesExclude:C(u().min(1)).optional(),minConfidence:r().min(0).max(1).optional(),zones:rq.optional(),zonesExclude:C(u().min(1)).optional(),crossing:tq.optional(),labelEquals:C(u().min(1)).optional(),identities:C(u().min(1)).optional(),plates:QK.optional(),identitiesExclude:C(u().min(1)).optional(),minImportance:r().min(0).max(1).optional(),minDwellSeconds:r().min(0).optional(),source:S([`pipeline`,`onboard`,`sensor`,`audio`,`any`]).optional(),minLabelConfidence:r().min(0).max(1).optional(),eventTypeTokens:C(u().min(1)).optional(),sensorKinds:C(u().min(1)).optional(),sensorTransition:nq.optional(),packagePhase:S([`delivered`,`picked-up`,`both`]).optional(),systemEvent:GK.optional(),customZones:C(wV).optional(),occupancy:$K.optional(),audio:eq.optional()}),dq=x({targetId:u().min(1),params:h(u(),w()).optional()}),fq=S([`none`,`image`,`clip`,`gif`]),pq=x({template:x({title:u().max(500).optional(),body:u().max(2e3).optional()}).optional(),schedule:JK.optional(),priority:r().int().min(1).max(5).optional(),attachment:fq.optional(),actions:y().optional()}),mq=h(u(),pq),hq=S([`scene-boxes`,`crop`,`clean`,`none`]),gq=S([`cropped`,`full`,`boxed`]),_q=S([`mosaic`,`each`]),vq=x({image:hq.optional(),showTriggerZone:y().optional(),showSubjectPath:y().optional(),attach:S([`best`,`best-matching`,`keyFrame`,`none`]).optional(),frame:gq.optional(),zoneCrop:y().optional(),gif:y().optional(),clip:y().optional(),clipPreRollSec:r().int().min(0).max(30).optional(),clipPostRollSec:r().int().min(0).max(30).optional(),clipSpeed:r().min(1).max(8).optional(),profile:j.optional(),linkedCameras:_q.optional(),wakeSleepingCamera:y().optional()}),yq=S([`shared`,`per-class`]),bq=x({cooldownSec:r().int().min(0).max(86400).default(60),scope:S([`rule`,`rule-device`]).default(`rule-device`),granularity:yq.optional()}),xq=1e3,Sq=2e4,Cq=8e3,wq=x({op:S([`>=`,`>`,`<=`,`<`,`==`]),count:r().int().min(0).max(1e3)}),Tq=x({enabled:y().default(!1),profileId:u().optional(),prompt:u().max(1e3).optional(),expect:wq.optional(),timeoutMs:r().int().min(xq).max(Sq).default(Cq),onTimeout:S([`fire`,`suppress`]).default(`fire`),maxImagePx:r().int().min(64).max(2048).default(448)}),Eq=x({name:u().min(1).max(200),enabled:y().default(!0),delivery:LK,conditions:uq.default({}),schedule:JK.optional(),systemEventDelivery:ZK.optional(),targets:C(dq),targetUsers:C(u()).optional(),targetOverrides:mq.optional(),media:vq.default({}),throttle:bq.default({cooldownSec:60,scope:`rule-device`}),template:x({title:u().max(500).optional(),body:u().max(2e3).optional()}).optional(),priority:r().int().min(1).max(5).default(3),ownerUserId:u().optional(),snoozeAllowGlobal:y().optional(),snoozeOptions:C(r().int().min(1).max(KK)).max(4).optional(),actions:sq.optional(),confirm:Tq.optional(),groupingSec:r().int().min(5).max(60).optional(),groupWithinSec:r().int().min(0).max(300).optional(),askVerdict:y().optional(),tags:Td.optional()}),Dq=S([`event`,`summary`,`timelapse`,`calendar-events`]),Oq=x({kind:Dq,ruleId:u(),tags:C(u())}),kq=Eq.partial().extend({disabledTargetIds:C(u()).optional(),enabled:y().optional(),conditions:uq.optional(),media:vq.optional(),throttle:bq.optional(),priority:r().int().min(1).max(5).optional()}),Aq=[`waitForEnhancement`,`groupIdleSec`];function mTe(e){return Aq.some(t=>t===e)}var jq=[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`actions`,`confirm`,`groupingSec`,`waitForEnhancement`,`groupIdleSec`],Mq=S(jq),Nq=x({ruleId:u(),patch:kq,clear:C(Mq).optional()}),Pq=Eq.extend({id:u(),createdBy:u(),createdAt:r(),updatedAt:r(),disabledTargetIds:C(u()).default([])}),Fq=[`device-state`,`streams`,`battery`,`consumables`,`detection-blind`,`nodes`,`addons`,`addon-updates`,`updates`],Iq=S(Fq),Lq=x({id:Iq,status:S([`read`,`unavailable`]),items:r().int().nonnegative(),reason:u().optional()}),Rq=x({section:Iq.optional(),title:u(),text:u(),count:r().int().nonnegative()}),zq=x({empty:y(),count:r().int().nonnegative(),text:u(),sections:C(Lq),dropped:h(u(),r().int().nonnegative()),excludedGroups:C(u()),split:XK.optional(),rows:C(Rq).optional()}),Bq=x({recordId:u(),recordKind:S([`object-event`,`track`,`device-event`,`package-event`,`system-event`]),deviceId:r(),timestamp:r(),wouldFire:y(),failedCondition:u().optional(),className:u().optional(),label:u().optional()}),Vq=S([`detection`,`sensor`,`occupancy`,`sound`,`device-events`,`system`,`alarm`,`mixed`]),Hq=S([`detection`,`sensor`,`occupancy`,`sound`,`system`]),Uq=x({id:S([`appliance-cycle`]),kind:Vq,title:u(),body:u()}),Wq=S([`rule`,`timelapse`,`summary`]),Gq=S([`title`,`body`,`previewText`,`captionText`]),Kq=S([`subject`,`place`,`time`,`rule`,`occupancy`,`sound`,`sensor`,`system`,`digest`,`ai`]),qq=x({name:u().regex(/^\w+$/),label:u(),description:u().optional(),example:u(),group:Kq,families:C(Wq).min(1),fields:C(Gq).optional(),kinds:C(Hq).optional(),deliveries:C(LK).optional(),systemEventKinds:C(RK).optional(),systemEventDeliveries:C(YK).optional(),dynamic:x({prefix:m(`count_`),from:m(`classes`)}).optional()}),Jq=x({family:Wq,field:Gq,kind:Vq.optional(),delivery:LK.optional(),systemEventKinds:C(RK).optional(),systemEventDelivery:YK.optional()}),Yq=x({context:Jq,template:x({title:u().max(500).optional(),body:u().max(2e3).optional()})}),Xq=x({title:u().nullable(),body:u().nullable(),unknown:C(u())}),Zq=x({id:u(),group:S([`scope`,`class`,`zones`,`quality`,`label`,`schedule`,`device`,`package`,`occupancy`,`audio`,`system`]),label:u(),valueType:S([`deviceIdList`,`deviceIdExcludeList`,`stringList`,`number01`,`number`,`sourceSelect`,`zoneSelection`,`zoneIdList`,`schedule`,`plateMatcher`,`packagePhase`,`crossingSelect`,`sensorTransition`,`polygonDraw`,`occupancy`,`audio`,`deviceState`,`scene`,`systemEvent`]),operator:S([`in`,`notIn`,`anyOf`,`allOf`,`gte`,`fuzzyIn`,`withinSchedule`]),appliesTo:C(LK),phase:u(),description:u().optional(),options:C(x({value:u(),label:u(),hint:u().optional()})).readonly().optional()}),Qq=[{id:`systemEvent`,group:`system`,label:`System event`,valueType:`systemEvent`,options:[{value:`device-online`,label:`Device online`},{value:`device-offline`,label:`Device offline`},{value:`device-disabled`,label:`Device switched off`},{value:`device-enabled`,label:`Device switched on`},{value:`stream-online`,label:`Stream online`},{value:`stream-offline`,label:`Stream offline`},{value:`node-online`,label:`Node online`},{value:`node-offline`,label:`Node offline`},{value:`node-restarting`,label:`Node restarting`},{value:`node-updating`,label:`Node updating (restart imminent)`},{value:`node-inference-unavailable`,label:`Node has no usable inference device`},{value:`detection-blind`,label:`Camera detecting nothing`},{value:`motion-noisy`,label:`Camera motion constant, no subject`},{value:`motion-calm`,label:`Camera motion calm again`},{value:`package-llm-silent`,label:`Package confirm not answering`},{value:`package-llm-answered`,label:`Package confirm answering again`},{value:`recording-stalled`,label:`Recording stalled`},{value:`recording-healthy`,label:`Recording healthy again`},{value:`recording-degraded`,label:`Recording degraded (restart storm)`},{value:`device-attention-required`,label:`Device needs attention`},{value:`device-attention-resolved`,label:`Device attention resolved`},{value:`device-command`,label:`Command given to a device`},{value:`storage-location-low`,label:`Storage location low`},{value:`storage-location-critical`,label:`Storage location critical`},{value:`storage-location-ok`,label:`Storage location ok again`},{value:`storage-drain-progress`,label:`Storage drain progress`},{value:`storage-drain-complete`,label:`Storage drain complete`},{value:`addon-crash-loop`,label:`Addon stopped after repeated crashes`},{value:`addon-update-available`,label:`Addon update available`},{value:`server-update-available`,label:`Server update available`},{value:`wrapper-update-available`,label:`Container / app update available`},{value:`addon-updated`,label:`Addons updated`},{value:`server-updated`,label:`Server updated`},{value:`device-battery-low`,label:`Battery low`},{value:`device-battery-normal`,label:`Battery back to normal`},{value:`device-consumable-low`,label:`Consumable low`},{value:`device-consumable-normal`,label:`Consumable replaced`},{value:`export-completed`,label:`Export completed`},{value:`backup-completed`,label:`Backup completed`},{value:`alert-critical`,label:`Critical alert raised`},{value:`alert-error`,label:`Error alert raised`},{value:`alert-critical-resolved`,label:`Critical alert resolved`},{value:`rule-broken`,label:`Notification rule broken`},{value:`rule-repaired`,label:`Notification rule repaired`},{value:`alarm-arm-refused`,label:`Alarm arm refused`},{value:`alarm-check-failed`,label:`Alarm check failed (armed anyway)`},{value:`alarm-arming`,label:`Alarm arming (exit delay)`},{value:`alarm-armed`,label:`Alarm armed`},{value:`alarm-pending`,label:`Alarm entry delay started`},{value:`alarm-triggered`,label:`Alarm triggered`},{value:`alarm-rearmed`,label:`Alarm re-armed after siren`},{value:`alarm-sensor-bypass`,label:`Alarm sensor bypass`},{value:`alarm-disarmed`,label:`Alarm disarmed`}],operator:`in`,appliesTo:[`system-event`],phase:`P1`,description:`Infrastructure and update events. Device liveness covers EVERY device type — narrow it by device type (cameras only, say) and/or by device, node events by node id, and addon updates by package name.`},{id:`devices`,group:`scope`,label:`Devices`,valueType:`deviceIdList`,operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P1`,description:`Restrict the rule to these devices; absent = all devices. A sensor event matches either the SENSOR that fired or the camera it is attributed to, so a rule may name either one.`},{id:`devicesExclude`,group:`scope`,label:`Excluded devices`,valueType:`deviceIdExcludeList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P1`,description:`Every device except these. Judged on the same device ids as Devices: a sensor event is excluded by the SENSOR that fired or by the camera it is attributed to.`},{id:`classes`,group:`class`,label:`Object classes`,valueType:`stringList`,operator:`in`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`,description:`Any overlap with the detection class set passes.`},{id:`classesExclude`,group:`class`,label:`Excluded classes`,valueType:`stringList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`},{id:`minConfidence`,group:`quality`,label:`Minimum confidence`,valueType:`number01`,operator:`gte`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`},{id:`zones`,group:`zones`,label:`Zones`,valueType:`zoneSelection`,operator:`anyOf`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`,description:`The zones the subject must be in (included) or never in (excluded).`},{id:`zonesExclude`,group:`zones`,label:`Excluded zones`,valueType:`zoneIdList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`},{id:`crossing`,group:`zones`,label:`Zone crossing`,valueType:`crossingSelect`,options:[{value:``,label:`Entering`,hint:`Entries and ordinary movement; never an exit.`},{value:`exit`,label:`Leaving`,hint:`Only an exit from a zone.`},{value:`any`,label:`Entering or leaving`,hint:`Entries, exits and ordinary movement.`}],operator:`in`,appliesTo:[`immediate`],phase:`P1`,description:`Which way the subject crosses the zone.`},{id:`labelEquals`,group:`label`,label:`Label equals`,valueType:`stringList`,operator:`in`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Exact match on the collapsed label (identity / plate / subclass).`},{id:`identities`,group:`label`,label:`Known faces`,valueType:`stringList`,operator:`in`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Only recognised people. Selecting NOBODY means every identity in the face gallery; selecting some narrows to those. Matched on the gallery id, so renaming a person does not break the rule. On Immediate delivery the name must already be known when an event is written — choose Immediate, grouped to wait for it.`},{id:`plates`,group:`label`,label:`Known plates`,valueType:`plateMatcher`,operator:`fuzzyIn`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Only vehicles whose plate was read. Selecting NO plate means any readable plate; listed plates are matched Levenshtein-tolerantly, because OCR noise makes an exact match useless.`},{id:`identitiesExclude`,group:`label`,label:`Excluded faces`,valueType:`stringList`,operator:`notIn`,appliesTo:[`immediate`,`track-end`],phase:`P1`,description:`Veto by identity (mirror of Known faces, same gallery ids). A subject nobody recognised passes — there is nothing to exclude.`},{id:`minLabelConfidence`,group:`label`,label:`Minimum label confidence`,valueType:`number01`,operator:`gte`,appliesTo:[`track-end`],phase:`P1`,description:`Best identity/plate recognition match confidence [0,1] for the label the track carries at close (peak assigned-identity cosine / peak plate OCR score; the higher of the two when both were read). Distinct from detection confidence. Fails closed for a track that ended un-recognized.`},{id:`minImportance`,group:`quality`,label:`Minimum importance`,valueType:`number01`,operator:`gte`,appliesTo:[`track-end`],phase:`P1`,description:`Server-computed key-event importance [0,1]; track-end rules only (importance is scored at close). Fails when the record has none.`},{id:`minDwellSeconds`,group:`quality`,label:`Minimum dwell (seconds)`,valueType:`number`,operator:`gte`,appliesTo:[`track-end`],phase:`P1`,description:`Track lifespan in seconds (lastSeen − firstSeen); track-end rules only.`},{id:`source`,group:`scope`,label:`Detection source`,valueType:`sourceSelect`,options:[{value:`any`,label:`Any source`},{value:`pipeline`,label:`Pipeline`},{value:`onboard`,label:`Onboard (camera)`},{value:`sensor`,label:`Sensor`},{value:`audio`,label:`Audio marker`}],operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P1`,description:`pipeline / onboard / sensor / audio; a record with no stamped source counts as pipeline.`},{id:`deviceState`,group:`scope`,label:`Device state`,valueType:`deviceState`,operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P2`,description:`Only fire while another device is in one of the chosen states — the alarm armed, a switch on, a contact closed. A state that cannot be read does NOT fire.`},{id:`scene`,group:`scope`,label:`Scene state`,valueType:`scene`,operator:`in`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`],phase:`P3`,description:`Only fire while a scene is matched or diverged.`},{id:`sensorKinds`,group:`device`,label:`Sensor kinds`,valueType:`stringList`,operator:`in`,appliesTo:[`device-event`],phase:`P1`,description:`Sensor/control taxonomy kinds (doorbell / contact / button / …) matched against the persisted device event.`},{id:`eventTypeTokens`,group:`device`,label:`Event-type tokens`,valueType:`stringList`,operator:`in`,appliesTo:[`device-event`],phase:`P1`,description:`Raw device event-type tokens (e.g. doorbell press / press_long) from the event-emitter slice; absent on doorbell-pulse / passive sensors.`},{id:`sensorTransition`,group:`device`,label:`Notify when`,valueType:`sensorTransition`,options:[{value:``,label:`When it starts and when it finishes`,hint:`Every change: the alert itself, and the return to normal.`},{value:`raised`,label:`Only when it starts`,hint:`Water detected, smoke, a contact opening — never the return to normal.`},{value:`cleared`,label:`Only when it finishes`,hint:`Back to dry, smoke gone, a contact closing — never the alert itself.`}],operator:`in`,appliesTo:[`device-event`],phase:`P2`,description:`Fire on one edge of a boolean sensor. Offered only when every chosen sensor kind raises and clears; a reading that cannot be placed still notifies.`},{id:`packagePhase`,group:`package`,label:`Package phase`,valueType:`packagePhase`,options:[{value:`delivered`,label:`Delivered`},{value:`picked-up`,label:`Picked up`},{value:`both`,label:`Both`}],operator:`in`,appliesTo:[`package-event`],phase:`P1`,description:`Delivered / picked-up / both.`},{id:`occupancy`,group:`occupancy`,label:`Occupancy`,valueType:`occupancy`,operator:`anyOf`,appliesTo:[`device-event`],phase:`P1`,description:`ZoneAnalytics occupancy edge (optionally zone/class-scoped): count crosses the threshold and holds for sustainSeconds. Fail-closed on a missing snapshot.`},{id:`audio`,group:`audio`,label:`Sound`,valueType:`audio`,operator:`anyOf`,appliesTo:[`immediate`],phase:`P2`,description:`Fires when at least hitPercent% of the samples in a samplingSeconds window are hits — a hit clears the dBFS floor AND carries one of the chosen sounds. Both filters are optional and independent, but naming NEITHER never matches: every sample would be a hit, so the engine refuses rather than notifying on silence. dBFS is negative-going (0 = full scale, -96 = silence).`},{id:`customZones`,group:`zones`,label:`Custom zones`,valueType:`polygonDraw`,operator:`anyOf`,appliesTo:[`immediate`,`track-end`,`package-event`],phase:`P1`,description:`User-drawn polygons; a detection whose bbox overlaps any polygon matches.`},{id:`schedule`,group:`schedule`,label:`Schedule`,valueType:`schedule`,operator:`withinSchedule`,appliesTo:[`immediate`,`track-end`,`device-event`,`package-event`,`system-event`],phase:`P1`,description:`Weekly activation windows (invertible); absent = always active.`}],$q=S([`pending`,`sent`,`dead`]),eJ=S([`object-event`,`track-end`,`device-event`,`package-event`,`system-event`]),tJ=x({className:u(),label:u().optional(),confidence:r().optional(),zones:C(u()),timestamp:r(),systemEvent:x({kind:RK,subject:u(),title:u(),body:u(),data:h(u(),w())}).optional()}),nJ=x({id:u(),ruleId:u(),ruleName:u(),delivery:LK,targetId:u(),deviceId:r(),recordKind:eJ,recordId:u(),trackId:u().optional(),status:$q,attempts:r().int(),createdAt:r(),updatedAt:r(),error:u().optional(),subject:tJ,title:u().optional(),body:u().optional(),artifactIds:C(u().min(1)).optional(),groupedInto:u().min(1).optional()}),rJ=x({ruleId:u().optional(),deviceId:r().optional(),status:$q.optional(),since:r().optional(),until:r().optional(),limit:r().int().min(1).max(500).default(100)}),iJ=x({ruleId:u(),lastAt:r(),status:$q,deviceId:r()}),aJ=x({runs:C(iJ),horizonMs:r().nonnegative().nullable()}),oJ=S([`rule`,`device`,`all`]),sJ=x({scope:oJ,ruleId:u().optional(),deviceId:r().int().optional(),classes:C(u().min(1)).min(1).optional(),durationMinutes:r().int().min(1).max(KK),global:y().optional(),summary:y().optional()}),cJ=x({id:u(),userId:u(),scope:oJ,ruleId:u().optional(),deviceId:r().int().optional(),classes:C(u().min(1)).min(1).optional(),startedAt:r(),expiresAt:r(),global:y(),summary:y(),digestSentAt:r().optional()}),hTe=x({snoozeId:u(),targetId:u(),ruleId:u(),ruleName:u(),deviceId:r().int(),count:r().int(),firstAt:r(),lastAt:r()}),lJ=3600,uJ=r().int().min(0).max(600),dJ=r().int().min(0).max(lJ),fJ=e=>new Set(e.map(e=>e.mode)).size===e.length,pJ=S([`rearmAfter`,`disableAfter`,`doNothing`]),mJ=x({mode:vy,exitDelaySec:uJ.optional(),entryDelaySec:uJ.optional(),triggeredDurationSec:dJ.optional(),postTriggeredAction:pJ.optional(),schedule:JK.optional(),notifyDuringEntryDelay:y().optional(),notifySensorRewatched:y().optional(),notifySensorIgnored:y().optional()}),gTe=C(mJ).max(8).refine(fJ,{message:`modeDelays: at most one entry per arm mode`}),hJ=x({mode:vy,exitDelaySec:uJ.nullable().optional(),entryDelaySec:uJ.nullable().optional(),triggeredDurationSec:dJ.nullable().optional(),postTriggeredAction:pJ.nullable().optional(),schedule:JK.nullable().optional(),notifyDuringEntryDelay:y().nullable().optional(),notifySensorRewatched:y().nullable().optional(),notifySensorIgnored:y().nullable().optional()}),_Te=C(hJ).max(8).refine(fJ,{message:`modeDelays: at most one edit per arm mode`}),gJ=x({mode:vy,deviceId:r().int().positive(),nonBlocking:y()}),_J=x({mode:vy,deviceId:r().int().positive(),blocking:y()}),vJ=x({mode:vy,deviceId:r().int().positive(),secureOnArm:y()}),yJ=x({mode:vy,deviceIds:C(r().int()).max(200)}),bJ=yJ,xJ=yJ,SJ=yJ,CJ=C(bJ).max(8).refine(fJ,{message:`nonBlocking: at most one list per arm mode`}),wJ=C(xJ).max(8).refine(fJ,{message:`blocking: at most one list per arm mode`}),TJ=C(SJ).max(8).refine(fJ,{message:`secureOnArmOff: at most one list per arm mode`}),EJ=x({exitDelaySec:uJ,entryDelaySec:uJ,triggeredDurationSec:dJ,postTriggeredAction:pJ.optional(),announceArm:y().optional(),announceTargets:C(u().min(1)).max(16),nonBlocking:CJ.default([]),blocking:wJ.default([]),secureOnArmOff:TJ.default([]),modeDelays:gTe.default([])}),DJ=x({id:u().min(1).max(64),name:u().min(1).max(64),isDefault:y()}),OJ=x({activeId:u().min(1),items:C(DJ).min(1)}),kJ=x({name:u().min(1).max(64),cloneFromId:u().min(1).max(64).optional()}),AJ=x({id:u().min(1).max(64),name:u().min(1).max(64)}),jJ=x({id:u().min(1).max(64)}),MJ=EJ.extend({nonBlocking:CJ,blocking:wJ,secureOnArmOff:TJ,modeDelays:_Te,nonBlockingEdit:gJ,blockingEdit:_J,secureOnArmEdit:vJ}).partial().refine(e=>e.nonBlocking===void 0||e.nonBlockingEdit===void 0,{message:`nonBlocking and nonBlockingEdit are exclusive — send the whole lists or one edit`}).refine(e=>e.blocking===void 0||e.blockingEdit===void 0,{message:`blocking and blockingEdit are exclusive — send the whole lists or one edit`}).refine(e=>e.secureOnArmOff===void 0||e.secureOnArmEdit===void 0,{message:`secureOnArmOff and secureOnArmEdit are exclusive — send the whole lists or one edit`}),NJ=S([`muted`,`detection-off`,`offline`]),PJ=x({deviceId:r().int(),reason:NJ}),FJ=x({mode:vy,ruleCount:r().int().min(0),allDevices:y(),deviceIds:C(r().int()),allDevicesExcept:C(r().int()).default([]),skippedDevices:C(PJ).default([])}),vTe=x({deviceId:r().int(),name:u(),state:u(),blocking:y()}),yTe=x({deviceId:r().int(),name:u(),phase:S([`open`,`closed`])}),bTe=x({mode:vy,devices:C(vTe),unknown:C(r().int())}),xTe=x({ruleId:u(),ruleName:u(),deviceId:r().int(),name:u(),since:r(),dropped:r().int().min(0)}),STe=x({state:_y,targetMode:vy.nullable(),availableModes:C(vy),openings:C(bTe),exclusions:C(yTe),bypassedInputs:C(xTe).default([])}),IJ=x({deviceId:r().int().nullable(),settings:EJ,profiles:OJ.optional(),coverage:C(FJ),live:STe.optional()}),LJ=S([`open`,`closed`,`unknown`,`not-opening`]),RJ=x({deviceId:r().int().positive(),reading:LJ,state:u().nullable(),unknownWhy:S([`read-failed`,`unknown-word`]).nullable(),online:y().nullable(),controllable:y().default(!1)}),zJ=x({deviceIds:C(r().int().positive()).max(500)}),BJ=x({sensors:C(RJ),readAt:r().int().nonnegative()}),VJ=x({deviceId:r().int().nonnegative().optional(),seconds:r().min(0).max(60),profile:j.optional(),ruleId:u(),ruleName:u(),reason:S([`window`,`occupancy`])}),HJ=x({rulesLoaded:y(),asks:C(VJ).readonly()}),UJ={name:`notification-rules`,scope:`system`,mode:`singleton`,methods:{listRules:D(x({}),x({rules:C(Pq)}),{auth:`admin`}),getRule:D(x({ruleId:u()}),x({rule:Pq.nullable()}),{auth:`admin`}),createRule:D(x({rule:Eq}),x({rule:Pq}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateRule:D(Nq,x({rule:Pq}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteRule:D(x({ruleId:u()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setRuleEnabled:D(x({ruleId:u(),enabled:y()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),listRuleTags:D(x({}),x({rules:C(Oq)}),{kind:`query`,auth:`admin`}),setRuleTags:D(x({kind:Dq,ruleId:u(),tags:Td}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getClipRetentionAsks:D(x({}),HJ,{auth:`admin`}),listDeviceMutes:D(x({}),x({mutedDeviceIds:C(r().int()).readonly()}),{auth:`admin`}),setDeviceMuted:D(x({deviceId:r().int(),muted:y()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),testRule:D(x({rule:Eq,lookbackMinutes:r().int().min(1).max(1440).default(60)}),x({results:C(Bq)}),{kind:`mutation`,auth:`admin`}),previewStateSummary:D(x({rule:Eq}),zq,{kind:`mutation`,auth:`admin`,access:`view`}),getConditionCatalog:D(x({}),x({catalog:C(Zq),taxonomy:PK.optional()})),getTemplateCatalog:D(x({}),x({vars:C(qq),defaults:C(Uq)})),previewTemplate:D(Yq,Xq,{kind:`mutation`,access:`view`}),getHistory:D(x({filter:rJ.default({limit:100})}),x({entries:C(nJ)}),{auth:`admin`}),getRuleLastRuns:D(x({}),aJ,{auth:`admin`}),resolveArtifactUrl:D(x({artifactId:u().min(1)}),x({url:u().nullable()}),{auth:`admin`}),listSnoozes:D(x({}),x({snoozes:C(cJ)}),{caller:`required`}),createSnooze:D(x({snooze:sJ}),x({snooze:cJ}),{kind:`mutation`,caller:`required`}),cancelSnooze:D(x({snoozeId:u()}),x({success:m(!0)}),{kind:`mutation`,caller:`required`}),getAlarmConfig:D(x({}),IJ,{auth:`admin`}),setAlarmConfig:D(x({patch:MJ}),IJ,{kind:`mutation`,auth:`admin`}),createAlarmProfile:D(kJ,IJ,{kind:`mutation`,auth:`admin`}),renameAlarmProfile:D(AJ,IJ,{kind:`mutation`,auth:`admin`}),deleteAlarmProfile:D(jJ,IJ,{kind:`mutation`,auth:`admin`}),activateAlarmProfile:D(jJ,IJ,{kind:`mutation`,auth:`admin`}),getAlarmSensors:D(zJ,BJ,{auth:`admin`})},vocabulary:{notOperatorFacing:`notification rules — authored on their own page`}},CTe=S([`min`,`low`,`normal`,`high`]),wTe=x({id:u().min(1),title:u().min(1),uri:i().optional(),destructive:y().optional()}),TTe=x({image:y(),priority:y(),data:y(),actions:y(),recipients:y()}),WJ=x({lastSentAt:r(),lastError:u().nullable(),queueDepth:r().int().nonnegative().meta(A(`count`)),supports:TTe}),ETe=x({deviceId:r().int().nonnegative(),title:u().optional(),body:u().min(1),image:u().optional(),priority:CTe.optional(),channel:u().optional(),recipients:C(u()).optional(),actions:C(wTe).optional(),data:h(u(),w()).optional()}),DTe=x({notificationId:u(),acceptedAt:r()}),GJ={name:`notifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Notifier],methods:{send:D(ETe,DTe,{kind:`mutation`,auth:`admin`,actions:[{id:`notifier.send`,label:L(`Send a notification`,`Invia una notifica`),phrase:L(`Send “{body}” through {device}`,`Invia «{body}» tramite {device}`),icon:`send`,openArgs:[{key:`title`,label:L(`Title`,`Titolo`),offer:{kind:`text`},optional:!0},{key:`body`,label:L(`Message`,`Messaggio`),offer:{kind:`text`}},{key:`priority`,label:L(`Priority`,`Priorità`),offer:{kind:`enum`,values:[{value:`min`,label:L(`Minimal`,`Minima`)},{value:`low`,label:L(`Low`,`Bassa`)},{value:`normal`,label:L(`Normal`,`Normale`)},{value:`high`,label:L(`High`,`Alta`)}]},optional:!0}]}]}),cancel:D(x({deviceId:r().int().nonnegative(),notificationId:u().min(1)}),v(),{kind:`mutation`,auth:`admin`})},events:{onSent:{data:x({deviceId:r(),notificationId:u(),success:y(),error:u().nullable(),acceptedAt:r()}),notOperatorFacing:`a delivery receipt of a send this system made — not a fact about the world`}},status:{schema:WJ,kind:`command-driven`},runtimeState:WJ,durability:`session`,history:`none`,vocabulary:{noun:L(`Notifier`,`Notificatore`),order:2110}},KJ=x({value:r().nullable().meta(A(`device`)),lastFetchedAt:r()}),qJ={name:`numeric-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:KJ,kind:`push`},runtimeState:KJ,durability:`restored`,history:{fields:{value:{kind:`gauge`,minIntervalMs:3e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Sensor`,`Sensore`),order:5150,state:[{kind:`numeric`,field:`value`,quantity:L(`the reading`,`il valore`),label:L(`Reading`,`Valore`),icon:`gauge`}]}},JJ=x({integrationId:u(),displayName:u(),requestedScopes:C(Yf),allowedRedirectPrefixes:C(u()).min(1),allowedPrivateHostPaths:C(u()).optional(),requiresPkce:y().optional(),hubUrl:u().optional(),refreshTokenTtlSec:g([r().int().positive(),m(`never`)]).optional(),instances:C(x({id:u(),displayName:u()})).optional()}),YJ={name:`oauth-integration`,scope:`system`,mode:`collection`,internal:!0,methods:{getDescriptor:D(v(),JJ,{auth:`admin`})},vocabulary:{notOperatorFacing:k.IDENTITY}},XJ=S([`text`,`timestamp`,`watermark`]),ZJ=S([`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`custom`]),QJ=x({id:u(),kind:XJ,enabled:y(),text:u().optional(),position:ZJ.optional(),availablePositions:C(ZJ).readonly(),readOnly:y().optional(),maxCharacters:r().int().positive().optional()}),$J=x({overlays:C(QJ).readonly()}),eY=x({enabled:y().optional(),text:u().optional(),position:ZJ.optional()}).partial(),tY={name:`osd`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],methods:{setOverlay:D(x({deviceId:r(),overlayId:u(),patch:eY}),v(),{kind:`mutation`,auth:`admin`})},events:{onStatusChanged:{data:x({deviceId:r(),status:$J}),notOperatorFacing:`an overlay setting changed — configuration, not a happening`}},status:{schema:$J,kind:`command-driven`},settings:{bindings:[{kind:`array`,statusPath:`overlays`,idField:`id`,method:`setOverlay`,idArg:`overlayId`,patchArg:`patch`,sectionId:`osd`,sectionTitle:`Video overlays`,itemFields:{enabled:{label:e=>`${String(e.id)} enabled`,kind:`boolean`},text:{label:e=>`${String(e.id)} text`,kind:`text`,when:e=>e.kind!==`timestamp`&&!e.readOnly},position:{label:e=>`${String(e.id)} position`,kind:`select`,options:e=>e.availablePositions??[],when:e=>Array.isArray(e.availablePositions)&&e.availablePositions.length>0}}}]},vocabulary:{noun:L(`On-screen text`,`Testo in sovrimpressione`),order:3190}},nY=1024,rY=x({id:u().min(1).max(64),name:u().min(1).max(64),text:u().max(nY).default(``)}),iY=a(`kind`,[x({kind:m(`none`)}),x({kind:m(`static`),text:u().max(nY)}),x({kind:m(`template`),templateId:u().min(1).max(64)})]),aY=x({enabled:y().default(!0),source:iY,schedule:JK.optional(),conditions:uq.optional()}),oY=x({slotId:u(),kind:XJ,readOnly:y(),cameraEnabled:y(),cameraText:u().optional(),binding:aY.nullable()}),sY=S([`written`,`unchanged`,`gated`,`unreadable`,`disabled`,`unbound`,`failed`]),cY=x({slotId:u(),outcome:sY,text:u(),reason:u().optional()}),lY=x({ok:y(),text:u(),notes:C(u())}),uY={name:`osd-manager`,scope:`system`,mode:`singleton`,methods:{getDeviceOsd:D(x({deviceId:r().int()}),x({supported:y(),slots:C(oY)}),{auth:`admin`}),getConditionSupport:D(x({}),x({supported:C(u()),catalog:C(Zq)}),{auth:`admin`}),setSlotBinding:D(x({deviceId:r().int(),slotId:u().min(1),binding:aY}),x({slot:oY,render:cY}),{kind:`mutation`,auth:`admin`}),clearSlotBinding:D(x({deviceId:r().int(),slotId:u().min(1)}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setSlotCameraEnabled:D(x({deviceId:r().int(),slotId:u().min(1),enabled:y()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),copyDeviceConfiguration:D(x({sourceDeviceId:r().int(),targetDeviceId:r().int()}),x({copied:r().int().nonnegative(),skipped:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),previewSlot:D(x({deviceId:r().int(),slotId:u().min(1),binding:aY.optional()}),cY,{kind:`mutation`,auth:`admin`}),previewTemplate:D(x({deviceId:r().int(),text:u().max(nY)}),lY,{kind:`mutation`,auth:`admin`}),renderDevice:D(x({deviceId:r().int()}),x({results:C(cY)}),{kind:`mutation`,auth:`admin`}),listTemplates:D(x({}),x({templates:C(rY)}),{auth:`admin`}),upsertTemplate:D(x({template:rY}),x({template:rY}),{kind:`mutation`,auth:`admin`}),deleteTemplate:D(x({templateId:u().min(1).max(64)}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.PIPELINE}},dY=1e4,OTe=S([`normal`,`offline`,`on_batteries`]),fY=r().int().min(4).max(200),pY=fY.meta(ig({quantity:`mass`,unit:`g`})),mY=x({foodLevel:r().nullable().meta(A(`none`)),bowlFood:r().nullable().meta(A(`mass`)),eating:y(),supportsMarkRefilled:y(),food1:r().nullable().meta(A(`none`)),food2:r().nullable().meta(A(`none`)),lowFood:y(),batteryPower:r().min(0).max(100).nullable().meta(A(`percentage`)),powerSource:S([`mains`,`battery`]).nullable(),desiccantLeftDays:r().nullable().meta(A(`duration`)),feeding:y(),status:OTe.nullable(),error:u().nullable(),errorCode:r().nullable().meta(A(`none`)),isDualHopper:y(),childLock:y(),indicatorLight:y(),feedSound:y(),volume:r().meta(A(`none`)),lastFeedGrams:fY.nullable(),lastFeedHopper1:fY.nullable(),lastFeedHopper2:fY.nullable(),lastFetchedAt:r()}),hY={name:`pet-feeder`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.PetFeeder],methods:{feed:D(x({deviceId:r().int().nonnegative(),grams:pY.optional(),hopper1:pY.optional(),hopper2:pY.optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feed`,label:L(`Feed`,`Dai da mangiare`),phrase:L(`Dispense {grams} from {device}`,`Eroga {grams} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:dY},openArgs:[{key:`grams`,label:L(`Grams`,`Grammi`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]},{id:`petFeeder.feedHoppers`,label:L(`Feed from both hoppers`,`Eroga da entrambi i serbatoi`),phrase:L(`Dispense {hopper1} and {hopper2} from {device}`,`Eroga {hopper1} e {hopper2} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:dY},openArgs:[{key:`hopper1`,label:L(`Hopper 1`,`Serbatoio 1`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0},{key:`hopper2`,label:L(`Hopper 2`,`Serbatoio 2`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]}]}),cancelFeed:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.cancelFeed`,label:L(`Cancel feeding`,`Annulla l’erogazione`),phrase:L(`Cancel the feeding on {device}`,`Annulla l’erogazione di {device}`),icon:`circle-x`}]}),callPet:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.callPet`,label:L(`Call pet`,`Chiama l’animale`),phrase:L(`Call your pet with {device}`,`Chiama l’animale con {device}`),icon:`megaphone`}]}),playSound:D(x({deviceId:r().int().nonnegative(),soundId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.playSound`,label:L(`Play sound`,`Riproduci un suono`),phrase:L(`Play sound {soundId} on {device}`,`Riproduci il suono {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:L(`Sound`,`Suono`),offer:{kind:`number`,min:0,step:1}}]}]}),resetDesiccant:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.resetDesiccant`,label:L(`Desiccant replaced`,`Essiccante sostituito`),phrase:L(`Mark the desiccant of {device} as replaced`,`Segna come sostituito l’essiccante di {device}`),icon:`refresh-cw`}]}),markFoodReplenished:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.foodReplenished`,label:L(`Food refilled`,`Cibo ricaricato`),phrase:L(`Mark {device} as refilled`,`Segna {device} come ricaricato`),icon:`package`}]}),setChildLock:D(x({deviceId:r().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.childLockOn`,effect:{field:`childLock`,value:!0},label:L(`Child lock on`,`Blocco bambini attivo`),phrase:L(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`petFeeder.childLockOff`,effect:{field:`childLock`,value:!1},label:L(`Child lock off`,`Blocco bambini spento`),phrase:L(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setIndicatorLight:D(x({deviceId:r().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.lightOn`,effect:{field:`indicatorLight`,value:!0},label:L(`Indicator light on`,`Spia accesa`),phrase:L(`Turn on the indicator light of {device}`,`Accendi la spia di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`petFeeder.lightOff`,effect:{field:`indicatorLight`,value:!1},label:L(`Indicator light off`,`Spia spenta`),phrase:L(`Turn off the indicator light of {device}`,`Spegni la spia di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setFeedSound:D(x({deviceId:r().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feedSoundOn`,effect:{field:`feedSound`,value:!0},label:L(`Feeding sound on`,`Suono di erogazione attivo`),phrase:L(`Turn on the feeding sound of {device}`,`Attiva il suono di erogazione di {device}`),icon:`volume-2`,args:{on:!0}},{id:`petFeeder.feedSoundOff`,effect:{field:`feedSound`,value:!1},label:L(`Feeding sound off`,`Suono di erogazione spento`),phrase:L(`Turn off the feeding sound of {device}`,`Disattiva il suono di erogazione di {device}`),icon:`volume-x`,args:{on:!1}}]}),setVolume:D(x({deviceId:r().int().nonnegative(),level:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.volume`,effect:{field:`volume`,fromArg:`level`},label:L(`Set volume`,`Imposta il volume`),phrase:L(`Set the volume of {device} to {level}`,`Imposta il volume di {device} a {level}`),icon:`volume-2`,openArgs:[{key:`level`,label:L(`Volume`,`Volume`),offer:{kind:`number`,min:0,step:1}}]}]})},status:{schema:mY,kind:`poll`},runtimeState:mY,durability:`session`,history:{fields:{feeding:{kind:`boolean`},eating:{kind:`boolean`},foodLevel:{kind:`gauge`},bowlFood:{kind:`gauge`},food1:{kind:`gauge`},food2:{kind:`gauge`},batteryPower:{kind:`gauge`,unit:`%`,deadband:2},desiccantLeftDays:{kind:`gauge`,unit:`s`}}},vocabulary:{noun:L(`Pet feeder`,`Distributore di cibo`),order:2030,state:[{kind:`boolean`,field:`lowFood`,label:L(`Food low`,`Cibo in esaurimento`),whenTrue:L(`When {device} runs low on food`,`Quando il cibo di {device} sta finendo`),whenFalse:L(`When {device} has enough food again`,`Quando {device} ha di nuovo cibo a sufficienza`),icon:`package`},{kind:`boolean`,field:`feeding`,label:L(`Feeding`,`In erogazione`),whenTrue:L(`When {device} starts feeding`,`Quando {device} inizia a erogare`),whenFalse:L(`When {device} finishes feeding`,`Quando {device} finisce di erogare`),icon:`paw-print`},{kind:`numeric`,field:`desiccantLeftDays`,quantity:L(`the desiccant life`,`la durata dell’essiccante`),label:L(`Desiccant`,`Essiccante`),unit:`d`,icon:`calendar-clock`}]}},gY=x({waterLevel:r().min(0).max(100).nullable().meta(A(`percentage`)),waterVolume:r().min(0).nullable().meta(A(`volume`)),empty:y().nullable(),pumpRunning:y().nullable(),error:u().nullable(),lastFetchedAt:r()}),_Y=`water`;function kTe(e){let t=e.waterLevel!==null||e.empty===null?null:e.empty?`empty`:`ok`;return{key:_Y,label:`Water`,level:e.waterLevel,status:t,kind:`supply`,form:`tank`,lastResetAt:null,resettable:!1}}var ATe=r().int().nonnegative(),vY={name:`pet-fountain`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.PetFountain],power:{kind:`field`,field:`pumpRunning`,set:`setPump`},methods:{setPump:D(x({deviceId:ATe,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFountain.pumpOn`,effect:{field:`pumpRunning`,value:!0},label:L(`Pump on`,`Pompa accesa`),phrase:L(`Start the pump of {device}`,`Avvia la pompa di {device}`),icon:`play`,args:{on:!0}},{id:`petFountain.pumpOff`,effect:{field:`pumpRunning`,value:!1},label:L(`Pump off`,`Pompa spenta`),phrase:L(`Stop the pump of {device}`,`Ferma la pompa di {device}`),icon:`square`,args:{on:!1}}]})},status:{schema:gY,kind:`push`},runtimeState:gY,durability:`session`,history:{fields:{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}}},vocabulary:{noun:L(`Pet fountain`,`Fontana per animali`),order:2040,state:[{kind:`boolean`,field:`empty`,label:L(`Tank empty`,`Serbatoio vuoto`),whenTrue:L(`When the tank of {device} is empty`,`Quando il serbatoio di {device} è vuoto`),whenFalse:L(`When the tank of {device} is refilled`,`Quando il serbatoio di {device} viene riempito`),icon:`droplet`},{kind:`numeric`,field:`waterLevel`,quantity:L(`the water level`,`il livello dell’acqua`),label:L(`Water level`,`Livello dell’acqua`),unit:`%`,icon:`droplets`}]}},jTe=S(ff),yY={min:1,max:8},bY=S([`intel-core-ultra`,`intel-n-series`,`apple-m-base`,`apple-m-pro`,`amd-phoenix`,`nvidia-gpu`,`unknown`]),xY=S([`intel-npu`,`intel-igpu`,`amd-igpu`,`amd-npu`,`nvidia-gpu`,`x86-cpu`,`arm-cpu`,`apple-ane`,`coral`]),SY=a(`kind`,[x({kind:m(`capacity`),sessions:r(),minSessions:r()}),x({kind:m(`tie-faster`),over:u(),recallDelta:r()}),x({kind:m(`stepped-down`),from:u(),to:u(),limitedBy:u()}),x({kind:m(`no-fit-lightest`),sessions:r(),minSessions:r()}),x({kind:m(`derived-latency`),modelId:u()}),x({kind:m(`cpu-device`)}),x({kind:m(`device-disabled`)}),x({kind:m(`device-unavailable`)}),x({kind:m(`node-offline`)}),x({kind:m(`no-hardware-facts`)}),x({kind:m(`no-measured-data`),hardwareClass:bY}),x({kind:m(`no-family-build`),format:jTe}),x({kind:m(`kept-custom-pin`),modelId:u(),deviceKey:u()})]),CY=S([`custom-pin`]),wY=a(`kind`,[x({kind:m(`table`)}),x({kind:m(`node-benchmark`),resultId:u(),measuredAtMs:r()}),x({kind:m(`estimated`),estimatedFrom:bY})]),TY=x({modelId:u(),p50Ms:r(),fps:r(),measured:y(),source:wY.optional(),estimatedFrom:bY.optional(),capacitySessions:r(),personRecall:r()}),EY=x({deviceKey:u(),accelerator:xY.nullable(),enabled:y(),available:y(),chosen:TY.nullable(),kept:CY.optional(),reasons:C(SY).readonly()}),DY=x({nodeId:u(),reachable:y(),hardwareClass:bY.nullable(),cpuModel:u().nullable(),skipped:y(),acceleratorModelId:u().nullable(),devices:C(EY).readonly(),reasons:C(SY).readonly()}),OY=x({stepId:u(),before:u().nullable(),after:u().nullable()}),kY=x({nodeId:u(),deviceKey:u(),madeExplicit:y(),modelPins:C(OY).readonly(),thresholds:C(x({stepId:u(),keys:C(u()).readonly()})).readonly()}),AY=a(`kind`,[x({kind:m(`custom-pin-kept`),nodeId:u(),deviceKey:u(),modelId:u()}),x({kind:m(`custom-registry-unreadable`),error:u()})]),jY=x({headroom:r().min(.3).max(.5).default(.4),minSessionsPerDevice:r().int().min(yY.min).max(yY.max).default(2)}),MY=x({planHash:u(),family:m(`yolov9`),headroom:r(),minSessionsPerDevice:r(),cameraFps:r(),generatedAt:r(),nodes:C(DY).readonly(),nodeChanges:C(kY).readonly(),warnings:C(AY).readonly()}),NY=x({planHash:u(),headroom:r().min(.3).max(.5).default(.4),minSessionsPerDevice:r().int().min(yY.min).max(yY.max).default(2)}),PY=x({phase:S([`download`,`node-models`,`redispatch`]),ok:y(),detail:u()}),FY=a(`kind`,[x({kind:m(`applied`),planHash:u(),phases:C(PY).readonly()}),x({kind:m(`aborted`),phases:C(PY).readonly()}),x({kind:m(`stale`),plan:MY}),x({kind:m(`refused`),reason:S([`apply-in-progress`])})]),IY=S([`least-loaded`,`share`]),LY=`share`,MTe=`sessionPlacement`;function NTe(e){let t=IY.safeParse(e);return t.success?t.data:LY}var RY=x({nodes:h(u(),r().positive()).default({}),devices:h(u(),h(u(),r().positive())).default({})}),zY=x({windowMs:r().int().min(6e4).max(1440*60*1e3).default(3600*1e3)}),BY=x({deviceKey:u(),sessionsNow:r(),sessionsStarted:r(),observedShare:r().nullable()}),VY=x({nodeId:u(),sessionsNow:r(),sessionsStarted:r(),observedShare:r().nullable(),peakSessions:r(),yieldsAway:r(),devices:C(BY).readonly()}),HY=x({deviceId:r(),deviceKey:u(),reason:S([`disabled`,`absent`])}),UY=x({policy:IY,windowMs:r(),observedForMs:r(),sessionsNow:r(),clusterPeakSessions:r(),nodes:C(VY).readonly(),stalePins:C(HY).readonly()}),WY=S([`hardware`,`benchmark`]),GY=S([`no-benchmark-results`,`partial-benchmark-results`]),KY=x({headroom:r().min(.3).max(.5).default(.4),source:WY.default(`hardware`)}),qY=x({deviceKey:u(),share:r(),modelId:u().nullable(),fps:r().nullable(),measured:y(),suggestedMaxSessions:r().nullable()}),JY=x({nodeId:u(),share:r().nullable(),capacitySessions:r(),devices:C(qY).readonly(),skippedReason:u().nullable(),capacitySource:WY.nullable(),capacityFallback:GY.nullable()}),YY=x({headroom:r(),source:WY,cameraFps:r(),minSessionsPerDevice:r(),nodes:C(JY).readonly()}),XY=S([`hardware`,`benchmark`,`manual`]),ZY=`benchmark`;function QY(e){return e!==`manual`}var PTe=.4,FTe=`shareSource`;function ITe(e){if(e===`auto`)return`hardware`;let t=XY.safeParse(e);return t.success?t.data:ZY}var $Y=x({source:XY}),LTe=x({nodes:h(u(),r()),devices:h(u(),h(u(),r()))}),eX=x({deviceKey:u(),eligible:y(),configuredPct:r(),effectivePct:r()}),tX=x({nodeId:u(),eligible:y(),configuredPct:r(),effectivePct:r(),capacitySource:WY.nullable(),capacityFallback:GY.nullable(),devices:C(eX).readonly()}),nX=x({source:XY,policy:IY,autoPending:y(),computedAt:r().nullable(),trigger:u().nullable(),nodes:C(tX).readonly(),nodeWeights:h(u(),r()),deviceWeights:h(u(),h(u(),r()))}),rX=[`motion-without-detections`,`detections-under-floor`,`inference-too-slow`,`frames-shed`,`inference-device-unusable`],iX=S(rX),aX=S([`info`,`warning`,`critical`]),oX=a(`type`,[x({type:m(`camera`),deviceId:r()}),x({type:m(`node`),nodeId:u()}),x({type:m(`inference-device`),nodeId:u(),deviceKey:u()})]),sX=x({id:u(),kind:iX,severity:aX,subject:oX,what:u(),evidence:h(u(),r().nullable()),action:u()}),cX=x({source:u(),entries:r().nullable()}),lX=x({nodeId:u(),sessionsNow:r(),unusableDevices:C(u()).readonly(),devices:C(x({deviceKey:u(),sessionsNow:r(),usable:y()})).readonly()}),uX=x({deviceId:r(),nativeCropMissesSincePreviousTick:r().nullable()}),dX=x({generatedAt:r(),tickMs:r(),camerasSeen:r().nullable(),findings:C(sX).readonly(),cameraSignals:C(uX).readonly(),nodes:C(lX).readonly(),sources:C(cX).readonly(),notCovered:C(u()).readonly()}),fX=x({history:r().int().min(1).max(24).default(1)}),pX=x({latest:dX.nullable(),previous:C(dX).readonly()}),RTe=x({engine:GU.optional(),steps:C(RU).readonly(),audio:x({engine:GU.optional(),modelId:u().optional(),enabled:y(),settings:h(u(),w()).readonly().optional()}).nullable().optional()}),mX=x({modelId:u().optional(),settings:h(u(),w()).optional(),jumpDeviceKey:u().optional(),enabled:y().optional()}),hX=x({maxCameras:r().int().nonnegative().nullable().default(null),detectWeight:r().positive().optional(),detect:y().optional(),decode:y().optional(),audio:y().optional(),ingest:y().optional(),decodeBudgetMb:r().int().min(1024).max(65536).optional(),maxLiveDecodeWorkers:r().int().min(1).max(32).optional(),reachableHost:u().optional(),color:sd.optional(),stepSettings:h(u(),h(u(),w()).readonly()).optional(),stepEnabled:h(u(),y()).optional(),inferenceDevices:h(u(),x({enabled:y(),weight:r().positive().optional(),maxSessions:r().int().positive().optional(),steps:h(u(),mX).optional()})).optional()}),zTe=h(u(),h(u(),w()).readonly()),gX=S([`pipeline`,`onboard`,`none`]),BTe=x({stepToggles:h(u(),y()).optional(),stepSettings:zTe.optional()}),_X=x({deviceId:r(),agentNodeId:u(),pinned:y(),reason:S([`manual`,`capacity`,`hardware-affinity`,`failover`,`rebalance`]),assignedAt:r()}),vX=x({nodeId:u(),online:y(),load:iG,score:r(),decodeHwaccel:u().nullable()}),yX=x({totalAgents:r(),onlineAgents:r(),totalCameras:r(),attachedCameras:r(),activeCameras:r(),avgInferenceTimeMs:r(),queueDepth:r()}),bX=h(u(),u()),xX=x({ownerNodeId:u(),reachableHost:u().optional(),configIssue:u().optional()}),SX=x({camStreamId:u(),codec:u(),width:r(),height:r(),fps:r(),kind:u()}),CX=x({streams:C(SX).readonly()}),wX=x({detectionNodeId:u().nullable(),decoderNodeId:u().nullable(),audioNodeId:u().nullable(),sourceNodeId:u().nullable(),pinned:x({detection:y(),decoder:y(),audio:y()}),reasons:x({detection:u().optional(),decoder:u().optional(),audio:u().optional()})}),TX=x({profile:u(),status:u(),codec:u(),width:r(),height:r(),subscribers:r(),inFps:r().nullable()}),EX=x({profiles:C(TX).readonly(),webrtcSessions:r(),rtspRestream:y()}),DX=x({nodeId:u()}),OX=x({enabled:y(),fps:r()}),kX=S([`idle`,`installing`,`verifying`,`ready`,`failed`]),AX=x({state:kX,error:u().optional()}),jX=S([`idle`,`watching`,`active`]),MX=x({nodeId:u(),engine:x({backend:u(),device:u()}),phase:jX,configuredFps:r(),actualFps:r(),queueDepth:r(),avgInferenceMs:r(),provisioning:AX}),NX=x({nodeId:u(),enabled:y()}),PX=nl,FX=x({mode:PX,active:y(),storageBytes:r()}),IX=S([`source`,`broker`,`detection`,`recording`,`switches`]),LX=S([`timeout`,`error`,`partial`]),RX=x({stage:IX,reason:LX,elapsedMs:r()}),zX=x({state:S([`idle`,`running`,`done`,`error`]),total:r().int().nonnegative(),completed:r().int().nonnegative(),currentDeviceId:r().int().nullable(),failed:C(r().int()).readonly(),mediaDropped:r().int().nonnegative(),tracks:r().int().nonnegative(),events:r().int().nonnegative(),startedAtMs:r().int().nullable(),finishedAtMs:r().int().nullable(),error:u().nullable()}),BX=x({deviceId:r(),assignment:wX,source:CX,broker:EX.nullable(),decoder:DX.nullable(),motion:OX.nullable(),detection:MX.nullable(),audio:NX.nullable(),recording:FX.nullable(),switchedOff:C(ao).readonly(),cameraSensors:gV.optional(),degraded:C(RX).readonly(),fetchedAt:r()}),VX=[`disabled`,`unavailable`,`cannot-host-camera-root`,`accelerator-preferred`,`root-switched-off`,`no-gpu-device`],HX=S(VX),VTe=x({key:u(),backend:u(),device:u(),format:S(ff),available:y(),presence:S([`present`,`absent`,`unknown`]).optional(),enabled:y(),weight:r(),maxSessions:r().nullable(),defaultModelId:u(),steps:h(u(),mX).optional(),exclusion:HX.nullable()}),UX=a(`kind`,[x({kind:m(`stored`),modelId:u()}),x({kind:m(`absent`),defaultModelId:u()}),x({kind:m(`unreadable`),reason:S(AV),error:u().optional()})]),HTe=x({nodeId:u(),reachable:y(),devices:C(VTe).readonly(),defaultPoolExcluded:y().optional()}),WX=S([`off`,`on`,`opt-in`]),GX=a(`kind`,[x({kind:m(`on`)}),x({kind:m(`off-cluster`)}),x({kind:m(`off-node`)}),x({kind:m(`off-device`)}),x({kind:m(`jump`),toDeviceKey:u()}),x({kind:m(`skip`),reason:S([`no-compatible-model`,`root-not-runnable-on-elected-device`])}),x({kind:m(`zone-driven`)}),x({kind:m(`supplied-by-root`),rootModelId:u()}),x({kind:m(`opt-in-unused`)})]),UTe=x({deviceKey:u(),format:S(ff),stepEnabled:y().nullable(),eligible:y(),cell:GX}),WTe=x({nodeId:u(),reachable:y(),stepEnabled:y().nullable(),devices:C(UTe).readonly()}),KX=x({steps:C(x({stepId:u(),name:u(),slot:u(),clusterMode:WX.nullable(),effectiveMode:WX,camerasEnabling:r().int().nonnegative(),camerasDisabling:r().int().nonnegative(),nodes:C(WTe).readonly()})).readonly()}),qX=x({deviceId:r().int().nonnegative(),config:lV.nullable()}),JX=S([`unknown-camera`,`out-of-range`,`no-burst-producer`,`already-looked`]),YX=x({deviceId:r().int().nonnegative(),afterMs:r().finite(),reason:u()}),XX=x({scheduled:y(),dueInMs:r().optional(),refusedBecause:JX.optional()}),ZX={name:`pipeline-orchestrator`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,exposesDeviceSettings:!0,methods:{requestOccupancyLook:D(YX,XX,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:D(Cl,x({paused:m(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:D(Cl,x({resumed:m(!0)}),{kind:`mutation`,auth:`admin`}),assignPipeline:D(x({deviceId:r(),agentNodeId:u()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),unassignPipeline:D(x({deviceId:r()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setPipelineDevicePin:D(x({deviceId:r(),deviceKey:u()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getPipelineDevicePin:D(x({deviceId:r()}),x({deviceKey:u().nullable()})),rebalance:D(v(),x({migrated:r(),skipped:C(x({deviceId:r(),targetNodeId:u(),reason:u()})).default([])}),{kind:`mutation`,auth:`admin`}),getPipelineAssignments:D(v(),C(_X).readonly()),getPipelineAssignment:D(x({deviceId:r()}),_X.nullable()),getAgentLoad:D(v(),C(vX).readonly()),getClusterModelChoice:D(x({stepId:u()}),UX),getGlobalMetrics:D(v(),yX),getCameraMetrics:D(x({deviceId:r()}),QU.nullable()),getCapabilityBindings:D(x({nodeId:u()}),bX),setCapabilityBinding:D(x({nodeId:u(),capName:u(),addonId:u()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getIngestOwner:D(v(),xX),assignAudio:D(x({deviceId:r(),nodeId:u()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),unassignAudio:D(x({deviceId:r()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getAudioAssignment:D(x({deviceId:r()}),x({nodeId:u(),pinned:y(),assignedAt:r()}).nullable()),getAudioNodeLoad:D(v(),C(x({nodeId:u(),deviceCount:r()}))),getAudioAssignments:D(v(),C(x({deviceId:r(),nodeId:u(),pinned:y(),assignedAt:r()}))),getAgentSettings:D(x({agentNodeId:u()}),hX.nullable()),listAgentSettings:D(v(),C(x({nodeId:u(),settings:hX})).readonly()),removeAgentSettings:D(x({agentNodeId:u()}),x({success:y(),removed:y()}),{kind:`mutation`,auth:`admin`}),setAgentMaxCameras:D(x({agentNodeId:u(),maxCameras:r().int().nonnegative().nullable()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentCapabilities:D(x({agentNodeId:u(),detect:y().nullable().optional(),audio:y().nullable().optional(),ingest:y().nullable().optional()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentDecodeLimits:D(x({agentNodeId:u(),decodeBudgetMb:r().int().min(1024).max(65536).nullable().optional(),maxLiveDecodeWorkers:r().int().min(1).max(32).nullable().optional()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentReachableHost:D(x({agentNodeId:u(),reachableHost:u().nullable().optional(),color:sd.nullable().optional()}).refine(e=>e.reachableHost!==void 0||e.color!==void 0,{message:`reachableHost or color required`}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentInferenceDevices:D(x({agentNodeId:u(),inferenceDevices:h(u(),x({enabled:y(),weight:r().positive().optional(),maxSessions:r().int().positive().optional(),steps:h(u(),mX).optional()}))}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepSettings:D(x({agentNodeId:u(),addonId:u(),settings:h(u(),w()).nullable()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setClusterStepMode:D(x({stepId:u(),mode:WX.nullable()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepEnabled:D(x({agentNodeId:u(),stepId:u(),enabled:y().nullable()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setDeviceStepEnabled:D(x({agentNodeId:u(),deviceKey:u(),stepId:u(),enabled:y().nullable()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getStepSwitches:D(v(),KX),getNodeInferenceDevices:D(x({nodeId:u()}),HTe),forgetInferenceDevice:D(x({agentNodeId:u(),deviceKey:u()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),resetNodePipelineDefaults:D(x({agentNodeId:u()}),x({success:m(!0),effectiveModelId:u().nullable()}),{kind:`mutation`,auth:`admin`}),planAutoTune:D(jY,MY,{auth:`admin`}),applyAutoTune:D(NY,FY,{kind:`mutation`,auth:`admin`}),setLoadBalancingShares:D(RY,x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getPlacementStats:D(zY,UY,{auth:`admin`}),getHealthDigest:D(fX,pX,{auth:`admin`}),suggestShares:D(KY,YY,{auth:`admin`}),getEffectiveShares:D(v(),nX,{auth:`admin`}),setShareSource:D($Y,x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkPreflight:D(sW,fW,{auth:`admin`}),startNodeBenchmark:D(sW,a(`kind`,[x({kind:m(`started`),runId:u()}),x({kind:m(`refused`),preflight:fW})]),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkStatus:D(v(),DW,{auth:`admin`}),abortNodeBenchmark:D(x({runId:u()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkCandidates:D(x({nodeId:u()}),jW,{auth:`admin`}),listNodeBenchmarkResults:D(kW,C(AW).readonly(),{auth:`admin`}),deleteNodeBenchmarkResult:D(x({id:u()}),x({deleted:y()}),{kind:`mutation`,auth:`admin`}),getCameraSettings:D(x({deviceId:r()}),BTe.nullable()),setCameraStepToggle:D(x({deviceId:r(),addonId:u(),enabled:y().nullable()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getCameraDetectionSource:D(x({deviceId:r()}),x({source:gX,explicit:y(),onboard:x({available:y(),geometry:S([`boxed`,`while-streaming`,`flag-only`,`unknown`])})})),setCameraDetectionSource:D(x({deviceId:r(),source:gX}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setCameraStepSettings:D(x({deviceId:r(),addonId:u(),settings:h(u(),w()).nullable()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),resolvePipeline:D(x({deviceId:r(),agentNodeId:u().optional()}),RTe),getCameraSwitches:D(x({deviceId:r()}),so,{role:`viewer`}),setCameraSwitch:D(x({deviceId:r(),switchId:ao,enabled:y()}),so,{kind:`mutation`,auth:`admin`}),getCameraStatus:D(x({deviceId:r()}),BX),getCameraStatuses:D(x({deviceIds:C(r()).optional()}),C(BX).readonly()),setCameraSensors:D(qX,x({success:m(!0)}),{kind:`mutation`,auth:`admin`}),reconcileFromDisk:D(v(),zX,{kind:`mutation`,auth:`admin`}),getReconcileFromDiskStatus:D(v(),zX,{auth:`admin`})},vocabulary:{notOperatorFacing:k.PIPELINE}},QX=x({id:u(),name:u(),sampleCount:r().int().nonnegative(),coverMediaId:r().int().optional(),coverBase64:u().optional()}),GTe=x({id:u(),text:u(),score:r(),addedAt:r().int(),deviceId:r().int().optional(),base64:u().optional(),mediaId:r().int().optional(),keyFrameMediaId:r().int().optional(),plateBbox:Ay.optional()}),$X=x({plateId:u(),deviceId:r().int(),trackId:u(),timestamp:r().int(),text:u(),score:r(),corrected:y(),recognizedVehicleId:u().optional(),vehicleName:u().optional(),assigned:y(),plateBbox:Ay.optional(),keyFrameMediaId:r().int().optional(),base64:u().optional(),cropUrl:u().optional(),cropMissReason:u().optional()}),KTe=x({mediaId:r().int(),kind:u(),url:u(),sizeBytes:r(),timestamp:r()}),qTe=x({plateIds:C(u()).readonly(),representativePlateId:u(),representativeText:u(),size:r().int(),cohesion:r()}),eZ={name:`plate-gallery`,role:{feature:`plate-assignment`},scope:`system`,mode:`singleton`,methods:{listPlates:D(x({deviceId:r().int().optional(),limit:r().int().positive().optional(),includeCrops:y().optional()}).optional(),C($X).readonly()),getPlateByTrack:D(x({deviceId:r().int(),trackId:u()}),$X.nullable(),{role:`viewer`}),getPlateMedia:D(x({plateId:u()}),C(KTe).readonly()),searchPlates:D(x({text:u().min(1),maxDistance:r().int().min(0).optional(),limit:r().int().positive().optional(),includeCrops:y().optional()}),C($X).readonly()),suggestPlateClusters:D(x({maxDistance:r().int().min(0).optional(),minClusterSize:r().int().min(2).optional(),limit:r().int().positive().optional()}).optional(),C(qTe).readonly()),correctPlateText:D(x({plateId:u(),text:u().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deletePlate:D(x({plateId:u()}),v(),{kind:`mutation`,auth:`admin`}),listVehicles:D(x({includeCrops:y().optional()}).optional(),C(QX).readonly()),createVehicle:D(x({name:u().min(1)}),QX,{kind:`mutation`,auth:`admin`}),renameVehicle:D(x({id:u(),name:u().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteVehicle:D(x({id:u()}),v(),{kind:`mutation`,auth:`admin`}),listVehicleSamples:D(x({vehicleId:u()}),C(GTe).readonly()),removeVehicleSample:D(x({vehicleId:u(),sampleId:u()}),v(),{kind:`mutation`,auth:`admin`}),moveVehicleSample:D(x({sampleId:u().min(1),toVehicleId:u().min(1)}),v(),{kind:`mutation`,auth:`admin`}),assignPlate:D(x({plateId:u(),vehicleId:u()}),v(),{kind:`mutation`,auth:`admin`}),unassignPlate:D(x({plateId:u()}),v(),{kind:`mutation`,auth:`admin`}),assignPlates:D(x({plateIds:C(u()).min(1),vehicleId:u()}),x({assigned:r().int(),failed:C(u()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignPlates:D(x({plateIds:C(u()).min(1)}),x({unassigned:r().int(),failed:C(u()).readonly()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the plate gallery — curated on its own page`}},tZ={"intel-core-ultra":{"intel-npu":{"yolov9t-320":{p50Ms:2.9,fps:383,measured:!0},"yolov9t-320-int8":{p50Ms:3.8,fps:333,measured:!0},"yolov9t-640":{p50Ms:7.4,fps:139,measured:!0},"yolov9t-640-int8":{p50Ms:7.5,fps:144,measured:!0},"yolov9s-320":{p50Ms:4.4,fps:241,measured:!0},"yolov9s-320-int8":{p50Ms:4.1,fps:264,measured:!0},"yolov9s-640":{p50Ms:12.7,fps:82,measured:!0},"yolov9s-640-int8":{p50Ms:10.7,fps:99,measured:!0},"yolov9m-320":{p50Ms:8.4,fps:123,measured:!0},"yolov9m-320-int8":{p50Ms:6.5,fps:165,measured:!0},"yolov9m-640":{p50Ms:29.5,fps:32,measured:!0},"yolov9m-640-int8":{p50Ms:19.5,fps:52,measured:!0}},"intel-igpu":{"yolov9t-320":{p50Ms:2.6,fps:405,measured:!0},"yolov9t-320-int8":{p50Ms:2.8,fps:324,measured:!0},"yolov9t-640":{p50Ms:6.5,fps:157,measured:!0},"yolov9t-640-int8":{p50Ms:5.6,fps:185,measured:!0},"yolov9s-320":{p50Ms:4.6,fps:200,measured:!0},"yolov9s-320-int8":{p50Ms:4.1,fps:239,measured:!0},"yolov9s-640":{p50Ms:15.2,fps:69,measured:!0},"yolov9s-640-int8":{p50Ms:10.5,fps:99,measured:!0},"yolov9m-320":{p50Ms:11.4,fps:88,measured:!0},"yolov9m-320-int8":{p50Ms:7,fps:127,measured:!0},"yolov9m-640":{p50Ms:40,fps:25,measured:!0},"yolov9m-640-int8":{p50Ms:23.5,fps:44,measured:!0}},"x86-cpu":{"yolov9t-320":{p50Ms:6.9,fps:145,measured:!0},"yolov9t-320-int8":{p50Ms:2.7,fps:405,measured:!0},"yolov9t-640":{p50Ms:23,fps:44,measured:!0},"yolov9t-640-int8":{p50Ms:8.8,fps:124,measured:!0},"yolov9s-320":{p50Ms:15.8,fps:63,measured:!0},"yolov9s-320-int8":{p50Ms:6.5,fps:180,measured:!0},"yolov9s-640":{p50Ms:58.2,fps:17,measured:!0},"yolov9s-640-int8":{p50Ms:20.1,fps:52,measured:!0},"yolov9m-320":{p50Ms:40,fps:25,measured:!0},"yolov9m-320-int8":{p50Ms:14.2,fps:74,measured:!0},"yolov9m-640":{p50Ms:155.8,fps:6,measured:!0},"yolov9m-640-int8":{p50Ms:52.4,fps:19,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"intel-n-series":{"intel-igpu":{"yolov9t-320":{p50Ms:15,fps:48,measured:!0},"yolov9t-320-int8":{p50Ms:14.1,fps:67,measured:!0},"yolov9t-640":{p50Ms:38.5,fps:26,measured:!0},"yolov9t-640-int8":{p50Ms:50,fps:20,measured:!0},"yolov9s-320":{p50Ms:41.4,fps:24,measured:!0},"yolov9s-320-int8":{p50Ms:23.3,fps:34,measured:!0},"yolov9s-640":{p50Ms:127.4,fps:8,measured:!0},"yolov9s-640-int8":{p50Ms:81,fps:12,measured:!0},"yolov9m-320":{p50Ms:63.5,fps:16,measured:!0},"yolov9m-320-int8":{p50Ms:66,fps:15,measured:!0},"yolov9m-640":{p50Ms:215.5,fps:5,measured:!0},"yolov9m-640-int8":{p50Ms:163,fps:6,measured:!0}},"x86-cpu":{"yolov9t-320":{p50Ms:86.2,fps:12,measured:!0},"yolov9t-320-int8":{p50Ms:52.7,fps:20,measured:!0},"yolov9t-640":{p50Ms:322.1,fps:3,measured:!0},"yolov9t-640-int8":{p50Ms:205.6,fps:5,measured:!0},"yolov9s-320":{p50Ms:164.4,fps:6,measured:!0},"yolov9s-320-int8":{p50Ms:86.9,fps:12,measured:!0},"yolov9s-640":{p50Ms:341.3,fps:3,measured:!0},"yolov9s-640-int8":{p50Ms:185.3,fps:5,measured:!0},"yolov9m-320":{p50Ms:166.8,fps:6,measured:!0},"yolov9m-320-int8":{p50Ms:226.3,fps:4,measured:!0},"yolov9m-640":{p50Ms:663.5,fps:2,measured:!0},"yolov9m-640-int8":{p50Ms:324.4,fps:3,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"amd-phoenix":{"x86-cpu":{"yolov9t-320":{p50Ms:24,fps:42,measured:!0},"yolov9t-320-int8":{p50Ms:12,fps:83,measured:!0},"yolov9t-640":{p50Ms:50,fps:20,measured:!0},"yolov9t-640-int8":{p50Ms:20,fps:50,measured:!0},"yolov9s-320":{p50Ms:30,fps:33,measured:!0},"yolov9s-320-int8":{p50Ms:15,fps:67,measured:!0},"yolov9s-640":{p50Ms:92,fps:11,measured:!0},"yolov9s-640-int8":{p50Ms:27,fps:37,measured:!0},"yolov9m-320":{p50Ms:67,fps:15,measured:!0},"yolov9m-320-int8":{p50Ms:21,fps:48,measured:!0},"yolov9m-640":{p50Ms:229,fps:4,measured:!0},"yolov9m-640-int8":{p50Ms:48,fps:21,measured:!0}},"amd-igpu":{"yolov9t-320":{p50Ms:40,fps:25,measured:!0},"yolov9t-640":{p50Ms:89,fps:11,measured:!0},"yolov9s-320":{p50Ms:65,fps:15,measured:!0},"yolov9s-640":{p50Ms:125,fps:8,measured:!0},"yolov9m-320":{p50Ms:85,fps:12,measured:!0},"yolov9m-640":{p50Ms:228,fps:4,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!0}}},"nvidia-gpu":{"nvidia-gpu":{"yolov9t-320":{p50Ms:12,fps:83,measured:!1},"yolov9t-640":{p50Ms:16,fps:62,measured:!1},"yolov9s-320":{p50Ms:13,fps:77,measured:!1},"yolov9s-640":{p50Ms:20,fps:50,measured:!1},"yolov9m-320":{p50Ms:16,fps:62,measured:!1},"yolov9m-640":{p50Ms:32,fps:31,measured:!1}}},"apple-m-pro":{"apple-ane":{"yolov9t-320":{p50Ms:1.1,fps:952,measured:!0},"yolov9t-640":{p50Ms:3,fps:333,measured:!0},"yolov9s-320":{p50Ms:1.5,fps:667,measured:!0},"yolov9s-640":{p50Ms:5.1,fps:196,measured:!0},"yolov9m-320":{p50Ms:3.2,fps:312,measured:!0},"yolov9m-640":{p50Ms:10.2,fps:98,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}},"apple-m-base":{"apple-ane":{"yolov9t-320":{p50Ms:1.32,fps:758,measured:!1},"yolov9t-640":{p50Ms:3.45,fps:290,measured:!0},"yolov9s-320":{p50Ms:1.8,fps:556,measured:!1},"yolov9s-640":{p50Ms:5.46,fps:183,measured:!0},"yolov9m-320":{p50Ms:3.79,fps:264,measured:!0},"yolov9m-640":{p50Ms:10.34,fps:97,measured:!0}},coral:{"yolov9s-320-edgetpu":{p50Ms:32,fps:31,measured:!1}}}},nZ={"yolov9m-320":{personPrecision:.979,personRecall:.649},"yolov9m-320-int8":{personPrecision:.974,personRecall:.684},"yolov9m-640":{personPrecision:.976,personRecall:.854},"yolov9m-640-int8":{personPrecision:.976,personRecall:.847},"yolov9s-320":{personPrecision:.958,personRecall:.479},"yolov9s-320-int8":{personPrecision:.969,personRecall:.438},"yolov9s-640":{personPrecision:.986,personRecall:.753},"yolov9s-640-int8":{personPrecision:.963,personRecall:.823},"yolov9t-320":{personPrecision:.946,personRecall:.368},"yolov9t-320-int8":{personPrecision:.943,personRecall:.347},"yolov9t-640":{personPrecision:.979,personRecall:.646},"yolov9t-640-int8":{personPrecision:.979,personRecall:.646}},rZ=.5,JTe=.05,iZ=2e3,aZ=r().nullable().transform(e=>e!==null&&Number.isFinite(e)&&e>0?e:null),oZ=u().nullable().transform(e=>e!==null&&e.trim()!==``?e:null),sZ=x({int8:aZ,fp16:aZ}),cZ=x({deviceKey:u(),fullDeviceName:oZ,executionUnits:aZ,clockMHz:aZ,gops:sZ.nullable(),architecture:oZ,npuName:oZ,tops:aZ,vendor:oZ,webgpuArchitecture:oZ,webgpuDevice:oZ,computeUnits:aZ}),YTe=x({accelerators:C(cZ).nullable()}),lZ=[{hardwareClass:`intel-n-series`,accelerator:`intel-igpu`,score:{metric:`eu-mhz`,value:24*750}},{hardwareClass:`intel-core-ultra`,accelerator:`intel-igpu`,score:{metric:`eu-mhz`,value:64*iZ}},{hardwareClass:`amd-phoenix`,accelerator:`amd-igpu`,score:{metric:`cu`,value:12}}];function XTe(e){let t=YTe.safeParse(e);return!t.success||t.data.accelerators===null?null:t.data.accelerators}function uZ(e){return e!==null&&e>0?e:null}function dZ(e){let t=[],n=uZ(e.gops?.int8??null);n!==null&&t.push({metric:`gops-int8`,value:n});let r=uZ(e.gops?.fp16??null);r!==null&&t.push({metric:`gops-fp16`,value:r});let i=uZ(e.executionUnits),a=uZ(e.clockMHz);i!==null&&a!==null&&t.push({metric:`eu-mhz`,value:i*a});let o=uZ(e.computeUnits);o!==null&&t.push({metric:`cu`,value:o});let s=uZ(e.tops);return s!==null&&t.push({metric:`tops`,value:s}),t}function fZ(e,t,n){let r=n.filter(n=>n.accelerator===e&&n.score.metric===t.metric&&n.score.value>0),i=r[0];return i===void 0?null:r.reduce((e,n)=>Math.abs(Math.log(t.value/n.score.value))<Math.abs(Math.log(t.value/e.score.value))?n:e,i)}function pZ(e,t,n){for(let r of dZ(e))if(fZ(t,r,n)!==null)return r;return null}function mZ(e,t,n=lZ){return pZ(e,t,n)!==null}function hZ(e,t,n){if(t!==`unknown`)return e[t]?.[n]}function ZTe(e){return Math.round(e*10)/10}function QTe(e){return Math.min(2,Math.max(rZ,e))}function $Te(e,t,n){let r={};for(let[i,a]of Object.entries(e))r[i]={p50Ms:ZTe(a.p50Ms/t),fps:Math.max(1,Math.round(a.fps*t)),measured:!1,estimatedFrom:n};return r}function gZ(e){let t=e.perf??tZ,n=e.references??lZ;if(e.accelerator===`nvidia-gpu`){let e=hZ(t,`nvidia-gpu`,`nvidia-gpu`);return e===void 0?null:{column:e,estimatedFrom:null}}let r=hZ(t,e.hardwareClass,e.accelerator);if(r!==void 0&&e.hardwareClass!==`intel-n-series`)return{column:r,estimatedFrom:null};let i=e.report===null?null:pZ(e.report,e.accelerator,n);if(i===null)return r===void 0?null:{column:r,estimatedFrom:null};let a=fZ(e.accelerator,i,n),o=a===null?void 0:hZ(t,a.hardwareClass,e.accelerator);if(a===null||o===void 0)return r===void 0?null:{column:r,estimatedFrom:null};let s=i.value/a.score.value;return e.hardwareClass===a.hardwareClass&&Math.abs(s-1)<=.05?{column:o,estimatedFrom:null}:{column:$Te(o,QTe(s),a.hardwareClass),estimatedFrom:a.hardwareClass}}var _Z=S(ff),eEe=S([`videotoolbox`,`cuda`,`nvdec`,`vaapi`,`qsv`,`d3d11va`,`dxva2`,`amf`,`vdpau`,`drm`,`coreml`,`tensorrt`,`openvino`,`directml`,`webgpu`,`none`]).nullable().optional(),tEe=x({preferred:C(u()).readonly(),rationale:u()}),vZ=S([`h264_videotoolbox`,`hevc_videotoolbox`,`h264_vaapi`,`hevc_vaapi`,`h264_nvenc`,`hevc_nvenc`,`h264_qsv`,`hevc_qsv`,`h264_amf`,`hevc_amf`,`libx264`,`libx265`]);x({encoders:C(x({encoder:vZ,codec:S([`H264`,`H265`]),family:S([`videotoolbox`,`vaapi`,`nvenc`,`qsv`,`amf`,`software`]),available:y(),reason:u().optional()})).readonly(),defaultH264:vZ,defaultH265:vZ,probedAt:r()}),x({methods:C(u()).readonly(),probedAt:r()});var nEe=S([`darwin`,`linux`,`win32`]),rEe=S([`arm64`,`x64`]),iEe=x({type:S([`nvidia`,`amd`,`intel`,`apple`]),name:u(),memoryMB:r().optional()}),aEe=x({type:S([`apple-ane`,`intel-npu`,`amd-xdna`]),name:u().optional(),generation:S([`xdna1`,`xdna2`]).optional()}),yZ=S([`usb`,`pci`]),oEe=x({type:m(`coral-edgetpu`),bus:u().optional(),count:r().int().nonnegative().optional(),units:C(x({bus:yZ,count:r().int().nonnegative()})).readonly().optional(),unavailable:C(x({bus:yZ,count:r().int().nonnegative(),reason:S([`driver-missing`,`device-not-accessible`])})).readonly().optional()}),bZ=x({type:m(`nvidia`),name:u(),memoryMB:r().optional()}),sEe=a(`usable`,[bZ.extend({usable:m(!0)}),bZ.extend({usable:m(!1),reason:S([`no-cuda-execution-provider`])})]),xZ=x({platform:nEe,arch:rEe,cpuModel:u(),cpuCores:r(),totalRAM_MB:r(),availableRAM_MB:r(),gpu:iEe.nullable(),npu:aEe.nullable(),coral:oEe.nullable().optional(),nvidia:sEe.nullable().optional(),accelerators:C(cZ).readonly().optional()}),SZ=x({runtime:m(`python`),backend:u(),format:S([`onnx`,`coreml`,`openvino`,`tflite`]),score:r(),reason:u(),available:y()}),CZ=x({key:u(),backend:u(),device:u(),format:_Z,runtime:m(`python`),score:r(),available:y()}),cEe=x({hardware:xZ,scores:C(SZ).readonly(),bestScore:SZ,pythonPath:u().nullable(),devices:C(CZ).readonly()}),lEe=x({modelId:u(),name:u(),minRAM_MB:r(),accuracyScore:r(),formats:C(u()).readonly()}),uEe=x({modelId:u(),runtime:m(`python`),backend:u(),format:_Z,reason:u()}),dEe=x({devices:C(CZ).readonly(),appeared:C(u()).readonly(),disappeared:C(u()).readonly(),usbBus:S([`observed`,`unobservable`]),decidedBy:S([`usb-ids`,`pci`,`delegate-fallback`,`none`])}),wZ={name:`platform-probe`,scope:`system`,mode:`singleton`,methods:{getCapabilities:D(v(),cEe),getHardware:D(v(),xZ),resolveInferenceConfig:D(x({requirements:C(lEe).readonly()}),uEe),resolveHwAccel:D(x({prefer:eEe}),tEe),rescanAccelerators:D(v(),dEe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.CLUSTER}},TZ=x({power:r().optional().meta(A(`power`,{label:`Power`})),deliveredPower:r().optional().meta(A(`power`,{label:`Delivered`})),energy:r().optional().meta(A(`energy`,{label:`Energy`})),voltage:r().optional().meta(A(`voltage`,{label:`Voltage`})),current:r().optional().meta(A(`current`,{label:`Current`})),apparentPower:r().optional().meta(A(`apparent-power`)),powerFactor:r().min(0).max(1).optional().meta(A(`ratio`)),lastFetchedAt:r()});function EZ(e){if(e.power===void 0)return;let t=e.power-(e.deliveredPower??0);return t<0?void 0:t}var DZ=[M.Sensor,M.Switch,M.Light,M.Fan,M.Climate,M.Humidifier,M.WaterHeater,M.MediaPlayer,M.Washer,M.Dryer,M.Dishwasher,M.Vacuum,M.LawnMower,M.PetFeeder,M.Workload],fEe=DZ.filter(e=>e!==M.Sensor);function OZ(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`power-meter`,stateField:e},deviceTypes:fEe,apply:`add`,path:e,sources:[{kind:`numeric`,requiredUnit:t,transforms:[{kind:`identity`}]}],companions:[{kind:`clock`,path:`lastFetchedAt`,when:`always`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}}var pEe={version:1,targets:[OZ(`power`,`W`),OZ(`energy`,`kWh`),OZ(`voltage`,`V`),OZ(`current`,`A`)]},kZ={name:`power-meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:DZ,deviceConfig:{ui:{kind:`widget`,widgetId:`host/power-meter-line`,tab:`power`,placement:`hero`,label:`Power`,order:4}},methods:{},status:{schema:TZ,kind:`push`},runtimeState:TZ,durability:`restored`,history:{primary:`power`,priority:80,fields:{power:{kind:`gauge`,unit:`W`,deadband:1,minIntervalMs:3e4},energy:{kind:`counter`,unit:`kWh`,deadband:.01,minIntervalMs:6e4},voltage:{kind:`gauge`,unit:`V`,deadband:1,minIntervalMs:3e4},current:{kind:`gauge`,unit:`A`,deadband:.05,minIntervalMs:3e4},apparentPower:{kind:`gauge`,unit:`VA`,deadband:1,minIntervalMs:3e4},powerFactor:{kind:`gauge`,unit:`ratio`,deadband:.01,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],customize:pEe,vocabulary:{noun:L(`Power meter`,`Misuratore di energia`),order:5160,state:[{kind:`numeric`,field:`power`,quantity:L(`the power draw`,`il consumo`),label:L(`Power`,`Potenza`),unit:`W`,icon:`zap`},{kind:`numeric`,field:`energy`,quantity:L(`the energy used`,`l’energia consumata`),label:L(`Energy`,`Energia`),unit:`kWh`,icon:`zap`},{kind:`numeric`,field:`voltage`,quantity:L(`the voltage`,`la tensione`),label:L(`Voltage`,`Tensione`),unit:`V`,icon:`zap`},{kind:`numeric`,field:`current`,quantity:L(`the current`,`la corrente`),label:L(`Current`,`Corrente`),unit:`A`,icon:`zap`}]}},mEe=x({latitude:r().min(-90).max(90).meta(A(`angle`)),longitude:r().min(-180).max(180).meta(A(`angle`)),accuracyMeters:r().nonnegative().meta(A(`length`))}),AZ=x({state:u(),location:u().nullable(),gps:mEe.nullable(),lastChangedAt:r()}),jZ={name:`presence`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Presence],methods:{},status:{schema:AZ,kind:`push`},runtimeState:AZ,durability:`restored`,history:`none`,volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Presence`,`Presenza`),order:5170,state:[{kind:`value`,field:`state`,label:L(`Where`,`Posizione`),phrase:L(`When {device} is at {value}`,`Quando {device} è in {value}`),icon:`map-pin`}]}},MZ=x({pressure:r().nullable().meta(A(`pressure`,{precision:0})),lastFetchedAt:r()}),NZ={name:`pressure-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:MZ,kind:`push`},runtimeState:MZ,durability:`restored`,history:{fields:{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Pressure`,`Pressione`),order:5180,state:[{kind:`numeric`,field:`pressure`,quantity:L(`the pressure`,`la pressione`),label:L(`Pressure`,`Pressione`),unit:`hPa`,icon:`gauge`}]}},PZ=a(`kind`,[CV,wV]),FZ=x({id:r(),enabled:y(),shape:PZ}),IZ=x({enabled:y(),regions:C(FZ).nullable(),audioEnabled:y().nullable(),lastFetchedAt:r()}),LZ=x({maxRegions:r(),supportedShapes:C(DV),polygonVertices:OV.optional(),supportsAudioMute:y()}),RZ=x({enabled:y().optional(),regions:C(FZ).optional()}),zZ={name:`privacy-mask`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/privacy-mask-grid`,tab:`image`,label:`Privacy Mask`}},methods:{getOptions:D(x({deviceId:r()}),LZ),setMask:D(x({deviceId:r(),patch:RZ}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.maskOn`,label:L(`Privacy mask on`,`Maschera privacy attiva`),phrase:L(`Cover the privacy zones of {device}`,`Oscura le zone private di {device}`),icon:`eye-off`,args:{patch:{enabled:!0}}},{id:`privacy.maskOff`,label:L(`Privacy mask off`,`Maschera privacy spenta`),phrase:L(`Uncover the privacy zones of {device}`,`Scopri le zone private di {device}`),icon:`eye`,args:{patch:{enabled:!1}}}]}),setAudioEnabled:D(x({deviceId:r(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.micOn`,label:L(`Microphone on`,`Microfono attivo`),phrase:L(`Turn on the microphone of {device}`,`Attiva il microfono di {device}`),icon:`mic`,args:{enabled:!0}},{id:`privacy.micOff`,label:L(`Microphone off`,`Microfono spento`),phrase:L(`Turn off the microphone of {device}`,`Disattiva il microfono di {device}`),icon:`mic-off`,args:{enabled:!1}}]})},status:{schema:IZ,kind:`poll`},runtimeState:IZ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`Privacy`,`Privacy`),order:3210,state:[{kind:`boolean`,field:`enabled`,label:L(`Privacy mask`,`Maschera privacy`),whenTrue:L(`When the privacy mask of {device} is turned on`,`Quando si attiva la maschera privacy di {device}`),whenFalse:L(`When the privacy mask of {device} is turned off`,`Quando si disattiva la maschera privacy di {device}`),icon:`eye-off`},{kind:`boolean`,field:`audioEnabled`,label:L(`Microphone`,`Microfono`),whenTrue:L(`When the microphone of {device} is turned on`,`Quando si attiva il microfono di {device}`),whenFalse:L(`When the microphone of {device} is turned off`,`Quando si disattiva il microfono di {device}`),icon:`mic`}]}};function hEe(e){return e.length===0?null:e.some(e=>e.audioEnabled)}var BZ=S([`home`,`day-mode`,`night-mode`,`day-night-auto`,`set-limits`,`save-limits`,`reboot`,`osd-menu`]),VZ=x({id:u(),name:u(),fn:BZ.nullable(),writable:y()}),HZ=x({pan:r().nullable(),tilt:r().nullable(),zoom:r().nullable()}),UZ=x({pan:r().optional(),tilt:r().optional(),zoom:r().optional(),speed:r().optional()}),WZ=HZ.extend({autofocus:y()}),GZ=x({hasPan:y(),hasTilt:y(),hasZoom:y(),supportsPresets:y(),maxPresets:r().optional(),hasAutofocus:y(),speedSteps:r().int().positive().nullable(),moveImpulseMs:r().int().positive().nullable()}),KZ=x({presetId:u().nullable(),source:S([`operator`,`firmware`,`native`,`none`])}),qZ=x({enabled:y(),seconds:r().int()}),JZ={name:`ptz`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-panel`,tab:`ptz`,topTab:!0,label:`PTZ`,order:0}},methods:{move:D(UZ.extend({deviceId:r()}),v(),{kind:`mutation`,notOperatorFacing:`a relative nudge from the live-view joystick; a fixed place is a preset`}),continuousMove:D(UZ.extend({deviceId:r()}),v(),{kind:`mutation`,notOperatorFacing:`joystick motion held until released — continuous, not a discrete step`}),goHome:D(x({deviceId:r()}),v(),{kind:`mutation`,actions:[{id:`ptz.goHome`,label:L(`PTZ go home`,`Torna alla posizione iniziale`),phrase:L(`Send {device} to its home position`,`Riporta {device} alla posizione iniziale`),icon:`house`}]}),getPresets:D(x({deviceId:r()}),C(VZ)),goToPreset:D(x({deviceId:r(),presetId:u()}),v(),{kind:`mutation`,actions:[{id:`ptz.goToPreset`,label:L(`PTZ go to preset`,`Vai a un preset`),phrase:L(`Move {device} to {presetId}`,`Sposta {device} su {presetId}`),icon:`move`,openArgs:[{key:`presetId`,label:L(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),savePreset:D(x({deviceId:r(),presetId:u(),name:u()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.savePreset`,label:L(`Save PTZ preset here`,`Salva qui un preset`),phrase:L(`Save where {device} points now as preset {presetId} ({name})`,`Salva la posizione attuale di {device} come preset {presetId} ({name})`),icon:`bookmark-plus`,openArgs:[{key:`presetId`,label:L(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}},{key:`name`,label:L(`Name`,`Nome`),offer:{kind:`text`}}]}]}),deletePreset:D(x({deviceId:r(),presetId:u()}),v(),{kind:`mutation`,auth:`admin`}),getOptions:D(x({deviceId:r()}),GZ),stop:D(x({deviceId:r()}),v(),{kind:`mutation`,actions:[{id:`ptz.stop`,label:L(`Stop moving`,`Ferma il movimento`),phrase:L(`Stop {device} moving`,`Ferma il movimento di {device}`),icon:`square`}]}),getHomePreset:D(x({deviceId:r()}),KZ),setHomePreset:D(x({deviceId:r(),presetId:u().nullable()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomePreset`,label:L(`Set PTZ home preset`,`Imposta il preset iniziale`),phrase:L(`Make {presetId} the home position of {device}`,`Rendi {presetId} la posizione iniziale di {device}`),icon:`house`,openArgs:[{key:`presetId`,label:L(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),captureHomeHere:D(x({deviceId:r()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.captureHomeHere`,label:L(`Set PTZ home here`,`Imposta qui la posizione iniziale`),phrase:L(`Make where {device} points now its home position`,`Rendi la posizione attuale di {device} la sua posizione iniziale`),icon:`map-pin`}]}),getHomeReturn:D(x({deviceId:r()}),qZ.nullable()),setHomeReturn:D(x({deviceId:r(),enabled:y(),seconds:r().int().min(0).max(3600)}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomeReturn`,label:L(`Set PTZ return home`,`Imposta il ritorno alla posizione iniziale`),phrase:L(`Set {device} to return home when idle ({enabled}) after {seconds} s`,`Imposta {device} per tornare alla posizione iniziale da fermo ({enabled}) dopo {seconds} s`),icon:`undo-2`,openArgs:[{key:`enabled`,label:L(`Return home`,`Torna alla posizione iniziale`),offer:{kind:`boolean`}},{key:`seconds`,label:L(`Idle seconds`,`Secondi da fermo`),offer:{kind:`number`,min:0,max:3600,step:1,unit:`s`}}]}]}),getPosition:D(x({deviceId:r()}),HZ),setAutofocus:D(x({deviceId:r(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autofocusOn`,label:L(`Autofocus on`,`Autofocus attivo`),phrase:L(`Turn on autofocus on {device}`,`Attiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!0}},{id:`ptz.autofocusOff`,label:L(`Autofocus off`,`Autofocus spento`),phrase:L(`Turn off autofocus on {device}`,`Disattiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!1}}]})},status:{schema:WZ,kind:`command-driven`},vocabulary:{noun:L(`Pan / tilt / zoom`,`Brandeggio`),order:3220}},YZ=x({targetType:u().describe(`Vendor target string (people/vehicle/pet); empty = camera default`),stopDelaySeconds:r().int().min(0).max(300).meta(A(`duration`)),disappearDelaySeconds:r().int().min(0).max(300).meta(A(`duration`))}),XZ=x({value:u(),label:u()}),ZZ=x({enabled:y(),lastChangedAt:r(),currentSettings:YZ.nullable(),supportedTargetTypes:C(XZ)}),QZ=ZZ.extend({lastFetchedAt:r()}),$Z={name:`ptz-autotrack`,scope:`device`,deviceNative:!0,mode:`singleton`,kind:`wrapper`,defaultActive:!1,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-autotrack`,tab:`ptz`,topTab:!0,label:`Auto-Tracking`,order:5}},methods:{getStatus:D(x({deviceId:r()}),ZZ),setEnabled:D(x({deviceId:r(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autotrackOn`,label:L(`Autotrack on`,`Inseguimento attivo`),phrase:L(`Start autotracking on {device}`,`Attiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!0}},{id:`ptz.autotrackOff`,label:L(`Autotrack off`,`Inseguimento spento`),phrase:L(`Stop autotracking on {device}`,`Disattiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!1}}]}),getSettings:D(x({deviceId:r()}),YZ.nullable()),setSettings:D(x({deviceId:r(),settings:YZ.partial()}),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`tracking tuning (target type, delays) — set once on the camera’s PTZ page`})},events:{onStatusChanged:{data:x({deviceId:r(),status:ZZ}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:ZZ,kind:`command-driven`},runtimeState:QZ,durability:`session`,history:`none`,vocabulary:{noun:L(`Autotracking`,`Inseguimento automatico`),order:3230,state:[{kind:`boolean`,field:`enabled`,label:L(`Autotracking`,`Inseguimento automatico`),whenTrue:L(`When autotracking is turned on for {device}`,`Quando si attiva l’inseguimento automatico di {device}`),whenFalse:L(`When autotracking is turned off for {device}`,`Quando si disattiva l’inseguimento automatico di {device}`),icon:`crosshair`}]}},eQ=x({enabled:y().nullable(),onTime:r().min(0).nullable().meta(A(`duration`)),offTime:r().min(0).nullable().meta(A(`duration`)),lastFetchedAt:r()}),tQ=r().int().nonnegative(),nQ=r().int().min(0),rQ={name:`pump-cycle`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.PetFountain],methods:{setEnabled:D(x({deviceId:tQ,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.on`,effect:{field:`enabled`,value:!0},label:L(`Pump cycle on`,`Ciclo pompa attivo`),phrase:L(`Run the pump of {device} on its on/off cycle`,`Fai lavorare la pompa di {device} a ciclo acceso/spento`),icon:`timer`,args:{on:!0}},{id:`pumpCycle.off`,effect:{field:`enabled`,value:!1},label:L(`Pump cycle off`,`Ciclo pompa spento`),phrase:L(`Run the pump of {device} continuously`,`Fai lavorare la pompa di {device} in continuo`),icon:`timer-off`,args:{on:!1}}]}),setOnMinutes:D(x({deviceId:tQ,minutes:nQ}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.onMinutes`,label:L(`Set pump run time`,`Imposta il tempo di lavoro della pompa`),phrase:L(`Set the pump of {device} to run {minutes} minutes per cycle`,`Imposta la pompa di {device} a lavorare {minutes} minuti per ciclo`),icon:`timer`,effect:{field:`onTime`,fromArg:`minutes`,scale:60},openArgs:[{key:`minutes`,label:L(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]}),setOffMinutes:D(x({deviceId:tQ,minutes:nQ}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.offMinutes`,label:L(`Set pump rest time`,`Imposta il tempo di riposo della pompa`),phrase:L(`Set the pump of {device} to rest {minutes} minutes per cycle`,`Imposta la pompa di {device} a riposare {minutes} minuti per ciclo`),icon:`timer-off`,effect:{field:`offTime`,fromArg:`minutes`,scale:60},openArgs:[{key:`minutes`,label:L(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]})},status:{schema:eQ,kind:`push`},runtimeState:eQ,durability:`session`,history:`none`,vocabulary:{noun:L(`Pump cycle`,`Ciclo della pompa`),order:2050,state:[{kind:`boolean`,field:`enabled`,label:L(`Pump cycle`,`Ciclo pompa`),whenTrue:L(`When {device} starts running its pump on a cycle`,`Quando {device} inizia a far lavorare la pompa a ciclo`),whenFalse:L(`When {device} runs its pump continuously`,`Quando {device} fa lavorare la pompa in continuo`),icon:`timer`}]}},iQ={name:`reboot`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera,M.Sensor,M.Switch,M.Gateway],methods:{reboot:D(x({deviceId:r().int().nonnegative()}),x({success:m(!0)}),{kind:`mutation`,auth:`admin`,actions:[{id:`reboot.reboot`,label:L(`Reboot device`,`Riavvia il dispositivo`),phrase:L(`Reboot {device}`,`Riavvia {device}`),icon:`refresh-cw`}]})},vocabulary:{noun:L(`Reboot`,`Riavvio`),order:3240}},aQ=x({owner:u(),kind:na,title:u(),nameField:u(),fields:h(u(),w()),secretPaths:C(u()),rows:r().int().nonnegative()}),oQ=x({id:OB,name:u(),rev:r().int(),updatedAt:r(),data:kB}),sQ={owner:u().min(1),kind:na},cQ={name:`record-entries`,scope:`system`,mode:`singleton`,methods:{listEntryKinds:D(x({}),x({kinds:C(aQ)}),{auth:`admin`}),listEntries:D(x({...sQ}),x({entries:C(oQ)}),{auth:`admin`}),putEntry:D(x({...sQ,id:OB.optional(),data:kB,ifRev:r().int().min(1).optional()}),x({id:u(),rev:r().int()}),{kind:`mutation`,auth:`admin`}),deleteEntry:D(x({...sQ,id:OB}),x({deleted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.INTERNAL}},gEe=`camstack`,lQ=`recorder`,uQ=x({profile:u(),startMs:r(),endMs:r()}),dQ=S([`read`,`unreadable`]),fQ=x({deviceId:r(),read:dQ,ranges:C(uQ),profilesWithFootage:C(u())}),pQ=x({deviceId:r(),read:dQ,days:C(r())}),mQ=x({deviceId:r(),localMasterPath:u().nullable(),playbackUrl:u().nullable(),playbackEndpoints:C(u())}),hQ=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:u().optional(),coverageAsOf:r().optional()}),gQ=x({source:u(),label:u(),addonId:u().optional(),availability:hQ}),_Q=x({transport:S([`archive`,`stream`,`realtime`]),coverage:S([`continuous`,`sparse`]),seek:S([`free`,`forward`,`segment`]),stepBack:y(),scrub:y(),rates:C(r().positive()).min(1).readonly(),exclusive:y()}),vQ=a(`kind`,[x({kind:m(`hls`),manifest:mQ}),x({kind:m(`clip`),source:u(),clipId:u(),startsAtMs:r()}),x({kind:m(`none`),reason:u()})]),yQ={name:`recording`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Camera],methods:{listSources:D(x({deviceId:r()}),C(gQ).readonly(),{kind:`query`,auth:`protected`}),getAvailability:D(x({deviceId:r(),provider:u().min(1),fromMs:r(),toMs:r(),profile:u().optional()}),fQ,{kind:`query`,auth:`protected`}),getDaysWithRecordings:D(x({deviceId:r(),provider:u().min(1),fromMs:r(),toMs:r(),tzOffsetMinutes:r()}),pQ,{kind:`query`,auth:`protected`}),getPlayback:D(x({deviceId:r(),provider:u().min(1),fromMs:r(),toMs:r(),profile:j.optional()}),vQ,{kind:`query`,auth:`protected`}),getPlaybackOptions:D(x({deviceId:r(),provider:u().min(1)}),_Q,{kind:`query`,auth:`protected`})},vocabulary:{noun:L(`Recording`,`Registrazione`),order:3250}},bQ=x({deviceId:r(),enabled:y(),activeMode:nl,nodeId:u(),storageBytes:r()}),xQ=x({deviceId:r(),read:S([`read`,`unreadable`]),ranges:C(uQ).readonly(),profilesWithFootage:C(u()).readonly()}),SQ=x({deviceId:r(),read:S([`read`,`unreadable`]),days:C(r()).readonly()}),CQ=x({deviceId:r(),usedBytes:r(),oldestMs:r().nullable().optional(),segments:r().optional(),residentBytes:r().optional(),residentOldestMs:r().nullable().optional()}),wQ=x({locationId:u().nullable(),locationIds:C(u()).optional(),root:u().optional(),usedBytes:r(),availableBytes:r().nullable(),totalBytes:r().nullable()}),TQ=x({nodeId:u(),totalUsedBytes:r(),devices:C(CQ),devicesRead:S([`archive`,`unavailable`]).optional(),complete:y().optional(),locations:C(wQ).optional()}),EQ=x({deviceId:r(),profile:u(),fromLocationId:u(),toLocationId:u(),bytes:r(),files:r().int()}),DQ=S([`unassigned`,`target-not-writable`,`below-threshold`,`no-headroom`]),OQ=x({deviceId:r(),profile:u(),fromLocationId:u(),toLocationId:u().nullable(),bytes:r(),reason:DQ}),kQ=x({moves:C(EQ),skipped:C(OQ),bytesToMove:r(),jobIds:C(u())}),AQ=x({throttleMbps:r().min(1).max(1e3).optional(),minMoveGb:r().min(0).optional()}),_Ee=x({deviceId:r().int(),profile:u(),locationId:u()}),vEe=x({deviceId:r().int(),locationId:u()}),yEe=x({assignments:C(_Ee),pins:C(vEe),defaultLocations:h(u(),u())}),bEe=x({deviceId:r().int(),locationId:u().nullable()}),jQ=a(`kind`,[x({kind:m(`segment`),startMs:r(),durMs:r(),bytes:r()}),x({kind:m(`gap`),nearestEdgeMs:r().nullable(),prevEndMs:r().nullable().optional()})]),MQ=x({data:b(Uint8Array)}),NQ=x({data:b(Uint8Array),gopStartMs:r(),gopDurMs:r()}),PQ=a(`kind`,[x({kind:m(`ok`),data:b(Uint8Array),gopStartMs:r(),gopDurMs:r(),reachesRequestedEnd:y()}),x({kind:m(`spans-multiple-segments`),segmentEndMs:r()})]),FQ={name:`recording-archive`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,status:{schema:bQ,kind:`command-driven`},methods:{getAvailabilityBatch:D(x({deviceIds:C(r()).min(1).max(200),fromMs:r(),toMs:r()}),C(xQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getDaysWithRecordingsBatch:D(x({deviceIds:C(r()).min(1).max(200),fromMs:r(),toMs:r(),tzOffsetMinutes:r()}),C(SQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getStorageUsage:D(x({}),TQ,{kind:`query`,auth:`admin`}),getDeviceConfig:D(x({deviceId:r()}),pl,{role:`viewer`,kind:`query`,auth:`protected`}),locateSegment:D(x({deviceId:r(),profile:u(),epochMs:r()}),jQ,{kind:`query`,auth:`admin`}),readSegmentBytes:D(x({deviceId:r(),profile:u(),startMs:r()}),MQ,{kind:`query`,auth:`admin`}),readGopBytes:D(x({deviceId:r(),profile:u(),startMs:r(),epochMs:r()}),NQ,{kind:`query`,auth:`admin`}),readWindowBytes:D(x({deviceId:r(),profile:u(),startMs:r(),fromMs:r(),toMs:r()}),PQ,{kind:`query`,auth:`admin`}),setDeviceConfig:D(x({deviceId:r(),config:pl}),pl,{kind:`mutation`,auth:`admin`}),rescanStorage:D(x({deviceId:r()}),bQ,{kind:`mutation`,auth:`admin`}),pruneFootage:D(x({deviceId:r(),reason:gc.optional()}),x({floorMs:r().nullable(),deletedBuckets:r().int(),reclaimedBytes:r().int()}),{kind:`mutation`,auth:`admin`}),deleteFootprint:D(x({deviceId:r(),fromMs:r().optional(),toMs:r().optional()}),x({deletedBuckets:r().int(),reclaimedBytes:r().int()}),{kind:`mutation`,auth:`admin`}),listOpsLog:D(vc,C(_c).readonly(),{kind:`query`,auth:`admin`}),renderGif:D(x({deviceId:r(),aroundMs:r(),preRollSec:r().min(0).max(30).default(2),postRollSec:r().min(0).max(30).default(5),maxWidth:r().int().min(120).max(1280).default(480),fps:r().int().min(1).max(15).default(5)}),x({gifBase64:u(),fromMs:r(),toMs:r()}),{kind:`mutation`,auth:`admin`}),renderClip:D(x({deviceId:r(),aroundMs:r(),preRollSec:r().min(0).max(30).default(3),postRollSec:r().min(0).max(30).default(7),maxWidth:r().int().min(160).max(1920).default(640)}),x({clipBase64:u(),mime:u(),fromMs:r(),toMs:r(),bytes:r().int()}),{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:D(Cl,x({paused:m(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:D(Cl,x({resumed:m(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:D(Cl,x({refreshed:m(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:D(wl,x({jobId:u()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:D(x({jobId:u()}),bl.nullable(),{auth:`admin`}),cancelStorageMigrationMove:D(x({jobId:u()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateFootage:D(Sl,x({jobId:u()}),{kind:`mutation`,auth:`admin`}),listRelocateJobs:D(x({}),C(bl).readonly(),{kind:`query`,auth:`admin`}),getRelocateResidue:D(Xl,Zl,{kind:`query`,auth:`admin`}),reconcileLedgerAgainstDisk:D(Ql,nu,{kind:`mutation`,auth:`admin`}),cancelRelocateJob:D(x({jobId:u()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),planStorageRebalance:D(AQ,kQ,{kind:`query`,auth:`admin`}),startStorageRebalance:D(AQ,kQ,{kind:`mutation`,auth:`admin`}),getPlacement:D(x({}),yEe,{kind:`query`,auth:`admin`}),setDevicePlacement:D(bEe,x({ok:m(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:k.STORAGE}},xEe=S([`queue-full`,`camera-backoff`,`sleeping`,`camera-refused`,`no-keyframe`,`decode-failed`,`no-catalog-row`,`unsupported`,`unknown-device`,`uid-missing`]),SEe=S([`deferred`,`final`]),IQ=`x-camstack-reason`;function CEe(e){let t=e.replace(/[\u2013\u2014\u2212]/g,`-`).replace(/[\u2018\u2019\u201b]/g,`'`).replace(/[\u201c\u201d]/g,`"`).replace(/\u2026/g,`...`).replace(/[\u00a0\u2007\u202f]/g,` `),n=``;for(let e of t){let t=e.codePointAt(0)??0;t<32||t===127?n+=` `:t>255?n+=`?`:n+=e}return n.slice(0,500).trim()}var LQ=`x-camstack-reason-code`,RQ=`x-camstack-disposition`,wEe=`x-camstack-clip-transport`,zQ=x({id:u(),source:u(),kind:S([`motion`,`object`,`audio`,`native`]),timeRange:x({startMs:r(),endMs:r()}),labels:C(u()).max(3).optional(),thumbnail:u().optional(),stillAtMs:r().optional(),eventIds:C(u()).optional(),eventCount:r().int().nonnegative().optional(),holes:C(x({startMs:r(),endMs:r()})).optional(),thumbnailMint:u().optional(),thumbnailUnavailable:x({reason:S([`sleeping`,`camera-refused`,`no-keyframe`,`unsupported`])}).optional(),catalogAsOf:r().optional(),nativeTypes:C(u()).optional(),behaviours:C(u()).optional(),streams:x({sub:x({id:u(),bytes:r().optional()}).optional(),main:x({id:u(),bytes:r().optional()}).optional()}).optional(),supportSub:y().optional(),playable:y().optional(),unplayableReason:u().optional(),inProgress:y().optional()}),BQ=x({playbackUrl:u(),format:S([`hls`,`mp4`]).optional(),served:j.optional(),playbackEndpoints:C(u()).optional(),token:u().optional()}),VQ=S([`authorised`]),TEe=50*1024*1024,EEe=500*1024*1024,HQ=x({base64:u(),contentType:u(),name:u(),bytes:r().int().nonnegative(),served:j,durationMs:r().positive().optional()}),UQ=x({ticket:io,contentType:u(),name:u(),served:j,durationMs:r().positive().optional()}),WQ=S([`opus`,`pcmu`,`none`]),GQ=S([`not-requested`,`unsupported-ask`]),KQ=x({url:u().min(1),expiresAtMs:r(),transport:m(`forward-only`),served:j,servedAudio:WQ,audioReason:GQ.optional()}),qQ=[.25,.5,1,1.5,2,4,8],JQ=[.25,.5,1,1.5,2,4],YQ=[.25,.5,1],XQ=x({transport:S([`stream`,`file`]),seek:S([`forward`,`free`]),stepBack:y(),scrub:y(),rates:C(r().positive()).min(1).readonly()}),ZQ=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:u().optional(),catalogAsOf:r().optional()}),QQ=x({source:u(),label:u(),addonId:u().optional(),availability:ZQ}),$Q={name:`videoclips`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/clips-browser`,tab:`recording`,topTab:!0,label:`Clips`,order:100}},methods:{listClips:D(x({deviceId:r(),since:r(),until:r(),limit:r().int().positive().optional(),provider:u().min(1)}),C(zQ).readonly(),{kind:`query`,auth:`protected`}),listSources:D(x({deviceId:r()}),C(QQ).readonly(),{kind:`query`,auth:`protected`}),getClipPlayback:D(x({deviceId:r(),clipId:u(),profile:j.optional()}),BQ,{kind:`query`,auth:`protected`}),readClipBytes:O(x({deviceId:r(),clipId:u().min(1),provider:u().min(1),profile:j.optional(),maxBytes:r().int().positive().optional(),wake:VQ.optional()}),HQ,{kind:`query`,auth:`protected`}),offerClipBytes:O(x({deviceId:r(),clipId:u().min(1),provider:u().min(1),profile:j.optional(),maxBytes:r().int().positive().optional(),wake:VQ.optional()}),UQ,{kind:`query`,auth:`protected`}),dialClipStream:O(x({deviceId:r(),clipId:u().min(1),provider:u().min(1),profile:j.optional(),audio:WQ.optional(),wake:VQ.optional()}),KQ,{kind:`query`,auth:`protected`}),getPlaybackOptions:O(x({deviceId:r(),provider:u().min(1)}),XQ,{kind:`query`,auth:`protected`})},vocabulary:{noun:L(`Video clips`,`Clip video`),order:3330}},DEe={stream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:JQ},realtimeStream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:YQ},file:{transport:`file`,seek:`free`,stepBack:!0,scrub:!0,rates:qQ}},e$=r().min(.25).max(32),t$=x({fromSec:r().nonnegative(),toSec:r().nonnegative()}).refine(e=>e.toSec>e.fromSec,{message:`dense range must have toSec > fromSec`}),n$=x({everyMs:r().int().positive(),ranges:C(t$).min(1).max(200)}),r$=x({everyMs:r().int().positive(),outputFps:r().int().min(1).max(60).optional(),dense:n$.optional()}).superRefine((e,t)=>{e.dense!==void 0&&e.dense.everyMs>=e.everyMs&&t.addIssue({code:ue.custom,message:`dense.everyMs must be strictly smaller than the base everyMs`,path:[`dense`,`everyMs`]})}),i$=x({speed:e$.optional(),timelapse:r$.optional(),includeAudio:y(),maxLifeMs:r().int().positive(),deleteAfterDownload:y(),title:u().max(200).optional(),notifyTargetIds:C(u().min(1)).max(20).optional()}).superRefine((e,t)=>{e.speed!==void 0&&e.timelapse!==void 0&&t.addIssue({code:ue.custom,message:`speed and timelapse are mutually exclusive`,path:[`timelapse`]})}),a$=S([`queued`,`rendering`,`ready`,`failed`,`expired`,`deleted`]),o$=x({kind:m(`footage`),deviceId:r(),profiles:C(u()).min(1),fromMs:r(),toMs:r()}),s$=x({kind:m(`clip`),deviceId:r(),provider:u().min(1),source:u().min(1),sourceLabel:u().min(1),clipId:u().min(1),catalogWindow:x({sinceMs:r(),untilMs:r()}),profile:S([`high`,`mid`,`low`]),wake:VQ.optional()}),c$=a(`kind`,[o$,s$]),l$=x({id:u(),deviceId:r(),profile:u(),fromMs:r(),toMs:r(),subject:c$.optional(),options:i$,state:a$,progressPct:r().nullable(),fileBytes:r().nullable(),expiresAt:r(),deleteAfterDownload:y(),downloadedAt:r().nullable(),createdAt:r(),createdBy:u(),error:u().nullable()}),u$=S([`catalog-miss`,`catalog-unreachable`,`no-file-for-window`,`clip-in-progress`,`unsupported-option`,`sleeping`,`camera-refused`,`fetch-failed`,`too-large-to-transfer`,`wake-expired`,`wake-timeout`]);function OEe(e,t){return t.length>0?`${e}: ${t}`:e}function kEe(e){if(e===null)return null;let t=e.split(`:`,1)[0]??``,n=u$.safeParse(t.trim());return n.success?n.data:null}var d$=x({url:u(),endpoints:C(u())}),AEe=50*1024*1024,f$=x({base64:u(),contentType:u(),name:u(),bytes:r().int().nonnegative()});function p$(e){return e.profiles!==void 0&&e.profiles.length>0?[...e.profiles]:typeof e.profile==`string`&&e.profile.length>0?[e.profile]:[]}var jEe=x({deviceId:r(),profile:u().optional(),profiles:C(u()).min(1).optional(),fromMs:r().optional(),toMs:r().optional(),subject:c$.optional(),options:i$}).superRefine((e,t)=>{if(e.subject?.kind===`clip`){e.subject.deviceId!==e.deviceId&&t.addIssue({code:ue.custom,message:`subject.deviceId (${e.subject.deviceId}) must equal deviceId (${e.deviceId}) — the top-level field is what per-device scope enforcement reads`,path:[`subject`,`deviceId`]}),(e.fromMs!==void 0||e.toMs!==void 0)&&t.addIssue({code:ue.custom,message:`a clip export asks for no time range: the camera chose the boundaries and they are read from the catalog row`,path:[`fromMs`]});return}e.subject?.kind===`footage`&&e.subject.deviceId!==e.deviceId&&t.addIssue({code:ue.custom,message:`subject.deviceId (${e.subject.deviceId}) must equal deviceId (${e.deviceId})`,path:[`subject`,`deviceId`]});let n=e.subject?.kind===`footage`?e.subject.fromMs:e.fromMs,r=e.subject?.kind===`footage`?e.subject.toMs:e.toMs;(typeof n!=`number`||typeof r!=`number`)&&t.addIssue({code:ue.custom,message:`a footage export needs fromMs and toMs`,path:[`fromMs`]}),(e.subject?.kind===`footage`?[...e.subject.profiles]:p$(e)).length<1&&t.addIssue({code:ue.custom,message:`pass profiles[] (min 1) or legacy profile`,path:[`profiles`]})});function MEe(e){if(e.subject!==void 0)return e.subject;let t=p$(e);if(typeof e.fromMs!=`number`||typeof e.toMs!=`number`)throw Error(`recording-export: a footage export needs fromMs and toMs`);return{kind:`footage`,deviceId:e.deviceId,profiles:t,fromMs:e.fromMs,toMs:e.toMs}}function NEe(e){return e.subject===void 0?{kind:`footage`,deviceId:e.deviceId,profiles:[e.profile],fromMs:e.fromMs,toMs:e.toMs}:e.subject}var m$={name:`recording-export`,scope:`system`,mode:`singleton`,methods:{createExport:D(jEe,l$,{role:`viewer`,kind:`mutation`,auth:`protected`}),listExports:D(x({deviceId:r().optional()}),C(l$),{role:`viewer`,kind:`query`,auth:`protected`}),getExport:D(x({exportId:u()}),l$,{role:`viewer`,kind:`query`,auth:`protected`}),cancelExport:D(x({exportId:u()}),l$,{role:`viewer`,kind:`mutation`,auth:`protected`}),deleteExport:D(x({exportId:u()}),l$,{role:`viewer`,kind:`mutation`,auth:`protected`}),getDownloadUrl:D(x({exportId:u()}),d$,{role:`viewer`,kind:`query`,auth:`protected`}),readExportBytes:D(x({exportId:u()}),f$,{kind:`query`,auth:`protected`})},vocabulary:{notOperatorFacing:`recording exports — requested from the timeline, not an automation step`}},h$=S([`continuous`,`motion`,`person`,`vehicle`,`animal`,`lineCrossing`,`intrusion`,`loitering`,`alarmInput`]),g$=x({trigger:h$,day:r().int().min(0).max(6).meta(A(`none`)),startMinute:r().int().min(0).max(1439).meta(A(`none`)),endMinute:r().int().min(1).max(1440).meta(A(`none`))}),_$=x({id:u(),label:u().optional(),status:S([`ok`,`unformatted`,`error`,`offline`,`unknown`]),capacityMb:r().nullable(),freeMb:r().nullable(),writable:y().optional()}),v$=a(`kind`,[x({kind:m(`present`),volumes:C(_$)}),x({kind:m(`absent`),reason:u()}),x({kind:m(`unknown`),reason:u()})]),y$=x({id:u(),enabled:y(),isVideo:y(),codec:u().nullable(),resolution:u().nullable(),overwriteWhenFull:y().nullable()}),b$=x({storage:v$,tracks:C(y$),primaryTrackId:u().nullable(),enabled:y().nullable(),overwriteWhenFull:y().nullable(),preRecordSec:r().nullable().meta(A(`duration`)),postRecordSec:r().nullable().meta(A(`duration`)),segmentMinutes:r().nullable().meta(A(`none`)),windows:C(g$),unreadableWindows:r().meta(A(`count`)),recordingToNowhere:y(),lastFetchedAt:r()}),x$=x({min:r(),max:r(),step:r()}),S$=x({values:C(r()).min(1),sentinel:x({value:r(),meaning:S([`no-limit`,`disabled`])}).optional()}),C$=x({readable:y(),writable:y(),reason:u().optional()}),w$=x({support:C$,granularityMinutes:r(),triggers:C(h$),supportsOverlappingTriggers:y()}),T$=x({enabled:C$,overwriteWhenFull:C$,preRecordSec:C$,preRecordSecRange:x$.optional(),preRecordSecAllowed:S$.optional(),postRecordSec:C$,postRecordSecRange:x$.optional(),postRecordSecAllowed:S$.optional(),segmentMinutes:C$,segmentMinutesRange:x$.optional(),segmentMinutesAllowed:S$.optional(),schedule:w$}),E$=x({enabled:y().optional(),overwriteWhenFull:y().optional(),preRecordSec:r().optional(),postRecordSec:r().optional(),segmentMinutes:r().optional(),windows:C(g$).optional()}),D$={name:`recording-onboard`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`recording-onboard`,tab:`recording`}},methods:{getOptions:D(x({deviceId:r()}),T$),setSettings:D(x({deviceId:r(),settings:E$}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`recordingOnboard.on`,label:L(`On-camera recording on`,`Registrazione a bordo attiva`),phrase:L(`Turn on recording to the card of {device}`,`Attiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!0}}},{id:`recordingOnboard.off`,label:L(`On-camera recording off`,`Registrazione a bordo spenta`),phrase:L(`Turn off recording to the card of {device}`,`Disattiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!1}}}]})},status:{schema:b$,kind:`poll`},runtimeState:b$,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:L(`On-camera recording`,`Registrazione a bordo`),order:3260,state:[{kind:`boolean`,field:`recordingToNowhere`,label:L(`Recording to nowhere`,`Registra nel vuoto`),whenTrue:L(`When {device} is recording with no card to write to`,`Quando {device} registra senza una scheda su cui scrivere`),whenFalse:L(`When {device} has a card to record to again`,`Quando {device} ha di nuovo una scheda su cui registrare`),icon:`hard-drive`}]}},O$=x({active:y(),reason:u(),lastChangedAt:r()}),k$=O$.extend({lastFetchedAt:r()}),A$={name:`recording-signal`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Camera],methods:{getStatus:D(x({deviceId:r()}),O$)},status:{schema:O$,kind:`push`,empty:{active:!1,reason:`unknown`,lastChangedAt:0}},runtimeState:k$,durability:`session`,history:`none`,vocabulary:{noun:L(`Recording signal`,`Segnale di registrazione`),order:3270,state:[{kind:`boolean`,field:`active`,label:L(`Recording`,`In registrazione`),whenTrue:L(`When {device} starts recording`,`Quando {device} inizia a registrare`),whenFalse:L(`When {device} stops recording`,`Quando {device} smette di registrare`),icon:`circle-dot`}]}},j$=x({kind:m(`cap`),deviceId:r().int().nonnegative(),cap:u().min(1),method:u().min(1),args:h(u(),w()).optional(),argUnits:h(u(),u().min(1)).optional()}),M$=x({action:j$}),N$=x({key:u().refine(jT,{message:`a lowercase slug`}),name:u().min(1).max(60)});function PEe(e,t){let n=new Set,r=new Set,i=new Set;e.sources.forEach((a,o)=>{let s=(e,n)=>{t.addIssue({code:`custom`,message:e,path:[`sources`,o,n]})};n.has(a.id)&&s(`source id "${a.id}" is used twice`,`id`),n.add(a.id);let c=a.name.trim().toLowerCase();if(r.has(c)&&s(`source name "${a.name}" is used twice`,`name`),r.add(c),a.kind===`digits`&&(i.has(a.number)&&s(`channel ${a.number} is declared twice`,`number`),i.add(a.number)),a.kind===`ir`){let e=WT(a);e!==null&&s(e,`payload`)}for(let t of UT(a))OT(t)?s(`"${a.name}" presses ${t}, a layout widget, not a command`,`steps`):e.bindings[t]===void 0&&s(`"${a.name}" presses ${t}, which is not bound`,`steps`)}),e.sources.forEach((n,r)=>{for(let i of e.sources)if(!(i.kind!==`digits`||i===n))for(let e of[`name`,`id`])n[e].trim()===i.number&&t.addIssue({code:`custom`,message:`${e} "${n[e]}" is the channel number of "${i.name}"`,path:[`sources`,r,e]})})}var P$=x({index:r().int().nonnegative(),id:u().nullable(),name:u().nullable(),reason:u()}),F$=x({layoutTemplateId:u().min(1).nullable(),defaultTransmitterId:r().int().nonnegative().nullable().default(null),bindings:h(u(),M$),customButtons:C(N$).max(100),sources:C(VT).max(200).default([]),stepDelayMs:r().int().min(100).max(HT).default(500),refusedSources:C(P$).optional()}).superRefine((e,t)=>{let n=Object.keys(e.bindings);n.length>200&&t.addIssue({code:`custom`,message:`too many bindings`,path:[`bindings`]});for(let e of n)OT(e)?t.addIssue({code:`custom`,message:`"${e}" is a layout widget, not a command: it cannot be bound`,path:[`bindings`,e]}):PT(e)||t.addIssue({code:`custom`,message:`"${e}" is not a role`,path:[`bindings`,e]});let r=new Set;e.customButtons.forEach((e,n)=>{r.has(e.key)&&t.addIssue({code:`custom`,message:`custom button "${e.key}" is listed twice`,path:[`customButtons`,n,`key`]}),r.add(e.key)});for(let e of n){let n=NT(e);n!==null&&!r.has(n)&&t.addIssue({code:`custom`,message:`${e} is bound but has no entry in customButtons`,path:[`bindings`,e]})}PEe(e,t)}),FEe=ce({sources:C(w())}),IEe=x({id:u(),name:u()}).partial();function LEe(e){let t=FEe.safeParse(e);if(!t.success)return I$(F$.safeParse(e));let n=[],r=[];t.data.sources.forEach((e,t)=>{let i=VT.safeParse(e),a=i.success&&i.data.kind===`ir`?WT(i.data):null;if(i.success&&a===null){n.push(e);return}let o=IEe.safeParse(e),s=a??i.error?.issues[0]?.message??`not a source`;r.push({index:t,id:o.success?o.data.id??null:null,name:o.success?o.data.name??null:null,reason:s})});let i=I$(F$.safeParse({...t.data,sources:n}));return!i.success||r.length===0?i:{success:!0,data:{...i.data,refusedSources:r}}}function I$(e){return e.success?{success:!0,data:e.data}:{success:!1,issues:e.error.issues.length}}var REe={layoutTemplateId:null,defaultTransmitterId:null,bindings:{},customButtons:[],sources:[],stepDelayMs:500},zEe=x({power:x({state:S([`on`,`off`]),at:r()}).nullable(),muted:x({value:y(),at:r()}).nullable(),source:x({name:u(),at:r()}).nullable().default(null)}),BEe={power:null,muted:null,source:null},L$=[`rect`,`rounded`,`round`,`pill`],R$=S(L$),z$=[`neutral`,`accent`,`danger`,`red`,`green`,`yellow`,`blue`],B$=S(z$),V$=[`none`,`panel`,`divider`,`dpad`,`rocker-v`,`rocker-h`,`keypad`],H$=S(V$),U$=x({id:u().min(1).max(40),row:r().int().min(0).max(24),col:r().int().min(0).max(24),rowSpan:r().int().min(1).max(24),colSpan:r().int().min(1).max(24),icon:u().min(1).max(60).optional(),label:u().min(1).max(40).optional(),role:FT,shape:R$.optional(),tone:B$.optional(),showLegend:y().optional(),groupId:u().min(1).max(40).optional()}),W$=x({id:u().min(1).max(40),componentId:u().min(1).max(80),frame:H$,row:r().int().min(0).max(24),col:r().int().min(0).max(24),rowSpan:r().int().min(1).max(24),colSpan:r().int().min(1).max(24),title:u().min(1).max(40).optional(),size:S([`compact`,`normal`]).optional(),hideTitle:y().optional()});function G$(e,t){return e.row<t.row+t.rowSpan&&t.row<e.row+e.rowSpan&&e.col<t.col+t.colSpan&&t.col<e.col+e.colSpan}function K$(e,t){return t.row>=e.row&&t.col>=e.col&&t.row+t.rowSpan<=e.row+e.rowSpan&&t.col+t.colSpan<=e.col+e.colSpan}function VEe(e,t){let n=e.groups??[],r=new Map,i=(e,n)=>{t.addIssue({code:`custom`,message:e,path:n})};n.forEach((t,a)=>{r.has(t.id)&&i(`group id "${t.id}" is used twice`,[`groups`,a,`id`]),r.set(t.id,t),(t.row+t.rowSpan>e.rows||t.col+t.colSpan>e.columns)&&i(`group "${t.id}" leaves the grid`,[`groups`,a]);for(let e=0;e<a;e+=1){let r=n[e];if(r!==void 0&&G$(r,t)){i(`groups "${r.id}" and "${t.id}" overlap`,[`groups`,a]);return}}}),e.buttons.forEach((e,t)=>{if(e.groupId!==void 0){let n=r.get(e.groupId);if(n===void 0){i(`button "${e.id}" names the unknown group "${e.groupId}"`,[`buttons`,t,`groupId`]);return}n.frame===`divider`&&i(`a divider group ("${n.id}") holds no buttons`,[`buttons`,t,`groupId`]),K$(n,e)||i(`button "${e.id}" lies outside its group "${n.id}"`,[`buttons`,t]);return}let a=n.find(t=>G$(t,e));a!==void 0&&i(`button "${e.id}" lies inside group "${a.id}" but is not a member`,[`buttons`,t])})}var q$=x({columns:r().int().min(1).max(24),rows:r().int().min(1).max(24),buttons:C(U$).max(200),groups:C(W$).max(50).optional()}).superRefine((e,t)=>{let n=new Set,r=new Map;e.buttons.forEach((i,a)=>{if(n.has(i.id)&&t.addIssue({code:`custom`,message:`button id "${i.id}" is used twice`,path:[`buttons`,a,`id`]}),n.add(i.id),i.row+i.rowSpan>e.rows||i.col+i.colSpan>e.columns){t.addIssue({code:`custom`,message:`button "${i.id}" leaves the grid`,path:[`buttons`,a]});return}for(let e=i.row;e<i.row+i.rowSpan;e+=1)for(let n=i.col;n<i.col+i.colSpan;n+=1){let o=`${e}:${n}`,s=r.get(o);if(s!==void 0){t.addIssue({code:`custom`,message:`buttons "${s}" and "${i.id}" overlap`,path:[`buttons`,a]});return}r.set(o,i.id)}}),VEe(e,t)}),J$=x({role:FT,label:u().optional(),custom:y()}),Y$=x({layoutTemplateId:u().nullable(),commands:C(J$),sources:C(VT)}),X$=[`no-remote`,`unbound-role`,`action-failed`,`unknown-source`,`unbound-step`,`undeclared-channel`,`press-timeout`,`no-transmitter`],Z$=S(X$),Q$=a(`status`,[x({status:m(`sent`),sends:r().int().min(1)}),x({status:m(`skipped`),reason:m(`already-in-state`)}),x({status:m(`refused`),reason:Z$,detail:u().optional(),step:x({index:r().int().min(1),role:u()}).optional()})]),$$=[`play`,`pause`,`stop`,`next`,`previous`,`setMute`,`selectSource`,`playMedia`,`turnOn`,`turnOff`,`volumeUp`,`volumeDown`,`channelUp`,`channelDown`],e1=S($$),t1=a(`status`,[...Q$.options,x({status:m(`not-routed`)})]),n1=[`unknown-template`,`not-a-media-player`],r1=a(`status`,[x({status:m(`saved`)}),x({status:m(`refused`),reason:S(n1),detail:u()})]),i1=x({deviceId:r().int().nonnegative()}),HEe={version:1,targets:[{id:`remote`,cardinality:`config`,vocabulary:{cap:`remote`},deviceTypes:[M.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`}]},a1={name:`remote`,scope:`system`,mode:`singleton`,methods:{getConfig:D(i1,F$,{auth:`admin`}),setConfig:D(i1.extend({config:F$}),r1,{kind:`mutation`,auth:`admin`}),listCommands:D(i1,Y$,{auth:`protected`}),sendCommand:D(i1.extend({role:FT,repeat:r().int().min(1).max(50).default(1)}),Q$,{kind:`mutation`,auth:`protected`}),getAssumedStatus:D(i1,XT.nullable(),{auth:`protected`}),sendMediaCommand:D(i1.extend({command:e1,muted:y().optional(),source:u().optional(),mediaType:u().optional(),mediaId:u().optional(),repeat:r().int().min(1).max(50).default(1)}),t1,{kind:`mutation`,auth:`protected`})},customize:HEe,vocabulary:{notOperatorFacing:`the per-device remote setup — authored in the Customize remote editor, sent through the remote UI`}},o1=[`power`,`navigation`,`volume`,`numbers`,`media`,`colour`,`apps`,`layout`],s1=S(o1),UEe=/^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_-]*$/,c1=x({idSuffix:u().regex(/^[a-z0-9][a-z0-9_-]{0,19}$/,{message:`a short lowercase slug`}),row:r().int().min(0).max(24),col:r().int().min(0).max(24),rowSpan:r().int().min(1).max(24),colSpan:r().int().min(1).max(24),role:FT,icon:u().min(1).max(60).optional(),label:u().min(1).max(40).optional(),shape:R$.optional(),tone:B$.optional(),showLegend:y().optional()}),l1=x({id:u().max(80).regex(UEe,{message:`<namespace>:<name>, lowercase`}),name:u().min(1).max(60),nameI18n:x({en:u().min(1).max(60),it:u().min(1).max(60)}).optional(),icon:u().min(1).max(60),category:s1,size:x({rows:r().int().min(1).max(24),cols:r().int().min(1).max(24)}),group:x({frame:H$,title:u().min(1).max(40).optional()}).nullable(),buttons:C(c1).max(40)}).superRefine((e,t)=>{let n=new Set;e.buttons.forEach((r,i)=>{if(n.has(r.idSuffix)&&t.addIssue({code:`custom`,message:`button "${r.idSuffix}" is listed twice`,path:[`buttons`,i,`idSuffix`]}),n.add(r.idSuffix),r.row+r.rowSpan>e.size.rows||r.col+r.colSpan>e.size.cols){t.addIssue({code:`custom`,message:`button "${r.idSuffix}" leaves the component`,path:[`buttons`,i]});return}for(let n=0;n<i;n+=1){let a=e.buttons[n];if(a!==void 0&&G$(a,r)){t.addIssue({code:`custom`,message:`buttons "${a.idSuffix}" and "${r.idSuffix}" overlap`,path:[`buttons`,i]});return}}}),e.group?.frame===`divider`&&e.buttons.length>0&&t.addIssue({code:`custom`,message:`a divider component holds no buttons`,path:[`buttons`]})}),u1={name:`remote-layout-components`,scope:`system`,mode:`collection`,methods:{listComponents:D(x({}),C(l1),{auth:`protected`})},vocabulary:{notOperatorFacing:`the palette of the remote template editor — read-only data, never actuated`}},d1=x({deviceId:r().int().nonnegative(),resetToSource:y().optional()}),f1={name:`resync`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Container,M.Workload,M.WeatherStation],methods:{resync:D(d1,Dk,{kind:`mutation`,auth:`admin`,notOperatorFacing:`device adoption — re-aligning a device with its source is an onboarding step, not an automation action`})},vocabulary:{noun:L(`Re-sync`,`Risincronizzazione`),order:3245}},p1=3e4,m1=18e4,h1={startDwellMs:p1,stopDwellMs:m1,minSamples:2},g1={[M.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}};function _1(e){return e!==void 0&&g1[e]!==void 0}function v1(e){return e===void 0?h1:g1[e]??h1}var WEe={running:null,since:null,source:`native`,phase:null,lastFetchedAt:null},y1=S([`native`,`assigned`]),b1=x({running:y().nullable(),since:r().nullable().meta(A(`none`)),source:y1.meta({label:`Source`}),phase:u().nullable(),lastFetchedAt:r().nullable()}),x1=x({deviceId:r(),since:r().nullable(),phase:u().nullable()}),GEe=Object.values(M),S1=[M.Washer,M.Dryer,M.Dishwasher,M.Vacuum,M.LawnMower,M.MediaPlayer,M.WaterHeater,M.Humidifier,M.Fan,M.Climate,M.PetFeeder],KEe={version:1,overridable:[{path:`running`,by:`running`}],targets:[{id:`running`,cardinality:`scalar`,vocabulary:{cap:`running-state`,stateField:`running`},deviceTypes:S1,apply:`add`,path:`running`,sources:[{kind:`switch`,transforms:[{kind:`identity`}]},{kind:`binary`,transforms:[{kind:`identity`},{kind:`invert`}]},{kind:`numeric`,requiredUnit:`W`,transforms:[{kind:`threshold`,comparisons:[`gte`,`lte`],comparison:`gte`,defaultThreshold:5,defaultStartDwellMs:p1,defaultStopDwellMs:m1,deviceTypeDefaults:g1,thresholdUnit:`W`}]}],companions:[{kind:`constant`,path:`source`,value:`assigned`,when:`always`},{kind:`constant`,path:`phase`,value:null,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`always`},{kind:`transition-time`,path:`since`,sourceChangedAt:`prefer`}],sourceReport:{status:`assignment-status`,runtimeField:`source`,nativeValue:`native`,assignedValue:`assigned`},advancedExpression:!0}]},C1={name:`running-state`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:GEe,methods:{},events:{onStarted:{data:x1,trigger:{category:T.RunningStarted,label:L(`Started running`,`Ha iniziato a funzionare`),phrase:L(`When {device} starts running`,`Quando {device} inizia a funzionare`),icon:`play`}},onFinished:{data:x1,trigger:{category:T.RunningFinished,label:L(`Finished`,`Ha finito`),phrase:L(`When {device} finishes`,`Quando {device} finisce`),icon:`square`}}},status:{schema:b1,kind:`push`},runtimeState:b1,durability:`restored`,history:{fields:{running:{kind:`boolean`}}},volatileStateFields:[`lastFetchedAt`],customize:KEe,vocabulary:{noun:L(`Running`,`In funzione`),order:2120,state:[{kind:`boolean`,field:`running`,label:L(`Running`,`In funzione`),whenTrue:L(`When {device} starts`,`Quando {device} inizia`),whenFalse:L(`When {device} finishes`,`Quando {device} finisce`),icon:`play`}],overrides:{byType:{[M.Washer]:{state:{running:{whenTrue:L(`When the washing machine starts`,`Quando la lavatrice inizia`),whenFalse:L(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}},events:{onStarted:{phrase:L(`When the washing machine starts`,`Quando la lavatrice inizia`)},onFinished:{phrase:L(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}}},[M.Dryer]:{state:{running:{whenTrue:L(`When the dryer starts`,`Quando l'asciugatrice inizia`),whenFalse:L(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}},events:{onStarted:{phrase:L(`When the dryer starts`,`Quando l'asciugatrice inizia`)},onFinished:{phrase:L(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}}},[M.Dishwasher]:{state:{running:{whenTrue:L(`When the dishwasher starts`,`Quando la lavastoviglie inizia`),whenFalse:L(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}},events:{onStarted:{phrase:L(`When the dishwasher starts`,`Quando la lavastoviglie inizia`)},onFinished:{phrase:L(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}}}}}}},w1=u(),qEe=[`day`,`ir`,`night`,`dawn`,`dusk`],T1=S([`skip`,`judge-anyway`]),JEe=`__diverged__`,E1=S([`matched`,`diverged`,`unknown`]),D1=S([`no-reference-for-condition`,`view-shifted`,`no-vision-profile`,`encoder-model-changed`,`no-snapshot`]),O1=x({embedding:C(r()),modelId:u(),condition:w1,capturedAt:r(),thumbnailMediaId:r().int().optional(),anchorEmbedding:C(r()).optional()}),k1=x({id:u(),label:u(),references:C(O1),textPrompts:C(u()).optional(),referenceCount:r(),currentlyMatched:y()}),A1=a(`mode`,[x({mode:m(`similarity`),threshold:r().min(0).max(1),hysteresisCount:r().int().positive()}),x({mode:m(`llm`),prompt:u(),profileId:u().optional(),hysteresisCount:r().int().positive()})]),j1=.85,M1=`skip`,N1=8e3,P1=x({enabled:y().default(!1),prompt:u().min(1).max(1e3),profileId:u().optional(),timeoutMs:r().int().min(1e3).max(2e4).default(N1),maxImagePx:r().int().min(64).max(2048).default(448),onTimeout:S([`flip`,`hold`]).default(`hold`)}),F1=x({id:u(),label:u(),roi:CV,enabled:y(),triggerMode:S([`periodic`,`on-motion`,`both`]),checkIntervalSec:r().optional(),check:A1,states:C(k1),currentStateId:u().nullable(),lastCheckedAt:r().nullable(),lastConfidence:r().nullable(),currentCondition:w1.nullable(),availability:S([`ok`,`unavailable`]),unavailableReason:u().nullable(),baselineStateId:u().nullable(),emit:S([`latched`,`live`]).default(`latched`),verdict:E1,latched:y(),armedAt:r(),divergedAt:r().nullable(),restoredAt:r().nullable(),quietSeconds:r().int().min(0).max(3600).default(60),minObservationSpacingSec:r().int().min(0).max(3600).default(120),confirm:P1.optional(),anchorThreshold:r().min(0).max(1).default(j1),autoRestore:y().default(!1),onUncoveredCondition:T1.default(M1),suspendedCondition:w1.nullable().default(null),unavailable:D1.nullable(),coveredConditions:C(w1)}),I1=x({monitors:C(F1),lastFetchedAt:r()}),L1=x({deviceId:r(),status:I1.nullable()}),R1={name:`scene-monitor`,role:{feature:`scenes`},scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[M.Camera],methods:{listScenes:D(x({deviceId:r()}),I1),listScenesBatch:D(x({deviceIds:C(r()).min(1).max(200)}),C(L1).readonly()),createScene:D(x({deviceId:r(),label:u(),roi:CV,check:A1,triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:r().optional()}),F1,{kind:`mutation`,auth:`admin`}),updateScene:D(x({deviceId:r(),monitorId:u(),patch:x({label:u().optional(),roi:CV.optional(),enabled:y().optional(),triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:r().optional(),check:A1.optional(),emit:S([`latched`,`live`]).optional(),quietSeconds:r().int().min(0).max(3600).optional(),minObservationSpacingSec:r().int().min(0).max(3600).optional(),anchorThreshold:r().min(0).max(1).optional(),autoRestore:y().optional(),onUncoveredCondition:T1.optional(),confirm:P1.nullable().optional()})}),v(),{kind:`mutation`,auth:`admin`}),deleteScene:D(x({deviceId:r(),monitorId:u()}),v(),{kind:`mutation`,auth:`admin`}),captureReference:D(x({deviceId:r(),monitorId:u(),stateId:u().optional(),label:u().optional(),condition:w1.optional()}),x({stateId:u(),referenceCount:r()}),{kind:`mutation`,auth:`admin`}),deleteReference:D(x({deviceId:r(),monitorId:u(),stateId:u(),index:r()}),v(),{kind:`mutation`,auth:`admin`}),recheckNow:D(x({deviceId:r(),monitorId:u()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`sceneMonitor.recheck`,label:L(`Re-check a scene`,`Ricontrolla una scena`),phrase:L(`Re-check {monitorId} on {device} now`,`Ricontrolla subito {monitorId} su {device}`),icon:`scan-search`,openArgs:[{key:`monitorId`,label:L(`Scene`,`Scena`),offer:{kind:`dynamic`,from:`status`,field:`monitors`,valueKey:`id`,labelKey:`label`}}]}]}),resetScene:D(x({deviceId:r(),monitorId:u(),recapture:y().optional()}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:I1,kind:`push`},runtimeState:I1,durability:`session`,history:`none`,vocabulary:{noun:L(`Scene watch`,`Controllo della scena`),order:3280,extraEvents:[{category:T.EnrichmentSceneStateChanged,label:L(`Scene changed`,`Scena cambiata`),phrase:L(`When a watched scene on {device} changes`,`Quando cambia una scena controllata su {device}`),icon:`scan-search`}]}},z1=x({schedulerId:u().min(1)}),B1={name:`schedulers`,scope:`system`,mode:`singleton`,methods:{list:D(x({}),C(F_),{auth:`admin`}),get:D(z1,x({scheduler:F_.nullable()}),{auth:`admin`}),create:D(x({scheduler:P_}),x({scheduler:F_}),{kind:`mutation`,auth:`admin`}),update:D(x({schedulerId:u().min(1),scheduler:P_}),x({scheduler:F_}),{kind:`mutation`,auth:`admin`}),delete:D(z1,v(),{kind:`mutation`,auth:`admin`}),setEnabled:D(x({schedulerId:u().min(1),profileId:u().min(1).optional(),enabled:y()}),x({scheduler:F_}),{kind:`mutation`,auth:`admin`}),preview:D(x({schedulerId:u().min(1),date:u().regex(L_).optional()}),pde,{auth:`admin`}),conflicts:D(x({scheduler:P_,schedulerId:u().min(1).optional()}),x({conflicts:C(mde)}),{auth:`admin`}),getStatus:D(x({}),C(gde),{auth:`admin`}),getTraces:D(z1,x({traces:C(V_)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`time schedulers — authored on their own page, not device actions`}},V1=x({isRunning:y(),lastRunAt:r(),lastRunSuccess:y().nullable(),lastError:u().nullable(),lastChangedAt:r()}),H1={name:`script-runner`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Script],methods:{run:D(x({deviceId:r().int().nonnegative(),variables:h(u(),w()).optional()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.run`,label:L(`Run script`,`Esegui lo script`),phrase:L(`Run {device}`,`Esegui {device}`),icon:`scroll-text`,hold:{effects:[{field:`isRunning`,value:!0}],holdMs:dY}}]}),stop:D(x({deviceId:r().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.stop`,effect:{field:`isRunning`,value:!1},label:L(`Stop script`,`Ferma lo script`),phrase:L(`Stop {device}`,`Ferma {device}`),icon:`square`}]})},status:{schema:V1,kind:`push`},runtimeState:V1,durability:`session`,history:`none`,vocabulary:{noun:L(`Script`,`Script`),order:2090,state:[{kind:`boolean`,field:`isRunning`,label:L(`Running`,`In esecuzione`),whenTrue:L(`When {device} starts running`,`Quando {device} parte`),whenFalse:L(`When {device} finishes`,`Quando {device} termina`),icon:`scroll-text`}]}},U1=S([`workspace`,`baked`,`data-root`]),W1=S([`idle`,`checking`,`staging`,`pending-restart`,`awaiting-confirmation`]),G1=S([`in-sync`,`behind-patch`,`behind-series`,`ahead`,`unknown`]),K1=x({state:G1,seedVersion:u().nullable(),contractVersion:u().nullable(),contractSource:S([`registry`,`running`]).nullable(),message:u()}),q1=S([`docker`,`electron`,`native`,`contradictory`,`unknown`]),J1=x({fact:S([`dockerenv-file`,`proc-1-cgroup`,`platform`,`electron-app-version-env`]),mode:S([`observed`,`declared`]),holds:y(),detail:u()}),Y1=x({kind:q1,evidence:C(J1),currentVersion:u().nullable()}),X1=x({fromVersion:u(),toVersion:u().nullable(),atMs:r(),reason:u()}),Z1=x({version:u(),update:x({available:y(),downloaded:y(),version:u().nullable(),checking:y(),error:u().nullable()}),stateAtMs:r(),stale:y()}),Q1=S([`not-electron`,`no-app-state`,`app-state-stale`,`not-downloaded`]),$1=x({accepted:y(),reason:Q1.nullable()}),e0=x({runnerId:u(),addonIds:C(u()),reason:u()}),t0=x({checkedAtMs:r(),expected:r(),running:r(),failed:C(u()),refused:C(e0),missing:C(u()),pending:C(u()).optional(),planKnown:y()}),n0=x({packageName:u(),runningVersion:u().nullable(),nodeRuntimeVersion:u().nullable(),activeVersion:u().nullable(),installedVersion:u().nullable().optional(),restartRequired:y().optional(),previousVersion:u().nullable(),seedVersion:u().nullable(),latestVersion:u().nullable(),updateAvailable:y(),bootMode:U1,updateState:W1,pendingVersion:u().nullable(),rolledBack:X1.nullable(),stateFileCorrupt:y(),lastCheckedAtMs:r().nullable(),imageContract:K1.optional(),wrapper:Y1.optional(),runners:t0.optional(),desktopApp:Z1.optional()}),r0=x({packageName:u(),runningVersion:u().nullable(),latestVersion:u().nullable(),updateAvailable:y(),checkedAtMs:r(),error:u().nullable(),pendingVersion:u().nullable().optional(),restartRequired:y().optional()}),i0=S([`staged`,`restart-scheduled`,`already-current`,`refused`,`failed`]),a0=x({addonId:u(),reason:u(),remedy:u()}),o0=x({accepted:y(),targetVersion:u().nullable(),restarting:y(),message:u(),outcome:i0.optional(),reason:u().nullable().optional(),error:u().nullable().optional(),blockers:C(a0).optional(),unmet:C(ti).optional(),requiredAddonUpdates:C(ni).optional()}),s0=x({heapMb:r().int().nullable(),rssBudgetMb:r().int().nullable()}),YEe=x({heapMb:r().int().min(512).max(65536).nullable(),rssBudgetMb:r().int().min(512).max(65536).nullable().optional()}),XEe=s0.extend({restartRequired:y()}),c0={name:`server-management`,scope:`system`,mode:`singleton`,methods:{getServerPackageStatus:D(v(),n0,{auth:`admin`}),checkServerUpdate:D(v(),r0,{kind:`mutation`,auth:`admin`}),applyServerUpdate:D(x({version:u().optional(),acknowledgeRefusals:y().optional()}),o0,{kind:`mutation`,auth:`admin`,timeoutMs:16*6e4}),installDesktopUpdate:D(v(),$1,{kind:`mutation`,auth:`admin`}),rollbackServerUpdate:D(v(),o0,{kind:`mutation`,auth:`admin`}),restartServer:D(v(),o0,{kind:`mutation`,auth:`admin`}),getLaunchOverrides:D(v(),s0,{auth:`admin`}),setLaunchOverrides:D(YEe,XEe,{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:k.CLUSTER}},l0={Seconds:`seconds`,Plays:`plays`},u0={Camera:`camera`,Fallback:`fallback`},d0=x({min:r().positive(),max:r().positive(),step:r().positive()}),f0=x({allowedSeconds:C(r().positive()).nullable(),rangeSeconds:d0.nullable(),defaultSeconds:r().positive(),allowedPlays:C(r().int().positive()).nullable().default(null),rangePlays:d0.nullable().default(null),defaultPlays:r().int().positive().nullable().default(null),unit:S([l0.Seconds,l0.Plays]),secondsPerPlay:r().positive().nullable(),source:S([u0.Camera,u0.Fallback]),fetchedAt:r()}),p0=x({active:y(),activeUntil:r().nullable(),durationSeconds:r().nullable(),plays:r().int().positive().nullable().default(null),activeUntilEstimated:y().default(!1),lastTriggeredAt:r()}),m0=x({deviceId:r().int().nonnegative(),durationSeconds:r().positive().optional(),plays:r().int().positive().optional()}).refine(e=>e.durationSeconds===void 0||e.plays===void 0,{message:`a siren trigger takes durationSeconds or plays, not both`,path:[`plays`]}),h0=p0.extend({lastFetchedAt:r()}),g0={name:`siren`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Siren],methods:{getOptions:D(x({deviceId:r().int().nonnegative()}),f0,{kind:`query`,auth:`protected`}),getPlayChoices:D(x({deviceId:r().int().nonnegative()}),C(r().int().positive()),{kind:`query`,auth:`protected`}),trigger:D(m0,p0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.trigger`,label:L(`Sound the siren`,`Fai suonare la sirena`),phrase:L(`Sound {device}`,`Fai suonare {device}`),icon:`siren`,args:{}},{id:`siren.triggerPlays`,label:L(`Sound the siren N times`,`Fai suonare la sirena N volte`),phrase:L(`Sound {device} {plays} times`,`Fai suonare {device} {plays} volte`),icon:`siren`,openArgs:[{key:`plays`,label:L(`Plays`,`Riproduzioni`),offer:{kind:`dynamic`,from:`method`,method:`getPlayChoices`,valueKind:`number`}}]}]}),stop:D(x({deviceId:r().int().nonnegative()}),p0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.stop`,label:L(`Silence the siren`,`Zittisci la sirena`),phrase:L(`Silence {device}`,`Zittisci {device}`),icon:`siren`,effect:{field:`active`,value:!1},args:{}}]})},events:{onSirenChanged:{data:x({deviceId:r(),active:y(),activeUntil:r().nullable()}),notOperatorFacing:"the `active` state trigger phrases both edges of this change"}},status:{schema:p0,kind:`command-driven`},runtimeState:h0,durability:`session`,history:`none`,vocabulary:{noun:L(`Siren`,`Sirena`),order:1170,state:[{kind:`boolean`,field:`active`,label:L(`Siren sounding`,`Sirena in funzione`),whenTrue:L(`When {device} starts sounding`,`Quando {device} inizia a suonare`),whenFalse:L(`When {device} falls silent`,`Quando {device} smette di suonare`),icon:`siren`}]}},_0=x({detected:y(),lastChangedAt:r()}),v0={name:`smoke`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[M.Sensor],methods:{},status:{schema:_0,kind:`push`},runtimeState:_0,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:L(`Smoke detector`,`Rilevatore di fumo`),order:5190,state:[{kind:`boolean`,field:`detected`,label:L(`Detected`,`Rilevato`),whenTrue:L(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:L(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}]}},y0=5*1024*1024,b0=`<!--camstack-images-->`,x0=x({ticket:io,mime:u().min(1),name:u().min(1),contentId:u().min(1),placement:S([`inline`,`attachment`]),deviceId:r().int().nonnegative().optional()}),S0=0;function C0(e){return S0+=1,`camstack_${e}_${S0.toString(36)}_${Date.now().toString(36)}`}function ZEe(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,`utf8`).toString(`base64`)}?=`}function w0(e){return(Array.isArray(e)?e:[e]).join(`, `)}function QEe(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function T0(e,t){let n=e.replace(/[\r\n"]/g,``).trim();return n.length>0?n:t}function $Ee(e){let t=Buffer.from(e).toString(`base64`),n=[];for(let e=0;e<t.length;e+=76)n.push(t.slice(e,e+76));return n.join(`\r
1114
1114
  `)}function eDe(e){return`<img src="cid:${QEe(e.contentId)}" alt="">`}function tDe(e,t){return e.replaceAll(b0,t.map(eDe).join(``))}function E0(e){let t=[`From: ${e.from}`,`To: ${w0(e.to)}`];return e.cc!==void 0&&e.cc.length>0&&t.push(`Cc: ${w0(e.cc)}`),e.bcc!==void 0&&e.bcc.length>0&&t.push(`Bcc: ${w0(e.bcc)}`),e.replyTo!==void 0&&e.replyTo.length>0&&t.push(`Reply-To: ${e.replyTo}`),t.push(`Subject: ${ZEe(e.subject)}`),t.push(`MIME-Version: 1.0`),t}function D0(e,t){return[`--${e}`,`Content-Type: text/plain; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,t]}function nDe(e,t){return[`--${e}`,`Content-Type: text/html; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,t]}function O0(e,t){let n=T0(t.mime,`image/jpeg`),r=T0(t.name,`image.jpg`),i=t.placement===`inline`?`inline`:`attachment`,a=[`--${e}`,`Content-Type: ${n}`,`Content-Transfer-Encoding: base64`,`Content-Disposition: ${i}; filename="${r}"`];return t.placement===`inline`&&a.push(`Content-ID: <${T0(t.contentId,`image`)}>`),a.push(``,$Ee(t.bytes)),a}function rDe(e,t,n){let r=C0(`alt`);return[`--${e}`,`Content-Type: multipart/alternative; boundary="${r}"`,``,...D0(r,t),...nDe(r,n),`--${r}--`]}function iDe(e,t){let n=E0(e);if(t!==void 0){let r=C0(`alt`);return n.push(`Content-Type: multipart/alternative; boundary="${r}"`,``),n.push(...D0(r,e.text),...nDe(r,t),`--${r}--`),n}return n.push(`Content-Type: text/plain; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,e.text),n}function aDe(e,t,n){let r=C0(`mix`),i=E0(e);i.push(`Content-Type: multipart/mixed; boundary="${r}"`,``),t===void 0?i.push(...D0(r,e.text)):i.push(...rDe(r,e.text,t));for(let e of n)i.push(...O0(r,e));return i.push(`--${r}--`),i}function oDe(e,t,n,r){let i=C0(`rel`),a=E0(e);a.push(`Content-Type: multipart/related; boundary="${i}"; type="multipart/alternative"`,``,...rDe(i,e.text,t));for(let e of n)a.push(...O0(i,e));for(let e of r)a.push(...O0(i,e));return a.push(`--${i}--`),a}function sDe(e){let t=e.images??[],n=t.filter(e=>e.placement===`inline`),r=t.filter(e=>e.placement===`attachment`),i=e.html!==void 0&&e.html.length>0?tDe(e.html,n):void 0;return i!==void 0&&n.length>0?oDe(e,i,n,r).join(`\r
1115
1115
  `):r.length>0||n.length>0?aDe(e,i,r.length>0?r:n).join(`\r
1116
1116
  `):iDe(e,i).join(`\r