@camstack/addon-admin-ui 1.2.702 → 1.2.703

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 (108) hide show
  1. package/CHANGELOG.md +8 -2
  2. package/dist/assets/{AccessSection-CNgvvC6Q.js → AccessSection-BGohJFsQ.js} +1 -1
  3. package/dist/assets/Addons-BDlFntTI.js +5 -0
  4. package/dist/assets/{AdminPage-BkxgjFWW.js → AdminPage-fCxxHmc-.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-bGVBepbw.js → AdminSectionedPage-DDqDbMM3.js} +1 -1
  6. package/dist/assets/AiProfiles-BFi1Kn6N.js +3 -0
  7. package/dist/assets/Archive-ChqpFwH8.js +1 -0
  8. package/dist/assets/{BootstrapSettingsForm-jBRoUiPn.js → BootstrapSettingsForm-BLWj6csX.js} +1 -1
  9. package/dist/assets/{Build-BoiB-nPA.js → Build-DfHu8hDx.js} +4 -4
  10. package/dist/assets/{Calendars-BBTnm6OG.js → Calendars-Cxw9P8Uq.js} +1 -1
  11. package/dist/assets/Cluster-BwIvlnpz.js +1 -0
  12. package/dist/assets/{CompositionBlockEditor-BloGManS.js → CompositionBlockEditor-DyGQ4aIz.js} +2 -2
  13. package/dist/assets/{CompositionEditorPage-C5pNxu2M.js → CompositionEditorPage-DRISSQzb.js} +1 -1
  14. package/dist/assets/Data-B1NgedRI.js +2 -0
  15. package/dist/assets/DeviceDetail-BzGdZ7Q_.js +1 -0
  16. package/dist/assets/{Devices-BJRvDHiT.js → Devices-CdmWPr7S.js} +1 -1
  17. package/dist/assets/EmbedDevicePage-CfSj9caC.js +1 -0
  18. package/dist/assets/{EmbedPlayerPage-BsxSpEcY.js → EmbedPlayerPage-DEP8gdti.js} +1 -1
  19. package/dist/assets/History-Bg9tQAqJ.js +1 -0
  20. package/dist/assets/Identity-Oyg78Wgg.js +1 -0
  21. package/dist/assets/InstancesTable-CItURWVx.js +1 -0
  22. package/dist/assets/IntegrationDetail-B05HfycS.js +1 -0
  23. package/dist/assets/{Integrations-BUOpFqfh.js → Integrations-Bpw7S0et.js} +2 -2
  24. package/dist/assets/{Integrations-Dpb2V2yu.js → Integrations-wpQtKhSO.js} +1 -1
  25. package/dist/assets/Library-afeuqgc6.js +1 -0
  26. package/dist/assets/Locations-DPd9tJpI.js +3 -0
  27. package/dist/assets/Logs-DSnFwEPX.js +1 -0
  28. package/dist/assets/{MaskShapeCanvas-D57fCIme.js → MaskShapeCanvas-DATKwWoi.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-w1kFM_O4.js → MotionZonesSettings-BrUyigty.js} +1 -1
  30. package/dist/assets/{MyAccess-D87gqxHt.js → MyAccess-DTWeghN4.js} +1 -1
  31. package/dist/assets/{Network-L7e5c9RP.js → Network-CzBJb8Ro.js} +1 -1
  32. package/dist/assets/{NewExportModal-CHwUJ26P.js → NewExportModal-DC6qeg0K.js} +1 -1
  33. package/dist/assets/NodeAddonsSettingsPanel-DwR6THxT.js +1 -0
  34. package/dist/assets/Notifications-8WkrgioY.js +1 -0
  35. package/dist/assets/{PanelContent-PhbemYUY.js → PanelContent-Cqel4gq_.js} +2 -2
  36. package/dist/assets/Pipeline-Dlg9wnRY.js +1 -0
  37. package/dist/assets/{PrivacyMaskSettings-BS29zGkX.js → PrivacyMaskSettings-jcKOGH_r.js} +1 -1
  38. package/dist/assets/{SceneMonitorEditor-CosxkmPM.js → SceneMonitorEditor-HfoxsYJf.js} +1 -1
  39. package/dist/assets/SessionsList-CIOmkBhu.js +2 -0
  40. package/dist/assets/{Showroom-0iJ0CCe5.js → Showroom-BgfY_eRn.js} +1 -1
  41. package/dist/assets/StorageLocationsTable-CbwL3VQY.js +1 -0
  42. package/dist/assets/System-DXC-3shW.js +2 -0
  43. package/dist/assets/{TemplateEditorDialog-8D78AUfO.js → TemplateEditorDialog-DXIGdBCR.js} +1 -1
  44. package/dist/assets/{Terminal-Cvw2rPrb.js → Terminal-Di7l31qa.js} +5 -5
  45. package/dist/assets/{TrainingProviders-DcThiLnE.js → TrainingProviders-aXqehRmF.js} +1 -1
  46. package/dist/assets/{Viewer-BUfnqb0c.js → Viewer-C71XpHjW.js} +1 -1
  47. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CNNET8uz.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DRUBvLQE.js} +1 -1
  48. package/dist/assets/{action-draft-BTVZLATm.js → action-draft-qcGhRMv4.js} +1 -1
  49. package/dist/assets/{ai-page.helpers-qxf7BP-v.js → ai-page.helpers-CEBa_im9.js} +1 -1
  50. package/dist/assets/{assignment-candidates-d-6NU8po.js → assignment-candidates-DdSU1Zo6.js} +1 -1
  51. package/dist/assets/{authed-media-Bqh0pB9D.js → authed-media-BZy-JJ_o.js} +1 -1
  52. package/dist/assets/{board-model-CPA2IZpg.js → board-model-DIWwdMST.js} +1 -1
  53. package/dist/assets/{camera-block-model-CJ0e2m0o.js → camera-block-model-Bq_R4oG5.js} +1 -1
  54. package/dist/assets/{client-Cng2SeYA.js → client-DLuByuRa.js} +1 -1
  55. package/dist/assets/{command-vocab-BzBhzE7i.js → command-vocab-CvGdlD2o.js} +1 -1
  56. package/dist/assets/{device-integration-icon-VMxiVsqd.js → device-integration-icon-Dd9uw4UF.js} +1 -1
  57. package/dist/assets/device-picker-model-PIGdnO_G.js +1 -0
  58. package/dist/assets/{dist-D7Gew3v3.js → dist-CDyYOITf.js} +1 -1
  59. package/dist/assets/{dist-CxrdebAP.js → dist-CFXBYJXQ.js} +1 -1
  60. package/dist/assets/{format-BopmTOzZ.js → format-CrKdqqCK.js} +1 -1
  61. package/dist/assets/{hostInit-DuH1KOuD.js → hostInit-CYHcdoYA.js} +1 -1
  62. package/dist/assets/i18n-CLov6T90.js +1 -0
  63. package/dist/assets/{icons-bi-mcO5N.js → icons-BLtyw4fH.js} +1 -1
  64. package/dist/assets/index-CFJEFXwr.js +6 -0
  65. package/dist/assets/{linked-devices-model-Bnz1douR.js → linked-devices-model-BPZYWQoj.js} +1 -1
  66. package/dist/assets/{mf-entry-bootstrap-0-ddbe056c.js → mf-entry-bootstrap-0-129d9964.js} +2 -2
  67. package/dist/assets/mount-PIGdnO_G.js +1 -0
  68. package/dist/assets/{notification-rule-status-ai5zWyzt.js → notification-rule-status-DeN2cEgy.js} +1 -1
  69. package/dist/assets/{player-overlays-fpbPSPqT.js → player-overlays-CgADEsQt.js} +1 -1
  70. package/dist/assets/remoteEntry-Cc7yyabb.js +1 -0
  71. package/dist/assets/{src-eL0OacoB.js → src-CA2_9YJD.js} +20 -20
  72. package/dist/assets/{sso-popup-Za4GwQBP.js → sso-popup-BXELI2t0.js} +1 -1
  73. package/dist/assets/{step-inspector-model-BAgxIyNV.js → step-inspector-model-BFq40l6S.js} +1 -1
  74. package/dist/assets/{use-scenes-feed-BTNdL7JV.js → use-scenes-feed-DyQPnSjQ.js} +1 -1
  75. package/dist/assets/{useAdminDeviceRemoval-COlTnaF7.js → useAdminDeviceRemoval-CKwvXhAP.js} +1 -1
  76. package/dist/assets/useEventInvalidation-PIGdnO_G.js +1 -0
  77. package/dist/assets/{useNodeUrlSelection-DhtJZEtx.js → useNodeUrlSelection-cFOr6zMH.js} +1 -1
  78. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-R-1W8c6C.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-HQVwzuiB.js} +2 -2
  79. package/dist/index.html +8 -8
  80. package/dist/server/addon.js +10 -3
  81. package/package.json +2 -2
  82. package/dist/assets/Addons-Dtx3xcZ2.js +0 -5
  83. package/dist/assets/AiProfiles-BLj-ic5N.js +0 -3
  84. package/dist/assets/Archive-y1aPYCx8.js +0 -1
  85. package/dist/assets/Cluster-DN0Cwciw.js +0 -1
  86. package/dist/assets/Data-LT-PQ05n.js +0 -2
  87. package/dist/assets/DeviceDetail-DAvmtNN2.js +0 -1
  88. package/dist/assets/EmbedDevicePage-CyKS-rmB.js +0 -1
  89. package/dist/assets/History-BPF9alct.js +0 -1
  90. package/dist/assets/Identity-dLFVHYZR.js +0 -1
  91. package/dist/assets/InstancesTable-LVQWfz07.js +0 -1
  92. package/dist/assets/IntegrationDetail-C_vN9X7q.js +0 -1
  93. package/dist/assets/Library-D4-BDy54.js +0 -1
  94. package/dist/assets/Locations-DGZ_lrp3.js +0 -3
  95. package/dist/assets/Logs-CUV00qxb.js +0 -1
  96. package/dist/assets/NodeAddonsSettingsPanel-Kqe8X8RH.js +0 -1
  97. package/dist/assets/Notifications-CucZNxjj.js +0 -1
  98. package/dist/assets/Pipeline-9O3YfaWk.js +0 -1
  99. package/dist/assets/SessionsList-OHo3GJ72.js +0 -2
  100. package/dist/assets/StorageLocationsTable-DqTWO4k1.js +0 -1
  101. package/dist/assets/System-DZXA2QSs.js +0 -2
  102. package/dist/assets/device-detail-Cg2Zt8FL.js +0 -1
  103. package/dist/assets/device-picker-model-B-FI9413.js +0 -1
  104. package/dist/assets/i18n--GTAj4mB.js +0 -1
  105. package/dist/assets/index-DbXFHmBJ.js +0 -6
  106. package/dist/assets/mount-B-FI9413.js +0 -1
  107. package/dist/assets/remoteEntry-g0NfB_lk.js +0 -1
  108. package/dist/assets/useEventInvalidation-B-FI9413.js +0 -1
@@ -1107,7 +1107,7 @@ ${d.map(({leaf:e,path:t})=>Tfe(e,t)).join(`
1107
1107
  }
1108
1108
  }
1109
1109
  `}function Lfe(e){return`subjects`in e?e.subjects:e.classes.map(Gh)}var Rfe=new Set(Object.values(Ih.mapping));function zfe(e){return Ih.mapping[e]??e}function Bfe(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r?!0:Rfe.has(n)&&zfe(r)===n}function Vfe(e){return e===`start`||e===`update`||e===`end`}var Hfe=class{trigger;fired=new Map;subjects;constructor(e){this.trigger=e,this.subjects=Lfe(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`||!Vfe(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=Yh(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 Ufe(e){return`classes`in e}function Wfe(e){return e===`appeared`||e===`departed`}function Gfe(e,t){let{deviceId:n,entryId:r,phase:i}=t;if(typeof n!=`number`||typeof r!=`string`||!Wfe(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=Ufe(e)?e.classes?.map(Gh):e.subjects;if(c!==void 0){let e=Yh(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 I(e,t){return{en:e,it:t}}var X_=b({deviceId:r(),eventType:u(),sourceId:u().optional(),data:h(u(),C()).nullable(),timestamp:r().meta(k(`none`)),seq:r().meta(k(`count`))}),Z_=b({eventTypes:S(u()),vocabulary:S(Ip).default([]),lastEvent:X_.nullable(),eventCountSinceStart:r().meta(k(`count`))}),Q_={name:`event-emitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.EventEmitter],methods:{},events:{onEvent:{data:X_,trigger:{category:w.EventEmitted,label:I(`Fired an event`,`Ha generato un evento`),phrase:I(`When {device} fires an event`,`Quando {device} genera un evento`),icon:`zap`}}},status:{schema:Z_,kind:`push`},runtimeState:Z_,durability:`session`,history:`none`,vocabulary:{noun:I(`Event source`,`Sorgente di eventi`),order:5280}},Kfe=3,qfe=32;function Jfe(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function $_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Yfe(e){let t={},n=(e,r,i)=>{if(!(Object.keys(t).length>=qfe)){if(Jfe(e)){t[r]=e;return}if(!(!$_(e)||i>=Kfe))for(let[t,a]of Object.entries(e))n(a,`${r}.${t}`,i+1)}};if($_(e))for(let[t,r]of Object.entries(e))n(r,`data.${t}`,1);return t}function Xfe(e,t){let n=e;for(let e of t.split(`.`)){if(!$_(n))return;n=n[e]}return n}function Zfe(e,t){return t===null?!0:e.timestamp===t.timestamp?e.seq>t.seq:e.timestamp>t.timestamp}var Qfe=`recovered by reconcile`,$fe=class{leaf;#e=null;#t=!1;#n=null;constructor(e){this.leaf=e}onEvent(e){let t=X_.safeParse(e);if(!t.success)return{kind:`ignore`,why:`malformed event`};let n=t.data;return n.deviceId===this.leaf.deviceId?Zfe(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=Z_.safeParse(e);if(!t.success)return{kind:`ignore`,why:`the event-emitter status is unreadable`};this.#n=Bp(t.data);let n=t.data.lastEvent,r=!this.#t;return this.#t=!0,n===null?{kind:`ignore`,why:`the device has not fired`}:Zfe(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??zp([e.eventType]);return(Vp(t,e.eventType,e.sourceId)??Vp(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=Yfe(e.data);for(let t of a??[]){let n=Xfe(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} — ${Qfe}`:l,vars:s,data:c}}},epe=6e4;function ev(e){return(e/epe).toFixed(1)}var tpe=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*epe;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 ${ev(n)} min ago`};let r=`${ev(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 ${ev(n)} min ago, ${r}`}}},npe=x([`string`,`number`,`boolean`,`select`]),rpe=/^[A-Za-z_][A-Za-z0-9_]*$/,tv=g([u(),r(),v()]),nv=b({name:u().regex(rpe),label:u().min(1).max(120).optional(),type:npe,required:v().optional(),default:tv.optional(),options:S(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&&rv(e,e.default)!==null&&t.addIssue({code:`custom`,message:rv(e,e.default)??`invalid default`,path:[`default`]})});function rv(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 ipe(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=rv(e,t);if(n!==null)return{ok:!1,error:n};i[e.name]=t}return{ok:!0,values:i}}var ape=x([`internal`,`addon`]),ope=`internal:`;function spe(e){return`${ope}${e}`}function iv(e){return e.startsWith(`internal:`)&&e.length>9}function cpe(e){if(iv(e))return null;let t=e.indexOf(`:`);return t>0&&t<e.length-1?e.slice(0,t):null}var lpe=b({isRunning:v(),lastRunAt:r().nullable(),lastError:u().nullable()}),upe={isRunning:!1,lastRunAt:null,lastError:null},av=r().int().min(0).max(86400),ov=b({id:u().min(3),name:u().min(1).max(120),addonId:u().min(1),source:ape,readOnly:v(),steps:S(Hg).min(1).max(50).optional(),variables:S(nv).max(20).optional(),minDelaySec:av.optional(),tags:Zu.optional(),status:lpe}).superRefine((e,t)=>{if(e.source===`internal`){iv(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`]}),cpe(e.id)===null&&t.addIssue({code:`custom`,message:`an addon action id is <addonId>:<localId>`,path:[`id`]})}),sv=b({name:u().min(1).max(120),steps:S(Hg).min(1).max(50),variables:S(nv).max(20).optional(),minDelaySec:av.optional(),tags:Zu.optional()}),dpe=b({blockId:u().min(1).optional()}),fpe=g([__,m(`started`),m(`timed-out`)]),ppe=b({runId:u().min(1),outcome:fpe,message:u().optional()}),mpe=x([`not-found`,`read-only`,`invalid-variables`,`invalid-steps`,`not-linked`,`template-scope`,`busy`]),hpe=class extends Error{code;constructor(e,t){super(`[${e}] ${t}`),this.name=`ActionError`,this.code=e}},gpe=b({actionId:u(),runId:u(),isRunning:v(),outcome:__.optional(),lastRunAt:r().nullable(),lastError:u().nullable()});function _pe(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 vpe(e){return[...e.kind===`command`&&e.target.kind===`devices`?[{actionId:e.actionId,ids:e.target.ids}]:[],..._pe(e).flatMap(vpe)]}async function ype(e,t){let n=e.flatMap(vpe);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){wp(e,void 0);for(let n of t)Tp(e,n,i.get(n)??[])}}async function bpe(e,t,n=Date.now,r,i,a){let o=r?.mirror??new qde(I_(e));await o.refresh(t);let s=V_(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 xpe(e){try{return await e()}catch(e){return{result:`unknown`,reason:e instanceof Error?e.message:String(e)}}}async function Spe(e){let t=e.now(),n=t+e.timeoutMs;for(;;){let r=await xpe(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 Cpe(e,t){return`timed out after ${e} s: ${t}`}function cv(e){return ec(e)}function lv(e){let t=cv(e);if(t===void 0)return[];let n=yh(t);return n===void 0?[t]:[t,...Th(n).filter(e=>e!==t)]}var uv=b({path:u(),deviceId:r().int().optional(),field:u(),value:r(),assumedUnit:u(),message:u()});function wpe(e){let t=ah(e);return t instanceof ue?t:void 0}function dv(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[...ch(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=wpe(i)?.shape[r];return a===void 0?void 0:Mh(a)}}}function Tpe(e){return ph(e)??e}function Epe(e){return lv(e).length>1}function Dpe(e){return{...e,message:`${e.field}: the bare number ${e.value} was taken as ${e.assumedUnit} — send { value, unit } to state the unit`}}function Ope(e,t){kh({value:1,unit:e,target:t})}function kpe(e,t,n){let r=t.fieldQuantity(e.cap,e.fieldPath),i=r===void 0?void 0:cv(r),a=Oh(e.value)||e.unit!==void 0;if(i===void 0||r===void 0){if(a)throw new Eh(`no-quantity`,`${e.cap}.${e.fieldPath} is not a quantity — it takes no unit`);return{leaf:e,warnings:[]}}if(Oh(e.value)){let t=kh({value:e.value.value,unit:e.value.unit,target:i});return{leaf:{...e,value:t,unit:Tpe(e.value.unit)},warnings:[]}}return typeof e.value==`number`?e.unit===void 0?Epe(r)?{leaf:e,warnings:[Dpe({path:n,deviceId:e.deviceId,field:e.fieldPath,value:e.value,assumedUnit:i})]}:{leaf:e,warnings:[]}:(Ope(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}=kpe(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 Ape(e,t,n){let r=e.target.kind===`devices`&&e.target.ids.length===1?e.target.ids[0]:void 0,{cap:i,method:a}=wp(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 Eh(`no-quantity`,`${i}.${a}(${n}) is not a quantity — it takes no unit`);Ope(r,e.unit)}for(let[l,u]of Object.entries(e.args??{})){let e=t.paramMeta(i,a,l);e!==void 0&&(Oh(u)?(o[l]=kh({value:u.value,unit:u.unit,target:e.unit}),s[l]=Tpe(u.unit)):typeof u==`number`&&s[l]===void 0&&Epe(e.quantity)&&c.push(Dpe({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 jpe(e,t,n=`steps`){let r=[],i=[];return e.forEach((e,a)=>{if(e.kind!==`command`){r.push(e);return}let o=Ape(e,t,`${n}.${a}`);r.push(o.value),i.push(...o.warnings)}),{value:r,warnings:i}}function Mpe(e,t){let n=fv(e.when,t,`when`),r=jpe(e.actions,t,`actions`);return{value:{...e,when:n.value,actions:r.value},warnings:[...n.warnings,...r.warnings]}}function pv(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||lv(n).length<2)return e;let r=cv(n);return r===void 0?e:{...e,unit:r}}case`not`:return{...e,child:pv(e.child,t)};case`all`:case`any`:return{...e,children:e.children.map(e=>pv(e,t))};default:return e}}function Npe(e,t){if(e.kind!==`command`||e.args===void 0)return e;let{cap:n,method:r}=wp(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&&lv(e.quantity).length>1&&(i[a]=e.unit)}return Object.keys(i).length===0?e:{...e,argUnits:i}}function mv(e,t){let n={...e,when:pv(e.when,t),actions:e.actions.map(e=>Npe(e,t))};try{return{ok:!0,recipe:Mpe(n,t).value}}catch(e){if(e instanceof Eh)return{ok:!1,error:e.message};throw e}}var Ppe=[`devices`,`time`,`cameras`,`events`,`logic`,`system`],hv=[`trigger`,`any`],gv=[`trigger`,`guard`,`any`],_v={detection:{kind:`detection`,category:`cameras`,role:`event`,allowedIn:hv,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:hv,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:hv,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:hv,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:hv,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:hv,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:hv,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:hv,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:gv,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:gv,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:gv,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:gv,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:gv,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 Fpe(e){return _v[e]}function Ipe(e){return _v[e].seed()}function Lpe(e){return vv.filter(t=>_v[t].allowedIn.includes(e))}function Rpe(e){return e instanceof Error?e.message:String(e)}function zpe(e){return e.startsWith(`[busy]`)?`already-running`:e.startsWith(`[not-found]`)?`not-found`:null}async function Bpe(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=Rpe(e),i=zpe(n);return i===null?(t.warn(`${r}: exported action failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}):o(i,n)}}async function Vpe(e,t,n){let{exporter:r,targetId:i}=n,a={targetId:i};try{let{targets:o,unreadable:s}=await pa(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:vi.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=Rpe(e);return t.warn(`${r}: exported notifier send failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}}}function Hpe(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 yv=u().min(1),bv=b({instanceId:yv.optional()}),xv=b({instanceId:yv,name:u(),enabled:v(),kind:u().optional(),nameRule:u().optional()}),Sv=`export-instance-unknown`,Upe=class extends Error{code=Sv;instanceId;constructor(e,t){super(`${Sv}: ${e} serves no instance "${t}"`),this.name=`ExportInstanceUnknownError`,this.instanceId=t}};function Wpe(e){return`instanceId`in e?e.instanceId:void 0}function Gpe(e,t,n){if(n!==void 0&&n!==t)throw new Upe(e,n)}var Kpe=x([`unlinked`,`linked`,`error`]),qpe=b({label:u(),value:u(),secret:v().optional()}),Jpe=b({qr:u().optional(),fields:S(qpe).readonly().optional(),note:u().optional()}),Cv=b({linkState:Kpe,exposedDeviceCount:r(),error:u().optional(),setup:Jpe.optional()}),Ype=u(),wv=b({deviceId:u(),exposedAs:u().optional(),exposedName:u().optional(),capabilities:S(u()).optional()}),Xpe=b({instanceId:yv,deviceId:u(),capabilities:S(u()).optional(),exposedName:u().nullable().optional()}),Zpe=b({instanceId:yv,deviceId:u(),name:u().nullable(),dryRun:v().optional()}),Tv=`export-name-refused`,Qpe=class extends Error{code=Tv;instanceId;reason;constructor(e,t){super(`${Tv}: ${t}`),this.name=`ExportNameRefusedError`,this.instanceId=e,this.reason=t}},$pe=b({instanceId:yv,deviceId:u()}),Ev=x([`device`,`action`,`notifier`]),Dv=a(`kind`,[b({kind:m(`device`),deviceId:u()}),b({kind:m(`action`),actionId:u().min(1)}),b({kind:m(`notifier`),targetId:u().min(1)})]),Ov=b({entity:Dv,exposedAs:u().optional()}),eme=b({instanceId:yv,entity:Dv}),tme=b({instanceId:yv,entity:Dv}),nme={name:`device-export`,scope:`system`,mode:`collection`,providerKind:`device-export`,status:{schema:Cv,kind:`poll`},exposesDeviceSettings:!0,methods:{getStatus:E(bv,Cv),listInstances:E(_(),S(xv)),listSupportedDeviceKinds:E(bv,S(Ype)),listExposedDevices:E(bv,S(wv)),exposeDevice:E(Xpe,_(),{kind:`mutation`,auth:`admin`}),unexposeDevice:E($pe,_(),{kind:`mutation`,auth:`admin`}),setExposedName:E(Zpe,_(),{kind:`mutation`,auth:`admin`}),listSupportedEntityKinds:D(_(),S(Ev)),listExposedEntities:D(bv,S(Ov)),exposeEntity:D(eme,_(),{kind:`mutation`,auth:`admin`}),unexposeEntity:D(tme,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`exports to other ecosystems — configured on the export pages`}},kv=`exposedNames`,rme=h(u(),u());function Av(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 jv(e){let t=rme.safeParse(e[kv]);return t.success?t.data:{}}function ime(e,t,n){let r=jv(e)[t];if(r===void 0)return null;let i=Av(r,n);return i.ok?i.name:null}function Mv(e,t,n){let r=Object.fromEntries(Object.entries(jv(e)).filter(([e])=>e!==t));return{[kv]:n===null?r:{...r,[t]:n}}}async function ame(e){let t=Av(e.raw,e.validate);if(!t.ok)throw new Qpe(e.instanceId,t.reason);if(e.dryRun===!0)return{changed:!1,name:t.name};let n=await e.store.read(e.deviceId);return(jv(n)[e.instanceId]??null)===t.name?{changed:!1,name:t.name}:(await e.store.write(e.deviceId,Mv(n,e.instanceId,t.name)),{changed:!0,name:t.name})}function ome(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 sme(e,t){let n=await e.listDeviceStoreIds();if(n.length===0)return[];let r=[];for(let[i,a]of await e.readDeviceStoreBatch(n))jv(a)[t]!==void 0&&(await e.writeDeviceStore(i,Mv(a,t,null)),r.push(i));return r}function cme(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 lme=[`automation`,`action`,`scheduler`,`composition`],ume=x(lme),dme=b({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:S(u().min(1)),zones:S(u().min(1)).optional()}),fme=b({timeZone:u().min(1),location:b({latitude:r(),longitude:r()}).nullable(),rooms:S(u().min(1)),devices:S(dme).min(1),actions:S(b({id:u().min(1),name:u().min(1)})).default([])}),pme=b({childDeviceIds:S(r()).readonly(),hiddenChildIds:S(r()).readonly()}),mme={name:`accessories`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera,j.Switch,j.Light,j.Sensor,j.Climate,j.Cover,j.Lock,j.Fan,j.MediaPlayer,j.AlarmPanel,j.Generic],methods:{setChildHidden:E(b({deviceId:r().int().nonnegative(),childDeviceId:r().int().nonnegative(),hidden:v()}),_(),{kind:`mutation`,auth:`admin`})},events:{onAccessoriesChanged:{data:b({deviceId:r(),childDeviceIds:S(r()).readonly(),hiddenChildIds:S(r()).readonly()}),notOperatorFacing:`the device’s child list changed — administration, not a happening`},onChildVisibilityChanged:{data:b({deviceId:r(),childDeviceId:r(),hidden:v()}),notOperatorFacing:`an operator hid or showed a child — administration, not a happening`}},status:{schema:pme,kind:`command-driven`},vocabulary:{noun:I(`Accessories`,`Accessori`),order:3e3}},hme={name:`action-source`,scope:`system`,mode:`collection`,methods:{listActions:E(b({}),S(ov),{auth:`admin`}),runAction:E(b({actionId:u().min(1),variables:h(u(),tv).optional()}),_(),{kind:`mutation`,auth:`admin`}),stopAction:E(b({actionId:u().min(1)}),_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},gme=60*6e4,_me=3e4,vme=363e4;function yme(e){let t=0;for(let n of e)n.kind===`wait`&&(t+=n.seconds*1e3);return t}var Nv=b({actionId:u().min(1)}),Pv=b({deviceId:r().int().nonnegative(),actionIds:S(u().min(1)).max(100)}),bme={name:`actions`,scope:`system`,mode:`singleton`,methods:{list:E(b({}),S(ov),{auth:`admin`}),get:E(b({actionId:u().min(1),deviceId:r().int().nonnegative().optional()}),b({action:ov.nullable()}),{role:`viewer`,auth:`protected`,kind:`query`,caller:`required`}),run:E(b({actionId:u().min(1),variables:h(u(),tv).optional(),wait:v().optional(),origin:dpe.optional(),deviceId:r().int().nonnegative().optional()}),ppe,{role:`viewer`,auth:`protected`,kind:`mutation`,caller:`required`,timeoutMs:vme}),stop:E(Nv,_(),{kind:`mutation`,auth:`admin`}),getTraces:E(Nv,b({traces:S(y_)}),{auth:`admin`}),create:E(b({action:sv}),b({action:ov,warnings:S(uv).optional()}),{kind:`mutation`,auth:`admin`}),update:E(b({actionId:u().min(1),action:sv.partial()}),b({action:ov,warnings:S(uv).optional()}),{kind:`mutation`,auth:`admin`}),delete:E(Nv,_(),{kind:`mutation`,auth:`admin`}),listForCamera:E(b({deviceId:r().int().nonnegative()}),S(ov),{role:`viewer`,auth:`protected`,kind:`query`}),getLinks:E(b({deviceId:r().int().nonnegative()}),Pv,{auth:`admin`}),setLinks:E(Pv,Pv,{kind:`mutation`,auth:`admin`})},events:{onRunChanged:{data:gpe}},vocabulary:{notOperatorFacing:`declared actions — run from the Actions page and from the cameras that link them`}},xme=b({id:u(),label:u(),icon:u(),path:u(),remoteName:u(),bundle:u(),section:u().optional(),sectionLabel:u().optional()}),Sme=b({addonId:u(),page:xme,bundleUrl:u()}),Cme={name:`addon-pages`,scope:`system`,mode:`singleton`,methods:{listPages:E(_(),S(Sme).readonly())},vocabulary:{notOperatorFacing:O.UI_PLUMBING}},wme=b({id:u(),label:u(),icon:u(),path:u(),remoteName:u(),bundle:u(),section:u().optional(),sectionLabel:u().optional()}),Tme={name:`addon-pages-source`,scope:`system`,mode:`collection`,internal:!0,methods:{listPages:E(_(),S(wme).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:O.UI_PLUMBING}},Eme=b({method:x([`GET`,`POST`,`PUT`,`DELETE`,`PATCH`]),path:u(),access:x([`public`,`authenticated`,`admin`]).optional(),description:u().optional(),rateLimit:x([`auth`]).optional(),perInstance:v().optional()}),Dme=b({method:u(),path:u(),params:h(u(),u()),query:h(u(),u()),body:C(),headers:h(u(),u()),instanceId:u().optional(),user:b({id:u(),username:u(),isAdmin:v()}).optional(),scopedToken:C().optional()}),Ome=b({status:r().int(),headers:h(u(),u()),redirectUrl:u().nullable(),body:C().optional(),contentType:u().optional()}),kme={name:`addon-routes`,scope:`system`,mode:`collection`,internal:!0,methods:{getRoutes:E(_(),S(Eme)),invoke:E(Dme,Ome,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.UI_PLUMBING}},Ame=b({id:u(),label:u(),icon:u(),order:r().optional()}),jme=b({id:u(),title:u(),titleKey:u().optional(),description:u().optional(),descriptionKey:u().optional(),style:x([`card`,`accordion`]).optional(),defaultCollapsed:v().optional(),columns:g([m(1),m(2),m(3),m(4)]).optional(),tab:u().optional(),location:x([`settings`,`top-tab`,`hero`]).optional(),order:r().optional(),fields:S(ve())}),Fv=b({tabs:S(Ame).optional(),sections:S(jme)}),Iv=h(u(),C()),Lv=x(sr),Mme=b({cap:u(),scope:Lv,sectionIds:S(u())}),Rv=b({success:m(!0)}),Nme={name:`addon-settings`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{getScopedSettings:E(b({addonId:u(),cap:u(),scope:Lv,nodeId:u().optional()}),Fv.nullable()),listScopedSettings:E(b({addonId:u(),nodeId:u().optional()}),S(Mme).nullable()),updateScopedSettings:E(b({addonId:u(),cap:u(),scope:Lv,nodeId:u().optional(),patch:Iv}),Rv,{kind:`mutation`,auth:`admin`}),readScopedValues:E(b({addonId:u(),cap:u(),scope:Lv,nodeId:u().optional()}),h(u(),C()).nullable()),getDeclaredSettingsKeys:E(b({addonId:u(),nodeId:u().optional()}),b({keys:S(u())}).nullable(),{auth:`admin`}),unsetStoredSettingsKeys:E(b({addonId:u(),nodeId:u().optional(),keys:S(u())}),b({removed:S(u()),refused:S(b({key:u(),reason:u()})),secretsCleared:r()}),{kind:`mutation`,auth:`admin`}),getDeviceSettings:E(b({addonId:u(),deviceId:r(),nodeId:u().optional()}),Fv.nullable()),updateDeviceSettings:E(b({addonId:u(),deviceId:r(),nodeId:u().optional(),patch:Iv}),Rv,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.ADDON_ADMIN}},Pme=x([`device-tab`,`dashboard`,`integration-detail`]),zv=x([`xs`,`sm`,`md`,`lg`,`xl`]),Bv=b({remoteName:u(),exposedModule:u(),componentKey:u().optional()}),Vv=b({tab:u(),subTab:u().optional(),label:u(),order:r().optional(),kind:m(`remote`),remote:Bv,stableId:u(),description:u().optional(),icon:u().optional(),bundle:u(),hosts:S(Pme).readonly(),requires:b({deviceContext:v().default(!1),integrationContext:v().default(!1)}),preAuth:v().optional().default(!1),defaultSize:zv.default(`md`),allowedSizes:S(zv).readonly().default([`sm`,`md`,`lg`]),defaultColumns:r().int().min(1).max(12).default(6),defaultRows:r().int().min(1).max(12).default(1)}),Fme={name:`addon-widgets-source`,scope:`system`,mode:`collection`,internal:!0,methods:{listWidgets:E(_(),S(Vv).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:O.UI_PLUMBING}},Ime=Vv.extend({addonId:u(),bundleUrl:u()}),Lme={name:`addon-widgets`,scope:`system`,mode:`singleton`,methods:{listWidgets:E(_(),S(Ime).readonly())},vocabulary:{notOperatorFacing:O.UI_PLUMBING}},Rme=x([`install`,`update`,`uninstall`,`restart`]),Hv=x([`queued`,`fetching`,`staged`,`validating`,`applying`,`restarting`,`applied`,`done`,`failed`,`skipped`]),zme=x([`framework`,`addon`]),Bme=b({tsMs:r(),nodeId:u(),packageName:u(),phase:Hv,message:u()}),Vme=b({taskId:u(),nodeId:u(),packageName:u(),fromVersion:u().nullable(),toVersion:u(),target:zme,phase:Hv,stagedPath:u().nullable(),attempts:r(),steps:S(Bme),error:u().nullable(),startedAtMs:r().nullable(),finishedAtMs:r().nullable()}),Hme=x([`running`,`completed`,`failed`,`partially-failed`,`cancelled`]),Ume=x([`single`,`bulk`,`cluster`]),Uv=b({jobId:u(),kind:Rme,createdAtMs:r(),createdBy:u(),scope:Ume,tasks:S(Vme),state:Hme,schemaVersion:m(1)}),Wme=x([`debug`,`info`,`warn`,`error`]),Wv=x([`off`,`latest`,`beta`]),Gme=x([`off`,`latest`,`beta`,`inherit`]),Kme=b({id:u(),name:u().optional(),version:u().optional(),description:u().optional(),icon:u().optional(),color:u().optional(),capabilities:S(C()).readonly().optional(),packageName:u(),packageVersion:u(),packageDisplayName:u().optional(),bundle:b({displayName:u(),description:u().optional(),icon:u().optional()}).optional(),protected:v().optional(),removable:v().optional(),integrationSection:x([`system`,`providers`]).optional()}),qme=b({pid:r().optional(),mode:u(),state:u(),reason:u().optional()}),Jme=b({phase:x([`pending`,`healthy`,`failed`]),retryCount:r(),firstFailureAt:r().nullable(),lastAttemptAt:r().nullable(),lastError:b({message:u(),stack:u().optional()}).nullable(),nextRetryAt:r().nullable(),alertEmitted:v(),retrying:v(),inGracePeriod:v()}),Yme=b({manifest:Kme,declaration:C().optional(),source:u(),installSource:u().optional(),process:qme.optional(),hasBackup:v().optional(),health:Jme.nullable().optional()}),Xme=b({name:u(),version:u(),dir:u(),installSource:u().optional()}),Zme=b({name:u(),currentVersion:u(),latestVersion:u(),category:x([`addon`,`core`]),requiresRestart:v(),isSystem:v(),blockedBy:S(zr).readonly().optional()}),Qme=b({version:u(),publishedAt:u(),deprecated:u().optional(),distTags:S(u()).readonly()}),$me=a(`status`,[b({status:m(`ok`),markdown:u()}),b({status:m(`missing`)}),b({status:m(`error`),message:u()})]),ehe=b({name:u(),version:u(),readme:$me,changelog:$me}),the=b({name:u(),version:u(),description:u(),keywords:S(u()).readonly(),publishedAt:u(),author:u(),installed:v(),installedVersion:u().optional(),capabilities:S(u()).readonly().nullable()}),nhe=b({channel:Wv,intervalSeconds:r(),updateCheckIntervalSeconds:r()}),rhe=Gme,ihe=C(),ahe=C(),ohe=C(),she=x([`uninstalled`,`not-installed`,`refused`,`failed`,`pending-reconnect`]),che=b({nodeId:u(),outcome:she,error:u().optional(),addonIds:S(u()).readonly(),runnersStopped:S(u()).readonly(),warnings:S(u()).readonly()}),lhe=b({success:v(),packageName:u(),results:S(che).readonly()}),uhe=b({packageName:u(),nodeId:u(),nodeName:u(),isHub:v(),isOnline:v(),version:u().nullable(),addonIds:S(u()).readonly(),source:x([`live`,`recorded`]),onHub:v()}),dhe=b({installations:S(uhe).readonly(),unreachable:S(b({nodeId:u(),error:u()})).readonly()}),fhe=x([`queued`,`updating`,`done`,`done-pending-restart`,`failed`]),phe=b({name:u(),isSystem:v(),fromVersion:u(),toVersion:u(),status:fhe,error:u().optional(),startedAtMs:r().optional(),completedAtMs:r().optional()}),mhe=x([`regular`,`system`,`restarting`,`finalizing`]);b({id:u(),nodeId:u(),startedAtMs:r(),completedAtMs:r().optional(),total:r(),completed:r(),failed:r(),current:u().nullable(),phase:mhe,cancelled:v(),items:S(phe).readonly()});var hhe=b({packageName:u(),currentVersion:u(),latestVersion:u().nullable(),hasUpdate:v(),description:u().optional(),buildId:u().nullable()}),ghe=b({timestamp:u(),level:u(),message:u(),scope:u().optional()}),_he=C(),vhe=b({addonId:u().min(1),action:u().min(1),input:C()}),yhe={name:`addons`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{list:E(b({nodeId:u().optional()}).optional(),S(Yme).readonly()),getLogs:E(b({addonId:u(),limit:r().min(1).max(500).default(100),level:Wme.optional()}),S(_he)),listPackages:E(_(),S(Xme).readonly()),installPackage:E(b({packageName:u(),version:u().optional()}),ahe,{kind:`mutation`,auth:`admin`}),uninstallPackage:E(b({packageName:u().min(1),nodeId:u().optional(),everywhere:v().optional()}),lhe,{kind:`mutation`,auth:`admin`}),listInstallations:E(b({packageName:u().optional()}),dhe,{auth:`admin`}),reloadPackages:E(_(),ohe,{kind:`mutation`,auth:`admin`}),searchAvailable:E(b({query:u().optional(),capability:u().optional()}),S(the)),listUpdates:E(b({nodeId:u().optional()}),S(Zme).readonly(),{auth:`admin`}),updatePackage:E(b({name:u().min(1),version:u().optional(),nodeId:u().optional()}),C(),{kind:`mutation`,auth:`admin`}),rollbackPackage:E(b({name:u().min(1)}),b({rolledBackTo:u().nullable()}),{kind:`mutation`,auth:`admin`}),forceRefresh:E(b({nodeId:u().optional()}),C(),{kind:`mutation`,auth:`admin`}),restartServer:E(b({confirm:m(!0)}),C(),{kind:`mutation`,auth:`admin`}),getLastRestart:E(_(),b({kind:x([`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:E(_(),S(hhe).readonly(),{auth:`admin`}),listCapabilityProviders:E(b({capName:u().min(1)}),S(b({addonId:u(),mode:x([`singleton`,`collection`]),isActive:v()})).readonly()),setCapabilityProviderEnabled:E(b({capName:u().min(1),addonId:u().min(1),enabled:v()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getVersions:E(b({name:u()}),S(Qme).readonly()),getPackageDocs:E(b({name:u().min(1),version:u().min(1).optional()}),ehe,{auth:`admin`}),restartAddon:E(b({addonId:u()}),ihe,{kind:`mutation`,auth:`admin`}),retryLoad:E(b({packageName:u()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getAutoUpdateSettings:E(_(),nhe,{auth:`admin`}),setAutoUpdateSettings:E(b({channel:Wv,intervalSeconds:r().min(300).max(86400).optional(),updateCheckIntervalSeconds:r().min(900).max(604800).optional()}),C(),{kind:`mutation`,auth:`admin`}),getAddonAutoUpdate:E(b({addonId:u()}),rhe,{auth:`admin`}),setAddonAutoUpdate:E(b({addonId:u(),channel:Gme}),C(),{kind:`mutation`,auth:`admin`}),applyAutoUpdateToAll:E(b({channel:Wv}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),custom:E(vhe,C(),{role:`viewer`,kind:`mutation`}),startJob:E(b({kind:x([`install`,`update`,`uninstall`,`restart`]),targets:S(b({name:u().min(1),version:u().min(1)})).min(1),nodeIds:S(u()).optional()}),b({jobId:u()}),{kind:`mutation`,auth:`admin`}),getJob:E(b({jobId:u()}),Uv.nullable(),{auth:`admin`}),listJobs:E(b({activeOnly:v().optional()}),S(Uv),{auth:`admin`}),cancelJob:E(b({jobId:u()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),onAddonLogs:E(b({addonId:u(),level:Wme.optional()}),ghe,{kind:`subscription`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.ADDON_ADMIN}},bhe=b({staticDir:u()}),xhe=b({version:u()}),She={name:`admin-ui`,scope:`system`,mode:`singleton`,internal:!0,methods:{getStaticDir:E(_(),bhe,{auth:`admin`}),getVersion:E(_(),xhe,{auth:`admin`})},vocabulary:{notOperatorFacing:O.UI_PLUMBING}},Gv=b({co2:r().min(0).optional().meta(k(`concentration-volume`)),voc:r().min(0).optional().meta(k(`concentration-ppb`)),pm25:r().min(0).optional().meta(k(`concentration-mass`)),pm10:r().min(0).optional().meta(k(`concentration-mass`)),aqi:r().optional().meta(k(`index`)),lastFetchedAt:r()}),Kv={name:`air-quality-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:Gv,kind:`push`},runtimeState:Gv,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:I(`Air quality`,`Qualità dell’aria`),order:5e3,state:[{kind:`numeric`,field:`co2`,quantity:I(`the CO₂`,`la CO₂`),label:I(`CO₂`,`CO₂`),unit:`ppm`,icon:`wind`},{kind:`numeric`,field:`voc`,quantity:I(`the VOC level`,`il livello di COV`),label:I(`VOC`,`COV`),unit:`ppb`,icon:`wind`},{kind:`numeric`,field:`pm25`,quantity:I(`the PM2.5`,`il PM2,5`),label:I(`PM2.5`,`PM2,5`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`pm10`,quantity:I(`the PM10`,`il PM10`),label:I(`PM10`,`PM10`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`aqi`,quantity:I(`the air quality index`,`l’indice di qualità dell’aria`),label:I(`AQI`,`IQA`),icon:`wind`}]}},qv=x([`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]),Jv=x([`home`,`away`,`night`,`vacation`,`custom_bypass`]),Yv=b({state:qv,targetMode:Jv.nullable().optional(),availableModes:S(Jv),codeRequired:v().nullable(),lastChangedAt:r()}),Xv={name:`alarm-panel`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.AlarmPanel],methods:{trigger:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.trigger`,label:I(`Trigger alarm`,`Fai scattare l’allarme`),phrase:I(`Trigger the alarm on {device}`,`Fai scattare l’allarme su {device}`),icon:`siren`}]}),disarm:E(b({deviceId:r().int().nonnegative(),code:u().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.disarm`,label:I(`Disarm`,`Disinserisci`),phrase:I(`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:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),arm:E(b({deviceId:r().int().nonnegative(),mode:Jv,code:u().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.arm.home`,label:I(`Arm home`,`Inserisci in casa`),phrase:I(`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:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.away`,label:I(`Arm away`,`Inserisci fuori casa`),phrase:I(`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:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.night`,label:I(`Arm night`,`Inserisci notte`),phrase:I(`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:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.vacation`,label:I(`Arm vacation`,`Inserisci vacanza`),phrase:I(`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:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.custom_bypass`,label:I(`Arm custom bypass`,`Inserisci con esclusioni`),phrase:I(`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:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]})},status:{schema:Yv,kind:`push`},runtimeState:Yv,durability:`restored`,restoredFieldRenames:{requiresCode:`codeRequired`},history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Alarm panel`,`Centrale d’allarme`),order:1120,state:[{kind:`enum`,field:`state`,label:I(`Alarm state`,`Stato dell’allarme`),values:[{value:`disarmed`,label:I(`Disarmed`,`Disinserito`),phrase:I(`When {device} is disarmed`,`Quando {device} viene disinserito`)},{value:`armed_home`,label:I(`Armed home`,`Inserito in casa`),phrase:I(`When {device} is armed for home`,`Quando {device} viene inserito in modalità casa`)},{value:`armed_away`,label:I(`Armed away`,`Inserito fuori casa`),phrase:I(`When {device} is armed for away`,`Quando {device} viene inserito in modalità fuori casa`)},{value:`armed_night`,label:I(`Armed night`,`Inserito notte`),phrase:I(`When {device} is armed for the night`,`Quando {device} viene inserito in modalità notte`)},{value:`armed_vacation`,label:I(`Armed vacation`,`Inserito vacanza`)},{value:`armed_custom_bypass`,label:I(`Armed with bypass`,`Inserito con esclusioni`)},{value:`arming`,label:I(`Arming`,`In inserimento`)},{value:`disarming`,label:I(`Disarming`,`In disinserimento`)},{value:`pending`,label:I(`Entry delay`,`Ritardo d’ingresso`)},{value:`triggered`,label:I(`Triggered`,`In allarme`),phrase:I(`When {device} goes off`,`Quando {device} scatta`)}],icon:`shield`}]}},Zv=x([`info`,`success`,`warning`,`error`,`critical`]),Che=b({addonId:u().min(1),action:u().min(1),input:h(u(),C()).optional()}),whe=b({label:u(),href:u().optional(),invoke:Che.optional(),navigation:x([`app`,`server`]).optional()}),The=x([`active`,`in-progress`,`completed`,`failed`,`dismissed`]),Ehe=b({type:u(),id:u()}),Qv=b({id:u(),category:u(),severity:Zv,title:u(),message:u(),action:whe.optional(),status:The,progress:r().optional(),read:v(),createdAt:r(),updatedAt:r(),source:Ehe.optional(),metadata:h(u(),C()).optional()}),Dhe={name:`alerts`,scope:`system`,mode:`singleton`,methods:{emit:E(Qv,_(),{kind:`mutation`}),update:E(b({alertId:u(),patch:Qv.partial()}),_(),{kind:`mutation`}),list:E(b({unreadOnly:v().optional(),limit:r().optional()}).optional(),S(Qv).readonly()),getUnreadCount:E(_(),r()),markRead:E(b({alertId:u()}),_(),{kind:`mutation`}),markAllRead:E(_(),_(),{kind:`mutation`}),dismiss:E(b({alertId:u()}),_(),{kind:`mutation`})},vocabulary:{notOperatorFacing:`the alert centre — read and acknowledged on its own page`}},$v=b({illuminance:r().min(0).nullable().meta(k(`illuminance`,{precision:0,label:`Illuminance`})),lastFetchedAt:r()}),ey={name:`ambient-light-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:$v,kind:`push`},runtimeState:$v,durability:`restored`,history:{fields:{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Light level`,`Luminosità ambiente`),order:5010,state:[{kind:`numeric`,field:`illuminance`,quantity:I(`the light level`,`la luminosità`),label:I(`Illuminance`,`Illuminamento`),unit:`lx`,icon:`sun`}]}},Ohe={name:`audio-analysis`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{resolveDeviceSettings:E(b({deviceId:r()}),be())},events:{onAudioLevel:ui(b({deviceId:r(),rms:r(),dbfs:r()}),{notOperatorFacing:`a sound-level sample at stream rate; loud-noise rules belong to the detection pipeline`})},vocabulary:{noun:I(`Audio analysis`,`Analisi audio`),order:3010}},khe=x([`jpeg`,`rgb`,`bgr`,`yuv420`,`gray`]),ty=b({data:be(),format:khe,width:r(),height:r(),timestamp:r()}),ny=b({x:r(),y:r(),w:r(),h:r()}),Ahe=b({class:u(),originalClass:u(),score:r(),bbox:ny}),ry=b({data:y(Uint8Array),sampleRate:r(),channels:r(),timestamp:r(),deviceId:r().optional()}),iy=b({rms:r(),dbfs:r()}),ay=b({className:u(),originalClass:u().optional(),score:r()}),oy=[`superseded`,`error`,`timeout`,`disposed`],sy=a(`state`,[b({state:m(`classified`)}),b({state:m(`not-classified`),reason:x(oy)})]),cy=b({level:iy,classification:b({labels:S(ay).readonly(),inferenceMs:r()}).optional(),classifyOutcome:sy,timestamp:r()}),ly=b({minConfidence:r().min(0).max(1).default(.3),allowedClasses:S(u()).default([])}),uy=b({deviceId:r(),brokerId:u(),ingestNodeId:u(),settings:ly}),dy=b({attached:v(),replaced:v()}),fy=b({detached:v()}),py=b({labels:S(ay).readonly(),rawLabels:S(ay).readonly().optional(),inferenceMs:r()}),jhe=[{value:`auto`,label:`Auto (platform default)`},{value:`apple-soundanalysis`,label:`Apple SoundAnalysis (macOS 12+)`},{value:`yamnet-onnx`,label:`YAMNet ONNX (cross-platform)`}],Mhe={audioBackend:`auto`,probedBestAudioBackend:``},my={name:`audio-analyzer`,scope:`system`,mode:`singleton`,methods:{analyseChunk:E(b({chunk:ry,settings:ly}),cy.nullable(),{kind:`mutation`}),classify:E(ry,py,{timeoutMs:3e4}),attachDevice:E(uy,dy,{kind:`mutation`}),detachDevice:E(b({deviceId:r()}),fy,{kind:`mutation`}),isReady:E(_(),v()),dispose:E(_(),_(),{kind:`mutation`}),reprobeAudioEngine:E(_(),b({backend:u()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},hy=x([`f32le`,`s16le`]),gy=b({codec:u(),canDecode:v(),canEncode:v(),label:u().optional()}),_y=b({codec:u(),sourceSampleRate:r().int().positive(),sourceChannels:r().int().positive(),extraData:y(Uint8Array).optional(),targetSampleRate:r().int().positive(),targetChannels:r().int().positive(),targetFormat:hy.optional(),idleMs:r().int().positive().optional(),tag:u().optional()}),vy=b({codec:u(),sourceSampleRate:r().int().positive(),sourceChannels:r().int().positive(),sourceFormat:hy.optional(),targetSampleRate:r().int().positive(),targetChannels:r().int().positive(),bitrateKbps:r().int().positive().optional(),idleMs:r().int().positive().optional(),tag:u().optional()}),yy=b({data:y(Uint8Array),sampleRate:r().int().positive(),channels:r().int().positive(),format:hy,pts:r()}),by=b({data:y(Uint8Array),codec:u(),pts:r(),frameComplete:v()}),Nhe=b({sessionId:u(),kind:x([`decode`,`encode`]),codec:u(),sourceSampleRate:r(),sourceChannels:r(),targetSampleRate:r(),targetChannels:r(),format:hy,tag:u().optional(),createdAtMs:r(),lastActivityMs:r(),framesIn:r(),framesOut:r()}),xy={name:`audio-codec`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{listSupportedCodecs:E(_(),S(gy).readonly()),canHandle:E(b({codec:u(),kind:x([`decode`,`encode`])}),v()),createDecodeSession:E(_y,b({sessionId:u(),nodeId:u()}),{kind:`mutation`}),createEncodeSession:E(vy,b({sessionId:u(),nodeId:u()}),{kind:`mutation`}),closeSession:E(b({sessionId:u(),nodeId:u().optional()}),_(),{kind:`mutation`}),pushEncodedFrame:E(b({sessionId:u(),nodeId:u().optional(),data:y(Uint8Array),pts:r().optional()}),_(),{kind:`mutation`}),pullPcm:E(b({sessionId:u(),nodeId:u().optional(),maxCount:r().int().positive().default(8)}),S(yy)),pushPcm:E(b({sessionId:u(),nodeId:u().optional(),data:y(Uint8Array),pts:r().optional()}),_(),{kind:`mutation`}),pullEncoded:E(b({sessionId:u(),nodeId:u().optional(),maxCount:r().int().positive().default(8)}),S(by)),flushEncode:E(b({sessionId:u(),nodeId:u().optional()}),S(by),{kind:`mutation`}),listActiveSessions:E(_(),S(Nhe).readonly())},vocabulary:{notOperatorFacing:O.INTERNAL}},Sy=b({className:u(),hits:r().int().nonnegative(),avgScore:r().min(0).max(1),peakScore:r().min(0).max(1)}),Cy=b({ts:r().int(),windowSec:r().int().positive(),level:b({rms:r(),dbfs:r()}),peakDbfs:r(),avgDbfs:r(),current:b({className:u(),score:r().min(0).max(1),timestamp:r().int()}).nullable(),byClass:S(Sy).readonly()}),wy=b({ts:r().int(),dbfs:r().nullable(),peakDbfs:r(),avgDbfs:r(),topClass:u().nullable(),topScore:r().min(0).max(1).nullable()}),Ty=b({points:S(wy).readonly(),effectiveSampleEveryMs:r().int().positive(),windowMsActual:r().int().nonnegative()}),Ey={name:`audio-metrics`,scope:`device`,mode:`singleton`,deviceTypes:[j.Camera],methods:{getCurrentSnapshot:E(b({deviceId:r()}),Cy.nullable()),getHistory:E(b({deviceId:r(),windowSec:r().int().positive().optional(),sampleEveryMs:r().int().positive().optional()}),Ty)},runtimeState:Cy,durability:`session`,history:`none`,vocabulary:{noun:I(`Audio metrics`,`Metriche audio`),order:3020}},Dy=b({userId:u(),username:u(),email:u().optional(),displayName:u().optional(),isAdmin:v().default(!1)}),Oy={name:`auth-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{validateCredentials:E(b({username:u(),password:u()}),Dy.nullable(),{kind:`mutation`}),getLoginUrl:E(b({state:u()}),u()),handleCallback:E(h(u(),u()),Dy,{kind:`mutation`}),validateToken:E(b({token:u()}),Dy.nullable())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.IDENTITY}},ky=b({enabled:v(),isRunning:v(),lastTriggeredAt:r(),lastError:u().nullable(),lastChangedAt:r()}),Ay={name:`automation-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Automation],methods:{enable:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.enable`,effect:{field:`enabled`,value:!0},label:I(`Enable automation`,`Abilita l’automazione`),phrase:I(`Enable {device}`,`Abilita {device}`),icon:`toggle-right`}]}),disable:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.disable`,effect:{field:`enabled`,value:!1},label:I(`Disable automation`,`Disabilita l’automazione`),phrase:I(`Disable {device}`,`Disabilita {device}`),icon:`toggle-left`}]}),trigger:E(b({deviceId:r().int().nonnegative(),skipCondition:v().optional()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.trigger`,label:I(`Trigger automation`,`Avvia l’automazione`),phrase:I(`Run {device} now`,`Esegui subito {device}`),icon:`workflow`}]})},status:{schema:ky,kind:`push`},runtimeState:ky,durability:`session`,history:`none`,vocabulary:{noun:I(`Automation`,`Automazione`),order:2100,state:[{kind:`boolean`,field:`enabled`,label:I(`Enabled`,`Abilitata`),whenTrue:I(`When {device} is enabled`,`Quando {device} viene abilitata`),whenFalse:I(`When {device} is disabled`,`Quando {device} viene disabilitata`),icon:`toggle-right`},{kind:`boolean`,field:`isRunning`,label:I(`Running`,`In esecuzione`),whenTrue:I(`When {device} starts running`,`Quando {device} parte`),whenFalse:I(`When {device} finishes`,`Quando {device} termina`),icon:`workflow`}]}},Phe=`.backup-snapshot`,Fhe=`.backup-snapshot-partial`,jy=30*6e4,My=b({databases:S(b({databaseId:Po,livePath:u()}))}),Ny=b({name:u(),rows:r().int().nonnegative()}),Py=b({livePath:u(),snapshotPath:u(),sizeBytes:r().int().nonnegative(),pageCount:r().int().nonnegative(),pageSize:r().int().positive(),tables:S(Ny),copyMs:r().nonnegative(),verifyMs:r().nonnegative(),takenAt:r()}),Fy=Py.extend({databaseId:Po}),Iy=b({databaseId:Po}),Ly=Py.extend({livePath:u(),snapshotPath:u(),databaseId:Po.optional()}),Ry={name:`database-snapshot`,scope:`system`,mode:`singleton`,internal:!0,methods:{listDatabases:E(b({}),My,{auth:`admin`}),writeSnapshot:E(Iy,Fy,{kind:`mutation`,auth:`admin`,timeoutMs:jy})},vocabulary:{notOperatorFacing:O.INTERNAL}},zy=b({subId:u(),displayName:u(),description:u().optional(),kind:u(),triggerSupported:v(),restoreSupported:v()}).extend({id:u(),addonId:u(),enabled:v(),retentionCount:r(),label:u().optional(),lastSuccessAt:r().optional(),lastSuccessSizeBytes:r().optional(),cron:u().optional(),nextRunAt:r().optional(),lastAttemptAt:r().optional(),lastError:u().optional()}),By=b({scheme:u(),keyId:u()}),Vy=b({enabled:v(),active:b({keyId:u(),publicKey:u(),createdAt:r()}).nullable(),keys:S(b({keyId:u(),createdAt:r(),retiredAt:r().nullable()})).readonly()}),Ihe=b({id:u(),filename:u(),createdAt:r(),sizeBytes:r(),label:u().optional(),locations:S(u()).readonly(),encryption:By.optional(),databases:S(Po).readonly().optional()}),Hy=b({id:u(),destinationId:u().optional(),label:u().optional(),createdAt:r(),sizeBytes:r(),locations:S(u()).optional(),encryption:By.optional()}),Uy=b({path:u(),kind:x([`file`,`dir`,`symlink`]),sizeBytes:r(),mtime:r()}),Wy=b({archiveVersion:m(1),createdAt:r(),dataDir:u(),locations:S(u()),entries:S(Uy),totalBytes:r(),totalFiles:r(),sqliteSnapshots:S(Ly).optional(),omittedDatabases:S(Po).optional()}),Gy=b({name:u(),sizeBytes:r(),fileCount:r(),present:v()}),Ky=x([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),qy=x([`queued`,`building`,`uploading`,`done`]),Jy=b({id:u(),state:Ky,phase:qy,destinationIds:S(u()).readonly(),label:u().optional(),requestedAt:r(),startedAt:r().optional(),finishedAt:r().optional(),stagedBytes:r(),archiveSizeBytes:r().optional(),uploadedBytes:r(),completedDestinationIds:S(u()).readonly(),failedDestinationIds:S(u()).readonly(),error:u().optional(),queuePosition:r().int().min(1).optional()}),Yy=b({runId:u(),queued:v(),joined:v(),cancelled:v(),entries:S(Hy).readonly()}),Xy=b({id:u(),label:u(),cron:u(),enabled:v(),locationIds:S(u()).readonly(),retentionCount:r().int().min(1).max(1e3),dataSources:S(u()).readonly().optional(),databases:S(Po).readonly().optional(),lastAttemptAt:r().optional(),lastSuccessAt:r().optional(),lastError:u().optional(),nextRunAt:r().optional()}),Zy={name:`backup`,scope:`system`,mode:`singleton`,methods:{listDestinations:E(_(),S(zy).readonly(),{auth:`admin`}),trigger:E(b({destinations:S(u()).optional(),locations:S(u()).optional(),label:u().optional(),retentionCount:r().int().min(1).max(1e3).optional(),databases:S(Po).optional()}).optional(),Yy,{kind:`mutation`,auth:`admin`}),listRuns:E(_(),S(Jy).readonly(),{auth:`admin`}),cancel:E(b({runId:u()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),list:E(_(),S(Hy).readonly(),{auth:`admin`}),listLocations:E(_(),S(Gy).readonly(),{auth:`admin`}),getEntries:E(b({destinationId:u(),backupId:u()}),Wy.nullable(),{auth:`admin`}),restore:E(b({destinationId:u(),backupId:u(),locations:S(u()).optional(),backupSecretKey:u().optional()}),_(),{kind:`mutation`,auth:`admin`}),getEncryption:E(_(),Vy,{auth:`admin`}),setupEncryption:E(b({}),b({keyId:u(),secretKey:u(),publicKey:u(),createdAt:r(),replacedKeyId:u().nullable()}),{kind:`mutation`,auth:`admin`}),disableEncryption:E(b({}),b({disabledKeyId:u().nullable()}),{kind:`mutation`,auth:`admin`}),checkBackupKey:E(b({backupSecretKey:u()}),b({valid:v(),keyId:u().nullable(),known:v(),active:v(),error:u().optional()}),{kind:`mutation`,auth:`admin`}),delete:E(b({destinationId:u(),backupId:u()}),_(),{kind:`mutation`,auth:`admin`}),listArchives:E(b({destinationId:u()}),S(Ihe).readonly(),{auth:`admin`}),upsertDestinationPolicy:E(b({locationId:u(),enabled:v(),retentionCount:r().int().min(1).max(1e3),label:u().optional()}),_(),{kind:`mutation`,auth:`admin`}),previewSchedule:E(b({cron:u(),count:r().int().min(1).max(20).optional()}),b({ok:v(),error:u().optional(),nextRuns:S(r()).readonly()})),listSchedules:E(_(),S(Xy).readonly(),{auth:`admin`}),listAvailableDatabases:E(_(),b({answered:v(),databases:S(Po).readonly()}),{auth:`admin`}),upsertSchedule:E(b({id:u().optional(),label:u(),cron:u(),enabled:v(),locationIds:S(u()).readonly(),retentionCount:r().int().min(1).max(1e3),dataSources:S(u()).readonly().optional(),databases:S(Po).readonly().optional()}),Xy,{kind:`mutation`,auth:`admin`}),deleteSchedule:E(b({id:u()}),_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`system backups — run and restored from the Backups page`}},Qy=b({level:r().min(0).max(100).nullable().meta(k(`percentage`,{label:`Charge`})),charging:x([`dc`,`solar`,`none`,`unknown`]).meta({label:`Charging source`}),sleeping:v().meta({label:`Sleeping`}),lastUpdated:r().meta(k(`none`)),voltage:r().nullable().optional().meta(k(`voltage`,{label:`Voltage`})),lastContactAt:r().optional(),lastFullRefreshAt:r().optional(),binary:v().optional().meta({label:`Binary indicator`})}),$y=[j.Camera,j.Sensor,j.Button,j.Switch,j.PetFeeder,j.Container,j.Climate,j.EventEmitter],Lhe={version:1,targets:[{id:`level`,cardinality:`scalar`,vocabulary:{cap:`battery`,stateField:`level`},deviceTypes:$y,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}]},eb={name:`battery`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:$y,methods:{},events:{onStatusChanged:{data:b({deviceId:r(),status:Qy}),notOperatorFacing:`the level / sleeping / charging state triggers each read one field of this change`}},status:{schema:Qy,kind:`push`,empty:{level:null,charging:`unknown`,sleeping:!1,lastUpdated:0}},runtimeState:Qy,durability:`restored`,history:{fields:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`}}},customize:Lhe,volatileStateFields:[`lastUpdated`],vocabulary:{noun:I(`Battery`,`Batteria`),order:5240,state:[{kind:`numeric`,field:`level`,quantity:I(`the battery level`,`il livello della batteria`),label:I(`Battery`,`Batteria`),unit:`%`,icon:`battery`},{kind:`boolean`,field:`sleeping`,label:I(`Asleep`,`In sospensione`),whenTrue:I(`When {device} goes to sleep`,`Quando {device} va in sospensione`),whenFalse:I(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`moon`},{kind:`enum`,field:`charging`,label:I(`Charging`,`Ricarica`),values:[{value:`dc`,label:I(`Charging from mains`,`In carica da rete`),phrase:I(`When {device} starts charging`,`Quando {device} inizia a caricarsi`)},{value:`solar`,label:I(`Charging from solar`,`In carica dal pannello solare`),phrase:I(`When {device} charges from its solar panel`,`Quando {device} si carica dal pannello solare`)},{value:`none`,label:I(`Not charging`,`Non in carica`),phrase:I(`When {device} stops charging`,`Quando {device} smette di caricarsi`)},{value:`unknown`,label:I(`Unknown`,`Sconosciuto`)}],icon:`battery-charging`}],extraEvents:[{category:w.DeviceAwake,label:I(`Woke up`,`Risvegliato`),phrase:I(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`sun`},{category:w.DeviceSleeping,label:I(`Went to sleep`,`In sospensione`),phrase:I(`When {device} goes to sleep`,`Quando {device} va in sospensione`),icon:`moon`}]}},tb=b({on:v().meta({label:`On`}),lastChangedAt:r()}),nb={name:`binary`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:tb,kind:`push`},runtimeState:tb,durability:`restored`,history:{fields:{on:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Binary sensor`,`Sensore binario`),order:5020,state:[{kind:`boolean`,field:`on`,label:I(`On`,`Acceso`),whenTrue:I(`When {device} turns active`,`Quando {device} si attiva`),whenFalse:I(`When {device} turns inactive`,`Quando {device} si disattiva`),icon:`toggle-right`}],overrides:{byRole:{[N.MotionSensor]:{state:{on:{label:I(`Motion`,`Movimento`),whenTrue:I(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:I(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}}},[N.ContactSensor]:{state:{on:{label:I(`Open`,`Aperto`),whenTrue:I(`When {device} opens`,`Quando {device} si apre`),whenFalse:I(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}}},[N.LeakSensor]:{state:{on:{label:I(`Leak`,`Perdita`),whenTrue:I(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:I(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}}},[N.SmokeSensor]:{state:{on:{label:I(`Smoke`,`Fumo`),whenTrue:I(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:I(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}}},[N.COSensor]:{state:{on:{label:I(`Carbon monoxide`,`Monossido di carbonio`),whenTrue:I(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:I(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}}},[N.GasSensor]:{state:{on:{label:I(`Gas`,`Gas`),whenTrue:I(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:I(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}}},[N.TamperSensor]:{state:{on:{label:I(`Tampered`,`Manomesso`),whenTrue:I(`When {device} is tampered with`,`Quando {device} viene manomesso`),whenFalse:I(`When the tamper alert on {device} clears`,`Quando l’allarme di manomissione di {device} rientra`),icon:`shield-alert`}}},[N.VibrationSensor]:{state:{on:{label:I(`Vibration`,`Vibrazione`),whenTrue:I(`When {device} vibrates`,`Quando {device} vibra`),whenFalse:I(`When {device} is still again`,`Quando {device} torna fermo`),icon:`vibrate`}}},[N.ConnectivitySensor]:{state:{on:{label:I(`Connected`,`Connesso`),whenTrue:I(`When {device} connects`,`Quando {device} si connette`),whenFalse:I(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}}},[N.SoundSensor]:{state:{on:{label:I(`Sound`,`Suono`),whenTrue:I(`When {device} hears a sound`,`Quando {device} sente un suono`),whenFalse:I(`When {device} is quiet again`,`Quando {device} torna silenzioso`),icon:`ear`}}},[N.BatterySensor]:{state:{on:{label:I(`Battery low`,`Batteria scarica`),whenTrue:I(`When the battery of {device} runs low`,`Quando la batteria di {device} si scarica`),whenFalse:I(`When the battery of {device} is fine again`,`Quando la batteria di {device} torna a posto`),icon:`battery-low`}}},[N.BinaryHelper]:{state:{on:{label:I(`On`,`Acceso`),whenTrue:I(`When {device} turns on`,`Quando {device} si accende`),whenFalse:I(`When {device} turns off`,`Quando {device} si spegne`),icon:`toggle-right`}}}}}}},rb=x([`unknown-source`,`not-admin`,`no-builder`,`no-ingress-url`,`unreachable`,`unknown-board`,`no-encryption-key`,`unreadable-config`]),Rhe=b({sourceId:u(),name:u()}),zhe=b({configuration:u(),name:u(),address:u().nullable()}),ib=b({ok:m(!1),reason:rb,detail:u().optional()}),Bhe=a(`ok`,[b({ok:m(!0),boards:S(zhe).readonly()}),ib]),Vhe=a(`ok`,[b({ok:m(!0),key:u()}),ib]),ab={name:`board-key-source`,scope:`system`,mode:`collection`,methods:{listSources:E(_(),S(Rhe).readonly(),{auth:`admin`}),listBoards:E(b({sourceId:u().min(1)}),Bhe,{auth:`admin`}),getBoardKey:E(b({sourceId:u().min(1),configuration:u().min(1)}),Vhe,{auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},ob=b({level:r().min(0).max(100).meta(k(`percentage`)),lastChangedAt:r()}),sb={name:`brightness`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Light],methods:{setBrightness:E(b({deviceId:r().int().nonnegative(),level:r().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`brightness.full`,label:I(`Full brightness`,`Luminosità massima`),phrase:I(`Set {device} to full brightness`,`Porta {device} alla massima luminosità`),icon:`sun`,effect:{field:`level`,value:100},args:{level:100}},{id:`brightness.half`,label:I(`Half brightness`,`Luminosità a metà`),phrase:I(`Dim {device} to half`,`Abbassa {device} a metà luminosità`),icon:`sun-dim`,effect:{field:`level`,value:50},args:{level:50}},{id:`brightness.off`,label:I(`Brightness off`,`Luminosità a zero`),phrase:I(`Dim {device} to zero`,`Abbassa {device} a zero`),icon:`lightbulb-off`,effect:{field:`level`,value:0},args:{level:0}},{id:`brightness.set`,label:I(`Set brightness`,`Imposta la luminosità`),phrase:I(`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:I(`Percentage`,`Percentuale`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},events:{onBrightnessChanged:{data:b({deviceId:r(),level:r().min(0).max(100),lastChangedAt:r()}),notOperatorFacing:"the `level` state trigger reads the same change"}},status:{schema:ob,kind:`command-driven`},runtimeState:ob,durability:`session`,history:{fields:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},vocabulary:{noun:I(`Brightness`,`Luminosità`),order:1010,state:[{kind:`numeric`,field:`level`,quantity:I(`the brightness`,`la luminosità`),label:I(`Brightness`,`Luminosità`),unit:`%`,icon:`sun`}]}},Hhe=x([`connected`,`disconnected`,`connecting`,`auth-failed`,`unreachable`,`error`]),cb=b({brokerCount:r().int().nonnegative(),connectedCount:r().int().nonnegative()}),Uhe=b({id:u()}),Whe=h(u(),C()),lb=b({brokerId:u(),target:h(u(),C()),payload:C().optional()}),ub=b({brokerId:u(),filter:h(u(),C())}),db=b({subscriptionId:u()}),fb=b({brokerId:u(),subscriptionId:u()}),pb=b({brokerId:u(),key:u()}),mb={name:`broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:cb,kind:`poll`},methods:{getBrokerConfig:E(Uhe,Whe.nullable(),{auth:`admin`}),publish:E(lb,C(),{kind:`mutation`,auth:`admin`}),subscribe:E(ub,db,{kind:`mutation`,auth:`admin`}),unsubscribe:E(fb,_(),{kind:`mutation`,auth:`admin`}),getState:E(pb,C().nullable(),{auth:`admin`}),getStatus:E(_(),cb)},vocabulary:{notOperatorFacing:`message-broker connections — configured, not actuated`}},hb={name:`button`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Button],methods:{press:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`button.press`,label:I(`Press`,`Premi`),phrase:I(`Press {device}`,`Premi {device}`),icon:`circle-dot`}]})},vocabulary:{noun:I(`Button`,`Pulsante`),order:1130}},gb=x([`ha`,`addon`]),_b=b({id:u().min(1),name:u().min(1),source:gb,enabled:v(),instanceId:u().min(1).optional()}),vb=b({id:u().min(1),calendarId:u().min(1),title:u(),startMs:r().int(),endMs:r().int(),allDay:v().optional(),description:u().optional(),location:u().optional()}),yb=b({calendarIds:S(u().min(1)).max(64).optional(),startMs:r().int(),endMs:r().int()}),bb={name:`calendar-source`,scope:`system`,mode:`collection`,internal:!0,providerKind:`calendar`,methods:{listCalendars:E(_(),S(_b).readonly(),{auth:`admin`}),listEvents:E(yb,S(vb).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}};function xb(e){let t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()).getTime()}function Sb(e){if(e.allDay!==!0)return{startMs:e.startMs,endMs:e.endMs};let t=xb(e.startMs),n=xb(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 Cb(e,t){let n=new Date(t),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1).getTime(),i=Sb(e);return i.startMs<r&&i.endMs>t}var wb=u().regex(/^#[0-9A-Fa-f]{6}$/,`expected #RRGGBB`),Tb=_b.extend({id:u().min(1),providerAddonId:u().min(1).optional(),defaultColor:wb,color:wb,visible:v()}),Eb=b({visible:v().optional(),color:wb.optional()}),Db=b({calendars:h(u(),Eb)}),Ob=b({calendarId:u().min(1),visible:v().optional(),color:wb.nullable().optional()}),kb={name:`calendars`,scope:`system`,mode:`singleton`,methods:{listCalendars:E(_(),S(Tb).readonly(),{auth:`admin`}),listEvents:E(yb,S(vb).readonly(),{auth:`admin`}),getPreferences:E(b({}),Db,{auth:`admin`,caller:`required`}),setCalendarPreference:E(Ob,Db,{auth:`admin`,kind:`mutation`,caller:`required`})},vocabulary:{notOperatorFacing:`calendars feed schedules and conditions, not device actions`}},Ab=b({host:u(),port:r().int().positive().optional(),onvifPort:r().int().positive().optional(),rtspPort:r().int().positive().optional(),https:v().optional(),username:u().optional(),password:u().optional(),onvifProfile:u().optional()}),jb=b({host:u(),port:r().int().positive().nullable(),onvifPort:r().int().positive().nullable(),rtspPort:r().int().positive().nullable(),https:v().nullable(),hasUsername:v(),hasPassword:v(),onvifProfile:u().nullable()}),Mb={name:`camera-credentials`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{getCredentials:E(b({deviceId:r()}),Ab.nullable(),{kind:`query`,auth:`admin`})},status:{schema:jb,kind:`command-driven`},vocabulary:{noun:I(`Camera credentials`,`Credenziali della telecamera`),order:3030}},Nb=b({x:r().min(0).max(1),y:r().min(0).max(1),width:r().gt(0).max(1),height:r().gt(0).max(1)}),Pb=b({deviceId:r().int().positive(),source:Nb,cell:Nb}),Ghe=b({profile:x([`high`,`mid`,`low`]),offered:v(),missingSources:S(r().int().positive()),canvas:u(),published:v()}),Fb=b({blockId:u(),deviceId:r().int().nonnegative(),name:u(),fps:r().int(),cells:S(Pb),profiles:S(Ghe)}),Ib=b({deviceId:r().int().nonnegative(),fps:r().int().min(1).max(60).optional(),publishedProfiles:S(x([`high`,`mid`,`low`])).max(3).optional(),cells:S(Pb).max(16)}),Lb={name:`camera-grid-layout`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{getLayout:E(b({deviceId:r().int().nonnegative()}),Fb.nullable(),{auth:`admin`}),saveLayout:E(Ib,Fb,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:I(`Grid layout`,`Layout a griglia`),order:3040}},Rb={name:`camera-pipeline-config`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:I(`Detection settings`,`Impostazioni di rilevamento`),order:3050}},zb=x([`webrtc`,`hls`,`mjpeg`,`rtsp`]),Bb=x([`mp4`,`gif`]),Vb=b({kind:Bb,handle:u(),nodeId:u(),mime:u(),bytes:r().int(),width:r().int(),height:r().int()}),Hb=b({fromTs:r(),toTs:r(),packets:r().int()}),Ub=b({media:S(Vb).readonly(),coverage:Hb,profile:A,video:x([`copy`,`encode`])}),Wb=b({brokerId:u(),url:u(),mutedUrl:u(),enabled:v(),codec:u().optional(),resolution:b({width:r().int().positive(),height:r().int().positive()}).optional()}),Gb=b({sessionId:u(),remoteAddr:u(),userAgent:u().nullish(),playing:v(),muted:v(),connectedAt:r(),lastRtpAt:r(),bytesSent:r()}),Kb=b({tag:u(),subscribedAt:r(),chunksDelivered:r()}),qb=x([`alexa`,`homekit`,`webrtc-browser`,`webrtc-mobile`,`webrtc-whep`,`rtsp-listen`,`derived-broker`,`recording`,`pipeline`,`snapshot`,`warmup`,`unknown`]),Jb=b({kind:qb,label:u().optional(),media:x([`audio`,`video`,`both`]).optional(),targetCodec:u().optional(),transport:x([`passthrough`,`repacketize`,`transcode`]).optional(),remoteAddr:u().optional(),userAgent:u().optional(),userId:u().optional(),sessionId:u().optional(),extra:h(u(),u()).optional()}).readonly(),Yb=b({id:u(),channel:x([`annexb`,`rtp`]),attribution:Jb,subscribedAt:r(),packetsDelivered:r()}),Xb=b({rtsp:S(Gb).readonly(),audio:S(Kb).readonly(),encoded:S(Yb).readonly(),pipeClients:r(),encodedSubscribers:r()}),Zb=b({deviceId:r().int().nonnegative(),viewers:r().int().positive()}),Khe=x([`reconnecting`,`sleeping`,`offline`,`disabled`,`waking`]),qhe=x([`h264`,`h265`,`copy`]),Jhe=x([`aac`,`opus`,`pcmu`,`copy`,`none`]),Qb=b({deviceId:r().int().nonnegative(),video:qhe,audio:Jhe.optional(),profile:A.optional(),targetResolution:b({width:r().int().positive(),height:r().int().positive()}).optional(),outputArgs:S(u()).optional(),audioEgress:v().optional(),hostname:u().optional(),tag:u().optional()}),$b=b({url:u(),sentryUrl:u().nullable().optional(),videoCodec:x([`H264`,`H265`]),audioCodec:u(),resolution:b({width:r().int().positive(),height:r().int().positive()}),transcoded:v(),encoder:u(),pipelineKey:u()}),ex=ga.omit({inputArgs:!0,outputArgs:!0}),tx=x([`tight`,`relaxed`]),nx=b({deviceId:r().int().nonnegative(),source:a(`kind`,[b({kind:m(`profile`),profile:A}),b({kind:m(`cam-stream`),camStreamId:u().min(1)})]),encode:ex,rateControl:tx.optional(),bitstreamFilter:x([`dump_extra`,`h264_mp4toannexb`,`hevc_mp4toannexb`]).optional(),publishLocally:v().optional(),pixelFormat:x([`yuv420p`,`nv12`]).optional(),decodeHwAccel:x([`auto`,`none`,`videotoolbox`,`vaapi`,`qsv`,`cuda`]).optional(),hostname:u().optional(),tag:u().optional()}),rx=b({url:u(),pipelineKey:u(),videoCodec:x([`H264`,`H265`]),resolution:b({width:r().int().positive(),height:r().int().positive()}),transcoded:v(),encoder:u(),decodeHwAccel:u().nullable(),camStreamId:u().nullable()}),ix={name:`stream-broker`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,methods:{reportStreamSignal:E(b({deviceId:r().int().nonnegative(),code:u().min(1),at:r().optional()}),b({accepted:v(),reason:x([`woke`,`hold-extended`,`not-enabled`,`no-consumer`,`unknown-code`])}),{kind:`mutation`}),publishCameraStream:E(b({deviceId:r().int().nonnegative(),camStreamId:u().min(1),kind:oc,url:u().optional(),codec:u().optional(),resolution:sc.optional(),fps:r().positive().optional(),label:u().optional(),deviceFeatures:S(u()).optional(),autoEligible:v().optional(),profileHint:A.optional(),metadata:h(u(),C()).optional(),sourceCamStreamId:u().min(1).optional(),encodeProfile:ga.optional()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),retractCameraStream:E(b({deviceId:r().int().nonnegative(),camStreamId:u().min(1)}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),assignProfile:E(b({deviceId:r().int().nonnegative(),profile:A,camStreamId:u().min(1)}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),unassignProfile:E(b({deviceId:r().int().nonnegative(),profile:A}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),forgetDeviceHardware:E(b({deviceId:r().int().nonnegative()}),b({derivedStreamsDeleted:S(u()).readonly(),assignmentsPurged:v(),probeSnapshotsDropped:r().int().nonnegative(),rtspTokenRowsDeleted:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),renderPreBufferClip:E(b({deviceId:r(),profile:A.optional(),aroundMs:r(),preRollSec:r().min(0).max(20).default(3),postRollSec:r().min(0).max(20).default(5),format:x([`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)}),b({base64:u(),mime:u(),bytes:r().int(),profile:A,durationMs:r()}),{kind:`mutation`,auth:`admin`}),produceEventMedia:E(b({deviceId:r(),profile:A.optional(),aroundMs:r(),preSeconds:r().min(0).max(20).default(4),postSeconds:r().min(0).max(20).default(6),kinds:S(Bb).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)}),Ub,{kind:`mutation`,auth:`admin`}),fetchEventMedia:E(b({handle:u()}),b({base64:u(),mime:u(),bytes:r().int()}).nullable(),{kind:`mutation`,auth:`admin`}),listAllCameraStreams:E(_(),S(cc).readonly()),listAllProfileSlots:E(_(),S(uc).readonly()),getBrokerStats:E(b({brokerId:u()}),bc),probeStream:E(b({brokerId:u()}),b({probed:v(),summary:u()}),{kind:`mutation`,auth:`admin`}),listClients:E(b({brokerId:u()}),Xb),getLiveViewerCounts:E(_(),S(Zb).readonly(),{role:`viewer`}),killClient:E(b({brokerId:u(),channel:x([`rtsp`,`audio`]),handle:u()}),b({killed:v()}),{kind:`mutation`,auth:`admin`}),restartProfile:E(b({deviceId:r().int().nonnegative(),profile:A}),b({success:v()}),{kind:`mutation`,auth:`admin`}),getStreamUrl:E(b({streamId:u(),format:zb}),b({url:u()})),getStreamWithCodec:E(Qb,$b,{kind:`mutation`,auth:`admin`}),releaseStreamWithCodec:E(b({pipelineKey:u()}),b({released:v(),refcount:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),acquireEgressTranscode:E(nx,rx,{kind:`mutation`,auth:`admin`}),releaseEgressTranscode:E(b({pipelineKey:u()}),b({released:v(),refcount:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),subscribeAudioChunks:E(_c,vc,{kind:`mutation`}),pullAudioChunks:E(b({subscriptionId:u(),maxCount:r().int().positive().default(8)}),S(gc).readonly()),unsubscribeAudioChunks:E(b({subscriptionId:u()}),b({released:v()}),{kind:`mutation`}),setPreBufferDuration:E(b({brokerId:u(),seconds:r().min(0).max(30)}),_(),{kind:`mutation`,auth:`admin`}),getPreBufferInfo:E(b({brokerId:u()}),b({configuredSec:r(),bufferedMs:r(),packetCount:r()})),getRtspPort:E(_(),r()),getAllRtspEntries:E(b({hostname:u().optional()}),S(Wb).readonly()),getRtspEntry:E(b({brokerId:u(),hostname:u().optional()}),Wb.nullable()),regenerateRtspToken:E(b({brokerId:u()}),u().nullable(),{kind:`mutation`,auth:`admin`}),setRtspEnabled:E(b({brokerId:u(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`}),isRtspEnabled:E(b({brokerId:u()}),v()),getDeviceAudioMute:E(b({deviceId:r().int()}),b({muted:v(),appliedBrokers:r().int().nonnegative()})),setDeviceAudioMute:E(b({deviceId:r().int(),muted:v()}),b({muted:v(),appliedBrokers:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`})},events:{onCamStreamDemand:ui(b({deviceId:r().int().nonnegative(),camStreamId:u(),profile:A})),onCamStreamIdle:ui(b({deviceId:r().int().nonnegative(),camStreamId:u()})),onRequestStreamSourceRefresh:ui(b({deviceId:r().int().nonnegative(),camStreamId:u(),brokerId:u()}))},vocabulary:{notOperatorFacing:O.PIPELINE}},ax=x([`h264`,`h265`,`hevc`,`av1`,`mjpeg`,`vp8`,`vp9`]),ox=b({acceptCodecs:S(ax).readonly().optional(),minHeight:r().int().positive().optional(),maxHeight:r().int().positive().optional(),minWidth:r().int().positive().optional(),excludeDerived:v().optional(),requireSiblingCodec:S(ax).readonly().optional(),allowTranscode:v().optional(),requireProfileBound:v().optional()}).readonly(),sx=b({preferredProviders:S(u()).readonly().optional(),resolutionPreference:x([`highest`,`lowest`]).optional(),targetHeight:r().int().positive().optional()}).readonly(),cx=b({camStreamId:u(),codec:u().optional(),resolution:sc.optional(),transcodes:v(),reason:u(),profile:A.optional(),brokerId:u().optional(),url:u().optional(),fps:r().positive().optional(),fpsSource:x([`published`,`measured`]).optional()}),lx={name:`camera-streams`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],methods:{getCameraStreams:E(b({deviceId:r().int().nonnegative()}),S(cc).readonly()),getBrokerStreams:E(b({deviceId:r().int().nonnegative()}),S(uc).readonly()),getRtspEntries:E(b({deviceId:r().int().nonnegative(),hostname:u().optional()}),S(Wb).readonly()),getProfileRtspEntries:E(b({deviceId:r().int().nonnegative(),hostname:u().optional()}),S(xc).readonly()),pickStream:E(b({deviceId:r().int().nonnegative(),requirements:ox,preferences:sx.optional()}),cx.nullable())},events:{onCamStreamsChanged:ui(b({deviceId:r().int().nonnegative(),camStreams:S(cc).readonly()}),{notOperatorFacing:`the stream catalog was rebuilt — plumbing, not a happening`}),onProfileSlotsChanged:ui(b({deviceId:r().int().nonnegative(),profileSlots:S(uc).readonly()}),{notOperatorFacing:`stream profiles were reassigned — plumbing, not a happening`})},runtimeState:b({online:v(),slotStatuses:b({high:lc.optional(),mid:lc.optional(),low:lc.optional()}),slotErrors:b({high:u().optional(),mid:u().optional(),low:u().optional()}),lastChangedAt:r()}),durability:`session`,history:`none`,vocabulary:{noun:I(`Camera streams`,`Flussi della telecamera`),order:3060}},ux=b({detected:v(),lastChangedAt:r()}),dx={name:`carbon-monoxide`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:ux,kind:`push`},runtimeState:ux,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Carbon monoxide`,`Monossido di carbonio`),order:5030,state:[{kind:`boolean`,field:`detected`,label:I(`Detected`,`Rilevato`),whenTrue:I(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:I(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}]}},fx=x([`off`,`heat`,`cool`,`auto`,`heat_cool`,`fan_only`,`dry`]),px=x([`heating`,`cooling`,`drying`,`fan`,`idle`,`off`]),mx=b({mode:fx,action:px.nullable().optional(),availableModes:S(fx),fanMode:u(),availableFanModes:S(u()),preset:u(),availablePresets:S(u()),target:r().nullable().meta(k(`temperature`)),targetHigh:r().nullable().meta(k(`temperature`)),targetLow:r().nullable().meta(k(`temperature`)),targetHumidity:r().min(0).max(100).nullable().meta(k(`humidity`)),currentTemp:r().nullable().meta(k(`temperature`)),currentHumidity:r().min(0).max(100).nullable().meta(k(`humidity`)),swingVertical:v().nullable(),swingHorizontal:v().nullable(),minTemp:r().nullable().optional().meta(k(`temperature`)),maxTemp:r().nullable().optional().meta(k(`temperature`)),tempStep:r().positive().nullable().optional().meta(k(`temperature`)),lastActiveMode:fx.exclude([`off`]).optional(),lastFetchedAt:r()}),Yhe=[j.Climate];function hx(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`climate-control`,stateField:t},deviceTypes:Yhe,apply:`replace`,path:t,sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}var gx=[hx(`room-temperature`,`currentTemp`),hx(`room-humidity`,`currentHumidity`)],Xhe={version:1,overridable:gx.map(e=>({path:e.path,by:e.id})),targets:gx},_x={name:`climate-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Climate],power:{kind:`mode`,field:`mode`,offValue:`off`,set:`setMode`,lastField:`lastActiveMode`},methods:{setMode:E(b({deviceId:r().int().nonnegative(),mode:fx}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.off`,label:I(`Climate off`,`Clima spento`),phrase:I(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`mode`,value:`off`},args:{mode:`off`}},{id:`climate.heat`,label:I(`Heat`,`Riscalda`),phrase:I(`Set {device} to heat`,`Metti {device} in riscaldamento`),icon:`flame`,effect:{field:`mode`,value:`heat`},args:{mode:`heat`}},{id:`climate.cool`,label:I(`Cool`,`Raffresca`),phrase:I(`Set {device} to cool`,`Metti {device} in raffrescamento`),icon:`snowflake`,effect:{field:`mode`,value:`cool`},args:{mode:`cool`}},{id:`climate.auto`,label:I(`Climate auto`,`Clima automatico`),phrase:I(`Set {device} to automatic`,`Metti {device} in automatico`),icon:`thermometer`,effect:{field:`mode`,value:`auto`},args:{mode:`auto`}},{id:`climate.mode`,label:I(`Set mode`,`Imposta la modalità`),phrase:I(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`thermometer`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:I(`Mode`,`Modalità`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Spento`)},{value:`heat`,label:I(`Heat`,`Riscaldamento`)},{value:`cool`,label:I(`Cool`,`Raffrescamento`)},{value:`auto`,label:I(`Automatic`,`Automatico`)},{value:`heat_cool`,label:I(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:I(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:I(`Dry`,`Deumidificazione`)}]}}]}]}),setTarget:E(b({deviceId:r().int().nonnegative(),target:r()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.target`,label:I(`Set temperature`,`Imposta la temperatura`),phrase:I(`Set {device} to {target}`,`Imposta {device} a {target}`),icon:`thermometer`,effect:{field:`target`,fromArg:`target`},openArgs:[{key:`target`,label:I(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetRange:D(b({deviceId:r().int().nonnegative(),targetLow:r(),targetHigh:r()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetRange`,label:I(`Set temperature range`,`Imposta l’intervallo di temperatura`),phrase:I(`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:I(`Lowest`,`Minima`),offer:{kind:`number`,step:.5,unit:`°C`}},{key:`targetHigh`,label:I(`Highest`,`Massima`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetHumidity:D(b({deviceId:r().int().nonnegative(),targetHumidity:r().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetHumidity`,label:I(`Set humidity`,`Imposta l’umidità`),phrase:I(`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:I(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setFanMode:D(b({deviceId:r().int().nonnegative(),fanMode:u().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.fanMode`,label:I(`Set fan mode`,`Imposta la ventilazione`),phrase:I(`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:I(`Fan mode`,`Ventilazione`),offer:{kind:`dynamic`,from:`status`,field:`availableFanModes`}}]}]}),setPreset:D(b({deviceId:r().int().nonnegative(),preset:u().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.preset`,label:I(`Set preset`,`Imposta il preset`),phrase:I(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setSwingVertical:D(b({deviceId:r().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingVerticalOn`,label:I(`Vertical swing on`,`Oscillazione verticale attiva`),phrase:I(`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:I(`Vertical swing off`,`Oscillazione verticale spenta`),phrase:I(`Stop the vertical swing of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,effect:{field:`swingVertical`,value:!1},args:{on:!1}}]}),setSwingHorizontal:D(b({deviceId:r().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingHorizontalOn`,label:I(`Horizontal swing on`,`Oscillazione orizzontale attiva`),phrase:I(`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:I(`Horizontal swing off`,`Oscillazione orizzontale spenta`),phrase:I(`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:mx,kind:`push`},runtimeState:mx,customize:Xhe,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:I(`Climate`,`Clima`),order:1070,state:[{kind:`enum`,field:`mode`,label:I(`Mode`,`Modalità`),values:[{value:`off`,label:I(`Off`,`Spento`),phrase:I(`When {device} turns off`,`Quando {device} si spegne`)},{value:`heat`,label:I(`Heat`,`Riscaldamento`),phrase:I(`When {device} starts heating`,`Quando {device} passa al riscaldamento`)},{value:`cool`,label:I(`Cool`,`Raffrescamento`),phrase:I(`When {device} starts cooling`,`Quando {device} passa al raffrescamento`)},{value:`auto`,label:I(`Automatic`,`Automatico`)},{value:`heat_cool`,label:I(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:I(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:I(`Dry`,`Deumidificazione`)}],icon:`thermometer`},{kind:`numeric`,field:`currentTemp`,quantity:I(`the temperature`,`la temperatura`),label:I(`Temperature`,`Temperatura`),unit:`°C`,icon:`thermometer`},{kind:`numeric`,field:`currentHumidity`,quantity:I(`the humidity`,`l’umidità`),label:I(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`},{kind:`numeric`,field:`target`,quantity:I(`the set temperature`,`la temperatura impostata`),label:I(`Set temperature`,`Temperatura impostata`),unit:`°C`,icon:`thermometer`}]}},vx=x([`backup`,`hub-server`,`agent-server`,`addons`]),yx=x([`pending`,`running`,`ok`,`failed`,`skipped`]),bx=x([`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`]),xx=b({kind:vx,nodeId:u().optional(),status:yx,detail:u(),reason:bx.optional(),fromVersion:u().nullable().optional(),packages:S(u()).readonly().optional(),startedAt:r().optional(),finishedAt:r().optional()}),Sx=x([`running`,`succeeded`,`failed`]),Cx=b({id:u(),state:Sx,targetVersion:u(),requestedBy:u(),startedAt:r(),finishedAt:r().optional(),steps:S(xx).readonly(),stoppedAt:u().optional(),reason:bx.optional(),skippedOffline:S(u()).readonly()}),wx=b({version:u().optional(),addons:v().optional(),backup:v().optional()}),Tx=x([`no-target`,`node-busy`,`job-running`,`nothing-to-do`,`status-unreadable`]),Ex=b({targetVersion:u().nullable(),steps:S(xx).readonly(),skippedOffline:S(u()).readonly(),blocker:Tx.nullable(),blockerDetail:u().nullable()}),Dx=b({accepted:v(),jobId:u().nullable(),blocker:Tx.nullable(),message:u()}),Ox={name:`cluster-update`,scope:`system`,mode:`singleton`,methods:{previewClusterUpdate:E(wx,Ex,{auth:`admin`}),startClusterUpdate:E(wx,Dx,{kind:`mutation`,auth:`admin`}),getClusterUpdateJob:E(b({jobId:u().optional()}),Cx.nullable(),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.CLUSTER}},kx=b({r:r().int().min(0).max(255).meta(k(`none`)),g:r().int().min(0).max(255).meta(k(`none`)),b:r().int().min(0).max(255).meta(k(`none`))}),Ax=b({h:r().min(0).max(360).meta(k(`none`)),s:r().min(0).max(100).meta(k(`none`)),v:r().min(0).max(100).meta(k(`none`))}),jx=a(`mode`,[b({mode:m(`rgb`),rgb:kx}),b({mode:m(`hsv`),hsv:Ax}),b({mode:m(`mired`),colorTemperature:r().int().min(50).max(1e3)})]),Mx=b({mode:x([`rgb`,`hsv`,`mired`]),rgb:kx.optional(),hsv:Ax.optional(),colorTemperature:r().int().optional().meta(k(`colour-temperature`)),lastChangedAt:r()});function Zhe(e){let t=jx.safeParse(e);return t.success?t.data:null}var Nx={name:`color`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Light],methods:{setColor:E(b({deviceId:r().int().nonnegative(),color:jx}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`color.warmWhite`,label:I(`Warm white`,`Bianco caldo`),phrase:I(`Set {device} to warm white`,`Imposta {device} su bianco caldo`),icon:`sun`,args:{color:{mode:`mired`,colorTemperature:370}}},{id:`color.coolWhite`,label:I(`Cool white`,`Bianco freddo`),phrase:I(`Set {device} to cool white`,`Imposta {device} su bianco freddo`),icon:`snowflake`,args:{color:{mode:`mired`,colorTemperature:200}}},{id:`color.red`,label:I(`Red`,`Rosso`),phrase:I(`Turn {device} red`,`Colora {device} di rosso`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:255,g:0,b:0}}}},{id:`color.green`,label:I(`Green`,`Verde`),phrase:I(`Turn {device} green`,`Colora {device} di verde`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:255,b:0}}}},{id:`color.blue`,label:I(`Blue`,`Blu`),phrase:I(`Turn {device} blue`,`Colora {device} di blu`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:0,b:255}}}}]})},events:{onColorChanged:{data:b({deviceId:r(),mode:x([`rgb`,`hsv`,`mired`]),rgb:kx.optional(),hsv:Ax.optional(),colorTemperature:r().int().optional(),lastChangedAt:r()}),notOperatorFacing:"a colour change is read through the `mode` state trigger"}},status:{schema:Mx,kind:`command-driven`},runtimeState:Mx,durability:`session`,history:`none`,vocabulary:{noun:I(`Colour`,`Colore`),order:1020,state:[{kind:`enum`,field:`mode`,label:I(`Colour mode`,`Modalità colore`),values:[{value:`rgb`,label:I(`RGB colour`,`Colore RGB`)},{value:`hsv`,label:I(`HSV colour`,`Colore HSV`)},{value:`mired`,label:I(`White temperature`,`Temperatura del bianco`)}],icon:`palette`}]}},Px=1/36e8;function Fx(e){return e*Px}var Ix=[`min`,`max`,`mean`,`sum`,`count`,`change`],Qhe=[`gauge`,`counter`,`boolean`];function Lx(e){return typeof e==`number`&&Number.isFinite(e)}function Rx(e){return Lx(e.value)?e.value:Lx(e.last)?e.last:null}function $he(e){let t=e.points.filter(t=>t.t>=e.from&&t.t<e.to),n=Lx(e.before?.value)?e.before.value:null,r=n,i=e.from,a=0,o=[];if(r===null){let n=t.find(e=>Rx(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=Rx(n)}for(let e of t){let t=Rx(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)=>Rx(t)??e,r);return{segments:o,included:t.length,gaps:a,end:s,start:n}}function ege(e){let t=e.points.filter(e=>Lx(e.twMean)&&Lx(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=>Lx(e.last)?[e.last]:[]),a=i.length>0?i[i.length-1]??null:null;return{segments:t.flatMap(e=>Lx(e.twMean)&&Lx(e.twMs)?[{value:e.twMean,ms:e.twMs}]:[]),included:t.length,gaps:r,end:a,start:Lx(e.before?.value)?e.before.value:null}}function zx(e){if(e.tier!==`raw`){let t=ege(e);if(t!==null)return t}return $he(e)}function tge(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 nge(e,t){let n=[],r=[];for(let t of e.points)Lx(t.min)&&n.push(t.min),Lx(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 rge(e){let t=e.points.flatMap(e=>Lx(e.delta)?[e.delta]:[]);return t.length===0?null:t.reduce((e,t)=>e+t,0)}function Bx(e){return{write:`hold`,value:null,included:0,excluded:0,reason:e}}function Vx(e,t){return{write:`null`,value:null,included:t,excluded:1,reason:e}}function Hx(e,t,n,r){return{write:`number`,value:e,included:t,excluded:n,reason:n>0?r:null}}var Ux=`history has a gap — that interval was not counted as zero`;function ige(e,t){if(t.truncated)return Bx(`the history query was truncated — the last statistic is kept`);if(e===`sum`&&t.kind!==`counter`)return Bx(`a gauge has no sum — that is the integral template`);if(t.to<=t.from)return Vx(`the range is empty`,0);let n=zx(t);if(n.segments.length===0&&n.start===null)return Vx(Ux,n.included);if(e===`count`)return Hx(n.included,n.included,n.gaps,Ux);if(e===`sum`||e===`change`&&t.kind===`counter`){let e=rge(t);return e===null?Vx(`the counter has no growth in this range`,n.included):Hx(e,n.included,n.gaps,Ux)}if(e===`change`)return n.start===null||n.end===null?Vx(`the change has no value at the start of the range`,n.included):Hx(n.end-n.start,n.included,n.gaps,Ux);if(e===`min`||e===`max`){let r=nge(t,n),i=e===`min`?r.min:r.max;return i===null?Vx(Ux,n.included):Hx(i,n.included,n.gaps,Ux)}let r=tge(n.segments);return r===null?Vx(Ux,n.included):Hx(r,n.included,n.gaps,Ux)}function age(e,t){if(e.truncated)return Bx(`the history query was truncated — the last total is kept`);if(e.kind===`counter`)return Bx(`a counter is already a total — it is not integrated again`);if(e.to<=e.from)return Vx(`the range is empty`,0);let n=zx(e);if(n.segments.length===0)return{write:`hold`,value:null,included:n.included,excluded:n.gaps,reason:Ux};let r=0;for(let e of n.segments)r+=e.value*e.ms;return Hx(t===`energy-kwh`?Fx(r):r/1e3,n.included,n.gaps,Ux)}function oge(e){let t=[];e.before!==null&&Lx(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=Rx(n);if(r===null)continue;let i=e.tier===`raw`||!Lx(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 sge=.1,cge=`history stops short of the window — the rate is over the part that was measured`;function Wx(e,t,n,r,i){return Hx(e/(t/n),r,+(i-t>i*sge),cge)}function lge(e,t){if(e.truncated)return Bx(`the history query was truncated — the last rate is kept`);if(e.to<=e.from)return Vx(`the range is empty`,0);let n=e.to-e.from,r=oge(e),i=r[0],a=r[r.length-1];if(i===void 0||a===void 0)return Vx(`history has no reading in this window`,0);if(e.kind===`counter`){let o=e.before!==null&&Lx(e.before.value),s=o?e.from:i.at,c=e.points.flatMap(t=>t.t>=e.from&&t.t<=e.to&&Lx(t.delta)&&(o||t.t>i.at)?[t.delta]:[]),l=a.at-s;return c.length===0||l<=0?Vx(`the counter has no growth in this window`,r.length):Wx(c.reduce((e,t)=>e+t,0),l,t,r.length,n)}if(r.length===1&&i.at===e.from&&e.before!==null)return Hx(0,1,0,null);let o=a.at-i.at;return r.length<2||o<=0?Vx(`the rate needs two readings in the window`,r.length):Wx(a.value-i.value,o,t,r.length,n)}var Gx=6e4,Kx=60*Gx,qx=24*Kx,Jx=[`1h`,`24h`,`2d`,`7d`,`30d`,`custom`],Yx=[`today`,`yesterday`,`this-week`,`this-month`],uge=[`raw`,`5m`,`1h`,`1d`],Xx=[`never`,`daily`,`weekly`,`monthly`],Zx=6e4,Qx=5*Gx,dge={"1h":Kx,"24h":24*Kx,"2d":2*qx,"7d":7*qx,"30d":30*qx},$x={rawMs:7*qx,fiveMinuteMs:30*qx,hourMs:365*qx,dayMs:null};function fge(e){return{rawMs:eS(e.rawDays,$x.rawMs),fiveMinuteMs:eS(e.fiveMinuteDays,$x.fiveMinuteMs),hourMs:eS(e.hourDays,$x.hourMs),dayMs:pge(e.dayDays)}}function eS(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>0?e*qx:t}function pge(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?null:e*qx}var tS=b({kind:m(`rolling`),span:x(Jx),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})}),nS=tS,rS=b({kind:m(`calendar`),period:x(Yx)}),mge=rS,iS=a(`kind`,[tS,rS]),hge={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6},aS=new Map;function gge(e){let t=aS.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 aS.set(e,n),n}function oS(e,t){let n=gge(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=hge[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 sS(e,t){let n=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second),r=oS(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=oS(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 cS(e,t){let n=oS(e,t);return n===null?null:sS({...n,hour:0,minute:0,second:0},t)}function lS(e,t){let n=oS(e,t);return n===null?null:sS({...n,day:1,hour:0,minute:0,second:0},t)}function uS(e,t){let n=oS(e,t),r=cS(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=cS(r-1,t);if(e===null)return null;r=e}return r}function dS(e){return e===null?`forever`:e%864e5==0?`${e/qx} d`:e%36e5==0?`${e/Kx} h`:`${e/Gx} min`}function _ge(e){return`raw ${dS(e.rawMs)}, 5m ${dS(e.fiveMinuteMs)}, 1h ${dS(e.hourMs)}, 1d ${dS(e.dayMs)}`}function fS(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 ${dS(e)} and no history tier is kept strictly longer (${_ge(t)})`}}function pS(e){return e.span===`custom`?e.customMinutes===void 0?null:e.customMinutes*Gx:dge[e.span]}function mS(e){if(e.kind===`rolling`)return pS(e);switch(e.period){case`today`:case`yesterday`:return 25*Kx;case`this-week`:return 6084e5;case`this-month`:return 2682e6}}function hS(e,t){let n=mS(e);return n===null?{ok:!1,reason:`a custom range needs a duration of at least 5 minutes`}:fS(n,t)}function gS(e,t){switch(e){case`never`:return fS(1/0,t);case`daily`:return fS(25*Kx,t);case`weekly`:return fS(6084e5,t);case`monthly`:return fS(2682e6,t)}}function vge(e,t,n){if(e.kind===`rolling`){let n=pS(e);return n===null?null:{from:t-n,to:t}}let r=cS(t,n);if(r===null)return null;switch(e.period){case`today`:return{from:r,to:t};case`yesterday`:{let e=cS(r-1,n);return e===null?null:{from:e,to:r}}case`this-week`:{let e=uS(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 yge(e,t,n){if(e===`never`)return{from:0,to:t};let r=cS(t,n);if(r===null)return null;if(e===`daily`)return{from:r,to:t};if(e===`weekly`){let e=uS(t,n);return e===null?null:{from:e,to:t}}let i=lS(t,n);return i===null?null:{from:i,to:t}}function bge(e,t){let n=cS(e,t);return n===null?null:cS(n+26*Kx,t)}function xge(e){if(e.kind===`calendar`)return e.period===`today`?Zx:Qx;let t=pS(e);return t!==null&&t<=24*36e5?Zx:Qx}function Sge(e){return e===`raw`?Zx:Qx}var _S=b({addonId:u().min(1),stableId:u().min(1)}),vS=[`temperature`,`humidity`,`pressure`,`illuminance`,`power`,`energy`,`battery`,`numeric`,`motion`,`contact`,`leak`,`smoke`,`occupancy`,`binary`,`switch`,`light`,`fan`,`cover`,`valve`,`lock`,`media-player`,`climate`],yS=[`mean`,`median`,`min`,`max`,`sum`],bS=[`any`,`all`],xS=[`at-least-one`,`all`],SS=[`mean`,`median`,`min`,`max`,`sum`,`any`,`all`],CS=x(vS),wS=x(SS),TS=x(xS),ES=b({source:_S,cap:u().min(1),fieldPath:u().min(1)}),DS=b({kind:m(`group`),templateId:CS,aggregate:wS,members:S(ES).min(1).max(64),active:TS.optional()}),OS=b({kind:m(`statistic`),stat:x(Ix),window:iS,source:ES}),Cge=OS,kS=[`energy`,`meter`],AS=b({kind:m(`integral`),reset:x(Xx),output:x(kS),source:ES}),wge=AS,jS=b({kind:m(`threshold`),source:ES,high:r(),low:r(),onForMs:r().int().nonnegative(),offForMs:r().int().nonnegative()}),Tge=jS,MS=[`sum`,`difference`,`ratio`],NS=b({kind:m(`arithmetic`),op:x(MS),inputs:S(ES).min(2).max(64)}),Ege=NS,PS=[`number`,`boolean`],FS=b({kind:m(`expression`),expr:u().min(1),inputs:S(b({name:u().min(1),member:ES})).min(1).max(64),output:x(PS)}),Dge=FS,IS=[`second`,`minute`,`hour`],LS=b({kind:m(`derivative`),window:nS,per:x(IS),source:ES}),Oge=LS,RS=[`high`,`mid`,`low`],zS=b({x:r().min(0).max(1),y:r().min(0).max(1),width:r().gt(0).max(1),height:r().gt(0).max(1)}),BS=b({source:_S,region:zS,cell:zS}),VS=b({kind:m(`grid`),fps:r().int().min(1).max(60),publishedProfiles:S(x(RS)).max(3),cells:S(BS).max(16)}),kge=VS,HS=[`mid`,`low`];function US(){return{kind:`grid`,fps:10,publishedProfiles:[...HS],cells:[]}}var WS=b({kind:m(`terminal`),terminalId:u().uuid()}),Age=WS,GS=a(`kind`,[VS,WS,DS,OS,AS,jS,NS,FS,LS]);function KS(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`terminal`:return[]}}var Mge=[`grid`,`terminal`];function qS(e){return e.kind===`grid`||e.kind===`terminal`}function Nge(e){return e.kind===`grid`?e.cells.map(e=>e.source):[]}var JS=`composed-`,YS=`composer`,Pge=`customize:`,XS=2e4,ZS=b({source:_S,cap:u().min(1),fieldPath:u().min(1)}),QS=ZS.extend({kind:m(`from`)}),$S=b({kind:m(`literal`),value:g([u(),r(),v(),se()])}),eC=a(`kind`,[QS,$S]),tC=b({kind:m(`expression`),expr:u().min(1).max(dm),bindings:h(u().regex(fm),eC)}).superRefine((e,t)=>{let n=Am(e);n!==null&&t.addIssue({code:`custom`,message:n,path:[`expr`]})}),nC=b({kind:m(`code`),code:u().min(1).max(XS)}),rC=b({kind:m(`aggregate`),reducer:x([`mean`,`median`,`min`,`max`,`sum`,`any`,`all`]),reads:S(ZS).min(1).max(64),activeWhen:S(u().min(1)).min(1).optional(),publish:x([`value`,`included`,`excluded`,`total`]),empty:x([`null`,`omit`,`offline`])}),iC=b({kind:m(`series`),read:ZS,publish:x([`value`,`included`,`excluded`,`total`]),empty:x([`null`,`omit`,`offline`])}),aC=a(`kind`,[QS,tC,nC,rC,iC]),oC=`$input`,sC=g([u(),r(),v(),c({[oC]:u().min(1)}),h(u().min(1),o(()=>sC))]),cC=sC;function lC(e){return typeof e==`object`&&typeof e.$input==`string`}var uC=b({kind:m(`forward`),source:_S,cap:u().min(1),method:u().min(1),args:h(u().min(1),cC).optional()}),dC=b({kind:m(`extension`),target:m(`remote`)}),fC=a(`kind`,[uC,nC,dC]),pC=/^[a-z0-9][a-z0-9-]{0,47}$/,mC=`items`,hC=b({label:u().min(1).max(80),fields:h(u().min(1),aC),reset:uC.optional()}),gC=b({linkId:u().min(1)}),_C=b({kind:m(`fields`),cap:u().min(1),enabled:v().optional(),fields:h(u().min(1),aC).refine(e=>Object.keys(e).length<=32,{message:`at most 32 fields per capability`}),items:h(u().regex(pC),hC).refine(e=>Object.keys(e).length<=16,{message:`at most 16 items`}).optional(),commands:h(u().min(1),fC).optional(),contributedBy:gC.optional()}),vC=b({kind:m(`passthrough`),cap:u().min(1),enabled:v().optional(),source:_S}),yC=a(`kind`,[_C,vC]);function bC(e){return e.enabled!==!1}var xC=b({kind:m(`new`),type:x(j),role:x(N).optional()});function Fge(e){if(!SC(e))return e;let t=Reflect.get(e,`source`);if(!SC(t))return e;let n=Reflect.get(t,`composition`);if(!SC(n))return e;let r=Reflect.get(n,`target`);if(!SC(r))return e;let i=Reflect.get(r,`type`);if(typeof i!=`string`)return e;let a={...r,type:pf(i)};return{...e,source:{...t,composition:{...n,target:a}}}}function SC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var CC=b({kind:m(`existing`),device:_S}),wC=a(`kind`,[xC,CC]),TC=b({target:wC,features:S(yC).min(0).max(16),helper:GS.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 EC(e){return`${e.addonId}/${e.stableId}`}function DC(e,t){return`${EC(e)}#${t}`}function OC(e){return`${DC(e.source,e.cap)}.${e.fieldPath}`}function kC(e){return`${JS}${e}`}function AC(e){return{addonId:YS,stableId:kC(e)}}function jC(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 MC(e,t,n){return`${e}[${t}].${n}`}function NC(e,t=mC){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:MC(t,e,n),source:r})))]}function PC(e){return NC(e).map(e=>e.source)}function FC(e,t){let n=e;for(let e of t.split(`.`)){let t=ah(n);if(!(t instanceof ue))return null;let r=t.shape[e];if(!(r instanceof oe))return null;n=r}return n}function IC(e,t){let n=ch(e).find(e=>e.path===t);if(n===void 0)return null;let r=FC(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 LC(e){return new Map(ch(e).filter(e=>!e.path.includes(`.`)).flatMap(t=>{let n=IC(e,t.path);return n===null?[]:[[t.path,n]]}))}function RC(e){let t=ah(e);return t instanceof ue?Object.entries(t.shape).flatMap(([e,t])=>t instanceof oe&&!t.safeParse(void 0).success?[e]:[]):[]}function zC(e,t){let n=t.split(`.`);return n.slice(0,-1).flatMap((t,r)=>{let i=n.slice(0,r+1).join(`.`),a=FC(e,i);return a!==null&&a.safeParse(void 0).success?[i]:[]})}var BC={"doorbell.onPressed":w.DoorbellOnPressed},Ige=BC,VC=b({featureIndex:r().int().nonnegative(),cap:u(),eventName:u(),category:x(w),stateField:u(),fieldKey:u()});function HC(e,t,n){return{code:e,path:t,message:n}}function Lge(e){return e.issues.map(e=>`${e.path.length===0?`payload`:e.path.join(`.`)}: ${e.message}`).join(`; `)}function UC(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?IC(e.runtimeState,s.field):null;if(l===null){r.push(HC(`unknown-field`,c,`\`${e.name}.${a}\` derives from missing state field \`${s.field}\``));continue}if(l.kind!==`number`){r.push(HC(`kind-mismatch`,c,`\`${e.name}.${a}\` needs a numeric state field; \`${s.field}\` is ${l.kind}`));continue}let u=`${e.name}.${a}`,d=Ige[u];if(d===void 0){r.push(HC(`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(HC(`not-composable`,`features[${t.featureIndex}].cap`,`\`${u}\` cannot be derived from { deviceId, timestamp }: ${Lge(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(HC(`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 WC=x(`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(`.`)),GC=b({code:WC,path:u(),message:u()}),KC=x([`string`,`number`,`boolean`,`enum`]),qC=x([`null`,`offline`,`unknown`,`release`,`omit`]),JC=x([`derived`,`clock`,`constant`,`accumulator`]),YC=b({arrayPath:u(),key:u(),label:u(),resettable:v().optional()}),XC=b({cap:u(),path:u(),item:YC.optional(),featureIndex:r().int().nonnegative(),kind:KC,nullable:v(),required:v(),unavailable:qC,role:JC,source:aC,reads:S(ZS)});function ZC(e){let t=e.item===void 0?e.path:MC(e.item.arrayPath,e.item.key,e.path);return`${e.cap}.${t}`}var QC=x([`new`,`add`,`replace`]),$C=b({featureIndex:r().int().nonnegative(),cap:u(),mode:QC}),ew=b({ok:v(),problems:S(GC),fields:S(XC),features:S($C),events:S(VC)}),tw=x([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),nw=x([`fresh`,`stale`,`unavailable`]),rw=b({cap:u(),path:u(),item:YC.optional(),state:nw,value:g([u(),r(),v(),se()]),reason:u().optional()}),iw=b({blockId:u(),deviceId:r().nullable(),status:tw,reason:u().optional(),fields:S(rw)}),Rge=YS,aw=b({id:u().min(1),name:u().min(1).max(120),enabled:v(),updatedAt:r(),composition:TC}),ow=b({id:u().min(1),name:u().nullable(),error:u()}),sw=b({deviceId:r().int(),capName:u(),owner:u(),error:u()}),cw=b({integrationId:u().nullable(),storeLoaded:v(),blocks:S(aw),restartBlockIds:S(u()),unreadableBlocks:S(ow),retiredBlockIds:S(u()).optional()}),lw=b({blockId:u(),status:tw,reason:u().optional()}),uw=b({blocks:S(lw),acted:v(),unreleasedClaims:S(sw).optional()}),dw={name:`composer`,scope:`system`,mode:`singleton`,internal:!0,methods:{applyBlocks:E(cw,uw,{kind:`mutation`,auth:`admin`}),getStates:E(b({blockIds:S(u())}),b({states:S(iw)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`device composition — an authoring tool, not an action`}},fw=b({connected:v(),lastChangedAt:r()}),pw={name:`connectivity`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:fw,kind:`push`},runtimeState:fw,durability:`restored`,history:{fields:{connected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Connectivity`,`Connettività`),order:5040,state:[{kind:`boolean`,field:`connected`,label:I(`Connected`,`Connesso`),whenTrue:I(`When {device} connects`,`Quando {device} si connette`),whenFalse:I(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}]}},mw=x([`wear`,`supply`,`waste`]),hw=x([`part`,`tank`,`product`,`bin`]),gw=x([`ok`,`low`,`empty`,`full`,`replace`]),_w=x([`ok`,`low`,`empty`,`full`]);function vw(e){return e.kind??`wear`}var zge={wear:`part`,waste:`bin`,supply:`product`};function yw(e){return e.form??zge[vw(e)]}var bw=x([`duration`,`count`]),xw=b({value:r().min(0).nullable().meta(k(`device`)),kind:bw}),Sw=b({key:u().min(1),label:u().min(1),level:r().min(0).max(100).nullable().meta(k(`percentage`)),status:gw.nullable(),kind:mw.optional(),form:hw.optional(),lastResetAt:r().nullable(),resettable:v(),remaining:xw.optional()}),Cw=b({items:S(Sw),lastChangedAt:r()}),Bge={items:[],lastChangedAt:0},Vge={version:1,targets:[{id:`items`,cardinality:`keyedArray`,vocabulary:{cap:`consumables`},deviceTypes:Object.values(j),apply:`add`,path:`items`,keyField:`key`,labelField:`label`,itemSchema:Sw,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:[...bw.options]}]},{path:`status`,sources:[{kind:`enum`,transforms:[{kind:`enum-map`,outputValues:[...gw.options],unmapped:null}]}]}],traits:[{path:`kind`,values:[...mw.options],defaultValue:`wear`},{path:`form`,values:[...hw.options],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}],advancedExpression:!0}]},ww={name:`consumables`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:Object.values(j),methods:{reset:E(b({deviceId:r().int().nonnegative(),key:u().min(1)}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`consumables.reset`,label:I(`Mark as replaced`,`Segna come sostituito`),phrase:I(`Mark {key} as replaced on {device}`,`Segna {key} come sostituito su {device}`),icon:`refresh-cw`,openArgs:[{key:`key`,label:I(`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:Cw,kind:`push`,empty:Bge,itemArray:{path:`items`,keyField:`key`,labelField:`label`,itemSchema:Sw,emptyItem:{key:``,label:``,level:null,status:null,lastResetAt:null,resettable:!1}}},runtimeState:Cw.extend({lastFetchedAt:r()}),durability:`restored`,customize:Vge,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:I(`Consumables`,`Materiali di consumo`),order:2070}},Tw=b({entryOpen:v(),lastChangedAt:r()}),Ew={name:`contact`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:Tw,kind:`push`},runtimeState:Tw,durability:`restored`,history:{fields:{entryOpen:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Contact`,`Contatto`),order:5050,state:[{kind:`boolean`,field:`entryOpen`,label:I(`Open`,`Aperto`),whenTrue:I(`When {device} opens`,`Quando {device} si apre`),whenFalse:I(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}]}},Dw=x([`numeric`,`select`,`text`,`datetime`]),Ow=b({kind:Dw,value:g([r().meta(k(`device`)),u()]),options:S(u()),lastChangedAt:r(),min:r().optional().meta(k(`device`)),max:r().optional().meta(k(`device`)),step:r().optional().meta(k(`device`))}),Hge=a(`kind`,[b({kind:m(`numeric`),value:r()}),b({kind:m(`select`),value:u().min(1)}),b({kind:m(`text`),value:u()}),b({kind:m(`datetime`),value:u().min(1)})]),kw=b({deviceId:r().int().nonnegative(),cycle:v().default(!0)}),Aw=b({deviceId:r().int().nonnegative()}),jw={name:`control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Control],methods:{setValue:E(b({deviceId:r().int().nonnegative(),control:Hge}),_(),{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:D(kw,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.next`,label:I(`Next option`,`Opzione successiva`),phrase:I(`Select the next option on {device}`,`Seleziona l’opzione successiva su {device}`),icon:`skip-forward`,openArgs:[{key:`cycle`,label:I(`Wrap to the first option`,`Ricomincia dalla prima opzione`),offer:{kind:`boolean`}}]}]}),previous:D(kw,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.previous`,label:I(`Previous option`,`Opzione precedente`),phrase:I(`Select the previous option on {device}`,`Seleziona l’opzione precedente su {device}`),icon:`skip-back`,openArgs:[{key:`cycle`,label:I(`Wrap to the last option`,`Ricomincia dall’ultima opzione`),offer:{kind:`boolean`}}]}]}),first:D(Aw,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.first`,label:I(`First option`,`Prima opzione`),phrase:I(`Select the first option on {device}`,`Seleziona la prima opzione su {device}`),icon:`chevron-first`}]}),last:D(Aw,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.last`,label:I(`Last option`,`Ultima opzione`),phrase:I(`Select the last option on {device}`,`Seleziona l’ultima opzione su {device}`),icon:`chevron-last`}]})},status:{schema:Ow,kind:`push`},runtimeState:Ow,durability:`session`,history:`none`,vocabulary:{noun:I(`Control`,`Controllo`),order:1150,state:[{kind:`value`,field:`value`,label:I(`Value`,`Valore`),offer:{kind:`dynamic`,from:`status`,field:`options`},icon:`sliders-horizontal`}]}},L=class extends Error{code;constructor(e,t){super(t),this.name=`IrCodecError`,this.code=e}},Mw=1024,Nw=S(r().int()).min(2).max(Mw).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]})})}),Pw=b({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()}),Uge=.241246,Wge=0;function Fw(e){let t=e.trim().split(/\s+/).filter(e=>e.length>0);if(t.length<4)throw new L(`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 L(`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 L(`pronto-malformed`,`Pronto header incomplete`);if(r!==Wge)throw new L(`pronto-unsupported-form`,`Pronto form ${t[0]??``} is not supported, only the learned 0000 form`);if(i===0)throw new L(`pronto-malformed`,`Pronto frequency word is zero`);let s=a+o;if(s===0||n.length!==4+s*2)throw new L(`pronto-malformed`,`Pronto declares ${s} burst pairs but carries ${(n.length-4)/2} word pairs`);let c=i*Uge,l=n.slice(4).map((e,t)=>{let n=Math.max(1,Math.round(e*c));return t%2==0?n:-n}),u=Nw.safeParse(l);if(!u.success)throw new L(`invalid-timings`,`Pronto decoded to invalid timings: ${u.error.message}`);return{timings:u.data,carrierHz:Math.round(1e6/c)}}var Gge=8192,Iw=32,Lw=3,Kge=264,Rw=Mw*2;function qge(e){let t=[],n=0,r=e=>{if(t.length+e>Rw)throw new L(`tuya-malformed`,`decompressed code is larger than any IR train`)},i=()=>{let t=e[n++];if(t===void 0)throw new L(`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 L(`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 L(`tuya-malformed`,`back-reference is invalid`);t.push(n)}}return Uint8Array.from(t)}function Jge(e){let t=[],n=new Map,r=0,i=n=>{for(let i=r;i<n;i+=Iw){let r=Math.min(i+Iw,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+Lw<=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<=Gge){let t=0;for(;a+t<e.length&&t<Kge&&e[r+t]===e[a+t];)t++;t>=Lw&&(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 zw=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Yge=65535;function Xge(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+=zw[o>>18&63],t+=zw[o>>12&63],t+=n+1<e.length?zw[o>>6&63]:`=`,t+=n+2<e.length?zw[o&63]:`=`}return t}function Zge(e){let t=e.trim().replace(/=+$/,``);if(t.length===0||t.length%4==1)throw new L(`tuya-malformed`,`not a base64 string`);let n=[],r=0,i=0;for(let e of t){let t=zw.indexOf(e);if(t<0)throw new L(`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 Bw(e){let t=new Uint8Array(e.length*2);return e.forEach((e,n)=>{let r=Math.abs(e);if(r===0||r>Yge)throw new L(`invalid-timings`,`timing ${n} does not fit 16 bits`);t[n*2]=r&255,t[n*2+1]=r>>8}),Xge(Jge(t))}function Vw(e){let t=qge(Zge(e));if(t.length===0||t.length%2!=0)throw new L(`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=Nw.safeParse(n);if(!r.success)throw new L(`tuya-malformed`,r.error.message);return r.data}var Hw=x([`tuya`]),Uw=Math.ceil((Rw+Math.ceil(Rw/32))/3)*4+256,Ww=b({format:Hw,code:u().min(1).max(Uw)}),Gw={tuya:{encode:Bw,decode:Vw}},Kw=a(`kind`,[b({kind:m(`raw`),timings:S(r().int()),settings:Pw.optional()}),b({kind:m(`pronto`),code:u()}),b({kind:m(`native`),format:Hw,code:u()})]);function qw(e){if(e.kind===`pronto`){let t=Fw(e.code);return{timings:t.timings,settings:{carrierHz:t.carrierHz}}}if(e.kind===`native`)return{timings:Gw[e.format].decode(e.code),settings:{}};let t=Nw.safeParse(e.timings);if(!t.success)throw new L(`invalid-timings`,t.error.message);return{timings:t.data,settings:e.settings??{}}}var Jw=`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(`.`),Yw=[`source_select`];function Xw(e){return Yw.includes(e)}var Zw=`custom:`,Qge=/^[a-z0-9][a-z0-9_]{0,47}$/,$ge=new Set(Jw);function Qw(e){return $ge.has(e)}function $w(e){return Qge.test(e)}function eT(e){return`${Zw}${e}`}function tT(e){if(!e.startsWith(`custom:`))return null;let t=e.slice(7);return $w(t)?t:null}function nT(e){return Qw(e)||tT(e)!==null}var rT=u().refine(nT,{message:`a role is one of the known roles or custom:<key> (lowercase letters, digits, _)`}),iT=[`digits`,`sequence`,`ir`],e_e=x(iT),t_e=/^[a-z0-9][a-z0-9_-]{0,47}$/,n_e=RegExp(`^[0-9]{1,6}$`),aT={id:u().regex(t_e,{message:`a lowercase slug`}),name:u().trim().min(1).max(60)},oT=b({...aT,kind:m(`digits`),number:u().regex(n_e,{message:`up to 6 digits`})}),sT=b({...aT,kind:m(`sequence`),steps:S(rT).min(1).max(16)}),cT=b({...aT,kind:m(`ir`),transmitterId:r().int().nonnegative().optional(),payload:Kw}),lT=a(`kind`,[oT,sT,cT]),uT=3e3;function dT(e){switch(e.kind){case`sequence`:return e.steps;case`digits`:return Array.from(e.number,e=>`digit_${e}`);case`ir`:return[]}}function fT(e){try{return qw(e.payload),null}catch(e){if(e instanceof L)return e.message;throw e}}function r_e(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function pT(e,t){let n=t.trim();for(let t of e)if(t.kind===`digits`&&t.number===n)return t;return null}function i_e(e,t){let n=e.find(e=>r_e(e.name,t));if(n!==void 0)return n;let r=e.find(e=>e.id===t.trim());return r===void 0?pT(e,t):r}var mT=x([`off`,`on`,`idle`,`playing`,`paused`,`buffering`,`standby`]),hT=x([`off`,`all`,`one`]),a_e=b({type:u(),title:u(),artist:u().optional(),album:u().optional(),imageUrl:u().optional()}),gT=x([`reported`,`assumed`]),_T=x([`state`,`volumeLevel`,`isMuted`,`source`]),vT=b({state:mT,stateSource:gT.default(`reported`),assumedFields:S(_T).default([]),volumeLevel:r().min(0).max(100).nullable().meta(k(`percentage`)),isMuted:v().nullable(),muteReadback:v().optional(),source:u(),availableSources:S(u()),declaredSources:S(b({name:u(),kind:x(iT),number:u().optional()})).optional(),currentMedia:a_e.nullable(),position:r().int().nonnegative().nullable().meta(k(`duration-ms`)),duration:r().int().nonnegative().nullable().meta(k(`duration-ms`)),shuffle:v().nullable(),repeat:hT.nullable(),positionUpdatedAt:r().nullable().default(null),lastChangedAt:r()}),yT=b({deviceId:r().int().nonnegative(),steps:r().int().min(1).max(50).default(1)}),bT=b({deviceId:r().int().nonnegative()}),xT={name:`media-player`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.MediaPlayer],power:{kind:`methods`,field:`state`,offValues:[`off`,`standby`],on:`turnOn`,off:`turnOff`},methods:{turnOn:D(bT,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOn`,label:I(`Turn on`,`Accendi`),phrase:I(`Turn on {device}`,`Accendi {device}`),icon:`power`}]}),turnOff:D(bT,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOff`,label:I(`Turn off`,`Spegni`),phrase:I(`Turn off {device}`,`Spegni {device}`),icon:`power`}]}),volumeUp:D(yT,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeUp`,label:I(`Volume up`,`Alza il volume`),phrase:I(`Raise the volume of {device}`,`Alza il volume di {device}`),icon:`volume-2`}]}),volumeDown:D(yT,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeDown`,label:I(`Volume down`,`Abbassa il volume`),phrase:I(`Lower the volume of {device}`,`Abbassa il volume di {device}`),icon:`volume-2`}]}),channelUp:D(yT,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelUp`,label:I(`Channel up`,`Canale successivo`),phrase:I(`Go to the next channel on {device}`,`Passa al canale successivo su {device}`),icon:`skip-forward`}]}),channelDown:D(yT,_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelDown`,label:I(`Channel down`,`Canale precedente`),phrase:I(`Go to the previous channel on {device}`,`Torna al canale precedente su {device}`),icon:`skip-back`}]}),play:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.play`,effect:{field:`state`,value:`playing`},label:I(`Play`,`Riproduci`),phrase:I(`Play on {device}`,`Avvia la riproduzione su {device}`),icon:`play`}]}),pause:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.pause`,effect:{field:`state`,value:`paused`},label:I(`Pause media`,`Metti in pausa`),phrase:I(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),stop:D(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.stop`,label:I(`Stop media`,`Ferma la riproduzione`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),next:D(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.next`,label:I(`Next track`,`Brano successivo`),phrase:I(`Skip to the next track on {device}`,`Passa al brano successivo su {device}`),icon:`skip-forward`}]}),previous:D(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.previous`,label:I(`Previous track`,`Brano precedente`),phrase:I(`Go back to the previous track on {device}`,`Torna al brano precedente su {device}`),icon:`skip-back`}]}),setVolume:D(b({deviceId:r().int().nonnegative(),volumeLevel:r().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volume`,effect:{field:`volumeLevel`,fromArg:`volumeLevel`},label:I(`Set volume`,`Imposta il volume`),phrase:I(`Set the volume of {device} to {volumeLevel}`,`Imposta il volume di {device} al {volumeLevel}`),icon:`volume-2`,openArgs:[{key:`volumeLevel`,label:I(`Volume`,`Volume`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMute:D(b({deviceId:r().int().nonnegative(),muted:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.mute`,effect:{field:`isMuted`,value:!0},label:I(`Mute`,`Silenzia`),phrase:I(`Mute {device}`,`Silenzia {device}`),icon:`volume-x`,args:{muted:!0}},{id:`media.unmute`,effect:{field:`isMuted`,value:!1},label:I(`Unmute`,`Riattiva l’audio`),phrase:I(`Unmute {device}`,`Riattiva l’audio di {device}`),icon:`volume-2`,args:{muted:!1}}]}),setShuffle:D(b({deviceId:r().int().nonnegative(),shuffle:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.shuffleOn`,effect:{field:`shuffle`,value:!0},label:I(`Shuffle on`,`Riproduzione casuale attiva`),phrase:I(`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:I(`Shuffle off`,`Riproduzione casuale spenta`),phrase:I(`Turn off shuffle on {device}`,`Disattiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!1}}]}),setRepeat:D(b({deviceId:r().int().nonnegative(),repeat:hT}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.repeat`,effect:{field:`repeat`,fromArg:`repeat`},label:I(`Set repeat`,`Imposta la ripetizione`),phrase:I(`Set repeat on {device} to {repeat}`,`Imposta la ripetizione di {device} su {repeat}`),icon:`repeat`,openArgs:[{key:`repeat`,label:I(`Repeat`,`Ripetizione`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Disattivata`)},{value:`all`,label:I(`All`,`Tutti i brani`)},{value:`one`,label:I(`One track`,`Un brano`)}]}}]}]}),selectSource:D(b({deviceId:r().int().nonnegative(),source:u().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.source`,effect:{field:`source`,fromArg:`source`},label:I(`Select source`,`Scegli la sorgente`),phrase:I(`Switch {device} to {source}`,`Passa {device} alla sorgente {source}`),icon:`cast`,openArgs:[{key:`source`,label:I(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`}}]}]}),seek:D(b({deviceId:r().int().nonnegative(),position:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.seek`,label:I(`Seek`,`Vai al punto`),phrase:I(`Move {device} to {position}`,`Porta {device} al punto {position}`),icon:`fast-forward`,openArgs:[{key:`position`,label:I(`Position`,`Posizione`),offer:{kind:`number`,min:0,step:1e3,unit:`ms`}}]}]}),playMedia:D(b({deviceId:r().int().nonnegative(),mediaId:u().min(1),mediaType:u().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.playMedia`,label:I(`Play media`,`Riproduci un contenuto`),phrase:I(`Play {mediaId} on {device}`,`Riproduci {mediaId} su {device}`),icon:`music`,openArgs:[{key:`mediaId`,label:I(`Media`,`Contenuto`),offer:{kind:`text`}},{key:`mediaType`,label:I(`Media type`,`Tipo di contenuto`),offer:{kind:`text`}}]}]})},status:{schema:vT,kind:`push`},runtimeState:vT,durability:`session`,history:{fields:{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}}},vocabulary:{noun:I(`Media player`,`Lettore multimediale`),order:2060,state:[{kind:`enum`,field:`state`,label:I(`Playback`,`Riproduzione`),values:[{value:`off`,label:I(`Off`,`Spento`),phrase:I(`When {device} turns off`,`Quando {device} si spegne`)},{value:`on`,label:I(`On`,`Acceso`),phrase:I(`When {device} turns on`,`Quando {device} si accende`)},{value:`idle`,label:I(`Idle`,`Inattivo`)},{value:`playing`,label:I(`Playing`,`In riproduzione`),phrase:I(`When {device} starts playing`,`Quando {device} inizia a riprodurre`)},{value:`paused`,label:I(`Paused`,`In pausa`),phrase:I(`When {device} is paused`,`Quando {device} va in pausa`)},{value:`buffering`,label:I(`Buffering`,`In caricamento`)},{value:`standby`,label:I(`Standby`,`In standby`)}],icon:`music`},{kind:`numeric`,field:`volumeLevel`,quantity:I(`the volume`,`il volume`),label:I(`Volume`,`Volume`),unit:`%`,icon:`volume-2`},{kind:`boolean`,field:`isMuted`,label:I(`Muted`,`Silenziato`),whenTrue:I(`When {device} is muted`,`Quando {device} viene silenziato`),whenFalse:I(`When {device} is unmuted`,`Quando l’audio di {device} torna attivo`),icon:`volume-x`},{kind:`value`,field:`source`,label:I(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`},icon:`cast`}]}},ST={battery:{version:1,targets:[{id:`level`,cardinality:`scalar`,deviceTypes:[j.Camera,j.Sensor,j.Button,j.Switch,j.PetFeeder,j.Container,j.Climate,j.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:[j.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:[j.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:[j.Camera,j.Light,j.Siren,j.Switch,j.Sensor,j.Climate,j.Button,j.EventEmitter,j.Update,j.Generic,j.Notifier,j.Script,j.Automation,j.Lock,j.Cover,j.Valve,j.Humidifier,j.WaterHeater,j.Fan,j.MediaPlayer,j.AlarmPanel,j.Control,j.Presence,j.Weather,j.WeatherStation,j.Vacuum,j.LawnMower,j.Container,j.Image,j.PetFeeder,j.PetFountain,j.Dishwasher,j.Washer,j.Dryer,j.Gateway,j.HeatPump,j.EnergySystem,j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`,vocabularyCap:`fan-presets`,sources:[],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},"lock-control":{version:1,targets:[{id:`door-contact`,cardinality:`scalar`,deviceTypes:[j.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:[j.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:[j.Switch,j.Light,j.Fan,j.Climate,j.Humidifier,j.WaterHeater,j.MediaPlayer,j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.PetFeeder,j.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:[j.Switch,j.Light,j.Fan,j.Climate,j.Humidifier,j.WaterHeater,j.MediaPlayer,j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.PetFeeder,j.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:[j.Switch,j.Light,j.Fan,j.Climate,j.Humidifier,j.WaterHeater,j.MediaPlayer,j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.PetFeeder,j.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:[j.Switch,j.Light,j.Fan,j.Climate,j.Humidifier,j.WaterHeater,j.MediaPlayer,j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.PetFeeder,j.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:[j.Gateway,j.Camera,j.Sensor,j.MediaPlayer,j.Vacuum,j.Generic,j.Washer,j.Dryer,j.Dishwasher,j.PetFountain,j.Fan,j.Humidifier,j.Climate,j.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:[j.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:[j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.MediaPlayer,j.WaterHeater,j.Humidifier,j.Fan,j.Climate,j.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:{[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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:[j.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`}]}},CT={"ambient-light-sensor":{illuminance:`lx`},battery:{level:`%`,voltage:`V`},"humidity-sensor":{humidity:`%`},"power-meter":{power:`W`,deliveredPower:`W`,energy:`kWh`,voltage:`V`,current:`A`},"temperature-sensor":{temperature:`°C`}};function R(e,t,n){return{code:e,path:t,message:n}}function wT(...e){return{problems:e,fields:[],features:[],events:[]}}function TT(e){let t=e.item===void 0?`fields`:`items.${e.item.key}.fields`;return`features[${e.featureIndex}].${t}.${e.path}`}var ET={kind:`fixed`,result:[`number`]},DT={kind:`fixed`,result:[`boolean`]},OT=Object.freeze({min:ET,max:ET,abs:ET,floor:ET,ceil:ET,sqrt:ET,round:ET,pow:ET,clamp:ET,avg:ET,sum:ET,age:ET,convert:ET,coalesce:{kind:`coalesce`},any:DT,all:DT,within:DT,latest:{kind:`fixed`,result:[`number`,`null`]},number:{kind:`fixed`,result:[`number`,`null`]},rose:{kind:`fixed`,result:[`number`,`null`]},count:ET,dwell:{kind:`fixed`,result:[`boolean`,`null`]},latchedAt:{kind:`fixed`,result:[`number`,`null`]},schmitt:{kind:`fixed`,result:[`boolean`,`null`]}}),kT=class extends Error{};function AT(e){return e===null?`null`:typeof e==`number`?`number`:typeof e==`string`?`string`:`boolean`}function jT(e){return new Set([e])}function MT(...e){return new Set(e.flatMap(e=>[...e]))}function o_e(e){return new Set([...e].filter(e=>e!==`null`))}function s_e(e,t,n){if(e===`+`){let e=[...t,...n];return e.every(e=>e===`string`)?jT(`string`):e.every(e=>e===`number`)?jT(`number`):new Set([`number`,`string`])}return jT(e===`-`||e===`*`||e===`/`||e===`%`?`number`:`boolean`)}function c_e(e){return e.minArgs===e.maxArgs?`exactly ${e.minArgs}`:e.maxArgs===1/0?`at least ${e.minArgs}`:`${e.minArgs}–${e.maxArgs}`}function l_e(e,t){let n=lm[e];if(n!==void 0&&(t.length<n.minArgs||t.length>n.maxArgs))throw new kT(`${e}: wrong number of arguments (${t.length}); expected ${c_e(n)}`);let r=OT[e];if(r===void 0)throw new kT(`no result-kind rule for builtin '${e}'`);if(r.kind===`fixed`)return new Set(r.result);let i=MT(...t.map(o_e));return t.every(e=>e.has(`null`))?MT(i,jT(`null`)):i}function NT(e,t){switch(e.kind){case`literal`:return jT(AT(e.value));case`identifier`:{if(e.name===`now`)return jT(`number`);let n=t.get(e.name);if(n===void 0)throw new kT(`unbound identifier '${e.name}'`);return n}case`unary`:return jT(e.op===`!`?`boolean`:`number`);case`binary`:return s_e(e.op,NT(e.left,t),NT(e.right,t));case`logical`:return MT(NT(e.left,t),NT(e.right,t));case`conditional`:return MT(NT(e.consequent,t),NT(e.alternate,t));case`call`:return l_e(e.callee,e.args.map(e=>NT(e,t)))}}function PT(e,t){switch(e.kind){case`literal`:case`identifier`:return!1;case`unary`:return PT(e.operand,t);case`binary`:case`logical`:return PT(e.left,t)||PT(e.right,t);case`conditional`:return PT(e.test,t)||PT(e.consequent,t)||PT(e.alternate,t);case`call`:return e.callee===t||e.args.some(e=>PT(e,t))}}function FT(e,t){let n=bm(e);return n.ok&&PT(n.parsed.ast,t)}function IT(e){let t=bm(e.expr);if(!t.ok)return{ok:!1,error:t.error};try{return{ok:!0,kinds:NT(t.parsed.ast,e.bindingKinds)}}catch(e){if(e instanceof kT)return{ok:!1,error:e.message};throw e}}function u_e(e){return e.publish===`value`&&e.empty===`null`?{ok:!0,kinds:new Set([`number`,`null`])}:{ok:!0,kinds:new Set([`number`])}}function d_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 LT(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=IC(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 RT(e,t,n){return R(`kind-mismatch`,n,`\`${e}.${t}\` is a union — it is read as a source, never written`)}function zT(e){return e.kind===`union`?null:e.kind===`enum`?`string`:e.kind}function BT(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=IC(a,e.fieldPath),s=zT(t);return o?.kind!==`union`||s===null||!n.has(s)?n:new Set(n.has(`null`)?[s,`null`]:[s])}function VT(e,t){if(e.kind===`from`)return LT(e,t);if(e.kind===`code`)return{ok:!1,code:`reserved-variant`,message:`code fields arrive in slice 4`};if(e.kind===`aggregate`)return d_e(e);if(e.kind===`series`)return u_e(e);let n=new Map;for(let[r,i]of Object.entries(e.bindings)){if(i.kind===`literal`){n.set(r,new Set([AT(i.value)]));continue}let e=LT(i,t);if(!e.ok)return{...e,message:`binding \`${r}\`: ${e.message}`};n.set(r,e.kinds)}let r=IT({expr:e.expr,bindingKinds:n});return r.ok?{ok:!0,kinds:r.kinds}:{ok:!1,code:`expression-invalid`,message:r.error}}function HT(e,t,n,r){let i=zT(t);if(i===null)return[RT(e,t.path,r)];let a=[...n].filter(e=>e!==`null`&&e!==i),o=[];return a.length>0&&o.push(R(`kind-mismatch`,r,`\`${e}.${t.path}\` is a ${t.kind}; this source can produce ${a.join(` or `)}`)),n.has(`null`)&&!t.nullable&&o.push(R(`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 f_e(e){if(e.kind!==`expression`)return null;let t=bm(e.expr);if(!t.ok)return null;let n=t.parsed.ast;return n.kind===`literal`&&typeof n.value==`string`?n.value:null}function UT(e,t,n,r){if(t.kind!==`enum`||t.enumValues===void 0)return null;let i=f_e(n);if(i===null||t.enumValues.includes(i))return null;let a=t.enumValues.map(e=>`\`${e}\``).join(`, `);return R(`kind-mismatch`,r,`\`${e}.${t.path}\` accepts only ${a}; this source is the literal \`${i}\``)}function WT(e){if(e.kind!==`expression`)return`derived`;if(FT(e.expr,`count`))return`accumulator`;if(jC(e).length>0)return`derived`;let t=bm(e.expr);return t.ok&&t.parsed.identifiers.has(`now`)?`clock`:`constant`}function GT(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:R(`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 KT={resettable:!1};function p_e(e){return new Set([e.keyField,...e.labelField===void 0?[]:[e.labelField],...Object.keys(KT)])}function m_e(e,t,n){let r=IC(e.itemSchema,t);return r===null||!r.required?!1:zC(e.itemSchema,t).every(e=>n.some(t=>t.startsWith(`${e}.`)))}function h_e({capName:e,itemArray:t,reserved:n},r,i){let a=Object.keys(r.fields);return ch(t.itemSchema).flatMap(o=>{if(n.has(o.path)||o.path in r.fields||!m_e(t,o.path,a))return[];let s=IC(t.itemSchema,o.path);return s===null||s.nullable?[]:[R(`missing-field`,`${i}.fields.${o.path}`,`\`${e}.${t.path}[].${o.path}\` is required and has no source`)]})}function g_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 wT(R(`item-field-reserved`,u,`\`${n}.${r.path}[].${c}\` is set by the composer itself — it takes no source`));let d=IC(r.itemSchema,c);if(d===null)return wT(R(`unknown-field`,u,`a \`${n}\` item has no field \`${c}\``));if(d.kind===`union`)return wT(RT(n,c,u));let f=VT(l,a);if(!f.ok)return wT(R(f.code,u,f.message));let p=WT(l),m=GT(d,p,e.mode,n,u);if(!m.ok)return wT(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:[...jC(l)]},g=UT(n,d,l,u);return{problems:[...HT(n,d,BT(l,d,f.kinds,a),u),...g===null?[]:[g]],fields:[h],features:[],events:[]}}function qT(e,t,n,r,i=`new`){let a=`features[${n}].items`,o=e.status?.itemArray;if(o===void 0)return wT(R(`not-item-array`,a,`\`${e.name}\` has no item array — it takes no \`items\``));if(o.path!==`items`)return wT(R(`not-item-array`,a,`\`${e.name}\`'s item array is at \`${o.path}\`, not \`${mC}\` — not composable yet`));let s={capName:e.name,itemArray:o,reserved:p_e(o),featureIndex:n,lookupCap:r,mode:i},c=Object.entries(t.items??{}).flatMap(([e,t])=>[{problems:h_e(s,t,`${a}.${e}`),fields:[],features:[],events:[]},...Object.entries(t.fields).map(([n,r])=>g_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 JT=`deviceId`;function YT(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 XT(e){let t=e.features.flatMap((e,t)=>e.kind===`fields`&&bC(e)?YT(e,t).map(e=>e.command.source):[]);return[...new Map(t.map(e=>[EC(e),e])).values()]}function __e(e,t){return e.name===`switch`&&t===`toggle`}function ZT(e){return Object.entries(e.methods).filter(([t,n])=>n.systemOnly!==!0&&e.composedMethods?.[t]===void 0&&!__e(e,t)).map(([e])=>e)}function QT(){return Object.fromEntries(ZT(xT).map(e=>[e,{kind:`extension`,target:`remote`}]))}var $T={all:new Set,required:new Set};function eE(e,t){let n=e.methods[t]?.input;if(n===void 0)return null;let r=ah(n);if(!(r instanceof ue))return null;let i=Object.entries(r.shape).filter(([e])=>e!==JT);return{all:new Set(i.map(([e])=>e)),required:new Set(i.flatMap(([e,t])=>t instanceof oe&&!t.safeParse(void 0).success?[e]:[]))}}function tE(e){return typeof e==`object`?lC(e)?[e.$input]:Object.values(e).flatMap(tE):[]}function nE(e){return[...e].map(e=>`\`${e}\``).join(`, `)}function v_e(e,t){let{command:n,at:r}=e,i=t(n.cap);if(i===null)return{def:null,problems:[R(`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:[R(`command-source-unknown`,`${r}.method`,`\`${n.cap}\` has no method \`${n.method}\` to forward to`)]}:a.kind===`mutation`?{def:i,problems:[]}:{def:null,problems:[R(`command-source-unknown`,`${r}.method`,`\`${n.cap}.${n.method}\` is a query — a command calls a mutation of the source`)]}}function y_e(e,t,n,r){let{at:i,command:a}=e,o=`${a.cap}.${a.method}`,s=[];if(`deviceId`in r&&s.push(R(`command-input-unknown`,`${i}.args.${JT}`,`\`${JT}\` 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(R(`command-input-unknown`,`${i}.args.${e}`,`\`${o}\` has no input field \`${e}\` (it takes ${nE(n.all)})`));let e=[...n.required].filter(e=>!(e in r));e.length>0&&s.push(R(`command-input-missing`,`${i}.args`,`\`${o}\` needs ${nE(e)}, which \`args\` does not provide`))}let c=e.itemKey===void 0?t:$T;if(c!==null)for(let t of Object.values(r).flatMap(tE))c.all.has(t)||s.push(R(`command-input-unknown`,`${i}.args`,c===$T?`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 ${nE(c.all)})`));return s}function b_e(e,t,n){let{at:r,command:i}=e,a=`${i.cap}.${i.method}`,o=e.itemKey===void 0?t:$T;if(o===null||n===null)return[];let s=[];for(let t of[...o.all].filter(e=>!n.all.has(e)))s.push(R(`command-input-unknown`,`${r}.args`,`\`${e.method}\` takes \`${t}\`, which \`${a}\` does not (it takes ${nE(n.all)}) — add \`args\` to map it`));let c=[...n.required].filter(e=>!o.all.has(e));return c.length>0&&s.push(R(`command-input-missing`,`${r}.args`,`\`${a}\` needs ${nE(c)}, which \`${e.method}\` does not take — add \`args\` to provide it`)),s}function rE(e,t,n){let r=v_e(t,n);if(r.def===null)return r.problems;let i=eE(e,t.method),a=eE(r.def,t.command.method),o=t.command.args;return o===void 0?b_e(t,i,a):y_e(t,i,a,o)}function iE(e,t,n){let r=new Set(ZT(e));return Object.keys(t.commands??{}).flatMap(t=>{if(r.has(t))return[];let i=e.composedMethods?.[t]!==void 0;return[R(`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 aE(e,t){return e.features.flatMap((e,n)=>e.kind!==`fields`||!bC(e)?[]:YT(e,n).flatMap(e=>{let n=EC(e.command.source),r=t.get(n),i=`${e.at}.source`;return r===void 0||r.kind===`unreadable`?[R(`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`?[R(`source-missing`,i,`source \`${n}\` does not exist`)]:r.caps.has(e.command.cap)?[]:[R(`source-capability-missing`,i,`source \`${n}\` (device ${r.deviceId}) has no \`${e.command.cap}\``)]}))}var oE={fieldPath:`lastFetchedAt`,expr:`now`},sE={fieldPath:`lastChangedAt`,expr:`now`};function cE(e){let{alsoFrom:t,...n}=e;return{...n,family:`numeric`,deviceType:j.Sensor,memberDeviceType:j.Sensor,memberDeviceTypes:[j.Sensor,...t?.deviceTypes??[]],activeWhen:void 0,commandCaps:[],baseUnit:ec(e.quantity),aggregates:yS,accept:[{cap:e.outputCap,fieldPath:e.outputField},...t===void 0?[]:[t.accept]]}}var lE=[j.Climate];function uE(e){return{...e,family:`binary`,deviceType:j.Sensor,memberDeviceType:j.Sensor,memberDeviceTypes:[j.Sensor],activeWhen:void 0,commandCaps:[],quantity:`none`,baseUnit:void 0,aggregates:bS,empty:`offline`}}var dE=[cE({id:`temperature`,summary:`Mean, median, min, max or sum of temperatures. Offline and unknown members are left out, never read as 0 °C.`,role:N.TemperatureSensor,outputCap:`temperature-sensor`,outputField:`temperature`,quantity:`temperature`,defaultAggregate:`mean`,empty:`null`,companions:[oE],alsoFrom:{deviceTypes:lE,accept:{cap:`climate-control`,fieldPath:`currentTemp`}}}),cE({id:`humidity`,summary:`Humidity in percent. Offline and unknown members are left out, never read as 0 %.`,role:N.HumiditySensor,outputCap:`humidity-sensor`,outputField:`humidity`,quantity:`humidity`,defaultAggregate:`mean`,empty:`null`,companions:[oE],alsoFrom:{deviceTypes:lE,accept:{cap:`climate-control`,fieldPath:`currentHumidity`}}}),cE({id:`pressure`,summary:`Pressure in hectopascals. Offline and unknown members are left out, never read as 0 hPa.`,role:N.PressureSensor,outputCap:`pressure-sensor`,outputField:`pressure`,quantity:`pressure`,defaultAggregate:`mean`,empty:`null`,companions:[oE]}),cE({id:`illuminance`,summary:`Illuminance in lux. Offline and unknown members are left out, never read as 0 lx.`,role:N.AmbientLightSensor,outputCap:`ambient-light-sensor`,outputField:`illuminance`,quantity:`illuminance`,defaultAggregate:`mean`,empty:`null`,companions:[oE]}),cE({id:`power`,summary:`Power in watts, summed by default. Nobody reporting omits the key rather than writing 0 W.`,role:N.PowerSensor,outputCap:`power-meter`,outputField:`power`,quantity:`power`,defaultAggregate:`sum`,empty:`omit`,companions:[oE]}),cE({id:`energy`,summary:`Energy in kilowatt-hours, summed by default. Nobody reporting omits the key rather than writing 0 kWh.`,role:N.EnergySensor,outputCap:`power-meter`,outputField:`energy`,quantity:`energy`,defaultAggregate:`sum`,empty:`omit`,companions:[oE]}),cE({id:`battery`,summary:`Battery charge in percent. Offline and unknown members are left out, never read as 0 %.`,role:N.BatterySensor,outputCap:`battery`,outputField:`level`,quantity:`percentage`,defaultAggregate:`mean`,empty:`null`,companions:[{fieldPath:`charging`,expr:`"unknown"`},{fieldPath:`sleeping`,expr:`false`},{fieldPath:`lastUpdated`,expr:`now`}]}),cE({id:`numeric`,summary:`A numeric reading in the members’ shared quantity. Mixed quantities are refused. Nobody reporting publishes null, not 0.`,role:N.NumericSensor,outputCap:`numeric-sensor`,outputField:`value`,quantity:`device`,defaultAggregate:`mean`,empty:`null`,companions:[oE]}),uE({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:N.MotionSensor,outputCap:`motion`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`}],companions:[{fieldPath:`lastDetectedAt`,expr:`null`},{fieldPath:`autoClearAfterMs`,expr:`null`}]}),uE({id:`contact`,summary:`Any or all open contacts. Offline and unknown members are left out, never read as closed.`,role:N.ContactSensor,outputCap:`contact`,outputField:`entryOpen`,defaultAggregate:`any`,accept:[{cap:`contact`,fieldPath:`entryOpen`}],companions:[sE]}),uE({id:`leak`,summary:`Any or all leak detections. Offline and unknown members are left out, never read as dry.`,role:N.LeakSensor,outputCap:`flood`,outputField:`flooded`,defaultAggregate:`any`,accept:[{cap:`flood`,fieldPath:`flooded`}],companions:[sE]}),uE({id:`smoke`,summary:`Any or all smoke detections. Offline and unknown members are left out, never read as clear.`,role:N.SmokeSensor,outputCap:`smoke`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`smoke`,fieldPath:`detected`}],companions:[sE]}),uE({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:N.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`},{cap:`binary`,fieldPath:`on`}],companions:[sE]}),uE({id:`binary`,summary:`Any or all generic binary sensors. Offline and unknown members are left out, never read as off.`,role:N.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`binary`,fieldPath:`on`}],companions:[sE]}),fE({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:j.Switch,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`]}),fE({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:j.Light,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`brightness`,`color`]}),fE({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:j.Fan,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`fan-control`]}),fE({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:j.Cover,outputCap:`group-active`,outputField:`active`,member:{cap:`cover`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`cover`]}),fE({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:j.Valve,outputCap:`group-active`,outputField:`active`,member:{cap:`valve`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`valve`]}),fE({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:j.Lock,outputCap:`group-active`,outputField:`active`,member:{cap:`lock-control`,fieldPath:`state`},activeWhen:[`locked`],commandCaps:[`lock-control`]}),fE({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:j.MediaPlayer,outputCap:`group-active`,outputField:`active`,member:{cap:`media-player`,fieldPath:`state`},activeWhen:[`playing`,`buffering`],commandCaps:[`media-player`]}),fE({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:j.Climate,memberDeviceTypes:[j.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 fE(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:bS,defaultAggregate:`any`,empty:`offline`,accept:[e.member],companions:[sE]}}var x_e=new Map(dE.map(e=>[e.id,e]));function pE(e){return x_e.get(e)??null}var mE={"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`}},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.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:[j.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`}}},S_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`}}}},hE={"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}},C_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 gE(e){return mE[e]??{}}function _E(e,t,n){return vE(e.deviceTypes,t,n)}function vE(e,t,n){return e.length===0||e.some(e=>e===t)?!0:_f(t,n)&&e.includes(j.Light)}function yE(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 bE(e){return{fieldChoice:`operator`,purpose:`historised`,multiple:!1,max:1,deviceTypes:[],accept:xE(e),history:{required:!0,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function xE(e){let t=[];for(let n of Object.keys(mE))for(let[r,i]of Object.entries(gE(n)))i.kind!==`enum`&&(e===`integral`&&i.kind!==`gauge`||t.push({cap:n,fieldPath:r,valueKind:i.kind===`boolean`?`boolean`:`number`}));return t}function SE(e){if(e===`derivative`)return{...bE(`statistic`),accept:CE()};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:CE(),history:{required:!1,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function CE(){return xE(`statistic`).filter(e=>e.valueKind===`number`)}var wE=[`switch`,`brightness`,`color`],w_e=[M.LightColorRgb,M.LightColorHsv,M.LightColorMired];function TE(e){return e===`all`?`all`:`any`}function T_e(e){return e===`all`?`all`:`at-least-one`}function E_e(e){return e.length===0?[]:wE.filter(t=>e.every(e=>e.includes(t)))}function EE(e){return e.length===0?[]:w_e.filter(t=>e.every(e=>e.includes(t)))}function D_e(e,t,n,r){return e.flatMap(e=>e.caps.includes(t)?[{deviceId:e.deviceId,cap:t,method:n,args:{...r}}]:[])}async function O_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 DE(e,t,n){return{kind:`series`,read:{source:e.source,cap:e.cap,fieldPath:e.fieldPath},publish:t,empty:n}}function A_e(e){return{included:DE(e,`included`,`offline`),excluded:DE(e,`excluded`,`offline`),total:DE(e,`total`,`offline`)}}var j_e={second:`s`,minute:`min`,hour:`h`};function OE(e){let t=gE(e.source.cap)[e.source.fieldPath]?.unit;return t===void 0?null:`${t}/${j_e[e.per]}`}function kE(e){let t=gE(e.cap)[e.fieldPath];return t===void 0?null:t.kind}function AE(e){return kE(e)===null?[R(`member-constraint`,`helper.source`,`${e.cap}.${e.fieldPath} has no history declaration`)]:[]}function jE(e){return{target:{kind:`new`,type:j.Sensor,role:e.role},helper:e.spec,features:[{kind:`fields`,cap:e.cap,fields:{[e.field]:DE(e.member,`value`,e.empty),lastFetchedAt:k_e}},{kind:`fields`,cap:`group-status`,fields:A_e(e.member)}]}}function ME(e,t=$x){let n=[...AE(e.source)],r=kE(e.source);r===`enum`&&n.push(R(`kind-mismatch`,`helper.source`,`a statistic reads a number or a boolean, not a state`)),e.stat===`sum`&&r!==`counter`&&n.push(R(`kind-mismatch`,`helper.stat`,`a gauge has no sum — that is the integral template`));let i=hS(e.window,t);return i.ok||n.push(R(`retention`,`helper.window`,i.reason)),{problems:n,draft:jE({role:N.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function NE(e,t=$x){let n=[...AE(e.source)],r=kE(e.source);(r===`enum`||r===`boolean`)&&n.push(R(`kind-mismatch`,`helper.source`,`a derivative reads a number that moves, not a yes/no or a state`));let i=hS(e.window,t);return i.ok||n.push(R(`retention`,`helper.window`,i.reason)),{problems:n,draft:jE({role:N.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function PE(e,t=$x){let n=[...AE(e.source)],r=kE(e.source),i=e.source.cap===`power-meter`&&e.source.fieldPath===`power`;(r===`counter`||r===`boolean`||r===`enum`)&&n.push(R(`kind-mismatch`,`helper.source`,`an integral reads an instantaneous gauge, not a counter or a state`)),e.output===`energy`&&!i&&n.push(R(`kind-mismatch`,`helper.output`,`energy is the integral of power-meter.power; another reading uses the meter`)),e.output===`meter`&&i&&n.push(R(`kind-mismatch`,`helper.output`,`power integrates to power-meter.energy, which energy dashboards already read`));let a=gS(e.reset,t);a.ok||n.push(R(`retention`,`helper.reset`,a.reason));let o=e.output===`energy`;return{problems:n,draft:jE({role:o?N.EnergySensor:N.NumericSensor,cap:o?`power-meter`:`meter`,field:o?`energy`:`value`,empty:`offline`,spec:e,member:e.source})}}var M_e=/^\d+(?:\.\d+)?$/,N_e=/^-?\d+(?:\.\d+)?$/,P_e=/^dwell\(x (>=|<=) (\d+(?:\.\d+)?), (\d+(?:\.\d+)?), (\d+(?:\.\d+)?)(?:, (\d+))?\)$/,F_e=/^clamp\((x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?)\)$/,I_e=/^(x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?)$/,L_e=/^[A-Za-z_][A-Za-z0-9_]*$/;function FE(e){return GE(e,M_e)}function IE(e){return GE(e,N_e)}function LE(e){return typeof e==`string`?JSON.stringify(e):typeof e==`number`?IE(e):typeof e==`boolean`?e?`true`:`false`:`null`}function RE(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 zE(e){return L_e.test(e)}function BE(e,t,n,r,i=1){return`dwell(x ${e===`gte`?`>=`:`<=`} ${t}, ${n}, ${r}${i>1?`, ${i}`:``})`}function VE(e,t,n,r,i){let a=`${e} * ${t} + ${n}`;return r===null||i===null?a:`clamp(${a}, ${r}, ${i})`}function HE(e){let t=P_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 UE(e){let t=F_e.exec(e);if(t!==null)return KE(t[1],t[2],t[3],t[4],t[5]);let n=I_e.exec(e);return n===null?null:KE(n[1],n[2],n[3],void 0,void 0)}function WE(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 GE(e,t){if(!Number.isFinite(e))return null;let n=Object.is(e,-0)?`0`:String(e);return t.test(n)?n:null}function KE(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 qE={kind:`expression`,expr:`now`,bindings:{}};function JE(e){return{kind:`from`,source:e.source,cap:e.cap,fieldPath:e.fieldPath}}function YE(e,t){return{kind:`expression`,expr:e,bindings:t}}function R_e(e,t){return e.source.addonId===t.source.addonId&&e.source.stableId===t.source.stableId&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function XE(e,t,n=[]){return{target:{kind:`new`,type:j.Sensor,role:N.NumericSensor},helper:e,features:[{kind:`fields`,cap:`numeric-sensor`,fields:{value:t,lastFetchedAt:qE}},...n]}}function ZE(e,t){return{target:{kind:`new`,type:j.Sensor,role:N.BinarySensor},helper:e,features:[{kind:`fields`,cap:`binary`,fields:{on:t,lastChangedAt:qE}}]}}function QE(e){let t=[],n=IE(e.high),r=IE(e.low);n===null&&t.push(R(`kind-mismatch`,`helper.high`,`the high edge is a finite number`)),r===null&&t.push(R(`kind-mismatch`,`helper.low`,`the low edge is a finite number`)),n!==null&&r!==null&&e.low>e.high&&t.push(R(`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=FE(e.onForMs),a=FE(e.offForMs);(i===null||a===null)&&t.push(R(`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:ZE(e,YE(`coalesce(schmitt(x, ${n??`0`}, ${r??`0`}${o}), false)`,{x:JE(e.source)}))}}var z_e=[`a`,`b`];function B_e(e){let t=[],n=e.op!==`sum`;return n&&e.inputs.length!==2&&t.push(R(`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(R(`member-constraint`,`helper.inputs`,`a sum takes two or more readings`)),e.inputs.forEach((n,r)=>{e.inputs.slice(0,r).some(e=>R_e(e,n))&&t.push(R(`member-constraint`,`helper.inputs[${r}]`,`this reading is already an input`))}),t}var V_e=[`included`,`excluded`,`total`];function $E(e){let t=B_e(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(V_e.map(e=>[e,r(e)]));return{problems:t,draft:XE(e,r(`value`),[{kind:`fields`,cap:`group-status`,fields:i}])}}let n=Object.fromEntries(e.inputs.slice(0,2).map((e,t)=>[z_e[t]??`a`,JE(e)]));return{problems:t,draft:XE(e,YE(e.op===`difference`?`a - b`:`b == 0 ? null : a / b`,n))}}function H_e(e){let t=[],n=new Set;if(e.inputs.forEach((e,r)=>{let i=`helper.inputs[${r}].name`;zE(e.name)||t.push(R(`expression-invalid`,i,`\`${e.name}\` is not a name — use letters, digits and _, starting with a letter`)),n.has(e.name)&&t.push(R(`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,JE(e.member)])),i=Am({expr:e.expr,bindings:r});return i===null?[]:[R(`expression-invalid`,`helper.expr`,i)]}function eD(e){let t=H_e(e),n=Object.fromEntries(e.inputs.map(e=>[e.name,JE(e.member)])),r=YE(e.expr,n);return{problems:t,draft:e.output===`boolean`?ZE(e,r):XE(e,r)}}function U_e(e,t){return e.addonId===t.addonId&&e.stableId===t.stableId}function W_e(e,t){return U_e(e.source,t.source)&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function G_e(e,t){return e.accept.some(e=>e.cap===t.cap&&e.fieldPath===t.fieldPath)}function K_e(e,t){return t.members.flatMap((n,r)=>{let i=`helper.members[${r}]`,a=[];if(!G_e(e,n)){let t=e.accept.map(e=>`${e.cap}.${e.fieldPath}`).join(` or `);a.push(R(`member-constraint`,i,`a ${e.id} group reads ${t}; this member is ${n.cap}.${n.fieldPath}`))}return t.members.slice(0,r).some(e=>W_e(e,n))&&a.push(R(`member-constraint`,i,`this member is already in the group`)),a})}function tD(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 q_e(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,Y_e(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]:tD(e,t,n,`value`),...r}},{kind:`fields`,cap:`group-status`,fields:{included:tD(e,t,n,`included`),excluded:tD(e,t,n,`excluded`),total:tD(e,t,n,`total`)}}]}}function J_e(e,t){if(e.family===`actuator`){if(t.active===void 0)return[R(`kind-mismatch`,`helper.active`,`a ${e.id} group needs an active criterion (at-least-one or all)`)];let n=TE(t.active);return t.aggregate===n?[]:[R(`kind-mismatch`,`helper.aggregate`,`active \`${t.active}\` aggregates by \`${n}\`, not \`${t.aggregate}\``)]}return t.active===void 0?[]:[R(`kind-mismatch`,`helper.active`,`a ${e.id} group has no active criterion — that belongs to an actuator group`)]}function nD(e){let t=TC.safeParse(e);return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:[R(`helper-mismatch`,`helper`,`the template did not compile: ${t.error.issues.map(e=>e.message).join(`; `)}`)]}}function Y_e(e,t={}){return{kind:`expression`,expr:e,bindings:t}}function rD(e,t=$x){switch(e.kind){case`group`:return Z_e(e);case`statistic`:{let n=ME(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:nD(n.draft)}case`integral`:{let n=PE(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:nD(n.draft)}case`derivative`:{let n=NE(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:nD(n.draft)}case`threshold`:return iD(QE(e));case`arithmetic`:return iD($E(e));case`expression`:return iD(eD(e));case`grid`:case`terminal`:return nD(X_e(e))}}function X_e(e){return{target:{kind:`new`,type:j.Camera},helper:e,features:[]}}function iD(e){return e.problems.length>0?{ok:!1,problems:e.problems}:nD(e.draft)}function Z_e(e){let t=pE(e.templateId);if(t===null)return{ok:!1,problems:[R(`member-constraint`,`helper.templateId`,`unknown template \`${e.templateId}\``)]};let n=J_e(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:[R(`kind-mismatch`,`helper.aggregate`,`a ${t.id} group aggregates by ${n}, not \`${e.aggregate}\``)]}}let r=K_e(t,e);return r.length>0?{ok:!1,problems:r}:nD(q_e(t,e))}function aD(e,t){return JSON.stringify(e.target)===JSON.stringify(t.target)&&JSON.stringify(e.features)===JSON.stringify(t.features)}function Q_e(e){return e.kind===`group`?pE(e.templateId)?.memberDeviceType??null:null}function $_e(e,t){if(e.kind!==`group`)return[];let n=pE(e.templateId);if(n===null||n.family!==`numeric`)return[];let r=e.members.flatMap((e,n)=>{let r=t.get(EC(e.source))?.quantity;return r===void 0?[]:[{index:n,quantity:r}]});if(n.quantity!==`device`)return r.flatMap(e=>e.quantity===n.quantity?[]:[R(`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?[]:[R(`mixed-quantity`,`helper.members`,`a numeric group requires one quantity; members report ${i.join(` and `)}`)]}function eve(e,t){if(e.kind!==`group`)return[];let n=pE(e.templateId);return n===null?[]:e.members.flatMap((e,r)=>{let i=t.get(EC(e.source)),a=i?.deviceType;return a===void 0||vE(n.memberDeviceTypes,a,i?.role)?[]:[R(`member-constraint`,`helper.members[${r}]`,`a ${n.id} group takes ${n.memberDeviceTypes.join(` or `)} devices; this member is a ${a}`)]})}function oD(e,t){let n=e.helper;if(n===void 0)return[];let r=rD(n);return r.ok?aD(e,r.composition)?n.kind===`arithmetic`?tve(n,t):n.kind===`group`?[...$_e(n,t),...eve(n,t)]:[]:[R(`helper-mismatch`,`helper`,`the stored features are not this template — the helper spec is the only writer`)]:r.problems}function tve(e,t){let n=e.inputs.flatMap(e=>{let n=t.get(EC(e.source))?.quantity;return n===void 0?[]:[n]}),r=[...new Set(n)];return r.length<=1?[]:[R(`mixed-quantity`,`helper.inputs`,`a ${e.op} needs readings of one quantity; these inputs report ${r.join(` and `)}`)]}var sD=class extends Error{};function nve(e){return new Set(e.composition.features.flatMap(e=>!bC(e)||e.kind!==`fields`?[]:NC(e).map(({fieldPath:t})=>`${e.cap}.${t}`)))}function rve(e,t,n){if(EC(n.source)!==EC(e.target))return!0;let r=`${n.cap}.${n.fieldPath}`;return t.has(r)&&e.replaced?.has(r)!==!0}function ive(e){let t=nve(e);return e.composition.features.flatMap(n=>!bC(n)||n.kind!==`fields`?[]:NC(n).map(({fieldPath:r,source:i})=>[OC({source:e.target,cap:n.cap,fieldPath:r}),jC(i).filter(n=>rve(e,t,n)).map(OC)]))}function ave(e,t){let n=EC(e.target),r=new Map;for(let i of t){if(i.blockId===e.blockId)continue;let t=EC(i.target);if(t===n)throw new sD(`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 sD(`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 cD(e,t){let n=ave(e,t).flatMap(ive);return new Map(n)}function ove(e,t){let n=cD(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 sve(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 cve(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 lD(e,t){let n=cD(e,t),r=`${EC(e.target)}#`;return sve(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:cve(t,i,n),component:i}]})}var uD=x([`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`]),dD=a(`accepted`,[b({accepted:m(!0)}),b({accepted:m(!1),reason:uD,message:u()})]),fD=b({linked:v(),switchDeviceId:r().nullable(),switchName:u().nullable(),switchOn:v().nullable(),switchOnline:v().nullable(),switchSettable:v().nullable().optional(),restartInProgress:v(),offSeconds:r().int()}),pD=b({switchOn:v().nullable(),offSeconds:r().int(),lastFetchedAt:r()}),mD=[j.Gateway,j.Camera,j.Sensor,j.MediaPlayer,j.Vacuum,j.Generic,j.Washer,j.Dryer,j.Dishwasher,j.PetFountain,j.Fan,j.Humidifier,j.Climate,j.WaterHeater],lve={version:1,targets:[{id:`switch`,cardinality:`scalar`,vocabulary:{cap:`power-source`,stateField:`switchOn`},deviceTypes:mD,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`}}]},hD=b({deviceId:r().int().nonnegative()}),gD={method:`getStatus`,field:`switchSettable`},_D={name:`power-source`,scope:`device`,mode:`singleton`,deviceTypes:mD,methods:{getStatus:li(hD,fD,{auth:`protected`}),powerOn:li(hD,dD,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.on`,label:I(`Power on`,`Dai corrente`),phrase:I(`Power on {device}`,`Dai corrente a {device}`),icon:`power`,offeredWhen:gD}]}),powerOff:li(hD,dD,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.off`,label:I(`Power off`,`Togli corrente`),phrase:I(`Cut the power of {device}`,`Togli la corrente a {device}`),icon:`power-off`,offeredWhen:gD}]}),forceRestart:li(hD,dD,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.forceRestart`,label:I(`Force restart`,`Riavvio forzato`),phrase:I(`Force restart {device} by cutting its power`,`Riavvia {device} togliendo la corrente`),icon:`refresh-cw`}]})},runtimeState:pD,customize:lve,durability:`session`,history:`none`,vocabulary:{noun:I(`Power source`,`Alimentazione`),order:1050,state:[{kind:`boolean`,field:`switchOn`,label:I(`Power switch on`,`Presa accesa`),whenTrue:I(`When the power of {device} comes on`,`Quando arriva la corrente a {device}`),whenFalse:I(`When the power of {device} is cut`,`Quando manca la corrente a {device}`),icon:`power`}]}};function vD(e){return typeof e!=`number`||!Number.isFinite(e)?10:Math.min(120,Math.max(3,Math.round(e)))}function uve(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 dve(e,t){if(e===null)return null;let n;if(e.target.kind===`existing`)n=e.target.device;else if(t!==void 0)n=AC(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=jC(i).find(e=>e.cap===`switch`);return a===void 0?null:{device:n,switch:a.source,offSeconds:vD(uve(e)),...r.contributedBy===void 0?{}:{contributedBy:r.contributedBy}}}var yD=`switch`;function fve(e){let t=new Set;return e.target.kind===`existing`&&t.add(EC(e.target.device)),e.features.forEach((e,n)=>{if(!(e.kind!==`fields`||e.cap!==yD)&&bC(e)){for(let n of PC(e))for(let e of jC(n))t.add(EC(e.source));for(let r of YT(e,n))t.add(EC(r.command.source))}}),t}function bD(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=fve(e);return jC(r).filter(e=>e.cap===yD&&i.has(EC(e.source))).map(e=>({path:`features[${t}].fields.switchOn`,switch:e.source}))}function xD(e){let t=new Map(e.map(e=>[e.name,e]));return e=>t.get(e)??null}var SD=new Set([`device-status`,`feature-probe`]),pve={addonId:YS,stableId:`${JS}(unsaved)`},mve=`(unsaved)`;function hve(e,t,n){let r=n(e.cap);if(r===null)return R(`unknown-capability`,`${t}.cap`,`no capability is named \`${e.cap}\``);if(SD.has(r.name))return R(`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?R(`not-composable`,`${t}.cap`,`\`${r.name}\` has no per-device state to compose`):{def:r,state:i,fields:LC(i)}}function gve(e){let t=e.helper;if(t===void 0||t.kind!==`group`)return new Set;let n=pE(t.templateId);return n===null||n.family!==`actuator`?new Set:new Set(n.commandCaps)}function _ve(e,t){return e.name===xT.name&&Object.values(t.commands??{}).some(e=>e.kind===`extension`)}function vve({def:e,state:t,fields:n},r,i,a,o){let s=[];e.deviceTypes!==void 0&&!e.deviceTypes.includes(a)&&s.push(R(`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=ZT(e).filter(e=>!c.has(e)).map(e=>`\`${e}\``);l.length>0&&!o.has(e.name)&&s.push(R(`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=_ve(e,r);for(let a of d?[]:RC(t))a!==u&&(n.has(a)?a in r.fields||s.push(R(`missing-field`,`${i}.fields.${a}`,`\`${e.name}.${a}\` is required and has no source`)):s.push(R(`not-composable`,`${i}.fields`,`\`${e.name}.${a}\` is not a scalar — nested fields arrive in a later slice`)));return s}function yve({fields:e,state:t},n,r){return n.includes(`.`)?r===`replace`?IC(t,n)??void 0:`nested`:e.get(n)}function bve(e,t,n,r){let{def:i}=e,{featureIndex:a,path:o,source:s}=t,c=`features[${a}].fields.${o}`,l=yve(e,o,n);if(l===`nested`)return wT(R(`nested-field`,c,`\`${o}\` is nested — a nested field is planned only on a declared replace (D1034)`));if(l===void 0)return wT(R(`unknown-field`,c,`\`${i.name}\` has no field \`${o}\``));if(l.kind===`union`)return wT(RT(i.name,o,c));let u=VT(s,r);if(!u.ok)return wT(R(u.code,c,u.message));let d=WT(s),f=GT(l,d,n,i.name,c);if(!f.ok)return wT(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:[...jC(s)]},h=UT(i.name,l,s,c);return{problems:[...HT(i.name,l,BT(s,l,u.kinds,r),c),...h===null?[]:[h]],fields:[m],features:[],events:[]}}function xve(e,t,n,r,i){let a=`features[${n}]`,o=YT(t,n),s=Object.entries(t.commands??{}).filter(([,e])=>e.kind===`code`).map(([e])=>R(`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!==xT.name?[...s,...c.map(([t])=>R(`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,R(`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=>rE(e,t,i))]}function CD(e,t,n,r,i){let a=`features[${t}]`,o=hve(e,a,r);if(`code`in o)return wT(o);let s=n.mode===`replace`?[]:[...vve(o,e,a,n.deviceType,i)];s.push(...xve(o.def,e,t,n.mode,r));let c=Object.entries(e.fields).map(([e,i])=>bve(o,{featureIndex:t,path:e,source:i},n.mode,r)),l=e.items===void 0?[]:[qT(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=UC(o.def,f,d);return{problems:[...s,...u.flatMap(e=>e.problems),...p.problems],fields:d,features:[f],events:p.events}}function wD(e,t){let n=e.nativeCaps.get(t);return n!==void 0&&n!==`composer`}function Sve(e){return`code`in e}function Cve(e,t){if(e.target.kind===`new`)return{kind:`new`,type:e.target.type};let n=EC(e.target.device);return t===void 0?R(`target-unreadable`,`target`,`target device \`${n}\` was not read — the save is refused rather than stored unchecked`):t.kind===`absent`?R(`target-missing`,`target`,`target device \`${n}\` does not exist`):t.kind===`unreadable`?R(`target-unreadable`,`target`,`could not read target device \`${n}\` (${t.error}) — the save is refused rather than stored unchecked`):{kind:`existing`,found:t}}var wve=new Set([`not-composable`,`unknown-capability`,`reserved-variant`]);function Tve(e,t){let n=t.problems.filter(e=>wve.has(e.code));return n.length>0?{problems:n,fields:[],features:[],events:[]}:wT(e)}var Eve=ST;function Dve(e){let t=Eve[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 Ove(e,t,n){let r=t.cap;return e.kind===`new`?{mode:`new`,deviceType:e.type}:wD(e.found,r)?Dve(t)?{mode:`replace`,deviceType:e.found.type}:R(`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 TD(e,t,n){let r=Cve(e,n);if(`code`in r)return wT(r);let i=gve(e),a=e.features.map((e,n)=>{let a=`features[${n}]`;if(e.kind===`passthrough`)return wT(R(`reserved-variant`,a,`whole-capability passthrough of \`${e.cap}\` arrives in slice 3`));let o=Ove(r,e,a);if(Sve(o))return!bC(e)||r.kind!==`existing`?{problems:[],fields:[],features:[],events:[]}:Tve(o,CD(e,n,{mode:`add`,deviceType:r.found.type},t,i));let s=CD(e,n,o,t,i);return bC(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=>bC(e)&&e.kind===`fields`?PC(e).flatMap(jC).map(e=>e.source):[]);return[...new Map([...t,...XT(e)].map(e=>[EC(e),e])).values()]}function Ave(e,t){return e.features.flatMap(e=>bC(e)&&e.kind===`fields`?PC(e).flatMap(e=>{if(e.kind!==`from`)return[];let n=t(e.cap),r=n?.runtimeState??n?.status?.schema;return r===void 0?[]:IC(r,e.fieldPath)?.kind===`union`?[e]:[]}):[])}function jve(e,t,n){return{ref:e.target.kind===`existing`?e.target.device:t.self??pve,native:e.target.kind===`existing`&&t.target?.kind===`found`?t.target:null,replaced:ED(n)}}function ED(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(ZC))}function Mve(e,t,n,r){let i=`${e.cap}.${e.fieldPath}`;return n.some(e=>ZC(e)===i&&!r.replaced.has(i))?[]:r.native===null?[R(`source-field-unknown`,t,`this device has no composed field \`${e.cap}.${e.fieldPath}\``)]:wD(r.native,e.cap)?[]:[R(`source-capability-missing`,t,`the target device (device ${r.native.deviceId}) has no native \`${e.cap}\``)]}function Nve(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?[]:[R(`source-kind-mismatch`,r,`\`${t.cap}.${t.fieldPath}\` of device ${n.deviceId} reads a ${i} now; \`${e.cap}.${e.path}\` takes a ${a}`)]}function Pve(e,t,n){let r=EC(n.ref);return e.flatMap(i=>i.reads.flatMap(a=>{let o=TT(i),s=EC(a.source);if(s===r)return Mve(a,o,e,n);let c=t.sources.get(s);return c===void 0||c.kind===`unreadable`?[R(`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`?[R(`source-missing`,o,`source \`${s}\` does not exist`)]:c.caps.has(a.cap)?Nve(i,a,c,o):[R(`source-capability-missing`,o,`source \`${s}\` (device ${c.deviceId}) has no \`${a.cap}\``)]}))}function Fve(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 Ive(e,t,n){for(let r of e){let e=Fve(r,t);if(e===null)continue;let i=`${e.cap}.${e.fieldPath}`,a=n.find(e=>ZC(e)===i);if(a!==void 0)return TT(a)}return`features`}function Lve(e,t){for(let[n,r]of t)if(e.some(e=>e.startsWith(`${n}#`)))return{key:n,error:r};return null}function Rve(e,t,n,r){let i={blockId:t.blockId??`(unsaved)`,target:r.ref,composition:e,replaced:r.replaced},a=EC(i.target),o=t.unreadTargets??new Map;try{return lD(i,t.peers).map(e=>{let t=Ive(e.path,a,n),r=Lve([...e.component],o);return r===null?R(`cycle`,t,`a field reads itself: ${e.path.join(` → `)}`):R(`cycle`,t,`possible cycle through \`${r.key}\` — its state could not be read (${r.error}): ${e.path.join(` → `)}`)})}catch(e){if(e instanceof sD)return[R(`duplicate-target`,`features`,e.message)];throw e}}function DD(e,t){let n=TD(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=Rve(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,...Pve(n.fields,t,r),...aE(e,t.sources),...a,...oD(e,o),...bD(e).map(e=>R(`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 OD=b({path:u(),kind:KC,nullable:v(),required:v(),enumValues:S(u()).optional()}),kD=b({cap:u(),fields:S(OD),itemArray:b({path:u(),keyField:u()}).optional()}),AD=b({caps:S(kD)});function jD(e,t){if(SD.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=LC(n),a=e.status?.itemArray?.path??null;return RC(n).some(e=>e!==a&&!i.has(e))&&r.push(`not-composable`),UC(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 zve(e,t){return e.filter(e=>jD(e,t).length===0).map(e=>{let t=e.runtimeState,n=t===void 0?[]:[...LC(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 MD=b({addonId:u().min(1),stableId:u().min(1),cap:u().min(1),fieldPath:u().min(1)}),Bve=b({kind:m(`identity`)}),Vve=b({kind:m(`invert`)}),ND=b({kind:m(`threshold`),comparison:x([`gte`,`lte`]),threshold:r(),startDwellMs:r().nonnegative(),stopDwellMs:r().nonnegative(),minSamples:r().int().min(1).optional()}),PD=a(`kind`,[Bve,Vve,ND,b({kind:m(`linear`),scale:r(),offset:r(),clampMin:r().optional(),clampMax:r().optional()}),b({kind:m(`enum-map`),mapping:h(u(),u().nullable())}),b({kind:m(`number`)})]),Hve=b({kind:m(`scalar`),cap:u().min(1),targetId:u().min(1),source:MD,transform:PD}),Uve=b({kind:m(`keyedArray`),cap:u().min(1),targetId:u().min(1),key:u().min(1),label:u().min(1),fieldPath:u().min(1),source:MD,transform:PD}),Wve=b({kind:m(`pulse`),cap:u().min(1),targetId:u().min(1),enabled:v(),debounceMs:r().nonnegative(),edges:S(x([`rising`,`button`,`native-event`])).min(1).optional(),sources:S(MD).min(1)}),Gve=MD.extend({mode:x([`in-addition`,`confirm`,`replace`]).optional()}),Kve=a(`kind`,[Hve,Uve,Wve,b({kind:m(`span`),cap:u().min(1),targetId:u().min(1),timeoutMs:r().nonnegative(),cooldownMs:r().nonnegative().optional(),sources:S(Gve)})]),qve=b({targetId:u().min(1),configured:v(),source:x([`native`,`assigned`]),state:x([`active`,`stale`,`released`,`unavailable`]),reason:u().nullable()}),FD=x([`raw`,`5m`]),ID=x([`high`,`medium`,`low`]),LD=x([`no-history`,`span-too-short`,`truncated`,`no-idle-floor`,`no-runs`,`no-separation`]),RD=b({intervals:r().int().nonnegative(),extra:r().int().nonnegative(),missed:r().int().nonnegative()}),zD=b({tier:FD,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:RD}),BD=b({spanMs:r().nonnegative(),points:r().int().nonnegative(),runsFound:r().int().nonnegative()}),VD=a(`state`,[b({state:m(`proposal`),transform:ND,evidence:zD,confidence:ID,notes:S(u())}),b({state:m(`insufficient`),reason:LD,evidence:BD,fallback:ND})]),HD=b({apply:v()}),UD=b({apply:v(),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:v()}),WD=`core-block-`,GD=`core-blocks`;function KD(e){return`${WD}${e}`}function Jve(e){if(!e.startsWith(`core-block-`))return null;let t=e.slice(11);return t.length>0?t:null}var qD=g([m(`hub`),u().min(1)]),JD=x([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),YD=`main.ts`,XD=h(u().min(1).max(260),u().max(2e5)),ZD=be(),QD=b({name:u().min(1).max(120),code:u().max(2e5).optional(),files:XD.optional(),entry:u().min(1).max(260).optional(),enabled:v(),placement:qD,integrationId:u().optional(),settingsSchema:ZD.optional(),tags:Zu.optional()}),$D=QD.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 eO(e){return e!==void 0&&e.length>0?e:YD}function tO(e){let t=eO(e.entry);return e.files===void 0?{files:{[t]:e.code},entry:t}:{files:{...e.files},entry:t}}function Yve(e){if(e.files!==void 0){let t=eO(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 nO=a(`kind`,[b({kind:m(`code`)}),b({kind:m(`recipe`),recipe:t_}),b({kind:m(`composition`),composition:TC})]),rO=b({name:u().min(1).max(120).optional(),enabled:v(),composition:TC}),iO=b({name:u().min(1).max(120),code:u().max(2e5),files:XD.optional(),entry:u().min(1).max(260).optional(),enabled:v(),placement:qD,integrationId:u().optional(),settingsSchema:ZD.optional(),tags:Zu.optional(),id:u(),createdAt:r(),updatedAt:r(),createdBy:u(),status:JD,lastError:u().optional(),lastChangedAt:r(),source:nO.optional()});function aO(e){return e.source?.kind??`code`}function oO(e){return e.source?.kind===`composition`?e.source.composition:null}var sO=a(`kind`,[b({kind:m(`answered`),state:iw.nullable()}),b({kind:m(`unreachable`),error:u()})]),cO=b({block:iO,state:sO}),lO=b({state:m(`not-loaded`),reason:u()}),uO=a(`state`,[b({state:m(`loaded`),views:S(cO)}),lO]),dO=a(`state`,[b({state:m(`loaded`),view:cO.nullable()}),lO]),fO=a(`state`,[b({state:m(`loaded`),view:cO.nullable()}),lO]),pO=b({ok:v(),error:u().optional(),line:r().optional(),column:r().optional()}),mO=b({code:u().optional(),files:XD.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`]})}),hO={name:`core-blocks`,scope:`system`,mode:`singleton`,methods:{list:E(b({}),b({blocks:S(iO)}),{auth:`admin`}),get:E(b({blockId:u()}),b({block:iO.nullable()}),{auth:`admin`}),create:E(b({block:$D}),b({block:iO}),{kind:`mutation`,auth:`admin`,caller:`required`}),update:E(b({blockId:u(),block:QD.partial()}),b({block:iO}),{kind:`mutation`,auth:`admin`,caller:`required`}),delete:E(b({blockId:u()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setEnabled:E(b({blockId:u(),enabled:v()}),b({block:iO}),{kind:`mutation`,auth:`admin`}),restart:E(b({blockId:u()}),b({block:iO}),{kind:`mutation`,auth:`admin`}),compile:E(mO,pO,{kind:`mutation`,auth:`admin`}),getBlockSettings:E(b({blockId:u()}),Fv.nullable(),{auth:`admin`}),updateBlockSettings:E(b({blockId:u(),patch:Iv}),Rv,{kind:`mutation`,auth:`admin`}),migrateRawSecrets:E(HD,UD,{kind:`mutation`,auth:`admin`}),getTypeDefs:E(b({}),b({libs:S(b({filePath:u(),content:u()}))}),{auth:`admin`}),createComposition:E(b({block:rO}),b({block:iO}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateComposition:E(b({blockId:u(),expectedUpdatedAt:r(),block:rO.partial()}),b({block:iO}),{kind:`mutation`,auth:`admin`,caller:`required`}),getComposition:E(b({blockId:u()}),dO,{auth:`admin`}),listCompositions:E(b({}),uO,{auth:`admin`}),getCustomization:E(b({addonId:u().min(1),stableId:u().min(1)}),fO,{auth:`admin`}),listComposableCaps:E(b({deviceType:x(j)}),AD,{auth:`admin`}),validateComposition:E(b({composition:TC,blockId:u().optional()}),ew,{kind:`mutation`,auth:`admin`,access:`view`}),proposeRunningThreshold:E(b({deviceId:r().int(),cap:u().min(1),fieldPath:u().min(1),deviceType:x(j).optional()}),VD,{auth:`admin`,access:`view`}),reportAutomationRun:E(b({blockId:u().min(1),trace:y_.optional(),runStartedAt:r().optional(),keepTraces:r().int().min(1).max(100).optional()}),_(),{kind:`mutation`,auth:`admin`}),getAutomationRunState:E(b({blockId:u().min(1)}),ade,{auth:`admin`}),getTraces:E(b({blockId:u().min(1)}),b({traces:S(y_),lastError:u().nullable()}),{auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},gO=x([`open`,`opening`,`closing`,`closed`,`stopped`]),_O=b({state:gO,position:r().min(0).max(100).nullable().meta(k(`percentage`)),tiltPosition:r().min(0).max(100).nullable().meta(k(`percentage`)),lastChangedAt:r()}),vO={name:`cover`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Cover],methods:{open:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.open`,label:I(`Open`,`Apri`),phrase:I(`Open {device}`,`Apri {device}`),icon:`arrow-up-to-line`,effect:{field:`state`,value:`open`}}]}),close:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.close`,label:I(`Close`,`Chiudi`),phrase:I(`Close {device}`,`Chiudi {device}`),icon:`arrow-down-to-line`,effect:{field:`state`,value:`closed`}}]}),stop:D(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.stop`,label:I(`Stop`,`Ferma`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setPosition:D(b({deviceId:r().int().nonnegative(),position:r().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.position`,label:I(`Set position`,`Imposta la posizione`),phrase:I(`Move {device} to {position} open`,`Porta {device} al {position} di apertura`),icon:`blinds`,effect:{field:`position`,fromArg:`position`},openArgs:[{key:`position`,label:I(`Position`,`Posizione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setTiltPosition:D(b({deviceId:r().int().nonnegative(),tiltPosition:r().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.tilt`,label:I(`Set tilt`,`Imposta l’inclinazione`),phrase:I(`Tilt {device} to {tiltPosition}`,`Inclina {device} al {tiltPosition}`),icon:`blinds`,effect:{field:`tiltPosition`,fromArg:`tiltPosition`},openArgs:[{key:`tiltPosition`,label:I(`Tilt`,`Inclinazione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},status:{schema:_O,kind:`push`},runtimeState:_O,durability:`restored`,history:{fields:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Cover`,`Copertura`),order:1030,state:[{kind:`enum`,field:`state`,label:I(`State`,`Stato`),values:[{value:`open`,label:I(`Open`,`Aperto`),phrase:I(`When {device} is fully open`,`Quando {device} è tutto aperto`)},{value:`opening`,label:I(`Opening`,`In apertura`),phrase:I(`When {device} starts opening`,`Quando {device} inizia ad aprirsi`)},{value:`closing`,label:I(`Closing`,`In chiusura`),phrase:I(`When {device} starts closing`,`Quando {device} inizia a chiudersi`)},{value:`closed`,label:I(`Closed`,`Chiuso`),phrase:I(`When {device} is fully closed`,`Quando {device} è tutto chiuso`)},{value:`stopped`,label:I(`Stopped`,`Fermo`),phrase:I(`When {device} stops part-way`,`Quando {device} si ferma a metà`)}],icon:`blinds`},{kind:`numeric`,field:`position`,quantity:I(`the opening`,`l’apertura`),label:I(`Position`,`Posizione`),unit:`%`,icon:`blinds`}],overrides:{byRole:{[N.CoverGarage]:{actions:{"cover.open":{phrase:I(`Open the garage door {device}`,`Apri il garage {device}`),icon:`warehouse`},"cover.close":{phrase:I(`Close the garage door {device}`,`Chiudi il garage {device}`),icon:`warehouse`}}},[N.CoverGate]:{actions:{"cover.open":{phrase:I(`Open the gate {device}`,`Apri il cancello {device}`),icon:`fence`},"cover.close":{phrase:I(`Close the gate {device}`,`Chiudi il cancello {device}`),icon:`fence`}}},[N.CoverDoor]:{actions:{"cover.open":{phrase:I(`Open the door {device}`,`Apri la porta {device}`),icon:`door-open`},"cover.close":{phrase:I(`Close the door {device}`,`Chiudi la porta {device}`),icon:`door-closed`}}},[N.CoverWindow]:{actions:{"cover.open":{phrase:I(`Open the window {device}`,`Apri la finestra {device}`),icon:`app-window`},"cover.close":{phrase:I(`Close the window {device}`,`Chiudi la finestra {device}`),icon:`app-window`}}},[N.CoverShutter]:{actions:{"cover.open":{phrase:I(`Raise the shutter {device}`,`Alza la tapparella {device}`)},"cover.close":{phrase:I(`Lower the shutter {device}`,`Abbassa la tapparella {device}`)}}},[N.CoverAwning]:{actions:{"cover.open":{phrase:I(`Extend the awning {device}`,`Apri la tenda da sole {device}`)},"cover.close":{phrase:I(`Retract the awning {device}`,`Chiudi la tenda da sole {device}`)}}}}}}},yO=b({stepId:u(),entry:Xd}),bO=b({path:u().min(1),bytes:r().int().nonnegative(),sha256:u().regex(/^[0-9a-f]{64}$/)}),xO=b({addonId:u(),stepId:u().min(1),entries:S(Xd).min(1).max(4),bundle:b({ticket:Xa,bytes:r().int().positive(),sha256:u().regex(/^[0-9a-f]{64}$/)}),files:S(bO).min(1).max(64),distribute:v()}),SO=a(`kind`,[b({kind:m(`imported`),modelIds:S(u()).readonly(),distributed:S(b({modelId:u(),nodeId:u(),format:x(Ld),ok:v(),error:u().optional()})).readonly()}),b({kind:m(`refused`),reason:x([`transfer-failed`,`checksum-mismatch`,`bundle-mismatch`,`invalid-entry`,`id-taken`]),detail:u()})]),CO={name:`custom-model-registry`,scope:`system`,mode:`collection`,internal:!0,methods:{listModels:E(_(),S(yO).readonly(),{auth:`admin`}),importModelBundle:E(xO,SO,{kind:`mutation`,auth:`admin`,timeoutMs:30*6e4})},vocabulary:{notOperatorFacing:O.ML}},wO=b({engineId:u(),kind:x([`relational`,`vector`]),displayName:u()}),TO={name:`data-store-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{getEngineInfo:E(_(),wO,{auth:`admin`}),get:E(b({namespace:u().optional(),collection:u(),key:u()}),C(),{auth:`admin`}),set:E(b({namespace:u().optional(),collection:u(),key:u(),value:C()}),_(),{kind:`mutation`,auth:`admin`}),query:E(b({namespace:u().optional(),collection:u(),filter:Ao.optional(),columns:S(u()).readonly().optional()}),S(Mo).readonly(),{auth:`admin`}),insert:E(b({namespace:u().optional(),collection:u(),record:b({id:u().optional(),data:h(u(),C())})}),b({id:g([u(),r()])}),{kind:`mutation`,auth:`admin`}),upsert:E(b({namespace:u().optional(),collection:u(),conflict:S(u()).readonly(),record:No}),b({id:g([u(),r()])}),{kind:`mutation`,auth:`admin`}),upsertMany:E(b({namespace:u().optional(),collection:u(),conflict:S(u()).readonly(),records:S(No).readonly()}),b({upserted:r().int()}),{kind:`mutation`,auth:`admin`}),insertMany:E(b({namespace:u().optional(),collection:u(),records:S(No).readonly()}),b({inserted:r().int()}),{kind:`mutation`,auth:`admin`}),transact:E(b({namespace:u().optional(),guard:pie.optional(),ops:S(fie).readonly()}),b({applied:v(),current:C().optional()}),{kind:`mutation`,auth:`admin`}),update:E(b({namespace:u().optional(),collection:u(),id:u(),data:h(u(),C())}),_(),{kind:`mutation`,auth:`admin`}),delete:E(b({namespace:u().optional(),collection:u(),key:u()}),_(),{kind:`mutation`,auth:`admin`}),deleteWhere:E(b({namespace:u().optional(),collection:u(),filter:jo}),b({deleted:r().int()}),{kind:`mutation`,auth:`admin`}),updateWhere:E(b({namespace:u().optional(),collection:u(),filter:jo,data:h(u(),C())}),b({updated:r().int()}),{kind:`mutation`,auth:`admin`}),count:E(b({namespace:u().optional(),collection:u(),filter:Ao.optional()}),r(),{auth:`admin`}),aggregate:E(b({namespace:u().optional(),collection:u(),fields:S(lie).readonly(),filter:Ao.optional()}),uie,{auth:`admin`}),histogram:E(b({namespace:u().optional(),collection:u(),field:u(),bucketSize:r().int().positive(),origin:r().int(),filter:Ao.optional()}),S(b({bucket:r().int(),count:r().int()})).readonly(),{auth:`admin`}),isEmpty:E(b({namespace:u().optional(),collection:u()}),v(),{auth:`admin`}),declareCollection:E(Fo,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},EO=x([`auto`,`day`,`night`,`schedule`]),DO=b({min:r(),max:r(),step:r()}),OO=b({mode:EO,sensitivity:r().optional().meta(k(`none`)),switchDelaySec:r().optional().meta(k(`duration`)),lastFetchedAt:r()}),kO=b({modes:S(EO),supportsSensitivity:v(),sensitivity:DO.optional(),supportsSwitchDelay:v(),switchDelaySec:DO.optional()}),AO=b({mode:EO.optional(),sensitivity:r().optional(),switchDelaySec:r().optional()}),jO={name:`day-night`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`day-night`,tab:`image`}},methods:{getOptions:E(b({deviceId:r()}),kO),setSettings:E(b({deviceId:r(),settings:AO}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`dayNight.auto`,label:I(`Day/night auto`,`Giorno/notte automatico`),phrase:I(`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:I(`Day mode`,`Modalità giorno`),phrase:I(`Force {device} into day mode`,`Forza {device} in modalità giorno`),icon:`sun`,args:{settings:{mode:`day`}}},{id:`dayNight.night`,label:I(`Night mode`,`Modalità notte`),phrase:I(`Force {device} into night mode`,`Forza {device} in modalità notte`),icon:`moon`,args:{settings:{mode:`night`}}}]})},status:{schema:OO,kind:`poll`},runtimeState:OO,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Day/night`,`Giorno/notte`),order:3070,state:[{kind:`enum`,field:`mode`,label:I(`Day/night mode`,`Modalità giorno/notte`),values:[{value:`auto`,label:I(`Automatic`,`Automatica`)},{value:`day`,label:I(`Day`,`Giorno`),phrase:I(`When {device} switches to day mode`,`Quando {device} passa in modalità giorno`)},{value:`night`,label:I(`Night`,`Notte`),phrase:I(`When {device} switches to night mode`,`Quando {device} passa in modalità notte`)},{value:`schedule`,label:I(`Scheduled`,`Programmata`)}],icon:`sun-moon`}]}},Xve=[{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)`}],Zve={hwaccel:`auto`,probedBestHwaccel:``},MO={name:`decoder`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{getInfo:E(_(),b({id:u(),name:u(),hwaccel:u().optional(),probedBestHwaccel:u().optional()})),reprobeHwaccel:E(_(),b({backend:u()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},NO={name:`detection-pipeline`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:I(`Detection pipeline`,`Pipeline di rilevamento`),order:3080}},PO=x([`device`,`integration`]),FO=b({url:u(),label:u(),target:PO,host:u()}),IO={name:`device-admin-link`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getAdminLink:E(b({deviceId:r().int().nonnegative()}),FO.nullable(),{auth:`admin`})},vocabulary:{noun:I(`Admin link`,`Link di amministrazione`),order:3090}},LO=x([`online`,`sleeping`,`offline`,`unknown`]),RO=o(()=>b({childNativeId:u(),name:u(),type:x(j),status:LO,metadata:b({model:u().optional(),serialNumber:u().optional(),uid:u().optional(),rtspChannel:r().int().nonnegative().optional(),isBattery:v().optional(),isDoorbell:v().optional(),isMultifocal:v().optional(),externalLocation:u().optional(),manufacturer:u().optional(),integration:u().optional()}).default({}),alreadyAdopted:v(),adoptedDeviceId:r().int().nonnegative().nullable(),capabilities:S(u()).readonly().optional(),features:S(u()).readonly().optional(),sourceInfo:uh.optional(),children:S(RO).readonly().optional(),parentStableId:u().optional()})),zO=b({id:u(),label:u(),isDefault:v().optional()}),BO=b({search:u().optional(),area:u().optional(),manufacturer:u().optional(),adoptedOnly:v().optional(),unadoptedOnly:v().optional()}),VO=b({integrationId:u(),page:r().int().positive().default(1),pageSize:r().int().positive().max(2e4).default(50),filter:u().optional(),filterText:BO.optional()}),HO=b({candidates:S(RO).readonly(),totalCount:r().int().nonnegative(),page:r().int().positive(),pageSize:r().int().positive()}),UO=b({integrationId:u(),childNativeId:u()}),WO=b({lastDiscoveryAt:r().int().nonnegative().nullable(),candidateCount:r().int().nonnegative(),adoptedCount:r().int().nonnegative(),lastError:u().nullable()}),Qve=b({name:u().min(1).optional(),hiddenChildIds:S(u()).optional()}),GO=b({integrationId:u(),childNativeIds:S(u()).min(1),filter:u().optional(),importLocations:v().optional(),perCandidate:h(u(),Qve).optional()}),KO=b({adopted:S(b({childNativeId:u(),parentDeviceId:r().int().nonnegative(),accessoryDeviceIds:S(r().int().nonnegative()).readonly()})).readonly()}),qO=b({integrationId:u(),camDeviceId:r().int().nonnegative()}),JO=b({camDeviceId:r().int().nonnegative(),resetToSource:v().optional()}),YO=b({changed:v(),rebuiltChildren:r().int().nonnegative(),removedChildren:r().int().nonnegative().optional()}),XO={name:`device-adoption`,scope:`system`,mode:`collection`,status:{schema:WO,kind:`poll`},methods:{listCandidateFilters:E(b({integrationId:u()}),b({filters:S(zO)}),{auth:`admin`}),listCandidates:E(VO,HO,{auth:`admin`}),getCandidate:E(UO,RO.nullable(),{auth:`admin`}),refresh:E(b({integrationId:u()}),WO,{kind:`mutation`,auth:`admin`}),adopt:E(GO,KO,{kind:`mutation`,auth:`admin`}),release:E(qO,_(),{kind:`mutation`,auth:`admin`}),resync:E(JO,YO,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`device adoption — an onboarding flow, not an action`}},ZO=a(`state`,[b({state:m(`absent`)}),b({state:m(`ready`),subject:u(),fingerprintSha256:u(),validTo:u()}),b({state:m(`unavailable`),reason:u()})]),QO=b({selfEnrollment:x([`allowed`,`disabled`])}),$O={name:`device-credentials`,scope:`system`,mode:`singleton`,methods:{listDeviceCredentials:E(b({userId:u().min(1).optional(),includeRevoked:v().default(!1)}),S(up).readonly(),{auth:`admin`}),startEnrollment:E(b({userId:u().min(1),deviceName:u().min(1).max(80)}),dp,{kind:`mutation`,auth:`admin`,caller:`required`}),revokeDeviceCredential:E(b({id:u().min(1)}),b({revoked:v(),sessionsEnded:r().int(),status:lp}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCertificateSettings:E(b({}),QO,{auth:`admin`}),setDeviceCertificateSettings:E(QO,QO,{kind:`mutation`,auth:`admin`}),deleteDeviceCredential:E(b({id:u().min(1)}),b({result:x([`deleted`,`live`,`unknown`])}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCaStatus:E(b({}),ZO,{auth:`admin`}),renameDeviceCredential:E(b({id:u().min(1),deviceName:u().min(1).max(80)}),b({renamed:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.IDENTITY}},ek=/^[a-z][a-z0-9_]*$/,$ve=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(`.`)),tk=u().max(64).regex(ek);function nk(e){return $ve.has(e)}function rk(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 eye(e,t){let n=rk(e);if(!nk(n)&&!t(n))return n;for(let e=2;;e+=1){let r=`${n}_${e}`;if(!t(r))return r}}function tye(e,t){return e.length===0?{ok:!1,reason:`empty`}:e.length>64?{ok:!1,reason:`too-long`}:ek.test(e)?nk(e)?{ok:!1,reason:`reserved`}:t(e)?{ok:!1,reason:`taken`}:{ok:!0,alias:e}:{ok:!1,reason:`grammar`}}var ik=[`filter`,`global`,`variable`],ak=[`number`,`unit`,`text`,`state`,`time`,`fallback`,`loop`,`variable`],ok=[`string`,`number`,`boolean`],sk=a(`kind`,[b({kind:m(`units-of-field`)}),b({kind:m(`choices`),options:S(b({value:u(),labelKey:u().min(1)})).min(1)}),b({kind:m(`range`),min:r(),max:r(),step:r().positive()})]),nye=sk,ck=b({name:u().min(1),type:x(ok),optional:v(),default:g([u(),r(),v()]).optional(),values:sk.optional()}),rye=b({name:u().min(1),kind:x(ik),category:x(ak),params:S(ck),descriptionKey:u().min(1),exampleKey:u().min(1)});function lk(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 z(e,t,n,r){return{name:e,kind:t,category:n,params:[...r],descriptionKey:`uiLibrary.deviceTemplateCatalogue.${e}.description`,exampleKey:`uiLibrary.deviceTemplateCatalogue.${e}.example`}}var uk=lk(`digits`,`number`,!0,0,{kind:`range`,min:0,max:4,step:1}),dk={kind:`units-of-field`},fk=[[`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)`]],pk=e=>`uiLibrary.deviceTemplateCatalogue.choice.time.${e}`,iye={kind:`choices`,options:fk.map(([e,t])=>({value:t,labelKey:pk(e)}))},mk=lk(`fallback`,`string`,!1),hk=lk(`falsy`,`boolean`,!0,!1),gk=[z(`unit`,`filter`,`unit`,[lk(`symbol`,`string`,!1,void 0,dk),lk(`from`,`string`,!0,void 0,dk)]),z(`round`,`filter`,`number`,[uk]),z(`trunc`,`filter`,`number`,[uk]),z(`onoff`,`filter`,`state`,[]),z(`default`,`filter`,`fallback`,[mk,hk]),z(`since`,`filter`,`time`,[]),z(`ago`,`filter`,`time`,[]),z(`format`,`filter`,`text`,[lk(`pattern`,`string`,!1)]),z(`upper`,`filter`,`text`,[]),z(`lower`,`filter`,`text`,[]),z(`title`,`filter`,`text`,[]),z(`capitalize`,`filter`,`text`,[]),z(`trim`,`filter`,`text`,[]),z(`abs`,`filter`,`number`,[]),z(`int`,`filter`,`number`,[lk(`fallback`,`number`,!0,0)]),z(`float`,`filter`,`number`,[lk(`fallback`,`number`,!0,0)]),z(`length`,`filter`,`text`,[]),z(`d`,`filter`,`fallback`,[mk,hk]),z(`join`,`filter`,`text`,[lk(`separator`,`string`,!0,``)]),z(`replace`,`filter`,`text`,[lk(`old`,`string`,!1),lk(`new`,`string`,!1),lk(`count`,`number`,!0)]),z(`first`,`filter`,`loop`,[]),z(`last`,`filter`,`loop`,[]),z(`sort`,`filter`,`loop`,[lk(`reverse`,`boolean`,!0,!1),lk(`caseSensitive`,`boolean`,!0,!1)]),z(`reverse`,`filter`,`loop`,[]),z(`sum`,`filter`,`number`,[]),z(`string`,`filter`,`text`,[]),z(`list`,`filter`,`loop`,[]),z(`truncate`,`filter`,`text`,[lk(`length`,`number`,!1),lk(`killwords`,`boolean`,!0,!1),lk(`end`,`string`,!0,`…`)]),z(`time`,`filter`,`time`,[lk(`pattern`,`string`,!1,void 0,iye)]),z(`range`,`global`,`loop`,[lk(`stop`,`number`,!1),lk(`start`,`number`,!0,0),lk(`step`,`number`,!0,1)]),z(`now`,`variable`,`time`,[]),z(`camera`,`variable`,`variable`,[]),z(`loop`,`variable`,`loop`,[]),z(`lastPerson`,`variable`,`variable`,[]),z(`lastPlate`,`variable`,`variable`,[])],aye={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 oye(){let e={};for(let t of gk){let n=aye[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 fk)e[pk(t)]={en:n,it:r};return e}var _k=oye();function vk(){return gk.filter(e=>e.kind===`filter`).map(e=>e.name)}function sye(){let e={};for(let t of gk)t.kind===`filter`&&(e[t.name]=t.params.length);return e}function cye(){return gk.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 yk=new Set([`now`,`camera`,`loop`]);function bk(){return gk.filter(e=>e.kind===`variable`&&yk.has(e.name))}function xk(){return gk.filter(e=>e.kind===`variable`&&!yk.has(e.name))}function Sk(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 Ck(e,t){return _k[e]?.[t]}function lye(){let e=[`| Name | Kind | What it does | Example |`,`| --- | --- | --- | --- |`],t=gk.map(e=>{let t=wk(Ck(e.descriptionKey,`en`)??``),n=wk(Ck(e.exampleKey,`en`)??``);return`| \`${Sk(e)}\` | ${e.kind} | ${t} | \`${n}\` |`});return[...e,...t].join(`
1110
- `)}function wk(e){return e.replaceAll(`|`,`\\|`)}function uye(){let e=[];for(let t of Object.values(gh))e.includes(t.dimension)||e.push(t.dimension);return e.map(e=>({group:e,choices:Th(e).map(e=>({value:e}))}))}function Tk(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:yh(t);return n===void 0?uye():[{group:n,choices:Th(n).map(e=>({value:e}))}]}var Ek=4096,dye=4096,Dk=u().min(1).max(Ek),fye=`camera`,Ok=g([u(),r(),v()]),kk=b({deviceId:r().int(),values:h(u().min(1).max(64),Ok).optional()}),pye=`values`,mye=vk(),Ak=[`too-long`,`syntax`,`forbidden-syntax`,`forbidden-member`,`unknown-filter`,`ambiguous-field`,`busy`,`budget-exceeded`,`timeout`,`output-too-large`,`render-failed`,`out-of-scope`,`unavailable`],jk=b({reason:x(Ak),message:u()}),Mk=[`unknown-alias`,`unknown-field`,`no-field`,`unavailable`],Nk=b({ref:u(),reason:x(Mk)}),Pk=a(`ok`,[b({ok:m(!0),text:u(),trace:S(Nk)}),b({ok:m(!1),refusal:jk,trace:S(Nk)})]);function Fk(e){return e.replace(/-/g,`_`)}function Ik(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Lk(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(Ik(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function hye(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||Fk(e)===n);if(i!==void 0){let n=t.slice(1);if(n.length===0)return{kind:`missing`,reason:`no-field`};let r=Lk(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 Ik(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=Lk(e.slices[o],t);return s===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:o,fieldPath:t,value:s}}var Rk=b({zoneKey:u(),label:u(),icon:Bu.nullable(),locationKeys:S(u())});function gye(e){return e.trim().toLowerCase()}var zk=[`mac`,`serial`,`machine-uuid`,`vendor-uid`,`hostname`,`ip`],Bk=x(zk),Vk=x([`read`,`derived`]),_ye=/^[0-9a-f]{2}(?::[0-9a-f]{2}){5}$/,Hk=/^[a-z0-9][a-z0-9._-]*:[^\sA-Z]+$/,Uk=/^[0-9a-f][0-9a-f-]{7,}$/,Wk=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function Gk(e){return b({value:e,origin:Vk,readAt:r().int().nonnegative()}).strict()}var vye=Gk(u().regex(_ye)),yye=Gk(u().regex(Hk)),bye=Gk(u().regex(Uk)),xye=Gk(u().regex(Hk)),Sye=Gk(u().regex(Wk)),Cye=Gk(g([te(),s()])),wye=b({value:u().min(1),origin:Vk,readAt:r().int().nonnegative()}).strict(),Kk=b({mac:S(vye).min(1).readonly().optional(),serial:yye.optional(),"machine-uuid":bye.optional(),"vendor-uid":xye.optional(),hostname:Sye.optional(),ip:Cye.optional()}).strict(),Tye={mac:`strong`,serial:`strong`,"machine-uuid":`strong`,"vendor-uid":`strong`,hostname:`weak`,ip:`weak`};function qk(e){return Tye[e]}function Jk(e){return zk.every(t=>e[t]===void 0)}var Eye=/^(?:unknown|none|n\/?a|null|undefined|default|0+|-+)$/i,Dye=new Set([`00:00:00:00:00:00`,`ff:ff:ff:ff:ff:ff`]);function Yk(e){return{ok:!1,reason:e}}function Xk(e){let t=e.trim().toLowerCase().replace(/[\s:.-]/g,``);if(!/^[0-9a-f]{12}$/.test(t))return Yk(`not a 48-bit MAC`);let n=(t.match(/../g)??[]).join(`:`);return Dye.has(n)?Yk(`placeholder MAC`):{ok:!0,value:n}}function Oye(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[-._]+|[-._]+$/g,``)}function Zk(e,t,n){let r=Oye(e);if(r.length===0)return Yk(`no ${n}`);let i=t.trim().toLowerCase().replace(/\s+/g,``);return i.length===0?Yk(`blank value`):Eye.test(i)?Yk(`placeholder value`):{ok:!0,value:`${r}:${i}`}}function kye(e){let t=e.trim().toLowerCase().replace(/^\{|\}$/g,``);return Uk.test(t)?/^[0-]+$/.test(t)||/^[f-]+$/.test(t)?Yk(`placeholder uuid`):{ok:!0,value:t}:Yk(`not a uuid`)}function Qk(e){return g([te(),s()]).safeParse(e).success}function Aye(e){let t=e.trim().toLowerCase().replace(/\.$/,``);if(t.length===0)return Yk(`blank hostname`);if(Qk(t))return Yk(`an address, not a hostname`);let n=t.split(`.`)[0]??``;return Wk.test(n)?n===`localhost`?Yk(`placeholder hostname`):{ok:!0,value:n}:Yk(`not a hostname`)}function jye(e){let t=e.trim().toLowerCase().replace(/^\[|\]$/g,``);return Qk(t)?t===`0.0.0.0`||t===`::`||t===`::1`||t.startsWith(`127.`)?Yk(`loopback or unspecified address`):{ok:!0,value:t}:Yk(`not an IP address`)}function $k(e){return e==null||e.trim().length===0}function eA(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($k(e))continue;let t=o(`mac`,e,Xk(e));t!==void 0&&!c.some(e=>e.value===t.value)&&c.push(t)}let l=e.serial===null||e.serial===void 0||$k(e.serial.serial)?void 0:o(`serial`,`${e.serial.manufacturer}:${e.serial.serial}`,Zk(e.serial.manufacturer,e.serial.serial,`manufacturer`)),u=e.vendorUid===null||e.vendorUid===void 0||$k(e.vendorUid.id)?void 0:o(`vendor-uid`,`${e.vendorUid.vendor}:${e.vendorUid.id}`,Zk(e.vendorUid.vendor,e.vendorUid.id,`vendor`)),d=$k(e.machineUuid)?void 0:o(`machine-uuid`,e.machineUuid,kye(e.machineUuid)),f=$k(e.host)?null:e.host.trim(),p=f!==null&&Qk(f.toLowerCase().replace(/^\[|\]$/g,``)),m=$k(e.hostname)?p?null:f:e.hostname,h=$k(e.ip)?p?f:null:e.ip,g=m===null?void 0:o(`hostname`,m,Aye(m)),ee=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},...ee===void 0?{}:{ip:ee}},rejected:a}}function tA(e,t){return e.value===t.value&&e.origin===t.origin}function nA(e,t){return t!==void 0&&tA(e,t)?t:e}function Mye(e,t,n=[]){let r=e??{},i=t??{},a=new Set(n),o=a.has(`mac`)?r.mac:i.mac?.map(e=>nA(e,r.mac?.find(t=>tA(t,e)))),s=e=>{if(a.has(e))return r[e];let t=i[e];return t===void 0?void 0:nA(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 Jk(p)?null:p}function Nye(e,t){let n=e=>e==null||Jk(e)?``:JSON.stringify(zk.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 rA=x([`auto`,`proposal`]),iA=b({key:Bk,value:u()}),aA=b({deviceId:r().int(),addonId:u(),integrationId:u().nullable()}),oA=b({a:aA,b:aA,keys:S(iA).readonly(),confidence:rA}),sA=a(`status`,[b({status:m(`unknown`),reason:u()}),b({status:m(`answered`),pairs:S(oA).readonly(),undeclaredDeviceIds:S(r().int()).readonly()})]),cA=[`same-device`,`poe-power`],lA=x(cA),uA=x([`proposed`,`linked`,`dismissed`]),dA=x([`auto`,`operator`]),fA=b({addonId:u().min(1),stableId:u().min(1),deviceId:r().int()}),pA=b({kind:lA,a:fA,b:fA,state:uA,origin:dA,evidence:S(iA).readonly(),evidenceGone:m(!0).optional(),createdAt:r().int().nonnegative(),decidedAt:r().int().nonnegative().optional()}),mA=pA.extend({id:u().min(1)}),hA={"same-device":{directional:!1,attachingRole:null,contributions:[]},"poe-power":{directional:!0,attachingRole:N.PoePort,contributions:[{cap:`power-source`,targetId:`switch`,host:`b`,source:`a`,sourceCap:`switch`,sourceField:`on`}]}};function Pye(e,t){let n=hA[e].attachingRole;return n===null||t===n?null:`attaching-side-role`}function gA(e){return`${e.addonId}/${e.stableId}`}function Fye(e,t,n){let r=gA(t),i=gA(n);return hA[e].directional||r<=i?`${e}:${r}|${i}`:`${e}:${i}|${r}`}var _A=a(`status`,[b({status:m(`not-loaded`),reason:u()}),b({status:m(`answered`),links:S(mA).readonly()})]),vA=x([`not-loaded`,`unknown-link`,`wrong-state`]),yA=a(`ok`,[b({ok:m(!0),link:mA}),b({ok:m(!1),reason:vA,message:u()})]),bA=x([`evidence-gone`,`device-removed`,`operator-unlinked`]),Iye=b({linkId:u(),kind:lA,aDeviceId:r().int(),bDeviceId:r().int(),origin:dA,reason:bA.optional()}),xA=b({caps:S(u()).readonly().optional(),actions:S(u()).readonly().optional(),mode:x([`any`,`all`]).optional()}),SA=b({locations:S(u()).readonly().optional(),integrationIds:S(u()).readonly().optional(),types:S(u()).readonly().optional()}),CA=b({text:u().optional(),requires:xA.optional(),filters:SA.optional(),includeIncompatible:v().optional(),contextDeviceId:r().optional(),ids:S(r()).readonly().optional(),cursor:u().nullable().optional(),limit:r().int().min(1).max(200).optional()}),wA=b({cap:u(),path:u(),label:u(),reading:u().nullable(),unit:u().nullable().optional(),quantity:Zs.optional()}),TA=b({id:r(),name:u(),type:x(j),location:u().nullable(),integrationId:u().nullable(),integrationLabel:u().nullable(),online:v().nullable(),disabled:v(),compatible:v(),values:S(wA).readonly()}),EA=b({value:u(),count:r()}),DA=b({id:u(),label:u(),count:r()}),OA=b({locations:S(EA).readonly(),integrations:S(DA).readonly(),types:S(EA).readonly()}),kA=b({items:S(TA).readonly(),nextCursor:u().nullable(),total:r(),compatibleTotal:r(),fleetTotal:r(),hiddenIncompatible:r(),facets:OA,suggested:S(TA).readonly(),missingIds:S(r()).readonly()}),AA=b({connected:v(),deviceCount:r(),error:u().optional(),motionSliceWriter:m(`orchestrator`).optional()}),Lye=b({externalId:u(),name:u(),type:u(),metadata:h(u(),C()).optional()}),jA=a(`kind`,[b({kind:m(`mdns`),serviceType:u().min(1),instancePattern:u().optional()}),b({kind:m(`ws-discovery`),types:S(u()).optional()}),b({kind:m(`ssdp`),searchTarget:u().min(1)}),b({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()}),b({kind:m(`http-probe`),port:r().int().min(1).max(65535),path:u().startsWith(`/`),method:x([`GET`,`POST`]).default(`GET`),bodyText:u().optional(),contentType:u().optional(),tls:v().default(!1),acceptStatus:S(r().int()).optional()}),b({kind:m(`custom`),reason:u().min(1)})]),MA=b({modeIndex:r().int().min(0),host:u(),port:r().int(),http:b({status:r().int(),headers:h(u(),u()),bodyText:u()}).optional(),mdns:b({instance:u(),host:u(),port:r().int(),txt:h(u(),u())}).optional(),udp:b({payloadHex:u()}).optional(),wsd:b({xaddrs:S(u()),types:S(u()),scopes:S(u())}).optional()}),NA=b({stableId:u(),type:x(j),suggestedName:u(),prefilledConfig:h(u(),C()),sourceInfo:uh.optional(),alreadyOnboarded:v().optional(),onboardedDeviceId:r().optional(),onboardedName:u().optional(),setupIntegration:v().optional(),parentStableId:u().optional(),selectable:v().optional(),needsParams:S(u()).optional()}),PA=b({id:r(),stableId:u(),addonId:u(),type:u(),name:u(),parentDeviceId:r().nullable(),online:v(),features:S(u()),config:h(u(),C()),sourceInfo:uh.optional()}),FA=b({status:x([`ok`,`error`]),labels:S(u()).optional(),error:u().optional()}),IA=C(),LA={name:`device-provider`,scope:`system`,mode:`collection`,methods:{start:E(_(),_(),{kind:`mutation`}),stop:E(_(),_(),{kind:`mutation`}),getStatus:E(_(),AA),getDevices:E(_(),S(b({id:u(),name:u(),type:u()}))),reloadDevice:E(b({stableId:u()}),b({deviceId:r()}),{kind:`mutation`,timeoutMs:3*6e4}),supportsDiscovery:E(b({}),v()),discoverDevices:E(b({params:h(u(),C()).optional()}),S(NA),{kind:`mutation`,auth:`admin`}),getDiscoveryModes:E(b({}),S(jA)),classifyDiscoveryHits:E(b({hits:S(MA),params:h(u(),C()).optional()}),S(NA),{kind:`mutation`,auth:`admin`}),getDiscoveryParamsSchema:E(b({}),IA),getManualCreationType:E(b({integrationId:u().optional()}),b({deviceType:x(j).nullable()})),adoptDiscoveredDevice:E(b({candidate:NA,integrationId:u().optional()}),PA,{kind:`mutation`,auth:`admin`}),supportsManualCreation:E(b({}),v()),getChildCreationSchema:E(b({type:x(j),integrationId:u().optional()}),IA),createDevice:E(b({type:x(j),config:h(u(),C()),integrationId:u().optional()}),PA,{kind:`mutation`,auth:`admin`}),testCreationField:E(b({type:x(j),key:u(),value:C(),formValues:h(u(),C()).optional()}),FA,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},RA=a(`kind`,[b({kind:m(`mdns`),serviceType:u(),instance:u(),host:u(),address:u().nullable(),port:r().int(),txt:h(u(),u())}),b({kind:m(`ssdp`),host:u(),port:r().int(),target:u(),headers:h(u(),u())})]),Rye=b({addonId:u(),candidate:NA,firstSeenAt:r(),lastSeenAt:r(),dismissed:v()}),zA=b({id:u(),addonId:u(),candidate:NA,firstSeenAt:r(),lastSeenAt:r(),dismissed:v()}),BA=b({childKey:u(),section:u(),order:r().optional(),collapsed:v().optional()}),zye=b({unit:u().min(1).optional(),precision:r().int().min(0).max(10).optional()}),VA=b({icon:u().min(1).optional(),label:u().min(1).optional(),unit:u().min(1).optional(),precision:r().int().min(0).max(10).optional(),hidden:v().optional(),perCap:h(u(),zye).optional()}),HA=b({unit:u().min(1).optional(),precision:r().int().min(0).max(10).optional(),icon:u().min(1).optional()}),UA=b({id:r(),stableId:u(),addonId:u(),type:x(j),name:u(),alias:tk.optional(),location:u().nullable(),tags:Zu.optional(),disabled:v(),parentDeviceId:r().nullable(),role:u().nullable().optional(),online:v(),probed:v().optional(),features:S(u()),isCamera:v(),config:h(u(),C()),secretConfigPaths:S(u()).optional(),metadata:h(u(),C()).nullable().optional(),identifiers:Kk.optional(),attachedIdentifiers:Kk.optional(),sourceInfo:uh.optional(),integrationId:u().optional(),linkDeviceId:r().nullable().optional(),primaryChildEntityId:u().nullable().optional(),childLayout:S(BA).readonly().optional(),primaryChildPreference:S(u()).readonly().optional(),display:VA.optional()}),WA=b({key:u(),value:C(),description:u().optional()}),GA=x([`manual`]),KA=b({deviceId:r(),name:u(),location:u().nullable(),features:S(u()),producesTrackedEvents:v().optional()}),qA=b({deviceIds:S(r().int().positive()),trackedDeviceIds:S(r().int().positive()).optional()}),JA={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:[j.Camera],sourceCaps:`any`,cardinality:`many`,value:qA},Bye=b({deviceId:r(),mode:GA,devices:S(KA)}),YA=b({deviceId:r(),entries:S(b({capName:u(),kind:x([`native`,`wrapped`]),providerAddonId:u(),providerNodeId:u(),nativeAddonId:u(),implementedMethods:S(u()).optional()}))}),XA=a(`kind`,[b({kind:m(`value`),wrapperAddonId:u().nullable()}),b({kind:m(`missing`)}),b({kind:m(`failed`),error:u()})]),Vye=b({id:r(),stableId:u(),type:u(),name:u(),location:u().nullable(),tags:Zu.optional(),disabled:v(),parentDeviceId:r().nullable(),role:u().nullable().optional()}),Hye=b({id:r(),stableId:u(),addonId:u(),type:u(),name:u(),userNamed:v().optional(),location:u().nullable(),tags:Zu.optional(),disabled:v(),parentDeviceId:r().nullable(),metadata:h(u(),C()).nullable().optional(),identifiers:Kk.optional(),attachedIdentifiers:Kk.optional(),sourceInfo:uh.optional(),integrationId:u().optional(),linkDeviceId:r().nullable().optional(),primaryChildEntityId:u().nullable().optional(),childLayout:S(BA).readonly().optional(),primaryChildPreference:S(u()).readonly().optional(),role:u().nullable().optional(),display:VA.optional()}),Uye=C().nullable(),Wye=b({streamId:u(),width:r().optional(),height:r().optional(),codec:u().optional(),fps:r().optional(),bitrateKbps:r().optional()}),Gye=b({addonId:u(),stableId:u(),id:r(),type:u(),name:u(),location:u().nullable().optional(),disabled:v().optional(),parentDeviceId:r().nullable(),role:u().nullable().optional(),features:S(u()).optional(),config:h(u(),C()),secretConfigPaths:S(u()).optional()}),ZA=b({deviceId:r().int().positive(),deletedAt:r(),providerAddonId:u()}),QA=2160*60*60*1e3,$A=b({deviceId:r().int().positive(),stores:h(u(),r().int().nonnegative())}),ej=b({status:x([`skipped`,`dry-run`,`cleaned`]),reason:u().nullable(),devices:S($A),unreachable:S(u())}),Kye=b({deviceId:r()}),qye=b({deviceId:r(),data:h(u(),C()),secretConfigPaths:S(u()).optional()}),tj=x([`off`,`on`,`not-offered`,`unreachable`]),nj=b({deviceId:r(),switchId:Za,outcome:tj,detail:u().optional()}),rj=b({sourceId:r(),targetId:r(),switches:S(nj).readonly(),sourceStillLive:S(Za).readonly(),swapped:v()}),ij={name:`device-manager`,scope:`system`,mode:`singleton`,extensionSlots:[JA],methods:{allocateDeviceId:E(b({addonId:u(),stableId:u()}),b({id:r()}),{kind:`mutation`}),migrateDevice:E(b({sourceId:r(),targetId:r()}),rj,{kind:`mutation`,auth:`admin`,timeoutMs:12*6e4}),registerDevice:E(Gye,_(),{kind:`mutation`}),removeDevice:E(Kye,_(),{kind:`mutation`}),persistConfig:E(qye,_(),{kind:`mutation`,auth:`admin`}),loadConfig:E(b({deviceId:r()}),h(u(),C()),{auth:`admin`}),loadRuntimeState:E(b({deviceId:r()}),h(u(),C()),{auth:`admin`}),loadMeta:E(b({deviceId:r()}),Hye.nullable()),setName:E(b({deviceId:r(),name:u(),stampUserNamed:v().optional()}),_(),{kind:`mutation`,auth:`admin`}),setAlias:E(b({deviceId:r(),alias:u()}),a(`ok`,[b({ok:m(!0),alias:tk}),b({ok:m(!1),reason:x([`empty`,`too-long`,`grammar`,`reserved`,`taken`]),takenBy:r().optional()})]),{kind:`mutation`,auth:`admin`}),renderDeviceTemplates:E(b({templates:S(Dk).max(64),allowedDeviceIds:S(r().int()).optional(),thisDevice:kk.optional()}),b({results:S(Pk)}),{auth:`admin`}),checkDeviceTemplates:E(b({templates:S(u()).max(64),allowedDeviceIds:S(r().int()).optional(),thisDevice:kk.optional()}),b({results:S(a(`ok`,[b({ok:m(!0),aliases:S(b({alias:u(),deviceId:r().int().nullable(),allowed:v(),reads:S(u())})),readsClock:v()}),b({ok:m(!1),refusal:jk})]))}),{auth:`admin`}),setLocation:E(b({deviceId:r(),location:u().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setTags:E(b({deviceId:r(),tags:Zu}),_(),{kind:`mutation`,auth:`admin`}),setType:E(b({deviceId:r(),type:x(j)}),_(),{kind:`mutation`,auth:`admin`}),setIntegrationId:E(b({deviceId:r(),integrationId:u()}),_(),{kind:`mutation`,auth:`admin`}),setLinkDeviceId:E(b({deviceId:r(),linkDeviceId:r().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setPrimaryChildEntityId:E(b({deviceId:r(),primaryChildEntityId:u().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setChildLayout:E(b({deviceId:r(),childLayout:S(BA).readonly()}),_(),{kind:`mutation`,auth:`admin`}),setPrimaryChildPreference:E(b({deviceId:r(),primaryChildPreference:S(u()).readonly()}),_(),{kind:`mutation`,auth:`admin`}),setDisplay:E(b({deviceId:r(),display:VA.nullable()}),_(),{kind:`mutation`,auth:`admin`}),getRoleDisplayDefaults:E(b({}),b({defaults:h(u(),HA)}),{role:`viewer`,kind:`query`}),setRoleDisplayDefaults:E(b({defaults:h(u(),HA)}),_(),{kind:`mutation`,auth:`admin`}),getWireableFields:E(b({deviceId:r(),includeSynthesizable:v().optional()}),b({caps:S(b({cap:u(),fields:S(b({path:u(),kind:x([`string`,`number`,`boolean`,`enum`,`union`]),unionMembers:S(x([`string`,`number`,`boolean`])).optional(),enumValues:S(u()).optional(),item:v().optional(),quantity:Zs.optional()})).readonly(),itemArray:b({path:u(),keyField:u()}).optional()})).readonly()}),{kind:`query`}),setRole:E(b({deviceId:r(),role:u().nullable()}),_(),{kind:`mutation`,auth:`admin`}),applyInitialMeta:E(b({deviceId:r(),name:u().optional(),location:u().nullable().optional(),tags:Zu.optional(),type:x(j).optional(),integrationId:u().optional(),linkDeviceId:r().nullable().optional(),role:u().nullable().optional()}),_(),{kind:`mutation`,auth:`admin`}),setMetadata:E(b({deviceId:r(),patch:h(u(),C())}),_(),{kind:`mutation`,auth:`admin`}),setIdentifiers:E(b({deviceId:r(),identifiers:Kk.nullable(),unread:S(Bk).optional()}),_(),{kind:`mutation`,auth:`admin`}),listIdentityCandidates:E(b({}),sA,{kind:`query`,auth:`admin`}),setAttachedIdentifiers:E(b({deviceId:r(),identifiers:Kk.nullable(),unread:S(Bk).optional()}),_(),{kind:`mutation`,auth:`admin`}),listIdentityLinks:E(b({deviceId:r().int().optional()}),_A,{kind:`query`,auth:`admin`}),confirmIdentityLink:E(b({linkId:u().min(1)}),yA,{kind:`mutation`,auth:`admin`}),dismissIdentityLink:E(b({linkId:u().min(1)}),yA,{kind:`mutation`,auth:`admin`}),unlinkIdentity:E(b({linkId:u().min(1)}),yA,{kind:`mutation`,auth:`admin`}),listLocations:E(_(),S(u())),addLocation:E(b({name:u()}),_(),{kind:`mutation`,auth:`admin`}),removeLocation:E(b({name:u(),cascade:v().optional()}),_(),{kind:`mutation`,auth:`admin`}),renameLocation:E(b({from:u(),to:u()}),b({moved:r()}),{kind:`mutation`,auth:`admin`}),listLocationIcons:E(_(),S(Dp),{role:`viewer`}),setLocationIcon:E(b({location:u(),icon:Bu.nullable()}),_(),{kind:`mutation`,auth:`admin`}),listLocationDescriptions:E(_(),S(kp)),setLocationDescription:E(b({location:u(),description:u().max(400).nullable()}),_(),{kind:`mutation`,auth:`admin`}),listSiteZones:E(_(),S(Rk),{role:`viewer`}),setSiteZone:E(b({name:u(),icon:Bu.nullable().optional()}),_(),{kind:`mutation`,auth:`admin`}),removeSiteZone:E(b({name:u()}),_(),{kind:`mutation`,auth:`admin`}),renameSiteZone:E(b({from:u(),to:u()}),_(),{kind:`mutation`,auth:`admin`}),setLocationZone:E(b({location:u(),zone:u().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setDisabled:E(b({deviceId:r(),disabled:v()}),_(),{kind:`mutation`,auth:`admin`}),listPersistedByAddon:E(b({addonId:u()}),S(Vye)),listAll:E(b({addonId:u().optional(),projection:x([`full`,`slim`]).optional(),isCamera:v().optional(),deviceIds:S(r()).optional()}),S(UA),{role:`viewer`}),search:E(CA,kA,{role:`viewer`}),getDevice:E(b({deviceId:r()}),UA.nullable()),getChildren:E(b({parentDeviceId:r()}),S(UA),{role:`viewer`}),getChildrenBatch:E(b({parentDeviceIds:S(r()).max(256)}),h(u(),S(UA))),getLinkedDevices:E(b({deviceId:r()}),b({mode:GA,devices:S(KA)}),{role:`viewer`}),getLinkedDevicesBatch:E(b({deviceIds:S(r())}),S(Bye),{role:`viewer`}),getStreamSources:E(b({deviceId:r()}),S(pc)),getConfigSchema:E(b({deviceId:r()}),S(WA)),getSettingsSchema:E(b({deviceId:r()}),Uye),updateConfig:E(b({deviceId:r(),values:h(u(),C())}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),enable:E(b({deviceId:r()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),disable:E(b({deviceId:r()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),remove:E(b({deviceId:r()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),listDeletedSince:E(b({sinceMs:r()}),S(ZA).readonly(),{auth:`admin`}),cleanupDeletedDevicesData:E(b({confirm:v()}),ej,{kind:`mutation`,auth:`admin`}),removeByIntegration:E(b({integrationId:u()}),b({removed:r()}),{kind:`mutation`,auth:`admin`}),getStreamProfileMap:E(b({deviceId:r()}),h(u(),u().nullable())),setStreamProfileMap:E(b({deviceId:r(),profileMap:h(u(),u().nullable())}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),probeStreams:E(b({deviceId:r()}),S(Wye),{kind:`mutation`,auth:`admin`}),getBindings:E(b({deviceId:r()}),YA,{role:`viewer`}),getBindingsBatch:E(b({deviceIds:S(r())}),S(YA)),getAllBindings:E(b({}),S(YA)),listDeviceIdsByCaps:E(b({capNames:S(u().min(1)).min(1).max(16)}),S(r()),{role:`viewer`}),setWrapperActive:E(b({deviceId:r(),capName:u(),wrapperAddonId:u(),active:v()}),_(),{kind:`mutation`,auth:`admin`}),getWrapperActivation:E(b({deviceId:r(),capName:u().min(1)}),XA),listWrappersForCap:E(b({capName:u()}),S(u())),listBindableCapsForDeviceType:E(b({deviceType:u()}),S(b({capName:u(),wrappers:S(u())}))),getDeviceSettingsAggregate:E(b({deviceId:r()}),Fv.nullable()),getDeviceLiveInfoAggregate:E(b({deviceId:r()}),Fv.nullable(),{role:`viewer`}),getDeviceAggregate:E(b({deviceId:r()}),b({settings:Fv.nullable(),live:Fv.nullable()})),runDeviceAction:E(b({deviceId:r().int().nonnegative(),action:u().min(1),input:C()}),C(),{kind:`mutation`}),updateDeviceField:E(b({deviceId:r(),writerCapName:u(),writerAddonId:u(),key:u(),value:C()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),updateDeviceFieldsBatch:E(b({deviceId:r(),changes:S(b({writerCapName:u(),writerAddonId:u(),key:u(),value:C()}))}),b({success:m(!0),failures:S(b({writerCapName:u(),writerAddonId:u(),error:u()}))}),{kind:`mutation`,auth:`admin`}),discoverDevices:E(b({addonId:u()}),S(NA),{kind:`mutation`,auth:`admin`}),adoptDevice:E(b({addonId:u(),candidate:NA,integrationId:u().optional()}),PA,{kind:`mutation`,auth:`admin`}),getCreationSchema:E(b({addonId:u(),type:x(j),integrationId:u().optional()}),C().nullable()),createDevice:E(b({addonId:u(),type:x(j),config:h(u(),C()),integrationId:u().optional()}),PA,{kind:`mutation`,auth:`admin`}),testCreationField:E(b({addonId:u(),type:x(j),key:u(),value:C(),formValues:h(u(),C()).optional()}),FA,{kind:`mutation`,auth:`admin`}),adoptionListCandidateFilters:E(b({addonId:u(),integrationId:u()}),b({filters:S(zO)}),{auth:`admin`}),adoptionListCandidates:E(VO.extend({addonId:u()}),HO,{auth:`admin`}),adoptionRefresh:E(b({addonId:u(),integrationId:u()}),WO,{kind:`mutation`,auth:`admin`}),adoptionAdopt:E(GO.extend({addonId:u()}),KO,{kind:`mutation`,auth:`admin`}),adoptionRelease:E(qO.extend({addonId:u()}),_(),{kind:`mutation`,auth:`admin`}),adoptionStartJob:E(GO.extend({addonId:u()}),b({jobId:u()}),{kind:`mutation`,auth:`admin`}),adoptionListJobs:E(b({addonId:u(),integrationId:u().optional()}),S(dre).readonly(),{auth:`admin`}),adoptionCancelJob:E(b({jobId:u()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),adoptionResync:E(JO,YO,{kind:`mutation`,auth:`admin`}),discoveryProviders:E(b({}),b({providers:S(b({addonId:u(),label:u()})).readonly()}),{auth:`admin`}),discoverAllProviders:E(b({subnets:S(u()).optional()}),b({groups:S(b({addonId:u(),label:u(),candidates:S(NA).readonly(),error:u().nullable()})).readonly()}),{kind:`mutation`,auth:`admin`}),discoverProvider:E(b({addonId:u(),params:h(u(),C()).optional(),subnets:S(u()).optional()}),b({candidates:S(NA).readonly()}),{kind:`mutation`,auth:`admin`}),listDiscoveryProposals:E(b({}),b({proposals:S(zA).readonly()}),{auth:`admin`}),dismissDiscoveryProposal:E(b({id:u()}),b({dismissed:v()}),{kind:`mutation`,auth:`admin`}),reportDiscoveryObservations:E(b({observations:S(RA).max(512)}),b({proposed:r().int()}),{kind:`mutation`,auth:`admin`}),runDiscoverySweep:E(b({}),b({providers:r().int(),proposed:r().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),providerCreationType:E(b({addonId:u(),integrationId:u().optional()}),b({deviceType:x(j).nullable()}),{auth:`admin`}),providerDiscoveryParamsSchema:E(b({addonId:u()}),C(),{auth:`admin`}),testField:E(b({deviceId:r(),key:u(),value:C()}),FA,{kind:`mutation`,auth:`admin`}),getDeviceStatusAggregate:E(b({deviceId:r(),caps:S(u()).readonly().optional()}),h(u(),C().nullable())),getDeviceStatusAggregateBatch:E(b({deviceIds:S(r()).readonly(),caps:S(u()).readonly().optional()}),h(u(),h(u(),C().nullable())),{role:`viewer`})},vocabulary:{notOperatorFacing:`the device registry itself — rename, move and remove are administration`}},aj=[`linked-devices`],oj=x(aj),sj={"linked-devices":{descriptor:JA,declaringCap:`device-manager`,hostDeviceTypes:[j.Camera]}},cj=a(`slot`,[qA.extend({slot:m(`linked-devices`)})]),lj=[j.Camera],Jye=`listSlots`,uj=a(`state`,[b({state:m(`ok`)}),b({state:m(`unreachable`),reason:u()})]),dj=b({source:u(),label:u(),addonId:u().optional(),availability:uj}),fj=x([`ok`,`missing`,`foreign`,`unavailable`]),pj=b({deviceId:r().int(),name:u().nullable(),health:fj,detail:u().optional()}),mj=b({state:x([`active`,`inactive`,`unknown`]),authority:u(),detail:u().optional()}),hj=b({state:m(`ok`),slotRef:u(),slot:oj,authority:u(),activation:mj.nullable(),value:cj,sources:S(pj),impliedSources:S(pj).optional()}),gj=b({state:m(`unreachable`),addonId:u(),reason:u()}),_j=a(`state`,[hj,gj]);function Yye(e,t){return{state:`unreachable`,addonId:e,reason:t}}var vj=b({deviceId:r().int(),name:u(),type:u(),location:u().nullable(),parentName:u().nullable(),suggested:v(),reason:u().nullable()}),yj=b({candidates:S(vj)}),bj=b({applied:m(!0),reload:x([`none`,`host`,`parent`])}),xj=b({deviceId:r().int(),slotRef:u().min(1)}),Sj=xj.extend({value:cj}),Cj={name:`device-extension`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:lj,deviceConfig:{ui:{kind:`widget`,widgetId:`host/extensions-panel`,tab:`general`,label:`Extensions`,order:72}},methods:{listSources:E(b({deviceId:r().int()}),S(dj)),listSlots:E(b({deviceId:r().int()}),S(_j)),listCandidates:E(xj,yj),setSlot:E(Sj,bj,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:I(`Device extension`,`Estensione del dispositivo`),order:3100}},wj=a(`kind`,[b({kind:m(`device`),deviceId:r().int()}),b({kind:m(`node`),nodeId:u().min(1)})]),Tj=x([`gauge`,`counter`,`boolean`,`enum`]),Ej=x([`gauge`,`counter`,`boolean`]),Dj=`derived:energy.kwh`,Oj=x([`raw`,`5m`,`1h`,`1d`]),kj=x([`undeclared`,`not-owner`,`opted-out`,`not-a-real-device`,`rate`,`ingest-mismatch`,`out-of-range`]),Xye=b({key:u(),reason:kj,count:r().int()}),Aj=b({accepted:r().int(),refused:S(Xye).readonly()}),jj=b({key:u(),scope:u(),kind:Tj,unit:u().nullable(),displayName:u(),source:x([`cap`,`addon`,`derived`]),values:S(u()).readonly().nullable(),firstTs:r(),lastTs:r()}),Zye=b({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()}),Qye=b({scope:u(),before:b({t:r(),value:r().nullable(),state:u().nullable()}).nullable(),points:S(Zye).readonly(),derivedFrom:u().nullable()}),Mj={key:u(),scope:u().optional(),from:r(),to:r(),resolution:g([Oj,m(`auto`)]).default(`auto`),maxPoints:r().int().positive().max(5e3).default(1e3)},Nj=b({resolution:Oj,series:S(Qye).readonly(),truncated:v()}),$ye=g([b({deviceId:r().int(),key:u(),scope:u().optional()}),b({forNodeId:u().min(1),key:u(),scope:u().optional()})]),ebe=a(`ok`,[b({ok:m(!0),result:Nj}),b({ok:m(!1),error:u()})]),tbe=b({tier:Oj,rows:r().int().nullable(),approxBytes:r().nullable(),countedAt:r().nullable()}),Pj=x([`device-gone`,`undeclared`]),Fj=b({raw:r().int(),"5m":r().int(),"1h":r().int(),"1d":r().int()}),nbe=b({seriesId:r().int(),deviceId:r().int(),key:u(),scope:u(),displayName:u().nullable(),reason:Pj,missingSince:r().nullable(),firstTs:r(),lastTs:r(),rows:Fj}),Ij=x([`not-found`,`not-orphan`,`failed`]),rbe=a(`ok`,[b({seriesId:r().int(),ok:m(!0),deleted:Fj}),b({seriesId:r().int(),ok:m(!1),reason:Ij})]),ibe=b({series:S(nbe).readonly(),truncated:v()}),Lj=x([`invalid-range`,`range-too-large`,`series-not-found`,`not-a-point-series`]),abe=b({"5m":r().int(),"1h":r().int(),"1d":r().int()}),obe=a(`ok`,[b({ok:m(!0),dryRun:v(),seriesId:r().int(),rows:Fj,rewritten:abe.nullable()}),b({ok:m(!1),reason:Lj})]),Rj=b({startedAt:r(),ready:v(),series:r().int(),metrics:r().int(),optedOutDevices:r().int(),tiers:S(tbe).readonly(),capture:b({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:b({accepted:r().int(),refused:h(u(),r().int())}),rollup:b({last5mAt:r().nullable(),last1hAt:r().nullable(),last1dAt:r().nullable(),errors:r().int(),dirty5m:r().int(),dirty1h:r().int(),dirty1d:r().int()}),retention:b({lastRunAt:r().nullable(),deleted:h(u(),r().int()),purgedSeries:r().int()}),directory:b({devices:r().int(),lastRefreshAt:r().nullable()})}),zj={name:`device-history`,scope:`system`,mode:`singleton`,methods:{listSeries:E(b({deviceId:r().int()}),S(jj).readonly()),listNodeSeries:E(b({forNodeId:u().min(1)}),S(jj).readonly(),{auth:`admin`}),query:E(b({deviceId:r().int(),...Mj}),Nj),queryNode:E(b({forNodeId:u().min(1),...Mj}),Nj,{auth:`admin`}),queryMany:E(b({items:S($ye).min(1).max(24),from:Mj.from,to:Mj.to,resolution:Mj.resolution,maxPoints:Mj.maxPoints}),b({results:S(ebe).readonly()}),{auth:`admin`}),declareSeries:E(b({name:u().regex(/^[a-z0-9-]+$/),subjectKind:x([`device`,`node`]),kind:Ej,unit:u().optional(),displayName:u().min(1),ingest:x([`points`,`buckets`])}),b({key:u()}),{kind:`mutation`,auth:`admin`}),record:E(b({points:S(b({key:u(),subject:wj,scope:u().default(``),ts:r(),value:r()})).max(5e3)}),Aj,{kind:`mutation`,auth:`admin`}),recordBuckets:E(b({buckets:S(b({key:u(),subject:wj,scope:u().default(``),bucketStart:r(),samples:r().int().positive(),sum:r(),min:r(),max:r(),last:r().nullable(),lastTs:r().nullable()})).max(5e3)}),Aj,{kind:`mutation`,auth:`admin`}),getDeviceEnabled:E(b({deviceId:r().int()}),b({enabled:v()})),setDeviceEnabled:E(b({deviceId:r().int(),enabled:v()}),b({enabled:v()}),{kind:`mutation`,auth:`admin`}),getStatus:E(b({}),Rj,{auth:`admin`}),listOrphanSeries:E(b({}),ibe,{auth:`admin`}),deleteOrphanSeries:E(b({seriesIds:S(r().int()).min(1).max(50)}),b({results:S(rbe).readonly()}),{kind:`mutation`,auth:`admin`}),deleteSeriesRange:E(b({deviceId:r().int(),key:u().min(1),scope:u(),fromMs:r().int().nonnegative(),toMs:r().int().nonnegative(),dryRun:v()}),obe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`recorded history of device state — read by charts, not actuated`}},sbe=b({id:u(),label:u(),protocol:x([`rtsp`,`rtmp`,`annexb`,`http-mjpeg`,`webrtc`,`custom`]),url:u().optional(),resolution:b({width:r(),height:r()}).optional(),fps:r().optional(),bitrate:r().optional(),codec:u().optional(),profileHint:A.optional(),sdp:u().optional()}),cbe=b({key:u(),value:C()}),Bj=b({source:u(),data:h(u(),C())}),Vj={name:`device-ops`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getStreamSources:E(b({deviceId:r()}),S(sbe)),getConfigEntries:E(b({deviceId:r()}),S(cbe)),setConfig:E(b({deviceId:r(),values:h(u(),C())}),_(),{kind:`mutation`,auth:`admin`}),runAction:E(b({deviceId:r(),action:u().min(1),input:C()}),C(),{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:E(b({deviceId:r()}),_(),{kind:`mutation`,auth:`admin`}),getSettingsSchema:E(b({deviceId:r()}),C().nullable()),getRawState:E(b({deviceId:r()}),Bj.nullable(),{auth:`protected`})},vocabulary:{noun:I(`Device operations`,`Operazioni del dispositivo`),order:3110}},Hj=b({deviceId:r().int().positive(),deletedAt:r(),providerAddonId:u()}),Uj=b({counts:h(u(),r().int().nonnegative())}),Wj=b({store:u(),deviceId:r().int().positive(),count:r().int().nonnegative()}),Gj={name:`device-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onDeviceRemoved:E(Hj,Uj,{kind:`mutation`,auth:`admin`}),listDeviceData:E(_(),S(Wj).readonly(),{auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},Kj=x([`appliance`,`mower`,`vacuum`]),qj=x([`open`,`closed`]),Jj=x([`completed`,`aborted`,`error`,`unknown`]),Yj=x([`running-state`,`activity`,`reconcile`]),Xj=x([`counter-delta`,`history-integral`]),Zj=b({phase:u(),at:r()}),Qj=b({kind:m(`appliance`),energyKwh:r().nullable().meta(k(`energy`)),energyMethod:Xj.nullable(),peakW:r().nullable().meta(k(`power`)),avgW:r().nullable().meta(k(`power`)),program:u().nullable(),remainingAtStartSec:r().nullable().meta(k(`duration`)),finalPhase:u().nullable(),energyStartKwh:r().nullable().meta(k(`energy`)),powerObservedMs:r()}),$j=a(`kind`,[Qj]),eM=b({runId:u(),deviceId:r().int(),kind:Kj,state:qj,startedAt:r(),endedAt:r().nullable(),durationMs:r().nullable(),outcome:Jj.nullable(),startSource:Yj,endSource:Yj.nullable(),runningSource:x([`native`,`assigned`]).nullable(),phases:S(Zj),detail:$j}),tM={name:`device-runs`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Washer,j.Dryer,j.Dishwasher],methods:{listRuns:E(b({deviceId:r().int(),outcome:Jj.optional(),atFrom:r().optional(),atTo:r().optional(),limit:r().int().positive().max(200).default(50),cursor:u().optional()}),b({runs:S(eM).readonly(),nextCursor:u().nullable()})),getRun:E(b({deviceId:r().int(),runId:u()}),eM.nullable()),getCurrentRun:E(b({deviceId:r().int()}),eM.nullable())},events:{onRunOpened:{data:eM,notOperatorFacing:`the durable record of a run that the running-state start flip already announces`},onRunClosed:{data:eM,notOperatorFacing:`the durable record of a run that the running-state finish flip already announces`}},vocabulary:{noun:I(`Runs`,`Esecuzioni`),order:2130}},nM=x([`replace`,`add`]),rM=a(`ok`,[b({ok:m(!0),changed:v()}),b({ok:m(!1),code:x([`owned-by-other`,`not-claimed`,`field-not-claimed`,`invalid-slice`,`unknown-device`,`row-unreadable`,`migration-in-flight`]),message:u()})]),iM=b({deviceId:r(),capName:u(),owner:u().min(1),mode:nM,fields:S(u().min(1)).min(1)}),aM=a(`state`,[b({state:m(`loaded`),claims:S(iM)}),b({state:m(`not-loaded`),reason:u()})]),oM={name:`device-state`,scope:`system`,mode:`singleton`,methods:{getSnapshot:E(b({deviceId:r()}),h(u(),h(u(),C()))),getCapSlice:E(b({deviceId:r(),capName:u(),confirmed:v().optional()}),h(u(),C()).nullable()),getAllSnapshots:E(b({confirmed:v().optional()}),h(u(),h(u(),h(u(),C())))),setCapSlice:E(b({deviceId:r(),capName:u(),slice:h(u(),C())}),_(),{kind:`mutation`}),claimFields:E(b({deviceId:r(),capName:u(),owner:u().min(1),mode:nM,fields:S(u().min(1)).min(1),values:h(u(),C())}),rM,{kind:`mutation`,auth:`admin`}),patchOwnedFields:E(b({deviceId:r(),capName:u(),owner:u().min(1),values:h(u(),C())}),rM,{kind:`mutation`,auth:`admin`}),releaseClaim:E(b({deviceId:r(),capName:u(),owner:u().min(1)}),rM,{kind:`mutation`,auth:`admin`}),listClaims:E(b({ownerPrefix:u().optional()}),aM,{auth:`admin`}),getNativeCapSlice:E(b({deviceId:r(),capName:u()}),h(u(),C()).nullable(),{auth:`admin`})},events:{onChanged:ui(b({deviceId:r(),capName:u(),slice:h(u(),C())}))},vocabulary:{notOperatorFacing:`the runtime-state mirror every trigger already reads through`}},sM=x([`schedule`,`command`,`burst`]),cM=x([`none`,`partial`,`full`]),lM=1e3,lbe=b({integrationId:u().min(1),minIntervalMs:r().int().min(lM),intervalMs:r().int().positive().optional(),batch:v(),push:cM,heartbeatMs:r().int().positive().optional(),connectionEpoch:r().int().nonnegative().optional()});function ube(e){let t=e.intervalMs??0;return Math.max(e.minIntervalMs,t)}var uM=[3e3,1e4],dM=1e4,fM=2e3;function dbe(e){let t=uM.filter(t=>t<e),n=e-fM,r=(t[t.length-1]??0)+dM;for(;r<n;)t.push(r),r+=dM;let i=t[t.length-1];return(i===void 0?n>0:n-i>=1e3)&&t.push(n),t}var fbe=2500,pM=b({deviceId:r().int().nonnegative(),deviceIds:S(r().int().nonnegative()).min(1),reason:sM}),mM=b({deviceId:r().int().nonnegative()}),hM=b({ok:m(!0)}),gM=`the core schedules state refreshes itself; an operator never asks for one`,_M={name:`device-state-refresh`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{refresh:E(pM,hM,{kind:`mutation`,auth:`admin`,notOperatorFacing:gM}),resubscribe:E(mM,hM,{kind:`mutation`,auth:`admin`,notOperatorFacing:gM})},vocabulary:{noun:I(`State refresh`,`Aggiornamento dello stato`),order:3247}},vM=b({online:v(),lastChangedAt:r()}),yM={name:`device-status`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onStatusChanged:{data:b({deviceId:r(),status:vM}),notOperatorFacing:"the `online` state trigger phrases both edges of this change"}},status:{schema:vM,kind:`push`},runtimeState:vM,durability:`restored`,history:{fields:{online:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Reachability`,`Raggiungibilità`),order:5260,state:[{kind:`boolean`,field:`online`,label:I(`Online`,`Online`),whenTrue:I(`When {device} comes back online`,`Quando {device} torna online`),whenFalse:I(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi`}],extraEvents:[{category:w.DeviceOnline,label:I(`Came online`,`Tornato online`),phrase:I(`When {device} comes back online`,`Quando {device} torna online`),icon:`wifi`},{category:w.DeviceOffline,label:I(`Went offline`,`Andato offline`),phrase:I(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi-off`}]}},bM=x([`not-kernel`,`invalid`]),xM=b({written:r().int().nonnegative(),refused:S(b({id:u(),reason:bM})).readonly()}),SM=b({rows:r().int().nullable(),lastWriteAt:r().nullable(),refused:h(u(),r())}),CM={name:`device-transitions`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Object.values(j).filter(e=>e!==j.Container),methods:{listTransitions:E(b({deviceId:r().int(),capName:u().optional(),actorKind:Do.optional(),outcome:Oo.optional(),atFrom:r().optional(),atTo:r().optional(),limit:r().int().positive().max(200).default(50),cursor:u().optional()}),b({transitions:S(ko).readonly(),nextCursor:u().nullable()})),getTransition:E(b({deviceId:r().int(),id:u()}),ko.nullable()),listRecentTransitions:li(b({actorKind:Do.optional(),outcome:Oo.optional(),atFrom:r().optional(),atTo:r().optional(),limit:r().int().positive().max(200).default(50),cursor:u().optional()}),b({transitions:S(ko).readonly(),nextCursor:u().nullable()}),{auth:`admin`}),record:li(b({transitions:S(ko).max(500)}),xM,{kind:`mutation`,auth:`admin`}),getStatus:li(b({}),SM,{auth:`admin`})},vocabulary:{noun:I(`Transitions`,`Transizioni`),order:2140}},wM=x([`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]),TM=x([`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]),EM=x([`available`,`offline`,`description-missing`]),DM=b({availability:EM,state:wM,operationState:TM.nullable(),program:u().nullable(),selectedProgram:u().nullable(),availablePrograms:S(u()),remaining:r().int().nonnegative().nullable().meta(k(`duration`)),delayedStart:r().int().nonnegative().nullable().meta(k(`duration`)),progress:r().min(0).max(100).nullable().meta(k(`percentage`)),doorOpen:v().nullable(),doorLocked:v().nullable(),remoteStartAllowed:v().nullable(),remoteControlActive:v().nullable(),localControlActive:v().nullable(),powerOn:v().nullable(),powerState:u().nullable(),filterCleaningDue:v().nullable(),machineCareDue:v().nullable(),machineCareRemainingRuns:r().int().nonnegative().nullable().meta(k(`count`)),halfLoad:v().nullable(),hygienePlus:v().nullable(),extraDry:v().nullable(),intensiveZone:v().nullable(),varioSpeedPlus:v().nullable(),childLock:v().nullable(),activeEvents:S(u()),errorCode:r().nullable().meta(k(`none`)),errorLabel:u().nullable(),lastFetchedAt:r()}),OM=r().int().nonnegative(),kM=g([v(),u(),r()]),AM=x([`none`,`read`,`readWrite`,`writeOnly`,`readStatic`]),jM=b({key:u(),name:u(),type:x([`boolean`,`number`,`enum`,`string`]),access:AM,available:v(),unit:u().nullable(),min:r().nullable(),max:r().nullable(),step:r().nullable(),enumValues:S(u()).nullable(),defaultValue:kM.nullable()}),MM=b({key:u(),name:u(),available:v(),options:S(jM)}),NM=b({availability:EM,supportsStart:v(),supportsPause:v(),supportsResume:v(),supportsStop:v(),supportsPower:v(),programs:S(MM),options:S(jM)}),PM={name:`dishwasher`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Dishwasher],methods:{start:E(b({deviceId:OM,program:u().min(1).optional(),options:h(u(),kM).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.start`,label:I(`Start cycle`,`Avvia il lavaggio`),phrase:I(`Start {device}`,`Avvia {device}`),icon:`play`,openArgs:[{key:`program`,label:I(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`},optional:!0}]}]}),pause:E(b({deviceId:OM}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.pause`,label:I(`Pause`,`Metti in pausa`),phrase:I(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),resume:E(b({deviceId:OM}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.resume`,label:I(`Resume`,`Riprendi`),phrase:I(`Resume {device}`,`Riprendi il lavaggio di {device}`),icon:`play`}]}),stop:E(b({deviceId:OM}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.stop`,label:I(`Stop`,`Ferma`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setProgram:E(b({deviceId:OM,program:u().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.program`,label:I(`Choose programme`,`Scegli il programma`),phrase:I(`Select the {program} programme on {device}`,`Seleziona il programma {program} su {device}`),icon:`list`,openArgs:[{key:`program`,label:I(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`}}]}]}),setPower:E(b({deviceId:OM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.powerOn`,label:I(`Power on`,`Accendi`),phrase:I(`Turn on {device}`,`Accendi {device}`),icon:`power`,args:{on:!0}},{id:`dishwasher.powerOff`,label:I(`Power off`,`Spegni`),phrase:I(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,args:{on:!1}}]}),setHalfLoad:E(b({deviceId:OM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.halfLoadOn`,label:I(`Half load on`,`Mezzo carico attivo`),phrase:I(`Turn on half load on {device}`,`Attiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!0}},{id:`dishwasher.halfLoadOff`,label:I(`Half load off`,`Mezzo carico spento`),phrase:I(`Turn off half load on {device}`,`Disattiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!1}}]}),setHygienePlus:E(b({deviceId:OM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.hygienePlusOn`,label:I(`Hygiene Plus on`,`Igiene Plus attiva`),phrase:I(`Turn on Hygiene Plus on {device}`,`Attiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!0}},{id:`dishwasher.hygienePlusOff`,label:I(`Hygiene Plus off`,`Igiene Plus spenta`),phrase:I(`Turn off Hygiene Plus on {device}`,`Disattiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!1}}]}),setExtraDry:E(b({deviceId:OM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.extraDryOn`,label:I(`Extra dry on`,`Asciugatura extra attiva`),phrase:I(`Turn on extra dry on {device}`,`Attiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!0}},{id:`dishwasher.extraDryOff`,label:I(`Extra dry off`,`Asciugatura extra spenta`),phrase:I(`Turn off extra dry on {device}`,`Disattiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!1}}]}),setIntensiveZone:E(b({deviceId:OM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.intensiveZoneOn`,label:I(`Intensive zone on`,`Zona intensiva attiva`),phrase:I(`Turn on the intensive zone on {device}`,`Attiva la zona intensiva su {device}`),icon:`flame`,args:{on:!0}},{id:`dishwasher.intensiveZoneOff`,label:I(`Intensive zone off`,`Zona intensiva spenta`),phrase:I(`Turn off the intensive zone on {device}`,`Disattiva la zona intensiva su {device}`),icon:`flame`,args:{on:!1}}]}),setVarioSpeedPlus:E(b({deviceId:OM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.varioSpeedOn`,label:I(`Speed boost on`,`Lavaggio rapido attivo`),phrase:I(`Turn on the speed boost on {device}`,`Attiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!0}},{id:`dishwasher.varioSpeedOff`,label:I(`Speed boost off`,`Lavaggio rapido spento`),phrase:I(`Turn off the speed boost on {device}`,`Disattiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!1}}]}),setChildLock:E(b({deviceId:OM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.childLockOn`,label:I(`Child lock on`,`Blocco bambini attivo`),phrase:I(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`dishwasher.childLockOff`,label:I(`Child lock off`,`Blocco bambini spento`),phrase:I(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setOption:E(b({deviceId:OM,key:u().min(1),value:kM}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw appliance option key/value; every option worth naming has its own action above`}),getOptions:E(b({deviceId:OM}),NM,{auth:`protected`})},status:{schema:DM,kind:`poll`},runtimeState:DM,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:I(`Dishwasher`,`Lavastoviglie`),order:2020,state:[{kind:`enum`,field:`state`,label:I(`Cycle`,`Ciclo`),values:[{value:`idle`,label:I(`Idle`,`Inattiva`)},{value:`running`,label:I(`Running`,`In funzione`),phrase:I(`When {device} starts a cycle`,`Quando {device} inizia un lavaggio`)},{value:`paused`,label:I(`Paused`,`In pausa`)},{value:`finished`,label:I(`Finished`,`Terminato`),phrase:I(`When {device} finishes`,`Quando {device} finisce il lavaggio`)},{value:`error`,label:I(`Error`,`Errore`),phrase:I(`When {device} reports an error`,`Quando {device} segnala un errore`)},{value:`unavailable`,label:I(`Unavailable`,`Non disponibile`)}],icon:`washing-machine`},{kind:`numeric`,field:`progress`,quantity:I(`the cycle progress`,`l’avanzamento del lavaggio`),label:I(`Progress`,`Avanzamento`),unit:`%`,icon:`loader`},{kind:`boolean`,field:`doorOpen`,label:I(`Door open`,`Sportello aperto`),whenTrue:I(`When the door of {device} opens`,`Quando si apre lo sportello di {device}`),whenFalse:I(`When the door of {device} closes`,`Quando si chiude lo sportello di {device}`),icon:`door-open`},{kind:`boolean`,field:`filterCleaningDue`,label:I(`Filter cleaning due`,`Pulizia filtro da fare`),whenTrue:I(`When {device} asks for its filter to be cleaned`,`Quando {device} chiede di pulire il filtro`),whenFalse:I(`When the filter reminder of {device} clears`,`Quando l’avviso filtro di {device} rientra`),icon:`funnel`},{kind:`boolean`,field:`machineCareDue`,label:I(`Machine care due`,`Manutenzione da fare`),whenTrue:I(`When {device} asks for a machine-care cycle`,`Quando {device} chiede un ciclo di manutenzione`),whenFalse:I(`When the machine-care reminder of {device} clears`,`Quando l’avviso di manutenzione di {device} rientra`),icon:`wrench`}]}},FM=`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(`.`),IM=`audio`,LM=[.3,.42,.55,.7,.85,1],RM=[`camstack`,`high-contrast`,`okabe-ito`];function pbe(e){return FM.includes(e)}function mbe(e){return RM.includes(e)}var zM={dark:`#0c0a09`,light:`#fafaf9`},hbe=[`live`,`heatmapScrub`],BM=/^#[0-9a-fA-F]{6}$/;function VM(e,t){return Number.parseInt(e.slice(t,t+2),16)}function HM(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function UM(e){let t=HM(VM(e,1)),n=HM(VM(e,3)),r=HM(VM(e,5));return .2126*t+.7152*n+.0722*r}function gbe(e,t){if(!BM.test(e)||!BM.test(t))return 0;let n=Math.max(UM(e),UM(t)),r=Math.min(UM(e),UM(t));return(n+.05)/(r+.05)}function WM(e){let t=HM(VM(e,1)),n=HM(VM(e,3)),r=HM(VM(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 GM(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 _be(e,t){if(!BM.test(e)||!BM.test(t))return 0;let n=WM(e),r=WM(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=GM(o,n.b),d=GM(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 ee=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),te=30*Math.exp(-(((g-275)/25)**2)),ne=h**7,_=2*Math.sqrt(ne/(ne+25**7)),re=1+.015*(m-50)**2/Math.sqrt(20+(m-50)**2),v=1+.045*h,ie=1+.015*h*ee,ae=-Math.sin(2*te*Math.PI/180)*_,oe=r.L-n.L,se=l-c;return Math.sqrt((oe/re)**2+(se/v)**2+(p/ie)**2+se/v*ae*(p/ie))}var vbe={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`},ybe=[`#b34dc7`,`#1d7d34`,`#db6b6c`,`#a43d29`,`#0e6ee6`,`#29a10b`,`#a98731`,`#0181c6`],bbe={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`},xbe=[`#817f3b`,`#a0733e`,`#8658b2`,`#956301`,`#bc652d`,`#647331`,`#a14c9e`,`#d14e71`],Sbe={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`},Cbe=[`#9a3784`,`#a7392c`,`#409d50`,`#6987e7`,`#ee5b3d`,`#c0430d`,`#af79b3`,`#4b6628`],KM=u().regex(/^#[0-9a-f]{6}$/),qM=a(`form`,[b({form:m(`solid`),hex:KM}),b({form:m(`gradient`),hex:KM,alphas:S(r().gt(0).lte(1)).length(LM.length)})]),JM=b({status:m(`ready`),presetId:x(RM),customized:v(),source:x([`stored`,`unconfigured`]),swatches:h(u(),qM),fallbacks:S(KM).length(8)}),YM=a(`status`,[JM,b({status:m(`unknown`),reason:u()})]),XM=g([b({presetId:u()}),b({presetId:u(),overrides:h(u(),qM)})]),ZM=b({presetId:u(),overrides:h(u(),qM)});function wbe(e){return{form:`solid`,hex:e}}function Tbe(e){return{form:`gradient`,hex:e,alphas:[...LM]}}function Ebe(e){let t={};for(let n of FM){let r=e[n];if(r===void 0)throw Error(`palette table missing ${n}`);t[n]=n===`audio`?Tbe(r):wbe(r)}return t}function QM(e,t,n,r){return{id:e,name:t,swatches:Ebe(n),fallbacks:r}}var $M=[QM(`camstack`,`CamStack`,vbe,ybe),QM(`high-contrast`,`High contrast`,bbe,xbe),QM(`okabe-ito`,`Colour-blind safe`,Sbe,Cbe)];function eN(e){return $M.find(t=>t.id===e)}function tN(){let e=eN(`camstack`);if(e===void 0)throw Error(`CamStack preset missing`);return Dbe(e,`unconfigured`,!1)}function Dbe(e,t,n){return{status:`ready`,presetId:e.id,customized:n,source:t,swatches:e.swatches,fallbacks:[...e.fallbacks]}}function Obe(e){return e.hex}function kbe(e,t){let n=[];for(let t of FM){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 Abe(e){let t=e[IM];return t===void 0||t.form===`gradient`&&LM.every((e,n)=>t.alphas[n]===e)?[]:[{code:`bad-gradient`,entry:IM}]}function jbe(e,t){let n=hbe;return n.includes(e)&&n.includes(t)}function nN(e,t){let n=[];for(let t of FM)e[t]===void 0&&n.push({code:`missing-entry`,entry:t});for(let t of Object.keys(e))pbe(t)||n.push({code:`unknown-entry`,entry:t});t.length!==8&&n.push({code:`bad-fallbacks`}),n.push(...Abe(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=_be(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=gbe(e.hex,zM[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 Mbe(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 rN(e){return e.map(Mbe).join(`; `)}var iN=class extends Error{violations;constructor(e){super(rN(e)),this.name=`PaletteRejectedError`,this.violations=e}};function aN(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 oN(e,t,n){let r=n.trim().toLowerCase();if(r.startsWith(`audio-`)){let n=e[IM];return n===void 0?aN(r,t):n.hex}let i=e[r];return i===void 0?aN(r,t):i.hex}function sN(e,t){return{...e,...t}}function Nbe(e){return`overrides`in e?e.overrides:{}}function Pbe(e){let t=eN(e.presetId);if(t===void 0||!mbe(e.presetId))throw new iN([{code:`unknown-preset`,presetId:e.presetId}]);let n=Nbe(e),r=sN(t.swatches,n),i=nN(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 Fbe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function Ibe(e){if(e==null||Fbe(e))return tN();let t=ZM.safeParse(e);if(!t.success)return{status:`unknown`,reason:`stored palette is unreadable`};let n=eN(t.data.presetId);if(n===void 0)return{status:`unknown`,reason:`unknown preset ${t.data.presetId}`};let r=sN(n.swatches,t.data.overrides),i=nN(r,n.fallbacks);if(!i.ok)return{status:`unknown`,reason:rN(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 Lbe(e,t){return{presetId:e.presetId,overrides:{...t}}}var Rbe=b({id:u(),name:u(),swatches:h(u(),qM),fallbacks:S(u())}),cN={name:`display-palette`,scope:`system`,mode:`singleton`,methods:{getPalette:E(_(),YM,{auth:`protected`,role:`viewer`}),listPresets:E(_(),S(Rbe).readonly(),{auth:`protected`,role:`viewer`}),setPalette:E(XM,JM,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the cluster display palette — one colour table for every client, not a device action`}},lN=b({enabled:v().nullable().meta({label:`Do not disturb`}),lastChangedAt:r()}),uN={name:`do-not-disturb`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.MediaPlayer],methods:{setEnabled:E(b({deviceId:r().int(),enabled:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dnd.on`,label:I(`Do not disturb on`,`Attiva Non disturbare`),phrase:I(`Turn on Do not disturb on {device}`,`Attiva Non disturbare su {device}`),icon:`bell-off`,args:{enabled:!0}},{id:`dnd.off`,label:I(`Do not disturb off`,`Disattiva Non disturbare`),phrase:I(`Turn off Do not disturb on {device}`,`Disattiva Non disturbare su {device}`),icon:`bell`,args:{enabled:!1}}]})},status:{schema:lN,kind:`push`},runtimeState:lN,durability:`session`,history:{fields:{enabled:{kind:`boolean`}}},vocabulary:{noun:I(`Do not disturb`,`Non disturbare`),order:2160,state:[{kind:`boolean`,field:`enabled`,label:I(`Do not disturb`,`Non disturbare`),whenTrue:I(`When Do not disturb turns on on {device}`,`Quando {device} attiva Non disturbare`),whenFalse:I(`When Do not disturb turns off on {device}`,`Quando {device} disattiva Non disturbare`),icon:`bell-off`}]}},dN=2e3,zbe={version:1,targets:[{id:`pressed`,cardinality:`event`,shape:`pulse`,vocabulary:{cap:`doorbell`,eventName:`onPressed`},deviceTypes:[j.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:dN,changedAtRequired:!0},sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},fN=b({lastPressedAt:r().nullable(),pressCountSinceStart:r().meta(k(`count`))}),pN=b({deviceId:r(),timestamp:r()}),mN={name:`doorbell`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Button,j.Camera],methods:{},events:{onPressed:{data:pN,fromState:{field:`lastPressedAt`,on:`advance`},trigger:{category:w.DoorbellOnPressed,label:I(`Rang`,`Ha suonato`),phrase:I(`When someone rings {device}`,`Quando qualcuno suona a {device}`),icon:`bell-ring`}}},status:{schema:fN,kind:`push`},runtimeState:fN,durability:`restored`,history:`none`,customize:zbe,vocabulary:{noun:I(`Doorbell`,`Campanello`),order:5270}},hN=b({embedding:S(r()),inferenceMs:r()}),gN=x([`image`,`text`]),_N=b({modelId:u(),tower:gN,nodeId:u(),crashes:r(),windowMs:r(),sinceMs:r(),lastReason:u()}),vN=b({modelId:u(),tower:gN,nodeId:u(),attempts:r(),sinceMs:r(),lastReason:u()}),yN=b({modelId:u(),embeddingDim:r(),ready:v(),nodeId:u().optional(),failedModels:S(_N).optional(),failedRequirements:S(vN).optional()}),bN=`embedding-model-failed`,xN=`embedding-requirements-unavailable`,SN=`embedding-requirements-failed`,CN=x([bN,xN,SN]);function wN(e,t){return`[${e} model=${t.modelId} tower=${t.tower} node=${t.nodeId}]`}function Bbe(e){return Error(`${wN(bN,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 Vbe(e,t){return Error(`${wN(xN,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: ${t}`)}function Hbe(e){return Error(`${wN(SN,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 Ube=RegExp(`\\[(${bN}|${xN}|${SN}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);function TN(e){let t=e instanceof Error?e.message:String(e),n=Ube.exec(t);if(n===null)return null;let r=CN.safeParse(n[1]),i=gN.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 Wbe(e){return EN(e)!==null}function EN(e){let t=TN(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 DN={name:`embedding-encoder`,scope:`system`,mode:`collection`,internal:!0,methods:{encode:E(b({crop:y(Uint8Array),width:r(),height:r()}),hN,{auth:`admin`}),encodeText:E(b({text:u(),modelId:u().min(1).optional()}),hN,{auth:`admin`}),getInfo:E(_(),yN,{auth:`admin`}),resetFailedModels:E(b({modelId:u().min(1).optional()}),b({cleared:S(u()),nodeId:u()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.ML}},ON=b({powerW:r().nullable().meta(k(`power`)),energyKwh:r().nullable().meta(k(`energy`)),todayKwh:r().nullable().meta(k(`energy`))}),kN=b({powerW:r().nullable().meta(k(`power`)),importKwh:r().nullable().meta(k(`energy`)),exportKwh:r().nullable().meta(k(`energy`)),importTodayKwh:r().nullable().meta(k(`energy`)),exportTodayKwh:r().nullable().meta(k(`energy`))}),AN=b({powerW:r().nullable().meta(k(`power`)),energyKwh:r().nullable().meta(k(`energy`)),todayKwh:r().nullable().meta(k(`energy`))}),jN=b({stateOfChargePct:r().nullable().meta(k(`percentage`)),storedKwh:r().nullable().meta(k(`energy`)),capacityKwh:r().nullable().meta(k(`energy`)),powerW:r().nullable().meta(k(`power`)),chargedKwh:r().nullable().meta(k(`energy`)),dischargedKwh:r().nullable().meta(k(`energy`)),chargedTodayKwh:r().nullable().meta(k(`energy`)),dischargedTodayKwh:r().nullable().meta(k(`energy`)),healthPct:r().nullable().meta(k(`percentage`))}),MN=b({solar:ON.nullable(),grid:kN.nullable(),house:AN.nullable(),heatPump:AN.nullable(),storage:jN.nullable(),lastFetchedAt:r()});function NN(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 PN={name:`energy-system`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.EnergySystem],methods:{},status:{schema:MN,kind:`push`},runtimeState:MN,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.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:I(`Energy system`,`Sistema energetico`),order:4020}},Gbe=x([`date`,`time`,`datetime`]),FN=b({value:u(),timestamp:v().optional(),lastFetchedAt:r()}),IN={name:`enum-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:FN,kind:`push`},runtimeState:FN,durability:`restored`,history:{fields:{value:{kind:`enum`,skipWhenSet:`timestamp`}}},volatileStateFields:[`lastFetchedAt`,`timestamp`],vocabulary:{noun:I(`State sensor`,`Sensore di stato`),order:5060,state:[{kind:`value`,field:`value`,label:I(`State`,`Stato`),icon:`list`}]}},LN=x([`warning`,`error`]),RN=b({code:u(),label:u(),severity:LN}),zN=b({active:v().nullable(),code:u().nullable(),label:u().nullable(),severity:LN,since:r().nullable(),faults:S(RN).optional(),lastFetchedAt:r()}),BN={active:null,code:null,label:null,severity:`error`,since:null,lastFetchedAt:0},VN={name:`error`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},status:{schema:zN,kind:`push`,empty:BN},runtimeState:zN,durability:`restored`,volatileStateFields:[`lastFetchedAt`],history:`none`,vocabulary:{noun:I(`Fault`,`Guasto`),order:5265,state:[{kind:`boolean`,field:`active`,label:I(`Fault`,`Guasto`),whenTrue:I(`When {device} reports a fault`,`Quando {device} segnala un guasto`),whenFalse:I(`When the fault of {device} clears`,`Quando il guasto di {device} si risolve`),icon:`triangle-alert`}]}},HN=b({id:u(),name:u(),sampleCount:r().int().nonnegative(),coverMediaId:r().int().optional(),coverBase64:u().optional()}),Kbe=b({id:u(),source:x([`detected`,`photo`]),addedAt:r().int(),deviceId:r().int().optional(),base64:u().optional(),mediaId:r().int().optional(),keyFrameMediaId:r().int().optional(),faceBbox:ny.optional()}),qbe=b({sampleId:u(),enrolledAt:r().int(),deviceId:r().int().optional(),source:x([`detected`,`photo`]),mediaId:r().int().optional(),comparable:v(),selfMean:r().nullable(),bestForeign:b({identityId:u(),name:u(),score:r()}).optional(),suspicion:r()}),Jbe=b({identityId:u(),name:u(),modelId:u(),totalSamples:r().int(),comparableSamples:r().int(),flagged:r().int(),flagThreshold:r(),rows:S(qbe).readonly()}),UN=b({faceId:u(),deviceId:r().int(),trackId:u(),timestamp:r().int(),recognizedIdentityId:u().optional(),identityName:u().optional(),assigned:v(),base64:u().optional(),cropUrl:u().optional(),faceBbox:ny.optional(),keyFrameMediaId:r().int().optional(),bestMatchScore:r().optional(),nativeFaceShortSidePx:r().optional(),suggestedIdentityId:u().optional(),suggestedMatchScore:r().optional()}),Ybe=x([`unassigned`,`recognized`,`identified`,`all`]),Xbe=x([`timestamp`,`suggestionConfidence`]),Zbe=x([`asc`,`desc`]),Qbe=b({faceIds:S(u()).readonly(),representativeFaceId:u(),size:r().int(),cohesion:r()}),$be=b({mediaId:r().int(),kind:u(),url:u(),sizeBytes:r(),timestamp:r()}),WN={name:`face-gallery`,role:{feature:`face-assignment`},scope:`system`,mode:`singleton`,methods:{listIdentities:E(b({includeCrops:v().optional()}).optional(),S(HN).readonly(),{role:`viewer`}),createIdentity:E(b({name:u().min(1)}),HN,{kind:`mutation`,auth:`admin`}),renameIdentity:E(b({id:u(),name:u().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deleteIdentity:E(b({id:u()}),_(),{kind:`mutation`,auth:`admin`}),listIdentitySamples:E(b({identityId:u()}),S(Kbe).readonly()),auditIdentitySamples:E(b({identityId:u().min(1)}),Jbe,{auth:`admin`}),removeSample:E(b({identityId:u(),sampleId:u()}),_(),{kind:`mutation`,auth:`admin`}),moveIdentitySample:E(b({sampleId:u().min(1),toIdentityId:u().min(1)}),_(),{kind:`mutation`,auth:`admin`}),listRecentFaces:E(b({deviceId:r().int().optional(),deviceIds:S(r().int()).optional(),limit:r().int().positive().optional(),filter:Ybe.optional(),since:r().int().optional(),until:r().int().optional(),sortBy:Xbe.optional(),sortDirection:Zbe.optional(),includeCrops:v().optional()}).optional(),S(UN).readonly()),getFaceByTrack:E(b({deviceId:r().int(),trackId:u()}),UN.nullable(),{role:`viewer`}),getFaceMedia:E(b({faceId:u()}),S($be).readonly()),assignFace:E(b({faceId:u(),identityId:u()}),_(),{kind:`mutation`,auth:`admin`}),unassignFace:E(b({faceId:u()}),_(),{kind:`mutation`,auth:`admin`}),deleteFace:E(b({faceId:u()}),_(),{kind:`mutation`,auth:`admin`}),assignFaces:E(b({faceIds:S(u()).min(1),identityId:u()}),b({assigned:r().int(),failed:S(u()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignFaces:E(b({faceIds:S(u()).min(1)}),b({unassigned:r().int(),failed:S(u()).readonly()}),{kind:`mutation`,auth:`admin`}),suggestFaceClusters:E(b({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(),S(Qbe).readonly())},vocabulary:{notOperatorFacing:`the face gallery — curated on its own page`}},GN=b({reason:u(),count:r().int().nonnegative()}),KN=b({family:u(),deviceId:r().int().positive(),variant:u().optional(),sinceMs:r(),atMs:r(),attempts:r().int().nonnegative(),succeeded:r().int().nonnegative(),reasons:S(GN).readonly()}),qN={name:`failure-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:E(_(),S(KN).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},JN=x([`forward`,`reverse`]),YN=[`horizontal`,`vertical`],XN=x(YN),ZN=[`oscillating`,`angle`,`sweepFrom`,`sweepTo`],QN=x(ZN),$N=[`min`,`max`,`step`],eP=b({oscillating:v().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)}),tP=b({horizontal:eP.nullable().default(null),vertical:eP.nullable().default(null)}),nP=[`nothing-to-set`,`axis-not-linked`,`out-of-range`,`source-gone`,`source-unknown`,`source-call-failed`],rP=x(nP),iP=a(`status`,[b({status:m(`applied`)}),b({status:m(`refused`),reason:rP,field:QN.optional(),detail:u(),applied:S(QN)})]),aP=b({deviceId:r().int().nonnegative(),axis:XN,oscillating:v().optional(),angle:r().optional(),sweepFrom:r().optional(),sweepTo:r().optional()});function oP(e,t){return`oscillationAxes.${e}.${t}`}var sP=b({speed:r().min(0).max(100).nullable().meta(k(`percentage`)),percentageStep:r().positive().optional().meta(k(`percentage`)),preset:u(),availablePresets:S(u()),direction:JN.nullable(),oscillating:v().nullable(),oscillationAxes:tP.optional(),lastChangedAt:r()});function exe(e){let t=e.oscillationAxes;if(t===void 0)return e.oscillating;let n=YN.flatMap(e=>{let n=t[e]?.oscillating;return n==null?[]:[n]});return n.length===0?e.oscillating:n.some(Boolean)}var cP=[j.Fan],lP=`oscillation-axes`;function txe(e){return{id:`${e}-oscillating`,cardinality:`scalar`,vocabulary:{cap:`fan-control`,stateField:`oscillating`},deviceTypes:cP,apply:`replace`,section:lP,path:oP(e,`oscillating`),sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}function uP(e,t){let n={id:`${e}-${t}`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:cP,apply:`replace`,section:lP,path:oP(e,t),sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}};return t===`angle`?{...n,companions:$N.map(t=>({kind:`source-field`,path:oP(e,t),field:t}))}:n}var nxe=YN.flatMap(e=>[txe(e),uP(e,`angle`),uP(e,`sweepFrom`),uP(e,`sweepTo`)]),rxe={id:`preset`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:cP,apply:`replace`,path:`preset`,sources:[{kind:`field`,valueKinds:[`string`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}},dP=[...nxe,rxe],ixe={version:1,overridable:dP.map(e=>({path:e.path,by:e.id})),targets:dP},fP={name:`fan-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Fan],methods:{setPercentage:D(b({deviceId:r().int().nonnegative(),speed:r().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.off`,label:I(`Fan off`,`Ventilatore spento`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`power-off`,effect:{field:`speed`,value:0},args:{speed:0}},{id:`fan.full`,label:I(`Fan full`,`Ventilatore al massimo`),phrase:I(`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:I(`Set speed`,`Imposta la velocità`),phrase:I(`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:I(`Speed`,`Velocità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setPreset:D(b({deviceId:r().int().nonnegative(),preset:u().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.preset`,label:I(`Set preset`,`Imposta il preset`),phrase:I(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setDirection:D(b({deviceId:r().int().nonnegative(),direction:JN}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.forward`,label:I(`Spin forward`,`Rotazione avanti`),phrase:I(`Spin {device} forward`,`Fai girare {device} in avanti`),icon:`refresh-cw`,effect:{field:`direction`,value:`forward`},args:{direction:`forward`}},{id:`fan.reverse`,label:I(`Spin in reverse`,`Rotazione inversa`),phrase:I(`Spin {device} in reverse`,`Fai girare {device} al contrario`),icon:`rotate-ccw`,effect:{field:`direction`,value:`reverse`},args:{direction:`reverse`}}]}),setOscillating:D(b({deviceId:r().int().nonnegative(),oscillating:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.oscillateOn`,label:I(`Oscillate`,`Oscillazione attiva`),phrase:I(`Make {device} oscillate`,`Fai oscillare {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!0},args:{oscillating:!0}},{id:`fan.oscillateOff`,label:I(`Stop oscillating`,`Oscillazione spenta`),phrase:I(`Stop {device} oscillating`,`Ferma l’oscillazione di {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!1},args:{oscillating:!1}}]}),setOscillationAxis:D(aP,iP,{kind:`mutation`,auth:`protected`,actions:[{id:`fan.horizontalOscillateOn`,label:I(`Horizontal oscillation on`,`Oscillazione orizzontale attiva`),phrase:I(`Start the horizontal oscillation of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!0}},{id:`fan.horizontalOscillateOff`,label:I(`Horizontal oscillation off`,`Oscillazione orizzontale spenta`),phrase:I(`Stop the horizontal oscillation of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!1}},{id:`fan.verticalOscillateOn`,label:I(`Vertical oscillation on`,`Oscillazione verticale attiva`),phrase:I(`Start the vertical oscillation of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!0}},{id:`fan.verticalOscillateOff`,label:I(`Vertical oscillation off`,`Oscillazione verticale spenta`),phrase:I(`Stop the vertical oscillation of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!1}}]})},status:{schema:sP,kind:`push`},runtimeState:sP,customize:ixe,durability:`session`,history:{fields:{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}}},vocabulary:{noun:I(`Fan`,`Ventilatore`),order:1080,state:[{kind:`numeric`,field:`speed`,quantity:I(`the speed`,`la velocità`),label:I(`Speed`,`Velocità`),unit:`%`,icon:`fan`},{kind:`boolean`,field:`oscillating`,label:I(`Oscillating`,`Oscillazione`),whenTrue:I(`When {device} starts oscillating`,`Quando {device} inizia a oscillare`),whenFalse:I(`When {device} stops oscillating`,`Quando {device} smette di oscillare`),icon:`move-horizontal`}]}},pP=b({oscillating:v().optional(),angle:r().optional(),sweepFrom:r().optional(),sweepTo:r().optional()}),mP=b({speed:r().min(0).max(100).optional(),preset:u().min(1).optional(),direction:JN.optional(),oscillationAxes:b({horizontal:pP.optional(),vertical:pP.optional()}).optional()}),hP=b({id:u().min(1).max(64),name:u().trim().min(1).max(40),state:mP}),gP=[`empty-state`,`duplicate-name`,`duplicate-id`,`too-many`,`not-a-fan`],_P=x(gP),vP=a(`status`,[b({status:m(`saved`),count:r().int().nonnegative()}),b({status:m(`refused`),reason:_P,detail:u()})]),yP=b({field:u(),outcome:x([`applied`,`failed`,`not-run`,`refused`]),message:u().optional()}),bP=b({status:x([`applied`,`partial`,`refused`]),fields:S(yP)}),xP=[`speed`,`direction`,`preset`,`oscillationAxes`],SP=x(xP),CP=b({what:u(),reason:u()}),wP=b({state:mP,omitted:S(CP)}),TP=b({deviceId:r().int().nonnegative()}),axe={version:1,targets:[{id:`presets`,cardinality:`config`,vocabulary:{cap:`fan-presets`},deviceTypes:[j.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`}]},EP={name:`fan-presets`,scope:`system`,mode:`singleton`,methods:{getPresets:E(TP,S(hP),{auth:`protected`}),setPresets:E(TP.extend({presets:S(hP).max(12)}),vP,{kind:`mutation`,auth:`admin`}),applyPreset:E(TP.extend({presetId:u().min(1)}),bP,{kind:`mutation`,auth:`protected`}),capturePreset:E(TP.extend({fields:S(SP).optional()}),wP,{auth:`protected`})},customize:axe,vocabulary:{notOperatorFacing:`the per-fan presets — authored in the Customize presets editor, applied through the actions the exports list`}},DP=b({flags:h(u(),C()),deviceType:u().nullable(),model:u().nullable(),channelCount:r().nullable().meta(k(`count`)),lastProbedAt:r(),lastFetchedAt:r()}),OP={name:`feature-probe`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onProbeChanged:{data:b({deviceId:r(),status:DP}),notOperatorFacing:`the device’s capabilities were re-probed — plumbing, not a happening`}},status:{schema:DP,kind:`push`},runtimeState:DP,durability:`session`,history:`none`,vocabulary:{noun:I(`Feature probe`,`Rilevamento funzioni`),order:3120}},oxe=b({name:u(),path:u()}),sxe=b({path:u(),entries:S(oxe).readonly(),freeBytes:r(),totalBytes:r()}),kP={name:`filesystem-browse`,scope:`system`,mode:`singleton`,internal:!0,methods:{listAllowedRoots:E(_(),S(u()).readonly(),{auth:`admin`}),browse:E(b({path:u()}),sxe,{auth:`admin`}),createDir:E(b({path:u()}),b({path:u()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},AP=b({flooded:v(),lastChangedAt:r()}),jP={name:`flood`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:AP,kind:`push`},runtimeState:AP,durability:`restored`,history:{fields:{flooded:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Leak sensor`,`Sensore di allagamento`),order:5070,state:[{kind:`boolean`,field:`flooded`,label:I(`Leak`,`Perdita`),whenTrue:I(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:I(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}]}},MP=b({detected:v(),lastChangedAt:r()}),NP={name:`gas`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:MP,kind:`push`},runtimeState:MP,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Gas sensor`,`Sensore di gas`),order:5080,state:[{kind:`boolean`,field:`detected`,label:I(`Detected`,`Rilevato`),whenTrue:I(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:I(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}]}},PP=b({active:v().meta({label:`Active`}),lastChangedAt:r()}),FP={name:`group-active`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Cover,j.Valve,j.Lock,j.MediaPlayer,j.Climate],methods:{},status:{schema:PP,kind:`push`},runtimeState:PP,durability:`session`,history:`none`,vocabulary:{noun:I(`Group state`,`Stato del gruppo`),order:5090}},IP=b({deviceId:r().int().nonnegative(),cap:u().min(1),method:u().min(1),ok:v(),error:u().optional(),at:r()}),LP=b({results:S(IP)}),RP={name:`group-commands`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Switch,j.Light,j.Fan,j.Cover,j.Valve,j.Lock,j.MediaPlayer,j.Climate],methods:{},status:{schema:LP,kind:`push`},runtimeState:LP,durability:`session`,history:`none`,vocabulary:{noun:I(`Group command`,`Comando di gruppo`),order:5100}},zP=b({included:r().int().nonnegative().meta(k(`count`,{precision:0,label:`Reporting`})),excluded:r().int().nonnegative().meta(k(`count`,{precision:0,label:`Excluded`})),total:r().int().nonnegative().meta(k(`count`,{precision:0,label:`Members`}))}),BP={name:`group-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor,j.Switch,j.Light,j.Fan,j.Cover,j.Valve,j.Lock,j.MediaPlayer,j.Climate],methods:{},status:{schema:zP,kind:`push`},runtimeState:zP,durability:`session`,history:`none`,vocabulary:{noun:I(`Group`,`Gruppo`),order:5110,state:[{kind:`numeric`,field:`included`,quantity:I(`the members reporting`,`i membri che rispondono`),label:I(`Reporting`,`Rispondono`),icon:`users`},{kind:`numeric`,field:`excluded`,quantity:I(`the members left out`,`i membri esclusi`),label:I(`Excluded`,`Esclusi`),icon:`users`},{kind:`numeric`,field:`total`,quantity:I(`the member count`,`il numero di membri`),label:I(`Members`,`Membri`),icon:`sigma`}]}},VP=r().int().nonnegative(),HP=u().min(1),UP=u().min(1),WP=r().finite(),GP={key:`circuitId`,label:I(`Circuit`,`Circuito`),offer:{kind:`dynamic`,from:`status`,cap:`heat-pump-status`,field:`circuits`,valueKey:`id`,labelKey:`label`,where:{key:`kind`,equals:`heating`}}},KP={...GP,label:I(`Hot water circuit`,`Circuito acqua calda`),offer:{...GP.offer,where:{key:`kind`,equals:`dhw`}}},qP={key:`mode`,label:I(`Mode`,`Modalità`),offer:{kind:`text`}},cxe={key:`level`,label:I(`Level`,`Livello`),offer:{kind:`text`}},JP={key:`temp`,label:I(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}},lxe={key:`minutes`,label:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}},YP={name:`heat-pump-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.HeatPump],methods:{setSilentMode:E(b({deviceId:VP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.silent`,label:I(`Set silent mode`,`Imposta la modalità silenziosa`),phrase:I(`Set silent mode of {device} to {mode}`,`Imposta la modalità silenziosa di {device} su {mode}`),icon:`volume-x`,openArgs:[{key:`mode`,label:I(`Silent mode`,`Modalità silenziosa`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`auto`,label:I(`Auto`,`Auto`)},{value:`on`,label:I(`On`,`On`)}]}}]}]}),setAwayMode:E(b({deviceId:VP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.away`,label:I(`Set away mode`,`Imposta la modalità assente`),phrase:I(`Set away mode of {device} to {mode}`,`Imposta la modalità assente di {device} su {mode}`),icon:`plane`,openArgs:[{key:`mode`,label:I(`Away mode`,`Modalità assente`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`on`,label:I(`On`,`On`)}]}}]}]}),setAdditionalHeaterMode:E(b({deviceId:VP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.additionalHeater`,label:I(`Set additional heater`,`Imposta il riscaldatore aggiuntivo`),phrase:I(`Set the additional heater of {device} to {mode}`,`Imposta il riscaldatore aggiuntivo di {device} su {mode}`),icon:`flame`,openArgs:[{key:`mode`,label:I(`Additional heater`,`Riscaldatore aggiuntivo`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`manual`,label:I(`Manual`,`Manuale`)},{value:`auto`,label:I(`Auto`,`Auto`)}]}}]}]}),setHolidayMode:E(b({deviceId:VP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.holiday`,label:I(`Set holiday mode`,`Imposta la modalità vacanza`),phrase:I(`Set holiday mode of {device} to {mode}`,`Imposta la modalità vacanza di {device} su {mode}`),icon:`tree-palm`,openArgs:[{key:`mode`,label:I(`Holiday programme`,`Programma vacanza`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`hm1`,label:I(`Programme 1`,`Programma 1`)},{value:`hm2`,label:I(`Programme 2`,`Programma 2`)},{value:`hm3`,label:I(`Programme 3`,`Programma 3`)},{value:`hm4`,label:I(`Programme 4`,`Programma 4`)},{value:`hm5`,label:I(`Programme 5`,`Programma 5`)},{value:`hm6`,label:I(`Programme 6`,`Programma 6`)},{value:`hm7`,label:I(`Programme 7`,`Programma 7`)},{value:`hm8`,label:I(`Programme 8`,`Programma 8`)}]}}]}]}),setCircuitOperationMode:E(b({deviceId:VP,circuitId:HP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitOperationMode`,label:I(`Set circuit operation mode`,`Imposta la modalità del circuito`),phrase:I(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`thermometer`,openArgs:[GP,qP]}]}),setCircuitHeatCoolMode:E(b({deviceId:VP,circuitId:HP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitHeatCoolMode`,label:I(`Set circuit heat / cool`,`Imposta caldo / freddo del circuito`),phrase:I(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun-snow`,openArgs:[GP,qP]}]}),setCircuitSummerWinter:E(b({deviceId:VP,circuitId:HP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitSummerWinter`,label:I(`Set circuit summer / winter`,`Imposta estate / inverno del circuito`),phrase:I(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun`,openArgs:[GP,qP]}]}),setCircuitComfortSetpoint:E(b({deviceId:VP,circuitId:HP,temp:WP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitComfortSetpoint`,label:I(`Set comfort temperature`,`Imposta la temperatura comfort`),phrase:I(`Set the comfort temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura comfort di {circuitId} su {device} a {temp}`),icon:`thermometer-sun`,openArgs:[GP,JP]}]}),setCircuitEcoSetpoint:E(b({deviceId:VP,circuitId:HP,temp:WP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitEcoSetpoint`,label:I(`Set eco temperature`,`Imposta la temperatura eco`),phrase:I(`Set the eco temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura eco di {circuitId} su {device} a {temp}`),icon:`leaf`,openArgs:[GP,JP]}]}),setCircuitMaxFlowTemp:E(b({deviceId:VP,circuitId:HP,temp:WP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitMaxFlowTemp`,label:I(`Set maximum flow temperature`,`Imposta la temperatura massima di mandata`),phrase:I(`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:[GP,JP]}]}),setDhwOperationMode:E(b({deviceId:VP,circuitId:HP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwOperationMode`,label:I(`Set hot water mode`,`Imposta la modalità acqua calda`),phrase:I(`Set hot water {circuitId} of {device} to {mode}`,`Imposta l'acqua calda {circuitId} di {device} su {mode}`),icon:`shower-head`,openArgs:[KP,qP]}]}),setDhwTemperatureLevel:E(b({deviceId:VP,circuitId:HP,level:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwTemperatureLevel`,label:I(`Set hot water level`,`Imposta il livello acqua calda`),phrase:I(`Set hot water {circuitId} of {device} to level {level}`,`Imposta l'acqua calda {circuitId} di {device} al livello {level}`),icon:`droplet`,openArgs:[KP,cxe]}]}),setDhwChargeDuration:E(b({deviceId:VP,circuitId:HP,minutes:r().int().positive()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwChargeDuration`,label:I(`Set hot water charge duration`,`Imposta la durata della carica acqua calda`),phrase:I(`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:[KP,lxe]}]}),startExtraHotWater:E(b({deviceId:VP,circuitId:HP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.extraHotWater`,label:I(`Start extra hot water`,`Avvia acqua calda extra`),phrase:I(`Start an extra hot water charge of {circuitId} on {device}`,`Avvia una carica extra di acqua calda {circuitId} su {device}`),icon:`droplets`,openArgs:[KP]}]})},vocabulary:{noun:I(`Heat pump settings`,`Impostazioni pompa di calore`),order:4010}},XP=[`heating`,`dhw`,`cooling`,`solar`],ZP=x(XP),QP=b({value:u().nullable(),allowed:S(u())}),$P=b({value:r().nullable(),min:r().nullable(),max:r().nullable(),step:r().nullable()}),eF=b({id:u().min(1),kind:ZP,label:u(),icon:Bu,currentTemp:r().nullable().meta(k(`temperature`)),targetTemp:r().nullable().meta(k(`temperature`)),mode:u().nullable(),active:v().nullable(),operationMode:QP.nullable(),heatCoolMode:QP.nullable(),summerWinter:QP.nullable(),comfortSetpoint:$P.nullable(),ecoSetpoint:$P.nullable(),maxFlowTemp:$P.nullable(),temperatureLevel:QP.nullable(),chargeDuration:$P.nullable(),extraHotWater:v().nullable()}),tF=b({silent:QP.nullable(),away:QP.nullable(),additionalHeater:QP.nullable(),holiday:QP.nullable()}),nF=b({thermalW:r().nullable().meta(k(`power`)),electricalW:r().nullable().meta(k(`power`)),compressorPct:r().nullable().meta(k(`percentage`))}),rF=b({supply:r().nullable().meta(k(`temperature`)),return:r().nullable().meta(k(`temperature`)),outdoor:r().nullable().meta(k(`temperature`))}),iF=b({thermalKwh:r().nullable().meta(k(`energy`)),electricalKwh:r().nullable().meta(k(`energy`))}),aF=b({circuits:S(eF),system:tF,power:nF,temperatures:rF,energy:iF,waterPressureBar:r().nullable(),starts:r().nullable(),lastFetchedAt:r()});function oF(e){let{thermalW:t,electricalW:n}=e;return t===null||n===null||n<=0?null:t/n}var sF={name:`heat-pump-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.HeatPump],methods:{},status:{schema:aF,kind:`push`},runtimeState:aF,durability:`session`,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:I(`Heat pump`,`Pompa di calore`),order:4e3}},cF=b({position:r().min(0).max(100).nullable().meta(k(`percentage`)),lastFetchedAt:r()}),lF={name:`heating-valve`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Climate],methods:{},status:{schema:cF,kind:`push`},runtimeState:cF,durability:`session`,history:{fields:{position:{kind:`gauge`,unit:`%`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Radiator valve`,`Valvola termostatica`),order:1110,state:[{kind:`numeric`,field:`position`,quantity:I(`the valve opening`,`l’apertura della valvola`),label:I(`Valve opening`,`Apertura della valvola`),unit:`%`,icon:`heater`}]}},uF=x([`s`,`min`]),uxe=x([`switch`,`pet-fountain`]),dF={actuator:`switch`,maxSeconds:10800,unit:`min`,quickRunDefault:30},fF={actuator:`pet-fountain`,maxSeconds:300,unit:`s`,quickRunDefault:60},pF=[j.Switch,j.PetFountain],mF={[j.Switch]:[N.SwitchHeater]};function hF(e,t){return e===j.PetFountain?fF:e===j.Switch&&t===N.SwitchHeater?dF:null}var dxe=1e3,fxe=6e4;function gF(e,t,n){let r=e-t;return r<=0?0:Math.max(1,Math.ceil(r/(n===`min`?fxe:dxe)))}function pxe(e,t){return t===`min`?e*60:e}function _F(e){return e.unit===`min`?Math.floor(e.maxSeconds/60):e.maxSeconds}var vF=b({duration:r().positive().finite(),unit:uF});function yF(e,t){let n=_F(e);return{duration:Math.min((t!==null&&Number.isFinite(t)&&t>0?t:null)??e.quickRunDefault,n),unit:e.unit}}var bF=x([`unsupported-device`,`over-max`,`command-failed`]),xF=a(`ok`,[b({ok:m(!0),activeUntil:r()}),b({ok:m(!1),reason:bF,maxSeconds:r().nullable()})]),SF=b({activeUntil:r().nullable(),requestedBy:u().nullable(),quickRun:vF.nullable(),lastFetchedAt:r()}),CF=b({unit:uF,maxDuration:r(),defaultDuration:r()}),wF=b({quickRunDuration:r().positive().finite().nullable().optional()}),TF={name:`timed-run`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:pF,deviceRoles:mF,deviceConfig:{ui:{kind:`derived-form`,builderId:`timed-run`,tab:`general`}},methods:{getOptions:E(b({deviceId:r().int()}),CF),setSettings:E(b({deviceId:r().int(),settings:wF}),_(),{kind:`mutation`,auth:`admin`}),runFor:E(b({deviceId:r().int(),duration:r().positive().finite(),unit:uF}),xF,{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.runForMinutes`,label:I(`Run for minutes`,`Accendi per alcuni minuti`),phrase:I(`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:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}}]},{id:`timedRun.runForSeconds`,label:I(`Run for seconds`,`Accendi per alcuni secondi`),phrase:I(`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:I(`Seconds`,`Secondi`),offer:{kind:`number`,min:1,step:1,unit:`s`}}]}]}),cancel:E(b({deviceId:r().int()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.cancel`,label:I(`Cancel the timer`,`Annulla il timer`),phrase:I(`Cancel the pending switch-off of {device}`,`Annulla lo spegnimento programmato di {device}`),icon:`timer-off`}]})},status:{schema:SF,kind:`push`},runtimeState:SF,durability:`session`,history:`none`,vocabulary:{noun:I(`Timed run`,`Esecuzione a tempo`),order:2150}},EF=[`on`,`off`,`running`,`idle`,`standby`,`alert`,`offline`,`unknown`],DF=[`success`,`warning`,`danger`,`primary`,`info`,`muted`],OF=[`none`,`pulse`,`spin`,`glow`,`halo`,`wave`,`rise`,`fall`,`tumble`,`equalizer`,`blink`,`breathe`],kF=[`plain`,`heat-rise`,`cool-fall`,`glow`,`water`,`drum`,`sky`,`mist`,`alert-wash`],AF=x(EF),jF=x(DF),mxe=x(OF),MF=b({icon:Bu,tone:jF,background:x(kF),animation:mxe});function NF(e){let t=hE[e];return t===void 0?null:`cap:${e}.${t.field}`}function PF(e){return e.enabledCaps.flatMap(e=>{let t=NF(e),n=hE[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 FF=b({en:u(),it:u()}),IF={en:`—`,it:`—`};function LF(e){return e.en===IF.en&&e.it===IF.it}var RF=[`temperature`,`humidity`,`power`,`contact`,`text`],zF=[`hot`,`mild`,`cold`],BF=[`updated`,`changed`],VF=b({value:r(),quantity:Zs}),HF=b({quantity:x(RF),reading:VF.nullable(),icon:Bu.nullable(),value:FF,unit:u().nullable(),band:x(zF).nullable(),level:r().min(0).max(1).nullable(),word:FF,tone:x(DF),since:r().nullable(),sinceKind:x(BF),historyKey:u().nullable()}),hxe=3e3,UF=e=>I(e,e),WF=e=>Math.min(1,Math.max(0,e)),gxe=(e,t)=>String(Number(e.toFixed(t)));function GF(e){return e<12?`cold`:e>28?`hot`:`mild`}var _xe={hot:I(`Hot`,`Caldo`),mild:I(`Normal`,`Normale`),cold:I(`Cold`,`Freddo`)},vxe={hot:`warning`,mild:`muted`,cold:`info`};function KF(e,t){let n=GF(e);return{quantity:`temperature`,reading:{value:e,quantity:`temperature`},icon:`thermometer`,value:UF(gxe(e,1)),unit:`°C`,band:n,level:null,word:_xe[n],tone:vxe[n],since:t,sinceKind:`updated`,historyKey:NF(`temperature-sensor`)}}function qF(e,t){let n=e<30,r=e>70;return{quantity:`humidity`,reading:{value:e,quantity:`humidity`},icon:`droplets`,value:UF(String(Math.round(e))),unit:`%`,band:null,level:WF(e/100),word:n?I(`Dry`,`Secco`):r?I(`Humid`,`Umido`):I(`Normal`,`Normale`),tone:n||r?`warning`:`info`,since:t,sinceKind:`updated`,historyKey:NF(`humidity-sensor`)}}function JF(e,t){let n=e>0;return{quantity:`power`,reading:{value:e,quantity:`power`},icon:`zap`,value:UF(String(Math.round(e))),unit:`W`,band:null,level:WF(e/hxe),word:n?I(`Active`,`Attivo`):I(`Idle`,`Inattivo`),tone:n?`primary`:`muted`,since:t,sinceKind:`updated`,historyKey:NF(`power-meter`)}}function YF(e,t){return{quantity:`contact`,reading:null,icon:e?`door-open`:`door-closed`,value:e?I(`Open`,`Aperto`):I(`Closed`,`Chiuso`),unit:null,band:null,level:+!!e,word:e?I(`Open`,`Aperto`):I(`Closed`,`Chiuso`),tone:e?`warning`:`success`,since:t,sinceKind:`changed`,historyKey:null}}function XF(e,t){return{quantity:`text`,reading:null,icon:null,value:UF(e),unit:null,band:null,level:null,word:I(`Changed`,`Cambiato`),tone:`muted`,since:t,sinceKind:`updated`,historyKey:null}}var yxe={temperature:{icon:`thermometer`,unit:`°C`,sinceKind:`updated`,historyKey:NF(`temperature-sensor`)},humidity:{icon:`droplets`,unit:`%`,sinceKind:`updated`,historyKey:NF(`humidity-sensor`)},power:{icon:`zap`,unit:`W`,sinceKind:`updated`,historyKey:NF(`power-meter`)},contact:{icon:null,unit:null,sinceKind:`changed`,historyKey:null},text:{icon:null,unit:null,sinceKind:`updated`,historyKey:null}};function ZF(e){let t=yxe[e];return{quantity:e,reading:null,icon:t.icon,value:IF,unit:t.unit,band:null,level:null,word:IF,tone:`muted`,since:null,sinceKind:t.sinceKind,historyKey:t.historyKey}}var bxe={power:new Set([`energy-sensor`,`voltage-sensor`,`current-sensor`])};function QF(e,t){return t===null?!0:!(bxe[e.quantity]?.has(t)??!1)}var $F=`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(`.`),xxe=x($F),eI=[`cool`,`heat`,`dry`,`fan`,`auto`,`playing`,`paused`,`open`,`closed`],tI=b({id:xxe,mode:x(eI).nullable(),level:r().min(0).max(1).nullable()}),nI={[j.Camera]:`camera`,[j.Light]:`light`,[j.Siren]:`siren`,[j.Switch]:`plug`,[j.Sensor]:`sensor-sparkline`,[j.Climate]:`thermostat`,[j.Button]:`button`,[j.EventEmitter]:`event-stream`,[j.Update]:`update`,[j.Generic]:`generic`,[j.Notifier]:`event-stream`,[j.Script]:`event-stream`,[j.Automation]:`event-stream`,[j.Lock]:`lock`,[j.Cover]:`cover`,[j.Valve]:`control-dial`,[j.Humidifier]:`control-dial`,[j.WaterHeater]:`heater`,[j.HeatPump]:`heat-pump`,[j.EnergySystem]:`generic`,[j.Workload]:`generic`,[j.Fan]:`fan`,[j.MediaPlayer]:`tv`,[j.AlarmPanel]:`alarm`,[j.Control]:`control-dial`,[j.Presence]:`presence`,[j.Weather]:`weather`,[j.WeatherStation]:`weather`,[j.Vacuum]:`vacuum`,[j.LawnMower]:`lawn-mower`,[j.Container]:`generic`,[j.Image]:`camera`,[j.PetFeeder]:`pet-feeder`,[j.PetFountain]:`pet-fountain`,[j.Dishwasher]:`dishwasher`,[j.Washer]:`washer`,[j.Dryer]:`dryer`,[j.Gateway]:`gateway`},rI={[N.Siren]:`siren`,[N.Floodlight]:`light`,[N.Spotlight]:`light`,[N.PirSensor]:`presence`,[N.Chime]:`speaker`,[N.Autotrack]:`inherit`,[N.Nightvision]:`inherit`,[N.PrivacyMask]:`inherit`,[N.Doorbell]:`inherit`,[N.CoverBlind]:`inherit`,[N.CoverShutter]:`inherit`,[N.CoverAwning]:`inherit`,[N.CoverCurtain]:`inherit`,[N.CoverGarage]:`inherit`,[N.CoverGate]:`inherit`,[N.CoverDoor]:`inherit`,[N.CoverWindow]:`inherit`,[N.BinaryHelper]:`inherit`,[N.Outlet]:`plug`,[N.SwitchHeater]:`heater`,[N.SwitchFan]:`fan`,[N.SwitchLight]:`light`,[N.PoePort]:`plug`,[N.ClimateAc]:`ac`,[N.ClimateThermostat]:`inherit`,[N.ClimateFloor]:`inherit`,[N.ClimateRadiator]:`inherit`,[N.ClimateHeater]:`inherit`,[N.ClimateHeatPumpCircuit]:`inherit`,[N.MotionSensor]:`presence`,[N.ContactSensor]:`contact`,[N.LeakSensor]:`inherit`,[N.SmokeSensor]:`alarm`,[N.COSensor]:`alarm`,[N.GasSensor]:`alarm`,[N.TamperSensor]:`inherit`,[N.VibrationSensor]:`inherit`,[N.ConnectivitySensor]:`inherit`,[N.SoundSensor]:`inherit`,[N.BinarySensor]:`inherit`,[N.TemperatureSensor]:`sensor-sparkline`,[N.HumiditySensor]:`sensor-sparkline`,[N.AmbientLightSensor]:`inherit`,[N.PressureSensor]:`weather`,[N.WindSensor]:`weather`,[N.RainSensor]:`weather`,[N.UvSensor]:`weather`,[N.SolarRadiationSensor]:`weather`,[N.SoilMoistureSensor]:`inherit`,[N.PowerSensor]:`plug`,[N.EnergySensor]:`plug`,[N.VoltageSensor]:`plug`,[N.CurrentSensor]:`plug`,[N.AirQualitySensor]:`inherit`,[N.BatterySensor]:`inherit`,[N.NumericSensor]:`inherit`,[N.EnumSensor]:`inherit`,[N.DateTimeSensor]:`inherit`,[N.GenericSensor]:`inherit`,[N.NumericControl]:`control-dial`,[N.SelectControl]:`control-dial`,[N.TextControl]:`inherit`,[N.DateTimeControl]:`inherit`,[N.MobilePushNotifier]:`inherit`,[N.MessagingNotifier]:`inherit`,[N.EmailNotifier]:`inherit`,[N.GenericNotifier]:`inherit`,[N.IrTransmitter]:`inherit`,[N.Vm]:`inherit`,[N.AppContainer]:`inherit`,[N.Lxc]:`inherit`,[N.App]:`inherit`,[N.Host]:`inherit`,[N.Ups]:`inherit`};function Sxe(e){return Object.values(j).includes(e)}function Cxe(e){return Object.values(N).includes(e)}function iI(e,t){let n=e!==null&&Cxe(e)?rI[e]:void 0;return n!==void 0&&n!==`inherit`?n:Sxe(t)?nI[t]:`generic`}var aI=`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(`.`),oI=x(aI),sI={progress:I(`Progress`,`Avanzamento`),"run-for":I(`Run for`,`Avvia per`),cycle:I(`Cycle`,`Ciclo`),program:I(`Program`,`Programma`),"appliance-power":I(`Appliance`,`Elettrodomestico`),"now-playing":I(`Now playing`,`In riproduzione`),playback:I(`Playback`,`Riproduzione`),volume:I(`Volume`,`Volume`),source:I(`Source`,`Sorgente`),contact:I(`Door`,`Porta`),"motion-trigger":I(`Motion`,`Movimento`),lock:I(`Lock`,`Serratura`),alarm:I(`Alarm`,`Allarme`),fan:I(`Fan`,`Ventola`),vacuum:I(`Cleaning`,`Pulizia`),"vacuum-suction":I(`Suction`,`Aspirazione`),mower:I(`Mowing`,`Taglio`),feeder:I(`Feed now`,`Eroga ora`),fountain:I(`Pump`,`Pompa`),"pump-cycle":I(`Pump cycle`,`Ciclo pompa`),automation:I(`Automation`,`Automazione`),script:I(`Script`,`Script`),"do-not-disturb":I(`Do not disturb`,`Non disturbare`),brightness:I(`Brightness`,`Luminosità`),color:I(`Colour`,`Colore`),cover:I(`Position`,`Posizione`),valve:I(`Valve`,`Valvola`),humidifier:I(`Humidifier`,`Umidificatore`),update:I(`Firmware`,`Firmware`),button:I(`Action`,`Azione`),"climate-mode":I(`Mode`,`Modalità`),"climate-fan":I(`Fan`,`Ventola`),setpoint:I(`Setpoint`,`Temperatura`),channel:I(`Channel`,`Canale`),control:I(`Control`,`Controllo`),circuit:I(`Circuit`,`Circuito`),"heat-pump-power":I(`Power`,`Potenza`),"system-mode":I(`Mode`,`Modalità`)},cI=o(()=>g([u(),r(),v(),h(u(),cI)])),wxe=h(u(),cI);function lI(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]:lI(o,i,n)}}function uI(e,t,n){return lI(e,t.split(`.`),n)}var dI=b({cap:u(),method:u(),args:wxe}),Txe=x([`off-while-running`,`unlock`,`install`,`press`]),fI=b({id:u(),label:FF,icon:Bu,call:dI,emphasis:x([`primary`,`normal`]),confirm:Txe.nullable()}),pI=a(`kind`,[b({kind:m(`action`),action:fI}),b({kind:m(`toggle`),id:u(),label:FF,on:v().nullable(),turnOn:fI,turnOff:fI}),b({kind:m(`slider`),id:u(),label:FF,value:r().nullable(),min:r(),max:r(),step:r(),unit:u(),call:dI,valueArg:u()}),b({kind:m(`picker`),id:u(),label:FF,current:u().nullable(),options:S(u()),optionLabels:h(u(),FF).optional(),call:dI,valueArg:u()}),b({kind:m(`number`),id:u(),label:FF,value:r().nullable(),step:r().nullable(),unit:u(),call:dI,valueArg:u()}),b({kind:m(`text`),id:u(),label:FF,value:u().nullable(),call:dI,valueArg:u()})]),Exe=b({icon:Bu.nullable(),text:FF,tone:jF}),Dxe=new Set([`cover`,`valve`,`lock`,`vacuum`,`playback`,`brightness`]),Oxe=b({id:oI,placement:x([`row`,`scene`]).optional(),label:FF.optional(),group:FF.optional(),pills:S(Exe).optional(),icon:Bu,status:FF.nullable(),controls:S(pI),progress:r().min(0).max(1).nullable().optional()}),mI=b({label:FF,value:g([r(),u()]),unit:u().nullable()}),kxe=b({id:x([`battery`,`network-link`,`integration`]),icon:Bu,tone:jF,value:r().nullable(),label:FF}),hI=`remote.open`,Axe=b({commands:r().int().nullable(),open:fI.optional()}),jxe=b({items:S(b({key:u(),label:u(),level:r().nullable(),needsAttention:v()})),attention:r().int()}),Mxe=a(`kind`,[b({kind:m(`power`),watts:r(),detail:S(mI)}),b({kind:m(`running`),running:v().nullable(),since:r().nullable(),phase:u().nullable(),detail:S(mI)})]),Nxe=b({source:x([`switch`,`media-player`,`climate-control`]),on:v().nullable(),assumed:v(),turnOn:fI,turnOff:fI}),Pxe=b({activeUntil:r().nullable(),quickRun:vF,run:fI,cancel:fI,remaining:r().nullable()}),Fxe=b({on:v().nullable(),confirmOffWhileRunning:v(),running:v().nullable(),powerOn:fI.nullable(),powerOff:fI.nullable(),restart:fI}),gI=b({token:x(kF),animation:x(OF)}),_I=b({id:x([`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:Bu.nullable(),text:FF,tone:jF}),vI=b({label:FF,value:FF,tone:jF.optional(),at:r().optional()}),Ixe=b({left:S(vI).max(2),right:S(vI).max(2)}),Lxe=a(`kind`,[b({kind:m(`artwork`),url:u(),fallback:gI}),b({kind:m(`state`),...gI.shape})]),Rxe=b({partId:u(),cap:u()}),zxe=b({deviceId:r().int(),type:u(),role:u().nullable(),name:u(),state:AF,stateAssumed:v(),look:MF,background:Lxe,scene:tI,facts:S(_I),sideTiles:Ixe,title:FF,caption:FF.optional(),badges:S(kxe),remote:Axe.nullable(),historyLabel:FF,consumables:jxe.nullable(),consumption:Mxe.nullable(),ownPower:Nxe.nullable(),timedRun:Pxe.nullable(),powerSupply:Fxe.nullable(),rows:S(Oxe),measurement:HF.optional(),gated:S(u()),provenance:S(Rxe)}),Bxe=b({id:x([`timed-run.run`,`timed-run.cancel`]),duration:r(),unit:x([`min`,`s`])}),yI=b({deviceId:r().int(),name:u(),type:u(),state:AF,stateAssumed:v(),look:MF,scene:tI,statusLine:S(FF),primary:pI.nullable(),primaryGated:v().optional(),timedRun:Bxe.nullable(),extras:S(pI).max(2).optional(),trailing:_I.nullable(),measurement:HF.optional()}),bI=[`temperature`,`humidity`,`pressure`,`illuminance`,`reading`,`air-quality`,`valve`],Vxe=[`power`,`battery`,`consumables`],Hxe=new Set(bI);function Uxe(e){for(let t of Vxe){let n=e.facts.find(e=>e.id===t);if(n!==void 0)return n}return e.facts.find(t=>Hxe.has(t.id)&&t.text.en===e.title.en)??null}var Wxe={[j.Climate]:`climate.mode`};function Gxe(e){let t=Wxe[e.type];if(t!==void 0){let n=SI(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 Kxe={[j.Climate]:[`climate.target`],[j.Vacuum]:[`vacuum.base`],[j.LawnMower]:[`mower.dock`],[j.MediaPlayer]:[`volume.level`,hI],[j.Automation]:[`automation.enabled`]},xI=e=>e.kind===`action`?e.action.id:e.id;function SI(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=>xI(e)===t);if(r!==void 0)return r}return null}function qxe(e,t){let n=Kxe[e.type]??[],r=t===null?null:xI(t);return n.filter(e=>e!==r).flatMap(t=>{let n=SI(e,t);return n===null?[]:[n]}).slice(0,2)}function Jxe(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 Yxe(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 Xxe(e){let t=Uxe(e),{control:n,gated:r}=Gxe(e);return{deviceId:e.deviceId,name:e.name,type:e.type,state:e.state,stateAssumed:e.stateAssumed,look:e.look,scene:e.scene,statusLine:Jxe(e,t),primary:n,primaryGated:r,timedRun:Yxe(e),extras:qxe(e,n),trailing:t,...e.measurement===void 0?{}:{measurement:e.measurement}}}var Zxe=b({deviceId:r().int().nonnegative(),canActuate:v().optional()}),Qxe=b({deviceIds:S(r().int().nonnegative()).max(500),canActuate:v().optional()}),CI=b({type:u(),rows:S(oI)}),wI={name:`hero-layout`,scope:`system`,mode:`singleton`,methods:{getHeroModel:E(Zxe,zxe.nullable(),{auth:`protected`,role:`viewer`}),getRowModels:E(Qxe,S(yI.nullable()),{auth:`protected`,role:`viewer`}),getLayout:E(b({deviceType:u(),role:u().nullable().optional()}),CI,{auth:`protected`,role:`viewer`})},vocabulary:{notOperatorFacing:`the device hero model — read-only data the UI draws, never actuated`}},TI=b({on:v(),currentHumidity:r().min(0).max(100).nullable().meta(k(`humidity`)),targetHumidity:r().min(0).max(100).nullable().meta(k(`humidity`)),mode:u().nullable(),availableModes:S(u()),action:u().nullable(),minHumidity:r().nullable().meta(k(`humidity`)),maxHumidity:r().nullable().meta(k(`humidity`)),lastChangedAt:r()}),EI={name:`humidifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Humidifier],power:{kind:`field`,field:`on`,set:`setOn`},methods:{setOn:E(b({deviceId:r().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.on`,label:I(`Humidifier on`,`Umidificatore acceso`),phrase:I(`Turn on {device}`,`Accendi {device}`),icon:`power`,effect:{field:`on`,value:!0},args:{on:!0}},{id:`humidifier.off`,label:I(`Humidifier off`,`Umidificatore spento`),phrase:I(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`on`,value:!1},args:{on:!1}}]}),setTargetHumidity:E(b({deviceId:r().int().nonnegative(),humidity:r().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.target`,label:I(`Set humidity`,`Imposta l’umidità`),phrase:I(`Set {device} to {humidity} humidity`,`Imposta {device} al {humidity} di umidità`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`humidity`},openArgs:[{key:`humidity`,label:I(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMode:E(b({deviceId:r().int().nonnegative(),mode:u().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.mode`,label:I(`Set mode`,`Imposta la modalità`),phrase:I(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`list`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:I(`Mode`,`Modalità`),offer:{kind:`dynamic`,from:`status`,field:`availableModes`}}]}]})},status:{schema:TI,kind:`push`},runtimeState:TI,durability:`session`,history:{fields:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}}},vocabulary:{noun:I(`Humidifier`,`Umidificatore`),order:1090,state:[{kind:`boolean`,field:`on`,label:I(`On`,`Acceso`),whenTrue:I(`When {device} turns on`,`Quando {device} si accende`),whenFalse:I(`When {device} turns off`,`Quando {device} si spegne`),icon:`power`},{kind:`numeric`,field:`currentHumidity`,quantity:I(`the humidity`,`l’umidità`),label:I(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},DI=b({humidity:r().min(0).max(100).nullable().meta(k(`humidity`,{precision:0,label:`Humidity`})),lastFetchedAt:r()}),OI={name:`humidity-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor,j.Climate],methods:{},status:{schema:DI,kind:`push`},runtimeState:DI,durability:`restored`,history:{primary:`humidity`,priority:90,fields:{humidity:{kind:`gauge`,unit:`%`,deadband:.5}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Humidity`,`Umidità`),order:5120,state:[{kind:`numeric`,field:`humidity`,quantity:I(`the humidity`,`l’umidità`),label:I(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},kI=b({url:u().nullable(),lastUpdated:r().nullable().meta(k(`none`))}),AI={name:`image`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Image],methods:{},status:{schema:kI,kind:`push`},runtimeState:kI,durability:`session`,history:`none`,vocabulary:{noun:I(`Image`,`Immagine`),order:3130}},jI=x([`0`,`90`,`180`,`270`]),MI=x([`auto`,`manual`]),NI=x([`auto`,`manual`]),PI=x([`off`,`blc`,`wdr`,`hlc`]),FI=b({min:r(),max:r(),step:r()}),II=b({brightness:r().optional().meta(k(`none`)),contrast:r().optional().meta(k(`none`)),saturation:r().optional().meta(k(`none`)),sharpness:r().optional().meta(k(`none`)),mirror:v().optional(),flip:v().optional(),rotate:jI.optional(),whiteBalance:MI.optional(),warmth:r().optional().meta(k(`none`)),exposureMode:NI.optional(),backlightMode:PI.optional(),lastFetchedAt:r()}),LI=b({supportsBrightness:v(),brightness:FI.optional(),supportsContrast:v(),contrast:FI.optional(),supportsSaturation:v(),saturation:FI.optional(),supportsSharpness:v(),sharpness:FI.optional(),supportsMirror:v(),supportsFlip:v(),rotateOptions:S(jI),whiteBalanceModes:S(MI),supportsWarmth:v(),warmth:FI.optional(),exposureModes:S(NI),backlightModes:S(PI)}),RI=b({brightness:r().optional(),contrast:r().optional(),saturation:r().optional(),sharpness:r().optional(),mirror:v().optional(),flip:v().optional(),rotate:jI.optional(),whiteBalance:MI.optional(),warmth:r().optional(),exposureMode:NI.optional(),backlightMode:PI.optional()}),zI={name:`image-settings`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`image-settings`,tab:`image`}},methods:{getOptions:E(b({deviceId:r()}),LI),setSettings:E(b({deviceId:r(),settings:RI}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:II,kind:`poll`},runtimeState:II,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Image settings`,`Impostazioni immagine`),order:3140}},BI=b({id:u(),addonId:u(),name:u(),enabled:v(),switchUnknown:m(!0).optional(),info:h(u(),C()).readonly(),originStableId:u().optional(),createdAt:r(),updatedAt:r(),processState:u()}),VI=b({id:u(),addonId:u(),name:u(),enabled:v(),switchUnknown:m(!0).optional(),info:h(u(),C()).readonly(),originStableId:u().optional(),createdAt:r(),updatedAt:r()}),HI=b({addonId:u(),name:u(),providerLabel:u().optional(),description:u(),iconUrl:u().nullable(),color:u(),instanceMode:u(),mode:x([`standalone`,`account`,`broker`]),discoveryMode:u(),kind:x([`device-adoption`,`device-provider`]),brokerKind:u().nullable(),supportsLocationImport:v(),canTest:v(),existingInstances:S(b({id:u(),name:u()})),canAdd:v()}),UI=x([`validated`,`rejected`,`inconclusive`,`unsupported`]),WI=b({success:v(),error:u().optional(),status:UI.optional(),testedBy:u().nullable().optional(),latencyMs:r().nonnegative().optional(),detail:u().optional()}),GI=b({id:u(),name:u().optional(),enabled:v().optional(),info:h(u(),C()).optional()}),KI=b({success:v(),deletedId:u()}),qI={name:`integrations`,scope:`system`,mode:`singleton`,methods:{list:E(_(),S(BI)),get:E(b({id:u()}),BI),getByAddonId:E(b({addonId:u()}),VI.nullable()),update:E(GI,VI,{kind:`mutation`,auth:`admin`}),delete:E(b({id:u()}),KI,{kind:`mutation`,auth:`admin`}),getAvailableTypes:E(_(),S(HI),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.ADDON_ADMIN}},$xe=be(),JI=u().min(1),YI=x([`single`,`multiple`]),XI=x([`devices`,`services`]),ZI=b({id:u().min(1),label:u().min(1),functionCap:u().min(1),brokerKind:u().min(1).optional(),alsoServes:S(u().min(1)).optional(),iconUrl:u().min(1).optional(),iconMediaType:u().min(1).optional(),role:XI.optional(),canTest:v().optional(),signIn:b({basePath:u().min(1),methods:S(x([`device-code`,`proxy`])).optional()}).optional(),connectPath:u().min(1).optional(),disconnectPath:u().min(1).optional(),widgets:S(b({id:u().min(1),placement:x([`connection`,`model`])})).optional()}),QI=b({mode:x([`none`,`lan`,`account`]),scopedToInstance:v()}),$I=b({kind:u().min(1),field:u().min(1),to:b({cap:u().min(1),kind:u().min(1).optional()})}),eL=b({role:XI,discovery:QI.optional(),instanceMode:YI,kind:u(),canTest:v(),kinds:S(ZI).min(1),allowRestoreId:v().optional(),mintsId:v().optional(),links:S($I).optional(),userScoped:v().optional()}),tL=b({state:x([`ok`,`off`,`error`,`unknown`]),detail:u().optional(),label:u().optional()}),nL=x([`scan`,`children`,`none`]),rL=b({id:JI,name:u(),configured:v(),enabled:v().optional(),kind:u().min(1),formValues:h(u(),C()),status:tL.optional(),lastCheckedAt:r().optional(),addDevice:nL.optional()}),iL=b({id:JI,name:u().min(1).optional(),values:h(u(),C())}),aL={name:`integration-instances`,scope:`system`,mode:`collection`,methods:{describe:E(_(),eL,{auth:`admin`}),instanceFormSchema:E(b({id:JI.nullable(),kind:u().min(1).optional(),mode:x([`standalone`,`account`,`broker`]).optional(),candidateStableId:u().min(1).optional()}),$xe,{auth:`admin`}),listInstances:E(le({}),S(rL).readonly(),{auth:`protected`,caller:`scoped`}),getInstance:E(b({id:JI}),rL.nullable(),{auth:`protected`,caller:`scoped`}),createInstance:E(b({id:JI.optional(),name:u().min(1),kind:u().min(1).optional(),values:h(u(),C()).optional(),originStableId:u().min(1).optional(),seed:b({info:h(u(),C())}).optional()}),b({id:u()}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),updateInstance:E(iL,b({ok:m(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),setInstanceEnabled:E(b({id:JI,enabled:v()}),b({ok:m(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),deleteInstance:E(b({id:JI}),b({ok:m(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),testInstance:D(b({id:JI.nullable(),values:h(u(),C()),kind:u().min(1).optional()}),WI,{kind:`mutation`,auth:`protected`,caller:`scoped`})},vocabulary:{notOperatorFacing:O.INTERNAL}},oL=b({codecs:S(u()),sampleRate:r().meta(k(`none`)),duplex:x([`half`,`full`]),maxBacklogMs:r().meta(k(`duration-ms`))}),sL=b({talking:v(),lastSessionAt:r().nullable(),ability:oL.nullable()}),eSe=x([`opus`,`s16le`,`g711ulaw`,`g711alaw`]),cL={name:`intercom`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{startSession:E(b({deviceId:r()}),b({sessionId:u(),sdpOffer:u()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),handleAnswer:E(b({deviceId:r(),sessionId:u(),sdpAnswer:u()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),stopSession:E(b({deviceId:r(),sessionId:u()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),startTalkSession:E(b({deviceId:r()}),b({sessionId:u()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`two-way talk is a person speaking through the viewer, not an automation step`}),pushTalkAudio:E(b({deviceId:r(),audioBase64:u(),codec:eSe.optional(),sampleRate:r().int().positive().optional(),channels:r().int().positive().optional(),sequenceNumber:r().int()}),b({accepted:v()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),endTalkSession:E(b({deviceId:r()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`})},events:{onStatusChanged:{data:b({deviceId:r(),status:sL}),notOperatorFacing:"the `talking` state trigger phrases both edges of this change"}},status:{schema:sL,kind:`command-driven`},runtimeState:sL,durability:`session`,history:`none`,vocabulary:{noun:I(`Intercom`,`Citofono`),order:3150,state:[{kind:`boolean`,field:`talking`,label:I(`Talking`,`In conversazione`),whenTrue:I(`When someone starts talking through {device}`,`Quando qualcuno inizia a parlare tramite {device}`),whenFalse:I(`When the conversation on {device} ends`,`Quando la conversazione su {device} finisce`),icon:`mic`}]}},lL=x([`carrierHz`,`dutyCyclePercent`,`repeat`,`repeatDelayMs`]),uL=x([`ir`,`rf`]),dL=b({ok:m(!0),ignoredSettings:S(u())}),fL=b({media:S(uL),settable:S(lL),maxTimings:r().int().positive(),learn:v().default(!1),formats:S(Hw).default([])}),pL=2e4,mL=6e4,hL=b({native:Ww.nullable(),timings:Nw,carrierHz:r().int().positive().nullable()}),gL=b({at:r(),ok:v(),error:u().nullable()}),_L=gL.extend({medium:uL}),vL=b({lastSend:_L.nullable(),lastLearn:gL.nullable(),lastFetchedAt:r()});function yL(e){return!(e.kind===`learn`&&e.error===`ir-transmitter.learn-unsupported`)}function tSe(e,t,n){let r=e??{lastSend:null,lastLearn:null,lastFetchedAt:n};return yL(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 nSe(e){return ti(e)?.code??null}var bL={name:`ir-transmitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Generic],methods:{send:E(b({deviceId:r().int().nonnegative(),timings:Nw.optional(),native:Ww.optional(),settings:Pw.optional()}).refine(e=>e.timings===void 0!=(e.native===void 0),{message:`send takes exactly one of timings or native`}),dL,{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:E(b({deviceId:r().int().nonnegative(),timeoutMs:r().int().positive().max(mL).default(pL)}),hL,{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:E(b({deviceId:r().int().nonnegative()}),fL,{kind:`query`,auth:`protected`})},runtimeState:vL,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`IR / RF transmitter`,`Trasmettitore IR / RF`),order:1140}},xL=x([`key-missing`,`wrong-key`,`key-file-unreadable`,`store-unavailable`,`not-initialized`,`decrypt-failed`]),SL=a(`state`,[b({state:m(`ready`)}),b({state:m(`locked`),reason:xL})]),CL=a(`kind`,[b({kind:m(`value`),value:u(),version:r().int()}),b({kind:m(`missing`)}),b({kind:m(`unavailable`),reason:xL}),b({kind:m(`forbidden`)})]),wL=h(u(),CL),TL=b({ref:u(),owner:u(),scope:u(),fieldPath:u(),version:r().int(),createdAt:r(),updatedAt:r(),updatedBy:u(),lastReadAt:r().nullable()}),EL=S(u().min(1)).max(512),DL={name:`keychain`,scope:`system`,mode:`singleton`,internal:!0,methods:{put:E(b({ref:u().min(1),value:u().min(1)}),b({ref:u(),version:r().int()}),{kind:`mutation`,auth:`admin`}),resolve:E(b({refs:EL}),wL,{auth:`admin`}),delete:E(b({refs:EL}),b({deleted:r().int()}),{kind:`mutation`,auth:`admin`}),deleteDeviceScope:E(b({deviceId:r().int()}),b({refs:S(u()).readonly()}),{kind:`mutation`,auth:`admin`}),releaseRecordRefs:E(b({refs:EL,onBehalfOf:u().min(1)}),b({released:r().int()}),{kind:`mutation`,auth:`admin`}),listMeta:E(b({}),S(TL).readonly(),{auth:`admin`}),getState:E(b({}),SL,{auth:`admin`})},vocabulary:{notOperatorFacing:O.IDENTITY}},OL=x([`mounted-file`,`previous-mounted-file`,`platform`,`default-file`]),kL=b({kind:OL,path:u().optional(),sharesBackupWithDatabase:v()}),AL=`trigger-file`,jL=b({id:u(),at:r(),actor:u(),lockedReason:u().nullable(),archived:r().int(),archivedCollection:u().nullable(),archivedKeysCollection:u().nullable(),clearedSettingsKeys:S(u()).readonly(),acknowledgedAt:r().nullable()}),ML=b({keychain:SL,keySource:kL.nullable(),configuredSource:kL,fingerprint:u().nullable(),activeKeyId:u().nullable(),rotationPending:v(),retiredWraps:r().int(),recoveryKeyDownloadedAt:r().nullable(),secretCount:r().int(),lastReset:jL.nullable()}),NL=x([`in-use`,`orphan`,`unknown`]),PL=TL.extend({usage:NL}),FL=x([`put`,`delete`,`reveal`,`rotate-master-key`,`purge-retired-keys`,`download-recovery-key`,`delete-orphans`,`reset`,`acknowledge-reset`,`initialize`]),IL=b({id:u(),at:r(),action:FL,actor:u(),ref:u().nullable(),detail:u().nullable()}),LL=`RESET KEYCHAIN`,RL=x([`jwt-signing-key`]),zL={name:`keychain-admin`,scope:`system`,mode:`singleton`,methods:{status:E(b({}),ML,{auth:`admin`}),listSecrets:E(b({}),S(PL).readonly(),{auth:`admin`}),listAudit:E(b({limit:r().int().min(1).max(500).optional()}),S(IL).readonly(),{auth:`admin`}),reveal:E(b({ref:u().min(1)}),b({value:u(),version:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),setSystemSecret:E(b({name:RL,value:u().min(16)}),b({ref:u(),version:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),importSecret:E(b({ref:u().min(1),value:u().min(1)}),b({ref:u(),version:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteOrphans:E(b({refs:S(u().min(1)).max(1e3)}),b({deleted:S(u()).readonly(),kept:S(b({ref:u(),usage:NL})).readonly()}),{kind:`mutation`,auth:`admin`,caller:`required`}),rotateMasterKey:E(b({}),b({fingerprint:u(),keySource:kL}),{kind:`mutation`,auth:`admin`,caller:`required`}),purgeRetiredKeys:E(b({}),b({purged:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),downloadRecoveryKey:E(b({}),b({key:u(),fingerprint:u(),keySource:kL}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetKeychain:E(b({confirm:m(LL)}),b({archivedCollection:u().nullable(),archived:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetReport:E(b({}),b({reset:jL.nullable(),pendingReentry:S(TL).readonly()}),{auth:`admin`}),acknowledgeReset:E(b({}),b({acknowledged:v()}),{kind:`mutation`,auth:`admin`,caller:`required`})},vocabulary:{notOperatorFacing:O.IDENTITY}},BL=x([`idle`,`mowing`,`paused`,`docked`,`error`]),VL=x([`info`,`warning`,`error`]),HL=b({activity:BL,batteryLevel:r().min(0).max(100).nullable().meta(k(`percentage`)),progress:r().min(0).max(100).nullable().meta(k(`percentage`)),currentCode:r().nullable().meta(k(`none`)),currentCodeLabel:u().nullable(),severity:VL,lastChangedAt:r()}),UL={name:`lawn-mower-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.LawnMower],methods:{startMowing:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.start`,label:I(`Start mowing`,`Avvia il taglio`),phrase:I(`Start {device} mowing`,`Fai partire il taglio di {device}`),icon:`play`}]}),pause:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.pause`,label:I(`Pause mower`,`Metti in pausa il tosaerba`),phrase:I(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),dock:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.dock`,label:I(`Dock mower`,`Riporta alla base`),phrase:I(`Send {device} back to its dock`,`Rimanda {device} alla base`),icon:`house`}]})},status:{schema:HL,kind:`push`},runtimeState:HL,durability:`session`,history:{fields:{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}}},vocabulary:{noun:I(`Robot mower`,`Robot tosaerba`),order:2010,state:[{kind:`enum`,field:`activity`,label:I(`Activity`,`Attività`),values:[{value:`idle`,label:I(`Idle`,`Inattivo`)},{value:`mowing`,label:I(`Mowing`,`In taglio`),phrase:I(`When {device} starts mowing`,`Quando {device} inizia a tagliare`)},{value:`paused`,label:I(`Paused`,`In pausa`)},{value:`docked`,label:I(`Docked`,`Alla base`),phrase:I(`When {device} docks`,`Quando {device} arriva alla base`)},{value:`error`,label:I(`Error`,`Errore`),phrase:I(`When {device} reports an error`,`Quando {device} segnala un errore`)}],icon:`bot`},{kind:`numeric`,field:`batteryLevel`,quantity:I(`the battery level`,`il livello della batteria`),label:I(`Battery`,`Batteria`),unit:`%`,icon:`battery`}]}},WL=6e5,rSe=60*6e4,GL=b({inputTokens:r(),outputTokens:r()}),KL=x([`timeout`,`rate-limited`,`auth`,`refusal`,`bad-request`,`unavailable`,`no-profile`,`budget-exceeded`,`adapter-error`]),qL=b({ok:m(!0),text:u(),model:u(),usage:GL,truncated:v(),latencyMs:r()}),JL=x([`guardrail`,`model`]),YL=b({ok:m(!1),code:KL,message:u(),retryAfterMs:r().optional(),refusalSource:JL.optional()}),XL=a(`ok`,[qL,YL]),ZL=b({bytes:y(Uint8Array),mimeType:u()}),QL=b({enabled:v().default(!1),maxAttempts:r().int().min(1).max(5).default(1)}),iSe={totalMs:6e4,connectMs:1e4,firstTokenMs:12e4,idleMs:6e4},$L=b({addonId:u().optional(),profileId:u().optional(),consumer:u(),system:u().optional(),prompt:u(),jsonSchema:h(u(),C()).optional(),maxTokens:r().int().positive().optional(),temperature:r().optional(),topP:r().min(0).max(1).optional(),topK:r().int().positive().optional(),reasoningEffort:x([`off`,`low`,`medium`,`high`]).optional(),timeoutMs:r().int().positive().optional(),retry:QL.optional(),requestId:u().optional()}),eR=b({url:u(),filename:u(),sizeBytes:r(),sha256:u().optional()}),tR=a(`kind`,[b({kind:m(`catalog`),catalogId:u()}),b({kind:m(`url`),url:u(),sha256:u().optional(),label:u().optional(),sizeBytes:r().optional(),extraFiles:S(eR).optional()}),b({kind:m(`path`),path:u()})]),nR=b({nodeId:u(),engine:x([`llama-cpp`]),model:tR,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:v().default(!1),mlock:v().default(!1),noMmap:v().default(!1),cacheTypeK:x([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),cacheTypeV:x([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),extraArgs:S(u()).default([]),autoStart:v().default(!1),idleStopMinutes:r().int().default(30)}),rR=b({phase:x([`downloading`,`verifying`]),file:u(),fileIndex:r().int(),fileCount:r().int(),downloadedBytes:r(),totalBytes:r().optional()}),iR=b({nodeId:u(),state:x([`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:rR.optional(),lastError:u().optional(),crashesInWindow:r(),memoryBytes:r().optional(),vramBytes:r().optional()}),aR=b({file:u(),sizeBytes:r(),catalogId:u().optional(),installedAt:r().optional(),path:u().optional()}),oR=b({nodeId:u(),modelsBytes:r(),freeBytes:r().optional()}),sR=$L.extend({images:S(ZL).optional(),runtime:nR,timeoutMs:r().int().positive().optional()}),cR=x([`deviceNotEligible`,`appleIntelligenceNotEnabled`,`modelNotReady`,`osTooOld`,`helperMissing`,`helperCrashed`]),lR=a(`state`,[b({state:m(`available`),osVersion:u(),contextSize:r().int().positive(),languages:S(u()),imageInput:v()}),b({state:m(`unavailable`),reason:cR,osVersion:u().nullable(),detail:u()}),b({state:m(`unsupported-platform`),platform:u()}),b({state:m(`unknown`),error:u()})]),uR=$L.extend({images:S(ZL).optional(),timeoutMs:r().int().positive().optional()}),dR=b({requestId:u()}),fR={name:`llm-runtime`,scope:`system`,mode:`singleton`,internal:!0,methods:{complete:E(sR,XL,{kind:`mutation`,auth:`admin`,timeoutMs:WL}),ensureStarted:E(b({runtime:nR}),iR,{kind:`mutation`,auth:`admin`,timeoutMs:WL}),stop:E(b({}),_(),{kind:`mutation`,auth:`admin`}),status:E(b({}),iR,{auth:`admin`}),installModel:E(b({model:tR}),_(),{kind:`mutation`,auth:`admin`,timeoutMs:rSe}),deleteModel:E(b({file:u()}),_(),{kind:`mutation`,auth:`admin`}),listLocalModels:E(b({}),S(aR),{auth:`admin`}),getDiskUsage:E(b({}),oR,{auth:`admin`}),cancel:E(dR,_(),{kind:`mutation`,auth:`admin`}),appleAvailability:E(b({}),lR,{auth:`admin`}),completeApple:E(uR,XL,{kind:`mutation`,auth:`admin`,timeoutMs:WL})},vocabulary:{notOperatorFacing:O.ML}},pR=/^[a-z0-9][a-z0-9-]{0,63}$/,mR=u().regex(pR,`a kind id is lower-case letters, digits and dashes`),hR=b({vision:v(),tools:v(),streaming:v(),reasoning:v().nullable().optional()}),gR=b({id:u(),label:u().optional(),contextLength:r().int().positive().optional(),features:hR.partial().optional()}),_R=h(u(),C()),aSe=b({id:u(),name:u(),kind:mR,addonId:u(),enabled:v(),model:u(),supportsVision:v(),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:x([`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:QL.default({enabled:!1,maxAttempts:1}),toolsEnabled:v().default(!1),providerConfig:_R.default({})}),vR=x([`temperature`,`topP`,`topK`,`maxTokens`,`reasoningEffort`,`contextLength`,`systemPrompt`,`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`]),yR=b({id:u(),placement:x([`connection`,`model`]),requires:S(u()).optional()}),bR=C(),oSe=b({kind:mR,label:u(),icon:u(),addonId:u(),connectionSchema:bR,advancedSchema:bR.optional(),features:hR,visionEditable:v(),modelCatalog:x([`fetch`,`static`,`none`]),staticModels:S(gR).optional(),profileFields:S(vR),providerWidgets:S(yR).optional()}),xR=b({addonId:u(),kind:mR,profileId:u().optional(),connection:_R.optional()}),SR=x([`auth`,`network`,`unsupported`,`invalid`]),CR=a(`ok`,[b({ok:m(!0),models:S(gR)}),b({ok:m(!1),code:SR,message:u()})]),wR=g([b({consumer:u()}),b({purpose:x([`text`,`vision`])})]),TR=b({selector:wR,profileId:u()}),ER=b({day:u(),consumer:u(),profileId:u(),calls:r(),okCalls:r(),errorCalls:r(),inputTokens:r(),outputTokens:r(),avgLatencyMs:r()}),DR=b({id:u(),label:u(),family:u(),purpose:x([`text`,`vision`]),url:u(),sha256:u(),sizeBytes:r(),quantization:u(),minRamBytes:r(),contextSizeDefault:r().int(),mmprojUrl:u().optional()}),OR=a(`ok`,[b({ok:m(!0),model:tR,label:u(),repo:u(),quantization:u(),purpose:x([`text`,`vision`]),totalBytes:r(),extraFilenames:S(u())}),b({ok:m(!1),code:u(),message:u(),candidates:S(u()).optional(),requiredBytes:r().optional()})]),kR=b({nodeId:u(),reachable:v(),status:iR.optional(),disk:oR.optional(),error:u().optional(),apple:lR.optional()}),sSe=$L.extend({images:S(ZL).min(1)}),AR=b({addonId:u(),profileId:u()}),jR={name:`llm`,scope:`system`,mode:`collection`,internal:!1,providerKind:`ai`,nodeIdMode:`data`,methods:{generate:E($L,XL,{kind:`mutation`,timeoutMs:WL}),generateVision:E(sSe,XL,{kind:`mutation`,timeoutMs:WL}),cancel:E(b({addonId:u().optional(),requestId:u()}),_(),{kind:`mutation`}),listModels:E(xR,CR,{kind:`mutation`,auth:`admin`}),getDefaults:E(b({}),S(TR)),setDefault:E(b({selector:wR,profileId:u().nullable()}),_(),{kind:`mutation`,auth:`admin`}),getUsage:E(b({since:r().optional(),until:r().optional(),consumer:u().optional(),profileId:u().optional()}),S(ER)),listModelCatalog:E(b({}),S(DR)),listRuntimeNodes:E(b({}),S(kR)),listNodeModels:E(b({nodeId:u()}),S(aR)),resolveModelRef:E(b({ref:u(),maxBytes:r().positive().optional()}),OR,{kind:`mutation`,auth:`admin`}),installModel:E(b({nodeId:u(),model:tR}),_(),{kind:`mutation`,auth:`admin`}),deleteModel:E(b({nodeId:u(),file:u()}),_(),{kind:`mutation`,auth:`admin`}),getRuntimeStatus:E(AR,iR),startRuntime:E(AR,iR,{kind:`mutation`,auth:`admin`}),stopRuntime:E(AR,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.ML}},MR=[`decode`,`transcode`,`recording`,`streaming`,`detection`],NR=[`measured`,`accounted`,`unattributable`],PR=b({role:x(MR),deviceId:r().int().positive().nullable(),attribution:x(NR),unit:u(),pid:r().int().positive().optional(),startedAtMs:r().optional(),cpuSeconds:r().optional(),rssBytes:r().optional()}),FR={name:`load-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:E(_(),S(PR).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},IR=`https://camstack.zentik.app`,LR=`/viewer/camstack`;function RR(e){if(e==null||e===``)return!1;try{return new URL(e).origin===IR}catch{return!1}}function cSe(e){let t=e.baseUrl??e.resolved;return RR(t)?{form:`app`,hubBaseUrl:e.appLinkHub??null}:{form:`hub`,hubBaseUrl:t}}function zR(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 lSe(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=zR(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 uSe(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 BR(e){return e.length===0?``:`?${e.map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`}function dSe(e){let t=uSe(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:zR(r),n=e===null?t.query:[...t.query,[`hub`,e]];return`${IR}${t.path}${BR(n)}`}return r===``||RR(r)?null:`${r}${LR}${t.path}${BR(t.query)}`}var VR=[`appConnections`,`notificationTaps`,`internal`,`publicEndpoint`],fSe=[`notificationTaps`,`internal`,`publicEndpoint`];function pSe(e){return e!==`appConnections`}var mSe={appConnections:[],notificationTaps:null,internal:null,publicEndpoint:null},hSe=/^\d{1,3}(?:\.\d{1,3}){3}$/;function HR(e){try{let t=new URL(e).hostname;return t.length>0?t:null}catch{return null}}function gSe(e){return e.replace(/\/+$/,``)}function UR(e){return e.kind===`public`&&e.interfaceKind===`vpn`}function _Se(e){return e.kind===`public`&&e.interfaceKind===`public`}function WR(e){return(e.kind===`lan-ipv4`||e.kind===`lan-ipv6`)&&e.plausible}function GR(e){if(e.kind!==`lan-ipv4`||!e.plausible)return!1;let t=HR(e.baseUrl);return t!==null&&hSe.test(t)}function KR(e){return e.stable===!1}function vSe(e,t){return t.kind===`loopback`||t.kind===`app-link`||t.kind===`custom`||HR(t.baseUrl)===null||KR(t)?null:e===`internal`?GR(t)?0:WR(t)?1:UR(t)?2:null:_Se(t)?0:UR(t)?1:GR(t)?2:WR(t)?3:null}var ySe=new Set([`localhost`,`0.0.0.0`,`::1`,`[::1]`,`::`,`[::]`]);function bSe(e){let t=e.toLowerCase();return ySe.has(t)||t.endsWith(`.localhost`)?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}function qR(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 JR=`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 YR(e,t,n={}){if(RR(t))return e===`notificationTaps`?{ok:!0,baseUrl:IR}:{ok:!1,reason:`The CamStack app link is not a hub address — only notification taps can use it.`};let r=qR(t);return r.ok&&e===`publicEndpoint`&&r.baseUrl.startsWith(`http:`)&&n.acceptInsecureHttp!==!0?{ok:!1,reason:JR}:r}function XR(e,t){if(t===null||t===``)return null;let n=YR(e,t,{acceptInsecureHttp:!0});return n.ok?n.baseUrl:null}function xSe(e,t){let n=e.flatMap(e=>{let n=vSe(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:gSe(n.endpoint.baseUrl)}function ZR(e,t,n){let r=XR(t,n);if(r!==null)return{flagged:r,resolved:r,source:`flagged`};let i=xSe(e,t);return{flagged:null,resolved:i,source:i===null?`none`:`auto`}}function QR(e,t){return ZR(e,`internal`,t.internal)}function $R(e,t){return ZR(e,`publicEndpoint`,t.publicEndpoint)}function ez(e){let t=XR(`notificationTaps`,e.notificationTaps);return t!==null&&!RR(t)?{flagged:t,resolved:t,source:`flagged`}:{flagged:null,resolved:IR,source:`auto`}}function tz(e){return KR(e)?!1:e.kind===`lan-ipv4`?!0:e.kind===`public`&&e.interfaceKind===`public`}function nz(e,t){let n=e.filter(tz);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 rz(e,t){let n=new Set(t.appConnections),r=nz(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 SSe(e,t,n){return{appConnections:rz(e,n),notificationTaps:ez(n),internal:QR(t,n),publicEndpoint:$R(t,n)}}function CSe(e){return e===null?null:HR(e)}var wSe=`camstack`,TSe=`_camstack._tcp.local`,ESe={nodeId:`nodeId`,version:`version`,role:`role`,url:`url`,hubId:`hubId`},iz=/^hub-[0-9a-f]{16}$/;function DSe(e){return typeof e==`string`&&iz.test(e)}var OSe=`camstack-agent`,kSe=`_camstack-agent._tcp.local`,ASe={nodeId:`nodeId`,version:`version`,name:`name`,state:`state`,keyFingerprint:`fp`},jSe=x([`lan`,`wifi`,`docker`,`vpn`,`loopback`,`other`]),az=b({name:u(),family:x([`IPv4`,`IPv6`]),address:u(),cidr:u(),netmask:u(),internal:v(),mac:u(),kind:jSe,preferred:v(),plausible:v(),plausibleReason:u()}),MSe=b({interfaces:S(az).readonly(),probedAt:r()}),NSe=az.nullable(),oz=b({label:u(),baseUrl:u(),kind:x([`lan-ipv4`,`lan-ipv6`,`public`,`loopback`,`app-link`,`custom`]),interfaceKind:x([`lan`,`wifi`,`docker`,`vpn`,`other`,`loopback`,`public`]),plausible:v(),plausibleReason:u(),priority:r(),stable:v().optional()}),PSe=x([`server-config`,`server-env`,`caller-hint`,`default`]),FSe=b({port:r().int().min(1).max(65535),source:PSe}),ISe=b({endpoints:S(oz).readonly(),localPort:FSe}),sz=b({baseUrl:u().nullable(),resolved:u().nullable(),appLinkHub:u().nullable()}),cz=b({baseUrls:S(u()).readonly(),resolved:S(u()).readonly()}),lz=b({override:u().nullable(),resolved:u().nullable(),source:x([`override`,`auto`,`none`])}),LSe=b({cluster:lz,browser:lz}),uz=x(VR),dz=x([`flagged`,`auto`,`none`]),fz=b({flagged:u().nullable(),resolved:u().nullable(),source:dz}),RSe=b({flagged:S(u()).readonly(),resolved:S(u()).readonly(),source:dz}),pz=b({rows:S(oz.extend({detected:v(),custom:v(),flags:S(uz).readonly(),inUse:S(uz).readonly(),eligible:S(uz).readonly()})).readonly(),roles:b({appConnections:RSe,notificationTaps:fz,internal:fz,publicEndpoint:fz}),appLinkHub:u().nullable(),listenerOrigins:S(u()).readonly().optional()}),mz=b({addresses:S(u()).readonly()}),hz=b({mode:x([`generated`,`uploaded`,`disabled`]),leafFingerprintSha256:u().nullable(),caFingerprintSha256:u().nullable(),validTo:u().nullable(),sans:S(u()),caCertPem:u().nullable(),reissueError:u().nullable(),restartRequired:v(),caMissing:v(),localCaConstrained:v().nullable(),caReplacedAt:u().nullable(),storedUpload:b({leafFingerprintSha256:u(),validTo:u(),hasCa:v()}).nullable()}),zSe=b({providerId:u().min(1),modes:S(jA)}),BSe=b({providerId:u().optional(),mode:u().optional(),message:u()}),VSe=b({hostsProbed:r().int(),hits:r().int(),timeouts:r().int(),byMode:h(u(),b({probed:r().int(),hits:r().int(),timeouts:r().int()}))}),HSe=b({hits:S(b({providerId:u(),hit:MA})),subnetsScanned:S(u()),errors:S(BSe),stats:VSe}),gz={name:`local-network`,scope:`system`,mode:`singleton`,methods:{list:E(_(),MSe),getPreferred:E(_(),NSe),getConnectionEndpoints:E(b({port:r().int().min(1).max(65535).optional(),includeLoopback:v().optional(),ipv4Only:v().optional(),scheme:x([`http`,`https`]).optional(),includeAppLink:v().optional()}),ISe),getNotificationEndpoint:E(_(),sz),setNotificationEndpoint:E(b({baseUrl:u().nullable()}),sz,{kind:`mutation`}),getViewerEndpoints:E(_(),cz),setViewerEndpoints:E(b({baseUrls:S(u()).readonly()}),cz,{kind:`mutation`}),getAddresses:E(b({scheme:x([`http`,`https`]).optional()}).optional(),pz),addCustomAddress:E(b({baseUrl:u(),label:u().max(80)}),pz,{kind:`mutation`,auth:`admin`}),removeCustomAddress:E(b({baseUrl:u()}),pz,{kind:`mutation`,auth:`admin`}),setAddressRole:E(b({role:uz,baseUrl:u().nullable(),enabled:v(),acceptInsecureHttp:v().optional()}),pz,{kind:`mutation`,auth:`admin`}),getHubAddresses:E(_(),LSe),getAllowedAddresses:E(_(),mz),setAllowedAddresses:E(mz,b({success:m(!0)}),{kind:`mutation`}),resetAllowlistToBestMatch:E(_(),mz,{kind:`mutation`}),getTlsStatus:E(_(),hz),regenerateCertificate:E(b({reason:u().optional()}),hz,{kind:`mutation`,auth:`admin`}),uploadCertificate:E(b({certPem:u().min(1),keyPem:u().min(1),caPem:u().optional()}),hz,{kind:`mutation`,auth:`admin`}),downloadCa:E(_(),b({pem:u()})),useStoredUploadedCertificate:E(_(),hz,{kind:`mutation`,auth:`admin`}),scanNetwork:E(b({requests:S(zSe),subnets:S(u()).optional()}),HSe,{kind:`mutation`,auth:`admin`,timeoutMs:9e4}),getScanSubnets:E(_(),b({subnets:S(u())}),{auth:`admin`}),setScanSubnets:E(b({subnets:S(u())}),b({subnets:S(u())}),{kind:`mutation`,auth:`admin`}),revertToGeneratedCertificate:E(_(),hz,{kind:`mutation`,auth:`admin`})},mount:{kind:`hub-only`},vocabulary:{notOperatorFacing:O.NETWORK}},_z=x([`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]),vz=b({state:_z,codeRequired:v().nullable().optional(),lastChangedAt:r()}),USe={version:1,overridable:[{path:`state`,by:`door-contact`}],targets:[{id:`door-contact`,cardinality:`scalar`,vocabulary:{cap:`lock-control`,stateField:`state`},deviceTypes:[j.Lock],apply:`replace`,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},sources:[{kind:`binary`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}]},yz={name:`lock-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Lock],methods:{lock:E(b({deviceId:r().int().nonnegative(),code:u().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.lock`,label:I(`Lock`,`Chiudi a chiave`),phrase:I(`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:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),unlock:E(b({deviceId:r().int().nonnegative(),code:u().min(1).optional(),confirm:v().optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.unlock`,label:I(`Unlock`,`Apri la serratura`),phrase:I(`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:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),open:D(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.open`,label:I(`Open latch`,`Apri lo scrocco`),phrase:I(`Release the latch of {device}`,`Fai scattare lo scrocco di {device}`),icon:`door-open`}]})},status:{schema:vz,kind:`push`},runtimeState:vz,customize:USe,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Lock`,`Serratura`),order:1060,state:[{kind:`enum`,field:`state`,label:I(`Lock state`,`Stato della serratura`),values:[{value:`locked`,label:I(`Locked`,`Chiusa a chiave`),phrase:I(`When {device} locks`,`Quando {device} si chiude a chiave`)},{value:`unlocked`,label:I(`Unlocked`,`Sbloccata`),phrase:I(`When {device} unlocks`,`Quando {device} si sblocca`)},{value:`locking`,label:I(`Locking`,`In chiusura`),phrase:I(`When {device} starts locking`,`Quando {device} inizia a chiudersi`)},{value:`unlocking`,label:I(`Unlocking`,`In apertura`),phrase:I(`When {device} starts unlocking`,`Quando {device} inizia a sbloccarsi`)},{value:`jammed`,label:I(`Jammed`,`Inceppata`),phrase:I(`When {device} jams`,`Quando {device} si inceppa`)},{value:`door-open`,label:I(`Door open`,`Porta aperta`),phrase:I(`When the door of {device} opens`,`Quando la porta di {device} si apre`)}],icon:`lock`}]}},bz=b({armed:r().int().min(0),unknown:S(u()).readonly()}),xz={name:`log-channels`,scope:`system`,mode:`collection`,internal:!0,methods:{list:E(_(),S(fu).readonly()),apply:E(b({windows:S(pu).readonly()}),bz,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},Sz=x([`debug`,`info`,`warn`,`error`]),Cz=b({timestamp:ee(),level:Sz,scope:S(u()),message:u(),meta:h(u(),C()).optional(),tags:h(u(),u()).optional()}),wz=b({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:Sz.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()}),Tz=b({id:u().optional(),timestamp:r(),level:Sz,scope:u().optional(),message:u(),tags:h(u(),g([u(),r()])).optional(),meta:h(u(),C()).optional()}),Ez=b({entries:S(Tz),nextBefore:u().nullable(),nextAfter:u().nullable(),scannedBytes:r().int().nonnegative(),done:v(),cancelled:v().optional()}),WSe=b({instanceId:u().min(1).max(200).optional()}),Dz=b({readable:v(),reason:u().nullable(),filters:b({deviceId:v(),addonId:v(),nodeId:v(),tags:v(),level:v(),text:v(),timeRange:v()}),retentionDays:r().nullable()}),Oz={name:`log-destination`,scope:`system`,mode:`collection`,internal:!0,methods:{write:E(Cz,_(),{kind:`mutation`}),describeRead:D(WSe,Dz,{auth:`admin`}),read:D(wz,Ez,{auth:`admin`}),cancelRead:D(b({requestId:u().min(1).max(64)}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},kz=x([`primary`,`second-factor`]),Az=b({kind:m(`redirect`),id:u(),label:u(),icon:u().optional(),startUrl:u(),stage:kz,linkable:v().optional(),app:Zf.nullable().optional()}),jz=b({kind:m(`widget`),id:u(),addonId:u(),bundle:u(),remote:Bv,stage:kz,app:Zf.nullable().optional()}),Mz=b({kind:m(`passkey`),id:u(),label:u(),stage:kz,rpId:u(),origin:u().nullable(),app:Zf.nullable().optional()}),Nz=a(`kind`,[Az,jz,Mz]),Pz={name:`login-method`,scope:`system`,mode:`collection`,internal:!0,methods:{getLoginMethods:E(_(),S(Nz).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.IDENTITY}},Fz=b({sleeping:v().meta({label:`Sleeping`}),lastContactAt:r().optional(),lastUpdated:r().meta(k(`none`))}),Iz={name:`low-power-sleep`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{wakeUp:E(b({deviceId:r(),timeoutMs:r().int().min(500).max(3e4).default(8e3)}),b({awoke:v(),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:Fz,kind:`push`,empty:{sleeping:!1,lastUpdated:0}},runtimeState:Fz,durability:`restored`,history:`none`,volatileStateFields:[`lastUpdated`],vocabulary:{noun:I(`Low-power sleep`,`Sospensione a basso consumo`),order:5245}},GSe=b({id:u(),label:u(),scope:x([`mesh`,`public`]),url:u(),hostname:u(),port:r(),protocol:x([`http`,`https`])}),Lz=b({id:u(),hostname:u(),magicDns:u(),addresses:S(u()).readonly(),os:u().optional(),online:v(),lastSeenMs:r(),isSelf:v(),connection:x([`direct`,`relay`,`idle`]),relay:u().nullable(),lastHandshakeMs:r(),rxBytes:r(),txBytes:r(),tags:S(u()).readonly(),exitNodeOption:v(),advertisedRoutes:S(u()).readonly(),userLogin:u().nullable(),keyExpiry:r().nullable()}),Rz=b({joined:v(),meshIp:u(),magicDnsHostname:u(),peerCount:r(),endpoints:S(GSe).readonly(),error:u().optional(),tenantName:u(),magicDnsSuffix:u(),userLogin:u().nullable(),controlPlaneUrl:u(),keyExpiry:r().nullable(),daemonSocket:u().optional(),daemonCliPath:u().optional()}),zz={name:`mesh-network`,scope:`system`,mode:`collection`,providerKind:`mesh`,methods:{getStatus:E(_(),Rz),join:E(b({authKey:u().min(8),hostname:u().optional()}),b({joined:m(!0)}),{kind:`mutation`}),startLogin:E(b({hostname:u().optional()}),b({loginUrl:u()}),{kind:`mutation`}),leave:E(_(),b({left:m(!0)}),{kind:`mutation`}),logout:E(_(),b({loggedOut:m(!0)}),{kind:`mutation`}),listPeers:E(_(),b({peers:S(Lz).readonly()}))},vocabulary:{notOperatorFacing:O.NETWORK}},Bz=b({value:r().nullable().meta(k(`device`,{label:`Total`})),lastFetchedAt:r()}),Vz={name:`meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:Bz,kind:`push`},runtimeState:Bz,durability:`restored`,history:{fields:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Meter`,`Contatore`),order:5140,state:[{kind:`numeric`,field:`value`,quantity:I(`the total`,`il totale`),label:I(`Total`,`Totale`),icon:`gauge`}]}},KSe=b({total:r(),user:r(),system:r(),irq:r(),nice:r(),loadAvg:d([r(),r(),r()]),cores:r()}),qSe=b({percent:r().nullable(),totalBytes:r(),usedBytes:r().nullable(),availableBytes:r().nullable(),swapUsedBytes:r(),swapTotalBytes:r()}),JSe=b({readBytes:r(),writeBytes:r(),readOps:r(),writeOps:r(),timestampMs:r()}),YSe=b({rxBytes:r(),txBytes:r(),rxPackets:r(),txPackets:r(),rxErrors:r(),txErrors:r(),timestampMs:r()}),Hz=b({utilization:r(),model:u(),memoryUsedBytes:r(),memoryTotalBytes:r(),temperature:r().nullable()}),XSe=b({openFds:r(),threadCount:r(),activeHandles:r(),activeRequests:r()}),Uz=b({avg10:r(),avg60:r(),avg300:r()}),Wz=b({some:Uz,full:Uz.nullable()}),Gz=b({cpu:KSe,memory:qSe,gpu:Hz.nullable(),network:YSe,disk:JSe,pressure:b({cpu:Wz.nullable(),memory:Wz.nullable(),io:Wz.nullable()}),process:XSe,cpuTemperature:r().nullable(),timestampMs:r()}),ZSe=b({path:u(),totalBytes:r(),usedBytes:r(),availableBytes:r(),percent:r()}),Kz=b({pid:r(),cpu:r(),memory:r(),privateBytes:r().optional(),sharedBytes:r().optional()}),QSe=b({addonId:u(),nodeId:u(),role:x([`hub`,`worker`]),pid:r(),state:x([`starting`,`running`,`stopping`,`stopped`,`crashed`]),uptimeSec:r()}),$Se=b({pid:r(),ppid:r(),pgid:r(),classification:x([`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()}),eCe=b({source:x([`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()}),tCe=b({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()}),nCe=b({key:u(),kind:x([`addon`,`root`,`unattributed`]),points:S(tCe).readonly()}),rCe=b({nodeId:u(),series:S(nCe).readonly(),containerMemory:S(eCe).readonly(),bucketMs:r(),retainedSamples:r(),oldestAtMs:r().nullable(),cadenceMs:r(),durable:v()}),iCe=b({forNodeId:u(),sinceMs:r().optional(),maxPoints:r().int().positive().optional()}),qz=b({cpuPercent:r(),memoryPercent:r().nullable(),memoryUsedMB:r().nullable(),memoryTotalMB:r(),diskPercent:r().optional(),temperature:r().optional(),gpuPercent:r().optional(),gpuMemoryPercent:r().optional()}),Jz={name:`metrics-provider`,scope:`system`,mode:`singleton`,methods:{collectSnapshot:E(_(),Gz),getCached:E(_(),Gz.nullable()),getCurrent:E(_(),qz),getDiskSpace:E(b({dirPath:u()}),ZSe),getGpuInfo:E(_(),Hz.nullable()),getCpuTemperature:E(_(),r().nullable()),getProcessStats:E(b({pids:S(r())}),S(Kz)),listAddonInstances:E(_(),S(QSe).readonly()),getAddonStats:E(b({addonId:u()}),Kz.nullable()),listNodeProcesses:E(_(),S($Se).readonly()),getLoadSeries:E(iCe,rCe)},vocabulary:{notOperatorFacing:O.CLUSTER}},Yz=u().min(1).max(256),Xz=h(u(),C()),Zz=b({id:Yz,deviceId:r().int().optional(),at:r().int().optional(),expiresAt:r().int().optional(),data:Xz}),Qz=b({id:u(),deviceId:r().int().nullable(),at:r().nullable(),expiresAt:r().nullable(),rev:r().int(),updatedAt:r(),data:Xz}),$z=h(Pi,g([u(),r(),v(),b({in:S(g([u(),r(),v()])).min(1).max(Ln)}),b({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`})])),eB={kind:Bi},tB={deviceId:r().int().optional(),atFrom:r().optional(),atTo:r().optional()},nB=b({...eB,...tB,where:$z.optional(),order:x([`at`,`id`]).optional(),desc:v().optional(),limit:r().int().min(1).max(zn).default(100),cursor:u().min(1).optional()}),rB=b({records:S(Qz),nextCursor:u().nullable()}),aCe=x([`created`,`unchanged`,`updated`]),iB=b({kindId:r().int(),state:aCe,createdIndexes:S(u())}),aB=S(u()),oB=a(`op`,[b({op:m(`put`),kind:Bi,record:Zz,ifRev:r().int().min(0).optional()}),b({op:m(`patch`),kind:Bi,id:Yz,data:Xz,at:r().int().nullable().optional(),expiresAt:r().int().nullable().optional(),ifRev:r().int().min(1).optional()}),b({op:m(`delete`),kind:Bi,id:Yz})]),sB=h(u(),h(u(),u())),cB={name:`records`,scope:`system`,mode:`singleton`,internal:!0,methods:{declareKinds:E(b({kinds:h(Bi,zi)}),b({kinds:h(u(),iB)}),{kind:`mutation`,auth:`admin`}),get:E(b({...eB,id:Yz}),Qz.nullable(),{auth:`admin`}),getMany:E(b({...eB,ids:S(Yz).min(1).max(Ln)}),S(Qz),{auth:`admin`}),secretRefs:E(b({...eB,ids:S(Yz).min(1).max(Ln)}),sB,{auth:`admin`}),put:E(b({...eB,record:Zz,ifRev:r().int().min(0).optional()}),b({rev:r().int(),releasedRefs:aB}),{kind:`mutation`,auth:`admin`}),putMany:E(b({...eB,records:S(Zz).min(1).max(Ln)}),b({count:r().int(),releasedRefs:aB}),{kind:`mutation`,auth:`admin`}),patch:E(b({...eB,id:Yz,data:Xz,at:r().int().nullable().optional(),expiresAt:r().int().nullable().optional(),ifRev:r().int().min(1).optional()}),b({rev:r().int(),releasedRefs:aB}),{kind:`mutation`,auth:`admin`}),delete:E(b({...eB,id:Yz}),b({deleted:v(),secretRefs:aB}),{kind:`mutation`,auth:`admin`}),deleteMany:E(b({...eB,ids:S(Yz).min(1).max(Ln)}),b({deleted:r().int(),secretRefs:aB}),{kind:`mutation`,auth:`admin`}),query:E(nB,rB,{auth:`admin`}),count:E(b({...eB,...tB,where:$z.optional()}),b({count:r().int()}),{auth:`admin`}),histogram:E(b({...eB,deviceId:r().int().optional(),from:r(),to:r(),bucketMs:r().int().positive()}),b({buckets:S(b({bucketStart:r(),count:r().int()}))}),{auth:`admin`}),aggregate:E(b({...eB,op:x([`sum`,`min`,`max`,`count`]),field:Pi.optional(),groupBy:Pi.optional(),where:$z.optional()}),b({rows:S(b({group:g([u(),r(),se()]),value:r().nullable()}))}),{auth:`admin`}),deleteWhere:E(b({...eB,deviceId:r().int().optional(),atBefore:r().optional(),where:$z.optional()}),b({deleted:r().int(),secretRefs:aB}),{kind:`mutation`,auth:`admin`}),transact:E(b({ops:S(oB).min(1).max(Ln)}),b({results:S(b({rev:r().int().nullable(),deleted:v()})),releasedRefs:aB,secretRefs:aB}),{kind:`mutation`,auth:`admin`}),deleteDevice:E(b({deviceId:r().int(),kinds:S(Bi).optional()}),b({deleted:h(u(),r().int()),secretRefs:aB}),{kind:`mutation`,auth:`admin`}),allocateId:E(b(eB),b({id:r().int()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},lB=h(u(),C()),uB=b({integrationId:u().min(1)}),dB=b({id:u().min(1)}),fB=b({id:u(),deviceId:r().int().nullable(),at:r().nullable(),expiresAt:r().nullable(),rev:r().int(),updatedAt:r(),data:lB}),pB={id:u().min(1),deviceId:r().int().optional(),at:r().int().optional(),expiresAt:r().int().optional(),data:lB},mB=b({id:u(),addonId:u(),name:u(),info:lB,enabled:v().optional(),originStableId:u().optional()}),oCe=b({id:r().int(),integrationId:u().nullable().optional(),parentDeviceId:r().int().nullable().optional(),type:u().optional(),name:u().optional(),stableId:u().optional()}),hB=b({version:r().int(),methods:S(u())}),gB=b({message:u(),meta:lB.optional(),tags:b({deviceId:r().int().optional()}).optional()}),sCe={"ledger.declare":{input:b({owner:u().min(1),metas:S(Ro)}),output:b({bootId:u(),snapshot:x([`none`,`written`,`refused`]),steps:S(Go),migrationApi:hB.optional()}),behaviours:[`ledger.declare.answers-steps-in-engine-order`,`ledger.declare.answers-the-migration-api`]},"ledger.start":{input:b({id:u().min(1)}),output:b({proceed:v(),state:g([m(`pending`),Uo]),reason:u().nullable()}),behaviours:[`ledger.start.proceeds-when-predecessors-applied`]},"ledger.finish":{input:b({id:u().min(1),result:Ho}),output:b({status:Uo,error:u().nullable(),rowsChanged:r().int().nonnegative()}),behaviours:[`ledger.finish.records-the-outcome`]},"legacyRows.read":{input:uB,output:lB,behaviours:[`legacyRows.read.returns-stored-rows`,`legacyRows.read.absent-store-is-empty`,`legacyRows.caller.sibling-package`]},"legacyRows.clear":{input:uB,output:b({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:lB}),output:b({written:v()}),behaviours:[`legacyRows.patch.upserts-keys-and-keeps-the-rest`,`legacyRows.patch.absent-store-writes-nothing`]},"legacyRows.deleteKeys":{input:uB.extend({keys:S(u().min(1))}),output:b({present:v(),removed:lB}),behaviours:[`legacyRows.deleteKeys.removes-the-named-keys`,`legacyRows.deleteKeys.absent-store-reports-not-present`]},"records.get":{input:dB,output:fB.nullable(),behaviours:[`records.get.returns-the-row-or-null`]},"records.getResolved":{input:dB,output:fB.nullable(),behaviours:[`records.getResolved.resolves-secret-fields`]},"records.put":{input:b({...pB,ifRev:r().int().optional()}),output:b({rev:r().int()}),behaviours:[`records.put.creates-and-replaces`,`records.put.if-rev-conflict-throws`]},"records.putMany":{input:b({records:S(b(pB))}),output:b({count:r().int().nonnegative()}),behaviours:[`records.putMany.writes-every-row`]},"records.patch":{input:dB.extend({partial:lB,ifRev:r().int().optional()}),output:b({rev:r().int()}),behaviours:[`records.patch.merges-and-null-removes`]},"records.delete":{input:dB,output:b({deleted:v()}),behaviours:[`records.delete.reports-whether-a-row-went`]},"records.query":{input:b({deviceId:r().int().optional(),atFrom:r().optional(),atTo:r().optional(),where:$z.optional(),limit:r().int().min(1).optional(),cursor:u().min(1).optional(),resolveSecrets:v().optional()}),output:b({records:S(fB),nextCursor:u().nullable()}),behaviours:[`records.query.pages-with-a-cursor`,`records.query.filters-on-a-declared-index`]},"records.deleteWhere":{input:b({deviceId:r().int().optional(),atBefore:r().optional(),where:$z.optional()}),output:b({count:r().int().nonnegative()}),behaviours:[`records.deleteWhere.deletes-the-matching-rows`]},"settings.read":{input:b({}),output:b({store:lB}),behaviours:[`settings.read.returns-the-addon-store`]},"settings.write":{input:b({patch:lB}),output:b({}),behaviours:[`settings.write.merges-and-keeps-other-keys`]},"settings.deleteKeys":{input:b({keys:S(u().min(1))}),output:b({removed:S(u())}),behaviours:[`settings.deleteKeys.removes-only-the-named-keys`]},"deviceSettings.listIds":{input:b({}),output:b({deviceIds:S(r().int())}),behaviours:[`deviceSettings.listIds.names-only-the-addons-own-devices`]},"deviceSettings.read":{input:b({deviceIds:S(r().int())}),output:b({blobs:h(u(),lB)}),behaviours:[`deviceSettings.read.returns-only-the-addons-own-blobs`]},"secrets.resolve":{input:b({refs:S(u())}),output:b({values:h(u(),u().nullable())}),behaviours:[`secrets.resolve.answers-null-for-a-missing-ref`]},"secrets.put":{input:b({ref:u().min(1),value:u()}),output:b({}),behaviours:[`secrets.put.stores-under-the-owner`]},"secrets.delete":{input:b({refs:S(u())}),output:b({deleted:r().int().nonnegative()}),behaviours:[`secrets.delete.ignores-unknown-refs`]},"integrations.list":{input:b({}),output:b({integrations:S(mB)}),behaviours:[`integrations.list.lists-every-integration`]},"integrations.get":{input:b({id:u().min(1)}),output:mB.nullable(),behaviours:[`integrations.get.null-for-an-unknown-id`]},"devices.list":{input:b({addonId:u().min(1),integrationId:u().min(1).optional()}),output:b({devices:S(oCe)}),behaviours:[`devices.list.scoped-to-the-addon`,`devices.list.filters-by-integration`]},"devices.get":{input:b({deviceId:r().int()}),output:b({id:r().int(),integrationId:u().nullable(),hasConfig:v()}).nullable(),behaviours:[`devices.get.null-for-an-unknown-id`,`devices.get.reports-link-and-config`]},"devices.aliases":{input:b({deviceIds:S(r().int())}),output:b({aliases:h(u(),u())}),behaviours:[`devices.aliases.answers-for-the-named-ids-only`]},"devices.setIntegrationId":{input:b({deviceId:r().int(),integrationId:u().min(1)}),output:b({}),behaviours:[`devices.setIntegrationId.links-the-device`]},"node.localNodeId":{input:b({}),output:b({nodeId:u()}),behaviours:[`node.localNodeId.names-this-node`]},"log.info":{input:gB,output:b({}),behaviours:[`log.info.writes-a-line`]},"log.warn":{input:gB,output:b({}),behaviours:[`log.warn.writes-a-line`]}},_B={name:`migrations`,scope:`system`,mode:`singleton`,internal:!0,methods:{listLedger:E(b({}),b({entries:S(Wo)}),{auth:`admin`}),listPending:E(b({owner:u().optional()}),b({pending:S(kie)}),{auth:`admin`}),dryRun:E(b({id:u().min(1)}),Aie,{auth:`admin`}),markFailed:E(b({id:u().min(1),error:u().min(1)}),Wo,{kind:`mutation`,auth:`admin`}),retry:E(b({id:u().min(1)}),b({entries:S(Wo)}),{kind:`mutation`,auth:`admin`}),restorePreMigration:E(b({database:Po,snapshotId:u().min(1)}),b({scheduled:v(),held:S(u()),restartRequired:v()}),{kind:`mutation`,auth:`admin`}),declareOwner:E(b({owner:u().min(1),metas:S(Ro),retired:S(u().min(1)).optional()}),b({bootId:u(),snapshot:x([`none`,`written`,`refused`]),steps:S(Go),migrationApi:hB.optional()}),{kind:`mutation`,auth:`admin`}),startMigration:E(b({id:u().min(1)}),b({proceed:v(),state:g([m(`pending`),Uo]),reason:u().nullable()}),{kind:`mutation`,auth:`admin`}),finishMigration:E(b({id:u().min(1),result:Ho}),b({status:Uo,error:u().nullable(),rowsChanged:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),readLegacyIntegrationRows:E(b({integrationId:u().min(1)}),h(u(),C()),{auth:`admin`}),clearLegacyIntegrationRows:E(b({integrationId:u().min(1)}),b({rows:r().int().nonnegative(),secrets:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),patchLegacyIntegrationRows:E(b({integrationId:u().min(1),patch:h(u(),C())}),b({written:v()}),{kind:`mutation`,auth:`admin`}),deleteLegacyIntegrationRowKeys:E(b({integrationId:u().min(1),keys:S(u().min(1))}),b({present:v(),removed:h(u(),C())}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},vB=b({sourceUrl:u(),metadata:Qd,targets:S(Zd).min(1).readonly(),calibrationRef:u().optional(),sessionId:u().optional()}),yB={name:`model-convert`,scope:`system`,mode:`singleton`,internal:!0,methods:{convert:E(vB,ef,{kind:`mutation`,auth:`admin`,timeoutMs:6e5})},vocabulary:{notOperatorFacing:O.ML}},bB=b({targetNodeId:u(),modelId:u(),format:x(Ld),entry:Xd}),xB=b({ok:v(),sha256:u(),bytes:r(),path:u()}),SB={name:`model-distributor`,scope:`system`,mode:`singleton`,internal:!0,methods:{distributeModel:E(bB,xB,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.ML}},CB=a(`kind`,[b({kind:m(`camera`)}),b({kind:m(`sensor`),deviceId:r().int().positive()})]),wB=Object.freeze({kind:`camera`});function cCe(e){if(e===void 0)return{triggeredBy:wB,malformed:!1};let t=CB.safeParse(e);return t.success?{triggeredBy:t.data,malformed:!1}:{triggeredBy:wB,malformed:!0}}var lCe=`cameraSensors`,TB=b({addonId:u().min(1),stableId:u().min(1)});function EB(e){return`${e.addonId}/${e.stableId}`}var DB=x([`in-addition`,`confirm`,`replace`]),OB=`in-addition`,kB=TB.extend({mode:DB.default(OB)}),AB=b({sensors:S(kB).min(1).max(8)}).superRefine((e,t)=>{let n=new Set;e.sensors.forEach((e,r)=>{let i=EB(e);n.has(i)&&t.addIssue({code:`custom`,path:[`sensors`,r],message:`duplicate camera sensor ${i}`}),n.add(i)})}),jB={addonId:u(),stableId:u(),mode:DB.default(OB)},MB=a(`state`,[b({...jB,state:m(`ready`),deviceId:r(),name:u(),caps:S(u()).readonly()}),b({...jB,state:m(`offline`),deviceId:r(),name:u(),reason:x([`offline`,`disabled`])}),b({...jB,state:m(`missing`),reason:u()}),b({...jB,state:m(`unsupported`),deviceId:r(),name:u(),reason:u()}),b({...jB,state:m(`unreadable`),reason:u()})]),NB=x([`onboard-not-listed`,`no-active-detection`]),PB=x([`always`,`when-confirmed`,`never`]),FB=x([`provider-not-split`]),IB=b({detected:v(),atMs:r()}),LB=a(`state`,[b({state:m(`not-configured`),cameraLevel:IB.optional()}),b({state:m(`unreadable`),reason:u(),cameraLevel:IB.optional()}),b({state:m(`configured`),cameraLevel:IB.optional(),sensors:S(MB).readonly(),cameraMotion:PB.optional(),notForwarded:NB.optional(),notEnforced:FB.optional()})]),RB=Object.freeze({state:`unreadable`,reason:`camera sensor mappings not loaded`}),zB=b({bbox:ny,pixelCount:r(),intensity:r()}),BB=b({detected:v(),regionCount:r(),regions:S(zB).readonly(),rawRegions:S(zB).readonly(),frameWidth:r(),frameHeight:r(),analysisMs:r()}),VB={name:`motion-detection`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{analyze:E(b({deviceId:r(),frame:ty.optional(),frameHandle:mc.optional()}),BB,{role:`admin`,kind:`mutation`,notOperatorFacing:`the pipeline feeds it frames — an internal stage, never called by a person`}),removeCamera:E(b({deviceId:r()}),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping when a camera leaves`}),reset:E(_(),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping`})},events:{onMotion:{data:b({deviceId:r(),detected:v(),regionCount:r()}),notOperatorFacing:"the analyzer’s raw verdict; the operator signal is the `motion` cap’s `detected` state"}},vocabulary:{noun:I(`Motion analysis`,`Analisi del movimento`),order:3160}},HB=b({package:v(),confidence:r().min(0).max(1),reason:u().min(1)}),UB=b({x:r(),y:r()}),WB=b({kind:m(`rect`),x:r(),y:r(),width:r(),height:r()}),GB=b({kind:m(`polygon`),points:S(UB)}),KB=b({kind:m(`grid`),gridWidth:r().meta(k(`none`)),gridHeight:r().meta(k(`none`)),cells:S(v())}),qB=b({kind:m(`line`),points:S(UB)}),uCe=a(`kind`,[WB,GB,KB,qB]),JB=x([`rect`,`polygon`,`grid`,`line`]),YB=b({min:r(),max:r()}),XB=b({width:r(),height:r()}),ZB=[`owner-not-ready`,`store-read-failed`,`three-way-read-unavailable`,`invalid-stored`,`not-cluster-scoped`],QB=[{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)`}]}],dCe=`cluster-step-models`;function $B(e){return`clusterModel:${e}`}function fCe(e){return QB.some(t=>t.stepId===e)}var eV=Object.freeze(Object.fromEntries(QB.map(e=>[e.stepId,e.defaultModelId])));function tV(e){return e==null||e===``?{kind:`absent`}:typeof e==`string`?{kind:`chosen`,modelId:e}:{kind:`invalid`,value:e}}function nV(e){let t=[];for(let n of QB){let r=tV(e[$B(n.stepId)]);r.kind===`invalid`&&t.push({stepId:n.stepId,value:r.value})}return t}function rV(e){let t={};for(let n of QB){let r=tV(e[$B(n.stepId)]);t[n.stepId]=r.kind===`chosen`?r.modelId:n.defaultModelId}return t}function pCe(e){return typeof e==`object`&&!!e&&`key`in e}function iV(e){return e===null?eV:rV(oV(e,aV()))}function mCe(e){return e===null?[]:nV(oV(e,aV()))}function aV(){return new Set(QB.map(e=>$B(e.stepId)))}function oV(e,t){let n={};for(let r of e.sections)for(let e of r.fields)!pCe(e)||typeof e.key!=`string`||t.has(e.key)&&(n[e.key]=e.value);return n}function hCe(e,t){let n=QB.find(t=>t.stepId===e);if(n===void 0)return null;let r=t[e];return r!==void 0&&r!==``?r:n.defaultModelId}var sV=[{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 cV(e,t){return`clusterStepSetting:${e}:${t}`}function lV(e){return sV.filter(t=>t.stepId===e)}var gCe=r().finite();function uV(e){let t={};for(let n of sV){let r=gCe.safeParse(e[cV(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 dV=uV({});function fV(e){return e===null?dV:uV(oV(e,new Set(sV.map(e=>cV(e.stepId,e.key)))))}function _Ce(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 pV=x([`new`,`entered`,`left`,`moving`,`idle`]),mV=x([`motion`,`object`,`audio`]),hV=a(`kind`,[WB,GB]),gV=x([`motion`,`audio`,`person`,`vehicle`,`animal`,`door`,`pir`,`smoke`,`water`,`button`,`package`,`generic`]),_V=x([`motion`,`audio`,`detection`,`sensor`,`control`,`custom`,`package`]),vCe=x([`macro`,`sub`]),vV=b({kind:u(),labelKey:u(),label:u(),color:u(),iconId:u(),icon:gV,category:_V,parentKind:u().nullable(),level:vCe,source:b({capName:u(),deviceId:r()})}),yV=b({deviceId:r(),kinds:S(vV).readonly()}),bV=b({id:u(),deviceId:r(),sourceDeviceId:r(),kind:u(),value:h(u(),C()).nullable(),timestamp:r()}),xV=b({x:r(),y:r(),timestamp:r(),bbox:ny,source:x([`frame`,`recovery`]).optional(),score:r().optional()}),yCe=b({timestamp:r(),position:xV,mediaId:r().int()}),SV=b({minX:r(),minY:r(),maxX:r(),maxY:r()}),CV=x([`full`,`slim`]),wV=b({label:u(),peakScore:r(),count:r(),firstAt:r(),lastAt:r()}),TV=x([`pipeline`,`onboard`,`sensor`,`audio`]),EV=x([`none`,`staging`,`trained`]),DV={markForTrain:v().optional(),debug:v().optional(),debugNote:u().max(500).optional(),favourited:v().optional()},OV={retrainStatus:EV.optional()},kV=b(DV),AV=b({trackId:u(),markForTrain:v(),debug:v(),debugNote:u(),favourited:v(),retrainStatus:EV}),bCe=g([m(1),m(2)]),jV=b({stepId:u(),modelId:u().optional(),decidedAt:r(),identityId:u().optional()}),MV={label:u().optional(),labelScore:r().optional(),labelMeta:jV.optional(),subLabel:u().optional(),subLabelScore:r().optional(),subLabelMeta:jV.optional()},NV=b({deviceId:r(),tracks:r().int(),files:r().int(),bytes:r().int()}),PV=b({generatedAt:r(),trackCount:r().int(),fileCount:r().int(),byteCount:r().int(),truncated:v(),devices:S(NV).readonly()}),FV=b({nodeId:u(),deviceKey:u().optional(),modelId:u().optional()}),IV=b({trackId:u(),deviceId:r(),className:u(),...MV,producingDeviceName:u().optional(),source:TV.optional(),firstSeen:r(),lastSeen:r(),positions:S(xV).readonly(),snapshots:S(yCe).readonly(),zonesVisited:S(u()).readonly(),zoneNames:S(u()).readonly().optional(),classes:S(u()).readonly().optional(),totalDistance:r(),state:pV,active:v(),importance:r().optional(),bestEventId:u().optional(),importanceReason:u().optional(),audioLabels:S(wV).readonly().optional(),envelope:SV.optional(),hasFace:v().optional(),hasEmbeddedFace:v().optional(),hasRider:v().optional(),previewMissReason:u().optional(),modelId:u().optional(),openedPlacement:FV.optional(),closedPlacement:FV.optional(),frameWidth:r().optional(),frameHeight:r().optional(),...DV,...OV}),LV={id:r().int(),deviceId:r(),timestamp:r()},RV=b({...LV,kind:m(`motion`),regionCount:r(),regions:S(b({bbox:ny,pixelCount:r(),intensity:r()})).readonly().optional(),frameWidth:r().optional(),frameHeight:r().optional(),mediaUrl:u().optional(),triggeredBy:CB.optional(),durationMs:r().nullable().optional(),edges:S(r()).readonly().optional()}),zV=x([`pipeline`,`onboard`]),BV=x([`enter`,`exit`]),VV=b({direction:BV,zoneId:u(),zoneName:u().optional()}),xCe=b({zoneId:u(),zoneName:u().optional(),overlapPct:r()}),HV=b({...LV,kind:m(`object`),source:zV.optional(),frameId:u().optional(),idempotencyKey:u().optional(),trackId:u().optional(),className:u(),...MV,confidence:r().optional(),bbox:ny.optional(),zones:S(u()).readonly().optional(),zoneOverlaps:S(xCe).readonly().optional(),spawnRefused:u().optional(),state:pV.optional(),zoneCrossing:VV.optional(),frameWidth:r().optional(),frameHeight:r().optional(),mediaId:r().int().optional(),keyFrameMediaId:r().int().optional(),mediaUrl:u().optional(),observedAt:r().optional(),packagePossible:v().optional(),packageLlmVerdict:HB.optional(),importance:r().optional()}),UV=b({...LV,kind:m(`audio`),rms:r(),dbfs:r(),classification:b({className:u(),originalClass:u().optional(),score:r()}).optional(),classifyOutcome:sy.optional(),mediaUrl:u().optional()}),WV=x([`crop`,`thumbnail`,`snapshot`,`firstFrame`,`lastFrame`,`fullFrame`,`fullFrameBoxed`,`faceCrop`,`plateCrop`,`keyFrame`,`keyFrameSmall`,`thumbnailSmall`,`confirmationCrop`,`debugCrop`,`sceneFrame`,`lastSceneFrame`]),GV=b({mediaId:r().int(),kind:WV,sizeBytes:r(),timestamp:r()}),KV=GV.extend({url:u(),base64:u()}),qV=KV.omit({base64:!0}),JV=x([`person`,`vehicle`,`animal`,`package`,`face`,`plate`]),YV=x([`subject`,`model_error`]),XV=x([`operator`,`assist`,`pipeline`,`llm`]),ZV=b({x:r(),y:r(),w:r(),h:r()}),QV=b({source:XV,ref:u().min(1),bbox:ZV,macroClass:JV,label:u().optional(),score:r().optional(),modelId:u().optional()}),$V=b({ref:u().min(1),snapshot:QV}),eH=x(gs),tH=b({ref:u(),savedId:u().optional(),status:eH,approximate:v(),origin:QV.optional(),macroClass:JV.optional(),label:u().optional(),iou:r().optional()}),nH=b({boxes:S(tH).readonly(),summary:b({counts:h(eH,r().int()),total:r().int(),changed:r().int(),approximate:v()})}),rH=b({id:u(),trackId:u().optional(),deviceId:r(),mediaKey:u(),bbox:ZV,macroClass:JV,label:u().optional(),subLabel:u().optional(),kind:YV,source:XV,assistModelId:u().optional(),assistScore:r().optional(),origin:QV.nullable().optional(),exportedInBatch:u().optional(),createdAt:r()}),iH=rH.omit({id:!0,trackId:!0,deviceId:!0,mediaKey:!0,createdAt:!0,exportedInBatch:!0}),aH=x([`correct`,`wrong`,`wrong-label`]),oH=b({verdict:aH,suggestedClass:u().optional(),suggestedMacroClass:JV.optional(),suggestedLabel:u().optional(),trackId:u(),at:r().optional()}),sH=b({trackId:u(),className:u(),label:u().optional(),bbox:ZV.optional(),verdict:aH,suggestedClass:u().optional(),at:r().optional()}),cH=b({trackId:u(),deviceId:r(),className:u(),label:u().optional(),firstSeen:r(),lastSeen:r(),frameCount:r().int(),annotationCount:r().int(),verdict:oH.optional()}),lH=b({mediaId:r().int(),kind:WV,timestamp:r(),sizeBytes:r().int(),copied:v()}),uH=b({bbox:ZV,macroClass:JV,label:u().optional(),subLabel:u().optional(),score:r().optional(),modelId:u().optional(),trackId:u(),basis:x([`subject-box`,`position`,`verdict`]),deltaMs:r()}),dH=x([`track`,`recording`]),fH=b({frameId:u(),deviceId:r(),origin:dH,trackId:u().optional(),sourceMediaId:r().int().optional(),epochMs:r().optional(),sourceKind:WV,sizeBytes:r().int(),width:r().int(),height:r().int(),copiedAt:r(),capturedAt:r().optional(),complete:v(),pipelineBoxes:S(uH).readonly().optional(),collectionIds:S(u()).readonly().optional(),verdict:oH.optional(),revision:r().int().optional(),dismissed:S($V).readonly().optional(),review:nH.optional(),imageUrl:u().optional(),thumbnailUrl:u().optional()}),pH=x([`source-missing`,`unreadable-image`,`write-failed`]),mH=b({copied:S(fH).readonly(),refused:S(b({sourceMediaId:r().int(),reason:pH})).readonly()}),hH=b({candidates:S(lH).readonly(),copies:S(fH).readonly(),autoPickMediaId:r().int().optional()}),gH=x([`unannotated`,`annotated`,`complete`]),_H=b({workState:gH.optional(),deviceIds:S(r()).max(500).optional(),collectionId:u().optional(),classes:S(JV).optional(),page:r().int().positive().default(1),pageSize:r().int().positive().max(100).default(50)}),vH=fH.extend({workState:gH}),yH=b({frames:S(vH).readonly(),total:r().int().nonnegative(),page:r().int().positive(),pageSize:r().int().positive()}),bH=b({deviceId:r(),unannotated:r().int().nonnegative(),annotated:r().int().nonnegative(),complete:r().int().nonnegative(),pctOfCorpus:r().min(0).max(1).nullable()}),xH=b({total:r().int().nonnegative(),unannotated:r().int().nonnegative(),annotated:r().int().nonnegative(),complete:r().int().nonnegative(),cameras:S(bH).readonly()}),SH=b({deviceIds:S(r()).optional(),frameIds:S(u()).max(2e4).optional(),collectionIds:S(u()).max(200).optional(),collectionId:u().optional(),batchId:u().optional(),completeOnly:v().optional(),workState:gH.optional(),classes:S(JV).optional()}),CH=x([`frames`,`crops`]),wH=b({kind:m(`http`),method:x([`PUT`,`POST`]),url:u().url(),headers:h(u(),u()).optional()}),TH=b({batchId:u(),frames:r().int(),crops:r().int(),annotations:r().int(),missing:r().int(),bytes:r().int(),sha256:u(),status:r().int()}),EH=a(`kind`,[b({kind:m(`package`),zone:ZV.optional()}),b({kind:m(`objects`),modelId:u(),minScore:r().optional()})]),DH=a(`kind`,[b({kind:m(`proposed`),modelId:u(),stepId:u(),minScore:r(),proposals:S(iH).readonly(),belowThreshold:r().int()}),b({kind:m(`refused`),reason:u(),detail:u().optional()})]),OH=b({id:u(),name:u(),createdAt:r(),frameCount:r().int()}),kH=a(`kind`,[b({kind:m(`created`),collection:OH}),b({kind:m(`refused`),reason:x([`empty-name`,`duplicate-name`])})]),AH=a(`kind`,[b({kind:m(`renamed`),collection:OH}),b({kind:m(`refused`),reason:x([`empty-name`,`duplicate-name`,`unknown-collection`])})]),jH=a(`kind`,[b({kind:m(`added`),collectionId:u(),frame:fH,reused:v()}),b({kind:m(`refused`),reason:x([`unknown-collection`,`still-unavailable`,`still-busy`,`unreadable-image`,`write-failed`]),detail:u().optional()})]),MH=b({id:u(),name:u(),model:u(),kind:u(),leavesHouse:v()}),NH=iH.extend({reason:u()}),PH=b({ref:u(),verdict:x([`confirmed`,`wrong-class`,`not-an-object`,`uncertain`]),suggestedClass:JV.optional(),reason:u()}),FH=a(`kind`,[b({kind:m(`proposed`),profileId:u(),model:u(),leftHouse:v(),proposals:S(NH).readonly(),reviews:S(PH).readonly(),rejected:r().int()}),b({kind:m(`refused`),reason:x([`unknown-frame`,`unreadable-frame`,`unknown-profile`,`profile-disabled`,`no-vision`,`cloud-not-confirmed`,`llm-error`,`malformed-answer`]),detail:u().optional()})]),IH=b({deviceIds:S(r()).readonly().optional(),collectionIds:S(u()).max(200).readonly().optional(),frameIds:S(u()).max(2e4).readonly().optional()}),LH=b({frames:r().int(),completeFrames:r().int(),completeness:r(),subjects:r().int(),modelErrors:r().int(),hardNegatives:r().int(),cells:S(b({macroClass:u(),deviceId:r(),lighting:x([`day`,`night`,`unknown`]),subjects:r().int(),frames:r().int()})).readonly(),cameras:S(b({deviceId:r(),frames:r().int(),completeFrames:r().int()})).readonly()}),SCe=b({id:u(),name:u(),createdAt:r(),selection:IH,layout:CH,completeOnly:v(),frameCount:r().int(),annotationHash:u(),manifestSchema:u(),stats:LH}),RH=b({collectionIds:S(u()).min(1),workState:x([`complete`,`annotated_or_complete`,`any_annotated`]).default(`complete`)}),zH=a(`kind`,[b({kind:m(`resolved`),frameIds:S(u()).max(2e4).readonly(),stats:LH,annotationHash:u(),layout:CH}),b({kind:m(`refused`),reason:x([`unknown-collection`,`no-frames`]),detail:u()})]),BH=b({trackId:u(),retrainStatus:EV,changed:v(),reason:x([`unknown-track`,`no-frames-copied`,`not-staging`,`not-trained`,`unchanged`]).optional()}),VH=1e3,HH=5e3,UH=b({deviceId:r(),since:r().optional(),until:r().optional(),limit:r().int().min(1).max(HH).default(VH),projection:x([`full`,`slim`]).optional()}),CCe=UH.extend({classFilter:u().optional()}),WH=b({deviceIds:S(r()),since:r().optional(),until:r().optional(),limit:r().int().min(1).max(1e3).default(200),cursor:u().optional(),projection:CV.optional(),includeStationary:v().optional(),classes:S(u()).optional(),excludeSources:S(TV).optional()}),GH=b({tracks:S(IV).readonly(),nextCursor:u().nullable()}),KH=50,qH=200,wCe=b({deviceId:r(),since:r(),until:r(),limit:r().int().min(1).max(qH).default(KH),minImportance:r().min(0).max(1).optional(),classFilter:u().optional()}),JH=b({id:u(),trackId:u(),timestamp:r(),className:u(),...MV,importance:r(),bestEventId:u(),windowMs:r().optional(),audioLabels:S(wV).readonly().optional(),...DV,...OV}),TCe=b({deviceIds:S(r()).min(1).max(200),since:r(),until:r(),limit:r().int().min(1).max(qH).default(KH),minImportance:r().min(0).max(1).optional(),classFilter:u().optional()}),ECe=b({deviceId:r(),events:S(JH).readonly()}),YH=b({bucketStart:r(),motion:r().int(),object:r().int(),audio:r().int(),audioDbfs:r().optional()}),XH=b({deviceId:r(),read:x([`read`,`unreadable`]),buckets:S(YH).readonly()}),DCe=b({trackId:u(),className:u(),confidence:r(),bbox:ny,zones:S(u()).readonly(),state:pV}),OCe=le({id:u(),kind:x([`first-level`,`detail`]),macroClass:u(),score:r(),bbox:b({x:r(),y:r(),width:r(),height:r()}),labels:S(le({label:u(),score:r()})).readonly(),parentId:u().optional()}),ZH=HV.extend({score:r()}),kCe=b({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:gd.optional(),modelId:u().min(1).optional()}),QH=b({tracks:r().int(),events:r().int(),media:r().int(),faces:r().int(),plates:r().int(),embeddings:r().int()}),ACe=b({mediaDropped:r().int(),tracks:r().int(),events:r().int()}),jCe=b({deviceId:r(),rows:r().int(),bytes:r().int()}),MCe=b({totalRows:r().int(),totalBytes:r().int(),devices:S(jCe).readonly()}),NCe=b({kind:WV,rows:r().int(),bytes:r().int()}),PCe=b({totalRows:r().int(),totalBytes:r().int(),kinds:S(NCe).readonly(),unaccountedRows:r().int(),unaccountedBytes:r().int()}),$H=b({motion:r().int(),object:r().int(),audio:r().int()}),FCe=b({deviceId:r().optional(),since:r().optional(),until:r().optional(),maxTracks:r().int().positive().optional(),executeOnNodeId:u().optional(),pacingMs:r().int().nonnegative().optional(),force:v().optional()}),ICe=b({deleted:r(),failedIndexes:S(u()).optional()}),eU=x([`stores-unavailable`,...ZB,`method-unavailable`,`read-failed`,`reads-disagree`,`not-a-clip-model`,`force-requires-max-tracks`]),LCe=b({started:v(),alreadyRunning:v(),refusal:eU.optional(),modelId:u().optional(),index:u().optional()}),RCe=b({running:v(),scanned:r(),rebuilt:r(),missingKeyFrame:r(),missingEvent:r(),missingBbox:r(),boxSource:b({subjectBox:r(),positions:r(),event:r(),refused:r()}),alreadyInSpace:r(),force:v().nullable(),forcedInSpace:r(),notRunnable:r(),noCapableNode:r(),failed:r(),complete:v().nullable(),startedAtMs:r().nullable(),finishedAtMs:r().nullable(),error:u().nullable(),modelId:u().nullable(),index:u().nullable()}),zCe=b({started:v(),alreadyRunning:v()}),BCe=b({mode:x([`report`,`reclaim`]).default(`report`),scopes:S(x([`motion-still`,`track-filmstrip`])).min(1).optional(),deviceIds:S(r().int()).min(1).optional(),restart:v().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()}),VCe=b({running:v(),mode:x([`report`,`reclaim`]).nullable(),totalExamined:r(),totalEligible:r(),totalReclaimed:r(),totalBytesReclaimed:r(),totalRefused:r(),devicesDone:r(),complete:v().nullable(),startedAtMs:r().nullable(),finishedAtMs:r().nullable(),error:u().nullable()}),tU=x([`motion`,`audio-dbfs`,`battery`,`occupancy`]);function HCe(e,t){let n=e??``;return t===void 0?n:`${n}|${t}`}function nU(e){let t=e.indexOf(`|`);return t<0?{zoneId:e}:{zoneId:e.slice(0,t),className:e.slice(t+1)}}var rU=b({scope:u(),bucketStart:r().int(),samples:r().int().nonnegative(),sum:r(),min:r(),max:r()}),iU={name:`pipeline-analytics`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{getActiveTracks:E(b({deviceId:r()}),S(IV).readonly()),getTrack:E(b({deviceId:r(),trackId:u()}),IV.nullable()),listTracks:E(b({deviceId:r(),since:r().optional(),until:r().optional(),limit:r().optional(),zone:hV.optional(),projection:CV.optional(),includeStationary:v().optional(),classes:S(u()).optional(),excludeSources:S(TV).optional()}),S(IV).readonly()),listRecentTracks:E(WH,GH),clearTracks:E(b({deviceId:r()}),_(),{kind:`mutation`,auth:`admin`}),getMotionEvents:E(UH,S(RV).readonly()),getObjectEvents:E(CCe,S(HV).readonly()),getAudioEvents:E(UH,S(UV).readonly()),listEventKinds:E(b({deviceId:r()}),S(vV).readonly()),listEventKindsBatch:E(b({deviceIds:S(r()).min(1).max(200)}),S(yV).readonly()),getSensorEvents:E(b({deviceId:r(),since:r().optional(),until:r().optional(),kinds:S(u()).optional(),limit:r().int().min(1).max(HH).default(VH)}),S(bV).readonly()),getKeyEvents:E(wCe,S(JH).readonly()),getKeyEventsBatch:E(TCe,S(ECe).readonly()),readLongTermSeries:E(b({deviceId:r(),series:tU,scope:u().optional(),from:r(),to:r(),limit:r().int().positive().optional()}),S(rU).readonly()),getEventDensity:E(b({deviceId:r(),since:r(),until:r(),bucketMs:r().int().positive()}),S(YH).readonly()),getEventDensityBatch:E(b({deviceIds:S(r()).min(1).max(200),since:r(),until:r(),bucketMs:r().int().positive()}),S(XH).readonly()),pruneEventsBefore:E(b({deviceId:r(),cutoffMs:r()}),b({motion:r().int(),object:r().int(),audio:r().int()}),{kind:`mutation`,auth:`admin`}),pruneTracksBefore:E(b({deviceId:r(),cutoffMs:r()}),QH,{kind:`mutation`,auth:`admin`}),wipeAllAnalytics:E(b({deviceId:r()}),QH,{kind:`mutation`,auth:`admin`}),reconcileFromDisk:E(b({deviceId:r()}),ACe,{kind:`mutation`,auth:`admin`}),deleteTracks:E(b({deviceId:r(),trackIds:S(u()).min(1)}),b({deleted:r().int(),failed:S(u()).readonly(),sparedMediaIds:S(r().int()).readonly().optional()}),{kind:`mutation`,auth:`admin`}),setTrackFlags:E(b({deviceId:r(),trackId:u(),flags:kV}),AV,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listArchivedDebugNotes:E(Ds,S(Es).readonly(),{kind:`query`}),setTrackRelation:E(Ns,js,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),clearTrackRelation:E(Ps,Fs,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),setTrackPurity:E(Is,Ls,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listTrackRelations:E(Rs,zs,{kind:`query`}),listBirthDecisions:E(Ts,S(ws).readonly(),{kind:`query`}),getEventStoreFootprint:E(b({}),MCe,{kind:`query`,auth:`admin`}),getEventMediaFootprintByKind:E(b({deviceId:r().int().optional()}),PCe,{kind:`query`,auth:`admin`}),pruneEvents:E(b({olderThanMs:r(),reason:qs.optional()}),$H,{kind:`mutation`,auth:`admin`}),deleteDeviceEvents:E(b({deviceId:r()}),$H,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:E(Yc,b({paused:m(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:E(Yc,b({resumed:m(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:E(Yc,b({refreshed:m(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:E(il,b({jobId:u()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:E(b({jobId:u()}),Kc.nullable(),{auth:`admin`}),cancelStorageMigrationMove:E(b({jobId:u()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),relocateMedia:E(Qc,b({jobId:u()}),{kind:`mutation`,auth:`admin`}),countUnstampedEventMedia:E(b({}),el,{auth:`admin`}),getMediaLocationCensus:E(tl,rl,{kind:`query`,auth:`admin`}),countRelocatableMedia:E(Al,kl,{kind:`query`,auth:`admin`}),listRelocateMediaJobs:E(b({}),S(Kc).readonly(),{kind:`query`,auth:`admin`}),cancelRelocateMedia:E(b({jobId:u()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),listOpsLog:E(Ys,S(Js).readonly(),{kind:`query`,auth:`admin`}),reclaimDebugMedia:E(BCe,zCe,{kind:`mutation`,auth:`admin`}),getMediaReclaimStatus:E(b({}),VCe,{kind:`query`,auth:`admin`}),getTrainingExportSummary:E(b({deviceIds:S(r()).optional()}),PV,{kind:`query`,auth:`admin`}),getTrainingExportUrl:E(b({deviceIds:S(r()).optional()}),b({url:u()}),{kind:`query`,auth:`admin`}),listRetrainStaging:E(b({deviceIds:S(r()).optional(),limit:r().int().min(1).max(500).optional()}),S(cH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainCorpusPage:E(_H,yH,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getRetrainCorpusKpi:E(b({}),xH,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainFrames:E(b({trackId:u()}),hH,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),selectRetrainFrames:E(b({deviceId:r(),trackId:u(),mediaIds:S(r().int()).min(1)}),mH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deselectRetrainFrame:E(b({deviceId:r(),trackId:u().optional(),frameId:u()}),b({removed:v(),removedAnnotations:r().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainFrameImage:E(b({frameId:u()}),b({base64:u(),width:r().int(),height:r().int()}),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotations:E(b({deviceId:r(),trackId:u().optional(),frameId:u(),subject:EH,nodeId:u().optional()}),DH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainAnnotations:E(b({trackId:u().optional(),frameIds:S(u()).max(2e3).optional()}),S(rH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),saveRetrainAnnotations:E(b({deviceId:r(),trackId:u().optional(),frameId:u(),annotations:S(iH),expectedRevision:r().int().optional(),dismissed:S($V).optional()}),S(rH).readonly(),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),backfillRetrainOrigins:E(b({deviceId:r(),trackId:u().optional(),frameId:u(),expectedRevision:r().int().optional(),origins:S(b({annotationId:u(),origin:QV})).min(1).max(500)}),b({updated:r().int(),skipped:r().int(),revision:r().int()}),{kind:`mutation`,auth:`admin`}),completeRetrainTrack:E(b({deviceId:r(),trackId:u()}),BH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),restageRetrainTrack:E(b({deviceId:r(),trackId:u()}),BH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainExportUrl:E(SH.extend({layout:CH.optional()}),b({url:u()}),{kind:`query`,auth:`admin`}),setRetrainFrameComplete:E(b({deviceId:r(),trackId:u().optional(),frameId:u(),complete:v()}),fH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),writeRetrainArchive:E(b({filter:SH,layout:CH,target:wH}),TH,{kind:`mutation`,auth:`admin`,timeoutMs:60*6e4}),offerRetrainArchive:E(b({filter:SH,layout:CH}),b({ticket:Xa,frames:r().int(),annotations:r().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),listRetrainAssistProfiles:E(b({}),S(MH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotationsWithLlm:E(b({deviceId:r(),trackId:u().optional(),frameId:u(),profileId:u(),classes:S(JV).min(1),boxes:S(b({ref:u(),bbox:ZV,macroClass:JV,label:u().optional()})).max(50),allowCloud:v()}),FH,{kind:`mutation`,auth:`admin`,timeoutMs:18e4}),createRetrainCollection:E(b({name:u().max(120)}),kH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollections:E(b({}),S(OH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),resolveRetrainTrainingCorpus:E(RH,zH,{kind:`query`,auth:`admin`,timeoutMs:6e4}),renameRetrainCollection:E(b({id:u(),name:u().max(120)}),AH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deleteRetrainCollection:E(b({id:u()}),b({deleted:v(),removedFrames:r().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),addRetrainFrameFromRecording:E(b({collectionId:u(),deviceId:r(),epochMs:r(),verdictSubject:sH.optional()}),jH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`,timeoutMs:6e4}),addRetrainFramesToCollection:E(b({collectionId:u(),frameIds:S(u()).min(1).max(500)}),b({added:r().int(),alreadyMember:r().int(),unknownFrameIds:S(u()).readonly()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),removeRetrainFrameFromCollection:E(b({collectionId:u(),frameId:u()}),b({removed:v(),deletedFrame:v()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollectionFrames:E(b({collectionId:u()}),S(fH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getEventMedia:E(b({ownerType:Xe,eventId:r().int(),kind:WV.optional(),deviceId:r()}),S(KV).readonly()),getTrackMedia:E(b({trackId:u(),kinds:S(WV).optional(),deviceId:r()}),S(KV).readonly()),listTrackMedia:E(b({trackId:u(),deviceId:r()}),S(qV).readonly()),listEventMedia:E(b({ownerType:Xe,eventId:r().int(),deviceId:r()}),S(qV).readonly()),ownersWithMedia:E(b({deviceId:r(),ownerKind:Qe,ownerIds:S(u()).max(5e3)}),S(u()).readonly()),searchObjectEvents:E(kCe,S(ZH).readonly(),{caller:`required`}),wipeObjectEmbeddings:E(b({}),ICe,{kind:`mutation`,auth:`admin`}),rebuildObjectEmbeddings:E(FCe,LCe,{kind:`mutation`,auth:`admin`}),getObjectEmbeddingRebuildStatus:E(b({}),RCe)},events:{onFrameTracked:{data:b({deviceId:r(),timestamp:r(),frameWidth:r(),frameHeight:r(),detections:S(OCe).readonly()}),notOperatorFacing:`one tracker frame — stream rate, never an automation trigger`},onTrackStarted:{data:b({deviceId:r(),trackId:u(),className:u()}),trigger:{category:w.PipelineAnalyticsTrackStarted,label:I(`Subject appeared`,`Soggetto comparso`),phrase:I(`When {device} starts following a subject`,`Quando {device} inizia a seguire un soggetto`),icon:`scan-eye`}},onTrackEnded:{data:b({deviceId:r(),trackId:u(),className:u(),durationMs:r()}),trigger:{category:w.PipelineAnalyticsTrackEnded,label:I(`Subject left`,`Soggetto uscito`),phrase:I(`When a subject leaves the view of {device}`,`Quando un soggetto esce dall’inquadratura di {device}`),icon:`scan-eye`}},onDetectionEvent:{data:b({deviceId:r(),kind:mV,eventId:u(),timestamp:r()}),trigger:{category:w.PipelineAnalyticsDetectionEvent,label:I(`Detection event`,`Evento di rilevamento`),phrase:I(`When {device} records a detection event`,`Quando {device} registra un evento di rilevamento`),icon:`radar`}}},vocabulary:{noun:I(`Tracking`,`Tracciamento`),order:3200,extraEvents:[{category:w.PipelineAnalyticsPackageDelivered,label:I(`Package delivered`,`Pacco consegnato`),phrase:I(`When a package is left in front of {device}`,`Quando viene lasciato un pacco davanti a {device}`),icon:`package`},{category:w.PipelineAnalyticsPackagePickedUp,label:I(`Package picked up`,`Pacco ritirato`),phrase:I(`When a package is picked up in front of {device}`,`Quando viene ritirato un pacco davanti a {device}`),icon:`package-open`}]}},aU=o(()=>b({addonId:u(),modelId:u().optional(),enabled:v().default(!0),children:S(aU).optional(),settings:h(u(),C()).optional(),jumpDeviceKey:u().optional()})),oU=be(),sU=b({x:r(),y:r(),w:r(),h:r()}),cU=b({stepId:u(),modelId:u(),detections:S(b({bbox:d([r(),r(),r(),r()]),score:r(),landmarks:S(b({x:r(),y:r()})).optional()})).min(1)}),lU=b({handle:mc,cropFrameSpace:b({x:r(),y:r(),w:r(),h:r()})});b({crop:b({left:r(),top:r(),width:r().positive(),height:r().positive()}).optional(),content:b({width:r().int().positive(),height:r().int().positive()}),fit:x([`stretch`,`contain`]),format:x([`rgb`,`gray`,`jpeg`])});var UCe=b({registryId:u().min(1),id:u().min(1),width:r().int().positive(),height:r().int().positive(),format:x([`rgb`,`gray`]),timestamp:r(),capturedAt:r().optional()}),uU=x([`onnx`,`coreml`,`openvino`,`tflite`,`pt`,`gguf`]),dU=x([`detector`,`cropper`,`classifier`,`refiner`,`audio-classifier`]),fU=b({runtime:m(`python`),backend:u(),format:uU,device:u().optional()}),pU=b({deviceKey:u().nullable(),runtime:u(),batchMode:u(),windowMs:r(),maxBatchSize:r(),concurrency:r(),numWorkers:r()}),WCe=b({engine:fU,devices:S(b({id:u(),label:u(),description:u().optional()})).readonly(),defaultDevice:u()}),mU=o(()=>b({addonId:u(),addonName:u(),slot:dU,inputClasses:S(u()).readonly(),outputClasses:S(u()).readonly(),enabled:v(),modelId:u(),children:S(mU).readonly(),group:u().optional(),settings:h(u(),C()).optional()})),GCe=b({id:u(),name:u(),formats:h(u(),Vd),group:Wd.optional(),legacy:v().optional(),provider:Kd.optional(),defaultConfidence:r().optional(),suppliesSteps:S(Yd).readonly().optional()}),KCe=be(),qCe=b({id:u(),name:u(),slot:dU,inputClasses:S(u()).readonly(),outputClasses:S(u()).readonly(),childSlots:S(dU).readonly(),models:S(GCe).readonly(),defaultModelId:u(),defaultModelIdByFormat:h(u(),u()).optional(),enabledByDefault:v().optional(),defaultConfidence:r(),group:u().optional(),configSchema:S(KCe).readonly().optional()}),JCe=b({id:dU,label:u(),priority:r(),parentSlot:dU.nullable(),addons:S(qCe).readonly()}),YCe=b({availableEngines:S(WCe).readonly(),selectedEngine:fU,slots:S(JCe).readonly()}),XCe=b({runtimeId:x([`onnx`,`openvino`,`coreml`,`edgetpu`]).nullable(),device:u().nullable(),state:x([`idle`,`installing`,`verifying`,`ready`,`failed`]),progress:r().optional(),error:u().optional(),nextRetryAt:r().optional(),configIssues:S(u()).optional()}),hU=b({addonId:u(),chosen:u(),running:u(),format:u()}),gU=b({addonId:u(),kind:x([`unknown-addon`,`no-format-build`,`unknown-device`]),detail:u()}),_U=b({ok:v(),issues:S(gU).readonly(),substitutions:S(hU).readonly(),format:u()}),ZCe=b({filename:u(),stepIds:S(u()).readonly().optional()}),QCe=b({base64:u(),filename:u()}),$Ce=b({filename:u(),sizeKb:r()}),ewe=b({base64:u()}),twe=b({id:u(),name:u(),description:u(),available:v(),rawLabels:S(u()).readonly().optional()}),nwe=b({activeBackend:u(),availableBackends:S(twe).readonly(),sampleRate:r(),chunkDurationMs:r()}),rwe=b({filePath:u(),sizeMB:r(),durationMs:r()}),iwe=b({success:v(),error:u().optional(),frame:be().optional()}),awe=be(),owe=be(),swe=be(),cwe=be(),vU={name:`pipeline-executor`,scope:`system`,mode:`singleton`,methods:{getAvailableEngines:E(_(),S(fU)),getSelectedEngine:E(_(),fU),getEngineProvisioning:E(b({nodeId:u()}),XCe),getVideoPipelineSteps:E(_(),h(u(),b({modelId:u(),settings:h(u(),C()).readonly()}))),setVideoPipelineSteps:E(b({steps:h(u(),b({modelId:u(),settings:h(u(),C()).readonly()}))}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getInferenceDeviceHealth:E(b({nodeId:u()}),b({unhealthy:S(b({deviceKey:u(),state:x([`failed`,`backoff`]),since:r(),deaths:r(),lastError:u()})).readonly()})),rearmInferenceDevice:E(b({nodeId:u(),deviceKey:u()}),b({rearmed:v()}),{kind:`mutation`,auth:`admin`}),getSchema:E(_(),YCe),getOrchestratorConfigSchema:E(_(),awe),validatePipeline:E(b({steps:S(aU),deviceKey:u().optional()}),_U),getCapabilities:E(_(),swe),getAddonModels:E(b({addonId:u()}),cwe),downloadModel:E(b({addonId:u(),modelId:u(),format:uU}),rwe,{kind:`mutation`}),deleteModel:E(b({addonId:u(),modelId:u(),format:uU}),b({success:m(!0)}),{kind:`mutation`}),runPipeline:E(b({steps:S(aU).min(1),frame:ty.optional(),frameRef:UCe.optional(),frameHandle:mc.optional(),imageBase64:u().optional(),image:y(Uint8Array).optional(),referenceImage:u().optional(),deviceId:r().optional(),sessionId:u().optional(),plane:x([`full`,`frame`]).optional(),deviceKey:u().optional(),nativeCropRef:lU.optional(),replay:m(!0).optional(),suppliedRoot:cU.optional(),motionRegions:S(sU).optional()}),oU,{kind:`mutation`}),runPipelineBatch:E(b({steps:S(aU).min(1),frames:S(ty).min(1).max(255),deviceId:r().optional(),sessionId:u().optional(),frameId:r().int().nonnegative().optional(),deviceKey:u().optional()}),b({results:S(oU).readonly()}),{kind:`mutation`}),cacheFrameInPool:E(b({data:y(Uint8Array),width:r().int().positive(),height:r().int().positive(),format:x([`rgb`,`bgr`,`gray`])}),b({frameId:r(),width:r(),height:r()}),{kind:`mutation`}),inferCached:E(b({stepId:u(),frameId:r().int(),modelId:u().min(1)}),h(u(),C()),{kind:`mutation`}),uncacheFrame:E(b({frameId:r().int()}),_(),{kind:`mutation`}),getEffectiveTuning:E(b({deviceKey:u().optional()}),pU),listLoadedEngines:E(_(),S(b({engineKey:u(),engine:fU,modelsLoaded:S(u()).readonly(),inUseByCameras:S(r()).readonly(),kind:x([`runtime`,`device-pool`]),poolPid:r().nullable(),idleMs:r().nullable(),idleTtlMs:r().nullable()})).readonly()),spinEngine:E(b({engine:fU}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),killEngine:E(b({engine:fU,force:v().optional()}),b({success:v(),reason:u().optional()}),{kind:`mutation`,auth:`admin`}),listReferenceImages:E(_(),S(ZCe).readonly()),getReferenceImage:E(b({filename:u()}),QCe.nullable()),getReferenceAudioFiles:E(_(),S($Ce).readonly()),getReferenceAudio:E(b({filename:u()}),ewe.nullable()),getAudioCapabilities:E(_(),nwe),runAudioTest:E(b({addonId:u(),modelId:u(),filename:u().optional(),settings:h(u(),C()).optional()}),iwe,{kind:`mutation`}),getDetectionConfigSchema:E(_(),owe)},vocabulary:{notOperatorFacing:O.PIPELINE}},lwe=b({activeCameras:r(),throttledCameras:r(),avgInferenceTimeMs:r(),queueDepth:r()}),yU=b({detectionMode:x([`disabled`,`always-on`,`on-motion`]),configuredFps:r(),actualFps:r(),queueDepth:r(),avgInferenceTimeMs:r(),droppedFrames:r(),nativeCropMisses:r().optional(),phase:x([`idle`,`watching`,`active`])}),bU=yU.extend({deviceId:r()}),xU=x([`polygon`,`tripwire`]),SU=b({x:r(),y:r()}),CU=b({id:u(),name:u(),kind:xU.default(`polygon`),polygon:S(SU).readonly(),color:u().default(`#3b82f6`)}),wU={name:`zones`,scope:`device`,mode:`singleton`,deviceTypes:[j.Camera],methods:{listZones:E(b({deviceId:r()}),S(CU).readonly()),addZone:E(b({deviceId:r(),zone:CU}),_(),{kind:`mutation`,auth:`admin`}),removeZone:E(b({deviceId:r(),zoneId:u()}),_(),{kind:`mutation`,auth:`admin`}),updateZone:E(b({deviceId:r(),zone:CU}),_(),{kind:`mutation`,auth:`admin`})},runtimeState:b({zones:S(CU).readonly()}),durability:`restored`,history:`none`,vocabulary:{noun:I(`Zones`,`Zone`),order:3370}},TU={fpsPerStream:10,budgetMinutes:45,minBudgetMinutes:10,maxBudgetMinutes:120,staleAfterDays:30,settleSec:5,measureSec:20,drainTimeoutSec:120,maxModelsPerDevice:6},EU=x([`device`,`pipeline`]),DU=b({deviceKey:u().min(1),modelIds:S(u().min(1)).min(1).max(TU.maxModelsPerDevice)}),OU=b({nodeId:u().min(1),devices:S(DU).min(1),phases:S(EU).min(1).default([`device`,`pipeline`]),steps:S(u().min(1)).default([]),fpsPerStream:r().int().min(1).max(30).default(TU.fpsPerStream),budgetMinutes:r().int().min(TU.minBudgetMinutes).max(TU.maxBudgetMinutes).default(TU.budgetMinutes),keepDownloadedModels:v().default(!1),acceptInsufficientHeadroom:v().default(!1)}),kU=x([`benchmark-active`,`node-offline`,`unknown-device`,`no-phase`,`insufficient-headroom`]),AU=b({kind:kU,detail:u(),overridable:v()}),jU=b({deviceId:r(),placedOnNode:v(),pinnedToNode:v()}),MU=b({deviceId:r(),reason:m(`only-frame-source`)}),NU=b({nodeId:u(),online:v(),moving:S(jU).readonly(),staying:S(MU).readonly(),estimatedDurationMs:r(),budgetMs:r(),phases:S(EU).readonly(),steps:S(u()).readonly(),devices:S(DU).readonly(),headroom:b({sessionsNow:r(),otherNodesCapacitySessions:r().nullable()}),refusals:S(AU).readonly(),canStart:v()}),PU=b({phase:x([`preparing`,`device`,`pipeline`,`cleanup`]),deviceKey:u().nullable(),modelId:u().nullable(),load:r().nullable(),cellsDone:r(),cellsTotal:r(),message:u()}),FU=x([`p95`,`drops`,`errors`,`stall`,`cpu`,`ram`,`none`]),IU=b({load:r(),pass:v(),p95Ms:r(),dropRatio:r(),fps:r(),cpuPct:r().nullable(),ramFreePct:r().nullable(),failReasons:S(u()).readonly()}),LU=b({phase:m(`device`),deviceKey:u(),modelId:u(),p50Ms:r(),p95Ms:r(),p99Ms:r(),fps:r(),kMax:r(),limitedBy:FU,warmupMs:r(),ramp:S(IU).readonly()}),RU=b({phase:m(`pipeline`),deviceKey:u(),modelId:u(),steps:S(u()).readonly(),maxSessions:r(),limitedBy:FU,stepsFired:S(u()).readonly(),warmupMs:r(),ramp:S(IU).readonly()}),zU=a(`phase`,[LU,RU]),BU=b({pipelineVersion:u().nullable(),cpuModel:u().nullable(),ramGb:r().nullable(),os:u().nullable(),pools:h(u(),b({runtime:u(),numWorkers:r(),concurrency:r(),batchMode:u()})).default({})}),VU=b({id:u(),revision:u().nullable(),frames:r(),width:r(),height:r()}),HU=b({runId:u().min(1),devices:S(DU).min(1),phases:S(EU).min(1),steps:S(u()).default([]),fpsPerStream:r().int().min(1).max(30),deadlineAtMs:r(),settleSec:r().min(0).max(60).default(TU.settleSec),measureSec:r().min(2).max(300).default(TU.measureSec),keepDownloadedModels:v().default(!1)}),UU=x([`running`,`done`,`failed`,`aborted`]),WU=b({runId:u(),nodeId:u(),state:UU,progress:PU.nullable(),cells:S(zU).readonly(),fingerprint:BU.nullable(),clip:VU.nullable(),activeCameraIds:S(r()).readonly(),deletedModels:S(u()).readonly(),error:u().nullable(),startedAtMs:r(),finishedAtMs:r().nullable()}),GU=x([`draining`,`measuring`,`restoring`,`done`,`failed`,`aborted`]),KU=x([`completed`,`operator-abort`,`deadline`,`node-lost`,`runner-lost`,`hub-restart`,`drain-timeout`,`failed`]),qU=b({runId:u(),nodeId:u(),state:GU,plan:OU,startedAtMs:r(),deadlineAtMs:r(),finishedAtMs:r().nullable(),endReason:KU.nullable(),error:u().nullable(),moved:S(r()).readonly(),staying:S(r()).readonly(),contaminated:v(),progress:PU.nullable(),resultIds:S(u()).readonly()}),JU=b({modeNodeId:u().nullable(),run:qU.nullable()}),YU=b({id:u(),runId:u(),nodeId:u(),cell:zU,fpsPerStream:r(),fingerprint:BU.nullable(),clip:VU.nullable(),contaminated:v(),stayingCameras:S(r()).readonly(),partialRun:v(),measuredAtMs:r()}),XU=b({nodeId:u().optional(),deviceKey:u().optional()}),ZU=YU.extend({standing:x([`fresh`,`stale`,`superseded`]),staleWhy:x([`age`,`runtime`,`pool-tuning`]).nullable()}),uwe=b({runId:u(),nodeId:u(),startedAtMs:r(),deadlineAtMs:r(),plan:OU,moved:S(r()).readonly(),staying:S(r()).readonly()}),QU=b({nodeId:u(),reachable:v(),devices:S(b({deviceKey:u(),enabled:v(),available:v(),suggested:S(u()).readonly(),all:S(u()).readonly(),currentModelId:u().nullable()})).readonly(),steps:S(b({id:u(),name:u(),slot:u()})).readonly()}),$U=b({x:r(),y:r(),w:r(),h:r()}),eW=b({bytes:y(Uint8Array).optional(),jpeg:u().optional(),jpegBytes:y(Uint8Array).optional(),width:r().int().positive(),height:r().int().positive(),tier:x([`native`,`ram-fullframe`]).optional()}),tW=x([`keyFrame`,`thumbnail`]),nW=x([`handle-gone`,`encode-failed`]),rW=a(`parked`,[b({parked:m(!0),nodeId:u(),width:r().int().positive(),height:r().int().positive(),bytes:r().int().nonnegative(),replaced:v()}),b({parked:m(!1),nodeId:u(),reason:nW,handleAgeMs:r().nullable(),detail:u().optional()})]),iW=b({jpeg:u().optional(),jpegBytes:y(Uint8Array).optional(),width:r().int().positive(),height:r().int().positive(),timestamp:r(),parkedAt:r()}),dwe=b({bbox:$U,className:u()}),aW=b({stepId:u(),className:u(),score:r(),bbox:$U.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:S(b({x:r(),y:r()})).optional()}),fwe=x([`unknown-step`,`model-not-servable`,`unreadable-frame`,`execution-failed`]),pwe=a(`kind`,[b({kind:m(`ran`),nodeId:u(),modelId:u(),details:S(aW)}),b({kind:m(`refused`),nodeId:u(),reason:fwe,detail:u()})]),oW={min:0,max:6e4,default:3e4,step:500},sW={min:0,max:6e5,default:12e4,step:5e3},cW={min:5e3,max:6e5,default:9e4,step:5e3},lW={min:1,max:30,default:4,step:1},uW={min:1,max:30,default:10,step:1},dW={min:0,max:300,default:300,step:5},fW={min:1,max:10,default:4,step:1},pW={min:0,max:30,default:12,step:1},mW=x([`onboard`,`analyzer`,`device-activity`]),hW=b({source:mW,triggeredBy:CB,sensorName:u().optional()}),gW=S(mW),_W={analyzer:`Frame-diff Analyzer (motion addon)`,onboard:`Camera sensors`,"device-activity":`Device activity (the device says it is working)`};function vW(e){let t=mW.safeParse(e);return t.success?_W[t.data]:e}var mwe=[`analyzer`,`onboard`,`device-activity`],yW=p(e=>Array.isArray(e)&&e.length>1?e.slice(0,1):e,S(zV).max(1)),bW=b({deviceId:r(),detected:v(),source:mW.default(`analyzer`),regions:S(zB).readonly().optional()}),xW=a(`kind`,[b({kind:m(`local-broker`)}),b({kind:m(`remote-restream`),ownerNodeId:u(),ownerReachableHost:u().optional(),hubHostnameOverride:u().optional()})]).describe(`Per-camera frame-source mode for the runner (P2c)`),SW=b({modelId:u().optional(),settings:h(u(),C()).optional()}),CW=b({deviceKey:u(),weight:r().positive().default(1),maxSessions:r().int().positive().nullable().default(null),steps:h(u(),SW).optional(),disabledSteps:S(u()).readonly().optional()}),wW=b({deviceId:r(),detectionMode:x([`disabled`,`always-on`,`on-motion`]).default(`on-motion`),audioMode:x([`disabled`,`always-on`,`on-motion`]).default(`always-on`),motionCooldownMs:r().min(oW.min).default(oW.default),maxSessionHoldMs:r().min(sW.min).max(sW.max).optional(),audioMotionWindowMs:r().min(cW.min).max(cW.max).optional(),motionFps:r().min(lW.min).max(lW.max).default(lW.default),detectionFps:r().min(uW.min).max(uW.max).default(uW.default),motionStreamId:u(),detectionStreamId:u(),audioStreamPick:ac.optional(),motionSources:gW.default([`analyzer`]),sessionTrigger:hW.optional(),detectionSources:yW.default([`pipeline`]),pipelineEnabled:v().default(!0),steps:S(aU).readonly().optional(),audio:b({modelId:u().optional(),enabled:v()}).nullable().optional(),zones:S(CU).readonly().default([]),onboardMotionDrivesAnalyzer:v().default(!0),preRollInferenceEnabled:v().default(!0),preRollInferenceFrames:r().min(pW.min).max(pW.max).default(pW.default),occupancyRecheckEnabled:v().default(!0),occupancyRecheckSec:r().min(dW.min).max(dW.max).default(dW.default),occupancyRecheckFrames:r().min(fW.min).max(fW.max).default(fW.default),frameSource:xW.default({kind:`local-broker`}),deviceKey:u().optional(),inferenceDevices:S(CW).readonly().optional()}),hwe=[{key:`motionSources`,type:`multiselect`,label:`Motion Sources`,default:[`analyzer`],options:mwe.map(e=>e===`onboard`?{value:e,label:_W[e],description:`The camera's own motion, plus any sensor attached to it`}:{value:e,label:_W[e]})},{key:`motionFps`,type:`slider`,label:`Motion FPS (analyzer)`,min:lW.min,max:lW.max,step:lW.step,default:lW.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:oW.min,max:oW.max,step:oW.step,default:oW.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:sW.min,max:sW.max,step:sW.step,default:sW.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:cW.min,max:cW.max,step:cW.step,default:cW.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:pW.min,max:pW.max,step:pW.step,default:pW.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:dW.min,max:dW.max,step:dW.step,default:dW.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:fW.min,max:fW.max,step:fW.step,default:fW.default,showValue:!0,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}}],TW=b({nodeId:u(),attachedCameras:r(),activeCameras:r(),avgInferenceFps:r(),avgInferenceTimeMs:r(),queueDepthTotal:r(),devices:S(b({deviceKey:u(),backend:u(),attachedCameras:r()})).default([]),hardware:b({hasGpu:v(),inferenceBackend:u().optional(),cpuCores:r().optional()}),motionSliceWriter:m(`orchestrator`).optional()}),EW=b({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()}),DW=b({node:EW,cameras:S(EW.extend({deviceId:r()}))}),OW=b({nodeId:u(),activeCameras:r(),throttledCameras:r(),avgInferenceTimeMs:r(),queueDepth:r(),frameLazy:DW.optional()}),kW=x([`not-attached`,`battery-asleep`,`not-watching`,`already-bursting`]),AW={name:`pipeline-runner`,scope:`system`,mode:`singleton`,methods:{attachCamera:E(wW,b({success:m(!0)}),{kind:`mutation`}),detachCamera:E(b({deviceId:r()}),b({success:m(!0)}),{kind:`mutation`}),reportMotion:E(bW,b({success:m(!0)}),{kind:`mutation`}),getLocalLoad:E(_(),TW),getLocalMetrics:E(_(),OW),getCameraMetrics:E(b({deviceId:r()}),yU.nullable()),getAllCameraMetrics:E(_(),S(bU).readonly()),getLocalCameras:E(_(),S(r()).readonly()),requestOccupancyBurst:E(b({deviceId:r(),frames:r().int().positive().optional(),reason:u()}),b({started:v(),refusedBecause:kW.optional()}),{auth:`admin`,kind:`mutation`}),getNativeCrop:E(b({handle:mc,bbox:$U,maxWidth:r().int().positive().optional(),acceptJpegBytes:v().optional(),encodeJpeg:v().optional()}),eW.nullable()),runDetailSubtree:E(b({deviceId:r(),frameHandle:mc.optional(),frameJpeg:u().optional(),cropJpeg:u().optional(),parent:dwe,steps:S(u()).optional(),supplied:b({stepId:u(),modelId:u(),boxes:S(b({bbox:$U,score:r()})).min(1)}).optional()}),b({details:S(aW)}).nullable(),{kind:`mutation`}),runStatelessStep:E(b({stepId:u(),modelId:u(),frameJpeg:u(),bbox:$U,className:u(),sourceDeviceId:r()}),pwe,{kind:`mutation`}),parkTrackFrame:E(b({deviceId:r(),trackId:u(),kind:tW,handle:mc,bbox:$U,maxWidth:r().int().positive().optional(),timestamp:r()}),rW,{kind:`mutation`}),getParkedTrackFrame:E(b({deviceId:r(),trackId:u(),kind:tW,acceptJpegBytes:v().optional()}),iW.nullable()),releaseParkedTrackFrames:E(b({deviceId:r(),trackId:u()}),b({released:r().int().nonnegative()}),{kind:`mutation`}),startNodeBench:E(HU,b({accepted:m(!0),runId:u()}),{kind:`mutation`,auth:`admin`}),getNodeBenchStatus:E(b({runId:u()}),WU.nullable(),{auth:`admin`}),abortNodeBench:E(b({runId:u()}),b({aborted:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},jW=3e4,gwe={version:1,targets:[{id:`detected`,cardinality:`event`,shape:`span`,vocabulary:{cap:`motion`,eventName:`onMotionChanged`},deviceTypes:[j.Camera],apply:`add`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:jW,combine:`any`,sourceModes:[`in-addition`,`confirm`,`replace`],sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},_we=15e3,MW=b({detected:v(),lastDetectedAt:r().nullable(),autoClearAfterMs:r().nullable().meta(k(`duration-ms`))}),NW=b({deviceId:r(),detected:v(),timestamp:r(),source:mW,regions:S(zB).readonly().optional(),triggeredBy:CB.optional()}),PW={name:`motion`,scope:`device`,mode:`singleton`,deviceNative:!0,deviceTypes:[j.Camera,j.Sensor],methods:{isDetected:E(b({deviceId:r()}),v())},composedMethods:{isDetected:{kind:`slice`,field:`detected`}},events:{onMotionChanged:{data:NW,notOperatorFacing:"the `detected` state trigger phrases both edges, from the mirror that survives a dropped event (D49)"}},status:{schema:MW,kind:`push`},runtimeState:MW,durability:`session`,history:{fields:{detected:{kind:`boolean`,excludeDeviceTypes:[j.Camera]}}},customize:gwe,vocabulary:{noun:I(`Motion`,`Movimento`),order:5130,state:[{kind:`boolean`,field:`detected`,label:I(`Motion`,`Movimento`),whenTrue:I(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:I(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}]}},FW=b({enabled:v(),lastChangedAt:r()}),IW=FW.extend({lastFetchedAt:r()}),LW={name:`motion-trigger`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Light,j.Siren,j.Switch],methods:{setMotionTrigger:E(b({deviceId:r().int().nonnegative(),enabled:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`motionTrigger.on`,label:I(`Motion trigger on`,`Attivazione al movimento attiva`),phrase:I(`Let motion trigger {device}`,`Fai attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!0},args:{enabled:!0}},{id:`motionTrigger.off`,label:I(`Motion trigger off`,`Attivazione al movimento spenta`),phrase:I(`Stop motion triggering {device}`,`Non far più attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!1},args:{enabled:!1}}]})},events:{onMotionTriggerChanged:{data:b({deviceId:r(),enabled:v(),lastChangedAt:r()}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:FW,kind:`command-driven`},runtimeState:IW,durability:`session`,history:`none`,vocabulary:{noun:I(`Motion trigger`,`Attivazione al movimento`),order:1160,state:[{kind:`boolean`,field:`enabled`,label:I(`Motion trigger`,`Attivazione al movimento`),whenTrue:I(`When motion triggering is turned on for {device}`,`Quando si attiva l’attivazione al movimento di {device}`),whenFalse:I(`When motion triggering is turned off for {device}`,`Quando si disattiva l’attivazione al movimento di {device}`),icon:`activity`}]}},RW=b({id:r(),enabled:v(),shape:KB}),zW=b({enabled:v(),sensitivity:r().meta(k(`none`)),regions:S(RW),lastFetchedAt:r()}),BW=b({maxRegions:r(),supportedShapes:S(JB),grid:XB,sensitivity:b({min:r(),max:r(),step:r()})}),VW=b({enabled:v().optional(),sensitivity:r().optional(),regions:S(RW).optional()}),HW={name:`motion-zones`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/motion-zones-grid`,tab:`motion`,label:`Motion Zones`}},methods:{getOptions:E(b({deviceId:r()}),BW),setZone:E(b({deviceId:r(),patch:VW}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:zW,kind:`poll`},runtimeState:zW,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Motion zones`,`Zone di movimento`),order:3170}},vwe=x([`external`,`embedded`]),ywe=x([`connected`,`disconnected`,`auth-failed`,`unreachable`,`tls-error`]),UW=b({id:u(),name:u(),url:u(),kind:vwe,status:ywe,latencyMs:r().nullable(),error:u().optional(),connectedClients:r().int().nonnegative().optional(),lastCheckedAt:r().optional()}),WW=b({url:u(),username:u().optional(),password:u().optional(),clientIdPrefix:u().optional()}),GW=b({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=b({id:u()}),KW=b({id:u()}),qW=b({port:r().int().min(1).max(65535).default(1883),allowAnonymous:v().default(!1),username:u().optional(),password:u().optional()}),xwe=b({id:u(),url:u()}),JW=b({brokerCount:r(),embeddedRunning:v()}),YW={name:`mqtt-broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:JW,kind:`poll`},methods:{listBrokers:E(_(),S(UW)),getBrokerConfig:E(KW,WW,{auth:`admin`}),addBroker:E(GW,bwe,{kind:`mutation`,auth:`admin`}),removeBroker:E(KW,_(),{kind:`mutation`,auth:`admin`}),startEmbeddedBroker:E(qW,xwe,{kind:`mutation`,auth:`admin`}),stopEmbeddedBroker:E(KW,_(),{kind:`mutation`,auth:`admin`}),getStatus:E(_(),JW)},vocabulary:{notOperatorFacing:O.NETWORK}},XW=x([`person`,`vehicle`,`animal`,`face`,`package`,`other`]),ZW=b({class:XW,timestamp:r(),confidence:r().min(0).max(1).optional()}),QW=b({lastByClass:f(XW,ZW.nullable()),supportedClasses:S(XW).readonly(),enabled:v()}),$W=x([`boxed`,`while-streaming`,`flag-only`]),eG=b({supportedClasses:S(XW).readonly(),geometry:$W}),tG=b({enabled:v().optional()}),nG=QW.extend({lastFetchedAt:r()}),rG={name:`native-object-detection`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{getOptions:E(b({deviceId:r()}),eG),setSettings:E(b({deviceId:r(),settings:tG}),_(),{kind:`mutation`,auth:`admin`}),setEnabled:E(b({deviceId:r(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`nativeDetection.on`,label:I(`On-camera detection on`,`Rilevamento a bordo attivo`),phrase:I(`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:I(`On-camera detection off`,`Rilevamento a bordo spento`),phrase:I(`Turn off the on-camera detection of {device}`,`Disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!1}}]})},events:{onDetected:{data:b({deviceId:r(),detection:ZW}),trigger:{category:w.DetectionCameraNative,label:I(`Camera spotted something`,`La telecamera ha rilevato qualcosa`),phrase:I(`When {device} spots something with its own detector`,`Quando {device} rileva qualcosa con il proprio rilevatore`),icon:`scan-eye`}}},status:{schema:QW,kind:`push`},runtimeState:nG,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`On-camera detection`,`Rilevamento a bordo`),order:3180,state:[{kind:`boolean`,field:`enabled`,label:I(`On-camera detection`,`Rilevamento a bordo`),whenTrue:I(`When the on-camera detection of {device} is turned on`,`Quando si attiva il rilevamento a bordo di {device}`),whenFalse:I(`When the on-camera detection of {device} is turned off`,`Quando si disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`}]}},iG=b({pan:r().min(-1).max(1).optional(),tilt:r().min(-1).max(1).optional(),speed:r().min(0).max(1).optional()}),aG=x([`goHome`,`locate`,`spotClean`,`findPet`,`personFollow`,`stop`,`startClean`,`pauseClean`,`dockWash`,`autoEmpty`,`flashOn`,`flashOff`]),oG=x([`action`,`sound`]),sG=b({id:u(),kind:oG,label:u(),icon:u(),soundId:r().int().optional(),enabled:v()}),Swe=[{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}],cG=b({x:r(),y:r()}),lG=b({move:v(),stop:v(),goToPoint:v(),runAction:v(),playSound:v(),light:v(),lightMode:v()}),uG=x([`auto`,`manual`]),dG=x([`idle`,`cleaning`,`spot`,`following`,`goto`,`returning`,`paused`,`unknown`]),fG=b({mode:dG,following:v(),flash:v(),lightMode:uG,lightLevel:r().min(40).max(100).meta(k(`none`)),lastChangedAt:r()}),pG=fG.extend({lastFetchedAt:r()}),mG={name:`navigation`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/navigation-panel`,tab:`navigation`,topTab:!0,label:`Navigation`,order:0}},methods:{move:E(iG.extend({deviceId:r()}),_(),{kind:`mutation`,notOperatorFacing:`joystick control from the live view — continuous, not a discrete step`}),stop:E(b({deviceId:r()}),_(),{kind:`mutation`,actions:[{id:`navigation.stop`,label:I(`Stop`,`Ferma`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),goToPoint:E(cG.extend({deviceId:r()}),_(),{kind:`mutation`,notOperatorFacing:`tap-to-go on the live map — the point only means something on that picture`}),listActions:E(b({deviceId:r()}),S(sG)),runAction:E(b({deviceId:r(),actionId:aG}),_(),{kind:`mutation`,actions:[{id:`navigation.runAction`,label:I(`Run a routine`,`Esegui una routine`),phrase:I(`Have {device} {actionId}`,`Fai eseguire a {device}: {actionId}`),icon:`bot`,openArgs:[{key:`actionId`,label:I(`Routine`,`Routine`),offer:{kind:`enum`,values:[{value:`goHome`,label:I(`go home`,`torna alla base`)},{value:`locate`,label:I(`beep so you can find it`,`suona per farsi trovare`)},{value:`spotClean`,label:I(`clean this spot`,`pulisci questo punto`)},{value:`findPet`,label:I(`find the pet`,`cerca l’animale`)},{value:`personFollow`,label:I(`follow a person`,`segui una persona`)},{value:`stop`,label:I(`stop`,`fermati`)},{value:`startClean`,label:I(`start cleaning`,`inizia a pulire`)},{value:`pauseClean`,label:I(`pause cleaning`,`metti in pausa la pulizia`)},{value:`dockWash`,label:I(`wash the mop at the dock`,`lava il mocio alla base`)},{value:`autoEmpty`,label:I(`empty the bin at the dock`,`svuota il contenitore alla base`)},{value:`flashOn`,label:I(`turn the flash on`,`accendi il flash`)},{value:`flashOff`,label:I(`turn the flash off`,`spegni il flash`)}]}}]}]}),playSound:E(b({deviceId:r(),soundId:r().int()}),_(),{kind:`mutation`,actions:[{id:`navigation.playSound`,label:I(`Play sound`,`Riproduci un suono`),phrase:I(`Play {soundId} on {device}`,`Riproduci {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:I(`Sound`,`Suono`),offer:{kind:`dynamic`,from:`method`,method:`listActions`,valueKey:`soundId`,labelKey:`label`,where:{key:`kind`,equals:`sound`},valueKind:`number`}}]}]}),setLightOn:E(b({deviceId:r(),on:v()}),_(),{kind:`mutation`,actions:[{id:`navigation.lightOn`,label:I(`Light on`,`Luce accesa`),phrase:I(`Turn on the light of {device}`,`Accendi la luce di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`navigation.lightOff`,label:I(`Light off`,`Luce spenta`),phrase:I(`Turn off the light of {device}`,`Spegni la luce di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setLightMode:E(b({deviceId:r(),mode:uG,level:r().min(40).max(100).optional()}),_(),{kind:`mutation`,actions:[{id:`navigation.lightAuto`,label:I(`Light automatic`,`Luce automatica`),phrase:I(`Set the light of {device} to automatic`,`Metti la luce di {device} in automatico`),icon:`lightbulb`,args:{mode:`auto`}}]}),setLightLevel:E(b({deviceId:r(),level:r().min(40).max(100)}),_(),{kind:`mutation`,actions:[{id:`navigation.lightLevel`,label:I(`Set light level`,`Imposta la luce`),phrase:I(`Set the light of {device} to {level}`,`Imposta la luce di {device} al {level}`),icon:`sun-medium`,openArgs:[{key:`level`,label:I(`Level`,`Livello`),offer:{kind:`number`,min:40,max:100,step:1,unit:`%`}}]}]}),getFeatures:E(b({deviceId:r()}),lG)},events:{onStatusChanged:{data:b({deviceId:r(),status:fG}),notOperatorFacing:"the `mode` state trigger reads the same change"}},status:{schema:fG,kind:`push`},runtimeState:pG,durability:`session`,history:`none`,vocabulary:{noun:I(`Robot movement`,`Movimento del robot`),order:2080,state:[{kind:`enum`,field:`mode`,label:I(`Activity`,`Attività`),values:[{value:`idle`,label:I(`Idle`,`Inattivo`)},{value:`cleaning`,label:I(`Cleaning`,`In pulizia`)},{value:`spot`,label:I(`Spot cleaning`,`Pulizia localizzata`)},{value:`following`,label:I(`Following`,`In inseguimento`)},{value:`goto`,label:I(`Moving to a point`,`In movimento verso un punto`)},{value:`returning`,label:I(`Returning`,`In rientro`)},{value:`paused`,label:I(`Paused`,`In pausa`)},{value:`unknown`,label:I(`Unknown`,`Sconosciuto`)}],icon:`bot`}]}},hG=b({url:u(),hostname:u(),port:r(),protocol:x([`http`,`https`]),stable:v().optional()}),Cwe=b({url:u(),stable:v().optional(),updated:v().optional()}),gG=b({connected:v(),endpoint:hG.nullable(),error:u().optional()}),wwe=hG.extend({id:u(),label:u(),mode:u().optional(),sourcePort:r().optional()}),_G={name:`network-access`,scope:`system`,mode:`collection`,providerKind:`ingress`,methods:{start:E(_(),hG,{kind:`mutation`}),stop:E(_(),_(),{kind:`mutation`}),getEndpoint:E(_(),hG.nullable()),getStatus:E(_(),gG),listEndpoints:E(_(),S(wwe).readonly())},vocabulary:{notOperatorFacing:O.NETWORK}},vG=[`wifi`,`ethernet`,`cellular`,`unknown`],yG=b({type:x(vG),signal:r().min(0).max(100).nullable().meta(k(`percentage`)),rssi:r().optional().meta(k(`signal-level`)),ssid:u().optional(),speedKbps:r().nonnegative().nullable().optional().meta(k(`bitrate`)),linkUp:v().nullable().optional(),lastUpdated:r().meta(k(`none`))}),bG={type:`unknown`,signal:null,lastUpdated:0};function Twe(e,t){return e===void 0||!Number.isFinite(e)||t<=0||e<0||e>t?null:Math.round(e/t*100)}function Ewe(e){return e===void 0||!Number.isFinite(e)||e>0?null:Math.round((Math.min(-50,Math.max(-100,e))+100)*2)}var xG={name:`network-link`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera,j.Sensor,j.Button,j.Switch,j.Light,j.Lock,j.Siren],methods:{},events:{onStatusChanged:{data:b({deviceId:r(),status:yG}),notOperatorFacing:`the signal / link-type state triggers each read one field of this change`}},status:{schema:yG,kind:`push`,empty:bG},runtimeState:yG,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:I(`Network link`,`Collegamento di rete`),order:5250,state:[{kind:`numeric`,field:`signal`,quantity:I(`the signal strength`,`l’intensità del segnale`),label:I(`Signal`,`Segnale`),unit:`%`,icon:`wifi`},{kind:`enum`,field:`type`,label:I(`Link type`,`Tipo di collegamento`),values:[{value:`wifi`,label:I(`Wi-Fi`,`Wi-Fi`)},{value:`ethernet`,label:I(`Ethernet`,`Ethernet`)},{value:`cellular`,label:I(`Cellular`,`Rete mobile`)},{value:`unknown`,label:I(`Unknown`,`Sconosciuto`)}],icon:`network`}]}},SG=b({nominalBitrateKbps:r(),observedBitrateKbps:r(),peakBitrateKbps:r(),packetLossPercent:r(),lastUpdated:r()}),CG=b({rttMs:r(),jitterMs:r(),estimatedBandwidthKbps:r(),packetLossPercent:r().min(0).max(100),downlinkMbps:r().optional(),downlinkAgeMs:r().optional(),lastUpdated:r()}),wG=b({deviceId:r(),streams:h(u(),SG),client:CG.optional()}),TG={name:`network-quality`,scope:`system`,mode:`singleton`,methods:{getDeviceStats:E(b({deviceId:r()}),wG.nullable()),getAllStats:E(_(),S(wG).readonly()),reportClientStats:E(b({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()}),_(),{role:`viewer`,kind:`mutation`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.NETWORK}},EG=b({cn:u(),serial:u(),fingerprintSha256:u(),notBefore:r(),notAfter:r()}),DG=b({fingerprintSha256:u(),issuer:u(),sans:S(u()),notBefore:r(),notAfter:r()}),OG=a(`state`,[b({state:m(`served`),leaf:DG}),b({state:m(`not-issued`),reason:u()})]),kG={name:`node-certificates`,scope:`system`,mode:`singleton`,internal:!0,methods:{getCertificates:E(b({}),b({nodeId:u(),mesh:EG.nullable(),https:OG}),{auth:`admin`}),prepareMeshRenewal:E(b({}),b({csrPem:u()}),{kind:`mutation`,auth:`admin`}),installMeshLeaf:E(b({certPem:u().min(1),caCertPem:u().min(1),confirmWithinMs:r().int().min(1e4).max(6e5)}),b({fingerprintSha256:u(),serial:u()}),{kind:`mutation`,auth:`admin`}),confirmMeshLeaf:E(b({fingerprintSha256:u()}),b({confirmed:v()}),{kind:`mutation`,auth:`admin`}),rollbackMeshLeaf:E(b({}),b({rolledBack:v()}),{kind:`mutation`,auth:`admin`}),prepareHttpsCertificate:E(b({}),b({csrPem:u(),hostnames:S(u()),addresses:S(u()),pinnedCaFingerprintSha256:u().nullable()}),{kind:`mutation`,auth:`admin`}),forgetHub:E(b({}),b({ok:m(!0)}),{kind:`mutation`,auth:`admin`}),installHttpsCertificate:E(b({certPem:u().min(1),caCertPem:u().min(1),caRotation:v().optional()}),DG,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.IDENTITY}},AG=b({nodeId:u().min(1),removedAt:r()}),jG=b({counts:h(u(),r().int().nonnegative())}),MG={name:`node-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onNodeRemoved:E(AG,jG,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},NG=b({addonId:u(),capabilities:S(u()).readonly(),status:u()}),PG=b({pid:r(),name:u(),state:u(),cpuPercent:r(),memoryRss:r(),uptimeSeconds:r(),services:S(NG).readonly(),groupId:u().optional()}),Dwe=b({id:u(),status:u(),cpuPercent:r(),memoryRss:r()}),Owe=b({category:u(),total:r(),healthy:r(),addons:S(Dwe).readonly()}),kwe=b({name:u(),version:u()}),FG=b({id:u(),name:u(),hostname:u(),platform:u(),arch:u(),cpuModel:u().nullable(),cpuCores:r(),memoryMB:r(),engines:S(u()).readonly(),isHub:v(),isOnline:v(),cpuPercent:r(),memoryPercent:r().nullable(),uptime:r(),lastSeen:u(),localIps:S(u()).readonly(),addons:S(b({id:u(),capabilities:S(u()).readonly(),status:u()})).readonly(),processes:S(PG).readonly(),categories:S(Owe).readonly(),rootPackage:kwe.nullable(),meshTransport:x([`tls`,`clear`]).optional(),capabilitiesRegistered:v().optional()}),Awe=b({callerAddonId:u(),providerAddonId:u(),capName:u(),callsPerMin:r(),lastCallAtMs:r()}),IG=b({nodeId:u(),name:u(),version:u(),status:u(),synced:v()}),LG=b({hubVersion:u(),nodes:S(IG)}),RG=b({nodeId:u(),addonId:u()}),jwe=b({id:u(),status:u(),version:u().optional(),packageName:u().optional()}),zG=b({success:v()}),Mwe=b({success:v(),reason:u().optional()}),Nwe=b({restarted:S(u()).readonly(),failed:S(u()).readonly()}),Pwe=b({nodeId:u(),name:u()}),BG=b({id:u(),name:u(),isHub:v(),isOnline:v()}),VG=b({nodes:S(BG).readonly(),complete:v()}),HG={name:`nodes`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{topology:E(_(),S(FG).readonly(),{auth:`admin`}),directory:E(_(),VG,{auth:`admin`}),deployAddon:E(RG,zG,{kind:`mutation`,auth:`admin`}),undeployAddon:E(RG,zG,{kind:`mutation`,auth:`admin`}),restartAddon:E(RG,zG,{kind:`mutation`,auth:`admin`}),restartProcess:E(b({nodeId:u(),processName:u()}),Mwe,{kind:`mutation`,auth:`admin`}),restartNode:E(b({nodeId:u()}),Nwe,{kind:`mutation`,auth:`admin`}),shutdownNode:E(b({nodeId:u()}),zG,{kind:`mutation`,auth:`admin`}),renameNode:E(b({nodeId:u(),name:u().min(1).max(64)}),Pwe,{kind:`mutation`,auth:`admin`}),clusterAddonStatus:E(_(),h(u(),LG),{auth:`admin`}),getCapUsageGraph:E(b({windowSeconds:r().int().positive().max(300).default(60)}),S(Awe).readonly(),{auth:`admin`}),getNodeAddons:E(b({nodeId:u()}),S(jwe).readonly(),{auth:`admin`}),setProcessLogLevel:E(b({nodeId:u(),level:u()}),zG,{kind:`mutation`,auth:`admin`}),executeQuery:E(b({nodeId:u(),addonId:u(),queryName:u(),params:h(u(),C()).optional()}),C(),{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.CLUSTER}},UG=[{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`}],WG={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},GG={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},KG=new Map;for(let[e,t]of Object.entries(WG.mapping))KG.set(e.toLowerCase(),t);for(let[e,t]of Object.entries(GG.mapping))KG.set(e.toLowerCase(),t);function Fwe(e){return KG.get(e.toLowerCase())??null}function Iwe(){return UG.map(e=>e.id)}var qG=tN();function JG(e){return oN(qG.swatches,qG.fallbacks,e)}function Lwe(e){let t=e[0];if(t===void 0)throw Error(`display palette has no fallback colour`);return t}var Rwe=Lwe(qG.fallbacks);function zwe(e){return e.split(/[-_ ]/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var YG=new Map;function XG(e,t,n,r){YG.set(e,{kind:e,parentKind:null,level:`macro`,category:t,color:JG(e),iconId:n,labelKey:`eventKind.${e}`,label:r})}function ZG(e,t,n,r,i){YG.set(e,{kind:e,parentKind:t,level:`sub`,category:n,color:JG(e),iconId:r,labelKey:`eventKind.${e}`,label:i})}XG(`motion`,`motion`,`motion`,`Motion`),XG(`audio`,`audio`,`audio`,`Audio`),XG(`person`,`detection`,`person`,`Person`),XG(`vehicle`,`detection`,`vehicle`,`Vehicle`),XG(`animal`,`detection`,`animal`,`Animal`),XG(`package`,`package`,`package`,`Package`),XG(`sensor`,`sensor`,`sensor`,`Sensor`),XG(`control`,`control`,`control`,`Control`);for(let[e,t]of Object.entries(Ih.mapping))t!==`vehicle`&&t!==`animal`||YG.has(e)||ZG(e,t,`detection`,e,zwe(e));ZG(`package-delivered`,`package`,`package`,`package`,`Package delivered`),ZG(`package-picked-up`,`package`,`package`,`package`,`Package picked up`),ZG(`contact`,`sensor`,`sensor`,`door`,`Contact`),ZG(`motion-sensor`,`sensor`,`sensor`,`pir`,`Motion sensor`),ZG(`smoke`,`sensor`,`sensor`,`smoke`,`Smoke`),ZG(`flood`,`sensor`,`sensor`,`water`,`Water leak`),ZG(`gas`,`sensor`,`sensor`,`gas`,`Gas`),ZG(`carbon-monoxide`,`sensor`,`sensor`,`smoke`,`Carbon monoxide`),ZG(`vibration`,`sensor`,`sensor`,`vibration`,`Vibration`),ZG(`tamper`,`sensor`,`sensor`,`tamper`,`Tamper`),ZG(`presence`,`sensor`,`sensor`,`presence`,`Presence`),ZG(`enum-sensor`,`sensor`,`sensor`,`generic`,`Sensor state`),ZG(`device-event`,`sensor`,`sensor`,`button`,`Device event`),ZG(`lock`,`control`,`control`,`lock`,`Lock`),ZG(`cover`,`control`,`control`,`door`,`Cover`),ZG(`switch`,`control`,`control`,`switch`,`Switch`),ZG(`siren`,`control`,`control`,`siren`,`Siren`),ZG(`button`,`control`,`control`,`button`,`Button`),ZG(`doorbell`,`control`,`control`,`doorbell`,`Doorbell`),ZG(`appliance-cycle`,`control`,`control`,`switch`,`Appliance cycle`);for(let e of UG){let t=`audio-${e.id}`;YG.has(t)||ZG(t,`audio`,`audio`,t,e.name)}var QG=Object.freeze(Object.fromEntries(YG));function $G(e){return QG[e]}function Bwe(e){return JG(e)}function Vwe(e){let t=[];for(let n of Object.values(QG))n.parentKind===e&&t.push(n);return t}var eK=b({kind:u(),label:u(),parentKind:u().nullable()}),tK=b({videoClasses:S(eK),audioKinds:S(eK),labels:S(eK)});function nK(e,t,n){return{kind:e,label:t,parentKind:n}}function rK(){let e=Object.values(QG);return{videoClasses:e.filter(e=>e.category===`detection`).map(e=>nK(e.kind,e.label,e.parentKind)),audioKinds:e.filter(e=>e.category===`audio`&&e.level===`sub`).map(e=>nK(e.kind,e.label,e.parentKind)),labels:e.filter(e=>e.category===`sensor`||e.category===`control`).map(e=>nK(e.kind,e.label,e.parentKind))}}var Hwe=Object.freeze(rK()),iK=x([`immediate`,`track-end`,`device-event`,`package-event`,`system-event`]),aK=x(`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(`.`)),oK=[`camera-online`,`camera-offline`,`camera-disabled`,`camera-enabled`],Uwe=new Set(oK),Wwe=aK.options.filter(e=>!Uwe.has(e)),sK=[`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`],cK=[`device-battery-low`,`device-battery-normal`,`device-consumable-low`,`device-consumable-normal`],lK=[`device-consumable-low`,`device-consumable-normal`],uK=[`confirmed`,`already`,`unconfirmed`,`failed`],dK=[`user`,`addon`,`action`,`scheduler`,`composition`,`node`],fK=b({kinds:S(aK).min(1),deviceIds:S(r().int()).min(1).optional(),deviceTypes:S(u().min(1)).min(1).optional(),excludeDeviceIds:S(r().int()).min(1).optional(),nodeIds:S(u().min(1)).min(1).optional(),packageNames:S(u().min(1)).min(1).optional(),commandActions:S(u().min(1)).min(1).optional(),commandOutcomes:S(x(uK)).min(1).optional(),commandActorKinds:S(x(dK)).min(1).optional(),consumableLowPercent:r().int().min(1).max(95).optional()});function Gwe(e){return e.consumableLowPercent??15}var pK=1440,Kwe=[10,30,60],mK=b({days:S(r().int().min(0).max(6)).min(1),startMinute:r().int().min(0).max(1439),endMinute:r().int().min(0).max(1439)}),hK=b({windows:S(mK).min(1),timezone:u().optional(),invert:v().optional()}),gK=x([`instant`,`summary`]),qwe=x([`activation`,`deactivation`,`schedule`]),_K=x([`rule`,`section`]),vK=a(`mode`,[b({mode:m(`instant`)}),b({mode:m(`summary`),schedule:hK,split:_K.optional()}),b({mode:m(`modes`),onActivation:v(),onDeactivation:v(),onSchedule:b({schedule:hK,grouping:_K}).optional()})]),yK=b({values:S(u().min(1)),maxDistance:r().int().min(0).max(3).default(1)}),bK=b({zoneId:u().optional(),className:u().optional(),op:x([`became-occupied`,`became-free`,`>=`,`<=`]).default(`became-occupied`),count:r().int().min(0).default(1),sustainSeconds:r().int().min(0).max(3600).default(15)}),xK=b({labels:S(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()}),SK=x([`enter`,`exit`,`any`]),CK=x([`raised`,`cleared`]),wK=b({ids:S(u().min(1)).min(1),match:x([`any`,`all`]).optional()}),TK=u().min(1),EK=S(TK).max(4),DK=b({id:u().min(1).max(64),label:u().min(1).max(40),actionId:TK,icon:mi.optional(),destructive:v().optional()}),OK=b({onActivation:EK.optional(),onDeactivation:EK.optional(),onTrigger:EK.optional(),onTriggerOff:EK.optional(),buttons:S(DK).max(8).optional()}),kK=b({deviceId:r().int(),states:S(u().min(1)).min(1)}),AK=b({sceneId:u().min(1),deviceId:r().int().optional(),requiredState:x([`matched`,`diverged`]),latched:v().optional()}),jK=b({deviceState:kK.optional(),scene:AK.optional(),devices:S(r()).optional(),devicesExclude:S(r()).min(1).optional(),classes:S(u().min(1)).optional(),classesExclude:S(u().min(1)).optional(),minConfidence:r().min(0).max(1).optional(),zones:wK.optional(),zonesExclude:S(u().min(1)).optional(),crossing:SK.optional(),labelEquals:S(u().min(1)).optional(),identities:S(u().min(1)).optional(),plates:yK.optional(),identitiesExclude:S(u().min(1)).optional(),minImportance:r().min(0).max(1).optional(),minDwellSeconds:r().min(0).optional(),source:x([`pipeline`,`onboard`,`sensor`,`audio`,`any`]).optional(),minLabelConfidence:r().min(0).max(1).optional(),eventTypeTokens:S(u().min(1)).optional(),sensorKinds:S(u().min(1)).optional(),sensorTransition:CK.optional(),packagePhase:x([`delivered`,`picked-up`,`both`]).optional(),systemEvent:fK.optional(),customZones:S(GB).optional(),occupancy:bK.optional(),audio:xK.optional()}),MK=b({targetId:u().min(1),params:h(u(),C()).optional()}),NK=x([`none`,`image`,`clip`,`gif`]),PK=b({template:b({title:u().max(500).optional(),body:u().max(2e3).optional()}).optional(),schedule:hK.optional(),priority:r().int().min(1).max(5).optional(),attachment:NK.optional(),actions:v().optional()}),FK=h(u(),PK),IK=x([`scene-boxes`,`crop`,`clean`,`none`]),LK=x([`cropped`,`full`,`boxed`]),RK=x([`mosaic`,`each`]),zK=b({image:IK.optional(),showTriggerZone:v().optional(),showSubjectPath:v().optional(),attach:x([`best`,`best-matching`,`keyFrame`,`none`]).optional(),frame:LK.optional(),zoneCrop:v().optional(),gif:v().optional(),clip:v().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:A.optional(),linkedCameras:RK.optional(),wakeSleepingCamera:v().optional()}),BK=x([`shared`,`per-class`]),VK=b({cooldownSec:r().int().min(0).max(86400).default(60),scope:x([`rule`,`rule-device`]).default(`rule-device`),granularity:BK.optional()}),HK=1e3,UK=2e4,WK=8e3,GK=b({op:x([`>=`,`>`,`<=`,`<`,`==`]),count:r().int().min(0).max(1e3)}),KK=b({enabled:v().default(!1),profileId:u().optional(),prompt:u().max(1e3).optional(),expect:GK.optional(),timeoutMs:r().int().min(HK).max(UK).default(WK),onTimeout:x([`fire`,`suppress`]).default(`fire`),maxImagePx:r().int().min(64).max(2048).default(448)}),qK=b({name:u().min(1).max(200),enabled:v().default(!0),delivery:iK,conditions:jK.default({}),schedule:hK.optional(),systemEventDelivery:vK.optional(),targets:S(MK),targetUsers:S(u()).optional(),targetOverrides:FK.optional(),media:zK.default({}),throttle:VK.default({cooldownSec:60,scope:`rule-device`}),template:b({title:u().max(500).optional(),body:u().max(2e3).optional()}).optional(),priority:r().int().min(1).max(5).default(3),ownerUserId:u().optional(),snoozeAllowGlobal:v().optional(),snoozeOptions:S(r().int().min(1).max(pK)).max(4).optional(),actions:OK.optional(),confirm:KK.optional(),groupingSec:r().int().min(5).max(60).optional(),groupWithinSec:r().int().min(0).max(300).optional(),askVerdict:v().optional(),tags:Zu.optional()}),JK=x([`event`,`summary`,`timelapse`,`calendar-events`]),YK=b({kind:JK,ruleId:u(),tags:S(u())}),XK=qK.partial().extend({disabledTargetIds:S(u()).optional(),enabled:v().optional(),conditions:jK.optional(),media:zK.optional(),throttle:VK.optional(),priority:r().int().min(1).max(5).optional()}),ZK=[`waitForEnhancement`,`groupIdleSec`];function Jwe(e){return ZK.some(t=>t===e)}var QK=[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`actions`,`confirm`,`groupingSec`,`waitForEnhancement`,`groupIdleSec`],$K=x(QK),eq=b({ruleId:u(),patch:XK,clear:S($K).optional()}),tq=qK.extend({id:u(),createdBy:u(),createdAt:r(),updatedAt:r(),disabledTargetIds:S(u()).default([])}),nq=[`device-state`,`streams`,`battery`,`consumables`,`detection-blind`,`nodes`,`addons`,`addon-updates`,`updates`],rq=x(nq),iq=b({id:rq,status:x([`read`,`unavailable`]),items:r().int().nonnegative(),reason:u().optional()}),aq=b({section:rq.optional(),title:u(),text:u(),count:r().int().nonnegative()}),oq=b({empty:v(),count:r().int().nonnegative(),text:u(),sections:S(iq),dropped:h(u(),r().int().nonnegative()),excludedGroups:S(u()),split:_K.optional(),rows:S(aq).optional()}),sq=b({recordId:u(),recordKind:x([`object-event`,`track`,`device-event`,`package-event`,`system-event`]),deviceId:r(),timestamp:r(),wouldFire:v(),failedCondition:u().optional(),className:u().optional(),label:u().optional()}),cq=x([`detection`,`sensor`,`occupancy`,`sound`,`device-events`,`system`,`alarm`,`mixed`]),lq=x([`detection`,`sensor`,`occupancy`,`sound`,`system`]),uq=b({id:x([`appliance-cycle`]),kind:cq,title:u(),body:u()}),dq=x([`rule`,`timelapse`,`summary`]),fq=x([`title`,`body`,`previewText`,`captionText`]),pq=x([`subject`,`place`,`time`,`rule`,`occupancy`,`sound`,`sensor`,`system`,`digest`,`ai`]),mq=b({name:u().regex(/^\w+$/),label:u(),description:u().optional(),example:u(),group:pq,families:S(dq).min(1),fields:S(fq).optional(),kinds:S(lq).optional(),deliveries:S(iK).optional(),systemEventKinds:S(aK).optional(),systemEventDeliveries:S(gK).optional(),dynamic:b({prefix:m(`count_`),from:m(`classes`)}).optional()}),hq=b({family:dq,field:fq,kind:cq.optional(),delivery:iK.optional(),systemEventKinds:S(aK).optional(),systemEventDelivery:gK.optional()}),gq=b({context:hq,template:b({title:u().max(500).optional(),body:u().max(2e3).optional()})}),_q=b({title:u().nullable(),body:u().nullable(),unknown:S(u())}),vq=b({id:u(),group:x([`scope`,`class`,`zones`,`quality`,`label`,`schedule`,`device`,`package`,`occupancy`,`audio`,`system`]),label:u(),valueType:x([`deviceIdList`,`deviceIdExcludeList`,`stringList`,`number01`,`number`,`sourceSelect`,`zoneSelection`,`zoneIdList`,`schedule`,`plateMatcher`,`packagePhase`,`crossingSelect`,`sensorTransition`,`polygonDraw`,`occupancy`,`audio`,`deviceState`,`scene`,`systemEvent`]),operator:x([`in`,`notIn`,`anyOf`,`allOf`,`gte`,`fuzzyIn`,`withinSchedule`]),appliesTo:S(iK),phase:u(),description:u().optional(),options:S(b({value:u(),label:u(),hint:u().optional()})).readonly().optional()}),yq=[{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.`}],bq=x([`pending`,`sent`,`dead`]),xq=x([`object-event`,`track-end`,`device-event`,`package-event`,`system-event`]),Sq=b({className:u(),label:u().optional(),confidence:r().optional(),zones:S(u()),timestamp:r(),systemEvent:b({kind:aK,subject:u(),title:u(),body:u(),data:h(u(),C())}).optional()}),Cq=b({id:u(),ruleId:u(),ruleName:u(),delivery:iK,targetId:u(),deviceId:r(),recordKind:xq,recordId:u(),trackId:u().optional(),status:bq,attempts:r().int(),createdAt:r(),updatedAt:r(),error:u().optional(),subject:Sq,title:u().optional(),body:u().optional(),artifactIds:S(u().min(1)).optional(),groupedInto:u().min(1).optional()}),wq=b({ruleId:u().optional(),deviceId:r().optional(),status:bq.optional(),since:r().optional(),until:r().optional(),limit:r().int().min(1).max(500).default(100)}),Tq=b({ruleId:u(),lastAt:r(),status:bq,deviceId:r()}),Eq=b({runs:S(Tq),horizonMs:r().nonnegative().nullable()}),Dq=x([`rule`,`device`,`all`]),Oq=b({scope:Dq,ruleId:u().optional(),deviceId:r().int().optional(),classes:S(u().min(1)).min(1).optional(),durationMinutes:r().int().min(1).max(pK),global:v().optional(),summary:v().optional()}),kq=b({id:u(),userId:u(),scope:Dq,ruleId:u().optional(),deviceId:r().int().optional(),classes:S(u().min(1)).min(1).optional(),startedAt:r(),expiresAt:r(),global:v(),summary:v(),digestSentAt:r().optional()}),Ywe=b({snoozeId:u(),targetId:u(),ruleId:u(),ruleName:u(),deviceId:r().int(),count:r().int(),firstAt:r(),lastAt:r()}),Aq=3600,jq=r().int().min(0).max(600),Mq=r().int().min(0).max(Aq),Nq=e=>new Set(e.map(e=>e.mode)).size===e.length,Pq=x([`rearmAfter`,`disableAfter`,`doNothing`]),Fq=b({mode:Jv,exitDelaySec:jq.optional(),entryDelaySec:jq.optional(),triggeredDurationSec:Mq.optional(),postTriggeredAction:Pq.optional(),schedule:hK.optional(),notifyDuringEntryDelay:v().optional(),notifySensorRewatched:v().optional(),notifySensorIgnored:v().optional()}),Xwe=S(Fq).max(8).refine(Nq,{message:`modeDelays: at most one entry per arm mode`}),Iq=b({mode:Jv,exitDelaySec:jq.nullable().optional(),entryDelaySec:jq.nullable().optional(),triggeredDurationSec:Mq.nullable().optional(),postTriggeredAction:Pq.nullable().optional(),schedule:hK.nullable().optional(),notifyDuringEntryDelay:v().nullable().optional(),notifySensorRewatched:v().nullable().optional(),notifySensorIgnored:v().nullable().optional()}),Zwe=S(Iq).max(8).refine(Nq,{message:`modeDelays: at most one edit per arm mode`}),Lq=b({mode:Jv,deviceId:r().int().positive(),nonBlocking:v()}),Rq=b({mode:Jv,deviceId:r().int().positive(),blocking:v()}),zq=b({mode:Jv,deviceId:r().int().positive(),secureOnArm:v()}),Bq=b({mode:Jv,deviceIds:S(r().int()).max(200)}),Vq=Bq,Hq=Bq,Uq=Bq,Wq=S(Vq).max(8).refine(Nq,{message:`nonBlocking: at most one list per arm mode`}),Gq=S(Hq).max(8).refine(Nq,{message:`blocking: at most one list per arm mode`}),Kq=S(Uq).max(8).refine(Nq,{message:`secureOnArmOff: at most one list per arm mode`}),qq=b({exitDelaySec:jq,entryDelaySec:jq,triggeredDurationSec:Mq,postTriggeredAction:Pq.optional(),announceArm:v().optional(),announceTargets:S(u().min(1)).max(16),nonBlocking:Wq.default([]),blocking:Gq.default([]),secureOnArmOff:Kq.default([]),modeDelays:Xwe.default([])}),Jq=b({id:u().min(1).max(64),name:u().min(1).max(64),isDefault:v()}),Yq=b({activeId:u().min(1),items:S(Jq).min(1)}),Xq=b({name:u().min(1).max(64),cloneFromId:u().min(1).max(64).optional()}),Zq=b({id:u().min(1).max(64),name:u().min(1).max(64)}),Qq=b({id:u().min(1).max(64)}),$q=qq.extend({nonBlocking:Wq,blocking:Gq,secureOnArmOff:Kq,modeDelays:Zwe,nonBlockingEdit:Lq,blockingEdit:Rq,secureOnArmEdit:zq}).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`}),eJ=x([`muted`,`detection-off`,`offline`]),tJ=b({deviceId:r().int(),reason:eJ}),nJ=b({mode:Jv,ruleCount:r().int().min(0),allDevices:v(),deviceIds:S(r().int()),allDevicesExcept:S(r().int()).default([]),skippedDevices:S(tJ).default([])}),Qwe=b({deviceId:r().int(),name:u(),state:u(),blocking:v()}),$we=b({deviceId:r().int(),name:u(),phase:x([`open`,`closed`])}),eTe=b({mode:Jv,devices:S(Qwe),unknown:S(r().int())}),tTe=b({ruleId:u(),ruleName:u(),deviceId:r().int(),name:u(),since:r(),dropped:r().int().min(0)}),nTe=b({state:qv,targetMode:Jv.nullable(),availableModes:S(Jv),openings:S(eTe),exclusions:S($we),bypassedInputs:S(tTe).default([])}),rJ=b({deviceId:r().int().nullable(),settings:qq,profiles:Yq.optional(),coverage:S(nJ),live:nTe.optional()}),iJ=x([`open`,`closed`,`unknown`,`not-opening`]),aJ=b({deviceId:r().int().positive(),reading:iJ,state:u().nullable(),unknownWhy:x([`read-failed`,`unknown-word`]).nullable(),online:v().nullable(),controllable:v().default(!1)}),oJ=b({deviceIds:S(r().int().positive()).max(500)}),sJ=b({sensors:S(aJ),readAt:r().int().nonnegative()}),cJ=b({deviceId:r().int().nonnegative().optional(),seconds:r().min(0).max(60),profile:A.optional(),ruleId:u(),ruleName:u(),reason:x([`window`,`occupancy`])}),lJ=b({rulesLoaded:v(),asks:S(cJ).readonly()}),uJ={name:`notification-rules`,scope:`system`,mode:`singleton`,methods:{listRules:E(b({}),b({rules:S(tq)}),{auth:`admin`}),getRule:E(b({ruleId:u()}),b({rule:tq.nullable()}),{auth:`admin`}),createRule:E(b({rule:qK}),b({rule:tq}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateRule:E(eq,b({rule:tq}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteRule:E(b({ruleId:u()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setRuleEnabled:E(b({ruleId:u(),enabled:v()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),listRuleTags:E(b({}),b({rules:S(YK)}),{kind:`query`,auth:`admin`}),setRuleTags:E(b({kind:JK,ruleId:u(),tags:Zu}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getClipRetentionAsks:E(b({}),lJ,{auth:`admin`}),listDeviceMutes:E(b({}),b({mutedDeviceIds:S(r().int()).readonly()}),{auth:`admin`}),setDeviceMuted:E(b({deviceId:r().int(),muted:v()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),testRule:E(b({rule:qK,lookbackMinutes:r().int().min(1).max(1440).default(60)}),b({results:S(sq)}),{kind:`mutation`,auth:`admin`}),previewStateSummary:E(b({rule:qK}),oq,{kind:`mutation`,auth:`admin`,access:`view`}),getConditionCatalog:E(b({}),b({catalog:S(vq),taxonomy:tK.optional()})),getTemplateCatalog:E(b({}),b({vars:S(mq),defaults:S(uq)})),previewTemplate:E(gq,_q,{kind:`mutation`,access:`view`}),getHistory:E(b({filter:wq.default({limit:100})}),b({entries:S(Cq)}),{auth:`admin`}),getRuleLastRuns:E(b({}),Eq,{auth:`admin`}),resolveArtifactUrl:E(b({artifactId:u().min(1)}),b({url:u().nullable()}),{auth:`admin`}),listSnoozes:E(b({}),b({snoozes:S(kq)}),{caller:`required`}),createSnooze:E(b({snooze:Oq}),b({snooze:kq}),{kind:`mutation`,caller:`required`}),cancelSnooze:E(b({snoozeId:u()}),b({success:m(!0)}),{kind:`mutation`,caller:`required`}),getAlarmConfig:E(b({}),rJ,{auth:`admin`}),setAlarmConfig:E(b({patch:$q}),rJ,{kind:`mutation`,auth:`admin`}),createAlarmProfile:E(Xq,rJ,{kind:`mutation`,auth:`admin`}),renameAlarmProfile:E(Zq,rJ,{kind:`mutation`,auth:`admin`}),deleteAlarmProfile:E(Qq,rJ,{kind:`mutation`,auth:`admin`}),activateAlarmProfile:E(Qq,rJ,{kind:`mutation`,auth:`admin`}),getAlarmSensors:E(oJ,sJ,{auth:`admin`})},vocabulary:{notOperatorFacing:`notification rules — authored on their own page`}},rTe=x([`min`,`low`,`normal`,`high`]),iTe=b({id:u().min(1),title:u().min(1),uri:i().optional(),destructive:v().optional()}),aTe=b({image:v(),priority:v(),data:v(),actions:v(),recipients:v()}),dJ=b({lastSentAt:r(),lastError:u().nullable(),queueDepth:r().int().nonnegative().meta(k(`count`)),supports:aTe}),oTe=b({deviceId:r().int().nonnegative(),title:u().optional(),body:u().min(1),image:u().optional(),priority:rTe.optional(),channel:u().optional(),recipients:S(u()).optional(),actions:S(iTe).optional(),data:h(u(),C()).optional()}),sTe=b({notificationId:u(),acceptedAt:r()}),fJ={name:`notifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Notifier],methods:{send:E(oTe,sTe,{kind:`mutation`,auth:`admin`,actions:[{id:`notifier.send`,label:I(`Send a notification`,`Invia una notifica`),phrase:I(`Send “{body}” through {device}`,`Invia «{body}» tramite {device}`),icon:`send`,openArgs:[{key:`title`,label:I(`Title`,`Titolo`),offer:{kind:`text`},optional:!0},{key:`body`,label:I(`Message`,`Messaggio`),offer:{kind:`text`}},{key:`priority`,label:I(`Priority`,`Priorità`),offer:{kind:`enum`,values:[{value:`min`,label:I(`Minimal`,`Minima`)},{value:`low`,label:I(`Low`,`Bassa`)},{value:`normal`,label:I(`Normal`,`Normale`)},{value:`high`,label:I(`High`,`Alta`)}]},optional:!0}]}]}),cancel:E(b({deviceId:r().int().nonnegative(),notificationId:u().min(1)}),_(),{kind:`mutation`,auth:`admin`})},events:{onSent:{data:b({deviceId:r(),notificationId:u(),success:v(),error:u().nullable(),acceptedAt:r()}),notOperatorFacing:`a delivery receipt of a send this system made — not a fact about the world`}},status:{schema:dJ,kind:`command-driven`},runtimeState:dJ,durability:`session`,history:`none`,vocabulary:{noun:I(`Notifier`,`Notificatore`),order:2110}},pJ=b({value:r().nullable().meta(k(`device`)),lastFetchedAt:r()}),mJ={name:`numeric-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:pJ,kind:`push`},runtimeState:pJ,durability:`restored`,history:{fields:{value:{kind:`gauge`,minIntervalMs:3e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Sensor`,`Sensore`),order:5150,state:[{kind:`numeric`,field:`value`,quantity:I(`the reading`,`il valore`),label:I(`Reading`,`Valore`),icon:`gauge`}]}},hJ=b({integrationId:u(),displayName:u(),requestedScopes:S(xf),allowedRedirectPrefixes:S(u()).min(1),allowedPrivateHostPaths:S(u()).optional(),requiresPkce:v().optional(),hubUrl:u().optional(),refreshTokenTtlSec:g([r().int().positive(),m(`never`)]).optional(),instances:S(b({id:u(),displayName:u()})).optional()}),gJ={name:`oauth-integration`,scope:`system`,mode:`collection`,internal:!0,methods:{getDescriptor:E(_(),hJ,{auth:`admin`})},vocabulary:{notOperatorFacing:O.IDENTITY}},_J=x([`text`,`timestamp`,`watermark`]),vJ=x([`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`custom`]),yJ=b({id:u(),kind:_J,enabled:v(),text:u().optional(),position:vJ.optional(),availablePositions:S(vJ).readonly(),readOnly:v().optional(),maxCharacters:r().int().positive().optional()}),bJ=b({overlays:S(yJ).readonly()}),xJ=b({enabled:v().optional(),text:u().optional(),position:vJ.optional()}).partial(),SJ={name:`osd`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{setOverlay:E(b({deviceId:r(),overlayId:u(),patch:xJ}),_(),{kind:`mutation`,auth:`admin`})},events:{onStatusChanged:{data:b({deviceId:r(),status:bJ}),notOperatorFacing:`an overlay setting changed — configuration, not a happening`}},status:{schema:bJ,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:I(`On-screen text`,`Testo in sovrimpressione`),order:3190}},CJ=1024,wJ=b({id:u().min(1).max(64),name:u().min(1).max(64),text:u().max(CJ).default(``)}),TJ=a(`kind`,[b({kind:m(`none`)}),b({kind:m(`static`),text:u().max(CJ)}),b({kind:m(`template`),templateId:u().min(1).max(64)})]),EJ=b({enabled:v().default(!0),source:TJ,schedule:hK.optional(),conditions:jK.optional()}),DJ=b({slotId:u(),kind:_J,readOnly:v(),cameraEnabled:v(),cameraText:u().optional(),binding:EJ.nullable()}),OJ=x([`written`,`unchanged`,`gated`,`unreadable`,`disabled`,`unbound`,`failed`]),kJ=b({slotId:u(),outcome:OJ,text:u(),reason:u().optional()}),AJ=b({ok:v(),text:u(),notes:S(u())}),jJ={name:`osd-manager`,scope:`system`,mode:`singleton`,methods:{getDeviceOsd:E(b({deviceId:r().int()}),b({supported:v(),slots:S(DJ)}),{auth:`admin`}),getConditionSupport:E(b({}),b({supported:S(u()),catalog:S(vq)}),{auth:`admin`}),setSlotBinding:E(b({deviceId:r().int(),slotId:u().min(1),binding:EJ}),b({slot:DJ,render:kJ}),{kind:`mutation`,auth:`admin`}),clearSlotBinding:E(b({deviceId:r().int(),slotId:u().min(1)}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setSlotCameraEnabled:E(b({deviceId:r().int(),slotId:u().min(1),enabled:v()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),copyDeviceConfiguration:E(b({sourceDeviceId:r().int(),targetDeviceId:r().int()}),b({copied:r().int().nonnegative(),skipped:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),previewSlot:E(b({deviceId:r().int(),slotId:u().min(1),binding:EJ.optional()}),kJ,{kind:`mutation`,auth:`admin`}),previewTemplate:E(b({deviceId:r().int(),text:u().max(CJ)}),AJ,{kind:`mutation`,auth:`admin`}),renderDevice:E(b({deviceId:r().int()}),b({results:S(kJ)}),{kind:`mutation`,auth:`admin`}),listTemplates:E(b({}),b({templates:S(wJ)}),{auth:`admin`}),upsertTemplate:E(b({template:wJ}),b({template:wJ}),{kind:`mutation`,auth:`admin`}),deleteTemplate:E(b({templateId:u().min(1).max(64)}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},MJ=1e4,cTe=x([`normal`,`offline`,`on_batteries`]),NJ=r().int().min(4).max(200),PJ=NJ.meta(Ah({quantity:`mass`,unit:`g`})),FJ=b({foodLevel:r().nullable().meta(k(`none`)),bowlFood:r().nullable().meta(k(`mass`)),eating:v(),supportsMarkRefilled:v(),food1:r().nullable().meta(k(`none`)),food2:r().nullable().meta(k(`none`)),lowFood:v(),batteryPower:r().min(0).max(100).nullable().meta(k(`percentage`)),powerSource:x([`mains`,`battery`]).nullable(),desiccantLeftDays:r().nullable().meta(k(`duration`)),feeding:v(),status:cTe.nullable(),error:u().nullable(),errorCode:r().nullable().meta(k(`none`)),isDualHopper:v(),childLock:v(),indicatorLight:v(),feedSound:v(),volume:r().meta(k(`none`)),lastFeedGrams:NJ.nullable(),lastFeedHopper1:NJ.nullable(),lastFeedHopper2:NJ.nullable(),lastFetchedAt:r()}),IJ={name:`pet-feeder`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.PetFeeder],methods:{feed:E(b({deviceId:r().int().nonnegative(),grams:PJ.optional(),hopper1:PJ.optional(),hopper2:PJ.optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feed`,label:I(`Feed`,`Dai da mangiare`),phrase:I(`Dispense {grams} from {device}`,`Eroga {grams} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:MJ},openArgs:[{key:`grams`,label:I(`Grams`,`Grammi`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]},{id:`petFeeder.feedHoppers`,label:I(`Feed from both hoppers`,`Eroga da entrambi i serbatoi`),phrase:I(`Dispense {hopper1} and {hopper2} from {device}`,`Eroga {hopper1} e {hopper2} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:MJ},openArgs:[{key:`hopper1`,label:I(`Hopper 1`,`Serbatoio 1`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0},{key:`hopper2`,label:I(`Hopper 2`,`Serbatoio 2`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]}]}),cancelFeed:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.cancelFeed`,label:I(`Cancel feeding`,`Annulla l’erogazione`),phrase:I(`Cancel the feeding on {device}`,`Annulla l’erogazione di {device}`),icon:`circle-x`}]}),callPet:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.callPet`,label:I(`Call pet`,`Chiama l’animale`),phrase:I(`Call your pet with {device}`,`Chiama l’animale con {device}`),icon:`megaphone`}]}),playSound:E(b({deviceId:r().int().nonnegative(),soundId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.playSound`,label:I(`Play sound`,`Riproduci un suono`),phrase:I(`Play sound {soundId} on {device}`,`Riproduci il suono {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:I(`Sound`,`Suono`),offer:{kind:`number`,min:0,step:1}}]}]}),resetDesiccant:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.resetDesiccant`,label:I(`Desiccant replaced`,`Essiccante sostituito`),phrase:I(`Mark the desiccant of {device} as replaced`,`Segna come sostituito l’essiccante di {device}`),icon:`refresh-cw`}]}),markFoodReplenished:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.foodReplenished`,label:I(`Food refilled`,`Cibo ricaricato`),phrase:I(`Mark {device} as refilled`,`Segna {device} come ricaricato`),icon:`package`}]}),setChildLock:E(b({deviceId:r().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.childLockOn`,effect:{field:`childLock`,value:!0},label:I(`Child lock on`,`Blocco bambini attivo`),phrase:I(`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:I(`Child lock off`,`Blocco bambini spento`),phrase:I(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setIndicatorLight:E(b({deviceId:r().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.lightOn`,effect:{field:`indicatorLight`,value:!0},label:I(`Indicator light on`,`Spia accesa`),phrase:I(`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:I(`Indicator light off`,`Spia spenta`),phrase:I(`Turn off the indicator light of {device}`,`Spegni la spia di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setFeedSound:E(b({deviceId:r().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feedSoundOn`,effect:{field:`feedSound`,value:!0},label:I(`Feeding sound on`,`Suono di erogazione attivo`),phrase:I(`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:I(`Feeding sound off`,`Suono di erogazione spento`),phrase:I(`Turn off the feeding sound of {device}`,`Disattiva il suono di erogazione di {device}`),icon:`volume-x`,args:{on:!1}}]}),setVolume:E(b({deviceId:r().int().nonnegative(),level:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.volume`,effect:{field:`volume`,fromArg:`level`},label:I(`Set volume`,`Imposta il volume`),phrase:I(`Set the volume of {device} to {level}`,`Imposta il volume di {device} a {level}`),icon:`volume-2`,openArgs:[{key:`level`,label:I(`Volume`,`Volume`),offer:{kind:`number`,min:0,step:1}}]}]})},status:{schema:FJ,kind:`poll`},runtimeState:FJ,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:I(`Pet feeder`,`Distributore di cibo`),order:2030,state:[{kind:`boolean`,field:`lowFood`,label:I(`Food low`,`Cibo in esaurimento`),whenTrue:I(`When {device} runs low on food`,`Quando il cibo di {device} sta finendo`),whenFalse:I(`When {device} has enough food again`,`Quando {device} ha di nuovo cibo a sufficienza`),icon:`package`},{kind:`boolean`,field:`feeding`,label:I(`Feeding`,`In erogazione`),whenTrue:I(`When {device} starts feeding`,`Quando {device} inizia a erogare`),whenFalse:I(`When {device} finishes feeding`,`Quando {device} finisce di erogare`),icon:`paw-print`},{kind:`numeric`,field:`desiccantLeftDays`,quantity:I(`the desiccant life`,`la durata dell’essiccante`),label:I(`Desiccant`,`Essiccante`),unit:`d`,icon:`calendar-clock`}]}},LJ=b({waterLevel:r().min(0).max(100).nullable().meta(k(`percentage`)),waterVolume:r().min(0).nullable().meta(k(`volume`)),empty:v().nullable(),pumpRunning:v().nullable(),error:u().nullable(),lastFetchedAt:r()}),RJ=`water`;function lTe(e){let t=e.waterLevel!==null||e.empty===null?null:e.empty?`empty`:`ok`;return{key:RJ,label:`Water`,level:e.waterLevel,status:t,kind:`supply`,form:`tank`,lastResetAt:null,resettable:!1}}var uTe=r().int().nonnegative(),zJ={name:`pet-fountain`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.PetFountain],power:{kind:`field`,field:`pumpRunning`,set:`setPump`},methods:{setPump:E(b({deviceId:uTe,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFountain.pumpOn`,effect:{field:`pumpRunning`,value:!0},label:I(`Pump on`,`Pompa accesa`),phrase:I(`Start the pump of {device}`,`Avvia la pompa di {device}`),icon:`play`,args:{on:!0}},{id:`petFountain.pumpOff`,effect:{field:`pumpRunning`,value:!1},label:I(`Pump off`,`Pompa spenta`),phrase:I(`Stop the pump of {device}`,`Ferma la pompa di {device}`),icon:`square`,args:{on:!1}}]})},status:{schema:LJ,kind:`push`},runtimeState:LJ,durability:`session`,history:{fields:{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}}},vocabulary:{noun:I(`Pet fountain`,`Fontana per animali`),order:2040,state:[{kind:`boolean`,field:`empty`,label:I(`Tank empty`,`Serbatoio vuoto`),whenTrue:I(`When the tank of {device} is empty`,`Quando il serbatoio di {device} è vuoto`),whenFalse:I(`When the tank of {device} is refilled`,`Quando il serbatoio di {device} viene riempito`),icon:`droplet`},{kind:`numeric`,field:`waterLevel`,quantity:I(`the water level`,`il livello dell’acqua`),label:I(`Water level`,`Livello dell’acqua`),unit:`%`,icon:`droplets`}]}},dTe=x(Ld),BJ={min:1,max:8},VJ=x([`intel-core-ultra`,`intel-n-series`,`apple-m-base`,`apple-m-pro`,`amd-phoenix`,`unknown`]),HJ=x([`intel-npu`,`intel-igpu`,`amd-igpu`,`amd-npu`,`x86-cpu`,`arm-cpu`,`apple-ane`,`coral`]),UJ=a(`kind`,[b({kind:m(`capacity`),sessions:r(),minSessions:r()}),b({kind:m(`tie-faster`),over:u(),recallDelta:r()}),b({kind:m(`stepped-down`),from:u(),to:u(),limitedBy:u()}),b({kind:m(`no-fit-lightest`),sessions:r(),minSessions:r()}),b({kind:m(`derived-latency`),modelId:u()}),b({kind:m(`cpu-device`)}),b({kind:m(`device-disabled`)}),b({kind:m(`device-unavailable`)}),b({kind:m(`node-offline`)}),b({kind:m(`no-hardware-facts`)}),b({kind:m(`no-measured-data`),hardwareClass:VJ}),b({kind:m(`no-family-build`),format:dTe}),b({kind:m(`kept-custom-pin`),modelId:u(),deviceKey:u()})]),WJ=x([`custom-pin`]),GJ=a(`kind`,[b({kind:m(`table`)}),b({kind:m(`node-benchmark`),resultId:u(),measuredAtMs:r()}),b({kind:m(`estimated`),estimatedFrom:VJ})]),KJ=b({modelId:u(),p50Ms:r(),fps:r(),measured:v(),source:GJ.optional(),estimatedFrom:VJ.optional(),capacitySessions:r(),personRecall:r()}),qJ=b({deviceKey:u(),accelerator:HJ.nullable(),enabled:v(),available:v(),chosen:KJ.nullable(),kept:WJ.optional(),reasons:S(UJ).readonly()}),JJ=b({nodeId:u(),reachable:v(),hardwareClass:VJ.nullable(),cpuModel:u().nullable(),skipped:v(),acceleratorModelId:u().nullable(),devices:S(qJ).readonly(),reasons:S(UJ).readonly()}),YJ=b({stepId:u(),before:u().nullable(),after:u().nullable()}),XJ=b({nodeId:u(),deviceKey:u(),madeExplicit:v(),modelPins:S(YJ).readonly(),thresholds:S(b({stepId:u(),keys:S(u()).readonly()})).readonly()}),ZJ=a(`kind`,[b({kind:m(`custom-pin-kept`),nodeId:u(),deviceKey:u(),modelId:u()}),b({kind:m(`custom-registry-unreadable`),error:u()})]),QJ=b({headroom:r().min(.3).max(.5).default(.4),minSessionsPerDevice:r().int().min(BJ.min).max(BJ.max).default(2)}),$J=b({planHash:u(),family:m(`yolov9`),headroom:r(),minSessionsPerDevice:r(),cameraFps:r(),generatedAt:r(),nodes:S(JJ).readonly(),nodeChanges:S(XJ).readonly(),warnings:S(ZJ).readonly()}),eY=b({planHash:u(),headroom:r().min(.3).max(.5).default(.4),minSessionsPerDevice:r().int().min(BJ.min).max(BJ.max).default(2)}),tY=b({phase:x([`download`,`node-models`,`redispatch`]),ok:v(),detail:u()}),nY=a(`kind`,[b({kind:m(`applied`),planHash:u(),phases:S(tY).readonly()}),b({kind:m(`aborted`),phases:S(tY).readonly()}),b({kind:m(`stale`),plan:$J}),b({kind:m(`refused`),reason:x([`apply-in-progress`])})]),rY=x([`least-loaded`,`share`]),iY=`share`,fTe=`sessionPlacement`;function pTe(e){let t=rY.safeParse(e);return t.success?t.data:iY}var aY=b({nodes:h(u(),r().positive()).default({}),devices:h(u(),h(u(),r().positive())).default({})}),oY=b({windowMs:r().int().min(6e4).max(1440*60*1e3).default(3600*1e3)}),sY=b({deviceKey:u(),sessionsNow:r(),sessionsStarted:r(),observedShare:r().nullable()}),cY=b({nodeId:u(),sessionsNow:r(),sessionsStarted:r(),observedShare:r().nullable(),peakSessions:r(),yieldsAway:r(),devices:S(sY).readonly()}),lY=b({deviceId:r(),deviceKey:u(),reason:x([`disabled`,`absent`])}),uY=b({policy:rY,windowMs:r(),observedForMs:r(),sessionsNow:r(),clusterPeakSessions:r(),nodes:S(cY).readonly(),stalePins:S(lY).readonly()}),dY=x([`hardware`,`benchmark`]),fY=x([`no-benchmark-results`,`partial-benchmark-results`]),pY=b({headroom:r().min(.3).max(.5).default(.4),source:dY.default(`hardware`)}),mY=b({deviceKey:u(),share:r(),modelId:u().nullable(),fps:r().nullable(),measured:v(),suggestedMaxSessions:r().nullable()}),hY=b({nodeId:u(),share:r().nullable(),capacitySessions:r(),devices:S(mY).readonly(),skippedReason:u().nullable(),capacitySource:dY.nullable(),capacityFallback:fY.nullable()}),gY=b({headroom:r(),source:dY,cameraFps:r(),minSessionsPerDevice:r(),nodes:S(hY).readonly()}),_Y=x([`hardware`,`benchmark`,`manual`]),vY=`benchmark`;function yY(e){return e!==`manual`}var mTe=.4,hTe=`shareSource`;function gTe(e){if(e===`auto`)return`hardware`;let t=_Y.safeParse(e);return t.success?t.data:vY}var bY=b({source:_Y}),_Te=b({nodes:h(u(),r()),devices:h(u(),h(u(),r()))}),xY=b({deviceKey:u(),eligible:v(),configuredPct:r(),effectivePct:r()}),SY=b({nodeId:u(),eligible:v(),configuredPct:r(),effectivePct:r(),capacitySource:dY.nullable(),capacityFallback:fY.nullable(),devices:S(xY).readonly()}),CY=b({source:_Y,policy:rY,autoPending:v(),computedAt:r().nullable(),trigger:u().nullable(),nodes:S(SY).readonly(),nodeWeights:h(u(),r()),deviceWeights:h(u(),h(u(),r()))}),wY=[`motion-without-detections`,`detections-under-floor`,`inference-too-slow`,`frames-shed`,`inference-device-unusable`],TY=x(wY),EY=x([`info`,`warning`,`critical`]),DY=a(`type`,[b({type:m(`camera`),deviceId:r()}),b({type:m(`node`),nodeId:u()}),b({type:m(`inference-device`),nodeId:u(),deviceKey:u()})]),OY=b({id:u(),kind:TY,severity:EY,subject:DY,what:u(),evidence:h(u(),r().nullable()),action:u()}),kY=b({source:u(),entries:r().nullable()}),AY=b({nodeId:u(),sessionsNow:r(),unusableDevices:S(u()).readonly(),devices:S(b({deviceKey:u(),sessionsNow:r(),usable:v()})).readonly()}),jY=b({deviceId:r(),nativeCropMissesSincePreviousTick:r().nullable()}),MY=b({generatedAt:r(),tickMs:r(),camerasSeen:r().nullable(),findings:S(OY).readonly(),cameraSignals:S(jY).readonly(),nodes:S(AY).readonly(),sources:S(kY).readonly(),notCovered:S(u()).readonly()}),NY=b({history:r().int().min(1).max(24).default(1)}),PY=b({latest:MY.nullable(),previous:S(MY).readonly()}),vTe=b({engine:fU.optional(),steps:S(aU).readonly(),audio:b({engine:fU.optional(),modelId:u().optional(),enabled:v(),settings:h(u(),C()).readonly().optional()}).nullable().optional()}),FY=b({modelId:u().optional(),settings:h(u(),C()).optional(),jumpDeviceKey:u().optional(),enabled:v().optional()}),IY=b({maxCameras:r().int().nonnegative().nullable().default(null),detectWeight:r().positive().optional(),detect:v().optional(),decode:v().optional(),audio:v().optional(),ingest:v().optional(),decodeBudgetMb:r().int().min(1024).max(65536).optional(),maxLiveDecodeWorkers:r().int().min(1).max(32).optional(),reachableHost:u().optional(),color:Nu.optional(),stepSettings:h(u(),h(u(),C()).readonly()).optional(),stepEnabled:h(u(),v()).optional(),inferenceDevices:h(u(),b({enabled:v(),weight:r().positive().optional(),maxSessions:r().int().positive().optional(),steps:h(u(),FY).optional()})).optional()}),yTe=h(u(),h(u(),C()).readonly()),LY=x([`pipeline`,`onboard`,`none`]),bTe=b({stepToggles:h(u(),v()).optional(),stepSettings:yTe.optional()}),RY=b({deviceId:r(),agentNodeId:u(),pinned:v(),reason:x([`manual`,`capacity`,`hardware-affinity`,`failover`,`rebalance`]),assignedAt:r()}),zY=b({nodeId:u(),online:v(),load:TW,score:r(),decodeHwaccel:u().nullable()}),BY=b({totalAgents:r(),onlineAgents:r(),totalCameras:r(),attachedCameras:r(),activeCameras:r(),avgInferenceTimeMs:r(),queueDepth:r()}),VY=h(u(),u()),HY=b({ownerNodeId:u(),reachableHost:u().optional(),configIssue:u().optional()}),UY=b({camStreamId:u(),codec:u(),width:r(),height:r(),fps:r(),kind:u()}),WY=b({streams:S(UY).readonly()}),GY=b({detectionNodeId:u().nullable(),decoderNodeId:u().nullable(),audioNodeId:u().nullable(),sourceNodeId:u().nullable(),pinned:b({detection:v(),decoder:v(),audio:v()}),reasons:b({detection:u().optional(),decoder:u().optional(),audio:u().optional()})}),KY=b({profile:u(),status:u(),codec:u(),width:r(),height:r(),subscribers:r(),inFps:r().nullable()}),qY=b({profiles:S(KY).readonly(),webrtcSessions:r(),rtspRestream:v()}),JY=b({nodeId:u()}),YY=b({enabled:v(),fps:r()}),XY=x([`idle`,`installing`,`verifying`,`ready`,`failed`]),ZY=b({state:XY,error:u().optional()}),QY=x([`idle`,`watching`,`active`]),$Y=b({nodeId:u(),engine:b({backend:u(),device:u()}),phase:QY,configuredFps:r(),actualFps:r(),queueDepth:r(),avgInferenceMs:r(),provisioning:ZY}),eX=b({nodeId:u(),enabled:v()}),tX=kc,nX=b({mode:tX,active:v(),storageBytes:r()}),rX=x([`source`,`broker`,`detection`,`recording`,`switches`]),iX=x([`timeout`,`error`,`partial`]),aX=b({stage:rX,reason:iX,elapsedMs:r()}),oX=b({state:x([`idle`,`running`,`done`,`error`]),total:r().int().nonnegative(),completed:r().int().nonnegative(),currentDeviceId:r().int().nullable(),failed:S(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()}),sX=b({deviceId:r(),assignment:GY,source:WY,broker:qY.nullable(),decoder:JY.nullable(),motion:YY.nullable(),detection:$Y.nullable(),audio:eX.nullable(),recording:nX.nullable(),switchedOff:S(Za).readonly(),cameraSensors:LB.optional(),degraded:S(aX).readonly(),fetchedAt:r()}),cX=[`disabled`,`unavailable`,`cannot-host-camera-root`,`accelerator-preferred`,`root-switched-off`],lX=x(cX),xTe=b({key:u(),backend:u(),device:u(),format:x(Ld),available:v(),presence:x([`present`,`absent`,`unknown`]).optional(),enabled:v(),weight:r(),maxSessions:r().nullable(),defaultModelId:u(),steps:h(u(),FY).optional(),exclusion:lX.nullable()}),uX=a(`kind`,[b({kind:m(`stored`),modelId:u()}),b({kind:m(`absent`),defaultModelId:u()}),b({kind:m(`unreadable`),reason:x(ZB),error:u().optional()})]),STe=b({nodeId:u(),reachable:v(),devices:S(xTe).readonly()}),dX=x([`off`,`on`,`opt-in`]),fX=a(`kind`,[b({kind:m(`on`)}),b({kind:m(`off-cluster`)}),b({kind:m(`off-node`)}),b({kind:m(`off-device`)}),b({kind:m(`jump`),toDeviceKey:u()}),b({kind:m(`skip`),reason:x([`no-compatible-model`,`root-not-runnable-on-elected-device`])}),b({kind:m(`zone-driven`)}),b({kind:m(`supplied-by-root`),rootModelId:u()}),b({kind:m(`opt-in-unused`)})]),CTe=b({deviceKey:u(),format:x(Ld),stepEnabled:v().nullable(),eligible:v(),cell:fX}),wTe=b({nodeId:u(),reachable:v(),stepEnabled:v().nullable(),devices:S(CTe).readonly()}),pX=b({steps:S(b({stepId:u(),name:u(),slot:u(),clusterMode:dX.nullable(),effectiveMode:dX,camerasEnabling:r().int().nonnegative(),camerasDisabling:r().int().nonnegative(),nodes:S(wTe).readonly()})).readonly()}),mX=b({deviceId:r().int().nonnegative(),config:AB.nullable()}),hX=x([`unknown-camera`,`out-of-range`,`no-burst-producer`,`already-looked`]),gX=b({deviceId:r().int().nonnegative(),afterMs:r().finite(),reason:u()}),_X=b({scheduled:v(),dueInMs:r().optional(),refusedBecause:hX.optional()}),vX={name:`pipeline-orchestrator`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,exposesDeviceSettings:!0,methods:{requestOccupancyLook:E(gX,_X,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:E(Yc,b({paused:m(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:E(Yc,b({resumed:m(!0)}),{kind:`mutation`,auth:`admin`}),assignPipeline:E(b({deviceId:r(),agentNodeId:u()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),unassignPipeline:E(b({deviceId:r()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setPipelineDevicePin:E(b({deviceId:r(),deviceKey:u()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getPipelineDevicePin:E(b({deviceId:r()}),b({deviceKey:u().nullable()})),rebalance:E(_(),b({migrated:r(),skipped:S(b({deviceId:r(),targetNodeId:u(),reason:u()})).default([])}),{kind:`mutation`,auth:`admin`}),getPipelineAssignments:E(_(),S(RY).readonly()),getPipelineAssignment:E(b({deviceId:r()}),RY.nullable()),getAgentLoad:E(_(),S(zY).readonly()),getClusterModelChoice:E(b({stepId:u()}),uX),getGlobalMetrics:E(_(),BY),getCameraMetrics:E(b({deviceId:r()}),yU.nullable()),getCapabilityBindings:E(b({nodeId:u()}),VY),setCapabilityBinding:E(b({nodeId:u(),capName:u(),addonId:u()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getIngestOwner:E(_(),HY),assignAudio:E(b({deviceId:r(),nodeId:u()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),unassignAudio:E(b({deviceId:r()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getAudioAssignment:E(b({deviceId:r()}),b({nodeId:u(),pinned:v(),assignedAt:r()}).nullable()),getAudioNodeLoad:E(_(),S(b({nodeId:u(),deviceCount:r()}))),getAudioAssignments:E(_(),S(b({deviceId:r(),nodeId:u(),pinned:v(),assignedAt:r()}))),getAgentSettings:E(b({agentNodeId:u()}),IY.nullable()),listAgentSettings:E(_(),S(b({nodeId:u(),settings:IY})).readonly()),removeAgentSettings:E(b({agentNodeId:u()}),b({success:v(),removed:v()}),{kind:`mutation`,auth:`admin`}),setAgentMaxCameras:E(b({agentNodeId:u(),maxCameras:r().int().nonnegative().nullable()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentCapabilities:E(b({agentNodeId:u(),detect:v().nullable().optional(),audio:v().nullable().optional(),ingest:v().nullable().optional()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentDecodeLimits:E(b({agentNodeId:u(),decodeBudgetMb:r().int().min(1024).max(65536).nullable().optional(),maxLiveDecodeWorkers:r().int().min(1).max(32).nullable().optional()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentReachableHost:E(b({agentNodeId:u(),reachableHost:u().nullable().optional(),color:Nu.nullable().optional()}).refine(e=>e.reachableHost!==void 0||e.color!==void 0,{message:`reachableHost or color required`}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentInferenceDevices:E(b({agentNodeId:u(),inferenceDevices:h(u(),b({enabled:v(),weight:r().positive().optional(),maxSessions:r().int().positive().optional(),steps:h(u(),FY).optional()}))}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepSettings:E(b({agentNodeId:u(),addonId:u(),settings:h(u(),C()).nullable()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setClusterStepMode:E(b({stepId:u(),mode:dX.nullable()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepEnabled:E(b({agentNodeId:u(),stepId:u(),enabled:v().nullable()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setDeviceStepEnabled:E(b({agentNodeId:u(),deviceKey:u(),stepId:u(),enabled:v().nullable()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getStepSwitches:E(_(),pX),getNodeInferenceDevices:E(b({nodeId:u()}),STe),forgetInferenceDevice:E(b({agentNodeId:u(),deviceKey:u()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),resetNodePipelineDefaults:E(b({agentNodeId:u()}),b({success:m(!0),effectiveModelId:u().nullable()}),{kind:`mutation`,auth:`admin`}),planAutoTune:E(QJ,$J,{auth:`admin`}),applyAutoTune:E(eY,nY,{kind:`mutation`,auth:`admin`}),setLoadBalancingShares:E(aY,b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getPlacementStats:E(oY,uY,{auth:`admin`}),getHealthDigest:E(NY,PY,{auth:`admin`}),suggestShares:E(pY,gY,{auth:`admin`}),getEffectiveShares:E(_(),CY,{auth:`admin`}),setShareSource:E(bY,b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkPreflight:E(OU,NU,{auth:`admin`}),startNodeBenchmark:E(OU,a(`kind`,[b({kind:m(`started`),runId:u()}),b({kind:m(`refused`),preflight:NU})]),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkStatus:E(_(),JU,{auth:`admin`}),abortNodeBenchmark:E(b({runId:u()}),b({aborted:v()}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkCandidates:E(b({nodeId:u()}),QU,{auth:`admin`}),listNodeBenchmarkResults:E(XU,S(ZU).readonly(),{auth:`admin`}),deleteNodeBenchmarkResult:E(b({id:u()}),b({deleted:v()}),{kind:`mutation`,auth:`admin`}),getCameraSettings:E(b({deviceId:r()}),bTe.nullable()),setCameraStepToggle:E(b({deviceId:r(),addonId:u(),enabled:v().nullable()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getCameraDetectionSource:E(b({deviceId:r()}),b({source:LY,explicit:v(),onboard:b({available:v(),geometry:x([`boxed`,`while-streaming`,`flag-only`,`unknown`])})})),setCameraDetectionSource:E(b({deviceId:r(),source:LY}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setCameraStepSettings:E(b({deviceId:r(),addonId:u(),settings:h(u(),C()).nullable()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),resolvePipeline:E(b({deviceId:r(),agentNodeId:u().optional()}),vTe),getCameraSwitches:E(b({deviceId:r()}),$a,{role:`viewer`}),setCameraSwitch:E(b({deviceId:r(),switchId:Za,enabled:v()}),$a,{kind:`mutation`,auth:`admin`}),getCameraStatus:E(b({deviceId:r()}),sX),getCameraStatuses:E(b({deviceIds:S(r()).optional()}),S(sX).readonly()),setCameraSensors:E(mX,b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),reconcileFromDisk:E(_(),oX,{kind:`mutation`,auth:`admin`}),getReconcileFromDiskStatus:E(_(),oX,{auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},yX=b({id:u(),name:u(),sampleCount:r().int().nonnegative(),coverMediaId:r().int().optional(),coverBase64:u().optional()}),TTe=b({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:ny.optional()}),bX=b({plateId:u(),deviceId:r().int(),trackId:u(),timestamp:r().int(),text:u(),score:r(),corrected:v(),recognizedVehicleId:u().optional(),vehicleName:u().optional(),assigned:v(),plateBbox:ny.optional(),keyFrameMediaId:r().int().optional(),base64:u().optional(),cropUrl:u().optional(),cropMissReason:u().optional()}),ETe=b({mediaId:r().int(),kind:u(),url:u(),sizeBytes:r(),timestamp:r()}),DTe=b({plateIds:S(u()).readonly(),representativePlateId:u(),representativeText:u(),size:r().int(),cohesion:r()}),xX={name:`plate-gallery`,role:{feature:`plate-assignment`},scope:`system`,mode:`singleton`,methods:{listPlates:E(b({deviceId:r().int().optional(),limit:r().int().positive().optional(),includeCrops:v().optional()}).optional(),S(bX).readonly()),getPlateByTrack:E(b({deviceId:r().int(),trackId:u()}),bX.nullable(),{role:`viewer`}),getPlateMedia:E(b({plateId:u()}),S(ETe).readonly()),searchPlates:E(b({text:u().min(1),maxDistance:r().int().min(0).optional(),limit:r().int().positive().optional(),includeCrops:v().optional()}),S(bX).readonly()),suggestPlateClusters:E(b({maxDistance:r().int().min(0).optional(),minClusterSize:r().int().min(2).optional(),limit:r().int().positive().optional()}).optional(),S(DTe).readonly()),correctPlateText:E(b({plateId:u(),text:u().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deletePlate:E(b({plateId:u()}),_(),{kind:`mutation`,auth:`admin`}),listVehicles:E(b({includeCrops:v().optional()}).optional(),S(yX).readonly()),createVehicle:E(b({name:u().min(1)}),yX,{kind:`mutation`,auth:`admin`}),renameVehicle:E(b({id:u(),name:u().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deleteVehicle:E(b({id:u()}),_(),{kind:`mutation`,auth:`admin`}),listVehicleSamples:E(b({vehicleId:u()}),S(TTe).readonly()),removeVehicleSample:E(b({vehicleId:u(),sampleId:u()}),_(),{kind:`mutation`,auth:`admin`}),moveVehicleSample:E(b({sampleId:u().min(1),toVehicleId:u().min(1)}),_(),{kind:`mutation`,auth:`admin`}),assignPlate:E(b({plateId:u(),vehicleId:u()}),_(),{kind:`mutation`,auth:`admin`}),unassignPlate:E(b({plateId:u()}),_(),{kind:`mutation`,auth:`admin`}),assignPlates:E(b({plateIds:S(u()).min(1),vehicleId:u()}),b({assigned:r().int(),failed:S(u()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignPlates:E(b({plateIds:S(u()).min(1)}),b({unassigned:r().int(),failed:S(u()).readonly()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the plate gallery — curated on its own page`}},SX={"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}}},"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}}}},CX={"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}},wX=.5,OTe=.05,TX=2e3,EX=r().nullable().transform(e=>e!==null&&Number.isFinite(e)&&e>0?e:null),DX=u().nullable().transform(e=>e!==null&&e.trim()!==``?e:null),OX=b({int8:EX,fp16:EX}),kX=b({deviceKey:u(),fullDeviceName:DX,executionUnits:EX,clockMHz:EX,gops:OX.nullable(),architecture:DX,npuName:DX,tops:EX,vendor:DX,webgpuArchitecture:DX,webgpuDevice:DX,computeUnits:EX}),kTe=b({accelerators:S(kX).nullable()}),AX=[{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*TX}},{hardwareClass:`amd-phoenix`,accelerator:`amd-igpu`,score:{metric:`cu`,value:12}}];function ATe(e){let t=kTe.safeParse(e);return!t.success||t.data.accelerators===null?null:t.data.accelerators}function jX(e){return e!==null&&e>0?e:null}function MX(e){let t=[],n=jX(e.gops?.int8??null);n!==null&&t.push({metric:`gops-int8`,value:n});let r=jX(e.gops?.fp16??null);r!==null&&t.push({metric:`gops-fp16`,value:r});let i=jX(e.executionUnits),a=jX(e.clockMHz);i!==null&&a!==null&&t.push({metric:`eu-mhz`,value:i*a});let o=jX(e.computeUnits);o!==null&&t.push({metric:`cu`,value:o});let s=jX(e.tops);return s!==null&&t.push({metric:`tops`,value:s}),t}function NX(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 PX(e,t,n){for(let r of MX(e))if(NX(t,r,n)!==null)return r;return null}function FX(e,t,n=AX){return PX(e,t,n)!==null}function IX(e,t,n){if(t!==`unknown`)return e[t]?.[n]}function jTe(e){return Math.round(e*10)/10}function MTe(e){return Math.min(2,Math.max(wX,e))}function NTe(e,t,n){let r={};for(let[i,a]of Object.entries(e))r[i]={p50Ms:jTe(a.p50Ms/t),fps:Math.max(1,Math.round(a.fps*t)),measured:!1,estimatedFrom:n};return r}function LX(e){let t=e.perf??SX,n=e.references??AX,r=IX(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:PX(e.report,e.accelerator,n);if(i===null)return r===void 0?null:{column:r,estimatedFrom:null};let a=NX(e.accelerator,i,n),o=a===null?void 0:IX(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:NTe(o,MTe(s),a.hardwareClass),estimatedFrom:a.hardwareClass}}var RX=x(Ld),PTe=x([`videotoolbox`,`cuda`,`nvdec`,`vaapi`,`qsv`,`d3d11va`,`dxva2`,`amf`,`vdpau`,`drm`,`coreml`,`tensorrt`,`openvino`,`directml`,`webgpu`,`none`]).nullable().optional(),FTe=b({preferred:S(u()).readonly(),rationale:u()}),zX=x([`h264_videotoolbox`,`hevc_videotoolbox`,`h264_vaapi`,`hevc_vaapi`,`h264_nvenc`,`hevc_nvenc`,`h264_qsv`,`hevc_qsv`,`h264_amf`,`hevc_amf`,`libx264`,`libx265`]);b({encoders:S(b({encoder:zX,codec:x([`H264`,`H265`]),family:x([`videotoolbox`,`vaapi`,`nvenc`,`qsv`,`amf`,`software`]),available:v(),reason:u().optional()})).readonly(),defaultH264:zX,defaultH265:zX,probedAt:r()}),b({methods:S(u()).readonly(),probedAt:r()});var ITe=x([`darwin`,`linux`,`win32`]),LTe=x([`arm64`,`x64`]),RTe=b({type:x([`nvidia`,`amd`,`intel`,`apple`]),name:u(),memoryMB:r().optional()}),zTe=b({type:x([`apple-ane`,`intel-npu`,`amd-xdna`]),name:u().optional(),generation:x([`xdna1`,`xdna2`]).optional()}),BX=x([`usb`,`pci`]),BTe=b({type:m(`coral-edgetpu`),bus:u().optional(),count:r().int().nonnegative().optional(),units:S(b({bus:BX,count:r().int().nonnegative()})).readonly().optional(),unavailable:S(b({bus:BX,count:r().int().nonnegative(),reason:x([`driver-missing`,`device-not-accessible`])})).readonly().optional()}),VX=b({type:m(`nvidia`),name:u(),memoryMB:r().optional()}),VTe=a(`usable`,[VX.extend({usable:m(!0)}),VX.extend({usable:m(!1),reason:x([`no-cuda-execution-provider`])})]),HX=b({platform:ITe,arch:LTe,cpuModel:u(),cpuCores:r(),totalRAM_MB:r(),availableRAM_MB:r(),gpu:RTe.nullable(),npu:zTe.nullable(),coral:BTe.nullable().optional(),nvidia:VTe.nullable().optional(),accelerators:S(kX).readonly().optional()}),UX=b({runtime:m(`python`),backend:u(),format:x([`onnx`,`coreml`,`openvino`,`tflite`]),score:r(),reason:u(),available:v()}),WX=b({key:u(),backend:u(),device:u(),format:RX,runtime:m(`python`),score:r(),available:v()}),HTe=b({hardware:HX,scores:S(UX).readonly(),bestScore:UX,pythonPath:u().nullable(),devices:S(WX).readonly()}),UTe=b({modelId:u(),name:u(),minRAM_MB:r(),accuracyScore:r(),formats:S(u()).readonly()}),WTe=b({modelId:u(),runtime:m(`python`),backend:u(),format:RX,reason:u()}),GTe=b({devices:S(WX).readonly(),appeared:S(u()).readonly(),disappeared:S(u()).readonly(),usbBus:x([`observed`,`unobservable`]),decidedBy:x([`usb-ids`,`pci`,`delegate-fallback`,`none`])}),GX={name:`platform-probe`,scope:`system`,mode:`singleton`,methods:{getCapabilities:E(_(),HTe),getHardware:E(_(),HX),resolveInferenceConfig:E(b({requirements:S(UTe).readonly()}),WTe),resolveHwAccel:E(b({prefer:PTe}),FTe),rescanAccelerators:E(_(),GTe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.CLUSTER}},KX=b({power:r().optional().meta(k(`power`,{label:`Power`})),deliveredPower:r().optional().meta(k(`power`,{label:`Delivered`})),energy:r().optional().meta(k(`energy`,{label:`Energy`})),voltage:r().optional().meta(k(`voltage`,{label:`Voltage`})),current:r().optional().meta(k(`current`,{label:`Current`})),apparentPower:r().optional().meta(k(`apparent-power`)),powerFactor:r().min(0).max(1).optional().meta(k(`ratio`)),lastFetchedAt:r()});function qX(e){if(e.power===void 0)return;let t=e.power-(e.deliveredPower??0);return t<0?void 0:t}var JX=[j.Sensor,j.Switch,j.Light,j.Fan,j.Climate,j.Humidifier,j.WaterHeater,j.MediaPlayer,j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.PetFeeder,j.Workload],KTe=JX.filter(e=>e!==j.Sensor);function YX(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`power-meter`,stateField:e},deviceTypes:KTe,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 qTe={version:1,targets:[YX(`power`,`W`),YX(`energy`,`kWh`),YX(`voltage`,`V`),YX(`current`,`A`)]},XX={name:`power-meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:JX,deviceConfig:{ui:{kind:`widget`,widgetId:`host/power-meter-line`,tab:`power`,placement:`hero`,label:`Power`,order:4}},methods:{},status:{schema:KX,kind:`push`},runtimeState:KX,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:qTe,vocabulary:{noun:I(`Power meter`,`Misuratore di energia`),order:5160,state:[{kind:`numeric`,field:`power`,quantity:I(`the power draw`,`il consumo`),label:I(`Power`,`Potenza`),unit:`W`,icon:`zap`},{kind:`numeric`,field:`energy`,quantity:I(`the energy used`,`l’energia consumata`),label:I(`Energy`,`Energia`),unit:`kWh`,icon:`zap`},{kind:`numeric`,field:`voltage`,quantity:I(`the voltage`,`la tensione`),label:I(`Voltage`,`Tensione`),unit:`V`,icon:`zap`},{kind:`numeric`,field:`current`,quantity:I(`the current`,`la corrente`),label:I(`Current`,`Corrente`),unit:`A`,icon:`zap`}]}},JTe=b({latitude:r().min(-90).max(90).meta(k(`angle`)),longitude:r().min(-180).max(180).meta(k(`angle`)),accuracyMeters:r().nonnegative().meta(k(`length`))}),ZX=b({state:u(),location:u().nullable(),gps:JTe.nullable(),lastChangedAt:r()}),QX={name:`presence`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Presence],methods:{},status:{schema:ZX,kind:`push`},runtimeState:ZX,durability:`restored`,history:`none`,volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Presence`,`Presenza`),order:5170,state:[{kind:`value`,field:`state`,label:I(`Where`,`Posizione`),phrase:I(`When {device} is at {value}`,`Quando {device} è in {value}`),icon:`map-pin`}]}},$X=b({pressure:r().nullable().meta(k(`pressure`,{precision:0})),lastFetchedAt:r()}),eZ={name:`pressure-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:$X,kind:`push`},runtimeState:$X,durability:`restored`,history:{fields:{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Pressure`,`Pressione`),order:5180,state:[{kind:`numeric`,field:`pressure`,quantity:I(`the pressure`,`la pressione`),label:I(`Pressure`,`Pressione`),unit:`hPa`,icon:`gauge`}]}},YTe=a(`kind`,[WB,GB]),tZ=b({id:r(),enabled:v(),shape:YTe}),nZ=b({enabled:v(),regions:S(tZ).nullable(),audioEnabled:v().nullable(),lastFetchedAt:r()}),rZ=b({maxRegions:r(),supportedShapes:S(JB),polygonVertices:YB.optional(),supportsAudioMute:v()}),iZ=b({enabled:v().optional(),regions:S(tZ).optional()}),aZ={name:`privacy-mask`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/privacy-mask-grid`,tab:`image`,label:`Privacy Mask`}},methods:{getOptions:E(b({deviceId:r()}),rZ),setMask:E(b({deviceId:r(),patch:iZ}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.maskOn`,label:I(`Privacy mask on`,`Maschera privacy attiva`),phrase:I(`Cover the privacy zones of {device}`,`Oscura le zone private di {device}`),icon:`eye-off`,args:{patch:{enabled:!0}}},{id:`privacy.maskOff`,label:I(`Privacy mask off`,`Maschera privacy spenta`),phrase:I(`Uncover the privacy zones of {device}`,`Scopri le zone private di {device}`),icon:`eye`,args:{patch:{enabled:!1}}}]}),setAudioEnabled:E(b({deviceId:r(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.micOn`,label:I(`Microphone on`,`Microfono attivo`),phrase:I(`Turn on the microphone of {device}`,`Attiva il microfono di {device}`),icon:`mic`,args:{enabled:!0}},{id:`privacy.micOff`,label:I(`Microphone off`,`Microfono spento`),phrase:I(`Turn off the microphone of {device}`,`Disattiva il microfono di {device}`),icon:`mic-off`,args:{enabled:!1}}]})},status:{schema:nZ,kind:`poll`},runtimeState:nZ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Privacy`,`Privacy`),order:3210,state:[{kind:`boolean`,field:`enabled`,label:I(`Privacy mask`,`Maschera privacy`),whenTrue:I(`When the privacy mask of {device} is turned on`,`Quando si attiva la maschera privacy di {device}`),whenFalse:I(`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:I(`Microphone`,`Microfono`),whenTrue:I(`When the microphone of {device} is turned on`,`Quando si attiva il microfono di {device}`),whenFalse:I(`When the microphone of {device} is turned off`,`Quando si disattiva il microfono di {device}`),icon:`mic`}]}};function XTe(e){return e.length===0?null:e.some(e=>e.audioEnabled)}var oZ=x([`home`,`day-mode`,`night-mode`,`day-night-auto`,`set-limits`,`save-limits`,`reboot`,`osd-menu`]),sZ=b({id:u(),name:u(),fn:oZ.nullable(),writable:v()}),cZ=b({pan:r().nullable(),tilt:r().nullable(),zoom:r().nullable()}),lZ=b({pan:r().optional(),tilt:r().optional(),zoom:r().optional(),speed:r().optional()}),uZ=cZ.extend({autofocus:v()}),dZ=b({hasPan:v(),hasTilt:v(),hasZoom:v(),supportsPresets:v(),maxPresets:r().optional(),hasAutofocus:v(),speedSteps:r().int().positive().nullable(),moveImpulseMs:r().int().positive().nullable()}),fZ=b({presetId:u().nullable(),source:x([`operator`,`firmware`,`native`,`none`])}),pZ=b({enabled:v(),seconds:r().int()}),mZ={name:`ptz`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-panel`,tab:`ptz`,topTab:!0,label:`PTZ`,order:0}},methods:{move:E(lZ.extend({deviceId:r()}),_(),{kind:`mutation`,notOperatorFacing:`a relative nudge from the live-view joystick; a fixed place is a preset`}),continuousMove:E(lZ.extend({deviceId:r()}),_(),{kind:`mutation`,notOperatorFacing:`joystick motion held until released — continuous, not a discrete step`}),goHome:E(b({deviceId:r()}),_(),{kind:`mutation`,actions:[{id:`ptz.goHome`,label:I(`PTZ go home`,`Torna alla posizione iniziale`),phrase:I(`Send {device} to its home position`,`Riporta {device} alla posizione iniziale`),icon:`house`}]}),getPresets:E(b({deviceId:r()}),S(sZ)),goToPreset:E(b({deviceId:r(),presetId:u()}),_(),{kind:`mutation`,actions:[{id:`ptz.goToPreset`,label:I(`PTZ go to preset`,`Vai a un preset`),phrase:I(`Move {device} to {presetId}`,`Sposta {device} su {presetId}`),icon:`move`,openArgs:[{key:`presetId`,label:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),savePreset:E(b({deviceId:r(),presetId:u(),name:u()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.savePreset`,label:I(`Save PTZ preset here`,`Salva qui un preset`),phrase:I(`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:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}},{key:`name`,label:I(`Name`,`Nome`),offer:{kind:`text`}}]}]}),deletePreset:E(b({deviceId:r(),presetId:u()}),_(),{kind:`mutation`,auth:`admin`}),getOptions:E(b({deviceId:r()}),dZ),stop:E(b({deviceId:r()}),_(),{kind:`mutation`,actions:[{id:`ptz.stop`,label:I(`Stop moving`,`Ferma il movimento`),phrase:I(`Stop {device} moving`,`Ferma il movimento di {device}`),icon:`square`}]}),getHomePreset:E(b({deviceId:r()}),fZ),setHomePreset:E(b({deviceId:r(),presetId:u().nullable()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomePreset`,label:I(`Set PTZ home preset`,`Imposta il preset iniziale`),phrase:I(`Make {presetId} the home position of {device}`,`Rendi {presetId} la posizione iniziale di {device}`),icon:`house`,openArgs:[{key:`presetId`,label:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),captureHomeHere:E(b({deviceId:r()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.captureHomeHere`,label:I(`Set PTZ home here`,`Imposta qui la posizione iniziale`),phrase:I(`Make where {device} points now its home position`,`Rendi la posizione attuale di {device} la sua posizione iniziale`),icon:`map-pin`}]}),getHomeReturn:E(b({deviceId:r()}),pZ.nullable()),setHomeReturn:E(b({deviceId:r(),enabled:v(),seconds:r().int().min(0).max(3600)}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomeReturn`,label:I(`Set PTZ return home`,`Imposta il ritorno alla posizione iniziale`),phrase:I(`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:I(`Return home`,`Torna alla posizione iniziale`),offer:{kind:`boolean`}},{key:`seconds`,label:I(`Idle seconds`,`Secondi da fermo`),offer:{kind:`number`,min:0,max:3600,step:1,unit:`s`}}]}]}),getPosition:E(b({deviceId:r()}),cZ),setAutofocus:E(b({deviceId:r(),enabled:v()}),_(),{kind:`mutation`,actions:[{id:`ptz.autofocusOn`,label:I(`Autofocus on`,`Autofocus attivo`),phrase:I(`Turn on autofocus on {device}`,`Attiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!0}},{id:`ptz.autofocusOff`,label:I(`Autofocus off`,`Autofocus spento`),phrase:I(`Turn off autofocus on {device}`,`Disattiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!1}}]})},status:{schema:uZ,kind:`command-driven`},vocabulary:{noun:I(`Pan / tilt / zoom`,`Brandeggio`),order:3220}},hZ=b({targetType:u().describe(`Vendor target string (people/vehicle/pet); empty = camera default`),stopDelaySeconds:r().int().min(0).max(300).meta(k(`duration`)),disappearDelaySeconds:r().int().min(0).max(300).meta(k(`duration`))}),gZ=b({value:u(),label:u()}),_Z=b({enabled:v(),lastChangedAt:r(),currentSettings:hZ.nullable(),supportedTargetTypes:S(gZ)}),vZ=_Z.extend({lastFetchedAt:r()}),yZ={name:`ptz-autotrack`,scope:`device`,deviceNative:!0,mode:`singleton`,kind:`wrapper`,defaultActive:!1,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-autotrack`,tab:`ptz`,topTab:!0,label:`Auto-Tracking`,order:5}},methods:{getStatus:E(b({deviceId:r()}),_Z),setEnabled:E(b({deviceId:r(),enabled:v()}),_(),{kind:`mutation`,actions:[{id:`ptz.autotrackOn`,label:I(`Autotrack on`,`Inseguimento attivo`),phrase:I(`Start autotracking on {device}`,`Attiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!0}},{id:`ptz.autotrackOff`,label:I(`Autotrack off`,`Inseguimento spento`),phrase:I(`Stop autotracking on {device}`,`Disattiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!1}}]}),getSettings:E(b({deviceId:r()}),hZ.nullable()),setSettings:E(b({deviceId:r(),settings:hZ.partial()}),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`tracking tuning (target type, delays) — set once on the camera’s PTZ page`})},events:{onStatusChanged:{data:b({deviceId:r(),status:_Z}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:_Z,kind:`command-driven`},runtimeState:vZ,durability:`session`,history:`none`,vocabulary:{noun:I(`Autotracking`,`Inseguimento automatico`),order:3230,state:[{kind:`boolean`,field:`enabled`,label:I(`Autotracking`,`Inseguimento automatico`),whenTrue:I(`When autotracking is turned on for {device}`,`Quando si attiva l’inseguimento automatico di {device}`),whenFalse:I(`When autotracking is turned off for {device}`,`Quando si disattiva l’inseguimento automatico di {device}`),icon:`crosshair`}]}},bZ=b({enabled:v().nullable(),onTime:r().min(0).nullable().meta(k(`duration`)),offTime:r().min(0).nullable().meta(k(`duration`)),lastFetchedAt:r()}),xZ=r().int().nonnegative(),SZ=r().int().min(0),CZ={name:`pump-cycle`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.PetFountain],methods:{setEnabled:E(b({deviceId:xZ,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.on`,effect:{field:`enabled`,value:!0},label:I(`Pump cycle on`,`Ciclo pompa attivo`),phrase:I(`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:I(`Pump cycle off`,`Ciclo pompa spento`),phrase:I(`Run the pump of {device} continuously`,`Fai lavorare la pompa di {device} in continuo`),icon:`timer-off`,args:{on:!1}}]}),setOnMinutes:E(b({deviceId:xZ,minutes:SZ}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.onMinutes`,label:I(`Set pump run time`,`Imposta il tempo di lavoro della pompa`),phrase:I(`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:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]}),setOffMinutes:E(b({deviceId:xZ,minutes:SZ}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.offMinutes`,label:I(`Set pump rest time`,`Imposta il tempo di riposo della pompa`),phrase:I(`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:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]})},status:{schema:bZ,kind:`push`},runtimeState:bZ,durability:`session`,history:`none`,vocabulary:{noun:I(`Pump cycle`,`Ciclo della pompa`),order:2050,state:[{kind:`boolean`,field:`enabled`,label:I(`Pump cycle`,`Ciclo pompa`),whenTrue:I(`When {device} starts running its pump on a cycle`,`Quando {device} inizia a far lavorare la pompa a ciclo`),whenFalse:I(`When {device} runs its pump continuously`,`Quando {device} fa lavorare la pompa in continuo`),icon:`timer`}]}},wZ={name:`reboot`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera,j.Sensor,j.Switch,j.Gateway],methods:{reboot:E(b({deviceId:r().int().nonnegative()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`,actions:[{id:`reboot.reboot`,label:I(`Reboot device`,`Riavvia il dispositivo`),phrase:I(`Reboot {device}`,`Riavvia {device}`),icon:`refresh-cw`}]})},vocabulary:{noun:I(`Reboot`,`Riavvio`),order:3240}},TZ=b({owner:u(),kind:Bi,title:u(),nameField:u(),fields:h(u(),C()),secretPaths:S(u()),rows:r().int().nonnegative()}),EZ=b({id:Yz,name:u(),rev:r().int(),updatedAt:r(),data:Xz}),DZ={owner:u().min(1),kind:Bi},OZ={name:`record-entries`,scope:`system`,mode:`singleton`,methods:{listEntryKinds:E(b({}),b({kinds:S(TZ)}),{auth:`admin`}),listEntries:E(b({...DZ}),b({entries:S(EZ)}),{auth:`admin`}),putEntry:E(b({...DZ,id:Yz.optional(),data:Xz,ifRev:r().int().min(1).optional()}),b({id:u(),rev:r().int()}),{kind:`mutation`,auth:`admin`}),deleteEntry:E(b({...DZ,id:Yz}),b({deleted:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},ZTe=`camstack`,kZ=`recorder`,AZ=b({profile:u(),startMs:r(),endMs:r()}),jZ=x([`read`,`unreadable`]),MZ=b({deviceId:r(),read:jZ,ranges:S(AZ),profilesWithFootage:S(u())}),NZ=b({deviceId:r(),read:jZ,days:S(r())}),PZ=b({deviceId:r(),localMasterPath:u().nullable(),playbackUrl:u().nullable(),playbackEndpoints:S(u())}),FZ=b({state:x([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:u().optional(),coverageAsOf:r().optional()}),IZ=b({source:u(),label:u(),addonId:u().optional(),availability:FZ}),LZ=b({transport:x([`archive`,`stream`,`realtime`]),coverage:x([`continuous`,`sparse`]),seek:x([`free`,`forward`,`segment`]),stepBack:v(),scrub:v(),rates:S(r().positive()).min(1).readonly(),exclusive:v()}),RZ=a(`kind`,[b({kind:m(`hls`),manifest:PZ}),b({kind:m(`clip`),source:u(),clipId:u(),startsAtMs:r()}),b({kind:m(`none`),reason:u()})]),zZ={name:`recording`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],methods:{listSources:E(b({deviceId:r()}),S(IZ).readonly(),{kind:`query`,auth:`protected`}),getAvailability:E(b({deviceId:r(),provider:u().min(1),fromMs:r(),toMs:r(),profile:u().optional()}),MZ,{kind:`query`,auth:`protected`}),getDaysWithRecordings:E(b({deviceId:r(),provider:u().min(1),fromMs:r(),toMs:r(),tzOffsetMinutes:r()}),NZ,{kind:`query`,auth:`protected`}),getPlayback:E(b({deviceId:r(),provider:u().min(1),fromMs:r(),toMs:r(),profile:A.optional()}),RZ,{kind:`query`,auth:`protected`}),getPlaybackOptions:E(b({deviceId:r(),provider:u().min(1)}),LZ,{kind:`query`,auth:`protected`})},vocabulary:{noun:I(`Recording`,`Registrazione`),order:3250}},BZ=b({deviceId:r(),enabled:v(),activeMode:kc,nodeId:u(),storageBytes:r()}),VZ=b({deviceId:r(),read:x([`read`,`unreadable`]),ranges:S(AZ).readonly(),profilesWithFootage:S(u()).readonly()}),HZ=b({deviceId:r(),read:x([`read`,`unreadable`]),days:S(r()).readonly()}),UZ=b({deviceId:r(),usedBytes:r(),oldestMs:r().nullable().optional(),segments:r().optional(),residentBytes:r().optional(),residentOldestMs:r().nullable().optional()}),WZ=b({locationId:u().nullable(),locationIds:S(u()).optional(),root:u().optional(),usedBytes:r(),availableBytes:r().nullable(),totalBytes:r().nullable()}),GZ=b({nodeId:u(),totalUsedBytes:r(),devices:S(UZ),devicesRead:x([`archive`,`unavailable`]).optional(),complete:v().optional(),locations:S(WZ).optional()}),KZ=b({deviceId:r(),profile:u(),fromLocationId:u(),toLocationId:u(),bytes:r(),files:r().int()}),qZ=x([`unassigned`,`target-not-writable`,`below-threshold`,`no-headroom`]),JZ=b({deviceId:r(),profile:u(),fromLocationId:u(),toLocationId:u().nullable(),bytes:r(),reason:qZ}),YZ=b({moves:S(KZ),skipped:S(JZ),bytesToMove:r(),jobIds:S(u())}),XZ=b({throttleMbps:r().min(1).max(1e3).optional(),minMoveGb:r().min(0).optional()}),QTe=b({deviceId:r().int(),profile:u(),locationId:u()}),$Te=b({deviceId:r().int(),locationId:u()}),eEe=b({assignments:S(QTe),pins:S($Te),defaultLocations:h(u(),u())}),tEe=b({deviceId:r().int(),locationId:u().nullable()}),ZZ=a(`kind`,[b({kind:m(`segment`),startMs:r(),durMs:r(),bytes:r()}),b({kind:m(`gap`),nearestEdgeMs:r().nullable(),prevEndMs:r().nullable().optional()})]),QZ=b({data:y(Uint8Array)}),$Z=b({data:y(Uint8Array),gopStartMs:r(),gopDurMs:r()}),eQ=a(`kind`,[b({kind:m(`ok`),data:y(Uint8Array),gopStartMs:r(),gopDurMs:r(),reachesRequestedEnd:v()}),b({kind:m(`spans-multiple-segments`),segmentEndMs:r()})]),tQ={name:`recording-archive`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,status:{schema:BZ,kind:`command-driven`},methods:{getAvailabilityBatch:E(b({deviceIds:S(r()).min(1).max(200),fromMs:r(),toMs:r()}),S(VZ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getDaysWithRecordingsBatch:E(b({deviceIds:S(r()).min(1).max(200),fromMs:r(),toMs:r(),tzOffsetMinutes:r()}),S(HZ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getStorageUsage:E(b({}),GZ,{kind:`query`,auth:`admin`}),getDeviceConfig:E(b({deviceId:r()}),zc,{role:`viewer`,kind:`query`,auth:`protected`}),locateSegment:E(b({deviceId:r(),profile:u(),epochMs:r()}),ZZ,{kind:`query`,auth:`admin`}),readSegmentBytes:E(b({deviceId:r(),profile:u(),startMs:r()}),QZ,{kind:`query`,auth:`admin`}),readGopBytes:E(b({deviceId:r(),profile:u(),startMs:r(),epochMs:r()}),$Z,{kind:`query`,auth:`admin`}),readWindowBytes:E(b({deviceId:r(),profile:u(),startMs:r(),fromMs:r(),toMs:r()}),eQ,{kind:`query`,auth:`admin`}),setDeviceConfig:E(b({deviceId:r(),config:zc}),zc,{kind:`mutation`,auth:`admin`}),rescanStorage:E(b({deviceId:r()}),BZ,{kind:`mutation`,auth:`admin`}),pruneFootage:E(b({deviceId:r(),reason:qs.optional()}),b({floorMs:r().nullable(),deletedBuckets:r().int(),reclaimedBytes:r().int()}),{kind:`mutation`,auth:`admin`}),deleteFootprint:E(b({deviceId:r(),fromMs:r().optional(),toMs:r().optional()}),b({deletedBuckets:r().int(),reclaimedBytes:r().int()}),{kind:`mutation`,auth:`admin`}),listOpsLog:E(Ys,S(Js).readonly(),{kind:`query`,auth:`admin`}),renderGif:E(b({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)}),b({gifBase64:u(),fromMs:r(),toMs:r()}),{kind:`mutation`,auth:`admin`}),renderClip:E(b({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)}),b({clipBase64:u(),mime:u(),fromMs:r(),toMs:r(),bytes:r().int()}),{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:E(Yc,b({paused:m(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:E(Yc,b({resumed:m(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:E(Yc,b({refreshed:m(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:E(Xc,b({jobId:u()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:E(b({jobId:u()}),Kc.nullable(),{auth:`admin`}),cancelStorageMigrationMove:E(b({jobId:u()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),relocateFootage:E(Jc,b({jobId:u()}),{kind:`mutation`,auth:`admin`}),listRelocateJobs:E(b({}),S(Kc).readonly(),{kind:`query`,auth:`admin`}),getRelocateResidue:E(Sl,Cl,{kind:`query`,auth:`admin`}),reconcileLedgerAgainstDisk:E(wl,Ol,{kind:`mutation`,auth:`admin`}),cancelRelocateJob:E(b({jobId:u()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),planStorageRebalance:E(XZ,YZ,{kind:`query`,auth:`admin`}),startStorageRebalance:E(XZ,YZ,{kind:`mutation`,auth:`admin`}),getPlacement:E(b({}),eEe,{kind:`query`,auth:`admin`}),setDevicePlacement:E(tEe,b({ok:m(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.STORAGE}},nEe=x([`queue-full`,`camera-backoff`,`sleeping`,`camera-refused`,`no-keyframe`,`decode-failed`,`no-catalog-row`,`unsupported`,`unknown-device`,`uid-missing`]),rEe=x([`deferred`,`final`]),nQ=`x-camstack-reason`;function iEe(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 rQ=`x-camstack-reason-code`,iQ=`x-camstack-disposition`,aEe=`x-camstack-clip-transport`,aQ=b({id:u(),source:u(),kind:x([`motion`,`object`,`audio`,`native`]),timeRange:b({startMs:r(),endMs:r()}),labels:S(u()).max(3).optional(),thumbnail:u().optional(),stillAtMs:r().optional(),eventIds:S(u()).optional(),eventCount:r().int().nonnegative().optional(),holes:S(b({startMs:r(),endMs:r()})).optional(),thumbnailMint:u().optional(),thumbnailUnavailable:b({reason:x([`sleeping`,`camera-refused`,`no-keyframe`,`unsupported`])}).optional(),catalogAsOf:r().optional(),nativeTypes:S(u()).optional(),behaviours:S(u()).optional(),streams:b({sub:b({id:u(),bytes:r().optional()}).optional(),main:b({id:u(),bytes:r().optional()}).optional()}).optional(),supportSub:v().optional(),playable:v().optional(),unplayableReason:u().optional(),inProgress:v().optional()}),oQ=b({playbackUrl:u(),format:x([`hls`,`mp4`]).optional(),served:A.optional(),playbackEndpoints:S(u()).optional(),token:u().optional()}),sQ=x([`authorised`]),oEe=50*1024*1024,sEe=500*1024*1024,cQ=b({base64:u(),contentType:u(),name:u(),bytes:r().int().nonnegative(),served:A,durationMs:r().positive().optional()}),lQ=b({ticket:Xa,contentType:u(),name:u(),served:A,durationMs:r().positive().optional()}),uQ=x([`opus`,`pcmu`,`none`]),dQ=x([`not-requested`,`unsupported-ask`]),fQ=b({url:u().min(1),expiresAtMs:r(),transport:m(`forward-only`),served:A,servedAudio:uQ,audioReason:dQ.optional()}),pQ=[.25,.5,1,1.5,2,4,8],mQ=[.25,.5,1,1.5,2,4],hQ=[.25,.5,1],gQ=b({transport:x([`stream`,`file`]),seek:x([`forward`,`free`]),stepBack:v(),scrub:v(),rates:S(r().positive()).min(1).readonly()}),_Q=b({state:x([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:u().optional(),catalogAsOf:r().optional()}),vQ=b({source:u(),label:u(),addonId:u().optional(),availability:_Q}),yQ={name:`videoclips`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/clips-browser`,tab:`recording`,topTab:!0,label:`Clips`,order:100}},methods:{listClips:E(b({deviceId:r(),since:r(),until:r(),limit:r().int().positive().optional(),provider:u().min(1)}),S(aQ).readonly(),{kind:`query`,auth:`protected`}),listSources:E(b({deviceId:r()}),S(vQ).readonly(),{kind:`query`,auth:`protected`}),getClipPlayback:E(b({deviceId:r(),clipId:u(),profile:A.optional()}),oQ,{kind:`query`,auth:`protected`}),readClipBytes:D(b({deviceId:r(),clipId:u().min(1),provider:u().min(1),profile:A.optional(),maxBytes:r().int().positive().optional(),wake:sQ.optional()}),cQ,{kind:`query`,auth:`protected`}),offerClipBytes:D(b({deviceId:r(),clipId:u().min(1),provider:u().min(1),profile:A.optional(),maxBytes:r().int().positive().optional(),wake:sQ.optional()}),lQ,{kind:`query`,auth:`protected`}),dialClipStream:D(b({deviceId:r(),clipId:u().min(1),provider:u().min(1),profile:A.optional(),audio:uQ.optional(),wake:sQ.optional()}),fQ,{kind:`query`,auth:`protected`}),getPlaybackOptions:D(b({deviceId:r(),provider:u().min(1)}),gQ,{kind:`query`,auth:`protected`})},vocabulary:{noun:I(`Video clips`,`Clip video`),order:3330}},cEe={stream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:mQ},realtimeStream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:hQ},file:{transport:`file`,seek:`free`,stepBack:!0,scrub:!0,rates:pQ}},bQ=r().min(.25).max(32),xQ=b({fromSec:r().nonnegative(),toSec:r().nonnegative()}).refine(e=>e.toSec>e.fromSec,{message:`dense range must have toSec > fromSec`}),SQ=b({everyMs:r().int().positive(),ranges:S(xQ).min(1).max(200)}),CQ=b({everyMs:r().int().positive(),outputFps:r().int().min(1).max(60).optional(),dense:SQ.optional()}).superRefine((e,t)=>{e.dense!==void 0&&e.dense.everyMs>=e.everyMs&&t.addIssue({code:de.custom,message:`dense.everyMs must be strictly smaller than the base everyMs`,path:[`dense`,`everyMs`]})}),wQ=b({speed:bQ.optional(),timelapse:CQ.optional(),includeAudio:v(),maxLifeMs:r().int().positive(),deleteAfterDownload:v(),title:u().max(200).optional(),notifyTargetIds:S(u().min(1)).max(20).optional()}).superRefine((e,t)=>{e.speed!==void 0&&e.timelapse!==void 0&&t.addIssue({code:de.custom,message:`speed and timelapse are mutually exclusive`,path:[`timelapse`]})}),TQ=x([`queued`,`rendering`,`ready`,`failed`,`expired`,`deleted`]),EQ=b({kind:m(`footage`),deviceId:r(),profiles:S(u()).min(1),fromMs:r(),toMs:r()}),DQ=b({kind:m(`clip`),deviceId:r(),provider:u().min(1),source:u().min(1),sourceLabel:u().min(1),clipId:u().min(1),catalogWindow:b({sinceMs:r(),untilMs:r()}),profile:x([`high`,`mid`,`low`]),wake:sQ.optional()}),OQ=a(`kind`,[EQ,DQ]),kQ=b({id:u(),deviceId:r(),profile:u(),fromMs:r(),toMs:r(),subject:OQ.optional(),options:wQ,state:TQ,progressPct:r().nullable(),fileBytes:r().nullable(),expiresAt:r(),deleteAfterDownload:v(),downloadedAt:r().nullable(),createdAt:r(),createdBy:u(),error:u().nullable()}),AQ=x([`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 lEe(e,t){return t.length>0?`${e}: ${t}`:e}function uEe(e){if(e===null)return null;let t=e.split(`:`,1)[0]??``,n=AQ.safeParse(t.trim());return n.success?n.data:null}var jQ=b({url:u(),endpoints:S(u())}),dEe=50*1024*1024,MQ=b({base64:u(),contentType:u(),name:u(),bytes:r().int().nonnegative()});function NQ(e){return e.profiles!==void 0&&e.profiles.length>0?[...e.profiles]:typeof e.profile==`string`&&e.profile.length>0?[e.profile]:[]}var fEe=b({deviceId:r(),profile:u().optional(),profiles:S(u()).min(1).optional(),fromMs:r().optional(),toMs:r().optional(),subject:OQ.optional(),options:wQ}).superRefine((e,t)=>{if(e.subject?.kind===`clip`){e.subject.deviceId!==e.deviceId&&t.addIssue({code:de.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:de.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:de.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:de.custom,message:`a footage export needs fromMs and toMs`,path:[`fromMs`]}),(e.subject?.kind===`footage`?[...e.subject.profiles]:NQ(e)).length<1&&t.addIssue({code:de.custom,message:`pass profiles[] (min 1) or legacy profile`,path:[`profiles`]})});function pEe(e){if(e.subject!==void 0)return e.subject;let t=NQ(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 mEe(e){return e.subject===void 0?{kind:`footage`,deviceId:e.deviceId,profiles:[e.profile],fromMs:e.fromMs,toMs:e.toMs}:e.subject}var PQ={name:`recording-export`,scope:`system`,mode:`singleton`,methods:{createExport:E(fEe,kQ,{role:`viewer`,kind:`mutation`,auth:`protected`}),listExports:E(b({deviceId:r().optional()}),S(kQ),{role:`viewer`,kind:`query`,auth:`protected`}),getExport:E(b({exportId:u()}),kQ,{role:`viewer`,kind:`query`,auth:`protected`}),cancelExport:E(b({exportId:u()}),kQ,{role:`viewer`,kind:`mutation`,auth:`protected`}),deleteExport:E(b({exportId:u()}),kQ,{role:`viewer`,kind:`mutation`,auth:`protected`}),getDownloadUrl:E(b({exportId:u()}),jQ,{role:`viewer`,kind:`query`,auth:`protected`}),readExportBytes:E(b({exportId:u()}),MQ,{kind:`query`,auth:`protected`})},vocabulary:{notOperatorFacing:`recording exports — requested from the timeline, not an automation step`}},FQ=x([`continuous`,`motion`,`person`,`vehicle`,`animal`,`lineCrossing`,`intrusion`,`loitering`,`alarmInput`]),IQ=b({trigger:FQ,day:r().int().min(0).max(6).meta(k(`none`)),startMinute:r().int().min(0).max(1439).meta(k(`none`)),endMinute:r().int().min(1).max(1440).meta(k(`none`))}),LQ=b({id:u(),label:u().optional(),status:x([`ok`,`unformatted`,`error`,`offline`,`unknown`]),capacityMb:r().nullable(),freeMb:r().nullable(),writable:v().optional()}),RQ=a(`kind`,[b({kind:m(`present`),volumes:S(LQ)}),b({kind:m(`absent`),reason:u()}),b({kind:m(`unknown`),reason:u()})]),zQ=b({id:u(),enabled:v(),isVideo:v(),codec:u().nullable(),resolution:u().nullable(),overwriteWhenFull:v().nullable()}),BQ=b({storage:RQ,tracks:S(zQ),primaryTrackId:u().nullable(),enabled:v().nullable(),overwriteWhenFull:v().nullable(),preRecordSec:r().nullable().meta(k(`duration`)),postRecordSec:r().nullable().meta(k(`duration`)),segmentMinutes:r().nullable().meta(k(`none`)),windows:S(IQ),unreadableWindows:r().meta(k(`count`)),recordingToNowhere:v(),lastFetchedAt:r()}),VQ=b({min:r(),max:r(),step:r()}),HQ=b({values:S(r()).min(1),sentinel:b({value:r(),meaning:x([`no-limit`,`disabled`])}).optional()}),UQ=b({readable:v(),writable:v(),reason:u().optional()}),WQ=b({support:UQ,granularityMinutes:r(),triggers:S(FQ),supportsOverlappingTriggers:v()}),GQ=b({enabled:UQ,overwriteWhenFull:UQ,preRecordSec:UQ,preRecordSecRange:VQ.optional(),preRecordSecAllowed:HQ.optional(),postRecordSec:UQ,postRecordSecRange:VQ.optional(),postRecordSecAllowed:HQ.optional(),segmentMinutes:UQ,segmentMinutesRange:VQ.optional(),segmentMinutesAllowed:HQ.optional(),schedule:WQ}),KQ=b({enabled:v().optional(),overwriteWhenFull:v().optional(),preRecordSec:r().optional(),postRecordSec:r().optional(),segmentMinutes:r().optional(),windows:S(IQ).optional()}),qQ={name:`recording-onboard`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`recording-onboard`,tab:`recording`}},methods:{getOptions:E(b({deviceId:r()}),GQ),setSettings:E(b({deviceId:r(),settings:KQ}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`recordingOnboard.on`,label:I(`On-camera recording on`,`Registrazione a bordo attiva`),phrase:I(`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:I(`On-camera recording off`,`Registrazione a bordo spenta`),phrase:I(`Turn off recording to the card of {device}`,`Disattiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!1}}}]})},status:{schema:BQ,kind:`poll`},runtimeState:BQ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`On-camera recording`,`Registrazione a bordo`),order:3260,state:[{kind:`boolean`,field:`recordingToNowhere`,label:I(`Recording to nowhere`,`Registra nel vuoto`),whenTrue:I(`When {device} is recording with no card to write to`,`Quando {device} registra senza una scheda su cui scrivere`),whenFalse:I(`When {device} has a card to record to again`,`Quando {device} ha di nuovo una scheda su cui registrare`),icon:`hard-drive`}]}},JQ=b({active:v(),reason:u(),lastChangedAt:r()}),YQ=JQ.extend({lastFetchedAt:r()}),XQ={name:`recording-signal`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{getStatus:E(b({deviceId:r()}),JQ)},status:{schema:JQ,kind:`push`,empty:{active:!1,reason:`unknown`,lastChangedAt:0}},runtimeState:YQ,durability:`session`,history:`none`,vocabulary:{noun:I(`Recording signal`,`Segnale di registrazione`),order:3270,state:[{kind:`boolean`,field:`active`,label:I(`Recording`,`In registrazione`),whenTrue:I(`When {device} starts recording`,`Quando {device} inizia a registrare`),whenFalse:I(`When {device} stops recording`,`Quando {device} smette di registrare`),icon:`circle-dot`}]}},ZQ=b({kind:m(`cap`),deviceId:r().int().nonnegative(),cap:u().min(1),method:u().min(1),args:h(u(),C()).optional(),argUnits:h(u(),u().min(1)).optional()}),QQ=b({action:ZQ}),$Q=b({key:u().refine($w,{message:`a lowercase slug`}),name:u().min(1).max(60)});function hEe(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=fT(a);e!==null&&s(e,`payload`)}for(let t of dT(a))Xw(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 e$=b({index:r().int().nonnegative(),id:u().nullable(),name:u().nullable(),reason:u()}),t$=b({layoutTemplateId:u().min(1).nullable(),defaultTransmitterId:r().int().nonnegative().nullable().default(null),bindings:h(u(),QQ),customButtons:S($Q).max(100),sources:S(lT).max(200).default([]),stepDelayMs:r().int().min(100).max(uT).default(500),refusedSources:S(e$).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)Xw(e)?t.addIssue({code:`custom`,message:`"${e}" is a layout widget, not a command: it cannot be bound`,path:[`bindings`,e]}):nT(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=tT(e);n!==null&&!r.has(n)&&t.addIssue({code:`custom`,message:`${e} is bound but has no entry in customButtons`,path:[`bindings`,e]})}hEe(e,t)}),gEe=le({sources:S(C())}),_Ee=b({id:u(),name:u()}).partial();function vEe(e){let t=gEe.safeParse(e);if(!t.success)return n$(t$.safeParse(e));let n=[],r=[];t.data.sources.forEach((e,t)=>{let i=lT.safeParse(e),a=i.success&&i.data.kind===`ir`?fT(i.data):null;if(i.success&&a===null){n.push(e);return}let o=_Ee.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=n$(t$.safeParse({...t.data,sources:n}));return!i.success||r.length===0?i:{success:!0,data:{...i.data,refusedSources:r}}}function n$(e){return e.success?{success:!0,data:e.data}:{success:!1,issues:e.error.issues.length}}var yEe={layoutTemplateId:null,defaultTransmitterId:null,bindings:{},customButtons:[],sources:[],stepDelayMs:500},bEe=b({power:b({state:x([`on`,`off`]),at:r()}).nullable(),muted:b({value:v(),at:r()}).nullable(),source:b({name:u(),at:r()}).nullable().default(null)}),xEe={power:null,muted:null,source:null},r$=[`rect`,`rounded`,`round`,`pill`],i$=x(r$),a$=[`neutral`,`accent`,`danger`,`red`,`green`,`yellow`,`blue`],o$=x(a$),s$=[`none`,`panel`,`divider`,`dpad`,`rocker-v`,`rocker-h`,`keypad`],c$=x(s$),l$=b({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:rT,shape:i$.optional(),tone:o$.optional(),showLegend:v().optional(),groupId:u().min(1).max(40).optional()}),u$=b({id:u().min(1).max(40),componentId:u().min(1).max(80),frame:c$,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:x([`compact`,`normal`]).optional(),hideTitle:v().optional()});function d$(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 f$(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 SEe(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&&d$(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`]),f$(n,e)||i(`button "${e.id}" lies outside its group "${n.id}"`,[`buttons`,t]);return}let a=n.find(t=>d$(t,e));a!==void 0&&i(`button "${e.id}" lies inside group "${a.id}" but is not a member`,[`buttons`,t])})}var p$=b({columns:r().int().min(1).max(24),rows:r().int().min(1).max(24),buttons:S(l$).max(200),groups:S(u$).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)}}),SEe(e,t)}),m$=b({role:rT,label:u().optional(),custom:v()}),h$=b({layoutTemplateId:u().nullable(),commands:S(m$),sources:S(lT)}),g$=[`no-remote`,`unbound-role`,`action-failed`,`unknown-source`,`unbound-step`,`undeclared-channel`,`press-timeout`,`no-transmitter`],_$=x(g$),v$=a(`status`,[b({status:m(`sent`),sends:r().int().min(1)}),b({status:m(`skipped`),reason:m(`already-in-state`)}),b({status:m(`refused`),reason:_$,detail:u().optional(),step:b({index:r().int().min(1),role:u()}).optional()})]),y$=[`play`,`pause`,`stop`,`next`,`previous`,`setMute`,`selectSource`,`playMedia`,`turnOn`,`turnOff`,`volumeUp`,`volumeDown`,`channelUp`,`channelDown`],b$=x(y$),x$=a(`status`,[...v$.options,b({status:m(`not-routed`)})]),S$=[`unknown-template`,`not-a-media-player`],C$=a(`status`,[b({status:m(`saved`)}),b({status:m(`refused`),reason:x(S$),detail:u()})]),w$=b({deviceId:r().int().nonnegative()}),CEe={version:1,targets:[{id:`remote`,cardinality:`config`,vocabulary:{cap:`remote`},deviceTypes:[j.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`}]},T$={name:`remote`,scope:`system`,mode:`singleton`,methods:{getConfig:E(w$,t$,{auth:`admin`}),setConfig:E(w$.extend({config:t$}),C$,{kind:`mutation`,auth:`admin`}),listCommands:E(w$,h$,{auth:`protected`}),sendCommand:E(w$.extend({role:rT,repeat:r().int().min(1).max(50).default(1)}),v$,{kind:`mutation`,auth:`protected`}),getAssumedStatus:E(w$,vT.nullable(),{auth:`protected`}),sendMediaCommand:E(w$.extend({command:b$,muted:v().optional(),source:u().optional(),mediaType:u().optional(),mediaId:u().optional(),repeat:r().int().min(1).max(50).default(1)}),x$,{kind:`mutation`,auth:`protected`})},customize:CEe,vocabulary:{notOperatorFacing:`the per-device remote setup — authored in the Customize remote editor, sent through the remote UI`}},E$=[`power`,`navigation`,`volume`,`numbers`,`media`,`colour`,`apps`,`layout`],D$=x(E$),wEe=/^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_-]*$/,O$=b({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:rT,icon:u().min(1).max(60).optional(),label:u().min(1).max(40).optional(),shape:i$.optional(),tone:o$.optional(),showLegend:v().optional()}),k$=b({id:u().max(80).regex(wEe,{message:`<namespace>:<name>, lowercase`}),name:u().min(1).max(60),nameI18n:b({en:u().min(1).max(60),it:u().min(1).max(60)}).optional(),icon:u().min(1).max(60),category:D$,size:b({rows:r().int().min(1).max(24),cols:r().int().min(1).max(24)}),group:b({frame:c$,title:u().min(1).max(40).optional()}).nullable(),buttons:S(O$).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&&d$(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`]})}),A$={name:`remote-layout-components`,scope:`system`,mode:`collection`,methods:{listComponents:E(b({}),S(k$),{auth:`protected`})},vocabulary:{notOperatorFacing:`the palette of the remote template editor — read-only data, never actuated`}},j$=b({deviceId:r().int().nonnegative(),resetToSource:v().optional()}),M$={name:`resync`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Container,j.Workload,j.WeatherStation],methods:{resync:E(j$,YO,{kind:`mutation`,auth:`admin`,notOperatorFacing:`device adoption — re-aligning a device with its source is an onboarding step, not an automation action`})},vocabulary:{noun:I(`Re-sync`,`Risincronizzazione`),order:3245}},N$=3e4,P$=18e4,F$={startDwellMs:N$,stopDwellMs:P$,minSamples:2},I$={[j.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}};function L$(e){return e!==void 0&&I$[e]!==void 0}function R$(e){return e===void 0?F$:I$[e]??F$}var TEe={running:null,since:null,source:`native`,phase:null,lastFetchedAt:null},z$=x([`native`,`assigned`]),B$=b({running:v().nullable(),since:r().nullable().meta(k(`none`)),source:z$.meta({label:`Source`}),phase:u().nullable(),lastFetchedAt:r().nullable()}),V$=b({deviceId:r(),since:r().nullable(),phase:u().nullable()}),EEe=Object.values(j),H$=[j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.MediaPlayer,j.WaterHeater,j.Humidifier,j.Fan,j.Climate,j.PetFeeder],DEe={version:1,overridable:[{path:`running`,by:`running`}],targets:[{id:`running`,cardinality:`scalar`,vocabulary:{cap:`running-state`,stateField:`running`},deviceTypes:H$,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:N$,defaultStopDwellMs:P$,deviceTypeDefaults:I$,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}]},U$={name:`running-state`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:EEe,methods:{},events:{onStarted:{data:V$,trigger:{category:w.RunningStarted,label:I(`Started running`,`Ha iniziato a funzionare`),phrase:I(`When {device} starts running`,`Quando {device} inizia a funzionare`),icon:`play`}},onFinished:{data:V$,trigger:{category:w.RunningFinished,label:I(`Finished`,`Ha finito`),phrase:I(`When {device} finishes`,`Quando {device} finisce`),icon:`square`}}},status:{schema:B$,kind:`push`},runtimeState:B$,durability:`restored`,history:{fields:{running:{kind:`boolean`}}},volatileStateFields:[`lastFetchedAt`],customize:DEe,vocabulary:{noun:I(`Running`,`In funzione`),order:2120,state:[{kind:`boolean`,field:`running`,label:I(`Running`,`In funzione`),whenTrue:I(`When {device} starts`,`Quando {device} inizia`),whenFalse:I(`When {device} finishes`,`Quando {device} finisce`),icon:`play`}],overrides:{byType:{[j.Washer]:{state:{running:{whenTrue:I(`When the washing machine starts`,`Quando la lavatrice inizia`),whenFalse:I(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}},events:{onStarted:{phrase:I(`When the washing machine starts`,`Quando la lavatrice inizia`)},onFinished:{phrase:I(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}}},[j.Dryer]:{state:{running:{whenTrue:I(`When the dryer starts`,`Quando l'asciugatrice inizia`),whenFalse:I(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}},events:{onStarted:{phrase:I(`When the dryer starts`,`Quando l'asciugatrice inizia`)},onFinished:{phrase:I(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}}},[j.Dishwasher]:{state:{running:{whenTrue:I(`When the dishwasher starts`,`Quando la lavastoviglie inizia`),whenFalse:I(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}},events:{onStarted:{phrase:I(`When the dishwasher starts`,`Quando la lavastoviglie inizia`)},onFinished:{phrase:I(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}}}}}}},W$=u(),OEe=[`day`,`ir`,`night`,`dawn`,`dusk`],G$=x([`skip`,`judge-anyway`]),kEe=`__diverged__`,K$=x([`matched`,`diverged`,`unknown`]),q$=x([`no-reference-for-condition`,`view-shifted`,`no-vision-profile`,`encoder-model-changed`,`no-snapshot`]),J$=b({embedding:S(r()),modelId:u(),condition:W$,capturedAt:r(),thumbnailMediaId:r().int().optional(),anchorEmbedding:S(r()).optional()}),Y$=b({id:u(),label:u(),references:S(J$),textPrompts:S(u()).optional(),referenceCount:r(),currentlyMatched:v()}),X$=a(`mode`,[b({mode:m(`similarity`),threshold:r().min(0).max(1),hysteresisCount:r().int().positive()}),b({mode:m(`llm`),prompt:u(),profileId:u().optional(),hysteresisCount:r().int().positive()})]),Z$=.85,Q$=`skip`,$$=8e3,e1=b({enabled:v().default(!1),prompt:u().min(1).max(1e3),profileId:u().optional(),timeoutMs:r().int().min(1e3).max(2e4).default($$),maxImagePx:r().int().min(64).max(2048).default(448),onTimeout:x([`flip`,`hold`]).default(`hold`)}),t1=b({id:u(),label:u(),roi:WB,enabled:v(),triggerMode:x([`periodic`,`on-motion`,`both`]),checkIntervalSec:r().optional(),check:X$,states:S(Y$),currentStateId:u().nullable(),lastCheckedAt:r().nullable(),lastConfidence:r().nullable(),currentCondition:W$.nullable(),availability:x([`ok`,`unavailable`]),unavailableReason:u().nullable(),baselineStateId:u().nullable(),emit:x([`latched`,`live`]).default(`latched`),verdict:K$,latched:v(),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:e1.optional(),anchorThreshold:r().min(0).max(1).default(Z$),autoRestore:v().default(!1),onUncoveredCondition:G$.default(Q$),suspendedCondition:W$.nullable().default(null),unavailable:q$.nullable(),coveredConditions:S(W$)}),n1=b({monitors:S(t1),lastFetchedAt:r()}),r1=b({deviceId:r(),status:n1.nullable()}),i1={name:`scene-monitor`,role:{feature:`scenes`},scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],methods:{listScenes:E(b({deviceId:r()}),n1),listScenesBatch:E(b({deviceIds:S(r()).min(1).max(200)}),S(r1).readonly()),createScene:E(b({deviceId:r(),label:u(),roi:WB,check:X$,triggerMode:x([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:r().optional()}),t1,{kind:`mutation`,auth:`admin`}),updateScene:E(b({deviceId:r(),monitorId:u(),patch:b({label:u().optional(),roi:WB.optional(),enabled:v().optional(),triggerMode:x([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:r().optional(),check:X$.optional(),emit:x([`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:v().optional(),onUncoveredCondition:G$.optional(),confirm:e1.nullable().optional()})}),_(),{kind:`mutation`,auth:`admin`}),deleteScene:E(b({deviceId:r(),monitorId:u()}),_(),{kind:`mutation`,auth:`admin`}),captureReference:E(b({deviceId:r(),monitorId:u(),stateId:u().optional(),label:u().optional(),condition:W$.optional()}),b({stateId:u(),referenceCount:r()}),{kind:`mutation`,auth:`admin`}),deleteReference:E(b({deviceId:r(),monitorId:u(),stateId:u(),index:r()}),_(),{kind:`mutation`,auth:`admin`}),recheckNow:E(b({deviceId:r(),monitorId:u()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`sceneMonitor.recheck`,label:I(`Re-check a scene`,`Ricontrolla una scena`),phrase:I(`Re-check {monitorId} on {device} now`,`Ricontrolla subito {monitorId} su {device}`),icon:`scan-search`,openArgs:[{key:`monitorId`,label:I(`Scene`,`Scena`),offer:{kind:`dynamic`,from:`status`,field:`monitors`,valueKey:`id`,labelKey:`label`}}]}]}),resetScene:E(b({deviceId:r(),monitorId:u(),recapture:v().optional()}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:n1,kind:`push`},runtimeState:n1,durability:`session`,history:`none`,vocabulary:{noun:I(`Scene watch`,`Controllo della scena`),order:3280,extraEvents:[{category:w.EnrichmentSceneStateChanged,label:I(`Scene changed`,`Scena cambiata`),phrase:I(`When a watched scene on {device} changes`,`Quando cambia una scena controllata su {device}`),icon:`scan-search`}]}},a1=b({schedulerId:u().min(1)}),o1={name:`schedulers`,scope:`system`,mode:`singleton`,methods:{list:E(b({}),S(p_),{auth:`admin`}),get:E(a1,b({scheduler:p_.nullable()}),{auth:`admin`}),create:E(b({scheduler:f_}),b({scheduler:p_}),{kind:`mutation`,auth:`admin`}),update:E(b({schedulerId:u().min(1),scheduler:f_}),b({scheduler:p_}),{kind:`mutation`,auth:`admin`}),delete:E(a1,_(),{kind:`mutation`,auth:`admin`}),setEnabled:E(b({schedulerId:u().min(1),profileId:u().min(1).optional(),enabled:v()}),b({scheduler:p_}),{kind:`mutation`,auth:`admin`}),preview:E(b({schedulerId:u().min(1),date:u().regex(h_).optional()}),que,{auth:`admin`}),conflicts:E(b({scheduler:f_,schedulerId:u().min(1).optional()}),b({conflicts:S(Jue)}),{auth:`admin`}),getStatus:E(b({}),S(Xue),{auth:`admin`}),getTraces:E(a1,b({traces:S(y_)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`time schedulers — authored on their own page, not device actions`}},s1=b({isRunning:v(),lastRunAt:r(),lastRunSuccess:v().nullable(),lastError:u().nullable(),lastChangedAt:r()}),c1={name:`script-runner`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Script],methods:{run:E(b({deviceId:r().int().nonnegative(),variables:h(u(),C()).optional()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.run`,label:I(`Run script`,`Esegui lo script`),phrase:I(`Run {device}`,`Esegui {device}`),icon:`scroll-text`,hold:{effects:[{field:`isRunning`,value:!0}],holdMs:MJ}}]}),stop:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.stop`,effect:{field:`isRunning`,value:!1},label:I(`Stop script`,`Ferma lo script`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]})},status:{schema:s1,kind:`push`},runtimeState:s1,durability:`session`,history:`none`,vocabulary:{noun:I(`Script`,`Script`),order:2090,state:[{kind:`boolean`,field:`isRunning`,label:I(`Running`,`In esecuzione`),whenTrue:I(`When {device} starts running`,`Quando {device} parte`),whenFalse:I(`When {device} finishes`,`Quando {device} termina`),icon:`scroll-text`}]}},l1=x([`workspace`,`baked`,`data-root`]),u1=x([`idle`,`checking`,`staging`,`pending-restart`,`awaiting-confirmation`]),d1=x([`in-sync`,`behind-patch`,`behind-series`,`ahead`,`unknown`]),f1=b({state:d1,seedVersion:u().nullable(),contractVersion:u().nullable(),contractSource:x([`registry`,`running`]).nullable(),message:u()}),p1=x([`docker`,`electron`,`native`,`contradictory`,`unknown`]),m1=b({fact:x([`dockerenv-file`,`proc-1-cgroup`,`platform`,`electron-app-version-env`]),mode:x([`observed`,`declared`]),holds:v(),detail:u()}),h1=b({kind:p1,evidence:S(m1),currentVersion:u().nullable()}),g1=b({fromVersion:u(),toVersion:u().nullable(),atMs:r(),reason:u()}),_1=b({version:u(),update:b({available:v(),downloaded:v(),version:u().nullable(),checking:v(),error:u().nullable()}),stateAtMs:r(),stale:v()}),v1=x([`not-electron`,`no-app-state`,`app-state-stale`,`not-downloaded`]),y1=b({accepted:v(),reason:v1.nullable()}),b1=b({runnerId:u(),addonIds:S(u()),reason:u()}),x1=b({checkedAtMs:r(),expected:r(),running:r(),failed:S(u()),refused:S(b1),missing:S(u()),pending:S(u()).optional(),planKnown:v()}),S1=b({packageName:u(),runningVersion:u().nullable(),nodeRuntimeVersion:u().nullable(),activeVersion:u().nullable(),installedVersion:u().nullable().optional(),restartRequired:v().optional(),previousVersion:u().nullable(),seedVersion:u().nullable(),latestVersion:u().nullable(),updateAvailable:v(),bootMode:l1,updateState:u1,pendingVersion:u().nullable(),rolledBack:g1.nullable(),stateFileCorrupt:v(),lastCheckedAtMs:r().nullable(),imageContract:f1.optional(),wrapper:h1.optional(),runners:x1.optional(),desktopApp:_1.optional()}),C1=b({packageName:u(),runningVersion:u().nullable(),latestVersion:u().nullable(),updateAvailable:v(),checkedAtMs:r(),error:u().nullable(),pendingVersion:u().nullable().optional(),restartRequired:v().optional()}),w1=x([`staged`,`restart-scheduled`,`already-current`,`refused`,`failed`]),T1=b({addonId:u(),reason:u(),remedy:u()}),E1=b({accepted:v(),targetVersion:u().nullable(),restarting:v(),message:u(),outcome:w1.optional(),reason:u().nullable().optional(),error:u().nullable().optional(),blockers:S(T1).optional(),unmet:S(zr).optional(),requiredAddonUpdates:S(Br).optional()}),D1=b({heapMb:r().int().nullable(),rssBudgetMb:r().int().nullable()}),AEe=b({heapMb:r().int().min(512).max(65536).nullable(),rssBudgetMb:r().int().min(512).max(65536).nullable().optional()}),jEe=D1.extend({restartRequired:v()}),O1={name:`server-management`,scope:`system`,mode:`singleton`,methods:{getServerPackageStatus:E(_(),S1,{auth:`admin`}),checkServerUpdate:E(_(),C1,{kind:`mutation`,auth:`admin`}),applyServerUpdate:E(b({version:u().optional(),acknowledgeRefusals:v().optional()}),E1,{kind:`mutation`,auth:`admin`,timeoutMs:16*6e4}),installDesktopUpdate:E(_(),y1,{kind:`mutation`,auth:`admin`}),rollbackServerUpdate:E(_(),E1,{kind:`mutation`,auth:`admin`}),restartServer:E(_(),E1,{kind:`mutation`,auth:`admin`}),getLaunchOverrides:E(_(),D1,{auth:`admin`}),setLaunchOverrides:E(AEe,jEe,{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.CLUSTER}},k1={Seconds:`seconds`,Plays:`plays`},A1={Camera:`camera`,Fallback:`fallback`},j1=b({min:r().positive(),max:r().positive(),step:r().positive()}),M1=b({allowedSeconds:S(r().positive()).nullable(),rangeSeconds:j1.nullable(),defaultSeconds:r().positive(),allowedPlays:S(r().int().positive()).nullable().default(null),rangePlays:j1.nullable().default(null),defaultPlays:r().int().positive().nullable().default(null),unit:x([k1.Seconds,k1.Plays]),secondsPerPlay:r().positive().nullable(),source:x([A1.Camera,A1.Fallback]),fetchedAt:r()}),N1=b({active:v(),activeUntil:r().nullable(),durationSeconds:r().nullable(),plays:r().int().positive().nullable().default(null),activeUntilEstimated:v().default(!1),lastTriggeredAt:r()}),P1=b({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`]}),F1=N1.extend({lastFetchedAt:r()}),I1={name:`siren`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Siren],methods:{getOptions:E(b({deviceId:r().int().nonnegative()}),M1,{kind:`query`,auth:`protected`}),getPlayChoices:E(b({deviceId:r().int().nonnegative()}),S(r().int().positive()),{kind:`query`,auth:`protected`}),trigger:E(P1,N1,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.trigger`,label:I(`Sound the siren`,`Fai suonare la sirena`),phrase:I(`Sound {device}`,`Fai suonare {device}`),icon:`siren`,args:{}},{id:`siren.triggerPlays`,label:I(`Sound the siren N times`,`Fai suonare la sirena N volte`),phrase:I(`Sound {device} {plays} times`,`Fai suonare {device} {plays} volte`),icon:`siren`,openArgs:[{key:`plays`,label:I(`Plays`,`Riproduzioni`),offer:{kind:`dynamic`,from:`method`,method:`getPlayChoices`,valueKind:`number`}}]}]}),stop:E(b({deviceId:r().int().nonnegative()}),N1,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.stop`,label:I(`Silence the siren`,`Zittisci la sirena`),phrase:I(`Silence {device}`,`Zittisci {device}`),icon:`siren`,effect:{field:`active`,value:!1},args:{}}]})},events:{onSirenChanged:{data:b({deviceId:r(),active:v(),activeUntil:r().nullable()}),notOperatorFacing:"the `active` state trigger phrases both edges of this change"}},status:{schema:N1,kind:`command-driven`},runtimeState:F1,durability:`session`,history:`none`,vocabulary:{noun:I(`Siren`,`Sirena`),order:1170,state:[{kind:`boolean`,field:`active`,label:I(`Siren sounding`,`Sirena in funzione`),whenTrue:I(`When {device} starts sounding`,`Quando {device} inizia a suonare`),whenFalse:I(`When {device} falls silent`,`Quando {device} smette di suonare`),icon:`siren`}]}},L1=b({detected:v(),lastChangedAt:r()}),R1={name:`smoke`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:L1,kind:`push`},runtimeState:L1,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Smoke detector`,`Rilevatore di fumo`),order:5190,state:[{kind:`boolean`,field:`detected`,label:I(`Detected`,`Rilevato`),whenTrue:I(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:I(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}]}},z1=5*1024*1024,B1=`<!--camstack-images-->`,V1=b({ticket:Xa,mime:u().min(1),name:u().min(1),contentId:u().min(1),placement:x([`inline`,`attachment`]),deviceId:r().int().nonnegative().optional()}),H1=0;function U1(e){return H1+=1,`camstack_${e}_${H1.toString(36)}_${Date.now().toString(36)}`}function MEe(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,`utf8`).toString(`base64`)}?=`}function W1(e){return(Array.isArray(e)?e:[e]).join(`, `)}function NEe(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function G1(e,t){let n=e.replace(/[\r\n"]/g,``).trim();return n.length>0?n:t}function PEe(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
1110
+ `)}function wk(e){return e.replaceAll(`|`,`\\|`)}function uye(){let e=[];for(let t of Object.values(gh))e.includes(t.dimension)||e.push(t.dimension);return e.map(e=>({group:e,choices:Th(e).map(e=>({value:e}))}))}function Tk(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:yh(t);return n===void 0?uye():[{group:n,choices:Th(n).map(e=>({value:e}))}]}var Ek=4096,dye=4096,Dk=u().min(1).max(Ek),fye=`camera`,Ok=g([u(),r(),v()]),kk=b({deviceId:r().int(),values:h(u().min(1).max(64),Ok).optional()}),pye=`values`,mye=vk(),Ak=[`too-long`,`syntax`,`forbidden-syntax`,`forbidden-member`,`unknown-filter`,`ambiguous-field`,`busy`,`budget-exceeded`,`timeout`,`output-too-large`,`render-failed`,`out-of-scope`,`unavailable`],jk=b({reason:x(Ak),message:u()}),Mk=[`unknown-alias`,`unknown-field`,`no-field`,`unavailable`],Nk=b({ref:u(),reason:x(Mk)}),Pk=a(`ok`,[b({ok:m(!0),text:u(),trace:S(Nk)}),b({ok:m(!1),refusal:jk,trace:S(Nk)})]);function Fk(e){return e.replace(/-/g,`_`)}function Ik(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Lk(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(Ik(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function hye(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||Fk(e)===n);if(i!==void 0){let n=t.slice(1);if(n.length===0)return{kind:`missing`,reason:`no-field`};let r=Lk(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 Ik(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=Lk(e.slices[o],t);return s===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:o,fieldPath:t,value:s}}var Rk=b({zoneKey:u(),label:u(),icon:Bu.nullable(),locationKeys:S(u())});function gye(e){return e.trim().toLowerCase()}var zk=[`mac`,`serial`,`machine-uuid`,`vendor-uid`,`hostname`,`ip`],Bk=x(zk),Vk=x([`read`,`derived`]),_ye=/^[0-9a-f]{2}(?::[0-9a-f]{2}){5}$/,Hk=/^[a-z0-9][a-z0-9._-]*:[^\sA-Z]+$/,Uk=/^[0-9a-f][0-9a-f-]{7,}$/,Wk=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function Gk(e){return b({value:e,origin:Vk,readAt:r().int().nonnegative()}).strict()}var vye=Gk(u().regex(_ye)),yye=Gk(u().regex(Hk)),bye=Gk(u().regex(Uk)),xye=Gk(u().regex(Hk)),Sye=Gk(u().regex(Wk)),Cye=Gk(g([te(),s()])),wye=b({value:u().min(1),origin:Vk,readAt:r().int().nonnegative()}).strict(),Kk=b({mac:S(vye).min(1).readonly().optional(),serial:yye.optional(),"machine-uuid":bye.optional(),"vendor-uid":xye.optional(),hostname:Sye.optional(),ip:Cye.optional()}).strict(),Tye={mac:`strong`,serial:`strong`,"machine-uuid":`strong`,"vendor-uid":`strong`,hostname:`weak`,ip:`weak`};function qk(e){return Tye[e]}function Jk(e){return zk.every(t=>e[t]===void 0)}var Eye=/^(?:unknown|none|n\/?a|null|undefined|default|0+|-+)$/i,Dye=new Set([`00:00:00:00:00:00`,`ff:ff:ff:ff:ff:ff`]);function Yk(e){return{ok:!1,reason:e}}function Xk(e){let t=e.trim().toLowerCase().replace(/[\s:.-]/g,``);if(!/^[0-9a-f]{12}$/.test(t))return Yk(`not a 48-bit MAC`);let n=(t.match(/../g)??[]).join(`:`);return Dye.has(n)?Yk(`placeholder MAC`):{ok:!0,value:n}}function Oye(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[-._]+|[-._]+$/g,``)}function Zk(e,t,n){let r=Oye(e);if(r.length===0)return Yk(`no ${n}`);let i=t.trim().toLowerCase().replace(/\s+/g,``);return i.length===0?Yk(`blank value`):Eye.test(i)?Yk(`placeholder value`):{ok:!0,value:`${r}:${i}`}}function kye(e){let t=e.trim().toLowerCase().replace(/^\{|\}$/g,``);return Uk.test(t)?/^[0-]+$/.test(t)||/^[f-]+$/.test(t)?Yk(`placeholder uuid`):{ok:!0,value:t}:Yk(`not a uuid`)}function Qk(e){return g([te(),s()]).safeParse(e).success}function Aye(e){let t=e.trim().toLowerCase().replace(/\.$/,``);if(t.length===0)return Yk(`blank hostname`);if(Qk(t))return Yk(`an address, not a hostname`);let n=t.split(`.`)[0]??``;return Wk.test(n)?n===`localhost`?Yk(`placeholder hostname`):{ok:!0,value:n}:Yk(`not a hostname`)}function jye(e){let t=e.trim().toLowerCase().replace(/^\[|\]$/g,``);return Qk(t)?t===`0.0.0.0`||t===`::`||t===`::1`||t.startsWith(`127.`)?Yk(`loopback or unspecified address`):{ok:!0,value:t}:Yk(`not an IP address`)}function $k(e){return e==null||e.trim().length===0}function eA(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($k(e))continue;let t=o(`mac`,e,Xk(e));t!==void 0&&!c.some(e=>e.value===t.value)&&c.push(t)}let l=e.serial===null||e.serial===void 0||$k(e.serial.serial)?void 0:o(`serial`,`${e.serial.manufacturer}:${e.serial.serial}`,Zk(e.serial.manufacturer,e.serial.serial,`manufacturer`)),u=e.vendorUid===null||e.vendorUid===void 0||$k(e.vendorUid.id)?void 0:o(`vendor-uid`,`${e.vendorUid.vendor}:${e.vendorUid.id}`,Zk(e.vendorUid.vendor,e.vendorUid.id,`vendor`)),d=$k(e.machineUuid)?void 0:o(`machine-uuid`,e.machineUuid,kye(e.machineUuid)),f=$k(e.host)?null:e.host.trim(),p=f!==null&&Qk(f.toLowerCase().replace(/^\[|\]$/g,``)),m=$k(e.hostname)?p?null:f:e.hostname,h=$k(e.ip)?p?f:null:e.ip,g=m===null?void 0:o(`hostname`,m,Aye(m)),ee=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},...ee===void 0?{}:{ip:ee}},rejected:a}}function tA(e,t){return e.value===t.value&&e.origin===t.origin}function nA(e,t){return t!==void 0&&tA(e,t)?t:e}function Mye(e,t,n=[]){let r=e??{},i=t??{},a=new Set(n),o=a.has(`mac`)?r.mac:i.mac?.map(e=>nA(e,r.mac?.find(t=>tA(t,e)))),s=e=>{if(a.has(e))return r[e];let t=i[e];return t===void 0?void 0:nA(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 Jk(p)?null:p}function Nye(e,t){let n=e=>e==null||Jk(e)?``:JSON.stringify(zk.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 rA=x([`auto`,`proposal`]),iA=b({key:Bk,value:u()}),aA=b({deviceId:r().int(),addonId:u(),integrationId:u().nullable()}),oA=b({a:aA,b:aA,keys:S(iA).readonly(),confidence:rA}),sA=a(`status`,[b({status:m(`unknown`),reason:u()}),b({status:m(`answered`),pairs:S(oA).readonly(),undeclaredDeviceIds:S(r().int()).readonly()})]),cA=[`same-device`,`poe-power`],lA=x(cA),uA=x([`proposed`,`linked`,`dismissed`]),dA=x([`auto`,`operator`]),fA=b({addonId:u().min(1),stableId:u().min(1),deviceId:r().int()}),pA=b({kind:lA,a:fA,b:fA,state:uA,origin:dA,evidence:S(iA).readonly(),evidenceGone:m(!0).optional(),createdAt:r().int().nonnegative(),decidedAt:r().int().nonnegative().optional()}),mA=pA.extend({id:u().min(1)}),hA={"same-device":{directional:!1,attachingRole:null,contributions:[]},"poe-power":{directional:!0,attachingRole:N.PoePort,contributions:[{cap:`power-source`,targetId:`switch`,host:`b`,source:`a`,sourceCap:`switch`,sourceField:`on`}]}};function Pye(e,t){let n=hA[e].attachingRole;return n===null||t===n?null:`attaching-side-role`}function gA(e){return`${e.addonId}/${e.stableId}`}function Fye(e,t,n){let r=gA(t),i=gA(n);return hA[e].directional||r<=i?`${e}:${r}|${i}`:`${e}:${i}|${r}`}var _A=a(`status`,[b({status:m(`not-loaded`),reason:u()}),b({status:m(`answered`),links:S(mA).readonly()})]),vA=x([`not-loaded`,`unknown-link`,`wrong-state`]),yA=a(`ok`,[b({ok:m(!0),link:mA}),b({ok:m(!1),reason:vA,message:u()})]),bA=x([`evidence-gone`,`device-removed`,`operator-unlinked`]),Iye=b({linkId:u(),kind:lA,aDeviceId:r().int(),bDeviceId:r().int(),origin:dA,reason:bA.optional()}),xA=b({caps:S(u()).readonly().optional(),actions:S(u()).readonly().optional(),mode:x([`any`,`all`]).optional()}),SA=b({locations:S(u()).readonly().optional(),integrationIds:S(u()).readonly().optional(),types:S(u()).readonly().optional()}),CA=b({text:u().optional(),requires:xA.optional(),filters:SA.optional(),includeIncompatible:v().optional(),contextDeviceId:r().optional(),ids:S(r()).readonly().optional(),cursor:u().nullable().optional(),limit:r().int().min(1).max(200).optional()}),wA=b({cap:u(),path:u(),label:u(),reading:u().nullable(),unit:u().nullable().optional(),quantity:Zs.optional()}),TA=b({id:r(),name:u(),type:x(j),location:u().nullable(),integrationId:u().nullable(),integrationLabel:u().nullable(),online:v().nullable(),disabled:v(),compatible:v(),values:S(wA).readonly()}),EA=b({value:u(),count:r()}),DA=b({id:u(),label:u(),count:r()}),OA=b({locations:S(EA).readonly(),integrations:S(DA).readonly(),types:S(EA).readonly()}),kA=b({items:S(TA).readonly(),nextCursor:u().nullable(),total:r(),compatibleTotal:r(),fleetTotal:r(),hiddenIncompatible:r(),facets:OA,suggested:S(TA).readonly(),missingIds:S(r()).readonly()}),AA=b({connected:v(),deviceCount:r(),error:u().optional(),motionSliceWriter:m(`orchestrator`).optional()}),Lye=b({externalId:u(),name:u(),type:u(),metadata:h(u(),C()).optional()}),jA=a(`kind`,[b({kind:m(`mdns`),serviceType:u().min(1),instancePattern:u().optional()}),b({kind:m(`ws-discovery`),types:S(u()).optional()}),b({kind:m(`ssdp`),searchTarget:u().min(1)}),b({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()}),b({kind:m(`http-probe`),port:r().int().min(1).max(65535),path:u().startsWith(`/`),method:x([`GET`,`POST`]).default(`GET`),bodyText:u().optional(),contentType:u().optional(),tls:v().default(!1),acceptStatus:S(r().int()).optional()}),b({kind:m(`custom`),reason:u().min(1)})]),MA=b({modeIndex:r().int().min(0),host:u(),port:r().int(),http:b({status:r().int(),headers:h(u(),u()),bodyText:u()}).optional(),mdns:b({instance:u(),host:u(),port:r().int(),txt:h(u(),u())}).optional(),udp:b({payloadHex:u()}).optional(),wsd:b({xaddrs:S(u()),types:S(u()),scopes:S(u())}).optional()}),NA=b({stableId:u(),type:x(j),suggestedName:u(),prefilledConfig:h(u(),C()),sourceInfo:uh.optional(),alreadyOnboarded:v().optional(),onboardedDeviceId:r().optional(),onboardedName:u().optional(),setupIntegration:v().optional(),parentStableId:u().optional(),selectable:v().optional(),needsParams:S(u()).optional()}),PA=b({id:r(),stableId:u(),addonId:u(),type:u(),name:u(),parentDeviceId:r().nullable(),online:v(),features:S(u()),config:h(u(),C()),sourceInfo:uh.optional()}),FA=b({status:x([`ok`,`error`]),labels:S(u()).optional(),error:u().optional()}),IA=C(),LA={name:`device-provider`,scope:`system`,mode:`collection`,methods:{start:E(_(),_(),{kind:`mutation`}),stop:E(_(),_(),{kind:`mutation`}),getStatus:E(_(),AA),getDevices:E(_(),S(b({id:u(),name:u(),type:u()}))),reloadDevice:E(b({stableId:u()}),b({deviceId:r()}),{kind:`mutation`,timeoutMs:3*6e4}),supportsDiscovery:E(b({}),v()),discoverDevices:E(b({params:h(u(),C()).optional()}),S(NA),{kind:`mutation`,auth:`admin`}),getDiscoveryModes:E(b({}),S(jA)),classifyDiscoveryHits:E(b({hits:S(MA),params:h(u(),C()).optional()}),S(NA),{kind:`mutation`,auth:`admin`}),getDiscoveryParamsSchema:E(b({}),IA),getManualCreationType:E(b({integrationId:u().optional()}),b({deviceType:x(j).nullable()})),adoptDiscoveredDevice:E(b({candidate:NA,integrationId:u().optional()}),PA,{kind:`mutation`,auth:`admin`}),supportsManualCreation:E(b({}),v()),getChildCreationSchema:E(b({type:x(j),integrationId:u().optional()}),IA),createDevice:E(b({type:x(j),config:h(u(),C()),integrationId:u().optional()}),PA,{kind:`mutation`,auth:`admin`}),testCreationField:E(b({type:x(j),key:u(),value:C(),formValues:h(u(),C()).optional()}),FA,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},RA=a(`kind`,[b({kind:m(`mdns`),serviceType:u(),instance:u(),host:u(),address:u().nullable(),port:r().int(),txt:h(u(),u())}),b({kind:m(`ssdp`),host:u(),port:r().int(),target:u(),headers:h(u(),u())})]),Rye=b({addonId:u(),candidate:NA,firstSeenAt:r(),lastSeenAt:r(),dismissed:v()}),zA=b({id:u(),addonId:u(),candidate:NA,firstSeenAt:r(),lastSeenAt:r(),dismissed:v()}),BA=b({childKey:u(),section:u(),order:r().optional(),collapsed:v().optional()}),zye=b({unit:u().min(1).optional(),precision:r().int().min(0).max(10).optional()}),VA=b({icon:u().min(1).optional(),label:u().min(1).optional(),unit:u().min(1).optional(),precision:r().int().min(0).max(10).optional(),hidden:v().optional(),perCap:h(u(),zye).optional()}),HA=b({unit:u().min(1).optional(),precision:r().int().min(0).max(10).optional(),icon:u().min(1).optional()}),UA=b({id:r(),stableId:u(),addonId:u(),type:x(j),name:u(),alias:tk.optional(),location:u().nullable(),tags:Zu.optional(),disabled:v(),parentDeviceId:r().nullable(),role:u().nullable().optional(),online:v(),probed:v().optional(),features:S(u()),isCamera:v(),config:h(u(),C()),secretConfigPaths:S(u()).optional(),metadata:h(u(),C()).nullable().optional(),identifiers:Kk.optional(),attachedIdentifiers:Kk.optional(),sourceInfo:uh.optional(),integrationId:u().optional(),linkDeviceId:r().nullable().optional(),primaryChildEntityId:u().nullable().optional(),childLayout:S(BA).readonly().optional(),primaryChildPreference:S(u()).readonly().optional(),display:VA.optional()}),WA=b({key:u(),value:C(),description:u().optional()}),GA=x([`manual`]),KA=b({deviceId:r(),name:u(),location:u().nullable(),features:S(u()),producesTrackedEvents:v().optional()}),qA=b({deviceIds:S(r().int().positive()),trackedDeviceIds:S(r().int().positive()).optional()}),JA={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:[j.Camera],sourceCaps:`any`,cardinality:`many`,value:qA},Bye=b({deviceId:r(),mode:GA,devices:S(KA)}),YA=b({deviceId:r(),entries:S(b({capName:u(),kind:x([`native`,`wrapped`]),providerAddonId:u(),providerNodeId:u(),nativeAddonId:u(),implementedMethods:S(u()).optional()}))}),XA=a(`kind`,[b({kind:m(`value`),wrapperAddonId:u().nullable()}),b({kind:m(`missing`)}),b({kind:m(`failed`),error:u()})]),Vye=b({id:r(),stableId:u(),type:u(),name:u(),location:u().nullable(),tags:Zu.optional(),disabled:v(),parentDeviceId:r().nullable(),role:u().nullable().optional()}),Hye=b({id:r(),stableId:u(),addonId:u(),type:u(),name:u(),userNamed:v().optional(),location:u().nullable(),tags:Zu.optional(),disabled:v(),parentDeviceId:r().nullable(),metadata:h(u(),C()).nullable().optional(),identifiers:Kk.optional(),attachedIdentifiers:Kk.optional(),sourceInfo:uh.optional(),integrationId:u().optional(),linkDeviceId:r().nullable().optional(),primaryChildEntityId:u().nullable().optional(),childLayout:S(BA).readonly().optional(),primaryChildPreference:S(u()).readonly().optional(),role:u().nullable().optional(),display:VA.optional()}),Uye=C().nullable(),Wye=b({streamId:u(),width:r().optional(),height:r().optional(),codec:u().optional(),fps:r().optional(),bitrateKbps:r().optional()}),Gye=b({addonId:u(),stableId:u(),id:r(),type:u(),name:u(),location:u().nullable().optional(),disabled:v().optional(),parentDeviceId:r().nullable(),role:u().nullable().optional(),features:S(u()).optional(),config:h(u(),C()),secretConfigPaths:S(u()).optional()}),ZA=b({deviceId:r().int().positive(),deletedAt:r(),providerAddonId:u()}),QA=2160*60*60*1e3,$A=b({deviceId:r().int().positive(),stores:h(u(),r().int().nonnegative())}),ej=b({status:x([`skipped`,`dry-run`,`cleaned`]),reason:u().nullable(),devices:S($A),unreachable:S(u())}),Kye=b({deviceId:r()}),qye=b({deviceId:r(),data:h(u(),C()),secretConfigPaths:S(u()).optional()}),tj=x([`off`,`on`,`not-offered`,`unreachable`]),nj=b({deviceId:r(),switchId:Za,outcome:tj,detail:u().optional()}),rj=b({sourceId:r(),targetId:r(),switches:S(nj).readonly(),sourceStillLive:S(Za).readonly(),swapped:v()}),ij={name:`device-manager`,scope:`system`,mode:`singleton`,extensionSlots:[JA],methods:{allocateDeviceId:E(b({addonId:u(),stableId:u()}),b({id:r()}),{kind:`mutation`}),migrateDevice:E(b({sourceId:r(),targetId:r()}),rj,{kind:`mutation`,auth:`admin`,timeoutMs:12*6e4}),registerDevice:E(Gye,_(),{kind:`mutation`}),removeDevice:E(Kye,_(),{kind:`mutation`}),persistConfig:E(qye,_(),{kind:`mutation`,auth:`admin`}),loadConfig:E(b({deviceId:r()}),h(u(),C()),{auth:`admin`}),loadRuntimeState:E(b({deviceId:r()}),h(u(),C()),{auth:`admin`}),loadMeta:E(b({deviceId:r()}),Hye.nullable()),setName:E(b({deviceId:r(),name:u(),stampUserNamed:v().optional()}),_(),{kind:`mutation`,auth:`admin`}),setAlias:E(b({deviceId:r(),alias:u()}),a(`ok`,[b({ok:m(!0),alias:tk}),b({ok:m(!1),reason:x([`empty`,`too-long`,`grammar`,`reserved`,`taken`]),takenBy:r().optional()})]),{kind:`mutation`,auth:`admin`}),renderDeviceTemplates:E(b({templates:S(Dk).max(64),allowedDeviceIds:S(r().int()).optional(),thisDevice:kk.optional()}),b({results:S(Pk)}),{auth:`admin`}),checkDeviceTemplates:E(b({templates:S(u()).max(64),allowedDeviceIds:S(r().int()).optional(),thisDevice:kk.optional()}),b({results:S(a(`ok`,[b({ok:m(!0),aliases:S(b({alias:u(),deviceId:r().int().nullable(),allowed:v(),reads:S(u())})),readsClock:v()}),b({ok:m(!1),refusal:jk})]))}),{auth:`admin`}),setLocation:E(b({deviceId:r(),location:u().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setTags:E(b({deviceId:r(),tags:Zu}),_(),{kind:`mutation`,auth:`admin`}),setType:E(b({deviceId:r(),type:x(j)}),_(),{kind:`mutation`,auth:`admin`}),setIntegrationId:E(b({deviceId:r(),integrationId:u()}),_(),{kind:`mutation`,auth:`admin`}),setLinkDeviceId:E(b({deviceId:r(),linkDeviceId:r().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setPrimaryChildEntityId:E(b({deviceId:r(),primaryChildEntityId:u().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setChildLayout:E(b({deviceId:r(),childLayout:S(BA).readonly()}),_(),{kind:`mutation`,auth:`admin`}),setPrimaryChildPreference:E(b({deviceId:r(),primaryChildPreference:S(u()).readonly()}),_(),{kind:`mutation`,auth:`admin`}),setDisplay:E(b({deviceId:r(),display:VA.nullable()}),_(),{kind:`mutation`,auth:`admin`}),getRoleDisplayDefaults:E(b({}),b({defaults:h(u(),HA)}),{role:`viewer`,kind:`query`}),setRoleDisplayDefaults:E(b({defaults:h(u(),HA)}),_(),{kind:`mutation`,auth:`admin`}),getWireableFields:E(b({deviceId:r(),includeSynthesizable:v().optional()}),b({caps:S(b({cap:u(),fields:S(b({path:u(),kind:x([`string`,`number`,`boolean`,`enum`,`union`]),unionMembers:S(x([`string`,`number`,`boolean`])).optional(),enumValues:S(u()).optional(),item:v().optional(),quantity:Zs.optional()})).readonly(),itemArray:b({path:u(),keyField:u()}).optional()})).readonly()}),{kind:`query`}),setRole:E(b({deviceId:r(),role:u().nullable()}),_(),{kind:`mutation`,auth:`admin`}),applyInitialMeta:E(b({deviceId:r(),name:u().optional(),location:u().nullable().optional(),tags:Zu.optional(),type:x(j).optional(),integrationId:u().optional(),linkDeviceId:r().nullable().optional(),role:u().nullable().optional()}),_(),{kind:`mutation`,auth:`admin`}),setMetadata:E(b({deviceId:r(),patch:h(u(),C())}),_(),{kind:`mutation`,auth:`admin`}),setIdentifiers:E(b({deviceId:r(),identifiers:Kk.nullable(),unread:S(Bk).optional()}),_(),{kind:`mutation`,auth:`admin`}),listIdentityCandidates:E(b({}),sA,{kind:`query`,auth:`admin`}),setAttachedIdentifiers:E(b({deviceId:r(),identifiers:Kk.nullable(),unread:S(Bk).optional()}),_(),{kind:`mutation`,auth:`admin`}),listIdentityLinks:E(b({deviceId:r().int().optional()}),_A,{kind:`query`,auth:`admin`}),confirmIdentityLink:E(b({linkId:u().min(1)}),yA,{kind:`mutation`,auth:`admin`}),dismissIdentityLink:E(b({linkId:u().min(1)}),yA,{kind:`mutation`,auth:`admin`}),unlinkIdentity:E(b({linkId:u().min(1)}),yA,{kind:`mutation`,auth:`admin`}),listLocations:E(_(),S(u())),addLocation:E(b({name:u()}),_(),{kind:`mutation`,auth:`admin`}),removeLocation:E(b({name:u(),cascade:v().optional()}),_(),{kind:`mutation`,auth:`admin`}),renameLocation:E(b({from:u(),to:u()}),b({moved:r()}),{kind:`mutation`,auth:`admin`}),listLocationIcons:E(_(),S(Dp),{role:`viewer`}),setLocationIcon:E(b({location:u(),icon:Bu.nullable()}),_(),{kind:`mutation`,auth:`admin`}),listLocationDescriptions:E(_(),S(kp)),setLocationDescription:E(b({location:u(),description:u().max(400).nullable()}),_(),{kind:`mutation`,auth:`admin`}),listSiteZones:E(_(),S(Rk),{role:`viewer`}),setSiteZone:E(b({name:u(),icon:Bu.nullable().optional()}),_(),{kind:`mutation`,auth:`admin`}),removeSiteZone:E(b({name:u()}),_(),{kind:`mutation`,auth:`admin`}),renameSiteZone:E(b({from:u(),to:u()}),_(),{kind:`mutation`,auth:`admin`}),setLocationZone:E(b({location:u(),zone:u().nullable()}),_(),{kind:`mutation`,auth:`admin`}),setDisabled:E(b({deviceId:r(),disabled:v()}),_(),{kind:`mutation`,auth:`admin`}),listPersistedByAddon:E(b({addonId:u()}),S(Vye)),listAll:E(b({addonId:u().optional(),projection:x([`full`,`slim`]).optional(),isCamera:v().optional(),deviceIds:S(r()).optional()}),S(UA),{role:`viewer`}),search:E(CA,kA,{role:`viewer`}),getDevice:E(b({deviceId:r()}),UA.nullable()),getChildren:E(b({parentDeviceId:r()}),S(UA),{role:`viewer`}),getChildrenBatch:E(b({parentDeviceIds:S(r()).max(256)}),h(u(),S(UA))),getLinkedDevices:E(b({deviceId:r()}),b({mode:GA,devices:S(KA)}),{role:`viewer`}),getLinkedDevicesBatch:E(b({deviceIds:S(r())}),S(Bye),{role:`viewer`}),getStreamSources:E(b({deviceId:r()}),S(pc)),getConfigSchema:E(b({deviceId:r()}),S(WA)),getSettingsSchema:E(b({deviceId:r()}),Uye),updateConfig:E(b({deviceId:r(),values:h(u(),C())}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),enable:E(b({deviceId:r()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),disable:E(b({deviceId:r()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),remove:E(b({deviceId:r()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),listDeletedSince:E(b({sinceMs:r()}),S(ZA).readonly(),{auth:`admin`}),cleanupDeletedDevicesData:E(b({confirm:v()}),ej,{kind:`mutation`,auth:`admin`}),removeByIntegration:E(b({integrationId:u()}),b({removed:r()}),{kind:`mutation`,auth:`admin`}),getStreamProfileMap:E(b({deviceId:r()}),h(u(),u().nullable())),setStreamProfileMap:E(b({deviceId:r(),profileMap:h(u(),u().nullable())}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),probeStreams:E(b({deviceId:r()}),S(Wye),{kind:`mutation`,auth:`admin`}),getBindings:E(b({deviceId:r()}),YA,{role:`viewer`}),getBindingsBatch:E(b({deviceIds:S(r())}),S(YA)),getAllBindings:E(b({}),S(YA)),listDeviceIdsByCaps:E(b({capNames:S(u().min(1)).min(1).max(16)}),S(r()),{role:`viewer`}),setWrapperActive:E(b({deviceId:r(),capName:u(),wrapperAddonId:u(),active:v()}),_(),{kind:`mutation`,auth:`admin`}),getWrapperActivation:E(b({deviceId:r(),capName:u().min(1)}),XA),listWrappersForCap:E(b({capName:u()}),S(u())),listBindableCapsForDeviceType:E(b({deviceType:u()}),S(b({capName:u(),wrappers:S(u())}))),getDeviceSettingsAggregate:E(b({deviceId:r()}),Fv.nullable()),getDeviceLiveInfoAggregate:E(b({deviceId:r()}),Fv.nullable(),{role:`viewer`}),getDeviceAggregate:E(b({deviceId:r()}),b({settings:Fv.nullable(),live:Fv.nullable()})),runDeviceAction:E(b({deviceId:r().int().nonnegative(),action:u().min(1),input:C()}),C(),{kind:`mutation`}),updateDeviceField:E(b({deviceId:r(),writerCapName:u(),writerAddonId:u(),key:u(),value:C()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),updateDeviceFieldsBatch:E(b({deviceId:r(),changes:S(b({writerCapName:u(),writerAddonId:u(),key:u(),value:C()}))}),b({success:m(!0),failures:S(b({writerCapName:u(),writerAddonId:u(),error:u()}))}),{kind:`mutation`,auth:`admin`}),discoverDevices:E(b({addonId:u()}),S(NA),{kind:`mutation`,auth:`admin`}),adoptDevice:E(b({addonId:u(),candidate:NA,integrationId:u().optional()}),PA,{kind:`mutation`,auth:`admin`}),getCreationSchema:E(b({addonId:u(),type:x(j),integrationId:u().optional()}),C().nullable()),createDevice:E(b({addonId:u(),type:x(j),config:h(u(),C()),integrationId:u().optional()}),PA,{kind:`mutation`,auth:`admin`}),testCreationField:E(b({addonId:u(),type:x(j),key:u(),value:C(),formValues:h(u(),C()).optional()}),FA,{kind:`mutation`,auth:`admin`}),adoptionListCandidateFilters:E(b({addonId:u(),integrationId:u()}),b({filters:S(zO)}),{auth:`admin`}),adoptionListCandidates:E(VO.extend({addonId:u()}),HO,{auth:`admin`}),adoptionRefresh:E(b({addonId:u(),integrationId:u()}),WO,{kind:`mutation`,auth:`admin`}),adoptionAdopt:E(GO.extend({addonId:u()}),KO,{kind:`mutation`,auth:`admin`}),adoptionRelease:E(qO.extend({addonId:u()}),_(),{kind:`mutation`,auth:`admin`}),adoptionStartJob:E(GO.extend({addonId:u()}),b({jobId:u()}),{kind:`mutation`,auth:`admin`}),adoptionListJobs:E(b({addonId:u(),integrationId:u().optional()}),S(dre).readonly(),{auth:`admin`}),adoptionCancelJob:E(b({jobId:u()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),adoptionResync:E(JO,YO,{kind:`mutation`,auth:`admin`}),discoveryProviders:E(b({}),b({providers:S(b({addonId:u(),label:u()})).readonly()}),{auth:`admin`}),discoverAllProviders:E(b({subnets:S(u()).optional()}),b({groups:S(b({addonId:u(),label:u(),candidates:S(NA).readonly(),error:u().nullable()})).readonly()}),{kind:`mutation`,auth:`admin`}),discoverProvider:E(b({addonId:u(),params:h(u(),C()).optional(),subnets:S(u()).optional()}),b({candidates:S(NA).readonly()}),{kind:`mutation`,auth:`admin`}),listDiscoveryProposals:E(b({}),b({proposals:S(zA).readonly()}),{auth:`admin`}),dismissDiscoveryProposal:E(b({id:u()}),b({dismissed:v()}),{kind:`mutation`,auth:`admin`}),reportDiscoveryObservations:E(b({observations:S(RA).max(512)}),b({proposed:r().int()}),{kind:`mutation`,auth:`admin`}),runDiscoverySweep:E(b({}),b({providers:r().int(),proposed:r().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),providerCreationType:E(b({addonId:u(),integrationId:u().optional()}),b({deviceType:x(j).nullable()}),{auth:`admin`}),providerDiscoveryParamsSchema:E(b({addonId:u()}),C(),{auth:`admin`}),testField:E(b({deviceId:r(),key:u(),value:C()}),FA,{kind:`mutation`,auth:`admin`}),getDeviceStatusAggregate:E(b({deviceId:r(),caps:S(u()).readonly().optional()}),h(u(),C().nullable())),getDeviceStatusAggregateBatch:E(b({deviceIds:S(r()).readonly(),caps:S(u()).readonly().optional()}),h(u(),h(u(),C().nullable())),{role:`viewer`})},vocabulary:{notOperatorFacing:`the device registry itself — rename, move and remove are administration`}},aj=[`linked-devices`],oj=x(aj),sj={"linked-devices":{descriptor:JA,declaringCap:`device-manager`,hostDeviceTypes:[j.Camera]}},cj=a(`slot`,[qA.extend({slot:m(`linked-devices`)})]),lj=[j.Camera],Jye=`listSlots`,uj=a(`state`,[b({state:m(`ok`)}),b({state:m(`unreachable`),reason:u()})]),dj=b({source:u(),label:u(),addonId:u().optional(),availability:uj}),fj=x([`ok`,`missing`,`foreign`,`unavailable`]),pj=b({deviceId:r().int(),name:u().nullable(),health:fj,detail:u().optional()}),mj=b({state:x([`active`,`inactive`,`unknown`]),authority:u(),detail:u().optional()}),hj=b({state:m(`ok`),slotRef:u(),slot:oj,authority:u(),activation:mj.nullable(),value:cj,sources:S(pj),impliedSources:S(pj).optional()}),gj=b({state:m(`unreachable`),addonId:u(),reason:u()}),_j=a(`state`,[hj,gj]);function Yye(e,t){return{state:`unreachable`,addonId:e,reason:t}}var vj=b({deviceId:r().int(),name:u(),type:u(),location:u().nullable(),parentName:u().nullable(),suggested:v(),reason:u().nullable()}),yj=b({candidates:S(vj)}),bj=b({applied:m(!0),reload:x([`none`,`host`,`parent`])}),xj=b({deviceId:r().int(),slotRef:u().min(1)}),Sj=xj.extend({value:cj}),Cj={name:`device-extension`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:lj,deviceConfig:{ui:{kind:`widget`,widgetId:`host/extensions-panel`,tab:`general`,label:`Extensions`,order:72}},methods:{listSources:E(b({deviceId:r().int()}),S(dj)),listSlots:E(b({deviceId:r().int()}),S(_j)),listCandidates:E(xj,yj),setSlot:E(Sj,bj,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:I(`Device extension`,`Estensione del dispositivo`),order:3100}},wj=a(`kind`,[b({kind:m(`device`),deviceId:r().int()}),b({kind:m(`node`),nodeId:u().min(1)})]),Tj=x([`gauge`,`counter`,`boolean`,`enum`]),Ej=x([`gauge`,`counter`,`boolean`]),Dj=`derived:energy.kwh`,Oj=x([`raw`,`5m`,`1h`,`1d`]),kj=x([`undeclared`,`not-owner`,`opted-out`,`not-a-real-device`,`rate`,`ingest-mismatch`,`out-of-range`]),Xye=b({key:u(),reason:kj,count:r().int()}),Aj=b({accepted:r().int(),refused:S(Xye).readonly()}),jj=b({key:u(),scope:u(),kind:Tj,unit:u().nullable(),displayName:u(),source:x([`cap`,`addon`,`derived`]),values:S(u()).readonly().nullable(),firstTs:r(),lastTs:r()}),Zye=b({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()}),Qye=b({scope:u(),before:b({t:r(),value:r().nullable(),state:u().nullable()}).nullable(),points:S(Zye).readonly(),derivedFrom:u().nullable()}),Mj={key:u(),scope:u().optional(),from:r(),to:r(),resolution:g([Oj,m(`auto`)]).default(`auto`),maxPoints:r().int().positive().max(5e3).default(1e3)},Nj=b({resolution:Oj,series:S(Qye).readonly(),truncated:v()}),$ye=g([b({deviceId:r().int(),key:u(),scope:u().optional()}),b({forNodeId:u().min(1),key:u(),scope:u().optional()})]),ebe=a(`ok`,[b({ok:m(!0),result:Nj}),b({ok:m(!1),error:u()})]),tbe=b({tier:Oj,rows:r().int().nullable(),approxBytes:r().nullable(),countedAt:r().nullable()}),Pj=x([`device-gone`,`undeclared`]),Fj=b({raw:r().int(),"5m":r().int(),"1h":r().int(),"1d":r().int()}),nbe=b({seriesId:r().int(),deviceId:r().int(),key:u(),scope:u(),displayName:u().nullable(),reason:Pj,missingSince:r().nullable(),firstTs:r(),lastTs:r(),rows:Fj}),Ij=x([`not-found`,`not-orphan`,`failed`]),rbe=a(`ok`,[b({seriesId:r().int(),ok:m(!0),deleted:Fj}),b({seriesId:r().int(),ok:m(!1),reason:Ij})]),ibe=b({series:S(nbe).readonly(),truncated:v()}),Lj=x([`invalid-range`,`range-too-large`,`series-not-found`,`not-a-point-series`]),abe=b({"5m":r().int(),"1h":r().int(),"1d":r().int()}),obe=a(`ok`,[b({ok:m(!0),dryRun:v(),seriesId:r().int(),rows:Fj,rewritten:abe.nullable()}),b({ok:m(!1),reason:Lj})]),Rj=b({startedAt:r(),ready:v(),series:r().int(),metrics:r().int(),optedOutDevices:r().int(),tiers:S(tbe).readonly(),capture:b({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:b({accepted:r().int(),refused:h(u(),r().int())}),rollup:b({last5mAt:r().nullable(),last1hAt:r().nullable(),last1dAt:r().nullable(),errors:r().int(),dirty5m:r().int(),dirty1h:r().int(),dirty1d:r().int()}),retention:b({lastRunAt:r().nullable(),deleted:h(u(),r().int()),purgedSeries:r().int()}),directory:b({devices:r().int(),lastRefreshAt:r().nullable()})}),zj={name:`device-history`,scope:`system`,mode:`singleton`,methods:{listSeries:E(b({deviceId:r().int()}),S(jj).readonly()),listNodeSeries:E(b({forNodeId:u().min(1)}),S(jj).readonly(),{auth:`admin`}),query:E(b({deviceId:r().int(),...Mj}),Nj),queryNode:E(b({forNodeId:u().min(1),...Mj}),Nj,{auth:`admin`}),queryMany:E(b({items:S($ye).min(1).max(24),from:Mj.from,to:Mj.to,resolution:Mj.resolution,maxPoints:Mj.maxPoints}),b({results:S(ebe).readonly()}),{auth:`admin`}),declareSeries:E(b({name:u().regex(/^[a-z0-9-]+$/),subjectKind:x([`device`,`node`]),kind:Ej,unit:u().optional(),displayName:u().min(1),ingest:x([`points`,`buckets`])}),b({key:u()}),{kind:`mutation`,auth:`admin`}),record:E(b({points:S(b({key:u(),subject:wj,scope:u().default(``),ts:r(),value:r()})).max(5e3)}),Aj,{kind:`mutation`,auth:`admin`}),recordBuckets:E(b({buckets:S(b({key:u(),subject:wj,scope:u().default(``),bucketStart:r(),samples:r().int().positive(),sum:r(),min:r(),max:r(),last:r().nullable(),lastTs:r().nullable()})).max(5e3)}),Aj,{kind:`mutation`,auth:`admin`}),getDeviceEnabled:E(b({deviceId:r().int()}),b({enabled:v()})),setDeviceEnabled:E(b({deviceId:r().int(),enabled:v()}),b({enabled:v()}),{kind:`mutation`,auth:`admin`}),getStatus:E(b({}),Rj,{auth:`admin`}),listOrphanSeries:E(b({}),ibe,{auth:`admin`}),deleteOrphanSeries:E(b({seriesIds:S(r().int()).min(1).max(50)}),b({results:S(rbe).readonly()}),{kind:`mutation`,auth:`admin`}),deleteSeriesRange:E(b({deviceId:r().int(),key:u().min(1),scope:u(),fromMs:r().int().nonnegative(),toMs:r().int().nonnegative(),dryRun:v()}),obe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`recorded history of device state — read by charts, not actuated`}},sbe=b({id:u(),label:u(),protocol:x([`rtsp`,`rtmp`,`annexb`,`http-mjpeg`,`webrtc`,`custom`]),url:u().optional(),resolution:b({width:r(),height:r()}).optional(),fps:r().optional(),bitrate:r().optional(),codec:u().optional(),profileHint:A.optional(),sdp:u().optional()}),cbe=b({key:u(),value:C()}),Bj=b({source:u(),data:h(u(),C())}),Vj={name:`device-ops`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getStreamSources:E(b({deviceId:r()}),S(sbe)),getConfigEntries:E(b({deviceId:r()}),S(cbe)),setConfig:E(b({deviceId:r(),values:h(u(),C())}),_(),{kind:`mutation`,auth:`admin`}),runAction:E(b({deviceId:r(),action:u().min(1),input:C()}),C(),{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:E(b({deviceId:r()}),_(),{kind:`mutation`,auth:`admin`}),getSettingsSchema:E(b({deviceId:r()}),C().nullable()),getRawState:E(b({deviceId:r()}),Bj.nullable(),{auth:`protected`})},vocabulary:{noun:I(`Device operations`,`Operazioni del dispositivo`),order:3110}},Hj=b({deviceId:r().int().positive(),deletedAt:r(),providerAddonId:u()}),Uj=b({counts:h(u(),r().int().nonnegative())}),Wj=b({store:u(),deviceId:r().int().positive(),count:r().int().nonnegative()}),Gj={name:`device-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onDeviceRemoved:E(Hj,Uj,{kind:`mutation`,auth:`admin`}),listDeviceData:E(_(),S(Wj).readonly(),{auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},Kj=x([`appliance`,`mower`,`vacuum`]),qj=x([`open`,`closed`]),Jj=x([`completed`,`aborted`,`error`,`unknown`]),Yj=x([`running-state`,`activity`,`reconcile`]),Xj=x([`counter-delta`,`history-integral`]),Zj=b({phase:u(),at:r()}),Qj=b({kind:m(`appliance`),energyKwh:r().nullable().meta(k(`energy`)),energyMethod:Xj.nullable(),peakW:r().nullable().meta(k(`power`)),avgW:r().nullable().meta(k(`power`)),program:u().nullable(),remainingAtStartSec:r().nullable().meta(k(`duration`)),finalPhase:u().nullable(),energyStartKwh:r().nullable().meta(k(`energy`)),powerObservedMs:r()}),$j=a(`kind`,[Qj]),eM=b({runId:u(),deviceId:r().int(),kind:Kj,state:qj,startedAt:r(),endedAt:r().nullable(),durationMs:r().nullable(),outcome:Jj.nullable(),startSource:Yj,endSource:Yj.nullable(),runningSource:x([`native`,`assigned`]).nullable(),phases:S(Zj),detail:$j}),tM={name:`device-runs`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Washer,j.Dryer,j.Dishwasher],methods:{listRuns:E(b({deviceId:r().int(),outcome:Jj.optional(),atFrom:r().optional(),atTo:r().optional(),limit:r().int().positive().max(200).default(50),cursor:u().optional()}),b({runs:S(eM).readonly(),nextCursor:u().nullable()})),getRun:E(b({deviceId:r().int(),runId:u()}),eM.nullable()),getCurrentRun:E(b({deviceId:r().int()}),eM.nullable())},events:{onRunOpened:{data:eM,notOperatorFacing:`the durable record of a run that the running-state start flip already announces`},onRunClosed:{data:eM,notOperatorFacing:`the durable record of a run that the running-state finish flip already announces`}},vocabulary:{noun:I(`Runs`,`Esecuzioni`),order:2130}},nM=x([`replace`,`add`]),rM=a(`ok`,[b({ok:m(!0),changed:v()}),b({ok:m(!1),code:x([`owned-by-other`,`not-claimed`,`field-not-claimed`,`invalid-slice`,`unknown-device`,`row-unreadable`,`migration-in-flight`]),message:u()})]),iM=b({deviceId:r(),capName:u(),owner:u().min(1),mode:nM,fields:S(u().min(1)).min(1)}),aM=a(`state`,[b({state:m(`loaded`),claims:S(iM)}),b({state:m(`not-loaded`),reason:u()})]),oM={name:`device-state`,scope:`system`,mode:`singleton`,methods:{getSnapshot:E(b({deviceId:r()}),h(u(),h(u(),C()))),getCapSlice:E(b({deviceId:r(),capName:u(),confirmed:v().optional()}),h(u(),C()).nullable()),getAllSnapshots:E(b({confirmed:v().optional()}),h(u(),h(u(),h(u(),C())))),setCapSlice:E(b({deviceId:r(),capName:u(),slice:h(u(),C())}),_(),{kind:`mutation`}),claimFields:E(b({deviceId:r(),capName:u(),owner:u().min(1),mode:nM,fields:S(u().min(1)).min(1),values:h(u(),C())}),rM,{kind:`mutation`,auth:`admin`}),patchOwnedFields:E(b({deviceId:r(),capName:u(),owner:u().min(1),values:h(u(),C())}),rM,{kind:`mutation`,auth:`admin`}),releaseClaim:E(b({deviceId:r(),capName:u(),owner:u().min(1)}),rM,{kind:`mutation`,auth:`admin`}),listClaims:E(b({ownerPrefix:u().optional()}),aM,{auth:`admin`}),getNativeCapSlice:E(b({deviceId:r(),capName:u()}),h(u(),C()).nullable(),{auth:`admin`})},events:{onChanged:ui(b({deviceId:r(),capName:u(),slice:h(u(),C())}))},vocabulary:{notOperatorFacing:`the runtime-state mirror every trigger already reads through`}},sM=x([`schedule`,`command`,`burst`]),cM=x([`none`,`partial`,`full`]),lM=1e3,lbe=b({integrationId:u().min(1),minIntervalMs:r().int().min(lM),intervalMs:r().int().positive().optional(),batch:v(),push:cM,heartbeatMs:r().int().positive().optional(),connectionEpoch:r().int().nonnegative().optional()});function ube(e){let t=e.intervalMs??0;return Math.max(e.minIntervalMs,t)}var uM=[3e3,1e4],dM=1e4,fM=2e3;function dbe(e){let t=uM.filter(t=>t<e),n=e-fM,r=(t[t.length-1]??0)+dM;for(;r<n;)t.push(r),r+=dM;let i=t[t.length-1];return(i===void 0?n>0:n-i>=1e3)&&t.push(n),t}var fbe=2500,pM=b({deviceId:r().int().nonnegative(),deviceIds:S(r().int().nonnegative()).min(1),reason:sM}),mM=b({deviceId:r().int().nonnegative()}),hM=b({ok:m(!0)}),gM=`the core schedules state refreshes itself; an operator never asks for one`,_M={name:`device-state-refresh`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{refresh:E(pM,hM,{kind:`mutation`,auth:`admin`,notOperatorFacing:gM}),resubscribe:E(mM,hM,{kind:`mutation`,auth:`admin`,notOperatorFacing:gM})},vocabulary:{noun:I(`State refresh`,`Aggiornamento dello stato`),order:3247}},vM=b({online:v(),lastChangedAt:r()}),yM={name:`device-status`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onStatusChanged:{data:b({deviceId:r(),status:vM}),notOperatorFacing:"the `online` state trigger phrases both edges of this change"}},status:{schema:vM,kind:`push`},runtimeState:vM,durability:`restored`,history:{fields:{online:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Reachability`,`Raggiungibilità`),order:5260,state:[{kind:`boolean`,field:`online`,label:I(`Online`,`Online`),whenTrue:I(`When {device} comes back online`,`Quando {device} torna online`),whenFalse:I(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi`}],extraEvents:[{category:w.DeviceOnline,label:I(`Came online`,`Tornato online`),phrase:I(`When {device} comes back online`,`Quando {device} torna online`),icon:`wifi`},{category:w.DeviceOffline,label:I(`Went offline`,`Andato offline`),phrase:I(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi-off`}]}},bM=x([`not-kernel`,`invalid`]),xM=b({written:r().int().nonnegative(),refused:S(b({id:u(),reason:bM})).readonly()}),SM=b({rows:r().int().nullable(),lastWriteAt:r().nullable(),refused:h(u(),r())}),CM={name:`device-transitions`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Object.values(j).filter(e=>e!==j.Container),methods:{listTransitions:E(b({deviceId:r().int(),capName:u().optional(),actorKind:Do.optional(),outcome:Oo.optional(),atFrom:r().optional(),atTo:r().optional(),limit:r().int().positive().max(200).default(50),cursor:u().optional()}),b({transitions:S(ko).readonly(),nextCursor:u().nullable()})),getTransition:E(b({deviceId:r().int(),id:u()}),ko.nullable()),listRecentTransitions:li(b({actorKind:Do.optional(),outcome:Oo.optional(),atFrom:r().optional(),atTo:r().optional(),limit:r().int().positive().max(200).default(50),cursor:u().optional()}),b({transitions:S(ko).readonly(),nextCursor:u().nullable()}),{auth:`admin`}),record:li(b({transitions:S(ko).max(500)}),xM,{kind:`mutation`,auth:`admin`}),getStatus:li(b({}),SM,{auth:`admin`})},vocabulary:{noun:I(`Transitions`,`Transizioni`),order:2140}},wM=x([`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]),TM=x([`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]),EM=x([`available`,`offline`,`description-missing`]),DM=b({availability:EM,state:wM,operationState:TM.nullable(),program:u().nullable(),selectedProgram:u().nullable(),availablePrograms:S(u()),remaining:r().int().nonnegative().nullable().meta(k(`duration`)),delayedStart:r().int().nonnegative().nullable().meta(k(`duration`)),progress:r().min(0).max(100).nullable().meta(k(`percentage`)),doorOpen:v().nullable(),doorLocked:v().nullable(),remoteStartAllowed:v().nullable(),remoteControlActive:v().nullable(),localControlActive:v().nullable(),powerOn:v().nullable(),powerState:u().nullable(),filterCleaningDue:v().nullable(),machineCareDue:v().nullable(),machineCareRemainingRuns:r().int().nonnegative().nullable().meta(k(`count`)),halfLoad:v().nullable(),hygienePlus:v().nullable(),extraDry:v().nullable(),intensiveZone:v().nullable(),varioSpeedPlus:v().nullable(),childLock:v().nullable(),activeEvents:S(u()),errorCode:r().nullable().meta(k(`none`)),errorLabel:u().nullable(),lastFetchedAt:r()}),OM=r().int().nonnegative(),kM=g([v(),u(),r()]),AM=x([`none`,`read`,`readWrite`,`writeOnly`,`readStatic`]),jM=b({key:u(),name:u(),type:x([`boolean`,`number`,`enum`,`string`]),access:AM,available:v(),unit:u().nullable(),min:r().nullable(),max:r().nullable(),step:r().nullable(),enumValues:S(u()).nullable(),defaultValue:kM.nullable()}),MM=b({key:u(),name:u(),available:v(),options:S(jM)}),NM=b({availability:EM,supportsStart:v(),supportsPause:v(),supportsResume:v(),supportsStop:v(),supportsPower:v(),programs:S(MM),options:S(jM)}),PM={name:`dishwasher`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Dishwasher],methods:{start:E(b({deviceId:OM,program:u().min(1).optional(),options:h(u(),kM).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.start`,label:I(`Start cycle`,`Avvia il lavaggio`),phrase:I(`Start {device}`,`Avvia {device}`),icon:`play`,openArgs:[{key:`program`,label:I(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`},optional:!0}]}]}),pause:E(b({deviceId:OM}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.pause`,label:I(`Pause`,`Metti in pausa`),phrase:I(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),resume:E(b({deviceId:OM}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.resume`,label:I(`Resume`,`Riprendi`),phrase:I(`Resume {device}`,`Riprendi il lavaggio di {device}`),icon:`play`}]}),stop:E(b({deviceId:OM}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.stop`,label:I(`Stop`,`Ferma`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setProgram:E(b({deviceId:OM,program:u().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.program`,label:I(`Choose programme`,`Scegli il programma`),phrase:I(`Select the {program} programme on {device}`,`Seleziona il programma {program} su {device}`),icon:`list`,openArgs:[{key:`program`,label:I(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`}}]}]}),setPower:E(b({deviceId:OM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.powerOn`,label:I(`Power on`,`Accendi`),phrase:I(`Turn on {device}`,`Accendi {device}`),icon:`power`,args:{on:!0}},{id:`dishwasher.powerOff`,label:I(`Power off`,`Spegni`),phrase:I(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,args:{on:!1}}]}),setHalfLoad:E(b({deviceId:OM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.halfLoadOn`,label:I(`Half load on`,`Mezzo carico attivo`),phrase:I(`Turn on half load on {device}`,`Attiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!0}},{id:`dishwasher.halfLoadOff`,label:I(`Half load off`,`Mezzo carico spento`),phrase:I(`Turn off half load on {device}`,`Disattiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!1}}]}),setHygienePlus:E(b({deviceId:OM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.hygienePlusOn`,label:I(`Hygiene Plus on`,`Igiene Plus attiva`),phrase:I(`Turn on Hygiene Plus on {device}`,`Attiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!0}},{id:`dishwasher.hygienePlusOff`,label:I(`Hygiene Plus off`,`Igiene Plus spenta`),phrase:I(`Turn off Hygiene Plus on {device}`,`Disattiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!1}}]}),setExtraDry:E(b({deviceId:OM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.extraDryOn`,label:I(`Extra dry on`,`Asciugatura extra attiva`),phrase:I(`Turn on extra dry on {device}`,`Attiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!0}},{id:`dishwasher.extraDryOff`,label:I(`Extra dry off`,`Asciugatura extra spenta`),phrase:I(`Turn off extra dry on {device}`,`Disattiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!1}}]}),setIntensiveZone:E(b({deviceId:OM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.intensiveZoneOn`,label:I(`Intensive zone on`,`Zona intensiva attiva`),phrase:I(`Turn on the intensive zone on {device}`,`Attiva la zona intensiva su {device}`),icon:`flame`,args:{on:!0}},{id:`dishwasher.intensiveZoneOff`,label:I(`Intensive zone off`,`Zona intensiva spenta`),phrase:I(`Turn off the intensive zone on {device}`,`Disattiva la zona intensiva su {device}`),icon:`flame`,args:{on:!1}}]}),setVarioSpeedPlus:E(b({deviceId:OM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.varioSpeedOn`,label:I(`Speed boost on`,`Lavaggio rapido attivo`),phrase:I(`Turn on the speed boost on {device}`,`Attiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!0}},{id:`dishwasher.varioSpeedOff`,label:I(`Speed boost off`,`Lavaggio rapido spento`),phrase:I(`Turn off the speed boost on {device}`,`Disattiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!1}}]}),setChildLock:E(b({deviceId:OM,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.childLockOn`,label:I(`Child lock on`,`Blocco bambini attivo`),phrase:I(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`dishwasher.childLockOff`,label:I(`Child lock off`,`Blocco bambini spento`),phrase:I(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setOption:E(b({deviceId:OM,key:u().min(1),value:kM}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw appliance option key/value; every option worth naming has its own action above`}),getOptions:E(b({deviceId:OM}),NM,{auth:`protected`})},status:{schema:DM,kind:`poll`},runtimeState:DM,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:I(`Dishwasher`,`Lavastoviglie`),order:2020,state:[{kind:`enum`,field:`state`,label:I(`Cycle`,`Ciclo`),values:[{value:`idle`,label:I(`Idle`,`Inattiva`)},{value:`running`,label:I(`Running`,`In funzione`),phrase:I(`When {device} starts a cycle`,`Quando {device} inizia un lavaggio`)},{value:`paused`,label:I(`Paused`,`In pausa`)},{value:`finished`,label:I(`Finished`,`Terminato`),phrase:I(`When {device} finishes`,`Quando {device} finisce il lavaggio`)},{value:`error`,label:I(`Error`,`Errore`),phrase:I(`When {device} reports an error`,`Quando {device} segnala un errore`)},{value:`unavailable`,label:I(`Unavailable`,`Non disponibile`)}],icon:`washing-machine`},{kind:`numeric`,field:`progress`,quantity:I(`the cycle progress`,`l’avanzamento del lavaggio`),label:I(`Progress`,`Avanzamento`),unit:`%`,icon:`loader`},{kind:`boolean`,field:`doorOpen`,label:I(`Door open`,`Sportello aperto`),whenTrue:I(`When the door of {device} opens`,`Quando si apre lo sportello di {device}`),whenFalse:I(`When the door of {device} closes`,`Quando si chiude lo sportello di {device}`),icon:`door-open`},{kind:`boolean`,field:`filterCleaningDue`,label:I(`Filter cleaning due`,`Pulizia filtro da fare`),whenTrue:I(`When {device} asks for its filter to be cleaned`,`Quando {device} chiede di pulire il filtro`),whenFalse:I(`When the filter reminder of {device} clears`,`Quando l’avviso filtro di {device} rientra`),icon:`funnel`},{kind:`boolean`,field:`machineCareDue`,label:I(`Machine care due`,`Manutenzione da fare`),whenTrue:I(`When {device} asks for a machine-care cycle`,`Quando {device} chiede un ciclo di manutenzione`),whenFalse:I(`When the machine-care reminder of {device} clears`,`Quando l’avviso di manutenzione di {device} rientra`),icon:`wrench`}]}},FM=`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(`.`),IM=`audio`,LM=[.3,.42,.55,.7,.85,1],RM=[`camstack`,`high-contrast`,`okabe-ito`];function pbe(e){return FM.includes(e)}function mbe(e){return RM.includes(e)}var zM={dark:`#0c0a09`,light:`#fafaf9`},hbe=[`live`,`heatmapScrub`],BM=/^#[0-9a-fA-F]{6}$/;function VM(e,t){return Number.parseInt(e.slice(t,t+2),16)}function HM(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function UM(e){let t=HM(VM(e,1)),n=HM(VM(e,3)),r=HM(VM(e,5));return .2126*t+.7152*n+.0722*r}function gbe(e,t){if(!BM.test(e)||!BM.test(t))return 0;let n=Math.max(UM(e),UM(t)),r=Math.min(UM(e),UM(t));return(n+.05)/(r+.05)}function WM(e){let t=HM(VM(e,1)),n=HM(VM(e,3)),r=HM(VM(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 GM(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 _be(e,t){if(!BM.test(e)||!BM.test(t))return 0;let n=WM(e),r=WM(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=GM(o,n.b),d=GM(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 ee=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),te=30*Math.exp(-(((g-275)/25)**2)),ne=h**7,_=2*Math.sqrt(ne/(ne+25**7)),re=1+.015*(m-50)**2/Math.sqrt(20+(m-50)**2),v=1+.045*h,ie=1+.015*h*ee,ae=-Math.sin(2*te*Math.PI/180)*_,oe=r.L-n.L,se=l-c;return Math.sqrt((oe/re)**2+(se/v)**2+(p/ie)**2+se/v*ae*(p/ie))}var vbe={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`},ybe=[`#b34dc7`,`#1d7d34`,`#db6b6c`,`#a43d29`,`#0e6ee6`,`#29a10b`,`#a98731`,`#0181c6`],bbe={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`},xbe=[`#817f3b`,`#a0733e`,`#8658b2`,`#956301`,`#bc652d`,`#647331`,`#a14c9e`,`#d14e71`],Sbe={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`},Cbe=[`#9a3784`,`#a7392c`,`#409d50`,`#6987e7`,`#ee5b3d`,`#c0430d`,`#af79b3`,`#4b6628`],KM=u().regex(/^#[0-9a-f]{6}$/),qM=a(`form`,[b({form:m(`solid`),hex:KM}),b({form:m(`gradient`),hex:KM,alphas:S(r().gt(0).lte(1)).length(LM.length)})]),JM=b({status:m(`ready`),presetId:x(RM),customized:v(),source:x([`stored`,`unconfigured`]),swatches:h(u(),qM),fallbacks:S(KM).length(8)}),YM=a(`status`,[JM,b({status:m(`unknown`),reason:u()})]),XM=g([b({presetId:u()}),b({presetId:u(),overrides:h(u(),qM)})]),ZM=b({presetId:u(),overrides:h(u(),qM)});function wbe(e){return{form:`solid`,hex:e}}function Tbe(e){return{form:`gradient`,hex:e,alphas:[...LM]}}function Ebe(e){let t={};for(let n of FM){let r=e[n];if(r===void 0)throw Error(`palette table missing ${n}`);t[n]=n===`audio`?Tbe(r):wbe(r)}return t}function QM(e,t,n,r){return{id:e,name:t,swatches:Ebe(n),fallbacks:r}}var $M=[QM(`camstack`,`CamStack`,vbe,ybe),QM(`high-contrast`,`High contrast`,bbe,xbe),QM(`okabe-ito`,`Colour-blind safe`,Sbe,Cbe)];function eN(e){return $M.find(t=>t.id===e)}function tN(){let e=eN(`camstack`);if(e===void 0)throw Error(`CamStack preset missing`);return Dbe(e,`unconfigured`,!1)}function Dbe(e,t,n){return{status:`ready`,presetId:e.id,customized:n,source:t,swatches:e.swatches,fallbacks:[...e.fallbacks]}}function Obe(e){return e.hex}function kbe(e,t){let n=[];for(let t of FM){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 Abe(e){let t=e[IM];return t===void 0||t.form===`gradient`&&LM.every((e,n)=>t.alphas[n]===e)?[]:[{code:`bad-gradient`,entry:IM}]}function jbe(e,t){let n=hbe;return n.includes(e)&&n.includes(t)}function nN(e,t){let n=[];for(let t of FM)e[t]===void 0&&n.push({code:`missing-entry`,entry:t});for(let t of Object.keys(e))pbe(t)||n.push({code:`unknown-entry`,entry:t});t.length!==8&&n.push({code:`bad-fallbacks`}),n.push(...Abe(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=_be(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=gbe(e.hex,zM[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 Mbe(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 rN(e){return e.map(Mbe).join(`; `)}var iN=class extends Error{violations;constructor(e){super(rN(e)),this.name=`PaletteRejectedError`,this.violations=e}};function aN(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 oN(e,t,n){let r=n.trim().toLowerCase();if(r.startsWith(`audio-`)){let n=e[IM];return n===void 0?aN(r,t):n.hex}let i=e[r];return i===void 0?aN(r,t):i.hex}function sN(e,t){return{...e,...t}}function Nbe(e){return`overrides`in e?e.overrides:{}}function Pbe(e){let t=eN(e.presetId);if(t===void 0||!mbe(e.presetId))throw new iN([{code:`unknown-preset`,presetId:e.presetId}]);let n=Nbe(e),r=sN(t.swatches,n),i=nN(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 Fbe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function Ibe(e){if(e==null||Fbe(e))return tN();let t=ZM.safeParse(e);if(!t.success)return{status:`unknown`,reason:`stored palette is unreadable`};let n=eN(t.data.presetId);if(n===void 0)return{status:`unknown`,reason:`unknown preset ${t.data.presetId}`};let r=sN(n.swatches,t.data.overrides),i=nN(r,n.fallbacks);if(!i.ok)return{status:`unknown`,reason:rN(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 Lbe(e,t){return{presetId:e.presetId,overrides:{...t}}}var Rbe=b({id:u(),name:u(),swatches:h(u(),qM),fallbacks:S(u())}),cN={name:`display-palette`,scope:`system`,mode:`singleton`,methods:{getPalette:E(_(),YM,{auth:`protected`,role:`viewer`}),listPresets:E(_(),S(Rbe).readonly(),{auth:`protected`,role:`viewer`}),setPalette:E(XM,JM,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the cluster display palette — one colour table for every client, not a device action`}},lN=b({enabled:v().nullable().meta({label:`Do not disturb`}),lastChangedAt:r()}),uN={name:`do-not-disturb`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.MediaPlayer],methods:{setEnabled:E(b({deviceId:r().int(),enabled:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`dnd.on`,label:I(`Do not disturb on`,`Attiva Non disturbare`),phrase:I(`Turn on Do not disturb on {device}`,`Attiva Non disturbare su {device}`),icon:`bell-off`,args:{enabled:!0}},{id:`dnd.off`,label:I(`Do not disturb off`,`Disattiva Non disturbare`),phrase:I(`Turn off Do not disturb on {device}`,`Disattiva Non disturbare su {device}`),icon:`bell`,args:{enabled:!1}}]})},status:{schema:lN,kind:`push`},runtimeState:lN,durability:`session`,history:{fields:{enabled:{kind:`boolean`}}},vocabulary:{noun:I(`Do not disturb`,`Non disturbare`),order:2160,state:[{kind:`boolean`,field:`enabled`,label:I(`Do not disturb`,`Non disturbare`),whenTrue:I(`When Do not disturb turns on on {device}`,`Quando {device} attiva Non disturbare`),whenFalse:I(`When Do not disturb turns off on {device}`,`Quando {device} disattiva Non disturbare`),icon:`bell-off`}]}},dN=2e3,zbe={version:1,targets:[{id:`pressed`,cardinality:`event`,shape:`pulse`,vocabulary:{cap:`doorbell`,eventName:`onPressed`},deviceTypes:[j.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:dN,changedAtRequired:!0},sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},fN=b({lastPressedAt:r().nullable(),pressCountSinceStart:r().meta(k(`count`))}),pN=b({deviceId:r(),timestamp:r()}),mN={name:`doorbell`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Button,j.Camera],methods:{},events:{onPressed:{data:pN,fromState:{field:`lastPressedAt`,on:`advance`},trigger:{category:w.DoorbellOnPressed,label:I(`Rang`,`Ha suonato`),phrase:I(`When someone rings {device}`,`Quando qualcuno suona a {device}`),icon:`bell-ring`}}},status:{schema:fN,kind:`push`},runtimeState:fN,durability:`restored`,history:`none`,customize:zbe,vocabulary:{noun:I(`Doorbell`,`Campanello`),order:5270}},hN=b({embedding:S(r()),inferenceMs:r()}),gN=x([`image`,`text`]),_N=b({modelId:u(),tower:gN,nodeId:u(),crashes:r(),windowMs:r(),sinceMs:r(),lastReason:u()}),vN=b({modelId:u(),tower:gN,nodeId:u(),attempts:r(),sinceMs:r(),lastReason:u()}),yN=b({modelId:u(),embeddingDim:r(),ready:v(),nodeId:u().optional(),failedModels:S(_N).optional(),failedRequirements:S(vN).optional()}),bN=`embedding-model-failed`,xN=`embedding-requirements-unavailable`,SN=`embedding-requirements-failed`,CN=x([bN,xN,SN]);function wN(e,t){return`[${e} model=${t.modelId} tower=${t.tower} node=${t.nodeId}]`}function Bbe(e){return Error(`${wN(bN,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 Vbe(e,t){return Error(`${wN(xN,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: ${t}`)}function Hbe(e){return Error(`${wN(SN,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 Ube=RegExp(`\\[(${bN}|${xN}|${SN}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);function TN(e){let t=e instanceof Error?e.message:String(e),n=Ube.exec(t);if(n===null)return null;let r=CN.safeParse(n[1]),i=gN.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 Wbe(e){return EN(e)!==null}function EN(e){let t=TN(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 DN={name:`embedding-encoder`,scope:`system`,mode:`collection`,internal:!0,methods:{encode:E(b({crop:y(Uint8Array),width:r(),height:r()}),hN,{auth:`admin`}),encodeText:E(b({text:u(),modelId:u().min(1).optional()}),hN,{auth:`admin`}),getInfo:E(_(),yN,{auth:`admin`}),resetFailedModels:E(b({modelId:u().min(1).optional()}),b({cleared:S(u()),nodeId:u()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.ML}},ON=b({powerW:r().nullable().meta(k(`power`)),energyKwh:r().nullable().meta(k(`energy`)),todayKwh:r().nullable().meta(k(`energy`))}),kN=b({powerW:r().nullable().meta(k(`power`)),importKwh:r().nullable().meta(k(`energy`)),exportKwh:r().nullable().meta(k(`energy`)),importTodayKwh:r().nullable().meta(k(`energy`)),exportTodayKwh:r().nullable().meta(k(`energy`))}),AN=b({powerW:r().nullable().meta(k(`power`)),energyKwh:r().nullable().meta(k(`energy`)),todayKwh:r().nullable().meta(k(`energy`))}),jN=b({stateOfChargePct:r().nullable().meta(k(`percentage`)),storedKwh:r().nullable().meta(k(`energy`)),capacityKwh:r().nullable().meta(k(`energy`)),powerW:r().nullable().meta(k(`power`)),chargedKwh:r().nullable().meta(k(`energy`)),dischargedKwh:r().nullable().meta(k(`energy`)),chargedTodayKwh:r().nullable().meta(k(`energy`)),dischargedTodayKwh:r().nullable().meta(k(`energy`)),healthPct:r().nullable().meta(k(`percentage`))}),MN=b({solar:ON.nullable(),grid:kN.nullable(),house:AN.nullable(),heatPump:AN.nullable(),storage:jN.nullable(),lastFetchedAt:r()});function NN(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 PN={name:`energy-system`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.EnergySystem],methods:{},status:{schema:MN,kind:`push`},runtimeState:MN,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.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:I(`Energy system`,`Sistema energetico`),order:4020}},Gbe=x([`date`,`time`,`datetime`]),FN=b({value:u(),timestamp:v().optional(),lastFetchedAt:r()}),IN={name:`enum-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:FN,kind:`push`},runtimeState:FN,durability:`restored`,history:{fields:{value:{kind:`enum`,skipWhenSet:`timestamp`}}},volatileStateFields:[`lastFetchedAt`,`timestamp`],vocabulary:{noun:I(`State sensor`,`Sensore di stato`),order:5060,state:[{kind:`value`,field:`value`,label:I(`State`,`Stato`),icon:`list`}]}},LN=x([`warning`,`error`]),RN=b({code:u(),label:u(),severity:LN}),zN=b({active:v().nullable(),code:u().nullable(),label:u().nullable(),severity:LN,since:r().nullable(),faults:S(RN).optional(),lastFetchedAt:r()}),BN={active:null,code:null,label:null,severity:`error`,since:null,lastFetchedAt:0},VN={name:`error`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},status:{schema:zN,kind:`push`,empty:BN},runtimeState:zN,durability:`restored`,volatileStateFields:[`lastFetchedAt`],history:`none`,vocabulary:{noun:I(`Fault`,`Guasto`),order:5265,state:[{kind:`boolean`,field:`active`,label:I(`Fault`,`Guasto`),whenTrue:I(`When {device} reports a fault`,`Quando {device} segnala un guasto`),whenFalse:I(`When the fault of {device} clears`,`Quando il guasto di {device} si risolve`),icon:`triangle-alert`}]}},HN=b({id:u(),name:u(),sampleCount:r().int().nonnegative(),coverMediaId:r().int().optional(),coverBase64:u().optional()}),Kbe=b({id:u(),source:x([`detected`,`photo`]),addedAt:r().int(),deviceId:r().int().optional(),base64:u().optional(),mediaId:r().int().optional(),keyFrameMediaId:r().int().optional(),faceBbox:ny.optional()}),qbe=b({sampleId:u(),enrolledAt:r().int(),deviceId:r().int().optional(),source:x([`detected`,`photo`]),mediaId:r().int().optional(),comparable:v(),selfMean:r().nullable(),bestForeign:b({identityId:u(),name:u(),score:r()}).optional(),suspicion:r()}),Jbe=b({identityId:u(),name:u(),modelId:u(),totalSamples:r().int(),comparableSamples:r().int(),flagged:r().int(),flagThreshold:r(),rows:S(qbe).readonly()}),UN=b({faceId:u(),deviceId:r().int(),trackId:u(),timestamp:r().int(),recognizedIdentityId:u().optional(),identityName:u().optional(),assigned:v(),base64:u().optional(),cropUrl:u().optional(),faceBbox:ny.optional(),keyFrameMediaId:r().int().optional(),bestMatchScore:r().optional(),nativeFaceShortSidePx:r().optional(),suggestedIdentityId:u().optional(),suggestedMatchScore:r().optional()}),Ybe=x([`unassigned`,`recognized`,`identified`,`all`]),Xbe=x([`timestamp`,`suggestionConfidence`]),Zbe=x([`asc`,`desc`]),Qbe=b({faceIds:S(u()).readonly(),representativeFaceId:u(),size:r().int(),cohesion:r()}),$be=b({mediaId:r().int(),kind:u(),url:u(),sizeBytes:r(),timestamp:r()}),WN={name:`face-gallery`,role:{feature:`face-assignment`},scope:`system`,mode:`singleton`,methods:{listIdentities:E(b({includeCrops:v().optional()}).optional(),S(HN).readonly(),{role:`viewer`}),createIdentity:E(b({name:u().min(1)}),HN,{kind:`mutation`,auth:`admin`}),renameIdentity:E(b({id:u(),name:u().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deleteIdentity:E(b({id:u()}),_(),{kind:`mutation`,auth:`admin`}),listIdentitySamples:E(b({identityId:u()}),S(Kbe).readonly()),auditIdentitySamples:E(b({identityId:u().min(1)}),Jbe,{auth:`admin`}),removeSample:E(b({identityId:u(),sampleId:u()}),_(),{kind:`mutation`,auth:`admin`}),moveIdentitySample:E(b({sampleId:u().min(1),toIdentityId:u().min(1)}),_(),{kind:`mutation`,auth:`admin`}),listRecentFaces:E(b({deviceId:r().int().optional(),deviceIds:S(r().int()).optional(),limit:r().int().positive().optional(),filter:Ybe.optional(),since:r().int().optional(),until:r().int().optional(),sortBy:Xbe.optional(),sortDirection:Zbe.optional(),includeCrops:v().optional()}).optional(),S(UN).readonly()),getFaceByTrack:E(b({deviceId:r().int(),trackId:u()}),UN.nullable(),{role:`viewer`}),getFaceMedia:E(b({faceId:u()}),S($be).readonly()),assignFace:E(b({faceId:u(),identityId:u()}),_(),{kind:`mutation`,auth:`admin`}),unassignFace:E(b({faceId:u()}),_(),{kind:`mutation`,auth:`admin`}),deleteFace:E(b({faceId:u()}),_(),{kind:`mutation`,auth:`admin`}),assignFaces:E(b({faceIds:S(u()).min(1),identityId:u()}),b({assigned:r().int(),failed:S(u()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignFaces:E(b({faceIds:S(u()).min(1)}),b({unassigned:r().int(),failed:S(u()).readonly()}),{kind:`mutation`,auth:`admin`}),suggestFaceClusters:E(b({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(),S(Qbe).readonly())},vocabulary:{notOperatorFacing:`the face gallery — curated on its own page`}},GN=b({reason:u(),count:r().int().nonnegative()}),KN=b({family:u(),deviceId:r().int().positive(),variant:u().optional(),sinceMs:r(),atMs:r(),attempts:r().int().nonnegative(),succeeded:r().int().nonnegative(),reasons:S(GN).readonly()}),qN={name:`failure-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:E(_(),S(KN).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},JN=x([`forward`,`reverse`]),YN=[`horizontal`,`vertical`],XN=x(YN),ZN=[`oscillating`,`angle`,`sweepFrom`,`sweepTo`],QN=x(ZN),$N=[`min`,`max`,`step`],eP=b({oscillating:v().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)}),tP=b({horizontal:eP.nullable().default(null),vertical:eP.nullable().default(null)}),nP=[`nothing-to-set`,`axis-not-linked`,`out-of-range`,`source-gone`,`source-unknown`,`source-call-failed`],rP=x(nP),iP=a(`status`,[b({status:m(`applied`)}),b({status:m(`refused`),reason:rP,field:QN.optional(),detail:u(),applied:S(QN)})]),aP=b({deviceId:r().int().nonnegative(),axis:XN,oscillating:v().optional(),angle:r().optional(),sweepFrom:r().optional(),sweepTo:r().optional()});function oP(e,t){return`oscillationAxes.${e}.${t}`}var sP=b({speed:r().min(0).max(100).nullable().meta(k(`percentage`)),percentageStep:r().positive().optional().meta(k(`percentage`)),preset:u(),availablePresets:S(u()),direction:JN.nullable(),oscillating:v().nullable(),oscillationAxes:tP.optional(),lastChangedAt:r()});function exe(e){let t=e.oscillationAxes;if(t===void 0)return e.oscillating;let n=YN.flatMap(e=>{let n=t[e]?.oscillating;return n==null?[]:[n]});return n.length===0?e.oscillating:n.some(Boolean)}var cP=[j.Fan],lP=`oscillation-axes`;function txe(e){return{id:`${e}-oscillating`,cardinality:`scalar`,vocabulary:{cap:`fan-control`,stateField:`oscillating`},deviceTypes:cP,apply:`replace`,section:lP,path:oP(e,`oscillating`),sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}function uP(e,t){let n={id:`${e}-${t}`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:cP,apply:`replace`,section:lP,path:oP(e,t),sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}};return t===`angle`?{...n,companions:$N.map(t=>({kind:`source-field`,path:oP(e,t),field:t}))}:n}var nxe=YN.flatMap(e=>[txe(e),uP(e,`angle`),uP(e,`sweepFrom`),uP(e,`sweepTo`)]),rxe={id:`preset`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:cP,apply:`replace`,path:`preset`,sources:[{kind:`field`,valueKinds:[`string`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}},dP=[...nxe,rxe],ixe={version:1,overridable:dP.map(e=>({path:e.path,by:e.id})),targets:dP},fP={name:`fan-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Fan],methods:{setPercentage:D(b({deviceId:r().int().nonnegative(),speed:r().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.off`,label:I(`Fan off`,`Ventilatore spento`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`power-off`,effect:{field:`speed`,value:0},args:{speed:0}},{id:`fan.full`,label:I(`Fan full`,`Ventilatore al massimo`),phrase:I(`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:I(`Set speed`,`Imposta la velocità`),phrase:I(`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:I(`Speed`,`Velocità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setPreset:D(b({deviceId:r().int().nonnegative(),preset:u().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.preset`,label:I(`Set preset`,`Imposta il preset`),phrase:I(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setDirection:D(b({deviceId:r().int().nonnegative(),direction:JN}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.forward`,label:I(`Spin forward`,`Rotazione avanti`),phrase:I(`Spin {device} forward`,`Fai girare {device} in avanti`),icon:`refresh-cw`,effect:{field:`direction`,value:`forward`},args:{direction:`forward`}},{id:`fan.reverse`,label:I(`Spin in reverse`,`Rotazione inversa`),phrase:I(`Spin {device} in reverse`,`Fai girare {device} al contrario`),icon:`rotate-ccw`,effect:{field:`direction`,value:`reverse`},args:{direction:`reverse`}}]}),setOscillating:D(b({deviceId:r().int().nonnegative(),oscillating:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.oscillateOn`,label:I(`Oscillate`,`Oscillazione attiva`),phrase:I(`Make {device} oscillate`,`Fai oscillare {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!0},args:{oscillating:!0}},{id:`fan.oscillateOff`,label:I(`Stop oscillating`,`Oscillazione spenta`),phrase:I(`Stop {device} oscillating`,`Ferma l’oscillazione di {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!1},args:{oscillating:!1}}]}),setOscillationAxis:D(aP,iP,{kind:`mutation`,auth:`protected`,actions:[{id:`fan.horizontalOscillateOn`,label:I(`Horizontal oscillation on`,`Oscillazione orizzontale attiva`),phrase:I(`Start the horizontal oscillation of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!0}},{id:`fan.horizontalOscillateOff`,label:I(`Horizontal oscillation off`,`Oscillazione orizzontale spenta`),phrase:I(`Stop the horizontal oscillation of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!1}},{id:`fan.verticalOscillateOn`,label:I(`Vertical oscillation on`,`Oscillazione verticale attiva`),phrase:I(`Start the vertical oscillation of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!0}},{id:`fan.verticalOscillateOff`,label:I(`Vertical oscillation off`,`Oscillazione verticale spenta`),phrase:I(`Stop the vertical oscillation of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!1}}]})},status:{schema:sP,kind:`push`},runtimeState:sP,customize:ixe,durability:`session`,history:{fields:{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}}},vocabulary:{noun:I(`Fan`,`Ventilatore`),order:1080,state:[{kind:`numeric`,field:`speed`,quantity:I(`the speed`,`la velocità`),label:I(`Speed`,`Velocità`),unit:`%`,icon:`fan`},{kind:`boolean`,field:`oscillating`,label:I(`Oscillating`,`Oscillazione`),whenTrue:I(`When {device} starts oscillating`,`Quando {device} inizia a oscillare`),whenFalse:I(`When {device} stops oscillating`,`Quando {device} smette di oscillare`),icon:`move-horizontal`}]}},pP=b({oscillating:v().optional(),angle:r().optional(),sweepFrom:r().optional(),sweepTo:r().optional()}),mP=b({speed:r().min(0).max(100).optional(),preset:u().min(1).optional(),direction:JN.optional(),oscillationAxes:b({horizontal:pP.optional(),vertical:pP.optional()}).optional()}),hP=b({id:u().min(1).max(64),name:u().trim().min(1).max(40),state:mP}),gP=[`empty-state`,`duplicate-name`,`duplicate-id`,`too-many`,`not-a-fan`],_P=x(gP),vP=a(`status`,[b({status:m(`saved`),count:r().int().nonnegative()}),b({status:m(`refused`),reason:_P,detail:u()})]),yP=b({field:u(),outcome:x([`applied`,`failed`,`not-run`,`refused`]),message:u().optional()}),bP=b({status:x([`applied`,`partial`,`refused`]),fields:S(yP)}),xP=[`speed`,`direction`,`preset`,`oscillationAxes`],SP=x(xP),CP=b({what:u(),reason:u()}),wP=b({state:mP,omitted:S(CP)}),TP=b({deviceId:r().int().nonnegative()}),axe={version:1,targets:[{id:`presets`,cardinality:`config`,vocabulary:{cap:`fan-presets`},deviceTypes:[j.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`}]},EP={name:`fan-presets`,scope:`system`,mode:`singleton`,methods:{getPresets:E(TP,S(hP),{auth:`protected`}),setPresets:E(TP.extend({presets:S(hP).max(12)}),vP,{kind:`mutation`,auth:`admin`}),applyPreset:E(TP.extend({presetId:u().min(1)}),bP,{kind:`mutation`,auth:`protected`}),capturePreset:E(TP.extend({fields:S(SP).optional()}),wP,{auth:`protected`})},customize:axe,vocabulary:{notOperatorFacing:`the per-fan presets — authored in the Customize presets editor, applied through the actions the exports list`}},DP=b({flags:h(u(),C()),deviceType:u().nullable(),model:u().nullable(),channelCount:r().nullable().meta(k(`count`)),lastProbedAt:r(),lastFetchedAt:r()}),OP={name:`feature-probe`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onProbeChanged:{data:b({deviceId:r(),status:DP}),notOperatorFacing:`the device’s capabilities were re-probed — plumbing, not a happening`}},status:{schema:DP,kind:`push`},runtimeState:DP,durability:`session`,history:`none`,vocabulary:{noun:I(`Feature probe`,`Rilevamento funzioni`),order:3120}},oxe=b({name:u(),path:u()}),sxe=b({path:u(),entries:S(oxe).readonly(),freeBytes:r(),totalBytes:r()}),kP={name:`filesystem-browse`,scope:`system`,mode:`singleton`,internal:!0,methods:{listAllowedRoots:E(_(),S(u()).readonly(),{auth:`admin`}),browse:E(b({path:u()}),sxe,{auth:`admin`}),createDir:E(b({path:u()}),b({path:u()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},AP=b({flooded:v(),lastChangedAt:r()}),jP={name:`flood`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:AP,kind:`push`},runtimeState:AP,durability:`restored`,history:{fields:{flooded:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Leak sensor`,`Sensore di allagamento`),order:5070,state:[{kind:`boolean`,field:`flooded`,label:I(`Leak`,`Perdita`),whenTrue:I(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:I(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}]}},MP=b({detected:v(),lastChangedAt:r()}),NP={name:`gas`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:MP,kind:`push`},runtimeState:MP,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Gas sensor`,`Sensore di gas`),order:5080,state:[{kind:`boolean`,field:`detected`,label:I(`Detected`,`Rilevato`),whenTrue:I(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:I(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}]}},PP=b({active:v().meta({label:`Active`}),lastChangedAt:r()}),FP={name:`group-active`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Cover,j.Valve,j.Lock,j.MediaPlayer,j.Climate],methods:{},status:{schema:PP,kind:`push`},runtimeState:PP,durability:`session`,history:`none`,vocabulary:{noun:I(`Group state`,`Stato del gruppo`),order:5090}},IP=b({deviceId:r().int().nonnegative(),cap:u().min(1),method:u().min(1),ok:v(),error:u().optional(),at:r()}),LP=b({results:S(IP)}),RP={name:`group-commands`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Switch,j.Light,j.Fan,j.Cover,j.Valve,j.Lock,j.MediaPlayer,j.Climate],methods:{},status:{schema:LP,kind:`push`},runtimeState:LP,durability:`session`,history:`none`,vocabulary:{noun:I(`Group command`,`Comando di gruppo`),order:5100}},zP=b({included:r().int().nonnegative().meta(k(`count`,{precision:0,label:`Reporting`})),excluded:r().int().nonnegative().meta(k(`count`,{precision:0,label:`Excluded`})),total:r().int().nonnegative().meta(k(`count`,{precision:0,label:`Members`}))}),BP={name:`group-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor,j.Switch,j.Light,j.Fan,j.Cover,j.Valve,j.Lock,j.MediaPlayer,j.Climate],methods:{},status:{schema:zP,kind:`push`},runtimeState:zP,durability:`session`,history:`none`,vocabulary:{noun:I(`Group`,`Gruppo`),order:5110,state:[{kind:`numeric`,field:`included`,quantity:I(`the members reporting`,`i membri che rispondono`),label:I(`Reporting`,`Rispondono`),icon:`users`},{kind:`numeric`,field:`excluded`,quantity:I(`the members left out`,`i membri esclusi`),label:I(`Excluded`,`Esclusi`),icon:`users`},{kind:`numeric`,field:`total`,quantity:I(`the member count`,`il numero di membri`),label:I(`Members`,`Membri`),icon:`sigma`}]}},VP=r().int().nonnegative(),HP=u().min(1),UP=u().min(1),WP=r().finite(),GP={key:`circuitId`,label:I(`Circuit`,`Circuito`),offer:{kind:`dynamic`,from:`status`,cap:`heat-pump-status`,field:`circuits`,valueKey:`id`,labelKey:`label`,where:{key:`kind`,equals:`heating`}}},KP={...GP,label:I(`Hot water circuit`,`Circuito acqua calda`),offer:{...GP.offer,where:{key:`kind`,equals:`dhw`}}},qP={key:`mode`,label:I(`Mode`,`Modalità`),offer:{kind:`text`}},cxe={key:`level`,label:I(`Level`,`Livello`),offer:{kind:`text`}},JP={key:`temp`,label:I(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}},lxe={key:`minutes`,label:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}},YP={name:`heat-pump-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.HeatPump],methods:{setSilentMode:E(b({deviceId:VP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.silent`,label:I(`Set silent mode`,`Imposta la modalità silenziosa`),phrase:I(`Set silent mode of {device} to {mode}`,`Imposta la modalità silenziosa di {device} su {mode}`),icon:`volume-x`,openArgs:[{key:`mode`,label:I(`Silent mode`,`Modalità silenziosa`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`auto`,label:I(`Auto`,`Auto`)},{value:`on`,label:I(`On`,`On`)}]}}]}]}),setAwayMode:E(b({deviceId:VP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.away`,label:I(`Set away mode`,`Imposta la modalità assente`),phrase:I(`Set away mode of {device} to {mode}`,`Imposta la modalità assente di {device} su {mode}`),icon:`plane`,openArgs:[{key:`mode`,label:I(`Away mode`,`Modalità assente`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`on`,label:I(`On`,`On`)}]}}]}]}),setAdditionalHeaterMode:E(b({deviceId:VP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.additionalHeater`,label:I(`Set additional heater`,`Imposta il riscaldatore aggiuntivo`),phrase:I(`Set the additional heater of {device} to {mode}`,`Imposta il riscaldatore aggiuntivo di {device} su {mode}`),icon:`flame`,openArgs:[{key:`mode`,label:I(`Additional heater`,`Riscaldatore aggiuntivo`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`manual`,label:I(`Manual`,`Manuale`)},{value:`auto`,label:I(`Auto`,`Auto`)}]}}]}]}),setHolidayMode:E(b({deviceId:VP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.holiday`,label:I(`Set holiday mode`,`Imposta la modalità vacanza`),phrase:I(`Set holiday mode of {device} to {mode}`,`Imposta la modalità vacanza di {device} su {mode}`),icon:`tree-palm`,openArgs:[{key:`mode`,label:I(`Holiday programme`,`Programma vacanza`),offer:{kind:`enum`,values:[{value:`off`,label:I(`Off`,`Off`)},{value:`hm1`,label:I(`Programme 1`,`Programma 1`)},{value:`hm2`,label:I(`Programme 2`,`Programma 2`)},{value:`hm3`,label:I(`Programme 3`,`Programma 3`)},{value:`hm4`,label:I(`Programme 4`,`Programma 4`)},{value:`hm5`,label:I(`Programme 5`,`Programma 5`)},{value:`hm6`,label:I(`Programme 6`,`Programma 6`)},{value:`hm7`,label:I(`Programme 7`,`Programma 7`)},{value:`hm8`,label:I(`Programme 8`,`Programma 8`)}]}}]}]}),setCircuitOperationMode:E(b({deviceId:VP,circuitId:HP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitOperationMode`,label:I(`Set circuit operation mode`,`Imposta la modalità del circuito`),phrase:I(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`thermometer`,openArgs:[GP,qP]}]}),setCircuitHeatCoolMode:E(b({deviceId:VP,circuitId:HP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitHeatCoolMode`,label:I(`Set circuit heat / cool`,`Imposta caldo / freddo del circuito`),phrase:I(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun-snow`,openArgs:[GP,qP]}]}),setCircuitSummerWinter:E(b({deviceId:VP,circuitId:HP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitSummerWinter`,label:I(`Set circuit summer / winter`,`Imposta estate / inverno del circuito`),phrase:I(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun`,openArgs:[GP,qP]}]}),setCircuitComfortSetpoint:E(b({deviceId:VP,circuitId:HP,temp:WP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitComfortSetpoint`,label:I(`Set comfort temperature`,`Imposta la temperatura comfort`),phrase:I(`Set the comfort temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura comfort di {circuitId} su {device} a {temp}`),icon:`thermometer-sun`,openArgs:[GP,JP]}]}),setCircuitEcoSetpoint:E(b({deviceId:VP,circuitId:HP,temp:WP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitEcoSetpoint`,label:I(`Set eco temperature`,`Imposta la temperatura eco`),phrase:I(`Set the eco temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura eco di {circuitId} su {device} a {temp}`),icon:`leaf`,openArgs:[GP,JP]}]}),setCircuitMaxFlowTemp:E(b({deviceId:VP,circuitId:HP,temp:WP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitMaxFlowTemp`,label:I(`Set maximum flow temperature`,`Imposta la temperatura massima di mandata`),phrase:I(`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:[GP,JP]}]}),setDhwOperationMode:E(b({deviceId:VP,circuitId:HP,mode:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwOperationMode`,label:I(`Set hot water mode`,`Imposta la modalità acqua calda`),phrase:I(`Set hot water {circuitId} of {device} to {mode}`,`Imposta l'acqua calda {circuitId} di {device} su {mode}`),icon:`shower-head`,openArgs:[KP,qP]}]}),setDhwTemperatureLevel:E(b({deviceId:VP,circuitId:HP,level:UP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwTemperatureLevel`,label:I(`Set hot water level`,`Imposta il livello acqua calda`),phrase:I(`Set hot water {circuitId} of {device} to level {level}`,`Imposta l'acqua calda {circuitId} di {device} al livello {level}`),icon:`droplet`,openArgs:[KP,cxe]}]}),setDhwChargeDuration:E(b({deviceId:VP,circuitId:HP,minutes:r().int().positive()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwChargeDuration`,label:I(`Set hot water charge duration`,`Imposta la durata della carica acqua calda`),phrase:I(`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:[KP,lxe]}]}),startExtraHotWater:E(b({deviceId:VP,circuitId:HP}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.extraHotWater`,label:I(`Start extra hot water`,`Avvia acqua calda extra`),phrase:I(`Start an extra hot water charge of {circuitId} on {device}`,`Avvia una carica extra di acqua calda {circuitId} su {device}`),icon:`droplets`,openArgs:[KP]}]})},vocabulary:{noun:I(`Heat pump settings`,`Impostazioni pompa di calore`),order:4010}},XP=[`heating`,`dhw`,`cooling`,`solar`],ZP=x(XP),QP=b({value:u().nullable(),allowed:S(u())}),$P=b({value:r().nullable(),min:r().nullable(),max:r().nullable(),step:r().nullable()}),eF=b({id:u().min(1),kind:ZP,label:u(),icon:Bu,currentTemp:r().nullable().meta(k(`temperature`)),targetTemp:r().nullable().meta(k(`temperature`)),mode:u().nullable(),active:v().nullable(),operationMode:QP.nullable(),heatCoolMode:QP.nullable(),summerWinter:QP.nullable(),comfortSetpoint:$P.nullable(),ecoSetpoint:$P.nullable(),maxFlowTemp:$P.nullable(),temperatureLevel:QP.nullable(),chargeDuration:$P.nullable(),extraHotWater:v().nullable()}),tF=b({silent:QP.nullable(),away:QP.nullable(),additionalHeater:QP.nullable(),holiday:QP.nullable()}),nF=b({thermalW:r().nullable().meta(k(`power`)),electricalW:r().nullable().meta(k(`power`)),compressorPct:r().nullable().meta(k(`percentage`))}),rF=b({supply:r().nullable().meta(k(`temperature`)),return:r().nullable().meta(k(`temperature`)),outdoor:r().nullable().meta(k(`temperature`))}),iF=b({thermalKwh:r().nullable().meta(k(`energy`)),electricalKwh:r().nullable().meta(k(`energy`))}),aF=b({circuits:S(eF),system:tF,power:nF,temperatures:rF,energy:iF,waterPressureBar:r().nullable(),starts:r().nullable(),lastFetchedAt:r()});function oF(e){let{thermalW:t,electricalW:n}=e;return t===null||n===null||n<=0?null:t/n}var sF={name:`heat-pump-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.HeatPump],methods:{},status:{schema:aF,kind:`push`},runtimeState:aF,durability:`session`,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:I(`Heat pump`,`Pompa di calore`),order:4e3}},cF=b({position:r().min(0).max(100).nullable().meta(k(`percentage`)),lastFetchedAt:r()}),lF={name:`heating-valve`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Climate],methods:{},status:{schema:cF,kind:`push`},runtimeState:cF,durability:`session`,history:{fields:{position:{kind:`gauge`,unit:`%`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Radiator valve`,`Valvola termostatica`),order:1110,state:[{kind:`numeric`,field:`position`,quantity:I(`the valve opening`,`l’apertura della valvola`),label:I(`Valve opening`,`Apertura della valvola`),unit:`%`,icon:`heater`}]}},uF=x([`s`,`min`]),uxe=x([`switch`,`pet-fountain`]),dF={actuator:`switch`,maxSeconds:10800,unit:`min`,quickRunDefault:30},fF={actuator:`pet-fountain`,maxSeconds:300,unit:`s`,quickRunDefault:60},pF=[j.Switch,j.PetFountain],mF={[j.Switch]:[N.SwitchHeater]};function hF(e,t){return e===j.PetFountain?fF:e===j.Switch&&t===N.SwitchHeater?dF:null}var dxe=1e3,fxe=6e4;function gF(e,t,n){let r=e-t;return r<=0?0:Math.max(1,Math.ceil(r/(n===`min`?fxe:dxe)))}function pxe(e,t){return t===`min`?e*60:e}function _F(e){return e.unit===`min`?Math.floor(e.maxSeconds/60):e.maxSeconds}var vF=b({duration:r().positive().finite(),unit:uF});function yF(e,t){let n=_F(e);return{duration:Math.min((t!==null&&Number.isFinite(t)&&t>0?t:null)??e.quickRunDefault,n),unit:e.unit}}var bF=x([`unsupported-device`,`over-max`,`command-failed`]),xF=a(`ok`,[b({ok:m(!0),activeUntil:r()}),b({ok:m(!1),reason:bF,maxSeconds:r().nullable()})]),SF=b({activeUntil:r().nullable(),requestedBy:u().nullable(),quickRun:vF.nullable(),lastFetchedAt:r()}),CF=b({unit:uF,maxDuration:r(),defaultDuration:r()}),wF=b({quickRunDuration:r().positive().finite().nullable().optional()}),TF={name:`timed-run`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:pF,deviceRoles:mF,deviceConfig:{ui:{kind:`derived-form`,builderId:`timed-run`,tab:`general`}},methods:{getOptions:E(b({deviceId:r().int()}),CF),setSettings:E(b({deviceId:r().int(),settings:wF}),_(),{kind:`mutation`,auth:`admin`}),runFor:E(b({deviceId:r().int(),duration:r().positive().finite(),unit:uF}),xF,{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.runForMinutes`,label:I(`Run for minutes`,`Accendi per alcuni minuti`),phrase:I(`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:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}}]},{id:`timedRun.runForSeconds`,label:I(`Run for seconds`,`Accendi per alcuni secondi`),phrase:I(`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:I(`Seconds`,`Secondi`),offer:{kind:`number`,min:1,step:1,unit:`s`}}]}]}),cancel:E(b({deviceId:r().int()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.cancel`,label:I(`Cancel the timer`,`Annulla il timer`),phrase:I(`Cancel the pending switch-off of {device}`,`Annulla lo spegnimento programmato di {device}`),icon:`timer-off`}]})},status:{schema:SF,kind:`push`},runtimeState:SF,durability:`session`,history:`none`,vocabulary:{noun:I(`Timed run`,`Esecuzione a tempo`),order:2150}},EF=[`on`,`off`,`running`,`idle`,`standby`,`alert`,`offline`,`unknown`],DF=[`success`,`warning`,`danger`,`primary`,`info`,`muted`],OF=[`none`,`pulse`,`spin`,`glow`,`halo`,`wave`,`rise`,`fall`,`tumble`,`equalizer`,`blink`,`breathe`],kF=[`plain`,`heat-rise`,`cool-fall`,`glow`,`water`,`drum`,`sky`,`mist`,`alert-wash`],AF=x(EF),jF=x(DF),mxe=x(OF),MF=b({icon:Bu,tone:jF,background:x(kF),animation:mxe});function NF(e){let t=hE[e];return t===void 0?null:`cap:${e}.${t.field}`}function PF(e){return e.enabledCaps.flatMap(e=>{let t=NF(e),n=hE[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 FF=b({en:u(),it:u()}),IF={en:`—`,it:`—`};function LF(e){return e.en===IF.en&&e.it===IF.it}var RF=[`temperature`,`humidity`,`power`,`contact`,`text`],zF=[`hot`,`mild`,`cold`],BF=[`updated`,`changed`],VF=b({value:r(),quantity:Zs}),HF=b({quantity:x(RF),reading:VF.nullable(),icon:Bu.nullable(),value:FF,unit:u().nullable(),band:x(zF).nullable(),level:r().min(0).max(1).nullable(),word:FF,tone:x(DF),since:r().nullable(),sinceKind:x(BF),historyKey:u().nullable()}),hxe=3e3,UF=e=>I(e,e),WF=e=>Math.min(1,Math.max(0,e)),gxe=(e,t)=>String(Number(e.toFixed(t)));function GF(e){return e<12?`cold`:e>28?`hot`:`mild`}var _xe={hot:I(`Hot`,`Caldo`),mild:I(`Normal`,`Normale`),cold:I(`Cold`,`Freddo`)},vxe={hot:`warning`,mild:`muted`,cold:`info`};function KF(e,t){let n=GF(e);return{quantity:`temperature`,reading:{value:e,quantity:`temperature`},icon:`thermometer`,value:UF(gxe(e,1)),unit:`°C`,band:n,level:null,word:_xe[n],tone:vxe[n],since:t,sinceKind:`updated`,historyKey:NF(`temperature-sensor`)}}function qF(e,t){let n=e<30,r=e>70;return{quantity:`humidity`,reading:{value:e,quantity:`humidity`},icon:`droplets`,value:UF(String(Math.round(e))),unit:`%`,band:null,level:WF(e/100),word:n?I(`Dry`,`Secco`):r?I(`Humid`,`Umido`):I(`Normal`,`Normale`),tone:n||r?`warning`:`info`,since:t,sinceKind:`updated`,historyKey:NF(`humidity-sensor`)}}function JF(e,t){let n=e>0;return{quantity:`power`,reading:{value:e,quantity:`power`},icon:`zap`,value:UF(String(Math.round(e))),unit:`W`,band:null,level:WF(e/hxe),word:n?I(`Active`,`Attivo`):I(`Idle`,`Inattivo`),tone:n?`primary`:`muted`,since:t,sinceKind:`updated`,historyKey:NF(`power-meter`)}}function YF(e,t){return{quantity:`contact`,reading:null,icon:e?`door-open`:`door-closed`,value:e?I(`Open`,`Aperto`):I(`Closed`,`Chiuso`),unit:null,band:null,level:+!!e,word:e?I(`Open`,`Aperto`):I(`Closed`,`Chiuso`),tone:e?`warning`:`success`,since:t,sinceKind:`changed`,historyKey:null}}function XF(e,t){return{quantity:`text`,reading:null,icon:null,value:UF(e),unit:null,band:null,level:null,word:I(`Changed`,`Cambiato`),tone:`muted`,since:t,sinceKind:`updated`,historyKey:null}}var yxe={temperature:{icon:`thermometer`,unit:`°C`,sinceKind:`updated`,historyKey:NF(`temperature-sensor`)},humidity:{icon:`droplets`,unit:`%`,sinceKind:`updated`,historyKey:NF(`humidity-sensor`)},power:{icon:`zap`,unit:`W`,sinceKind:`updated`,historyKey:NF(`power-meter`)},contact:{icon:null,unit:null,sinceKind:`changed`,historyKey:null},text:{icon:null,unit:null,sinceKind:`updated`,historyKey:null}};function ZF(e){let t=yxe[e];return{quantity:e,reading:null,icon:t.icon,value:IF,unit:t.unit,band:null,level:null,word:IF,tone:`muted`,since:null,sinceKind:t.sinceKind,historyKey:t.historyKey}}var bxe={power:new Set([`energy-sensor`,`voltage-sensor`,`current-sensor`])};function QF(e,t){return t===null?!0:!(bxe[e.quantity]?.has(t)??!1)}var $F=`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(`.`),xxe=x($F),eI=[`cool`,`heat`,`dry`,`fan`,`auto`,`playing`,`paused`,`open`,`closed`],tI=b({id:xxe,mode:x(eI).nullable(),level:r().min(0).max(1).nullable()}),nI={[j.Camera]:`camera`,[j.Light]:`light`,[j.Siren]:`siren`,[j.Switch]:`plug`,[j.Sensor]:`sensor-sparkline`,[j.Climate]:`thermostat`,[j.Button]:`button`,[j.EventEmitter]:`event-stream`,[j.Update]:`update`,[j.Generic]:`generic`,[j.Notifier]:`event-stream`,[j.Script]:`event-stream`,[j.Automation]:`event-stream`,[j.Lock]:`lock`,[j.Cover]:`cover`,[j.Valve]:`control-dial`,[j.Humidifier]:`control-dial`,[j.WaterHeater]:`heater`,[j.HeatPump]:`heat-pump`,[j.EnergySystem]:`generic`,[j.Workload]:`generic`,[j.Fan]:`fan`,[j.MediaPlayer]:`tv`,[j.AlarmPanel]:`alarm`,[j.Control]:`control-dial`,[j.Presence]:`presence`,[j.Weather]:`weather`,[j.WeatherStation]:`weather`,[j.Vacuum]:`vacuum`,[j.LawnMower]:`lawn-mower`,[j.Container]:`generic`,[j.Image]:`camera`,[j.PetFeeder]:`pet-feeder`,[j.PetFountain]:`pet-fountain`,[j.Dishwasher]:`dishwasher`,[j.Washer]:`washer`,[j.Dryer]:`dryer`,[j.Gateway]:`gateway`},rI={[N.Siren]:`siren`,[N.Floodlight]:`light`,[N.Spotlight]:`light`,[N.PirSensor]:`presence`,[N.Chime]:`speaker`,[N.Autotrack]:`inherit`,[N.Nightvision]:`inherit`,[N.PrivacyMask]:`inherit`,[N.Doorbell]:`inherit`,[N.CoverBlind]:`inherit`,[N.CoverShutter]:`inherit`,[N.CoverAwning]:`inherit`,[N.CoverCurtain]:`inherit`,[N.CoverGarage]:`inherit`,[N.CoverGate]:`inherit`,[N.CoverDoor]:`inherit`,[N.CoverWindow]:`inherit`,[N.BinaryHelper]:`inherit`,[N.Outlet]:`plug`,[N.SwitchHeater]:`heater`,[N.SwitchFan]:`fan`,[N.SwitchLight]:`light`,[N.PoePort]:`plug`,[N.ClimateAc]:`ac`,[N.ClimateThermostat]:`inherit`,[N.ClimateFloor]:`inherit`,[N.ClimateRadiator]:`inherit`,[N.ClimateHeater]:`inherit`,[N.ClimateHeatPumpCircuit]:`inherit`,[N.MotionSensor]:`presence`,[N.ContactSensor]:`contact`,[N.LeakSensor]:`inherit`,[N.SmokeSensor]:`alarm`,[N.COSensor]:`alarm`,[N.GasSensor]:`alarm`,[N.TamperSensor]:`inherit`,[N.VibrationSensor]:`inherit`,[N.ConnectivitySensor]:`inherit`,[N.SoundSensor]:`inherit`,[N.BinarySensor]:`inherit`,[N.TemperatureSensor]:`sensor-sparkline`,[N.HumiditySensor]:`sensor-sparkline`,[N.AmbientLightSensor]:`inherit`,[N.PressureSensor]:`weather`,[N.WindSensor]:`weather`,[N.RainSensor]:`weather`,[N.UvSensor]:`weather`,[N.SolarRadiationSensor]:`weather`,[N.SoilMoistureSensor]:`inherit`,[N.PowerSensor]:`plug`,[N.EnergySensor]:`plug`,[N.VoltageSensor]:`plug`,[N.CurrentSensor]:`plug`,[N.AirQualitySensor]:`inherit`,[N.BatterySensor]:`inherit`,[N.NumericSensor]:`inherit`,[N.EnumSensor]:`inherit`,[N.DateTimeSensor]:`inherit`,[N.GenericSensor]:`inherit`,[N.NumericControl]:`control-dial`,[N.SelectControl]:`control-dial`,[N.TextControl]:`inherit`,[N.DateTimeControl]:`inherit`,[N.MobilePushNotifier]:`inherit`,[N.MessagingNotifier]:`inherit`,[N.EmailNotifier]:`inherit`,[N.GenericNotifier]:`inherit`,[N.IrTransmitter]:`inherit`,[N.Vm]:`inherit`,[N.AppContainer]:`inherit`,[N.Lxc]:`inherit`,[N.App]:`inherit`,[N.Host]:`inherit`,[N.Ups]:`inherit`};function Sxe(e){return Object.values(j).includes(e)}function Cxe(e){return Object.values(N).includes(e)}function iI(e,t){let n=e!==null&&Cxe(e)?rI[e]:void 0;return n!==void 0&&n!==`inherit`?n:Sxe(t)?nI[t]:`generic`}var aI=`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(`.`),oI=x(aI),sI={progress:I(`Progress`,`Avanzamento`),"run-for":I(`Run for`,`Avvia per`),cycle:I(`Cycle`,`Ciclo`),program:I(`Program`,`Programma`),"appliance-power":I(`Appliance`,`Elettrodomestico`),"now-playing":I(`Now playing`,`In riproduzione`),playback:I(`Playback`,`Riproduzione`),volume:I(`Volume`,`Volume`),source:I(`Source`,`Sorgente`),contact:I(`Door`,`Porta`),"motion-trigger":I(`Motion`,`Movimento`),lock:I(`Lock`,`Serratura`),alarm:I(`Alarm`,`Allarme`),fan:I(`Fan`,`Ventola`),vacuum:I(`Cleaning`,`Pulizia`),"vacuum-suction":I(`Suction`,`Aspirazione`),mower:I(`Mowing`,`Taglio`),feeder:I(`Feed now`,`Eroga ora`),fountain:I(`Pump`,`Pompa`),"pump-cycle":I(`Pump cycle`,`Ciclo pompa`),automation:I(`Automation`,`Automazione`),script:I(`Script`,`Script`),"do-not-disturb":I(`Do not disturb`,`Non disturbare`),brightness:I(`Brightness`,`Luminosità`),color:I(`Colour`,`Colore`),cover:I(`Position`,`Posizione`),valve:I(`Valve`,`Valvola`),humidifier:I(`Humidifier`,`Umidificatore`),update:I(`Firmware`,`Firmware`),button:I(`Action`,`Azione`),"climate-mode":I(`Mode`,`Modalità`),"climate-fan":I(`Fan`,`Ventola`),setpoint:I(`Setpoint`,`Temperatura`),channel:I(`Channel`,`Canale`),control:I(`Control`,`Controllo`),circuit:I(`Circuit`,`Circuito`),"heat-pump-power":I(`Power`,`Potenza`),"system-mode":I(`Mode`,`Modalità`)},cI=o(()=>g([u(),r(),v(),h(u(),cI)])),wxe=h(u(),cI);function lI(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]:lI(o,i,n)}}function uI(e,t,n){return lI(e,t.split(`.`),n)}var dI=b({cap:u(),method:u(),args:wxe}),Txe=x([`off-while-running`,`unlock`,`install`,`press`]),fI=b({id:u(),label:FF,icon:Bu,call:dI,emphasis:x([`primary`,`normal`]),confirm:Txe.nullable()}),pI=a(`kind`,[b({kind:m(`action`),action:fI}),b({kind:m(`toggle`),id:u(),label:FF,on:v().nullable(),turnOn:fI,turnOff:fI}),b({kind:m(`slider`),id:u(),label:FF,value:r().nullable(),min:r(),max:r(),step:r(),unit:u(),call:dI,valueArg:u()}),b({kind:m(`picker`),id:u(),label:FF,current:u().nullable(),options:S(u()),optionLabels:h(u(),FF).optional(),call:dI,valueArg:u()}),b({kind:m(`number`),id:u(),label:FF,value:r().nullable(),step:r().nullable(),unit:u(),call:dI,valueArg:u()}),b({kind:m(`text`),id:u(),label:FF,value:u().nullable(),call:dI,valueArg:u()})]),Exe=b({icon:Bu.nullable(),text:FF,tone:jF}),Dxe=new Set([`cover`,`valve`,`lock`,`vacuum`,`playback`,`brightness`]),Oxe=b({id:oI,placement:x([`row`,`scene`]).optional(),label:FF.optional(),group:FF.optional(),pills:S(Exe).optional(),icon:Bu,status:FF.nullable(),controls:S(pI),progress:r().min(0).max(1).nullable().optional()}),mI=b({label:FF,value:g([r(),u()]),unit:u().nullable()}),kxe=b({id:x([`battery`,`network-link`,`integration`]),icon:Bu,tone:jF,value:r().nullable(),label:FF}),hI=`remote.open`,Axe=b({commands:r().int().nullable(),open:fI.optional()}),jxe=b({items:S(b({key:u(),label:u(),level:r().nullable(),needsAttention:v()})),attention:r().int()}),Mxe=a(`kind`,[b({kind:m(`power`),watts:r(),detail:S(mI)}),b({kind:m(`running`),running:v().nullable(),since:r().nullable(),phase:u().nullable(),detail:S(mI)})]),Nxe=b({source:x([`switch`,`media-player`,`climate-control`]),on:v().nullable(),assumed:v(),turnOn:fI,turnOff:fI}),Pxe=b({activeUntil:r().nullable(),quickRun:vF,run:fI,cancel:fI,remaining:r().nullable()}),Fxe=b({on:v().nullable(),confirmOffWhileRunning:v(),running:v().nullable(),powerOn:fI.nullable(),powerOff:fI.nullable(),restart:fI}),gI=b({token:x(kF),animation:x(OF)}),_I=b({id:x([`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:Bu.nullable(),text:FF,tone:jF}),vI=b({label:FF,value:FF,tone:jF.optional(),at:r().optional()}),Ixe=b({left:S(vI).max(2),right:S(vI).max(2)}),Lxe=a(`kind`,[b({kind:m(`artwork`),url:u(),fallback:gI}),b({kind:m(`state`),...gI.shape})]),Rxe=b({partId:u(),cap:u()}),zxe=b({deviceId:r().int(),type:u(),role:u().nullable(),name:u(),state:AF,stateAssumed:v(),look:MF,background:Lxe,scene:tI,facts:S(_I),sideTiles:Ixe,title:FF,caption:FF.optional(),badges:S(kxe),remote:Axe.nullable(),historyLabel:FF,consumables:jxe.nullable(),consumption:Mxe.nullable(),ownPower:Nxe.nullable(),timedRun:Pxe.nullable(),powerSupply:Fxe.nullable(),rows:S(Oxe),measurement:HF.optional(),gated:S(u()),provenance:S(Rxe)}),Bxe=b({id:x([`timed-run.run`,`timed-run.cancel`]),duration:r(),unit:x([`min`,`s`])}),yI=b({deviceId:r().int(),name:u(),type:u(),state:AF,stateAssumed:v(),look:MF,scene:tI,statusLine:S(FF),primary:pI.nullable(),primaryGated:v().optional(),timedRun:Bxe.nullable(),extras:S(pI).max(2).optional(),trailing:_I.nullable(),measurement:HF.optional()}),bI=[`temperature`,`humidity`,`pressure`,`illuminance`,`reading`,`air-quality`,`valve`],Vxe=[`power`,`battery`,`consumables`],Hxe=new Set(bI);function Uxe(e){for(let t of Vxe){let n=e.facts.find(e=>e.id===t);if(n!==void 0)return n}return e.facts.find(t=>Hxe.has(t.id)&&t.text.en===e.title.en)??null}var Wxe={[j.Climate]:`climate.mode`};function Gxe(e){let t=Wxe[e.type];if(t!==void 0){let n=SI(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 Kxe={[j.Climate]:[`climate.target`],[j.Vacuum]:[`vacuum.base`],[j.LawnMower]:[`mower.dock`],[j.MediaPlayer]:[`volume.level`,hI],[j.Automation]:[`automation.enabled`]},xI=e=>e.kind===`action`?e.action.id:e.id;function SI(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=>xI(e)===t);if(r!==void 0)return r}return null}function qxe(e,t){let n=Kxe[e.type]??[],r=t===null?null:xI(t);return n.filter(e=>e!==r).flatMap(t=>{let n=SI(e,t);return n===null?[]:[n]}).slice(0,2)}function Jxe(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 Yxe(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 Xxe(e){let t=Uxe(e),{control:n,gated:r}=Gxe(e);return{deviceId:e.deviceId,name:e.name,type:e.type,state:e.state,stateAssumed:e.stateAssumed,look:e.look,scene:e.scene,statusLine:Jxe(e,t),primary:n,primaryGated:r,timedRun:Yxe(e),extras:qxe(e,n),trailing:t,...e.measurement===void 0?{}:{measurement:e.measurement}}}var Zxe=b({deviceId:r().int().nonnegative(),canActuate:v().optional()}),Qxe=b({deviceIds:S(r().int().nonnegative()).max(500),canActuate:v().optional()}),CI=b({type:u(),rows:S(oI)}),wI={name:`hero-layout`,scope:`system`,mode:`singleton`,methods:{getHeroModel:E(Zxe,zxe.nullable(),{auth:`protected`,role:`viewer`}),getRowModels:E(Qxe,S(yI.nullable()),{auth:`protected`,role:`viewer`}),getLayout:E(b({deviceType:u(),role:u().nullable().optional()}),CI,{auth:`protected`,role:`viewer`})},vocabulary:{notOperatorFacing:`the device hero model — read-only data the UI draws, never actuated`}},TI=b({on:v(),currentHumidity:r().min(0).max(100).nullable().meta(k(`humidity`)),targetHumidity:r().min(0).max(100).nullable().meta(k(`humidity`)),mode:u().nullable(),availableModes:S(u()),action:u().nullable(),minHumidity:r().nullable().meta(k(`humidity`)),maxHumidity:r().nullable().meta(k(`humidity`)),lastChangedAt:r()}),EI={name:`humidifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Humidifier],power:{kind:`field`,field:`on`,set:`setOn`},methods:{setOn:E(b({deviceId:r().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.on`,label:I(`Humidifier on`,`Umidificatore acceso`),phrase:I(`Turn on {device}`,`Accendi {device}`),icon:`power`,effect:{field:`on`,value:!0},args:{on:!0}},{id:`humidifier.off`,label:I(`Humidifier off`,`Umidificatore spento`),phrase:I(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`on`,value:!1},args:{on:!1}}]}),setTargetHumidity:E(b({deviceId:r().int().nonnegative(),humidity:r().min(0).max(100)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.target`,label:I(`Set humidity`,`Imposta l’umidità`),phrase:I(`Set {device} to {humidity} humidity`,`Imposta {device} al {humidity} di umidità`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`humidity`},openArgs:[{key:`humidity`,label:I(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMode:E(b({deviceId:r().int().nonnegative(),mode:u().min(1)}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.mode`,label:I(`Set mode`,`Imposta la modalità`),phrase:I(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`list`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:I(`Mode`,`Modalità`),offer:{kind:`dynamic`,from:`status`,field:`availableModes`}}]}]})},status:{schema:TI,kind:`push`},runtimeState:TI,durability:`session`,history:{fields:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}}},vocabulary:{noun:I(`Humidifier`,`Umidificatore`),order:1090,state:[{kind:`boolean`,field:`on`,label:I(`On`,`Acceso`),whenTrue:I(`When {device} turns on`,`Quando {device} si accende`),whenFalse:I(`When {device} turns off`,`Quando {device} si spegne`),icon:`power`},{kind:`numeric`,field:`currentHumidity`,quantity:I(`the humidity`,`l’umidità`),label:I(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},DI=b({humidity:r().min(0).max(100).nullable().meta(k(`humidity`,{precision:0,label:`Humidity`})),lastFetchedAt:r()}),OI={name:`humidity-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor,j.Climate],methods:{},status:{schema:DI,kind:`push`},runtimeState:DI,durability:`restored`,history:{primary:`humidity`,priority:90,fields:{humidity:{kind:`gauge`,unit:`%`,deadband:.5}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Humidity`,`Umidità`),order:5120,state:[{kind:`numeric`,field:`humidity`,quantity:I(`the humidity`,`l’umidità`),label:I(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},kI=b({url:u().nullable(),lastUpdated:r().nullable().meta(k(`none`))}),AI={name:`image`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Image],methods:{},status:{schema:kI,kind:`push`},runtimeState:kI,durability:`session`,history:`none`,vocabulary:{noun:I(`Image`,`Immagine`),order:3130}},jI=x([`0`,`90`,`180`,`270`]),MI=x([`auto`,`manual`]),NI=x([`auto`,`manual`]),PI=x([`off`,`blc`,`wdr`,`hlc`]),FI=b({min:r(),max:r(),step:r()}),II=b({brightness:r().optional().meta(k(`none`)),contrast:r().optional().meta(k(`none`)),saturation:r().optional().meta(k(`none`)),sharpness:r().optional().meta(k(`none`)),mirror:v().optional(),flip:v().optional(),rotate:jI.optional(),whiteBalance:MI.optional(),warmth:r().optional().meta(k(`none`)),exposureMode:NI.optional(),backlightMode:PI.optional(),lastFetchedAt:r()}),LI=b({supportsBrightness:v(),brightness:FI.optional(),supportsContrast:v(),contrast:FI.optional(),supportsSaturation:v(),saturation:FI.optional(),supportsSharpness:v(),sharpness:FI.optional(),supportsMirror:v(),supportsFlip:v(),rotateOptions:S(jI),whiteBalanceModes:S(MI),supportsWarmth:v(),warmth:FI.optional(),exposureModes:S(NI),backlightModes:S(PI)}),RI=b({brightness:r().optional(),contrast:r().optional(),saturation:r().optional(),sharpness:r().optional(),mirror:v().optional(),flip:v().optional(),rotate:jI.optional(),whiteBalance:MI.optional(),warmth:r().optional(),exposureMode:NI.optional(),backlightMode:PI.optional()}),zI={name:`image-settings`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`image-settings`,tab:`image`}},methods:{getOptions:E(b({deviceId:r()}),LI),setSettings:E(b({deviceId:r(),settings:RI}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:II,kind:`poll`},runtimeState:II,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Image settings`,`Impostazioni immagine`),order:3140}},BI=b({id:u(),addonId:u(),name:u(),enabled:v(),switchUnknown:m(!0).optional(),info:h(u(),C()).readonly(),originStableId:u().optional(),createdAt:r(),updatedAt:r(),processState:u()}),VI=b({id:u(),addonId:u(),name:u(),enabled:v(),switchUnknown:m(!0).optional(),info:h(u(),C()).readonly(),originStableId:u().optional(),createdAt:r(),updatedAt:r()}),HI=b({addonId:u(),name:u(),providerLabel:u().optional(),description:u(),iconUrl:u().nullable(),color:u(),instanceMode:u(),mode:x([`standalone`,`account`,`broker`]),discoveryMode:u(),kind:x([`device-adoption`,`device-provider`]),brokerKind:u().nullable(),supportsLocationImport:v(),canTest:v(),existingInstances:S(b({id:u(),name:u()})),canAdd:v()}),UI=x([`validated`,`rejected`,`inconclusive`,`unsupported`]),WI=b({success:v(),error:u().optional(),status:UI.optional(),testedBy:u().nullable().optional(),latencyMs:r().nonnegative().optional(),detail:u().optional()}),GI=b({id:u(),name:u().optional(),enabled:v().optional(),info:h(u(),C()).optional()}),KI=b({success:v(),deletedId:u()}),qI={name:`integrations`,scope:`system`,mode:`singleton`,methods:{list:E(_(),S(BI)),get:E(b({id:u()}),BI),getByAddonId:E(b({addonId:u()}),VI.nullable()),update:E(GI,VI,{kind:`mutation`,auth:`admin`}),delete:E(b({id:u()}),KI,{kind:`mutation`,auth:`admin`}),getAvailableTypes:E(_(),S(HI),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.ADDON_ADMIN}},$xe=be(),JI=u().min(1),YI=x([`single`,`multiple`]),XI=x([`devices`,`services`]),ZI=b({id:u().min(1),label:u().min(1),functionCap:u().min(1),brokerKind:u().min(1).optional(),alsoServes:S(u().min(1)).optional(),iconUrl:u().min(1).optional(),iconMediaType:u().min(1).optional(),role:XI.optional(),canTest:v().optional(),signIn:b({basePath:u().min(1),methods:S(x([`device-code`,`proxy`])).optional()}).optional(),connectPath:u().min(1).optional(),disconnectPath:u().min(1).optional(),widgets:S(b({id:u().min(1),placement:x([`connection`,`model`])})).optional()}),QI=b({mode:x([`none`,`lan`,`account`]),scopedToInstance:v()}),$I=b({kind:u().min(1),field:u().min(1),to:b({cap:u().min(1),kind:u().min(1).optional()})}),eL=b({role:XI,discovery:QI.optional(),instanceMode:YI,kind:u(),canTest:v(),kinds:S(ZI).min(1),allowRestoreId:v().optional(),mintsId:v().optional(),links:S($I).optional(),userScoped:v().optional()}),tL=b({state:x([`ok`,`off`,`error`,`unknown`]),detail:u().optional(),label:u().optional()}),nL=x([`scan`,`children`,`none`]),rL=b({id:JI,name:u(),configured:v(),enabled:v().optional(),kind:u().min(1),formValues:h(u(),C()),status:tL.optional(),lastCheckedAt:r().optional(),addDevice:nL.optional()}),iL=b({id:JI,name:u().min(1).optional(),values:h(u(),C())}),aL={name:`integration-instances`,scope:`system`,mode:`collection`,methods:{describe:E(_(),eL,{auth:`admin`}),instanceFormSchema:E(b({id:JI.nullable(),kind:u().min(1).optional(),mode:x([`standalone`,`account`,`broker`]).optional(),candidateStableId:u().min(1).optional()}),$xe,{auth:`admin`}),listInstances:E(le({}),S(rL).readonly(),{auth:`protected`,caller:`scoped`}),getInstance:E(b({id:JI}),rL.nullable(),{auth:`protected`,caller:`scoped`}),createInstance:E(b({id:JI.optional(),name:u().min(1),kind:u().min(1).optional(),values:h(u(),C()).optional(),originStableId:u().min(1).optional(),seed:b({info:h(u(),C())}).optional()}),b({id:u()}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),updateInstance:E(iL,b({ok:m(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),setInstanceEnabled:E(b({id:JI,enabled:v()}),b({ok:m(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),deleteInstance:E(b({id:JI}),b({ok:m(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),testInstance:D(b({id:JI.nullable(),values:h(u(),C()),kind:u().min(1).optional()}),WI,{kind:`mutation`,auth:`protected`,caller:`scoped`})},vocabulary:{notOperatorFacing:O.INTERNAL}},oL=b({codecs:S(u()),sampleRate:r().meta(k(`none`)),duplex:x([`half`,`full`]),maxBacklogMs:r().meta(k(`duration-ms`))}),sL=b({talking:v(),lastSessionAt:r().nullable(),ability:oL.nullable()}),eSe=x([`opus`,`s16le`,`g711ulaw`,`g711alaw`]),cL={name:`intercom`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{startSession:E(b({deviceId:r()}),b({sessionId:u(),sdpOffer:u()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),handleAnswer:E(b({deviceId:r(),sessionId:u(),sdpAnswer:u()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),stopSession:E(b({deviceId:r(),sessionId:u()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),startTalkSession:E(b({deviceId:r()}),b({sessionId:u()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`two-way talk is a person speaking through the viewer, not an automation step`}),pushTalkAudio:E(b({deviceId:r(),audioBase64:u(),codec:eSe.optional(),sampleRate:r().int().positive().optional(),channels:r().int().positive().optional(),sequenceNumber:r().int()}),b({accepted:v()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),endTalkSession:E(b({deviceId:r()}),_(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`})},events:{onStatusChanged:{data:b({deviceId:r(),status:sL}),notOperatorFacing:"the `talking` state trigger phrases both edges of this change"}},status:{schema:sL,kind:`command-driven`},runtimeState:sL,durability:`session`,history:`none`,vocabulary:{noun:I(`Intercom`,`Citofono`),order:3150,state:[{kind:`boolean`,field:`talking`,label:I(`Talking`,`In conversazione`),whenTrue:I(`When someone starts talking through {device}`,`Quando qualcuno inizia a parlare tramite {device}`),whenFalse:I(`When the conversation on {device} ends`,`Quando la conversazione su {device} finisce`),icon:`mic`}]}},lL=x([`carrierHz`,`dutyCyclePercent`,`repeat`,`repeatDelayMs`]),uL=x([`ir`,`rf`]),dL=b({ok:m(!0),ignoredSettings:S(u())}),fL=b({media:S(uL),settable:S(lL),maxTimings:r().int().positive(),learn:v().default(!1),formats:S(Hw).default([])}),pL=2e4,mL=6e4,hL=b({native:Ww.nullable(),timings:Nw,carrierHz:r().int().positive().nullable()}),gL=b({at:r(),ok:v(),error:u().nullable()}),_L=gL.extend({medium:uL}),vL=b({lastSend:_L.nullable(),lastLearn:gL.nullable(),lastFetchedAt:r()});function yL(e){return!(e.kind===`learn`&&e.error===`ir-transmitter.learn-unsupported`)}function tSe(e,t,n){let r=e??{lastSend:null,lastLearn:null,lastFetchedAt:n};return yL(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 nSe(e){return ti(e)?.code??null}var bL={name:`ir-transmitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Generic],methods:{send:E(b({deviceId:r().int().nonnegative(),timings:Nw.optional(),native:Ww.optional(),settings:Pw.optional()}).refine(e=>e.timings===void 0!=(e.native===void 0),{message:`send takes exactly one of timings or native`}),dL,{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:E(b({deviceId:r().int().nonnegative(),timeoutMs:r().int().positive().max(mL).default(pL)}),hL,{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:E(b({deviceId:r().int().nonnegative()}),fL,{kind:`query`,auth:`protected`})},runtimeState:vL,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`IR / RF transmitter`,`Trasmettitore IR / RF`),order:1140}},xL=x([`key-missing`,`wrong-key`,`key-file-unreadable`,`store-unavailable`,`not-initialized`,`decrypt-failed`]),SL=a(`state`,[b({state:m(`ready`)}),b({state:m(`locked`),reason:xL})]),CL=a(`kind`,[b({kind:m(`value`),value:u(),version:r().int()}),b({kind:m(`missing`)}),b({kind:m(`unavailable`),reason:xL}),b({kind:m(`forbidden`)})]),wL=h(u(),CL),TL=b({ref:u(),owner:u(),scope:u(),fieldPath:u(),version:r().int(),createdAt:r(),updatedAt:r(),updatedBy:u(),lastReadAt:r().nullable()}),EL=S(u().min(1)).max(512),DL={name:`keychain`,scope:`system`,mode:`singleton`,internal:!0,methods:{put:E(b({ref:u().min(1),value:u().min(1)}),b({ref:u(),version:r().int()}),{kind:`mutation`,auth:`admin`}),resolve:E(b({refs:EL}),wL,{auth:`admin`}),delete:E(b({refs:EL}),b({deleted:r().int()}),{kind:`mutation`,auth:`admin`}),deleteDeviceScope:E(b({deviceId:r().int()}),b({refs:S(u()).readonly()}),{kind:`mutation`,auth:`admin`}),releaseRecordRefs:E(b({refs:EL,onBehalfOf:u().min(1)}),b({released:r().int()}),{kind:`mutation`,auth:`admin`}),listMeta:E(b({}),S(TL).readonly(),{auth:`admin`}),getState:E(b({}),SL,{auth:`admin`})},vocabulary:{notOperatorFacing:O.IDENTITY}},OL=x([`mounted-file`,`previous-mounted-file`,`platform`,`default-file`]),kL=b({kind:OL,path:u().optional(),sharesBackupWithDatabase:v()}),AL=`trigger-file`,jL=b({id:u(),at:r(),actor:u(),lockedReason:u().nullable(),archived:r().int(),archivedCollection:u().nullable(),archivedKeysCollection:u().nullable(),clearedSettingsKeys:S(u()).readonly(),acknowledgedAt:r().nullable()}),ML=b({keychain:SL,keySource:kL.nullable(),configuredSource:kL,fingerprint:u().nullable(),activeKeyId:u().nullable(),rotationPending:v(),retiredWraps:r().int(),recoveryKeyDownloadedAt:r().nullable(),secretCount:r().int(),lastReset:jL.nullable()}),NL=x([`in-use`,`orphan`,`unknown`]),PL=TL.extend({usage:NL}),FL=x([`put`,`delete`,`reveal`,`rotate-master-key`,`purge-retired-keys`,`download-recovery-key`,`delete-orphans`,`reset`,`acknowledge-reset`,`initialize`]),IL=b({id:u(),at:r(),action:FL,actor:u(),ref:u().nullable(),detail:u().nullable()}),LL=`RESET KEYCHAIN`,RL=x([`jwt-signing-key`]),zL={name:`keychain-admin`,scope:`system`,mode:`singleton`,methods:{status:E(b({}),ML,{auth:`admin`}),listSecrets:E(b({}),S(PL).readonly(),{auth:`admin`}),listAudit:E(b({limit:r().int().min(1).max(500).optional()}),S(IL).readonly(),{auth:`admin`}),reveal:E(b({ref:u().min(1)}),b({value:u(),version:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),setSystemSecret:E(b({name:RL,value:u().min(16)}),b({ref:u(),version:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),importSecret:E(b({ref:u().min(1),value:u().min(1)}),b({ref:u(),version:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteOrphans:E(b({refs:S(u().min(1)).max(1e3)}),b({deleted:S(u()).readonly(),kept:S(b({ref:u(),usage:NL})).readonly()}),{kind:`mutation`,auth:`admin`,caller:`required`}),rotateMasterKey:E(b({}),b({fingerprint:u(),keySource:kL}),{kind:`mutation`,auth:`admin`,caller:`required`}),purgeRetiredKeys:E(b({}),b({purged:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),downloadRecoveryKey:E(b({}),b({key:u(),fingerprint:u(),keySource:kL}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetKeychain:E(b({confirm:m(LL)}),b({archivedCollection:u().nullable(),archived:r().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetReport:E(b({}),b({reset:jL.nullable(),pendingReentry:S(TL).readonly()}),{auth:`admin`}),acknowledgeReset:E(b({}),b({acknowledged:v()}),{kind:`mutation`,auth:`admin`,caller:`required`})},vocabulary:{notOperatorFacing:O.IDENTITY}},BL=x([`idle`,`mowing`,`paused`,`docked`,`error`]),VL=x([`info`,`warning`,`error`]),HL=b({activity:BL,batteryLevel:r().min(0).max(100).nullable().meta(k(`percentage`)),progress:r().min(0).max(100).nullable().meta(k(`percentage`)),currentCode:r().nullable().meta(k(`none`)),currentCodeLabel:u().nullable(),severity:VL,lastChangedAt:r()}),UL={name:`lawn-mower-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.LawnMower],methods:{startMowing:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.start`,label:I(`Start mowing`,`Avvia il taglio`),phrase:I(`Start {device} mowing`,`Fai partire il taglio di {device}`),icon:`play`}]}),pause:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.pause`,label:I(`Pause mower`,`Metti in pausa il tosaerba`),phrase:I(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),dock:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.dock`,label:I(`Dock mower`,`Riporta alla base`),phrase:I(`Send {device} back to its dock`,`Rimanda {device} alla base`),icon:`house`}]})},status:{schema:HL,kind:`push`},runtimeState:HL,durability:`session`,history:{fields:{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}}},vocabulary:{noun:I(`Robot mower`,`Robot tosaerba`),order:2010,state:[{kind:`enum`,field:`activity`,label:I(`Activity`,`Attività`),values:[{value:`idle`,label:I(`Idle`,`Inattivo`)},{value:`mowing`,label:I(`Mowing`,`In taglio`),phrase:I(`When {device} starts mowing`,`Quando {device} inizia a tagliare`)},{value:`paused`,label:I(`Paused`,`In pausa`)},{value:`docked`,label:I(`Docked`,`Alla base`),phrase:I(`When {device} docks`,`Quando {device} arriva alla base`)},{value:`error`,label:I(`Error`,`Errore`),phrase:I(`When {device} reports an error`,`Quando {device} segnala un errore`)}],icon:`bot`},{kind:`numeric`,field:`batteryLevel`,quantity:I(`the battery level`,`il livello della batteria`),label:I(`Battery`,`Batteria`),unit:`%`,icon:`battery`}]}},WL=6e5,rSe=60*6e4,GL=b({inputTokens:r(),outputTokens:r()}),KL=x([`timeout`,`rate-limited`,`auth`,`refusal`,`bad-request`,`unavailable`,`no-profile`,`budget-exceeded`,`adapter-error`]),qL=b({ok:m(!0),text:u(),model:u(),usage:GL,truncated:v(),latencyMs:r()}),JL=x([`guardrail`,`model`]),YL=b({ok:m(!1),code:KL,message:u(),retryAfterMs:r().optional(),refusalSource:JL.optional()}),XL=a(`ok`,[qL,YL]),ZL=b({bytes:y(Uint8Array),mimeType:u()}),QL=b({enabled:v().default(!1),maxAttempts:r().int().min(1).max(5).default(1)}),iSe={totalMs:6e4,connectMs:1e4,firstTokenMs:12e4,idleMs:6e4},$L=b({addonId:u().optional(),profileId:u().optional(),consumer:u(),system:u().optional(),prompt:u(),jsonSchema:h(u(),C()).optional(),maxTokens:r().int().positive().optional(),temperature:r().optional(),topP:r().min(0).max(1).optional(),topK:r().int().positive().optional(),reasoningEffort:x([`off`,`low`,`medium`,`high`]).optional(),timeoutMs:r().int().positive().optional(),retry:QL.optional(),requestId:u().optional()}),eR=b({url:u(),filename:u(),sizeBytes:r(),sha256:u().optional()}),tR=a(`kind`,[b({kind:m(`catalog`),catalogId:u()}),b({kind:m(`url`),url:u(),sha256:u().optional(),label:u().optional(),sizeBytes:r().optional(),extraFiles:S(eR).optional()}),b({kind:m(`path`),path:u()})]),nR=b({nodeId:u(),engine:x([`llama-cpp`]),model:tR,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:v().default(!1),mlock:v().default(!1),noMmap:v().default(!1),cacheTypeK:x([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),cacheTypeV:x([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),extraArgs:S(u()).default([]),autoStart:v().default(!1),idleStopMinutes:r().int().default(30)}),rR=b({phase:x([`downloading`,`verifying`]),file:u(),fileIndex:r().int(),fileCount:r().int(),downloadedBytes:r(),totalBytes:r().optional()}),iR=b({nodeId:u(),state:x([`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:rR.optional(),lastError:u().optional(),crashesInWindow:r(),memoryBytes:r().optional(),vramBytes:r().optional()}),aR=b({file:u(),sizeBytes:r(),catalogId:u().optional(),installedAt:r().optional(),path:u().optional()}),oR=b({nodeId:u(),modelsBytes:r(),freeBytes:r().optional()}),sR=$L.extend({images:S(ZL).optional(),runtime:nR,timeoutMs:r().int().positive().optional()}),cR=x([`deviceNotEligible`,`appleIntelligenceNotEnabled`,`modelNotReady`,`osTooOld`,`helperMissing`,`helperCrashed`]),lR=a(`state`,[b({state:m(`available`),osVersion:u(),contextSize:r().int().positive(),languages:S(u()),imageInput:v()}),b({state:m(`unavailable`),reason:cR,osVersion:u().nullable(),detail:u()}),b({state:m(`unsupported-platform`),platform:u()}),b({state:m(`unknown`),error:u()})]),uR=$L.extend({images:S(ZL).optional(),timeoutMs:r().int().positive().optional()}),dR=b({requestId:u()}),fR={name:`llm-runtime`,scope:`system`,mode:`singleton`,internal:!0,methods:{complete:E(sR,XL,{kind:`mutation`,auth:`admin`,timeoutMs:WL}),ensureStarted:E(b({runtime:nR}),iR,{kind:`mutation`,auth:`admin`,timeoutMs:WL}),stop:E(b({}),_(),{kind:`mutation`,auth:`admin`}),status:E(b({}),iR,{auth:`admin`}),installModel:E(b({model:tR}),_(),{kind:`mutation`,auth:`admin`,timeoutMs:rSe}),deleteModel:E(b({file:u()}),_(),{kind:`mutation`,auth:`admin`}),listLocalModels:E(b({}),S(aR),{auth:`admin`}),getDiskUsage:E(b({}),oR,{auth:`admin`}),cancel:E(dR,_(),{kind:`mutation`,auth:`admin`}),appleAvailability:E(b({}),lR,{auth:`admin`}),completeApple:E(uR,XL,{kind:`mutation`,auth:`admin`,timeoutMs:WL})},vocabulary:{notOperatorFacing:O.ML}},pR=/^[a-z0-9][a-z0-9-]{0,63}$/,mR=u().regex(pR,`a kind id is lower-case letters, digits and dashes`),hR=b({vision:v(),tools:v(),streaming:v(),reasoning:v().nullable().optional()}),gR=b({id:u(),label:u().optional(),contextLength:r().int().positive().optional(),features:hR.partial().optional()}),_R=h(u(),C()),aSe=b({id:u(),name:u(),kind:mR,addonId:u(),enabled:v(),model:u(),supportsVision:v(),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:x([`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:QL.default({enabled:!1,maxAttempts:1}),toolsEnabled:v().default(!1),providerConfig:_R.default({})}),vR=x([`temperature`,`topP`,`topK`,`maxTokens`,`reasoningEffort`,`contextLength`,`systemPrompt`,`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`]),yR=b({id:u(),placement:x([`connection`,`model`]),requires:S(u()).optional()}),bR=C(),oSe=b({kind:mR,label:u(),icon:u(),addonId:u(),connectionSchema:bR,advancedSchema:bR.optional(),features:hR,visionEditable:v(),modelCatalog:x([`fetch`,`static`,`none`]),staticModels:S(gR).optional(),profileFields:S(vR),providerWidgets:S(yR).optional()}),xR=b({addonId:u(),kind:mR,profileId:u().optional(),connection:_R.optional()}),SR=x([`auth`,`network`,`unsupported`,`invalid`]),CR=a(`ok`,[b({ok:m(!0),models:S(gR)}),b({ok:m(!1),code:SR,message:u()})]),wR=g([b({consumer:u()}),b({purpose:x([`text`,`vision`])})]),TR=b({selector:wR,profileId:u()}),ER=b({day:u(),consumer:u(),profileId:u(),calls:r(),okCalls:r(),errorCalls:r(),inputTokens:r(),outputTokens:r(),avgLatencyMs:r()}),DR=b({id:u(),label:u(),family:u(),purpose:x([`text`,`vision`]),url:u(),sha256:u(),sizeBytes:r(),quantization:u(),minRamBytes:r(),contextSizeDefault:r().int(),mmprojUrl:u().optional()}),OR=a(`ok`,[b({ok:m(!0),model:tR,label:u(),repo:u(),quantization:u(),purpose:x([`text`,`vision`]),totalBytes:r(),extraFilenames:S(u())}),b({ok:m(!1),code:u(),message:u(),candidates:S(u()).optional(),requiredBytes:r().optional()})]),kR=b({nodeId:u(),reachable:v(),status:iR.optional(),disk:oR.optional(),error:u().optional(),apple:lR.optional()}),sSe=$L.extend({images:S(ZL).min(1)}),AR=b({addonId:u(),profileId:u()}),jR={name:`llm`,scope:`system`,mode:`collection`,internal:!1,providerKind:`ai`,nodeIdMode:`data`,methods:{generate:E($L,XL,{kind:`mutation`,timeoutMs:WL}),generateVision:E(sSe,XL,{kind:`mutation`,timeoutMs:WL}),cancel:E(b({addonId:u().optional(),requestId:u()}),_(),{kind:`mutation`}),listModels:E(xR,CR,{kind:`mutation`,auth:`admin`}),getDefaults:E(b({}),S(TR)),setDefault:E(b({selector:wR,profileId:u().nullable()}),_(),{kind:`mutation`,auth:`admin`}),getUsage:E(b({since:r().optional(),until:r().optional(),consumer:u().optional(),profileId:u().optional()}),S(ER)),listModelCatalog:E(b({}),S(DR)),listRuntimeNodes:E(b({}),S(kR)),listNodeModels:E(b({nodeId:u()}),S(aR)),resolveModelRef:E(b({ref:u(),maxBytes:r().positive().optional()}),OR,{kind:`mutation`,auth:`admin`}),installModel:E(b({nodeId:u(),model:tR}),_(),{kind:`mutation`,auth:`admin`}),deleteModel:E(b({nodeId:u(),file:u()}),_(),{kind:`mutation`,auth:`admin`}),getRuntimeStatus:E(AR,iR),startRuntime:E(AR,iR,{kind:`mutation`,auth:`admin`}),stopRuntime:E(AR,_(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.ML}},MR=[`decode`,`transcode`,`recording`,`streaming`,`detection`],NR=[`measured`,`accounted`,`unattributable`],PR=b({role:x(MR),deviceId:r().int().positive().nullable(),attribution:x(NR),unit:u(),pid:r().int().positive().optional(),startedAtMs:r().optional(),cpuSeconds:r().optional(),rssBytes:r().optional()}),FR={name:`load-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:E(_(),S(PR).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},IR=`https://camstack.zentik.app`,LR=`/viewer/camstack`;function RR(e){if(e==null||e===``)return!1;try{return new URL(e).origin===IR}catch{return!1}}function cSe(e){let t=e.baseUrl??e.resolved;return RR(t)?{form:`app`,hubBaseUrl:e.appLinkHub??null}:{form:`hub`,hubBaseUrl:t}}function zR(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 lSe(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=zR(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 uSe(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 BR(e){return e.length===0?``:`?${e.map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`}function dSe(e){let t=uSe(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:zR(r),n=e===null?t.query:[...t.query,[`hub`,e]];return`${IR}${t.path}${BR(n)}`}return r===``||RR(r)?null:`${r}${LR}${t.path}${BR(t.query)}`}var VR=[`appConnections`,`notificationTaps`,`internal`,`publicEndpoint`],fSe=[`notificationTaps`,`internal`,`publicEndpoint`];function pSe(e){return e!==`appConnections`}var mSe={appConnections:[],notificationTaps:null,internal:null,publicEndpoint:null},hSe=/^\d{1,3}(?:\.\d{1,3}){3}$/;function HR(e){try{let t=new URL(e).hostname;return t.length>0?t:null}catch{return null}}function gSe(e){return e.replace(/\/+$/,``)}function UR(e){return e.kind===`public`&&e.interfaceKind===`vpn`}function _Se(e){return e.kind===`public`&&e.interfaceKind===`public`}function WR(e){return(e.kind===`lan-ipv4`||e.kind===`lan-ipv6`)&&e.plausible}function GR(e){if(e.kind!==`lan-ipv4`||!e.plausible)return!1;let t=HR(e.baseUrl);return t!==null&&hSe.test(t)}function KR(e){return e.stable===!1}function vSe(e,t){return t.kind===`loopback`||t.kind===`app-link`||t.kind===`custom`||HR(t.baseUrl)===null||KR(t)?null:e===`internal`?GR(t)?0:WR(t)?1:UR(t)?2:null:_Se(t)?0:UR(t)?1:GR(t)?2:WR(t)?3:null}var ySe=new Set([`localhost`,`0.0.0.0`,`::1`,`[::1]`,`::`,`[::]`]);function bSe(e){let t=e.toLowerCase();return ySe.has(t)||t.endsWith(`.localhost`)?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}function qR(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 JR=`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 YR(e,t,n={}){if(RR(t))return e===`notificationTaps`?{ok:!0,baseUrl:IR}:{ok:!1,reason:`The CamStack app link is not a hub address — only notification taps can use it.`};let r=qR(t);return r.ok&&e===`publicEndpoint`&&r.baseUrl.startsWith(`http:`)&&n.acceptInsecureHttp!==!0?{ok:!1,reason:JR}:r}function XR(e,t){if(t===null||t===``)return null;let n=YR(e,t,{acceptInsecureHttp:!0});return n.ok?n.baseUrl:null}function xSe(e,t){let n=e.flatMap(e=>{let n=vSe(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:gSe(n.endpoint.baseUrl)}function ZR(e,t,n){let r=XR(t,n);if(r!==null)return{flagged:r,resolved:r,source:`flagged`};let i=xSe(e,t);return{flagged:null,resolved:i,source:i===null?`none`:`auto`}}function QR(e,t){return ZR(e,`internal`,t.internal)}function $R(e,t){return ZR(e,`publicEndpoint`,t.publicEndpoint)}function ez(e){let t=XR(`notificationTaps`,e.notificationTaps);return t!==null&&!RR(t)?{flagged:t,resolved:t,source:`flagged`}:{flagged:null,resolved:IR,source:`auto`}}function tz(e){return KR(e)?!1:e.kind===`lan-ipv4`?!0:e.kind===`public`&&e.interfaceKind===`public`}function nz(e,t){let n=e.filter(tz);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 rz(e,t){let n=new Set(t.appConnections),r=nz(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 SSe(e,t,n){return{appConnections:rz(e,n),notificationTaps:ez(n),internal:QR(t,n),publicEndpoint:$R(t,n)}}function CSe(e){return e===null?null:HR(e)}var wSe=`camstack`,TSe=`_camstack._tcp.local`,ESe={nodeId:`nodeId`,version:`version`,role:`role`,url:`url`,hubId:`hubId`},iz=/^hub-[0-9a-f]{16}$/;function DSe(e){return typeof e==`string`&&iz.test(e)}var OSe=`camstack-agent`,kSe=`_camstack-agent._tcp.local`,ASe={nodeId:`nodeId`,version:`version`,name:`name`,state:`state`,keyFingerprint:`fp`},jSe=x([`lan`,`wifi`,`docker`,`vpn`,`loopback`,`other`]),az=b({name:u(),family:x([`IPv4`,`IPv6`]),address:u(),cidr:u(),netmask:u(),internal:v(),mac:u(),kind:jSe,preferred:v(),plausible:v(),plausibleReason:u()}),MSe=b({interfaces:S(az).readonly(),probedAt:r()}),NSe=az.nullable(),oz=b({label:u(),baseUrl:u(),kind:x([`lan-ipv4`,`lan-ipv6`,`public`,`loopback`,`app-link`,`custom`]),interfaceKind:x([`lan`,`wifi`,`docker`,`vpn`,`other`,`loopback`,`public`]),plausible:v(),plausibleReason:u(),priority:r(),stable:v().optional()}),PSe=x([`server-config`,`server-env`,`caller-hint`,`default`]),FSe=b({port:r().int().min(1).max(65535),source:PSe}),ISe=b({endpoints:S(oz).readonly(),localPort:FSe}),sz=b({baseUrl:u().nullable(),resolved:u().nullable(),appLinkHub:u().nullable()}),cz=b({baseUrls:S(u()).readonly(),resolved:S(u()).readonly()}),lz=b({override:u().nullable(),resolved:u().nullable(),source:x([`override`,`auto`,`none`])}),LSe=b({cluster:lz,browser:lz}),uz=x(VR),dz=x([`flagged`,`auto`,`none`]),fz=b({flagged:u().nullable(),resolved:u().nullable(),source:dz}),RSe=b({flagged:S(u()).readonly(),resolved:S(u()).readonly(),source:dz}),pz=b({rows:S(oz.extend({detected:v(),custom:v(),flags:S(uz).readonly(),inUse:S(uz).readonly(),eligible:S(uz).readonly()})).readonly(),roles:b({appConnections:RSe,notificationTaps:fz,internal:fz,publicEndpoint:fz}),appLinkHub:u().nullable(),listenerOrigins:S(u()).readonly().optional()}),mz=b({addresses:S(u()).readonly()}),hz=b({mode:x([`generated`,`uploaded`,`disabled`]),leafFingerprintSha256:u().nullable(),caFingerprintSha256:u().nullable(),validTo:u().nullable(),sans:S(u()),caCertPem:u().nullable(),reissueError:u().nullable(),restartRequired:v(),caMissing:v(),localCaConstrained:v().nullable(),caReplacedAt:u().nullable(),storedUpload:b({leafFingerprintSha256:u(),validTo:u(),hasCa:v()}).nullable()}),zSe=b({providerId:u().min(1),modes:S(jA)}),BSe=b({providerId:u().optional(),mode:u().optional(),message:u()}),VSe=b({hostsProbed:r().int(),hits:r().int(),timeouts:r().int(),byMode:h(u(),b({probed:r().int(),hits:r().int(),timeouts:r().int()}))}),HSe=b({hits:S(b({providerId:u(),hit:MA})),subnetsScanned:S(u()),errors:S(BSe),stats:VSe}),gz={name:`local-network`,scope:`system`,mode:`singleton`,methods:{list:E(_(),MSe),getPreferred:E(_(),NSe),getConnectionEndpoints:E(b({port:r().int().min(1).max(65535).optional(),includeLoopback:v().optional(),ipv4Only:v().optional(),scheme:x([`http`,`https`]).optional(),includeAppLink:v().optional()}),ISe),getNotificationEndpoint:E(_(),sz),setNotificationEndpoint:E(b({baseUrl:u().nullable()}),sz,{kind:`mutation`}),getViewerEndpoints:E(_(),cz),setViewerEndpoints:E(b({baseUrls:S(u()).readonly()}),cz,{kind:`mutation`}),getAddresses:E(b({scheme:x([`http`,`https`]).optional()}).optional(),pz),addCustomAddress:E(b({baseUrl:u(),label:u().max(80)}),pz,{kind:`mutation`,auth:`admin`}),removeCustomAddress:E(b({baseUrl:u()}),pz,{kind:`mutation`,auth:`admin`}),setAddressRole:E(b({role:uz,baseUrl:u().nullable(),enabled:v(),acceptInsecureHttp:v().optional()}),pz,{kind:`mutation`,auth:`admin`}),getHubAddresses:E(_(),LSe),getAllowedAddresses:E(_(),mz),setAllowedAddresses:E(mz,b({success:m(!0)}),{kind:`mutation`}),resetAllowlistToBestMatch:E(_(),mz,{kind:`mutation`}),getTlsStatus:E(_(),hz),regenerateCertificate:E(b({reason:u().optional()}),hz,{kind:`mutation`,auth:`admin`}),uploadCertificate:E(b({certPem:u().min(1),keyPem:u().min(1),caPem:u().optional()}),hz,{kind:`mutation`,auth:`admin`}),downloadCa:E(_(),b({pem:u()})),useStoredUploadedCertificate:E(_(),hz,{kind:`mutation`,auth:`admin`}),scanNetwork:E(b({requests:S(zSe),subnets:S(u()).optional()}),HSe,{kind:`mutation`,auth:`admin`,timeoutMs:9e4}),getScanSubnets:E(_(),b({subnets:S(u())}),{auth:`admin`}),setScanSubnets:E(b({subnets:S(u())}),b({subnets:S(u())}),{kind:`mutation`,auth:`admin`}),revertToGeneratedCertificate:E(_(),hz,{kind:`mutation`,auth:`admin`})},mount:{kind:`hub-only`},vocabulary:{notOperatorFacing:O.NETWORK}},_z=x([`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]),vz=b({state:_z,codeRequired:v().nullable().optional(),lastChangedAt:r()}),USe={version:1,overridable:[{path:`state`,by:`door-contact`}],targets:[{id:`door-contact`,cardinality:`scalar`,vocabulary:{cap:`lock-control`,stateField:`state`},deviceTypes:[j.Lock],apply:`replace`,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},sources:[{kind:`binary`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}]},yz={name:`lock-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Lock],methods:{lock:E(b({deviceId:r().int().nonnegative(),code:u().min(1).optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.lock`,label:I(`Lock`,`Chiudi a chiave`),phrase:I(`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:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),unlock:E(b({deviceId:r().int().nonnegative(),code:u().min(1).optional(),confirm:v().optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.unlock`,label:I(`Unlock`,`Apri la serratura`),phrase:I(`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:I(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),open:D(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.open`,label:I(`Open latch`,`Apri lo scrocco`),phrase:I(`Release the latch of {device}`,`Fai scattare lo scrocco di {device}`),icon:`door-open`}]})},status:{schema:vz,kind:`push`},runtimeState:vz,customize:USe,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Lock`,`Serratura`),order:1060,state:[{kind:`enum`,field:`state`,label:I(`Lock state`,`Stato della serratura`),values:[{value:`locked`,label:I(`Locked`,`Chiusa a chiave`),phrase:I(`When {device} locks`,`Quando {device} si chiude a chiave`)},{value:`unlocked`,label:I(`Unlocked`,`Sbloccata`),phrase:I(`When {device} unlocks`,`Quando {device} si sblocca`)},{value:`locking`,label:I(`Locking`,`In chiusura`),phrase:I(`When {device} starts locking`,`Quando {device} inizia a chiudersi`)},{value:`unlocking`,label:I(`Unlocking`,`In apertura`),phrase:I(`When {device} starts unlocking`,`Quando {device} inizia a sbloccarsi`)},{value:`jammed`,label:I(`Jammed`,`Inceppata`),phrase:I(`When {device} jams`,`Quando {device} si inceppa`)},{value:`door-open`,label:I(`Door open`,`Porta aperta`),phrase:I(`When the door of {device} opens`,`Quando la porta di {device} si apre`)}],icon:`lock`}]}},bz=b({armed:r().int().min(0),unknown:S(u()).readonly()}),xz={name:`log-channels`,scope:`system`,mode:`collection`,internal:!0,methods:{list:E(_(),S(fu).readonly()),apply:E(b({windows:S(pu).readonly()}),bz,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},Sz=x([`debug`,`info`,`warn`,`error`]),Cz=b({timestamp:ee(),level:Sz,scope:S(u()),message:u(),meta:h(u(),C()).optional(),tags:h(u(),u()).optional()}),wz=b({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:Sz.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()}),Tz=b({id:u().optional(),timestamp:r(),level:Sz,scope:u().optional(),message:u(),tags:h(u(),g([u(),r()])).optional(),meta:h(u(),C()).optional()}),Ez=b({entries:S(Tz),nextBefore:u().nullable(),nextAfter:u().nullable(),scannedBytes:r().int().nonnegative(),done:v(),cancelled:v().optional()}),WSe=b({instanceId:u().min(1).max(200).optional()}),Dz=b({readable:v(),reason:u().nullable(),filters:b({deviceId:v(),addonId:v(),nodeId:v(),tags:v(),level:v(),text:v(),timeRange:v()}),retentionDays:r().nullable()}),Oz={name:`log-destination`,scope:`system`,mode:`collection`,internal:!0,methods:{write:E(Cz,_(),{kind:`mutation`}),describeRead:D(WSe,Dz,{auth:`admin`}),read:D(wz,Ez,{auth:`admin`}),cancelRead:D(b({requestId:u().min(1).max(64)}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},kz=x([`primary`,`second-factor`]),Az=b({kind:m(`redirect`),id:u(),label:u(),icon:u().optional(),startUrl:u(),stage:kz,linkable:v().optional(),app:Zf.nullable().optional()}),jz=b({kind:m(`widget`),id:u(),addonId:u(),bundle:u(),remote:Bv,stage:kz,app:Zf.nullable().optional()}),Mz=b({kind:m(`passkey`),id:u(),label:u(),stage:kz,rpId:u(),origin:u().nullable(),app:Zf.nullable().optional()}),Nz=a(`kind`,[Az,jz,Mz]),Pz={name:`login-method`,scope:`system`,mode:`collection`,internal:!0,methods:{getLoginMethods:E(_(),S(Nz).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.IDENTITY}},Fz=b({sleeping:v().meta({label:`Sleeping`}),lastContactAt:r().optional(),lastUpdated:r().meta(k(`none`))}),Iz={name:`low-power-sleep`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{wakeUp:E(b({deviceId:r(),timeoutMs:r().int().min(500).max(3e4).default(8e3)}),b({awoke:v(),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:Fz,kind:`push`,empty:{sleeping:!1,lastUpdated:0}},runtimeState:Fz,durability:`restored`,history:`none`,volatileStateFields:[`lastUpdated`],vocabulary:{noun:I(`Low-power sleep`,`Sospensione a basso consumo`),order:5245}},GSe=b({id:u(),label:u(),scope:x([`mesh`,`public`]),url:u(),hostname:u(),port:r(),protocol:x([`http`,`https`])}),Lz=b({id:u(),hostname:u(),magicDns:u(),addresses:S(u()).readonly(),os:u().optional(),online:v(),lastSeenMs:r(),isSelf:v(),connection:x([`direct`,`relay`,`idle`]),relay:u().nullable(),lastHandshakeMs:r(),rxBytes:r(),txBytes:r(),tags:S(u()).readonly(),exitNodeOption:v(),advertisedRoutes:S(u()).readonly(),userLogin:u().nullable(),keyExpiry:r().nullable()}),Rz=b({joined:v(),meshIp:u(),magicDnsHostname:u(),peerCount:r(),endpoints:S(GSe).readonly(),error:u().optional(),tenantName:u(),magicDnsSuffix:u(),userLogin:u().nullable(),controlPlaneUrl:u(),keyExpiry:r().nullable(),daemonSocket:u().optional(),daemonCliPath:u().optional()}),zz={name:`mesh-network`,scope:`system`,mode:`collection`,providerKind:`mesh`,methods:{getStatus:E(_(),Rz),join:E(b({authKey:u().min(8),hostname:u().optional()}),b({joined:m(!0)}),{kind:`mutation`}),startLogin:E(b({hostname:u().optional()}),b({loginUrl:u()}),{kind:`mutation`}),leave:E(_(),b({left:m(!0)}),{kind:`mutation`}),logout:E(_(),b({loggedOut:m(!0)}),{kind:`mutation`}),listPeers:E(_(),b({peers:S(Lz).readonly()}))},vocabulary:{notOperatorFacing:O.NETWORK}},Bz=b({value:r().nullable().meta(k(`device`,{label:`Total`})),lastFetchedAt:r()}),Vz={name:`meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:Bz,kind:`push`},runtimeState:Bz,durability:`restored`,history:{fields:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Meter`,`Contatore`),order:5140,state:[{kind:`numeric`,field:`value`,quantity:I(`the total`,`il totale`),label:I(`Total`,`Totale`),icon:`gauge`}]}},KSe=b({total:r(),user:r(),system:r(),irq:r(),nice:r(),loadAvg:d([r(),r(),r()]),cores:r()}),qSe=b({percent:r().nullable(),totalBytes:r(),usedBytes:r().nullable(),availableBytes:r().nullable(),swapUsedBytes:r(),swapTotalBytes:r()}),JSe=b({readBytes:r(),writeBytes:r(),readOps:r(),writeOps:r(),timestampMs:r()}),YSe=b({rxBytes:r(),txBytes:r(),rxPackets:r(),txPackets:r(),rxErrors:r(),txErrors:r(),timestampMs:r()}),Hz=b({utilization:r(),model:u(),memoryUsedBytes:r(),memoryTotalBytes:r(),temperature:r().nullable()}),XSe=b({openFds:r(),threadCount:r(),activeHandles:r(),activeRequests:r()}),Uz=b({avg10:r(),avg60:r(),avg300:r()}),Wz=b({some:Uz,full:Uz.nullable()}),Gz=b({cpu:KSe,memory:qSe,gpu:Hz.nullable(),network:YSe,disk:JSe,pressure:b({cpu:Wz.nullable(),memory:Wz.nullable(),io:Wz.nullable()}),process:XSe,cpuTemperature:r().nullable(),timestampMs:r()}),ZSe=b({path:u(),totalBytes:r(),usedBytes:r(),availableBytes:r(),percent:r()}),Kz=b({pid:r(),cpu:r(),memory:r(),privateBytes:r().optional(),sharedBytes:r().optional()}),QSe=b({addonId:u(),nodeId:u(),role:x([`hub`,`worker`]),pid:r(),state:x([`starting`,`running`,`stopping`,`stopped`,`crashed`]),uptimeSec:r()}),$Se=b({pid:r(),ppid:r(),pgid:r(),classification:x([`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()}),eCe=b({source:x([`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()}),tCe=b({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()}),nCe=b({key:u(),kind:x([`addon`,`root`,`unattributed`]),points:S(tCe).readonly()}),rCe=b({nodeId:u(),series:S(nCe).readonly(),containerMemory:S(eCe).readonly(),bucketMs:r(),retainedSamples:r(),oldestAtMs:r().nullable(),cadenceMs:r(),durable:v()}),iCe=b({forNodeId:u(),sinceMs:r().optional(),maxPoints:r().int().positive().optional()}),qz=b({cpuPercent:r(),memoryPercent:r().nullable(),memoryUsedMB:r().nullable(),memoryTotalMB:r(),diskPercent:r().optional(),temperature:r().optional(),gpuPercent:r().optional(),gpuMemoryPercent:r().optional()}),Jz={name:`metrics-provider`,scope:`system`,mode:`singleton`,methods:{collectSnapshot:E(_(),Gz),getCached:E(_(),Gz.nullable()),getCurrent:E(_(),qz),getDiskSpace:E(b({dirPath:u()}),ZSe),getGpuInfo:E(_(),Hz.nullable()),getCpuTemperature:E(_(),r().nullable()),getProcessStats:E(b({pids:S(r())}),S(Kz)),listAddonInstances:E(_(),S(QSe).readonly()),getAddonStats:E(b({addonId:u()}),Kz.nullable()),listNodeProcesses:E(_(),S($Se).readonly()),getLoadSeries:E(iCe,rCe)},vocabulary:{notOperatorFacing:O.CLUSTER}},Yz=u().min(1).max(256),Xz=h(u(),C()),Zz=b({id:Yz,deviceId:r().int().optional(),at:r().int().optional(),expiresAt:r().int().optional(),data:Xz}),Qz=b({id:u(),deviceId:r().int().nullable(),at:r().nullable(),expiresAt:r().nullable(),rev:r().int(),updatedAt:r(),data:Xz}),$z=h(Pi,g([u(),r(),v(),b({in:S(g([u(),r(),v()])).min(1).max(Ln)}),b({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`})])),eB={kind:Bi},tB={deviceId:r().int().optional(),atFrom:r().optional(),atTo:r().optional()},nB=b({...eB,...tB,where:$z.optional(),order:x([`at`,`id`]).optional(),desc:v().optional(),limit:r().int().min(1).max(zn).default(100),cursor:u().min(1).optional()}),rB=b({records:S(Qz),nextCursor:u().nullable()}),aCe=x([`created`,`unchanged`,`updated`]),iB=b({kindId:r().int(),state:aCe,createdIndexes:S(u())}),aB=S(u()),oB=a(`op`,[b({op:m(`put`),kind:Bi,record:Zz,ifRev:r().int().min(0).optional()}),b({op:m(`patch`),kind:Bi,id:Yz,data:Xz,at:r().int().nullable().optional(),expiresAt:r().int().nullable().optional(),ifRev:r().int().min(1).optional()}),b({op:m(`delete`),kind:Bi,id:Yz})]),sB=h(u(),h(u(),u())),cB={name:`records`,scope:`system`,mode:`singleton`,internal:!0,methods:{declareKinds:E(b({kinds:h(Bi,zi)}),b({kinds:h(u(),iB)}),{kind:`mutation`,auth:`admin`}),get:E(b({...eB,id:Yz}),Qz.nullable(),{auth:`admin`}),getMany:E(b({...eB,ids:S(Yz).min(1).max(Ln)}),S(Qz),{auth:`admin`}),secretRefs:E(b({...eB,ids:S(Yz).min(1).max(Ln)}),sB,{auth:`admin`}),put:E(b({...eB,record:Zz,ifRev:r().int().min(0).optional()}),b({rev:r().int(),releasedRefs:aB}),{kind:`mutation`,auth:`admin`}),putMany:E(b({...eB,records:S(Zz).min(1).max(Ln)}),b({count:r().int(),releasedRefs:aB}),{kind:`mutation`,auth:`admin`}),patch:E(b({...eB,id:Yz,data:Xz,at:r().int().nullable().optional(),expiresAt:r().int().nullable().optional(),ifRev:r().int().min(1).optional()}),b({rev:r().int(),releasedRefs:aB}),{kind:`mutation`,auth:`admin`}),delete:E(b({...eB,id:Yz}),b({deleted:v(),secretRefs:aB}),{kind:`mutation`,auth:`admin`}),deleteMany:E(b({...eB,ids:S(Yz).min(1).max(Ln)}),b({deleted:r().int(),secretRefs:aB}),{kind:`mutation`,auth:`admin`}),query:E(nB,rB,{auth:`admin`}),count:E(b({...eB,...tB,where:$z.optional()}),b({count:r().int()}),{auth:`admin`}),histogram:E(b({...eB,deviceId:r().int().optional(),from:r(),to:r(),bucketMs:r().int().positive()}),b({buckets:S(b({bucketStart:r(),count:r().int()}))}),{auth:`admin`}),aggregate:E(b({...eB,op:x([`sum`,`min`,`max`,`count`]),field:Pi.optional(),groupBy:Pi.optional(),where:$z.optional()}),b({rows:S(b({group:g([u(),r(),se()]),value:r().nullable()}))}),{auth:`admin`}),deleteWhere:E(b({...eB,deviceId:r().int().optional(),atBefore:r().optional(),where:$z.optional()}),b({deleted:r().int(),secretRefs:aB}),{kind:`mutation`,auth:`admin`}),transact:E(b({ops:S(oB).min(1).max(Ln)}),b({results:S(b({rev:r().int().nullable(),deleted:v()})),releasedRefs:aB,secretRefs:aB}),{kind:`mutation`,auth:`admin`}),deleteDevice:E(b({deviceId:r().int(),kinds:S(Bi).optional()}),b({deleted:h(u(),r().int()),secretRefs:aB}),{kind:`mutation`,auth:`admin`}),allocateId:E(b(eB),b({id:r().int()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},lB=h(u(),C()),uB=b({integrationId:u().min(1)}),dB=b({id:u().min(1)}),fB=b({id:u(),deviceId:r().int().nullable(),at:r().nullable(),expiresAt:r().nullable(),rev:r().int(),updatedAt:r(),data:lB}),pB={id:u().min(1),deviceId:r().int().optional(),at:r().int().optional(),expiresAt:r().int().optional(),data:lB},mB=b({id:u(),addonId:u(),name:u(),info:lB,enabled:v().optional(),originStableId:u().optional()}),oCe=b({id:r().int(),integrationId:u().nullable().optional(),parentDeviceId:r().int().nullable().optional(),type:u().optional(),name:u().optional(),stableId:u().optional()}),hB=b({version:r().int(),methods:S(u())}),gB=b({message:u(),meta:lB.optional(),tags:b({deviceId:r().int().optional()}).optional()}),sCe={"ledger.declare":{input:b({owner:u().min(1),metas:S(Ro)}),output:b({bootId:u(),snapshot:x([`none`,`written`,`refused`]),steps:S(Go),migrationApi:hB.optional()}),behaviours:[`ledger.declare.answers-steps-in-engine-order`,`ledger.declare.answers-the-migration-api`]},"ledger.start":{input:b({id:u().min(1)}),output:b({proceed:v(),state:g([m(`pending`),Uo]),reason:u().nullable()}),behaviours:[`ledger.start.proceeds-when-predecessors-applied`]},"ledger.finish":{input:b({id:u().min(1),result:Ho}),output:b({status:Uo,error:u().nullable(),rowsChanged:r().int().nonnegative()}),behaviours:[`ledger.finish.records-the-outcome`]},"legacyRows.read":{input:uB,output:lB,behaviours:[`legacyRows.read.returns-stored-rows`,`legacyRows.read.absent-store-is-empty`,`legacyRows.caller.sibling-package`]},"legacyRows.clear":{input:uB,output:b({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:lB}),output:b({written:v()}),behaviours:[`legacyRows.patch.upserts-keys-and-keeps-the-rest`,`legacyRows.patch.absent-store-writes-nothing`]},"legacyRows.deleteKeys":{input:uB.extend({keys:S(u().min(1))}),output:b({present:v(),removed:lB}),behaviours:[`legacyRows.deleteKeys.removes-the-named-keys`,`legacyRows.deleteKeys.absent-store-reports-not-present`]},"records.get":{input:dB,output:fB.nullable(),behaviours:[`records.get.returns-the-row-or-null`]},"records.getResolved":{input:dB,output:fB.nullable(),behaviours:[`records.getResolved.resolves-secret-fields`]},"records.put":{input:b({...pB,ifRev:r().int().optional()}),output:b({rev:r().int()}),behaviours:[`records.put.creates-and-replaces`,`records.put.if-rev-conflict-throws`]},"records.putMany":{input:b({records:S(b(pB))}),output:b({count:r().int().nonnegative()}),behaviours:[`records.putMany.writes-every-row`]},"records.patch":{input:dB.extend({partial:lB,ifRev:r().int().optional()}),output:b({rev:r().int()}),behaviours:[`records.patch.merges-and-null-removes`]},"records.delete":{input:dB,output:b({deleted:v()}),behaviours:[`records.delete.reports-whether-a-row-went`]},"records.query":{input:b({deviceId:r().int().optional(),atFrom:r().optional(),atTo:r().optional(),where:$z.optional(),limit:r().int().min(1).optional(),cursor:u().min(1).optional(),resolveSecrets:v().optional()}),output:b({records:S(fB),nextCursor:u().nullable()}),behaviours:[`records.query.pages-with-a-cursor`,`records.query.filters-on-a-declared-index`]},"records.deleteWhere":{input:b({deviceId:r().int().optional(),atBefore:r().optional(),where:$z.optional()}),output:b({count:r().int().nonnegative()}),behaviours:[`records.deleteWhere.deletes-the-matching-rows`]},"settings.read":{input:b({}),output:b({store:lB}),behaviours:[`settings.read.returns-the-addon-store`]},"settings.write":{input:b({patch:lB}),output:b({}),behaviours:[`settings.write.merges-and-keeps-other-keys`]},"settings.deleteKeys":{input:b({keys:S(u().min(1))}),output:b({removed:S(u())}),behaviours:[`settings.deleteKeys.removes-only-the-named-keys`]},"deviceSettings.listIds":{input:b({}),output:b({deviceIds:S(r().int())}),behaviours:[`deviceSettings.listIds.names-only-the-addons-own-devices`]},"deviceSettings.read":{input:b({deviceIds:S(r().int())}),output:b({blobs:h(u(),lB)}),behaviours:[`deviceSettings.read.returns-only-the-addons-own-blobs`]},"secrets.resolve":{input:b({refs:S(u())}),output:b({values:h(u(),u().nullable())}),behaviours:[`secrets.resolve.answers-null-for-a-missing-ref`]},"secrets.put":{input:b({ref:u().min(1),value:u()}),output:b({}),behaviours:[`secrets.put.stores-under-the-owner`]},"secrets.delete":{input:b({refs:S(u())}),output:b({deleted:r().int().nonnegative()}),behaviours:[`secrets.delete.ignores-unknown-refs`]},"integrations.list":{input:b({}),output:b({integrations:S(mB)}),behaviours:[`integrations.list.lists-every-integration`]},"integrations.get":{input:b({id:u().min(1)}),output:mB.nullable(),behaviours:[`integrations.get.null-for-an-unknown-id`]},"devices.list":{input:b({addonId:u().min(1),integrationId:u().min(1).optional()}),output:b({devices:S(oCe)}),behaviours:[`devices.list.scoped-to-the-addon`,`devices.list.filters-by-integration`]},"devices.get":{input:b({deviceId:r().int()}),output:b({id:r().int(),integrationId:u().nullable(),hasConfig:v()}).nullable(),behaviours:[`devices.get.null-for-an-unknown-id`,`devices.get.reports-link-and-config`]},"devices.aliases":{input:b({deviceIds:S(r().int())}),output:b({aliases:h(u(),u())}),behaviours:[`devices.aliases.answers-for-the-named-ids-only`]},"devices.setIntegrationId":{input:b({deviceId:r().int(),integrationId:u().min(1)}),output:b({}),behaviours:[`devices.setIntegrationId.links-the-device`]},"node.localNodeId":{input:b({}),output:b({nodeId:u()}),behaviours:[`node.localNodeId.names-this-node`]},"log.info":{input:gB,output:b({}),behaviours:[`log.info.writes-a-line`]},"log.warn":{input:gB,output:b({}),behaviours:[`log.warn.writes-a-line`]}},_B={name:`migrations`,scope:`system`,mode:`singleton`,internal:!0,methods:{listLedger:E(b({}),b({entries:S(Wo)}),{auth:`admin`}),listPending:E(b({owner:u().optional()}),b({pending:S(kie)}),{auth:`admin`}),dryRun:E(b({id:u().min(1)}),Aie,{auth:`admin`}),markFailed:E(b({id:u().min(1),error:u().min(1)}),Wo,{kind:`mutation`,auth:`admin`}),retry:E(b({id:u().min(1)}),b({entries:S(Wo)}),{kind:`mutation`,auth:`admin`}),restorePreMigration:E(b({database:Po,snapshotId:u().min(1)}),b({scheduled:v(),held:S(u()),restartRequired:v()}),{kind:`mutation`,auth:`admin`}),declareOwner:E(b({owner:u().min(1),metas:S(Ro),retired:S(u().min(1)).optional()}),b({bootId:u(),snapshot:x([`none`,`written`,`refused`]),steps:S(Go),migrationApi:hB.optional()}),{kind:`mutation`,auth:`admin`}),startMigration:E(b({id:u().min(1)}),b({proceed:v(),state:g([m(`pending`),Uo]),reason:u().nullable()}),{kind:`mutation`,auth:`admin`}),finishMigration:E(b({id:u().min(1),result:Ho}),b({status:Uo,error:u().nullable(),rowsChanged:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),readLegacyIntegrationRows:E(b({integrationId:u().min(1)}),h(u(),C()),{auth:`admin`}),clearLegacyIntegrationRows:E(b({integrationId:u().min(1)}),b({rows:r().int().nonnegative(),secrets:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),patchLegacyIntegrationRows:E(b({integrationId:u().min(1),patch:h(u(),C())}),b({written:v()}),{kind:`mutation`,auth:`admin`}),deleteLegacyIntegrationRowKeys:E(b({integrationId:u().min(1),keys:S(u().min(1))}),b({present:v(),removed:h(u(),C())}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},vB=b({sourceUrl:u(),metadata:Qd,targets:S(Zd).min(1).readonly(),calibrationRef:u().optional(),sessionId:u().optional()}),yB={name:`model-convert`,scope:`system`,mode:`singleton`,internal:!0,methods:{convert:E(vB,ef,{kind:`mutation`,auth:`admin`,timeoutMs:6e5})},vocabulary:{notOperatorFacing:O.ML}},bB=b({targetNodeId:u(),modelId:u(),format:x(Ld),entry:Xd}),xB=b({ok:v(),sha256:u(),bytes:r(),path:u()}),SB={name:`model-distributor`,scope:`system`,mode:`singleton`,internal:!0,methods:{distributeModel:E(bB,xB,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.ML}},CB=a(`kind`,[b({kind:m(`camera`)}),b({kind:m(`sensor`),deviceId:r().int().positive()})]),wB=Object.freeze({kind:`camera`});function cCe(e){if(e===void 0)return{triggeredBy:wB,malformed:!1};let t=CB.safeParse(e);return t.success?{triggeredBy:t.data,malformed:!1}:{triggeredBy:wB,malformed:!0}}var lCe=`cameraSensors`,TB=b({addonId:u().min(1),stableId:u().min(1)});function EB(e){return`${e.addonId}/${e.stableId}`}var DB=x([`in-addition`,`confirm`,`replace`]),OB=`in-addition`,kB=TB.extend({mode:DB.default(OB)}),AB=b({sensors:S(kB).min(1).max(8)}).superRefine((e,t)=>{let n=new Set;e.sensors.forEach((e,r)=>{let i=EB(e);n.has(i)&&t.addIssue({code:`custom`,path:[`sensors`,r],message:`duplicate camera sensor ${i}`}),n.add(i)})}),jB={addonId:u(),stableId:u(),mode:DB.default(OB)},MB=a(`state`,[b({...jB,state:m(`ready`),deviceId:r(),name:u(),caps:S(u()).readonly()}),b({...jB,state:m(`offline`),deviceId:r(),name:u(),reason:x([`offline`,`disabled`])}),b({...jB,state:m(`missing`),reason:u()}),b({...jB,state:m(`unsupported`),deviceId:r(),name:u(),reason:u()}),b({...jB,state:m(`unreadable`),reason:u()})]),NB=x([`onboard-not-listed`,`no-active-detection`]),PB=x([`always`,`when-confirmed`,`never`]),FB=x([`provider-not-split`]),IB=b({detected:v(),atMs:r()}),LB=a(`state`,[b({state:m(`not-configured`),cameraLevel:IB.optional()}),b({state:m(`unreadable`),reason:u(),cameraLevel:IB.optional()}),b({state:m(`configured`),cameraLevel:IB.optional(),sensors:S(MB).readonly(),cameraMotion:PB.optional(),notForwarded:NB.optional(),notEnforced:FB.optional()})]),RB=Object.freeze({state:`unreadable`,reason:`camera sensor mappings not loaded`}),zB=b({bbox:ny,pixelCount:r(),intensity:r()}),BB=b({detected:v(),regionCount:r(),regions:S(zB).readonly(),rawRegions:S(zB).readonly(),frameWidth:r(),frameHeight:r(),analysisMs:r()}),VB={name:`motion-detection`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{analyze:E(b({deviceId:r(),frame:ty.optional(),frameHandle:mc.optional()}),BB,{role:`admin`,kind:`mutation`,notOperatorFacing:`the pipeline feeds it frames — an internal stage, never called by a person`}),removeCamera:E(b({deviceId:r()}),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping when a camera leaves`}),reset:E(_(),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping`})},events:{onMotion:{data:b({deviceId:r(),detected:v(),regionCount:r()}),notOperatorFacing:"the analyzer’s raw verdict; the operator signal is the `motion` cap’s `detected` state"}},vocabulary:{noun:I(`Motion analysis`,`Analisi del movimento`),order:3160}},HB=b({package:v(),confidence:r().min(0).max(1),reason:u().min(1)}),UB=b({x:r(),y:r()}),WB=b({kind:m(`rect`),x:r(),y:r(),width:r(),height:r()}),GB=b({kind:m(`polygon`),points:S(UB)}),KB=b({kind:m(`grid`),gridWidth:r().meta(k(`none`)),gridHeight:r().meta(k(`none`)),cells:S(v())}),qB=b({kind:m(`line`),points:S(UB)}),uCe=a(`kind`,[WB,GB,KB,qB]),JB=x([`rect`,`polygon`,`grid`,`line`]),YB=b({min:r(),max:r()}),XB=b({width:r(),height:r()}),ZB=[`owner-not-ready`,`store-read-failed`,`three-way-read-unavailable`,`invalid-stored`,`not-cluster-scoped`],QB=[{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)`}]}],dCe=`cluster-step-models`;function $B(e){return`clusterModel:${e}`}function fCe(e){return QB.some(t=>t.stepId===e)}var eV=Object.freeze(Object.fromEntries(QB.map(e=>[e.stepId,e.defaultModelId])));function tV(e){return e==null||e===``?{kind:`absent`}:typeof e==`string`?{kind:`chosen`,modelId:e}:{kind:`invalid`,value:e}}function nV(e){let t=[];for(let n of QB){let r=tV(e[$B(n.stepId)]);r.kind===`invalid`&&t.push({stepId:n.stepId,value:r.value})}return t}function rV(e){let t={};for(let n of QB){let r=tV(e[$B(n.stepId)]);t[n.stepId]=r.kind===`chosen`?r.modelId:n.defaultModelId}return t}function pCe(e){return typeof e==`object`&&!!e&&`key`in e}function iV(e){return e===null?eV:rV(oV(e,aV()))}function mCe(e){return e===null?[]:nV(oV(e,aV()))}function aV(){return new Set(QB.map(e=>$B(e.stepId)))}function oV(e,t){let n={};for(let r of e.sections)for(let e of r.fields)!pCe(e)||typeof e.key!=`string`||t.has(e.key)&&(n[e.key]=e.value);return n}function hCe(e,t){let n=QB.find(t=>t.stepId===e);if(n===void 0)return null;let r=t[e];return r!==void 0&&r!==``?r:n.defaultModelId}var sV=[{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 cV(e,t){return`clusterStepSetting:${e}:${t}`}function lV(e){return sV.filter(t=>t.stepId===e)}var gCe=r().finite();function uV(e){let t={};for(let n of sV){let r=gCe.safeParse(e[cV(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 dV=uV({});function fV(e){return e===null?dV:uV(oV(e,new Set(sV.map(e=>cV(e.stepId,e.key)))))}function _Ce(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 pV=x([`new`,`entered`,`left`,`moving`,`idle`]),mV=x([`motion`,`object`,`audio`]),hV=a(`kind`,[WB,GB]),gV=x([`motion`,`audio`,`person`,`vehicle`,`animal`,`door`,`pir`,`smoke`,`water`,`button`,`package`,`generic`]),_V=x([`motion`,`audio`,`detection`,`sensor`,`control`,`custom`,`package`]),vCe=x([`macro`,`sub`]),vV=b({kind:u(),labelKey:u(),label:u(),color:u(),iconId:u(),icon:gV,category:_V,parentKind:u().nullable(),level:vCe,source:b({capName:u(),deviceId:r()})}),yV=b({deviceId:r(),kinds:S(vV).readonly()}),bV=b({id:u(),deviceId:r(),sourceDeviceId:r(),kind:u(),value:h(u(),C()).nullable(),timestamp:r()}),xV=b({x:r(),y:r(),timestamp:r(),bbox:ny,source:x([`frame`,`recovery`]).optional(),score:r().optional()}),yCe=b({timestamp:r(),position:xV,mediaId:r().int()}),SV=b({minX:r(),minY:r(),maxX:r(),maxY:r()}),CV=x([`full`,`slim`]),wV=b({label:u(),peakScore:r(),count:r(),firstAt:r(),lastAt:r()}),TV=x([`pipeline`,`onboard`,`sensor`,`audio`]),EV=x([`none`,`staging`,`trained`]),DV={markForTrain:v().optional(),debug:v().optional(),debugNote:u().max(500).optional(),favourited:v().optional()},OV={retrainStatus:EV.optional()},kV=b(DV),AV=b({trackId:u(),markForTrain:v(),debug:v(),debugNote:u(),favourited:v(),retrainStatus:EV}),bCe=g([m(1),m(2)]),jV=b({stepId:u(),modelId:u().optional(),decidedAt:r(),identityId:u().optional()}),MV={label:u().optional(),labelScore:r().optional(),labelMeta:jV.optional(),subLabel:u().optional(),subLabelScore:r().optional(),subLabelMeta:jV.optional()},NV=b({deviceId:r(),tracks:r().int(),files:r().int(),bytes:r().int()}),PV=b({generatedAt:r(),trackCount:r().int(),fileCount:r().int(),byteCount:r().int(),truncated:v(),devices:S(NV).readonly()}),FV=b({nodeId:u(),deviceKey:u().optional(),modelId:u().optional()}),IV=b({trackId:u(),deviceId:r(),className:u(),...MV,producingDeviceName:u().optional(),source:TV.optional(),firstSeen:r(),lastSeen:r(),positions:S(xV).readonly(),snapshots:S(yCe).readonly(),zonesVisited:S(u()).readonly(),zoneNames:S(u()).readonly().optional(),classes:S(u()).readonly().optional(),totalDistance:r(),state:pV,active:v(),importance:r().optional(),bestEventId:u().optional(),importanceReason:u().optional(),audioLabels:S(wV).readonly().optional(),envelope:SV.optional(),hasFace:v().optional(),hasEmbeddedFace:v().optional(),hasRider:v().optional(),previewMissReason:u().optional(),modelId:u().optional(),openedPlacement:FV.optional(),closedPlacement:FV.optional(),frameWidth:r().optional(),frameHeight:r().optional(),...DV,...OV}),LV={id:r().int(),deviceId:r(),timestamp:r()},RV=b({...LV,kind:m(`motion`),regionCount:r(),regions:S(b({bbox:ny,pixelCount:r(),intensity:r()})).readonly().optional(),frameWidth:r().optional(),frameHeight:r().optional(),mediaUrl:u().optional(),triggeredBy:CB.optional(),durationMs:r().nullable().optional(),edges:S(r()).readonly().optional()}),zV=x([`pipeline`,`onboard`]),BV=x([`enter`,`exit`]),VV=b({direction:BV,zoneId:u(),zoneName:u().optional()}),xCe=b({zoneId:u(),zoneName:u().optional(),overlapPct:r()}),HV=b({...LV,kind:m(`object`),source:zV.optional(),frameId:u().optional(),idempotencyKey:u().optional(),trackId:u().optional(),className:u(),...MV,confidence:r().optional(),bbox:ny.optional(),zones:S(u()).readonly().optional(),zoneOverlaps:S(xCe).readonly().optional(),spawnRefused:u().optional(),state:pV.optional(),zoneCrossing:VV.optional(),frameWidth:r().optional(),frameHeight:r().optional(),mediaId:r().int().optional(),keyFrameMediaId:r().int().optional(),mediaUrl:u().optional(),observedAt:r().optional(),packagePossible:v().optional(),packageLlmVerdict:HB.optional(),importance:r().optional()}),UV=b({...LV,kind:m(`audio`),rms:r(),dbfs:r(),classification:b({className:u(),originalClass:u().optional(),score:r()}).optional(),classifyOutcome:sy.optional(),mediaUrl:u().optional()}),WV=x([`crop`,`thumbnail`,`snapshot`,`firstFrame`,`lastFrame`,`fullFrame`,`fullFrameBoxed`,`faceCrop`,`plateCrop`,`keyFrame`,`keyFrameSmall`,`thumbnailSmall`,`confirmationCrop`,`debugCrop`,`sceneFrame`,`lastSceneFrame`]),GV=b({mediaId:r().int(),kind:WV,sizeBytes:r(),timestamp:r()}),KV=GV.extend({url:u(),base64:u()}),qV=KV.omit({base64:!0}),JV=x([`person`,`vehicle`,`animal`,`package`,`face`,`plate`]),YV=x([`subject`,`model_error`]),XV=x([`operator`,`assist`,`pipeline`,`llm`]),ZV=b({x:r(),y:r(),w:r(),h:r()}),QV=b({source:XV,ref:u().min(1),bbox:ZV,macroClass:JV,label:u().optional(),score:r().optional(),modelId:u().optional()}),$V=b({ref:u().min(1),snapshot:QV}),eH=x(gs),tH=b({ref:u(),savedId:u().optional(),status:eH,approximate:v(),origin:QV.optional(),macroClass:JV.optional(),label:u().optional(),iou:r().optional()}),nH=b({boxes:S(tH).readonly(),summary:b({counts:h(eH,r().int()),total:r().int(),changed:r().int(),approximate:v()})}),rH=b({id:u(),trackId:u().optional(),deviceId:r(),mediaKey:u(),bbox:ZV,macroClass:JV,label:u().optional(),subLabel:u().optional(),kind:YV,source:XV,assistModelId:u().optional(),assistScore:r().optional(),origin:QV.nullable().optional(),exportedInBatch:u().optional(),createdAt:r()}),iH=rH.omit({id:!0,trackId:!0,deviceId:!0,mediaKey:!0,createdAt:!0,exportedInBatch:!0}),aH=x([`correct`,`wrong`,`wrong-label`]),oH=b({verdict:aH,suggestedClass:u().optional(),suggestedMacroClass:JV.optional(),suggestedLabel:u().optional(),trackId:u(),at:r().optional()}),sH=b({trackId:u(),className:u(),label:u().optional(),bbox:ZV.optional(),verdict:aH,suggestedClass:u().optional(),at:r().optional()}),cH=b({trackId:u(),deviceId:r(),className:u(),label:u().optional(),firstSeen:r(),lastSeen:r(),frameCount:r().int(),annotationCount:r().int(),verdict:oH.optional()}),lH=b({mediaId:r().int(),kind:WV,timestamp:r(),sizeBytes:r().int(),copied:v()}),uH=b({bbox:ZV,macroClass:JV,label:u().optional(),subLabel:u().optional(),score:r().optional(),modelId:u().optional(),trackId:u(),basis:x([`subject-box`,`position`,`verdict`]),deltaMs:r()}),dH=x([`track`,`recording`]),fH=b({frameId:u(),deviceId:r(),origin:dH,trackId:u().optional(),sourceMediaId:r().int().optional(),epochMs:r().optional(),sourceKind:WV,sizeBytes:r().int(),width:r().int(),height:r().int(),copiedAt:r(),capturedAt:r().optional(),complete:v(),pipelineBoxes:S(uH).readonly().optional(),collectionIds:S(u()).readonly().optional(),verdict:oH.optional(),revision:r().int().optional(),dismissed:S($V).readonly().optional(),review:nH.optional(),imageUrl:u().optional(),thumbnailUrl:u().optional()}),pH=x([`source-missing`,`unreadable-image`,`write-failed`]),mH=b({copied:S(fH).readonly(),refused:S(b({sourceMediaId:r().int(),reason:pH})).readonly()}),hH=b({candidates:S(lH).readonly(),copies:S(fH).readonly(),autoPickMediaId:r().int().optional()}),gH=x([`unannotated`,`annotated`,`complete`]),_H=b({workState:gH.optional(),deviceIds:S(r()).max(500).optional(),collectionId:u().optional(),classes:S(JV).optional(),page:r().int().positive().default(1),pageSize:r().int().positive().max(100).default(50)}),vH=fH.extend({workState:gH}),yH=b({frames:S(vH).readonly(),total:r().int().nonnegative(),page:r().int().positive(),pageSize:r().int().positive()}),bH=b({deviceId:r(),unannotated:r().int().nonnegative(),annotated:r().int().nonnegative(),complete:r().int().nonnegative(),pctOfCorpus:r().min(0).max(1).nullable()}),xH=b({total:r().int().nonnegative(),unannotated:r().int().nonnegative(),annotated:r().int().nonnegative(),complete:r().int().nonnegative(),cameras:S(bH).readonly()}),SH=b({deviceIds:S(r()).optional(),frameIds:S(u()).max(2e4).optional(),collectionIds:S(u()).max(200).optional(),collectionId:u().optional(),batchId:u().optional(),completeOnly:v().optional(),workState:gH.optional(),classes:S(JV).optional()}),CH=x([`frames`,`crops`]),wH=b({kind:m(`http`),method:x([`PUT`,`POST`]),url:u().url(),headers:h(u(),u()).optional()}),TH=b({batchId:u(),frames:r().int(),crops:r().int(),annotations:r().int(),missing:r().int(),bytes:r().int(),sha256:u(),status:r().int()}),EH=a(`kind`,[b({kind:m(`package`),zone:ZV.optional()}),b({kind:m(`objects`),modelId:u(),minScore:r().optional()})]),DH=a(`kind`,[b({kind:m(`proposed`),modelId:u(),stepId:u(),minScore:r(),proposals:S(iH).readonly(),belowThreshold:r().int()}),b({kind:m(`refused`),reason:u(),detail:u().optional()})]),OH=b({id:u(),name:u(),createdAt:r(),frameCount:r().int()}),kH=a(`kind`,[b({kind:m(`created`),collection:OH}),b({kind:m(`refused`),reason:x([`empty-name`,`duplicate-name`])})]),AH=a(`kind`,[b({kind:m(`renamed`),collection:OH}),b({kind:m(`refused`),reason:x([`empty-name`,`duplicate-name`,`unknown-collection`])})]),jH=a(`kind`,[b({kind:m(`added`),collectionId:u(),frame:fH,reused:v()}),b({kind:m(`refused`),reason:x([`unknown-collection`,`still-unavailable`,`still-busy`,`unreadable-image`,`write-failed`]),detail:u().optional()})]),MH=b({id:u(),name:u(),model:u(),kind:u(),leavesHouse:v()}),NH=iH.extend({reason:u()}),PH=b({ref:u(),verdict:x([`confirmed`,`wrong-class`,`not-an-object`,`uncertain`]),suggestedClass:JV.optional(),reason:u()}),FH=a(`kind`,[b({kind:m(`proposed`),profileId:u(),model:u(),leftHouse:v(),proposals:S(NH).readonly(),reviews:S(PH).readonly(),rejected:r().int()}),b({kind:m(`refused`),reason:x([`unknown-frame`,`unreadable-frame`,`unknown-profile`,`profile-disabled`,`no-vision`,`cloud-not-confirmed`,`llm-error`,`malformed-answer`]),detail:u().optional()})]),IH=b({deviceIds:S(r()).readonly().optional(),collectionIds:S(u()).max(200).readonly().optional(),frameIds:S(u()).max(2e4).readonly().optional()}),LH=b({frames:r().int(),completeFrames:r().int(),completeness:r(),subjects:r().int(),modelErrors:r().int(),hardNegatives:r().int(),cells:S(b({macroClass:u(),deviceId:r(),lighting:x([`day`,`night`,`unknown`]),subjects:r().int(),frames:r().int()})).readonly(),cameras:S(b({deviceId:r(),frames:r().int(),completeFrames:r().int()})).readonly()}),SCe=b({id:u(),name:u(),createdAt:r(),selection:IH,layout:CH,completeOnly:v(),frameCount:r().int(),annotationHash:u(),manifestSchema:u(),stats:LH}),RH=b({collectionIds:S(u()).min(1),workState:x([`complete`,`annotated_or_complete`,`any_annotated`]).default(`complete`)}),zH=a(`kind`,[b({kind:m(`resolved`),frameIds:S(u()).max(2e4).readonly(),stats:LH,annotationHash:u(),layout:CH}),b({kind:m(`refused`),reason:x([`unknown-collection`,`no-frames`]),detail:u()})]),BH=b({trackId:u(),retrainStatus:EV,changed:v(),reason:x([`unknown-track`,`no-frames-copied`,`not-staging`,`not-trained`,`unchanged`]).optional()}),VH=1e3,HH=5e3,UH=b({deviceId:r(),since:r().optional(),until:r().optional(),limit:r().int().min(1).max(HH).default(VH),projection:x([`full`,`slim`]).optional()}),CCe=UH.extend({classFilter:u().optional()}),WH=b({deviceIds:S(r()),since:r().optional(),until:r().optional(),limit:r().int().min(1).max(1e3).default(200),cursor:u().optional(),projection:CV.optional(),includeStationary:v().optional(),classes:S(u()).optional(),excludeSources:S(TV).optional()}),GH=b({tracks:S(IV).readonly(),nextCursor:u().nullable()}),KH=50,qH=200,wCe=b({deviceId:r(),since:r(),until:r(),limit:r().int().min(1).max(qH).default(KH),minImportance:r().min(0).max(1).optional(),classFilter:u().optional()}),JH=b({id:u(),trackId:u(),timestamp:r(),className:u(),...MV,importance:r(),bestEventId:u(),windowMs:r().optional(),audioLabels:S(wV).readonly().optional(),...DV,...OV}),TCe=b({deviceIds:S(r()).min(1).max(200),since:r(),until:r(),limit:r().int().min(1).max(qH).default(KH),minImportance:r().min(0).max(1).optional(),classFilter:u().optional()}),ECe=b({deviceId:r(),events:S(JH).readonly()}),YH=b({bucketStart:r(),motion:r().int(),object:r().int(),audio:r().int(),audioDbfs:r().optional()}),XH=b({deviceId:r(),read:x([`read`,`unreadable`]),buckets:S(YH).readonly()}),DCe=b({trackId:u(),className:u(),confidence:r(),bbox:ny,zones:S(u()).readonly(),state:pV}),OCe=le({id:u(),kind:x([`first-level`,`detail`]),macroClass:u(),score:r(),bbox:b({x:r(),y:r(),width:r(),height:r()}),labels:S(le({label:u(),score:r()})).readonly(),parentId:u().optional()}),ZH=HV.extend({score:r()}),kCe=b({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:gd.optional(),modelId:u().min(1).optional()}),QH=b({tracks:r().int(),events:r().int(),media:r().int(),faces:r().int(),plates:r().int(),embeddings:r().int()}),ACe=b({mediaDropped:r().int(),tracks:r().int(),events:r().int()}),jCe=b({deviceId:r(),rows:r().int(),bytes:r().int()}),MCe=b({totalRows:r().int(),totalBytes:r().int(),devices:S(jCe).readonly()}),NCe=b({kind:WV,rows:r().int(),bytes:r().int()}),PCe=b({totalRows:r().int(),totalBytes:r().int(),kinds:S(NCe).readonly(),unaccountedRows:r().int(),unaccountedBytes:r().int()}),$H=b({motion:r().int(),object:r().int(),audio:r().int()}),FCe=b({deviceId:r().optional(),since:r().optional(),until:r().optional(),maxTracks:r().int().positive().optional(),executeOnNodeId:u().optional(),pacingMs:r().int().nonnegative().optional(),force:v().optional()}),ICe=b({deleted:r(),failedIndexes:S(u()).optional()}),eU=x([`stores-unavailable`,...ZB,`method-unavailable`,`read-failed`,`reads-disagree`,`not-a-clip-model`,`force-requires-max-tracks`]),LCe=b({started:v(),alreadyRunning:v(),refusal:eU.optional(),modelId:u().optional(),index:u().optional()}),RCe=b({running:v(),scanned:r(),rebuilt:r(),missingKeyFrame:r(),missingEvent:r(),missingBbox:r(),boxSource:b({subjectBox:r(),positions:r(),event:r(),refused:r()}),alreadyInSpace:r(),force:v().nullable(),forcedInSpace:r(),notRunnable:r(),noCapableNode:r(),failed:r(),complete:v().nullable(),startedAtMs:r().nullable(),finishedAtMs:r().nullable(),error:u().nullable(),modelId:u().nullable(),index:u().nullable()}),zCe=b({started:v(),alreadyRunning:v()}),BCe=b({mode:x([`report`,`reclaim`]).default(`report`),scopes:S(x([`motion-still`,`track-filmstrip`])).min(1).optional(),deviceIds:S(r().int()).min(1).optional(),restart:v().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()}),VCe=b({running:v(),mode:x([`report`,`reclaim`]).nullable(),totalExamined:r(),totalEligible:r(),totalReclaimed:r(),totalBytesReclaimed:r(),totalRefused:r(),devicesDone:r(),complete:v().nullable(),startedAtMs:r().nullable(),finishedAtMs:r().nullable(),error:u().nullable()}),tU=x([`motion`,`audio-dbfs`,`battery`,`occupancy`]);function HCe(e,t){let n=e??``;return t===void 0?n:`${n}|${t}`}function nU(e){let t=e.indexOf(`|`);return t<0?{zoneId:e}:{zoneId:e.slice(0,t),className:e.slice(t+1)}}var rU=b({scope:u(),bucketStart:r().int(),samples:r().int().nonnegative(),sum:r(),min:r(),max:r()}),iU={name:`pipeline-analytics`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],exposesDeviceSettings:!0,methods:{getActiveTracks:E(b({deviceId:r()}),S(IV).readonly()),getTrack:E(b({deviceId:r(),trackId:u()}),IV.nullable()),listTracks:E(b({deviceId:r(),since:r().optional(),until:r().optional(),limit:r().optional(),zone:hV.optional(),projection:CV.optional(),includeStationary:v().optional(),classes:S(u()).optional(),excludeSources:S(TV).optional()}),S(IV).readonly()),listRecentTracks:E(WH,GH),clearTracks:E(b({deviceId:r()}),_(),{kind:`mutation`,auth:`admin`}),getMotionEvents:E(UH,S(RV).readonly()),getObjectEvents:E(CCe,S(HV).readonly()),getAudioEvents:E(UH,S(UV).readonly()),listEventKinds:E(b({deviceId:r()}),S(vV).readonly()),listEventKindsBatch:E(b({deviceIds:S(r()).min(1).max(200)}),S(yV).readonly()),getSensorEvents:E(b({deviceId:r(),since:r().optional(),until:r().optional(),kinds:S(u()).optional(),limit:r().int().min(1).max(HH).default(VH)}),S(bV).readonly()),getKeyEvents:E(wCe,S(JH).readonly()),getKeyEventsBatch:E(TCe,S(ECe).readonly()),readLongTermSeries:E(b({deviceId:r(),series:tU,scope:u().optional(),from:r(),to:r(),limit:r().int().positive().optional()}),S(rU).readonly()),getEventDensity:E(b({deviceId:r(),since:r(),until:r(),bucketMs:r().int().positive()}),S(YH).readonly()),getEventDensityBatch:E(b({deviceIds:S(r()).min(1).max(200),since:r(),until:r(),bucketMs:r().int().positive()}),S(XH).readonly()),pruneEventsBefore:E(b({deviceId:r(),cutoffMs:r()}),b({motion:r().int(),object:r().int(),audio:r().int()}),{kind:`mutation`,auth:`admin`}),pruneTracksBefore:E(b({deviceId:r(),cutoffMs:r()}),QH,{kind:`mutation`,auth:`admin`}),wipeAllAnalytics:E(b({deviceId:r()}),QH,{kind:`mutation`,auth:`admin`}),reconcileFromDisk:E(b({deviceId:r()}),ACe,{kind:`mutation`,auth:`admin`}),deleteTracks:E(b({deviceId:r(),trackIds:S(u()).min(1)}),b({deleted:r().int(),failed:S(u()).readonly(),sparedMediaIds:S(r().int()).readonly().optional()}),{kind:`mutation`,auth:`admin`}),setTrackFlags:E(b({deviceId:r(),trackId:u(),flags:kV}),AV,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listArchivedDebugNotes:E(Ds,S(Es).readonly(),{kind:`query`}),setTrackRelation:E(Ns,js,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),clearTrackRelation:E(Ps,Fs,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),setTrackPurity:E(Is,Ls,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listTrackRelations:E(Rs,zs,{kind:`query`}),listBirthDecisions:E(Ts,S(ws).readonly(),{kind:`query`}),getEventStoreFootprint:E(b({}),MCe,{kind:`query`,auth:`admin`}),getEventMediaFootprintByKind:E(b({deviceId:r().int().optional()}),PCe,{kind:`query`,auth:`admin`}),pruneEvents:E(b({olderThanMs:r(),reason:qs.optional()}),$H,{kind:`mutation`,auth:`admin`}),deleteDeviceEvents:E(b({deviceId:r()}),$H,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:E(Yc,b({paused:m(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:E(Yc,b({resumed:m(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:E(Yc,b({refreshed:m(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:E(il,b({jobId:u()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:E(b({jobId:u()}),Kc.nullable(),{auth:`admin`}),cancelStorageMigrationMove:E(b({jobId:u()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),relocateMedia:E(Qc,b({jobId:u()}),{kind:`mutation`,auth:`admin`}),countUnstampedEventMedia:E(b({}),el,{auth:`admin`}),getMediaLocationCensus:E(tl,rl,{kind:`query`,auth:`admin`}),countRelocatableMedia:E(Al,kl,{kind:`query`,auth:`admin`}),listRelocateMediaJobs:E(b({}),S(Kc).readonly(),{kind:`query`,auth:`admin`}),cancelRelocateMedia:E(b({jobId:u()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),listOpsLog:E(Ys,S(Js).readonly(),{kind:`query`,auth:`admin`}),reclaimDebugMedia:E(BCe,zCe,{kind:`mutation`,auth:`admin`}),getMediaReclaimStatus:E(b({}),VCe,{kind:`query`,auth:`admin`}),getTrainingExportSummary:E(b({deviceIds:S(r()).optional()}),PV,{kind:`query`,auth:`admin`}),getTrainingExportUrl:E(b({deviceIds:S(r()).optional()}),b({url:u()}),{kind:`query`,auth:`admin`}),listRetrainStaging:E(b({deviceIds:S(r()).optional(),limit:r().int().min(1).max(500).optional()}),S(cH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainCorpusPage:E(_H,yH,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getRetrainCorpusKpi:E(b({}),xH,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainFrames:E(b({trackId:u()}),hH,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),selectRetrainFrames:E(b({deviceId:r(),trackId:u(),mediaIds:S(r().int()).min(1)}),mH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deselectRetrainFrame:E(b({deviceId:r(),trackId:u().optional(),frameId:u()}),b({removed:v(),removedAnnotations:r().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainFrameImage:E(b({frameId:u()}),b({base64:u(),width:r().int(),height:r().int()}),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotations:E(b({deviceId:r(),trackId:u().optional(),frameId:u(),subject:EH,nodeId:u().optional()}),DH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainAnnotations:E(b({trackId:u().optional(),frameIds:S(u()).max(2e3).optional()}),S(rH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),saveRetrainAnnotations:E(b({deviceId:r(),trackId:u().optional(),frameId:u(),annotations:S(iH),expectedRevision:r().int().optional(),dismissed:S($V).optional()}),S(rH).readonly(),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),backfillRetrainOrigins:E(b({deviceId:r(),trackId:u().optional(),frameId:u(),expectedRevision:r().int().optional(),origins:S(b({annotationId:u(),origin:QV})).min(1).max(500)}),b({updated:r().int(),skipped:r().int(),revision:r().int()}),{kind:`mutation`,auth:`admin`}),completeRetrainTrack:E(b({deviceId:r(),trackId:u()}),BH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),restageRetrainTrack:E(b({deviceId:r(),trackId:u()}),BH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainExportUrl:E(SH.extend({layout:CH.optional()}),b({url:u()}),{kind:`query`,auth:`admin`}),setRetrainFrameComplete:E(b({deviceId:r(),trackId:u().optional(),frameId:u(),complete:v()}),fH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),writeRetrainArchive:E(b({filter:SH,layout:CH,target:wH}),TH,{kind:`mutation`,auth:`admin`,timeoutMs:60*6e4}),offerRetrainArchive:E(b({filter:SH,layout:CH}),b({ticket:Xa,frames:r().int(),annotations:r().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),listRetrainAssistProfiles:E(b({}),S(MH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotationsWithLlm:E(b({deviceId:r(),trackId:u().optional(),frameId:u(),profileId:u(),classes:S(JV).min(1),boxes:S(b({ref:u(),bbox:ZV,macroClass:JV,label:u().optional()})).max(50),allowCloud:v()}),FH,{kind:`mutation`,auth:`admin`,timeoutMs:18e4}),createRetrainCollection:E(b({name:u().max(120)}),kH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollections:E(b({}),S(OH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),resolveRetrainTrainingCorpus:E(RH,zH,{kind:`query`,auth:`admin`,timeoutMs:6e4}),renameRetrainCollection:E(b({id:u(),name:u().max(120)}),AH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deleteRetrainCollection:E(b({id:u()}),b({deleted:v(),removedFrames:r().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),addRetrainFrameFromRecording:E(b({collectionId:u(),deviceId:r(),epochMs:r(),verdictSubject:sH.optional()}),jH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`,timeoutMs:6e4}),addRetrainFramesToCollection:E(b({collectionId:u(),frameIds:S(u()).min(1).max(500)}),b({added:r().int(),alreadyMember:r().int(),unknownFrameIds:S(u()).readonly()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),removeRetrainFrameFromCollection:E(b({collectionId:u(),frameId:u()}),b({removed:v(),deletedFrame:v()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollectionFrames:E(b({collectionId:u()}),S(fH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getEventMedia:E(b({ownerType:Xe,eventId:r().int(),kind:WV.optional(),deviceId:r()}),S(KV).readonly()),getTrackMedia:E(b({trackId:u(),kinds:S(WV).optional(),deviceId:r()}),S(KV).readonly()),listTrackMedia:E(b({trackId:u(),deviceId:r()}),S(qV).readonly()),listEventMedia:E(b({ownerType:Xe,eventId:r().int(),deviceId:r()}),S(qV).readonly()),ownersWithMedia:E(b({deviceId:r(),ownerKind:Qe,ownerIds:S(u()).max(5e3)}),S(u()).readonly()),searchObjectEvents:E(kCe,S(ZH).readonly(),{caller:`required`}),wipeObjectEmbeddings:E(b({}),ICe,{kind:`mutation`,auth:`admin`}),rebuildObjectEmbeddings:E(FCe,LCe,{kind:`mutation`,auth:`admin`}),getObjectEmbeddingRebuildStatus:E(b({}),RCe)},events:{onFrameTracked:{data:b({deviceId:r(),timestamp:r(),frameWidth:r(),frameHeight:r(),detections:S(OCe).readonly()}),notOperatorFacing:`one tracker frame — stream rate, never an automation trigger`},onTrackStarted:{data:b({deviceId:r(),trackId:u(),className:u()}),trigger:{category:w.PipelineAnalyticsTrackStarted,label:I(`Subject appeared`,`Soggetto comparso`),phrase:I(`When {device} starts following a subject`,`Quando {device} inizia a seguire un soggetto`),icon:`scan-eye`}},onTrackEnded:{data:b({deviceId:r(),trackId:u(),className:u(),durationMs:r()}),trigger:{category:w.PipelineAnalyticsTrackEnded,label:I(`Subject left`,`Soggetto uscito`),phrase:I(`When a subject leaves the view of {device}`,`Quando un soggetto esce dall’inquadratura di {device}`),icon:`scan-eye`}},onDetectionEvent:{data:b({deviceId:r(),kind:mV,eventId:u(),timestamp:r()}),trigger:{category:w.PipelineAnalyticsDetectionEvent,label:I(`Detection event`,`Evento di rilevamento`),phrase:I(`When {device} records a detection event`,`Quando {device} registra un evento di rilevamento`),icon:`radar`}}},vocabulary:{noun:I(`Tracking`,`Tracciamento`),order:3200,extraEvents:[{category:w.PipelineAnalyticsPackageDelivered,label:I(`Package delivered`,`Pacco consegnato`),phrase:I(`When a package is left in front of {device}`,`Quando viene lasciato un pacco davanti a {device}`),icon:`package`},{category:w.PipelineAnalyticsPackagePickedUp,label:I(`Package picked up`,`Pacco ritirato`),phrase:I(`When a package is picked up in front of {device}`,`Quando viene ritirato un pacco davanti a {device}`),icon:`package-open`}]}},aU=o(()=>b({addonId:u(),modelId:u().optional(),enabled:v().default(!0),children:S(aU).optional(),settings:h(u(),C()).optional(),jumpDeviceKey:u().optional()})),oU=be(),sU=b({x:r(),y:r(),w:r(),h:r()}),cU=b({stepId:u(),modelId:u(),detections:S(b({bbox:d([r(),r(),r(),r()]),score:r(),landmarks:S(b({x:r(),y:r()})).optional()})).min(1)}),lU=b({handle:mc,cropFrameSpace:b({x:r(),y:r(),w:r(),h:r()})});b({crop:b({left:r(),top:r(),width:r().positive(),height:r().positive()}).optional(),content:b({width:r().int().positive(),height:r().int().positive()}),fit:x([`stretch`,`contain`]),format:x([`rgb`,`gray`,`jpeg`])});var UCe=b({registryId:u().min(1),id:u().min(1),width:r().int().positive(),height:r().int().positive(),format:x([`rgb`,`gray`]),timestamp:r(),capturedAt:r().optional()}),uU=x([`onnx`,`coreml`,`openvino`,`tflite`,`pt`,`gguf`]),dU=x([`detector`,`cropper`,`classifier`,`refiner`,`audio-classifier`]),fU=b({runtime:m(`python`),backend:u(),format:uU,device:u().optional()}),pU=b({deviceKey:u().nullable(),runtime:u(),batchMode:u(),windowMs:r(),maxBatchSize:r(),concurrency:r(),numWorkers:r()}),WCe=b({engine:fU,devices:S(b({id:u(),label:u(),description:u().optional()})).readonly(),defaultDevice:u()}),mU=o(()=>b({addonId:u(),addonName:u(),slot:dU,inputClasses:S(u()).readonly(),outputClasses:S(u()).readonly(),enabled:v(),modelId:u(),children:S(mU).readonly(),group:u().optional(),settings:h(u(),C()).optional()})),GCe=b({id:u(),name:u(),formats:h(u(),Vd),group:Wd.optional(),legacy:v().optional(),provider:Kd.optional(),defaultConfidence:r().optional(),suppliesSteps:S(Yd).readonly().optional()}),KCe=be(),qCe=b({id:u(),name:u(),slot:dU,inputClasses:S(u()).readonly(),outputClasses:S(u()).readonly(),childSlots:S(dU).readonly(),models:S(GCe).readonly(),defaultModelId:u(),defaultModelIdByFormat:h(u(),u()).optional(),enabledByDefault:v().optional(),defaultConfidence:r(),group:u().optional(),configSchema:S(KCe).readonly().optional()}),JCe=b({id:dU,label:u(),priority:r(),parentSlot:dU.nullable(),addons:S(qCe).readonly()}),YCe=b({availableEngines:S(WCe).readonly(),selectedEngine:fU,slots:S(JCe).readonly()}),XCe=b({runtimeId:x([`onnx`,`openvino`,`coreml`,`edgetpu`]).nullable(),device:u().nullable(),state:x([`idle`,`installing`,`verifying`,`ready`,`failed`]),progress:r().optional(),error:u().optional(),nextRetryAt:r().optional(),configIssues:S(u()).optional()}),hU=b({addonId:u(),chosen:u(),running:u(),format:u()}),gU=b({addonId:u(),kind:x([`unknown-addon`,`no-format-build`,`unknown-device`]),detail:u()}),_U=b({ok:v(),issues:S(gU).readonly(),substitutions:S(hU).readonly(),format:u()}),ZCe=b({filename:u(),stepIds:S(u()).readonly().optional()}),QCe=b({base64:u(),filename:u()}),$Ce=b({filename:u(),sizeKb:r()}),ewe=b({base64:u()}),twe=b({id:u(),name:u(),description:u(),available:v(),rawLabels:S(u()).readonly().optional()}),nwe=b({activeBackend:u(),availableBackends:S(twe).readonly(),sampleRate:r(),chunkDurationMs:r()}),rwe=b({filePath:u(),sizeMB:r(),durationMs:r()}),iwe=b({success:v(),error:u().optional(),frame:be().optional()}),awe=be(),owe=be(),swe=be(),cwe=be(),vU={name:`pipeline-executor`,scope:`system`,mode:`singleton`,methods:{getAvailableEngines:E(_(),S(fU)),getSelectedEngine:E(_(),fU),getEngineProvisioning:E(b({nodeId:u()}),XCe),getVideoPipelineSteps:E(_(),h(u(),b({modelId:u(),settings:h(u(),C()).readonly()}))),setVideoPipelineSteps:E(b({steps:h(u(),b({modelId:u(),settings:h(u(),C()).readonly()}))}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getInferenceDeviceHealth:E(b({nodeId:u()}),b({unhealthy:S(b({deviceKey:u(),state:x([`failed`,`backoff`]),since:r(),deaths:r(),lastError:u(),absentReason:x([`no-gpu-device`]).optional()})).readonly()})),rearmInferenceDevice:E(b({nodeId:u(),deviceKey:u()}),b({rearmed:v()}),{kind:`mutation`,auth:`admin`}),getSchema:E(_(),YCe),getOrchestratorConfigSchema:E(_(),awe),validatePipeline:E(b({steps:S(aU),deviceKey:u().optional()}),_U),getCapabilities:E(_(),swe),getAddonModels:E(b({addonId:u()}),cwe),downloadModel:E(b({addonId:u(),modelId:u(),format:uU}),rwe,{kind:`mutation`}),deleteModel:E(b({addonId:u(),modelId:u(),format:uU}),b({success:m(!0)}),{kind:`mutation`}),runPipeline:E(b({steps:S(aU).min(1),frame:ty.optional(),frameRef:UCe.optional(),frameHandle:mc.optional(),imageBase64:u().optional(),image:y(Uint8Array).optional(),referenceImage:u().optional(),deviceId:r().optional(),sessionId:u().optional(),plane:x([`full`,`frame`]).optional(),deviceKey:u().optional(),nativeCropRef:lU.optional(),replay:m(!0).optional(),suppliedRoot:cU.optional(),motionRegions:S(sU).optional()}),oU,{kind:`mutation`}),runPipelineBatch:E(b({steps:S(aU).min(1),frames:S(ty).min(1).max(255),deviceId:r().optional(),sessionId:u().optional(),frameId:r().int().nonnegative().optional(),deviceKey:u().optional()}),b({results:S(oU).readonly()}),{kind:`mutation`}),cacheFrameInPool:E(b({data:y(Uint8Array),width:r().int().positive(),height:r().int().positive(),format:x([`rgb`,`bgr`,`gray`])}),b({frameId:r(),width:r(),height:r()}),{kind:`mutation`}),inferCached:E(b({stepId:u(),frameId:r().int(),modelId:u().min(1)}),h(u(),C()),{kind:`mutation`}),uncacheFrame:E(b({frameId:r().int()}),_(),{kind:`mutation`}),getEffectiveTuning:E(b({deviceKey:u().optional()}),pU),listLoadedEngines:E(_(),S(b({engineKey:u(),engine:fU,modelsLoaded:S(u()).readonly(),inUseByCameras:S(r()).readonly(),kind:x([`runtime`,`device-pool`]),poolPid:r().nullable(),idleMs:r().nullable(),idleTtlMs:r().nullable()})).readonly()),spinEngine:E(b({engine:fU}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),killEngine:E(b({engine:fU,force:v().optional()}),b({success:v(),reason:u().optional()}),{kind:`mutation`,auth:`admin`}),listReferenceImages:E(_(),S(ZCe).readonly()),getReferenceImage:E(b({filename:u()}),QCe.nullable()),getReferenceAudioFiles:E(_(),S($Ce).readonly()),getReferenceAudio:E(b({filename:u()}),ewe.nullable()),getAudioCapabilities:E(_(),nwe),runAudioTest:E(b({addonId:u(),modelId:u(),filename:u().optional(),settings:h(u(),C()).optional()}),iwe,{kind:`mutation`}),getDetectionConfigSchema:E(_(),owe)},vocabulary:{notOperatorFacing:O.PIPELINE}},lwe=b({activeCameras:r(),throttledCameras:r(),avgInferenceTimeMs:r(),queueDepth:r()}),yU=b({detectionMode:x([`disabled`,`always-on`,`on-motion`]),configuredFps:r(),actualFps:r(),queueDepth:r(),avgInferenceTimeMs:r(),droppedFrames:r(),nativeCropMisses:r().optional(),phase:x([`idle`,`watching`,`active`])}),bU=yU.extend({deviceId:r()}),xU=x([`polygon`,`tripwire`]),SU=b({x:r(),y:r()}),CU=b({id:u(),name:u(),kind:xU.default(`polygon`),polygon:S(SU).readonly(),color:u().default(`#3b82f6`)}),wU={name:`zones`,scope:`device`,mode:`singleton`,deviceTypes:[j.Camera],methods:{listZones:E(b({deviceId:r()}),S(CU).readonly()),addZone:E(b({deviceId:r(),zone:CU}),_(),{kind:`mutation`,auth:`admin`}),removeZone:E(b({deviceId:r(),zoneId:u()}),_(),{kind:`mutation`,auth:`admin`}),updateZone:E(b({deviceId:r(),zone:CU}),_(),{kind:`mutation`,auth:`admin`})},runtimeState:b({zones:S(CU).readonly()}),durability:`restored`,history:`none`,vocabulary:{noun:I(`Zones`,`Zone`),order:3370}},TU={fpsPerStream:10,budgetMinutes:45,minBudgetMinutes:10,maxBudgetMinutes:120,staleAfterDays:30,settleSec:5,measureSec:20,drainTimeoutSec:120,maxModelsPerDevice:6},EU=x([`device`,`pipeline`]),DU=b({deviceKey:u().min(1),modelIds:S(u().min(1)).min(1).max(TU.maxModelsPerDevice)}),OU=b({nodeId:u().min(1),devices:S(DU).min(1),phases:S(EU).min(1).default([`device`,`pipeline`]),steps:S(u().min(1)).default([]),fpsPerStream:r().int().min(1).max(30).default(TU.fpsPerStream),budgetMinutes:r().int().min(TU.minBudgetMinutes).max(TU.maxBudgetMinutes).default(TU.budgetMinutes),keepDownloadedModels:v().default(!1),acceptInsufficientHeadroom:v().default(!1)}),kU=x([`benchmark-active`,`node-offline`,`unknown-device`,`no-phase`,`insufficient-headroom`]),AU=b({kind:kU,detail:u(),overridable:v()}),jU=b({deviceId:r(),placedOnNode:v(),pinnedToNode:v()}),MU=b({deviceId:r(),reason:m(`only-frame-source`)}),NU=b({nodeId:u(),online:v(),moving:S(jU).readonly(),staying:S(MU).readonly(),estimatedDurationMs:r(),budgetMs:r(),phases:S(EU).readonly(),steps:S(u()).readonly(),devices:S(DU).readonly(),headroom:b({sessionsNow:r(),otherNodesCapacitySessions:r().nullable()}),refusals:S(AU).readonly(),canStart:v()}),PU=b({phase:x([`preparing`,`device`,`pipeline`,`cleanup`]),deviceKey:u().nullable(),modelId:u().nullable(),load:r().nullable(),cellsDone:r(),cellsTotal:r(),message:u()}),FU=x([`p95`,`drops`,`errors`,`stall`,`cpu`,`ram`,`none`]),IU=b({load:r(),pass:v(),p95Ms:r(),dropRatio:r(),fps:r(),cpuPct:r().nullable(),ramFreePct:r().nullable(),failReasons:S(u()).readonly()}),LU=b({phase:m(`device`),deviceKey:u(),modelId:u(),p50Ms:r(),p95Ms:r(),p99Ms:r(),fps:r(),kMax:r(),limitedBy:FU,warmupMs:r(),ramp:S(IU).readonly()}),RU=b({phase:m(`pipeline`),deviceKey:u(),modelId:u(),steps:S(u()).readonly(),maxSessions:r(),limitedBy:FU,stepsFired:S(u()).readonly(),warmupMs:r(),ramp:S(IU).readonly()}),zU=a(`phase`,[LU,RU]),BU=b({pipelineVersion:u().nullable(),cpuModel:u().nullable(),ramGb:r().nullable(),os:u().nullable(),pools:h(u(),b({runtime:u(),numWorkers:r(),concurrency:r(),batchMode:u()})).default({})}),VU=b({id:u(),revision:u().nullable(),frames:r(),width:r(),height:r()}),HU=b({runId:u().min(1),devices:S(DU).min(1),phases:S(EU).min(1),steps:S(u()).default([]),fpsPerStream:r().int().min(1).max(30),deadlineAtMs:r(),settleSec:r().min(0).max(60).default(TU.settleSec),measureSec:r().min(2).max(300).default(TU.measureSec),keepDownloadedModels:v().default(!1)}),UU=x([`running`,`done`,`failed`,`aborted`]),WU=b({runId:u(),nodeId:u(),state:UU,progress:PU.nullable(),cells:S(zU).readonly(),fingerprint:BU.nullable(),clip:VU.nullable(),activeCameraIds:S(r()).readonly(),deletedModels:S(u()).readonly(),error:u().nullable(),startedAtMs:r(),finishedAtMs:r().nullable()}),GU=x([`draining`,`measuring`,`restoring`,`done`,`failed`,`aborted`]),KU=x([`completed`,`operator-abort`,`deadline`,`node-lost`,`runner-lost`,`hub-restart`,`drain-timeout`,`failed`]),qU=b({runId:u(),nodeId:u(),state:GU,plan:OU,startedAtMs:r(),deadlineAtMs:r(),finishedAtMs:r().nullable(),endReason:KU.nullable(),error:u().nullable(),moved:S(r()).readonly(),staying:S(r()).readonly(),contaminated:v(),progress:PU.nullable(),resultIds:S(u()).readonly()}),JU=b({modeNodeId:u().nullable(),run:qU.nullable()}),YU=b({id:u(),runId:u(),nodeId:u(),cell:zU,fpsPerStream:r(),fingerprint:BU.nullable(),clip:VU.nullable(),contaminated:v(),stayingCameras:S(r()).readonly(),partialRun:v(),measuredAtMs:r()}),XU=b({nodeId:u().optional(),deviceKey:u().optional()}),ZU=YU.extend({standing:x([`fresh`,`stale`,`superseded`]),staleWhy:x([`age`,`runtime`,`pool-tuning`]).nullable()}),uwe=b({runId:u(),nodeId:u(),startedAtMs:r(),deadlineAtMs:r(),plan:OU,moved:S(r()).readonly(),staying:S(r()).readonly()}),QU=b({nodeId:u(),reachable:v(),devices:S(b({deviceKey:u(),enabled:v(),available:v(),suggested:S(u()).readonly(),all:S(u()).readonly(),currentModelId:u().nullable()})).readonly(),steps:S(b({id:u(),name:u(),slot:u()})).readonly()}),$U=b({x:r(),y:r(),w:r(),h:r()}),eW=b({bytes:y(Uint8Array).optional(),jpeg:u().optional(),jpegBytes:y(Uint8Array).optional(),width:r().int().positive(),height:r().int().positive(),tier:x([`native`,`ram-fullframe`]).optional()}),tW=x([`keyFrame`,`thumbnail`]),nW=x([`handle-gone`,`encode-failed`]),rW=a(`parked`,[b({parked:m(!0),nodeId:u(),width:r().int().positive(),height:r().int().positive(),bytes:r().int().nonnegative(),replaced:v()}),b({parked:m(!1),nodeId:u(),reason:nW,handleAgeMs:r().nullable(),detail:u().optional()})]),iW=b({jpeg:u().optional(),jpegBytes:y(Uint8Array).optional(),width:r().int().positive(),height:r().int().positive(),timestamp:r(),parkedAt:r()}),dwe=b({bbox:$U,className:u()}),aW=b({stepId:u(),className:u(),score:r(),bbox:$U.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:S(b({x:r(),y:r()})).optional()}),fwe=x([`unknown-step`,`model-not-servable`,`unreadable-frame`,`execution-failed`]),pwe=a(`kind`,[b({kind:m(`ran`),nodeId:u(),modelId:u(),details:S(aW)}),b({kind:m(`refused`),nodeId:u(),reason:fwe,detail:u()})]),oW={min:0,max:6e4,default:3e4,step:500},sW={min:0,max:6e5,default:12e4,step:5e3},cW={min:5e3,max:6e5,default:9e4,step:5e3},lW={min:1,max:30,default:4,step:1},uW={min:1,max:30,default:10,step:1},dW={min:0,max:300,default:300,step:5},fW={min:1,max:10,default:4,step:1},pW={min:0,max:30,default:12,step:1},mW=x([`onboard`,`analyzer`,`device-activity`]),hW=b({source:mW,triggeredBy:CB,sensorName:u().optional()}),gW=S(mW),_W={analyzer:`Frame-diff Analyzer (motion addon)`,onboard:`Camera sensors`,"device-activity":`Device activity (the device says it is working)`};function vW(e){let t=mW.safeParse(e);return t.success?_W[t.data]:e}var mwe=[`analyzer`,`onboard`,`device-activity`],yW=p(e=>Array.isArray(e)&&e.length>1?e.slice(0,1):e,S(zV).max(1)),bW=b({deviceId:r(),detected:v(),source:mW.default(`analyzer`),regions:S(zB).readonly().optional()}),xW=a(`kind`,[b({kind:m(`local-broker`)}),b({kind:m(`remote-restream`),ownerNodeId:u(),ownerReachableHost:u().optional(),hubHostnameOverride:u().optional()})]).describe(`Per-camera frame-source mode for the runner (P2c)`),SW=b({modelId:u().optional(),settings:h(u(),C()).optional()}),CW=b({deviceKey:u(),weight:r().positive().default(1),maxSessions:r().int().positive().nullable().default(null),steps:h(u(),SW).optional(),disabledSteps:S(u()).readonly().optional()}),wW=b({deviceId:r(),detectionMode:x([`disabled`,`always-on`,`on-motion`]).default(`on-motion`),audioMode:x([`disabled`,`always-on`,`on-motion`]).default(`always-on`),motionCooldownMs:r().min(oW.min).default(oW.default),maxSessionHoldMs:r().min(sW.min).max(sW.max).optional(),audioMotionWindowMs:r().min(cW.min).max(cW.max).optional(),motionFps:r().min(lW.min).max(lW.max).default(lW.default),detectionFps:r().min(uW.min).max(uW.max).default(uW.default),motionStreamId:u(),detectionStreamId:u(),audioStreamPick:ac.optional(),motionSources:gW.default([`analyzer`]),sessionTrigger:hW.optional(),detectionSources:yW.default([`pipeline`]),pipelineEnabled:v().default(!0),steps:S(aU).readonly().optional(),audio:b({modelId:u().optional(),enabled:v()}).nullable().optional(),zones:S(CU).readonly().default([]),onboardMotionDrivesAnalyzer:v().default(!0),preRollInferenceEnabled:v().default(!0),preRollInferenceFrames:r().min(pW.min).max(pW.max).default(pW.default),occupancyRecheckEnabled:v().default(!0),occupancyRecheckSec:r().min(dW.min).max(dW.max).default(dW.default),occupancyRecheckFrames:r().min(fW.min).max(fW.max).default(fW.default),frameSource:xW.default({kind:`local-broker`}),deviceKey:u().optional(),inferenceDevices:S(CW).readonly().optional()}),hwe=[{key:`motionSources`,type:`multiselect`,label:`Motion Sources`,default:[`analyzer`],options:mwe.map(e=>e===`onboard`?{value:e,label:_W[e],description:`The camera's own motion, plus any sensor attached to it`}:{value:e,label:_W[e]})},{key:`motionFps`,type:`slider`,label:`Motion FPS (analyzer)`,min:lW.min,max:lW.max,step:lW.step,default:lW.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:oW.min,max:oW.max,step:oW.step,default:oW.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:sW.min,max:sW.max,step:sW.step,default:sW.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:cW.min,max:cW.max,step:cW.step,default:cW.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:pW.min,max:pW.max,step:pW.step,default:pW.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:dW.min,max:dW.max,step:dW.step,default:dW.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:fW.min,max:fW.max,step:fW.step,default:fW.default,showValue:!0,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}}],TW=b({nodeId:u(),attachedCameras:r(),activeCameras:r(),avgInferenceFps:r(),avgInferenceTimeMs:r(),queueDepthTotal:r(),devices:S(b({deviceKey:u(),backend:u(),attachedCameras:r()})).default([]),hardware:b({hasGpu:v(),inferenceBackend:u().optional(),cpuCores:r().optional()}),motionSliceWriter:m(`orchestrator`).optional()}),EW=b({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()}),DW=b({node:EW,cameras:S(EW.extend({deviceId:r()}))}),OW=b({nodeId:u(),activeCameras:r(),throttledCameras:r(),avgInferenceTimeMs:r(),queueDepth:r(),frameLazy:DW.optional()}),kW=x([`not-attached`,`battery-asleep`,`not-watching`,`already-bursting`]),AW={name:`pipeline-runner`,scope:`system`,mode:`singleton`,methods:{attachCamera:E(wW,b({success:m(!0)}),{kind:`mutation`}),detachCamera:E(b({deviceId:r()}),b({success:m(!0)}),{kind:`mutation`}),reportMotion:E(bW,b({success:m(!0)}),{kind:`mutation`}),getLocalLoad:E(_(),TW),getLocalMetrics:E(_(),OW),getCameraMetrics:E(b({deviceId:r()}),yU.nullable()),getAllCameraMetrics:E(_(),S(bU).readonly()),getLocalCameras:E(_(),S(r()).readonly()),requestOccupancyBurst:E(b({deviceId:r(),frames:r().int().positive().optional(),reason:u()}),b({started:v(),refusedBecause:kW.optional()}),{auth:`admin`,kind:`mutation`}),getNativeCrop:E(b({handle:mc,bbox:$U,maxWidth:r().int().positive().optional(),acceptJpegBytes:v().optional(),encodeJpeg:v().optional()}),eW.nullable()),runDetailSubtree:E(b({deviceId:r(),frameHandle:mc.optional(),frameJpeg:u().optional(),cropJpeg:u().optional(),parent:dwe,steps:S(u()).optional(),supplied:b({stepId:u(),modelId:u(),boxes:S(b({bbox:$U,score:r()})).min(1)}).optional()}),b({details:S(aW)}).nullable(),{kind:`mutation`}),runStatelessStep:E(b({stepId:u(),modelId:u(),frameJpeg:u(),bbox:$U,className:u(),sourceDeviceId:r()}),pwe,{kind:`mutation`}),parkTrackFrame:E(b({deviceId:r(),trackId:u(),kind:tW,handle:mc,bbox:$U,maxWidth:r().int().positive().optional(),timestamp:r()}),rW,{kind:`mutation`}),getParkedTrackFrame:E(b({deviceId:r(),trackId:u(),kind:tW,acceptJpegBytes:v().optional()}),iW.nullable()),releaseParkedTrackFrames:E(b({deviceId:r(),trackId:u()}),b({released:r().int().nonnegative()}),{kind:`mutation`}),startNodeBench:E(HU,b({accepted:m(!0),runId:u()}),{kind:`mutation`,auth:`admin`}),getNodeBenchStatus:E(b({runId:u()}),WU.nullable(),{auth:`admin`}),abortNodeBench:E(b({runId:u()}),b({aborted:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},jW=3e4,gwe={version:1,targets:[{id:`detected`,cardinality:`event`,shape:`span`,vocabulary:{cap:`motion`,eventName:`onMotionChanged`},deviceTypes:[j.Camera],apply:`add`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:jW,combine:`any`,sourceModes:[`in-addition`,`confirm`,`replace`],sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},_we=15e3,MW=b({detected:v(),lastDetectedAt:r().nullable(),autoClearAfterMs:r().nullable().meta(k(`duration-ms`))}),NW=b({deviceId:r(),detected:v(),timestamp:r(),source:mW,regions:S(zB).readonly().optional(),triggeredBy:CB.optional()}),PW={name:`motion`,scope:`device`,mode:`singleton`,deviceNative:!0,deviceTypes:[j.Camera,j.Sensor],methods:{isDetected:E(b({deviceId:r()}),v())},composedMethods:{isDetected:{kind:`slice`,field:`detected`}},events:{onMotionChanged:{data:NW,notOperatorFacing:"the `detected` state trigger phrases both edges, from the mirror that survives a dropped event (D49)"}},status:{schema:MW,kind:`push`},runtimeState:MW,durability:`session`,history:{fields:{detected:{kind:`boolean`,excludeDeviceTypes:[j.Camera]}}},customize:gwe,vocabulary:{noun:I(`Motion`,`Movimento`),order:5130,state:[{kind:`boolean`,field:`detected`,label:I(`Motion`,`Movimento`),whenTrue:I(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:I(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}]}},FW=b({enabled:v(),lastChangedAt:r()}),IW=FW.extend({lastFetchedAt:r()}),LW={name:`motion-trigger`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Light,j.Siren,j.Switch],methods:{setMotionTrigger:E(b({deviceId:r().int().nonnegative(),enabled:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`motionTrigger.on`,label:I(`Motion trigger on`,`Attivazione al movimento attiva`),phrase:I(`Let motion trigger {device}`,`Fai attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!0},args:{enabled:!0}},{id:`motionTrigger.off`,label:I(`Motion trigger off`,`Attivazione al movimento spenta`),phrase:I(`Stop motion triggering {device}`,`Non far più attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!1},args:{enabled:!1}}]})},events:{onMotionTriggerChanged:{data:b({deviceId:r(),enabled:v(),lastChangedAt:r()}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:FW,kind:`command-driven`},runtimeState:IW,durability:`session`,history:`none`,vocabulary:{noun:I(`Motion trigger`,`Attivazione al movimento`),order:1160,state:[{kind:`boolean`,field:`enabled`,label:I(`Motion trigger`,`Attivazione al movimento`),whenTrue:I(`When motion triggering is turned on for {device}`,`Quando si attiva l’attivazione al movimento di {device}`),whenFalse:I(`When motion triggering is turned off for {device}`,`Quando si disattiva l’attivazione al movimento di {device}`),icon:`activity`}]}},RW=b({id:r(),enabled:v(),shape:KB}),zW=b({enabled:v(),sensitivity:r().meta(k(`none`)),regions:S(RW),lastFetchedAt:r()}),BW=b({maxRegions:r(),supportedShapes:S(JB),grid:XB,sensitivity:b({min:r(),max:r(),step:r()})}),VW=b({enabled:v().optional(),sensitivity:r().optional(),regions:S(RW).optional()}),HW={name:`motion-zones`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/motion-zones-grid`,tab:`motion`,label:`Motion Zones`}},methods:{getOptions:E(b({deviceId:r()}),BW),setZone:E(b({deviceId:r(),patch:VW}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:zW,kind:`poll`},runtimeState:zW,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Motion zones`,`Zone di movimento`),order:3170}},vwe=x([`external`,`embedded`]),ywe=x([`connected`,`disconnected`,`auth-failed`,`unreachable`,`tls-error`]),UW=b({id:u(),name:u(),url:u(),kind:vwe,status:ywe,latencyMs:r().nullable(),error:u().optional(),connectedClients:r().int().nonnegative().optional(),lastCheckedAt:r().optional()}),WW=b({url:u(),username:u().optional(),password:u().optional(),clientIdPrefix:u().optional()}),GW=b({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=b({id:u()}),KW=b({id:u()}),qW=b({port:r().int().min(1).max(65535).default(1883),allowAnonymous:v().default(!1),username:u().optional(),password:u().optional()}),xwe=b({id:u(),url:u()}),JW=b({brokerCount:r(),embeddedRunning:v()}),YW={name:`mqtt-broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:JW,kind:`poll`},methods:{listBrokers:E(_(),S(UW)),getBrokerConfig:E(KW,WW,{auth:`admin`}),addBroker:E(GW,bwe,{kind:`mutation`,auth:`admin`}),removeBroker:E(KW,_(),{kind:`mutation`,auth:`admin`}),startEmbeddedBroker:E(qW,xwe,{kind:`mutation`,auth:`admin`}),stopEmbeddedBroker:E(KW,_(),{kind:`mutation`,auth:`admin`}),getStatus:E(_(),JW)},vocabulary:{notOperatorFacing:O.NETWORK}},XW=x([`person`,`vehicle`,`animal`,`face`,`package`,`other`]),ZW=b({class:XW,timestamp:r(),confidence:r().min(0).max(1).optional()}),QW=b({lastByClass:f(XW,ZW.nullable()),supportedClasses:S(XW).readonly(),enabled:v()}),$W=x([`boxed`,`while-streaming`,`flag-only`]),eG=b({supportedClasses:S(XW).readonly(),geometry:$W}),tG=b({enabled:v().optional()}),nG=QW.extend({lastFetchedAt:r()}),rG={name:`native-object-detection`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{getOptions:E(b({deviceId:r()}),eG),setSettings:E(b({deviceId:r(),settings:tG}),_(),{kind:`mutation`,auth:`admin`}),setEnabled:E(b({deviceId:r(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`nativeDetection.on`,label:I(`On-camera detection on`,`Rilevamento a bordo attivo`),phrase:I(`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:I(`On-camera detection off`,`Rilevamento a bordo spento`),phrase:I(`Turn off the on-camera detection of {device}`,`Disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!1}}]})},events:{onDetected:{data:b({deviceId:r(),detection:ZW}),trigger:{category:w.DetectionCameraNative,label:I(`Camera spotted something`,`La telecamera ha rilevato qualcosa`),phrase:I(`When {device} spots something with its own detector`,`Quando {device} rileva qualcosa con il proprio rilevatore`),icon:`scan-eye`}}},status:{schema:QW,kind:`push`},runtimeState:nG,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`On-camera detection`,`Rilevamento a bordo`),order:3180,state:[{kind:`boolean`,field:`enabled`,label:I(`On-camera detection`,`Rilevamento a bordo`),whenTrue:I(`When the on-camera detection of {device} is turned on`,`Quando si attiva il rilevamento a bordo di {device}`),whenFalse:I(`When the on-camera detection of {device} is turned off`,`Quando si disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`}]}},iG=b({pan:r().min(-1).max(1).optional(),tilt:r().min(-1).max(1).optional(),speed:r().min(0).max(1).optional()}),aG=x([`goHome`,`locate`,`spotClean`,`findPet`,`personFollow`,`stop`,`startClean`,`pauseClean`,`dockWash`,`autoEmpty`,`flashOn`,`flashOff`]),oG=x([`action`,`sound`]),sG=b({id:u(),kind:oG,label:u(),icon:u(),soundId:r().int().optional(),enabled:v()}),Swe=[{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}],cG=b({x:r(),y:r()}),lG=b({move:v(),stop:v(),goToPoint:v(),runAction:v(),playSound:v(),light:v(),lightMode:v()}),uG=x([`auto`,`manual`]),dG=x([`idle`,`cleaning`,`spot`,`following`,`goto`,`returning`,`paused`,`unknown`]),fG=b({mode:dG,following:v(),flash:v(),lightMode:uG,lightLevel:r().min(40).max(100).meta(k(`none`)),lastChangedAt:r()}),pG=fG.extend({lastFetchedAt:r()}),mG={name:`navigation`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/navigation-panel`,tab:`navigation`,topTab:!0,label:`Navigation`,order:0}},methods:{move:E(iG.extend({deviceId:r()}),_(),{kind:`mutation`,notOperatorFacing:`joystick control from the live view — continuous, not a discrete step`}),stop:E(b({deviceId:r()}),_(),{kind:`mutation`,actions:[{id:`navigation.stop`,label:I(`Stop`,`Ferma`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),goToPoint:E(cG.extend({deviceId:r()}),_(),{kind:`mutation`,notOperatorFacing:`tap-to-go on the live map — the point only means something on that picture`}),listActions:E(b({deviceId:r()}),S(sG)),runAction:E(b({deviceId:r(),actionId:aG}),_(),{kind:`mutation`,actions:[{id:`navigation.runAction`,label:I(`Run a routine`,`Esegui una routine`),phrase:I(`Have {device} {actionId}`,`Fai eseguire a {device}: {actionId}`),icon:`bot`,openArgs:[{key:`actionId`,label:I(`Routine`,`Routine`),offer:{kind:`enum`,values:[{value:`goHome`,label:I(`go home`,`torna alla base`)},{value:`locate`,label:I(`beep so you can find it`,`suona per farsi trovare`)},{value:`spotClean`,label:I(`clean this spot`,`pulisci questo punto`)},{value:`findPet`,label:I(`find the pet`,`cerca l’animale`)},{value:`personFollow`,label:I(`follow a person`,`segui una persona`)},{value:`stop`,label:I(`stop`,`fermati`)},{value:`startClean`,label:I(`start cleaning`,`inizia a pulire`)},{value:`pauseClean`,label:I(`pause cleaning`,`metti in pausa la pulizia`)},{value:`dockWash`,label:I(`wash the mop at the dock`,`lava il mocio alla base`)},{value:`autoEmpty`,label:I(`empty the bin at the dock`,`svuota il contenitore alla base`)},{value:`flashOn`,label:I(`turn the flash on`,`accendi il flash`)},{value:`flashOff`,label:I(`turn the flash off`,`spegni il flash`)}]}}]}]}),playSound:E(b({deviceId:r(),soundId:r().int()}),_(),{kind:`mutation`,actions:[{id:`navigation.playSound`,label:I(`Play sound`,`Riproduci un suono`),phrase:I(`Play {soundId} on {device}`,`Riproduci {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:I(`Sound`,`Suono`),offer:{kind:`dynamic`,from:`method`,method:`listActions`,valueKey:`soundId`,labelKey:`label`,where:{key:`kind`,equals:`sound`},valueKind:`number`}}]}]}),setLightOn:E(b({deviceId:r(),on:v()}),_(),{kind:`mutation`,actions:[{id:`navigation.lightOn`,label:I(`Light on`,`Luce accesa`),phrase:I(`Turn on the light of {device}`,`Accendi la luce di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`navigation.lightOff`,label:I(`Light off`,`Luce spenta`),phrase:I(`Turn off the light of {device}`,`Spegni la luce di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setLightMode:E(b({deviceId:r(),mode:uG,level:r().min(40).max(100).optional()}),_(),{kind:`mutation`,actions:[{id:`navigation.lightAuto`,label:I(`Light automatic`,`Luce automatica`),phrase:I(`Set the light of {device} to automatic`,`Metti la luce di {device} in automatico`),icon:`lightbulb`,args:{mode:`auto`}}]}),setLightLevel:E(b({deviceId:r(),level:r().min(40).max(100)}),_(),{kind:`mutation`,actions:[{id:`navigation.lightLevel`,label:I(`Set light level`,`Imposta la luce`),phrase:I(`Set the light of {device} to {level}`,`Imposta la luce di {device} al {level}`),icon:`sun-medium`,openArgs:[{key:`level`,label:I(`Level`,`Livello`),offer:{kind:`number`,min:40,max:100,step:1,unit:`%`}}]}]}),getFeatures:E(b({deviceId:r()}),lG)},events:{onStatusChanged:{data:b({deviceId:r(),status:fG}),notOperatorFacing:"the `mode` state trigger reads the same change"}},status:{schema:fG,kind:`push`},runtimeState:pG,durability:`session`,history:`none`,vocabulary:{noun:I(`Robot movement`,`Movimento del robot`),order:2080,state:[{kind:`enum`,field:`mode`,label:I(`Activity`,`Attività`),values:[{value:`idle`,label:I(`Idle`,`Inattivo`)},{value:`cleaning`,label:I(`Cleaning`,`In pulizia`)},{value:`spot`,label:I(`Spot cleaning`,`Pulizia localizzata`)},{value:`following`,label:I(`Following`,`In inseguimento`)},{value:`goto`,label:I(`Moving to a point`,`In movimento verso un punto`)},{value:`returning`,label:I(`Returning`,`In rientro`)},{value:`paused`,label:I(`Paused`,`In pausa`)},{value:`unknown`,label:I(`Unknown`,`Sconosciuto`)}],icon:`bot`}]}},hG=b({url:u(),hostname:u(),port:r(),protocol:x([`http`,`https`]),stable:v().optional()}),Cwe=b({url:u(),stable:v().optional(),updated:v().optional()}),gG=b({connected:v(),endpoint:hG.nullable(),error:u().optional()}),wwe=hG.extend({id:u(),label:u(),mode:u().optional(),sourcePort:r().optional()}),_G={name:`network-access`,scope:`system`,mode:`collection`,providerKind:`ingress`,methods:{start:E(_(),hG,{kind:`mutation`}),stop:E(_(),_(),{kind:`mutation`}),getEndpoint:E(_(),hG.nullable()),getStatus:E(_(),gG),listEndpoints:E(_(),S(wwe).readonly())},vocabulary:{notOperatorFacing:O.NETWORK}},vG=[`wifi`,`ethernet`,`cellular`,`unknown`],yG=b({type:x(vG),signal:r().min(0).max(100).nullable().meta(k(`percentage`)),rssi:r().optional().meta(k(`signal-level`)),ssid:u().optional(),speedKbps:r().nonnegative().nullable().optional().meta(k(`bitrate`)),linkUp:v().nullable().optional(),lastUpdated:r().meta(k(`none`))}),bG={type:`unknown`,signal:null,lastUpdated:0};function Twe(e,t){return e===void 0||!Number.isFinite(e)||t<=0||e<0||e>t?null:Math.round(e/t*100)}function Ewe(e){return e===void 0||!Number.isFinite(e)||e>0?null:Math.round((Math.min(-50,Math.max(-100,e))+100)*2)}var xG={name:`network-link`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera,j.Sensor,j.Button,j.Switch,j.Light,j.Lock,j.Siren],methods:{},events:{onStatusChanged:{data:b({deviceId:r(),status:yG}),notOperatorFacing:`the signal / link-type state triggers each read one field of this change`}},status:{schema:yG,kind:`push`,empty:bG},runtimeState:yG,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:I(`Network link`,`Collegamento di rete`),order:5250,state:[{kind:`numeric`,field:`signal`,quantity:I(`the signal strength`,`l’intensità del segnale`),label:I(`Signal`,`Segnale`),unit:`%`,icon:`wifi`},{kind:`enum`,field:`type`,label:I(`Link type`,`Tipo di collegamento`),values:[{value:`wifi`,label:I(`Wi-Fi`,`Wi-Fi`)},{value:`ethernet`,label:I(`Ethernet`,`Ethernet`)},{value:`cellular`,label:I(`Cellular`,`Rete mobile`)},{value:`unknown`,label:I(`Unknown`,`Sconosciuto`)}],icon:`network`}]}},SG=b({nominalBitrateKbps:r(),observedBitrateKbps:r(),peakBitrateKbps:r(),packetLossPercent:r(),lastUpdated:r()}),CG=b({rttMs:r(),jitterMs:r(),estimatedBandwidthKbps:r(),packetLossPercent:r().min(0).max(100),downlinkMbps:r().optional(),downlinkAgeMs:r().optional(),lastUpdated:r()}),wG=b({deviceId:r(),streams:h(u(),SG),client:CG.optional()}),TG={name:`network-quality`,scope:`system`,mode:`singleton`,methods:{getDeviceStats:E(b({deviceId:r()}),wG.nullable()),getAllStats:E(_(),S(wG).readonly()),reportClientStats:E(b({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()}),_(),{role:`viewer`,kind:`mutation`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.NETWORK}},EG=b({cn:u(),serial:u(),fingerprintSha256:u(),notBefore:r(),notAfter:r()}),DG=b({fingerprintSha256:u(),issuer:u(),sans:S(u()),notBefore:r(),notAfter:r()}),OG=a(`state`,[b({state:m(`served`),leaf:DG}),b({state:m(`not-issued`),reason:u()})]),kG={name:`node-certificates`,scope:`system`,mode:`singleton`,internal:!0,methods:{getCertificates:E(b({}),b({nodeId:u(),mesh:EG.nullable(),https:OG}),{auth:`admin`}),prepareMeshRenewal:E(b({}),b({csrPem:u()}),{kind:`mutation`,auth:`admin`}),installMeshLeaf:E(b({certPem:u().min(1),caCertPem:u().min(1),confirmWithinMs:r().int().min(1e4).max(6e5)}),b({fingerprintSha256:u(),serial:u()}),{kind:`mutation`,auth:`admin`}),confirmMeshLeaf:E(b({fingerprintSha256:u()}),b({confirmed:v()}),{kind:`mutation`,auth:`admin`}),rollbackMeshLeaf:E(b({}),b({rolledBack:v()}),{kind:`mutation`,auth:`admin`}),prepareHttpsCertificate:E(b({}),b({csrPem:u(),hostnames:S(u()),addresses:S(u()),pinnedCaFingerprintSha256:u().nullable()}),{kind:`mutation`,auth:`admin`}),forgetHub:E(b({}),b({ok:m(!0)}),{kind:`mutation`,auth:`admin`}),installHttpsCertificate:E(b({certPem:u().min(1),caCertPem:u().min(1),caRotation:v().optional()}),DG,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.IDENTITY}},AG=b({nodeId:u().min(1),removedAt:r()}),jG=b({counts:h(u(),r().int().nonnegative())}),MG={name:`node-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onNodeRemoved:E(AG,jG,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:O.INTERNAL}},NG=b({addonId:u(),capabilities:S(u()).readonly(),status:u()}),PG=b({pid:r(),name:u(),state:u(),cpuPercent:r(),memoryRss:r(),uptimeSeconds:r(),services:S(NG).readonly(),groupId:u().optional()}),Dwe=b({id:u(),status:u(),cpuPercent:r(),memoryRss:r()}),Owe=b({category:u(),total:r(),healthy:r(),addons:S(Dwe).readonly()}),kwe=b({name:u(),version:u()}),FG=b({id:u(),name:u(),hostname:u(),platform:u(),arch:u(),cpuModel:u().nullable(),cpuCores:r(),memoryMB:r(),engines:S(u()).readonly(),isHub:v(),isOnline:v(),cpuPercent:r(),memoryPercent:r().nullable(),uptime:r(),lastSeen:u(),localIps:S(u()).readonly(),addons:S(b({id:u(),capabilities:S(u()).readonly(),status:u()})).readonly(),processes:S(PG).readonly(),categories:S(Owe).readonly(),rootPackage:kwe.nullable(),meshTransport:x([`tls`,`clear`]).optional(),capabilitiesRegistered:v().optional()}),Awe=b({callerAddonId:u(),providerAddonId:u(),capName:u(),callsPerMin:r(),lastCallAtMs:r()}),IG=b({nodeId:u(),name:u(),version:u(),status:u(),synced:v()}),LG=b({hubVersion:u(),nodes:S(IG)}),RG=b({nodeId:u(),addonId:u()}),jwe=b({id:u(),status:u(),version:u().optional(),packageName:u().optional()}),zG=b({success:v()}),Mwe=b({success:v(),reason:u().optional()}),Nwe=b({restarted:S(u()).readonly(),failed:S(u()).readonly()}),Pwe=b({nodeId:u(),name:u()}),BG=b({id:u(),name:u(),isHub:v(),isOnline:v()}),VG=b({nodes:S(BG).readonly(),complete:v()}),HG={name:`nodes`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{topology:E(_(),S(FG).readonly(),{auth:`admin`}),directory:E(_(),VG,{auth:`admin`}),deployAddon:E(RG,zG,{kind:`mutation`,auth:`admin`}),undeployAddon:E(RG,zG,{kind:`mutation`,auth:`admin`}),restartAddon:E(RG,zG,{kind:`mutation`,auth:`admin`}),restartProcess:E(b({nodeId:u(),processName:u()}),Mwe,{kind:`mutation`,auth:`admin`}),restartNode:E(b({nodeId:u()}),Nwe,{kind:`mutation`,auth:`admin`}),shutdownNode:E(b({nodeId:u()}),zG,{kind:`mutation`,auth:`admin`}),renameNode:E(b({nodeId:u(),name:u().min(1).max(64)}),Pwe,{kind:`mutation`,auth:`admin`}),clusterAddonStatus:E(_(),h(u(),LG),{auth:`admin`}),getCapUsageGraph:E(b({windowSeconds:r().int().positive().max(300).default(60)}),S(Awe).readonly(),{auth:`admin`}),getNodeAddons:E(b({nodeId:u()}),S(jwe).readonly(),{auth:`admin`}),setProcessLogLevel:E(b({nodeId:u(),level:u()}),zG,{kind:`mutation`,auth:`admin`}),executeQuery:E(b({nodeId:u(),addonId:u(),queryName:u(),params:h(u(),C()).optional()}),C(),{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.CLUSTER}},UG=[{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`}],WG={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},GG={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},KG=new Map;for(let[e,t]of Object.entries(WG.mapping))KG.set(e.toLowerCase(),t);for(let[e,t]of Object.entries(GG.mapping))KG.set(e.toLowerCase(),t);function Fwe(e){return KG.get(e.toLowerCase())??null}function Iwe(){return UG.map(e=>e.id)}var qG=tN();function JG(e){return oN(qG.swatches,qG.fallbacks,e)}function Lwe(e){let t=e[0];if(t===void 0)throw Error(`display palette has no fallback colour`);return t}var Rwe=Lwe(qG.fallbacks);function zwe(e){return e.split(/[-_ ]/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var YG=new Map;function XG(e,t,n,r){YG.set(e,{kind:e,parentKind:null,level:`macro`,category:t,color:JG(e),iconId:n,labelKey:`eventKind.${e}`,label:r})}function ZG(e,t,n,r,i){YG.set(e,{kind:e,parentKind:t,level:`sub`,category:n,color:JG(e),iconId:r,labelKey:`eventKind.${e}`,label:i})}XG(`motion`,`motion`,`motion`,`Motion`),XG(`audio`,`audio`,`audio`,`Audio`),XG(`person`,`detection`,`person`,`Person`),XG(`vehicle`,`detection`,`vehicle`,`Vehicle`),XG(`animal`,`detection`,`animal`,`Animal`),XG(`package`,`package`,`package`,`Package`),XG(`sensor`,`sensor`,`sensor`,`Sensor`),XG(`control`,`control`,`control`,`Control`);for(let[e,t]of Object.entries(Ih.mapping))t!==`vehicle`&&t!==`animal`||YG.has(e)||ZG(e,t,`detection`,e,zwe(e));ZG(`package-delivered`,`package`,`package`,`package`,`Package delivered`),ZG(`package-picked-up`,`package`,`package`,`package`,`Package picked up`),ZG(`contact`,`sensor`,`sensor`,`door`,`Contact`),ZG(`motion-sensor`,`sensor`,`sensor`,`pir`,`Motion sensor`),ZG(`smoke`,`sensor`,`sensor`,`smoke`,`Smoke`),ZG(`flood`,`sensor`,`sensor`,`water`,`Water leak`),ZG(`gas`,`sensor`,`sensor`,`gas`,`Gas`),ZG(`carbon-monoxide`,`sensor`,`sensor`,`smoke`,`Carbon monoxide`),ZG(`vibration`,`sensor`,`sensor`,`vibration`,`Vibration`),ZG(`tamper`,`sensor`,`sensor`,`tamper`,`Tamper`),ZG(`presence`,`sensor`,`sensor`,`presence`,`Presence`),ZG(`enum-sensor`,`sensor`,`sensor`,`generic`,`Sensor state`),ZG(`device-event`,`sensor`,`sensor`,`button`,`Device event`),ZG(`lock`,`control`,`control`,`lock`,`Lock`),ZG(`cover`,`control`,`control`,`door`,`Cover`),ZG(`switch`,`control`,`control`,`switch`,`Switch`),ZG(`siren`,`control`,`control`,`siren`,`Siren`),ZG(`button`,`control`,`control`,`button`,`Button`),ZG(`doorbell`,`control`,`control`,`doorbell`,`Doorbell`),ZG(`appliance-cycle`,`control`,`control`,`switch`,`Appliance cycle`);for(let e of UG){let t=`audio-${e.id}`;YG.has(t)||ZG(t,`audio`,`audio`,t,e.name)}var QG=Object.freeze(Object.fromEntries(YG));function $G(e){return QG[e]}function Bwe(e){return JG(e)}function Vwe(e){let t=[];for(let n of Object.values(QG))n.parentKind===e&&t.push(n);return t}var eK=b({kind:u(),label:u(),parentKind:u().nullable()}),tK=b({videoClasses:S(eK),audioKinds:S(eK),labels:S(eK)});function nK(e,t,n){return{kind:e,label:t,parentKind:n}}function rK(){let e=Object.values(QG);return{videoClasses:e.filter(e=>e.category===`detection`).map(e=>nK(e.kind,e.label,e.parentKind)),audioKinds:e.filter(e=>e.category===`audio`&&e.level===`sub`).map(e=>nK(e.kind,e.label,e.parentKind)),labels:e.filter(e=>e.category===`sensor`||e.category===`control`).map(e=>nK(e.kind,e.label,e.parentKind))}}var Hwe=Object.freeze(rK()),iK=x([`immediate`,`track-end`,`device-event`,`package-event`,`system-event`]),aK=x(`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(`.`)),oK=[`camera-online`,`camera-offline`,`camera-disabled`,`camera-enabled`],Uwe=new Set(oK),Wwe=aK.options.filter(e=>!Uwe.has(e)),sK=[`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`],cK=[`device-battery-low`,`device-battery-normal`,`device-consumable-low`,`device-consumable-normal`],lK=[`device-consumable-low`,`device-consumable-normal`],uK=[`confirmed`,`already`,`unconfirmed`,`failed`],dK=[`user`,`addon`,`action`,`scheduler`,`composition`,`node`],fK=b({kinds:S(aK).min(1),deviceIds:S(r().int()).min(1).optional(),deviceTypes:S(u().min(1)).min(1).optional(),excludeDeviceIds:S(r().int()).min(1).optional(),nodeIds:S(u().min(1)).min(1).optional(),packageNames:S(u().min(1)).min(1).optional(),commandActions:S(u().min(1)).min(1).optional(),commandOutcomes:S(x(uK)).min(1).optional(),commandActorKinds:S(x(dK)).min(1).optional(),consumableLowPercent:r().int().min(1).max(95).optional()});function Gwe(e){return e.consumableLowPercent??15}var pK=1440,Kwe=[10,30,60],mK=b({days:S(r().int().min(0).max(6)).min(1),startMinute:r().int().min(0).max(1439),endMinute:r().int().min(0).max(1439)}),hK=b({windows:S(mK).min(1),timezone:u().optional(),invert:v().optional()}),gK=x([`instant`,`summary`]),qwe=x([`activation`,`deactivation`,`schedule`]),_K=x([`rule`,`section`]),vK=a(`mode`,[b({mode:m(`instant`)}),b({mode:m(`summary`),schedule:hK,split:_K.optional()}),b({mode:m(`modes`),onActivation:v(),onDeactivation:v(),onSchedule:b({schedule:hK,grouping:_K}).optional()})]),yK=b({values:S(u().min(1)),maxDistance:r().int().min(0).max(3).default(1)}),bK=b({zoneId:u().optional(),className:u().optional(),op:x([`became-occupied`,`became-free`,`>=`,`<=`]).default(`became-occupied`),count:r().int().min(0).default(1),sustainSeconds:r().int().min(0).max(3600).default(15)}),xK=b({labels:S(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()}),SK=x([`enter`,`exit`,`any`]),CK=x([`raised`,`cleared`]),wK=b({ids:S(u().min(1)).min(1),match:x([`any`,`all`]).optional()}),TK=u().min(1),EK=S(TK).max(4),DK=b({id:u().min(1).max(64),label:u().min(1).max(40),actionId:TK,icon:mi.optional(),destructive:v().optional()}),OK=b({onActivation:EK.optional(),onDeactivation:EK.optional(),onTrigger:EK.optional(),onTriggerOff:EK.optional(),buttons:S(DK).max(8).optional()}),kK=b({deviceId:r().int(),states:S(u().min(1)).min(1)}),AK=b({sceneId:u().min(1),deviceId:r().int().optional(),requiredState:x([`matched`,`diverged`]),latched:v().optional()}),jK=b({deviceState:kK.optional(),scene:AK.optional(),devices:S(r()).optional(),devicesExclude:S(r()).min(1).optional(),classes:S(u().min(1)).optional(),classesExclude:S(u().min(1)).optional(),minConfidence:r().min(0).max(1).optional(),zones:wK.optional(),zonesExclude:S(u().min(1)).optional(),crossing:SK.optional(),labelEquals:S(u().min(1)).optional(),identities:S(u().min(1)).optional(),plates:yK.optional(),identitiesExclude:S(u().min(1)).optional(),minImportance:r().min(0).max(1).optional(),minDwellSeconds:r().min(0).optional(),source:x([`pipeline`,`onboard`,`sensor`,`audio`,`any`]).optional(),minLabelConfidence:r().min(0).max(1).optional(),eventTypeTokens:S(u().min(1)).optional(),sensorKinds:S(u().min(1)).optional(),sensorTransition:CK.optional(),packagePhase:x([`delivered`,`picked-up`,`both`]).optional(),systemEvent:fK.optional(),customZones:S(GB).optional(),occupancy:bK.optional(),audio:xK.optional()}),MK=b({targetId:u().min(1),params:h(u(),C()).optional()}),NK=x([`none`,`image`,`clip`,`gif`]),PK=b({template:b({title:u().max(500).optional(),body:u().max(2e3).optional()}).optional(),schedule:hK.optional(),priority:r().int().min(1).max(5).optional(),attachment:NK.optional(),actions:v().optional()}),FK=h(u(),PK),IK=x([`scene-boxes`,`crop`,`clean`,`none`]),LK=x([`cropped`,`full`,`boxed`]),RK=x([`mosaic`,`each`]),zK=b({image:IK.optional(),showTriggerZone:v().optional(),showSubjectPath:v().optional(),attach:x([`best`,`best-matching`,`keyFrame`,`none`]).optional(),frame:LK.optional(),zoneCrop:v().optional(),gif:v().optional(),clip:v().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:A.optional(),linkedCameras:RK.optional(),wakeSleepingCamera:v().optional()}),BK=x([`shared`,`per-class`]),VK=b({cooldownSec:r().int().min(0).max(86400).default(60),scope:x([`rule`,`rule-device`]).default(`rule-device`),granularity:BK.optional()}),HK=1e3,UK=2e4,WK=8e3,GK=b({op:x([`>=`,`>`,`<=`,`<`,`==`]),count:r().int().min(0).max(1e3)}),KK=b({enabled:v().default(!1),profileId:u().optional(),prompt:u().max(1e3).optional(),expect:GK.optional(),timeoutMs:r().int().min(HK).max(UK).default(WK),onTimeout:x([`fire`,`suppress`]).default(`fire`),maxImagePx:r().int().min(64).max(2048).default(448)}),qK=b({name:u().min(1).max(200),enabled:v().default(!0),delivery:iK,conditions:jK.default({}),schedule:hK.optional(),systemEventDelivery:vK.optional(),targets:S(MK),targetUsers:S(u()).optional(),targetOverrides:FK.optional(),media:zK.default({}),throttle:VK.default({cooldownSec:60,scope:`rule-device`}),template:b({title:u().max(500).optional(),body:u().max(2e3).optional()}).optional(),priority:r().int().min(1).max(5).default(3),ownerUserId:u().optional(),snoozeAllowGlobal:v().optional(),snoozeOptions:S(r().int().min(1).max(pK)).max(4).optional(),actions:OK.optional(),confirm:KK.optional(),groupingSec:r().int().min(5).max(60).optional(),groupWithinSec:r().int().min(0).max(300).optional(),askVerdict:v().optional(),tags:Zu.optional()}),JK=x([`event`,`summary`,`timelapse`,`calendar-events`]),YK=b({kind:JK,ruleId:u(),tags:S(u())}),XK=qK.partial().extend({disabledTargetIds:S(u()).optional(),enabled:v().optional(),conditions:jK.optional(),media:zK.optional(),throttle:VK.optional(),priority:r().int().min(1).max(5).optional()}),ZK=[`waitForEnhancement`,`groupIdleSec`];function Jwe(e){return ZK.some(t=>t===e)}var QK=[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`actions`,`confirm`,`groupingSec`,`waitForEnhancement`,`groupIdleSec`],$K=x(QK),eq=b({ruleId:u(),patch:XK,clear:S($K).optional()}),tq=qK.extend({id:u(),createdBy:u(),createdAt:r(),updatedAt:r(),disabledTargetIds:S(u()).default([])}),nq=[`device-state`,`streams`,`battery`,`consumables`,`detection-blind`,`nodes`,`addons`,`addon-updates`,`updates`],rq=x(nq),iq=b({id:rq,status:x([`read`,`unavailable`]),items:r().int().nonnegative(),reason:u().optional()}),aq=b({section:rq.optional(),title:u(),text:u(),count:r().int().nonnegative()}),oq=b({empty:v(),count:r().int().nonnegative(),text:u(),sections:S(iq),dropped:h(u(),r().int().nonnegative()),excludedGroups:S(u()),split:_K.optional(),rows:S(aq).optional()}),sq=b({recordId:u(),recordKind:x([`object-event`,`track`,`device-event`,`package-event`,`system-event`]),deviceId:r(),timestamp:r(),wouldFire:v(),failedCondition:u().optional(),className:u().optional(),label:u().optional()}),cq=x([`detection`,`sensor`,`occupancy`,`sound`,`device-events`,`system`,`alarm`,`mixed`]),lq=x([`detection`,`sensor`,`occupancy`,`sound`,`system`]),uq=b({id:x([`appliance-cycle`]),kind:cq,title:u(),body:u()}),dq=x([`rule`,`timelapse`,`summary`]),fq=x([`title`,`body`,`previewText`,`captionText`]),pq=x([`subject`,`place`,`time`,`rule`,`occupancy`,`sound`,`sensor`,`system`,`digest`,`ai`]),mq=b({name:u().regex(/^\w+$/),label:u(),description:u().optional(),example:u(),group:pq,families:S(dq).min(1),fields:S(fq).optional(),kinds:S(lq).optional(),deliveries:S(iK).optional(),systemEventKinds:S(aK).optional(),systemEventDeliveries:S(gK).optional(),dynamic:b({prefix:m(`count_`),from:m(`classes`)}).optional()}),hq=b({family:dq,field:fq,kind:cq.optional(),delivery:iK.optional(),systemEventKinds:S(aK).optional(),systemEventDelivery:gK.optional()}),gq=b({context:hq,template:b({title:u().max(500).optional(),body:u().max(2e3).optional()})}),_q=b({title:u().nullable(),body:u().nullable(),unknown:S(u())}),vq=b({id:u(),group:x([`scope`,`class`,`zones`,`quality`,`label`,`schedule`,`device`,`package`,`occupancy`,`audio`,`system`]),label:u(),valueType:x([`deviceIdList`,`deviceIdExcludeList`,`stringList`,`number01`,`number`,`sourceSelect`,`zoneSelection`,`zoneIdList`,`schedule`,`plateMatcher`,`packagePhase`,`crossingSelect`,`sensorTransition`,`polygonDraw`,`occupancy`,`audio`,`deviceState`,`scene`,`systemEvent`]),operator:x([`in`,`notIn`,`anyOf`,`allOf`,`gte`,`fuzzyIn`,`withinSchedule`]),appliesTo:S(iK),phase:u(),description:u().optional(),options:S(b({value:u(),label:u(),hint:u().optional()})).readonly().optional()}),yq=[{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.`}],bq=x([`pending`,`sent`,`dead`]),xq=x([`object-event`,`track-end`,`device-event`,`package-event`,`system-event`]),Sq=b({className:u(),label:u().optional(),confidence:r().optional(),zones:S(u()),timestamp:r(),systemEvent:b({kind:aK,subject:u(),title:u(),body:u(),data:h(u(),C())}).optional()}),Cq=b({id:u(),ruleId:u(),ruleName:u(),delivery:iK,targetId:u(),deviceId:r(),recordKind:xq,recordId:u(),trackId:u().optional(),status:bq,attempts:r().int(),createdAt:r(),updatedAt:r(),error:u().optional(),subject:Sq,title:u().optional(),body:u().optional(),artifactIds:S(u().min(1)).optional(),groupedInto:u().min(1).optional()}),wq=b({ruleId:u().optional(),deviceId:r().optional(),status:bq.optional(),since:r().optional(),until:r().optional(),limit:r().int().min(1).max(500).default(100)}),Tq=b({ruleId:u(),lastAt:r(),status:bq,deviceId:r()}),Eq=b({runs:S(Tq),horizonMs:r().nonnegative().nullable()}),Dq=x([`rule`,`device`,`all`]),Oq=b({scope:Dq,ruleId:u().optional(),deviceId:r().int().optional(),classes:S(u().min(1)).min(1).optional(),durationMinutes:r().int().min(1).max(pK),global:v().optional(),summary:v().optional()}),kq=b({id:u(),userId:u(),scope:Dq,ruleId:u().optional(),deviceId:r().int().optional(),classes:S(u().min(1)).min(1).optional(),startedAt:r(),expiresAt:r(),global:v(),summary:v(),digestSentAt:r().optional()}),Ywe=b({snoozeId:u(),targetId:u(),ruleId:u(),ruleName:u(),deviceId:r().int(),count:r().int(),firstAt:r(),lastAt:r()}),Aq=3600,jq=r().int().min(0).max(600),Mq=r().int().min(0).max(Aq),Nq=e=>new Set(e.map(e=>e.mode)).size===e.length,Pq=x([`rearmAfter`,`disableAfter`,`doNothing`]),Fq=b({mode:Jv,exitDelaySec:jq.optional(),entryDelaySec:jq.optional(),triggeredDurationSec:Mq.optional(),postTriggeredAction:Pq.optional(),schedule:hK.optional(),notifyDuringEntryDelay:v().optional(),notifySensorRewatched:v().optional(),notifySensorIgnored:v().optional()}),Xwe=S(Fq).max(8).refine(Nq,{message:`modeDelays: at most one entry per arm mode`}),Iq=b({mode:Jv,exitDelaySec:jq.nullable().optional(),entryDelaySec:jq.nullable().optional(),triggeredDurationSec:Mq.nullable().optional(),postTriggeredAction:Pq.nullable().optional(),schedule:hK.nullable().optional(),notifyDuringEntryDelay:v().nullable().optional(),notifySensorRewatched:v().nullable().optional(),notifySensorIgnored:v().nullable().optional()}),Zwe=S(Iq).max(8).refine(Nq,{message:`modeDelays: at most one edit per arm mode`}),Lq=b({mode:Jv,deviceId:r().int().positive(),nonBlocking:v()}),Rq=b({mode:Jv,deviceId:r().int().positive(),blocking:v()}),zq=b({mode:Jv,deviceId:r().int().positive(),secureOnArm:v()}),Bq=b({mode:Jv,deviceIds:S(r().int()).max(200)}),Vq=Bq,Hq=Bq,Uq=Bq,Wq=S(Vq).max(8).refine(Nq,{message:`nonBlocking: at most one list per arm mode`}),Gq=S(Hq).max(8).refine(Nq,{message:`blocking: at most one list per arm mode`}),Kq=S(Uq).max(8).refine(Nq,{message:`secureOnArmOff: at most one list per arm mode`}),qq=b({exitDelaySec:jq,entryDelaySec:jq,triggeredDurationSec:Mq,postTriggeredAction:Pq.optional(),announceArm:v().optional(),announceTargets:S(u().min(1)).max(16),nonBlocking:Wq.default([]),blocking:Gq.default([]),secureOnArmOff:Kq.default([]),modeDelays:Xwe.default([])}),Jq=b({id:u().min(1).max(64),name:u().min(1).max(64),isDefault:v()}),Yq=b({activeId:u().min(1),items:S(Jq).min(1)}),Xq=b({name:u().min(1).max(64),cloneFromId:u().min(1).max(64).optional()}),Zq=b({id:u().min(1).max(64),name:u().min(1).max(64)}),Qq=b({id:u().min(1).max(64)}),$q=qq.extend({nonBlocking:Wq,blocking:Gq,secureOnArmOff:Kq,modeDelays:Zwe,nonBlockingEdit:Lq,blockingEdit:Rq,secureOnArmEdit:zq}).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`}),eJ=x([`muted`,`detection-off`,`offline`]),tJ=b({deviceId:r().int(),reason:eJ}),nJ=b({mode:Jv,ruleCount:r().int().min(0),allDevices:v(),deviceIds:S(r().int()),allDevicesExcept:S(r().int()).default([]),skippedDevices:S(tJ).default([])}),Qwe=b({deviceId:r().int(),name:u(),state:u(),blocking:v()}),$we=b({deviceId:r().int(),name:u(),phase:x([`open`,`closed`])}),eTe=b({mode:Jv,devices:S(Qwe),unknown:S(r().int())}),tTe=b({ruleId:u(),ruleName:u(),deviceId:r().int(),name:u(),since:r(),dropped:r().int().min(0)}),nTe=b({state:qv,targetMode:Jv.nullable(),availableModes:S(Jv),openings:S(eTe),exclusions:S($we),bypassedInputs:S(tTe).default([])}),rJ=b({deviceId:r().int().nullable(),settings:qq,profiles:Yq.optional(),coverage:S(nJ),live:nTe.optional()}),iJ=x([`open`,`closed`,`unknown`,`not-opening`]),aJ=b({deviceId:r().int().positive(),reading:iJ,state:u().nullable(),unknownWhy:x([`read-failed`,`unknown-word`]).nullable(),online:v().nullable(),controllable:v().default(!1)}),oJ=b({deviceIds:S(r().int().positive()).max(500)}),sJ=b({sensors:S(aJ),readAt:r().int().nonnegative()}),cJ=b({deviceId:r().int().nonnegative().optional(),seconds:r().min(0).max(60),profile:A.optional(),ruleId:u(),ruleName:u(),reason:x([`window`,`occupancy`])}),lJ=b({rulesLoaded:v(),asks:S(cJ).readonly()}),uJ={name:`notification-rules`,scope:`system`,mode:`singleton`,methods:{listRules:E(b({}),b({rules:S(tq)}),{auth:`admin`}),getRule:E(b({ruleId:u()}),b({rule:tq.nullable()}),{auth:`admin`}),createRule:E(b({rule:qK}),b({rule:tq}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateRule:E(eq,b({rule:tq}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteRule:E(b({ruleId:u()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setRuleEnabled:E(b({ruleId:u(),enabled:v()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),listRuleTags:E(b({}),b({rules:S(YK)}),{kind:`query`,auth:`admin`}),setRuleTags:E(b({kind:JK,ruleId:u(),tags:Zu}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getClipRetentionAsks:E(b({}),lJ,{auth:`admin`}),listDeviceMutes:E(b({}),b({mutedDeviceIds:S(r().int()).readonly()}),{auth:`admin`}),setDeviceMuted:E(b({deviceId:r().int(),muted:v()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),testRule:E(b({rule:qK,lookbackMinutes:r().int().min(1).max(1440).default(60)}),b({results:S(sq)}),{kind:`mutation`,auth:`admin`}),previewStateSummary:E(b({rule:qK}),oq,{kind:`mutation`,auth:`admin`,access:`view`}),getConditionCatalog:E(b({}),b({catalog:S(vq),taxonomy:tK.optional()})),getTemplateCatalog:E(b({}),b({vars:S(mq),defaults:S(uq)})),previewTemplate:E(gq,_q,{kind:`mutation`,access:`view`}),getHistory:E(b({filter:wq.default({limit:100})}),b({entries:S(Cq)}),{auth:`admin`}),getRuleLastRuns:E(b({}),Eq,{auth:`admin`}),resolveArtifactUrl:E(b({artifactId:u().min(1)}),b({url:u().nullable()}),{auth:`admin`}),listSnoozes:E(b({}),b({snoozes:S(kq)}),{caller:`required`}),createSnooze:E(b({snooze:Oq}),b({snooze:kq}),{kind:`mutation`,caller:`required`}),cancelSnooze:E(b({snoozeId:u()}),b({success:m(!0)}),{kind:`mutation`,caller:`required`}),getAlarmConfig:E(b({}),rJ,{auth:`admin`}),setAlarmConfig:E(b({patch:$q}),rJ,{kind:`mutation`,auth:`admin`}),createAlarmProfile:E(Xq,rJ,{kind:`mutation`,auth:`admin`}),renameAlarmProfile:E(Zq,rJ,{kind:`mutation`,auth:`admin`}),deleteAlarmProfile:E(Qq,rJ,{kind:`mutation`,auth:`admin`}),activateAlarmProfile:E(Qq,rJ,{kind:`mutation`,auth:`admin`}),getAlarmSensors:E(oJ,sJ,{auth:`admin`})},vocabulary:{notOperatorFacing:`notification rules — authored on their own page`}},rTe=x([`min`,`low`,`normal`,`high`]),iTe=b({id:u().min(1),title:u().min(1),uri:i().optional(),destructive:v().optional()}),aTe=b({image:v(),priority:v(),data:v(),actions:v(),recipients:v()}),dJ=b({lastSentAt:r(),lastError:u().nullable(),queueDepth:r().int().nonnegative().meta(k(`count`)),supports:aTe}),oTe=b({deviceId:r().int().nonnegative(),title:u().optional(),body:u().min(1),image:u().optional(),priority:rTe.optional(),channel:u().optional(),recipients:S(u()).optional(),actions:S(iTe).optional(),data:h(u(),C()).optional()}),sTe=b({notificationId:u(),acceptedAt:r()}),fJ={name:`notifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Notifier],methods:{send:E(oTe,sTe,{kind:`mutation`,auth:`admin`,actions:[{id:`notifier.send`,label:I(`Send a notification`,`Invia una notifica`),phrase:I(`Send “{body}” through {device}`,`Invia «{body}» tramite {device}`),icon:`send`,openArgs:[{key:`title`,label:I(`Title`,`Titolo`),offer:{kind:`text`},optional:!0},{key:`body`,label:I(`Message`,`Messaggio`),offer:{kind:`text`}},{key:`priority`,label:I(`Priority`,`Priorità`),offer:{kind:`enum`,values:[{value:`min`,label:I(`Minimal`,`Minima`)},{value:`low`,label:I(`Low`,`Bassa`)},{value:`normal`,label:I(`Normal`,`Normale`)},{value:`high`,label:I(`High`,`Alta`)}]},optional:!0}]}]}),cancel:E(b({deviceId:r().int().nonnegative(),notificationId:u().min(1)}),_(),{kind:`mutation`,auth:`admin`})},events:{onSent:{data:b({deviceId:r(),notificationId:u(),success:v(),error:u().nullable(),acceptedAt:r()}),notOperatorFacing:`a delivery receipt of a send this system made — not a fact about the world`}},status:{schema:dJ,kind:`command-driven`},runtimeState:dJ,durability:`session`,history:`none`,vocabulary:{noun:I(`Notifier`,`Notificatore`),order:2110}},pJ=b({value:r().nullable().meta(k(`device`)),lastFetchedAt:r()}),mJ={name:`numeric-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:pJ,kind:`push`},runtimeState:pJ,durability:`restored`,history:{fields:{value:{kind:`gauge`,minIntervalMs:3e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Sensor`,`Sensore`),order:5150,state:[{kind:`numeric`,field:`value`,quantity:I(`the reading`,`il valore`),label:I(`Reading`,`Valore`),icon:`gauge`}]}},hJ=b({integrationId:u(),displayName:u(),requestedScopes:S(xf),allowedRedirectPrefixes:S(u()).min(1),allowedPrivateHostPaths:S(u()).optional(),requiresPkce:v().optional(),hubUrl:u().optional(),refreshTokenTtlSec:g([r().int().positive(),m(`never`)]).optional(),instances:S(b({id:u(),displayName:u()})).optional()}),gJ={name:`oauth-integration`,scope:`system`,mode:`collection`,internal:!0,methods:{getDescriptor:E(_(),hJ,{auth:`admin`})},vocabulary:{notOperatorFacing:O.IDENTITY}},_J=x([`text`,`timestamp`,`watermark`]),vJ=x([`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`custom`]),yJ=b({id:u(),kind:_J,enabled:v(),text:u().optional(),position:vJ.optional(),availablePositions:S(vJ).readonly(),readOnly:v().optional(),maxCharacters:r().int().positive().optional()}),bJ=b({overlays:S(yJ).readonly()}),xJ=b({enabled:v().optional(),text:u().optional(),position:vJ.optional()}).partial(),SJ={name:`osd`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{setOverlay:E(b({deviceId:r(),overlayId:u(),patch:xJ}),_(),{kind:`mutation`,auth:`admin`})},events:{onStatusChanged:{data:b({deviceId:r(),status:bJ}),notOperatorFacing:`an overlay setting changed — configuration, not a happening`}},status:{schema:bJ,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:I(`On-screen text`,`Testo in sovrimpressione`),order:3190}},CJ=1024,wJ=b({id:u().min(1).max(64),name:u().min(1).max(64),text:u().max(CJ).default(``)}),TJ=a(`kind`,[b({kind:m(`none`)}),b({kind:m(`static`),text:u().max(CJ)}),b({kind:m(`template`),templateId:u().min(1).max(64)})]),EJ=b({enabled:v().default(!0),source:TJ,schedule:hK.optional(),conditions:jK.optional()}),DJ=b({slotId:u(),kind:_J,readOnly:v(),cameraEnabled:v(),cameraText:u().optional(),binding:EJ.nullable()}),OJ=x([`written`,`unchanged`,`gated`,`unreadable`,`disabled`,`unbound`,`failed`]),kJ=b({slotId:u(),outcome:OJ,text:u(),reason:u().optional()}),AJ=b({ok:v(),text:u(),notes:S(u())}),jJ={name:`osd-manager`,scope:`system`,mode:`singleton`,methods:{getDeviceOsd:E(b({deviceId:r().int()}),b({supported:v(),slots:S(DJ)}),{auth:`admin`}),getConditionSupport:E(b({}),b({supported:S(u()),catalog:S(vq)}),{auth:`admin`}),setSlotBinding:E(b({deviceId:r().int(),slotId:u().min(1),binding:EJ}),b({slot:DJ,render:kJ}),{kind:`mutation`,auth:`admin`}),clearSlotBinding:E(b({deviceId:r().int(),slotId:u().min(1)}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setSlotCameraEnabled:E(b({deviceId:r().int(),slotId:u().min(1),enabled:v()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),copyDeviceConfiguration:E(b({sourceDeviceId:r().int(),targetDeviceId:r().int()}),b({copied:r().int().nonnegative(),skipped:r().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),previewSlot:E(b({deviceId:r().int(),slotId:u().min(1),binding:EJ.optional()}),kJ,{kind:`mutation`,auth:`admin`}),previewTemplate:E(b({deviceId:r().int(),text:u().max(CJ)}),AJ,{kind:`mutation`,auth:`admin`}),renderDevice:E(b({deviceId:r().int()}),b({results:S(kJ)}),{kind:`mutation`,auth:`admin`}),listTemplates:E(b({}),b({templates:S(wJ)}),{auth:`admin`}),upsertTemplate:E(b({template:wJ}),b({template:wJ}),{kind:`mutation`,auth:`admin`}),deleteTemplate:E(b({templateId:u().min(1).max(64)}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},MJ=1e4,cTe=x([`normal`,`offline`,`on_batteries`]),NJ=r().int().min(4).max(200),PJ=NJ.meta(Ah({quantity:`mass`,unit:`g`})),FJ=b({foodLevel:r().nullable().meta(k(`none`)),bowlFood:r().nullable().meta(k(`mass`)),eating:v(),supportsMarkRefilled:v(),food1:r().nullable().meta(k(`none`)),food2:r().nullable().meta(k(`none`)),lowFood:v(),batteryPower:r().min(0).max(100).nullable().meta(k(`percentage`)),powerSource:x([`mains`,`battery`]).nullable(),desiccantLeftDays:r().nullable().meta(k(`duration`)),feeding:v(),status:cTe.nullable(),error:u().nullable(),errorCode:r().nullable().meta(k(`none`)),isDualHopper:v(),childLock:v(),indicatorLight:v(),feedSound:v(),volume:r().meta(k(`none`)),lastFeedGrams:NJ.nullable(),lastFeedHopper1:NJ.nullable(),lastFeedHopper2:NJ.nullable(),lastFetchedAt:r()}),IJ={name:`pet-feeder`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.PetFeeder],methods:{feed:E(b({deviceId:r().int().nonnegative(),grams:PJ.optional(),hopper1:PJ.optional(),hopper2:PJ.optional()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feed`,label:I(`Feed`,`Dai da mangiare`),phrase:I(`Dispense {grams} from {device}`,`Eroga {grams} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:MJ},openArgs:[{key:`grams`,label:I(`Grams`,`Grammi`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]},{id:`petFeeder.feedHoppers`,label:I(`Feed from both hoppers`,`Eroga da entrambi i serbatoi`),phrase:I(`Dispense {hopper1} and {hopper2} from {device}`,`Eroga {hopper1} e {hopper2} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:MJ},openArgs:[{key:`hopper1`,label:I(`Hopper 1`,`Serbatoio 1`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0},{key:`hopper2`,label:I(`Hopper 2`,`Serbatoio 2`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]}]}),cancelFeed:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.cancelFeed`,label:I(`Cancel feeding`,`Annulla l’erogazione`),phrase:I(`Cancel the feeding on {device}`,`Annulla l’erogazione di {device}`),icon:`circle-x`}]}),callPet:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.callPet`,label:I(`Call pet`,`Chiama l’animale`),phrase:I(`Call your pet with {device}`,`Chiama l’animale con {device}`),icon:`megaphone`}]}),playSound:E(b({deviceId:r().int().nonnegative(),soundId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.playSound`,label:I(`Play sound`,`Riproduci un suono`),phrase:I(`Play sound {soundId} on {device}`,`Riproduci il suono {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:I(`Sound`,`Suono`),offer:{kind:`number`,min:0,step:1}}]}]}),resetDesiccant:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.resetDesiccant`,label:I(`Desiccant replaced`,`Essiccante sostituito`),phrase:I(`Mark the desiccant of {device} as replaced`,`Segna come sostituito l’essiccante di {device}`),icon:`refresh-cw`}]}),markFoodReplenished:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.foodReplenished`,label:I(`Food refilled`,`Cibo ricaricato`),phrase:I(`Mark {device} as refilled`,`Segna {device} come ricaricato`),icon:`package`}]}),setChildLock:E(b({deviceId:r().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.childLockOn`,effect:{field:`childLock`,value:!0},label:I(`Child lock on`,`Blocco bambini attivo`),phrase:I(`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:I(`Child lock off`,`Blocco bambini spento`),phrase:I(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setIndicatorLight:E(b({deviceId:r().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.lightOn`,effect:{field:`indicatorLight`,value:!0},label:I(`Indicator light on`,`Spia accesa`),phrase:I(`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:I(`Indicator light off`,`Spia spenta`),phrase:I(`Turn off the indicator light of {device}`,`Spegni la spia di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setFeedSound:E(b({deviceId:r().int().nonnegative(),on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feedSoundOn`,effect:{field:`feedSound`,value:!0},label:I(`Feeding sound on`,`Suono di erogazione attivo`),phrase:I(`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:I(`Feeding sound off`,`Suono di erogazione spento`),phrase:I(`Turn off the feeding sound of {device}`,`Disattiva il suono di erogazione di {device}`),icon:`volume-x`,args:{on:!1}}]}),setVolume:E(b({deviceId:r().int().nonnegative(),level:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.volume`,effect:{field:`volume`,fromArg:`level`},label:I(`Set volume`,`Imposta il volume`),phrase:I(`Set the volume of {device} to {level}`,`Imposta il volume di {device} a {level}`),icon:`volume-2`,openArgs:[{key:`level`,label:I(`Volume`,`Volume`),offer:{kind:`number`,min:0,step:1}}]}]})},status:{schema:FJ,kind:`poll`},runtimeState:FJ,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:I(`Pet feeder`,`Distributore di cibo`),order:2030,state:[{kind:`boolean`,field:`lowFood`,label:I(`Food low`,`Cibo in esaurimento`),whenTrue:I(`When {device} runs low on food`,`Quando il cibo di {device} sta finendo`),whenFalse:I(`When {device} has enough food again`,`Quando {device} ha di nuovo cibo a sufficienza`),icon:`package`},{kind:`boolean`,field:`feeding`,label:I(`Feeding`,`In erogazione`),whenTrue:I(`When {device} starts feeding`,`Quando {device} inizia a erogare`),whenFalse:I(`When {device} finishes feeding`,`Quando {device} finisce di erogare`),icon:`paw-print`},{kind:`numeric`,field:`desiccantLeftDays`,quantity:I(`the desiccant life`,`la durata dell’essiccante`),label:I(`Desiccant`,`Essiccante`),unit:`d`,icon:`calendar-clock`}]}},LJ=b({waterLevel:r().min(0).max(100).nullable().meta(k(`percentage`)),waterVolume:r().min(0).nullable().meta(k(`volume`)),empty:v().nullable(),pumpRunning:v().nullable(),error:u().nullable(),lastFetchedAt:r()}),RJ=`water`;function lTe(e){let t=e.waterLevel!==null||e.empty===null?null:e.empty?`empty`:`ok`;return{key:RJ,label:`Water`,level:e.waterLevel,status:t,kind:`supply`,form:`tank`,lastResetAt:null,resettable:!1}}var uTe=r().int().nonnegative(),zJ={name:`pet-fountain`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.PetFountain],power:{kind:`field`,field:`pumpRunning`,set:`setPump`},methods:{setPump:E(b({deviceId:uTe,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFountain.pumpOn`,effect:{field:`pumpRunning`,value:!0},label:I(`Pump on`,`Pompa accesa`),phrase:I(`Start the pump of {device}`,`Avvia la pompa di {device}`),icon:`play`,args:{on:!0}},{id:`petFountain.pumpOff`,effect:{field:`pumpRunning`,value:!1},label:I(`Pump off`,`Pompa spenta`),phrase:I(`Stop the pump of {device}`,`Ferma la pompa di {device}`),icon:`square`,args:{on:!1}}]})},status:{schema:LJ,kind:`push`},runtimeState:LJ,durability:`session`,history:{fields:{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}}},vocabulary:{noun:I(`Pet fountain`,`Fontana per animali`),order:2040,state:[{kind:`boolean`,field:`empty`,label:I(`Tank empty`,`Serbatoio vuoto`),whenTrue:I(`When the tank of {device} is empty`,`Quando il serbatoio di {device} è vuoto`),whenFalse:I(`When the tank of {device} is refilled`,`Quando il serbatoio di {device} viene riempito`),icon:`droplet`},{kind:`numeric`,field:`waterLevel`,quantity:I(`the water level`,`il livello dell’acqua`),label:I(`Water level`,`Livello dell’acqua`),unit:`%`,icon:`droplets`}]}},dTe=x(Ld),BJ={min:1,max:8},VJ=x([`intel-core-ultra`,`intel-n-series`,`apple-m-base`,`apple-m-pro`,`amd-phoenix`,`unknown`]),HJ=x([`intel-npu`,`intel-igpu`,`amd-igpu`,`amd-npu`,`x86-cpu`,`arm-cpu`,`apple-ane`,`coral`]),UJ=a(`kind`,[b({kind:m(`capacity`),sessions:r(),minSessions:r()}),b({kind:m(`tie-faster`),over:u(),recallDelta:r()}),b({kind:m(`stepped-down`),from:u(),to:u(),limitedBy:u()}),b({kind:m(`no-fit-lightest`),sessions:r(),minSessions:r()}),b({kind:m(`derived-latency`),modelId:u()}),b({kind:m(`cpu-device`)}),b({kind:m(`device-disabled`)}),b({kind:m(`device-unavailable`)}),b({kind:m(`node-offline`)}),b({kind:m(`no-hardware-facts`)}),b({kind:m(`no-measured-data`),hardwareClass:VJ}),b({kind:m(`no-family-build`),format:dTe}),b({kind:m(`kept-custom-pin`),modelId:u(),deviceKey:u()})]),WJ=x([`custom-pin`]),GJ=a(`kind`,[b({kind:m(`table`)}),b({kind:m(`node-benchmark`),resultId:u(),measuredAtMs:r()}),b({kind:m(`estimated`),estimatedFrom:VJ})]),KJ=b({modelId:u(),p50Ms:r(),fps:r(),measured:v(),source:GJ.optional(),estimatedFrom:VJ.optional(),capacitySessions:r(),personRecall:r()}),qJ=b({deviceKey:u(),accelerator:HJ.nullable(),enabled:v(),available:v(),chosen:KJ.nullable(),kept:WJ.optional(),reasons:S(UJ).readonly()}),JJ=b({nodeId:u(),reachable:v(),hardwareClass:VJ.nullable(),cpuModel:u().nullable(),skipped:v(),acceleratorModelId:u().nullable(),devices:S(qJ).readonly(),reasons:S(UJ).readonly()}),YJ=b({stepId:u(),before:u().nullable(),after:u().nullable()}),XJ=b({nodeId:u(),deviceKey:u(),madeExplicit:v(),modelPins:S(YJ).readonly(),thresholds:S(b({stepId:u(),keys:S(u()).readonly()})).readonly()}),ZJ=a(`kind`,[b({kind:m(`custom-pin-kept`),nodeId:u(),deviceKey:u(),modelId:u()}),b({kind:m(`custom-registry-unreadable`),error:u()})]),QJ=b({headroom:r().min(.3).max(.5).default(.4),minSessionsPerDevice:r().int().min(BJ.min).max(BJ.max).default(2)}),$J=b({planHash:u(),family:m(`yolov9`),headroom:r(),minSessionsPerDevice:r(),cameraFps:r(),generatedAt:r(),nodes:S(JJ).readonly(),nodeChanges:S(XJ).readonly(),warnings:S(ZJ).readonly()}),eY=b({planHash:u(),headroom:r().min(.3).max(.5).default(.4),minSessionsPerDevice:r().int().min(BJ.min).max(BJ.max).default(2)}),tY=b({phase:x([`download`,`node-models`,`redispatch`]),ok:v(),detail:u()}),nY=a(`kind`,[b({kind:m(`applied`),planHash:u(),phases:S(tY).readonly()}),b({kind:m(`aborted`),phases:S(tY).readonly()}),b({kind:m(`stale`),plan:$J}),b({kind:m(`refused`),reason:x([`apply-in-progress`])})]),rY=x([`least-loaded`,`share`]),iY=`share`,fTe=`sessionPlacement`;function pTe(e){let t=rY.safeParse(e);return t.success?t.data:iY}var aY=b({nodes:h(u(),r().positive()).default({}),devices:h(u(),h(u(),r().positive())).default({})}),oY=b({windowMs:r().int().min(6e4).max(1440*60*1e3).default(3600*1e3)}),sY=b({deviceKey:u(),sessionsNow:r(),sessionsStarted:r(),observedShare:r().nullable()}),cY=b({nodeId:u(),sessionsNow:r(),sessionsStarted:r(),observedShare:r().nullable(),peakSessions:r(),yieldsAway:r(),devices:S(sY).readonly()}),lY=b({deviceId:r(),deviceKey:u(),reason:x([`disabled`,`absent`])}),uY=b({policy:rY,windowMs:r(),observedForMs:r(),sessionsNow:r(),clusterPeakSessions:r(),nodes:S(cY).readonly(),stalePins:S(lY).readonly()}),dY=x([`hardware`,`benchmark`]),fY=x([`no-benchmark-results`,`partial-benchmark-results`]),pY=b({headroom:r().min(.3).max(.5).default(.4),source:dY.default(`hardware`)}),mY=b({deviceKey:u(),share:r(),modelId:u().nullable(),fps:r().nullable(),measured:v(),suggestedMaxSessions:r().nullable()}),hY=b({nodeId:u(),share:r().nullable(),capacitySessions:r(),devices:S(mY).readonly(),skippedReason:u().nullable(),capacitySource:dY.nullable(),capacityFallback:fY.nullable()}),gY=b({headroom:r(),source:dY,cameraFps:r(),minSessionsPerDevice:r(),nodes:S(hY).readonly()}),_Y=x([`hardware`,`benchmark`,`manual`]),vY=`benchmark`;function yY(e){return e!==`manual`}var mTe=.4,hTe=`shareSource`;function gTe(e){if(e===`auto`)return`hardware`;let t=_Y.safeParse(e);return t.success?t.data:vY}var bY=b({source:_Y}),_Te=b({nodes:h(u(),r()),devices:h(u(),h(u(),r()))}),xY=b({deviceKey:u(),eligible:v(),configuredPct:r(),effectivePct:r()}),SY=b({nodeId:u(),eligible:v(),configuredPct:r(),effectivePct:r(),capacitySource:dY.nullable(),capacityFallback:fY.nullable(),devices:S(xY).readonly()}),CY=b({source:_Y,policy:rY,autoPending:v(),computedAt:r().nullable(),trigger:u().nullable(),nodes:S(SY).readonly(),nodeWeights:h(u(),r()),deviceWeights:h(u(),h(u(),r()))}),wY=[`motion-without-detections`,`detections-under-floor`,`inference-too-slow`,`frames-shed`,`inference-device-unusable`],TY=x(wY),EY=x([`info`,`warning`,`critical`]),DY=a(`type`,[b({type:m(`camera`),deviceId:r()}),b({type:m(`node`),nodeId:u()}),b({type:m(`inference-device`),nodeId:u(),deviceKey:u()})]),OY=b({id:u(),kind:TY,severity:EY,subject:DY,what:u(),evidence:h(u(),r().nullable()),action:u()}),kY=b({source:u(),entries:r().nullable()}),AY=b({nodeId:u(),sessionsNow:r(),unusableDevices:S(u()).readonly(),devices:S(b({deviceKey:u(),sessionsNow:r(),usable:v()})).readonly()}),jY=b({deviceId:r(),nativeCropMissesSincePreviousTick:r().nullable()}),MY=b({generatedAt:r(),tickMs:r(),camerasSeen:r().nullable(),findings:S(OY).readonly(),cameraSignals:S(jY).readonly(),nodes:S(AY).readonly(),sources:S(kY).readonly(),notCovered:S(u()).readonly()}),NY=b({history:r().int().min(1).max(24).default(1)}),PY=b({latest:MY.nullable(),previous:S(MY).readonly()}),vTe=b({engine:fU.optional(),steps:S(aU).readonly(),audio:b({engine:fU.optional(),modelId:u().optional(),enabled:v(),settings:h(u(),C()).readonly().optional()}).nullable().optional()}),FY=b({modelId:u().optional(),settings:h(u(),C()).optional(),jumpDeviceKey:u().optional(),enabled:v().optional()}),IY=b({maxCameras:r().int().nonnegative().nullable().default(null),detectWeight:r().positive().optional(),detect:v().optional(),decode:v().optional(),audio:v().optional(),ingest:v().optional(),decodeBudgetMb:r().int().min(1024).max(65536).optional(),maxLiveDecodeWorkers:r().int().min(1).max(32).optional(),reachableHost:u().optional(),color:Nu.optional(),stepSettings:h(u(),h(u(),C()).readonly()).optional(),stepEnabled:h(u(),v()).optional(),inferenceDevices:h(u(),b({enabled:v(),weight:r().positive().optional(),maxSessions:r().int().positive().optional(),steps:h(u(),FY).optional()})).optional()}),yTe=h(u(),h(u(),C()).readonly()),LY=x([`pipeline`,`onboard`,`none`]),bTe=b({stepToggles:h(u(),v()).optional(),stepSettings:yTe.optional()}),RY=b({deviceId:r(),agentNodeId:u(),pinned:v(),reason:x([`manual`,`capacity`,`hardware-affinity`,`failover`,`rebalance`]),assignedAt:r()}),zY=b({nodeId:u(),online:v(),load:TW,score:r(),decodeHwaccel:u().nullable()}),BY=b({totalAgents:r(),onlineAgents:r(),totalCameras:r(),attachedCameras:r(),activeCameras:r(),avgInferenceTimeMs:r(),queueDepth:r()}),VY=h(u(),u()),HY=b({ownerNodeId:u(),reachableHost:u().optional(),configIssue:u().optional()}),UY=b({camStreamId:u(),codec:u(),width:r(),height:r(),fps:r(),kind:u()}),WY=b({streams:S(UY).readonly()}),GY=b({detectionNodeId:u().nullable(),decoderNodeId:u().nullable(),audioNodeId:u().nullable(),sourceNodeId:u().nullable(),pinned:b({detection:v(),decoder:v(),audio:v()}),reasons:b({detection:u().optional(),decoder:u().optional(),audio:u().optional()})}),KY=b({profile:u(),status:u(),codec:u(),width:r(),height:r(),subscribers:r(),inFps:r().nullable()}),qY=b({profiles:S(KY).readonly(),webrtcSessions:r(),rtspRestream:v()}),JY=b({nodeId:u()}),YY=b({enabled:v(),fps:r()}),XY=x([`idle`,`installing`,`verifying`,`ready`,`failed`]),ZY=b({state:XY,error:u().optional()}),QY=x([`idle`,`watching`,`active`]),$Y=b({nodeId:u(),engine:b({backend:u(),device:u()}),phase:QY,configuredFps:r(),actualFps:r(),queueDepth:r(),avgInferenceMs:r(),provisioning:ZY}),eX=b({nodeId:u(),enabled:v()}),tX=kc,nX=b({mode:tX,active:v(),storageBytes:r()}),rX=x([`source`,`broker`,`detection`,`recording`,`switches`]),iX=x([`timeout`,`error`,`partial`]),aX=b({stage:rX,reason:iX,elapsedMs:r()}),oX=b({state:x([`idle`,`running`,`done`,`error`]),total:r().int().nonnegative(),completed:r().int().nonnegative(),currentDeviceId:r().int().nullable(),failed:S(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()}),sX=b({deviceId:r(),assignment:GY,source:WY,broker:qY.nullable(),decoder:JY.nullable(),motion:YY.nullable(),detection:$Y.nullable(),audio:eX.nullable(),recording:nX.nullable(),switchedOff:S(Za).readonly(),cameraSensors:LB.optional(),degraded:S(aX).readonly(),fetchedAt:r()}),cX=[`disabled`,`unavailable`,`cannot-host-camera-root`,`accelerator-preferred`,`root-switched-off`,`no-gpu-device`],lX=x(cX),xTe=b({key:u(),backend:u(),device:u(),format:x(Ld),available:v(),presence:x([`present`,`absent`,`unknown`]).optional(),enabled:v(),weight:r(),maxSessions:r().nullable(),defaultModelId:u(),steps:h(u(),FY).optional(),exclusion:lX.nullable()}),uX=a(`kind`,[b({kind:m(`stored`),modelId:u()}),b({kind:m(`absent`),defaultModelId:u()}),b({kind:m(`unreadable`),reason:x(ZB),error:u().optional()})]),STe=b({nodeId:u(),reachable:v(),devices:S(xTe).readonly()}),dX=x([`off`,`on`,`opt-in`]),fX=a(`kind`,[b({kind:m(`on`)}),b({kind:m(`off-cluster`)}),b({kind:m(`off-node`)}),b({kind:m(`off-device`)}),b({kind:m(`jump`),toDeviceKey:u()}),b({kind:m(`skip`),reason:x([`no-compatible-model`,`root-not-runnable-on-elected-device`])}),b({kind:m(`zone-driven`)}),b({kind:m(`supplied-by-root`),rootModelId:u()}),b({kind:m(`opt-in-unused`)})]),CTe=b({deviceKey:u(),format:x(Ld),stepEnabled:v().nullable(),eligible:v(),cell:fX}),wTe=b({nodeId:u(),reachable:v(),stepEnabled:v().nullable(),devices:S(CTe).readonly()}),pX=b({steps:S(b({stepId:u(),name:u(),slot:u(),clusterMode:dX.nullable(),effectiveMode:dX,camerasEnabling:r().int().nonnegative(),camerasDisabling:r().int().nonnegative(),nodes:S(wTe).readonly()})).readonly()}),mX=b({deviceId:r().int().nonnegative(),config:AB.nullable()}),hX=x([`unknown-camera`,`out-of-range`,`no-burst-producer`,`already-looked`]),gX=b({deviceId:r().int().nonnegative(),afterMs:r().finite(),reason:u()}),_X=b({scheduled:v(),dueInMs:r().optional(),refusedBecause:hX.optional()}),vX={name:`pipeline-orchestrator`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,exposesDeviceSettings:!0,methods:{requestOccupancyLook:E(gX,_X,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:E(Yc,b({paused:m(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:E(Yc,b({resumed:m(!0)}),{kind:`mutation`,auth:`admin`}),assignPipeline:E(b({deviceId:r(),agentNodeId:u()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),unassignPipeline:E(b({deviceId:r()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setPipelineDevicePin:E(b({deviceId:r(),deviceKey:u()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getPipelineDevicePin:E(b({deviceId:r()}),b({deviceKey:u().nullable()})),rebalance:E(_(),b({migrated:r(),skipped:S(b({deviceId:r(),targetNodeId:u(),reason:u()})).default([])}),{kind:`mutation`,auth:`admin`}),getPipelineAssignments:E(_(),S(RY).readonly()),getPipelineAssignment:E(b({deviceId:r()}),RY.nullable()),getAgentLoad:E(_(),S(zY).readonly()),getClusterModelChoice:E(b({stepId:u()}),uX),getGlobalMetrics:E(_(),BY),getCameraMetrics:E(b({deviceId:r()}),yU.nullable()),getCapabilityBindings:E(b({nodeId:u()}),VY),setCapabilityBinding:E(b({nodeId:u(),capName:u(),addonId:u()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getIngestOwner:E(_(),HY),assignAudio:E(b({deviceId:r(),nodeId:u()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),unassignAudio:E(b({deviceId:r()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getAudioAssignment:E(b({deviceId:r()}),b({nodeId:u(),pinned:v(),assignedAt:r()}).nullable()),getAudioNodeLoad:E(_(),S(b({nodeId:u(),deviceCount:r()}))),getAudioAssignments:E(_(),S(b({deviceId:r(),nodeId:u(),pinned:v(),assignedAt:r()}))),getAgentSettings:E(b({agentNodeId:u()}),IY.nullable()),listAgentSettings:E(_(),S(b({nodeId:u(),settings:IY})).readonly()),removeAgentSettings:E(b({agentNodeId:u()}),b({success:v(),removed:v()}),{kind:`mutation`,auth:`admin`}),setAgentMaxCameras:E(b({agentNodeId:u(),maxCameras:r().int().nonnegative().nullable()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentCapabilities:E(b({agentNodeId:u(),detect:v().nullable().optional(),audio:v().nullable().optional(),ingest:v().nullable().optional()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentDecodeLimits:E(b({agentNodeId:u(),decodeBudgetMb:r().int().min(1024).max(65536).nullable().optional(),maxLiveDecodeWorkers:r().int().min(1).max(32).nullable().optional()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentReachableHost:E(b({agentNodeId:u(),reachableHost:u().nullable().optional(),color:Nu.nullable().optional()}).refine(e=>e.reachableHost!==void 0||e.color!==void 0,{message:`reachableHost or color required`}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setAgentInferenceDevices:E(b({agentNodeId:u(),inferenceDevices:h(u(),b({enabled:v(),weight:r().positive().optional(),maxSessions:r().int().positive().optional(),steps:h(u(),FY).optional()}))}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepSettings:E(b({agentNodeId:u(),addonId:u(),settings:h(u(),C()).nullable()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setClusterStepMode:E(b({stepId:u(),mode:dX.nullable()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepEnabled:E(b({agentNodeId:u(),stepId:u(),enabled:v().nullable()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setDeviceStepEnabled:E(b({agentNodeId:u(),deviceKey:u(),stepId:u(),enabled:v().nullable()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getStepSwitches:E(_(),pX),getNodeInferenceDevices:E(b({nodeId:u()}),STe),forgetInferenceDevice:E(b({agentNodeId:u(),deviceKey:u()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),resetNodePipelineDefaults:E(b({agentNodeId:u()}),b({success:m(!0),effectiveModelId:u().nullable()}),{kind:`mutation`,auth:`admin`}),planAutoTune:E(QJ,$J,{auth:`admin`}),applyAutoTune:E(eY,nY,{kind:`mutation`,auth:`admin`}),setLoadBalancingShares:E(aY,b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getPlacementStats:E(oY,uY,{auth:`admin`}),getHealthDigest:E(NY,PY,{auth:`admin`}),suggestShares:E(pY,gY,{auth:`admin`}),getEffectiveShares:E(_(),CY,{auth:`admin`}),setShareSource:E(bY,b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkPreflight:E(OU,NU,{auth:`admin`}),startNodeBenchmark:E(OU,a(`kind`,[b({kind:m(`started`),runId:u()}),b({kind:m(`refused`),preflight:NU})]),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkStatus:E(_(),JU,{auth:`admin`}),abortNodeBenchmark:E(b({runId:u()}),b({aborted:v()}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkCandidates:E(b({nodeId:u()}),QU,{auth:`admin`}),listNodeBenchmarkResults:E(XU,S(ZU).readonly(),{auth:`admin`}),deleteNodeBenchmarkResult:E(b({id:u()}),b({deleted:v()}),{kind:`mutation`,auth:`admin`}),getCameraSettings:E(b({deviceId:r()}),bTe.nullable()),setCameraStepToggle:E(b({deviceId:r(),addonId:u(),enabled:v().nullable()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),getCameraDetectionSource:E(b({deviceId:r()}),b({source:LY,explicit:v(),onboard:b({available:v(),geometry:x([`boxed`,`while-streaming`,`flag-only`,`unknown`])})})),setCameraDetectionSource:E(b({deviceId:r(),source:LY}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),setCameraStepSettings:E(b({deviceId:r(),addonId:u(),settings:h(u(),C()).nullable()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),resolvePipeline:E(b({deviceId:r(),agentNodeId:u().optional()}),vTe),getCameraSwitches:E(b({deviceId:r()}),$a,{role:`viewer`}),setCameraSwitch:E(b({deviceId:r(),switchId:Za,enabled:v()}),$a,{kind:`mutation`,auth:`admin`}),getCameraStatus:E(b({deviceId:r()}),sX),getCameraStatuses:E(b({deviceIds:S(r()).optional()}),S(sX).readonly()),setCameraSensors:E(mX,b({success:m(!0)}),{kind:`mutation`,auth:`admin`}),reconcileFromDisk:E(_(),oX,{kind:`mutation`,auth:`admin`}),getReconcileFromDiskStatus:E(_(),oX,{auth:`admin`})},vocabulary:{notOperatorFacing:O.PIPELINE}},yX=b({id:u(),name:u(),sampleCount:r().int().nonnegative(),coverMediaId:r().int().optional(),coverBase64:u().optional()}),TTe=b({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:ny.optional()}),bX=b({plateId:u(),deviceId:r().int(),trackId:u(),timestamp:r().int(),text:u(),score:r(),corrected:v(),recognizedVehicleId:u().optional(),vehicleName:u().optional(),assigned:v(),plateBbox:ny.optional(),keyFrameMediaId:r().int().optional(),base64:u().optional(),cropUrl:u().optional(),cropMissReason:u().optional()}),ETe=b({mediaId:r().int(),kind:u(),url:u(),sizeBytes:r(),timestamp:r()}),DTe=b({plateIds:S(u()).readonly(),representativePlateId:u(),representativeText:u(),size:r().int(),cohesion:r()}),xX={name:`plate-gallery`,role:{feature:`plate-assignment`},scope:`system`,mode:`singleton`,methods:{listPlates:E(b({deviceId:r().int().optional(),limit:r().int().positive().optional(),includeCrops:v().optional()}).optional(),S(bX).readonly()),getPlateByTrack:E(b({deviceId:r().int(),trackId:u()}),bX.nullable(),{role:`viewer`}),getPlateMedia:E(b({plateId:u()}),S(ETe).readonly()),searchPlates:E(b({text:u().min(1),maxDistance:r().int().min(0).optional(),limit:r().int().positive().optional(),includeCrops:v().optional()}),S(bX).readonly()),suggestPlateClusters:E(b({maxDistance:r().int().min(0).optional(),minClusterSize:r().int().min(2).optional(),limit:r().int().positive().optional()}).optional(),S(DTe).readonly()),correctPlateText:E(b({plateId:u(),text:u().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deletePlate:E(b({plateId:u()}),_(),{kind:`mutation`,auth:`admin`}),listVehicles:E(b({includeCrops:v().optional()}).optional(),S(yX).readonly()),createVehicle:E(b({name:u().min(1)}),yX,{kind:`mutation`,auth:`admin`}),renameVehicle:E(b({id:u(),name:u().min(1)}),_(),{kind:`mutation`,auth:`admin`}),deleteVehicle:E(b({id:u()}),_(),{kind:`mutation`,auth:`admin`}),listVehicleSamples:E(b({vehicleId:u()}),S(TTe).readonly()),removeVehicleSample:E(b({vehicleId:u(),sampleId:u()}),_(),{kind:`mutation`,auth:`admin`}),moveVehicleSample:E(b({sampleId:u().min(1),toVehicleId:u().min(1)}),_(),{kind:`mutation`,auth:`admin`}),assignPlate:E(b({plateId:u(),vehicleId:u()}),_(),{kind:`mutation`,auth:`admin`}),unassignPlate:E(b({plateId:u()}),_(),{kind:`mutation`,auth:`admin`}),assignPlates:E(b({plateIds:S(u()).min(1),vehicleId:u()}),b({assigned:r().int(),failed:S(u()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignPlates:E(b({plateIds:S(u()).min(1)}),b({unassigned:r().int(),failed:S(u()).readonly()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the plate gallery — curated on its own page`}},SX={"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}}},"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}}}},CX={"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}},wX=.5,OTe=.05,TX=2e3,EX=r().nullable().transform(e=>e!==null&&Number.isFinite(e)&&e>0?e:null),DX=u().nullable().transform(e=>e!==null&&e.trim()!==``?e:null),OX=b({int8:EX,fp16:EX}),kX=b({deviceKey:u(),fullDeviceName:DX,executionUnits:EX,clockMHz:EX,gops:OX.nullable(),architecture:DX,npuName:DX,tops:EX,vendor:DX,webgpuArchitecture:DX,webgpuDevice:DX,computeUnits:EX}),kTe=b({accelerators:S(kX).nullable()}),AX=[{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*TX}},{hardwareClass:`amd-phoenix`,accelerator:`amd-igpu`,score:{metric:`cu`,value:12}}];function ATe(e){let t=kTe.safeParse(e);return!t.success||t.data.accelerators===null?null:t.data.accelerators}function jX(e){return e!==null&&e>0?e:null}function MX(e){let t=[],n=jX(e.gops?.int8??null);n!==null&&t.push({metric:`gops-int8`,value:n});let r=jX(e.gops?.fp16??null);r!==null&&t.push({metric:`gops-fp16`,value:r});let i=jX(e.executionUnits),a=jX(e.clockMHz);i!==null&&a!==null&&t.push({metric:`eu-mhz`,value:i*a});let o=jX(e.computeUnits);o!==null&&t.push({metric:`cu`,value:o});let s=jX(e.tops);return s!==null&&t.push({metric:`tops`,value:s}),t}function NX(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 PX(e,t,n){for(let r of MX(e))if(NX(t,r,n)!==null)return r;return null}function FX(e,t,n=AX){return PX(e,t,n)!==null}function IX(e,t,n){if(t!==`unknown`)return e[t]?.[n]}function jTe(e){return Math.round(e*10)/10}function MTe(e){return Math.min(2,Math.max(wX,e))}function NTe(e,t,n){let r={};for(let[i,a]of Object.entries(e))r[i]={p50Ms:jTe(a.p50Ms/t),fps:Math.max(1,Math.round(a.fps*t)),measured:!1,estimatedFrom:n};return r}function LX(e){let t=e.perf??SX,n=e.references??AX,r=IX(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:PX(e.report,e.accelerator,n);if(i===null)return r===void 0?null:{column:r,estimatedFrom:null};let a=NX(e.accelerator,i,n),o=a===null?void 0:IX(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:NTe(o,MTe(s),a.hardwareClass),estimatedFrom:a.hardwareClass}}var RX=x(Ld),PTe=x([`videotoolbox`,`cuda`,`nvdec`,`vaapi`,`qsv`,`d3d11va`,`dxva2`,`amf`,`vdpau`,`drm`,`coreml`,`tensorrt`,`openvino`,`directml`,`webgpu`,`none`]).nullable().optional(),FTe=b({preferred:S(u()).readonly(),rationale:u()}),zX=x([`h264_videotoolbox`,`hevc_videotoolbox`,`h264_vaapi`,`hevc_vaapi`,`h264_nvenc`,`hevc_nvenc`,`h264_qsv`,`hevc_qsv`,`h264_amf`,`hevc_amf`,`libx264`,`libx265`]);b({encoders:S(b({encoder:zX,codec:x([`H264`,`H265`]),family:x([`videotoolbox`,`vaapi`,`nvenc`,`qsv`,`amf`,`software`]),available:v(),reason:u().optional()})).readonly(),defaultH264:zX,defaultH265:zX,probedAt:r()}),b({methods:S(u()).readonly(),probedAt:r()});var ITe=x([`darwin`,`linux`,`win32`]),LTe=x([`arm64`,`x64`]),RTe=b({type:x([`nvidia`,`amd`,`intel`,`apple`]),name:u(),memoryMB:r().optional()}),zTe=b({type:x([`apple-ane`,`intel-npu`,`amd-xdna`]),name:u().optional(),generation:x([`xdna1`,`xdna2`]).optional()}),BX=x([`usb`,`pci`]),BTe=b({type:m(`coral-edgetpu`),bus:u().optional(),count:r().int().nonnegative().optional(),units:S(b({bus:BX,count:r().int().nonnegative()})).readonly().optional(),unavailable:S(b({bus:BX,count:r().int().nonnegative(),reason:x([`driver-missing`,`device-not-accessible`])})).readonly().optional()}),VX=b({type:m(`nvidia`),name:u(),memoryMB:r().optional()}),VTe=a(`usable`,[VX.extend({usable:m(!0)}),VX.extend({usable:m(!1),reason:x([`no-cuda-execution-provider`])})]),HX=b({platform:ITe,arch:LTe,cpuModel:u(),cpuCores:r(),totalRAM_MB:r(),availableRAM_MB:r(),gpu:RTe.nullable(),npu:zTe.nullable(),coral:BTe.nullable().optional(),nvidia:VTe.nullable().optional(),accelerators:S(kX).readonly().optional()}),UX=b({runtime:m(`python`),backend:u(),format:x([`onnx`,`coreml`,`openvino`,`tflite`]),score:r(),reason:u(),available:v()}),WX=b({key:u(),backend:u(),device:u(),format:RX,runtime:m(`python`),score:r(),available:v()}),HTe=b({hardware:HX,scores:S(UX).readonly(),bestScore:UX,pythonPath:u().nullable(),devices:S(WX).readonly()}),UTe=b({modelId:u(),name:u(),minRAM_MB:r(),accuracyScore:r(),formats:S(u()).readonly()}),WTe=b({modelId:u(),runtime:m(`python`),backend:u(),format:RX,reason:u()}),GTe=b({devices:S(WX).readonly(),appeared:S(u()).readonly(),disappeared:S(u()).readonly(),usbBus:x([`observed`,`unobservable`]),decidedBy:x([`usb-ids`,`pci`,`delegate-fallback`,`none`])}),GX={name:`platform-probe`,scope:`system`,mode:`singleton`,methods:{getCapabilities:E(_(),HTe),getHardware:E(_(),HX),resolveInferenceConfig:E(b({requirements:S(UTe).readonly()}),WTe),resolveHwAccel:E(b({prefer:PTe}),FTe),rescanAccelerators:E(_(),GTe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.CLUSTER}},KX=b({power:r().optional().meta(k(`power`,{label:`Power`})),deliveredPower:r().optional().meta(k(`power`,{label:`Delivered`})),energy:r().optional().meta(k(`energy`,{label:`Energy`})),voltage:r().optional().meta(k(`voltage`,{label:`Voltage`})),current:r().optional().meta(k(`current`,{label:`Current`})),apparentPower:r().optional().meta(k(`apparent-power`)),powerFactor:r().min(0).max(1).optional().meta(k(`ratio`)),lastFetchedAt:r()});function qX(e){if(e.power===void 0)return;let t=e.power-(e.deliveredPower??0);return t<0?void 0:t}var JX=[j.Sensor,j.Switch,j.Light,j.Fan,j.Climate,j.Humidifier,j.WaterHeater,j.MediaPlayer,j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.PetFeeder,j.Workload],KTe=JX.filter(e=>e!==j.Sensor);function YX(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`power-meter`,stateField:e},deviceTypes:KTe,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 qTe={version:1,targets:[YX(`power`,`W`),YX(`energy`,`kWh`),YX(`voltage`,`V`),YX(`current`,`A`)]},XX={name:`power-meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:JX,deviceConfig:{ui:{kind:`widget`,widgetId:`host/power-meter-line`,tab:`power`,placement:`hero`,label:`Power`,order:4}},methods:{},status:{schema:KX,kind:`push`},runtimeState:KX,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:qTe,vocabulary:{noun:I(`Power meter`,`Misuratore di energia`),order:5160,state:[{kind:`numeric`,field:`power`,quantity:I(`the power draw`,`il consumo`),label:I(`Power`,`Potenza`),unit:`W`,icon:`zap`},{kind:`numeric`,field:`energy`,quantity:I(`the energy used`,`l’energia consumata`),label:I(`Energy`,`Energia`),unit:`kWh`,icon:`zap`},{kind:`numeric`,field:`voltage`,quantity:I(`the voltage`,`la tensione`),label:I(`Voltage`,`Tensione`),unit:`V`,icon:`zap`},{kind:`numeric`,field:`current`,quantity:I(`the current`,`la corrente`),label:I(`Current`,`Corrente`),unit:`A`,icon:`zap`}]}},JTe=b({latitude:r().min(-90).max(90).meta(k(`angle`)),longitude:r().min(-180).max(180).meta(k(`angle`)),accuracyMeters:r().nonnegative().meta(k(`length`))}),ZX=b({state:u(),location:u().nullable(),gps:JTe.nullable(),lastChangedAt:r()}),QX={name:`presence`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Presence],methods:{},status:{schema:ZX,kind:`push`},runtimeState:ZX,durability:`restored`,history:`none`,volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Presence`,`Presenza`),order:5170,state:[{kind:`value`,field:`state`,label:I(`Where`,`Posizione`),phrase:I(`When {device} is at {value}`,`Quando {device} è in {value}`),icon:`map-pin`}]}},$X=b({pressure:r().nullable().meta(k(`pressure`,{precision:0})),lastFetchedAt:r()}),eZ={name:`pressure-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:$X,kind:`push`},runtimeState:$X,durability:`restored`,history:{fields:{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Pressure`,`Pressione`),order:5180,state:[{kind:`numeric`,field:`pressure`,quantity:I(`the pressure`,`la pressione`),label:I(`Pressure`,`Pressione`),unit:`hPa`,icon:`gauge`}]}},YTe=a(`kind`,[WB,GB]),tZ=b({id:r(),enabled:v(),shape:YTe}),nZ=b({enabled:v(),regions:S(tZ).nullable(),audioEnabled:v().nullable(),lastFetchedAt:r()}),rZ=b({maxRegions:r(),supportedShapes:S(JB),polygonVertices:YB.optional(),supportsAudioMute:v()}),iZ=b({enabled:v().optional(),regions:S(tZ).optional()}),aZ={name:`privacy-mask`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/privacy-mask-grid`,tab:`image`,label:`Privacy Mask`}},methods:{getOptions:E(b({deviceId:r()}),rZ),setMask:E(b({deviceId:r(),patch:iZ}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.maskOn`,label:I(`Privacy mask on`,`Maschera privacy attiva`),phrase:I(`Cover the privacy zones of {device}`,`Oscura le zone private di {device}`),icon:`eye-off`,args:{patch:{enabled:!0}}},{id:`privacy.maskOff`,label:I(`Privacy mask off`,`Maschera privacy spenta`),phrase:I(`Uncover the privacy zones of {device}`,`Scopri le zone private di {device}`),icon:`eye`,args:{patch:{enabled:!1}}}]}),setAudioEnabled:E(b({deviceId:r(),enabled:v()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.micOn`,label:I(`Microphone on`,`Microfono attivo`),phrase:I(`Turn on the microphone of {device}`,`Attiva il microfono di {device}`),icon:`mic`,args:{enabled:!0}},{id:`privacy.micOff`,label:I(`Microphone off`,`Microfono spento`),phrase:I(`Turn off the microphone of {device}`,`Disattiva il microfono di {device}`),icon:`mic-off`,args:{enabled:!1}}]})},status:{schema:nZ,kind:`poll`},runtimeState:nZ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`Privacy`,`Privacy`),order:3210,state:[{kind:`boolean`,field:`enabled`,label:I(`Privacy mask`,`Maschera privacy`),whenTrue:I(`When the privacy mask of {device} is turned on`,`Quando si attiva la maschera privacy di {device}`),whenFalse:I(`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:I(`Microphone`,`Microfono`),whenTrue:I(`When the microphone of {device} is turned on`,`Quando si attiva il microfono di {device}`),whenFalse:I(`When the microphone of {device} is turned off`,`Quando si disattiva il microfono di {device}`),icon:`mic`}]}};function XTe(e){return e.length===0?null:e.some(e=>e.audioEnabled)}var oZ=x([`home`,`day-mode`,`night-mode`,`day-night-auto`,`set-limits`,`save-limits`,`reboot`,`osd-menu`]),sZ=b({id:u(),name:u(),fn:oZ.nullable(),writable:v()}),cZ=b({pan:r().nullable(),tilt:r().nullable(),zoom:r().nullable()}),lZ=b({pan:r().optional(),tilt:r().optional(),zoom:r().optional(),speed:r().optional()}),uZ=cZ.extend({autofocus:v()}),dZ=b({hasPan:v(),hasTilt:v(),hasZoom:v(),supportsPresets:v(),maxPresets:r().optional(),hasAutofocus:v(),speedSteps:r().int().positive().nullable(),moveImpulseMs:r().int().positive().nullable()}),fZ=b({presetId:u().nullable(),source:x([`operator`,`firmware`,`native`,`none`])}),pZ=b({enabled:v(),seconds:r().int()}),mZ={name:`ptz`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-panel`,tab:`ptz`,topTab:!0,label:`PTZ`,order:0}},methods:{move:E(lZ.extend({deviceId:r()}),_(),{kind:`mutation`,notOperatorFacing:`a relative nudge from the live-view joystick; a fixed place is a preset`}),continuousMove:E(lZ.extend({deviceId:r()}),_(),{kind:`mutation`,notOperatorFacing:`joystick motion held until released — continuous, not a discrete step`}),goHome:E(b({deviceId:r()}),_(),{kind:`mutation`,actions:[{id:`ptz.goHome`,label:I(`PTZ go home`,`Torna alla posizione iniziale`),phrase:I(`Send {device} to its home position`,`Riporta {device} alla posizione iniziale`),icon:`house`}]}),getPresets:E(b({deviceId:r()}),S(sZ)),goToPreset:E(b({deviceId:r(),presetId:u()}),_(),{kind:`mutation`,actions:[{id:`ptz.goToPreset`,label:I(`PTZ go to preset`,`Vai a un preset`),phrase:I(`Move {device} to {presetId}`,`Sposta {device} su {presetId}`),icon:`move`,openArgs:[{key:`presetId`,label:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),savePreset:E(b({deviceId:r(),presetId:u(),name:u()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.savePreset`,label:I(`Save PTZ preset here`,`Salva qui un preset`),phrase:I(`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:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}},{key:`name`,label:I(`Name`,`Nome`),offer:{kind:`text`}}]}]}),deletePreset:E(b({deviceId:r(),presetId:u()}),_(),{kind:`mutation`,auth:`admin`}),getOptions:E(b({deviceId:r()}),dZ),stop:E(b({deviceId:r()}),_(),{kind:`mutation`,actions:[{id:`ptz.stop`,label:I(`Stop moving`,`Ferma il movimento`),phrase:I(`Stop {device} moving`,`Ferma il movimento di {device}`),icon:`square`}]}),getHomePreset:E(b({deviceId:r()}),fZ),setHomePreset:E(b({deviceId:r(),presetId:u().nullable()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomePreset`,label:I(`Set PTZ home preset`,`Imposta il preset iniziale`),phrase:I(`Make {presetId} the home position of {device}`,`Rendi {presetId} la posizione iniziale di {device}`),icon:`house`,openArgs:[{key:`presetId`,label:I(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),captureHomeHere:E(b({deviceId:r()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.captureHomeHere`,label:I(`Set PTZ home here`,`Imposta qui la posizione iniziale`),phrase:I(`Make where {device} points now its home position`,`Rendi la posizione attuale di {device} la sua posizione iniziale`),icon:`map-pin`}]}),getHomeReturn:E(b({deviceId:r()}),pZ.nullable()),setHomeReturn:E(b({deviceId:r(),enabled:v(),seconds:r().int().min(0).max(3600)}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomeReturn`,label:I(`Set PTZ return home`,`Imposta il ritorno alla posizione iniziale`),phrase:I(`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:I(`Return home`,`Torna alla posizione iniziale`),offer:{kind:`boolean`}},{key:`seconds`,label:I(`Idle seconds`,`Secondi da fermo`),offer:{kind:`number`,min:0,max:3600,step:1,unit:`s`}}]}]}),getPosition:E(b({deviceId:r()}),cZ),setAutofocus:E(b({deviceId:r(),enabled:v()}),_(),{kind:`mutation`,actions:[{id:`ptz.autofocusOn`,label:I(`Autofocus on`,`Autofocus attivo`),phrase:I(`Turn on autofocus on {device}`,`Attiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!0}},{id:`ptz.autofocusOff`,label:I(`Autofocus off`,`Autofocus spento`),phrase:I(`Turn off autofocus on {device}`,`Disattiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!1}}]})},status:{schema:uZ,kind:`command-driven`},vocabulary:{noun:I(`Pan / tilt / zoom`,`Brandeggio`),order:3220}},hZ=b({targetType:u().describe(`Vendor target string (people/vehicle/pet); empty = camera default`),stopDelaySeconds:r().int().min(0).max(300).meta(k(`duration`)),disappearDelaySeconds:r().int().min(0).max(300).meta(k(`duration`))}),gZ=b({value:u(),label:u()}),_Z=b({enabled:v(),lastChangedAt:r(),currentSettings:hZ.nullable(),supportedTargetTypes:S(gZ)}),vZ=_Z.extend({lastFetchedAt:r()}),yZ={name:`ptz-autotrack`,scope:`device`,deviceNative:!0,mode:`singleton`,kind:`wrapper`,defaultActive:!1,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-autotrack`,tab:`ptz`,topTab:!0,label:`Auto-Tracking`,order:5}},methods:{getStatus:E(b({deviceId:r()}),_Z),setEnabled:E(b({deviceId:r(),enabled:v()}),_(),{kind:`mutation`,actions:[{id:`ptz.autotrackOn`,label:I(`Autotrack on`,`Inseguimento attivo`),phrase:I(`Start autotracking on {device}`,`Attiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!0}},{id:`ptz.autotrackOff`,label:I(`Autotrack off`,`Inseguimento spento`),phrase:I(`Stop autotracking on {device}`,`Disattiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!1}}]}),getSettings:E(b({deviceId:r()}),hZ.nullable()),setSettings:E(b({deviceId:r(),settings:hZ.partial()}),_(),{role:`admin`,kind:`mutation`,notOperatorFacing:`tracking tuning (target type, delays) — set once on the camera’s PTZ page`})},events:{onStatusChanged:{data:b({deviceId:r(),status:_Z}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:_Z,kind:`command-driven`},runtimeState:vZ,durability:`session`,history:`none`,vocabulary:{noun:I(`Autotracking`,`Inseguimento automatico`),order:3230,state:[{kind:`boolean`,field:`enabled`,label:I(`Autotracking`,`Inseguimento automatico`),whenTrue:I(`When autotracking is turned on for {device}`,`Quando si attiva l’inseguimento automatico di {device}`),whenFalse:I(`When autotracking is turned off for {device}`,`Quando si disattiva l’inseguimento automatico di {device}`),icon:`crosshair`}]}},bZ=b({enabled:v().nullable(),onTime:r().min(0).nullable().meta(k(`duration`)),offTime:r().min(0).nullable().meta(k(`duration`)),lastFetchedAt:r()}),xZ=r().int().nonnegative(),SZ=r().int().min(0),CZ={name:`pump-cycle`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.PetFountain],methods:{setEnabled:E(b({deviceId:xZ,on:v()}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.on`,effect:{field:`enabled`,value:!0},label:I(`Pump cycle on`,`Ciclo pompa attivo`),phrase:I(`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:I(`Pump cycle off`,`Ciclo pompa spento`),phrase:I(`Run the pump of {device} continuously`,`Fai lavorare la pompa di {device} in continuo`),icon:`timer-off`,args:{on:!1}}]}),setOnMinutes:E(b({deviceId:xZ,minutes:SZ}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.onMinutes`,label:I(`Set pump run time`,`Imposta il tempo di lavoro della pompa`),phrase:I(`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:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]}),setOffMinutes:E(b({deviceId:xZ,minutes:SZ}),_(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.offMinutes`,label:I(`Set pump rest time`,`Imposta il tempo di riposo della pompa`),phrase:I(`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:I(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]})},status:{schema:bZ,kind:`push`},runtimeState:bZ,durability:`session`,history:`none`,vocabulary:{noun:I(`Pump cycle`,`Ciclo della pompa`),order:2050,state:[{kind:`boolean`,field:`enabled`,label:I(`Pump cycle`,`Ciclo pompa`),whenTrue:I(`When {device} starts running its pump on a cycle`,`Quando {device} inizia a far lavorare la pompa a ciclo`),whenFalse:I(`When {device} runs its pump continuously`,`Quando {device} fa lavorare la pompa in continuo`),icon:`timer`}]}},wZ={name:`reboot`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera,j.Sensor,j.Switch,j.Gateway],methods:{reboot:E(b({deviceId:r().int().nonnegative()}),b({success:m(!0)}),{kind:`mutation`,auth:`admin`,actions:[{id:`reboot.reboot`,label:I(`Reboot device`,`Riavvia il dispositivo`),phrase:I(`Reboot {device}`,`Riavvia {device}`),icon:`refresh-cw`}]})},vocabulary:{noun:I(`Reboot`,`Riavvio`),order:3240}},TZ=b({owner:u(),kind:Bi,title:u(),nameField:u(),fields:h(u(),C()),secretPaths:S(u()),rows:r().int().nonnegative()}),EZ=b({id:Yz,name:u(),rev:r().int(),updatedAt:r(),data:Xz}),DZ={owner:u().min(1),kind:Bi},OZ={name:`record-entries`,scope:`system`,mode:`singleton`,methods:{listEntryKinds:E(b({}),b({kinds:S(TZ)}),{auth:`admin`}),listEntries:E(b({...DZ}),b({entries:S(EZ)}),{auth:`admin`}),putEntry:E(b({...DZ,id:Yz.optional(),data:Xz,ifRev:r().int().min(1).optional()}),b({id:u(),rev:r().int()}),{kind:`mutation`,auth:`admin`}),deleteEntry:E(b({...DZ,id:Yz}),b({deleted:v()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.INTERNAL}},ZTe=`camstack`,kZ=`recorder`,AZ=b({profile:u(),startMs:r(),endMs:r()}),jZ=x([`read`,`unreadable`]),MZ=b({deviceId:r(),read:jZ,ranges:S(AZ),profilesWithFootage:S(u())}),NZ=b({deviceId:r(),read:jZ,days:S(r())}),PZ=b({deviceId:r(),localMasterPath:u().nullable(),playbackUrl:u().nullable(),playbackEndpoints:S(u())}),FZ=b({state:x([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:u().optional(),coverageAsOf:r().optional()}),IZ=b({source:u(),label:u(),addonId:u().optional(),availability:FZ}),LZ=b({transport:x([`archive`,`stream`,`realtime`]),coverage:x([`continuous`,`sparse`]),seek:x([`free`,`forward`,`segment`]),stepBack:v(),scrub:v(),rates:S(r().positive()).min(1).readonly(),exclusive:v()}),RZ=a(`kind`,[b({kind:m(`hls`),manifest:PZ}),b({kind:m(`clip`),source:u(),clipId:u(),startsAtMs:r()}),b({kind:m(`none`),reason:u()})]),zZ={name:`recording`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],methods:{listSources:E(b({deviceId:r()}),S(IZ).readonly(),{kind:`query`,auth:`protected`}),getAvailability:E(b({deviceId:r(),provider:u().min(1),fromMs:r(),toMs:r(),profile:u().optional()}),MZ,{kind:`query`,auth:`protected`}),getDaysWithRecordings:E(b({deviceId:r(),provider:u().min(1),fromMs:r(),toMs:r(),tzOffsetMinutes:r()}),NZ,{kind:`query`,auth:`protected`}),getPlayback:E(b({deviceId:r(),provider:u().min(1),fromMs:r(),toMs:r(),profile:A.optional()}),RZ,{kind:`query`,auth:`protected`}),getPlaybackOptions:E(b({deviceId:r(),provider:u().min(1)}),LZ,{kind:`query`,auth:`protected`})},vocabulary:{noun:I(`Recording`,`Registrazione`),order:3250}},BZ=b({deviceId:r(),enabled:v(),activeMode:kc,nodeId:u(),storageBytes:r()}),VZ=b({deviceId:r(),read:x([`read`,`unreadable`]),ranges:S(AZ).readonly(),profilesWithFootage:S(u()).readonly()}),HZ=b({deviceId:r(),read:x([`read`,`unreadable`]),days:S(r()).readonly()}),UZ=b({deviceId:r(),usedBytes:r(),oldestMs:r().nullable().optional(),segments:r().optional(),residentBytes:r().optional(),residentOldestMs:r().nullable().optional()}),WZ=b({locationId:u().nullable(),locationIds:S(u()).optional(),root:u().optional(),usedBytes:r(),availableBytes:r().nullable(),totalBytes:r().nullable()}),GZ=b({nodeId:u(),totalUsedBytes:r(),devices:S(UZ),devicesRead:x([`archive`,`unavailable`]).optional(),complete:v().optional(),locations:S(WZ).optional()}),KZ=b({deviceId:r(),profile:u(),fromLocationId:u(),toLocationId:u(),bytes:r(),files:r().int()}),qZ=x([`unassigned`,`target-not-writable`,`below-threshold`,`no-headroom`]),JZ=b({deviceId:r(),profile:u(),fromLocationId:u(),toLocationId:u().nullable(),bytes:r(),reason:qZ}),YZ=b({moves:S(KZ),skipped:S(JZ),bytesToMove:r(),jobIds:S(u())}),XZ=b({throttleMbps:r().min(1).max(1e3).optional(),minMoveGb:r().min(0).optional()}),QTe=b({deviceId:r().int(),profile:u(),locationId:u()}),$Te=b({deviceId:r().int(),locationId:u()}),eEe=b({assignments:S(QTe),pins:S($Te),defaultLocations:h(u(),u())}),tEe=b({deviceId:r().int(),locationId:u().nullable()}),ZZ=a(`kind`,[b({kind:m(`segment`),startMs:r(),durMs:r(),bytes:r()}),b({kind:m(`gap`),nearestEdgeMs:r().nullable(),prevEndMs:r().nullable().optional()})]),QZ=b({data:y(Uint8Array)}),$Z=b({data:y(Uint8Array),gopStartMs:r(),gopDurMs:r()}),eQ=a(`kind`,[b({kind:m(`ok`),data:y(Uint8Array),gopStartMs:r(),gopDurMs:r(),reachesRequestedEnd:v()}),b({kind:m(`spans-multiple-segments`),segmentEndMs:r()})]),tQ={name:`recording-archive`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,status:{schema:BZ,kind:`command-driven`},methods:{getAvailabilityBatch:E(b({deviceIds:S(r()).min(1).max(200),fromMs:r(),toMs:r()}),S(VZ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getDaysWithRecordingsBatch:E(b({deviceIds:S(r()).min(1).max(200),fromMs:r(),toMs:r(),tzOffsetMinutes:r()}),S(HZ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getStorageUsage:E(b({}),GZ,{kind:`query`,auth:`admin`}),getDeviceConfig:E(b({deviceId:r()}),zc,{role:`viewer`,kind:`query`,auth:`protected`}),locateSegment:E(b({deviceId:r(),profile:u(),epochMs:r()}),ZZ,{kind:`query`,auth:`admin`}),readSegmentBytes:E(b({deviceId:r(),profile:u(),startMs:r()}),QZ,{kind:`query`,auth:`admin`}),readGopBytes:E(b({deviceId:r(),profile:u(),startMs:r(),epochMs:r()}),$Z,{kind:`query`,auth:`admin`}),readWindowBytes:E(b({deviceId:r(),profile:u(),startMs:r(),fromMs:r(),toMs:r()}),eQ,{kind:`query`,auth:`admin`}),setDeviceConfig:E(b({deviceId:r(),config:zc}),zc,{kind:`mutation`,auth:`admin`}),rescanStorage:E(b({deviceId:r()}),BZ,{kind:`mutation`,auth:`admin`}),pruneFootage:E(b({deviceId:r(),reason:qs.optional()}),b({floorMs:r().nullable(),deletedBuckets:r().int(),reclaimedBytes:r().int()}),{kind:`mutation`,auth:`admin`}),deleteFootprint:E(b({deviceId:r(),fromMs:r().optional(),toMs:r().optional()}),b({deletedBuckets:r().int(),reclaimedBytes:r().int()}),{kind:`mutation`,auth:`admin`}),listOpsLog:E(Ys,S(Js).readonly(),{kind:`query`,auth:`admin`}),renderGif:E(b({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)}),b({gifBase64:u(),fromMs:r(),toMs:r()}),{kind:`mutation`,auth:`admin`}),renderClip:E(b({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)}),b({clipBase64:u(),mime:u(),fromMs:r(),toMs:r(),bytes:r().int()}),{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:E(Yc,b({paused:m(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:E(Yc,b({resumed:m(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:E(Yc,b({refreshed:m(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:E(Xc,b({jobId:u()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:E(b({jobId:u()}),Kc.nullable(),{auth:`admin`}),cancelStorageMigrationMove:E(b({jobId:u()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),relocateFootage:E(Jc,b({jobId:u()}),{kind:`mutation`,auth:`admin`}),listRelocateJobs:E(b({}),S(Kc).readonly(),{kind:`query`,auth:`admin`}),getRelocateResidue:E(Sl,Cl,{kind:`query`,auth:`admin`}),reconcileLedgerAgainstDisk:E(wl,Ol,{kind:`mutation`,auth:`admin`}),cancelRelocateJob:E(b({jobId:u()}),b({cancelled:v()}),{kind:`mutation`,auth:`admin`}),planStorageRebalance:E(XZ,YZ,{kind:`query`,auth:`admin`}),startStorageRebalance:E(XZ,YZ,{kind:`mutation`,auth:`admin`}),getPlacement:E(b({}),eEe,{kind:`query`,auth:`admin`}),setDevicePlacement:E(tEe,b({ok:m(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:O.STORAGE}},nEe=x([`queue-full`,`camera-backoff`,`sleeping`,`camera-refused`,`no-keyframe`,`decode-failed`,`no-catalog-row`,`unsupported`,`unknown-device`,`uid-missing`]),rEe=x([`deferred`,`final`]),nQ=`x-camstack-reason`;function iEe(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 rQ=`x-camstack-reason-code`,iQ=`x-camstack-disposition`,aEe=`x-camstack-clip-transport`,aQ=b({id:u(),source:u(),kind:x([`motion`,`object`,`audio`,`native`]),timeRange:b({startMs:r(),endMs:r()}),labels:S(u()).max(3).optional(),thumbnail:u().optional(),stillAtMs:r().optional(),eventIds:S(u()).optional(),eventCount:r().int().nonnegative().optional(),holes:S(b({startMs:r(),endMs:r()})).optional(),thumbnailMint:u().optional(),thumbnailUnavailable:b({reason:x([`sleeping`,`camera-refused`,`no-keyframe`,`unsupported`])}).optional(),catalogAsOf:r().optional(),nativeTypes:S(u()).optional(),behaviours:S(u()).optional(),streams:b({sub:b({id:u(),bytes:r().optional()}).optional(),main:b({id:u(),bytes:r().optional()}).optional()}).optional(),supportSub:v().optional(),playable:v().optional(),unplayableReason:u().optional(),inProgress:v().optional()}),oQ=b({playbackUrl:u(),format:x([`hls`,`mp4`]).optional(),served:A.optional(),playbackEndpoints:S(u()).optional(),token:u().optional()}),sQ=x([`authorised`]),oEe=50*1024*1024,sEe=500*1024*1024,cQ=b({base64:u(),contentType:u(),name:u(),bytes:r().int().nonnegative(),served:A,durationMs:r().positive().optional()}),lQ=b({ticket:Xa,contentType:u(),name:u(),served:A,durationMs:r().positive().optional()}),uQ=x([`opus`,`pcmu`,`none`]),dQ=x([`not-requested`,`unsupported-ask`]),fQ=b({url:u().min(1),expiresAtMs:r(),transport:m(`forward-only`),served:A,servedAudio:uQ,audioReason:dQ.optional()}),pQ=[.25,.5,1,1.5,2,4,8],mQ=[.25,.5,1,1.5,2,4],hQ=[.25,.5,1],gQ=b({transport:x([`stream`,`file`]),seek:x([`forward`,`free`]),stepBack:v(),scrub:v(),rates:S(r().positive()).min(1).readonly()}),_Q=b({state:x([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:u().optional(),catalogAsOf:r().optional()}),vQ=b({source:u(),label:u(),addonId:u().optional(),availability:_Q}),yQ={name:`videoclips`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/clips-browser`,tab:`recording`,topTab:!0,label:`Clips`,order:100}},methods:{listClips:E(b({deviceId:r(),since:r(),until:r(),limit:r().int().positive().optional(),provider:u().min(1)}),S(aQ).readonly(),{kind:`query`,auth:`protected`}),listSources:E(b({deviceId:r()}),S(vQ).readonly(),{kind:`query`,auth:`protected`}),getClipPlayback:E(b({deviceId:r(),clipId:u(),profile:A.optional()}),oQ,{kind:`query`,auth:`protected`}),readClipBytes:D(b({deviceId:r(),clipId:u().min(1),provider:u().min(1),profile:A.optional(),maxBytes:r().int().positive().optional(),wake:sQ.optional()}),cQ,{kind:`query`,auth:`protected`}),offerClipBytes:D(b({deviceId:r(),clipId:u().min(1),provider:u().min(1),profile:A.optional(),maxBytes:r().int().positive().optional(),wake:sQ.optional()}),lQ,{kind:`query`,auth:`protected`}),dialClipStream:D(b({deviceId:r(),clipId:u().min(1),provider:u().min(1),profile:A.optional(),audio:uQ.optional(),wake:sQ.optional()}),fQ,{kind:`query`,auth:`protected`}),getPlaybackOptions:D(b({deviceId:r(),provider:u().min(1)}),gQ,{kind:`query`,auth:`protected`})},vocabulary:{noun:I(`Video clips`,`Clip video`),order:3330}},cEe={stream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:mQ},realtimeStream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:hQ},file:{transport:`file`,seek:`free`,stepBack:!0,scrub:!0,rates:pQ}},bQ=r().min(.25).max(32),xQ=b({fromSec:r().nonnegative(),toSec:r().nonnegative()}).refine(e=>e.toSec>e.fromSec,{message:`dense range must have toSec > fromSec`}),SQ=b({everyMs:r().int().positive(),ranges:S(xQ).min(1).max(200)}),CQ=b({everyMs:r().int().positive(),outputFps:r().int().min(1).max(60).optional(),dense:SQ.optional()}).superRefine((e,t)=>{e.dense!==void 0&&e.dense.everyMs>=e.everyMs&&t.addIssue({code:de.custom,message:`dense.everyMs must be strictly smaller than the base everyMs`,path:[`dense`,`everyMs`]})}),wQ=b({speed:bQ.optional(),timelapse:CQ.optional(),includeAudio:v(),maxLifeMs:r().int().positive(),deleteAfterDownload:v(),title:u().max(200).optional(),notifyTargetIds:S(u().min(1)).max(20).optional()}).superRefine((e,t)=>{e.speed!==void 0&&e.timelapse!==void 0&&t.addIssue({code:de.custom,message:`speed and timelapse are mutually exclusive`,path:[`timelapse`]})}),TQ=x([`queued`,`rendering`,`ready`,`failed`,`expired`,`deleted`]),EQ=b({kind:m(`footage`),deviceId:r(),profiles:S(u()).min(1),fromMs:r(),toMs:r()}),DQ=b({kind:m(`clip`),deviceId:r(),provider:u().min(1),source:u().min(1),sourceLabel:u().min(1),clipId:u().min(1),catalogWindow:b({sinceMs:r(),untilMs:r()}),profile:x([`high`,`mid`,`low`]),wake:sQ.optional()}),OQ=a(`kind`,[EQ,DQ]),kQ=b({id:u(),deviceId:r(),profile:u(),fromMs:r(),toMs:r(),subject:OQ.optional(),options:wQ,state:TQ,progressPct:r().nullable(),fileBytes:r().nullable(),expiresAt:r(),deleteAfterDownload:v(),downloadedAt:r().nullable(),createdAt:r(),createdBy:u(),error:u().nullable()}),AQ=x([`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 lEe(e,t){return t.length>0?`${e}: ${t}`:e}function uEe(e){if(e===null)return null;let t=e.split(`:`,1)[0]??``,n=AQ.safeParse(t.trim());return n.success?n.data:null}var jQ=b({url:u(),endpoints:S(u())}),dEe=50*1024*1024,MQ=b({base64:u(),contentType:u(),name:u(),bytes:r().int().nonnegative()});function NQ(e){return e.profiles!==void 0&&e.profiles.length>0?[...e.profiles]:typeof e.profile==`string`&&e.profile.length>0?[e.profile]:[]}var fEe=b({deviceId:r(),profile:u().optional(),profiles:S(u()).min(1).optional(),fromMs:r().optional(),toMs:r().optional(),subject:OQ.optional(),options:wQ}).superRefine((e,t)=>{if(e.subject?.kind===`clip`){e.subject.deviceId!==e.deviceId&&t.addIssue({code:de.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:de.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:de.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:de.custom,message:`a footage export needs fromMs and toMs`,path:[`fromMs`]}),(e.subject?.kind===`footage`?[...e.subject.profiles]:NQ(e)).length<1&&t.addIssue({code:de.custom,message:`pass profiles[] (min 1) or legacy profile`,path:[`profiles`]})});function pEe(e){if(e.subject!==void 0)return e.subject;let t=NQ(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 mEe(e){return e.subject===void 0?{kind:`footage`,deviceId:e.deviceId,profiles:[e.profile],fromMs:e.fromMs,toMs:e.toMs}:e.subject}var PQ={name:`recording-export`,scope:`system`,mode:`singleton`,methods:{createExport:E(fEe,kQ,{role:`viewer`,kind:`mutation`,auth:`protected`}),listExports:E(b({deviceId:r().optional()}),S(kQ),{role:`viewer`,kind:`query`,auth:`protected`}),getExport:E(b({exportId:u()}),kQ,{role:`viewer`,kind:`query`,auth:`protected`}),cancelExport:E(b({exportId:u()}),kQ,{role:`viewer`,kind:`mutation`,auth:`protected`}),deleteExport:E(b({exportId:u()}),kQ,{role:`viewer`,kind:`mutation`,auth:`protected`}),getDownloadUrl:E(b({exportId:u()}),jQ,{role:`viewer`,kind:`query`,auth:`protected`}),readExportBytes:E(b({exportId:u()}),MQ,{kind:`query`,auth:`protected`})},vocabulary:{notOperatorFacing:`recording exports — requested from the timeline, not an automation step`}},FQ=x([`continuous`,`motion`,`person`,`vehicle`,`animal`,`lineCrossing`,`intrusion`,`loitering`,`alarmInput`]),IQ=b({trigger:FQ,day:r().int().min(0).max(6).meta(k(`none`)),startMinute:r().int().min(0).max(1439).meta(k(`none`)),endMinute:r().int().min(1).max(1440).meta(k(`none`))}),LQ=b({id:u(),label:u().optional(),status:x([`ok`,`unformatted`,`error`,`offline`,`unknown`]),capacityMb:r().nullable(),freeMb:r().nullable(),writable:v().optional()}),RQ=a(`kind`,[b({kind:m(`present`),volumes:S(LQ)}),b({kind:m(`absent`),reason:u()}),b({kind:m(`unknown`),reason:u()})]),zQ=b({id:u(),enabled:v(),isVideo:v(),codec:u().nullable(),resolution:u().nullable(),overwriteWhenFull:v().nullable()}),BQ=b({storage:RQ,tracks:S(zQ),primaryTrackId:u().nullable(),enabled:v().nullable(),overwriteWhenFull:v().nullable(),preRecordSec:r().nullable().meta(k(`duration`)),postRecordSec:r().nullable().meta(k(`duration`)),segmentMinutes:r().nullable().meta(k(`none`)),windows:S(IQ),unreadableWindows:r().meta(k(`count`)),recordingToNowhere:v(),lastFetchedAt:r()}),VQ=b({min:r(),max:r(),step:r()}),HQ=b({values:S(r()).min(1),sentinel:b({value:r(),meaning:x([`no-limit`,`disabled`])}).optional()}),UQ=b({readable:v(),writable:v(),reason:u().optional()}),WQ=b({support:UQ,granularityMinutes:r(),triggers:S(FQ),supportsOverlappingTriggers:v()}),GQ=b({enabled:UQ,overwriteWhenFull:UQ,preRecordSec:UQ,preRecordSecRange:VQ.optional(),preRecordSecAllowed:HQ.optional(),postRecordSec:UQ,postRecordSecRange:VQ.optional(),postRecordSecAllowed:HQ.optional(),segmentMinutes:UQ,segmentMinutesRange:VQ.optional(),segmentMinutesAllowed:HQ.optional(),schedule:WQ}),KQ=b({enabled:v().optional(),overwriteWhenFull:v().optional(),preRecordSec:r().optional(),postRecordSec:r().optional(),segmentMinutes:r().optional(),windows:S(IQ).optional()}),qQ={name:`recording-onboard`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`recording-onboard`,tab:`recording`}},methods:{getOptions:E(b({deviceId:r()}),GQ),setSettings:E(b({deviceId:r(),settings:KQ}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`recordingOnboard.on`,label:I(`On-camera recording on`,`Registrazione a bordo attiva`),phrase:I(`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:I(`On-camera recording off`,`Registrazione a bordo spenta`),phrase:I(`Turn off recording to the card of {device}`,`Disattiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!1}}}]})},status:{schema:BQ,kind:`poll`},runtimeState:BQ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:I(`On-camera recording`,`Registrazione a bordo`),order:3260,state:[{kind:`boolean`,field:`recordingToNowhere`,label:I(`Recording to nowhere`,`Registra nel vuoto`),whenTrue:I(`When {device} is recording with no card to write to`,`Quando {device} registra senza una scheda su cui scrivere`),whenFalse:I(`When {device} has a card to record to again`,`Quando {device} ha di nuovo una scheda su cui registrare`),icon:`hard-drive`}]}},JQ=b({active:v(),reason:u(),lastChangedAt:r()}),YQ=JQ.extend({lastFetchedAt:r()}),XQ={name:`recording-signal`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Camera],methods:{getStatus:E(b({deviceId:r()}),JQ)},status:{schema:JQ,kind:`push`,empty:{active:!1,reason:`unknown`,lastChangedAt:0}},runtimeState:YQ,durability:`session`,history:`none`,vocabulary:{noun:I(`Recording signal`,`Segnale di registrazione`),order:3270,state:[{kind:`boolean`,field:`active`,label:I(`Recording`,`In registrazione`),whenTrue:I(`When {device} starts recording`,`Quando {device} inizia a registrare`),whenFalse:I(`When {device} stops recording`,`Quando {device} smette di registrare`),icon:`circle-dot`}]}},ZQ=b({kind:m(`cap`),deviceId:r().int().nonnegative(),cap:u().min(1),method:u().min(1),args:h(u(),C()).optional(),argUnits:h(u(),u().min(1)).optional()}),QQ=b({action:ZQ}),$Q=b({key:u().refine($w,{message:`a lowercase slug`}),name:u().min(1).max(60)});function hEe(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=fT(a);e!==null&&s(e,`payload`)}for(let t of dT(a))Xw(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 e$=b({index:r().int().nonnegative(),id:u().nullable(),name:u().nullable(),reason:u()}),t$=b({layoutTemplateId:u().min(1).nullable(),defaultTransmitterId:r().int().nonnegative().nullable().default(null),bindings:h(u(),QQ),customButtons:S($Q).max(100),sources:S(lT).max(200).default([]),stepDelayMs:r().int().min(100).max(uT).default(500),refusedSources:S(e$).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)Xw(e)?t.addIssue({code:`custom`,message:`"${e}" is a layout widget, not a command: it cannot be bound`,path:[`bindings`,e]}):nT(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=tT(e);n!==null&&!r.has(n)&&t.addIssue({code:`custom`,message:`${e} is bound but has no entry in customButtons`,path:[`bindings`,e]})}hEe(e,t)}),gEe=le({sources:S(C())}),_Ee=b({id:u(),name:u()}).partial();function vEe(e){let t=gEe.safeParse(e);if(!t.success)return n$(t$.safeParse(e));let n=[],r=[];t.data.sources.forEach((e,t)=>{let i=lT.safeParse(e),a=i.success&&i.data.kind===`ir`?fT(i.data):null;if(i.success&&a===null){n.push(e);return}let o=_Ee.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=n$(t$.safeParse({...t.data,sources:n}));return!i.success||r.length===0?i:{success:!0,data:{...i.data,refusedSources:r}}}function n$(e){return e.success?{success:!0,data:e.data}:{success:!1,issues:e.error.issues.length}}var yEe={layoutTemplateId:null,defaultTransmitterId:null,bindings:{},customButtons:[],sources:[],stepDelayMs:500},bEe=b({power:b({state:x([`on`,`off`]),at:r()}).nullable(),muted:b({value:v(),at:r()}).nullable(),source:b({name:u(),at:r()}).nullable().default(null)}),xEe={power:null,muted:null,source:null},r$=[`rect`,`rounded`,`round`,`pill`],i$=x(r$),a$=[`neutral`,`accent`,`danger`,`red`,`green`,`yellow`,`blue`],o$=x(a$),s$=[`none`,`panel`,`divider`,`dpad`,`rocker-v`,`rocker-h`,`keypad`],c$=x(s$),l$=b({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:rT,shape:i$.optional(),tone:o$.optional(),showLegend:v().optional(),groupId:u().min(1).max(40).optional()}),u$=b({id:u().min(1).max(40),componentId:u().min(1).max(80),frame:c$,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:x([`compact`,`normal`]).optional(),hideTitle:v().optional()});function d$(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 f$(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 SEe(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&&d$(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`]),f$(n,e)||i(`button "${e.id}" lies outside its group "${n.id}"`,[`buttons`,t]);return}let a=n.find(t=>d$(t,e));a!==void 0&&i(`button "${e.id}" lies inside group "${a.id}" but is not a member`,[`buttons`,t])})}var p$=b({columns:r().int().min(1).max(24),rows:r().int().min(1).max(24),buttons:S(l$).max(200),groups:S(u$).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)}}),SEe(e,t)}),m$=b({role:rT,label:u().optional(),custom:v()}),h$=b({layoutTemplateId:u().nullable(),commands:S(m$),sources:S(lT)}),g$=[`no-remote`,`unbound-role`,`action-failed`,`unknown-source`,`unbound-step`,`undeclared-channel`,`press-timeout`,`no-transmitter`],_$=x(g$),v$=a(`status`,[b({status:m(`sent`),sends:r().int().min(1)}),b({status:m(`skipped`),reason:m(`already-in-state`)}),b({status:m(`refused`),reason:_$,detail:u().optional(),step:b({index:r().int().min(1),role:u()}).optional()})]),y$=[`play`,`pause`,`stop`,`next`,`previous`,`setMute`,`selectSource`,`playMedia`,`turnOn`,`turnOff`,`volumeUp`,`volumeDown`,`channelUp`,`channelDown`],b$=x(y$),x$=a(`status`,[...v$.options,b({status:m(`not-routed`)})]),S$=[`unknown-template`,`not-a-media-player`],C$=a(`status`,[b({status:m(`saved`)}),b({status:m(`refused`),reason:x(S$),detail:u()})]),w$=b({deviceId:r().int().nonnegative()}),CEe={version:1,targets:[{id:`remote`,cardinality:`config`,vocabulary:{cap:`remote`},deviceTypes:[j.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`}]},T$={name:`remote`,scope:`system`,mode:`singleton`,methods:{getConfig:E(w$,t$,{auth:`admin`}),setConfig:E(w$.extend({config:t$}),C$,{kind:`mutation`,auth:`admin`}),listCommands:E(w$,h$,{auth:`protected`}),sendCommand:E(w$.extend({role:rT,repeat:r().int().min(1).max(50).default(1)}),v$,{kind:`mutation`,auth:`protected`}),getAssumedStatus:E(w$,vT.nullable(),{auth:`protected`}),sendMediaCommand:E(w$.extend({command:b$,muted:v().optional(),source:u().optional(),mediaType:u().optional(),mediaId:u().optional(),repeat:r().int().min(1).max(50).default(1)}),x$,{kind:`mutation`,auth:`protected`})},customize:CEe,vocabulary:{notOperatorFacing:`the per-device remote setup — authored in the Customize remote editor, sent through the remote UI`}},E$=[`power`,`navigation`,`volume`,`numbers`,`media`,`colour`,`apps`,`layout`],D$=x(E$),wEe=/^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_-]*$/,O$=b({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:rT,icon:u().min(1).max(60).optional(),label:u().min(1).max(40).optional(),shape:i$.optional(),tone:o$.optional(),showLegend:v().optional()}),k$=b({id:u().max(80).regex(wEe,{message:`<namespace>:<name>, lowercase`}),name:u().min(1).max(60),nameI18n:b({en:u().min(1).max(60),it:u().min(1).max(60)}).optional(),icon:u().min(1).max(60),category:D$,size:b({rows:r().int().min(1).max(24),cols:r().int().min(1).max(24)}),group:b({frame:c$,title:u().min(1).max(40).optional()}).nullable(),buttons:S(O$).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&&d$(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`]})}),A$={name:`remote-layout-components`,scope:`system`,mode:`collection`,methods:{listComponents:E(b({}),S(k$),{auth:`protected`})},vocabulary:{notOperatorFacing:`the palette of the remote template editor — read-only data, never actuated`}},j$=b({deviceId:r().int().nonnegative(),resetToSource:v().optional()}),M$={name:`resync`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Container,j.Workload,j.WeatherStation],methods:{resync:E(j$,YO,{kind:`mutation`,auth:`admin`,notOperatorFacing:`device adoption — re-aligning a device with its source is an onboarding step, not an automation action`})},vocabulary:{noun:I(`Re-sync`,`Risincronizzazione`),order:3245}},N$=3e4,P$=18e4,F$={startDwellMs:N$,stopDwellMs:P$,minSamples:2},I$={[j.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}};function L$(e){return e!==void 0&&I$[e]!==void 0}function R$(e){return e===void 0?F$:I$[e]??F$}var TEe={running:null,since:null,source:`native`,phase:null,lastFetchedAt:null},z$=x([`native`,`assigned`]),B$=b({running:v().nullable(),since:r().nullable().meta(k(`none`)),source:z$.meta({label:`Source`}),phase:u().nullable(),lastFetchedAt:r().nullable()}),V$=b({deviceId:r(),since:r().nullable(),phase:u().nullable()}),EEe=Object.values(j),H$=[j.Washer,j.Dryer,j.Dishwasher,j.Vacuum,j.LawnMower,j.MediaPlayer,j.WaterHeater,j.Humidifier,j.Fan,j.Climate,j.PetFeeder],DEe={version:1,overridable:[{path:`running`,by:`running`}],targets:[{id:`running`,cardinality:`scalar`,vocabulary:{cap:`running-state`,stateField:`running`},deviceTypes:H$,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:N$,defaultStopDwellMs:P$,deviceTypeDefaults:I$,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}]},U$={name:`running-state`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:EEe,methods:{},events:{onStarted:{data:V$,trigger:{category:w.RunningStarted,label:I(`Started running`,`Ha iniziato a funzionare`),phrase:I(`When {device} starts running`,`Quando {device} inizia a funzionare`),icon:`play`}},onFinished:{data:V$,trigger:{category:w.RunningFinished,label:I(`Finished`,`Ha finito`),phrase:I(`When {device} finishes`,`Quando {device} finisce`),icon:`square`}}},status:{schema:B$,kind:`push`},runtimeState:B$,durability:`restored`,history:{fields:{running:{kind:`boolean`}}},volatileStateFields:[`lastFetchedAt`],customize:DEe,vocabulary:{noun:I(`Running`,`In funzione`),order:2120,state:[{kind:`boolean`,field:`running`,label:I(`Running`,`In funzione`),whenTrue:I(`When {device} starts`,`Quando {device} inizia`),whenFalse:I(`When {device} finishes`,`Quando {device} finisce`),icon:`play`}],overrides:{byType:{[j.Washer]:{state:{running:{whenTrue:I(`When the washing machine starts`,`Quando la lavatrice inizia`),whenFalse:I(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}},events:{onStarted:{phrase:I(`When the washing machine starts`,`Quando la lavatrice inizia`)},onFinished:{phrase:I(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}}},[j.Dryer]:{state:{running:{whenTrue:I(`When the dryer starts`,`Quando l'asciugatrice inizia`),whenFalse:I(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}},events:{onStarted:{phrase:I(`When the dryer starts`,`Quando l'asciugatrice inizia`)},onFinished:{phrase:I(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}}},[j.Dishwasher]:{state:{running:{whenTrue:I(`When the dishwasher starts`,`Quando la lavastoviglie inizia`),whenFalse:I(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}},events:{onStarted:{phrase:I(`When the dishwasher starts`,`Quando la lavastoviglie inizia`)},onFinished:{phrase:I(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}}}}}}},W$=u(),OEe=[`day`,`ir`,`night`,`dawn`,`dusk`],G$=x([`skip`,`judge-anyway`]),kEe=`__diverged__`,K$=x([`matched`,`diverged`,`unknown`]),q$=x([`no-reference-for-condition`,`view-shifted`,`no-vision-profile`,`encoder-model-changed`,`no-snapshot`]),J$=b({embedding:S(r()),modelId:u(),condition:W$,capturedAt:r(),thumbnailMediaId:r().int().optional(),anchorEmbedding:S(r()).optional()}),Y$=b({id:u(),label:u(),references:S(J$),textPrompts:S(u()).optional(),referenceCount:r(),currentlyMatched:v()}),X$=a(`mode`,[b({mode:m(`similarity`),threshold:r().min(0).max(1),hysteresisCount:r().int().positive()}),b({mode:m(`llm`),prompt:u(),profileId:u().optional(),hysteresisCount:r().int().positive()})]),Z$=.85,Q$=`skip`,$$=8e3,e1=b({enabled:v().default(!1),prompt:u().min(1).max(1e3),profileId:u().optional(),timeoutMs:r().int().min(1e3).max(2e4).default($$),maxImagePx:r().int().min(64).max(2048).default(448),onTimeout:x([`flip`,`hold`]).default(`hold`)}),t1=b({id:u(),label:u(),roi:WB,enabled:v(),triggerMode:x([`periodic`,`on-motion`,`both`]),checkIntervalSec:r().optional(),check:X$,states:S(Y$),currentStateId:u().nullable(),lastCheckedAt:r().nullable(),lastConfidence:r().nullable(),currentCondition:W$.nullable(),availability:x([`ok`,`unavailable`]),unavailableReason:u().nullable(),baselineStateId:u().nullable(),emit:x([`latched`,`live`]).default(`latched`),verdict:K$,latched:v(),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:e1.optional(),anchorThreshold:r().min(0).max(1).default(Z$),autoRestore:v().default(!1),onUncoveredCondition:G$.default(Q$),suspendedCondition:W$.nullable().default(null),unavailable:q$.nullable(),coveredConditions:S(W$)}),n1=b({monitors:S(t1),lastFetchedAt:r()}),r1=b({deviceId:r(),status:n1.nullable()}),i1={name:`scene-monitor`,role:{feature:`scenes`},scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[j.Camera],methods:{listScenes:E(b({deviceId:r()}),n1),listScenesBatch:E(b({deviceIds:S(r()).min(1).max(200)}),S(r1).readonly()),createScene:E(b({deviceId:r(),label:u(),roi:WB,check:X$,triggerMode:x([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:r().optional()}),t1,{kind:`mutation`,auth:`admin`}),updateScene:E(b({deviceId:r(),monitorId:u(),patch:b({label:u().optional(),roi:WB.optional(),enabled:v().optional(),triggerMode:x([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:r().optional(),check:X$.optional(),emit:x([`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:v().optional(),onUncoveredCondition:G$.optional(),confirm:e1.nullable().optional()})}),_(),{kind:`mutation`,auth:`admin`}),deleteScene:E(b({deviceId:r(),monitorId:u()}),_(),{kind:`mutation`,auth:`admin`}),captureReference:E(b({deviceId:r(),monitorId:u(),stateId:u().optional(),label:u().optional(),condition:W$.optional()}),b({stateId:u(),referenceCount:r()}),{kind:`mutation`,auth:`admin`}),deleteReference:E(b({deviceId:r(),monitorId:u(),stateId:u(),index:r()}),_(),{kind:`mutation`,auth:`admin`}),recheckNow:E(b({deviceId:r(),monitorId:u()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`sceneMonitor.recheck`,label:I(`Re-check a scene`,`Ricontrolla una scena`),phrase:I(`Re-check {monitorId} on {device} now`,`Ricontrolla subito {monitorId} su {device}`),icon:`scan-search`,openArgs:[{key:`monitorId`,label:I(`Scene`,`Scena`),offer:{kind:`dynamic`,from:`status`,field:`monitors`,valueKey:`id`,labelKey:`label`}}]}]}),resetScene:E(b({deviceId:r(),monitorId:u(),recapture:v().optional()}),_(),{kind:`mutation`,auth:`admin`})},status:{schema:n1,kind:`push`},runtimeState:n1,durability:`session`,history:`none`,vocabulary:{noun:I(`Scene watch`,`Controllo della scena`),order:3280,extraEvents:[{category:w.EnrichmentSceneStateChanged,label:I(`Scene changed`,`Scena cambiata`),phrase:I(`When a watched scene on {device} changes`,`Quando cambia una scena controllata su {device}`),icon:`scan-search`}]}},a1=b({schedulerId:u().min(1)}),o1={name:`schedulers`,scope:`system`,mode:`singleton`,methods:{list:E(b({}),S(p_),{auth:`admin`}),get:E(a1,b({scheduler:p_.nullable()}),{auth:`admin`}),create:E(b({scheduler:f_}),b({scheduler:p_}),{kind:`mutation`,auth:`admin`}),update:E(b({schedulerId:u().min(1),scheduler:f_}),b({scheduler:p_}),{kind:`mutation`,auth:`admin`}),delete:E(a1,_(),{kind:`mutation`,auth:`admin`}),setEnabled:E(b({schedulerId:u().min(1),profileId:u().min(1).optional(),enabled:v()}),b({scheduler:p_}),{kind:`mutation`,auth:`admin`}),preview:E(b({schedulerId:u().min(1),date:u().regex(h_).optional()}),que,{auth:`admin`}),conflicts:E(b({scheduler:f_,schedulerId:u().min(1).optional()}),b({conflicts:S(Jue)}),{auth:`admin`}),getStatus:E(b({}),S(Xue),{auth:`admin`}),getTraces:E(a1,b({traces:S(y_)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`time schedulers — authored on their own page, not device actions`}},s1=b({isRunning:v(),lastRunAt:r(),lastRunSuccess:v().nullable(),lastError:u().nullable(),lastChangedAt:r()}),c1={name:`script-runner`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Script],methods:{run:E(b({deviceId:r().int().nonnegative(),variables:h(u(),C()).optional()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.run`,label:I(`Run script`,`Esegui lo script`),phrase:I(`Run {device}`,`Esegui {device}`),icon:`scroll-text`,hold:{effects:[{field:`isRunning`,value:!0}],holdMs:MJ}}]}),stop:E(b({deviceId:r().int().nonnegative()}),_(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.stop`,effect:{field:`isRunning`,value:!1},label:I(`Stop script`,`Ferma lo script`),phrase:I(`Stop {device}`,`Ferma {device}`),icon:`square`}]})},status:{schema:s1,kind:`push`},runtimeState:s1,durability:`session`,history:`none`,vocabulary:{noun:I(`Script`,`Script`),order:2090,state:[{kind:`boolean`,field:`isRunning`,label:I(`Running`,`In esecuzione`),whenTrue:I(`When {device} starts running`,`Quando {device} parte`),whenFalse:I(`When {device} finishes`,`Quando {device} termina`),icon:`scroll-text`}]}},l1=x([`workspace`,`baked`,`data-root`]),u1=x([`idle`,`checking`,`staging`,`pending-restart`,`awaiting-confirmation`]),d1=x([`in-sync`,`behind-patch`,`behind-series`,`ahead`,`unknown`]),f1=b({state:d1,seedVersion:u().nullable(),contractVersion:u().nullable(),contractSource:x([`registry`,`running`]).nullable(),message:u()}),p1=x([`docker`,`electron`,`native`,`contradictory`,`unknown`]),m1=b({fact:x([`dockerenv-file`,`proc-1-cgroup`,`platform`,`electron-app-version-env`]),mode:x([`observed`,`declared`]),holds:v(),detail:u()}),h1=b({kind:p1,evidence:S(m1),currentVersion:u().nullable()}),g1=b({fromVersion:u(),toVersion:u().nullable(),atMs:r(),reason:u()}),_1=b({version:u(),update:b({available:v(),downloaded:v(),version:u().nullable(),checking:v(),error:u().nullable()}),stateAtMs:r(),stale:v()}),v1=x([`not-electron`,`no-app-state`,`app-state-stale`,`not-downloaded`]),y1=b({accepted:v(),reason:v1.nullable()}),b1=b({runnerId:u(),addonIds:S(u()),reason:u()}),x1=b({checkedAtMs:r(),expected:r(),running:r(),failed:S(u()),refused:S(b1),missing:S(u()),pending:S(u()).optional(),planKnown:v()}),S1=b({packageName:u(),runningVersion:u().nullable(),nodeRuntimeVersion:u().nullable(),activeVersion:u().nullable(),installedVersion:u().nullable().optional(),restartRequired:v().optional(),previousVersion:u().nullable(),seedVersion:u().nullable(),latestVersion:u().nullable(),updateAvailable:v(),bootMode:l1,updateState:u1,pendingVersion:u().nullable(),rolledBack:g1.nullable(),stateFileCorrupt:v(),lastCheckedAtMs:r().nullable(),imageContract:f1.optional(),wrapper:h1.optional(),runners:x1.optional(),desktopApp:_1.optional()}),C1=b({packageName:u(),runningVersion:u().nullable(),latestVersion:u().nullable(),updateAvailable:v(),checkedAtMs:r(),error:u().nullable(),pendingVersion:u().nullable().optional(),restartRequired:v().optional()}),w1=x([`staged`,`restart-scheduled`,`already-current`,`refused`,`failed`]),T1=b({addonId:u(),reason:u(),remedy:u()}),E1=b({accepted:v(),targetVersion:u().nullable(),restarting:v(),message:u(),outcome:w1.optional(),reason:u().nullable().optional(),error:u().nullable().optional(),blockers:S(T1).optional(),unmet:S(zr).optional(),requiredAddonUpdates:S(Br).optional()}),D1=b({heapMb:r().int().nullable(),rssBudgetMb:r().int().nullable()}),AEe=b({heapMb:r().int().min(512).max(65536).nullable(),rssBudgetMb:r().int().min(512).max(65536).nullable().optional()}),jEe=D1.extend({restartRequired:v()}),O1={name:`server-management`,scope:`system`,mode:`singleton`,methods:{getServerPackageStatus:E(_(),S1,{auth:`admin`}),checkServerUpdate:E(_(),C1,{kind:`mutation`,auth:`admin`}),applyServerUpdate:E(b({version:u().optional(),acknowledgeRefusals:v().optional()}),E1,{kind:`mutation`,auth:`admin`,timeoutMs:16*6e4}),installDesktopUpdate:E(_(),y1,{kind:`mutation`,auth:`admin`}),rollbackServerUpdate:E(_(),E1,{kind:`mutation`,auth:`admin`}),restartServer:E(_(),E1,{kind:`mutation`,auth:`admin`}),getLaunchOverrides:E(_(),D1,{auth:`admin`}),setLaunchOverrides:E(AEe,jEe,{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:O.CLUSTER}},k1={Seconds:`seconds`,Plays:`plays`},A1={Camera:`camera`,Fallback:`fallback`},j1=b({min:r().positive(),max:r().positive(),step:r().positive()}),M1=b({allowedSeconds:S(r().positive()).nullable(),rangeSeconds:j1.nullable(),defaultSeconds:r().positive(),allowedPlays:S(r().int().positive()).nullable().default(null),rangePlays:j1.nullable().default(null),defaultPlays:r().int().positive().nullable().default(null),unit:x([k1.Seconds,k1.Plays]),secondsPerPlay:r().positive().nullable(),source:x([A1.Camera,A1.Fallback]),fetchedAt:r()}),N1=b({active:v(),activeUntil:r().nullable(),durationSeconds:r().nullable(),plays:r().int().positive().nullable().default(null),activeUntilEstimated:v().default(!1),lastTriggeredAt:r()}),P1=b({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`]}),F1=N1.extend({lastFetchedAt:r()}),I1={name:`siren`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Siren],methods:{getOptions:E(b({deviceId:r().int().nonnegative()}),M1,{kind:`query`,auth:`protected`}),getPlayChoices:E(b({deviceId:r().int().nonnegative()}),S(r().int().positive()),{kind:`query`,auth:`protected`}),trigger:E(P1,N1,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.trigger`,label:I(`Sound the siren`,`Fai suonare la sirena`),phrase:I(`Sound {device}`,`Fai suonare {device}`),icon:`siren`,args:{}},{id:`siren.triggerPlays`,label:I(`Sound the siren N times`,`Fai suonare la sirena N volte`),phrase:I(`Sound {device} {plays} times`,`Fai suonare {device} {plays} volte`),icon:`siren`,openArgs:[{key:`plays`,label:I(`Plays`,`Riproduzioni`),offer:{kind:`dynamic`,from:`method`,method:`getPlayChoices`,valueKind:`number`}}]}]}),stop:E(b({deviceId:r().int().nonnegative()}),N1,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.stop`,label:I(`Silence the siren`,`Zittisci la sirena`),phrase:I(`Silence {device}`,`Zittisci {device}`),icon:`siren`,effect:{field:`active`,value:!1},args:{}}]})},events:{onSirenChanged:{data:b({deviceId:r(),active:v(),activeUntil:r().nullable()}),notOperatorFacing:"the `active` state trigger phrases both edges of this change"}},status:{schema:N1,kind:`command-driven`},runtimeState:F1,durability:`session`,history:`none`,vocabulary:{noun:I(`Siren`,`Sirena`),order:1170,state:[{kind:`boolean`,field:`active`,label:I(`Siren sounding`,`Sirena in funzione`),whenTrue:I(`When {device} starts sounding`,`Quando {device} inizia a suonare`),whenFalse:I(`When {device} falls silent`,`Quando {device} smette di suonare`),icon:`siren`}]}},L1=b({detected:v(),lastChangedAt:r()}),R1={name:`smoke`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[j.Sensor],methods:{},status:{schema:L1,kind:`push`},runtimeState:L1,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:I(`Smoke detector`,`Rilevatore di fumo`),order:5190,state:[{kind:`boolean`,field:`detected`,label:I(`Detected`,`Rilevato`),whenTrue:I(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:I(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}]}},z1=5*1024*1024,B1=`<!--camstack-images-->`,V1=b({ticket:Xa,mime:u().min(1),name:u().min(1),contentId:u().min(1),placement:x([`inline`,`attachment`]),deviceId:r().int().nonnegative().optional()}),H1=0;function U1(e){return H1+=1,`camstack_${e}_${H1.toString(36)}_${Date.now().toString(36)}`}function MEe(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,`utf8`).toString(`base64`)}?=`}function W1(e){return(Array.isArray(e)?e:[e]).join(`, `)}function NEe(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function G1(e,t){let n=e.replace(/[\r\n"]/g,``).trim();return n.length>0?n:t}function PEe(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
1111
1111
  `)}function FEe(e){return`<img src="cid:${NEe(e.contentId)}" alt="">`}function IEe(e,t){return e.replaceAll(B1,t.map(FEe).join(``))}function K1(e){let t=[`From: ${e.from}`,`To: ${W1(e.to)}`];return e.cc!==void 0&&e.cc.length>0&&t.push(`Cc: ${W1(e.cc)}`),e.bcc!==void 0&&e.bcc.length>0&&t.push(`Bcc: ${W1(e.bcc)}`),e.replyTo!==void 0&&e.replyTo.length>0&&t.push(`Reply-To: ${e.replyTo}`),t.push(`Subject: ${MEe(e.subject)}`),t.push(`MIME-Version: 1.0`),t}function q1(e,t){return[`--${e}`,`Content-Type: text/plain; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,t]}function J1(e,t){return[`--${e}`,`Content-Type: text/html; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,t]}function Y1(e,t){let n=G1(t.mime,`image/jpeg`),r=G1(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: <${G1(t.contentId,`image`)}>`),a.push(``,PEe(t.bytes)),a}function X1(e,t,n){let r=U1(`alt`);return[`--${e}`,`Content-Type: multipart/alternative; boundary="${r}"`,``,...q1(r,t),...J1(r,n),`--${r}--`]}function LEe(e,t){let n=K1(e);if(t!==void 0){let r=U1(`alt`);return n.push(`Content-Type: multipart/alternative; boundary="${r}"`,``),n.push(...q1(r,e.text),...J1(r,t),`--${r}--`),n}return n.push(`Content-Type: text/plain; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,e.text),n}function REe(e,t,n){let r=U1(`mix`),i=K1(e);i.push(`Content-Type: multipart/mixed; boundary="${r}"`,``),t===void 0?i.push(...q1(r,e.text)):i.push(...X1(r,e.text,t));for(let e of n)i.push(...Y1(r,e));return i.push(`--${r}--`),i}function zEe(e,t,n,r){let i=U1(`rel`),a=K1(e);a.push(`Content-Type: multipart/related; boundary="${i}"; type="multipart/alternative"`,``,...X1(i,e.text,t));for(let e of n)a.push(...Y1(i,e));for(let e of r)a.push(...Y1(i,e));return a.push(`--${i}--`),a}function Z1(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?IEe(e.html,n):void 0;return i!==void 0&&n.length>0?zEe(e,i,n,r).join(`\r
1112
1112
  `):r.length>0||n.length>0?REe(e,i,r.length>0?r:n).join(`\r
1113
1113
  `):LEe(e,i).join(`\r